uTox/0000700000175000001440000000000014003056553010500 5ustar rakusersuTox/tools/0000700000175000001440000000000014003056216011634 5ustar rakusersuTox/tools/update-changelog.sh0000700000175000001440000000036314003056216015404 0ustar rakusers#!/bin/sh TOKEN=$(git config --get user.token) if [ -z "$TOKEN" ]; then echo "Please add your github token to user.token" echo "Run git config --local user.token [token]" exit 1 fi github_changelog_generator -u uTox -t "$TOKEN" uTox/tools/update-bootstrap.py0000600000175000001440000001162014003056216015505 0ustar rakusers# # Update bootstrap nodes # # This script is used to generate src/tox_bootstrap.h by adding a list # of bootstrap nodes from https://nodes.tox.chat/ # # It should be executed on a regular basis (before a release) to make sure # the list is up to date and contains active bootstrap nodes. # This will make sure clients can connect to the network quickly and do not have to waste # time trying to connect to nodes that do no longer exist. # # You can run the script like this: # # python3 tools/update-bootstrap.py > src/tox_bootstrap.h # # Status information will be printed to stderr. # import http.client import json from datetime import datetime import re import sys # print for stderr def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) # check whether arg is an IP or a hostname def is_ip(ip): # these are not exactly nice patterns but the are sufficient to distinguish IP from hostname ipv4 = re.compile("^\\d+\\.\\d+\\.\\d+\\.\\d+$") ipv6 = re.compile("^[0-9a-f:]+$") return ipv4.match(ip) or ipv6.match(ip) # select a tcp port from a given range, use 443 if available def select_tcp_port(ports): if ports.count(443) > 0: return 443 else: return ports[0] # http://stackoverflow.com/questions/18854620/whats-the-best-way-to-split-a-string-into-fixed-length-chunks-and-work-with-the#18854817 def chunkstring(string, length): return (string[0+i:length+i] for i in range(0, len(string), length)) # get latest node data connection = http.client.HTTPSConnection('nodes.tox.chat') connection.request('GET', '/json') response = connection.getresponse() nodeData = response.read().decode() data = json.loads(nodeData) # print some info eprint("Last scan: " + datetime.fromtimestamp(data.get('last_scan')).isoformat(' ')) eprint("Last refresh: " + datetime.fromtimestamp(data.get('last_refresh')).isoformat(' ')) eprint("Nodes: " + len(data.get('nodes')).__str__()) # filter out offline nodes # only keep nodes that are active on tcp and udp # also filter nodes that specify a hostname instead of IP # we do not want utox to make DNS queries # some of those are on a DynDNS so it does not even make sense to do the query in this script nodes = [] for n in data.get('nodes'): if not n.get('status_udp') or not n.get('status_tcp'): continue if is_ip(n.get('ipv4')): # eprint(n.get('ipv4'), " udp: " + n.get('port').__str__(), " tcp:", *n.get('tcp_ports')) # eprint(" pkey:", n.get('public_key')) nodes.append({ 'ip': n.get('ipv4'), 'ipv6': 'false', 'udp': n.get('port'), 'tcp': select_tcp_port(n.get('tcp_ports')), 'version': n.get('version'), 'pubkey': n.get('public_key'), 'maintainer': n.get('maintainer'), 'location': n.get('location'), }) if is_ip(n.get('ipv6')): # eprint(n.get('ipv6'), " udp: " + n.get('port').__str__(), " tcp:", *n.get('tcp_ports')) # eprint(" pkey:", n.get('public_key')) nodes.append({ 'ip': n.get('ipv6'), 'ipv6': 'true', 'udp': n.get('port'), 'tcp': select_tcp_port(n.get('tcp_ports')), 'version': n.get('version'), 'pubkey': n.get('public_key'), 'maintainer': n.get('maintainer'), 'location': n.get('location'), }) eprint("filtered offline and hostname-only nodes: ", len(nodes), "candidate entries") # sort by the following criteria: # - 1. sort by version, prefer nodes that are up to date # - 2. prefer low udp port, i.e. 443 gets listed higher # - 3. prefer tcp with port 443 over tcp without it eprint("sorting by criteria...") nodes = sorted(nodes, key = lambda n: (n.get('version'), -n.get('udp'), 1 if n.get('tcp') == 443 else 0), reverse=True) #f = open("tox_bootstrap.h.test", 'w') f = sys.stdout f.write("""#ifndef TOX_BOOTSTRAP_H #define TOX_BOOTSTRAP_H // // IMPORTANT: This file is generated by the /tools/update-bootstrap.py script, do not edit manually. // struct bootstrap_node { char *address; bool ipv6; uint16_t port_udp; uint16_t port_tcp; uint8_t key[32]; } bootstrap_nodes[] = { """) # use the first 32 nodes that match the criteria above k = 0 for n in nodes: if k >= 32: break eprint("adding ", n.get('ip'), " (", n.get('udp'), n.get('tcp'), ") by", n.get('maintainer') + ', ' + n.get('location'), "version: ", n.get('version')) f.write(" /* by " + n.get('maintainer') + ', ' + n.get('location') + " */\n") f.write(' { "' + n.get('ip') + '", ' + n.get('ipv6') + ', ' + n.get('udp').__str__() + ', ' + n.get('tcp').__str__() + ",\n") f.write(" {") i = 0 for p in chunkstring(n.get('pubkey'), 2): i += 1 if i > 16: f.write("\n ") i = 0 f.write(" 0x" + p + ",") f.write(" }\n },\n") k += 1 f.write(""" }; #endif """) f.close() eprint("added", k, "nodes.") uTox/tools/timediff.py0000600000175000001440000000074014003056216014000 0ustar rakusers# Tool for GitHub CI logs to prepend time diffs between lines. # # Processes lines from stdin or from the files passed via argv. # from datetime import datetime import fileinput prevdate = datetime(1970, 1, 1) for l in fileinput.input(): datestr = l.split(maxsplit=1)[0] datestr = datestr[:-2] + datestr[-1:] # hack to limit µsec precision date = datetime.strptime(datestr, "%Y-%m-%dT%H:%M:%S.%fZ") print(f"{date - prevdate} | {l}", end='') prevdate = date uTox/tools/sign-release.sh0000700000175000001440000000216714003056216014557 0ustar rakusers#!/bin/sh # set -e TAG=$(git describe --abbrev=0 --tags) USER=${USER:-$(git config --get user.name)} VERSION=${TAG#v} echo "Going to verify and sign releases." echo "" echo "" git diff --exit-code >> /dev/null || (echo "Working Dir not clean, this script won't work." && false) echo "" echo "Getting $TAG.zip" curl -LOs "https://github.com/uTox/uTox/archive/$TAG.zip" unzip -q "$TAG.zip" cp -r "uTox-$VERSION"/* . rm -r "uTox-$VERSION" echo "Checking $TAG.zip" if git diff --exit-code >> /dev/null; then echo "PASSED $TAG.zip" gpg --armor --detach-sign "$TAG.zip" mv "$TAG.zip.asc" "uTox-$TAG.$USER.zip.asc" rm "$TAG.zip" else echo "FAILED $TAG.zip" rm "$TAG.zip" fi echo "" echo "Getting $TAG.tar.gz" curl -LOs "https://github.com/uTox/uTox/archive/$TAG.tar.gz" tar xf "$TAG.tar.gz" cp -r "uTox-$VERSION"/* . rm -r "uTox-$VERSION" echo "Checking $TAG.tar.gz" if git diff --exit-code >> /dev/null; then echo "PASSED $TAG.tar.gz" gpg --armor --detach-sign "$TAG.tar.gz" mv "$TAG.tar.gz.asc" "uTox-$TAG.$USER.tar.gz.asc" rm "$TAG.tar.gz" else echo "FAILED $TAG.tar.gz" rm "$TAG.tar.gz" fi uTox/tools/relnotes_to_cstring.sed0000700000175000001440000000110214003056216016414 0ustar rakusers#!/bin/sed -f # This is a helper script to convert release notes written in Markdown # to C-strings for langs/*.h # This is not supposed to be perfect. # (@user) s/(@\([^)]*\))/(Thanks, \1!)/ # (commit) s/ ([ 0-9a-f]\+)// # escape " s/"/\\"/g # ## (Features:) → " \1\n" s/^## \(.*\)$/" \1\\n"/ # * (Fix …) → " \1\n" s/^* \(.*\)$/" \1\\n"/ # (-…) → " \1\n" s/^[[:space:]]\+\(-.*\)$/" \1\\n"/ # **(…)** → " \1\n" [important notes] s/^\*\*\(.*\)\*\*$/" \1\\n"/ # c-string the rest s/^\([^"].*\)$/"\1\\n"/ s/^$/"\\n"/ uTox/tools/hexdump_for_chatlogs.sh0000700000175000001440000000103314003056216016374 0ustar rakusers#!/usr/bin/zsh #TODO use the author length + msglength from hexdump to gener OFFSET=(14 150 15 22 110 24 17 47 98) HEADER='1/8 "Vers : %u \n" " Time : " 1/8 "%12u \n" 1/8 " Author: %12u \n" 1/8 " MsgLen: %12u \n" 1/1 " Flags : %12u \n" 1/1 " MSGTYP: %12u \n" 1/6 " \n"' I=1 START=0 NUM=40 for len in $OFFSET; do hexdump -s $START -n $NUM -v -e $HEADER log2.txt ((START=START+40)) ((START=START+len)) ((I++)) done hexdump -s $START -n $NUM -v -e $HEADER log2.txt ((START=START+40)) ((START=START+len)) ((I++)) uTox/tools/checksum.sh0000700000175000001440000000100614003056216013772 0ustar rakusers#!/bin/sh TAG=$(git describe --abbrev=0 --tags) curl -LOs "https://github.com/uTox/uTox/archive/$TAG.zip" curl -LOs "https://github.com/uTox/uTox/archive/$TAG.tar.gz" echo echo "md5" echo "-----------------------------------------" md5sum "$TAG.zip" md5sum "$TAG.tar.gz" echo "-----------------------------------------" echo echo "sha256" echo "-----------------------------------------" sha256sum "$TAG.zip" sha256sum "$TAG.tar.gz" echo "-----------------------------------------" rm "$TAG.zip" rm "$TAG.tar.gz" uTox/tools/build-android.sh0000700000175000001440000001054714003056216014717 0ustar rakusers#!/usr/bin/env bash # read settings from a custom settings file. [ -f settings.android ] && source settings.android set -ex # You may need to change these values, to what ever your system has available DEV_VERSION="25.0.0" SDK_VERSION="android-23" NDK_VERSION="android-12" # $TOXCLIORE_LIBS is the compilation of all the required dependencies you can # scrape from build.tox.chat needed to cross compile uTox to Android, you # might choose to store them elsewhere. TOXCORE_LIBS=${TOXCORE_LIBS-./libs/android/lib} LDFLAGS=${LDFLAGS--L$TOXCORE_LIBS/} TOOLCHAIN=${TOOLCHAIN-./toolchain} BUILD_DIR=${BUILD_DIR-./build_android} # Standard dev kit locations on posix ANDROID_NDK_HOME=${ANDROID_NDK_HOME-/opt/android-ndk} ANDROID_SDK_HOME=${ANDROID_SDK_HOME-/opt/android-sdk} KEYSTORE=${KEYSTORE-~/.android/utox.keystore} SYSROOT=${SYSROOT-${ANDROID_NDK_HOME}/platforms/${NDK_VERSION}/arch-arm} AAPT=${AAPT-${ANDROID_SDK_HOME}/build-tools/${DEV_VERSION}/aapt} DX=${DX-${ANDROID_SDK_HOME}/build-tools/${DEV_VERSION}/dx} ZIPALIGN=${ZIPALIGN-$ANDROID_SDK_HOME/build-tools/${DEV_VERSION}/zipalign} mkdir -p ${BUILD_DIR}/{lib/armeabi,java} mkdir -p ./.android/ if [ $1 == "--new" ]; then rm ${BUILD_DIR}/lib/armeabi/libuTox.so || true fi if [ $1 == "--auto-CI" ]; then curl -O https://utox.io/android.tar.gz tar xf android.tar.gz fi [ -d ${TOOLCHAIN} ] || "$ANDROID_NDK_HOME/build/tools/make-standalone-toolchain.sh" \ --toolchain="arm-linux-androideabi-clang" \ --install-dir=${TOOLCHAIN}/ \ --platform=${NDK_VERSION} TOX_LIBS=${TOX_LIBS-\ $TOXCORE_LIBS/libtoxcore.a \ $TOXCORE_LIBS/libtoxav.a \ $TOXCORE_LIBS/libtoxencryptsave.a } MORE_LIBS=${MORE_LIBS-\ $TOXCORE_LIBS/libsodium.a \ $TOXCORE_LIBS/libopus.a \ $TOXCORE_LIBS/libvpx.a \ $TOXCORE_LIBS/libopenal.a \ $TOXCORE_LIBS/libfreetype.a } PLATFORM_LIBS=${PLATFORM_LIBS--llog -landroid -lEGL -lGLESv2 -lOpenSLES -lm -lz -ldl} if ! [ -f ${BUILD_DIR}/lib/armeabi/libuTox.so ]; then ${TOOLCHAIN}/bin/arm-linux-androideabi-clang -std=gnu11 \ -Wformat=0 \ -Wl,--unresolved-symbols=report-all \ -I ./toolchain/include \ -I ./libs/android/include/freetype2/ \ -I ./libs/android/include/ \ -I ./sys/ \ ${CFLAGS} \ ./src/*.c \ ./src/ui/*.c \ ./src/av/*.c \ ./src/layout/*.c \ ./src/android/*.c \ ./toxcore/toxcore/*.c \ ./toxcore/toxav/*.c \ ./toxcore/toxencryptsave/*.c \ $ANDROID_NDK_HOME/sources/android/cpufeatures/cpu-features.c \ ${LDFLAGS} \ ${MORE_LIBS} \ -o ${BUILD_DIR}/lib/armeabi/libuTox.so \ --sysroot=$SYSROOT \ ${PLATFORM_LIBS} \ -DPLATFORM_ANDROID=1 \ -shared -s fi $AAPT package -f \ -M ./src/android/AndroidManifest.xml \ -S ./src/android/res \ -I $ANDROID_SDK_HOME/platforms/${SDK_VERSION}/android.jar \ -F ${BUILD_DIR}/uTox.apk \ -J ${BUILD_DIR}/java javac \ -d ${BUILD_DIR}/java \ -source 7 \ -target 7 \ ${BUILD_DIR}/java/R.java $DX --dex \ --output="${BUILD_DIR}/classes.dex" \ ${BUILD_DIR}/java # the class path is likely hacky, but I can't be arsed to find the real fix now java \ -classpath $ANDROID_SDK_HOME/tools/lib/sdklib-25.3.0.jar \ com.android.sdklib.build.ApkBuilderMain \ ${BUILD_DIR}/uTox.unsigned.apk \ -u -z ${BUILD_DIR}/uTox.apk \ -f ${BUILD_DIR}/classes.dex \ -nf ${BUILD_DIR}/lib if [ "$1" == "--auto-CI" ]; then keytool -genkeypair -v \ -dname "cn=uToxer, ou=uTox, o=Tox, c=US" \ -keystore ./tmp.keystore \ -keyalg RSA \ -keysize 2048 \ -validity 36500 \ -alias "utox-default" \ -keypass "the default password...really?" \ -storepass "the default password...really?" jarsigner \ -sigalg SHA1withRSA \ -digestalg SHA1 \ -keystore ./tmp.keystore \ ${BUILD_DIR}/uTox.unsigned.apk \ -keypass "the default password...really?" \ -storepass "the default password...really?" \ "utox-default" else jarsigner \ -sigalg SHA1withRSA \ -digestalg SHA1 \ -keystore ${KEYSTORE} \ ${BUILD_DIR}/uTox.unsigned.apk \ utox-dev fi mv ${BUILD_DIR}/uTox.unsigned.apk ${BUILD_DIR}/uTox.signed.apk $ZIPALIGN \ -f 4 \ ${BUILD_DIR}/uTox.signed.apk \ ./uTox.ready.apk uTox/third_party/0000700000175000001440000000000014003056216013025 5ustar rakusersuTox/third_party/stb/0000700000175000001440000000000014003056216013615 5ustar rakusersuTox/third_party/stb/stb.h0000600000175000001440000000045414003056216014563 0ustar rakusers#ifndef STB_H #define STB_H #include "stb/stb_image.h" #include "stb/stb_image_write.h" // uTox uses internal stb functions. extern unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len); #endif uTox/third_party/stb/stb.c0000600000175000001440000000020414003056216014547 0ustar rakusers#define STB_IMAGE_IMPLEMENTATION #include "stb/stb_image.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb/stb_image_write.h" uTox/third_party/stb/stb/0000700000175000001440000000000014003056224014404 5ustar rakusersuTox/third_party/stb/stb/tools/0000700000175000001440000000000014003056224015544 5ustar rakusersuTox/third_party/stb/stb/tools/unicode/0000700000175000001440000000000014003056224017172 5ustar rakusersuTox/third_party/stb/stb/tools/unicode/unicode.dsp0000600000175000001440000000746614003056224021347 0ustar rakusers# Microsoft Developer Studio Project File - Name="unicode" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=unicode - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "unicode.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "unicode.mak" CFG="unicode - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "unicode - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "unicode - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "unicode - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "unicode - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "unicode - Win32 Release" # Name "unicode - Win32 Debug" # Begin Source File SOURCE=..\unicode.c # End Source File # End Target # End Project uTox/third_party/stb/stb/tools/unicode.c0000600000175000001440000005250314003056224017345 0ustar rakusers#define STB_DEFINE #include "../stb.h" // create unicode mappings // // Two kinds of mappings: // map to a number // map to a bit // // For mapping to a number, we use the following strategy: // // User supplies: // 1. a table of numbers (for now we use uint16, so full Unicode table is 4MB) // 2. a "don't care" value // 3. define a 'fallback' value (typically 0) // 4. define a fast-path range (typically 0..255 or 0..1023) [@TODO: automate detecting this] // // Code: // 1. Determine range of *end* of unicode codepoints (U+10FFFF and down) which // all have the same value (or don't care). If large enough, emit this as a // special case in the code. // 2. Repeat above, limited to at most U+FFFF. // 3. Cluster the data into intervals of 8,16,32,64,128,256 numeric values. // 3a. If all the values in an interval are fallback/dont-care, no further processing // 3b. Find the "trimmed range" outside which all the values are the fallback or don't care // 3c. Find the "special trimmed range" outside which all the values are some constant or don't care // 4. Pack the clusters into continuous memory, and find previous instances of // the cluster. Repeat for trimmed & special-trimmed. In the first case, find // previous instances of the cluster (allow don't-care to match in either // direction), both aligned and mis-aligned; in the latter, starting where // things start or mis-aligned. Build an index table specifiying the // location of each cluster (and its length). Allow an extra indirection here; // the full-sized index can index a smaller table which has the actual offset // (and lengths). // 5. Associate with each packed continuous memory above the amount of memory // required to store the data w/ smallest datatype (of uint8, uint16, uint32). // Discard the continuous memory. Recurse on each index table, but avoid the // smaller packing. // // For mapping to a bit, we pack the results for 8 characters into a byte, and then apply // the above strategy. Note that there may be more optimal approaches with e.g. packing // 8 different bits into a single structure, though, which we should explore eventually. // currently we limit *indices* to being 2^16, and we pack them as // index + end_trim*2^16 + start_trim*2^24; specials have to go in a separate table typedef uint32 uval; #define UVAL_DONT_CARE_DEFAULT 0xffffffff typedef struct { uval *input; uint32 dont_care; uint32 fallback; int fastpath; int length; int depth; int has_sign; int splittable; int replace_fallback_with_codepoint; size_t input_size; size_t inherited_storage; } table; typedef struct { int split_log2; table result; // index into not-returned table int storage; } output; typedef struct { table t; char **output_name; } info; typedef struct { size_t path; size_t size; } result; typedef struct { uint8 trim_end; uint8 trim_start; uint8 special; uint8 aligned; uint8 indirect; uint16 overhead; // add some forced overhead for each mode to avoid getting complex encoding when it doesn't save much } mode_info; mode_info modes[] = { { 0,0,0,0,0, 32, }, { 0,0,0,0,1, 100, }, { 0,0,0,1,0, 32, }, { 0,0,0,1,1, 100, }, { 0,0,1,0,1, 100, }, { 0,0,1,1,0, 32, }, { 0,0,1,1,1, 200, }, { 1,0,0,0,0, 100, }, { 1,0,0,0,1, 120, }, { 1,1,0,0,0, 100, }, { 1,1,0,0,1, 130, }, { 1,0,1,0,0, 130, }, { 1,0,1,0,1, 180, }, { 1,1,1,0,0, 180, }, { 1,1,1,0,1, 200, }, }; #define MODECOUNT (sizeof(modes)/sizeof(modes[0])) #define CLUSTERSIZECOUNT 6 // 8,16, 32,64, 128,256 size_t size_for_max_number(uint32 number) { if (number == 0) return 0; if (number < 256) return 1; if (number < 256*256) return 2; if (number < 256*256*256) return 3; return 4; } size_t size_for_max_number_aligned(uint32 number) { size_t n = size_for_max_number(number); return n == 3 ? 4 : n; } uval get_data(uval *data, int offset, uval *end) { if (data + offset >= end) return 0; else return data[offset]; } int safe_len(uval *data, int len, uval *end) { if (len > end - data) return end - data; return len; } uval tempdata[256]; int dirty=0; size_t find_packed(uval **packed, uval *data, int len, int aligned, int fastpath, uval *end, int offset, int replace) { int packlen = stb_arr_len(*packed); int i,p; if (data+len > end || replace) { int safelen = safe_len(data, len, end); memset(tempdata, 0, dirty*sizeof(tempdata[0])); memcpy(tempdata, data, safelen * sizeof(data[0])); data = tempdata; dirty = len; } if (replace) { int i; int safelen = safe_len(data, len, end); for (i=0; i < safelen; ++i) if (data[i] == 0) data[i] = offset+i; } if (len <= 0) return 0; if (!fastpath) { if (aligned) { for (i=0; i < packlen; i += len) if ((*packed)[i] == data[0] && 0==memcmp(&(*packed)[i], data, len * sizeof(uval))) return i / len; } else { for (i=0; i < packlen-len+1; i += 1 ) if ((*packed)[i] == data[0] && 0==memcmp(&(*packed)[i], data, len * sizeof(uval))) return i; } } p = stb_arr_len(*packed); for (i=0; i < len; ++i) stb_arr_push(*packed, data[i]); return p; } void output_table(char *name1, char *name2, uval *data, int length, int sign, char **names) { char temp[20]; uval maxv = 0; int bytes, numlen, at_newline; int linelen = 79; // @TODO: make table more readable by choosing a length that's a multiple? int i,pos, do_split=0; for (i=0; i < length; ++i) if (sign) maxv = stb_max(maxv, (uval)abs((int)data[i])); else maxv = stb_max(maxv, data[i]); bytes = size_for_max_number_aligned(maxv); sprintf(temp, "%d", maxv); numlen=strlen(temp); if (sign) ++numlen; if (bytes == 0) return; printf("uint%d %s%s[%d] = {\n", bytes*8, name1, name2, length); at_newline = 1; for (i=0; i < length; ++i) { if (pos + numlen + 2 > linelen) { printf("\n"); at_newline = 1; pos = 0; } if (at_newline) { printf(" "); pos = 2; at_newline = 0; } else { printf(" "); ++pos; } printf("%*d,", numlen, data[i]); pos += numlen+1; } if (!at_newline) printf("\n"); printf("};\n"); } void output_table_with_trims(char *name1, char *name2, uval *data, int length) { uval maxt=0, maxp=0; int i,d,s,e, count; // split the table into two pieces uval *trims = NULL; if (length == 0) return; for (i=0; i < stb_arr_len(data); ++i) { stb_arr_push(trims, data[i] >> 16); data[i] &= 0xffff; maxt = stb_max(maxt, trims[i]); maxp = stb_max(maxp, data[i]); } d=s=e=1; if (maxt >= 256) { // need to output start & end values if (maxp >= 256) { // can pack into a single table printf("struct { uint16 val; uint8 start, end; } %s%s[%d] = {\n", name1, name2, length); } else { output_table(name1, name2, data, length, 0, 0); d=0; printf("struct { uint8 start, end; } %s%s_trim[%d] = {\n", name1, name2, length); } } else if (maxt > 0) { if (maxp >= 256) { output_table(name1, name2, data, length, 0, 0); output_table(name1, stb_sprintf("%s_end", name2), trims, length, 0, 0); return; } else { printf("struct { uint8 val, end; } %s%s[%d] = {\n", name1, name2, length); s=0; } } else { output_table(name1, name2, data, length, 0, 0); return; } // d or s can be zero (but not both), e is always present and last count = d + s + e; assert(count >= 2 && count <= 3); { char temp[60]; uval maxv = 0; int numlen, at_newline, len; int linelen = 79; // @TODO: make table more readable by choosing a length that's a multiple? int i,pos, do_split=0; numlen = 0; for (i=0; i < length; ++i) { if (count == 2) sprintf(temp, "{%d,%d}", d ? data[i] : (trims[i]>>8), trims[i]&255); else sprintf(temp, "{%d,%d,%d}", data[i], trims[i]>>8, trims[i]&255); len = strlen(temp); numlen = stb_max(len, numlen); } at_newline = 1; for (i=0; i < length; ++i) { if (pos + numlen + 2 > linelen) { printf("\n"); at_newline = 1; pos = 0; } if (at_newline) { printf(" "); pos = 2; at_newline = 0; } else { printf(" "); ++pos; } if (count == 2) sprintf(temp, "{%d,%d}", d ? data[i] : (trims[i]>>8), trims[i]&255); else sprintf(temp, "{%d,%d,%d}", data[i], trims[i]>>8, trims[i]&255); printf("%*s,", numlen, temp); pos += numlen+1; } if (!at_newline) printf("\n"); printf("};\n"); } } int weight=1; table pack_for_mode(table *t, int mode, char *table_name) { size_t extra_size; int i; uval maxv; mode_info mi = modes[mode % MODECOUNT]; int size = 8 << (mode / MODECOUNT); table newtab; uval *packed = NULL; uval *index = NULL; uval *indirect = NULL; uval *specials = NULL; newtab.dont_care = UVAL_DONT_CARE_DEFAULT; if (table_name) printf("// clusters of %d\n", size); for (i=0; i < t->length; i += size) { uval newval; int fastpath = (i < t->fastpath); if (mi.special) { int end_trim = size-1; int start_trim = 0; uval special; // @TODO: pick special from start or end instead of only end depending on which is longer for(;;) { special = t->input[i + end_trim]; if (special != t->dont_care || end_trim == 0) break; --end_trim; } // at this point, special==inp[end_trim], and end_trim >= 0 if (special == t->dont_care && !fastpath) { // entire block is don't care, so OUTPUT don't care stb_arr_push(index, newtab.dont_care); continue; } else { uval pos, trim; if (mi.trim_end && !fastpath) { while (end_trim >= 0) { if (t->input[i + end_trim] == special || t->input[i + end_trim] == t->dont_care) --end_trim; else break; } } if (mi.trim_start && !fastpath) { while (start_trim < end_trim) { if (t->input[i + start_trim] == special || t->input[i + start_trim] == t->dont_care) ++start_trim; else break; } } // end_trim points to the last character we have to output // find the first match, or add it pos = find_packed(&packed, &t->input[i+start_trim], end_trim-start_trim+1, mi.aligned, fastpath, &t->input[t->length], i+start_trim, t->replace_fallback_with_codepoint); // encode as a uval if (!mi.trim_end) { if (end_trim == 0) pos = special; else pos = pos | 0x80000000; } else { assert(end_trim < size && end_trim >= -1); if (!fastpath) assert(end_trim < size-1); // special always matches last one assert(end_trim < size && end_trim+1 >= 0); if (!fastpath) assert(end_trim+1 < size); if (mi.trim_start) trim = start_trim*256 + (end_trim+1); else trim = end_trim+1; assert(pos < 65536); // @TODO: if this triggers, just bail on this search path pos = pos + (trim << 16); } newval = pos; stb_arr_push(specials, special); } } else if (mi.trim_end) { int end_trim = size-1; int start_trim = 0; uval pos, trim; while (end_trim >= 0 && !fastpath) if (t->input[i + end_trim] == t->fallback || t->input[i + end_trim] == t->dont_care) --end_trim; else break; if (mi.trim_start && !fastpath) { while (start_trim < end_trim) { if (t->input[i + start_trim] == t->fallback || t->input[i + start_trim] == t->dont_care) ++start_trim; else break; } } // end_trim points to the last character we have to output, and can be -1 ++end_trim; // make exclusive at end if (end_trim == 0 && size == 256) start_trim = end_trim = 1; // we can't make encode a length from 0..256 in 8 bits, so restrict end_trim to 1..256 // find the first match, or add it pos = find_packed(&packed, &t->input[i+start_trim], end_trim - start_trim, mi.aligned, fastpath, &t->input[t->length], i+start_trim, t->replace_fallback_with_codepoint); assert(end_trim <= size && end_trim >= 0); if (size == 256) assert(end_trim-1 < 256 && end_trim-1 >= 0); else assert(end_trim < 256 && end_trim >= 0); if (size == 256) --end_trim; if (mi.trim_start) trim = start_trim*256 + end_trim; else trim = end_trim; assert(pos < 65536); // @TODO: if this triggers, just bail on this search path pos = pos + (trim << 16); newval = pos; } else { newval = find_packed(&packed, &t->input[i], size, mi.aligned, fastpath, &t->input[t->length], i, t->replace_fallback_with_codepoint); } if (mi.indirect) { int j; for (j=0; j < stb_arr_len(indirect); ++j) if (indirect[j] == newval) break; if (j == stb_arr_len(indirect)) stb_arr_push(indirect, newval); stb_arr_push(index, j); } else { stb_arr_push(index, newval); } } // total up the new size for everything but the index table extra_size = mi.overhead * weight; // not the actual overhead cost; a penalty to avoid excessive complexity extra_size += 150; // per indirection if (table_name) extra_size = 0; if (t->has_sign) { // 'packed' contains two values, which should be packed positive & negative for size uval maxv2; for (i=0; i < stb_arr_len(packed); ++i) if (packed[i] & 0x80000000) maxv2 = stb_max(maxv2, packed[i]); else maxv = stb_max(maxv, packed[i]); maxv = stb_max(maxv, maxv2) << 1; } else { maxv = 0; for (i=0; i < stb_arr_len(packed); ++i) if (packed[i] > maxv && packed[i] != t->dont_care) maxv = packed[i]; } extra_size += stb_arr_len(packed) * (t->splittable ? size_for_max_number(maxv) : size_for_max_number_aligned(maxv)); if (table_name) { if (t->splittable) output_table_with_trims(table_name, "", packed, stb_arr_len(packed)); else output_table(table_name, "", packed, stb_arr_len(packed), t->has_sign, NULL); } maxv = 0; for (i=0; i < stb_arr_len(specials); ++i) if (specials[i] > maxv) maxv = specials[i]; extra_size += stb_arr_len(specials) * size_for_max_number_aligned(maxv); if (table_name) output_table(table_name, "_default", specials, stb_arr_len(specials), 0, NULL); maxv = 0; for (i=0; i < stb_arr_len(indirect); ++i) if (indirect[i] > maxv) maxv = indirect[i]; extra_size += stb_arr_len(indirect) * size_for_max_number(maxv); if (table_name && stb_arr_len(indirect)) { if (mi.trim_end) output_table_with_trims(table_name, "_index", indirect, stb_arr_len(indirect)); else { assert(0); // this case should only trigger in very extreme circumstances output_table(table_name, "_index", indirect, stb_arr_len(indirect), 0, NULL); } mi.trim_end = mi.special = 0; } if (table_name) printf("// above tables should be %d bytes\n", extra_size); maxv = 0; for (i=0; i < stb_arr_len(index); ++i) if (index[i] > maxv && index[i] != t->dont_care) maxv = index[i]; newtab.splittable = mi.trim_end; newtab.input_size = newtab.splittable ? size_for_max_number(maxv) : size_for_max_number_aligned(maxv); newtab.input = index; newtab.length = stb_arr_len(index); newtab.inherited_storage = t->inherited_storage + extra_size; newtab.fastpath = 0; newtab.depth = t->depth+1; stb_arr_free(indirect); stb_arr_free(packed); stb_arr_free(specials); return newtab; } result pack_table(table *t, size_t path, int min_storage) { int i; result best; best.size = t->inherited_storage + t->input_size * t->length; best.path = path; if ((int) t->inherited_storage > min_storage) { best.size = stb_max(best.size, t->inherited_storage); return best; } if (t->length <= 256 || t->depth >= 4) { //printf("%08x: %7d\n", best.path, best.size); return best; } path <<= 7; for (i=0; i < MODECOUNT * CLUSTERSIZECOUNT; ++i) { table newtab; result r; newtab = pack_for_mode(t, i, 0); r = pack_table(&newtab, path+i+1, min_storage); if (r.size < best.size) best = r; stb_arr_free(newtab.input); //printf("Size: %6d + %6d\n", newtab.inherited_storage, newtab.input_size * newtab.length); } return best; } int pack_table_by_modes(table *t, int *modes) { table s = *t; while (*modes > -1) { table newtab; newtab = pack_for_mode(&s, *modes, 0); if (s.input != t->input) stb_arr_free(s.input); s = newtab; ++modes; } return s.inherited_storage + s.input_size * s.length; } int strip_table(table *t, int exceptions) { uval terminal_value; int p = t->length-1; while (t->input[p] == t->dont_care) --p; terminal_value = t->input[p]; while (p >= 0x10000) { if (t->input[p] != terminal_value && t->input[p] != t->dont_care) { if (exceptions) --exceptions; else break; } --p; } return p+1; // p is a character we must output } void optimize_table(table *t, char *table_name) { int modelist[3] = { 85, -1 }; int modes[8]; int num_modes = 0; int decent_size; result r; size_t path; table s; // strip tail end of table int orig_length = t->length; int threshhold = 0xffff; int p = strip_table(t, 2); int len_saved = t->length - p; if (len_saved >= threshhold) { t->length = p; while (p > 0x10000) { p = strip_table(t, 0); len_saved = t->length - p; if (len_saved < 0x10000) break; len_saved = orig_length - p; if (len_saved < threshhold) break; threshhold *= 2; } } t->depth = 1; // find size of table if we use path 86 decent_size = pack_table_by_modes(t, modelist); #if 1 // find best packing of remainder of table by exploring tree of packings r = pack_table(t, 0, decent_size); // use the computed 'path' to evaluate and output tree path = r.path; #else path = 86;//90;//132097; #endif while (path) { modes[num_modes++] = (path & 127) - 1; path >>= 7; } printf("// modes: %d\n", r.path); s = *t; while (num_modes > 0) { char name[256]; sprintf(name, "%s_%d", table_name, num_modes+1); --num_modes; s = pack_for_mode(&s, modes[num_modes], name); } // output the final table as-is if (s.splittable) output_table_with_trims(table_name, "_1", s.input, s.length); else output_table(table_name, "_1", s.input, s.length, 0, NULL); } uval unicode_table[0x110000]; typedef struct { uval lo,hi; } char_range; char_range get_range(char *str) { char_range cr; char *p; cr.lo = strtol(str, &p, 16); p = stb_skipwhite(p); if (*p == '.') cr.hi = strtol(p+2, NULL, 16); else cr.hi = cr.lo; return cr; } char *skip_semi(char *s, int count) { while (count) { s = strchr(s, ';'); assert(s != NULL); ++s; --count; } return s; } int main(int argc, char **argv) { table t; uval maxv=0; int i,n=0; char **s = stb_stringfile("../../data/UnicodeData.txt", &n); assert(s); for (i=0; i < n; ++i) { if (s[i][0] == '#' || s[i][0] == '\n' || s[i][0] == 0) ; else { char_range cr = get_range(s[i]); char *t = skip_semi(s[i], 13); uval j, v; if (*t == ';' || *t == '\n' || *t == 0) v = 0; else { v = strtol(t, NULL, 16); if (v < 65536) { maxv = stb_max(v, maxv); for (j=cr.lo; j <= cr.hi; ++j) { unicode_table[j] = v; //printf("%06x => %06x\n", j, v); } } } } } t.depth = 0; t.dont_care = UVAL_DONT_CARE_DEFAULT; t.fallback = 0; t.fastpath = 256; t.inherited_storage = 0; t.has_sign = 0; t.splittable = 0; t.input = unicode_table; t.input_size = size_for_max_number(maxv); t.length = 0x110000; t.replace_fallback_with_codepoint = 1; optimize_table(&t, "stbu_upppercase"); return 0; } uTox/third_party/stb/stb/tools/mr.bat0000600000175000001440000000002214003056224016646 0ustar rakusersdebug\make_readme uTox/third_party/stb/stb/tools/make_readme.dsp0000600000175000001440000000776714003056224020531 0ustar rakusers# Microsoft Developer Studio Project File - Name="make_readme" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=make_readme - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "make_readme.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "make_readme.mak" CFG="make_readme - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "make_readme - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "make_readme - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "make_readme - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "make_readme - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug\make_readme" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "make_readme - Win32 Release" # Name "make_readme - Win32 Debug" # Begin Source File SOURCE=.\make_readme.c # End Source File # Begin Source File SOURCE=.\README.header.md # End Source File # Begin Source File SOURCE=.\README.list # End Source File # End Target # End Project uTox/third_party/stb/stb/tools/make_readme.c0000600000175000001440000000471714003056224020155 0ustar rakusers#define STB_DEFINE #include "../stb.h" int main(int argc, char **argv) { int i; int hlen, flen, listlen, total_lines = 0; char *header = stb_file("README.header.md", &hlen); // stb_file - read file into malloc()ed buffer char *footer = stb_file("README.footer.md", &flen); // stb_file - read file into malloc()ed buffer char **list = stb_stringfile("README.list", &listlen); // stb_stringfile - read file lines into malloced array of strings FILE *f = fopen("../README.md", "wb"); fprintf(f, "\n\n"); fwrite(header, 1, hlen, f); for (i=0; i < listlen; ++i) { int num,j; char **tokens = stb_tokens_stripwhite(list[i], "|", &num); // stb_tokens -- tokenize string into malloced array of strings int num_lines; char **lines = stb_stringfile(stb_sprintf("../%s", tokens[0]), &num_lines); char *s1, *s2,*s3; s1 = strchr(lines[0], '-'); if (!s1) stb_fatal("Couldn't find '-' before version number in %s", tokens[0]); // stb_fatal -- print error message & exit s2 = strchr(s1+2, '-'); if (!s2) stb_fatal("Couldn't find '-' after version number in %s", tokens[0]); // stb_fatal -- print error message & exit *s2 = 0; s1 += 1; s1 = stb_trimwhite(s1); // stb_trimwhite -- advance pointer to after whitespace & delete trailing whitespace if (*s1 == 'v') ++s1; s3 = tokens[0]; stb_trimwhite(s3); fprintf(f, "**["); if (strlen(s3) < 21) { fprintf(f, "%s", tokens[0]); } else { char buffer[256]; strncpy(buffer, s3, 18); buffer[18] = 0; strcat(buffer, "..."); fprintf(f, "%s", buffer); } fprintf(f, "](%s)**", tokens[0]); fprintf(f, " | %s", s1); s1 = stb_trimwhite(tokens[1]); // stb_trimwhite -- advance pointer to after whitespace & delete trailing whitespace s2 = stb_dupreplace(s1, " ", " "); // stb_dupreplace -- search & replace string and malloc result fprintf(f, " | %s", s2); free(s2); fprintf(f, " | %d", num_lines); total_lines += num_lines; for (j=2; j < num; ++j) fprintf(f, " | %s", tokens[j]); fprintf(f, "\n"); } fprintf(f, "\n"); fprintf(f, "Total libraries: %d \n", listlen); fprintf(f, "Total lines of C code: %d\n\n", total_lines); fwrite(footer, 1, flen, f); fclose(f); return 0; } uTox/third_party/stb/stb/tools/easy_font_maker.c0000600000175000001440000001205014003056224021056 0ustar rakusers// This program was used to encode the data for stb_simple_font.h #define STB_DEFINE #include "stb.h" #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" int w,h; uint8 *data; int last_x[2], last_y[2]; int num_seg[2], non_empty; #if 0 typedef struct { unsigned short first_segment; unsigned char advance; } chardata; typedef struct { unsigned char x:4; unsigned char y:4; unsigned char len:3; unsigned char dir:1; } segment; segment *segments; void add_seg(int x, int y, int len, int horizontal) { segment s; s.x = x; s.y = y; s.len = len; s.dir = horizontal; assert(s.x == x); assert(s.y == y); assert(s.len == len); stb_arr_push(segments, s); } #else typedef struct { unsigned char first_segment:8; unsigned char first_v_segment:8; unsigned char advance:5; unsigned char voff:1; } chardata; #define X_LIMIT 1 #define LEN_LIMIT 7 typedef struct { unsigned char dx:1; unsigned char y:4; unsigned char len:3; } segment; segment *segments; segment *vsegments; void add_seg(int x, int y, int len, int horizontal) { segment s; while (x - last_x[horizontal] > X_LIMIT) { add_seg(last_x[horizontal] + X_LIMIT, 0, 0, horizontal); } while (len > LEN_LIMIT) { add_seg(x, y, LEN_LIMIT, horizontal); len -= LEN_LIMIT; x += LEN_LIMIT*horizontal; y += LEN_LIMIT*!horizontal; } s.dx = x - last_x[horizontal]; s.y = y; s.len = len; non_empty += len != 0; //assert(s.x == x); assert(s.y == y); assert(s.len == len); ++num_seg[horizontal]; if (horizontal) stb_arr_push(segments, s); else stb_arr_push(vsegments, s); last_x[horizontal] = x; } void print_segments(segment *s) { int i, hpos; printf(" "); hpos = 4; for (i=0; i < stb_arr_len(s); ++i) { // repack for portability unsigned char seg = s[i].len + s[i].dx*8 + s[i].y*16; hpos += printf("%d,", seg); if (hpos > 72 && i+1 < stb_arr_len(s)) { hpos = 4; printf("\n "); } } printf("\n"); } #endif chardata charinfo[128]; int parse_char(int x, chardata *c, int offset) { int start_x = x, end_x, top_y = 0, y; c->first_segment = stb_arr_len(segments); c->first_v_segment = stb_arr_len(vsegments) - offset; assert(c->first_segment == stb_arr_len(segments)); assert(c->first_v_segment + offset == stb_arr_len(vsegments)); // find advance distance end_x = x+1; while (data[end_x*3] == 255) ++end_x; c->advance = end_x - start_x + 1; last_x[0] = last_x[1] = 0; last_y[0] = last_y[1] = 0; for (y=2; y < h; ++y) { for (x=start_x; x < end_x; ++x) { if (data[y*3*w+x*3+1] < 255) { top_y = y; break; } } if (top_y) break; } c->voff = top_y > 2; if (top_y > 2) top_y = 3; for (x=start_x; x < end_x; ++x) { int y; for (y=2; y < h; ++y) { if (data[y*3*w+x*3+1] < 255) { if (data[y*3*w+x*3+0] == 255) { // red int len=0; while (y+len < h && data[(y+len)*3*w+x*3+0] == 255 && data[(y+len)*3*w+x*3+1] == 0) { data[(y+len)*3*w+x*3+0] = 0; ++len; } add_seg(x-start_x,y-top_y,len,0); } if (data[y*3*w+x*3+2] == 255) { // blue int len=0; while (x+len < end_x && data[y*3*w+(x+len)*3+2] == 255 && data[y*3*w+(x+len)*3+1] == 0) { data[y*3*w+(x+len)*3+2] = 0; ++len; } add_seg(x-start_x,y-top_y,len,1); } } } } return end_x; } int main(int argc, char **argv) { int c, x=0; data = stbi_load("easy_font_raw.png", &w, &h, 0, 3); for (c=32; c < 127; ++c) { x = parse_char(x, &charinfo[c], 0); printf("%3d -- %3d %3d\n", c, charinfo[c].first_segment, charinfo[c].first_v_segment); } printf("===\n"); printf("%d %d %d\n", num_seg[0], num_seg[1], non_empty); printf("%d\n", sizeof(segments[0]) * stb_arr_len(segments)); printf("%d\n", sizeof(segments[0]) * stb_arr_len(segments) + sizeof(segments[0]) * stb_arr_len(vsegments) + sizeof(charinfo[32])*95); printf("struct {\n" " unsigned char advance;\n" " unsigned char h_seg;\n" " unsigned char v_seg;\n" "} stb_easy_font_charinfo[96] = {\n"); charinfo[c].first_segment = stb_arr_len(segments); charinfo[c].first_v_segment = stb_arr_len(vsegments); for (c=32; c < 128; ++c) { if ((c & 3) == 0) printf(" "); printf("{ %2d,%3d,%3d },", charinfo[c].advance + 16*charinfo[c].voff, charinfo[c].first_segment, charinfo[c].first_v_segment); if ((c & 3) == 3) printf("\n"); else printf(" "); } printf("};\n\n"); printf("unsigned char stb_easy_font_hseg[%d] = {\n", stb_arr_len(segments)); print_segments(segments); printf("};\n\n"); printf("unsigned char stb_easy_font_vseg[%d] = {\n", stb_arr_len(vsegments)); print_segments(vsegments); printf("};\n"); return 0; } uTox/third_party/stb/stb/tools/README.list0000600000175000001440000000401714003056224017402 0ustar rakusersstb_vorbis.c | audio | decode ogg vorbis files from file/memory to float/16-bit signed output stb_image.h | graphics | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC stb_truetype.h | graphics | parse, decode, and rasterize characters from truetype fonts stb_image_write.h | graphics | image writing to disk: PNG, TGA, BMP stb_image_resize.h | graphics | resize images larger/smaller with good quality stb_rect_pack.h | graphics | simple 2D rectangle packer with decent quality stb_sprintf.h | utility | fast sprintf, snprintf for C/C++ stretchy_buffer.h | utility | typesafe dynamic array for C (i.e. approximation to vector<>), doesn't compile as C++ stb_textedit.h | user interface | guts of a text editor for games etc implementing them from scratch stb_voxel_render.h | 3D graphics | Minecraft-esque voxel rendering "engine" with many more features stb_dxt.h | 3D graphics | Fabian "ryg" Giesen's real-time DXT compressor stb_perlin.h | 3D graphics | revised Perlin noise (3D input, 1D output) stb_easy_font.h | 3D graphics | quick-and-dirty easy-to-deploy bitmap font for printing frame rate, etc stb_tilemap_editor.h | game dev | embeddable tilemap editor stb_herringbone_wang_tile.h | game dev | herringbone Wang tile map generator stb_c_lexer.h | parsing | simplify writing parsers for C-like languages stb_divide.h | math | more useful 32-bit modulus e.g. "euclidean divide" stb_connected_components.h | misc | incrementally compute reachability on grids stb.h | misc | helper functions for C, mostly redundant in C++; basically author's personal stuff stb_leakcheck.h | misc | quick-and-dirty malloc/free leak-checking uTox/third_party/stb/stb/tools/README.header.md0000600000175000001440000000060214003056224020252 0ustar rakusersstb === single-file public domain (or MIT licensed) libraries for C/C++ Most libraries by stb, except: stb_dxt by Fabian "ryg" Giesen, stb_image_resize by Jorge L. "VinoBS" Rodriguez, and stb_sprintf by Jeff Roberts. library | lastest version | category | LoC | description --------------------- | ---- | -------- | --- | -------------------------------- uTox/third_party/stb/stb/tools/README.footer.md0000600000175000001440000001164614003056224020332 0ustar rakusers FAQ --- #### What's the license? These libraries are in the public domain. You can do anything you want with them. You have no legal obligation to do anything else, although I appreciate attribution. They are also licensed under the MIT open source license, if you have lawyers who are unhappy with public domain. Every source file includes an explicit dual-license for you to choose from. #### Are there other single-file public-domain/open source libraries with minimal dependencies out there? [Yes.](https://github.com/nothings/single_file_libs) #### If I wrap an stb library in a new library, does the new library have to be public domain/MIT? No, because it's public domain you can freely relicense it to whatever license your new library wants to be. #### What's the deal with SSE support in GCC-based compilers? stb_image will either use SSE2 (if you compile with -msse2) or will not use any SIMD at all, rather than trying to detect the processor at runtime and handle it correctly. As I understand it, the approved path in GCC for runtime-detection require you to use multiple source files, one for each CPU configuration. Because stb_image is a header-file library that compiles in only one source file, there's no approved way to build both an SSE-enabled and a non-SSE-enabled variation. While we've tried to work around it, we've had multiple issues over the years due to specific versions of gcc breaking what we're doing, so we've given up on it. See https://github.com/nothings/stb/issues/280 and https://github.com/nothings/stb/issues/410 for examples. #### Some of these libraries seem redundant to existing open source libraries. Are they better somehow? Generally they're only better in that they're easier to integrate, easier to use, and easier to release (single file; good API; no attribution requirement). They may be less featureful, slower, and/or use more memory. If you're already using an equivalent library, there's probably no good reason to switch. #### Can I link directly to the table of stb libraries? You can use [this URL](https://github.com/nothings/stb#stb_libs) to link directly to that list. #### Why do you list "lines of code"? It's a terrible metric. Just to give you some idea of the internal complexity of the library, to help you manage your expectations, or to let you know what you're getting into. While not all the libraries are written in the same style, they're certainly similar styles, and so comparisons between the libraries are probably still meaningful. Note though that the lines do include both the implementation, the part that corresponds to a header file, and the documentation. #### Why single-file headers? Windows doesn't have standard directories where libraries live. That makes deploying libraries in Windows a lot more painful than open source developers on Unix-derivates generally realize. (It also makes library dependencies a lot worse in Windows.) There's also a common problem in Windows where a library was built against a different version of the runtime library, which causes link conflicts and confusion. Shipping the libs as headers means you normally just compile them straight into your project without making libraries, thus sidestepping that problem. Making them a single file makes it very easy to just drop them into a project that needs them. (Of course you can still put them in a proper shared library tree if you want.) Why not two files, one a header and one an implementation? The difference between 10 files and 9 files is not a big deal, but the difference between 2 files and 1 file is a big deal. You don't need to zip or tar the files up, you don't have to remember to attach *two* files, etc. #### Why "stb"? Is this something to do with Set-Top Boxes? No, they are just the initials for my name, Sean T. Barrett. This was not chosen out of egomania, but as a moderately sane way of namespacing the filenames and source function names. #### Will you add more image types to stb_image.h? If people submit them, I generally add them, but the goal of stb_image is less for applications like image viewer apps (which need to support every type of image under the sun) and more for things like games which can choose what images to use, so I may decline to add them if they're too rare or if the size of implementation vs. apparent benefit is too low. #### Do you have any advice on how to create my own single-file library? Yes. https://github.com/nothings/stb/blob/master/docs/stb_howto.txt #### Why public domain? I prefer it over GPL, LGPL, BSD, zlib, etc. for many reasons. Some of them are listed here: https://github.com/nothings/stb/blob/master/docs/why_public_domain.md #### Why C? Primarily, because I use C, not C++. But it does also make it easier for other people to use them from other languages. #### Why not C99? stdint.h, declare-anywhere, etc. I still use MSVC 6 (1998) as my IDE because it has better human factors for me than later versions of MSVC. uTox/third_party/stb/stb/tests/0000700000175000001440000000000014003056224015546 5ustar rakusersuTox/third_party/stb/stb/tests/vorbseek/0000700000175000001440000000000014003056224017366 5ustar rakusersuTox/third_party/stb/stb/tests/vorbseek/vorbseek.dsp0000600000175000001440000000776714003056224021741 0ustar rakusers# Microsoft Developer Studio Project File - Name="vorbseek" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=vorbseek - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "vorbseek.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "vorbseek.mak" CFG="vorbseek - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "vorbseek - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "vorbseek - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "vorbseek - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /Zd /O2 /I "..\.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 !ELSEIF "$(CFG)" == "vorbseek - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "vorbseek - Win32 Release" # Name "vorbseek - Win32 Debug" # Begin Source File SOURCE=..\..\stb_vorbis.c # End Source File # Begin Source File SOURCE=.\vorbseek.c # End Source File # End Target # End Project uTox/third_party/stb/stb/tests/vorbseek/vorbseek.c0000600000175000001440000000745514003056224021367 0ustar rakusers#include #include #include #include #define STB_VORBIS_HEADER_ONLY #include "stb_vorbis.c" #define SAMPLES_TO_TEST 3000 int test_count [5] = { 5000, 3000, 2000, 50000, 50000 }; int test_spacing[5] = { 1, 111, 3337, 7779, 72717 }; int try_seeking(stb_vorbis *v, unsigned int pos, short *output, unsigned int num_samples) { int count; short samples[SAMPLES_TO_TEST*2]; assert(pos <= num_samples); if (!stb_vorbis_seek(v, pos)) { fprintf(stderr, "Seek to %u returned error from stb_vorbis\n", pos); return 0; } count = stb_vorbis_get_samples_short_interleaved(v, 2, samples, SAMPLES_TO_TEST*2); if (count > (int) (num_samples - pos)) { fprintf(stderr, "Seek to %u allowed decoding %d samples when only %d should have been valid.\n", pos, count, (int) (num_samples - pos)); return 0; } if (count < SAMPLES_TO_TEST && count < (int) (num_samples - pos)) { fprintf(stderr, "Seek to %u only decoded %d samples of %d attempted when at least %d should have been valid.\n", pos, count, SAMPLES_TO_TEST, num_samples - pos); return 0; } if (0 != memcmp(samples, output + pos*2, count*2)) { int k; for (k=0; k < SAMPLES_TO_TEST*2; ++k) { if (samples[k] != output[k]) { fprintf(stderr, "Seek to %u produced incorrect samples starting at sample %u (short #%d in buffer).\n", pos, pos + (k/2), k); break; } } assert(k != SAMPLES_TO_TEST*2); return 0; } return 1; } int main(int argc, char **argv) { int num_chan, samprate; int i, j, test, phase; short *output; if (argc == 1) { fprintf(stderr, "Usage: vorbseek {vorbisfile} [{vorbisfile]*]\n"); fprintf(stderr, "Tests various seek offsets to make sure they're sample exact.\n"); return 0; } #if 0 { // check that outofmem occurs correctly stb_vorbis_alloc va; va.alloc_buffer = malloc(1024*1024); for (i=0; i < 1024*1024; i += 10) { int error=0; stb_vorbis *v; va.alloc_buffer_length_in_bytes = i; v = stb_vorbis_open_filename(argv[1], &error, &va); if (v != NULL) break; printf("Error %d at %d\n", error, i); } } #endif for (j=1; j < argc; ++j) { unsigned int successes=0, attempts = 0; unsigned int num_samples = stb_vorbis_decode_filename(argv[j], &num_chan, &samprate, &output); break; if (num_samples == 0xffffffff) { fprintf(stderr, "Error: couldn't open file or not vorbis file: %s\n", argv[j]); goto fail; } if (num_chan != 2) { fprintf(stderr, "vorbseek testing only works with files with 2 channels, %s has %d\n", argv[j], num_chan); goto fail; } for (test=0; test < 5; ++test) { int error; stb_vorbis *v = stb_vorbis_open_filename(argv[j], &error, NULL); if (v == NULL) { fprintf(stderr, "Couldn't re-open %s for test #%d\n", argv[j], test); goto fail; } for (phase=0; phase < 3; ++phase) { unsigned int base = phase == 0 ? 0 : phase == 1 ? num_samples - test_count[test]*test_spacing[test] : num_samples/3; for (i=0; i < test_count[test]; ++i) { unsigned int pos = base + i*test_spacing[test]; if (pos > num_samples) // this also catches underflows continue; successes += try_seeking(v, pos, output, num_samples); attempts += 1; } } stb_vorbis_close(v); } printf("%d of %d seeks failed in %s (%d samples)\n", attempts-successes, attempts, argv[j], num_samples); free(output); } return 0; fail: return 1; }uTox/third_party/stb/stb/tests/tilemap_editor_integration_example.c0000600000175000001440000001432014003056224025033 0ustar rakusers// This isn't compilable as-is, as it was extracted from a working // integration-in-a-game and makes reference to symbols from that game. #include #include #include "game.h" #include "SDL.h" #include "stb_tilemap_editor.h" extern void editor_draw_tile(int x, int y, unsigned short tile, int mode, float *props); extern void editor_draw_rect(int x0, int y0, int x1, int y1, unsigned char r, unsigned char g, unsigned char b); static int is_platform(short *tiles); static unsigned int prop_type(int n, short *tiles); static char *prop_name(int n, short *tiles); static float prop_range(int n, short *tiles, int is_max); static int allow_link(short *src, short *dest); #define STBTE_MAX_PROPERTIES 8 #define STBTE_PROP_TYPE(n, tiledata, p) prop_type(n,tiledata) #define STBTE_PROP_NAME(n, tiledata, p) prop_name(n,tiledata) #define STBTE_PROP_MIN(n, tiledata, p) prop_range(n,tiledata,0) #define STBTE_PROP_MAX(n, tiledata, p) prop_range(n,tiledata,1) #define STBTE_PROP_FLOAT_SCALE(n,td,p) (0.1) #define STBTE_ALLOW_LINK(srctile, srcprop, desttile, destprop) \ allow_link(srctile, desttile) #define STBTE_LINK_COLOR(srctile, srcprop, desttile, destprop) \ (is_platform(srctile) ? 0xff80ff : 0x808040) #define STBTE_DRAW_RECT(x0,y0,x1,y1,c) \ editor_draw_rect(x0,y0,x1,y1,(c)>>16,((c)>>8)&255,(c)&255) #define STBTE_DRAW_TILE(x,y,id,highlight,props) \ editor_draw_tile(x,y,id,highlight,props) #define STB_TILEMAP_EDITOR_IMPLEMENTATION #include "stb_tilemap_editor.h" stbte_tilemap *edit_map; void editor_key(enum stbte_action act) { stbte_action(edit_map, act); } void editor_process_sdl_event(SDL_Event *e) { switch (e->type) { case SDL_MOUSEMOTION: case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: case SDL_MOUSEWHEEL: stbte_mouse_sdl(edit_map, e, 1.0f/editor_scale,1.0f/editor_scale,0,0); break; case SDL_KEYDOWN: if (in_editor) { switch (e->key.keysym.sym) { case SDLK_RIGHT: editor_key(STBTE_scroll_right); break; case SDLK_LEFT : editor_key(STBTE_scroll_left ); break; case SDLK_UP : editor_key(STBTE_scroll_up ); break; case SDLK_DOWN : editor_key(STBTE_scroll_down ); break; } switch (e->key.keysym.scancode) { case SDL_SCANCODE_S: editor_key(STBTE_tool_select); break; case SDL_SCANCODE_B: editor_key(STBTE_tool_brush ); break; case SDL_SCANCODE_E: editor_key(STBTE_tool_erase ); break; case SDL_SCANCODE_R: editor_key(STBTE_tool_rectangle ); break; case SDL_SCANCODE_I: editor_key(STBTE_tool_eyedropper); break; case SDL_SCANCODE_L: editor_key(STBTE_tool_link); break; case SDL_SCANCODE_G: editor_key(STBTE_act_toggle_grid); break; } if ((e->key.keysym.mod & KMOD_CTRL) && !(e->key.keysym.mod & ~KMOD_CTRL)) { switch (e->key.keysym.scancode) { case SDL_SCANCODE_X: editor_key(STBTE_act_cut ); break; case SDL_SCANCODE_C: editor_key(STBTE_act_copy ); break; case SDL_SCANCODE_V: editor_key(STBTE_act_paste); break; case SDL_SCANCODE_Z: editor_key(STBTE_act_undo ); break; case SDL_SCANCODE_Y: editor_key(STBTE_act_redo ); break; } } } break; } } void editor_init(void) { int i; edit_map = stbte_create_map(20,14, 8, 16,16, 100); stbte_set_background_tile(edit_map, T_empty); for (i=0; i < T__num_types; ++i) { if (i != T_reserved1 && i != T_entry && i != T_doorframe) stbte_define_tile(edit_map, 0+i, 1, "Background"); } stbte_define_tile(edit_map, 256+O_player , 8, "Char"); stbte_define_tile(edit_map, 256+O_robot , 8, "Char"); for (i=O_lockeddoor; i < O__num_types-2; ++i) if (i == O_platform || i == O_vplatform) stbte_define_tile(edit_map, 256+i, 4, "Object"); else stbte_define_tile(edit_map, 256+i, 2, "Object"); //stbte_set_layername(edit_map, 0, "background"); //stbte_set_layername(edit_map, 1, "objects"); //stbte_set_layername(edit_map, 2, "platforms"); //stbte_set_layername(edit_map, 3, "characters"); } static int is_platform(short *tiles) { // platforms are only on layer #2 return tiles[2] == 256 + O_platform || tiles[2] == 256 + O_vplatform; } static int is_object(short *tiles) { return (tiles[1] >= 256 || tiles[2] >= 256 || tiles[3] >= 256); } static unsigned int prop_type(int n, short *tiles) { if (is_platform(tiles)) { static unsigned int platform_types[STBTE_MAX_PROPERTIES] = { STBTE_PROP_bool, // phantom STBTE_PROP_int, // x_adjust STBTE_PROP_int, // y_adjust STBTE_PROP_float, // width STBTE_PROP_float, // lspeed STBTE_PROP_float, // rspeed STBTE_PROP_bool, // autoreturn STBTE_PROP_bool, // one-shot // remainder get 0, means 'no property in this slot' }; return platform_types[n]; } else if (is_object(tiles)) { if (n == 0) return STBTE_PROP_bool; } return 0; } static char *prop_name(int n, short *tiles) { if (is_platform(tiles)) { static char *platform_vars[STBTE_MAX_PROPERTIES] = { "phantom", "x_adjust", "y_adjust", "width", "lspeed", "rspeed", "autoreturn", "one-shot", }; return platform_vars[n]; } return "phantom"; } static float prop_range(int n, short *tiles, int is_max) { if (is_platform(tiles)) { static float ranges[8][2] = { { 0, 1 }, // phantom-flag, range is ignored { -15, 15 }, // x_adjust { -15, 15 }, // y_adjust { 0, 6 }, // width { 0, 10 }, // lspeed { 0, 10 }, // rspeed { 0, 1 }, // autoreturn, range is ignored { 0, 1 }, // one-shot, range is ignored }; return ranges[n][is_max]; } return 0; } static int allow_link(short *src, short *dest) { if (is_platform(src)) return dest[1] == 256+O_lever; if (src[1] == 256+O_endpoint) return is_platform(dest); return 0; } uTox/third_party/stb/stb/tests/textedit_sample.c0000600000175000001440000000664314003056224021120 0ustar rakusers// I haven't actually tested this yet, this is just to make sure it compiles #include #include // memmove #include // isspace #define STB_TEXTEDIT_CHARTYPE char #define STB_TEXTEDIT_STRING text_control // get the base type #include "stb_textedit.h" // define our editor structure typedef struct { char *string; int stringlen; STB_TexteditState state; } text_control; // define the functions we need void layout_func(StbTexteditRow *row, STB_TEXTEDIT_STRING *str, int start_i) { int remaining_chars = str->stringlen - start_i; row->num_chars = remaining_chars > 20 ? 20 : remaining_chars; // should do real word wrap here row->x0 = 0; row->x1 = 20; // need to account for actual size of characters row->baseline_y_delta = 1.25; row->ymin = -1; row->ymax = 0; } int delete_chars(STB_TEXTEDIT_STRING *str, int pos, int num) { memmove(&str->string[pos], &str->string[pos+num], str->stringlen - (pos+num)); str->stringlen -= num; return 1; // always succeeds } int insert_chars(STB_TEXTEDIT_STRING *str, int pos, STB_TEXTEDIT_CHARTYPE *newtext, int num) { str->string = realloc(str->string, str->stringlen + num); memmove(&str->string[pos+num], &str->string[pos], str->stringlen - pos); memcpy(&str->string[pos], newtext, num); str->stringlen += num; return 1; // always succeeds } // define all the #defines needed #define KEYDOWN_BIT 0x80000000 #define STB_TEXTEDIT_STRINGLEN(tc) ((tc)->stringlen) #define STB_TEXTEDIT_LAYOUTROW layout_func #define STB_TEXTEDIT_GETWIDTH(tc,n,i) (1) // quick hack for monospaced #define STB_TEXTEDIT_KEYTOTEXT(key) (((key) & KEYDOWN_BIT) ? 0 : (key)) #define STB_TEXTEDIT_GETCHAR(tc,i) ((tc)->string[i]) #define STB_TEXTEDIT_NEWLINE '\n' #define STB_TEXTEDIT_IS_SPACE(ch) isspace(ch) #define STB_TEXTEDIT_DELETECHARS delete_chars #define STB_TEXTEDIT_INSERTCHARS insert_chars #define STB_TEXTEDIT_K_SHIFT 0x40000000 #define STB_TEXTEDIT_K_CONTROL 0x20000000 #define STB_TEXTEDIT_K_LEFT (KEYDOWN_BIT | 1) // actually use VK_LEFT, SDLK_LEFT, etc #define STB_TEXTEDIT_K_RIGHT (KEYDOWN_BIT | 2) // VK_RIGHT #define STB_TEXTEDIT_K_UP (KEYDOWN_BIT | 3) // VK_UP #define STB_TEXTEDIT_K_DOWN (KEYDOWN_BIT | 4) // VK_DOWN #define STB_TEXTEDIT_K_LINESTART (KEYDOWN_BIT | 5) // VK_HOME #define STB_TEXTEDIT_K_LINEEND (KEYDOWN_BIT | 6) // VK_END #define STB_TEXTEDIT_K_TEXTSTART (STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_CONTROL) #define STB_TEXTEDIT_K_TEXTEND (STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_CONTROL) #define STB_TEXTEDIT_K_DELETE (KEYDOWN_BIT | 7) // VK_DELETE #define STB_TEXTEDIT_K_BACKSPACE (KEYDOWN_BIT | 8) // VK_BACKSPACE #define STB_TEXTEDIT_K_UNDO (KEYDOWN_BIT | STB_TEXTEDIT_K_CONTROL | 'z') #define STB_TEXTEDIT_K_REDO (KEYDOWN_BIT | STB_TEXTEDIT_K_CONTROL | 'y') #define STB_TEXTEDIT_K_INSERT (KEYDOWN_BIT | 9) // VK_INSERT #define STB_TEXTEDIT_K_WORDLEFT (STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_CONTROL) #define STB_TEXTEDIT_K_WORDRIGHT (STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_CONTROL) #define STB_TEXTEDIT_K_PGUP (KEYDOWN_BIT | 10) // VK_PGUP -- not implemented #define STB_TEXTEDIT_K_PGDOWN (KEYDOWN_BIT | 11) // VK_PGDOWN -- not implemented #define STB_TEXTEDIT_IMPLEMENTATION #include "stb_textedit.h" uTox/third_party/stb/stb/tests/test_vorbis.c0000600000175000001440000000103414003056224020255 0ustar rakusers#define STB_IMAGE_STATIC #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" #define STB_VORBIS_HEADER_ONLY #include "stb_vorbis.c" #include "stb.h" extern void stb_vorbis_dumpmem(void); #ifdef VORBIS_TEST int main(int argc, char **argv) { size_t memlen; unsigned char *mem = stb_fileu("c:/x/sketch008.ogg", &memlen); int chan, samplerate; short *output; int samples = stb_vorbis_decode_memory(mem, memlen, &chan, &samplerate, &output); stb_filewrite("c:/x/sketch008.raw", output, samples*4); return 0; } #endif uTox/third_party/stb/stb/tests/test_truetype.c0000600000175000001440000000567214003056224020646 0ustar rakusers#include "stb_rect_pack.h" #define STB_TRUETYPE_IMPLEMENTATION #include "stb_truetype.h" #include "stb_image_write.h" #ifdef TT_TEST #include char ttf_buffer[1<<25]; unsigned char output[512*100]; void debug(void) { stbtt_fontinfo font; fread(ttf_buffer, 1, 1<<25, fopen("c:/x/lm/LiberationMono-Regular.ttf", "rb")); stbtt_InitFont(&font, ttf_buffer, 0); stbtt_MakeGlyphBitmap(&font, output, 6, 9, 512, 5.172414E-03f, 5.172414E-03f, 54); } #define BITMAP_W 256 #define BITMAP_H 512 unsigned char temp_bitmap[BITMAP_H][BITMAP_W]; stbtt_bakedchar cdata[256*2]; // ASCII 32..126 is 95 glyphs stbtt_packedchar pdata[256*2]; int main(int argc, char **argv) { stbtt_fontinfo font; unsigned char *bitmap; int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 34807), s = (argc > 2 ? atoi(argv[2]) : 32); //debug(); // @TODO: why is minglui.ttc failing? fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/mingliu.ttc", "rb")); //fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/x/DroidSansMono.ttf", "rb")); { static stbtt_pack_context pc; static stbtt_packedchar cd[256]; static unsigned char atlas[1024*1024]; stbtt_PackBegin(&pc, atlas, 1024,1024,1024,1,NULL); stbtt_PackFontRange(&pc, ttf_buffer, 0, 32.0, 0, 256, cd); stbtt_PackEnd(&pc); } #if 0 stbtt_BakeFontBitmap(ttf_buffer,stbtt_GetFontOffsetForIndex(ttf_buffer,0), 40.0, temp_bitmap[0],BITMAP_W,BITMAP_H, 32,96, cdata); // no guarantee this fits! stbi_write_png("fonttest1.png", BITMAP_W, BITMAP_H, 1, temp_bitmap, 0); { stbtt_pack_context pc; stbtt_PackBegin(&pc, temp_bitmap[0], BITMAP_W, BITMAP_H, 0, 1, NULL); stbtt_PackFontRange(&pc, ttf_buffer, 0, 20.0, 32, 95, pdata); stbtt_PackFontRange(&pc, ttf_buffer, 0, 20.0, 0xa0, 0x100-0xa0, pdata); stbtt_PackEnd(&pc); stbi_write_png("fonttest2.png", BITMAP_W, BITMAP_H, 1, temp_bitmap, 0); } { stbtt_pack_context pc; stbtt_pack_range pr[2]; stbtt_PackBegin(&pc, temp_bitmap[0], BITMAP_W, BITMAP_H, 0, 1, NULL); pr[0].chardata_for_range = pdata; pr[0].first_unicode_char_in_range = 32; pr[0].num_chars_in_range = 95; pr[0].font_size = 20.0f; pr[1].chardata_for_range = pdata+256; pr[1].first_unicode_char_in_range = 0xa0; pr[1].num_chars_in_range = 0x100 - 0xa0; pr[1].font_size = 20.0f; stbtt_PackSetOversampling(&pc, 2, 2); stbtt_PackFontRanges(&pc, ttf_buffer, 0, pr, 2); stbtt_PackEnd(&pc); stbi_write_png("fonttest3.png", BITMAP_W, BITMAP_H, 1, temp_bitmap, 0); } return 0; #endif stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0)); bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, (float)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 uTox/third_party/stb/stb/tests/test_cpp_compilation.cpp0000600000175000001440000001163614003056224022502 0ustar rakusers#include "stb_sprintf.h" #define STB_SPRINTF_IMPLEMENTATION #include "stb_sprintf.h" #define STB_TRUETYPE_IMPLEMENTATION #define STB_PERLIN_IMPLEMENTATION #define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_DXT_IMPLEMENATION #define STB_C_LEXER_IMPLEMENTATIOn #define STB_DIVIDE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION #define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION #define STB_RECT_PACK_IMPLEMENTATION #define STB_VOXEL_RENDER_IMPLEMENTATION #define STB_CONNECTED_COMPONENTS_IMPLEMENTATION #define STBI_MALLOC my_malloc #define STBI_FREE my_free #define STBI_REALLOC my_realloc void *my_malloc(size_t) { return 0; } void *my_realloc(void *, size_t) { return 0; } void my_free(void *) { } #include "stb_image.h" #include "stb_rect_pack.h" #include "stb_truetype.h" #include "stb_image_write.h" #include "stb_perlin.h" #include "stb_dxt.h" #include "stb_c_lexer.h" #include "stb_divide.h" #include "stb_herringbone_wang_tile.h" #define STBCC_GRID_COUNT_X_LOG2 10 #define STBCC_GRID_COUNT_Y_LOG2 10 #include "stb_connected_components.h" #define STBVOX_CONFIG_MODE 1 #include "stb_voxel_render.h" #define STBTE_DRAW_RECT(x0,y0,x1,y1,color) do ; while(0) #define STBTE_DRAW_TILE(x,y,id,highlight,data) do ; while(0) #define STB_TILEMAP_EDITOR_IMPLEMENTATION #include "stb_tilemap_editor.h" #include "stb_easy_font.h" #define STB_LEAKCHECK_IMPLEMENTATION #include "stb_leakcheck.h" #define STB_IMAGE_RESIZE_IMPLEMENTATION #include "stb_image_resize.h" #include "stretchy_buffer.h" //////////////////////////////////////////////////////////// // // text edit #include #include // memmove #include // isspace #define STB_TEXTEDIT_CHARTYPE char #define STB_TEXTEDIT_STRING text_control // get the base type #include "stb_textedit.h" // define our editor structure typedef struct { char *string; int stringlen; STB_TexteditState state; } text_control; // define the functions we need void layout_func(StbTexteditRow *row, STB_TEXTEDIT_STRING *str, int start_i) { int remaining_chars = str->stringlen - start_i; row->num_chars = remaining_chars > 20 ? 20 : remaining_chars; // should do real word wrap here row->x0 = 0; row->x1 = 20; // need to account for actual size of characters row->baseline_y_delta = 1.25; row->ymin = -1; row->ymax = 0; } int delete_chars(STB_TEXTEDIT_STRING *str, int pos, int num) { memmove(&str->string[pos], &str->string[pos+num], str->stringlen - (pos+num)); str->stringlen -= num; return 1; // always succeeds } int insert_chars(STB_TEXTEDIT_STRING *str, int pos, STB_TEXTEDIT_CHARTYPE *newtext, int num) { str->string = (char *) realloc(str->string, str->stringlen + num); memmove(&str->string[pos+num], &str->string[pos], str->stringlen - pos); memcpy(&str->string[pos], newtext, num); str->stringlen += num; return 1; // always succeeds } // define all the #defines needed #define KEYDOWN_BIT 0x80000000 #define STB_TEXTEDIT_STRINGLEN(tc) ((tc)->stringlen) #define STB_TEXTEDIT_LAYOUTROW layout_func #define STB_TEXTEDIT_GETWIDTH(tc,n,i) (1) // quick hack for monospaced #define STB_TEXTEDIT_KEYTOTEXT(key) (((key) & KEYDOWN_BIT) ? 0 : (key)) #define STB_TEXTEDIT_GETCHAR(tc,i) ((tc)->string[i]) #define STB_TEXTEDIT_NEWLINE '\n' #define STB_TEXTEDIT_IS_SPACE(ch) isspace(ch) #define STB_TEXTEDIT_DELETECHARS delete_chars #define STB_TEXTEDIT_INSERTCHARS insert_chars #define STB_TEXTEDIT_K_SHIFT 0x40000000 #define STB_TEXTEDIT_K_CONTROL 0x20000000 #define STB_TEXTEDIT_K_LEFT (KEYDOWN_BIT | 1) // actually use VK_LEFT, SDLK_LEFT, etc #define STB_TEXTEDIT_K_RIGHT (KEYDOWN_BIT | 2) // VK_RIGHT #define STB_TEXTEDIT_K_UP (KEYDOWN_BIT | 3) // VK_UP #define STB_TEXTEDIT_K_DOWN (KEYDOWN_BIT | 4) // VK_DOWN #define STB_TEXTEDIT_K_LINESTART (KEYDOWN_BIT | 5) // VK_HOME #define STB_TEXTEDIT_K_LINEEND (KEYDOWN_BIT | 6) // VK_END #define STB_TEXTEDIT_K_TEXTSTART (STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_CONTROL) #define STB_TEXTEDIT_K_TEXTEND (STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_CONTROL) #define STB_TEXTEDIT_K_DELETE (KEYDOWN_BIT | 7) // VK_DELETE #define STB_TEXTEDIT_K_BACKSPACE (KEYDOWN_BIT | 8) // VK_BACKSPACE #define STB_TEXTEDIT_K_UNDO (KEYDOWN_BIT | STB_TEXTEDIT_K_CONTROL | 'z') #define STB_TEXTEDIT_K_REDO (KEYDOWN_BIT | STB_TEXTEDIT_K_CONTROL | 'y') #define STB_TEXTEDIT_K_INSERT (KEYDOWN_BIT | 9) // VK_INSERT #define STB_TEXTEDIT_K_WORDLEFT (STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_CONTROL) #define STB_TEXTEDIT_K_WORDRIGHT (STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_CONTROL) #define STB_TEXTEDIT_K_PGUP (KEYDOWN_BIT | 10) // VK_PGUP -- not implemented #define STB_TEXTEDIT_K_PGDOWN (KEYDOWN_BIT | 11) // VK_PGDOWN -- not implemented #define STB_TEXTEDIT_IMPLEMENTATION #include "stb_textedit.h" uTox/third_party/stb/stb/tests/test_c_compilation.c0000600000175000001440000000211314003056224021570 0ustar rakusers#include "stb_sprintf.h" #define STB_SPRINTF_IMPLEMENTATION #include "stb_sprintf.h" #define STB_PERLIN_IMPLEMENTATION #define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_DXT_IMPLEMENATION #define STB_C_LEXER_IMPLEMENTATIOn #define STB_DIVIDE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION #define STB_HERRINGBONE_WANG_TILE_IMEPLEMENTATIOn #define STB_IMAGE_RESIZE_IMPLEMENTATION #define STB_RECT_PACK_IMPLEMENTATION #define STB_VOXEL_RENDER_IMPLEMENTATION #define STB_EASY_FONT_IMPLEMENTATION #include "stb_easy_font.h" #include "stb_herringbone_wang_tile.h" #include "stb_image.h" #include "stb_image_write.h" #include "stb_perlin.h" #include "stb_dxt.h" #include "stb_c_lexer.h" #include "stb_divide.h" #include "stb_image_resize.h" #include "stb_rect_pack.h" #define STBVOX_CONFIG_MODE 1 #include "stb_voxel_render.h" #define STBTE_DRAW_RECT(x0,y0,x1,y1,color) 0 #define STBTE_DRAW_TILE(x,y,id,highlight,data) 0 #define STB_TILEMAP_EDITOR_IMPLEMENTATION #include "stb_tilemap_editor.h" int quicktest(void) { char buffer[999]; stbsp_sprintf(buffer, "test%%test"); return 0; }uTox/third_party/stb/stb/tests/stretchy_buffer_test.c0000600000175000001440000000003414003056224022146 0ustar rakusers#include "stretchy_buffer.h"uTox/third_party/stb/stb/tests/stretch_test.dsp0000600000175000001440000000773114003056224021003 0ustar rakusers# Microsoft Developer Studio Project File - Name="stretch_test" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=stretch_test - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "stretch_test.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "stretch_test.mak" CFG="stretch_test - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "stretch_test - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "stretch_test - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "stretch_test - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "..\.." /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "TT_TEST" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "stretch_test - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "stretch_test___Win32_Debug" # PROP BASE Intermediate_Dir "stretch_test___Win32_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug\stretch_test" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "stretch_test - Win32 Release" # Name "stretch_test - Win32 Debug" # Begin Source File SOURCE=.\stretch_test.c # End Source File # End Target # End Project uTox/third_party/stb/stb/tests/stretch_test.c0000600000175000001440000000101614003056224020425 0ustar rakusers// check that stb_truetype compiles with no stb_rect_pack.h #define STB_TRUETYPE_IMPLEMENTATION #include "stb_truetype.h" #include "stretchy_buffer.h" #include int main(int arg, char **argv) { int i; int *arr = NULL; for (i=0; i < 1000000; ++i) sb_push(arr, i); assert(sb_count(arr) == 1000000); for (i=0; i < 1000000; ++i) assert(arr[i] == i); sb_free(arr); arr = NULL; for (i=0; i < 1000; ++i) sb_add(arr, 1000); assert(sb_count(arr) == 1000000); return 0; }uTox/third_party/stb/stb/tests/stb_cpp.dsp0000600000175000001440000000777714003056224017734 0ustar rakusers# Microsoft Developer Studio Project File - Name="stb_cpp" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=stb_cpp - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "stb_cpp.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "stb_cpp.mak" CFG="stb_cpp - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "stb_cpp - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "stb_cpp - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "stb_cpp - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "stb_cpp - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug\stb_cpp" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /GX /Zd /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "stb_cpp - Win32 Release" # Name "stb_cpp - Win32 Debug" # Begin Source File SOURCE=.\stb_cpp.cpp # End Source File # Begin Source File SOURCE=..\stb_vorbis.c # End Source File # Begin Source File SOURCE=.\test_cpp_compilation.cpp # End Source File # End Target # End Project uTox/third_party/stb/stb/tests/stb_cpp.cpp0000600000175000001440000000416114003056224017710 0ustar rakusers#define WIN32_MEAN_AND_LEAN #define WIN32_LEAN_AND_MEAN //#include #include #define STB_STUA #define STB_DEFINE #define STB_NPTR #define STB_ONLY #include "stb.h" //#include "stb_file.h" int count; void c(int truth, char *error) { if (!truth) { fprintf(stderr, "Test failed: %s\n", error); ++count; } } char *expects(stb_matcher *m, char *s, int result, int len, char *str) { int res2,len2=0; res2 = stb_lex(m, s, &len2); c(result == res2 && len == len2, str); return s + len; } void test_lex(void) { stb_matcher *m = stb_lex_matcher(); // tok_en5 .3 20.1 20. .20 .1 char *s = "tok_en5.3 20.1 20. .20.1"; stb_lex_item(m, "[a-zA-Z_][a-zA-Z0-9_]*", 1 ); stb_lex_item(m, "[0-9]*\\.?[0-9]*" , 2 ); stb_lex_item(m, "[\r\n\t ]+" , 3 ); stb_lex_item(m, "." , -99 ); s=expects(m,s,1,7, "stb_lex 1"); s=expects(m,s,2,2, "stb_lex 2"); s=expects(m,s,3,1, "stb_lex 3"); s=expects(m,s,2,4, "stb_lex 4"); s=expects(m,s,3,1, "stb_lex 5"); s=expects(m,s,2,3, "stb_lex 6"); s=expects(m,s,3,1, "stb_lex 7"); s=expects(m,s,2,3, "stb_lex 8"); s=expects(m,s,2,2, "stb_lex 9"); s=expects(m,s,0,0, "stb_lex 10"); stb_matcher_free(m); } int main(int argc, char **argv) { char *p; p = "abcdefghijklmnopqrstuvwxyz"; c(stb_ischar('c', p), "stb_ischar 1"); c(stb_ischar('x', p), "stb_ischar 2"); c(!stb_ischar('#', p), "stb_ischar 3"); c(!stb_ischar('X', p), "stb_ischar 4"); p = "0123456789"; c(!stb_ischar('c', p), "stb_ischar 5"); c(!stb_ischar('x', p), "stb_ischar 6"); c(!stb_ischar('#', p), "stb_ischar 7"); c(!stb_ischar('X', p), "stb_ischar 8"); p = "#####"; c(!stb_ischar('c', p), "stb_ischar a"); c(!stb_ischar('x', p), "stb_ischar b"); c(stb_ischar('#', p), "stb_ischar c"); c(!stb_ischar('X', p), "stb_ischar d"); p = "xXyY"; c(!stb_ischar('c', p), "stb_ischar e"); c(stb_ischar('x', p), "stb_ischar f"); c(!stb_ischar('#', p), "stb_ischar g"); c(stb_ischar('X', p), "stb_ischar h"); test_lex(); if (count) { _getch(); } return 0; } uTox/third_party/stb/stb/tests/stb.dsw0000600000175000001440000000552114003056224017062 0ustar rakusersMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "c_lexer_test"=.\c_lexer_test.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "herringbone"=.\herringbone.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "herringbone_map"=.\herringbone_map.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "image_test"=.\image_test.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "make_readme"=..\tools\make_readme.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "pg_test"=.\pg_test\pg_test.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "resize"=.\resize.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "stb"=.\stb.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ Begin Project Dependency Project_Dep_Name stb_cpp End Project Dependency Begin Project Dependency Project_Dep_Name image_test End Project Dependency Begin Project Dependency Project_Dep_Name stretch_test End Project Dependency Begin Project Dependency Project_Dep_Name c_lexer_test End Project Dependency }}} ############################################################################### Project: "stb_cpp"=.\stb_cpp.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "stretch_test"=.\stretch_test.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "unicode"=..\tools\unicode\unicode.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "vorbseek"=.\vorbseek\vorbseek.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### uTox/third_party/stb/stb/tests/stb.dsp0000600000175000001440000001333114003056224017051 0ustar rakusers# Microsoft Developer Studio Project File - Name="stb" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=stb - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "stb.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "stb.mak" CFG="stb - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "stb - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "stb - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "stb - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /G6 /MT /W3 /GX /Z7 /O2 /Ob2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "GRID_TEST" /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 !ELSEIF "$(CFG)" == "stb - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug\stb" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /GX /Zi /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "VORBIS_TEST" /FR /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept # SUBTRACT LINK32 /force !ENDIF # Begin Target # Name "stb - Win32 Release" # Name "stb - Win32 Debug" # Begin Source File SOURCE=.\grid_reachability.c # End Source File # Begin Source File SOURCE=.\stb.c # End Source File # Begin Source File SOURCE=..\stb.h # End Source File # Begin Source File SOURCE=..\stb_c_lexer.h # End Source File # Begin Source File SOURCE=..\stb_connected_components.h # End Source File # Begin Source File SOURCE=..\stb_divide.h # End Source File # Begin Source File SOURCE=..\stb_dxt.h # End Source File # Begin Source File SOURCE=..\stb_easy_font.h # End Source File # Begin Source File SOURCE=..\stb_herringbone_wang_tile.h # End Source File # Begin Source File SOURCE=..\stb_image.h # End Source File # Begin Source File SOURCE=..\stb_image_resize.h # End Source File # Begin Source File SOURCE=..\stb_image_write.h # End Source File # Begin Source File SOURCE=..\stb_leakcheck.h # End Source File # Begin Source File SOURCE=..\stb_malloc.h # End Source File # Begin Source File SOURCE=..\stb_perlin.h # End Source File # Begin Source File SOURCE=..\stb_pg.h # End Source File # Begin Source File SOURCE=..\stb_rect_pack.h # End Source File # Begin Source File SOURCE=..\stb_sprintf.h # End Source File # Begin Source File SOURCE=..\stb_textedit.h # End Source File # Begin Source File SOURCE=..\stb_tilemap_editor.h # End Source File # Begin Source File SOURCE=..\stb_truetype.h # End Source File # Begin Source File SOURCE=..\stb_vorbis.c # End Source File # Begin Source File SOURCE=..\stb_voxel_render.h # End Source File # Begin Source File SOURCE=..\stretchy_buffer.h # End Source File # Begin Source File SOURCE=.\stretchy_buffer_test.c # End Source File # Begin Source File SOURCE=.\test_c_compilation.c # End Source File # Begin Source File SOURCE=.\test_truetype.c # End Source File # Begin Source File SOURCE=.\test_vorbis.c # End Source File # Begin Source File SOURCE=.\textedit_sample.c # End Source File # End Target # End Project uTox/third_party/stb/stb/tests/stb.c0000600000175000001440000036333014003056224016514 0ustar rakusers/* * Unit tests for "stb.h" */ //#include #include #include #include #include #include #ifdef _WIN32 #include #endif #define STB_STUA //#define STB_FASTMALLOC #ifdef _DEBUG #define STB_MALLOC_WRAPPER_DEBUG #endif #define STB_NPTR #define STB_DEFINE #include "stb.h" //#include "stb_file.h" //#include "stb_pixel32.h" //#define DEBUG_BLOCK #ifdef DEBUG_BLOCK #include #endif #ifdef STB_FASTMALLOC #error "can't use FASTMALLOC with threads" #endif int count; void c(int truth, char *error) { if (!truth) { fprintf(stderr, "Test failed: %s\n", error); ++count; } } #if 0 void show(void) { #ifdef _WIN32 SYSTEM_INFO x; GetSystemInfo(&x); printf("%d\n", x.dwPageSize); #endif } #endif void test_classes(void) { unsigned char size_base[32], size_shift[32]; int class_to_pages[256]; int class_to_size[256], cl; int lg, size, wasted_pages; int kAlignShift = 3; int kAlignment = 1 << kAlignShift; int kMaxSize = 8 * 4096; int kPageShift = 12; int kPageSize = (1 << kPageShift); int next_class = 1; int alignshift = kAlignShift; int last_lg = -1; for (lg = 0; lg < kAlignShift; lg++) { size_base[lg] = 1; size_shift[lg] = kAlignShift; } for (size = kAlignment; size <= kMaxSize; size += (1 << alignshift)) { int lg = stb_log2_floor(size); if (lg > last_lg) { // Increase alignment every so often. // // Since we double the alignment every time size doubles and // size >= 128, this means that space wasted due to alignment is // at most 16/128 i.e., 12.5%. Plus we cap the alignment at 256 // bytes, so the space wasted as a percentage starts falling for // sizes > 2K. if ((lg >= 7) && (alignshift < 8)) { alignshift++; } size_base[lg] = next_class - ((size-1) >> alignshift); size_shift[lg] = alignshift; } class_to_size[next_class] = size; last_lg = lg; next_class++; } // Initialize the number of pages we should allocate to split into // small objects for a given class. wasted_pages = 0; for (cl = 1; cl < next_class; cl++) { // Allocate enough pages so leftover is less than 1/8 of total. // This bounds wasted space to at most 12.5%. size_t psize = kPageSize; const size_t s = class_to_size[cl]; while ((psize % s) > (psize >> 3)) { psize += kPageSize; } class_to_pages[cl] = psize >> kPageShift; wasted_pages += psize; } printf("TCMalloc can waste as much as %d memory on one-shot allocations\n", wasted_pages); return; } void test_script(void) { stua_run_script( "var g = (2+3)*5 + 3*(2+1) + ((7)); \n" "func sprint(x) _print(x) _print(' ') x end;\n" "func foo(y) var q = func(x) sprint(x) end; q end;\n " "var z=foo(5); z(77);\n" "func counter(z) func(x) z=z+1 end end\n" "var q=counter(0), p=counter(5);\n" "sprint(q()) sprint(p()) sprint(q()) sprint(p()) sprint(q()) sprint(p())\n" "var x=2222;\n" "if 1 == 2 then 3333 else 4444 end; => x; sprint(x);\n" "var x1 = sprint(1.5e3); \n" "var x2 = sprint(.5); \n" "var x3 = sprint(1.); \n" "var x4 = sprint(1.e3); \n" "var x5 = sprint(1e3); \n" "var x6 = sprint(0.5e3); \n" "var x7 = sprint(.5e3); \n" " func sum(x,y) x+y end \n" " func sumfunc(a) sum+{x=a} end \n" " var q = sumfunc(3) \n" " var p = sumfunc(20) \n" " var d = sprint(q(5)) - sprint(q(8)) \n" " var e = sprint(p(5)) - sprint(p(8)) \n" " func test3(x) \n" " sprint(x) \n" " x = x+3 \n" " sprint(x) \n" " x+5 \n" " end \n" " var y = test3(4); \n" " func fib(x) \n" " if x < 3 then \n" " 1 \n" " else \n" " fib(x-1) + fib(x-2); \n" " end \n" " end \n" " \n" " func fib2(x) \n" " var a=1 \n" " var b=1 \n" " sprint(a) \n" " sprint(b) \n" " while x > 2 do \n" " var c=a+b \n" " a=b \n" " b=c \n" " sprint(b) \n" " x=x-1 \n" " end \n" " b \n" " end \n" " \n" " func assign(z) \n" " var y = { 'this', 'is', 'a', 'lame', 'day', 'to', 'die'} \n" " y[3] = z \n" " var i = 0 \n" " while y[i] != nil do \n" " sprint(y[i]) \n" " i = i+1 \n" " end \n" " end \n" " \n" " sprint(fib(12)); \n" " assign(\"good\"); \n" " fib2(20); \n" " sprint('ok'); \n" " sprint(-5); \n" " // final comment with no newline" ); } #ifdef STB_THREADS extern void __stdcall Sleep(unsigned long); void * thread_1(void *x) { Sleep(80); printf("thread 1\n"); fflush(stdout); return (void *) 2; } void * thread_2(void *y) { stb_work(thread_1, NULL, y); Sleep(50); printf("thread 2\n"); fflush(stdout); return (void *) 3; } stb_semaphore stest; stb_mutex mutex; volatile int tc1, tc2; void *thread_3(void *p) { stb_mutex_begin(mutex); ++tc1; stb_mutex_end(mutex); stb_sem_waitfor(stest); stb_mutex_begin(mutex); ++tc2; stb_mutex_end(mutex); return NULL; } void test_threads(void) { volatile int a=0,b=0; //stb_work_numthreads(2); stb_work(thread_2, (void *) &a, (void *) &b); while (a==0 || b==0) { Sleep(10); //printf("a=%d b=%d\n", a, b); } c(a==2 && b == 3, "stb_thread"); stb_work_numthreads(4); stest = stb_sem_new(8); mutex = stb_mutex_new(); stb_work(thread_3, NULL, NULL); stb_work(thread_3, NULL, NULL); stb_work(thread_3, NULL, NULL); stb_work(thread_3, NULL, NULL); stb_work(thread_3, NULL, NULL); stb_work(thread_3, NULL, NULL); stb_work(thread_3, NULL, NULL); stb_work(thread_3, NULL, NULL); while (tc1 < 4) Sleep(10); c(tc1 == 4, "stb_work 1"); stb_sem_release(stest); stb_sem_release(stest); stb_sem_release(stest); stb_sem_release(stest); stb_sem_release(stest); stb_sem_release(stest); stb_sem_release(stest); stb_sem_release(stest); Sleep(40); while (tc1 != 8 || tc2 != 8) Sleep(10); c(tc1 == 8 && tc2 == 8, "stb_work 2"); stb_work_numthreads(2); stb_work(thread_3, NULL, NULL); stb_work(thread_3, NULL, NULL); stb_work(thread_3, NULL, NULL); stb_work(thread_3, NULL, NULL); while (tc1 < 10) Sleep(10); c(tc1 == 10, "stb_work 1"); stb_sem_release(stest); stb_sem_release(stest); stb_sem_release(stest); stb_sem_release(stest); Sleep(100); stb_sem_delete(stest); stb_mutex_delete(mutex); } #else void test_threads(void) { } #endif void *thread4(void *p) { return NULL; } #ifdef STB_THREADS stb_threadqueue *tq; stb_sync synch; stb_mutex msum; volatile int thread_sum; void *consume1(void *p) { volatile int *q = (volatile int *) p; for(;;) { int z; stb_threadq_get_block(tq, &z); stb_mutex_begin(msum); thread_sum += z; *q += z; stb_mutex_end(msum); stb_sync_reach(synch); } } void test_threads2(void) { int array[256],i,n=0; volatile int which[4]; synch = stb_sync_new(); stb_sync_set_target(synch,2); stb_work_reach(thread4, NULL, NULL, synch); stb_sync_reach_and_wait(synch); printf("ok\n"); tq = stb_threadq_new(4, 1, TRUE,TRUE); msum = stb_mutex_new(); thread_sum = 0; stb_sync_set_target(synch, 65); for (i=0; i < 4; ++i) { which[i] = 0; stb_create_thread(consume1, (int *) &which[i]); } for (i=1; i <= 64; ++i) { array[i] = i; n += i; stb_threadq_add_block(tq, &array[i]); } stb_sync_reach_and_wait(synch); stb_barrier(); c(thread_sum == n, "stb_threadq 1"); c(which[0] + which[1] + which[2] + which[3] == n, "stb_threadq 2"); printf("(Distribution: %d %d %d %d)\n", which[0], which[1], which[2], which[3]); stb_sync_delete(synch); stb_threadq_delete(tq); stb_mutex_delete(msum); } #else void test_threads2(void) { } #endif char tc[] = "testing compression test quick test voila woohoo what the hell"; char storage1[1 << 23]; int test_compression(char *buffer, int length) { char *storage2; int c_len = stb_compress(storage1, buffer, length); int dc_len; printf("Compressed %d to %d\n", length, c_len); dc_len = stb_decompress_length(storage1); storage2 = malloc(dc_len); dc_len = stb_decompress(storage2, storage1, c_len); if (dc_len != length) { free(storage2); return -1; } if (memcmp(buffer, storage2, length) != 0) { free(storage2); return -1; } free(storage2); return c_len; } #if 0 int test_en_compression(char *buffer, int length) { int c_len = stb_en_compress(storage1, buffer, length); int dc_len; printf("Encompressed %d to %d\n", length, c_len); dc_len = stb_en_decompress(storage2, storage1, c_len); if (dc_len != length) return -1; if (memcmp(buffer, storage2, length) != 0) return -1; return c_len; } #endif #define STR_x "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" #define STR_y "yyyyyyyyyyyyyyyyyy" #define STR_xy STR_x STR_y #define STR_xyyxy STR_xy STR_y STR_xy #define STR_1 "testing" #define STR_2 STR_xyyxy STR_xy STR_xyyxy STR_xyyxy STR_xy STR_xyyxy #define STR_3 "buh" char buffer[] = STR_1 "\r\n" STR_2 STR_2 STR_2 "\n" STR_3; char str1[] = STR_1; char str2[] = STR_2 STR_2 STR_2; char str3[] = STR_3; int sum(short *s) { int i,total=0; for (i=0; i < stb_arr_len(s); ++i) total += s[i]; return total; } stb_uint stb_adler32_old(stb_uint adler32, stb_uchar *buffer, stb_uint buflen) { const stb_uint ADLER_MOD = 65521; stb_uint s1 = adler32 & 0xffff; stb_uint s2 = adler32 >> 16; while (buflen-- > 0) { // NOTE: much faster implementations are possible! s1 += *buffer++; if (s1 > ADLER_MOD) s1 -= ADLER_MOD; s2 += s1 ; if (s2 > ADLER_MOD) s2 -= ADLER_MOD; } return (s2 << 16) + s1; } static int sample_test[3][5] = { { 1,2,3,4,5 }, { 6,7,8,9,10, }, { 11,12,13,14,15 }, }; typedef struct { unsigned short x,y,z; } struct1; typedef struct { double a; int x,y,z; } struct2; char *args_raw[] = { "foo", "-dxrf", "bar", "-ts" }; char *args[8]; void do_compressor(int,char**); void test_sha1(void); int alloc_num, alloc_size; void dumpfunc(void *ptr, int sz, char *file, int line) { printf("%p (%6d) -- %3d:%s\n", ptr, sz, line, file); alloc_size += sz; alloc_num += 1; } char *expects(stb_matcher *m, char *s, int result, int len, char *str) { int res2,len2=0; res2 = stb_lex(m, s, &len2); c(result == res2 && len == len2, str); return s + len; } void test_lex(void) { stb_matcher *m = stb_lex_matcher(); // tok_en5 .3 20.1 20. .20 .1 char *s = "tok_en5.3 20.1 20. .20.1"; stb_lex_item(m, "[a-zA-Z_][a-zA-Z0-9_]*", 1 ); stb_lex_item(m, "[0-9]*\\.?[0-9]*" , 2 ); stb_lex_item(m, "[\r\n\t ]+" , 3 ); stb_lex_item(m, "." , -99 ); s=expects(m,s,1,7, "stb_lex 1"); s=expects(m,s,2,2, "stb_lex 2"); s=expects(m,s,3,1, "stb_lex 3"); s=expects(m,s,2,4, "stb_lex 4"); s=expects(m,s,3,1, "stb_lex 5"); s=expects(m,s,2,3, "stb_lex 6"); s=expects(m,s,3,1, "stb_lex 7"); s=expects(m,s,2,3, "stb_lex 8"); s=expects(m,s,2,2, "stb_lex 9"); s=expects(m,s,0,0, "stb_lex 10"); stb_matcher_free(m); } typedef struct Btest { struct Btest stb_bst_fields(btest_); int v; } Btest; stb_bst(Btest, btest_, BT2,bt2,v, int, a - b) void bst_test(void) { Btest *root = NULL, *t; int items[500], sorted[500]; int i,j,z; for (z=0; z < 10; ++z) { for (i=0; i < 500; ++i) items[i] = stb_rand() & 0xfffffff; // check for collisions, and retrry if so memcpy(sorted, items, sizeof(sorted)); qsort(sorted, 500, sizeof(sorted[0]), stb_intcmp(0)); for (i=1; i < 500; ++i) if (sorted[i-1] == sorted[i]) break; if (i != 500) { --z; break; } for (i=0; i < 500; ++i) { t = malloc(sizeof(*t)); t->v = items[i]; root = btest_insert(root, t); #ifdef STB_DEBUG btest__validate(root,1); #endif for (j=0; j <= i; ++j) c(btest_find(root, items[j]) != NULL, "stb_bst 1"); for ( ; j < 500; ++j) c(btest_find(root, items[j]) == NULL, "stb_bst 2"); } t = btest_first(root); for (i=0; i < 500; ++i) t = btest_next(root,t); c(t == NULL, "stb_bst 5"); t = btest_last(root); for (i=0; i < 500; ++i) t = btest_prev(root,t); c(t == NULL, "stb_bst 6"); memcpy(sorted, items, sizeof(sorted)); qsort(sorted, 500, sizeof(sorted[0]), stb_intcmp(0)); t = btest_first(root); for (i=0; i < 500; ++i) { assert(t->v == sorted[i]); t = btest_next(root, t); } assert(t == NULL); if (z==1) stb_reverse(items, 500, sizeof(items[0])); else if (z) stb_shuffle(items, 500, sizeof(items[0]), stb_rand()); for (i=0; i < 500; ++i) { t = btest_find(root, items[i]); assert(t != NULL); root = btest_remove(root, t); c(btest_find(root, items[i]) == NULL, "stb_bst 5"); #ifdef STB_DEBUG btest__validate(root, 1); #endif for (j=0; j <= i; ++j) c(btest_find(root, items[j]) == NULL, "stb_bst 3"); for ( ; j < 500; ++j) c(btest_find(root, items[j]) != NULL, "stb_bst 4"); free(t); } } } extern void stu_uninit(void); stb_define_sort(sort_int, int, *a < *b) stb_rand_define(prime_rand, 1) void test_packed_floats(void); void test_parser_generator(void); void rec_print(stb_dirtree2 *d, int depth) { int i; for (i=0; i < depth; ++i) printf(" "); printf("%s (%d)\n", d->relpath, stb_arr_len(d->files)); for (i=0; i < stb_arr_len(d->subdirs); ++i) rec_print(d->subdirs[i], depth+1); d->weight = (float) stb_arr_len(d->files); } #ifdef MAIN_TEST int main(int argc, char **argv) { char *z; stb__wchar buffer7[1024],buffer9[1024]; char buffer8[4096]; FILE *f; char *p1 = "foo/bar\\baz/test.xyz"; char *p2 = "foo/.bar"; char *p3 = "foo.bar"; char *p4 = "foo/bar"; char *wildcards[] = { "*foo*", "*bar", "baz", "*1*2*3*", "*/CVS/repository", "*oof*" }; char **s; char buf[256], *p; int n,len2,*q,i; stb_matcher *mt=NULL; if (argc > 1) { do_compressor(argc,argv); return 0; } test_classes(); //show(); //stb_malloc_check_counter(2,2); //_CrtSetBreakAlloc(10398); stbprint("Checking {!if} the {$fancy} print function {#works}? - should\n"); stbprint(" - align\n"); stbprint("But {#3this}} {one}} - shouldn't\n"); #if 0 { int i; char **s = stb_readdir_recursive("/sean", NULL); stb_dirtree *d = stb_dirtree_from_files_relative("", s, stb_arr_len(s)); stb_dirtree **e; rec_print(d, 0); e = stb_summarize_tree(d,12,4); for (i=0; i < stb_arr_len(e); ++i) { printf("%s\n", e[i]->fullpath); } stb_arr_free(e); stb_fatal("foo"); } #endif stb_("Started stb.c"); test_threads2(); test_threads(); for (i=0; i < 1023 && 5+77*i < 0xd800; ++i) buffer7[i] = 5+77*i; buffer7[i++] = 0xd801; buffer7[i++] = 0xdc02; buffer7[i++] = 0xdbff; buffer7[i++] = 0xdfff; buffer7[i] = 0; p = stb_to_utf8(buffer8, buffer7, sizeof(buffer8)); c(p != NULL, "stb_to_utf8"); if (p != NULL) { stb_from_utf8(buffer9, buffer8, sizeof(buffer9)/2); c(!memcmp(buffer7, buffer9, i*2), "stb_from_utf8"); } z = "foo.*[bd]ak?r"; c( stb_regex(z, "muggle man food is barfy") == 1, "stb_regex 1"); c( stb_regex("foo.*bar", "muggle man food is farfy") == 0, "stb_regex 2"); c( stb_regex("[^a-zA-Z]foo[^a-zA-Z]", "dfoobar xfood") == 0, "stb_regex 3"); c( stb_regex(z, "muman foob is bakrfy") == 1, "stb_regex 4"); z = "foo.*[bd]bk?r"; c( stb_regex(z, "muman foob is bakrfy") == 0, "stb_regex 5"); c( stb_regex(z, "muman foob is bbkrfy") == 1, "stb_regex 6"); stb_regex(NULL,NULL); #if 0 test_parser_generator(); stb_wrapper_listall(dumpfunc); if (alloc_num) printf("Memory still in use: %d allocations of %d bytes.\n", alloc_num, alloc_size); #endif test_script(); p = stb_file("sieve.stua", NULL); if (p) { stua_run_script(p); free(p); } stua_uninit(); //stb_wrapper_listall(dumpfunc); printf("Memory still in use: %d allocations of %d bytes.\n", alloc_num, alloc_size); c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc 0"); bst_test(); c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc 0"); #if 0 // stb_block { int inuse=0, freespace=0; int *x = malloc(10000*sizeof(*x)); stb_block *b = stb_block_new(1, 10000); #define BLOCK_COUNT 1000 int *p = malloc(sizeof(*p) * BLOCK_COUNT); int *l = malloc(sizeof(*l) * BLOCK_COUNT); int i, n, k = 0; memset(x, 0, 10000 * sizeof(*x)); n = 0; while (n < BLOCK_COUNT && k < 1000) { l[n] = 16 + (rand() & 31); p[n] = stb_block_alloc(b, l[n], 0); if (p[n] == 0) break; inuse += l[n]; freespace = 0; for (i=0; i < b->len; ++i) freespace += b->freelist[i].len; assert(freespace + inuse == 9999); for (i=0; i < l[n]; ++i) x[ p[n]+i ] = p[n]; ++n; if (k > 20) { int sz; i = (stb_rand() % n); sz = l[i]; stb_block_free(b, p[i], sz); inuse -= sz; p[i] = p[n-1]; l[i] = l[n-1]; --n; freespace = 0; for (i=0; i < b->len; ++i) freespace += b->freelist[i].len; assert(freespace + inuse == 9999); } ++k; // validate if ((k % 50) == 0) { int j; for (j=0; j < n; ++j) { for (i=0; i < l[j]; ++i) assert(x[ p[j]+i ] == p[j]); } } if ((k % 200) == 0) { stb_block_compact_freelist(b); } } for (i=0; i < n; ++i) stb_block_free(b, p[i], l[i]); stb_block_destroy(b); free(p); free(l); free(x); } blockfile_test(); #endif mt = stb_lex_matcher(); for (i=0; i < 5; ++i) stb_lex_item_wild(mt, wildcards[i], i+1); c(1==stb_lex(mt, "this is a foo in the middle",NULL), "stb_matcher_match 1"); c(0==stb_lex(mt, "this is a bar in the middle",NULL), "stb_matcher_match 2"); c(0==stb_lex(mt, "this is a baz in the middle",NULL), "stb_matcher_match 3"); c(2==stb_lex(mt, "this is a bar",NULL), "stb_matcher_match 4"); c(0==stb_lex(mt, "this is a baz",NULL), "stb_matcher_match 5"); c(3==stb_lex(mt, "baz",NULL), "stb_matcher_match 6"); c(4==stb_lex(mt, "1_2_3_4",NULL), "stb_matcher_match 7"); c(0==stb_lex(mt, "1 3 3 3 3 2 ",NULL), "stb_matcher_match 8"); c(4==stb_lex(mt, "1 3 3 3 2 3 ",NULL), "stb_matcher_match 9"); c(5==stb_lex(mt, "C:/sean/prj/old/gdmag/mipmap/hqp/adol-c/CVS/Repository",NULL), "stb_matcher_match 10"); stb_matcher_free(mt); { #define SSIZE 500000 static int arr[SSIZE],arr2[SSIZE]; int i,good; for (i=0; i < SSIZE; ++i) arr2[i] = stb_rand(); memcpy(arr,arr2,sizeof(arr)); printf("stb_define_sort:\n"); sort_int(arr, SSIZE); good = 1; for (i=0; i+1 < SSIZE; ++i) if (arr[i] > arr[i+1]) good = 0; c(good, "stb_define_sort"); printf("qsort:\n"); qsort(arr2, SSIZE, sizeof(arr2[0]), stb_intcmp(0)); printf("done\n"); // check for bugs memset(arr, 0, sizeof(arr[0]) * 1000); sort_int(arr, 1000); } c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc -2"); c( stb_is_prime( 2), "stb_is_prime 1"); c( stb_is_prime( 3), "stb_is_prime 2"); c( stb_is_prime( 5), "stb_is_prime 3"); c( stb_is_prime( 7), "stb_is_prime 4"); c(!stb_is_prime( 9), "stb_is_prime 5"); c( stb_is_prime(11), "stb_is_prime 6"); c(!stb_is_prime(25), "stb_is_prime 7"); c(!stb_is_prime(27), "stb_is_prime 8"); c( stb_is_prime(29), "stb_is_prime 9"); c( stb_is_prime(31), "stb_is_prime a"); c(!stb_is_prime(33), "stb_is_prime b"); c(!stb_is_prime(35), "stb_is_prime c"); c(!stb_is_prime(36), "stb_is_prime d"); for (n=7; n < 64; n += 3) { int i; stb_perfect s; unsigned int *p = malloc(n * sizeof(*p)); for (i=0; i < n; ++i) p[i] = i*i; c(stb_perfect_create(&s, p, n), "stb_perfect_hash 1"); stb_perfect_destroy(&s); for (i=0; i < n; ++i) p[i] = stb_rand(); c(stb_perfect_create(&s, p, n), "stb_perfect_hash 2"); stb_perfect_destroy(&s); for (i=0; i < n; ++i) p[i] = (0x80000000 >> stb_log2_ceil(n>>1)) * i; c(stb_perfect_create(&s, p, n), "stb_perfect_hash 2"); stb_perfect_destroy(&s); for (i=0; i < n; ++i) p[i] = (int) malloc(1024); c(stb_perfect_create(&s, p, n), "stb_perfect_hash 3"); stb_perfect_destroy(&s); for (i=0; i < n; ++i) free((void *) p[i]); free(p); } printf("Maximum attempts required to find perfect hash: %d\n", stb_perfect_hash_max_failures); p = "abcdefghijklmnopqrstuvwxyz"; c(stb_ischar('c', p), "stb_ischar 1"); c(stb_ischar('x', p), "stb_ischar 2"); c(!stb_ischar('#', p), "stb_ischar 3"); c(!stb_ischar('X', p), "stb_ischar 4"); p = "0123456789"; c(!stb_ischar('c', p), "stb_ischar 5"); c(!stb_ischar('x', p), "stb_ischar 6"); c(!stb_ischar('#', p), "stb_ischar 7"); c(!stb_ischar('X', p), "stb_ischar 8"); p = "#####"; c(!stb_ischar('c', p), "stb_ischar a"); c(!stb_ischar('x', p), "stb_ischar b"); c(stb_ischar('#', p), "stb_ischar c"); c(!stb_ischar('X', p), "stb_ischar d"); p = "xXyY"; c(!stb_ischar('c', p), "stb_ischar e"); c(stb_ischar('x', p), "stb_ischar f"); c(!stb_ischar('#', p), "stb_ischar g"); c(stb_ischar('X', p), "stb_ischar h"); c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc 1"); q = stb_wordwrapalloc(15, "How now brown cow. Testinglishously. Okey dokey"); // How now brown // cow. Testinglis // hously. Okey // dokey c(stb_arr_len(q) == 8, "stb_wordwrap 8"); c(q[2] == 14 && q[3] == 15, "stb_wordwrap 9"); c(q[4] == 29 && q[5] == 12, "stb_wordwrap 10"); stb_arr_free(q); q = stb_wordwrapalloc(20, "How now brown cow. Testinglishously. Okey dokey"); // How now brown cow. // Testinglishously. // Okey dokey c(stb_arr_len(q) == 6, "stb_wordwrap 1"); c(q[0] == 0 && q[1] == 18, "stb_wordwrap 2"); c(q[2] == 19 && q[3] == 17, "stb_wordwrap 3"); c(q[4] == 37 && q[5] == 10, "stb_wordwrap 4"); stb_arr_free(q); q = stb_wordwrapalloc(12, "How now brown cow. Testinglishously. Okey dokey"); // How now // brown cow. // Testinglisho // usly. Okey // dokey c(stb_arr_len(q) == 10, "stb_wordwrap 5"); c(q[4] == 19 && q[5] == 12, "stb_wordwrap 6"); c(q[6] == 31 && q[3] == 10, "stb_wordwrap 7"); stb_arr_free(q); //test_script(); //test_packed_floats(); c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc 0"); if (stb_alloc_count_alloc != stb_alloc_count_free) { printf("%d allocs, %d frees\n", stb_alloc_count_alloc, stb_alloc_count_free); } test_lex(); mt = stb_regex_matcher(".*foo.*bar.*"); c(stb_matcher_match(mt, "foobarx") == 1, "stb_matcher_match 1"); c(stb_matcher_match(mt, "foobar") == 1, "stb_matcher_match 2"); c(stb_matcher_match(mt, "foo bar") == 1, "stb_matcher_match 3"); c(stb_matcher_match(mt, "fo foo ba ba bar ba") == 1, "stb_matcher_match 4"); c(stb_matcher_match(mt, "fo oo oo ba ba bar foo") == 0, "stb_matcher_match 5"); stb_free(mt); mt = stb_regex_matcher(".*foo.?bar.*"); c(stb_matcher_match(mt, "abfoobarx") == 1, "stb_matcher_match 6"); c(stb_matcher_match(mt, "abfoobar") == 1, "stb_matcher_match 7"); c(stb_matcher_match(mt, "abfoo bar") == 1, "stb_matcher_match 8"); c(stb_matcher_match(mt, "abfoo bar") == 0, "stb_matcher_match 9"); c(stb_matcher_match(mt, "abfo foo ba ba bar ba") == 0, "stb_matcher_match 10"); c(stb_matcher_match(mt, "abfo oo oo ba ba bar foo") == 0, "stb_matcher_match 11"); stb_free(mt); mt = stb_regex_matcher(".*m((foo|bar)*baz)m.*"); c(stb_matcher_match(mt, "abfoobarx") == 0, "stb_matcher_match 12"); c(stb_matcher_match(mt, "a mfoofoofoobazm d") == 1, "stb_matcher_match 13"); c(stb_matcher_match(mt, "a mfoobarbazfoom d") == 0, "stb_matcher_match 14"); c(stb_matcher_match(mt, "a mbarbarfoobarbazm d") == 1, "stb_matcher_match 15"); c(stb_matcher_match(mt, "a mfoobarfoo bazm d") == 0, "stb_matcher_match 16"); c(stb_matcher_match(mt, "a mm foobarfoobarfoobar ") == 0, "stb_matcher_match 17"); stb_free(mt); mt = stb_regex_matcher("f*|z"); c(stb_matcher_match(mt, "fz") == 0, "stb_matcher_match 0a"); c(stb_matcher_match(mt, "ff") == 1, "stb_matcher_match 0b"); c(stb_matcher_match(mt, "z") == 1, "stb_matcher_match 0c"); stb_free(mt); mt = stb_regex_matcher("m(f|z*)n"); c(stb_matcher_match(mt, "mfzn") == 0, "stb_matcher_match 0d"); c(stb_matcher_match(mt, "mffn") == 0, "stb_matcher_match 0e"); c(stb_matcher_match(mt, "mzn") == 1, "stb_matcher_match 0f"); c(stb_matcher_match(mt, "mn") == 1, "stb_matcher_match 0g"); c(stb_matcher_match(mt, "mzfn") == 0, "stb_matcher_match 0f"); c(stb_matcher_find(mt, "manmanmannnnnnnmmmmmmmmm ") == 0, "stb_matcher_find 1"); c(stb_matcher_find(mt, "manmanmannnnnnnmmmmmmmmm ") == 0, "stb_matcher_find 2"); c(stb_matcher_find(mt, "manmanmannnnnnnmmmmmmmmmffzzz ") == 0, "stb_matcher_find 3"); c(stb_matcher_find(mt, "manmanmannnnnnnmmmmmmmmmnfzzz ") == 1, "stb_matcher_find 4"); c(stb_matcher_find(mt, "mmmfn aanmannnnnnnmmmmmm fzzz ") == 1, "stb_matcher_find 5"); c(stb_matcher_find(mt, "mmmzzn anmannnnnnnmmmmmm fzzz ") == 1, "stb_matcher_find 6"); c(stb_matcher_find(mt, "mm anmannnnnnnmmmmmm fzmzznzz ") == 1, "stb_matcher_find 7"); c(stb_matcher_find(mt, "mm anmannnnnnnmmmmmm fzmzzfnzz ") == 0, "stb_matcher_find 8"); c(stb_matcher_find(mt, "manmfnmannnnnnnmmmmmmmmmffzzz ") == 1, "stb_matcher_find 9"); stb_free(mt); mt = stb_regex_matcher(".*m((foo|bar)*|baz)m.*"); c(stb_matcher_match(mt, "abfoobarx") == 0, "stb_matcher_match 18"); c(stb_matcher_match(mt, "a mfoofoofoobazm d") == 0, "stb_matcher_match 19"); c(stb_matcher_match(mt, "a mfoobarbazfoom d") == 0, "stb_matcher_match 20"); c(stb_matcher_match(mt, "a mbazm d") == 1, "stb_matcher_match 21"); c(stb_matcher_match(mt, "a mfoobarfoom d") == 1, "stb_matcher_match 22"); c(stb_matcher_match(mt, "a mm foobarfoobarfoobar ") == 1, "stb_matcher_match 23"); stb_free(mt); mt = stb_regex_matcher("[a-fA-F]..[^]a-zA-Z]"); c(stb_matcher_match(mt, "Axx1") == 1, "stb_matcher_match 24"); c(stb_matcher_match(mt, "Fxx1") == 1, "stb_matcher_match 25"); c(stb_matcher_match(mt, "Bxx]") == 0, "stb_matcher_match 26"); c(stb_matcher_match(mt, "Cxxz") == 0, "stb_matcher_match 27"); c(stb_matcher_match(mt, "gxx[") == 0, "stb_matcher_match 28"); c(stb_matcher_match(mt, "-xx0") == 0, "stb_matcher_match 29"); stb_free(mt); c(stb_wildmatch("foo*bar", "foobarx") == 0, "stb_wildmatch 0a"); c(stb_wildmatch("foo*bar", "foobar") == 1, "stb_wildmatch 1a"); c(stb_wildmatch("foo*bar", "foo bar") == 1, "stb_wildmatch 2a"); c(stb_wildmatch("foo*bar", "fo foo ba ba bar ba") == 0, "stb_wildmatch 3a"); c(stb_wildmatch("foo*bar", "fo oo oo ba ba ar foo") == 0, "stb_wildmatch 4a"); c(stb_wildmatch("*foo*bar*", "foobar") == 1, "stb_wildmatch 1b"); c(stb_wildmatch("*foo*bar*", "foo bar") == 1, "stb_wildmatch 2b"); c(stb_wildmatch("*foo*bar*", "fo foo ba ba bar ba") == 1, "stb_wildmatch 3b"); c(stb_wildmatch("*foo*bar*", "fo oo oo ba ba ar foo") == 0, "stb_wildmatch 4b"); c(stb_wildmatch("foo*bar*", "foobarx") == 1, "stb_wildmatch 1c"); c(stb_wildmatch("foo*bar*", "foobabar") == 1, "stb_wildmatch 2c"); c(stb_wildmatch("foo*bar*", "fo foo ba ba bar ba") == 0, "stb_wildmatch 3c"); c(stb_wildmatch("foo*bar*", "fo oo oo ba ba ar foo") == 0, "stb_wildmatch 4c"); c(stb_wildmatch("*foo*bar", "foobar") == 1, "stb_wildmatch 1d"); c(stb_wildmatch("*foo*bar", "foo bar") == 1, "stb_wildmatch 2d"); c(stb_wildmatch("*foo*bar", "fo foo ba ba bar ba") == 0, "stb_wildmatch 3d"); c(stb_wildmatch("*foo*bar", "fo oo oo ba ba ar foo") == 0, "stb_wildmatch 4d"); c(stb_wildfind("foo*bar", "xyfoobarx") == 2, "stb_wildfind 0a"); c(stb_wildfind("foo*bar", "aaafoobar") == 3, "stb_wildfind 1a"); c(stb_wildfind("foo*bar", "foo bar") == 0, "stb_wildfind 2a"); c(stb_wildfind("foo*bar", "fo foo ba ba bar ba") == 3, "stb_wildfind 3a"); c(stb_wildfind("foo*bar", "fo oo oo ba ba ar foo") == -1, "stb_wildfind 4a"); c(stb_wildmatch("*foo*;*bar*", "foobar") == 1, "stb_wildmatch 1e"); c(stb_wildmatch("*foo*;*bar*", "afooa") == 1, "stb_wildmatch 2e"); c(stb_wildmatch("*foo*;*bar*", "abara") == 1, "stb_wildmatch 3e"); c(stb_wildmatch("*foo*;*bar*", "abaza") == 0, "stb_wildmatch 4e"); c(stb_wildmatch("*foo*;*bar*", "foboar") == 0, "stb_wildmatch 5e"); test_sha1(); n = sizeof(args_raw)/sizeof(args_raw[0]); memcpy(args, args_raw, sizeof(args_raw)); s = stb_getopt(&n, args); c(n >= 1 && !strcmp(args[1], "bar" ), "stb_getopt 1"); c(stb_arr_len(s) >= 2 && !strcmp(s[2] , "r" ), "stb_getopt 2"); stb_getopt_free(s); n = sizeof(args_raw)/sizeof(args_raw[0]); memcpy(args, args_raw, sizeof(args_raw)); s = stb_getopt_param(&n, args, "f"); c(stb_arr_len(s) >= 3 && !strcmp(s[3] , "fbar"), "stb_getopt 3"); stb_getopt_free(s); n = sizeof(args_raw)/sizeof(args_raw[0]); memcpy(args, args_raw, sizeof(args_raw)); s = stb_getopt_param(&n, args, "x"); c(stb_arr_len(s) >= 2 && !strcmp(s[1] , "xrf" ), "stb_getopt 4"); stb_getopt_free(s); n = sizeof(args_raw)/sizeof(args_raw[0]); memcpy(args, args_raw, sizeof(args_raw)); s = stb_getopt_param(&n, args, "s"); c(s == NULL && n == 0 , "stb_getopt 5"); stb_getopt_free(s); #if 0 c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, -1, -1) == 1, "stb_csample_int 1"); c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 1, -3) == 2, "stb_csample_int 2"); c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 12, -2) == 5, "stb_csample_int 3"); c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 15, 1) == 10, "stb_csample_int 4"); c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 5, 4) == 15, "stb_csample_int 5"); c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 3, 3) == 14, "stb_csample_int 6"); c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, -2, 5) == 11, "stb_csample_int 7"); c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, -7, 0) == 1, "stb_csample_int 8"); c(*stb_csample_int(sample_test[0], 1, 5, 5, 3, 2, 1) == 8, "stb_csample_int 9"); #endif c(!strcmp(stb_splitpath(buf, p1, STB_PATH ), "foo/bar\\baz/"), "stb_splitpath 1"); c(!strcmp(stb_splitpath(buf, p1, STB_FILE ), "test"), "stb_splitpath 2"); c(!strcmp(stb_splitpath(buf, p1, STB_EXT ), ".xyz"), "stb_splitpath 3"); c(!strcmp(stb_splitpath(buf, p1, STB_PATH_FILE ), "foo/bar\\baz/test"), "stb_splitpath 4"); c(!strcmp(stb_splitpath(buf, p1, STB_FILE_EXT ), "test.xyz"), "stb_splitpath 5"); c(!strcmp(stb_splitpath(buf, p2, STB_PATH ), "foo/"), "stb_splitpath 6"); c(!strcmp(stb_splitpath(buf, p2, STB_FILE ), ""), "stb_splitpath 7"); c(!strcmp(stb_splitpath(buf, p2, STB_EXT ), ".bar"), "stb_splitpath 8"); c(!strcmp(stb_splitpath(buf, p2, STB_PATH_FILE ), "foo/"), "stb_splitpath 9"); c(!strcmp(stb_splitpath(buf, p2, STB_FILE_EXT ), ".bar"), "stb_splitpath 10"); c(!strcmp(stb_splitpath(buf, p3, STB_PATH ), "./"), "stb_splitpath 11"); c(!strcmp(stb_splitpath(buf, p3, STB_FILE ), "foo"), "stb_splitpath 12"); c(!strcmp(stb_splitpath(buf, p3, STB_EXT ), ".bar"), "stb_splitpath 13"); c(!strcmp(stb_splitpath(buf, p3, STB_PATH_FILE ), "foo"), "stb_splitpath 14"); c(!strcmp(stb_splitpath(buf, p4, STB_PATH ), "foo/"), "stb_splitpath 16"); c(!strcmp(stb_splitpath(buf, p4, STB_FILE ), "bar"), "stb_splitpath 17"); c(!strcmp(stb_splitpath(buf, p4, STB_EXT ), ""), "stb_splitpath 18"); c(!strcmp(stb_splitpath(buf, p4, STB_PATH_FILE ), "foo/bar"), "stb_splitpath 19"); c(!strcmp(stb_splitpath(buf, p4, STB_FILE_EXT ), "bar"), "stb_splitpath 20"); c(!strcmp(p=stb_dupreplace("testfootffooo foo fox", "foo", "brap"), "testbraptfbrapo brap fox"), "stb_dupreplace 1"); free(p); c(!strcmp(p=stb_dupreplace("testfootffooo foo fox", "foo", "" ), "testtfo fox" ), "stb_dupreplace 2"); free(p); c(!strcmp(p=stb_dupreplace("abacab", "a", "aba"), "abababacabab" ), "stb_dupreplace 3"); free(p); #if 0 m = stb_mml_parse("xy<&f>"); c(m != NULL, "stb_mml_parse 1"); if (m) { c(!strcmp(m->child[0]->child[0]->child[1]->tag, "d"), "stb_mml_parse 2"); c(!strcmp(m->child[0]->child[1]->leaf_data, "<&f>"), "stb_mml_parse 3"); } if (m) stb_mml_free(m); c(stb_alloc_count_alloc == stb_alloc_count_free, "stb_alloc 1"); if (stb_alloc_count_alloc != stb_alloc_count_free) { printf("%d allocs, %d frees\n", stb_alloc_count_alloc, stb_alloc_count_free); } #endif c(stb_linear_remap(3.0f,0,8,1,2) == 1.375, "stb_linear_remap()"); c(stb_bitreverse(0x1248fec8) == 0x137f1248, "stb_bitreverse() 1"); c(stb_bitreverse8(0x4e) == 0x72, "stb_bitreverse8() 1"); c(stb_bitreverse8(0x31) == 0x8c, "stb_bitreverse8() 2"); for (n=1; n < 255; ++n) { unsigned int m = stb_bitreverse8((uint8) n); c(stb_bitreverse8((uint8) m) == (unsigned int) n, "stb_bitreverse8() 3"); } for (n=2; n <= 31; ++n) { c(stb_is_pow2 ((1 << n) ) == 1 , "stb_is_pow2() 1"); c(stb_is_pow2 ((1 << n)+1) == 0 , "stb_is_pow2() 2"); c(stb_is_pow2 ((1 << n)-1) == 0 , "stb_is_pow2() 3"); c(stb_log2_floor((1 << n) ) == n , "stb_log2_floor() 1"); c(stb_log2_floor((1 << n)+1) == n , "stb_log2_floor() 2"); c(stb_log2_floor((1 << n)-1) == n-1, "stb_log2_floor() 3"); c(stb_log2_ceil ((1 << n) ) == n , "stb_log2_ceil() 1"); c(stb_log2_ceil ((1 << n)+1) == n+1, "stb_log2_ceil() 2"); c(stb_log2_ceil ((1 << n)-1) == n , "stb_log2_ceil() 3"); c(stb_bitreverse(1 << n) == 1U << (31-n), "stb_bitreverse() 2"); } c(stb_log2_floor(0) == -1, "stb_log2_floor() 4"); c(stb_log2_ceil (0) == -1, "stb_log2_ceil () 4"); c(stb_log2_floor(-1) == 31, "stb_log2_floor() 5"); c(stb_log2_ceil (-1) == 32, "stb_log2_ceil () 5"); c(stb_bitcount(0xffffffff) == 32, "stb_bitcount() 1"); c(stb_bitcount(0xaaaaaaaa) == 16, "stb_bitcount() 2"); c(stb_bitcount(0x55555555) == 16, "stb_bitcount() 3"); c(stb_bitcount(0x00000000) == 0, "stb_bitcount() 4"); c(stb_lowbit8(0xf0) == 4, "stb_lowbit8 1"); c(stb_lowbit8(0x10) == 4, "stb_lowbit8 2"); c(stb_lowbit8(0xf3) == 0, "stb_lowbit8 3"); c(stb_lowbit8(0xf8) == 3, "stb_lowbit8 4"); c(stb_lowbit8(0x60) == 5, "stb_lowbit8 5"); for (n=0; n < sizeof(buf); ++n) buf[n] = 0; for (n = 0; n < 200000; ++n) { unsigned int k = stb_rand(); int i,z=0; for (i=0; i < 32; ++i) if (k & (1 << i)) ++z; c(stb_bitcount(k) == z, "stb_bitcount() 5"); buf[k >> 24] = 1; if (k != 0) { if (stb_is_pow2(k)) { c(stb_log2_floor(k) == stb_log2_ceil(k), "stb_is_pow2() 1"); c(k == 1U << stb_log2_floor(k), "stb_is_pow2() 2"); } else { c(stb_log2_floor(k) == stb_log2_ceil(k)-1, "stb_is_pow2() 3"); } } c(stb_bitreverse(stb_bitreverse(n)) == (uint32) n, "stb_bitreverse() 3"); } // make sure reasonable coverage from stb_rand() for (n=0; n < sizeof(buf); ++n) c(buf[n] != 0, "stb_rand()"); for (n=0; n < sizeof(buf); ++n) buf[n] = 0; for (n=0; n < 60000; ++n) { float z = (float) stb_frand(); int n = (int) (z * sizeof(buf)); c(z >= 0 && z < 1, "stb_frand() 1"); c(n >= 0 && n < sizeof(buf), "stb_frand() 2"); buf[n] = 1; } // make sure reasonable coverage from stb_frand(), // e.g. that the range remap isn't incorrect for (n=0; n < sizeof(buf); ++n) c(buf[n] != 0, "stb_frand()"); // stb_arr { short *s = NULL; c(sum(s) == 0, "stb_arr 1"); stb_arr_add(s); s[0] = 3; stb_arr_push(s,7); c( stb_arr_valid(s,1), "stb_arr 2"); c(!stb_arr_valid(s,2), "stb_arr 3"); // force a realloc stb_arr_push(s,0); stb_arr_push(s,0); stb_arr_push(s,0); stb_arr_push(s,0); c(sum(s) == 10, "stb_arr 4"); stb_arr_push(s,0); s[0] = 1; s[1] = 5; s[2] = 20; c(sum(s) == 26, "stb_arr 5"); stb_arr_setlen(s,2); c(sum(s) == 6, "stb_arr 6"); stb_arr_setlen(s,1); c(sum(s) == 1, "stb_arr 7"); stb_arr_setlen(s,0); c(sum(s) == 0, "stb_arr 8"); stb_arr_push(s,3); stb_arr_push(s,4); stb_arr_push(s,5); stb_arr_push(s,6); stb_arr_push(s,7); stb_arr_deleten(s,1,3); c(stb_arr_len(s)==2 && sum(s) == 10, "stb_arr_9"); stb_arr_push(s,2); // 3 7 2 stb_arr_insertn(s,2,2); // 3 7 x x 2 s[2] = 5; s[3] = 6; c(s[0]==3 && s[1] == 7 && s[2] == 5 && s[3] == 6 && s[4] == 2, "stb_arr 10"); stb_arr_free(s); } #if 1 f= stb_fopen("data/stb.test", "wb"); fwrite(buffer, 1, sizeof(buffer)-1, f); stb_fclose(f, stb_keep_yes); #ifndef WIN32 sleep(1); // andLinux has some synchronization problem here #endif #else f= fopen("data/stb.test", "wb"); fwrite(buffer, 1, sizeof(buffer)-1, f); fclose(f); #endif if (!stb_fexists("data/stb.test")) { fprintf(stderr, "Error: couldn't open file just written, or stb_fexists() is broken.\n"); } f = fopen("data/stb.test", "rb"); // f = NULL; // test stb_fatal() if (!f) { stb_fatal("Error: couldn't open file just written\n"); } else { char temp[4]; int len1 = stb_filelen(f), len2; int n1,n2; if (fread(temp,1,4,f) == 0) { int n = ferror(f); if (n) { stb_fatal("Error reading from stream: %d", n); } if (feof(f)) stb_fatal("Weird, read 0 bytes and hit eof"); stb_fatal("Read 0, but neither feof nor ferror is true"); } fclose(f); p = stb_file("data/stb.test", &len2); if (p == NULL) stb_fatal("Error: stb_file() failed"); c(len1 == sizeof(buffer)-1, "stb_filelen()"); c(len2 == sizeof(buffer)-1, "stb_file():n"); c(memcmp(p, buffer, sizeof(buffer)-1) == 0, "stb_file()"); c(strcmp(p, buffer)==0, "stb_file() terminated"); free(p); s = stb_stringfile("data/stb.test", &n1); c(n1 == 3, "stb_stringfile():n"); n2 = 0; while (s[n2]) ++n2; c(n1 == n2, "stb_stringfile():n length matches the non-NULL strings"); if (n2 == 3) { c(strcmp(s[0],str1)==0, "stb_stringfile()[0]"); c(strcmp(s[1],str2)==0, "stb_stringfile()[1]"); c(strcmp(s[2],str3)==0, "stb_stringfile()[2] (no terminating newlines)"); } free(s); f = fopen("data/stb.test", "rb"); stb_fgets(buf, sizeof(buf), f); //c(strcmp(buf, str1)==0, "stb_fgets()"); p = stb_fgets_malloc(f); n1 = strlen(p); n2 = strlen(str2); c(strcmp(p, str2)==0, "stb_fgets_malloc()"); free(p); stb_fgets(buf, sizeof(buf), f); c(strcmp(buf, str3)==0, "stb_fgets()3"); } c( stb_prefix("foobar", "foo"), "stb_prefix() 1"); c(!stb_prefix("foo", "foobar"), "stb_prefix() 2"); c( stb_prefix("foob", "foob" ), "stb_prefix() 3"); stb_strncpy(buf, "foobar", 6); c(strcmp(buf,"fooba" )==0, "stb_strncpy() 1"); stb_strncpy(buf, "foobar", 8); c(strcmp(buf,"foobar")==0, "stb_strncpy() 2"); c(!strcmp(p=stb_duplower("FooBar"), "foobar"), "stb_duplower()"); free(p); strcpy(buf, "FooBar"); stb_tolower(buf); c(!strcmp(buf, "foobar"), "stb_tolower()"); p = stb_strtok(buf, "foo=ba*r", "#=*"); c(!strcmp(buf, "foo" ), "stb_strtok() 1"); c(!strcmp(p , "ba*r"), "stb_strtok() 2"); p = stb_strtok(buf, "foobar", "#=*"); c(*p == 0, "stb_strtok() 3"); c(!strcmp(stb_skipwhite(" \t\n foo"), "foo"), "stb_skipwhite()"); s = stb_tokens("foo == ba*r", "#=*", NULL); c(!strcmp(s[0], "foo "), "stb_tokens() 1"); c(!strcmp(s[1], " ba"), "stb_tokens() 2"); c(!strcmp(s[2], "r"), "stb_tokens() 3"); c(s[3] == 0, "stb_tokens() 4"); free(s); s = stb_tokens_allowempty("foo == ba*r", "#=*", NULL); c(!strcmp(s[0], "foo "), "stb_tokens_allowempty() 1"); c(!strcmp(s[1], "" ), "stb_tokens_allowempty() 2"); c(!strcmp(s[2], " ba"), "stb_tokens_allowempty() 3"); c(!strcmp(s[3], "r"), "stb_tokens_allowempty() 4"); c(s[4] == 0, "stb_tokens_allowempty() 5"); free(s); s = stb_tokens_stripwhite("foo == ba*r", "#=*", NULL); c(!strcmp(s[0], "foo"), "stb_tokens_stripwhite() 1"); c(!strcmp(s[1], "" ), "stb_tokens_stripwhite() 2"); c(!strcmp(s[2], "ba"), "stb_tokens_stripwhite() 3"); c(!strcmp(s[3], "r"), "stb_tokens_stripwhite() 4"); c(s[4] == 0, "stb_tokens_stripwhite() 5"); free(s); s = stb_tokens_quoted("foo =\"=\" ba*\"\"r \" foo\" bah ", "#=*", NULL); c(!strcmp(s[0], "foo"), "stb_tokens_quoted() 1"); c(!strcmp(s[1], "= ba"), "stb_tokens_quoted() 2"); c(!strcmp(s[2], "\"r foo bah"), "stb_tokens_quoted() 3"); c(s[3] == 0, "stb_tokens_quoted() 4"); free(s); p = stb_file("stb.h", &len2); if (p) { uint32 z = stb_adler32_old(1, p, len2); uint32 x = stb_adler32 (1, p, len2); c(z == x, "stb_adler32() 1"); memset(p,0xff,len2); z = stb_adler32_old((65520<<16) + 65520, p, len2); x = stb_adler32 ((65520<<16) + 65520, p, len2); c(z == x, "stb_adler32() 2"); free(p); } // stb_hheap { #define HHEAP_COUNT 100000 void **p = malloc(sizeof(*p) * HHEAP_COUNT); int i, j; #if 0 stb_hheap *h2, *h = stb_newhheap(sizeof(struct1),0); for (i=0; i < HHEAP_COUNT; ++i) p[i] = stb_halloc(h); stb_shuffle(p, HHEAP_COUNT, sizeof(*p), stb_rand()); for (i=0; i < HHEAP_COUNT; ++i) stb_hfree(p[i]); c(h->num_alloc == 0, "stb_hheap 1"); stb_delhheap(h); h = stb_newhheap(sizeof(struct1),0); h2 = stb_newhheap(sizeof(struct2),8); for (i=0; i < HHEAP_COUNT; ++i) { if (i & 1) p[i] = stb_halloc(h); else { p[i] = stb_halloc(h2); c((((int) p[i]) & 4) == 0, "stb_hheap 2"); } } stb_shuffle(p, HHEAP_COUNT, sizeof(*p), stb_rand()); for (i=0; i < HHEAP_COUNT; ++i) stb_hfree(p[i]); c(h->num_alloc == 0, "stb_hheap 3"); c(h2->num_alloc == 0, "stb_hheap 4"); stb_delhheap(h); stb_delhheap(h2); #else for (i=0; i < HHEAP_COUNT; ++i) p[i] = malloc(32); stb_shuffle(p, HHEAP_COUNT, sizeof(*p), stb_rand()); for (i=0; i < HHEAP_COUNT; ++i) free(p[i]); #endif // now use the same array of pointers to do pointer set operations for (j=100; j < HHEAP_COUNT; j += 25000) { stb_ps *ps = NULL; for (i=0; i < j; ++i) ps = stb_ps_add(ps, p[i]); for (i=0; i < HHEAP_COUNT; ++i) c(stb_ps_find(ps, p[i]) == (i < j), "stb_ps 1"); c(stb_ps_count(ps) == j, "stb_ps 1b"); for (i=j; i < HHEAP_COUNT; ++i) ps = stb_ps_add(ps, p[i]); for (i=0; i < j; ++i) ps = stb_ps_remove(ps, p[i]); for (i=0; i < HHEAP_COUNT; ++i) c(stb_ps_find(ps, p[i]) == !(i < j), "stb_ps 2"); stb_ps_delete(ps); } #define HHEAP_COUNT2 100 // now use the same array of pointers to do pointer set operations for (j=1; j < 40; ++j) { stb_ps *ps = NULL; for (i=0; i < j; ++i) ps = stb_ps_add(ps, p[i]); for (i=0; i < HHEAP_COUNT2; ++i) c(stb_ps_find(ps, p[i]) == (i < j), "stb_ps 3"); c(stb_ps_count(ps) == j, "stb_ps 3b"); for (i=j; i < HHEAP_COUNT2; ++i) ps = stb_ps_add(ps, p[i]); for (i=0; i < j; ++i) ps = stb_ps_remove(ps, p[i]); for (i=0; i < HHEAP_COUNT2; ++i) c(stb_ps_find(ps, p[i]) == !(i < j), "stb_ps 4"); stb_ps_delete(ps); } free(p); } n = test_compression(tc, sizeof(tc)); c(n >= 0, "stb_compress()/stb_decompress() 1"); p = stb_file("stb.h", &len2); if (p) { FILE *f = fopen("data/stb_h.z", "wb"); if (stb_compress_stream_start(f)) { int i; void *q; int len3; for (i=0; i < len2; ) { int n = stb_rand() % 10; if (n <= 6) n = 1 + stb_rand()%16; else if (n <= 8) n = 20 + stb_rand() % 1000; else n = 15000; if (i + n > len2) n = len2 - i; stb_write(p + i, n); i += n; } stb_compress_stream_end(1); q = stb_decompress_fromfile("data/stb_h.z", &len3); c(len3 == len2, "stb_compress_stream 2"); if (len2 == len3) c(!memcmp(p,q,len2), "stb_compress_stream 3"); if (q) free(q); } else { c(0, "stb_compress_stream 1"); } free(p); stb_compress_window(65536*4); } p = stb_file("stb.h", &len2); if (p) { n = test_compression(p, len2); c(n >= 0, "stb_compress()/stb_decompress() 2"); #if 0 n = test_en_compression(p, len2); c(n >= 0, "stb_en_compress()/stb_en_decompress() 2"); #endif free(p); } else { fprintf(stderr, "No stb.h to compression test.\n"); } p = stb_file("data/test.bmp", &len2); if (p) { n = test_compression(p, len2); c(n == 106141, "stb_compress()/stb_decompress() 4"); #if 0 n = test_en_compression(p, len2); c(n >= 0, "stb_en_compress()/stb_en_decompress() 4"); #endif free(p); } // the hardcoded compressed lengths being verified _could_ // change if you changed the compresser parameters; but pure // performance optimizations shouldn't change them p = stb_file("data/cantrbry.zip", &len2); if (p) { n = test_compression(p, len2); c(n == 642787, "stb_compress()/stb_decompress() 3"); #if 0 n = test_en_compression(p, len2); c(n >= 0, "stb_en_compress()/stb_en_decompress() 3"); #endif free(p); } p = stb_file("data/bible.txt", &len2); if (p) { n = test_compression(p, len2); c(n == 2022520, "stb_compress()/stb_decompress() 4"); #if 0 n = test_en_compression(p, len2); c(n >= 0, "stb_en_compress()/stb_en_decompress() 4"); #endif free(p); } { int len = 1 << 25, o=0; // 32MB char *buffer = malloc(len); int i; for (i=0; i < 8192; ++i) buffer[o++] = (char) stb_rand(); for (i=0; i < (1 << 15); ++i) buffer[o++] = 1; for (i=0; i < 64; ++i) buffer[o++] = buffer[i]; for (i=0; i < (1 << 21); ++i) buffer[o++] = 2; for (i=0; i < 64; ++i) buffer[o++] = buffer[i]; for (i=0; i < (1 << 21); ++i) buffer[o++] = 3; for (i=0; i < 8192; ++i) buffer[o++] = buffer[i]; for (i=0; i < (1 << 21); ++i) buffer[o++] = 4; assert(o < len); stb_compress_window(1 << 24); i = test_compression(buffer, len); c(n >= 0, "stb_compress() 6"); free(buffer); } #ifdef STB_THREADS stb_thread_cleanup(); #endif stb_ischar(0,NULL); stb_wrapper_listall(dumpfunc); printf("Memory still in use: %d allocations of %d bytes.\n", alloc_num, alloc_size); // force some memory checking for (n=1; n < 20; ++n) malloc(1 << n); printf("Finished stb.c with %d errors.\n", count); #ifdef _MSC_VER if (count) __asm int 3; #endif return 0; } #endif // NIST test vectors struct { int length; char *message; char *digest; } sha1_tests[] = { 24, "616263", "a9993e364706816aba3e25717850c26c9cd0d89d", 1304, "ec29561244ede706b6eb30a1c371d74450a105c3f9735f7fa9fe38cf67f304a5736a106e" "92e17139a6813b1c81a4f3d3fb9546ab4296fa9f722826c066869edacd73b25480351858" "13e22634a9da44000d95a281ff9f264ecce0a931222162d021cca28db5f3c2aa24945ab1" "e31cb413ae29810fd794cad5dfaf29ec43cb38d198fe4ae1da2359780221405bd6712a53" "05da4b1b737fce7cd21c0eb7728d08235a9011", "970111c4e77bcc88cc20459c02b69b4aa8f58217", 2096, "5fc2c3f6a7e79dc94be526e5166a238899d54927ce470018fbfd668fd9dd97cbf64e2c91" "584d01da63be3cc9fdff8adfefc3ac728e1e335b9cdc87f069172e323d094b47fa1e652a" "fe4d6aa147a9f46fda33cacb65f3aa12234746b9007a8c85fe982afed7815221e43dba55" "3d8fe8a022cdac1b99eeeea359e5a9d2e72e382dffa6d19f359f4f27dc3434cd27daeeda" "8e38594873398678065fbb23665aba9309d946135da0e4a4afdadff14db18e85e71dd93c" "3bf9faf7f25c8194c4269b1ee3d9934097ab990025d9c3aaf63d5109f52335dd3959d38a" "e485050e4bbb6235574fc0102be8f7a306d6e8de6ba6becf80f37415b57f9898a5824e77" "414197422be3d36a6080", "0423dc76a8791107d14e13f5265b343f24cc0f19", 2888, "0f865f46a8f3aed2da18482aa09a8f390dc9da07d51d1bd10fe0bf5f3928d5927d08733d" "32075535a6d1c8ac1b2dc6ba0f2f633dc1af68e3f0fa3d85e6c60cb7b56c239dc1519a00" "7ea536a07b518ecca02a6c31b46b76f021620ef3fc6976804018380e5ab9c558ebfc5cb1" "c9ed2d974722bf8ab6398f1f2b82fa5083f85c16a5767a3a07271d67743f00850ce8ec42" "8c7f22f1cf01f99895c0c844845b06a06cecb0c6cf83eb55a1d4ebc44c2c13f6f7aa5e0e" "08abfd84e7864279057abc471ee4a45dbbb5774afa24e51791a0eada11093b88681fe30b" "aa3b2e94113dc63342c51ca5d1a6096d0897b626e42cb91761058008f746f35465465540" "ad8c6b8b60f7e1461b3ce9e6529625984cb8c7d46f07f735be067588a0117f23e34ff578" "00e2bbe9a1605fde6087fb15d22c5d3ac47566b8c448b0cee40373e5ba6eaa21abee7136" "6afbb27dbbd300477d70c371e7b8963812f5ed4fb784fb2f3bd1d3afe883cdd47ef32bea" "ea", "6692a71d73e00f27df976bc56df4970650d90e45", 3680, "4893f1c763625f2c6ce53aacf28026f14b3cd8687e1a1d3b60a81e80fcd1e2b038f9145a" "b64a0718f948f7c3c9ac92e3d86fb669a5257da1a18c776291653688338210a3242120f1" "01788e8acc9110db9258b1554bf3d26602516ea93606a25a7f566c0c758fb39ecd9d876b" "c5d8abc1c3205095382c2474cb1f8bbdb45c2c0e659cb0fc703ec607a5de6bcc7a28687d" "b1ee1c8f34797bb2441d5706d210df8c2d7d65dbded36414d063c117b52a51f7a4eb9cac" "0782e008b47459ed5acac0bc1f20121087f992ad985511b33c866d18e63f585478ee5a5e" "654b19d81231d98683ae3f0533565aba43dce408d7e3c4c6be11d8f05165f29c9dcb2030" "c4ee31d3a04e7421aa92c3231a1fc07e50e95fea7389a5e65891afaba51cf55e36a9d089" "bf293accb356d5d06547307d6e41456d4ed146a056179971c56521c83109bf922866186e" "184a99a96c7bb96df8937e35970e438412a2b8d744cf2ad87cb605d4232e976f9f151697" "76e4e5b6b786132c966b25fc56d815c56c819af5e159aa39f8a93d38115f5580cda93bc0" "73c30b39920e726fe861b72483a3f886269ab7a8eefe952f35d25c4eb7f443f4f3f26e43" "d51fb54591e6a6dad25fcdf5142033084e5624bdd51435e77dea86b8", "dc5859dd5163c4354d5d577b855fa98e37f04384", 4472, "cf494c18a4e17bf03910631471bca5ba7edea8b9a63381e3463517961749848eb03abefd" "4ce676dece3740860255f57c261a558aa9c7f11432f549a9e4ce31d8e17c79450ce2ccfc" "148ad904aedfb138219d7052088520495355dadd90f72e6f69f9c6176d3d45f113f275b7" "fbc2a295784d41384cd7d629b23d1459a22e45fd5097ec9bf65fa965d3555ec77367903c" "32141065fc24da5c56963d46a2da3c279e4035fb2fb1c0025d9dda5b9e3443d457d92401" "a0d3f58b48469ecb1862dc975cdbe75ca099526db8b0329b03928206f084c633c04eef5e" "8e377f118d30edf592504be9d2802651ec78aeb02aea167a03fc3e23e5fc907c324f283f" "89ab37e84687a9c74ccf055402db95c29ba2c8d79b2bd4fa96459f8e3b78e07e923b8119" "8267492196ecb71e01c331f8df245ec5bdf8d0e05c91e63bb299f0f6324895304dda721d" "39410458f117c87b7dd6a0ee734b79fcbe482b2c9e9aa0cef03a39d4b0c86de3bc34b4aa" "dabfa373fd2258f7c40c187744d237080762382f547a36adb117839ca72f8ebbc5a20a07" "e86f4c8bb923f5787698d278f6db0040e76e54645bb0f97083995b34b9aa445fc4244550" "58795828dd00c32471ec402a307f5aa1b37b1a86d6dae3bcbfbe9ba41cab0beeabf489af" "0073d4b3837d3f14b815120bc3602d072b5aeefcdec655fe756b660eba7dcf34675acbce" "317746270599424b9248791a0780449c1eabbb9459cc1e588bfd74df9b1b711c85c09d8a" "a171b309281947e8f4b6ac438753158f4f36fa", "4c17926feb6e87f5bca7890d8a5cde744f231dab", 5264, "8236153781bd2f1b81ffe0def1beb46f5a70191142926651503f1b3bb1016acdb9e7f7ac" "ced8dd168226f118ff664a01a8800116fd023587bfba52a2558393476f5fc69ce9c65001" "f23e70476d2cc81c97ea19caeb194e224339bcb23f77a83feac5096f9b3090c51a6ee6d2" "04b735aa71d7e996d380b80822e4dfd43683af9c7442498cacbea64842dfda238cb09992" "7c6efae07fdf7b23a4e4456e0152b24853fe0d5de4179974b2b9d4a1cdbefcbc01d8d311" "b5dda059136176ea698ab82acf20dd490be47130b1235cb48f8a6710473cfc923e222d94" "b582f9ae36d4ca2a32d141b8e8cc36638845fbc499bce17698c3fecae2572dbbd4705524" "30d7ef30c238c2124478f1f780483839b4fb73d63a9460206824a5b6b65315b21e3c2f24" "c97ee7c0e78faad3df549c7ca8ef241876d9aafe9a309f6da352bec2caaa92ee8dca3928" "99ba67dfed90aef33d41fc2494b765cb3e2422c8e595dabbfaca217757453fb322a13203" "f425f6073a9903e2dc5818ee1da737afc345f0057744e3a56e1681c949eb12273a3bfc20" "699e423b96e44bd1ff62e50a848a890809bfe1611c6787d3d741103308f849a790f9c015" "098286dbacfc34c1718b2c2b77e32194a75dda37954a320fa68764027852855a7e5b5274" "eb1e2cbcd27161d98b59ad245822015f48af82a45c0ed59be94f9af03d9736048570d6e3" "ef63b1770bc98dfb77de84b1bb1708d872b625d9ab9b06c18e5dbbf34399391f0f8aa26e" "c0dac7ff4cb8ec97b52bcb942fa6db2385dcd1b3b9d567aaeb425d567b0ebe267235651a" "1ed9bf78fd93d3c1dd077fe340bb04b00529c58f45124b717c168d07e9826e33376988bc" "5cf62845c2009980a4dfa69fbc7e5a0b1bb20a5958ca967aec68eb31dd8fccca9afcd30a" "26bab26279f1bf6724ff", "11863b483809ef88413ca9b0084ac4a5390640af", 6056, "31ec3c3636618c7141441294fde7e72366a407fa7ec6a64a41a7c8dfda150ca417fac868" "1b3c5be253e3bff3ab7a5e2c01b72790d95ee09b5362be835b4d33bd20e307c3c702aa15" "60cdc97d190a1f98b1c78e9230446e31d60d25155167f73e33ed20cea27b2010514b57ba" "b05ed16f601e6388ea41f714b0f0241d2429022e37623c11156f66dd0fa59131d8401dba" "f502cffb6f1d234dcb53e4243b5cf9951688821586a524848123a06afa76ab8058bcfa72" "27a09ce30d7e8cb100c8877bb7a81b615ee6010b8e0daced7cc922c971940b757a9107de" "60b8454dda3452e902092e7e06faa57c20aadc43c8012b9d28d12a8cd0ba0f47ab4b377f" "316902e6dff5e4f2e4a9b9de1e4359f344e66d0565bd814091e15a25d67d89cf6e30407b" "36b2654762bbe53a6f204b855a3f9108109e351825cf9080c89764c5f74fb4afef89d804" "e7f7d097fd89d98171d63eaf11bd719df44c5a606be0efea358e058af2c265b2da2623fd" "afc62b70f0711d0150625b55672060cea6a253c590b7db1427a536d8a51085756d1e6ada" "41d9d506b5d51bcae41249d16123b7df7190e056777a70feaf7d9f051fdbbe45cbd60fc6" "295dda84d4ebbd7284ad44be3ee3ba57c8883ead603519b8ad434e3bf630734a9243c00a" "a07366b8f88621ec6176111f0418c66b20ff9a93009f43432aaea899dad0f4e3ae72e9ab" "a3f678f140118eb7117230c357a5caa0fe36c4e6cf1957bbe7499f9a68b0f1536e476e53" "457ed826d9dea53a6ded52e69052faaa4d3927b9a3f9e8b435f424b941bf2d9cd6849874" "42a44d5acaa0da6d9f390d1a0dd6c19af427f8bb7c082ae405a8dd535dea76aa360b4faa" "d786093e113424bb75b8cc66c41af637a7b2acdca048a501417919cf9c5cd3b2fa668860" "d08b6717eea6f125fa1b0bae1dbb52aafce8ae2deaf92aeb5be003fb9c09fedbc286ffb5" "e16ad8e07e725faa46ebc35500cf205fc03250075ddc050c263814b8d16d141db4ca289f" "386719b28a09a8e5934722202beb3429899b016dfeb972fee487cdd8d18f8a681042624f" "51", "f43937922444421042f76756fbed0338b354516f", 6848, "21b9a9686ec200456c414f2e6963e2d59e8b57e654eced3d4b57fe565b51c9045c697566" "44c953178f0a64a6e44d1b46f58763c6a71ce4c373b0821c0b3927a64159c32125ec916b" "6edd9bf41c3d80725b9675d6a97c8a7e3b662fac9dbcf6379a319a805b5341a8d360fe00" "5a5c9ac1976094fea43566d66d220aee5901bd1f2d98036b2d27eb36843e94b2e5d1f09c" "738ec826de6e0034cf8b1dca873104c5c33704cae290177d491d65f307c50a69b5c81936" "a050e1fe2b4a6f296e73549323b6a885c3b54ee5eca67aa90660719126b590163203909e" "470608f157f033f017bcf48518bf17d63380dabe2bc9ac7d8efe34aedcae957aeb68f10c" "8ad02c4465f1f2b029d5fbb8e8538d18be294394b54b0ee6e67a79fce11731604f3ac4f8" "d6ffa9ef3d2081f3d1c99ca107a7bf3d624324a7978ec38af0bcd0d7ee568572328b212b" "9dc831efb7880e3f4d6ca7e25f8e80d73913fb8edfffd758ae4df61b4140634a92f49314" "6138ebdcdaa083ea72d52a601230aa6f77874dcad9479f5bcac3763662cc30cb99823c5f" "f469dcbd64c028286b0e579580fd3a17b56b099b97bf62d555798f7a250e08b0e4f238c3" "fcf684198bd48a68c208a6268be2bb416eda3011b523388bce8357b7f26122640420461a" "bcabcb5004519adfa2d43db718bce7d0c8f1b4645c89315c65df1f0842e5741244bba3b5" "10801d2a446818635d0e8ffcd80c8a6f97ca9f878793b91780ee18eb6c2b99ffac3c38ef" "b7c6d3af0478317c2b9c421247eba8209ea677f984e2398c7c243696a12df2164417f602" "d7a1d33809c865b73397550ff33fe116166ae0ddbccd00e2b6fc538733830ac39c328018" "bcb87ac52474ad3cce8780d6002e14c6734f814cb551632bcc31965c1cd23d048b9509a4" "e22ab88f76a6dba209d5dd2febd1413a64d32be8574a22341f2a14e4bd879abb35627ef1" "35c37be0f80843006a7cc7158d2bb2a71bf536b36de20ca09bb5b674e5c408485106e6fa" "966e4f2139779b46f6010051615b5b41cda12d206d48e436b9f75d7e1398a656abb0087a" "a0eb453368fc1ecc71a31846080f804d7b67ad6a7aa48579c3a1435eff7577f4e6004d46" "aac4130293f6f62ae6d50c0d0c3b9876f0728923a94843785966a27555dd3ce68602e7d9" "0f7c7c552f9bda4969ec2dc3e30a70620db6300e822a93e633ab9a7a", "5d4d18b24b877092188a44be4f2e80ab1d41e795", 7640, "1c87f48f4409c3682e2cf34c63286dd52701b6c14e08669851a6dc8fa15530ad3bef692c" "7d2bf02238644561069df19bdec3bccae5311fce877afc58c7628d08d32d9bd2dc1df0a6" "24360e505944219d211f33bff62e9ff2342ac86070240a420ccaf14908e6a93c1b27b6e2" "0324e522199e83692805cc4c7f3ea66f45a490a50d4dd558aa8e052c45c1a5dfad452674" "edc7149024c09024913f004ceee90577ff3eaec96a1eebbdc98b440ffeb0cad9c6224efc" "9267d2c192b53dc012fb53010926e362ef9d4238d00df9399f6cbb9acc389a7418007a6c" "a926c59359e3608b548bdeece213f4e581d02d273781dffe26905ec161956f6dfe1c008d" "6da8165d08f8062eea88e80c055b499f6ff8204ffdb303ab132d9b0cba1e5675f3525bbe" "4cf2c3f2b00506f58336b36aefd865d37827f2fad7d1e59105b52f1596ea19f848037dfe" "dc9136e824ead5505e2995d4c0769276548835430667f333fc77375125b29c1b1535602c" "10fe161864f49a98fc274ae7335a736be6bf0a98cd019d120b87881103f86c0a6efadd8c" "aa405b6855c384141b4f8751cc42dc0cb2913382210baaa84fe242ca66679472d815c08b" "f3d1a7c6b5705a3de17ad157522de1eb90c568a8a1fbcbb422cca293967bb14bfdd91bc5" "a9c4d2774dee524057e08f937f3e2bd8a04ced0fc7b16fb78a7b16ee9c6447d99e53d846" "3726c59066af25c317fc5c01f5dc9125809e63a55f1cd7bdf7f995ca3c2655f4c7ab940f" "2aa48bc3808961eb48b3a03c731ce627bb67dd0037206c5f2c442fc72704258548c6a9db" "e16da45e40da009dc8b2600347620eff8361346116b550087cb9e2ba6b1d6753622e8b22" "85589b90a8e93902aa17530104455699a1829efef153327639b2ae722d5680fec035575c" "3b48d9ec8c8e9550e15338cc76b203f3ab597c805a8c6482676deabc997a1e4ba857a889" "97ceba32431443c53d4d662dd5532aa177b373c93bf93122b72ed7a3189e0fa171dfabf0" "520edf4b9d5caef595c9a3a13830c190cf84bcf9c3596aadb2a674fbc2c951d135cb7525" "3ee6c59313444f48440a381e4b95f5086403beb19ff640603394931f15d36b1cc9f3924f" "794c965d4449bfbdd8b543194335bdf70616dc986b49582019ac2bf8e68cfd71ec67e0aa" "dff63db39e6a0ef207f74ec6108fae6b13f08a1e6ae01b813cb7ee40961f95f5be189c49" "c43fbf5c594f5968e4e820a1d38f105f2ff7a57e747e4d059ffb1d0788b7c3c772b9bc1f" "e147c723aca999015230d22c917730b935e902092f83e0a8e6db9a75d2626e0346e67e40" "8d5b815439dab8ccb8ea23f828fff6916c4047", "32e0f5d40ceec1fbe45ddd151c76c0b3fef1c938", 8432, "084f04f8d44b333dca539ad2f45f1d94065fbb1d86d2ccf32f9486fe98f7c64011160ec0" "cd66c9c7478ed74fde7945b9c2a95cbe14cedea849978cc2d0c8eb0df48d4834030dfac2" "b043e793b6094a88be76b37f836a4f833467693f1aa331b97a5bbc3dbd694d96ce19d385" "c439b26bc16fc64919d0a5eab7ad255fbdb01fac6b2872c142a24aac69b9a20c4f2f07c9" "923c9f0220256b479c11c90903193d4e8f9e70a9dbdf796a49ca5c12a113d00afa844694" "de942601a93a5c2532031308ad63c0ded048633935f50a7e000e9695c1efc1e59c426080" "a7d1e69a93982a408f1f6a4769078f82f6e2b238b548e0d4af271adfa15aa02c5d7d7052" "6e00095ffb7b74cbee4185ab54385f2707e8362e8bd1596937026f6d95e700340b6338ce" "ba1ee854a621ce1e17a016354016200b1f98846aa46254ab15b7a128b1e840f494b2cdc9" "daccf14107c1e149a7fc27d33121a5cc31a4d74ea6945816a9b7a83850dc2c11d26d767e" "ec44c74b83bfd2ef8a17c37626ed80be10262fe63cf9f804b8460c16d62ae63c8dd0d124" "1d8aaac5f220e750cb68d8631b162d80afd6b9bf929875bf2e2bc8e2b30e05babd8336be" "31e41842673a66a68f0c5acd4d7572d0a77970f42199a4da26a56df6aad2fe420e0d5e34" "448eb2ed33afbfb35dffaba1bf92039df89c038bae3e11c02ea08aba5240c10ea88a45a1" "d0a8631b269bec99a28b39a3fc5b6b5d1381f7018f15638cc5274ab8dc56a62b2e9e4fee" "f172be20170b17ec72ff67b81c15299f165810222f6a001a281b5df1153a891206aca89e" "e7baa761a5af7c0493a3af840b9219e358b1ec1dd301f35d4d241b71ad70337bda42f0ea" "dc9434a93ed28f96b6ea073608a314a7272fefd69d030cf22ee6e520b848fa705ed6160f" "e54bd3bf5e89608506e882a16aced9c3cf80657cd03749f34977ced9749caa9f52b683e6" "4d96af371b293ef4e5053a8ea9422df9dd8be45d5574730f660e79bf4cbaa5f3c93a79b4" "0f0e4e86e0fd999ef4f26c509b0940c7a3eaf1f87c560ad89aff43cd1b9d4863aa3ebc41" "a3dd7e5b77372b6953dae497fc7f517efe99e553052e645e8be6a3aeb362900c75ce712d" "fcba712c4c25583728db9a883302939655ef118d603e13fcf421d0cea0f8fb7c49224681" "d013250defa7d4fd64b69b0b52e95142e4cc1fb6332486716a82a3b02818b25025ccd283" "198b07c7d9e08519c3c52c655db94f423912b9dc1c95f2315e44be819477e7ff6d2e3ccd" "daa6da27722aaadf142c2b09ce9472f7fd586f68b64d71fc653decebb4397bf7af30219f" "25c1d496514e3c73b952b8aa57f4a2bbf7dcd4a9e0456aaeb653ca2d9fa7e2e8a532b173" "5c4609e9c4f393dd70901393e898ed704db8e9b03b253357f333a66aba24495e7c3d1ad1" "b5200b7892554b59532ac63af3bdef590b57bd5df4fbf38d2b3fa540fa5bf89455802963" "036bd173fe3967ed1b7d", "ee976e4ad3cad933b283649eff9ffdb41fcccb18", 9224, "bd8320703d0cac96a96aeefa3abf0f757456bf42b3e56f62070fc03e412d3b8f4e4e427b" "c47c4600bb423b96de6b4910c20bc5c476c45feb5b429d4b35088813836fa5060ceb26db" "bb9162e4acd683ef879a7e6a0d6549caf0f0482de8e7083d03ed2f583de1b3ef505f4b2c" "cd8a23d86c09d47ba05093c56f21a82c815223d777d0cabb7ee4550423b5deb6690f9394" "1862ae41590ea7a580dda79229d141a786215d75f77e74e1db9a03c9a7eb39eb35adf302" "5e26eb31ca2d2ca507edca77d9e7cfcfd136784f2117a2afafa87fa468f08d07d720c933" "f61820af442d260d172a0a113494ca169d33a3aeaacdcc895b356398ed85a871aba769f6" "071abd31e9f2f5834721d0fef6f6ee0fc0e38760b6835dfcc7dbefb592e1f0c3793af7ad" "f748786d3364f3cfd5686b1a18711af220e3637d8fad08c553ce9d5dc1183d48e8337b16" "1fe69b50e1920316dbffec07425b5d616a805a699576590e0939f5c965bce6c7342d314a" "c37b9c4d30166567c4f633f182de4d6b00e20a1c762789f915eaa1c89ac31b85222b1f05" "403dedd94db9ce75ff4e49923d1999d032695fa0a1c595617830c3c9a7ab758732fcec26" "85ae14350959b6a5f423ef726587e186b055a8daf6fa8fdefa02841b2fdbca1616dcee78" "c685fc6dcc09f24a36097572eba3c37a3eabe98bc23836085f63ef71a54b4488615d83b2" "6ed28c9fce78852df9b6cf8a75ca3899a7567298e91bc4ffdd04ffab0066b43b8286a4bb" "555c78808496b252c6e0e4d153631f11f68baf88630e052acc2af5d2af2e22e4f23bb630" "314c561a577455f86b6727bcad3c19d3e271404dec30af3d9dd0ed63cd9fa708aadfa12a" "500ef2d99a6b71e137b56ba90036975b88004b45f577ef800f0fb3cf97577dc9da37253b" "8675e5c8bb7e0bd26564f19eca232fb25f280f82e014424c9fbdd1411d7556e5d7906bb8" "62206316ba03385cd820c54c82ed35b36735bc486b1885d84053eba036c1ebfb5422d93d" "a71c53deda7f74db07cd4959cdfa898ba37080d76b564d344b124dd7b80cd70ed3b52a6c" "f9c9a32695d134bd39eb11ddeecdac86c808e469bd8a7995b667c452e7d9a54d5c85bcf6" "d5ffdc27d491bc06f438f02c7cf018073431587c78ba08d18a8daccb2d3b26136f612ade" "c673f3cd5eb83412b29652d55a10d0d6238d0b5365db272c917349450aff062c36191cfc" "d45660819083f89cd42ecae9e26934a020cafeb9b2b68d544edf59574c0ca159fd195dbf" "3e3e74244d942fffdbd4ed7f626219bab88b5a07e50b09a832d3e8ad82091114e54f2c35" "6b48e55e36589ebad3ac6077cb7b1827748b00670df65bbf0a2e65caad3f8a97d654d64e" "1c7dad171cafbc37110d2f7ca66524dc08fe60593e914128bd95f41137bfe819b5ca835f" "e5741344b5c907ce20a35f4f48726141c6398e753ed9d46d3692050628c78859d5014fe4" "dd3708e58d4d9807f8dac540492e32fa579491717ad4145c9efc24cf95605660b2e09b89" "9369b74d3ebff41e707917ff314d93e6ac8dfd643ef2c087cd9912005b4b2681da01a369" "42a756a3e22123cbf38c429373c6a8663130c24b24b2690b000013960b1c46a32d1d5397" "47", "2df09b10933afedfcd3f2532dfd29e7cb6213859", 10016, "7a94978bec7f5034b12c96b86498068db28cd2726b676f54d81d8d7350804cc106bead8a" "252b465a1f413b1c41e5697f8cece49ec0dea4dfb9fa7b1bfe7a4a00981875b420d094bb" "1ce86c1b8c2e1dbebf819c176b926409fdec69042e324e71d7a8d75006f5a11f512811fe" "6af88a12f450e327950b18994dfc3f740631beda6c78bca5fe23d54e6509120e05cd1842" "d3639f1466cf26585030e5b4aefe0404fe900afc31e1980f0193579085342f1803c1ba27" "0568f80eaf92440c4f2186b736f6ab9dc7b7522ccdcfc8cf12b6375a2d721aa89b5ef482" "112a42c31123aebabcb485d0e72d6b6b70c44e12d2da98d1f87fa9df4f37847e1ffec823" "1b8be3d737d282ddb9cc4b95937acfa0f028ba450def4d134a7d0fc88119bf7296e18cd4" "4f56890b661b5b72ddfa34c29228067e13caf08eb3b7fd29de800df9a9ae137aad4a81a4" "16a301c9f74b66c0e163e243b3187996b36eb569de3d9c007d78df91f9b554eef0eaa663" "88754ce20460b75d95e2d0747229a1502a5652cf39ca58e1daa0e9321d7ab3093981cd70" "23a7ee956030dd70177028a66ad619ad0629e631f91228b7c5db8e81b276d3b168c1edb1" "bc0888d1cbcbb23245c2d8e40c1ff14bfe13f9c70e93a1939a5c45eef9351e795374b9e1" "b5c3a7bd642477ba7233e1f590ab44a8232c53099a3c0a6ffe8be8b7ca7b58e6fedf700f" "6f03dd7861ee1ef857e3f1a32a2e0baa591d0c7ca04cb231cc254d29cda873f00d68f465" "00d6101cfdc2e8004c1f333d8007325d06ffe6b0ff7b80f24ba51928e65aa3cb78752028" "27511207b089328bb60264595a2cebfc0b84d9899f5eca7ea3e1d2f0f053b4e67f975500" "7ff3705ca4178ab9c15b29dd99494135f35befbcec05691d91f6361cad9c9a32e0e65577" "f14d8dc66515081b51d09e3f6c25eea868cf519a83e80c935968cae6fce949a646ad53c5" "6ee1f07dda23daef3443310bc04670afedb1a0132a04cb64fa84b4af4b3dc501044849cd" "dd4adb8d733d1eac9c73afa4f7d75864c87787f4033ffe5ba707cbc14dd17bd1014b8b61" "509c1f55a25cf6c0cbe49e4ddcc9e4de3fa38f7203134e4c7404ee52ef30d0b3f4e69bcc" "7d0b2e4d8e60d9970e02cc69d537cfbc066734eb9f690a174e0194ca87a6fadad3883d91" "6bd1700a052b26deee832701590d67e6f78938eac7c4beef3061a3474dd90dd588c1cd6e" "6a4cda85b110fd08a30dcd85a3ebde910283366a17a100db920885600db7578be46bcfa6" "4765ba9a8d6d5010cb1766d5a645e48365ed785e4b1d8c7c233c76291c92ef89d70bc77f" "bf37d7ce9996367e5b13b08242ce73971f1e0c6ff2d7920fb9c821768a888a7fe0734908" "33efb854cbf482aed5cb594fb715ec82a110130664164db488666d6198279006c1aa521f" "9cf04250476c934eba0914fd586f62d6c5825b8cf82cd7ef915d93106c506ea6760fd8b0" "bf39875cd1036b28417de54783173446026330ef701c3a6e5b6873b2025a2c1666bb9e41" "a40adb4a81c1052047dabe2ad092df2ae06d6d67b87ac90be7d826ca647940c4da264cad" "43c32a2bb8d5e27f87414e6887561444a80ed879ce91af13e0fbd6af1b5fa497ad0cbd2e" "7f0f898f52f9e4710de2174e55ad07c45f8ead3b02cac6c811becc51e72324f2439099a0" "5740090c1b165ecae7dec0b341d60a88f46d7ad8624aac231a90c93fad61fcfbbea12503" "59fcd203862a6b0f1d71ac43db6c58a6b60c2c546edc12dd658998e8", "f32e70862a16e3e8b199e9d81a9949d66f812cad", 10808, "88dd7f273acbe799219c23184782ac0b07bade2bc46b4f8adbd25ed3d59c0fd3e2931638" "837d31998641bbb7374c7f03d533ca60439ac4290054ff7659cc519bdda3dff2129a7bdb" "66b3300068931ade382b7b813c970c8e15469187d25cb04b635403dc50ea6c65ab38a97c" "431f28a41ae81c16192bd0c103f03b8fa815d6ea5bf0aa7fa534ad413b194eb12eb74f5d" "62b3d3a7411eb8c8b09a261542bf6880acbdfb617a42e577009e482992253712f8d4c8bd" "1c386bad068c7aa10a22111640041f0c35dabd0de00ebf6cd82f89cbc49325df12419278" "ec0d5ebb670577b2fe0c3e0840c5dd0dc5b3da00669eed8ead380f968b00d42f4967faec" "c131425fce1f7edb01cbec7e96d3c26fa6390a659e0ab069ef3edadc07e077bb816f1b22" "98830a0fe2b393693bb79f41feca89577c5230e0a6c34b860dc1fdb10d85aa054481082c" "494779d59ba798fcd817116c3059b7831857d0364352b354ce3b960fbb61a1b8a04d47ca" "a0ead52a9bea4bada2646cdbaec211f391dac22f2c5b8748e36bfc3d4e8ea45131ca7f52" "af09df21babe776fcecbb5c5dfa352c790ab27b9a5e74242bbd23970368dbefd7c3c74d1" "61ae01c7e13c65b415f38aa660f51b69ea1c9a504fe1ad31987cb9b26a4db2c37d7b326c" "50dbc8c91b13925306ff0e6098532dee7282a99c3ddf99f9e1024301f76e31e58271870b" "d94b9356e892a6a798d422a48c7fd5b80efe855a4925cc93b8cf27badec5498338e2b538" "70758b45d3e7a2fa059ed88df320a65e0a7cf87fa7e63b74cea1b7371e221f8004726642" "30d4d57945a85b23d58f248c8cd06ccfabfa969ab8cb78317451fab60e4fdfa796e2e2a8" "b46405839a91266d37e8d38bae545fb4060c357923b86d62f5d59d7bef5af20fbb9c7fb4" "2c6fd487748ed3b9973dbf4b1f2c9615129fa10d21cc49c622842c37c01670be71715765" "a98814634efbdee66bf3420f284dbd3efafc8a9117a8b9a72d9b81aa53ded78c409f3f90" "bad6e30d5229e26f4f0cea7ee82c09e3b60ec0e768f35a7fb9007b869f9bfc49c518f648" "3c951d3b6e22505453266ec4e7fe6a80dbe6a2458a1d6cd93044f2955607412091009c7d" "6cd81648a3b0603c92bfdff9ec3c0104b07ed2105962ca7c56ede91cb932073c337665e2" "409387549f9a46da05bc21c5126bd4b084bc2c06ab1019c51df30581aa4464ab92978c13" "f6d7c7ac8d30a78f982b9a43181bbe3c3eb9f7a1230b3e53b98a3c2a028317827fbe8cf6" "ec5e3e6b2a084d517d472b25f72fab3a34415bba488f14e7f621cfa72396ba40890e8c60" "b04815601a0819c9bebc5e18b95e04be3f9c156bd7375d8cc8a97c13ce0a3976123419fa" "592631317ca638c1182be06886f9663d0e8e6839573df8f52219eeb5381482a6a1681a64" "173660bfbb6d98bf06ee31e601ee99b4b99b5671ed0253260b3077ed5b977c6a79b4ff9a" "08efd3cba5c39bec1a1e9807d40bbf0c988e0fd071cf2155ed7b014c88683cd869783a95" "4cbfced9c0e80c3a92d45b508985cbbc533ba868c0dc4f112e99400345cf7524e42bf234" "5a129e53da4051c429af2ef09aba33ae3c820ec1529132a203bd2b81534f2e865265f55c" "9395caf0e0d3e1762c95eaaec935e765dc963b3e0d0a04b28373ab560fa9ba5ca71ced5d" "17bb8b56f314f6f0d0bc8104b3f1835eca7eaac15adf912cf9a6945cfd1de392342dd596" "d67e7ffcb7e086a6c1ea318aa2e0c2b5c2da079078232c637de0d317a1f26640bc1dac5b" "e8699b53edc86e4bfdfaf797a2ae350bf4ea29790face675c4d2e85b8f37a694c91f6a14" "1fd561274392ee6ee1a14424d5c134a69bcb4333079400f03615952fc4c99bf03f5733a8" "dc71524269fc5c648371f5f3098314d9d10258", "08632c75676571a5db5971f5d99cb8de6bf1792a", 11600, "85d43615942fcaa449329fd1fe9efb17545eb252cac752228f1e9d90955a3cf4e72cb116" "3c3d8e93ccb7e4826206ff58b3e05009ee82ab70943db3f18a32925d6d5aed1525c91673" "bd33846571af815b09bb236466807d935b5816a8be8e9becbe65d05d765bcc0bc3ae66c2" "5320ebe9fff712aa5b4931548b76b0fd58f6be6b83554435587b1725873172e130e1a3ca" "3d9d0425f4632d79cca0683780f266a0633230e4f3b25f87b0c390092f7b13c66ab5e31b" "5a58dbcac8dd26a0600bf85507057bb36e870dfae76da8847875a1a52e4596d5b4b0a211" "2435d27e1dc8dd5016d60feaf2838746d436a2983457b72e3357059b2bf1e9148bb0551a" "e2b27d5a39abd3d1a62c36331e26668e8baabc2a1ef218b5e7a51a9ca35795bcd54f403a" "188eafafb30d82896e45ddaea4f418629a1fb76a0f539c7114317bac1e2a8fba5a868bce" "40abd40f6b9ced3fa8c0329b4de5ca03cc84d75b8746ef31e6c8d0a0a79b4f747690928e" "be327f8bbe9374a0df4c39c845bf3322a49fda9455b36db5a9d6e4ea7d4326cf0e0f7cd8" "0ff74538f95cec01a38c188d1243221e9272ccc1053e30787c4cf697043cca6fc3730d2a" "431ecbf60d73ee667a3ab114c68d578c66dc1c659b346cb148c053980190353f6499bfef" "acfd1d73838d6dc1188c74dd72b690fb0481eee481a3fd9af1d4233f05d5ae33a7b10d7d" "d643406cb1f88d7dd1d77580dcbee6f757eeb2bfbcc940f2cddb820b2718264b1a64115c" "b85909352c44b13d4e70bbb374a8594d8af7f41f65b221bf54b8d1a7f8f9c7da563550cb" "2b062e7a7f21d5e07dd9da8d82e5a89074627597551c745718094c2eb316ca077526d27f" "9a589c461d891dc7cd1bc20ba3f464da53c97924219c87a0f683dfb3b3ac8793c59e78ac" "fac109439221ac599a6fd8d2754946d6bcba60784805f7958c9e34ff287ad1dbbc888848" "fa80cc4200dbb8c5e4224535906cbffdd0237a77a906c10ced740f9c0ce7821f2dbf8c8d" "7d41ecfcc7dfdc0846b98c78b765d01fb1eb15ff39149ab592e5dd1152665304bba85bbf" "4705751985aaaf31245361554d561a2337e3daeef58a826492fd886d5f18ef568c1e772e" "f6461170407695e3254eb7bf0c683811ddde5960140d959114998f08bdb24a104095987d" "3255d590e0dbd41ae32b1ae4f4ea4a4f011de1388034231e034756870c9f2d9f23788723" "27055a7de2b5e931dfb53e7780b6d4294bf094e08567025b026db9203b681565a1d52f30" "318d0ebe49471b22ba5fd62e1ed6c8966c99b853c9062246a1ace51ef7523c7bf93bef53" "d8a9cb96d6a04f0da1eca888df66e0380a72525a7ecc6115d08569a66248f6ba34e2341b" "fd01a78f7b3c1cfe0754e0d26cba2fa3f951ef14d5749ff8933b8aba06fa40fb570b467c" "54ce0d3f0bed21e998e5a36b3bc2f9e1ae29c4bab59c121af6fad67c0b45959cd6a86194" "14b90b4535fb95f86ca7e64502acc135eff4f8a3abe9dde84238fab7a7d402454a3f07ad" "ec05ec94b2891e0879037fae6acaa31dcecf3f85236ade946f5ad69ad4077beb65099285" "38ee09f2bc38e5704da67b5006b5e39cd765aafcd740c7dadb99d0c547126e1324610fcb" "7353dac2c110e803fca2b17485b1c4b78690bc4f867e6f043b2568889f67985a465a48eb" "ee915200589e915756d4968d26529c3ffe3dbe70e84c682ad08a0c68db571634fbb0210d" "c1b16b8b725886465c8c51f36a5e27d0f78e5643e051d3bddd512ce511f6bdf3dfe42759" "00c5fea9d248c2b3f36911ed0ff41a19f6445521f251724657ea8f795b3ead0928a1657f" "308dd7c7c1e7e490d9849df43becfa5cc25ed09ef614fd69ddc7e5e3147623901d647876" "fb60077ffc48c51ed7d02b35f6802e3715fc708a0c88b82fe9cba0a442d38d09ca5ae483" "21487bdef1794e7636bf7457dd2b51a391880c34d229438347e5fec8555fe263f08ba87b" "b16dcde529248a477628067d13d0cb3bf51776f4d39fb3fbc5f669e91019323e40360e4b" "78b6584f077bf9e03b66", "ab7213f6becb980d40dc89fbda0ca39f225a2d33", 12392, "7ae3ca60b3a96be914d24980fb5652eb68451fed5fa47abe8e771db8301fbd5331e64753" "93d96a4010d6551701e5c23f7ecb33bec7dd7bade21381e9865d410c383a139cb4863082" "8e9372bd197c5b5788b6599853e8487bddfd395e537772fdd706b6a1de59c695d63427da" "0dc3261bce2e1ae3cd6de90ec45ecd7e5f14580f5672b6ccd8f9336330dffcd6a3612a74" "975afc08fb136450e25dc6b071ddfc28fca89d846c107fd2e4bd7a19a4ff6f482d62896d" "a583c3277e23ab5e537a653112cdf2306043b3cc39f5280bd744fe81d66f497b95650e7d" "dfd704efcb929b13e00c3e3a7d3cd53878af8f1506d9de05dba9c39a92604b394ea25acb" "a2cda7b4ae8b08098ba3f0fdea15359df76517be84377f33631c844313ac335aa0d590fe" "c472d805521f0905d44ca40d7391b292184105acd142c083761c1a038c4f5ed869ea3696" "99592a37817f64cb4205b66be1f1de6fa47a08e1bf1a94312fe61a29e71bab242af95a7b" "38d4fb412c682b30256d91e2a46b634535d02b495240cbdb842cbe17cba6a2b94073f3d5" "f9621ac92ddda66f98bed997216466b4bb0579d58945f8d7450808d9e285d4f1709d8a1d" "416aa57d4a1a72bfcbfecdda33de2cff3e90e0cc60c897c4663224fc5bbe8316a83c1773" "802837a57bc7e9238173ed41ea32fe5fe38e546014a16d5e80700d9bac7a84bb03902f31" "79e641f86f6bc383d656daf69801499633fb367ea7593195934c72bc9bf9624c0c845ebf" "c36eb7ad4b22fdfb45ca7d4f0d6708c69a21f6eaa6db6bde0f0bd9dc7ec9c6e24626d0a7" "8fbeeed4b391f871e80e6a9d207165832d4ff689296f9bca15dc03c7c0381659ea5335eb" "aafdc3e50d18e46b00f1844870d09c25afcdb0ff1ae69dd8f94f91aca6095ba6f2b6e594" "c4acfe9903485d21b684e31a6acc2162d40e1a7bb8114a860a07e76f5265666555f2418d" "f11ef8f7499656d12215f5da8d7d041ac72648d15d7661ad93b24f3f071334b0921d5bb0" "6f2c7ab09f5034518b5ae21cec379373e87d51c77d44a70c2337606aadeb9036716fd920" "a824e7ae18ce3de9f0ec3456f3454027d8c476b3f1854b240c309f6f9786fa8a073915d9" "7a019ce99aec3260c5f6b6346cd9c41cb9267f4475958e45289965548238c6b9f91a8784" "b4e0957ba8b73956012c9a2fc3428434b1c1679f6ed2a3e8e2c90238df428622046f668e" "e2b053f55e64ffd45600e05a885e3264af573bacee93d23d72a0222b5442ac80bc0a8b79" "4c2afcf3bc881d20c111f57e3450b50a703f3db1fc5de2076a006f3b7eed694b93269874" "3b03c2ed2684bad445e69a692e744c7ac3a04f1e0e52b7a6708076d1fbffdb3f1c995828" "7d5f884e29407030f2db06811092efd80ae08da9daec39744c5ecd3ca771663b8f4968d4" "2a88c2c9821c73ae2a5a4d9e2551f82c03583b9c4dea775423b4748d24eb604e8ee3159b" "a6de9bea5b22eed6264e011734ed02b2c74ce06dda890b8604ed7ba49e7bf30e28c9871b" "e90f5cead67eaf52b5d3181c822b10701219b28ef6f6bebfa278e38acf863e2a1d4b1e40" "fd8a0ac6ce31054446301046148bf10dc3ae3385e2026e7762bdc8003ffebc4263191a59" "c72f4f90db03e7d52808506b33bfe1dfa53f1a3daa152e83974fbe56cfd4e8f4e7f7806a" "084b9d0795b858100eced0b5355a72446f37779d6c67ade60a627b8077ae1f3996b03bc3" "a5c290651c8609f0d879fbf578cbab35086e1159dd6ddbe3bf7fb5654edcc8f09e4f80d0" "258c9376d7c53fb68f78d333b18b70170d9a11070790c956f5744c78c986b1baf08b7631" "7a65c5f07ae6f57eb0e65488659324d29709e3735623d0426e90aa8c4629bb080881150c" "02be1c004da84414ac001c2eb6138c26388f5a36d594f3acef0e69e2cb43b870efa84da0" "cff9c923a9880202aed64ad76260f53c45bb1584b3e388a909d13586094b924680006a1d" "25d4dd36c579a8ec9d3fa63c082d977a5a5021440b5314b51850f2daa6e6af6ae88cb5b1" "44242bceb1d4771e641101f8abfc3a9b19f2de64e35e76458ad22072ba57925d73015de5" "66c66fcaa28fdc656f90de967ad51afd331e246d74ed469d63dd7d219935c59984bd9629" "09d1af296eb3121d782650e7d038063bab5fa854aac77de5ffebeb53d263f521e3fc02ac" "70", "b0e15d39025f5263e3efa255c1868d4a37041382", 13184, "fa922061131282d91217a9ff07463843ae34ff7f8c28b6d93b23f1ea031d5020aa92f660" "8c3d3df0ee24a8958fd41af880ee454e36e26438defb2de8f09c018607c967d2f0e8b80a" "00c91c0eabe5b4c253e319b45e6106ff8bf0516f866020e5ba3f59fd669c5aeff310ebb3" "85007069d01c64f72d2b02f4ec0b45c5ecf313056afcb52b17e08b666d01fecc42adb5b4" "9ea00c60cacac2e0a953f1324bdd44aec00964a22a3cb33916a33da10d74ec6c6577fb37" "5dc6ac8a6ad13e00cba419a8636d4daac8383a2e98fe90790cde7b59cfaa17c410a52abc" "d68b127593d2fcbafd30578d195d890e981ae09e6772cb4382404a4e09f1a33c958b57db" "ccee54ae335b6c91443206a0c100135647b844f226417a1f70317fd350d9f3789d81894a" "aff4730072401aaeb8b713ead4394e2e64b6917d6eee2549af7bd0952f12035719065320" "ca0d2dfe2847c6a2357c52bee4a676b12bafff66597bd479aa29299c1896f63a7523a85a" "b7b916c5930ab66b4d191103cefc74f2f7e0e96e354f65e355ae43959a0af1880d14ea9d" "1569e4fd47174aba7f5decb430b3f6baf80a1ef27855227b62487250d3602970e423423c" "7ca90920685bcf75adfbe2a61ce5bd9228947b32f567927cb1a5bd8727c03aef91d6367b" "ae7d86fd15c0977ac965a88b0d7236037aefb8d24eec8d2a07c633e031a7b9147c4c7714" "110bfc7e261448a5d0f73c3619664e1c533c81a0acbf95d502227a33f84f0b8249e3f9fa" "5c7905a8192b7313fc56bb20679e81333d32c797ac5162204a0eaa0e64507635921c485b" "8f17c4e2484667a733197529e2a833eed83c57229b11bd820b5a5b78f1867787dbc217ea" "28bfba785fb545cbc5a840a12eea428213e1aaa4e50a900ba13efcf4a5345574c2481c5d" "927ada610bba567a55630c89d905db3d9b67fe36c9cc3d6a947664c83e69f51c74711a33" "df66dd3ff6af9b7c1605b614d4798b4192b9a4b1508f2e2ec5aaad7eaea1ee8867353db9" "b8d7d9a6f16aa5f339492073238c979082879aee7f94ac4be8133eaacbaedfb044e2ad4e" "93ba0fa071dea615a5cd80d1d2678f4f93ae5a4bc9cdf3df345a29ec41d8febb23805ce4" "2541036f3f05c63ae736f79a29802045fad9f370cabf843458c1b636ca41f387fd7821c9" "1abbd1946afcb9186b936403233f28a5b467595131a6bc07b0873e51a08de66b5d7709a6" "02c1bd0e7f6e8f4beb0579c51bda0e0c738ef876fcd9a40ab7873c9c31c1d63a588eebc7" "8d9a0ae6fa35cd1a269e0d2bc68252cbd7c08d79e96f0aa6be22a016136a2b8abe9d3c9c" "f9d60eeafe3dbc76d489b24d68c36167df4c38cf2b21cf03dc5e659e39018c3490f1237e" "ca3f85b742ab0045d86a899c4126ad60a147cbc95b71814c274d6478668df41eb32acfb4" "bbf024fb4e3d6be0b60653a0471afc3037ab67dcb00a2b2e24b26911e1880136e56106b7" "f3c570fbe6f311d94624cb001914ff96fbbf481f71686aa17be0850568058fc1ee8900b4" "7af5cf51c5ed9e00a8b532c131f42513f6b8df14a9bbc2e9ede5a560681184d41a147552" "edfbdef98d95e6a7793229d25ba9b0b395a020aa1c0731de89e662246d59ec22e5d8f4b4" "6fbc048efcffbc234744c5c66417070f9c751c81788f04691ccb1a09d60c46f6f73375bf" "e2e646cf6290069541a8dfe216374c925e94d06ece72e851e81d3e8acd011f82526c2f9f" "55955c6752dc10e93153ab58627e30fa2c573e4042954337982eec1f741be058c85bad86" "bf3a02ed96d3201dadd48bd4de8105200dfcbcc400c3c3dd717abfc562ebe338b14b1eb5" "ecbe9227661e49c58bf8233770d813faafc78b05711135adcc4ce4c65095ca0bdc1debc0" "b6e5d195dbc582ce94b3afa14a422edf9b69abd7ae869a78c3a26fb50ef7122ec5af8d0c" "78ef082ca114f8817c3d93b31809870caea2eb9533fa767c2954efb9ba07e4f1077e9f9b" "be845661eabea2c91079321477a7c167c7234528d63d6aabbe723e0e337b2e61138a310a" "3fd04368aa4215b7af9d0334a8a74681bcb86b4af87a0329a1ed9dc7c9aef14521785eda" "0eeb97bdff8c9945fd0ee04e84d0dae091a69c0bfcdcd4150878fed839c0db6565fc1fed" "0e7d6ae2efde7a59d58a9fb3b07e6f7cea51ba93f771c18b2eafa252d7fe171085776052" "a6a17e6858f0a20b7e8be54413523989bf20a028a84d9ce98b78e6ee0b8362df49de5344" "b409cc322354672a21ea383e870d047551a3af71aaf2f44f49a859cf001e61b592dd036f" "c6625bf7b91ea0fb78c1563cceb8c4345bf4a9fbe6ee2b6bf5e81083", "8b6d59106f04300cb57c7c961945cd77f3536b0a", 13976, "162cca41155de90f6e4b76a34261be6666ef65bdb92b5831b47604ce42e0c6c8d2eda265" "ab9a3716809bf2e745e7831a41768d0f6349a268d9ac6e6adfb832a5d51b75d7951cf60e" "03d9e40de6d351f1f6ade5143531cf32839401ca6dfb9dc7473daa607aeb0c3d1e8eb3db" "cc2f1231ad1dd394d7eac9d8dab726b895b1ee774fdcabc8031063ecfa41c71a9f03ad23" "904cc056f17c76a1059c43faffe30dfd157fdfd7d792e162bf7a889109550a0fc4c41523" "2af0c0d72dcbc2595299e1a1c2aeae549f7970e994c15e0ab02f113d740d38c32a4d8ec0" "79cd099d37d954ab7ef2800902cdf7c7a19fb14b3c98aaf4c6ad93fe9a9bc7a61229828e" "55ad4d6270d1bdbca9975d450f9be91e5699bd7ee22e8c9c22e355cf1f6793f3551cb510" "c1d5cd363bdf8cab063e6e49a6383221f1188d64692c1f84c910a696de2e72fb9886193f" "61ab6b41ad0ea894d37ff1261bf1fd1f187e0d0c38ab223d99ec6d6b1e6b079fc305e24e" "2d9500c98676e2d587434495d6e107b193c06fb12d5d8eaa7b0c001d08f4d91cae5bdcae" "6624ee755e95ca8e4c5ef5b903d7f5ba438abeffd6f16d82d88138f157e7a50d1c91fb50" "c770f6d222fcbf6daf791b1f8379e3b157a3b496ddb2e71650c1c4ac4fc5f2aceb5b3228" "ffc44e15c02d4baa9434e60928a93f21bc91cfd3c2719f53a8c9bcd2f2dee65a8bbc88f9" "5d7ced211fc3b04f6e8b74eb2026d66fd57fa0cccea43f0a0381782e6fee5660afed674d" "cb2c28cb54d2bdbbaf78e534b0742ede6b5e659b46cd516d5362a194dd0822f6417935c4" "ff05815b118fe5687cd8b050240015cfe449d9dfde1f4fdb105586e429b2c1849aac2791" "ef73bc54603190eba39037ec057e784bb92d497e705dfcde2addb3514b4f1926f12d5440" "850935779019b23bd0f2977a8c9478c424a7eaaeec04f3743a77bee2bec3937412e707bc" "92a070046e2f9c35fe5cc3f755bbb91a182e683591ab7e8cff40633730546e81522f588f" "07bdf142b78e115d2a22d2eb5664fcdb7574c1ee5ba9abd307d7d29078cd5223c222fc69" "60324c40cc639be84dad96b01059efce7b08538ebef89bafab834609c7e82774a14e5be6" "62067edba6111efa8ae270f5066442b17e3f31a793581c8a3f96d92921ec26981594e28a" "08987d020b97ad2ba5c662836e35fd3fd954bcec52b579528913959d0d942fbf1c4b9910" "ba010c3700359a4eb7616541257f0f7727cc71b580cc903f718ecc408a315b6bbfa7f6e3" "beb9d258804bd2731ee2fb75e763281baf1effc4690a23d5f952ab5d4311d4f5885af2eb" "f27cad9f6d84692cb903064bbd11ca751f919b4811b7722c6ec80c360521e34d357b5c8b" "ba6d42e5c632730f53add99ab8aa9c607b6796216753086ede158bc670d04900aca66ce8" "357bd72d19fb147b5fde8ee4df6a0184573a2e65ba3fd3a0cb04dac5eb36d17d2f639a6e" "b602645f3ab4da9de4c9999d6506e8e242a5a3216f9e79a4202558ecdc74249ad3caaf90" "71b4e653338b48b3ba3e9daf1e51e49384268d63f37ce87c6335de79175cdf542d661bcd" "74b8f5107d6ab492f54b7c3c31257ecb0b426b77ed2e2ed22bbfdaf49653e1d54e5988fa" "d71397546f9955659f22b3a4117fc823a1e87d6fb6fb8ab7d302a1316975e8baf0c0adbd" "35455655f6a596b6ac3be7c9a8ea34166119d5e70dfbc1aa6e14ff98eff95e94ef576656" "5d368ec8857fb0b029bcb990d420a5ca6bc7ab08053eb4dbfc4612a345d56faefc5e03a4" "43520b224de776a5b618e1aa16edc513d5fcefcd413031b0ddc958a6fca45d108fbde065" "3cf2d11cb00a71cd35f57993875598b4e33e2384623a0986859105d511c717c21d6534bf" "69fd3d7cf1682e4fc25298d90df951e77a316996beac61bb7078988118c906548af92cfe" "72cd4b102ffad584e5e721a0cdb5621ed07dda8955d84bea57a5afa4ba06289ddfac3a9e" "765538fd9392fc7904cedb65e38cd90967f01845ff819777a22d199f608e62c13e6ba98b" "40824b38c784bdb41d62c4014fc7e8d93be52695e975e54d1ff92b412f451177143d74a6" "bde0ee53a986043ab465a1ef315ac4c538e775ef4178fde5f2ea560a364de18b8fe9578a" "ad80027c3fd32dcf0967d9d03789b1cdf19040762f626289cf3af8afe5a8e0a152d9258e" "981872c1ec95cd7f8d65812e55cb5cbd8db61b3f068a23d9652372dfbf18d43a663c5a0d" "026b0898e383ce5c95b0ba7fb5ed6b7304c7c9d3ba64f38d1dc579465148ccfa7271f2e3" "e0e97e9ddac7c0874f0f396cf07851638a734df393687b7b0343afd1652ff32a2da17b3a" "4c99d79c02256c73f32625527e5666594a8a42a12135eddb022e743371b3ab7b12ad6785" "7635eed03558ac673d17280769b2368056276d5d72f5dbc75525f8a7558bd90b544aa6cb" "dd964e6c70be79441969bfdf471f17a2dc0c92", "6144c4786145852e2a01b20604c369d1b9721019", 14768, "c9bed88d93806b89c2d028866842e6542ab88c895228c96c1f9f05125f8697c7402538b0" "6465b7ae33daef847500f73d20c598c86e4804e633e1c4466e61f3ed1e9baadc5723bbed" "9455a2ff4f99b852cfe6aa3442852ade0b18e4995ddab4250928165a9441de108d4a293d" "1d95935de022aa17f366a31d4f4c4c54557a4235a9d56473444787ddc5c06c87087aef24" "fa8280b7ac74d76ba685e4be7dc705e5a8a97c6c8fbd201ee5bf522438d23371c60c155d" "93352f8fb8cc9421fe4b66ffabad46909c2c1099944fc55ed424c90aecca4f50d0331153" "2e2844c3ff8ecb495de7ab26941cbf177b79ad7b05f918b713c417da8cf6e67db0a2dcee" "a9179d8d636191759e13955f4244f0c4f2d88842e3015641ef0417d6e54144e8246e4591" "6823e2c6e39bfa3b90b97781c44981710689f2ce20e70a26760d65f9971b291e12338461" "8b3b56710dde2afaa2d46b0e2164d5c9482729350a0e256b2aa6b3fb099b618ebd7c11ca" "62bdf176b502aedfdf9be57a8e4adbca4a4d6d8407984af2f6635f95a1e4930e375eb53f" "245ab2ade5340c281bda87afded1268e537955c9819168bd60fd440533c75c9b1865e03f" "de3a301d165f97aa6da236cf39cf3e49512f6350224f8d76ff02d0d3b9a99e5f70b23b9f" "a85f72849fc98790df246c3a0f4437940e60d42b4317f72e2eb055d343a614f7f9648005" "1e4dff186dff476462d9ced24dbb82eaa60cbbf6a0026e64001da36d30f529f48f3688b1" "0ce9378ef3f50f5106e5007cd0eb037136254fda4f20d048769bd51a9d8d09a1e469a482" "6aa0e25b6267b5a96abcb6e919a362fdd7b683d2f2dcec40ee5969311c07f6066ee22f36" "89ca08381c85bea470040e9541e7a451cd43d62c2aa292a9dc4b95e3a7c4de2ba29663f3" "8d5002eb64ceba6934bb1b0e2e55fba7fa706b514ebeeae1be4dd882d6512da066246a05" "1d8bd042593bd0513e9cc47806ccdc7097e75bc75b8603834c85cd084e0ade3cc2c2b7e8" "586eac62249f9769f5bdcd50e24e515f257548762db9adf3ee0846d67cfcd723d85d9588" "09e6dd406f4c2637557c356fc52490a2a0763429ee298a1c72c098bb810e740c15faffc6" "1e80cf6e18f86dc0e29bc150ce43ca71f5729356cd966277fd8b32366f6263c3a761b13d" "544a631a25e1c4c8dea8d794abed47ccb4069d20f1dcb54e40a673ffb5f7b2eb31fb7d44" "36fd8252f92dc35bb9a18fc55099b17e0807e79caf4f9641ee4bbbc2d6922508bcfae236" "475bf78bc796548bc8d60659e816af68e5e43352fa64b5086c97c22c60ddcbbbefb9d9ef" "7cd57c64454604793910f4f90aedb4fb824a86061a93bb79c9b0272a1ad0d24e8165f099" "ef6f14a6a4fea09845f280022e061804090d7ab79f7bddcbef264b6f7d4e9971eddb9ca7" "d0e79a8dbe7cff2fa59f514a608d66ae8c44d5e69745aa1b19995e366812064567d3ca20" "9e12994c901d1b1f489be7253615f7c339b5581afd4d262e879ab8480ecb18990d3db61f" "96895dcde9c065e645f52baafefcbe34d072dba373fd1c786fd56c3f3284be7260eaff9a" "6a8348b762ed59e20ea443313b1164db53c3989c32fcae5b366f190b9548e8cff46df961" "350369b490354ed8e530a91f5072967eff45c63540862fb2deab02b3ae05deac65414368" "ac3549f277da92b692947de47cba9c1579526931e31c3490c1d3605f9bafcf468c2e9b47" "981407ea40b0b59754621943095a2d4f4ba266ac545fe7447e54f69555a7ac9ff1e8f001" "834fa65f2d4523061726e4d3bf4680519032dc21b7389e9f3229e4c2295d354482f8b803" "b06ca3a8cb3ff786e60f6bc59dd3a5bfed63b0aa493bab78e97bbefb6633534d84de826f" "4e2ccc3069050d50a2caace6c9de15ffc2656988d94b736e5688df0351a3a6a4c875cd99" "ef304f3cc7a0585df2b0b3e6c62f86bba0d43de47b80c4eec1c4f98e60a36188219919cf" "36dc10ee11e174a67d226ad9e71f02a7fca26ad67a4862773f3defc6a747545314063e5f" "ce7a3f890ec57daa5532acfd027739832437c8a58dcbe11c2842e60e8ca64979d081fbd5" "a1a028f59317212fb5869abc689a156171d69e4f4c93b949c3459904c00192d3603cd184" "48d64b843c57f34aee7830f313e58e2abc41b44be46a96c845ffebcb7120e21d1d751046" "c072adf65dd901a39c8019742054be5e159ea88d0885ee05fcd4c189bafe5abb68603186" "5dc570b9342fa7f41fd5c1c87e68371ab19a83c82ae1d890c678102d5da8e6c29845657c" "027ba07362cba4d24950ab38e747925e22ce8df9eaec1ae2c6d23374b360c8352feb6cb9" "913e4fc49bde6caf5293030d0d234a8ecd616023cc668262591f812de208738e5336a9e6" "9f9be2479b86be1e1369761518dfc93797ed3a55308878a944581eba50bc9c7f7a0e75c7" "6a28acd95b277857726f3f684eefc215e0a696f47d65d30431d710d957c08ef96682b385" "0ee5ba1c8417aafc1af2846a127ec155b4b7fb369e90eb3a5c3793a3389bbc6b532ca32b" "f5e1f03c2280e71c6e1ae21312d4ff163eee16ebb1fdee8e887bb0d453829b4e6ed5fa70" "8f2053f29b81e277be46", "a757ead499a6ec3d8ab9814f839117354ae563c8" }; void test_sha1(void) { unsigned char buffer[4000]; int i; for (i=0; i < sizeof(sha1_tests) / sizeof(sha1_tests[0]); ++i) { stb_uint len = sha1_tests[i].length / 8; unsigned char digest[20], fdig[20]; unsigned int h; assert(len <= sizeof(buffer)); assert(strlen(sha1_tests[i].message) == len*2); assert(strlen(sha1_tests[i].digest) == 20 * 2); for (h=0; h < len; ++h) { char v[3]; v[0] = sha1_tests[i].message[h*2]; v[1] = sha1_tests[i].message[h*2+1]; v[2] = 0; buffer[h] = (unsigned char) strtol(v, NULL, 16); } stb_sha1(digest, buffer, len); for (h=0; h < 20; ++h) { char v[3]; int res; v[0] = sha1_tests[i].digest[h*2]; v[1] = sha1_tests[i].digest[h*2+1]; v[2] = 0; res = digest[h] == strtol(v, NULL, 16); c(res, sha1_tests[i].digest); if (!res) break; } { int z; FILE *f = fopen("data/test.bin", "wb"); if (!f) stb_fatal("Couldn't write to test.bin"); fwrite(buffer, len, 1, f); fclose(f); #ifdef _WIN32 z = stb_sha1_file(fdig, "data/test.bin"); if (!z) stb_fatal("Couldn't digest test.bin"); c(memcmp(digest, fdig, 20)==0, "stb_sh1_file"); #endif } } } #if 0 stb__obj zero, one; void test_packed_floats(void) { stb__obj *p; float x,y,*q; clock_t a,b,c; int i; stb_float_init(); for (i=-10; i < 10; ++i) { float f = (float) pow(10,i); float g = f * 10; float delta = (g - f) / 10000; while (f < g) { stb__obj z = stb_float(f); float k = stb_getfloat(z); float p = stb_getfloat_table(z); assert((z & 1) == 1); assert(f == k); assert(k == p); f += delta; } } zero = stb_float(0); one = stb_float(1); p = malloc(8192 * 4); for (i=0; i < 8192; ++i) p[i] = stb_rand(); for (i=0; i < 8192; ++i) if ((stb_rand() & 31) < 28) p[i] = zero; q = malloc(4 * 1024); a = clock(); x = y = 0; for (i=0; i < 200000000; ++i) q[i&1023] = stb_getfloat_table(p[i&8191]); b = clock(); for (i=0; i < 200000000; ++i) q[i&1023] = stb_getfloat_table2(p[i&8191]); c = clock(); free(p); free(q); printf("Table: %d\nIFs: %d\n", b-a, c-b); } #endif void do_compressor(int argc,char**argv) { char *p; int len; int window; if (argc == 2) { p = stb_file(argv[1], &len); if (p) { int dlen, clen = stb_compress_tofile("data/dummy.bin", p, len); char *q = stb_decompress_fromfile("data/dummy.bin", &dlen); if (len != dlen) { printf("FAILED %d -> %d\n", len, clen); } else { int z = memcmp(q,p,dlen); if (z != 0) printf("FAILED %d -> %d\n", len, clen); else printf("%d -> %d\n", len, clen); } } return; } window = atoi(argv[1]); if (window && argc == 4) { p = stb_file(argv[3], &len); if (p) { stb_compress_hashsize(window); stb_compress_tofile(argv[2], p, len); } } else if (argc == 3) { p = stb_decompress_fromfile(argv[2], &len); if (p) { FILE *f = fopen(argv[1], "wb"); fwrite(p,1,len,f); fclose(f); } else { fprintf(stderr, "FAILED.\n"); } } else { fprintf(stderr, "Usage: stb \n" " or stb \n"); } } #if 0 // naive backtracking implementation int wildmatch(char *expr, char *candidate) { while(*expr) { if (*expr == '?') { if (!*candidate) return 0; ++candidate; ++expr; } else if (*expr == '*') { ++expr; while (*expr == '*' || *expr =='?') ++expr; // '*' at end of expression matches anything if (!*expr) return 1; // now scan candidate 'til first match while (*candidate) { if (*candidate == *expr) { // check this candidate if (stb_wildmatch(expr+1, candidate+1)) return 1; // if not, then backtrack } ++candidate; } } else { if (*expr != *candidate) return 0; ++expr, ++candidate; } } return *candidate != 0; } int stb_matcher_find_slow(stb_matcher *m, char *str) { int result = 1; int i,j,y,z; uint16 *previous = NULL; uint16 *current = NULL; uint16 *temp; stb_arr_setsize(previous, 4); stb_arr_setsize(current, 4); previous = stb__add_if_inactive(m, previous, m->start_node); previous = stb__eps_closure(m,previous); if (stb__clear_goalcheck(m, previous)) goto done; while (*str) { y = stb_arr_len(previous); for (i=0; i < y; ++i) { stb_nfa_node *n = &m->nodes[previous[i]]; z = stb_arr_len(n->out); for (j=0; j < z; ++j) { if (n->out[j].match == *str) current = stb__add_if_inactive(m, current, n->out[j].node); else if (n->out[j].match == -1) { if (*str != '\n') current = stb__add_if_inactive(m, current, n->out[j].node); } else if (n->out[j].match < -1) { int z = -n->out[j].match - 2; if (m->charset[(uint8) *str] & (1 << z)) current = stb__add_if_inactive(m, current, n->out[j].node); } } } ++str; stb_arr_setlen(previous, 0); temp = previous; previous = current; current = temp; if (!m->match_start) previous = stb__add_if_inactive(m, previous, m->start_node); previous = stb__eps_closure(m,previous); if (stb__clear_goalcheck(m, previous)) goto done; } result=0; done: stb_arr_free(previous); stb_arr_free(current); return result; } #endif ////////////////////////////////////////////////////////////////////////// // // stb_parser // // Generates an LR(1) parser from a grammar, and can parse with it // Symbol representations // // Client: Internal: // - c=0 e aka epsilon // - c=1 $ aka end of string // > 0 2<=c= 0 ? encode_term(x) : encode_nonterm(x)) stb_bitset **compute_first(short ** productions) { int i, changed; stb_bitset **first = malloc(sizeof(*first) * num_symbols); assert(symset); for (i=0; i < num_symbols; ++i) first[i] = stb_bitset_new(0, symset); for (i=END; i < first_nonterm; ++i) stb_bitset_setbit(first[i], i); for (i=0; i < stb_arr_len(productions); ++i) { if (productions[i][2] == 0) { int nt = encode_nonterm(productions[i][0]); stb_bitset_setbit(first[nt], EPS); } } do { changed = 0; for (i=0; i < stb_arr_len(productions); ++i) { int j, nt = encode_nonterm(productions[i][0]); for (j=2; productions[i][j]; ++j) { int z = encode_symbol(productions[i][j]); changed |= stb_bitset_unioneq_changed(first[nt], first[z], symset); if (!stb_bitset_testbit(first[z], EPS)) break; } if (!productions[i][j] && !stb_bitset_testbit(first[nt], EPS)) { stb_bitset_setbit(first[nt], EPS); changed = 1; } } } while (changed); return first; } stb_bitset **compute_follow(short ** productions, stb_bitset **first, int start) { int i,j,changed; stb_bitset **follow = malloc(sizeof(*follow) * num_symbols); assert(symset); for (i=0; i < num_symbols; ++i) follow[i] = (i >= first_nonterm ? stb_bitset_new(0, symset) : NULL); stb_bitset_setbit(follow[start], END); do { changed = 0; for (i=0; i < stb_arr_len(productions); ++i) { int nt = encode_nonterm(productions[i][0]); for (j=2; productions[i][j]; ++j) { if (productions[i][j] < 0) { int k,z = encode_nonterm(productions[i][j]); for (k=j+1; productions[i][k]; ++k) { int q = encode_symbol(productions[i][k]); changed |= stb_bitset_unioneq_changed(follow[z], first[q], symset); if (!stb_bitset_testbit(first[q], EPS)) break; } if (!productions[i][k] == 0) changed |= stb_bitset_unioneq_changed(follow[z], follow[nt], symset); } } } } while (changed); for (i=first_nonterm; i < num_symbols; ++i) stb_bitset_clearbit(follow[i], EPS); return follow; } void first_for_prod_plus_sym(stb_bitset **first, stb_bitset *out, short *prod, int symbol) { stb_bitset_clearall(out, symset); for(;*prod;++prod) { int z = encode_symbol(*prod); stb_bitset_unioneq_changed(out, first[z], symset); if (!stb_bitset_testbit(first[z], EPS)) return; } stb_bitset_unioneq_changed(out, first[symbol], symset); } #define Item(p,c,t) ((void *) (((t) << 18) + ((c) << 12) + ((p) << 2))) #define ItemProd(i) ((((uint32) (i)) >> 2) & 1023) #define ItemCursor(i) ((((uint32) (i)) >> 12) & 63) #define ItemLookahead(i) (((uint32) (i)) >> 18) static void pc(stb_ps *p) { } typedef struct { short *prod; int prod_num; } ProdRef; typedef struct { stb_bitset **first; stb_bitset **follow; short ** prod; ProdRef ** prod_by_nt; } Grammar; stb_ps *itemset_closure(Grammar g, stb_ps *set) { stb_bitset *lookahead; int changed,i,j,k, list_len; if (set == NULL) return set; lookahead = stb_bitset_new(0, symset); do { void **list = stb_ps_getlist(set, &list_len); changed = 0; for (i=0; i < list_len; ++i) { ProdRef *prod; int nt, *looklist; int p = ItemProd(list[i]), c = ItemCursor(list[i]), t = ItemLookahead(list[i]); if (g.prod[p][c] >= 0) continue; nt = encode_nonterm(g.prod[p][c]); first_for_prod_plus_sym(g.first, lookahead, g.prod[p]+c+1, t); looklist = stb_bitset_getlist(lookahead, 1, first_nonterm); prod = g.prod_by_nt[nt]; for (j=0; j < stb_arr_len(prod); ++j) { assert(prod[j].prod[0] == g.prod[p][c]); // matched production; now iterate terminals for (k=0; k < stb_arr_len(looklist); ++k) { void *item = Item(prod[j].prod_num,2,looklist[k]); if (!stb_ps_find(set, item)) { changed = 1; set = stb_ps_add(set, item); pc(set); } } } stb_arr_free(looklist); } free(list); } while (changed); free(lookahead); return set; } stb_ps *itemset_goto(Grammar g, stb_ps *set, int sym) { int i, listlen; void **list = stb_ps_fastlist(set, &listlen); stb_ps *out = NULL; for (i=0; i < listlen; ++i) { int p,c; if (!stb_ps_fastlist_valid(list[i])) continue; p = ItemProd(list[i]), c = ItemCursor(list[i]); if (encode_symbol(g.prod[p][c]) == sym) { void *z = Item(p,c+1,ItemLookahead(list[i])); if (!stb_ps_find(out, z)) out = stb_ps_add(out, z); pc(out); } } return itemset_closure(g, out); } void itemset_all_nextsym(Grammar g, stb_bitset *out, stb_ps *set) { int i, listlen; void **list = stb_ps_fastlist(set, &listlen); stb_bitset_clearall(out, symset); pc(set); for (i=0; i < listlen; ++i) { if (stb_ps_fastlist_valid(list[i])) { int p = ItemProd(list[i]); int c = ItemCursor(list[i]); if (g.prod[p][c]) stb_bitset_setbit(out, encode_symbol(g.prod[p][c])); } } } stb_ps ** generate_items(Grammar g, int start_prod) { stb_ps ** all=NULL; int i,j,k; stb_bitset *try = stb_bitset_new(0,symset); stb_ps *set = NULL; void *item = Item(start_prod, 2, END); set = stb_ps_add(set, item); pc(set); set = itemset_closure(g, set); pc(set); stb_arr_push(all, set); for (i = 0; i < stb_arr_len(all); ++i) { // only try symbols that appear in all[i]... there's a smarter way to do this, // which is to take all[i], and divide it up by symbol pc(all[i]); itemset_all_nextsym(g, try, all[i]); for (j = 1; j < num_symbols; ++j) { if (stb_bitset_testbit(try, j)) { stb_ps *out; if (stb_arr_len(all) > 4) pc(all[4]); if (i == 1 && j == 29) { if (stb_arr_len(all) > 4) pc(all[4]); out = itemset_goto(g, all[i], j); if (stb_arr_len(all) > 4) pc(all[4]); } else out = itemset_goto(g, all[i], j); pc(out); if (stb_arr_len(all) > 4) pc(all[4]); if (out != NULL) { // add it to the array if it's not already there for (k=0; k < stb_arr_len(all); ++k) if (stb_ps_eq(all[k], out)) break; if (k == stb_arr_len(all)) { stb_arr_push(all, out); pc(out); if (stb_arr_len(all) > 4) pc(all[4]); } else stb_ps_delete(out); } } } } free(try); return all; } typedef struct { int num_stack; int function; } Reduction; typedef struct { short *encode_term; Reduction *reductions; short **action_goto; // terminals are action, nonterminals are goto int start; int end_term; } Parser; enum { A_error, A_accept, A_shift, A_reduce, A_conflict }; typedef struct { uint8 type; uint8 cursor; short prod; short value; } Action; Parser *parser_create(short **productions, int num_prod, int start_nt, int end_term) { short *mini_rule = malloc(4 * sizeof(mini_rule[0])); Action *actions; Grammar g; stb_ps ** sets; Parser *p = malloc(sizeof(*p)); int i,j,n; stb_bitset *mapped; int min_s=0, max_s=0, termset, ntset, num_states, num_reductions, init_prod; int synth_start; // remap sparse terminals and nonterminals for (i=0; i < num_prod; ++i) { for (j=2; productions[i][j]; ++j) { if (productions[i][j] < min_s) min_s = productions[i][j]; if (productions[i][j] > max_s) max_s = productions[i][j]; } } synth_start = --min_s; termset = (max_s + 32) >> 5; ntset = (~min_s + 32) >> 5; memset(encode_term, 0, sizeof(encode_term)); memset(encode_nonterm, 0, sizeof(encode_nonterm)); mapped = stb_bitset_new(0, termset); n = 2; for (i=0; i < num_prod; ++i) for (j=2; productions[i][j]; ++j) if (productions[i][j] > 0) if (!stb_bitset_testbit(mapped, productions[i][j])) { stb_bitset_setbit(mapped, productions[i][j]); encode_term[productions[i][j]] = n++; } free(mapped); first_nonterm = n; mapped = stb_bitset_new(0, ntset); for (i=0; i < num_prod; ++i) for (j=2; productions[i][j]; ++j) if (productions[i][j] < 0) if (!stb_bitset_testbit(mapped, ~productions[i][j])) { stb_bitset_setbit(mapped, ~productions[i][j]); encode_nonterm[~productions[i][j]] = n++; } free(mapped); // add a special start state for internal processing p->start = n++; encode_nonterm[synth_start] = p->start; mini_rule[0] = synth_start; mini_rule[1] = -32768; mini_rule[2] = start_nt; mini_rule[3] = 0; p->end_term = end_term; num_symbols = n; // create tables g.prod = NULL; g.prod_by_nt = malloc(num_symbols * sizeof(g.prod_by_nt[0])); for (i=0; i < num_symbols; ++i) g.prod_by_nt[i] = NULL; for (i=0; i < num_prod; ++i) { stb_arr_push(g.prod, productions[i]); } init_prod = stb_arr_len(g.prod); stb_arr_push(g.prod, mini_rule); num_reductions = stb_arr_len(g.prod); p->reductions = malloc(num_reductions * sizeof(*p->reductions)); symset = (num_symbols + 31) >> 5; g.first = compute_first(g.prod); g.follow = compute_follow(g.prod, g.first, p->start); for (i=0; i < stb_arr_len(g.prod); ++i) { ProdRef pr = { g.prod[i], i }; stb_arr_push(g.prod_by_nt[encode_nonterm(g.prod[i][0])], pr); } sets = generate_items(g, init_prod); num_states = stb_arr_len(sets); // now generate tables actions = malloc(sizeof(*actions) * first_nonterm); p->action_goto = (short **) stb_array_block_alloc(num_states, sizeof(short) * num_symbols); for (i=0; i < num_states; ++i) { int j,n; void **list = stb_ps_getlist(sets[i], &n); memset(actions, 0, sizeof(*actions) * first_nonterm); for (j=0; j < n; ++j) { int p = ItemProd(list[j]), c = ItemCursor(list[j]), t = ItemLookahead(list[j]); if (g.prod[p][c] == 0) { if (p == init_prod) { // @TODO: check for conflicts assert(actions[t].type == A_error || actions[t].type == A_accept); actions[t].type = A_accept; } else { // reduce production p if (actions[t].type == A_reduce) { // is it the same reduction we already have? if (actions[t].prod != p) { // no, it's a reduce-reduce conflict! printf("Reduce-reduce conflict for rule %d and %d, lookahead %d\n", p, actions[t].prod, t); // @TODO: use precedence actions[t].type = A_conflict; } } else if (actions[t].type == A_shift) { printf("Shift-reduce conflict for rule %d and %d, lookahead %d\n", actions[t].prod, p, t); actions[t].type = A_conflict; } else if (actions[t].type == A_accept) { assert(0); } else if (actions[t].type == A_error) { actions[t].type = A_reduce; actions[t].prod = p; } } } else if (g.prod[p][c] > 0) { int a = encode_symbol(g.prod[p][c]), k; stb_ps *out = itemset_goto(g, sets[i], a); for (k=0; k < stb_arr_len(sets); ++k) if (stb_ps_eq(sets[k], out)) break; assert(k < stb_arr_len(sets)); // shift k if (actions[a].type == A_shift) { if (actions[a].value != k) { printf("Shift-shift conflict! Rule %d and %d with lookahead %d/%d\n", actions[a].prod, p, a,t); actions[a].type = A_conflict; } } else if (actions[a].type == A_reduce) { printf("Shift-reduce conflict for rule %d and %d, lookahead %d/%d\n", p, actions[a].prod, a,t); actions[a].type = A_conflict; } else if (actions[a].type == A_accept) { assert(0); } else if (actions[a].type == A_error) { actions[a].type = A_shift; actions[a].prod = p; actions[a].cursor = c; actions[a].value = k; } } } // @TODO: recompile actions into p->action_goto } free(mini_rule); stb_pointer_array_free(g.first , num_symbols); free(g.first ); stb_pointer_array_free(g.follow, num_symbols); free(g.follow); stb_arr_free(g.prod); for (i=0; i < num_symbols; ++i) stb_arr_free(g.prod_by_nt[i]); free(g.prod_by_nt); for (i=0; i < stb_arr_len(sets); ++i) stb_ps_delete(sets[i]); stb_arr_free(sets); return p; } void parser_destroy(Parser *p) { free(p); } #if 0 enum nonterm { N_globals = -50, N_global, N_vardef, N_varinitlist, N_varinit, N_funcdef, N_optid, N_optparamlist, N_paramlist, N_param, N_optinit, N_optcomma, N_statements, N_statement, N_optexpr, N_assign, N_if, N_ifcore, N_else, N_dictdef, N_dictdef2, N_dictdefitem, N_expr, N__last }; short grammar[][10] = { { N_globals , 0, N_globals, N_global }, { N_globals , 0 }, { N_global , 0, N_vardef }, { N_global , 0, N_funcdef }, { N_vardef , 0, ST_var, N_varinitlist, }, { N_varinitlist, 0, N_varinitlist, ',', N_varinit }, { N_varinitlist, 0, N_varinit, }, { N_varinit , 0, ST_id, N_optinit, }, { N_funcdef , 0, ST_func, N_optid, '(', N_optparamlist, ')', N_statements, ST_end }, { N_optid , 0, ST_id }, { N_optid , 0, }, { N_optparamlist, 0, }, { N_optparamlist, 0, N_paramlist, N_optcomma }, { N_paramlist , 0, N_paramlist, ',', N_param }, { N_paramlist , 0, N_param }, { N_param , 0, ST_id, N_optinit }, { N_optinit , 0, '=', N_expr }, { N_optinit , 0, }, { N_optcomma , 0, ',' }, { N_optcomma , 0, }, { N_statements , 0, N_statements, N_statement }, { N_statement , 0, N_statement, ';' }, { N_statement , 0, N_varinit }, { N_statement , 0, ST_return, N_expr }, { N_statement , 0, ST_break , N_optexpr }, { N_optexpr , 0, N_expr }, { N_optexpr , 0, }, { N_statement , 0, ST_continue }, { N_statement , 0, N_assign }, { N_assign , 0, N_expr, '=', N_assign }, //{ N_assign , 0, N_expr }, { N_statement , 0, ST_while, N_expr, N_statements, ST_end }, { N_statement , 0, ST_if, N_if, }, { N_if , 0, N_ifcore, ST_end, }, { N_ifcore , 0, N_expr, ST_then, N_statements, N_else, ST_end }, { N_else , 0, ST_elseif, N_ifcore }, { N_else , 0, ST_else, N_statements }, { N_else , 0, }, { N_dictdef , 0, N_dictdef2, N_optcomma }, { N_dictdef2 , 0, N_dictdef2, ',', N_dictdefitem }, { N_dictdef2 , 0, N_dictdefitem }, { N_dictdefitem, 0, ST_id, '=', N_expr }, { N_dictdefitem, 0, N_expr }, { N_expr , 0, ST_number }, { N_expr , 0, ST_string }, { N_expr , 0, ST_id }, { N_expr , 0, N_funcdef }, { N_expr , 0, '-', N_expr }, { N_expr , 0, '{', N_dictdef, '}' }, { N_expr , 0, '(', N_expr, ')' }, { N_expr , 0, N_expr, '.', ST_id }, { N_expr , 0, N_expr, '[', N_expr, ']' }, { N_expr , 0, N_expr, '(', N_dictdef, ')' }, #if 0 #define BINOP(op) { N_expr, 0, N_expr, op, N_expr } BINOP(ST_and), BINOP(ST_or), BINOP(ST_eq), BINOP(ST_ne), BINOP(ST_le), BINOP(ST_ge), BINOP('>') , BINOP('<' ), BINOP('&'), BINOP('|'), BINOP('^'), BINOP('+'), BINOP('-'), BINOP('*'), BINOP('/'), BINOP('%'), #undef BINOP #endif }; short *grammar_list[stb_arrcount(grammar)]; void test_parser_generator(void) { Parser *p; int i; assert(N__last <= 0); for (i=0; i < stb_arrcount(grammar); ++i) grammar_list[i] = grammar[i]; p = parser_create(grammar_list, stb_arrcount(grammar), N_globals, 0); parser_destroy(p); } #endif #if 0 // stb_threadtest.c #include #define STB_DEFINE //#define STB_THREAD_TEST #include "../stb.h" #define NUM_WORK 100 void *work_consumer(void *p) { stb__thread_sleep(20); return NULL; } int pass; stb_threadqueue *tq1, *tq2, *tq3, *tq4; volatile float t1,t2; // with windows.h // Worked correctly with 100,000,000 enqueue/dequeue WAITLESS // (770 passes, 170000 per pass) // Worked correctly with 2,500,000 enqueue/dequeue !WAITLESS // (15 passes, 170000 per pass) // Worked correctly with 1,500,000 enqueue/dequeue WAITLESS && STB_THREAD_TEST // (9 passes, 170000 per pass) // without windows.h // Worked correctly with 1,000,000 enqueue/dequeue WAITLESS && STB_THREAD_TEST // (6 passes, 170000 per pass) // Worked correctly with 500,000 enqueue/dequeue !WAITLESS && STB_THREAD_TEST // (3 passes, 170000 per pass) // Worked correctly with 1,000,000 enqueue/dequeue WAITLESS // (15 passes, 170000 per pass) #define WAITLESS volatile int table[1000*1000*10]; void wait(int n) { #ifndef WAITLESS int j; float y; for (j=0; j < n; ++j) y += 1 / (t1+j); t2 = y; #endif } void *tq1_consumer(void *p) { for(;;) { int z; float y = 0; stb_threadq_get_block(tq1, &z); wait(5000); table[z] = pass; } } void *tq2_consumer(void *p) { for(;;) { int z; if (stb_threadq_get(tq2, &z)) table[z] = pass; wait(1000); } } void *tq3_consumer(void *p) { for(;;) { int z; stb_threadq_get_block(tq3, &z); table[z] = pass; wait(500); } } void *tq4_consumer(void *p) { for (;;) { int z; stb_threadq_get_block(tq4, &z); table[z] = pass; wait(500); } } typedef struct { int start, end; stb_threadqueue *tq; int delay; } write_data; void *writer(void *q) { int i; write_data *p = (write_data *) q; for (i=p->start; i < p->end; ++i) { stb_threadq_add_block(p->tq, &i); #ifndef WAITLESS if (p->delay) stb__thread_sleep(p->delay); else { int j; float z = 0; for (j=0; j <= 20; ++j) z += 1 / (t1+j); t2 = z; } #endif } return NULL; } write_data info[256]; int pos; void start_writer(int z, int count, stb_threadqueue *tq, int delay) { info[z].start = pos; info[z].end = pos+count; info[z].tq = tq; info[z].delay = delay; stb_create_thread(writer, &info[z]); pos += count; } int main(int argc, char **argv) { int i; stb_sync s = stb_sync_new(); stb_sync_set_target(s, NUM_WORK+1); stb_work_numthreads(2); for (i=0; i < NUM_WORK; ++i) { stb_work_reach(work_consumer, NULL, NULL, s); } printf("Started stb_work test.\n"); t1 = 1; // create the queues tq1 = stb_threadq_new(4, 4, TRUE , TRUE); tq2 = stb_threadq_new(4, 4, TRUE , FALSE); tq3 = stb_threadq_new(4, 4, FALSE, TRUE); tq4 = stb_threadq_new(4, 4, FALSE, FALSE); // start the consumers stb_create_thread(tq1_consumer, NULL); stb_create_thread(tq1_consumer, NULL); stb_create_thread(tq1_consumer, NULL); stb_create_thread(tq2_consumer, NULL); stb_create_thread(tq3_consumer, NULL); stb_create_thread(tq3_consumer, NULL); stb_create_thread(tq3_consumer, NULL); stb_create_thread(tq3_consumer, NULL); stb_create_thread(tq3_consumer, NULL); stb_create_thread(tq3_consumer, NULL); stb_create_thread(tq3_consumer, NULL); stb_create_thread(tq4_consumer, NULL); for (pass=1; pass <= 5000; ++pass) { int z = 0; int last_n = -1; int identical = 0; pos = 0; start_writer(z++, 50000, tq1, 0); start_writer(z++, 50000, tq1, 0); start_writer(z++, 50000, tq1, 0); start_writer(z++, 5000, tq2, 1); start_writer(z++, 3000, tq2, 3); start_writer(z++, 2000, tq2, 5); start_writer(z++, 5000, tq3, 3); start_writer(z++, 5000, tq4, 3); #ifndef WAITLESS stb__thread_sleep(8000); #endif for(;;) { int n =0; for (i=0; i < pos; ++i) { if (table[i] == pass) ++n; } if (n == pos) break; if (n == last_n) { ++identical; if (identical == 3) { printf("Problem slots:\n"); for (i=0; i < pos; ++i) { if (table[i] != pass) printf("%d ", i); } printf("\n"); } else { if (identical < 3) printf("Processed %d of %d\n", n, pos); else printf("."); } } else { identical = 0; printf("Processed %d of %d\n", n, pos); } last_n = n; #ifdef WAITLESS stb__thread_sleep(750); #else stb__thread_sleep(3000); #endif } printf("Finished pass %d\n", pass); } stb_sync_reach_and_wait(s); printf("stb_work test completed ok.\n"); return 0; } #endif #if 0 ////////////////////////////////////////////////////////////////////////////// // // collapse tree leaves up to parents until we only have N nodes // useful for cmirror summaries typedef struct stb_summary_tree { struct stb_summary_tree **children; int num_children; float weight; } stb_summary_tree; STB_EXTERN void *stb_summarize_tree(void *tree, int limit, float reweight); #ifdef STB_DEFINE typedef struct stb_summary_tree2 { STB__ARR(struct stb_summary_tree2 *) children; int num_children; float weight; float weight_with_all_children; float makes_target_weight; float weight_at_target; stb_summary_tree *original; struct stb_summary_tree2 *target; STB__ARR(struct stb_summary_tree2 *) targeters; } stb_summary_tree2; static stb_summary_tree2 *stb__summarize_clone(stb_summary_tree *t) { int i; stb_summary_tree2 *s; s = (stb_summary_tree2 *) malloc(sizeof(*s)); s->original = t; s->weight = t->weight; s->weight_with_all_children = 0; s->weight_at_target = 0; s->target = NULL; s->targeters = NULL; s->num_children = t->num_children; s->children = NULL; for (i=0; i < s->num_children; ++i) stb_arr_push(s->children, stb__summarize_clone(t->children[i])); return s; } static float stb__summarize_compute_targets(stb_summary_tree2 *parent, stb_summary_tree2 *node, float reweight, float weight) { float total = 0; if (node->weight == 0 && node->num_children == 1 && parent) { node->target = parent; return stb__summarize_compute_targets(parent, node->children[0], reweight, weight*reweight); } else { float total=0; int i; for (i=0; i < node->num_children; ++i) total += stb__summarize_compute_targets(node, node->children[i], reweight, reweight); node->weight_with_all_children = total + node->weight; if (parent && node->weight_with_all_children) { node->target = parent; node->weight_at_target = node->weight_with_all_children * weight; node->makes_target_weight = node->weight_at_target + parent->weight; stb_arr_push(parent->targeters, node); } else { node->target = NULL; node->weight_at_target = node->weight; node->makes_target_weight = 0; } return node->weight_with_all_children * weight; } } static stb_summary_tree2 ** stb__summarize_make_array(STB__ARR(stb_summary_tree2 *) all, stb_summary_tree2 *tree) { int i; stb_arr_push(all, tree); for (i=0; i < tree->num_children; ++i) all = stb__summarize_make_array(all, tree->children[i]); return all; } typedef stb_summary_tree2 * stb__stree2; stb_define_sort(stb__summarysort, stb__stree2, (*a)->makes_target_weight < (*b)->makes_target_weight) void *stb_summarize_tree(void *tree, int limit, float reweight) { int i,j,k; STB__ARR(stb_summary_tree *) ret=NULL; STB__ARR(stb_summary_tree2 *) all=NULL; // first clone the tree so we can manipulate it stb_summary_tree2 *t = stb__summarize_clone((stb_summary_tree *) tree); if (reweight < 1) reweight = 1; // now compute how far up the tree each node would get pushed // there's no value in pushing a node up to an empty node with // only one child, so we keep pushing it up stb__summarize_compute_targets(NULL, t, reweight, 1); all = stb__summarize_make_array(all, t); // now we want to iteratively find the smallest 'makes_target_weight', // update that, and then fix all the others (which will be all descendents) // to do this efficiently, we need a heap or a sorted binary tree // what we have is an array. maybe we can insertion sort the array? stb__summarysort(all, stb_arr_len(all)); for (i=0; i < stb_arr_len(all) - limit; ++i) { stb_summary_tree2 *src, *dest; src = all[i]; dest = all[i]->target; if (src->makes_target_weight == 0) continue; assert(dest != NULL); for (k=0; k < stb_arr_len(all); ++k) if (all[k] == dest) break; assert(k != stb_arr_len(all)); assert(i < k); // move weight from all[i] to target src->weight = dest->makes_target_weight; src->weight = 0; src->makes_target_weight = 0; // recompute effect of other descendents for (j=0; j < stb_arr_len(dest->targeters); ++j) { if (dest->targeters[j]->weight) { dest->targeters[j]->makes_target_weight = dest->weight + dest->targeters[j]->weight_at_target; assert(dest->targeters[j]->makes_target_weight <= dest->weight_with_all_children); } } STB_(stb__summarysort,_ins_sort)(all+i, stb_arr_len(all)-i); } // now the elements in [ i..stb_arr_len(all) ) are the relevant ones for (; i < stb_arr_len(all); ++i) stb_arr_push(ret, all[i]->original); // now free all our temp data for (i=0; i < stb_arr_len(all); ++i) { stb_arr_free(all[i]->children); free(all[i]); } stb_arr_free(all); return ret; } #endif #endif uTox/third_party/stb/stb/tests/sdf/0000700000175000001440000000000014003056224016322 5ustar rakusersuTox/third_party/stb/stb/tests/sdf/sdf_test_times_50.png0000600000175000001440000031500214003056224022353 0ustar rakusersPNG  IHDR  UIDATx^c?(      y!4!0!0!0!0!0!0#3F;)4FC`4FC`4FC`4FC`4FC`4FhvGhhhhhhvGhhhhhhH >!0!0!0!0!0#4F;I4FC`4FC`4FC`4FC`4FC`4F;i`4FC`4FC`4FC`4FC`4FC`4FC`$ hz      Ѥ?!0!0!0!0!040!0!0!0!0!0!0B`tp4hhhhh h      h      I!0:C8GC`4FC`4FC`4FC`4FC`4FC`hp4鏆hhhhhhp4 hhhhhh!M!0!0!0!0!0!0BC`C8GC`4FC`4FC`4FC`4FC`4FC`C8FC`4FC`4FC`4FC`4FC`4FC`4FR     !0!M!0!0!0!0!0!0!M!0!0!0!0!0!0#)FgGhhhhhh&           3}4FC`4FC`4FC`4FC`4FC`4FhvGhhhhhhvGh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4FC`4FC`4FC`4FC`4FR     !0!M!0!0!0!0!0!0!M!0!0!0!0!0!0#)FgGhhhhhh&           3}4FC`4FC`4FC`4FC`4FC`4FhvGhhhhhhvGhhhhhhH >!0!0!0!0!0#4F;I4FC`4FC`4FC`4FC`4FC`4F;i`4FC`4FC`4FC`4FC`4FC`4FC`$ hz      Ѥ?!0!0!0!0!040!0!0!0!0!0!0B`tp4hhhhh h      h      I!0:C8GC`4FC`4FC`4FC`4FC`4FC`hp4鏆hhhhhhp4 hhhhhh!M!0!0!0!0!0!0BC`C8GC`4FC`4FC`4FC`4FC`4FC`C8FC`4FC`4FC`4FC`4FC`4FC`4FR     !0!M!0!0!0!0!0!0!M!0!0!0!0!0!0#)FgGhhhhhh&           3}4FC`4FC`4FC`4FC`4FC`4FhvGhhhhhhvGhhhhhhH >!0!0!0!0!0#4F;I4FC`4FC`4FC`4FC`4FC`4F;i`4FC`4FC`4FC`4FC`4FC`4FC`$ hz      Ѥ?!0!0!0!0!040!0!0!0!0!0!0B`tp4hhhhh h      h      I!0:C8GC`4FC`4FC`4FC`4FC`4FC`=ꆨEU2IENDB`uTox/third_party/stb/stb/tests/sdf/sdf_test_times_16.png0000600000175000001440000032352314003056224022364 0ustar rakusersPNG  IHDR  UIDATx^c?(      y!4!0!0!0!0!0!0#3F;)4FC`4FC`4FC`4FC`4FC`4FhvGhhhhhhvGhhhhhhH >!0!0!0!0!0#4F;I4FC`4FC`4FC`4FC`4FC`4F;i`4FC`4FC`4FC`4FC`4FC`4FC`$ hz      Ѥ?!0!0!0!0!040!0!0!0!0!0!0B`tp4hhhhh h      h      I!0:C8GC`4FC`4FC`4FC`4FC`4FC`hp4鏆hhhhhhp4 hhhhhh!M!0!0!0!0!0!0BC`C8GC`4FC`4FC`4FC`4FC`4FC`C8FC`4FC`4FC`4FC`4FC`4FC`4FR     !0!M!0!0!0!0!0!0!M!0!0!0!0!0!0#)FgGhhhhhh&           3}4FC`4FC`4FC`4FC`4FC`4FhvGhhhhhhv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h&           M[`IENDB`uTox/third_party/stb/stb/tests/sdf/sdf_test_arial_16.png0000600000175000001440000035466514003056224022346 0ustar rakusersPNG  IHDR  U|IDATx^c?(      y!4!0!0!0!0!0!0#3F;)4FC`4FC`4FC`4FC`4FC`4FhvGhhhhhhvGhhhhhhH >!0!0!0!0!0#4F;I4FC`4FC`4FC`4FC`4FC`4F;i`4FC`4FC`4FC`4FC`4FC`4FC`$ hz      Ѥ?!0!0!0!0!040!0!0!0!0!0!0B`tp4hhhhh h      h      I!0:C8GC`4FC`4FC`4FC`4FC`4FC`hp4鏆hhhhhhp4 hhhhhh!M!0!0!0!0!0!0BC`C8GC`4FC`4FC`4FC`4FC`4FC`C8FC`4FC`4FC`4FC`4FC`4FC`4FR     !0!M!0!0!0!0!0!0!M!0!0!0!0!0!0#)FgGhhhhhh&           3}4FC`4FC`4FC`4FC`4FC`4FhvGhhhhhhvGhhhhhhH >!0!0!0!0!0#4F;I4FC`4FC`4FC`4FC`4FC`4F;i`4FC`4FC`4FC`4FC`4FC`4FC`$ hz      Ѥ?!0!0!0!0!040!0!0!0!0!0!0B`tp4hhhhh h      h      I!0:C8GC`4FC`4FC`4FC`4FC`4FC`hp4鏆hhhhhhp4 hhhhhh!M!0!0!0!0!0!0BC`C8GC`4FC`4FC`4FC`4FC`4FC`C8FC`4FC`4FC`4FC`4FC`4FC`4FR     !0!M!0!0!0!0!0!0!M!0!0!0!0!0!0#)FgGhhhhhh&           3}4FC`4FC`4FC`4FC`4FC`4FhvGhhhhhhvGhhhhhhH >!0!0!0!0!0#4F;I4FC`4FC`4FC`4FC`4FC`4F;i`4FC`4FC`4FC`4FC`4FC`4FC`$ hz      Ѥ?!0!0!0!0!040!0!0!0!0!0!0B`tp4hhhhh h      h      I!0:C8GC`4FC`4FC`4FC`4FC`4FC`hp4鏆hhhhhhp4 hhhhhh!M!0!0!0!0!0!0BC`C8GC`4FC`4FC`4FC`4FC`4FC`C8FC`4FC`4FC`4FC`4FC`4FC`4FR     !0!M!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FC`hp4鏆hhhhhhp4 hhhhhh!M!0!0!0!0!0!0BC`C8GC`4FC`4FC`4FC`4FC`4FC`C8FC`4FC`4FC`4FC`4FC`4FC`4FR     !0!M!0!0!0!0!0!0!M!0!0!0!0!0!0#)FgGhhhhhh&           3}4FC`4FC`4FC`4FC`4FC`4FhvGhhhhhhvGhhhhhhH >!0!0!0!0!0#4F;I4FC`4FC`4FC`4FC`4FC`4F;i`4FC`4FC`4FC`4FC`4FC`4FC`$ hz      "KA'IENDB`uTox/third_party/stb/stb/tests/sdf/sdf_test.c0000600000175000001440000001102214003056224020277 0ustar rakusers#define STB_DEFINE #include "stb.h" #define STB_TRUETYPE_IMPLEMENTATION #include "stb_truetype.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" // used both to compute SDF and in 'shader' float sdf_size = 32.0; // the larger this is, the better large font sizes look float pixel_dist_scale = 64.0; // trades off precision w/ ability to handle *smaller* sizes int onedge_value = 128; int padding = 3; // not used in shader typedef struct { float advance; signed char xoff; signed char yoff; unsigned char w,h; unsigned char *data; } fontchar; fontchar fdata[128]; #define BITMAP_W 1200 #define BITMAP_H 800 unsigned char bitmap[BITMAP_H][BITMAP_W][3]; char *sample = "This is goofy text, size %d!"; char *small_sample = "This is goofy text, size %d! Really needs in-shader supersampling to look good."; void blend_pixel(int x, int y, int color, float alpha) { int i; for (i=0; i < 3; ++i) bitmap[y][x][i] = (unsigned char) (stb_lerp(alpha, bitmap[y][x][i], color)+0.5); // round } void draw_char(float px, float py, char c, float relative_scale) { int x,y; fontchar *fc = &fdata[c]; float fx0 = px + fc->xoff*relative_scale; float fy0 = py + fc->yoff*relative_scale; float fx1 = fx0 + fc->w*relative_scale; float fy1 = fy0 + fc->h*relative_scale; int ix0 = (int) floor(fx0); int iy0 = (int) floor(fy0); int ix1 = (int) ceil(fx1); int iy1 = (int) ceil(fy1); // clamp to viewport if (ix0 < 0) ix0 = 0; if (iy0 < 0) iy0 = 0; if (ix1 > BITMAP_W) ix1 = BITMAP_W; if (iy1 > BITMAP_H) iy1 = BITMAP_H; for (y=iy0; y < iy1; ++y) { for (x=ix0; x < ix1; ++x) { float sdf_dist, pix_dist; float bmx = stb_linear_remap(x, fx0, fx1, 0, fc->w); float bmy = stb_linear_remap(y, fy0, fy1, 0, fc->h); int v00,v01,v10,v11; float v0,v1,v; int sx0 = (int) bmx; int sx1 = sx0+1; int sy0 = (int) bmy; int sy1 = sy0+1; // compute lerp weights bmx = bmx - sx0; bmy = bmy - sy0; // clamp to edge sx0 = stb_clamp(sx0, 0, fc->w-1); sx1 = stb_clamp(sx1, 0, fc->w-1); sy0 = stb_clamp(sy0, 0, fc->h-1); sy1 = stb_clamp(sy1, 0, fc->h-1); // bilinear texture sample v00 = fc->data[sy0*fc->w+sx0]; v01 = fc->data[sy0*fc->w+sx1]; v10 = fc->data[sy1*fc->w+sx0]; v11 = fc->data[sy1*fc->w+sx1]; v0 = stb_lerp(bmx,v00,v01); v1 = stb_lerp(bmx,v10,v11); v = stb_lerp(bmy,v0 ,v1 ); #if 0 // non-anti-aliased if (v > onedge_value) blend_pixel(x,y,0,1.0); #else // Following math can be greatly simplified // convert distance in SDF value to distance in SDF bitmap sdf_dist = stb_linear_remap(v, onedge_value, onedge_value+pixel_dist_scale, 0, 1); // convert distance in SDF bitmap to distance in output bitmap pix_dist = sdf_dist * relative_scale; // anti-alias by mapping 1/2 pixel around contour from 0..1 alpha v = stb_linear_remap(pix_dist, -0.5f, 0.5f, 0, 1); if (v > 1) v = 1; if (v > 0) blend_pixel(x,y,0,v); #endif } } } void print_text(float x, float y, char *text, float scale) { int i; for (i=0; text[i]; ++i) { if (fdata[text[i]].data) draw_char(x,y,text[i],scale); x += fdata[text[i]].advance * scale; } } int main(int argc, char **argv) { int ch; float scale, ypos; stbtt_fontinfo font; void *data = stb_file("c:/windows/fonts/times.ttf", NULL); stbtt_InitFont(&font, data, 0); scale = stbtt_ScaleForPixelHeight(&font, sdf_size); for (ch=32; ch < 127; ++ch) { fontchar fc; int xoff,yoff,w,h, advance; fc.data = stbtt_GetCodepointSDF(&font, scale, ch, padding, onedge_value, pixel_dist_scale, &w, &h, &xoff, &yoff); fc.xoff = xoff; fc.yoff = yoff; fc.w = w; fc.h = h; stbtt_GetCodepointHMetrics(&font, ch, &advance, NULL); fc.advance = advance * scale; fdata[ch] = fc; } ypos = 60; memset(bitmap, 255, sizeof(bitmap)); print_text(400, ypos+30, stb_sprintf("sdf bitmap height %d", (int) sdf_size), 30/sdf_size); ypos += 80; for (scale = 8.0; scale < 120.0; scale *= 1.33f) { print_text(80, ypos+scale, stb_sprintf(scale == 8.0 ? small_sample : sample, (int) scale), scale / sdf_size); ypos += scale*1.05f + 20; } stbi_write_png("sdf_test.png", BITMAP_W, BITMAP_H, 3, bitmap, 0); return 0; } uTox/third_party/stb/stb/tests/resize.dsp0000600000175000001440000000767514003056224017600 0ustar rakusers# Microsoft Developer Studio Project File - Name="resize" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=resize - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "resize.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "resize.mak" CFG="resize - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "resize - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "resize - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "resize - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /G6 /W3 /GX /Z7 /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 !ELSEIF "$(CFG)" == "resize - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /WX /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "resize - Win32 Release" # Name "resize - Win32 Debug" # Begin Source File SOURCE=.\resample_test.cpp # End Source File # Begin Source File SOURCE=..\stb_image_resize.h # End Source File # End Target # End Project uTox/third_party/stb/stb/tests/resample_test_c.c0000600000175000001440000000026514003056224021070 0ustar rakusers#define STB_IMAGE_RESIZE_IMPLEMENTATION #define STB_IMAGE_RESIZE_STATIC #include "stb_image_resize.h" // Just to make sure it will build properly with a c compiler int main() { } uTox/third_party/stb/stb/tests/resample_test.cpp0000600000175000001440000011453314003056224021132 0ustar rakusers#include #include #if defined(_WIN32) && _MSC_VER > 1200 #define STBIR_ASSERT(x) \ if (!(x)) { \ __debugbreak(); \ } else #else #include #define STBIR_ASSERT(x) assert(x) #endif #define STBIR_MALLOC stbir_malloc #define STBIR_FREE stbir_free class stbir_context { public: stbir_context() { size = 1000000; memory = malloc(size); } ~stbir_context() { free(memory); } size_t size; void* memory; } g_context; void* stbir_malloc(size_t size, void* context) { if (!context) return malloc(size); stbir_context* real_context = (stbir_context*)context; if (size > real_context->size) return 0; return real_context->memory; } void stbir_free(void* memory, void* context) { if (!context) free(memory); } //#include void stbir_progress(float p) { //printf("%f\n", p); STBIR_ASSERT(p >= 0 && p <= 1); } #define STBIR_PROGRESS_REPORT stbir_progress #define STB_IMAGE_RESIZE_IMPLEMENTATION #define STB_IMAGE_RESIZE_STATIC #include "stb_image_resize.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" #ifdef _WIN32 #include #include #define mkdir(a, b) _mkdir(a) #else #include #endif #define MT_SIZE 624 static size_t g_aiMT[MT_SIZE]; static size_t g_iMTI = 0; // Mersenne Twister implementation from Wikipedia. // Avoiding use of the system rand() to be sure that our tests generate the same test data on any system. void mtsrand(size_t iSeed) { g_aiMT[0] = iSeed; for (size_t i = 1; i < MT_SIZE; i++) { size_t inner1 = g_aiMT[i - 1]; size_t inner2 = (g_aiMT[i - 1] >> 30); size_t inner = inner1 ^ inner2; g_aiMT[i] = (0x6c078965 * inner) + i; } g_iMTI = 0; } size_t mtrand() { if (g_iMTI == 0) { for (size_t i = 0; i < MT_SIZE; i++) { size_t y = (0x80000000 & (g_aiMT[i])) + (0x7fffffff & (g_aiMT[(i + 1) % MT_SIZE])); g_aiMT[i] = g_aiMT[(i + 397) % MT_SIZE] ^ (y >> 1); if ((y % 2) == 1) g_aiMT[i] = g_aiMT[i] ^ 0x9908b0df; } } size_t y = g_aiMT[g_iMTI]; y = y ^ (y >> 11); y = y ^ ((y << 7) & (0x9d2c5680)); y = y ^ ((y << 15) & (0xefc60000)); y = y ^ (y >> 18); g_iMTI = (g_iMTI + 1) % MT_SIZE; return y; } inline float mtfrand() { const int ninenine = 999999; return (float)(mtrand() % ninenine)/ninenine; } static void resizer(int argc, char **argv) { unsigned char* input_pixels; unsigned char* output_pixels; int w, h; int n; int out_w, out_h; input_pixels = stbi_load(argv[1], &w, &h, &n, 0); out_w = w*3; out_h = h*3; output_pixels = (unsigned char*) malloc(out_w*out_h*n); //stbir_resize_uint8_srgb(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, n, -1,0); stbir_resize_uint8(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, n); stbi_write_png("output.png", out_w, out_h, n, output_pixels, 0); exit(0); } static void performance(int argc, char **argv) { unsigned char* input_pixels; unsigned char* output_pixels; int w, h, count; int n, i; int out_w, out_h, srgb=1; input_pixels = stbi_load(argv[1], &w, &h, &n, 0); #if 0 out_w = w/4; out_h = h/4; count=100; // 1 #elif 0 out_w = w*2; out_h = h/4; count=20; // 2 // note this is structured pessimily, would be much faster to downsample vertically first #elif 0 out_w = w/4; out_h = h*2; count=50; // 3 #elif 0 out_w = w*3; out_h = h*3; count=2; srgb=0; // 4 #else out_w = w*3; out_h = h*3; count=2; // 5 // this is dominated by linear->sRGB conversion #endif output_pixels = (unsigned char*) malloc(out_w*out_h*n); for (i=0; i < count; ++i) if (srgb) stbir_resize_uint8_srgb(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, n,-1,0); else stbir_resize(input_pixels, w, h, 0, output_pixels, out_w, out_h, 0, STBIR_TYPE_UINT8, n,-1, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, STBIR_COLORSPACE_LINEAR, NULL); exit(0); } void test_suite(int argc, char **argv); int main(int argc, char** argv) { //resizer(argc, argv); //performance(argc, argv); test_suite(argc, argv); return 0; } void resize_image(const char* filename, float width_percent, float height_percent, stbir_filter filter, stbir_edge edge, stbir_colorspace colorspace, const char* output_filename) { int w, h, n; unsigned char* input_data = stbi_load(filename, &w, &h, &n, 0); if (!input_data) { printf("Input image could not be loaded\n"); return; } int out_w = (int)(w * width_percent); int out_h = (int)(h * height_percent); unsigned char* output_data = (unsigned char*)malloc(out_w * out_h * n); stbir_resize(input_data, w, h, 0, output_data, out_w, out_h, 0, STBIR_TYPE_UINT8, n, STBIR_ALPHA_CHANNEL_NONE, 0, edge, edge, filter, filter, colorspace, &g_context); stbi_image_free(input_data); stbi_write_png(output_filename, out_w, out_h, n, output_data, 0); free(output_data); } template void convert_image(const F* input, T* output, int length) { double f = (pow(2.0, 8.0 * sizeof(T)) - 1) / (pow(2.0, 8.0 * sizeof(F)) - 1); for (int i = 0; i < length; i++) output[i] = (T)(((double)input[i]) * f); } template void test_format(const char* file, float width_percent, float height_percent, stbir_datatype type, stbir_colorspace colorspace) { int w, h, n; unsigned char* input_data = stbi_load(file, &w, &h, &n, 0); if (input_data == NULL) return; int new_w = (int)(w * width_percent); int new_h = (int)(h * height_percent); T* T_data = (T*)malloc(w * h * n * sizeof(T)); memset(T_data, 0, w*h*n*sizeof(T)); convert_image(input_data, T_data, w * h * n); T* output_data = (T*)malloc(new_w * new_h * n * sizeof(T)); stbir_resize(T_data, w, h, 0, output_data, new_w, new_h, 0, type, n, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, colorspace, &g_context); free(T_data); stbi_image_free(input_data); unsigned char* char_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(char)); convert_image(output_data, char_data, new_w * new_h * n); char output[200]; sprintf(output, "test-output/type-%d-%d-%d-%d-%s", type, colorspace, new_w, new_h, file); stbi_write_png(output, new_w, new_h, n, char_data, 0); free(char_data); free(output_data); } void convert_image_float(const unsigned char* input, float* output, int length) { for (int i = 0; i < length; i++) output[i] = ((float)input[i])/255; } void convert_image_float(const float* input, unsigned char* output, int length) { for (int i = 0; i < length; i++) output[i] = (unsigned char)(stbir__saturate(input[i]) * 255); } void test_float(const char* file, float width_percent, float height_percent, stbir_datatype type, stbir_colorspace colorspace) { int w, h, n; unsigned char* input_data = stbi_load(file, &w, &h, &n, 0); if (input_data == NULL) return; int new_w = (int)(w * width_percent); int new_h = (int)(h * height_percent); float* T_data = (float*)malloc(w * h * n * sizeof(float)); convert_image_float(input_data, T_data, w * h * n); float* output_data = (float*)malloc(new_w * new_h * n * sizeof(float)); stbir_resize_float_generic(T_data, w, h, 0, output_data, new_w, new_h, 0, n, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, colorspace, &g_context); free(T_data); stbi_image_free(input_data); unsigned char* char_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(char)); convert_image_float(output_data, char_data, new_w * new_h * n); char output[200]; sprintf(output, "test-output/type-%d-%d-%d-%d-%s", type, colorspace, new_w, new_h, file); stbi_write_png(output, new_w, new_h, n, char_data, 0); free(char_data); free(output_data); } void test_channels(const char* file, float width_percent, float height_percent, int channels) { int w, h, n; unsigned char* input_data = stbi_load(file, &w, &h, &n, 0); if (input_data == NULL) return; int new_w = (int)(w * width_percent); int new_h = (int)(h * height_percent); unsigned char* channels_data = (unsigned char*)malloc(w * h * channels * sizeof(unsigned char)); for (int i = 0; i < w * h; i++) { int input_position = i * n; int output_position = i * channels; for (int c = 0; c < channels; c++) channels_data[output_position + c] = input_data[input_position + stbir__min(c, n)]; } unsigned char* output_data = (unsigned char*)malloc(new_w * new_h * channels * sizeof(unsigned char)); stbir_resize_uint8_srgb(channels_data, w, h, 0, output_data, new_w, new_h, 0, channels, STBIR_ALPHA_CHANNEL_NONE, 0); free(channels_data); stbi_image_free(input_data); char output[200]; sprintf(output, "test-output/channels-%d-%d-%d-%s", channels, new_w, new_h, file); stbi_write_png(output, new_w, new_h, channels, output_data, 0); free(output_data); } void test_subpixel(const char* file, float width_percent, float height_percent, float s1, float t1) { int w, h, n; unsigned char* input_data = stbi_load(file, &w, &h, &n, 0); if (input_data == NULL) return; s1 = ((float)w - 1 + s1)/w; t1 = ((float)h - 1 + t1)/h; int new_w = (int)(w * width_percent); int new_h = (int)(h * height_percent); unsigned char* output_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(unsigned char)); stbir_resize_region(input_data, w, h, 0, output_data, new_w, new_h, 0, STBIR_TYPE_UINT8, n, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 0, 0, s1, t1); stbi_image_free(input_data); char output[200]; sprintf(output, "test-output/subpixel-%d-%d-%f-%f-%s", new_w, new_h, s1, t1, file); stbi_write_png(output, new_w, new_h, n, output_data, 0); free(output_data); } void test_subpixel_region(const char* file, float width_percent, float height_percent, float s0, float t0, float s1, float t1) { int w, h, n; unsigned char* input_data = stbi_load(file, &w, &h, &n, 0); if (input_data == NULL) return; int new_w = (int)(w * width_percent); int new_h = (int)(h * height_percent); unsigned char* output_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(unsigned char)); stbir_resize_region(input_data, w, h, 0, output_data, new_w, new_h, 0, STBIR_TYPE_UINT8, n, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, s0, t0, s1, t1); stbi_image_free(input_data); char output[200]; sprintf(output, "test-output/subpixel-region-%d-%d-%f-%f-%f-%f-%s", new_w, new_h, s0, t0, s1, t1, file); stbi_write_png(output, new_w, new_h, n, output_data, 0); free(output_data); } void test_subpixel_command(const char* file, float width_percent, float height_percent, float x_scale, float y_scale, float x_offset, float y_offset) { int w, h, n; unsigned char* input_data = stbi_load(file, &w, &h, &n, 0); if (input_data == NULL) return; int new_w = (int)(w * width_percent); int new_h = (int)(h * height_percent); unsigned char* output_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(unsigned char)); stbir_resize_subpixel(input_data, w, h, 0, output_data, new_w, new_h, 0, STBIR_TYPE_UINT8, n, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, x_scale, y_scale, x_offset, y_offset); stbi_image_free(input_data); char output[200]; sprintf(output, "test-output/subpixel-command-%d-%d-%f-%f-%f-%f-%s", new_w, new_h, x_scale, y_scale, x_offset, y_offset, file); stbi_write_png(output, new_w, new_h, n, output_data, 0); free(output_data); } unsigned int* pixel(unsigned int* buffer, int x, int y, int c, int w, int n) { return &buffer[y*w*n + x*n + c]; } void test_premul() { unsigned int input[2 * 2 * 4]; unsigned int output[1 * 1 * 4]; unsigned int output2[2 * 2 * 4]; memset(input, 0, sizeof(input)); // First a test to make sure premul is working properly. // Top left - solid red *pixel(input, 0, 0, 0, 2, 4) = 255; *pixel(input, 0, 0, 3, 2, 4) = 255; // Bottom left - solid red *pixel(input, 0, 1, 0, 2, 4) = 255; *pixel(input, 0, 1, 3, 2, 4) = 255; // Top right - transparent green *pixel(input, 1, 0, 1, 2, 4) = 255; *pixel(input, 1, 0, 3, 2, 4) = 25; // Bottom right - transparent green *pixel(input, 1, 1, 1, 2, 4) = 255; *pixel(input, 1, 1, 3, 2, 4) = 25; stbir_resize(input, 2, 2, 0, output, 1, 1, 0, STBIR_TYPE_UINT32, 4, 3, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, &g_context); float r = (float)255 / 4294967296; float g = (float)255 / 4294967296; float ra = (float)255 / 4294967296; float ga = (float)25 / 4294967296; float a = (ra + ga) / 2; STBIR_ASSERT(output[0] == (unsigned int)(r * ra / 2 / a * 4294967296 + 0.5f)); // 232 STBIR_ASSERT(output[1] == (unsigned int)(g * ga / 2 / a * 4294967296 + 0.5f)); // 23 STBIR_ASSERT(output[2] == 0); STBIR_ASSERT(output[3] == (unsigned int)(a * 4294967296 + 0.5f)); // 140 // Now a test to make sure it doesn't clobber existing values. // Top right - completely transparent green *pixel(input, 1, 0, 1, 2, 4) = 255; *pixel(input, 1, 0, 3, 2, 4) = 0; // Bottom right - completely transparent green *pixel(input, 1, 1, 1, 2, 4) = 255; *pixel(input, 1, 1, 3, 2, 4) = 0; stbir_resize(input, 2, 2, 0, output2, 2, 2, 0, STBIR_TYPE_UINT32, 4, 3, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, &g_context); STBIR_ASSERT(*pixel(output2, 0, 0, 0, 2, 4) == 255); STBIR_ASSERT(*pixel(output2, 0, 0, 1, 2, 4) == 0); STBIR_ASSERT(*pixel(output2, 0, 0, 2, 2, 4) == 0); STBIR_ASSERT(*pixel(output2, 0, 0, 3, 2, 4) == 255); STBIR_ASSERT(*pixel(output2, 0, 1, 0, 2, 4) == 255); STBIR_ASSERT(*pixel(output2, 0, 1, 1, 2, 4) == 0); STBIR_ASSERT(*pixel(output2, 0, 1, 2, 2, 4) == 0); STBIR_ASSERT(*pixel(output2, 0, 1, 3, 2, 4) == 255); STBIR_ASSERT(*pixel(output2, 1, 0, 0, 2, 4) == 0); STBIR_ASSERT(*pixel(output2, 1, 0, 1, 2, 4) == 255); STBIR_ASSERT(*pixel(output2, 1, 0, 2, 2, 4) == 0); STBIR_ASSERT(*pixel(output2, 1, 0, 3, 2, 4) == 0); STBIR_ASSERT(*pixel(output2, 1, 1, 0, 2, 4) == 0); STBIR_ASSERT(*pixel(output2, 1, 1, 1, 2, 4) == 255); STBIR_ASSERT(*pixel(output2, 1, 1, 2, 2, 4) == 0); STBIR_ASSERT(*pixel(output2, 1, 1, 3, 2, 4) == 0); } // test that splitting a pow-2 image into tiles produces identical results void test_subpixel_1() { unsigned char image[8 * 8]; mtsrand(0); for (int i = 0; i < sizeof(image); i++) image[i] = mtrand() & 255; unsigned char output_data[16 * 16]; stbir_resize_region(image, 8, 8, 0, output_data, 16, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 0, 0, 1, 1); unsigned char output_left[8 * 16]; unsigned char output_right[8 * 16]; stbir_resize_region(image, 8, 8, 0, output_left, 8, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 0, 0, 0.5f, 1); stbir_resize_region(image, 8, 8, 0, output_right, 8, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 0.5f, 0, 1, 1); for (int x = 0; x < 8; x++) { for (int y = 0; y < 16; y++) { STBIR_ASSERT(output_data[y * 16 + x] == output_left[y * 8 + x]); STBIR_ASSERT(output_data[y * 16 + x + 8] == output_right[y * 8 + x]); } } stbir_resize_subpixel(image, 8, 8, 0, output_left, 8, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 2, 2, 0, 0); stbir_resize_subpixel(image, 8, 8, 0, output_right, 8, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 2, 2, 8, 0); {for (int x = 0; x < 8; x++) { for (int y = 0; y < 16; y++) { STBIR_ASSERT(output_data[y * 16 + x] == output_left[y * 8 + x]); STBIR_ASSERT(output_data[y * 16 + x + 8] == output_right[y * 8 + x]); } }} } // test that replicating an image and using a subtile of it produces same results as wraparound void test_subpixel_2() { unsigned char image[8 * 8]; mtsrand(0); for (int i = 0; i < sizeof(image); i++) image[i] = mtrand() & 255; unsigned char large_image[32 * 32]; for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) large_image[j*4*8*8 + i*8 + y*4*8 + x] = image[y*8 + x]; } } } unsigned char output_data_1[16 * 16]; unsigned char output_data_2[16 * 16]; stbir_resize(image, 8, 8, 0, output_data_1, 16, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_WRAP, STBIR_EDGE_WRAP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context); stbir_resize_region(large_image, 32, 32, 0, output_data_2, 16, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_WRAP, STBIR_EDGE_WRAP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 0.25f, 0.25f, 0.5f, 0.5f); {for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) STBIR_ASSERT(output_data_1[y * 16 + x] == output_data_2[y * 16 + x]); }} stbir_resize_subpixel(large_image, 32, 32, 0, output_data_2, 16, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_WRAP, STBIR_EDGE_WRAP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context, 2, 2, 16, 16); {for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) STBIR_ASSERT(output_data_1[y * 16 + x] == output_data_2[y * 16 + x]); }} } // test that 0,0,1,1 subpixel produces same result as no-rect void test_subpixel_3() { unsigned char image[8 * 8]; mtsrand(0); for (int i = 0; i < sizeof(image); i++) image[i] = mtrand() & 255; unsigned char output_data_1[32 * 32]; unsigned char output_data_2[32 * 32]; stbir_resize_region(image, 8, 8, 0, output_data_1, 32, 32, 0, STBIR_TYPE_UINT8, 1, 0, STBIR_ALPHA_CHANNEL_NONE, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_LINEAR, NULL, 0, 0, 1, 1); stbir_resize_uint8(image, 8, 8, 0, output_data_2, 32, 32, 0, 1); for (int x = 0; x < 32; x++) { for (int y = 0; y < 32; y++) STBIR_ASSERT(output_data_1[y * 32 + x] == output_data_2[y * 32 + x]); } stbir_resize_subpixel(image, 8, 8, 0, output_data_1, 32, 32, 0, STBIR_TYPE_UINT8, 1, 0, STBIR_ALPHA_CHANNEL_NONE, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_LINEAR, NULL, 4, 4, 0, 0); {for (int x = 0; x < 32; x++) { for (int y = 0; y < 32; y++) STBIR_ASSERT(output_data_1[y * 32 + x] == output_data_2[y * 32 + x]); }} } // test that 1:1 resample using s,t=0,0,1,1 with bilinear produces original image void test_subpixel_4() { unsigned char image[8 * 8]; mtsrand(0); for (int i = 0; i < sizeof(image); i++) image[i] = mtrand() & 255; unsigned char output[8 * 8]; stbir_resize_region(image, 8, 8, 0, output, 8, 8, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_TRIANGLE, STBIR_FILTER_TRIANGLE, STBIR_COLORSPACE_LINEAR, &g_context, 0, 0, 1, 1); STBIR_ASSERT(memcmp(image, output, 8 * 8) == 0); stbir_resize_subpixel(image, 8, 8, 0, output, 8, 8, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_TRIANGLE, STBIR_FILTER_TRIANGLE, STBIR_COLORSPACE_LINEAR, &g_context, 1, 1, 0, 0); STBIR_ASSERT(memcmp(image, output, 8 * 8) == 0); } static unsigned int image88_int[8][8]; static unsigned char image88 [8][8]; static unsigned char output88[8][8]; static unsigned char output44[4][4]; static unsigned char output22[2][2]; static unsigned char output11[1][1]; void resample_88(stbir_filter filter) { stbir_resize_uint8_generic(image88[0],8,8,0, output88[0],8,8,0, 1,-1,0, STBIR_EDGE_CLAMP, filter, STBIR_COLORSPACE_LINEAR, NULL); stbir_resize_uint8_generic(image88[0],8,8,0, output44[0],4,4,0, 1,-1,0, STBIR_EDGE_CLAMP, filter, STBIR_COLORSPACE_LINEAR, NULL); stbir_resize_uint8_generic(image88[0],8,8,0, output22[0],2,2,0, 1,-1,0, STBIR_EDGE_CLAMP, filter, STBIR_COLORSPACE_LINEAR, NULL); stbir_resize_uint8_generic(image88[0],8,8,0, output11[0],1,1,0, 1,-1,0, STBIR_EDGE_CLAMP, filter, STBIR_COLORSPACE_LINEAR, NULL); } void verify_box(void) { int i,j,t; resample_88(STBIR_FILTER_BOX); for (i=0; i < sizeof(image88); ++i) STBIR_ASSERT(image88[0][i] == output88[0][i]); t = 0; for (j=0; j < 4; ++j) for (i=0; i < 4; ++i) { int n = image88[j*2+0][i*2+0] + image88[j*2+0][i*2+1] + image88[j*2+1][i*2+0] + image88[j*2+1][i*2+1]; STBIR_ASSERT(output44[j][i] == ((n+2)>>2) || output44[j][i] == ((n+1)>>2)); // can't guarantee exact rounding due to numerical precision t += n; } STBIR_ASSERT(output11[0][0] == ((t+32)>>6) || output11[0][0] == ((t+31)>>6)); // can't guarantee exact rounding due to numerical precision } void verify_filter_normalized(stbir_filter filter, int output_size, unsigned int value) { int i, j; unsigned int output[64]; stbir_resize(image88_int[0], 8, 8, 0, output, output_size, output_size, 0, STBIR_TYPE_UINT32, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, filter, filter, STBIR_COLORSPACE_LINEAR, NULL); for (j = 0; j < output_size; ++j) for (i = 0; i < output_size; ++i) STBIR_ASSERT(value == output[j*output_size + i]); } float round2(float f) { return (float) floor(f+0.5f); // round() isn't C standard pre-C99 } void test_filters(void) { int i,j; mtsrand(0); for (i=0; i < sizeof(image88); ++i) image88[0][i] = mtrand() & 255; verify_box(); for (i=0; i < sizeof(image88); ++i) image88[0][i] = 0; image88[4][4] = 255; verify_box(); for (j=0; j < 8; ++j) for (i=0; i < 8; ++i) image88[j][i] = (j^i)&1 ? 255 : 0; verify_box(); for (j=0; j < 8; ++j) for (i=0; i < 8; ++i) image88[j][i] = i&2 ? 255 : 0; verify_box(); int value = 64; for (j = 0; j < 8; ++j) for (i = 0; i < 8; ++i) image88_int[j][i] = value; verify_filter_normalized(STBIR_FILTER_BOX, 8, value); verify_filter_normalized(STBIR_FILTER_TRIANGLE, 8, value); verify_filter_normalized(STBIR_FILTER_CUBICBSPLINE, 8, value); verify_filter_normalized(STBIR_FILTER_CATMULLROM, 8, value); verify_filter_normalized(STBIR_FILTER_MITCHELL, 8, value); verify_filter_normalized(STBIR_FILTER_BOX, 4, value); verify_filter_normalized(STBIR_FILTER_TRIANGLE, 4, value); verify_filter_normalized(STBIR_FILTER_CUBICBSPLINE, 4, value); verify_filter_normalized(STBIR_FILTER_CATMULLROM, 4, value); verify_filter_normalized(STBIR_FILTER_MITCHELL, 4, value); verify_filter_normalized(STBIR_FILTER_BOX, 2, value); verify_filter_normalized(STBIR_FILTER_TRIANGLE, 2, value); verify_filter_normalized(STBIR_FILTER_CUBICBSPLINE, 2, value); verify_filter_normalized(STBIR_FILTER_CATMULLROM, 2, value); verify_filter_normalized(STBIR_FILTER_MITCHELL, 2, value); verify_filter_normalized(STBIR_FILTER_BOX, 1, value); verify_filter_normalized(STBIR_FILTER_TRIANGLE, 1, value); verify_filter_normalized(STBIR_FILTER_CUBICBSPLINE, 1, value); verify_filter_normalized(STBIR_FILTER_CATMULLROM, 1, value); verify_filter_normalized(STBIR_FILTER_MITCHELL, 1, value); { // This test is designed to produce coefficients that are very badly denormalized. unsigned int v = 556; unsigned int input[100 * 100]; unsigned int output[11 * 11]; for (j = 0; j < 100 * 100; ++j) input[j] = v; stbir_resize(input, 100, 100, 0, output, 11, 11, 0, STBIR_TYPE_UINT32, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_TRIANGLE, STBIR_FILTER_TRIANGLE, STBIR_COLORSPACE_LINEAR, NULL); for (j = 0; j < 11 * 11; ++j) STBIR_ASSERT(v == output[j]); } { // Now test the trapezoid filter for downsampling. unsigned int input[3 * 1]; unsigned int output[2 * 1]; input[0] = 0; input[1] = 255; input[2] = 127; stbir_resize(input, 3, 1, 0, output, 2, 1, 0, STBIR_TYPE_UINT32, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); STBIR_ASSERT(output[0] == (unsigned int)round2((float)(input[0] * 2 + input[1]) / 3)); STBIR_ASSERT(output[1] == (unsigned int)round2((float)(input[2] * 2 + input[1]) / 3)); stbir_resize(input, 1, 3, 0, output, 1, 2, 0, STBIR_TYPE_UINT32, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); STBIR_ASSERT(output[0] == (unsigned int)round2((float)(input[0] * 2 + input[1]) / 3)); STBIR_ASSERT(output[1] == (unsigned int)round2((float)(input[2] * 2 + input[1]) / 3)); } { // Now test the trapezoid filter for upsampling. unsigned int input[2 * 1]; unsigned int output[3 * 1]; input[0] = 0; input[1] = 255; stbir_resize(input, 2, 1, 0, output, 3, 1, 0, STBIR_TYPE_UINT32, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); STBIR_ASSERT(output[0] == input[0]); STBIR_ASSERT(output[1] == (input[0] + input[1]) / 2); STBIR_ASSERT(output[2] == input[1]); stbir_resize(input, 1, 2, 0, output, 1, 3, 0, STBIR_TYPE_UINT32, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); STBIR_ASSERT(output[0] == input[0]); STBIR_ASSERT(output[1] == (input[0] + input[1]) / 2); STBIR_ASSERT(output[2] == input[1]); } // checkerboard { unsigned char input[64][64]; unsigned char output[16][16]; int i,j; for (j=0; j < 64; ++j) for (i=0; i < 64; ++i) input[j][i] = (i^j)&1 ? 255 : 0; stbir_resize_uint8_generic(input[0], 64, 64, 0, output[0],16,16,0, 1,-1,0,STBIR_EDGE_WRAP,STBIR_FILTER_DEFAULT,STBIR_COLORSPACE_LINEAR,0); for (j=0; j < 16; ++j) for (i=0; i < 16; ++i) STBIR_ASSERT(output[j][i] == 128); stbir_resize_uint8_srgb_edgemode(input[0], 64, 64, 0, output[0],16,16,0, 1,-1,0,STBIR_EDGE_WRAP); for (j=0; j < 16; ++j) for (i=0; i < 16; ++i) STBIR_ASSERT(output[j][i] == 188); } { // Test trapezoid box filter unsigned char input[2 * 1]; unsigned char output[127 * 1]; input[0] = 0; input[1] = 255; stbir_resize(input, 2, 1, 0, output, 127, 1, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); STBIR_ASSERT(output[0] == 0); STBIR_ASSERT(output[127 / 2 - 1] == 0); STBIR_ASSERT(output[127 / 2] == 128); STBIR_ASSERT(output[127 / 2 + 1] == 255); STBIR_ASSERT(output[126] == 255); stbi_write_png("test-output/trapezoid-upsample-horizontal.png", 127, 1, 1, output, 0); stbir_resize(input, 1, 2, 0, output, 1, 127, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); STBIR_ASSERT(output[0] == 0); STBIR_ASSERT(output[127 / 2 - 1] == 0); STBIR_ASSERT(output[127 / 2] == 128); STBIR_ASSERT(output[127 / 2 + 1] == 255); STBIR_ASSERT(output[126] == 255); stbi_write_png("test-output/trapezoid-upsample-vertical.png", 1, 127, 1, output, 0); } } #define UMAX32 4294967295U static void write32(const char *filename, stbir_uint32 *output, int w, int h) { stbir_uint8 *data = (stbir_uint8*) malloc(w*h*3); for (int i=0; i < w*h*3; ++i) data[i] = output[i]>>24; stbi_write_png(filename, w, h, 3, data, 0); free(data); } static void test_32(void) { int w=100,h=120,x,y, out_w,out_h; stbir_uint32 *input = (stbir_uint32*) malloc(4 * 3 * w * h); stbir_uint32 *output = (stbir_uint32*) malloc(4 * 3 * 3*w * 3*h); for (y=0; y < h; ++y) { for (x=0; x < w; ++x) { input[y*3*w + x*3 + 0] = x * ( UMAX32/w ); input[y*3*w + x*3 + 1] = y * ( UMAX32/h ); input[y*3*w + x*3 + 2] = UMAX32/2; } } out_w = w*33/16; out_h = h*33/16; stbir_resize(input,w,h,0,output,out_w,out_h,0,STBIR_TYPE_UINT32,3,-1,0,STBIR_EDGE_CLAMP,STBIR_EDGE_CLAMP,STBIR_FILTER_DEFAULT,STBIR_FILTER_DEFAULT,STBIR_COLORSPACE_LINEAR,NULL); write32("test-output/seantest_1.png", output,out_w,out_h); out_w = w*16/33; out_h = h*16/33; stbir_resize(input,w,h,0,output,out_w,out_h,0,STBIR_TYPE_UINT32,3,-1,0,STBIR_EDGE_CLAMP,STBIR_EDGE_CLAMP,STBIR_FILTER_DEFAULT,STBIR_FILTER_DEFAULT,STBIR_COLORSPACE_LINEAR,NULL); write32("test-output/seantest_2.png", output,out_w,out_h); } void test_suite(int argc, char **argv) { int i; const char *barbara; mkdir("test-output", 777); if (argc > 1) barbara = argv[1]; else barbara = "barbara.png"; // check what cases we need normalization for #if 1 { float x, y; for (x = -1; x < 1; x += 0.05f) { float sums[5] = { 0 }; float o; for (o = -5; o <= 5; ++o) { sums[0] += stbir__filter_mitchell(x + o, 1); sums[1] += stbir__filter_catmullrom(x + o, 1); sums[2] += stbir__filter_cubic(x + o, 1); sums[3] += stbir__filter_triangle(x + o, 1); sums[4] += stbir__filter_trapezoid(x + o, 0.5f); } for (i = 0; i < 5; ++i) STBIR_ASSERT(sums[i] >= 1.0 - 0.001 && sums[i] <= 1.0 + 0.001); } #if 1 for (y = 0.11f; y < 1; y += 0.01f) { // Step for (x = -1; x < 1; x += 0.05f) { // Phase float sums[5] = { 0 }; float o; for (o = -5; o <= 5; o += y) { sums[0] += y * stbir__filter_mitchell(x + o, 1); sums[1] += y * stbir__filter_catmullrom(x + o, 1); sums[2] += y * stbir__filter_cubic(x + o, 1); sums[4] += y * stbir__filter_trapezoid(x + o, 0.5f); sums[3] += y * stbir__filter_triangle(x + o, 1); } for (i = 0; i < 3; ++i) STBIR_ASSERT(sums[i] >= 1.0 - 0.0170 && sums[i] <= 1.0 + 0.0170); } } #endif } #endif #if 0 // linear_to_srgb_uchar table for (i=0; i < 256; ++i) { float f = stbir__srgb_to_linear((i-0.5f)/255.0f); printf("%9d, ", (int) ((f) * (1<<28))); if ((i & 7) == 7) printf("\n"); } #endif // old tests that hacky fix worked on - test that // every uint8 maps to itself for (i = 0; i < 256; i++) { float f = stbir__srgb_to_linear(float(i) / 255); int n = stbir__linear_to_srgb_uchar(f); STBIR_ASSERT(n == i); } // new tests that hacky fix failed for - test that // values adjacent to uint8 round to nearest uint8 for (i = 0; i < 256; i++) { for (float y = -0.42f; y <= 0.42f; y += 0.01f) { float f = stbir__srgb_to_linear((i+y) / 255.0f); int n = stbir__linear_to_srgb_uchar(f); STBIR_ASSERT(n == i); } } test_filters(); test_subpixel_1(); test_subpixel_2(); test_subpixel_3(); test_subpixel_4(); test_premul(); test_32(); // Some tests to make sure errors don't pop up with strange filter/dimension combinations. stbir_resize(image88, 8, 8, 0, output88, 4, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context); stbir_resize(image88, 8, 8, 0, output88, 4, 16, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_BOX, STBIR_COLORSPACE_SRGB, &g_context); stbir_resize(image88, 8, 8, 0, output88, 16, 4, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_FILTER_CATMULLROM, STBIR_COLORSPACE_SRGB, &g_context); stbir_resize(image88, 8, 8, 0, output88, 16, 4, 0, STBIR_TYPE_UINT8, 1, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, STBIR_FILTER_BOX, STBIR_COLORSPACE_SRGB, &g_context); int barbara_width, barbara_height, barbara_channels; stbi_image_free(stbi_load(barbara, &barbara_width, &barbara_height, &barbara_channels, 0)); int res = 10; // Downscaling {for (int i = 0; i <= res; i++) { float t = (float)i/res; float scale = 0.5; float out_scale = 2.0f/3; float x_shift = (barbara_width*out_scale - barbara_width*scale) * t; float y_shift = (barbara_height*out_scale - barbara_height*scale) * t; test_subpixel_command(barbara, scale, scale, out_scale, out_scale, x_shift, y_shift); }} // Upscaling {for (int i = 0; i <= res; i++) { float t = (float)i/res; float scale = 2; float out_scale = 3; float x_shift = (barbara_width*out_scale - barbara_width*scale) * t; float y_shift = (barbara_height*out_scale - barbara_height*scale) * t; test_subpixel_command(barbara, scale, scale, out_scale, out_scale, x_shift, y_shift); }} // Downscaling {for (int i = 0; i <= res; i++) { float t = (float)i/res / 2; test_subpixel_region(barbara, 0.25f, 0.25f, t, t, t+0.5f, t+0.5f); }} // No scaling {for (int i = 0; i <= res; i++) { float t = (float)i/res / 2; test_subpixel_region(barbara, 0.5f, 0.5f, t, t, t+0.5f, t+0.5f); }} // Upscaling {for (int i = 0; i <= res; i++) { float t = (float)i/res / 2; test_subpixel_region(barbara, 1, 1, t, t, t+0.5f, t+0.5f); }} {for (i = 0; i < 10; i++) test_subpixel(barbara, 0.5f, 0.5f, (float)i / 10, 1); } {for (i = 0; i < 10; i++) test_subpixel(barbara, 0.5f, 0.5f, 1, (float)i / 10); } {for (i = 0; i < 10; i++) test_subpixel(barbara, 2, 2, (float)i / 10, 1); } {for (i = 0; i < 10; i++) test_subpixel(barbara, 2, 2, 1, (float)i / 10); } // Channels test test_channels(barbara, 0.5f, 0.5f, 1); test_channels(barbara, 0.5f, 0.5f, 2); test_channels(barbara, 0.5f, 0.5f, 3); test_channels(barbara, 0.5f, 0.5f, 4); test_channels(barbara, 2, 2, 1); test_channels(barbara, 2, 2, 2); test_channels(barbara, 2, 2, 3); test_channels(barbara, 2, 2, 4); // filter tests resize_image(barbara, 2, 2, STBIR_FILTER_BOX , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-upsample-nearest.png"); resize_image(barbara, 2, 2, STBIR_FILTER_TRIANGLE , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-upsample-bilinear.png"); resize_image(barbara, 2, 2, STBIR_FILTER_CUBICBSPLINE, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-upsample-bicubic.png"); resize_image(barbara, 2, 2, STBIR_FILTER_CATMULLROM , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-upsample-catmullrom.png"); resize_image(barbara, 2, 2, STBIR_FILTER_MITCHELL , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-upsample-mitchell.png"); resize_image(barbara, 0.5f, 0.5f, STBIR_FILTER_BOX , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-downsample-nearest.png"); resize_image(barbara, 0.5f, 0.5f, STBIR_FILTER_TRIANGLE , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-downsample-bilinear.png"); resize_image(barbara, 0.5f, 0.5f, STBIR_FILTER_CUBICBSPLINE, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-downsample-bicubic.png"); resize_image(barbara, 0.5f, 0.5f, STBIR_FILTER_CATMULLROM , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-downsample-catmullrom.png"); resize_image(barbara, 0.5f, 0.5f, STBIR_FILTER_MITCHELL , STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, "test-output/barbara-downsample-mitchell.png"); {for (i = 10; i < 100; i++) { char outname[200]; sprintf(outname, "test-output/barbara-width-%d.jpg", i); resize_image(barbara, (float)i / 100, 1, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, outname); }} {for (i = 110; i < 500; i += 10) { char outname[200]; sprintf(outname, "test-output/barbara-width-%d.jpg", i); resize_image(barbara, (float)i / 100, 1, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, outname); }} {for (i = 10; i < 100; i++) { char outname[200]; sprintf(outname, "test-output/barbara-height-%d.jpg", i); resize_image(barbara, 1, (float)i / 100, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, outname); }} {for (i = 110; i < 500; i += 10) { char outname[200]; sprintf(outname, "test-output/barbara-height-%d.jpg", i); resize_image(barbara, 1, (float)i / 100, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, outname); }} {for (i = 50; i < 200; i += 10) { char outname[200]; sprintf(outname, "test-output/barbara-width-height-%d.jpg", i); resize_image(barbara, 100 / (float)i, (float)i / 100, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB, outname); }} test_format(barbara, 0.5, 2.0, STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB); test_format(barbara, 0.5, 2.0, STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR); test_format(barbara, 2.0, 0.5, STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB); test_format(barbara, 2.0, 0.5, STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR); test_format(barbara, 0.5, 2.0, STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB); test_format(barbara, 0.5, 2.0, STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR); test_format(barbara, 2.0, 0.5, STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB); test_format(barbara, 2.0, 0.5, STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR); test_float(barbara, 0.5, 2.0, STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB); test_float(barbara, 0.5, 2.0, STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR); test_float(barbara, 2.0, 0.5, STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB); test_float(barbara, 2.0, 0.5, STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR); // Edge behavior tests resize_image("hgradient.png", 2, 2, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR, "test-output/hgradient-clamp.png"); resize_image("hgradient.png", 2, 2, STBIR_FILTER_CATMULLROM, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/hgradient-wrap.png"); resize_image("vgradient.png", 2, 2, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR, "test-output/vgradient-clamp.png"); resize_image("vgradient.png", 2, 2, STBIR_FILTER_CATMULLROM, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/vgradient-wrap.png"); resize_image("1px-border.png", 2, 2, STBIR_FILTER_CATMULLROM, STBIR_EDGE_REFLECT, STBIR_COLORSPACE_LINEAR, "test-output/1px-border-reflect.png"); resize_image("1px-border.png", 2, 2, STBIR_FILTER_CATMULLROM, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR, "test-output/1px-border-clamp.png"); // sRGB tests resize_image("gamma_colors.jpg", .5f, .5f, STBIR_FILTER_CATMULLROM, STBIR_EDGE_REFLECT, STBIR_COLORSPACE_SRGB, "test-output/gamma_colors.jpg"); resize_image("gamma_2.2.jpg", .5f, .5f, STBIR_FILTER_CATMULLROM, STBIR_EDGE_REFLECT, STBIR_COLORSPACE_SRGB, "test-output/gamma_2.2.jpg"); resize_image("gamma_dalai_lama_gray.jpg", .5f, .5f, STBIR_FILTER_CATMULLROM, STBIR_EDGE_REFLECT, STBIR_COLORSPACE_SRGB, "test-output/gamma_dalai_lama_gray.jpg"); } uTox/third_party/stb/stb/tests/pngsuite/0000700000175000001440000000000014003056224017404 5ustar rakusersuTox/third_party/stb/stb/tests/pngsuite/unused/0000700000175000001440000000000014003056224020707 5ustar rakusersuTox/third_party/stb/stb/tests/pngsuite/unused/ps2n2c16.png0000600000175000001440000000466414003056224022707 0ustar rakusersPNG  IHDR 1gAMA1_zsPLTsix-cube3f3333f333ff3fffff3f3f3f3333f3333333333f3333333f3f33ff3f3f3f3333f3333333f3333333f333ff3ffffff3f33f3ff3f3f3ffff3fffffffffff3fffffff3fffffff3fffff3f3333f333ff3fffff3f3f3f3f3333f333ff3fffff3f3f3f3f3333f333ff3fffff3f3f3fЋIDATxՖ 0DA~&fzE=֠B>/drs~='3_Zwt(p3p]`_yt?t(C\l52L̩g I@g.`(`g Dg&((`60Y`zl(P49܀:{z*zȟmt3ΞAO3B^IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/ps2n0g08.png0000600000175000001440000000442014003056224022700 0ustar rakusersPNG  IHDR V%(gAMA1_zsPLTsix-cube3f3333f333ff3fffff3f3f3f3333f3333333333f3333333f3f33ff3f3f3f3333f3333333f3333333f333ff3ffffff3f33f3ff3f3f3ffff3fffffffffff3fffffff3fffffff3fffff3f3333f333ff3fffff3f3f3f3f3333f333ff3fffff3f3f3f3f3333f333ff3fffff3f3f3fЋAIDATxcd`$ȳ )?`y00gdy\ q10edPq5YIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/ps1n2c16.png0000600000175000001440000000312414003056224022674 0ustar rakusersPNG  IHDR 1gAMA1_sPLTsix-cube3f3333f333ff3fffff3f3f̙3f3333f3333333333f3333333f3f33ff3f3f3f3333f3333333f3̙333333f333ff3ffffff3f33f3ff3f3f3ffff3fffffffffff3fffffff3fff̙ffff3fffff3f3333f333ff3fffff3f3f̙3f3f3333f333ff3fffff̙̙3̙f̙̙̙3f̙3f3f3333f333ff3fffff3f3f̙3f"h.IDATxՖ 0DA~&fzE=֠B>/drs~='3_Zwt(p3p]`_yt?t(C\l52L̩g I@g.`(`g Dg&((`60Y`zl(P49܀:{z*zȟmt3ΞAO3B^IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/ps1n0g08.png0000600000175000001440000000266014003056224022703 0ustar rakusersPNG  IHDR V%(gAMA1_sPLTsix-cube3f3333f333ff3fffff3f3f̙3f3333f3333333333f3333333f3f33ff3f3f3f3333f3333333f3̙333333f333ff3ffffff3f33f3ff3f3f3ffff3fffffffffff3fffffff3fff̙ffff3fffff3f3333f333ff3fffff3f3f̙3f3f3333f333ff3fffff̙̙3̙f̙̙̙3f̙3f3f3333f333ff3fffff3f3f̙3f"h.AIDATxcd`$ȳ )?`y00gdy\ q10edPq5YIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/pp0n6a08.png0000600000175000001440000000146214003056224022676 0ustar rakusersPNG  IHDR szzgAMA1_PLTE3f3333f333ff3fffff3f3f̙3f3333f3333333333f3333333f3f33ff3f3f3f3333f3333333f3̙333333f333ff3ffffff3f33f3ff3f3f3ffff3fffffffffff3fffffff3fff̙ffff3fffff3f̙3333f33̙3ff3ffff̙f3f̙3f̙̙3f̙3f3333f333ff3fffff̙̙3̙f̙̙̙3f̙3f3f3333f333ff3fffff3f3f̙3fcQUIDATx1 0 CQ<$o ԥKA4 z-qKjI`~Ux\Ku7UIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/pp0n2c16.png0000600000175000001440000000170214003056224022670 0ustar rakusersPNG  IHDR 1gAMA1_PLTE3f3333f333ff3fffff3f3f̙3f3333f3333333333f3333333f3f33ff3f3f3f3333f3333333f3̙333333f333ff3ffffff3f33f3ff3f3f3ffff3fffffffffff3fffffff3fff̙ffff3fffff3f̙3333f33̙3ff3ffff̙f3f̙3f̙̙3f̙3f3333f333ff3fffff̙̙3̙f̙̙̙3f̙3f3f3333f333ff3fffff3f3f̙3fcQIDATxՖ 0DA~&fzE=֠B>/drs~='3_Zwt(p3p]`_yt?t(C\l52L̩g I@g.`(`g Dg&((`60Y`zl(P49܀:{z*zȟmt3ΞAO3B^IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g25n3p04.png0000600000175000001440000000032714003056224022603 0ustar rakusersPNG  IHDR TggAMAАTOPLTE--\\\RQdIDATxα 0 DQ[J+ ^msQ$s5HІ:P 5B) oe p/)FqjS!*$BB?x(:5tf;PIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g25n2c08.png0000600000175000001440000000062514003056224022572 0ustar rakusersPNG  IHDR gAMAАTOLIDATxm1@Nj #؎8Pu-` @ T@|HsZOH0gi,a&^ݥݧSȀY@'%  @V T2H o2 @'J\^_^|AU ov2`4"236"yA瓲4 x pϋ< HHQ‰ b_`8,ߢ^-v@'N=yLӅw@["^] s2 pd@@?+ZD _-a2wIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g25n0g16.png0000600000175000001440000000057714003056224022601 0ustar rakusersPNG  IHDR kgAMAАTO6IDATx 0 @@|"gnā:]5 8DQ-YPVVo@EN\o6VEVj4ef 0O c@ `ӟ3i(ͦzZB 7me\ tf|4t~3Cl^f3{oLkeU>b0]β  o1z0}we}&%ϧS<ے$m 664p_4f@B`2|? 8IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g10n3p04.png0000600000175000001440000000032614003056224022574 0ustar rakusersPNG  IHDR TggAMA1_PLTETTUZcIDATxcP H% `@`@W,@G.@` p00NK`CV`Ɩ *@-H*ـ"(/YLFə:IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g10n2c08.png0000600000175000001440000000043514003056224022563 0ustar rakusersPNG  IHDR gAMA1_IDATx1 0D }ǰ Bp 3H*M&S-g O 7C @T PĠ("kp3p _ (d Pu )-wzCDD2O5 H3oiۺvtv|GSMd"*?l kblt RUԭMTߏIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g10n0g16.png0000600000175000001440000000040614003056224022562 0ustar rakusersPNG  IHDR kgAMA1_IDATx1 E? ,=\!^KXHbřDdcfy΁HkMqye--HwZ_< JMGi =ضB;݃al>hly,kdǔ41{mi!,RIϴϫ IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g07n3p04.png0000600000175000001440000000031714003056224022602 0ustar rakusersPNG  IHDR TggAMAp;XVPLTEvvvNTl\IDATxc4 PA `@`0 @P p0S EX (//(Wbb 00 ``gRBQQ^w*#kr=IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g07n2c08.png0000600000175000001440000000052414003056224022570 0ustar rakusersPNG  IHDR gAMAp;XV IDATxՖA 0E'"+/Ir&!ݖm)E+U:34`;"!WPMė"p)~~ ʒ~\( !C@@I LR4b2fI" Ā30FEow0R2~hp2@Z  6fMW^uP릪R|y?i ` DlknkYuKc,5U(s(28 3Z? IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g07n0g16.png0000600000175000001440000000050114003056224022564 0ustar rakusersPNG  IHDR kgAMAp;XVIDATx͕ 0 B%hXI\1-Dl IL9P8j-Z׵Z{ۦ>2x n@i$qliE: - tA LZ߷4 di`Y8 }SU1@ͣAYhgphk \";9@39BuxC]] @ Ҡ >š,s,IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g05n3p04.png0000600000175000001440000000031614003056224022577 0ustar rakusersPNG  IHDR TggAMAOX2PLTEs$[IDATxcP pA `@`P@W,@Gi@` p00vq`AV`CU ``gjARQ^w*x;JUIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g05n2c08.png0000600000175000001440000000053614003056224022571 0ustar rakusersPNG  IHDR gAMAOX2IDATx90ERBDAGChr8hnB @B"B$pT/ϱܪd?nGg 9 vi%(.tDj$" n Ejj@ͦ  2@5Eۢ`W f@ՠV *2 @StA鴸̲/klyС(BK@`n\"2z˷^dx!E" Vf@ˡE7j9M,WIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g05n0g16.png0000600000175000001440000000052314003056224022566 0ustar rakusersPNG  IHDR kgAMAOX2 IDATxս 0~ H7i>AA U As GA/@ Q#99͹~ͅEX@p:)q)8WSp80/)n#vW <8`2C~8\x8ah`,uA׭ nV @_`+(W]X&*&5-~> ϧR#лtpDPGXDzЂd ?_fAIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g04n3p04.png0000600000175000001440000000033314003056224022575 0ustar rakusersPNG  IHDR TggAMA7PLTE",hIDATx 0D!ہ[\Ӷ` `N?eq]Q- q@SMť" DCܛ6 ѐ }~ uIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g04n2c08.png0000600000175000001440000000057114003056224022567 0ustar rakusersPNG  IHDR gAMA70IDATxՖ=n@F̟D-}H(R"~_Oq)xw޼!Su4T矪'3p0R%F``\~ql\^6 >`k\Π1d@Wnw G/Ȼ15+:@ l`6 rD^_](iX."d@3V1yod@o3LzdR f8l6?VFpaHnnrenuݮ|4-)4(cIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g03n3p04.png0000600000175000001440000000032614003056224022576 0ustar rakusersPNG  IHDR TggAMAIPLTEȭ1 cIDATxc(% 0A `@`@W,@G.@p`06`FRalb\%U@ l@-H*@ SRpIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g03n2c08.png0000600000175000001440000000056214003056224022566 0ustar rakusersPNG  IHDR gAMAI)IDATxM@F1Dw.x!.2dFgFˆ$øVJ_.b+gƻGq98`>//߀шVa" A+P :Π P Z-@TfSA2~4@]5Ȁ_>tl̮1333$RdV8$lB'4I^7m6MV78YmtC|wcn'[|(% jПA Ϻd@ ZY#[jIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/g03n0g16.png0000600000175000001440000000053114003056224022563 0ustar rakusersPNG  IHDR kgAMAIIDATxM 0WZEP(]S4^"\"_mu!A3Ct7Hi|k,P1 Q`8  M$ z NA)]Wqm)*N ׫_ׂ X.TyecyZBJu2y"8MN7E@WP Mw; N'`2}&8MUeem`<u+DݷIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/f99n0g04.png0000600000175000001440000000065214003056224022602 0ustar rakusersPNG  IHDR )qIDATxuQNAdj8R4TV? 0_@=3 2F‚] ւ`0A̼yoCsOWg {'`]|7fDr2pG ,\`KaB&@y0 {s4iv[q@2(+M2 ^X@Ka@F`F96**Yի6Z)yY٣hV+%y33O|@&2Yq~({H`G: j!ᕐaLAvde+'ܡixlryں%_*v|[I [7ND)S?%]M.VoQ㎐B d/?o[tIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/f04n2c08.png0000600000175000001440000000173114003056224022565 0ustar rakusersPNG  IHDR IDATx͎E[Uv۔("  ${Y[g*BQ,<3c/n=c ZG֭v[N+:ۭv=WoTQa8`HB[ n zeH4;؂->VJP_Ӻrό9q'JB i9 "Ok-E4Ҹ2mr n:(UB 칻ZLwW)40)t\+ T_?G٪{wGN)t йj^0~_j 4hL| sIE@ ͐mʢv;̣8R^j" RC6>|+WAp )O'-a_[>w(e5H5:϶yz8㖫$CykU樏G.% )xr|Ok5 }MR9?Hұ5`_€Q .i P7|Hrel$Л\$XT)3T%?qoٿ*V%J(Kq Oq/nB]g_`GR|%mʹbZ2w̛@{?X&^~ MTPIF$->Ү|#0M&ؑd'Q($4 0Scs:yꆼU]Mj 0WGɱ٦o l` k;4 Xͽ {vG!@,'$iKqOaHOv}8Xg DBs96)j2"4~, *ڧ30ClZ(cՂU@ \Ҍivݙ!)̓r+LV71 jIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/f04n0g08.png0000600000175000001440000000041514003056224022565 0ustar rakusersPNG  IHDR V%(IDATxm0Lb )nK'-X B!9Dzѧي|o&C{/މsYk1#gZL B.mz#\@* // _,LPߪZQ[6@]8_fX`ⷹ=L[+/C qfS(RR| D_H/$@&L!`IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/f03n2c08.png0000600000175000001440000000241314003056224022562 0ustar rakusersPNG  IHDR IDATx}]TeϼggZ,(BB2B*M  zxc~PwUwMW{m "^XvabE|}893a?Qr6WŊG7٧7m/ڗ^wډ7I-]!{S{=qž~S̱u/EP2E(B ƚ%Eȃ/)¨2a&$&c-ˈZFGawK$qIJ 3<{=<{xjxJ=Z5fLP9 0U~4 ߄-|fm@+u1qv7/M1 i"ޡE*plCǰby% &'0B{C* T L @cg\B 9IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/f02n2c08.png0000600000175000001440000000330114003056224022556 0ustar rakusersPNG  IHDR IDATxmI$yoD-YKWee xƓ s@#xƃ0" (*"҈=ݵuUU&eAjҞPRd91aTI)5aXL+Fxx\7enhƸ}Lʢ62+/PDa\KAe@(8sIs qU%2Wm:!UQeD))C&5k,xs[T/&\K\{pN`Wσ1+l)LxƄQaDÝ뱭w,;{q7Mt FO|Azz:ԡ-4AԣvZlĶeǛmWfy>ohy2DR:AO+16=MlemĶ쁳EEyOlnB79D#9FW-4z6Gj6cϑpײ*3%%sp&aKpmϱ(pвݘ-gV~jv݊)&Rz!6So'ގ%4[^l;ζm:[ ,X)HlW#PTL|o-o.)8iGqь{uHGg6[m~.~?7i7iæ5d=_0?IR'iК&x[]{ r>@Btttؤf2gLX2iɔX!.y,'͑ Jqie<z<}B ,;{3:rwBnNN,' -KQXq©pzv[llĬ98;bEAQyNfV|JK'DmN~ TªcrԿC(*ۡӥWfvJ'~ TºcHV5d +Kѡۥ2Q$+^B T+*abts:9yF^VӒ1{1;-Ǧc-C>We==IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/f02n0g08.png0000600000175000001440000000054314003056224022565 0ustar rakusersPNG  IHDR V%(*IDATx/KQ8 A M,XI0 V `M`b,AA}_æ½pp:<&1"iDD1Zw{B1FDJA)JAP R4A`w{s=4Jtm}L\$ EDj@M'TR$z.BĢ ..k>PZdOb 31z]贘G1(q tڷOr|1:S! ?C+k[;{CAE  䗿IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/f01n2c08.png0000600000175000001440000000223414003056224022561 0ustar rakusersPNG  IHDR cIDATx?%UΜ34"XBc+АPF M(,hH((,10V5RB %,bܝ토x7}ost°ٙbW>y~Lk鯝U(3kAy=uesp+ȍ2:SAE7woyU~wz:`{('^TU*qVNzS)S[I[DY\O*_ ?+t|' E3ǧpդ$LTPMR54: @|6ۿ|a3Ƞ@ *TTA:0`pIvz (Ȓ"Dթhbvt;}@8}*(fDv8䨞ꨞi٫ُ3Zg { IdyW LδH Q=~w'%hr')<Gh9^zp70FR(;{ ^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$"ˋ?CCP75Cp`,%/}XPζIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/ctzn0g04.png0000600000175000001440000000136114003056224022771 0ustar rakusersPNG  IHDR )gAMA1_tEXtTitlePngSuiteOUL1tEXtAuthorWillem A.J. van Schaik (willem@schaik.com)GAzTXtCopyrightxs/,L(QIU(KSNHQKO,/JU04յ4aRZzTXtDescriptionx-0 D~MLX`\C"8J UWY{wwRg+]|?BO&2 .IlL} "$ܮg<-.=KMk.QI#|Ě=&'*EQ5 o>ᤊ{,SPm{͹<}mUxoGmҥVbz@zTXtSoftwarexs.JM,IMQSHTK).I,sJ3 rK ҕBQzTXtDisclaimerxs+JM-O,JU`ԮIDATx] 0 P*@# #T10lPF`ؠF=IQ*u`%qk H񚈩mߟ э=,fOK t(F ;P{xp]9/p*$(*yՃ@C  cqNU#)11.rf0gh(tEkIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/ctjn0g04.png0000600000175000001440000000165514003056224022757 0ustar rakusersPNG  IHDR )gAMA1_ iTXtTitlejaタイトルPngSuite\8iTXtAuthorja著者Willem van Schaik (willem@schaik.com)̡SiTXtCopyrightja本文へ著作権ウィレムヴァンシャイク、カナダ2011_mwiTXtDescriptionja概要PNG形式の様々な色の種類をテストするために作成されたイメージのセットのコンパイル。含まれているのは透明度のフォーマットで、アルファチャネルを持つ、白黒、カラー、パレットです。すべてのビット深度が存在している仕様に従ったことができました。 ciTXtSoftwarejaソフトウェア"pnmtopng"を使用してNeXTstation色上に作成されます。ƒ02iTXtDisclaimerja免責事項フリーウェア。vCeIDAT(c``..ii d *)vt#dl?;s&9 Ȱj9h\rİ{3 Ϝ{wn޽#CN H>IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cthn0g04.png0000600000175000001440000000236514003056224022754 0ustar rakusersPNG  IHDR )gAMA1_&iTXtTitlehiशीर्षकPngSuiteSK>iTXtAuthorhiलेखकWillem van Schaik (willem@schaik.com)M}hiTXtCopyrighthiकॉपीराइटकॉपीराइट Willem van Schaik, 2011 कनाडाՅeiTXtDescriptionhiविवरणकरने के लिए PNG प्रारूप के विभिन्न रंग प्रकार परीक्षण बनाया छवियों का एक सेट का एक संकलन. शामिल काले और सफेद, रंग, पैलेटेड हैं, अल्फा चैनल के साथ पारदर्शिता स्वरूपों के साथ. सभी बिट गहराई कल्पना के अनुसार की अनुमति दी मौजूद हैं.ԑiTXtSoftwarehiसॉफ्टवेयरएक NeXTstation "pnmtopng 'का उपयोग कर रंग पर बनाया गया.QBiTXtDisclaimerhiअस्वीकरणफ्रीवेयर.-O@`IDAT(c_Pccдrq;:wL\\;e O 4V"OI@ 2`ݻ%K@H IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/ctgn0g04.png0000600000175000001440000000223614003056224022750 0ustar rakusersPNG  IHDR )gAMA1_ iTXtTitleelΤίτλοςPngSuite @FiTXtAuthorelΣυγγραφέαςWillem van Schaik (willem@schaik.com)*6fiTXtCopyrightelΠνευματικά δικαιώματαΠνευματικά δικαιώματα Schaik van Willem, Καναδάς 2011#viTXtDescriptionelΠεριγραφήΜια συλλογή από ένα σύνολο εικόνων που δημιουργήθηκαν για τη δοκιμή των διαφόρων χρωμάτων-τύπων του μορφή PNG. Περιλαμβάνονται οι ασπρόμαυρες, χρώμα, paletted, με άλφα κανάλι, με μορφές της διαφάνειας. Όλοι λίγο-βάθη επιτρέπεται σύμφωνα με το spec είναι παρόντες.)iTXtSoftwareelΛογισμικόΔημιουργήθηκε σε ένα χρώμα NeXTstation χρησιμοποιώντας "pnmtopng".CxCiTXtDisclaimerelΑποποίησηΔωρεάν λογισμικό.,l]IDAT(A! Ch,`P X@ ӝ= KǘDifki}{) %5 #E9AEIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/ctfn0g04.png0000600000175000001440000000131414003056224022743 0ustar rakusersPNG  IHDR )gAMA1_iTXtTitlefiOtsikkoPngSuiteI9iTXtAuthorfiTekijäWillem van Schaik (willem@schaik.com)MHiTXtCopyrightfiTekijänoikeudetCopyright Willem van Schaik, Kanada 2011iTXtDescriptionfiKuvauskokoelma joukon kuvia luotu testata eri väri-tyyppisiä PNG-muodossa. Mukana on mustavalkoinen, väri, paletted, alpha-kanava, avoimuuden muodossa. Kaikki bit-syvyydessä mukaan sallittua spec on ​​läsnä.6qY?iTXtSoftwarefiOhjelmistotLuotu NeXTstation väriä "pnmtopng".Qm]-iTXtDisclaimerfiVastuuvapauslausekeFreeware.w/HIDAT(c..ii d ()! ΜI <w*иd w9C rAĽIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cten0g04.png0000600000175000001440000000134614003056224022747 0ustar rakusersPNG  IHDR )gAMA1_iTXtTitleenTitlePngSuiteլ8iTXtAuthorenAuthorWillem van Schaik (willem@schaik.com)EW AiTXtCopyrightenCopyrightCopyright Willem van Schaik, Canada 20113 iTXtDescriptionenDescriptionA compilation of a set of images created to test the various color-types of the PNG format. Included are black&white, color, paletted, with alpha channel, with transparency formats. All bit-depths allowed according to the spec are present.~5 DGiTXtSoftwareenSoftwareCreated on a NeXTstation color using "pnmtopng".$iTXtDisclaimerenDisclaimerFreeware.Ӿ2 LIDAT(c..ii d ()! ΜII@@ \<\ݻϜ!OztݳQU4IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/ct1n0g04.png0000600000175000001440000000143014003056224022655 0ustar rakusersPNG  IHDR )gAMA1_tEXtTitlePngSuiteOUL1tEXtAuthorWillem A.J. van Schaik (willem@schaik.com)G8tEXtCopyrightCopyright Willem van Schaik, Singapore 1995-96P8tEXtDescriptionA compilation of a set of images created to test the various color-types of the PNG format. Included are black&white, color, paletted, with alpha channel, with transparency formats. All bit-depths allowed according to the spec are present.M k9tEXtSoftwareCreated on a NeXTstation color using "pnmtopng".jdytEXtDisclaimerFreeware._,JIDATx] 0 P*@# #T10lPF`ؠF=IQ*u`%qk H񚈩mߟ э=,fOK t(F ;P{xp]9/p*$(*yՃ@C  cqNU#)11.rf0gh(tEkIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/ct0n0g04.png0000600000175000001440000000042114003056224022653 0ustar rakusersPNG  IHDR )gAMA1_IDATx] 0 P*@# #T10lPF`ؠF=IQ*u`%qk H񚈩mߟ э=,fOK t(F ;P{xp]9/p*$(*yՃ@C  cqNU#)11.rf0gh(tEkIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cs8n3p08.png0000600000175000001440000000040014003056224022677 0ustar rakusersPNG  IHDR DgAMA1_`PLTE ߠ?_`@`@_ ?cKIDATx0[> |Gp "lX *A/P $BP Z.Y N-x)>SIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cs8n2c08.png0000600000175000001440000000022514003056224022666 0ustar rakusersPNG  IHDR gAMA1_LIDATxA 0 BQcjS҉hi Dk`j}0MA_uoFIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cs5n3p08.png0000600000175000001440000000041714003056224022704 0ustar rakusersPNG  IHDR DgAMA1_sBIT&C`PLTEB{c!Z::cZ!B{G/KIDATx0[>@Vj%(`R A XtY VA,`d\p *-hq>IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cs5n2c08.png0000600000175000001440000000027214003056224022665 0ustar rakusersPNG  IHDR gAMA1_sBIT&CbIDATx핱@ Ô;/Awl@*QEDqm\a .[p=jE'-X@O0 WyH0o y<Aa=^ohIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cs3n3p08.png0000600000175000001440000000040314003056224022675 0ustar rakusersPNG  IHDR DgAMA1_sBITBTPLTEmmI$$II$m$Imp+KIDATxbWT#$tNzC{h t. mtn:B"@3w&IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cs3n2c16.png0000600000175000001440000000032614003056224022662 0ustar rakusersPNG  IHDR 1gAMA1_sBIT 7~IDATx @ H*)^ < 4\u wClPgXPR3ޛߟ:Ž~!N$#|G}LCli(?c"B@aEDG@0S&i\vgIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cm9n0g04.png0000600000175000001440000000044414003056224022662 0ustar rakusersPNG  IHDR )gAMA1_tIME ;;u0IDATx] 0 P*@# #T10lPF`ؠF=IQ*u`%qk H񚈩mߟ э=,fOK t(F ;P{xp]9/p*$(*yՃ@C  cqNU#)11.rf0gh(tEkIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cm7n0g04.png0000600000175000001440000000044414003056224022660 0ustar rakusersPNG  IHDR )gAMA1_tIME V IDATx] 0 P*@# #T10lPF`ؠF=IQ*u`%qk H񚈩mߟ э=,fOK t(F ;P{xp]9/p*$(*yՃ@C  cqNU#)11.rf0gh(tEkIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cm0n0g04.png0000600000175000001440000000044414003056224022651 0ustar rakusersPNG  IHDR )gAMA1_tIME "8ݜIDATx] 0 P*@# #T10lPF`ؠF=IQ*u`%qk H񚈩mߟ э=,fOK t(F ;P{xp]9/p*$(*yՃ@C  cqNU#)11.rf0gh(tEkIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/ch2n3p08.png0000600000175000001440000000342214003056224022665 0ustar rakusersPNG  IHDR DgAMA1_PLTE"Dww :w""""Uffff"DDUU"DDUU3DDff3D"ffD33U*D˺[""f2Ucw:DDkfBkܺ33sJw{"w332fDwJf""UUDff3UwwDwffD"w"3333cU3{UUUUf܃wwUUww""DD3ԪU*U˴f3BSD̙"Sww333Ĉwff""UU"DD[wfwws33wD""U"f 3bhISTMIDATx GHd+;3 ekXegа**4h lޣY2W%syiHCL*;8"KE6sx'HK?Y9sģ>1~!'B 0IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/ch1n3p04.png0000600000175000001440000000040214003056224022653 0ustar rakusersPNG  IHDR TggAMA1_sBITw-PLTE""fwDDҰIhIST@p0`` P@0PpHYAGIDATxc =sfժrcwfd C+(H*ŅTݻq@*)#MK#G{7}IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cdun2c08.png0000600000175000001440000000132414003056224022745 0ustar rakusersPNG  IHDR gAMA1_sBITw pHYs{RkgIDATx qjhWK %ܵB q @ Fx7 zO/̃/[ü ̍ӑm@`]]6y~KXa;e" ṯ[I=du5V3>&?wVӶc[lJ6YՖ` ⤉)?euSX,QOyKN]J:#< CL=v%$ǃ'JwMk=b+\u;zwP^<'pbS d(@J,=9ּnH])rt`oIAtUۛDVbmB5˙(YkTns=xBd"\`"[ fRhz0'mehCMݨ3  Ldٯ?`~+Іdl*#p]q2^ɩ8|_ rj:2Ckiʙ9ff |ADJi?c~++ 範t>rl5yM.f P6@.lIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cdsn2c08.png0000600000175000001440000000035014003056224022741 0ustar rakusersPNG  IHDRKm)gAMA1_sBITw pHYsO%{IDATxEQ @DSga-B+ X JV++|4L2]C0بp|̡b?Liy+[}5kIR0_66T$'GjD>Pe}P] aO_w |*/^֮IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cdhn2c08.png0000600000175000001440000000053014003056224022726 0ustar rakusersPNG  IHDR jgAMA1_sBITw pHYsUeIDATx}k ZB,B,B,XX#!Btvw@Ÿ7xźG93zWڣ / X ]D,lpar )fK+J^?]OFsaM̂h$kQt0N;8t-F Bf =SpԕjAdf"(>/6ީ~k\hIENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/cdfn2c08.png0000600000175000001440000000062414003056224022730 0ustar rakusersPNG  IHDR gAMA1_sBITw pHYs2R0'IDATxUaq0 ௙SPp R8 @h Tv6]iW[dogsPz`qfX)\ةo_ճ_ժLNNq u*nVS pv5%/sPdG"Gx% ^ .Utl[mv=K#~e%ȥkQ|܏y1](+AFK F898%| OҎISSq-r3˯[œ"}p4=ABYi9Q@u3us IENDB`uTox/third_party/stb/stb/tests/pngsuite/unused/ccwn3p08.png0000600000175000001440000000302214003056224022761 0ustar rakusersPNG  IHDR DgAMA1_ cHRMz&u0`:pQ<PLTEމu k51I&442tQ#l-^>bOw3X .c$s=;Y\z<HA(-I`%{KR~o|dqj`+_p5]g+=dEcC=K&037c, G6ǫfYLqLَJ{AL;[@]~T<e9O)f ˝4foX㌖Ae=6&^?)gKT!i¿kK{|SiC/5^eMu@~rs>oݛ?@3'0|{O%?|{S 9OU>/WLbz Y+к+JIDATxc8B0m\ 4RR¥ #* \kjZ]OhM$]un6n SUrn: a(`Ywhsh \7Oڿ{ѣ[BCWǣ*Uy~55T]E$Wvwk^a\",:Ad9IW 45dVUO8\YI$.lkzÂzz $\\cz)nh4Ck']pn.OM^ȱr-e8q́_jխ[ Nl)s6SE^~YPtKQQ ۇNX&Ѷ]I{7(31s+H׀ ]jSRokV֩e+O>{bk'ܙt>/_N-[&$T"+a)P^Me#ΗS>BϜ93or S}}TT6*@Hp4R1 Ng V㬞d<t:XAդ>#88z~ N{nCT8^@7f{0>c&`[M4.!E4&AKgڧ藘MtP]k):b$B`نDua֎ś1pi{nLO .Q*F搸 kº0求xIv |it(=7b65aC #a$ SANEG{G8gCa, 7^^=I]BЭ-Cʅ;8N{A$6$*0Ԍ>qل"a:&$2u>Of[9E fskTZ$ A27CRu,_9s_~G5b .07ɛmK9.r<};,%"o㞩6",5f}<ܞo@JLWW/FJ*y]^'; D(IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/0000700000175000001440000000000014003056224022224 5ustar rakusersuTox/third_party/stb/stb/tests/pngsuite/primary_check/z09n2c08.png0000600000175000001440000000064614003056224024137 0ustar rakusersPNG  IHDR szzgAMA asRGB cHRMz&u0`:pQ<bKGDIDATXҹ 0,bʱ&78dg={owvd>)2@88"TƝq q q Ƹq9n+Wp q  tpptqf8# N `FhOFh*;|G18p& Om%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:05:54-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/z06n2c08.png0000600000175000001440000000064614003056224024134 0ustar rakusersPNG  IHDR szzgAMA asRGB cHRMz&u0`:pQ<bKGDIDATXҹ 0,bʱ&78dg={owvd>)2@88"TƝq q q Ƹq9n+Wp q  tpptqf8# N `FhOFh*;|G18p& Om%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:05:52-07:00 IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/z03n2c08.png0000600000175000001440000000064614003056224024131 0ustar rakusersPNG  IHDR szzgAMA asRGB cHRMz&u0`:pQ<bKGDIDATXҹ 0,bʱ&78dg={owvd>)2@88"TƝq q q Ƹq9n+Wp q  tpptqf8# N `FhOFh*;|G18p& Om%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:05:52-07:00 IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/z00n2c08.png0000600000175000001440000000064614003056224024126 0ustar rakusersPNG  IHDR szzgAMA asRGB cHRMz&u0`:pQ<bKGDIDATXҹ 0,bʱ&78dg={owvd>)2@88"TƝq q q Ƹq9n+Wp q  tpptqf8# N `FhOFh*;|G18p& Om%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:05:52-07:00 IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/tp1n3p08.png0000600000175000001440000000356714003056224024244 0ustar rakusersPNG  IHDR szzgAMA1_bKGDIDATXŗo?37^0׬5yj#"ED%ry"E"yK>U-E jd]X0q1Գw\c.%Rv͞s~sVBszt:-fffD\~! ms8ɈoM2=}eDB,^s|ǏDMi5*$333,..P'4?Qv$a`oEoFQ岸qdwb:7e2xaP Owtu|v;ze8X !m H&$IRiB6KhzFv.y;hVVpt5߾{( hX,@@0;;+Ν;G^g}o_Ut@~?Q==DI,-A /`"V$ &'' E\. à^D[X@|24[z/w ;m6<@0x:u]'SՈFu#@ulPl,Fh嫽m#96Frl&i)4M `xxx3a5sR8G׎v1 jJ^j[OAXP(:a`@ni޻j։K%:omnXZ5ߟp(Ϗ32l_RrSͩvсB`YV,XXhG?6p12wu>< ZƊoX, otwy(aZ[]D"d BwC 0:[dqd` +H H0:rIOPEt| ϒBJ, 00Mtځe54Nw`Ѕ3>٦lo:)Лz@`Y6P&'r9^yM#ɓ',٭8`뢾7Xv ӂ\V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Μcn9[#tyXs:X4lzgPǺ}Dnָ+[LdRX:zikT6&'Oq7 t%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:32-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s39i3p04.png0000600000175000001440000000076314003056224024140 0ustar rakusersPNG  IHDR''Q5gAMA1_bKGD6IDATX͘[ Cm=-j&Ix\)W ՚Xsa`Nr _4Ʋgs1K04 !;PMTVHxV"d<<[ `'K(ՠ#$T.ius"j40S[hkǞ#tވ Z:bFJ 7[7T2ez(훸:>/ܮNtS@ ,\UFT\mΜcn9[#tyXs:X4lzgPǺ}Dnָ+[LdRX:zikT6&'Oq7 t%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:42-07:00utIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s38n3p04.png0000600000175000001440000000066714003056224024147 0ustar rakusersPNG  IHDR&&=gAMA1_bKGDIDATX EOs{A-nFא rRJKt I# O0 EZ ?C,=+JyPϥcYF9f2TqlIx:VYϿK΍+8Ҵ\;%u$4&zO8Yj-8XK\pkj ܌y>֩)Ėu ֨2Kq?XU0, <ʠ..k4Op˲ WW5q%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:30-07:00.IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s38i3p04.png0000600000175000001440000000066714003056224024142 0ustar rakusersPNG  IHDR&&=gAMA1_bKGDIDATX EOs{A-nFא rRJKt I# O0 EZ ?C,=+JyPϥcYF9f2TqlIx:VYϿK΍+8Ҵ\;%u$4&zO8Yj-8XK\pkj ܌y>֩)Ėu ֨2Kq?XU0, <ʠ..k4Op˲ WW5q%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:40-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s37n3p04.png0000600000175000001440000000073614003056224024143 0ustar rakusersPNG  IHDR%%Ş gAMA1_bKGD!IDATX͗]0 m)wޮSvA~BiVaXCєvV@^sMxhf1t86e d$0CU"4c! ା)Hw8^E `2&G1O¨hM@"2,:hƖ'TT"(Rݷ7tuFYC'Q \vߓ⺩$N>9U(ĔY&^Wb]:w͡-,LYWT|v l\' \%_se s.,%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:30-07:00.IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s37i3p04.png0000600000175000001440000000073614003056224024136 0ustar rakusersPNG  IHDR%%Ş gAMA1_bKGD!IDATX͗]0 m)wޮSvA~BiVaXCєvV@^sMxhf1t86e d$0CU"4c! ା)Hw8^E `2&G1O¨hM@"2,:hƖ'TT"(Rݷ7tuFYC'Q \vߓ⺩$N>9U(ĔY&^Wb]:w͡-,LYWT|v l\' \%_se s.,%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:40-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s36n3p04.png0000600000175000001440000000070014003056224024131 0ustar rakusersPNG  IHDR$$gAMA1_bKGDIDATX]0 ; =@BuGi0B*' $$@*HJMGdz =އ.R0h8+Č5 x@;sLd tNT@y. $rp5PȨnKÀNovZۻ` ʢ(uq핡@X t ^ߠʂO6Hiz_i5@Y\üvS*MwQ@o5p~i~Գ?bV=Sm%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:28-07:00k0IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s36i3p04.png0000600000175000001440000000070014003056224024124 0ustar rakusersPNG  IHDR$$gAMA1_bKGDIDATX]0 ; =@BuGi0B*' $$@*HJMGdz =އ.R0h8+Č5 x@;sLd tNT@y. $rp5PȨnKÀNovZۻ` ʢ(uq핡@X t ^ߠʂO6Hiz_i5@Y\üvS*MwQ@o5p~i~Գ?bV=Sm%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:38-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s35n3p04.png0000600000175000001440000000073514003056224024140 0ustar rakusersPNG  IHDR##ٳYgAMA1_bKGD IDATX͖Q0 CwS{? F쑇  >eعe3c`"YT 2+" )i+nR;=M*&/G7kE/e" jܴ{@hצr%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:28-07:00k0IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s35i3p04.png0000600000175000001440000000073514003056224024133 0ustar rakusersPNG  IHDR##ٳYgAMA1_bKGD IDATX͖Q0 CwS{? F쑇  >eعe3c`"YT 2+" )i+nR;=M*&/G7kE/e" jܴ{@hצr%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:36-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s34n3p04.png0000600000175000001440000000065714003056224024142 0ustar rakusersPNG  IHDR"":G gAMA1_bKGDIDATXQ D; zG *Y5& *zN! @2$!a/<$2a mKQB~k"=aT5tO5yGfm֙@_@ڏ'c`5ednqE8ZU}+cq 'iNE`"4u 7ȉ#2WEqG5N;n<І/wo >I ?Ћi %tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:26-07:00GTmIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s34i3p04.png0000600000175000001440000000065714003056224024135 0ustar rakusersPNG  IHDR"":G gAMA1_bKGDIDATXQ D; zG *Y5& *zN! @2$!a/<$2a mKQB~k"=aT5tO5yGfm֙@_@ڏ'c`5ednqE8ZU}+cq 'iNE`"4u 7ȉ#2WEqG5N;n<І/wo >I ?Ћi %tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:36-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s33n3p04.png0000600000175000001440000000072614003056224024136 0ustar rakusersPNG  IHDR!!WogAMA1_bKGDIDATXWA %̾C jk$c X*\IRS+]LKBp5Bj6"h^qm oCHx_ 1Hwcp~yt$S ta͖ICJ(6zlx"шhˎ2 ';6 6Bke eaĤ)nkC{̎!-s0 ߯Dˤl6+(yϰ#qb1?l͎DHv ÔDPvc7(!#"oYi#G/%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:26-07:00GTmIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s33i3p04.png0000600000175000001440000000072614003056224024131 0ustar rakusersPNG  IHDR!!WogAMA1_bKGDIDATXWA %̾C jk$c X*\IRS+]LKBp5Bj6"h^qm oCHx_ 1Hwcp~yt$S ta͖ICJ(6zlx"шhˎ2 ';6 6Bke eaĤ)nkC{̎!-s0 ߯Dˤl6+(yϰ#qb1?l͎DHv ÔDPvc7(!#"oYi#G/%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:34-07:00aIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s32n3p04.png0000600000175000001440000000067114003056224024134 0ustar rakusersPNG  IHDR szzgAMA1_bKGDIDATXW[ 3p$!7-c@p%HBITȏ، hWE J2?~Ī+#p (.L> ey(ɑ<D;' h. ϒoT.F= QW ֠[L;1ٳ7.$C4N?iN-0EToe,QF*va8fxfՂkƹ u3S7<)?>Hc ^JA%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:24-07:00ˏDIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s32i3p04.png0000600000175000001440000000067114003056224024127 0ustar rakusersPNG  IHDR szzgAMA1_bKGDIDATXW[ 3p$!7-c@p%HBITȏ، hWE J2?~Ī+#p (.L> ey(ɑ<D;' h. ϒoT.F= QW ֠[L;1ٳ7.$C4N?iN-0EToe,QF*va8fxfՂkƹ u3S7<)?>Hc ^JA%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:34-07:00aIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s09n3p02.png0000600000175000001440000000040714003056224024133 0ustar rakusersPNG  IHDR gAMA1_bKGDJIDATӍA ! '˲]92Iq 0hRG]锡g2n`s%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:18-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s09i3p02.png0000600000175000001440000000040714003056224024126 0ustar rakusersPNG  IHDR gAMA1_bKGDJIDATӍA ! '˲]92Iq 0hRG]锡g2n`s%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:22-07:00~IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s08n3p02.png0000600000175000001440000000037714003056224024140 0ustar rakusersPNG  IHDRgAMA1_bKGDBIDATӅI  z5.x($x,ycep֏%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:16-07:00ۙIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s03i3p01.png0000600000175000001440000000033014003056224024112 0ustar rakusersPNG  IHDRV(gAMA1_bKGDIDATcd W@82z~x>%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:20-07:00$WIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s02n3p01.png0000600000175000001440000000032214003056224024117 0ustar rakusersPNG  IHDRr $gAMA1_bKGDIDATcd?- %tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:16-07:00ۙIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s02i3p01.png0000600000175000001440000000032214003056224024112 0ustar rakusersPNG  IHDRr $gAMA1_bKGDIDATcd?- %tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:20-07:00$WIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s01n3p01.png0000600000175000001440000000031214003056224024115 0ustar rakusersPNG  IHDRĉgAMA1_bKGD IDATc``rd%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:16-07:00ۙIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/s01i3p01.png0000600000175000001440000000031214003056224024110 0ustar rakusersPNG  IHDRĉgAMA1_bKGD IDATc``rd%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:18-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/bgwn6a08.png0000600000175000001440000000045214003056224024271 0ustar rakusersPNG  IHDR szzgAMA1_bKGDmIDATX1 0D/LaN?U!-6"1. >x9ug ue wp O wrAJCl@w@<P6@OR +JE%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:58-07:00)IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/bgbn4a08.png0000600000175000001440000000040714003056224024242 0ustar rakusersPNG  IHDR szzgAMA1_bKGDCJIDATXҡ 0E70Xm ^A0pHҾ6sx4DD^}w%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:48-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/bgan6a08.png0000600000175000001440000000045214003056224024243 0ustar rakusersPNG  IHDR szzgAMA1_bKGDmIDATX1 0D/LaN?U!-6"1. >x9ug ue wp O wrAJCl@w@<P6@OR +JE%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:56-07:00MtIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/bgai4a08.png0000600000175000001440000000040714003056224024234 0ustar rakusersPNG  IHDR szzgAMA1_bKGDJIDATXҡ 0E70Xm ^A0pHҾ6sx4DD^}w%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:48-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basn6a08.png0000600000175000001440000000045214003056224024257 0ustar rakusersPNG  IHDR szzgAMA1_bKGDmIDATX1 0D/LaN?U!-6"1. >x9ug ue wp O wrAJCl@w@<P6@OR +JE%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:42-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basn4a08.png0000600000175000001440000000040714003056224024255 0ustar rakusersPNG  IHDR szzgAMA1_bKGDJIDATXҡ 0E70Xm ^A0pHҾ6sx4DD^}w%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:36-07:00d<IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basn3p08.png0000600000175000001440000000060314003056224024271 0ustar rakusersPNG  IHDR szzgAMA1_bKGDIDATX헱0 D(9eB"尀 ߖ:#+u@ޅP~q?/d_q(UPEЎ}nP!7 @l'@|<`mW=C 0'% C(~Q"j,Nh!huQC 6Nk Biyױhkӡ%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:34-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basn3p04.png0000600000175000001440000000051314003056224024265 0ustar rakusersPNG  IHDR szzgAMA1_bKGDIDATX 0 I:KW`bFU*K׆Z';Zs wO%2;st`~=0:sLw@v{љ`(3U3G0xz(3w0l8%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:30-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basn3p02.png0000600000175000001440000000043614003056224024267 0ustar rakusersPNG  IHDR szzgAMA1_bKGDaIDATXA 0'jsǖlK61`@8R~܁ȱo;3ŏԏ;P}h( <'Ч%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:30-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basn3p01.png0000600000175000001440000000042114003056224024260 0ustar rakusersPNG  IHDR szzgAMA1_bKGDTIDATXc|_?0Ie83SL  F% :<F8Zx-F0Z:`uh90[jb%T%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:30-07:00IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basn2c08.png0000600000175000001440000000042214003056224024252 0ustar rakusersPNG  IHDR szzgAMA1_bKGDUIDATXԱ 0 A+m) <@BZdkH(g Ly|n\_νzY^%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:26-07:00SIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basn0g08.png0000600000175000001440000000044514003056224024261 0ustar rakusersPNG  IHDR szzgAMA1_bKGDhIDATXֱ ! @1B?b(/\5NLEk-r 0$UUPM{˖`/sbHl`s$1|oAD`1{. d# T%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:20-07:00FiIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basn0g04.png0000600000175000001440000000037414003056224024256 0ustar rakusersPNG  IHDR szzgAMA1_bKGD?IDATXұ AX  -sHsy<h@4p$j h%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:18-07:00v&IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basn0g02.png0000600000175000001440000000043314003056224024250 0ustar rakusersPNG  IHDR szzgAMA1_bKGD^IDATXK 0DgJbm6!XRvW}?՚'@sFk85g87o%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:18-07:00v&IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basn0g01.png0000600000175000001440000000060714003056224024252 0ustar rakusersPNG  IHDR szzgAMA1_bKGDIDATXŗA@UzqL5%(:DI8|$nۢSo|Zkz7{3b8Wsj =_kZ6PT 8|[6x9ug ue wp O wrAJCl@w@<P6@OR +JE%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:12-07:00=IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basi4a08.png0000600000175000001440000000040714003056224024250 0ustar rakusersPNG  IHDR szzgAMA1_bKGDJIDATXҡ 0E70Xm ^A0pHҾ6sx4DD^}w%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:04-07:009IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basi3p08.png0000600000175000001440000000060314003056224024264 0ustar rakusersPNG  IHDR szzgAMA1_bKGDIDATX헱0 D(9eB"尀 ߖ:#+u@ޅP~q?/d_q(UPEЎ}nP!7 @l'@|<`mW=C 0'% C(~Q"j,Nh!huQC 6Nk Biyױhkӡ%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:03:02-07:00>IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basi3p04.png0000600000175000001440000000051314003056224024260 0ustar rakusersPNG  IHDR szzgAMA1_bKGDIDATX 0 I:KW`bFU*K׆Z';Zs wO%2;st`~=0:sLw@v{љ`(3U3G0xz(3w0l8%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:58-07:00lIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basi3p02.png0000600000175000001440000000043614003056224024262 0ustar rakusersPNG  IHDR szzgAMA1_bKGDaIDATXA 0'jsǖlK61`@8R~܁ȱo;3ŏԏ;P}h( <'Ч%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:58-07:00lIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basi3p01.png0000600000175000001440000000042114003056224024253 0ustar rakusersPNG  IHDR szzgAMA1_bKGDTIDATXc|_?0Ie83SL  F% :<F8Zx-F0Z:`uh90[jb%T%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:58-07:00lIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basi2c08.png0000600000175000001440000000042214003056224024245 0ustar rakusersPNG  IHDR szzgAMA1_bKGDUIDATXԱ 0 A+m) <@BZdkH(g Ly|n\_νzY^%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:54-07:005cIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basi0g08.png0000600000175000001440000000044514003056224024254 0ustar rakusersPNG  IHDR szzgAMA1_bKGDhIDATXֱ ! @1B?b(/\5NLEk-r 0$UUPM{˖`/sbHl`s$1|oAD`1{. d# T%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:48-07:00>ƇIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basi0g04.png0000600000175000001440000000037414003056224024251 0ustar rakusersPNG  IHDR szzgAMA1_bKGD?IDATXұ AX  -sHsy<h@4p$j h%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:48-07:00>ƇIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basi0g02.png0000600000175000001440000000043314003056224024243 0ustar rakusersPNG  IHDR szzgAMA1_bKGD^IDATXK 0DgJbm6!XRvW}?՚'@sFk85g87o%tEXtdate:create2014-12-13T23:09:12-08:00q %%tEXtdate:modify1998-04-05T22:02:46-07:00nIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary_check/basi0g01.png0000600000175000001440000000060714003056224024245 0ustar rakusersPNG  IHDR szzgAMA1_bKGDIDATXŗA@UzqL5%(:DI8|$nۢSo|Zkz7{3b8Wsj =_kZ6PT 8|[6W$n(8yKr-"ˡ %PzPE:wNh~uJLН#uOE" m(t:][ZWXtF]]Tҗ^}@'#si" |A~UUNnIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/z06n2c08.png0000600000175000001440000000034014003056224022766 0ustar rakusersPNG  IHDR IDATxK Кv1~a>W$n(8yKr-"ˡ %PzPE:wNh~uJLН#uOE" m(t:][ZWXtF]]Tҗ^}@'#si" |A~UUNn1R,IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/z03n2c08.png0000600000175000001440000000035014003056224022764 0ustar rakusersPNG  IHDR IDATx^@0 J\l" [ןED=SJSf^տ> xЀ(9CNщ֠ .Gtx_AC:$%tgcݳ"n]ZWXtyF]؁]ȥ:Й1zd\ROx DWUNnCIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/z00n2c08.png0000600000175000001440000000614414003056224022770 0ustar rakusersPNG  IHDR  +IDATx                                                                                                                 UNnIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/tp1n3p08.png0000600000175000001440000000271314003056224023077 0ustar rakusersPNG  IHDR DgAMA1_PLTEVVBB Y))V.. xuu}}}{{{yyy77VwwwuuusssHHdbVV((|SSgggeee]m]&&o--DDaaa;;DD==YYYWWWUUUSSS44QQQ$$OOO::A-w-h{ k111*@ ̓** kkx>>m VFFHAAMs]]Qvvx~~~~~|||zzzJJvvvtttrrrpppnnnjpjzffjjjDDKKadabbb88\\\ZZZ]BxBVVV..GhG11`RRRPPP!!mLLLokkHHH4f4SS`OO44odVYdNNk{A!!YWWYDDx--T `}}%tRNS@fIDAT8c`2x* =fO,|*^ʴMoU_"PejVi\)}ãu]c`1Y>_[+f@|ޓ5:9k2 *kkߒ{&ĉg`}X }Yohii3ם=[Wd~=XA|35P-O܃a5[~0tz'9C]9+i|Sd@FAQ- EGl-x֖K>j3: $&:_d.Owόw۴Āh˦Oҵtg]S5aɴƕN"ͲŽ^ e{rM~9ٻ px43 rwXS}o6Ry găw'ؼen.GLA;!wn!zccg^{ăayx' o-:&kP v[ o9p }Y|cA~)ӟq0$k% *Fqs<-If3T`,&cS BC n%:1䁠|[Ȣkyibg`5lS]'{y6pJf IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/tp0n3p08.png0000600000175000001440000000270414003056224023076 0ustar rakusersPNG  IHDR DgAMA1_PLTEmVVBB Y))V.. xuu}}}{{{yyy77VwwwuuusssHHdbVV((|SSgggeee]m]&&o--DDaaa;;DD==YYYWWWUUUSSS44QQQ$$OOO::A-w-h{ k111*@ ̓** kkx>>m VFFHAAMs]]Qvvx~~~~~|||z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O|z`FYD^PaJ|BBBG ~-NNNL ,83TFHRTDaJP?1TG@@Z|ӖP_m#Y_[l+-[RQѝo^ {x#=0`_lhmK ڎ,MH=SOA`FQc]IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/tm3n3p02.png0000600000175000001440000000016414003056224023066 0ustar rakusersPNG  IHDR g PLTECtRNSU '9IDATx^cdP ,U+a3.AIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/tbyn3p08.png0000600000175000001440000000273314003056224023173 0ustar rakusersPNG  IHDR DgAMA1_PLTEVVBB Y))V.. xuu}}}{{{yyy77VwwwuuusssHHdbVV((|SSgggeee]m]&&o--DDaaa;;DD==YYYWWWUUUSSS44QQQ$$OOO::A-w-h{ k111*@ ̓** kkx>>m VFFHAAMs]]Qvvx~~~~~|||zzzJJvvvtttrrrpppnnnjpjzffjjjDDKKadabbb88\\\ZZZ]BxBVVV..GhG11`RRRPPP!!mLLLokkHHH4f4SS`OO44odVYdNNk{A!!YWWYDDx--T `}}2tRNS@fbKGDEIDAT8c`2x* =fO,|*^ʴMoU_"PejVi\)}ãu]c`1Y>_[+f@|ޓ5:9k2 *kkߒ{&ĉg`}X }Yohii3ם=[Wd~=XA|35P-O܃a5[~0tz'9C]9+i|Sd@FAQ- EGl-x֖K>j3: $&:_d.Owόw۴Āh˦Oҵtg]S5aɴƕN"ͲŽ^ e{rM~9ٻ px43 rwXS}o6Ry găw'ؼen.GLA;!wn!zccg^{ăayx' o-:&kP v[ o9p }Y|cA~)ӟq0$k% *Fqs<-If3T`,&cS BC n%:1䁠|[Ȣkyibg`5lS]'{y6pJf IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/tbwn3p08.png0000600000175000001440000000273014003056224023166 0ustar rakusersPNG  IHDR DgAMA1_PLTEVVBB Y))V.. xuu}}}{{{yyy77VwwwuuusssHHdbVV((|SSgggeee]m]&&o--DDaaa;;DD==YYYWWWUUUSSS44QQQ$$OOO::A-w-h{ k111*@ ̓** kkx>>m VFFHAAMs]]Qvvx~~~~~|||zzzJJvvvtttrrrpppnnnjpjzffjjjDDKKadabbb88\\\ZZZ]BxBVVV..GhG11`RRRPPP!!mLLLokkHHH4f4SS`OO44odVYdNNk{A!!YWWYDDx--T `}}%tRNS@fbKGDHIDAT8c`2x* =fO,|*^ʴMoU_"PejVi\)}ãu]c`1Y>_[+f@|ޓ5:9k2 *kkߒ{&ĉg`}X }Yohii3ם=[Wd~=XA|35P-O܃a5[~0tz'9C]9+i|Sd@FAQ- EGl-x֖K>j3: $&:_d.Owόw۴Āh˦Oҵtg]S5aɴƕN"ͲŽ^ e{rM~9ٻ px43 rwXS}o6Ry găw'ؼen.GLA;!wn!zccg^{ăayx' o-:&kP v[ o9p }Y|cA~)ӟq0$k% *Fqs<-If3T`,&cS BC n%:1䁠|[Ȣkyibg`5lS]'{y6pJf IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/tbrn2c08.png0000600000175000001440000000314114003056224023140 0ustar rakusersPNG  IHDR gAMA1_tRNS7X}bKGD3'|IDATH͖ LwǿRl0E h D)P)A""`ӉW)!A se"0e!fL4sNi|kɖ b6]B({?̾apΝp޽X4G=Z탑͍Ruu33* K|RSSSW^-++_Hٵ+{2ix.7Aby˖lllxaGf;:p8Y &ɷPۧg@!Hbcc uʝ>>ځs\nmbe!60G~(rMEGGS**'''33355Uan~Jw$))/P(Zv[W.w씝]jP9p}rQRBQbݻt9SlfWuĉ QwL&s- tQ^^s5` vyqq1REEEiiivvTlv {.14G51ZMTR8 73vwk:FrS2UIS!ꃯtTTWW@Eu'T͛O5#w,,rpRPSvAMprrr=xf .e.>%AD.GPFFq..w\)II&qrEw *!*MPĠ%@pNi[[40LAmIÀ7o)tTxkkB]_U@T"cdrq Vlhca͚W>*T`8J|SbJbPvLׇA)ci8==m@+~OӶ288L E=E{ZtA3$x {f<>ptnnOƏ rZ> \n p2*^ o\oL]}44  \cdt31 ^ 9`Xxt~ !HhA:(J/>m VFFHAAMs]]Qvvx~~~~~|||zzzJJvvvtttrrrpppnnnjpjzffjjjDDKKadabbb88\\\ZZZ]BxBVVV..GhG11`RRRPPP!!mLLLokkHHH4f4SS`OO44odVYdNNk{A!!YWWYDDx--T `}}xe=5tRNS@fbKGDEIDAT8c`2x* =fO,|*^ʴMoU_"PejVi\)}ãu]c`1Y>_[+f@|ޓ5:9k2 *kkߒ{&ĉg`}X }Yohii3ם=[Wd~=XA|35P-O܃a5[~0tz'9C]9+i|Sd@FAQ- EGl-x֖K>j3: $&:_d.Owόw۴Āh˦Oҵtg]S5aɴƕN"ͲŽ^ e{rM~9ٻ px43 rwXS}o6Ry găw'ؼen.GLA;!wn!zccg^{ăayx' o-:&kP v[ o9p }Y|cA~)ӟq0$k% *Fqs<-If3T`,&cS BC n%:1䁠|[Ȣkyibg`5lS]'{y6pJf IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/tbbn3p08.png0000600000175000001440000000273314003056224023144 0ustar rakusersPNG  IHDR DgAMA1_PLTEVVBB Y))V.. xuu}}}{{{yyy77VwwwuuusssHHdbVV((|SSgggeee]m]&&o--DDaaa;;DD==YYYWWWUUUSSS44QQQ$$OOO::A-w-h{ k111*@ ̓** kkx>>m VFFHAAMs]]Qvvx~~~~~|||zzzJJvvvtttrrrpppnnnjpjzffjjjDDKKadabbb88\\\ZZZ]BxBVVV..GhG11`RRRPPP!!mLLLokkHHH4f4SS`OO44odVYdNNk{A!!YWWYDDx--T `}}atRNS@fbKGDEIDAT8c`2x* =fO,|*^ʴMoU_"PejVi\)}ãu]c`1Y>_[+f@|ޓ5:9k2 *kkߒ{&ĉg`}X }Yohii3ם=[Wd~=XA|35P-O܃a5[~0tz'9C]9+i|Sd@FAQ- EGl-x֖K>j3: $&:_d.Owόw۴Āh˦Oҵtg]S5aɴƕN"ͲŽ^ e{rM~9ٻ px43 rwXS}o6Ry găw'ؼen.GLA;!wn!zccg^{ăayx' o-:&kP v[ o9p }Y|cA~)ӟq0$k% *Fqs<-If3T`,&cS BC n%:1䁠|[Ȣkyibg`5lS]'{y6pJf IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/tbbn0g04.png0000600000175000001440000000065514003056224023125 0ustar rakusersPNG  IHDR )gAMA1_tRNS,ЩbKGD#2HIDAT(u1O@q>GYL\$.&&K[,B&`r%$.28j]mHxw^:x-ArO+ ђY3Hjdcs&Amv{`ěeV,\MV[*MIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s40n3p04.png0000600000175000001440000000040014003056224022764 0ustar rakusersPNG  IHDR((~Х^gAMA1_sBITw'PLTEwwwwww;uIDATxб 0 DC,!alE6H%2EHVNRbG@!FeQk7^ Bؚp877*,mWBMwG)Rc!wu'gWpH])IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s40i3p04.png0000600000175000001440000000054514003056224022771 0ustar rakusersPNG  IHDR(( וgAMA1_sBITw'PLTEwwwwww;IDATx 0EZk]dRPN7upqg'B YP1BCᐼ<DZrQeA|$`O sc#WLYDOLILȾ{aWvD( cNٮaXDCapl5pQDV @"$֓I#U&!AHt xnR=͈ki^ jNp{xIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s39n3p04.png0000600000175000001440000000054014003056224023001 0ustar rakusersPNG  IHDR''~LgAMA1_sBITw'PLTEwwwwww;IDATxm!@GHzp 8,šW1CufICgf`2(6 'Zж =E'̪ 'QuEyJڟd0`7~mdUg/C>d(U>ѱb'LWtec+`:4nh7zob/ Ǫ O/5+IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s39i3p04.png0000600000175000001440000000064414003056224023001 0ustar rakusersPNG  IHDR'' |gAMA1_sBITw'PLTEwwwwww;IDATxm1r0EǓ N."pʵ;ZJnQS:TV1/{f3T` Di@QhjZjvJJ85=P*0 zS`9!T5k=- K#<͚_.ܥ?Nubo&8:/G„"L,B MǔvkNhy>xxppWpX9çe(wx:Ι4e5߹?N|.@ny 5 IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s38n3p04.png0000600000175000001440000000036514003056224023005 0ustar rakusersPNG  IHDR&&ZgAMA1_sBITw'PLTEwwwwww;jIDATxc`eG`$61 !fpCCl* L1lvX*`q*b 0h-܌81 bhb)`@da1-i+άDIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s38i3p04.png0000600000175000001440000000054514003056224023000 0ustar rakusersPNG  IHDR&&- gAMA1_sBITw'PLTEwwwwww;IDATx? @XA_EZF6i4475 :E@Hީn#9SЎOQbdTw)q!o;s+;qZIc|jb[P4i|aljƕAn6 S4zg4Xn8m uM/$yC;+|<ױ;^y}kvob땗){zB|DyEIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s37n3p04.png0000600000175000001440000000052014003056224022775 0ustar rakusersPNG  IHDR%%7=0gAMA1_sBITw'PLTEwwwwww;IDATxe-@/M' '؄ z Vp)3x3@|Iz#S<#u*dUa02qEKϾ,27Fxlj<ɹ)Pz?KwWs:kPѤW2 -W]s' jeG KޭۯG|QV IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s37i3p04.png0000600000175000001440000000061114003056224022771 0ustar rakusersPNG  IHDR%%@ gAMA1_sBITw'PLTEwwwwww;IDATxe;0Q NL.`h쭨hSRڥr(70̲˷`FCj} |n(`,,䜖jK)#)(8n P M$0 6!a?ؑ\Zs!*V}6nJ_Dؐ w9)/ggL x q%x \r/Rx [JsFNk-8F߮Rz'#?IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s36n3p04.png0000600000175000001440000000040214003056224022773 0ustar rakusersPNG  IHDR$$.gAMA1_sBITw'PLTEwwwwww;wIDATxc`eG$! .dp]]h*t !,[*`:B,!,Bl7݅,NEPWB BB Є$BB62`XoIӑIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s36i3p04.png0000600000175000001440000000054414003056224022775 0ustar rakusersPNG  IHDR$$d)=gAMA1_sBITw'PLTEwwwwww;IDATx 0F?ӷ"]IQv iwqpvrTjbMI xA(;ވVLIFqxfSB0'zWs%Ñm rtȁ \Ap9*e} u} GT_`-U$ڪz3Q?, 0h+8郱oe(8Eb_zةj ,a*muuZ9?.IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s35n3p04.png0000600000175000001440000000052214003056224022775 0ustar rakusersPNG  IHDR##jgAMA1_sBITw'PLTEwwwwww;IDATxe!@״p иJ,{>a3Fު`Y\Ռ:T4b2(h%sn݆oEd=d2ܙBcF5μWhQd *F&Ny7zAwe\/x7rL#"ckLiq6>G΢HIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s35i3p04.png0000600000175000001440000000061714003056224022775 0ustar rakusersPNG  IHDR##gAMA1_sBITw'PLTEwwwwww;IDATxe=PQv@Xـ  zs;&}!rBї 8ycec:1 4;0'9]L(PFڄ唪*1j1-FtH?׹HD"nƮMM;-ww+T0q=މ^fBu/ep cA%q)uMa8VFL`?Ha; L[ΉqЊiIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s34n3p04.png0000600000175000001440000000037014003056224022775 0ustar rakusersPNG  IHDR""igAMA1_sBITw'PLTEwwwwww;mIDATxϱ _ [2г0&G+.%:r*Hv4,$ĂY49n2=xNNm'c)*+ TxVR,v5H\-Y~H:+NIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s34i3p04.png0000600000175000001440000000053514003056224022773 0ustar rakusersPNG  IHDR""n&ggAMA1_sBITw'PLTEwwwwww;IDATx} 0Fj[tdAk[]:8;9 jD{- q>oĻ$`*1sPxKE= "aXIDo-MBC:e֖)Zir450NRk[]IldnaȕGR[_{Q_E6bp&],P]I4?t3P]jP33/2Z߈)IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s33n3p04.png0000600000175000001440000000051114003056224022771 0ustar rakusersPNG  IHDR!!\gAMA1_sBITw'PLTEwwwwww;IDATx]- W7pp ]WFp- +ƒ|Jop .[+j1Oe ]lD78Z;W갮kLWă⑻E=qx6U3QkT.:])T:IpPM#I?xxIJAhjW :M\ɩ]3b֓1%IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s33i3p04.png0000600000175000001440000000060114003056224022764 0ustar rakusersPNG  IHDR!!gAMA1_sBITw'PLTEwwwwww;IDATx]1r0E?0(xFHܸSKε+4>y˒Vo 4Ĺp:4a`5$9k L~FQZ #J3^K?Z]T4Z?&ikEJ 3) ]aVYEh-=& r%@=E"t6;s2 q2wzE¥0l%=!޲Z;7R҄#IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s09n3p02.png0000600000175000001440000000021714003056224022775 0ustar rakusersPNG  IHDR gAMA1_sBITw PLTEwwVdIDATxc` V,XB q iejC#IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s09i3p02.png0000600000175000001440000000022314003056224022765 0ustar rakusersPNG  IHDR gAMA1_sBITw PLTEwwVd#IDATxc`@ X ^3\b  duFIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s08n3p02.png0000600000175000001440000000021314003056224022770 0ustar rakusersPNG  IHDRaVgAMA1_sBITw PLTEwwYIDATxc```ZA =V=LIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s08i3p02.png0000600000175000001440000000022514003056224022766 0ustar rakusersPNG  IHDRffgAMA1_sBITw PLTEwwY%IDATxc` ~`Ǡ0aXAAPPpJIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s07n3p02.png0000600000175000001440000000021214003056224022766 0ustar rakusersPNG  IHDR<@gAMA1_sBITw PLTEwwCIDATxcj í9 7H qy ]mIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s07i3p02.png0000600000175000001440000000022514003056224022765 0ustar rakusersPNG  IHDR;gAMA1_sBITw PLTEwwC%IDATxc8p 3aH? Wcn UIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s06n3p02.png0000600000175000001440000000020314003056224022765 0ustar rakusersPNG  IHDRgAMA1_sBITw PLTEwEhIDATxcXaj02V-9_)pIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s06i3p02.png0000600000175000001440000000021714003056224022765 0ustar rakusersPNG  IHDR7MgAMA1_sBITw PLTEwEh"IDATxch`h` - +<"&0LH`XYLe$IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s05n3p02.png0000600000175000001440000000020114003056224022762 0ustar rakusersPNG  IHDRvgAMA1_sBITw PLTEwAsIDATxcX0a"\*JIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s05i3p02.png0000600000175000001440000000020614003056224022762 0ustar rakusersPNG  IHDRgAMA1_sBITw PLTEwAsIDATxch`h`X";tOm"Mp$FEIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s04n3p01.png0000600000175000001440000000017114003056224022766 0ustar rakusersPNG  IHDR? =gAMA1_sBITwPLTEwCIDATxc0?  IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s04i3p01.png0000600000175000001440000000017614003056224022766 0ustar rakusersPNG  IHDR8<gAMA1_sBITwPLTEwCIDATxch`  >7IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s03n3p01.png0000600000175000001440000000017014003056224022764 0ustar rakusersPNG  IHDRl'gAMA1_sBITwPLTEw奟IDATxc``p``A91 KIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s03i3p01.png0000600000175000001440000000016614003056224022764 0ustar rakusersPNG  IHDRjgAMA1_sBITwPLTEw奟 IDATxc`LAIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s02n3p01.png0000600000175000001440000000016314003056224022765 0ustar rakusersPNG  IHDRHxggAMA1_sBITwPLTE\/% IDATxc```8UIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s02i3p01.png0000600000175000001440000000016214003056224022757 0ustar rakusersPNG  IHDR?gAMA1_sBITwPLTE\/% IDATxc`gIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s01n3p01.png0000600000175000001440000000016114003056224022762 0ustar rakusersPNG  IHDR%VgAMA1_sBITwPLTExW IDATxc`HqIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/s01i3p01.png0000600000175000001440000000016114003056224022755 0ustar rakusersPNG  IHDRRf\gAMA1_sBITwPLTExW IDATxc`HqIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/bgwn6a08.png0000600000175000001440000000031214003056224023127 0ustar rakusersPNG  IHDR szzgAMA1_bKGDoIDATx1 0 F'dhO?U!ExRP(M(ي0^{~3uG XN5"}\TB\.y 6{@<P6@R LIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/bgbn4a08.png0000600000175000001440000000021414003056224023101 0ustar rakusersPNG  IHDR sgAMA1_bKGD#25IDATxch41",(,?a0T1`4GÀ*hP* }IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/bgan6a08.png0000600000175000001440000000027014003056224023104 0ustar rakusersPNG  IHDR szzgAMA1_oIDATx1 0 F'dhO?U!ExRP(M(ي0^{~3uG XN5"}\TB\.y 6{@<P6@R LIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/bgai4a08.png0000600000175000001440000000032614003056224023077 0ustar rakusersPNG  IHDR tgAMA1_IDATx 0 ֽA((sOAVG":ݙbH$ @ɾzM2x<7U[0t<n!Y~.,>RfqXAh٪wϤ50o0N N6 O= YU]IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basn6a08.png0000600000175000001440000000027014003056224023120 0ustar rakusersPNG  IHDR szzgAMA1_oIDATx1 0 F'dhO?U!ExRP(M(ي0^{~3uG XN5"}\TB\.y 6{@<P6@R LIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basn4a08.png0000600000175000001440000000017614003056224023123 0ustar rakusersPNG  IHDR sgAMA1_5IDATxch41",(,?a0T1`4GÀ*hP* }IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basn3p08.png0000600000175000001440000000240614003056224023137 0ustar rakusersPNG  IHDR DgAMA1_PLTE"Dww :w""""Uffff"DDUU"DDUU3DDff3D"ffD33U*D˺[""f2Ucw:DDkfBkܺ33sJw{"w332fDwJf""UUDff3UwwDwffD"w"3333cU3{UUUUf܃wwUUww""DD3ԪU*U˴f3BSD̙"Sww333Ĉwff""UU"DD[wfwws33wD""U"f 3bIDATx GHd+;3 ekXegа**4h lޣY2W%syiHCL*;8"KE6sx'HK?Y9sģ>1~!'B 0IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basn3p04.png0000600000175000001440000000033014003056224023125 0ustar rakusersPNG  IHDR TggAMA1_sBITw-PLTE""fwDDҰIGIDATxc =sfժrcwfd C+(H*ŅTݻq@*)#MK#G{7}IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basn3p02.png0000600000175000001440000000022214003056224023123 0ustar rakusersPNG  IHDR ggAMA1_sBIT|.w PLTEe?+"IDATxc0,| =IꉎIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basn3p01.png0000600000175000001440000000016014003056224023123 0ustar rakusersPNG  IHDR IgAMA1_PLTE""fl&IDATxc4?fYIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basn2c08.png0000600000175000001440000000022114003056224023112 0ustar rakusersPNG  IHDR gAMA1_HIDATx 0 @r;D++ ; }Lx@J„(t8#@pw^@KIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basn0g08.png0000600000175000001440000000021214003056224023114 0ustar rakusersPNG  IHDR V%(gAMA1_AIDATxcd`$ȳ )?`y00gdy\ q10edPq5YIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basn0g04.png0000600000175000001440000000022114003056224023110 0ustar rakusersPNG  IHDR )gAMA1_HIDATxc``TR26vq MK+/g CA*wLrPV#ݽT3r%GAIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basn0g02.png0000600000175000001440000000015014003056224023107 0ustar rakusersPNG  IHDR =gAMA1_IDATxc`]0PS3 cI IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basn0g01.png0000600000175000001440000000024414003056224023112 0ustar rakusersPNG  IHDR [GYgAMA1_[IDATx-̱ 0 J z4o< aEQ/ҤlΩ%SS4W!K&=Bs%%^ڲoj0i.)ano0eI//IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basi6a08.png0000600000175000001440000000055114003056224023115 0ustar rakusersPNG  IHDR }JbgAMA1_ IDATxŕAN0EAfAME*q *e@ՔAHɊ|?'dG` 9c:1Ⓣ{=k ֵS˰gc. 3{_m /N @-~'.lM1! jѠ D h=F`u@]`^-^%x zRhb!9:XF/h.䋱 lY PtP΀W(3mYm πu(ש P:JSiNsBIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basi4a08.png0000600000175000001440000000032614003056224023113 0ustar rakusersPNG  IHDR tgAMA1_IDATx 0 ֽA((sOAVG":ݙbH$ @ɾzM2x<7U[0t<n!Y~.,>RfqXAh٪wϤ50o0N N6 O= YU]IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basi3p08.png0000600000175000001440000000276714003056224023144 0ustar rakusersPNG  IHDR 3PgAMA1_PLTE"Dww :w""""Uffff"DDUU"DDUU3DDff3D"ffD33U*D˺[""f2Ucw:DDkfBkܺ33sJw{"w332fDwJf""UUDff3UwwDwffD"w"3333cU3{UUUUf܃wwUUww""DD3ԪU*U˴f3BSD̙"Sww333Ĉwff""UU"DD[wfwws33wD""U"f 3bIDATxei\ 7JMc))IDXQaѡ29s%"B!W*M%:9Z<}RE4XL1M.5#\HmP!BzԞ]Be&hAViڍ5Fױ{Y.L؛# 0Mun`7%RYH5!C33;;׷522%JK *+}|ظյ()JJHY'00/OI),LW7< sr::mm)>>&&*JNBKK_22x< 0: fiAޞ]\"rqa2|ۛdkj&&zz֦v 05MMuvnh`0TTd9:ƆFDȶmn%53 ke(/^S#Av/#,0 '0N5X S vc0jXw`  p>U0 N x!<۰ .^ nZs` z\?0! oa<~Np&023 0 tx C8, `#G0srIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basi3p04.png0000600000175000001440000000050714003056224023126 0ustar rakusersPNG  IHDR SWQgAMA1_sBITw-PLTE""fwDDҰIIDATxcc8N%(KS,1,ľ @ _B$ ,qP=L(-]]tލ0@L1 RL1pOGh3V{7s&*WPS)ʽ{Sˀ)UR@妥a rwvh t_IENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basi3p02.png0000600000175000001440000000030114003056224023114 0ustar rakusersPNG  IHDR ygAMA1_sBIT|.w PLTEe?+QIDATxcxǰ]̌!9J޸b.??dCH dJHR?t#B,*9Z}uIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basi3p01.png0000600000175000001440000000020414003056224023115 0ustar rakusersPNG  IHDR >!gAMA1_PLTE""fl&)IDATxc`P CѰ1Ù3IH6?@@!( B-vÞIENDB`uTox/third_party/stb/stb/tests/pngsuite/primary/basi2c08.png0000600000175000001440000000047314003056224023116 0ustar rakusersPNG  IHDR 5gAMA1_IDATxՓA! D{x=Ys3hhf gZYd1b|V%}֠Ɯ7~gv>^/-Jcm smXTmcm @x!Kܦ$]!2,$UIBH"*V$$ŏ Jl, lܲ 9:eSW}q@Şp쿣;_|?/ 92ujQQμI tk7ej-9tHQjK ῸO58mcCN,m&ld[ gVWmez՞W\\V6{# 8s͘Ąڤ9w51NYμR(ʚ5 n;--.ʢ5p XoQUI7!11AA{ xݳ/(+KN y nMIW*l&ܘ<TAeeVVx8Hgd$J,tue^)2k`"Vyzp#$d/ɬ X,侾dn A8t$9$8hѓl#={$ヒ}7z7&R'I.d;xEKjdN p/-ľ}ٳBNMƶDxs;VL?JpX-Ē%v% ͘TxJ^/ {> _TG`!B|qqBzmT;5G8 Nr?X /k]gpELxd\yok04@WĪD!z ٿʐ<X+$ښCxO#bbBӄ7m݌5!¯)/}޾F$Vi-0LD Yw,DY q W aIENDB`uTox/third_party/stb/stb/tests/pngsuite/16bit/tbbn2c16.png0000600000175000001440000000377114003056224022372 0ustar rakusersPNG  IHDR 1gAMA1_tRNSK2bKGDGeIDATX LeG0nL$QbSbe#v<\" LTºRZ e79N4:qd:f 1fDs6YPA;X 9M6 |M:R@JJuuw[ؘ ;6.\r'("b2dqVUUxlhcgz{LMM_<'pC< TU=n^/ݍAb2k`"Vyzp#$d/ɬ X,侾dn A8t$9$8hѓl#={$ヒ}7z7&R'I.d;xEKjdN p/-ľ}ٳBNMƶDxs;VL?JpX-Ē%v% ͘TxJ^/ {> _TG`!B|qqBzmT;5G8 Nr?X /k]gpELxd\yok04@WĪD!z ٿʐ<X+$ښCxO#bbBӄ7m݌5!¯)/}޾F$Vi-0LD Yw,DY q W aIENDB`uTox/third_party/stb/stb/tests/pngsuite/16bit/oi9n2c16.png0000600000175000001440000000573614003056224022326 0ustar rakusersPNG  IHDR 1gAMA1_IDATxvIDATсIDATށ[IDAT1TKIDAT[IDAT IDAT\rIDAT0MDIDAT5mIDATDYaIDAT`KIDAT2IDATA) IDATEIDAT$fIDAT~!IDAT}=[IDAT4IIDAT_IDAT|*IDAT1TKIDAT7@IDAT[IDAT1,RIDAT69IDAT,[IDAT&5IDATf鹅IDATA>IDAT̺sIDATzIDAT;TIDAT,[IDATE.IDAT_[IDAT=pP1IDATG IDATIDATU?YIDAT5mIDATB]TIDAT(8}IDAT>Y`CIDAT/@IDAT2IDAT8IDATIDATdbةIDATr3mIDATs4]nIDAT~!IDAT;TIDAT=pP1IDAT'2ȃIDAT3IDAT_1IDATT_IDATf<IDAT NIDATZIDATwYwIDAT}=[IDAT6IDATFIDATT_IDATtPIDAT(IDATpx= IDAT,IDAT3IDATFS{IDAT NIDAT-IDAT{IDATpx= IDAT]=PIDAT쟪IDAT_?M~IDAT`eIDAT NIDAT WHIDAT^IDAT_1IDATIDAT쁄ӻIDAT{IDAT6IDATypIDATtPIDAT{5IDATYdIDAT\XIDAT?^PIDATtPIDAT{5IDAT_[IDATLS(IDAT(IDATCmIDATV 3IDAT\J`7IDATll1IDAT(8}IDAT :kQIDATgIDATV 3IDAT VUIDATKIDATDYaIDATgIDATIDAT&5IDATЮ<IDAT0pIDATIDATO7$IDAT\XIDAT(IDATKIDAT(IDAT`eIDAT WIDATK>1IDAT;TIDATRR'@IDATT_IDATWV|IDAT1uIDAT6qIDAT0MDIDAT1,RIDATIDATIDATY:IDAT`eIDAT7@IDATzIDATzPIDAT\XIDATllIDATzIDAT2⩕IDATȽ7jIDATH=IDAT_?M~IDATm;` IDATtPIDATT_IDAT3IDAT]IDAT𕅏IDATŀIDATT_IDAT?ëIDAT&IDAT^IDATA) IDATO[!IDAT/UIDATOIDATIDAT3IDATsIDATaQ:IDATB]TIDATr=IDAT^IENDB`uTox/third_party/stb/stb/tests/pngsuite/16bit/oi9n0g16.png0000600000175000001440000000240314003056224022314 0ustar rakusersPNG  IHDR kgAMA1_IDATxvIDATсIDATށ[IDAT@IDAT1y}IDAT IDAT\XIDAT0MDIDAT !1IDATCmIDATQ4TIDAT9w=IDAT[ԁIDATIDATEIDATZ?mIDATܧ]IDATIDATA>IDAT\XIDAT(IDAT{\IDAT2,hIDATށ[IDAT*>IDAT/UIDATg珺IDAT7IDATU?YIDAT?^PIDAT8:vIDATŀIDAT`KIDATFVIDATW7IDAT<6IDAT<6IDATcM IDATIDAT:4ZIDAT+IDAT`eIDATK>1IDAT&IDATVIDAT(8}IDATZӁIDAT+IDAT|*IDAT@^/drs~='3_Zwt(p3p]`_yt?t(CnTZXIDAT\l52L̩g I@gecIDAT.`(`g Dg&((`60Y`zl(P49܀:{z*zȟmt3ΞAO3B )IDAT^z zIENDB`uTox/third_party/stb/stb/tests/pngsuite/16bit/oi4n0g16.png0000600000175000001440000000031314003056224022305 0ustar rakusersPNG  IHDR kgAMA1_IDATx1 0 CQ9[ܠ({2*ُ?8mIDATWc:`݂@B&@=ΣIDAT2mf IDAT -hL`?oO8K_z_}IENDB`uTox/third_party/stb/stb/tests/pngsuite/16bit/oi2n2c16.png0000600000175000001440000000047214003056224022307 0ustar rakusersPNG  IHDR 1gAMA1_IDATxՖ 0DA~&fzE=֠B>/drs~='3_Zwt(p3p]`_yt?t(C\l52L̩g I@gseIDAT.`(`g Dg&((`60Y`zl(P49܀:{z*zȟmt3ΞAO3B^MwbIENDB`uTox/third_party/stb/stb/tests/pngsuite/16bit/oi2n0g16.png0000600000175000001440000000026314003056224022307 0ustar rakusersPNG  IHDR kgAMA1_@IDATx1 0 CQ9[ܠ({2*ُ?8Wc:`݂@B&@=2:3IDAT -hL`?oO8K_z_}IENDB`uTox/third_party/stb/stb/tests/pngsuite/16bit/oi1n2c16.png0000600000175000001440000000045614003056224022310 0ustar rakusersPNG  IHDR 1gAMA1_IDATxՖ 0DA~&fzE=֠B>/drs~='3_Zwt(p3p]`_yt?t(C\l52L̩g I@g.`(`g Dg&((`60Y`zl(P49܀:{z*zȟmt3ΞAO3B^IENDB`uTox/third_party/stb/stb/tests/pngsuite/16bit/oi1n0g16.png0000600000175000001440000000024714003056224022310 0ustar rakusersPNG  IHDR kgAMA1_^IDATx1 0 CQ9[ܠ({2*ُ?8Wc:`݂@B&@=2 -hL`?oO8K_+IENDB`uTox/third_party/stb/stb/tests/pngsuite/16bit/bgyn6a16.png0000600000175000001440000000657514003056224022413 0ustar rakusersPNG  IHDR #ꦷgAMA1_bKGD~# "IDATxݙ_luKrM.ZKʴRM Y.R2Z[Ɋ^qb,ZɊ (0PrB&\)(D~D4KK/9wUU4AΝ;ww|猕i |ؘ}}+M!3߀ޱ&}߯ZfF5[,@f.3rZtL017qHÿto Z?TR4٢:O~-{D`kEU4")sZHfn2@6RtXO)ޯ;voR'zֽO۴=5ߣDOqD Oc3`co47e k$9SQ aȗ~U5`:OE5CJ :u'|VMt?\3%'*JS_7W&; 42@THtZ]m'Ի6tmrwK'Z׉^щ~QCbV b^NJ^Jr宁Z S _XfxNEOfͅz-/?ջu5Dp^vGVˏGW5| %˿\5ėf%XYhNf uSSn6Ys;;:p-'AW:UGpxqB?7GsZ g`/f@%6mW#r?zf7k.{zzz _NF٪ At5Huta>4u-⋋=wTK\*< e7 M@x޶"&nܛ9f5|>IEtSqEUvvhƫ ^R\TjVz=XtodɎap~~ p}c ׍{3lvB}ކ|9:^TyJz5%WkFƫ%X go|h7#aL$7u)7ݬP?*>WU4^Y+/WZO?{1+^ |{ w u'0oh5HM@3~ݸ7sf7k.7e-/NK?RxZ s'@/eAY@ [?p| HQtu yfKϼQ-ѪHM@3~ݸ7sf7k.ԇ _|IV?4ħځN,'[3kX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 4eύpNf.J,OAdžN 6lf-ȌcGR3*%dE((\0){n$KJ3`38`ek+-w53&7yiIq/drs~='3_Zwt(p3p]`_yt?t(C\l52L̩g I@g.`(`g Dg&((`60Y`zl(P49܀:{z*zȟmt3ΞAO3B^IENDB`uTox/third_party/stb/stb/tests/pngsuite/16bit/basn0g16.png0000600000175000001440000000024714003056224022365 0ustar rakusersPNG  IHDR kgAMA1_^IDATx1 0 CQ9[ܠ({2*ُ?8Wc:`݂@B&@=2 -hL`?oO8K_+IENDB`uTox/third_party/stb/stb/tests/pngsuite/16bit/basi6a16.png0000600000175000001440000001012414003056224022353 0ustar rakusersPNG  IHDR T!gAMA1_ IDATxݙktU՝}&$@h⍠("І`YЎ" BZ.oY(ZAG$P t 8B[#CIIk_̇$̸Y]gc}m&ZCmI6D#?$XVIͮl̏d׽OB6nnm|¶,()^VnhO*sL-5S< ΍:wx4SEݰ# 𛷍[w8[ u,ZZY: ʊ+$n Pna WݹP^ql}cC#~NZ`^Z$;VWãȖG68F쾰=0@@ SCMpmr/$0J?B?;燈tKi ">SͭVUgTYъ2sAw厊D|Ɏ$d:|sGW#ߘ,  PU*Ԇ͒4C=3Q86sS-C?"SWkK/:[l; ~-&g]۔Bj+SwݗTQ@id'D|_0$[]d)u]3/U'NJ&:=V!``wS W uTBWAUD|UjՒ9U>z1ulh0,9h H=0HF-_0M-R_V[[TSϪ C7dg$@~s9%@Vm֋㔷ޓKN]]35 _#igT}ޙ3c\s  {$)cng*c4&'[9X`}'p 1g>"@BlOjbc%Q4Ի`RVUuH3 eMл@,Lr%е̬i(?XQ-7z(m626 ~Pt2o@ċPgCƁy.`$Jg]q0pUzOs$ɒ%}䦿^)cdmXrSd8j -7!ܘNSו qpH@8fʹn]Ʉ*yU.O.~UZ_4ö*p2Ib늦-D/.l_YY0E%; )7eBkGD!-7KJ@&ڕI:Mi㊽FaPŀ!oyF(Qp\rs@I{5w_8*-#yfvC۫"ʒ*%&%iO:6@8-'*S,dHNn-L] 8tJo26V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suite/16bit/basi2c16.png0000600000175000001440000000112314003056224022350 0ustar rakusersPNG  IHDR ۏvgAMA1_ IDATxՖ!s0?8a>Vx?0.;Xx0p0 SW+c Y}+EI$ ottЅ Awj88:A?/ĠnqsT`z& \lX5R 2'+d~G @4 @4߁@\\y9۩ܵEkQט-} Q FAQ wbk@|DVIENDB`uTox/third_party/stb/stb/tests/pg_test/0000700000175000001440000000000014003056224017213 5ustar rakusersuTox/third_party/stb/stb/tests/pg_test/pg_test.c0000600000175000001440000000617614003056224021040 0ustar rakusers#define STB_DEFINE #include "stb.h" #define STB_PG_IMPLEMENTATION #include "stb_pg.h" #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" static float *hf; static int hf_width = 10001; static int hf_height = 10001; static float get_height(float x, float y) { float h00,h01,h10,h11,h0,h1; int ix,iy; if (x < 0) x = 0; if (x > hf_width-1) x = (float) hf_width-1; if (y < 0) y = 0; if (y > hf_height-1) y = (float) hf_height-1; ix = (int) x; x -= ix; iy = (int) y; y -= iy; h00 = hf[(iy+0)*hf_height+(ix+0)]; h10 = hf[(iy+0)*hf_height+(ix+1)]; h01 = hf[(iy+1)*hf_height+(ix+0)]; h11 = hf[(iy+1)*hf_height+(ix+1)]; h0 = stb_lerp(y, h00, h01); h1 = stb_lerp(y, h10, h11); return stb_lerp(x, h0, h1); } void stbpg_tick(float dt) { int i=0,j=0; int step = 1; glUseProgram(0); glClearColor(0.6f,0.7f,1.0f,1.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); #if 1 glEnable(GL_CULL_FACE); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, 1920/1080.0f, 0.02f, 8000.0f); //glOrtho(-8,8,-6,6, -100, 100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(-90, 1,0,0); // z-up { float x,y; stbpg_get_mouselook(&x,&y); glRotatef(-y, 1,0,0); glRotatef(-x, 0,0,1); } { static float cam_x = 1000; static float cam_y = 1000; static float cam_z = 700; float x=0,y=0; stbpg_get_keymove(&x,&y); cam_x += x*dt*5.0f; cam_y += y*dt*5.0f; glTranslatef(-cam_x, -cam_y, -cam_z); if (cam_x >= 0 && cam_x < hf_width && cam_y >= 0 && cam_y < hf_height) cam_z = get_height(cam_x, cam_y) + 1.65f; // average eye height in meters } for (j=501; j+1 < 1500+0*hf_height; j += step) { glBegin(GL_QUAD_STRIP); for (i=501; i < 1500+0*hf_width; i += step) { static int flip=0; if (flip) glColor3f(0.5,0.5,0.5); else glColor3f(0.4f,0.4f,0.4f); flip = !flip; glVertex3f((float) i, (float) j+step,hf[(j+step)*hf_width+i]); glVertex3f((float) i, (float) j ,hf[ j *hf_width+i]); } glEnd(); } glBegin(GL_LINES); glColor3f(1,0,0); glVertex3f(10,0,0); glVertex3f(0,0,0); glColor3f(0,1,0); glVertex3f(0,10,0); glVertex3f(0,0,0); glColor3f(0,0,1); glVertex3f(0,0,10); glVertex3f(0,0,0); glEnd(); #endif } void stbpg_main(int argc, char **argv) { int i,j; #if 0 int w,h,c; unsigned short *data = stbi_load_16("c:/x/ned_1m/test2.png", &w, &h, &c, 1); stb_filewrite("c:/x/ned_1m/x73_y428_10012_10012.bin", data, w*h*2); #else unsigned short *data = stb_file("c:/x/ned_1m/x73_y428_10012_10012.bin", NULL); int w=10012, h = 10012; #endif hf = malloc(hf_width * hf_height * 4); for (j=0; j < hf_height; ++j) for (i=0; i < hf_width; ++i) hf[j*hf_width+i] = data[j*w+i] / 32.0f; stbpg_gl_compat_version(1,1); stbpg_windowed("terrain_edit", 1920, 1080); stbpg_run(); return; } uTox/third_party/stb/stb/tests/oversample/0000700000175000001440000000000014003056224017723 5ustar rakusersuTox/third_party/stb/stb/tests/oversample/stb_wingraph.h0000600000175000001440000006045314003056224022575 0ustar rakusers// stb_wingraph.h v0.01 - public domain windows graphics programming // wraps WinMain, ChoosePixelFormat, ChangeDisplayResolution, etc. for // doing OpenGL graphics // // in ONE source file, put '#define STB_DEFINE' before including this // OR put '#define STB_WINMAIN' to define a WinMain that calls stbwingraph_main(void) // // @TODO: // 2d rendering interface (that can be done easily in software) // STB_WINGRAPH_SOFTWARE -- 2d software rendering only // STB_WINGRAPH_OPENGL -- OpenGL only #ifndef INCLUDE_STB_WINGRAPH_H #define INCLUDE_STB_WINGRAPH_H #ifdef STB_WINMAIN #ifndef STB_DEFINE #define STB_DEFINE #define STB_WINGRAPH_DISABLE_DEFINE_AT_END #endif #endif #ifdef STB_DEFINE #pragma comment(lib, "opengl32.lib") #pragma comment(lib, "glu32.lib") #pragma comment(lib, "winmm.lib") #pragma comment(lib, "gdi32.lib") #pragma comment(lib, "user32.lib") #endif #ifdef __cplusplus #define STB_EXTERN extern "C" #else #define STB_EXTERN #endif #ifdef STB_DEFINE #ifndef _WINDOWS_ #ifdef APIENTRY #undef APIENTRY #endif #ifdef WINGDIAPI #undef WINGDIAPI #endif #define _WIN32_WINNT 0x0400 // WM_MOUSEWHEEL #include #endif #include #include #include #include #include #endif typedef void * stbwingraph_hwnd; typedef void * stbwingraph_hinstance; enum { STBWINGRAPH_unprocessed = -(1 << 24), STBWINGRAPH_do_not_show, STBWINGRAPH_winproc_exit, STBWINGRAPH_winproc_update, STBWINGRAPH_update_exit, STBWINGRAPH_update_pause, }; typedef enum { STBWGE__none=0, STBWGE_create, STBWGE_create_postshow, STBWGE_draw, STBWGE_destroy, STBWGE_char, STBWGE_keydown, STBWGE_syskeydown, STBWGE_keyup, STBWGE_syskeyup, STBWGE_deactivate, STBWGE_activate, STBWGE_size, STBWGE_mousemove , STBWGE_leftdown , STBWGE_leftup , STBWGE_middledown, STBWGE_middleup, STBWGE_rightdown , STBWGE_rightup , STBWGE_mousewheel, } stbwingraph_event_type; typedef struct { stbwingraph_event_type type; // for input events (mouse, keyboard) int mx,my; // mouse x & y int dx,dy; int shift, ctrl, alt; // for keyboard events int key; // for STBWGE_size: int width, height; // for STBWGE_crate int did_share_lists; // if true, wglShareLists succeeded void *handle; } stbwingraph_event; typedef int (*stbwingraph_window_proc)(void *data, stbwingraph_event *event); extern stbwingraph_hinstance stbwingraph_app; extern stbwingraph_hwnd stbwingraph_primary_window; extern int stbwingraph_request_fullscreen; extern int stbwingraph_request_windowed; STB_EXTERN void stbwingraph_ods(char *str, ...); STB_EXTERN int stbwingraph_MessageBox(stbwingraph_hwnd win, unsigned int type, char *caption, char *text, ...); STB_EXTERN int stbwingraph_ChangeResolution(unsigned int w, unsigned int h, unsigned int bits, int use_message_box); STB_EXTERN int stbwingraph_SetPixelFormat(stbwingraph_hwnd win, int color_bits, int alpha_bits, int depth_bits, int stencil_bits, int accum_bits); STB_EXTERN int stbwingraph_DefineClass(void *hinstance, char *iconname); STB_EXTERN void stbwingraph_SwapBuffers(void *win); STB_EXTERN void stbwingraph_Priority(int n); STB_EXTERN void stbwingraph_MakeFonts(void *window, int font_base); STB_EXTERN void stbwingraph_ShowWindow(void *window); STB_EXTERN void *stbwingraph_CreateWindow(int primary, stbwingraph_window_proc func, void *data, char *text, int width, int height, int fullscreen, int resizeable, int dest_alpha, int stencil); STB_EXTERN void *stbwingraph_CreateWindowSimple(stbwingraph_window_proc func, int width, int height); STB_EXTERN void *stbwingraph_CreateWindowSimpleFull(stbwingraph_window_proc func, int fullscreen, int ww, int wh, int fw, int fh); STB_EXTERN void stbwingraph_DestroyWindow(void *window); STB_EXTERN void stbwingraph_ShowCursor(void *window, int visible); STB_EXTERN float stbwingraph_GetTimestep(float minimum_time); STB_EXTERN void stbwingraph_SetGLWindow(void *win); typedef int (*stbwingraph_update)(float timestep, int real, int in_client); STB_EXTERN int stbwingraph_MainLoop(stbwingraph_update func, float mintime); #ifdef STB_DEFINE stbwingraph_hinstance stbwingraph_app; stbwingraph_hwnd stbwingraph_primary_window; int stbwingraph_request_fullscreen; int stbwingraph_request_windowed; void stbwingraph_ods(char *str, ...) { char buffer[1024]; va_list v; va_start(v,str); vsprintf(buffer, str, v); va_end(v); OutputDebugString(buffer); } int stbwingraph_MessageBox(stbwingraph_hwnd win, unsigned int type, char *caption, char *text, ...) { va_list v; char buffer[1024]; va_start(v, text); vsprintf(buffer, text, v); va_end(v); return MessageBox(win, buffer, caption, type); } void stbwingraph_Priority(int n) { int p; switch (n) { case -1: p = THREAD_PRIORITY_BELOW_NORMAL; break; case 0: p = THREAD_PRIORITY_NORMAL; break; case 1: p = THREAD_PRIORITY_ABOVE_NORMAL; break; default: if (n < 0) p = THREAD_PRIORITY_LOWEST; else p = THREAD_PRIORITY_HIGHEST; } SetThreadPriority(GetCurrentThread(), p); } static void stbwingraph_ResetResolution(void) { ChangeDisplaySettings(NULL, 0); } static void stbwingraph_RegisterResetResolution(void) { static int done=0; if (!done) { done = 1; atexit(stbwingraph_ResetResolution); } } int stbwingraph_ChangeResolution(unsigned int w, unsigned int h, unsigned int bits, int use_message_box) { DEVMODE mode; int res; int i, tries=0; for (i=0; ; ++i) { int success = EnumDisplaySettings(NULL, i, &mode); if (!success) break; if (mode.dmBitsPerPel == bits && mode.dmPelsWidth == w && mode.dmPelsHeight == h) { ++tries; success = ChangeDisplaySettings(&mode, CDS_FULLSCREEN); if (success == DISP_CHANGE_SUCCESSFUL) { stbwingraph_RegisterResetResolution(); return TRUE; } break; } } if (!tries) { if (use_message_box) stbwingraph_MessageBox(stbwingraph_primary_window, MB_ICONERROR, NULL, "The resolution %d x %d x %d-bits is not supported.", w, h, bits); return FALSE; } // we tried but failed, so try explicitly doing it without specifying refresh rate // Win95 support logic mode.dmBitsPerPel = bits; mode.dmPelsWidth = w; mode.dmPelsHeight = h; mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; res = ChangeDisplaySettings(&mode, CDS_FULLSCREEN); switch (res) { case DISP_CHANGE_SUCCESSFUL: stbwingraph_RegisterResetResolution(); return TRUE; case DISP_CHANGE_RESTART: if (use_message_box) stbwingraph_MessageBox(stbwingraph_primary_window, MB_ICONERROR, NULL, "Please set your desktop to %d-bit color and then try again."); return FALSE; case DISP_CHANGE_FAILED: if (use_message_box) stbwingraph_MessageBox(stbwingraph_primary_window, MB_ICONERROR, NULL, "The hardware failed to change modes."); return FALSE; case DISP_CHANGE_BADMODE: if (use_message_box) stbwingraph_MessageBox(stbwingraph_primary_window, MB_ICONERROR, NULL, "The resolution %d x %d x %d-bits is not supported.", w, h, bits); return FALSE; default: if (use_message_box) stbwingraph_MessageBox(stbwingraph_primary_window, MB_ICONERROR, NULL, "An unknown error prevented a change to a %d x %d x %d-bit display.", w, h, bits); return FALSE; } } int stbwingraph_SetPixelFormat(stbwingraph_hwnd win, int color_bits, int alpha_bits, int depth_bits, int stencil_bits, int accum_bits) { HDC dc = GetDC(win); PIXELFORMATDESCRIPTOR pfd = { sizeof(pfd) }; int pixel_format; pfd.nVersion = 1; pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER; pfd.dwLayerMask = PFD_MAIN_PLANE; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = color_bits; pfd.cAlphaBits = alpha_bits; pfd.cDepthBits = depth_bits; pfd.cStencilBits = stencil_bits; pfd.cAccumBits = accum_bits; pixel_format = ChoosePixelFormat(dc, &pfd); if (!pixel_format) return FALSE; if (!DescribePixelFormat(dc, pixel_format, sizeof(PIXELFORMATDESCRIPTOR), &pfd)) return FALSE; SetPixelFormat(dc, pixel_format, &pfd); return TRUE; } typedef struct { // app data stbwingraph_window_proc func; void *data; // creation parameters int color, alpha, depth, stencil, accum; HWND share_window; HWND window; // internal data HGLRC rc; HDC dc; int hide_mouse; int in_client; int active; int did_share_lists; int mx,my; // last mouse positions } stbwingraph__window; static void stbwingraph__inclient(stbwingraph__window *win, int state) { if (state != win->in_client) { win->in_client = state; if (win->hide_mouse) ShowCursor(!state); } } static void stbwingraph__key(stbwingraph_event *e, int type, int key, stbwingraph__window *z) { e->type = type; e->key = key; e->shift = (GetKeyState(VK_SHIFT) < 0); e->ctrl = (GetKeyState(VK_CONTROL) < 0); e->alt = (GetKeyState(VK_MENU) < 0); if (z) { e->mx = z->mx; e->my = z->my; } else { e->mx = e->my = 0; } e->dx = e->dy = 0; } static void stbwingraph__mouse(stbwingraph_event *e, int type, WPARAM wparam, LPARAM lparam, int capture, void *wnd, stbwingraph__window *z) { static int captured = 0; e->type = type; e->mx = (short) LOWORD(lparam); e->my = (short) HIWORD(lparam); if (!z || z->mx == -(1 << 30)) { e->dx = e->dy = 0; } else { e->dx = e->mx - z->mx; e->dy = e->my - z->my; } e->shift = (wparam & MK_SHIFT) != 0; e->ctrl = (wparam & MK_CONTROL) != 0; e->alt = (wparam & MK_ALT) != 0; if (z) { z->mx = e->mx; z->my = e->my; } if (capture) { if (!captured && capture == 1) SetCapture(wnd); captured += capture; if (!captured && capture == -1) ReleaseCapture(); if (captured < 0) captured = 0; } } static void stbwingraph__mousewheel(stbwingraph_event *e, int type, WPARAM wparam, LPARAM lparam, int capture, void *wnd, stbwingraph__window *z) { // lparam seems bogus! static int captured = 0; e->type = type; if (z) { e->mx = z->mx; e->my = z->my; } e->dx = e->dy = 0; e->shift = (wparam & MK_SHIFT) != 0; e->ctrl = (wparam & MK_CONTROL) != 0; e->alt = (GetKeyState(VK_MENU) < 0); e->key = ((int) wparam >> 16); } int stbwingraph_force_update; static int WINAPI stbwingraph_WinProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam) { int allow_default = TRUE; stbwingraph_event e = { STBWGE__none }; // the following line is wrong for 64-bit windows, but VC6 doesn't have GetWindowLongPtr stbwingraph__window *z = (stbwingraph__window *) GetWindowLong(wnd, GWL_USERDATA); switch (msg) { case WM_CREATE: { LPCREATESTRUCT lpcs = (LPCREATESTRUCT) lparam; assert(z == NULL); z = (stbwingraph__window *) lpcs->lpCreateParams; SetWindowLong(wnd, GWL_USERDATA, (LONG) z); z->dc = GetDC(wnd); if (stbwingraph_SetPixelFormat(wnd, z->color, z->alpha, z->depth, z->stencil, z->accum)) { z->rc = wglCreateContext(z->dc); if (z->rc) { e.type = STBWGE_create; z->did_share_lists = FALSE; if (z->share_window) { stbwingraph__window *y = (stbwingraph__window *) GetWindowLong(z->share_window, GWL_USERDATA); if (wglShareLists(z->rc, y->rc)) z->did_share_lists = TRUE; } wglMakeCurrent(z->dc, z->rc); return 0; } } return -1; } case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(wnd, &ps); SelectObject(hdc, GetStockObject(NULL_BRUSH)); e.type = STBWGE_draw; e.handle = wnd; z->func(z->data, &e); EndPaint(wnd, &ps); return 0; } case WM_DESTROY: e.type = STBWGE_destroy; e.handle = wnd; if (z && z->func) z->func(z->data, &e); wglMakeCurrent(NULL, NULL) ; if (z) { if (z->rc) wglDeleteContext(z->rc); z->dc = 0; z->rc = 0; } if (wnd == stbwingraph_primary_window) PostQuitMessage (0); return 0; case WM_CHAR: stbwingraph__key(&e, STBWGE_char , wparam, z); break; case WM_KEYDOWN: stbwingraph__key(&e, STBWGE_keydown, wparam, z); break; case WM_KEYUP: stbwingraph__key(&e, STBWGE_keyup , wparam, z); break; case WM_NCMOUSEMOVE: stbwingraph__inclient(z,0); break; case WM_MOUSEMOVE: stbwingraph__inclient(z,1); stbwingraph__mouse(&e, STBWGE_mousemove, wparam, lparam,0,wnd, z); break; case WM_LBUTTONDOWN: stbwingraph__mouse(&e, STBWGE_leftdown, wparam, lparam,1,wnd, z); break; case WM_MBUTTONDOWN: stbwingraph__mouse(&e, STBWGE_middledown, wparam, lparam,1,wnd, z); break; case WM_RBUTTONDOWN: stbwingraph__mouse(&e, STBWGE_rightdown, wparam, lparam,1,wnd, z); break; case WM_LBUTTONUP: stbwingraph__mouse(&e, STBWGE_leftup, wparam, lparam,-1,wnd, z); break; case WM_MBUTTONUP: stbwingraph__mouse(&e, STBWGE_middleup, wparam, lparam,-1,wnd, z); break; case WM_RBUTTONUP: stbwingraph__mouse(&e, STBWGE_rightup, wparam, lparam,-1,wnd, z); break; case WM_MOUSEWHEEL: stbwingraph__mousewheel(&e, STBWGE_mousewheel, wparam, lparam,0,wnd, z); break; case WM_ACTIVATE: allow_default = FALSE; if (LOWORD(wparam)==WA_INACTIVE ) { wglMakeCurrent(z->dc, NULL); e.type = STBWGE_deactivate; z->active = FALSE; } else { wglMakeCurrent(z->dc, z->rc); e.type = STBWGE_activate; z->active = TRUE; } e.handle = wnd; z->func(z->data, &e); return 0; case WM_SIZE: { RECT rect; allow_default = FALSE; GetClientRect(wnd, &rect); e.type = STBWGE_size; e.width = rect.right; e.height = rect.bottom; e.handle = wnd; z->func(z->data, &e); return 0; } default: return DefWindowProc (wnd, msg, wparam, lparam); } if (e.type != STBWGE__none) { int n; e.handle = wnd; n = z->func(z->data, &e); if (n == STBWINGRAPH_winproc_exit) { PostQuitMessage(0); n = 0; } if (n == STBWINGRAPH_winproc_update) { stbwingraph_force_update = TRUE; return 1; } if (n != STBWINGRAPH_unprocessed) return n; } return DefWindowProc (wnd, msg, wparam, lparam); } int stbwingraph_DefineClass(HINSTANCE hInstance, char *iconname) { WNDCLASSEX wndclass; stbwingraph_app = hInstance; wndclass.cbSize = sizeof(wndclass); wndclass.style = CS_OWNDC; wndclass.lpfnWndProc = (WNDPROC) stbwingraph_WinProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(hInstance, iconname); wndclass.hCursor = LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground = GetStockObject(NULL_BRUSH); wndclass.lpszMenuName = "zwingraph"; wndclass.lpszClassName = "zwingraph"; wndclass.hIconSm = NULL; if (!RegisterClassEx(&wndclass)) return FALSE; return TRUE; } void stbwingraph_ShowWindow(void *window) { stbwingraph_event e = { STBWGE_create_postshow }; stbwingraph__window *z = (stbwingraph__window *) GetWindowLong(window, GWL_USERDATA); ShowWindow(window, SW_SHOWNORMAL); InvalidateRect(window, NULL, TRUE); UpdateWindow(window); e.handle = window; z->func(z->data, &e); } void *stbwingraph_CreateWindow(int primary, stbwingraph_window_proc func, void *data, char *text, int width, int height, int fullscreen, int resizeable, int dest_alpha, int stencil) { HWND win; DWORD dwstyle; stbwingraph__window *z = (stbwingraph__window *) malloc(sizeof(*z)); if (z == NULL) return NULL; memset(z, 0, sizeof(*z)); z->color = 24; z->depth = 24; z->alpha = dest_alpha; z->stencil = stencil; z->func = func; z->data = data; z->mx = -(1 << 30); z->my = 0; if (primary) { if (stbwingraph_request_windowed) fullscreen = FALSE; else if (stbwingraph_request_fullscreen) fullscreen = TRUE; } if (fullscreen) { #ifdef STB_SIMPLE stbwingraph_ChangeResolution(width, height, 32, 1); #else if (!stbwingraph_ChangeResolution(width, height, 32, 0)) return NULL; #endif dwstyle = WS_POPUP | WS_CLIPSIBLINGS; } else { RECT rect; dwstyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; if (resizeable) dwstyle |= WS_SIZEBOX | WS_MAXIMIZEBOX; rect.top = 0; rect.left = 0; rect.right = width; rect.bottom = height; AdjustWindowRect(&rect, dwstyle, FALSE); width = rect.right - rect.left; height = rect.bottom - rect.top; } win = CreateWindow("zwingraph", text ? text : "sample", dwstyle, CW_USEDEFAULT,0, width, height, NULL, NULL, stbwingraph_app, z); if (win == NULL) return win; if (primary) { if (stbwingraph_primary_window) stbwingraph_DestroyWindow(stbwingraph_primary_window); stbwingraph_primary_window = win; } { stbwingraph_event e = { STBWGE_create }; stbwingraph__window *z = (stbwingraph__window *) GetWindowLong(win, GWL_USERDATA); z->window = win; e.did_share_lists = z->did_share_lists; e.handle = win; if (z->func(z->data, &e) != STBWINGRAPH_do_not_show) stbwingraph_ShowWindow(win); } return win; } void *stbwingraph_CreateWindowSimple(stbwingraph_window_proc func, int width, int height) { int fullscreen = 0; #ifndef _DEBUG if (width == 640 && height == 480) fullscreen = 1; if (width == 800 && height == 600) fullscreen = 1; if (width == 1024 && height == 768) fullscreen = 1; if (width == 1280 && height == 1024) fullscreen = 1; if (width == 1600 && height == 1200) fullscreen = 1; //@TODO: widescreen widths #endif return stbwingraph_CreateWindow(1, func, NULL, NULL, width, height, fullscreen, 1, 0, 0); } void *stbwingraph_CreateWindowSimpleFull(stbwingraph_window_proc func, int fullscreen, int ww, int wh, int fw, int fh) { if (fullscreen == -1) { #ifdef _DEBUG fullscreen = 0; #else fullscreen = 1; #endif } if (fullscreen) { if (fw) ww = fw; if (fh) wh = fh; } return stbwingraph_CreateWindow(1, func, NULL, NULL, ww, wh, fullscreen, 1, 0, 0); } void stbwingraph_DestroyWindow(void *window) { stbwingraph__window *z = (stbwingraph__window *) GetWindowLong(window, GWL_USERDATA); DestroyWindow(window); free(z); if (stbwingraph_primary_window == window) stbwingraph_primary_window = NULL; } void stbwingraph_ShowCursor(void *window, int visible) { int hide; stbwingraph__window *win; if (!window) window = stbwingraph_primary_window; win = (stbwingraph__window *) GetWindowLong((HWND) window, GWL_USERDATA); hide = !visible; if (hide != win->hide_mouse) { win->hide_mouse = hide; if (!hide) ShowCursor(TRUE); else if (win->in_client) ShowCursor(FALSE); } } float stbwingraph_GetTimestep(float minimum_time) { float elapsedTime; double thisTime; static double lastTime = -1; if (lastTime == -1) lastTime = timeGetTime() / 1000.0 - minimum_time; for(;;) { thisTime = timeGetTime() / 1000.0; elapsedTime = (float) (thisTime - lastTime); if (elapsedTime >= minimum_time) { lastTime = thisTime; return elapsedTime; } #if 1 Sleep(2); #endif } } void stbwingraph_SetGLWindow(void *win) { stbwingraph__window *z = (stbwingraph__window *) GetWindowLong(win, GWL_USERDATA); if (z) wglMakeCurrent(z->dc, z->rc); } void stbwingraph_MakeFonts(void *window, int font_base) { wglUseFontBitmaps(GetDC(window ? window : stbwingraph_primary_window), 0, 256, font_base); } // returns 1 if WM_QUIT, 0 if 'func' returned 0 int stbwingraph_MainLoop(stbwingraph_update func, float mintime) { int needs_drawing = FALSE; MSG msg; int is_animating = TRUE; if (mintime <= 0) mintime = 0.01f; for(;;) { int n; is_animating = TRUE; // wait for a message if: (a) we're animating and there's already a message // or (b) we're not animating if (!is_animating || PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { stbwingraph_force_update = FALSE; if (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { return 1; // WM_QUIT } // only force a draw for certain messages... // if I don't do this, we peg at 50% for some reason... must // be a bug somewhere, because we peg at 100% when rendering... // very weird... looks like NVIDIA is pumping some messages // through our pipeline? well, ok, I guess if we can get // non-user-generated messages we have to do this if (!stbwingraph_force_update) { switch (msg.message) { case WM_MOUSEMOVE: case WM_NCMOUSEMOVE: break; case WM_CHAR: case WM_KEYDOWN: case WM_KEYUP: case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: case WM_TIMER: case WM_SIZE: case WM_ACTIVATE: needs_drawing = TRUE; break; } } else needs_drawing = TRUE; } // if another message, process that first // @TODO: i don't think this is working, because I can't key ahead // in the SVT demo app if (PeekMessage(&msg, NULL, 0,0, PM_NOREMOVE)) continue; // and now call update if (needs_drawing || is_animating) { int real=1, in_client=1; if (stbwingraph_primary_window) { stbwingraph__window *z = (stbwingraph__window *) GetWindowLong(stbwingraph_primary_window, GWL_USERDATA); if (z && !z->active) { real = 0; } if (z) in_client = z->in_client; } if (stbwingraph_primary_window) stbwingraph_SetGLWindow(stbwingraph_primary_window); n = func(stbwingraph_GetTimestep(mintime), real, in_client); if (n == STBWINGRAPH_update_exit) return 0; // update_quit is_animating = (n != STBWINGRAPH_update_pause); needs_drawing = FALSE; } } } void stbwingraph_SwapBuffers(void *win) { stbwingraph__window *z; if (win == NULL) win = stbwingraph_primary_window; z = (stbwingraph__window *) GetWindowLong(win, GWL_USERDATA); if (z && z->dc) SwapBuffers(z->dc); } #endif #ifdef STB_WINMAIN void stbwingraph_main(void); char *stb_wingraph_commandline; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { { char buffer[1024]; // add spaces to either side of the string buffer[0] = ' '; strcpy(buffer+1, lpCmdLine); strcat(buffer, " "); if (strstr(buffer, " -reset ")) { ChangeDisplaySettings(NULL, 0); exit(0); } if (strstr(buffer, " -window ") || strstr(buffer, " -windowed ")) stbwingraph_request_windowed = TRUE; else if (strstr(buffer, " -full ") || strstr(buffer, " -fullscreen ")) stbwingraph_request_fullscreen = TRUE; } stb_wingraph_commandline = lpCmdLine; stbwingraph_DefineClass(hInstance, "appicon"); stbwingraph_main(); return 0; } #endif #undef STB_EXTERN #ifdef STB_WINGRAPH_DISABLE_DEFINE_AT_END #undef STB_DEFINE #endif #endif // INCLUDE_STB_WINGRAPH_H uTox/third_party/stb/stb/tests/oversample/oversample.exe0000600000175000001440000015200014003056224022603 0ustar rakusersMZ@ !L!This program cannot be run in DOS mode. $i -kֆ-kֆ-kֆBt݆,kֆw؆>kֆBt܆vkֆd kֆ-k׆YkֆyH,kֆRich-kֆPELVT @@UPX0UPX1@UPX2@3.03UPX!  <Ώ%pU;`&L$$ T$PQRKR{%$ 9*oFPhA}ÐD$t}Mt8t3x3ߋj øvb_'3!#s`vhDOSUVW3PVV*ȋ$?8Wn $$((9|$~xu9l$|u 9:t9 FQ|VjyNu̼e!ovkFU.Wh!NjP D>5^.jRp.l_^][:BQ o9hz@ փ f*$X. 7hph N;2d},gtj]||P ; =Q??hUtS_:`SrBqOhLYn||aŃ(,vTTP oÊ fr(<_{ 8f DxmB>FH6aY %,g{oj(R" uoQ (wQj(Wf{1TR-`x_/?x084QPE<0 @)YӍ|4Ӽ ܍-D`)R(,0^Nf40^W Z~ jjWܜfX|=L .j,4H-W"L0VWNVmFF R> :Wfcm4(P4PR$tRVىv2$F8fItpPH$$hTt~ rQ(Xai/3-k;@t;tRwA8SSF>@^( =auLf]VQ@Z(R +X)84q07Dn= @%)a'~DQWv iã=jbL0P4h<~lZVLQRD$TP9xP DOoȁ; P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|Q5p viuCBfJcG Q4_T@ȸ/ {"xſ19opebOdNGetLTXtADvdu=&WjdM]&ageBoxri].dv 1#QNANINFD AwS.(  &\@)+n@ν@t`AxAnɏ?7prevena chang>% x -bdisplay.vnhFRrdw lwwailxf{f!es.e0as ڳxyou.kNpWv6coll~nrygn.>yus ƀ/supp|;zwrphhWNsamplex wY ?p|!8mtcfOTTO+typ1maxpkern{WhmtxheaglyoϾd/c/cpo V%s/f g.,ʘoM0I(,ofwp0V{a4^>1:1xt;V, onee=pi?s,P,sndi9F,883.3x1d#g2x27F xght: 4DL̜/2C^G949:D{o:viewTB:RgQab-B{*F7%7IC`G7srgbdd$ -v?/-- (0F)CRrwyy<5:^c}y碶 ݐuDwE?+KA9h( *Hdr%%[\rw]p ހ|. 8@05 |&'g vm#M  [v 7 nn'/''!5ACPvngR/SWYspl/mpVr_g炓ۂ?NN)ߧn??n`y!m˕@~^ړ!@'_AϢB[~Q)^ھ_j2r=e1~@C>$@ A>P$ 4@N@ p+ŝi@]%O@qוC)@D@<զIx@oGAkU'9p|Bݎ~QCv)/&D(DJzEeǑF e uuvHMXB䧓9;5SM]=];Z] T7aZ%]g']݀nLlɛ R`%u?q= ףp ?Zd;On?,eX?#GGŧ?@il7?3=BzՔ?aw̫?/L[Mľ?S;uD?g9Eϔ?$#⼺;1az?aUY~S|_?/DF?9'*?}d|FU>c{#Tw=:zc%C1$oGetStringTypeASd?HandleLoadLibrary7EnvironmentV(iabJAOEMCPbAComp>eWoocLInfoMultiByteToW[;ideChN^Va"FiClo`se% -Po̞@RWQNRtlUnwi='d [&u;, VCsW/2Fe_1fA&hdExcep0>4vRdLCMap[W dOfSlSurrThrތMPnoHyI`LaszN aiAF';TocAddjs0fVtualAll(vhoHpED`aW0ttVsBbGMod sNam&SizKm*n.a2p;<_A3X{pTm~O+z#Zi=Flu sh1Buff!Q1[n4"fSwPcFbj ik oPixJF0X$cXb)K.ey4t#eȁԷSP)EtQuic#AB ǙfʋqIc-˰Rzs>awaEDCum}.y"tufEhe/T ” ܂T ?/PELVT /'_۶}@g^޻Of ؍M![.]!Fl& .ragچ(@в.M^ >@O> .ٶ$I`EW FGurus u(rHuuR1ɃrFtu urAurusu s/vBGIuBw,^jG,<w?u_f)ٍ t<_0PGt܉WHU tPTjSWՍ `(XPTPSWXaD$j9u  0@N\jxKERNEL32.DLLGDI32.dllGLU32.dllOPENGL32.dllUSER32.dllWINMM.dllLoadLibraryAGetProcAddressVirtualProtectVirtualAllocVirtualFreeExitProcessSwapBuffersgluOrtho2DglEndGetDCtimeGetTimeuTox/third_party/stb/stb/tests/oversample/oversample.dsw0000600000175000001440000000100214003056224022612 0ustar rakusersMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "oversample"=.\oversample.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### uTox/third_party/stb/stb/tests/oversample/oversample.dsp0000600000175000001440000000716414003056224022622 0ustar rakusers# Microsoft Developer Studio Project File - Name="oversample" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Application" 0x0101 CFG=oversample - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "oversample.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "oversample.mak" CFG="oversample - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "oversample - Win32 Release" (based on "Win32 (x86) Application") !MESSAGE "oversample - Win32 Debug" (based on "Win32 (x86) Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "oversample - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /WX /GX /O2 /I "c:\sean\prj\stb" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 # SUBTRACT LINK32 /map /debug !ELSEIF "$(CFG)" == "oversample - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /WX /Gm /GX /Zi /Od /I "c:\sean\prj\stb" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:no /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "oversample - Win32 Release" # Name "oversample - Win32 Debug" # Begin Source File SOURCE=.\main.c # End Source File # End Target # End Project uTox/third_party/stb/stb/tests/oversample/main.c0000600000175000001440000002056714003056224021027 0ustar rakusers#pragma warning(disable:4244; disable:4305; disable:4018) #include #include #define STB_WINMAIN #include "stb_wingraph.h" #define STB_TRUETYPE_IMPLEMENTATION #define STB_RECT_PACK_IMPLEMENTATION #include "stb_rect_pack.h" #include "stb_truetype.h" #ifndef WINGDIAPI #define CALLBACK __stdcall #define WINGDIAPI __declspec(dllimport) #define APIENTRY __stdcall #endif #include #include #define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 #define SIZE_X 1024 #define SIZE_Y 768 stbtt_packedchar chardata[6][128]; int sx=SIZE_X, sy=SIZE_Y; #define BITMAP_W 512 #define BITMAP_H 512 unsigned char temp_bitmap[BITMAP_W][BITMAP_H]; unsigned char ttf_buffer[1 << 25]; GLuint font_tex; float scale[2] = { 24.0f, 14.0f }; int sf[6] = { 0,1,2, 0,1,2 }; void load_fonts(void) { stbtt_pack_context pc; int i; FILE *f; char filename[256]; char *win = getenv("windir"); if (win == NULL) win = getenv("SystemRoot"); f = fopen(stb_wingraph_commandline, "rb"); if (!f) { if (win == NULL) sprintf(filename, "arial.ttf", win); else sprintf(filename, "%s/fonts/arial.ttf", win); f = fopen(filename, "rb"); if (!f) exit(0); } fread(ttf_buffer, 1, 1<<25, f); stbtt_PackBegin(&pc, temp_bitmap[0], BITMAP_W, BITMAP_H, 0, 1, NULL); for (i=0; i < 2; ++i) { stbtt_PackSetOversampling(&pc, 1, 1); stbtt_PackFontRange(&pc, ttf_buffer, 0, scale[i], 32, 95, chardata[i*3+0]+32); stbtt_PackSetOversampling(&pc, 2, 2); stbtt_PackFontRange(&pc, ttf_buffer, 0, scale[i], 32, 95, chardata[i*3+1]+32); stbtt_PackSetOversampling(&pc, 3, 1); stbtt_PackFontRange(&pc, ttf_buffer, 0, scale[i], 32, 95, chardata[i*3+2]+32); } stbtt_PackEnd(&pc); glGenTextures(1, &font_tex); glBindTexture(GL_TEXTURE_2D, font_tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, BITMAP_W, BITMAP_H, 0, GL_ALPHA, GL_UNSIGNED_BYTE, temp_bitmap); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } int black_on_white; void draw_init(void) { glDisable(GL_CULL_FACE); glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glViewport(0,0,sx,sy); if (black_on_white) glClearColor(255,255,255,0); else glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0,sx,sy,0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void drawBoxTC(float x0, float y0, float x1, float y1, float s0, float t0, float s1, float t1) { glTexCoord2f(s0,t0); glVertex2f(x0,y0); glTexCoord2f(s1,t0); glVertex2f(x1,y0); glTexCoord2f(s1,t1); glVertex2f(x1,y1); glTexCoord2f(s0,t1); glVertex2f(x0,y1); } int integer_align; void print(float x, float y, int font, char *text) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, font_tex); glBegin(GL_QUADS); while (*text) { stbtt_aligned_quad q; stbtt_GetPackedQuad(chardata[font], BITMAP_W, BITMAP_H, *text++, &x, &y, &q, font ? 0 : integer_align); drawBoxTC(q.x0,q.y0,q.x1,q.y1, q.s0,q.t0,q.s1,q.t1); } glEnd(); } int font=3; int translating; int rotating=0; int srgb=0; float rotate_t, translate_t; int show_tex; void draw_world(void) { int sfont = sf[font]; float x = 20; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if (black_on_white) glColor3f(0,0,0); else glColor3f(1,1,1); print(80, 30, sfont, "Controls:"); print(100, 60, sfont, "S: toggle font size"); print(100, 85, sfont, "O: toggle oversampling"); print(100,110, sfont, "T: toggle translation"); print(100,135, sfont, "R: toggle rotation"); print(100,160, sfont, "P: toggle pixel-snap (only non-oversampled)"); print(100,185, sfont, "G: toggle srgb gamma-correction"); if (black_on_white) print(100,210, sfont, "B: toggle to white-on-black"); else print(100,210, sfont, "B: toggle to black-on-white"); print(100,235, sfont, "V: view font texture"); print(80, 300, sfont, "Current font:"); if (!show_tex) { if (font < 3) print(100, 350, sfont, "Font height: 24 pixels"); else print(100, 350, sfont, "Font height: 14 pixels"); } if (font%3==1) print(100, 325, sfont, "2x2 oversampled text at 1:1"); else if (font%3 == 2) print(100, 325, sfont, "3x1 oversampled text at 1:1"); else if (integer_align) print(100, 325, sfont, "1:1 text, one texel = one pixel, snapped to integer coordinates"); else print(100, 325, sfont, "1:1 text, one texel = one pixel"); if (show_tex) { glBegin(GL_QUADS); drawBoxTC(200,400, 200+BITMAP_W,300+BITMAP_H, 0,0,1,1); glEnd(); } else { glMatrixMode(GL_MODELVIEW); glTranslatef(200,350,0); if (translating) x += fmod(translate_t*8,30); if (rotating) { glTranslatef(100,150,0); glRotatef(rotate_t*2,0,0,1); glTranslatef(-100,-150,0); } print(x,100, font, "This is a test"); print(x,130, font, "Now is the time for all good men to come to the aid of their country."); print(x,160, font, "The quick brown fox jumps over the lazy dog."); print(x,190, font, "0123456789"); } } void draw(void) { draw_init(); draw_world(); stbwingraph_SwapBuffers(NULL); } static int initialized=0; static float last_dt; int move[4]; int raw_mouse_x, raw_mouse_y; int loopmode(float dt, int real, int in_client) { float actual_dt = dt; if (!initialized) return 0; rotate_t += dt; translate_t += dt; // music_sim(); if (!real) return 0; if (dt > 0.25) dt = 0.25; if (dt < 0.01) dt = 0.01; draw(); return 0; } int winproc(void *data, stbwingraph_event *e) { switch (e->type) { case STBWGE_create: break; case STBWGE_char: switch(e->key) { case 27: stbwingraph_ShowCursor(NULL,1); return STBWINGRAPH_winproc_exit; break; case 'o': case 'O': font = (font+1) % 3 + (font/3)*3; break; case 's': case 'S': font = (font+3) % 6; break; case 't': case 'T': translating = !translating; translate_t = 0; break; case 'r': case 'R': rotating = !rotating; rotate_t = 0; break; case 'p': case 'P': integer_align = !integer_align; break; case 'g': case 'G': srgb = !srgb; if (srgb) glEnable(GL_FRAMEBUFFER_SRGB_EXT); else glDisable(GL_FRAMEBUFFER_SRGB_EXT); break; case 'v': case 'V': show_tex = !show_tex; break; case 'b': case 'B': black_on_white = !black_on_white; break; } break; case STBWGE_mousemove: raw_mouse_x = e->mx; raw_mouse_y = e->my; break; #if 0 case STBWGE_mousewheel: do_mouse(e,0,0); break; case STBWGE_leftdown: do_mouse(e, 1,0); break; case STBWGE_leftup: do_mouse(e,-1,0); break; case STBWGE_rightdown: do_mouse(e,0, 1); break; case STBWGE_rightup: do_mouse(e,0,-1); break; #endif case STBWGE_keydown: if (e->key == VK_RIGHT) move[0] = 1; if (e->key == VK_LEFT) move[1] = 1; if (e->key == VK_UP) move[2] = 1; if (e->key == VK_DOWN) move[3] = 1; break; case STBWGE_keyup: if (e->key == VK_RIGHT) move[0] = 0; if (e->key == VK_LEFT) move[1] = 0; if (e->key == VK_UP) move[2] = 0; if (e->key == VK_DOWN) move[3] = 0; break; case STBWGE_size: sx = e->width; sy = e->height; loopmode(0,1,0); break; case STBWGE_draw: if (initialized) loopmode(0,1,0); break; default: return STBWINGRAPH_unprocessed; } return 0; } void stbwingraph_main(void) { stbwingraph_Priority(2); stbwingraph_CreateWindow(1, winproc, NULL, "tt", SIZE_X,SIZE_Y, 0, 1, 0, 0); stbwingraph_ShowCursor(NULL, 0); load_fonts(); initialized = 1; stbwingraph_MainLoop(loopmode, 0.016f); // 30 fps = 0.33 } uTox/third_party/stb/stb/tests/oversample/README.md0000600000175000001440000001103414003056224021203 0ustar rakusers# Font character oversampling for rendering from atlas textures TL,DR: Run oversample.exe on a windows machine to see the benefits of oversampling. It will try to use arial.ttf from the Windows font directory unless you type the name of a .ttf file as a command-line argument. ## Benefits of oversampling Oversampling is a mechanism for improving subpixel rendering of characters. Improving subpixel has a few benefits: * With horizontal-oversampling, text can remain sharper while still being sub-pixel positioned for better kerning * Horizontally-oversampled text significantly reduces aliasing when text animates horizontally * Vertically-oversampled text significantly reduces aliasing when text animates vertically * Text oversampled in both directions significantly reduces aliasing when text rotates ## What text oversampling is A common strategy for rendering text is to cache character bitmaps and reuse them. For hinted characters, every instance of a given character is always identical, so this works fine. However, stb_truetype doesn't do hinting. For anti-aliased characters, you can actually position the characters with subpixel precision, and get different bitmaps based on that positioning if you re-render the vector data. However, if you simply cache a single version of the bitmap and draw it at different subpixel positions with a GPU, you will get either the exact same result (if you use point-sampling on the texture) or linear filtering. Linear filtering will cause a sub-pixel positioned bitmap to blur further, causing a visible de-sharpening of the character. (And, since the character wasn't hinted, it was already blurrier than a hinted one would be, and now it gets even more blurry.) You can avoid this by caching multiple variants of a character which were rendered independently from the vector data. For example, you might cache 3 versions of a char, at 0, 1/3, and 2/3rds of a pixel horizontal offset, and always require characters to fall on integer positions vertically. When creating a texture atlas for use on GPUs, which support bilinear filtering, there is a better approach than caching several independent positions, which is to allow lerping between the versions to allow finer subpixel positioning. You can achieve these by interleaving each of the cached bitmaps, but this turns out to be mathematically equivalent to a simpler operation: oversampling and prefiltering the characters. So, setting oversampling of 2x2 in stb_truetype is equivalent to caching each character in 4 different variations, 1 for each subpixel position in a 2x2 set. An advantage of this formulation is that no changes are required to the rendering code; the exact same quad-rendering code works, it just uses different texture coordinates. (Note this does potentially increase texture bandwidth for text rendering since we end up minifying the texture without using mipmapping, but you probably are not going to be fill-bound by your text rendering.) ## What about gamma? Gamma-correction for fonts just doesn't work. This doesn't seem to make much sense -- it's physically correct, it simulates what we'd see if you shrunk a font down really far, right? But you can play with it in the oversample.exe app. If you turn it on, white-on-black fonts become too thick (i.e. they become too bright), and black-on-white fonts become too thin (i.e. they are insufficiently dark). There is no way to adjust the font's inherent thickness (i.e. by switching to bold) to fix this for both; making the font thicker will make white text worse, and making the font thinner will make black text worse. Obviously you could use different fonts for light and dark cases, but this doesn't seem like a very good way for fonts to work. Multiple people who have experimented with this independently (me, Fabian Giesen,and Maxim Shemanarev of Anti-Grain Geometry) have all concluded that correct gamma-correction does not produce the best results for fonts. Font rendering just generally looks better without gamma correction (or possibly with some arbitrary power stuck in there, but it's not really correcting for gamma at that point). Maybe this is in part a product of how we're used to fonts being on screens which has changed how we expect them to look (e.g. perhaps hinting oversharpens them and prevents the real-world thinning you'd see in a black-on-white text). (AGG link on text rendering, including mention of gamma: http://www.antigrain.com/research/font_rasterization/ ) Nevertheless, even if you turn on gamma-correction, you will find that oversampling still helps in many cases for small fonts. uTox/third_party/stb/stb/tests/image_test.dsp0000600000175000001440000000777514003056224020421 0ustar rakusers# Microsoft Developer Studio Project File - Name="image_test" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=image_test - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "image_test.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "image_test.mak" CFG="image_test - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "image_test - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "image_test - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "image_test - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "image_test - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug\image_test" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "image_test - Win32 Release" # Name "image_test - Win32 Debug" # Begin Source File SOURCE=.\image_test.c # End Source File # Begin Source File SOURCE=..\stb_image.h # End Source File # Begin Source File SOURCE=..\stb_image_write.h # End Source File # End Target # End Project uTox/third_party/stb/stb/tests/image_test.c0000600000175000001440000001346714003056224020050 0ustar rakusers#define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" #define STB_DEFINE #include "stb.h" //#define PNGSUITE_PRIMARY #if 0 void test_ycbcr(void) { STBI_SIMD_ALIGN(unsigned char, y[256]); STBI_SIMD_ALIGN(unsigned char, cb[256]); STBI_SIMD_ALIGN(unsigned char, cr[256]); STBI_SIMD_ALIGN(unsigned char, out1[256][4]); STBI_SIMD_ALIGN(unsigned char, out2[256][4]); int i,j,k; int count = 0, bigcount=0, total=0; for (i=0; i < 256; ++i) { for (j=0; j < 256; ++j) { for (k=0; k < 256; ++k) { y [k] = k; cb[k] = j; cr[k] = i; } stbi__YCbCr_to_RGB_row(out1[0], y, cb, cr, 256, 4); stbi__YCbCr_to_RGB_sse2(out2[0], y, cb, cr, 256, 4); for (k=0; k < 256; ++k) { // inaccurate proxy for values outside of RGB cube if (out1[k][0] == 0 || out1[k][1] == 0 || out1[k][2] == 0 || out1[k][0] == 255 || out1[k][1] == 255 || out1[k][2] == 255) continue; ++total; if (out1[k][0] != out2[k][0] || out1[k][1] != out2[k][1] || out1[k][2] != out2[k][2]) { int dist1 = abs(out1[k][0] - out2[k][0]); int dist2 = abs(out1[k][1] - out2[k][1]); int dist3 = abs(out1[k][2] - out2[k][2]); ++count; if (out1[k][1] > out2[k][1]) ++bigcount; } } } printf("So far: %d (%d big) of %d\n", count, bigcount, total); } printf("Final: %d (%d big) of %d\n", count, bigcount, total); } #endif float hdr_data[200][200][3]; void dummy_write(void *context, void *data, int len) { static char dummy[1024]; if (len > 1024) len = 1024; memcpy(dummy, data, len); } int main(int argc, char **argv) { int w,h; //test_ycbcr(); #if 0 // test hdr asserts for (h=0; h < 100; h += 2) for (w=0; w < 200; ++w) hdr_data[h][w][0] = (float) rand(), hdr_data[h][w][1] = (float) rand(), hdr_data[h][w][2] = (float) rand(); stbi_write_hdr("output/test.hdr", 200,200,3,hdr_data[0][0]); #endif if (argc > 1) { int i, n; for (i=1; i < argc; ++i) { int res; int w2,h2,n2; unsigned char *data; printf("%s\n", argv[i]); res = stbi_info(argv[1], &w2, &h2, &n2); data = stbi_load(argv[i], &w, &h, &n, 4); if (data) free(data); else printf("Failed &n\n"); data = stbi_load(argv[i], &w, &h, 0, 1); if (data) free(data); else printf("Failed 1\n"); data = stbi_load(argv[i], &w, &h, 0, 2); if (data) free(data); else printf("Failed 2\n"); data = stbi_load(argv[i], &w, &h, 0, 3); if (data) free(data); else printf("Failed 3\n"); data = stbi_load(argv[i], &w, &h, &n, 4); assert(data); assert(w == w2 && h == h2 && n == n2); assert(res); if (data) { char fname[512]; stb_splitpath(fname, argv[i], STB_FILE); stbi_write_png(stb_sprintf("output/%s.png", fname), w, h, 4, data, w*4); stbi_write_bmp(stb_sprintf("output/%s.bmp", fname), w, h, 4, data); stbi_write_tga(stb_sprintf("output/%s.tga", fname), w, h, 4, data); stbi_write_png_to_func(dummy_write,0, w, h, 4, data, w*4); stbi_write_bmp_to_func(dummy_write,0, w, h, 4, data); stbi_write_tga_to_func(dummy_write,0, w, h, 4, data); free(data); } else printf("FAILED 4\n"); } } else { int i, nope=0; #ifdef PNGSUITE_PRIMARY char **files = stb_readdir_files("pngsuite/primary"); #else char **files = stb_readdir_files("images"); #endif for (i=0; i < stb_arr_len(files); ++i) { int n; char **failed = NULL; unsigned char *data; printf("."); //printf("%s\n", files[i]); data = stbi_load(files[i], &w, &h, &n, 0); if (data) free(data); else stb_arr_push(failed, "&n"); data = stbi_load(files[i], &w, &h, 0, 1); if (data) free(data); else stb_arr_push(failed, "1"); data = stbi_load(files[i], &w, &h, 0, 2); if (data) free(data); else stb_arr_push(failed, "2"); data = stbi_load(files[i], &w, &h, 0, 3); if (data) free(data); else stb_arr_push(failed, "3"); data = stbi_load(files[i], &w, &h, 0, 4); if (data) ; else stb_arr_push(failed, "4"); if (data) { char fname[512]; #ifdef PNGSUITE_PRIMARY int w2,h2; unsigned char *data2; stb_splitpath(fname, files[i], STB_FILE_EXT); data2 = stbi_load(stb_sprintf("pngsuite/primary_check/%s", fname), &w2, &h2, 0, 4); if (!data2) printf("FAILED: couldn't load 'pngsuite/primary_check/%s\n", fname); else { if (w != w2 || h != w2 || 0 != memcmp(data, data2, w*h*4)) { int x,y,c; if (w == w2 && h == h2) for (y=0; y < h; ++y) for (x=0; x < w; ++x) for (c=0; c < 4; ++c) assert(data[y*w*4+x*4+c] == data2[y*w*4+x*4+c]); printf("FAILED: %s loaded but didn't match PRIMARY_check 32-bit version\n", files[i]); } free(data2); } #else stb_splitpath(fname, files[i], STB_FILE); stbi_write_png(stb_sprintf("output/%s.png", fname), w, h, 4, data, w*4); #endif free(data); } if (failed) { int j; printf("FAILED: "); for (j=0; j < stb_arr_len(failed); ++j) printf("%s ", failed[j]); printf(" -- %s\n", files[i]); } } printf("Tested %d files.\n", i); } return 0; } uTox/third_party/stb/stb/tests/herringbone_map.dsp0000600000175000001440000001010614003056224021415 0ustar rakusers# Microsoft Developer Studio Project File - Name="herringbone_map" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=herringbone_map - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "herringbone_map.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "herringbone_map.mak" CFG="herringbone_map - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "herringbone_map - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "herringbone_map - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "herringbone_map - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "herringbone_map - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "herringbone_map___Win32_Debug" # PROP BASE Intermediate_Dir "herringbone_map___Win32_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "herringbone_map - Win32 Release" # Name "herringbone_map - Win32 Debug" # Begin Source File SOURCE=.\herringbone_map.c # End Source File # Begin Source File SOURCE=..\stb_herringbone_wang_tile.h # End Source File # End Target # End Project uTox/third_party/stb/stb/tests/herringbone_map.c0000600000175000001440000000470014003056224021054 0ustar rakusers#include #define STB_HBWANG_MAX_X 500 #define STB_HBWANG_MAX_Y 500 #define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION #include "stb_herringbone_wang_tile.h" #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" int main(int argc, char **argv) { if (argc < 5) { fprintf(stderr, "Usage: herringbone_map {inputfile} {output-width} {output-height} {outputfile}\n"); return 1; } else { char *filename = argv[1]; int out_w = atoi(argv[2]); int out_h = atoi(argv[3]); char *outfile = argv[4]; unsigned char *pixels, *out_pixels; stbhw_tileset ts; int w,h; pixels = stbi_load(filename, &w, &h, 0, 3); if (pixels == 0) { fprintf(stderr, "Couldn't open input file '%s'\n", filename); exit(1); } if (!stbhw_build_tileset_from_image(&ts, pixels, w*3, w, h)) { fprintf(stderr, "Error: %s\n", stbhw_get_last_error()); return 1; } free(pixels); #ifdef DEBUG_OUTPUT { int i,j,k; // add blue borders to top-left edges of the tiles int hstride = (ts.short_side_len*2)*3; int vstride = (ts.short_side_len )*3; for (i=0; i < ts.num_h_tiles; ++i) { unsigned char *pix = ts.h_tiles[i]->pixels; for (j=0; j < ts.short_side_len*2; ++j) for (k=0; k < 3; ++k) pix[j*3+k] = (pix[j*3+k]*0.5+100+k*75)/1.5; for (j=1; j < ts.short_side_len; ++j) for (k=0; k < 3; ++k) pix[j*hstride+k] = (pix[j*hstride+k]*0.5+100+k*75)/1.5; } for (i=0; i < ts.num_v_tiles; ++i) { unsigned char *pix = ts.v_tiles[i]->pixels; for (j=0; j < ts.short_side_len; ++j) for (k=0; k < 3; ++k) pix[j*3+k] = (pix[j*3+k]*0.5+100+k*75)/1.5; for (j=1; j < ts.short_side_len*2; ++j) for (k=0; k < 3; ++k) pix[j*vstride+k] = (pix[j*vstride+k]*0.5+100+k*75)/1.5; } } #endif out_pixels = malloc(out_w * out_h * 3); if (!stbhw_generate_image(&ts, NULL, out_pixels, out_w*3, out_w, out_h)) { fprintf(stderr, "Error: %s\n", stbhw_get_last_error()); return 1; } stbi_write_png(argv[4], out_w, out_h, 3, out_pixels, out_w*3); free(out_pixels); stbhw_free_tileset(&ts); return 0; } }uTox/third_party/stb/stb/tests/herringbone_generator.c0000600000175000001440000000571014003056224022267 0ustar rakusers#define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION #include "stb_herringbone_wang_tile.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" // e 12 1 1 1 1 1 1 4 4 int main(int argc, char **argv) { stbhw_config c = { 0 }; int w,h, num_colors,i; unsigned char *data; if (argc == 1) goto usage; if (argc < 3) goto error; switch (argv[2][0]) { case 'c': if (argc < 8 || argc > 10) goto error; num_colors = 4; c.is_corner = 1; break; case 'e': if (argc < 10 || argc > 12) goto error; num_colors = 6; c.is_corner = 0; break; default: goto error; } c.short_side_len = atoi(argv[3]); for (i=0; i < num_colors; ++i) c.num_color[i] = atoi(argv[4+i]); c.num_vary_x = 1; c.num_vary_y = 1; if (argc > 4+i) c.num_vary_x = atoi(argv[4+i]); if (argc > 5+i) c.num_vary_y = atoi(argv[5+i]); stbhw_get_template_size(&c, &w, &h); data = (unsigned char *) malloc(w*h*3); if (stbhw_make_template(&c, data, w, h, w*3)) stbi_write_png(argv[1], w, h, 3, data, w*3); else fprintf(stderr, "Error: %s\n", stbhw_get_last_error()); return 0; error: fputs("Invalid command-line arguments\n\n", stderr); usage: fputs("Usage (see source for corner & edge type definitions):\n\n", stderr); fputs("herringbone_generator {outfile} c {sidelen} {c0} {c1} {c2} {c3} [{vx} {vy}]\n" " {outfile} -- filename that template will be written to as PNG\n" " {sidelen} -- length of short side of rectangle in pixels\n" " {c0} -- number of colors for corner type 0\n" " {c1} -- number of colors for corner type 1\n" " {c2} -- number of colors for corner type 2\n" " {c3} -- number of colors for corner type 3\n" " {vx} -- number of color-duplicating variations horizontally in template\n" " {vy} -- number of color-duplicating variations vertically in template\n" "\n" , stderr); fputs("herringbone_generator {outfile} e {sidelen} {e0} {e1} {e2} {e3} {e4} {e5} [{vx} {vy}]\n" " {outfile} -- filename that template will be written to as PNG\n" " {sidelen} -- length of short side of rectangle in pixels\n" " {e0} -- number of colors for edge type 0\n" " {e1} -- number of colors for edge type 1\n" " {e2} -- number of colors for edge type 2\n" " {e3} -- number of colors for edge type 3\n" " {e4} -- number of colors for edge type 4\n" " {e5} -- number of colors for edge type 5\n" " {vx} -- number of color-duplicating variations horizontally in template\n" " {vy} -- number of color-duplicating variations vertically in template\n" , stderr); return 1; } uTox/third_party/stb/stb/tests/herringbone.dsp0000600000175000001440000001006314003056224020562 0ustar rakusers# Microsoft Developer Studio Project File - Name="herringbone" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=herringbone - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "herringbone.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "herringbone.mak" CFG="herringbone - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "herringbone - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "herringbone - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "herringbone - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "herringbone - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "herringbone___Win32_Debug" # PROP BASE Intermediate_Dir "herringbone___Win32_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "herringbone - Win32 Release" # Name "herringbone - Win32 Debug" # Begin Source File SOURCE=.\herringbone_generator.c # End Source File # Begin Source File SOURCE=..\stb_herringbone_wang_tile.h # End Source File # End Target # End Project uTox/third_party/stb/stb/tests/grid_reachability.c0000600000175000001440000002211314003056224021360 0ustar rakusers#define STB_CONNECTED_COMPONENTS_IMPLEMENTATION #define STBCC_GRID_COUNT_X_LOG2 10 #define STBCC_GRID_COUNT_Y_LOG2 10 #include "stb_connected_components.h" #ifdef GRID_TEST #include #include #include //#define STB_DEFINE #include "stb.h" //#define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" //#define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" typedef struct { uint16 x,y; } point; point leader[1024][1024]; uint32 color[1024][1024]; point find(int x, int y) { point p,q; p = leader[y][x]; if (p.x == x && p.y == y) return p; q = find(p.x, p.y); leader[y][x] = q; return q; } void onion(int x1, int y1, int x2, int y2) { point p = find(x1,y1); point q = find(x2,y2); if (p.x == q.x && p.y == q.y) return; leader[p.y][p.x] = q; } void reference(uint8 *map, int w, int h) { int i,j; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { leader[j][i].x = i; leader[j][i].y = j; } } for (j=1; j < h-1; ++j) { for (i=1; i < w-1; ++i) { if (map[j*w+i] == 255) { if (map[(j+1)*w+i] == 255) onion(i,j, i,j+1); if (map[(j)*w+i+1] == 255) onion(i,j, i+1,j); } } } for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { uint32 c = 0xff000000; if (leader[j][i].x == i && leader[j][i].y == j) { if (map[j*w+i] == 255) c = stb_randLCG() | 0xff404040; } color[j][i] = c; } } for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { if (leader[j][i].x != i || leader[j][i].y != j) { point p = find(i,j); color[j][i] = color[p.y][p.x]; } } } } void write_map(stbcc_grid *g, int w, int h, char *filename) { int i,j; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { unsigned int c; c = stbcc_get_unique_id(g,i,j); c = stb_rehash_improved(c)&0xffffff; if (c == STBCC_NULL_UNIQUE_ID) c = 0xff000000; else c = (~c)^0x555555; if (i % 32 == 0 || j %32 == 0) { int r = (c >> 16) & 255; int g = (c >> 8) & 255; int b = c & 255; r = (r+130)/2; g = (g+130)/2; b = (b+130)/2; c = 0xff000000 + (r<<16) + (g<<8) + b; } color[j][i] = c; } } stbi_write_png(filename, w, h, 4, color, 4*w); } void test_connected(stbcc_grid *g) { int n = stbcc_query_grid_node_connection(g, 512, 90, 512, 871); //printf("%d ", n); } static char *message; LARGE_INTEGER start; void start_timer(char *s) { message = s; QueryPerformanceCounter(&start); } void end_timer(void) { LARGE_INTEGER end, freq; double tm; QueryPerformanceCounter(&end); QueryPerformanceFrequency(&freq); tm = (end.QuadPart - start.QuadPart) / (double) freq.QuadPart; printf("%6.4lf ms: %s\n", tm * 1000, message); } extern void quicktest(void); int loc[5000][2]; int main(int argc, char **argv) { stbcc_grid *g; int w,h, i,j,k=0, count=0, r; uint8 *map = stbi_load("data/map_03.png", &w, &h, 0, 1); assert(map); quicktest(); for (j=0; j < h; ++j) for (i=0; i < w; ++i) map[j*w+i] = ~map[j*w+i]; for (i=0; i < w; ++i) for (j=0; j < h; ++j) //map[j*w+i] = (((i+1) ^ (j+1)) >> 1) & 1 ? 255 : 0; map[j*w+i] = stb_max(abs(i-w/2),abs(j-h/2)) & 1 ? 255 : 0; //map[j*w+i] = (((i ^ j) >> 5) ^ (i ^ j)) & 1 ? 255 : 0; //map[j*w+i] = stb_rand() & 1 ? 255 : 0; #if 1 for (i=0; i < 100000; ++i) map[(stb_rand()%h)*w + stb_rand()%w] ^= 255; #endif _mkdir("tests/output/stbcc"); stbi_write_png("tests/output/stbcc/reference.png", w, h, 1, map, 0); //reference(map, w, h); g = malloc(stbcc_grid_sizeof()); printf("Size: %d\n", stbcc_grid_sizeof()); #if 0 memset(map, 0, w*h); stbcc_init_grid(g, map, w, h); { int n; char **s = stb_stringfile("c:/x/clockwork_update.txt", &n); write_map(g, w, h, "tests/output/stbcc/base.png"); for (i=1; i < n; i += 1) { int x,y,t; sscanf(s[i], "%d %d %d", &x, &y, &t); if (i == 571678) write_map(g, w, h, stb_sprintf("tests/output/stbcc/clockwork_good.png", i)); stbcc_update_grid(g, x, y, t); if (i == 571678) write_map(g, w, h, stb_sprintf("tests/output/stbcc/clockwork_bad.png", i)); //if (i > 571648 && i <= 571712) //write_map(g, w, h, stb_sprintf("tests/output/stbcc/clockwork_%06d.png", i)); } write_map(g, w, h, stb_sprintf("tests/output/stbcc/clockwork_%06d.png", i-1)); } return 0; #endif start_timer("init"); stbcc_init_grid(g, map, w, h); end_timer(); //g = stb_file("c:/x/clockwork_path.bin", 0); write_map(g, w, h, "tests/output/stbcc/base.png"); for (i=0; i < 5000;) { loc[i][0] = stb_rand() % w; loc[i][1] = stb_rand() % h; if (stbcc_query_grid_open(g, loc[i][0], loc[i][1])) ++i; } r = 0; start_timer("reachable"); for (i=0; i < 2000; ++i) { for (j=0; j < 2000; ++j) { int x1 = loc[i][0], y1 = loc[i][1]; int x2 = loc[2000+j][0], y2 = loc[2000+j][1]; r += stbcc_query_grid_node_connection(g, x1,y1, x2,y2); } } end_timer(); printf("%d reachable\n", r); printf("Cluster size: %d,%d\n", STBCC__CLUSTER_SIZE_X, STBCC__CLUSTER_SIZE_Y); #if 1 for (j=0; j < 10; ++j) { for (i=0; i < 5000; ++i) { loc[i][0] = stb_rand() % w; loc[i][1] = stb_rand() % h; } start_timer("updating 2500"); for (i=0; i < 2500; ++i) { if (stbcc_query_grid_open(g, loc[i][0], loc[i][1])) stbcc_update_grid(g, loc[i][0], loc[i][1], 1); else stbcc_update_grid(g, loc[i][0], loc[i][1], 0); } end_timer(); write_map(g, w, h, stb_sprintf("tests/output/stbcc/update_random_%d.png", j*i)); } #endif #if 0 start_timer("removing"); count = 0; for (i=0; i < 1800; ++i) { int x,y,a,b; x = stb_rand() % (w-32); y = stb_rand() % (h-32); if (i & 1) { for (a=0; a < 32; ++a) for (b=0; b < 1; ++b) if (stbcc_query_grid_open(g, x+a, y+b)) { stbcc_update_grid(g, x+a, y+b, 1); ++count; } } else { for (a=0; a < 1; ++a) for (b=0; b < 32; ++b) if (stbcc_query_grid_open(g, x+a, y+b)) { stbcc_update_grid(g, x+a, y+b, 1); ++count; } } //if (i % 100 == 0) write_map(g, w, h, stb_sprintf("tests/output/stbcc/open_random_%d.png", i+1)); } end_timer(); printf("Removed %d grid spaces\n", count); write_map(g, w, h, stb_sprintf("tests/output/stbcc/open_random_%d.png", i)); r = 0; start_timer("reachable"); for (i=0; i < 1000; ++i) { for (j=0; j < 1000; ++j) { int x1 = loc[i][0], y1 = loc[i][1]; int x2 = loc[j][0], y2 = loc[j][1]; r += stbcc_query_grid_node_connection(g, x1,y1, x2,y2); } } end_timer(); printf("%d reachable\n", r); start_timer("adding"); count = 0; for (i=0; i < 1800; ++i) { int x,y,a,b; x = stb_rand() % (w-32); y = stb_rand() % (h-32); if (i & 1) { for (a=0; a < 32; ++a) for (b=0; b < 1; ++b) if (!stbcc_query_grid_open(g, x+a, y+b)) { stbcc_update_grid(g, x+a, y+b, 0); ++count; } } else { for (a=0; a < 1; ++a) for (b=0; b < 32; ++b) if (!stbcc_query_grid_open(g, x+a, y+b)) { stbcc_update_grid(g, x+a, y+b, 0); ++count; } } //if (i % 100 == 0) write_map(g, w, h, stb_sprintf("tests/output/stbcc/close_random_%d.png", i+1)); } end_timer(); write_map(g, w, h, stb_sprintf("tests/output/stbcc/close_random_%d.png", i)); printf("Added %d grid spaces\n", count); #endif #if 0 // for map_02.png start_timer("process"); for (k=0; k < 20; ++k) { for (j=0; j < h; ++j) { int any=0; for (i=0; i < w; ++i) { if (map[j*w+i] > 10 && map[j*w+i] < 250) { //start_timer(stb_sprintf("open %d,%d", i,j)); stbcc_update_grid(g, i, j, 0); test_connected(g); //end_timer(); any = 1; } } if (any) write_map(g, w, h, stb_sprintf("tests/output/stbcc/open_row_%04d.png", j)); } for (j=0; j < h; ++j) { int any=0; for (i=0; i < w; ++i) { if (map[j*w+i] > 10 && map[j*w+i] < 250) { //start_timer(stb_sprintf("close %d,%d", i,j)); stbcc_update_grid(g, i, j, 1); test_connected(g); //end_timer(); any = 1; } } if (any) write_map(g, w, h, stb_sprintf("tests/output/stbcc/close_row_%04d.png", j)); } } end_timer(); #endif return 0; } #endif uTox/third_party/stb/stb/tests/caveview/0000700000175000001440000000000014003056224017357 5ustar rakusersuTox/third_party/stb/stb/tests/caveview/win32/0000700000175000001440000000000014003056224020321 5ustar rakusersuTox/third_party/stb/stb/tests/caveview/win32/SDL_windows_main.c0000600000175000001440000001261614003056224023675 0ustar rakusers/* SDL_windows_main.c, placed in the public domain by Sam Lantinga 4/13/98 The WinMain function -- calls your program's main() function */ #include "SDL_config.h" #ifdef __WIN32__ //#include "../../core/windows/SDL_windows.h" /* Include this so we define UNICODE properly */ #if defined(__WIN32__) #define WIN32_LEAN_AND_MEAN #define STRICT #ifndef UNICODE #define UNICODE 1 #endif #undef _WIN32_WINNT #define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */ #endif #include /* Routines to convert from UTF8 to native Windows text */ #if UNICODE #define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) #define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1) #else /* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */ #define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1)) #define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1) #endif /* Sets an error message based on a given HRESULT */ extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr); /* Sets an error message based on GetLastError(). Always return -1. */ extern int WIN_SetError(const char *prefix); /* Wrap up the oddities of CoInitialize() into a common function. */ extern HRESULT WIN_CoInitialize(void); extern void WIN_CoUninitialize(void); /* Returns SDL_TRUE if we're running on Windows Vista and newer */ extern BOOL WIN_IsWindowsVistaOrGreater(); #include #include /* Include the SDL main definition header */ #include "SDL.h" #include "SDL_main.h" #ifdef main # undef main #endif /* main */ static void UnEscapeQuotes(char *arg) { char *last = NULL; while (*arg) { if (*arg == '"' && (last != NULL && *last == '\\')) { char *c_curr = arg; char *c_last = last; while (*c_curr) { *c_last = *c_curr; c_last = c_curr; c_curr++; } *c_last = '\0'; } last = arg; arg++; } } /* Parse a command line buffer into arguments */ static int ParseCommandLine(char *cmdline, char **argv) { char *bufp; char *lastp = NULL; int argc, last_argc; argc = last_argc = 0; for (bufp = cmdline; *bufp;) { /* Skip leading whitespace */ while (SDL_isspace(*bufp)) { ++bufp; } /* Skip over argument */ if (*bufp == '"') { ++bufp; if (*bufp) { if (argv) { argv[argc] = bufp; } ++argc; } /* Skip over word */ lastp = bufp; while (*bufp && (*bufp != '"' || *lastp == '\\')) { lastp = bufp; ++bufp; } } else { if (*bufp) { if (argv) { argv[argc] = bufp; } ++argc; } /* Skip over word */ while (*bufp && !SDL_isspace(*bufp)) { ++bufp; } } if (*bufp) { if (argv) { *bufp = '\0'; } ++bufp; } /* Strip out \ from \" sequences */ if (argv && last_argc != argc) { UnEscapeQuotes(argv[last_argc]); } last_argc = argc; } if (argv) { argv[argc] = NULL; } return (argc); } /* Show an error message */ static void ShowError(const char *title, const char *message) { /* If USE_MESSAGEBOX is defined, you need to link with user32.lib */ #ifdef USE_MESSAGEBOX MessageBox(NULL, message, title, MB_ICONEXCLAMATION | MB_OK); #else fprintf(stderr, "%s: %s\n", title, message); #endif } /* Pop up an out of memory message, returns to Windows */ static BOOL OutOfMemory(void) { ShowError("Fatal Error", "Out of memory - aborting"); return FALSE; } #if defined(_MSC_VER) /* The VC++ compiler needs main defined */ #define console_main main #endif /* This is where execution begins [console apps] */ int console_main(int argc, char *argv[]) { int status; SDL_SetMainReady(); /* Run the application main() code */ status = SDL_main(argc, argv); /* Exit cleanly, calling atexit() functions */ exit(status); /* Hush little compiler, don't you cry... */ return 0; } /* This is where execution begins [windowed apps] */ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) { char **argv; int argc; char *cmdline; /* Grab the command line */ TCHAR *text = GetCommandLine(); #if UNICODE cmdline = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(text), (SDL_wcslen(text)+1)*sizeof(WCHAR)); #else cmdline = SDL_strdup(text); #endif if (cmdline == NULL) { return OutOfMemory(); } /* Parse it into argv and argc */ argc = ParseCommandLine(cmdline, NULL); argv = SDL_stack_alloc(char *, argc + 1); if (argv == NULL) { return OutOfMemory(); } ParseCommandLine(cmdline, argv); /* Run the main program */ console_main(argc, argv); SDL_stack_free(argv); SDL_free(cmdline); /* Hush little compiler, don't you cry... */ return 0; } #endif /* __WIN32__ */ /* vi: set ts=4 sw=4 expandtab: */ uTox/third_party/stb/stb/tests/caveview/stb_glprog.h0000600000175000001440000004747314003056224021713 0ustar rakusers// stb_glprog v0.02 public domain functions to reduce GLSL boilerplate // http://nothings.org/stb/stb_glprog.h especially with GL1 + ARB extensions // // Following defines *before* including have following effects: // // STB_GLPROG_IMPLEMENTATION // creates the implementation // // STB_GLPROG_STATIC // forces the implementation to be static (private to file that creates it) // // STB_GLPROG_ARB // uses ARB extension names for GLSL functions and enumerants instead of core names // // STB_GLPROG_ARB_DEFINE_EXTENSIONS // instantiates function pointers needed, static to implementing file // to avoid collisions (but will collide if implementing file also // defines any; best to isolate this to its own file in this case). // This will try to automatically #include glext.h, but if it's not // in the default include directories you'll need to include it // yourself and define the next macro. // // STB_GLPROG_SUPPRESS_GLEXT_INCLUDE // disables the automatic #include of glext.h which is normally // forced by STB_GLPROG_ARB_DEFINE_EXTENSIONS // // So, e.g., sample usage on an old Windows compiler: // // #define STB_GLPROG_IMPLEMENTATION // #define STB_GLPROG_ARB_DEFINE_EXTENSIONS // #include // #include "gl/gl.h" // #include "stb_glprog.h" // // Note though that the header-file version of this (when you don't define // STB_GLPROG_IMPLEMENTATION) still uses GLint and such, so you basically // can only include it in places where you're already including GL, especially // on Windows where including "gl.h" requires (some of) "windows.h". // // See following comment blocks for function documentation. // // Version history: // 2013-12-08 v0.02 slightly simplified API and reduced GL resource usage (@rygorous) // 2013-12-08 v0.01 initial release // header file section starts here #if !defined(INCLUDE_STB_GLPROG_H) #define INCLUDE_STB_GLPROG_H #ifndef STB_GLPROG_STATIC #ifdef __cplusplus extern "C" { #endif ////////////////////////////////////////////////////////////////////////////// ///////////// SHADER CREATION /// EASY API extern GLuint stbgl_create_program(char const **vertex_source, char const **frag_source, char const **binds, char *error, int error_buflen); // This function returns a compiled program or 0 if there's an error. // To free the created program, call stbgl_delete_program. // // stbgl_create_program( // char **vertex_source, // NULL or one or more strings with the vertex shader source, with a final NULL // char **frag_source, // NULL or one or more strings with the fragment shader source, with a final NULL // char **binds, // NULL or zero or more strings with attribute bind names, with a final NULL // char *error, // output location where compile error message is placed // int error_buflen) // length of error output buffer // // Returns a GLuint with the GL program object handle. // // If an individual bind string is "", no name is bound to that slot (this // allows you to create binds that aren't continuous integers starting at 0). // // If the vertex shader is NULL, then fixed-function vertex pipeline // is used, if that's legal in your version of GL. // // If the fragment shader is NULL, then fixed-function fragment pipeline // is used, if that's legal in your version of GL. extern void stgbl_delete_program(GLuint program); // deletes a program created by stbgl_create_program or stbgl_link_program /// FLEXIBLE API extern GLuint stbgl_compile_shader(GLenum type, char const **sources, int num_sources, char *error, int error_buflen); // compiles a shader. returns the shader on success or 0 on failure. // // type either: GL_VERTEX_SHADER or GL_FRAGMENT_SHADER // or GL_VERTEX_SHADER_ARB or GL_FRAGMENT_SHADER_ARB // or STBGL_VERTEX_SHADER or STBGL_FRAGMENT_SHADER // sources array of strings containing the shader source // num_sources number of string in sources, or -1 meaning sources is NULL-terminated // error string to output compiler error to // error_buflen length of error buffer in chars extern GLuint stbgl_link_program(GLuint vertex_shader, GLuint fragment_shader, char const **binds, int num_binds, char *error, int error_buflen); // links a shader. returns the linked program on success or 0 on failure. // // vertex_shader a compiled vertex shader from stbgl_compile_shader, or 0 for fixed-function (if legal) // fragment_shader a compiled fragment shader from stbgl_compile_shader, or 0 for fixed-function (if legal) // extern void stbgl_delete_shader(GLuint shader); // deletes a shader created by stbgl_compile_shader ///////////// RENDERING WITH SHADERS extern GLint stbgl_find_uniform(GLuint prog, char *uniform); extern void stbgl_find_uniforms(GLuint prog, GLint *locations, char const **uniforms, int num_uniforms); // Given the locations array that is num_uniforms long, fills out // the locations of each of those uniforms for the specified program. // If num_uniforms is -1, then uniforms[] must be NULL-terminated // the following functions just wrap the difference in naming between GL2+ and ARB, // so you don't need them unless you're using both ARB and GL2+ in the same codebase, // or you're relying on this lib to provide the extensions extern void stbglUseProgram(GLuint program); extern void stbglVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer); extern void stbglEnableVertexAttribArray(GLuint index); extern void stbglDisableVertexAttribArray(GLuint index); extern void stbglUniform1fv(GLint loc, GLsizei count, const GLfloat *v); extern void stbglUniform2fv(GLint loc, GLsizei count, const GLfloat *v); extern void stbglUniform3fv(GLint loc, GLsizei count, const GLfloat *v); extern void stbglUniform4fv(GLint loc, GLsizei count, const GLfloat *v); extern void stbglUniform1iv(GLint loc, GLsizei count, const GLint *v); extern void stbglUniform2iv(GLint loc, GLsizei count, const GLint *v); extern void stbglUniform3iv(GLint loc, GLsizei count, const GLint *v); extern void stbglUniform4iv(GLint loc, GLsizei count, const GLint *v); extern void stbglUniform1f(GLint loc, float v0); extern void stbglUniform2f(GLint loc, float v0, float v1); extern void stbglUniform3f(GLint loc, float v0, float v1, float v2); extern void stbglUniform4f(GLint loc, float v0, float v1, float v2, float v3); extern void stbglUniform1i(GLint loc, GLint v0); extern void stbglUniform2i(GLint loc, GLint v0, GLint v1); extern void stbglUniform3i(GLint loc, GLint v0, GLint v1, GLint v2); extern void stbglUniform4i(GLint loc, GLint v0, GLint v1, GLint v2, GLint v3); ////////////// END OF FUNCTIONS ////////////////////////////////////////////////////////////////////////////// #ifdef __cplusplus } #endif #endif // STB_GLPROG_STATIC #ifdef STB_GLPROG_ARB #define STBGL_VERTEX_SHADER GL_VERTEX_SHADER_ARB #define STBGL_FRAGMENT_SHADER GL_FRAGMENT_SHADER_ARB #else #define STBGL_VERTEX_SHADER GL_VERTEX_SHADER #define STBGL_FRAGMENT_SHADER GL_FRAGMENT_SHADER #endif #endif // INCLUDE_STB_GLPROG_H ///////// header file section ends here #ifdef STB_GLPROG_IMPLEMENTATION #include // strncpy #ifdef STB_GLPROG_STATIC #define STB_GLPROG_DECLARE static #else #define STB_GLPROG_DECLARE extern #endif // check if user wants this file to define the GL extensions itself #ifdef STB_GLPROG_ARB_DEFINE_EXTENSIONS #define STB_GLPROG_ARB // make sure later code uses the extensions #ifndef STB_GLPROG_SUPPRESS_GLEXT_INCLUDE #include "glext.h" #endif #define STB_GLPROG_EXTENSIONS \ STB_GLPROG_FUNC(ATTACHOBJECT , AttachObject ) \ STB_GLPROG_FUNC(BINDATTRIBLOCATION , BindAttribLocation ) \ STB_GLPROG_FUNC(COMPILESHADER , CompileShader ) \ STB_GLPROG_FUNC(CREATEPROGRAMOBJECT , CreateProgramObject ) \ STB_GLPROG_FUNC(CREATESHADEROBJECT , CreateShaderObject ) \ STB_GLPROG_FUNC(DELETEOBJECT , DeleteObject ) \ STB_GLPROG_FUNC(DETACHOBJECT , DetachObject ) \ STB_GLPROG_FUNC(DISABLEVERTEXATTRIBARRAY, DisableVertexAttribArray) \ STB_GLPROG_FUNC(ENABLEVERTEXATTRIBARRAY, EnableVertexAttribArray ) \ STB_GLPROG_FUNC(GETATTACHEDOBJECTS , GetAttachedObjects ) \ STB_GLPROG_FUNC(GETOBJECTPARAMETERIV, GetObjectParameteriv) \ STB_GLPROG_FUNC(GETINFOLOG , GetInfoLog ) \ STB_GLPROG_FUNC(GETUNIFORMLOCATION , GetUniformLocation ) \ STB_GLPROG_FUNC(LINKPROGRAM , LinkProgram ) \ STB_GLPROG_FUNC(SHADERSOURCE , ShaderSource ) \ STB_GLPROG_FUNC(UNIFORM1F , Uniform1f ) \ STB_GLPROG_FUNC(UNIFORM2F , Uniform2f ) \ STB_GLPROG_FUNC(UNIFORM3F , Uniform3f ) \ STB_GLPROG_FUNC(UNIFORM4F , Uniform4f ) \ STB_GLPROG_FUNC(UNIFORM1I , Uniform1i ) \ STB_GLPROG_FUNC(UNIFORM2I , Uniform2i ) \ STB_GLPROG_FUNC(UNIFORM3I , Uniform3i ) \ STB_GLPROG_FUNC(UNIFORM4I , Uniform4i ) \ STB_GLPROG_FUNC(UNIFORM1FV , Uniform1fv ) \ STB_GLPROG_FUNC(UNIFORM2FV , Uniform2fv ) \ STB_GLPROG_FUNC(UNIFORM3FV , Uniform3fv ) \ STB_GLPROG_FUNC(UNIFORM4FV , Uniform4fv ) \ STB_GLPROG_FUNC(UNIFORM1IV , Uniform1iv ) \ STB_GLPROG_FUNC(UNIFORM2IV , Uniform2iv ) \ STB_GLPROG_FUNC(UNIFORM3IV , Uniform3iv ) \ STB_GLPROG_FUNC(UNIFORM4IV , Uniform4iv ) \ STB_GLPROG_FUNC(USEPROGRAMOBJECT , UseProgramObject ) \ STB_GLPROG_FUNC(VERTEXATTRIBPOINTER , VertexAttribPointer ) // define the static function pointers #define STB_GLPROG_FUNC(x,y) static PFNGL##x##ARBPROC gl##y##ARB; STB_GLPROG_EXTENSIONS #undef STB_GLPROG_FUNC // define the GetProcAddress #ifdef _WIN32 #ifndef WINGDIAPI #ifndef STB__HAS_WGLPROC typedef int (__stdcall *stbgl__voidfunc)(void); static __declspec(dllimport) stbgl__voidfunc wglGetProcAddress(char *); #endif #endif #define STBGL__GET_FUNC(x) wglGetProcAddress(x) #else #error "need to define how this platform gets extensions" #endif // create a function that fills out the function pointers static void stb_glprog_init(void) { static int initialized = 0; // not thread safe! if (initialized) return; #define STB_GLPROG_FUNC(x,y) gl##y##ARB = (PFNGL##x##ARBPROC) STBGL__GET_FUNC("gl" #y "ARB"); STB_GLPROG_EXTENSIONS #undef STB_GLPROG_FUNC } #undef STB_GLPROG_EXTENSIONS #else static void stb_glprog_init(void) { } #endif // define generic names for many of the gl functions or extensions for later use; // note that in some cases there are two functions in core and one function in ARB #ifdef STB_GLPROG_ARB #define stbglCreateShader glCreateShaderObjectARB #define stbglDeleteShader glDeleteObjectARB #define stbglAttachShader glAttachObjectARB #define stbglDetachShader glDetachObjectARB #define stbglShaderSource glShaderSourceARB #define stbglCompileShader glCompileShaderARB #define stbglGetShaderStatus(a,b) glGetObjectParameterivARB(a, GL_OBJECT_COMPILE_STATUS_ARB, b) #define stbglGetShaderInfoLog glGetInfoLogARB #define stbglCreateProgram glCreateProgramObjectARB #define stbglDeleteProgram glDeleteObjectARB #define stbglLinkProgram glLinkProgramARB #define stbglGetProgramStatus(a,b) glGetObjectParameterivARB(a, GL_OBJECT_LINK_STATUS_ARB, b) #define stbglGetProgramInfoLog glGetInfoLogARB #define stbglGetAttachedShaders glGetAttachedObjectsARB #define stbglBindAttribLocation glBindAttribLocationARB #define stbglGetUniformLocation glGetUniformLocationARB #define stbgl_UseProgram glUseProgramObjectARB #else #define stbglCreateShader glCreateShader #define stbglDeleteShader glDeleteShader #define stbglAttachShader glAttachShader #define stbglDetachShader glDetachShader #define stbglShaderSource glShaderSource #define stbglCompileShader glCompileShader #define stbglGetShaderStatus(a,b) glGetShaderiv(a, GL_COMPILE_STATUS, b) #define stbglGetShaderInfoLog glGetShaderInfoLog #define stbglCreateProgram glCreateProgram #define stbglDeleteProgram glDeleteProgram #define stbglLinkProgram glLinkProgram #define stbglGetProgramStatus(a,b) glGetProgramiv(a, GL_LINK_STATUS, b) #define stbglGetProgramInfoLog glGetProgramInfoLog #define stbglGetAttachedShaders glGetAttachedShaders #define stbglBindAttribLocation glBindAttribLocation #define stbglGetUniformLocation glGetUniformLocation #define stbgl_UseProgram glUseProgram #endif // perform a safe strcat of 3 strings, given that we can't rely on portable snprintf // if you need to break on error, this is the best place to place a breakpoint static void stb_glprog_error(char *error, int error_buflen, char *str1, char *str2, char *str3) { int n = strlen(str1); strncpy(error, str1, error_buflen); if (n < error_buflen && str2) { strncpy(error+n, str2, error_buflen - n); n += strlen(str2); if (n < error_buflen && str3) { strncpy(error+n, str3, error_buflen - n); } } error[error_buflen-1] = 0; } STB_GLPROG_DECLARE GLuint stbgl_compile_shader(GLenum type, char const **sources, int num_sources, char *error, int error_buflen) { char *typename = (type == STBGL_VERTEX_SHADER ? "vertex" : "fragment"); int len; GLint result; GLuint shader; // initialize the extensions if we haven't already stb_glprog_init(); // allocate shader = stbglCreateShader(type); if (!shader) { stb_glprog_error(error, error_buflen, "Couldn't allocate shader object in stbgl_compile_shader for ", typename, NULL); return 0; } // compile // if num_sources is negative, assume source is NULL-terminated and count the non-NULL ones if (num_sources < 0) for (num_sources = 0; sources[num_sources] != NULL; ++num_sources) ; stbglShaderSource(shader, num_sources, sources, NULL); stbglCompileShader(shader); stbglGetShaderStatus(shader, &result); if (result) return shader; // errors stb_glprog_error(error, error_buflen, "Compile error for ", typename, " shader: "); len = strlen(error); if (len < error_buflen) stbglGetShaderInfoLog(shader, error_buflen-len, NULL, error+len); stbglDeleteShader(shader); return 0; } STB_GLPROG_DECLARE GLuint stbgl_link_program(GLuint vertex_shader, GLuint fragment_shader, char const **binds, int num_binds, char *error, int error_buflen) { int len; GLint result; // allocate GLuint prog = stbglCreateProgram(); if (!prog) { stb_glprog_error(error, error_buflen, "Couldn't allocate program object in stbgl_link_program", NULL, NULL); return 0; } // attach if (vertex_shader) stbglAttachShader(prog, vertex_shader); if (fragment_shader) stbglAttachShader(prog, fragment_shader); // attribute binds if (binds) { int i; // if num_binds is negative, then it is NULL terminated if (num_binds < 0) for (num_binds=0; binds[num_binds]; ++num_binds) ; for (i=0; i < num_binds; ++i) if (binds[i] && binds[i][0]) // empty binds can be NULL or "" stbglBindAttribLocation(prog, i, binds[i]); } // link stbglLinkProgram(prog); // detach if (vertex_shader) stbglDetachShader(prog, vertex_shader); if (fragment_shader) stbglDetachShader(prog, fragment_shader); // errors stbglGetProgramStatus(prog, &result); if (result) return prog; stb_glprog_error(error, error_buflen, "Link error: ", NULL, NULL); len = strlen(error); if (len < error_buflen) stbglGetProgramInfoLog(prog, error_buflen-len, NULL, error+len); stbglDeleteProgram(prog); return 0; } STB_GLPROG_DECLARE GLuint stbgl_create_program(char const **vertex_source, char const **frag_source, char const **binds, char *error, int error_buflen) { GLuint vertex, fragment, prog=0; vertex = stbgl_compile_shader(STBGL_VERTEX_SHADER, vertex_source, -1, error, error_buflen); if (vertex) { fragment = stbgl_compile_shader(STBGL_FRAGMENT_SHADER, frag_source, -1, error, error_buflen); if (fragment) prog = stbgl_link_program(vertex, fragment, binds, -1, error, error_buflen); if (fragment) stbglDeleteShader(fragment); stbglDeleteShader(vertex); } return prog; } STB_GLPROG_DECLARE void stbgl_delete_shader(GLuint shader) { stbglDeleteShader(shader); } STB_GLPROG_DECLARE void stgbl_delete_program(GLuint program) { stbglDeleteProgram(program); } GLint stbgl_find_uniform(GLuint prog, char *uniform) { return stbglGetUniformLocation(prog, uniform); } STB_GLPROG_DECLARE void stbgl_find_uniforms(GLuint prog, GLint *locations, char const **uniforms, int num_uniforms) { int i; if (num_uniforms < 0) num_uniforms = 999999; for (i=0; i < num_uniforms && uniforms[i]; ++i) locations[i] = stbglGetUniformLocation(prog, uniforms[i]); } STB_GLPROG_DECLARE void stbglUseProgram(GLuint program) { stbgl_UseProgram(program); } #ifdef STB_GLPROG_ARB #define STBGL_ARBIFY(name) name##ARB #else #define STBGL_ARBIFY(name) name #endif STB_GLPROG_DECLARE void stbglVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer) { STBGL_ARBIFY(glVertexAttribPointer)(index, size, type, normalized, stride, pointer); } STB_GLPROG_DECLARE void stbglEnableVertexAttribArray (GLuint index) { STBGL_ARBIFY(glEnableVertexAttribArray )(index); } STB_GLPROG_DECLARE void stbglDisableVertexAttribArray(GLuint index) { STBGL_ARBIFY(glDisableVertexAttribArray)(index); } STB_GLPROG_DECLARE void stbglUniform1fv(GLint loc, GLsizei count, const GLfloat *v) { STBGL_ARBIFY(glUniform1fv)(loc,count,v); } STB_GLPROG_DECLARE void stbglUniform2fv(GLint loc, GLsizei count, const GLfloat *v) { STBGL_ARBIFY(glUniform2fv)(loc,count,v); } STB_GLPROG_DECLARE void stbglUniform3fv(GLint loc, GLsizei count, const GLfloat *v) { STBGL_ARBIFY(glUniform3fv)(loc,count,v); } STB_GLPROG_DECLARE void stbglUniform4fv(GLint loc, GLsizei count, const GLfloat *v) { STBGL_ARBIFY(glUniform4fv)(loc,count,v); } STB_GLPROG_DECLARE void stbglUniform1iv(GLint loc, GLsizei count, const GLint *v) { STBGL_ARBIFY(glUniform1iv)(loc,count,v); } STB_GLPROG_DECLARE void stbglUniform2iv(GLint loc, GLsizei count, const GLint *v) { STBGL_ARBIFY(glUniform2iv)(loc,count,v); } STB_GLPROG_DECLARE void stbglUniform3iv(GLint loc, GLsizei count, const GLint *v) { STBGL_ARBIFY(glUniform3iv)(loc,count,v); } STB_GLPROG_DECLARE void stbglUniform4iv(GLint loc, GLsizei count, const GLint *v) { STBGL_ARBIFY(glUniform4iv)(loc,count,v); } STB_GLPROG_DECLARE void stbglUniform1f(GLint loc, float v0) { STBGL_ARBIFY(glUniform1f)(loc,v0); } STB_GLPROG_DECLARE void stbglUniform2f(GLint loc, float v0, float v1) { STBGL_ARBIFY(glUniform2f)(loc,v0,v1); } STB_GLPROG_DECLARE void stbglUniform3f(GLint loc, float v0, float v1, float v2) { STBGL_ARBIFY(glUniform3f)(loc,v0,v1,v2); } STB_GLPROG_DECLARE void stbglUniform4f(GLint loc, float v0, float v1, float v2, float v3) { STBGL_ARBIFY(glUniform4f)(loc,v0,v1,v2,v3); } STB_GLPROG_DECLARE void stbglUniform1i(GLint loc, GLint v0) { STBGL_ARBIFY(glUniform1i)(loc,v0); } STB_GLPROG_DECLARE void stbglUniform2i(GLint loc, GLint v0, GLint v1) { STBGL_ARBIFY(glUniform2i)(loc,v0,v1); } STB_GLPROG_DECLARE void stbglUniform3i(GLint loc, GLint v0, GLint v1, GLint v2) { STBGL_ARBIFY(glUniform3i)(loc,v0,v1,v2); } STB_GLPROG_DECLARE void stbglUniform4i(GLint loc, GLint v0, GLint v1, GLint v2, GLint v3) { STBGL_ARBIFY(glUniform4i)(loc,v0,v1,v2,v3); } #endif uTox/third_party/stb/stb/tests/caveview/stb_gl.h0000600000175000001440000011233314003056224021007 0ustar rakusers// stbgl - v0.04 - Sean Barrett 2008 - public domain // // Note that the gl extensions support requires glext.h. In fact, it works // if you just concatenate glext.h onto the end of this file. In that case, // this file is covered by the SGI FreeB license, and is not public domain. // // Extension usage: // // 1. Make a file called something like "extlist.txt" which contains stuff like: // GLE(ShaderSourceARB,SHADERSOURCEARB) // GLE(Uniform1iARB,UNIFORM1IARB) // GLARB(ActiveTexture,ACTIVETEXTURE) // same as GLE(ActiveTextureARB,ACTIVETEXTUREARB) // GLARB(ClientActiveTexture,CLIENTACTIVETEXTURE) // GLE(MultiTexCoord2f,MULTITEXCOORD2F) // // 2. To declare functions (to make a header file), do this: // #define STB_GLEXT_DECLARE "extlist.txt" // #include "stb_gl.h" // // A good way to do this is to define STB_GLEXT_DECLARE project-wide. // // 3. To define functions (implement), do this in some C file: // #define STB_GLEXT_DEFINE "extlist.txt" // #include "stb_gl.h" // // If you've already defined STB_GLEXT_DECLARE, you can just do: // #define STB_GLEXT_DEFINE_DECLARE // #include "stb_gl.h" // // 4. Now you need to initialize: // // stbgl_initExtensions(); #ifndef INCLUDE_STB_GL_H #define INCLUDE_STB_GL_H #define STB_GL #ifdef _WIN32 #ifndef WINGDIAPI #define CALLBACK __stdcall #define WINGDIAPI __declspec(dllimport) #define APIENTRY __stdcall #endif #endif //_WIN32 #include #include #include #ifndef M_PI #define M_PI 3.14159265358979323846f #endif #ifdef __cplusplus extern "C" { #endif // like gluPerspective, but: // fov is chosen to satisfy both hfov <= max_hfov & vfov <= max_vfov; // set one to 179 or 0 to ignore it // zoom is applied separately, so you can do linear zoom without // mucking with trig with fov; 1 -> use exact fov // 'aspect' is inferred from the current viewport, and ignores the // possibility of non-square pixels extern void stbgl_Perspective(float zoom, float max_hfov, float max_vfov, float znear, float zfar); extern void stbgl_PerspectiveViewport(int x, int y, int w, int h, float zoom, float max_hfov, float max_vfov, float znear, float zfar); extern void stbgl_initCamera_zup_facing_x(void); extern void stbgl_initCamera_zup_facing_y(void); extern void stbgl_positionCameraWithEulerAngles(float *loc, float *ang); extern void stbgl_drawRect(float x0, float y0, float x1, float y1); extern void stbgl_drawRectTC(float x0, float y0, float x1, float y1, float s0, float t0, float s1, float t1); extern void stbgl_drawBox(float x, float y, float z, float sx, float sy, float sz, int cw); extern int stbgl_hasExtension(char *ext); extern void stbgl_SimpleLight(int index, float bright, float x, float y, float z); extern void stbgl_GlobalAmbient(float r, float g, float b); extern int stbgl_LoadTexture(char *filename, char *props); // only if stb_image is available extern int stbgl_TestTexture(int w); extern int stbgl_TestTextureEx(int w, char *scale_table, int checks_log2, int r1,int g1,int b1, int r2, int b2, int g2); extern unsigned int stbgl_rand(void); // internal, but exposed just in case; LCG, so use middle bits extern int stbgl_TexImage2D(int texid, int w, int h, void *data, char *props); extern int stbgl_TexImage2D_Extra(int texid, int w, int h, void *data, int chan, char *props, int preserve_data); // "props" is a series of characters (and blocks of characters), a la fopen()'s mode, // e.g.: // GLuint texid = stbgl_LoadTexture("myfile.jpg", "mbc") // means: load the image "myfile.jpg", and do the following: // generate mipmaps // use bilinear filtering (not trilinear) // use clamp-to-edge on both channels // // input descriptor: AT MOST ONE // TEXT MEANING // 1 1 channel of input (intensity/alpha) // 2 2 channels of input (luminance, alpha) // 3 3 channels of input (RGB) // 4 4 channels of input (RGBA) // l 1 channel of input (luminance) // a 1 channel of input (alpha) // la 2 channels of input (lum/alpha) // rgb 3 channels of input (RGB) // ycocg 3 channels of input (YCoCg - forces YCoCg output) // ycocgj 4 channels of input (YCoCgJunk - forces YCoCg output) // rgba 4 channels of input (RGBA) // // output descriptor: AT MOST ONE // TEXT MEANING // A 1 channel of output (alpha) // I 1 channel of output (intensity) // LA 2 channels of output (lum/alpha) // RGB 3 channels of output (RGB) // RGBA 4 channels of output (RGBA) // DXT1 encode as a DXT1 texture (RGB unless input has RGBA) // DXT3 encode as a DXT3 texture // DXT5 encode as a DXT5 texture // YCoCg encode as a DXT5 texture with Y in alpha, CoCg in RG // D GL_DEPTH_COMPONENT // NONE no input/output, don't call TexImage2D at all // // when reading from a file or using another interface with an explicit // channel count, the input descriptor is ignored and instead the channel // count is used as the input descriptor. if the file read is a DXT DDS, // then it is passed directly to OpenGL in the file format. // // if an input descriptor is supplied but no output descriptor, the output // is assumed to be the same as the input. if an output descriptor is supplied // but no input descriptor, the input is assumed to be the same as the // output. if neither is supplied, the input is assumed to be 4-channel. // If DXT1 or YCoCG output is requested with no input, the input is assumed // to be 4-channel but the alpha channel is ignored. // // filtering descriptor (default is no mipmaps) // TEXT MEANING // m generate mipmaps // M mipmaps are provided, concatenated at end of data (from largest to smallest) // t use trilinear filtering (default if mipmapped) // b use bilinear filtering (default if not-mipmapped) // n use nearest-neighbor sampling // // wrapping descriptor // TEXT MEANING // w wrap (default) // c clamp-to-edge // C GL_CLAMP (uses border color) // // If only one wrapping descriptor is supplied, it is applied to both channels. // // special: // TEXT MEANING // f input data is floats (default unsigned bytes) // F input&output data is floats (default unsigned bytes) // p explicitly pre-multiply the alpha // P pad to power-of-two (default stretches) // NP2 non-power-of-two // + can overwrite the texture data with temp data // ! free the texture data with "free" // // the properties string can also include spaces #ifdef __cplusplus } #endif #ifdef STB_GL_IMPLEMENTATION #include #include #include #include int stbgl_hasExtension(char *ext) { const char *s = glGetString(GL_EXTENSIONS); for(;;) { char *e = ext; for (;;) { if (*e == 0) { if (*s == 0 || *s == ' ') return 1; break; } if (*s != *e) break; ++s, ++e; } while (*s && *s != ' ') ++s; if (!*s) return 0; ++s; // skip space } } void stbgl_drawRect(float x0, float y0, float x1, float y1) { glBegin(GL_POLYGON); glTexCoord2f(0,0); glVertex2f(x0,y0); glTexCoord2f(1,0); glVertex2f(x1,y0); glTexCoord2f(1,1); glVertex2f(x1,y1); glTexCoord2f(0,1); glVertex2f(x0,y1); glEnd(); } void stbgl_drawRectTC(float x0, float y0, float x1, float y1, float s0, float t0, float s1, float t1) { glBegin(GL_POLYGON); glTexCoord2f(s0,t0); glVertex2f(x0,y0); glTexCoord2f(s1,t0); glVertex2f(x1,y0); glTexCoord2f(s1,t1); glVertex2f(x1,y1); glTexCoord2f(s0,t1); glVertex2f(x0,y1); glEnd(); } void stbgl_drawBox(float x, float y, float z, float sx, float sy, float sz, int cw) { float x0,y0,z0,x1,y1,z1; sx /=2, sy/=2, sz/=2; x0 = x-sx; y0 = y-sy; z0 = z-sz; x1 = x+sx; y1 = y+sy; z1 = z+sz; glBegin(GL_QUADS); if (cw) { glNormal3f(0,0,-1); glTexCoord2f(0,0); glVertex3f(x0,y0,z0); glTexCoord2f(1,0); glVertex3f(x1,y0,z0); glTexCoord2f(1,1); glVertex3f(x1,y1,z0); glTexCoord2f(0,1); glVertex3f(x0,y1,z0); glNormal3f(0,0,1); glTexCoord2f(0,0); glVertex3f(x1,y0,z1); glTexCoord2f(1,0); glVertex3f(x0,y0,z1); glTexCoord2f(1,1); glVertex3f(x0,y1,z1); glTexCoord2f(0,1); glVertex3f(x1,y1,z1); glNormal3f(-1,0,0); glTexCoord2f(0,0); glVertex3f(x0,y1,z1); glTexCoord2f(1,0); glVertex3f(x0,y0,z1); glTexCoord2f(1,1); glVertex3f(x0,y0,z0); glTexCoord2f(0,1); glVertex3f(x0,y1,z0); glNormal3f(1,0,0); glTexCoord2f(0,0); glVertex3f(x1,y0,z1); glTexCoord2f(1,0); glVertex3f(x1,y1,z1); glTexCoord2f(1,1); glVertex3f(x1,y1,z0); glTexCoord2f(0,1); glVertex3f(x1,y0,z0); glNormal3f(0,-1,0); glTexCoord2f(0,0); glVertex3f(x0,y0,z1); glTexCoord2f(1,0); glVertex3f(x1,y0,z1); glTexCoord2f(1,1); glVertex3f(x1,y0,z0); glTexCoord2f(0,1); glVertex3f(x0,y0,z0); glNormal3f(0,1,0); glTexCoord2f(0,0); glVertex3f(x1,y1,z1); glTexCoord2f(1,0); glVertex3f(x0,y1,z1); glTexCoord2f(1,1); glVertex3f(x0,y1,z0); glTexCoord2f(0,1); glVertex3f(x1,y1,z0); } else { glNormal3f(0,0,-1); glTexCoord2f(0,0); glVertex3f(x0,y0,z0); glTexCoord2f(0,1); glVertex3f(x0,y1,z0); glTexCoord2f(1,1); glVertex3f(x1,y1,z0); glTexCoord2f(1,0); glVertex3f(x1,y0,z0); glNormal3f(0,0,1); glTexCoord2f(0,0); glVertex3f(x1,y0,z1); glTexCoord2f(0,1); glVertex3f(x1,y1,z1); glTexCoord2f(1,1); glVertex3f(x0,y1,z1); glTexCoord2f(1,0); glVertex3f(x0,y0,z1); glNormal3f(-1,0,0); glTexCoord2f(0,0); glVertex3f(x0,y1,z1); glTexCoord2f(0,1); glVertex3f(x0,y1,z0); glTexCoord2f(1,1); glVertex3f(x0,y0,z0); glTexCoord2f(1,0); glVertex3f(x0,y0,z1); glNormal3f(1,0,0); glTexCoord2f(0,0); glVertex3f(x1,y0,z1); glTexCoord2f(0,1); glVertex3f(x1,y0,z0); glTexCoord2f(1,1); glVertex3f(x1,y1,z0); glTexCoord2f(1,0); glVertex3f(x1,y1,z1); glNormal3f(0,-1,0); glTexCoord2f(0,0); glVertex3f(x0,y0,z1); glTexCoord2f(0,1); glVertex3f(x0,y0,z0); glTexCoord2f(1,1); glVertex3f(x1,y0,z0); glTexCoord2f(1,0); glVertex3f(x1,y0,z1); glNormal3f(0,1,0); glTexCoord2f(0,0); glVertex3f(x1,y1,z1); glTexCoord2f(0,1); glVertex3f(x1,y1,z0); glTexCoord2f(1,1); glVertex3f(x0,y1,z0); glTexCoord2f(1,0); glVertex3f(x0,y1,z1); } glEnd(); } void stbgl_SimpleLight(int index, float bright, float x, float y, float z) { float d = (float) (1.0f/sqrt(x*x+y*y+z*z)); float dir[4] = { x*d,y*d,z*d,0 }, zero[4] = { 0,0,0,0 }; float c[4] = { bright,bright,bright,0 }; GLuint light = GL_LIGHT0 + index; glLightfv(light, GL_POSITION, dir); glLightfv(light, GL_DIFFUSE, c); glLightfv(light, GL_AMBIENT, zero); glLightfv(light, GL_SPECULAR, zero); glEnable(light); glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); } void stbgl_GlobalAmbient(float r, float g, float b) { float v[4] = { r,g,b,0 }; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, v); } #define stbgl_rad2deg(r) ((r)*180.0f / M_PI) #define stbgl_deg2rad(r) ((r)/180.0f * M_PI) void stbgl_Perspective(float zoom, float max_hfov, float max_vfov, float znear, float zfar) { float unit_width, unit_height, aspect, vfov; int data[4],w,h; glGetIntegerv(GL_VIEWPORT, data); w = data[2]; h = data[3]; aspect = (float) w / h; if (max_hfov <= 0) max_hfov = 179; if (max_vfov <= 0) max_vfov = 179; // convert max_hfov, max_vfov to worldspace width at depth=1 unit_width = (float) tan(stbgl_deg2rad(max_hfov/2)) * 2; unit_height = (float) tan(stbgl_deg2rad(max_vfov/2)) * 2; // check if hfov = max_hfov is enough to satisfy it if (unit_width <= aspect * unit_height) { float height = unit_width / aspect; vfov = (float) atan(( height/2) / zoom); } else { vfov = (float) atan((unit_height/2) / zoom); } vfov = (float) stbgl_rad2deg(vfov * 2); gluPerspective(vfov, aspect, znear, zfar); } void stbgl_PerspectiveViewport(int x, int y, int w, int h, float zoom, float min_hfov, float min_vfov, float znear, float zfar) { if (znear <= 0.0001f) znear = 0.0001f; glViewport(x,y,w,h); glScissor(x,y,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); stbgl_Perspective(zoom, min_hfov, min_vfov, znear, zfar); glMatrixMode(GL_MODELVIEW); } // point the camera along the positive X axis, Z-up void stbgl_initCamera_zup_facing_x(void) { glRotatef(-90, 1,0,0); glRotatef( 90, 0,0,1); } // point the camera along the positive Y axis, Z-up void stbgl_initCamera_zup_facing_y(void) { glRotatef(-90, 1,0,0); } // setup a camera using Euler angles void stbgl_positionCameraWithEulerAngles(float *loc, float *ang) { glRotatef(-ang[1], 0,1,0); glRotatef(-ang[0], 1,0,0); glRotatef(-ang[2], 0,0,1); glTranslatef(-loc[0], -loc[1], -loc[2]); } static int stbgl_m(char *a, char *b) { // skip first character do { ++a,++b; } while (*b && *a == *b); return *b == 0; } #ifdef STBI_VERSION #ifndef STBI_NO_STDIO int stbgl_LoadTexture(char *filename, char *props) { // @TODO: handle DDS files directly int res; void *data; int w,h,c; #ifndef STBI_NO_HDR if (stbi_is_hdr(filename)) { data = stbi_loadf(filename, &w, &h, &c, 0); if (!data) return 0; res = stbgl_TexImage2D_Extra(0, w,h,data, -c, props, 0); free(data); return res; } #endif data = stbi_load(filename, &w, &h, &c, 0); if (!data) return 0; res = stbgl_TexImage2D_Extra(0, w,h,data, c, props, 0); free(data); return res; } #endif #endif // STBI_VERSION int stbgl_TexImage2D(int texid, int w, int h, void *data, char *props) { return stbgl_TexImage2D_Extra(texid, w, h, data, 0, props,1); } int stbgl_TestTexture(int w) { char scale_table[] = { 10,20,30,30,35,40,5,18,25,13,7,5,3,3,2,2,2,2,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0 }; return stbgl_TestTextureEx(w, scale_table, 2, 140,130,200, 180,200,170); } unsigned int stbgl_rand(void) { static unsigned int stbgl__rand_seed = 3248980923; // random typing return stbgl__rand_seed = stbgl__rand_seed * 2147001325 + 715136305; // BCPL generator } // wish this could be smaller, since it's so frivolous int stbgl_TestTextureEx(int w, char *scale_table, int checks_log2, int r1,int g1,int b1, int r2, int b2, int g2) { int rt[2] = {r1,r2}, gt[2] = {g1,g2}, bt[2] = {b1,b2}; signed char modded[256]; int i,j, m = w-1, s,k,scale; unsigned char *data = (unsigned char *) malloc(w*w*3); assert((m & w) == 0); data[0] = 128; for (s=0; s < 16; ++s) if ((1 << s) == w) break; assert(w == (1 << s)); // plasma fractal noise for (k=s-1; k >= 0; --k) { int step = 1 << k; // interpolate from "parents" for (j=0; j < w; j += step*2) { for (i=0; i < w; i += step*2) { int i1 = i+step, j1=j+step; int i2 = (i+step*2)&m, j2 = (j+step*2)&m; int p00 = data[(j*w+i )*3], p01 = data[(j2*w+i )*3]; int p10 = data[(j*w+i2)*3], p11 = data[(j2*w+i2)*3]; data[(j*w+i1)*3] = (p00+p10)>>1; data[(j1*w+i)*3] = (p00+p01)>>1; data[(j1*w+i1)*3]= (p00+p01+p10+p11)>>2; } } scale = scale_table[s-k+1]; if (!scale) continue; // just interpolate down the remaining data for (j=0,i=0; i < 256; i += 2, j == scale ? j=0 : ++j) modded[i] = j, modded[i+1] = -j; // precompute i%scale (plus sign) for (j=0; j < w; j += step) for (i=0; i < w; i += step) { int x = data[(j*w+i)*3] + modded[(stbgl_rand() >> 12) & 255]; data[(j*w+i)*3] = x < 0 ? 0 : x > 255 ? 255 : x; } } for (j=0; j < w; ++j) for (i=0; i < w; ++i) { int check = ((i^j) & (1 << (s-checks_log2))) == 0; int v = data[(j*w+i)*3] >> 2; data[(j*w+i)*3+0] = rt[check]-v; data[(j*w+i)*3+1] = gt[check]-v; data[(j*w+i)*3+2] = bt[check]-v; } return stbgl_TexImage2D(0, w, w, data, "3m!"); // 3 channels, mipmap, free } #ifdef _WIN32 #ifndef WINGDIAPI typedef int (__stdcall *stbgl__voidfunc)(void); __declspec(dllimport) stbgl__voidfunc wglGetProcAddress(char *); #endif #define STB__HAS_WGLPROC static void (__stdcall *stbgl__CompressedTexImage2DARB)(int target, int level, int internalformat, int width, int height, int border, int imageSize, void *data); static void stbgl__initCompTex(void) { *((void **) &stbgl__CompressedTexImage2DARB) = (void *) wglGetProcAddress("glCompressedTexImage2DARB"); } #else static void (*stbgl__CompressedTexImage2DARB)(int target, int level, int internalformat, int width, int height, int border, int imageSize, void *data); static void stbgl__initCompTex(void) { } #endif // _WIN32 #define STBGL_COMPRESSED_RGB_S3TC_DXT1 0x83F0 #define STBGL_COMPRESSED_RGBA_S3TC_DXT1 0x83F1 #define STBGL_COMPRESSED_RGBA_S3TC_DXT3 0x83F2 #define STBGL_COMPRESSED_RGBA_S3TC_DXT5 0x83F3 #ifdef STB_COMPRESS_DXT_BLOCK static void stbgl__convert(uint8 *p, uint8 *q, int n, int input_desc, uint8 *end) { int i; switch (input_desc) { case GL_RED: case GL_LUMINANCE: for (i=0; i < n; ++i,p+=4) p[0] = p[1] = p[2] = q[0], p[3]=255, q+=1; break; case GL_ALPHA: for (i=0; i < n; ++i,p+=4) p[0] = p[1] = p[2] = 0, p[3] = q[0], q+=1; break; case GL_LUMINANCE_ALPHA: for (i=0; i < n; ++i,p+=4) p[0] = p[1] = p[2] = q[0], p[3]=q[1], q+=2; break; case GL_RGB: for (i=0; i < n; ++i,p+=4) p[0]=q[0],p[1]=q[1],p[2]=q[2],p[3]=255,q+=3; break; case GL_RGBA: memcpy(p, q, n*4); break; case GL_INTENSITY: for (i=0; i < n; ++i,p+=4) p[0] = p[1] = p[2] = p[3] = q[0], q+=1; break; } assert(p <= end); } static void stbgl__compress(uint8 *p, uint8 *rgba, int w, int h, int output_desc, uint8 *end) { int i,j,y,y2; int alpha = (output_desc == STBGL_COMPRESSED_RGBA_S3TC_DXT5); for (j=0; j < w; j += 4) { int x=4; for (i=0; i < h; i += 4) { uint8 block[16*4]; if (i+3 >= w) x = w-i; for (y=0; y < 4; ++y) { if (j+y >= h) break; memcpy(block+y*16, rgba + w*4*(j+y) + i*4, x*4); } if (x < 4) { switch (x) { case 0: assert(0); case 1: for (y2=0; y2 < y; ++y2) { memcpy(block+y2*16+1*4, block+y2*16+0*4, 4); memcpy(block+y2*16+2*4, block+y2*16+0*4, 8); } break; case 2: for (y2=0; y2 < y; ++y2) memcpy(block+y2*16+2*4, block+y2*16+0*4, 8); break; case 3: for (y2=0; y2 < y; ++y2) memcpy(block+y2*16+3*4, block+y2*16+1*4, 4); break; } } y2 = 0; for(; y<4; ++y,++y2) memcpy(block+y*16, block+y2*16, 4*4); stb_compress_dxt_block(p, block, alpha, 10); p += alpha ? 16 : 8; } } assert(p <= end); } #endif // STB_COMPRESS_DXT_BLOCK // use the reserved temporary-use enumerant range, since no // OpenGL enumerants should fall in that range enum { STBGL_UNDEFINED = 0x6000, STBGL_YCOCG, STBGL_YCOCGJ, STBGL_GEN_MIPMAPS, STBGL_MIPMAPS, STBGL_NO_DOWNLOAD, }; #define STBGL_CLAMP_TO_EDGE 0x812F #define STBGL_CLAMP_TO_BORDER 0x812D #define STBGL_DEPTH_COMPONENT16 0x81A5 #define STBGL_DEPTH_COMPONENT24 0x81A6 #define STBGL_DEPTH_COMPONENT32 0x81A7 int stbgl_TexImage2D_Extra(int texid, int w, int h, void *data, int chan, char *props, int preserve_data) { static int has_s3tc = -1; // haven't checked yet int free_data = 0, is_compressed = 0; int pad_to_power_of_two = 0, non_power_of_two = 0; int premultiply_alpha = 0; // @TODO int float_tex = 0; // @TODO int input_type = GL_UNSIGNED_BYTE; int input_desc = STBGL_UNDEFINED; int output_desc = STBGL_UNDEFINED; int mipmaps = STBGL_UNDEFINED; int filter = STBGL_UNDEFINED, mag_filter; int wrap_s = STBGL_UNDEFINED, wrap_t = STBGL_UNDEFINED; // parse out the properties if (props == NULL) props = ""; while (*props) { switch (*props) { case '1' : input_desc = GL_LUMINANCE; break; case '2' : input_desc = GL_LUMINANCE_ALPHA; break; case '3' : input_desc = GL_RGB; break; case '4' : input_desc = GL_RGBA; break; case 'l' : if (props[1] == 'a') { input_desc = GL_LUMINANCE_ALPHA; ++props; } else input_desc = GL_LUMINANCE; break; case 'a' : input_desc = GL_ALPHA; break; case 'r' : if (stbgl_m(props, "rgba")) { input_desc = GL_RGBA; props += 3; break; } if (stbgl_m(props, "rgb")) { input_desc = GL_RGB; props += 2; break; } input_desc = GL_RED; break; case 'y' : if (stbgl_m(props, "ycocg")) { if (props[5] == 'j') { props += 5; input_desc = STBGL_YCOCGJ; } else { props += 4; input_desc = STBGL_YCOCG; } break; } return 0; case 'L' : if (props[1] == 'A') { output_desc = GL_LUMINANCE_ALPHA; ++props; } else output_desc = GL_LUMINANCE; break; case 'I' : output_desc = GL_INTENSITY; break; case 'A' : output_desc = GL_ALPHA; break; case 'R' : if (stbgl_m(props, "RGBA")) { output_desc = GL_RGBA; props += 3; break; } if (stbgl_m(props, "RGB")) { output_desc = GL_RGB; props += 2; break; } output_desc = GL_RED; break; case 'Y' : if (stbgl_m(props, "YCoCg") || stbgl_m(props, "YCOCG")) { props += 4; output_desc = STBGL_YCOCG; break; } return 0; case 'D' : if (stbgl_m(props, "DXT")) { switch (props[3]) { case '1': output_desc = STBGL_COMPRESSED_RGB_S3TC_DXT1; break; case '3': output_desc = STBGL_COMPRESSED_RGBA_S3TC_DXT3; break; case '5': output_desc = STBGL_COMPRESSED_RGBA_S3TC_DXT5; break; default: return 0; } props += 3; } else if (stbgl_m(props, "D16")) { output_desc = STBGL_DEPTH_COMPONENT16; input_desc = GL_DEPTH_COMPONENT; props += 2; } else if (stbgl_m(props, "D24")) { output_desc = STBGL_DEPTH_COMPONENT24; input_desc = GL_DEPTH_COMPONENT; props += 2; } else if (stbgl_m(props, "D32")) { output_desc = STBGL_DEPTH_COMPONENT32; input_desc = GL_DEPTH_COMPONENT; props += 2; } else { output_desc = GL_DEPTH_COMPONENT; input_desc = GL_DEPTH_COMPONENT; } break; case 'N' : if (stbgl_m(props, "NONE")) { props += 3; input_desc = STBGL_NO_DOWNLOAD; output_desc = STBGL_NO_DOWNLOAD; break; } if (stbgl_m(props, "NP2")) { non_power_of_two = 1; props += 2; break; } return 0; case 'm' : mipmaps = STBGL_GEN_MIPMAPS; break; case 'M' : mipmaps = STBGL_MIPMAPS; break; case 't' : filter = GL_LINEAR_MIPMAP_LINEAR; break; case 'b' : filter = GL_LINEAR; break; case 'n' : filter = GL_NEAREST; break; case 'w' : if (wrap_s == STBGL_UNDEFINED) wrap_s = GL_REPEAT; else wrap_t = GL_REPEAT; break; case 'C' : if (wrap_s == STBGL_UNDEFINED) wrap_s = STBGL_CLAMP_TO_BORDER; else wrap_t = STBGL_CLAMP_TO_BORDER; break; case 'c' : if (wrap_s == STBGL_UNDEFINED) wrap_s = STBGL_CLAMP_TO_EDGE; else wrap_t = STBGL_CLAMP_TO_EDGE; break; case 'f' : input_type = GL_FLOAT; break; case 'F' : input_type = GL_FLOAT; float_tex = 1; break; case 'p' : premultiply_alpha = 1; break; case 'P' : pad_to_power_of_two = 1; break; case '+' : preserve_data = 0; break; case '!' : preserve_data = 0; free_data = 1; break; case ' ' : break; case '-' : break; default : if (free_data) free(data); return 0; } ++props; } // override input_desc based on channel count if (output_desc != STBGL_NO_DOWNLOAD) { switch (abs(chan)) { case 1: input_desc = GL_LUMINANCE; break; case 2: input_desc = GL_LUMINANCE_ALPHA; break; case 3: input_desc = GL_RGB; break; case 4: input_desc = GL_RGBA; break; case 0: break; default: return 0; } } // override input_desc based on channel info if (chan > 0) { input_type = GL_UNSIGNED_BYTE; } if (chan < 0) { input_type = GL_FLOAT; } if (output_desc == GL_ALPHA) { if (input_desc == GL_LUMINANCE) input_desc = GL_ALPHA; if (input_desc == GL_RGB) { // force a presumably-mono image to alpha // @TODO handle 'preserve_data' case? if (data && !preserve_data && input_type == GL_UNSIGNED_BYTE) { int i; unsigned char *p = (unsigned char *) data, *q = p; for (i=0; i < w*h; ++i) { *q = (p[0] + 2*p[1] + p[2]) >> 2; p += 3; q += 1; } input_desc = GL_ALPHA; } } } // set undefined input/output based on the other if (input_desc == STBGL_UNDEFINED && output_desc == STBGL_UNDEFINED) { input_desc = output_desc = GL_RGBA; } else if (output_desc == STBGL_UNDEFINED) { switch (input_desc) { case GL_LUMINANCE: case GL_ALPHA: case GL_LUMINANCE_ALPHA: case GL_RGB: case GL_RGBA: output_desc = input_desc; break; case GL_RED: output_desc = GL_INTENSITY; break; case STBGL_YCOCG: case STBGL_YCOCGJ: output_desc = STBGL_YCOCG; break; default: assert(0); return 0; } } else if (input_desc == STBGL_UNDEFINED) { switch (output_desc) { case GL_LUMINANCE: case GL_ALPHA: case GL_LUMINANCE_ALPHA: case GL_RGB: case GL_RGBA: input_desc = output_desc; break; case GL_INTENSITY: input_desc = GL_RED; break; case STBGL_YCOCG: case STBGL_COMPRESSED_RGB_S3TC_DXT1: case STBGL_COMPRESSED_RGBA_S3TC_DXT3: case STBGL_COMPRESSED_RGBA_S3TC_DXT5: input_desc = GL_RGBA; break; } } else { if (output_desc == STBGL_COMPRESSED_RGB_S3TC_DXT1) { // if input has alpha, force output alpha switch (input_desc) { case GL_ALPHA: case GL_LUMINANCE_ALPHA: case GL_RGBA: output_desc = STBGL_COMPRESSED_RGBA_S3TC_DXT5; break; } } } switch(input_desc) { case GL_LUMINANCE: case GL_RED: case GL_ALPHA: chan = 1; break; case GL_LUMINANCE_ALPHA: chan = 2; break; case GL_RGB: chan = 3; break; case GL_RGBA: chan = 4; break; } if (pad_to_power_of_two && ((w & (w-1)) || (h & (h-1)))) { if (output_desc != STBGL_NO_DOWNLOAD && input_type == GL_UNSIGNED_BYTE && chan > 0) { unsigned char *new_data; int w2 = w, h2 = h, j; while (w & (w-1)) w = (w | (w>>1))+1; while (h & (h-1)) h = (h | (h>>1))+1; new_data = malloc(w * h * chan); for (j=0; j < h2; ++j) { memcpy(new_data + j * w * chan, (char *) data+j*w2*chan, w2*chan); memset(new_data + (j * w+w2) * chan, 0, (w-w2)*chan); } for (; j < h; ++j) memset(new_data + j*w*chan, 0, w*chan); if (free_data) free(data); data = new_data; free_data = 1; } } switch (output_desc) { case STBGL_COMPRESSED_RGB_S3TC_DXT1: case STBGL_COMPRESSED_RGBA_S3TC_DXT1: case STBGL_COMPRESSED_RGBA_S3TC_DXT3: case STBGL_COMPRESSED_RGBA_S3TC_DXT5: is_compressed = 1; if (has_s3tc == -1) { has_s3tc = stbgl_hasExtension("GL_EXT_texture_compression_s3tc"); if (has_s3tc) stbgl__initCompTex(); } if (!has_s3tc) { is_compressed = 0; if (output_desc == STBGL_COMPRESSED_RGB_S3TC_DXT1) output_desc = GL_RGB; else output_desc = GL_RGBA; } } if (output_desc == STBGL_YCOCG) { assert(0); output_desc = GL_RGB; // @TODO! if (free_data) free(data); return 0; } mag_filter = 0; if (mipmaps != STBGL_UNDEFINED) { switch (filter) { case STBGL_UNDEFINED: filter = GL_LINEAR_MIPMAP_LINEAR; break; case GL_NEAREST : mag_filter = GL_NEAREST; filter = GL_LINEAR_MIPMAP_LINEAR; break; case GL_LINEAR : filter = GL_LINEAR_MIPMAP_NEAREST; break; } } else { if (filter == STBGL_UNDEFINED) filter = GL_LINEAR; } // update filtering if (!mag_filter) { if (filter == GL_NEAREST) mag_filter = GL_NEAREST; else mag_filter = GL_LINEAR; } // update wrap/clamp if (wrap_s == STBGL_UNDEFINED) wrap_s = GL_REPEAT; if (wrap_t == STBGL_UNDEFINED) wrap_t = wrap_s; // if no texture id, generate one if (texid == 0) { GLuint tex; glGenTextures(1, &tex); if (tex == 0) { if (free_data) free(data); return 0; } texid = tex; } if (data == NULL && mipmaps == STBGL_GEN_MIPMAPS) mipmaps = STBGL_MIPMAPS; if (output_desc == STBGL_NO_DOWNLOAD) mipmaps = STBGL_NO_DOWNLOAD; glBindTexture(GL_TEXTURE_2D, texid); #ifdef STB_COMPRESS_DXT_BLOCK if (!is_compressed || !stbgl__CompressedTexImage2DARB || output_desc == STBGL_COMPRESSED_RGBA_S3TC_DXT3 || data == NULL) #endif { switch (mipmaps) { case STBGL_NO_DOWNLOAD: break; case STBGL_UNDEFINED: // check if actually power-of-two if (non_power_of_two || ((w & (w-1)) == 0 && (h & (h-1)) == 0)) glTexImage2D(GL_TEXTURE_2D, 0, output_desc, w, h, 0, input_desc, input_type, data); else gluBuild2DMipmaps(GL_TEXTURE_2D, output_desc, w, h, input_desc, input_type, data); // not power of two, so use glu to resize (generates mipmaps needlessly) break; case STBGL_MIPMAPS: { int level = 0; int size = input_type == GL_FLOAT ? sizeof(float) : 1; if (data == NULL) size = 0; // reuse same block of memory for all mipmaps assert((w & (w-1)) == 0 && (h & (h-1)) == 0); // verify power-of-two while (w > 1 && h > 1) { glTexImage2D(GL_TEXTURE_2D, level, output_desc, w, h, 0, input_desc, input_type, data); data = (void *) ((char *) data + w * h * size * chan); if (w > 1) w >>= 1; if (h > 1) h >>= 1; ++level; } break; } case STBGL_GEN_MIPMAPS: gluBuild2DMipmaps(GL_TEXTURE_2D, output_desc, w, h, input_desc, input_type, data); break; default: assert(0); if (free_data) free(data); return 0; } #ifdef STB_COMPRESS_DXT_BLOCK } else { uint8 *out, *rgba=0, *end_out, *end_rgba; int level = 0, alpha = (output_desc != STBGL_COMPRESSED_RGB_S3TC_DXT1); int size = input_type == GL_FLOAT ? sizeof(float) : 1; int osize = alpha ? 16 : 8; if (!free_data && mipmaps == STBGL_GEN_MIPMAPS) { uint8 *temp = malloc(w*h*chan); if (!temp) { if (free_data) free(data); return 0; } memcpy(temp, data, w*h*chan); if (free_data) free(data); free_data = 1; data = temp; } if (chan != 4 || size != 1) { rgba = malloc(w*h*4); if (!rgba) return 0; end_rgba = rgba+w*h*4; } out = malloc((w+3)*(h+3)/16*osize); // enough storage for the s3tc data if (!out) return 0; end_out = out + ((w+3)*(h+3))/16*osize; for(;;) { if (chan != 4) stbgl__convert(rgba, data, w*h, input_desc, end_rgba); stbgl__compress(out, rgba ? rgba : data, w, h, output_desc, end_out); stbgl__CompressedTexImage2DARB(GL_TEXTURE_2D, level, output_desc, w, h, 0, ((w+3)&~3)*((h+3)&~3)/16*osize, out); //glTexImage2D(GL_TEXTURE_2D, level, alpha?GL_RGBA:GL_RGB, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgba ? rgba : data); if (mipmaps == STBGL_UNDEFINED) break; if (w <= 1 && h <= 1) break; if (mipmaps == STBGL_MIPMAPS) data = (void *) ((char *) data + w * h * size * chan); if (mipmaps == STBGL_GEN_MIPMAPS) { int w2 = w>>1, h2=h>>1, i,j,k, s=w*chan; uint8 *p = data, *q=data; if (w == 1) { for (j=0; j < h2; ++j) { for (k=0; k < chan; ++k) *p++ = (q[k] + q[s+k] + 1) >> 1; q += s*2; } } else if (h == 1) { for (i=0; i < w2; ++i) { for (k=0; k < chan; ++k) *p++ = (q[k] + q[k+chan] + 1) >> 1; q += chan*2; } } else { for (j=0; j < h2; ++j) { for (i=0; i < w2; ++i) { for (k=0; k < chan; ++k) *p++ = (q[k] + q[k+chan] + q[s+k] + q[s+k+chan] + 2) >> 2; q += chan*2; } q += s; } } } if (w > 1) w >>= 1; if (h > 1) h >>= 1; ++level; } if (out) free(out); if (rgba) free(rgba); #endif // STB_COMPRESS_DXT_BLOCK } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); if (free_data) free(data); return texid; } #endif // STB_DEFINE #undef STB_EXTERN #endif //INCLUDE_STB_GL_H // Extension handling... must be outside the INCLUDE_ brackets #if defined(STB_GLEXT_DEFINE) || defined(STB_GLEXT_DECLARE) #ifndef STB_GLEXT_SKIP_DURING_RECURSION #ifndef GL_GLEXT_VERSION // First check if glext.h is concatenated on the end of this file // (if it's concatenated on the beginning, we'll have GL_GLEXT_VERSION) #define STB_GLEXT_SKIP_DURING_RECURSION #include __FILE__ #undef STB_GLEXT_SKIP_DURING_RECURSION // now check if it's still undefined; if so, try going for it by name; // if this errors, that's fine, since we can't compile without it #ifndef GL_GLEXT_VERSION #include "glext.h" #endif #endif #define GLARB(a,b) GLE(a##ARB,b##ARB) #define GLEXT(a,b) GLE(a##EXT,b##EXT) #define GLNV(a,b) GLE(a##NV ,b##NV) #define GLATI(a,b) GLE(a##ATI,b##ATI) #define GLCORE(a,b) GLE(a,b) #ifdef STB_GLEXT_DEFINE_DECLARE #define STB_GLEXT_DEFINE STB_GLEXT_DECLARE #endif #if defined(STB_GLEXT_DECLARE) && defined(STB_GLEXT_DEFINE) #undef STB_GLEXT_DECLARE #endif #if defined(STB_GLEXT_DECLARE) && !defined(STB_GLEXT_DEFINE) #define GLE(a,b) extern PFNGL##b##PROC gl##a; #ifdef __cplusplus extern "C" { #endif extern void stbgl_initExtensions(void); #include STB_GLEXT_DECLARE #ifdef __cplusplus }; #endif #else #ifndef STB_GLEXT_DEFINE #error "Header file is screwed up somehow" #endif #ifdef _WIN32 #ifndef WINGDIAPI #ifndef STB__HAS_WGLPROC typedef int (__stdcall *stbgl__voidfunc)(void); __declspec(dllimport) stbgl__voidfunc wglGetProcAddress(char *); #endif #endif #define STBGL__GET_FUNC(x) wglGetProcAddress(x) #endif #ifdef GLE #undef GLE #endif #define GLE(a,b) PFNGL##b##PROC gl##a; #include STB_GLEXT_DEFINE #undef GLE #define GLE(a,b) gl##a = (PFNGL##b##PROC) STBGL__GET_FUNC("gl" #a ); void stbgl_initExtensions(void) { #include STB_GLEXT_DEFINE } #undef GLE #endif // STB_GLEXT_DECLARE #endif // STB_GLEXT_SKIP #endif // STB_GLEXT_DEFINE || STB_GLEXT_DECLARE uTox/third_party/stb/stb/tests/caveview/main.c0000600000175000001440000000000014003056224020437 0ustar rakusersuTox/third_party/stb/stb/tests/caveview/glext_list.h0000600000175000001440000000225214003056224021711 0ustar rakusersGLARB(ActiveTexture,ACTIVETEXTURE) GLARB(ClientActiveTexture,CLIENTACTIVETEXTURE) GLARB(MultiTexCoord2f,MULTITEXCOORD2F) GLEXT(TexImage3D,TEXIMAGE3D) GLEXT(TexSubImage3D,TEXSUBIMAGE3D) GLEXT(GenerateMipmap,GENERATEMIPMAP) GLARB(DebugMessageCallback,DEBUGMESSAGECALLBACK) GLCORE(VertexAttribIPointer,VERTEXATTRIBIPOINTER) GLEXT(BindFramebuffer,BINDFRAMEBUFFER) GLEXT(DeleteFramebuffers,DELETEFRAMEBUFFERS) GLEXT(GenFramebuffers,GENFRAMEBUFFERS) GLEXT(CheckFramebufferStatus,CHECKFRAMEBUFFERSTATUS) GLEXT(FramebufferTexture2D,FRAMEBUFFERTEXTURE2D) GLEXT(BindRenderBuffer,BINDRENDERBUFFER) GLEXT(RenderbufferStorage,RENDERBUFFERSTORAGE) GLEXT(GenRenderbuffers,GENRENDERBUFFERS) GLEXT(BindRenderbuffer,BINDRENDERBUFFER) GLEXT(FramebufferRenderbuffer,FRAMEBUFFERRENDERBUFFER) GLEXT(GenerateMipmap,GENERATEMIPMAP) GLARB(BindBuffer ,BINDBUFFER,) GLARB(GenBuffers ,GENBUFFERS ) GLARB(DeleteBuffers,DELETEBUFFERS) GLARB(BufferData ,BUFFERDATA ) GLARB(BufferSubData,BUFFERSUBDATA) GLARB(MapBuffer ,MAPBUFFER ) GLARB(UnmapBuffer ,UNMAPBUFFER ) GLARB(TexBuffer ,TEXBUFFER ) GLEXT(NamedBufferStorage,NAMEDBUFFERSTORAGE) GLE(BufferStorage,BUFFERSTORAGE) GLE(GetStringi,GETSTRINGI)uTox/third_party/stb/stb/tests/caveview/glext.h0000600000175000001440000262130314003056224020664 0ustar rakusers#ifndef __glext_h_ #define __glext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* ** Copyright (c) 2013 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. */ /* ** 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 ** http://www.opengl.org/registry/ ** ** Khronos $Revision: 24756 $ on $Date: 2014-01-14 03:42:29 -0800 (Tue, 14 Jan 2014) $ */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif #include #endif #ifndef APIENTRY #define APIENTRY #endif #ifndef APIENTRYP #define APIENTRYP APIENTRY * #endif #ifndef GLAPI #define GLAPI extern #endif #define GL_GLEXT_VERSION 20140114 /* 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_FUNC_ADD 0x8006 #define GL_FUNC_SUBTRACT 0x800A #define GL_FUNC_REVERSE_SUBTRACT 0x800B #define GL_MIN 0x8007 #define GL_MAX 0x8008 #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 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 #include typedef ptrdiff_t GLsizeiptr; typedef ptrdiff_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 unsigned short 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_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_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_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_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; #ifndef GLEXT_64_TYPES_DEFINED /* This code block is duplicated in glxext.h, so must be protected */ #define GLEXT_64_TYPES_DEFINED /* Define int32_t, int64_t, and uint64_t types for UST/MSC */ /* (as used in the GL_EXT_timer_query extension). */ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #include #elif defined(__sun__) || defined(__digital__) #include #if defined(__STDC__) #if defined(__arch64__) || defined(_LP64) typedef long int int64_t; typedef unsigned long int uint64_t; #else typedef long long int int64_t; typedef unsigned long long int uint64_t; #endif /* __arch64__ */ #endif /* __STDC__ */ #elif defined( __VMS ) || defined(__sgi) #include #elif defined(__SCO__) || defined(__USLC__) #include #elif defined(__UNIXOS2__) || defined(__SOL64__) typedef long int int32_t; typedef long long int int64_t; typedef unsigned long long int uint64_t; #elif defined(_WIN32) && defined(__GNUC__) #include #elif defined(_WIN32) typedef __int32 int32_t; typedef __int64 int64_t; typedef unsigned __int64 uint64_t; #else /* Fallback if nothing above works */ #include #endif #endif typedef uint64_t GLuint64; typedef 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 bufSize, 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 bufSize, 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_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 bufSize, 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 bufSize, 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_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_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 bufSize, 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 bufSize, 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 bufSize, 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 bufSize, 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_ARB_ES2_compatibility #define GL_ARB_ES2_compatibility 1 #endif /* GL_ARB_ES2_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 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_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 #define GL_COMPUTE_SHADER_BIT 0x00000020 #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_conservative_depth #define GL_ARB_conservative_depth 1 #endif /* GL_ARB_conservative_depth */ #ifndef GL_ARB_copy_buffer #define GL_ARB_copy_buffer 1 #define GL_COPY_READ_BUFFER_BINDING 0x8F36 #define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 #endif /* GL_ARB_copy_buffer */ #ifndef GL_ARB_copy_image #define GL_ARB_copy_image 1 #endif /* GL_ARB_copy_image */ #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_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_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_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_half_float_pixel #define GL_ARB_half_float_pixel 1 typedef unsigned short 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_BLEND_COLOR 0x8005 #define GL_BLEND_EQUATION 0x8009 #define GL_CONVOLUTION_1D 0x8010 #define GL_CONVOLUTION_2D 0x8011 #define GL_SEPARABLE_2D 0x8012 #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 0x8024 #define GL_PROXY_HISTOGRAM 0x8025 #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 0x802E #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 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_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, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr 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 #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_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_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_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_counters #define GL_ARB_shader_atomic_counters 1 #endif /* GL_ARB_shader_atomic_counters */ #ifndef GL_ARB_shader_bit_encoding #define GL_ARB_shader_bit_encoding 1 #endif /* GL_ARB_shader_bit_encoding */ #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_lod #define GL_ARB_shader_texture_lod 1 #endif /* GL_ARB_shader_texture_lod */ #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_texture #define GL_ARB_sparse_texture 1 #define GL_TEXTURE_SPARSE_ARB 0x91A6 #define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 #define GL_MIN_SPARSE_LEVEL_ARB 0x919B #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 resident); #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 resident); #endif #endif /* GL_ARB_sparse_texture */ #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_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_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 #define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 #define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 #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_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 #define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C #define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 #define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 #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 ptrdiff_t GLsizeiptrARB; typedef ptrdiff_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 #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_debug #define GL_KHR_debug 1 #endif /* GL_KHR_debug */ #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_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); typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y); typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z); 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); GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y); GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z); 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 GLint 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 PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert); 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 glSampleCoverageOES (GLfixed value, GLboolean invert); 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_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 #define GL_SUBSAMPLE_DISTANCE_AMD 0x883F 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_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_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_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_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 resident); 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 resident); 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_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_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD #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 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); #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); #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_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_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_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_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_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_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_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 #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_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_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_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_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_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_fragment_shader_ordering #define GL_INTEL_fragment_shader_ordering 1 #endif /* GL_INTEL_fragment_shader_ordering */ #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, GLvoid *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, GLvoid *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_pack_invert #define GL_MESA_pack_invert 1 #define GL_PACK_INVERT_MESA 0x8758 #endif /* GL_MESA_pack_invert */ #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_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_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_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_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_square #define GL_NV_blend_square 1 #endif /* GL_NV_blend_square */ #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_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_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_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_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_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_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 PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); 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 glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); 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_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 typedef 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_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_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_multisample_coverage #define GL_NV_multisample_coverage 1 #define GL_COLOR_SAMPLES_NV 0x8E20 #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_PATH_FOG_GEN_MODE_NV 0x90AC #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_COLOR_FORMAT_NV 0x90B2 #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_PRIMARY_COLOR_NV 0x852C #define GL_SECONDARY_COLOR_NV 0x852D 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 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 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 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); 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); #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 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 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 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); 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); #endif #endif /* GL_NV_path_rendering */ #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_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_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_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_storage_buffer_object #define GL_NV_shader_storage_buffer_object 1 #endif /* GL_NV_shader_storage_buffer_object */ #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_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_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) (GLuint 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 (GLuint 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_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 bufSize, 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 bufSize, 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_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 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 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_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_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_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 0x842C #define GL_UNPACK_RESAMPLE_SGIX 0x842D #define GL_RESAMPLE_REPLICATE_SGIX 0x842E #define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F #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 uTox/third_party/stb/stb/tests/caveview/caveview.h0000600000175000001440000000227714003056224021353 0ustar rakusers#ifndef INCLUDE_CAVEVIEW_H #define INCLUDE_CAVEVIEW_H #include "stb.h" #include "stb_voxel_render.h" typedef struct { int cx,cy; stbvox_mesh_maker mm; uint8 *build_buffer; uint8 *face_buffer; int num_quads; float transform[3][3]; float bounds[2][3]; uint8 sv_blocktype[34][34][18]; uint8 sv_lighting [34][34][18]; } raw_mesh; // a 3D checkerboard of empty,solid would be: 32x32x255x6/2 ~= 800000 // an all-leaf qchunk would be: 32 x 32 x 255 x 6 ~= 1,600,000 #define BUILD_QUAD_MAX 400000 #define BUILD_BUFFER_SIZE (4*4*BUILD_QUAD_MAX) // 4 bytes per vertex, 4 vertices per quad #define FACE_BUFFER_SIZE ( 4*BUILD_QUAD_MAX) // 4 bytes per quad extern void mesh_init(void); extern void render_init(void); extern void world_init(void); extern void ods(char *fmt, ...); // output debug string extern void reset_cache_size(int size); extern void render_caves(float pos[3]); #include "cave_parse.h" // fast_chunk extern fast_chunk *get_converted_fastchunk(int chunk_x, int chunk_y); extern void build_chunk(int chunk_x, int chunk_y, fast_chunk *fc_table[4][4], raw_mesh *rm); extern void reset_cache_size(int size); extern void deref_fastchunk(fast_chunk *fc); #endifuTox/third_party/stb/stb/tests/caveview/caveview.dsw0000600000175000001440000000077614003056224021723 0ustar rakusersMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "caveview"=.\caveview.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### uTox/third_party/stb/stb/tests/caveview/caveview.dsp0000600000175000001440000001117714003056224021711 0ustar rakusers# Microsoft Developer Studio Project File - Name="caveview" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Application" 0x0101 CFG=caveview - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "caveview.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "caveview.mak" CFG="caveview - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "caveview - Win32 Release" (based on "Win32 (x86) Application") !MESSAGE "caveview - Win32 Debug" (based on "Win32 (x86) Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "caveview - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /WX /GX /Zd /O2 /I "../.." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sdl2.lib opengl32.lib glu32.lib winmm.lib sdl2_mixer.lib advapi32.lib /nologo /subsystem:windows /debug /machine:I386 # SUBTRACT LINK32 /map !ELSEIF "$(CFG)" == "caveview - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /WX /Gm /GX /Zi /Od /I "../.." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sdl2.lib opengl32.lib glu32.lib winmm.lib sdl2_mixer.lib /nologo /subsystem:windows /incremental:no /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "caveview - Win32 Release" # Name "caveview - Win32 Debug" # Begin Source File SOURCE=.\cave_main.c # End Source File # Begin Source File SOURCE=.\cave_mesher.c # End Source File # Begin Source File SOURCE=.\cave_parse.c # End Source File # Begin Source File SOURCE=.\cave_parse.h # End Source File # Begin Source File SOURCE=.\cave_render.c # End Source File # Begin Source File SOURCE=.\caveview.h # End Source File # Begin Source File SOURCE=.\glext.h # End Source File # Begin Source File SOURCE=.\glext_list.h # End Source File # Begin Source File SOURCE=.\README.md # End Source File # Begin Source File SOURCE=.\win32\SDL_windows_main.c # End Source File # Begin Source File SOURCE=..\..\stb.h # End Source File # Begin Source File SOURCE=..\..\stb_easy_font.h # End Source File # Begin Source File SOURCE=.\stb_gl.h # End Source File # Begin Source File SOURCE=.\stb_glprog.h # End Source File # Begin Source File SOURCE=..\..\stb_image.h # End Source File # Begin Source File SOURCE=..\..\stb_voxel_render.h # End Source File # End Target # End Project uTox/third_party/stb/stb/tests/caveview/cave_render.c0000600000175000001440000007151714003056224022015 0ustar rakusers// This file renders vertex buffers, converts raw meshes // to GL meshes, and manages threads that do the raw-mesh // building (found in cave_mesher.c) #include "stb_voxel_render.h" #define STB_GLEXT_DECLARE "glext_list.h" #include "stb_gl.h" #include "stb_image.h" #include "stb_glprog.h" #include "caveview.h" #include "cave_parse.h" #include "stb.h" #include "sdl.h" #include "sdl_thread.h" #include #include //#define STBVOX_CONFIG_TEX1_EDGE_CLAMP // currently no dynamic way to set mesh cache size or view distance //#define SHORTVIEW stbvox_mesh_maker g_mesh_maker; GLuint main_prog; GLint uniform_locations[64]; //#define MAX_QUADS_PER_DRAW (65536 / 4) // assuming 16-bit indices, 4 verts per quad //#define FIXED_INDEX_BUFFER_SIZE (MAX_QUADS_PER_DRAW * 6 * 2) // 16*1024 * 12 == ~192KB // while uploading texture data, this holds our each texture #define TEX_SIZE 64 uint32 texture[TEX_SIZE][TEX_SIZE]; GLuint voxel_tex[2]; // chunk state enum { STATE_invalid, STATE_needed, STATE_requested, STATE_abandoned, STATE_valid, }; // mesh is 32x32x255 ... this is hardcoded in that // a mesh covers 2x2 minecraft chunks, no #defines for it typedef struct { int state; int chunk_x, chunk_y; int num_quads; float priority; int vbuf_size, fbuf_size; float transform[3][3]; float bounds[2][3]; GLuint vbuf;// vbuf_tex; GLuint fbuf, fbuf_tex; } chunk_mesh; void scale_texture(unsigned char *src, int x, int y, int w, int h) { int i,j,k; assert(w == 256 && h == 256); for (j=0; j < TEX_SIZE; ++j) { for (i=0; i < TEX_SIZE; ++i) { uint32 val=0; for (k=0; k < 4; ++k) { val >>= 8; val += src[ 4*(x+(i>>2)) + 4*w*(y+(j>>2)) + k]<<24; } texture[j][i] = val; } } } void build_base_texture(int n) { int x,y; uint32 color = stb_rand() | 0x808080; for (y=0; ystate == STATE_valid) { glDeleteTextures(1, &cm->fbuf_tex); glDeleteBuffersARB(1, &cm->vbuf); glDeleteBuffersARB(1, &cm->fbuf); cached_chunk_mesh[slot_y][slot_x].state = STATE_invalid; } } void upload_mesh(chunk_mesh *cm, uint8 *build_buffer, uint8 *face_buffer) { glGenBuffersARB(1, &cm->vbuf); glBindBufferARB(GL_ARRAY_BUFFER_ARB, cm->vbuf); glBufferDataARB(GL_ARRAY_BUFFER_ARB, cm->num_quads*4*sizeof(uint32), build_buffer, GL_STATIC_DRAW_ARB); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); glGenBuffersARB(1, &cm->fbuf); glBindBufferARB(GL_TEXTURE_BUFFER_ARB, cm->fbuf); glBufferDataARB(GL_TEXTURE_BUFFER_ARB, cm->num_quads*sizeof(uint32), face_buffer , GL_STATIC_DRAW_ARB); glBindBufferARB(GL_TEXTURE_BUFFER_ARB, 0); glGenTextures(1, &cm->fbuf_tex); glBindTexture(GL_TEXTURE_BUFFER_ARB, cm->fbuf_tex); glTexBufferARB(GL_TEXTURE_BUFFER_ARB, GL_RGBA8UI, cm->fbuf); glBindTexture(GL_TEXTURE_BUFFER_ARB, 0); } static void upload_mesh_data(raw_mesh *rm) { int cx = rm->cx; int cy = rm->cy; int slot_x = (cx >> 1) & (CACHED_MESH_NUM_X-1); int slot_y = (cy >> 1) & (CACHED_MESH_NUM_Y-1); chunk_mesh *cm; free_chunk(slot_x, slot_y); cm = &cached_chunk_mesh[slot_y][slot_x]; cm->num_quads = rm->num_quads; upload_mesh(cm, rm->build_buffer, rm->face_buffer); cm->vbuf_size = rm->num_quads*4*sizeof(uint32); cm->fbuf_size = rm->num_quads*sizeof(uint32); cm->priority = 100000; cm->chunk_x = cx; cm->chunk_y = cy; memcpy(cm->bounds, rm->bounds, sizeof(cm->bounds)); memcpy(cm->transform, rm->transform, sizeof(cm->transform)); // write barrier here cm->state = STATE_valid; } GLint uniform_loc[16]; float table3[128][3]; float table4[64][4]; GLint tablei[2]; float step=0; #ifdef SHORTVIEW int view_dist_in_chunks = 50; #else int view_dist_in_chunks = 80; #endif void setup_uniforms(float pos[3]) { int i,j; step += 1.0f/60.0f; for (i=0; i < STBVOX_UNIFORM_count; ++i) { stbvox_uniform_info raw, *ui=&raw; stbvox_get_uniform_info(&raw, i); uniform_loc[i] = -1; if (i == STBVOX_UNIFORM_texscale || i == STBVOX_UNIFORM_texgen || i == STBVOX_UNIFORM_color_table) continue; if (ui) { void *data = ui->default_value; uniform_loc[i] = stbgl_find_uniform(main_prog, ui->name); switch (i) { case STBVOX_UNIFORM_face_data: tablei[0] = 2; data = tablei; break; case STBVOX_UNIFORM_tex_array: glActiveTextureARB(GL_TEXTURE0_ARB); glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, voxel_tex[0]); glActiveTextureARB(GL_TEXTURE1_ARB); glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, voxel_tex[1]); glActiveTextureARB(GL_TEXTURE0_ARB); tablei[0] = 0; tablei[1] = 1; data = tablei; break; case STBVOX_UNIFORM_color_table: data = ui->default_value; ((float *)data)[63*4+3] = 2.0f; // emissive break; case STBVOX_UNIFORM_camera_pos: data = table3[0]; table3[0][0] = pos[0]; table3[0][1] = pos[1]; table3[0][2] = pos[2]; table3[0][3] = stb_max(0,(float)sin(step*2)*0.125f); break; case STBVOX_UNIFORM_ambient: { float bright = 1.0; //float bright = 0.75; float amb[3][3]; // ambient direction is sky-colored upwards // "ambient" lighting is from above table4[0][0] = 0.3f; table4[0][1] = -0.5f; table4[0][2] = 0.9f; amb[1][0] = 0.3f; amb[1][1] = 0.3f; amb[1][2] = 0.3f; // dark-grey amb[2][0] = 1.0; amb[2][1] = 1.0; amb[2][2] = 1.0; // white // convert so (table[1]*dot+table[2]) gives // above interpolation // lerp((dot+1)/2, amb[1], amb[2]) // amb[1] + (amb[2] - amb[1]) * (dot+1)/2 // amb[1] + (amb[2] - amb[1]) * dot/2 + (amb[2]-amb[1])/2 for (j=0; j < 3; ++j) { table4[1][j] = (amb[2][j] - amb[1][j])/2 * bright; table4[2][j] = (amb[1][j] + amb[2][j])/2 * bright; } // fog color table4[3][0] = 0.6f, table4[3][1] = 0.7f, table4[3][2] = 0.9f; table4[3][3] = 1.0f / (view_dist_in_chunks * 16); table4[3][3] *= table4[3][3]; data = table4; break; } } switch (ui->type) { case STBVOX_UNIFORM_TYPE_sampler: stbglUniform1iv(uniform_loc[i], ui->array_length, data); break; case STBVOX_UNIFORM_TYPE_vec2: stbglUniform2fv(uniform_loc[i], ui->array_length, data); break; case STBVOX_UNIFORM_TYPE_vec3: stbglUniform3fv(uniform_loc[i], ui->array_length, data); break; case STBVOX_UNIFORM_TYPE_vec4: stbglUniform4fv(uniform_loc[i], ui->array_length, data); break; } } } } GLuint unitex[64], unibuf[64]; void make_texture_buffer_for_uniform(int uniform, int slot) { GLenum type; stbvox_uniform_info raw, *ui=&raw; GLint uloc; stbvox_get_uniform_info(ui, uniform); uloc = stbgl_find_uniform(main_prog, ui->name); if (uniform == STBVOX_UNIFORM_color_table) ((float *)ui->default_value)[63*4+3] = 2.0f; // emissive glGenBuffersARB(1, &unibuf[uniform]); glBindBufferARB(GL_ARRAY_BUFFER_ARB, unibuf[uniform]); glBufferDataARB(GL_ARRAY_BUFFER_ARB, ui->array_length * ui->bytes_per_element, ui->default_value, GL_STATIC_DRAW_ARB); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); glGenTextures(1, &unitex[uniform]); glBindTexture(GL_TEXTURE_BUFFER_ARB, unitex[uniform]); switch (ui->type) { case STBVOX_UNIFORM_TYPE_vec2: type = GL_RG32F; break; case STBVOX_UNIFORM_TYPE_vec3: type = GL_RGB32F; break; case STBVOX_UNIFORM_TYPE_vec4: type = GL_RGBA32F; break; default: assert(0); } glTexBufferARB(GL_TEXTURE_BUFFER_ARB, type, unibuf[uniform]); glBindTexture(GL_TEXTURE_BUFFER_ARB, 0); glActiveTextureARB(GL_TEXTURE0 + slot); glBindTexture(GL_TEXTURE_BUFFER_ARB, unitex[uniform]); glActiveTextureARB(GL_TEXTURE0); stbglUseProgram(main_prog); stbglUniform1i(uloc, slot); } #define MAX_MESH_WORKERS 8 #define MAX_CHUNK_LOAD_WORKERS 2 int num_mesh_workers; int num_chunk_load_workers; typedef struct { int state; int request_cx; int request_cy; int padding[13]; SDL_sem * request_received; SDL_sem * chunk_server_done_processing; int chunk_action; int chunk_request_x; int chunk_request_y; fast_chunk *chunks[4][4]; int padding2[16]; raw_mesh rm; int padding3[16]; uint8 *build_buffer; uint8 *face_buffer ; } mesh_worker; enum { WSTATE_idle, WSTATE_requested, WSTATE_running, WSTATE_mesh_ready, }; mesh_worker mesh_data[MAX_MESH_WORKERS]; int num_meshes_started; // stats int request_chunk(int chunk_x, int chunk_y); void update_meshes_from_render_thread(void); unsigned char tex2_data[64][4]; void init_tex2_gradient(void) { int i; for (i=0; i < 16; ++i) { tex2_data[i+ 0][0] = 64 + 12*i; tex2_data[i+ 0][1] = 32; tex2_data[i+ 0][2] = 64; tex2_data[i+16][0] = 255; tex2_data[i+16][1] = 32 + 8*i; tex2_data[i+16][2] = 64; tex2_data[i+32][0] = 255; tex2_data[i+32][1] = 160; tex2_data[i+32][2] = 64 + 12*i; tex2_data[i+48][0] = 255; tex2_data[i+48][1] = 160 + 6*i; tex2_data[i+48][2] = 255; } } void set_tex2_alpha(float fa) { int i; int a = (int) stb_lerp(fa, 0, 255); if (a < 0) a = 0; else if (a > 255) a = 255; glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, voxel_tex[1]); for (i=0; i < 64; ++i) { tex2_data[i][3] = a; glTexSubImage3DEXT(GL_TEXTURE_2D_ARRAY_EXT, 0, 0,0,i, 1,1,1, GL_RGBA, GL_UNSIGNED_BYTE, tex2_data[i]); } } void render_init(void) { int i; char *binds[] = { "attr_vertex", "attr_face", NULL }; char *vertex; char *fragment; int w=0,h=0; unsigned char *texdata = stbi_load("terrain.png", &w, &h, NULL, 4); stbvox_init_mesh_maker(&g_mesh_maker); for (i=0; i < num_mesh_workers; ++i) { stbvox_init_mesh_maker(&mesh_data[i].rm.mm); } vertex = stbvox_get_vertex_shader(); fragment = stbvox_get_fragment_shader(); { char error_buffer[1024]; char *main_vertex[] = { vertex, NULL }; char *main_fragment[] = { fragment, NULL }; main_prog = stbgl_create_program(main_vertex, main_fragment, binds, error_buffer, sizeof(error_buffer)); if (main_prog == 0) { ods("Compile error for main shader: %s\n", error_buffer); assert(0); exit(1); } } //init_index_buffer(); make_texture_buffer_for_uniform(STBVOX_UNIFORM_texscale , 3); make_texture_buffer_for_uniform(STBVOX_UNIFORM_texgen , 4); make_texture_buffer_for_uniform(STBVOX_UNIFORM_color_table , 5); glGenTextures(2, voxel_tex); glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, voxel_tex[0]); glTexImage3DEXT(GL_TEXTURE_2D_ARRAY_EXT, 0, GL_RGBA, TEX_SIZE,TEX_SIZE,256, 0,GL_RGBA,GL_UNSIGNED_BYTE,NULL); for (i=0; i < 256; ++i) { if (texdata) scale_texture(texdata, (i&15)*w/16, (h/16)*(i>>4), w,h); else build_base_texture(i); glTexSubImage3DEXT(GL_TEXTURE_2D_ARRAY_EXT, 0, 0,0,i, TEX_SIZE,TEX_SIZE,1, GL_RGBA, GL_UNSIGNED_BYTE, texture[0]); } glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16); #ifdef STBVOX_CONFIG_TEX1_EDGE_CLAMP glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); #endif glGenerateMipmapEXT(GL_TEXTURE_2D_ARRAY_EXT); glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, voxel_tex[1]); glTexImage3DEXT(GL_TEXTURE_2D_ARRAY_EXT, 0, GL_RGBA, 1,1,64, 0,GL_RGBA,GL_UNSIGNED_BYTE,NULL); init_tex2_gradient(); set_tex2_alpha(0.0); #if 0 for (i=0; i < 128; ++i) { //build_overlay_texture(i); glTexSubImage3DEXT(GL_TEXTURE_2D_ARRAY_EXT, 0, 0,0,i, TEX_SIZE,TEX_SIZE,1, GL_RGBA, GL_UNSIGNED_BYTE, texture[0]); } #endif glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glGenerateMipmapEXT(GL_TEXTURE_2D_ARRAY_EXT); } void world_init(void) { int a,b,x,y; Uint64 start_time, end_time; #ifdef NDEBUG int range = 32; #else int range = 12; #endif start_time = SDL_GetPerformanceCounter(); // iterate in 8x8 clusters of qchunks at a time to get better converted-chunk-cache reuse // than a purely row-by-row ordering is (single-threaded this is a bigger win than // any of the above optimizations were, since it halves zlib/mc-conversion costs) for (x=-range; x <= range; x += 16) for (y=-range; y <= range; y += 16) for (b=y; b < y+16 && b <= range; b += 2) for (a=x; a < x+16 && a <= range; a += 2) while (!request_chunk(a, b)) { // if request fails, all threads are busy update_meshes_from_render_thread(); SDL_Delay(1); } // wait until all the workers are done, // (this is only needed if we want to time // when the build finishes, or when we want to reset the // cache size; otherwise we could just go ahead and // start rendering whatever we've got) for(;;) { int i; update_meshes_from_render_thread(); for (i=0; i < num_mesh_workers; ++i) if (mesh_data[i].state != WSTATE_idle) break; if (i == num_mesh_workers) break; SDL_Delay(3); } end_time = SDL_GetPerformanceCounter(); ods("Build time: %7.2fs\n", (end_time - start_time) / (float) SDL_GetPerformanceFrequency()); // don't waste lots of storage on chunk caches once it's finished starting-up; // this was only needed to be this large because we worked in large blocks // to maximize sharing reset_cache_size(32); } extern SDL_mutex * chunk_cache_mutex; int mesh_worker_handler(void *data) { mesh_worker *mw = data; mw->face_buffer = malloc(FACE_BUFFER_SIZE); mw->build_buffer = malloc(BUILD_BUFFER_SIZE); // this loop only works because the compiler can't // tell that the SDL_calls don't access mw->state; // really we should barrier that stuff for(;;) { int i,j; int cx,cy; // wait for a chunk request SDL_SemWait(mw->request_received); // analyze the chunk request assert(mw->state == WSTATE_requested); cx = mw->request_cx; cy = mw->request_cy; // this is inaccurate as it can block while another thread has the cache locked mw->state = WSTATE_running; // get the chunks we need (this takes a lock and caches them) for (j=0; j < 4; ++j) for (i=0; i < 4; ++i) mw->chunks[j][i] = get_converted_fastchunk(cx-1 + i, cy-1 + j); // build the mesh based on the chunks mw->rm.build_buffer = mw->build_buffer; mw->rm.face_buffer = mw->face_buffer; build_chunk(cx, cy, mw->chunks, &mw->rm); mw->state = WSTATE_mesh_ready; // don't need to notify of this, because it gets polled // when done, free the chunks // for efficiency we just take the mutex once around the whole thing, // though this spreads the mutex logic over two files SDL_LockMutex(chunk_cache_mutex); for (j=0; j < 4; ++j) for (i=0; i < 4; ++i) { deref_fastchunk(mw->chunks[j][i]); mw->chunks[j][i] = NULL; } SDL_UnlockMutex(chunk_cache_mutex); } return 0; } int request_chunk(int chunk_x, int chunk_y) { int i; for (i=0; i < num_mesh_workers; ++i) { mesh_worker *mw = &mesh_data[i]; if (mw->state == WSTATE_idle) { mw->request_cx = chunk_x; mw->request_cy = chunk_y; mw->state = WSTATE_requested; SDL_SemPost(mw->request_received); ++num_meshes_started; return 1; } } return 0; } void prepare_threads(void) { int i; int num_proc = SDL_GetCPUCount(); if (num_proc > 6) num_mesh_workers = num_proc/2; else if (num_proc > 4) num_mesh_workers = 4; else num_mesh_workers = num_proc-1; // @TODO // Thread usage is probably pretty terrible; need to make a // separate queue of needed chunks, instead of just generating // one request per thread per frame, and a separate queue of // results. (E.g. If it takes 1.5 frames to build mesh, thread // is idle for 0.5 frames.) To fake this for now, I've just // doubled the number of threads to let those serve as a 'queue', // but that's dumb. num_mesh_workers *= 2; // try to get better thread usage if (num_mesh_workers > MAX_MESH_WORKERS) num_mesh_workers = MAX_MESH_WORKERS; for (i=0; i < num_mesh_workers; ++i) { mesh_worker *data = &mesh_data[i]; data->request_received = SDL_CreateSemaphore(0); data->chunk_server_done_processing = SDL_CreateSemaphore(0); SDL_CreateThread(mesh_worker_handler, "mesh worker", data); } } // "better" buffer uploading #if 0 if (glBufferStorage) { glDeleteBuffersARB(1, &vb->vbuf); glGenBuffersARB(1, &vb->vbuf); glBindBufferARB(GL_ARRAY_BUFFER_ARB, vb->vbuf); glBufferStorage(GL_ARRAY_BUFFER_ARB, sizeof(build_buffer), build_buffer, 0); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); } else { glBindBufferARB(GL_ARRAY_BUFFER_ARB, vb->vbuf); glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(build_buffer), build_buffer, GL_STATIC_DRAW_ARB); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); } #endif typedef struct { float x,y,z,w; } plane; static plane frustum[6]; static void matd_mul(double out[4][4], double src1[4][4], double src2[4][4]) { int i,j,k; for (j=0; j < 4; ++j) { for (i=0; i < 4; ++i) { double t=0; for (k=0; k < 4; ++k) t += src1[k][i] * src2[j][k]; out[i][j] = t; } } } // https://fgiesen.wordpress.com/2012/08/31/frustum-planes-from-the-projection-matrix/ static void compute_frustum(void) { int i; GLdouble mv[4][4],proj[4][4], mvproj[4][4]; glGetDoublev(GL_MODELVIEW_MATRIX , mv[0]); glGetDoublev(GL_PROJECTION_MATRIX, proj[0]); matd_mul(mvproj, proj, mv); for (i=0; i < 4; ++i) { (&frustum[0].x)[i] = (float) (mvproj[3][i] + mvproj[0][i]); (&frustum[1].x)[i] = (float) (mvproj[3][i] - mvproj[0][i]); (&frustum[2].x)[i] = (float) (mvproj[3][i] + mvproj[1][i]); (&frustum[3].x)[i] = (float) (mvproj[3][i] - mvproj[1][i]); (&frustum[4].x)[i] = (float) (mvproj[3][i] + mvproj[2][i]); (&frustum[5].x)[i] = (float) (mvproj[3][i] - mvproj[2][i]); } } static int test_plane(plane *p, float x0, float y0, float z0, float x1, float y1, float z1) { // return false if the box is entirely behind the plane float d=0; assert(x0 <= x1 && y0 <= y1 && z0 <= z1); if (p->x > 0) d += x1*p->x; else d += x0*p->x; if (p->y > 0) d += y1*p->y; else d += y0*p->y; if (p->z > 0) d += z1*p->z; else d += z0*p->z; return d + p->w >= 0; } static int is_box_in_frustum(float *bmin, float *bmax) { int i; for (i=0; i < 6; ++i) if (!test_plane(&frustum[i], bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2])) return 0; return 1; } float compute_priority(int cx, int cy, float x, float y) { float distx, disty, dist2; distx = (cx*16+8) - x; disty = (cy*16+8) - y; dist2 = distx*distx + disty*disty; return view_dist_in_chunks*view_dist_in_chunks * 16 * 16 - dist2; } int chunk_locations, chunks_considered, chunks_in_frustum; int quads_considered, quads_rendered; int chunk_storage_rendered, chunk_storage_considered, chunk_storage_total; int update_frustum = 1; #ifdef SHORTVIEW int max_chunk_storage = 450 << 20; int min_chunk_storage = 350 << 20; #else int max_chunk_storage = 900 << 20; int min_chunk_storage = 800 << 20; #endif float min_priority = -500; // this really wants to be in unit space, not squared space int num_meshes_uploaded; void update_meshes_from_render_thread(void) { int i; for (i=0; i < num_mesh_workers; ++i) { mesh_worker *mw = &mesh_data[i]; if (mw->state == WSTATE_mesh_ready) { upload_mesh_data(&mw->rm); ++num_meshes_uploaded; mw->state = WSTATE_idle; } } } extern float tex2_alpha; extern int global_hack; int num_threads_active; float chunk_server_activity; void render_caves(float campos[3]) { float x = campos[0], y = campos[1]; int qchunk_x, qchunk_y; int cam_x, cam_y; int i,j, rad; compute_frustum(); chunk_locations = chunks_considered = chunks_in_frustum = 0; quads_considered = quads_rendered = 0; chunk_storage_total = chunk_storage_considered = chunk_storage_rendered = 0; cam_x = (int) floor(x+0.5); cam_y = (int) floor(y+0.5); qchunk_x = (((int) floor(x)+16) >> 5) << 1; qchunk_y = (((int) floor(y)+16) >> 5) << 1; glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5); stbglUseProgram(main_prog); setup_uniforms(campos); // set uniforms to default values inefficiently glActiveTextureARB(GL_TEXTURE2_ARB); stbglEnableVertexAttribArray(0); { float lighting[2][3] = { { campos[0],campos[1],campos[2] }, { 0.75,0.75,0.65f } }; float bright = 8; lighting[1][0] *= bright; lighting[1][1] *= bright; lighting[1][2] *= bright; stbglUniform3fv(stbgl_find_uniform(main_prog, "light_source"), 2, lighting[0]); } if (global_hack) set_tex2_alpha(tex2_alpha); num_meshes_uploaded = 0; update_meshes_from_render_thread(); // traverse all in-range chunks and analyze them for (j=-view_dist_in_chunks; j <= view_dist_in_chunks; j += 2) { for (i=-view_dist_in_chunks; i <= view_dist_in_chunks; i += 2) { float priority; int cx = qchunk_x + i; int cy = qchunk_y + j; priority = compute_priority(cx, cy, x, y); if (priority >= min_priority) { int slot_x = (cx>>1) & (CACHED_MESH_NUM_X-1); int slot_y = (cy>>1) & (CACHED_MESH_NUM_Y-1); chunk_mesh *cm = &cached_chunk_mesh[slot_y][slot_x]; ++chunk_locations; if (cm->state == STATE_valid && priority >= 0) { // check if chunk pos actually matches if (cm->chunk_x != cx || cm->chunk_y != cy) { // we have a stale chunk we need to recreate free_chunk(slot_x, slot_y); // it probably will have already gotten freed, but just in case } } if (cm->state == STATE_invalid) { cm->chunk_x = cx; cm->chunk_y = cy; cm->state = STATE_needed; } cm->priority = priority; } } } // draw front-to-back for (rad = 0; rad <= view_dist_in_chunks; rad += 2) { for (j=-rad; j <= rad; j += 2) { // if j is +- rad, then iterate i through all values // if j isn't +-rad, then i should be only -rad & rad int step = 2; if (abs(j) != rad) step = 2*rad; for (i=-rad; i <= rad; i += step) { int cx = qchunk_x + i; int cy = qchunk_y + j; int slot_x = (cx>>1) & (CACHED_MESH_NUM_X-1); int slot_y = (cy>>1) & (CACHED_MESH_NUM_Y-1); chunk_mesh *cm = &cached_chunk_mesh[slot_y][slot_x]; if (cm->state == STATE_valid && cm->priority >= 0) { ++chunks_considered; quads_considered += cm->num_quads; if (is_box_in_frustum(cm->bounds[0], cm->bounds[1])) { ++chunks_in_frustum; // @TODO if in range stbglUniform3fv(uniform_loc[STBVOX_UNIFORM_transform], 3, cm->transform[0]); glBindBufferARB(GL_ARRAY_BUFFER_ARB, cm->vbuf); glVertexAttribIPointer(0, 1, GL_UNSIGNED_INT, 4, (void*) 0); glBindTexture(GL_TEXTURE_BUFFER_ARB, cm->fbuf_tex); glDrawArrays(GL_QUADS, 0, cm->num_quads*4); quads_rendered += cm->num_quads; chunk_storage_rendered += cm->vbuf_size + cm->fbuf_size; } chunk_storage_considered += cm->vbuf_size + cm->fbuf_size; } } } } stbglDisableVertexAttribArray(0); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); glActiveTextureARB(GL_TEXTURE0_ARB); stbglUseProgram(0); num_meshes_started = 0; { #define MAX_QUEUE 8 float highest_priority[MAX_QUEUE]; int highest_i[MAX_QUEUE], highest_j[MAX_QUEUE]; float lowest_priority = view_dist_in_chunks * view_dist_in_chunks * 16 * 16.0f; int lowest_i = -1, lowest_j = -1; for (i=0; i < MAX_QUEUE; ++i) { highest_priority[i] = min_priority; highest_i[i] = -1; highest_j[i] = -1; } for (j=0; j < CACHED_MESH_NUM_Y; ++j) { for (i=0; i < CACHED_MESH_NUM_X; ++i) { chunk_mesh *cm = &cached_chunk_mesh[j][i]; if (cm->state == STATE_valid) { cm->priority = compute_priority(cm->chunk_x, cm->chunk_y, x, y); chunk_storage_total += cm->vbuf_size + cm->fbuf_size; if (cm->priority < lowest_priority) { lowest_priority = cm->priority; lowest_i = i; lowest_j = j; } } if (cm->state == STATE_needed) { cm->priority = compute_priority(cm->chunk_x, cm->chunk_y, x, y); if (cm->priority < min_priority) cm->state = STATE_invalid; else if (cm->priority > highest_priority[0]) { int k; highest_priority[0] = cm->priority; highest_i[0] = i; highest_j[0] = j; // bubble this up to right place for (k=0; k < MAX_QUEUE-1; ++k) { if (highest_priority[k] > highest_priority[k+1]) { highest_priority[k] = highest_priority[k+1]; highest_priority[k+1] = cm->priority; highest_i[k] = highest_i[k+1]; highest_i[k+1] = i; highest_j[k] = highest_j[k+1]; highest_j[k+1] = j; } else { break; } } } } } } // I couldn't find any straightforward logic that avoids // the hysteresis problem of continually creating & freeing // a block on the margin, so I just don't free a block until // it's out of range, but this doesn't actually correctly // handle when the cache is too small for the given range if (chunk_storage_total >= min_chunk_storage && lowest_i >= 0) { if (cached_chunk_mesh[lowest_j][lowest_i].priority < -1200) // -1000? 0? free_chunk(lowest_i, lowest_j); } if (chunk_storage_total < max_chunk_storage && highest_i[0] >= 0) { for (j=MAX_QUEUE-1; j >= 0; --j) { if (highest_j[0] >= 0) { chunk_mesh *cm = &cached_chunk_mesh[highest_j[j]][highest_i[j]]; if (request_chunk(cm->chunk_x, cm->chunk_y)) { cm->state = STATE_requested; } else { // if we couldn't queue this one, skip the remainder break; } } } } } update_meshes_from_render_thread(); num_threads_active = 0; for (i=0; i < num_mesh_workers; ++i) { num_threads_active += (mesh_data[i].state == WSTATE_running); } } uTox/third_party/stb/stb/tests/caveview/cave_parse.h0000600000175000001440000000171514003056224021646 0ustar rakusers#ifndef INCLUDE_CAVE_PARSE_H #define INCLUDE_CAVE_PARSE_H typedef struct { unsigned char block; unsigned char data; unsigned char light:4; unsigned char skylight:4; } raw_block; // this is the old fully-decoded chunk typedef struct { int xpos, zpos, max_y; int height[16][16]; raw_block rb[16][16][256]; // [z][x][y] which becomes [y][x][z] in stb } chunk; chunk *get_decoded_chunk(int chunk_x, int chunk_z); #define NUM_SEGMENTS 16 typedef struct { int max_y, xpos, zpos; unsigned char *blockdata[NUM_SEGMENTS]; unsigned char *data[NUM_SEGMENTS]; unsigned char *skylight[NUM_SEGMENTS]; unsigned char *light[NUM_SEGMENTS]; void *pointer_to_free; int refcount; // this allows multi-threaded building without wrapping in ANOTHER struct } fast_chunk; fast_chunk *get_decoded_fastchunk(int chunk_x, int chunk_z); // cache, never call free() fast_chunk *get_decoded_fastchunk_uncached(int chunk_x, int chunk_z); #endif uTox/third_party/stb/stb/tests/caveview/cave_parse.c0000600000175000001440000004151314003056224021641 0ustar rakusers#include #include #include #include #define FAST_CHUNK // disabling this enables the old, slower path that deblocks into a regular form #include "cave_parse.h" #include "stb_image.h" #include "stb.h" #define NUM_CHUNKS_PER_REGION 32 // only on one axis #define NUM_CHUNKS_PER_REGION_LOG2 5 #define NUM_COLUMNS_PER_CHUNK 16 #define NUM_COLUMNS_PER_CHUNK_LOG2 4 uint32 read_uint32_be(FILE *f) { unsigned char data[4]; fread(data, 1, 4, f); return (data[0]<<24) + (data[1]<<16) + (data[2]<<8) + data[3]; } typedef struct { uint8 *data; size_t len; int x,z; // chunk index int refcount; // for multi-threading } compressed_chunk; typedef struct { int x,z; uint32 sector_data[NUM_CHUNKS_PER_REGION][NUM_CHUNKS_PER_REGION]; } region; size_t cached_compressed=0; FILE *last_region; int last_region_x; int last_region_z; int opened=0; static void open_file(int reg_x, int reg_z) { if (!opened || last_region_x != reg_x || last_region_z != reg_z) { char filename[256]; if (last_region != NULL) fclose(last_region); sprintf(filename, "r.%d.%d.mca", reg_x, reg_z); last_region = fopen(filename, "rb"); last_region_x = reg_x; last_region_z = reg_z; opened = 1; } } static region *load_region(int reg_x, int reg_z) { region *r; int x,z; open_file(reg_x, reg_z); r = malloc(sizeof(*r)); if (last_region == NULL) { memset(r, 0, sizeof(*r)); } else { fseek(last_region, 0, SEEK_SET); for (z=0; z < NUM_CHUNKS_PER_REGION; ++z) for (x=0; x < NUM_CHUNKS_PER_REGION; ++x) r->sector_data[z][x] = read_uint32_be(last_region); } r->x = reg_x; r->z = reg_z; return r; } void free_region(region *r) { free(r); } #define MAX_MAP_REGIONS 64 // in one axis: 64 regions * 32 chunk/region * 16 columns/chunk = 16384 columns region *regions[MAX_MAP_REGIONS][MAX_MAP_REGIONS]; static region *get_region(int reg_x, int reg_z) { int slot_x = reg_x & (MAX_MAP_REGIONS-1); int slot_z = reg_z & (MAX_MAP_REGIONS-1); region *r; r = regions[slot_z][slot_x]; if (r) { if (r->x == reg_x && r->z == reg_z) return r; free_region(r); } r = load_region(reg_x, reg_z); regions[slot_z][slot_x] = r; return r; } // about one region, so size should be ok #define NUM_CACHED_X 64 #define NUM_CACHED_Z 64 // @TODO: is it really worth caching these? we probably can just // pull them from the disk cache nearly as efficiently. // Can test that by setting to 1x1? compressed_chunk *cached_chunk[NUM_CACHED_Z][NUM_CACHED_X]; static void deref_compressed_chunk(compressed_chunk *cc) { assert(cc->refcount > 0); --cc->refcount; if (cc->refcount == 0) { if (cc->data) free(cc->data); free(cc); } } static compressed_chunk *get_compressed_chunk(int chunk_x, int chunk_z) { int slot_x = chunk_x & (NUM_CACHED_X-1); int slot_z = chunk_z & (NUM_CACHED_Z-1); compressed_chunk *cc = cached_chunk[slot_z][slot_x]; if (cc && cc->x == chunk_x && cc->z == chunk_z) return cc; else { int reg_x = chunk_x >> NUM_CHUNKS_PER_REGION_LOG2; int reg_z = chunk_z >> NUM_CHUNKS_PER_REGION_LOG2; region *r = get_region(reg_x, reg_z); if (cc) { deref_compressed_chunk(cc); cached_chunk[slot_z][slot_x] = NULL; } cc = malloc(sizeof(*cc)); cc->x = chunk_x; cc->z = chunk_z; { int subchunk_x = chunk_x & (NUM_CHUNKS_PER_REGION-1); int subchunk_z = chunk_z & (NUM_CHUNKS_PER_REGION-1); uint32 code = r->sector_data[subchunk_z][subchunk_x]; if (code & 255) { open_file(reg_x, reg_z); fseek(last_region, (code>>8)*4096, SEEK_SET); cc->len = (code&255)*4096; cc->data = malloc(cc->len); fread(cc->data, 1, cc->len, last_region); } else { cc->len = 0; cc->data = 0; } } cc->refcount = 1; cached_chunk[slot_z][slot_x] = cc; return cc; } } // NBT parser -- can automatically parse stuff we don't // have definitions for, but want to explicitly parse // stuff we do have definitions for. // // option 1: auto-parse everything into data structures, // then read those // // option 2: have a "parse next object" which // doesn't resolve whether it expands its children // yet, and then the user either says "expand" or // "skip" after looking at the name. Anything with // "children" without names can't go through this // interface. // // Let's try option 2. typedef struct { unsigned char *buffer_start; unsigned char *buffer_end; unsigned char *cur; int nesting; char temp_buffer[256]; } nbt; enum { TAG_End=0, TAG_Byte=1, TAG_Short=2, TAG_Int=3, TAG_Long=4, TAG_Float=5, TAG_Double=6, TAG_Byte_Array=7, TAG_String=8, TAG_List=9, TAG_Compound=10, TAG_Int_Array=11 }; static void nbt_get_string_data(unsigned char *data, char *buffer, size_t bufsize) { int len = data[0]*256 + data[1]; int i; for (i=0; i < len && i+1 < (int) bufsize; ++i) buffer[i] = (char) data[i+2]; buffer[i] = 0; } static char *nbt_peek(nbt *n) { unsigned char type = *n->cur; if (type == TAG_End) return NULL; nbt_get_string_data(n->cur+1, n->temp_buffer, sizeof(n->temp_buffer)); return n->temp_buffer; } static uint32 nbt_parse_uint32(unsigned char *buffer) { return (buffer[0] << 24) + (buffer[1]<<16) + (buffer[2]<<8) + buffer[3]; } static void nbt_skip(nbt *n); // skip an item that doesn't have an id or name prefix (usable in lists) static void nbt_skip_raw(nbt *n, unsigned char type) { switch (type) { case TAG_Byte : n->cur += 1; break; case TAG_Short : n->cur += 2; break; case TAG_Int : n->cur += 4; break; case TAG_Long : n->cur += 8; break; case TAG_Float : n->cur += 4; break; case TAG_Double: n->cur += 8; break; case TAG_Byte_Array: n->cur += 4 + 1*nbt_parse_uint32(n->cur); break; case TAG_Int_Array : n->cur += 4 + 4*nbt_parse_uint32(n->cur); break; case TAG_String : n->cur += 2 + (n->cur[0]*256 + n->cur[1]); break; case TAG_List : { unsigned char list_type = *n->cur++; unsigned int list_len = nbt_parse_uint32(n->cur); unsigned int i; n->cur += 4; // list_len for (i=0; i < list_len; ++i) nbt_skip_raw(n, list_type); break; } case TAG_Compound : { while (*n->cur != TAG_End) nbt_skip(n); nbt_skip(n); // skip the TAG_end break; } } assert(n->cur <= n->buffer_end); } static void nbt_skip(nbt *n) { unsigned char type = *n->cur++; if (type == TAG_End) return; // skip name n->cur += (n->cur[0]*256 + n->cur[1]) + 2; nbt_skip_raw(n, type); } // byteswap static void nbt_swap(unsigned char *ptr, int len) { int i; for (i=0; i < (len>>1); ++i) { unsigned char t = ptr[i]; ptr[i] = ptr[len-1-i]; ptr[len-1-i] = t; } } // pass in the expected type, fail if doesn't match // returns a pointer to the data, byteswapped if appropriate static void *nbt_get_fromlist(nbt *n, unsigned char type, int *len) { unsigned char *ptr; assert(type != TAG_Compound); assert(type != TAG_List); // we could support getting lists of primitives as if they were arrays, but eh if (len) *len = 1; ptr = n->cur; switch (type) { case TAG_Byte : break; case TAG_Short : nbt_swap(ptr, 2); break; case TAG_Int : nbt_swap(ptr, 4); break; case TAG_Long : nbt_swap(ptr, 8); break; case TAG_Float : nbt_swap(ptr, 4); break; case TAG_Double: nbt_swap(ptr, 8); break; case TAG_Byte_Array: *len = nbt_parse_uint32(ptr); ptr += 4; break; case TAG_Int_Array: { int i; *len = nbt_parse_uint32(ptr); ptr += 4; for (i=0; i < *len; ++i) nbt_swap(ptr + 4*i, 4); break; } default: assert(0); // unhandled case } nbt_skip_raw(n, type); return ptr; } static void *nbt_get(nbt *n, unsigned char type, int *len) { assert(n->cur[0] == type); n->cur += 3 + (n->cur[1]*256+n->cur[2]); return nbt_get_fromlist(n, type, len); } static void nbt_begin_compound(nbt *n) // start a compound { assert(*n->cur == TAG_Compound); // skip header n->cur += 3 + (n->cur[1]*256 + n->cur[2]); ++n->nesting; } static void nbt_begin_compound_in_list(nbt *n) // start a compound { ++n->nesting; } static void nbt_end_compound(nbt *n) // end a compound { assert(*n->cur == TAG_End); assert(n->nesting != 0); ++n->cur; --n->nesting; } // @TODO no interface to get lists from lists static int nbt_begin_list(nbt *n, unsigned char type) { uint32 len; unsigned char *ptr; ptr = n->cur + 3 + (n->cur[1]*256 + n->cur[2]); if (ptr[0] != type) return -1; n->cur = ptr; len = nbt_parse_uint32(n->cur+1); assert(n->cur[0] == type); // @TODO keep a stack with the count to make sure they do it right ++n->nesting; n->cur += 5; return (int) len; } static void nbt_end_list(nbt *n) { --n->nesting; } // raw_block chunk is 16x256x16x4 = 2^(4+8+4+2) = 256KB // // if we want to process 64x64x256 at a time, that will be: // 4*4*256KB => 4MB per area in raw_block // // (plus we maybe need to decode adjacent regions) #ifdef FAST_CHUNK typedef fast_chunk parse_chunk; #else typedef chunk parse_chunk; #endif static parse_chunk *minecraft_chunk_parse(unsigned char *data, size_t len) { char *s; parse_chunk *c = NULL; nbt n_store, *n = &n_store; n->buffer_start = data; n->buffer_end = data + len; n->cur = n->buffer_start; n->nesting = 0; nbt_begin_compound(n); while ((s = nbt_peek(n)) != NULL) { if (!strcmp(s, "Level")) { int *height; c = malloc(sizeof(*c)); #ifdef FAST_CHUNK memset(c, 0, sizeof(*c)); c->pointer_to_free = data; #else c->rb[15][15][255].block = 0; #endif c->max_y = 0; nbt_begin_compound(n); while ((s = nbt_peek(n)) != NULL) { if (!strcmp(s, "xPos")) c->xpos = *(int *) nbt_get(n, TAG_Int, 0); else if (!strcmp(s, "zPos")) c->zpos = *(int *) nbt_get(n, TAG_Int, 0); else if (!strcmp(s, "Sections")) { int count = nbt_begin_list(n, TAG_Compound), i; if (count == -1) { // this not-a-list case happens in The End and I'm not sure // what it means... possibly one of those silly encodings // where it's not encoded as a list if there's only one? // not worth figuring out nbt_skip(n); count = -1; } for (i=0; i < count; ++i) { int yi, len; uint8 *light = NULL, *blocks = NULL, *data = NULL, *skylight = NULL; nbt_begin_compound_in_list(n); while ((s = nbt_peek(n)) != NULL) { if (!strcmp(s, "Y")) yi = * (uint8 *) nbt_get(n, TAG_Byte, 0); else if (!strcmp(s, "BlockLight")) { light = nbt_get(n, TAG_Byte_Array, &len); assert(len == 2048); } else if (!strcmp(s, "Blocks")) { blocks = nbt_get(n, TAG_Byte_Array, &len); assert(len == 4096); } else if (!strcmp(s, "Data")) { data = nbt_get(n, TAG_Byte_Array, &len); assert(len == 2048); } else if (!strcmp(s, "SkyLight")) { skylight = nbt_get(n, TAG_Byte_Array, &len); assert(len == 2048); } } nbt_end_compound(n); assert(yi < 16); #ifndef FAST_CHUNK // clear data below current max_y { int x,z; while (c->max_y < yi*16) { for (x=0; x < 16; ++x) for (z=0; z < 16; ++z) c->rb[z][x][c->max_y].block = 0; ++c->max_y; } } // now assemble the data { int x,y,z, o2=0,o4=0; for (y=0; y < 16; ++y) { for (z=0; z < 16; ++z) { for (x=0; x < 16; x += 2) { raw_block *rb = &c->rb[15-z][x][y + yi*16]; // 15-z because switching to z-up will require flipping an axis rb[0].block = blocks[o4]; rb[0].light = light[o2] & 15; rb[0].data = data[o2] & 15; rb[0].skylight = skylight[o2] & 15; rb[256].block = blocks[o4+1]; rb[256].light = light[o2] >> 4; rb[256].data = data[o2] >> 4; rb[256].skylight = skylight[o2] >> 4; o2 += 1; o4 += 2; } } } c->max_y += 16; } #else c->blockdata[yi] = blocks; c->data [yi] = data; c->light [yi] = light; c->skylight [yi] = skylight; #endif } //nbt_end_list(n); } else if (!strcmp(s, "HeightMap")) { height = nbt_get(n, TAG_Int_Array, &len); assert(len == 256); } else nbt_skip(n); } nbt_end_compound(n); } else nbt_skip(n); } nbt_end_compound(n); assert(n->cur == n->buffer_end); return c; } #define MAX_DECODED_CHUNK_X 64 #define MAX_DECODED_CHUNK_Z 64 typedef struct { int cx,cz; fast_chunk *fc; int valid; } decoded_buffer; static decoded_buffer decoded_buffers[MAX_DECODED_CHUNK_Z][MAX_DECODED_CHUNK_X]; void lock_chunk_get_mutex(void); void unlock_chunk_get_mutex(void); #ifdef FAST_CHUNK fast_chunk *get_decoded_fastchunk_uncached(int chunk_x, int chunk_z) { unsigned char *decoded; compressed_chunk *cc; int inlen; int len; fast_chunk *fc; lock_chunk_get_mutex(); cc = get_compressed_chunk(chunk_x, chunk_z); if (cc->len != 0) ++cc->refcount; unlock_chunk_get_mutex(); if (cc->len == 0) return NULL; assert(cc != NULL); assert(cc->data[4] == 2); inlen = nbt_parse_uint32(cc->data); decoded = stbi_zlib_decode_malloc_guesssize(cc->data+5, inlen, inlen*3, &len); assert(decoded != NULL); assert(len != 0); lock_chunk_get_mutex(); deref_compressed_chunk(cc); unlock_chunk_get_mutex(); #ifdef FAST_CHUNK fc = minecraft_chunk_parse(decoded, len); #else fc = NULL; #endif if (fc == NULL) free(decoded); return fc; } decoded_buffer *get_decoded_buffer(int chunk_x, int chunk_z) { decoded_buffer *db = &decoded_buffers[chunk_z&(MAX_DECODED_CHUNK_Z-1)][chunk_x&(MAX_DECODED_CHUNK_X-1)]; if (db->valid) { if (db->cx == chunk_x && db->cz == chunk_z) return db; if (db->fc) { free(db->fc->pointer_to_free); free(db->fc); } } db->cx = chunk_x; db->cz = chunk_z; db->valid = 1; db->fc = 0; { db->fc = get_decoded_fastchunk_uncached(chunk_x, chunk_z); return db; } } fast_chunk *get_decoded_fastchunk(int chunk_x, int chunk_z) { decoded_buffer *db = get_decoded_buffer(chunk_x, chunk_z); return db->fc; } #endif #ifndef FAST_CHUNK chunk *get_decoded_chunk_raw(int chunk_x, int chunk_z) { unsigned char *decoded; compressed_chunk *cc = get_compressed_chunk(chunk_x, chunk_z); assert(cc != NULL); if (cc->len == 0) return NULL; else { chunk *ch; int inlen = nbt_parse_uint32(cc->data); int len; assert(cc->data[4] == 2); decoded = stbi_zlib_decode_malloc_guesssize(cc->data+5, inlen, inlen*3, &len); assert(decoded != NULL); #ifdef FAST_CHUNK ch = NULL; #else ch = minecraft_chunk_parse(decoded, len); #endif free(decoded); return ch; } } static chunk *decoded_chunks[MAX_DECODED_CHUNK_Z][MAX_DECODED_CHUNK_X]; chunk *get_decoded_chunk(int chunk_x, int chunk_z) { chunk *c = decoded_chunks[chunk_z&(MAX_DECODED_CHUNK_Z-1)][chunk_x&(MAX_DECODED_CHUNK_X-1)]; if (c && c->xpos == chunk_x && c->zpos == chunk_z) return c; if (c) free(c); c = get_decoded_chunk_raw(chunk_x, chunk_z); decoded_chunks[chunk_z&(MAX_DECODED_CHUNK_Z-1)][chunk_x&(MAX_DECODED_CHUNK_X-1)] = c; return c; } #endif uTox/third_party/stb/stb/tests/caveview/cave_mesher.c0000600000175000001440000007022514003056224022014 0ustar rakusers// This file takes minecraft chunks (decoded by cave_parse) and // uses stb_voxel_render to turn them into vertex buffers. #define STB_GLEXT_DECLARE "glext_list.h" #include "stb_gl.h" #include "stb_image.h" #include "stb_glprog.h" #include "caveview.h" #include "cave_parse.h" #include "stb.h" #include "sdl.h" #include "sdl_thread.h" #include //#define VHEIGHT_TEST //#define STBVOX_OPTIMIZED_VHEIGHT #define STBVOX_CONFIG_MODE 1 #define STBVOX_CONFIG_OPENGL_MODELVIEW #define STBVOX_CONFIG_PREFER_TEXBUFFER //#define STBVOX_CONFIG_LIGHTING_SIMPLE #define STBVOX_CONFIG_FOG_SMOOTHSTEP //#define STBVOX_CONFIG_PREMULTIPLIED_ALPHA // this doesn't work properly alpha test without next #define //#define STBVOX_CONFIG_UNPREMULTIPLY // slower, fixes alpha test makes windows & fancy leaves look better //#define STBVOX_CONFIG_TEX1_EDGE_CLAMP #define STBVOX_CONFIG_DISABLE_TEX2 //#define STBVOX_CONFIG_DOWN_TEXLERP_PACKED #define STBVOX_CONFIG_ROTATION_IN_LIGHTING #define STB_VOXEL_RENDER_IMPLEMENTATION #include "stb_voxel_render.h" extern void ods(char *fmt, ...); //#define FANCY_LEAVES // nearly 2x the triangles when enabled (if underground is filled) #define FAST_CHUNK #define IN_PLACE #define SKIP_TERRAIN 48 // use to avoid building underground stuff // allows you to see what perf would be like if underground was efficiently culled, // or if you were making a game without underground enum { C_empty, C_solid, C_trans, C_cross, C_water, C_slab, C_stair, C_force, }; unsigned char geom_map[] = { STBVOX_GEOM_empty, STBVOX_GEOM_solid, STBVOX_GEOM_transp, STBVOX_GEOM_crossed_pair, STBVOX_GEOM_solid, STBVOX_GEOM_slab_lower, STBVOX_GEOM_floor_slope_north_is_top, STBVOX_GEOM_force, }; unsigned char minecraft_info[256][7] = { { C_empty, 0,0,0,0,0,0 }, { C_solid, 1,1,1,1,1,1 }, { C_solid, 3,3,3,3,40,2 }, { C_solid, 2,2,2,2,2,2 }, { C_solid, 16,16,16,16,16,16 }, { C_solid, 4,4,4,4,4,4 }, { C_cross, 15,15,15,15 }, { C_solid, 17,17,17,17,17,17 }, // 8 { C_water, 223,223,223,223,223,223 }, { C_water, 223,223,223,223,223,223 }, { C_solid, 255,255,255,255,255,255 }, { C_solid, 255,255,255,255,255,255 }, { C_solid, 18,18,18,18,18,18 }, { C_solid, 19,19,19,19,19,19 }, { C_solid, 32,32,32,32,32,32 }, { C_solid, 33,33,33,33,33,33 }, // 16 { C_solid, 34,34,34,34,34,34 }, { C_solid, 20,20,20,20,21,21 }, #ifdef FANCY_LEAVES { C_force, 52,52,52,52,52,52 }, // leaves #else { C_solid, 53,53,53,53,53,53 }, // leaves #endif { C_solid, 24,24,24,24,24,24 }, { C_trans, 49,49,49,49,49,49 }, // glass { C_solid, 160,160,160,160,160,160 }, { C_solid, 144,144,144,144,144,144 }, { C_solid, 46,45,45,45,62,62 }, // 24 { C_solid, 192,192,192,192, 176,176 }, { C_solid, 74,74,74,74,74,74 }, { C_empty }, // bed { C_empty }, // powered rail { C_empty }, // detector rail { C_solid, 106,108,109,108,108,108 }, { C_empty }, // cobweb=11 { C_cross, 39,39,39,39 }, // 32 { C_cross, 55,55,55,55,0,0 }, { C_solid, 107,108,109,108,108,108 }, { C_empty }, // piston head { C_solid, 64,64,64,64,64,64 }, // various colors { C_empty }, // unused { C_cross, 13,13,13,13,0,0 }, { C_cross, 12,12,12,12,0,0 }, { C_cross, 29,29,29,29,0,0 }, // 40 { C_cross, 28,28,28,28,0,0 }, { C_solid, 23,23,23,23,23,23 }, { C_solid, 22,22,22,22,22,22 }, { C_solid, 5,5,5,5,6,6, }, { C_slab , 5,5,5,5,6,6, }, { C_solid, 7,7,7,7,7,7, }, { C_solid, 8,8,8,8,9,10 }, { C_solid, 35,35,35,35,4,4, }, // 48 { C_solid, 36,36,36,36,36,36 }, { C_solid, 37,37,37,37,37,37 }, { C_cross, 80,80,80,80,80,80 }, // torch { C_empty }, // fire { C_trans, 65,65,65,65,65,65 }, { C_stair, 4,4,4,4,4,4 }, { C_solid, 26,26,26,27,25,25 }, { C_empty }, // redstone // 56 { C_solid, 50,50,50,50,50,50 }, { C_solid, 26,26,26,26,26,26 }, { C_solid, 60,59,59,59,43,43 }, { C_cross, 95,95,95,95 }, { C_solid, 2,2,2,2,86,2 }, { C_solid, 44,45,45,45,62,62 }, { C_solid, 61,45,45,45,62,62 }, { C_empty }, // sign // 64 { C_empty }, // door { C_empty }, // ladder { C_empty }, // rail { C_stair, 16,16,16,16,16,16 }, // cobblestone stairs { C_empty }, // sign { C_empty }, // lever { C_empty }, // stone pressure plate { C_empty }, // iron door // 72 { C_empty }, // wooden pressure { C_solid, 51,51,51,51,51,51 }, { C_solid, 51,51,51,51,51,51 }, { C_empty }, { C_empty }, { C_empty }, { C_empty }, // snow on block below, do as half slab? { C_solid, 67,67,67,67,67,67 }, // 80 { C_solid, 66,66,66,66,66,66 }, { C_solid, 70,70,70,70,69,71 }, { C_solid, 72,72,72,72,72,72 }, { C_cross, 73,73,73,73,73,73 }, { C_solid, 74,74,74,74,75,74 }, { C_empty }, // fence { C_solid,119,118,118,118,102,102 }, { C_solid,103,103,103,103,103,103 }, // 88 { C_solid, 104,104,104,104,104,104 }, { C_solid, 105,105,105,105,105,105 }, { C_solid, 167,167,167,167,167,167 }, { C_solid, 120,118,118,118,102,102 }, { C_empty }, // cake { C_empty }, // repeater { C_empty }, // repeater { C_solid, 49,49,49,49,49,49 }, // colored glass // 96 { C_empty }, { C_empty }, { C_solid, 54,54,54,54,54,54 }, { C_solid, 125,125,125,125,125,125 }, { C_solid, 126,126,126,126,126,126 }, { C_empty }, // bars { C_trans, 49,49,49,49,49,49 }, // glass pane { C_solid, 136,136,136,136,137,137 }, // melon // 104 { C_empty }, // pumpkin stem { C_empty }, // melon stem { C_empty }, // vines { C_empty }, // gate { C_stair, 7,7,7,7,7,7, }, // brick stairs { C_stair, 54,54,54,54,54,54 }, // stone brick stairs { C_empty }, // mycelium { C_empty }, // lily pad // 112 { C_solid, 224,224,224,224,224,224 }, { C_empty }, // nether brick fence { C_stair, 224,224,224,224,224,224 }, // nether brick stairs { C_empty }, // nether wart { C_solid, 182,182,182,182,166,183 }, { C_empty }, // brewing stand { C_empty }, // cauldron { C_empty }, // end portal // 120 { C_solid, 159,159,159,159,158,158 }, { C_solid, 175,175,175,175,175,175 }, { C_empty }, // dragon egg { C_solid, 211,211,211,211,211,211 }, { C_solid, 212,212,212,212,212,212 }, { C_solid, 4,4,4,4,4,4, }, // wood double-slab { C_slab , 4,4,4,4,4,4, }, // wood slab { C_empty }, // cocoa // 128 { C_solid, 192,192,192,192,176,176 }, // sandstone stairs { C_solid, 32,32,32,32,32,32 }, // emerald ore { C_solid, 26,26,26,27,25,25 }, // ender chest { C_empty }, { C_empty }, { C_solid, 23,23,23,23,23,23 }, // emerald block { C_solid, 198,198,198,198,198,198 }, // spruce stairs { C_solid, 214,214,214,214,214,214 }, // birch stairs // 136 { C_stair, 199,199,199,199,199,199 }, // jungle stairs { C_empty }, // command block { C_empty }, // beacon { C_slab, 16,16,16,16,16,16 }, // cobblestone wall { C_empty }, // flower pot { C_empty }, // carrot { C_empty }, // potatoes { C_empty }, // wooden button // 144 { C_empty }, // mob head { C_empty }, // anvil { C_solid, 26,26,26,27,25,25 }, // trapped chest { C_empty }, // weighted pressure plate light { C_empty }, // weighted pressure plat eheavy { C_empty }, // comparator inactive { C_empty }, // comparator active { C_empty }, // daylight sensor // 152 { C_solid, 135,135,135,135,135,135 }, // redstone block { C_solid, 0,0,0,0,0,0, }, // nether quartz ore { C_empty }, // hopper { C_solid, 22,22,22,22,22,22 }, // quartz block { C_stair, 22,22,22,22,22,22 }, // quartz stairs { C_empty }, // activator rail { C_solid, 46,45,45,45,62,62 }, // dropper { C_solid, 72,72,72,72,72,72 }, // stained clay // 160 { C_trans, 49,49,49,49,49,49 }, // stained glass pane #ifdef FANCY_LEAVES { C_force, 52,52,52,52,52,52 }, // leaves #else { C_solid, 53,53,53,53,53,53 }, // acacia leaves #endif { C_solid, 20,20,20,20,21,21 }, // acacia tree { C_solid, 199,199,199,199,199,199 }, // acacia wood stairs { C_solid, 198,198,198,198,198,198 }, // dark oak stairs { C_solid, 146,146,146,146,146,146 }, // slime block { C_solid, 176,176,176,176,176,176 }, // red sandstone { C_solid, 176,176,176,176,176,176 }, // red sandstone // 168 { C_empty }, { C_empty }, { C_empty }, { C_empty }, { C_solid, 72,72,72,72,72,72 }, // hardened clay { C_empty }, { C_empty }, { C_empty }, // 176 { C_empty }, { C_empty }, { C_solid, 176,176,176,176,176,176 }, // red sandstone }; unsigned char minecraft_tex1_for_blocktype[256][6]; unsigned char effective_blocktype[256]; unsigned char minecraft_color_for_blocktype[256][6]; unsigned char minecraft_geom_for_blocktype[256]; uint8 build_buffer[BUILD_BUFFER_SIZE]; uint8 face_buffer[FACE_BUFFER_SIZE]; //GLuint vbuf, fbuf, fbuf_tex; //unsigned char tex1_for_blocktype[256][6]; //unsigned char blocktype[34][34][257]; //unsigned char lighting[34][34][257]; // a superchunk is 64x64x256, with the border blocks computed as well, // which means we need 4x4 chunks plus 16 border chunks plus 4 corner chunks #define SUPERCHUNK_X 4 #define SUPERCHUNK_Y 4 unsigned char remap_data[16][16]; unsigned char remap[256]; unsigned char rotate_data[4] = { 1,3,2,0 }; void convert_fastchunk_inplace(fast_chunk *fc) { int i; int num_blocks=0, step=0; unsigned char rot[4096]; #ifndef IN_PLACE unsigned char *storage; #endif memset(rot, 0, 4096); for (i=0; i < 16; ++i) num_blocks += fc->blockdata[i] != NULL; #ifndef IN_PLACE storage = malloc(16*16*16*2 * num_blocks); #endif for (i=0; i < 16; ++i) { if (fc->blockdata[i]) { int o=0; unsigned char *bd,*dd,*lt,*sky; unsigned char *out, *outb; // this ordering allows us to determine which data we can safely overwrite for in-place processing bd = fc->blockdata[i]; dd = fc->data[i]; lt = fc->light[i]; sky = fc->skylight[i]; #ifdef IN_PLACE out = bd; #else out = storage + 16*16*16*2*step; #endif // bd is written in place, but also reads from dd for (o=0; o < 16*16*16/2; o += 1) { unsigned char v1,v2; unsigned char d = dd[o]; v1 = bd[o*2+0]; v2 = bd[o*2+1]; if (remap[v1]) { //unsigned char d = bd[o] & 15; v1 = remap_data[remap[v1]][d&15]; rot[o*2+0] = rotate_data[d&3]; } else v1 = effective_blocktype[v1]; if (remap[v2]) { //unsigned char d = bd[o] >> 4; v2 = remap_data[remap[v2]][d>>4]; rot[o*2+1] = rotate_data[(d>>4)&3]; } else v2 = effective_blocktype[v2]; out[o*2+0] = v1; out[o*2+1] = v2; } // this reads from lt & sky #ifndef IN_PLACE outb = out + 16*16*16; ++step; #endif // MC used to write in this order and it makes it possible to compute in-place if (dd < sky && sky < lt) { // @TODO go this path always if !IN_PLACE #ifdef IN_PLACE outb = dd; #endif for (o=0; o < 16*16*16/2; ++o) { int bright; bright = (lt[o]&15)*12 + 15 + (sky[o]&15)*16; if (bright > 255) bright = 255; if (bright < 32) bright = 32; outb[o*2+0] = STBVOX_MAKE_LIGHTING_EXT((unsigned char) bright, (rot[o*2+0]&3)); bright = (lt[o]>>4)*12 + 15 + (sky[o]>>4)*16; if (bright > 255) bright = 255; if (bright < 32) bright = 32; outb[o*2+1] = STBVOX_MAKE_LIGHTING_EXT((unsigned char) bright, (rot[o*2+1]&3)); } } else { // @TODO: if blocktype is in between others, this breaks; need to find which side has two pointers, and use that // overwrite rot[] array, then copy out #ifdef IN_PLACE outb = (dd < sky) ? dd : sky; if (lt < outb) lt = outb; #endif for (o=0; o < 16*16*16/2; ++o) { int bright; bright = (lt[o]&15)*12 + 15 + (sky[o]&15)*16; if (bright > 255) bright = 255; if (bright < 32) bright = 32; rot[o*2+0] = STBVOX_MAKE_LIGHTING_EXT((unsigned char) bright, (rot[o*2+0]&3)); bright = (lt[o]>>4)*12 + 15 + (sky[o]>>4)*16; if (bright > 255) bright = 255; if (bright < 32) bright = 32; rot[o*2+1] = STBVOX_MAKE_LIGHTING_EXT((unsigned char) bright, (rot[o*2+1]&3)); } memcpy(outb, rot, 4096); fc->data[i] = outb; } #ifndef IN_PLACE fc->blockdata[i] = out; fc->data[i] = outb; #endif } } #ifndef IN_PLACE free(fc->pointer_to_free); fc->pointer_to_free = storage; #endif } void make_converted_fastchunk(fast_chunk *fc, int x, int y, int segment, uint8 *sv_blocktype, uint8 *sv_lighting) { int z; assert(fc == NULL || (fc->refcount > 0 && fc->refcount < 64)); if (fc == NULL || fc->blockdata[segment] == NULL) { for (z=0; z < 16; ++z) { sv_blocktype[z] = C_empty; sv_lighting[z] = 255; } } else { unsigned char *block = fc->blockdata[segment]; unsigned char *data = fc->data[segment]; y = 15-y; for (z=0; z < 16; ++z) { sv_blocktype[z] = block[z*256 + y*16 + x]; sv_lighting [z] = data [z*256 + y*16 + x]; } } } #define CHUNK_CACHE 64 typedef struct { int valid; int chunk_x, chunk_y; fast_chunk *fc; } cached_converted_chunk; cached_converted_chunk chunk_cache[CHUNK_CACHE][CHUNK_CACHE]; int cache_size = CHUNK_CACHE; void reset_cache_size(int size) { int i,j; for (j=size; j < cache_size; ++j) { for (i=size; i < cache_size; ++i) { cached_converted_chunk *ccc = &chunk_cache[j][i]; if (ccc->valid) { if (ccc->fc) { free(ccc->fc->pointer_to_free); free(ccc->fc); ccc->fc = NULL; } ccc->valid = 0; } } } cache_size = size; } // this must be called inside mutex void deref_fastchunk(fast_chunk *fc) { if (fc) { assert(fc->refcount > 0); --fc->refcount; if (fc->refcount == 0) { free(fc->pointer_to_free); free(fc); } } } SDL_mutex * chunk_cache_mutex; SDL_mutex * chunk_get_mutex; void lock_chunk_get_mutex(void) { SDL_LockMutex(chunk_get_mutex); } void unlock_chunk_get_mutex(void) { SDL_UnlockMutex(chunk_get_mutex); } fast_chunk *get_converted_fastchunk(int chunk_x, int chunk_y) { int slot_x = (chunk_x & (cache_size-1)); int slot_y = (chunk_y & (cache_size-1)); fast_chunk *fc; cached_converted_chunk *ccc; SDL_LockMutex(chunk_cache_mutex); ccc = &chunk_cache[slot_y][slot_x]; if (ccc->valid) { if (ccc->chunk_x == chunk_x && ccc->chunk_y == chunk_y) { fast_chunk *fc = ccc->fc; if (fc) ++fc->refcount; SDL_UnlockMutex(chunk_cache_mutex); return fc; } if (ccc->fc) { deref_fastchunk(ccc->fc); ccc->fc = NULL; ccc->valid = 0; } } SDL_UnlockMutex(chunk_cache_mutex); fc = get_decoded_fastchunk_uncached(chunk_x, -chunk_y); if (fc) convert_fastchunk_inplace(fc); SDL_LockMutex(chunk_cache_mutex); // another thread might have updated it, so before we overwrite it... if (ccc->fc) { deref_fastchunk(ccc->fc); ccc->fc = NULL; } if (fc) fc->refcount = 1; // 1 in the cache ccc->chunk_x = chunk_x; ccc->chunk_y = chunk_y; ccc->valid = 1; if (fc) ++fc->refcount; ccc->fc = fc; SDL_UnlockMutex(chunk_cache_mutex); return fc; } void make_map_segment_for_superchunk_preconvert(int chunk_x, int chunk_y, int segment, fast_chunk *fc_table[4][4], uint8 sv_blocktype[34][34][18], uint8 sv_lighting[34][34][18]) { int a,b; assert((chunk_x & 1) == 0); assert((chunk_y & 1) == 0); for (b=-1; b < 3; ++b) { for (a=-1; a < 3; ++a) { int xo = a*16+1; int yo = b*16+1; int x,y; fast_chunk *fc = fc_table[b+1][a+1]; for (y=0; y < 16; ++y) for (x=0; x < 16; ++x) if (xo+x >= 0 && xo+x < 34 && yo+y >= 0 && yo+y < 34) make_converted_fastchunk(fc,x,y, segment, sv_blocktype[xo+x][yo+y], sv_lighting[xo+x][yo+y]); } } } // build 1 mesh covering 2x2 chunks void build_chunk(int chunk_x, int chunk_y, fast_chunk *fc_table[4][4], raw_mesh *rm) { int a,b,z; stbvox_input_description *map; #ifdef VHEIGHT_TEST unsigned char vheight[34][34][18]; #endif #ifndef STBVOX_CONFIG_DISABLE_TEX2 unsigned char tex2_choice[34][34][18]; #endif assert((chunk_x & 1) == 0); assert((chunk_y & 1) == 0); rm->cx = chunk_x; rm->cy = chunk_y; stbvox_set_input_stride(&rm->mm, 34*18, 18); assert(rm->mm.input.geometry == NULL); map = stbvox_get_input_description(&rm->mm); map->block_tex1_face = minecraft_tex1_for_blocktype; map->block_color_face = minecraft_color_for_blocktype; map->block_geometry = minecraft_geom_for_blocktype; stbvox_reset_buffers(&rm->mm); stbvox_set_buffer(&rm->mm, 0, 0, rm->build_buffer, BUILD_BUFFER_SIZE); stbvox_set_buffer(&rm->mm, 0, 1, rm->face_buffer , FACE_BUFFER_SIZE); map->blocktype = &rm->sv_blocktype[1][1][1]; // this is (0,0,0), but we need to be able to query off the edges map->lighting = &rm->sv_lighting[1][1][1]; // fill in the top two rows of the buffer for (a=0; a < 34; ++a) { for (b=0; b < 34; ++b) { rm->sv_blocktype[a][b][16] = 0; rm->sv_lighting [a][b][16] = 255; rm->sv_blocktype[a][b][17] = 0; rm->sv_lighting [a][b][17] = 255; } } #ifndef STBVOX_CONFIG_DISABLE_TEX2 for (a=0; a < 34; ++a) { for (b=0; b < 34; ++b) { int px = chunk_x*16 + a - 1; int py = chunk_y*16 + b - 1; float dist = (float) sqrt(px*px + py*py); float s1 = (float) sin(dist / 16), s2, s3; dist = (float) sqrt((px-80)*(px-80) + (py-50)*(py-50)); s2 = (float) sin(dist / 11); for (z=0; z < 18; ++z) { s3 = (float) sin(z * 3.141592 / 8); s3 = s1*s2*s3; tex2_choice[a][b][z] = 63 & (int) stb_linear_remap(s3,-1,1, -20,83); } } } #endif for (z=256-16; z >= SKIP_TERRAIN; z -= 16) { int z0 = z; int z1 = z+16; if (z1 == 256) z1 = 255; make_map_segment_for_superchunk_preconvert(chunk_x, chunk_y, z >> 4, fc_table, rm->sv_blocktype, rm->sv_lighting); map->blocktype = &rm->sv_blocktype[1][1][1-z]; // specify location of 0,0,0 so that accessing z0..z1 gets right data map->lighting = &rm->sv_lighting[1][1][1-z]; #ifndef STBVOX_CONFIG_DISABLE_TEX2 map->tex2 = &tex2_choice[1][1][1-z]; #endif #ifdef VHEIGHT_TEST // hacky test of vheight for (a=0; a < 34; ++a) { for (b=0; b < 34; ++b) { int c; for (c=0; c < 17; ++c) { if (rm->sv_blocktype[a][b][c] != 0 && rm->sv_blocktype[a][b][c+1] == 0) { // topmost block vheight[a][b][c] = rand() & 255; rm->sv_blocktype[a][b][c] = 168; } else if (c > 0 && rm->sv_blocktype[a][b][c] != 0 && rm->sv_blocktype[a][b][c-1] == 0) { // bottommost block vheight[a][b][c] = ((rand() % 3) << 6) + ((rand() % 3) << 4) + ((rand() % 3) << 2) + (rand() % 3); rm->sv_blocktype[a][b][c] = 169; } } vheight[a][b][c] = STBVOX_MAKE_VHEIGHT(2,2,2,2); // flat top } } map->vheight = &vheight[1][1][1-z]; #endif { stbvox_set_input_range(&rm->mm, 0,0,z0, 32,32,z1); stbvox_set_default_mesh(&rm->mm, 0); stbvox_make_mesh(&rm->mm); } // copy the bottom two rows of data up to the top for (a=0; a < 34; ++a) { for (b=0; b < 34; ++b) { rm->sv_blocktype[a][b][16] = rm->sv_blocktype[a][b][0]; rm->sv_blocktype[a][b][17] = rm->sv_blocktype[a][b][1]; rm->sv_lighting [a][b][16] = rm->sv_lighting [a][b][0]; rm->sv_lighting [a][b][17] = rm->sv_lighting [a][b][1]; } } } stbvox_set_mesh_coordinates(&rm->mm, chunk_x*16, chunk_y*16, 0); stbvox_get_transform(&rm->mm, rm->transform); stbvox_set_input_range(&rm->mm, 0,0,0, 32,32,255); stbvox_get_bounds(&rm->mm, rm->bounds); rm->num_quads = stbvox_get_quad_count(&rm->mm, 0); } int next_blocktype = 255; unsigned char mc_rot[4] = { 1,3,2,0 }; // create blocktypes with rotation baked into type... // @TODO we no longer need this now that we store rotations // in lighting void build_stair_rotations(int blocktype, unsigned char *map) { int i; // use the existing block type for floor stairs; allocate a new type for ceil stairs for (i=0; i < 6; ++i) { minecraft_color_for_blocktype[next_blocktype][i] = minecraft_color_for_blocktype[blocktype][i]; minecraft_tex1_for_blocktype [next_blocktype][i] = minecraft_tex1_for_blocktype [blocktype][i]; } minecraft_geom_for_blocktype[next_blocktype] = (unsigned char) STBVOX_MAKE_GEOMETRY(STBVOX_GEOM_ceil_slope_north_is_bottom, 0, 0); minecraft_geom_for_blocktype[ blocktype] = (unsigned char) STBVOX_MAKE_GEOMETRY(STBVOX_GEOM_floor_slope_north_is_top, 0, 0); for (i=0; i < 4; ++i) { map[0+i+8] = map[0+i] = blocktype; map[4+i+8] = map[4+i] = next_blocktype; } --next_blocktype; } void build_wool_variations(int bt, unsigned char *map) { int i,k; unsigned char tex[16] = { 64, 210, 194, 178, 162, 146, 130, 114, 225, 209, 193, 177, 161, 145, 129, 113 }; for (i=0; i < 16; ++i) { if (i == 0) map[i] = bt; else { map[i] = next_blocktype; for (k=0; k < 6; ++k) { minecraft_tex1_for_blocktype[next_blocktype][k] = tex[i]; } minecraft_geom_for_blocktype[next_blocktype] = minecraft_geom_for_blocktype[bt]; --next_blocktype; } } } void build_wood_variations(int bt, unsigned char *map) { int i,k; unsigned char tex[4] = { 5, 198, 214, 199 }; for (i=0; i < 4; ++i) { if (i == 0) map[i] = bt; else { map[i] = next_blocktype; for (k=0; k < 6; ++k) { minecraft_tex1_for_blocktype[next_blocktype][k] = tex[i]; } minecraft_geom_for_blocktype[next_blocktype] = minecraft_geom_for_blocktype[bt]; --next_blocktype; } } map[i] = map[i-1]; ++i; for (; i < 16; ++i) map[i] = bt; } void remap_in_place(int bt, int rm) { int i; remap[bt] = rm; for (i=0; i < 16; ++i) remap_data[rm][i] = bt; } void mesh_init(void) { int i; chunk_cache_mutex = SDL_CreateMutex(); chunk_get_mutex = SDL_CreateMutex(); for (i=0; i < 256; ++i) { memcpy(minecraft_tex1_for_blocktype[i], minecraft_info[i]+1, 6); effective_blocktype[i] = (minecraft_info[i][0] == C_empty ? 0 : i); minecraft_geom_for_blocktype[i] = geom_map[minecraft_info[i][0]]; } //effective_blocktype[50] = 0; // delete torches for (i=0; i < 6*256; ++i) { if (minecraft_tex1_for_blocktype[0][i] == 40) minecraft_color_for_blocktype[0][i] = 38 | 64; // apply to tex1 if (minecraft_tex1_for_blocktype[0][i] == 39) minecraft_color_for_blocktype[0][i] = 39 | 64; // apply to tex1 if (minecraft_tex1_for_blocktype[0][i] == 105) minecraft_color_for_blocktype[0][i] = 63; // emissive if (minecraft_tex1_for_blocktype[0][i] == 212) minecraft_color_for_blocktype[0][i] = 63; // emissive if (minecraft_tex1_for_blocktype[0][i] == 80) minecraft_color_for_blocktype[0][i] = 63; // emissive } for (i=0; i < 6; ++i) { minecraft_color_for_blocktype[172][i] = 47 | 64; // apply to tex1 minecraft_color_for_blocktype[178][i] = 47 | 64; // apply to tex1 minecraft_color_for_blocktype[18][i] = 39 | 64; // green minecraft_color_for_blocktype[161][i] = 37 | 64; // green minecraft_color_for_blocktype[10][i] = 63; // emissive lava minecraft_color_for_blocktype[11][i] = 63; // emissive } #ifdef VHEIGHT_TEST effective_blocktype[168] = 168; minecraft_tex1_for_blocktype[168][0] = 1; minecraft_tex1_for_blocktype[168][1] = 1; minecraft_tex1_for_blocktype[168][2] = 1; minecraft_tex1_for_blocktype[168][3] = 1; minecraft_tex1_for_blocktype[168][4] = 1; minecraft_tex1_for_blocktype[168][5] = 1; minecraft_geom_for_blocktype[168] = STBVOX_GEOM_floor_vheight_12; effective_blocktype[169] = 169; minecraft_tex1_for_blocktype[169][0] = 1; minecraft_tex1_for_blocktype[169][1] = 1; minecraft_tex1_for_blocktype[169][2] = 1; minecraft_tex1_for_blocktype[169][3] = 1; minecraft_tex1_for_blocktype[169][4] = 1; minecraft_tex1_for_blocktype[169][5] = 1; minecraft_geom_for_blocktype[169] = STBVOX_GEOM_ceil_vheight_03; #endif remap[53] = 1; remap[67] = 2; remap[108] = 3; remap[109] = 4; remap[114] = 5; remap[136] = 6; remap[156] = 7; for (i=0; i < 256; ++i) if (remap[i]) build_stair_rotations(i, remap_data[remap[i]]); remap[35] = 8; build_wool_variations(35, remap_data[remap[35]]); remap[5] = 11; build_wood_variations(5, remap_data[remap[5]]); // set the remap flags for these so they write the rotation values remap_in_place(54, 9); remap_in_place(146, 10); } // Timing stats while optimizing the single-threaded builder // 32..-32, 32..-32, SKIP_TERRAIN=0, !FANCY_LEAVES on 'mcrealm' data set // 6.27s - reblocked to do 16 z at a time instead of 256 (still using 66x66x258), 4 meshes in parallel // 5.96s - reblocked to use FAST_CHUNK (no intermediate data structure) // 5.45s - unknown change, or previous measurement was wrong // 6.12s - use preconverted data, not in-place // 5.91s - use preconverted, in-place // 5.34s - preconvert, in-place, avoid dependency chain (suggested by ryg) // 5.34s - preconvert, in-place, avoid dependency chain, use bit-table instead of byte-table // 5.50s - preconvert, in-place, branchless // 6.42s - non-preconvert, avoid dependency chain (not an error) // 5.40s - non-preconvert, w/dependency chain (same as earlier) // 5.50s - non-FAST_CHUNK, reblocked outer loop for better cache reuse // 4.73s - FAST_CHUNK non-preconvert, reblocked outer loop // 4.25s - preconvert, in-place, reblocked outer loop // 4.18s - preconvert, in-place, unrolled again // 4.10s - 34x34 1 mesh instead of 66x66 and 4 meshes (will make it easier to do multiple threads) // 4.83s - building bitmasks but not using them (2 bits per block, one if empty, one if solid) // 5.16s - using empty bitmasks to early out // 5.01s - using solid & empty bitmasks to early out - "foo" // 4.64s - empty bitmask only, test 8 at a time, then test geom // 4.72s - empty bitmask only, 8 at a time, then test bits // 4.46s - split bitmask building into three loops (each byte is separate) // 4.42s - further optimize computing bitmask // 4.58s - using solid & empty bitmasks to early out, same as "foo" but faster bitmask building // 4.12s - using solid & empty bitmasks to efficiently test neighbors // 4.04s - using 16-bit fetches (not endian-independent) // - note this is first place that beats previous best '4.10s - 34x34 1 mesh' // 4.30s - current time with bitmasks disabled again (note was 4.10s earlier) // 3.95s - bitmasks enabled again, no other changes // 4.00s - current time with bitmasks disabled again, no other changes -- wide variation that is time dependent? // (note that most of the numbers listed here are median of 3 values already) // 3.98s - bitmasks enabled // Bitmasks removed from the code as not worth the complexity increase // Raw data for Q&A: // // 26% parsing & loading minecraft files (4/5ths of which is zlib decode) // 39% building mesh from stb input format // 18% converting from minecraft blocks to stb blocks // 9% reordering from minecraft axis order to stb axis order // 7% uploading vertex buffer to OpenGL uTox/third_party/stb/stb/tests/caveview/cave_main.c0000600000175000001440000003706014003056224021455 0ustar rakusers#define _WIN32_WINNT 0x400 #include #include // stb.h #define STB_DEFINE #include "stb.h" // stb_gl.h #define STB_GL_IMPLEMENTATION #define STB_GLEXT_DEFINE "glext_list.h" #include "stb_gl.h" // SDL #include "sdl.h" #include "SDL_opengl.h" // stb_glprog.h #define STB_GLPROG_IMPLEMENTATION #define STB_GLPROG_ARB_DEFINE_EXTENSIONS #include "stb_glprog.h" // stb_image.h #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" // stb_easy_font.h #include "stb_easy_font.h" // doesn't require an IMPLEMENTATION #include "caveview.h" char *game_name = "caveview"; #define REVERSE_DEPTH static void print_string(float x, float y, char *text, float r, float g, float b) { static char buffer[99999]; int num_quads; num_quads = stb_easy_font_print(x, y, text, NULL, buffer, sizeof(buffer)); glColor3f(r,g,b); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 16, buffer); glDrawArrays(GL_QUADS, 0, num_quads*4); glDisableClientState(GL_VERTEX_ARRAY); } static float text_color[3]; static float pos_x = 10; static float pos_y = 10; static void print(char *text, ...) { char buffer[999]; va_list va; va_start(va, text); vsprintf(buffer, text, va); va_end(va); print_string(pos_x, pos_y, buffer, text_color[0], text_color[1], text_color[2]); pos_y += 10; } float camang[3], camloc[3] = { 60,22,77 }; float player_zoom = 1.0; float rotate_view = 0.0; void camera_to_worldspace(float world[3], float cam_x, float cam_y, float cam_z) { float vec[3] = { cam_x, cam_y, cam_z }; float t[3]; float s,c; s = (float) sin(camang[0]*3.141592/180); c = (float) cos(camang[0]*3.141592/180); t[0] = vec[0]; t[1] = c*vec[1] - s*vec[2]; t[2] = s*vec[1] + c*vec[2]; s = (float) sin(camang[2]*3.141592/180); c = (float) cos(camang[2]*3.141592/180); world[0] = c*t[0] - s*t[1]; world[1] = s*t[0] + c*t[1]; world[2] = t[2]; } // camera worldspace velocity float cam_vel[3]; int controls; #define MAX_VEL 150.0f // blocks per second #define ACCEL 6.0f #define DECEL 3.0f #define STATIC_FRICTION DECEL #define EFFECTIVE_ACCEL (ACCEL+DECEL) // dynamic friction: // // if going at MAX_VEL, ACCEL and friction must cancel // EFFECTIVE_ACCEL = DECEL + DYNAMIC_FRIC*MAX_VEL #define DYNAMIC_FRICTION (ACCEL/(float)MAX_VEL) float view_x_vel = 0; float view_z_vel = 0; float pending_view_x; float pending_view_z; float pending_view_x; float pending_view_z; void process_tick_raw(float dt) { int i; float thrust[3] = { 0,0,0 }; float world_thrust[3]; // choose direction to apply thrust thrust[0] = (controls & 3)== 1 ? EFFECTIVE_ACCEL : (controls & 3)== 2 ? -EFFECTIVE_ACCEL : 0; thrust[1] = (controls & 12)== 4 ? EFFECTIVE_ACCEL : (controls & 12)== 8 ? -EFFECTIVE_ACCEL : 0; thrust[2] = (controls & 48)==16 ? EFFECTIVE_ACCEL : (controls & 48)==32 ? -EFFECTIVE_ACCEL : 0; // @TODO clamp thrust[0] & thrust[1] vector length to EFFECTIVE_ACCEL camera_to_worldspace(world_thrust, thrust[0], thrust[1], 0); world_thrust[2] += thrust[2]; for (i=0; i < 3; ++i) { float acc = world_thrust[i]; cam_vel[i] += acc*dt; } if (cam_vel[0] || cam_vel[1] || cam_vel[2]) { float vel = (float) sqrt(cam_vel[0]*cam_vel[0] + cam_vel[1]*cam_vel[1] + cam_vel[2]*cam_vel[2]); float newvel = vel; float dec = STATIC_FRICTION + DYNAMIC_FRICTION*vel; newvel = vel - dec*dt; if (newvel < 0) newvel = 0; cam_vel[0] *= newvel/vel; cam_vel[1] *= newvel/vel; cam_vel[2] *= newvel/vel; } camloc[0] += cam_vel[0] * dt; camloc[1] += cam_vel[1] * dt; camloc[2] += cam_vel[2] * dt; view_x_vel *= (float) pow(0.75, dt); view_z_vel *= (float) pow(0.75, dt); view_x_vel += (pending_view_x - view_x_vel)*dt*60; view_z_vel += (pending_view_z - view_z_vel)*dt*60; pending_view_x -= view_x_vel * dt; pending_view_z -= view_z_vel * dt; camang[0] += view_x_vel * dt; camang[2] += view_z_vel * dt; camang[0] = stb_clamp(camang[0], -90, 90); camang[2] = (float) fmod(camang[2], 360); } void process_tick(float dt) { while (dt > 1.0f/60) { process_tick_raw(1.0f/60); dt -= 1.0f/60; } process_tick_raw(dt); } void update_view(float dx, float dy) { // hard-coded mouse sensitivity, not resolution independent? pending_view_z -= dx*300; pending_view_x -= dy*700; } extern int screen_x, screen_y; extern int is_synchronous_debug; float render_time; extern int chunk_locations, chunks_considered, chunks_in_frustum; extern int quads_considered, quads_rendered; extern int chunk_storage_rendered, chunk_storage_considered, chunk_storage_total; extern int view_dist_in_chunks; extern int num_threads_active, num_meshes_started, num_meshes_uploaded; extern float chunk_server_activity; static Uint64 start_time, end_time; // render time float chunk_server_status[32]; int chunk_server_pos; void draw_stats(void) { int i; static Uint64 last_frame_time; Uint64 cur_time = SDL_GetPerformanceCounter(); float chunk_server=0; float frame_time = (cur_time - last_frame_time) / (float) SDL_GetPerformanceFrequency(); last_frame_time = cur_time; chunk_server_status[chunk_server_pos] = chunk_server_activity; chunk_server_pos = (chunk_server_pos+1) %32; for (i=0; i < 32; ++i) chunk_server += chunk_server_status[i] / 32.0f; stb_easy_font_spacing(-0.75); pos_y = 10; text_color[0] = text_color[1] = text_color[2] = 1.0f; print("Frame time: %6.2fms, CPU frame render time: %5.2fms", frame_time*1000, render_time*1000); print("Tris: %4.1fM drawn of %4.1fM in range", 2*quads_rendered/1000000.0f, 2*quads_considered/1000000.0f); print("Vbuf storage: %dMB in frustum of %dMB in range of %dMB in cache", chunk_storage_rendered>>20, chunk_storage_considered>>20, chunk_storage_total>>20); print("Num mesh builds started this frame: %d; num uploaded this frame: %d\n", num_meshes_started, num_meshes_uploaded); print("QChunks: %3d in frustum of %3d valid of %3d in range", chunks_in_frustum, chunks_considered, chunk_locations); print("Mesh worker threads active: %d", num_threads_active); print("View distance: %d blocks", view_dist_in_chunks*16); print("%s", glGetString(GL_RENDERER)); if (is_synchronous_debug) { text_color[0] = 1.0; text_color[1] = 0.5; text_color[2] = 0.5; print("SLOWNESS: Synchronous debug output is enabled!"); } } void draw_main(void) { glEnable(GL_CULL_FACE); glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); #ifdef REVERSE_DEPTH glDepthFunc(GL_GREATER); glClearDepth(0); #else glDepthFunc(GL_LESS); glClearDepth(1); #endif glDepthMask(GL_TRUE); glDisable(GL_SCISSOR_TEST); glClearColor(0.6f,0.7f,0.9f,0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor3f(1,1,1); glFrontFace(GL_CW); glEnable(GL_TEXTURE_2D); glDisable(GL_BLEND); glMatrixMode(GL_PROJECTION); glLoadIdentity(); #ifdef REVERSE_DEPTH stbgl_Perspective(player_zoom, 90, 70, 3000, 1.0/16); #else stbgl_Perspective(player_zoom, 90, 70, 1.0/16, 3000); #endif // now compute where the camera should be glMatrixMode(GL_MODELVIEW); glLoadIdentity(); stbgl_initCamera_zup_facing_y(); glRotatef(-camang[0],1,0,0); glRotatef(-camang[2],0,0,1); glTranslatef(-camloc[0], -camloc[1], -camloc[2]); start_time = SDL_GetPerformanceCounter(); render_caves(camloc); end_time = SDL_GetPerformanceCounter(); render_time = (end_time - start_time) / (float) SDL_GetPerformanceFrequency(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0,screen_x/2,screen_y/2,0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); glDisable(GL_CULL_FACE); draw_stats(); } #pragma warning(disable:4244; disable:4305; disable:4018) #define SCALE 2 void error(char *s) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", s, NULL); exit(0); } void ods(char *fmt, ...) { char buffer[1000]; va_list va; va_start(va, fmt); vsprintf(buffer, fmt, va); va_end(va); SDL_Log("%s", buffer); } #define TICKS_PER_SECOND 60 static SDL_Window *window; extern void draw_main(void); extern void process_tick(float dt); extern void editor_init(void); void draw(void) { draw_main(); SDL_GL_SwapWindow(window); } static int initialized=0; static float last_dt; int screen_x,screen_y; float carried_dt = 0; #define TICKRATE 60 float tex2_alpha = 1.0; int raw_level_time; float global_timer; int global_hack; int loopmode(float dt, int real, int in_client) { if (!initialized) return 0; if (!real) return 0; // don't allow more than 6 frames to update at a time if (dt > 0.075) dt = 0.075; global_timer += dt; carried_dt += dt; while (carried_dt > 1.0/TICKRATE) { if (global_hack) { tex2_alpha += global_hack / 60.0f; if (tex2_alpha < 0) tex2_alpha = 0; if (tex2_alpha > 1) tex2_alpha = 1; } //update_input(); // if the player is dead, stop the sim carried_dt -= 1.0/TICKRATE; } process_tick(dt); draw(); return 0; } static int quit; extern int controls; void active_control_set(int key) { controls |= 1 << key; } void active_control_clear(int key) { controls &= ~(1 << key); } extern void update_view(float dx, float dy); void process_sdl_mouse(SDL_Event *e) { update_view((float) e->motion.xrel / screen_x, (float) e->motion.yrel / screen_y); } void process_event(SDL_Event *e) { switch (e->type) { case SDL_MOUSEMOTION: process_sdl_mouse(e); break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: break; case SDL_QUIT: quit = 1; break; case SDL_WINDOWEVENT: switch (e->window.event) { case SDL_WINDOWEVENT_SIZE_CHANGED: screen_x = e->window.data1; screen_y = e->window.data2; loopmode(0,1,0); break; } break; case SDL_KEYDOWN: { int k = e->key.keysym.sym; int s = e->key.keysym.scancode; SDL_Keymod mod; mod = SDL_GetModState(); if (k == SDLK_ESCAPE) quit = 1; if (s == SDL_SCANCODE_D) active_control_set(0); if (s == SDL_SCANCODE_A) active_control_set(1); if (s == SDL_SCANCODE_W) active_control_set(2); if (s == SDL_SCANCODE_S) active_control_set(3); if (k == SDLK_SPACE) active_control_set(4); if (s == SDL_SCANCODE_LCTRL) active_control_set(5); if (s == SDL_SCANCODE_S) active_control_set(6); if (s == SDL_SCANCODE_D) active_control_set(7); if (k == '1') global_hack = !global_hack; if (k == '2') global_hack = -1; #if 0 if (game_mode == GAME_editor) { switch (k) { case SDLK_RIGHT: editor_key(STBTE_scroll_right); break; case SDLK_LEFT : editor_key(STBTE_scroll_left ); break; case SDLK_UP : editor_key(STBTE_scroll_up ); break; case SDLK_DOWN : editor_key(STBTE_scroll_down ); break; } switch (s) { case SDL_SCANCODE_S: editor_key(STBTE_tool_select); break; case SDL_SCANCODE_B: editor_key(STBTE_tool_brush ); break; case SDL_SCANCODE_E: editor_key(STBTE_tool_erase ); break; case SDL_SCANCODE_R: editor_key(STBTE_tool_rectangle ); break; case SDL_SCANCODE_I: editor_key(STBTE_tool_eyedropper); break; case SDL_SCANCODE_L: editor_key(STBTE_tool_link); break; case SDL_SCANCODE_G: editor_key(STBTE_act_toggle_grid); break; } if ((e->key.keysym.mod & KMOD_CTRL) && !(e->key.keysym.mod & ~KMOD_CTRL)) { switch (s) { case SDL_SCANCODE_X: editor_key(STBTE_act_cut ); break; case SDL_SCANCODE_C: editor_key(STBTE_act_copy ); break; case SDL_SCANCODE_V: editor_key(STBTE_act_paste); break; case SDL_SCANCODE_Z: editor_key(STBTE_act_undo ); break; case SDL_SCANCODE_Y: editor_key(STBTE_act_redo ); break; } } } #endif break; } case SDL_KEYUP: { int k = e->key.keysym.sym; int s = e->key.keysym.scancode; if (s == SDL_SCANCODE_D) active_control_clear(0); if (s == SDL_SCANCODE_A) active_control_clear(1); if (s == SDL_SCANCODE_W) active_control_clear(2); if (s == SDL_SCANCODE_S) active_control_clear(3); if (k == SDLK_SPACE) active_control_clear(4); if (s == SDL_SCANCODE_LCTRL) active_control_clear(5); if (s == SDL_SCANCODE_S) active_control_clear(6); if (s == SDL_SCANCODE_D) active_control_clear(7); break; } } } static SDL_GLContext *context; static float getTimestep(float minimum_time) { float elapsedTime; double thisTime; static double lastTime = -1; if (lastTime == -1) lastTime = SDL_GetTicks() / 1000.0 - minimum_time; for(;;) { thisTime = SDL_GetTicks() / 1000.0; elapsedTime = (float) (thisTime - lastTime); if (elapsedTime >= minimum_time) { lastTime = thisTime; return elapsedTime; } // @TODO: compute correct delay SDL_Delay(1); } } void APIENTRY gl_debug(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *param) { ods("%s\n", message); } int is_synchronous_debug; void enable_synchronous(void) { glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); is_synchronous_debug = 1; } void prepare_threads(void); //void stbwingraph_main(void) int SDL_main(int argc, char **argv) { SDL_Init(SDL_INIT_VIDEO); prepare_threads(); SDL_GL_SetAttribute(SDL_GL_RED_SIZE , 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE , 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); #ifdef GL_DEBUG SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); #endif SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); screen_x = 1920; screen_y = 1080; window = SDL_CreateWindow("caveview", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen_x, screen_y, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE ); if (!window) error("Couldn't create window"); context = SDL_GL_CreateContext(window); if (!context) error("Couldn't create context"); SDL_GL_MakeCurrent(window, context); // is this true by default? SDL_SetRelativeMouseMode(SDL_TRUE); #if defined(_MSC_VER) && _MSC_VER < 1300 // work around broken behavior in VC6 debugging if (IsDebuggerPresent()) SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1"); #endif stbgl_initExtensions(); #ifdef GL_DEBUG if (glDebugMessageCallbackARB) { glDebugMessageCallbackARB(gl_debug, NULL); enable_synchronous(); } #endif SDL_GL_SetSwapInterval(1); render_init(); mesh_init(); world_init(); initialized = 1; while (!quit) { SDL_Event e; while (SDL_PollEvent(&e)) process_event(&e); loopmode(getTimestep(0.0166f/8), 1, 1); } return 0; } uTox/third_party/stb/stb/tests/caveview/README.md0000600000175000001440000000657014003056224020650 0ustar rakusers# FAQ ### How to run it? There's no GUI. Find a directory with Minecraft Anvil files (.mca). Copy a Minecraft "terrain.png" into that directory (do a google image search). Run from that directory. ### How accurate is this as a Minecraft viewer? Not very. Many Minecraft blocks are not handled correctly: * No redstone, rails, or other "flat" blocks * No signs, doors, fences, carpets, or other complicated geometry * Stairs are turned into ramps * Upper slabs turn into lower slabs * Wood types only for blocks, not stairs, slabs, etc * Colored glass becomes regular glass * Glass panes become glass blocks * Water is opaque * Water level is incorrect * No biome coloration * Cactus is not shrunk, shows holes * Chests are not shrunk * Double-chests draw as two chests * Pumpkins etc. are not rotated properly * Torches are drawn hackily, do not attach to walls * Incorrect textures for blocks that postdate terrain.png * Transparent textures have black fringes due to non-premultiplied-alpha * Skylight and block light are combined in a single value * Only blocks at y=1..255 are shown (not y=0) * If a 32x32x256 "quad-chunk" needs more than 800K quads, isn't handled (very unlikely) Some of these are due to engine limitations, and some of these are because I didn't make the effort since my goal was to make a demo for stb_voxel_render.h, not to make a proper Minecraft viewer. ### Could this be turned into a proper Minecraft viewer? Yes and no. Yes, you could do it, but no, it wouldn't really resemble this code that much anymore. You could certainly use this engine to render the parts of Minecraft it works for, but many of the things it doesn't handle it can't handle at all (stairs, water, fences, carpets, etc) because it uses low-precision coordinates to store voxel data. You would have to render all of the stuff it doesn't handle through another rendering path. In a game (not a viewer) you would need such a path for movable entities like doors and carts anyway, so possibly handling other things that way wouldn't be so bad. Rails, ladders, and redstone lines could be implemented by using tex2 to overlay those effects, but you can't rotate tex1 and tex2 independently, so there may be cases where the underlying texture needs a different rotation from the overlaid texture, which would require separate rendering. Handling redstone's brightness being different from underlying block's brightness would require separate rendering. You can use the face-color effect to do biome coloration, but the change won't be smooth the way it is in Minecraft. ### Why isn't building the mesh data faster? Partly because converting from minecraft data is expensive. Here is the approximate breakdown of an older version of this executable and lib that did the building single-threaded. * 25% loading & parsing minecraft files (4/5ths of this is my crappy zlib) * 18% converting from minecraft blockids & lighting to stb blockids & lighting * 10% reordering from data[z][y]\[x] (minecraft-style) to data[y][x]\[z] (stb-style) * 40% building mesh data * 7% uploading mesh data to OpenGL I did do significant optimizations after the above, so the final breakdown is different, but it should give you some sense of the costs. uTox/third_party/stb/stb/tests/c_lexer_test.dsp0000600000175000001440000000760714003056224020752 0ustar rakusers# Microsoft Developer Studio Project File - Name="c_lexer_test" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=c_lexer_test - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "c_lexer_test.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "c_lexer_test.mak" CFG="c_lexer_test - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "c_lexer_test - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "c_lexer_test - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "c_lexer_test - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "c_lexer_test - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug\c_lexer_test" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "c_lexer_test - Win32 Release" # Name "c_lexer_test - Win32 Debug" # Begin Source File SOURCE=.\c_lexer_test.c # End Source File # End Target # End Project uTox/third_party/stb/stb/tests/c_lexer_test.c0000600000175000001440000000717614003056224020407 0ustar rakusers#define STB_C_LEX_C_DECIMAL_INTS Y // "0|[1-9][0-9]*" CLEX_intlit #define STB_C_LEX_C_HEX_INTS Y // "0x[0-9a-fA-F]+" CLEX_intlit #define STB_C_LEX_C_OCTAL_INTS Y // "[0-7]+" CLEX_intlit #define STB_C_LEX_C_DECIMAL_FLOATS Y // "[0-9]*(.[0-9]*([eE][-+]?[0-9]+)?) CLEX_floatlit #define STB_C_LEX_C99_HEX_FLOATS Y // "0x{hex}+(.{hex}*)?[pP][-+]?{hex}+ CLEX_floatlit #define STB_C_LEX_C_IDENTIFIERS Y // "[_a-zA-Z][_a-zA-Z0-9]*" CLEX_id #define STB_C_LEX_C_DQ_STRINGS Y // double-quote-delimited strings with escapes CLEX_dqstring #define STB_C_LEX_C_SQ_STRINGS Y // single-quote-delimited strings with escapes CLEX_ssstring #define STB_C_LEX_C_CHARS Y // single-quote-delimited character with escape CLEX_charlits #define STB_C_LEX_C_COMMENTS Y // "/* comment */" #define STB_C_LEX_CPP_COMMENTS Y // "// comment to end of line\n" #define STB_C_LEX_C_COMPARISONS Y // "==" CLEX_eq "!=" CLEX_noteq "<=" CLEX_lesseq ">=" CLEX_greatereq #define STB_C_LEX_C_LOGICAL Y // "&&" CLEX_andand "||" CLEX_oror #define STB_C_LEX_C_SHIFTS Y // "<<" CLEX_shl ">>" CLEX_shr #define STB_C_LEX_C_INCREMENTS Y // "++" CLEX_plusplus "--" CLEX_minusminus #define STB_C_LEX_C_ARROW Y // "->" CLEX_arrow #define STB_C_LEX_EQUAL_ARROW Y // "=>" CLEX_eqarrow #define STB_C_LEX_C_BITWISEEQ Y // "&=" CLEX_andeq "|=" CLEX_oreq "^=" CLEX_xoreq #define STB_C_LEX_C_ARITHEQ Y // "+=" CLEX_pluseq "-=" CLEX_minuseq // "*=" CLEX_muleq "/=" CLEX_diveq "%=" CLEX_modeq // if both STB_C_LEX_SHIFTS & STB_C_LEX_ARITHEQ: // "<<=" CLEX_shleq ">>=" CLEX_shreq #define STB_C_LEX_PARSE_SUFFIXES Y // letters after numbers are parsed as part of those numbers, and must be in suffix list below #define STB_C_LEX_DECIMAL_SUFFIXES "uUlL" // decimal integer suffixes e.g. "uUlL" -- these are returned as-is in string storage #define STB_C_LEX_HEX_SUFFIXES "lL" // e.g. "uUlL" #define STB_C_LEX_OCTAL_SUFFIXES "lL" // e.g. "uUlL" #define STB_C_LEX_FLOAT_SUFFIXES "uulL" // #define STB_C_LEX_0_IS_EOF N // if Y, ends parsing at '\0'; if N, returns '\0' as token #define STB_C_LEX_INTEGERS_AS_DOUBLES N // parses integers as doubles so they can be larger than 'int', but only if STB_C_LEX_STDLIB==N #define STB_C_LEX_MULTILINE_DSTRINGS Y // allow newlines in double-quoted strings #define STB_C_LEX_MULTILINE_SSTRINGS Y // allow newlines in single-quoted strings #define STB_C_LEX_USE_STDLIB N // use strtod,strtol for parsing #s; otherwise inaccurate hack #define STB_C_LEX_DOLLAR_IDENTIFIER Y // allow $ as an identifier character #define STB_C_LEX_FLOAT_NO_DECIMAL Y // allow floats that have no decimal point if they have an exponent #define STB_C_LEX_DEFINE_ALL_TOKEN_NAMES Y // if Y, all CLEX_ token names are defined, even if never returned // leaving it as N should help you catch config bugs #define STB_C_LEX_DISCARD_PREPROCESSOR Y // discard C-preprocessor directives (e.g. after prepocess // still have #line, #pragma, etc) #define STB_C_LEXER_DEFINITIONS // This line prevents the header file from replacing your definitions #define STB_C_LEXER_IMPLEMENTATION #define STB_C_LEXER_SELF_TEST #include "../stb_c_lexer.h" uTox/third_party/stb/stb/tests/Makefile0000600000175000001440000000043114003056224017206 0ustar rakusersINCLUDES = -I.. CFLAGS = -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -DSTB_DIVIDE_TEST CPPFLAGS = -Wno-write-strings -DSTB_DIVIDE_TEST all: $(CC) $(INCLUDES) $(CFLAGS) ../stb_vorbis.c test_c_compilation.c -lm $(CC) $(INCLUDES) $(CPPFLAGS) test_cpp_compilation.cpp -lm uTox/third_party/stb/stb/stretchy_buffer.h0000600000175000001440000002621514003056224017763 0ustar rakusers// stretchy_buffer.h - v1.02 - public domain - nothings.org/stb // a vector<>-like dynamic array for C // // version history: // 1.02 - tweaks to syntax for no good reason // 1.01 - added a "common uses" documentation section // 1.0 - fixed bug in the version I posted prematurely // 0.9 - rewrite to try to avoid strict-aliasing optimization // issues, but won't compile as C++ // // Will probably not work correctly with strict-aliasing optimizations. // // The idea: // // This implements an approximation to C++ vector<> for C, in that it // provides a generic definition for dynamic arrays which you can // still access in a typesafe way using arr[i] or *(arr+i). However, // it is simply a convenience wrapper around the common idiom of // of keeping a set of variables (in a struct or globals) which store // - pointer to array // - the length of the "in-use" part of the array // - the current size of the allocated array // // I find it to be the single most useful non-built-in-structure when // programming in C (hash tables a close second), but to be clear // it lacks many of the capabilities of C++ vector<>: there is no // range checking, the object address isn't stable (see next section // for details), the set of methods available is small (although // the file stb.h has another implementation of stretchy buffers // called 'stb_arr' which provides more methods, e.g. for insertion // and deletion). // // How to use: // // Unlike other stb header file libraries, there is no need to // define an _IMPLEMENTATION symbol. Every #include creates as // much implementation is needed. // // stretchy_buffer.h does not define any types, so you do not // need to #include it to before defining data types that are // stretchy buffers, only in files that *manipulate* stretchy // buffers. // // If you want a stretchy buffer aka dynamic array containing // objects of TYPE, declare such an array as: // // TYPE *myarray = NULL; // // (There is no typesafe way to distinguish between stretchy // buffers and regular arrays/pointers; this is necessary to // make ordinary array indexing work on these objects.) // // Unlike C++ vector<>, the stretchy_buffer has the same // semantics as an object that you manually malloc and realloc. // The pointer may relocate every time you add a new object // to it, so you: // // 1. can't take long-term pointers to elements of the array // 2. have to return the pointer from functions which might expand it // (either as a return value or by storing it to a ptr-to-ptr) // // Now you can do the following things with this array: // // sb_free(TYPE *a) free the array // sb_count(TYPE *a) the number of elements in the array // sb_push(TYPE *a, TYPE v) adds v on the end of the array, a la push_back // sb_add(TYPE *a, int n) adds n uninitialized elements at end of array & returns pointer to first added // sb_last(TYPE *a) returns an lvalue of the last item in the array // a[n] access the nth (counting from 0) element of the array // // #define STRETCHY_BUFFER_NO_SHORT_NAMES to only export // names of the form 'stb_sb_' if you have a name that would // otherwise collide. // // Note that these are all macros and many of them evaluate // their arguments more than once, so the arguments should // be side-effect-free. // // Note that 'TYPE *a' in sb_push and sb_add must be lvalues // so that the library can overwrite the existing pointer if // the object has to be reallocated. // // In an out-of-memory condition, the code will try to // set up a null-pointer or otherwise-invalid-pointer // exception to happen later. It's possible optimizing // compilers could detect this write-to-null statically // and optimize away some of the code, but it should only // be along the failure path. Nevertheless, for more security // in the face of such compilers, #define STRETCHY_BUFFER_OUT_OF_MEMORY // to a statement such as assert(0) or exit(1) or something // to force a failure when out-of-memory occurs. // // Common use: // // The main application for this is when building a list of // things with an unknown quantity, either due to loading from // a file or through a process which produces an unpredictable // number. // // My most common idiom is something like: // // SomeStruct *arr = NULL; // while (something) // { // SomeStruct new_one; // new_one.whatever = whatever; // new_one.whatup = whatup; // new_one.foobar = barfoo; // sb_push(arr, new_one); // } // // and various closely-related factorings of that. For example, // you might have several functions to create/init new SomeStructs, // and if you use the above idiom, you might prefer to make them // return structs rather than take non-const-pointers-to-structs, // so you can do things like: // // SomeStruct *arr = NULL; // while (something) // { // if (case_A) { // sb_push(arr, some_func1()); // } else if (case_B) { // sb_push(arr, some_func2()); // } else { // sb_push(arr, some_func3()); // } // } // // Note that the above relies on the fact that sb_push doesn't // evaluate its second argument more than once. The macros do // evaluate the *array* argument multiple times, and numeric // arguments may be evaluated multiple times, but you can rely // on the second argument of sb_push being evaluated only once. // // Of course, you don't have to store bare objects in the array; // if you need the objects to have stable pointers, store an array // of pointers instead: // // SomeStruct **arr = NULL; // while (something) // { // SomeStruct *new_one = malloc(sizeof(*new_one)); // new_one->whatever = whatever; // new_one->whatup = whatup; // new_one->foobar = barfoo; // sb_push(arr, new_one); // } // // How it works: // // A long-standing tradition in things like malloc implementations // is to store extra data before the beginning of the block returned // to the user. The stretchy buffer implementation here uses the // same trick; the current-count and current-allocation-size are // stored before the beginning of the array returned to the user. // (This means you can't directly free() the pointer, because the // allocated pointer is different from the type-safe pointer provided // to the user.) // // The details are trivial and implementation is straightforward; // the main trick is in realizing in the first place that it's // possible to do this in a generic, type-safe way in C. // // LICENSE // // See end of file for license information. #ifndef STB_STRETCHY_BUFFER_H_INCLUDED #define STB_STRETCHY_BUFFER_H_INCLUDED #ifndef NO_STRETCHY_BUFFER_SHORT_NAMES #define sb_free stb_sb_free #define sb_push stb_sb_push #define sb_count stb_sb_count #define sb_add stb_sb_add #define sb_last stb_sb_last #endif #define stb_sb_free(a) ((a) ? free(stb__sbraw(a)),0 : 0) #define stb_sb_push(a,v) (stb__sbmaybegrow(a,1), (a)[stb__sbn(a)++] = (v)) #define stb_sb_count(a) ((a) ? stb__sbn(a) : 0) #define stb_sb_add(a,n) (stb__sbmaybegrow(a,n), stb__sbn(a)+=(n), &(a)[stb__sbn(a)-(n)]) #define stb_sb_last(a) ((a)[stb__sbn(a)-1]) #define stb__sbraw(a) ((int *) (a) - 2) #define stb__sbm(a) stb__sbraw(a)[0] #define stb__sbn(a) stb__sbraw(a)[1] #define stb__sbneedgrow(a,n) ((a)==0 || stb__sbn(a)+(n) >= stb__sbm(a)) #define stb__sbmaybegrow(a,n) (stb__sbneedgrow(a,(n)) ? stb__sbgrow(a,n) : 0) #define stb__sbgrow(a,n) ((a) = stb__sbgrowf((a), (n), sizeof(*(a)))) #include static void * stb__sbgrowf(void *arr, int increment, int itemsize) { int dbl_cur = arr ? 2*stb__sbm(arr) : 0; int min_needed = stb_sb_count(arr) + increment; int m = dbl_cur > min_needed ? dbl_cur : min_needed; int *p = (int *) realloc(arr ? stb__sbraw(arr) : 0, itemsize * m + sizeof(int)*2); if (p) { if (!arr) p[1] = 0; p[0] = m; return p+2; } else { #ifdef STRETCHY_BUFFER_OUT_OF_MEMORY STRETCHY_BUFFER_OUT_OF_MEMORY ; #endif return (void *) (2*sizeof(int)); // try to force a NULL pointer exception later } } #endif // STB_STRETCHY_BUFFER_H_INCLUDED /* ------------------------------------------------------------------------------ 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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_voxel_render.h0000600000175000001440000047253714003056224020145 0ustar rakusers// stb_voxel_render.h - v0.85 - Sean Barrett, 2015 - public domain // // This library helps render large-scale "voxel" worlds for games, // in this case, one with blocks that can have textures and that // can also be a few shapes other than cubes. // // Video introduction: // http://www.youtube.com/watch?v=2vnTtiLrV1w // // Minecraft-viewer sample app (not very simple though): // http://github.com/nothings/stb/tree/master/tests/caveview // // It works by creating triangle meshes. The library includes // // - converter from dense 3D arrays of block info to vertex mesh // - vertex & fragment shaders for the vertex mesh // - assistance in setting up shader state // // For portability, none of the library code actually accesses // the 3D graphics API. (At the moment, it's not actually portable // since the shaders are GLSL only, but patches are welcome.) // // You have to do all the caching and tracking of vertex buffers // yourself. However, you could also try making a game with // a small enough world that it's fully loaded rather than // streaming. Currently the preferred vertex format is 20 bytes // per quad. There are designs to allow much more compact formats // with a slight reduction in shader features, but no roadmap // for actually implementing them. // // // USAGE // // #define the symbol STB_VOXEL_RENDER_IMPLEMENTATION in *one* // C/C++ file before the #include of this file; the implementation // will be generated in that file. // // If you define the symbols STB_VOXEL_RENDER_STATIC, then the // implementation will be private to that file. // // // FEATURES // // - you can choose textured blocks with the features below, // or colored voxels with 2^24 colors and no textures. // // - voxels are mostly just cubes, but there's support for // half-height cubes and diagonal slopes, half-height // diagonals, and even odder shapes especially for doing // more-continuous "ground". // // - texture coordinates are projections along one of the major // axes, with the per-texture scaling. // // - a number of aspects of the shader and the vertex format // are configurable; the library generally takes care of // coordinating the vertex format with the mesh for you. // // // FEATURES (SHADER PERSPECTIVE) // // - vertices aligned on integer lattice, z on multiples of 0.5 // - per-vertex "lighting" or "ambient occlusion" value (6 bits) // - per-vertex texture crossfade (3 bits) // // - per-face texture #1 id (8-bit index into array texture) // - per-face texture #2 id (8-bit index into second array texture) // - per-face color (6-bit palette index, 2 bits of per-texture boolean enable) // - per-face 5-bit normal for lighting calculations & texture coord computation // - per-face 2-bit texture matrix rotation to rotate faces // // - indexed-by-texture-id scale factor (separate for texture #1 and texture #2) // - indexed-by-texture-#2-id blend mode (alpha composite or modulate/multiply); // the first is good for decals, the second for detail textures, "light maps", // etc; both modes are controlled by texture #2's alpha, scaled by the // per-vertex texture crossfade and the per-face color (if enabled on texture #2); // modulate/multiply multiplies by an extra factor of 2.0 so that if you // make detail maps whose average brightness is 0.5 everything works nicely. // // - ambient lighting: half-lambert directional plus constant, all scaled by vertex ao // - face can be fullbright (emissive), controlled by per-face color // - installable lighting, with default single-point-light // - installable fog, with default hacked smoothstep // // Note that all the variations of lighting selection and texture // blending are run-time conditions in the shader, so they can be // intermixed in a single mesh. // // // INTEGRATION ARC // // The way to get this library to work from scratch is to do the following: // // Step 1. define STBVOX_CONFIG_MODE to 0 // // This mode uses only vertex attributes and uniforms, and is easiest // to get working. It requires 32 bytes per quad and limits the // size of some tables to avoid hitting uniform limits. // // Step 2. define STBVOX_CONFIG_MODE to 1 // // This requires using a texture buffer to store the quad data, // reducing the size to 20 bytes per quad. // // Step 3: define STBVOX_CONFIG_PREFER_TEXBUFFER // // This causes some uniforms to be stored as texture buffers // instead. This increases the size of some of those tables, // and avoids a potential slow path (gathering non-uniform // data from uniforms) on some hardware. // // In the future I might add additional modes that have significantly // smaller meshes but reduce features, down as small as 6 bytes per quad. // See elsewhere in this file for a table of candidate modes. Switching // to a mode will require changing some of your mesh creation code, but // everything else should be seamless. (And I'd like to change the API // so that mesh creation is data-driven the way the uniforms are, and // then you wouldn't even have to change anything but the mode number.) // // // IMPROVEMENTS FOR SHIP-WORTHY PROGRAMS USING THIS LIBRARY // // I currently tolerate a certain level of "bugginess" in this library. // // I'm referring to things which look a little wrong (as long as they // don't cause holes or cracks in the output meshes), or things which // do not produce as optimal a mesh as possible. Notable examples: // // - incorrect lighting on slopes // - inefficient meshes for vheight blocks // // I am willing to do the work to improve these things if someone is // going to ship a substantial program that would be improved by them. // (It need not be commercial, nor need it be a game.) I just didn't // want to do the work up front if it might never be leveraged. So just // submit a bug report as usual (github is preferred), but add a note // that this is for a thing that is really going to ship. (That means // you need to be far enough into the project that it's clear you're // committed to it; not during early exploratory development.) // // // VOXEL MESH API // // Context // // To understand the API, make sure you first understand the feature set // listed above. // // Because the vertices are compact, they have very limited spatial // precision. Thus a single mesh can only contain the data for a limited // area. To make very large voxel maps, you'll need to build multiple // vertex buffers. (But you want this anyway for frustum culling.) // // Each generated mesh has three components: // - vertex data (vertex buffer) // - face data (optional, stored in texture buffer) // - mesh transform (uniforms) // // Once you've generated the mesh with this library, it's up to you // to upload it to the GPU, to keep track of the state, and to render // it. // // Concept // // The basic design is that you pass in one or more 3D arrays; each array // is (typically) one-byte-per-voxel and contains information about one // or more properties of some particular voxel property. // // Because there is so much per-vertex and per-face data possible // in the output, and each voxel can have 6 faces and 8 vertices, it // would require an very large data structure to describe all // of the possibilities, and this would cause the mesh-creation // process to be slow. Instead, the API provides multiple ways // to express each property, some more compact, others less so; // each such way has some limitations on what it can express. // // Note that there are so many paths and combinations, not all of them // have been tested. Just report bugs and I'll fix 'em. // // Details // // See the API documentation in the header-file section. // // // CONTRIBUTORS // // Features Porting Bugfixes & Warnings // Sean Barrett github:r-leyh Jesus Fernandez // Miguel Lechon github:Arbeiterunfallversicherungsgesetz // Thomas Frase James Hofmann // Stephen Olsen github:guitarfreak // // VERSION HISTORY // // 0.85 (2017-03-03) add block_selector (by guitarfreak) // 0.84 (2016-04-02) fix GLSL syntax error on glModelView path // 0.83 (2015-09-13) remove non-constant struct initializers to support more compilers // 0.82 (2015-08-01) added input.packed_compact to store rot, vheight & texlerp efficiently // fix broken tex_overlay2 // 0.81 (2015-05-28) fix broken STBVOX_CONFIG_OPTIMIZED_VHEIGHT // 0.80 (2015-04-11) fix broken STBVOX_CONFIG_ROTATION_IN_LIGHTING refactoring // change STBVOX_MAKE_LIGHTING to STBVOX_MAKE_LIGHTING_EXT so // that header defs don't need to see config vars // add STBVOX_CONFIG_VHEIGHT_IN_LIGHTING and other vheight fixes // added documentation for vheight ("weird slopes") // 0.79 (2015-04-01) fix the missing types from 0.78; fix string constants being const // 0.78 (2015-04-02) bad "#else", compile as C++ // 0.77 (2015-04-01) documentation tweaks, rename config var to STB_VOXEL_RENDER_STATIC // 0.76 (2015-04-01) typos, signed/unsigned shader issue, more documentation // 0.75 (2015-04-01) initial release // // // HISTORICAL FOUNDATION // // stb_voxel_render 20-byte quads 2015/01 // zmc engine 32-byte quads 2013/12 // zmc engine 96-byte quads 2011/10 // // // LICENSE // // See end of file for license information. #ifndef INCLUDE_STB_VOXEL_RENDER_H #define INCLUDE_STB_VOXEL_RENDER_H #include typedef struct stbvox_mesh_maker stbvox_mesh_maker; typedef struct stbvox_input_description stbvox_input_description; #ifdef STB_VOXEL_RENDER_STATIC #define STBVXDEC static #else #define STBVXDEC extern #endif #ifdef __cplusplus extern "C" { #endif ////////////////////////////////////////////////////////////////////////////// // // CONFIGURATION MACROS // // #define STBVOX_CONFIG_MODE // REQUIRED // Configures the overall behavior of stb_voxel_render. This // can affect the shaders, the uniform info, and other things. // (If you need more than one mode in the same app, you can // use STB_VOXEL_RENDER_STATIC to create multiple versions // in separate files, and then wrap them.) // // Mode value Meaning // 0 Textured blocks, 32-byte quads // 1 Textured blocks, 20-byte quads // 20 Untextured blocks, 32-byte quads // 21 Untextured blocks, 20-byte quads // // // #define STBVOX_CONFIG_PRECISION_Z // OPTIONAL // Defines the number of bits of fractional position for Z. // Only 0 or 1 are valid. 1 is the default. If 0, then a // single mesh has twice the legal Z range; e.g. in // modes 0,1,20,21, Z in the mesh can extend to 511 instead // of 255. However, half-height blocks cannot be used. // // All of the following are just #ifdef tested so need no values, and are optional. // // STBVOX_CONFIG_BLOCKTYPE_SHORT // use unsigned 16-bit values for 'blocktype' in the input instead of 8-bit values // // STBVOX_CONFIG_OPENGL_MODELVIEW // use the gl_ModelView matrix rather than the explicit uniform // // STBVOX_CONFIG_HLSL // NOT IMPLEMENTED! Define HLSL shaders instead of GLSL shaders // // STBVOX_CONFIG_PREFER_TEXBUFFER // Stores many of the uniform arrays in texture buffers intead, // so they can be larger and may be more efficient on some hardware. // // STBVOX_CONFIG_LIGHTING_SIMPLE // Creates a simple lighting engine with a single point light source // in addition to the default half-lambert ambient light. // // STBVOX_CONFIG_LIGHTING // Declares a lighting function hook; you must append a lighting function // to the shader before compiling it: // vec3 compute_lighting(vec3 pos, vec3 norm, vec3 albedo, vec3 ambient); // 'ambient' is the half-lambert ambient light with vertex ambient-occlusion applied // // STBVOX_CONFIG_FOG_SMOOTHSTEP // Defines a simple unrealistic fog system designed to maximize // unobscured view distance while not looking too weird when things // emerge from the fog. Configured using an extra array element // in the STBVOX_UNIFORM_ambient uniform. // // STBVOX_CONFIG_FOG // Defines a fog function hook; you must append a fog function to // the shader before compiling it: // vec3 compute_fog(vec3 color, vec3 relative_pos, float fragment_alpha); // "color" is the incoming pre-fogged color, fragment_alpha is the alpha value, // and relative_pos is the vector from the point to the camera in worldspace // // STBVOX_CONFIG_DISABLE_TEX2 // This disables all processing of texture 2 in the shader in case // you don't use it. Eventually this could be replaced with a mode // that omits the unused data entirely. // // STBVOX_CONFIG_TEX1_EDGE_CLAMP // STBVOX_CONFIG_TEX2_EDGE_CLAMP // If you want to edge clamp the textures, instead of letting them wrap, // set this flag. By default stb_voxel_render relies on texture wrapping // to simplify texture coordinate generation. This flag forces it to do // it correctly, although there can still be minor artifacts. // // STBVOX_CONFIG_ROTATION_IN_LIGHTING // Changes the meaning of the 'lighting' mesher input variable to also // store the rotation; see later discussion. // // STBVOX_CONFIG_VHEIGHT_IN_LIGHTING // Changes the meaning of the 'lighting' mesher input variable to also // store the vheight; see later discussion. Cannot use both this and // the previous variable. // // STBVOX_CONFIG_PREMULTIPLIED_ALPHA // Adjusts the shader calculations on the assumption that tex1.rgba, // tex2.rgba, and color.rgba all use premultiplied values, and that // the output of the fragment shader should be premultiplied. // // STBVOX_CONFIG_UNPREMULTIPLY // Only meaningful if STBVOX_CONFIG_PREMULTIPLIED_ALPHA is defined. // Changes the behavior described above so that the inputs are // still premultiplied alpha, but the output of the fragment // shader is not premultiplied alpha. This is needed when allowing // non-unit alpha values but not doing alpha-blending (for example // when alpha testing). // ////////////////////////////////////////////////////////////////////////////// // // MESHING // // A mesh represents a (typically) small chunk of a larger world. // Meshes encode coordinates using small integers, so those // coordinates must be relative to some base location. // All of the coordinates in the functions below use // these relative coordinates unless explicitly stated // otherwise. // // Input to the meshing step is documented further down STBVXDEC void stbvox_init_mesh_maker(stbvox_mesh_maker *mm); // Call this function to initialize a mesh-maker context structure // used to build meshes. You should have one context per thread // that's building meshes. STBVXDEC void stbvox_set_buffer(stbvox_mesh_maker *mm, int mesh, int slot, void *buffer, size_t len); // Call this to set the buffer into which stbvox will write the mesh // it creates. It can build more than one mesh in parallel (distinguished // by the 'mesh' parameter), and each mesh can be made up of more than // one buffer (distinguished by the 'slot' parameter). // // Multiple meshes are under your control; use the 'selector' input // variable to choose which mesh each voxel's vertices are written to. // For example, you can use this to generate separate meshes for opaque // and transparent data. // // You can query the number of slots by calling stbvox_get_buffer_count // described below. The meaning of the buffer for each slot depends // on STBVOX_CONFIG_MODE. // // In mode 0 & mode 20, there is only one slot. The mesh data for that // slot is two interleaved vertex attributes: attr_vertex, a single // 32-bit uint, and attr_face, a single 32-bit uint. // // In mode 1 & mode 21, there are two slots. The first buffer should // be four times as large as the second buffer. The first buffer // contains a single vertex attribute: 'attr_vertex', a single 32-bit uint. // The second buffer contains texture buffer data (an array of 32-bit uints) // that will be accessed through the sampler identified by STBVOX_UNIFORM_face_data. STBVXDEC int stbvox_get_buffer_count(stbvox_mesh_maker *mm); // Returns the number of buffers needed per mesh as described above. STBVXDEC int stbvox_get_buffer_size_per_quad(stbvox_mesh_maker *mm, int slot); // Returns how much of a given buffer will get used per quad. This // allows you to choose correct relative sizes for each buffer, although // the values are fixed based on the configuration you've selected at // compile time, and the details are described in stbvox_set_buffer. STBVXDEC void stbvox_set_default_mesh(stbvox_mesh_maker *mm, int mesh); // Selects which mesh the mesher will output to (see previous function) // if the input doesn't specify a per-voxel selector. (I doubt this is // useful, but it's here just in case.) STBVXDEC stbvox_input_description *stbvox_get_input_description(stbvox_mesh_maker *mm); // This function call returns a pointer to the stbvox_input_description part // of stbvox_mesh_maker (which you should otherwise treat as opaque). You // zero this structure, then fill out the relevant pointers to the data // describing your voxel object/world. // // See further documentation at the description of stbvox_input_description below. STBVXDEC void stbvox_set_input_stride(stbvox_mesh_maker *mm, int x_stride_in_elements, int y_stride_in_elements); // This sets the stride between successive elements of the 3D arrays // in the stbvox_input_description. Z values are always stored consecutively. // (The preferred coordinate system for stbvox is X right, Y forwards, Z up.) STBVXDEC void stbvox_set_input_range(stbvox_mesh_maker *mm, int x0, int y0, int z0, int x1, int y1, int z1); // This sets the range of values in the 3D array for the voxels that // the mesh generator will convert. The lower values are inclusive, // the higher values are exclusive, so (0,0,0) to (16,16,16) generates // mesh data associated with voxels up to (15,15,15) but no higher. // // The mesh generate generates faces at the boundary between open space // and solid space but associates them with the solid space, so if (15,0,0) // is open and (16,0,0) is solid, then the mesh will contain the boundary // between them if x0 <= 16 and x1 > 16. // // Note that the mesh generator will access array elements 1 beyond the // limits set in these parameters. For example, if you set the limits // to be (0,0,0) and (16,16,16), then the generator will access all of // the voxels between (-1,-1,-1) and (16,16,16), including (16,16,16). // You may have to do pointer arithmetic to make it work. // // For example, caveview processes mesh chunks that are 32x32x16, but it // does this using input buffers that are 34x34x18. // // The lower limits are x0 >= 0, y0 >= 0, and z0 >= 0. // // The upper limits are mode dependent, but all the current methods are // limited to x1 < 127, y1 < 127, z1 < 255. Note that these are not // powers of two; if you want to use power-of-two chunks (to make // it efficient to decide which chunk a coordinate falls in), you're // limited to at most x1=64, y1=64, z1=128. For classic Minecraft-style // worlds with limited vertical extent, I recommend using a single // chunk for the entire height, which limits the height to 255 blocks // (one less than Minecraft), and only chunk the map in X & Y. STBVXDEC int stbvox_make_mesh(stbvox_mesh_maker *mm); // Call this function to create mesh data for the currently configured // set of input data. This appends to the currently configured mesh output // buffer. Returns 1 on success. If there is not enough room in the buffer, // it outputs as much as it can, and returns 0; you need to switch output // buffers (either by calling stbvox_set_buffer to set new buffers, or // by copying the data out and calling stbvox_reset_buffers), and then // call this function again without changing any of the input parameters. // // Note that this function appends; you can call it multiple times to // build a single mesh. For example, caveview uses chunks that are // 32x32x255, but builds the mesh for it by processing 32x32x16 at atime // (this is faster as it is reuses the same 34x34x18 input buffers rather // than needing 34x34x257 input buffers). // Once you're done creating a mesh into a given buffer, // consider the following functions: STBVXDEC int stbvox_get_quad_count(stbvox_mesh_maker *mm, int mesh); // Returns the number of quads in the mesh currently generated by mm. // This is the sum of all consecutive stbvox_make_mesh runs appending // to the same buffer. 'mesh' distinguishes between the multiple user // meshes available via 'selector' or stbvox_set_default_mesh. // // Typically you use this function when you're done building the mesh // and want to record how to draw it. // // Note that there are no index buffers; the data stored in the buffers // should be drawn as quads (e.g. with GL_QUAD); if your API does not // support quads, you can create a single index buffer large enough to // draw your largest vertex buffer, and reuse it for every rendering. // (Note that if you use 32-bit indices, you'll use 24 bytes of bandwidth // per quad, more than the 20 bytes for the vertex/face mesh data.) STBVXDEC void stbvox_set_mesh_coordinates(stbvox_mesh_maker *mm, int x, int y, int z); // Sets the global coordinates for this chunk, such that (0,0,0) relative // coordinates will be at (x,y,z) in global coordinates. STBVXDEC void stbvox_get_bounds(stbvox_mesh_maker *mm, float bounds[2][3]); // Returns the bounds for the mesh in global coordinates. Use this // for e.g. frustum culling the mesh. @BUG: this just uses the // values from stbvox_set_input_range(), so if you build by // appending multiple values, this will be wrong, and you need to // set stbvox_set_input_range() to the full size. Someday this // will switch to tracking the actual bounds of the *mesh*, though. STBVXDEC void stbvox_get_transform(stbvox_mesh_maker *mm, float transform[3][3]); // Returns the 'transform' data for the shader uniforms. It is your // job to set this to the shader before drawing the mesh. It is the // only uniform that needs to change per-mesh. Note that it is not // a 3x3 matrix, but rather a scale to decode fixed point numbers as // floats, a translate from relative to global space, and a special // translation for texture coordinate generation that avoids // floating-point precision issues. @TODO: currently we add the // global translation to the vertex, than multiply by modelview, // but this means if camera location and vertex are far from the // origin, we lose precision. Need to make a special modelview with // the translation (or some of it) factored out to avoid this. STBVXDEC void stbvox_reset_buffers(stbvox_mesh_maker *mm); // Call this function if you're done with the current output buffer // but want to reuse it (e.g. you're done appending with // stbvox_make_mesh and you've copied the data out to your graphics API // so can reuse the buffer). ////////////////////////////////////////////////////////////////////////////// // // RENDERING // STBVXDEC char *stbvox_get_vertex_shader(void); // Returns the (currently GLSL-only) vertex shader. STBVXDEC char *stbvox_get_fragment_shader(void); // Returns the (currently GLSL-only) fragment shader. // You can override the lighting and fogging calculations // by appending data to the end of these; see the #define // documentation for more information. STBVXDEC char *stbvox_get_fragment_shader_alpha_only(void); // Returns a slightly cheaper fragment shader that computes // alpha but not color. This is useful for e.g. a depth-only // pass when using alpha test. typedef struct stbvox_uniform_info stbvox_uniform_info; STBVXDEC int stbvox_get_uniform_info(stbvox_uniform_info *info, int uniform); // Gets the information about a uniform necessary for you to // set up each uniform with a minimal amount of explicit code. // See the sample code after the structure definition for stbvox_uniform_info, // further down in this header section. // // "uniform" is from the list immediately following. For many // of these, default values are provided which you can set. // Most values are shared for most draw calls; e.g. for stateful // APIs you can set most of the state only once. Only // STBVOX_UNIFORM_transform needs to change per draw call. // // STBVOX_UNIFORM_texscale // 64- or 128-long vec4 array. (128 only if STBVOX_CONFIG_PREFER_TEXBUFFER) // x: scale factor to apply to texture #1. must be a power of two. 1.0 means 'face-sized' // y: scale factor to apply to texture #2. must be a power of two. 1.0 means 'face-sized' // z: blend mode indexed by texture #2. 0.0 is alpha compositing; 1.0 is multiplication. // w: unused currently. @TODO use to support texture animation? // // Texscale is indexed by the bottom 6 or 7 bits of the texture id; thus for // example the texture at index 0 in the array and the texture in index 128 of // the array must be scaled the same. This means that if you only have 64 or 128 // unique textures, they all get distinct values anyway; otherwise you have // to group them in pairs or sets of four. // // STBVOX_UNIFORM_ambient // 4-long vec4 array: // ambient[0].xyz - negative of direction of a directional light for half-lambert // ambient[1].rgb - color of light scaled by NdotL (can be negative) // ambient[2].rgb - constant light added to above calculation; // effectively light ranges from ambient[2]-ambient[1] to ambient[2]+ambient[1] // ambient[3].rgb - fog color for STBVOX_CONFIG_FOG_SMOOTHSTEP // ambient[3].a - reciprocal of squared distance of farthest fog point (viewing distance) // +----- has a default value // | +-- you should always use the default value enum // V V { // ------------------------------------------------ STBVOX_UNIFORM_face_data, // n the sampler with the face texture buffer STBVOX_UNIFORM_transform, // n the transform data from stbvox_get_transform STBVOX_UNIFORM_tex_array, // n an array of two texture samplers containing the two texture arrays STBVOX_UNIFORM_texscale, // Y a table of texture properties, see above STBVOX_UNIFORM_color_table, // Y 64 vec4 RGBA values; a default palette is provided; if A > 1.0, fullbright STBVOX_UNIFORM_normals, // Y Y table of normals, internal-only STBVOX_UNIFORM_texgen, // Y Y table of texgen vectors, internal-only STBVOX_UNIFORM_ambient, // n lighting & fog info, see above STBVOX_UNIFORM_camera_pos, // Y camera position in global voxel space (for lighting & fog) STBVOX_UNIFORM_count, }; enum { STBVOX_UNIFORM_TYPE_none, STBVOX_UNIFORM_TYPE_sampler, STBVOX_UNIFORM_TYPE_vec2, STBVOX_UNIFORM_TYPE_vec3, STBVOX_UNIFORM_TYPE_vec4, }; struct stbvox_uniform_info { int type; // which type of uniform int bytes_per_element; // the size of each uniform array element (e.g. vec3 = 12 bytes) int array_length; // length of the uniform array char *name; // name in the shader @TODO use numeric binding float *default_value; // if not NULL, you can use this as the uniform pointer int use_tex_buffer; // if true, then the uniform is a sampler but the data can come from default_value }; ////////////////////////////////////////////////////////////////////////////// // // Uniform sample code // #if 0 // Run this once per frame before drawing all the meshes. // You still need to separately set the 'transform' uniform for every mesh. void setup_uniforms(GLuint shader, float camera_pos[4], GLuint tex1, GLuint tex2) { int i; glUseProgram(shader); // so uniform binding works for (i=0; i < STBVOX_UNIFORM_count; ++i) { stbvox_uniform_info sui; if (stbvox_get_uniform_info(&sui, i)) { GLint loc = glGetUniformLocation(shader, sui.name); if (loc != 0) { switch (i) { case STBVOX_UNIFORM_camera_pos: // only needed for fog glUniform4fv(loc, sui.array_length, camera_pos); break; case STBVOX_UNIFORM_tex_array: { GLuint tex_unit[2] = { 0, 1 }; // your choice of samplers glUniform1iv(loc, 2, tex_unit); glActiveTexture(GL_TEXTURE0 + tex_unit[0]); glBindTexture(GL_TEXTURE_2D_ARRAY, tex1); glActiveTexture(GL_TEXTURE0 + tex_unit[1]); glBindTexture(GL_TEXTURE_2D_ARRAY, tex2); glActiveTexture(GL_TEXTURE0); // reset to default break; } case STBVOX_UNIFORM_face_data: glUniform1i(loc, SAMPLER_YOU_WILL_BIND_PER_MESH_FACE_DATA_TO); break; case STBVOX_UNIFORM_ambient: // you definitely want to override this case STBVOX_UNIFORM_color_table: // you might want to override this case STBVOX_UNIFORM_texscale: // you may want to override this glUniform4fv(loc, sui.array_length, sui.default_value); break; case STBVOX_UNIFORM_normals: // you never want to override this case STBVOX_UNIFORM_texgen: // you never want to override this glUniform3fv(loc, sui.array_length, sui.default_value); break; } } } } } #endif #ifdef __cplusplus } #endif ////////////////////////////////////////////////////////////////////////////// // // INPUT TO MESHING // // Shapes of blocks that aren't always cubes enum { STBVOX_GEOM_empty, STBVOX_GEOM_knockout, // creates a hole in the mesh STBVOX_GEOM_solid, STBVOX_GEOM_transp, // solid geometry, but transparent contents so neighbors generate normally, unless same blocktype // following 4 can be represented by vheight as well STBVOX_GEOM_slab_upper, STBVOX_GEOM_slab_lower, STBVOX_GEOM_floor_slope_north_is_top, STBVOX_GEOM_ceil_slope_north_is_bottom, STBVOX_GEOM_floor_slope_north_is_top_as_wall_UNIMPLEMENTED, // same as floor_slope above, but uses wall's texture & texture projection STBVOX_GEOM_ceil_slope_north_is_bottom_as_wall_UNIMPLEMENTED, STBVOX_GEOM_crossed_pair, // corner-to-corner pairs, with normal vector bumped upwards STBVOX_GEOM_force, // like GEOM_transp, but faces visible even if neighbor is same type, e.g. minecraft fancy leaves // these access vheight input STBVOX_GEOM_floor_vheight_03 = 12, // diagonal is SW-NE STBVOX_GEOM_floor_vheight_12, // diagonal is SE-NW STBVOX_GEOM_ceil_vheight_03, STBVOX_GEOM_ceil_vheight_12, STBVOX_GEOM_count, // number of geom cases }; enum { STBVOX_FACE_east, STBVOX_FACE_north, STBVOX_FACE_west, STBVOX_FACE_south, STBVOX_FACE_up, STBVOX_FACE_down, STBVOX_FACE_count, }; #ifdef STBVOX_CONFIG_BLOCKTYPE_SHORT typedef unsigned short stbvox_block_type; #else typedef unsigned char stbvox_block_type; #endif // 24-bit color typedef struct { unsigned char r,g,b; } stbvox_rgb; #define STBVOX_COLOR_TEX1_ENABLE 64 #define STBVOX_COLOR_TEX2_ENABLE 128 // This is the data structure you fill out. Most of the arrays can be // NULL, except when one is required to get the value to index another. // // The compass system used in the following descriptions is: // east means increasing x // north means increasing y // up means increasing z struct stbvox_input_description { unsigned char lighting_at_vertices; // The default is lighting values (i.e. ambient occlusion) are at block // center, and the vertex light is gathered from those adjacent block // centers that the vertex is facing. This makes smooth lighting // consistent across adjacent faces with the same orientation. // // Setting this flag to non-zero gives you explicit control // of light at each vertex, but now the lighting/ao will be // shared by all vertices at the same point, even if they // have different normals. // these are mostly 3D maps you use to define your voxel world, using x_stride and y_stride // note that for cache efficiency, you want to use the block_foo palettes as much as possible instead stbvox_rgb *rgb; // Indexed by 3D coordinate. // 24-bit voxel color for STBVOX_CONFIG_MODE = 20 or 21 only unsigned char *lighting; // Indexed by 3D coordinate. The lighting value / ambient occlusion // value that is used to define the vertex lighting values. // The raw lighting values are defined at the center of blocks // (or at vertex if 'lighting_at_vertices' is true). // // If the macro STBVOX_CONFIG_ROTATION_IN_LIGHTING is defined, // then an additional 2-bit block rotation value is stored // in this field as well. // // Encode with STBVOX_MAKE_LIGHTING_EXT(lighting,rot)--here // 'lighting' should still be 8 bits, as the macro will // discard the bottom bits automatically. Similarly, if // using STBVOX_CONFIG_VHEIGHT_IN_LIGHTING, encode with // STBVOX_MAKE_LIGHTING_EXT(lighting,vheight). // // (Rationale: rotation needs to be independent of blocktype, // but is only 2 bits so doesn't want to be its own array. // Lighting is the one thing that was likely to already be // in use and that I could easily steal 2 bits from.) stbvox_block_type *blocktype; // Indexed by 3D coordinate. This is a core "block type" value, which is used // to index into other arrays; essentially a "palette". This is much more // memory-efficient and performance-friendly than storing the values explicitly, // but only makes sense if the values are always synchronized. // // If a voxel's blocktype is 0, it is assumed to be empty (STBVOX_GEOM_empty), // and no other blocktypes should be STBVOX_GEOM_empty. (Only if you do not // have blocktypes should STBVOX_GEOM_empty ever used.) // // Normally it is an unsigned byte, but you can override it to be // a short if you have too many blocktypes. unsigned char *geometry; // Indexed by 3D coordinate. Contains the geometry type for the block. // Also contains a 2-bit rotation for how the whole block is rotated. // Also includes a 2-bit vheight value when using shared vheight values. // See the separate vheight documentation. // Encode with STBVOX_MAKE_GEOMETRY(geom, rot, vheight) unsigned char *block_geometry; // Array indexed by blocktype containing the geometry for this block, plus // a 2-bit "simple rotation". Note rotation has limited use since it's not // independent of blocktype. // // Encode with STBVOX_MAKE_GEOMETRY(geom,simple_rot,0) unsigned char *block_tex1; // Array indexed by blocktype containing the texture id for texture #1. unsigned char (*block_tex1_face)[6]; // Array indexed by blocktype and face containing the texture id for texture #1. // The N/E/S/W face choices can be rotated by one of the rotation selectors; // The top & bottom face textures will rotate to match. // Note that it only makes sense to use one of block_tex1 or block_tex1_face; // this pattern repeats throughout and this notice is not repeated. unsigned char *tex2; // Indexed by 3D coordinate. Contains the texture id for texture #2 // to use on all faces of the block. unsigned char *block_tex2; // Array indexed by blocktype containing the texture id for texture #2. unsigned char (*block_tex2_face)[6]; // Array indexed by blocktype and face containing the texture id for texture #2. // The N/E/S/W face choices can be rotated by one of the rotation selectors; // The top & bottom face textures will rotate to match. unsigned char *color; // Indexed by 3D coordinate. Contains the color for all faces of the block. // The core color value is 0..63. // Encode with STBVOX_MAKE_COLOR(color_number, tex1_enable, tex2_enable) unsigned char *block_color; // Array indexed by blocktype containing the color value to apply to the faces. // The core color value is 0..63. // Encode with STBVOX_MAKE_COLOR(color_number, tex1_enable, tex2_enable) unsigned char (*block_color_face)[6]; // Array indexed by blocktype and face containing the color value to apply to that face. // The core color value is 0..63. // Encode with STBVOX_MAKE_COLOR(color_number, tex1_enable, tex2_enable) unsigned char *block_texlerp; // Array indexed by blocktype containing 3-bit scalar for texture #2 alpha // (known throughout as 'texlerp'). This is constant over every face even // though the property is potentially per-vertex. unsigned char (*block_texlerp_face)[6]; // Array indexed by blocktype and face containing 3-bit scalar for texture #2 alpha. // This is constant over the face even though the property is potentially per-vertex. unsigned char *block_vheight; // Array indexed by blocktype containing the vheight values for the // top or bottom face of this block. These will rotate properly if the // block is rotated. See discussion of vheight. // Encode with STBVOX_MAKE_VHEIGHT(sw_height, se_height, nw_height, ne_height) unsigned char *selector; // Array indexed by 3D coordinates indicating which output mesh to select. unsigned char *block_selector; // Array indexed by blocktype indicating which output mesh to select. unsigned char *side_texrot; // Array indexed by 3D coordinates encoding 2-bit texture rotations for the // faces on the E/N/W/S sides of the block. // Encode with STBVOX_MAKE_SIDE_TEXROT(rot_e, rot_n, rot_w, rot_s) unsigned char *block_side_texrot; // Array indexed by blocktype encoding 2-bit texture rotations for the faces // on the E/N/W/S sides of the block. // Encode with STBVOX_MAKE_SIDE_TEXROT(rot_e, rot_n, rot_w, rot_s) unsigned char *overlay; // index into palettes listed below // Indexed by 3D coordinate. If 0, there is no overlay. If non-zero, // it indexes into to the below arrays and overrides the values // defined by the blocktype. unsigned char (*overlay_tex1)[6]; // Array indexed by overlay value and face, containing an override value // for the texture id for texture #1. If 0, the value defined by blocktype // is used. unsigned char (*overlay_tex2)[6]; // Array indexed by overlay value and face, containing an override value // for the texture id for texture #2. If 0, the value defined by blocktype // is used. unsigned char (*overlay_color)[6]; // Array indexed by overlay value and face, containing an override value // for the face color. If 0, the value defined by blocktype is used. unsigned char *overlay_side_texrot; // Array indexed by overlay value, encoding 2-bit texture rotations for the faces // on the E/N/W/S sides of the block. // Encode with STBVOX_MAKE_SIDE_TEXROT(rot_e, rot_n, rot_w, rot_s) unsigned char *rotate; // Indexed by 3D coordinate. Allows independent rotation of several // parts of the voxel, where by rotation I mean swapping textures // and colors between E/N/S/W faces. // Block: rotates anything indexed by blocktype // Overlay: rotates anything indexed by overlay // EColor: rotates faces defined in ecolor_facemask // Encode with STBVOX_MAKE_MATROT(block,overlay,ecolor) unsigned char *tex2_for_tex1; // Array indexed by tex1 containing the texture id for texture #2. // You can use this if the two are always/almost-always strictly // correlated (e.g. if tex2 is a detail texture for tex1), as it // will be more efficient (touching fewer cache lines) than using // e.g. block_tex2_face. unsigned char *tex2_replace; // Indexed by 3D coordinate. Specifies the texture id for texture #2 // to use on a single face of the voxel, which must be E/N/W/S (not U/D). // The texture id is limited to 6 bits unless tex2_facemask is also // defined (see below). // Encode with STBVOX_MAKE_TEX2_REPLACE(tex2, face) unsigned char *tex2_facemask; // Indexed by 3D coordinate. Specifies which of the six faces should // have their tex2 replaced by the value of tex2_replace. In this // case, all 8 bits of tex2_replace are used as the texture id. // Encode with STBVOX_MAKE_FACE_MASK(east,north,west,south,up,down) unsigned char *extended_color; // Indexed by 3D coordinate. Specifies a value that indexes into // the ecolor arrays below (both of which must be defined). unsigned char *ecolor_color; // Indexed by extended_color value, specifies an optional override // for the color value on some faces. // Encode with STBVOX_MAKE_COLOR(color_number, tex1_enable, tex2_enable) unsigned char *ecolor_facemask; // Indexed by extended_color value, this specifies which faces the // color in ecolor_color should be applied to. The faces can be // independently rotated by the ecolor value of 'rotate', if it exists. // Encode with STBVOX_MAKE_FACE_MASK(e,n,w,s,u,d) unsigned char *color2; // Indexed by 3D coordinates, specifies an alternative color to apply // to some of the faces of the block. // Encode with STBVOX_MAKE_COLOR(color_number, tex1_enable, tex2_enable) unsigned char *color2_facemask; // Indexed by 3D coordinates, specifies which faces should use the // color defined in color2. No rotation value is applied. // Encode with STBVOX_MAKE_FACE_MASK(e,n,w,s,u,d) unsigned char *color3; // Indexed by 3D coordinates, specifies an alternative color to apply // to some of the faces of the block. // Encode with STBVOX_MAKE_COLOR(color_number, tex1_enable, tex2_enable) unsigned char *color3_facemask; // Indexed by 3D coordinates, specifies which faces should use the // color defined in color3. No rotation value is applied. // Encode with STBVOX_MAKE_FACE_MASK(e,n,w,s,u,d) unsigned char *texlerp_simple; // Indexed by 3D coordinates, this is the smallest texlerp encoding // that can do useful work. It consits of three values: baselerp, // vertlerp, and face_vertlerp. Baselerp defines the value // to use on all of the faces but one, from the STBVOX_TEXLERP_BASE // values. face_vertlerp is one of the 6 face values (or STBVOX_FACE_NONE) // which specifies the face should use the vertlerp values. // Vertlerp defines a lerp value at every vertex of the mesh. // Thus, one face can have per-vertex texlerp values, and those // values are encoded in the space so that they will be shared // by adjacent faces that also use vertlerp, allowing continuity // (this is used for the "texture crossfade" bit of the release video). // Encode with STBVOX_MAKE_TEXLERP_SIMPLE(baselerp, vertlerp, face_vertlerp) // The following texlerp encodings are experimental and maybe not // that useful. unsigned char *texlerp; // Indexed by 3D coordinates, this defines four values: // vertlerp is a lerp value at every vertex of the mesh (using STBVOX_TEXLERP_BASE values). // ud is the value to use on up and down faces, from STBVOX_TEXLERP_FACE values // ew is the value to use on east and west faces, from STBVOX_TEXLERP_FACE values // ns is the value to use on north and south faces, from STBVOX_TEXLERP_FACE values // If any of ud, ew, or ns is STBVOX_TEXLERP_FACE_use_vert, then the // vertlerp values for the vertices are gathered and used for those faces. // Encode with STBVOX_MAKE_TEXLERP(vertlerp,ud,ew,sw) unsigned short *texlerp_vert3; // Indexed by 3D coordinates, this works with texlerp and // provides a unique texlerp value for every direction at // every vertex. The same rules of whether faces share values // applies. The STBVOX_TEXLERP_FACE vertlerp value defined in // texlerp is only used for the down direction. The values at // each vertex in other directions are defined in this array, // and each uses the STBVOX_TEXLERP3 values (i.e. full precision // 3-bit texlerp values). // Encode with STBVOX_MAKE_VERT3(vertlerp_e,vertlerp_n,vertlerp_w,vertlerp_s,vertlerp_u) unsigned short *texlerp_face3; // e:3,n:3,w:3,s:3,u:2,d:2 // Indexed by 3D coordinates, this provides a compact way to // fully specify the texlerp value indepenendly for every face, // but doesn't allow per-vertex variation. E/N/W/S values are // encoded using STBVOX_TEXLERP3 values, whereas up and down // use STBVOX_TEXLERP_SIMPLE values. // Encode with STBVOX_MAKE_FACE3(face_e,face_n,face_w,face_s,face_u,face_d) unsigned char *vheight; // STBVOX_MAKE_VHEIGHT -- sw:2, se:2, nw:2, ne:2, doesn't rotate // Indexed by 3D coordinates, this defines the four // vheight values to use if the geometry is STBVOX_GEOM_vheight*. // See the vheight discussion. unsigned char *packed_compact; // Stores block rotation, vheight, and texlerp values: // block rotation: 2 bits // vertex vheight: 2 bits // use_texlerp : 1 bit // vertex texlerp: 3 bits // If STBVOX_CONFIG_UP_TEXLERP_PACKED is defined, then 'vertex texlerp' is // used for up faces if use_texlerp is 1. If STBVOX_CONFIG_DOWN_TEXLERP_PACKED // is defined, then 'vertex texlerp' is used for down faces if use_texlerp is 1. // Note if those symbols are defined but packed_compact is NULL, the normal // texlerp default will be used. // Encode with STBVOX_MAKE_PACKED_COMPACT(rot, vheight, texlerp, use_texlerp) }; // @OPTIMIZE allow specializing; build a single struct with all of the // 3D-indexed arrays combined so it's AoS instead of SoA for better // cache efficiency ////////////////////////////////////////////////////////////////////////////// // // VHEIGHT DOCUMENTATION // // "vheight" is the internal name for the special block types // with sloped tops or bottoms. "vheight" stands for "vertex height". // // Note that these blocks are very flexible (there are 256 of them, // although at least 17 of them should never be used), but they // also have a disadvantage that they generate extra invisible // faces; the generator does not currently detect whether adjacent // vheight blocks hide each others sides, so those side faces are // always generated. For a continuous ground terrain, this means // that you may generate 5x as many quads as needed. See notes // on "improvements for shipping products" in the introduction. enum { STBVOX_VERTEX_HEIGHT_0, STBVOX_VERTEX_HEIGHT_half, STBVOX_VERTEX_HEIGHT_1, STBVOX_VERTEX_HEIGHT_one_and_a_half, }; // These are the "vheight" values. Vheight stands for "vertex height". // The idea is that for a "floor vheight" block, you take a cube and // reposition the top-most vertices at various heights as specified by // the vheight values. Similarly, a "ceiling vheight" block takes a // cube and repositions the bottom-most vertices. // // A floor block only adjusts the top four vertices; the bottom four vertices // remain at the bottom of the block. The height values are 2 bits, // measured in halves of a block; so you can specify heights of 0/2, // 1/2, 2/2, or 3/2. 0 is the bottom of the block, 1 is halfway // up the block, 2 is the top of the block, and 3 is halfway up the // next block (and actually outside of the block). The value 3 is // actually legal for floor vheight (but not ceiling), and allows you to: // // (A) have smoother terrain by having slopes that cross blocks, // e.g. (1,1,3,3) is a regular-seeming slope halfway between blocks // (B) make slopes steeper than 45-degrees, e.g. (0,0,3,3) // // (Because only z coordinates have half-block precision, and x&y are // limited to block corner precision, it's not possible to make these // things "properly" out of blocks, e.g. a half-slope block on its side // or a sloped block halfway between blocks that's made out of two blocks.) // // If you define STBVOX_CONFIG_OPTIMIZED_VHEIGHT, then the top face // (or bottom face for a ceiling vheight block) will be drawn as a // single quad even if the four vertex heights aren't planar, and a // single normal will be used over the entire quad. If you // don't define it, then if the top face is non-planar, it will be // split into two triangles, each with their own normal/lighting. // (Note that since all output from stb_voxel_render is quad meshes, // triangles are actually rendered as degenerate quads.) In this case, // the distinction betwen STBVOX_GEOM_floor_vheight_03 and // STBVOX_GEOM_floor_vheight_12 comes into play; the former introduces // an edge from the SW to NE corner (i.e. from <0,0,?> to <1,1,?>), // while the latter introduces an edge from the NW to SE corner // (i.e. from <0,1,?> to <1,0,?>.) For a "lazy mesh" look, use // exclusively _03 or _12. For a "classic mesh" look, alternate // _03 and _12 in a checkerboard pattern. For a "smoothest surface" // look, choose the edge based on actual vertex heights. // // The four vertex heights can come from several places. The simplest // encoding is to just use the 'vheight' parameter which stores four // explicit vertex heights for every block. This allows total independence, // but at the cost of the largest memory usage, 1 byte per 3D block. // Encode this with STBVOX_MAKE_VHEIGHT(vh_sw, vh_se, vh_nw, vh_ne). // These coordinates are absolute, not affected by block rotations. // // An alternative if you just want to encode some very specific block // types, not all the possibilities--say you just want half-height slopes, // so you want (0,0,1,1) and (1,1,2,2)--then you can use block_vheight // to specify them. The geometry rotation will cause block_vheight values // to be rotated (because it's as if you're just defining a type of // block). This value is also encoded with STBVOX_MAKE_VHEIGHT. // // If you want to save memory and you're creating a "continuous ground" // sort of effect, you can make each vertex of the lattice share the // vheight value; that is, two adjacent blocks that share a vertex will // always get the same vheight value for that vertex. Then you need to // store two bits of vheight for every block, which you do by storing it // as part another data structure. Store the south-west vertex's vheight // with the block. You can either use the "geometry" mesh variable (it's // a parameter to STBVOX_MAKE_GEOMETRY) or you can store it in the // "lighting" mesh variable if you defined STBVOX_CONFIG_VHEIGHT_IN_LIGHTING, // using STBVOX_MAKE_LIGHTING_EXT(lighting,vheight). // // Note that if you start with a 2D height map and generate vheight data from // it, you don't necessarily store only one value per (x,y) coordinate, // as the same value may need to be set up at multiple z heights. For // example, if height(8,8) = 13.5, then you want the block at (8,8,13) // to store STBVOX_VERTEX_HEIGHT_half, and this will be used by blocks // at (7,7,13), (8,7,13), (7,8,13), and (8,8,13). However, if you're // allowing steep slopes, it might be the case that you have a block // at (7,7,12) which is supposed to stick up to 13.5; that means // you also need to store STBVOX_VERTEX_HEIGHT_one_and_a_half at (8,8,12). enum { STBVOX_TEXLERP_FACE_0, STBVOX_TEXLERP_FACE_half, STBVOX_TEXLERP_FACE_1, STBVOX_TEXLERP_FACE_use_vert, }; enum { STBVOX_TEXLERP_BASE_0, // 0.0 STBVOX_TEXLERP_BASE_2_7, // 2/7 STBVOX_TEXLERP_BASE_5_7, // 4/7 STBVOX_TEXLERP_BASE_1 // 1.0 }; enum { STBVOX_TEXLERP3_0_8, STBVOX_TEXLERP3_1_8, STBVOX_TEXLERP3_2_8, STBVOX_TEXLERP3_3_8, STBVOX_TEXLERP3_4_8, STBVOX_TEXLERP3_5_8, STBVOX_TEXLERP3_6_8, STBVOX_TEXLERP3_7_8, }; #define STBVOX_FACE_NONE 7 #define STBVOX_BLOCKTYPE_EMPTY 0 #ifdef STBVOX_BLOCKTYPE_SHORT #define STBVOX_BLOCKTYPE_HOLE 65535 #else #define STBVOX_BLOCKTYPE_HOLE 255 #endif #define STBVOX_MAKE_GEOMETRY(geom, rotate, vheight) ((geom) + (rotate)*16 + (vheight)*64) #define STBVOX_MAKE_VHEIGHT(v_sw, v_se, v_nw, v_ne) ((v_sw) + (v_se)*4 + (v_nw)*16 + (v_ne)*64) #define STBVOX_MAKE_MATROT(block, overlay, color) ((block) + (overlay)*4 + (color)*64) #define STBVOX_MAKE_TEX2_REPLACE(tex2, tex2_replace_face) ((tex2) + ((tex2_replace_face) & 3)*64) #define STBVOX_MAKE_TEXLERP(ns2, ew2, ud2, vert) ((ew2) + (ns2)*4 + (ud2)*16 + (vert)*64) #define STBVOX_MAKE_TEXLERP_SIMPLE(baselerp,vert,face) ((vert)*32 + (face)*4 + (baselerp)) #define STBVOX_MAKE_TEXLERP1(vert,e2,n2,w2,s2,u4,d2) STBVOX_MAKE_TEXLERP(s2, w2, d2, vert) #define STBVOX_MAKE_TEXLERP2(vert,e2,n2,w2,s2,u4,d2) ((u2)*16 + (n2)*4 + (s2)) #define STBVOX_MAKE_FACE_MASK(e,n,w,s,u,d) ((e)+(n)*2+(w)*4+(s)*8+(u)*16+(d)*32) #define STBVOX_MAKE_SIDE_TEXROT(e,n,w,s) ((e)+(n)*4+(w)*16+(s)*64) #define STBVOX_MAKE_COLOR(color,t1,t2) ((color)+(t1)*64+(t2)*128) #define STBVOX_MAKE_TEXLERP_VERT3(e,n,w,s,u) ((e)+(n)*8+(w)*64+(s)*512+(u)*4096) #define STBVOX_MAKE_TEXLERP_FACE3(e,n,w,s,u,d) ((e)+(n)*8+(w)*64+(s)*512+(u)*4096+(d)*16384) #define STBVOX_MAKE_PACKED_COMPACT(rot, vheight, texlerp, def) ((rot)+4*(vheight)+16*(use)+32*(texlerp)) #define STBVOX_MAKE_LIGHTING_EXT(lighting, rot) (((lighting)&~3)+(rot)) #define STBVOX_MAKE_LIGHTING(lighting) (lighting) #ifndef STBVOX_MAX_MESHES #define STBVOX_MAX_MESHES 2 // opaque & transparent #endif #define STBVOX_MAX_MESH_SLOTS 3 // one vertex & two faces, or two vertex and one face // don't mess with this directly, it's just here so you can // declare stbvox_mesh_maker on the stack or as a global struct stbvox_mesh_maker { stbvox_input_description input; int cur_x, cur_y, cur_z; // last unprocessed voxel if it splits into multiple buffers int x0,y0,z0,x1,y1,z1; int x_stride_in_bytes; int y_stride_in_bytes; int config_dirty; int default_mesh; unsigned int tags; int cube_vertex_offset[6][4]; // this allows access per-vertex data stored block-centered (like texlerp, ambient) int vertex_gather_offset[6][4]; int pos_x,pos_y,pos_z; int full; // computed from user input char *output_cur [STBVOX_MAX_MESHES][STBVOX_MAX_MESH_SLOTS]; char *output_end [STBVOX_MAX_MESHES][STBVOX_MAX_MESH_SLOTS]; char *output_buffer[STBVOX_MAX_MESHES][STBVOX_MAX_MESH_SLOTS]; int output_len [STBVOX_MAX_MESHES][STBVOX_MAX_MESH_SLOTS]; // computed from config int output_size [STBVOX_MAX_MESHES][STBVOX_MAX_MESH_SLOTS]; // per quad int output_step [STBVOX_MAX_MESHES][STBVOX_MAX_MESH_SLOTS]; // per vertex or per face, depending int num_mesh_slots; float default_tex_scale[128][2]; }; #endif // INCLUDE_STB_VOXEL_RENDER_H #ifdef STB_VOXEL_RENDER_IMPLEMENTATION #include #include #include // memset // have to use our own names to avoid the _MSC_VER path having conflicting type names #ifndef _MSC_VER #include typedef uint16_t stbvox_uint16; typedef uint32_t stbvox_uint32; #else typedef unsigned short stbvox_uint16; typedef unsigned int stbvox_uint32; #endif #ifdef _MSC_VER #define STBVOX_NOTUSED(v) (void)(v) #else #define STBVOX_NOTUSED(v) (void)sizeof(v) #endif #ifndef STBVOX_CONFIG_MODE #error "Must defined STBVOX_CONFIG_MODE to select the mode" #endif #if defined(STBVOX_CONFIG_ROTATION_IN_LIGHTING) && defined(STBVOX_CONFIG_VHEIGHT_IN_LIGHTING) #error "Can't store both rotation and vheight in lighting" #endif // The following are candidate voxel modes. Only modes 0, 1, and 20, and 21 are // currently implemented. Reducing the storage-per-quad further // shouldn't improve performance, although obviously it allow you // to create larger worlds without streaming. // // // ----------- Two textures ----------- -- One texture -- ---- Color only ---- // Mode: 0 1 2 3 4 5 6 10 11 12 20 21 22 23 24 // ============================================================================================================ // uses Tex Buffer n Y Y Y Y Y Y Y Y Y n Y Y Y Y // bytes per quad 32 20 14 12 10 6 6 8 8 4 32 20 10 6 4 // non-blocks all all some some some slabs stairs some some none all all slabs slabs none // tex1 256 256 256 256 256 256 256 256 256 256 n n n n n // tex2 256 256 256 256 256 256 128 n n n n n n n n // colors 64 64 64 64 64 64 64 8 n n 2^24 2^24 2^24 2^24 256 // vertex ao Y Y Y Y Y n n Y Y n Y Y Y n n // vertex texlerp Y Y Y n n n n - - - - - - - - // x&y extents 127 127 128 64 64 128 64 64 128 128 127 127 128 128 128 // z extents 255 255 128 64? 64? 64 64 32 64 128 255 255 128 64 128 // not sure why I only wrote down the above "result data" and didn't preserve // the vertex formats, but here I've tried to reconstruct the designs... // mode # 3 is wrong, one byte too large, but they may have been an error originally // Mode: 0 1 2 3 4 5 6 10 11 12 20 21 22 23 24 // ============================================================================================================= // bytes per quad 32 20 14 12 10 6 6 8 8 4 20 10 6 4 // // vertex x bits 7 7 0 6 0 0 0 0 0 0 7 0 0 0 // vertex y bits 7 7 0 0 0 0 0 0 0 0 7 0 0 0 // vertex z bits 9 9 7 4 2 0 0 2 2 0 9 2 0 0 // vertex ao bits 6 6 6 6 6 0 0 6 6 0 6 6 0 0 // vertex txl bits 3 3 3 0 0 0 0 0 0 0 (3) 0 0 0 // // face tex1 bits (8) 8 8 8 8 8 8 8 8 8 // face tex2 bits (8) 8 8 8 8 8 7 - - - // face color bits (8) 8 8 8 8 8 8 3 0 0 24 24 24 8 // face normal bits (8) 8 8 8 6 4 7 4 4 3 8 3 4 3 // face x bits 7 0 6 7 6 6 7 7 0 7 7 7 // face y bits 7 6 6 7 6 6 7 7 0 7 7 7 // face z bits 2 2 6 6 6 5 6 7 0 7 6 7 #if STBVOX_CONFIG_MODE==0 || STBVOX_CONFIG_MODE==1 #define STBVOX_ICONFIG_VERTEX_32 #define STBVOX_ICONFIG_FACE1_1 #elif STBVOX_CONFIG_MODE==20 || STBVOX_CONFIG_MODE==21 #define STBVOX_ICONFIG_VERTEX_32 #define STBVOX_ICONFIG_FACE1_1 #define STBVOX_ICONFIG_UNTEXTURED #else #error "Selected value of STBVOX_CONFIG_MODE is not supported" #endif #if STBVOX_CONFIG_MODE==0 || STBVOX_CONFIG_MODE==20 #define STBVOX_ICONFIG_FACE_ATTRIBUTE #endif #ifndef STBVOX_CONFIG_HLSL // the fallback if all others are exhausted is GLSL #define STBVOX_ICONFIG_GLSL #endif #ifdef STBVOX_CONFIG_OPENGL_MODELVIEW #define STBVOX_ICONFIG_OPENGL_3_1_COMPATIBILITY #endif #if defined(STBVOX_ICONFIG_VERTEX_32) typedef stbvox_uint32 stbvox_mesh_vertex; #define stbvox_vertex_encode(x,y,z,ao,texlerp) \ ((stbvox_uint32) ((x)+((y)<<7)+((z)<<14)+((ao)<<23)+((texlerp)<<29))) #elif defined(STBVOX_ICONFIG_VERTEX_16_1) // mode=2 typedef stbvox_uint16 stbvox_mesh_vertex; #define stbvox_vertex_encode(x,y,z,ao,texlerp) \ ((stbvox_uint16) ((z)+((ao)<<7)+((texlerp)<<13) #elif defined(STBVOX_ICONFIG_VERTEX_16_2) // mode=3 typedef stbvox_uint16 stbvox_mesh_vertex; #define stbvox_vertex_encode(x,y,z,ao,texlerp) \ ((stbvox_uint16) ((x)+((z)<<6))+((ao)<<10)) #elif defined(STBVOX_ICONFIG_VERTEX_8) typedef stbvox_uint8 stbvox_mesh_vertex; #define stbvox_vertex_encode(x,y,z,ao,texlerp) \ ((stbvox_uint8) ((z)+((ao)<<6)) #else #error "internal error, no vertex type" #endif #ifdef STBVOX_ICONFIG_FACE1_1 typedef struct { unsigned char tex1,tex2,color,face_info; } stbvox_mesh_face; #else #error "internal error, no face type" #endif // 20-byte quad format: // // per vertex: // // x:7 // y:7 // z:9 // ao:6 // tex_lerp:3 // // per face: // // tex1:8 // tex2:8 // face:8 // color:8 // Faces: // // Faces use the bottom 3 bits to choose the texgen // mode, and all the bits to choose the normal. // Thus the bottom 3 bits have to be: // e, n, w, s, u, d, u, d // // These use compact names so tables are readable enum { STBVF_e, STBVF_n, STBVF_w, STBVF_s, STBVF_u, STBVF_d, STBVF_eu, STBVF_ed, STBVF_eu_wall, STBVF_nu_wall, STBVF_wu_wall, STBVF_su_wall, STBVF_ne_u, STBVF_ne_d, STBVF_nu, STBVF_nd, STBVF_ed_wall, STBVF_nd_wall, STBVF_wd_wall, STBVF_sd_wall, STBVF_nw_u, STBVF_nw_d, STBVF_wu, STBVF_wd, STBVF_ne_u_cross, STBVF_nw_u_cross, STBVF_sw_u_cross, STBVF_se_u_cross, STBVF_sw_u, STBVF_sw_d, STBVF_su, STBVF_sd, // @TODO we need more than 5 bits to encode the normal to fit the following // so for now we use the right projection but the wrong normal STBVF_se_u = STBVF_su, STBVF_se_d = STBVF_sd, STBVF_count, }; ///////////////////////////////////////////////////////////////////////////// // // tables -- i'd prefer if these were at the end of the file, but: C++ // static float stbvox_default_texgen[2][32][3] = { { { 0, 1,0 }, { 0, 0, 1 }, { 0,-1,0 }, { 0, 0,-1 }, { -1, 0,0 }, { 0, 0, 1 }, { 1, 0,0 }, { 0, 0,-1 }, { 0,-1,0 }, { 0, 0, 1 }, { 0, 1,0 }, { 0, 0,-1 }, { 1, 0,0 }, { 0, 0, 1 }, { -1, 0,0 }, { 0, 0,-1 }, { 1, 0,0 }, { 0, 1, 0 }, { -1, 0,0 }, { 0,-1, 0 }, { -1, 0,0 }, { 0,-1, 0 }, { 1, 0,0 }, { 0, 1, 0 }, { 1, 0,0 }, { 0, 1, 0 }, { -1, 0,0 }, { 0,-1, 0 }, { -1, 0,0 }, { 0,-1, 0 }, { 1, 0,0 }, { 0, 1, 0 }, }, { { 0, 0,-1 }, { 0, 1,0 }, { 0, 0, 1 }, { 0,-1,0 }, { 0, 0,-1 }, { -1, 0,0 }, { 0, 0, 1 }, { 1, 0,0 }, { 0, 0,-1 }, { 0,-1,0 }, { 0, 0, 1 }, { 0, 1,0 }, { 0, 0,-1 }, { 1, 0,0 }, { 0, 0, 1 }, { -1, 0,0 }, { 0,-1, 0 }, { 1, 0,0 }, { 0, 1, 0 }, { -1, 0,0 }, { 0, 1, 0 }, { -1, 0,0 }, { 0,-1, 0 }, { 1, 0,0 }, { 0,-1, 0 }, { 1, 0,0 }, { 0, 1, 0 }, { -1, 0,0 }, { 0, 1, 0 }, { -1, 0,0 }, { 0,-1, 0 }, { 1, 0,0 }, }, }; #define STBVOX_RSQRT2 0.7071067811865f #define STBVOX_RSQRT3 0.5773502691896f static float stbvox_default_normals[32][3] = { { 1,0,0 }, // east { 0,1,0 }, // north { -1,0,0 }, // west { 0,-1,0 }, // south { 0,0,1 }, // up { 0,0,-1 }, // down { STBVOX_RSQRT2,0, STBVOX_RSQRT2 }, // east & up { STBVOX_RSQRT2,0, -STBVOX_RSQRT2 }, // east & down { STBVOX_RSQRT2,0, STBVOX_RSQRT2 }, // east & up { 0, STBVOX_RSQRT2, STBVOX_RSQRT2 }, // north & up { -STBVOX_RSQRT2,0, STBVOX_RSQRT2 }, // west & up { 0,-STBVOX_RSQRT2, STBVOX_RSQRT2 }, // south & up { STBVOX_RSQRT3, STBVOX_RSQRT3, STBVOX_RSQRT3 }, // ne & up { STBVOX_RSQRT3, STBVOX_RSQRT3,-STBVOX_RSQRT3 }, // ne & down { 0, STBVOX_RSQRT2, STBVOX_RSQRT2 }, // north & up { 0, STBVOX_RSQRT2, -STBVOX_RSQRT2 }, // north & down { STBVOX_RSQRT2,0, -STBVOX_RSQRT2 }, // east & down { 0, STBVOX_RSQRT2, -STBVOX_RSQRT2 }, // north & down { -STBVOX_RSQRT2,0, -STBVOX_RSQRT2 }, // west & down { 0,-STBVOX_RSQRT2, -STBVOX_RSQRT2 }, // south & down { -STBVOX_RSQRT3, STBVOX_RSQRT3, STBVOX_RSQRT3 }, // NW & up { -STBVOX_RSQRT3, STBVOX_RSQRT3,-STBVOX_RSQRT3 }, // NW & down { -STBVOX_RSQRT2,0, STBVOX_RSQRT2 }, // west & up { -STBVOX_RSQRT2,0, -STBVOX_RSQRT2 }, // west & down { STBVOX_RSQRT3, STBVOX_RSQRT3,STBVOX_RSQRT3 }, // NE & up crossed { -STBVOX_RSQRT3, STBVOX_RSQRT3,STBVOX_RSQRT3 }, // NW & up crossed { -STBVOX_RSQRT3,-STBVOX_RSQRT3,STBVOX_RSQRT3 }, // SW & up crossed { STBVOX_RSQRT3,-STBVOX_RSQRT3,STBVOX_RSQRT3 }, // SE & up crossed { -STBVOX_RSQRT3,-STBVOX_RSQRT3, STBVOX_RSQRT3 }, // SW & up { -STBVOX_RSQRT3,-STBVOX_RSQRT3,-STBVOX_RSQRT3 }, // SW & up { 0,-STBVOX_RSQRT2, STBVOX_RSQRT2 }, // south & up { 0,-STBVOX_RSQRT2, -STBVOX_RSQRT2 }, // south & down }; static float stbvox_default_texscale[128][4] = { {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, {1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0},{1,1,0,0}, }; static unsigned char stbvox_default_palette_compact[64][3] = { { 255,255,255 }, { 238,238,238 }, { 221,221,221 }, { 204,204,204 }, { 187,187,187 }, { 170,170,170 }, { 153,153,153 }, { 136,136,136 }, { 119,119,119 }, { 102,102,102 }, { 85, 85, 85 }, { 68, 68, 68 }, { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }, { 255,240,240 }, { 255,220,220 }, { 255,160,160 }, { 255, 32, 32 }, { 200,120,160 }, { 200, 60,150 }, { 220,100,130 }, { 255, 0,128 }, { 240,240,255 }, { 220,220,255 }, { 160,160,255 }, { 32, 32,255 }, { 120,160,200 }, { 60,150,200 }, { 100,130,220 }, { 0,128,255 }, { 240,255,240 }, { 220,255,220 }, { 160,255,160 }, { 32,255, 32 }, { 160,200,120 }, { 150,200, 60 }, { 130,220,100 }, { 128,255, 0 }, { 255,255,240 }, { 255,255,220 }, { 220,220,180 }, { 255,255, 32 }, { 200,160,120 }, { 200,150, 60 }, { 220,130,100 }, { 255,128, 0 }, { 255,240,255 }, { 255,220,255 }, { 220,180,220 }, { 255, 32,255 }, { 160,120,200 }, { 150, 60,200 }, { 130,100,220 }, { 128, 0,255 }, { 240,255,255 }, { 220,255,255 }, { 180,220,220 }, { 32,255,255 }, { 120,200,160 }, { 60,200,150 }, { 100,220,130 }, { 0,255,128 }, }; static float stbvox_default_ambient[4][4] = { { 0,0,1 ,0 }, // reversed lighting direction { 0.5,0.5,0.5,0 }, // directional color { 0.5,0.5,0.5,0 }, // constant color { 0.5,0.5,0.5,1.0f/1000.0f/1000.0f }, // fog data for simple_fog }; static float stbvox_default_palette[64][4]; static void stbvox_build_default_palette(void) { int i; for (i=0; i < 64; ++i) { stbvox_default_palette[i][0] = stbvox_default_palette_compact[i][0] / 255.0f; stbvox_default_palette[i][1] = stbvox_default_palette_compact[i][1] / 255.0f; stbvox_default_palette[i][2] = stbvox_default_palette_compact[i][2] / 255.0f; stbvox_default_palette[i][3] = 1.0f; } } ////////////////////////////////////////////////////////////////////////////// // // Shaders // #if defined(STBVOX_ICONFIG_OPENGL_3_1_COMPATIBILITY) #define STBVOX_SHADER_VERSION "#version 150 compatibility\n" #elif defined(STBVOX_ICONFIG_OPENGL_3_0) #define STBVOX_SHADER_VERSION "#version 130\n" #elif defined(STBVOX_ICONFIG_GLSL) #define STBVOX_SHADER_VERSION "#version 150\n" #else #define STBVOX_SHADER_VERSION "" #endif static const char *stbvox_vertex_program = { STBVOX_SHADER_VERSION #ifdef STBVOX_ICONFIG_FACE_ATTRIBUTE // NOT TAG_face_sampled "in uvec4 attr_face;\n" #else "uniform usamplerBuffer facearray;\n" #endif #ifdef STBVOX_ICONFIG_FACE_ARRAY_2 "uniform usamplerBuffer facearray2;\n" #endif // vertex input data "in uint attr_vertex;\n" // per-buffer data "uniform vec3 transform[3];\n" // per-frame data "uniform vec4 camera_pos;\n" // 4th value is used for arbitrary hacking // to simplify things, we avoid using more than 256 uniform vectors // in fragment shader to avoid possible 1024 component limit, so // we access this table in the fragment shader. "uniform vec3 normal_table[32];\n" #ifndef STBVOX_CONFIG_OPENGL_MODELVIEW "uniform mat4x4 model_view;\n" #endif // fragment output data "flat out uvec4 facedata;\n" " out vec3 voxelspace_pos;\n" " out vec3 vnormal;\n" " out float texlerp;\n" " out float amb_occ;\n" // @TODO handle the HLSL way to do this "void main()\n" "{\n" #ifdef STBVOX_ICONFIG_FACE_ATTRIBUTE " facedata = attr_face;\n" #else " int faceID = gl_VertexID >> 2;\n" " facedata = texelFetch(facearray, faceID);\n" #endif // extract data for vertex " vec3 offset;\n" " offset.x = float( (attr_vertex ) & 127u );\n" // a[0..6] " offset.y = float( (attr_vertex >> 7u) & 127u );\n" // a[7..13] " offset.z = float( (attr_vertex >> 14u) & 511u );\n" // a[14..22] " amb_occ = float( (attr_vertex >> 23u) & 63u ) / 63.0;\n" // a[23..28] " texlerp = float( (attr_vertex >> 29u) ) / 7.0;\n" // a[29..31] " vnormal = normal_table[(facedata.w>>2u) & 31u];\n" " voxelspace_pos = offset * transform[0];\n" // mesh-to-object scale " vec3 position = voxelspace_pos + transform[1];\n" // mesh-to-object translate #ifdef STBVOX_DEBUG_TEST_NORMALS " if ((facedata.w & 28u) == 16u || (facedata.w & 28u) == 24u)\n" " position += vnormal.xyz * camera_pos.w;\n" #endif #ifndef STBVOX_CONFIG_OPENGL_MODELVIEW " gl_Position = model_view * vec4(position,1.0);\n" #else " gl_Position = gl_ModelViewProjectionMatrix * vec4(position,1.0);\n" #endif "}\n" }; static const char *stbvox_fragment_program = { STBVOX_SHADER_VERSION // rlerp is lerp but with t on the left, like god intended #if defined(STBVOX_ICONFIG_GLSL) "#define rlerp(t,x,y) mix(x,y,t)\n" #elif defined(STBVOX_CONFIG_HLSL) "#define rlerp(t,x,y) lerp(x,y,t)\n" #else #error "need definition of rlerp()" #endif // vertex-shader output data "flat in uvec4 facedata;\n" " in vec3 voxelspace_pos;\n" " in vec3 vnormal;\n" " in float texlerp;\n" " in float amb_occ;\n" // per-buffer data "uniform vec3 transform[3];\n" // per-frame data "uniform vec4 camera_pos;\n" // 4th value is used for arbitrary hacking // probably constant data "uniform vec4 ambient[4];\n" #ifndef STBVOX_ICONFIG_UNTEXTURED // generally constant data "uniform sampler2DArray tex_array[2];\n" #ifdef STBVOX_CONFIG_PREFER_TEXBUFFER "uniform samplerBuffer color_table;\n" "uniform samplerBuffer texscale;\n" "uniform samplerBuffer texgen;\n" #else "uniform vec4 color_table[64];\n" "uniform vec4 texscale[64];\n" // instead of 128, to avoid running out of uniforms "uniform vec3 texgen[64];\n" #endif #endif "out vec4 outcolor;\n" #if defined(STBVOX_CONFIG_LIGHTING) || defined(STBVOX_CONFIG_LIGHTING_SIMPLE) "vec3 compute_lighting(vec3 pos, vec3 norm, vec3 albedo, vec3 ambient);\n" #endif #if defined(STBVOX_CONFIG_FOG) || defined(STBVOX_CONFIG_FOG_SMOOTHSTEP) "vec3 compute_fog(vec3 color, vec3 relative_pos, float fragment_alpha);\n" #endif "void main()\n" "{\n" " vec3 albedo;\n" " float fragment_alpha;\n" #ifndef STBVOX_ICONFIG_UNTEXTURED // unpack the values " uint tex1_id = facedata.x;\n" " uint tex2_id = facedata.y;\n" " uint texprojid = facedata.w & 31u;\n" " uint color_id = facedata.z;\n" #ifndef STBVOX_CONFIG_PREFER_TEXBUFFER // load from uniforms / texture buffers " vec3 texgen_s = texgen[texprojid];\n" " vec3 texgen_t = texgen[texprojid+32u];\n" " float tex1_scale = texscale[tex1_id & 63u].x;\n" " vec4 color = color_table[color_id & 63u];\n" #ifndef STBVOX_CONFIG_DISABLE_TEX2 " vec4 tex2_props = texscale[tex2_id & 63u];\n" #endif #else " vec3 texgen_s = texelFetch(texgen, int(texprojid)).xyz;\n" " vec3 texgen_t = texelFetch(texgen, int(texprojid+32u)).xyz;\n" " float tex1_scale = texelFetch(texscale, int(tex1_id & 127u)).x;\n" " vec4 color = texelFetch(color_table, int(color_id & 63u));\n" #ifndef STBVOX_CONFIG_DISABLE_TEX2 " vec4 tex2_props = texelFetch(texscale, int(tex1_id & 127u));\n" #endif #endif #ifndef STBVOX_CONFIG_DISABLE_TEX2 " float tex2_scale = tex2_props.y;\n" " bool texblend_mode = tex2_props.z != 0.0;\n" #endif " vec2 texcoord;\n" " vec3 texturespace_pos = voxelspace_pos + transform[2].xyz;\n" " texcoord.s = dot(texturespace_pos, texgen_s);\n" " texcoord.t = dot(texturespace_pos, texgen_t);\n" " vec2 texcoord_1 = tex1_scale * texcoord;\n" #ifndef STBVOX_CONFIG_DISABLE_TEX2 " vec2 texcoord_2 = tex2_scale * texcoord;\n" #endif #ifdef STBVOX_CONFIG_TEX1_EDGE_CLAMP " texcoord_1 = texcoord_1 - floor(texcoord_1);\n" " vec4 tex1 = textureGrad(tex_array[0], vec3(texcoord_1, float(tex1_id)), dFdx(tex1_scale*texcoord), dFdy(tex1_scale*texcoord));\n" #else " vec4 tex1 = texture(tex_array[0], vec3(texcoord_1, float(tex1_id)));\n" #endif #ifndef STBVOX_CONFIG_DISABLE_TEX2 #ifdef STBVOX_CONFIG_TEX2_EDGE_CLAMP " texcoord_2 = texcoord_2 - floor(texcoord_2);\n" " vec4 tex2 = textureGrad(tex_array[0], vec3(texcoord_2, float(tex2_id)), dFdx(tex2_scale*texcoord), dFdy(tex2_scale*texcoord));\n" #else " vec4 tex2 = texture(tex_array[1], vec3(texcoord_2, float(tex2_id)));\n" #endif #endif " bool emissive = (color.a > 1.0);\n" " color.a = min(color.a, 1.0);\n" // recolor textures " if ((color_id & 64u) != 0u) tex1.rgba *= color.rgba;\n" " fragment_alpha = tex1.a;\n" #ifndef STBVOX_CONFIG_DISABLE_TEX2 " if ((color_id & 128u) != 0u) tex2.rgba *= color.rgba;\n" #ifdef STBVOX_CONFIG_PREMULTIPLIED_ALPHA " tex2.rgba *= texlerp;\n" #else " tex2.a *= texlerp;\n" #endif " if (texblend_mode)\n" " albedo = tex1.xyz * rlerp(tex2.a, vec3(1.0,1.0,1.0), 2.0*tex2.xyz);\n" " else {\n" #ifdef STBVOX_CONFIG_PREMULTIPLIED_ALPHA " albedo = (1.0-tex2.a)*tex1.xyz + tex2.xyz;\n" #else " albedo = rlerp(tex2.a, tex1.xyz, tex2.xyz);\n" #endif " fragment_alpha = tex1.a*(1-tex2.a)+tex2.a;\n" " }\n" #else " albedo = tex1.xyz;\n" #endif #else // UNTEXTURED " vec4 color;" " color.xyz = vec3(facedata.xyz) / 255.0;\n" " bool emissive = false;\n" " albedo = color.xyz;\n" " fragment_alpha = 1.0;\n" #endif #ifdef STBVOX_ICONFIG_VARYING_VERTEX_NORMALS // currently, there are no modes that trigger this path; idea is that there // could be a couple of bits per vertex to perturb the normal to e.g. get curved look " vec3 normal = normalize(vnormal);\n" #else " vec3 normal = vnormal;\n" #endif " vec3 ambient_color = dot(normal, ambient[0].xyz) * ambient[1].xyz + ambient[2].xyz;\n" " ambient_color = clamp(ambient_color, 0.0, 1.0);" " ambient_color *= amb_occ;\n" " vec3 lit_color;\n" " if (!emissive)\n" #if defined(STBVOX_ICONFIG_LIGHTING) || defined(STBVOX_CONFIG_LIGHTING_SIMPLE) " lit_color = compute_lighting(voxelspace_pos + transform[1], normal, albedo, ambient_color);\n" #else " lit_color = albedo * ambient_color ;\n" #endif " else\n" " lit_color = albedo;\n" #if defined(STBVOX_ICONFIG_FOG) || defined(STBVOX_CONFIG_FOG_SMOOTHSTEP) " vec3 dist = voxelspace_pos + (transform[1] - camera_pos.xyz);\n" " lit_color = compute_fog(lit_color, dist, fragment_alpha);\n" #endif #ifdef STBVOX_CONFIG_UNPREMULTIPLY " vec4 final_color = vec4(lit_color/fragment_alpha, fragment_alpha);\n" #else " vec4 final_color = vec4(lit_color, fragment_alpha);\n" #endif " outcolor = final_color;\n" "}\n" #ifdef STBVOX_CONFIG_LIGHTING_SIMPLE "\n" "uniform vec3 light_source[2];\n" "vec3 compute_lighting(vec3 pos, vec3 norm, vec3 albedo, vec3 ambient)\n" "{\n" " vec3 light_dir = light_source[0] - pos;\n" " float lambert = dot(light_dir, norm) / dot(light_dir, light_dir);\n" " vec3 diffuse = clamp(light_source[1] * clamp(lambert, 0.0, 1.0), 0.0, 1.0);\n" " return (diffuse + ambient) * albedo;\n" "}\n" #endif #ifdef STBVOX_CONFIG_FOG_SMOOTHSTEP "\n" "vec3 compute_fog(vec3 color, vec3 relative_pos, float fragment_alpha)\n" "{\n" " float f = dot(relative_pos,relative_pos)*ambient[3].w;\n" //" f = rlerp(f, -2,1);\n" " f = clamp(f, 0.0, 1.0);\n" " f = 3.0*f*f - 2.0*f*f*f;\n" // smoothstep //" f = f*f;\n" // fade in more smoothly #ifdef STBVOX_CONFIG_PREMULTIPLIED_ALPHA " return rlerp(f, color.xyz, ambient[3].xyz*fragment_alpha);\n" #else " return rlerp(f, color.xyz, ambient[3].xyz);\n" #endif "}\n" #endif }; // still requires full alpha lookups, including tex2 if texblend is enabled static const char *stbvox_fragment_program_alpha_only = { STBVOX_SHADER_VERSION // vertex-shader output data "flat in uvec4 facedata;\n" " in vec3 voxelspace_pos;\n" " in float texlerp;\n" // per-buffer data "uniform vec3 transform[3];\n" #ifndef STBVOX_ICONFIG_UNTEXTURED // generally constant data "uniform sampler2DArray tex_array[2];\n" #ifdef STBVOX_CONFIG_PREFER_TEXBUFFER "uniform samplerBuffer texscale;\n" "uniform samplerBuffer texgen;\n" #else "uniform vec4 texscale[64];\n" // instead of 128, to avoid running out of uniforms "uniform vec3 texgen[64];\n" #endif #endif "out vec4 outcolor;\n" "void main()\n" "{\n" " vec3 albedo;\n" " float fragment_alpha;\n" #ifndef STBVOX_ICONFIG_UNTEXTURED // unpack the values " uint tex1_id = facedata.x;\n" " uint tex2_id = facedata.y;\n" " uint texprojid = facedata.w & 31u;\n" " uint color_id = facedata.z;\n" #ifndef STBVOX_CONFIG_PREFER_TEXBUFFER // load from uniforms / texture buffers " vec3 texgen_s = texgen[texprojid];\n" " vec3 texgen_t = texgen[texprojid+32u];\n" " float tex1_scale = texscale[tex1_id & 63u].x;\n" " vec4 color = color_table[color_id & 63u];\n" " vec4 tex2_props = texscale[tex2_id & 63u];\n" #else " vec3 texgen_s = texelFetch(texgen, int(texprojid)).xyz;\n" " vec3 texgen_t = texelFetch(texgen, int(texprojid+32u)).xyz;\n" " float tex1_scale = texelFetch(texscale, int(tex1_id & 127u)).x;\n" " vec4 color = texelFetch(color_table, int(color_id & 63u));\n" " vec4 tex2_props = texelFetch(texscale, int(tex2_id & 127u));\n" #endif #ifndef STBVOX_CONFIG_DISABLE_TEX2 " float tex2_scale = tex2_props.y;\n" " bool texblend_mode = tex2_props.z &((facedata.w & 128u) != 0u);\n" #endif " color.a = min(color.a, 1.0);\n" " vec2 texcoord;\n" " vec3 texturespace_pos = voxelspace_pos + transform[2].xyz;\n" " texcoord.s = dot(texturespace_pos, texgen_s);\n" " texcoord.t = dot(texturespace_pos, texgen_t);\n" " vec2 texcoord_1 = tex1_scale * texcoord;\n" " vec2 texcoord_2 = tex2_scale * texcoord;\n" #ifdef STBVOX_CONFIG_TEX1_EDGE_CLAMP " texcoord_1 = texcoord_1 - floor(texcoord_1);\n" " vec4 tex1 = textureGrad(tex_array[0], vec3(texcoord_1, float(tex1_id)), dFdx(tex1_scale*texcoord), dFdy(tex1_scale*texcoord));\n" #else " vec4 tex1 = texture(tex_array[0], vec3(texcoord_1, float(tex1_id)));\n" #endif " if ((color_id & 64u) != 0u) tex1.a *= color.a;\n" " fragment_alpha = tex1.a;\n" #ifndef STBVOX_CONFIG_DISABLE_TEX2 " if (!texblend_mode) {\n" #ifdef STBVOX_CONFIG_TEX2_EDGE_CLAMP " texcoord_2 = texcoord_2 - floor(texcoord_2);\n" " vec4 tex2 = textureGrad(tex_array[0], vec3(texcoord_2, float(tex2_id)), dFdx(tex2_scale*texcoord), dFdy(tex2_scale*texcoord));\n" #else " vec4 tex2 = texture(tex_array[1], vec3(texcoord_2, float(tex2_id)));\n" #endif " tex2.a *= texlerp;\n" " if ((color_id & 128u) != 0u) tex2.rgba *= color.a;\n" " fragment_alpha = tex1.a*(1-tex2.a)+tex2.a;\n" "}\n" "\n" #endif #else // UNTEXTURED " fragment_alpha = 1.0;\n" #endif " outcolor = vec4(0.0, 0.0, 0.0, fragment_alpha);\n" "}\n" }; STBVXDEC char *stbvox_get_vertex_shader(void) { return (char *) stbvox_vertex_program; } STBVXDEC char *stbvox_get_fragment_shader(void) { return (char *) stbvox_fragment_program; } STBVXDEC char *stbvox_get_fragment_shader_alpha_only(void) { return (char *) stbvox_fragment_program_alpha_only; } static float stbvox_dummy_transform[3][3]; #ifdef STBVOX_CONFIG_PREFER_TEXBUFFER #define STBVOX_TEXBUF 1 #else #define STBVOX_TEXBUF 0 #endif static stbvox_uniform_info stbvox_uniforms[] = { { STBVOX_UNIFORM_TYPE_sampler , 4, 1, (char*) "facearray" , 0 }, { STBVOX_UNIFORM_TYPE_vec3 , 12, 3, (char*) "transform" , stbvox_dummy_transform[0] }, { STBVOX_UNIFORM_TYPE_sampler , 4, 2, (char*) "tex_array" , 0 }, { STBVOX_UNIFORM_TYPE_vec4 , 16, 128, (char*) "texscale" , stbvox_default_texscale[0] , STBVOX_TEXBUF }, { STBVOX_UNIFORM_TYPE_vec4 , 16, 64, (char*) "color_table" , stbvox_default_palette[0] , STBVOX_TEXBUF }, { STBVOX_UNIFORM_TYPE_vec3 , 12, 32, (char*) "normal_table" , stbvox_default_normals[0] }, { STBVOX_UNIFORM_TYPE_vec3 , 12, 64, (char*) "texgen" , stbvox_default_texgen[0][0], STBVOX_TEXBUF }, { STBVOX_UNIFORM_TYPE_vec4 , 16, 4, (char*) "ambient" , stbvox_default_ambient[0] }, { STBVOX_UNIFORM_TYPE_vec4 , 16, 1, (char*) "camera_pos" , stbvox_dummy_transform[0] }, }; STBVXDEC int stbvox_get_uniform_info(stbvox_uniform_info *info, int uniform) { if (uniform < 0 || uniform >= STBVOX_UNIFORM_count) return 0; *info = stbvox_uniforms[uniform]; return 1; } #define STBVOX_GET_GEO(geom_data) ((geom_data) & 15) typedef struct { unsigned char block:2; unsigned char overlay:2; unsigned char facerot:2; unsigned char ecolor:2; } stbvox_rotate; typedef struct { unsigned char x,y,z; } stbvox_pos; static unsigned char stbvox_rotate_face[6][4] = { { 0,1,2,3 }, { 1,2,3,0 }, { 2,3,0,1 }, { 3,0,1,2 }, { 4,4,4,4 }, { 5,5,5,5 }, }; #define STBVOX_ROTATE(x,r) stbvox_rotate_face[x][r] // (((x)+(r))&3) stbvox_mesh_face stbvox_compute_mesh_face_value(stbvox_mesh_maker *mm, stbvox_rotate rot, int face, int v_off, int normal) { stbvox_mesh_face face_data = { 0 }; stbvox_block_type bt = mm->input.blocktype[v_off]; unsigned char bt_face = STBVOX_ROTATE(face, rot.block); int facerot = rot.facerot; #ifdef STBVOX_ICONFIG_UNTEXTURED if (mm->input.rgb) { face_data.tex1 = mm->input.rgb[v_off].r; face_data.tex2 = mm->input.rgb[v_off].g; face_data.color = mm->input.rgb[v_off].b; face_data.face_info = (normal<<2); return face_data; } #else unsigned char color_face; if (mm->input.color) face_data.color = mm->input.color[v_off]; if (mm->input.block_tex1) face_data.tex1 = mm->input.block_tex1[bt]; else if (mm->input.block_tex1_face) face_data.tex1 = mm->input.block_tex1_face[bt][bt_face]; else face_data.tex1 = bt; if (mm->input.block_tex2) face_data.tex2 = mm->input.block_tex2[bt]; else if (mm->input.block_tex2_face) face_data.tex2 = mm->input.block_tex2_face[bt][bt_face]; if (mm->input.block_color) { unsigned char mcol = mm->input.block_color[bt]; if (mcol) face_data.color = mcol; } else if (mm->input.block_color_face) { unsigned char mcol = mm->input.block_color_face[bt][bt_face]; if (mcol) face_data.color = mcol; } if (face <= STBVOX_FACE_south) { if (mm->input.side_texrot) facerot = mm->input.side_texrot[v_off] >> (2 * face); else if (mm->input.block_side_texrot) facerot = mm->input.block_side_texrot[v_off] >> (2 * bt_face); } if (mm->input.overlay) { int over_face = STBVOX_ROTATE(face, rot.overlay); unsigned char over = mm->input.overlay[v_off]; if (over) { if (mm->input.overlay_tex1) { unsigned char rep1 = mm->input.overlay_tex1[over][over_face]; if (rep1) face_data.tex1 = rep1; } if (mm->input.overlay_tex2) { unsigned char rep2 = mm->input.overlay_tex2[over][over_face]; if (rep2) face_data.tex2 = rep2; } if (mm->input.overlay_color) { unsigned char rep3 = mm->input.overlay_color[over][over_face]; if (rep3) face_data.color = rep3; } if (mm->input.overlay_side_texrot && face <= STBVOX_FACE_south) facerot = mm->input.overlay_side_texrot[over] >> (2*over_face); } } if (mm->input.tex2_for_tex1) face_data.tex2 = mm->input.tex2_for_tex1[face_data.tex1]; if (mm->input.tex2) face_data.tex2 = mm->input.tex2[v_off]; if (mm->input.tex2_replace) { if (mm->input.tex2_facemask[v_off] & (1 << face)) face_data.tex2 = mm->input.tex2_replace[v_off]; } color_face = STBVOX_ROTATE(face, rot.ecolor); if (mm->input.extended_color) { unsigned char ec = mm->input.extended_color[v_off]; if (mm->input.ecolor_facemask[ec] & (1 << color_face)) face_data.color = mm->input.ecolor_color[ec]; } if (mm->input.color2) { if (mm->input.color2_facemask[v_off] & (1 << color_face)) face_data.color = mm->input.color2[v_off]; if (mm->input.color3 && (mm->input.color3_facemask[v_off] & (1 << color_face))) face_data.color = mm->input.color3[v_off]; } #endif face_data.face_info = (normal<<2) + facerot; return face_data; } // these are the types of faces each block can have enum { STBVOX_FT_none , STBVOX_FT_upper , STBVOX_FT_lower , STBVOX_FT_solid , STBVOX_FT_diag_012, STBVOX_FT_diag_023, STBVOX_FT_diag_013, STBVOX_FT_diag_123, STBVOX_FT_force , // can't be covered up, used for internal faces, also hides nothing STBVOX_FT_partial , // only covered by solid, never covers anything else STBVOX_FT_count }; static unsigned char stbvox_face_lerp[6] = { 0,2,0,2,4,4 }; static unsigned char stbvox_vert3_lerp[5] = { 0,3,6,9,12 }; static unsigned char stbvox_vert_lerp_for_face_lerp[4] = { 0, 4, 7, 7 }; static unsigned char stbvox_face3_lerp[6] = { 0,3,6,9,12,14 }; static unsigned char stbvox_vert_lerp_for_simple[4] = { 0,2,5,7 }; static unsigned char stbvox_face3_updown[8] = { 0,2,5,7,0,2,5,7 }; // ignore top bit // vertex offsets for face vertices static unsigned char stbvox_vertex_vector[6][4][3] = { { { 1,0,1 }, { 1,1,1 }, { 1,1,0 }, { 1,0,0 } }, // east { { 1,1,1 }, { 0,1,1 }, { 0,1,0 }, { 1,1,0 } }, // north { { 0,1,1 }, { 0,0,1 }, { 0,0,0 }, { 0,1,0 } }, // west { { 0,0,1 }, { 1,0,1 }, { 1,0,0 }, { 0,0,0 } }, // south { { 0,1,1 }, { 1,1,1 }, { 1,0,1 }, { 0,0,1 } }, // up { { 0,0,0 }, { 1,0,0 }, { 1,1,0 }, { 0,1,0 } }, // down }; // stbvox_vertex_vector, but read coordinates as binary numbers, zyx static unsigned char stbvox_vertex_selector[6][4] = { { 5,7,3,1 }, { 7,6,2,3 }, { 6,4,0,2 }, { 4,5,1,0 }, { 6,7,5,4 }, { 0,1,3,2 }, }; static stbvox_mesh_vertex stbvox_vmesh_delta_normal[6][4] = { { stbvox_vertex_encode(1,0,1,0,0) , stbvox_vertex_encode(1,1,1,0,0) , stbvox_vertex_encode(1,1,0,0,0) , stbvox_vertex_encode(1,0,0,0,0) }, { stbvox_vertex_encode(1,1,1,0,0) , stbvox_vertex_encode(0,1,1,0,0) , stbvox_vertex_encode(0,1,0,0,0) , stbvox_vertex_encode(1,1,0,0,0) }, { stbvox_vertex_encode(0,1,1,0,0) , stbvox_vertex_encode(0,0,1,0,0) , stbvox_vertex_encode(0,0,0,0,0) , stbvox_vertex_encode(0,1,0,0,0) }, { stbvox_vertex_encode(0,0,1,0,0) , stbvox_vertex_encode(1,0,1,0,0) , stbvox_vertex_encode(1,0,0,0,0) , stbvox_vertex_encode(0,0,0,0,0) }, { stbvox_vertex_encode(0,1,1,0,0) , stbvox_vertex_encode(1,1,1,0,0) , stbvox_vertex_encode(1,0,1,0,0) , stbvox_vertex_encode(0,0,1,0,0) }, { stbvox_vertex_encode(0,0,0,0,0) , stbvox_vertex_encode(1,0,0,0,0) , stbvox_vertex_encode(1,1,0,0,0) , stbvox_vertex_encode(0,1,0,0,0) } }; static stbvox_mesh_vertex stbvox_vmesh_pre_vheight[6][4] = { { stbvox_vertex_encode(1,0,0,0,0) , stbvox_vertex_encode(1,1,0,0,0) , stbvox_vertex_encode(1,1,0,0,0) , stbvox_vertex_encode(1,0,0,0,0) }, { stbvox_vertex_encode(1,1,0,0,0) , stbvox_vertex_encode(0,1,0,0,0) , stbvox_vertex_encode(0,1,0,0,0) , stbvox_vertex_encode(1,1,0,0,0) }, { stbvox_vertex_encode(0,1,0,0,0) , stbvox_vertex_encode(0,0,0,0,0) , stbvox_vertex_encode(0,0,0,0,0) , stbvox_vertex_encode(0,1,0,0,0) }, { stbvox_vertex_encode(0,0,0,0,0) , stbvox_vertex_encode(1,0,0,0,0) , stbvox_vertex_encode(1,0,0,0,0) , stbvox_vertex_encode(0,0,0,0,0) }, { stbvox_vertex_encode(0,1,0,0,0) , stbvox_vertex_encode(1,1,0,0,0) , stbvox_vertex_encode(1,0,0,0,0) , stbvox_vertex_encode(0,0,0,0,0) }, { stbvox_vertex_encode(0,0,0,0,0) , stbvox_vertex_encode(1,0,0,0,0) , stbvox_vertex_encode(1,1,0,0,0) , stbvox_vertex_encode(0,1,0,0,0) } }; static stbvox_mesh_vertex stbvox_vmesh_delta_half_z[6][4] = { { stbvox_vertex_encode(1,0,2,0,0) , stbvox_vertex_encode(1,1,2,0,0) , stbvox_vertex_encode(1,1,0,0,0) , stbvox_vertex_encode(1,0,0,0,0) }, { stbvox_vertex_encode(1,1,2,0,0) , stbvox_vertex_encode(0,1,2,0,0) , stbvox_vertex_encode(0,1,0,0,0) , stbvox_vertex_encode(1,1,0,0,0) }, { stbvox_vertex_encode(0,1,2,0,0) , stbvox_vertex_encode(0,0,2,0,0) , stbvox_vertex_encode(0,0,0,0,0) , stbvox_vertex_encode(0,1,0,0,0) }, { stbvox_vertex_encode(0,0,2,0,0) , stbvox_vertex_encode(1,0,2,0,0) , stbvox_vertex_encode(1,0,0,0,0) , stbvox_vertex_encode(0,0,0,0,0) }, { stbvox_vertex_encode(0,1,2,0,0) , stbvox_vertex_encode(1,1,2,0,0) , stbvox_vertex_encode(1,0,2,0,0) , stbvox_vertex_encode(0,0,2,0,0) }, { stbvox_vertex_encode(0,0,0,0,0) , stbvox_vertex_encode(1,0,0,0,0) , stbvox_vertex_encode(1,1,0,0,0) , stbvox_vertex_encode(0,1,0,0,0) } }; static stbvox_mesh_vertex stbvox_vmesh_crossed_pair[6][4] = { { stbvox_vertex_encode(1,0,2,0,0) , stbvox_vertex_encode(0,1,2,0,0) , stbvox_vertex_encode(0,1,0,0,0) , stbvox_vertex_encode(1,0,0,0,0) }, { stbvox_vertex_encode(1,1,2,0,0) , stbvox_vertex_encode(0,0,2,0,0) , stbvox_vertex_encode(0,0,0,0,0) , stbvox_vertex_encode(1,1,0,0,0) }, { stbvox_vertex_encode(0,1,2,0,0) , stbvox_vertex_encode(1,0,2,0,0) , stbvox_vertex_encode(1,0,0,0,0) , stbvox_vertex_encode(0,1,0,0,0) }, { stbvox_vertex_encode(0,0,2,0,0) , stbvox_vertex_encode(1,1,2,0,0) , stbvox_vertex_encode(1,1,0,0,0) , stbvox_vertex_encode(0,0,0,0,0) }, // not used, so we leave it non-degenerate to make sure it doesn't get gen'd accidentally { stbvox_vertex_encode(0,1,2,0,0) , stbvox_vertex_encode(1,1,2,0,0) , stbvox_vertex_encode(1,0,2,0,0) , stbvox_vertex_encode(0,0,2,0,0) }, { stbvox_vertex_encode(0,0,0,0,0) , stbvox_vertex_encode(1,0,0,0,0) , stbvox_vertex_encode(1,1,0,0,0) , stbvox_vertex_encode(0,1,0,0,0) } }; #define STBVOX_MAX_GEOM 16 #define STBVOX_NUM_ROTATION 4 // this is used to determine if a face is ever generated at all static unsigned char stbvox_hasface[STBVOX_MAX_GEOM][STBVOX_NUM_ROTATION] = { { 0,0,0,0 }, // empty { 0,0,0,0 }, // knockout { 63,63,63,63 }, // solid { 63,63,63,63 }, // transp { 63,63,63,63 }, // slab { 63,63,63,63 }, // slab { 1|2|4|48, 8|1|2|48, 4|8|1|48, 2|4|8|48, }, // floor slopes { 1|2|4|48, 8|1|2|48, 4|8|1|48, 2|4|8|48, }, // ceil slopes { 47,47,47,47 }, // wall-projected diagonal with down face { 31,31,31,31 }, // wall-projected diagonal with up face { 63,63,63,63 }, // crossed-pair has special handling, but avoid early-out { 63,63,63,63 }, // force { 63,63,63,63 }, // vheight { 63,63,63,63 }, // vheight { 63,63,63,63 }, // vheight { 63,63,63,63 }, // vheight }; // this determines which face type above is visible on each side of the geometry static unsigned char stbvox_facetype[STBVOX_GEOM_count][6] = { { 0, }, // STBVOX_GEOM_empty { STBVOX_FT_solid, STBVOX_FT_solid, STBVOX_FT_solid, STBVOX_FT_solid, STBVOX_FT_solid, STBVOX_FT_solid }, // knockout { STBVOX_FT_solid, STBVOX_FT_solid, STBVOX_FT_solid, STBVOX_FT_solid, STBVOX_FT_solid, STBVOX_FT_solid }, // solid { STBVOX_FT_force, STBVOX_FT_force, STBVOX_FT_force, STBVOX_FT_force, STBVOX_FT_force, STBVOX_FT_force }, // transp { STBVOX_FT_upper, STBVOX_FT_upper, STBVOX_FT_upper, STBVOX_FT_upper, STBVOX_FT_solid, STBVOX_FT_force }, { STBVOX_FT_lower, STBVOX_FT_lower, STBVOX_FT_lower, STBVOX_FT_lower, STBVOX_FT_force, STBVOX_FT_solid }, { STBVOX_FT_diag_123, STBVOX_FT_solid, STBVOX_FT_diag_023, STBVOX_FT_none, STBVOX_FT_force, STBVOX_FT_solid }, { STBVOX_FT_diag_012, STBVOX_FT_solid, STBVOX_FT_diag_013, STBVOX_FT_none, STBVOX_FT_solid, STBVOX_FT_force }, { STBVOX_FT_diag_123, STBVOX_FT_solid, STBVOX_FT_diag_023, STBVOX_FT_force, STBVOX_FT_none, STBVOX_FT_solid }, { STBVOX_FT_diag_012, STBVOX_FT_solid, STBVOX_FT_diag_013, STBVOX_FT_force, STBVOX_FT_solid, STBVOX_FT_none }, { STBVOX_FT_force, STBVOX_FT_force, STBVOX_FT_force, STBVOX_FT_force, 0,0 }, // crossed pair { STBVOX_FT_force, STBVOX_FT_force, STBVOX_FT_force, STBVOX_FT_force, STBVOX_FT_force, STBVOX_FT_force }, // GEOM_force { STBVOX_FT_partial,STBVOX_FT_partial,STBVOX_FT_partial,STBVOX_FT_partial, STBVOX_FT_force, STBVOX_FT_solid }, // floor vheight, all neighbors forced { STBVOX_FT_partial,STBVOX_FT_partial,STBVOX_FT_partial,STBVOX_FT_partial, STBVOX_FT_force, STBVOX_FT_solid }, // floor vheight, all neighbors forced { STBVOX_FT_partial,STBVOX_FT_partial,STBVOX_FT_partial,STBVOX_FT_partial, STBVOX_FT_solid, STBVOX_FT_force }, // ceil vheight, all neighbors forced { STBVOX_FT_partial,STBVOX_FT_partial,STBVOX_FT_partial,STBVOX_FT_partial, STBVOX_FT_solid, STBVOX_FT_force }, // ceil vheight, all neighbors forced }; // This table indicates what normal to use for the "up" face of a sloped geom // @TODO this could be done with math given the current arrangement of the enum, but let's not require it static unsigned char stbvox_floor_slope_for_rot[4] = { STBVF_su, STBVF_wu, // @TODO: why is this reversed from what it should be? this is a north-is-up face, so slope should be south&up STBVF_nu, STBVF_eu, }; static unsigned char stbvox_ceil_slope_for_rot[4] = { STBVF_sd, STBVF_ed, STBVF_nd, STBVF_wd, }; // this table indicates whether, for each pair of types above, a face is visible. // each value indicates whether a given type is visible for all neighbor types static unsigned short stbvox_face_visible[STBVOX_FT_count] = { // we encode the table by listing which cases cause *obscuration*, and bitwise inverting that // table is pre-shifted by 5 to save a shift when it's accessed (unsigned short) ((~0x07ff )<<5), // none is completely obscured by everything (unsigned short) ((~((1<output_cur[mesh][0]; int step = mm->output_step[mesh][0]; // allocate a new quad from the mesh vertices[0] = (stbvox_mesh_vertex *) p; p += step; vertices[1] = (stbvox_mesh_vertex *) p; p += step; vertices[2] = (stbvox_mesh_vertex *) p; p += step; vertices[3] = (stbvox_mesh_vertex *) p; p += step; mm->output_cur[mesh][0] = p; // output the face #ifdef STBVOX_ICONFIG_FACE_ATTRIBUTE // write face as interleaved vertex data *(stbvox_mesh_face *) (vertices[0]+1) = face; *(stbvox_mesh_face *) (vertices[1]+1) = face; *(stbvox_mesh_face *) (vertices[2]+1) = face; *(stbvox_mesh_face *) (vertices[3]+1) = face; #else *(stbvox_mesh_face *) mm->output_cur[mesh][1] = face; mm->output_cur[mesh][1] += 4; #endif } void stbvox_make_mesh_for_face(stbvox_mesh_maker *mm, stbvox_rotate rot, int face, int v_off, stbvox_pos pos, stbvox_mesh_vertex vertbase, stbvox_mesh_vertex *face_coord, unsigned char mesh, int normal) { stbvox_mesh_face face_data = stbvox_compute_mesh_face_value(mm,rot,face,v_off, normal); // still need to compute ao & texlerp for each vertex // first compute texlerp into p1 stbvox_mesh_vertex p1[4] = { 0 }; #if defined(STBVOX_CONFIG_DOWN_TEXLERP_PACKED) && defined(STBVOX_CONFIG_UP_TEXLERP_PACKED) #define STBVOX_USE_PACKED(f) ((f) == STBVOX_FACE_up || (f) == STBVOX_FACE_down) #elif defined(STBVOX_CONFIG_UP_TEXLERP_PACKED) #define STBVOX_USE_PACKED(f) ((f) == STBVOX_FACE_up ) #elif defined(STBVOX_CONFIG_DOWN_TEXLERP_PACKED) #define STBVOX_USE_PACKED(f) ( (f) == STBVOX_FACE_down) #endif #if defined(STBVOX_CONFIG_DOWN_TEXLERP_PACKED) || defined(STBVOX_CONFIG_UP_TEXLERP_PACKED) if (STBVOX_USE_PACKED(face)) { if (!mm->input.packed_compact || 0==(mm->input.packed_compact[v_off]&16)) goto set_default; p1[0] = (mm->input.packed_compact[v_off + mm->cube_vertex_offset[face][0]] >> 5); p1[1] = (mm->input.packed_compact[v_off + mm->cube_vertex_offset[face][1]] >> 5); p1[2] = (mm->input.packed_compact[v_off + mm->cube_vertex_offset[face][2]] >> 5); p1[3] = (mm->input.packed_compact[v_off + mm->cube_vertex_offset[face][3]] >> 5); p1[0] = stbvox_vertex_encode(0,0,0,0,p1[0]); p1[1] = stbvox_vertex_encode(0,0,0,0,p1[1]); p1[2] = stbvox_vertex_encode(0,0,0,0,p1[2]); p1[3] = stbvox_vertex_encode(0,0,0,0,p1[3]); goto skip; } #endif if (mm->input.block_texlerp) { stbvox_block_type bt = mm->input.blocktype[v_off]; unsigned char val = mm->input.block_texlerp[bt]; p1[0] = p1[1] = p1[2] = p1[3] = stbvox_vertex_encode(0,0,0,0,val); } else if (mm->input.block_texlerp_face) { stbvox_block_type bt = mm->input.blocktype[v_off]; unsigned char bt_face = STBVOX_ROTATE(face, rot.block); unsigned char val = mm->input.block_texlerp_face[bt][bt_face]; p1[0] = p1[1] = p1[2] = p1[3] = stbvox_vertex_encode(0,0,0,0,val); } else if (mm->input.texlerp_face3) { unsigned char val = (mm->input.texlerp_face3[v_off] >> stbvox_face3_lerp[face]) & 7; if (face >= STBVOX_FACE_up) val = stbvox_face3_updown[val]; p1[0] = p1[1] = p1[2] = p1[3] = stbvox_vertex_encode(0,0,0,0,val); } else if (mm->input.texlerp_simple) { unsigned char val = mm->input.texlerp_simple[v_off]; unsigned char lerp_face = (val >> 2) & 7; if (lerp_face == face) { p1[0] = (mm->input.texlerp_simple[v_off + mm->cube_vertex_offset[face][0]] >> 5) & 7; p1[1] = (mm->input.texlerp_simple[v_off + mm->cube_vertex_offset[face][1]] >> 5) & 7; p1[2] = (mm->input.texlerp_simple[v_off + mm->cube_vertex_offset[face][2]] >> 5) & 7; p1[3] = (mm->input.texlerp_simple[v_off + mm->cube_vertex_offset[face][3]] >> 5) & 7; p1[0] = stbvox_vertex_encode(0,0,0,0,p1[0]); p1[1] = stbvox_vertex_encode(0,0,0,0,p1[1]); p1[2] = stbvox_vertex_encode(0,0,0,0,p1[2]); p1[3] = stbvox_vertex_encode(0,0,0,0,p1[3]); } else { unsigned char base = stbvox_vert_lerp_for_simple[val&3]; p1[0] = p1[1] = p1[2] = p1[3] = stbvox_vertex_encode(0,0,0,0,base); } } else if (mm->input.texlerp) { unsigned char facelerp = (mm->input.texlerp[v_off] >> stbvox_face_lerp[face]) & 3; if (facelerp == STBVOX_TEXLERP_FACE_use_vert) { if (mm->input.texlerp_vert3 && face != STBVOX_FACE_down) { unsigned char shift = stbvox_vert3_lerp[face]; p1[0] = (mm->input.texlerp_vert3[mm->cube_vertex_offset[face][0]] >> shift) & 7; p1[1] = (mm->input.texlerp_vert3[mm->cube_vertex_offset[face][1]] >> shift) & 7; p1[2] = (mm->input.texlerp_vert3[mm->cube_vertex_offset[face][2]] >> shift) & 7; p1[3] = (mm->input.texlerp_vert3[mm->cube_vertex_offset[face][3]] >> shift) & 7; } else { p1[0] = stbvox_vert_lerp_for_simple[mm->input.texlerp[mm->cube_vertex_offset[face][0]]>>6]; p1[1] = stbvox_vert_lerp_for_simple[mm->input.texlerp[mm->cube_vertex_offset[face][1]]>>6]; p1[2] = stbvox_vert_lerp_for_simple[mm->input.texlerp[mm->cube_vertex_offset[face][2]]>>6]; p1[3] = stbvox_vert_lerp_for_simple[mm->input.texlerp[mm->cube_vertex_offset[face][3]]>>6]; } p1[0] = stbvox_vertex_encode(0,0,0,0,p1[0]); p1[1] = stbvox_vertex_encode(0,0,0,0,p1[1]); p1[2] = stbvox_vertex_encode(0,0,0,0,p1[2]); p1[3] = stbvox_vertex_encode(0,0,0,0,p1[3]); } else { p1[0] = p1[1] = p1[2] = p1[3] = stbvox_vertex_encode(0,0,0,0,stbvox_vert_lerp_for_face_lerp[facelerp]); } } else { #if defined(STBVOX_CONFIG_UP_TEXLERP_PACKED) || defined(STBVOX_CONFIG_DOWN_TEXLERP_PACKED) set_default: #endif p1[0] = p1[1] = p1[2] = p1[3] = stbvox_vertex_encode(0,0,0,0,7); // @TODO make this configurable } #if defined(STBVOX_CONFIG_UP_TEXLERP_PACKED) || defined(STBVOX_CONFIG_DOWN_TEXLERP_PACKED) skip: #endif // now compute lighting and store to vertices { stbvox_mesh_vertex *mv[4]; stbvox_get_quad_vertex_pointer(mm, mesh, mv, face_data); if (mm->input.lighting) { // @TODO: lighting at block centers, but not gathered, instead constant-per-face if (mm->input.lighting_at_vertices) { int i; for (i=0; i < 4; ++i) { *mv[i] = vertbase + face_coord[i] + stbvox_vertex_encode(0,0,0,mm->input.lighting[v_off + mm->cube_vertex_offset[face][i]] & 63,0) + p1[i]; } } else { unsigned char *amb = &mm->input.lighting[v_off]; int i,j; #if defined(STBVOX_CONFIG_ROTATION_IN_LIGHTING) || defined(STBVOX_CONFIG_VHEIGHT_IN_LIGHTING) #define STBVOX_GET_LIGHTING(light) ((light) & ~3) #define STBVOX_LIGHTING_ROUNDOFF 8 #else #define STBVOX_GET_LIGHTING(light) (light) #define STBVOX_LIGHTING_ROUNDOFF 2 #endif for (i=0; i < 4; ++i) { // for each vertex, gather from the four neighbor blocks it's facing unsigned char *vamb = &amb[mm->cube_vertex_offset[face][i]]; int total=0; for (j=0; j < 4; ++j) total += STBVOX_GET_LIGHTING(vamb[mm->vertex_gather_offset[face][j]]); *mv[i] = vertbase + face_coord[i] + stbvox_vertex_encode(0,0,0,(total+STBVOX_LIGHTING_ROUNDOFF)>>4,0) + p1[i]; // >> 4 is because: // >> 2 to divide by 4 to get average over 4 samples // >> 2 because input is 8 bits, output is 6 bits } // @TODO: note that gathering baked *lighting* // is different from gathering baked ao; baked ao can count // solid blocks as 0 ao, but baked lighting wants average // of non-blocked--not take average & treat blocked as 0. And // we can't bake the right value into the solid blocks // because they can have different lighting values on // different sides. So we need to actually gather and // then divide by 0..4 (which we can do with a table-driven // multiply, or have an 'if' for the 3 case) } } else { vertbase += stbvox_vertex_encode(0,0,0,63,0); *mv[0] = vertbase + face_coord[0] + p1[0]; *mv[1] = vertbase + face_coord[1] + p1[1]; *mv[2] = vertbase + face_coord[2] + p1[2]; *mv[3] = vertbase + face_coord[3] + p1[3]; } } } // get opposite-facing normal & texgen for opposite face, used to map up-facing vheight data to down-facing data static unsigned char stbvox_reverse_face[STBVF_count] = { STBVF_w, STBVF_s, STBVF_e, STBVF_n, STBVF_d , STBVF_u , STBVF_wd, STBVF_wu, 0, 0, 0, 0, STBVF_sw_d, STBVF_sw_u, STBVF_sd, STBVF_su, 0, 0, 0, 0, STBVF_se_d, STBVF_se_u, STBVF_ed, STBVF_eu, 0, 0, 0, 0, STBVF_ne_d, STBVF_ne_d, STBVF_nd, STBVF_nu }; #ifndef STBVOX_CONFIG_OPTIMIZED_VHEIGHT // render non-planar quads by splitting into two triangles, rendering each as a degenerate quad static void stbvox_make_12_split_mesh_for_face(stbvox_mesh_maker *mm, stbvox_rotate rot, int face, int v_off, stbvox_pos pos, stbvox_mesh_vertex vertbase, stbvox_mesh_vertex *face_coord, unsigned char mesh, unsigned char *ht) { stbvox_mesh_vertex v[4]; unsigned char normal1 = stbvox_face_up_normal_012[ht[2]][ht[1]][ht[0]]; unsigned char normal2 = stbvox_face_up_normal_123[ht[3]][ht[2]][ht[1]]; if (face == STBVOX_FACE_down) { normal1 = stbvox_reverse_face[normal1]; normal2 = stbvox_reverse_face[normal2]; } // the floor side face_coord is stored in order NW,NE,SE,SW, but ht[] is stored SW,SE,NW,NE v[0] = face_coord[2]; v[1] = face_coord[3]; v[2] = face_coord[0]; v[3] = face_coord[2]; stbvox_make_mesh_for_face(mm, rot, face, v_off, pos, vertbase, v, mesh, normal1); v[1] = face_coord[0]; v[2] = face_coord[1]; stbvox_make_mesh_for_face(mm, rot, face, v_off, pos, vertbase, v, mesh, normal2); } static void stbvox_make_03_split_mesh_for_face(stbvox_mesh_maker *mm, stbvox_rotate rot, int face, int v_off, stbvox_pos pos, stbvox_mesh_vertex vertbase, stbvox_mesh_vertex *face_coord, unsigned char mesh, unsigned char *ht) { stbvox_mesh_vertex v[4]; unsigned char normal1 = stbvox_face_up_normal_013[ht[3]][ht[1]][ht[0]]; unsigned char normal2 = stbvox_face_up_normal_023[ht[3]][ht[2]][ht[0]]; if (face == STBVOX_FACE_down) { normal1 = stbvox_reverse_face[normal1]; normal2 = stbvox_reverse_face[normal2]; } v[0] = face_coord[1]; v[1] = face_coord[2]; v[2] = face_coord[3]; v[3] = face_coord[1]; stbvox_make_mesh_for_face(mm, rot, face, v_off, pos, vertbase, v, mesh, normal1); v[1] = face_coord[3]; v[2] = face_coord[0]; stbvox_make_mesh_for_face(mm, rot, face, v_off, pos, vertbase, v, mesh, normal2); // this one is correct! } #endif #ifndef STBVOX_CONFIG_PRECISION_Z #define STBVOX_CONFIG_PRECISION_Z 1 #endif // simple case for mesh generation: we have only solid and empty blocks static void stbvox_make_mesh_for_block(stbvox_mesh_maker *mm, stbvox_pos pos, int v_off, stbvox_mesh_vertex *vmesh) { int ns_off = mm->y_stride_in_bytes; int ew_off = mm->x_stride_in_bytes; unsigned char *blockptr = &mm->input.blocktype[v_off]; stbvox_mesh_vertex basevert = stbvox_vertex_encode(pos.x, pos.y, pos.z << STBVOX_CONFIG_PRECISION_Z , 0,0); stbvox_rotate rot = { 0,0,0,0 }; unsigned char simple_rot = 0; unsigned char mesh = mm->default_mesh; if (mm->input.selector) mesh = mm->input.selector[v_off]; else if (mm->input.block_selector) mesh = mm->input.block_selector[mm->input.blocktype[v_off]]; // check if we're going off the end if (mm->output_cur[mesh][0] + mm->output_size[mesh][0]*6 > mm->output_end[mesh][0]) { mm->full = 1; return; } #ifdef STBVOX_CONFIG_ROTATION_IN_LIGHTING simple_rot = mm->input.lighting[v_off] & 3; #endif if (mm->input.packed_compact) simple_rot = mm->input.packed_compact[v_off] & 3; if (blockptr[ 1]==0) { rot.facerot = simple_rot; stbvox_make_mesh_for_face(mm, rot, STBVOX_FACE_up , v_off, pos, basevert, vmesh+4*STBVOX_FACE_up, mesh, STBVOX_FACE_up); } if (blockptr[-1]==0) { rot.facerot = (-simple_rot) & 3; stbvox_make_mesh_for_face(mm, rot, STBVOX_FACE_down, v_off, pos, basevert, vmesh+4*STBVOX_FACE_down, mesh, STBVOX_FACE_down); } if (mm->input.rotate) { unsigned char val = mm->input.rotate[v_off]; rot.block = (val >> 0) & 3; rot.overlay = (val >> 2) & 3; //rot.tex2 = (val >> 4) & 3; rot.ecolor = (val >> 6) & 3; } else { rot.block = rot.overlay = rot.ecolor = simple_rot; } rot.facerot = 0; if (blockptr[ ns_off]==0) stbvox_make_mesh_for_face(mm, rot, STBVOX_FACE_north, v_off, pos, basevert, vmesh+4*STBVOX_FACE_north, mesh, STBVOX_FACE_north); if (blockptr[-ns_off]==0) stbvox_make_mesh_for_face(mm, rot, STBVOX_FACE_south, v_off, pos, basevert, vmesh+4*STBVOX_FACE_south, mesh, STBVOX_FACE_south); if (blockptr[ ew_off]==0) stbvox_make_mesh_for_face(mm, rot, STBVOX_FACE_east , v_off, pos, basevert, vmesh+4*STBVOX_FACE_east, mesh, STBVOX_FACE_east); if (blockptr[-ew_off]==0) stbvox_make_mesh_for_face(mm, rot, STBVOX_FACE_west , v_off, pos, basevert, vmesh+4*STBVOX_FACE_west, mesh, STBVOX_FACE_west); } // complex case for mesh generation: we have lots of different // block types, and we don't want to generate faces of blocks // if they're hidden by neighbors. // // we use lots of tables to determine this: we have a table // which tells us what face type is generated for each type of // geometry, and then a table that tells us whether that type // is hidden by a neighbor. static void stbvox_make_mesh_for_block_with_geo(stbvox_mesh_maker *mm, stbvox_pos pos, int v_off) { int ns_off = mm->y_stride_in_bytes; int ew_off = mm->x_stride_in_bytes; int visible_faces, visible_base; unsigned char mesh; // first gather the geometry info for this block and all neighbors unsigned char bt, nbt[6]; unsigned char geo, ngeo[6]; unsigned char rot, nrot[6]; bt = mm->input.blocktype[v_off]; nbt[0] = mm->input.blocktype[v_off + ew_off]; nbt[1] = mm->input.blocktype[v_off + ns_off]; nbt[2] = mm->input.blocktype[v_off - ew_off]; nbt[3] = mm->input.blocktype[v_off - ns_off]; nbt[4] = mm->input.blocktype[v_off + 1]; nbt[5] = mm->input.blocktype[v_off - 1]; if (mm->input.geometry) { int i; geo = mm->input.geometry[v_off]; ngeo[0] = mm->input.geometry[v_off + ew_off]; ngeo[1] = mm->input.geometry[v_off + ns_off]; ngeo[2] = mm->input.geometry[v_off - ew_off]; ngeo[3] = mm->input.geometry[v_off - ns_off]; ngeo[4] = mm->input.geometry[v_off + 1]; ngeo[5] = mm->input.geometry[v_off - 1]; rot = (geo >> 4) & 3; geo &= 15; for (i=0; i < 6; ++i) { nrot[i] = (ngeo[i] >> 4) & 3; ngeo[i] &= 15; } } else { int i; assert(mm->input.block_geometry); geo = mm->input.block_geometry[bt]; for (i=0; i < 6; ++i) ngeo[i] = mm->input.block_geometry[nbt[i]]; if (mm->input.selector) { #ifndef STBVOX_CONFIG_ROTATION_IN_LIGHTING if (mm->input.packed_compact == NULL) { rot = (mm->input.selector[v_off ] >> 4) & 3; nrot[0] = (mm->input.selector[v_off + ew_off] >> 4) & 3; nrot[1] = (mm->input.selector[v_off + ns_off] >> 4) & 3; nrot[2] = (mm->input.selector[v_off - ew_off] >> 4) & 3; nrot[3] = (mm->input.selector[v_off - ns_off] >> 4) & 3; nrot[4] = (mm->input.selector[v_off + 1] >> 4) & 3; nrot[5] = (mm->input.selector[v_off - 1] >> 4) & 3; } #endif } else { #ifndef STBVOX_CONFIG_ROTATION_IN_LIGHTING if (mm->input.packed_compact == NULL) { rot = (geo>>4)&3; geo &= 15; for (i=0; i < 6; ++i) { nrot[i] = (ngeo[i]>>4)&3; ngeo[i] &= 15; } } #endif } } #ifndef STBVOX_CONFIG_ROTATION_IN_LIGHTING if (mm->input.packed_compact) { rot = mm->input.packed_compact[rot] & 3; nrot[0] = mm->input.packed_compact[v_off + ew_off] & 3; nrot[1] = mm->input.packed_compact[v_off + ns_off] & 3; nrot[2] = mm->input.packed_compact[v_off - ew_off] & 3; nrot[3] = mm->input.packed_compact[v_off - ns_off] & 3; nrot[4] = mm->input.packed_compact[v_off + 1] & 3; nrot[5] = mm->input.packed_compact[v_off - 1] & 3; } #else rot = mm->input.lighting[v_off] & 3; nrot[0] = (mm->input.lighting[v_off + ew_off]) & 3; nrot[1] = (mm->input.lighting[v_off + ns_off]) & 3; nrot[2] = (mm->input.lighting[v_off - ew_off]) & 3; nrot[3] = (mm->input.lighting[v_off - ns_off]) & 3; nrot[4] = (mm->input.lighting[v_off + 1]) & 3; nrot[5] = (mm->input.lighting[v_off - 1]) & 3; #endif if (geo == STBVOX_GEOM_transp) { // transparency has a special rule: if the blocktype is the same, // and the faces are compatible, then can hide them; otherwise, // force them on // Note that this means we don't support any transparentshapes other // than solid blocks, since detecting them is too complicated. If // you wanted to do something like minecraft water, you probably // should just do that with a separate renderer anyway. (We don't // support transparency sorting so you need to use alpha test // anyway) int i; for (i=0; i < 6; ++i) if (nbt[i] != bt) { nbt[i] = 0; ngeo[i] = STBVOX_GEOM_empty; } else ngeo[i] = STBVOX_GEOM_solid; geo = STBVOX_GEOM_solid; } // now compute the face visibility visible_base = stbvox_hasface[geo][rot]; // @TODO: assert(visible_base != 0); // we should have early-outted earlier in this case visible_faces = 0; // now, for every face that might be visible, check if neighbor hides it if (visible_base & (1 << STBVOX_FACE_east)) { int type = stbvox_facetype[ geo ][(STBVOX_FACE_east+ rot )&3]; int ntype = stbvox_facetype[ngeo[0]][(STBVOX_FACE_west+nrot[0])&3]; visible_faces |= ((stbvox_face_visible[type]) >> (ntype + 5 - STBVOX_FACE_east)) & (1 << STBVOX_FACE_east); } if (visible_base & (1 << STBVOX_FACE_north)) { int type = stbvox_facetype[ geo ][(STBVOX_FACE_north+ rot )&3]; int ntype = stbvox_facetype[ngeo[1]][(STBVOX_FACE_south+nrot[1])&3]; visible_faces |= ((stbvox_face_visible[type]) >> (ntype + 5 - STBVOX_FACE_north)) & (1 << STBVOX_FACE_north); } if (visible_base & (1 << STBVOX_FACE_west)) { int type = stbvox_facetype[ geo ][(STBVOX_FACE_west+ rot )&3]; int ntype = stbvox_facetype[ngeo[2]][(STBVOX_FACE_east+nrot[2])&3]; visible_faces |= ((stbvox_face_visible[type]) >> (ntype + 5 - STBVOX_FACE_west)) & (1 << STBVOX_FACE_west); } if (visible_base & (1 << STBVOX_FACE_south)) { int type = stbvox_facetype[ geo ][(STBVOX_FACE_south+ rot )&3]; int ntype = stbvox_facetype[ngeo[3]][(STBVOX_FACE_north+nrot[3])&3]; visible_faces |= ((stbvox_face_visible[type]) >> (ntype + 5 - STBVOX_FACE_south)) & (1 << STBVOX_FACE_south); } if (visible_base & (1 << STBVOX_FACE_up)) { int type = stbvox_facetype[ geo ][STBVOX_FACE_up]; int ntype = stbvox_facetype[ngeo[4]][STBVOX_FACE_down]; visible_faces |= ((stbvox_face_visible[type]) >> (ntype + 5 - STBVOX_FACE_up)) & (1 << STBVOX_FACE_up); } if (visible_base & (1 << STBVOX_FACE_down)) { int type = stbvox_facetype[ geo ][STBVOX_FACE_down]; int ntype = stbvox_facetype[ngeo[5]][STBVOX_FACE_up]; visible_faces |= ((stbvox_face_visible[type]) >> (ntype + 5 - STBVOX_FACE_down)) & (1 << STBVOX_FACE_down); } if (geo == STBVOX_GEOM_force) geo = STBVOX_GEOM_solid; assert((geo == STBVOX_GEOM_crossed_pair) ? (visible_faces == 15) : 1); // now we finally know for sure which faces are getting generated if (visible_faces == 0) return; mesh = mm->default_mesh; if (mm->input.selector) mesh = mm->input.selector[v_off]; else if (mm->input.block_selector) mesh = mm->input.block_selector[bt]; if (geo <= STBVOX_GEOM_ceil_slope_north_is_bottom) { // this is the simple case, we can just use regular block gen with special vmesh calculated with vheight stbvox_mesh_vertex basevert; stbvox_mesh_vertex vmesh[6][4]; stbvox_rotate rotate = { 0,0,0,0 }; unsigned char simple_rot = rot; int i; // we only need to do this for the displayed faces, but it's easier // to just do it up front; @OPTIMIZE check if it's faster to do it // for visible faces only for (i=0; i < 6*4; ++i) { int vert = stbvox_vertex_selector[0][i]; vert = stbvox_rotate_vertex[vert][rot]; vmesh[0][i] = stbvox_vmesh_pre_vheight[0][i] + stbvox_geometry_vheight[geo][vert]; } basevert = stbvox_vertex_encode(pos.x, pos.y, pos.z << STBVOX_CONFIG_PRECISION_Z, 0,0); if (mm->input.selector) { mesh = mm->input.selector[v_off]; } else if (mm->input.block_selector) mesh = mm->input.block_selector[bt]; // check if we're going off the end if (mm->output_cur[mesh][0] + mm->output_size[mesh][0]*6 > mm->output_end[mesh][0]) { mm->full = 1; return; } if (geo >= STBVOX_GEOM_floor_slope_north_is_top) { if (visible_faces & (1 << STBVOX_FACE_up)) { int normal = geo == STBVOX_GEOM_floor_slope_north_is_top ? stbvox_floor_slope_for_rot[simple_rot] : STBVOX_FACE_up; rotate.facerot = simple_rot; stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_up , v_off, pos, basevert, vmesh[STBVOX_FACE_up], mesh, normal); } if (visible_faces & (1 << STBVOX_FACE_down)) { int normal = geo == STBVOX_GEOM_ceil_slope_north_is_bottom ? stbvox_ceil_slope_for_rot[simple_rot] : STBVOX_FACE_down; rotate.facerot = (-rotate.facerot) & 3; stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_down, v_off, pos, basevert, vmesh[STBVOX_FACE_down], mesh, normal); } } else { if (visible_faces & (1 << STBVOX_FACE_up)) { rotate.facerot = simple_rot; stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_up , v_off, pos, basevert, vmesh[STBVOX_FACE_up], mesh, STBVOX_FACE_up); } if (visible_faces & (1 << STBVOX_FACE_down)) { rotate.facerot = (-rotate.facerot) & 3; stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_down, v_off, pos, basevert, vmesh[STBVOX_FACE_down], mesh, STBVOX_FACE_down); } } if (mm->input.rotate) { unsigned char val = mm->input.rotate[v_off]; rotate.block = (val >> 0) & 3; rotate.overlay = (val >> 2) & 3; //rotate.tex2 = (val >> 4) & 3; rotate.ecolor = (val >> 6) & 3; } else { rotate.block = rotate.overlay = rotate.ecolor = simple_rot; } rotate.facerot = 0; if (visible_faces & (1 << STBVOX_FACE_north)) stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_north, v_off, pos, basevert, vmesh[STBVOX_FACE_north], mesh, STBVOX_FACE_north); if (visible_faces & (1 << STBVOX_FACE_south)) stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_south, v_off, pos, basevert, vmesh[STBVOX_FACE_south], mesh, STBVOX_FACE_south); if (visible_faces & (1 << STBVOX_FACE_east)) stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_east , v_off, pos, basevert, vmesh[STBVOX_FACE_east ], mesh, STBVOX_FACE_east); if (visible_faces & (1 << STBVOX_FACE_west)) stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_west , v_off, pos, basevert, vmesh[STBVOX_FACE_west ], mesh, STBVOX_FACE_west); } if (geo >= STBVOX_GEOM_floor_vheight_03) { // this case can also be generated with regular block gen with special vmesh, // except: // if we want to generate middle diagonal for 'weird' blocks // it's more complicated to detect neighbor matchups stbvox_mesh_vertex vmesh[6][4]; stbvox_mesh_vertex cube[8]; stbvox_mesh_vertex basevert; stbvox_rotate rotate = { 0,0,0,0 }; unsigned char simple_rot = rot; unsigned char ht[4]; int extreme; // extract the heights #ifdef STBVOX_CONFIG_VHEIGHT_IN_LIGHTING ht[0] = mm->input.lighting[v_off ] & 3; ht[1] = mm->input.lighting[v_off+ew_off ] & 3; ht[2] = mm->input.lighting[v_off +ns_off] & 3; ht[3] = mm->input.lighting[v_off+ew_off+ns_off] & 3; #else if (mm->input.vheight) { unsigned char v = mm->input.vheight[v_off]; ht[0] = (v >> 0) & 3; ht[1] = (v >> 2) & 3; ht[2] = (v >> 4) & 3; ht[3] = (v >> 6) & 3; } else if (mm->input.block_vheight) { unsigned char v = mm->input.block_vheight[bt]; unsigned char raw[4]; int i; raw[0] = (v >> 0) & 3; raw[1] = (v >> 2) & 3; raw[2] = (v >> 4) & 3; raw[3] = (v >> 6) & 3; for (i=0; i < 4; ++i) ht[i] = raw[stbvox_rotate_vertex[i][rot]]; } else if (mm->input.packed_compact) { ht[0] = (mm->input.packed_compact[v_off ] >> 2) & 3; ht[1] = (mm->input.packed_compact[v_off+ew_off ] >> 2) & 3; ht[2] = (mm->input.packed_compact[v_off +ns_off] >> 2) & 3; ht[3] = (mm->input.packed_compact[v_off+ew_off+ns_off] >> 2) & 3; } else if (mm->input.geometry) { ht[0] = mm->input.geometry[v_off ] >> 6; ht[1] = mm->input.geometry[v_off+ew_off ] >> 6; ht[2] = mm->input.geometry[v_off +ns_off] >> 6; ht[3] = mm->input.geometry[v_off+ew_off+ns_off] >> 6; } else { assert(0); } #endif // flag whether any sides go off the top of the block, which means // our visible_faces test was wrong extreme = (ht[0] == 3 || ht[1] == 3 || ht[2] == 3 || ht[3] == 3); if (geo >= STBVOX_GEOM_ceil_vheight_03) { cube[0] = stbvox_vertex_encode(0,0,ht[0],0,0); cube[1] = stbvox_vertex_encode(0,0,ht[1],0,0); cube[2] = stbvox_vertex_encode(0,0,ht[2],0,0); cube[3] = stbvox_vertex_encode(0,0,ht[3],0,0); cube[4] = stbvox_vertex_encode(0,0,2,0,0); cube[5] = stbvox_vertex_encode(0,0,2,0,0); cube[6] = stbvox_vertex_encode(0,0,2,0,0); cube[7] = stbvox_vertex_encode(0,0,2,0,0); } else { cube[0] = stbvox_vertex_encode(0,0,0,0,0); cube[1] = stbvox_vertex_encode(0,0,0,0,0); cube[2] = stbvox_vertex_encode(0,0,0,0,0); cube[3] = stbvox_vertex_encode(0,0,0,0,0); cube[4] = stbvox_vertex_encode(0,0,ht[0],0,0); cube[5] = stbvox_vertex_encode(0,0,ht[1],0,0); cube[6] = stbvox_vertex_encode(0,0,ht[2],0,0); cube[7] = stbvox_vertex_encode(0,0,ht[3],0,0); } if (!mm->input.vheight && mm->input.block_vheight) { // @TODO: support block vheight here, I've forgotten what needs to be done specially } // build vertex mesh { int i; for (i=0; i < 6*4; ++i) { int vert = stbvox_vertex_selector[0][i]; vmesh[0][i] = stbvox_vmesh_pre_vheight[0][i] + cube[vert]; } } basevert = stbvox_vertex_encode(pos.x, pos.y, pos.z << STBVOX_CONFIG_PRECISION_Z, 0,0); // check if we're going off the end if (mm->output_cur[mesh][0] + mm->output_size[mesh][0]*6 > mm->output_end[mesh][0]) { mm->full = 1; return; } // @TODO generate split faces if (visible_faces & (1 << STBVOX_FACE_up)) { if (geo >= STBVOX_GEOM_ceil_vheight_03) // flat stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_up , v_off, pos, basevert, vmesh[STBVOX_FACE_up], mesh, STBVOX_FACE_up); else { #ifndef STBVOX_CONFIG_OPTIMIZED_VHEIGHT // check if it's non-planar if (cube[5] + cube[6] != cube[4] + cube[7]) { // not planar, split along diagonal and make degenerate quads if (geo == STBVOX_GEOM_floor_vheight_03) stbvox_make_03_split_mesh_for_face(mm, rotate, STBVOX_FACE_up, v_off, pos, basevert, vmesh[STBVOX_FACE_up], mesh, ht); else stbvox_make_12_split_mesh_for_face(mm, rotate, STBVOX_FACE_up, v_off, pos, basevert, vmesh[STBVOX_FACE_up], mesh, ht); } else stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_up , v_off, pos, basevert, vmesh[STBVOX_FACE_up], mesh, stbvox_planar_face_up_normal[ht[2]][ht[1]][ht[0]]); #else stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_up , v_off, pos, basevert, vmesh[STBVOX_FACE_up], mesh, stbvox_optimized_face_up_normal[ht[3]][ht[2]][ht[1]][ht[0]]); #endif } } if (visible_faces & (1 << STBVOX_FACE_down)) { if (geo < STBVOX_GEOM_ceil_vheight_03) // flat stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_down, v_off, pos, basevert, vmesh[STBVOX_FACE_down], mesh, STBVOX_FACE_down); else { #ifndef STBVOX_CONFIG_OPTIMIZED_VHEIGHT // check if it's non-planar if (cube[1] + cube[2] != cube[0] + cube[3]) { // not planar, split along diagonal and make degenerate quads if (geo == STBVOX_GEOM_ceil_vheight_03) stbvox_make_03_split_mesh_for_face(mm, rotate, STBVOX_FACE_down, v_off, pos, basevert, vmesh[STBVOX_FACE_down], mesh, ht); else stbvox_make_12_split_mesh_for_face(mm, rotate, STBVOX_FACE_down, v_off, pos, basevert, vmesh[STBVOX_FACE_down], mesh, ht); } else stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_down, v_off, pos, basevert, vmesh[STBVOX_FACE_down], mesh, stbvox_reverse_face[stbvox_planar_face_up_normal[ht[2]][ht[1]][ht[0]]]); #else stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_down, v_off, pos, basevert, vmesh[STBVOX_FACE_down], mesh, stbvox_reverse_face[stbvox_optimized_face_up_normal[ht[3]][ht[2]][ht[1]][ht[0]]]); #endif } } if (mm->input.rotate) { unsigned char val = mm->input.rotate[v_off]; rotate.block = (val >> 0) & 3; rotate.overlay = (val >> 2) & 3; //rotate.tex2 = (val >> 4) & 3; rotate.ecolor = (val >> 6) & 3; } else if (mm->input.selector) { rotate.block = rotate.overlay = rotate.ecolor = simple_rot; } if ((visible_faces & (1 << STBVOX_FACE_north)) || (extreme && (ht[2] == 3 || ht[3] == 3))) stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_north, v_off, pos, basevert, vmesh[STBVOX_FACE_north], mesh, STBVOX_FACE_north); if ((visible_faces & (1 << STBVOX_FACE_south)) || (extreme && (ht[0] == 3 || ht[1] == 3))) stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_south, v_off, pos, basevert, vmesh[STBVOX_FACE_south], mesh, STBVOX_FACE_south); if ((visible_faces & (1 << STBVOX_FACE_east)) || (extreme && (ht[1] == 3 || ht[3] == 3))) stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_east , v_off, pos, basevert, vmesh[STBVOX_FACE_east ], mesh, STBVOX_FACE_east); if ((visible_faces & (1 << STBVOX_FACE_west)) || (extreme && (ht[0] == 3 || ht[2] == 3))) stbvox_make_mesh_for_face(mm, rotate, STBVOX_FACE_west , v_off, pos, basevert, vmesh[STBVOX_FACE_west ], mesh, STBVOX_FACE_west); } if (geo == STBVOX_GEOM_crossed_pair) { // this can be generated with a special vmesh stbvox_mesh_vertex basevert = stbvox_vertex_encode(pos.x, pos.y, pos.z << STBVOX_CONFIG_PRECISION_Z , 0,0); unsigned char simple_rot=0; stbvox_rotate rot = { 0,0,0,0 }; unsigned char mesh = mm->default_mesh; if (mm->input.selector) { mesh = mm->input.selector[v_off]; simple_rot = mesh >> 4; mesh &= 15; } if (mm->input.block_selector) { mesh = mm->input.block_selector[bt]; } // check if we're going off the end if (mm->output_cur[mesh][0] + mm->output_size[mesh][0]*4 > mm->output_end[mesh][0]) { mm->full = 1; return; } if (mm->input.rotate) { unsigned char val = mm->input.rotate[v_off]; rot.block = (val >> 0) & 3; rot.overlay = (val >> 2) & 3; //rot.tex2 = (val >> 4) & 3; rot.ecolor = (val >> 6) & 3; } else if (mm->input.selector) { rot.block = rot.overlay = rot.ecolor = simple_rot; } rot.facerot = 0; stbvox_make_mesh_for_face(mm, rot, STBVOX_FACE_north, v_off, pos, basevert, stbvox_vmesh_crossed_pair[STBVOX_FACE_north], mesh, STBVF_ne_u_cross); stbvox_make_mesh_for_face(mm, rot, STBVOX_FACE_south, v_off, pos, basevert, stbvox_vmesh_crossed_pair[STBVOX_FACE_south], mesh, STBVF_sw_u_cross); stbvox_make_mesh_for_face(mm, rot, STBVOX_FACE_east , v_off, pos, basevert, stbvox_vmesh_crossed_pair[STBVOX_FACE_east ], mesh, STBVF_se_u_cross); stbvox_make_mesh_for_face(mm, rot, STBVOX_FACE_west , v_off, pos, basevert, stbvox_vmesh_crossed_pair[STBVOX_FACE_west ], mesh, STBVF_nw_u_cross); } // @TODO // STBVOX_GEOM_floor_slope_north_is_top_as_wall, // STBVOX_GEOM_ceil_slope_north_is_bottom_as_wall, } static void stbvox_make_mesh_for_column(stbvox_mesh_maker *mm, int x, int y, int z0) { stbvox_pos pos; int v_off = x * mm->x_stride_in_bytes + y * mm->y_stride_in_bytes; int ns_off = mm->y_stride_in_bytes; int ew_off = mm->x_stride_in_bytes; pos.x = x; pos.y = y; pos.z = 0; if (mm->input.geometry) { unsigned char *bt = mm->input.blocktype + v_off; unsigned char *geo = mm->input.geometry + v_off; int z; for (z=z0; z < mm->z1; ++z) { if (bt[z] && ( !bt[z+ns_off] || !STBVOX_GET_GEO(geo[z+ns_off]) || !bt[z-ns_off] || !STBVOX_GET_GEO(geo[z-ns_off]) || !bt[z+ew_off] || !STBVOX_GET_GEO(geo[z+ew_off]) || !bt[z-ew_off] || !STBVOX_GET_GEO(geo[z-ew_off]) || !bt[z-1] || !STBVOX_GET_GEO(geo[z-1]) || !bt[z+1] || !STBVOX_GET_GEO(geo[z+1]))) { // TODO check up and down pos.z = z; stbvox_make_mesh_for_block_with_geo(mm, pos, v_off+z); if (mm->full) { mm->cur_z = z; return; } } } } else if (mm->input.block_geometry) { int z; unsigned char *bt = mm->input.blocktype + v_off; unsigned char *geo = mm->input.block_geometry; for (z=z0; z < mm->z1; ++z) { if (bt[z] && ( geo[bt[z+ns_off]] != STBVOX_GEOM_solid || geo[bt[z-ns_off]] != STBVOX_GEOM_solid || geo[bt[z+ew_off]] != STBVOX_GEOM_solid || geo[bt[z-ew_off]] != STBVOX_GEOM_solid || geo[bt[z-1]] != STBVOX_GEOM_solid || geo[bt[z+1]] != STBVOX_GEOM_solid)) { pos.z = z; stbvox_make_mesh_for_block_with_geo(mm, pos, v_off+z); if (mm->full) { mm->cur_z = z; return; } } } } else { unsigned char *bt = mm->input.blocktype + v_off; int z; #if STBVOX_CONFIG_PRECISION_Z == 1 stbvox_mesh_vertex *vmesh = stbvox_vmesh_delta_half_z[0]; #else stbvox_mesh_vertex *vmesh = stbvox_vmesh_delta_normal[0]; #endif for (z=z0; z < mm->z1; ++z) { // if it's solid and at least one neighbor isn't solid if (bt[z] && (!bt[z+ns_off] || !bt[z-ns_off] || !bt[z+ew_off] || !bt[z-ew_off] || !bt[z-1] || !bt[z+1])) { pos.z = z; stbvox_make_mesh_for_block(mm, pos, v_off+z, vmesh); if (mm->full) { mm->cur_z = z; return; } } } } } static void stbvox_bring_up_to_date(stbvox_mesh_maker *mm) { if (mm->config_dirty) { int i; #ifdef STBVOX_ICONFIG_FACE_ATTRIBUTE mm->num_mesh_slots = 1; for (i=0; i < STBVOX_MAX_MESHES; ++i) { mm->output_size[i][0] = 32; mm->output_step[i][0] = 8; } #else mm->num_mesh_slots = 2; for (i=0; i < STBVOX_MAX_MESHES; ++i) { mm->output_size[i][0] = 16; mm->output_step[i][0] = 4; mm->output_size[i][1] = 4; mm->output_step[i][1] = 4; } #endif mm->config_dirty = 0; } } int stbvox_make_mesh(stbvox_mesh_maker *mm) { int x,y; stbvox_bring_up_to_date(mm); mm->full = 0; if (mm->cur_x > mm->x0 || mm->cur_y > mm->y0 || mm->cur_z > mm->z0) { stbvox_make_mesh_for_column(mm, mm->cur_x, mm->cur_y, mm->cur_z); if (mm->full) return 0; ++mm->cur_y; while (mm->cur_y < mm->y1 && !mm->full) { stbvox_make_mesh_for_column(mm, mm->cur_x, mm->cur_y, mm->z0); if (mm->full) return 0; ++mm->cur_y; } ++mm->cur_x; } for (x=mm->cur_x; x < mm->x1; ++x) { for (y=mm->y0; y < mm->y1; ++y) { stbvox_make_mesh_for_column(mm, x, y, mm->z0); if (mm->full) { mm->cur_x = x; mm->cur_y = y; return 0; } } } return 1; } void stbvox_init_mesh_maker(stbvox_mesh_maker *mm) { memset(mm, 0, sizeof(*mm)); stbvox_build_default_palette(); mm->config_dirty = 1; mm->default_mesh = 0; } int stbvox_get_buffer_count(stbvox_mesh_maker *mm) { stbvox_bring_up_to_date(mm); return mm->num_mesh_slots; } int stbvox_get_buffer_size_per_quad(stbvox_mesh_maker *mm, int n) { return mm->output_size[0][n]; } void stbvox_reset_buffers(stbvox_mesh_maker *mm) { int i; for (i=0; i < STBVOX_MAX_MESHES*STBVOX_MAX_MESH_SLOTS; ++i) { mm->output_cur[0][i] = 0; mm->output_buffer[0][i] = 0; } } void stbvox_set_buffer(stbvox_mesh_maker *mm, int mesh, int slot, void *buffer, size_t len) { int i; stbvox_bring_up_to_date(mm); mm->output_buffer[mesh][slot] = (char *) buffer; mm->output_cur [mesh][slot] = (char *) buffer; mm->output_len [mesh][slot] = len; mm->output_end [mesh][slot] = (char *) buffer + len; for (i=0; i < STBVOX_MAX_MESH_SLOTS; ++i) { if (mm->output_buffer[mesh][i]) { assert(mm->output_len[mesh][i] / mm->output_size[mesh][i] == mm->output_len[mesh][slot] / mm->output_size[mesh][slot]); } } } void stbvox_set_default_mesh(stbvox_mesh_maker *mm, int mesh) { mm->default_mesh = mesh; } int stbvox_get_quad_count(stbvox_mesh_maker *mm, int mesh) { return (mm->output_cur[mesh][0] - mm->output_buffer[mesh][0]) / mm->output_size[mesh][0]; } stbvox_input_description *stbvox_get_input_description(stbvox_mesh_maker *mm) { return &mm->input; } void stbvox_set_input_range(stbvox_mesh_maker *mm, int x0, int y0, int z0, int x1, int y1, int z1) { mm->x0 = x0; mm->y0 = y0; mm->z0 = z0; mm->x1 = x1; mm->y1 = y1; mm->z1 = z1; mm->cur_x = x0; mm->cur_y = y0; mm->cur_z = z0; // @TODO validate that this range is representable in this mode } void stbvox_get_transform(stbvox_mesh_maker *mm, float transform[3][3]) { // scale transform[0][0] = 1.0; transform[0][1] = 1.0; #if STBVOX_CONFIG_PRECISION_Z==1 transform[0][2] = 0.5f; #else transform[0][2] = 1.0f; #endif // translation transform[1][0] = (float) (mm->pos_x); transform[1][1] = (float) (mm->pos_y); transform[1][2] = (float) (mm->pos_z); // texture coordinate projection translation transform[2][0] = (float) (mm->pos_x & 255); // @TODO depends on max texture scale transform[2][1] = (float) (mm->pos_y & 255); transform[2][2] = (float) (mm->pos_z & 255); } void stbvox_get_bounds(stbvox_mesh_maker *mm, float bounds[2][3]) { bounds[0][0] = (float) (mm->pos_x + mm->x0); bounds[0][1] = (float) (mm->pos_y + mm->y0); bounds[0][2] = (float) (mm->pos_z + mm->z0); bounds[1][0] = (float) (mm->pos_x + mm->x1); bounds[1][1] = (float) (mm->pos_y + mm->y1); bounds[1][2] = (float) (mm->pos_z + mm->z1); } void stbvox_set_mesh_coordinates(stbvox_mesh_maker *mm, int x, int y, int z) { mm->pos_x = x; mm->pos_y = y; mm->pos_z = z; } void stbvox_set_input_stride(stbvox_mesh_maker *mm, int x_stride_in_bytes, int y_stride_in_bytes) { int f,v; mm->x_stride_in_bytes = x_stride_in_bytes; mm->y_stride_in_bytes = y_stride_in_bytes; for (f=0; f < 6; ++f) { for (v=0; v < 4; ++v) { mm->cube_vertex_offset[f][v] = stbvox_vertex_vector[f][v][0] * mm->x_stride_in_bytes + stbvox_vertex_vector[f][v][1] * mm->y_stride_in_bytes + stbvox_vertex_vector[f][v][2] ; mm->vertex_gather_offset[f][v] = (stbvox_vertex_vector[f][v][0]-1) * mm->x_stride_in_bytes + (stbvox_vertex_vector[f][v][1]-1) * mm->y_stride_in_bytes + (stbvox_vertex_vector[f][v][2]-1) ; } } } ///////////////////////////////////////////////////////////////////////////// // // offline computation of tables // #if 0 // compute optimized vheight table static char *normal_names[32] = { 0,0,0,0,"u ",0, "eu ",0, 0,0,0,0,"ne_u",0, "nu ",0, 0,0,0,0,"nw_u",0, "wu ",0, 0,0,0,0,"sw_u",0, "su ",0, }; static char *find_best_normal(float x, float y, float z) { int best_slot = 4; float best_dot = 0; int i; for (i=0; i < 32; ++i) { if (normal_names[i]) { float dot = x * stbvox_default_normals[i][0] + y * stbvox_default_normals[i][1] + z * stbvox_default_normals[i][2]; if (dot > best_dot) { best_dot = dot; best_slot = i; } } } return normal_names[best_slot]; } int main(int argc, char **argv) { int sw,se,nw,ne; for (ne=0; ne < 4; ++ne) { for (nw=0; nw < 4; ++nw) { for (se=0; se < 4; ++se) { printf(" { "); for (sw=0; sw < 4; ++sw) { float x = (float) (nw + sw - ne - se); float y = (float) (sw + se - nw - ne); float z = 2; printf("STBVF_%s, ", find_best_normal(x,y,z)); } printf("},\n"); } } } return 0; } #endif // @TODO // // - test API for texture rotation on side faces // - API for texture rotation on top & bottom // - better culling of vheight faces with vheight neighbors // - better culling of non-vheight faces with vheight neighbors // - gather vertex lighting from slopes correctly // - better support texture edge_clamp: currently if you fall // exactly on 1.0 you get wrapped incorrectly; this is rare, but // can avoid: compute texcoords in vertex shader, offset towards // center before modding, need 2 bits per vertex to know offset direction) // - other mesh modes (10,6,4-byte quads) // // // With TexBuffer for the fixed vertex data, we can actually do // minecrafty non-blocks like stairs -- we still probably only // want 256 or so, so we can't do the equivalent of all the vheight // combos, but that's ok. The 256 includes baked rotations, but only // some of them need it, and lots of block types share some faces. // // mode 5 (6 bytes): mode 6 (6 bytes) // x:7 x:6 // y:7 y:6 // z:6 z:6 // tex1:8 tex1:8 // tex2:8 tex2:7 // color:8 color:8 // face:4 face:7 // // // side faces (all x4) top&bottom faces (2x) internal faces (1x) // 1 regular 1 regular // 2 slabs 2 // 8 stairs 4 stairs 16 // 4 diag side 8 // 4 upper diag side 8 // 4 lower diag side 8 // 4 crossed pairs // // 23*4 + 5*4 + 46 // == 92 + 20 + 46 = 158 // // Must drop 30 of them to fit in 7 bits: // ceiling half diagonals: 16+8 = 24 // Need to get rid of 6 more. // ceiling diagonals: 8+4 = 12 // This brings it to 122, so can add a crossed-pair variant. // (diagonal and non-diagonal, or randomly offset) // Or carpet, which would be 5 more. // // // Mode 4 (10 bytes): // v: z:2,light:6 // f: x:6,y:6,z:7, t1:8,t2:8,c:8,f:5 // // Mode ? (10 bytes) // v: xyz:5 (27 values), light:3 // f: x:7,y:7,z:6, t1:8,t2:8,c:8,f:4 // (v: x:2,y:2,z:2,light:2) #endif // STB_VOXEL_RENDER_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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_vorbis.c0000600000175000001440000055567014003056224016750 0ustar rakusers// Ogg Vorbis audio decoder - v1.11 - public domain // http://nothings.org/stb_vorbis/ // // Original version written by Sean Barrett in 2007. // // Originally sponsored by RAD Game Tools. Seeking sponsored // by Phillip Bennefall, Marc Andersen, Aaron Baker, Elias Software, // Aras Pranckevicius, and Sean Barrett. // // LICENSE // // See end of file for license information. // // Limitations: // // - floor 0 not supported (used in old ogg vorbis files pre-2004) // - lossless sample-truncation at beginning ignored // - cannot concatenate multiple vorbis streams // - sample positions are 32-bit, limiting seekable 192Khz // files to around 6 hours (Ogg supports 64-bit) // // Feature contributors: // Dougall Johnson (sample-exact seeking) // // Bugfix/warning contributors: // Terje Mathisen Niklas Frykholm Andy Hill // Casey Muratori John Bolton Gargaj // Laurent Gomila Marc LeBlanc Ronny Chevalier // Bernhard Wodo Evan Balster alxprd@github // Tom Beaumont Ingo Leitgeb Nicolas Guillemot // Phillip Bennefall Rohit Thiago Goulart // manxorist@github saga musix github:infatum // // Partial history: // 1.11 - 2017/07/23 - fix MinGW compilation // 1.10 - 2017/03/03 - more robust seeking; fix negative ilog(); clear error in open_memory // 1.09 - 2016/04/04 - back out 'truncation of last frame' fix from previous version // 1.08 - 2016/04/02 - warnings; setup memory leaks; truncation of last frame // 1.07 - 2015/01/16 - fixes for crashes on invalid files; warning fixes; const // 1.06 - 2015/08/31 - full, correct support for seeking API (Dougall Johnson) // some crash fixes when out of memory or with corrupt files // fix some inappropriately signed shifts // 1.05 - 2015/04/19 - don't define __forceinline if it's redundant // 1.04 - 2014/08/27 - fix missing const-correct case in API // 1.03 - 2014/08/07 - warning fixes // 1.02 - 2014/07/09 - declare qsort comparison as explicitly _cdecl in Windows // 1.01 - 2014/06/18 - fix stb_vorbis_get_samples_float (interleaved was correct) // 1.0 - 2014/05/26 - fix memory leaks; fix warnings; fix bugs in >2-channel; // (API change) report sample rate for decode-full-file funcs // // See end of file for full version history. ////////////////////////////////////////////////////////////////////////////// // // HEADER BEGINS HERE // #ifndef STB_VORBIS_INCLUDE_STB_VORBIS_H #define STB_VORBIS_INCLUDE_STB_VORBIS_H #if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO) #define STB_VORBIS_NO_STDIO 1 #endif #ifndef STB_VORBIS_NO_STDIO #include #endif #ifdef __cplusplus extern "C" { #endif /////////// THREAD SAFETY // Individual stb_vorbis* handles are not thread-safe; you cannot decode from // them from multiple threads at the same time. However, you can have multiple // stb_vorbis* handles and decode from them independently in multiple thrads. /////////// MEMORY ALLOCATION // normally stb_vorbis uses malloc() to allocate memory at startup, // and alloca() to allocate temporary memory during a frame on the // stack. (Memory consumption will depend on the amount of setup // data in the file and how you set the compile flags for speed // vs. size. In my test files the maximal-size usage is ~150KB.) // // You can modify the wrapper functions in the source (setup_malloc, // setup_temp_malloc, temp_malloc) to change this behavior, or you // can use a simpler allocation model: you pass in a buffer from // which stb_vorbis will allocate _all_ its memory (including the // temp memory). "open" may fail with a VORBIS_outofmem if you // do not pass in enough data; there is no way to determine how // much you do need except to succeed (at which point you can // query get_info to find the exact amount required. yes I know // this is lame). // // If you pass in a non-NULL buffer of the type below, allocation // will occur from it as described above. Otherwise just pass NULL // to use malloc()/alloca() typedef struct { char *alloc_buffer; int alloc_buffer_length_in_bytes; } stb_vorbis_alloc; /////////// FUNCTIONS USEABLE WITH ALL INPUT MODES typedef struct stb_vorbis stb_vorbis; typedef struct { unsigned int sample_rate; int channels; unsigned int setup_memory_required; unsigned int setup_temp_memory_required; unsigned int temp_memory_required; int max_frame_size; } stb_vorbis_info; // get general information about the file extern stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f); // get the last error detected (clears it, too) extern int stb_vorbis_get_error(stb_vorbis *f); // close an ogg vorbis file and free all memory in use extern void stb_vorbis_close(stb_vorbis *f); // this function returns the offset (in samples) from the beginning of the // file that will be returned by the next decode, if it is known, or -1 // otherwise. after a flush_pushdata() call, this may take a while before // it becomes valid again. // NOT WORKING YET after a seek with PULLDATA API extern int stb_vorbis_get_sample_offset(stb_vorbis *f); // returns the current seek point within the file, or offset from the beginning // of the memory buffer. In pushdata mode it returns 0. extern unsigned int stb_vorbis_get_file_offset(stb_vorbis *f); /////////// PUSHDATA API #ifndef STB_VORBIS_NO_PUSHDATA_API // this API allows you to get blocks of data from any source and hand // them to stb_vorbis. you have to buffer them; stb_vorbis will tell // you how much it used, and you have to give it the rest next time; // and stb_vorbis may not have enough data to work with and you will // need to give it the same data again PLUS more. Note that the Vorbis // specification does not bound the size of an individual frame. extern stb_vorbis *stb_vorbis_open_pushdata( const unsigned char * datablock, int datablock_length_in_bytes, int *datablock_memory_consumed_in_bytes, int *error, const stb_vorbis_alloc *alloc_buffer); // create a vorbis decoder by passing in the initial data block containing // the ogg&vorbis headers (you don't need to do parse them, just provide // the first N bytes of the file--you're told if it's not enough, see below) // on success, returns an stb_vorbis *, does not set error, returns the amount of // data parsed/consumed on this call in *datablock_memory_consumed_in_bytes; // on failure, returns NULL on error and sets *error, does not change *datablock_memory_consumed // if returns NULL and *error is VORBIS_need_more_data, then the input block was // incomplete and you need to pass in a larger block from the start of the file extern int stb_vorbis_decode_frame_pushdata( stb_vorbis *f, const unsigned char *datablock, int datablock_length_in_bytes, int *channels, // place to write number of float * buffers float ***output, // place to write float ** array of float * buffers int *samples // place to write number of output samples ); // decode a frame of audio sample data if possible from the passed-in data block // // return value: number of bytes we used from datablock // // possible cases: // 0 bytes used, 0 samples output (need more data) // N bytes used, 0 samples output (resynching the stream, keep going) // N bytes used, M samples output (one frame of data) // note that after opening a file, you will ALWAYS get one N-bytes,0-sample // frame, because Vorbis always "discards" the first frame. // // Note that on resynch, stb_vorbis will rarely consume all of the buffer, // instead only datablock_length_in_bytes-3 or less. This is because it wants // to avoid missing parts of a page header if they cross a datablock boundary, // without writing state-machiney code to record a partial detection. // // The number of channels returned are stored in *channels (which can be // NULL--it is always the same as the number of channels reported by // get_info). *output will contain an array of float* buffers, one per // channel. In other words, (*output)[0][0] contains the first sample from // the first channel, and (*output)[1][0] contains the first sample from // the second channel. extern void stb_vorbis_flush_pushdata(stb_vorbis *f); // inform stb_vorbis that your next datablock will not be contiguous with // previous ones (e.g. you've seeked in the data); future attempts to decode // frames will cause stb_vorbis to resynchronize (as noted above), and // once it sees a valid Ogg page (typically 4-8KB, as large as 64KB), it // will begin decoding the _next_ frame. // // if you want to seek using pushdata, you need to seek in your file, then // call stb_vorbis_flush_pushdata(), then start calling decoding, then once // decoding is returning you data, call stb_vorbis_get_sample_offset, and // if you don't like the result, seek your file again and repeat. #endif ////////// PULLING INPUT API #ifndef STB_VORBIS_NO_PULLDATA_API // This API assumes stb_vorbis is allowed to pull data from a source-- // either a block of memory containing the _entire_ vorbis stream, or a // FILE * that you or it create, or possibly some other reading mechanism // if you go modify the source to replace the FILE * case with some kind // of callback to your code. (But if you don't support seeking, you may // just want to go ahead and use pushdata.) #if !defined(STB_VORBIS_NO_STDIO) && !defined(STB_VORBIS_NO_INTEGER_CONVERSION) extern int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output); #endif #if !defined(STB_VORBIS_NO_INTEGER_CONVERSION) extern int stb_vorbis_decode_memory(const unsigned char *mem, int len, int *channels, int *sample_rate, short **output); #endif // decode an entire file and output the data interleaved into a malloc()ed // buffer stored in *output. The return value is the number of samples // decoded, or -1 if the file could not be opened or was not an ogg vorbis file. // When you're done with it, just free() the pointer returned in *output. extern stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc_buffer); // create an ogg vorbis decoder from an ogg vorbis stream in memory (note // this must be the entire stream!). on failure, returns NULL and sets *error #ifndef STB_VORBIS_NO_STDIO extern stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc_buffer); // create an ogg vorbis decoder from a filename via fopen(). on failure, // returns NULL and sets *error (possibly to VORBIS_file_open_failure). extern stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close, int *error, const stb_vorbis_alloc *alloc_buffer); // create an ogg vorbis decoder from an open FILE *, looking for a stream at // the _current_ seek point (ftell). on failure, returns NULL and sets *error. // note that stb_vorbis must "own" this stream; if you seek it in between // calls to stb_vorbis, it will become confused. Morever, if you attempt to // perform stb_vorbis_seek_*() operations on this file, it will assume it // owns the _entire_ rest of the file after the start point. Use the next // function, stb_vorbis_open_file_section(), to limit it. extern stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_close, int *error, const stb_vorbis_alloc *alloc_buffer, unsigned int len); // create an ogg vorbis decoder from an open FILE *, looking for a stream at // the _current_ seek point (ftell); the stream will be of length 'len' bytes. // on failure, returns NULL and sets *error. note that stb_vorbis must "own" // this stream; if you seek it in between calls to stb_vorbis, it will become // confused. #endif extern int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number); extern int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number); // these functions seek in the Vorbis file to (approximately) 'sample_number'. // after calling seek_frame(), the next call to get_frame_*() will include // the specified sample. after calling stb_vorbis_seek(), the next call to // stb_vorbis_get_samples_* will start with the specified sample. If you // do not need to seek to EXACTLY the target sample when using get_samples_*, // you can also use seek_frame(). extern int stb_vorbis_seek_start(stb_vorbis *f); // this function is equivalent to stb_vorbis_seek(f,0) extern unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f); extern float stb_vorbis_stream_length_in_seconds(stb_vorbis *f); // these functions return the total length of the vorbis stream extern int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output); // decode the next frame and return the number of samples. the number of // channels returned are stored in *channels (which can be NULL--it is always // the same as the number of channels reported by get_info). *output will // contain an array of float* buffers, one per channel. These outputs will // be overwritten on the next call to stb_vorbis_get_frame_*. // // You generally should not intermix calls to stb_vorbis_get_frame_*() // and stb_vorbis_get_samples_*(), since the latter calls the former. #ifndef STB_VORBIS_NO_INTEGER_CONVERSION extern int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts); extern int stb_vorbis_get_frame_short (stb_vorbis *f, int num_c, short **buffer, int num_samples); #endif // decode the next frame and return the number of *samples* per channel. // Note that for interleaved data, you pass in the number of shorts (the // size of your array), but the return value is the number of samples per // channel, not the total number of samples. // // The data is coerced to the number of channels you request according to the // channel coercion rules (see below). You must pass in the size of your // buffer(s) so that stb_vorbis will not overwrite the end of the buffer. // The maximum buffer size needed can be gotten from get_info(); however, // the Vorbis I specification implies an absolute maximum of 4096 samples // per channel. // Channel coercion rules: // Let M be the number of channels requested, and N the number of channels present, // and Cn be the nth channel; let stereo L be the sum of all L and center channels, // and stereo R be the sum of all R and center channels (channel assignment from the // vorbis spec). // M N output // 1 k sum(Ck) for all k // 2 * stereo L, stereo R // k l k > l, the first l channels, then 0s // k l k <= l, the first k channels // Note that this is not _good_ surround etc. mixing at all! It's just so // you get something useful. extern int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats); extern int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples); // gets num_samples samples, not necessarily on a frame boundary--this requires // buffering so you have to supply the buffers. DOES NOT APPLY THE COERCION RULES. // Returns the number of samples stored per channel; it may be less than requested // at the end of the file. If there are no more samples in the file, returns 0. #ifndef STB_VORBIS_NO_INTEGER_CONVERSION extern int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts); extern int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int num_samples); #endif // gets num_samples samples, not necessarily on a frame boundary--this requires // buffering so you have to supply the buffers. Applies the coercion rules above // to produce 'channels' channels. Returns the number of samples stored per channel; // it may be less than requested at the end of the file. If there are no more // samples in the file, returns 0. #endif //////// ERROR CODES enum STBVorbisError { VORBIS__no_error, VORBIS_need_more_data=1, // not a real error VORBIS_invalid_api_mixing, // can't mix API modes VORBIS_outofmem, // not enough memory VORBIS_feature_not_supported, // uses floor 0 VORBIS_too_many_channels, // STB_VORBIS_MAX_CHANNELS is too small VORBIS_file_open_failure, // fopen() failed VORBIS_seek_without_length, // can't seek in unknown-length file VORBIS_unexpected_eof=10, // file is truncated? VORBIS_seek_invalid, // seek past EOF // decoding errors (corrupt/invalid stream) -- you probably // don't care about the exact details of these // vorbis errors: VORBIS_invalid_setup=20, VORBIS_invalid_stream, // ogg errors: VORBIS_missing_capture_pattern=30, VORBIS_invalid_stream_structure_version, VORBIS_continued_packet_flag_invalid, VORBIS_incorrect_stream_serial_number, VORBIS_invalid_first_page, VORBIS_bad_packet_type, VORBIS_cant_find_last_page, VORBIS_seek_failed }; #ifdef __cplusplus } #endif #endif // STB_VORBIS_INCLUDE_STB_VORBIS_H // // HEADER ENDS HERE // ////////////////////////////////////////////////////////////////////////////// #ifndef STB_VORBIS_HEADER_ONLY // global configuration settings (e.g. set these in the project/makefile), // or just set them in this file at the top (although ideally the first few // should be visible when the header file is compiled too, although it's not // crucial) // STB_VORBIS_NO_PUSHDATA_API // does not compile the code for the various stb_vorbis_*_pushdata() // functions // #define STB_VORBIS_NO_PUSHDATA_API // STB_VORBIS_NO_PULLDATA_API // does not compile the code for the non-pushdata APIs // #define STB_VORBIS_NO_PULLDATA_API // STB_VORBIS_NO_STDIO // does not compile the code for the APIs that use FILE *s internally // or externally (implied by STB_VORBIS_NO_PULLDATA_API) // #define STB_VORBIS_NO_STDIO // STB_VORBIS_NO_INTEGER_CONVERSION // does not compile the code for converting audio sample data from // float to integer (implied by STB_VORBIS_NO_PULLDATA_API) // #define STB_VORBIS_NO_INTEGER_CONVERSION // STB_VORBIS_NO_FAST_SCALED_FLOAT // does not use a fast float-to-int trick to accelerate float-to-int on // most platforms which requires endianness be defined correctly. //#define STB_VORBIS_NO_FAST_SCALED_FLOAT // STB_VORBIS_MAX_CHANNELS [number] // globally define this to the maximum number of channels you need. // The spec does not put a restriction on channels except that // the count is stored in a byte, so 255 is the hard limit. // Reducing this saves about 16 bytes per value, so using 16 saves // (255-16)*16 or around 4KB. Plus anything other memory usage // I forgot to account for. Can probably go as low as 8 (7.1 audio), // 6 (5.1 audio), or 2 (stereo only). #ifndef STB_VORBIS_MAX_CHANNELS #define STB_VORBIS_MAX_CHANNELS 16 // enough for anyone? #endif // STB_VORBIS_PUSHDATA_CRC_COUNT [number] // after a flush_pushdata(), stb_vorbis begins scanning for the // next valid page, without backtracking. when it finds something // that looks like a page, it streams through it and verifies its // CRC32. Should that validation fail, it keeps scanning. But it's // possible that _while_ streaming through to check the CRC32 of // one candidate page, it sees another candidate page. This #define // determines how many "overlapping" candidate pages it can search // at once. Note that "real" pages are typically ~4KB to ~8KB, whereas // garbage pages could be as big as 64KB, but probably average ~16KB. // So don't hose ourselves by scanning an apparent 64KB page and // missing a ton of real ones in the interim; so minimum of 2 #ifndef STB_VORBIS_PUSHDATA_CRC_COUNT #define STB_VORBIS_PUSHDATA_CRC_COUNT 4 #endif // STB_VORBIS_FAST_HUFFMAN_LENGTH [number] // sets the log size of the huffman-acceleration table. Maximum // supported value is 24. with larger numbers, more decodings are O(1), // but the table size is larger so worse cache missing, so you'll have // to probe (and try multiple ogg vorbis files) to find the sweet spot. #ifndef STB_VORBIS_FAST_HUFFMAN_LENGTH #define STB_VORBIS_FAST_HUFFMAN_LENGTH 10 #endif // STB_VORBIS_FAST_BINARY_LENGTH [number] // sets the log size of the binary-search acceleration table. this // is used in similar fashion to the fast-huffman size to set initial // parameters for the binary search // STB_VORBIS_FAST_HUFFMAN_INT // The fast huffman tables are much more efficient if they can be // stored as 16-bit results instead of 32-bit results. This restricts // the codebooks to having only 65535 possible outcomes, though. // (At least, accelerated by the huffman table.) #ifndef STB_VORBIS_FAST_HUFFMAN_INT #define STB_VORBIS_FAST_HUFFMAN_SHORT #endif // STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH // If the 'fast huffman' search doesn't succeed, then stb_vorbis falls // back on binary searching for the correct one. This requires storing // extra tables with the huffman codes in sorted order. Defining this // symbol trades off space for speed by forcing a linear search in the // non-fast case, except for "sparse" codebooks. // #define STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH // STB_VORBIS_DIVIDES_IN_RESIDUE // stb_vorbis precomputes the result of the scalar residue decoding // that would otherwise require a divide per chunk. you can trade off // space for time by defining this symbol. // #define STB_VORBIS_DIVIDES_IN_RESIDUE // STB_VORBIS_DIVIDES_IN_CODEBOOK // vorbis VQ codebooks can be encoded two ways: with every case explicitly // stored, or with all elements being chosen from a small range of values, // and all values possible in all elements. By default, stb_vorbis expands // this latter kind out to look like the former kind for ease of decoding, // because otherwise an integer divide-per-vector-element is required to // unpack the index. If you define STB_VORBIS_DIVIDES_IN_CODEBOOK, you can // trade off storage for speed. //#define STB_VORBIS_DIVIDES_IN_CODEBOOK #ifdef STB_VORBIS_CODEBOOK_SHORTS #error "STB_VORBIS_CODEBOOK_SHORTS is no longer supported as it produced incorrect results for some input formats" #endif // STB_VORBIS_DIVIDE_TABLE // this replaces small integer divides in the floor decode loop with // table lookups. made less than 1% difference, so disabled by default. // STB_VORBIS_NO_INLINE_DECODE // disables the inlining of the scalar codebook fast-huffman decode. // might save a little codespace; useful for debugging // #define STB_VORBIS_NO_INLINE_DECODE // STB_VORBIS_NO_DEFER_FLOOR // Normally we only decode the floor without synthesizing the actual // full curve. We can instead synthesize the curve immediately. This // requires more memory and is very likely slower, so I don't think // you'd ever want to do it except for debugging. // #define STB_VORBIS_NO_DEFER_FLOOR ////////////////////////////////////////////////////////////////////////////// #ifdef STB_VORBIS_NO_PULLDATA_API #define STB_VORBIS_NO_INTEGER_CONVERSION #define STB_VORBIS_NO_STDIO #endif #if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO) #define STB_VORBIS_NO_STDIO 1 #endif #ifndef STB_VORBIS_NO_INTEGER_CONVERSION #ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT // only need endianness for fast-float-to-int, which we don't // use for pushdata #ifndef STB_VORBIS_BIG_ENDIAN #define STB_VORBIS_ENDIAN 0 #else #define STB_VORBIS_ENDIAN 1 #endif #endif #endif #ifndef STB_VORBIS_NO_STDIO #include #endif #ifndef STB_VORBIS_NO_CRT #include #include #include #include // find definition of alloca if it's not in stdlib.h: #if defined(_MSC_VER) || defined(__MINGW32__) #include #endif #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) #include #endif #else // STB_VORBIS_NO_CRT #define NULL 0 #define malloc(s) 0 #define free(s) ((void) 0) #define realloc(s) 0 #endif // STB_VORBIS_NO_CRT #include #ifdef __MINGW32__ // eff you mingw: // "fixed": // http://sourceforge.net/p/mingw-w64/mailman/message/32882927/ // "no that broke the build, reverted, who cares about C": // http://sourceforge.net/p/mingw-w64/mailman/message/32890381/ #ifdef __forceinline #undef __forceinline #endif #define __forceinline #define alloca __builtin_alloca #elif !defined(_MSC_VER) #if __GNUC__ #define __forceinline inline #else #define __forceinline #endif #endif #if STB_VORBIS_MAX_CHANNELS > 256 #error "Value of STB_VORBIS_MAX_CHANNELS outside of allowed range" #endif #if STB_VORBIS_FAST_HUFFMAN_LENGTH > 24 #error "Value of STB_VORBIS_FAST_HUFFMAN_LENGTH outside of allowed range" #endif #if 0 #include #define CHECK(f) _CrtIsValidHeapPointer(f->channel_buffers[1]) #else #define CHECK(f) ((void) 0) #endif #define MAX_BLOCKSIZE_LOG 13 // from specification #define MAX_BLOCKSIZE (1 << MAX_BLOCKSIZE_LOG) typedef unsigned char uint8; typedef signed char int8; typedef unsigned short uint16; typedef signed short int16; typedef unsigned int uint32; typedef signed int int32; #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif typedef float codetype; // @NOTE // // Some arrays below are tagged "//varies", which means it's actually // a variable-sized piece of data, but rather than malloc I assume it's // small enough it's better to just allocate it all together with the // main thing // // Most of the variables are specified with the smallest size I could pack // them into. It might give better performance to make them all full-sized // integers. It should be safe to freely rearrange the structures or change // the sizes larger--nothing relies on silently truncating etc., nor the // order of variables. #define FAST_HUFFMAN_TABLE_SIZE (1 << STB_VORBIS_FAST_HUFFMAN_LENGTH) #define FAST_HUFFMAN_TABLE_MASK (FAST_HUFFMAN_TABLE_SIZE - 1) typedef struct { int dimensions, entries; uint8 *codeword_lengths; float minimum_value; float delta_value; uint8 value_bits; uint8 lookup_type; uint8 sequence_p; uint8 sparse; uint32 lookup_values; codetype *multiplicands; uint32 *codewords; #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT int16 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; #else int32 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; #endif uint32 *sorted_codewords; int *sorted_values; int sorted_entries; } Codebook; typedef struct { uint8 order; uint16 rate; uint16 bark_map_size; uint8 amplitude_bits; uint8 amplitude_offset; uint8 number_of_books; uint8 book_list[16]; // varies } Floor0; typedef struct { uint8 partitions; uint8 partition_class_list[32]; // varies uint8 class_dimensions[16]; // varies uint8 class_subclasses[16]; // varies uint8 class_masterbooks[16]; // varies int16 subclass_books[16][8]; // varies uint16 Xlist[31*8+2]; // varies uint8 sorted_order[31*8+2]; uint8 neighbors[31*8+2][2]; uint8 floor1_multiplier; uint8 rangebits; int values; } Floor1; typedef union { Floor0 floor0; Floor1 floor1; } Floor; typedef struct { uint32 begin, end; uint32 part_size; uint8 classifications; uint8 classbook; uint8 **classdata; int16 (*residue_books)[8]; } Residue; typedef struct { uint8 magnitude; uint8 angle; uint8 mux; } MappingChannel; typedef struct { uint16 coupling_steps; MappingChannel *chan; uint8 submaps; uint8 submap_floor[15]; // varies uint8 submap_residue[15]; // varies } Mapping; typedef struct { uint8 blockflag; uint8 mapping; uint16 windowtype; uint16 transformtype; } Mode; typedef struct { uint32 goal_crc; // expected crc if match int bytes_left; // bytes left in packet uint32 crc_so_far; // running crc int bytes_done; // bytes processed in _current_ chunk uint32 sample_loc; // granule pos encoded in page } CRCscan; typedef struct { uint32 page_start, page_end; uint32 last_decoded_sample; } ProbedPage; struct stb_vorbis { // user-accessible info unsigned int sample_rate; int channels; unsigned int setup_memory_required; unsigned int temp_memory_required; unsigned int setup_temp_memory_required; // input config #ifndef STB_VORBIS_NO_STDIO FILE *f; uint32 f_start; int close_on_free; #endif uint8 *stream; uint8 *stream_start; uint8 *stream_end; uint32 stream_len; uint8 push_mode; uint32 first_audio_page_offset; ProbedPage p_first, p_last; // memory management stb_vorbis_alloc alloc; int setup_offset; int temp_offset; // run-time results int eof; enum STBVorbisError error; // user-useful data // header info int blocksize[2]; int blocksize_0, blocksize_1; int codebook_count; Codebook *codebooks; int floor_count; uint16 floor_types[64]; // varies Floor *floor_config; int residue_count; uint16 residue_types[64]; // varies Residue *residue_config; int mapping_count; Mapping *mapping; int mode_count; Mode mode_config[64]; // varies uint32 total_samples; // decode buffer float *channel_buffers[STB_VORBIS_MAX_CHANNELS]; float *outputs [STB_VORBIS_MAX_CHANNELS]; float *previous_window[STB_VORBIS_MAX_CHANNELS]; int previous_length; #ifndef STB_VORBIS_NO_DEFER_FLOOR int16 *finalY[STB_VORBIS_MAX_CHANNELS]; #else float *floor_buffers[STB_VORBIS_MAX_CHANNELS]; #endif uint32 current_loc; // sample location of next frame to decode int current_loc_valid; // per-blocksize precomputed data // twiddle factors float *A[2],*B[2],*C[2]; float *window[2]; uint16 *bit_reverse[2]; // current page/packet/segment streaming info uint32 serial; // stream serial number for verification int last_page; int segment_count; uint8 segments[255]; uint8 page_flag; uint8 bytes_in_seg; uint8 first_decode; int next_seg; int last_seg; // flag that we're on the last segment int last_seg_which; // what was the segment number of the last seg? uint32 acc; int valid_bits; int packet_bytes; int end_seg_with_known_loc; uint32 known_loc_for_packet; int discard_samples_deferred; uint32 samples_output; // push mode scanning int page_crc_tests; // only in push_mode: number of tests active; -1 if not searching #ifndef STB_VORBIS_NO_PUSHDATA_API CRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT]; #endif // sample-access int channel_buffer_start; int channel_buffer_end; }; #if defined(STB_VORBIS_NO_PUSHDATA_API) #define IS_PUSH_MODE(f) FALSE #elif defined(STB_VORBIS_NO_PULLDATA_API) #define IS_PUSH_MODE(f) TRUE #else #define IS_PUSH_MODE(f) ((f)->push_mode) #endif typedef struct stb_vorbis vorb; static int error(vorb *f, enum STBVorbisError e) { f->error = e; if (!f->eof && e != VORBIS_need_more_data) { f->error=e; // breakpoint for debugging } return 0; } // these functions are used for allocating temporary memory // while decoding. if you can afford the stack space, use // alloca(); otherwise, provide a temp buffer and it will // allocate out of those. #define array_size_required(count,size) (count*(sizeof(void *)+(size))) #define temp_alloc(f,size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size)) #ifdef dealloca #define temp_free(f,p) (f->alloc.alloc_buffer ? 0 : dealloca(size)) #else #define temp_free(f,p) 0 #endif #define temp_alloc_save(f) ((f)->temp_offset) #define temp_alloc_restore(f,p) ((f)->temp_offset = (p)) #define temp_block_array(f,count,size) make_block_array(temp_alloc(f,array_size_required(count,size)), count, size) // given a sufficiently large block of memory, make an array of pointers to subblocks of it static void *make_block_array(void *mem, int count, int size) { int i; void ** p = (void **) mem; char *q = (char *) (p + count); for (i=0; i < count; ++i) { p[i] = q; q += size; } return p; } static void *setup_malloc(vorb *f, int sz) { sz = (sz+3) & ~3; f->setup_memory_required += sz; if (f->alloc.alloc_buffer) { void *p = (char *) f->alloc.alloc_buffer + f->setup_offset; if (f->setup_offset + sz > f->temp_offset) return NULL; f->setup_offset += sz; return p; } return sz ? malloc(sz) : NULL; } static void setup_free(vorb *f, void *p) { if (f->alloc.alloc_buffer) return; // do nothing; setup mem is a stack free(p); } static void *setup_temp_malloc(vorb *f, int sz) { sz = (sz+3) & ~3; if (f->alloc.alloc_buffer) { if (f->temp_offset - sz < f->setup_offset) return NULL; f->temp_offset -= sz; return (char *) f->alloc.alloc_buffer + f->temp_offset; } return malloc(sz); } static void setup_temp_free(vorb *f, void *p, int sz) { if (f->alloc.alloc_buffer) { f->temp_offset += (sz+3)&~3; return; } free(p); } #define CRC32_POLY 0x04c11db7 // from spec static uint32 crc_table[256]; static void crc32_init(void) { int i,j; uint32 s; for(i=0; i < 256; i++) { for (s=(uint32) i << 24, j=0; j < 8; ++j) s = (s << 1) ^ (s >= (1U<<31) ? CRC32_POLY : 0); crc_table[i] = s; } } static __forceinline uint32 crc32_update(uint32 crc, uint8 byte) { return (crc << 8) ^ crc_table[byte ^ (crc >> 24)]; } // used in setup, and for huffman that doesn't go fast path static unsigned int bit_reverse(unsigned int n) { n = ((n & 0xAAAAAAAA) >> 1) | ((n & 0x55555555) << 1); n = ((n & 0xCCCCCCCC) >> 2) | ((n & 0x33333333) << 2); n = ((n & 0xF0F0F0F0) >> 4) | ((n & 0x0F0F0F0F) << 4); n = ((n & 0xFF00FF00) >> 8) | ((n & 0x00FF00FF) << 8); return (n >> 16) | (n << 16); } static float square(float x) { return x*x; } // this is a weird definition of log2() for which log2(1) = 1, log2(2) = 2, log2(4) = 3 // as required by the specification. fast(?) implementation from stb.h // @OPTIMIZE: called multiple times per-packet with "constants"; move to setup static int ilog(int32 n) { static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 }; if (n < 0) return 0; // signed n returns 0 // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29) if (n < (1 << 14)) if (n < (1 << 4)) return 0 + log2_4[n ]; else if (n < (1 << 9)) return 5 + log2_4[n >> 5]; else return 10 + log2_4[n >> 10]; else if (n < (1 << 24)) if (n < (1 << 19)) return 15 + log2_4[n >> 15]; else return 20 + log2_4[n >> 20]; else if (n < (1 << 29)) return 25 + log2_4[n >> 25]; else return 30 + log2_4[n >> 30]; } #ifndef M_PI #define M_PI 3.14159265358979323846264f // from CRC #endif // code length assigned to a value with no huffman encoding #define NO_CODE 255 /////////////////////// LEAF SETUP FUNCTIONS ////////////////////////// // // these functions are only called at setup, and only a few times // per file static float float32_unpack(uint32 x) { // from the specification uint32 mantissa = x & 0x1fffff; uint32 sign = x & 0x80000000; uint32 exp = (x & 0x7fe00000) >> 21; double res = sign ? -(double)mantissa : (double)mantissa; return (float) ldexp((float)res, exp-788); } // zlib & jpeg huffman tables assume that the output symbols // can either be arbitrarily arranged, or have monotonically // increasing frequencies--they rely on the lengths being sorted; // this makes for a very simple generation algorithm. // vorbis allows a huffman table with non-sorted lengths. This // requires a more sophisticated construction, since symbols in // order do not map to huffman codes "in order". static void add_entry(Codebook *c, uint32 huff_code, int symbol, int count, int len, uint32 *values) { if (!c->sparse) { c->codewords [symbol] = huff_code; } else { c->codewords [count] = huff_code; c->codeword_lengths[count] = len; values [count] = symbol; } } static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values) { int i,k,m=0; uint32 available[32]; memset(available, 0, sizeof(available)); // find the first entry for (k=0; k < n; ++k) if (len[k] < NO_CODE) break; if (k == n) { assert(c->sorted_entries == 0); return TRUE; } // add to the list add_entry(c, 0, k, m++, len[k], values); // add all available leaves for (i=1; i <= len[k]; ++i) available[i] = 1U << (32-i); // note that the above code treats the first case specially, // but it's really the same as the following code, so they // could probably be combined (except the initial code is 0, // and I use 0 in available[] to mean 'empty') for (i=k+1; i < n; ++i) { uint32 res; int z = len[i], y; if (z == NO_CODE) continue; // find lowest available leaf (should always be earliest, // which is what the specification calls for) // note that this property, and the fact we can never have // more than one free leaf at a given level, isn't totally // trivial to prove, but it seems true and the assert never // fires, so! while (z > 0 && !available[z]) --z; if (z == 0) { return FALSE; } res = available[z]; assert(z >= 0 && z < 32); available[z] = 0; add_entry(c, bit_reverse(res), i, m++, len[i], values); // propogate availability up the tree if (z != len[i]) { assert(len[i] >= 0 && len[i] < 32); for (y=len[i]; y > z; --y) { assert(available[y] == 0); available[y] = res + (1 << (32-y)); } } } return TRUE; } // accelerated huffman table allows fast O(1) match of all symbols // of length <= STB_VORBIS_FAST_HUFFMAN_LENGTH static void compute_accelerated_huffman(Codebook *c) { int i, len; for (i=0; i < FAST_HUFFMAN_TABLE_SIZE; ++i) c->fast_huffman[i] = -1; len = c->sparse ? c->sorted_entries : c->entries; #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT if (len > 32767) len = 32767; // largest possible value we can encode! #endif for (i=0; i < len; ++i) { if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) { uint32 z = c->sparse ? bit_reverse(c->sorted_codewords[i]) : c->codewords[i]; // set table entries for all bit combinations in the higher bits while (z < FAST_HUFFMAN_TABLE_SIZE) { c->fast_huffman[z] = i; z += 1 << c->codeword_lengths[i]; } } } } #ifdef _MSC_VER #define STBV_CDECL __cdecl #else #define STBV_CDECL #endif static int STBV_CDECL uint32_compare(const void *p, const void *q) { uint32 x = * (uint32 *) p; uint32 y = * (uint32 *) q; return x < y ? -1 : x > y; } static int include_in_sort(Codebook *c, uint8 len) { if (c->sparse) { assert(len != NO_CODE); return TRUE; } if (len == NO_CODE) return FALSE; if (len > STB_VORBIS_FAST_HUFFMAN_LENGTH) return TRUE; return FALSE; } // if the fast table above doesn't work, we want to binary // search them... need to reverse the bits static void compute_sorted_huffman(Codebook *c, uint8 *lengths, uint32 *values) { int i, len; // build a list of all the entries // OPTIMIZATION: don't include the short ones, since they'll be caught by FAST_HUFFMAN. // this is kind of a frivolous optimization--I don't see any performance improvement, // but it's like 4 extra lines of code, so. if (!c->sparse) { int k = 0; for (i=0; i < c->entries; ++i) if (include_in_sort(c, lengths[i])) c->sorted_codewords[k++] = bit_reverse(c->codewords[i]); assert(k == c->sorted_entries); } else { for (i=0; i < c->sorted_entries; ++i) c->sorted_codewords[i] = bit_reverse(c->codewords[i]); } qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]), uint32_compare); c->sorted_codewords[c->sorted_entries] = 0xffffffff; len = c->sparse ? c->sorted_entries : c->entries; // now we need to indicate how they correspond; we could either // #1: sort a different data structure that says who they correspond to // #2: for each sorted entry, search the original list to find who corresponds // #3: for each original entry, find the sorted entry // #1 requires extra storage, #2 is slow, #3 can use binary search! for (i=0; i < len; ++i) { int huff_len = c->sparse ? lengths[values[i]] : lengths[i]; if (include_in_sort(c,huff_len)) { uint32 code = bit_reverse(c->codewords[i]); int x=0, n=c->sorted_entries; while (n > 1) { // invariant: sc[x] <= code < sc[x+n] int m = x + (n >> 1); if (c->sorted_codewords[m] <= code) { x = m; n -= (n>>1); } else { n >>= 1; } } assert(c->sorted_codewords[x] == code); if (c->sparse) { c->sorted_values[x] = values[i]; c->codeword_lengths[x] = huff_len; } else { c->sorted_values[x] = i; } } } } // only run while parsing the header (3 times) static int vorbis_validate(uint8 *data) { static uint8 vorbis[6] = { 'v', 'o', 'r', 'b', 'i', 's' }; return memcmp(data, vorbis, 6) == 0; } // called from setup only, once per code book // (formula implied by specification) static int lookup1_values(int entries, int dim) { int r = (int) floor(exp((float) log((float) entries) / dim)); if ((int) floor(pow((float) r+1, dim)) <= entries) // (int) cast for MinGW warning; ++r; // floor() to avoid _ftol() when non-CRT assert(pow((float) r+1, dim) > entries); assert((int) floor(pow((float) r, dim)) <= entries); // (int),floor() as above return r; } // called twice per file static void compute_twiddle_factors(int n, float *A, float *B, float *C) { int n4 = n >> 2, n8 = n >> 3; int k,k2; for (k=k2=0; k < n4; ++k,k2+=2) { A[k2 ] = (float) cos(4*k*M_PI/n); A[k2+1] = (float) -sin(4*k*M_PI/n); B[k2 ] = (float) cos((k2+1)*M_PI/n/2) * 0.5f; B[k2+1] = (float) sin((k2+1)*M_PI/n/2) * 0.5f; } for (k=k2=0; k < n8; ++k,k2+=2) { C[k2 ] = (float) cos(2*(k2+1)*M_PI/n); C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n); } } static void compute_window(int n, float *window) { int n2 = n >> 1, i; for (i=0; i < n2; ++i) window[i] = (float) sin(0.5 * M_PI * square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI))); } static void compute_bitreverse(int n, uint16 *rev) { int ld = ilog(n) - 1; // ilog is off-by-one from normal definitions int i, n8 = n >> 3; for (i=0; i < n8; ++i) rev[i] = (bit_reverse(i) >> (32-ld+3)) << 2; } static int init_blocksize(vorb *f, int b, int n) { int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3; f->A[b] = (float *) setup_malloc(f, sizeof(float) * n2); f->B[b] = (float *) setup_malloc(f, sizeof(float) * n2); f->C[b] = (float *) setup_malloc(f, sizeof(float) * n4); if (!f->A[b] || !f->B[b] || !f->C[b]) return error(f, VORBIS_outofmem); compute_twiddle_factors(n, f->A[b], f->B[b], f->C[b]); f->window[b] = (float *) setup_malloc(f, sizeof(float) * n2); if (!f->window[b]) return error(f, VORBIS_outofmem); compute_window(n, f->window[b]); f->bit_reverse[b] = (uint16 *) setup_malloc(f, sizeof(uint16) * n8); if (!f->bit_reverse[b]) return error(f, VORBIS_outofmem); compute_bitreverse(n, f->bit_reverse[b]); return TRUE; } static void neighbors(uint16 *x, int n, int *plow, int *phigh) { int low = -1; int high = 65536; int i; for (i=0; i < n; ++i) { if (x[i] > low && x[i] < x[n]) { *plow = i; low = x[i]; } if (x[i] < high && x[i] > x[n]) { *phigh = i; high = x[i]; } } } // this has been repurposed so y is now the original index instead of y typedef struct { uint16 x,id; } stbv__floor_ordering; static int STBV_CDECL point_compare(const void *p, const void *q) { stbv__floor_ordering *a = (stbv__floor_ordering *) p; stbv__floor_ordering *b = (stbv__floor_ordering *) q; return a->x < b->x ? -1 : a->x > b->x; } // /////////////////////// END LEAF SETUP FUNCTIONS ////////////////////////// #if defined(STB_VORBIS_NO_STDIO) #define USE_MEMORY(z) TRUE #else #define USE_MEMORY(z) ((z)->stream) #endif static uint8 get8(vorb *z) { if (USE_MEMORY(z)) { if (z->stream >= z->stream_end) { z->eof = TRUE; return 0; } return *z->stream++; } #ifndef STB_VORBIS_NO_STDIO { int c = fgetc(z->f); if (c == EOF) { z->eof = TRUE; return 0; } return c; } #endif } static uint32 get32(vorb *f) { uint32 x; x = get8(f); x += get8(f) << 8; x += get8(f) << 16; x += (uint32) get8(f) << 24; return x; } static int getn(vorb *z, uint8 *data, int n) { if (USE_MEMORY(z)) { if (z->stream+n > z->stream_end) { z->eof = 1; return 0; } memcpy(data, z->stream, n); z->stream += n; return 1; } #ifndef STB_VORBIS_NO_STDIO if (fread(data, n, 1, z->f) == 1) return 1; else { z->eof = 1; return 0; } #endif } static void skip(vorb *z, int n) { if (USE_MEMORY(z)) { z->stream += n; if (z->stream >= z->stream_end) z->eof = 1; return; } #ifndef STB_VORBIS_NO_STDIO { long x = ftell(z->f); fseek(z->f, x+n, SEEK_SET); } #endif } static int set_file_offset(stb_vorbis *f, unsigned int loc) { #ifndef STB_VORBIS_NO_PUSHDATA_API if (f->push_mode) return 0; #endif f->eof = 0; if (USE_MEMORY(f)) { if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) { f->stream = f->stream_end; f->eof = 1; return 0; } else { f->stream = f->stream_start + loc; return 1; } } #ifndef STB_VORBIS_NO_STDIO if (loc + f->f_start < loc || loc >= 0x80000000) { loc = 0x7fffffff; f->eof = 1; } else { loc += f->f_start; } if (!fseek(f->f, loc, SEEK_SET)) return 1; f->eof = 1; fseek(f->f, f->f_start, SEEK_END); return 0; #endif } static uint8 ogg_page_header[4] = { 0x4f, 0x67, 0x67, 0x53 }; static int capture_pattern(vorb *f) { if (0x4f != get8(f)) return FALSE; if (0x67 != get8(f)) return FALSE; if (0x67 != get8(f)) return FALSE; if (0x53 != get8(f)) return FALSE; return TRUE; } #define PAGEFLAG_continued_packet 1 #define PAGEFLAG_first_page 2 #define PAGEFLAG_last_page 4 static int start_page_no_capturepattern(vorb *f) { uint32 loc0,loc1,n; // stream structure version if (0 != get8(f)) return error(f, VORBIS_invalid_stream_structure_version); // header flag f->page_flag = get8(f); // absolute granule position loc0 = get32(f); loc1 = get32(f); // @TODO: validate loc0,loc1 as valid positions? // stream serial number -- vorbis doesn't interleave, so discard get32(f); //if (f->serial != get32(f)) return error(f, VORBIS_incorrect_stream_serial_number); // page sequence number n = get32(f); f->last_page = n; // CRC32 get32(f); // page_segments f->segment_count = get8(f); if (!getn(f, f->segments, f->segment_count)) return error(f, VORBIS_unexpected_eof); // assume we _don't_ know any the sample position of any segments f->end_seg_with_known_loc = -2; if (loc0 != ~0U || loc1 != ~0U) { int i; // determine which packet is the last one that will complete for (i=f->segment_count-1; i >= 0; --i) if (f->segments[i] < 255) break; // 'i' is now the index of the _last_ segment of a packet that ends if (i >= 0) { f->end_seg_with_known_loc = i; f->known_loc_for_packet = loc0; } } if (f->first_decode) { int i,len; ProbedPage p; len = 0; for (i=0; i < f->segment_count; ++i) len += f->segments[i]; len += 27 + f->segment_count; p.page_start = f->first_audio_page_offset; p.page_end = p.page_start + len; p.last_decoded_sample = loc0; f->p_first = p; } f->next_seg = 0; return TRUE; } static int start_page(vorb *f) { if (!capture_pattern(f)) return error(f, VORBIS_missing_capture_pattern); return start_page_no_capturepattern(f); } static int start_packet(vorb *f) { while (f->next_seg == -1) { if (!start_page(f)) return FALSE; if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_continued_packet_flag_invalid); } f->last_seg = FALSE; f->valid_bits = 0; f->packet_bytes = 0; f->bytes_in_seg = 0; // f->next_seg is now valid return TRUE; } static int maybe_start_packet(vorb *f) { if (f->next_seg == -1) { int x = get8(f); if (f->eof) return FALSE; // EOF at page boundary is not an error! if (0x4f != x ) return error(f, VORBIS_missing_capture_pattern); if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern); if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern); if (0x53 != get8(f)) return error(f, VORBIS_missing_capture_pattern); if (!start_page_no_capturepattern(f)) return FALSE; if (f->page_flag & PAGEFLAG_continued_packet) { // set up enough state that we can read this packet if we want, // e.g. during recovery f->last_seg = FALSE; f->bytes_in_seg = 0; return error(f, VORBIS_continued_packet_flag_invalid); } } return start_packet(f); } static int next_segment(vorb *f) { int len; if (f->last_seg) return 0; if (f->next_seg == -1) { f->last_seg_which = f->segment_count-1; // in case start_page fails if (!start_page(f)) { f->last_seg = 1; return 0; } if (!(f->page_flag & PAGEFLAG_continued_packet)) return error(f, VORBIS_continued_packet_flag_invalid); } len = f->segments[f->next_seg++]; if (len < 255) { f->last_seg = TRUE; f->last_seg_which = f->next_seg-1; } if (f->next_seg >= f->segment_count) f->next_seg = -1; assert(f->bytes_in_seg == 0); f->bytes_in_seg = len; return len; } #define EOP (-1) #define INVALID_BITS (-1) static int get8_packet_raw(vorb *f) { if (!f->bytes_in_seg) { // CLANG! if (f->last_seg) return EOP; else if (!next_segment(f)) return EOP; } assert(f->bytes_in_seg > 0); --f->bytes_in_seg; ++f->packet_bytes; return get8(f); } static int get8_packet(vorb *f) { int x = get8_packet_raw(f); f->valid_bits = 0; return x; } static void flush_packet(vorb *f) { while (get8_packet_raw(f) != EOP); } // @OPTIMIZE: this is the secondary bit decoder, so it's probably not as important // as the huffman decoder? static uint32 get_bits(vorb *f, int n) { uint32 z; if (f->valid_bits < 0) return 0; if (f->valid_bits < n) { if (n > 24) { // the accumulator technique below would not work correctly in this case z = get_bits(f, 24); z += get_bits(f, n-24) << 24; return z; } if (f->valid_bits == 0) f->acc = 0; while (f->valid_bits < n) { int z = get8_packet_raw(f); if (z == EOP) { f->valid_bits = INVALID_BITS; return 0; } f->acc += z << f->valid_bits; f->valid_bits += 8; } } if (f->valid_bits < 0) return 0; z = f->acc & ((1 << n)-1); f->acc >>= n; f->valid_bits -= n; return z; } // @OPTIMIZE: primary accumulator for huffman // expand the buffer to as many bits as possible without reading off end of packet // it might be nice to allow f->valid_bits and f->acc to be stored in registers, // e.g. cache them locally and decode locally static __forceinline void prep_huffman(vorb *f) { if (f->valid_bits <= 24) { if (f->valid_bits == 0) f->acc = 0; do { int z; if (f->last_seg && !f->bytes_in_seg) return; z = get8_packet_raw(f); if (z == EOP) return; f->acc += (unsigned) z << f->valid_bits; f->valid_bits += 8; } while (f->valid_bits <= 24); } } enum { VORBIS_packet_id = 1, VORBIS_packet_comment = 3, VORBIS_packet_setup = 5 }; static int codebook_decode_scalar_raw(vorb *f, Codebook *c) { int i; prep_huffman(f); if (c->codewords == NULL && c->sorted_codewords == NULL) return -1; // cases to use binary search: sorted_codewords && !c->codewords // sorted_codewords && c->entries > 8 if (c->entries > 8 ? c->sorted_codewords!=NULL : !c->codewords) { // binary search uint32 code = bit_reverse(f->acc); int x=0, n=c->sorted_entries, len; while (n > 1) { // invariant: sc[x] <= code < sc[x+n] int m = x + (n >> 1); if (c->sorted_codewords[m] <= code) { x = m; n -= (n>>1); } else { n >>= 1; } } // x is now the sorted index if (!c->sparse) x = c->sorted_values[x]; // x is now sorted index if sparse, or symbol otherwise len = c->codeword_lengths[x]; if (f->valid_bits >= len) { f->acc >>= len; f->valid_bits -= len; return x; } f->valid_bits = 0; return -1; } // if small, linear search assert(!c->sparse); for (i=0; i < c->entries; ++i) { if (c->codeword_lengths[i] == NO_CODE) continue; if (c->codewords[i] == (f->acc & ((1 << c->codeword_lengths[i])-1))) { if (f->valid_bits >= c->codeword_lengths[i]) { f->acc >>= c->codeword_lengths[i]; f->valid_bits -= c->codeword_lengths[i]; return i; } f->valid_bits = 0; return -1; } } error(f, VORBIS_invalid_stream); f->valid_bits = 0; return -1; } #ifndef STB_VORBIS_NO_INLINE_DECODE #define DECODE_RAW(var, f,c) \ if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) \ prep_huffman(f); \ var = f->acc & FAST_HUFFMAN_TABLE_MASK; \ var = c->fast_huffman[var]; \ if (var >= 0) { \ int n = c->codeword_lengths[var]; \ f->acc >>= n; \ f->valid_bits -= n; \ if (f->valid_bits < 0) { f->valid_bits = 0; var = -1; } \ } else { \ var = codebook_decode_scalar_raw(f,c); \ } #else static int codebook_decode_scalar(vorb *f, Codebook *c) { int i; if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) prep_huffman(f); // fast huffman table lookup i = f->acc & FAST_HUFFMAN_TABLE_MASK; i = c->fast_huffman[i]; if (i >= 0) { f->acc >>= c->codeword_lengths[i]; f->valid_bits -= c->codeword_lengths[i]; if (f->valid_bits < 0) { f->valid_bits = 0; return -1; } return i; } return codebook_decode_scalar_raw(f,c); } #define DECODE_RAW(var,f,c) var = codebook_decode_scalar(f,c); #endif #define DECODE(var,f,c) \ DECODE_RAW(var,f,c) \ if (c->sparse) var = c->sorted_values[var]; #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK #define DECODE_VQ(var,f,c) DECODE_RAW(var,f,c) #else #define DECODE_VQ(var,f,c) DECODE(var,f,c) #endif // CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case // where we avoid one addition #define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off]) #define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off]) #define CODEBOOK_ELEMENT_BASE(c) (0) static int codebook_decode_start(vorb *f, Codebook *c) { int z = -1; // type 0 is only legal in a scalar context if (c->lookup_type == 0) error(f, VORBIS_invalid_stream); else { DECODE_VQ(z,f,c); if (c->sparse) assert(z < c->sorted_entries); if (z < 0) { // check for EOP if (!f->bytes_in_seg) if (f->last_seg) return z; error(f, VORBIS_invalid_stream); } } return z; } static int codebook_decode(vorb *f, Codebook *c, float *output, int len) { int i,z = codebook_decode_start(f,c); if (z < 0) return FALSE; if (len > c->dimensions) len = c->dimensions; #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK if (c->lookup_type == 1) { float last = CODEBOOK_ELEMENT_BASE(c); int div = 1; for (i=0; i < len; ++i) { int off = (z / div) % c->lookup_values; float val = CODEBOOK_ELEMENT_FAST(c,off) + last; output[i] += val; if (c->sequence_p) last = val + c->minimum_value; div *= c->lookup_values; } return TRUE; } #endif z *= c->dimensions; if (c->sequence_p) { float last = CODEBOOK_ELEMENT_BASE(c); for (i=0; i < len; ++i) { float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; output[i] += val; last = val + c->minimum_value; } } else { float last = CODEBOOK_ELEMENT_BASE(c); for (i=0; i < len; ++i) { output[i] += CODEBOOK_ELEMENT_FAST(c,z+i) + last; } } return TRUE; } static int codebook_decode_step(vorb *f, Codebook *c, float *output, int len, int step) { int i,z = codebook_decode_start(f,c); float last = CODEBOOK_ELEMENT_BASE(c); if (z < 0) return FALSE; if (len > c->dimensions) len = c->dimensions; #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK if (c->lookup_type == 1) { int div = 1; for (i=0; i < len; ++i) { int off = (z / div) % c->lookup_values; float val = CODEBOOK_ELEMENT_FAST(c,off) + last; output[i*step] += val; if (c->sequence_p) last = val; div *= c->lookup_values; } return TRUE; } #endif z *= c->dimensions; for (i=0; i < len; ++i) { float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; output[i*step] += val; if (c->sequence_p) last = val; } return TRUE; } static int codebook_decode_deinterleave_repeat(vorb *f, Codebook *c, float **outputs, int ch, int *c_inter_p, int *p_inter_p, int len, int total_decode) { int c_inter = *c_inter_p; int p_inter = *p_inter_p; int i,z, effective = c->dimensions; // type 0 is only legal in a scalar context if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream); while (total_decode > 0) { float last = CODEBOOK_ELEMENT_BASE(c); DECODE_VQ(z,f,c); #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK assert(!c->sparse || z < c->sorted_entries); #endif if (z < 0) { if (!f->bytes_in_seg) if (f->last_seg) return FALSE; return error(f, VORBIS_invalid_stream); } // if this will take us off the end of the buffers, stop short! // we check by computing the length of the virtual interleaved // buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter), // and the length we'll be using (effective) if (c_inter + p_inter*ch + effective > len * ch) { effective = len*ch - (p_inter*ch - c_inter); } #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK if (c->lookup_type == 1) { int div = 1; for (i=0; i < effective; ++i) { int off = (z / div) % c->lookup_values; float val = CODEBOOK_ELEMENT_FAST(c,off) + last; if (outputs[c_inter]) outputs[c_inter][p_inter] += val; if (++c_inter == ch) { c_inter = 0; ++p_inter; } if (c->sequence_p) last = val; div *= c->lookup_values; } } else #endif { z *= c->dimensions; if (c->sequence_p) { for (i=0; i < effective; ++i) { float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; if (outputs[c_inter]) outputs[c_inter][p_inter] += val; if (++c_inter == ch) { c_inter = 0; ++p_inter; } last = val; } } else { for (i=0; i < effective; ++i) { float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; if (outputs[c_inter]) outputs[c_inter][p_inter] += val; if (++c_inter == ch) { c_inter = 0; ++p_inter; } } } } total_decode -= effective; } *c_inter_p = c_inter; *p_inter_p = p_inter; return TRUE; } static int predict_point(int x, int x0, int x1, int y0, int y1) { int dy = y1 - y0; int adx = x1 - x0; // @OPTIMIZE: force int division to round in the right direction... is this necessary on x86? int err = abs(dy) * (x - x0); int off = err / adx; return dy < 0 ? y0 - off : y0 + off; } // the following table is block-copied from the specification static float inverse_db_table[256] = { 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f, 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f, 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f, 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f, 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f, 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f, 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f, 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f, 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f, 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f, 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f, 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f, 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f, 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f, 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f, 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f, 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f, 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f, 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f, 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f, 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f, 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f, 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f, 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f, 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f, 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f, 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f, 0.82788260f, 0.88168307f, 0.9389798f, 1.0f }; // @OPTIMIZE: if you want to replace this bresenham line-drawing routine, // note that you must produce bit-identical output to decode correctly; // this specific sequence of operations is specified in the spec (it's // drawing integer-quantized frequency-space lines that the encoder // expects to be exactly the same) // ... also, isn't the whole point of Bresenham's algorithm to NOT // have to divide in the setup? sigh. #ifndef STB_VORBIS_NO_DEFER_FLOOR #define LINE_OP(a,b) a *= b #else #define LINE_OP(a,b) a = b #endif #ifdef STB_VORBIS_DIVIDE_TABLE #define DIVTAB_NUMER 32 #define DIVTAB_DENOM 64 int8 integer_divide_table[DIVTAB_NUMER][DIVTAB_DENOM]; // 2KB #endif static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y1, int n) { int dy = y1 - y0; int adx = x1 - x0; int ady = abs(dy); int base; int x=x0,y=y0; int err = 0; int sy; #ifdef STB_VORBIS_DIVIDE_TABLE if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) { if (dy < 0) { base = -integer_divide_table[ady][adx]; sy = base-1; } else { base = integer_divide_table[ady][adx]; sy = base+1; } } else { base = dy / adx; if (dy < 0) sy = base - 1; else sy = base+1; } #else base = dy / adx; if (dy < 0) sy = base - 1; else sy = base+1; #endif ady -= abs(base) * adx; if (x1 > n) x1 = n; if (x < x1) { LINE_OP(output[x], inverse_db_table[y]); for (++x; x < x1; ++x) { err += ady; if (err >= adx) { err -= adx; y += sy; } else y += base; LINE_OP(output[x], inverse_db_table[y]); } } } static int residue_decode(vorb *f, Codebook *book, float *target, int offset, int n, int rtype) { int k; if (rtype == 0) { int step = n / book->dimensions; for (k=0; k < step; ++k) if (!codebook_decode_step(f, book, target+offset+k, n-offset-k, step)) return FALSE; } else { for (k=0; k < n; ) { if (!codebook_decode(f, book, target+offset, n-k)) return FALSE; k += book->dimensions; offset += book->dimensions; } } return TRUE; } static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int rn, uint8 *do_not_decode) { int i,j,pass; Residue *r = f->residue_config + rn; int rtype = f->residue_types[rn]; int c = r->classbook; int classwords = f->codebooks[c].dimensions; int n_read = r->end - r->begin; int part_read = n_read / r->part_size; int temp_alloc_point = temp_alloc_save(f); #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE uint8 ***part_classdata = (uint8 ***) temp_block_array(f,f->channels, part_read * sizeof(**part_classdata)); #else int **classifications = (int **) temp_block_array(f,f->channels, part_read * sizeof(**classifications)); #endif CHECK(f); for (i=0; i < ch; ++i) if (!do_not_decode[i]) memset(residue_buffers[i], 0, sizeof(float) * n); if (rtype == 2 && ch != 1) { for (j=0; j < ch; ++j) if (!do_not_decode[j]) break; if (j == ch) goto done; for (pass=0; pass < 8; ++pass) { int pcount = 0, class_set = 0; if (ch == 2) { while (pcount < part_read) { int z = r->begin + pcount*r->part_size; int c_inter = (z & 1), p_inter = z>>1; if (pass == 0) { Codebook *c = f->codebooks+r->classbook; int q; DECODE(q,f,c); if (q == EOP) goto done; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE part_classdata[0][class_set] = r->classdata[q]; #else for (i=classwords-1; i >= 0; --i) { classifications[0][i+pcount] = q % r->classifications; q /= r->classifications; } #endif } for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { int z = r->begin + pcount*r->part_size; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE int c = part_classdata[0][class_set][i]; #else int c = classifications[0][pcount]; #endif int b = r->residue_books[c][pass]; if (b >= 0) { Codebook *book = f->codebooks + b; #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) goto done; #else // saves 1% if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) goto done; #endif } else { z += r->part_size; c_inter = z & 1; p_inter = z >> 1; } } #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE ++class_set; #endif } } else if (ch == 1) { while (pcount < part_read) { int z = r->begin + pcount*r->part_size; int c_inter = 0, p_inter = z; if (pass == 0) { Codebook *c = f->codebooks+r->classbook; int q; DECODE(q,f,c); if (q == EOP) goto done; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE part_classdata[0][class_set] = r->classdata[q]; #else for (i=classwords-1; i >= 0; --i) { classifications[0][i+pcount] = q % r->classifications; q /= r->classifications; } #endif } for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { int z = r->begin + pcount*r->part_size; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE int c = part_classdata[0][class_set][i]; #else int c = classifications[0][pcount]; #endif int b = r->residue_books[c][pass]; if (b >= 0) { Codebook *book = f->codebooks + b; if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) goto done; } else { z += r->part_size; c_inter = 0; p_inter = z; } } #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE ++class_set; #endif } } else { while (pcount < part_read) { int z = r->begin + pcount*r->part_size; int c_inter = z % ch, p_inter = z/ch; if (pass == 0) { Codebook *c = f->codebooks+r->classbook; int q; DECODE(q,f,c); if (q == EOP) goto done; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE part_classdata[0][class_set] = r->classdata[q]; #else for (i=classwords-1; i >= 0; --i) { classifications[0][i+pcount] = q % r->classifications; q /= r->classifications; } #endif } for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { int z = r->begin + pcount*r->part_size; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE int c = part_classdata[0][class_set][i]; #else int c = classifications[0][pcount]; #endif int b = r->residue_books[c][pass]; if (b >= 0) { Codebook *book = f->codebooks + b; if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) goto done; } else { z += r->part_size; c_inter = z % ch; p_inter = z / ch; } } #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE ++class_set; #endif } } } goto done; } CHECK(f); for (pass=0; pass < 8; ++pass) { int pcount = 0, class_set=0; while (pcount < part_read) { if (pass == 0) { for (j=0; j < ch; ++j) { if (!do_not_decode[j]) { Codebook *c = f->codebooks+r->classbook; int temp; DECODE(temp,f,c); if (temp == EOP) goto done; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE part_classdata[j][class_set] = r->classdata[temp]; #else for (i=classwords-1; i >= 0; --i) { classifications[j][i+pcount] = temp % r->classifications; temp /= r->classifications; } #endif } } } for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { for (j=0; j < ch; ++j) { if (!do_not_decode[j]) { #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE int c = part_classdata[j][class_set][i]; #else int c = classifications[j][pcount]; #endif int b = r->residue_books[c][pass]; if (b >= 0) { float *target = residue_buffers[j]; int offset = r->begin + pcount * r->part_size; int n = r->part_size; Codebook *book = f->codebooks + b; if (!residue_decode(f, book, target, offset, n, rtype)) goto done; } } } } #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE ++class_set; #endif } } done: CHECK(f); #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE temp_free(f,part_classdata); #else temp_free(f,classifications); #endif temp_alloc_restore(f,temp_alloc_point); } #if 0 // slow way for debugging void inverse_mdct_slow(float *buffer, int n) { int i,j; int n2 = n >> 1; float *x = (float *) malloc(sizeof(*x) * n2); memcpy(x, buffer, sizeof(*x) * n2); for (i=0; i < n; ++i) { float acc = 0; for (j=0; j < n2; ++j) // formula from paper: //acc += n/4.0f * x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1)); // formula from wikipedia //acc += 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5)); // these are equivalent, except the formula from the paper inverts the multiplier! // however, what actually works is NO MULTIPLIER!?! //acc += 64 * 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5)); acc += x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1)); buffer[i] = acc; } free(x); } #elif 0 // same as above, but just barely able to run in real time on modern machines void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) { float mcos[16384]; int i,j; int n2 = n >> 1, nmask = (n << 2) -1; float *x = (float *) malloc(sizeof(*x) * n2); memcpy(x, buffer, sizeof(*x) * n2); for (i=0; i < 4*n; ++i) mcos[i] = (float) cos(M_PI / 2 * i / n); for (i=0; i < n; ++i) { float acc = 0; for (j=0; j < n2; ++j) acc += x[j] * mcos[(2 * i + 1 + n2)*(2*j+1) & nmask]; buffer[i] = acc; } free(x); } #elif 0 // transform to use a slow dct-iv; this is STILL basically trivial, // but only requires half as many ops void dct_iv_slow(float *buffer, int n) { float mcos[16384]; float x[2048]; int i,j; int n2 = n >> 1, nmask = (n << 3) - 1; memcpy(x, buffer, sizeof(*x) * n); for (i=0; i < 8*n; ++i) mcos[i] = (float) cos(M_PI / 4 * i / n); for (i=0; i < n; ++i) { float acc = 0; for (j=0; j < n; ++j) acc += x[j] * mcos[((2 * i + 1)*(2*j+1)) & nmask]; buffer[i] = acc; } } void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) { int i, n4 = n >> 2, n2 = n >> 1, n3_4 = n - n4; float temp[4096]; memcpy(temp, buffer, n2 * sizeof(float)); dct_iv_slow(temp, n2); // returns -c'-d, a-b' for (i=0; i < n4 ; ++i) buffer[i] = temp[i+n4]; // a-b' for ( ; i < n3_4; ++i) buffer[i] = -temp[n3_4 - i - 1]; // b-a', c+d' for ( ; i < n ; ++i) buffer[i] = -temp[i - n3_4]; // c'+d } #endif #ifndef LIBVORBIS_MDCT #define LIBVORBIS_MDCT 0 #endif #if LIBVORBIS_MDCT // directly call the vorbis MDCT using an interface documented // by Jeff Roberts... useful for performance comparison typedef struct { int n; int log2n; float *trig; int *bitrev; float scale; } mdct_lookup; extern void mdct_init(mdct_lookup *lookup, int n); extern void mdct_clear(mdct_lookup *l); extern void mdct_backward(mdct_lookup *init, float *in, float *out); mdct_lookup M1,M2; void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) { mdct_lookup *M; if (M1.n == n) M = &M1; else if (M2.n == n) M = &M2; else if (M1.n == 0) { mdct_init(&M1, n); M = &M1; } else { if (M2.n) __asm int 3; mdct_init(&M2, n); M = &M2; } mdct_backward(M, buffer, buffer); } #endif // the following were split out into separate functions while optimizing; // they could be pushed back up but eh. __forceinline showed no change; // they're probably already being inlined. static void imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, float *A) { float *ee0 = e + i_off; float *ee2 = ee0 + k_off; int i; assert((n & 3) == 0); for (i=(n>>2); i > 0; --i) { float k00_20, k01_21; k00_20 = ee0[ 0] - ee2[ 0]; k01_21 = ee0[-1] - ee2[-1]; ee0[ 0] += ee2[ 0];//ee0[ 0] = ee0[ 0] + ee2[ 0]; ee0[-1] += ee2[-1];//ee0[-1] = ee0[-1] + ee2[-1]; ee2[ 0] = k00_20 * A[0] - k01_21 * A[1]; ee2[-1] = k01_21 * A[0] + k00_20 * A[1]; A += 8; k00_20 = ee0[-2] - ee2[-2]; k01_21 = ee0[-3] - ee2[-3]; ee0[-2] += ee2[-2];//ee0[-2] = ee0[-2] + ee2[-2]; ee0[-3] += ee2[-3];//ee0[-3] = ee0[-3] + ee2[-3]; ee2[-2] = k00_20 * A[0] - k01_21 * A[1]; ee2[-3] = k01_21 * A[0] + k00_20 * A[1]; A += 8; k00_20 = ee0[-4] - ee2[-4]; k01_21 = ee0[-5] - ee2[-5]; ee0[-4] += ee2[-4];//ee0[-4] = ee0[-4] + ee2[-4]; ee0[-5] += ee2[-5];//ee0[-5] = ee0[-5] + ee2[-5]; ee2[-4] = k00_20 * A[0] - k01_21 * A[1]; ee2[-5] = k01_21 * A[0] + k00_20 * A[1]; A += 8; k00_20 = ee0[-6] - ee2[-6]; k01_21 = ee0[-7] - ee2[-7]; ee0[-6] += ee2[-6];//ee0[-6] = ee0[-6] + ee2[-6]; ee0[-7] += ee2[-7];//ee0[-7] = ee0[-7] + ee2[-7]; ee2[-6] = k00_20 * A[0] - k01_21 * A[1]; ee2[-7] = k01_21 * A[0] + k00_20 * A[1]; A += 8; ee0 -= 8; ee2 -= 8; } } static void imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off, float *A, int k1) { int i; float k00_20, k01_21; float *e0 = e + d0; float *e2 = e0 + k_off; for (i=lim >> 2; i > 0; --i) { k00_20 = e0[-0] - e2[-0]; k01_21 = e0[-1] - e2[-1]; e0[-0] += e2[-0];//e0[-0] = e0[-0] + e2[-0]; e0[-1] += e2[-1];//e0[-1] = e0[-1] + e2[-1]; e2[-0] = (k00_20)*A[0] - (k01_21) * A[1]; e2[-1] = (k01_21)*A[0] + (k00_20) * A[1]; A += k1; k00_20 = e0[-2] - e2[-2]; k01_21 = e0[-3] - e2[-3]; e0[-2] += e2[-2];//e0[-2] = e0[-2] + e2[-2]; e0[-3] += e2[-3];//e0[-3] = e0[-3] + e2[-3]; e2[-2] = (k00_20)*A[0] - (k01_21) * A[1]; e2[-3] = (k01_21)*A[0] + (k00_20) * A[1]; A += k1; k00_20 = e0[-4] - e2[-4]; k01_21 = e0[-5] - e2[-5]; e0[-4] += e2[-4];//e0[-4] = e0[-4] + e2[-4]; e0[-5] += e2[-5];//e0[-5] = e0[-5] + e2[-5]; e2[-4] = (k00_20)*A[0] - (k01_21) * A[1]; e2[-5] = (k01_21)*A[0] + (k00_20) * A[1]; A += k1; k00_20 = e0[-6] - e2[-6]; k01_21 = e0[-7] - e2[-7]; e0[-6] += e2[-6];//e0[-6] = e0[-6] + e2[-6]; e0[-7] += e2[-7];//e0[-7] = e0[-7] + e2[-7]; e2[-6] = (k00_20)*A[0] - (k01_21) * A[1]; e2[-7] = (k01_21)*A[0] + (k00_20) * A[1]; e0 -= 8; e2 -= 8; A += k1; } } static void imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off, float *A, int a_off, int k0) { int i; float A0 = A[0]; float A1 = A[0+1]; float A2 = A[0+a_off]; float A3 = A[0+a_off+1]; float A4 = A[0+a_off*2+0]; float A5 = A[0+a_off*2+1]; float A6 = A[0+a_off*3+0]; float A7 = A[0+a_off*3+1]; float k00,k11; float *ee0 = e +i_off; float *ee2 = ee0+k_off; for (i=n; i > 0; --i) { k00 = ee0[ 0] - ee2[ 0]; k11 = ee0[-1] - ee2[-1]; ee0[ 0] = ee0[ 0] + ee2[ 0]; ee0[-1] = ee0[-1] + ee2[-1]; ee2[ 0] = (k00) * A0 - (k11) * A1; ee2[-1] = (k11) * A0 + (k00) * A1; k00 = ee0[-2] - ee2[-2]; k11 = ee0[-3] - ee2[-3]; ee0[-2] = ee0[-2] + ee2[-2]; ee0[-3] = ee0[-3] + ee2[-3]; ee2[-2] = (k00) * A2 - (k11) * A3; ee2[-3] = (k11) * A2 + (k00) * A3; k00 = ee0[-4] - ee2[-4]; k11 = ee0[-5] - ee2[-5]; ee0[-4] = ee0[-4] + ee2[-4]; ee0[-5] = ee0[-5] + ee2[-5]; ee2[-4] = (k00) * A4 - (k11) * A5; ee2[-5] = (k11) * A4 + (k00) * A5; k00 = ee0[-6] - ee2[-6]; k11 = ee0[-7] - ee2[-7]; ee0[-6] = ee0[-6] + ee2[-6]; ee0[-7] = ee0[-7] + ee2[-7]; ee2[-6] = (k00) * A6 - (k11) * A7; ee2[-7] = (k11) * A6 + (k00) * A7; ee0 -= k0; ee2 -= k0; } } static __forceinline void iter_54(float *z) { float k00,k11,k22,k33; float y0,y1,y2,y3; k00 = z[ 0] - z[-4]; y0 = z[ 0] + z[-4]; y2 = z[-2] + z[-6]; k22 = z[-2] - z[-6]; z[-0] = y0 + y2; // z0 + z4 + z2 + z6 z[-2] = y0 - y2; // z0 + z4 - z2 - z6 // done with y0,y2 k33 = z[-3] - z[-7]; z[-4] = k00 + k33; // z0 - z4 + z3 - z7 z[-6] = k00 - k33; // z0 - z4 - z3 + z7 // done with k33 k11 = z[-1] - z[-5]; y1 = z[-1] + z[-5]; y3 = z[-3] + z[-7]; z[-1] = y1 + y3; // z1 + z5 + z3 + z7 z[-3] = y1 - y3; // z1 + z5 - z3 - z7 z[-5] = k11 - k22; // z1 - z5 + z2 - z6 z[-7] = k11 + k22; // z1 - z5 - z2 + z6 } static void imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n) { int a_off = base_n >> 3; float A2 = A[0+a_off]; float *z = e + i_off; float *base = z - 16 * n; while (z > base) { float k00,k11; k00 = z[-0] - z[-8]; k11 = z[-1] - z[-9]; z[-0] = z[-0] + z[-8]; z[-1] = z[-1] + z[-9]; z[-8] = k00; z[-9] = k11 ; k00 = z[ -2] - z[-10]; k11 = z[ -3] - z[-11]; z[ -2] = z[ -2] + z[-10]; z[ -3] = z[ -3] + z[-11]; z[-10] = (k00+k11) * A2; z[-11] = (k11-k00) * A2; k00 = z[-12] - z[ -4]; // reverse to avoid a unary negation k11 = z[ -5] - z[-13]; z[ -4] = z[ -4] + z[-12]; z[ -5] = z[ -5] + z[-13]; z[-12] = k11; z[-13] = k00; k00 = z[-14] - z[ -6]; // reverse to avoid a unary negation k11 = z[ -7] - z[-15]; z[ -6] = z[ -6] + z[-14]; z[ -7] = z[ -7] + z[-15]; z[-14] = (k00+k11) * A2; z[-15] = (k00-k11) * A2; iter_54(z); iter_54(z-8); z -= 16; } } static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) { int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; int ld; // @OPTIMIZE: reduce register pressure by using fewer variables? int save_point = temp_alloc_save(f); float *buf2 = (float *) temp_alloc(f, n2 * sizeof(*buf2)); float *u=NULL,*v=NULL; // twiddle factors float *A = f->A[blocktype]; // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio" // See notes about bugs in that paper in less-optimal implementation 'inverse_mdct_old' after this function. // kernel from paper // merged: // copy and reflect spectral data // step 0 // note that it turns out that the items added together during // this step are, in fact, being added to themselves (as reflected // by step 0). inexplicable inefficiency! this became obvious // once I combined the passes. // so there's a missing 'times 2' here (for adding X to itself). // this propogates through linearly to the end, where the numbers // are 1/2 too small, and need to be compensated for. { float *d,*e, *AA, *e_stop; d = &buf2[n2-2]; AA = A; e = &buffer[0]; e_stop = &buffer[n2]; while (e != e_stop) { d[1] = (e[0] * AA[0] - e[2]*AA[1]); d[0] = (e[0] * AA[1] + e[2]*AA[0]); d -= 2; AA += 2; e += 4; } e = &buffer[n2-3]; while (d >= buf2) { d[1] = (-e[2] * AA[0] - -e[0]*AA[1]); d[0] = (-e[2] * AA[1] + -e[0]*AA[0]); d -= 2; AA += 2; e -= 4; } } // now we use symbolic names for these, so that we can // possibly swap their meaning as we change which operations // are in place u = buffer; v = buf2; // step 2 (paper output is w, now u) // this could be in place, but the data ends up in the wrong // place... _somebody_'s got to swap it, so this is nominated { float *AA = &A[n2-8]; float *d0,*d1, *e0, *e1; e0 = &v[n4]; e1 = &v[0]; d0 = &u[n4]; d1 = &u[0]; while (AA >= A) { float v40_20, v41_21; v41_21 = e0[1] - e1[1]; v40_20 = e0[0] - e1[0]; d0[1] = e0[1] + e1[1]; d0[0] = e0[0] + e1[0]; d1[1] = v41_21*AA[4] - v40_20*AA[5]; d1[0] = v40_20*AA[4] + v41_21*AA[5]; v41_21 = e0[3] - e1[3]; v40_20 = e0[2] - e1[2]; d0[3] = e0[3] + e1[3]; d0[2] = e0[2] + e1[2]; d1[3] = v41_21*AA[0] - v40_20*AA[1]; d1[2] = v40_20*AA[0] + v41_21*AA[1]; AA -= 8; d0 += 4; d1 += 4; e0 += 4; e1 += 4; } } // step 3 ld = ilog(n) - 1; // ilog is off-by-one from normal definitions // optimized step 3: // the original step3 loop can be nested r inside s or s inside r; // it's written originally as s inside r, but this is dumb when r // iterates many times, and s few. So I have two copies of it and // switch between them halfway. // this is iteration 0 of step 3 imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A); imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A); // this is iteration 1 of step 3 imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16); imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16); imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16); imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16); l=2; for (; l < (ld-3)>>1; ++l) { int k0 = n >> (l+2), k0_2 = k0>>1; int lim = 1 << (l+1); int i; for (i=0; i < lim; ++i) imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3)); } for (; l < ld-6; ++l) { int k0 = n >> (l+2), k1 = 1 << (l+3), k0_2 = k0>>1; int rlim = n >> (l+6), r; int lim = 1 << (l+1); int i_off; float *A0 = A; i_off = n2-1; for (r=rlim; r > 0; --r) { imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0); A0 += k1*4; i_off -= 8; } } // iterations with count: // ld-6,-5,-4 all interleaved together // the big win comes from getting rid of needless flops // due to the constants on pass 5 & 4 being all 1 and 0; // combining them to be simultaneous to improve cache made little difference imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n); // output is u // step 4, 5, and 6 // cannot be in-place because of step 5 { uint16 *bitrev = f->bit_reverse[blocktype]; // weirdly, I'd have thought reading sequentially and writing // erratically would have been better than vice-versa, but in // fact that's not what my testing showed. (That is, with // j = bitreverse(i), do you read i and write j, or read j and write i.) float *d0 = &v[n4-4]; float *d1 = &v[n2-4]; while (d0 >= v) { int k4; k4 = bitrev[0]; d1[3] = u[k4+0]; d1[2] = u[k4+1]; d0[3] = u[k4+2]; d0[2] = u[k4+3]; k4 = bitrev[1]; d1[1] = u[k4+0]; d1[0] = u[k4+1]; d0[1] = u[k4+2]; d0[0] = u[k4+3]; d0 -= 4; d1 -= 4; bitrev += 2; } } // (paper output is u, now v) // data must be in buf2 assert(v == buf2); // step 7 (paper output is v, now v) // this is now in place { float *C = f->C[blocktype]; float *d, *e; d = v; e = v + n2 - 4; while (d < e) { float a02,a11,b0,b1,b2,b3; a02 = d[0] - e[2]; a11 = d[1] + e[3]; b0 = C[1]*a02 + C[0]*a11; b1 = C[1]*a11 - C[0]*a02; b2 = d[0] + e[ 2]; b3 = d[1] - e[ 3]; d[0] = b2 + b0; d[1] = b3 + b1; e[2] = b2 - b0; e[3] = b1 - b3; a02 = d[2] - e[0]; a11 = d[3] + e[1]; b0 = C[3]*a02 + C[2]*a11; b1 = C[3]*a11 - C[2]*a02; b2 = d[2] + e[ 0]; b3 = d[3] - e[ 1]; d[2] = b2 + b0; d[3] = b3 + b1; e[0] = b2 - b0; e[1] = b1 - b3; C += 4; d += 4; e -= 4; } } // data must be in buf2 // step 8+decode (paper output is X, now buffer) // this generates pairs of data a la 8 and pushes them directly through // the decode kernel (pushing rather than pulling) to avoid having // to make another pass later // this cannot POSSIBLY be in place, so we refer to the buffers directly { float *d0,*d1,*d2,*d3; float *B = f->B[blocktype] + n2 - 8; float *e = buf2 + n2 - 8; d0 = &buffer[0]; d1 = &buffer[n2-4]; d2 = &buffer[n2]; d3 = &buffer[n-4]; while (e >= v) { float p0,p1,p2,p3; p3 = e[6]*B[7] - e[7]*B[6]; p2 = -e[6]*B[6] - e[7]*B[7]; d0[0] = p3; d1[3] = - p3; d2[0] = p2; d3[3] = p2; p1 = e[4]*B[5] - e[5]*B[4]; p0 = -e[4]*B[4] - e[5]*B[5]; d0[1] = p1; d1[2] = - p1; d2[1] = p0; d3[2] = p0; p3 = e[2]*B[3] - e[3]*B[2]; p2 = -e[2]*B[2] - e[3]*B[3]; d0[2] = p3; d1[1] = - p3; d2[2] = p2; d3[1] = p2; p1 = e[0]*B[1] - e[1]*B[0]; p0 = -e[0]*B[0] - e[1]*B[1]; d0[3] = p1; d1[0] = - p1; d2[3] = p0; d3[0] = p0; B -= 8; e -= 8; d0 += 4; d2 += 4; d1 -= 4; d3 -= 4; } } temp_free(f,buf2); temp_alloc_restore(f,save_point); } #if 0 // this is the original version of the above code, if you want to optimize it from scratch void inverse_mdct_naive(float *buffer, int n) { float s; float A[1 << 12], B[1 << 12], C[1 << 11]; int i,k,k2,k4, n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; int n3_4 = n - n4, ld; // how can they claim this only uses N words?! // oh, because they're only used sparsely, whoops float u[1 << 13], X[1 << 13], v[1 << 13], w[1 << 13]; // set up twiddle factors for (k=k2=0; k < n4; ++k,k2+=2) { A[k2 ] = (float) cos(4*k*M_PI/n); A[k2+1] = (float) -sin(4*k*M_PI/n); B[k2 ] = (float) cos((k2+1)*M_PI/n/2); B[k2+1] = (float) sin((k2+1)*M_PI/n/2); } for (k=k2=0; k < n8; ++k,k2+=2) { C[k2 ] = (float) cos(2*(k2+1)*M_PI/n); C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n); } // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio" // Note there are bugs in that pseudocode, presumably due to them attempting // to rename the arrays nicely rather than representing the way their actual // implementation bounces buffers back and forth. As a result, even in the // "some formulars corrected" version, a direct implementation fails. These // are noted below as "paper bug". // copy and reflect spectral data for (k=0; k < n2; ++k) u[k] = buffer[k]; for ( ; k < n ; ++k) u[k] = -buffer[n - k - 1]; // kernel from paper // step 1 for (k=k2=k4=0; k < n4; k+=1, k2+=2, k4+=4) { v[n-k4-1] = (u[k4] - u[n-k4-1]) * A[k2] - (u[k4+2] - u[n-k4-3])*A[k2+1]; v[n-k4-3] = (u[k4] - u[n-k4-1]) * A[k2+1] + (u[k4+2] - u[n-k4-3])*A[k2]; } // step 2 for (k=k4=0; k < n8; k+=1, k4+=4) { w[n2+3+k4] = v[n2+3+k4] + v[k4+3]; w[n2+1+k4] = v[n2+1+k4] + v[k4+1]; w[k4+3] = (v[n2+3+k4] - v[k4+3])*A[n2-4-k4] - (v[n2+1+k4]-v[k4+1])*A[n2-3-k4]; w[k4+1] = (v[n2+1+k4] - v[k4+1])*A[n2-4-k4] + (v[n2+3+k4]-v[k4+3])*A[n2-3-k4]; } // step 3 ld = ilog(n) - 1; // ilog is off-by-one from normal definitions for (l=0; l < ld-3; ++l) { int k0 = n >> (l+2), k1 = 1 << (l+3); int rlim = n >> (l+4), r4, r; int s2lim = 1 << (l+2), s2; for (r=r4=0; r < rlim; r4+=4,++r) { for (s2=0; s2 < s2lim; s2+=2) { u[n-1-k0*s2-r4] = w[n-1-k0*s2-r4] + w[n-1-k0*(s2+1)-r4]; u[n-3-k0*s2-r4] = w[n-3-k0*s2-r4] + w[n-3-k0*(s2+1)-r4]; u[n-1-k0*(s2+1)-r4] = (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1] - (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1+1]; u[n-3-k0*(s2+1)-r4] = (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1] + (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1+1]; } } if (l+1 < ld-3) { // paper bug: ping-ponging of u&w here is omitted memcpy(w, u, sizeof(u)); } } // step 4 for (i=0; i < n8; ++i) { int j = bit_reverse(i) >> (32-ld+3); assert(j < n8); if (i == j) { // paper bug: original code probably swapped in place; if copying, // need to directly copy in this case int i8 = i << 3; v[i8+1] = u[i8+1]; v[i8+3] = u[i8+3]; v[i8+5] = u[i8+5]; v[i8+7] = u[i8+7]; } else if (i < j) { int i8 = i << 3, j8 = j << 3; v[j8+1] = u[i8+1], v[i8+1] = u[j8 + 1]; v[j8+3] = u[i8+3], v[i8+3] = u[j8 + 3]; v[j8+5] = u[i8+5], v[i8+5] = u[j8 + 5]; v[j8+7] = u[i8+7], v[i8+7] = u[j8 + 7]; } } // step 5 for (k=0; k < n2; ++k) { w[k] = v[k*2+1]; } // step 6 for (k=k2=k4=0; k < n8; ++k, k2 += 2, k4 += 4) { u[n-1-k2] = w[k4]; u[n-2-k2] = w[k4+1]; u[n3_4 - 1 - k2] = w[k4+2]; u[n3_4 - 2 - k2] = w[k4+3]; } // step 7 for (k=k2=0; k < n8; ++k, k2 += 2) { v[n2 + k2 ] = ( u[n2 + k2] + u[n-2-k2] + C[k2+1]*(u[n2+k2]-u[n-2-k2]) + C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2; v[n-2 - k2] = ( u[n2 + k2] + u[n-2-k2] - C[k2+1]*(u[n2+k2]-u[n-2-k2]) - C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2; v[n2+1+ k2] = ( u[n2+1+k2] - u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2; v[n-1 - k2] = (-u[n2+1+k2] + u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2; } // step 8 for (k=k2=0; k < n4; ++k,k2 += 2) { X[k] = v[k2+n2]*B[k2 ] + v[k2+1+n2]*B[k2+1]; X[n2-1-k] = v[k2+n2]*B[k2+1] - v[k2+1+n2]*B[k2 ]; } // decode kernel to output // determined the following value experimentally // (by first figuring out what made inverse_mdct_slow work); then matching that here // (probably vorbis encoder premultiplies by n or n/2, to save it on the decoder?) s = 0.5; // theoretically would be n4 // [[[ note! the s value of 0.5 is compensated for by the B[] in the current code, // so it needs to use the "old" B values to behave correctly, or else // set s to 1.0 ]]] for (i=0; i < n4 ; ++i) buffer[i] = s * X[i+n4]; for ( ; i < n3_4; ++i) buffer[i] = -s * X[n3_4 - i - 1]; for ( ; i < n ; ++i) buffer[i] = -s * X[i - n3_4]; } #endif static float *get_window(vorb *f, int len) { len <<= 1; if (len == f->blocksize_0) return f->window[0]; if (len == f->blocksize_1) return f->window[1]; assert(0); return NULL; } #ifndef STB_VORBIS_NO_DEFER_FLOOR typedef int16 YTYPE; #else typedef int YTYPE; #endif static int do_floor(vorb *f, Mapping *map, int i, int n, float *target, YTYPE *finalY, uint8 *step2_flag) { int n2 = n >> 1; int s = map->chan[i].mux, floor; floor = map->submap_floor[s]; if (f->floor_types[floor] == 0) { return error(f, VORBIS_invalid_stream); } else { Floor1 *g = &f->floor_config[floor].floor1; int j,q; int lx = 0, ly = finalY[0] * g->floor1_multiplier; for (q=1; q < g->values; ++q) { j = g->sorted_order[q]; #ifndef STB_VORBIS_NO_DEFER_FLOOR if (finalY[j] >= 0) #else if (step2_flag[j]) #endif { int hy = finalY[j] * g->floor1_multiplier; int hx = g->Xlist[j]; if (lx != hx) draw_line(target, lx,ly, hx,hy, n2); CHECK(f); lx = hx, ly = hy; } } if (lx < n2) { // optimization of: draw_line(target, lx,ly, n,ly, n2); for (j=lx; j < n2; ++j) LINE_OP(target[j], inverse_db_table[ly]); CHECK(f); } } return TRUE; } // The meaning of "left" and "right" // // For a given frame: // we compute samples from 0..n // window_center is n/2 // we'll window and mix the samples from left_start to left_end with data from the previous frame // all of the samples from left_end to right_start can be output without mixing; however, // this interval is 0-length except when transitioning between short and long frames // all of the samples from right_start to right_end need to be mixed with the next frame, // which we don't have, so those get saved in a buffer // frame N's right_end-right_start, the number of samples to mix with the next frame, // has to be the same as frame N+1's left_end-left_start (which they are by // construction) static int vorbis_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode) { Mode *m; int i, n, prev, next, window_center; f->channel_buffer_start = f->channel_buffer_end = 0; retry: if (f->eof) return FALSE; if (!maybe_start_packet(f)) return FALSE; // check packet type if (get_bits(f,1) != 0) { if (IS_PUSH_MODE(f)) return error(f,VORBIS_bad_packet_type); while (EOP != get8_packet(f)); goto retry; } if (f->alloc.alloc_buffer) assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); i = get_bits(f, ilog(f->mode_count-1)); if (i == EOP) return FALSE; if (i >= f->mode_count) return FALSE; *mode = i; m = f->mode_config + i; if (m->blockflag) { n = f->blocksize_1; prev = get_bits(f,1); next = get_bits(f,1); } else { prev = next = 0; n = f->blocksize_0; } // WINDOWING window_center = n >> 1; if (m->blockflag && !prev) { *p_left_start = (n - f->blocksize_0) >> 2; *p_left_end = (n + f->blocksize_0) >> 2; } else { *p_left_start = 0; *p_left_end = window_center; } if (m->blockflag && !next) { *p_right_start = (n*3 - f->blocksize_0) >> 2; *p_right_end = (n*3 + f->blocksize_0) >> 2; } else { *p_right_start = window_center; *p_right_end = n; } return TRUE; } static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, int left_end, int right_start, int right_end, int *p_left) { Mapping *map; int i,j,k,n,n2; int zero_channel[256]; int really_zero_channel[256]; // WINDOWING n = f->blocksize[m->blockflag]; map = &f->mapping[m->mapping]; // FLOORS n2 = n >> 1; CHECK(f); for (i=0; i < f->channels; ++i) { int s = map->chan[i].mux, floor; zero_channel[i] = FALSE; floor = map->submap_floor[s]; if (f->floor_types[floor] == 0) { return error(f, VORBIS_invalid_stream); } else { Floor1 *g = &f->floor_config[floor].floor1; if (get_bits(f, 1)) { short *finalY; uint8 step2_flag[256]; static int range_list[4] = { 256, 128, 86, 64 }; int range = range_list[g->floor1_multiplier-1]; int offset = 2; finalY = f->finalY[i]; finalY[0] = get_bits(f, ilog(range)-1); finalY[1] = get_bits(f, ilog(range)-1); for (j=0; j < g->partitions; ++j) { int pclass = g->partition_class_list[j]; int cdim = g->class_dimensions[pclass]; int cbits = g->class_subclasses[pclass]; int csub = (1 << cbits)-1; int cval = 0; if (cbits) { Codebook *c = f->codebooks + g->class_masterbooks[pclass]; DECODE(cval,f,c); } for (k=0; k < cdim; ++k) { int book = g->subclass_books[pclass][cval & csub]; cval = cval >> cbits; if (book >= 0) { int temp; Codebook *c = f->codebooks + book; DECODE(temp,f,c); finalY[offset++] = temp; } else finalY[offset++] = 0; } } if (f->valid_bits == INVALID_BITS) goto error; // behavior according to spec step2_flag[0] = step2_flag[1] = 1; for (j=2; j < g->values; ++j) { int low, high, pred, highroom, lowroom, room, val; low = g->neighbors[j][0]; high = g->neighbors[j][1]; //neighbors(g->Xlist, j, &low, &high); pred = predict_point(g->Xlist[j], g->Xlist[low], g->Xlist[high], finalY[low], finalY[high]); val = finalY[j]; highroom = range - pred; lowroom = pred; if (highroom < lowroom) room = highroom * 2; else room = lowroom * 2; if (val) { step2_flag[low] = step2_flag[high] = 1; step2_flag[j] = 1; if (val >= room) if (highroom > lowroom) finalY[j] = val - lowroom + pred; else finalY[j] = pred - val + highroom - 1; else if (val & 1) finalY[j] = pred - ((val+1)>>1); else finalY[j] = pred + (val>>1); } else { step2_flag[j] = 0; finalY[j] = pred; } } #ifdef STB_VORBIS_NO_DEFER_FLOOR do_floor(f, map, i, n, f->floor_buffers[i], finalY, step2_flag); #else // defer final floor computation until _after_ residue for (j=0; j < g->values; ++j) { if (!step2_flag[j]) finalY[j] = -1; } #endif } else { error: zero_channel[i] = TRUE; } // So we just defer everything else to later // at this point we've decoded the floor into buffer } } CHECK(f); // at this point we've decoded all floors if (f->alloc.alloc_buffer) assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); // re-enable coupled channels if necessary memcpy(really_zero_channel, zero_channel, sizeof(really_zero_channel[0]) * f->channels); for (i=0; i < map->coupling_steps; ++i) if (!zero_channel[map->chan[i].magnitude] || !zero_channel[map->chan[i].angle]) { zero_channel[map->chan[i].magnitude] = zero_channel[map->chan[i].angle] = FALSE; } CHECK(f); // RESIDUE DECODE for (i=0; i < map->submaps; ++i) { float *residue_buffers[STB_VORBIS_MAX_CHANNELS]; int r; uint8 do_not_decode[256]; int ch = 0; for (j=0; j < f->channels; ++j) { if (map->chan[j].mux == i) { if (zero_channel[j]) { do_not_decode[ch] = TRUE; residue_buffers[ch] = NULL; } else { do_not_decode[ch] = FALSE; residue_buffers[ch] = f->channel_buffers[j]; } ++ch; } } r = map->submap_residue[i]; decode_residue(f, residue_buffers, ch, n2, r, do_not_decode); } if (f->alloc.alloc_buffer) assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); CHECK(f); // INVERSE COUPLING for (i = map->coupling_steps-1; i >= 0; --i) { int n2 = n >> 1; float *m = f->channel_buffers[map->chan[i].magnitude]; float *a = f->channel_buffers[map->chan[i].angle ]; for (j=0; j < n2; ++j) { float a2,m2; if (m[j] > 0) if (a[j] > 0) m2 = m[j], a2 = m[j] - a[j]; else a2 = m[j], m2 = m[j] + a[j]; else if (a[j] > 0) m2 = m[j], a2 = m[j] + a[j]; else a2 = m[j], m2 = m[j] - a[j]; m[j] = m2; a[j] = a2; } } CHECK(f); // finish decoding the floors #ifndef STB_VORBIS_NO_DEFER_FLOOR for (i=0; i < f->channels; ++i) { if (really_zero_channel[i]) { memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); } else { do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL); } } #else for (i=0; i < f->channels; ++i) { if (really_zero_channel[i]) { memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); } else { for (j=0; j < n2; ++j) f->channel_buffers[i][j] *= f->floor_buffers[i][j]; } } #endif // INVERSE MDCT CHECK(f); for (i=0; i < f->channels; ++i) inverse_mdct(f->channel_buffers[i], n, f, m->blockflag); CHECK(f); // this shouldn't be necessary, unless we exited on an error // and want to flush to get to the next packet flush_packet(f); if (f->first_decode) { // assume we start so first non-discarded sample is sample 0 // this isn't to spec, but spec would require us to read ahead // and decode the size of all current frames--could be done, // but presumably it's not a commonly used feature f->current_loc = -n2; // start of first frame is positioned for discard // we might have to discard samples "from" the next frame too, // if we're lapping a large block then a small at the start? f->discard_samples_deferred = n - right_end; f->current_loc_valid = TRUE; f->first_decode = FALSE; } else if (f->discard_samples_deferred) { if (f->discard_samples_deferred >= right_start - left_start) { f->discard_samples_deferred -= (right_start - left_start); left_start = right_start; *p_left = left_start; } else { left_start += f->discard_samples_deferred; *p_left = left_start; f->discard_samples_deferred = 0; } } else if (f->previous_length == 0 && f->current_loc_valid) { // we're recovering from a seek... that means we're going to discard // the samples from this packet even though we know our position from // the last page header, so we need to update the position based on // the discarded samples here // but wait, the code below is going to add this in itself even // on a discard, so we don't need to do it here... } // check if we have ogg information about the sample # for this packet if (f->last_seg_which == f->end_seg_with_known_loc) { // if we have a valid current loc, and this is final: if (f->current_loc_valid && (f->page_flag & PAGEFLAG_last_page)) { uint32 current_end = f->known_loc_for_packet - (n-right_end); // then let's infer the size of the (probably) short final frame if (current_end < f->current_loc + (right_end-left_start)) { if (current_end < f->current_loc) { // negative truncation, that's impossible! *len = 0; } else { *len = current_end - f->current_loc; } *len += left_start; if (*len > right_end) *len = right_end; // this should never happen f->current_loc += *len; return TRUE; } } // otherwise, just set our sample loc // guess that the ogg granule pos refers to the _middle_ of the // last frame? // set f->current_loc to the position of left_start f->current_loc = f->known_loc_for_packet - (n2-left_start); f->current_loc_valid = TRUE; } if (f->current_loc_valid) f->current_loc += (right_start - left_start); if (f->alloc.alloc_buffer) assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); *len = right_end; // ignore samples after the window goes to 0 CHECK(f); return TRUE; } static int vorbis_decode_packet(vorb *f, int *len, int *p_left, int *p_right) { int mode, left_end, right_end; if (!vorbis_decode_initial(f, p_left, &left_end, p_right, &right_end, &mode)) return 0; return vorbis_decode_packet_rest(f, len, f->mode_config + mode, *p_left, left_end, *p_right, right_end, p_left); } static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right) { int prev,i,j; // we use right&left (the start of the right- and left-window sin()-regions) // to determine how much to return, rather than inferring from the rules // (same result, clearer code); 'left' indicates where our sin() window // starts, therefore where the previous window's right edge starts, and // therefore where to start mixing from the previous buffer. 'right' // indicates where our sin() ending-window starts, therefore that's where // we start saving, and where our returned-data ends. // mixin from previous window if (f->previous_length) { int i,j, n = f->previous_length; float *w = get_window(f, n); for (i=0; i < f->channels; ++i) { for (j=0; j < n; ++j) f->channel_buffers[i][left+j] = f->channel_buffers[i][left+j]*w[ j] + f->previous_window[i][ j]*w[n-1-j]; } } prev = f->previous_length; // last half of this data becomes previous window f->previous_length = len - right; // @OPTIMIZE: could avoid this copy by double-buffering the // output (flipping previous_window with channel_buffers), but // then previous_window would have to be 2x as large, and // channel_buffers couldn't be temp mem (although they're NOT // currently temp mem, they could be (unless we want to level // performance by spreading out the computation)) for (i=0; i < f->channels; ++i) for (j=0; right+j < len; ++j) f->previous_window[i][j] = f->channel_buffers[i][right+j]; if (!prev) // there was no previous packet, so this data isn't valid... // this isn't entirely true, only the would-have-overlapped data // isn't valid, but this seems to be what the spec requires return 0; // truncate a short frame if (len < right) right = len; f->samples_output += right-left; return right - left; } static int vorbis_pump_first_frame(stb_vorbis *f) { int len, right, left, res; res = vorbis_decode_packet(f, &len, &left, &right); if (res) vorbis_finish_frame(f, len, left, right); return res; } #ifndef STB_VORBIS_NO_PUSHDATA_API static int is_whole_packet_present(stb_vorbis *f, int end_page) { // make sure that we have the packet available before continuing... // this requires a full ogg parse, but we know we can fetch from f->stream // instead of coding this out explicitly, we could save the current read state, // read the next packet with get8() until end-of-packet, check f->eof, then // reset the state? but that would be slower, esp. since we'd have over 256 bytes // of state to restore (primarily the page segment table) int s = f->next_seg, first = TRUE; uint8 *p = f->stream; if (s != -1) { // if we're not starting the packet with a 'continue on next page' flag for (; s < f->segment_count; ++s) { p += f->segments[s]; if (f->segments[s] < 255) // stop at first short segment break; } // either this continues, or it ends it... if (end_page) if (s < f->segment_count-1) return error(f, VORBIS_invalid_stream); if (s == f->segment_count) s = -1; // set 'crosses page' flag if (p > f->stream_end) return error(f, VORBIS_need_more_data); first = FALSE; } for (; s == -1;) { uint8 *q; int n; // check that we have the page header ready if (p + 26 >= f->stream_end) return error(f, VORBIS_need_more_data); // validate the page if (memcmp(p, ogg_page_header, 4)) return error(f, VORBIS_invalid_stream); if (p[4] != 0) return error(f, VORBIS_invalid_stream); if (first) { // the first segment must NOT have 'continued_packet', later ones MUST if (f->previous_length) if ((p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream); // if no previous length, we're resynching, so we can come in on a continued-packet, // which we'll just drop } else { if (!(p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream); } n = p[26]; // segment counts q = p+27; // q points to segment table p = q + n; // advance past header // make sure we've read the segment table if (p > f->stream_end) return error(f, VORBIS_need_more_data); for (s=0; s < n; ++s) { p += q[s]; if (q[s] < 255) break; } if (end_page) if (s < n-1) return error(f, VORBIS_invalid_stream); if (s == n) s = -1; // set 'crosses page' flag if (p > f->stream_end) return error(f, VORBIS_need_more_data); first = FALSE; } return TRUE; } #endif // !STB_VORBIS_NO_PUSHDATA_API static int start_decoder(vorb *f) { uint8 header[6], x,y; int len,i,j,k, max_submaps = 0; int longest_floorlist=0; // first page, first packet if (!start_page(f)) return FALSE; // validate page flag if (!(f->page_flag & PAGEFLAG_first_page)) return error(f, VORBIS_invalid_first_page); if (f->page_flag & PAGEFLAG_last_page) return error(f, VORBIS_invalid_first_page); if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page); // check for expected packet length if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page); if (f->segments[0] != 30) return error(f, VORBIS_invalid_first_page); // read packet // check packet header if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page); if (!getn(f, header, 6)) return error(f, VORBIS_unexpected_eof); if (!vorbis_validate(header)) return error(f, VORBIS_invalid_first_page); // vorbis_version if (get32(f) != 0) return error(f, VORBIS_invalid_first_page); f->channels = get8(f); if (!f->channels) return error(f, VORBIS_invalid_first_page); if (f->channels > STB_VORBIS_MAX_CHANNELS) return error(f, VORBIS_too_many_channels); f->sample_rate = get32(f); if (!f->sample_rate) return error(f, VORBIS_invalid_first_page); get32(f); // bitrate_maximum get32(f); // bitrate_nominal get32(f); // bitrate_minimum x = get8(f); { int log0,log1; log0 = x & 15; log1 = x >> 4; f->blocksize_0 = 1 << log0; f->blocksize_1 = 1 << log1; if (log0 < 6 || log0 > 13) return error(f, VORBIS_invalid_setup); if (log1 < 6 || log1 > 13) return error(f, VORBIS_invalid_setup); if (log0 > log1) return error(f, VORBIS_invalid_setup); } // framing_flag x = get8(f); if (!(x & 1)) return error(f, VORBIS_invalid_first_page); // second packet! if (!start_page(f)) return FALSE; if (!start_packet(f)) return FALSE; do { len = next_segment(f); skip(f, len); f->bytes_in_seg = 0; } while (len); // third packet! if (!start_packet(f)) return FALSE; #ifndef STB_VORBIS_NO_PUSHDATA_API if (IS_PUSH_MODE(f)) { if (!is_whole_packet_present(f, TRUE)) { // convert error in ogg header to write type if (f->error == VORBIS_invalid_stream) f->error = VORBIS_invalid_setup; return FALSE; } } #endif crc32_init(); // always init it, to avoid multithread race conditions if (get8_packet(f) != VORBIS_packet_setup) return error(f, VORBIS_invalid_setup); for (i=0; i < 6; ++i) header[i] = get8_packet(f); if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup); // codebooks f->codebook_count = get_bits(f,8) + 1; f->codebooks = (Codebook *) setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count); if (f->codebooks == NULL) return error(f, VORBIS_outofmem); memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count); for (i=0; i < f->codebook_count; ++i) { uint32 *values; int ordered, sorted_count; int total=0; uint8 *lengths; Codebook *c = f->codebooks+i; CHECK(f); x = get_bits(f, 8); if (x != 0x42) return error(f, VORBIS_invalid_setup); x = get_bits(f, 8); if (x != 0x43) return error(f, VORBIS_invalid_setup); x = get_bits(f, 8); if (x != 0x56) return error(f, VORBIS_invalid_setup); x = get_bits(f, 8); c->dimensions = (get_bits(f, 8)<<8) + x; x = get_bits(f, 8); y = get_bits(f, 8); c->entries = (get_bits(f, 8)<<16) + (y<<8) + x; ordered = get_bits(f,1); c->sparse = ordered ? 0 : get_bits(f,1); if (c->dimensions == 0 && c->entries != 0) return error(f, VORBIS_invalid_setup); if (c->sparse) lengths = (uint8 *) setup_temp_malloc(f, c->entries); else lengths = c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); if (!lengths) return error(f, VORBIS_outofmem); if (ordered) { int current_entry = 0; int current_length = get_bits(f,5) + 1; while (current_entry < c->entries) { int limit = c->entries - current_entry; int n = get_bits(f, ilog(limit)); if (current_entry + n > (int) c->entries) { return error(f, VORBIS_invalid_setup); } memset(lengths + current_entry, current_length, n); current_entry += n; ++current_length; } } else { for (j=0; j < c->entries; ++j) { int present = c->sparse ? get_bits(f,1) : 1; if (present) { lengths[j] = get_bits(f, 5) + 1; ++total; if (lengths[j] == 32) return error(f, VORBIS_invalid_setup); } else { lengths[j] = NO_CODE; } } } if (c->sparse && total >= c->entries >> 2) { // convert sparse items to non-sparse! if (c->entries > (int) f->setup_temp_memory_required) f->setup_temp_memory_required = c->entries; c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); if (c->codeword_lengths == NULL) return error(f, VORBIS_outofmem); memcpy(c->codeword_lengths, lengths, c->entries); setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs! lengths = c->codeword_lengths; c->sparse = 0; } // compute the size of the sorted tables if (c->sparse) { sorted_count = total; } else { sorted_count = 0; #ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH for (j=0; j < c->entries; ++j) if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE) ++sorted_count; #endif } c->sorted_entries = sorted_count; values = NULL; CHECK(f); if (!c->sparse) { c->codewords = (uint32 *) setup_malloc(f, sizeof(c->codewords[0]) * c->entries); if (!c->codewords) return error(f, VORBIS_outofmem); } else { unsigned int size; if (c->sorted_entries) { c->codeword_lengths = (uint8 *) setup_malloc(f, c->sorted_entries); if (!c->codeword_lengths) return error(f, VORBIS_outofmem); c->codewords = (uint32 *) setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries); if (!c->codewords) return error(f, VORBIS_outofmem); values = (uint32 *) setup_temp_malloc(f, sizeof(*values) * c->sorted_entries); if (!values) return error(f, VORBIS_outofmem); } size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries; if (size > f->setup_temp_memory_required) f->setup_temp_memory_required = size; } if (!compute_codewords(c, lengths, c->entries, values)) { if (c->sparse) setup_temp_free(f, values, 0); return error(f, VORBIS_invalid_setup); } if (c->sorted_entries) { // allocate an extra slot for sentinels c->sorted_codewords = (uint32 *) setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1)); if (c->sorted_codewords == NULL) return error(f, VORBIS_outofmem); // allocate an extra slot at the front so that c->sorted_values[-1] is defined // so that we can catch that case without an extra if c->sorted_values = ( int *) setup_malloc(f, sizeof(*c->sorted_values ) * (c->sorted_entries+1)); if (c->sorted_values == NULL) return error(f, VORBIS_outofmem); ++c->sorted_values; c->sorted_values[-1] = -1; compute_sorted_huffman(c, lengths, values); } if (c->sparse) { setup_temp_free(f, values, sizeof(*values)*c->sorted_entries); setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries); setup_temp_free(f, lengths, c->entries); c->codewords = NULL; } compute_accelerated_huffman(c); CHECK(f); c->lookup_type = get_bits(f, 4); if (c->lookup_type > 2) return error(f, VORBIS_invalid_setup); if (c->lookup_type > 0) { uint16 *mults; c->minimum_value = float32_unpack(get_bits(f, 32)); c->delta_value = float32_unpack(get_bits(f, 32)); c->value_bits = get_bits(f, 4)+1; c->sequence_p = get_bits(f,1); if (c->lookup_type == 1) { c->lookup_values = lookup1_values(c->entries, c->dimensions); } else { c->lookup_values = c->entries * c->dimensions; } if (c->lookup_values == 0) return error(f, VORBIS_invalid_setup); mults = (uint16 *) setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values); if (mults == NULL) return error(f, VORBIS_outofmem); for (j=0; j < (int) c->lookup_values; ++j) { int q = get_bits(f, c->value_bits); if (q == EOP) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); } mults[j] = q; } #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK if (c->lookup_type == 1) { int len, sparse = c->sparse; float last=0; // pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop if (sparse) { if (c->sorted_entries == 0) goto skip; c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions); } else c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions); if (c->multiplicands == NULL) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } len = sparse ? c->sorted_entries : c->entries; for (j=0; j < len; ++j) { unsigned int z = sparse ? c->sorted_values[j] : j; unsigned int div=1; for (k=0; k < c->dimensions; ++k) { int off = (z / div) % c->lookup_values; float val = mults[off]; val = mults[off]*c->delta_value + c->minimum_value + last; c->multiplicands[j*c->dimensions + k] = val; if (c->sequence_p) last = val; if (k+1 < c->dimensions) { if (div > UINT_MAX / (unsigned int) c->lookup_values) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); } div *= c->lookup_values; } } } c->lookup_type = 2; } else #endif { float last=0; CHECK(f); c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values); if (c->multiplicands == NULL) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } for (j=0; j < (int) c->lookup_values; ++j) { float val = mults[j] * c->delta_value + c->minimum_value + last; c->multiplicands[j] = val; if (c->sequence_p) last = val; } } #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK skip:; #endif setup_temp_free(f, mults, sizeof(mults[0])*c->lookup_values); CHECK(f); } CHECK(f); } // time domain transfers (notused) x = get_bits(f, 6) + 1; for (i=0; i < x; ++i) { uint32 z = get_bits(f, 16); if (z != 0) return error(f, VORBIS_invalid_setup); } // Floors f->floor_count = get_bits(f, 6)+1; f->floor_config = (Floor *) setup_malloc(f, f->floor_count * sizeof(*f->floor_config)); if (f->floor_config == NULL) return error(f, VORBIS_outofmem); for (i=0; i < f->floor_count; ++i) { f->floor_types[i] = get_bits(f, 16); if (f->floor_types[i] > 1) return error(f, VORBIS_invalid_setup); if (f->floor_types[i] == 0) { Floor0 *g = &f->floor_config[i].floor0; g->order = get_bits(f,8); g->rate = get_bits(f,16); g->bark_map_size = get_bits(f,16); g->amplitude_bits = get_bits(f,6); g->amplitude_offset = get_bits(f,8); g->number_of_books = get_bits(f,4) + 1; for (j=0; j < g->number_of_books; ++j) g->book_list[j] = get_bits(f,8); return error(f, VORBIS_feature_not_supported); } else { stbv__floor_ordering p[31*8+2]; Floor1 *g = &f->floor_config[i].floor1; int max_class = -1; g->partitions = get_bits(f, 5); for (j=0; j < g->partitions; ++j) { g->partition_class_list[j] = get_bits(f, 4); if (g->partition_class_list[j] > max_class) max_class = g->partition_class_list[j]; } for (j=0; j <= max_class; ++j) { g->class_dimensions[j] = get_bits(f, 3)+1; g->class_subclasses[j] = get_bits(f, 2); if (g->class_subclasses[j]) { g->class_masterbooks[j] = get_bits(f, 8); if (g->class_masterbooks[j] >= f->codebook_count) return error(f, VORBIS_invalid_setup); } for (k=0; k < 1 << g->class_subclasses[j]; ++k) { g->subclass_books[j][k] = get_bits(f,8)-1; if (g->subclass_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); } } g->floor1_multiplier = get_bits(f,2)+1; g->rangebits = get_bits(f,4); g->Xlist[0] = 0; g->Xlist[1] = 1 << g->rangebits; g->values = 2; for (j=0; j < g->partitions; ++j) { int c = g->partition_class_list[j]; for (k=0; k < g->class_dimensions[c]; ++k) { g->Xlist[g->values] = get_bits(f, g->rangebits); ++g->values; } } // precompute the sorting for (j=0; j < g->values; ++j) { p[j].x = g->Xlist[j]; p[j].id = j; } qsort(p, g->values, sizeof(p[0]), point_compare); for (j=0; j < g->values; ++j) g->sorted_order[j] = (uint8) p[j].id; // precompute the neighbors for (j=2; j < g->values; ++j) { int low,hi; neighbors(g->Xlist, j, &low,&hi); g->neighbors[j][0] = low; g->neighbors[j][1] = hi; } if (g->values > longest_floorlist) longest_floorlist = g->values; } } // Residue f->residue_count = get_bits(f, 6)+1; f->residue_config = (Residue *) setup_malloc(f, f->residue_count * sizeof(f->residue_config[0])); if (f->residue_config == NULL) return error(f, VORBIS_outofmem); memset(f->residue_config, 0, f->residue_count * sizeof(f->residue_config[0])); for (i=0; i < f->residue_count; ++i) { uint8 residue_cascade[64]; Residue *r = f->residue_config+i; f->residue_types[i] = get_bits(f, 16); if (f->residue_types[i] > 2) return error(f, VORBIS_invalid_setup); r->begin = get_bits(f, 24); r->end = get_bits(f, 24); if (r->end < r->begin) return error(f, VORBIS_invalid_setup); r->part_size = get_bits(f,24)+1; r->classifications = get_bits(f,6)+1; r->classbook = get_bits(f,8); if (r->classbook >= f->codebook_count) return error(f, VORBIS_invalid_setup); for (j=0; j < r->classifications; ++j) { uint8 high_bits=0; uint8 low_bits=get_bits(f,3); if (get_bits(f,1)) high_bits = get_bits(f,5); residue_cascade[j] = high_bits*8 + low_bits; } r->residue_books = (short (*)[8]) setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications); if (r->residue_books == NULL) return error(f, VORBIS_outofmem); for (j=0; j < r->classifications; ++j) { for (k=0; k < 8; ++k) { if (residue_cascade[j] & (1 << k)) { r->residue_books[j][k] = get_bits(f, 8); if (r->residue_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); } else { r->residue_books[j][k] = -1; } } } // precompute the classifications[] array to avoid inner-loop mod/divide // call it 'classdata' since we already have r->classifications r->classdata = (uint8 **) setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); if (!r->classdata) return error(f, VORBIS_outofmem); memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); for (j=0; j < f->codebooks[r->classbook].entries; ++j) { int classwords = f->codebooks[r->classbook].dimensions; int temp = j; r->classdata[j] = (uint8 *) setup_malloc(f, sizeof(r->classdata[j][0]) * classwords); if (r->classdata[j] == NULL) return error(f, VORBIS_outofmem); for (k=classwords-1; k >= 0; --k) { r->classdata[j][k] = temp % r->classifications; temp /= r->classifications; } } } f->mapping_count = get_bits(f,6)+1; f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping)); if (f->mapping == NULL) return error(f, VORBIS_outofmem); memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping)); for (i=0; i < f->mapping_count; ++i) { Mapping *m = f->mapping + i; int mapping_type = get_bits(f,16); if (mapping_type != 0) return error(f, VORBIS_invalid_setup); m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan)); if (m->chan == NULL) return error(f, VORBIS_outofmem); if (get_bits(f,1)) m->submaps = get_bits(f,4)+1; else m->submaps = 1; if (m->submaps > max_submaps) max_submaps = m->submaps; if (get_bits(f,1)) { m->coupling_steps = get_bits(f,8)+1; for (k=0; k < m->coupling_steps; ++k) { m->chan[k].magnitude = get_bits(f, ilog(f->channels-1)); m->chan[k].angle = get_bits(f, ilog(f->channels-1)); if (m->chan[k].magnitude >= f->channels) return error(f, VORBIS_invalid_setup); if (m->chan[k].angle >= f->channels) return error(f, VORBIS_invalid_setup); if (m->chan[k].magnitude == m->chan[k].angle) return error(f, VORBIS_invalid_setup); } } else m->coupling_steps = 0; // reserved field if (get_bits(f,2)) return error(f, VORBIS_invalid_setup); if (m->submaps > 1) { for (j=0; j < f->channels; ++j) { m->chan[j].mux = get_bits(f, 4); if (m->chan[j].mux >= m->submaps) return error(f, VORBIS_invalid_setup); } } else // @SPECIFICATION: this case is missing from the spec for (j=0; j < f->channels; ++j) m->chan[j].mux = 0; for (j=0; j < m->submaps; ++j) { get_bits(f,8); // discard m->submap_floor[j] = get_bits(f,8); m->submap_residue[j] = get_bits(f,8); if (m->submap_floor[j] >= f->floor_count) return error(f, VORBIS_invalid_setup); if (m->submap_residue[j] >= f->residue_count) return error(f, VORBIS_invalid_setup); } } // Modes f->mode_count = get_bits(f, 6)+1; for (i=0; i < f->mode_count; ++i) { Mode *m = f->mode_config+i; m->blockflag = get_bits(f,1); m->windowtype = get_bits(f,16); m->transformtype = get_bits(f,16); m->mapping = get_bits(f,8); if (m->windowtype != 0) return error(f, VORBIS_invalid_setup); if (m->transformtype != 0) return error(f, VORBIS_invalid_setup); if (m->mapping >= f->mapping_count) return error(f, VORBIS_invalid_setup); } flush_packet(f); f->previous_length = 0; for (i=0; i < f->channels; ++i) { f->channel_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1); f->previous_window[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); f->finalY[i] = (int16 *) setup_malloc(f, sizeof(int16) * longest_floorlist); if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) return error(f, VORBIS_outofmem); #ifdef STB_VORBIS_NO_DEFER_FLOOR f->floor_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); if (f->floor_buffers[i] == NULL) return error(f, VORBIS_outofmem); #endif } if (!init_blocksize(f, 0, f->blocksize_0)) return FALSE; if (!init_blocksize(f, 1, f->blocksize_1)) return FALSE; f->blocksize[0] = f->blocksize_0; f->blocksize[1] = f->blocksize_1; #ifdef STB_VORBIS_DIVIDE_TABLE if (integer_divide_table[1][1]==0) for (i=0; i < DIVTAB_NUMER; ++i) for (j=1; j < DIVTAB_DENOM; ++j) integer_divide_table[i][j] = i / j; #endif // compute how much temporary memory is needed // 1. { uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1); uint32 classify_mem; int i,max_part_read=0; for (i=0; i < f->residue_count; ++i) { Residue *r = f->residue_config + i; int n_read = r->end - r->begin; int part_read = n_read / r->part_size; if (part_read > max_part_read) max_part_read = part_read; } #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(uint8 *)); #else classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *)); #endif f->temp_memory_required = classify_mem; if (imdct_mem > f->temp_memory_required) f->temp_memory_required = imdct_mem; } f->first_decode = TRUE; if (f->alloc.alloc_buffer) { assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes); // check if there's enough temp memory so we don't error later if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset) return error(f, VORBIS_outofmem); } f->first_audio_page_offset = stb_vorbis_get_file_offset(f); return TRUE; } static void vorbis_deinit(stb_vorbis *p) { int i,j; if (p->residue_config) { for (i=0; i < p->residue_count; ++i) { Residue *r = p->residue_config+i; if (r->classdata) { for (j=0; j < p->codebooks[r->classbook].entries; ++j) setup_free(p, r->classdata[j]); setup_free(p, r->classdata); } setup_free(p, r->residue_books); } } if (p->codebooks) { CHECK(p); for (i=0; i < p->codebook_count; ++i) { Codebook *c = p->codebooks + i; setup_free(p, c->codeword_lengths); setup_free(p, c->multiplicands); setup_free(p, c->codewords); setup_free(p, c->sorted_codewords); // c->sorted_values[-1] is the first entry in the array setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL); } setup_free(p, p->codebooks); } setup_free(p, p->floor_config); setup_free(p, p->residue_config); if (p->mapping) { for (i=0; i < p->mapping_count; ++i) setup_free(p, p->mapping[i].chan); setup_free(p, p->mapping); } CHECK(p); for (i=0; i < p->channels && i < STB_VORBIS_MAX_CHANNELS; ++i) { setup_free(p, p->channel_buffers[i]); setup_free(p, p->previous_window[i]); #ifdef STB_VORBIS_NO_DEFER_FLOOR setup_free(p, p->floor_buffers[i]); #endif setup_free(p, p->finalY[i]); } for (i=0; i < 2; ++i) { setup_free(p, p->A[i]); setup_free(p, p->B[i]); setup_free(p, p->C[i]); setup_free(p, p->window[i]); setup_free(p, p->bit_reverse[i]); } #ifndef STB_VORBIS_NO_STDIO if (p->close_on_free) fclose(p->f); #endif } void stb_vorbis_close(stb_vorbis *p) { if (p == NULL) return; vorbis_deinit(p); setup_free(p,p); } static void vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z) { memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start if (z) { p->alloc = *z; p->alloc.alloc_buffer_length_in_bytes = (p->alloc.alloc_buffer_length_in_bytes+3) & ~3; p->temp_offset = p->alloc.alloc_buffer_length_in_bytes; } p->eof = 0; p->error = VORBIS__no_error; p->stream = NULL; p->codebooks = NULL; p->page_crc_tests = -1; #ifndef STB_VORBIS_NO_STDIO p->close_on_free = FALSE; p->f = NULL; #endif } int stb_vorbis_get_sample_offset(stb_vorbis *f) { if (f->current_loc_valid) return f->current_loc; else return -1; } stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f) { stb_vorbis_info d; d.channels = f->channels; d.sample_rate = f->sample_rate; d.setup_memory_required = f->setup_memory_required; d.setup_temp_memory_required = f->setup_temp_memory_required; d.temp_memory_required = f->temp_memory_required; d.max_frame_size = f->blocksize_1 >> 1; return d; } int stb_vorbis_get_error(stb_vorbis *f) { int e = f->error; f->error = VORBIS__no_error; return e; } static stb_vorbis * vorbis_alloc(stb_vorbis *f) { stb_vorbis *p = (stb_vorbis *) setup_malloc(f, sizeof(*p)); return p; } #ifndef STB_VORBIS_NO_PUSHDATA_API void stb_vorbis_flush_pushdata(stb_vorbis *f) { f->previous_length = 0; f->page_crc_tests = 0; f->discard_samples_deferred = 0; f->current_loc_valid = FALSE; f->first_decode = FALSE; f->samples_output = 0; f->channel_buffer_start = 0; f->channel_buffer_end = 0; } static int vorbis_search_for_page_pushdata(vorb *f, uint8 *data, int data_len) { int i,n; for (i=0; i < f->page_crc_tests; ++i) f->scan[i].bytes_done = 0; // if we have room for more scans, search for them first, because // they may cause us to stop early if their header is incomplete if (f->page_crc_tests < STB_VORBIS_PUSHDATA_CRC_COUNT) { if (data_len < 4) return 0; data_len -= 3; // need to look for 4-byte sequence, so don't miss // one that straddles a boundary for (i=0; i < data_len; ++i) { if (data[i] == 0x4f) { if (0==memcmp(data+i, ogg_page_header, 4)) { int j,len; uint32 crc; // make sure we have the whole page header if (i+26 >= data_len || i+27+data[i+26] >= data_len) { // only read up to this page start, so hopefully we'll // have the whole page header start next time data_len = i; break; } // ok, we have it all; compute the length of the page len = 27 + data[i+26]; for (j=0; j < data[i+26]; ++j) len += data[i+27+j]; // scan everything up to the embedded crc (which we must 0) crc = 0; for (j=0; j < 22; ++j) crc = crc32_update(crc, data[i+j]); // now process 4 0-bytes for ( ; j < 26; ++j) crc = crc32_update(crc, 0); // len is the total number of bytes we need to scan n = f->page_crc_tests++; f->scan[n].bytes_left = len-j; f->scan[n].crc_so_far = crc; f->scan[n].goal_crc = data[i+22] + (data[i+23] << 8) + (data[i+24]<<16) + (data[i+25]<<24); // if the last frame on a page is continued to the next, then // we can't recover the sample_loc immediately if (data[i+27+data[i+26]-1] == 255) f->scan[n].sample_loc = ~0; else f->scan[n].sample_loc = data[i+6] + (data[i+7] << 8) + (data[i+ 8]<<16) + (data[i+ 9]<<24); f->scan[n].bytes_done = i+j; if (f->page_crc_tests == STB_VORBIS_PUSHDATA_CRC_COUNT) break; // keep going if we still have room for more } } } } for (i=0; i < f->page_crc_tests;) { uint32 crc; int j; int n = f->scan[i].bytes_done; int m = f->scan[i].bytes_left; if (m > data_len - n) m = data_len - n; // m is the bytes to scan in the current chunk crc = f->scan[i].crc_so_far; for (j=0; j < m; ++j) crc = crc32_update(crc, data[n+j]); f->scan[i].bytes_left -= m; f->scan[i].crc_so_far = crc; if (f->scan[i].bytes_left == 0) { // does it match? if (f->scan[i].crc_so_far == f->scan[i].goal_crc) { // Houston, we have page data_len = n+m; // consumption amount is wherever that scan ended f->page_crc_tests = -1; // drop out of page scan mode f->previous_length = 0; // decode-but-don't-output one frame f->next_seg = -1; // start a new page f->current_loc = f->scan[i].sample_loc; // set the current sample location // to the amount we'd have decoded had we decoded this page f->current_loc_valid = f->current_loc != ~0U; return data_len; } // delete entry f->scan[i] = f->scan[--f->page_crc_tests]; } else { ++i; } } return data_len; } // return value: number of bytes we used int stb_vorbis_decode_frame_pushdata( stb_vorbis *f, // the file we're decoding const uint8 *data, int data_len, // the memory available for decoding int *channels, // place to write number of float * buffers float ***output, // place to write float ** array of float * buffers int *samples // place to write number of output samples ) { int i; int len,right,left; if (!IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); if (f->page_crc_tests >= 0) { *samples = 0; return vorbis_search_for_page_pushdata(f, (uint8 *) data, data_len); } f->stream = (uint8 *) data; f->stream_end = (uint8 *) data + data_len; f->error = VORBIS__no_error; // check that we have the entire packet in memory if (!is_whole_packet_present(f, FALSE)) { *samples = 0; return 0; } if (!vorbis_decode_packet(f, &len, &left, &right)) { // save the actual error we encountered enum STBVorbisError error = f->error; if (error == VORBIS_bad_packet_type) { // flush and resynch f->error = VORBIS__no_error; while (get8_packet(f) != EOP) if (f->eof) break; *samples = 0; return (int) (f->stream - data); } if (error == VORBIS_continued_packet_flag_invalid) { if (f->previous_length == 0) { // we may be resynching, in which case it's ok to hit one // of these; just discard the packet f->error = VORBIS__no_error; while (get8_packet(f) != EOP) if (f->eof) break; *samples = 0; return (int) (f->stream - data); } } // if we get an error while parsing, what to do? // well, it DEFINITELY won't work to continue from where we are! stb_vorbis_flush_pushdata(f); // restore the error that actually made us bail f->error = error; *samples = 0; return 1; } // success! len = vorbis_finish_frame(f, len, left, right); for (i=0; i < f->channels; ++i) f->outputs[i] = f->channel_buffers[i] + left; if (channels) *channels = f->channels; *samples = len; *output = f->outputs; return (int) (f->stream - data); } stb_vorbis *stb_vorbis_open_pushdata( const unsigned char *data, int data_len, // the memory available for decoding int *data_used, // only defined if result is not NULL int *error, const stb_vorbis_alloc *alloc) { stb_vorbis *f, p; vorbis_init(&p, alloc); p.stream = (uint8 *) data; p.stream_end = (uint8 *) data + data_len; p.push_mode = TRUE; if (!start_decoder(&p)) { if (p.eof) *error = VORBIS_need_more_data; else *error = p.error; return NULL; } f = vorbis_alloc(&p); if (f) { *f = p; *data_used = (int) (f->stream - data); *error = 0; return f; } else { vorbis_deinit(&p); return NULL; } } #endif // STB_VORBIS_NO_PUSHDATA_API unsigned int stb_vorbis_get_file_offset(stb_vorbis *f) { #ifndef STB_VORBIS_NO_PUSHDATA_API if (f->push_mode) return 0; #endif if (USE_MEMORY(f)) return (unsigned int) (f->stream - f->stream_start); #ifndef STB_VORBIS_NO_STDIO return (unsigned int) (ftell(f->f) - f->f_start); #endif } #ifndef STB_VORBIS_NO_PULLDATA_API // // DATA-PULLING API // static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last) { for(;;) { int n; if (f->eof) return 0; n = get8(f); if (n == 0x4f) { // page header candidate unsigned int retry_loc = stb_vorbis_get_file_offset(f); int i; // check if we're off the end of a file_section stream if (retry_loc - 25 > f->stream_len) return 0; // check the rest of the header for (i=1; i < 4; ++i) if (get8(f) != ogg_page_header[i]) break; if (f->eof) return 0; if (i == 4) { uint8 header[27]; uint32 i, crc, goal, len; for (i=0; i < 4; ++i) header[i] = ogg_page_header[i]; for (; i < 27; ++i) header[i] = get8(f); if (f->eof) return 0; if (header[4] != 0) goto invalid; goal = header[22] + (header[23] << 8) + (header[24]<<16) + (header[25]<<24); for (i=22; i < 26; ++i) header[i] = 0; crc = 0; for (i=0; i < 27; ++i) crc = crc32_update(crc, header[i]); len = 0; for (i=0; i < header[26]; ++i) { int s = get8(f); crc = crc32_update(crc, s); len += s; } if (len && f->eof) return 0; for (i=0; i < len; ++i) crc = crc32_update(crc, get8(f)); // finished parsing probable page if (crc == goal) { // we could now check that it's either got the last // page flag set, OR it's followed by the capture // pattern, but I guess TECHNICALLY you could have // a file with garbage between each ogg page and recover // from it automatically? So even though that paranoia // might decrease the chance of an invalid decode by // another 2^32, not worth it since it would hose those // invalid-but-useful files? if (end) *end = stb_vorbis_get_file_offset(f); if (last) { if (header[5] & 0x04) *last = 1; else *last = 0; } set_file_offset(f, retry_loc-1); return 1; } } invalid: // not a valid page, so rewind and look for next one set_file_offset(f, retry_loc); } } } #define SAMPLE_unknown 0xffffffff // seeking is implemented with a binary search, which narrows down the range to // 64K, before using a linear search (because finding the synchronization // pattern can be expensive, and the chance we'd find the end page again is // relatively high for small ranges) // // two initial interpolation-style probes are used at the start of the search // to try to bound either side of the binary search sensibly, while still // working in O(log n) time if they fail. static int get_seek_page_info(stb_vorbis *f, ProbedPage *z) { uint8 header[27], lacing[255]; int i,len; // record where the page starts z->page_start = stb_vorbis_get_file_offset(f); // parse the header getn(f, header, 27); if (header[0] != 'O' || header[1] != 'g' || header[2] != 'g' || header[3] != 'S') return 0; getn(f, lacing, header[26]); // determine the length of the payload len = 0; for (i=0; i < header[26]; ++i) len += lacing[i]; // this implies where the page ends z->page_end = z->page_start + 27 + header[26] + len; // read the last-decoded sample out of the data z->last_decoded_sample = header[6] + (header[7] << 8) + (header[8] << 16) + (header[9] << 24); // restore file state to where we were set_file_offset(f, z->page_start); return 1; } // rarely used function to seek back to the preceeding page while finding the // start of a packet static int go_to_page_before(stb_vorbis *f, unsigned int limit_offset) { unsigned int previous_safe, end; // now we want to seek back 64K from the limit if (limit_offset >= 65536 && limit_offset-65536 >= f->first_audio_page_offset) previous_safe = limit_offset - 65536; else previous_safe = f->first_audio_page_offset; set_file_offset(f, previous_safe); while (vorbis_find_page(f, &end, NULL)) { if (end >= limit_offset && stb_vorbis_get_file_offset(f) < limit_offset) return 1; set_file_offset(f, end); } return 0; } // implements the search logic for finding a page and starting decoding. if // the function succeeds, current_loc_valid will be true and current_loc will // be less than or equal to the provided sample number (the closer the // better). static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) { ProbedPage left, right, mid; int i, start_seg_with_known_loc, end_pos, page_start; uint32 delta, stream_length, padding; double offset, bytes_per_sample; int probe = 0; // find the last page and validate the target sample stream_length = stb_vorbis_stream_length_in_samples(f); if (stream_length == 0) return error(f, VORBIS_seek_without_length); if (sample_number > stream_length) return error(f, VORBIS_seek_invalid); // this is the maximum difference between the window-center (which is the // actual granule position value), and the right-start (which the spec // indicates should be the granule position (give or take one)). padding = ((f->blocksize_1 - f->blocksize_0) >> 2); if (sample_number < padding) sample_number = 0; else sample_number -= padding; left = f->p_first; while (left.last_decoded_sample == ~0U) { // (untested) the first page does not have a 'last_decoded_sample' set_file_offset(f, left.page_end); if (!get_seek_page_info(f, &left)) goto error; } right = f->p_last; assert(right.last_decoded_sample != ~0U); // starting from the start is handled differently if (sample_number <= left.last_decoded_sample) { if (stb_vorbis_seek_start(f)) return 1; return 0; } while (left.page_end != right.page_start) { assert(left.page_end < right.page_start); // search range in bytes delta = right.page_start - left.page_end; if (delta <= 65536) { // there's only 64K left to search - handle it linearly set_file_offset(f, left.page_end); } else { if (probe < 2) { if (probe == 0) { // first probe (interpolate) double data_bytes = right.page_end - left.page_start; bytes_per_sample = data_bytes / right.last_decoded_sample; offset = left.page_start + bytes_per_sample * (sample_number - left.last_decoded_sample); } else { // second probe (try to bound the other side) double error = ((double) sample_number - mid.last_decoded_sample) * bytes_per_sample; if (error >= 0 && error < 8000) error = 8000; if (error < 0 && error > -8000) error = -8000; offset += error * 2; } // ensure the offset is valid if (offset < left.page_end) offset = left.page_end; if (offset > right.page_start - 65536) offset = right.page_start - 65536; set_file_offset(f, (unsigned int) offset); } else { // binary search for large ranges (offset by 32K to ensure // we don't hit the right page) set_file_offset(f, left.page_end + (delta / 2) - 32768); } if (!vorbis_find_page(f, NULL, NULL)) goto error; } for (;;) { if (!get_seek_page_info(f, &mid)) goto error; if (mid.last_decoded_sample != ~0U) break; // (untested) no frames end on this page set_file_offset(f, mid.page_end); assert(mid.page_start < right.page_start); } // if we've just found the last page again then we're in a tricky file, // and we're close enough. if (mid.page_start == right.page_start) break; if (sample_number < mid.last_decoded_sample) right = mid; else left = mid; ++probe; } // seek back to start of the last packet page_start = left.page_start; set_file_offset(f, page_start); if (!start_page(f)) return error(f, VORBIS_seek_failed); end_pos = f->end_seg_with_known_loc; assert(end_pos >= 0); for (;;) { for (i = end_pos; i > 0; --i) if (f->segments[i-1] != 255) break; start_seg_with_known_loc = i; if (start_seg_with_known_loc > 0 || !(f->page_flag & PAGEFLAG_continued_packet)) break; // (untested) the final packet begins on an earlier page if (!go_to_page_before(f, page_start)) goto error; page_start = stb_vorbis_get_file_offset(f); if (!start_page(f)) goto error; end_pos = f->segment_count - 1; } // prepare to start decoding f->current_loc_valid = FALSE; f->last_seg = FALSE; f->valid_bits = 0; f->packet_bytes = 0; f->bytes_in_seg = 0; f->previous_length = 0; f->next_seg = start_seg_with_known_loc; for (i = 0; i < start_seg_with_known_loc; i++) skip(f, f->segments[i]); // start decoding (optimizable - this frame is generally discarded) if (!vorbis_pump_first_frame(f)) return 0; if (f->current_loc > sample_number) return error(f, VORBIS_seek_failed); return 1; error: // try to restore the file to a valid state stb_vorbis_seek_start(f); return error(f, VORBIS_seek_failed); } // the same as vorbis_decode_initial, but without advancing static int peek_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode) { int bits_read, bytes_read; if (!vorbis_decode_initial(f, p_left_start, p_left_end, p_right_start, p_right_end, mode)) return 0; // either 1 or 2 bytes were read, figure out which so we can rewind bits_read = 1 + ilog(f->mode_count-1); if (f->mode_config[*mode].blockflag) bits_read += 2; bytes_read = (bits_read + 7) / 8; f->bytes_in_seg += bytes_read; f->packet_bytes -= bytes_read; skip(f, -bytes_read); if (f->next_seg == -1) f->next_seg = f->segment_count - 1; else f->next_seg--; f->valid_bits = 0; return 1; } int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number) { uint32 max_frame_samples; if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); // fast page-level search if (!seek_to_sample_coarse(f, sample_number)) return 0; assert(f->current_loc_valid); assert(f->current_loc <= sample_number); // linear search for the relevant packet max_frame_samples = (f->blocksize_1*3 - f->blocksize_0) >> 2; while (f->current_loc < sample_number) { int left_start, left_end, right_start, right_end, mode, frame_samples; if (!peek_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode)) return error(f, VORBIS_seek_failed); // calculate the number of samples returned by the next frame frame_samples = right_start - left_start; if (f->current_loc + frame_samples > sample_number) { return 1; // the next frame will contain the sample } else if (f->current_loc + frame_samples + max_frame_samples > sample_number) { // there's a chance the frame after this could contain the sample vorbis_pump_first_frame(f); } else { // this frame is too early to be relevant f->current_loc += frame_samples; f->previous_length = 0; maybe_start_packet(f); flush_packet(f); } } // the next frame will start with the sample assert(f->current_loc == sample_number); return 1; } int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number) { if (!stb_vorbis_seek_frame(f, sample_number)) return 0; if (sample_number != f->current_loc) { int n; uint32 frame_start = f->current_loc; stb_vorbis_get_frame_float(f, &n, NULL); assert(sample_number > frame_start); assert(f->channel_buffer_start + (int) (sample_number-frame_start) <= f->channel_buffer_end); f->channel_buffer_start += (sample_number - frame_start); } return 1; } int stb_vorbis_seek_start(stb_vorbis *f) { if (IS_PUSH_MODE(f)) { return error(f, VORBIS_invalid_api_mixing); } set_file_offset(f, f->first_audio_page_offset); f->previous_length = 0; f->first_decode = TRUE; f->next_seg = -1; return vorbis_pump_first_frame(f); } unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f) { unsigned int restore_offset, previous_safe; unsigned int end, last_page_loc; if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); if (!f->total_samples) { unsigned int last; uint32 lo,hi; char header[6]; // first, store the current decode position so we can restore it restore_offset = stb_vorbis_get_file_offset(f); // now we want to seek back 64K from the end (the last page must // be at most a little less than 64K, but let's allow a little slop) if (f->stream_len >= 65536 && f->stream_len-65536 >= f->first_audio_page_offset) previous_safe = f->stream_len - 65536; else previous_safe = f->first_audio_page_offset; set_file_offset(f, previous_safe); // previous_safe is now our candidate 'earliest known place that seeking // to will lead to the final page' if (!vorbis_find_page(f, &end, &last)) { // if we can't find a page, we're hosed! f->error = VORBIS_cant_find_last_page; f->total_samples = 0xffffffff; goto done; } // check if there are more pages last_page_loc = stb_vorbis_get_file_offset(f); // stop when the last_page flag is set, not when we reach eof; // this allows us to stop short of a 'file_section' end without // explicitly checking the length of the section while (!last) { set_file_offset(f, end); if (!vorbis_find_page(f, &end, &last)) { // the last page we found didn't have the 'last page' flag // set. whoops! break; } previous_safe = last_page_loc+1; last_page_loc = stb_vorbis_get_file_offset(f); } set_file_offset(f, last_page_loc); // parse the header getn(f, (unsigned char *)header, 6); // extract the absolute granule position lo = get32(f); hi = get32(f); if (lo == 0xffffffff && hi == 0xffffffff) { f->error = VORBIS_cant_find_last_page; f->total_samples = SAMPLE_unknown; goto done; } if (hi) lo = 0xfffffffe; // saturate f->total_samples = lo; f->p_last.page_start = last_page_loc; f->p_last.page_end = end; f->p_last.last_decoded_sample = lo; done: set_file_offset(f, restore_offset); } return f->total_samples == SAMPLE_unknown ? 0 : f->total_samples; } float stb_vorbis_stream_length_in_seconds(stb_vorbis *f) { return stb_vorbis_stream_length_in_samples(f) / (float) f->sample_rate; } int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output) { int len, right,left,i; if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); if (!vorbis_decode_packet(f, &len, &left, &right)) { f->channel_buffer_start = f->channel_buffer_end = 0; return 0; } len = vorbis_finish_frame(f, len, left, right); for (i=0; i < f->channels; ++i) f->outputs[i] = f->channel_buffers[i] + left; f->channel_buffer_start = left; f->channel_buffer_end = left+len; if (channels) *channels = f->channels; if (output) *output = f->outputs; return len; } #ifndef STB_VORBIS_NO_STDIO stb_vorbis * stb_vorbis_open_file_section(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc, unsigned int length) { stb_vorbis *f, p; vorbis_init(&p, alloc); p.f = file; p.f_start = (uint32) ftell(file); p.stream_len = length; p.close_on_free = close_on_free; if (start_decoder(&p)) { f = vorbis_alloc(&p); if (f) { *f = p; vorbis_pump_first_frame(f); return f; } } if (error) *error = p.error; vorbis_deinit(&p); return NULL; } stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc) { unsigned int len, start; start = (unsigned int) ftell(file); fseek(file, 0, SEEK_END); len = (unsigned int) (ftell(file) - start); fseek(file, start, SEEK_SET); return stb_vorbis_open_file_section(file, close_on_free, error, alloc, len); } stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc) { FILE *f = fopen(filename, "rb"); if (f) return stb_vorbis_open_file(f, TRUE, error, alloc); if (error) *error = VORBIS_file_open_failure; return NULL; } #endif // STB_VORBIS_NO_STDIO stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc) { stb_vorbis *f, p; if (data == NULL) return NULL; vorbis_init(&p, alloc); p.stream = (uint8 *) data; p.stream_end = (uint8 *) data + len; p.stream_start = (uint8 *) p.stream; p.stream_len = len; p.push_mode = FALSE; if (start_decoder(&p)) { f = vorbis_alloc(&p); if (f) { *f = p; vorbis_pump_first_frame(f); if (error) *error = VORBIS__no_error; return f; } } if (error) *error = p.error; vorbis_deinit(&p); return NULL; } #ifndef STB_VORBIS_NO_INTEGER_CONVERSION #define PLAYBACK_MONO 1 #define PLAYBACK_LEFT 2 #define PLAYBACK_RIGHT 4 #define L (PLAYBACK_LEFT | PLAYBACK_MONO) #define C (PLAYBACK_LEFT | PLAYBACK_RIGHT | PLAYBACK_MONO) #define R (PLAYBACK_RIGHT | PLAYBACK_MONO) static int8 channel_position[7][6] = { { 0 }, { C }, { L, R }, { L, C, R }, { L, R, L, R }, { L, C, R, L, R }, { L, C, R, L, R, C }, }; #ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT typedef union { float f; int i; } float_conv; typedef char stb_vorbis_float_size_test[sizeof(float)==4 && sizeof(int) == 4]; #define FASTDEF(x) float_conv x // add (1<<23) to convert to int, then divide by 2^SHIFT, then add 0.5/2^SHIFT to round #define MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT)) #define ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22)) #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) (temp.f = (x) + MAGIC(s), temp.i - ADDEND(s)) #define check_endianness() #else #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s)))) #define check_endianness() #define FASTDEF(x) #endif static void copy_samples(short *dest, float *src, int len) { int i; check_endianness(); for (i=0; i < len; ++i) { FASTDEF(temp); int v = FAST_SCALED_FLOAT_TO_INT(temp, src[i],15); if ((unsigned int) (v + 32768) > 65535) v = v < 0 ? -32768 : 32767; dest[i] = v; } } static void compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len) { #define BUFFER_SIZE 32 float buffer[BUFFER_SIZE]; int i,j,o,n = BUFFER_SIZE; check_endianness(); for (o = 0; o < len; o += BUFFER_SIZE) { memset(buffer, 0, sizeof(buffer)); if (o + n > len) n = len - o; for (j=0; j < num_c; ++j) { if (channel_position[num_c][j] & mask) { for (i=0; i < n; ++i) buffer[i] += data[j][d_offset+o+i]; } } for (i=0; i < n; ++i) { FASTDEF(temp); int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15); if ((unsigned int) (v + 32768) > 65535) v = v < 0 ? -32768 : 32767; output[o+i] = v; } } } static void compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len) { #define BUFFER_SIZE 32 float buffer[BUFFER_SIZE]; int i,j,o,n = BUFFER_SIZE >> 1; // o is the offset in the source data check_endianness(); for (o = 0; o < len; o += BUFFER_SIZE >> 1) { // o2 is the offset in the output data int o2 = o << 1; memset(buffer, 0, sizeof(buffer)); if (o + n > len) n = len - o; for (j=0; j < num_c; ++j) { int m = channel_position[num_c][j] & (PLAYBACK_LEFT | PLAYBACK_RIGHT); if (m == (PLAYBACK_LEFT | PLAYBACK_RIGHT)) { for (i=0; i < n; ++i) { buffer[i*2+0] += data[j][d_offset+o+i]; buffer[i*2+1] += data[j][d_offset+o+i]; } } else if (m == PLAYBACK_LEFT) { for (i=0; i < n; ++i) { buffer[i*2+0] += data[j][d_offset+o+i]; } } else if (m == PLAYBACK_RIGHT) { for (i=0; i < n; ++i) { buffer[i*2+1] += data[j][d_offset+o+i]; } } } for (i=0; i < (n<<1); ++i) { FASTDEF(temp); int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15); if ((unsigned int) (v + 32768) > 65535) v = v < 0 ? -32768 : 32767; output[o2+i] = v; } } } static void convert_samples_short(int buf_c, short **buffer, int b_offset, int data_c, float **data, int d_offset, int samples) { int i; if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { static int channel_selector[3][2] = { {0}, {PLAYBACK_MONO}, {PLAYBACK_LEFT, PLAYBACK_RIGHT} }; for (i=0; i < buf_c; ++i) compute_samples(channel_selector[buf_c][i], buffer[i]+b_offset, data_c, data, d_offset, samples); } else { int limit = buf_c < data_c ? buf_c : data_c; for (i=0; i < limit; ++i) copy_samples(buffer[i]+b_offset, data[i]+d_offset, samples); for ( ; i < buf_c; ++i) memset(buffer[i]+b_offset, 0, sizeof(short) * samples); } } int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples) { float **output; int len = stb_vorbis_get_frame_float(f, NULL, &output); if (len > num_samples) len = num_samples; if (len) convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len); return len; } static void convert_channels_short_interleaved(int buf_c, short *buffer, int data_c, float **data, int d_offset, int len) { int i; check_endianness(); if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { assert(buf_c == 2); for (i=0; i < buf_c; ++i) compute_stereo_samples(buffer, data_c, data, d_offset, len); } else { int limit = buf_c < data_c ? buf_c : data_c; int j; for (j=0; j < len; ++j) { for (i=0; i < limit; ++i) { FASTDEF(temp); float f = data[i][d_offset+j]; int v = FAST_SCALED_FLOAT_TO_INT(temp, f,15);//data[i][d_offset+j],15); if ((unsigned int) (v + 32768) > 65535) v = v < 0 ? -32768 : 32767; *buffer++ = v; } for ( ; i < buf_c; ++i) *buffer++ = 0; } } } int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts) { float **output; int len; if (num_c == 1) return stb_vorbis_get_frame_short(f,num_c,&buffer, num_shorts); len = stb_vorbis_get_frame_float(f, NULL, &output); if (len) { if (len*num_c > num_shorts) len = num_shorts / num_c; convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len); } return len; } int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts) { float **outputs; int len = num_shorts / channels; int n=0; int z = f->channels; if (z > channels) z = channels; while (n < len) { int k = f->channel_buffer_end - f->channel_buffer_start; if (n+k >= len) k = len - n; if (k) convert_channels_short_interleaved(channels, buffer, f->channels, f->channel_buffers, f->channel_buffer_start, k); buffer += k*channels; n += k; f->channel_buffer_start += k; if (n == len) break; if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; } return n; } int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int len) { float **outputs; int n=0; int z = f->channels; if (z > channels) z = channels; while (n < len) { int k = f->channel_buffer_end - f->channel_buffer_start; if (n+k >= len) k = len - n; if (k) convert_samples_short(channels, buffer, n, f->channels, f->channel_buffers, f->channel_buffer_start, k); n += k; f->channel_buffer_start += k; if (n == len) break; if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; } return n; } #ifndef STB_VORBIS_NO_STDIO int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output) { int data_len, offset, total, limit, error; short *data; stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL); if (v == NULL) return -1; limit = v->channels * 4096; *channels = v->channels; if (sample_rate) *sample_rate = v->sample_rate; offset = data_len = 0; total = limit; data = (short *) malloc(total * sizeof(*data)); if (data == NULL) { stb_vorbis_close(v); return -2; } for (;;) { int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset); if (n == 0) break; data_len += n; offset += n * v->channels; if (offset + limit > total) { short *data2; total *= 2; data2 = (short *) realloc(data, total * sizeof(*data)); if (data2 == NULL) { free(data); stb_vorbis_close(v); return -2; } data = data2; } } *output = data; stb_vorbis_close(v); return data_len; } #endif // NO_STDIO int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *sample_rate, short **output) { int data_len, offset, total, limit, error; short *data; stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, NULL); if (v == NULL) return -1; limit = v->channels * 4096; *channels = v->channels; if (sample_rate) *sample_rate = v->sample_rate; offset = data_len = 0; total = limit; data = (short *) malloc(total * sizeof(*data)); if (data == NULL) { stb_vorbis_close(v); return -2; } for (;;) { int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset); if (n == 0) break; data_len += n; offset += n * v->channels; if (offset + limit > total) { short *data2; total *= 2; data2 = (short *) realloc(data, total * sizeof(*data)); if (data2 == NULL) { free(data); stb_vorbis_close(v); return -2; } data = data2; } } *output = data; stb_vorbis_close(v); return data_len; } #endif // STB_VORBIS_NO_INTEGER_CONVERSION int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats) { float **outputs; int len = num_floats / channels; int n=0; int z = f->channels; if (z > channels) z = channels; while (n < len) { int i,j; int k = f->channel_buffer_end - f->channel_buffer_start; if (n+k >= len) k = len - n; for (j=0; j < k; ++j) { for (i=0; i < z; ++i) *buffer++ = f->channel_buffers[i][f->channel_buffer_start+j]; for ( ; i < channels; ++i) *buffer++ = 0; } n += k; f->channel_buffer_start += k; if (n == len) break; if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; } return n; } int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples) { float **outputs; int n=0; int z = f->channels; if (z > channels) z = channels; while (n < num_samples) { int i; int k = f->channel_buffer_end - f->channel_buffer_start; if (n+k >= num_samples) k = num_samples - n; if (k) { for (i=0; i < z; ++i) memcpy(buffer[i]+n, f->channel_buffers[i]+f->channel_buffer_start, sizeof(float)*k); for ( ; i < channels; ++i) memset(buffer[i]+n, 0, sizeof(float) * k); } n += k; f->channel_buffer_start += k; if (n == num_samples) break; if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; } return n; } #endif // STB_VORBIS_NO_PULLDATA_API /* Version history 1.10 - 2017/03/03 - more robust seeking; fix negative ilog(); clear error in open_memory 1.09 - 2016/04/04 - back out 'avoid discarding last frame' fix from previous version 1.08 - 2016/04/02 - fixed multiple warnings; fix setup memory leaks; avoid discarding last frame of audio data 1.07 - 2015/01/16 - fixed some warnings, fix mingw, const-correct API some more crash fixes when out of memory or with corrupt files 1.06 - 2015/08/31 - full, correct support for seeking API (Dougall Johnson) some crash fixes when out of memory or with corrupt files 1.05 - 2015/04/19 - don't define __forceinline if it's redundant 1.04 - 2014/08/27 - fix missing const-correct case in API 1.03 - 2014/08/07 - Warning fixes 1.02 - 2014/07/09 - Declare qsort compare function _cdecl on windows 1.01 - 2014/06/18 - fix stb_vorbis_get_samples_float 1.0 - 2014/05/26 - fix memory leaks; fix warnings; fix bugs in multichannel (API change) report sample rate for decode-full-file funcs 0.99996 - bracket #include for macintosh compilation by Laurent Gomila 0.99995 - use union instead of pointer-cast for fast-float-to-int to avoid alias-optimization problem 0.99994 - change fast-float-to-int to work in single-precision FPU mode, remove endian-dependence 0.99993 - remove assert that fired on legal files with empty tables 0.99992 - rewind-to-start 0.99991 - bugfix to stb_vorbis_get_samples_short by Bernhard Wodo 0.9999 - (should have been 0.99990) fix no-CRT support, compiling as C++ 0.9998 - add a full-decode function with a memory source 0.9997 - fix a bug in the read-from-FILE case in 0.9996 addition 0.9996 - query length of vorbis stream in samples/seconds 0.9995 - bugfix to another optimization that only happened in certain files 0.9994 - bugfix to one of the optimizations that caused significant (but inaudible?) errors 0.9993 - performance improvements; runs in 99% to 104% of time of reference implementation 0.9992 - performance improvement of IMDCT; now performs close to reference implementation 0.9991 - performance improvement of IMDCT 0.999 - (should have been 0.9990) performance improvement of IMDCT 0.998 - no-CRT support from Casey Muratori 0.997 - bugfixes for bugs found by Terje Mathisen 0.996 - bugfix: fast-huffman decode initialized incorrectly for sparse codebooks; fixing gives 10% speedup - found by Terje Mathisen 0.995 - bugfix: fix to 'effective' overrun detection - found by Terje Mathisen 0.994 - bugfix: garbage decode on final VQ symbol of a non-multiple - found by Terje Mathisen 0.993 - bugfix: pushdata API required 1 extra byte for empty page (failed to consume final page if empty) - found by Terje Mathisen 0.992 - fixes for MinGW warning 0.991 - turn fast-float-conversion on by default 0.990 - fix push-mode seek recovery if you seek into the headers 0.98b - fix to bad release of 0.98 0.98 - fix push-mode seek recovery; robustify float-to-int and support non-fast mode 0.97 - builds under c++ (typecasting, don't use 'class' keyword) 0.96 - somehow MY 0.95 was right, but the web one was wrong, so here's my 0.95 rereleased as 0.96, fixes a typo in the clamping code 0.95 - clamping code for 16-bit functions 0.94 - not publically released 0.93 - fixed all-zero-floor case (was decoding garbage) 0.92 - fixed a memory leak 0.91 - conditional compiles to omit parts of the API and the infrastructure to support them: STB_VORBIS_NO_PULLDATA_API, STB_VORBIS_NO_PUSHDATA_API, STB_VORBIS_NO_STDIO, STB_VORBIS_NO_INTEGER_CONVERSION 0.90 - first public release */ #endif // STB_VORBIS_HEADER_ONLY /* ------------------------------------------------------------------------------ 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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_truetype.h0000600000175000001440000053171414003056224017323 0ustar rakusers// stb_truetype.h - v1.17 - 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 // // Misc other: // Ryan Gordon // Simon Glass // github:IntellectualKitty // Imanol Celaya // // Bug/warning reports/fixes: // "Zer" on mollyrocket // Cass Everitt // stoiko (Haemimont Games) // Brian Hook // Walter van Niftrik // David Gow // David Given // Ivan-Assen Ivanov // Anthony Pesch // Johan Duparc // Hou Qiming // Fabian "ryg" Giesen // Martins Mozeiko // Cap Petschulat // Omar Cornut // github:aloucks // Peter LaValle // Sergey Popov // Giumo X. Clanjor // Higor Euripedes // Thomas Fields // Derek Vinyard // Cort Stratton // github:oyvindjam // // VERSION HISTORY // // 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 they 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. // // 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 #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. #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]; // #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h #ifndef STBTT_ifloor #include #define STBTT_ifloor(x) ((int) floor(x)) #define STBTT_iceil(x) ((int) ceil(x)) #endif #ifndef STBTT_sqrt #include #define STBTT_sqrt(x) sqrt(x) #define STBTT_pow(x,y) pow(x,y) #endif #ifndef STBTT_cos #include #define STBTT_cos(x) cos(x) #define STBTT_acos(x) acos(x) #endif #ifndef STBTT_fabs #include #define STBTT_fabs(x) fabs(x) #endif #ifndef STBTT_fabs #include #define STBTT_fabs(x) fabs(x) #endif // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h #ifndef STBTT_malloc #include #define STBTT_malloc(x,u) ((void)(u),malloc(x)) #define STBTT_free(x,u) ((void)(u),free(x)) #endif #ifndef STBTT_assert #include #define STBTT_assert(x) assert(x) #endif #ifndef STBTT_strlen #include #define STBTT_strlen(x) strlen(x) #endif #ifndef STBTT_memcpy #include #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; // 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 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__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; *y0 = r ? c.min_y : 0; *x1 = r ? c.max_x : 0; *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)); } } STBTT_DEF int stbtt_GetGlyphKernAdvance(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; } STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2) { if (!info->kern) // 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) + 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 && midn => n; 0 0 */ /* 0n: 0>n => 0; 0 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, *winding_lengths; 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_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) 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) 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.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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_tilemap_editor.h0000600000175000001440000043567314003056224020452 0ustar rakusers// stb_tilemap_editor.h - v0.38 - Sean Barrett - http://nothings.org/stb // placed in the public domain - not copyrighted - first released 2014-09 // // Embeddable tilemap editor for C/C++ // // // TABLE OF CONTENTS // FAQ // How to compile/use the library // Additional configuration macros // API documentation // Info on editing multiple levels // Revision history // Todo // Credits // License // // // FAQ // // Q: What counts as a tilemap for this library? // // A: An array of rectangles, where each rectangle contains a small // stack of images. // // Q: What are the limitations? // // A: Maps are limited to 4096x4096 in dimension. // Each map square can only contain a stack of at most 32 images. // A map can only use up to 32768 distinct image tiles. // // Q: How do I compile this? // // A: You need to #define several symbols before #including it, but only // in one file. This will cause all the function definitions to be // generated in that file. See the "HOW TO COMPILE" section. // // Q: What advantages does this have over a standalone editor? // // A: For one, you can integrate the editor into your game so you can // flip between editing and testing without even switching windows. // For another, you don't need an XML parser to get at the map data. // // Q: Can I live-edit my game maps? // // A: Not really, the editor keeps its own map representation. // // Q: How do I save and load maps? // // A: You have to do this yourself. The editor provides serialization // functions (get & set) for reading and writing the map it holds. // You can choose whatever format you want to store the map to on // disk; you just need to provide functions to convert. (For example, // I actually store the editor's map representation to disk basically // as-is; then I have a single function that converts from the editor // map representation to the game representation, which is used both // to go from editor-to-game and from loaded-map-to-game.) // // Q: I want to have tiles change appearance based on what's // adjacent, or other tile-display/substitution trickiness. // // A: You can do this when you convert from the editor's map // representation to the game representation, but there's // no way to show this live in the editor. // // Q: The editor appears to be put map location (0,0) at the top left? // I want to use a different coordinate system in my game (e.g. y // increasing upwards, or origin at the center). // // A: You can do this when you convert from the editor's map // representation to the game representation. (Don't forget to // translate link coordinates as well!) // // Q: The editor appears to put pixel (0,0) at the top left? I want // to use a different coordinate system in my game. // // A: The editor defines an "editor pixel coordinate system" with // (0,0) at the top left and requires you to display things in // that coordinate system. You can freely remap those coordinates // to anything you want on screen. // // Q: How do I scale the user interface? // // A: Since you do all the rendering, you can scale up all the rendering // calls that the library makes to you. If you do, (a) you need // to also scale up the mouse coordinates, and (b) you may want // to scale the map display back down so that you're only scaling // the UI and not everything. See the next question. // // Q: How do I scale the map display? // // A: Use stbte_set_spacing() to change the size that the map is displayed // at. Note that the "callbacks" to draw tiles are used for both drawing // the map and drawing the tile palette, so that callback may need to // draw at two different scales. You should choose the scales to match // You can tell them apart because the // tile palette gets NULL for the property pointer. // // Q: How does object editing work? // // A: One way to think of this is that in the editor, you're placing // spawners, not objects. Each spawner must be tile-aligned, because // it's only a tile editor. Each tile (stack of layers) gets // an associated set of properties, and it's up to you to // determine what properties should appear for a given tile, // based on e.g. the spawners that are in it. // // Q: How are properties themselves handled? // // A: All properties, regardless of UI behavior, are internally floats. // Each tile has an array of floats associated with it, which is // passed back to you when drawing the tiles so you can draw // objects appropriately modified by the properties. // // Q: What if I want to have two different objects/spawners in // one tile, both of which have their own properties? // // A: Make sure STBTE_MAX_PROPERTIES is large enough for the sum of // properties in both objects, and then you have to explicitly // map the property slot #s to the appropriate objects. They'll // still all appear in a single property panel; there's no way // to get multiple panels. // // Q: Can I do one-to-many linking? // // A: The library only supports one link per tile. However, you // can have multiple tiles all link to a single tile. So, you // can fake one-to-many linking by linking in the reverse // direction. // // Q: What if I have two objects in the same tile, and they each // need an independent link? Or I have two kinds of link associated // with a single object? // // A: There is no way to do this. (Unless you can reverse one link.) // // Q: How does cut & paste interact with object properties & links? // // A: Currently the library has no idea which properties or links // are associated with which layers of a tile. So currently, the // library will only copy properties & links if the layer panel // is set to allow all layers to be copied, OR if you set the // "props" in the layer panel to "always". Similarly, you can // set "props" to "none" so it will never copy. // // Q: What happens if the library gets a memory allocation failure // while I'm editing? Will I lose my work? // // A: The library allocates all editor memory when you create // the tilemap. It allocates a maximally-sized map and a // fixed-size undo buffer (and the fixed-size copy buffer // is static), and never allocates memory while it's running. // So it can't fail due to running out of memory. // // Q: What happens if the library crashes while I'm editing? Will // I lose my work? // // A: Yes. Save often. // // // HOW TO COMPILE // // This header file contains both the header file and the // implementation file in one. To create the implementation, // in one source file define a few symbols first and then // include this header: // // #define STB_TILEMAP_EDITOR_IMPLEMENTATION // // this triggers the implementation // // void STBTE_DRAW_RECT(int x0, int y0, int x1, int y1, uint color); // // this must draw a filled rectangle (exclusive on right/bottom) // // color = (r<<16)|(g<<8)|(b) // // void STBTE_DRAW_TILE(int x0, int y0, // unsigned short id, int highlight, float *data); // // this draws the tile image identified by 'id' in one of several // // highlight modes (see STBTE_drawmode_* in the header section); // // if 'data' is NULL, it's drawing the tile in the palette; if 'data' // // is not NULL, it's drawing a tile on the map, and that is the data // // associated with that map tile // // #include "stb_tilemap_editor.h" // // Optionally you can define the following functions before the include; // note these must be macros (but they can just call a function) so // this library can #ifdef to detect if you've defined them: // // #define STBTE_PROP_TYPE(int n, short *tiledata, float *params) ... // // Returns the type of the n'th property of a given tile, which // // controls how it is edited. Legal types are: // // 0 /* no editable property in this slot */ // // STBTE_PROP_int /* uses a slider to adjust value */ // // STBTE_PROP_float /* uses a weird multi-axis control */ // // STBTE_PROP_bool /* uses a checkbox to change value */ // // And you can bitwise-OR in the following flags: // // STBTE_PROP_disabled // // Note that all of these are stored as floats in the param array. // // The integer slider is limited in precision based on the space // // available on screen, so for wide-ranged integers you may want // // to use floats instead. // // // // Since the tiledata is passed to you, you can choose which property // // is bound to that slot based on that data. // // // // Changing the type of a parameter does not cause the underlying // // value to be clamped to the type min/max except when the tile is // // explicitly selected. // // #define STBTE_PROP_NAME(int n, short *tiledata, float *params) ... // // these return a string with the name for slot #n in the float // // property list for the tile. // // #define STBTE_PROP_MIN(int n, short *tiledata) ...your code here... // #define STBTE_PROP_MAX(int n, short *tiledata) ...your code here... // // These return the allowable range for the property values for // // the specified slot. It is never called for boolean types. // // #define STBTE_PROP_FLOAT_SCALE(int n, short *tiledata, float *params) // // This rescales the float control for a given property; by default // // left mouse drags add integers, right mouse drags adds fractions, // // but you can rescale this per-property. // // #define STBTE_FLOAT_CONTROL_GRANULARITY ... value ... // // This returns the number of pixels of mouse motion necessary // // to advance the object float control. Default is 4 // // #define STBTE_ALLOW_LINK(short *src, float *src_data, \ // short *dest, float *dest_data) ...your code... // // this returns true or false depending on whether you allow a link // // to be drawn from a tile 'src' to a tile 'dest'. if you don't // // define this, linking will not be supported // // #define STBTE_LINK_COLOR(short *src, float *src_data, \ // short *dest, float *dest_data) ...your code... // // return a color encoded as a 24-bit unsigned integer in the // // form 0xRRGGBB. If you don't define this, default colors will // // be used. // // // [[ support for those below is not implemented yet ]] // // #define STBTE_HITTEST_TILE(x0,y0,id,mx,my) ...your code here... // // this returns true or false depending on whether the mouse // // pointer at mx,my is over (touching) a tile of type 'id' // // displayed at x0,y0. Normally stb_tilemap_editor just does // // this hittest based on the tile geometry, but if you have // // tiles whose images extend out of the tile, you'll need this. // // ADDITIONAL CONFIGURATION // // The following symbols set static limits which determine how much // memory will be allocated for the editor. You can override them // by making similiar definitions, but memory usage will increase. // // #define STBTE_MAX_TILEMAP_X 200 // max 4096 // #define STBTE_MAX_TILEMAP_Y 200 // max 4096 // #define STBTE_MAX_LAYERS 8 // max 32 // #define STBTE_MAX_CATEGORIES 100 // #define STBTE_UNDO_BUFFER_BYTES (1 << 24) // 16 MB // #define STBTE_MAX_COPY 90000 // e.g. 300x300 // #define STBTE_MAX_PROPERTIES 10 // max properties per tile // // API // // Further documentation appears in the header-file section below. // // EDITING MULTIPLE LEVELS // // You can only have one active editor instance. To switch between multiple // levels, you can either store the levels in your own format and copy them // in and out of the editor format, or you can create multiple stbte_tilemap // objects and switch between them. The latter has the advantage that each // stbte_tilemap keeps its own undo state. (The clipboard is global, so // either approach allows cut&pasting between levels.) // // REVISION HISTORY // 0.38 fix warning // 0.37 fix warning // 0.36 minor compiler support // 0.35 layername button changes // - layername buttons grow with the layer panel // - fix stbte_create_map being declared as stbte_create // - fix declaration of stbte_create_map // 0.30 properties release // - properties panel for editing user-defined "object" properties // - can link each tile to one other tile // - keyboard interface // - fix eraser tool bug (worked in complex cases, failed in simple) // - undo/redo tools have visible disabled state // - tiles on higher layers draw on top of adjacent lower-layer tiles // 0.20 erasable release // - eraser tool // - fix bug when pasting into protected layer // - better color scheme // - internal-use color picker // 0.10 initial release // // TODO // // Separate scroll state for each category // Implement paint bucket // Support STBTE_HITTEST_TILE above // ?Cancel drags by clicking other button? - may be fixed // Finish support for toolbar at side // // CREDITS // // // Main editor & features // Sean Barrett // Additional features: // Josh Huelsman // Bugfixes: // Ryan Whitworth // Eugene Opalev // // LICENSE // // See end of file for license information. /////////////////////////////////////////////////////////////////////// // // HEADER SECTION #ifndef STB_TILEMAP_INCLUDE_STB_TILEMAP_EDITOR_H #define STB_TILEMAP_INCLUDE_STB_TILEMAP_EDITOR_H #ifdef _WIN32 #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif #include #include #endif typedef struct stbte_tilemap stbte_tilemap; // these are the drawmodes used in STBTE_DRAW_TILE enum { STBTE_drawmode_deemphasize = -1, STBTE_drawmode_normal = 0, STBTE_drawmode_emphasize = 1, }; // these are the property types #define STBTE_PROP_none 0 #define STBTE_PROP_int 1 #define STBTE_PROP_float 2 #define STBTE_PROP_bool 3 #define STBTE_PROP_disabled 4 //////// // // creation // extern stbte_tilemap *stbte_create_map(int map_x, int map_y, int map_layers, int spacing_x, int spacing_y, int max_tiles); // create an editable tilemap // map_x : dimensions of map horizontally (user can change this in editor), <= STBTE_MAX_TILEMAP_X // map_y : dimensions of map vertically (user can change this in editor) <= STBTE_MAX_TILEMAP_Y // map_layers : number of layers to use (fixed), <= STBTE_MAX_LAYERS // spacing_x : initial horizontal distance between left edges of map tiles in stb_tilemap_editor pixels // spacing_y : initial vertical distance between top edges of map tiles in stb_tilemap_editor pixels // max_tiles : maximum number of tiles that can defined // // If insufficient memory, returns NULL extern void stbte_define_tile(stbte_tilemap *tm, unsigned short id, unsigned int layermask, const char * category); // call this repeatedly for each tile to install the tile definitions into the editable tilemap // tm : tilemap created by stbte_create_map // id : unique identifier for each tile, 0 <= id < 32768 // layermask : bitmask of which layers tile is allowed on: 1 = layer 0, 255 = layers 0..7 // (note that onscreen, the editor numbers the layers from 1 not 0) // layer 0 is the furthest back, layer 1 is just in front of layer 0, etc // category : which category this tile is grouped in extern void stbte_set_display(int x0, int y0, int x1, int y1); // call this once to set the size; if you resize, call it again ///////// // // every frame // extern void stbte_draw(stbte_tilemap *tm); extern void stbte_tick(stbte_tilemap *tm, float time_in_seconds_since_last_frame); //////////// // // user input // // if you're using SDL, call the next function for SDL_MOUSEMOVE, SDL_MOUSEBUTTON, SDL_MOUSEWHEEL; // the transformation lets you scale from SDL mouse coords to stb_tilemap_editor coords extern void stbte_mouse_sdl(stbte_tilemap *tm, const void *sdl_event, float xscale, float yscale, int xoffset, int yoffset); // otherwise, hook these up explicitly: extern void stbte_mouse_move(stbte_tilemap *tm, int x, int y, int shifted, int scrollkey); extern void stbte_mouse_button(stbte_tilemap *tm, int x, int y, int right, int down, int shifted, int scrollkey); extern void stbte_mouse_wheel(stbte_tilemap *tm, int x, int y, int vscroll); // for keyboard, define your own mapping from keys to the following actions. // this is totally optional, as all features are accessible with the mouse enum stbte_action { STBTE_tool_select, STBTE_tool_brush, STBTE_tool_erase, STBTE_tool_rectangle, STBTE_tool_eyedropper, STBTE_tool_link, STBTE_act_toggle_grid, STBTE_act_toggle_links, STBTE_act_undo, STBTE_act_redo, STBTE_act_cut, STBTE_act_copy, STBTE_act_paste, STBTE_scroll_left, STBTE_scroll_right, STBTE_scroll_up, STBTE_scroll_down, }; extern void stbte_action(stbte_tilemap *tm, enum stbte_action act); //////////////// // // save/load // // There is no editor file format. You have to save and load the data yourself // through the following functions. You can also use these functions to get the // data to generate game-formatted levels directly. (But make sure you save // first! You may also want to autosave to a temp file periodically, etc etc.) #define STBTE_EMPTY -1 extern void stbte_get_dimensions(stbte_tilemap *tm, int *max_x, int *max_y); // get the dimensions of the level, since the user can change them extern short* stbte_get_tile(stbte_tilemap *tm, int x, int y); // returns an array of shorts that is 'map_layers' in length. each short is // either one of the tile_id values from define_tile, or STBTE_EMPTY. extern float *stbte_get_properties(stbte_tilemap *tm, int x, int y); // get the property array associated with the tile at x,y. this is an // array of floats that is STBTE_MAX_PROPERTIES in length; you have to // interpret the slots according to the semantics you've chosen extern void stbte_get_link(stbte_tilemap *tm, int x, int y, int *destx, int *desty); // gets the link associated with the tile at x,y. extern void stbte_set_dimensions(stbte_tilemap *tm, int max_x, int max_y); // set the dimensions of the level, overrides previous stbte_create_map() // values or anything the user has changed extern void stbte_clear_map(stbte_tilemap *tm); // clears the map, including the region outside the defined region, so if the // user expands the map, they won't see garbage there extern void stbte_set_tile(stbte_tilemap *tm, int x, int y, int layer, signed short tile); // tile is your tile_id from define_tile, or STBTE_EMPTY extern void stbte_set_property(stbte_tilemap *tm, int x, int y, int n, float val); // set the value of the n'th slot of the tile at x,y extern void stbte_set_link(stbte_tilemap *tm, int x, int y, int destx, int desty); // set a link going from x,y to destx,desty. to force no link, // use destx=desty=-1 //////// // // optional // extern void stbte_set_background_tile(stbte_tilemap *tm, short id); // selects the tile to fill the bottom layer with and used to clear bottom tiles to; // should be same ID as extern void stbte_set_sidewidths(int left, int right); // call this once to set the left & right side widths. don't call // it again since the user can change it extern void stbte_set_spacing(stbte_tilemap *tm, int spacing_x, int spacing_y, int palette_spacing_x, int palette_spacing_y); // call this to set the spacing of map tiles and the spacing of palette tiles. // if you rescale your display, call it again (e.g. you can implement map zooming yourself) extern void stbte_set_layername(stbte_tilemap *tm, int layer, const char *layername); // sets a string name for your layer that shows in the layer selector. note that this // makes the layer selector wider. 'layer' is from 0..(map_layers-1) #endif #ifdef STB_TILEMAP_EDITOR_IMPLEMENTATION #ifndef STBTE_ASSERT #define STBTE_ASSERT assert #include #endif #ifdef _MSC_VER #define STBTE__NOTUSED(v) (void)(v) #else #define STBTE__NOTUSED(v) (void)sizeof(v) #endif #ifndef STBTE_MAX_TILEMAP_X #define STBTE_MAX_TILEMAP_X 200 #endif #ifndef STBTE_MAX_TILEMAP_Y #define STBTE_MAX_TILEMAP_Y 200 #endif #ifndef STBTE_MAX_LAYERS #define STBTE_MAX_LAYERS 8 #endif #ifndef STBTE_MAX_CATEGORIES #define STBTE_MAX_CATEGORIES 100 #endif #ifndef STBTE_MAX_COPY #define STBTE_MAX_COPY 65536 #endif #ifndef STBTE_UNDO_BUFFER_BYTES #define STBTE_UNDO_BUFFER_BYTES (1 << 24) // 16 MB #endif #ifndef STBTE_PROP_TYPE #define STBTE__NO_PROPS #define STBTE_PROP_TYPE(n,td,tp) 0 #endif #ifndef STBTE_PROP_NAME #define STBTE_PROP_NAME(n,td,tp) "" #endif #ifndef STBTE_MAX_PROPERTIES #define STBTE_MAX_PROPERTIES 10 #endif #ifndef STBTE_PROP_MIN #define STBTE_PROP_MIN(n,td,tp) 0 #endif #ifndef STBTE_PROP_MAX #define STBTE_PROP_MAX(n,td,tp) 100.0 #endif #ifndef STBTE_PROP_FLOAT_SCALE #define STBTE_PROP_FLOAT_SCALE(n,td,tp) 1 // default scale size #endif #ifndef STBTE_FLOAT_CONTROL_GRANULARITY #define STBTE_FLOAT_CONTROL_GRANULARITY 4 #endif #define STBTE__UNDO_BUFFER_COUNT (STBTE_UNDO_BUFFER_BYTES>>1) #if STBTE_MAX_TILEMAP_X > 4096 || STBTE_MAX_TILEMAP_Y > 4096 #error "Maximum editable map size is 4096 x 4096" #endif #if STBTE_MAX_LAYERS > 32 #error "Maximum layers allowed is 32" #endif #if STBTE_UNDO_BUFFER_COUNT & (STBTE_UNDO_BUFFER_COUNT-1) #error "Undo buffer size must be a power of 2" #endif #if STBTE_MAX_PROPERTIES == 0 #define STBTE__NO_PROPS #endif #ifdef STBTE__NO_PROPS #undef STBTE_MAX_PROPERTIES #define STBTE_MAX_PROPERTIES 1 // so we can declare arrays #endif typedef struct { short x,y; } stbte__link; enum { STBTE__base, STBTE__outline, STBTE__text, STBTE__num_color_aspects, }; enum { STBTE__idle, STBTE__over, STBTE__down, STBTE__over_down, STBTE__selected, STBTE__selected_over, STBTE__disabled, STBTE__num_color_states, }; enum { STBTE__cexpander, STBTE__ctoolbar, STBTE__ctoolbar_button, STBTE__cpanel, STBTE__cpanel_sider, STBTE__cpanel_sizer, STBTE__cscrollbar, STBTE__cmapsize, STBTE__clayer_button, STBTE__clayer_hide, STBTE__clayer_lock, STBTE__clayer_solo, STBTE__ccategory_button, STBTE__num_color_modes, }; #ifdef STBTE__COLORPICKER static char *stbte__color_names[] = { "expander", "toolbar", "tool button", "panel", "panel c1", "panel c2", "scollbar", "map button", "layer", "hide", "lock", "solo", "category", }; #endif // STBTE__COLORPICKER // idle, over, down, over&down, selected, sel&over, disabled static int stbte__color_table[STBTE__num_color_modes][STBTE__num_color_aspects][STBTE__num_color_states] = { { { 0x000000, 0x84987c, 0xdcdca8, 0xdcdca8, 0x40c040, 0x60d060, 0x505050, }, { 0xa4b090, 0xe0ec80, 0xffffc0, 0xffffc0, 0x80ff80, 0x80ff80, 0x606060, }, { 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x909090, }, }, { { 0x808890, 0x606060, 0x606060, 0x606060, 0x606060, 0x606060, 0x606060, }, { 0x605860, 0x606060, 0x606060, 0x606060, 0x606060, 0x606060, 0x606060, }, { 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, }, }, { { 0x3c5068, 0x7088a8, 0x647488, 0x94b4dc, 0x8890c4, 0x9caccc, 0x404040, }, { 0x889cb8, 0x889cb8, 0x889cb8, 0x889cb8, 0x84c4e8, 0xacc8ff, 0x0c0c08, }, { 0xbcc4cc, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x707074, }, }, { { 0x403848, 0x403010, 0x403010, 0x403010, 0x403010, 0x403010, 0x303024, }, { 0x68546c, 0xc08040, 0xc08040, 0xc08040, 0xc08040, 0xc08040, 0x605030, }, { 0xf4e4ff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x909090, }, }, { { 0xb4b04c, 0xacac60, 0xc0ffc0, 0xc0ffc0, 0x40c040, 0x60d060, 0x505050, }, { 0xa0a04c, 0xd0d04c, 0xffff80, 0xffff80, 0x80ff80, 0x80ff80, 0x606060, }, { 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x909090, }, }, { { 0x40c440, 0x60d060, 0xc0ffc0, 0xc0ffc0, 0x40c040, 0x60d060, 0x505050, }, { 0x40c040, 0x80ff80, 0x80ff80, 0x80ff80, 0x80ff80, 0x80ff80, 0x606060, }, { 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x909090, }, }, { { 0x9090ac, 0xa0a0b8, 0xbcb8cc, 0xbcb8cc, 0x909040, 0x909040, 0x909040, }, { 0xa0a0b8, 0xb0b4d0, 0xa0a0b8, 0xa0a0b8, 0xa0a050, 0xa0a050, 0xa0a050, }, { 0x808088, 0x808030, 0x808030, 0x808030, 0x808030, 0x808030, 0x808030, }, }, { { 0x704c70, 0x885c8c, 0x9c68a4, 0xb870bc, 0xb490bc, 0xb490bc, 0x302828, }, { 0x646064, 0xcca8d4, 0xc060c0, 0xa07898, 0xe0b8e0, 0xe0b8e0, 0x403838, }, { 0xdccce4, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x909090, }, }, { { 0x704c70, 0x885c8c, 0x9c68a4, 0xb870bc, 0xb490bc, 0xb490bc, 0x302828, }, { 0xb09cb4, 0xcca8d4, 0xc060c0, 0xa07898, 0xe0b8e0, 0xe0b8e0, 0x403838, }, { 0xdccce4, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x909090, }, }, { { 0x646494, 0x888cb8, 0xb0b0b0, 0xb0b0cc, 0x9c9cf4, 0x8888b0, 0x50506c, }, { 0x9090a4, 0xb0b4d4, 0xb0b0dc, 0xb0b0cc, 0xd0d0fc, 0xd0d4f0, 0x606060, }, { 0xb4b4d4, 0xe4e4ff, 0xffffff, 0xffffff, 0xe0e4ff, 0xececff, 0x909090, }, }, { { 0x646444, 0x888c64, 0xb0b0b0, 0xb0b088, 0xaca858, 0x88886c, 0x505050, }, { 0x88886c, 0xb0b490, 0xb0b0b0, 0xb0b088, 0xd8d898, 0xd0d4b0, 0x606060, }, { 0xb4b49c, 0xffffd8, 0xffffff, 0xffffd4, 0xffffdc, 0xffffcc, 0x909090, }, }, { { 0x906464, 0xb48c8c, 0xd4b0b0, 0xdcb0b0, 0xff9c9c, 0xc88888, 0x505050, }, { 0xb47c80, 0xd4b4b8, 0xc4a8a8, 0xdcb0b0, 0xffc0c0, 0xfce8ec, 0x606060, }, { 0xe0b4b4, 0xffdcd8, 0xffd8d4, 0xffe0e4, 0xffece8, 0xffffff, 0x909090, }, }, { { 0x403848, 0x403848, 0x403848, 0x886894, 0x7c80c8, 0x7c80c8, 0x302828, }, { 0x403848, 0x403848, 0x403848, 0x403848, 0x7c80c8, 0x7c80c8, 0x403838, }, { 0xc8c4c8, 0xffffff, 0xffffff, 0xffffff, 0xe8e8ec, 0xffffff, 0x909090, }, }, }; #define STBTE_COLOR_TILEMAP_BACKGROUND 0x000000 #define STBTE_COLOR_TILEMAP_BORDER 0x203060 #define STBTE_COLOR_TILEMAP_HIGHLIGHT 0xffffff #define STBTE_COLOR_GRID 0x404040 #define STBTE_COLOR_SELECTION_OUTLINE1 0xdfdfdf #define STBTE_COLOR_SELECTION_OUTLINE2 0x303030 #define STBTE_COLOR_TILEPALETTE_OUTLINE 0xffffff #define STBTE_COLOR_TILEPALETTE_BACKGROUND 0x000000 #ifndef STBTE_LINK_COLOR #define STBTE_LINK_COLOR(src,sp,dest,dp) 0x5030ff #endif #ifndef STBTE_LINK_COLOR_DRAWING #define STBTE_LINK_COLOR_DRAWING 0xff40ff #endif #ifndef STBTE_LINK_COLOR_DISALLOWED #define STBTE_LINK_COLOR_DISALLOWED 0x602060 #endif // disabled, selected, down, over static unsigned char stbte__state_to_index[2][2][2][2] = { { { { STBTE__idle , STBTE__over }, { STBTE__down , STBTE__over_down }, }, { { STBTE__selected, STBTE__selected_over }, { STBTE__down , STBTE__over_down }, }, },{ { { STBTE__disabled, STBTE__disabled }, { STBTE__disabled, STBTE__disabled }, }, { { STBTE__selected, STBTE__selected_over }, { STBTE__disabled, STBTE__disabled }, }, } }; #define STBTE__INDEX_FOR_STATE(disable,select,down,over) stbte__state_to_index[disable][select][down][over] #define STBTE__INDEX_FOR_ID(id,disable,select) STBTE__INDEX_FOR_STATE(disable,select,STBTE__IS_ACTIVE(id),STBTE__IS_HOT(id)) #define STBTE__FONT_HEIGHT 9 static short stbte__font_offset[95+16]; static short stbte__fontdata[769] = { 4,9,6,9,9,9,9,8,9,8,4,9,7,7,7,7,4,2,6,8,6,6,7,3,4,4,8,6,3,6,2,6,6,6,6,6,6, 6,6,6,6,6,2,3,5,4,5,6,6,6,6,6,6,6,6,6,6,6,6,7,6,7,7,7,6,7,6,6,6,6,7,7,6,6, 6,4,6,4,7,7,3,6,6,5,6,6,5,6,6,4,5,6,4,7,6,6,6,6,6,6,6,6,6,7,6,6,6,5,2,5,8, 0,0,0,0,2,253,130,456,156,8,72,184,64,2,125,66,64,160,64,146,511,146,146, 511,146,146,511,146,511,257,341,297,341,297,341,257,511,16,56,124,16,16,16, 124,56,16,96,144,270,261,262,136,80,48,224,192,160,80,40,22,14,15,3,448,496, 496,240,232,20,10,5,2,112,232,452,450,225,113,58,28,63,30,60,200,455,257, 257,0,0,0,257,257,455,120,204,132,132,159,14,4,4,14,159,132,132,204,120,8, 24,56,120,56,24,8,32,48,56,60,56,48,32,0,0,0,0,111,111,7,7,0,0,7,7,34,127, 127,34,34,127,127,34,36,46,107,107,58,18,99,51,24,12,102,99,48,122,79,93, 55,114,80,4,7,3,62,127,99,65,65,99,127,62,8,42,62,28,28,62,42,8,8,8,62,62, 8,8,128,224,96,8,8,8,8,8,8,96,96,96,48,24,12,6,3,62,127,89,77,127,62,64,66, 127,127,64,64,98,115,89,77,71,66,33,97,73,93,119,35,24,28,22,127,127,16,39, 103,69,69,125,57,62,127,73,73,121,48,1,1,113,121,15,7,54,127,73,73,127,54, 6,79,73,105,63,30,54,54,128,246,118,8,28,54,99,65,20,20,20,20,65,99,54,28, 8,2,3,105,109,7,2,30,63,33,45,47,46,124,126,19,19,126,124,127,127,73,73,127, 54,62,127,65,65,99,34,127,127,65,99,62,28,127,127,73,73,73,65,127,127,9,9, 9,1,62,127,65,73,121,121,127,127,8,8,127,127,65,65,127,127,65,65,32,96,64, 64,127,63,127,127,8,28,54,99,65,127,127,64,64,64,64,127,127,6,12,6,127,127, 127,127,6,12,24,127,127,62,127,65,65,65,127,62,127,127,9,9,15,6,62,127,65, 81,49,127,94,127,127,9,25,127,102,70,79,73,73,121,49,1,1,127,127,1,1,63,127, 64,64,127,63,15,31,48,96,48,31,15,127,127,48,24,48,127,127,99,119,28,28,119, 99,7,15,120,120,15,7,97,113,89,77,71,67,127,127,65,65,3,6,12,24,48,96,65, 65,127,127,8,12,6,3,6,12,8,64,64,64,64,64,64,64,3,7,4,32,116,84,84,124,120, 127,127,68,68,124,56,56,124,68,68,68,56,124,68,68,127,127,56,124,84,84,92, 24,8,124,126,10,10,56,380,324,324,508,252,127,127,4,4,124,120,72,122,122, 64,256,256,256,506,250,126,126,16,56,104,64,66,126,126,64,124,124,24,56,28, 124,120,124,124,4,4,124,120,56,124,68,68,124,56,508,508,68,68,124,56,56,124, 68,68,508,508,124,124,4,4,12,8,72,92,84,84,116,36,4,4,62,126,68,68,60,124, 64,64,124,124,28,60,96,96,60,28,28,124,112,56,112,124,28,68,108,56,56,108, 68,284,316,352,320,508,252,68,100,116,92,76,68,8,62,119,65,65,127,127,65, 65,119,62,8,16,24,12,12,24,24,12,4, }; typedef struct { short id; unsigned short category_id; char *category; unsigned int layermask; } stbte__tileinfo; #define MAX_LAYERMASK (1 << (8*sizeof(unsigned int))) typedef short stbte__tiledata; #define STBTE__NO_TILE -1 enum { STBTE__panel_toolbar, STBTE__panel_colorpick, STBTE__panel_info, STBTE__panel_layers, STBTE__panel_props, STBTE__panel_categories, STBTE__panel_tiles, STBTE__num_panel, }; enum { STBTE__side_left, STBTE__side_right, STBTE__side_top, STBTE__side_bottom, }; enum { STBTE__tool_select, STBTE__tool_brush, STBTE__tool_erase, STBTE__tool_rect, STBTE__tool_eyedrop, STBTE__tool_fill, STBTE__tool_link, STBTE__tool_showgrid, STBTE__tool_showlinks, STBTE__tool_undo, STBTE__tool_redo, // copy/cut/paste aren't included here because they're displayed differently STBTE__num_tool, }; // icons are stored in the 0-31 range of ASCII in the font static int toolchar[] = { 26,24,25,20,23,22,18, 19,17, 29,28, }; enum { STBTE__propmode_default, STBTE__propmode_always, STBTE__propmode_never, }; enum { STBTE__paint, // from here down does hittesting STBTE__tick, STBTE__mousemove, STBTE__mousewheel, STBTE__leftdown, STBTE__leftup, STBTE__rightdown, STBTE__rightup, }; typedef struct { int expanded, mode; int delta_height; // number of rows they've requested for this int side; int width,height; int x0,y0; } stbte__panel; typedef struct { int x0,y0,x1,y1,color; } stbte__colorrect; #define STBTE__MAX_DELAYRECT 256 typedef struct { int tool, active_event; int active_id, hot_id, next_hot_id; int event; int mx,my, dx,dy; int ms_time; int shift, scrollkey; int initted; int side_extended[2]; stbte__colorrect delayrect[STBTE__MAX_DELAYRECT]; int delaycount; int show_grid, show_links; int brush_state; // used to decide which kind of erasing int eyedrop_x, eyedrop_y, eyedrop_last_layer; int pasting, paste_x, paste_y; int scrolling, start_x, start_y; int last_mouse_x, last_mouse_y; int accum_x, accum_y; int linking; int dragging; int drag_x, drag_y, drag_w, drag_h; int drag_offx, drag_offy, drag_dest_x, drag_dest_y; int undoing; int has_selection, select_x0, select_y0, select_x1, select_y1; int sx,sy; int x0,y0,x1,y1, left_width, right_width; // configurable widths float alert_timer; const char *alert_msg; float dt; stbte__panel panel[STBTE__num_panel]; short copybuffer[STBTE_MAX_COPY][STBTE_MAX_LAYERS]; float copyprops[STBTE_MAX_COPY][STBTE_MAX_PROPERTIES]; #ifdef STBTE_ALLOW_LINK stbte__link copylinks[STBTE_MAX_COPY]; #endif int copy_src_x, copy_src_y; stbte_tilemap *copy_src; int copy_width,copy_height,has_copy,copy_has_props; } stbte__ui_t; // there's only one UI system at a time, so we can globalize this static stbte__ui_t stbte__ui = { STBTE__tool_brush, 0 }; #define STBTE__INACTIVE() (stbte__ui.active_id == 0) #define STBTE__IS_ACTIVE(id) (stbte__ui.active_id == (id)) #define STBTE__IS_HOT(id) (stbte__ui.hot_id == (id)) #define STBTE__BUTTON_HEIGHT (STBTE__FONT_HEIGHT + 2 * STBTE__BUTTON_INTERNAL_SPACING) #define STBTE__BUTTON_INTERNAL_SPACING (2 + (STBTE__FONT_HEIGHT>>4)) typedef struct { const char *name; int locked; int hidden; } stbte__layer; enum { STBTE__unlocked, STBTE__protected, STBTE__locked, }; struct stbte_tilemap { stbte__tiledata data[STBTE_MAX_TILEMAP_Y][STBTE_MAX_TILEMAP_X][STBTE_MAX_LAYERS]; float props[STBTE_MAX_TILEMAP_Y][STBTE_MAX_TILEMAP_X][STBTE_MAX_PROPERTIES]; #ifdef STBTE_ALLOW_LINK stbte__link link[STBTE_MAX_TILEMAP_Y][STBTE_MAX_TILEMAP_X]; int linkcount[STBTE_MAX_TILEMAP_Y][STBTE_MAX_TILEMAP_X]; #endif int max_x, max_y, num_layers; int spacing_x, spacing_y; int palette_spacing_x, palette_spacing_y; int scroll_x,scroll_y; int cur_category, cur_tile, cur_layer; char *categories[STBTE_MAX_CATEGORIES]; int num_categories, category_scroll; stbte__tileinfo *tiles; int num_tiles, max_tiles, digits; unsigned char undo_available_valid; unsigned char undo_available; unsigned char redo_available; unsigned char padding; int cur_palette_count; int palette_scroll; int tileinfo_dirty; stbte__layer layerinfo[STBTE_MAX_LAYERS]; int has_layer_names; int layername_width; int layer_scroll; int propmode; int solo_layer; int undo_pos, undo_len, redo_len; short background_tile; unsigned char id_in_use[32768>>3]; short *undo_buffer; }; static char *default_category = "[unassigned]"; static void stbte__init_gui(void) { int i,n; stbte__ui.initted = 1; // init UI state stbte__ui.show_links = 1; for (i=0; i < STBTE__num_panel; ++i) { stbte__ui.panel[i].expanded = 1; // visible if not autohidden stbte__ui.panel[i].delta_height = 0; stbte__ui.panel[i].side = STBTE__side_left; } stbte__ui.panel[STBTE__panel_toolbar ].side = STBTE__side_top; stbte__ui.panel[STBTE__panel_colorpick].side = STBTE__side_right; if (stbte__ui.left_width == 0) stbte__ui.left_width = 80; if (stbte__ui.right_width == 0) stbte__ui.right_width = 80; // init font n=95+16; for (i=0; i < 95+16; ++i) { stbte__font_offset[i] = n; n += stbte__fontdata[i]; } } stbte_tilemap *stbte_create_map(int map_x, int map_y, int map_layers, int spacing_x, int spacing_y, int max_tiles) { int i; stbte_tilemap *tm; STBTE_ASSERT(map_layers >= 0 && map_layers <= STBTE_MAX_LAYERS); STBTE_ASSERT(map_x >= 0 && map_x <= STBTE_MAX_TILEMAP_X); STBTE_ASSERT(map_y >= 0 && map_y <= STBTE_MAX_TILEMAP_Y); if (map_x < 0 || map_y < 0 || map_layers < 0 || map_x > STBTE_MAX_TILEMAP_X || map_y > STBTE_MAX_TILEMAP_Y || map_layers > STBTE_MAX_LAYERS) return NULL; if (!stbte__ui.initted) stbte__init_gui(); tm = (stbte_tilemap *) malloc(sizeof(*tm) + sizeof(*tm->tiles) * max_tiles + STBTE_UNDO_BUFFER_BYTES); if (tm == NULL) return NULL; tm->tiles = (stbte__tileinfo *) (tm+1); tm->undo_buffer = (short *) (tm->tiles + max_tiles); tm->num_layers = map_layers; tm->max_x = map_x; tm->max_y = map_y; tm->spacing_x = spacing_x; tm->spacing_y = spacing_y; tm->scroll_x = 0; tm->scroll_y = 0; tm->palette_scroll = 0; tm->palette_spacing_x = spacing_x+1; tm->palette_spacing_y = spacing_y+1; tm->cur_category = -1; tm->cur_tile = 0; tm->solo_layer = -1; tm->undo_len = 0; tm->redo_len = 0; tm->undo_pos = 0; tm->category_scroll = 0; tm->layer_scroll = 0; tm->propmode = 0; tm->has_layer_names = 0; tm->layername_width = 0; tm->undo_available_valid = 0; for (i=0; i < tm->num_layers; ++i) { tm->layerinfo[i].hidden = 0; tm->layerinfo[i].locked = STBTE__unlocked; tm->layerinfo[i].name = 0; } tm->background_tile = STBTE__NO_TILE; stbte_clear_map(tm); tm->max_tiles = max_tiles; tm->num_tiles = 0; for (i=0; i < 32768/8; ++i) tm->id_in_use[i] = 0; tm->tileinfo_dirty = 1; return tm; } void stbte_set_background_tile(stbte_tilemap *tm, short id) { int i; STBTE_ASSERT(id >= -1 && id < 32768); if (id >= 32768 || id < -1) return; for (i=0; i < STBTE_MAX_TILEMAP_X * STBTE_MAX_TILEMAP_Y; ++i) if (tm->data[0][i][0] == -1) tm->data[0][i][0] = id; tm->background_tile = id; } void stbte_set_spacing(stbte_tilemap *tm, int spacing_x, int spacing_y, int palette_spacing_x, int palette_spacing_y) { tm->spacing_x = spacing_x; tm->spacing_y = spacing_y; tm->palette_spacing_x = palette_spacing_x; tm->palette_spacing_y = palette_spacing_y; } void stbte_set_sidewidths(int left, int right) { stbte__ui.left_width = left; stbte__ui.right_width = right; } void stbte_set_display(int x0, int y0, int x1, int y1) { stbte__ui.x0 = x0; stbte__ui.y0 = y0; stbte__ui.x1 = x1; stbte__ui.y1 = y1; } void stbte_define_tile(stbte_tilemap *tm, unsigned short id, unsigned int layermask, const char * category_c) { char *category = (char *) category_c; STBTE_ASSERT(id < 32768); STBTE_ASSERT(tm->num_tiles < tm->max_tiles); STBTE_ASSERT((tm->id_in_use[id>>3]&(1<<(id&7))) == 0); if (id >= 32768 || tm->num_tiles >= tm->max_tiles || (tm->id_in_use[id>>3]&(1<<(id&7)))) return; if (category == NULL) category = (char*) default_category; tm->id_in_use[id>>3] |= 1 << (id&7); tm->tiles[tm->num_tiles].category = category; tm->tiles[tm->num_tiles].id = id; tm->tiles[tm->num_tiles].layermask = layermask; ++tm->num_tiles; tm->tileinfo_dirty = 1; } static int stbte__text_width(const char *str); void stbte_set_layername(stbte_tilemap *tm, int layer, const char *layername) { STBTE_ASSERT(layer >= 0 && layer < tm->num_layers); if (layer >= 0 && layer < tm->num_layers) { int width; tm->layerinfo[layer].name = layername; tm->has_layer_names = 1; width = stbte__text_width(layername); tm->layername_width = (width > tm->layername_width ? width : tm->layername_width); } } void stbte_get_dimensions(stbte_tilemap *tm, int *max_x, int *max_y) { *max_x = tm->max_x; *max_y = tm->max_y; } short* stbte_get_tile(stbte_tilemap *tm, int x, int y) { STBTE_ASSERT(x >= 0 && x < tm->max_x && y >= 0 && y < tm->max_y); if (x < 0 || x >= STBTE_MAX_TILEMAP_X || y < 0 || y >= STBTE_MAX_TILEMAP_Y) return NULL; return tm->data[y][x]; } float *stbte_get_properties(stbte_tilemap *tm, int x, int y) { STBTE_ASSERT(x >= 0 && x < tm->max_x && y >= 0 && y < tm->max_y); if (x < 0 || x >= STBTE_MAX_TILEMAP_X || y < 0 || y >= STBTE_MAX_TILEMAP_Y) return NULL; return tm->props[y][x]; } void stbte_get_link(stbte_tilemap *tm, int x, int y, int *destx, int *desty) { int gx=-1,gy=-1; STBTE_ASSERT(x >= 0 && x < tm->max_x && y >= 0 && y < tm->max_y); #ifdef STBTE_ALLOW_LINK if (x >= 0 && x < STBTE_MAX_TILEMAP_X && y >= 0 && y < STBTE_MAX_TILEMAP_Y) { gx = tm->link[y][x].x; gy = tm->link[y][x].y; if (gx >= 0) if (!STBTE_ALLOW_LINK(tm->data[y][x], tm->props[y][x], tm->data[gy][gx], tm->props[gy][gx])) gx = gy = -1; } #endif *destx = gx; *desty = gy; } void stbte_set_property(stbte_tilemap *tm, int x, int y, int n, float val) { tm->props[y][x][n] = val; } static void stbte__set_link(stbte_tilemap *tm, int src_x, int src_y, int dest_x, int dest_y, int undo_mode); enum { STBTE__undo_none, STBTE__undo_record, STBTE__undo_block, }; void stbte_set_link(stbte_tilemap *tm, int x, int y, int destx, int desty) { #ifdef STBTE_ALLOW_LINK stbte__set_link(tm, x, y, destx, desty, STBTE__undo_none); #else STBTE_ASSERT(0); #endif } // returns an array of map_layers shorts. each short is either // one of the tile_id values from define_tile, or STBTE_EMPTY void stbte_set_dimensions(stbte_tilemap *tm, int map_x, int map_y) { STBTE_ASSERT(map_x >= 0 && map_x <= STBTE_MAX_TILEMAP_X); STBTE_ASSERT(map_y >= 0 && map_y <= STBTE_MAX_TILEMAP_Y); if (map_x < 0 || map_y < 0 || map_x > STBTE_MAX_TILEMAP_X || map_y > STBTE_MAX_TILEMAP_Y) return; tm->max_x = map_x; tm->max_y = map_y; } void stbte_clear_map(stbte_tilemap *tm) { int i,j; for (i=0; i < STBTE_MAX_TILEMAP_X * STBTE_MAX_TILEMAP_Y; ++i) { tm->data[0][i][0] = tm->background_tile; for (j=1; j < tm->num_layers; ++j) tm->data[0][i][j] = STBTE__NO_TILE; for (j=0; j < STBTE_MAX_PROPERTIES; ++j) tm->props[0][i][j] = 0; #ifdef STBTE_ALLOW_LINK tm->link[0][i].x = -1; tm->link[0][i].y = -1; tm->linkcount[0][i] = 0; #endif } } void stbte_set_tile(stbte_tilemap *tm, int x, int y, int layer, signed short tile) { STBTE_ASSERT(x >= 0 && x < tm->max_x && y >= 0 && y < tm->max_y); STBTE_ASSERT(layer >= 0 && layer < tm->num_layers); STBTE_ASSERT(tile >= -1 && tile < 32768); if (x < 0 || x >= STBTE_MAX_TILEMAP_X || y < 0 || y >= STBTE_MAX_TILEMAP_Y) return; if (layer < 0 || layer >= tm->num_layers || tile < -1) return; tm->data[y][x][layer] = tile; } static void stbte__choose_category(stbte_tilemap *tm, int category) { int i,n=0; tm->cur_category = category; for (i=0; i < tm->num_tiles; ++i) if (tm->tiles[i].category_id == category || category == -1) ++n; tm->cur_palette_count = n; tm->palette_scroll = 0; } static int stbte__strequal(char *p, char *q) { while (*p) if (*p++ != *q++) return 0; return *q == 0; } static void stbte__compute_tileinfo(stbte_tilemap *tm) { int i,j,n=0; tm->num_categories=0; for (i=0; i < tm->num_tiles; ++i) { stbte__tileinfo *t = &tm->tiles[i]; // find category for (j=0; j < tm->num_categories; ++j) if (stbte__strequal(t->category, tm->categories[j])) goto found; tm->categories[j] = t->category; ++tm->num_categories; found: t->category_id = (unsigned short) j; } // currently number of categories can never decrease because you // can't remove tile definitions, but let's get it right anyway if (tm->cur_category > tm->num_categories) { tm->cur_category = -1; } stbte__choose_category(tm, tm->cur_category); tm->tileinfo_dirty = 0; } static void stbte__prepare_tileinfo(stbte_tilemap *tm) { if (tm->tileinfo_dirty) stbte__compute_tileinfo(tm); } /////////////////////// undo system //////////////////////// // the undo system works by storing "commands" into a buffer, and // then playing back those commands. undo and redo have to store // the commands in different order. // // the commands are: // // 1) end_of_undo_record // -1:short // // 2) end_of_redo_record // -2:short // // 3) tile update // tile_id:short (-1..32767) // x_coord:short // y_coord:short // layer:short (0..31) // // 4) property update (also used for links) // value_hi:short // value_lo:short // y_coord:short // x_coord:short // property:short (256+prop#) // // Since we use a circular buffer, we might overwrite the undo storage. // To detect this, before playing back commands we scan back and see // if we see an end_of_undo_record before hitting the relevant boundary, // it's wholly contained. // // When we read back through, we see them in reverse order, so // we'll see the layer number or property number first // // To be clearer about the circular buffer, there are two cases: // 1. a single record is larger than the whole buffer. // this is caught because the end_of_undo_record will // get overwritten. // 2. multiple records written are larger than the whole // buffer, so some of them have been overwritten by // the later ones. this is handled by explicitly tracking // the undo length; we never try to parse the data that // got overwritten // given two points, compute the length between them #define stbte__wrap(pos) ((pos) & (STBTE__UNDO_BUFFER_COUNT-1)) #define STBTE__undo_record -2 #define STBTE__redo_record -3 #define STBTE__undo_junk -4 // this is written underneath the undo pointer, never used static void stbte__write_undo(stbte_tilemap *tm, short value) { int pos = tm->undo_pos; tm->undo_buffer[pos] = value; tm->undo_pos = stbte__wrap(pos+1); tm->undo_len += (tm->undo_len < STBTE__UNDO_BUFFER_COUNT-2); tm->redo_len -= (tm->redo_len > 0); tm->undo_available_valid = 0; } static void stbte__write_redo(stbte_tilemap *tm, short value) { int pos = tm->undo_pos; tm->undo_buffer[pos] = value; tm->undo_pos = stbte__wrap(pos-1); tm->redo_len += (tm->redo_len < STBTE__UNDO_BUFFER_COUNT-2); tm->undo_len -= (tm->undo_len > 0); tm->undo_available_valid = 0; } static void stbte__begin_undo(stbte_tilemap *tm) { tm->redo_len = 0; stbte__write_undo(tm, STBTE__undo_record); stbte__ui.undoing = 1; stbte__ui.alert_msg = 0; // clear alert if they start doing something } static void stbte__end_undo(stbte_tilemap *tm) { if (stbte__ui.undoing) { // check if anything got written int pos = stbte__wrap(tm->undo_pos-1); if (tm->undo_buffer[pos] == STBTE__undo_record) { // empty undo record, move back tm->undo_pos = pos; STBTE_ASSERT(tm->undo_len > 0); tm->undo_len -= 1; } tm->undo_buffer[tm->undo_pos] = STBTE__undo_junk; // otherwise do nothing stbte__ui.undoing = 0; } } static void stbte__undo_record(stbte_tilemap *tm, int x, int y, int i, int v) { STBTE_ASSERT(stbte__ui.undoing); if (stbte__ui.undoing) { stbte__write_undo(tm, v); stbte__write_undo(tm, x); stbte__write_undo(tm, y); stbte__write_undo(tm, i); } } static void stbte__redo_record(stbte_tilemap *tm, int x, int y, int i, int v) { stbte__write_redo(tm, v); stbte__write_redo(tm, x); stbte__write_redo(tm, y); stbte__write_redo(tm, i); } static float stbte__extract_float(short s0, short s1) { union { float f; short s[2]; } converter; converter.s[0] = s0; converter.s[1] = s1; return converter.f; } static short stbte__extract_short(float f, int slot) { union { float f; short s[2]; } converter; converter.f = f; return converter.s[slot]; } static void stbte__undo_record_prop(stbte_tilemap *tm, int x, int y, int i, short s0, short s1) { STBTE_ASSERT(stbte__ui.undoing); if (stbte__ui.undoing) { stbte__write_undo(tm, s1); stbte__write_undo(tm, s0); stbte__write_undo(tm, x); stbte__write_undo(tm, y); stbte__write_undo(tm, 256+i); } } static void stbte__undo_record_prop_float(stbte_tilemap *tm, int x, int y, int i, float f) { stbte__undo_record_prop(tm, x,y,i, stbte__extract_short(f,0), stbte__extract_short(f,1)); } static void stbte__redo_record_prop(stbte_tilemap *tm, int x, int y, int i, short s0, short s1) { stbte__write_redo(tm, s1); stbte__write_redo(tm, s0); stbte__write_redo(tm, x); stbte__write_redo(tm, y); stbte__write_redo(tm, 256+i); } static int stbte__undo_find_end(stbte_tilemap *tm) { // first scan through for the end record int i, pos = stbte__wrap(tm->undo_pos-1); for (i=0; i < tm->undo_len;) { STBTE_ASSERT(tm->undo_buffer[pos] != STBTE__undo_junk); if (tm->undo_buffer[pos] == STBTE__undo_record) break; if (tm->undo_buffer[pos] >= 255) pos = stbte__wrap(pos-5), i += 5; else pos = stbte__wrap(pos-4), i += 4; } if (i >= tm->undo_len) return -1; return pos; } static void stbte__undo(stbte_tilemap *tm) { int i, pos, endpos; endpos = stbte__undo_find_end(tm); if (endpos < 0) return; // we found a complete undo record pos = stbte__wrap(tm->undo_pos-1); // start a redo record stbte__write_redo(tm, STBTE__redo_record); // so now go back through undo and apply in reverse // order, and copy it to redo for (i=0; endpos != pos; i += 4) { int x,y,n,v; // get the undo entry n = tm->undo_buffer[pos]; y = tm->undo_buffer[stbte__wrap(pos-1)]; x = tm->undo_buffer[stbte__wrap(pos-2)]; v = tm->undo_buffer[stbte__wrap(pos-3)]; if (n >= 255) { short s0=0,s1=0; int v2 = tm->undo_buffer[stbte__wrap(pos-4)]; pos = stbte__wrap(pos-5); if (n > 255) { float vf = stbte__extract_float(v, v2); s0 = stbte__extract_short(tm->props[y][x][n-256], 0); s1 = stbte__extract_short(tm->props[y][x][n-256], 1); tm->props[y][x][n-256] = vf; } else { #ifdef STBTE_ALLOW_LINK s0 = tm->link[y][x].x; s1 = tm->link[y][x].y; stbte__set_link(tm, x,y, v, v2, STBTE__undo_none); #endif } // write the redo entry stbte__redo_record_prop(tm, x, y, n-256, s0,s1); // apply the undo entry } else { pos = stbte__wrap(pos-4); // write the redo entry stbte__redo_record(tm, x, y, n, tm->data[y][x][n]); // apply the undo entry tm->data[y][x][n] = (short) v; } } // overwrite undo record with junk tm->undo_buffer[tm->undo_pos] = STBTE__undo_junk; } static int stbte__redo_find_end(stbte_tilemap *tm) { // first scan through for the end record int i, pos = stbte__wrap(tm->undo_pos+1); for (i=0; i < tm->redo_len;) { STBTE_ASSERT(tm->undo_buffer[pos] != STBTE__undo_junk); if (tm->undo_buffer[pos] == STBTE__redo_record) break; if (tm->undo_buffer[pos] >= 255) pos = stbte__wrap(pos+5), i += 5; else pos = stbte__wrap(pos+4), i += 4; } if (i >= tm->redo_len) return -1; // this should only ever happen if redo buffer is empty return pos; } static void stbte__redo(stbte_tilemap *tm) { // first scan through for the end record int i, pos, endpos; endpos = stbte__redo_find_end(tm); if (endpos < 0) return; // we found a complete redo record pos = stbte__wrap(tm->undo_pos+1); // start an undo record stbte__write_undo(tm, STBTE__undo_record); for (i=0; pos != endpos; i += 4) { int x,y,n,v; n = tm->undo_buffer[pos]; y = tm->undo_buffer[stbte__wrap(pos+1)]; x = tm->undo_buffer[stbte__wrap(pos+2)]; v = tm->undo_buffer[stbte__wrap(pos+3)]; if (n >= 255) { int v2 = tm->undo_buffer[stbte__wrap(pos+4)]; short s0=0,s1=0; pos = stbte__wrap(pos+5); if (n > 255) { float vf = stbte__extract_float(v, v2); s0 = stbte__extract_short(tm->props[y][x][n-256],0); s1 = stbte__extract_short(tm->props[y][x][n-256],1); tm->props[y][x][n-256] = vf; } else { #ifdef STBTE_ALLOW_LINK s0 = tm->link[y][x].x; s1 = tm->link[y][x].y; stbte__set_link(tm, x,y,v,v2, STBTE__undo_none); #endif } // don't use stbte__undo_record_prop because it's guarded stbte__write_undo(tm, s1); stbte__write_undo(tm, s0); stbte__write_undo(tm, x); stbte__write_undo(tm, y); stbte__write_undo(tm, n); } else { pos = stbte__wrap(pos+4); // don't use stbte__undo_record because it's guarded stbte__write_undo(tm, tm->data[y][x][n]); stbte__write_undo(tm, x); stbte__write_undo(tm, y); stbte__write_undo(tm, n); tm->data[y][x][n] = (short) v; } } tm->undo_buffer[tm->undo_pos] = STBTE__undo_junk; } // because detecting that undo is available static void stbte__recompute_undo_available(stbte_tilemap *tm) { tm->undo_available = (stbte__undo_find_end(tm) >= 0); tm->redo_available = (stbte__redo_find_end(tm) >= 0); } static int stbte__undo_available(stbte_tilemap *tm) { if (!tm->undo_available_valid) stbte__recompute_undo_available(tm); return tm->undo_available; } static int stbte__redo_available(stbte_tilemap *tm) { if (!tm->undo_available_valid) stbte__recompute_undo_available(tm); return tm->redo_available; } /////////////////////////////////////////////////////////////////////////////////////////////////// #ifdef STBTE_ALLOW_LINK static void stbte__set_link(stbte_tilemap *tm, int src_x, int src_y, int dest_x, int dest_y, int undo_mode) { stbte__link *a; STBTE_ASSERT(src_x >= 0 && src_x < STBTE_MAX_TILEMAP_X && src_y >= 0 && src_y < STBTE_MAX_TILEMAP_Y); a = &tm->link[src_y][src_x]; // check if it's a do nothing if (a->x == dest_x && a->y == dest_y) return; if (undo_mode != STBTE__undo_none ) { if (undo_mode == STBTE__undo_block) stbte__begin_undo(tm); stbte__undo_record_prop(tm, src_x, src_y, -1, a->x, a->y); if (undo_mode == STBTE__undo_block) stbte__end_undo(tm); } // check if there's an existing link if (a->x >= 0) { // decrement existing link refcount STBTE_ASSERT(tm->linkcount[a->y][a->x] > 0); --tm->linkcount[a->y][a->x]; } // increment new dest if (dest_x >= 0) { ++tm->linkcount[dest_y][dest_x]; } a->x = dest_x; a->y = dest_y; } #endif static void stbte__draw_rect(int x0, int y0, int x1, int y1, unsigned int color) { STBTE_DRAW_RECT(x0,y0,x1,y1, color); } static void stbte__draw_line(int x0, int y0, int x1, int y1, unsigned int color) { int temp; if (x1 < x0) temp=x0,x0=x1,x1=temp; if (y1 < y0) temp=y0,y0=y1,y1=temp; stbte__draw_rect(x0,y0,x1+1,y1+1,color); } static void stbte__draw_link(int x0, int y0, int x1, int y1, unsigned int color) { stbte__draw_line(x0,y0,x0,y1, color); stbte__draw_line(x0,y1,x1,y1, color); } static void stbte__draw_frame(int x0, int y0, int x1, int y1, unsigned int color) { stbte__draw_rect(x0,y0,x1-1,y0+1,color); stbte__draw_rect(x1-1,y0,x1,y1-1,color); stbte__draw_rect(x0+1,y1-1,x1,y1,color); stbte__draw_rect(x0,y0+1,x0+1,y1,color); } static void stbte__draw_halfframe(int x0, int y0, int x1, int y1, unsigned int color) { stbte__draw_rect(x0,y0,x1,y0+1,color); stbte__draw_rect(x0,y0+1,x0+1,y1,color); } static int stbte__get_char_width(int ch) { return stbte__fontdata[ch-16]; } static short *stbte__get_char_bitmap(int ch) { return stbte__fontdata + stbte__font_offset[ch-16]; } static void stbte__draw_bitmask_as_columns(int x, int y, short bitmask, int color) { int start_i = -1, i=0; while (bitmask) { if (bitmask & (1<= 0) { stbte__draw_rect(x, y+start_i, x+1, y+i, color); start_i = -1; bitmask &= ~((1< x_end) break; stbte__draw_bitmap(x, y, cw, stbte__get_char_bitmap(c), color); if (digitspace && c == ' ') cw = stbte__get_char_width('0'); x += cw+1; } } static void stbte__draw_text(int x, int y, const char *str, int w, int color) { stbte__draw_text_core(x,y,str,w,color,0); } static int stbte__text_width(const char *str) { int x = 0; while (*str) { int c = *str++; int cw = stbte__get_char_width(c); x += cw+1; } return x; } static void stbte__draw_frame_delayed(int x0, int y0, int x1, int y1, int color) { if (stbte__ui.delaycount < STBTE__MAX_DELAYRECT) { stbte__colorrect r = { x0,y0,x1,y1,color }; stbte__ui.delayrect[stbte__ui.delaycount++] = r; } } static void stbte__flush_delay(void) { stbte__colorrect *r; int i; r = stbte__ui.delayrect; for (i=0; i < stbte__ui.delaycount; ++i,++r) stbte__draw_frame(r->x0,r->y0,r->x1,r->y1,r->color); stbte__ui.delaycount = 0; } static void stbte__activate(int id) { stbte__ui.active_id = id; stbte__ui.active_event = stbte__ui.event; stbte__ui.accum_x = 0; stbte__ui.accum_y = 0; } static int stbte__hittest(int x0, int y0, int x1, int y1, int id) { int over = stbte__ui.mx >= x0 && stbte__ui.my >= y0 && stbte__ui.mx < x1 && stbte__ui.my < y1; if (over && stbte__ui.event >= STBTE__tick) stbte__ui.next_hot_id = id; return over; } static int stbte__button_core(int id) { switch (stbte__ui.event) { case STBTE__leftdown: if (stbte__ui.hot_id == id && STBTE__INACTIVE()) stbte__activate(id); break; case STBTE__leftup: if (stbte__ui.active_id == id && STBTE__IS_HOT(id)) { stbte__activate(0); return 1; } break; case STBTE__rightdown: if (stbte__ui.hot_id == id && STBTE__INACTIVE()) stbte__activate(id); break; case STBTE__rightup: if (stbte__ui.active_id == id && STBTE__IS_HOT(id)) { stbte__activate(0); return -1; } break; } return 0; } static void stbte__draw_box(int x0, int y0, int x1, int y1, int colormode, int colorindex) { stbte__draw_rect (x0,y0,x1,y1, stbte__color_table[colormode][STBTE__base ][colorindex]); stbte__draw_frame(x0,y0,x1,y1, stbte__color_table[colormode][STBTE__outline][colorindex]); } static void stbte__draw_textbox(int x0, int y0, int x1, int y1, char *text, int xoff, int yoff, int colormode, int colorindex) { stbte__draw_box(x0,y0,x1,y1,colormode,colorindex); stbte__draw_text(x0+xoff,y0+yoff, text, x1-x0-xoff-1, stbte__color_table[colormode][STBTE__text][colorindex]); } static int stbte__button(int colormode, char *label, int x, int y, int textoff, int width, int id, int toggled, int disabled) { int x0=x,y0=y, x1=x+width,y1=y+STBTE__BUTTON_HEIGHT; int s = STBTE__BUTTON_INTERNAL_SPACING; int over = !disabled && stbte__hittest(x0,y0,x1,y1,id); if (stbte__ui.event == STBTE__paint) stbte__draw_textbox(x0,y0,x1,y1, label,s+textoff,s, colormode, STBTE__INDEX_FOR_ID(id,disabled,toggled)); if (disabled) return 0; return (stbte__button_core(id) == 1); } static int stbte__button_icon(int colormode, char ch, int x, int y, int width, int id, int toggled, int disabled) { int x0=x,y0=y, x1=x+width,y1=y+STBTE__BUTTON_HEIGHT; int s = STBTE__BUTTON_INTERNAL_SPACING; int over = stbte__hittest(x0,y0,x1,y1,id); if (stbte__ui.event == STBTE__paint) { char label[2] = { ch, 0 }; int pad = (9 - stbte__get_char_width(ch))/2; stbte__draw_textbox(x0,y0,x1,y1, label,s+pad,s, colormode, STBTE__INDEX_FOR_ID(id,disabled,toggled)); } if (disabled) return 0; return (stbte__button_core(id) == 1); } static int stbte__minibutton(int colormode, int x, int y, int ch, int id) { int x0 = x, y0 = y, x1 = x+8, y1 = y+7; int over = stbte__hittest(x0,y0,x1,y1,id); if (stbte__ui.event == STBTE__paint) { char str[2] = { ch,0 }; stbte__draw_textbox(x0,y0,x1,y1, str,1,0,colormode, STBTE__INDEX_FOR_ID(id,0,0)); } return stbte__button_core(id); } static int stbte__layerbutton(int x, int y, int ch, int id, int toggled, int disabled, int colormode) { int x0 = x, y0 = y, x1 = x+10, y1 = y+11; int over = !disabled && stbte__hittest(x0,y0,x1,y1,id); if (stbte__ui.event == STBTE__paint) { char str[2] = { ch,0 }; int off = (9-stbte__get_char_width(ch))/2; stbte__draw_textbox(x0,y0,x1,y1, str, off+1,2, colormode, STBTE__INDEX_FOR_ID(id,disabled,toggled)); } if (disabled) return 0; return stbte__button_core(id); } static int stbte__microbutton(int x, int y, int size, int id, int colormode) { int x0 = x, y0 = y, x1 = x+size, y1 = y+size; int over = stbte__hittest(x0,y0,x1,y1,id); if (stbte__ui.event == STBTE__paint) { stbte__draw_box(x0,y0,x1,y1, colormode, STBTE__INDEX_FOR_ID(id,0,0)); } return stbte__button_core(id); } static int stbte__microbutton_dragger(int x, int y, int size, int id, int *pos) { int x0 = x, y0 = y, x1 = x+size, y1 = y+size; int over = stbte__hittest(x0,y0,x1,y1,id); switch (stbte__ui.event) { case STBTE__paint: stbte__draw_box(x0,y0,x1,y1, STBTE__cexpander, STBTE__INDEX_FOR_ID(id,0,0)); break; case STBTE__leftdown: if (STBTE__IS_HOT(id) && STBTE__INACTIVE()) { stbte__activate(id); stbte__ui.sx = stbte__ui.mx - *pos; } break; case STBTE__mousemove: if (STBTE__IS_ACTIVE(id) && stbte__ui.active_event == STBTE__leftdown) { *pos = stbte__ui.mx - stbte__ui.sx; } break; case STBTE__leftup: if (STBTE__IS_ACTIVE(id)) stbte__activate(0); break; default: return stbte__button_core(id); } return 0; } static int stbte__category_button(char *label, int x, int y, int width, int id, int toggled) { int x0=x,y0=y, x1=x+width,y1=y+STBTE__BUTTON_HEIGHT; int s = STBTE__BUTTON_INTERNAL_SPACING; int over = stbte__hittest(x0,y0,x1,y1,id); if (stbte__ui.event == STBTE__paint) stbte__draw_textbox(x0,y0,x1,y1, label, s,s, STBTE__ccategory_button, STBTE__INDEX_FOR_ID(id,0,toggled)); return (stbte__button_core(id) == 1); } enum { STBTE__none, STBTE__begin, STBTE__end, STBTE__change, }; // returns -1 if value changes, 1 at end of drag static int stbte__slider(int x0, int w, int y, int range, int *value, int id) { int x1 = x0+w; int pos = *value * w / (range+1); int over = stbte__hittest(x0,y-2,x1,y+3,id); int event_mouse_move = STBTE__change; switch (stbte__ui.event) { case STBTE__paint: stbte__draw_rect(x0,y,x1,y+1, 0x808080); stbte__draw_rect(x0+pos-1,y-1,x0+pos+2,y+2, 0xffffff); break; case STBTE__leftdown: if (STBTE__IS_HOT(id) && STBTE__INACTIVE()) { stbte__activate(id); event_mouse_move = STBTE__begin; } // fall through case STBTE__mousemove: if (STBTE__IS_ACTIVE(id)) { int v = (stbte__ui.mx-x0)*(range+1)/w; if (v < 0) v = 0; else if (v > range) v = range; *value = v; return event_mouse_move; } break; case STBTE__leftup: if (STBTE__IS_ACTIVE(id)) { stbte__activate(0); return STBTE__end; } break; } return STBTE__none; } static int stbte__float_control(int x0, int y0, int w, float minv, float maxv, float scale, char *fmt, float *value, int colormode, int id) { int x1 = x0+w; int y1 = y0+11; int over = stbte__hittest(x0,y0,x1,y1,id); switch (stbte__ui.event) { case STBTE__paint: { char text[32]; sprintf(text, fmt ? fmt : "%6.2f", *value); stbte__draw_textbox(x0,y0,x1,y1, text, 1,2, colormode, STBTE__INDEX_FOR_ID(id,0,0)); break; } case STBTE__leftdown: case STBTE__rightdown: if (STBTE__IS_HOT(id) && STBTE__INACTIVE()) stbte__activate(id); return STBTE__begin; break; case STBTE__leftup: case STBTE__rightup: if (STBTE__IS_ACTIVE(id)) { stbte__activate(0); return STBTE__end; } break; case STBTE__mousemove: if (STBTE__IS_ACTIVE(id)) { float v = *value, delta; int ax = stbte__ui.accum_x/STBTE_FLOAT_CONTROL_GRANULARITY; int ay = stbte__ui.accum_y/STBTE_FLOAT_CONTROL_GRANULARITY; stbte__ui.accum_x -= ax*STBTE_FLOAT_CONTROL_GRANULARITY; stbte__ui.accum_y -= ay*STBTE_FLOAT_CONTROL_GRANULARITY; if (stbte__ui.shift) { if (stbte__ui.active_event == STBTE__leftdown) delta = ax * 16.0f + ay; else delta = ax / 16.0f + ay / 256.0f; } else { if (stbte__ui.active_event == STBTE__leftdown) delta = ax*10.0f + ay; else delta = ax * 0.1f + ay * 0.01f; } v += delta * scale; if (v < minv) v = minv; if (v > maxv) v = maxv; *value = v; return STBTE__change; } break; } return STBTE__none; } static void stbte__scrollbar(int x, int y0, int y1, int *val, int v0, int v1, int num_vis, int id) { int over; int thumbpos; if (v1 - v0 <= num_vis) return; // generate thumbpos from numvis thumbpos = y0+2 + (y1-y0-4) * *val / (v1 - v0 - num_vis); if (thumbpos < y0) thumbpos = y0; if (thumbpos >= y1) thumbpos = y1; over = stbte__hittest(x-1,y0,x+2,y1,id); switch (stbte__ui.event) { case STBTE__paint: stbte__draw_rect(x,y0,x+1,y1, stbte__color_table[STBTE__cscrollbar][STBTE__text][STBTE__idle]); stbte__draw_box(x-1,thumbpos-3,x+2,thumbpos+4, STBTE__cscrollbar, STBTE__INDEX_FOR_ID(id,0,0)); break; case STBTE__leftdown: if (STBTE__IS_HOT(id) && STBTE__INACTIVE()) { // check if it's over the thumb stbte__activate(id); *val = ((stbte__ui.my-y0) * (v1 - v0 - num_vis) + (y1-y0)/2)/ (y1-y0); } break; case STBTE__mousemove: if (STBTE__IS_ACTIVE(id) && stbte__ui.mx >= x-15 && stbte__ui.mx <= x+15) *val = ((stbte__ui.my-y0) * (v1 - v0 - num_vis) + (y1-y0)/2)/ (y1-y0); break; case STBTE__leftup: if (STBTE__IS_ACTIVE(id)) stbte__activate(0); break; } if (*val >= v1-num_vis) *val = v1-num_vis; if (*val <= v0) *val = v0; } static void stbte__compute_digits(stbte_tilemap *tm) { if (tm->max_x >= 1000 || tm->max_y >= 1000) tm->digits = 4; else if (tm->max_x >= 100 || tm->max_y >= 100) tm->digits = 3; else tm->digits = 2; } static int stbte__is_single_selection(void) { return stbte__ui.has_selection && stbte__ui.select_x0 == stbte__ui.select_x1 && stbte__ui.select_y0 == stbte__ui.select_y1; } typedef struct { int width, height; int x,y; int active; float retracted; } stbte__region_t; static stbte__region_t stbte__region[4]; #define STBTE__TOOLBAR_ICON_SIZE (9+2*2) #define STBTE__TOOLBAR_PASTE_SIZE (34+2*2) // This routine computes where every panel goes onscreen: computes // a minimum width for each side based on which panels are on that // side, and accounts for width-dependent layout of certain panels. static void stbte__compute_panel_locations(stbte_tilemap *tm) { int i, limit, w, k; int window_width = stbte__ui.x1 - stbte__ui.x0; int window_height = stbte__ui.y1 - stbte__ui.y0; int min_width[STBTE__num_panel]={0,0,0,0,0,0,0}; int height[STBTE__num_panel]={0,0,0,0,0,0,0}; int panel_active[STBTE__num_panel]={1,0,1,1,1,1,1}; int vpos[4] = { 0,0,0,0 }; stbte__panel *p = stbte__ui.panel; stbte__panel *pt = &p[STBTE__panel_toolbar]; #ifdef STBTE__NO_PROPS int props = 0; #else int props = 1; #endif for (i=0; i < 4; ++i) { stbte__region[i].active = 0; stbte__region[i].width = 0; stbte__region[i].height = 0; } // compute number of digits needs for info panel stbte__compute_digits(tm); // determine which panels are active panel_active[STBTE__panel_categories] = tm->num_categories != 0; panel_active[STBTE__panel_layers ] = tm->num_layers > 1; #ifdef STBTE__COLORPICKER panel_active[STBTE__panel_colorpick ] = 1; #endif panel_active[STBTE__panel_props ] = props && stbte__is_single_selection(); // compute minimum widths for each panel (assuming they're on sides not top) min_width[STBTE__panel_info ] = 8 + 11 + 7*tm->digits+17+7; // estimate min width of "w:0000" min_width[STBTE__panel_colorpick ] = 120; min_width[STBTE__panel_tiles ] = 4 + tm->palette_spacing_x + 5; // 5 for scrollbar min_width[STBTE__panel_categories] = 4 + 42 + 5; // 42 is enough to show ~7 chars; 5 for scrollbar min_width[STBTE__panel_layers ] = 4 + 54 + 30*tm->has_layer_names; // 2 digits plus 3 buttons plus scrollbar min_width[STBTE__panel_toolbar ] = 4 + STBTE__TOOLBAR_PASTE_SIZE; // wide enough for 'Paste' button min_width[STBTE__panel_props ] = 80; // narrowest info panel // compute minimum widths for left & right panels based on the above stbte__region[0].width = stbte__ui.left_width; stbte__region[1].width = stbte__ui.right_width; for (i=0; i < STBTE__num_panel; ++i) { if (panel_active[i]) { int side = stbte__ui.panel[i].side; if (min_width[i] > stbte__region[side].width) stbte__region[side].width = min_width[i]; stbte__region[side].active = 1; } } // now compute the heights of each panel // if toolbar at top, compute its size & push the left and right start points down if (stbte__region[STBTE__side_top].active) { int height = STBTE__TOOLBAR_ICON_SIZE+2; pt->x0 = stbte__ui.x0; pt->y0 = stbte__ui.y0; pt->width = window_width; pt->height = height; vpos[STBTE__side_left] = vpos[STBTE__side_right] = height; } else { int num_rows = STBTE__num_tool * ((stbte__region[pt->side].width-4)/STBTE__TOOLBAR_ICON_SIZE); height[STBTE__panel_toolbar] = num_rows*13 + 3*15 + 4; // 3*15 for cut/copy/paste, which are stacked vertically } for (i=0; i < 4; ++i) stbte__region[i].y = stbte__ui.y0 + vpos[i]; for (i=0; i < 2; ++i) { int anim = (int) (stbte__region[i].width * stbte__region[i].retracted); stbte__region[i].x = (i == STBTE__side_left) ? stbte__ui.x0 - anim : stbte__ui.x1 - stbte__region[i].width + anim; } // color picker height[STBTE__panel_colorpick] = 300; // info panel w = stbte__region[p[STBTE__panel_info].side].width; p[STBTE__panel_info].mode = (w >= 8 + (11+7*tm->digits+17)*2 + 4); if (p[STBTE__panel_info].mode) height[STBTE__panel_info] = 5 + 11*2 + 2 + tm->palette_spacing_y; else height[STBTE__panel_info] = 5 + 11*4 + 2 + tm->palette_spacing_y; // layers limit = 6 + stbte__ui.panel[STBTE__panel_layers].delta_height; height[STBTE__panel_layers] = (tm->num_layers > limit ? limit : tm->num_layers)*15 + 7 + (tm->has_layer_names ? 0 : 11) + props*13; // categories limit = 6 + stbte__ui.panel[STBTE__panel_categories].delta_height; height[STBTE__panel_categories] = (tm->num_categories+1 > limit ? limit : tm->num_categories+1)*11 + 14; if (stbte__ui.panel[STBTE__panel_categories].side == stbte__ui.panel[STBTE__panel_categories].side) height[STBTE__panel_categories] -= 4; // palette k = (stbte__region[p[STBTE__panel_tiles].side].width - 8) / tm->palette_spacing_x; if (k == 0) k = 1; height[STBTE__panel_tiles] = ((tm->num_tiles+k-1)/k) * tm->palette_spacing_y + 8; // properties panel height[STBTE__panel_props] = 9 + STBTE_MAX_PROPERTIES*14; // now compute the locations of all the panels for (i=0; i < STBTE__num_panel; ++i) { if (panel_active[i]) { int side = p[i].side; if (side == STBTE__side_left || side == STBTE__side_right) { p[i].width = stbte__region[side].width; p[i].x0 = stbte__region[side].x; p[i].y0 = stbte__ui.y0 + vpos[side]; p[i].height = height[i]; vpos[side] += height[i]; if (vpos[side] > window_height) { vpos[side] = window_height; p[i].height = stbte__ui.y1 - p[i].y0; } } else { ; // it's at top, it's already been explicitly set up earlier } } else { // inactive panel p[i].height = 0; p[i].width = 0; p[i].x0 = stbte__ui.x1; p[i].y0 = stbte__ui.y1; } } } // unique identifiers for imgui enum { STBTE__map=1, STBTE__region, STBTE__panel, // panel background to hide map, and misc controls STBTE__info, // info data STBTE__toolbarA, STBTE__toolbarB, // toolbar buttons: param is tool number STBTE__palette, // palette selectors: param is tile index STBTE__categories, // category selectors: param is category index STBTE__layer, // STBTE__solo, STBTE__hide, STBTE__lock, // layer controls: param is layer STBTE__scrollbar, // param is panel ID STBTE__panel_mover, // p1 is panel ID, p2 is destination side STBTE__panel_sizer, // param panel ID STBTE__scrollbar_id, STBTE__colorpick_id, STBTE__prop_flag, STBTE__prop_float, STBTE__prop_int, }; // id is: [ 24-bit data : 7-bit identifer ] // map id is: [ 12-bit y : 12 bit x : 7-bit identifier ] #define STBTE__ID(n,p) ((n) + ((p)<<7)) #define STBTE__ID2(n,p,q) STBTE__ID(n, ((p)<<12)+(q) ) #define STBTE__IDMAP(x,y) STBTE__ID2(STBTE__map, x,y) static void stbte__activate_map(int x, int y) { stbte__ui.active_id = STBTE__IDMAP(x,y); stbte__ui.active_event = stbte__ui.event; stbte__ui.sx = x; stbte__ui.sy = y; } static void stbte__alert(const char *msg) { stbte__ui.alert_msg = msg; stbte__ui.alert_timer = 3; } #define STBTE__BG(tm,layer) ((layer) == 0 ? (tm)->background_tile : STBTE__NO_TILE) static void stbte__brush_predict(stbte_tilemap *tm, short result[]) { int layer_to_paint = tm->cur_layer; stbte__tileinfo *ti; int i; if (tm->cur_tile < 0) return; ti = &tm->tiles[tm->cur_tile]; // find lowest legit layer to paint it on, and put it there for (i=0; i < tm->num_layers; ++i) { // check if object is allowed on layer if (!(ti->layermask & (1 << i))) continue; if (i != tm->solo_layer) { // if there's a selected layer, can only paint on that if (tm->cur_layer >= 0 && i != tm->cur_layer) continue; // if the layer is hidden, we can't see it if (tm->layerinfo[i].hidden) continue; // if the layer is locked, we can't write to it if (tm->layerinfo[i].locked == STBTE__locked) continue; // if the layer is non-empty and protected, can't write to it if (tm->layerinfo[i].locked == STBTE__protected && result[i] != STBTE__BG(tm,i)) continue; } result[i] = ti->id; return; } } static void stbte__brush(stbte_tilemap *tm, int x, int y) { int layer_to_paint = tm->cur_layer; stbte__tileinfo *ti; // find lowest legit layer to paint it on, and put it there int i; if (tm->cur_tile < 0) return; ti = &tm->tiles[tm->cur_tile]; for (i=0; i < tm->num_layers; ++i) { // check if object is allowed on layer if (!(ti->layermask & (1 << i))) continue; if (i != tm->solo_layer) { // if there's a selected layer, can only paint on that if (tm->cur_layer >= 0 && i != tm->cur_layer) continue; // if the layer is hidden, we can't see it if (tm->layerinfo[i].hidden) continue; // if the layer is locked, we can't write to it if (tm->layerinfo[i].locked == STBTE__locked) continue; // if the layer is non-empty and protected, can't write to it if (tm->layerinfo[i].locked == STBTE__protected && tm->data[y][x][i] != STBTE__BG(tm,i)) continue; } stbte__undo_record(tm,x,y,i,tm->data[y][x][i]); tm->data[y][x][i] = ti->id; return; } //stbte__alert("Selected tile not valid on active layer(s)"); } enum { STBTE__erase_none = -1, STBTE__erase_brushonly = 0, STBTE__erase_any = 1, STBTE__erase_all = 2, }; static int stbte__erase_predict(stbte_tilemap *tm, short result[], int allow_any) { stbte__tileinfo *ti = tm->cur_tile >= 0 ? &tm->tiles[tm->cur_tile] : NULL; int i; if (allow_any == STBTE__erase_none) return allow_any; // first check if only one layer is legit i = tm->cur_layer; if (tm->solo_layer >= 0) i = tm->solo_layer; // if only one layer is legit, directly process that one for clarity if (i >= 0) { short bg = (i == 0 ? tm->background_tile : -1); if (tm->solo_layer < 0) { // check that we're allowed to write to it if (tm->layerinfo[i].hidden) return STBTE__erase_none; if (tm->layerinfo[i].locked) return STBTE__erase_none; } if (result[i] == bg) return STBTE__erase_none; // didn't erase anything if (ti && result[i] == ti->id && (i != 0 || ti->id != tm->background_tile)) { result[i] = bg; return STBTE__erase_brushonly; } if (allow_any == STBTE__erase_any) { result[i] = bg; return STBTE__erase_any; } return STBTE__erase_none; } // if multiple layers are legit, first scan all for brush data if (ti && allow_any != STBTE__erase_all) { for (i=tm->num_layers-1; i >= 0; --i) { if (result[i] != ti->id) continue; if (tm->layerinfo[i].locked || tm->layerinfo[i].hidden) continue; if (i == 0 && result[i] == tm->background_tile) return STBTE__erase_none; result[i] = STBTE__BG(tm,i); return STBTE__erase_brushonly; } } if (allow_any != STBTE__erase_any && allow_any != STBTE__erase_all) return STBTE__erase_none; // apply layer filters, erase from top for (i=tm->num_layers-1; i >= 0; --i) { if (result[i] < 0) continue; if (tm->layerinfo[i].locked || tm->layerinfo[i].hidden) continue; if (i == 0 && result[i] == tm->background_tile) return STBTE__erase_none; result[i] = STBTE__BG(tm,i); if (allow_any != STBTE__erase_all) return STBTE__erase_any; } if (allow_any == STBTE__erase_all) return allow_any; return STBTE__erase_none; } static int stbte__erase(stbte_tilemap *tm, int x, int y, int allow_any) { stbte__tileinfo *ti = tm->cur_tile >= 0 ? &tm->tiles[tm->cur_tile] : NULL; int i; if (allow_any == STBTE__erase_none) return allow_any; // first check if only one layer is legit i = tm->cur_layer; if (tm->solo_layer >= 0) i = tm->solo_layer; // if only one layer is legit, directly process that one for clarity if (i >= 0) { short bg = (i == 0 ? tm->background_tile : -1); if (tm->solo_layer < 0) { // check that we're allowed to write to it if (tm->layerinfo[i].hidden) return STBTE__erase_none; if (tm->layerinfo[i].locked) return STBTE__erase_none; } if (tm->data[y][x][i] == bg) return -1; // didn't erase anything if (ti && tm->data[y][x][i] == ti->id && (i != 0 || ti->id != tm->background_tile)) { stbte__undo_record(tm,x,y,i,tm->data[y][x][i]); tm->data[y][x][i] = bg; return STBTE__erase_brushonly; } if (allow_any == STBTE__erase_any) { stbte__undo_record(tm,x,y,i,tm->data[y][x][i]); tm->data[y][x][i] = bg; return STBTE__erase_any; } return STBTE__erase_none; } // if multiple layers are legit, first scan all for brush data if (ti && allow_any != STBTE__erase_all) { for (i=tm->num_layers-1; i >= 0; --i) { if (tm->data[y][x][i] != ti->id) continue; if (tm->layerinfo[i].locked || tm->layerinfo[i].hidden) continue; if (i == 0 && tm->data[y][x][i] == tm->background_tile) return STBTE__erase_none; stbte__undo_record(tm,x,y,i,tm->data[y][x][i]); tm->data[y][x][i] = STBTE__BG(tm,i); return STBTE__erase_brushonly; } } if (allow_any != STBTE__erase_any && allow_any != STBTE__erase_all) return STBTE__erase_none; // apply layer filters, erase from top for (i=tm->num_layers-1; i >= 0; --i) { if (tm->data[y][x][i] < 0) continue; if (tm->layerinfo[i].locked || tm->layerinfo[i].hidden) continue; if (i == 0 && tm->data[y][x][i] == tm->background_tile) return STBTE__erase_none; stbte__undo_record(tm,x,y,i,tm->data[y][x][i]); tm->data[y][x][i] = STBTE__BG(tm,i); if (allow_any != STBTE__erase_all) return STBTE__erase_any; } if (allow_any == STBTE__erase_all) return allow_any; return STBTE__erase_none; } static int stbte__find_tile(stbte_tilemap *tm, int tile_id) { int i; for (i=0; i < tm->num_tiles; ++i) if (tm->tiles[i].id == tile_id) return i; stbte__alert("Eyedropped tile that isn't in tileset"); return -1; } static void stbte__eyedrop(stbte_tilemap *tm, int x, int y) { int i,j; // flush eyedropper state if (stbte__ui.eyedrop_x != x || stbte__ui.eyedrop_y != y) { stbte__ui.eyedrop_x = x; stbte__ui.eyedrop_y = y; stbte__ui.eyedrop_last_layer = tm->num_layers; } // if only one layer is active, query that i = tm->cur_layer; if (tm->solo_layer >= 0) i = tm->solo_layer; if (i >= 0) { if (tm->data[y][x][i] == STBTE__NO_TILE) return; tm->cur_tile = stbte__find_tile(tm, tm->data[y][x][i]); return; } // if multiple layers, continue from previous i = stbte__ui.eyedrop_last_layer; for (j=0; j < tm->num_layers; ++j) { if (--i < 0) i = tm->num_layers-1; if (tm->layerinfo[i].hidden) continue; if (tm->data[y][x][i] == STBTE__NO_TILE) continue; stbte__ui.eyedrop_last_layer = i; tm->cur_tile = stbte__find_tile(tm, tm->data[y][x][i]); return; } } static int stbte__should_copy_properties(stbte_tilemap *tm) { int i; if (tm->propmode == STBTE__propmode_always) return 1; if (tm->propmode == STBTE__propmode_never) return 0; if (tm->solo_layer >= 0 || tm->cur_layer >= 0) return 0; for (i=0; i < tm->num_layers; ++i) if (tm->layerinfo[i].hidden || tm->layerinfo[i].locked) return 0; return 1; } // compute the result of pasting into a tile non-destructively so we can preview it static void stbte__paste_stack(stbte_tilemap *tm, short result[], short dest[], short src[], int dragging) { int i; // special case single-layer i = tm->cur_layer; if (tm->solo_layer >= 0) i = tm->solo_layer; if (i >= 0) { if (tm->solo_layer < 0) { // check that we're allowed to write to it if (tm->layerinfo[i].hidden) return; if (tm->layerinfo[i].locked == STBTE__locked) return; // if protected, dest has to be empty if (tm->layerinfo[i].locked == STBTE__protected && dest[i] != STBTE__BG(tm,i)) return; // if dragging w/o copy, we will try to erase stuff, which protection disallows if (dragging && tm->layerinfo[i].locked == STBTE__protected) return; } result[i] = dest[i]; if (src[i] != STBTE__BG(tm,i)) result[i] = src[i]; return; } for (i=0; i < tm->num_layers; ++i) { result[i] = dest[i]; if (src[i] != STBTE__NO_TILE) if (!tm->layerinfo[i].hidden && tm->layerinfo[i].locked != STBTE__locked) if (tm->layerinfo[i].locked == STBTE__unlocked || (!dragging && dest[i] == STBTE__BG(tm,i))) result[i] = src[i]; } } // compute the result of dragging away from a tile static void stbte__clear_stack(stbte_tilemap *tm, short result[]) { int i; // special case single-layer i = tm->cur_layer; if (tm->solo_layer >= 0) i = tm->solo_layer; if (i >= 0) result[i] = STBTE__BG(tm,i); else for (i=0; i < tm->num_layers; ++i) if (!tm->layerinfo[i].hidden && tm->layerinfo[i].locked == STBTE__unlocked) result[i] = STBTE__BG(tm,i); } // check if some map square is active #define STBTE__IS_MAP_ACTIVE() ((stbte__ui.active_id & 127) == STBTE__map) #define STBTE__IS_MAP_HOT() ((stbte__ui.hot_id & 127) == STBTE__map) static void stbte__fillrect(stbte_tilemap *tm, int x0, int y0, int x1, int y1, int fill) { int i,j; int x=x0,y=y0; stbte__begin_undo(tm); if (x0 > x1) i=x0,x0=x1,x1=i; if (y0 > y1) j=y0,y0=y1,y1=j; for (j=y0; j <= y1; ++j) for (i=x0; i <= x1; ++i) if (fill) stbte__brush(tm, i,j); else stbte__erase(tm, i,j,STBTE__erase_any); stbte__end_undo(tm); // suppress warning from brush stbte__ui.alert_msg = 0; } static void stbte__select_rect(stbte_tilemap *tm, int x0, int y0, int x1, int y1) { stbte__ui.has_selection = 1; stbte__ui.select_x0 = (x0 < x1 ? x0 : x1); stbte__ui.select_x1 = (x0 < x1 ? x1 : x0); stbte__ui.select_y0 = (y0 < y1 ? y0 : y1); stbte__ui.select_y1 = (y0 < y1 ? y1 : y0); } static void stbte__copy_properties(float *dest, float *src) { int i; for (i=0; i < STBTE_MAX_PROPERTIES; ++i) dest[i] = src[i]; } static void stbte__copy_cut(stbte_tilemap *tm, int cut) { int i,j,n,w,h,p=0; int copy_props = stbte__should_copy_properties(tm); if (!stbte__ui.has_selection) return; w = stbte__ui.select_x1 - stbte__ui.select_x0 + 1; h = stbte__ui.select_y1 - stbte__ui.select_y0 + 1; if (STBTE_MAX_COPY / w < h) { stbte__alert("Selection too large for copy buffer, increase STBTE_MAX_COPY"); return; } for (i=0; i < w*h; ++i) for (n=0; n < tm->num_layers; ++n) stbte__ui.copybuffer[i][n] = STBTE__NO_TILE; if (cut) stbte__begin_undo(tm); for (j=stbte__ui.select_y0; j <= stbte__ui.select_y1; ++j) { for (i=stbte__ui.select_x0; i <= stbte__ui.select_x1; ++i) { for (n=0; n < tm->num_layers; ++n) { if (tm->solo_layer >= 0) { if (tm->solo_layer != n) continue; } else { if (tm->cur_layer >= 0) if (tm->cur_layer != n) continue; if (tm->layerinfo[n].hidden) continue; if (cut && tm->layerinfo[n].locked) continue; } stbte__ui.copybuffer[p][n] = tm->data[j][i][n]; if (cut) { stbte__undo_record(tm,i,j,n, tm->data[j][i][n]); tm->data[j][i][n] = (n==0 ? tm->background_tile : -1); } } if (copy_props) { stbte__copy_properties(stbte__ui.copyprops[p], tm->props[j][i]); #ifdef STBTE_ALLOW_LINK stbte__ui.copylinks[p] = tm->link[j][i]; if (cut) stbte__set_link(tm, i,j,-1,-1, STBTE__undo_record); #endif } ++p; } } if (cut) stbte__end_undo(tm); stbte__ui.copy_width = w; stbte__ui.copy_height = h; stbte__ui.has_copy = 1; //stbte__ui.has_selection = 0; stbte__ui.copy_has_props = copy_props; stbte__ui.copy_src = tm; // used to give better semantics when copying links stbte__ui.copy_src_x = stbte__ui.select_x0; stbte__ui.copy_src_y = stbte__ui.select_y0; } static int stbte__in_rect(int x, int y, int x0, int y0, int w, int h) { return x >= x0 && x < x0+w && y >= y0 && y < y0+h; } static int stbte__in_src_rect(int x, int y) { return stbte__in_rect(x,y, stbte__ui.copy_src_x, stbte__ui.copy_src_y, stbte__ui.copy_width, stbte__ui.copy_height); } static int stbte__in_dest_rect(int x, int y, int destx, int desty) { return stbte__in_rect(x,y, destx, desty, stbte__ui.copy_width, stbte__ui.copy_height); } static void stbte__paste(stbte_tilemap *tm, int mapx, int mapy) { int w = stbte__ui.copy_width; int h = stbte__ui.copy_height; int i,j,k,p; int x = mapx - (w>>1); int y = mapy - (h>>1); int copy_props = stbte__should_copy_properties(tm) && stbte__ui.copy_has_props; if (stbte__ui.has_copy == 0) return; stbte__begin_undo(tm); p = 0; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { if (y+j >= 0 && y+j < tm->max_y && x+i >= 0 && x+i < tm->max_x) { // compute the new stack short tilestack[STBTE_MAX_LAYERS]; for (k=0; k < tm->num_layers; ++k) tilestack[k] = tm->data[y+j][x+i][k]; stbte__paste_stack(tm, tilestack, tilestack, stbte__ui.copybuffer[p], 0); // update anything that changed for (k=0; k < tm->num_layers; ++k) { if (tilestack[k] != tm->data[y+j][x+i][k]) { stbte__undo_record(tm, x+i,y+j,k, tm->data[y+j][x+i][k]); tm->data[y+j][x+i][k] = tilestack[k]; } } } if (copy_props) { #ifdef STBTE_ALLOW_LINK // need to decide how to paste a link, so there's a few cases int destx = -1, desty = -1; stbte__link *link = &stbte__ui.copylinks[p]; // check if link is within-rect if (stbte__in_src_rect(link->x, link->y)) { // new link should point to copy (but only if copy is within map) destx = x + (link->x - stbte__ui.copy_src_x); desty = y + (link->y - stbte__ui.copy_src_y); } else if (tm == stbte__ui.copy_src) { // if same map, then preserve link unless target is overwritten if (!stbte__in_dest_rect(link->x,link->y,x,y)) { destx = link->x; desty = link->y; } } // this is necessary for offset-copy, but also in case max_x/max_y has changed if (destx < 0 || destx >= tm->max_x || desty < 0 || desty >= tm->max_y) destx = -1, desty = -1; stbte__set_link(tm, x+i, y+j, destx, desty, STBTE__undo_record); #endif for (k=0; k < STBTE_MAX_PROPERTIES; ++k) { if (tm->props[y+j][x+i][k] != stbte__ui.copyprops[p][k]) stbte__undo_record_prop_float(tm, x+i, y+j, k, tm->props[y+j][x+i][k]); } stbte__copy_properties(tm->props[y+j][x+i], stbte__ui.copyprops[p]); } ++p; } } stbte__end_undo(tm); } static void stbte__drag_update(stbte_tilemap *tm, int mapx, int mapy, int copy_props) { int w = stbte__ui.drag_w, h = stbte__ui.drag_h; int ox,oy,i,deleted=0,written=0; short temp[STBTE_MAX_LAYERS]; short *data = NULL; if (!stbte__ui.shift) { ox = mapx - stbte__ui.drag_x; oy = mapy - stbte__ui.drag_y; if (ox >= 0 && ox < w && oy >= 0 && oy < h) { deleted=1; for (i=0; i < tm->num_layers; ++i) temp[i] = tm->data[mapy][mapx][i]; data = temp; stbte__clear_stack(tm, data); } } ox = mapx - stbte__ui.drag_dest_x; oy = mapy - stbte__ui.drag_dest_y; // if this map square is in the target drag region if (ox >= 0 && ox < w && oy >= 0 && oy < h) { // and the src map square is on the map if (stbte__in_rect(stbte__ui.drag_x+ox, stbte__ui.drag_y+oy, 0, 0, tm->max_x, tm->max_y)) { written = 1; if (data == NULL) { for (i=0; i < tm->num_layers; ++i) temp[i] = tm->data[mapy][mapx][i]; data = temp; } stbte__paste_stack(tm, data, data, tm->data[stbte__ui.drag_y+oy][stbte__ui.drag_x+ox], !stbte__ui.shift); if (copy_props) { for (i=0; i < STBTE_MAX_PROPERTIES; ++i) { if (tm->props[mapy][mapx][i] != tm->props[stbte__ui.drag_y+oy][stbte__ui.drag_x+ox][i]) { stbte__undo_record_prop_float(tm, mapx, mapy, i, tm->props[mapy][mapx][i]); tm->props[mapy][mapx][i] = tm->props[stbte__ui.drag_y+oy][stbte__ui.drag_x+ox][i]; } } } } } if (data) { for (i=0; i < tm->num_layers; ++i) { if (tm->data[mapy][mapx][i] != data[i]) { stbte__undo_record(tm, mapx, mapy, i, tm->data[mapy][mapx][i]); tm->data[mapy][mapx][i] = data[i]; } } } #ifdef STBTE_ALLOW_LINK if (copy_props) { int overwritten=0, moved=0, copied=0; // since this function is called on EVERY tile, we can fix up even tiles not // involved in the move stbte__link *k; // first, determine what src link ends up here k = &tm->link[mapy][mapx]; // by default, it's the one currently here if (deleted) // if dragged away, it's erased k = NULL; if (written) // if dragged into, it gets that link k = &tm->link[stbte__ui.drag_y+oy][stbte__ui.drag_x+ox]; // now check whether the *target* gets moved or overwritten if (k && k->x >= 0) { overwritten = stbte__in_rect(k->x, k->y, stbte__ui.drag_dest_x, stbte__ui.drag_dest_y, w, h); if (!stbte__ui.shift) moved = stbte__in_rect(k->x, k->y, stbte__ui.drag_x , stbte__ui.drag_y , w, h); else copied = stbte__in_rect(k->x, k->y, stbte__ui.drag_x , stbte__ui.drag_y , w, h); } if (deleted || written || overwritten || moved || copied) { // choose the final link value based on the above if (k == NULL || k->x < 0) stbte__set_link(tm, mapx, mapy, -1, -1, STBTE__undo_record); else if (moved || (copied && written)) { // if we move the target, we update to point to the new target; // or, if we copy the target and the source is part ofthe copy, then update to new target int x = k->x + (stbte__ui.drag_dest_x - stbte__ui.drag_x); int y = k->y + (stbte__ui.drag_dest_y - stbte__ui.drag_y); if (!(x >= 0 && y >= 0 && x < tm->max_x && y < tm->max_y)) x = -1, y = -1; stbte__set_link(tm, mapx, mapy, x, y, STBTE__undo_record); } else if (overwritten) { stbte__set_link(tm, mapx, mapy, -1, -1, STBTE__undo_record); } else stbte__set_link(tm, mapx, mapy, k->x, k->y, STBTE__undo_record); } } #endif } static void stbte__drag_place(stbte_tilemap *tm, int mapx, int mapy) { int i,j; int copy_props = stbte__should_copy_properties(tm); int move_x = (stbte__ui.drag_dest_x - stbte__ui.drag_x); int move_y = (stbte__ui.drag_dest_y - stbte__ui.drag_y); if (move_x == 0 && move_y == 0) return; stbte__begin_undo(tm); // we now need a 2D memmove-style mover that doesn't // overwrite any data as it goes. this requires being // direction sensitive in the same way as memmove if (move_y > 0 || (move_y == 0 && move_x > 0)) { for (j=tm->max_y-1; j >= 0; --j) for (i=tm->max_x-1; i >= 0; --i) stbte__drag_update(tm,i,j,copy_props); } else { for (j=0; j < tm->max_y; ++j) for (i=0; i < tm->max_x; ++i) stbte__drag_update(tm,i,j,copy_props); } stbte__end_undo(tm); stbte__ui.has_selection = 1; stbte__ui.select_x0 = stbte__ui.drag_dest_x; stbte__ui.select_y0 = stbte__ui.drag_dest_y; stbte__ui.select_x1 = stbte__ui.select_x0 + stbte__ui.drag_w - 1; stbte__ui.select_y1 = stbte__ui.select_y0 + stbte__ui.drag_h - 1; } static void stbte__tile_paint(stbte_tilemap *tm, int sx, int sy, int mapx, int mapy, int layer) { int i; int id = STBTE__IDMAP(mapx,mapy); int x0=sx, y0=sy; int x1=sx+tm->spacing_x, y1=sy+tm->spacing_y; int over = stbte__hittest(x0,y0,x1,y1, id); short *data = tm->data[mapy][mapx]; short temp[STBTE_MAX_LAYERS]; if (STBTE__IS_MAP_HOT()) { if (stbte__ui.pasting) { int ox = mapx - stbte__ui.paste_x; int oy = mapy - stbte__ui.paste_y; if (ox >= 0 && ox < stbte__ui.copy_width && oy >= 0 && oy < stbte__ui.copy_height) { stbte__paste_stack(tm, temp, tm->data[mapy][mapx], stbte__ui.copybuffer[oy*stbte__ui.copy_width+ox], 0); data = temp; } } else if (stbte__ui.dragging) { int ox,oy; for (i=0; i < tm->num_layers; ++i) temp[i] = tm->data[mapy][mapx][i]; data = temp; // if it's in the source area, remove things unless shift-dragging ox = mapx - stbte__ui.drag_x; oy = mapy - stbte__ui.drag_y; if (!stbte__ui.shift && ox >= 0 && ox < stbte__ui.drag_w && oy >= 0 && oy < stbte__ui.drag_h) { stbte__clear_stack(tm, temp); } ox = mapx - stbte__ui.drag_dest_x; oy = mapy - stbte__ui.drag_dest_y; if (ox >= 0 && ox < stbte__ui.drag_w && oy >= 0 && oy < stbte__ui.drag_h) { stbte__paste_stack(tm, temp, temp, tm->data[stbte__ui.drag_y+oy][stbte__ui.drag_x+ox], !stbte__ui.shift); } } else if (STBTE__IS_MAP_ACTIVE()) { if (stbte__ui.tool == STBTE__tool_rect) { if ((stbte__ui.ms_time & 511) < 380) { int ex = ((stbte__ui.hot_id >> 19) & 4095); int ey = ((stbte__ui.hot_id >> 7) & 4095); int sx = stbte__ui.sx; int sy = stbte__ui.sy; if ( ((mapx >= sx && mapx < ex+1) || (mapx >= ex && mapx < sx+1)) && ((mapy >= sy && mapy < ey+1) || (mapy >= ey && mapy < sy+1))) { int i; for (i=0; i < tm->num_layers; ++i) temp[i] = tm->data[mapy][mapx][i]; data = temp; if (stbte__ui.active_event == STBTE__leftdown) stbte__brush_predict(tm, temp); else stbte__erase_predict(tm, temp, STBTE__erase_any); } } } } } if (STBTE__IS_HOT(id) && STBTE__INACTIVE() && !stbte__ui.pasting) { if (stbte__ui.tool == STBTE__tool_brush) { if ((stbte__ui.ms_time & 511) < 300) { data = temp; for (i=0; i < tm->num_layers; ++i) temp[i] = tm->data[mapy][mapx][i]; stbte__brush_predict(tm, temp); } } } { i = layer; if (i == tm->solo_layer || (!tm->layerinfo[i].hidden && tm->solo_layer < 0)) if (data[i] >= 0) STBTE_DRAW_TILE(x0,y0, (unsigned short) data[i], 0, tm->props[mapy][mapx]); } } static void stbte__tile(stbte_tilemap *tm, int sx, int sy, int mapx, int mapy) { int tool = stbte__ui.tool; int x0=sx, y0=sy; int x1=sx+tm->spacing_x, y1=sy+tm->spacing_y; int id = STBTE__IDMAP(mapx,mapy); int over = stbte__hittest(x0,y0,x1,y1, id); switch (stbte__ui.event) { case STBTE__paint: { if (stbte__ui.pasting || stbte__ui.dragging || stbte__ui.scrolling) break; if (stbte__ui.scrollkey && !STBTE__IS_MAP_ACTIVE()) break; if (STBTE__IS_HOT(id) && STBTE__IS_MAP_ACTIVE() && (tool == STBTE__tool_rect || tool == STBTE__tool_select)) { int rx0,ry0,rx1,ry1,t; // compute the center of each rect rx0 = x0 + tm->spacing_x/2; ry0 = y0 + tm->spacing_y/2; rx1 = rx0 + (stbte__ui.sx - mapx) * tm->spacing_x; ry1 = ry0 + (stbte__ui.sy - mapy) * tm->spacing_y; if (rx0 > rx1) t=rx0,rx0=rx1,rx1=t; if (ry0 > ry1) t=ry0,ry0=ry1,ry1=t; rx0 -= tm->spacing_x/2; ry0 -= tm->spacing_y/2; rx1 += tm->spacing_x/2; ry1 += tm->spacing_y/2; stbte__draw_frame(rx0-1,ry0-1,rx1+1,ry1+1, STBTE_COLOR_TILEMAP_HIGHLIGHT); break; } if (STBTE__IS_HOT(id) && STBTE__INACTIVE()) { stbte__draw_frame(x0-1,y0-1,x1+1,y1+1, STBTE_COLOR_TILEMAP_HIGHLIGHT); } #ifdef STBTE_ALLOW_LINK if (stbte__ui.show_links && tm->link[mapy][mapx].x >= 0) { int tx = tm->link[mapy][mapx].x; int ty = tm->link[mapy][mapx].y; int lx0,ly0,lx1,ly1; if (STBTE_ALLOW_LINK(tm->data[mapy][mapx], tm->props[mapy][mapx], tm->data[ty ][tx ], tm->props[ty ][tx ])) { lx0 = x0 + (tm->spacing_x >> 1) - 1; ly0 = y0 + (tm->spacing_y >> 1) - 1; lx1 = lx0 + (tx - mapx) * tm->spacing_x + 2; ly1 = ly0 + (ty - mapy) * tm->spacing_y + 2; stbte__draw_link(lx0,ly0,lx1,ly1, STBTE_LINK_COLOR(tm->data[mapy][mapx], tm->props[mapy][mapx], tm->data[ty ][tx ], tm->props[ty ][tx])); } } #endif break; } } if (stbte__ui.pasting) { switch (stbte__ui.event) { case STBTE__leftdown: if (STBTE__IS_HOT(id)) { stbte__ui.pasting = 0; stbte__paste(tm, mapx, mapy); stbte__activate(0); } break; case STBTE__leftup: // just clear it no matter what, since they might click away to clear it stbte__activate(0); break; case STBTE__rightdown: if (STBTE__IS_HOT(id)) { stbte__activate(0); stbte__ui.pasting = 0; } break; } return; } if (stbte__ui.scrolling) { if (stbte__ui.event == STBTE__leftup) { stbte__activate(0); stbte__ui.scrolling = 0; } if (stbte__ui.event == STBTE__mousemove) { tm->scroll_x += (stbte__ui.start_x - stbte__ui.mx); tm->scroll_y += (stbte__ui.start_y - stbte__ui.my); stbte__ui.start_x = stbte__ui.mx; stbte__ui.start_y = stbte__ui.my; } return; } // regardless of tool, leftdown is a scrolldrag if (STBTE__IS_HOT(id) && stbte__ui.scrollkey && stbte__ui.event == STBTE__leftdown) { stbte__ui.scrolling = 1; stbte__ui.start_x = stbte__ui.mx; stbte__ui.start_y = stbte__ui.my; return; } switch (tool) { case STBTE__tool_brush: switch (stbte__ui.event) { case STBTE__mousemove: if (STBTE__IS_MAP_ACTIVE() && over) { // don't brush/erase same tile multiple times unless they move away and back @TODO should just be only once, but that needs another data structure if (!STBTE__IS_ACTIVE(id)) { if (stbte__ui.active_event == STBTE__leftdown) stbte__brush(tm, mapx, mapy); else stbte__erase(tm, mapx, mapy, stbte__ui.brush_state); stbte__ui.active_id = id; // switch to this map square so we don't rebrush IT multiple times } } break; case STBTE__leftdown: if (STBTE__IS_HOT(id) && STBTE__INACTIVE()) { stbte__activate(id); stbte__begin_undo(tm); stbte__brush(tm, mapx, mapy); } break; case STBTE__rightdown: if (STBTE__IS_HOT(id) && STBTE__INACTIVE()) { stbte__activate(id); stbte__begin_undo(tm); if (stbte__erase(tm, mapx, mapy, STBTE__erase_any) == STBTE__erase_brushonly) stbte__ui.brush_state = STBTE__erase_brushonly; else stbte__ui.brush_state = STBTE__erase_any; } break; case STBTE__leftup: case STBTE__rightup: if (STBTE__IS_MAP_ACTIVE()) { stbte__end_undo(tm); stbte__activate(0); } break; } break; #ifdef STBTE_ALLOW_LINK case STBTE__tool_link: switch (stbte__ui.event) { case STBTE__leftdown: if (STBTE__IS_HOT(id) && STBTE__INACTIVE()) { stbte__activate(id); stbte__ui.linking = 1; stbte__ui.sx = mapx; stbte__ui.sy = mapy; // @TODO: undo } break; case STBTE__leftup: if (STBTE__IS_HOT(id) && STBTE__IS_MAP_ACTIVE()) { if ((mapx != stbte__ui.sx || mapy != stbte__ui.sy) && STBTE_ALLOW_LINK(tm->data[stbte__ui.sy][stbte__ui.sx], tm->props[stbte__ui.sy][stbte__ui.sx], tm->data[mapy][mapx], tm->props[mapy][mapx])) stbte__set_link(tm, stbte__ui.sx, stbte__ui.sy, mapx, mapy, STBTE__undo_block); else stbte__set_link(tm, stbte__ui.sx, stbte__ui.sy, -1,-1, STBTE__undo_block); stbte__ui.linking = 0; stbte__activate(0); } break; case STBTE__rightdown: if (STBTE__IS_ACTIVE(id)) { stbte__activate(0); stbte__ui.linking = 0; } break; } break; #endif case STBTE__tool_erase: switch (stbte__ui.event) { case STBTE__mousemove: if (STBTE__IS_MAP_ACTIVE() && over) stbte__erase(tm, mapx, mapy, STBTE__erase_all); break; case STBTE__leftdown: if (STBTE__IS_HOT(id) && STBTE__INACTIVE()) { stbte__activate(id); stbte__begin_undo(tm); stbte__erase(tm, mapx, mapy, STBTE__erase_all); } break; case STBTE__leftup: if (STBTE__IS_MAP_ACTIVE()) { stbte__end_undo(tm); stbte__activate(0); } break; } break; case STBTE__tool_select: if (STBTE__IS_HOT(id)) { switch (stbte__ui.event) { case STBTE__leftdown: if (STBTE__INACTIVE()) { // if we're clicking in an existing selection... if (stbte__ui.has_selection) { if ( mapx >= stbte__ui.select_x0 && mapx <= stbte__ui.select_x1 && mapy >= stbte__ui.select_y0 && mapy <= stbte__ui.select_y1) { stbte__ui.dragging = 1; stbte__ui.drag_x = stbte__ui.select_x0; stbte__ui.drag_y = stbte__ui.select_y0; stbte__ui.drag_w = stbte__ui.select_x1 - stbte__ui.select_x0 + 1; stbte__ui.drag_h = stbte__ui.select_y1 - stbte__ui.select_y0 + 1; stbte__ui.drag_offx = mapx - stbte__ui.select_x0; stbte__ui.drag_offy = mapy - stbte__ui.select_y0; } } stbte__ui.has_selection = 0; // no selection until it completes stbte__activate_map(mapx,mapy); } break; case STBTE__leftup: if (STBTE__IS_MAP_ACTIVE()) { if (stbte__ui.dragging) { stbte__drag_place(tm, mapx,mapy); stbte__ui.dragging = 0; stbte__activate(0); } else { stbte__select_rect(tm, stbte__ui.sx, stbte__ui.sy, mapx, mapy); stbte__activate(0); } } break; case STBTE__rightdown: stbte__ui.has_selection = 0; break; } } break; case STBTE__tool_rect: if (STBTE__IS_HOT(id)) { switch (stbte__ui.event) { case STBTE__leftdown: if (STBTE__INACTIVE()) stbte__activate_map(mapx,mapy); break; case STBTE__leftup: if (STBTE__IS_MAP_ACTIVE()) { stbte__fillrect(tm, stbte__ui.sx, stbte__ui.sy, mapx, mapy, 1); stbte__activate(0); } break; case STBTE__rightdown: if (STBTE__INACTIVE()) stbte__activate_map(mapx,mapy); break; case STBTE__rightup: if (STBTE__IS_MAP_ACTIVE()) { stbte__fillrect(tm, stbte__ui.sx, stbte__ui.sy, mapx, mapy, 0); stbte__activate(0); } break; } } break; case STBTE__tool_eyedrop: switch (stbte__ui.event) { case STBTE__leftdown: if (STBTE__IS_HOT(id) && STBTE__INACTIVE()) stbte__eyedrop(tm,mapx,mapy); break; } break; } } static void stbte__start_paste(stbte_tilemap *tm) { if (stbte__ui.has_copy) { stbte__ui.pasting = 1; stbte__activate(STBTE__ID(STBTE__toolbarB,3)); } } static void stbte__toolbar(stbte_tilemap *tm, int x0, int y0, int w, int h) { int i; int estimated_width = 13 * STBTE__num_tool + 8+8+ 120+4 - 30; int x = x0 + w/2 - estimated_width/2; int y = y0+1; for (i=0; i < STBTE__num_tool; ++i) { int highlight=0, disable=0; highlight = (stbte__ui.tool == i); if (i == STBTE__tool_undo || i == STBTE__tool_showgrid) x += 8; if (i == STBTE__tool_showgrid && stbte__ui.show_grid) highlight = 1; if (i == STBTE__tool_showlinks && stbte__ui.show_links) highlight = 1; if (i == STBTE__tool_fill) continue; #ifndef STBTE_ALLOW_LINK if (i == STBTE__tool_link || i == STBTE__tool_showlinks) disable = 1; #endif if (i == STBTE__tool_undo && !stbte__undo_available(tm)) disable = 1; if (i == STBTE__tool_redo && !stbte__redo_available(tm)) disable = 1; if (stbte__button_icon(STBTE__ctoolbar_button, toolchar[i], x, y, 13, STBTE__ID(STBTE__toolbarA, i), highlight, disable)) { switch (i) { case STBTE__tool_eyedrop: stbte__ui.eyedrop_last_layer = tm->num_layers; // flush eyedropper state // fallthrough default: stbte__ui.tool = i; stbte__ui.has_selection = 0; break; case STBTE__tool_showlinks: stbte__ui.show_links = !stbte__ui.show_links; break; case STBTE__tool_showgrid: stbte__ui.show_grid = (stbte__ui.show_grid+1)%3; break; case STBTE__tool_undo: stbte__undo(tm); break; case STBTE__tool_redo: stbte__redo(tm); break; } } x += 13; } x += 8; if (stbte__button(STBTE__ctoolbar_button, "cut" , x, y,10, 40, STBTE__ID(STBTE__toolbarB,0), 0, !stbte__ui.has_selection)) stbte__copy_cut(tm, 1); x += 42; if (stbte__button(STBTE__ctoolbar_button, "copy" , x, y, 5, 40, STBTE__ID(STBTE__toolbarB,1), 0, !stbte__ui.has_selection)) stbte__copy_cut(tm, 0); x += 42; if (stbte__button(STBTE__ctoolbar_button, "paste", x, y, 0, 40, STBTE__ID(STBTE__toolbarB,2), stbte__ui.pasting, !stbte__ui.has_copy)) stbte__start_paste(tm); } #define STBTE__TEXTCOLOR(n) stbte__color_table[n][STBTE__text][STBTE__idle] static int stbte__info_value(const char *label, int x, int y, int val, int digits, int id) { if (stbte__ui.event == STBTE__paint) { int off = 9-stbte__get_char_width(label[0]); char text[16]; sprintf(text, label, digits, val); stbte__draw_text_core(x+off,y, text, 999, STBTE__TEXTCOLOR(STBTE__cpanel),1); } if (id) { x += 9+7*digits+4; if (stbte__minibutton(STBTE__cmapsize, x,y, '+', STBTE__ID2(id,1,0))) val += (stbte__ui.shift ? 10 : 1); x += 9; if (stbte__minibutton(STBTE__cmapsize, x,y, '-', STBTE__ID2(id,2,0))) val -= (stbte__ui.shift ? 10 : 1); if (val < 1) val = 1; else if (val > 4096) val = 4096; } return val; } static void stbte__info(stbte_tilemap *tm, int x0, int y0, int w, int h) { int mode = stbte__ui.panel[STBTE__panel_info].mode; int s = 11+7*tm->digits+4+15; int x,y; int in_region; x = x0+2; y = y0+2; tm->max_x = stbte__info_value("w:%*d",x,y, tm->max_x, tm->digits, STBTE__ID(STBTE__info,0)); if (mode) x += s; else y += 11; tm->max_y = stbte__info_value("h:%*d",x,y, tm->max_y, tm->digits, STBTE__ID(STBTE__info,1)); x = x0+2; y += 11; in_region = (stbte__ui.hot_id & 127) == STBTE__map; stbte__info_value(in_region ? "x:%*d" : "x:",x,y, (stbte__ui.hot_id>>19)&4095, tm->digits, 0); if (mode) x += s; else y += 11; stbte__info_value(in_region ? "y:%*d" : "y:",x,y, (stbte__ui.hot_id>> 7)&4095, tm->digits, 0); y += 15; x = x0+2; stbte__draw_text(x,y,"brush:",40,STBTE__TEXTCOLOR(STBTE__cpanel)); if (tm->cur_tile >= 0) STBTE_DRAW_TILE(x+43,y-3,tm->tiles[tm->cur_tile].id,1,0); } static void stbte__layers(stbte_tilemap *tm, int x0, int y0, int w, int h) { static char *propmodes[3] = { "default", "always", "never" }; int num_rows; int i, y, n; int x1 = x0+w; int y1 = y0+h; int xoff = 20; if (tm->has_layer_names) { int side = stbte__ui.panel[STBTE__panel_layers].side; xoff = stbte__region[side].width - 42; xoff = (xoff < tm->layername_width + 10 ? xoff : tm->layername_width + 10); } x0 += 2; y0 += 5; if (!tm->has_layer_names) { if (stbte__ui.event == STBTE__paint) { stbte__draw_text(x0,y0, "Layers", w-4, STBTE__TEXTCOLOR(STBTE__cpanel)); } y0 += 11; } num_rows = (y1-y0)/15; #ifndef STBTE_NO_PROPS --num_rows; #endif y = y0; for (i=0; i < tm->num_layers; ++i) { char text[3], *str = (char *) tm->layerinfo[i].name; static char lockedchar[3] = { 'U', 'P', 'L' }; int locked = tm->layerinfo[i].locked; int disabled = (tm->solo_layer >= 0 && tm->solo_layer != i); if (i-tm->layer_scroll >= 0 && i-tm->layer_scroll < num_rows) { if (str == NULL) sprintf(str=text, "%2d", i+1); if (stbte__button(STBTE__clayer_button, str, x0,y,(i+1<10)*2,xoff-2, STBTE__ID(STBTE__layer,i), tm->cur_layer==i,0)) tm->cur_layer = (tm->cur_layer == i ? -1 : i); if (stbte__layerbutton(x0+xoff + 0,y+1,'H',STBTE__ID(STBTE__hide,i), tm->layerinfo[i].hidden,disabled,STBTE__clayer_hide)) tm->layerinfo[i].hidden = !tm->layerinfo[i].hidden; if (stbte__layerbutton(x0+xoff + 12,y+1,lockedchar[locked],STBTE__ID(STBTE__lock,i), locked!=0,disabled,STBTE__clayer_lock)) tm->layerinfo[i].locked = (locked+1)%3; if (stbte__layerbutton(x0+xoff + 24,y+1,'S',STBTE__ID(STBTE__solo,i), tm->solo_layer==i,0,STBTE__clayer_solo)) tm->solo_layer = (tm->solo_layer == i ? -1 : i); y += 15; } } stbte__scrollbar(x1-4, y0,y-2, &tm->layer_scroll, 0, tm->num_layers, num_rows, STBTE__ID(STBTE__scrollbar_id, STBTE__layer)); #ifndef STBTE_NO_PROPS n = stbte__text_width("prop:")+2; stbte__draw_text(x0,y+2, "prop:", w, STBTE__TEXTCOLOR(STBTE__cpanel)); i = w - n - 4; if (i > 50) i = 50; if (stbte__button(STBTE__clayer_button, propmodes[tm->propmode], x0+n,y,0,i, STBTE__ID(STBTE__layer,256), 0,0)) tm->propmode = (tm->propmode+1)%3; #endif } static void stbte__categories(stbte_tilemap *tm, int x0, int y0, int w, int h) { int s=11, x,y, i; int num_rows = h / s; w -= 4; x = x0+2; y = y0+4; if (tm->category_scroll == 0) { if (stbte__category_button("*ALL*", x,y, w, STBTE__ID(STBTE__categories, 65535), tm->cur_category == -1)) { stbte__choose_category(tm, -1); } y += s; } for (i=0; i < tm->num_categories; ++i) { if (i+1 - tm->category_scroll >= 0 && i+1 - tm->category_scroll < num_rows) { if (y + 10 > y0+h) return; if (stbte__category_button(tm->categories[i], x,y,w, STBTE__ID(STBTE__categories,i), tm->cur_category == i)) stbte__choose_category(tm, i); y += s; } } stbte__scrollbar(x0+w, y0+4, y0+h-4, &tm->category_scroll, 0, tm->num_categories+1, num_rows, STBTE__ID(STBTE__scrollbar_id, STBTE__categories)); } static void stbte__tile_in_palette(stbte_tilemap *tm, int x, int y, int slot) { stbte__tileinfo *t = &tm->tiles[slot]; int x0=x, y0=y, x1 = x+tm->palette_spacing_x - 1, y1 = y+tm->palette_spacing_y; int id = STBTE__ID(STBTE__palette, slot); int over = stbte__hittest(x0,y0,x1,y1, id); switch (stbte__ui.event) { case STBTE__paint: stbte__draw_rect(x,y,x+tm->palette_spacing_x-1,y+tm->palette_spacing_x-1, STBTE_COLOR_TILEPALETTE_BACKGROUND); STBTE_DRAW_TILE(x,y,t->id, slot == tm->cur_tile,0); if (slot == tm->cur_tile) stbte__draw_frame_delayed(x-1,y-1,x+tm->palette_spacing_x,y+tm->palette_spacing_y, STBTE_COLOR_TILEPALETTE_OUTLINE); break; default: if (stbte__button_core(id)) tm->cur_tile = slot; break; } } static void stbte__palette_of_tiles(stbte_tilemap *tm, int x0, int y0, int w, int h) { int i,x,y; int num_vis_rows = (h-6) / tm->palette_spacing_y; int num_columns = (w-2-6) / tm->palette_spacing_x; int num_total_rows; int column,row; int x1 = x0+w, y1=y0+h; x = x0+2; y = y0+6; if (num_columns == 0) return; num_total_rows = (tm->cur_palette_count + num_columns-1) / num_columns; // ceil() column = 0; row = -tm->palette_scroll; for (i=0; i < tm->num_tiles; ++i) { stbte__tileinfo *t = &tm->tiles[i]; // filter based on category if (tm->cur_category >= 0 && t->category_id != tm->cur_category) continue; // display it if (row >= 0 && row < num_vis_rows) { x = x0 + 2 + tm->palette_spacing_x * column; y = y0 + 6 + tm->palette_spacing_y * row; stbte__tile_in_palette(tm,x,y,i); } ++column; if (column == num_columns) { column = 0; ++row; } } stbte__flush_delay(); stbte__scrollbar(x1-4, y0+6, y1-2, &tm->palette_scroll, 0, num_total_rows, num_vis_rows, STBTE__ID(STBTE__scrollbar_id, STBTE__palette)); } static float stbte__linear_remap(float n, float x0, float x1, float y0, float y1) { return (n-x0)/(x1-x0)*(y1-y0) + y0; } static float stbte__saved; static void stbte__props_panel(stbte_tilemap *tm, int x0, int y0, int w, int h) { int x1 = x0+w, y1 = y0+h; int i; int y = y0 + 5, x = x0+2; int slider_width = 60; int mx,my; float *p; short *data; if (!stbte__is_single_selection()) return; mx = stbte__ui.select_x0; my = stbte__ui.select_y0; p = tm->props[my][mx]; data = tm->data[my][mx]; for (i=0; i < STBTE_MAX_PROPERTIES; ++i) { unsigned int n = STBTE_PROP_TYPE(i, data, p); if (n) { char *s = STBTE_PROP_NAME(i, data, p); if (s == NULL) s = ""; switch (n & 3) { case STBTE_PROP_bool: { int flag = (int) p[i]; if (stbte__layerbutton(x,y, flag ? 'x' : ' ', STBTE__ID(STBTE__prop_flag,i), flag, 0, 2)) { stbte__begin_undo(tm); stbte__undo_record_prop_float(tm,mx,my,i,(float) flag); p[i] = (float) !flag; stbte__end_undo(tm); } stbte__draw_text(x+13,y+1,s,x1-(x+13)-2,STBTE__TEXTCOLOR(STBTE__cpanel)); y += 13; break; } case STBTE_PROP_int: { int a = (int) STBTE_PROP_MIN(i,data,p); int b = (int) STBTE_PROP_MAX(i,data,p); int v = (int) p[i] - a; if (a+v != p[i] || v < 0 || v > b-a) { if (v < 0) v = 0; if (v > b-a) v = b-a; p[i] = (float) (a+v); // @TODO undo } switch (stbte__slider(x, slider_width, y+7, b-a, &v, STBTE__ID(STBTE__prop_int,i))) { case STBTE__begin: stbte__saved = p[i]; // fallthrough case STBTE__change: p[i] = (float) (a+v); // @TODO undo break; case STBTE__end: if (p[i] != stbte__saved) { stbte__begin_undo(tm); stbte__undo_record_prop_float(tm,mx,my,i,stbte__saved); stbte__end_undo(tm); } break; } stbte__draw_text(x+slider_width+2,y+2, s, x1-1-(x+slider_width+2), STBTE__TEXTCOLOR(STBTE__cpanel)); y += 12; break; } case STBTE_PROP_float: { float a = (float) STBTE_PROP_MIN(i, data,p); float b = (float) STBTE_PROP_MAX(i, data,p); float c = STBTE_PROP_FLOAT_SCALE(i, data, p); float old; if (p[i] < a || p[i] > b) { // @TODO undo if (p[i] < a) p[i] = a; if (p[i] > b) p[i] = b; } old = p[i]; switch (stbte__float_control(x, y, 50, a, b, c, "%8.4f", &p[i], STBTE__layer,STBTE__ID(STBTE__prop_float,i))) { case STBTE__begin: stbte__saved = old; break; case STBTE__end: if (stbte__saved != p[i]) { stbte__begin_undo(tm); stbte__undo_record_prop_float(tm,mx,my,i, stbte__saved); stbte__end_undo(tm); } break; } stbte__draw_text(x+53,y+1, s, x1-1-(x+53), STBTE__TEXTCOLOR(STBTE__cpanel)); y += 12; break; } } } } } static int stbte__cp_mode, stbte__cp_aspect, stbte__cp_state, stbte__cp_index, stbte__save, stbte__cp_altered, stbte__color_copy; #ifdef STBTE__COLORPICKER static void stbte__dump_colorstate(void) { int i,j,k; printf("static int stbte__color_table[STBTE__num_color_modes][STBTE__num_color_aspects][STBTE__num_color_states] =\n"); printf("{\n"); printf(" {\n"); for (k=0; k < STBTE__num_color_modes; ++k) { for (j=0; j < STBTE__num_color_aspects; ++j) { printf(" { "); for (i=0; i < STBTE__num_color_states; ++i) { printf("0x%06x, ", stbte__color_table[k][j][i]); } printf("},\n"); } if (k+1 < STBTE__num_color_modes) printf(" }, {\n"); else printf(" },\n"); } printf("};\n"); } static void stbte__colorpicker(int x0, int y0, int w, int h) { int x1 = x0+w, y1 = y0+h, x,y, i; x = x0+2; y = y0+6; y += 5; x += 8; { int color = stbte__color_table[stbte__cp_mode][stbte__cp_aspect][stbte__cp_index]; int rgb[3]; if (stbte__cp_altered && stbte__cp_index == STBTE__idle) color = stbte__save; if (stbte__minibutton(STBTE__cmapsize, x1-20,y+ 5, 'C', STBTE__ID2(STBTE__colorpick_id,4,0))) stbte__color_copy = color; if (stbte__minibutton(STBTE__cmapsize, x1-20,y+15, 'P', STBTE__ID2(STBTE__colorpick_id,4,1))) color = stbte__color_copy; rgb[0] = color >> 16; rgb[1] = (color>>8)&255; rgb[2] = color & 255; for (i=0; i < 3; ++i) { if (stbte__slider(x+8,64, y, 255, rgb+i, STBTE__ID2(STBTE__colorpick_id,3,i)) > 0) stbte__dump_colorstate(); y += 15; } if (stbte__ui.event != STBTE__paint && stbte__ui.event != STBTE__tick) stbte__color_table[stbte__cp_mode][stbte__cp_aspect][stbte__cp_index] = (rgb[0]<<16)|(rgb[1]<<8)|(rgb[2]); } y += 5; // states x = x0+2+35; if (stbte__ui.event == STBTE__paint) { static char *states[] = { "idle", "over", "down", "down&over", "selected", "selected&over", "disabled" }; stbte__draw_text(x, y+1, states[stbte__cp_index], x1-x-1, 0xffffff); } x = x0+24; y += 12; for (i=3; i >= 0; --i) { int state = 0 != (stbte__cp_state & (1 << i)); if (stbte__layerbutton(x,y, "OASD"[i], STBTE__ID2(STBTE__colorpick_id, 0,i), state,0, STBTE__clayer_button)) { stbte__cp_state ^= (1 << i); stbte__cp_index = stbte__state_to_index[0][0][0][stbte__cp_state]; } x += 16; } x = x0+2; y += 18; for (i=0; i < 3; ++i) { static char *labels[] = { "Base", "Edge", "Text" }; if (stbte__button(STBTE__ctoolbar_button, labels[i], x,y,0,36, STBTE__ID2(STBTE__colorpick_id,1,i), stbte__cp_aspect==i,0)) stbte__cp_aspect = i; x += 40; } y += 18; x = x0+2; for (i=0; i < STBTE__num_color_modes; ++i) { if (stbte__button(STBTE__ctoolbar_button, stbte__color_names[i], x, y, 0,80, STBTE__ID2(STBTE__colorpick_id,2,i), stbte__cp_mode == i,0)) stbte__cp_mode = i; y += 12; } // make the currently selected aspect flash, unless we're actively dragging color slider etc if (stbte__ui.event == STBTE__tick) { stbte__save = stbte__color_table[stbte__cp_mode][stbte__cp_aspect][STBTE__idle]; if ((stbte__ui.active_id & 127) != STBTE__colorpick_id) { if ((stbte__ui.ms_time & 2047) < 200) { stbte__color_table[stbte__cp_mode][stbte__cp_aspect][STBTE__idle] ^= 0x1f1f1f; stbte__cp_altered = 1; } } } } #endif static void stbte__editor_traverse(stbte_tilemap *tm) { int i,j,i0,j0,i1,j1,n; if (tm == NULL) return; if (stbte__ui.x0 == stbte__ui.x1 || stbte__ui.y0 == stbte__ui.y1) return; stbte__prepare_tileinfo(tm); stbte__compute_panel_locations(tm); // @OPTIMIZE: we don't need to recompute this every time if (stbte__ui.event == STBTE__paint) { // fill screen with border stbte__draw_rect(stbte__ui.x0, stbte__ui.y0, stbte__ui.x1, stbte__ui.y1, STBTE_COLOR_TILEMAP_BORDER); // fill tilemap with tilemap background stbte__draw_rect(stbte__ui.x0 - tm->scroll_x, stbte__ui.y0 - tm->scroll_y, stbte__ui.x0 - tm->scroll_x + tm->spacing_x * tm->max_x, stbte__ui.y0 - tm->scroll_y + tm->spacing_y * tm->max_y, STBTE_COLOR_TILEMAP_BACKGROUND); } // step 1: traverse all the tilemap data... i0 = (tm->scroll_x - tm->spacing_x) / tm->spacing_x; j0 = (tm->scroll_y - tm->spacing_y) / tm->spacing_y; i1 = (tm->scroll_x + stbte__ui.x1 - stbte__ui.x0) / tm->spacing_x + 1; j1 = (tm->scroll_y + stbte__ui.y1 - stbte__ui.y0) / tm->spacing_y + 1; if (i0 < 0) i0 = 0; if (j0 < 0) j0 = 0; if (i1 > tm->max_x) i1 = tm->max_x; if (j1 > tm->max_y) j1 = tm->max_y; if (stbte__ui.event == STBTE__paint) { // draw all of layer 0, then all of layer 1, etc, instead of old // way which drew entire stack of each tile at once for (n=0; n < tm->num_layers; ++n) { for (j=j0; j < j1; ++j) { for (i=i0; i < i1; ++i) { int x = stbte__ui.x0 + i * tm->spacing_x - tm->scroll_x; int y = stbte__ui.y0 + j * tm->spacing_y - tm->scroll_y; stbte__tile_paint(tm, x, y, i, j, n); } } if (n == 0 && stbte__ui.show_grid == 1) { int x = stbte__ui.x0 + i0 * tm->spacing_x - tm->scroll_x; int y = stbte__ui.y0 + j0 * tm->spacing_y - tm->scroll_y; for (i=0; x < stbte__ui.x1 && i <= i1; ++i, x += tm->spacing_x) stbte__draw_rect(x, stbte__ui.y0, x+1, stbte__ui.y1, STBTE_COLOR_GRID); for (j=0; y < stbte__ui.y1 && j <= j1; ++j, y += tm->spacing_y) stbte__draw_rect(stbte__ui.x0, y, stbte__ui.x1, y+1, STBTE_COLOR_GRID); } } } if (stbte__ui.event == STBTE__paint) { // draw grid on top of everything except UI if (stbte__ui.show_grid == 2) { int x = stbte__ui.x0 + i0 * tm->spacing_x - tm->scroll_x; int y = stbte__ui.y0 + j0 * tm->spacing_y - tm->scroll_y; for (i=0; x < stbte__ui.x1 && i <= i1; ++i, x += tm->spacing_x) stbte__draw_rect(x, stbte__ui.y0, x+1, stbte__ui.y1, STBTE_COLOR_GRID); for (j=0; y < stbte__ui.y1 && j <= j1; ++j, y += tm->spacing_y) stbte__draw_rect(stbte__ui.x0, y, stbte__ui.x1, y+1, STBTE_COLOR_GRID); } } for (j=j0; j < j1; ++j) { for (i=i0; i < i1; ++i) { int x = stbte__ui.x0 + i * tm->spacing_x - tm->scroll_x; int y = stbte__ui.y0 + j * tm->spacing_y - tm->scroll_y; stbte__tile(tm, x, y, i, j); } } if (stbte__ui.event == STBTE__paint) { // draw the selection border if (stbte__ui.has_selection) { int x0,y0,x1,y1; x0 = stbte__ui.x0 + (stbte__ui.select_x0 ) * tm->spacing_x - tm->scroll_x; y0 = stbte__ui.y0 + (stbte__ui.select_y0 ) * tm->spacing_y - tm->scroll_y; x1 = stbte__ui.x0 + (stbte__ui.select_x1 + 1) * tm->spacing_x - tm->scroll_x + 1; y1 = stbte__ui.y0 + (stbte__ui.select_y1 + 1) * tm->spacing_y - tm->scroll_y + 1; stbte__draw_frame(x0,y0,x1,y1, (stbte__ui.ms_time & 256 ? STBTE_COLOR_SELECTION_OUTLINE1 : STBTE_COLOR_SELECTION_OUTLINE2)); } stbte__flush_delay(); // draw a dynamic link on top of the queued links #ifdef STBTE_ALLOW_LINK if (stbte__ui.linking && STBTE__IS_MAP_HOT()) { int x0,y0,x1,y1; int color; int ex = ((stbte__ui.hot_id >> 19) & 4095); int ey = ((stbte__ui.hot_id >> 7) & 4095); x0 = stbte__ui.x0 + (stbte__ui.sx ) * tm->spacing_x - tm->scroll_x + (tm->spacing_x>>1)+1; y0 = stbte__ui.y0 + (stbte__ui.sy ) * tm->spacing_y - tm->scroll_y + (tm->spacing_y>>1)+1; x1 = stbte__ui.x0 + (ex ) * tm->spacing_x - tm->scroll_x + (tm->spacing_x>>1)-1; y1 = stbte__ui.y0 + (ey ) * tm->spacing_y - tm->scroll_y + (tm->spacing_y>>1)-1; if (STBTE_ALLOW_LINK(tm->data[stbte__ui.sy][stbte__ui.sx], tm->props[stbte__ui.sy][stbte__ui.sx], tm->data[ey][ex], tm->props[ey][ex])) color = STBTE_LINK_COLOR_DRAWING; else color = STBTE_LINK_COLOR_DISALLOWED; stbte__draw_link(x0,y0,x1,y1, color); } #endif } stbte__flush_delay(); // step 2: traverse the panels for (i=0; i < STBTE__num_panel; ++i) { stbte__panel *p = &stbte__ui.panel[i]; if (stbte__ui.event == STBTE__paint) { stbte__draw_box(p->x0,p->y0,p->x0+p->width,p->y0+p->height, STBTE__cpanel, STBTE__idle); } // obscure tilemap data underneath panel stbte__hittest(p->x0,p->y0,p->x0+p->width,p->y0+p->height, STBTE__ID2(STBTE__panel, i, 0)); switch (i) { case STBTE__panel_toolbar: if (stbte__ui.event == STBTE__paint) stbte__draw_rect(p->x0,p->y0,p->x0+p->width,p->y0+p->height, stbte__color_table[STBTE__ctoolbar][STBTE__base][STBTE__idle]); stbte__toolbar(tm,p->x0,p->y0,p->width,p->height); break; case STBTE__panel_info: stbte__info(tm,p->x0,p->y0,p->width,p->height); break; case STBTE__panel_layers: stbte__layers(tm,p->x0,p->y0,p->width,p->height); break; case STBTE__panel_categories: stbte__categories(tm,p->x0,p->y0,p->width,p->height); break; case STBTE__panel_colorpick: #ifdef STBTE__COLORPICKER stbte__colorpicker(p->x0,p->y0,p->width,p->height); #endif break; case STBTE__panel_tiles: // erase boundary between categories and tiles if they're on same side if (stbte__ui.event == STBTE__paint && p->side == stbte__ui.panel[STBTE__panel_categories].side) stbte__draw_rect(p->x0+1,p->y0-1,p->x0+p->width-1,p->y0+1, stbte__color_table[STBTE__cpanel][STBTE__base][STBTE__idle]); stbte__palette_of_tiles(tm,p->x0,p->y0,p->width,p->height); break; case STBTE__panel_props: stbte__props_panel(tm,p->x0,p->y0,p->width,p->height); break; } // draw the panel side selectors for (j=0; j < 2; ++j) { int result; if (i == STBTE__panel_toolbar) continue; result = stbte__microbutton(p->x0+p->width - 1 - 2*4 + 4*j,p->y0+2,3, STBTE__ID2(STBTE__panel, i, j+1), STBTE__cpanel_sider+j); if (result) { switch (j) { case 0: p->side = result > 0 ? STBTE__side_left : STBTE__side_right; break; case 1: p->delta_height += result; break; } } } } if (stbte__ui.panel[STBTE__panel_categories].delta_height < -5) stbte__ui.panel[STBTE__panel_categories].delta_height = -5; if (stbte__ui.panel[STBTE__panel_layers ].delta_height < -5) stbte__ui.panel[STBTE__panel_layers ].delta_height = -5; // step 3: traverse the regions to place expander controls on them for (i=0; i < 2; ++i) { if (stbte__region[i].active) { int x = stbte__region[i].x; int width; if (i == STBTE__side_left) width = stbte__ui.left_width , x += stbte__region[i].width + 1; else width = -stbte__ui.right_width, x -= 6; if (stbte__microbutton_dragger(x, stbte__region[i].y+2, 5, STBTE__ID(STBTE__region,i), &width)) { // if non-0, it is expanding, so retract it if (stbte__region[i].retracted == 0.0) stbte__region[i].retracted = 0.01f; else stbte__region[i].retracted = 0.0; } if (i == STBTE__side_left) stbte__ui.left_width = width; else stbte__ui.right_width = -width; if (stbte__ui.event == STBTE__tick) { if (stbte__region[i].retracted && stbte__region[i].retracted < 1.0f) { stbte__region[i].retracted += stbte__ui.dt*4; if (stbte__region[i].retracted > 1) stbte__region[i].retracted = 1; } } } } if (stbte__ui.event == STBTE__paint && stbte__ui.alert_msg) { int w = stbte__text_width(stbte__ui.alert_msg); int x = (stbte__ui.x0+stbte__ui.x1)/2; int y = (stbte__ui.y0+stbte__ui.y1)*5/6; stbte__draw_rect (x-w/2-4,y-8, x+w/2+4,y+8, 0x604020); stbte__draw_frame(x-w/2-4,y-8, x+w/2+4,y+8, 0x906030); stbte__draw_text (x-w/2,y-4, stbte__ui.alert_msg, w+1, 0xff8040); } #ifdef STBTE_SHOW_CURSOR if (stbte__ui.event == STBTE__paint) stbte__draw_bitmap(stbte__ui.mx, stbte__ui.my, stbte__get_char_width(26), stbte__get_char_bitmap(26), 0xe0e0e0); #endif if (stbte__ui.event == STBTE__tick && stbte__ui.alert_msg) { stbte__ui.alert_timer -= stbte__ui.dt; if (stbte__ui.alert_timer < 0) { stbte__ui.alert_timer = 0; stbte__ui.alert_msg = 0; } } if (stbte__ui.event == STBTE__paint) { stbte__color_table[stbte__cp_mode][stbte__cp_aspect][STBTE__idle] = stbte__save; stbte__cp_altered = 0; } } static void stbte__do_event(stbte_tilemap *tm) { stbte__ui.next_hot_id = 0; stbte__editor_traverse(tm); stbte__ui.hot_id = stbte__ui.next_hot_id; // automatically cancel on mouse-up in case the object that triggered it // doesn't exist anymore if (stbte__ui.active_id) { if (stbte__ui.event == STBTE__leftup || stbte__ui.event == STBTE__rightup) { if (!stbte__ui.pasting) { stbte__activate(0); if (stbte__ui.undoing) stbte__end_undo(tm); stbte__ui.scrolling = 0; stbte__ui.dragging = 0; stbte__ui.linking = 0; } } } // we could do this stuff in the widgets directly, but it would keep recomputing // the same thing on every tile, which seems dumb. if (stbte__ui.pasting) { if (STBTE__IS_MAP_HOT()) { // compute pasting location based on last hot stbte__ui.paste_x = ((stbte__ui.hot_id >> 19) & 4095) - (stbte__ui.copy_width >> 1); stbte__ui.paste_y = ((stbte__ui.hot_id >> 7) & 4095) - (stbte__ui.copy_height >> 1); } } if (stbte__ui.dragging) { if (STBTE__IS_MAP_HOT()) { stbte__ui.drag_dest_x = ((stbte__ui.hot_id >> 19) & 4095) - stbte__ui.drag_offx; stbte__ui.drag_dest_y = ((stbte__ui.hot_id >> 7) & 4095) - stbte__ui.drag_offy; } } } static void stbte__set_event(int event, int x, int y) { stbte__ui.event = event; stbte__ui.mx = x; stbte__ui.my = y; stbte__ui.dx = x - stbte__ui.last_mouse_x; stbte__ui.dy = y - stbte__ui.last_mouse_y; stbte__ui.last_mouse_x = x; stbte__ui.last_mouse_y = y; stbte__ui.accum_x += stbte__ui.dx; stbte__ui.accum_y += stbte__ui.dy; } void stbte_draw(stbte_tilemap *tm) { stbte__ui.event = STBTE__paint; stbte__editor_traverse(tm); } void stbte_mouse_move(stbte_tilemap *tm, int x, int y, int shifted, int scrollkey) { stbte__set_event(STBTE__mousemove, x,y); stbte__ui.shift = shifted; stbte__ui.scrollkey = scrollkey; stbte__do_event(tm); } void stbte_mouse_button(stbte_tilemap *tm, int x, int y, int right, int down, int shifted, int scrollkey) { static int events[2][2] = { { STBTE__leftup , STBTE__leftdown }, { STBTE__rightup, STBTE__rightdown } }; stbte__set_event(events[right][down], x,y); stbte__ui.shift = shifted; stbte__ui.scrollkey = scrollkey; stbte__do_event(tm); } void stbte_mouse_wheel(stbte_tilemap *tm, int x, int y, int vscroll) { // not implemented yet -- need different way of hittesting } void stbte_action(stbte_tilemap *tm, enum stbte_action act) { switch (act) { case STBTE_tool_select: stbte__ui.tool = STBTE__tool_select; break; case STBTE_tool_brush: stbte__ui.tool = STBTE__tool_brush; break; case STBTE_tool_erase: stbte__ui.tool = STBTE__tool_erase; break; case STBTE_tool_rectangle: stbte__ui.tool = STBTE__tool_rect; break; case STBTE_tool_eyedropper: stbte__ui.tool = STBTE__tool_eyedrop; break; case STBTE_tool_link: stbte__ui.tool = STBTE__tool_link; break; case STBTE_act_toggle_grid: stbte__ui.show_grid = (stbte__ui.show_grid+1) % 3; break; case STBTE_act_toggle_links: stbte__ui.show_links ^= 1; break; case STBTE_act_undo: stbte__undo(tm); break; case STBTE_act_redo: stbte__redo(tm); break; case STBTE_act_cut: stbte__copy_cut(tm, 1); break; case STBTE_act_copy: stbte__copy_cut(tm, 0); break; case STBTE_act_paste: stbte__start_paste(tm); break; case STBTE_scroll_left: tm->scroll_x -= tm->spacing_x; break; case STBTE_scroll_right: tm->scroll_x += tm->spacing_x; break; case STBTE_scroll_up: tm->scroll_y -= tm->spacing_y; break; case STBTE_scroll_down: tm->scroll_y += tm->spacing_y; break; } } void stbte_tick(stbte_tilemap *tm, float dt) { stbte__ui.event = STBTE__tick; stbte__ui.dt = dt; stbte__do_event(tm); stbte__ui.ms_time += (int) (dt * 1024) + 1; // make sure if time is superfast it always updates a little } void stbte_mouse_sdl(stbte_tilemap *tm, const void *sdl_event, float xs, float ys, int xo, int yo) { #ifdef _SDL_H SDL_Event *event = (SDL_Event *) sdl_event; SDL_Keymod km = SDL_GetModState(); int shift = (km & KMOD_LCTRL) || (km & KMOD_RCTRL); int scrollkey = 0 != SDL_GetKeyboardState(NULL)[SDL_SCANCODE_SPACE]; switch (event->type) { case SDL_MOUSEMOTION: stbte_mouse_move(tm, (int) (xs*event->motion.x+xo), (int) (ys*event->motion.y+yo), shift, scrollkey); break; case SDL_MOUSEBUTTONUP: stbte_mouse_button(tm, (int) (xs*event->button.x+xo), (int) (ys*event->button.y+yo), event->button.button != SDL_BUTTON_LEFT, 0, shift, scrollkey); break; case SDL_MOUSEBUTTONDOWN: stbte_mouse_button(tm, (int) (xs*event->button.x+xo), (int) (ys*event->button.y+yo), event->button.button != SDL_BUTTON_LEFT, 1, shift, scrollkey); break; case SDL_MOUSEWHEEL: stbte_mouse_wheel(tm, stbte__ui.mx, stbte__ui.my, event->wheel.y); break; } #else STBTE__NOTUSED(tm); STBTE__NOTUSED(sdl_event); STBTE__NOTUSED(xs); STBTE__NOTUSED(ys); STBTE__NOTUSED(xo); STBTE__NOTUSED(yo); #endif } #endif // STB_TILEMAP_EDITOR_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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_textedit.h0000600000175000001440000014603114003056224017266 0ustar rakusers// stb_textedit.h - v1.11 - public domain - Sean Barrett // Development of this library was sponsored by RAD Game Tools // // This C header file implements the guts of a multi-line text-editing // widget; you implement display, word-wrapping, and low-level string // insertion/deletion, and stb_textedit will map user inputs into // insertions & deletions, plus updates to the cursor position, // selection state, and undo state. // // It is intended for use in games and other systems that need to build // their own custom widgets and which do not have heavy text-editing // requirements (this library is not recommended for use for editing large // texts, as its performance does not scale and it has limited undo). // // Non-trivial behaviors are modelled after Windows text controls. // // // LICENSE // // See end of file for license information. // // // DEPENDENCIES // // Uses the C runtime function 'memmove', which you can override // by defining STB_TEXTEDIT_memmove before the implementation. // Uses no other functions. Performs no runtime allocations. // // // VERSION HISTORY // // 1.11 (2017-03-03) fix HOME on last line, dragging off single-line textfield // 1.10 (2016-10-25) supress warnings about casting away const with -Wcast-qual // 1.9 (2016-08-27) customizable move-by-word // 1.8 (2016-04-02) better keyboard handling when mouse button is down // 1.7 (2015-09-13) change y range handling in case baseline is non-0 // 1.6 (2015-04-15) allow STB_TEXTEDIT_memmove // 1.5 (2014-09-10) add support for secondary keys for OS X // 1.4 (2014-08-17) fix signed/unsigned warnings // 1.3 (2014-06-19) fix mouse clicking to round to nearest char boundary // 1.2 (2014-05-27) fix some RAD types that had crept into the new code // 1.1 (2013-12-15) move-by-word (requires STB_TEXTEDIT_IS_SPACE ) // 1.0 (2012-07-26) improve documentation, initial public release // 0.3 (2012-02-24) bugfixes, single-line mode; insert mode // 0.2 (2011-11-28) fixes to undo/redo // 0.1 (2010-07-08) initial version // // ADDITIONAL CONTRIBUTORS // // Ulf Winklemann: move-by-word in 1.1 // Fabian Giesen: secondary key inputs in 1.5 // Martins Mozeiko: STB_TEXTEDIT_memmove in 1.6 // // Bugfixes: // Scott Graham // Daniel Keller // Omar Cornut // Dan Thompson // // USAGE // // This file behaves differently depending on what symbols you define // before including it. // // // Header-file mode: // // If you do not define STB_TEXTEDIT_IMPLEMENTATION before including this, // it will operate in "header file" mode. In this mode, it declares a // single public symbol, STB_TexteditState, which encapsulates the current // state of a text widget (except for the string, which you will store // separately). // // To compile in this mode, you must define STB_TEXTEDIT_CHARTYPE to a // primitive type that defines a single character (e.g. char, wchar_t, etc). // // To save space or increase undo-ability, you can optionally define the // following things that are used by the undo system: // // STB_TEXTEDIT_POSITIONTYPE small int type encoding a valid cursor position // STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow // STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer // // If you don't define these, they are set to permissive types and // moderate sizes. The undo system does no memory allocations, so // it grows STB_TexteditState by the worst-case storage which is (in bytes): // // [4 + sizeof(STB_TEXTEDIT_POSITIONTYPE)] * STB_TEXTEDIT_UNDOSTATE_COUNT // + sizeof(STB_TEXTEDIT_CHARTYPE) * STB_TEXTEDIT_UNDOCHAR_COUNT // // // Implementation mode: // // If you define STB_TEXTEDIT_IMPLEMENTATION before including this, it // will compile the implementation of the text edit widget, depending // on a large number of symbols which must be defined before the include. // // The implementation is defined only as static functions. You will then // need to provide your own APIs in the same file which will access the // static functions. // // The basic concept is that you provide a "string" object which // behaves like an array of characters. stb_textedit uses indices to // refer to positions in the string, implicitly representing positions // in the displayed textedit. This is true for both plain text and // rich text; even with rich text stb_truetype interacts with your // code as if there was an array of all the displayed characters. // // Symbols that must be the same in header-file and implementation mode: // // STB_TEXTEDIT_CHARTYPE the character type // STB_TEXTEDIT_POSITIONTYPE small type that a valid cursor position // STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow // STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer // // Symbols you must define for implementation mode: // // STB_TEXTEDIT_STRING the type of object representing a string being edited, // typically this is a wrapper object with other data you need // // STB_TEXTEDIT_STRINGLEN(obj) the length of the string (ideally O(1)) // STB_TEXTEDIT_LAYOUTROW(&r,obj,n) returns the results of laying out a line of characters // starting from character #n (see discussion below) // STB_TEXTEDIT_GETWIDTH(obj,n,i) returns the pixel delta from the xpos of the i'th character // to the xpos of the i+1'th char for a line of characters // starting at character #n (i.e. accounts for kerning // with previous char) // STB_TEXTEDIT_KEYTOTEXT(k) maps a keyboard input to an insertable character // (return type is int, -1 means not valid to insert) // STB_TEXTEDIT_GETCHAR(obj,i) returns the i'th character of obj, 0-based // STB_TEXTEDIT_NEWLINE the character returned by _GETCHAR() we recognize // as manually wordwrapping for end-of-line positioning // // STB_TEXTEDIT_DELETECHARS(obj,i,n) delete n characters starting at i // STB_TEXTEDIT_INSERTCHARS(obj,i,c*,n) insert n characters at i (pointed to by STB_TEXTEDIT_CHARTYPE*) // // STB_TEXTEDIT_K_SHIFT a power of two that is or'd in to a keyboard input to represent the shift key // // STB_TEXTEDIT_K_LEFT keyboard input to move cursor left // STB_TEXTEDIT_K_RIGHT keyboard input to move cursor right // STB_TEXTEDIT_K_UP keyboard input to move cursor up // STB_TEXTEDIT_K_DOWN keyboard input to move cursor down // STB_TEXTEDIT_K_LINESTART keyboard input to move cursor to start of line // e.g. HOME // STB_TEXTEDIT_K_LINEEND keyboard input to move cursor to end of line // e.g. END // STB_TEXTEDIT_K_TEXTSTART keyboard input to move cursor to start of text // e.g. ctrl-HOME // STB_TEXTEDIT_K_TEXTEND keyboard input to move cursor to end of text // e.g. ctrl-END // STB_TEXTEDIT_K_DELETE keyboard input to delete selection or character under cursor // STB_TEXTEDIT_K_BACKSPACE keyboard input to delete selection or character left of cursor // STB_TEXTEDIT_K_UNDO keyboard input to perform undo // STB_TEXTEDIT_K_REDO keyboard input to perform redo // // Optional: // STB_TEXTEDIT_K_INSERT keyboard input to toggle insert mode // STB_TEXTEDIT_IS_SPACE(ch) true if character is whitespace (e.g. 'isspace'), // required for default WORDLEFT/WORDRIGHT handlers // STB_TEXTEDIT_MOVEWORDLEFT(obj,i) custom handler for WORDLEFT, returns index to move cursor to // STB_TEXTEDIT_MOVEWORDRIGHT(obj,i) custom handler for WORDRIGHT, returns index to move cursor to // STB_TEXTEDIT_K_WORDLEFT keyboard input to move cursor left one word // e.g. ctrl-LEFT // STB_TEXTEDIT_K_WORDRIGHT keyboard input to move cursor right one word // e.g. ctrl-RIGHT // STB_TEXTEDIT_K_LINESTART2 secondary keyboard input to move cursor to start of line // STB_TEXTEDIT_K_LINEEND2 secondary keyboard input to move cursor to end of line // STB_TEXTEDIT_K_TEXTSTART2 secondary keyboard input to move cursor to start of text // STB_TEXTEDIT_K_TEXTEND2 secondary keyboard input to move cursor to end of text // // Todo: // STB_TEXTEDIT_K_PGUP keyboard input to move cursor up a page // STB_TEXTEDIT_K_PGDOWN keyboard input to move cursor down a page // // Keyboard input must be encoded as a single integer value; e.g. a character code // and some bitflags that represent shift states. to simplify the interface, SHIFT must // be a bitflag, so we can test the shifted state of cursor movements to allow selection, // i.e. (STB_TEXTED_K_RIGHT|STB_TEXTEDIT_K_SHIFT) should be shifted right-arrow. // // You can encode other things, such as CONTROL or ALT, in additional bits, and // then test for their presence in e.g. STB_TEXTEDIT_K_WORDLEFT. For example, // my Windows implementations add an additional CONTROL bit, and an additional KEYDOWN // bit. Then all of the STB_TEXTEDIT_K_ values bitwise-or in the KEYDOWN bit, // and I pass both WM_KEYDOWN and WM_CHAR events to the "key" function in the // API below. The control keys will only match WM_KEYDOWN events because of the // keydown bit I add, and STB_TEXTEDIT_KEYTOTEXT only tests for the KEYDOWN // bit so it only decodes WM_CHAR events. // // STB_TEXTEDIT_LAYOUTROW returns information about the shape of one displayed // row of characters assuming they start on the i'th character--the width and // the height and the number of characters consumed. This allows this library // to traverse the entire layout incrementally. You need to compute word-wrapping // here. // // Each textfield keeps its own insert mode state, which is not how normal // applications work. To keep an app-wide insert mode, update/copy the // "insert_mode" field of STB_TexteditState before/after calling API functions. // // API // // void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line) // // void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) // void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) // int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) // int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len) // void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int key) // // Each of these functions potentially updates the string and updates the // state. // // initialize_state: // set the textedit state to a known good default state when initially // constructing the textedit. // // click: // call this with the mouse x,y on a mouse down; it will update the cursor // and reset the selection start/end to the cursor point. the x,y must // be relative to the text widget, with (0,0) being the top left. // // drag: // call this with the mouse x,y on a mouse drag/up; it will update the // cursor and the selection end point // // cut: // call this to delete the current selection; returns true if there was // one. you should FIRST copy the current selection to the system paste buffer. // (To copy, just copy the current selection out of the string yourself.) // // paste: // call this to paste text at the current cursor point or over the current // selection if there is one. // // key: // call this for keyboard inputs sent to the textfield. you can use it // for "key down" events or for "translated" key events. if you need to // do both (as in Win32), or distinguish Unicode characters from control // inputs, set a high bit to distinguish the two; then you can define the // various definitions like STB_TEXTEDIT_K_LEFT have the is-key-event bit // set, and make STB_TEXTEDIT_KEYTOCHAR check that the is-key-event bit is // clear. // // When rendering, you can read the cursor position and selection state from // the STB_TexteditState. // // // Notes: // // This is designed to be usable in IMGUI, so it allows for the possibility of // running in an IMGUI that has NOT cached the multi-line layout. For this // reason, it provides an interface that is compatible with computing the // layout incrementally--we try to make sure we make as few passes through // as possible. (For example, to locate the mouse pointer in the text, we // could define functions that return the X and Y positions of characters // and binary search Y and then X, but if we're doing dynamic layout this // will run the layout algorithm many times, so instead we manually search // forward in one pass. Similar logic applies to e.g. up-arrow and // down-arrow movement.) // // If it's run in a widget that *has* cached the layout, then this is less // efficient, but it's not horrible on modern computers. But you wouldn't // want to edit million-line files with it. //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //// //// Header-file mode //// //// #ifndef INCLUDE_STB_TEXTEDIT_H #define INCLUDE_STB_TEXTEDIT_H //////////////////////////////////////////////////////////////////////// // // STB_TexteditState // // Definition of STB_TexteditState which you should store // per-textfield; it includes cursor position, selection state, // and undo state. // #ifndef STB_TEXTEDIT_UNDOSTATECOUNT #define STB_TEXTEDIT_UNDOSTATECOUNT 99 #endif #ifndef STB_TEXTEDIT_UNDOCHARCOUNT #define STB_TEXTEDIT_UNDOCHARCOUNT 999 #endif #ifndef STB_TEXTEDIT_CHARTYPE #define STB_TEXTEDIT_CHARTYPE int #endif #ifndef STB_TEXTEDIT_POSITIONTYPE #define STB_TEXTEDIT_POSITIONTYPE int #endif typedef struct { // private data STB_TEXTEDIT_POSITIONTYPE where; short insert_length; short delete_length; short char_storage; } StbUndoRecord; typedef struct { // private data StbUndoRecord undo_rec [STB_TEXTEDIT_UNDOSTATECOUNT]; STB_TEXTEDIT_CHARTYPE undo_char[STB_TEXTEDIT_UNDOCHARCOUNT]; short undo_point, redo_point; short undo_char_point, redo_char_point; } StbUndoState; typedef struct { ///////////////////// // // public data // int cursor; // position of the text cursor within the string int select_start; // selection start point int select_end; // selection start and end point in characters; if equal, no selection. // note that start may be less than or greater than end (e.g. when // dragging the mouse, start is where the initial click was, and you // can drag in either direction) unsigned char insert_mode; // each textfield keeps its own insert mode state. to keep an app-wide // insert mode, copy this value in/out of the app state ///////////////////// // // private data // unsigned char cursor_at_end_of_line; // not implemented yet unsigned char initialized; unsigned char has_preferred_x; unsigned char single_line; unsigned char padding1, padding2, padding3; float preferred_x; // this determines where the cursor up/down tries to seek to along x StbUndoState undostate; } STB_TexteditState; //////////////////////////////////////////////////////////////////////// // // StbTexteditRow // // Result of layout query, used by stb_textedit to determine where // the text in each row is. // result of layout query typedef struct { float x0,x1; // starting x location, end x location (allows for align=right, etc) float baseline_y_delta; // position of baseline relative to previous row's baseline float ymin,ymax; // height of row above and below baseline int num_chars; } StbTexteditRow; #endif //INCLUDE_STB_TEXTEDIT_H //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //// //// Implementation mode //// //// // implementation isn't include-guarded, since it might have indirectly // included just the "header" portion #ifdef STB_TEXTEDIT_IMPLEMENTATION #ifndef STB_TEXTEDIT_memmove #include #define STB_TEXTEDIT_memmove memmove #endif ///////////////////////////////////////////////////////////////////////////// // // Mouse input handling // // traverse the layout to locate the nearest character to a display position static int stb_text_locate_coord(STB_TEXTEDIT_STRING *str, float x, float y) { StbTexteditRow r; int n = STB_TEXTEDIT_STRINGLEN(str); float base_y = 0, prev_x; int i=0, k; r.x0 = r.x1 = 0; r.ymin = r.ymax = 0; r.num_chars = 0; // search rows to find one that straddles 'y' while (i < n) { STB_TEXTEDIT_LAYOUTROW(&r, str, i); if (r.num_chars <= 0) return n; if (i==0 && y < base_y + r.ymin) return 0; if (y < base_y + r.ymax) break; i += r.num_chars; base_y += r.baseline_y_delta; } // below all text, return 'after' last character if (i >= n) return n; // check if it's before the beginning of the line if (x < r.x0) return i; // check if it's before the end of the line if (x < r.x1) { // search characters in row for one that straddles 'x' prev_x = r.x0; for (k=0; k < r.num_chars; ++k) { float w = STB_TEXTEDIT_GETWIDTH(str, i, k); if (x < prev_x+w) { if (x < prev_x+w/2) return k+i; else return k+i+1; } prev_x += w; } // shouldn't happen, but if it does, fall through to end-of-line case } // if the last character is a newline, return that. otherwise return 'after' the last character if (STB_TEXTEDIT_GETCHAR(str, i+r.num_chars-1) == STB_TEXTEDIT_NEWLINE) return i+r.num_chars-1; else return i+r.num_chars; } // API click: on mouse down, move the cursor to the clicked location, and reset the selection static void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) { // In single-line mode, just always make y = 0. This lets the drag keep working if the mouse // goes off the top or bottom of the text if( state->single_line ) { StbTexteditRow r; STB_TEXTEDIT_LAYOUTROW(&r, str, 0); y = r.ymin; } state->cursor = stb_text_locate_coord(str, x, y); state->select_start = state->cursor; state->select_end = state->cursor; state->has_preferred_x = 0; } // API drag: on mouse drag, move the cursor and selection endpoint to the clicked location static void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) { int p = 0; // In single-line mode, just always make y = 0. This lets the drag keep working if the mouse // goes off the top or bottom of the text if( state->single_line ) { StbTexteditRow r; STB_TEXTEDIT_LAYOUTROW(&r, str, 0); y = r.ymin; } if (state->select_start == state->select_end) state->select_start = state->cursor; p = stb_text_locate_coord(str, x, y); state->cursor = state->select_end = p; } ///////////////////////////////////////////////////////////////////////////// // // Keyboard input handling // // forward declarations static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state); static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state); static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length); static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length); static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length); typedef struct { float x,y; // position of n'th character float height; // height of line int first_char, length; // first char of row, and length int prev_first; // first char of previous row } StbFindState; // find the x/y location of a character, and remember info about the previous row in // case we get a move-up event (for page up, we'll have to rescan) static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *str, int n, int single_line) { StbTexteditRow r; int prev_start = 0; int z = STB_TEXTEDIT_STRINGLEN(str); int i=0, first; if (n == z) { // if it's at the end, then find the last line -- simpler than trying to // explicitly handle this case in the regular code if (single_line) { STB_TEXTEDIT_LAYOUTROW(&r, str, 0); find->y = 0; find->first_char = 0; find->length = z; find->height = r.ymax - r.ymin; find->x = r.x1; } else { find->y = 0; find->x = 0; find->height = 1; while (i < z) { STB_TEXTEDIT_LAYOUTROW(&r, str, i); prev_start = i; i += r.num_chars; } find->first_char = i; find->length = 0; find->prev_first = prev_start; } return; } // search rows to find the one that straddles character n find->y = 0; for(;;) { STB_TEXTEDIT_LAYOUTROW(&r, str, i); if (n < i + r.num_chars) break; prev_start = i; i += r.num_chars; find->y += r.baseline_y_delta; } find->first_char = first = i; find->length = r.num_chars; find->height = r.ymax - r.ymin; find->prev_first = prev_start; // now scan to find xpos find->x = r.x0; i = 0; for (i=0; first+i < n; ++i) find->x += STB_TEXTEDIT_GETWIDTH(str, first, i); } #define STB_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end) // make the selection/cursor state valid if client altered the string static void stb_textedit_clamp(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { int n = STB_TEXTEDIT_STRINGLEN(str); if (STB_TEXT_HAS_SELECTION(state)) { if (state->select_start > n) state->select_start = n; if (state->select_end > n) state->select_end = n; // if clamping forced them to be equal, move the cursor to match if (state->select_start == state->select_end) state->cursor = state->select_start; } if (state->cursor > n) state->cursor = n; } // delete characters while updating undo static void stb_textedit_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int len) { stb_text_makeundo_delete(str, state, where, len); STB_TEXTEDIT_DELETECHARS(str, where, len); state->has_preferred_x = 0; } // delete the section static void stb_textedit_delete_selection(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { stb_textedit_clamp(str, state); if (STB_TEXT_HAS_SELECTION(state)) { if (state->select_start < state->select_end) { stb_textedit_delete(str, state, state->select_start, state->select_end - state->select_start); state->select_end = state->cursor = state->select_start; } else { stb_textedit_delete(str, state, state->select_end, state->select_start - state->select_end); state->select_start = state->cursor = state->select_end; } state->has_preferred_x = 0; } } // canoncialize the selection so start <= end static void stb_textedit_sortselection(STB_TexteditState *state) { if (state->select_end < state->select_start) { int temp = state->select_end; state->select_end = state->select_start; state->select_start = temp; } } // move cursor to first character of selection static void stb_textedit_move_to_first(STB_TexteditState *state) { if (STB_TEXT_HAS_SELECTION(state)) { stb_textedit_sortselection(state); state->cursor = state->select_start; state->select_end = state->select_start; state->has_preferred_x = 0; } } // move cursor to last character of selection static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { if (STB_TEXT_HAS_SELECTION(state)) { stb_textedit_sortselection(state); stb_textedit_clamp(str, state); state->cursor = state->select_end; state->select_start = state->select_end; state->has_preferred_x = 0; } } #ifdef STB_TEXTEDIT_IS_SPACE static int is_word_boundary( STB_TEXTEDIT_STRING *str, int idx ) { return idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str,idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str, idx) ) ) : 1; } #ifndef STB_TEXTEDIT_MOVEWORDLEFT static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *str, int c ) { --c; // always move at least one character while( c >= 0 && !is_word_boundary( str, c ) ) --c; if( c < 0 ) c = 0; return c; } #define STB_TEXTEDIT_MOVEWORDLEFT stb_textedit_move_to_word_previous #endif #ifndef STB_TEXTEDIT_MOVEWORDRIGHT static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *str, int c ) { const int len = STB_TEXTEDIT_STRINGLEN(str); ++c; // always move at least one character while( c < len && !is_word_boundary( str, c ) ) ++c; if( c > len ) c = len; return c; } #define STB_TEXTEDIT_MOVEWORDRIGHT stb_textedit_move_to_word_next #endif #endif // update selection and cursor to match each other static void stb_textedit_prep_selection_at_cursor(STB_TexteditState *state) { if (!STB_TEXT_HAS_SELECTION(state)) state->select_start = state->select_end = state->cursor; else state->cursor = state->select_end; } // API cut: delete selection static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { if (STB_TEXT_HAS_SELECTION(state)) { stb_textedit_delete_selection(str,state); // implicity clamps state->has_preferred_x = 0; return 1; } return 0; } // API paste: replace existing selection with passed-in text static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len) { // if there's a selection, the paste should delete it stb_textedit_clamp(str, state); stb_textedit_delete_selection(str,state); // try to insert the characters if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, len)) { stb_text_makeundo_insert(state, state->cursor, len); state->cursor += len; state->has_preferred_x = 0; return 1; } // remove the undo since we didn't actually insert the characters if (state->undostate.undo_point) --state->undostate.undo_point; return 0; } // API key: process a keyboard input static void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int key) { retry: switch (key) { default: { int c = STB_TEXTEDIT_KEYTOTEXT(key); if (c > 0) { STB_TEXTEDIT_CHARTYPE ch = (STB_TEXTEDIT_CHARTYPE) c; // can't add newline in single-line mode if (c == '\n' && state->single_line) break; if (state->insert_mode && !STB_TEXT_HAS_SELECTION(state) && state->cursor < STB_TEXTEDIT_STRINGLEN(str)) { stb_text_makeundo_replace(str, state, state->cursor, 1, 1); STB_TEXTEDIT_DELETECHARS(str, state->cursor, 1); if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { ++state->cursor; state->has_preferred_x = 0; } } else { stb_textedit_delete_selection(str,state); // implicity clamps if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { stb_text_makeundo_insert(state, state->cursor, 1); ++state->cursor; state->has_preferred_x = 0; } } } break; } #ifdef STB_TEXTEDIT_K_INSERT case STB_TEXTEDIT_K_INSERT: state->insert_mode = !state->insert_mode; break; #endif case STB_TEXTEDIT_K_UNDO: stb_text_undo(str, state); state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_REDO: stb_text_redo(str, state); state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_LEFT: // if currently there's a selection, move cursor to start of selection if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_first(state); else if (state->cursor > 0) --state->cursor; state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_RIGHT: // if currently there's a selection, move cursor to end of selection if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_last(str, state); else ++state->cursor; stb_textedit_clamp(str, state); state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_SHIFT: stb_textedit_clamp(str, state); stb_textedit_prep_selection_at_cursor(state); // move selection left if (state->select_end > 0) --state->select_end; state->cursor = state->select_end; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_MOVEWORDLEFT case STB_TEXTEDIT_K_WORDLEFT: if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_first(state); else { state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); stb_textedit_clamp( str, state ); } break; case STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT: if( !STB_TEXT_HAS_SELECTION( state ) ) stb_textedit_prep_selection_at_cursor(state); state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); state->select_end = state->cursor; stb_textedit_clamp( str, state ); break; #endif #ifdef STB_TEXTEDIT_MOVEWORDRIGHT case STB_TEXTEDIT_K_WORDRIGHT: if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_last(str, state); else { state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); stb_textedit_clamp( str, state ); } break; case STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT: if( !STB_TEXT_HAS_SELECTION( state ) ) stb_textedit_prep_selection_at_cursor(state); state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); state->select_end = state->cursor; stb_textedit_clamp( str, state ); break; #endif case STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_SHIFT: stb_textedit_prep_selection_at_cursor(state); // move selection right ++state->select_end; stb_textedit_clamp(str, state); state->cursor = state->select_end; state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_DOWN: case STB_TEXTEDIT_K_DOWN | STB_TEXTEDIT_K_SHIFT: { StbFindState find; StbTexteditRow row; int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; if (state->single_line) { // on windows, up&down in single-line behave like left&right key = STB_TEXTEDIT_K_RIGHT | (key & STB_TEXTEDIT_K_SHIFT); goto retry; } if (sel) stb_textedit_prep_selection_at_cursor(state); else if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_last(str,state); // compute current position of cursor point stb_textedit_clamp(str, state); stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); // now find character position down a row if (find.length) { float goal_x = state->has_preferred_x ? state->preferred_x : find.x; float x; int start = find.first_char + find.length; state->cursor = start; STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); x = row.x0; for (i=0; i < row.num_chars; ++i) { float dx = STB_TEXTEDIT_GETWIDTH(str, start, i); #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) break; #endif x += dx; if (x > goal_x) break; ++state->cursor; } stb_textedit_clamp(str, state); state->has_preferred_x = 1; state->preferred_x = goal_x; if (sel) state->select_end = state->cursor; } break; } case STB_TEXTEDIT_K_UP: case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT: { StbFindState find; StbTexteditRow row; int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; if (state->single_line) { // on windows, up&down become left&right key = STB_TEXTEDIT_K_LEFT | (key & STB_TEXTEDIT_K_SHIFT); goto retry; } if (sel) stb_textedit_prep_selection_at_cursor(state); else if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_first(state); // compute current position of cursor point stb_textedit_clamp(str, state); stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); // can only go up if there's a previous row if (find.prev_first != find.first_char) { // now find character position up a row float goal_x = state->has_preferred_x ? state->preferred_x : find.x; float x; state->cursor = find.prev_first; STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); x = row.x0; for (i=0; i < row.num_chars; ++i) { float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i); #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) break; #endif x += dx; if (x > goal_x) break; ++state->cursor; } stb_textedit_clamp(str, state); state->has_preferred_x = 1; state->preferred_x = goal_x; if (sel) state->select_end = state->cursor; } break; } case STB_TEXTEDIT_K_DELETE: case STB_TEXTEDIT_K_DELETE | STB_TEXTEDIT_K_SHIFT: if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_delete_selection(str, state); else { int n = STB_TEXTEDIT_STRINGLEN(str); if (state->cursor < n) stb_textedit_delete(str, state, state->cursor, 1); } state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_BACKSPACE: case STB_TEXTEDIT_K_BACKSPACE | STB_TEXTEDIT_K_SHIFT: if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_delete_selection(str, state); else { stb_textedit_clamp(str, state); if (state->cursor > 0) { stb_textedit_delete(str, state, state->cursor-1, 1); --state->cursor; } } state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_TEXTSTART2 case STB_TEXTEDIT_K_TEXTSTART2: #endif case STB_TEXTEDIT_K_TEXTSTART: state->cursor = state->select_start = state->select_end = 0; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_TEXTEND2 case STB_TEXTEDIT_K_TEXTEND2: #endif case STB_TEXTEDIT_K_TEXTEND: state->cursor = STB_TEXTEDIT_STRINGLEN(str); state->select_start = state->select_end = 0; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_TEXTSTART2 case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT: #endif case STB_TEXTEDIT_K_TEXTSTART | STB_TEXTEDIT_K_SHIFT: stb_textedit_prep_selection_at_cursor(state); state->cursor = state->select_end = 0; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_TEXTEND2 case STB_TEXTEDIT_K_TEXTEND2 | STB_TEXTEDIT_K_SHIFT: #endif case STB_TEXTEDIT_K_TEXTEND | STB_TEXTEDIT_K_SHIFT: stb_textedit_prep_selection_at_cursor(state); state->cursor = state->select_end = STB_TEXTEDIT_STRINGLEN(str); state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_LINESTART2 case STB_TEXTEDIT_K_LINESTART2: #endif case STB_TEXTEDIT_K_LINESTART: stb_textedit_clamp(str, state); stb_textedit_move_to_first(state); if (state->single_line) state->cursor = 0; else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) --state->cursor; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_LINEEND2 case STB_TEXTEDIT_K_LINEEND2: #endif case STB_TEXTEDIT_K_LINEEND: { int n = STB_TEXTEDIT_STRINGLEN(str); stb_textedit_clamp(str, state); stb_textedit_move_to_first(state); if (state->single_line) state->cursor = n; else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) ++state->cursor; state->has_preferred_x = 0; break; } #ifdef STB_TEXTEDIT_K_LINESTART2 case STB_TEXTEDIT_K_LINESTART2 | STB_TEXTEDIT_K_SHIFT: #endif case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT: stb_textedit_clamp(str, state); stb_textedit_prep_selection_at_cursor(state); if (state->single_line) state->cursor = 0; else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) --state->cursor; state->select_end = state->cursor; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_LINEEND2 case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT: #endif case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: { int n = STB_TEXTEDIT_STRINGLEN(str); stb_textedit_clamp(str, state); stb_textedit_prep_selection_at_cursor(state); if (state->single_line) state->cursor = n; else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) ++state->cursor; state->select_end = state->cursor; state->has_preferred_x = 0; break; } // @TODO: // STB_TEXTEDIT_K_PGUP - move cursor up a page // STB_TEXTEDIT_K_PGDOWN - move cursor down a page } } ///////////////////////////////////////////////////////////////////////////// // // Undo processing // // @OPTIMIZE: the undo/redo buffer should be circular static void stb_textedit_flush_redo(StbUndoState *state) { state->redo_point = STB_TEXTEDIT_UNDOSTATECOUNT; state->redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT; } // discard the oldest entry in the undo list static void stb_textedit_discard_undo(StbUndoState *state) { if (state->undo_point > 0) { // if the 0th undo state has characters, clean those up if (state->undo_rec[0].char_storage >= 0) { int n = state->undo_rec[0].insert_length, i; // delete n characters from all other records state->undo_char_point = state->undo_char_point - (short) n; // vsnet05 STB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE))); for (i=0; i < state->undo_point; ++i) if (state->undo_rec[i].char_storage >= 0) state->undo_rec[i].char_storage = state->undo_rec[i].char_storage - (short) n; // vsnet05 // @OPTIMIZE: get rid of char_storage and infer it } --state->undo_point; STB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0]))); } } // discard the oldest entry in the redo list--it's bad if this // ever happens, but because undo & redo have to store the actual // characters in different cases, the redo character buffer can // fill up even though the undo buffer didn't static void stb_textedit_discard_redo(StbUndoState *state) { int k = STB_TEXTEDIT_UNDOSTATECOUNT-1; if (state->redo_point <= k) { // if the k'th undo state has characters, clean those up if (state->undo_rec[k].char_storage >= 0) { int n = state->undo_rec[k].insert_length, i; // delete n characters from all other records state->redo_char_point = state->redo_char_point + (short) n; // vsnet05 STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE))); for (i=state->redo_point; i < k; ++i) if (state->undo_rec[i].char_storage >= 0) state->undo_rec[i].char_storage = state->undo_rec[i].char_storage + (short) n; // vsnet05 } ++state->redo_point; STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point-1, state->undo_rec + state->redo_point, (size_t) ((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0]))); } } static StbUndoRecord *stb_text_create_undo_record(StbUndoState *state, int numchars) { // any time we create a new undo record, we discard redo stb_textedit_flush_redo(state); // if we have no free records, we have to make room, by sliding the // existing records down if (state->undo_point == STB_TEXTEDIT_UNDOSTATECOUNT) stb_textedit_discard_undo(state); // if the characters to store won't possibly fit in the buffer, we can't undo if (numchars > STB_TEXTEDIT_UNDOCHARCOUNT) { state->undo_point = 0; state->undo_char_point = 0; return NULL; } // if we don't have enough free characters in the buffer, we have to make room while (state->undo_char_point + numchars > STB_TEXTEDIT_UNDOCHARCOUNT) stb_textedit_discard_undo(state); return &state->undo_rec[state->undo_point++]; } static STB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos, int insert_len, int delete_len) { StbUndoRecord *r = stb_text_create_undo_record(state, insert_len); if (r == NULL) return NULL; r->where = pos; r->insert_length = (short) insert_len; r->delete_length = (short) delete_len; if (insert_len == 0) { r->char_storage = -1; return NULL; } else { r->char_storage = state->undo_char_point; state->undo_char_point = state->undo_char_point + (short) insert_len; return &state->undo_char[r->char_storage]; } } static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { StbUndoState *s = &state->undostate; StbUndoRecord u, *r; if (s->undo_point == 0) return; // we need to do two things: apply the undo record, and create a redo record u = s->undo_rec[s->undo_point-1]; r = &s->undo_rec[s->redo_point-1]; r->char_storage = -1; r->insert_length = u.delete_length; r->delete_length = u.insert_length; r->where = u.where; if (u.delete_length) { // if the undo record says to delete characters, then the redo record will // need to re-insert the characters that get deleted, so we need to store // them. // there are three cases: // there's enough room to store the characters // characters stored for *redoing* don't leave room for redo // characters stored for *undoing* don't leave room for redo // if the last is true, we have to bail if (s->undo_char_point + u.delete_length >= STB_TEXTEDIT_UNDOCHARCOUNT) { // the undo records take up too much character space; there's no space to store the redo characters r->insert_length = 0; } else { int i; // there's definitely room to store the characters eventually while (s->undo_char_point + u.delete_length > s->redo_char_point) { // there's currently not enough room, so discard a redo record stb_textedit_discard_redo(s); // should never happen: if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) return; } r = &s->undo_rec[s->redo_point-1]; r->char_storage = s->redo_char_point - u.delete_length; s->redo_char_point = s->redo_char_point - (short) u.delete_length; // now save the characters for (i=0; i < u.delete_length; ++i) s->undo_char[r->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u.where + i); } // now we can carry out the deletion STB_TEXTEDIT_DELETECHARS(str, u.where, u.delete_length); } // check type of recorded action: if (u.insert_length) { // easy case: was a deletion, so we need to insert n characters STB_TEXTEDIT_INSERTCHARS(str, u.where, &s->undo_char[u.char_storage], u.insert_length); s->undo_char_point -= u.insert_length; } state->cursor = u.where + u.insert_length; s->undo_point--; s->redo_point--; } static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { StbUndoState *s = &state->undostate; StbUndoRecord *u, r; if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) return; // we need to do two things: apply the redo record, and create an undo record u = &s->undo_rec[s->undo_point]; r = s->undo_rec[s->redo_point]; // we KNOW there must be room for the undo record, because the redo record // was derived from an undo record u->delete_length = r.insert_length; u->insert_length = r.delete_length; u->where = r.where; u->char_storage = -1; if (r.delete_length) { // the redo record requires us to delete characters, so the undo record // needs to store the characters if (s->undo_char_point + u->insert_length > s->redo_char_point) { u->insert_length = 0; u->delete_length = 0; } else { int i; u->char_storage = s->undo_char_point; s->undo_char_point = s->undo_char_point + u->insert_length; // now save the characters for (i=0; i < u->insert_length; ++i) s->undo_char[u->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u->where + i); } STB_TEXTEDIT_DELETECHARS(str, r.where, r.delete_length); } if (r.insert_length) { // easy case: need to insert n characters STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length); } state->cursor = r.where + r.insert_length; s->undo_point++; s->redo_point++; } static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length) { stb_text_createundo(&state->undostate, where, 0, length); } static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length) { int i; STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, length, 0); if (p) { for (i=0; i < length; ++i) p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); } } static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length) { int i; STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, old_length, new_length); if (p) { for (i=0; i < old_length; ++i) p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); } } // reset the state to default static void stb_textedit_clear_state(STB_TexteditState *state, int is_single_line) { state->undostate.undo_point = 0; state->undostate.undo_char_point = 0; state->undostate.redo_point = STB_TEXTEDIT_UNDOSTATECOUNT; state->undostate.redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT; state->select_end = state->select_start = 0; state->cursor = 0; state->has_preferred_x = 0; state->preferred_x = 0; state->cursor_at_end_of_line = 0; state->initialized = 1; state->single_line = (unsigned char) is_single_line; state->insert_mode = 0; } // API initialize static void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line) { stb_textedit_clear_state(state, is_single_line); } #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-qual" #endif static int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE const *ctext, int len) { return stb_textedit_paste_internal(str, state, (STB_TEXTEDIT_CHARTYPE *) ctext, len); } #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif #endif//STB_TEXTEDIT_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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_sprintf.h0000600000175000001440000015407514003056224017130 0ustar rakusers// stb_sprintf - v1.03 - 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 : h ll j z t I64 I32 I // // Contributors: // Fabian "ryg" Giesen (reformatting) // // Contributors (bugfixes): // github:d26435 // github:trex78 // Jari Komppa (SI suffixes) // // 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(__has_feature) #if __has_feature(address_sanitizer) #define STBI__ASAN __attribute__((no_sanitize("address"))) #endif #endif #ifndef STBI__ASAN #define STBI__ASAN #endif #ifdef STB_SPRINTF_STATIC #define STBSP__PUBLICDEC static #define STBSP__PUBLICDEF static STBI__ASAN #else #ifdef __cplusplus #define STBSP__PUBLICDEC extern "C" #define STBSP__PUBLICDEF extern "C" STBI__ASAN #else #define STBSP__PUBLICDEC extern #define STBSP__PUBLICDEF STBI__ASAN #endif #endif #include // for va_list() #ifndef STB_SPRINTF_MIN #define STB_SPRINTF_MIN 512 // how many characters per callback #endif typedef char *STBSP_SPRINTFCB(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__PUBLICDEF int STB_SPRINTF_DECORATE(vsprintf)(char *buf, char const *fmt, va_list va); STBSP__PUBLICDEF int STB_SPRINTF_DECORATE(vsnprintf)(char *buf, int count, char const *fmt, va_list va); STBSP__PUBLICDEF int STB_SPRINTF_DECORATE(sprintf)(char *buf, char const *fmt, ...); STBSP__PUBLICDEF int STB_SPRINTF_DECORATE(snprintf)(char *buf, int count, char const *fmt, ...); STBSP__PUBLICDEF int STB_SPRINTF_DECORATE(vsprintfcb)(STBSP_SPRINTFCB *callback, void *user, char *buf, char const *fmt, va_list va); STBSP__PUBLICDEF void STB_SPRINTF_DECORATE(set_separators)(char comma, char period); #endif // STB_SPRINTF_H_INCLUDE #ifdef STB_SPRINTF_IMPLEMENTATION #include // for va_arg() #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(__aarch64__) || defined(_M_X64) || defined(__x86_64__) || defined(__x86_64) #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 char stbsp__digitpair[201] = "0001020304050607080910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576" "7778798081828384858687888990919293949596979899"; 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] = '+'; } } 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; *(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; break; // are we 64-bit (unix style) case 'l': ++f; if (f[0] == 'l') { fl |= STBSP__INTMAX; ++f; } break; // are we 64-bit on intmax? (c99) case 'j': fl |= STBSP__INTMAX; ++f; break; // are we 64-bit on size_t or ptrdiff_t? (c99) case 'z': case 't': fl |= ((sizeof(char *) == 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 sn = s; for (;;) { if ((((stbsp__uintptr)sn) & 3) == 0) break; lchk: if (sn[0] == 0) goto ld; ++sn; } n = 0xffffffff; if (pr >= 0) { n = (stbsp__uint32)(sn - s); if (n >= (stbsp__uint32)pr) goto ld; n = ((stbsp__uint32)(pr - n)) >> 2; } while (n) { stbsp__uint32 v = *(stbsp__uint32 *)sn; if ((v - 0x01010101) & (~v) & 0x80808080UL) goto lchk; sn += 4; --n; } goto lchk; ld: l = (stbsp__uint32)(sn - s); // clamp to precision if (l > (stbsp__uint32)pr) l = pr; 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; dp = 0; cs = 0; 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 sematics for %f if (dp > 0) { pr = (dp < (stbsp__int32)l) ? l - dp : 0; } else { pr = -dp + ((pr > (stbsp__int32)l) ? 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 // drop 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 = (((l >> 4) & 15)) << 24; 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) { while (n) { s -= 2; *(stbsp__uint16 *)s = *(stbsp__uint16 *)&stbsp__digitpair[(n % 100) * 2]; n /= 100; } } 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 *)bf = *(stbsp__uint32 *)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 = pr = 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; char tmp[STB_SPRINTF_MIN]; } stbsp__context; static char *stbsp__clamp_callback(char *buf, void *user, int len) { stbsp__context *c = (stbsp__context *)user; if (len > c->count) len = c->count; if (len) { if (buf != c->buf) { char *s, *d, *se; 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 0; return (c->count >= STB_SPRINTF_MIN) ? c->buf : 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; int l; if (count == 0) return 0; c.buf = buf; c.count = count; 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 l; } 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)(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)ph; \ 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)(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 ((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[(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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_rect_pack.h0000600000175000001440000004706114003056224017372 0ustar rakusers// stb_rect_pack.h - v0.11 - public domain - rectangle packing // Sean Barrett 2014 // // Useful for e.g. packing rectangular textures into an atlas. // Does not do rotation. // // Not necessarily the awesomest packing method, but better than // the totally naive one in stb_truetype (which is primarily what // this is meant to replace). // // Has only had a few tests run, may have issues. // // More docs to come. // // No memory allocations; uses qsort() and assert() from stdlib. // Can override those by defining STBRP_SORT and STBRP_ASSERT. // // This library currently uses the Skyline Bottom-Left algorithm. // // Please note: better rectangle packers are welcome! Please // implement them to the same API, but with a different init // function. // // Credits // // Library // Sean Barrett // Minor features // Martins Mozeiko // github:IntellectualKitty // // Bugfixes / warning fixes // Jeremy Jaussaud // // Version history: // // 0.11 (2017-03-03) return packing success/fail result // 0.10 (2016-10-25) remove cast-away-const to avoid warnings // 0.09 (2016-08-27) fix compiler warnings // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort // 0.05: added STBRP_ASSERT to allow replacing assert // 0.04: fixed minor bug in STBRP_LARGE_RECTS support // 0.01: initial release // // LICENSE // // See end of file for license information. ////////////////////////////////////////////////////////////////////////////// // // INCLUDE SECTION // #ifndef STB_INCLUDE_STB_RECT_PACK_H #define STB_INCLUDE_STB_RECT_PACK_H #define STB_RECT_PACK_VERSION 1 #ifdef STBRP_STATIC #define STBRP_DEF static #else #define STBRP_DEF extern #endif #ifdef __cplusplus extern "C" { #endif typedef struct stbrp_context stbrp_context; typedef struct stbrp_node stbrp_node; typedef struct stbrp_rect stbrp_rect; #ifdef STBRP_LARGE_RECTS typedef int stbrp_coord; #else typedef unsigned short stbrp_coord; #endif STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); // Assign packed locations to rectangles. The rectangles are of type // 'stbrp_rect' defined below, stored in the array 'rects', and there // are 'num_rects' many of them. // // Rectangles which are successfully packed have the 'was_packed' flag // set to a non-zero value and 'x' and 'y' store the minimum location // on each axis (i.e. bottom-left in cartesian coordinates, top-left // if you imagine y increasing downwards). Rectangles which do not fit // have the 'was_packed' flag set to 0. // // You should not try to access the 'rects' array from another thread // while this function is running, as the function temporarily reorders // the array while it executes. // // To pack into another rectangle, you need to call stbrp_init_target // again. To continue packing into the same rectangle, you can call // this function again. Calling this multiple times with multiple rect // arrays will probably produce worse packing results than calling it // a single time with the full rectangle array, but the option is // available. // // The function returns 1 if all of the rectangles were successfully // packed and 0 otherwise. struct stbrp_rect { // reserved for your use: int id; // input: stbrp_coord w, h; // output: stbrp_coord x, y; int was_packed; // non-zero if valid packing }; // 16 bytes, nominally STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); // Initialize a rectangle packer to: // pack a rectangle that is 'width' by 'height' in dimensions // using temporary storage provided by the array 'nodes', which is 'num_nodes' long // // You must call this function every time you start packing into a new target. // // There is no "shutdown" function. The 'nodes' memory must stay valid for // the following stbrp_pack_rects() call (or calls), but can be freed after // the call (or calls) finish. // // Note: to guarantee best results, either: // 1. make sure 'num_nodes' >= 'width' // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' // // If you don't do either of the above things, widths will be quantized to multiples // of small integers to guarantee the algorithm doesn't run out of temporary storage. // // If you do #2, then the non-quantized algorithm will be used, but the algorithm // may run out of temporary storage and be unable to pack some rectangles. STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); // Optionally call this function after init but before doing any packing to // change the handling of the out-of-temp-memory scenario, described above. // If you call init again, this will be reset to the default (false). STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); // Optionally select which packing heuristic the library should use. Different // heuristics will produce better/worse results for different data sets. // If you call init again, this will be reset to the default. enum { STBRP_HEURISTIC_Skyline_default=0, STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, STBRP_HEURISTIC_Skyline_BF_sortHeight }; ////////////////////////////////////////////////////////////////////////////// // // the details of the following structures don't matter to you, but they must // be visible so you can handle the memory allocations for them struct stbrp_node { stbrp_coord x,y; stbrp_node *next; }; struct stbrp_context { int width; int height; int align; int init_mode; int heuristic; int num_nodes; stbrp_node *active_head; stbrp_node *free_head; stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' }; #ifdef __cplusplus } #endif #endif ////////////////////////////////////////////////////////////////////////////// // // IMPLEMENTATION SECTION // #ifdef STB_RECT_PACK_IMPLEMENTATION #ifndef STBRP_SORT #include #define STBRP_SORT qsort #endif #ifndef STBRP_ASSERT #include #define STBRP_ASSERT assert #endif #ifdef _MSC_VER #define STBRP__NOTUSED(v) (void)(v) #else #define STBRP__NOTUSED(v) (void)sizeof(v) #endif enum { STBRP__INIT_skyline = 1 }; STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) { switch (context->init_mode) { case STBRP__INIT_skyline: STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); context->heuristic = heuristic; break; default: STBRP_ASSERT(0); } } STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) { if (allow_out_of_mem) // if it's ok to run out of memory, then don't bother aligning them; // this gives better packing, but may fail due to OOM (even though // the rectangles easily fit). @TODO a smarter approach would be to only // quantize once we've hit OOM, then we could get rid of this parameter. context->align = 1; else { // if it's not ok to run out of memory, then quantize the widths // so that num_nodes is always enough nodes. // // I.e. num_nodes * align >= width // align >= width / num_nodes // align = ceil(width/num_nodes) context->align = (context->width + context->num_nodes-1) / context->num_nodes; } } STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) { int i; #ifndef STBRP_LARGE_RECTS STBRP_ASSERT(width <= 0xffff && height <= 0xffff); #endif for (i=0; i < num_nodes-1; ++i) nodes[i].next = &nodes[i+1]; nodes[i].next = NULL; context->init_mode = STBRP__INIT_skyline; context->heuristic = STBRP_HEURISTIC_Skyline_default; context->free_head = &nodes[0]; context->active_head = &context->extra[0]; context->width = width; context->height = height; context->num_nodes = num_nodes; stbrp_setup_allow_out_of_mem(context, 0); // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) context->extra[0].x = 0; context->extra[0].y = 0; context->extra[0].next = &context->extra[1]; context->extra[1].x = (stbrp_coord) width; #ifdef STBRP_LARGE_RECTS context->extra[1].y = (1<<30); #else context->extra[1].y = 65535; #endif context->extra[1].next = NULL; } // find minimum y position if it starts at x1 static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) { stbrp_node *node = first; int x1 = x0 + width; int min_y, visited_width, waste_area; STBRP__NOTUSED(c); STBRP_ASSERT(first->x <= x0); #if 0 // skip in case we're past the node while (node->next->x <= x0) ++node; #else STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency #endif STBRP_ASSERT(node->x <= x0); min_y = 0; waste_area = 0; visited_width = 0; while (node->x < x1) { if (node->y > min_y) { // raise min_y higher. // we've accounted for all waste up to min_y, // but we'll now add more waste for everything we've visted waste_area += visited_width * (node->y - min_y); min_y = node->y; // the first time through, visited_width might be reduced if (node->x < x0) visited_width += node->next->x - x0; else visited_width += node->next->x - node->x; } else { // add waste area int under_width = node->next->x - node->x; if (under_width + visited_width > width) under_width = width - visited_width; waste_area += under_width * (min_y - node->y); visited_width += under_width; } node = node->next; } *pwaste = waste_area; return min_y; } typedef struct { int x,y; stbrp_node **prev_link; } stbrp__findresult; static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) { int best_waste = (1<<30), best_x, best_y = (1 << 30); stbrp__findresult fr; stbrp_node **prev, *node, *tail, **best = NULL; // align to multiple of c->align width = (width + c->align - 1); width -= width % c->align; STBRP_ASSERT(width % c->align == 0); node = c->active_head; prev = &c->active_head; while (node->x + width <= c->width) { int y,waste; y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL // bottom left if (y < best_y) { best_y = y; best = prev; } } else { // best-fit if (y + height <= c->height) { // can only use it if it first vertically if (y < best_y || (y == best_y && waste < best_waste)) { best_y = y; best_waste = waste; best = prev; } } } prev = &node->next; node = node->next; } best_x = (best == NULL) ? 0 : (*best)->x; // if doing best-fit (BF), we also have to try aligning right edge to each node position // // e.g, if fitting // // ____________________ // |____________________| // // into // // | | // | ____________| // |____________| // // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned // // This makes BF take about 2x the time if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { tail = c->active_head; node = c->active_head; prev = &c->active_head; // find first node that's admissible while (tail->x < width) tail = tail->next; while (tail) { int xpos = tail->x - width; int y,waste; STBRP_ASSERT(xpos >= 0); // find the left position that matches this while (node->next->x <= xpos) { prev = &node->next; node = node->next; } STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); if (y + height < c->height) { if (y <= best_y) { if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { best_x = xpos; STBRP_ASSERT(y <= best_y); best_y = y; best_waste = waste; best = prev; } } } tail = tail->next; } } fr.prev_link = best; fr.x = best_x; fr.y = best_y; return fr; } static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) { // find best position according to heuristic stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); stbrp_node *node, *cur; // bail if: // 1. it failed // 2. the best node doesn't fit (we don't always check this) // 3. we're out of memory if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { res.prev_link = NULL; return res; } // on success, create new node node = context->free_head; node->x = (stbrp_coord) res.x; node->y = (stbrp_coord) (res.y + height); context->free_head = node->next; // insert the new node into the right starting point, and // let 'cur' point to the remaining nodes needing to be // stiched back in cur = *res.prev_link; if (cur->x < res.x) { // preserve the existing one, so start testing with the next one stbrp_node *next = cur->next; cur->next = node; cur = next; } else { *res.prev_link = node; } // from here, traverse cur and free the nodes, until we get to one // that shouldn't be freed while (cur->next && cur->next->x <= res.x + width) { stbrp_node *next = cur->next; // move the current node to the free list cur->next = context->free_head; context->free_head = cur; cur = next; } // stitch the list back in node->next = cur; if (cur->x < res.x + width) cur->x = (stbrp_coord) (res.x + width); #ifdef _DEBUG cur = context->active_head; while (cur->x < context->width) { STBRP_ASSERT(cur->x < cur->next->x); cur = cur->next; } STBRP_ASSERT(cur->next == NULL); { stbrp_node *L1 = NULL, *L2 = NULL; int count=0; cur = context->active_head; while (cur) { L1 = cur; cur = cur->next; ++count; } cur = context->free_head; while (cur) { L2 = cur; cur = cur->next; ++count; } STBRP_ASSERT(count == context->num_nodes+2); } #endif return res; } static int rect_height_compare(const void *a, const void *b) { const stbrp_rect *p = (const stbrp_rect *) a; const stbrp_rect *q = (const stbrp_rect *) b; if (p->h > q->h) return -1; if (p->h < q->h) return 1; return (p->w > q->w) ? -1 : (p->w < q->w); } static int rect_original_order(const void *a, const void *b) { const stbrp_rect *p = (const stbrp_rect *) a; const stbrp_rect *q = (const stbrp_rect *) b; return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); } #ifdef STBRP_LARGE_RECTS #define STBRP__MAXVAL 0xffffffff #else #define STBRP__MAXVAL 0xffff #endif STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) { int i, all_rects_packed = 1; // we use the 'was_packed' field internally to allow sorting/unsorting for (i=0; i < num_rects; ++i) { rects[i].was_packed = i; #ifndef STBRP_LARGE_RECTS STBRP_ASSERT(rects[i].w <= 0xffff && rects[i].h <= 0xffff); #endif } // sort according to heuristic STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); for (i=0; i < num_rects; ++i) { if (rects[i].w == 0 || rects[i].h == 0) { rects[i].x = rects[i].y = 0; // empty rect needs no space } else { stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); if (fr.prev_link) { rects[i].x = (stbrp_coord) fr.x; rects[i].y = (stbrp_coord) fr.y; } else { rects[i].x = rects[i].y = STBRP__MAXVAL; } } } // unsort STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); // set was_packed flags and all_rects_packed status for (i=0; i < num_rects; ++i) { rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); if (!rects[i].was_packed) all_rects_packed = 0; } // return the all_rects_packed status return all_rects_packed; } #endif /* ------------------------------------------------------------------------------ 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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_perlin.h0000600000175000001440000003216614003056224016730 0ustar rakusers// stb_perlin.h - v0.3 - perlin noise // public domain single-file C implementation by Sean Barrett // // LICENSE // // See end of file. // // // to create the implementation, // #define STB_PERLIN_IMPLEMENTATION // in *one* C/CPP file that includes this file. // // // Documentation: // // float stb_perlin_noise3( float x, // float y, // float z, // int x_wrap=0, // int y_wrap=0, // int z_wrap=0) // // This function computes a random value at the coordinate (x,y,z). // Adjacent random values are continuous but the noise fluctuates // its randomness with period 1, i.e. takes on wholly unrelated values // at integer points. Specifically, this implements Ken Perlin's // revised noise function from 2002. // // The "wrap" parameters can be used to create wraparound noise that // wraps at powers of two. The numbers MUST be powers of two. Specify // 0 to mean "don't care". (The noise always wraps every 256 due // details of the implementation, even if you ask for larger or no // wrapping.) // // Fractal Noise: // // Three common fractal noise functions are included, which produce // a wide variety of nice effects depending on the parameters // provided. Note that each function will call stb_perlin_noise3 // 'octaves' times, so this parameter will affect runtime. // // float stb_perlin_ridge_noise3(float x, float y, float z, // float lacunarity, float gain, float offset, int octaves, // int x_wrap, int y_wrap, int z_wrap); // // float stb_perlin_fbm_noise3(float x, float y, float z, // float lacunarity, float gain, int octaves, // int x_wrap, int y_wrap, int z_wrap); // // float stb_perlin_turbulence_noise3(float x, float y, float z, // float lacunarity, float gain,int octaves, // int x_wrap, int y_wrap, int z_wrap); // // Typical values to start playing with: // octaves = 6 -- number of "octaves" of noise3() to sum // lacunarity = ~ 2.0 -- spacing between successive octaves (use exactly 2.0 for wrapping output) // gain = 0.5 -- relative weighting applied to each successive octave // offset = 1.0? -- used to invert the ridges, may need to be larger, not sure // // // Contributors: // Jack Mott - additional noise functions // #ifdef __cplusplus extern "C" { #endif extern float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap); extern float stb_perlin_ridge_noise3(float x, float y, float z,float lacunarity, float gain, float offset, int octaves,int x_wrap, int y_wrap, int z_wrap); extern float stb_perlin_fbm_noise3(float x, float y, float z,float lacunarity, float gain, int octaves,int x_wrap, int y_wrap, int z_wrap); extern float stb_perlin_turbulence_noise3(float x, float y, float z, float lacunarity, float gain, int octaves,int x_wrap, int y_wrap, int z_wrap); #ifdef __cplusplus } #endif #ifdef STB_PERLIN_IMPLEMENTATION // not same permutation table as Perlin's reference to avoid copyright issues; // Perlin's table can be found at http://mrl.nyu.edu/~perlin/noise/ // @OPTIMIZE: should this be unsigned char instead of int for cache? static unsigned char stb__perlin_randtab[512] = { 23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123, 152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72, 175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240, 8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57, 225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233, 94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172, 165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243, 65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122, 26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76, 250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246, 132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3, 91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231, 38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221, 131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62, 27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135, 61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5, // and a second copy so we don't need an extra mask or static initializer 23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123, 152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72, 175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240, 8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57, 225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233, 94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172, 165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243, 65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122, 26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76, 250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246, 132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3, 91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231, 38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221, 131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62, 27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135, 61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5, }; static float stb__perlin_lerp(float a, float b, float t) { return a + (b-a) * t; } static int stb__perlin_fastfloor(float a) { int ai = (int) a; return (a < ai) ? ai-1 : ai; } // different grad function from Perlin's, but easy to modify to match reference static float stb__perlin_grad(int hash, float x, float y, float z) { static float basis[12][4] = { { 1, 1, 0 }, { -1, 1, 0 }, { 1,-1, 0 }, { -1,-1, 0 }, { 1, 0, 1 }, { -1, 0, 1 }, { 1, 0,-1 }, { -1, 0,-1 }, { 0, 1, 1 }, { 0,-1, 1 }, { 0, 1,-1 }, { 0,-1,-1 }, }; // perlin's gradient has 12 cases so some get used 1/16th of the time // and some 2/16ths. We reduce bias by changing those fractions // to 5/64ths and 6/64ths, and the same 4 cases get the extra weight. static unsigned char indices[64] = { 0,1,2,3,4,5,6,7,8,9,10,11, 0,9,1,11, 0,1,2,3,4,5,6,7,8,9,10,11, 0,1,2,3,4,5,6,7,8,9,10,11, 0,1,2,3,4,5,6,7,8,9,10,11, 0,1,2,3,4,5,6,7,8,9,10,11, }; // if you use reference permutation table, change 63 below to 15 to match reference // (this is why the ordering of the table above is funky) float *grad = basis[indices[hash & 63]]; return grad[0]*x + grad[1]*y + grad[2]*z; } float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap) { float u,v,w; float n000,n001,n010,n011,n100,n101,n110,n111; float n00,n01,n10,n11; float n0,n1; unsigned int x_mask = (x_wrap-1) & 255; unsigned int y_mask = (y_wrap-1) & 255; unsigned int z_mask = (z_wrap-1) & 255; int px = stb__perlin_fastfloor(x); int py = stb__perlin_fastfloor(y); int pz = stb__perlin_fastfloor(z); int x0 = px & x_mask, x1 = (px+1) & x_mask; int y0 = py & y_mask, y1 = (py+1) & y_mask; int z0 = pz & z_mask, z1 = (pz+1) & z_mask; int r0,r1, r00,r01,r10,r11; #define stb__perlin_ease(a) (((a*6-15)*a + 10) * a * a * a) x -= px; u = stb__perlin_ease(x); y -= py; v = stb__perlin_ease(y); z -= pz; w = stb__perlin_ease(z); r0 = stb__perlin_randtab[x0]; r1 = stb__perlin_randtab[x1]; r00 = stb__perlin_randtab[r0+y0]; r01 = stb__perlin_randtab[r0+y1]; r10 = stb__perlin_randtab[r1+y0]; r11 = stb__perlin_randtab[r1+y1]; n000 = stb__perlin_grad(stb__perlin_randtab[r00+z0], x , y , z ); n001 = stb__perlin_grad(stb__perlin_randtab[r00+z1], x , y , z-1 ); n010 = stb__perlin_grad(stb__perlin_randtab[r01+z0], x , y-1, z ); n011 = stb__perlin_grad(stb__perlin_randtab[r01+z1], x , y-1, z-1 ); n100 = stb__perlin_grad(stb__perlin_randtab[r10+z0], x-1, y , z ); n101 = stb__perlin_grad(stb__perlin_randtab[r10+z1], x-1, y , z-1 ); n110 = stb__perlin_grad(stb__perlin_randtab[r11+z0], x-1, y-1, z ); n111 = stb__perlin_grad(stb__perlin_randtab[r11+z1], x-1, y-1, z-1 ); n00 = stb__perlin_lerp(n000,n001,w); n01 = stb__perlin_lerp(n010,n011,w); n10 = stb__perlin_lerp(n100,n101,w); n11 = stb__perlin_lerp(n110,n111,w); n0 = stb__perlin_lerp(n00,n01,v); n1 = stb__perlin_lerp(n10,n11,v); return stb__perlin_lerp(n0,n1,u); } float stb_perlin_ridge_noise3(float x, float y, float z,float lacunarity, float gain, float offset, int octaves,int x_wrap, int y_wrap, int z_wrap) { int i; float frequency = 1.0f; float prev = 1.0f; float amplitude = 0.5f; float sum = 0.0f; for (i = 0; i < octaves; i++) { float r = (float)(stb_perlin_noise3(x*frequency,y*frequency,z*frequency,x_wrap,y_wrap,z_wrap)); r = r<0 ? -r : r; // fabs() r = offset - r; r = r*r; sum += r*amplitude*prev; prev = r; frequency *= lacunarity; amplitude *= gain; } return sum; } float stb_perlin_fbm_noise3(float x, float y, float z,float lacunarity, float gain, int octaves,int x_wrap, int y_wrap, int z_wrap) { int i; float frequency = 1.0f; float amplitude = 1.0f; float sum = 0.0f; for (i = 0; i < octaves; i++) { sum += stb_perlin_noise3(x*frequency,y*frequency,z*frequency,x_wrap,y_wrap,z_wrap)*amplitude; frequency *= lacunarity; amplitude *= gain; } return sum; } float stb_perlin_turbulence_noise3(float x, float y, float z, float lacunarity, float gain, int octaves,int x_wrap, int y_wrap, int z_wrap) { int i; float frequency = 1.0f; float amplitude = 1.0f; float sum = 0.0f; for (i = 0; i < octaves; i++) { float r = stb_perlin_noise3(x*frequency,y*frequency,z*frequency,x_wrap,y_wrap,z_wrap)*amplitude; r = r<0 ? -r : r; // fabs() sum += r; frequency *= lacunarity; amplitude *= gain; } return sum; } #endif // STB_PERLIN_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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_leakcheck.h0000600000175000001440000001550014003056224017342 0ustar rakusers// stb_leakcheck.h - v0.4 - quick & dirty malloc leak-checking - public domain // LICENSE // // See end of file. #ifdef STB_LEAKCHECK_IMPLEMENTATION #undef STB_LEAKCHECK_IMPLEMENTATION // don't implement more than once // if we've already included leakcheck before, undefine the macros #ifdef malloc #undef malloc #undef free #undef realloc #endif #include #include #include #include #include typedef struct malloc_info stb_leakcheck_malloc_info; struct malloc_info { const char *file; int line; size_t size; stb_leakcheck_malloc_info *next,*prev; }; static stb_leakcheck_malloc_info *mi_head; void *stb_leakcheck_malloc(size_t sz, const char *file, int line) { stb_leakcheck_malloc_info *mi = (stb_leakcheck_malloc_info *) malloc(sz + sizeof(*mi)); if (mi == NULL) return mi; mi->file = file; mi->line = line; mi->next = mi_head; if (mi_head) mi->next->prev = mi; mi->prev = NULL; mi->size = (int) sz; mi_head = mi; return mi+1; } void stb_leakcheck_free(void *ptr) { if (ptr != NULL) { stb_leakcheck_malloc_info *mi = (stb_leakcheck_malloc_info *) ptr - 1; mi->size = ~mi->size; #ifndef STB_LEAKCHECK_SHOWALL if (mi->prev == NULL) { assert(mi_head == mi); mi_head = mi->next; } else mi->prev->next = mi->next; if (mi->next) mi->next->prev = mi->prev; #endif free(mi); } } void *stb_leakcheck_realloc(void *ptr, size_t sz, const char *file, int line) { if (ptr == NULL) { return stb_leakcheck_malloc(sz, file, line); } else if (sz == 0) { stb_leakcheck_free(ptr); return NULL; } else { stb_leakcheck_malloc_info *mi = (stb_leakcheck_malloc_info *) ptr - 1; if (sz <= mi->size) return ptr; else { #ifdef STB_LEAKCHECK_REALLOC_PRESERVE_MALLOC_FILELINE void *q = stb_leakcheck_malloc(sz, mi->file, mi->line); #else void *q = stb_leakcheck_malloc(sz, file, line); #endif if (q) { memcpy(q, ptr, mi->size); stb_leakcheck_free(ptr); } return q; } } } static void stblkck_internal_print(const char *reason, const char *file, int line, size_t size, void *ptr) { #if (defined(_MSC_VER) && _MSC_VER < 1900) /* 1900=VS 2015 */ || defined(__MINGW32__) // Compilers that use the old MS C runtime library don't have %zd // and the older ones don't even have %lld either... however, the old compilers // without "long long" don't support 64-bit targets either, so here's the // compromise: #if defined(_MSC_VER) && _MSC_VER < 1400 // before VS 2005 printf("%-6s: %s (%4d): %8d bytes at %p\n", reason, file, line, (int)size, ptr); #else printf("%-6s: %s (%4d): %8lld bytes at %p\n", reason, file, line, (long long)size, ptr); #endif #else // Assume we have %zd on other targets. printf("%-6s: %s (%4d): %zd bytes at %p\n", reason, file, line, size, ptr); #endif } void stb_leakcheck_dumpmem(void) { stb_leakcheck_malloc_info *mi = mi_head; while (mi) { if ((ptrdiff_t) mi->size >= 0) stblkck_internal_print("LEAKED", mi->file, mi->line, mi->size, mi+1); printf("LEAKED: %s (%4d): %8d bytes at %p\n", mi->file, mi->line, (int) mi->size, mi+1); mi = mi->next; } #ifdef STB_LEAKCHECK_SHOWALL mi = mi_head; while (mi) { if ((ptrdiff_t) mi->size < 0) stblkck_internal_print("FREED", mi->file, mi->line, ~mi->size, mi+1); printf("FREED : %s (%4d): %8d bytes at %p\n", mi->file, mi->line, (int) ~mi->size, mi+1); mi = mi->next; } #endif } #endif // STB_LEAKCHECK_IMPLEMENTATION #ifndef INCLUDE_STB_LEAKCHECK_H #define INCLUDE_STB_LEAKCHECK_H #define malloc(sz) stb_leakcheck_malloc(sz, __FILE__, __LINE__) #define free(p) stb_leakcheck_free(p) #define realloc(p,sz) stb_leakcheck_realloc(p,sz, __FILE__, __LINE__) extern void * stb_leakcheck_malloc(size_t sz, const char *file, int line); extern void * stb_leakcheck_realloc(void *ptr, size_t sz, const char *file, int line); extern void stb_leakcheck_free(void *ptr); extern void stb_leakcheck_dumpmem(void); #endif // INCLUDE_STB_LEAKCHECK_H /* ------------------------------------------------------------------------------ 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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_image_write.h0000600000175000001440000016521014003056224017730 0ustar rakusers/* stb_image_write - v1.07 - public domain - http://nothings.org/stb/stb_image_write.h writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015 no warranty implied; use at your own risk Before #including, #define STB_IMAGE_WRITE_IMPLEMENTATION in the file that you want to have the implementation. Will probably not work correctly with strict-aliasing optimizations. ABOUT: This header file is a library for writing images to C stdio. It could be adapted to write to memory or a general streaming interface; let me know. The PNG output is not optimal; it is 20-50% larger than the file written by a decent optimizing implementation. This library is designed for source code compactness and simplicity, not optimal image file size or run-time performance. BUILDING: You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h. You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace malloc,realloc,free. You can define STBIW_MEMMOVE() to replace memmove() USAGE: There are four functions, one for each image file format: int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); int stbi_write_jpg(char const *filename, int w, int h, int comp, const float *data); There are also four equivalent functions that use an arbitrary write function. You are expected to open/close your file-equivalent before and after calling these: int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); where the callback is: void stbi_write_func(void *context, void *data, int size); You can define STBI_WRITE_NO_STDIO to disable the file variant of these functions, so the library will not use stdio.h at all. However, this will also disable HDR writing, because it requires stdio for formatted output. Each function returns 0 on failure and non-0 on success. The functions create an image file defined by the parameters. The image is a rectangle of pixels stored from left-to-right, top-to-bottom. Each pixel contains 'comp' channels of data stored interleaved with 8-bits per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall. The *data pointer points to the first byte of the top-left-most pixel. For PNG, "stride_in_bytes" is the distance in bytes from the first byte of a row of pixels to the first byte of the next row of pixels. PNG creates output files with the same number of components as the input. The BMP format expands Y to RGB in the file format and does not output alpha. PNG supports writing rectangles of data even when the bytes storing rows of data are not consecutive in memory (e.g. sub-rectangles of a larger image), by supplying the stride between the beginning of adjacent rows. The other formats do not. (Thus you cannot write a native-format BMP through the BMP writer, both because it is in BGR order and because it may have padding at the end of the line.) HDR expects linear float data. Since the format is always 32-bit rgb(e) data, alpha (if provided) is discarded, and for monochrome data it is replicated across all three channels. TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed data, set the global variable 'stbi_write_tga_with_rle' to 0. JPEG does ignore alpha channels in input data; quality is between 1 and 100. Higher quality looks better but results in a bigger image. JPEG baseline (no JPEG progressive). CREDITS: PNG/BMP/TGA Sean Barrett HDR Baldur Karlsson TGA monochrome: Jean-Sebastien Guay misc enhancements: Tim Kelsey TGA RLE Alan Hickman initial file IO callback implementation Emmanuel Julien JPEG Jon Olick (original jo_jpeg.cpp code) Daniel Gibson bugfixes: github:Chribba Guillaume Chereau github:jry2 github:romigrou Sergio Gonzalez Jonas Karlsson Filip Wasil Thatcher Ulrich github:poppolopoppo Patrick Boettcher LICENSE See end of file for license information. */ #ifndef INCLUDE_STB_IMAGE_WRITE_H #define INCLUDE_STB_IMAGE_WRITE_H #ifdef __cplusplus extern "C" { #endif #ifdef STB_IMAGE_WRITE_STATIC #define STBIWDEF static #else #define STBIWDEF extern extern int stbi_write_tga_with_rle; #endif #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality); #endif typedef void stbi_write_func(void *context, void *data, int size); STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); #ifdef __cplusplus } #endif #endif//INCLUDE_STB_IMAGE_WRITE_H #ifdef STB_IMAGE_WRITE_IMPLEMENTATION #ifdef _WIN32 #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif #ifndef _CRT_NONSTDC_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE #endif #endif #ifndef STBI_WRITE_NO_STDIO #include #endif // STBI_WRITE_NO_STDIO #include #include #include #include #if defined(STBIW_MALLOC) && defined(STBIW_FREE) && (defined(STBIW_REALLOC) || defined(STBIW_REALLOC_SIZED)) // ok #elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) && !defined(STBIW_REALLOC_SIZED) // ok #else #error "Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED)." #endif #ifndef STBIW_MALLOC #define STBIW_MALLOC(sz) malloc(sz) #define STBIW_REALLOC(p,newsz) realloc(p,newsz) #define STBIW_FREE(p) free(p) #endif #ifndef STBIW_REALLOC_SIZED #define STBIW_REALLOC_SIZED(p,oldsz,newsz) STBIW_REALLOC(p,newsz) #endif #ifndef STBIW_MEMMOVE #define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz) #endif #ifndef STBIW_ASSERT #include #define STBIW_ASSERT(x) assert(x) #endif #define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff) typedef struct { stbi_write_func *func; void *context; } stbi__write_context; // initialize a callback-based context static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context) { s->func = c; s->context = context; } #ifndef STBI_WRITE_NO_STDIO static void stbi__stdio_write(void *context, void *data, int size) { fwrite(data,1,size,(FILE*) context); } static int stbi__start_write_file(stbi__write_context *s, const char *filename) { FILE *f = fopen(filename, "wb"); stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f); return f != NULL; } static void stbi__end_write_file(stbi__write_context *s) { fclose((FILE *)s->context); } #endif // !STBI_WRITE_NO_STDIO typedef unsigned int stbiw_uint32; typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1]; #ifdef STB_IMAGE_WRITE_STATIC static int stbi_write_tga_with_rle = 1; #else int stbi_write_tga_with_rle = 1; #endif static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v) { while (*fmt) { switch (*fmt++) { case ' ': break; case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int)); s->func(s->context,&x,1); break; } case '2': { int x = va_arg(v,int); unsigned char b[2]; b[0] = STBIW_UCHAR(x); b[1] = STBIW_UCHAR(x>>8); s->func(s->context,b,2); break; } case '4': { stbiw_uint32 x = va_arg(v,int); unsigned char b[4]; b[0]=STBIW_UCHAR(x); b[1]=STBIW_UCHAR(x>>8); b[2]=STBIW_UCHAR(x>>16); b[3]=STBIW_UCHAR(x>>24); s->func(s->context,b,4); break; } default: STBIW_ASSERT(0); return; } } } static void stbiw__writef(stbi__write_context *s, const char *fmt, ...) { va_list v; va_start(v, fmt); stbiw__writefv(s, fmt, v); va_end(v); } static void stbiw__putc(stbi__write_context *s, unsigned char c) { s->func(s->context, &c, 1); } static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c) { unsigned char arr[3]; arr[0] = a, arr[1] = b, arr[2] = c; s->func(s->context, arr, 3); } static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d) { unsigned char bg[3] = { 255, 0, 255}, px[3]; int k; if (write_alpha < 0) s->func(s->context, &d[comp - 1], 1); switch (comp) { case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case case 1: if (expand_mono) stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp else s->func(s->context, d, 1); // monochrome TGA break; case 4: if (!write_alpha) { // composite against pink background for (k = 0; k < 3; ++k) px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255; stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]); break; } /* FALLTHROUGH */ case 3: stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]); break; } if (write_alpha > 0) s->func(s->context, &d[comp - 1], 1); } static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono) { stbiw_uint32 zero = 0; int i,j, j_end; if (y <= 0) return; if (vdir < 0) j_end = -1, j = y-1; else j_end = y, j = 0; for (; j != j_end; j += vdir) { for (i=0; i < x; ++i) { unsigned char *d = (unsigned char *) data + (j*x+i)*comp; stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d); } s->func(s->context, &zero, scanline_pad); } } static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...) { if (y < 0 || x < 0) { return 0; } else { va_list v; va_start(v, fmt); stbiw__writefv(s, fmt, v); va_end(v); stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono); return 1; } } static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data) { int pad = (-x*3) & 3; return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, "11 4 22 4" "4 44 22 444444", 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header } STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_bmp_core(&s, x, y, comp, data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_bmp_core(&s, x, y, comp, data); stbi__end_write_file(&s); return r; } else return 0; } #endif //!STBI_WRITE_NO_STDIO static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data) { int has_alpha = (comp == 2 || comp == 4); int colorbytes = has_alpha ? comp-1 : comp; int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3 if (y < 0 || x < 0) return 0; if (!stbi_write_tga_with_rle) { return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0, "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8); } else { int i,j,k; stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8); for (j = y - 1; j >= 0; --j) { unsigned char *row = (unsigned char *) data + j * x * comp; int len; for (i = 0; i < x; i += len) { unsigned char *begin = row + i * comp; int diff = 1; len = 1; if (i < x - 1) { ++len; diff = memcmp(begin, row + (i + 1) * comp, comp); if (diff) { const unsigned char *prev = begin; for (k = i + 2; k < x && len < 128; ++k) { if (memcmp(prev, row + k * comp, comp)) { prev += comp; ++len; } else { --len; break; } } } else { for (k = i + 2; k < x && len < 128; ++k) { if (!memcmp(begin, row + k * comp, comp)) { ++len; } else { break; } } } } if (diff) { unsigned char header = STBIW_UCHAR(len - 1); s->func(s->context, &header, 1); for (k = 0; k < len; ++k) { stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp); } } else { unsigned char header = STBIW_UCHAR(len - 129); s->func(s->context, &header, 1); stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin); } } } } return 1; } STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_tga_core(&s, x, y, comp, (void *) data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_tga_core(&s, x, y, comp, (void *) data); stbi__end_write_file(&s); return r; } else return 0; } #endif // ************************************************************************************************* // Radiance RGBE HDR writer // by Baldur Karlsson #define stbiw__max(a, b) ((a) > (b) ? (a) : (b)) void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) { int exponent; float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2])); if (maxcomp < 1e-32f) { rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0; } else { float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp; rgbe[0] = (unsigned char)(linear[0] * normalize); rgbe[1] = (unsigned char)(linear[1] * normalize); rgbe[2] = (unsigned char)(linear[2] * normalize); rgbe[3] = (unsigned char)(exponent + 128); } } void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte) { unsigned char lengthbyte = STBIW_UCHAR(length+128); STBIW_ASSERT(length+128 <= 255); s->func(s->context, &lengthbyte, 1); s->func(s->context, &databyte, 1); } void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data) { unsigned char lengthbyte = STBIW_UCHAR(length); STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code s->func(s->context, &lengthbyte, 1); s->func(s->context, data, length); } void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline) { unsigned char scanlineheader[4] = { 2, 2, 0, 0 }; unsigned char rgbe[4]; float linear[3]; int x; scanlineheader[2] = (width&0xff00)>>8; scanlineheader[3] = (width&0x00ff); /* skip RLE for images too small or large */ if (width < 8 || width >= 32768) { for (x=0; x < width; x++) { switch (ncomp) { case 4: /* fallthrough */ case 3: linear[2] = scanline[x*ncomp + 2]; linear[1] = scanline[x*ncomp + 1]; linear[0] = scanline[x*ncomp + 0]; break; default: linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; break; } stbiw__linear_to_rgbe(rgbe, linear); s->func(s->context, rgbe, 4); } } else { int c,r; /* encode into scratch buffer */ for (x=0; x < width; x++) { switch(ncomp) { case 4: /* fallthrough */ case 3: linear[2] = scanline[x*ncomp + 2]; linear[1] = scanline[x*ncomp + 1]; linear[0] = scanline[x*ncomp + 0]; break; default: linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; break; } stbiw__linear_to_rgbe(rgbe, linear); scratch[x + width*0] = rgbe[0]; scratch[x + width*1] = rgbe[1]; scratch[x + width*2] = rgbe[2]; scratch[x + width*3] = rgbe[3]; } s->func(s->context, scanlineheader, 4); /* RLE each component separately */ for (c=0; c < 4; c++) { unsigned char *comp = &scratch[width*c]; x = 0; while (x < width) { // find first run r = x; while (r+2 < width) { if (comp[r] == comp[r+1] && comp[r] == comp[r+2]) break; ++r; } if (r+2 >= width) r = width; // dump up to first run while (x < r) { int len = r-x; if (len > 128) len = 128; stbiw__write_dump_data(s, len, &comp[x]); x += len; } // if there's a run, output it if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd // find next byte after run while (r < width && comp[r] == comp[x]) ++r; // output run up to r while (x < r) { int len = r-x; if (len > 127) len = 127; stbiw__write_run_data(s, len, comp[x]); x += len; } } } } } } static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data) { if (y <= 0 || x <= 0 || data == NULL) return 0; else { // Each component is stored separately. Allocate scratch space for full output scanline. unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4); int i, len; char buffer[128]; char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n"; s->func(s->context, header, sizeof(header)-1); len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); s->func(s->context, buffer, len); for(i=0; i < y; i++) stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*i*x); STBIW_FREE(scratch); return 1; } } STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_hdr_core(&s, x, y, comp, (float *) data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data); stbi__end_write_file(&s); return r; } else return 0; } #endif // STBI_WRITE_NO_STDIO ////////////////////////////////////////////////////////////////////////////// // // PNG writer // // stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size() #define stbiw__sbraw(a) ((int *) (a) - 2) #define stbiw__sbm(a) stbiw__sbraw(a)[0] #define stbiw__sbn(a) stbiw__sbraw(a)[1] #define stbiw__sbneedgrow(a,n) ((a)==0 || stbiw__sbn(a)+n >= stbiw__sbm(a)) #define stbiw__sbmaybegrow(a,n) (stbiw__sbneedgrow(a,(n)) ? stbiw__sbgrow(a,n) : 0) #define stbiw__sbgrow(a,n) stbiw__sbgrowf((void **) &(a), (n), sizeof(*(a))) #define stbiw__sbpush(a, v) (stbiw__sbmaybegrow(a,1), (a)[stbiw__sbn(a)++] = (v)) #define stbiw__sbcount(a) ((a) ? stbiw__sbn(a) : 0) #define stbiw__sbfree(a) ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0) static void *stbiw__sbgrowf(void **arr, int increment, int itemsize) { int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1; void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2); STBIW_ASSERT(p); if (p) { if (!*arr) ((int *) p)[1] = 0; *arr = (void *) ((int *) p + 2); stbiw__sbm(*arr) = m; } return *arr; } static unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount) { while (*bitcount >= 8) { stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer)); *bitbuffer >>= 8; *bitcount -= 8; } return data; } static int stbiw__zlib_bitrev(int code, int codebits) { int res=0; while (codebits--) { res = (res << 1) | (code & 1); code >>= 1; } return res; } static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit) { int i; for (i=0; i < limit && i < 258; ++i) if (a[i] != b[i]) break; return i; } static unsigned int stbiw__zhash(unsigned char *data) { stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16); hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return hash; } #define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount)) #define stbiw__zlib_add(code,codebits) \ (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush()) #define stbiw__zlib_huffa(b,c) stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c) // default huffman tables #define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8) #define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n)-144, 9) #define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n)-256,7) #define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n)-280,8) #define stbiw__zlib_huff(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : (n) <= 255 ? stbiw__zlib_huff2(n) : (n) <= 279 ? stbiw__zlib_huff3(n) : stbiw__zlib_huff4(n)) #define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n)) #define stbiw__ZHASH 16384 unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality) { static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 }; static unsigned char lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 }; static unsigned short distc[] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 }; static unsigned char disteb[] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 }; unsigned int bitbuf=0; int i,j, bitcount=0; unsigned char *out = NULL; unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(char**)); if (quality < 5) quality = 5; stbiw__sbpush(out, 0x78); // DEFLATE 32K window stbiw__sbpush(out, 0x5e); // FLEVEL = 1 stbiw__zlib_add(1,1); // BFINAL = 1 stbiw__zlib_add(1,2); // BTYPE = 1 -- fixed huffman for (i=0; i < stbiw__ZHASH; ++i) hash_table[i] = NULL; i=0; while (i < data_len-3) { // hash next 3 bytes of data to be compressed int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3; unsigned char *bestloc = 0; unsigned char **hlist = hash_table[h]; int n = stbiw__sbcount(hlist); for (j=0; j < n; ++j) { if (hlist[j]-data > i-32768) { // if entry lies within window int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i); if (d >= best) best=d,bestloc=hlist[j]; } } // when hash table entry is too long, delete half the entries if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) { STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality); stbiw__sbn(hash_table[h]) = quality; } stbiw__sbpush(hash_table[h],data+i); if (bestloc) { // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1); hlist = hash_table[h]; n = stbiw__sbcount(hlist); for (j=0; j < n; ++j) { if (hlist[j]-data > i-32767) { int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1); if (e > best) { // if next match is better, bail on current match bestloc = NULL; break; } } } } if (bestloc) { int d = (int) (data+i - bestloc); // distance back STBIW_ASSERT(d <= 32767 && best <= 258); for (j=0; best > lengthc[j+1]-1; ++j); stbiw__zlib_huff(j+257); if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]); for (j=0; d > distc[j+1]-1; ++j); stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5); if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]); i += best; } else { stbiw__zlib_huffb(data[i]); ++i; } } // write out final bytes for (;i < data_len; ++i) stbiw__zlib_huffb(data[i]); stbiw__zlib_huff(256); // end of block // pad with 0 bits to byte boundary while (bitcount) stbiw__zlib_add(0,1); for (i=0; i < stbiw__ZHASH; ++i) (void) stbiw__sbfree(hash_table[i]); STBIW_FREE(hash_table); { // compute adler32 on input unsigned int s1=1, s2=0; int blocklen = (int) (data_len % 5552); j=0; while (j < data_len) { for (i=0; i < blocklen; ++i) s1 += data[j+i], s2 += s1; s1 %= 65521, s2 %= 65521; j += blocklen; blocklen = 5552; } stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8)); stbiw__sbpush(out, STBIW_UCHAR(s2)); stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8)); stbiw__sbpush(out, STBIW_UCHAR(s1)); } *out_len = stbiw__sbn(out); // make returned pointer freeable STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len); return (unsigned char *) stbiw__sbraw(out); } static unsigned int stbiw__crc32(unsigned char *buffer, int len) { static unsigned int crc_table[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D }; unsigned int crc = ~0u; int i; for (i=0; i < len; ++i) crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; return ~crc; } #define stbiw__wpng4(o,a,b,c,d) ((o)[0]=STBIW_UCHAR(a),(o)[1]=STBIW_UCHAR(b),(o)[2]=STBIW_UCHAR(c),(o)[3]=STBIW_UCHAR(d),(o)+=4) #define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v)); #define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3]) static void stbiw__wpcrc(unsigned char **data, int len) { unsigned int crc = stbiw__crc32(*data - len - 4, len+4); stbiw__wp32(*data, crc); } static unsigned char stbiw__paeth(int a, int b, int c) { int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c); if (pa <= pb && pa <= pc) return STBIW_UCHAR(a); if (pb <= pc) return STBIW_UCHAR(b); return STBIW_UCHAR(c); } // @OPTIMIZE: provide an option that always forces left-predict or paeth predict unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len) { int ctype[5] = { -1, 0, 4, 2, 6 }; unsigned char sig[8] = { 137,80,78,71,13,10,26,10 }; unsigned char *out,*o, *filt, *zlib; signed char *line_buffer; int i,j,k,p,zlen; if (stride_bytes == 0) stride_bytes = x * n; filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0; line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; } for (j=0; j < y; ++j) { static int mapping[] = { 0,1,2,3,4 }; static int firstmap[] = { 0,1,0,5,6 }; int *mymap = (j != 0) ? mapping : firstmap; int best = 0, bestval = 0x7fffffff; for (p=0; p < 2; ++p) { for (k= p?best:0; k < 5; ++k) { // @TODO: clarity: rewrite this to go 0..5, and 'continue' the unwanted ones during 2nd pass int type = mymap[k],est=0; unsigned char *z = pixels + stride_bytes*j; for (i=0; i < n; ++i) switch (type) { case 0: line_buffer[i] = z[i]; break; case 1: line_buffer[i] = z[i]; break; case 2: line_buffer[i] = z[i] - z[i-stride_bytes]; break; case 3: line_buffer[i] = z[i] - (z[i-stride_bytes]>>1); break; case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-stride_bytes],0)); break; case 5: line_buffer[i] = z[i]; break; case 6: line_buffer[i] = z[i]; break; } for (i=n; i < x*n; ++i) { switch (type) { case 0: line_buffer[i] = z[i]; break; case 1: line_buffer[i] = z[i] - z[i-n]; break; case 2: line_buffer[i] = z[i] - z[i-stride_bytes]; break; case 3: line_buffer[i] = z[i] - ((z[i-n] + z[i-stride_bytes])>>1); break; case 4: line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-stride_bytes], z[i-stride_bytes-n]); break; case 5: line_buffer[i] = z[i] - (z[i-n]>>1); break; case 6: line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break; } } if (p) break; for (i=0; i < x*n; ++i) est += abs((signed char) line_buffer[i]); if (est < bestval) { bestval = est; best = k; } } } // when we get here, best contains the filter type, and line_buffer contains the data filt[j*(x*n+1)] = (unsigned char) best; STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n); } STBIW_FREE(line_buffer); zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, 8); // increase 8 to get smaller but use more memory STBIW_FREE(filt); if (!zlib) return 0; // each tag requires 12 bytes of overhead out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12); if (!out) return 0; *out_len = 8 + 12+13 + 12+zlen + 12; o=out; STBIW_MEMMOVE(o,sig,8); o+= 8; stbiw__wp32(o, 13); // header length stbiw__wptag(o, "IHDR"); stbiw__wp32(o, x); stbiw__wp32(o, y); *o++ = 8; *o++ = STBIW_UCHAR(ctype[n]); *o++ = 0; *o++ = 0; *o++ = 0; stbiw__wpcrc(&o,13); stbiw__wp32(o, zlen); stbiw__wptag(o, "IDAT"); STBIW_MEMMOVE(o, zlib, zlen); o += zlen; STBIW_FREE(zlib); stbiw__wpcrc(&o, zlen); stbiw__wp32(o,0); stbiw__wptag(o, "IEND"); stbiw__wpcrc(&o,0); STBIW_ASSERT(o == out + *out_len); return out; } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes) { FILE *f; int len; unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len); if (png == NULL) return 0; f = fopen(filename, "wb"); if (!f) { STBIW_FREE(png); return 0; } fwrite(png, 1, len, f); fclose(f); STBIW_FREE(png); return 1; } #endif STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes) { int len; unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len); if (png == NULL) return 0; func(context, png, len); STBIW_FREE(png); return 1; } /* *************************************************************************** * * JPEG writer * * This is based on Jon Olick's jo_jpeg.cpp: * public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html */ static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18, 24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 }; static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) { int bitBuf = *bitBufP, bitCnt = *bitCntP; bitCnt += bs[1]; bitBuf |= bs[0] << (24 - bitCnt); while(bitCnt >= 8) { unsigned char c = (bitBuf >> 16) & 255; stbiw__putc(s, c); if(c == 255) { stbiw__putc(s, 0); } bitBuf <<= 8; bitCnt -= 8; } *bitBufP = bitBuf; *bitCntP = bitCnt; } static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p) { float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p; float z1, z2, z3, z4, z5, z11, z13; float tmp0 = d0 + d7; float tmp7 = d0 - d7; float tmp1 = d1 + d6; float tmp6 = d1 - d6; float tmp2 = d2 + d5; float tmp5 = d2 - d5; float tmp3 = d3 + d4; float tmp4 = d3 - d4; // Even part float tmp10 = tmp0 + tmp3; // phase 2 float tmp13 = tmp0 - tmp3; float tmp11 = tmp1 + tmp2; float tmp12 = tmp1 - tmp2; d0 = tmp10 + tmp11; // phase 3 d4 = tmp10 - tmp11; z1 = (tmp12 + tmp13) * 0.707106781f; // c4 d2 = tmp13 + z1; // phase 5 d6 = tmp13 - z1; // Odd part tmp10 = tmp4 + tmp5; // phase 2 tmp11 = tmp5 + tmp6; tmp12 = tmp6 + tmp7; // The rotator is modified from fig 4-8 to avoid extra negations. z5 = (tmp10 - tmp12) * 0.382683433f; // c6 z2 = tmp10 * 0.541196100f + z5; // c2-c6 z4 = tmp12 * 1.306562965f + z5; // c2+c6 z3 = tmp11 * 0.707106781f; // c4 z11 = tmp7 + z3; // phase 5 z13 = tmp7 - z3; *d5p = z13 + z2; // phase 6 *d3p = z13 - z2; *d1p = z11 + z4; *d7p = z11 - z4; *d0p = d0; *d2p = d2; *d4p = d4; *d6p = d6; } static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) { int tmp1 = val < 0 ? -val : val; val = val < 0 ? val-1 : val; bits[1] = 1; while(tmp1 >>= 1) { ++bits[1]; } bits[0] = val & ((1<0)&&(DU[end0pos]==0); --end0pos) { } // end0pos = first element in reverse order !=0 if(end0pos == 0) { stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); return DU[0]; } for(i = 1; i <= end0pos; ++i) { int startpos = i; int nrzeroes; unsigned short bits[2]; for (; DU[i]==0 && i<=end0pos; ++i) { } nrzeroes = i-startpos; if ( nrzeroes >= 16 ) { int lng = nrzeroes>>4; int nrmarker; for (nrmarker=1; nrmarker <= lng; ++nrmarker) stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes); nrzeroes &= 15; } stbiw__jpg_calcBits(DU[i], bits); stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]); stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); } if(end0pos != 63) { stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); } return DU[0]; } static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) { // Constants that don't pollute global namespace static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0}; static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d}; static const unsigned char std_ac_luminance_values[] = { 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08, 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28, 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59, 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89, 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6, 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2, 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa }; static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0}; static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77}; static const unsigned char std_ac_chrominance_values[] = { 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91, 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26, 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58, 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87, 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4, 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda, 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa }; // Huffman tables static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}}; static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}}; static const unsigned short YAC_HT[256][2] = { {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0}, {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} }; static const unsigned short UVAC_HT[256][2] = { {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0}, {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} }; static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22, 37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99}; static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}; static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f, 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f }; int row, col, i, k; float fdtbl_Y[64], fdtbl_UV[64]; unsigned char YTable[64], UVTable[64]; if(!data || !width || !height || comp > 4 || comp < 1) { return 0; } quality = quality ? quality : 90; quality = quality < 1 ? 1 : quality > 100 ? 100 : quality; quality = quality < 50 ? 5000 / quality : 200 - quality * 2; for(i = 0; i < 64; ++i) { int uvti, yti = (YQT[i]*quality+50)/100; YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti); uvti = (UVQT[i]*quality+50)/100; UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti); } for(row = 0, k = 0; row < 8; ++row) { for(col = 0; col < 8; ++col, ++k) { fdtbl_Y[k] = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); } } // Write Headers { static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 }; static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 }; const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width), 3,1,0x11,0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 }; s->func(s->context, (void*)head0, sizeof(head0)); s->func(s->context, (void*)YTable, sizeof(YTable)); stbiw__putc(s, 1); s->func(s->context, UVTable, sizeof(UVTable)); s->func(s->context, (void*)head1, sizeof(head1)); s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1); s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values)); stbiw__putc(s, 0x10); // HTYACinfo s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1); s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values)); stbiw__putc(s, 1); // HTUDCinfo s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1); s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values)); stbiw__putc(s, 0x11); // HTUACinfo s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1); s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values)); s->func(s->context, (void*)head2, sizeof(head2)); } // Encode 8x8 macroblocks { static const unsigned short fillBits[] = {0x7F, 7}; const unsigned char *imageData = (const unsigned char *)data; int DCY=0, DCU=0, DCV=0; int bitBuf=0, bitCnt=0; // comp == 2 is grey+alpha (alpha is ignored) int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0; int x, y, pos; for(y = 0; y < height; y += 8) { for(x = 0; x < width; x += 8) { float YDU[64], UDU[64], VDU[64]; for(row = y, pos = 0; row < y+8; ++row) { for(col = x; col < x+8; ++col, ++pos) { int p = row*width*comp + col*comp; float r, g, b; if(row >= height) { p -= width*comp*(row+1 - height); } if(col >= width) { p -= comp*(col+1 - width); } r = imageData[p+0]; g = imageData[p+ofsG]; b = imageData[p+ofsB]; YDU[pos]=+0.29900f*r+0.58700f*g+0.11400f*b-128; UDU[pos]=-0.16874f*r-0.33126f*g+0.50000f*b; VDU[pos]=+0.50000f*r-0.41869f*g-0.08131f*b; } } DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); } } // Do the bit alignment of the EOI marker stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits); } // EOI stbiw__putc(s, 0xFF); stbiw__putc(s, 0xD9); return 1; } STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_jpg_core(&s, x, y, comp, data, quality); stbi__end_write_file(&s); return r; } else return 0; } #endif #endif // STB_IMAGE_WRITE_IMPLEMENTATION /* Revision history 1.07 (2017-07-24) doc fix 1.06 (2017-07-23) writing JPEG (using Jon Olick's code) 1.05 ??? 1.04 (2017-03-03) monochrome BMP expansion 1.03 ??? 1.02 (2016-04-02) avoid allocating large structures on the stack 1.01 (2016-01-16) STBIW_REALLOC_SIZED: support allocators with no realloc support avoid race-condition in crc initialization minor compile issues 1.00 (2015-09-14) installable file IO function 0.99 (2015-09-13) warning fixes; TGA rle support 0.98 (2015-04-08) added STBIW_MALLOC, STBIW_ASSERT etc 0.97 (2015-01-18) fixed HDR asserts, rewrote HDR rle logic 0.96 (2015-01-17) add HDR output fix monochrome BMP 0.95 (2014-08-17) add monochrome TGA output 0.94 (2014-05-31) rename private functions to avoid conflicts with stb_image.h 0.93 (2014-05-27) warning fixes 0.92 (2010-08-01) casts to unsigned char to fix warnings 0.91 (2010-07-17) first public release 0.90 first internal 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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_image_resize.h0000600000175000001440000034243714003056224020107 0ustar rakusers/* stb_image_resize - v0.95 - public domain image resizing by Jorge L Rodriguez (@VinoBS) - 2014 http://github.com/nothings/stb Written with emphasis on usability, portability, and efficiency. (No SIMD or threads, so it be easily outperformed by libs that use those.) Only scaling and translation is supported, no rotations or shears. Easy API downsamples w/Mitchell filter, upsamples w/cubic interpolation. COMPILING & LINKING In one C/C++ file that #includes this file, do this: #define STB_IMAGE_RESIZE_IMPLEMENTATION before the #include. That will create the implementation in that file. QUICKSTART stbir_resize_uint8( input_pixels , in_w , in_h , 0, output_pixels, out_w, out_h, 0, num_channels) stbir_resize_float(...) stbir_resize_uint8_srgb( input_pixels , in_w , in_h , 0, output_pixels, out_w, out_h, 0, num_channels , alpha_chan , 0) stbir_resize_uint8_srgb_edgemode( input_pixels , in_w , in_h , 0, output_pixels, out_w, out_h, 0, num_channels , alpha_chan , 0, STBIR_EDGE_CLAMP) // WRAP/REFLECT/ZERO FULL API See the "header file" section of the source for API documentation. ADDITIONAL DOCUMENTATION SRGB & FLOATING POINT REPRESENTATION The sRGB functions presume IEEE floating point. If you do not have IEEE floating point, define STBIR_NON_IEEE_FLOAT. This will use a slower implementation. MEMORY ALLOCATION The resize functions here perform a single memory allocation using malloc. To control the memory allocation, before the #include that triggers the implementation, do: #define STBIR_MALLOC(size,context) ... #define STBIR_FREE(ptr,context) ... Each resize function makes exactly one call to malloc/free, so to use temp memory, store the temp memory in the context and return that. ASSERT Define STBIR_ASSERT(boolval) to override assert() and not use assert.h OPTIMIZATION Define STBIR_SATURATE_INT to compute clamp values in-range using integer operations instead of float operations. This may be faster on some platforms. DEFAULT FILTERS For functions which don't provide explicit control over what filters to use, you can change the compile-time defaults with #define STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_something #define STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_something See stbir_filter in the header-file section for the list of filters. NEW FILTERS A number of 1D filter kernels are used. For a list of supported filters see the stbir_filter enum. To add a new filter, write a filter function and add it to stbir__filter_info_table. PROGRESS For interactive use with slow resize operations, you can install a progress-report callback: #define STBIR_PROGRESS_REPORT(val) some_func(val) The parameter val is a float which goes from 0 to 1 as progress is made. For example: static void my_progress_report(float progress); #define STBIR_PROGRESS_REPORT(val) my_progress_report(val) #define STB_IMAGE_RESIZE_IMPLEMENTATION #include "stb_image_resize.h" static void my_progress_report(float progress) { printf("Progress: %f%%\n", progress*100); } MAX CHANNELS If your image has more than 64 channels, define STBIR_MAX_CHANNELS to the max you'll have. ALPHA CHANNEL Most of the resizing functions provide the ability to control how the alpha channel of an image is processed. The important things to know about this: 1. The best mathematically-behaved version of alpha to use is called "premultiplied alpha", in which the other color channels have had the alpha value multiplied in. If you use premultiplied alpha, linear filtering (such as image resampling done by this library, or performed in texture units on GPUs) does the "right thing". While premultiplied alpha is standard in the movie CGI industry, it is still uncommon in the videogame/real-time world. If you linearly filter non-premultiplied alpha, strange effects occur. (For example, the 50/50 average of 99% transparent bright green and 1% transparent black produces 50% transparent dark green when non-premultiplied, whereas premultiplied it produces 50% transparent near-black. The former introduces green energy that doesn't exist in the source image.) 2. Artists should not edit premultiplied-alpha images; artists want non-premultiplied alpha images. Thus, art tools generally output non-premultiplied alpha images. 3. You will get best results in most cases by converting images to premultiplied alpha before processing them mathematically. 4. If you pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED, the resizer does not do anything special for the alpha channel; it is resampled identically to other channels. This produces the correct results for premultiplied-alpha images, but produces less-than-ideal results for non-premultiplied-alpha images. 5. If you do not pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED, then the resizer weights the contribution of input pixels based on their alpha values, or, equivalently, it multiplies the alpha value into the color channels, resamples, then divides by the resultant alpha value. Input pixels which have alpha=0 do not contribute at all to output pixels unless _all_ of the input pixels affecting that output pixel have alpha=0, in which case the result for that pixel is the same as it would be without STBIR_FLAG_ALPHA_PREMULTIPLIED. However, this is only true for input images in integer formats. For input images in float format, input pixels with alpha=0 have no effect, and output pixels which have alpha=0 will be 0 in all channels. (For float images, you can manually achieve the same result by adding a tiny epsilon value to the alpha channel of every image, and then subtracting or clamping it at the end.) 6. You can suppress the behavior described in #5 and make all-0-alpha pixels have 0 in all channels by #defining STBIR_NO_ALPHA_EPSILON. 7. You can separately control whether the alpha channel is interpreted as linear or affected by the colorspace. By default it is linear; you almost never want to apply the colorspace. (For example, graphics hardware does not apply sRGB conversion to the alpha channel.) CONTRIBUTORS Jorge L Rodriguez: Implementation Sean Barrett: API design, optimizations Aras Pranckevicius: bugfix Nathan Reed: warning fixes REVISIONS 0.95 (2017-07-23) fixed warnings 0.94 (2017-03-18) fixed warnings 0.93 (2017-03-03) fixed bug with certain combinations of heights 0.92 (2017-01-02) fix integer overflow on large (>2GB) images 0.91 (2016-04-02) fix warnings; fix handling of subpixel regions 0.90 (2014-09-17) first released version LICENSE See end of file for license information. TODO Don't decode all of the image data when only processing a partial tile Don't use full-width decode buffers when only processing a partial tile When processing wide images, break processing into tiles so data fits in L1 cache Installable filters? Resize that respects alpha test coverage (Reference code: FloatImage::alphaTestCoverage and FloatImage::scaleAlphaToCoverage: https://code.google.com/p/nvidia-texture-tools/source/browse/trunk/src/nvimage/FloatImage.cpp ) */ #ifndef STBIR_INCLUDE_STB_IMAGE_RESIZE_H #define STBIR_INCLUDE_STB_IMAGE_RESIZE_H #ifdef _MSC_VER typedef unsigned char stbir_uint8; typedef unsigned short stbir_uint16; typedef unsigned int stbir_uint32; #else #include typedef uint8_t stbir_uint8; typedef uint16_t stbir_uint16; typedef uint32_t stbir_uint32; #endif #ifdef STB_IMAGE_RESIZE_STATIC #define STBIRDEF static #else #ifdef __cplusplus #define STBIRDEF extern "C" #else #define STBIRDEF extern #endif #endif ////////////////////////////////////////////////////////////////////////////// // // Easy-to-use API: // // * "input pixels" points to an array of image data with 'num_channels' channels (e.g. RGB=3, RGBA=4) // * input_w is input image width (x-axis), input_h is input image height (y-axis) // * stride is the offset between successive rows of image data in memory, in bytes. you can // specify 0 to mean packed continuously in memory // * alpha channel is treated identically to other channels. // * colorspace is linear or sRGB as specified by function name // * returned result is 1 for success or 0 in case of an error. // #define STBIR_ASSERT() to trigger an assert on parameter validation errors. // * Memory required grows approximately linearly with input and output size, but with // discontinuities at input_w == output_w and input_h == output_h. // * These functions use a "default" resampling filter defined at compile time. To change the filter, // you can change the compile-time defaults by #defining STBIR_DEFAULT_FILTER_UPSAMPLE // and STBIR_DEFAULT_FILTER_DOWNSAMPLE, or you can use the medium-complexity API. STBIRDEF int stbir_resize_uint8( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels); STBIRDEF int stbir_resize_float( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, float *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels); // The following functions interpret image data as gamma-corrected sRGB. // Specify STBIR_ALPHA_CHANNEL_NONE if you have no alpha channel, // or otherwise provide the index of the alpha channel. Flags value // of 0 will probably do the right thing if you're not sure what // the flags mean. #define STBIR_ALPHA_CHANNEL_NONE -1 // Set this flag if your texture has premultiplied alpha. Otherwise, stbir will // use alpha-weighted resampling (effectively premultiplying, resampling, // then unpremultiplying). #define STBIR_FLAG_ALPHA_PREMULTIPLIED (1 << 0) // The specified alpha channel should be handled as gamma-corrected value even // when doing sRGB operations. #define STBIR_FLAG_ALPHA_USES_COLORSPACE (1 << 1) STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags); typedef enum { STBIR_EDGE_CLAMP = 1, STBIR_EDGE_REFLECT = 2, STBIR_EDGE_WRAP = 3, STBIR_EDGE_ZERO = 4, } stbir_edge; // This function adds the ability to specify how requests to sample off the edge of the image are handled. STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode); ////////////////////////////////////////////////////////////////////////////// // // Medium-complexity API // // This extends the easy-to-use API as follows: // // * Alpha-channel can be processed separately // * If alpha_channel is not STBIR_ALPHA_CHANNEL_NONE // * Alpha channel will not be gamma corrected (unless flags&STBIR_FLAG_GAMMA_CORRECT) // * Filters will be weighted by alpha channel (unless flags&STBIR_FLAG_ALPHA_PREMULTIPLIED) // * Filter can be selected explicitly // * uint16 image type // * sRGB colorspace available for all types // * context parameter for passing to STBIR_MALLOC typedef enum { STBIR_FILTER_DEFAULT = 0, // use same filter type that easy-to-use API chooses STBIR_FILTER_BOX = 1, // A trapezoid w/1-pixel wide ramps, same result as box for integer scale ratios STBIR_FILTER_TRIANGLE = 2, // On upsampling, produces same results as bilinear texture filtering STBIR_FILTER_CUBICBSPLINE = 3, // The cubic b-spline (aka Mitchell-Netrevalli with B=1,C=0), gaussian-esque STBIR_FILTER_CATMULLROM = 4, // An interpolating cubic spline STBIR_FILTER_MITCHELL = 5, // Mitchell-Netrevalli filter with B=1/3, C=1/3 } stbir_filter; typedef enum { STBIR_COLORSPACE_LINEAR, STBIR_COLORSPACE_SRGB, STBIR_MAX_COLORSPACES, } stbir_colorspace; // The following functions are all identical except for the type of the image data STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context); STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels , int input_w , int input_h , int input_stride_in_bytes, stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context); STBIRDEF int stbir_resize_float_generic( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, float *output_pixels , int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context); ////////////////////////////////////////////////////////////////////////////// // // Full-complexity API // // This extends the medium API as follows: // // * uint32 image type // * not typesafe // * separate filter types for each axis // * separate edge modes for each axis // * can specify scale explicitly for subpixel correctness // * can specify image source tile using texture coordinates typedef enum { STBIR_TYPE_UINT8 , STBIR_TYPE_UINT16, STBIR_TYPE_UINT32, STBIR_TYPE_FLOAT , STBIR_MAX_TYPES } stbir_datatype; STBIRDEF int stbir_resize( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context); STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context, float x_scale, float y_scale, float x_offset, float y_offset); STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context, float s0, float t0, float s1, float t1); // (s0, t0) & (s1, t1) are the top-left and bottom right corner (uv addressing style: [0, 1]x[0, 1]) of a region of the input image to use. // // //// end header file ///////////////////////////////////////////////////// #endif // STBIR_INCLUDE_STB_IMAGE_RESIZE_H #ifdef STB_IMAGE_RESIZE_IMPLEMENTATION #ifndef STBIR_ASSERT #include #define STBIR_ASSERT(x) assert(x) #endif // For memset #include #include #ifndef STBIR_MALLOC #include // use comma operator to evaluate c, to avoid "unused parameter" warnings #define STBIR_MALLOC(size,c) ((void)(c), malloc(size)) #define STBIR_FREE(ptr,c) ((void)(c), free(ptr)) #endif #ifndef _MSC_VER #ifdef __cplusplus #define stbir__inline inline #else #define stbir__inline #endif #else #define stbir__inline __forceinline #endif // should produce compiler error if size is wrong typedef unsigned char stbir__validate_uint32[sizeof(stbir_uint32) == 4 ? 1 : -1]; #ifdef _MSC_VER #define STBIR__NOTUSED(v) (void)(v) #else #define STBIR__NOTUSED(v) (void)sizeof(v) #endif #define STBIR__ARRAY_SIZE(a) (sizeof((a))/sizeof((a)[0])) #ifndef STBIR_DEFAULT_FILTER_UPSAMPLE #define STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_CATMULLROM #endif #ifndef STBIR_DEFAULT_FILTER_DOWNSAMPLE #define STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_MITCHELL #endif #ifndef STBIR_PROGRESS_REPORT #define STBIR_PROGRESS_REPORT(float_0_to_1) #endif #ifndef STBIR_MAX_CHANNELS #define STBIR_MAX_CHANNELS 64 #endif #if STBIR_MAX_CHANNELS > 65536 #error "Too many channels; STBIR_MAX_CHANNELS must be no more than 65536." // because we store the indices in 16-bit variables #endif // This value is added to alpha just before premultiplication to avoid // zeroing out color values. It is equivalent to 2^-80. If you don't want // that behavior (it may interfere if you have floating point images with // very small alpha values) then you can define STBIR_NO_ALPHA_EPSILON to // disable it. #ifndef STBIR_ALPHA_EPSILON #define STBIR_ALPHA_EPSILON ((float)1 / (1 << 20) / (1 << 20) / (1 << 20) / (1 << 20)) #endif #ifdef _MSC_VER #define STBIR__UNUSED_PARAM(v) (void)(v) #else #define STBIR__UNUSED_PARAM(v) (void)sizeof(v) #endif // must match stbir_datatype static unsigned char stbir__type_size[] = { 1, // STBIR_TYPE_UINT8 2, // STBIR_TYPE_UINT16 4, // STBIR_TYPE_UINT32 4, // STBIR_TYPE_FLOAT }; // Kernel function centered at 0 typedef float (stbir__kernel_fn)(float x, float scale); typedef float (stbir__support_fn)(float scale); typedef struct { stbir__kernel_fn* kernel; stbir__support_fn* support; } stbir__filter_info; // When upsampling, the contributors are which source pixels contribute. // When downsampling, the contributors are which destination pixels are contributed to. typedef struct { int n0; // First contributing pixel int n1; // Last contributing pixel } stbir__contributors; typedef struct { const void* input_data; int input_w; int input_h; int input_stride_bytes; void* output_data; int output_w; int output_h; int output_stride_bytes; float s0, t0, s1, t1; float horizontal_shift; // Units: output pixels float vertical_shift; // Units: output pixels float horizontal_scale; float vertical_scale; int channels; int alpha_channel; stbir_uint32 flags; stbir_datatype type; stbir_filter horizontal_filter; stbir_filter vertical_filter; stbir_edge edge_horizontal; stbir_edge edge_vertical; stbir_colorspace colorspace; stbir__contributors* horizontal_contributors; float* horizontal_coefficients; stbir__contributors* vertical_contributors; float* vertical_coefficients; int decode_buffer_pixels; float* decode_buffer; float* horizontal_buffer; // cache these because ceil/floor are inexplicably showing up in profile int horizontal_coefficient_width; int vertical_coefficient_width; int horizontal_filter_pixel_width; int vertical_filter_pixel_width; int horizontal_filter_pixel_margin; int vertical_filter_pixel_margin; int horizontal_num_contributors; int vertical_num_contributors; int ring_buffer_length_bytes; // The length of an individual entry in the ring buffer. The total number of ring buffers is stbir__get_filter_pixel_width(filter) int ring_buffer_num_entries; // Total number of entries in the ring buffer. int ring_buffer_first_scanline; int ring_buffer_last_scanline; int ring_buffer_begin_index; // first_scanline is at this index in the ring buffer float* ring_buffer; float* encode_buffer; // A temporary buffer to store floats so we don't lose precision while we do multiply-adds. int horizontal_contributors_size; int horizontal_coefficients_size; int vertical_contributors_size; int vertical_coefficients_size; int decode_buffer_size; int horizontal_buffer_size; int ring_buffer_size; int encode_buffer_size; } stbir__info; static const float stbir__max_uint8_as_float = 255.0f; static const float stbir__max_uint16_as_float = 65535.0f; static const double stbir__max_uint32_as_float = 4294967295.0; static stbir__inline int stbir__min(int a, int b) { return a < b ? a : b; } static stbir__inline float stbir__saturate(float x) { if (x < 0) return 0; if (x > 1) return 1; return x; } #ifdef STBIR_SATURATE_INT static stbir__inline stbir_uint8 stbir__saturate8(int x) { if ((unsigned int) x <= 255) return x; if (x < 0) return 0; return 255; } static stbir__inline stbir_uint16 stbir__saturate16(int x) { if ((unsigned int) x <= 65535) return x; if (x < 0) return 0; return 65535; } #endif static float stbir__srgb_uchar_to_linear_float[256] = { 0.000000f, 0.000304f, 0.000607f, 0.000911f, 0.001214f, 0.001518f, 0.001821f, 0.002125f, 0.002428f, 0.002732f, 0.003035f, 0.003347f, 0.003677f, 0.004025f, 0.004391f, 0.004777f, 0.005182f, 0.005605f, 0.006049f, 0.006512f, 0.006995f, 0.007499f, 0.008023f, 0.008568f, 0.009134f, 0.009721f, 0.010330f, 0.010960f, 0.011612f, 0.012286f, 0.012983f, 0.013702f, 0.014444f, 0.015209f, 0.015996f, 0.016807f, 0.017642f, 0.018500f, 0.019382f, 0.020289f, 0.021219f, 0.022174f, 0.023153f, 0.024158f, 0.025187f, 0.026241f, 0.027321f, 0.028426f, 0.029557f, 0.030713f, 0.031896f, 0.033105f, 0.034340f, 0.035601f, 0.036889f, 0.038204f, 0.039546f, 0.040915f, 0.042311f, 0.043735f, 0.045186f, 0.046665f, 0.048172f, 0.049707f, 0.051269f, 0.052861f, 0.054480f, 0.056128f, 0.057805f, 0.059511f, 0.061246f, 0.063010f, 0.064803f, 0.066626f, 0.068478f, 0.070360f, 0.072272f, 0.074214f, 0.076185f, 0.078187f, 0.080220f, 0.082283f, 0.084376f, 0.086500f, 0.088656f, 0.090842f, 0.093059f, 0.095307f, 0.097587f, 0.099899f, 0.102242f, 0.104616f, 0.107023f, 0.109462f, 0.111932f, 0.114435f, 0.116971f, 0.119538f, 0.122139f, 0.124772f, 0.127438f, 0.130136f, 0.132868f, 0.135633f, 0.138432f, 0.141263f, 0.144128f, 0.147027f, 0.149960f, 0.152926f, 0.155926f, 0.158961f, 0.162029f, 0.165132f, 0.168269f, 0.171441f, 0.174647f, 0.177888f, 0.181164f, 0.184475f, 0.187821f, 0.191202f, 0.194618f, 0.198069f, 0.201556f, 0.205079f, 0.208637f, 0.212231f, 0.215861f, 0.219526f, 0.223228f, 0.226966f, 0.230740f, 0.234551f, 0.238398f, 0.242281f, 0.246201f, 0.250158f, 0.254152f, 0.258183f, 0.262251f, 0.266356f, 0.270498f, 0.274677f, 0.278894f, 0.283149f, 0.287441f, 0.291771f, 0.296138f, 0.300544f, 0.304987f, 0.309469f, 0.313989f, 0.318547f, 0.323143f, 0.327778f, 0.332452f, 0.337164f, 0.341914f, 0.346704f, 0.351533f, 0.356400f, 0.361307f, 0.366253f, 0.371238f, 0.376262f, 0.381326f, 0.386430f, 0.391573f, 0.396755f, 0.401978f, 0.407240f, 0.412543f, 0.417885f, 0.423268f, 0.428691f, 0.434154f, 0.439657f, 0.445201f, 0.450786f, 0.456411f, 0.462077f, 0.467784f, 0.473532f, 0.479320f, 0.485150f, 0.491021f, 0.496933f, 0.502887f, 0.508881f, 0.514918f, 0.520996f, 0.527115f, 0.533276f, 0.539480f, 0.545725f, 0.552011f, 0.558340f, 0.564712f, 0.571125f, 0.577581f, 0.584078f, 0.590619f, 0.597202f, 0.603827f, 0.610496f, 0.617207f, 0.623960f, 0.630757f, 0.637597f, 0.644480f, 0.651406f, 0.658375f, 0.665387f, 0.672443f, 0.679543f, 0.686685f, 0.693872f, 0.701102f, 0.708376f, 0.715694f, 0.723055f, 0.730461f, 0.737911f, 0.745404f, 0.752942f, 0.760525f, 0.768151f, 0.775822f, 0.783538f, 0.791298f, 0.799103f, 0.806952f, 0.814847f, 0.822786f, 0.830770f, 0.838799f, 0.846873f, 0.854993f, 0.863157f, 0.871367f, 0.879622f, 0.887923f, 0.896269f, 0.904661f, 0.913099f, 0.921582f, 0.930111f, 0.938686f, 0.947307f, 0.955974f, 0.964686f, 0.973445f, 0.982251f, 0.991102f, 1.0f }; static float stbir__srgb_to_linear(float f) { if (f <= 0.04045f) return f / 12.92f; else return (float)pow((f + 0.055f) / 1.055f, 2.4f); } static float stbir__linear_to_srgb(float f) { if (f <= 0.0031308f) return f * 12.92f; else return 1.055f * (float)pow(f, 1 / 2.4f) - 0.055f; } #ifndef STBIR_NON_IEEE_FLOAT // From https://gist.github.com/rygorous/2203834 typedef union { stbir_uint32 u; float f; } stbir__FP32; static const stbir_uint32 fp32_to_srgb8_tab4[104] = { 0x0073000d, 0x007a000d, 0x0080000d, 0x0087000d, 0x008d000d, 0x0094000d, 0x009a000d, 0x00a1000d, 0x00a7001a, 0x00b4001a, 0x00c1001a, 0x00ce001a, 0x00da001a, 0x00e7001a, 0x00f4001a, 0x0101001a, 0x010e0033, 0x01280033, 0x01410033, 0x015b0033, 0x01750033, 0x018f0033, 0x01a80033, 0x01c20033, 0x01dc0067, 0x020f0067, 0x02430067, 0x02760067, 0x02aa0067, 0x02dd0067, 0x03110067, 0x03440067, 0x037800ce, 0x03df00ce, 0x044600ce, 0x04ad00ce, 0x051400ce, 0x057b00c5, 0x05dd00bc, 0x063b00b5, 0x06970158, 0x07420142, 0x07e30130, 0x087b0120, 0x090b0112, 0x09940106, 0x0a1700fc, 0x0a9500f2, 0x0b0f01cb, 0x0bf401ae, 0x0ccb0195, 0x0d950180, 0x0e56016e, 0x0f0d015e, 0x0fbc0150, 0x10630143, 0x11070264, 0x1238023e, 0x1357021d, 0x14660201, 0x156601e9, 0x165a01d3, 0x174401c0, 0x182401af, 0x18fe0331, 0x1a9602fe, 0x1c1502d2, 0x1d7e02ad, 0x1ed4028d, 0x201a0270, 0x21520256, 0x227d0240, 0x239f0443, 0x25c003fe, 0x27bf03c4, 0x29a10392, 0x2b6a0367, 0x2d1d0341, 0x2ebe031f, 0x304d0300, 0x31d105b0, 0x34a80555, 0x37520507, 0x39d504c5, 0x3c37048b, 0x3e7c0458, 0x40a8042a, 0x42bd0401, 0x44c20798, 0x488e071e, 0x4c1c06b6, 0x4f76065d, 0x52a50610, 0x55ac05cc, 0x5892058f, 0x5b590559, 0x5e0c0a23, 0x631c0980, 0x67db08f6, 0x6c55087f, 0x70940818, 0x74a007bd, 0x787d076c, 0x7c330723, }; static stbir_uint8 stbir__linear_to_srgb_uchar(float in) { static const stbir__FP32 almostone = { 0x3f7fffff }; // 1-eps static const stbir__FP32 minval = { (127-13) << 23 }; stbir_uint32 tab,bias,scale,t; stbir__FP32 f; // Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively. // The tests are carefully written so that NaNs map to 0, same as in the reference // implementation. if (!(in > minval.f)) // written this way to catch NaNs in = minval.f; if (in > almostone.f) in = almostone.f; // Do the table lookup and unpack bias, scale f.f = in; tab = fp32_to_srgb8_tab4[(f.u - minval.u) >> 20]; bias = (tab >> 16) << 9; scale = tab & 0xffff; // Grab next-highest mantissa bits and perform linear interpolation t = (f.u >> 12) & 0xff; return (unsigned char) ((bias + scale*t) >> 16); } #else // sRGB transition values, scaled by 1<<28 static int stbir__srgb_offset_to_linear_scaled[256] = { 0, 40738, 122216, 203693, 285170, 366648, 448125, 529603, 611080, 692557, 774035, 855852, 942009, 1033024, 1128971, 1229926, 1335959, 1447142, 1563542, 1685229, 1812268, 1944725, 2082664, 2226148, 2375238, 2529996, 2690481, 2856753, 3028870, 3206888, 3390865, 3580856, 3776916, 3979100, 4187460, 4402049, 4622919, 4850123, 5083710, 5323731, 5570236, 5823273, 6082892, 6349140, 6622065, 6901714, 7188133, 7481369, 7781466, 8088471, 8402427, 8723380, 9051372, 9386448, 9728650, 10078021, 10434603, 10798439, 11169569, 11548036, 11933879, 12327139, 12727857, 13136073, 13551826, 13975156, 14406100, 14844697, 15290987, 15745007, 16206795, 16676389, 17153826, 17639142, 18132374, 18633560, 19142734, 19659934, 20185196, 20718552, 21260042, 21809696, 22367554, 22933648, 23508010, 24090680, 24681686, 25281066, 25888850, 26505076, 27129772, 27762974, 28404716, 29055026, 29713942, 30381490, 31057708, 31742624, 32436272, 33138682, 33849884, 34569912, 35298800, 36036568, 36783260, 37538896, 38303512, 39077136, 39859796, 40651528, 41452360, 42262316, 43081432, 43909732, 44747252, 45594016, 46450052, 47315392, 48190064, 49074096, 49967516, 50870356, 51782636, 52704392, 53635648, 54576432, 55526772, 56486700, 57456236, 58435408, 59424248, 60422780, 61431036, 62449032, 63476804, 64514376, 65561776, 66619028, 67686160, 68763192, 69850160, 70947088, 72053992, 73170912, 74297864, 75434880, 76581976, 77739184, 78906536, 80084040, 81271736, 82469648, 83677792, 84896192, 86124888, 87363888, 88613232, 89872928, 91143016, 92423512, 93714432, 95015816, 96327688, 97650056, 98982952, 100326408, 101680440, 103045072, 104420320, 105806224, 107202800, 108610064, 110028048, 111456776, 112896264, 114346544, 115807632, 117279552, 118762328, 120255976, 121760536, 123276016, 124802440, 126339832, 127888216, 129447616, 131018048, 132599544, 134192112, 135795792, 137410592, 139036528, 140673648, 142321952, 143981456, 145652208, 147334208, 149027488, 150732064, 152447968, 154175200, 155913792, 157663776, 159425168, 161197984, 162982240, 164777968, 166585184, 168403904, 170234160, 172075968, 173929344, 175794320, 177670896, 179559120, 181458992, 183370528, 185293776, 187228736, 189175424, 191133888, 193104112, 195086128, 197079968, 199085648, 201103184, 203132592, 205173888, 207227120, 209292272, 211369392, 213458480, 215559568, 217672656, 219797792, 221934976, 224084240, 226245600, 228419056, 230604656, 232802400, 235012320, 237234432, 239468736, 241715280, 243974080, 246245120, 248528464, 250824112, 253132064, 255452368, 257785040, 260130080, 262487520, 264857376, 267239664, }; static stbir_uint8 stbir__linear_to_srgb_uchar(float f) { int x = (int) (f * (1 << 28)); // has headroom so you don't need to clamp int v = 0; int i; // Refine the guess with a short binary search. i = v + 128; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 64; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 32; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 16; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 8; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 4; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 2; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 1; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; return (stbir_uint8) v; } #endif static float stbir__filter_trapezoid(float x, float scale) { float halfscale = scale / 2; float t = 0.5f + halfscale; STBIR_ASSERT(scale <= 1); x = (float)fabs(x); if (x >= t) return 0; else { float r = 0.5f - halfscale; if (x <= r) return 1; else return (t - x) / scale; } } static float stbir__support_trapezoid(float scale) { STBIR_ASSERT(scale <= 1); return 0.5f + scale / 2; } static float stbir__filter_triangle(float x, float s) { STBIR__UNUSED_PARAM(s); x = (float)fabs(x); if (x <= 1.0f) return 1 - x; else return 0; } static float stbir__filter_cubic(float x, float s) { STBIR__UNUSED_PARAM(s); x = (float)fabs(x); if (x < 1.0f) return (4 + x*x*(3*x - 6))/6; else if (x < 2.0f) return (8 + x*(-12 + x*(6 - x)))/6; return (0.0f); } static float stbir__filter_catmullrom(float x, float s) { STBIR__UNUSED_PARAM(s); x = (float)fabs(x); if (x < 1.0f) return 1 - x*x*(2.5f - 1.5f*x); else if (x < 2.0f) return 2 - x*(4 + x*(0.5f*x - 2.5f)); return (0.0f); } static float stbir__filter_mitchell(float x, float s) { STBIR__UNUSED_PARAM(s); x = (float)fabs(x); if (x < 1.0f) return (16 + x*x*(21 * x - 36))/18; else if (x < 2.0f) return (32 + x*(-60 + x*(36 - 7*x)))/18; return (0.0f); } static float stbir__support_zero(float s) { STBIR__UNUSED_PARAM(s); return 0; } static float stbir__support_one(float s) { STBIR__UNUSED_PARAM(s); return 1; } static float stbir__support_two(float s) { STBIR__UNUSED_PARAM(s); return 2; } static stbir__filter_info stbir__filter_info_table[] = { { NULL, stbir__support_zero }, { stbir__filter_trapezoid, stbir__support_trapezoid }, { stbir__filter_triangle, stbir__support_one }, { stbir__filter_cubic, stbir__support_two }, { stbir__filter_catmullrom, stbir__support_two }, { stbir__filter_mitchell, stbir__support_two }, }; stbir__inline static int stbir__use_upsampling(float ratio) { return ratio > 1; } stbir__inline static int stbir__use_width_upsampling(stbir__info* stbir_info) { return stbir__use_upsampling(stbir_info->horizontal_scale); } stbir__inline static int stbir__use_height_upsampling(stbir__info* stbir_info) { return stbir__use_upsampling(stbir_info->vertical_scale); } // This is the maximum number of input samples that can affect an output sample // with the given filter static int stbir__get_filter_pixel_width(stbir_filter filter, float scale) { STBIR_ASSERT(filter != 0); STBIR_ASSERT(filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); if (stbir__use_upsampling(scale)) return (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2); else return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2 / scale); } // This is how much to expand buffers to account for filters seeking outside // the image boundaries. static int stbir__get_filter_pixel_margin(stbir_filter filter, float scale) { return stbir__get_filter_pixel_width(filter, scale) / 2; } static int stbir__get_coefficient_width(stbir_filter filter, float scale) { if (stbir__use_upsampling(scale)) return (int)ceil(stbir__filter_info_table[filter].support(1 / scale) * 2); else return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2); } static int stbir__get_contributors(float scale, stbir_filter filter, int input_size, int output_size) { if (stbir__use_upsampling(scale)) return output_size; else return (input_size + stbir__get_filter_pixel_margin(filter, scale) * 2); } static int stbir__get_total_horizontal_coefficients(stbir__info* info) { return info->horizontal_num_contributors * stbir__get_coefficient_width (info->horizontal_filter, info->horizontal_scale); } static int stbir__get_total_vertical_coefficients(stbir__info* info) { return info->vertical_num_contributors * stbir__get_coefficient_width (info->vertical_filter, info->vertical_scale); } static stbir__contributors* stbir__get_contributor(stbir__contributors* contributors, int n) { return &contributors[n]; } // For perf reasons this code is duplicated in stbir__resample_horizontal_upsample/downsample, // if you change it here change it there too. static float* stbir__get_coefficient(float* coefficients, stbir_filter filter, float scale, int n, int c) { int width = stbir__get_coefficient_width(filter, scale); return &coefficients[width*n + c]; } static int stbir__edge_wrap_slow(stbir_edge edge, int n, int max) { switch (edge) { case STBIR_EDGE_ZERO: return 0; // we'll decode the wrong pixel here, and then overwrite with 0s later case STBIR_EDGE_CLAMP: if (n < 0) return 0; if (n >= max) return max - 1; return n; // NOTREACHED case STBIR_EDGE_REFLECT: { if (n < 0) { if (n < max) return -n; else return max - 1; } if (n >= max) { int max2 = max * 2; if (n >= max2) return 0; else return max2 - n - 1; } return n; // NOTREACHED } case STBIR_EDGE_WRAP: if (n >= 0) return (n % max); else { int m = (-n) % max; if (m != 0) m = max - m; return (m); } // NOTREACHED default: STBIR_ASSERT(!"Unimplemented edge type"); return 0; } } stbir__inline static int stbir__edge_wrap(stbir_edge edge, int n, int max) { // avoid per-pixel switch if (n >= 0 && n < max) return n; return stbir__edge_wrap_slow(edge, n, max); } // What input pixels contribute to this output pixel? static void stbir__calculate_sample_range_upsample(int n, float out_filter_radius, float scale_ratio, float out_shift, int* in_first_pixel, int* in_last_pixel, float* in_center_of_out) { float out_pixel_center = (float)n + 0.5f; float out_pixel_influence_lowerbound = out_pixel_center - out_filter_radius; float out_pixel_influence_upperbound = out_pixel_center + out_filter_radius; float in_pixel_influence_lowerbound = (out_pixel_influence_lowerbound + out_shift) / scale_ratio; float in_pixel_influence_upperbound = (out_pixel_influence_upperbound + out_shift) / scale_ratio; *in_center_of_out = (out_pixel_center + out_shift) / scale_ratio; *in_first_pixel = (int)(floor(in_pixel_influence_lowerbound + 0.5)); *in_last_pixel = (int)(floor(in_pixel_influence_upperbound - 0.5)); } // What output pixels does this input pixel contribute to? static void stbir__calculate_sample_range_downsample(int n, float in_pixels_radius, float scale_ratio, float out_shift, int* out_first_pixel, int* out_last_pixel, float* out_center_of_in) { float in_pixel_center = (float)n + 0.5f; float in_pixel_influence_lowerbound = in_pixel_center - in_pixels_radius; float in_pixel_influence_upperbound = in_pixel_center + in_pixels_radius; float out_pixel_influence_lowerbound = in_pixel_influence_lowerbound * scale_ratio - out_shift; float out_pixel_influence_upperbound = in_pixel_influence_upperbound * scale_ratio - out_shift; *out_center_of_in = in_pixel_center * scale_ratio - out_shift; *out_first_pixel = (int)(floor(out_pixel_influence_lowerbound + 0.5)); *out_last_pixel = (int)(floor(out_pixel_influence_upperbound - 0.5)); } static void stbir__calculate_coefficients_upsample(stbir_filter filter, float scale, int in_first_pixel, int in_last_pixel, float in_center_of_out, stbir__contributors* contributor, float* coefficient_group) { int i; float total_filter = 0; float filter_scale; STBIR_ASSERT(in_last_pixel - in_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical. contributor->n0 = in_first_pixel; contributor->n1 = in_last_pixel; STBIR_ASSERT(contributor->n1 >= contributor->n0); for (i = 0; i <= in_last_pixel - in_first_pixel; i++) { float in_pixel_center = (float)(i + in_first_pixel) + 0.5f; coefficient_group[i] = stbir__filter_info_table[filter].kernel(in_center_of_out - in_pixel_center, 1 / scale); // If the coefficient is zero, skip it. (Don't do the <0 check here, we want the influence of those outside pixels.) if (i == 0 && !coefficient_group[i]) { contributor->n0 = ++in_first_pixel; i--; continue; } total_filter += coefficient_group[i]; } STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(in_last_pixel + 1) + 0.5f - in_center_of_out, 1/scale) == 0); STBIR_ASSERT(total_filter > 0.9); STBIR_ASSERT(total_filter < 1.1f); // Make sure it's not way off. // Make sure the sum of all coefficients is 1. filter_scale = 1 / total_filter; for (i = 0; i <= in_last_pixel - in_first_pixel; i++) coefficient_group[i] *= filter_scale; for (i = in_last_pixel - in_first_pixel; i >= 0; i--) { if (coefficient_group[i]) break; // This line has no weight. We can skip it. contributor->n1 = contributor->n0 + i - 1; } } static void stbir__calculate_coefficients_downsample(stbir_filter filter, float scale_ratio, int out_first_pixel, int out_last_pixel, float out_center_of_in, stbir__contributors* contributor, float* coefficient_group) { int i; STBIR_ASSERT(out_last_pixel - out_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(scale_ratio) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical. contributor->n0 = out_first_pixel; contributor->n1 = out_last_pixel; STBIR_ASSERT(contributor->n1 >= contributor->n0); for (i = 0; i <= out_last_pixel - out_first_pixel; i++) { float out_pixel_center = (float)(i + out_first_pixel) + 0.5f; float x = out_pixel_center - out_center_of_in; coefficient_group[i] = stbir__filter_info_table[filter].kernel(x, scale_ratio) * scale_ratio; } STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(out_last_pixel + 1) + 0.5f - out_center_of_in, scale_ratio) == 0); for (i = out_last_pixel - out_first_pixel; i >= 0; i--) { if (coefficient_group[i]) break; // This line has no weight. We can skip it. contributor->n1 = contributor->n0 + i - 1; } } static void stbir__normalize_downsample_coefficients(stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, int input_size, int output_size) { int num_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size); int num_coefficients = stbir__get_coefficient_width(filter, scale_ratio); int i, j; int skip; for (i = 0; i < output_size; i++) { float scale; float total = 0; for (j = 0; j < num_contributors; j++) { if (i >= contributors[j].n0 && i <= contributors[j].n1) { float coefficient = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0); total += coefficient; } else if (i < contributors[j].n0) break; } STBIR_ASSERT(total > 0.9f); STBIR_ASSERT(total < 1.1f); scale = 1 / total; for (j = 0; j < num_contributors; j++) { if (i >= contributors[j].n0 && i <= contributors[j].n1) *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0) *= scale; else if (i < contributors[j].n0) break; } } // Optimize: Skip zero coefficients and contributions outside of image bounds. // Do this after normalizing because normalization depends on the n0/n1 values. for (j = 0; j < num_contributors; j++) { int range, max, width; skip = 0; while (*stbir__get_coefficient(coefficients, filter, scale_ratio, j, skip) == 0) skip++; contributors[j].n0 += skip; while (contributors[j].n0 < 0) { contributors[j].n0++; skip++; } range = contributors[j].n1 - contributors[j].n0 + 1; max = stbir__min(num_coefficients, range); width = stbir__get_coefficient_width(filter, scale_ratio); for (i = 0; i < max; i++) { if (i + skip >= width) break; *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i) = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i + skip); } continue; } // Using min to avoid writing into invalid pixels. for (i = 0; i < num_contributors; i++) contributors[i].n1 = stbir__min(contributors[i].n1, output_size - 1); } // Each scan line uses the same kernel values so we should calculate the kernel // values once and then we can use them for every scan line. static void stbir__calculate_filters(stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, float shift, int input_size, int output_size) { int n; int total_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size); if (stbir__use_upsampling(scale_ratio)) { float out_pixels_radius = stbir__filter_info_table[filter].support(1 / scale_ratio) * scale_ratio; // Looping through out pixels for (n = 0; n < total_contributors; n++) { float in_center_of_out; // Center of the current out pixel in the in pixel space int in_first_pixel, in_last_pixel; stbir__calculate_sample_range_upsample(n, out_pixels_radius, scale_ratio, shift, &in_first_pixel, &in_last_pixel, &in_center_of_out); stbir__calculate_coefficients_upsample(filter, scale_ratio, in_first_pixel, in_last_pixel, in_center_of_out, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0)); } } else { float in_pixels_radius = stbir__filter_info_table[filter].support(scale_ratio) / scale_ratio; // Looping through in pixels for (n = 0; n < total_contributors; n++) { float out_center_of_in; // Center of the current out pixel in the in pixel space int out_first_pixel, out_last_pixel; int n_adjusted = n - stbir__get_filter_pixel_margin(filter, scale_ratio); stbir__calculate_sample_range_downsample(n_adjusted, in_pixels_radius, scale_ratio, shift, &out_first_pixel, &out_last_pixel, &out_center_of_in); stbir__calculate_coefficients_downsample(filter, scale_ratio, out_first_pixel, out_last_pixel, out_center_of_in, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0)); } stbir__normalize_downsample_coefficients(contributors, coefficients, filter, scale_ratio, input_size, output_size); } } static float* stbir__get_decode_buffer(stbir__info* stbir_info) { // The 0 index of the decode buffer starts after the margin. This makes // it okay to use negative indexes on the decode buffer. return &stbir_info->decode_buffer[stbir_info->horizontal_filter_pixel_margin * stbir_info->channels]; } #define STBIR__DECODE(type, colorspace) ((type) * (STBIR_MAX_COLORSPACES) + (colorspace)) static void stbir__decode_scanline(stbir__info* stbir_info, int n) { int c; int channels = stbir_info->channels; int alpha_channel = stbir_info->alpha_channel; int type = stbir_info->type; int colorspace = stbir_info->colorspace; int input_w = stbir_info->input_w; size_t input_stride_bytes = stbir_info->input_stride_bytes; float* decode_buffer = stbir__get_decode_buffer(stbir_info); stbir_edge edge_horizontal = stbir_info->edge_horizontal; stbir_edge edge_vertical = stbir_info->edge_vertical; size_t in_buffer_row_offset = stbir__edge_wrap(edge_vertical, n, stbir_info->input_h) * input_stride_bytes; const void* input_data = (char *) stbir_info->input_data + in_buffer_row_offset; int max_x = input_w + stbir_info->horizontal_filter_pixel_margin; int decode = STBIR__DECODE(type, colorspace); int x = -stbir_info->horizontal_filter_pixel_margin; // special handling for STBIR_EDGE_ZERO because it needs to return an item that doesn't appear in the input, // and we want to avoid paying overhead on every pixel if not STBIR_EDGE_ZERO if (edge_vertical == STBIR_EDGE_ZERO && (n < 0 || n >= stbir_info->input_h)) { for (; x < max_x; x++) for (c = 0; c < channels; c++) decode_buffer[x*channels + c] = 0; return; } switch (decode) { case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = ((float)((const unsigned char*)input_data)[input_pixel_index + c]) / stbir__max_uint8_as_float; } break; case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + c]]; if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned char*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint8_as_float; } break; case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = ((float)((const unsigned short*)input_data)[input_pixel_index + c]) / stbir__max_uint16_as_float; } break; case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((float)((const unsigned short*)input_data)[input_pixel_index + c]) / stbir__max_uint16_as_float); if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned short*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint16_as_float; } break; case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / stbir__max_uint32_as_float); } break; case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear((float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / stbir__max_uint32_as_float)); if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) decode_buffer[decode_pixel_index + alpha_channel] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint32_as_float); } break; case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = ((const float*)input_data)[input_pixel_index + c]; } break; case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((const float*)input_data)[input_pixel_index + c]); if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) decode_buffer[decode_pixel_index + alpha_channel] = ((const float*)input_data)[input_pixel_index + alpha_channel]; } break; default: STBIR_ASSERT(!"Unknown type/colorspace/channels combination."); break; } if (!(stbir_info->flags & STBIR_FLAG_ALPHA_PREMULTIPLIED)) { for (x = -stbir_info->horizontal_filter_pixel_margin; x < max_x; x++) { int decode_pixel_index = x * channels; // If the alpha value is 0 it will clobber the color values. Make sure it's not. float alpha = decode_buffer[decode_pixel_index + alpha_channel]; #ifndef STBIR_NO_ALPHA_EPSILON if (stbir_info->type != STBIR_TYPE_FLOAT) { alpha += STBIR_ALPHA_EPSILON; decode_buffer[decode_pixel_index + alpha_channel] = alpha; } #endif for (c = 0; c < channels; c++) { if (c == alpha_channel) continue; decode_buffer[decode_pixel_index + c] *= alpha; } } } if (edge_horizontal == STBIR_EDGE_ZERO) { for (x = -stbir_info->horizontal_filter_pixel_margin; x < 0; x++) { for (c = 0; c < channels; c++) decode_buffer[x*channels + c] = 0; } for (x = input_w; x < max_x; x++) { for (c = 0; c < channels; c++) decode_buffer[x*channels + c] = 0; } } } static float* stbir__get_ring_buffer_entry(float* ring_buffer, int index, int ring_buffer_length) { return &ring_buffer[index * ring_buffer_length]; } static float* stbir__add_empty_ring_buffer_entry(stbir__info* stbir_info, int n) { int ring_buffer_index; float* ring_buffer; stbir_info->ring_buffer_last_scanline = n; if (stbir_info->ring_buffer_begin_index < 0) { ring_buffer_index = stbir_info->ring_buffer_begin_index = 0; stbir_info->ring_buffer_first_scanline = n; } else { ring_buffer_index = (stbir_info->ring_buffer_begin_index + (stbir_info->ring_buffer_last_scanline - stbir_info->ring_buffer_first_scanline)) % stbir_info->ring_buffer_num_entries; STBIR_ASSERT(ring_buffer_index != stbir_info->ring_buffer_begin_index); } ring_buffer = stbir__get_ring_buffer_entry(stbir_info->ring_buffer, ring_buffer_index, stbir_info->ring_buffer_length_bytes / sizeof(float)); memset(ring_buffer, 0, stbir_info->ring_buffer_length_bytes); return ring_buffer; } static void stbir__resample_horizontal_upsample(stbir__info* stbir_info, float* output_buffer) { int x, k; int output_w = stbir_info->output_w; int channels = stbir_info->channels; float* decode_buffer = stbir__get_decode_buffer(stbir_info); stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors; float* horizontal_coefficients = stbir_info->horizontal_coefficients; int coefficient_width = stbir_info->horizontal_coefficient_width; for (x = 0; x < output_w; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int out_pixel_index = x * channels; int coefficient_group = coefficient_width * x; int coefficient_counter = 0; STBIR_ASSERT(n1 >= n0); STBIR_ASSERT(n0 >= -stbir_info->horizontal_filter_pixel_margin); STBIR_ASSERT(n1 >= -stbir_info->horizontal_filter_pixel_margin); STBIR_ASSERT(n0 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin); STBIR_ASSERT(n1 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin); switch (channels) { case 1: for (k = n0; k <= n1; k++) { int in_pixel_index = k * 1; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; } break; case 2: for (k = n0; k <= n1; k++) { int in_pixel_index = k * 2; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; } break; case 3: for (k = n0; k <= n1; k++) { int in_pixel_index = k * 3; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; } break; case 4: for (k = n0; k <= n1; k++) { int in_pixel_index = k * 4; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient; } break; default: for (k = n0; k <= n1; k++) { int in_pixel_index = k * channels; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; int c; STBIR_ASSERT(coefficient != 0); for (c = 0; c < channels; c++) output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient; } break; } } } static void stbir__resample_horizontal_downsample(stbir__info* stbir_info, float* output_buffer) { int x, k; int input_w = stbir_info->input_w; int channels = stbir_info->channels; float* decode_buffer = stbir__get_decode_buffer(stbir_info); stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors; float* horizontal_coefficients = stbir_info->horizontal_coefficients; int coefficient_width = stbir_info->horizontal_coefficient_width; int filter_pixel_margin = stbir_info->horizontal_filter_pixel_margin; int max_x = input_w + filter_pixel_margin * 2; STBIR_ASSERT(!stbir__use_width_upsampling(stbir_info)); switch (channels) { case 1: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * 1; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int out_pixel_index = k * 1; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; } } break; case 2: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * 2; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int out_pixel_index = k * 2; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; } } break; case 3: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * 3; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int out_pixel_index = k * 3; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; } } break; case 4: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * 4; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int out_pixel_index = k * 4; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient; } } break; default: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * channels; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int c; int out_pixel_index = k * channels; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); for (c = 0; c < channels; c++) output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient; } } break; } } static void stbir__decode_and_resample_upsample(stbir__info* stbir_info, int n) { // Decode the nth scanline from the source image into the decode buffer. stbir__decode_scanline(stbir_info, n); // Now resample it into the ring buffer. if (stbir__use_width_upsampling(stbir_info)) stbir__resample_horizontal_upsample(stbir_info, stbir__add_empty_ring_buffer_entry(stbir_info, n)); else stbir__resample_horizontal_downsample(stbir_info, stbir__add_empty_ring_buffer_entry(stbir_info, n)); // Now it's sitting in the ring buffer ready to be used as source for the vertical sampling. } static void stbir__decode_and_resample_downsample(stbir__info* stbir_info, int n) { // Decode the nth scanline from the source image into the decode buffer. stbir__decode_scanline(stbir_info, n); memset(stbir_info->horizontal_buffer, 0, stbir_info->output_w * stbir_info->channels * sizeof(float)); // Now resample it into the horizontal buffer. if (stbir__use_width_upsampling(stbir_info)) stbir__resample_horizontal_upsample(stbir_info, stbir_info->horizontal_buffer); else stbir__resample_horizontal_downsample(stbir_info, stbir_info->horizontal_buffer); // Now it's sitting in the horizontal buffer ready to be distributed into the ring buffers. } // Get the specified scan line from the ring buffer. static float* stbir__get_ring_buffer_scanline(int get_scanline, float* ring_buffer, int begin_index, int first_scanline, int ring_buffer_num_entries, int ring_buffer_length) { int ring_buffer_index = (begin_index + (get_scanline - first_scanline)) % ring_buffer_num_entries; return stbir__get_ring_buffer_entry(ring_buffer, ring_buffer_index, ring_buffer_length); } static void stbir__encode_scanline(stbir__info* stbir_info, int num_pixels, void *output_buffer, float *encode_buffer, int channels, int alpha_channel, int decode) { int x; int n; int num_nonalpha; stbir_uint16 nonalpha[STBIR_MAX_CHANNELS]; if (!(stbir_info->flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) { for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; float alpha = encode_buffer[pixel_index + alpha_channel]; float reciprocal_alpha = alpha ? 1.0f / alpha : 0; // unrolling this produced a 1% slowdown upscaling a large RGBA linear-space image on my machine - stb for (n = 0; n < channels; n++) if (n != alpha_channel) encode_buffer[pixel_index + n] *= reciprocal_alpha; // We added in a small epsilon to prevent the color channel from being deleted with zero alpha. // Because we only add it for integer types, it will automatically be discarded on integer // conversion, so we don't need to subtract it back out (which would be problematic for // numeric precision reasons). } } // build a table of all channels that need colorspace correction, so // we don't perform colorspace correction on channels that don't need it. for (x = 0, num_nonalpha = 0; x < channels; ++x) { if (x != alpha_channel || (stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE)) { nonalpha[num_nonalpha++] = (stbir_uint16)x; } } #define STBIR__ROUND_INT(f) ((int) ((f)+0.5)) #define STBIR__ROUND_UINT(f) ((stbir_uint32) ((f)+0.5)) #ifdef STBIR__SATURATE_INT #define STBIR__ENCODE_LINEAR8(f) stbir__saturate8 (STBIR__ROUND_INT((f) * stbir__max_uint8_as_float )) #define STBIR__ENCODE_LINEAR16(f) stbir__saturate16(STBIR__ROUND_INT((f) * stbir__max_uint16_as_float)) #else #define STBIR__ENCODE_LINEAR8(f) (unsigned char ) STBIR__ROUND_INT(stbir__saturate(f) * stbir__max_uint8_as_float ) #define STBIR__ENCODE_LINEAR16(f) (unsigned short) STBIR__ROUND_INT(stbir__saturate(f) * stbir__max_uint16_as_float) #endif switch (decode) { case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < channels; n++) { int index = pixel_index + n; ((unsigned char*)output_buffer)[index] = STBIR__ENCODE_LINEAR8(encode_buffer[index]); } } break; case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < num_nonalpha; n++) { int index = pixel_index + nonalpha[n]; ((unsigned char*)output_buffer)[index] = stbir__linear_to_srgb_uchar(encode_buffer[index]); } if (!(stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE)) ((unsigned char *)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR8(encode_buffer[pixel_index+alpha_channel]); } break; case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < channels; n++) { int index = pixel_index + n; ((unsigned short*)output_buffer)[index] = STBIR__ENCODE_LINEAR16(encode_buffer[index]); } } break; case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < num_nonalpha; n++) { int index = pixel_index + nonalpha[n]; ((unsigned short*)output_buffer)[index] = (unsigned short)STBIR__ROUND_INT(stbir__linear_to_srgb(stbir__saturate(encode_buffer[index])) * stbir__max_uint16_as_float); } if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) ((unsigned short*)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR16(encode_buffer[pixel_index + alpha_channel]); } break; case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < channels; n++) { int index = pixel_index + n; ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__saturate(encode_buffer[index])) * stbir__max_uint32_as_float); } } break; case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < num_nonalpha; n++) { int index = pixel_index + nonalpha[n]; ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__linear_to_srgb(stbir__saturate(encode_buffer[index]))) * stbir__max_uint32_as_float); } if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) ((unsigned int*)output_buffer)[pixel_index + alpha_channel] = (unsigned int)STBIR__ROUND_INT(((double)stbir__saturate(encode_buffer[pixel_index + alpha_channel])) * stbir__max_uint32_as_float); } break; case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < channels; n++) { int index = pixel_index + n; ((float*)output_buffer)[index] = encode_buffer[index]; } } break; case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < num_nonalpha; n++) { int index = pixel_index + nonalpha[n]; ((float*)output_buffer)[index] = stbir__linear_to_srgb(encode_buffer[index]); } if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) ((float*)output_buffer)[pixel_index + alpha_channel] = encode_buffer[pixel_index + alpha_channel]; } break; default: STBIR_ASSERT(!"Unknown type/colorspace/channels combination."); break; } } static void stbir__resample_vertical_upsample(stbir__info* stbir_info, int n) { int x, k; int output_w = stbir_info->output_w; stbir__contributors* vertical_contributors = stbir_info->vertical_contributors; float* vertical_coefficients = stbir_info->vertical_coefficients; int channels = stbir_info->channels; int alpha_channel = stbir_info->alpha_channel; int type = stbir_info->type; int colorspace = stbir_info->colorspace; int ring_buffer_entries = stbir_info->ring_buffer_num_entries; void* output_data = stbir_info->output_data; float* encode_buffer = stbir_info->encode_buffer; int decode = STBIR__DECODE(type, colorspace); int coefficient_width = stbir_info->vertical_coefficient_width; int coefficient_counter; int contributor = n; float* ring_buffer = stbir_info->ring_buffer; int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index; int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline; int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); int n0,n1, output_row_start; int coefficient_group = coefficient_width * contributor; n0 = vertical_contributors[contributor].n0; n1 = vertical_contributors[contributor].n1; output_row_start = n * stbir_info->output_stride_bytes; STBIR_ASSERT(stbir__use_height_upsampling(stbir_info)); memset(encode_buffer, 0, output_w * sizeof(float) * channels); // I tried reblocking this for better cache usage of encode_buffer // (using x_outer, k, x_inner), but it lost speed. -- stb coefficient_counter = 0; switch (channels) { case 1: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * 1; encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; } } break; case 2: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * 2; encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; } } break; case 3: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * 3; encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient; } } break; case 4: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * 4; encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient; encode_buffer[in_pixel_index + 3] += ring_buffer_entry[in_pixel_index + 3] * coefficient; } } break; default: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * channels; int c; for (c = 0; c < channels; c++) encode_buffer[in_pixel_index + c] += ring_buffer_entry[in_pixel_index + c] * coefficient; } } break; } stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, encode_buffer, channels, alpha_channel, decode); } static void stbir__resample_vertical_downsample(stbir__info* stbir_info, int n) { int x, k; int output_w = stbir_info->output_w; stbir__contributors* vertical_contributors = stbir_info->vertical_contributors; float* vertical_coefficients = stbir_info->vertical_coefficients; int channels = stbir_info->channels; int ring_buffer_entries = stbir_info->ring_buffer_num_entries; float* horizontal_buffer = stbir_info->horizontal_buffer; int coefficient_width = stbir_info->vertical_coefficient_width; int contributor = n + stbir_info->vertical_filter_pixel_margin; float* ring_buffer = stbir_info->ring_buffer; int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index; int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline; int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); int n0,n1; n0 = vertical_contributors[contributor].n0; n1 = vertical_contributors[contributor].n1; STBIR_ASSERT(!stbir__use_height_upsampling(stbir_info)); for (k = n0; k <= n1; k++) { int coefficient_index = k - n0; int coefficient_group = coefficient_width * contributor; float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); switch (channels) { case 1: for (x = 0; x < output_w; x++) { int in_pixel_index = x * 1; ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; } break; case 2: for (x = 0; x < output_w; x++) { int in_pixel_index = x * 2; ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; } break; case 3: for (x = 0; x < output_w; x++) { int in_pixel_index = x * 3; ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient; } break; case 4: for (x = 0; x < output_w; x++) { int in_pixel_index = x * 4; ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient; ring_buffer_entry[in_pixel_index + 3] += horizontal_buffer[in_pixel_index + 3] * coefficient; } break; default: for (x = 0; x < output_w; x++) { int in_pixel_index = x * channels; int c; for (c = 0; c < channels; c++) ring_buffer_entry[in_pixel_index + c] += horizontal_buffer[in_pixel_index + c] * coefficient; } break; } } } static void stbir__buffer_loop_upsample(stbir__info* stbir_info) { int y; float scale_ratio = stbir_info->vertical_scale; float out_scanlines_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(1/scale_ratio) * scale_ratio; STBIR_ASSERT(stbir__use_height_upsampling(stbir_info)); for (y = 0; y < stbir_info->output_h; y++) { float in_center_of_out = 0; // Center of the current out scanline in the in scanline space int in_first_scanline = 0, in_last_scanline = 0; stbir__calculate_sample_range_upsample(y, out_scanlines_radius, scale_ratio, stbir_info->vertical_shift, &in_first_scanline, &in_last_scanline, &in_center_of_out); STBIR_ASSERT(in_last_scanline - in_first_scanline + 1 <= stbir_info->ring_buffer_num_entries); if (stbir_info->ring_buffer_begin_index >= 0) { // Get rid of whatever we don't need anymore. while (in_first_scanline > stbir_info->ring_buffer_first_scanline) { if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline) { // We just popped the last scanline off the ring buffer. // Reset it to the empty state. stbir_info->ring_buffer_begin_index = -1; stbir_info->ring_buffer_first_scanline = 0; stbir_info->ring_buffer_last_scanline = 0; break; } else { stbir_info->ring_buffer_first_scanline++; stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->ring_buffer_num_entries; } } } // Load in new ones. if (stbir_info->ring_buffer_begin_index < 0) stbir__decode_and_resample_upsample(stbir_info, in_first_scanline); while (in_last_scanline > stbir_info->ring_buffer_last_scanline) stbir__decode_and_resample_upsample(stbir_info, stbir_info->ring_buffer_last_scanline + 1); // Now all buffers should be ready to write a row of vertical sampling. stbir__resample_vertical_upsample(stbir_info, y); STBIR_PROGRESS_REPORT((float)y / stbir_info->output_h); } } static void stbir__empty_ring_buffer(stbir__info* stbir_info, int first_necessary_scanline) { int output_stride_bytes = stbir_info->output_stride_bytes; int channels = stbir_info->channels; int alpha_channel = stbir_info->alpha_channel; int type = stbir_info->type; int colorspace = stbir_info->colorspace; int output_w = stbir_info->output_w; void* output_data = stbir_info->output_data; int decode = STBIR__DECODE(type, colorspace); float* ring_buffer = stbir_info->ring_buffer; int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); if (stbir_info->ring_buffer_begin_index >= 0) { // Get rid of whatever we don't need anymore. while (first_necessary_scanline > stbir_info->ring_buffer_first_scanline) { if (stbir_info->ring_buffer_first_scanline >= 0 && stbir_info->ring_buffer_first_scanline < stbir_info->output_h) { int output_row_start = stbir_info->ring_buffer_first_scanline * output_stride_bytes; float* ring_buffer_entry = stbir__get_ring_buffer_entry(ring_buffer, stbir_info->ring_buffer_begin_index, ring_buffer_length); stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, ring_buffer_entry, channels, alpha_channel, decode); STBIR_PROGRESS_REPORT((float)stbir_info->ring_buffer_first_scanline / stbir_info->output_h); } if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline) { // We just popped the last scanline off the ring buffer. // Reset it to the empty state. stbir_info->ring_buffer_begin_index = -1; stbir_info->ring_buffer_first_scanline = 0; stbir_info->ring_buffer_last_scanline = 0; break; } else { stbir_info->ring_buffer_first_scanline++; stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->ring_buffer_num_entries; } } } } static void stbir__buffer_loop_downsample(stbir__info* stbir_info) { int y; float scale_ratio = stbir_info->vertical_scale; int output_h = stbir_info->output_h; float in_pixels_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(scale_ratio) / scale_ratio; int pixel_margin = stbir_info->vertical_filter_pixel_margin; int max_y = stbir_info->input_h + pixel_margin; STBIR_ASSERT(!stbir__use_height_upsampling(stbir_info)); for (y = -pixel_margin; y < max_y; y++) { float out_center_of_in; // Center of the current out scanline in the in scanline space int out_first_scanline, out_last_scanline; stbir__calculate_sample_range_downsample(y, in_pixels_radius, scale_ratio, stbir_info->vertical_shift, &out_first_scanline, &out_last_scanline, &out_center_of_in); STBIR_ASSERT(out_last_scanline - out_first_scanline + 1 <= stbir_info->ring_buffer_num_entries); if (out_last_scanline < 0 || out_first_scanline >= output_h) continue; stbir__empty_ring_buffer(stbir_info, out_first_scanline); stbir__decode_and_resample_downsample(stbir_info, y); // Load in new ones. if (stbir_info->ring_buffer_begin_index < 0) stbir__add_empty_ring_buffer_entry(stbir_info, out_first_scanline); while (out_last_scanline > stbir_info->ring_buffer_last_scanline) stbir__add_empty_ring_buffer_entry(stbir_info, stbir_info->ring_buffer_last_scanline + 1); // Now the horizontal buffer is ready to write to all ring buffer rows. stbir__resample_vertical_downsample(stbir_info, y); } stbir__empty_ring_buffer(stbir_info, stbir_info->output_h); } static void stbir__setup(stbir__info *info, int input_w, int input_h, int output_w, int output_h, int channels) { info->input_w = input_w; info->input_h = input_h; info->output_w = output_w; info->output_h = output_h; info->channels = channels; } static void stbir__calculate_transform(stbir__info *info, float s0, float t0, float s1, float t1, float *transform) { info->s0 = s0; info->t0 = t0; info->s1 = s1; info->t1 = t1; if (transform) { info->horizontal_scale = transform[0]; info->vertical_scale = transform[1]; info->horizontal_shift = transform[2]; info->vertical_shift = transform[3]; } else { info->horizontal_scale = ((float)info->output_w / info->input_w) / (s1 - s0); info->vertical_scale = ((float)info->output_h / info->input_h) / (t1 - t0); info->horizontal_shift = s0 * info->output_w / (s1 - s0); info->vertical_shift = t0 * info->output_h / (t1 - t0); } } static void stbir__choose_filter(stbir__info *info, stbir_filter h_filter, stbir_filter v_filter) { if (h_filter == 0) h_filter = stbir__use_upsampling(info->horizontal_scale) ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE; if (v_filter == 0) v_filter = stbir__use_upsampling(info->vertical_scale) ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE; info->horizontal_filter = h_filter; info->vertical_filter = v_filter; } static stbir_uint32 stbir__calculate_memory(stbir__info *info) { int pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale); int filter_height = stbir__get_filter_pixel_width(info->vertical_filter, info->vertical_scale); info->horizontal_num_contributors = stbir__get_contributors(info->horizontal_scale, info->horizontal_filter, info->input_w, info->output_w); info->vertical_num_contributors = stbir__get_contributors(info->vertical_scale , info->vertical_filter , info->input_h, info->output_h); // One extra entry because floating point precision problems sometimes cause an extra to be necessary. info->ring_buffer_num_entries = filter_height + 1; info->horizontal_contributors_size = info->horizontal_num_contributors * sizeof(stbir__contributors); info->horizontal_coefficients_size = stbir__get_total_horizontal_coefficients(info) * sizeof(float); info->vertical_contributors_size = info->vertical_num_contributors * sizeof(stbir__contributors); info->vertical_coefficients_size = stbir__get_total_vertical_coefficients(info) * sizeof(float); info->decode_buffer_size = (info->input_w + pixel_margin * 2) * info->channels * sizeof(float); info->horizontal_buffer_size = info->output_w * info->channels * sizeof(float); info->ring_buffer_size = info->output_w * info->channels * info->ring_buffer_num_entries * sizeof(float); info->encode_buffer_size = info->output_w * info->channels * sizeof(float); STBIR_ASSERT(info->horizontal_filter != 0); STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late STBIR_ASSERT(info->vertical_filter != 0); STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late if (stbir__use_height_upsampling(info)) // The horizontal buffer is for when we're downsampling the height and we // can't output the result of sampling the decode buffer directly into the // ring buffers. info->horizontal_buffer_size = 0; else // The encode buffer is to retain precision in the height upsampling method // and isn't used when height downsampling. info->encode_buffer_size = 0; return info->horizontal_contributors_size + info->horizontal_coefficients_size + info->vertical_contributors_size + info->vertical_coefficients_size + info->decode_buffer_size + info->horizontal_buffer_size + info->ring_buffer_size + info->encode_buffer_size; } static int stbir__resize_allocated(stbir__info *info, const void* input_data, int input_stride_in_bytes, void* output_data, int output_stride_in_bytes, int alpha_channel, stbir_uint32 flags, stbir_datatype type, stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace, void* tempmem, size_t tempmem_size_in_bytes) { size_t memory_required = stbir__calculate_memory(info); int width_stride_input = input_stride_in_bytes ? input_stride_in_bytes : info->channels * info->input_w * stbir__type_size[type]; int width_stride_output = output_stride_in_bytes ? output_stride_in_bytes : info->channels * info->output_w * stbir__type_size[type]; #ifdef STBIR_DEBUG_OVERWRITE_TEST #define OVERWRITE_ARRAY_SIZE 8 unsigned char overwrite_output_before_pre[OVERWRITE_ARRAY_SIZE]; unsigned char overwrite_tempmem_before_pre[OVERWRITE_ARRAY_SIZE]; unsigned char overwrite_output_after_pre[OVERWRITE_ARRAY_SIZE]; unsigned char overwrite_tempmem_after_pre[OVERWRITE_ARRAY_SIZE]; size_t begin_forbidden = width_stride_output * (info->output_h - 1) + info->output_w * info->channels * stbir__type_size[type]; memcpy(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE); memcpy(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE); memcpy(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE); memcpy(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE); #endif STBIR_ASSERT(info->channels >= 0); STBIR_ASSERT(info->channels <= STBIR_MAX_CHANNELS); if (info->channels < 0 || info->channels > STBIR_MAX_CHANNELS) return 0; STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); if (info->horizontal_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table)) return 0; if (info->vertical_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table)) return 0; if (alpha_channel < 0) flags |= STBIR_FLAG_ALPHA_USES_COLORSPACE | STBIR_FLAG_ALPHA_PREMULTIPLIED; if (!(flags&STBIR_FLAG_ALPHA_USES_COLORSPACE) || !(flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) STBIR_ASSERT(alpha_channel >= 0 && alpha_channel < info->channels); if (alpha_channel >= info->channels) return 0; STBIR_ASSERT(tempmem); if (!tempmem) return 0; STBIR_ASSERT(tempmem_size_in_bytes >= memory_required); if (tempmem_size_in_bytes < memory_required) return 0; memset(tempmem, 0, tempmem_size_in_bytes); info->input_data = input_data; info->input_stride_bytes = width_stride_input; info->output_data = output_data; info->output_stride_bytes = width_stride_output; info->alpha_channel = alpha_channel; info->flags = flags; info->type = type; info->edge_horizontal = edge_horizontal; info->edge_vertical = edge_vertical; info->colorspace = colorspace; info->horizontal_coefficient_width = stbir__get_coefficient_width (info->horizontal_filter, info->horizontal_scale); info->vertical_coefficient_width = stbir__get_coefficient_width (info->vertical_filter , info->vertical_scale ); info->horizontal_filter_pixel_width = stbir__get_filter_pixel_width (info->horizontal_filter, info->horizontal_scale); info->vertical_filter_pixel_width = stbir__get_filter_pixel_width (info->vertical_filter , info->vertical_scale ); info->horizontal_filter_pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale); info->vertical_filter_pixel_margin = stbir__get_filter_pixel_margin(info->vertical_filter , info->vertical_scale ); info->ring_buffer_length_bytes = info->output_w * info->channels * sizeof(float); info->decode_buffer_pixels = info->input_w + info->horizontal_filter_pixel_margin * 2; #define STBIR__NEXT_MEMPTR(current, newtype) (newtype*)(((unsigned char*)current) + current##_size) info->horizontal_contributors = (stbir__contributors *) tempmem; info->horizontal_coefficients = STBIR__NEXT_MEMPTR(info->horizontal_contributors, float); info->vertical_contributors = STBIR__NEXT_MEMPTR(info->horizontal_coefficients, stbir__contributors); info->vertical_coefficients = STBIR__NEXT_MEMPTR(info->vertical_contributors, float); info->decode_buffer = STBIR__NEXT_MEMPTR(info->vertical_coefficients, float); if (stbir__use_height_upsampling(info)) { info->horizontal_buffer = NULL; info->ring_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float); info->encode_buffer = STBIR__NEXT_MEMPTR(info->ring_buffer, float); STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->encode_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes); } else { info->horizontal_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float); info->ring_buffer = STBIR__NEXT_MEMPTR(info->horizontal_buffer, float); info->encode_buffer = NULL; STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->ring_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes); } #undef STBIR__NEXT_MEMPTR // This signals that the ring buffer is empty info->ring_buffer_begin_index = -1; stbir__calculate_filters(info->horizontal_contributors, info->horizontal_coefficients, info->horizontal_filter, info->horizontal_scale, info->horizontal_shift, info->input_w, info->output_w); stbir__calculate_filters(info->vertical_contributors, info->vertical_coefficients, info->vertical_filter, info->vertical_scale, info->vertical_shift, info->input_h, info->output_h); STBIR_PROGRESS_REPORT(0); if (stbir__use_height_upsampling(info)) stbir__buffer_loop_upsample(info); else stbir__buffer_loop_downsample(info); STBIR_PROGRESS_REPORT(1); #ifdef STBIR_DEBUG_OVERWRITE_TEST STBIR_ASSERT(memcmp(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0); STBIR_ASSERT(memcmp(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE) == 0); STBIR_ASSERT(memcmp(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0); STBIR_ASSERT(memcmp(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE) == 0); #endif return 1; } static int stbir__resize_arbitrary( void *alloc_context, const void* input_data, int input_w, int input_h, int input_stride_in_bytes, void* output_data, int output_w, int output_h, int output_stride_in_bytes, float s0, float t0, float s1, float t1, float *transform, int channels, int alpha_channel, stbir_uint32 flags, stbir_datatype type, stbir_filter h_filter, stbir_filter v_filter, stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace) { stbir__info info; int result; size_t memory_required; void* extra_memory; stbir__setup(&info, input_w, input_h, output_w, output_h, channels); stbir__calculate_transform(&info, s0,t0,s1,t1,transform); stbir__choose_filter(&info, h_filter, v_filter); memory_required = stbir__calculate_memory(&info); extra_memory = STBIR_MALLOC(memory_required, alloc_context); if (!extra_memory) return 0; result = stbir__resize_allocated(&info, input_data, input_stride_in_bytes, output_data, output_stride_in_bytes, alpha_channel, flags, type, edge_horizontal, edge_vertical, colorspace, extra_memory, memory_required); STBIR_FREE(extra_memory, alloc_context); return result; } STBIRDEF int stbir_resize_uint8( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels) { return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR); } STBIRDEF int stbir_resize_float( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, float *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels) { return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_FLOAT, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR); } STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags) { return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB); } STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode) { return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, edge_wrap_mode, edge_wrap_mode, STBIR_COLORSPACE_SRGB); } STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, filter, filter, edge_wrap_mode, edge_wrap_mode, space); } STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels , int input_w , int input_h , int input_stride_in_bytes, stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT16, filter, filter, edge_wrap_mode, edge_wrap_mode, space); } STBIRDEF int stbir_resize_float_generic( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, float *output_pixels , int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_FLOAT, filter, filter, edge_wrap_mode, edge_wrap_mode, space); } STBIRDEF int stbir_resize( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, edge_mode_horizontal, edge_mode_vertical, space); } STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context, float x_scale, float y_scale, float x_offset, float y_offset) { float transform[4]; transform[0] = x_scale; transform[1] = y_scale; transform[2] = x_offset; transform[3] = y_offset; return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,transform,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, edge_mode_horizontal, edge_mode_vertical, space); } STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context, float s0, float t0, float s1, float t1) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, s0,t0,s1,t1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, edge_mode_horizontal, edge_mode_vertical, space); } #endif // STB_IMAGE_RESIZE_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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_image.h0000600000175000001440000075175514003056224016535 0ustar rakusers/* stb_image - v2.16 - public domain image loader - http://nothings.org/stb_image.h no warranty implied; use at your own risk Do this: #define STB_IMAGE_IMPLEMENTATION before you include this file in *one* C or C++ file to create the implementation. // i.e. it should look like this: #include ... #include ... #include ... #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free QUICK NOTES: Primarily of interest to game developers and other people who can avoid problematic images and only need the trivial interface JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) PNG 1/2/4/8/16-bit-per-channel TGA (not sure what subset, if a subset) BMP non-1bpp, non-RLE PSD (composited view only, no extra channels, 8/16 bit-per-channel) GIF (*comp always reports as 4-channel) HDR (radiance rgbE format) PIC (Softimage PIC) PNM (PPM and PGM binary only) Animated GIF still needs a proper API, but here's one way to do it: http://gist.github.com/urraka/685d9a6340b26b830d49 - decode from memory or through FILE (define STBI_NO_STDIO to remove code) - decode from arbitrary I/O callbacks - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) Full documentation under "DOCUMENTATION" below. LICENSE See end of file for license information. RECENT REVISION HISTORY: 2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes 2.15 (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs 2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes 2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64 RGB-format JPEG; remove white matting in PSD; allocate large structures on the stack; correct channel count for PNG & BMP 2.10 (2016-01-22) avoid warning introduced in 2.09 2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED See end of file for full revision history. ============================ Contributors ========================= Image formats Extensions, features Sean Barrett (jpeg, png, bmp) Jetro Lauha (stbi_info) Nicolas Schulz (hdr, psd) Martin "SpartanJ" Golini (stbi_info) Jonathan Dummer (tga) James "moose2000" Brown (iPhone PNG) Jean-Marc Lienher (gif) Ben "Disch" Wenger (io callbacks) Tom Seddon (pic) Omar Cornut (1/2/4-bit PNG) Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) github:urraka (animated gif) Junggon Kim (PNM comments) Daniel Gibson (16-bit TGA) socks-the-fox (16-bit PNG) Jeremy Sawicki (handle all ImageNet JPGs) Optimizations & bugfixes Fabian "ryg" Giesen Arseny Kapoulkine John-Mark Allen Bug & warning fixes Marc LeBlanc David Woo Guillaume George Martins Mozeiko Christpher Lloyd Jerry Jansson Joseph Thomson Phil Jordan Dave Moore Roy Eltham Hayaki Saito Nathan Reed Won Chun Luke Graham Johan Duparc Nick Verigakis the Horde3D community Thomas Ruf Ronny Chevalier Baldur Karlsson Janez Zemva John Bartholomew Michal Cichon github:rlyeh Jonathan Blow Ken Hamada Tero Hanninen github:romigrou Laurent Gomila Cort Stratton Sergio Gonzalez github:svdijk Aruelien Pocheville Thibault Reuille Cass Everitt github:snagar Ryamond Barbiero Paul Du Bois Engin Manap github:Zelex Michaelangel007@github Philipp Wiesemann Dale Weiler github:grim210 Oriol Ferrer Mesia Josh Tobin Matthew Gregan github:sammyhw Blazej Dariusz Roszkowski Gregory Mullen github:phprus Christian Floisand Kevin Schmidt github:poppolopoppo */ #ifndef STBI_INCLUDE_STB_IMAGE_H #define STBI_INCLUDE_STB_IMAGE_H // DOCUMENTATION // // Limitations: // - no 16-bit-per-channel PNG // - no 12-bit-per-channel JPEG // - no JPEGs with arithmetic coding // - no 1-bit BMP // - GIF always returns *comp=4 // // Basic usage (see HDR discussion below for HDR usage): // int x,y,n; // unsigned char *data = stbi_load(filename, &x, &y, &n, 0); // // ... process data if not NULL ... // // ... x = width, y = height, n = # 8-bit components per pixel ... // // ... replace '0' with '1'..'4' to force that many components per pixel // // ... but 'n' will always be the number that it would have been if you said 0 // stbi_image_free(data) // // Standard parameters: // int *x -- outputs image width in pixels // int *y -- outputs image height in pixels // int *channels_in_file -- outputs # of image components in image file // int desired_channels -- if non-zero, # of image components requested in result // // The return value from an image loader is an 'unsigned char *' which points // to the pixel data, or NULL on an allocation failure or if the image is // corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, // with each pixel consisting of N interleaved 8-bit components; the first // pixel pointed to is top-left-most in the image. There is no padding between // image scanlines or between pixels, regardless of format. The number of // components N is 'desired_channels' if desired_channels is non-zero, or // *channels_in_file otherwise. If desired_channels is non-zero, // *channels_in_file has the number of components that _would_ have been // output otherwise. E.g. if you set desired_channels to 4, you will always // get RGBA output, but you can check *channels_in_file to see if it's trivially // opaque because e.g. there were only 3 channels in the source image. // // An output image with N components has the following components interleaved // in this order in each pixel: // // N=#comp components // 1 grey // 2 grey, alpha // 3 red, green, blue // 4 red, green, blue, alpha // // If image loading fails for any reason, the return value will be NULL, // and *x, *y, *channels_in_file will be unchanged. The function // stbi_failure_reason() can be queried for an extremely brief, end-user // unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS // to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly // more user-friendly ones. // // Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. // // =========================================================================== // // Philosophy // // stb libraries are designed with the following priorities: // // 1. easy to use // 2. easy to maintain // 3. good performance // // Sometimes I let "good performance" creep up in priority over "easy to maintain", // and for best performance I may provide less-easy-to-use APIs that give higher // performance, in addition to the easy to use ones. Nevertheless, it's important // to keep in mind that from the standpoint of you, a client of this library, // all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all. // // Some secondary priorities arise directly from the first two, some of which // make more explicit reasons why performance can't be emphasized. // // - Portable ("ease of use") // - Small source code footprint ("easy to maintain") // - No dependencies ("ease of use") // // =========================================================================== // // I/O callbacks // // I/O callbacks allow you to read from arbitrary sources, like packaged // files or some other source. Data read from callbacks are processed // through a small internal buffer (currently 128 bytes) to try to reduce // overhead. // // The three functions you must define are "read" (reads some bytes of data), // "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). // // =========================================================================== // // SIMD support // // The JPEG decoder will try to automatically use SIMD kernels on x86 when // supported by the compiler. For ARM Neon support, you must explicitly // request it. // // (The old do-it-yourself SIMD API is no longer supported in the current // code.) // // On x86, SSE2 will automatically be used when available based on a run-time // test; if not, the generic C versions are used as a fall-back. On ARM targets, // the typical path is to have separate builds for NEON and non-NEON devices // (at least this is true for iOS and Android). Therefore, the NEON support is // toggled by a build flag: define STBI_NEON to get NEON loops. // // If for some reason you do not want to use any of SIMD code, or if // you have issues compiling it, you can disable it entirely by // defining STBI_NO_SIMD. // // =========================================================================== // // HDR image support (disable by defining STBI_NO_HDR) // // stb_image now supports loading HDR images in general, and currently // the Radiance .HDR file format, although the support is provided // generically. You can still load any file through the existing interface; // if you attempt to load an HDR file, it will be automatically remapped to // LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; // both of these constants can be reconfigured through this interface: // // stbi_hdr_to_ldr_gamma(2.2f); // stbi_hdr_to_ldr_scale(1.0f); // // (note, do not use _inverse_ constants; stbi_image will invert them // appropriately). // // Additionally, there is a new, parallel interface for loading files as // (linear) floats to preserve the full dynamic range: // // float *data = stbi_loadf(filename, &x, &y, &n, 0); // // If you load LDR images through this interface, those images will // be promoted to floating point values, run through the inverse of // constants corresponding to the above: // // stbi_ldr_to_hdr_scale(1.0f); // stbi_ldr_to_hdr_gamma(2.2f); // // Finally, given a filename (or an open file or memory block--see header // file for details) containing image data, you can query for the "most // appropriate" interface to use (that is, whether the image is HDR or // not), using: // // stbi_is_hdr(char *filename); // // =========================================================================== // // iPhone PNG support: // // By default we convert iphone-formatted PNGs back to RGB, even though // they are internally encoded differently. You can disable this conversion // by by calling stbi_convert_iphone_png_to_rgb(0), in which case // you will always just get the native iphone "format" through (which // is BGR stored in RGB). // // Call stbi_set_unpremultiply_on_load(1) as well to force a divide per // pixel to remove any premultiplied alpha *only* if the image file explicitly // says there's premultiplied data (currently only happens in iPhone images, // and only if iPhone convert-to-rgb processing is on). // // =========================================================================== // // ADDITIONAL CONFIGURATION // // - You can suppress implementation of any of the decoders to reduce // your code footprint by #defining one or more of the following // symbols before creating the implementation. // // STBI_NO_JPEG // STBI_NO_PNG // STBI_NO_BMP // STBI_NO_PSD // STBI_NO_TGA // STBI_NO_GIF // STBI_NO_HDR // STBI_NO_PIC // STBI_NO_PNM (.ppm and .pgm) // // - You can request *only* certain decoders and suppress all other ones // (this will be more forward-compatible, as addition of new decoders // doesn't require you to disable them explicitly): // // STBI_ONLY_JPEG // STBI_ONLY_PNG // STBI_ONLY_BMP // STBI_ONLY_PSD // STBI_ONLY_TGA // STBI_ONLY_GIF // STBI_ONLY_HDR // STBI_ONLY_PIC // STBI_ONLY_PNM (.ppm and .pgm) // // - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still // want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB // #ifndef STBI_NO_STDIO #include #endif // STBI_NO_STDIO #define STBI_VERSION 1 enum { STBI_default = 0, // only used for desired_channels STBI_grey = 1, STBI_grey_alpha = 2, STBI_rgb = 3, STBI_rgb_alpha = 4 }; typedef unsigned char stbi_uc; typedef unsigned short stbi_us; #ifdef __cplusplus extern "C" { #endif #ifdef STB_IMAGE_STATIC #define STBIDEF static #else #define STBIDEF extern #endif ////////////////////////////////////////////////////////////////////////////// // // PRIMARY API - works on images of any type // // // load image by filename, open file, or memory buffer // typedef struct { int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative int (*eof) (void *user); // returns nonzero if we are at end of file/data } stbi_io_callbacks; //////////////////////////////////// // // 8-bits-per-channel interface // STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); // for stbi_load_from_file, file pointer is left pointing immediately after image #endif //////////////////////////////////// // // 16-bits-per-channel interface // STBIDEF stbi_us *stbi_load_16_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF stbi_us *stbi_load_16 (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); #endif //////////////////////////////////// // // float-per-channel interface // #ifndef STBI_NO_LINEAR STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); #endif #endif #ifndef STBI_NO_HDR STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); STBIDEF void stbi_hdr_to_ldr_scale(float scale); #endif // STBI_NO_HDR #ifndef STBI_NO_LINEAR STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); STBIDEF void stbi_ldr_to_hdr_scale(float scale); #endif // STBI_NO_LINEAR // stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); #ifndef STBI_NO_STDIO STBIDEF int stbi_is_hdr (char const *filename); STBIDEF int stbi_is_hdr_from_file(FILE *f); #endif // STBI_NO_STDIO // get a VERY brief reason for failure // NOT THREADSAFE STBIDEF const char *stbi_failure_reason (void); // free the loaded image -- this is just free() STBIDEF void stbi_image_free (void *retval_from_stbi_load); // get image dimensions & components without fully decoding STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); #ifndef STBI_NO_STDIO STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); #endif // for image formats that explicitly notate that they have premultiplied alpha, // we just return the colors as stored in the file. set this flag to force // unpremultiplication. results are undefined if the unpremultiply overflow. STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); // indicate whether we should process iphone images back to canonical format, // or just pass them through "as-is" STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); // flip the image vertically, so the first pixel in the output array is the bottom left STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); // ZLIB client - used by PNG, available for other purposes STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); #ifdef __cplusplus } #endif // // //// end header file ///////////////////////////////////////////////////// #endif // STBI_INCLUDE_STB_IMAGE_H #ifdef STB_IMAGE_IMPLEMENTATION #if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ || defined(STBI_ONLY_ZLIB) #ifndef STBI_ONLY_JPEG #define STBI_NO_JPEG #endif #ifndef STBI_ONLY_PNG #define STBI_NO_PNG #endif #ifndef STBI_ONLY_BMP #define STBI_NO_BMP #endif #ifndef STBI_ONLY_PSD #define STBI_NO_PSD #endif #ifndef STBI_ONLY_TGA #define STBI_NO_TGA #endif #ifndef STBI_ONLY_GIF #define STBI_NO_GIF #endif #ifndef STBI_ONLY_HDR #define STBI_NO_HDR #endif #ifndef STBI_ONLY_PIC #define STBI_NO_PIC #endif #ifndef STBI_ONLY_PNM #define STBI_NO_PNM #endif #endif #if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) #define STBI_NO_ZLIB #endif #include #include // ptrdiff_t on osx #include #include #include #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) #include // ldexp #endif #ifndef STBI_NO_STDIO #include #endif #ifndef STBI_ASSERT #include #define STBI_ASSERT(x) assert(x) #endif #ifndef _MSC_VER #ifdef __cplusplus #define stbi_inline inline #else #define stbi_inline #endif #else #define stbi_inline __forceinline #endif #ifdef _MSC_VER typedef unsigned short stbi__uint16; typedef signed short stbi__int16; typedef unsigned int stbi__uint32; typedef signed int stbi__int32; #else #include typedef uint16_t stbi__uint16; typedef int16_t stbi__int16; typedef uint32_t stbi__uint32; typedef int32_t stbi__int32; #endif // should produce compiler error if size is wrong typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; #ifdef _MSC_VER #define STBI_NOTUSED(v) (void)(v) #else #define STBI_NOTUSED(v) (void)sizeof(v) #endif #ifdef _MSC_VER #define STBI_HAS_LROTL #endif #ifdef STBI_HAS_LROTL #define stbi_lrot(x,y) _lrotl(x,y) #else #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) #endif #if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) // ok #elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) // ok #else #error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." #endif #ifndef STBI_MALLOC #define STBI_MALLOC(sz) malloc(sz) #define STBI_REALLOC(p,newsz) realloc(p,newsz) #define STBI_FREE(p) free(p) #endif #ifndef STBI_REALLOC_SIZED #define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz) #endif // x86/x64 detection #if defined(__x86_64__) || defined(_M_X64) #define STBI__X64_TARGET #elif defined(__i386) || defined(_M_IX86) #define STBI__X86_TARGET #endif #if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) // gcc doesn't support sse2 intrinsics unless you compile with -msse2, // which in turn means it gets to use SSE2 everywhere. This is unfortunate, // but previous attempts to provide the SSE2 functions with runtime // detection caused numerous issues. The way architecture extensions are // exposed in GCC/Clang is, sadly, not really suited for one-file libs. // New behavior: if compiled with -msse2, we use SSE2 without any // detection; if not, we don't use it at all. #define STBI_NO_SIMD #endif #if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) // Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET // // 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the // Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. // As a result, enabling SSE2 on 32-bit MinGW is dangerous when not // simultaneously enabling "-mstackrealign". // // See https://github.com/nothings/stb/issues/81 for more information. // // So default to no SSE2 on 32-bit MinGW. If you've read this far and added // -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. #define STBI_NO_SIMD #endif #if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) #define STBI_SSE2 #include #ifdef _MSC_VER #if _MSC_VER >= 1400 // not VC6 #include // __cpuid static int stbi__cpuid3(void) { int info[4]; __cpuid(info,1); return info[3]; } #else static int stbi__cpuid3(void) { int res; __asm { mov eax,1 cpuid mov res,edx } return res; } #endif #define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name static int stbi__sse2_available(void) { int info3 = stbi__cpuid3(); return ((info3 >> 26) & 1) != 0; } #else // assume GCC-style if not VC++ #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) static int stbi__sse2_available(void) { // If we're even attempting to compile this on GCC/Clang, that means // -msse2 is on, which means the compiler is allowed to use SSE2 // instructions at will, and so are we. return 1; } #endif #endif // ARM NEON #if defined(STBI_NO_SIMD) && defined(STBI_NEON) #undef STBI_NEON #endif #ifdef STBI_NEON #include // assume GCC or Clang on ARM targets #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) #endif #ifndef STBI_SIMD_ALIGN #define STBI_SIMD_ALIGN(type, name) type name #endif /////////////////////////////////////////////// // // stbi__context struct and start_xxx functions // stbi__context structure is our basic context used by all images, so it // contains all the IO context, plus some basic image information typedef struct { stbi__uint32 img_x, img_y; int img_n, img_out_n; stbi_io_callbacks io; void *io_user_data; int read_from_callbacks; int buflen; stbi_uc buffer_start[128]; stbi_uc *img_buffer, *img_buffer_end; stbi_uc *img_buffer_original, *img_buffer_original_end; } stbi__context; static void stbi__refill_buffer(stbi__context *s); // initialize a memory-decode context static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) { s->io.read = NULL; s->read_from_callbacks = 0; s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer; s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len; } // initialize a callback-based context static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) { s->io = *c; s->io_user_data = user; s->buflen = sizeof(s->buffer_start); s->read_from_callbacks = 1; s->img_buffer_original = s->buffer_start; stbi__refill_buffer(s); s->img_buffer_original_end = s->img_buffer_end; } #ifndef STBI_NO_STDIO static int stbi__stdio_read(void *user, char *data, int size) { return (int) fread(data,1,size,(FILE*) user); } static void stbi__stdio_skip(void *user, int n) { fseek((FILE*) user, n, SEEK_CUR); } static int stbi__stdio_eof(void *user) { return feof((FILE*) user); } static stbi_io_callbacks stbi__stdio_callbacks = { stbi__stdio_read, stbi__stdio_skip, stbi__stdio_eof, }; static void stbi__start_file(stbi__context *s, FILE *f) { stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f); } //static void stop_file(stbi__context *s) { } #endif // !STBI_NO_STDIO static void stbi__rewind(stbi__context *s) { // conceptually rewind SHOULD rewind to the beginning of the stream, // but we just rewind to the beginning of the initial buffer, because // we only use it after doing 'test', which only ever looks at at most 92 bytes s->img_buffer = s->img_buffer_original; s->img_buffer_end = s->img_buffer_original_end; } enum { STBI_ORDER_RGB, STBI_ORDER_BGR }; typedef struct { int bits_per_channel; int num_channels; int channel_order; } stbi__result_info; #ifndef STBI_NO_JPEG static int stbi__jpeg_test(stbi__context *s); static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNG static int stbi__png_test(stbi__context *s); static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_BMP static int stbi__bmp_test(stbi__context *s); static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_TGA static int stbi__tga_test(stbi__context *s); static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PSD static int stbi__psd_test(stbi__context *s); static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc); static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_HDR static int stbi__hdr_test(stbi__context *s); static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PIC static int stbi__pic_test(stbi__context *s); static void *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_GIF static int stbi__gif_test(stbi__context *s); static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNM static int stbi__pnm_test(stbi__context *s); static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); #endif // this is not threadsafe static const char *stbi__g_failure_reason; STBIDEF const char *stbi_failure_reason(void) { return stbi__g_failure_reason; } static int stbi__err(const char *str) { stbi__g_failure_reason = str; return 0; } static void *stbi__malloc(size_t size) { return STBI_MALLOC(size); } // stb_image uses ints pervasively, including for offset calculations. // therefore the largest decoded image size we can support with the // current code, even on 64-bit targets, is INT_MAX. this is not a // significant limitation for the intended use case. // // we do, however, need to make sure our size calculations don't // overflow. hence a few helper functions for size calculations that // multiply integers together, making sure that they're non-negative // and no overflow occurs. // return 1 if the sum is valid, 0 on overflow. // negative terms are considered invalid. static int stbi__addsizes_valid(int a, int b) { if (b < 0) return 0; // now 0 <= b <= INT_MAX, hence also // 0 <= INT_MAX - b <= INTMAX. // And "a + b <= INT_MAX" (which might overflow) is the // same as a <= INT_MAX - b (no overflow) return a <= INT_MAX - b; } // returns 1 if the product is valid, 0 on overflow. // negative factors are considered invalid. static int stbi__mul2sizes_valid(int a, int b) { if (a < 0 || b < 0) return 0; if (b == 0) return 1; // mul-by-0 is always safe // portable way to check for no overflows in a*b return a <= INT_MAX/b; } // returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow static int stbi__mad2sizes_valid(int a, int b, int add) { return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add); } // returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow static int stbi__mad3sizes_valid(int a, int b, int c, int add) { return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && stbi__addsizes_valid(a*b*c, add); } // returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) { return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add); } // mallocs with size overflow checking static void *stbi__malloc_mad2(int a, int b, int add) { if (!stbi__mad2sizes_valid(a, b, add)) return NULL; return stbi__malloc(a*b + add); } static void *stbi__malloc_mad3(int a, int b, int c, int add) { if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL; return stbi__malloc(a*b*c + add); } static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) { if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL; return stbi__malloc(a*b*c*d + add); } // stbi__err - error // stbi__errpf - error returning pointer to float // stbi__errpuc - error returning pointer to unsigned char #ifdef STBI_NO_FAILURE_STRINGS #define stbi__err(x,y) 0 #elif defined(STBI_FAILURE_USERMSG) #define stbi__err(x,y) stbi__err(y) #else #define stbi__err(x,y) stbi__err(x) #endif #define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) #define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) STBIDEF void stbi_image_free(void *retval_from_stbi_load) { STBI_FREE(retval_from_stbi_load); } #ifndef STBI_NO_LINEAR static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); #endif #ifndef STBI_NO_HDR static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); #endif static int stbi__vertically_flip_on_load = 0; STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) { stbi__vertically_flip_on_load = flag_true_if_should_flip; } static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) { memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order ri->num_channels = 0; #ifndef STBI_NO_JPEG if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PNG if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_BMP if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_GIF if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PSD if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc); #endif #ifndef STBI_NO_PIC if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PNM if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_HDR if (stbi__hdr_test(s)) { float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri); return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); } #endif #ifndef STBI_NO_TGA // test tga last because it's a crappy test! if (stbi__tga_test(s)) return stbi__tga_load(s,x,y,comp,req_comp, ri); #endif return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); } static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels) { int i; int img_len = w * h * channels; stbi_uc *reduced; reduced = (stbi_uc *) stbi__malloc(img_len); if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory"); for (i = 0; i < img_len; ++i) reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling STBI_FREE(orig); return reduced; } static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) { int i; int img_len = w * h * channels; stbi__uint16 *enlarged; enlarged = (stbi__uint16 *) stbi__malloc(img_len*2); if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); for (i = 0; i < img_len; ++i) enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff STBI_FREE(orig); return enlarged; } static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) { int row; size_t bytes_per_row = (size_t)w * bytes_per_pixel; stbi_uc temp[2048]; stbi_uc *bytes = (stbi_uc *)image; for (row = 0; row < (h>>1); row++) { stbi_uc *row0 = bytes + row*bytes_per_row; stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row; // swap row0 with row1 size_t bytes_left = bytes_per_row; while (bytes_left) { size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp); memcpy(temp, row0, bytes_copy); memcpy(row0, row1, bytes_copy); memcpy(row1, temp, bytes_copy); row0 += bytes_copy; row1 += bytes_copy; bytes_left -= bytes_copy; } } } static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi__result_info ri; void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); if (result == NULL) return NULL; if (ri.bits_per_channel != 8) { STBI_ASSERT(ri.bits_per_channel == 16); result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp); ri.bits_per_channel = 8; } // @TODO: move stbi__convert_format to here if (stbi__vertically_flip_on_load) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); } return (unsigned char *) result; } static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi__result_info ri; void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16); if (result == NULL) return NULL; if (ri.bits_per_channel != 16) { STBI_ASSERT(ri.bits_per_channel == 8); result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp); ri.bits_per_channel = 16; } // @TODO: move stbi__convert_format16 to here // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision if (stbi__vertically_flip_on_load) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16)); } return (stbi__uint16 *) result; } #ifndef STBI_NO_HDR static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) { if (stbi__vertically_flip_on_load && result != NULL) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(float)); } } #endif #ifndef STBI_NO_STDIO static FILE *stbi__fopen(char const *filename, char const *mode) { FILE *f; #if defined(_MSC_VER) && _MSC_VER >= 1400 if (0 != fopen_s(&f, filename, mode)) f=0; #else f = fopen(filename, mode); #endif return f; } STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) { FILE *f = stbi__fopen(filename, "rb"); unsigned char *result; if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); result = stbi_load_from_file(f,x,y,comp,req_comp); fclose(f); return result; } STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { unsigned char *result; stbi__context s; stbi__start_file(&s,f); result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); } return result; } STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp) { stbi__uint16 *result; stbi__context s; stbi__start_file(&s,f); result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); } return result; } STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp) { FILE *f = stbi__fopen(filename, "rb"); stbi__uint16 *result; if (!f) return (stbi_us *) stbi__errpuc("can't fopen", "Unable to open file"); result = stbi_load_from_file_16(f,x,y,comp,req_comp); fclose(f); return result; } #endif //!STBI_NO_STDIO STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); } STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); } STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); } STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); } #ifndef STBI_NO_LINEAR static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) { unsigned char *data; #ifndef STBI_NO_HDR if (stbi__hdr_test(s)) { stbi__result_info ri; float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri); if (hdr_data) stbi__float_postprocess(hdr_data,x,y,comp,req_comp); return hdr_data; } #endif data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp); if (data) return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); } STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__loadf_main(&s,x,y,comp,req_comp); } STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__loadf_main(&s,x,y,comp,req_comp); } #ifndef STBI_NO_STDIO STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) { float *result; FILE *f = stbi__fopen(filename, "rb"); if (!f) return stbi__errpf("can't fopen", "Unable to open file"); result = stbi_loadf_from_file(f,x,y,comp,req_comp); fclose(f); return result; } STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_file(&s,f); return stbi__loadf_main(&s,x,y,comp,req_comp); } #endif // !STBI_NO_STDIO #endif // !STBI_NO_LINEAR // these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is // defined, for API simplicity; if STBI_NO_LINEAR is defined, it always // reports false! STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__hdr_test(&s); #else STBI_NOTUSED(buffer); STBI_NOTUSED(len); return 0; #endif } #ifndef STBI_NO_STDIO STBIDEF int stbi_is_hdr (char const *filename) { FILE *f = stbi__fopen(filename, "rb"); int result=0; if (f) { result = stbi_is_hdr_from_file(f); fclose(f); } return result; } STBIDEF int stbi_is_hdr_from_file(FILE *f) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_file(&s,f); return stbi__hdr_test(&s); #else STBI_NOTUSED(f); return 0; #endif } #endif // !STBI_NO_STDIO STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__hdr_test(&s); #else STBI_NOTUSED(clbk); STBI_NOTUSED(user); return 0; #endif } #ifndef STBI_NO_LINEAR static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } #endif static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } ////////////////////////////////////////////////////////////////////////////// // // Common code used by all image loaders // enum { STBI__SCAN_load=0, STBI__SCAN_type, STBI__SCAN_header }; static void stbi__refill_buffer(stbi__context *s) { int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); if (n == 0) { // at end of file, treat same as if from memory, but need to handle case // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file s->read_from_callbacks = 0; s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start+1; *s->img_buffer = 0; } else { s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start + n; } } stbi_inline static stbi_uc stbi__get8(stbi__context *s) { if (s->img_buffer < s->img_buffer_end) return *s->img_buffer++; if (s->read_from_callbacks) { stbi__refill_buffer(s); return *s->img_buffer++; } return 0; } stbi_inline static int stbi__at_eof(stbi__context *s) { if (s->io.read) { if (!(s->io.eof)(s->io_user_data)) return 0; // if feof() is true, check if buffer = end // special case: we've only got the special 0 character at the end if (s->read_from_callbacks == 0) return 1; } return s->img_buffer >= s->img_buffer_end; } static void stbi__skip(stbi__context *s, int n) { if (n < 0) { s->img_buffer = s->img_buffer_end; return; } if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { s->img_buffer = s->img_buffer_end; (s->io.skip)(s->io_user_data, n - blen); return; } } s->img_buffer += n; } static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) { if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { int res, count; memcpy(buffer, s->img_buffer, blen); count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); res = (count == (n-blen)); s->img_buffer = s->img_buffer_end; return res; } } if (s->img_buffer+n <= s->img_buffer_end) { memcpy(buffer, s->img_buffer, n); s->img_buffer += n; return 1; } else return 0; } static int stbi__get16be(stbi__context *s) { int z = stbi__get8(s); return (z << 8) + stbi__get8(s); } static stbi__uint32 stbi__get32be(stbi__context *s) { stbi__uint32 z = stbi__get16be(s); return (z << 16) + stbi__get16be(s); } #if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) // nothing #else static int stbi__get16le(stbi__context *s) { int z = stbi__get8(s); return z + (stbi__get8(s) << 8); } #endif #ifndef STBI_NO_BMP static stbi__uint32 stbi__get32le(stbi__context *s) { stbi__uint32 z = stbi__get16le(s); return z + (stbi__get16le(s) << 16); } #endif #define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings ////////////////////////////////////////////////////////////////////////////// // // generic converter from built-in img_n to req_comp // individual types do this automatically as much as possible (e.g. jpeg // does all cases internally since it needs to colorspace convert anyway, // and it never has alpha, so very few cases ). png can automatically // interleave an alpha=255 channel, but falls back to this for other cases // // assume data buffer is malloced, so malloc a new one and free that one // only failure mode is malloc failing static stbi_uc stbi__compute_y(int r, int g, int b) { return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); } static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) { int i,j; unsigned char *good; if (req_comp == img_n) return data; STBI_ASSERT(req_comp >= 1 && req_comp <= 4); good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0); if (good == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } for (j=0; j < (int) y; ++j) { unsigned char *src = data + j * x * img_n ; unsigned char *dest = good + j * x * req_comp; #define STBI__COMBO(a,b) ((a)*8+(b)) #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) // convert source image with img_n components to one with req_comp components; // avoid switch per pixel, so use switch per scanline and massive macros switch (STBI__COMBO(img_n, req_comp)) { STBI__CASE(1,2) { dest[0]=src[0], dest[1]=255; } break; STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; } break; STBI__CASE(2,1) { dest[0]=src[0]; } break; STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; } break; STBI__CASE(3,4) { dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; } break; STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = 255; } break; STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = src[3]; } break; STBI__CASE(4,3) { dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; } break; default: STBI_ASSERT(0); } #undef STBI__CASE } STBI_FREE(data); return good; } static stbi__uint16 stbi__compute_y_16(int r, int g, int b) { return (stbi__uint16) (((r*77) + (g*150) + (29*b)) >> 8); } static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y) { int i,j; stbi__uint16 *good; if (req_comp == img_n) return data; STBI_ASSERT(req_comp >= 1 && req_comp <= 4); good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2); if (good == NULL) { STBI_FREE(data); return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); } for (j=0; j < (int) y; ++j) { stbi__uint16 *src = data + j * x * img_n ; stbi__uint16 *dest = good + j * x * req_comp; #define STBI__COMBO(a,b) ((a)*8+(b)) #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) // convert source image with img_n components to one with req_comp components; // avoid switch per pixel, so use switch per scanline and massive macros switch (STBI__COMBO(img_n, req_comp)) { STBI__CASE(1,2) { dest[0]=src[0], dest[1]=0xffff; } break; STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0], dest[3]=0xffff; } break; STBI__CASE(2,1) { dest[0]=src[0]; } break; STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; } break; STBI__CASE(3,4) { dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=0xffff; } break; STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]), dest[1] = 0xffff; } break; STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]), dest[1] = src[3]; } break; STBI__CASE(4,3) { dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; } break; default: STBI_ASSERT(0); } #undef STBI__CASE } STBI_FREE(data); return good; } #ifndef STBI_NO_LINEAR static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) { int i,k,n; float *output; if (!data) return NULL; output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0); if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); } if (k < comp) output[i*comp + k] = data[i*comp+k]/255.0f; } STBI_FREE(data); return output; } #endif #ifndef STBI_NO_HDR #define stbi__float2int(x) ((int) (x)) static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) { int i,k,n; stbi_uc *output; if (!data) return NULL; output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0); if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi_uc) stbi__float2int(z); } if (k < comp) { float z = data[i*comp+k] * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi_uc) stbi__float2int(z); } } STBI_FREE(data); return output; } #endif ////////////////////////////////////////////////////////////////////////////// // // "baseline" JPEG/JFIF decoder // // simple implementation // - doesn't support delayed output of y-dimension // - simple interface (only one output format: 8-bit interleaved RGB) // - doesn't try to recover corrupt jpegs // - doesn't allow partial loading, loading multiple at once // - still fast on x86 (copying globals into locals doesn't help x86) // - allocates lots of intermediate memory (full size of all components) // - non-interleaved case requires this anyway // - allows good upsampling (see next) // high-quality // - upsampled channels are bilinearly interpolated, even across blocks // - quality integer IDCT derived from IJG's 'slow' // performance // - fast huffman; reasonable integer IDCT // - some SIMD kernels for common paths on targets with SSE2/NEON // - uses a lot of intermediate memory, could cache poorly #ifndef STBI_NO_JPEG // huffman decoding acceleration #define FAST_BITS 9 // larger handles more cases; smaller stomps less cache typedef struct { stbi_uc fast[1 << FAST_BITS]; // weirdly, repacking this into AoS is a 10% speed loss, instead of a win stbi__uint16 code[256]; stbi_uc values[256]; stbi_uc size[257]; unsigned int maxcode[18]; int delta[17]; // old 'firstsymbol' - old 'firstcode' } stbi__huffman; typedef struct { stbi__context *s; stbi__huffman huff_dc[4]; stbi__huffman huff_ac[4]; stbi__uint16 dequant[4][64]; stbi__int16 fast_ac[4][1 << FAST_BITS]; // sizes for components, interleaved MCUs int img_h_max, img_v_max; int img_mcu_x, img_mcu_y; int img_mcu_w, img_mcu_h; // definition of jpeg image component struct { int id; int h,v; int tq; int hd,ha; int dc_pred; int x,y,w2,h2; stbi_uc *data; void *raw_data, *raw_coeff; stbi_uc *linebuf; short *coeff; // progressive only int coeff_w, coeff_h; // number of 8x8 coefficient blocks } img_comp[4]; stbi__uint32 code_buffer; // jpeg entropy-coded buffer int code_bits; // number of valid bits unsigned char marker; // marker seen while filling entropy buffer int nomore; // flag if we saw a marker so must stop int progressive; int spec_start; int spec_end; int succ_high; int succ_low; int eob_run; int jfif; int app14_color_transform; // Adobe APP14 tag int rgb; int scan_n, order[4]; int restart_interval, todo; // kernels void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); } stbi__jpeg; static int stbi__build_huffman(stbi__huffman *h, int *count) { int i,j,k=0,code; // build size list for each symbol (from JPEG spec) for (i=0; i < 16; ++i) for (j=0; j < count[i]; ++j) h->size[k++] = (stbi_uc) (i+1); h->size[k] = 0; // compute actual symbols (from jpeg spec) code = 0; k = 0; for(j=1; j <= 16; ++j) { // compute delta to add to code to compute symbol id h->delta[j] = k - code; if (h->size[k] == j) { while (h->size[k] == j) h->code[k++] = (stbi__uint16) (code++); if (code-1 >= (1 << j)) return stbi__err("bad code lengths","Corrupt JPEG"); } // compute largest code + 1 for this size, preshifted as needed later h->maxcode[j] = code << (16-j); code <<= 1; } h->maxcode[j] = 0xffffffff; // build non-spec acceleration table; 255 is flag for not-accelerated memset(h->fast, 255, 1 << FAST_BITS); for (i=0; i < k; ++i) { int s = h->size[i]; if (s <= FAST_BITS) { int c = h->code[i] << (FAST_BITS-s); int m = 1 << (FAST_BITS-s); for (j=0; j < m; ++j) { h->fast[c+j] = (stbi_uc) i; } } } return 1; } // build a table that decodes both magnitude and value of small ACs in // one go. static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) { int i; for (i=0; i < (1 << FAST_BITS); ++i) { stbi_uc fast = h->fast[i]; fast_ac[i] = 0; if (fast < 255) { int rs = h->values[fast]; int run = (rs >> 4) & 15; int magbits = rs & 15; int len = h->size[fast]; if (magbits && len + magbits <= FAST_BITS) { // magnitude code followed by receive_extend code int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); int m = 1 << (magbits - 1); if (k < m) k += (~0U << magbits) + 1; // if the result is small enough, we can fit it in fast_ac table if (k >= -128 && k <= 127) fast_ac[i] = (stbi__int16) ((k << 8) + (run << 4) + (len + magbits)); } } } } static void stbi__grow_buffer_unsafe(stbi__jpeg *j) { do { int b = j->nomore ? 0 : stbi__get8(j->s); if (b == 0xff) { int c = stbi__get8(j->s); while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes if (c != 0) { j->marker = (unsigned char) c; j->nomore = 1; return; } } j->code_buffer |= b << (24 - j->code_bits); j->code_bits += 8; } while (j->code_bits <= 24); } // (1 << n) - 1 static stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; // decode a jpeg huffman value from the bitstream stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) { unsigned int temp; int c,k; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); // look at the top FAST_BITS and determine what symbol ID it is, // if the code is <= FAST_BITS c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); k = h->fast[c]; if (k < 255) { int s = h->size[k]; if (s > j->code_bits) return -1; j->code_buffer <<= s; j->code_bits -= s; return h->values[k]; } // naive test is to shift the code_buffer down so k bits are // valid, then test against maxcode. To speed this up, we've // preshifted maxcode left so that it has (16-k) 0s at the // end; in other words, regardless of the number of bits, it // wants to be compared against something shifted to have 16; // that way we don't need to shift inside the loop. temp = j->code_buffer >> 16; for (k=FAST_BITS+1 ; ; ++k) if (temp < h->maxcode[k]) break; if (k == 17) { // error! code not found j->code_bits -= 16; return -1; } if (k > j->code_bits) return -1; // convert the huffman code to the symbol id c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); // convert the id to a symbol j->code_bits -= k; j->code_buffer <<= k; return h->values[c]; } // bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB k = stbi_lrot(j->code_buffer, n); STBI_ASSERT(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))); j->code_buffer = k & ~stbi__bmask[n]; k &= stbi__bmask[n]; j->code_bits -= n; return k + (stbi__jbias[n] & ~sgn); } // get some unsigned bits stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) { unsigned int k; if (j->code_bits < n) stbi__grow_buffer_unsafe(j); k = stbi_lrot(j->code_buffer, n); j->code_buffer = k & ~stbi__bmask[n]; k &= stbi__bmask[n]; j->code_bits -= n; return k; } stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) { unsigned int k; if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); k = j->code_buffer; j->code_buffer <<= 1; --j->code_bits; return k & 0x80000000; } // given a value that's at position X in the zigzag stream, // where does it appear in the 8x8 matrix coded as row-major? static stbi_uc stbi__jpeg_dezigzag[64+15] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, // let corrupt input sample past end 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 }; // decode one 64-entry block-- static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant) { int diff,dc,k; int t; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); t = stbi__jpeg_huff_decode(j, hdc); if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); // 0 all the ac values now so we can do it 32-bits at a time memset(data,0,64*sizeof(data[0])); diff = t ? stbi__extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; data[0] = (short) (dc * dequant[0]); // decode AC components, see JPEG spec k = 1; do { unsigned int zig; int c,r,s; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) { // fast-AC path k += (r >> 4) & 15; // run s = r & 15; // combined length j->code_buffer <<= s; j->code_bits -= s; // decode into unzigzag'd location zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) * dequant[zig]); } else { int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (rs != 0xf0) break; // end block k += 16; } else { k += r; // decode into unzigzag'd location zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); } } } while (k < 64); return 1; } static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) { int diff,dc; int t; if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); if (j->succ_high == 0) { // first scan for DC coefficient, must be first memset(data,0,64*sizeof(data[0])); // 0 all the ac values now t = stbi__jpeg_huff_decode(j, hdc); diff = t ? stbi__extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; data[0] = (short) (dc << j->succ_low); } else { // refinement scan for DC coefficient if (stbi__jpeg_get_bit(j)) data[0] += (short) (1 << j->succ_low); } return 1; } // @OPTIMIZE: store non-zigzagged during the decode passes, // and only de-zigzag when dequantizing static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) { int k; if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); if (j->succ_high == 0) { int shift = j->succ_low; if (j->eob_run) { --j->eob_run; return 1; } k = j->spec_start; do { unsigned int zig; int c,r,s; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) { // fast-AC path k += (r >> 4) & 15; // run s = r & 15; // combined length j->code_buffer <<= s; j->code_bits -= s; zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) << shift); } else { int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r); if (r) j->eob_run += stbi__jpeg_get_bits(j, r); --j->eob_run; break; } k += 16; } else { k += r; zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) (stbi__extend_receive(j,s) << shift); } } } while (k <= j->spec_end); } else { // refinement scan for these AC coefficients short bit = (short) (1 << j->succ_low); if (j->eob_run) { --j->eob_run; for (k = j->spec_start; k <= j->spec_end; ++k) { short *p = &data[stbi__jpeg_dezigzag[k]]; if (*p != 0) if (stbi__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; else *p -= bit; } } } else { k = j->spec_start; do { int r,s; int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r) - 1; if (r) j->eob_run += stbi__jpeg_get_bits(j, r); r = 64; // force end of block } else { // r=15 s=0 should write 16 0s, so we just do // a run of 15 0s and then write s (which is 0), // so we don't have to do anything special here } } else { if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); // sign bit if (stbi__jpeg_get_bit(j)) s = bit; else s = -bit; } // advance by r while (k <= j->spec_end) { short *p = &data[stbi__jpeg_dezigzag[k++]]; if (*p != 0) { if (stbi__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; else *p -= bit; } } else { if (r == 0) { *p = (short) s; break; } --r; } } } while (k <= j->spec_end); } } return 1; } // take a -128..127 value and stbi__clamp it and convert to 0..255 stbi_inline static stbi_uc stbi__clamp(int x) { // trick to use a single test to catch both cases if ((unsigned int) x > 255) { if (x < 0) return 0; if (x > 255) return 255; } return (stbi_uc) x; } #define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) #define stbi__fsh(x) ((x) << 12) // derived from jidctint -- DCT_ISLOW #define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ p2 = s2; \ p3 = s6; \ p1 = (p2+p3) * stbi__f2f(0.5411961f); \ t2 = p1 + p3*stbi__f2f(-1.847759065f); \ t3 = p1 + p2*stbi__f2f( 0.765366865f); \ p2 = s0; \ p3 = s4; \ t0 = stbi__fsh(p2+p3); \ t1 = stbi__fsh(p2-p3); \ x0 = t0+t3; \ x3 = t0-t3; \ x1 = t1+t2; \ x2 = t1-t2; \ t0 = s7; \ t1 = s5; \ t2 = s3; \ t3 = s1; \ p3 = t0+t2; \ p4 = t1+t3; \ p1 = t0+t3; \ p2 = t1+t2; \ p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ t0 = t0*stbi__f2f( 0.298631336f); \ t1 = t1*stbi__f2f( 2.053119869f); \ t2 = t2*stbi__f2f( 3.072711026f); \ t3 = t3*stbi__f2f( 1.501321110f); \ p1 = p5 + p1*stbi__f2f(-0.899976223f); \ p2 = p5 + p2*stbi__f2f(-2.562915447f); \ p3 = p3*stbi__f2f(-1.961570560f); \ p4 = p4*stbi__f2f(-0.390180644f); \ t3 += p1+p4; \ t2 += p2+p3; \ t1 += p2+p4; \ t0 += p1+p3; static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) { int i,val[64],*v=val; stbi_uc *o; short *d = data; // columns for (i=0; i < 8; ++i,++d, ++v) { // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 && d[40]==0 && d[48]==0 && d[56]==0) { // no shortcut 0 seconds // (1|2|3|4|5|6|7)==0 0 seconds // all separate -0.047 seconds // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds int dcterm = d[0] << 2; v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; } else { STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) // constants scaled things up by 1<<12; let's bring them back // down, but keep 2 extra bits of precision x0 += 512; x1 += 512; x2 += 512; x3 += 512; v[ 0] = (x0+t3) >> 10; v[56] = (x0-t3) >> 10; v[ 8] = (x1+t2) >> 10; v[48] = (x1-t2) >> 10; v[16] = (x2+t1) >> 10; v[40] = (x2-t1) >> 10; v[24] = (x3+t0) >> 10; v[32] = (x3-t0) >> 10; } } for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { // no fast case since the first 1D IDCT spread components out STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) // constants scaled things up by 1<<12, plus we had 1<<2 from first // loop, plus horizontal and vertical each scale by sqrt(8) so together // we've got an extra 1<<3, so 1<<17 total we need to remove. // so we want to round that, which means adding 0.5 * 1<<17, // aka 65536. Also, we'll end up with -128 to 127 that we want // to encode as 0..255 by adding 128, so we'll add that before the shift x0 += 65536 + (128<<17); x1 += 65536 + (128<<17); x2 += 65536 + (128<<17); x3 += 65536 + (128<<17); // tried computing the shifts into temps, or'ing the temps to see // if any were out of range, but that was slower o[0] = stbi__clamp((x0+t3) >> 17); o[7] = stbi__clamp((x0-t3) >> 17); o[1] = stbi__clamp((x1+t2) >> 17); o[6] = stbi__clamp((x1-t2) >> 17); o[2] = stbi__clamp((x2+t1) >> 17); o[5] = stbi__clamp((x2-t1) >> 17); o[3] = stbi__clamp((x3+t0) >> 17); o[4] = stbi__clamp((x3-t0) >> 17); } } #ifdef STBI_SSE2 // sse2 integer IDCT. not the fastest possible implementation but it // produces bit-identical results to the generic C version so it's // fully "transparent". static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { // This is constructed to match our regular (generic) integer IDCT exactly. __m128i row0, row1, row2, row3, row4, row5, row6, row7; __m128i tmp; // dot product constant: even elems=x, odd elems=y #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) // out(1) = c1[even]*x + c1[odd]*y #define dct_rot(out0,out1, x,y,c0,c1) \ __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) // out = in << 12 (in 16-bit, out 32-bit) #define dct_widen(out, in) \ __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) // wide add #define dct_wadd(out, a, b) \ __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ __m128i out##_h = _mm_add_epi32(a##_h, b##_h) // wide sub #define dct_wsub(out, a, b) \ __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) // butterfly a/b, add bias, then shift by "s" and pack #define dct_bfly32o(out0, out1, a,b,bias,s) \ { \ __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ dct_wadd(sum, abiased, b); \ dct_wsub(dif, abiased, b); \ out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ } // 8-bit interleave step (for transposes) #define dct_interleave8(a, b) \ tmp = a; \ a = _mm_unpacklo_epi8(a, b); \ b = _mm_unpackhi_epi8(tmp, b) // 16-bit interleave step (for transposes) #define dct_interleave16(a, b) \ tmp = a; \ a = _mm_unpacklo_epi16(a, b); \ b = _mm_unpackhi_epi16(tmp, b) #define dct_pass(bias,shift) \ { \ /* even part */ \ dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ __m128i sum04 = _mm_add_epi16(row0, row4); \ __m128i dif04 = _mm_sub_epi16(row0, row4); \ dct_widen(t0e, sum04); \ dct_widen(t1e, dif04); \ dct_wadd(x0, t0e, t3e); \ dct_wsub(x3, t0e, t3e); \ dct_wadd(x1, t1e, t2e); \ dct_wsub(x2, t1e, t2e); \ /* odd part */ \ dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ __m128i sum17 = _mm_add_epi16(row1, row7); \ __m128i sum35 = _mm_add_epi16(row3, row5); \ dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ dct_wadd(x4, y0o, y4o); \ dct_wadd(x5, y1o, y5o); \ dct_wadd(x6, y2o, y5o); \ dct_wadd(x7, y3o, y4o); \ dct_bfly32o(row0,row7, x0,x7,bias,shift); \ dct_bfly32o(row1,row6, x1,x6,bias,shift); \ dct_bfly32o(row2,row5, x2,x5,bias,shift); \ dct_bfly32o(row3,row4, x3,x4,bias,shift); \ } __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); // rounding biases in column/row passes, see stbi__idct_block for explanation. __m128i bias_0 = _mm_set1_epi32(512); __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); // load row0 = _mm_load_si128((const __m128i *) (data + 0*8)); row1 = _mm_load_si128((const __m128i *) (data + 1*8)); row2 = _mm_load_si128((const __m128i *) (data + 2*8)); row3 = _mm_load_si128((const __m128i *) (data + 3*8)); row4 = _mm_load_si128((const __m128i *) (data + 4*8)); row5 = _mm_load_si128((const __m128i *) (data + 5*8)); row6 = _mm_load_si128((const __m128i *) (data + 6*8)); row7 = _mm_load_si128((const __m128i *) (data + 7*8)); // column pass dct_pass(bias_0, 10); { // 16bit 8x8 transpose pass 1 dct_interleave16(row0, row4); dct_interleave16(row1, row5); dct_interleave16(row2, row6); dct_interleave16(row3, row7); // transpose pass 2 dct_interleave16(row0, row2); dct_interleave16(row1, row3); dct_interleave16(row4, row6); dct_interleave16(row5, row7); // transpose pass 3 dct_interleave16(row0, row1); dct_interleave16(row2, row3); dct_interleave16(row4, row5); dct_interleave16(row6, row7); } // row pass dct_pass(bias_1, 17); { // pack __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 __m128i p1 = _mm_packus_epi16(row2, row3); __m128i p2 = _mm_packus_epi16(row4, row5); __m128i p3 = _mm_packus_epi16(row6, row7); // 8bit 8x8 transpose pass 1 dct_interleave8(p0, p2); // a0e0a1e1... dct_interleave8(p1, p3); // c0g0c1g1... // transpose pass 2 dct_interleave8(p0, p1); // a0c0e0g0... dct_interleave8(p2, p3); // b0d0f0h0... // transpose pass 3 dct_interleave8(p0, p2); // a0b0c0d0... dct_interleave8(p1, p3); // a4b4c4d4... // store _mm_storel_epi64((__m128i *) out, p0); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p2); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p1); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p3); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); } #undef dct_const #undef dct_rot #undef dct_widen #undef dct_wadd #undef dct_wsub #undef dct_bfly32o #undef dct_interleave8 #undef dct_interleave16 #undef dct_pass } #endif // STBI_SSE2 #ifdef STBI_NEON // NEON integer IDCT. should produce bit-identical // results to the generic C version. static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); #define dct_long_mul(out, inq, coeff) \ int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) #define dct_long_mac(out, acc, inq, coeff) \ int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) #define dct_widen(out, inq) \ int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) // wide add #define dct_wadd(out, a, b) \ int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ int32x4_t out##_h = vaddq_s32(a##_h, b##_h) // wide sub #define dct_wsub(out, a, b) \ int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ int32x4_t out##_h = vsubq_s32(a##_h, b##_h) // butterfly a/b, then shift using "shiftop" by "s" and pack #define dct_bfly32o(out0,out1, a,b,shiftop,s) \ { \ dct_wadd(sum, a, b); \ dct_wsub(dif, a, b); \ out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ } #define dct_pass(shiftop, shift) \ { \ /* even part */ \ int16x8_t sum26 = vaddq_s16(row2, row6); \ dct_long_mul(p1e, sum26, rot0_0); \ dct_long_mac(t2e, p1e, row6, rot0_1); \ dct_long_mac(t3e, p1e, row2, rot0_2); \ int16x8_t sum04 = vaddq_s16(row0, row4); \ int16x8_t dif04 = vsubq_s16(row0, row4); \ dct_widen(t0e, sum04); \ dct_widen(t1e, dif04); \ dct_wadd(x0, t0e, t3e); \ dct_wsub(x3, t0e, t3e); \ dct_wadd(x1, t1e, t2e); \ dct_wsub(x2, t1e, t2e); \ /* odd part */ \ int16x8_t sum15 = vaddq_s16(row1, row5); \ int16x8_t sum17 = vaddq_s16(row1, row7); \ int16x8_t sum35 = vaddq_s16(row3, row5); \ int16x8_t sum37 = vaddq_s16(row3, row7); \ int16x8_t sumodd = vaddq_s16(sum17, sum35); \ dct_long_mul(p5o, sumodd, rot1_0); \ dct_long_mac(p1o, p5o, sum17, rot1_1); \ dct_long_mac(p2o, p5o, sum35, rot1_2); \ dct_long_mul(p3o, sum37, rot2_0); \ dct_long_mul(p4o, sum15, rot2_1); \ dct_wadd(sump13o, p1o, p3o); \ dct_wadd(sump24o, p2o, p4o); \ dct_wadd(sump23o, p2o, p3o); \ dct_wadd(sump14o, p1o, p4o); \ dct_long_mac(x4, sump13o, row7, rot3_0); \ dct_long_mac(x5, sump24o, row5, rot3_1); \ dct_long_mac(x6, sump23o, row3, rot3_2); \ dct_long_mac(x7, sump14o, row1, rot3_3); \ dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ } // load row0 = vld1q_s16(data + 0*8); row1 = vld1q_s16(data + 1*8); row2 = vld1q_s16(data + 2*8); row3 = vld1q_s16(data + 3*8); row4 = vld1q_s16(data + 4*8); row5 = vld1q_s16(data + 5*8); row6 = vld1q_s16(data + 6*8); row7 = vld1q_s16(data + 7*8); // add DC bias row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); // column pass dct_pass(vrshrn_n_s32, 10); // 16bit 8x8 transpose { // these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. // whether compilers actually get this is another story, sadly. #define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } #define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } #define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } // pass 1 dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 dct_trn16(row2, row3); dct_trn16(row4, row5); dct_trn16(row6, row7); // pass 2 dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 dct_trn32(row1, row3); dct_trn32(row4, row6); dct_trn32(row5, row7); // pass 3 dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 dct_trn64(row1, row5); dct_trn64(row2, row6); dct_trn64(row3, row7); #undef dct_trn16 #undef dct_trn32 #undef dct_trn64 } // row pass // vrshrn_n_s32 only supports shifts up to 16, we need // 17. so do a non-rounding shift of 16 first then follow // up with a rounding shift by 1. dct_pass(vshrn_n_s32, 16); { // pack and round uint8x8_t p0 = vqrshrun_n_s16(row0, 1); uint8x8_t p1 = vqrshrun_n_s16(row1, 1); uint8x8_t p2 = vqrshrun_n_s16(row2, 1); uint8x8_t p3 = vqrshrun_n_s16(row3, 1); uint8x8_t p4 = vqrshrun_n_s16(row4, 1); uint8x8_t p5 = vqrshrun_n_s16(row5, 1); uint8x8_t p6 = vqrshrun_n_s16(row6, 1); uint8x8_t p7 = vqrshrun_n_s16(row7, 1); // again, these can translate into one instruction, but often don't. #define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } #define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } #define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } // sadly can't use interleaved stores here since we only write // 8 bytes to each scan line! // 8x8 8-bit transpose pass 1 dct_trn8_8(p0, p1); dct_trn8_8(p2, p3); dct_trn8_8(p4, p5); dct_trn8_8(p6, p7); // pass 2 dct_trn8_16(p0, p2); dct_trn8_16(p1, p3); dct_trn8_16(p4, p6); dct_trn8_16(p5, p7); // pass 3 dct_trn8_32(p0, p4); dct_trn8_32(p1, p5); dct_trn8_32(p2, p6); dct_trn8_32(p3, p7); // store vst1_u8(out, p0); out += out_stride; vst1_u8(out, p1); out += out_stride; vst1_u8(out, p2); out += out_stride; vst1_u8(out, p3); out += out_stride; vst1_u8(out, p4); out += out_stride; vst1_u8(out, p5); out += out_stride; vst1_u8(out, p6); out += out_stride; vst1_u8(out, p7); #undef dct_trn8_8 #undef dct_trn8_16 #undef dct_trn8_32 } #undef dct_long_mul #undef dct_long_mac #undef dct_widen #undef dct_wadd #undef dct_wsub #undef dct_bfly32o #undef dct_pass } #endif // STBI_NEON #define STBI__MARKER_none 0xff // if there's a pending marker from the entropy stream, return that // otherwise, fetch from the stream and get a marker. if there's no // marker, return 0xff, which is never a valid marker value static stbi_uc stbi__get_marker(stbi__jpeg *j) { stbi_uc x; if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } x = stbi__get8(j->s); if (x != 0xff) return STBI__MARKER_none; while (x == 0xff) x = stbi__get8(j->s); // consume repeated 0xff fill bytes return x; } // in each scan, we'll have scan_n components, and the order // of the components is specified by order[] #define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) // after a restart interval, stbi__jpeg_reset the entropy decoder and // the dc prediction static void stbi__jpeg_reset(stbi__jpeg *j) { j->code_bits = 0; j->code_buffer = 0; j->nomore = 0; j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0; j->marker = STBI__MARKER_none; j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; j->eob_run = 0; // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, // since we don't even allow 1<<30 pixels } static int stbi__parse_entropy_coded_data(stbi__jpeg *z) { stbi__jpeg_reset(z); if (!z->progressive) { if (z->scan_n == 1) { int i,j; STBI_SIMD_ALIGN(short, data[64]); int n = z->order[0]; // non-interleaved data, we just need to process one block at a time, // in trivial scanline order // number of blocks to do just depends on how many actual "pixels" this // component has, independent of interleaved MCU blocking and such int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); // if it's NOT a restart, then just bail, so we get corrupt data // rather than no data if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } else { // interleaved int i,j,k,x,y; STBI_SIMD_ALIGN(short, data[64]); for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order for (k=0; k < z->scan_n; ++k) { int n = z->order[k]; // scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component for (y=0; y < z->img_comp[n].v; ++y) { for (x=0; x < z->img_comp[n].h; ++x) { int x2 = (i*z->img_comp[n].h + x)*8; int y2 = (j*z->img_comp[n].v + y)*8; int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); } } } // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } } else { if (z->scan_n == 1) { int i,j; int n = z->order[0]; // non-interleaved data, we just need to process one block at a time, // in trivial scanline order // number of blocks to do just depends on how many actual "pixels" this // component has, independent of interleaved MCU blocking and such int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); if (z->spec_start == 0) { if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } else { int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) return 0; } // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } else { // interleaved int i,j,k,x,y; for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order for (k=0; k < z->scan_n; ++k) { int n = z->order[k]; // scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component for (y=0; y < z->img_comp[n].v; ++y) { for (x=0; x < z->img_comp[n].h; ++x) { int x2 = (i*z->img_comp[n].h + x); int y2 = (j*z->img_comp[n].v + y); short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } } } // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } } } static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant) { int i; for (i=0; i < 64; ++i) data[i] *= dequant[i]; } static void stbi__jpeg_finish(stbi__jpeg *z) { if (z->progressive) { // dequantize and idct the data int i,j,n; for (n=0; n < z->s->img_n; ++n) { int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); } } } } } static int stbi__process_marker(stbi__jpeg *z, int m) { int L; switch (m) { case STBI__MARKER_none: // no marker found return stbi__err("expected marker","Corrupt JPEG"); case 0xDD: // DRI - specify restart interval if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); z->restart_interval = stbi__get16be(z->s); return 1; case 0xDB: // DQT - define quantization table L = stbi__get16be(z->s)-2; while (L > 0) { int q = stbi__get8(z->s); int p = q >> 4, sixteen = (p != 0); int t = q & 15,i; if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG"); if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); for (i=0; i < 64; ++i) z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); L -= (sixteen ? 129 : 65); } return L==0; case 0xC4: // DHT - define huffman table L = stbi__get16be(z->s)-2; while (L > 0) { stbi_uc *v; int sizes[16],i,n=0; int q = stbi__get8(z->s); int tc = q >> 4; int th = q & 15; if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); for (i=0; i < 16; ++i) { sizes[i] = stbi__get8(z->s); n += sizes[i]; } L -= 17; if (tc == 0) { if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; v = z->huff_dc[th].values; } else { if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; v = z->huff_ac[th].values; } for (i=0; i < n; ++i) v[i] = stbi__get8(z->s); if (tc != 0) stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); L -= n; } return L==0; } // check for comment block or APP blocks if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { L = stbi__get16be(z->s); if (L < 2) { if (m == 0xFE) return stbi__err("bad COM len","Corrupt JPEG"); else return stbi__err("bad APP len","Corrupt JPEG"); } L -= 2; if (m == 0xE0 && L >= 5) { // JFIF APP0 segment static const unsigned char tag[5] = {'J','F','I','F','\0'}; int ok = 1; int i; for (i=0; i < 5; ++i) if (stbi__get8(z->s) != tag[i]) ok = 0; L -= 5; if (ok) z->jfif = 1; } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment static const unsigned char tag[6] = {'A','d','o','b','e','\0'}; int ok = 1; int i; for (i=0; i < 6; ++i) if (stbi__get8(z->s) != tag[i]) ok = 0; L -= 6; if (ok) { stbi__get8(z->s); // version stbi__get16be(z->s); // flags0 stbi__get16be(z->s); // flags1 z->app14_color_transform = stbi__get8(z->s); // color transform L -= 6; } } stbi__skip(z->s, L); return 1; } return stbi__err("unknown marker","Corrupt JPEG"); } // after we see SOS static int stbi__process_scan_header(stbi__jpeg *z) { int i; int Ls = stbi__get16be(z->s); z->scan_n = stbi__get8(z->s); if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG"); if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG"); for (i=0; i < z->scan_n; ++i) { int id = stbi__get8(z->s), which; int q = stbi__get8(z->s); for (which = 0; which < z->s->img_n; ++which) if (z->img_comp[which].id == id) break; if (which == z->s->img_n) return 0; // no match z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG"); z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG"); z->order[i] = which; } { int aa; z->spec_start = stbi__get8(z->s); z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 aa = stbi__get8(z->s); z->succ_high = (aa >> 4); z->succ_low = (aa & 15); if (z->progressive) { if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) return stbi__err("bad SOS", "Corrupt JPEG"); } else { if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); z->spec_end = 63; } } return 1; } static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) { int i; for (i=0; i < ncomp; ++i) { if (z->img_comp[i].raw_data) { STBI_FREE(z->img_comp[i].raw_data); z->img_comp[i].raw_data = NULL; z->img_comp[i].data = NULL; } if (z->img_comp[i].raw_coeff) { STBI_FREE(z->img_comp[i].raw_coeff); z->img_comp[i].raw_coeff = 0; z->img_comp[i].coeff = 0; } if (z->img_comp[i].linebuf) { STBI_FREE(z->img_comp[i].linebuf); z->img_comp[i].linebuf = NULL; } } return why; } static int stbi__process_frame_header(stbi__jpeg *z, int scan) { stbi__context *s = z->s; int Lf,p,i,q, h_max=1,v_max=1,c; Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires c = stbi__get8(s); if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG"); s->img_n = c; for (i=0; i < c; ++i) { z->img_comp[i].data = NULL; z->img_comp[i].linebuf = NULL; } if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); z->rgb = 0; for (i=0; i < s->img_n; ++i) { static unsigned char rgb[3] = { 'R', 'G', 'B' }; z->img_comp[i].id = stbi__get8(s); if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) ++z->rgb; q = stbi__get8(s); z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); } if (scan != STBI__SCAN_load) return 1; if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode"); for (i=0; i < s->img_n; ++i) { if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; } // compute interleaved mcu info z->img_h_max = h_max; z->img_v_max = v_max; z->img_mcu_w = h_max * 8; z->img_mcu_h = v_max * 8; // these sizes can't be more than 17 bits z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; for (i=0; i < s->img_n; ++i) { // number of effective pixels (e.g. for non-interleaved MCU) z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; // to simplify generation, we'll allocate enough memory to decode // the bogus oversized data from using interleaved MCUs and their // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't // discard the extra data until colorspace conversion // // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) // so these muls can't overflow with 32-bit ints (which we require) z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; z->img_comp[i].coeff = 0; z->img_comp[i].raw_coeff = 0; z->img_comp[i].linebuf = NULL; z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); if (z->img_comp[i].raw_data == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); // align blocks for idct using mmx/sse z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); if (z->progressive) { // w2, h2 are multiples of 8 (see above) z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); if (z->img_comp[i].raw_coeff == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); } } return 1; } // use comparisons since in some cases we handle more than one case (e.g. SOF) #define stbi__DNL(x) ((x) == 0xdc) #define stbi__SOI(x) ((x) == 0xd8) #define stbi__EOI(x) ((x) == 0xd9) #define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) #define stbi__SOS(x) ((x) == 0xda) #define stbi__SOF_progressive(x) ((x) == 0xc2) static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) { int m; z->jfif = 0; z->app14_color_transform = -1; // valid values are 0,1,2 z->marker = STBI__MARKER_none; // initialize cached marker to empty m = stbi__get_marker(z); if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); if (scan == STBI__SCAN_type) return 1; m = stbi__get_marker(z); while (!stbi__SOF(m)) { if (!stbi__process_marker(z,m)) return 0; m = stbi__get_marker(z); while (m == STBI__MARKER_none) { // some files have extra padding after their blocks, so ok, we'll scan if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); m = stbi__get_marker(z); } } z->progressive = stbi__SOF_progressive(m); if (!stbi__process_frame_header(z, scan)) return 0; return 1; } // decode image to YCbCr format static int stbi__decode_jpeg_image(stbi__jpeg *j) { int m; for (m = 0; m < 4; m++) { j->img_comp[m].raw_data = NULL; j->img_comp[m].raw_coeff = NULL; } j->restart_interval = 0; if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; m = stbi__get_marker(j); while (!stbi__EOI(m)) { if (stbi__SOS(m)) { if (!stbi__process_scan_header(j)) return 0; if (!stbi__parse_entropy_coded_data(j)) return 0; if (j->marker == STBI__MARKER_none ) { // handle 0s at the end of image data from IP Kamera 9060 while (!stbi__at_eof(j->s)) { int x = stbi__get8(j->s); if (x == 255) { j->marker = stbi__get8(j->s); break; } } // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 } } else if (stbi__DNL(m)) { int Ld = stbi__get16be(j->s); stbi__uint32 NL = stbi__get16be(j->s); if (Ld != 4) stbi__err("bad DNL len", "Corrupt JPEG"); if (NL != j->s->img_y) stbi__err("bad DNL height", "Corrupt JPEG"); } else { if (!stbi__process_marker(j, m)) return 0; } m = stbi__get_marker(j); } if (j->progressive) stbi__jpeg_finish(j); return 1; } // static jfif-centered resampling (across block boundaries) typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, int w, int hs); #define stbi__div4(x) ((stbi_uc) ((x) >> 2)) static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { STBI_NOTUSED(out); STBI_NOTUSED(in_far); STBI_NOTUSED(w); STBI_NOTUSED(hs); return in_near; } static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate two samples vertically for every one in input int i; STBI_NOTUSED(hs); for (i=0; i < w; ++i) out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); return out; } static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate two samples horizontally for every one in input int i; stbi_uc *input = in_near; if (w == 1) { // if only one sample, can't do any interpolation out[0] = out[1] = input[0]; return out; } out[0] = input[0]; out[1] = stbi__div4(input[0]*3 + input[1] + 2); for (i=1; i < w-1; ++i) { int n = 3*input[i]+2; out[i*2+0] = stbi__div4(n+input[i-1]); out[i*2+1] = stbi__div4(n+input[i+1]); } out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); out[i*2+1] = input[w-1]; STBI_NOTUSED(in_far); STBI_NOTUSED(hs); return out; } #define stbi__div16(x) ((stbi_uc) ((x) >> 4)) static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate 2x2 samples for every one in input int i,t0,t1; if (w == 1) { out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); return out; } t1 = 3*in_near[0] + in_far[0]; out[0] = stbi__div4(t1+2); for (i=1; i < w; ++i) { t0 = t1; t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = stbi__div16(3*t0 + t1 + 8); out[i*2 ] = stbi__div16(3*t1 + t0 + 8); } out[w*2-1] = stbi__div4(t1+2); STBI_NOTUSED(hs); return out; } #if defined(STBI_SSE2) || defined(STBI_NEON) static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate 2x2 samples for every one in input int i=0,t0,t1; if (w == 1) { out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); return out; } t1 = 3*in_near[0] + in_far[0]; // process groups of 8 pixels for as long as we can. // note we can't handle the last pixel in a row in this loop // because we need to handle the filter boundary conditions. for (; i < ((w-1) & ~7); i += 8) { #if defined(STBI_SSE2) // load and perform the vertical filtering pass // this uses 3*x + y = 4*x + (y - x) __m128i zero = _mm_setzero_si128(); __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); __m128i farw = _mm_unpacklo_epi8(farb, zero); __m128i nearw = _mm_unpacklo_epi8(nearb, zero); __m128i diff = _mm_sub_epi16(farw, nearw); __m128i nears = _mm_slli_epi16(nearw, 2); __m128i curr = _mm_add_epi16(nears, diff); // current row // horizontal filter works the same based on shifted vers of current // row. "prev" is current row shifted right by 1 pixel; we need to // insert the previous pixel value (from t1). // "next" is current row shifted left by 1 pixel, with first pixel // of next block of 8 pixels added in. __m128i prv0 = _mm_slli_si128(curr, 2); __m128i nxt0 = _mm_srli_si128(curr, 2); __m128i prev = _mm_insert_epi16(prv0, t1, 0); __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); // horizontal filter, polyphase implementation since it's convenient: // even pixels = 3*cur + prev = cur*4 + (prev - cur) // odd pixels = 3*cur + next = cur*4 + (next - cur) // note the shared term. __m128i bias = _mm_set1_epi16(8); __m128i curs = _mm_slli_epi16(curr, 2); __m128i prvd = _mm_sub_epi16(prev, curr); __m128i nxtd = _mm_sub_epi16(next, curr); __m128i curb = _mm_add_epi16(curs, bias); __m128i even = _mm_add_epi16(prvd, curb); __m128i odd = _mm_add_epi16(nxtd, curb); // interleave even and odd pixels, then undo scaling. __m128i int0 = _mm_unpacklo_epi16(even, odd); __m128i int1 = _mm_unpackhi_epi16(even, odd); __m128i de0 = _mm_srli_epi16(int0, 4); __m128i de1 = _mm_srli_epi16(int1, 4); // pack and write output __m128i outv = _mm_packus_epi16(de0, de1); _mm_storeu_si128((__m128i *) (out + i*2), outv); #elif defined(STBI_NEON) // load and perform the vertical filtering pass // this uses 3*x + y = 4*x + (y - x) uint8x8_t farb = vld1_u8(in_far + i); uint8x8_t nearb = vld1_u8(in_near + i); int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); int16x8_t curr = vaddq_s16(nears, diff); // current row // horizontal filter works the same based on shifted vers of current // row. "prev" is current row shifted right by 1 pixel; we need to // insert the previous pixel value (from t1). // "next" is current row shifted left by 1 pixel, with first pixel // of next block of 8 pixels added in. int16x8_t prv0 = vextq_s16(curr, curr, 7); int16x8_t nxt0 = vextq_s16(curr, curr, 1); int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); // horizontal filter, polyphase implementation since it's convenient: // even pixels = 3*cur + prev = cur*4 + (prev - cur) // odd pixels = 3*cur + next = cur*4 + (next - cur) // note the shared term. int16x8_t curs = vshlq_n_s16(curr, 2); int16x8_t prvd = vsubq_s16(prev, curr); int16x8_t nxtd = vsubq_s16(next, curr); int16x8_t even = vaddq_s16(curs, prvd); int16x8_t odd = vaddq_s16(curs, nxtd); // undo scaling and round, then store with even/odd phases interleaved uint8x8x2_t o; o.val[0] = vqrshrun_n_s16(even, 4); o.val[1] = vqrshrun_n_s16(odd, 4); vst2_u8(out + i*2, o); #endif // "previous" value for next iter t1 = 3*in_near[i+7] + in_far[i+7]; } t0 = t1; t1 = 3*in_near[i] + in_far[i]; out[i*2] = stbi__div16(3*t1 + t0 + 8); for (++i; i < w; ++i) { t0 = t1; t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = stbi__div16(3*t0 + t1 + 8); out[i*2 ] = stbi__div16(3*t1 + t0 + 8); } out[w*2-1] = stbi__div4(t1+2); STBI_NOTUSED(hs); return out; } #endif static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // resample with nearest-neighbor int i,j; STBI_NOTUSED(in_far); for (i=0; i < w; ++i) for (j=0; j < hs; ++j) out[i*hs+j] = in_near[i]; return out; } // this is a reduced-precision calculation of YCbCr-to-RGB introduced // to make sure the code produces the same results in both SIMD and scalar #define stbi__float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) { int i; for (i=0; i < count; ++i) { int y_fixed = (y[i] << 20) + (1<<19); // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr* stbi__float2fixed(1.40200f); g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); b = y_fixed + cb* stbi__float2fixed(1.77200f); r >>= 20; g >>= 20; b >>= 20; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi_uc)r; out[1] = (stbi_uc)g; out[2] = (stbi_uc)b; out[3] = 255; out += step; } } #if defined(STBI_SSE2) || defined(STBI_NEON) static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) { int i = 0; #ifdef STBI_SSE2 // step == 3 is pretty ugly on the final interleave, and i'm not convinced // it's useful in practice (you wouldn't use it for textures, for example). // so just accelerate step == 4 case. if (step == 4) { // this is a fairly straightforward implementation and not super-optimized. __m128i signflip = _mm_set1_epi8(-0x80); __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); __m128i xw = _mm_set1_epi16(255); // alpha channel for (; i+7 < count; i += 8) { // load __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 // unpack to short (and left-shift cr, cb by 8) __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); // color transform __m128i yws = _mm_srli_epi16(yw, 4); __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); __m128i rws = _mm_add_epi16(cr0, yws); __m128i gwt = _mm_add_epi16(cb0, yws); __m128i bws = _mm_add_epi16(yws, cb1); __m128i gws = _mm_add_epi16(gwt, cr1); // descale __m128i rw = _mm_srai_epi16(rws, 4); __m128i bw = _mm_srai_epi16(bws, 4); __m128i gw = _mm_srai_epi16(gws, 4); // back to byte, set up for transpose __m128i brb = _mm_packus_epi16(rw, bw); __m128i gxb = _mm_packus_epi16(gw, xw); // transpose to interleave channels __m128i t0 = _mm_unpacklo_epi8(brb, gxb); __m128i t1 = _mm_unpackhi_epi8(brb, gxb); __m128i o0 = _mm_unpacklo_epi16(t0, t1); __m128i o1 = _mm_unpackhi_epi16(t0, t1); // store _mm_storeu_si128((__m128i *) (out + 0), o0); _mm_storeu_si128((__m128i *) (out + 16), o1); out += 32; } } #endif #ifdef STBI_NEON // in this version, step=3 support would be easy to add. but is there demand? if (step == 4) { // this is a fairly straightforward implementation and not super-optimized. uint8x8_t signflip = vdup_n_u8(0x80); int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); for (; i+7 < count; i += 8) { // load uint8x8_t y_bytes = vld1_u8(y + i); uint8x8_t cr_bytes = vld1_u8(pcr + i); uint8x8_t cb_bytes = vld1_u8(pcb + i); int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); // expand to s16 int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); int16x8_t crw = vshll_n_s8(cr_biased, 7); int16x8_t cbw = vshll_n_s8(cb_biased, 7); // color transform int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); int16x8_t rws = vaddq_s16(yws, cr0); int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); int16x8_t bws = vaddq_s16(yws, cb1); // undo scaling, round, convert to byte uint8x8x4_t o; o.val[0] = vqrshrun_n_s16(rws, 4); o.val[1] = vqrshrun_n_s16(gws, 4); o.val[2] = vqrshrun_n_s16(bws, 4); o.val[3] = vdup_n_u8(255); // store, interleaving r/g/b/a vst4_u8(out, o); out += 8*4; } } #endif for (; i < count; ++i) { int y_fixed = (y[i] << 20) + (1<<19); // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr* stbi__float2fixed(1.40200f); g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); b = y_fixed + cb* stbi__float2fixed(1.77200f); r >>= 20; g >>= 20; b >>= 20; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi_uc)r; out[1] = (stbi_uc)g; out[2] = (stbi_uc)b; out[3] = 255; out += step; } } #endif // set up the kernels static void stbi__setup_jpeg(stbi__jpeg *j) { j->idct_block_kernel = stbi__idct_block; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; #ifdef STBI_SSE2 if (stbi__sse2_available()) { j->idct_block_kernel = stbi__idct_simd; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; } #endif #ifdef STBI_NEON j->idct_block_kernel = stbi__idct_simd; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; #endif } // clean up the temporary component buffers static void stbi__cleanup_jpeg(stbi__jpeg *j) { stbi__free_jpeg_components(j, j->s->img_n, 0); } typedef struct { resample_row_func resample; stbi_uc *line0,*line1; int hs,vs; // expansion factor in each axis int w_lores; // horizontal pixels pre-expansion int ystep; // how far through vertical expansion we are int ypos; // which pre-expansion row we're on } stbi__resample; // fast 0..255 * 0..255 => 0..255 rounded multiplication static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) { unsigned int t = x*y + 128; return (stbi_uc) ((t + (t >>8)) >> 8); } static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) { int n, decode_n, is_rgb; z->s->img_n = 0; // make stbi__cleanup_jpeg safe // validate req_comp if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); // load a jpeg image from whichever source, but leave in YCbCr format if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } // determine actual number of components to generate n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1; is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif)); if (z->s->img_n == 3 && n < 3 && !is_rgb) decode_n = 1; else decode_n = z->s->img_n; // resample and color-convert { int k; unsigned int i,j; stbi_uc *output; stbi_uc *coutput[4]; stbi__resample res_comp[4]; for (k=0; k < decode_n; ++k) { stbi__resample *r = &res_comp[k]; // allocate line buffer big enough for upsampling off the edges // with upsample factor of 4 z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3); if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } r->hs = z->img_h_max / z->img_comp[k].h; r->vs = z->img_v_max / z->img_comp[k].v; r->ystep = r->vs >> 1; r->w_lores = (z->s->img_x + r->hs-1) / r->hs; r->ypos = 0; r->line0 = r->line1 = z->img_comp[k].data; if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; else r->resample = stbi__resample_row_generic; } // can't error after this so, this is safe output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1); if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } // now go ahead and resample for (j=0; j < z->s->img_y; ++j) { stbi_uc *out = output + n * z->s->img_x * j; for (k=0; k < decode_n; ++k) { stbi__resample *r = &res_comp[k]; int y_bot = r->ystep >= (r->vs >> 1); coutput[k] = r->resample(z->img_comp[k].linebuf, y_bot ? r->line1 : r->line0, y_bot ? r->line0 : r->line1, r->w_lores, r->hs); if (++r->ystep >= r->vs) { r->ystep = 0; r->line0 = r->line1; if (++r->ypos < z->img_comp[k].y) r->line1 += z->img_comp[k].w2; } } if (n >= 3) { stbi_uc *y = coutput[0]; if (z->s->img_n == 3) { if (is_rgb) { for (i=0; i < z->s->img_x; ++i) { out[0] = y[i]; out[1] = coutput[1][i]; out[2] = coutput[2][i]; out[3] = 255; out += n; } } else { z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); } } else if (z->s->img_n == 4) { if (z->app14_color_transform == 0) { // CMYK for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; out[0] = stbi__blinn_8x8(coutput[0][i], m); out[1] = stbi__blinn_8x8(coutput[1][i], m); out[2] = stbi__blinn_8x8(coutput[2][i], m); out[3] = 255; out += n; } } else if (z->app14_color_transform == 2) { // YCCK z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; out[0] = stbi__blinn_8x8(255 - out[0], m); out[1] = stbi__blinn_8x8(255 - out[1], m); out[2] = stbi__blinn_8x8(255 - out[2], m); out += n; } } else { // YCbCr + alpha? Ignore the fourth channel for now z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); } } else for (i=0; i < z->s->img_x; ++i) { out[0] = out[1] = out[2] = y[i]; out[3] = 255; // not used if n==3 out += n; } } else { if (is_rgb) { if (n == 1) for (i=0; i < z->s->img_x; ++i) *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); else { for (i=0; i < z->s->img_x; ++i, out += 2) { out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); out[1] = 255; } } } else if (z->s->img_n == 4 && z->app14_color_transform == 0) { for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); out[0] = stbi__compute_y(r, g, b); out[1] = 255; out += n; } } else if (z->s->img_n == 4 && z->app14_color_transform == 2) { for (i=0; i < z->s->img_x; ++i) { out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]); out[1] = 255; out += n; } } else { stbi_uc *y = coutput[0]; if (n == 1) for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; else for (i=0; i < z->s->img_x; ++i) *out++ = y[i], *out++ = 255; } } } stbi__cleanup_jpeg(z); *out_x = z->s->img_x; *out_y = z->s->img_y; if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output return output; } } static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { unsigned char* result; stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg)); STBI_NOTUSED(ri); j->s = s; stbi__setup_jpeg(j); result = load_jpeg_image(j, x,y,comp,req_comp); STBI_FREE(j); return result; } static int stbi__jpeg_test(stbi__context *s) { int r; stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg)); j->s = s; stbi__setup_jpeg(j); r = stbi__decode_jpeg_header(j, STBI__SCAN_type); stbi__rewind(s); STBI_FREE(j); return r; } static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) { if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { stbi__rewind( j->s ); return 0; } if (x) *x = j->s->img_x; if (y) *y = j->s->img_y; if (comp) *comp = j->s->img_n >= 3 ? 3 : 1; return 1; } static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) { int result; stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg))); j->s = s; result = stbi__jpeg_info_raw(j, x, y, comp); STBI_FREE(j); return result; } #endif // public domain zlib decode v0.2 Sean Barrett 2006-11-18 // simple implementation // - all input must be provided in an upfront buffer // - all output is written to a single output buffer (can malloc/realloc) // performance // - fast huffman #ifndef STBI_NO_ZLIB // fast-way is faster to check than jpeg huffman, but slow way is slower #define STBI__ZFAST_BITS 9 // accelerate all cases in default tables #define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) // zlib-style huffman encoding // (jpegs packs from left, zlib from right, so can't share code) typedef struct { stbi__uint16 fast[1 << STBI__ZFAST_BITS]; stbi__uint16 firstcode[16]; int maxcode[17]; stbi__uint16 firstsymbol[16]; stbi_uc size[288]; stbi__uint16 value[288]; } stbi__zhuffman; stbi_inline static int stbi__bitreverse16(int n) { n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); return n; } stbi_inline static int stbi__bit_reverse(int v, int bits) { STBI_ASSERT(bits <= 16); // to bit reverse n bits, reverse 16 and shift // e.g. 11 bits, bit reverse and shift away 5 return stbi__bitreverse16(v) >> (16-bits); } static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num) { int i,k=0; int code, next_code[16], sizes[17]; // DEFLATE spec for generating codes memset(sizes, 0, sizeof(sizes)); memset(z->fast, 0, sizeof(z->fast)); for (i=0; i < num; ++i) ++sizes[sizelist[i]]; sizes[0] = 0; for (i=1; i < 16; ++i) if (sizes[i] > (1 << i)) return stbi__err("bad sizes", "Corrupt PNG"); code = 0; for (i=1; i < 16; ++i) { next_code[i] = code; z->firstcode[i] = (stbi__uint16) code; z->firstsymbol[i] = (stbi__uint16) k; code = (code + sizes[i]); if (sizes[i]) if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG"); z->maxcode[i] = code << (16-i); // preshift for inner loop code <<= 1; k += sizes[i]; } z->maxcode[16] = 0x10000; // sentinel for (i=0; i < num; ++i) { int s = sizelist[i]; if (s) { int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i); z->size [c] = (stbi_uc ) s; z->value[c] = (stbi__uint16) i; if (s <= STBI__ZFAST_BITS) { int j = stbi__bit_reverse(next_code[s],s); while (j < (1 << STBI__ZFAST_BITS)) { z->fast[j] = fastv; j += (1 << s); } } ++next_code[s]; } } return 1; } // zlib-from-memory implementation for PNG reading // because PNG allows splitting the zlib stream arbitrarily, // and it's annoying structurally to have PNG call ZLIB call PNG, // we require PNG read all the IDATs and combine them into a single // memory buffer typedef struct { stbi_uc *zbuffer, *zbuffer_end; int num_bits; stbi__uint32 code_buffer; char *zout; char *zout_start; char *zout_end; int z_expandable; stbi__zhuffman z_length, z_distance; } stbi__zbuf; stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) { if (z->zbuffer >= z->zbuffer_end) return 0; return *z->zbuffer++; } static void stbi__fill_bits(stbi__zbuf *z) { do { STBI_ASSERT(z->code_buffer < (1U << z->num_bits)); z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits; z->num_bits += 8; } while (z->num_bits <= 24); } stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) { unsigned int k; if (z->num_bits < n) stbi__fill_bits(z); k = z->code_buffer & ((1 << n) - 1); z->code_buffer >>= n; z->num_bits -= n; return k; } static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) { int b,s,k; // not resolved by fast table, so compute it the slow way // use jpeg approach, which requires MSbits at top k = stbi__bit_reverse(a->code_buffer, 16); for (s=STBI__ZFAST_BITS+1; ; ++s) if (k < z->maxcode[s]) break; if (s == 16) return -1; // invalid code! // code size is s, so: b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; STBI_ASSERT(z->size[b] == s); a->code_buffer >>= s; a->num_bits -= s; return z->value[b]; } stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) { int b,s; if (a->num_bits < 16) stbi__fill_bits(a); b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; if (b) { s = b >> 9; a->code_buffer >>= s; a->num_bits -= s; return b & 511; } return stbi__zhuffman_decode_slowpath(a, z); } static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes { char *q; int cur, limit, old_limit; z->zout = zout; if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); cur = (int) (z->zout - z->zout_start); limit = old_limit = (int) (z->zout_end - z->zout_start); while (cur + n > limit) limit *= 2; q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); STBI_NOTUSED(old_limit); if (q == NULL) return stbi__err("outofmem", "Out of memory"); z->zout_start = q; z->zout = q + cur; z->zout_end = q + limit; return 1; } static int stbi__zlength_base[31] = { 3,4,5,6,7,8,9,10,11,13, 15,17,19,23,27,31,35,43,51,59, 67,83,99,115,131,163,195,227,258,0,0 }; static int stbi__zlength_extra[31]= { 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; static int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, 257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; static int stbi__zdist_extra[32] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; static int stbi__parse_huffman_block(stbi__zbuf *a) { char *zout = a->zout; for(;;) { int z = stbi__zhuffman_decode(a, &a->z_length); if (z < 256) { if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes if (zout >= a->zout_end) { if (!stbi__zexpand(a, zout, 1)) return 0; zout = a->zout; } *zout++ = (char) z; } else { stbi_uc *p; int len,dist; if (z == 256) { a->zout = zout; return 1; } z -= 257; len = stbi__zlength_base[z]; if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); z = stbi__zhuffman_decode(a, &a->z_distance); if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); dist = stbi__zdist_base[z]; if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG"); if (zout + len > a->zout_end) { if (!stbi__zexpand(a, zout, len)) return 0; zout = a->zout; } p = (stbi_uc *) (zout - dist); if (dist == 1) { // run of one byte; common in images. stbi_uc v = *p; if (len) { do *zout++ = v; while (--len); } } else { if (len) { do *zout++ = *p++; while (--len); } } } } } static int stbi__compute_huffman_codes(stbi__zbuf *a) { static stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; stbi__zhuffman z_codelength; stbi_uc lencodes[286+32+137];//padding for maximum single op stbi_uc codelength_sizes[19]; int i,n; int hlit = stbi__zreceive(a,5) + 257; int hdist = stbi__zreceive(a,5) + 1; int hclen = stbi__zreceive(a,4) + 4; int ntot = hlit + hdist; memset(codelength_sizes, 0, sizeof(codelength_sizes)); for (i=0; i < hclen; ++i) { int s = stbi__zreceive(a,3); codelength_sizes[length_dezigzag[i]] = (stbi_uc) s; } if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; n = 0; while (n < ntot) { int c = stbi__zhuffman_decode(a, &z_codelength); if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); if (c < 16) lencodes[n++] = (stbi_uc) c; else { stbi_uc fill = 0; if (c == 16) { c = stbi__zreceive(a,2)+3; if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG"); fill = lencodes[n-1]; } else if (c == 17) c = stbi__zreceive(a,3)+3; else { STBI_ASSERT(c == 18); c = stbi__zreceive(a,7)+11; } if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG"); memset(lencodes+n, fill, c); n += c; } } if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG"); if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; return 1; } static int stbi__parse_uncompressed_block(stbi__zbuf *a) { stbi_uc header[4]; int len,nlen,k; if (a->num_bits & 7) stbi__zreceive(a, a->num_bits & 7); // discard // drain the bit-packed data into header k = 0; while (a->num_bits > 0) { header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check a->code_buffer >>= 8; a->num_bits -= 8; } STBI_ASSERT(a->num_bits == 0); // now fill header the normal way while (k < 4) header[k++] = stbi__zget8(a); len = header[1] * 256 + header[0]; nlen = header[3] * 256 + header[2]; if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG"); if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG"); if (a->zout + len > a->zout_end) if (!stbi__zexpand(a, a->zout, len)) return 0; memcpy(a->zout, a->zbuffer, len); a->zbuffer += len; a->zout += len; return 1; } static int stbi__parse_zlib_header(stbi__zbuf *a) { int cmf = stbi__zget8(a); int cm = cmf & 15; /* int cinfo = cmf >> 4; */ int flg = stbi__zget8(a); if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png // window = 1 << (8 + cinfo)... but who cares, we fully buffer output return 1; } static const stbi_uc stbi__zdefault_length[288] = { 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8 }; static const stbi_uc stbi__zdefault_distance[32] = { 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 }; /* Init algorithm: { int i; // use <= to match clearly with spec for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; } */ static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) { int final, type; if (parse_header) if (!stbi__parse_zlib_header(a)) return 0; a->num_bits = 0; a->code_buffer = 0; do { final = stbi__zreceive(a,1); type = stbi__zreceive(a,2); if (type == 0) { if (!stbi__parse_uncompressed_block(a)) return 0; } else if (type == 3) { return 0; } else { if (type == 1) { // use fixed code lengths if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , 288)) return 0; if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; } else { if (!stbi__compute_huffman_codes(a)) return 0; } if (!stbi__parse_huffman_block(a)) return 0; } } while (!final); return 1; } static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) { a->zout_start = obuf; a->zout = obuf; a->zout_end = obuf + olen; a->z_expandable = exp; return stbi__parse_zlib(a, parse_header); } STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer + len; if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) { return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); } STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer + len; if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; a.zbuffer_end = (stbi_uc *) ibuffer + ilen; if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) return (int) (a.zout - a.zout_start); else return -1; } STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(16384); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer+len; if (stbi__do_zlib(&a, p, 16384, 1, 0)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; a.zbuffer_end = (stbi_uc *) ibuffer + ilen; if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) return (int) (a.zout - a.zout_start); else return -1; } #endif // public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 // simple implementation // - only 8-bit samples // - no CRC checking // - allocates lots of intermediate memory // - avoids problem of streaming data between subsystems // - avoids explicit window management // performance // - uses stb_zlib, a PD zlib implementation with fast huffman decoding #ifndef STBI_NO_PNG typedef struct { stbi__uint32 length; stbi__uint32 type; } stbi__pngchunk; static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) { stbi__pngchunk c; c.length = stbi__get32be(s); c.type = stbi__get32be(s); return c; } static int stbi__check_png_header(stbi__context *s) { static stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; int i; for (i=0; i < 8; ++i) if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG"); return 1; } typedef struct { stbi__context *s; stbi_uc *idata, *expanded, *out; int depth; } stbi__png; enum { STBI__F_none=0, STBI__F_sub=1, STBI__F_up=2, STBI__F_avg=3, STBI__F_paeth=4, // synthetic filters used for first scanline to avoid needing a dummy row of 0s STBI__F_avg_first, STBI__F_paeth_first }; static stbi_uc first_row_filter[5] = { STBI__F_none, STBI__F_sub, STBI__F_none, STBI__F_avg_first, STBI__F_paeth_first }; static int stbi__paeth(int a, int b, int c) { int p = a + b - c; int pa = abs(p-a); int pb = abs(p-b); int pc = abs(p-c); if (pa <= pb && pa <= pc) return a; if (pb <= pc) return b; return c; } static stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; // create the png data from post-deflated data static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) { int bytes = (depth == 16? 2 : 1); stbi__context *s = a->s; stbi__uint32 i,j,stride = x*out_n*bytes; stbi__uint32 img_len, img_width_bytes; int k; int img_n = s->img_n; // copy it into a local for later int output_bytes = out_n*bytes; int filter_bytes = img_n*bytes; int width = x; STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1); a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into if (!a->out) return stbi__err("outofmem", "Out of memory"); img_width_bytes = (((img_n * x * depth) + 7) >> 3); img_len = (img_width_bytes + 1) * y; // we used to check for exact match between raw_len and img_len on non-interlaced PNGs, // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros), // so just check for raw_len < img_len always. if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG"); for (j=0; j < y; ++j) { stbi_uc *cur = a->out + stride*j; stbi_uc *prior; int filter = *raw++; if (filter > 4) return stbi__err("invalid filter","Corrupt PNG"); if (depth < 8) { STBI_ASSERT(img_width_bytes <= x); cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place filter_bytes = 1; width = img_width_bytes; } prior = cur - stride; // bugfix: need to compute this after 'cur +=' computation above // if first row, use special filter that doesn't sample previous row if (j == 0) filter = first_row_filter[filter]; // handle first byte explicitly for (k=0; k < filter_bytes; ++k) { switch (filter) { case STBI__F_none : cur[k] = raw[k]; break; case STBI__F_sub : cur[k] = raw[k]; break; case STBI__F_up : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; case STBI__F_avg : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break; case STBI__F_paeth : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break; case STBI__F_avg_first : cur[k] = raw[k]; break; case STBI__F_paeth_first: cur[k] = raw[k]; break; } } if (depth == 8) { if (img_n != out_n) cur[img_n] = 255; // first pixel raw += img_n; cur += out_n; prior += out_n; } else if (depth == 16) { if (img_n != out_n) { cur[filter_bytes] = 255; // first pixel top byte cur[filter_bytes+1] = 255; // first pixel bottom byte } raw += filter_bytes; cur += output_bytes; prior += output_bytes; } else { raw += 1; cur += 1; prior += 1; } // this is a little gross, so that we don't switch per-pixel or per-component if (depth < 8 || img_n == out_n) { int nk = (width - 1)*filter_bytes; #define STBI__CASE(f) \ case f: \ for (k=0; k < nk; ++k) switch (filter) { // "none" filter turns into a memcpy here; make that explicit. case STBI__F_none: memcpy(cur, raw, nk); break; STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); } break; STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); } break; STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); } break; STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); } break; STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); } break; } #undef STBI__CASE raw += nk; } else { STBI_ASSERT(img_n+1 == out_n); #define STBI__CASE(f) \ case f: \ for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \ for (k=0; k < filter_bytes; ++k) switch (filter) { STBI__CASE(STBI__F_none) { cur[k] = raw[k]; } break; STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); } break; STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); } break; STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); } break; STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); } break; STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); } break; } #undef STBI__CASE // the loop above sets the high byte of the pixels' alpha, but for // 16 bit png files we also need the low byte set. we'll do that here. if (depth == 16) { cur = a->out + stride*j; // start at the beginning of the row again for (i=0; i < x; ++i,cur+=output_bytes) { cur[filter_bytes+1] = 255; } } } } // we make a separate pass to expand bits to pixels; for performance, // this could run two scanlines behind the above code, so it won't // intefere with filtering but will still be in the cache. if (depth < 8) { for (j=0; j < y; ++j) { stbi_uc *cur = a->out + stride*j; stbi_uc *in = a->out + stride*j + x*out_n - img_width_bytes; // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range // note that the final byte might overshoot and write more data than desired. // we can allocate enough data that this never writes out of memory, but it // could also overwrite the next scanline. can it overwrite non-empty data // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel. // so we need to explicitly clamp the final ones if (depth == 4) { for (k=x*img_n; k >= 2; k-=2, ++in) { *cur++ = scale * ((*in >> 4) ); *cur++ = scale * ((*in ) & 0x0f); } if (k > 0) *cur++ = scale * ((*in >> 4) ); } else if (depth == 2) { for (k=x*img_n; k >= 4; k-=4, ++in) { *cur++ = scale * ((*in >> 6) ); *cur++ = scale * ((*in >> 4) & 0x03); *cur++ = scale * ((*in >> 2) & 0x03); *cur++ = scale * ((*in ) & 0x03); } if (k > 0) *cur++ = scale * ((*in >> 6) ); if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03); if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03); } else if (depth == 1) { for (k=x*img_n; k >= 8; k-=8, ++in) { *cur++ = scale * ((*in >> 7) ); *cur++ = scale * ((*in >> 6) & 0x01); *cur++ = scale * ((*in >> 5) & 0x01); *cur++ = scale * ((*in >> 4) & 0x01); *cur++ = scale * ((*in >> 3) & 0x01); *cur++ = scale * ((*in >> 2) & 0x01); *cur++ = scale * ((*in >> 1) & 0x01); *cur++ = scale * ((*in ) & 0x01); } if (k > 0) *cur++ = scale * ((*in >> 7) ); if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01); if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01); if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01); if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01); if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01); if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01); } if (img_n != out_n) { int q; // insert alpha = 255 cur = a->out + stride*j; if (img_n == 1) { for (q=x-1; q >= 0; --q) { cur[q*2+1] = 255; cur[q*2+0] = cur[q]; } } else { STBI_ASSERT(img_n == 3); for (q=x-1; q >= 0; --q) { cur[q*4+3] = 255; cur[q*4+2] = cur[q*3+2]; cur[q*4+1] = cur[q*3+1]; cur[q*4+0] = cur[q*3+0]; } } } } } else if (depth == 16) { // force the image data from big-endian to platform-native. // this is done in a separate pass due to the decoding relying // on the data being untouched, but could probably be done // per-line during decode if care is taken. stbi_uc *cur = a->out; stbi__uint16 *cur16 = (stbi__uint16*)cur; for(i=0; i < x*y*out_n; ++i,cur16++,cur+=2) { *cur16 = (cur[0] << 8) | cur[1]; } } return 1; } static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) { int bytes = (depth == 16 ? 2 : 1); int out_bytes = out_n * bytes; stbi_uc *final; int p; if (!interlaced) return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); // de-interlacing final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0); for (p=0; p < 7; ++p) { int xorig[] = { 0,4,0,2,0,1,0 }; int yorig[] = { 0,0,4,0,2,0,1 }; int xspc[] = { 8,8,4,4,2,2,1 }; int yspc[] = { 8,8,8,4,4,2,2 }; int i,j,x,y; // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; if (x && y) { stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { STBI_FREE(final); return 0; } for (j=0; j < y; ++j) { for (i=0; i < x; ++i) { int out_y = j*yspc[p]+yorig[p]; int out_x = i*xspc[p]+xorig[p]; memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes, a->out + (j*x+i)*out_bytes, out_bytes); } } STBI_FREE(a->out); image_data += img_len; image_data_len -= img_len; } } a->out = final; return 1; } static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi_uc *p = z->out; // compute color-based transparency, assuming we've // already got 255 as the alpha value in the output STBI_ASSERT(out_n == 2 || out_n == 4); if (out_n == 2) { for (i=0; i < pixel_count; ++i) { p[1] = (p[0] == tc[0] ? 0 : 255); p += 2; } } else { for (i=0; i < pixel_count; ++i) { if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) p[3] = 0; p += 4; } } return 1; } static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi__uint16 *p = (stbi__uint16*) z->out; // compute color-based transparency, assuming we've // already got 65535 as the alpha value in the output STBI_ASSERT(out_n == 2 || out_n == 4); if (out_n == 2) { for (i = 0; i < pixel_count; ++i) { p[1] = (p[0] == tc[0] ? 0 : 65535); p += 2; } } else { for (i = 0; i < pixel_count; ++i) { if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) p[3] = 0; p += 4; } } return 1; } static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) { stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; stbi_uc *p, *temp_out, *orig = a->out; p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0); if (p == NULL) return stbi__err("outofmem", "Out of memory"); // between here and free(out) below, exitting would leak temp_out = p; if (pal_img_n == 3) { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p += 3; } } else { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p[3] = palette[n+3]; p += 4; } } STBI_FREE(a->out); a->out = temp_out; STBI_NOTUSED(len); return 1; } static int stbi__unpremultiply_on_load = 0; static int stbi__de_iphone_flag = 0; STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) { stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply; } STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) { stbi__de_iphone_flag = flag_true_if_should_convert; } static void stbi__de_iphone(stbi__png *z) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi_uc *p = z->out; if (s->img_out_n == 3) { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi_uc t = p[0]; p[0] = p[2]; p[2] = t; p += 3; } } else { STBI_ASSERT(s->img_out_n == 4); if (stbi__unpremultiply_on_load) { // convert bgr to rgb and unpremultiply for (i=0; i < pixel_count; ++i) { stbi_uc a = p[3]; stbi_uc t = p[0]; if (a) { stbi_uc half = a / 2; p[0] = (p[2] * 255 + half) / a; p[1] = (p[1] * 255 + half) / a; p[2] = ( t * 255 + half) / a; } else { p[0] = p[2]; p[2] = t; } p += 4; } } else { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi_uc t = p[0]; p[0] = p[2]; p[2] = t; p += 4; } } } } #define STBI__PNG_TYPE(a,b,c,d) (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) { stbi_uc palette[1024], pal_img_n=0; stbi_uc has_trans=0, tc[3]; stbi__uint16 tc16[3]; stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; int first=1,k,interlace=0, color=0, is_iphone=0; stbi__context *s = z->s; z->expanded = NULL; z->idata = NULL; z->out = NULL; if (!stbi__check_png_header(s)) return 0; if (scan == STBI__SCAN_type) return 1; for (;;) { stbi__pngchunk c = stbi__get_chunk_header(s); switch (c.type) { case STBI__PNG_TYPE('C','g','B','I'): is_iphone = 1; stbi__skip(s, c.length); break; case STBI__PNG_TYPE('I','H','D','R'): { int comp,filter; if (!first) return stbi__err("multiple IHDR","Corrupt PNG"); first = 0; if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG"); s->img_x = stbi__get32be(s); if (s->img_x > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); s->img_y = stbi__get32be(s); if (s->img_y > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); z->depth = stbi__get8(s); if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16) return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only"); color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG"); if (color == 3 && z->depth == 16) return stbi__err("bad ctype","Corrupt PNG"); if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG"); comp = stbi__get8(s); if (comp) return stbi__err("bad comp method","Corrupt PNG"); filter= stbi__get8(s); if (filter) return stbi__err("bad filter method","Corrupt PNG"); interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG"); if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG"); if (!pal_img_n) { s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); if (scan == STBI__SCAN_header) return 1; } else { // if paletted, then pal_n is our final components, and // img_n is # components to decompress/filter. s->img_n = 1; if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG"); // if SCAN_header, have to scan to see if we have a tRNS } break; } case STBI__PNG_TYPE('P','L','T','E'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG"); pal_len = c.length / 3; if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG"); for (i=0; i < pal_len; ++i) { palette[i*4+0] = stbi__get8(s); palette[i*4+1] = stbi__get8(s); palette[i*4+2] = stbi__get8(s); palette[i*4+3] = 255; } break; } case STBI__PNG_TYPE('t','R','N','S'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG"); if (pal_img_n) { if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG"); if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG"); pal_img_n = 4; for (i=0; i < c.length; ++i) palette[i*4+3] = stbi__get8(s); } else { if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG"); if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG"); has_trans = 1; if (z->depth == 16) { for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is } else { for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger } } break; } case STBI__PNG_TYPE('I','D','A','T'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; } if ((int)(ioff + c.length) < (int)ioff) return 0; if (ioff + c.length > idata_limit) { stbi__uint32 idata_limit_old = idata_limit; stbi_uc *p; if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; while (ioff + c.length > idata_limit) idata_limit *= 2; STBI_NOTUSED(idata_limit_old); p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); z->idata = p; } if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); ioff += c.length; break; } case STBI__PNG_TYPE('I','E','N','D'): { stbi__uint32 raw_len, bpl; if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (scan != STBI__SCAN_load) return 1; if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG"); // initial guess for decoded data size to avoid unnecessary reallocs bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone); if (z->expanded == NULL) return 0; // zlib should set error STBI_FREE(z->idata); z->idata = NULL; if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) s->img_out_n = s->img_n+1; else s->img_out_n = s->img_n; if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0; if (has_trans) { if (z->depth == 16) { if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0; } else { if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; } } if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) stbi__de_iphone(z); if (pal_img_n) { // pal_img_n == 3 or 4 s->img_n = pal_img_n; // record the actual colors we had s->img_out_n = pal_img_n; if (req_comp >= 3) s->img_out_n = req_comp; if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) return 0; } else if (has_trans) { // non-paletted image with tRNS -> source image has (constant) alpha ++s->img_n; } STBI_FREE(z->expanded); z->expanded = NULL; return 1; } default: // if critical, fail if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if ((c.type & (1 << 29)) == 0) { #ifndef STBI_NO_FAILURE_STRINGS // not threadsafe static char invalid_chunk[] = "XXXX PNG chunk not known"; invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); #endif return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); } stbi__skip(s, c.length); break; } // end of PNG chunk, read and skip CRC stbi__get32be(s); } } static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri) { void *result=NULL; if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { if (p->depth < 8) ri->bits_per_channel = 8; else ri->bits_per_channel = p->depth; result = p->out; p->out = NULL; if (req_comp && req_comp != p->s->img_out_n) { if (ri->bits_per_channel == 8) result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); else result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); p->s->img_out_n = req_comp; if (result == NULL) return result; } *x = p->s->img_x; *y = p->s->img_y; if (n) *n = p->s->img_n; } STBI_FREE(p->out); p->out = NULL; STBI_FREE(p->expanded); p->expanded = NULL; STBI_FREE(p->idata); p->idata = NULL; return result; } static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi__png p; p.s = s; return stbi__do_png(&p, x,y,comp,req_comp, ri); } static int stbi__png_test(stbi__context *s) { int r; r = stbi__check_png_header(s); stbi__rewind(s); return r; } static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) { if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { stbi__rewind( p->s ); return 0; } if (x) *x = p->s->img_x; if (y) *y = p->s->img_y; if (comp) *comp = p->s->img_n; return 1; } static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) { stbi__png p; p.s = s; return stbi__png_info_raw(&p, x, y, comp); } #endif // Microsoft/Windows BMP image #ifndef STBI_NO_BMP static int stbi__bmp_test_raw(stbi__context *s) { int r; int sz; if (stbi__get8(s) != 'B') return 0; if (stbi__get8(s) != 'M') return 0; stbi__get32le(s); // discard filesize stbi__get16le(s); // discard reserved stbi__get16le(s); // discard reserved stbi__get32le(s); // discard data offset sz = stbi__get32le(s); r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); return r; } static int stbi__bmp_test(stbi__context *s) { int r = stbi__bmp_test_raw(s); stbi__rewind(s); return r; } // returns 0..31 for the highest set bit static int stbi__high_bit(unsigned int z) { int n=0; if (z == 0) return -1; if (z >= 0x10000) n += 16, z >>= 16; if (z >= 0x00100) n += 8, z >>= 8; if (z >= 0x00010) n += 4, z >>= 4; if (z >= 0x00004) n += 2, z >>= 2; if (z >= 0x00002) n += 1, z >>= 1; return n; } static int stbi__bitcount(unsigned int a) { a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits a = (a + (a >> 8)); // max 16 per 8 bits a = (a + (a >> 16)); // max 32 per 8 bits return a & 0xff; } static int stbi__shiftsigned(int v, int shift, int bits) { int result; int z=0; if (shift < 0) v <<= -shift; else v >>= shift; result = v; z = bits; while (z < 8) { result += v >> z; z += bits; } return result; } typedef struct { int bpp, offset, hsz; unsigned int mr,mg,mb,ma, all_a; } stbi__bmp_data; static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) { int hsz; if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); stbi__get32le(s); // discard filesize stbi__get16le(s); // discard reserved stbi__get16le(s); // discard reserved info->offset = stbi__get32le(s); info->hsz = hsz = stbi__get32le(s); info->mr = info->mg = info->mb = info->ma = 0; if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); if (hsz == 12) { s->img_x = stbi__get16le(s); s->img_y = stbi__get16le(s); } else { s->img_x = stbi__get32le(s); s->img_y = stbi__get32le(s); } if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); info->bpp = stbi__get16le(s); if (info->bpp == 1) return stbi__errpuc("monochrome", "BMP type not supported: 1-bit"); if (hsz != 12) { int compress = stbi__get32le(s); if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); stbi__get32le(s); // discard sizeof stbi__get32le(s); // discard hres stbi__get32le(s); // discard vres stbi__get32le(s); // discard colorsused stbi__get32le(s); // discard max important if (hsz == 40 || hsz == 56) { if (hsz == 56) { stbi__get32le(s); stbi__get32le(s); stbi__get32le(s); stbi__get32le(s); } if (info->bpp == 16 || info->bpp == 32) { if (compress == 0) { if (info->bpp == 32) { info->mr = 0xffu << 16; info->mg = 0xffu << 8; info->mb = 0xffu << 0; info->ma = 0xffu << 24; info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 } else { info->mr = 31u << 10; info->mg = 31u << 5; info->mb = 31u << 0; } } else if (compress == 3) { info->mr = stbi__get32le(s); info->mg = stbi__get32le(s); info->mb = stbi__get32le(s); // not documented, but generated by photoshop and handled by mspaint if (info->mr == info->mg && info->mg == info->mb) { // ?!?!? return stbi__errpuc("bad BMP", "bad BMP"); } } else return stbi__errpuc("bad BMP", "bad BMP"); } } else { int i; if (hsz != 108 && hsz != 124) return stbi__errpuc("bad BMP", "bad BMP"); info->mr = stbi__get32le(s); info->mg = stbi__get32le(s); info->mb = stbi__get32le(s); info->ma = stbi__get32le(s); stbi__get32le(s); // discard color space for (i=0; i < 12; ++i) stbi__get32le(s); // discard color space parameters if (hsz == 124) { stbi__get32le(s); // discard rendering intent stbi__get32le(s); // discard offset of profile data stbi__get32le(s); // discard size of profile data stbi__get32le(s); // discard reserved } } } return (void *) 1; } static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *out; unsigned int mr=0,mg=0,mb=0,ma=0, all_a; stbi_uc pal[256][4]; int psize=0,i,j,width; int flip_vertically, pad, target; stbi__bmp_data info; STBI_NOTUSED(ri); info.all_a = 255; if (stbi__bmp_parse_header(s, &info) == NULL) return NULL; // error code already set flip_vertically = ((int) s->img_y) > 0; s->img_y = abs((int) s->img_y); mr = info.mr; mg = info.mg; mb = info.mb; ma = info.ma; all_a = info.all_a; if (info.hsz == 12) { if (info.bpp < 24) psize = (info.offset - 14 - 24) / 3; } else { if (info.bpp < 16) psize = (info.offset - 14 - info.hsz) >> 2; } s->img_n = ma ? 4 : 3; if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 target = req_comp; else target = s->img_n; // if they want monochrome, we'll post-convert // sanity-check size if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0)) return stbi__errpuc("too large", "Corrupt BMP"); out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0); if (!out) return stbi__errpuc("outofmem", "Out of memory"); if (info.bpp < 16) { int z=0; if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } for (i=0; i < psize; ++i) { pal[i][2] = stbi__get8(s); pal[i][1] = stbi__get8(s); pal[i][0] = stbi__get8(s); if (info.hsz != 12) stbi__get8(s); pal[i][3] = 255; } stbi__skip(s, info.offset - 14 - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); if (info.bpp == 4) width = (s->img_x + 1) >> 1; else if (info.bpp == 8) width = s->img_x; else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } pad = (-width)&3; for (j=0; j < (int) s->img_y; ++j) { for (i=0; i < (int) s->img_x; i += 2) { int v=stbi__get8(s),v2=0; if (info.bpp == 4) { v2 = v & 15; v >>= 4; } out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; if (i+1 == (int) s->img_x) break; v = (info.bpp == 8) ? stbi__get8(s) : v2; out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; } stbi__skip(s, pad); } } else { int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; int z = 0; int easy=0; stbi__skip(s, info.offset - 14 - info.hsz); if (info.bpp == 24) width = 3 * s->img_x; else if (info.bpp == 16) width = 2*s->img_x; else /* bpp = 32 and pad = 0 */ width=0; pad = (-width) & 3; if (info.bpp == 24) { easy = 1; } else if (info.bpp == 32) { if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) easy = 2; } if (!easy) { if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } // right shift amt to put high bit in position #7 rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr); gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg); bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb); ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma); } for (j=0; j < (int) s->img_y; ++j) { if (easy) { for (i=0; i < (int) s->img_x; ++i) { unsigned char a; out[z+2] = stbi__get8(s); out[z+1] = stbi__get8(s); out[z+0] = stbi__get8(s); z += 3; a = (easy == 2 ? stbi__get8(s) : 255); all_a |= a; if (target == 4) out[z++] = a; } } else { int bpp = info.bpp; for (i=0; i < (int) s->img_x; ++i) { stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s)); int a; out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); all_a |= a; if (target == 4) out[z++] = STBI__BYTECAST(a); } } stbi__skip(s, pad); } } // if alpha channel is all 0s, replace with all 255s if (target == 4 && all_a == 0) for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4) out[i] = 255; if (flip_vertically) { stbi_uc t; for (j=0; j < (int) s->img_y>>1; ++j) { stbi_uc *p1 = out + j *s->img_x*target; stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; for (i=0; i < (int) s->img_x*target; ++i) { t = p1[i], p1[i] = p2[i], p2[i] = t; } } } if (req_comp && req_comp != target) { out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); if (out == NULL) return out; // stbi__convert_format frees input on failure } *x = s->img_x; *y = s->img_y; if (comp) *comp = s->img_n; return out; } #endif // Targa Truevision - TGA // by Jonathan Dummer #ifndef STBI_NO_TGA // returns STBI_rgb or whatever, 0 on error static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) { // only RGB or RGBA (incl. 16bit) or grey allowed if(is_rgb16) *is_rgb16 = 0; switch(bits_per_pixel) { case 8: return STBI_grey; case 16: if(is_grey) return STBI_grey_alpha; // else: fall-through case 15: if(is_rgb16) *is_rgb16 = 1; return STBI_rgb; case 24: // fall-through case 32: return bits_per_pixel/8; default: return 0; } } static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) { int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; int sz, tga_colormap_type; stbi__get8(s); // discard Offset tga_colormap_type = stbi__get8(s); // colormap type if( tga_colormap_type > 1 ) { stbi__rewind(s); return 0; // only RGB or indexed allowed } tga_image_type = stbi__get8(s); // image type if ( tga_colormap_type == 1 ) { // colormapped (paletted) image if (tga_image_type != 1 && tga_image_type != 9) { stbi__rewind(s); return 0; } stbi__skip(s,4); // skip index of first colormap entry and number of entries sz = stbi__get8(s); // check bits per palette color entry if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) { stbi__rewind(s); return 0; } stbi__skip(s,4); // skip image x and y origin tga_colormap_bpp = sz; } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) { stbi__rewind(s); return 0; // only RGB or grey allowed, +/- RLE } stbi__skip(s,9); // skip colormap specification and image x/y origin tga_colormap_bpp = 0; } tga_w = stbi__get16le(s); if( tga_w < 1 ) { stbi__rewind(s); return 0; // test width } tga_h = stbi__get16le(s); if( tga_h < 1 ) { stbi__rewind(s); return 0; // test height } tga_bits_per_pixel = stbi__get8(s); // bits per pixel stbi__get8(s); // ignore alpha bits if (tga_colormap_bpp != 0) { if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { // when using a colormap, tga_bits_per_pixel is the size of the indexes // I don't think anything but 8 or 16bit indexes makes sense stbi__rewind(s); return 0; } tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); } else { tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL); } if(!tga_comp) { stbi__rewind(s); return 0; } if (x) *x = tga_w; if (y) *y = tga_h; if (comp) *comp = tga_comp; return 1; // seems to have passed everything } static int stbi__tga_test(stbi__context *s) { int res = 0; int sz, tga_color_type; stbi__get8(s); // discard Offset tga_color_type = stbi__get8(s); // color type if ( tga_color_type > 1 ) goto errorEnd; // only RGB or indexed allowed sz = stbi__get8(s); // image type if ( tga_color_type == 1 ) { // colormapped (paletted) image if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9 stbi__skip(s,4); // skip index of first colormap entry and number of entries sz = stbi__get8(s); // check bits per palette color entry if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; stbi__skip(s,4); // skip image x and y origin } else { // "normal" image w/o colormap if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE stbi__skip(s,9); // skip colormap specification and image x/y origin } if ( stbi__get16le(s) < 1 ) goto errorEnd; // test width if ( stbi__get16le(s) < 1 ) goto errorEnd; // test height sz = stbi__get8(s); // bits per pixel if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; res = 1; // if we got this far, everything's good and we can return 1 instead of 0 errorEnd: stbi__rewind(s); return res; } // read 16bit value and convert to 24bit RGB static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) { stbi__uint16 px = (stbi__uint16)stbi__get16le(s); stbi__uint16 fiveBitMask = 31; // we have 3 channels with 5bits each int r = (px >> 10) & fiveBitMask; int g = (px >> 5) & fiveBitMask; int b = px & fiveBitMask; // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later out[0] = (stbi_uc)((r * 255)/31); out[1] = (stbi_uc)((g * 255)/31); out[2] = (stbi_uc)((b * 255)/31); // some people claim that the most significant bit might be used for alpha // (possibly if an alpha-bit is set in the "image descriptor byte") // but that only made 16bit test images completely translucent.. // so let's treat all 15 and 16bit TGAs as RGB with no alpha. } static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { // read in the TGA header stuff int tga_offset = stbi__get8(s); int tga_indexed = stbi__get8(s); int tga_image_type = stbi__get8(s); int tga_is_RLE = 0; int tga_palette_start = stbi__get16le(s); int tga_palette_len = stbi__get16le(s); int tga_palette_bits = stbi__get8(s); int tga_x_origin = stbi__get16le(s); int tga_y_origin = stbi__get16le(s); int tga_width = stbi__get16le(s); int tga_height = stbi__get16le(s); int tga_bits_per_pixel = stbi__get8(s); int tga_comp, tga_rgb16=0; int tga_inverted = stbi__get8(s); // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) // image data unsigned char *tga_data; unsigned char *tga_palette = NULL; int i, j; unsigned char raw_data[4] = {0}; int RLE_count = 0; int RLE_repeating = 0; int read_next_pixel = 1; STBI_NOTUSED(ri); // do a tiny bit of precessing if ( tga_image_type >= 8 ) { tga_image_type -= 8; tga_is_RLE = 1; } tga_inverted = 1 - ((tga_inverted >> 5) & 1); // If I'm paletted, then I'll use the number of bits from the palette if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); // tga info *x = tga_width; *y = tga_height; if (comp) *comp = tga_comp; if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0)) return stbi__errpuc("too large", "Corrupt TGA"); tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0); if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); // skip to the data's starting position (offset usually = 0) stbi__skip(s, tga_offset ); if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) { for (i=0; i < tga_height; ++i) { int row = tga_inverted ? tga_height -i - 1 : i; stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; stbi__getn(s, tga_row, tga_width * tga_comp); } } else { // do I need to load a palette? if ( tga_indexed) { // any data to skip? (offset usually = 0) stbi__skip(s, tga_palette_start ); // load the palette tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0); if (!tga_palette) { STBI_FREE(tga_data); return stbi__errpuc("outofmem", "Out of memory"); } if (tga_rgb16) { stbi_uc *pal_entry = tga_palette; STBI_ASSERT(tga_comp == STBI_rgb); for (i=0; i < tga_palette_len; ++i) { stbi__tga_read_rgb16(s, pal_entry); pal_entry += tga_comp; } } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { STBI_FREE(tga_data); STBI_FREE(tga_palette); return stbi__errpuc("bad palette", "Corrupt TGA"); } } // load the data for (i=0; i < tga_width * tga_height; ++i) { // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? if ( tga_is_RLE ) { if ( RLE_count == 0 ) { // yep, get the next byte as a RLE command int RLE_cmd = stbi__get8(s); RLE_count = 1 + (RLE_cmd & 127); RLE_repeating = RLE_cmd >> 7; read_next_pixel = 1; } else if ( !RLE_repeating ) { read_next_pixel = 1; } } else { read_next_pixel = 1; } // OK, if I need to read a pixel, do it now if ( read_next_pixel ) { // load however much data we did have if ( tga_indexed ) { // read in index, then perform the lookup int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); if ( pal_idx >= tga_palette_len ) { // invalid index pal_idx = 0; } pal_idx *= tga_comp; for (j = 0; j < tga_comp; ++j) { raw_data[j] = tga_palette[pal_idx+j]; } } else if(tga_rgb16) { STBI_ASSERT(tga_comp == STBI_rgb); stbi__tga_read_rgb16(s, raw_data); } else { // read in the data raw for (j = 0; j < tga_comp; ++j) { raw_data[j] = stbi__get8(s); } } // clear the reading flag for the next pixel read_next_pixel = 0; } // end of reading a pixel // copy data for (j = 0; j < tga_comp; ++j) tga_data[i*tga_comp+j] = raw_data[j]; // in case we're in RLE mode, keep counting down --RLE_count; } // do I need to invert the image? if ( tga_inverted ) { for (j = 0; j*2 < tga_height; ++j) { int index1 = j * tga_width * tga_comp; int index2 = (tga_height - 1 - j) * tga_width * tga_comp; for (i = tga_width * tga_comp; i > 0; --i) { unsigned char temp = tga_data[index1]; tga_data[index1] = tga_data[index2]; tga_data[index2] = temp; ++index1; ++index2; } } } // clear my palette, if I had one if ( tga_palette != NULL ) { STBI_FREE( tga_palette ); } } // swap RGB - if the source data was RGB16, it already is in the right order if (tga_comp >= 3 && !tga_rgb16) { unsigned char* tga_pixel = tga_data; for (i=0; i < tga_width * tga_height; ++i) { unsigned char temp = tga_pixel[0]; tga_pixel[0] = tga_pixel[2]; tga_pixel[2] = temp; tga_pixel += tga_comp; } } // convert to target component count if (req_comp && req_comp != tga_comp) tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); // the things I do to get rid of an error message, and yet keep // Microsoft's C compilers happy... [8^( tga_palette_start = tga_palette_len = tga_palette_bits = tga_x_origin = tga_y_origin = 0; // OK, done return tga_data; } #endif // ************************************************************************************************* // Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB #ifndef STBI_NO_PSD static int stbi__psd_test(stbi__context *s) { int r = (stbi__get32be(s) == 0x38425053); stbi__rewind(s); return r; } static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) { int count, nleft, len; count = 0; while ((nleft = pixelCount - count) > 0) { len = stbi__get8(s); if (len == 128) { // No-op. } else if (len < 128) { // Copy next len+1 bytes literally. len++; if (len > nleft) return 0; // corrupt data count += len; while (len) { *p = stbi__get8(s); p += 4; len--; } } else if (len > 128) { stbi_uc val; // Next -len+1 bytes in the dest are replicated from next source byte. // (Interpret len as a negative 8-bit int.) len = 257 - len; if (len > nleft) return 0; // corrupt data val = stbi__get8(s); count += len; while (len) { *p = val; p += 4; len--; } } } return 1; } static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) { int pixelCount; int channelCount, compression; int channel, i; int bitdepth; int w,h; stbi_uc *out; STBI_NOTUSED(ri); // Check identifier if (stbi__get32be(s) != 0x38425053) // "8BPS" return stbi__errpuc("not PSD", "Corrupt PSD image"); // Check file type version. if (stbi__get16be(s) != 1) return stbi__errpuc("wrong version", "Unsupported version of PSD image"); // Skip 6 reserved bytes. stbi__skip(s, 6 ); // Read the number of channels (R, G, B, A, etc). channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); // Read the rows and columns of the image. h = stbi__get32be(s); w = stbi__get32be(s); // Make sure the depth is 8 bits. bitdepth = stbi__get16be(s); if (bitdepth != 8 && bitdepth != 16) return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); // Make sure the color mode is RGB. // Valid options are: // 0: Bitmap // 1: Grayscale // 2: Indexed color // 3: RGB color // 4: CMYK color // 7: Multichannel // 8: Duotone // 9: Lab color if (stbi__get16be(s) != 3) return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) stbi__skip(s,stbi__get32be(s) ); // Skip the image resources. (resolution, pen tool paths, etc) stbi__skip(s, stbi__get32be(s) ); // Skip the reserved data. stbi__skip(s, stbi__get32be(s) ); // Find out if the data is compressed. // Known values: // 0: no compression // 1: RLE compressed compression = stbi__get16be(s); if (compression > 1) return stbi__errpuc("bad compression", "PSD has an unknown compression format"); // Check size if (!stbi__mad3sizes_valid(4, w, h, 0)) return stbi__errpuc("too large", "Corrupt PSD"); // Create the destination image. if (!compression && bitdepth == 16 && bpc == 16) { out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0); ri->bits_per_channel = 16; } else out = (stbi_uc *) stbi__malloc(4 * w*h); if (!out) return stbi__errpuc("outofmem", "Out of memory"); pixelCount = w*h; // Initialize the data to zero. //memset( out, 0, pixelCount * 4 ); // Finally, the image data. if (compression) { // RLE as used by .PSD and .TIFF // Loop until you get the number of unpacked bytes you are expecting: // Read the next source byte into n. // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. // Else if n is 128, noop. // Endloop // The RLE-compressed data is preceeded by a 2-byte data count for each row in the data, // which we're going to just skip. stbi__skip(s, h * channelCount * 2 ); // Read the RLE data by channel. for (channel = 0; channel < 4; channel++) { stbi_uc *p; p = out+channel; if (channel >= channelCount) { // Fill this channel with default data. for (i = 0; i < pixelCount; i++, p += 4) *p = (channel == 3 ? 255 : 0); } else { // Read the RLE data. if (!stbi__psd_decode_rle(s, p, pixelCount)) { STBI_FREE(out); return stbi__errpuc("corrupt", "bad RLE data"); } } } } else { // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image. // Read the data by channel. for (channel = 0; channel < 4; channel++) { if (channel >= channelCount) { // Fill this channel with default data. if (bitdepth == 16 && bpc == 16) { stbi__uint16 *q = ((stbi__uint16 *) out) + channel; stbi__uint16 val = channel == 3 ? 65535 : 0; for (i = 0; i < pixelCount; i++, q += 4) *q = val; } else { stbi_uc *p = out+channel; stbi_uc val = channel == 3 ? 255 : 0; for (i = 0; i < pixelCount; i++, p += 4) *p = val; } } else { if (ri->bits_per_channel == 16) { // output bpc stbi__uint16 *q = ((stbi__uint16 *) out) + channel; for (i = 0; i < pixelCount; i++, q += 4) *q = (stbi__uint16) stbi__get16be(s); } else { stbi_uc *p = out+channel; if (bitdepth == 16) { // input bpc for (i = 0; i < pixelCount; i++, p += 4) *p = (stbi_uc) (stbi__get16be(s) >> 8); } else { for (i = 0; i < pixelCount; i++, p += 4) *p = stbi__get8(s); } } } } } // remove weird white matte from PSD if (channelCount >= 4) { if (ri->bits_per_channel == 16) { for (i=0; i < w*h; ++i) { stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i; if (pixel[3] != 0 && pixel[3] != 65535) { float a = pixel[3] / 65535.0f; float ra = 1.0f / a; float inv_a = 65535.0f * (1 - ra); pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a); pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a); pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a); } } } else { for (i=0; i < w*h; ++i) { unsigned char *pixel = out + 4*i; if (pixel[3] != 0 && pixel[3] != 255) { float a = pixel[3] / 255.0f; float ra = 1.0f / a; float inv_a = 255.0f * (1 - ra); pixel[0] = (unsigned char) (pixel[0]*ra + inv_a); pixel[1] = (unsigned char) (pixel[1]*ra + inv_a); pixel[2] = (unsigned char) (pixel[2]*ra + inv_a); } } } } // convert to desired output format if (req_comp && req_comp != 4) { if (ri->bits_per_channel == 16) out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h); else out = stbi__convert_format(out, 4, req_comp, w, h); if (out == NULL) return out; // stbi__convert_format frees input on failure } if (comp) *comp = 4; *y = h; *x = w; return out; } #endif // ************************************************************************************************* // Softimage PIC loader // by Tom Seddon // // See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format // See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ #ifndef STBI_NO_PIC static int stbi__pic_is4(stbi__context *s,const char *str) { int i; for (i=0; i<4; ++i) if (stbi__get8(s) != (stbi_uc)str[i]) return 0; return 1; } static int stbi__pic_test_core(stbi__context *s) { int i; if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) return 0; for(i=0;i<84;++i) stbi__get8(s); if (!stbi__pic_is4(s,"PICT")) return 0; return 1; } typedef struct { stbi_uc size,type,channel; } stbi__pic_packet; static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) { int mask=0x80, i; for (i=0; i<4; ++i, mask>>=1) { if (channel & mask) { if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short"); dest[i]=stbi__get8(s); } } return dest; } static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) { int mask=0x80,i; for (i=0;i<4; ++i, mask>>=1) if (channel&mask) dest[i]=src[i]; } static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) { int act_comp=0,num_packets=0,y,chained; stbi__pic_packet packets[10]; // this will (should...) cater for even some bizarre stuff like having data // for the same channel in multiple packets. do { stbi__pic_packet *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return stbi__errpuc("bad format","too many packets"); packet = &packets[num_packets++]; chained = stbi__get8(s); packet->size = stbi__get8(s); packet->type = stbi__get8(s); packet->channel = stbi__get8(s); act_comp |= packet->channel; if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)"); if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp"); } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? for(y=0; ytype) { default: return stbi__errpuc("bad format","packet has bad compression type"); case 0: {//uncompressed int x; for(x=0;xchannel,dest)) return 0; break; } case 1://Pure RLE { int left=width, i; while (left>0) { stbi_uc count,value[4]; count=stbi__get8(s); if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)"); if (count > left) count = (stbi_uc) left; if (!stbi__readval(s,packet->channel,value)) return 0; for(i=0; ichannel,dest,value); left -= count; } } break; case 2: {//Mixed RLE int left=width; while (left>0) { int count = stbi__get8(s), i; if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (mixed read count)"); if (count >= 128) { // Repeated stbi_uc value[4]; if (count==128) count = stbi__get16be(s); else count -= 127; if (count > left) return stbi__errpuc("bad file","scanline overrun"); if (!stbi__readval(s,packet->channel,value)) return 0; for(i=0;ichannel,dest,value); } else { // Raw ++count; if (count>left) return stbi__errpuc("bad file","scanline overrun"); for(i=0;ichannel,dest)) return 0; } left-=count; } break; } } } } return result; } static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri) { stbi_uc *result; int i, x,y, internal_comp; STBI_NOTUSED(ri); if (!comp) comp = &internal_comp; for (i=0; i<92; ++i) stbi__get8(s); x = stbi__get16be(s); y = stbi__get16be(s); if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)"); if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode"); stbi__get32be(s); //skip `ratio' stbi__get16be(s); //skip `fields' stbi__get16be(s); //skip `pad' // intermediate buffer is RGBA result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0); memset(result, 0xff, x*y*4); if (!stbi__pic_load_core(s,x,y,comp, result)) { STBI_FREE(result); result=0; } *px = x; *py = y; if (req_comp == 0) req_comp = *comp; result=stbi__convert_format(result,4,req_comp,x,y); return result; } static int stbi__pic_test(stbi__context *s) { int r = stbi__pic_test_core(s); stbi__rewind(s); return r; } #endif // ************************************************************************************************* // GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb #ifndef STBI_NO_GIF typedef struct { stbi__int16 prefix; stbi_uc first; stbi_uc suffix; } stbi__gif_lzw; typedef struct { int w,h; stbi_uc *out, *old_out; // output buffer (always 4 components) int flags, bgindex, ratio, transparent, eflags, delay; stbi_uc pal[256][4]; stbi_uc lpal[256][4]; stbi__gif_lzw codes[4096]; stbi_uc *color_table; int parse, step; int lflags; int start_x, start_y; int max_x, max_y; int cur_x, cur_y; int line_size; } stbi__gif; static int stbi__gif_test_raw(stbi__context *s) { int sz; if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; sz = stbi__get8(s); if (sz != '9' && sz != '7') return 0; if (stbi__get8(s) != 'a') return 0; return 1; } static int stbi__gif_test(stbi__context *s) { int r = stbi__gif_test_raw(s); stbi__rewind(s); return r; } static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) { int i; for (i=0; i < num_entries; ++i) { pal[i][2] = stbi__get8(s); pal[i][1] = stbi__get8(s); pal[i][0] = stbi__get8(s); pal[i][3] = transp == i ? 0 : 255; } } static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) { stbi_uc version; if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return stbi__err("not GIF", "Corrupt GIF"); version = stbi__get8(s); if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); stbi__g_failure_reason = ""; g->w = stbi__get16le(s); g->h = stbi__get16le(s); g->flags = stbi__get8(s); g->bgindex = stbi__get8(s); g->ratio = stbi__get8(s); g->transparent = -1; if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments if (is_info) return 1; if (g->flags & 0x80) stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); return 1; } static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) { stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif)); if (!stbi__gif_header(s, g, comp, 1)) { STBI_FREE(g); stbi__rewind( s ); return 0; } if (x) *x = g->w; if (y) *y = g->h; STBI_FREE(g); return 1; } static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) { stbi_uc *p, *c; // recurse to decode the prefixes, since the linked-list is backwards, // and working backwards through an interleaved image would be nasty if (g->codes[code].prefix >= 0) stbi__out_gif_code(g, g->codes[code].prefix); if (g->cur_y >= g->max_y) return; p = &g->out[g->cur_x + g->cur_y]; c = &g->color_table[g->codes[code].suffix * 4]; if (c[3] >= 128) { p[0] = c[2]; p[1] = c[1]; p[2] = c[0]; p[3] = c[3]; } g->cur_x += 4; if (g->cur_x >= g->max_x) { g->cur_x = g->start_x; g->cur_y += g->step; while (g->cur_y >= g->max_y && g->parse > 0) { g->step = (1 << g->parse) * g->line_size; g->cur_y = g->start_y + (g->step >> 1); --g->parse; } } } static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) { stbi_uc lzw_cs; stbi__int32 len, init_code; stbi__uint32 first; stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; stbi__gif_lzw *p; lzw_cs = stbi__get8(s); if (lzw_cs > 12) return NULL; clear = 1 << lzw_cs; first = 1; codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; bits = 0; valid_bits = 0; for (init_code = 0; init_code < clear; init_code++) { g->codes[init_code].prefix = -1; g->codes[init_code].first = (stbi_uc) init_code; g->codes[init_code].suffix = (stbi_uc) init_code; } // support no starting clear code avail = clear+2; oldcode = -1; len = 0; for(;;) { if (valid_bits < codesize) { if (len == 0) { len = stbi__get8(s); // start new block if (len == 0) return g->out; } --len; bits |= (stbi__int32) stbi__get8(s) << valid_bits; valid_bits += 8; } else { stbi__int32 code = bits & codemask; bits >>= codesize; valid_bits -= codesize; // @OPTIMIZE: is there some way we can accelerate the non-clear path? if (code == clear) { // clear code codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; avail = clear + 2; oldcode = -1; first = 0; } else if (code == clear + 1) { // end of stream code stbi__skip(s, len); while ((len = stbi__get8(s)) > 0) stbi__skip(s,len); return g->out; } else if (code <= avail) { if (first) return stbi__errpuc("no clear code", "Corrupt GIF"); if (oldcode >= 0) { p = &g->codes[avail++]; if (avail > 4096) return stbi__errpuc("too many codes", "Corrupt GIF"); p->prefix = (stbi__int16) oldcode; p->first = g->codes[oldcode].first; p->suffix = (code == avail) ? p->first : g->codes[code].first; } else if (code == avail) return stbi__errpuc("illegal code in raster", "Corrupt GIF"); stbi__out_gif_code(g, (stbi__uint16) code); if ((avail & codemask) == 0 && avail <= 0x0FFF) { codesize++; codemask = (1 << codesize) - 1; } oldcode = code; } else { return stbi__errpuc("illegal code in raster", "Corrupt GIF"); } } } } static void stbi__fill_gif_background(stbi__gif *g, int x0, int y0, int x1, int y1) { int x, y; stbi_uc *c = g->pal[g->bgindex]; for (y = y0; y < y1; y += 4 * g->w) { for (x = x0; x < x1; x += 4) { stbi_uc *p = &g->out[y + x]; p[0] = c[2]; p[1] = c[1]; p[2] = c[0]; p[3] = 0; } } } // this function is designed to support animated gifs, although stb_image doesn't support it static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp) { int i; stbi_uc *prev_out = 0; if (g->out == 0 && !stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header if (!stbi__mad3sizes_valid(g->w, g->h, 4, 0)) return stbi__errpuc("too large", "GIF too large"); prev_out = g->out; g->out = (stbi_uc *) stbi__malloc_mad3(4, g->w, g->h, 0); if (g->out == 0) return stbi__errpuc("outofmem", "Out of memory"); switch ((g->eflags & 0x1C) >> 2) { case 0: // unspecified (also always used on 1st frame) stbi__fill_gif_background(g, 0, 0, 4 * g->w, 4 * g->w * g->h); break; case 1: // do not dispose if (prev_out) memcpy(g->out, prev_out, 4 * g->w * g->h); g->old_out = prev_out; break; case 2: // dispose to background if (prev_out) memcpy(g->out, prev_out, 4 * g->w * g->h); stbi__fill_gif_background(g, g->start_x, g->start_y, g->max_x, g->max_y); break; case 3: // dispose to previous if (g->old_out) { for (i = g->start_y; i < g->max_y; i += 4 * g->w) memcpy(&g->out[i + g->start_x], &g->old_out[i + g->start_x], g->max_x - g->start_x); } break; } for (;;) { switch (stbi__get8(s)) { case 0x2C: /* Image Descriptor */ { int prev_trans = -1; stbi__int32 x, y, w, h; stbi_uc *o; x = stbi__get16le(s); y = stbi__get16le(s); w = stbi__get16le(s); h = stbi__get16le(s); if (((x + w) > (g->w)) || ((y + h) > (g->h))) return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); g->line_size = g->w * 4; g->start_x = x * 4; g->start_y = y * g->line_size; g->max_x = g->start_x + w * 4; g->max_y = g->start_y + h * g->line_size; g->cur_x = g->start_x; g->cur_y = g->start_y; g->lflags = stbi__get8(s); if (g->lflags & 0x40) { g->step = 8 * g->line_size; // first interlaced spacing g->parse = 3; } else { g->step = g->line_size; g->parse = 0; } if (g->lflags & 0x80) { stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); g->color_table = (stbi_uc *) g->lpal; } else if (g->flags & 0x80) { if (g->transparent >= 0 && (g->eflags & 0x01)) { prev_trans = g->pal[g->transparent][3]; g->pal[g->transparent][3] = 0; } g->color_table = (stbi_uc *) g->pal; } else return stbi__errpuc("missing color table", "Corrupt GIF"); o = stbi__process_gif_raster(s, g); if (o == NULL) return NULL; if (prev_trans != -1) g->pal[g->transparent][3] = (stbi_uc) prev_trans; return o; } case 0x21: // Comment Extension. { int len; if (stbi__get8(s) == 0xF9) { // Graphic Control Extension. len = stbi__get8(s); if (len == 4) { g->eflags = stbi__get8(s); g->delay = stbi__get16le(s); g->transparent = stbi__get8(s); } else { stbi__skip(s, len); break; } } while ((len = stbi__get8(s)) != 0) stbi__skip(s, len); break; } case 0x3B: // gif stream termination code return (stbi_uc *) s; // using '1' causes warning on some compilers default: return stbi__errpuc("unknown code", "Corrupt GIF"); } } STBI_NOTUSED(req_comp); } static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *u = 0; stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif)); memset(g, 0, sizeof(*g)); STBI_NOTUSED(ri); u = stbi__gif_load_next(s, g, comp, req_comp); if (u == (stbi_uc *) s) u = 0; // end of animated gif marker if (u) { *x = g->w; *y = g->h; if (req_comp && req_comp != 4) u = stbi__convert_format(u, 4, req_comp, g->w, g->h); } else if (g->out) STBI_FREE(g->out); STBI_FREE(g); return u; } static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) { return stbi__gif_info_raw(s,x,y,comp); } #endif // ************************************************************************************************* // Radiance RGBE HDR loader // originally by Nicolas Schulz #ifndef STBI_NO_HDR static int stbi__hdr_test_core(stbi__context *s, const char *signature) { int i; for (i=0; signature[i]; ++i) if (stbi__get8(s) != signature[i]) return 0; stbi__rewind(s); return 1; } static int stbi__hdr_test(stbi__context* s) { int r = stbi__hdr_test_core(s, "#?RADIANCE\n"); stbi__rewind(s); if(!r) { r = stbi__hdr_test_core(s, "#?RGBE\n"); stbi__rewind(s); } return r; } #define STBI__HDR_BUFLEN 1024 static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) { int len=0; char c = '\0'; c = (char) stbi__get8(z); while (!stbi__at_eof(z) && c != '\n') { buffer[len++] = c; if (len == STBI__HDR_BUFLEN-1) { // flush to end of line while (!stbi__at_eof(z) && stbi__get8(z) != '\n') ; break; } c = (char) stbi__get8(z); } buffer[len] = 0; return buffer; } static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) { if ( input[3] != 0 ) { float f1; // Exponent f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); if (req_comp <= 2) output[0] = (input[0] + input[1] + input[2]) * f1 / 3; else { output[0] = input[0] * f1; output[1] = input[1] * f1; output[2] = input[2] * f1; } if (req_comp == 2) output[1] = 1; if (req_comp == 4) output[3] = 1; } else { switch (req_comp) { case 4: output[3] = 1; /* fallthrough */ case 3: output[0] = output[1] = output[2] = 0; break; case 2: output[1] = 1; /* fallthrough */ case 1: output[0] = 0; break; } } } static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { char buffer[STBI__HDR_BUFLEN]; char *token; int valid = 0; int width, height; stbi_uc *scanline; float *hdr_data; int len; unsigned char count, value; int i, j, k, c1,c2, z; const char *headerToken; STBI_NOTUSED(ri); // Check identifier headerToken = stbi__hdr_gettoken(s,buffer); if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0) return stbi__errpf("not HDR", "Corrupt HDR image"); // Parse header for(;;) { token = stbi__hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); // Parse width and height // can't use sscanf() if we're not using stdio! token = stbi__hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); token += 3; height = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); token += 3; width = (int) strtol(token, NULL, 10); *x = width; *y = height; if (comp) *comp = 3; if (req_comp == 0) req_comp = 3; if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0)) return stbi__errpf("too large", "HDR image is too large"); // Read data hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0); if (!hdr_data) return stbi__errpf("outofmem", "Out of memory"); // Load image data // image data is stored as some number of sca if ( width < 8 || width >= 32768) { // Read flat data for (j=0; j < height; ++j) { for (i=0; i < width; ++i) { stbi_uc rgbe[4]; main_decode_loop: stbi__getn(s, rgbe, 4); stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); } } } else { // Read RLE-encoded data scanline = NULL; for (j = 0; j < height; ++j) { c1 = stbi__get8(s); c2 = stbi__get8(s); len = stbi__get8(s); if (c1 != 2 || c2 != 2 || (len & 0x80)) { // not run-length encoded, so we have to actually use THIS data as a decoded // pixel (note this can't be a valid pixel--one of RGB must be >= 128) stbi_uc rgbe[4]; rgbe[0] = (stbi_uc) c1; rgbe[1] = (stbi_uc) c2; rgbe[2] = (stbi_uc) len; rgbe[3] = (stbi_uc) stbi__get8(s); stbi__hdr_convert(hdr_data, rgbe, req_comp); i = 1; j = 0; STBI_FREE(scanline); goto main_decode_loop; // yes, this makes no sense } len <<= 8; len |= stbi__get8(s); if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } if (scanline == NULL) { scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0); if (!scanline) { STBI_FREE(hdr_data); return stbi__errpf("outofmem", "Out of memory"); } } for (k = 0; k < 4; ++k) { int nleft; i = 0; while ((nleft = width - i) > 0) { count = stbi__get8(s); if (count > 128) { // Run value = stbi__get8(s); count -= 128; if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = value; } else { // Dump if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = stbi__get8(s); } } } for (i=0; i < width; ++i) stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); } if (scanline) STBI_FREE(scanline); } return hdr_data; } static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) { char buffer[STBI__HDR_BUFLEN]; char *token; int valid = 0; int dummy; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (stbi__hdr_test(s) == 0) { stbi__rewind( s ); return 0; } for(;;) { token = stbi__hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) { stbi__rewind( s ); return 0; } token = stbi__hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) { stbi__rewind( s ); return 0; } token += 3; *y = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) { stbi__rewind( s ); return 0; } token += 3; *x = (int) strtol(token, NULL, 10); *comp = 3; return 1; } #endif // STBI_NO_HDR #ifndef STBI_NO_BMP static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) { void *p; stbi__bmp_data info; info.all_a = 255; p = stbi__bmp_parse_header(s, &info); stbi__rewind( s ); if (p == NULL) return 0; if (x) *x = s->img_x; if (y) *y = s->img_y; if (comp) *comp = info.ma ? 4 : 3; return 1; } #endif #ifndef STBI_NO_PSD static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) { int channelCount, dummy; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (stbi__get32be(s) != 0x38425053) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 1) { stbi__rewind( s ); return 0; } stbi__skip(s, 6); channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) { stbi__rewind( s ); return 0; } *y = stbi__get32be(s); *x = stbi__get32be(s); if (stbi__get16be(s) != 8) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 3) { stbi__rewind( s ); return 0; } *comp = 4; return 1; } #endif #ifndef STBI_NO_PIC static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) { int act_comp=0,num_packets=0,chained,dummy; stbi__pic_packet packets[10]; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) { stbi__rewind(s); return 0; } stbi__skip(s, 88); *x = stbi__get16be(s); *y = stbi__get16be(s); if (stbi__at_eof(s)) { stbi__rewind( s); return 0; } if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { stbi__rewind( s ); return 0; } stbi__skip(s, 8); do { stbi__pic_packet *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return 0; packet = &packets[num_packets++]; chained = stbi__get8(s); packet->size = stbi__get8(s); packet->type = stbi__get8(s); packet->channel = stbi__get8(s); act_comp |= packet->channel; if (stbi__at_eof(s)) { stbi__rewind( s ); return 0; } if (packet->size != 8) { stbi__rewind( s ); return 0; } } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); return 1; } #endif // ************************************************************************************************* // Portable Gray Map and Portable Pixel Map loader // by Ken Miller // // PGM: http://netpbm.sourceforge.net/doc/pgm.html // PPM: http://netpbm.sourceforge.net/doc/ppm.html // // Known limitations: // Does not support comments in the header section // Does not support ASCII image data (formats P2 and P3) // Does not support 16-bit-per-channel #ifndef STBI_NO_PNM static int stbi__pnm_test(stbi__context *s) { char p, t; p = (char) stbi__get8(s); t = (char) stbi__get8(s); if (p != 'P' || (t != '5' && t != '6')) { stbi__rewind( s ); return 0; } return 1; } static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *out; STBI_NOTUSED(ri); if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n)) return 0; *x = s->img_x; *y = s->img_y; if (comp) *comp = s->img_n; if (!stbi__mad3sizes_valid(s->img_n, s->img_x, s->img_y, 0)) return stbi__errpuc("too large", "PNM too large"); out = (stbi_uc *) stbi__malloc_mad3(s->img_n, s->img_x, s->img_y, 0); if (!out) return stbi__errpuc("outofmem", "Out of memory"); stbi__getn(s, out, s->img_n * s->img_x * s->img_y); if (req_comp && req_comp != s->img_n) { out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); if (out == NULL) return out; // stbi__convert_format frees input on failure } return out; } static int stbi__pnm_isspace(char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; } static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) { for (;;) { while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) *c = (char) stbi__get8(s); if (stbi__at_eof(s) || *c != '#') break; while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' ) *c = (char) stbi__get8(s); } } static int stbi__pnm_isdigit(char c) { return c >= '0' && c <= '9'; } static int stbi__pnm_getinteger(stbi__context *s, char *c) { int value = 0; while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { value = value*10 + (*c - '0'); *c = (char) stbi__get8(s); } return value; } static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) { int maxv, dummy; char c, p, t; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; stbi__rewind(s); // Get identifier p = (char) stbi__get8(s); t = (char) stbi__get8(s); if (p != 'P' || (t != '5' && t != '6')) { stbi__rewind(s); return 0; } *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm c = (char) stbi__get8(s); stbi__pnm_skip_whitespace(s, &c); *x = stbi__pnm_getinteger(s, &c); // read width stbi__pnm_skip_whitespace(s, &c); *y = stbi__pnm_getinteger(s, &c); // read height stbi__pnm_skip_whitespace(s, &c); maxv = stbi__pnm_getinteger(s, &c); // read max value if (maxv > 255) return stbi__err("max value > 255", "PPM image not 8-bit"); else return 1; } #endif static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) { #ifndef STBI_NO_JPEG if (stbi__jpeg_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNG if (stbi__png_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_GIF if (stbi__gif_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_BMP if (stbi__bmp_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PSD if (stbi__psd_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PIC if (stbi__pic_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNM if (stbi__pnm_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_HDR if (stbi__hdr_info(s, x, y, comp)) return 1; #endif // test tga last because it's a crappy test! #ifndef STBI_NO_TGA if (stbi__tga_info(s, x, y, comp)) return 1; #endif return stbi__err("unknown image type", "Image not of any known type, or corrupt"); } #ifndef STBI_NO_STDIO STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) { FILE *f = stbi__fopen(filename, "rb"); int result; if (!f) return stbi__err("can't fopen", "Unable to open file"); result = stbi_info_from_file(f, x, y, comp); fclose(f); return result; } STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) { int r; stbi__context s; long pos = ftell(f); stbi__start_file(&s, f); r = stbi__info_main(&s,x,y,comp); fseek(f,pos,SEEK_SET); return r; } #endif // !STBI_NO_STDIO STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__info_main(&s,x,y,comp); } STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); return stbi__info_main(&s,x,y,comp); } #endif // STB_IMAGE_IMPLEMENTATION /* revision history: 2.16 (2017-07-23) all functions have 16-bit variants; STBI_NO_STDIO works again; compilation fixes; fix rounding in unpremultiply; optimize vertical flip; disable raw_len validation; documentation fixes 2.15 (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode; warning fixes; disable run-time SSE detection on gcc; uniform handling of optional "return" values; thread-safe initialization of zlib tables 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs 2.13 (2016-11-29) add 16-bit API, only supported for PNG right now 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes 2.11 (2016-04-02) allocate large structures on the stack remove white matting for transparent PSD fix reported channel count for PNG & BMP re-enable SSE2 in non-gcc 64-bit support RGB-formatted JPEG read 16-bit PNGs (only as 8-bit) 2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED 2.09 (2016-01-16) allow comments in PNM files 16-bit-per-pixel TGA (not bit-per-component) info() for TGA could break due to .hdr handling info() for BMP to shares code instead of sloppy parse can use STBI_REALLOC_SIZED if allocator doesn't support realloc code cleanup 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA 2.07 (2015-09-13) fix compiler warnings partial animated GIF support limited 16-bpc PSD support #ifdef unused functions bug with < 92 byte PIC,PNM,HDR,TGA 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit 2.03 (2015-04-12) extra corruption checking (mmozeiko) stbi_set_flip_vertically_on_load (nguillemot) fix NEON support; fix mingw support 2.02 (2015-01-19) fix incorrect assert, fix warning 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) progressive JPEG (stb) PGM/PPM support (Ken Miller) STBI_MALLOC,STBI_REALLOC,STBI_FREE GIF bugfix -- seemingly never worked STBI_NO_*, STBI_ONLY_* 1.48 (2014-12-14) fix incorrectly-named assert() 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) optimize PNG (ryg) fix bug in interlaced PNG with user-specified channel count (stb) 1.46 (2014-08-26) fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG 1.45 (2014-08-16) fix MSVC-ARM internal compiler error by wrapping malloc 1.44 (2014-08-07) various warning fixes from Ronny Chevalier 1.43 (2014-07-15) fix MSVC-only compiler problem in code changed in 1.42 1.42 (2014-07-09) don't define _CRT_SECURE_NO_WARNINGS (affects user code) fixes to stbi__cleanup_jpeg path added STBI_ASSERT to avoid requiring assert.h 1.41 (2014-06-25) fix search&replace from 1.36 that messed up comments/error messages 1.40 (2014-06-22) fix gcc struct-initialization warning 1.39 (2014-06-15) fix to TGA optimization when req_comp != number of components in TGA; fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) add support for BMP version 5 (more ignored fields) 1.38 (2014-06-06) suppress MSVC warnings on integer casts truncating values fix accidental rename of 'skip' field of I/O 1.37 (2014-06-04) remove duplicate typedef 1.36 (2014-06-03) convert to header file single-file library if de-iphone isn't set, load iphone images color-swapped instead of returning NULL 1.35 (2014-05-27) various warnings fix broken STBI_SIMD path fix bug where stbi_load_from_file no longer left file pointer in correct place fix broken non-easy path for 32-bit BMP (possibly never used) TGA optimization by Arseny Kapoulkine 1.34 (unknown) use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case 1.33 (2011-07-14) make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements 1.32 (2011-07-13) support for "info" function for all supported filetypes (SpartanJ) 1.31 (2011-06-20) a few more leak fixes, bug in PNG handling (SpartanJ) 1.30 (2011-06-11) added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) removed deprecated format-specific test/load functions removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) fix inefficiency in decoding 32-bit BMP (David Woo) 1.29 (2010-08-16) various warning fixes from Aurelien Pocheville 1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ) 1.27 (2010-08-01) cast-to-stbi_uc to fix warnings 1.26 (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ 1.25 (2010-07-17) refix trans_data warning (Won Chun) 1.24 (2010-07-12) perf improvements reading from files on platforms with lock-heavy fgetc() minor perf improvements for jpeg deprecated type-specific functions so we'll get feedback if they're needed attempt to fix trans_data warning (Won Chun) 1.23 fixed bug in iPhone support 1.22 (2010-07-10) removed image *writing* support stbi_info support from Jetro Lauha GIF support from Jean-Marc Lienher iPhone PNG-extensions from James Brown warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) 1.21 fix use of 'stbi_uc' in header (reported by jon blow) 1.20 added support for Softimage PIC, by Tom Seddon 1.19 bug in interlaced PNG corruption check (found by ryg) 1.18 (2008-08-02) fix a threading bug (local mutable static) 1.17 support interlaced PNG 1.16 major bugfix - stbi__convert_format converted one too many pixels 1.15 initialize some fields for thread safety 1.14 fix threadsafe conversion bug header-file-only version (#define STBI_HEADER_FILE_ONLY before including) 1.13 threadsafe 1.12 const qualifiers in the API 1.11 Support installable IDCT, colorspace conversion routines 1.10 Fixes for 64-bit (don't use "unsigned long") optimized upsampling by Fabian "ryg" Giesen 1.09 Fix format-conversion for PSD code (bad global variables!) 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz 1.07 attempt to fix C++ warning/errors again 1.06 attempt to fix C++ warning/errors again 1.05 fix TGA loading to return correct *comp and use good luminance calc 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR 1.02 support for (subset of) HDR files, float interface for preferred access to them 1.01 fix bug: possible bug in handling right-side up bmps... not sure fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all 1.00 interface to zlib that skips zlib header 0.99 correct handling of alpha in palette 0.98 TGA loader by lonesock; dynamically add loaders (untested) 0.97 jpeg errors on too large a file; also catch another malloc failure 0.96 fix detection of invalid v value - particleman@mollyrocket forum 0.95 during header scan, seek to markers in case of padding 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same 0.93 handle jpegtran output; verbose errors 0.92 read 4,8,16,24,32-bit BMP files of several formats 0.91 output 24-bit Windows 3.0 BMP files 0.90 fix a few more warnings; bump version number to approach 1.0 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd 0.60 fix compiling as c++ 0.59 fix warnings: merge Dave Moore's -Wall fixes 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available 0.56 fix bug: zlib uncompressed mode len vs. nlen 0.55 fix bug: restart_interval not initialized to 0 0.54 allow NULL for 'int *comp' 0.53 fix bug in png 3->4; speedup png decoding 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments 0.51 obey req_comp requests, 1-component jpegs return as 1-component, on 'test' only check type, not whether we support this variant 0.50 (2006-11-19) first released version */ /* ------------------------------------------------------------------------------ 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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_herringbone_wang_tile.h0000600000175000001440000012405114003056224021765 0ustar rakusers/* stbhw - v0.6 - http://nothings.org/gamedev/herringbone Herringbone Wang Tile Generator - Sean Barrett 2014 - public domain == LICENSE ============================== This software is dual-licensed to the public domain and under the following license: you are granted a perpetual, irrevocable license to copy, modify, publish, and distribute this file as you see fit. == WHAT IT IS =========================== This library is an SDK for Herringbone Wang Tile generation: http://nothings.org/gamedev/herringbone The core design is that you use this library offline to generate a "template" of the tiles you'll create. You then edit those tiles, then load the created tile image file back into this library and use it at runtime to generate "maps". You cannot load arbitrary tile image files with this library; it is only designed to load image files made from the template it created. It stores a binary description of the tile sizes & constraints in a few pixels, and uses those to recover the rules, rather than trying to parse the tiles themselves. You *can* use this library to generate from arbitrary tile sets, but only by loading the tile set and specifying the constraints explicitly yourself. == COMPILING ============================ 1. #define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION before including this header file in *one* source file to create the implementation in that source file. 2. optionally #define STB_HBWANG_RAND() to be a random number generator. if you don't define it, it will use rand(), and you need to seed srand() yourself. 3. optionally #define STB_HBWANG_ASSERT(x), otherwise it will use assert() 4. optionally #define STB_HBWANG_STATIC to force all symbols to be static instead of public, so they are only accesible in the source file that creates the implementation 5. optionally #define STB_HBWANG_NO_REPITITION_REDUCTION to disable the code that tries to reduce having the same tile appear adjacent to itself in wang-corner-tile mode (e.g. imagine if you were doing something where 90% of things should be the same grass tile, you need to disable this system) 6. optionally define STB_HBWANG_MAX_X and STB_HBWANG_MAX_Y to be the max dimensions of the generated map in multiples of the wang tile's short side's length (e.g. if you have 20x10 wang tiles, so short_side_len=10, and you have MAX_X is 17, then the largest map you can generate is 170 pixels wide). The defaults are 100x100. This is used to define static arrays which affect memory usage. == USING ================================ To use the map generator, you need a tileset. You can download some sample tilesets from http://nothings.org/gamedev/herringbone Then see the "sample application" below. You can also use this file to generate templates for tilesets which you then hand-edit to create the data. == MEMORY MANAGEMENT ==================== The tileset loader allocates memory with malloc(). The map generator does no memory allocation, so e.g. you can load tilesets at startup and never free them and never do any further allocation. == SAMPLE APPLICATION =================== #include #include #include #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" // http://nothings.org/stb_image.c #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" // http://nothings.org/stb/stb_image_write.h #define STB_HBWANG_IMPLEMENTATION #include "stb_hbwang.h" int main(int argc, char **argv) { unsigned char *data; int xs,ys, w,h; stbhw_tileset ts; if (argc != 4) { fprintf(stderr, "Usage: mapgen {tile-file} {xsize} {ysize}\n" "generates file named 'test_map.png'\n"); exit(1); } data = stbi_load(argv[1], &w, &h, NULL, 3); xs = atoi(argv[2]); ys = atoi(argv[3]); if (data == NULL) { fprintf(stderr, "Error opening or parsing '%s' as an image file\n", argv[1]); exit(1); } if (xs < 1 || xs > 1000) { fprintf(stderr, "xsize invalid or out of range\n"); exit(1); } if (ys < 1 || ys > 1000) { fprintf(stderr, "ysize invalid or out of range\n"); exit(1); } stbhw_build_tileset_from_image(&ts, data, w*3, w, h); free(data); // allocate a buffer to create the final image to data = malloc(3 * xs * ys); srand(time(NULL)); stbhw_generate_image(&ts, NULL, data, xs*3, xs, ys); stbi_write_png("test_map.png", xs, ys, 3, data, xs*3); stbhw_free_tileset(&ts); free(data); return 0; } == VERSION HISTORY =================== 0.6 2014-08-17 - fix broken map-maker 0.5 2014-07-07 - initial release */ ////////////////////////////////////////////////////////////////////////////// // // // HEADER FILE SECTION // // // #ifndef INCLUDE_STB_HWANG_H #define INCLUDE_STB_HWANG_H #ifdef STB_HBWANG_STATIC #define STBHW_EXTERN static #else #ifdef __cplusplus #define STBHW_EXTERN extern "C" #else #define STBHW_EXTERN extern #endif #endif typedef struct stbhw_tileset stbhw_tileset; // returns description of last error produced by any function (not thread-safe) STBHW_EXTERN char *stbhw_get_last_error(void); // build a tileset from an image that conforms to a template created by this // library. (you allocate storage for stbhw_tileset and function fills it out; // memory for individual tiles are malloc()ed). // returns non-zero on success, 0 on error STBHW_EXTERN int stbhw_build_tileset_from_image(stbhw_tileset *ts, unsigned char *pixels, int stride_in_bytes, int w, int h); // free a tileset built by stbhw_build_tileset_from_image STBHW_EXTERN void stbhw_free_tileset(stbhw_tileset *ts); // generate a map that is w * h pixels (3-bytes each) // returns non-zero on success, 0 on error // not thread-safe (uses a global data structure to avoid memory management) // weighting should be NULL, as non-NULL weighting is currently untested STBHW_EXTERN int stbhw_generate_image(stbhw_tileset *ts, int **weighting, unsigned char *pixels, int stride_in_bytes, int w, int h); ////////////////////////////////////// // // TILESET DATA STRUCTURE // // if you use the image-to-tileset system from this file, you // don't need to worry about these data structures. but if you // want to build/load a tileset yourself, you'll need to fill // these out. typedef struct { // the edge or vertex constraints, according to diagram below signed char a,b,c,d,e,f; // The herringbone wang tile data; it is a bitmap which is either // w=2*short_sidelen,h=short_sidelen, or w=short_sidelen,h=2*short_sidelen. // it is always RGB, stored row-major, with no padding between rows. // (allocate stbhw_tile structure to be large enough for the pixel data) unsigned char pixels[1]; } stbhw_tile; struct stbhw_tileset { int is_corner; int num_color[6]; // number of colors for each of 6 edge types or 4 corner types int short_side_len; stbhw_tile **h_tiles; stbhw_tile **v_tiles; int num_h_tiles, max_h_tiles; int num_v_tiles, max_v_tiles; }; /////////////// TEMPLATE GENERATOR ////////////////////////// // when requesting a template, you fill out this data typedef struct { int is_corner; // using corner colors or edge colors? int short_side_len; // rectangles is 2n x n, n = short_side_len int num_color[6]; // see below diagram for meaning of the index to this; // 6 values if edge (!is_corner), 4 values if is_corner // legal numbers: 1..8 if edge, 1..4 if is_corner int num_vary_x; // additional number of variations along x axis in the template int num_vary_y; // additional number of variations along y axis in the template int corner_type_color_template[4][4]; // if corner_type_color_template[s][t] is non-zero, then any // corner of type s generated as color t will get a little // corner sample markup in the template image data } stbhw_config; // computes the size needed for the template image STBHW_EXTERN void stbhw_get_template_size(stbhw_config *c, int *w, int *h); // generates a template image, assuming data is 3*w*h bytes long, RGB format STBHW_EXTERN int stbhw_make_template(stbhw_config *c, unsigned char *data, int w, int h, int stride_in_bytes); #endif//INCLUDE_STB_HWANG_H // TILE CONSTRAINT TYPES // // there are 4 "types" of corners and 6 types of edges. // you can configure the tileset to have different numbers // of colors for each type of color or edge. // // corner types: // // 0---*---1---*---2---*---3 // | | | // * * * // | | | // 1---*---2---*---3 0---*---1---*---2 // | | | // * * * // | | | // 0---*---1---*---2---*---3 // // // edge types: // // *---2---*---3---* *---0---* // | | | | // 1 4 5 1 // | | | | // *---0---*---2---* * * // | | // 4 5 // | | // *---3---* // // TILE CONSTRAINTS // // each corner/edge has a color; this shows the name // of the variable containing the color // // corner constraints: // // a---*---d // | | // * * // | | // a---*---b---*---c b e // | | | | // * * * * // | | | | // d---*---e---*---f c---*---f // // // edge constraints: // // *---a---*---b---* *---a---* // | | | | // c d b c // | | | | // *---e---*---f---* * * // | | // d e // | | // *---f---* // ////////////////////////////////////////////////////////////////////////////// // // // IMPLEMENTATION SECTION // // // #ifdef STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION #include // memcpy #include // malloc #ifndef STB_HBWANG_RAND #include #define STB_HBWANG_RAND() (rand() >> 4) #endif #ifndef STB_HBWANG_ASSERT #include #define STB_HBWANG_ASSERT(x) assert(x) #endif // map size #ifndef STB_HBWANG_MAX_X #define STB_HBWANG_MAX_X 100 #endif #ifndef STB_HBWANG_MAX_Y #define STB_HBWANG_MAX_Y 100 #endif // global variables for color assignments // @MEMORY change these to just store last two/three rows // and keep them on the stack static signed char c_color[STB_HBWANG_MAX_Y+6][STB_HBWANG_MAX_X+6]; static signed char v_color[STB_HBWANG_MAX_Y+6][STB_HBWANG_MAX_X+5]; static signed char h_color[STB_HBWANG_MAX_Y+5][STB_HBWANG_MAX_X+6]; static char *stbhw_error; STBHW_EXTERN char *stbhw_get_last_error(void) { char *temp = stbhw_error; stbhw_error = 0; return temp; } ///////////////////////////////////////////////////////////// // // SHARED TEMPLATE-DESCRIPTION CODE // // Used by both template generator and tileset parser; by // using the same code, they are locked in sync and we don't // need to try to do more sophisticated parsing of edge color // markup or something. typedef void stbhw__process_rect(struct stbhw__process *p, int xpos, int ypos, int a, int b, int c, int d, int e, int f); typedef struct stbhw__process { stbhw_tileset *ts; stbhw_config *c; stbhw__process_rect *process_h_rect; stbhw__process_rect *process_v_rect; unsigned char *data; int stride,w,h; } stbhw__process; static void stbhw__process_h_row(stbhw__process *p, int xpos, int ypos, int a0, int a1, int b0, int b1, int c0, int c1, int d0, int d1, int e0, int e1, int f0, int f1, int variants) { int a,b,c,d,e,f,v; for (v=0; v < variants; ++v) for (f=f0; f <= f1; ++f) for (e=e0; e <= e1; ++e) for (d=d0; d <= d1; ++d) for (c=c0; c <= c1; ++c) for (b=b0; b <= b1; ++b) for (a=a0; a <= a1; ++a) { p->process_h_rect(p, xpos, ypos, a,b,c,d,e,f); xpos += 2*p->c->short_side_len + 3; } } static void stbhw__process_v_row(stbhw__process *p, int xpos, int ypos, int a0, int a1, int b0, int b1, int c0, int c1, int d0, int d1, int e0, int e1, int f0, int f1, int variants) { int a,b,c,d,e,f,v; for (v=0; v < variants; ++v) for (f=f0; f <= f1; ++f) for (e=e0; e <= e1; ++e) for (d=d0; d <= d1; ++d) for (c=c0; c <= c1; ++c) for (b=b0; b <= b1; ++b) for (a=a0; a <= a1; ++a) { p->process_v_rect(p, xpos, ypos, a,b,c,d,e,f); xpos += p->c->short_side_len+3; } } static void stbhw__get_template_info(stbhw_config *c, int *w, int *h, int *h_count, int *v_count) { int size_x,size_y; int horz_count,vert_count; if (c->is_corner) { int horz_w = c->num_color[1] * c->num_color[2] * c->num_color[3] * c->num_vary_x; int horz_h = c->num_color[0] * c->num_color[1] * c->num_color[2] * c->num_vary_y; int vert_w = c->num_color[0] * c->num_color[3] * c->num_color[2] * c->num_vary_y; int vert_h = c->num_color[1] * c->num_color[0] * c->num_color[3] * c->num_vary_x; int horz_x = horz_w * (2*c->short_side_len + 3); int horz_y = horz_h * ( c->short_side_len + 3); int vert_x = vert_w * ( c->short_side_len + 3); int vert_y = vert_h * (2*c->short_side_len + 3); horz_count = horz_w * horz_h; vert_count = vert_w * vert_h; size_x = horz_x > vert_x ? horz_x : vert_x; size_y = 2 + horz_y + 2 + vert_y; } else { int horz_w = c->num_color[0] * c->num_color[1] * c->num_color[2] * c->num_vary_x; int horz_h = c->num_color[3] * c->num_color[4] * c->num_color[2] * c->num_vary_y; int vert_w = c->num_color[0] * c->num_color[5] * c->num_color[1] * c->num_vary_y; int vert_h = c->num_color[3] * c->num_color[4] * c->num_color[5] * c->num_vary_x; int horz_x = horz_w * (2*c->short_side_len + 3); int horz_y = horz_h * ( c->short_side_len + 3); int vert_x = vert_w * ( c->short_side_len + 3); int vert_y = vert_h * (2*c->short_side_len + 3); horz_count = horz_w * horz_h; vert_count = vert_w * vert_h; size_x = horz_x > vert_x ? horz_x : vert_x; size_y = 2 + horz_y + 2 + vert_y; } if (w) *w = size_x; if (h) *h = size_y; if (h_count) *h_count = horz_count; if (v_count) *v_count = vert_count; } STBHW_EXTERN void stbhw_get_template_size(stbhw_config *c, int *w, int *h) { stbhw__get_template_info(c, w, h, NULL, NULL); } static int stbhw__process_template(stbhw__process *p) { int i,j,k,q, ypos; int size_x, size_y; stbhw_config *c = p->c; stbhw__get_template_info(c, &size_x, &size_y, NULL, NULL); if (p->w < size_x || p->h < size_y) { stbhw_error = "image too small for configuration"; return 0; } if (c->is_corner) { ypos = 2; for (k=0; k < c->num_color[2]; ++k) { for (j=0; j < c->num_color[1]; ++j) { for (i=0; i < c->num_color[0]; ++i) { for (q=0; q < c->num_vary_y; ++q) { stbhw__process_h_row(p, 0,ypos, 0,c->num_color[1]-1, 0,c->num_color[2]-1, 0,c->num_color[3]-1, i,i, j,j, k,k, c->num_vary_x); ypos += c->short_side_len + 3; } } } } ypos += 2; for (k=0; k < c->num_color[3]; ++k) { for (j=0; j < c->num_color[0]; ++j) { for (i=0; i < c->num_color[1]; ++i) { for (q=0; q < c->num_vary_x; ++q) { stbhw__process_v_row(p, 0,ypos, 0,c->num_color[0]-1, 0,c->num_color[3]-1, 0,c->num_color[2]-1, i,i, j,j, k,k, c->num_vary_y); ypos += (c->short_side_len*2) + 3; } } } } assert(ypos == size_y); } else { ypos = 2; for (k=0; k < c->num_color[3]; ++k) { for (j=0; j < c->num_color[4]; ++j) { for (i=0; i < c->num_color[2]; ++i) { for (q=0; q < c->num_vary_y; ++q) { stbhw__process_h_row(p, 0,ypos, 0,c->num_color[2]-1, k,k, 0,c->num_color[1]-1, j,j, 0,c->num_color[0]-1, i,i, c->num_vary_x); ypos += c->short_side_len + 3; } } } } ypos += 2; for (k=0; k < c->num_color[3]; ++k) { for (j=0; j < c->num_color[4]; ++j) { for (i=0; i < c->num_color[5]; ++i) { for (q=0; q < c->num_vary_x; ++q) { stbhw__process_v_row(p, 0,ypos, 0,c->num_color[0]-1, i,i, 0,c->num_color[1]-1, j,j, 0,c->num_color[5]-1, k,k, c->num_vary_y); ypos += (c->short_side_len*2) + 3; } } } } assert(ypos == size_y); } return 1; } ///////////////////////////////////////////////////////////// // // MAP GENERATOR // static void stbhw__draw_pixel(unsigned char *output, int stride, int x, int y, unsigned char c[3]) { memcpy(output + y*stride + x*3, c, 3); } static void stbhw__draw_h_tile(unsigned char *output, int stride, int xmax, int ymax, int x, int y, stbhw_tile *h, int sz) { int i,j; for (j=0; j < sz; ++j) if (y+j >= 0 && y+j < ymax) for (i=0; i < sz*2; ++i) if (x+i >= 0 && x+i < xmax) stbhw__draw_pixel(output,stride, x+i,y+j, &h->pixels[(j*sz*2 + i)*3]); } static void stbhw__draw_v_tile(unsigned char *output, int stride, int xmax, int ymax, int x, int y, stbhw_tile *h, int sz) { int i,j; for (j=0; j < sz*2; ++j) if (y+j >= 0 && y+j < ymax) for (i=0; i < sz; ++i) if (x+i >= 0 && x+i < xmax) stbhw__draw_pixel(output,stride, x+i,y+j, &h->pixels[(j*sz + i)*3]); } // randomly choose a tile that fits constraints for a given spot, and update the constraints static stbhw_tile * stbhw__choose_tile(stbhw_tile **list, int numlist, signed char *a, signed char *b, signed char *c, signed char *d, signed char *e, signed char *f, int **weighting) { int i,n,m = 1<<30,pass; for (pass=0; pass < 2; ++pass) { n=0; // pass #1: // count number of variants that match this partial set of constraints // pass #2: // stop on randomly selected match for (i=0; i < numlist; ++i) { stbhw_tile *h = list[i]; if ((*a < 0 || *a == h->a) && (*b < 0 || *b == h->b) && (*c < 0 || *c == h->c) && (*d < 0 || *d == h->d) && (*e < 0 || *e == h->e) && (*f < 0 || *f == h->f)) { if (weighting) n += weighting[0][i]; else n += 1; if (n > m) { // use list[i] // update constraints to reflect what we placed *a = h->a; *b = h->b; *c = h->c; *d = h->d; *e = h->e; *f = h->f; return h; } } } if (n == 0) { stbhw_error = "couldn't find tile matching constraints"; return NULL; } m = STB_HBWANG_RAND() % n; } STB_HBWANG_ASSERT(0); return NULL; } static int stbhw__match(int x, int y) { return c_color[y][x] == c_color[y+1][x+1]; } static int stbhw__weighted(int num_options, int *weights) { int k, total, choice; total = 0; for (k=0; k < num_options; ++k) total += weights[k]; choice = STB_HBWANG_RAND() % total; total = 0; for (k=0; k < num_options; ++k) { total += weights[k]; if (choice < total) break; } STB_HBWANG_ASSERT(k < num_options); return k; } static int stbhw__change_color(int old_color, int num_options, int *weights) { if (weights) { int k, total, choice; total = 0; for (k=0; k < num_options; ++k) if (k != old_color) total += weights[k]; choice = STB_HBWANG_RAND() % total; total = 0; for (k=0; k < num_options; ++k) { if (k != old_color) { total += weights[k]; if (choice < total) break; } } STB_HBWANG_ASSERT(k < num_options); return k; } else { int offset = 1+STB_HBWANG_RAND() % (num_options-1); return (old_color+offset) % num_options; } } // generate a map that is w * h pixels (3-bytes each) // returns 1 on success, 0 on error STBHW_EXTERN int stbhw_generate_image(stbhw_tileset *ts, int **weighting, unsigned char *output, int stride, int w, int h) { int sidelen = ts->short_side_len; int xmax = (w / sidelen) + 6; int ymax = (h / sidelen) + 6; if (xmax > STB_HBWANG_MAX_X+6 || ymax > STB_HBWANG_MAX_Y+6) { stbhw_error = "increase STB_HBWANG_MAX_X/Y"; return 0; } if (ts->is_corner) { int i,j, ypos; int *cc = ts->num_color; for (j=0; j < ymax; ++j) { for (i=0; i < xmax; ++i) { int p = (i-j+1)&3; // corner type if (weighting==NULL || weighting[p]==0 || cc[p] == 1) c_color[j][i] = STB_HBWANG_RAND() % cc[p]; else c_color[j][i] = stbhw__weighted(cc[p], weighting[p]); } } #ifndef STB_HBWANG_NO_REPITITION_REDUCTION // now go back through and make sure we don't have adjancent 3x2 vertices that are identical, // to avoid really obvious repetition (which happens easily with extreme weights) for (j=0; j < ymax-3; ++j) { for (i=0; i < xmax-3; ++i) { int p = (i-j+1) & 3; // corner type STB_HBWANG_ASSERT(i+3 < STB_HBWANG_MAX_X+6); STB_HBWANG_ASSERT(j+3 < STB_HBWANG_MAX_Y+6); if (stbhw__match(i,j) && stbhw__match(i,j+1) && stbhw__match(i,j+2) && stbhw__match(i+1,j) && stbhw__match(i+1,j+1) && stbhw__match(i+1,j+2)) { int p = ((i+1)-(j+1)+1) & 3; if (cc[p] > 1) c_color[j+1][i+1] = stbhw__change_color(c_color[j+1][i+1], cc[p], weighting ? weighting[p] : NULL); } if (stbhw__match(i,j) && stbhw__match(i+1,j) && stbhw__match(i+2,j) && stbhw__match(i,j+1) && stbhw__match(i+1,j+1) && stbhw__match(i+2,j+1)) { int p = ((i+2)-(j+1)+1) & 3; if (cc[p] > 1) c_color[j+1][i+2] = stbhw__change_color(c_color[j+1][i+2], cc[p], weighting ? weighting[p] : NULL); } } } #endif ypos = -1 * sidelen; for (j = -1; ypos < h; ++j) { // a general herringbone row consists of: // horizontal left block, the bottom of a previous vertical, the top of a new vertical int phase = (j & 3); // displace horizontally according to pattern if (phase == 0) { i = 0; } else { i = phase-4; } for (i;; i += 4) { int xpos = i * sidelen; if (xpos >= w) break; // horizontal left-block if (xpos + sidelen*2 >= 0 && ypos >= 0) { stbhw_tile *t = stbhw__choose_tile( ts->h_tiles, ts->num_h_tiles, &c_color[j+2][i+2], &c_color[j+2][i+3], &c_color[j+2][i+4], &c_color[j+3][i+2], &c_color[j+3][i+3], &c_color[j+3][i+4], weighting ); if (t == NULL) return 0; stbhw__draw_h_tile(output,stride,w,h, xpos, ypos, t, sidelen); } xpos += sidelen * 2; // now we're at the end of a previous vertical one xpos += sidelen; // now we're at the start of a new vertical one if (xpos < w) { stbhw_tile *t = stbhw__choose_tile( ts->v_tiles, ts->num_v_tiles, &c_color[j+2][i+5], &c_color[j+3][i+5], &c_color[j+4][i+5], &c_color[j+2][i+6], &c_color[j+3][i+6], &c_color[j+4][i+6], weighting ); if (t == NULL) return 0; stbhw__draw_v_tile(output,stride,w,h, xpos, ypos, t, sidelen); } } ypos += sidelen; } } else { // @TODO edge-color repetition reduction int i,j, ypos; memset(v_color, -1, sizeof(v_color)); memset(h_color, -1, sizeof(h_color)); ypos = -1 * sidelen; for (j = -1; ypos= w) break; // horizontal left-block if (xpos + sidelen*2 >= 0 && ypos >= 0) { stbhw_tile *t = stbhw__choose_tile( ts->h_tiles, ts->num_h_tiles, &h_color[j+2][i+2], &h_color[j+2][i+3], &v_color[j+2][i+2], &v_color[j+2][i+4], &h_color[j+3][i+2], &h_color[j+3][i+3], weighting ); if (t == NULL) return 0; stbhw__draw_h_tile(output,stride,w,h, xpos, ypos, t, sidelen); } xpos += sidelen * 2; // now we're at the end of a previous vertical one xpos += sidelen; // now we're at the start of a new vertical one if (xpos < w) { stbhw_tile *t = stbhw__choose_tile( ts->v_tiles, ts->num_v_tiles, &h_color[j+2][i+5], &v_color[j+2][i+5], &v_color[j+2][i+6], &v_color[j+3][i+5], &v_color[j+3][i+6], &h_color[j+4][i+5], weighting ); if (t == NULL) return 0; stbhw__draw_v_tile(output,stride,w,h, xpos, ypos, t, sidelen); } } ypos += sidelen; } } return 1; } static void stbhw__parse_h_rect(stbhw__process *p, int xpos, int ypos, int a, int b, int c, int d, int e, int f) { int len = p->c->short_side_len; stbhw_tile *h = (stbhw_tile *) malloc(sizeof(*h)-1 + 3 * (len*2) * len); int i,j; ++xpos; ++ypos; h->a = a, h->b = b, h->c = c, h->d = d, h->e = e, h->f = f; for (j=0; j < len; ++j) for (i=0; i < len*2; ++i) memcpy(h->pixels + j*(3*len*2) + i*3, p->data+(ypos+j)*p->stride+(xpos+i)*3, 3); STB_HBWANG_ASSERT(p->ts->num_h_tiles < p->ts->max_h_tiles); p->ts->h_tiles[p->ts->num_h_tiles++] = h; } static void stbhw__parse_v_rect(stbhw__process *p, int xpos, int ypos, int a, int b, int c, int d, int e, int f) { int len = p->c->short_side_len; stbhw_tile *h = (stbhw_tile *) malloc(sizeof(*h)-1 + 3 * (len*2) * len); int i,j; ++xpos; ++ypos; h->a = a, h->b = b, h->c = c, h->d = d, h->e = e, h->f = f; for (j=0; j < len*2; ++j) for (i=0; i < len; ++i) memcpy(h->pixels + j*(3*len) + i*3, p->data+(ypos+j)*p->stride+(xpos+i)*3, 3); STB_HBWANG_ASSERT(p->ts->num_v_tiles < p->ts->max_v_tiles); p->ts->v_tiles[p->ts->num_v_tiles++] = h; } STBHW_EXTERN int stbhw_build_tileset_from_image(stbhw_tileset *ts, unsigned char *data, int stride, int w, int h) { int i, h_count, v_count; unsigned char header[9]; stbhw_config c = { 0 }; stbhw__process p = { 0 }; // extract binary header // remove encoding that makes it more visually obvious it encodes actual data for (i=0; i < 9; ++i) header[i] = data[w*3 - 1 - i] ^ (i*55); // extract header info if (header[7] == 0xc0) { // corner-type c.is_corner = 1; for (i=0; i < 4; ++i) c.num_color[i] = header[i]; c.num_vary_x = header[4]; c.num_vary_y = header[5]; c.short_side_len = header[6]; } else { c.is_corner = 0; // edge-type for (i=0; i < 6; ++i) c.num_color[i] = header[i]; c.num_vary_x = header[6]; c.num_vary_y = header[7]; c.short_side_len = header[8]; } if (c.num_vary_x < 0 || c.num_vary_x > 64 || c.num_vary_y < 0 || c.num_vary_y > 64) return 0; if (c.short_side_len == 0) return 0; if (c.num_color[0] > 32 || c.num_color[1] > 32 || c.num_color[2] > 32 || c.num_color[3] > 32) return 0; stbhw__get_template_info(&c, NULL, NULL, &h_count, &v_count); ts->is_corner = c.is_corner; ts->short_side_len = c.short_side_len; memcpy(ts->num_color, c.num_color, sizeof(ts->num_color)); ts->max_h_tiles = h_count; ts->max_v_tiles = v_count; ts->num_h_tiles = ts->num_v_tiles = 0; ts->h_tiles = (stbhw_tile **) malloc(sizeof(*ts->h_tiles) * h_count); ts->v_tiles = (stbhw_tile **) malloc(sizeof(*ts->v_tiles) * v_count); p.ts = ts; p.data = data; p.stride = stride; p.process_h_rect = stbhw__parse_h_rect; p.process_v_rect = stbhw__parse_v_rect; p.w = w; p.h = h; p.c = &c; // load all the tiles out of the image return stbhw__process_template(&p); } STBHW_EXTERN void stbhw_free_tileset(stbhw_tileset *ts) { int i; for (i=0; i < ts->num_h_tiles; ++i) free(ts->h_tiles[i]); for (i=0; i < ts->num_v_tiles; ++i) free(ts->v_tiles[i]); free(ts->h_tiles); free(ts->v_tiles); ts->h_tiles = NULL; ts->v_tiles = NULL; ts->num_h_tiles = ts->max_h_tiles = 0; ts->num_v_tiles = ts->max_v_tiles = 0; } ////////////////////////////////////////////////////////////////////////////// // // GENERATOR // // // shared code static void stbhw__set_pixel(unsigned char *data, int stride, int xpos, int ypos, unsigned char color[3]) { memcpy(data + ypos*stride + xpos*3, color, 3); } static void stbhw__stbhw__set_pixel_whiten(unsigned char *data, int stride, int xpos, int ypos, unsigned char color[3]) { unsigned char c2[3]; int i; for (i=0; i < 3; ++i) c2[i] = (color[i]*2 + 255)/3; memcpy(data + ypos*stride + xpos*3, c2, 3); } static unsigned char stbhw__black[3] = { 0,0,0 }; // each edge set gets its own unique color variants // used http://phrogz.net/css/distinct-colors.html to generate this set, // but it's not very good and needs to be revised static unsigned char stbhw__color[7][8][3] = { { {255,51,51} , {143,143,29}, {0,199,199}, {159,119,199}, {0,149,199} , {143, 0,143}, {255,128,0}, {64,255,0}, }, { {235,255,30 }, {255,0,255}, {199,139,119}, {29,143, 57}, {143,0,71} , { 0,143,143}, {0,99,199}, {143,71,0}, }, { {0,149,199} , {143, 0,143}, {255,128,0}, {64,255,0}, {255,191,0} , {51,255,153}, {0,0,143}, {199,119,159},}, { {143,0,71} , { 0,143,143}, {0,99,199}, {143,71,0}, {255,190,153}, { 0,255,255}, {128,0,255}, {255,51,102},}, { {255,191,0} , {51,255,153}, {0,0,143}, {199,119,159}, {255,51,51} , {143,143,29}, {0,199,199}, {159,119,199},}, { {255,190,153}, { 0,255,255}, {128,0,255}, {255,51,102}, {235,255,30 }, {255,0,255}, {199,139,119}, {29,143, 57}, }, { {40,40,40 }, { 90,90,90 }, { 150,150,150 }, { 200,200,200 }, { 255,90,90 }, { 160,160,80}, { 50,150,150 }, { 200,50,200 } }, }; static void stbhw__draw_hline(unsigned char *data, int stride, int xpos, int ypos, int color, int len, int slot) { int i; int j = len * 6 / 16; int k = len * 10 / 16; for (i=0; i < len; ++i) stbhw__set_pixel(data, stride, xpos+i, ypos, stbhw__black); if (k-j < 2) { j = len/2 - 1; k = j+2; if (len & 1) ++k; } for (i=j; i < k; ++i) stbhw__stbhw__set_pixel_whiten(data, stride, xpos+i, ypos, stbhw__color[slot][color]); } static void stbhw__draw_vline(unsigned char *data, int stride, int xpos, int ypos, int color, int len, int slot) { int i; int j = len * 6 / 16; int k = len * 10 / 16; for (i=0; i < len; ++i) stbhw__set_pixel(data, stride, xpos, ypos+i, stbhw__black); if (k-j < 2) { j = len/2 - 1; k = j+2; if (len & 1) ++k; } for (i=j; i < k; ++i) stbhw__stbhw__set_pixel_whiten(data, stride, xpos, ypos+i, stbhw__color[slot][color]); } // 0--*--1--*--2--*--3 // | | | // * * * // | | | // 1--*--2--*--3 0--*--1--*--2 // | | | // * * * // | | | // 0--*--1--*--2--*--3 // // variables while enumerating (no correspondence between corners // of the types is implied by these variables) // // a-----b-----c a-----d // | | | | // | | | | // | | | | // d-----e-----f b e // | | // | | // | | // c-----f // unsigned char stbhw__corner_colors[4][4][3] = { { { 255,0,0 }, { 200,200,200 }, { 100,100,200 }, { 255,200,150 }, }, { { 0,0,255 }, { 255,255,0 }, { 100,200,100 }, { 150,255,200 }, }, { { 255,0,255 }, { 80,80,80 }, { 200,100,100 }, { 200,150,255 }, }, { { 0,255,255 }, { 0,255,0 }, { 200,120,200 }, { 255,200,200 }, }, }; int stbhw__corner_colors_to_edge_color[4][4] = { // 0 1 2 3 { 0, 1, 4, 9, }, // 0 { 2, 3, 5, 10, }, // 1 { 6, 7, 8, 11, }, // 2 { 12, 13, 14, 15, }, // 3 }; #define stbhw__c2e stbhw__corner_colors_to_edge_color static void stbhw__draw_clipped_corner(unsigned char *data, int stride, int xpos, int ypos, int w, int h, int x, int y) { static unsigned char template_color[3] = { 167,204,204 }; int i,j; for (j = -2; j <= 1; ++j) { for (i = -2; i <= 1; ++i) { if ((i == -2 || i == 1) && (j == -2 || j == 1)) continue; else { if (x+i < 1 || x+i > w) continue; if (y+j < 1 || y+j > h) continue; stbhw__set_pixel(data, stride, xpos+x+i, ypos+y+j, template_color); } } } } static void stbhw__edge_process_h_rect(stbhw__process *p, int xpos, int ypos, int a, int b, int c, int d, int e, int f) { int len = p->c->short_side_len; stbhw__draw_hline(p->data, p->stride, xpos+1 , ypos , a, len, 2); stbhw__draw_hline(p->data, p->stride, xpos+ len+1 , ypos , b, len, 3); stbhw__draw_vline(p->data, p->stride, xpos , ypos+1 , c, len, 1); stbhw__draw_vline(p->data, p->stride, xpos+2*len+1 , ypos+1 , d, len, 4); stbhw__draw_hline(p->data, p->stride, xpos+1 , ypos + len+1, e, len, 0); stbhw__draw_hline(p->data, p->stride, xpos + len+1 , ypos + len+1, f, len, 2); } static void stbhw__edge_process_v_rect(stbhw__process *p, int xpos, int ypos, int a, int b, int c, int d, int e, int f) { int len = p->c->short_side_len; stbhw__draw_hline(p->data, p->stride, xpos+1 , ypos , a, len, 0); stbhw__draw_vline(p->data, p->stride, xpos , ypos+1 , b, len, 5); stbhw__draw_vline(p->data, p->stride, xpos + len+1, ypos+1 , c, len, 1); stbhw__draw_vline(p->data, p->stride, xpos , ypos + len+1, d, len, 4); stbhw__draw_vline(p->data, p->stride, xpos + len+1, ypos + len+1, e, len, 5); stbhw__draw_hline(p->data, p->stride, xpos+1 , ypos + 2*len+1, f, len, 3); } static void stbhw__corner_process_h_rect(stbhw__process *p, int xpos, int ypos, int a, int b, int c, int d, int e, int f) { int len = p->c->short_side_len; stbhw__draw_hline(p->data, p->stride, xpos+1 , ypos , stbhw__c2e[a][b], len, 2); stbhw__draw_hline(p->data, p->stride, xpos+ len+1 , ypos , stbhw__c2e[b][c], len, 3); stbhw__draw_vline(p->data, p->stride, xpos , ypos+1 , stbhw__c2e[a][d], len, 1); stbhw__draw_vline(p->data, p->stride, xpos+2*len+1 , ypos+1 , stbhw__c2e[c][f], len, 4); stbhw__draw_hline(p->data, p->stride, xpos+1 , ypos + len+1, stbhw__c2e[d][e], len, 0); stbhw__draw_hline(p->data, p->stride, xpos + len+1 , ypos + len+1, stbhw__c2e[e][f], len, 2); if (p->c->corner_type_color_template[1][a]) stbhw__draw_clipped_corner(p->data,p->stride, xpos,ypos, len*2,len, 1,1); if (p->c->corner_type_color_template[2][b]) stbhw__draw_clipped_corner(p->data,p->stride, xpos,ypos, len*2,len, len+1,1); if (p->c->corner_type_color_template[3][c]) stbhw__draw_clipped_corner(p->data,p->stride, xpos,ypos, len*2,len, len*2+1,1); if (p->c->corner_type_color_template[0][d]) stbhw__draw_clipped_corner(p->data,p->stride, xpos,ypos, len*2,len, 1,len+1); if (p->c->corner_type_color_template[1][e]) stbhw__draw_clipped_corner(p->data,p->stride, xpos,ypos, len*2,len, len+1,len+1); if (p->c->corner_type_color_template[2][f]) stbhw__draw_clipped_corner(p->data,p->stride, xpos,ypos, len*2,len, len*2+1,len+1); stbhw__set_pixel(p->data, p->stride, xpos , ypos, stbhw__corner_colors[1][a]); stbhw__set_pixel(p->data, p->stride, xpos+len , ypos, stbhw__corner_colors[2][b]); stbhw__set_pixel(p->data, p->stride, xpos+2*len+1, ypos, stbhw__corner_colors[3][c]); stbhw__set_pixel(p->data, p->stride, xpos , ypos+len+1, stbhw__corner_colors[0][d]); stbhw__set_pixel(p->data, p->stride, xpos+len , ypos+len+1, stbhw__corner_colors[1][e]); stbhw__set_pixel(p->data, p->stride, xpos+2*len+1, ypos+len+1, stbhw__corner_colors[2][f]); } static void stbhw__corner_process_v_rect(stbhw__process *p, int xpos, int ypos, int a, int b, int c, int d, int e, int f) { int len = p->c->short_side_len; stbhw__draw_hline(p->data, p->stride, xpos+1 , ypos , stbhw__c2e[a][d], len, 0); stbhw__draw_vline(p->data, p->stride, xpos , ypos+1 , stbhw__c2e[a][b], len, 5); stbhw__draw_vline(p->data, p->stride, xpos + len+1, ypos+1 , stbhw__c2e[d][e], len, 1); stbhw__draw_vline(p->data, p->stride, xpos , ypos + len+1, stbhw__c2e[b][c], len, 4); stbhw__draw_vline(p->data, p->stride, xpos + len+1, ypos + len+1, stbhw__c2e[e][f], len, 5); stbhw__draw_hline(p->data, p->stride, xpos+1 , ypos + 2*len+1, stbhw__c2e[c][f], len, 3); if (p->c->corner_type_color_template[0][a]) stbhw__draw_clipped_corner(p->data,p->stride, xpos,ypos, len,len*2, 1,1); if (p->c->corner_type_color_template[3][b]) stbhw__draw_clipped_corner(p->data,p->stride, xpos,ypos, len,len*2, 1,len+1); if (p->c->corner_type_color_template[2][c]) stbhw__draw_clipped_corner(p->data,p->stride, xpos,ypos, len,len*2, 1,len*2+1); if (p->c->corner_type_color_template[1][d]) stbhw__draw_clipped_corner(p->data,p->stride, xpos,ypos, len,len*2, len+1,1); if (p->c->corner_type_color_template[0][e]) stbhw__draw_clipped_corner(p->data,p->stride, xpos,ypos, len,len*2, len+1,len+1); if (p->c->corner_type_color_template[3][f]) stbhw__draw_clipped_corner(p->data,p->stride, xpos,ypos, len,len*2, len+1,len*2+1); stbhw__set_pixel(p->data, p->stride, xpos , ypos , stbhw__corner_colors[0][a]); stbhw__set_pixel(p->data, p->stride, xpos , ypos+len , stbhw__corner_colors[3][b]); stbhw__set_pixel(p->data, p->stride, xpos , ypos+2*len+1, stbhw__corner_colors[2][c]); stbhw__set_pixel(p->data, p->stride, xpos+len+1, ypos , stbhw__corner_colors[1][d]); stbhw__set_pixel(p->data, p->stride, xpos+len+1, ypos+len , stbhw__corner_colors[0][e]); stbhw__set_pixel(p->data, p->stride, xpos+len+1, ypos+2*len+1, stbhw__corner_colors[3][f]); } // generates a template image, assuming data is 3*w*h bytes long, RGB format STBHW_EXTERN int stbhw_make_template(stbhw_config *c, unsigned char *data, int w, int h, int stride_in_bytes) { stbhw__process p; int i; p.data = data; p.w = w; p.h = h; p.stride = stride_in_bytes; p.ts = 0; p.c = c; if (c->is_corner) { p.process_h_rect = stbhw__corner_process_h_rect; p.process_v_rect = stbhw__corner_process_v_rect; } else { p.process_h_rect = stbhw__edge_process_h_rect; p.process_v_rect = stbhw__edge_process_v_rect; } for (i=0; i < p.h; ++i) memset(p.data + i*p.stride, 255, 3*p.w); if (!stbhw__process_template(&p)) return 0; if (c->is_corner) { // write out binary information in first line of image for (i=0; i < 4; ++i) data[w*3-1-i] = c->num_color[i]; data[w*3-1-i] = c->num_vary_x; data[w*3-2-i] = c->num_vary_y; data[w*3-3-i] = c->short_side_len; data[w*3-4-i] = 0xc0; } else { for (i=0; i < 6; ++i) data[w*3-1-i] = c->num_color[i]; data[w*3-1-i] = c->num_vary_x; data[w*3-2-i] = c->num_vary_y; data[w*3-3-i] = c->short_side_len; } // make it more obvious it encodes actual data for (i=0; i < 9; ++i) p.data[p.w*3 - 1 - i] ^= i*55; return 1; } #endif // STB_HBWANG_IMPLEMENTATION uTox/third_party/stb/stb/stb_easy_font.h0000600000175000001440000003056214003056224017424 0ustar rakusers// stb_easy_font.h - v1.0 - bitmap font for 3D rendering - public domain // Sean Barrett, Feb 2015 // // Easy-to-deploy, // reasonably compact, // extremely inefficient performance-wise, // crappy-looking, // ASCII-only, // bitmap font for use in 3D APIs. // // Intended for when you just want to get some text displaying // in a 3D app as quickly as possible. // // Doesn't use any textures, instead builds characters out of quads. // // DOCUMENTATION: // // int stb_easy_font_width(char *text) // int stb_easy_font_height(char *text) // // Takes a string and returns the horizontal size and the // vertical size (which can vary if 'text' has newlines). // // int stb_easy_font_print(float x, float y, // char *text, unsigned char color[4], // void *vertex_buffer, int vbuf_size) // // Takes a string (which can contain '\n') and fills out a // vertex buffer with renderable data to draw the string. // Output data assumes increasing x is rightwards, increasing y // is downwards. // // The vertex data is divided into quads, i.e. there are four // vertices in the vertex buffer for each quad. // // The vertices are stored in an interleaved format: // // x:float // y:float // z:float // color:uint8[4] // // You can ignore z and color if you get them from elsewhere // This format was chosen in the hopes it would make it // easier for you to reuse existing vertex-buffer-drawing code. // // If you pass in NULL for color, it becomes 255,255,255,255. // // Returns the number of quads. // // If the buffer isn't large enough, it will truncate. // Expect it to use an average of ~270 bytes per character. // // If your API doesn't draw quads, build a reusable index // list that allows you to render quads as indexed triangles. // // void stb_easy_font_spacing(float spacing) // // Use positive values to expand the space between characters, // and small negative values (no smaller than -1.5) to contract // the space between characters. // // E.g. spacing = 1 adds one "pixel" of spacing between the // characters. spacing = -1 is reasonable but feels a bit too // compact to me; -0.5 is a reasonable compromise as long as // you're scaling the font up. // // LICENSE // // See end of file for license information. // // VERSION HISTORY // // (2017-01-15) 1.0 space character takes same space as numbers; fix bad spacing of 'f' // (2016-01-22) 0.7 width() supports multiline text; add height() // (2015-09-13) 0.6 #include ; updated license // (2015-02-01) 0.5 First release // // CONTRIBUTORS // // github:vassvik -- bug report #if 0 // SAMPLE CODE: // // Here's sample code for old OpenGL; it's a lot more complicated // to make work on modern APIs, and that's your problem. // void print_string(float x, float y, char *text, float r, float g, float b) { static char buffer[99999]; // ~500 chars int num_quads; num_quads = stb_easy_font_print(x, y, text, NULL, buffer, sizeof(buffer)); glColor3f(r,g,b); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 16, buffer); glDrawArrays(GL_QUADS, 0, num_quads*4); glDisableClientState(GL_VERTEX_ARRAY); } #endif #ifndef INCLUDE_STB_EASY_FONT_H #define INCLUDE_STB_EASY_FONT_H #include #include struct stb_easy_font_info_struct { unsigned char advance; unsigned char h_seg; unsigned char v_seg; } stb_easy_font_charinfo[96] = { { 6, 0, 0 }, { 3, 0, 0 }, { 5, 1, 1 }, { 7, 1, 4 }, { 7, 3, 7 }, { 7, 6, 12 }, { 7, 8, 19 }, { 4, 16, 21 }, { 4, 17, 22 }, { 4, 19, 23 }, { 23, 21, 24 }, { 23, 22, 31 }, { 20, 23, 34 }, { 22, 23, 36 }, { 19, 24, 36 }, { 21, 25, 36 }, { 6, 25, 39 }, { 6, 27, 43 }, { 6, 28, 45 }, { 6, 30, 49 }, { 6, 33, 53 }, { 6, 34, 57 }, { 6, 40, 58 }, { 6, 46, 59 }, { 6, 47, 62 }, { 6, 55, 64 }, { 19, 57, 68 }, { 20, 59, 68 }, { 21, 61, 69 }, { 22, 66, 69 }, { 21, 68, 69 }, { 7, 73, 69 }, { 9, 75, 74 }, { 6, 78, 81 }, { 6, 80, 85 }, { 6, 83, 90 }, { 6, 85, 91 }, { 6, 87, 95 }, { 6, 90, 96 }, { 7, 92, 97 }, { 6, 96,102 }, { 5, 97,106 }, { 6, 99,107 }, { 6,100,110 }, { 6,100,115 }, { 7,101,116 }, { 6,101,121 }, { 6,101,125 }, { 6,102,129 }, { 7,103,133 }, { 6,104,140 }, { 6,105,145 }, { 7,107,149 }, { 6,108,151 }, { 7,109,155 }, { 7,109,160 }, { 7,109,165 }, { 7,118,167 }, { 6,118,172 }, { 4,120,176 }, { 6,122,177 }, { 4,122,181 }, { 23,124,182 }, { 22,129,182 }, { 4,130,182 }, { 22,131,183 }, { 6,133,187 }, { 22,135,191 }, { 6,137,192 }, { 22,139,196 }, { 6,144,197 }, { 22,147,198 }, { 6,150,202 }, { 19,151,206 }, { 21,152,207 }, { 6,155,209 }, { 3,160,210 }, { 23,160,211 }, { 22,164,216 }, { 22,165,220 }, { 22,167,224 }, { 22,169,228 }, { 21,171,232 }, { 21,173,233 }, { 5,178,233 }, { 22,179,234 }, { 23,180,238 }, { 23,180,243 }, { 23,180,248 }, { 22,189,248 }, { 22,191,252 }, { 5,196,252 }, { 3,203,252 }, { 5,203,253 }, { 22,210,253 }, { 0,214,253 }, }; unsigned char stb_easy_font_hseg[214] = { 97,37,69,84,28,51,2,18,10,49,98,41,65,25,81,105,33,9,97,1,97,37,37,36, 81,10,98,107,3,100,3,99,58,51,4,99,58,8,73,81,10,50,98,8,73,81,4,10,50, 98,8,25,33,65,81,10,50,17,65,97,25,33,25,49,9,65,20,68,1,65,25,49,41, 11,105,13,101,76,10,50,10,50,98,11,99,10,98,11,50,99,11,50,11,99,8,57, 58,3,99,99,107,10,10,11,10,99,11,5,100,41,65,57,41,65,9,17,81,97,3,107, 9,97,1,97,33,25,9,25,41,100,41,26,82,42,98,27,83,42,98,26,51,82,8,41, 35,8,10,26,82,114,42,1,114,8,9,73,57,81,41,97,18,8,8,25,26,26,82,26,82, 26,82,41,25,33,82,26,49,73,35,90,17,81,41,65,57,41,65,25,81,90,114,20, 84,73,57,41,49,25,33,65,81,9,97,1,97,25,33,65,81,57,33,25,41,25, }; unsigned char stb_easy_font_vseg[253] = { 4,2,8,10,15,8,15,33,8,15,8,73,82,73,57,41,82,10,82,18,66,10,21,29,1,65, 27,8,27,9,65,8,10,50,97,74,66,42,10,21,57,41,29,25,14,81,73,57,26,8,8, 26,66,3,8,8,15,19,21,90,58,26,18,66,18,105,89,28,74,17,8,73,57,26,21, 8,42,41,42,8,28,22,8,8,30,7,8,8,26,66,21,7,8,8,29,7,7,21,8,8,8,59,7,8, 8,15,29,8,8,14,7,57,43,10,82,7,7,25,42,25,15,7,25,41,15,21,105,105,29, 7,57,57,26,21,105,73,97,89,28,97,7,57,58,26,82,18,57,57,74,8,30,6,8,8, 14,3,58,90,58,11,7,74,43,74,15,2,82,2,42,75,42,10,67,57,41,10,7,2,42, 74,106,15,2,35,8,8,29,7,8,8,59,35,51,8,8,15,35,30,35,8,8,30,7,8,8,60, 36,8,45,7,7,36,8,43,8,44,21,8,8,44,35,8,8,43,23,8,8,43,35,8,8,31,21,15, 20,8,8,28,18,58,89,58,26,21,89,73,89,29,20,8,8,30,7, }; typedef struct { unsigned char c[4]; } stb_easy_font_color; static int stb_easy_font_draw_segs(float x, float y, unsigned char *segs, int num_segs, int vertical, stb_easy_font_color c, char *vbuf, int vbuf_size, int offset) { int i,j; for (i=0; i < num_segs; ++i) { int len = segs[i] & 7; x += (float) ((segs[i] >> 3) & 1); if (len && offset+64 <= vbuf_size) { float y0 = y + (float) (segs[i]>>4); for (j=0; j < 4; ++j) { * (float *) (vbuf+offset+0) = x + (j==1 || j==2 ? (vertical ? 1 : len) : 0); * (float *) (vbuf+offset+4) = y0 + ( j >= 2 ? (vertical ? len : 1) : 0); * (float *) (vbuf+offset+8) = 0.f; * (stb_easy_font_color *) (vbuf+offset+12) = c; offset += 16; } } } return offset; } float stb_easy_font_spacing_val = 0; static void stb_easy_font_spacing(float spacing) { stb_easy_font_spacing_val = spacing; } static int stb_easy_font_print(float x, float y, char *text, unsigned char color[4], void *vertex_buffer, int vbuf_size) { char *vbuf = (char *) vertex_buffer; float start_x = x; int offset = 0; stb_easy_font_color c = { 255,255,255,255 }; // use structure copying to avoid needing depending on memcpy() if (color) { c.c[0] = color[0]; c.c[1] = color[1]; c.c[2] = color[2]; c.c[3] = color[3]; } while (*text && offset < vbuf_size) { if (*text == '\n') { y += 12; x = start_x; } else { unsigned char advance = stb_easy_font_charinfo[*text-32].advance; float y_ch = advance & 16 ? y+1 : y; int h_seg, v_seg, num_h, num_v; h_seg = stb_easy_font_charinfo[*text-32 ].h_seg; v_seg = stb_easy_font_charinfo[*text-32 ].v_seg; num_h = stb_easy_font_charinfo[*text-32+1].h_seg - h_seg; num_v = stb_easy_font_charinfo[*text-32+1].v_seg - v_seg; offset = stb_easy_font_draw_segs(x, y_ch, &stb_easy_font_hseg[h_seg], num_h, 0, c, vbuf, vbuf_size, offset); offset = stb_easy_font_draw_segs(x, y_ch, &stb_easy_font_vseg[v_seg], num_v, 1, c, vbuf, vbuf_size, offset); x += advance & 15; x += stb_easy_font_spacing_val; } ++text; } return (unsigned) offset/64; } static int stb_easy_font_width(char *text) { float len = 0; float max_len = 0; while (*text) { if (*text == '\n') { if (len > max_len) max_len = len; len = 0; } else { len += stb_easy_font_charinfo[*text-32].advance & 15; len += stb_easy_font_spacing_val; } ++text; } if (len > max_len) max_len = len; return (int) ceil(max_len); } static int stb_easy_font_height(char *text) { float y = 0; int nonempty_line=0; while (*text) { if (*text == '\n') { y += 12; nonempty_line = 0; } else { nonempty_line = 1; } ++text; } return (int) ceil(y + (nonempty_line ? 12 : 0)); } #endif /* ------------------------------------------------------------------------------ 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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_dxt.h0000600000175000001440000005435614003056224016243 0ustar rakusers// stb_dxt.h - v1.07 - DXT1/DXT5 compressor - public domain // original by fabian "ryg" giesen - ported to C by stb // use '#define STB_DXT_IMPLEMENTATION' before including to create the implementation // // USAGE: // call stb_compress_dxt_block() for every block (you must pad) // source should be a 4x4 block of RGBA data in row-major order; // A is ignored if you specify alpha=0; you can turn on dithering // and "high quality" using mode. // // version history: // v1.07 - bc4; allow not using libc; add STB_DXT_STATIC // v1.06 - (stb) fix to known-broken 1.05 // v1.05 - (stb) support bc5/3dc (Arvids Kokins), use extern "C" in C++ (Pavel Krajcevski) // v1.04 - (ryg) default to no rounding bias for lerped colors (as per S3TC/DX10 spec); // single color match fix (allow for inexact color interpolation); // optimal DXT5 index finder; "high quality" mode that runs multiple refinement steps. // v1.03 - (stb) endianness support // v1.02 - (stb) fix alpha encoding bug // v1.01 - (stb) fix bug converting to RGB that messed up quality, thanks ryg & cbloom // v1.00 - (stb) first release // // contributors: // Kevin Schmidt (#defines for "freestanding" compilation) // github:ppiastucki (BC4 support) // // LICENSE // // See end of file for license information. #ifndef STB_INCLUDE_STB_DXT_H #define STB_INCLUDE_STB_DXT_H // compression mode (bitflags) #define STB_DXT_NORMAL 0 #define STB_DXT_DITHER 1 // use dithering. dubious win. never use for normal maps and the like! #define STB_DXT_HIGHQUAL 2 // high quality mode, does two refinement steps instead of 1. ~30-40% slower. #ifdef __cplusplus extern "C" { #endif #ifdef STB_DXT_STATIC #define STBDDEF static #else #define STBDDEF extern #endif STBDDEF void stb_compress_dxt_block(unsigned char *dest, const unsigned char *src_rgba_four_bytes_per_pixel, int alpha, int mode); STBDDEF void stb_compress_bc4_block(unsigned char *dest, const unsigned char *src_r_one_byte_per_pixel); STBDDEF void stb_compress_bc5_block(unsigned char *dest, const unsigned char *src_rg_two_byte_per_pixel); #ifdef __cplusplus } #endif #define STB_COMPRESS_DXT_BLOCK #ifdef STB_DXT_IMPLEMENTATION // configuration options for DXT encoder. set them in the project/makefile or just define // them at the top. // STB_DXT_USE_ROUNDING_BIAS // use a rounding bias during color interpolation. this is closer to what "ideal" // interpolation would do but doesn't match the S3TC/DX10 spec. old versions (pre-1.03) // implicitly had this turned on. // // in case you're targeting a specific type of hardware (e.g. console programmers): // NVidia and Intel GPUs (as of 2010) as well as DX9 ref use DXT decoders that are closer // to STB_DXT_USE_ROUNDING_BIAS. AMD/ATI, S3 and DX10 ref are closer to rounding with no bias. // you also see "(a*5 + b*3) / 8" on some old GPU designs. // #define STB_DXT_USE_ROUNDING_BIAS #include #if !defined(STBD_ABS) || !defined(STBI_FABS) #include #endif #ifndef STBD_ABS #define STBD_ABS(i) abs(i) #endif #ifndef STBD_FABS #define STBD_FABS(x) fabs(x) #endif #ifndef STBD_MEMSET #include #define STBD_MEMSET(x) memset(x) #endif static unsigned char stb__Expand5[32]; static unsigned char stb__Expand6[64]; static unsigned char stb__OMatch5[256][2]; static unsigned char stb__OMatch6[256][2]; static unsigned char stb__QuantRBTab[256+16]; static unsigned char stb__QuantGTab[256+16]; static int stb__Mul8Bit(int a, int b) { int t = a*b + 128; return (t + (t >> 8)) >> 8; } static void stb__From16Bit(unsigned char *out, unsigned short v) { int rv = (v & 0xf800) >> 11; int gv = (v & 0x07e0) >> 5; int bv = (v & 0x001f) >> 0; out[0] = stb__Expand5[rv]; out[1] = stb__Expand6[gv]; out[2] = stb__Expand5[bv]; out[3] = 0; } static unsigned short stb__As16Bit(int r, int g, int b) { return (stb__Mul8Bit(r,31) << 11) + (stb__Mul8Bit(g,63) << 5) + stb__Mul8Bit(b,31); } // linear interpolation at 1/3 point between a and b, using desired rounding type static int stb__Lerp13(int a, int b) { #ifdef STB_DXT_USE_ROUNDING_BIAS // with rounding bias return a + stb__Mul8Bit(b-a, 0x55); #else // without rounding bias // replace "/ 3" by "* 0xaaab) >> 17" if your compiler sucks or you really need every ounce of speed. return (2*a + b) / 3; #endif } // lerp RGB color static void stb__Lerp13RGB(unsigned char *out, unsigned char *p1, unsigned char *p2) { out[0] = stb__Lerp13(p1[0], p2[0]); out[1] = stb__Lerp13(p1[1], p2[1]); out[2] = stb__Lerp13(p1[2], p2[2]); } /****************************************************************************/ // compute table to reproduce constant colors as accurately as possible static void stb__PrepareOptTable(unsigned char *Table,const unsigned char *expand,int size) { int i,mn,mx; for (i=0;i<256;i++) { int bestErr = 256; for (mn=0;mn> 4)]; ep1[0] = bp[ 0] - dp[ 0]; dp[ 4] = quant[bp[ 4] + ((7*ep1[0] + 3*ep2[2] + 5*ep2[1] + ep2[0]) >> 4)]; ep1[1] = bp[ 4] - dp[ 4]; dp[ 8] = quant[bp[ 8] + ((7*ep1[1] + 3*ep2[3] + 5*ep2[2] + ep2[1]) >> 4)]; ep1[2] = bp[ 8] - dp[ 8]; dp[12] = quant[bp[12] + ((7*ep1[2] + 5*ep2[3] + ep2[2]) >> 4)]; ep1[3] = bp[12] - dp[12]; bp += 16; dp += 16; et = ep1, ep1 = ep2, ep2 = et; // swap } } } // The color matching function static unsigned int stb__MatchColorsBlock(unsigned char *block, unsigned char *color,int dither) { unsigned int mask = 0; int dirr = color[0*4+0] - color[1*4+0]; int dirg = color[0*4+1] - color[1*4+1]; int dirb = color[0*4+2] - color[1*4+2]; int dots[16]; int stops[4]; int i; int c0Point, halfPoint, c3Point; for(i=0;i<16;i++) dots[i] = block[i*4+0]*dirr + block[i*4+1]*dirg + block[i*4+2]*dirb; for(i=0;i<4;i++) stops[i] = color[i*4+0]*dirr + color[i*4+1]*dirg + color[i*4+2]*dirb; // think of the colors as arranged on a line; project point onto that line, then choose // next color out of available ones. we compute the crossover points for "best color in top // half"/"best in bottom half" and then the same inside that subinterval. // // relying on this 1d approximation isn't always optimal in terms of euclidean distance, // but it's very close and a lot faster. // http://cbloomrants.blogspot.com/2008/12/12-08-08-dxtc-summary.html c0Point = (stops[1] + stops[3]) >> 1; halfPoint = (stops[3] + stops[2]) >> 1; c3Point = (stops[2] + stops[0]) >> 1; if(!dither) { // the version without dithering is straightforward for (i=15;i>=0;i--) { int dot = dots[i]; mask <<= 2; if(dot < halfPoint) mask |= (dot < c0Point) ? 1 : 3; else mask |= (dot < c3Point) ? 2 : 0; } } else { // with floyd-steinberg dithering int err[8],*ep1 = err,*ep2 = err+4; int *dp = dots, y; c0Point <<= 4; halfPoint <<= 4; c3Point <<= 4; for(i=0;i<8;i++) err[i] = 0; for(y=0;y<4;y++) { int dot,lmask,step; dot = (dp[0] << 4) + (3*ep2[1] + 5*ep2[0]); if(dot < halfPoint) step = (dot < c0Point) ? 1 : 3; else step = (dot < c3Point) ? 2 : 0; ep1[0] = dp[0] - stops[step]; lmask = step; dot = (dp[1] << 4) + (7*ep1[0] + 3*ep2[2] + 5*ep2[1] + ep2[0]); if(dot < halfPoint) step = (dot < c0Point) ? 1 : 3; else step = (dot < c3Point) ? 2 : 0; ep1[1] = dp[1] - stops[step]; lmask |= step<<2; dot = (dp[2] << 4) + (7*ep1[1] + 3*ep2[3] + 5*ep2[2] + ep2[1]); if(dot < halfPoint) step = (dot < c0Point) ? 1 : 3; else step = (dot < c3Point) ? 2 : 0; ep1[2] = dp[2] - stops[step]; lmask |= step<<4; dot = (dp[3] << 4) + (7*ep1[2] + 5*ep2[3] + ep2[2]); if(dot < halfPoint) step = (dot < c0Point) ? 1 : 3; else step = (dot < c3Point) ? 2 : 0; ep1[3] = dp[3] - stops[step]; lmask |= step<<6; dp += 4; mask |= lmask << (y*8); { int *et = ep1; ep1 = ep2; ep2 = et; } // swap } } return mask; } // The color optimization function. (Clever code, part 1) static void stb__OptimizeColorsBlock(unsigned char *block, unsigned short *pmax16, unsigned short *pmin16) { int mind = 0x7fffffff,maxd = -0x7fffffff; unsigned char *minp, *maxp; double magn; int v_r,v_g,v_b; static const int nIterPower = 4; float covf[6],vfr,vfg,vfb; // determine color distribution int cov[6]; int mu[3],min[3],max[3]; int ch,i,iter; for(ch=0;ch<3;ch++) { const unsigned char *bp = ((const unsigned char *) block) + ch; int muv,minv,maxv; muv = minv = maxv = bp[0]; for(i=4;i<64;i+=4) { muv += bp[i]; if (bp[i] < minv) minv = bp[i]; else if (bp[i] > maxv) maxv = bp[i]; } mu[ch] = (muv + 8) >> 4; min[ch] = minv; max[ch] = maxv; } // determine covariance matrix for (i=0;i<6;i++) cov[i] = 0; for (i=0;i<16;i++) { int r = block[i*4+0] - mu[0]; int g = block[i*4+1] - mu[1]; int b = block[i*4+2] - mu[2]; cov[0] += r*r; cov[1] += r*g; cov[2] += r*b; cov[3] += g*g; cov[4] += g*b; cov[5] += b*b; } // convert covariance matrix to float, find principal axis via power iter for(i=0;i<6;i++) covf[i] = cov[i] / 255.0f; vfr = (float) (max[0] - min[0]); vfg = (float) (max[1] - min[1]); vfb = (float) (max[2] - min[2]); for(iter=0;iter magn) magn = STBD_FABS(vfg); if (STBD_FABS(vfb) > magn) magn = STBD_FABS(vfb); if(magn < 4.0f) { // too small, default to luminance v_r = 299; // JPEG YCbCr luma coefs, scaled by 1000. v_g = 587; v_b = 114; } else { magn = 512.0 / magn; v_r = (int) (vfr * magn); v_g = (int) (vfg * magn); v_b = (int) (vfb * magn); } // Pick colors at extreme points for(i=0;i<16;i++) { int dot = block[i*4+0]*v_r + block[i*4+1]*v_g + block[i*4+2]*v_b; if (dot < mind) { mind = dot; minp = block+i*4; } if (dot > maxd) { maxd = dot; maxp = block+i*4; } } *pmax16 = stb__As16Bit(maxp[0],maxp[1],maxp[2]); *pmin16 = stb__As16Bit(minp[0],minp[1],minp[2]); } static int stb__sclamp(float y, int p0, int p1) { int x = (int) y; if (x < p0) return p0; if (x > p1) return p1; return x; } // The refinement function. (Clever code, part 2) // Tries to optimize colors to suit block contents better. // (By solving a least squares system via normal equations+Cramer's rule) static int stb__RefineBlock(unsigned char *block, unsigned short *pmax16, unsigned short *pmin16, unsigned int mask) { static const int w1Tab[4] = { 3,0,2,1 }; static const int prods[4] = { 0x090000,0x000900,0x040102,0x010402 }; // ^some magic to save a lot of multiplies in the accumulating loop... // (precomputed products of weights for least squares system, accumulated inside one 32-bit register) float frb,fg; unsigned short oldMin, oldMax, min16, max16; int i, akku = 0, xx,xy,yy; int At1_r,At1_g,At1_b; int At2_r,At2_g,At2_b; unsigned int cm = mask; oldMin = *pmin16; oldMax = *pmax16; if((mask ^ (mask<<2)) < 4) // all pixels have the same index? { // yes, linear system would be singular; solve using optimal // single-color match on average color int r = 8, g = 8, b = 8; for (i=0;i<16;++i) { r += block[i*4+0]; g += block[i*4+1]; b += block[i*4+2]; } r >>= 4; g >>= 4; b >>= 4; max16 = (stb__OMatch5[r][0]<<11) | (stb__OMatch6[g][0]<<5) | stb__OMatch5[b][0]; min16 = (stb__OMatch5[r][1]<<11) | (stb__OMatch6[g][1]<<5) | stb__OMatch5[b][1]; } else { At1_r = At1_g = At1_b = 0; At2_r = At2_g = At2_b = 0; for (i=0;i<16;++i,cm>>=2) { int step = cm&3; int w1 = w1Tab[step]; int r = block[i*4+0]; int g = block[i*4+1]; int b = block[i*4+2]; akku += prods[step]; At1_r += w1*r; At1_g += w1*g; At1_b += w1*b; At2_r += r; At2_g += g; At2_b += b; } At2_r = 3*At2_r - At1_r; At2_g = 3*At2_g - At1_g; At2_b = 3*At2_b - At1_b; // extract solutions and decide solvability xx = akku >> 16; yy = (akku >> 8) & 0xff; xy = (akku >> 0) & 0xff; frb = 3.0f * 31.0f / 255.0f / (xx*yy - xy*xy); fg = frb * 63.0f / 31.0f; // solve. max16 = stb__sclamp((At1_r*yy - At2_r*xy)*frb+0.5f,0,31) << 11; max16 |= stb__sclamp((At1_g*yy - At2_g*xy)*fg +0.5f,0,63) << 5; max16 |= stb__sclamp((At1_b*yy - At2_b*xy)*frb+0.5f,0,31) << 0; min16 = stb__sclamp((At2_r*xx - At1_r*xy)*frb+0.5f,0,31) << 11; min16 |= stb__sclamp((At2_g*xx - At1_g*xy)*fg +0.5f,0,63) << 5; min16 |= stb__sclamp((At2_b*xx - At1_b*xy)*frb+0.5f,0,31) << 0; } *pmin16 = min16; *pmax16 = max16; return oldMin != min16 || oldMax != max16; } // Color block compression static void stb__CompressColorBlock(unsigned char *dest, unsigned char *block, int mode) { unsigned int mask; int i; int dither; int refinecount; unsigned short max16, min16; unsigned char dblock[16*4],color[4*4]; dither = mode & STB_DXT_DITHER; refinecount = (mode & STB_DXT_HIGHQUAL) ? 2 : 1; // check if block is constant for (i=1;i<16;i++) if (((unsigned int *) block)[i] != ((unsigned int *) block)[0]) break; if(i == 16) { // constant color int r = block[0], g = block[1], b = block[2]; mask = 0xaaaaaaaa; max16 = (stb__OMatch5[r][0]<<11) | (stb__OMatch6[g][0]<<5) | stb__OMatch5[b][0]; min16 = (stb__OMatch5[r][1]<<11) | (stb__OMatch6[g][1]<<5) | stb__OMatch5[b][1]; } else { // first step: compute dithered version for PCA if desired if(dither) stb__DitherBlock(dblock,block); // second step: pca+map along principal axis stb__OptimizeColorsBlock(dither ? dblock : block,&max16,&min16); if (max16 != min16) { stb__EvalColors(color,max16,min16); mask = stb__MatchColorsBlock(block,color,dither); } else mask = 0; // third step: refine (multiple times if requested) for (i=0;i> 8); dest[2] = (unsigned char) (min16); dest[3] = (unsigned char) (min16 >> 8); dest[4] = (unsigned char) (mask); dest[5] = (unsigned char) (mask >> 8); dest[6] = (unsigned char) (mask >> 16); dest[7] = (unsigned char) (mask >> 24); } // Alpha block compression (this is easy for a change) static void stb__CompressAlphaBlock(unsigned char *dest,unsigned char *src, int stride) { int i,dist,bias,dist4,dist2,bits,mask; // find min/max color int mn,mx; mn = mx = src[0]; for (i=1;i<16;i++) { if (src[i*stride] < mn) mn = src[i*stride]; else if (src[i*stride] > mx) mx = src[i*stride]; } // encode them ((unsigned char *)dest)[0] = mx; ((unsigned char *)dest)[1] = mn; dest += 2; // determine bias and emit color indices // given the choice of mx/mn, these indices are optimal: // http://fgiesen.wordpress.com/2009/12/15/dxt5-alpha-block-index-determination/ dist = mx-mn; dist4 = dist*4; dist2 = dist*2; bias = (dist < 8) ? (dist - 1) : (dist/2 + 2); bias -= mn * 7; bits = 0,mask=0; for (i=0;i<16;i++) { int a = src[i*stride]*7 + bias; int ind,t; // select index. this is a "linear scale" lerp factor between 0 (val=min) and 7 (val=max). t = (a >= dist4) ? -1 : 0; ind = t & 4; a -= dist4 & t; t = (a >= dist2) ? -1 : 0; ind += t & 2; a -= dist2 & t; ind += (a >= dist); // turn linear scale into DXT index (0/1 are extremal pts) ind = -ind & 7; ind ^= (2 > ind); // write index mask |= ind << bits; if((bits += 3) >= 8) { *dest++ = mask; mask >>= 8; bits -= 8; } } } static void stb__InitDXT() { int i; for(i=0;i<32;i++) stb__Expand5[i] = (i<<3)|(i>>2); for(i=0;i<64;i++) stb__Expand6[i] = (i<<2)|(i>>4); for(i=0;i<256+16;i++) { int v = i-8 < 0 ? 0 : i-8 > 255 ? 255 : i-8; stb__QuantRBTab[i] = stb__Expand5[stb__Mul8Bit(v,31)]; stb__QuantGTab[i] = stb__Expand6[stb__Mul8Bit(v,63)]; } stb__PrepareOptTable(&stb__OMatch5[0][0],stb__Expand5,32); stb__PrepareOptTable(&stb__OMatch6[0][0],stb__Expand6,64); } void stb_compress_dxt_block(unsigned char *dest, const unsigned char *src, int alpha, int mode) { static int init=1; if (init) { stb__InitDXT(); init=0; } if (alpha) { stb__CompressAlphaBlock(dest,(unsigned char*) src+3, 4); dest += 8; } stb__CompressColorBlock(dest,(unsigned char*) src,mode); } void stb_compress_bc4_block(unsigned char *dest, const unsigned char *src) { stb__CompressAlphaBlock(dest,(unsigned char*) src, 1); } void stb_compress_bc5_block(unsigned char *dest, const unsigned char *src) { stb__CompressAlphaBlock(dest,(unsigned char*) src,2); stb__CompressAlphaBlock(dest + 8,(unsigned char*) src+1,2); } #endif // STB_DXT_IMPLEMENTATION #endif // STB_INCLUDE_STB_DXT_H /* ------------------------------------------------------------------------------ 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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_divide.h0000600000175000001440000003336714003056224016707 0ustar rakusers// stb_divide.h - v0.91 - public domain - Sean Barrett, Feb 2010 // Three kinds of divide/modulus of signed integers. // // HISTORY // // v0.91 2010-02-27 Fix euclidean division by INT_MIN for non-truncating C // Check result with 64-bit math to catch such cases // v0.90 2010-02-24 First public release // // USAGE // // In *ONE* source file, put: // // #define STB_DIVIDE_IMPLEMENTATION // // #define C_INTEGER_DIVISION_TRUNCATES // see Note 1 // // #define C_INTEGER_DIVISION_FLOORS // see Note 2 // #include "stb_divide.h" // // Other source files should just include stb_divide.h // // Note 1: On platforms/compilers that you know signed C division // truncates, you can #define C_INTEGER_DIVISION_TRUNCATES. // // Note 2: On platforms/compilers that you know signed C division // floors (rounds to negative infinity), you can #define // C_INTEGER_DIVISION_FLOORS. // // You can #define STB_DIVIDE_TEST in which case the implementation // will generate a main() and compiling the result will create a // program that tests the implementation. Run it with no arguments // and any output indicates an error; run it with any argument and // it will also print the test results. Define STB_DIVIDE_TEST_64 // to a 64-bit integer type to avoid overflows in the result-checking // which give false negatives. // // ABOUT // // This file provides three different consistent divide/mod pairs // implemented on top of arbitrary C/C++ division, including correct // handling of overflow of intermediate calculations: // // trunc: a/b truncates to 0, a%b has same sign as a // floor: a/b truncates to -inf, a%b has same sign as b // eucl: a/b truncates to sign(b)*inf, a%b is non-negative // // Not necessarily optimal; I tried to keep it generally efficient, // but there may be better ways. // // Briefly, for those who are not familiar with the problem, we note // the reason these divides exist and are interesting: // // 'trunc' is easy to implement in hardware (strip the signs, // compute, reapply the signs), thus is commonly defined // by many languages (including C99) // // 'floor' is simple to define and better behaved than trunc; // for example it divides integers into fixed-size buckets // without an extra-wide bucket at 0, and for a fixed // divisor N there are only |N| possible moduli. // // 'eucl' guarantees fixed-sized buckets *and* a non-negative // modulus and defines division to be whatever is needed // to achieve that result. // // See "The Euclidean definition of the functions div and mod" // by Raymond Boute (1992), or "Division and Modulus for Computer // Scientists" by Daan Leijen (2001) // // We assume of the built-in C division: // (a) modulus is the remainder for the corresponding division // (b) a/b truncates if a and b are the same sign // // Property (a) requires (a/b)*b + (a%b)==a, and is required by C. // Property (b) seems to be true of all hardware but is *not* satisfied // by the euclidean division operator we define, so it's possibly not // always true. If any such platform turns up, we can add more cases. // (Possibly only stb_div_trunc currently relies on property (b).) // // LICENSE // // See end of file for license information. #ifndef INCLUDE_STB_DIVIDE_H #define INCLUDE_STB_DIVIDE_H #ifdef __cplusplus extern "C" { #endif extern int stb_div_trunc(int value_to_be_divided, int value_to_divide_by); extern int stb_div_floor(int value_to_be_divided, int value_to_divide_by); extern int stb_div_eucl (int value_to_be_divided, int value_to_divide_by); extern int stb_mod_trunc(int value_to_be_divided, int value_to_divide_by); extern int stb_mod_floor(int value_to_be_divided, int value_to_divide_by); extern int stb_mod_eucl (int value_to_be_divided, int value_to_divide_by); #ifdef __cplusplus } #endif #ifdef STB_DIVIDE_IMPLEMENTATION #if defined(__STDC_VERSION) && __STDC_VERSION__ >= 19901 #ifndef C_INTEGER_DIVISION_TRUNCATES #define C_INTEGER_DIVISION_TRUNCATES #endif #endif #ifndef INT_MIN #include // if you have no limits.h, #define INT_MIN yourself #endif // the following macros are designed to allow testing // other platforms by simulating them #ifndef STB_DIVIDE_TEST_FLOOR #define stb__div(a,b) ((a)/(b)) #define stb__mod(a,b) ((a)%(b)) #else // implement floor-style divide on trunc platform #ifndef C_INTEGER_DIVISION_TRUNCATES #error "floor test requires truncating division" #endif #undef C_INTEGER_DIVISION_TRUNCATES int stb__div(int v1, int v2) { int q = v1/v2, r = v1%v2; if ((r > 0 && v2 < 0) || (r < 0 && v2 > 0)) return q-1; else return q; } int stb__mod(int v1, int v2) { int r = v1%v2; if ((r > 0 && v2 < 0) || (r < 0 && v2 > 0)) return r+v2; else return r; } #endif int stb_div_trunc(int v1, int v2) { #ifdef C_INTEGER_DIVISION_TRUNCATES return v1/v2; #else if (v1 >= 0 && v2 <= 0) return -stb__div(-v1,v2); // both negative to avoid overflow if (v1 <= 0 && v2 >= 0) if (v1 != INT_MIN) return -stb__div(v1,-v2); // both negative to avoid overflow else return -stb__div(v1+v2,-v2)-1; // push v1 away from wrap point else return v1/v2; // same sign, so expect truncation #endif } int stb_div_floor(int v1, int v2) { #ifdef C_INTEGER_DIVISION_FLOORS return v1/v2; #else if (v1 >= 0 && v2 < 0) if ((-v1)+v2+1 < 0) // check if increasing v1's magnitude overflows return -stb__div(-v1+v2+1,v2); // nope, so just compute it else return -stb__div(-v1,v2) + ((-v1)%v2 ? -1 : 0); if (v1 < 0 && v2 >= 0) if (v1 != INT_MIN) if (v1-v2+1 < 0) // check if increasing v1's magnitude overflows return -stb__div(v1-v2+1,-v2); // nope, so just compute it else return -stb__div(-v1,v2) + (stb__mod(v1,-v2) ? -1 : 0); else // it must be possible to compute -(v1+v2) without overflowing return -stb__div(-(v1+v2),v2) + (stb__mod(-(v1+v2),v2) ? -2 : -1); else return v1/v2; // same sign, so expect truncation #endif } int stb_div_eucl(int v1, int v2) { int q,r; #ifdef C_INTEGER_DIVISION_TRUNCATES q = v1/v2; r = v1%v2; #else // handle every quadrant separately, since we can't rely on q and r flor if (v1 >= 0) if (v2 >= 0) return stb__div(v1,v2); else if (v2 != INT_MIN) q = -stb__div(v1,-v2), r = stb__mod(v1,-v2); else q = 0, r = v1; else if (v1 != INT_MIN) if (v2 >= 0) q = -stb__div(-v1,v2), r = -stb__mod(-v1,v2); else if (v2 != INT_MIN) q = stb__div(-v1,-v2), r = -stb__mod(-v1,-v2); else // if v2 is INT_MIN, then we can't use -v2, but we can't divide by v2 q = 1, r = v1-q*v2; else // if v1 is INT_MIN, we have to move away from overflow place if (v2 >= 0) q = -stb__div(-(v1+v2),v2)-1, r = -stb__mod(-(v1+v2),v2); else q = stb__div(-(v1-v2),-v2)+1, r = -stb__mod(-(v1-v2),-v2); #endif if (r >= 0) return q; else return q + (v2 > 0 ? -1 : 1); } int stb_mod_trunc(int v1, int v2) { #ifdef C_INTEGER_DIVISION_TRUNCATES return v1%v2; #else if (v1 >= 0) { // modulus result should always be positive int r = stb__mod(v1,v2); if (r >= 0) return r; else return r + (v2 > 0 ? v2 : -v2); } else { // modulus result should always be negative int r = stb__mod(v1,v2); if (r <= 0) return r; else return r - (v2 > 0 ? v2 : -v2); } #endif } int stb_mod_floor(int v1, int v2) { #ifdef C_INTEGER_DIVISION_FLOORS return v1%v2; #else if (v2 >= 0) { // result should always be positive int r = stb__mod(v1,v2); if (r >= 0) return r; else return r + v2; } else { // result should always be negative int r = stb__mod(v1,v2); if (r <= 0) return r; else return r + v2; } #endif } int stb_mod_eucl(int v1, int v2) { int r = stb__mod(v1,v2); if (r >= 0) return r; else return r + (v2 > 0 ? v2 : -v2); // abs() } #ifdef STB_DIVIDE_TEST #include #include #include int show=0; void stbdiv_check(int q, int r, int a, int b, char *type, int dir) { if ((dir > 0 && r < 0) || (dir < 0 && r > 0)) fprintf(stderr, "FAILED: %s(%d,%d) remainder %d in wrong direction\n", type,a,b,r); else if (b != INT_MIN) // can't compute abs(), but if b==INT_MIN all remainders are valid if (r <= -abs(b) || r >= abs(b)) fprintf(stderr, "FAILED: %s(%d,%d) remainder %d out of range\n", type,a,b,r); #ifdef STB_DIVIDE_TEST_64 { STB_DIVIDE_TEST_64 q64 = q, r64=r, a64=a, b64=b; if (q64*b64+r64 != a64) fprintf(stderr, "FAILED: %s(%d,%d) remainder %d doesn't match quotient %d\n", type,a,b,r,q); } #else if (q*b+r != a) fprintf(stderr, "FAILED: %s(%d,%d) remainder %d doesn't match quotient %d\n", type,a,b,r,q); #endif } void test(int a, int b) { int q,r; if (show) printf("(%+11d,%+d) | ", a,b); q = stb_div_trunc(a,b), r = stb_mod_trunc(a,b); if (show) printf("(%+11d,%+2d) ", q,r); stbdiv_check(q,r,a,b, "trunc",a); q = stb_div_floor(a,b), r = stb_mod_floor(a,b); if (show) printf("(%+11d,%+2d) ", q,r); stbdiv_check(q,r,a,b, "floor",b); q = stb_div_eucl (a,b), r = stb_mod_eucl (a,b); if (show) printf("(%+11d,%+2d)\n", q,r); stbdiv_check(q,r,a,b, "euclidean",1); } void testh(int a, int b) { int q,r; if (show) printf("(%08x,%08x) |\n", a,b); q = stb_div_trunc(a,b), r = stb_mod_trunc(a,b); stbdiv_check(q,r,a,b, "trunc",a); if (show) printf(" (%08x,%08x)", q,r); q = stb_div_floor(a,b), r = stb_mod_floor(a,b); stbdiv_check(q,r,a,b, "floor",b); if (show) printf(" (%08x,%08x)", q,r); q = stb_div_eucl (a,b), r = stb_mod_eucl (a,b); stbdiv_check(q,r,a,b, "euclidean",1); if (show) printf(" (%08x,%08x)\n ", q,r); } int main(int argc, char **argv) { if (argc > 1) show=1; test(8,3); test(8,-3); test(-8,3); test(-8,-3); test(1,2); test(1,-2); test(-1,2); test(-1,-2); test(8,4); test(8,-4); test(-8,4); test(-8,-4); test(INT_MAX,1); test(INT_MIN,1); test(INT_MIN+1,1); test(INT_MAX,-1); //test(INT_MIN,-1); // this traps in MSVC, so we leave it untested test(INT_MIN+1,-1); test(INT_MIN,-2); test(INT_MIN+1,2); test(INT_MIN+1,-2); test(INT_MAX,2); test(INT_MAX,-2); test(INT_MIN+1,2); test(INT_MIN+1,-2); test(INT_MIN,2); test(INT_MIN,-2); test(INT_MIN,7); test(INT_MIN,-7); test(INT_MIN+1,4); test(INT_MIN+1,-4); testh(-7, INT_MIN); testh(-1, INT_MIN); testh(1, INT_MIN); testh(7, INT_MIN); testh(INT_MAX-1, INT_MIN); testh(INT_MAX, INT_MIN); testh(INT_MIN, INT_MIN); testh(INT_MIN+1, INT_MIN); testh(INT_MAX-1, INT_MAX); testh(INT_MAX , INT_MAX); testh(INT_MIN , INT_MAX); testh(INT_MIN+1, INT_MAX); return 0; } #endif // STB_DIVIDE_TEST #endif // STB_DIVIDE_IMPLEMENTATION #endif // INCLUDE_STB_DIVIDE_H /* ------------------------------------------------------------------------------ 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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_connected_components.h0000600000175000001440000011057614003056224021650 0ustar rakusers// stb_connected_components - v0.95 - public domain connected components on grids // http://github.com/nothings/stb // // Finds connected components on 2D grids for testing reachability between // two points, with fast updates when changing reachability (e.g. on one machine // it was typically 0.2ms w/ 1024x1024 grid). Each grid square must be "open" or // "closed" (traversable or untraversable), and grid squares are only connected // to their orthogonal neighbors, not diagonally. // // In one source file, create the implementation by doing something like this: // // #define STBCC_GRID_COUNT_X_LOG2 10 // #define STBCC_GRID_COUNT_Y_LOG2 10 // #define STB_CONNECTED_COMPONENTS_IMPLEMENTATION // #include "stb_connected_components.h" // // The above creates an implementation that can run on maps up to 1024x1024. // Map sizes must be a multiple of (1<<(LOG2/2)) on each axis (e.g. 32 if LOG2=10, // 16 if LOG2=8, etc.) (You can just pad your map with untraversable space.) // // MEMORY USAGE // // Uses about 6-7 bytes per grid square (e.g. 7MB for a 1024x1024 grid). // Uses a single worst-case allocation which you pass in. // // PERFORMANCE // // On a core i7-2700K at 3.5 Ghz, for a particular 1024x1024 map (map_03.png): // // Creating map : 44.85 ms // Making one square traversable: 0.27 ms (average over 29,448 calls) // Making one square untraversable: 0.23 ms (average over 30,123 calls) // Reachability query: 0.00001 ms (average over 4,000,000 calls) // // On non-degenerate maps update time is O(N^0.5), but on degenerate maps like // checkerboards or 50% random, update time is O(N^0.75) (~2ms on above machine). // // CHANGELOG // // 0.95 (2016-10-16) Bugfix if multiple clumps in one cluster connect to same clump in another // 0.94 (2016-04-17) Bugfix & optimize worst case (checkerboard & random) // 0.93 (2016-04-16) Reduce memory by 10x for 1Kx1K map; small speedup // 0.92 (2016-04-16) Compute sqrt(N) cluster size by default // 0.91 (2016-04-15) Initial release // // TODO: // - better API documentation // - more comments // - try re-integrating naive algorithm & compare performance // - more optimized batching (current approach still recomputes local clumps many times) // - function for setting a grid of squares at once (just use batching) // // LICENSE // // See end of file for license information. // // ALGORITHM // // The NxN grid map is split into sqrt(N) x sqrt(N) blocks called // "clusters". Each cluster independently computes a set of connected // components within that cluster (ignoring all connectivity out of // that cluster) using a union-find disjoint set forest. This produces a bunch // of locally connected components called "clumps". Each clump is (a) connected // within its cluster, (b) does not directly connect to any other clumps in the // cluster (though it may connect to them by paths that lead outside the cluster, // but those are ignored at this step), and (c) maintains an adjacency list of // all clumps in adjacent clusters that it _is_ connected to. Then a second // union-find disjoint set forest is used to compute connected clumps // globally, across the whole map. Reachability is then computed by // finding which clump each input point belongs to, and checking whether // those clumps are in the same "global" connected component. // // The above data structure can be updated efficiently; on a change // of a single grid square on the map, only one cluster changes its // purely-local state, so only one cluster needs its clumps fully // recomputed. Clumps in adjacent clusters need their adjacency lists // updated: first to remove all references to the old clumps in the // rebuilt cluster, then to add new references to the new clumps. Both // of these operations can use the existing "find which clump each input // point belongs to" query to compute that adjacency information rapidly. #ifndef INCLUDE_STB_CONNECTED_COMPONENTS_H #define INCLUDE_STB_CONNECTED_COMPONENTS_H #include typedef struct st_stbcc_grid stbcc_grid; #ifdef __cplusplus extern "C" { #endif ////////////////////////////////////////////////////////////////////////////////////////// // // initialization // // you allocate the grid data structure to this size (note that it will be very big!!!) extern size_t stbcc_grid_sizeof(void); // initialize the grid, value of map[] is 0 = traversable, non-0 is solid extern void stbcc_init_grid(stbcc_grid *g, unsigned char *map, int w, int h); ////////////////////////////////////////////////////////////////////////////////////////// // // main functionality // // update a grid square state, 0 = traversable, non-0 is solid // i can add a batch-update if it's needed extern void stbcc_update_grid(stbcc_grid *g, int x, int y, int solid); // query if two grid squares are reachable from each other extern int stbcc_query_grid_node_connection(stbcc_grid *g, int x1, int y1, int x2, int y2); ////////////////////////////////////////////////////////////////////////////////////////// // // bonus functions // // wrap multiple stbcc_update_grid calls in these function to compute // multiple updates more efficiently; cannot make queries inside batch extern void stbcc_update_batch_begin(stbcc_grid *g); extern void stbcc_update_batch_end(stbcc_grid *g); // query the grid data structure for whether a given square is open or not extern int stbcc_query_grid_open(stbcc_grid *g, int x, int y); // get a unique id for the connected component this is in; it's not necessarily // small, you'll need a hash table or something to remap it (or just use extern unsigned int stbcc_get_unique_id(stbcc_grid *g, int x, int y); #define STBCC_NULL_UNIQUE_ID 0xffffffff // returned for closed map squares #ifdef __cplusplus } #endif #endif // INCLUDE_STB_CONNECTED_COMPONENTS_H #ifdef STB_CONNECTED_COMPONENTS_IMPLEMENTATION #include #include // memset #if !defined(STBCC_GRID_COUNT_X_LOG2) || !defined(STBCC_GRID_COUNT_Y_LOG2) #error "You must define STBCC_GRID_COUNT_X_LOG2 and STBCC_GRID_COUNT_Y_LOG2 to define the max grid supported." #endif #define STBCC__GRID_COUNT_X (1 << STBCC_GRID_COUNT_X_LOG2) #define STBCC__GRID_COUNT_Y (1 << STBCC_GRID_COUNT_Y_LOG2) #define STBCC__MAP_STRIDE (1 << (STBCC_GRID_COUNT_X_LOG2-3)) #ifndef STBCC_CLUSTER_SIZE_X_LOG2 #define STBCC_CLUSTER_SIZE_X_LOG2 (STBCC_GRID_COUNT_X_LOG2/2) // log2(sqrt(2^N)) = 1/2 * log2(2^N)) = 1/2 * N #if STBCC_CLUSTER_SIZE_X_LOG2 > 6 #undef STBCC_CLUSTER_SIZE_X_LOG2 #define STBCC_CLUSTER_SIZE_X_LOG2 6 #endif #endif #ifndef STBCC_CLUSTER_SIZE_Y_LOG2 #define STBCC_CLUSTER_SIZE_Y_LOG2 (STBCC_GRID_COUNT_Y_LOG2/2) #if STBCC_CLUSTER_SIZE_Y_LOG2 > 6 #undef STBCC_CLUSTER_SIZE_Y_LOG2 #define STBCC_CLUSTER_SIZE_Y_LOG2 6 #endif #endif #define STBCC__CLUSTER_SIZE_X (1 << STBCC_CLUSTER_SIZE_X_LOG2) #define STBCC__CLUSTER_SIZE_Y (1 << STBCC_CLUSTER_SIZE_Y_LOG2) #define STBCC__CLUSTER_COUNT_X_LOG2 (STBCC_GRID_COUNT_X_LOG2 - STBCC_CLUSTER_SIZE_X_LOG2) #define STBCC__CLUSTER_COUNT_Y_LOG2 (STBCC_GRID_COUNT_Y_LOG2 - STBCC_CLUSTER_SIZE_Y_LOG2) #define STBCC__CLUSTER_COUNT_X (1 << STBCC__CLUSTER_COUNT_X_LOG2) #define STBCC__CLUSTER_COUNT_Y (1 << STBCC__CLUSTER_COUNT_Y_LOG2) #if STBCC__CLUSTER_SIZE_X >= STBCC__GRID_COUNT_X || STBCC__CLUSTER_SIZE_Y >= STBCC__GRID_COUNT_Y #error "STBCC_CLUSTER_SIZE_X/Y_LOG2 must be smaller than STBCC_GRID_COUNT_X/Y_LOG2" #endif // worst case # of clumps per cluster #define STBCC__MAX_CLUMPS_PER_CLUSTER_LOG2 (STBCC_CLUSTER_SIZE_X_LOG2 + STBCC_CLUSTER_SIZE_Y_LOG2-1) #define STBCC__MAX_CLUMPS_PER_CLUSTER (1 << STBCC__MAX_CLUMPS_PER_CLUSTER_LOG2) #define STBCC__MAX_CLUMPS (STBCC__MAX_CLUMPS_PER_CLUSTER * STBCC__CLUSTER_COUNT_X * STBCC__CLUSTER_COUNT_Y) #define STBCC__NULL_CLUMPID STBCC__MAX_CLUMPS_PER_CLUSTER #define STBCC__CLUSTER_X_FOR_COORD_X(x) ((x) >> STBCC_CLUSTER_SIZE_X_LOG2) #define STBCC__CLUSTER_Y_FOR_COORD_Y(y) ((y) >> STBCC_CLUSTER_SIZE_Y_LOG2) #define STBCC__MAP_BYTE_MASK(x,y) (1 << ((x) & 7)) #define STBCC__MAP_BYTE(g,x,y) ((g)->map[y][(x) >> 3]) #define STBCC__MAP_OPEN(g,x,y) (STBCC__MAP_BYTE(g,x,y) & STBCC__MAP_BYTE_MASK(x,y)) typedef unsigned short stbcc__clumpid; typedef unsigned char stbcc__verify_max_clumps[STBCC__MAX_CLUMPS_PER_CLUSTER < (1 << (8*sizeof(stbcc__clumpid))) ? 1 : -1]; #define STBCC__MAX_EXITS_PER_CLUSTER (STBCC__CLUSTER_SIZE_X + STBCC__CLUSTER_SIZE_Y) // 64 for 32x32 #define STBCC__MAX_EXITS_PER_CLUMP (STBCC__CLUSTER_SIZE_X + STBCC__CLUSTER_SIZE_Y) // 64 for 32x32 #define STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER (STBCC__MAX_EXITS_PER_CLUMP) // 2^19 * 2^6 => 2^25 exits => 2^26 => 64MB for 1024x1024 // Logic for above on 4x4 grid: // // Many clumps: One clump: // + + + + // +X.X. +XX.X+ // .X.X+ .XXX // +X.X. XXX. // .X.X+ +X.XX+ // + + + + // // 8 exits either way typedef unsigned char stbcc__verify_max_exits[STBCC__MAX_EXITS_PER_CLUMP <= 256]; typedef struct { unsigned short clump_index:12; signed short cluster_dx:2; signed short cluster_dy:2; } stbcc__relative_clumpid; typedef union { struct { unsigned int clump_index:12; unsigned int cluster_x:10; unsigned int cluster_y:10; } f; unsigned int c; } stbcc__global_clumpid; // rebuilt cluster 3,4 // what changes in cluster 2,4 typedef struct { stbcc__global_clumpid global_label; // 4 unsigned char num_adjacent; // 1 unsigned char max_adjacent; // 1 unsigned char adjacent_clump_list_index; // 1 unsigned char reserved; } stbcc__clump; // 8 #define STBCC__CLUSTER_ADJACENCY_COUNT (STBCC__MAX_EXITS_PER_CLUSTER*2) typedef struct { short num_clumps; unsigned char num_edge_clumps; unsigned char rebuild_adjacency; stbcc__clump clump[STBCC__MAX_CLUMPS_PER_CLUSTER]; // 8 * 2^9 = 4KB stbcc__relative_clumpid adjacency_storage[STBCC__CLUSTER_ADJACENCY_COUNT]; // 256 bytes } stbcc__cluster; struct st_stbcc_grid { int w,h,cw,ch; int in_batched_update; //unsigned char cluster_dirty[STBCC__CLUSTER_COUNT_Y][STBCC__CLUSTER_COUNT_X]; // could bitpack, but: 1K x 1K => 1KB unsigned char map[STBCC__GRID_COUNT_Y][STBCC__MAP_STRIDE]; // 1K x 1K => 1K x 128 => 128KB stbcc__clumpid clump_for_node[STBCC__GRID_COUNT_Y][STBCC__GRID_COUNT_X]; // 1K x 1K x 2 = 2MB stbcc__cluster cluster[STBCC__CLUSTER_COUNT_Y][STBCC__CLUSTER_COUNT_X]; // 1K x 4.5KB = 4.5MB }; int stbcc_query_grid_node_connection(stbcc_grid *g, int x1, int y1, int x2, int y2) { stbcc__global_clumpid label1, label2; stbcc__clumpid c1 = g->clump_for_node[y1][x1]; stbcc__clumpid c2 = g->clump_for_node[y2][x2]; int cx1 = STBCC__CLUSTER_X_FOR_COORD_X(x1); int cy1 = STBCC__CLUSTER_Y_FOR_COORD_Y(y1); int cx2 = STBCC__CLUSTER_X_FOR_COORD_X(x2); int cy2 = STBCC__CLUSTER_Y_FOR_COORD_Y(y2); assert(!g->in_batched_update); if (c1 == STBCC__NULL_CLUMPID || c2 == STBCC__NULL_CLUMPID) return 0; label1 = g->cluster[cy1][cx1].clump[c1].global_label; label2 = g->cluster[cy2][cx2].clump[c2].global_label; if (label1.c == label2.c) return 1; return 0; } int stbcc_query_grid_open(stbcc_grid *g, int x, int y) { return STBCC__MAP_OPEN(g, x, y) != 0; } unsigned int stbcc_get_unique_id(stbcc_grid *g, int x, int y) { stbcc__clumpid c = g->clump_for_node[y][x]; int cx = STBCC__CLUSTER_X_FOR_COORD_X(x); int cy = STBCC__CLUSTER_Y_FOR_COORD_Y(y); assert(!g->in_batched_update); if (c == STBCC__NULL_CLUMPID) return STBCC_NULL_UNIQUE_ID; return g->cluster[cy][cx].clump[c].global_label.c; } typedef struct { unsigned char x,y; } stbcc__tinypoint; typedef struct { stbcc__tinypoint parent[STBCC__CLUSTER_SIZE_Y][STBCC__CLUSTER_SIZE_X]; // 32x32 => 2KB stbcc__clumpid label[STBCC__CLUSTER_SIZE_Y][STBCC__CLUSTER_SIZE_X]; } stbcc__cluster_build_info; static void stbcc__build_clumps_for_cluster(stbcc_grid *g, int cx, int cy); static void stbcc__remove_connections_to_adjacent_cluster(stbcc_grid *g, int cx, int cy, int dx, int dy); static void stbcc__add_connections_to_adjacent_cluster(stbcc_grid *g, int cx, int cy, int dx, int dy); static stbcc__global_clumpid stbcc__clump_find(stbcc_grid *g, stbcc__global_clumpid n) { stbcc__global_clumpid q; stbcc__clump *c = &g->cluster[n.f.cluster_y][n.f.cluster_x].clump[n.f.clump_index]; if (c->global_label.c == n.c) return n; q = stbcc__clump_find(g, c->global_label); c->global_label = q; return q; } typedef struct { unsigned int cluster_x; unsigned int cluster_y; unsigned int clump_index; } stbcc__unpacked_clumpid; static void stbcc__clump_union(stbcc_grid *g, stbcc__unpacked_clumpid m, int x, int y, int idx) { stbcc__clump *mc = &g->cluster[m.cluster_y][m.cluster_x].clump[m.clump_index]; stbcc__clump *nc = &g->cluster[y][x].clump[idx]; stbcc__global_clumpid mp = stbcc__clump_find(g, mc->global_label); stbcc__global_clumpid np = stbcc__clump_find(g, nc->global_label); if (mp.c == np.c) return; g->cluster[mp.f.cluster_y][mp.f.cluster_x].clump[mp.f.clump_index].global_label = np; } static void stbcc__build_connected_components_for_clumps(stbcc_grid *g) { int i,j,k,h; for (j=0; j < STBCC__CLUSTER_COUNT_Y; ++j) { for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i) { stbcc__cluster *cluster = &g->cluster[j][i]; for (k=0; k < (int) cluster->num_edge_clumps; ++k) { stbcc__global_clumpid m; m.f.clump_index = k; m.f.cluster_x = i; m.f.cluster_y = j; assert((int) m.f.clump_index == k && (int) m.f.cluster_x == i && (int) m.f.cluster_y == j); cluster->clump[k].global_label = m; } } } for (j=0; j < STBCC__CLUSTER_COUNT_Y; ++j) { for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i) { stbcc__cluster *cluster = &g->cluster[j][i]; for (k=0; k < (int) cluster->num_edge_clumps; ++k) { stbcc__clump *clump = &cluster->clump[k]; stbcc__unpacked_clumpid m; stbcc__relative_clumpid *adj; m.clump_index = k; m.cluster_x = i; m.cluster_y = j; adj = &cluster->adjacency_storage[clump->adjacent_clump_list_index]; for (h=0; h < clump->num_adjacent; ++h) { unsigned int clump_index = adj[h].clump_index; unsigned int x = adj[h].cluster_dx + i; unsigned int y = adj[h].cluster_dy + j; stbcc__clump_union(g, m, x, y, clump_index); } } } } for (j=0; j < STBCC__CLUSTER_COUNT_Y; ++j) { for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i) { stbcc__cluster *cluster = &g->cluster[j][i]; for (k=0; k < (int) cluster->num_edge_clumps; ++k) { stbcc__global_clumpid m; m.f.clump_index = k; m.f.cluster_x = i; m.f.cluster_y = j; stbcc__clump_find(g, m); } } } } static void stbcc__build_all_connections_for_cluster(stbcc_grid *g, int cx, int cy) { // in this particular case, we are fully non-incremental. that means we // can discover the correct sizes for the arrays, but requires we build // the data into temporary data structures, or just count the sizes, so // for simplicity we do the latter stbcc__cluster *cluster = &g->cluster[cy][cx]; unsigned char connected[STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER][STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER/8]; // 64 x 8 => 1KB unsigned char num_adj[STBCC__MAX_CLUMPS_PER_CLUSTER] = { 0 }; int x = cx * STBCC__CLUSTER_SIZE_X; int y = cy * STBCC__CLUSTER_SIZE_Y; int step_x, step_y=0, i, j, k, n, m, dx, dy, total; int extra; g->cluster[cy][cx].rebuild_adjacency = 0; total = 0; for (m=0; m < 4; ++m) { switch (m) { case 0: dx = 1, dy = 0; step_x = 0, step_y = 1; i = STBCC__CLUSTER_SIZE_X-1; j = 0; n = STBCC__CLUSTER_SIZE_Y; break; case 1: dx = -1, dy = 0; i = 0; j = 0; step_x = 0; step_y = 1; n = STBCC__CLUSTER_SIZE_Y; break; case 2: dy = -1, dx = 0; i = 0; j = 0; step_x = 1; step_y = 0; n = STBCC__CLUSTER_SIZE_X; break; case 3: dy = 1, dx = 0; i = 0; j = STBCC__CLUSTER_SIZE_Y-1; step_x = 1; step_y = 0; n = STBCC__CLUSTER_SIZE_X; break; } if (cx+dx < 0 || cx+dx >= g->cw || cy+dy < 0 || cy+dy >= g->ch) continue; memset(connected, 0, sizeof(connected)); for (k=0; k < n; ++k) { if (STBCC__MAP_OPEN(g, x+i, y+j) && STBCC__MAP_OPEN(g, x+i+dx, y+j+dy)) { stbcc__clumpid src = g->clump_for_node[y+j][x+i]; stbcc__clumpid dest = g->clump_for_node[y+j+dy][x+i+dx]; if (0 == (connected[src][dest>>3] & (1 << (dest & 7)))) { connected[src][dest>>3] |= 1 << (dest & 7); ++num_adj[src]; ++total; } } i += step_x; j += step_y; } } assert(total <= STBCC__CLUSTER_ADJACENCY_COUNT); // decide how to apportion unused adjacency slots; only clumps that lie // on the edges of the cluster need adjacency slots, so divide them up // evenly between those clumps // we want: // extra = (STBCC__CLUSTER_ADJACENCY_COUNT - total) / cluster->num_edge_clumps; // but we efficiently approximate this without a divide, because // ignoring edge-vs-non-edge with 'num_adj[i]*2' was faster than // 'num_adj[i]+extra' with the divide if (total + (cluster->num_edge_clumps<<2) <= STBCC__CLUSTER_ADJACENCY_COUNT) extra = 4; else if (total + (cluster->num_edge_clumps<<1) <= STBCC__CLUSTER_ADJACENCY_COUNT) extra = 2; else if (total + (cluster->num_edge_clumps<<0) <= STBCC__CLUSTER_ADJACENCY_COUNT) extra = 1; else extra = 0; total = 0; for (i=0; i < (int) cluster->num_edge_clumps; ++i) { int alloc = num_adj[i]+extra; if (alloc > STBCC__MAX_EXITS_PER_CLUSTER) alloc = STBCC__MAX_EXITS_PER_CLUSTER; assert(total < 256); // must fit in byte cluster->clump[i].adjacent_clump_list_index = (unsigned char) total; cluster->clump[i].max_adjacent = alloc; cluster->clump[i].num_adjacent = 0; total += alloc; } assert(total <= STBCC__CLUSTER_ADJACENCY_COUNT); stbcc__add_connections_to_adjacent_cluster(g, cx, cy, -1, 0); stbcc__add_connections_to_adjacent_cluster(g, cx, cy, 1, 0); stbcc__add_connections_to_adjacent_cluster(g, cx, cy, 0,-1); stbcc__add_connections_to_adjacent_cluster(g, cx, cy, 0, 1); // make sure all of the above succeeded. assert(g->cluster[cy][cx].rebuild_adjacency == 0); } static void stbcc__add_connections_to_adjacent_cluster_with_rebuild(stbcc_grid *g, int cx, int cy, int dx, int dy) { if (cx >= 0 && cx < g->cw && cy >= 0 && cy < g->ch) { stbcc__add_connections_to_adjacent_cluster(g, cx, cy, dx, dy); if (g->cluster[cy][cx].rebuild_adjacency) stbcc__build_all_connections_for_cluster(g, cx, cy); } } void stbcc_update_grid(stbcc_grid *g, int x, int y, int solid) { int cx,cy; if (!solid) { if (STBCC__MAP_OPEN(g,x,y)) return; } else { if (!STBCC__MAP_OPEN(g,x,y)) return; } cx = STBCC__CLUSTER_X_FOR_COORD_X(x); cy = STBCC__CLUSTER_Y_FOR_COORD_Y(y); stbcc__remove_connections_to_adjacent_cluster(g, cx-1, cy, 1, 0); stbcc__remove_connections_to_adjacent_cluster(g, cx+1, cy, -1, 0); stbcc__remove_connections_to_adjacent_cluster(g, cx, cy-1, 0, 1); stbcc__remove_connections_to_adjacent_cluster(g, cx, cy+1, 0,-1); if (!solid) STBCC__MAP_BYTE(g,x,y) |= STBCC__MAP_BYTE_MASK(x,y); else STBCC__MAP_BYTE(g,x,y) &= ~STBCC__MAP_BYTE_MASK(x,y); stbcc__build_clumps_for_cluster(g, cx, cy); stbcc__build_all_connections_for_cluster(g, cx, cy); stbcc__add_connections_to_adjacent_cluster_with_rebuild(g, cx-1, cy, 1, 0); stbcc__add_connections_to_adjacent_cluster_with_rebuild(g, cx+1, cy, -1, 0); stbcc__add_connections_to_adjacent_cluster_with_rebuild(g, cx, cy-1, 0, 1); stbcc__add_connections_to_adjacent_cluster_with_rebuild(g, cx, cy+1, 0,-1); if (!g->in_batched_update) stbcc__build_connected_components_for_clumps(g); #if 0 else g->cluster_dirty[cy][cx] = 1; #endif } void stbcc_update_batch_begin(stbcc_grid *g) { assert(!g->in_batched_update); g->in_batched_update = 1; } void stbcc_update_batch_end(stbcc_grid *g) { assert(g->in_batched_update); g->in_batched_update = 0; stbcc__build_connected_components_for_clumps(g); // @OPTIMIZE: only do this if update was non-empty } size_t stbcc_grid_sizeof(void) { return sizeof(stbcc_grid); } void stbcc_init_grid(stbcc_grid *g, unsigned char *map, int w, int h) { int i,j,k; assert(w % STBCC__CLUSTER_SIZE_X == 0); assert(h % STBCC__CLUSTER_SIZE_Y == 0); assert(w % 8 == 0); g->w = w; g->h = h; g->cw = w >> STBCC_CLUSTER_SIZE_X_LOG2; g->ch = h >> STBCC_CLUSTER_SIZE_Y_LOG2; g->in_batched_update = 0; #if 0 for (j=0; j < STBCC__CLUSTER_COUNT_Y; ++j) for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i) g->cluster_dirty[j][i] = 0; #endif for (j=0; j < h; ++j) { for (i=0; i < w; i += 8) { unsigned char c = 0; for (k=0; k < 8; ++k) if (map[j*w + (i+k)] == 0) c |= (1 << k); g->map[j][i>>3] = c; } } for (j=0; j < g->ch; ++j) for (i=0; i < g->cw; ++i) stbcc__build_clumps_for_cluster(g, i, j); for (j=0; j < g->ch; ++j) for (i=0; i < g->cw; ++i) stbcc__build_all_connections_for_cluster(g, i, j); stbcc__build_connected_components_for_clumps(g); for (j=0; j < g->h; ++j) for (i=0; i < g->w; ++i) assert(g->clump_for_node[j][i] <= STBCC__NULL_CLUMPID); } static void stbcc__add_clump_connection(stbcc_grid *g, int x1, int y1, int x2, int y2) { stbcc__cluster *cluster; stbcc__clump *clump; int cx1 = STBCC__CLUSTER_X_FOR_COORD_X(x1); int cy1 = STBCC__CLUSTER_Y_FOR_COORD_Y(y1); int cx2 = STBCC__CLUSTER_X_FOR_COORD_X(x2); int cy2 = STBCC__CLUSTER_Y_FOR_COORD_Y(y2); stbcc__clumpid c1 = g->clump_for_node[y1][x1]; stbcc__clumpid c2 = g->clump_for_node[y2][x2]; stbcc__relative_clumpid rc; assert(cx1 != cx2 || cy1 != cy2); assert(abs(cx1-cx2) + abs(cy1-cy2) == 1); // add connection to c2 in c1 rc.clump_index = c2; rc.cluster_dx = x2-x1; rc.cluster_dy = y2-y1; cluster = &g->cluster[cy1][cx1]; clump = &cluster->clump[c1]; assert(clump->num_adjacent <= clump->max_adjacent); if (clump->num_adjacent == clump->max_adjacent) g->cluster[cy1][cx1].rebuild_adjacency = 1; else { stbcc__relative_clumpid *adj = &cluster->adjacency_storage[clump->adjacent_clump_list_index]; assert(clump->num_adjacent < STBCC__MAX_EXITS_PER_CLUMP); assert(clump->adjacent_clump_list_index + clump->num_adjacent <= STBCC__CLUSTER_ADJACENCY_COUNT); adj[clump->num_adjacent++] = rc; } } static void stbcc__remove_clump_connection(stbcc_grid *g, int x1, int y1, int x2, int y2) { stbcc__cluster *cluster; stbcc__clump *clump; stbcc__relative_clumpid *adj; int i; int cx1 = STBCC__CLUSTER_X_FOR_COORD_X(x1); int cy1 = STBCC__CLUSTER_Y_FOR_COORD_Y(y1); int cx2 = STBCC__CLUSTER_X_FOR_COORD_X(x2); int cy2 = STBCC__CLUSTER_Y_FOR_COORD_Y(y2); stbcc__clumpid c1 = g->clump_for_node[y1][x1]; stbcc__clumpid c2 = g->clump_for_node[y2][x2]; stbcc__relative_clumpid rc; assert(cx1 != cx2 || cy1 != cy2); assert(abs(cx1-cx2) + abs(cy1-cy2) == 1); // add connection to c2 in c1 rc.clump_index = c2; rc.cluster_dx = x2-x1; rc.cluster_dy = y2-y1; cluster = &g->cluster[cy1][cx1]; clump = &cluster->clump[c1]; adj = &cluster->adjacency_storage[clump->adjacent_clump_list_index]; for (i=0; i < clump->num_adjacent; ++i) if (rc.clump_index == adj[i].clump_index && rc.cluster_dx == adj[i].cluster_dx && rc.cluster_dy == adj[i].cluster_dy) break; if (i < clump->num_adjacent) adj[i] = adj[--clump->num_adjacent]; else assert(0); } static void stbcc__add_connections_to_adjacent_cluster(stbcc_grid *g, int cx, int cy, int dx, int dy) { unsigned char connected[STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER][STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER/8] = { 0 }; int x = cx * STBCC__CLUSTER_SIZE_X; int y = cy * STBCC__CLUSTER_SIZE_Y; int step_x, step_y=0, i, j, k, n; if (cx < 0 || cx >= g->cw || cy < 0 || cy >= g->ch) return; if (cx+dx < 0 || cx+dx >= g->cw || cy+dy < 0 || cy+dy >= g->ch) return; if (g->cluster[cy][cx].rebuild_adjacency) return; assert(abs(dx) + abs(dy) == 1); if (dx == 1) { i = STBCC__CLUSTER_SIZE_X-1; j = 0; step_x = 0; step_y = 1; n = STBCC__CLUSTER_SIZE_Y; } else if (dx == -1) { i = 0; j = 0; step_x = 0; step_y = 1; n = STBCC__CLUSTER_SIZE_Y; } else if (dy == -1) { i = 0; j = 0; step_x = 1; step_y = 0; n = STBCC__CLUSTER_SIZE_X; } else if (dy == 1) { i = 0; j = STBCC__CLUSTER_SIZE_Y-1; step_x = 1; step_y = 0; n = STBCC__CLUSTER_SIZE_X; } else { assert(0); } for (k=0; k < n; ++k) { if (STBCC__MAP_OPEN(g, x+i, y+j) && STBCC__MAP_OPEN(g, x+i+dx, y+j+dy)) { stbcc__clumpid src = g->clump_for_node[y+j][x+i]; stbcc__clumpid dest = g->clump_for_node[y+j+dy][x+i+dx]; if (0 == (connected[src][dest>>3] & (1 << (dest & 7)))) { assert((dest>>3) < sizeof(connected)); connected[src][dest>>3] |= 1 << (dest & 7); stbcc__add_clump_connection(g, x+i, y+j, x+i+dx, y+j+dy); if (g->cluster[cy][cx].rebuild_adjacency) break; } } i += step_x; j += step_y; } } static void stbcc__remove_connections_to_adjacent_cluster(stbcc_grid *g, int cx, int cy, int dx, int dy) { unsigned char disconnected[STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER][STBCC__MAX_EDGE_CLUMPS_PER_CLUSTER/8] = { 0 }; int x = cx * STBCC__CLUSTER_SIZE_X; int y = cy * STBCC__CLUSTER_SIZE_Y; int step_x, step_y=0, i, j, k, n; if (cx < 0 || cx >= g->cw || cy < 0 || cy >= g->ch) return; if (cx+dx < 0 || cx+dx >= g->cw || cy+dy < 0 || cy+dy >= g->ch) return; assert(abs(dx) + abs(dy) == 1); if (dx == 1) { i = STBCC__CLUSTER_SIZE_X-1; j = 0; step_x = 0; step_y = 1; n = STBCC__CLUSTER_SIZE_Y; } else if (dx == -1) { i = 0; j = 0; step_x = 0; step_y = 1; n = STBCC__CLUSTER_SIZE_Y; } else if (dy == -1) { i = 0; j = 0; step_x = 1; step_y = 0; n = STBCC__CLUSTER_SIZE_X; } else if (dy == 1) { i = 0; j = STBCC__CLUSTER_SIZE_Y-1; step_x = 1; step_y = 0; n = STBCC__CLUSTER_SIZE_X; } else { assert(0); } for (k=0; k < n; ++k) { if (STBCC__MAP_OPEN(g, x+i, y+j) && STBCC__MAP_OPEN(g, x+i+dx, y+j+dy)) { stbcc__clumpid src = g->clump_for_node[y+j][x+i]; stbcc__clumpid dest = g->clump_for_node[y+j+dy][x+i+dx]; if (0 == (disconnected[src][dest>>3] & (1 << (dest & 7)))) { disconnected[src][dest>>3] |= 1 << (dest & 7); stbcc__remove_clump_connection(g, x+i, y+j, x+i+dx, y+j+dy); } } i += step_x; j += step_y; } } static stbcc__tinypoint stbcc__incluster_find(stbcc__cluster_build_info *cbi, int x, int y) { stbcc__tinypoint p,q; p = cbi->parent[y][x]; if (p.x == x && p.y == y) return p; q = stbcc__incluster_find(cbi, p.x, p.y); cbi->parent[y][x] = q; return q; } static void stbcc__incluster_union(stbcc__cluster_build_info *cbi, int x1, int y1, int x2, int y2) { stbcc__tinypoint p = stbcc__incluster_find(cbi, x1,y1); stbcc__tinypoint q = stbcc__incluster_find(cbi, x2,y2); if (p.x == q.x && p.y == q.y) return; cbi->parent[p.y][p.x] = q; } static void stbcc__switch_root(stbcc__cluster_build_info *cbi, int x, int y, stbcc__tinypoint p) { cbi->parent[p.y][p.x].x = x; cbi->parent[p.y][p.x].y = y; cbi->parent[y][x].x = x; cbi->parent[y][x].y = y; } static void stbcc__build_clumps_for_cluster(stbcc_grid *g, int cx, int cy) { stbcc__cluster *c; stbcc__cluster_build_info cbi; int label=0; int i,j; int x = cx * STBCC__CLUSTER_SIZE_X; int y = cy * STBCC__CLUSTER_SIZE_Y; // set initial disjoint set forest state for (j=0; j < STBCC__CLUSTER_SIZE_Y; ++j) { for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) { cbi.parent[j][i].x = i; cbi.parent[j][i].y = j; } } // join all sets that are connected for (j=0; j < STBCC__CLUSTER_SIZE_Y; ++j) { // check down only if not on bottom row if (j < STBCC__CLUSTER_SIZE_Y-1) for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) if (STBCC__MAP_OPEN(g,x+i,y+j) && STBCC__MAP_OPEN(g,x+i ,y+j+1)) stbcc__incluster_union(&cbi, i,j, i,j+1); // check right for everything but rightmost column for (i=0; i < STBCC__CLUSTER_SIZE_X-1; ++i) if (STBCC__MAP_OPEN(g,x+i,y+j) && STBCC__MAP_OPEN(g,x+i+1,y+j )) stbcc__incluster_union(&cbi, i,j, i+1,j); } // label all non-empty clumps along edges so that all edge clumps are first // in list; this means in degenerate case we can skip traversing non-edge clumps. // because in the first pass we only label leaders, we swap the leader to the // edge first // first put solid labels on all the edges; these will get overwritten if they're open for (j=0; j < STBCC__CLUSTER_SIZE_Y; ++j) cbi.label[j][0] = cbi.label[j][STBCC__CLUSTER_SIZE_X-1] = STBCC__NULL_CLUMPID; for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) cbi.label[0][i] = cbi.label[STBCC__CLUSTER_SIZE_Y-1][i] = STBCC__NULL_CLUMPID; for (j=0; j < STBCC__CLUSTER_SIZE_Y; ++j) { i = 0; if (STBCC__MAP_OPEN(g, x+i, y+j)) { stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); if (p.x == i && p.y == j) // if this is the leader, give it a label cbi.label[j][i] = label++; else if (!(p.x == 0 || p.x == STBCC__CLUSTER_SIZE_X-1 || p.y == 0 || p.y == STBCC__CLUSTER_SIZE_Y-1)) { // if leader is in interior, promote this edge node to leader and label stbcc__switch_root(&cbi, i, j, p); cbi.label[j][i] = label++; } // else if leader is on edge, do nothing (it'll get labelled when we reach it) } i = STBCC__CLUSTER_SIZE_X-1; if (STBCC__MAP_OPEN(g, x+i, y+j)) { stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); if (p.x == i && p.y == j) cbi.label[j][i] = label++; else if (!(p.x == 0 || p.x == STBCC__CLUSTER_SIZE_X-1 || p.y == 0 || p.y == STBCC__CLUSTER_SIZE_Y-1)) { stbcc__switch_root(&cbi, i, j, p); cbi.label[j][i] = label++; } } } for (i=1; i < STBCC__CLUSTER_SIZE_Y-1; ++i) { j = 0; if (STBCC__MAP_OPEN(g, x+i, y+j)) { stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); if (p.x == i && p.y == j) cbi.label[j][i] = label++; else if (!(p.x == 0 || p.x == STBCC__CLUSTER_SIZE_X-1 || p.y == 0 || p.y == STBCC__CLUSTER_SIZE_Y-1)) { stbcc__switch_root(&cbi, i, j, p); cbi.label[j][i] = label++; } } j = STBCC__CLUSTER_SIZE_Y-1; if (STBCC__MAP_OPEN(g, x+i, y+j)) { stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); if (p.x == i && p.y == j) cbi.label[j][i] = label++; else if (!(p.x == 0 || p.x == STBCC__CLUSTER_SIZE_X-1 || p.y == 0 || p.y == STBCC__CLUSTER_SIZE_Y-1)) { stbcc__switch_root(&cbi, i, j, p); cbi.label[j][i] = label++; } } } c = &g->cluster[cy][cx]; c->num_edge_clumps = label; // label any internal clusters for (j=1; j < STBCC__CLUSTER_SIZE_Y-1; ++j) { for (i=1; i < STBCC__CLUSTER_SIZE_X-1; ++i) { stbcc__tinypoint p = cbi.parent[j][i]; if (p.x == i && p.y == j) if (STBCC__MAP_OPEN(g,x+i,y+j)) cbi.label[j][i] = label++; else cbi.label[j][i] = STBCC__NULL_CLUMPID; } } // label all other nodes for (j=0; j < STBCC__CLUSTER_SIZE_Y; ++j) { for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) { stbcc__tinypoint p = stbcc__incluster_find(&cbi, i,j); if (p.x != i || p.y != j) { if (STBCC__MAP_OPEN(g,x+i,y+j)) cbi.label[j][i] = cbi.label[p.y][p.x]; } if (STBCC__MAP_OPEN(g,x+i,y+j)) assert(cbi.label[j][i] != STBCC__NULL_CLUMPID); } } c->num_clumps = label; for (i=0; i < label; ++i) { c->clump[i].num_adjacent = 0; c->clump[i].max_adjacent = 0; } for (j=0; j < STBCC__CLUSTER_SIZE_Y; ++j) for (i=0; i < STBCC__CLUSTER_SIZE_X; ++i) { g->clump_for_node[y+j][x+i] = cbi.label[j][i]; // @OPTIMIZE: remove cbi.label entirely assert(g->clump_for_node[y+j][x+i] <= STBCC__NULL_CLUMPID); } // set the global label for all interior clumps since they can't have connections, // so we don't have to do this on the global pass (brings from O(N) to O(N^0.75)) for (i=(int) c->num_edge_clumps; i < (int) c->num_clumps; ++i) { stbcc__global_clumpid gc; gc.f.cluster_x = cx; gc.f.cluster_y = cy; gc.f.clump_index = i; c->clump[i].global_label = gc; } c->rebuild_adjacency = 1; // flag that it has no valid adjacency data } #endif // STB_CONNECTED_COMPONENTS_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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb_c_lexer.h0000600000175000001440000010532614003056224017057 0ustar rakusers// stb_c_lexer.h - v0.09 - public domain Sean Barrett 2013 // lexer for making little C-like languages with recursive-descent parsers // // This file provides both the interface and the implementation. // To instantiate the implementation, // #define STB_C_LEXER_IMPLEMENTATION // in *ONE* source file, before #including this file. // // The default configuration is fairly close to a C lexer, although // suffixes on integer constants are not handled (you can override this). // // History: // 0.09 hex floats, no-stdlib fixes // 0.08 fix bad pointer comparison // 0.07 fix mishandling of hexadecimal constants parsed by strtol // 0.06 fix missing next character after ending quote mark (Andreas Fredriksson) // 0.05 refixed get_location because github version had lost the fix // 0.04 fix octal parsing bug // 0.03 added STB_C_LEX_DISCARD_PREPROCESSOR option // refactor API to simplify (only one struct instead of two) // change literal enum names to have 'lit' at the end // 0.02 first public release // // Status: // - haven't tested compiling as C++ // - haven't tested the float parsing path // - haven't tested the non-default-config paths (e.g. non-stdlib) // - only tested default-config paths by eyeballing output of self-parse // // - haven't implemented multiline strings // - haven't implemented octal/hex character constants // - haven't implemented support for unicode CLEX_char // - need to expand error reporting so you don't just get "CLEX_parse_error" // // Contributors: // Arpad Goretity (bugfix) // Alan Hickman (hex floats) // // LICENSE // // See end of file for license information. #ifndef STB_C_LEXER_DEFINITIONS // to change the default parsing rules, copy the following lines // into your C/C++ file *before* including this, and then replace // the Y's with N's for the ones you don't want. // --BEGIN-- #define STB_C_LEX_C_DECIMAL_INTS Y // "0|[1-9][0-9]*" CLEX_intlit #define STB_C_LEX_C_HEX_INTS Y // "0x[0-9a-fA-F]+" CLEX_intlit #define STB_C_LEX_C_OCTAL_INTS Y // "[0-7]+" CLEX_intlit #define STB_C_LEX_C_DECIMAL_FLOATS Y // "[0-9]*(.[0-9]*([eE][-+]?[0-9]+)?) CLEX_floatlit #define STB_C_LEX_C99_HEX_FLOATS N // "0x{hex}+(.{hex}*)?[pP][-+]?{hex}+ CLEX_floatlit #define STB_C_LEX_C_IDENTIFIERS Y // "[_a-zA-Z][_a-zA-Z0-9]*" CLEX_id #define STB_C_LEX_C_DQ_STRINGS Y // double-quote-delimited strings with escapes CLEX_dqstring #define STB_C_LEX_C_SQ_STRINGS N // single-quote-delimited strings with escapes CLEX_ssstring #define STB_C_LEX_C_CHARS Y // single-quote-delimited character with escape CLEX_charlits #define STB_C_LEX_C_COMMENTS Y // "/* comment */" #define STB_C_LEX_CPP_COMMENTS Y // "// comment to end of line\n" #define STB_C_LEX_C_COMPARISONS Y // "==" CLEX_eq "!=" CLEX_noteq "<=" CLEX_lesseq ">=" CLEX_greatereq #define STB_C_LEX_C_LOGICAL Y // "&&" CLEX_andand "||" CLEX_oror #define STB_C_LEX_C_SHIFTS Y // "<<" CLEX_shl ">>" CLEX_shr #define STB_C_LEX_C_INCREMENTS Y // "++" CLEX_plusplus "--" CLEX_minusminus #define STB_C_LEX_C_ARROW Y // "->" CLEX_arrow #define STB_C_LEX_EQUAL_ARROW N // "=>" CLEX_eqarrow #define STB_C_LEX_C_BITWISEEQ Y // "&=" CLEX_andeq "|=" CLEX_oreq "^=" CLEX_xoreq #define STB_C_LEX_C_ARITHEQ Y // "+=" CLEX_pluseq "-=" CLEX_minuseq // "*=" CLEX_muleq "/=" CLEX_diveq "%=" CLEX_modeq // if both STB_C_LEX_SHIFTS & STB_C_LEX_ARITHEQ: // "<<=" CLEX_shleq ">>=" CLEX_shreq #define STB_C_LEX_PARSE_SUFFIXES N // letters after numbers are parsed as part of those numbers, and must be in suffix list below #define STB_C_LEX_DECIMAL_SUFFIXES "" // decimal integer suffixes e.g. "uUlL" -- these are returned as-is in string storage #define STB_C_LEX_HEX_SUFFIXES "" // e.g. "uUlL" #define STB_C_LEX_OCTAL_SUFFIXES "" // e.g. "uUlL" #define STB_C_LEX_FLOAT_SUFFIXES "" // #define STB_C_LEX_0_IS_EOF N // if Y, ends parsing at '\0'; if N, returns '\0' as token #define STB_C_LEX_INTEGERS_AS_DOUBLES N // parses integers as doubles so they can be larger than 'int', but only if STB_C_LEX_STDLIB==N #define STB_C_LEX_MULTILINE_DSTRINGS N // allow newlines in double-quoted strings #define STB_C_LEX_MULTILINE_SSTRINGS N // allow newlines in single-quoted strings #define STB_C_LEX_USE_STDLIB Y // use strtod,strtol for parsing #s; otherwise inaccurate hack #define STB_C_LEX_DOLLAR_IDENTIFIER Y // allow $ as an identifier character #define STB_C_LEX_FLOAT_NO_DECIMAL Y // allow floats that have no decimal point if they have an exponent #define STB_C_LEX_DEFINE_ALL_TOKEN_NAMES N // if Y, all CLEX_ token names are defined, even if never returned // leaving it as N should help you catch config bugs #define STB_C_LEX_DISCARD_PREPROCESSOR Y // discard C-preprocessor directives (e.g. after prepocess // still have #line, #pragma, etc) //#define STB_C_LEX_ISWHITE(str) ... // return length in bytes of whitespace characters if first char is whitespace #define STB_C_LEXER_DEFINITIONS // This line prevents the header file from replacing your definitions // --END-- #endif #ifndef INCLUDE_STB_C_LEXER_H #define INCLUDE_STB_C_LEXER_H typedef struct { // lexer variables char *input_stream; char *eof; char *parse_point; char *string_storage; int string_storage_len; // lexer parse location for error messages char *where_firstchar; char *where_lastchar; // lexer token variables long token; double real_number; long int_number; char *string; int string_len; } stb_lexer; typedef struct { int line_number; int line_offset; } stb_lex_location; #ifdef __cplusplus extern "C" { #endif extern void stb_c_lexer_init(stb_lexer *lexer, const char *input_stream, const char *input_stream_end, char *string_store, int store_length); // this function initialize the 'lexer' structure // Input: // - input_stream points to the file to parse, loaded into memory // - input_stream_end points to the end of the file, or NULL if you use 0-for-EOF // - string_store is storage the lexer can use for storing parsed strings and identifiers // - store_length is the length of that storage extern int stb_c_lexer_get_token(stb_lexer *lexer); // this function returns non-zero if a token is parsed, or 0 if at EOF // Output: // - lexer->token is the token ID, which is unicode code point for a single-char token, < 0 for a multichar or eof or error // - lexer->real_number is a double constant value for CLEX_floatlit, or CLEX_intlit if STB_C_LEX_INTEGERS_AS_DOUBLES // - lexer->int_number is an integer constant for CLEX_intlit if !STB_C_LEX_INTEGERS_AS_DOUBLES, or character for CLEX_charlit // - lexer->string is a 0-terminated string for CLEX_dqstring or CLEX_sqstring or CLEX_identifier // - lexer->string_len is the byte length of lexer->string extern void stb_c_lexer_get_location(const stb_lexer *lexer, const char *where, stb_lex_location *loc); // this inefficient function returns the line number and character offset of a // given location in the file as returned by stb_lex_token. Because it's inefficient, // you should only call it for errors, not for every token. // For error messages of invalid tokens, you typically want the location of the start // of the token (which caused the token to be invalid). For bugs involving legit // tokens, you can report the first or the range. // Output: // - loc->line_number is the line number in the file, counting from 1, of the location // - loc->line_offset is the char-offset in the line, counting from 0, of the location #ifdef __cplusplus } #endif #endif // INCLUDE_STB_C_LEXER_H #ifdef STB_C_LEXER_IMPLEMENTATION #if defined(Y) || defined(N) #error "Can only use stb_c_lexer in contexts where the preprocessor symbols 'Y' and 'N' are not defined" #endif // Hacky definitions so we can easily #if on them #define Y(x) 1 #define N(x) 0 #if STB_C_LEX_INTEGERS_AS_DOUBLES(x) typedef double stb__clex_int; #define intfield real_number #define STB__clex_int_as_double #else typedef long stb__clex_int; #define intfield int_number #endif // Convert these config options to simple conditional #defines so we can more // easily test them once we've change the meaning of Y/N #if STB_C_LEX_PARSE_SUFFIXES(x) #define STB__clex_parse_suffixes #endif #if STB_C_LEX_C_DECIMAL_INTS(x) || STB_C_LEX_C_HEX_INTS(x) || STB_C_LEX_DEFINE_ALL_TOKEN_NAMES(x) #define STB__clex_define_int #endif #if (STB_C_LEX_C_ARITHEQ(x) && STB_C_LEX_C_SHIFTS(x)) || STB_C_LEX_DEFINE_ALL_TOKEN_NAMES(x) #define STB__clex_define_shifts #endif #if STB_C_LEX_C99_HEX_FLOATS(x) #define STB__clex_hex_floats #endif #if STB_C_LEX_C_HEX_INTS(x) #define STB__clex_hex_ints #endif #if STB_C_LEX_C_DECIMAL_INTS(x) #define STB__clex_decimal_ints #endif #if STB_C_LEX_C_OCTAL_INTS(x) #define STB__clex_octal_ints #endif #if STB_C_LEX_C_DECIMAL_FLOATS(x) #define STB__clex_decimal_floats #endif #if STB_C_LEX_DISCARD_PREPROCESSOR(x) #define STB__clex_discard_preprocessor #endif #if STB_C_LEX_USE_STDLIB(x) && (!defined(STB__clex_hex_floats) || __STDC_VERSION__ >= 199901L) #define STB__CLEX_use_stdlib #include #endif // Now pick a definition of Y/N that's conducive to // defining the enum of token names. #if STB_C_LEX_DEFINE_ALL_TOKEN_NAMES(x) || defined(STB_C_LEXER_SELF_TEST) #undef N #define N(a) Y(a) #else #undef N #define N(a) #endif #undef Y #define Y(a) a, enum { CLEX_eof = 256, CLEX_parse_error, #ifdef STB__clex_define_int CLEX_intlit, #endif STB_C_LEX_C_DECIMAL_FLOATS( CLEX_floatlit ) STB_C_LEX_C_IDENTIFIERS( CLEX_id ) STB_C_LEX_C_DQ_STRINGS( CLEX_dqstring ) STB_C_LEX_C_SQ_STRINGS( CLEX_sqstring ) STB_C_LEX_C_CHARS( CLEX_charlit ) STB_C_LEX_C_COMPARISONS( CLEX_eq ) STB_C_LEX_C_COMPARISONS( CLEX_noteq ) STB_C_LEX_C_COMPARISONS( CLEX_lesseq ) STB_C_LEX_C_COMPARISONS( CLEX_greatereq ) STB_C_LEX_C_LOGICAL( CLEX_andand ) STB_C_LEX_C_LOGICAL( CLEX_oror ) STB_C_LEX_C_SHIFTS( CLEX_shl ) STB_C_LEX_C_SHIFTS( CLEX_shr ) STB_C_LEX_C_INCREMENTS( CLEX_plusplus ) STB_C_LEX_C_INCREMENTS( CLEX_minusminus ) STB_C_LEX_C_ARITHEQ( CLEX_pluseq ) STB_C_LEX_C_ARITHEQ( CLEX_minuseq ) STB_C_LEX_C_ARITHEQ( CLEX_muleq ) STB_C_LEX_C_ARITHEQ( CLEX_diveq ) STB_C_LEX_C_ARITHEQ( CLEX_modeq ) STB_C_LEX_C_BITWISEEQ( CLEX_andeq ) STB_C_LEX_C_BITWISEEQ( CLEX_oreq ) STB_C_LEX_C_BITWISEEQ( CLEX_xoreq ) STB_C_LEX_C_ARROW( CLEX_arrow ) STB_C_LEX_EQUAL_ARROW( CLEX_eqarrow ) #ifdef STB__clex_define_shifts CLEX_shleq, CLEX_shreq, #endif CLEX_first_unused_token #undef Y #define Y(a) a }; // Now for the rest of the file we'll use the basic definition where // where Y expands to its contents and N expands to nothing #undef N #define N(a) // API function void stb_c_lexer_init(stb_lexer *lexer, const char *input_stream, const char *input_stream_end, char *string_store, int store_length) { lexer->input_stream = (char *) input_stream; lexer->eof = (char *) input_stream_end; lexer->parse_point = (char *) input_stream; lexer->string_storage = string_store; lexer->string_storage_len = store_length; } // API function void stb_c_lexer_get_location(const stb_lexer *lexer, const char *where, stb_lex_location *loc) { char *p = lexer->input_stream; int line_number = 1; int char_offset = 0; while (*p && p < where) { if (*p == '\n' || *p == '\r') { p += (p[0]+p[1] == '\r'+'\n' ? 2 : 1); // skip newline line_number += 1; char_offset = 0; } else { ++p; ++char_offset; } } loc->line_number = line_number; loc->line_offset = char_offset; } // main helper function for returning a parsed token static int stb__clex_token(stb_lexer *lexer, int token, char *start, char *end) { lexer->token = token; lexer->where_firstchar = start; lexer->where_lastchar = end; lexer->parse_point = end+1; return 1; } // helper function for returning eof static int stb__clex_eof(stb_lexer *lexer) { lexer->token = CLEX_eof; return 0; } static int stb__clex_iswhite(int x) { return x == ' ' || x == '\t' || x == '\r' || x == '\n' || x == '\f'; } static const char *stb__strchr(const char *str, int ch) { for (; *str; ++str) if (*str == ch) return str; return 0; } // parse suffixes at the end of a number static int stb__clex_parse_suffixes(stb_lexer *lexer, long tokenid, char *start, char *cur, const char *suffixes) { #ifdef STB__clex_parse_suffixes lexer->string = lexer->string_storage; lexer->string_len = 0; while ((*cur >= 'a' && *cur <= 'z') || (*cur >= 'A' && *cur <= 'Z')) { if (stb__strchr(suffixes, *cur) == 0) return stb__clex_token(lexer, CLEX_parse_error, start, cur); if (lexer->string_len+1 >= lexer->string_storage_len) return stb__clex_token(lexer, CLEX_parse_error, start, cur); lexer->string[lexer->string_len++] = *cur++; } #else suffixes = suffixes; // attempt to suppress warnings #endif return stb__clex_token(lexer, tokenid, start, cur-1); } #ifndef STB__CLEX_use_stdlib static double stb__clex_pow(double base, unsigned int exponent) { double value=1; for ( ; exponent; exponent >>= 1) { if (exponent & 1) value *= base; base *= base; } return value; } static double stb__clex_parse_float(char *p, char **q) { char *s = p; double value=0; int base=10; int exponent=0; #ifdef STB__clex_hex_floats if (*p == '0') { if (p[1] == 'x' || p[1] == 'X') { base=16; p += 2; } } #endif for (;;) { if (*p >= '0' && *p <= '9') value = value*base + (*p++ - '0'); #ifdef STB__clex_hex_floats else if (base == 16 && *p >= 'a' && *p <= 'f') value = value*base + 10 + (*p++ - 'a'); else if (base == 16 && *p >= 'A' && *p <= 'F') value = value*base + 10 + (*p++ - 'A'); #endif else break; } if (*p == '.') { double pow, addend = 0; ++p; for (pow=1; ; pow*=base) { if (*p >= '0' && *p <= '9') addend = addend*base + (*p++ - '0'); #ifdef STB__clex_hex_floats else if (base == 16 && *p >= 'a' && *p <= 'f') addend = addend*base + 10 + (*p++ - 'a'); else if (base == 16 && *p >= 'A' && *p <= 'F') addend = addend*base + 10 + (*p++ - 'A'); #endif else break; } value += addend / pow; } #ifdef STB__clex_hex_floats if (base == 16) { // exponent required for hex float literal if (*p != 'p' && *p != 'P') { *q = s; return 0; } exponent = 1; } else #endif exponent = (*p == 'e' || *p == 'E'); if (exponent) { int sign = p[1] == '-'; unsigned int exponent=0; double power=1; ++p; if (*p == '-' || *p == '+') ++p; while (*p >= '0' && *p <= '9') exponent = exponent*10 + (*p++ - '0'); #ifdef STB__clex_hex_floats if (base == 16) power = stb__clex_pow(2, exponent); else #endif power = stb__clex_pow(10, exponent); if (sign) value /= power; else value *= power; } *q = p; return value; } #endif static int stb__clex_parse_char(char *p, char **q) { if (*p == '\\') { *q = p+2; // tentatively guess we'll parse two characters switch(p[1]) { case '\\': return '\\'; case '\'': return '\''; case '"': return '"'; case 't': return '\t'; case 'f': return '\f'; case 'n': return '\n'; case 'r': return '\r'; case '0': return '\0'; // @TODO ocatal constants case 'x': case 'X': return -1; // @TODO hex constants case 'u': return -1; // @TODO unicode constants } } *q = p+1; return (unsigned char) *p; } static int stb__clex_parse_string(stb_lexer *lexer, char *p, int type) { char *start = p; char delim = *p++; // grab the " or ' for later matching char *out = lexer->string_storage; char *outend = lexer->string_storage + lexer->string_storage_len; while (*p != delim) { int n; if (*p == '\\') { char *q; n = stb__clex_parse_char(p, &q); if (n < 0) return stb__clex_token(lexer, CLEX_parse_error, start, q); p = q; } else { // @OPTIMIZE: could speed this up by looping-while-not-backslash n = (unsigned char) *p++; } if (out+1 > outend) return stb__clex_token(lexer, CLEX_parse_error, start, p); // @TODO expand unicode escapes to UTF8 *out++ = (char) n; } *out = 0; lexer->string = lexer->string_storage; lexer->string_len = out - lexer->string_storage; return stb__clex_token(lexer, type, start, p); } int stb_c_lexer_get_token(stb_lexer *lexer) { char *p = lexer->parse_point; // skip whitespace and comments for (;;) { #ifdef STB_C_LEX_ISWHITE while (p != lexer->stream_end) { int n; n = STB_C_LEX_ISWHITE(p); if (n == 0) break; if (lexer->eof && lexer->eof - lexer->parse_point < n) return stb__clex_token(tok, CLEX_parse_error, p,lexer->eof-1); p += n; } #else while (p != lexer->eof && stb__clex_iswhite(*p)) ++p; #endif STB_C_LEX_CPP_COMMENTS( if (p != lexer->eof && p[0] == '/' && p[1] == '/') { while (p != lexer->eof && *p != '\r' && *p != '\n') ++p; continue; } ) STB_C_LEX_C_COMMENTS( if (p != lexer->eof && p[0] == '/' && p[1] == '*') { char *start = p; p += 2; while (p != lexer->eof && (p[0] != '*' || p[1] != '/')) ++p; if (p == lexer->eof) return stb__clex_token(lexer, CLEX_parse_error, start, p-1); p += 2; continue; } ) #ifdef STB__clex_discard_preprocessor // @TODO this discards everything after a '#', regardless // of where in the line the # is, rather than requiring it // be at the start. (because this parser doesn't otherwise // check for line breaks!) if (p != lexer->eof && p[0] == '#') { while (p != lexer->eof && *p != '\r' && *p != '\n') ++p; continue; } #endif break; } if (p == lexer->eof) return stb__clex_eof(lexer); switch (*p) { default: if ( (*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || *p == '_' || (unsigned char) *p >= 128 // >= 128 is UTF8 char STB_C_LEX_DOLLAR_IDENTIFIER( || *p == '$' ) ) { int n = 0; lexer->string = lexer->string_storage; lexer->string_len = n; do { if (n+1 >= lexer->string_storage_len) return stb__clex_token(lexer, CLEX_parse_error, p, p+n); lexer->string[n] = p[n]; ++n; } while ( (p[n] >= 'a' && p[n] <= 'z') || (p[n] >= 'A' && p[n] <= 'Z') || (p[n] >= '0' && p[n] <= '9') // allow digits in middle of identifier || p[n] == '_' || (unsigned char) p[n] >= 128 STB_C_LEX_DOLLAR_IDENTIFIER( || p[n] == '$' ) ); lexer->string[n] = 0; return stb__clex_token(lexer, CLEX_id, p, p+n-1); } // check for EOF STB_C_LEX_0_IS_EOF( if (*p == 0) return stb__clex_eof(tok); ) single_char: // not an identifier, return the character as itself return stb__clex_token(lexer, *p, p, p); case '+': if (p+1 != lexer->eof) { STB_C_LEX_C_INCREMENTS(if (p[1] == '+') return stb__clex_token(lexer, CLEX_plusplus, p,p+1);) STB_C_LEX_C_ARITHEQ( if (p[1] == '=') return stb__clex_token(lexer, CLEX_pluseq , p,p+1);) } goto single_char; case '-': if (p+1 != lexer->eof) { STB_C_LEX_C_INCREMENTS(if (p[1] == '-') return stb__clex_token(lexer, CLEX_minusminus, p,p+1);) STB_C_LEX_C_ARITHEQ( if (p[1] == '=') return stb__clex_token(lexer, CLEX_minuseq , p,p+1);) STB_C_LEX_C_ARROW( if (p[1] == '>') return stb__clex_token(lexer, CLEX_arrow , p,p+1);) } goto single_char; case '&': if (p+1 != lexer->eof) { STB_C_LEX_C_LOGICAL( if (p[1] == '&') return stb__clex_token(lexer, CLEX_andand, p,p+1);) STB_C_LEX_C_BITWISEEQ(if (p[1] == '=') return stb__clex_token(lexer, CLEX_andeq , p,p+1);) } goto single_char; case '|': if (p+1 != lexer->eof) { STB_C_LEX_C_LOGICAL( if (p[1] == '|') return stb__clex_token(lexer, CLEX_oror, p,p+1);) STB_C_LEX_C_BITWISEEQ(if (p[1] == '=') return stb__clex_token(lexer, CLEX_oreq, p,p+1);) } goto single_char; case '=': if (p+1 != lexer->eof) { STB_C_LEX_C_COMPARISONS(if (p[1] == '=') return stb__clex_token(lexer, CLEX_eq, p,p+1);) STB_C_LEX_EQUAL_ARROW( if (p[1] == '>') return stb__clex_token(lexer, CLEX_eqarrow, p,p+1);) } goto single_char; case '!': STB_C_LEX_C_COMPARISONS(if (p+1 != lexer->eof && p[1] == '=') return stb__clex_token(lexer, CLEX_noteq, p,p+1);) goto single_char; case '^': STB_C_LEX_C_BITWISEEQ(if (p+1 != lexer->eof && p[1] == '=') return stb__clex_token(lexer, CLEX_xoreq, p,p+1)); goto single_char; case '%': STB_C_LEX_C_ARITHEQ(if (p+1 != lexer->eof && p[1] == '=') return stb__clex_token(lexer, CLEX_modeq, p,p+1)); goto single_char; case '*': STB_C_LEX_C_ARITHEQ(if (p+1 != lexer->eof && p[1] == '=') return stb__clex_token(lexer, CLEX_muleq, p,p+1)); goto single_char; case '/': STB_C_LEX_C_ARITHEQ(if (p+1 != lexer->eof && p[1] == '=') return stb__clex_token(lexer, CLEX_diveq, p,p+1)); goto single_char; case '<': if (p+1 != lexer->eof) { STB_C_LEX_C_COMPARISONS(if (p[1] == '=') return stb__clex_token(lexer, CLEX_lesseq, p,p+1);) STB_C_LEX_C_SHIFTS( if (p[1] == '<') { STB_C_LEX_C_ARITHEQ(if (p+2 != lexer->eof && p[2] == '=') return stb__clex_token(lexer, CLEX_shleq, p,p+2);) return stb__clex_token(lexer, CLEX_shl, p,p+1); } ) } goto single_char; case '>': if (p+1 != lexer->eof) { STB_C_LEX_C_COMPARISONS(if (p[1] == '=') return stb__clex_token(lexer, CLEX_greatereq, p,p+1);) STB_C_LEX_C_SHIFTS( if (p[1] == '>') { STB_C_LEX_C_ARITHEQ(if (p+2 != lexer->eof && p[2] == '=') return stb__clex_token(lexer, CLEX_shreq, p,p+2);) return stb__clex_token(lexer, CLEX_shr, p,p+1); } ) } goto single_char; case '"': STB_C_LEX_C_DQ_STRINGS(return stb__clex_parse_string(lexer, p, CLEX_dqstring);) goto single_char; case '\'': STB_C_LEX_C_SQ_STRINGS(return stb__clex_parse_string(lexer, p, CLEX_sqstring);) STB_C_LEX_C_CHARS( { char *start = p; lexer->int_number = stb__clex_parse_char(p+1, &p); if (lexer->int_number < 0) return stb__clex_token(lexer, CLEX_parse_error, start,start); if (p == lexer->eof || *p != '\'') return stb__clex_token(lexer, CLEX_parse_error, start,p); return stb__clex_token(lexer, CLEX_charlit, start, p+1); }) goto single_char; case '0': #if defined(STB__clex_hex_ints) || defined(STB__clex_hex_floats) if (p+1 != lexer->eof) { if (p[1] == 'x' || p[1] == 'X') { char *q; #ifdef STB__clex_hex_floats for (q=p+2; q != lexer->eof && ((*q >= '0' && *q <= '9') || (*q >= 'a' && *q <= 'f') || (*q >= 'A' && *q <= 'F')); ++q); if (q != lexer->eof) { if (*q == '.' STB_C_LEX_FLOAT_NO_DECIMAL(|| *q == 'p' || *q == 'P')) { #ifdef STB__CLEX_use_stdlib lexer->real_number = strtod((char *) p, (char**) &q); #else lexer->real_number = stb__clex_parse_float(p, &q); #endif if (p == q) return stb__clex_token(lexer, CLEX_parse_error, p,q); return stb__clex_parse_suffixes(lexer, CLEX_floatlit, p,q, STB_C_LEX_FLOAT_SUFFIXES); } } #endif // STB__CLEX_hex_floats #ifdef STB__clex_hex_ints #ifdef STB__CLEX_use_stdlib lexer->int_number = strtol((char *) p, (char **) &q, 16); #else { stb__clex_int n=0; for (q=p+2; q != lexer->eof; ++q) { if (*q >= '0' && *q <= '9') n = n*16 + (*q - '0'); else if (*q >= 'a' && *q <= 'f') n = n*16 + (*q - 'a') + 10; else if (*q >= 'A' && *q <= 'F') n = n*16 + (*q - 'A') + 10; else break; } lexer->int_number = n; } #endif if (q == p+2) return stb__clex_token(lexer, CLEX_parse_error, p-2,p-1); return stb__clex_parse_suffixes(lexer, CLEX_intlit, p,q, STB_C_LEX_HEX_SUFFIXES); #endif } } #endif // defined(STB__clex_hex_ints) || defined(STB__clex_hex_floats) // can't test for octal because we might parse '0.0' as float or as '0' '.' '0', // so have to do float first /* FALL THROUGH */ case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': #ifdef STB__clex_decimal_floats { char *q = p; while (q != lexer->eof && (*q >= '0' && *q <= '9')) ++q; if (q != lexer->eof) { if (*q == '.' STB_C_LEX_FLOAT_NO_DECIMAL(|| *q == 'e' || *q == 'E')) { #ifdef STB__CLEX_use_stdlib lexer->real_number = strtod((char *) p, (char**) &q); #else lexer->real_number = stb__clex_parse_float(p, &q); #endif return stb__clex_parse_suffixes(lexer, CLEX_floatlit, p,q, STB_C_LEX_FLOAT_SUFFIXES); } } } #endif // STB__clex_decimal_floats #ifdef STB__clex_octal_ints if (p[0] == '0') { char *q = p; #ifdef STB__CLEX_use_stdlib lexer->int_number = strtol((char *) p, (char **) &q, 8); #else stb__clex_int n=0; while (q != lexer->eof) { if (*q >= '0' && *q <= '7') n = n*8 + (*q - '0'); else break; ++q; } if (q != lexer->eof && (*q == '8' || *q=='9')) return stb__clex_token(lexer, CLEX_parse_error, p, q); lexer->int_number = n; #endif return stb__clex_parse_suffixes(lexer, CLEX_intlit, p,q, STB_C_LEX_OCTAL_SUFFIXES); } #endif // STB__clex_octal_ints #ifdef STB__clex_decimal_ints { char *q = p; #ifdef STB__CLEX_use_stdlib lexer->int_number = strtol((char *) p, (char **) &q, 10); #else stb__clex_int n=0; while (q != lexer->eof) { if (*q >= '0' && *q <= '9') n = n*10 + (*q - '0'); else break; ++q; } lexer->int_number = n; #endif return stb__clex_parse_suffixes(lexer, CLEX_intlit, p,q, STB_C_LEX_OCTAL_SUFFIXES); } #endif // STB__clex_decimal_ints goto single_char; } } #endif // STB_C_LEXER_IMPLEMENTATION #ifdef STB_C_LEXER_SELF_TEST #include #include static void print_token(stb_lexer *lexer) { switch (lexer->token) { case CLEX_id : printf("_%s", lexer->string); break; case CLEX_eq : printf("=="); break; case CLEX_noteq : printf("!="); break; case CLEX_lesseq : printf("<="); break; case CLEX_greatereq : printf(">="); break; case CLEX_andand : printf("&&"); break; case CLEX_oror : printf("||"); break; case CLEX_shl : printf("<<"); break; case CLEX_shr : printf(">>"); break; case CLEX_plusplus : printf("++"); break; case CLEX_minusminus: printf("--"); break; case CLEX_arrow : printf("->"); break; case CLEX_andeq : printf("&="); break; case CLEX_oreq : printf("|="); break; case CLEX_xoreq : printf("^="); break; case CLEX_pluseq : printf("+="); break; case CLEX_minuseq : printf("-="); break; case CLEX_muleq : printf("*="); break; case CLEX_diveq : printf("/="); break; case CLEX_modeq : printf("%%="); break; case CLEX_shleq : printf("<<="); break; case CLEX_shreq : printf(">>="); break; case CLEX_eqarrow : printf("=>"); break; case CLEX_dqstring : printf("\"%s\"", lexer->string); break; case CLEX_sqstring : printf("'\"%s\"'", lexer->string); break; case CLEX_charlit : printf("'%s'", lexer->string); break; #if defined(STB__clex_int_as_double) && !defined(STB__CLEX_use_stdlib) case CLEX_intlit : printf("#%g", lexer->real_number); break; #else case CLEX_intlit : printf("#%ld", lexer->int_number); break; #endif case CLEX_floatlit : printf("%g", lexer->real_number); break; default: if (lexer->token >= 0 && lexer->token < 256) printf("%c", (int) lexer->token); else { printf("<<>>\n", lexer->token); } break; } } /* Force a test of parsing multiline comments */ /*/ comment /*/ /**/ extern /**/ void dummy(void) { double some_floats[] = { 1.0501, -10.4e12, 5E+10, #if 0 // not support in C++ or C-pre-99, so don't try to compile it 0x1.0p+24, 0xff.FP-8, 0x1p-23, #endif 4. }; printf("test %d",1); // https://github.com/nothings/stb/issues/13 } int main(int argc, char **argv) { FILE *f = fopen("stb_c_lexer.h","rb"); char *text = (char *) malloc(1 << 20); int len = f ? fread(text, 1, 1<<20, f) : -1; stb_lexer lex; if (len < 0) { fprintf(stderr, "Error opening file\n"); free(text); fclose(f); return 1; } fclose(f); stb_c_lexer_init(&lex, text, text+len, (char *) malloc(0x10000), 0x10000); while (stb_c_lexer_get_token(&lex)) { if (lex.token == CLEX_parse_error) { printf("\n<<>>\n"); break; } print_token(&lex); printf(" "); } return 0; } #endif /* ------------------------------------------------------------------------------ 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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/stb.h0000600000175000001440000160033114003056224015353 0ustar rakusers/* stb.h - v2.30 - Sean's Tool Box -- public domain -- http://nothings.org/stb.h no warranty is offered or implied; use this code at your own risk This is a single header file with a bunch of useful utilities for getting stuff done in C/C++. Documentation: http://nothings.org/stb/stb_h.html Unit tests: http://nothings.org/stb/stb.c ============================================================================ You MUST #define STB_DEFINE in EXACTLY _one_ C or C++ file that includes this header, BEFORE the include, like this: #define STB_DEFINE #include "stb.h" All other files should just #include "stb.h" without the #define. ============================================================================ Version History 2.30 MinGW fix 2.29 attempt to fix use of swprintf() 2.28 various new functionality 2.27 test _WIN32 not WIN32 in STB_THREADS 2.26 various warning & bugfixes 2.25 various warning & bugfixes 2.24 various warning & bugfixes 2.23 fix 2.22 2.22 64-bit fixes from '!='; fix stb_sdict_copy() to have preferred name 2.21 utf-8 decoder rejects "overlong" encodings; attempted 64-bit improvements 2.20 fix to hash "copy" function--reported by someone with handle "!=" 2.19 ??? 2.18 stb_readdir_subdirs_mask 2.17 stb_cfg_dir 2.16 fix stb_bgio_, add stb_bgio_stat(); begin a streaming wrapper 2.15 upgraded hash table template to allow: - aggregate keys (explicit comparison func for EMPTY and DEL keys) - "static" implementations (so they can be culled if unused) 2.14 stb_mprintf 2.13 reduce identifiable strings in STB_NO_STB_STRINGS 2.12 fix STB_ONLY -- lots of uint32s, TRUE/FALSE things had crept in 2.11 fix bug in stb_dirtree_get() which caused "c://path" sorts of stuff 2.10 STB_F(), STB_I() inline constants (also KI,KU,KF,KD) 2.09 stb_box_face_vertex_axis_side 2.08 bugfix stb_trimwhite() 2.07 colored printing in windows (why are we in 1985?) 2.06 comparison functions are now functions-that-return-functions and accept a struct-offset as a parameter (not thread-safe) 2.05 compile and pass tests under Linux (but no threads); thread cleanup 2.04 stb_cubic_bezier_1d, smoothstep, avoid dependency on registry 2.03 ? 2.02 remove integrated documentation 2.01 integrate various fixes; stb_force_uniprocessor 2.00 revised stb_dupe to use multiple hashes 1.99 stb_charcmp 1.98 stb_arr_deleten, stb_arr_insertn 1.97 fix stb_newell_normal() 1.96 stb_hash_number() 1.95 hack stb__rec_max; clean up recursion code to use new functions 1.94 stb_dirtree; rename stb_extra to stb_ptrmap 1.93 stb_sem_new() API cleanup (no blockflag-starts blocked; use 'extra') 1.92 stb_threadqueue--multi reader/writer queue, fixed size or resizeable 1.91 stb_bgio_* for reading disk asynchronously 1.90 stb_mutex uses CRITICAL_REGION; new stb_sync primitive for thread joining; workqueue supports stb_sync instead of stb_semaphore 1.89 support ';' in constant-string wildcards; stb_mutex wrapper (can implement with EnterCriticalRegion eventually) 1.88 portable threading API (only for win32 so far); worker thread queue 1.87 fix wildcard handling in stb_readdir_recursive 1.86 support ';' in wildcards 1.85 make stb_regex work with non-constant strings; beginnings of stb_introspect() 1.84 (forgot to make notes) 1.83 whoops, stb_keep_if_different wasn't deleting the temp file 1.82 bring back stb_compress from stb_file.h for cmirror 1.81 various bugfixes, STB_FASTMALLOC_INIT inits FASTMALLOC in release 1.80 stb_readdir returns utf8; write own utf8-utf16 because lib was wrong 1.79 stb_write 1.78 calloc() support for malloc wrapper, STB_FASTMALLOC 1.77 STB_FASTMALLOC 1.76 STB_STUA - Lua-like language; (stb_image, stb_csample, stb_bilinear) 1.75 alloc/free array of blocks; stb_hheap bug; a few stb_ps_ funcs; hash*getkey, hash*copy; stb_bitset; stb_strnicmp; bugfix stb_bst 1.74 stb_replaceinplace; use stdlib C function to convert utf8 to UTF-16 1.73 fix performance bug & leak in stb_ischar (C++ port lost a 'static') 1.72 remove stb_block, stb_block_manager, stb_decompress (to stb_file.h) 1.71 stb_trimwhite, stb_tokens_nested, etc. 1.70 back out 1.69 because it might problemize mixed builds; stb_filec() 1.69 (stb_file returns 'char *' in C++) 1.68 add a special 'tree root' data type for stb_bst; stb_arr_end 1.67 full C++ port. (stb_block_manager) 1.66 stb_newell_normal 1.65 stb_lex_item_wild -- allow wildcard items which MUST match entirely 1.64 stb_data 1.63 stb_log_name 1.62 stb_define_sort; C++ cleanup 1.61 stb_hash_fast -- Paul Hsieh's hash function (beats Bob Jenkins'?) 1.60 stb_delete_directory_recursive 1.59 stb_readdir_recursive 1.58 stb_bst variant with parent pointer for O(1) iteration, not O(log N) 1.57 replace LCG random with Mersenne Twister (found a public domain one) 1.56 stb_perfect_hash, stb_ischar, stb_regex 1.55 new stb_bst API allows multiple BSTs per node (e.g. secondary keys) 1.54 bugfix: stb_define_hash, stb_wildmatch, regexp 1.53 stb_define_hash; recoded stb_extra, stb_sdict use it 1.52 stb_rand_define, stb_bst, stb_reverse 1.51 fix 'stb_arr_setlen(NULL, 0)' 1.50 stb_wordwrap 1.49 minor improvements to enable the scripting language 1.48 better approach for stb_arr using stb_malloc; more invasive, clearer 1.47 stb_lex (lexes stb.h at 1.5ML/s on 3Ghz P4; 60/70% of optimal/flex) 1.46 stb_wrapper_*, STB_MALLOC_WRAPPER 1.45 lightly tested DFA acceleration of regexp searching 1.44 wildcard matching & searching; regexp matching & searching 1.43 stb_temp 1.42 allow stb_arr to use stb_malloc/realloc; note this is global 1.41 make it compile in C++; (disable stb_arr in C++) 1.40 stb_dupe tweak; stb_swap; stb_substr 1.39 stb_dupe; improve stb_file_max to be less stupid 1.38 stb_sha1_file: generate sha1 for file, even > 4GB 1.37 stb_file_max; partial support for utf8 filenames in Windows 1.36 remove STB__NO_PREFIX - poor interaction with IDE, not worth it streamline stb_arr to make it separately publishable 1.35 bugfixes for stb_sdict, stb_malloc(0), stristr 1.34 (streaming interfaces for stb_compress) 1.33 stb_alloc; bug in stb_getopt; remove stb_overflow 1.32 (stb_compress returns, smaller&faster; encode window & 64-bit len) 1.31 stb_prefix_count 1.30 (STB__NO_PREFIX - remove stb_ prefixes for personal projects) 1.29 stb_fput_varlen64, etc. 1.28 stb_sha1 1.27 ? 1.26 stb_extra 1.25 ? 1.24 stb_copyfile 1.23 stb_readdir 1.22 ? 1.21 ? 1.20 ? 1.19 ? 1.18 ? 1.17 ? 1.16 ? 1.15 stb_fixpath, stb_splitpath, stb_strchr2 1.14 stb_arr 1.13 ?stb, stb_log, stb_fatal 1.12 ?stb_hash2 1.11 miniML 1.10 stb_crc32, stb_adler32 1.09 stb_sdict 1.08 stb_bitreverse, stb_ispow2, stb_big32 stb_fopen, stb_fput_varlen, stb_fput_ranged stb_fcmp, stb_feq 1.07 (stb_encompress) 1.06 stb_compress 1.05 stb_tokens, (stb_hheap) 1.04 stb_rand 1.03 ?(s-strings) 1.02 ?stb_filelen, stb_tokens 1.01 stb_tolower 1.00 stb_hash, stb_intcmp stb_file, stb_stringfile, stb_fgets stb_prefix, stb_strlower, stb_strtok stb_image (stb_array), (stb_arena) Parenthesized items have since been removed. LICENSE See end of file for license information. CREDITS Written by Sean Barrett. Fixes: Philipp Wiesemann Robert Nix r-lyeh blackpawn github:Mojofreem Ryan Whitworth Vincent Isambart Mike Sartain Eugene Opalev Tim Sjostrand github:infatum */ #include #ifndef STB__INCLUDE_STB_H #define STB__INCLUDE_STB_H #define STB_VERSION 1 #ifdef STB_INTROSPECT #define STB_DEFINE #endif #ifdef STB_DEFINE_THREADS #ifndef STB_DEFINE #define STB_DEFINE #endif #ifndef STB_THREADS #define STB_THREADS #endif #endif #if defined(_WIN32) && !defined(__MINGW32__) #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif #ifndef _CRT_NONSTDC_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE #endif #ifndef _CRT_NON_CONFORMING_SWPRINTFS #define _CRT_NON_CONFORMING_SWPRINTFS #endif #if !defined(_MSC_VER) || _MSC_VER > 1700 #include // _BitScanReverse #endif #endif #include // stdlib could have min/max #include // need FILE #include // stb_define_hash needs memcpy/memset #include // stb_dirtree #ifdef __MINGW32__ #include // O_RDWR #endif #ifdef STB_PERSONAL typedef int Bool; #define False 0 #define True 1 #endif #ifdef STB_MALLOC_WRAPPER_PAGED #define STB_MALLOC_WRAPPER_DEBUG #endif #ifdef STB_MALLOC_WRAPPER_DEBUG #define STB_MALLOC_WRAPPER #endif #ifdef STB_MALLOC_WRAPPER_FASTMALLOC #define STB_FASTMALLOC #define STB_MALLOC_WRAPPER #endif #ifdef STB_FASTMALLOC #ifndef _WIN32 #undef STB_FASTMALLOC #endif #endif #ifdef STB_DEFINE #include #include #include #include #include #ifndef _WIN32 #include #else #include // _mktemp #include // _rmdir #endif #include // stat()/_stat() #include // stat()/_stat() #endif #define stb_min(a,b) ((a) < (b) ? (a) : (b)) #define stb_max(a,b) ((a) > (b) ? (a) : (b)) #ifndef STB_ONLY #if !defined(__cplusplus) && !defined(min) && !defined(max) #define min(x,y) stb_min(x,y) #define max(x,y) stb_max(x,y) #endif #ifndef M_PI #define M_PI 3.14159265358979323846f #endif #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #ifndef deg2rad #define deg2rad(a) ((a)*(M_PI/180)) #endif #ifndef rad2deg #define rad2deg(a) ((a)*(180/M_PI)) #endif #ifndef swap #ifndef __cplusplus #define swap(TYPE,a,b) \ do { TYPE stb__t; stb__t = (a); (a) = (b); (b) = stb__t; } while (0) #endif #endif typedef unsigned char uint8 ; typedef signed char int8 ; typedef unsigned short uint16; typedef signed short int16; #if defined(STB_USE_LONG_FOR_32_BIT_INT) || defined(STB_LONG32) typedef unsigned long uint32; typedef signed long int32; #else typedef unsigned int uint32; typedef signed int int32; #endif typedef unsigned char uchar ; typedef unsigned short ushort; typedef unsigned int uint ; typedef unsigned long ulong ; // produce compile errors if the sizes aren't right typedef char stb__testsize16[sizeof(int16)==2]; typedef char stb__testsize32[sizeof(int32)==4]; #endif #ifndef STB_TRUE #define STB_TRUE 1 #define STB_FALSE 0 #endif // if we're STB_ONLY, can't rely on uint32 or even uint, so all the // variables we'll use herein need typenames prefixed with 'stb': typedef unsigned char stb_uchar; typedef unsigned char stb_uint8; typedef unsigned int stb_uint; typedef unsigned short stb_uint16; typedef short stb_int16; typedef signed char stb_int8; #if defined(STB_USE_LONG_FOR_32_BIT_INT) || defined(STB_LONG32) typedef unsigned long stb_uint32; typedef long stb_int32; #else typedef unsigned int stb_uint32; typedef int stb_int32; #endif typedef char stb__testsize2_16[sizeof(stb_uint16)==2 ? 1 : -1]; typedef char stb__testsize2_32[sizeof(stb_uint32)==4 ? 1 : -1]; #ifdef _MSC_VER typedef unsigned __int64 stb_uint64; typedef __int64 stb_int64; #define STB_IMM_UINT64(literalui64) (literalui64##ui64) #define STB_IMM_INT64(literali64) (literali64##i64) #else // ?? typedef unsigned long long stb_uint64; typedef long long stb_int64; #define STB_IMM_UINT64(literalui64) (literalui64##ULL) #define STB_IMM_INT64(literali64) (literali64##LL) #endif typedef char stb__testsize2_64[sizeof(stb_uint64)==8 ? 1 : -1]; // add platform-specific ways of checking for sizeof(char*) == 8, // and make those define STB_PTR64 #if defined(_WIN64) || defined(__x86_64__) || defined(__ia64__) || defined(__LP64__) #define STB_PTR64 #endif #ifdef STB_PTR64 typedef char stb__testsize2_ptr[sizeof(char *) == 8]; typedef stb_uint64 stb_uinta; typedef stb_int64 stb_inta; #else typedef char stb__testsize2_ptr[sizeof(char *) == 4]; typedef stb_uint32 stb_uinta; typedef stb_int32 stb_inta; #endif typedef char stb__testsize2_uinta[sizeof(stb_uinta)==sizeof(char*) ? 1 : -1]; // if so, we should define an int type that is the pointer size. until then, // we'll have to make do with this (which is not the same at all!) typedef union { unsigned int i; void * p; } stb_uintptr; #ifdef __cplusplus #define STB_EXTERN extern "C" #else #define STB_EXTERN extern #endif // check for well-known debug defines #if defined(DEBUG) || defined(_DEBUG) || defined(DBG) #ifndef NDEBUG #define STB_DEBUG #endif #endif #ifdef STB_DEBUG #include #endif STB_EXTERN void stb_wrapper_malloc(void *newp, int sz, char *file, int line); STB_EXTERN void stb_wrapper_free(void *oldp, char *file, int line); STB_EXTERN void stb_wrapper_realloc(void *oldp, void *newp, int sz, char *file, int line); STB_EXTERN void stb_wrapper_calloc(size_t num, size_t sz, char *file, int line); STB_EXTERN void stb_wrapper_listall(void (*func)(void *ptr, int sz, char *file, int line)); STB_EXTERN void stb_wrapper_dump(char *filename); STB_EXTERN int stb_wrapper_allocsize(void *oldp); STB_EXTERN void stb_wrapper_check(void *oldp); #ifdef STB_DEFINE // this is a special function used inside malloc wrapper // to do allocations that aren't tracked (to avoid // reentrancy). Of course if someone _else_ wraps realloc, // this breaks, but if they're doing that AND the malloc // wrapper they need to explicitly check for reentrancy. // // only define realloc_raw() and we do realloc(NULL,sz) // for malloc() and realloc(p,0) for free(). static void * stb__realloc_raw(void *p, int sz) { if (p == NULL) return malloc(sz); if (sz == 0) { free(p); return NULL; } return realloc(p,sz); } #endif #ifdef _WIN32 STB_EXTERN void * stb_smalloc(size_t sz); STB_EXTERN void stb_sfree(void *p); STB_EXTERN void * stb_srealloc(void *p, size_t sz); STB_EXTERN void * stb_scalloc(size_t n, size_t sz); STB_EXTERN char * stb_sstrdup(char *s); #endif #ifdef STB_FASTMALLOC #define malloc stb_smalloc #define free stb_sfree #define realloc stb_srealloc #define strdup stb_sstrdup #define calloc stb_scalloc #endif #ifndef STB_MALLOC_ALLCHECK #define stb__check(p) 1 #else #ifndef STB_MALLOC_WRAPPER #error STB_MALLOC_ALLCHECK requires STB_MALLOC_WRAPPER #else #define stb__check(p) stb_mcheck(p) #endif #endif #ifdef STB_MALLOC_WRAPPER STB_EXTERN void * stb__malloc(int, char *, int); STB_EXTERN void * stb__realloc(void *, int, char *, int); STB_EXTERN void * stb__calloc(size_t n, size_t s, char *, int); STB_EXTERN void stb__free(void *, char *file, int); STB_EXTERN char * stb__strdup(char *s, char *file, int); STB_EXTERN void stb_malloc_checkall(void); STB_EXTERN void stb_malloc_check_counter(int init_delay, int rep_delay); #ifndef STB_MALLOC_WRAPPER_DEBUG #define stb_mcheck(p) 1 #else STB_EXTERN int stb_mcheck(void *); #endif #ifdef STB_DEFINE #ifdef STB_MALLOC_WRAPPER_DEBUG #define STB__PAD 32 #define STB__BIAS 16 #define STB__SIG 0x51b01234 #define STB__FIXSIZE(sz) (((sz+3) & ~3) + STB__PAD) #define STB__ptr(x,y) ((char *) (x) + (y)) #else #define STB__ptr(x,y) (x) #define STB__FIXSIZE(sz) (sz) #endif #ifdef STB_MALLOC_WRAPPER_DEBUG int stb_mcheck(void *p) { unsigned int sz; if (p == NULL) return 1; p = ((char *) p) - STB__BIAS; sz = * (unsigned int *) p; assert(* (unsigned int *) STB__ptr(p,4) == STB__SIG); assert(* (unsigned int *) STB__ptr(p,8) == STB__SIG); assert(* (unsigned int *) STB__ptr(p,12) == STB__SIG); assert(* (unsigned int *) STB__ptr(p,sz-4) == STB__SIG+1); assert(* (unsigned int *) STB__ptr(p,sz-8) == STB__SIG+1); assert(* (unsigned int *) STB__ptr(p,sz-12) == STB__SIG+1); assert(* (unsigned int *) STB__ptr(p,sz-16) == STB__SIG+1); stb_wrapper_check(STB__ptr(p, STB__BIAS)); return 1; } static void stb__check2(void *p, int sz, char *file, int line) { stb_mcheck(p); } void stb_malloc_checkall(void) { stb_wrapper_listall(stb__check2); } #else void stb_malloc_checkall(void) { } #endif static int stb__malloc_wait=(1 << 30), stb__malloc_next_wait = (1 << 30), stb__malloc_iter; void stb_malloc_check_counter(int init_delay, int rep_delay) { stb__malloc_wait = init_delay; stb__malloc_next_wait = rep_delay; } void stb_mcheck_all(void) { #ifdef STB_MALLOC_WRAPPER_DEBUG ++stb__malloc_iter; if (--stb__malloc_wait <= 0) { stb_malloc_checkall(); stb__malloc_wait = stb__malloc_next_wait; } #endif } #ifdef STB_MALLOC_WRAPPER_PAGED #define STB__WINDOWS_PAGE (1 << 12) #ifndef _WINDOWS_ STB_EXTERN __declspec(dllimport) void * __stdcall VirtualAlloc(void *p, unsigned long size, unsigned long type, unsigned long protect); STB_EXTERN __declspec(dllimport) int __stdcall VirtualFree(void *p, unsigned long size, unsigned long freetype); #endif #endif static void *stb__malloc_final(int sz) { #ifdef STB_MALLOC_WRAPPER_PAGED int aligned = (sz + STB__WINDOWS_PAGE - 1) & ~(STB__WINDOWS_PAGE-1); char *p = VirtualAlloc(NULL, aligned + STB__WINDOWS_PAGE, 0x2000, 0x04); // RESERVE, READWRITE if (p == NULL) return p; VirtualAlloc(p, aligned, 0x1000, 0x04); // COMMIT, READWRITE return p; #else return malloc(sz); #endif } static void stb__free_final(void *p) { #ifdef STB_MALLOC_WRAPPER_PAGED VirtualFree(p, 0, 0x8000); // RELEASE #else free(p); #endif } int stb__malloc_failure; static void *stb__realloc_final(void *p, int sz, int old_sz) { #ifdef STB_MALLOC_WRAPPER_PAGED void *q = stb__malloc_final(sz); if (q == NULL) return ++stb__malloc_failure, q; // @TODO: deal with p being smaller! memcpy(q, p, sz < old_sz ? sz : old_sz); stb__free_final(p); return q; #else return realloc(p,sz); #endif } void stb__free(void *p, char *file, int line) { stb_mcheck_all(); if (!p) return; #ifdef STB_MALLOC_WRAPPER_DEBUG stb_mcheck(p); #endif stb_wrapper_free(p,file,line); #ifdef STB_MALLOC_WRAPPER_DEBUG p = STB__ptr(p,-STB__BIAS); * (unsigned int *) STB__ptr(p,0) = 0xdeadbeef; * (unsigned int *) STB__ptr(p,4) = 0xdeadbeef; * (unsigned int *) STB__ptr(p,8) = 0xdeadbeef; * (unsigned int *) STB__ptr(p,12) = 0xdeadbeef; #endif stb__free_final(p); } void * stb__malloc(int sz, char *file, int line) { void *p; stb_mcheck_all(); if (sz == 0) return NULL; p = stb__malloc_final(STB__FIXSIZE(sz)); if (p == NULL) p = stb__malloc_final(STB__FIXSIZE(sz)); if (p == NULL) p = stb__malloc_final(STB__FIXSIZE(sz)); if (p == NULL) { ++stb__malloc_failure; #ifdef STB_MALLOC_WRAPPER_DEBUG stb_malloc_checkall(); #endif return p; } #ifdef STB_MALLOC_WRAPPER_DEBUG * (int *) STB__ptr(p,0) = STB__FIXSIZE(sz); * (unsigned int *) STB__ptr(p,4) = STB__SIG; * (unsigned int *) STB__ptr(p,8) = STB__SIG; * (unsigned int *) STB__ptr(p,12) = STB__SIG; * (unsigned int *) STB__ptr(p,STB__FIXSIZE(sz)-4) = STB__SIG+1; * (unsigned int *) STB__ptr(p,STB__FIXSIZE(sz)-8) = STB__SIG+1; * (unsigned int *) STB__ptr(p,STB__FIXSIZE(sz)-12) = STB__SIG+1; * (unsigned int *) STB__ptr(p,STB__FIXSIZE(sz)-16) = STB__SIG+1; p = STB__ptr(p, STB__BIAS); #endif stb_wrapper_malloc(p,sz,file,line); return p; } void * stb__realloc(void *p, int sz, char *file, int line) { void *q; stb_mcheck_all(); if (p == NULL) return stb__malloc(sz,file,line); if (sz == 0 ) { stb__free(p,file,line); return NULL; } #ifdef STB_MALLOC_WRAPPER_DEBUG stb_mcheck(p); p = STB__ptr(p,-STB__BIAS); #endif #ifdef STB_MALLOC_WRAPPER_PAGED { int n = stb_wrapper_allocsize(STB__ptr(p,STB__BIAS)); if (!n) stb_wrapper_check(STB__ptr(p,STB__BIAS)); q = stb__realloc_final(p, STB__FIXSIZE(sz), STB__FIXSIZE(n)); } #else q = realloc(p, STB__FIXSIZE(sz)); #endif if (q == NULL) return ++stb__malloc_failure, q; #ifdef STB_MALLOC_WRAPPER_DEBUG * (int *) STB__ptr(q,0) = STB__FIXSIZE(sz); * (unsigned int *) STB__ptr(q,4) = STB__SIG; * (unsigned int *) STB__ptr(q,8) = STB__SIG; * (unsigned int *) STB__ptr(q,12) = STB__SIG; * (unsigned int *) STB__ptr(q,STB__FIXSIZE(sz)-4) = STB__SIG+1; * (unsigned int *) STB__ptr(q,STB__FIXSIZE(sz)-8) = STB__SIG+1; * (unsigned int *) STB__ptr(q,STB__FIXSIZE(sz)-12) = STB__SIG+1; * (unsigned int *) STB__ptr(q,STB__FIXSIZE(sz)-16) = STB__SIG+1; q = STB__ptr(q, STB__BIAS); p = STB__ptr(p, STB__BIAS); #endif stb_wrapper_realloc(p,q,sz,file,line); return q; } STB_EXTERN int stb_log2_ceil(unsigned int); static void *stb__calloc(size_t n, size_t sz, char *file, int line) { void *q; stb_mcheck_all(); if (n == 0 || sz == 0) return NULL; if (stb_log2_ceil(n) + stb_log2_ceil(sz) >= 32) return NULL; q = stb__malloc(n*sz, file, line); if (q) memset(q, 0, n*sz); return q; } char * stb__strdup(char *s, char *file, int line) { char *p; stb_mcheck_all(); p = stb__malloc(strlen(s)+1, file, line); if (!p) return p; strcpy(p, s); return p; } #endif // STB_DEFINE #ifdef STB_FASTMALLOC #undef malloc #undef realloc #undef free #undef strdup #undef calloc #endif // include everything that might define these, BEFORE making macros #include #include #include #define malloc(s) stb__malloc ( s, __FILE__, __LINE__) #define realloc(p,s) stb__realloc(p,s, __FILE__, __LINE__) #define calloc(n,s) stb__calloc (n,s, __FILE__, __LINE__) #define free(p) stb__free (p, __FILE__, __LINE__) #define strdup(p) stb__strdup (p, __FILE__, __LINE__) #endif ////////////////////////////////////////////////////////////////////////////// // // Windows pretty display // STB_EXTERN void stbprint(const char *fmt, ...); STB_EXTERN char *stb_sprintf(const char *fmt, ...); STB_EXTERN char *stb_mprintf(const char *fmt, ...); STB_EXTERN int stb_snprintf(char *s, size_t n, const char *fmt, ...); STB_EXTERN int stb_vsnprintf(char *s, size_t n, const char *fmt, va_list v); #ifdef STB_DEFINE int stb_vsnprintf(char *s, size_t n, const char *fmt, va_list v) { int res; #ifdef _WIN32 // Could use "_vsnprintf_s(s, n, _TRUNCATE, fmt, v)" ? res = _vsnprintf(s,n,fmt,v); #else res = vsnprintf(s,n,fmt,v); #endif if (n) s[n-1] = 0; // Unix returns length output would require, Windows returns negative when truncated. return (res >= (int) n || res < 0) ? -1 : res; } int stb_snprintf(char *s, size_t n, const char *fmt, ...) { int res; va_list v; va_start(v,fmt); res = stb_vsnprintf(s, n, fmt, v); va_end(v); return res; } char *stb_sprintf(const char *fmt, ...) { static char buffer[1024]; va_list v; va_start(v,fmt); stb_vsnprintf(buffer,1024,fmt,v); va_end(v); return buffer; } char *stb_mprintf(const char *fmt, ...) { static char buffer[1024]; va_list v; va_start(v,fmt); stb_vsnprintf(buffer,1024,fmt,v); va_end(v); return strdup(buffer); } #ifdef _WIN32 #ifndef _WINDOWS_ STB_EXTERN __declspec(dllimport) int __stdcall WriteConsoleA(void *, const void *, unsigned int, unsigned int *, void *); STB_EXTERN __declspec(dllimport) void * __stdcall GetStdHandle(unsigned int); STB_EXTERN __declspec(dllimport) int __stdcall SetConsoleTextAttribute(void *, unsigned short); #endif static void stb__print_one(void *handle, char *s, int len) { if (len) if (WriteConsoleA(handle, s, len, NULL,NULL)) fwrite(s, 1, len, stdout); // if it fails, maybe redirected, so do normal } static void stb__print(char *s) { void *handle = GetStdHandle((unsigned int) -11); // STD_OUTPUT_HANDLE int pad=0; // number of padding characters to add char *t = s; while (*s) { int lpad; while (*s && *s != '{') { if (pad) { if (*s == '\r' || *s == '\n') pad = 0; else if (s[0] == ' ' && s[1] == ' ') { stb__print_one(handle, t, s-t); t = s; while (pad) { stb__print_one(handle, t, 1); --pad; } } } ++s; } if (!*s) break; stb__print_one(handle, t, s-t); if (s[1] == '{') { ++s; continue; } if (s[1] == '#') { t = s+3; if (isxdigit(s[2])) if (isdigit(s[2])) SetConsoleTextAttribute(handle, s[2] - '0'); else SetConsoleTextAttribute(handle, tolower(s[2]) - 'a' + 10); else { SetConsoleTextAttribute(handle, 0x0f); t=s+2; } } else if (s[1] == '!') { SetConsoleTextAttribute(handle, 0x0c); t = s+2; } else if (s[1] == '@') { SetConsoleTextAttribute(handle, 0x09); t = s+2; } else if (s[1] == '$') { SetConsoleTextAttribute(handle, 0x0a); t = s+2; } else { SetConsoleTextAttribute(handle, 0x08); // 0,7,8,15 => shades of grey t = s+1; } lpad = (t-s); s = t; while (*s && *s != '}') ++s; if (!*s) break; stb__print_one(handle, t, s-t); if (s[1] == '}') { t = s+2; } else { pad += 1+lpad; t = s+1; } s=t; SetConsoleTextAttribute(handle, 0x07); } stb__print_one(handle, t, s-t); SetConsoleTextAttribute(handle, 0x07); } void stbprint(const char *fmt, ...) { int res; char buffer[1024]; char *tbuf = buffer; va_list v; va_start(v,fmt); res = stb_vsnprintf(buffer, sizeof(buffer), fmt, v); va_end(v); if (res < 0) { tbuf = (char *) malloc(16384); va_start(v,fmt); res = _vsnprintf(tbuf,16384, fmt, v); va_end(v); tbuf[16383] = 0; } stb__print(tbuf); if (tbuf != buffer) free(tbuf); } #else // _WIN32 void stbprint(const char *fmt, ...) { va_list v; va_start(v,fmt); vprintf(fmt,v); va_end(v); } #endif // _WIN32 #endif // STB_DEFINE ////////////////////////////////////////////////////////////////////////////// // // Windows UTF8 filename handling // // Windows stupidly treats 8-bit filenames as some dopey code page, // rather than utf-8. If we want to use utf8 filenames, we have to // convert them to WCHAR explicitly and call WCHAR versions of the // file functions. So, ok, we do. #ifdef _WIN32 #define stb__fopen(x,y) _wfopen((const wchar_t *)stb__from_utf8(x), (const wchar_t *)stb__from_utf8_alt(y)) #define stb__windows(x,y) x #else #define stb__fopen(x,y) fopen(x,y) #define stb__windows(x,y) y #endif typedef unsigned short stb__wchar; STB_EXTERN stb__wchar * stb_from_utf8(stb__wchar *buffer, char *str, int n); STB_EXTERN char * stb_to_utf8 (char *buffer, stb__wchar *str, int n); STB_EXTERN stb__wchar *stb__from_utf8(char *str); STB_EXTERN stb__wchar *stb__from_utf8_alt(char *str); STB_EXTERN char *stb__to_utf8(stb__wchar *str); #ifdef STB_DEFINE stb__wchar * stb_from_utf8(stb__wchar *buffer, char *ostr, int n) { unsigned char *str = (unsigned char *) ostr; stb_uint32 c; int i=0; --n; while (*str) { if (i >= n) return NULL; if (!(*str & 0x80)) buffer[i++] = *str++; else if ((*str & 0xe0) == 0xc0) { if (*str < 0xc2) return NULL; c = (*str++ & 0x1f) << 6; if ((*str & 0xc0) != 0x80) return NULL; buffer[i++] = c + (*str++ & 0x3f); } else if ((*str & 0xf0) == 0xe0) { if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return NULL; if (*str == 0xed && str[1] > 0x9f) return NULL; // str[1] < 0x80 is checked below c = (*str++ & 0x0f) << 12; if ((*str & 0xc0) != 0x80) return NULL; c += (*str++ & 0x3f) << 6; if ((*str & 0xc0) != 0x80) return NULL; buffer[i++] = c + (*str++ & 0x3f); } else if ((*str & 0xf8) == 0xf0) { if (*str > 0xf4) return NULL; if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return NULL; if (*str == 0xf4 && str[1] > 0x8f) return NULL; // str[1] < 0x80 is checked below c = (*str++ & 0x07) << 18; if ((*str & 0xc0) != 0x80) return NULL; c += (*str++ & 0x3f) << 12; if ((*str & 0xc0) != 0x80) return NULL; c += (*str++ & 0x3f) << 6; if ((*str & 0xc0) != 0x80) return NULL; c += (*str++ & 0x3f); // utf-8 encodings of values used in surrogate pairs are invalid if ((c & 0xFFFFF800) == 0xD800) return NULL; if (c >= 0x10000) { c -= 0x10000; if (i + 2 > n) return NULL; buffer[i++] = 0xD800 | (0x3ff & (c >> 10)); buffer[i++] = 0xDC00 | (0x3ff & (c )); } } else return NULL; } buffer[i] = 0; return buffer; } char * stb_to_utf8(char *buffer, stb__wchar *str, int n) { int i=0; --n; while (*str) { if (*str < 0x80) { if (i+1 > n) return NULL; buffer[i++] = (char) *str++; } else if (*str < 0x800) { if (i+2 > n) return NULL; buffer[i++] = 0xc0 + (*str >> 6); buffer[i++] = 0x80 + (*str & 0x3f); str += 1; } else if (*str >= 0xd800 && *str < 0xdc00) { stb_uint32 c; if (i+4 > n) return NULL; c = ((str[0] - 0xd800) << 10) + ((str[1]) - 0xdc00) + 0x10000; buffer[i++] = 0xf0 + (c >> 18); buffer[i++] = 0x80 + ((c >> 12) & 0x3f); buffer[i++] = 0x80 + ((c >> 6) & 0x3f); buffer[i++] = 0x80 + ((c ) & 0x3f); str += 2; } else if (*str >= 0xdc00 && *str < 0xe000) { return NULL; } else { if (i+3 > n) return NULL; buffer[i++] = 0xe0 + (*str >> 12); buffer[i++] = 0x80 + ((*str >> 6) & 0x3f); buffer[i++] = 0x80 + ((*str ) & 0x3f); str += 1; } } buffer[i] = 0; return buffer; } stb__wchar *stb__from_utf8(char *str) { static stb__wchar buffer[4096]; return stb_from_utf8(buffer, str, 4096); } stb__wchar *stb__from_utf8_alt(char *str) { static stb__wchar buffer[64]; return stb_from_utf8(buffer, str, 64); } char *stb__to_utf8(stb__wchar *str) { static char buffer[4096]; return stb_to_utf8(buffer, str, 4096); } #endif ////////////////////////////////////////////////////////////////////////////// // // Miscellany // STB_EXTERN void stb_fatal(char *fmt, ...); STB_EXTERN void stb_(char *fmt, ...); STB_EXTERN void stb_append_to_file(char *file, char *fmt, ...); STB_EXTERN void stb_log(int active); STB_EXTERN void stb_log_fileline(int active); STB_EXTERN void stb_log_name(char *filename); STB_EXTERN void stb_swap(void *p, void *q, size_t sz); STB_EXTERN void *stb_copy(void *p, size_t sz); STB_EXTERN void stb_pointer_array_free(void *p, int len); STB_EXTERN void **stb_array_block_alloc(int count, int blocksize); #define stb_arrcount(x) (sizeof(x)/sizeof((x)[0])) STB_EXTERN int stb__record_fileline(char *f, int n); #ifdef STB_DEFINE static char *stb__file; static int stb__line; int stb__record_fileline(char *f, int n) { stb__file = f; stb__line = n; return 0; } void stb_fatal(char *s, ...) { va_list a; if (stb__file) fprintf(stderr, "[%s:%d] ", stb__file, stb__line); va_start(a,s); fputs("Fatal error: ", stderr); vfprintf(stderr, s, a); va_end(a); fputs("\n", stderr); #ifdef STB_DEBUG #ifdef _MSC_VER #ifndef STB_PTR64 __asm int 3; // trap to debugger! #else __debugbreak(); #endif #else __builtin_trap(); #endif #endif exit(1); } static int stb__log_active=1, stb__log_fileline=1; void stb_log(int active) { stb__log_active = active; } void stb_log_fileline(int active) { stb__log_fileline = active; } #ifdef STB_NO_STB_STRINGS char *stb__log_filename = "temp.log"; #else char *stb__log_filename = "stb.log"; #endif void stb_log_name(char *s) { stb__log_filename = s; } void stb_(char *s, ...) { if (stb__log_active) { FILE *f = fopen(stb__log_filename, "a"); if (f) { va_list a; if (stb__log_fileline && stb__file) fprintf(f, "[%s:%4d] ", stb__file, stb__line); va_start(a,s); vfprintf(f, s, a); va_end(a); fputs("\n", f); fclose(f); } } } void stb_append_to_file(char *filename, char *s, ...) { FILE *f = fopen(filename, "a"); if (f) { va_list a; va_start(a,s); vfprintf(f, s, a); va_end(a); fputs("\n", f); fclose(f); } } typedef struct { char d[4]; } stb__4; typedef struct { char d[8]; } stb__8; // optimize the small cases, though you shouldn't be calling this for those! void stb_swap(void *p, void *q, size_t sz) { char buffer[256]; if (p == q) return; if (sz == 4) { stb__4 temp = * ( stb__4 *) p; * (stb__4 *) p = * ( stb__4 *) q; * (stb__4 *) q = temp; return; } else if (sz == 8) { stb__8 temp = * ( stb__8 *) p; * (stb__8 *) p = * ( stb__8 *) q; * (stb__8 *) q = temp; return; } while (sz > sizeof(buffer)) { stb_swap(p, q, sizeof(buffer)); p = (char *) p + sizeof(buffer); q = (char *) q + sizeof(buffer); sz -= sizeof(buffer); } memcpy(buffer, p , sz); memcpy(p , q , sz); memcpy(q , buffer, sz); } void *stb_copy(void *p, size_t sz) { void *q = malloc(sz); memcpy(q, p, sz); return q; } void stb_pointer_array_free(void *q, int len) { void **p = (void **) q; int i; for (i=0; i < len; ++i) free(p[i]); } void **stb_array_block_alloc(int count, int blocksize) { int i; char *p = (char *) malloc(sizeof(void *) * count + count * blocksize); void **q; if (p == NULL) return NULL; q = (void **) p; p += sizeof(void *) * count; for (i=0; i < count; ++i) q[i] = p + i * blocksize; return q; } #endif #ifdef STB_DEBUG // tricky hack to allow recording FILE,LINE even in varargs functions #define STB__RECORD_FILE(x) (stb__record_fileline(__FILE__, __LINE__),(x)) #define stb_log STB__RECORD_FILE(stb_log) #define stb_ STB__RECORD_FILE(stb_) #ifndef STB_FATAL_CLEAN #define stb_fatal STB__RECORD_FILE(stb_fatal) #endif #define STB__DEBUG(x) x #else #define STB__DEBUG(x) #endif ////////////////////////////////////////////////////////////////////////////// // // stb_temp // #define stb_temp(block, sz) stb__temp(block, sizeof(block), (sz)) STB_EXTERN void * stb__temp(void *b, int b_sz, int want_sz); STB_EXTERN void stb_tempfree(void *block, void *ptr); #ifdef STB_DEFINE void * stb__temp(void *b, int b_sz, int want_sz) { if (b_sz >= want_sz) return b; else return malloc(want_sz); } void stb_tempfree(void *b, void *p) { if (p != b) free(p); } #endif ////////////////////////////////////////////////////////////////////////////// // // math/sampling operations // #define stb_lerp(t,a,b) ( (a) + (t) * (float) ((b)-(a)) ) #define stb_unlerp(t,a,b) ( ((t) - (a)) / (float) ((b) - (a)) ) #define stb_clamp(x,xmin,xmax) ((x) < (xmin) ? (xmin) : (x) > (xmax) ? (xmax) : (x)) STB_EXTERN void stb_newell_normal(float *normal, int num_vert, float **vert, int normalize); STB_EXTERN int stb_box_face_vertex_axis_side(int face_number, int vertex_number, int axis); STB_EXTERN void stb_linear_controller(float *curpos, float target_pos, float acc, float deacc, float dt); STB_EXTERN int stb_float_eq(float x, float y, float delta, int max_ulps); STB_EXTERN int stb_is_prime(unsigned int m); STB_EXTERN unsigned int stb_power_of_two_nearest_prime(int n); STB_EXTERN float stb_smoothstep(float t); STB_EXTERN float stb_cubic_bezier_1d(float t, float p0, float p1, float p2, float p3); STB_EXTERN double stb_linear_remap(double x, double a, double b, double c, double d); #ifdef STB_DEFINE float stb_smoothstep(float t) { return (3 - 2*t)*(t*t); } float stb_cubic_bezier_1d(float t, float p0, float p1, float p2, float p3) { float it = 1-t; return it*it*it*p0 + 3*it*it*t*p1 + 3*it*t*t*p2 + t*t*t*p3; } void stb_newell_normal(float *normal, int num_vert, float **vert, int normalize) { int i,j; float p; normal[0] = normal[1] = normal[2] = 0; for (i=num_vert-1,j=0; j < num_vert; i=j++) { float *u = vert[i]; float *v = vert[j]; normal[0] += (u[1] - v[1]) * (u[2] + v[2]); normal[1] += (u[2] - v[2]) * (u[0] + v[0]); normal[2] += (u[0] - v[0]) * (u[1] + v[1]); } if (normalize) { p = normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal[2]; p = (float) (1.0 / sqrt(p)); normal[0] *= p; normal[1] *= p; normal[2] *= p; } } int stb_box_face_vertex_axis_side(int face_number, int vertex_number, int axis) { static int box_vertices[6][4][3] = { { { 1,1,1 }, { 1,0,1 }, { 1,0,0 }, { 1,1,0 } }, { { 0,0,0 }, { 0,0,1 }, { 0,1,1 }, { 0,1,0 } }, { { 0,0,0 }, { 0,1,0 }, { 1,1,0 }, { 1,0,0 } }, { { 0,0,0 }, { 1,0,0 }, { 1,0,1 }, { 0,0,1 } }, { { 1,1,1 }, { 0,1,1 }, { 0,0,1 }, { 1,0,1 } }, { { 1,1,1 }, { 1,1,0 }, { 0,1,0 }, { 0,1,1 } }, }; assert(face_number >= 0 && face_number < 6); assert(vertex_number >= 0 && vertex_number < 4); assert(axis >= 0 && axis < 3); return box_vertices[face_number][vertex_number][axis]; } void stb_linear_controller(float *curpos, float target_pos, float acc, float deacc, float dt) { float sign = 1, p, cp = *curpos; if (cp == target_pos) return; if (target_pos < cp) { target_pos = -target_pos; cp = -cp; sign = -1; } // first decelerate if (cp < 0) { p = cp + deacc * dt; if (p > 0) { p = 0; dt = dt - cp / deacc; if (dt < 0) dt = 0; } else { dt = 0; } cp = p; } // now accelerate p = cp + acc*dt; if (p > target_pos) p = target_pos; *curpos = p * sign; // @TODO: testing } float stb_quadratic_controller(float target_pos, float curpos, float maxvel, float maxacc, float dt, float *curvel) { return 0; // @TODO } int stb_float_eq(float x, float y, float delta, int max_ulps) { if (fabs(x-y) <= delta) return 1; if (abs(*(int *)&x - *(int *)&y) <= max_ulps) return 1; return 0; } int stb_is_prime(unsigned int m) { unsigned int i,j; if (m < 2) return 0; if (m == 2) return 1; if (!(m & 1)) return 0; if (m % 3 == 0) return (m == 3); for (i=5; (j=i*i), j <= m && j > i; i += 6) { if (m % i == 0) return 0; if (m % (i+2) == 0) return 0; } return 1; } unsigned int stb_power_of_two_nearest_prime(int n) { static signed char tab[32] = { 0,0,0,0,1,0,-1,0,1,-1,-1,3,-1,0,-1,2,1, 0,2,0,-1,-4,-1,5,-1,18,-2,15,2,-1,2,0 }; if (!tab[0]) { int i; for (i=0; i < 32; ++i) tab[i] = (1 << i) + 2*tab[i] - 1; tab[1] = 2; tab[0] = 1; } if (n >= 32) return 0xfffffffb; return tab[n]; } double stb_linear_remap(double x, double x_min, double x_max, double out_min, double out_max) { return stb_lerp(stb_unlerp(x,x_min,x_max),out_min,out_max); } #endif // create a macro so it's faster, but you can get at the function pointer #define stb_linear_remap(t,a,b,c,d) stb_lerp(stb_unlerp(t,a,b),c,d) ////////////////////////////////////////////////////////////////////////////// // // bit operations // #define stb_big32(c) (((c)[0]<<24) + (c)[1]*65536 + (c)[2]*256 + (c)[3]) #define stb_little32(c) (((c)[3]<<24) + (c)[2]*65536 + (c)[1]*256 + (c)[0]) #define stb_big16(c) ((c)[0]*256 + (c)[1]) #define stb_little16(c) ((c)[1]*256 + (c)[0]) STB_EXTERN int stb_bitcount(unsigned int a); STB_EXTERN unsigned int stb_bitreverse8(unsigned char n); STB_EXTERN unsigned int stb_bitreverse(unsigned int n); STB_EXTERN int stb_is_pow2(unsigned int n); STB_EXTERN int stb_log2_ceil(unsigned int n); STB_EXTERN int stb_log2_floor(unsigned int n); STB_EXTERN int stb_lowbit8(unsigned int n); STB_EXTERN int stb_highbit8(unsigned int n); #ifdef STB_DEFINE int stb_bitcount(unsigned int a) { a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits a = (a + (a >> 8)); // max 16 per 8 bits a = (a + (a >> 16)); // max 32 per 8 bits return a & 0xff; } unsigned int stb_bitreverse8(unsigned char n) { n = ((n & 0xAA) >> 1) + ((n & 0x55) << 1); n = ((n & 0xCC) >> 2) + ((n & 0x33) << 2); return (unsigned char) ((n >> 4) + (n << 4)); } unsigned int stb_bitreverse(unsigned int n) { n = ((n & 0xAAAAAAAA) >> 1) | ((n & 0x55555555) << 1); n = ((n & 0xCCCCCCCC) >> 2) | ((n & 0x33333333) << 2); n = ((n & 0xF0F0F0F0) >> 4) | ((n & 0x0F0F0F0F) << 4); n = ((n & 0xFF00FF00) >> 8) | ((n & 0x00FF00FF) << 8); return (n >> 16) | (n << 16); } int stb_is_pow2(unsigned int n) { return (n & (n-1)) == 0; } // tricky use of 4-bit table to identify 5 bit positions (note the '-1') // 3-bit table would require another tree level; 5-bit table wouldn't save one #if defined(_WIN32) && !defined(__MINGW32__) #pragma warning(push) #pragma warning(disable: 4035) // disable warning about no return value int stb_log2_floor(unsigned int n) { #if _MSC_VER > 1700 unsigned long i; _BitScanReverse(&i, n); return i != 0 ? i : -1; #else __asm { bsr eax,n jnz done mov eax,-1 } done:; #endif } #pragma warning(pop) #else int stb_log2_floor(unsigned int n) { static signed char log2_4[16] = { -1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3 }; // 2 compares if n < 16, 3 compares otherwise if (n < (1U << 14)) if (n < (1U << 4)) return 0 + log2_4[n ]; else if (n < (1U << 9)) return 5 + log2_4[n >> 5]; else return 10 + log2_4[n >> 10]; else if (n < (1U << 24)) if (n < (1U << 19)) return 15 + log2_4[n >> 15]; else return 20 + log2_4[n >> 20]; else if (n < (1U << 29)) return 25 + log2_4[n >> 25]; else return 30 + log2_4[n >> 30]; } #endif // define ceil from floor int stb_log2_ceil(unsigned int n) { if (stb_is_pow2(n)) return stb_log2_floor(n); else return 1 + stb_log2_floor(n); } int stb_highbit8(unsigned int n) { return stb_log2_ceil(n&255); } int stb_lowbit8(unsigned int n) { static signed char lowbit4[16] = { -1,0,1,0, 2,0,1,0, 3,0,1,0, 2,0,1,0 }; int k = lowbit4[n & 15]; if (k >= 0) return k; k = lowbit4[(n >> 4) & 15]; if (k >= 0) return k+4; return k; } #endif ////////////////////////////////////////////////////////////////////////////// // // qsort Compare Routines // #ifdef _WIN32 #define stb_stricmp(a,b) stricmp(a,b) #define stb_strnicmp(a,b,n) strnicmp(a,b,n) #else #define stb_stricmp(a,b) strcasecmp(a,b) #define stb_strnicmp(a,b,n) strncasecmp(a,b,n) #endif STB_EXTERN int (*stb_intcmp(int offset))(const void *a, const void *b); STB_EXTERN int (*stb_qsort_strcmp(int offset))(const void *a, const void *b); STB_EXTERN int (*stb_qsort_stricmp(int offset))(const void *a, const void *b); STB_EXTERN int (*stb_floatcmp(int offset))(const void *a, const void *b); STB_EXTERN int (*stb_doublecmp(int offset))(const void *a, const void *b); STB_EXTERN int (*stb_charcmp(int offset))(const void *a, const void *b); #ifdef STB_DEFINE static int stb__intcmpoffset, stb__charcmpoffset, stb__strcmpoffset; static int stb__floatcmpoffset, stb__doublecmpoffset; int stb__intcmp(const void *a, const void *b) { const int p = *(const int *) ((const char *) a + stb__intcmpoffset); const int q = *(const int *) ((const char *) b + stb__intcmpoffset); return p < q ? -1 : p > q; } int stb__charcmp(const void *a, const void *b) { const int p = *(const unsigned char *) ((const char *) a + stb__charcmpoffset); const int q = *(const unsigned char *) ((const char *) b + stb__charcmpoffset); return p < q ? -1 : p > q; } int stb__floatcmp(const void *a, const void *b) { const float p = *(const float *) ((const char *) a + stb__floatcmpoffset); const float q = *(const float *) ((const char *) b + stb__floatcmpoffset); return p < q ? -1 : p > q; } int stb__doublecmp(const void *a, const void *b) { const double p = *(const double *) ((const char *) a + stb__doublecmpoffset); const double q = *(const double *) ((const char *) b + stb__doublecmpoffset); return p < q ? -1 : p > q; } int stb__qsort_strcmp(const void *a, const void *b) { const char *p = *(const char **) ((const char *) a + stb__strcmpoffset); const char *q = *(const char **) ((const char *) b + stb__strcmpoffset); return strcmp(p,q); } int stb__qsort_stricmp(const void *a, const void *b) { const char *p = *(const char **) ((const char *) a + stb__strcmpoffset); const char *q = *(const char **) ((const char *) b + stb__strcmpoffset); return stb_stricmp(p,q); } int (*stb_intcmp(int offset))(const void *, const void *) { stb__intcmpoffset = offset; return &stb__intcmp; } int (*stb_charcmp(int offset))(const void *, const void *) { stb__charcmpoffset = offset; return &stb__charcmp; } int (*stb_qsort_strcmp(int offset))(const void *, const void *) { stb__strcmpoffset = offset; return &stb__qsort_strcmp; } int (*stb_qsort_stricmp(int offset))(const void *, const void *) { stb__strcmpoffset = offset; return &stb__qsort_stricmp; } int (*stb_floatcmp(int offset))(const void *, const void *) { stb__floatcmpoffset = offset; return &stb__floatcmp; } int (*stb_doublecmp(int offset))(const void *, const void *) { stb__doublecmpoffset = offset; return &stb__doublecmp; } #endif ////////////////////////////////////////////////////////////////////////////// // // Binary Search Toolkit // typedef struct { int minval, maxval, guess; int mode, step; } stb_search; STB_EXTERN int stb_search_binary(stb_search *s, int minv, int maxv, int find_smallest); STB_EXTERN int stb_search_open(stb_search *s, int minv, int find_smallest); STB_EXTERN int stb_probe(stb_search *s, int compare, int *result); // return 0 when done #ifdef STB_DEFINE enum { STB_probe_binary_smallest, STB_probe_binary_largest, STB_probe_open_smallest, STB_probe_open_largest, }; static int stb_probe_guess(stb_search *s, int *result) { switch(s->mode) { case STB_probe_binary_largest: if (s->minval == s->maxval) { *result = s->minval; return 0; } assert(s->minval < s->maxval); // if a < b, then a < p <= b s->guess = s->minval + (((unsigned) s->maxval - s->minval + 1) >> 1); break; case STB_probe_binary_smallest: if (s->minval == s->maxval) { *result = s->minval; return 0; } assert(s->minval < s->maxval); // if a < b, then a <= p < b s->guess = s->minval + (((unsigned) s->maxval - s->minval) >> 1); break; case STB_probe_open_smallest: case STB_probe_open_largest: s->guess = s->maxval; // guess the current maxval break; } *result = s->guess; return 1; } int stb_probe(stb_search *s, int compare, int *result) { switch(s->mode) { case STB_probe_open_smallest: case STB_probe_open_largest: { if (compare <= 0) { // then it lies within minval & maxval if (s->mode == STB_probe_open_smallest) s->mode = STB_probe_binary_smallest; else s->mode = STB_probe_binary_largest; } else { // otherwise, we need to probe larger s->minval = s->maxval + 1; s->maxval = s->minval + s->step; s->step += s->step; } break; } case STB_probe_binary_smallest: { // if compare < 0, then s->minval <= a < p // if compare = 0, then s->minval <= a <= p // if compare > 0, then p < a <= s->maxval if (compare <= 0) s->maxval = s->guess; else s->minval = s->guess+1; break; } case STB_probe_binary_largest: { // if compare < 0, then s->minval <= a < p // if compare = 0, then p <= a <= s->maxval // if compare > 0, then p < a <= s->maxval if (compare < 0) s->maxval = s->guess-1; else s->minval = s->guess; break; } } return stb_probe_guess(s, result); } int stb_search_binary(stb_search *s, int minv, int maxv, int find_smallest) { int r; if (maxv < minv) return minv-1; s->minval = minv; s->maxval = maxv; s->mode = find_smallest ? STB_probe_binary_smallest : STB_probe_binary_largest; stb_probe_guess(s, &r); return r; } int stb_search_open(stb_search *s, int minv, int find_smallest) { int r; s->step = 4; s->minval = minv; s->maxval = minv+s->step; s->mode = find_smallest ? STB_probe_open_smallest : STB_probe_open_largest; stb_probe_guess(s, &r); return r; } #endif ////////////////////////////////////////////////////////////////////////////// // // String Processing // #define stb_prefixi(s,t) (0==stb_strnicmp((s),(t),strlen(t))) enum stb_splitpath_flag { STB_PATH = 1, STB_FILE = 2, STB_EXT = 4, STB_PATH_FILE = STB_PATH + STB_FILE, STB_FILE_EXT = STB_FILE + STB_EXT, STB_EXT_NO_PERIOD = 8, }; STB_EXTERN char * stb_skipwhite(char *s); STB_EXTERN char * stb_trimwhite(char *s); STB_EXTERN char * stb_skipnewline(char *s); STB_EXTERN char * stb_strncpy(char *s, char *t, int n); STB_EXTERN char * stb_substr(char *t, int n); STB_EXTERN char * stb_duplower(char *s); STB_EXTERN void stb_tolower (char *s); STB_EXTERN char * stb_strchr2 (char *s, char p1, char p2); STB_EXTERN char * stb_strrchr2(char *s, char p1, char p2); STB_EXTERN char * stb_strtok(char *output, char *src, char *delimit); STB_EXTERN char * stb_strtok_keep(char *output, char *src, char *delimit); STB_EXTERN char * stb_strtok_invert(char *output, char *src, char *allowed); STB_EXTERN char * stb_dupreplace(char *s, char *find, char *replace); STB_EXTERN void stb_replaceinplace(char *s, char *find, char *replace); STB_EXTERN char * stb_splitpath(char *output, char *src, int flag); STB_EXTERN char * stb_splitpathdup(char *src, int flag); STB_EXTERN char * stb_replacedir(char *output, char *src, char *dir); STB_EXTERN char * stb_replaceext(char *output, char *src, char *ext); STB_EXTERN void stb_fixpath(char *path); STB_EXTERN char * stb_shorten_path_readable(char *path, int max_len); STB_EXTERN int stb_suffix (char *s, char *t); STB_EXTERN int stb_suffixi(char *s, char *t); STB_EXTERN int stb_prefix (char *s, char *t); STB_EXTERN char * stb_strichr(char *s, char t); STB_EXTERN char * stb_stristr(char *s, char *t); STB_EXTERN int stb_prefix_count(char *s, char *t); STB_EXTERN char * stb_plural(int n); // "s" or "" STB_EXTERN size_t stb_strscpy(char *d, const char *s, size_t n); STB_EXTERN char **stb_tokens(char *src, char *delimit, int *count); STB_EXTERN char **stb_tokens_nested(char *src, char *delimit, int *count, char *nest_in, char *nest_out); STB_EXTERN char **stb_tokens_nested_empty(char *src, char *delimit, int *count, char *nest_in, char *nest_out); STB_EXTERN char **stb_tokens_allowempty(char *src, char *delimit, int *count); STB_EXTERN char **stb_tokens_stripwhite(char *src, char *delimit, int *count); STB_EXTERN char **stb_tokens_withdelim(char *src, char *delimit, int *count); STB_EXTERN char **stb_tokens_quoted(char *src, char *delimit, int *count); // with 'quoted', allow delimiters to appear inside quotation marks, and don't // strip whitespace inside them (and we delete the quotation marks unless they // appear back to back, in which case they're considered escaped) #ifdef STB_DEFINE size_t stb_strscpy(char *d, const char *s, size_t n) { size_t len = strlen(s); if (len >= n) { if (n) d[0] = 0; return 0; } strcpy(d,s); return len + 1; } char *stb_plural(int n) { return n == 1 ? "" : "s"; } int stb_prefix(char *s, char *t) { while (*t) if (*s++ != *t++) return STB_FALSE; return STB_TRUE; } int stb_prefix_count(char *s, char *t) { int c=0; while (*t) { if (*s++ != *t++) break; ++c; } return c; } int stb_suffix(char *s, char *t) { size_t n = strlen(s); size_t m = strlen(t); if (m <= n) return 0 == strcmp(s+n-m, t); else return 0; } int stb_suffixi(char *s, char *t) { size_t n = strlen(s); size_t m = strlen(t); if (m <= n) return 0 == stb_stricmp(s+n-m, t); else return 0; } // originally I was using this table so that I could create known sentinel // values--e.g. change whitetable[0] to be true if I was scanning for whitespace, // and false if I was scanning for nonwhite. I don't appear to be using that // functionality anymore (I do for tokentable, though), so just replace it // with isspace() char *stb_skipwhite(char *s) { while (isspace((unsigned char) *s)) ++s; return s; } char *stb_skipnewline(char *s) { if (s[0] == '\r' || s[0] == '\n') { if (s[0]+s[1] == '\r' + '\n') ++s; ++s; } return s; } char *stb_trimwhite(char *s) { int i,n; s = stb_skipwhite(s); n = (int) strlen(s); for (i=n-1; i >= 0; --i) if (!isspace(s[i])) break; s[i+1] = 0; return s; } char *stb_strncpy(char *s, char *t, int n) { strncpy(s,t,n); s[n-1] = 0; return s; } char *stb_substr(char *t, int n) { char *a; int z = (int) strlen(t); if (z < n) n = z; a = (char *) malloc(n+1); strncpy(a,t,n); a[n] = 0; return a; } char *stb_duplower(char *s) { char *p = strdup(s), *q = p; while (*q) { *q = tolower(*q); ++q; } return p; } void stb_tolower(char *s) { while (*s) { *s = tolower(*s); ++s; } } char *stb_strchr2(char *s, char x, char y) { for(; *s; ++s) if (*s == x || *s == y) return s; return NULL; } char *stb_strrchr2(char *s, char x, char y) { char *r = NULL; for(; *s; ++s) if (*s == x || *s == y) r = s; return r; } char *stb_strichr(char *s, char t) { if (tolower(t) == toupper(t)) return strchr(s,t); return stb_strchr2(s, (char) tolower(t), (char) toupper(t)); } char *stb_stristr(char *s, char *t) { size_t n = strlen(t); char *z; if (n==0) return s; while ((z = stb_strichr(s, *t)) != NULL) { if (0==stb_strnicmp(z, t, n)) return z; s = z+1; } return NULL; } static char *stb_strtok_raw(char *output, char *src, char *delimit, int keep, int invert) { if (invert) { while (*src && strchr(delimit, *src) != NULL) { *output++ = *src++; } } else { while (*src && strchr(delimit, *src) == NULL) { *output++ = *src++; } } *output = 0; if (keep) return src; else return *src ? src+1 : src; } char *stb_strtok(char *output, char *src, char *delimit) { return stb_strtok_raw(output, src, delimit, 0, 0); } char *stb_strtok_keep(char *output, char *src, char *delimit) { return stb_strtok_raw(output, src, delimit, 1, 0); } char *stb_strtok_invert(char *output, char *src, char *delimit) { return stb_strtok_raw(output, src, delimit, 1,1); } static char **stb_tokens_raw(char *src_, char *delimit, int *count, int stripwhite, int allow_empty, char *start, char *end) { int nested = 0; unsigned char *src = (unsigned char *) src_; static char stb_tokentable[256]; // rely on static initializion to 0 static char stable[256],etable[256]; char *out; char **result; int num=0; unsigned char *s; s = (unsigned char *) delimit; while (*s) stb_tokentable[*s++] = 1; if (start) { s = (unsigned char *) start; while (*s) stable[*s++] = 1; s = (unsigned char *) end; if (s) while (*s) stable[*s++] = 1; s = (unsigned char *) end; if (s) while (*s) etable[*s++] = 1; } stable[0] = 1; // two passes through: the first time, counting how many s = (unsigned char *) src; while (*s) { // state: just found delimiter // skip further delimiters if (!allow_empty) { stb_tokentable[0] = 0; while (stb_tokentable[*s]) ++s; if (!*s) break; } ++num; // skip further non-delimiters stb_tokentable[0] = 1; if (stripwhite == 2) { // quoted strings while (!stb_tokentable[*s]) { if (*s != '"') ++s; else { ++s; if (*s == '"') ++s; // "" -> ", not start a string else { // begin a string while (*s) { if (s[0] == '"') { if (s[1] == '"') s += 2; // "" -> " else { ++s; break; } // terminating " } else ++s; } } } } } else while (nested || !stb_tokentable[*s]) { if (stable[*s]) { if (!*s) break; if (end ? etable[*s] : nested) --nested; else ++nested; } ++s; } if (allow_empty) { if (*s) ++s; } } // now num has the actual count... malloc our output structure // need space for all the strings: strings won't be any longer than // original input, since for every '\0' there's at least one delimiter result = (char **) malloc(sizeof(*result) * (num+1) + (s-src+1)); if (result == NULL) return result; out = (char *) (result + (num+1)); // second pass: copy out the data s = (unsigned char *) src; num = 0; nested = 0; while (*s) { char *last_nonwhite; // state: just found delimiter // skip further delimiters if (!allow_empty) { stb_tokentable[0] = 0; if (stripwhite) while (stb_tokentable[*s] || isspace(*s)) ++s; else while (stb_tokentable[*s]) ++s; } else if (stripwhite) { while (isspace(*s)) ++s; } if (!*s) break; // we're past any leading delimiters and whitespace result[num] = out; ++num; // copy non-delimiters stb_tokentable[0] = 1; last_nonwhite = out-1; if (stripwhite == 2) { while (!stb_tokentable[*s]) { if (*s != '"') { if (!isspace(*s)) last_nonwhite = out; *out++ = *s++; } else { ++s; if (*s == '"') { if (!isspace(*s)) last_nonwhite = out; *out++ = *s++; // "" -> ", not start string } else { // begin a quoted string while (*s) { if (s[0] == '"') { if (s[1] == '"') { *out++ = *s; s += 2; } else { ++s; break; } // terminating " } else *out++ = *s++; } last_nonwhite = out-1; // all in quotes counts as non-white } } } } else { while (nested || !stb_tokentable[*s]) { if (!isspace(*s)) last_nonwhite = out; if (stable[*s]) { if (!*s) break; if (end ? etable[*s] : nested) --nested; else ++nested; } *out++ = *s++; } } if (stripwhite) // rewind to last non-whitespace char out = last_nonwhite+1; *out++ = '\0'; if (*s) ++s; // skip delimiter } s = (unsigned char *) delimit; while (*s) stb_tokentable[*s++] = 0; if (start) { s = (unsigned char *) start; while (*s) stable[*s++] = 1; s = (unsigned char *) end; if (s) while (*s) stable[*s++] = 1; s = (unsigned char *) end; if (s) while (*s) etable[*s++] = 1; } if (count != NULL) *count = num; result[num] = 0; return result; } char **stb_tokens(char *src, char *delimit, int *count) { return stb_tokens_raw(src,delimit,count,0,0,0,0); } char **stb_tokens_nested(char *src, char *delimit, int *count, char *nest_in, char *nest_out) { return stb_tokens_raw(src,delimit,count,0,0,nest_in,nest_out); } char **stb_tokens_nested_empty(char *src, char *delimit, int *count, char *nest_in, char *nest_out) { return stb_tokens_raw(src,delimit,count,0,1,nest_in,nest_out); } char **stb_tokens_allowempty(char *src, char *delimit, int *count) { return stb_tokens_raw(src,delimit,count,0,1,0,0); } char **stb_tokens_stripwhite(char *src, char *delimit, int *count) { return stb_tokens_raw(src,delimit,count,1,1,0,0); } char **stb_tokens_quoted(char *src, char *delimit, int *count) { return stb_tokens_raw(src,delimit,count,2,1,0,0); } char *stb_dupreplace(char *src, char *find, char *replace) { size_t len_find = strlen(find); size_t len_replace = strlen(replace); int count = 0; char *s,*p,*q; s = strstr(src, find); if (s == NULL) return strdup(src); do { ++count; s = strstr(s + len_find, find); } while (s != NULL); p = (char *) malloc(strlen(src) + count * (len_replace - len_find) + 1); if (p == NULL) return p; q = p; s = src; for (;;) { char *t = strstr(s, find); if (t == NULL) { strcpy(q,s); assert(strlen(p) == strlen(src) + count*(len_replace-len_find)); return p; } memcpy(q, s, t-s); q += t-s; memcpy(q, replace, len_replace); q += len_replace; s = t + len_find; } } void stb_replaceinplace(char *src, char *find, char *replace) { size_t len_find = strlen(find); size_t len_replace = strlen(replace); int delta; char *s,*p,*q; delta = len_replace - len_find; assert(delta <= 0); if (delta > 0) return; p = strstr(src, find); if (p == NULL) return; s = q = p; while (*s) { memcpy(q, replace, len_replace); p += len_find; q += len_replace; s = strstr(p, find); if (s == NULL) s = p + strlen(p); memmove(q, p, s-p); q += s-p; p = s; } *q = 0; } void stb_fixpath(char *path) { for(; *path; ++path) if (*path == '\\') *path = '/'; } void stb__add_section(char *buffer, char *data, int curlen, int newlen) { if (newlen < curlen) { int z1 = newlen >> 1, z2 = newlen-z1; memcpy(buffer, data, z1-1); buffer[z1-1] = '.'; buffer[z1-0] = '.'; memcpy(buffer+z1+1, data+curlen-z2+1, z2-1); } else memcpy(buffer, data, curlen); } char * stb_shorten_path_readable(char *path, int len) { static char buffer[1024]; int n = strlen(path),n1,n2,r1,r2; char *s; if (n <= len) return path; if (len > 1024) return path; s = stb_strrchr2(path, '/', '\\'); if (s) { n1 = s - path + 1; n2 = n - n1; ++s; } else { n1 = 0; n2 = n; s = path; } // now we need to reduce r1 and r2 so that they fit in len if (n1 < len>>1) { r1 = n1; r2 = len - r1; } else if (n2 < len >> 1) { r2 = n2; r1 = len - r2; } else { r1 = n1 * len / n; r2 = n2 * len / n; if (r1 < len>>2) r1 = len>>2, r2 = len-r1; if (r2 < len>>2) r2 = len>>2, r1 = len-r2; } assert(r1 <= n1 && r2 <= n2); if (n1) stb__add_section(buffer, path, n1, r1); stb__add_section(buffer+r1, s, n2, r2); buffer[len] = 0; return buffer; } static char *stb__splitpath_raw(char *buffer, char *path, int flag) { int len=0,x,y, n = (int) strlen(path), f1,f2; char *s = stb_strrchr2(path, '/', '\\'); char *t = strrchr(path, '.'); if (s && t && t < s) t = NULL; if (s) ++s; if (flag == STB_EXT_NO_PERIOD) flag |= STB_EXT; if (!(flag & (STB_PATH | STB_FILE | STB_EXT))) return NULL; f1 = s == NULL ? 0 : s-path; // start of filename f2 = t == NULL ? n : t-path; // just past end of filename if (flag & STB_PATH) { x = 0; if (f1 == 0 && flag == STB_PATH) len=2; } else if (flag & STB_FILE) { x = f1; } else { x = f2; if (flag & STB_EXT_NO_PERIOD) if (buffer[x] == '.') ++x; } if (flag & STB_EXT) y = n; else if (flag & STB_FILE) y = f2; else y = f1; if (buffer == NULL) { buffer = (char *) malloc(y-x + len + 1); if (!buffer) return NULL; } if (len) { strcpy(buffer, "./"); return buffer; } strncpy(buffer, path+x, y-x); buffer[y-x] = 0; return buffer; } char *stb_splitpath(char *output, char *src, int flag) { return stb__splitpath_raw(output, src, flag); } char *stb_splitpathdup(char *src, int flag) { return stb__splitpath_raw(NULL, src, flag); } char *stb_replacedir(char *output, char *src, char *dir) { char buffer[4096]; stb_splitpath(buffer, src, STB_FILE | STB_EXT); if (dir) sprintf(output, "%s/%s", dir, buffer); else strcpy(output, buffer); return output; } char *stb_replaceext(char *output, char *src, char *ext) { char buffer[4096]; stb_splitpath(buffer, src, STB_PATH | STB_FILE); if (ext) sprintf(output, "%s.%s", buffer, ext[0] == '.' ? ext+1 : ext); else strcpy(output, buffer); return output; } #endif ////////////////////////////////////////////////////////////////////////////// // // stb_alloc - hierarchical allocator // // inspired by http://swapped.cc/halloc // // // When you alloc a given block through stb_alloc, you have these choices: // // 1. does it have a parent? // 2. can it have children? // 3. can it be freed directly? // 4. is it transferrable? // 5. what is its alignment? // // Here are interesting combinations of those: // // children free transfer alignment // arena Y Y N n/a // no-overhead, chunked N N N normal // string pool alloc N N N 1 // parent-ptr, chunked Y N N normal // low-overhead, unchunked N Y Y normal // general purpose alloc Y Y Y normal // // Unchunked allocations will probably return 16-aligned pointers. If // we 16-align the results, we have room for 4 pointers. For smaller // allocations that allow finer alignment, we can reduce the pointers. // // The strategy is that given a pointer, assuming it has a header (only // the no-overhead allocations have no header), we can determine the // type of the header fields, and the number of them, by stepping backwards // through memory and looking at the tags in the bottom bits. // // Implementation strategy: // chunked allocations come from the middle of chunks, and can't // be freed. thefore they do not need to be on a sibling chain. // they may need child pointers if they have children. // // chunked, with-children // void *parent; // // unchunked, no-children -- reduced storage // void *next_sibling; // void *prev_sibling_nextp; // // unchunked, general // void *first_child; // void *next_sibling; // void *prev_sibling_nextp; // void *chunks; // // so, if we code each of these fields with different bit patterns // (actually same one for next/prev/child), then we can identify which // each one is from the last field. STB_EXTERN void stb_free(void *p); STB_EXTERN void *stb_malloc_global(size_t size); STB_EXTERN void *stb_malloc(void *context, size_t size); STB_EXTERN void *stb_malloc_nofree(void *context, size_t size); STB_EXTERN void *stb_malloc_leaf(void *context, size_t size); STB_EXTERN void *stb_malloc_raw(void *context, size_t size); STB_EXTERN void *stb_realloc(void *ptr, size_t newsize); STB_EXTERN void stb_reassign(void *new_context, void *ptr); STB_EXTERN void stb_malloc_validate(void *p, void *parent); extern int stb_alloc_chunk_size ; extern int stb_alloc_count_free ; extern int stb_alloc_count_alloc; extern int stb_alloc_alignment ; #ifdef STB_DEFINE int stb_alloc_chunk_size = 65536; int stb_alloc_count_free = 0; int stb_alloc_count_alloc = 0; int stb_alloc_alignment = -16; typedef struct stb__chunk { struct stb__chunk *next; int data_left; int alloc; } stb__chunk; typedef struct { void * next; void ** prevn; } stb__nochildren; typedef struct { void ** prevn; void * child; void * next; stb__chunk *chunks; } stb__alloc; typedef struct { stb__alloc *parent; } stb__chunked; #define STB__PARENT 1 #define STB__CHUNKS 2 typedef enum { STB__nochildren = 0, STB__chunked = STB__PARENT, STB__alloc = STB__CHUNKS, STB__chunk_raw = 4, } stb__alloc_type; // these functions set the bottom bits of a pointer efficiently #define STB__DECODE(x,v) ((void *) ((char *) (x) - (v))) #define STB__ENCODE(x,v) ((void *) ((char *) (x) + (v))) #define stb__parent(z) (stb__alloc *) STB__DECODE((z)->parent, STB__PARENT) #define stb__chunks(z) (stb__chunk *) STB__DECODE((z)->chunks, STB__CHUNKS) #define stb__setparent(z,p) (z)->parent = (stb__alloc *) STB__ENCODE((p), STB__PARENT) #define stb__setchunks(z,c) (z)->chunks = (stb__chunk *) STB__ENCODE((c), STB__CHUNKS) static stb__alloc stb__alloc_global = { NULL, NULL, NULL, (stb__chunk *) STB__ENCODE(NULL, STB__CHUNKS) }; static stb__alloc_type stb__identify(void *p) { void **q = (void **) p; return (stb__alloc_type) ((stb_uinta) q[-1] & 3); } static void *** stb__prevn(void *p) { if (stb__identify(p) == STB__alloc) { stb__alloc *s = (stb__alloc *) p - 1; return &s->prevn; } else { stb__nochildren *s = (stb__nochildren *) p - 1; return &s->prevn; } } void stb_free(void *p) { if (p == NULL) return; // count frees so that unit tests can see what's happening ++stb_alloc_count_free; switch(stb__identify(p)) { case STB__chunked: // freeing a chunked-block with children does nothing; // they only get freed when the parent does // surely this is wrong, and it should free them immediately? // otherwise how are they getting put on the right chain? return; case STB__nochildren: { stb__nochildren *s = (stb__nochildren *) p - 1; // unlink from sibling chain *(s->prevn) = s->next; if (s->next) *stb__prevn(s->next) = s->prevn; free(s); return; } case STB__alloc: { stb__alloc *s = (stb__alloc *) p - 1; stb__chunk *c, *n; void *q; // unlink from sibling chain, if any *(s->prevn) = s->next; if (s->next) *stb__prevn(s->next) = s->prevn; // first free chunks c = (stb__chunk *) stb__chunks(s); while (c != NULL) { n = c->next; stb_alloc_count_free += c->alloc; free(c); c = n; } // validating stb__setchunks(s,NULL); s->prevn = NULL; s->next = NULL; // now free children while ((q = s->child) != NULL) { stb_free(q); } // now free self free(s); return; } default: assert(0); /* NOTREACHED */ } } void stb_malloc_validate(void *p, void *parent) { if (p == NULL) return; switch(stb__identify(p)) { case STB__chunked: return; case STB__nochildren: { stb__nochildren *n = (stb__nochildren *) p - 1; if (n->prevn) assert(*n->prevn == p); if (n->next) { assert(*stb__prevn(n->next) == &n->next); stb_malloc_validate(n, parent); } return; } case STB__alloc: { stb__alloc *s = (stb__alloc *) p - 1; if (s->prevn) assert(*s->prevn == p); if (s->child) { assert(*stb__prevn(s->child) == &s->child); stb_malloc_validate(s->child, p); } if (s->next) { assert(*stb__prevn(s->next) == &s->next); stb_malloc_validate(s->next, parent); } return; } default: assert(0); /* NOTREACHED */ } } static void * stb__try_chunk(stb__chunk *c, int size, int align, int pre_align) { char *memblock = (char *) (c+1), *q; stb_inta iq; int start_offset; // we going to allocate at the end of the chunk, not the start. confusing, // but it means we don't need both a 'limit' and a 'cur', just a 'cur'. // the block ends at: p + c->data_left // then we move back by size start_offset = c->data_left - size; // now we need to check the alignment of that q = memblock + start_offset; iq = (stb_inta) q; assert(sizeof(q) == sizeof(iq)); // suppose align = 2 // then we need to retreat iq far enough that (iq & (2-1)) == 0 // to get (iq & (align-1)) = 0 requires subtracting (iq & (align-1)) start_offset -= iq & (align-1); assert(((stb_uinta) (memblock+start_offset) & (align-1)) == 0); // now, if that + pre_align works, go for it! start_offset -= pre_align; if (start_offset >= 0) { c->data_left = start_offset; return memblock + start_offset; } return NULL; } static void stb__sort_chunks(stb__alloc *src) { // of the first two chunks, put the chunk with more data left in it first stb__chunk *c = stb__chunks(src), *d; if (c == NULL) return; d = c->next; if (d == NULL) return; if (c->data_left > d->data_left) return; c->next = d->next; d->next = c; stb__setchunks(src, d); } static void * stb__alloc_chunk(stb__alloc *src, int size, int align, int pre_align) { void *p; stb__chunk *c = stb__chunks(src); if (c && size <= stb_alloc_chunk_size) { p = stb__try_chunk(c, size, align, pre_align); if (p) { ++c->alloc; return p; } // try a second chunk to reduce wastage if (c->next) { p = stb__try_chunk(c->next, size, align, pre_align); if (p) { ++c->alloc; return p; } // put the bigger chunk first, since the second will get buried // the upshot of this is that, until it gets allocated from, chunk #2 // is always the largest remaining chunk. (could formalize // this with a heap!) stb__sort_chunks(src); c = stb__chunks(src); } } // allocate a new chunk { stb__chunk *n; int chunk_size = stb_alloc_chunk_size; // we're going to allocate a new chunk to put this in if (size > chunk_size) chunk_size = size; assert(sizeof(*n) + pre_align <= 16); // loop trying to allocate a large enough chunk // the loop is because the alignment may cause problems if it's big... // and we don't know what our chunk alignment is going to be while (1) { n = (stb__chunk *) malloc(16 + chunk_size); if (n == NULL) return NULL; n->data_left = chunk_size - sizeof(*n); p = stb__try_chunk(n, size, align, pre_align); if (p != NULL) { n->next = c; stb__setchunks(src, n); // if we just used up the whole block immediately, // move the following chunk up n->alloc = 1; if (size == chunk_size) stb__sort_chunks(src); return p; } free(n); chunk_size += 16+align; } } } static stb__alloc * stb__get_context(void *context) { if (context == NULL) { return &stb__alloc_global; } else { int u = stb__identify(context); // if context is chunked, grab parent if (u == STB__chunked) { stb__chunked *s = (stb__chunked *) context - 1; return stb__parent(s); } else { return (stb__alloc *) context - 1; } } } static void stb__insert_alloc(stb__alloc *src, stb__alloc *s) { s->prevn = &src->child; s->next = src->child; src->child = s+1; if (s->next) *stb__prevn(s->next) = &s->next; } static void stb__insert_nochild(stb__alloc *src, stb__nochildren *s) { s->prevn = &src->child; s->next = src->child; src->child = s+1; if (s->next) *stb__prevn(s->next) = &s->next; } static void * malloc_base(void *context, size_t size, stb__alloc_type t, int align) { void *p; stb__alloc *src = stb__get_context(context); if (align <= 0) { // compute worst-case C packed alignment // e.g. a 24-byte struct is 8-aligned int align_proposed = 1 << stb_lowbit8(size); if (align_proposed < 0) align_proposed = 4; if (align_proposed == 0) { if (size == 0) align_proposed = 1; else align_proposed = 256; } // a negative alignment means 'don't align any larger // than this'; so -16 means we align 1,2,4,8, or 16 if (align < 0) { if (align_proposed > -align) align_proposed = -align; } align = align_proposed; } assert(stb_is_pow2(align)); // don't cause misalignment when allocating nochildren if (t == STB__nochildren && align > 8) t = STB__alloc; switch (t) { case STB__alloc: { stb__alloc *s = (stb__alloc *) malloc(size + sizeof(*s)); if (s == NULL) return NULL; p = s+1; s->child = NULL; stb__insert_alloc(src, s); stb__setchunks(s,NULL); break; } case STB__nochildren: { stb__nochildren *s = (stb__nochildren *) malloc(size + sizeof(*s)); if (s == NULL) return NULL; p = s+1; stb__insert_nochild(src, s); break; } case STB__chunk_raw: { p = stb__alloc_chunk(src, size, align, 0); if (p == NULL) return NULL; break; } case STB__chunked: { stb__chunked *s; if (align < sizeof(stb_uintptr)) align = sizeof(stb_uintptr); s = (stb__chunked *) stb__alloc_chunk(src, size, align, sizeof(*s)); if (s == NULL) return NULL; stb__setparent(s, src); p = s+1; break; } default: p = NULL; assert(0); /* NOTREACHED */ } ++stb_alloc_count_alloc; return p; } void *stb_malloc_global(size_t size) { return malloc_base(NULL, size, STB__alloc, stb_alloc_alignment); } void *stb_malloc(void *context, size_t size) { return malloc_base(context, size, STB__alloc, stb_alloc_alignment); } void *stb_malloc_nofree(void *context, size_t size) { return malloc_base(context, size, STB__chunked, stb_alloc_alignment); } void *stb_malloc_leaf(void *context, size_t size) { return malloc_base(context, size, STB__nochildren, stb_alloc_alignment); } void *stb_malloc_raw(void *context, size_t size) { return malloc_base(context, size, STB__chunk_raw, stb_alloc_alignment); } char *stb_malloc_string(void *context, size_t size) { return (char *) malloc_base(context, size, STB__chunk_raw, 1); } void *stb_realloc(void *ptr, size_t newsize) { stb__alloc_type t; if (ptr == NULL) return stb_malloc(NULL, newsize); if (newsize == 0) { stb_free(ptr); return NULL; } t = stb__identify(ptr); assert(t == STB__alloc || t == STB__nochildren); if (t == STB__alloc) { stb__alloc *s = (stb__alloc *) ptr - 1; s = (stb__alloc *) realloc(s, newsize + sizeof(*s)); if (s == NULL) return NULL; ptr = s+1; // update pointers (*s->prevn) = ptr; if (s->next) *stb__prevn(s->next) = &s->next; if (s->child) *stb__prevn(s->child) = &s->child; return ptr; } else { stb__nochildren *s = (stb__nochildren *) ptr - 1; s = (stb__nochildren *) realloc(ptr, newsize + sizeof(s)); if (s == NULL) return NULL; // update pointers (*s->prevn) = s+1; if (s->next) *stb__prevn(s->next) = &s->next; return s+1; } } void *stb_realloc_c(void *context, void *ptr, size_t newsize) { if (ptr == NULL) return stb_malloc(context, newsize); if (newsize == 0) { stb_free(ptr); return NULL; } // @TODO: verify you haven't changed contexts return stb_realloc(ptr, newsize); } void stb_reassign(void *new_context, void *ptr) { stb__alloc *src = stb__get_context(new_context); stb__alloc_type t = stb__identify(ptr); assert(t == STB__alloc || t == STB__nochildren); if (t == STB__alloc) { stb__alloc *s = (stb__alloc *) ptr - 1; // unlink from old *(s->prevn) = s->next; if (s->next) *stb__prevn(s->next) = s->prevn; stb__insert_alloc(src, s); } else { stb__nochildren *s = (stb__nochildren *) ptr - 1; // unlink from old *(s->prevn) = s->next; if (s->next) *stb__prevn(s->next) = s->prevn; stb__insert_nochild(src, s); } } #endif ////////////////////////////////////////////////////////////////////////////// // // stb_arr // // An stb_arr is directly useable as a pointer (use the actual type in your // definition), but when it resizes, it returns a new pointer and you can't // use the old one, so you have to be careful to copy-in-out as necessary. // // Use a NULL pointer as a 0-length array. // // float *my_array = NULL, *temp; // // // add elements on the end one at a time // stb_arr_push(my_array, 0.0f); // stb_arr_push(my_array, 1.0f); // stb_arr_push(my_array, 2.0f); // // assert(my_array[1] == 2.0f); // // // add an uninitialized element at the end, then assign it // *stb_arr_add(my_array) = 3.0f; // // // add three uninitialized elements at the end // temp = stb_arr_addn(my_array,3); // temp[0] = 4.0f; // temp[1] = 5.0f; // temp[2] = 6.0f; // // assert(my_array[5] == 5.0f); // // // remove the last one // stb_arr_pop(my_array); // // assert(stb_arr_len(my_array) == 6); #ifdef STB_MALLOC_WRAPPER #define STB__PARAMS , char *file, int line #define STB__ARGS , file, line #else #define STB__PARAMS #define STB__ARGS #endif // calling this function allocates an empty stb_arr attached to p // (whereas NULL isn't attached to anything) STB_EXTERN void stb_arr_malloc(void **target, void *context); // call this function with a non-NULL value to have all successive // stbs that are created be attached to the associated parent. Note // that once a given stb_arr is non-empty, it stays attached to its // current parent, even if you call this function again. // it turns the previous value, so you can restore it STB_EXTERN void* stb_arr_malloc_parent(void *p); // simple functions written on top of other functions #define stb_arr_empty(a) ( stb_arr_len(a) == 0 ) #define stb_arr_add(a) ( stb_arr_addn((a),1) ) #define stb_arr_push(a,v) ( *stb_arr_add(a)=(v) ) typedef struct { int len, limit; int stb_malloc; unsigned int signature; } stb__arr; #define stb_arr_signature 0x51bada7b // ends with 0123 in decimal // access the header block stored before the data #define stb_arrhead(a) /*lint --e(826)*/ (((stb__arr *) (a)) - 1) #define stb_arrhead2(a) /*lint --e(826)*/ (((stb__arr *) (a)) - 1) #ifdef STB_DEBUG #define stb_arr_check(a) assert(!a || stb_arrhead(a)->signature == stb_arr_signature) #define stb_arr_check2(a) assert(!a || stb_arrhead2(a)->signature == stb_arr_signature) #else #define stb_arr_check(a) ((void) 0) #define stb_arr_check2(a) ((void) 0) #endif // ARRAY LENGTH // get the array length; special case if pointer is NULL #define stb_arr_len(a) (a ? stb_arrhead(a)->len : 0) #define stb_arr_len2(a) ((stb__arr *) (a) ? stb_arrhead2(a)->len : 0) #define stb_arr_lastn(a) (stb_arr_len(a)-1) // check whether a given index is valid -- tests 0 <= i < stb_arr_len(a) #define stb_arr_valid(a,i) (a ? (int) (i) < stb_arrhead(a)->len : 0) // change the array length so is is exactly N entries long, creating // uninitialized entries as needed #define stb_arr_setlen(a,n) \ (stb__arr_setlen((void **) &(a), sizeof(a[0]), (n))) // change the array length so that N is a valid index (that is, so // it is at least N entries long), creating uninitialized entries as needed #define stb_arr_makevalid(a,n) \ (stb_arr_len(a) < (n)+1 ? stb_arr_setlen(a,(n)+1),(a) : (a)) // remove the last element of the array, returning it #define stb_arr_pop(a) ((stb_arr_check(a), (a))[--stb_arrhead(a)->len]) // access the last element in the array #define stb_arr_last(a) ((stb_arr_check(a), (a))[stb_arr_len(a)-1]) // is iterator at end of list? #define stb_arr_end(a,i) ((i) >= &(a)[stb_arr_len(a)]) // (internal) change the allocated length of the array #define stb_arr__grow(a,n) (stb_arr_check(a), stb_arrhead(a)->len += (n)) // add N new unitialized elements to the end of the array #define stb_arr__addn(a,n) /*lint --e(826)*/ \ ((stb_arr_len(a)+(n) > stb_arrcurmax(a)) \ ? (stb__arr_addlen((void **) &(a),sizeof(*a),(n)),0) \ : ((stb_arr__grow(a,n), 0))) // add N new unitialized elements to the end of the array, and return // a pointer to the first new one #define stb_arr_addn(a,n) (stb_arr__addn((a),n),(a)+stb_arr_len(a)-(n)) // add N new uninitialized elements starting at index 'i' #define stb_arr_insertn(a,i,n) (stb__arr_insertn((void **) &(a), sizeof(*a), i, n)) // insert an element at i #define stb_arr_insert(a,i,v) (stb__arr_insertn((void **) &(a), sizeof(*a), i, 1), ((a)[i] = v)) // delete N elements from the middle starting at index 'i' #define stb_arr_deleten(a,i,n) (stb__arr_deleten((void **) &(a), sizeof(*a), i, n)) // delete the i'th element #define stb_arr_delete(a,i) stb_arr_deleten(a,i,1) // delete the i'th element, swapping down from the end #define stb_arr_fastdelete(a,i) \ (stb_swap(&a[i], &a[stb_arrhead(a)->len-1], sizeof(*a)), stb_arr_pop(a)) // ARRAY STORAGE // get the array maximum storage; special case if NULL #define stb_arrcurmax(a) (a ? stb_arrhead(a)->limit : 0) #define stb_arrcurmax2(a) (a ? stb_arrhead2(a)->limit : 0) // set the maxlength of the array to n in anticipation of further growth #define stb_arr_setsize(a,n) (stb_arr_check(a), stb__arr_setsize((void **) &(a),sizeof((a)[0]),n)) // make sure maxlength is large enough for at least N new allocations #define stb_arr_atleast(a,n) (stb_arr_len(a)+(n) > stb_arrcurmax(a) \ ? stb_arr_setsize((a), (n)) : 0) // make a copy of a given array (copies contents via 'memcpy'!) #define stb_arr_copy(a) stb__arr_copy(a, sizeof((a)[0])) // compute the storage needed to store all the elements of the array #define stb_arr_storage(a) (stb_arr_len(a) * sizeof((a)[0])) #define stb_arr_for(v,arr) for((v)=(arr); (v) < (arr)+stb_arr_len(arr); ++(v)) // IMPLEMENTATION STB_EXTERN void stb_arr_free_(void **p); STB_EXTERN void *stb__arr_copy_(void *p, int elem_size); STB_EXTERN void stb__arr_setsize_(void **p, int size, int limit STB__PARAMS); STB_EXTERN void stb__arr_setlen_(void **p, int size, int newlen STB__PARAMS); STB_EXTERN void stb__arr_addlen_(void **p, int size, int addlen STB__PARAMS); STB_EXTERN void stb__arr_deleten_(void **p, int size, int loc, int n STB__PARAMS); STB_EXTERN void stb__arr_insertn_(void **p, int size, int loc, int n STB__PARAMS); #define stb_arr_free(p) stb_arr_free_((void **) &(p)) #define stb__arr_copy stb__arr_copy_ #ifndef STB_MALLOC_WRAPPER #define stb__arr_setsize stb__arr_setsize_ #define stb__arr_setlen stb__arr_setlen_ #define stb__arr_addlen stb__arr_addlen_ #define stb__arr_deleten stb__arr_deleten_ #define stb__arr_insertn stb__arr_insertn_ #else #define stb__arr_addlen(p,s,n) stb__arr_addlen_(p,s,n,__FILE__,__LINE__) #define stb__arr_setlen(p,s,n) stb__arr_setlen_(p,s,n,__FILE__,__LINE__) #define stb__arr_setsize(p,s,n) stb__arr_setsize_(p,s,n,__FILE__,__LINE__) #define stb__arr_deleten(p,s,i,n) stb__arr_deleten_(p,s,i,n,__FILE__,__LINE__) #define stb__arr_insertn(p,s,i,n) stb__arr_insertn_(p,s,i,n,__FILE__,__LINE__) #endif #ifdef STB_DEFINE static void *stb__arr_context; void *stb_arr_malloc_parent(void *p) { void *q = stb__arr_context; stb__arr_context = p; return q; } void stb_arr_malloc(void **target, void *context) { stb__arr *q = (stb__arr *) stb_malloc(context, sizeof(*q)); q->len = q->limit = 0; q->stb_malloc = 1; q->signature = stb_arr_signature; *target = (void *) (q+1); } static void * stb__arr_malloc(int size) { if (stb__arr_context) return stb_malloc(stb__arr_context, size); return malloc(size); } void * stb__arr_copy_(void *p, int elem_size) { stb__arr *q; if (p == NULL) return p; q = (stb__arr *) stb__arr_malloc(sizeof(*q) + elem_size * stb_arrhead2(p)->limit); stb_arr_check2(p); memcpy(q, stb_arrhead2(p), sizeof(*q) + elem_size * stb_arrhead2(p)->len); q->stb_malloc = !!stb__arr_context; return q+1; } void stb_arr_free_(void **pp) { void *p = *pp; stb_arr_check2(p); if (p) { stb__arr *q = stb_arrhead2(p); if (q->stb_malloc) stb_free(q); else free(q); } *pp = NULL; } static void stb__arrsize_(void **pp, int size, int limit, int len STB__PARAMS) { void *p = *pp; stb__arr *a; stb_arr_check2(p); if (p == NULL) { if (len == 0 && size == 0) return; a = (stb__arr *) stb__arr_malloc(sizeof(*a) + size*limit); a->limit = limit; a->len = len; a->stb_malloc = !!stb__arr_context; a->signature = stb_arr_signature; } else { a = stb_arrhead2(p); a->len = len; if (a->limit < limit) { void *p; if (a->limit >= 4 && limit < a->limit * 2) limit = a->limit * 2; if (a->stb_malloc) p = stb_realloc(a, sizeof(*a) + limit*size); else #ifdef STB_MALLOC_WRAPPER p = stb__realloc(a, sizeof(*a) + limit*size, file, line); #else p = realloc(a, sizeof(*a) + limit*size); #endif if (p) { a = (stb__arr *) p; a->limit = limit; } else { // throw an error! } } } a->len = stb_min(a->len, a->limit); *pp = a+1; } void stb__arr_setsize_(void **pp, int size, int limit STB__PARAMS) { void *p = *pp; stb_arr_check2(p); stb__arrsize_(pp, size, limit, stb_arr_len2(p) STB__ARGS); } void stb__arr_setlen_(void **pp, int size, int newlen STB__PARAMS) { void *p = *pp; stb_arr_check2(p); if (stb_arrcurmax2(p) < newlen || p == NULL) { stb__arrsize_(pp, size, newlen, newlen STB__ARGS); } else { stb_arrhead2(p)->len = newlen; } } void stb__arr_addlen_(void **p, int size, int addlen STB__PARAMS) { stb__arr_setlen_(p, size, stb_arr_len2(*p) + addlen STB__ARGS); } void stb__arr_insertn_(void **pp, int size, int i, int n STB__PARAMS) { void *p = *pp; if (n) { int z; if (p == NULL) { stb__arr_addlen_(pp, size, n STB__ARGS); return; } z = stb_arr_len2(p); stb__arr_addlen_(&p, size, n STB__ARGS); memmove((char *) p + (i+n)*size, (char *) p + i*size, size * (z-i)); } *pp = p; } void stb__arr_deleten_(void **pp, int size, int i, int n STB__PARAMS) { void *p = *pp; if (n) { memmove((char *) p + i*size, (char *) p + (i+n)*size, size * (stb_arr_len2(p)-(i+n))); stb_arrhead2(p)->len -= n; } *pp = p; } #endif ////////////////////////////////////////////////////////////////////////////// // // Hashing // // typical use for this is to make a power-of-two hash table. // // let N = size of table (2^n) // let H = stb_hash(str) // let S = stb_rehash(H) | 1 // // then hash probe sequence P(i) for i=0..N-1 // P(i) = (H + S*i) & (N-1) // // the idea is that H has 32 bits of hash information, but the // table has only, say, 2^20 entries so only uses 20 of the bits. // then by rehashing the original H we get 2^12 different probe // sequences for a given initial probe location. (So it's optimal // for 64K tables and its optimality decreases past that.) // // ok, so I've added something that generates _two separate_ // 32-bit hashes simultaneously which should scale better to // very large tables. STB_EXTERN unsigned int stb_hash(char *str); STB_EXTERN unsigned int stb_hashptr(void *p); STB_EXTERN unsigned int stb_hashlen(char *str, int len); STB_EXTERN unsigned int stb_rehash_improved(unsigned int v); STB_EXTERN unsigned int stb_hash_fast(void *p, int len); STB_EXTERN unsigned int stb_hash2(char *str, unsigned int *hash2_ptr); STB_EXTERN unsigned int stb_hash_number(unsigned int hash); #define stb_rehash(x) ((x) + ((x) >> 6) + ((x) >> 19)) #ifdef STB_DEFINE unsigned int stb_hash(char *str) { unsigned int hash = 0; while (*str) hash = (hash << 7) + (hash >> 25) + *str++; return hash + (hash >> 16); } unsigned int stb_hashlen(char *str, int len) { unsigned int hash = 0; while (len-- > 0 && *str) hash = (hash << 7) + (hash >> 25) + *str++; return hash + (hash >> 16); } unsigned int stb_hashptr(void *p) { unsigned int x = (unsigned int) p; // typically lacking in low bits and high bits x = stb_rehash(x); x += x << 16; // pearson's shuffle x ^= x << 3; x += x >> 5; x ^= x << 2; x += x >> 15; x ^= x << 10; return stb_rehash(x); } unsigned int stb_rehash_improved(unsigned int v) { return stb_hashptr((void *)(size_t) v); } unsigned int stb_hash2(char *str, unsigned int *hash2_ptr) { unsigned int hash1 = 0x3141592c; unsigned int hash2 = 0x77f044ed; while (*str) { hash1 = (hash1 << 7) + (hash1 >> 25) + *str; hash2 = (hash2 << 11) + (hash2 >> 21) + *str; ++str; } *hash2_ptr = hash2 + (hash1 >> 16); return hash1 + (hash2 >> 16); } // Paul Hsieh hash #define stb__get16_slow(p) ((p)[0] + ((p)[1] << 8)) #if defined(_MSC_VER) #define stb__get16(p) (*((unsigned short *) (p))) #else #define stb__get16(p) stb__get16_slow(p) #endif unsigned int stb_hash_fast(void *p, int len) { unsigned char *q = (unsigned char *) p; unsigned int hash = len; if (len <= 0 || q == NULL) return 0; /* Main loop */ if (((int) q & 1) == 0) { for (;len > 3; len -= 4) { unsigned int val; hash += stb__get16(q); val = (stb__get16(q+2) << 11); hash = (hash << 16) ^ hash ^ val; q += 4; hash += hash >> 11; } } else { for (;len > 3; len -= 4) { unsigned int val; hash += stb__get16_slow(q); val = (stb__get16_slow(q+2) << 11); hash = (hash << 16) ^ hash ^ val; q += 4; hash += hash >> 11; } } /* Handle end cases */ switch (len) { case 3: hash += stb__get16_slow(q); hash ^= hash << 16; hash ^= q[2] << 18; hash += hash >> 11; break; case 2: hash += stb__get16_slow(q); hash ^= hash << 11; hash += hash >> 17; break; case 1: hash += q[0]; hash ^= hash << 10; hash += hash >> 1; break; case 0: break; } /* Force "avalanching" of final 127 bits */ hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return hash; } unsigned int stb_hash_number(unsigned int hash) { hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return hash; } #endif ////////////////////////////////////////////////////////////////////////////// // // Perfect hashing for ints/pointers // // This is mainly useful for making faster pointer-indexed tables // that don't change frequently. E.g. for stb_ischar(). // typedef struct { stb_uint32 addend; stb_uint multiplicand; stb_uint b_mask; stb_uint8 small_bmap[16]; stb_uint16 *large_bmap; stb_uint table_mask; stb_uint32 *table; } stb_perfect; STB_EXTERN int stb_perfect_create(stb_perfect *,unsigned int*,int n); STB_EXTERN void stb_perfect_destroy(stb_perfect *); STB_EXTERN int stb_perfect_hash(stb_perfect *, unsigned int x); extern int stb_perfect_hash_max_failures; #ifdef STB_DEFINE int stb_perfect_hash_max_failures; int stb_perfect_hash(stb_perfect *p, unsigned int x) { stb_uint m = x * p->multiplicand; stb_uint y = x >> 16; stb_uint bv = (m >> 24) + y; stb_uint av = (m + y) >> 12; if (p->table == NULL) return -1; // uninitialized table fails bv &= p->b_mask; av &= p->table_mask; if (p->large_bmap) av ^= p->large_bmap[bv]; else av ^= p->small_bmap[bv]; return p->table[av] == x ? av : -1; } static void stb__perfect_prehash(stb_perfect *p, stb_uint x, stb_uint16 *a, stb_uint16 *b) { stb_uint m = x * p->multiplicand; stb_uint y = x >> 16; stb_uint bv = (m >> 24) + y; stb_uint av = (m + y) >> 12; bv &= p->b_mask; av &= p->table_mask; *b = bv; *a = av; } static unsigned long stb__perfect_rand(void) { static unsigned long stb__rand; stb__rand = stb__rand * 2147001325 + 715136305; return 0x31415926 ^ ((stb__rand >> 16) + (stb__rand << 16)); } typedef struct { unsigned short count; unsigned short b; unsigned short map; unsigned short *entries; } stb__slot; static int stb__slot_compare(const void *p, const void *q) { stb__slot *a = (stb__slot *) p; stb__slot *b = (stb__slot *) q; return a->count > b->count ? -1 : a->count < b->count; // sort large to small } int stb_perfect_create(stb_perfect *p, unsigned int *v, int n) { unsigned int buffer1[64], buffer2[64], buffer3[64], buffer4[64], buffer5[32]; unsigned short *as = (unsigned short *) stb_temp(buffer1, sizeof(*v)*n); unsigned short *bs = (unsigned short *) stb_temp(buffer2, sizeof(*v)*n); unsigned short *entries = (unsigned short *) stb_temp(buffer4, sizeof(*entries) * n); int size = 1 << stb_log2_ceil(n), bsize=8; int failure = 0,i,j,k; assert(n <= 32768); p->large_bmap = NULL; for(;;) { stb__slot *bcount = (stb__slot *) stb_temp(buffer3, sizeof(*bcount) * bsize); unsigned short *bloc = (unsigned short *) stb_temp(buffer5, sizeof(*bloc) * bsize); unsigned short *e; int bad=0; p->addend = stb__perfect_rand(); p->multiplicand = stb__perfect_rand() | 1; p->table_mask = size-1; p->b_mask = bsize-1; p->table = (stb_uint32 *) malloc(size * sizeof(*p->table)); for (i=0; i < bsize; ++i) { bcount[i].b = i; bcount[i].count = 0; bcount[i].map = 0; } for (i=0; i < n; ++i) { stb__perfect_prehash(p, v[i], as+i, bs+i); ++bcount[bs[i]].count; } qsort(bcount, bsize, sizeof(*bcount), stb__slot_compare); e = entries; // now setup up their entries index for (i=0; i < bsize; ++i) { bcount[i].entries = e; e += bcount[i].count; bcount[i].count = 0; bloc[bcount[i].b] = i; } // now fill them out for (i=0; i < n; ++i) { int b = bs[i]; int w = bloc[b]; bcount[w].entries[bcount[w].count++] = i; } stb_tempfree(buffer5,bloc); // verify for (i=0; i < bsize; ++i) for (j=0; j < bcount[i].count; ++j) assert(bs[bcount[i].entries[j]] == bcount[i].b); memset(p->table, 0, size*sizeof(*p->table)); // check if any b has duplicate a for (i=0; i < bsize; ++i) { if (bcount[i].count > 1) { for (j=0; j < bcount[i].count; ++j) { if (p->table[as[bcount[i].entries[j]]]) bad = 1; p->table[as[bcount[i].entries[j]]] = 1; } for (j=0; j < bcount[i].count; ++j) { p->table[as[bcount[i].entries[j]]] = 0; } if (bad) break; } } if (!bad) { // go through the bs and populate the table, first fit for (i=0; i < bsize; ++i) { if (bcount[i].count) { // go through the candidate table[b] values for (j=0; j < size; ++j) { // go through the a values and see if they fit for (k=0; k < bcount[i].count; ++k) { int a = as[bcount[i].entries[k]]; if (p->table[(a^j)&p->table_mask]) { break; // fails } } // if succeeded, accept if (k == bcount[i].count) { bcount[i].map = j; for (k=0; k < bcount[i].count; ++k) { int a = as[bcount[i].entries[k]]; p->table[(a^j)&p->table_mask] = 1; } break; } } if (j == size) break; // no match for i'th entry, so break out in failure } } if (i == bsize) { // success... fill out map if (bsize <= 16 && size <= 256) { p->large_bmap = NULL; for (i=0; i < bsize; ++i) p->small_bmap[bcount[i].b] = (stb_uint8) bcount[i].map; } else { p->large_bmap = (unsigned short *) malloc(sizeof(*p->large_bmap) * bsize); for (i=0; i < bsize; ++i) p->large_bmap[bcount[i].b] = bcount[i].map; } // initialize table to v[0], so empty slots will fail for (i=0; i < size; ++i) p->table[i] = v[0]; for (i=0; i < n; ++i) if (p->large_bmap) p->table[as[i] ^ p->large_bmap[bs[i]]] = v[i]; else p->table[as[i] ^ p->small_bmap[bs[i]]] = v[i]; // and now validate that none of them collided for (i=0; i < n; ++i) assert(stb_perfect_hash(p, v[i]) >= 0); stb_tempfree(buffer3, bcount); break; } } free(p->table); p->table = NULL; stb_tempfree(buffer3, bcount); ++failure; if (failure >= 4 && bsize < size) bsize *= 2; if (failure >= 8 && (failure & 3) == 0 && size < 4*n) { size *= 2; bsize *= 2; } if (failure == 6) { // make sure the input data is unique, so we don't infinite loop unsigned int *data = (unsigned int *) stb_temp(buffer3, n * sizeof(*data)); memcpy(data, v, sizeof(*data) * n); qsort(data, n, sizeof(*data), stb_intcmp(0)); for (i=1; i < n; ++i) { if (data[i] == data[i-1]) size = 0; // size is return value, so 0 it } stb_tempfree(buffer3, data); if (!size) break; } } if (failure > stb_perfect_hash_max_failures) stb_perfect_hash_max_failures = failure; stb_tempfree(buffer1, as); stb_tempfree(buffer2, bs); stb_tempfree(buffer4, entries); return size; } void stb_perfect_destroy(stb_perfect *p) { if (p->large_bmap) free(p->large_bmap); if (p->table ) free(p->table); p->large_bmap = NULL; p->table = NULL; p->b_mask = 0; p->table_mask = 0; } #endif ////////////////////////////////////////////////////////////////////////////// // // Perfect hash clients STB_EXTERN int stb_ischar(char s, char *set); #ifdef STB_DEFINE int stb_ischar(char c, char *set) { static unsigned char bit[8] = { 1,2,4,8,16,32,64,128 }; static stb_perfect p; static unsigned char (*tables)[256]; static char ** sets = NULL; int z = stb_perfect_hash(&p, (int) set); if (z < 0) { int i,k,n,j,f; // special code that means free all existing data if (set == NULL) { stb_arr_free(sets); free(tables); tables = NULL; stb_perfect_destroy(&p); return 0; } stb_arr_push(sets, set); stb_perfect_destroy(&p); n = stb_perfect_create(&p, (unsigned int *) (char **) sets, stb_arr_len(sets)); assert(n != 0); k = (n+7) >> 3; tables = (unsigned char (*)[256]) realloc(tables, sizeof(*tables) * k); memset(tables, 0, sizeof(*tables) * k); for (i=0; i < stb_arr_len(sets); ++i) { k = stb_perfect_hash(&p, (int) sets[i]); assert(k >= 0); n = k >> 3; f = bit[k&7]; for (j=0; !j || sets[i][j]; ++j) { tables[n][(unsigned char) sets[i][j]] |= f; } } z = stb_perfect_hash(&p, (int) set); } return tables[z >> 3][(unsigned char) c] & bit[z & 7]; } #endif ////////////////////////////////////////////////////////////////////////////// // // Instantiated data structures // // This is an attempt to implement a templated data structure. // // Hash table: call stb_define_hash(TYPE,N,KEY,K1,K2,HASH,VALUE) // TYPE -- will define a structure type containing the hash table // N -- the name, will prefix functions named: // N create // N destroy // N get // N set, N add, N update, // N remove // KEY -- the type of the key. 'x == y' must be valid // K1,K2 -- keys never used by the app, used as flags in the hashtable // HASH -- a piece of code ending with 'return' that hashes key 'k' // VALUE -- the type of the value. 'x = y' must be valid // // Note that stb_define_hash_base can be used to define more sophisticated // hash tables, e.g. those that make copies of the key or use special // comparisons (e.g. strcmp). #define STB_(prefix,name) stb__##prefix##name #define STB__(prefix,name) prefix##name #define STB__use(x) x #define STB__skip(x) #define stb_declare_hash(PREFIX,TYPE,N,KEY,VALUE) \ typedef struct stb__st_##TYPE TYPE;\ PREFIX int STB__(N, init)(TYPE *h, int count);\ PREFIX int STB__(N, memory_usage)(TYPE *h);\ PREFIX TYPE * STB__(N, create)(void);\ PREFIX TYPE * STB__(N, copy)(TYPE *h);\ PREFIX void STB__(N, destroy)(TYPE *h);\ PREFIX int STB__(N,get_flag)(TYPE *a, KEY k, VALUE *v);\ PREFIX VALUE STB__(N,get)(TYPE *a, KEY k);\ PREFIX int STB__(N, set)(TYPE *a, KEY k, VALUE v);\ PREFIX int STB__(N, add)(TYPE *a, KEY k, VALUE v);\ PREFIX int STB__(N, update)(TYPE*a,KEY k,VALUE v);\ PREFIX int STB__(N, remove)(TYPE *a, KEY k, VALUE *v); #define STB_nocopy(x) (x) #define STB_nodelete(x) 0 #define STB_nofields #define STB_nonullvalue(x) #define STB_nullvalue(x) x #define STB_safecompare(x) x #define STB_nosafe(x) #define STB_noprefix #ifdef __GNUC__ #define STB__nogcc(x) #else #define STB__nogcc(x) x #endif #define stb_define_hash_base(PREFIX,TYPE,FIELDS,N,NC,LOAD_FACTOR, \ KEY,EMPTY,DEL,COPY,DISPOSE,SAFE, \ VCOMPARE,CCOMPARE,HASH, \ VALUE,HASVNULL,VNULL) \ \ typedef struct \ { \ KEY k; \ VALUE v; \ } STB_(N,_hashpair); \ \ STB__nogcc( typedef struct stb__st_##TYPE TYPE; ) \ struct stb__st_##TYPE { \ FIELDS \ STB_(N,_hashpair) *table; \ unsigned int mask; \ int count, limit; \ int deleted; \ \ int delete_threshhold; \ int grow_threshhold; \ int shrink_threshhold; \ unsigned char alloced, has_empty, has_del; \ VALUE ev; VALUE dv; \ }; \ \ static unsigned int STB_(N, hash)(KEY k) \ { \ HASH \ } \ \ PREFIX int STB__(N, init)(TYPE *h, int count) \ { \ int i; \ if (count < 4) count = 4; \ h->limit = count; \ h->count = 0; \ h->mask = count-1; \ h->deleted = 0; \ h->grow_threshhold = (int) (count * LOAD_FACTOR); \ h->has_empty = h->has_del = 0; \ h->alloced = 0; \ if (count <= 64) \ h->shrink_threshhold = 0; \ else \ h->shrink_threshhold = (int) (count * (LOAD_FACTOR/2.25)); \ h->delete_threshhold = (int) (count * (1-LOAD_FACTOR)/2); \ h->table = (STB_(N,_hashpair)*) malloc(sizeof(h->table[0]) * count); \ if (h->table == NULL) return 0; \ /* ideally this gets turned into a memset32 automatically */ \ for (i=0; i < count; ++i) \ h->table[i].k = EMPTY; \ return 1; \ } \ \ PREFIX int STB__(N, memory_usage)(TYPE *h) \ { \ return sizeof(*h) + h->limit * sizeof(h->table[0]); \ } \ \ PREFIX TYPE * STB__(N, create)(void) \ { \ TYPE *h = (TYPE *) malloc(sizeof(*h)); \ if (h) { \ if (STB__(N, init)(h, 16)) \ h->alloced = 1; \ else { free(h); h=NULL; } \ } \ return h; \ } \ \ PREFIX void STB__(N, destroy)(TYPE *a) \ { \ int i; \ for (i=0; i < a->limit; ++i) \ if (!CCOMPARE(a->table[i].k,EMPTY) && !CCOMPARE(a->table[i].k, DEL)) \ DISPOSE(a->table[i].k); \ free(a->table); \ if (a->alloced) \ free(a); \ } \ \ static void STB_(N, rehash)(TYPE *a, int count); \ \ PREFIX int STB__(N,get_flag)(TYPE *a, KEY k, VALUE *v) \ { \ unsigned int h = STB_(N, hash)(k); \ unsigned int n = h & a->mask, s; \ if (CCOMPARE(k,EMPTY)){ if (a->has_empty) *v = a->ev; return a->has_empty;}\ if (CCOMPARE(k,DEL)) { if (a->has_del ) *v = a->dv; return a->has_del; }\ if (CCOMPARE(a->table[n].k,EMPTY)) return 0; \ SAFE(if (!CCOMPARE(a->table[n].k,DEL))) \ if (VCOMPARE(a->table[n].k,k)) { *v = a->table[n].v; return 1; } \ s = stb_rehash(h) | 1; \ for(;;) { \ n = (n + s) & a->mask; \ if (CCOMPARE(a->table[n].k,EMPTY)) return 0; \ SAFE(if (CCOMPARE(a->table[n].k,DEL)) continue;) \ if (VCOMPARE(a->table[n].k,k)) \ { *v = a->table[n].v; return 1; } \ } \ } \ \ HASVNULL( \ PREFIX VALUE STB__(N,get)(TYPE *a, KEY k) \ { \ VALUE v; \ if (STB__(N,get_flag)(a,k,&v)) return v; \ else return VNULL; \ } \ ) \ \ PREFIX int STB__(N,getkey)(TYPE *a, KEY k, KEY *kout) \ { \ unsigned int h = STB_(N, hash)(k); \ unsigned int n = h & a->mask, s; \ if (CCOMPARE(k,EMPTY)||CCOMPARE(k,DEL)) return 0; \ if (CCOMPARE(a->table[n].k,EMPTY)) return 0; \ SAFE(if (!CCOMPARE(a->table[n].k,DEL))) \ if (VCOMPARE(a->table[n].k,k)) { *kout = a->table[n].k; return 1; } \ s = stb_rehash(h) | 1; \ for(;;) { \ n = (n + s) & a->mask; \ if (CCOMPARE(a->table[n].k,EMPTY)) return 0; \ SAFE(if (CCOMPARE(a->table[n].k,DEL)) continue;) \ if (VCOMPARE(a->table[n].k,k)) \ { *kout = a->table[n].k; return 1; } \ } \ } \ \ static int STB_(N,addset)(TYPE *a, KEY k, VALUE v, \ int allow_new, int allow_old, int copy) \ { \ unsigned int h = STB_(N, hash)(k); \ unsigned int n = h & a->mask; \ int b = -1; \ if (CCOMPARE(k,EMPTY)) { \ if (a->has_empty ? allow_old : allow_new) { \ n=a->has_empty; a->ev = v; a->has_empty = 1; return !n; \ } else return 0; \ } \ if (CCOMPARE(k,DEL)) { \ if (a->has_del ? allow_old : allow_new) { \ n=a->has_del; a->dv = v; a->has_del = 1; return !n; \ } else return 0; \ } \ if (!CCOMPARE(a->table[n].k, EMPTY)) { \ unsigned int s; \ if (CCOMPARE(a->table[n].k, DEL)) \ b = n; \ else if (VCOMPARE(a->table[n].k,k)) { \ if (allow_old) \ a->table[n].v = v; \ return !allow_new; \ } \ s = stb_rehash(h) | 1; \ for(;;) { \ n = (n + s) & a->mask; \ if (CCOMPARE(a->table[n].k, EMPTY)) break; \ if (CCOMPARE(a->table[n].k, DEL)) { \ if (b < 0) b = n; \ } else if (VCOMPARE(a->table[n].k,k)) { \ if (allow_old) \ a->table[n].v = v; \ return !allow_new; \ } \ } \ } \ if (!allow_new) return 0; \ if (b < 0) b = n; else --a->deleted; \ a->table[b].k = copy ? COPY(k) : k; \ a->table[b].v = v; \ ++a->count; \ if (a->count > a->grow_threshhold) \ STB_(N,rehash)(a, a->limit*2); \ return 1; \ } \ \ PREFIX int STB__(N, set)(TYPE *a, KEY k, VALUE v){return STB_(N,addset)(a,k,v,1,1,1);}\ PREFIX int STB__(N, add)(TYPE *a, KEY k, VALUE v){return STB_(N,addset)(a,k,v,1,0,1);}\ PREFIX int STB__(N, update)(TYPE*a,KEY k,VALUE v){return STB_(N,addset)(a,k,v,0,1,1);}\ \ PREFIX int STB__(N, remove)(TYPE *a, KEY k, VALUE *v) \ { \ unsigned int h = STB_(N, hash)(k); \ unsigned int n = h & a->mask, s; \ if (CCOMPARE(k,EMPTY)) { if (a->has_empty) { if(v)*v = a->ev; a->has_empty=0; return 1; } return 0; } \ if (CCOMPARE(k,DEL)) { if (a->has_del ) { if(v)*v = a->dv; a->has_del =0; return 1; } return 0; } \ if (CCOMPARE(a->table[n].k,EMPTY)) return 0; \ if (SAFE(CCOMPARE(a->table[n].k,DEL) || ) !VCOMPARE(a->table[n].k,k)) { \ s = stb_rehash(h) | 1; \ for(;;) { \ n = (n + s) & a->mask; \ if (CCOMPARE(a->table[n].k,EMPTY)) return 0; \ SAFE(if (CCOMPARE(a->table[n].k, DEL)) continue;) \ if (VCOMPARE(a->table[n].k,k)) break; \ } \ } \ DISPOSE(a->table[n].k); \ a->table[n].k = DEL; \ --a->count; \ ++a->deleted; \ if (v != NULL) \ *v = a->table[n].v; \ if (a->count < a->shrink_threshhold) \ STB_(N, rehash)(a, a->limit >> 1); \ else if (a->deleted > a->delete_threshhold) \ STB_(N, rehash)(a, a->limit); \ return 1; \ } \ \ PREFIX TYPE * STB__(NC, copy)(TYPE *a) \ { \ int i; \ TYPE *h = (TYPE *) malloc(sizeof(*h)); \ if (!h) return NULL; \ if (!STB__(N, init)(h, a->limit)) { free(h); return NULL; } \ h->count = a->count; \ h->deleted = a->deleted; \ h->alloced = 1; \ h->ev = a->ev; h->dv = a->dv; \ h->has_empty = a->has_empty; h->has_del = a->has_del; \ memcpy(h->table, a->table, h->limit * sizeof(h->table[0])); \ for (i=0; i < a->limit; ++i) \ if (!CCOMPARE(h->table[i].k,EMPTY) && !CCOMPARE(h->table[i].k,DEL)) \ h->table[i].k = COPY(h->table[i].k); \ return h; \ } \ \ static void STB_(N, rehash)(TYPE *a, int count) \ { \ int i; \ TYPE b; \ STB__(N, init)(&b, count); \ for (i=0; i < a->limit; ++i) \ if (!CCOMPARE(a->table[i].k,EMPTY) && !CCOMPARE(a->table[i].k,DEL)) \ STB_(N,addset)(&b, a->table[i].k, a->table[i].v,1,1,0); \ free(a->table); \ a->table = b.table; \ a->mask = b.mask; \ a->count = b.count; \ a->limit = b.limit; \ a->deleted = b.deleted; \ a->delete_threshhold = b.delete_threshhold; \ a->grow_threshhold = b.grow_threshhold; \ a->shrink_threshhold = b.shrink_threshhold; \ } #define STB_equal(a,b) ((a) == (b)) #define stb_define_hash(TYPE,N,KEY,EMPTY,DEL,HASH,VALUE) \ stb_define_hash_base(STB_noprefix, TYPE,STB_nofields,N,NC,0.85f, \ KEY,EMPTY,DEL,STB_nocopy,STB_nodelete,STB_nosafe, \ STB_equal,STB_equal,HASH, \ VALUE,STB_nonullvalue,0) #define stb_define_hash_vnull(TYPE,N,KEY,EMPTY,DEL,HASH,VALUE,VNULL) \ stb_define_hash_base(STB_noprefix, TYPE,STB_nofields,N,NC,0.85f, \ KEY,EMPTY,DEL,STB_nocopy,STB_nodelete,STB_nosafe, \ STB_equal,STB_equal,HASH, \ VALUE,STB_nullvalue,VNULL) ////////////////////////////////////////////////////////////////////////////// // // stb_ptrmap // // An stb_ptrmap data structure is an O(1) hash table between pointers. One // application is to let you store "extra" data associated with pointers, // which is why it was originally called stb_extra. stb_declare_hash(STB_EXTERN, stb_ptrmap, stb_ptrmap_, void *, void *) stb_declare_hash(STB_EXTERN, stb_idict, stb_idict_, stb_int32, stb_int32) STB_EXTERN void stb_ptrmap_delete(stb_ptrmap *e, void (*free_func)(void *)); STB_EXTERN stb_ptrmap *stb_ptrmap_new(void); STB_EXTERN stb_idict * stb_idict_new_size(int size); STB_EXTERN void stb_idict_remove_all(stb_idict *e); #ifdef STB_DEFINE #define STB_EMPTY ((void *) 2) #define STB_EDEL ((void *) 6) stb_define_hash_base(STB_noprefix,stb_ptrmap, STB_nofields, stb_ptrmap_,stb_ptrmap_,0.85f, void *,STB_EMPTY,STB_EDEL,STB_nocopy,STB_nodelete,STB_nosafe, STB_equal,STB_equal,return stb_hashptr(k);, void *,STB_nullvalue,NULL) stb_ptrmap *stb_ptrmap_new(void) { return stb_ptrmap_create(); } void stb_ptrmap_delete(stb_ptrmap *e, void (*free_func)(void *)) { int i; if (free_func) for (i=0; i < e->limit; ++i) if (e->table[i].k != STB_EMPTY && e->table[i].k != STB_EDEL) { if (free_func == free) free(e->table[i].v); // allow STB_MALLOC_WRAPPER to operate else free_func(e->table[i].v); } stb_ptrmap_destroy(e); } // extra fields needed for stua_dict #define STB_IEMPTY ((int) 1) #define STB_IDEL ((int) 3) stb_define_hash_base(STB_noprefix, stb_idict, short type; short gc; STB_nofields, stb_idict_,stb_idict_,0.85f, stb_int32,STB_IEMPTY,STB_IDEL,STB_nocopy,STB_nodelete,STB_nosafe, STB_equal,STB_equal, return stb_rehash_improved(k);,stb_int32,STB_nonullvalue,0) stb_idict * stb_idict_new_size(int size) { stb_idict *e = (stb_idict *) malloc(sizeof(*e)); if (e) { if (!stb_is_pow2(size)) size = 1 << stb_log2_ceil(size); stb_idict_init(e, size); e->alloced = 1; } return e; } void stb_idict_remove_all(stb_idict *e) { int n; for (n=0; n < e->limit; ++n) e->table[n].k = STB_IEMPTY; e->has_empty = e->has_del = 0; } #endif ////////////////////////////////////////////////////////////////////////////// // // stb_sparse_ptr_matrix // // An stb_ptrmap data structure is an O(1) hash table storing an arbitrary // block of data for a given pair of pointers. // // If create=0, returns typedef struct stb__st_stb_spmatrix stb_spmatrix; STB_EXTERN stb_spmatrix * stb_sparse_ptr_matrix_new(int val_size); STB_EXTERN void stb_sparse_ptr_matrix_free(stb_spmatrix *z); STB_EXTERN void * stb_sparse_ptr_matrix_get(stb_spmatrix *z, void *a, void *b, int create); #ifdef STB_DEFINE typedef struct { void *a; void *b; } stb__ptrpair; static stb__ptrpair stb__ptrpair_empty = { (void *) 1, (void *) 1 }; static stb__ptrpair stb__ptrpair_del = { (void *) 2, (void *) 2 }; #define STB__equal_ptrpair(x,y) ((x).a == (y).a && (x).b == (y).b) stb_define_hash_base(static, stb_spmatrix, int val_size; void *arena;, stb__spmatrix_,stb__spmatrix_, 0.85, stb__ptrpair, stb__ptrpair_empty, stb__ptrpair_del, STB_nocopy, STB_nodelete, STB_nosafe, STB__equal_ptrpair, STB__equal_ptrpair, return stb_rehash(stb_hashptr(k.a))+stb_hashptr(k.b);, void *, STB_nullvalue, 0) stb_spmatrix *stb_sparse_ptr_matrix_new(int val_size) { stb_spmatrix *m = stb__spmatrix_create(); if (m) m->val_size = val_size; if (m) m->arena = stb_malloc_global(1); return m; } void stb_sparse_ptr_matrix_free(stb_spmatrix *z) { if (z->arena) stb_free(z->arena); stb__spmatrix_destroy(z); } void *stb_sparse_ptr_matrix_get(stb_spmatrix *z, void *a, void *b, int create) { stb__ptrpair t = { a,b }; void *data = stb__spmatrix_get(z, t); if (!data && create) { data = stb_malloc_raw(z->arena, z->val_size); if (!data) return NULL; memset(data, 0, z->val_size); stb__spmatrix_add(z, t, data); } return data; } #endif ////////////////////////////////////////////////////////////////////////////// // // SDICT: Hash Table for Strings (symbol table) // // if "use_arena=1", then strings will be copied // into blocks and never freed until the sdict is freed; // otherwise they're malloc()ed and free()d on the fly. // (specify use_arena=1 if you never stb_sdict_remove) stb_declare_hash(STB_EXTERN, stb_sdict, stb_sdict_, char *, void *) STB_EXTERN stb_sdict * stb_sdict_new(int use_arena); STB_EXTERN stb_sdict * stb_sdict_copy(stb_sdict*); STB_EXTERN void stb_sdict_delete(stb_sdict *); STB_EXTERN void * stb_sdict_change(stb_sdict *, char *str, void *p); STB_EXTERN int stb_sdict_count(stb_sdict *d); #define stb_sdict_for(d,i,q,z) \ for(i=0; i < (d)->limit ? q=(d)->table[i].k,z=(d)->table[i].v,1 : 0; ++i) \ if (q==NULL||q==(void *) 1);else // reversed makes macro friendly #ifdef STB_DEFINE #define STB_DEL ((void *) 1) #define STB_SDEL ((char *) 1) #define stb_sdict__copy(x) \ strcpy(a->arena ? stb_malloc_string(a->arena, strlen(x)+1) \ : (char *) malloc(strlen(x)+1), x) #define stb_sdict__dispose(x) if (!a->arena) free(x) stb_define_hash_base(STB_noprefix, stb_sdict, void*arena;, stb_sdict_,stb_sdictinternal_, 0.85f, char *, NULL, STB_SDEL, stb_sdict__copy, stb_sdict__dispose, STB_safecompare, !strcmp, STB_equal, return stb_hash(k);, void *, STB_nullvalue, NULL) int stb_sdict_count(stb_sdict *a) { return a->count; } stb_sdict * stb_sdict_new(int use_arena) { stb_sdict *d = stb_sdict_create(); if (d == NULL) return NULL; d->arena = use_arena ? stb_malloc_global(1) : NULL; return d; } stb_sdict* stb_sdict_copy(stb_sdict *old) { stb_sdict *n; void *old_arena = old->arena; void *new_arena = old_arena ? stb_malloc_global(1) : NULL; old->arena = new_arena; n = stb_sdictinternal_copy(old); old->arena = old_arena; if (n) n->arena = new_arena; else if (new_arena) stb_free(new_arena); return n; } void stb_sdict_delete(stb_sdict *d) { if (d->arena) stb_free(d->arena); stb_sdict_destroy(d); } void * stb_sdict_change(stb_sdict *d, char *str, void *p) { void *q = stb_sdict_get(d, str); stb_sdict_set(d, str, p); return q; } #endif ////////////////////////////////////////////////////////////////////////////// // // Instantiated data structures // // This is an attempt to implement a templated data structure. // What you do is define a struct foo, and then include several // pointer fields to struct foo in your struct. Then you call // the instantiator, which creates the functions that implement // the data structure. This requires massive undebuggable #defines, // so we limit the cases where we do this. // // AA tree is an encoding of a 2-3 tree whereas RB trees encode a 2-3-4 tree; // much simpler code due to fewer cases. #define stb__bst_parent(x) x #define stb__bst_noparent(x) #define stb_bst_fields(N) \ *STB_(N,left), *STB_(N,right); \ unsigned char STB_(N,level) #define stb_bst_fields_parent(N) \ *STB_(N,left), *STB_(N,right), *STB_(N,parent); \ unsigned char STB_(N,level) #define STB__level(N,x) ((x) ? (x)->STB_(N,level) : 0) #define stb_bst_base(TYPE, N, TREE, M, compare, PAR) \ \ static int STB_(N,_compare)(TYPE *p, TYPE *q) \ { \ compare \ } \ \ static void STB_(N,setleft)(TYPE *q, TYPE *v) \ { \ q->STB_(N,left) = v; \ PAR(if (v) v->STB_(N,parent) = q;) \ } \ \ static void STB_(N,setright)(TYPE *q, TYPE *v) \ { \ q->STB_(N,right) = v; \ PAR(if (v) v->STB_(N,parent) = q;) \ } \ \ static TYPE *STB_(N,skew)(TYPE *q) \ { \ if (q == NULL) return q; \ if (q->STB_(N,left) \ && q->STB_(N,left)->STB_(N,level) == q->STB_(N,level)) { \ TYPE *p = q->STB_(N,left); \ STB_(N,setleft)(q, p->STB_(N,right)); \ STB_(N,setright)(p, q); \ return p; \ } \ return q; \ } \ \ static TYPE *STB_(N,split)(TYPE *p) \ { \ TYPE *q = p->STB_(N,right); \ if (q && q->STB_(N,right) \ && q->STB_(N,right)->STB_(N,level) == p->STB_(N,level)) { \ STB_(N,setright)(p, q->STB_(N,left)); \ STB_(N,setleft)(q,p); \ ++q->STB_(N,level); \ return q; \ } \ return p; \ } \ \ TYPE *STB__(N,insert)(TYPE *tree, TYPE *item) \ { \ int c; \ if (tree == NULL) { \ item->STB_(N,left) = NULL; \ item->STB_(N,right) = NULL; \ item->STB_(N,level) = 1; \ PAR(item->STB_(N,parent) = NULL;) \ return item; \ } \ c = STB_(N,_compare)(item,tree); \ if (c == 0) { \ if (item != tree) { \ STB_(N,setleft)(item, tree->STB_(N,left)); \ STB_(N,setright)(item, tree->STB_(N,right)); \ item->STB_(N,level) = tree->STB_(N,level); \ PAR(item->STB_(N,parent) = NULL;) \ } \ return item; \ } \ if (c < 0) \ STB_(N,setleft )(tree, STB__(N,insert)(tree->STB_(N,left), item)); \ else \ STB_(N,setright)(tree, STB__(N,insert)(tree->STB_(N,right), item)); \ tree = STB_(N,skew)(tree); \ tree = STB_(N,split)(tree); \ PAR(tree->STB_(N,parent) = NULL;) \ return tree; \ } \ \ TYPE *STB__(N,remove)(TYPE *tree, TYPE *item) \ { \ static TYPE *delnode, *leaf, *restore; \ if (tree == NULL) return NULL; \ leaf = tree; \ if (STB_(N,_compare)(item, tree) < 0) { \ STB_(N,setleft)(tree, STB__(N,remove)(tree->STB_(N,left), item)); \ } else { \ TYPE *r; \ delnode = tree; \ r = STB__(N,remove)(tree->STB_(N,right), item); \ /* maybe move 'leaf' up to this location */ \ if (restore == tree) { tree = leaf; leaf = restore = NULL; } \ STB_(N,setright)(tree,r); \ assert(tree->STB_(N,right) != tree); \ } \ if (tree == leaf) { \ if (delnode == item) { \ tree = tree->STB_(N,right); \ assert(leaf->STB_(N,left) == NULL); \ /* move leaf (the right sibling) up to delnode */ \ STB_(N,setleft )(leaf, item->STB_(N,left )); \ STB_(N,setright)(leaf, item->STB_(N,right)); \ leaf->STB_(N,level) = item->STB_(N,level); \ if (leaf != item) \ restore = delnode; \ } \ delnode = NULL; \ } else { \ if (STB__level(N,tree->STB_(N,left) ) < tree->STB_(N,level)-1 || \ STB__level(N,tree->STB_(N,right)) < tree->STB_(N,level)-1) { \ --tree->STB_(N,level); \ if (STB__level(N,tree->STB_(N,right)) > tree->STB_(N,level)) \ tree->STB_(N,right)->STB_(N,level) = tree->STB_(N,level); \ tree = STB_(N,skew)(tree); \ STB_(N,setright)(tree, STB_(N,skew)(tree->STB_(N,right))); \ if (tree->STB_(N,right)) \ STB_(N,setright)(tree->STB_(N,right), \ STB_(N,skew)(tree->STB_(N,right)->STB_(N,right))); \ tree = STB_(N,split)(tree); \ if (tree->STB_(N,right)) \ STB_(N,setright)(tree, STB_(N,split)(tree->STB_(N,right))); \ } \ } \ PAR(if (tree) tree->STB_(N,parent) = NULL;) \ return tree; \ } \ \ TYPE *STB__(N,last)(TYPE *tree) \ { \ if (tree) \ while (tree->STB_(N,right)) tree = tree->STB_(N,right); \ return tree; \ } \ \ TYPE *STB__(N,first)(TYPE *tree) \ { \ if (tree) \ while (tree->STB_(N,left)) tree = tree->STB_(N,left); \ return tree; \ } \ \ TYPE *STB__(N,next)(TYPE *tree, TYPE *item) \ { \ TYPE *next = NULL; \ if (item->STB_(N,right)) \ return STB__(N,first)(item->STB_(N,right)); \ PAR( \ while(item->STB_(N,parent)) { \ TYPE *up = item->STB_(N,parent); \ if (up->STB_(N,left) == item) return up; \ item = up; \ } \ return NULL; \ ) \ while (tree != item) { \ if (STB_(N,_compare)(item, tree) < 0) { \ next = tree; \ tree = tree->STB_(N,left); \ } else { \ tree = tree->STB_(N,right); \ } \ } \ return next; \ } \ \ TYPE *STB__(N,prev)(TYPE *tree, TYPE *item) \ { \ TYPE *next = NULL; \ if (item->STB_(N,left)) \ return STB__(N,last)(item->STB_(N,left)); \ PAR( \ while(item->STB_(N,parent)) { \ TYPE *up = item->STB_(N,parent); \ if (up->STB_(N,right) == item) return up; \ item = up; \ } \ return NULL; \ ) \ while (tree != item) { \ if (STB_(N,_compare)(item, tree) < 0) { \ tree = tree->STB_(N,left); \ } else { \ next = tree; \ tree = tree->STB_(N,right); \ } \ } \ return next; \ } \ \ STB__DEBUG( \ void STB__(N,_validate)(TYPE *tree, int root) \ { \ if (tree == NULL) return; \ PAR(if(root) assert(tree->STB_(N,parent) == NULL);) \ assert(STB__level(N,tree->STB_(N,left) ) == tree->STB_(N,level)-1); \ assert(STB__level(N,tree->STB_(N,right)) <= tree->STB_(N,level)); \ assert(STB__level(N,tree->STB_(N,right)) >= tree->STB_(N,level)-1); \ if (tree->STB_(N,right)) { \ assert(STB__level(N,tree->STB_(N,right)->STB_(N,right)) \ != tree->STB_(N,level)); \ PAR(assert(tree->STB_(N,right)->STB_(N,parent) == tree);) \ } \ PAR(if(tree->STB_(N,left)) assert(tree->STB_(N,left)->STB_(N,parent) == tree);) \ STB__(N,_validate)(tree->STB_(N,left) ,0); \ STB__(N,_validate)(tree->STB_(N,right),0); \ } \ ) \ \ typedef struct \ { \ TYPE *root; \ } TREE; \ \ void STB__(M,Insert)(TREE *tree, TYPE *item) \ { tree->root = STB__(N,insert)(tree->root, item); } \ void STB__(M,Remove)(TREE *tree, TYPE *item) \ { tree->root = STB__(N,remove)(tree->root, item); } \ TYPE *STB__(M,Next)(TREE *tree, TYPE *item) \ { return STB__(N,next)(tree->root, item); } \ TYPE *STB__(M,Prev)(TREE *tree, TYPE *item) \ { return STB__(N,prev)(tree->root, item); } \ TYPE *STB__(M,First)(TREE *tree) { return STB__(N,first)(tree->root); } \ TYPE *STB__(M,Last) (TREE *tree) { return STB__(N,last) (tree->root); } \ void STB__(M,Init)(TREE *tree) { tree->root = NULL; } #define stb_bst_find(N,tree,fcompare) \ { \ int c; \ while (tree != NULL) { \ fcompare \ if (c == 0) return tree; \ if (c < 0) tree = tree->STB_(N,left); \ else tree = tree->STB_(N,right); \ } \ return NULL; \ } #define stb_bst_raw(TYPE,N,TREE,M,vfield,VTYPE,compare,PAR) \ stb_bst_base(TYPE,N,TREE,M, \ VTYPE a = p->vfield; VTYPE b = q->vfield; return (compare);, PAR ) \ \ TYPE *STB__(N,find)(TYPE *tree, VTYPE a) \ stb_bst_find(N,tree,VTYPE b = tree->vfield; c = (compare);) \ TYPE *STB__(M,Find)(TREE *tree, VTYPE a) \ { return STB__(N,find)(tree->root, a); } #define stb_bst(TYPE,N,TREE,M,vfield,VTYPE,compare) \ stb_bst_raw(TYPE,N,TREE,M,vfield,VTYPE,compare,stb__bst_noparent) #define stb_bst_parent(TYPE,N,TREE,M,vfield,VTYPE,compare) \ stb_bst_raw(TYPE,N,TREE,M,vfield,VTYPE,compare,stb__bst_parent) ////////////////////////////////////////////////////////////////////////////// // // Pointer Nulling // // This lets you automatically NULL dangling pointers to "registered" // objects. Note that you have to make sure you call the appropriate // functions when you free or realloc blocks of memory that contain // pointers or pointer targets. stb.h can automatically do this for // stb_arr, or for all frees/reallocs if it's wrapping them. // #ifdef STB_NPTR STB_EXTERN void stb_nptr_set(void *address_of_pointer, void *value_to_write); STB_EXTERN void stb_nptr_didset(void *address_of_pointer); STB_EXTERN void stb_nptr_didfree(void *address_being_freed, int len); STB_EXTERN void stb_nptr_free(void *address_being_freed, int len); STB_EXTERN void stb_nptr_didrealloc(void *new_address, void *old_address, int len); STB_EXTERN void stb_nptr_recache(void); // recache all known pointers // do this after pointer sets outside your control, slow #ifdef STB_DEFINE // for fast updating on free/realloc, we need to be able to find // all the objects (pointers and targets) within a given block; // this precludes hashing // we use a three-level hierarchy of memory to minimize storage: // level 1: 65536 pointers to stb__memory_node (always uses 256 KB) // level 2: each stb__memory_node represents a 64K block of memory // with 256 stb__memory_leafs (worst case 64MB) // level 3: each stb__memory_leaf represents 256 bytes of memory // using a list of target locations and a list of pointers // (which are hopefully fairly short normally!) // this approach won't work in 64-bit, which has a much larger address // space. need to redesign #define STB__NPTR_ROOT_LOG2 16 #define STB__NPTR_ROOT_NUM (1 << STB__NPTR_ROOT_LOG2) #define STB__NPTR_ROOT_SHIFT (32 - STB__NPTR_ROOT_LOG2) #define STB__NPTR_NODE_LOG2 5 #define STB__NPTR_NODE_NUM (1 << STB__NPTR_NODE_LOG2) #define STB__NPTR_NODE_MASK (STB__NPTR_NODE_NUM-1) #define STB__NPTR_NODE_SHIFT (STB__NPTR_ROOT_SHIFT - STB__NPTR_NODE_LOG2) #define STB__NPTR_NODE_OFFSET(x) (((x) >> STB__NPTR_NODE_SHIFT) & STB__NPTR_NODE_MASK) typedef struct stb__st_nptr { void *ptr; // address of actual pointer struct stb__st_nptr *next; // next pointer with same target struct stb__st_nptr **prev; // prev pointer with same target, address of 'next' field (or first) struct stb__st_nptr *next_in_block; } stb__nptr; typedef struct stb__st_nptr_target { void *ptr; // address of target stb__nptr *first; // address of first nptr pointing to this struct stb__st_nptr_target *next_in_block; } stb__nptr_target; typedef struct { stb__nptr *pointers; stb__nptr_target *targets; } stb__memory_leaf; typedef struct { stb__memory_leaf *children[STB__NPTR_NODE_NUM]; } stb__memory_node; stb__memory_node *stb__memtab_root[STB__NPTR_ROOT_NUM]; static stb__memory_leaf *stb__nptr_find_leaf(void *mem) { stb_uint32 address = (stb_uint32) mem; stb__memory_node *z = stb__memtab_root[address >> STB__NPTR_ROOT_SHIFT]; if (z) return z->children[STB__NPTR_NODE_OFFSET(address)]; else return NULL; } static void * stb__nptr_alloc(int size) { return stb__realloc_raw(0,size); } static void stb__nptr_free(void *p) { stb__realloc_raw(p,0); } static stb__memory_leaf *stb__nptr_make_leaf(void *mem) { stb_uint32 address = (stb_uint32) mem; stb__memory_node *z = stb__memtab_root[address >> STB__NPTR_ROOT_SHIFT]; stb__memory_leaf *f; if (!z) { int i; z = (stb__memory_node *) stb__nptr_alloc(sizeof(*stb__memtab_root[0])); stb__memtab_root[address >> STB__NPTR_ROOT_SHIFT] = z; for (i=0; i < 256; ++i) z->children[i] = 0; } f = (stb__memory_leaf *) stb__nptr_alloc(sizeof(*f)); z->children[STB__NPTR_NODE_OFFSET(address)] = f; f->pointers = NULL; f->targets = NULL; return f; } static stb__nptr_target *stb__nptr_find_target(void *target, int force) { stb__memory_leaf *p = stb__nptr_find_leaf(target); if (p) { stb__nptr_target *t = p->targets; while (t) { if (t->ptr == target) return t; t = t->next_in_block; } } if (force) { stb__nptr_target *t = (stb__nptr_target*) stb__nptr_alloc(sizeof(*t)); if (!p) p = stb__nptr_make_leaf(target); t->ptr = target; t->first = NULL; t->next_in_block = p->targets; p->targets = t; return t; } else return NULL; } static stb__nptr *stb__nptr_find_pointer(void *ptr, int force) { stb__memory_leaf *p = stb__nptr_find_leaf(ptr); if (p) { stb__nptr *t = p->pointers; while (t) { if (t->ptr == ptr) return t; t = t->next_in_block; } } if (force) { stb__nptr *t = (stb__nptr *) stb__nptr_alloc(sizeof(*t)); if (!p) p = stb__nptr_make_leaf(ptr); t->ptr = ptr; t->next = NULL; t->prev = NULL; t->next_in_block = p->pointers; p->pointers = t; return t; } else return NULL; } void stb_nptr_set(void *address_of_pointer, void *value_to_write) { if (*(void **)address_of_pointer != value_to_write) { *(void **) address_of_pointer = value_to_write; stb_nptr_didset(address_of_pointer); } } void stb_nptr_didset(void *address_of_pointer) { // first unlink from old chain void *new_address; stb__nptr *p = stb__nptr_find_pointer(address_of_pointer, 1); // force building if doesn't exist if (p->prev) { // if p->prev is NULL, we just built it, or it was NULL *(p->prev) = p->next; if (p->next) p->next->prev = p->prev; } // now add to new chain new_address = *(void **)address_of_pointer; if (new_address != NULL) { stb__nptr_target *t = stb__nptr_find_target(new_address, 1); p->next = t->first; if (p->next) p->next->prev = &p->next; p->prev = &t->first; t->first = p; } else { p->prev = NULL; p->next = NULL; } } void stb__nptr_block(void *address, int len, void (*function)(stb__memory_leaf *f, int datum, void *start, void *end), int datum) { void *end_address = (void *) ((char *) address + len - 1); stb__memory_node *n; stb_uint32 start = (stb_uint32) address; stb_uint32 end = start + len - 1; int b0 = start >> STB__NPTR_ROOT_SHIFT; int b1 = end >> STB__NPTR_ROOT_SHIFT; int b=b0,i,e0,e1; e0 = STB__NPTR_NODE_OFFSET(start); if (datum <= 0) { // first block n = stb__memtab_root[b0]; if (n) { if (b0 != b1) e1 = STB__NPTR_NODE_NUM-1; else e1 = STB__NPTR_NODE_OFFSET(end); for (i=e0; i <= e1; ++i) if (n->children[i]) function(n->children[i], datum, address, end_address); } if (b1 > b0) { // blocks other than the first and last block for (b=b0+1; b < b1; ++b) { n = stb__memtab_root[b]; if (n) for (i=0; i <= STB__NPTR_NODE_NUM-1; ++i) if (n->children[i]) function(n->children[i], datum, address, end_address); } // last block n = stb__memtab_root[b1]; if (n) { e1 = STB__NPTR_NODE_OFFSET(end); for (i=0; i <= e1; ++i) if (n->children[i]) function(n->children[i], datum, address, end_address); } } } else { if (b1 > b0) { // last block n = stb__memtab_root[b1]; if (n) { e1 = STB__NPTR_NODE_OFFSET(end); for (i=e1; i >= 0; --i) if (n->children[i]) function(n->children[i], datum, address, end_address); } // blocks other than the first and last block for (b=b1-1; b > b0; --b) { n = stb__memtab_root[b]; if (n) for (i=STB__NPTR_NODE_NUM-1; i >= 0; --i) if (n->children[i]) function(n->children[i], datum, address, end_address); } } // first block n = stb__memtab_root[b0]; if (n) { if (b0 != b1) e1 = STB__NPTR_NODE_NUM-1; else e1 = STB__NPTR_NODE_OFFSET(end); for (i=e1; i >= e0; --i) if (n->children[i]) function(n->children[i], datum, address, end_address); } } } static void stb__nptr_delete_pointers(stb__memory_leaf *f, int offset, void *start, void *end) { stb__nptr **p = &f->pointers; while (*p) { stb__nptr *n = *p; if (n->ptr >= start && n->ptr <= end) { // unlink if (n->prev) { *(n->prev) = n->next; if (n->next) n->next->prev = n->prev; } *p = n->next_in_block; stb__nptr_free(n); } else p = &(n->next_in_block); } } static void stb__nptr_delete_targets(stb__memory_leaf *f, int offset, void *start, void *end) { stb__nptr_target **p = &f->targets; while (*p) { stb__nptr_target *n = *p; if (n->ptr >= start && n->ptr <= end) { // null pointers stb__nptr *z = n->first; while (z) { stb__nptr *y = z->next; z->prev = NULL; z->next = NULL; *(void **) z->ptr = NULL; z = y; } // unlink this target *p = n->next_in_block; stb__nptr_free(n); } else p = &(n->next_in_block); } } void stb_nptr_didfree(void *address_being_freed, int len) { // step one: delete all pointers in this block stb__nptr_block(address_being_freed, len, stb__nptr_delete_pointers, 0); // step two: NULL all pointers to this block; do this second to avoid NULLing deleted pointers stb__nptr_block(address_being_freed, len, stb__nptr_delete_targets, 0); } void stb_nptr_free(void *address_being_freed, int len) { free(address_being_freed); stb_nptr_didfree(address_being_freed, len); } static void stb__nptr_move_targets(stb__memory_leaf *f, int offset, void *start, void *end) { stb__nptr_target **t = &f->targets; while (*t) { stb__nptr_target *n = *t; if (n->ptr >= start && n->ptr <= end) { stb__nptr *z; stb__memory_leaf *f; // unlink n *t = n->next_in_block; // update n to new address n->ptr = (void *) ((char *) n->ptr + offset); f = stb__nptr_find_leaf(n->ptr); if (!f) f = stb__nptr_make_leaf(n->ptr); n->next_in_block = f->targets; f->targets = n; // now go through all pointers and make them point here z = n->first; while (z) { *(void**) z->ptr = n->ptr; z = z->next; } } else t = &(n->next_in_block); } } static void stb__nptr_move_pointers(stb__memory_leaf *f, int offset, void *start, void *end) { stb__nptr **p = &f->pointers; while (*p) { stb__nptr *n = *p; if (n->ptr >= start && n->ptr <= end) { // unlink *p = n->next_in_block; n->ptr = (void *) ((int) n->ptr + offset); // move to new block f = stb__nptr_find_leaf(n->ptr); if (!f) f = stb__nptr_make_leaf(n->ptr); n->next_in_block = f->pointers; f->pointers = n; } else p = &(n->next_in_block); } } void stb_nptr_realloc(void *new_address, void *old_address, int len) { if (new_address == old_address) return; // have to move the pointers first, because moving the targets // requires writing to the pointers-to-the-targets, and if some of those moved too, // we need to make sure we don't write to the old memory // step one: move all pointers within the block stb__nptr_block(old_address, len, stb__nptr_move_pointers, (char *) new_address - (char *) old_address); // step two: move all targets within the block stb__nptr_block(old_address, len, stb__nptr_move_targets, (char *) new_address - (char *) old_address); } void stb_nptr_move(void *new_address, void *old_address) { stb_nptr_realloc(new_address, old_address, 1); } void stb_nptr_recache(void) { int i,j; for (i=0; i < STB__NPTR_ROOT_NUM; ++i) if (stb__memtab_root[i]) for (j=0; j < STB__NPTR_NODE_NUM; ++j) if (stb__memtab_root[i]->children[j]) { stb__nptr *p = stb__memtab_root[i]->children[j]->pointers; while (p) { stb_nptr_didset(p->ptr); p = p->next_in_block; } } } #endif // STB_DEFINE #endif // STB_NPTR ////////////////////////////////////////////////////////////////////////////// // // File Processing // #ifdef _MSC_VER #define stb_rename(x,y) _wrename((const wchar_t *)stb__from_utf8(x), (const wchar_t *)stb__from_utf8_alt(y)) #define stb_mktemp _mktemp #else #define stb_mktemp mktemp #define stb_rename rename #endif STB_EXTERN void stb_fput_varlen64(FILE *f, stb_uint64 v); STB_EXTERN stb_uint64 stb_fget_varlen64(FILE *f); STB_EXTERN int stb_size_varlen64(stb_uint64 v); #define stb_filec (char *) stb_file #define stb_fileu (unsigned char *) stb_file STB_EXTERN void * stb_file(char *filename, size_t *length); STB_EXTERN void * stb_file_max(char *filename, size_t *length); STB_EXTERN size_t stb_filelen(FILE *f); STB_EXTERN int stb_filewrite(char *filename, void *data, size_t length); STB_EXTERN int stb_filewritestr(char *filename, char *data); STB_EXTERN char ** stb_stringfile(char *filename, int *len); STB_EXTERN char ** stb_stringfile_trimmed(char *name, int *len, char comm); STB_EXTERN char * stb_fgets(char *buffer, int buflen, FILE *f); STB_EXTERN char * stb_fgets_malloc(FILE *f); STB_EXTERN int stb_fexists(char *filename); STB_EXTERN int stb_fcmp(char *s1, char *s2); STB_EXTERN int stb_feq(char *s1, char *s2); STB_EXTERN time_t stb_ftimestamp(char *filename); STB_EXTERN int stb_fullpath(char *abs, int abs_size, char *rel); STB_EXTERN FILE * stb_fopen(char *filename, char *mode); STB_EXTERN int stb_fclose(FILE *f, int keep); enum { stb_keep_no = 0, stb_keep_yes = 1, stb_keep_if_different = 2, }; STB_EXTERN int stb_copyfile(char *src, char *dest); STB_EXTERN void stb_fput_varlen64(FILE *f, stb_uint64 v); STB_EXTERN stb_uint64 stb_fget_varlen64(FILE *f); STB_EXTERN int stb_size_varlen64(stb_uint64 v); STB_EXTERN void stb_fwrite32(FILE *f, stb_uint32 datum); STB_EXTERN void stb_fput_varlen (FILE *f, int v); STB_EXTERN void stb_fput_varlenu(FILE *f, unsigned int v); STB_EXTERN int stb_fget_varlen (FILE *f); STB_EXTERN stb_uint stb_fget_varlenu(FILE *f); STB_EXTERN void stb_fput_ranged (FILE *f, int v, int b, stb_uint n); STB_EXTERN int stb_fget_ranged (FILE *f, int b, stb_uint n); STB_EXTERN int stb_size_varlen (int v); STB_EXTERN int stb_size_varlenu(unsigned int v); STB_EXTERN int stb_size_ranged (int b, stb_uint n); STB_EXTERN int stb_fread(void *data, size_t len, size_t count, void *f); STB_EXTERN int stb_fwrite(void *data, size_t len, size_t count, void *f); #if 0 typedef struct { FILE *base_file; char *buffer; int buffer_size; int buffer_off; int buffer_left; } STBF; STB_EXTERN STBF *stb_tfopen(char *filename, char *mode); STB_EXTERN int stb_tfread(void *data, size_t len, size_t count, STBF *f); STB_EXTERN int stb_tfwrite(void *data, size_t len, size_t count, STBF *f); #endif #ifdef STB_DEFINE #if 0 STBF *stb_tfopen(char *filename, char *mode) { STBF *z; FILE *f = fopen(filename, mode); if (!f) return NULL; z = (STBF *) malloc(sizeof(*z)); if (!z) { fclose(f); return NULL; } z->base_file = f; if (!strcmp(mode, "rb") || !strcmp(mode, "wb")) { z->buffer_size = 4096; z->buffer_off = z->buffer_size; z->buffer_left = 0; z->buffer = malloc(z->buffer_size); if (!z->buffer) { free(z); fclose(f); return NULL; } } else { z->buffer = 0; z->buffer_size = 0; z->buffer_left = 0; } return z; } int stb_tfread(void *data, size_t len, size_t count, STBF *f) { int total = len*count, done=0; if (!total) return 0; if (total <= z->buffer_left) { memcpy(data, z->buffer + z->buffer_off, total); z->buffer_off += total; z->buffer_left -= total; return count; } else { char *out = (char *) data; // consume all buffered data memcpy(data, z->buffer + z->buffer_off, z->buffer_left); done = z->buffer_left; out += z->buffer_left; z->buffer_left=0; if (total-done > (z->buffer_size >> 1)) { done += fread(out } } } #endif void stb_fwrite32(FILE *f, stb_uint32 x) { fwrite(&x, 4, 1, f); } #if defined(_MSC_VER) || defined(__MINGW32__) #define stb__stat _stat #else #define stb__stat stat #endif int stb_fexists(char *filename) { struct stb__stat buf; return stb__windows( _wstat((const wchar_t *)stb__from_utf8(filename), &buf), stat(filename,&buf) ) == 0; } time_t stb_ftimestamp(char *filename) { struct stb__stat buf; if (stb__windows( _wstat((const wchar_t *)stb__from_utf8(filename), &buf), stat(filename,&buf) ) == 0) { return buf.st_mtime; } else { return 0; } } size_t stb_filelen(FILE *f) { size_t len, pos; pos = ftell(f); fseek(f, 0, SEEK_END); len = ftell(f); fseek(f, pos, SEEK_SET); return len; } void *stb_file(char *filename, size_t *length) { FILE *f = stb__fopen(filename, "rb"); char *buffer; size_t len, len2; if (!f) return NULL; len = stb_filelen(f); buffer = (char *) malloc(len+2); // nul + extra len2 = fread(buffer, 1, len, f); if (len2 == len) { if (length) *length = len; buffer[len] = 0; } else { free(buffer); buffer = NULL; } fclose(f); return buffer; } int stb_filewrite(char *filename, void *data, size_t length) { FILE *f = stb_fopen(filename, "wb"); if (f) { unsigned char *data_ptr = (unsigned char *) data; size_t remaining = length; while (remaining > 0) { size_t len2 = remaining > 65536 ? 65536 : remaining; size_t len3 = fwrite(data_ptr, 1, len2, f); if (len2 != len3) { fprintf(stderr, "Failed while writing %s\n", filename); break; } remaining -= len2; data_ptr += len2; } stb_fclose(f, stb_keep_if_different); } return f != NULL; } int stb_filewritestr(char *filename, char *data) { return stb_filewrite(filename, data, strlen(data)); } void * stb_file_max(char *filename, size_t *length) { FILE *f = stb__fopen(filename, "rb"); char *buffer; size_t len, maxlen; if (!f) return NULL; maxlen = *length; buffer = (char *) malloc(maxlen+1); len = fread(buffer, 1, maxlen, f); buffer[len] = 0; fclose(f); *length = len; return buffer; } char ** stb_stringfile(char *filename, int *plen) { FILE *f = stb__fopen(filename, "rb"); char *buffer, **list=NULL, *s; size_t len, count, i; if (!f) return NULL; len = stb_filelen(f); buffer = (char *) malloc(len+1); len = fread(buffer, 1, len, f); buffer[len] = 0; fclose(f); // two passes through: first time count lines, second time set them for (i=0; i < 2; ++i) { s = buffer; if (i == 1) list[0] = s; count = 1; while (*s) { if (*s == '\n' || *s == '\r') { // detect if both cr & lf are together int crlf = (s[0] + s[1]) == ('\n' + '\r'); if (i == 1) *s = 0; if (crlf) ++s; if (s[1]) { // it's not over yet if (i == 1) list[count] = s+1; ++count; } } ++s; } if (i == 0) { list = (char **) malloc(sizeof(*list) * (count+1) + len+1); if (!list) return NULL; list[count] = 0; // recopy the file so there's just a single allocation to free memcpy(&list[count+1], buffer, len+1); free(buffer); buffer = (char *) &list[count+1]; if (plen) *plen = count; } } return list; } char ** stb_stringfile_trimmed(char *name, int *len, char comment) { int i,n,o=0; char **s = stb_stringfile(name, &n); if (s == NULL) return NULL; for (i=0; i < n; ++i) { char *p = stb_skipwhite(s[i]); if (*p && *p != comment) s[o++] = p; } s[o] = NULL; if (len) *len = o; return s; } char * stb_fgets(char *buffer, int buflen, FILE *f) { char *p; buffer[0] = 0; p = fgets(buffer, buflen, f); if (p) { int n = strlen(p)-1; if (n >= 0) if (p[n] == '\n') p[n] = 0; } return p; } char * stb_fgets_malloc(FILE *f) { // avoid reallocing for small strings char quick_buffer[800]; quick_buffer[sizeof(quick_buffer)-2] = 0; if (!fgets(quick_buffer, sizeof(quick_buffer), f)) return NULL; if (quick_buffer[sizeof(quick_buffer)-2] == 0) { int n = strlen(quick_buffer); if (n > 0 && quick_buffer[n-1] == '\n') quick_buffer[n-1] = 0; return strdup(quick_buffer); } else { char *p; char *a = strdup(quick_buffer); int len = sizeof(quick_buffer)-1; while (!feof(f)) { if (a[len-1] == '\n') break; a = (char *) realloc(a, len*2); p = &a[len]; p[len-2] = 0; if (!fgets(p, len, f)) break; if (p[len-2] == 0) { len += strlen(p); break; } len = len + (len-1); } if (a[len-1] == '\n') a[len-1] = 0; return a; } } int stb_fullpath(char *abs, int abs_size, char *rel) { #ifdef _MSC_VER return _fullpath(abs, rel, abs_size) != NULL; #else if (rel[0] == '/' || rel[0] == '~') { if ((int) strlen(rel) >= abs_size) return 0; strcpy(abs,rel); return STB_TRUE; } else { int n; getcwd(abs, abs_size); n = strlen(abs); if (n+(int) strlen(rel)+2 <= abs_size) { abs[n] = '/'; strcpy(abs+n+1, rel); return STB_TRUE; } else { return STB_FALSE; } } #endif } static int stb_fcmp_core(FILE *f, FILE *g) { char buf1[1024],buf2[1024]; int n1,n2, res=0; while (1) { n1 = fread(buf1, 1, sizeof(buf1), f); n2 = fread(buf2, 1, sizeof(buf2), g); res = memcmp(buf1,buf2,stb_min(n1,n2)); if (res) break; if (n1 != n2) { res = n1 < n2 ? -1 : 1; break; } if (n1 == 0) break; } fclose(f); fclose(g); return res; } int stb_fcmp(char *s1, char *s2) { FILE *f = stb__fopen(s1, "rb"); FILE *g = stb__fopen(s2, "rb"); if (f == NULL || g == NULL) { if (f) fclose(f); if (g) { fclose(g); return STB_TRUE; } return f != NULL; } return stb_fcmp_core(f,g); } int stb_feq(char *s1, char *s2) { FILE *f = stb__fopen(s1, "rb"); FILE *g = stb__fopen(s2, "rb"); if (f == NULL || g == NULL) { if (f) fclose(f); if (g) fclose(g); return f == g; } // feq is faster because it shortcuts if they're different length if (stb_filelen(f) != stb_filelen(g)) { fclose(f); fclose(g); return 0; } return !stb_fcmp_core(f,g); } static stb_ptrmap *stb__files; typedef struct { char *temp_name; char *name; int errors; } stb__file_data; FILE * stb_fopen(char *filename, char *mode) { FILE *f; char name_full[4096]; char temp_full[sizeof(name_full) + 12]; int p; #ifdef _MSC_VER int j; #endif if (mode[0] != 'w' && !strchr(mode, '+')) return stb__fopen(filename, mode); // save away the full path to the file so if the program // changes the cwd everything still works right! unix has // better ways to do this, but we have to work in windows name_full[0] = '\0'; // stb_fullpath reads name_full[0] if (stb_fullpath(name_full, sizeof(name_full), filename)==0) return 0; // try to generate a temporary file in the same directory p = strlen(name_full)-1; while (p > 0 && name_full[p] != '/' && name_full[p] != '\\' && name_full[p] != ':' && name_full[p] != '~') --p; ++p; memcpy(temp_full, name_full, p); #ifdef _MSC_VER // try multiple times to make a temp file... just in // case some other process makes the name first for (j=0; j < 32; ++j) { strcpy(temp_full+p, "stmpXXXXXX"); if (stb_mktemp(temp_full) == NULL) return 0; f = fopen(temp_full, mode); if (f != NULL) break; } #else { strcpy(temp_full+p, "stmpXXXXXX"); #ifdef __MINGW32__ int fd = open(mktemp(temp_full), O_RDWR); #else int fd = mkstemp(temp_full); #endif if (fd == -1) return NULL; f = fdopen(fd, mode); if (f == NULL) { unlink(temp_full); close(fd); return NULL; } } #endif if (f != NULL) { stb__file_data *d = (stb__file_data *) malloc(sizeof(*d)); if (!d) { assert(0); /* NOTREACHED */fclose(f); return NULL; } if (stb__files == NULL) stb__files = stb_ptrmap_create(); d->temp_name = strdup(temp_full); d->name = strdup(name_full); d->errors = 0; stb_ptrmap_add(stb__files, f, d); return f; } return NULL; } int stb_fclose(FILE *f, int keep) { stb__file_data *d; int ok = STB_FALSE; if (f == NULL) return 0; if (ferror(f)) keep = stb_keep_no; fclose(f); if (stb__files && stb_ptrmap_remove(stb__files, f, (void **) &d)) { if (stb__files->count == 0) { stb_ptrmap_destroy(stb__files); stb__files = NULL; } } else return STB_TRUE; // not special if (keep == stb_keep_if_different) { // check if the files are identical if (stb_feq(d->name, d->temp_name)) { keep = stb_keep_no; ok = STB_TRUE; // report success if no change } } if (keep != stb_keep_no) { if (stb_fexists(d->name) && remove(d->name)) { // failed to delete old, so don't keep new keep = stb_keep_no; } else { if (!stb_rename(d->temp_name, d->name)) ok = STB_TRUE; else keep=stb_keep_no; } } if (keep == stb_keep_no) remove(d->temp_name); free(d->temp_name); free(d->name); free(d); return ok; } int stb_copyfile(char *src, char *dest) { char raw_buffer[1024]; char *buffer; int buf_size = 65536; FILE *f, *g; // if file already exists at destination, do nothing if (stb_feq(src, dest)) return STB_TRUE; // open file f = stb__fopen(src, "rb"); if (f == NULL) return STB_FALSE; // open file for writing g = stb__fopen(dest, "wb"); if (g == NULL) { fclose(f); return STB_FALSE; } buffer = (char *) malloc(buf_size); if (buffer == NULL) { buffer = raw_buffer; buf_size = sizeof(raw_buffer); } while (!feof(f)) { int n = fread(buffer, 1, buf_size, f); if (n != 0) fwrite(buffer, 1, n, g); } fclose(f); if (buffer != raw_buffer) free(buffer); fclose(g); return STB_TRUE; } // varlen: // v' = (v >> 31) + (v < 0 ? ~v : v)<<1; // small abs(v) => small v' // output v as big endian v'+k for v' <= k: // 1 byte : v' <= 0x00000080 ( -64 <= v < 64) 7 bits // 2 bytes: v' <= 0x00004000 (-8192 <= v < 8192) 14 bits // 3 bytes: v' <= 0x00200000 21 bits // 4 bytes: v' <= 0x10000000 28 bits // the number of most significant 1-bits in the first byte // equals the number of bytes after the first #define stb__varlen_xform(v) (v<0 ? (~v << 1)+1 : (v << 1)) int stb_size_varlen(int v) { return stb_size_varlenu(stb__varlen_xform(v)); } int stb_size_varlenu(unsigned int v) { if (v < 0x00000080) return 1; if (v < 0x00004000) return 2; if (v < 0x00200000) return 3; if (v < 0x10000000) return 4; return 5; } void stb_fput_varlen(FILE *f, int v) { stb_fput_varlenu(f, stb__varlen_xform(v)); } void stb_fput_varlenu(FILE *f, unsigned int z) { if (z >= 0x10000000) fputc(0xF0,f); if (z >= 0x00200000) fputc((z < 0x10000000 ? 0xE0 : 0)+(z>>24),f); if (z >= 0x00004000) fputc((z < 0x00200000 ? 0xC0 : 0)+(z>>16),f); if (z >= 0x00000080) fputc((z < 0x00004000 ? 0x80 : 0)+(z>> 8),f); fputc(z,f); } #define stb_fgetc(f) ((unsigned char) fgetc(f)) int stb_fget_varlen(FILE *f) { unsigned int z = stb_fget_varlenu(f); return (z & 1) ? ~(z>>1) : (z>>1); } unsigned int stb_fget_varlenu(FILE *f) { unsigned int z; unsigned char d; d = stb_fgetc(f); if (d >= 0x80) { if (d >= 0xc0) { if (d >= 0xe0) { if (d == 0xf0) z = stb_fgetc(f) << 24; else z = (d - 0xe0) << 24; z += stb_fgetc(f) << 16; } else z = (d - 0xc0) << 16; z += stb_fgetc(f) << 8; } else z = (d - 0x80) << 8; z += stb_fgetc(f); } else z = d; return z; } stb_uint64 stb_fget_varlen64(FILE *f) { stb_uint64 z; unsigned char d; d = stb_fgetc(f); if (d >= 0x80) { if (d >= 0xc0) { if (d >= 0xe0) { if (d >= 0xf0) { if (d >= 0xf8) { if (d >= 0xfc) { if (d >= 0xfe) { if (d >= 0xff) z = (stb_uint64) stb_fgetc(f) << 56; else z = (stb_uint64) (d - 0xfe) << 56; z |= (stb_uint64) stb_fgetc(f) << 48; } else z = (stb_uint64) (d - 0xfc) << 48; z |= (stb_uint64) stb_fgetc(f) << 40; } else z = (stb_uint64) (d - 0xf8) << 40; z |= (stb_uint64) stb_fgetc(f) << 32; } else z = (stb_uint64) (d - 0xf0) << 32; z |= (stb_uint) stb_fgetc(f) << 24; } else z = (stb_uint) (d - 0xe0) << 24; z |= (stb_uint) stb_fgetc(f) << 16; } else z = (stb_uint) (d - 0xc0) << 16; z |= (stb_uint) stb_fgetc(f) << 8; } else z = (stb_uint) (d - 0x80) << 8; z |= stb_fgetc(f); } else z = d; return (z & 1) ? ~(z >> 1) : (z >> 1); } int stb_size_varlen64(stb_uint64 v) { if (v < 0x00000080) return 1; if (v < 0x00004000) return 2; if (v < 0x00200000) return 3; if (v < 0x10000000) return 4; if (v < STB_IMM_UINT64(0x0000000800000000)) return 5; if (v < STB_IMM_UINT64(0x0000040000000000)) return 6; if (v < STB_IMM_UINT64(0x0002000000000000)) return 7; if (v < STB_IMM_UINT64(0x0100000000000000)) return 8; return 9; } void stb_fput_varlen64(FILE *f, stb_uint64 v) { stb_uint64 z = stb__varlen_xform(v); int first=1; if (z >= STB_IMM_UINT64(0x100000000000000)) { fputc(0xff,f); first=0; } if (z >= STB_IMM_UINT64(0x02000000000000)) fputc((first ? 0xFE : 0)+(char)(z>>56),f), first=0; if (z >= STB_IMM_UINT64(0x00040000000000)) fputc((first ? 0xFC : 0)+(char)(z>>48),f), first=0; if (z >= STB_IMM_UINT64(0x00000800000000)) fputc((first ? 0xF8 : 0)+(char)(z>>40),f), first=0; if (z >= STB_IMM_UINT64(0x00000010000000)) fputc((first ? 0xF0 : 0)+(char)(z>>32),f), first=0; if (z >= STB_IMM_UINT64(0x00000000200000)) fputc((first ? 0xE0 : 0)+(char)(z>>24),f), first=0; if (z >= STB_IMM_UINT64(0x00000000004000)) fputc((first ? 0xC0 : 0)+(char)(z>>16),f), first=0; if (z >= STB_IMM_UINT64(0x00000000000080)) fputc((first ? 0x80 : 0)+(char)(z>> 8),f), first=0; fputc((char)z,f); } void stb_fput_ranged(FILE *f, int v, int b, stb_uint n) { v -= b; if (n <= (1 << 31)) assert((stb_uint) v < n); if (n > (1 << 24)) fputc(v >> 24, f); if (n > (1 << 16)) fputc(v >> 16, f); if (n > (1 << 8)) fputc(v >> 8, f); fputc(v,f); } int stb_fget_ranged(FILE *f, int b, stb_uint n) { unsigned int v=0; if (n > (1 << 24)) v += stb_fgetc(f) << 24; if (n > (1 << 16)) v += stb_fgetc(f) << 16; if (n > (1 << 8)) v += stb_fgetc(f) << 8; v += stb_fgetc(f); return b+v; } int stb_size_ranged(int b, stb_uint n) { if (n > (1 << 24)) return 4; if (n > (1 << 16)) return 3; if (n > (1 << 8)) return 2; return 1; } void stb_fput_string(FILE *f, char *s) { int len = strlen(s); stb_fput_varlenu(f, len); fwrite(s, 1, len, f); } // inverse of the above algorithm char *stb_fget_string(FILE *f, void *p) { char *s; int len = stb_fget_varlenu(f); if (len > 4096) return NULL; s = p ? stb_malloc_string(p, len+1) : (char *) malloc(len+1); fread(s, 1, len, f); s[len] = 0; return s; } char *stb_strdup(char *str, void *pool) { int len = strlen(str); char *p = stb_malloc_string(pool, len+1); strcpy(p, str); return p; } // strip the trailing '/' or '\\' from a directory so we can refer to it // as a file for _stat() char *stb_strip_final_slash(char *t) { if (t[0]) { char *z = t + strlen(t) - 1; // *z is the last character if (*z == '\\' || *z == '/') if (z != t+2 || t[1] != ':') // but don't strip it if it's e.g. "c:/" *z = 0; if (*z == '\\') *z = '/'; // canonicalize to make sure it matches db } return t; } char *stb_strip_final_slash_regardless(char *t) { if (t[0]) { char *z = t + strlen(t) - 1; // *z is the last character if (*z == '\\' || *z == '/') *z = 0; if (*z == '\\') *z = '/'; // canonicalize to make sure it matches db } return t; } #endif ////////////////////////////////////////////////////////////////////////////// // // Options parsing // STB_EXTERN char **stb_getopt_param(int *argc, char **argv, char *param); STB_EXTERN char **stb_getopt(int *argc, char **argv); STB_EXTERN void stb_getopt_free(char **opts); #ifdef STB_DEFINE void stb_getopt_free(char **opts) { int i; char ** o2 = opts; for (i=0; i < stb_arr_len(o2); ++i) free(o2[i]); stb_arr_free(o2); } char **stb_getopt(int *argc, char **argv) { return stb_getopt_param(argc, argv, ""); } char **stb_getopt_param(int *argc, char **argv, char *param) { char ** opts=NULL; int i,j=1; for (i=1; i < *argc; ++i) { if (argv[i][0] != '-') { argv[j++] = argv[i]; } else { if (argv[i][1] == 0) { // plain - == don't parse further options ++i; while (i < *argc) argv[j++] = argv[i++]; break; } else { int k; char *q = argv[i]; // traverse options list for (k=1; q[k]; ++k) { char *s; if (strchr(param, q[k])) { // does it take a parameter? char *t = &q[k+1], z = q[k]; int len=0; if (*t == 0) { if (i == *argc-1) { // takes a parameter, but none found *argc = 0; stb_getopt_free(opts); return NULL; } t = argv[++i]; } else k += strlen(t); len = strlen(t); s = (char *) malloc(len+2); if (!s) return NULL; s[0] = z; strcpy(s+1, t); } else { // no parameter s = (char *) malloc(2); if (!s) return NULL; s[0] = q[k]; s[1] = 0; } stb_arr_push(opts, s); } } } } stb_arr_push(opts, NULL); *argc = j; return opts; } #endif ////////////////////////////////////////////////////////////////////////////// // // Portable directory reading // STB_EXTERN char **stb_readdir_files (char *dir); STB_EXTERN char **stb_readdir_files_mask(char *dir, char *wild); STB_EXTERN char **stb_readdir_subdirs(char *dir); STB_EXTERN char **stb_readdir_subdirs_mask(char *dir, char *wild); STB_EXTERN void stb_readdir_free (char **files); STB_EXTERN char **stb_readdir_recursive(char *dir, char *filespec); STB_EXTERN void stb_delete_directory_recursive(char *dir); #ifdef STB_DEFINE #ifdef _MSC_VER #include #else #include #include #endif void stb_readdir_free(char **files) { char **f2 = files; int i; for (i=0; i < stb_arr_len(f2); ++i) free(f2[i]); stb_arr_free(f2); } static int isdotdirname(char *name) { if (name[0] == '.') return (name[1] == '.') ? !name[2] : !name[1]; return 0; } STB_EXTERN int stb_wildmatchi(char *expr, char *candidate); static char **readdir_raw(char *dir, int return_subdirs, char *mask) { char **results = NULL; char buffer[4096], with_slash[4096]; size_t n; #ifdef _MSC_VER stb__wchar *ws; struct _wfinddata_t data; #ifdef _WIN64 const intptr_t none = -1; intptr_t z; #else const long none = -1; long z; #endif #else // !_MSC_VER const DIR *none = NULL; DIR *z; #endif n = stb_strscpy(buffer,dir,sizeof(buffer)); if (!n || n >= sizeof(buffer)) return NULL; stb_fixpath(buffer); n--; if (n > 0 && (buffer[n-1] != '/')) { buffer[n++] = '/'; } buffer[n] = 0; if (!stb_strscpy(with_slash,buffer,sizeof(with_slash))) return NULL; #ifdef _MSC_VER if (!stb_strscpy(buffer+n,"*.*",sizeof(buffer)-n)) return NULL; ws = stb__from_utf8(buffer); z = _wfindfirst((const wchar_t *)ws, &data); #else z = opendir(dir); #endif if (z != none) { int nonempty = STB_TRUE; #ifndef _MSC_VER struct dirent *data = readdir(z); nonempty = (data != NULL); #endif if (nonempty) { do { int is_subdir; #ifdef _MSC_VER char *name = stb__to_utf8((stb__wchar *)data.name); if (name == NULL) { fprintf(stderr, "%s to convert '%S' to %s!\n", "Unable", data.name, "utf8"); continue; } is_subdir = !!(data.attrib & _A_SUBDIR); #else char *name = data->d_name; if (!stb_strscpy(buffer+n,name,sizeof(buffer)-n)) break; // Could follow DT_LNK, but would need to check for recursive links. is_subdir = !!(data->d_type & DT_DIR); #endif if (is_subdir == return_subdirs) { if (!is_subdir || !isdotdirname(name)) { if (!mask || stb_wildmatchi(mask, name)) { char buffer[4096],*p=buffer; if ( stb_snprintf(buffer, sizeof(buffer), "%s%s", with_slash, name) < 0 ) break; if (buffer[0] == '.' && buffer[1] == '/') p = buffer+2; stb_arr_push(results, strdup(p)); } } } } #ifdef _MSC_VER while (0 == _wfindnext(z, &data)); #else while ((data = readdir(z)) != NULL); #endif } #ifdef _MSC_VER _findclose(z); #else closedir(z); #endif } return results; } char **stb_readdir_files (char *dir) { return readdir_raw(dir, 0, NULL); } char **stb_readdir_subdirs(char *dir) { return readdir_raw(dir, 1, NULL); } char **stb_readdir_files_mask(char *dir, char *wild) { return readdir_raw(dir, 0, wild); } char **stb_readdir_subdirs_mask(char *dir, char *wild) { return readdir_raw(dir, 1, wild); } int stb__rec_max=0x7fffffff; static char **stb_readdir_rec(char **sofar, char *dir, char *filespec) { char **files; char ** dirs; char **p; if (stb_arr_len(sofar) >= stb__rec_max) return sofar; files = stb_readdir_files_mask(dir, filespec); stb_arr_for(p, files) { stb_arr_push(sofar, strdup(*p)); if (stb_arr_len(sofar) >= stb__rec_max) break; } stb_readdir_free(files); if (stb_arr_len(sofar) >= stb__rec_max) return sofar; dirs = stb_readdir_subdirs(dir); stb_arr_for(p, dirs) sofar = stb_readdir_rec(sofar, *p, filespec); stb_readdir_free(dirs); return sofar; } char **stb_readdir_recursive(char *dir, char *filespec) { return stb_readdir_rec(NULL, dir, filespec); } void stb_delete_directory_recursive(char *dir) { char **list = stb_readdir_subdirs(dir); int i; for (i=0; i < stb_arr_len(list); ++i) stb_delete_directory_recursive(list[i]); stb_arr_free(list); list = stb_readdir_files(dir); for (i=0; i < stb_arr_len(list); ++i) if (!remove(list[i])) { // on windows, try again after making it writeable; don't ALWAYS // do this first since that would be slow in the normal case #ifdef _MSC_VER _chmod(list[i], _S_IWRITE); remove(list[i]); #endif } stb_arr_free(list); stb__windows(_rmdir,rmdir)(dir); } #endif ////////////////////////////////////////////////////////////////////////////// // // construct trees from filenames; useful for cmirror summaries typedef struct stb_dirtree2 stb_dirtree2; struct stb_dirtree2 { stb_dirtree2 **subdirs; // make convenient for stb_summarize_tree int num_subdir; float weight; // actual data char *fullpath; char *relpath; char **files; }; STB_EXTERN stb_dirtree2 *stb_dirtree2_from_files_relative(char *src, char **filelist, int count); STB_EXTERN stb_dirtree2 *stb_dirtree2_from_files(char **filelist, int count); STB_EXTERN int stb_dir_is_prefix(char *dir, int dirlen, char *file); #ifdef STB_DEFINE int stb_dir_is_prefix(char *dir, int dirlen, char *file) { if (dirlen == 0) return STB_TRUE; if (stb_strnicmp(dir, file, dirlen)) return STB_FALSE; if (file[dirlen] == '/' || file[dirlen] == '\\') return STB_TRUE; return STB_FALSE; } stb_dirtree2 *stb_dirtree2_from_files_relative(char *src, char **filelist, int count) { char buffer1[1024]; int i; int dlen = strlen(src), elen; stb_dirtree2 *d; char ** descendents = NULL; char ** files = NULL; char *s; if (!count) return NULL; // first find all the ones that belong here... note this is will take O(NM) with N files and M subdirs for (i=0; i < count; ++i) { if (stb_dir_is_prefix(src, dlen, filelist[i])) { stb_arr_push(descendents, filelist[i]); } } if (descendents == NULL) return NULL; elen = dlen; // skip a leading slash if (elen == 0 && (descendents[0][0] == '/' || descendents[0][0] == '\\')) ++elen; else if (elen) ++elen; // now extract all the ones that have their root here for (i=0; i < stb_arr_len(descendents);) { if (!stb_strchr2(descendents[i]+elen, '/', '\\')) { stb_arr_push(files, descendents[i]); descendents[i] = descendents[stb_arr_len(descendents)-1]; stb_arr_pop(descendents); } else ++i; } // now create a record d = (stb_dirtree2 *) malloc(sizeof(*d)); d->files = files; d->subdirs = NULL; d->fullpath = strdup(src); s = stb_strrchr2(d->fullpath, '/', '\\'); if (s) ++s; else s = d->fullpath; d->relpath = s; // now create the children qsort(descendents, stb_arr_len(descendents), sizeof(char *), stb_qsort_stricmp(0)); buffer1[0] = 0; for (i=0; i < stb_arr_len(descendents); ++i) { char buffer2[1024]; char *s = descendents[i] + elen, *t; t = stb_strchr2(s, '/', '\\'); assert(t); stb_strncpy(buffer2, descendents[i], t-descendents[i]+1); if (stb_stricmp(buffer1, buffer2)) { stb_dirtree2 *t = stb_dirtree2_from_files_relative(buffer2, descendents, stb_arr_len(descendents)); assert(t != NULL); strcpy(buffer1, buffer2); stb_arr_push(d->subdirs, t); } } d->num_subdir = stb_arr_len(d->subdirs); d->weight = 0; return d; } stb_dirtree2 *stb_dirtree2_from_files(char **filelist, int count) { return stb_dirtree2_from_files_relative("", filelist, count); } #endif ////////////////////////////////////////////////////////////////////////////// // // Checksums: CRC-32, ADLER32, SHA-1 // // CRC-32 and ADLER32 allow streaming blocks // SHA-1 requires either a complete buffer, max size 2^32 - 73 // or it can checksum directly from a file, max 2^61 #define STB_ADLER32_SEED 1 #define STB_CRC32_SEED 0 // note that we logical NOT this in the code STB_EXTERN stb_uint stb_adler32(stb_uint adler32, stb_uchar *buffer, stb_uint buflen); STB_EXTERN stb_uint stb_crc32_block(stb_uint crc32, stb_uchar *buffer, stb_uint len); STB_EXTERN stb_uint stb_crc32(unsigned char *buffer, stb_uint len); STB_EXTERN void stb_sha1( unsigned char output[20], unsigned char *buffer, unsigned int len); STB_EXTERN int stb_sha1_file(unsigned char output[20], char *file); STB_EXTERN void stb_sha1_readable(char display[27], unsigned char sha[20]); #ifdef STB_DEFINE stb_uint stb_crc32_block(stb_uint crc, unsigned char *buffer, stb_uint len) { static stb_uint crc_table[256]; stb_uint i,j,s; crc = ~crc; if (crc_table[1] == 0) for(i=0; i < 256; i++) { for (s=i, j=0; j < 8; ++j) s = (s >> 1) ^ (s & 1 ? 0xedb88320 : 0); crc_table[i] = s; } for (i=0; i < len; ++i) crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; return ~crc; } stb_uint stb_crc32(unsigned char *buffer, stb_uint len) { return stb_crc32_block(0, buffer, len); } stb_uint stb_adler32(stb_uint adler32, stb_uchar *buffer, stb_uint buflen) { const unsigned long ADLER_MOD = 65521; unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16; unsigned long blocklen, i; blocklen = buflen % 5552; while (buflen) { for (i=0; i + 7 < blocklen; i += 8) { s1 += buffer[0], s2 += s1; s1 += buffer[1], s2 += s1; s1 += buffer[2], s2 += s1; s1 += buffer[3], s2 += s1; s1 += buffer[4], s2 += s1; s1 += buffer[5], s2 += s1; s1 += buffer[6], s2 += s1; s1 += buffer[7], s2 += s1; buffer += 8; } for (; i < blocklen; ++i) s1 += *buffer++, s2 += s1; s1 %= ADLER_MOD, s2 %= ADLER_MOD; buflen -= blocklen; blocklen = 5552; } return (s2 << 16) + s1; } static void stb__sha1(stb_uchar *chunk, stb_uint h[5]) { int i; stb_uint a,b,c,d,e; stb_uint w[80]; for (i=0; i < 16; ++i) w[i] = stb_big32(&chunk[i*4]); for (i=16; i < 80; ++i) { stb_uint t; t = w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16]; w[i] = (t + t) | (t >> 31); } a = h[0]; b = h[1]; c = h[2]; d = h[3]; e = h[4]; #define STB__SHA1(k,f) \ { \ stb_uint temp = (a << 5) + (a >> 27) + (f) + e + (k) + w[i]; \ e = d; \ d = c; \ c = (b << 30) + (b >> 2); \ b = a; \ a = temp; \ } i=0; for (; i < 20; ++i) STB__SHA1(0x5a827999, d ^ (b & (c ^ d)) ); for (; i < 40; ++i) STB__SHA1(0x6ed9eba1, b ^ c ^ d ); for (; i < 60; ++i) STB__SHA1(0x8f1bbcdc, (b & c) + (d & (b ^ c)) ); for (; i < 80; ++i) STB__SHA1(0xca62c1d6, b ^ c ^ d ); #undef STB__SHA1 h[0] += a; h[1] += b; h[2] += c; h[3] += d; h[4] += e; } void stb_sha1(stb_uchar output[20], stb_uchar *buffer, stb_uint len) { unsigned char final_block[128]; stb_uint end_start, final_len, j; int i; stb_uint h[5]; h[0] = 0x67452301; h[1] = 0xefcdab89; h[2] = 0x98badcfe; h[3] = 0x10325476; h[4] = 0xc3d2e1f0; // we need to write padding to the last one or two // blocks, so build those first into 'final_block' // we have to write one special byte, plus the 8-byte length // compute the block where the data runs out end_start = len & ~63; // compute the earliest we can encode the length if (((len+9) & ~63) == end_start) { // it all fits in one block, so fill a second-to-last block end_start -= 64; } final_len = end_start + 128; // now we need to copy the data in assert(end_start + 128 >= len+9); assert(end_start < len || len < 64-9); j = 0; if (end_start > len) j = (stb_uint) - (int) end_start; for (; end_start + j < len; ++j) final_block[j] = buffer[end_start + j]; final_block[j++] = 0x80; while (j < 128-5) // 5 byte length, so write 4 extra padding bytes final_block[j++] = 0; // big-endian size final_block[j++] = len >> 29; final_block[j++] = len >> 21; final_block[j++] = len >> 13; final_block[j++] = len >> 5; final_block[j++] = len << 3; assert(j == 128 && end_start + j == final_len); for (j=0; j < final_len; j += 64) { // 512-bit chunks if (j+64 >= end_start+64) stb__sha1(&final_block[j - end_start], h); else stb__sha1(&buffer[j], h); } for (i=0; i < 5; ++i) { output[i*4 + 0] = h[i] >> 24; output[i*4 + 1] = h[i] >> 16; output[i*4 + 2] = h[i] >> 8; output[i*4 + 3] = h[i] >> 0; } } #ifdef _MSC_VER int stb_sha1_file(stb_uchar output[20], char *file) { int i; stb_uint64 length=0; unsigned char buffer[128]; FILE *f = stb__fopen(file, "rb"); stb_uint h[5]; if (f == NULL) return 0; // file not found h[0] = 0x67452301; h[1] = 0xefcdab89; h[2] = 0x98badcfe; h[3] = 0x10325476; h[4] = 0xc3d2e1f0; for(;;) { int n = fread(buffer, 1, 64, f); if (n == 64) { stb__sha1(buffer, h); length += n; } else { int block = 64; length += n; buffer[n++] = 0x80; // if there isn't enough room for the length, double the block if (n + 8 > 64) block = 128; // pad to end memset(buffer+n, 0, block-8-n); i = block - 8; buffer[i++] = (stb_uchar) (length >> 53); buffer[i++] = (stb_uchar) (length >> 45); buffer[i++] = (stb_uchar) (length >> 37); buffer[i++] = (stb_uchar) (length >> 29); buffer[i++] = (stb_uchar) (length >> 21); buffer[i++] = (stb_uchar) (length >> 13); buffer[i++] = (stb_uchar) (length >> 5); buffer[i++] = (stb_uchar) (length << 3); assert(i == block); stb__sha1(buffer, h); if (block == 128) stb__sha1(buffer+64, h); else assert(block == 64); break; } } fclose(f); for (i=0; i < 5; ++i) { output[i*4 + 0] = h[i] >> 24; output[i*4 + 1] = h[i] >> 16; output[i*4 + 2] = h[i] >> 8; output[i*4 + 3] = h[i] >> 0; } return 1; } #endif // _MSC_VER // client can truncate this wherever they like void stb_sha1_readable(char display[27], unsigned char sha[20]) { char encoding[65] = "0123456789abcdefghijklmnopqrstuv" "wxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%$"; int num_bits = 0, acc=0; int i=0,o=0; while (o < 26) { int v; // expand the accumulator if (num_bits < 6) { assert(i != 20); acc += sha[i++] << num_bits; num_bits += 8; } v = acc & ((1 << 6) - 1); display[o++] = encoding[v]; acc >>= 6; num_bits -= 6; } assert(num_bits == 20*8 - 26*6); display[o++] = encoding[acc]; } #endif // STB_DEFINE /////////////////////////////////////////////////////////// // // simplified WINDOWS registry interface... hopefully // we'll never actually use this? #if defined(_WIN32) STB_EXTERN void * stb_reg_open(char *mode, char *where); // mode: "rHKLM" or "rHKCU" or "w.." STB_EXTERN void stb_reg_close(void *reg); STB_EXTERN int stb_reg_read(void *zreg, char *str, void *data, unsigned long len); STB_EXTERN int stb_reg_read_string(void *zreg, char *str, char *data, int len); STB_EXTERN void stb_reg_write(void *zreg, char *str, void *data, unsigned long len); STB_EXTERN void stb_reg_write_string(void *zreg, char *str, char *data); #if defined(STB_DEFINE) && !defined(STB_NO_REGISTRY) #define STB_HAS_REGISTRY #ifndef _WINDOWS_ #define HKEY void * STB_EXTERN __declspec(dllimport) long __stdcall RegCloseKey ( HKEY hKey ); STB_EXTERN __declspec(dllimport) long __stdcall RegCreateKeyExA ( HKEY hKey, const char * lpSubKey, int Reserved, char * lpClass, int dwOptions, int samDesired, void *lpSecurityAttributes, HKEY * phkResult, int * lpdwDisposition ); STB_EXTERN __declspec(dllimport) long __stdcall RegDeleteKeyA ( HKEY hKey, const char * lpSubKey ); STB_EXTERN __declspec(dllimport) long __stdcall RegQueryValueExA ( HKEY hKey, const char * lpValueName, int * lpReserved, unsigned long * lpType, unsigned char * lpData, unsigned long * lpcbData ); STB_EXTERN __declspec(dllimport) long __stdcall RegSetValueExA ( HKEY hKey, const char * lpValueName, int Reserved, int dwType, const unsigned char* lpData, int cbData ); STB_EXTERN __declspec(dllimport) long __stdcall RegOpenKeyExA ( HKEY hKey, const char * lpSubKey, int ulOptions, int samDesired, HKEY * phkResult ); #endif // _WINDOWS_ #define STB__REG_OPTION_NON_VOLATILE 0 #define STB__REG_KEY_ALL_ACCESS 0x000f003f #define STB__REG_KEY_READ 0x00020019 void *stb_reg_open(char *mode, char *where) { long res; HKEY base; HKEY zreg; if (!stb_stricmp(mode+1, "cu") || !stb_stricmp(mode+1, "hkcu")) base = (HKEY) 0x80000001; // HKCU else if (!stb_stricmp(mode+1, "lm") || !stb_stricmp(mode+1, "hklm")) base = (HKEY) 0x80000002; // HKLM else return NULL; if (mode[0] == 'r') res = RegOpenKeyExA(base, where, 0, STB__REG_KEY_READ, &zreg); else if (mode[0] == 'w') res = RegCreateKeyExA(base, where, 0, NULL, STB__REG_OPTION_NON_VOLATILE, STB__REG_KEY_ALL_ACCESS, NULL, &zreg, NULL); else return NULL; return res ? NULL : zreg; } void stb_reg_close(void *reg) { RegCloseKey((HKEY) reg); } #define STB__REG_SZ 1 #define STB__REG_BINARY 3 #define STB__REG_DWORD 4 int stb_reg_read(void *zreg, char *str, void *data, unsigned long len) { unsigned long type; unsigned long alen = len; if (0 == RegQueryValueExA((HKEY) zreg, str, 0, &type, (unsigned char *) data, &len)) if (type == STB__REG_BINARY || type == STB__REG_SZ || type == STB__REG_DWORD) { if (len < alen) *((char *) data + len) = 0; return 1; } return 0; } void stb_reg_write(void *zreg, char *str, void *data, unsigned long len) { if (zreg) RegSetValueExA((HKEY) zreg, str, 0, STB__REG_BINARY, (const unsigned char *) data, len); } int stb_reg_read_string(void *zreg, char *str, char *data, int len) { if (!stb_reg_read(zreg, str, data, len)) return 0; data[len-1] = 0; // force a 0 at the end of the string no matter what return 1; } void stb_reg_write_string(void *zreg, char *str, char *data) { if (zreg) RegSetValueExA((HKEY) zreg, str, 0, STB__REG_SZ, (const unsigned char *) data, strlen(data)+1); } #endif // STB_DEFINE #endif // _WIN32 ////////////////////////////////////////////////////////////////////////////// // // stb_cfg - This is like the registry, but the config info // is all stored in plain old files where we can // backup and restore them easily. The LOCATION of // the config files is gotten from... the registry! #ifndef STB_NO_STB_STRINGS typedef struct stb_cfg_st stb_cfg; STB_EXTERN stb_cfg * stb_cfg_open(char *config, char *mode); // mode = "r", "w" STB_EXTERN void stb_cfg_close(stb_cfg *cfg); STB_EXTERN int stb_cfg_read(stb_cfg *cfg, char *key, void *value, int len); STB_EXTERN void stb_cfg_write(stb_cfg *cfg, char *key, void *value, int len); STB_EXTERN int stb_cfg_read_string(stb_cfg *cfg, char *key, char *value, int len); STB_EXTERN void stb_cfg_write_string(stb_cfg *cfg, char *key, char *value); STB_EXTERN int stb_cfg_delete(stb_cfg *cfg, char *key); STB_EXTERN void stb_cfg_set_directory(char *dir); #ifdef STB_DEFINE typedef struct { char *key; void *value; int value_len; } stb__cfg_item; struct stb_cfg_st { stb__cfg_item *data; char *loaded_file; // this needs to be freed FILE *f; // write the data to this file on close }; static char *stb__cfg_sig = "sTbCoNfIg!\0\0"; static char stb__cfg_dir[512]; STB_EXTERN void stb_cfg_set_directory(char *dir) { strcpy(stb__cfg_dir, dir); } STB_EXTERN stb_cfg * stb_cfg_open(char *config, char *mode) { size_t len; stb_cfg *z; char file[512]; if (mode[0] != 'r' && mode[0] != 'w') return NULL; if (!stb__cfg_dir[0]) { #ifdef _WIN32 strcpy(stb__cfg_dir, "c:/stb"); #else strcpy(stb__cfg_dir, "~/.stbconfig"); #endif #ifdef STB_HAS_REGISTRY { void *reg = stb_reg_open("rHKLM", "Software\\SilverSpaceship\\stb"); if (reg) { stb_reg_read_string(reg, "config_dir", stb__cfg_dir, sizeof(stb__cfg_dir)); stb_reg_close(reg); } } #endif } sprintf(file, "%s/%s.cfg", stb__cfg_dir, config); z = (stb_cfg *) stb_malloc(0, sizeof(*z)); z->data = NULL; z->loaded_file = stb_filec(file, &len); if (z->loaded_file) { char *s = z->loaded_file; if (!memcmp(s, stb__cfg_sig, 12)) { char *s = z->loaded_file + 12; while (s < z->loaded_file + len) { stb__cfg_item a; int n = *(stb_int16 *) s; a.key = s+2; s = s+2 + n; a.value_len = *(int *) s; s += 4; a.value = s; s += a.value_len; stb_arr_push(z->data, a); } assert(s == z->loaded_file + len); } } if (mode[0] == 'w') z->f = fopen(file, "wb"); else z->f = NULL; return z; } void stb_cfg_close(stb_cfg *z) { if (z->f) { int i; // write the file out fwrite(stb__cfg_sig, 12, 1, z->f); for (i=0; i < stb_arr_len(z->data); ++i) { stb_int16 n = strlen(z->data[i].key)+1; fwrite(&n, 2, 1, z->f); fwrite(z->data[i].key, n, 1, z->f); fwrite(&z->data[i].value_len, 4, 1, z->f); fwrite(z->data[i].value, z->data[i].value_len, 1, z->f); } fclose(z->f); } stb_arr_free(z->data); stb_free(z); } int stb_cfg_read(stb_cfg *z, char *key, void *value, int len) { int i; for (i=0; i < stb_arr_len(z->data); ++i) { if (!stb_stricmp(z->data[i].key, key)) { int n = stb_min(len, z->data[i].value_len); memcpy(value, z->data[i].value, n); if (n < len) *((char *) value + n) = 0; return 1; } } return 0; } void stb_cfg_write(stb_cfg *z, char *key, void *value, int len) { int i; for (i=0; i < stb_arr_len(z->data); ++i) if (!stb_stricmp(z->data[i].key, key)) break; if (i == stb_arr_len(z->data)) { stb__cfg_item p; p.key = stb_strdup(key, z); p.value = NULL; p.value_len = 0; stb_arr_push(z->data, p); } z->data[i].value = stb_malloc(z, len); z->data[i].value_len = len; memcpy(z->data[i].value, value, len); } int stb_cfg_delete(stb_cfg *z, char *key) { int i; for (i=0; i < stb_arr_len(z->data); ++i) if (!stb_stricmp(z->data[i].key, key)) { stb_arr_fastdelete(z->data, i); return 1; } return 0; } int stb_cfg_read_string(stb_cfg *z, char *key, char *value, int len) { if (!stb_cfg_read(z, key, value, len)) return 0; value[len-1] = 0; return 1; } void stb_cfg_write_string(stb_cfg *z, char *key, char *value) { stb_cfg_write(z, key, value, strlen(value)+1); } #endif ////////////////////////////////////////////////////////////////////////////// // // stb_dirtree - load a description of a directory tree // uses a cache and stat()s the directories for changes // MUCH faster on NTFS, _wrong_ on FAT32, so should // ignore the db on FAT32 #ifdef _WIN32 typedef struct { char * path; // full path from passed-in root time_t last_modified; int num_files; int flag; } stb_dirtree_dir; typedef struct { char *name; // name relative to path int dir; // index into dirs[] array stb_int64 size; // size, max 4GB time_t last_modified; int flag; } stb_dirtree_file; typedef struct { stb_dirtree_dir *dirs; stb_dirtree_file *files; // internal use void * string_pool; // used to free data en masse } stb_dirtree; extern void stb_dirtree_free ( stb_dirtree *d ); extern stb_dirtree *stb_dirtree_get ( char *dir); extern stb_dirtree *stb_dirtree_get_dir ( char *dir, char *cache_dir); extern stb_dirtree *stb_dirtree_get_with_file ( char *dir, char *cache_file); // get a list of all the files recursively underneath 'dir' // // cache_file is used to store a copy of the directory tree to speed up // later calls. It must be unique to 'dir' and the current working // directory! Otherwise who knows what will happen (a good solution // is to put it _in_ dir, but this API doesn't force that). // // Also, it might be possible to break this if you have two different processes // do a call to stb_dirtree_get() with the same cache file at about the same // time, but I _think_ it might just work. // i needed to build an identical data structure representing the state of // a mirrored copy WITHOUT bothering to rescan it (i.e. we're mirroring to // it WITHOUT scanning it, e.g. it's over the net), so this requires access // to all of the innards. extern void stb_dirtree_db_add_dir(stb_dirtree *active, char *path, time_t last); extern void stb_dirtree_db_add_file(stb_dirtree *active, char *name, int dir, stb_int64 size, time_t last); extern void stb_dirtree_db_read(stb_dirtree *target, char *filename, char *dir); extern void stb_dirtree_db_write(stb_dirtree *target, char *filename, char *dir); #ifdef STB_DEFINE static void stb__dirtree_add_dir(char *path, time_t last, stb_dirtree *active) { stb_dirtree_dir d; d.last_modified = last; d.num_files = 0; d.path = stb_strdup(path, active->string_pool); stb_arr_push(active->dirs, d); } static void stb__dirtree_add_file(char *name, int dir, stb_int64 size, time_t last, stb_dirtree *active) { stb_dirtree_file f; f.dir = dir; f.size = size; f.last_modified = last; f.name = stb_strdup(name, active->string_pool); ++active->dirs[dir].num_files; stb_arr_push(active->files, f); } // version 02 supports > 4GB files static char stb__signature[12] = { 's', 'T', 'b', 'D', 'i', 'R', 't', 'R', 'e', 'E', '0', '2' }; static void stb__dirtree_save_db(char *filename, stb_dirtree *data, char *root) { int i, num_dirs_final=0, num_files_final; char *info = root ? root : ""; int *remap; FILE *f = fopen(filename, "wb"); if (!f) return; fwrite(stb__signature, sizeof(stb__signature), 1, f); fwrite(info, strlen(info)+1, 1, f); // need to be slightly tricky and not write out NULLed directories, nor the root // build remapping table of all dirs we'll be writing out remap = (int *) malloc(sizeof(remap[0]) * stb_arr_len(data->dirs)); for (i=0; i < stb_arr_len(data->dirs); ++i) { if (data->dirs[i].path == NULL || (root && 0==stb_stricmp(data->dirs[i].path, root))) { remap[i] = -1; } else { remap[i] = num_dirs_final++; } } fwrite(&num_dirs_final, 4, 1, f); for (i=0; i < stb_arr_len(data->dirs); ++i) { if (remap[i] >= 0) { fwrite(&data->dirs[i].last_modified, 4, 1, f); stb_fput_string(f, data->dirs[i].path); } } num_files_final = 0; for (i=0; i < stb_arr_len(data->files); ++i) if (remap[data->files[i].dir] >= 0 && data->files[i].name) ++num_files_final; fwrite(&num_files_final, 4, 1, f); for (i=0; i < stb_arr_len(data->files); ++i) { if (remap[data->files[i].dir] >= 0 && data->files[i].name) { stb_fput_ranged(f, remap[data->files[i].dir], 0, num_dirs_final); stb_fput_varlen64(f, data->files[i].size); fwrite(&data->files[i].last_modified, 4, 1, f); stb_fput_string(f, data->files[i].name); } } fclose(f); } // note: stomps any existing data, rather than appending static void stb__dirtree_load_db(char *filename, stb_dirtree *data, char *dir) { char sig[2048]; int i,n; FILE *f = fopen(filename, "rb"); if (!f) return; data->string_pool = stb_malloc(0,1); fread(sig, sizeof(stb__signature), 1, f); if (memcmp(stb__signature, sig, sizeof(stb__signature))) { fclose(f); return; } if (!fread(sig, strlen(dir)+1, 1, f)) { fclose(f); return; } if (stb_stricmp(sig,dir)) { fclose(f); return; } // we can just read them straight in, because they're guaranteed to be valid fread(&n, 4, 1, f); stb_arr_setlen(data->dirs, n); for(i=0; i < stb_arr_len(data->dirs); ++i) { fread(&data->dirs[i].last_modified, 4, 1, f); data->dirs[i].path = stb_fget_string(f, data->string_pool); if (data->dirs[i].path == NULL) goto bail; } fread(&n, 4, 1, f); stb_arr_setlen(data->files, n); for (i=0; i < stb_arr_len(data->files); ++i) { data->files[i].dir = stb_fget_ranged(f, 0, stb_arr_len(data->dirs)); data->files[i].size = stb_fget_varlen64(f); fread(&data->files[i].last_modified, 4, 1, f); data->files[i].name = stb_fget_string(f, data->string_pool); if (data->files[i].name == NULL) goto bail; } if (0) { bail: stb_arr_free(data->dirs); stb_arr_free(data->files); } fclose(f); } static int stb__dircount, stb__dircount_mask, stb__showfile; static void stb__dirtree_scandir(char *path, time_t last_time, stb_dirtree *active) { // this is dumb depth first; theoretically it might be faster // to fully traverse each directory before visiting its children, // but it's complicated and didn't seem like a gain in the test app int n; struct _wfinddatai64_t c_file; long hFile; stb__wchar full_path[1024]; int has_slash; if (stb__showfile) printf("<"); has_slash = (path[0] && path[strlen(path)-1] == '/'); // @TODO: do this concatenation without using swprintf to avoid this mess: #if defined(_MSC_VER) && _MSC_VER < 1400 if (has_slash) swprintf(full_path, L"%s*", stb__from_utf8(path)); else swprintf(full_path, L"%s/*", stb__from_utf8(path)); #else if (has_slash) swprintf(full_path, 1024, L"%s*", stb__from_utf8(path)); else swprintf(full_path, 1024, L"%s/*", stb__from_utf8(path)); #endif // it's possible this directory is already present: that means it was in the // cache, but its parent wasn't... in that case, we're done with it if (stb__showfile) printf("C[%d]", stb_arr_len(active->dirs)); for (n=0; n < stb_arr_len(active->dirs); ++n) if (0 == stb_stricmp(active->dirs[n].path, path)) { if (stb__showfile) printf("D"); return; } if (stb__showfile) printf("E"); // otherwise, we need to add it stb__dirtree_add_dir(path, last_time, active); n = stb_arr_lastn(active->dirs); if (stb__showfile) printf("["); if( (hFile = _wfindfirsti64( full_path, &c_file )) != -1L ) { do { if (stb__showfile) printf(")"); if (c_file.attrib & _A_SUBDIR) { // ignore subdirectories starting with '.', e.g. "." and ".." if (c_file.name[0] != '.') { char *new_path = (char *) full_path; char *temp = stb__to_utf8(c_file.name); if (has_slash) sprintf(new_path, "%s%s", path, temp); else sprintf(new_path, "%s/%s", path, temp); if (stb__dircount_mask) { ++stb__dircount; if (!(stb__dircount & stb__dircount_mask)) { printf("%s\r", new_path); } } stb__dirtree_scandir(new_path, c_file.time_write, active); } } else { char *temp = stb__to_utf8(c_file.name); stb__dirtree_add_file(temp, n, c_file.size, c_file.time_write, active); } if (stb__showfile) printf("("); } while( _wfindnexti64( hFile, &c_file ) == 0 ); if (stb__showfile) printf("]"); _findclose( hFile ); } if (stb__showfile) printf(">\n"); } // scan the database and see if it's all valid static int stb__dirtree_update_db(stb_dirtree *db, stb_dirtree *active) { int changes_detected = STB_FALSE; int i; int *remap; int *rescan=NULL; remap = (int *) malloc(sizeof(remap[0]) * stb_arr_len(db->dirs)); memset(remap, 0, sizeof(remap[0]) * stb_arr_len(db->dirs)); rescan = NULL; for (i=0; i < stb_arr_len(db->dirs); ++i) { struct _stat info; if (stb__dircount_mask) { ++stb__dircount; if (!(stb__dircount & stb__dircount_mask)) { printf("."); } } if (0 == _stat(db->dirs[i].path, &info)) { if (info.st_mode & _S_IFDIR) { // it's still a directory, as expected int n = abs(info.st_mtime - db->dirs[i].last_modified); if (n > 1 && n != 3600) { // the 3600 is a hack because sometimes this jumps for no apparent reason, even when no time zone or DST issues are at play // it's changed! force a rescan // we don't want to scan it until we've stat()d its // subdirs, though, so we queue it if (stb__showfile) printf("Changed: %s - %08x:%08x\n", db->dirs[i].path, db->dirs[i].last_modified, info.st_mtime); stb_arr_push(rescan, i); // update the last_mod time db->dirs[i].last_modified = info.st_mtime; // ignore existing files in this dir remap[i] = -1; changes_detected = STB_TRUE; } else { // it hasn't changed, just copy it through unchanged stb__dirtree_add_dir(db->dirs[i].path, db->dirs[i].last_modified, active); remap[i] = stb_arr_lastn(active->dirs); } } else { // this path used to refer to a directory, but now it's a file! // assume that the parent directory is going to be forced to rescan anyway goto delete_entry; } } else { delete_entry: // directory no longer exists, so don't copy it // we don't free it because it's in the string pool now db->dirs[i].path = NULL; remap[i] = -1; changes_detected = STB_TRUE; } } // at this point, we have: // // holds a list of directory indices that need to be scanned due to being out of date // holds the directory index in for each dir in , if it exists; -1 if not // directories in are not in yet // so we can go ahead and remap all the known files right now for (i=0; i < stb_arr_len(db->files); ++i) { int dir = db->files[i].dir; if (remap[dir] >= 0) { stb__dirtree_add_file(db->files[i].name, remap[dir], db->files[i].size, db->files[i].last_modified, active); } } // at this point we're done with db->files, and done with remap free(remap); // now scan those directories using the standard scan for (i=0; i < stb_arr_len(rescan); ++i) { int z = rescan[i]; stb__dirtree_scandir(db->dirs[z].path, db->dirs[z].last_modified, active); } stb_arr_free(rescan); return changes_detected; } static void stb__dirtree_free_raw(stb_dirtree *d) { stb_free(d->string_pool); stb_arr_free(d->dirs); stb_arr_free(d->files); } stb_dirtree *stb_dirtree_get_with_file(char *dir, char *cache_file) { stb_dirtree *output = (stb_dirtree *) malloc(sizeof(*output)); stb_dirtree db,active; int prev_dir_count, cache_mismatch; char *stripped_dir; // store the directory name without a trailing '/' or '\\' // load the database of last-known state on disk db.string_pool = NULL; db.files = NULL; db.dirs = NULL; stripped_dir = stb_strip_final_slash(strdup(dir)); if (cache_file != NULL) stb__dirtree_load_db(cache_file, &db, stripped_dir); else if (stb__showfile) printf("No cache file\n"); active.files = NULL; active.dirs = NULL; active.string_pool = stb_malloc(0,1); // @TODO: share string pools between both? // check all the directories in the database; make note if // anything we scanned had changed, and rescan those things cache_mismatch = stb__dirtree_update_db(&db, &active); // check the root tree prev_dir_count = stb_arr_len(active.dirs); // record how many directories we've seen stb__dirtree_scandir(stripped_dir, 0, &active); // no last_modified time available for root if (stb__dircount_mask) printf(" \r"); // done with the DB; write it back out if any changes, i.e. either // 1. any inconsistency found between cached information and actual disk // or 2. if scanning the root found any new directories--which we detect because // more than one directory got added to the active db during that scan if (cache_mismatch || stb_arr_len(active.dirs) > prev_dir_count+1) stb__dirtree_save_db(cache_file, &active, stripped_dir); free(stripped_dir); stb__dirtree_free_raw(&db); *output = active; return output; } stb_dirtree *stb_dirtree_get_dir(char *dir, char *cache_dir) { int i; stb_uint8 sha[20]; char dir_lower[1024]; char cache_file[1024],*s; if (cache_dir == NULL) return stb_dirtree_get_with_file(dir, NULL); strcpy(dir_lower, dir); stb_tolower(dir_lower); stb_sha1(sha, (unsigned char *) dir_lower, strlen(dir_lower)); strcpy(cache_file, cache_dir); s = cache_file + strlen(cache_file); if (s[-1] != '//' && s[-1] != '\\') *s++ = '/'; strcpy(s, "dirtree_"); s += strlen(s); for (i=0; i < 8; ++i) { char *hex = "0123456789abcdef"; stb_uint z = sha[i]; *s++ = hex[z >> 4]; *s++ = hex[z & 15]; } strcpy(s, ".bin"); return stb_dirtree_get_with_file(dir, cache_file); } stb_dirtree *stb_dirtree_get(char *dir) { char cache_dir[256]; strcpy(cache_dir, "c:/stb"); #ifdef STB_HAS_REGISTRY { void *reg = stb_reg_open("rHKLM", "Software\\SilverSpaceship\\stb"); if (reg) { stb_reg_read(reg, "dirtree", cache_dir, sizeof(cache_dir)); stb_reg_close(reg); } } #endif return stb_dirtree_get_dir(dir, cache_dir); } void stb_dirtree_free(stb_dirtree *d) { stb__dirtree_free_raw(d); free(d); } void stb_dirtree_db_add_dir(stb_dirtree *active, char *path, time_t last) { stb__dirtree_add_dir(path, last, active); } void stb_dirtree_db_add_file(stb_dirtree *active, char *name, int dir, stb_int64 size, time_t last) { stb__dirtree_add_file(name, dir, size, last, active); } void stb_dirtree_db_read(stb_dirtree *target, char *filename, char *dir) { char *s = stb_strip_final_slash(strdup(dir)); target->dirs = 0; target->files = 0; target->string_pool = 0; stb__dirtree_load_db(filename, target, s); free(s); } void stb_dirtree_db_write(stb_dirtree *target, char *filename, char *dir) { stb__dirtree_save_db(filename, target, 0); // don't strip out any directories } #endif // STB_DEFINE #endif // _WIN32 #endif // STB_NO_STB_STRINGS ////////////////////////////////////////////////////////////////////////////// // // STB_MALLOC_WRAPPER // // you can use the wrapper functions with your own malloc wrapper, // or define STB_MALLOC_WRAPPER project-wide to have // malloc/free/realloc/strdup all get vectored to it // this has too many very specific error messages you could google for and find in stb.h, // so don't use it if they don't want any stb.h-identifiable strings #if defined(STB_DEFINE) && !defined(STB_NO_STB_STRINGS) typedef struct { void *p; char *file; int line; int size; } stb_malloc_record; #ifndef STB_MALLOC_HISTORY_COUNT #define STB_MALLOC_HISTORY_COUNT 50 // 800 bytes #endif stb_malloc_record *stb__allocations; static int stb__alloc_size, stb__alloc_limit, stb__alloc_mask; int stb__alloc_count; stb_malloc_record stb__alloc_history[STB_MALLOC_HISTORY_COUNT]; int stb__history_pos; static int stb__hashfind(void *p) { stb_uint32 h = stb_hashptr(p); int s,n = h & stb__alloc_mask; if (stb__allocations[n].p == p) return n; s = stb_rehash(h)|1; for(;;) { if (stb__allocations[n].p == NULL) return -1; n = (n+s) & stb__alloc_mask; if (stb__allocations[n].p == p) return n; } } int stb_wrapper_allocsize(void *p) { int n = stb__hashfind(p); if (n < 0) return 0; return stb__allocations[n].size; } static int stb__historyfind(void *p) { int n = stb__history_pos; int i; for (i=0; i < STB_MALLOC_HISTORY_COUNT; ++i) { if (--n < 0) n = STB_MALLOC_HISTORY_COUNT-1; if (stb__alloc_history[n].p == p) return n; } return -1; } static void stb__add_alloc(void *p, int sz, char *file, int line); static void stb__grow_alloc(void) { int i,old_num = stb__alloc_size; stb_malloc_record *old = stb__allocations; if (stb__alloc_size == 0) stb__alloc_size = 64; else stb__alloc_size *= 2; stb__allocations = (stb_malloc_record *) stb__realloc_raw(NULL, stb__alloc_size * sizeof(stb__allocations[0])); if (stb__allocations == NULL) stb_fatal("Internal error: couldn't grow malloc wrapper table"); memset(stb__allocations, 0, stb__alloc_size * sizeof(stb__allocations[0])); stb__alloc_limit = (stb__alloc_size*3)>>2; stb__alloc_mask = stb__alloc_size-1; stb__alloc_count = 0; for (i=0; i < old_num; ++i) if (old[i].p > STB_DEL) { stb__add_alloc(old[i].p, old[i].size, old[i].file, old[i].line); assert(stb__hashfind(old[i].p) >= 0); } for (i=0; i < old_num; ++i) if (old[i].p > STB_DEL) assert(stb__hashfind(old[i].p) >= 0); stb__realloc_raw(old, 0); } static void stb__add_alloc(void *p, int sz, char *file, int line) { stb_uint32 h; int n; if (stb__alloc_count >= stb__alloc_limit) stb__grow_alloc(); h = stb_hashptr(p); n = h & stb__alloc_mask; if (stb__allocations[n].p > STB_DEL) { int s = stb_rehash(h)|1; do { n = (n+s) & stb__alloc_mask; } while (stb__allocations[n].p > STB_DEL); } assert(stb__allocations[n].p == NULL || stb__allocations[n].p == STB_DEL); stb__allocations[n].p = p; stb__allocations[n].size = sz; stb__allocations[n].line = line; stb__allocations[n].file = file; ++stb__alloc_count; } static void stb__remove_alloc(int n, char *file, int line) { stb__alloc_history[stb__history_pos] = stb__allocations[n]; stb__alloc_history[stb__history_pos].file = file; stb__alloc_history[stb__history_pos].line = line; if (++stb__history_pos == STB_MALLOC_HISTORY_COUNT) stb__history_pos = 0; stb__allocations[n].p = STB_DEL; --stb__alloc_count; } void stb_wrapper_malloc(void *p, int sz, char *file, int line) { if (!p) return; stb__add_alloc(p,sz,file,line); } void stb_wrapper_free(void *p, char *file, int line) { int n; if (p == NULL) return; n = stb__hashfind(p); if (n >= 0) stb__remove_alloc(n, file, line); else { // tried to free something we hadn't allocated! n = stb__historyfind(p); assert(0); /* NOTREACHED */ if (n >= 0) stb_fatal("Attempted to free %d-byte block %p at %s:%d previously freed/realloced at %s:%d", stb__alloc_history[n].size, p, file, line, stb__alloc_history[n].file, stb__alloc_history[n].line); else stb_fatal("Attempted to free unknown block %p at %s:%d", p, file,line); } } void stb_wrapper_check(void *p) { int n; if (p == NULL) return; n = stb__hashfind(p); if (n >= 0) return; for (n=0; n < stb__alloc_size; ++n) if (stb__allocations[n].p == p) stb_fatal("Internal error: pointer %p was allocated, but hash search failed", p); // tried to free something that wasn't allocated! n = stb__historyfind(p); if (n >= 0) stb_fatal("Checked %d-byte block %p previously freed/realloced at %s:%d", stb__alloc_history[n].size, p, stb__alloc_history[n].file, stb__alloc_history[n].line); stb_fatal("Checked unknown block %p"); } void stb_wrapper_realloc(void *p, void *q, int sz, char *file, int line) { int n; if (p == NULL) { stb_wrapper_malloc(q, sz, file, line); return; } if (q == NULL) return; // nothing happened n = stb__hashfind(p); if (n == -1) { // tried to free something we hadn't allocated! // this is weird, though, because we got past the realloc! n = stb__historyfind(p); assert(0); /* NOTREACHED */ if (n >= 0) stb_fatal("Attempted to realloc %d-byte block %p at %s:%d previously freed/realloced at %s:%d", stb__alloc_history[n].size, p, file, line, stb__alloc_history[n].file, stb__alloc_history[n].line); else stb_fatal("Attempted to realloc unknown block %p at %s:%d", p, file,line); } else { if (q == p) { stb__allocations[n].size = sz; stb__allocations[n].file = file; stb__allocations[n].line = line; } else { stb__remove_alloc(n, file, line); stb__add_alloc(q,sz,file,line); } } } void stb_wrapper_listall(void (*func)(void *ptr, int sz, char *file, int line)) { int i; for (i=0; i < stb__alloc_size; ++i) if (stb__allocations[i].p > STB_DEL) func(stb__allocations[i].p , stb__allocations[i].size, stb__allocations[i].file, stb__allocations[i].line); } void stb_wrapper_dump(char *filename) { int i; FILE *f = fopen(filename, "w"); if (!f) return; for (i=0; i < stb__alloc_size; ++i) if (stb__allocations[i].p > STB_DEL) fprintf(f, "%p %7d - %4d %s\n", stb__allocations[i].p , stb__allocations[i].size, stb__allocations[i].line, stb__allocations[i].file); } #endif // STB_DEFINE ////////////////////////////////////////////////////////////////////////////// // // stb_pointer_set // // // For data structures that support querying by key, data structure // classes always hand-wave away the issue of what to do if two entries // have the same key: basically, store a linked list of all the nodes // which have the same key (a LISP-style list). // // The thing is, it's not that trivial. If you have an O(log n) // lookup data structure, but then n/4 items have the same value, // you don't want to spend O(n) time scanning that list when // deleting an item if you already have a pointer to the item. // (You have to spend O(n) time enumerating all the items with // a given key, sure, and you can't accelerate deleting a particular // item if you only have the key, not a pointer to the item.) // // I'm going to call this data structure, whatever it turns out to // be, a "pointer set", because we don't store any associated data for // items in this data structure, we just answer the question of // whether an item is in it or not (it's effectively one bit per pointer). // Technically they don't have to be pointers; you could cast ints // to (void *) if you want, but you can't store 0 or 1 because of the // hash table. // // Since the fastest data structure we might want to add support for // identical-keys to is a hash table with O(1)-ish lookup time, // that means that the conceptual "linked list of all items with // the same indexed value" that we build needs to have the same // performance; that way when we index a table we think is arbitrary // ints, but in fact half of them are 0, we don't get screwed. // // Therefore, it needs to be a hash table, at least when it gets // large. On the other hand, when the data has totally arbitrary ints // or floats, there won't be many collisions, and we'll have tons of // 1-item bitmaps. That will be grossly inefficient as hash tables; // trade-off; the hash table is reasonably efficient per-item when // it's large, but not when it's small. So we need to do something // Judy-like and use different strategies depending on the size. // // Like Judy, we'll use the bottom bit to encode the strategy: // // bottom bits: // 00 - direct pointer // 01 - 4-item bucket (16 bytes, no length, NULLs) // 10 - N-item array // 11 - hash table typedef struct stb_ps stb_ps; STB_EXTERN int stb_ps_find (stb_ps *ps, void *value); STB_EXTERN stb_ps * stb_ps_add (stb_ps *ps, void *value); STB_EXTERN stb_ps * stb_ps_remove(stb_ps *ps, void *value); STB_EXTERN stb_ps * stb_ps_remove_any(stb_ps *ps, void **value); STB_EXTERN void stb_ps_delete(stb_ps *ps); STB_EXTERN int stb_ps_count (stb_ps *ps); STB_EXTERN stb_ps * stb_ps_copy (stb_ps *ps); STB_EXTERN int stb_ps_subset(stb_ps *bigger, stb_ps *smaller); STB_EXTERN int stb_ps_eq (stb_ps *p0, stb_ps *p1); STB_EXTERN void ** stb_ps_getlist (stb_ps *ps, int *count); STB_EXTERN int stb_ps_writelist(stb_ps *ps, void **list, int size ); // enum and fastlist don't allocate storage, but you must consume the // list before there's any chance the data structure gets screwed up; STB_EXTERN int stb_ps_enum (stb_ps *ps, void *data, int (*func)(void *value, void*data) ); STB_EXTERN void ** stb_ps_fastlist(stb_ps *ps, int *count); // result: // returns a list, *count is the length of that list, // but some entries of the list may be invalid; // test with 'stb_ps_fastlist_valid(x)' #define stb_ps_fastlist_valid(x) ((stb_uinta) (x) > 1) #ifdef STB_DEFINE enum { STB_ps_direct = 0, STB_ps_bucket = 1, STB_ps_array = 2, STB_ps_hash = 3, }; #define STB_BUCKET_SIZE 4 typedef struct { void *p[STB_BUCKET_SIZE]; } stb_ps_bucket; #define GetBucket(p) ((stb_ps_bucket *) ((char *) (p) - STB_ps_bucket)) #define EncodeBucket(p) ((stb_ps *) ((char *) (p) + STB_ps_bucket)) static void stb_bucket_free(stb_ps_bucket *b) { free(b); } static stb_ps_bucket *stb_bucket_create2(void *v0, void *v1) { stb_ps_bucket *b = (stb_ps_bucket*) malloc(sizeof(*b)); b->p[0] = v0; b->p[1] = v1; b->p[2] = NULL; b->p[3] = NULL; return b; } static stb_ps_bucket * stb_bucket_create3(void **v) { stb_ps_bucket *b = (stb_ps_bucket*) malloc(sizeof(*b)); b->p[0] = v[0]; b->p[1] = v[1]; b->p[2] = v[2]; b->p[3] = NULL; return b; } // could use stb_arr, but this will save us memory typedef struct { int count; void *p[1]; } stb_ps_array; #define GetArray(p) ((stb_ps_array *) ((char *) (p) - STB_ps_array)) #define EncodeArray(p) ((stb_ps *) ((char *) (p) + STB_ps_array)) static int stb_ps_array_max = 13; typedef struct { int size, mask; int count, count_deletes; int grow_threshhold; int shrink_threshhold; int rehash_threshhold; int any_offset; void *table[1]; } stb_ps_hash; #define GetHash(p) ((stb_ps_hash *) ((char *) (p) - STB_ps_hash)) #define EncodeHash(p) ((stb_ps *) ((char *) (p) + STB_ps_hash)) #define stb_ps_empty(v) (((stb_uint32) v) <= 1) static stb_ps_hash *stb_ps_makehash(int size, int old_size, void **old_data) { int i; stb_ps_hash *h = (stb_ps_hash *) malloc(sizeof(*h) + (size-1) * sizeof(h->table[0])); assert(stb_is_pow2(size)); h->size = size; h->mask = size-1; h->shrink_threshhold = (int) (0.3f * size); h-> grow_threshhold = (int) (0.8f * size); h->rehash_threshhold = (int) (0.9f * size); h->count = 0; h->count_deletes = 0; h->any_offset = 0; memset(h->table, 0, size * sizeof(h->table[0])); for (i=0; i < old_size; ++i) if (!stb_ps_empty(old_data[i])) stb_ps_add(EncodeHash(h), old_data[i]); return h; } void stb_ps_delete(stb_ps *ps) { switch (3 & (int) ps) { case STB_ps_direct: break; case STB_ps_bucket: stb_bucket_free(GetBucket(ps)); break; case STB_ps_array : free(GetArray(ps)); break; case STB_ps_hash : free(GetHash(ps)); break; } } stb_ps *stb_ps_copy(stb_ps *ps) { int i; // not a switch: order based on expected performance/power-law distribution switch (3 & (int) ps) { case STB_ps_direct: return ps; case STB_ps_bucket: { stb_ps_bucket *n = (stb_ps_bucket *) malloc(sizeof(*n)); *n = *GetBucket(ps); return EncodeBucket(n); } case STB_ps_array: { stb_ps_array *a = GetArray(ps); stb_ps_array *n = (stb_ps_array *) malloc(sizeof(*n) + stb_ps_array_max * sizeof(n->p[0])); n->count = a->count; for (i=0; i < a->count; ++i) n->p[i] = a->p[i]; return EncodeArray(n); } case STB_ps_hash: { stb_ps_hash *h = GetHash(ps); stb_ps_hash *n = stb_ps_makehash(h->size, h->size, h->table); return EncodeHash(n); } } assert(0); /* NOTREACHED */ return NULL; } int stb_ps_find(stb_ps *ps, void *value) { int i, code = 3 & (int) ps; assert((3 & (int) value) == STB_ps_direct); assert(stb_ps_fastlist_valid(value)); // not a switch: order based on expected performance/power-law distribution if (code == STB_ps_direct) return value == ps; if (code == STB_ps_bucket) { stb_ps_bucket *b = GetBucket(ps); assert(STB_BUCKET_SIZE == 4); if (b->p[0] == value || b->p[1] == value || b->p[2] == value || b->p[3] == value) return STB_TRUE; return STB_FALSE; } if (code == STB_ps_array) { stb_ps_array *a = GetArray(ps); for (i=0; i < a->count; ++i) if (a->p[i] == value) return STB_TRUE; return STB_FALSE; } else { stb_ps_hash *h = GetHash(ps); stb_uint32 hash = stb_hashptr(value); stb_uint32 s, n = hash & h->mask; void **t = h->table; if (t[n] == value) return STB_TRUE; if (t[n] == NULL) return STB_FALSE; s = stb_rehash(hash) | 1; do { n = (n + s) & h->mask; if (t[n] == value) return STB_TRUE; } while (t[n] != NULL); return STB_FALSE; } } stb_ps * stb_ps_add (stb_ps *ps, void *value) { #ifdef STB_DEBUG assert(!stb_ps_find(ps,value)); #endif if (value == NULL) return ps; // ignore NULL adds to avoid bad breakage assert((3 & (int) value) == STB_ps_direct); assert(stb_ps_fastlist_valid(value)); assert(value != STB_DEL); // STB_DEL is less likely switch (3 & (int) ps) { case STB_ps_direct: if (ps == NULL) return (stb_ps *) value; return EncodeBucket(stb_bucket_create2(ps,value)); case STB_ps_bucket: { stb_ps_bucket *b = GetBucket(ps); stb_ps_array *a; assert(STB_BUCKET_SIZE == 4); if (b->p[0] == NULL) { b->p[0] = value; return ps; } if (b->p[1] == NULL) { b->p[1] = value; return ps; } if (b->p[2] == NULL) { b->p[2] = value; return ps; } if (b->p[3] == NULL) { b->p[3] = value; return ps; } a = (stb_ps_array *) malloc(sizeof(*a) + 7 * sizeof(a->p[0])); // 8 slots, must be 2^k memcpy(a->p, b, sizeof(*b)); a->p[4] = value; a->count = 5; stb_bucket_free(b); return EncodeArray(a); } case STB_ps_array: { stb_ps_array *a = GetArray(ps); if (a->count == stb_ps_array_max) { // promote from array to hash stb_ps_hash *h = stb_ps_makehash(2 << stb_log2_ceil(a->count), a->count, a->p); free(a); return stb_ps_add(EncodeHash(h), value); } // do we need to resize the array? the array doubles in size when it // crosses a power-of-two if ((a->count & (a->count-1))==0) { int newsize = a->count*2; // clamp newsize to max if: // 1. it's larger than max // 2. newsize*1.5 is larger than max (to avoid extra resizing) if (newsize + a->count > stb_ps_array_max) newsize = stb_ps_array_max; a = (stb_ps_array *) realloc(a, sizeof(*a) + (newsize-1) * sizeof(a->p[0])); } a->p[a->count++] = value; return EncodeArray(a); } case STB_ps_hash: { stb_ps_hash *h = GetHash(ps); stb_uint32 hash = stb_hashptr(value); stb_uint32 n = hash & h->mask; void **t = h->table; // find first NULL or STB_DEL entry if (!stb_ps_empty(t[n])) { stb_uint32 s = stb_rehash(hash) | 1; do { n = (n + s) & h->mask; } while (!stb_ps_empty(t[n])); } if (t[n] == STB_DEL) -- h->count_deletes; t[n] = value; ++ h->count; if (h->count == h->grow_threshhold) { stb_ps_hash *h2 = stb_ps_makehash(h->size*2, h->size, t); free(h); return EncodeHash(h2); } if (h->count + h->count_deletes == h->rehash_threshhold) { stb_ps_hash *h2 = stb_ps_makehash(h->size, h->size, t); free(h); return EncodeHash(h2); } return ps; } } return NULL; /* NOTREACHED */ } stb_ps *stb_ps_remove(stb_ps *ps, void *value) { #ifdef STB_DEBUG assert(stb_ps_find(ps, value)); #endif assert((3 & (int) value) == STB_ps_direct); if (value == NULL) return ps; // ignore NULL removes to avoid bad breakage switch (3 & (int) ps) { case STB_ps_direct: return ps == value ? NULL : ps; case STB_ps_bucket: { stb_ps_bucket *b = GetBucket(ps); int count=0; assert(STB_BUCKET_SIZE == 4); if (b->p[0] == value) b->p[0] = NULL; else count += (b->p[0] != NULL); if (b->p[1] == value) b->p[1] = NULL; else count += (b->p[1] != NULL); if (b->p[2] == value) b->p[2] = NULL; else count += (b->p[2] != NULL); if (b->p[3] == value) b->p[3] = NULL; else count += (b->p[3] != NULL); if (count == 1) { // shrink bucket at size 1 value = b->p[0]; if (value == NULL) value = b->p[1]; if (value == NULL) value = b->p[2]; if (value == NULL) value = b->p[3]; assert(value != NULL); stb_bucket_free(b); return (stb_ps *) value; // return STB_ps_direct of value } return ps; } case STB_ps_array: { stb_ps_array *a = GetArray(ps); int i; for (i=0; i < a->count; ++i) { if (a->p[i] == value) { a->p[i] = a->p[--a->count]; if (a->count == 3) { // shrink to bucket! stb_ps_bucket *b = stb_bucket_create3(a->p); free(a); return EncodeBucket(b); } return ps; } } return ps; } case STB_ps_hash: { stb_ps_hash *h = GetHash(ps); stb_uint32 hash = stb_hashptr(value); stb_uint32 s, n = hash & h->mask; void **t = h->table; if (t[n] != value) { s = stb_rehash(hash) | 1; do { n = (n + s) & h->mask; } while (t[n] != value); } t[n] = STB_DEL; -- h->count; ++ h->count_deletes; // should we shrink down to an array? if (h->count < stb_ps_array_max) { int n = 1 << stb_log2_floor(stb_ps_array_max); if (h->count < n) { stb_ps_array *a = (stb_ps_array *) malloc(sizeof(*a) + (n-1) * sizeof(a->p[0])); int i,j=0; for (i=0; i < h->size; ++i) if (!stb_ps_empty(t[i])) a->p[j++] = t[i]; assert(j == h->count); a->count = j; free(h); return EncodeArray(a); } } if (h->count == h->shrink_threshhold) { stb_ps_hash *h2 = stb_ps_makehash(h->size >> 1, h->size, t); free(h); return EncodeHash(h2); } return ps; } } return ps; /* NOTREACHED */ } stb_ps *stb_ps_remove_any(stb_ps *ps, void **value) { assert(ps != NULL); switch (3 & (int) ps) { case STB_ps_direct: *value = ps; return NULL; case STB_ps_bucket: { stb_ps_bucket *b = GetBucket(ps); int count=0, slast=0, last=0; assert(STB_BUCKET_SIZE == 4); if (b->p[0]) { ++count; last = 0; } if (b->p[1]) { ++count; slast = last; last = 1; } if (b->p[2]) { ++count; slast = last; last = 2; } if (b->p[3]) { ++count; slast = last; last = 3; } *value = b->p[last]; b->p[last] = 0; if (count == 2) { void *leftover = b->p[slast]; // second to last stb_bucket_free(b); return (stb_ps *) leftover; } return ps; } case STB_ps_array: { stb_ps_array *a = GetArray(ps); *value = a->p[a->count-1]; if (a->count == 4) return stb_ps_remove(ps, *value); --a->count; return ps; } case STB_ps_hash: { stb_ps_hash *h = GetHash(ps); void **t = h->table; stb_uint32 n = h->any_offset; while (stb_ps_empty(t[n])) n = (n + 1) & h->mask; *value = t[n]; h->any_offset = (n+1) & h->mask; // check if we need to skip down to the previous type if (h->count-1 < stb_ps_array_max || h->count-1 == h->shrink_threshhold) return stb_ps_remove(ps, *value); t[n] = STB_DEL; -- h->count; ++ h->count_deletes; return ps; } } return ps; /* NOTREACHED */ } void ** stb_ps_getlist(stb_ps *ps, int *count) { int i,n=0; void **p = NULL; switch (3 & (int) ps) { case STB_ps_direct: if (ps == NULL) { *count = 0; return NULL; } p = (void **) malloc(sizeof(*p) * 1); p[0] = ps; *count = 1; return p; case STB_ps_bucket: { stb_ps_bucket *b = GetBucket(ps); p = (void **) malloc(sizeof(*p) * STB_BUCKET_SIZE); for (i=0; i < STB_BUCKET_SIZE; ++i) if (b->p[i] != NULL) p[n++] = b->p[i]; break; } case STB_ps_array: { stb_ps_array *a = GetArray(ps); p = (void **) malloc(sizeof(*p) * a->count); memcpy(p, a->p, sizeof(*p) * a->count); *count = a->count; return p; } case STB_ps_hash: { stb_ps_hash *h = GetHash(ps); p = (void **) malloc(sizeof(*p) * h->count); for (i=0; i < h->size; ++i) if (!stb_ps_empty(h->table[i])) p[n++] = h->table[i]; break; } } *count = n; return p; } int stb_ps_writelist(stb_ps *ps, void **list, int size ) { int i,n=0; switch (3 & (int) ps) { case STB_ps_direct: if (ps == NULL || size <= 0) return 0; list[0] = ps; return 1; case STB_ps_bucket: { stb_ps_bucket *b = GetBucket(ps); for (i=0; i < STB_BUCKET_SIZE; ++i) if (b->p[i] != NULL && n < size) list[n++] = b->p[i]; return n; } case STB_ps_array: { stb_ps_array *a = GetArray(ps); n = stb_min(size, a->count); memcpy(list, a->p, sizeof(*list) * n); return n; } case STB_ps_hash: { stb_ps_hash *h = GetHash(ps); if (size <= 0) return 0; for (i=0; i < h->count; ++i) { if (!stb_ps_empty(h->table[i])) { list[n++] = h->table[i]; if (n == size) break; } } return n; } } return 0; /* NOTREACHED */ } int stb_ps_enum(stb_ps *ps, void *data, int (*func)(void *value, void *data)) { int i; switch (3 & (int) ps) { case STB_ps_direct: if (ps == NULL) return STB_TRUE; return func(ps, data); case STB_ps_bucket: { stb_ps_bucket *b = GetBucket(ps); for (i=0; i < STB_BUCKET_SIZE; ++i) if (b->p[i] != NULL) if (!func(b->p[i], data)) return STB_FALSE; return STB_TRUE; } case STB_ps_array: { stb_ps_array *a = GetArray(ps); for (i=0; i < a->count; ++i) if (!func(a->p[i], data)) return STB_FALSE; return STB_TRUE; } case STB_ps_hash: { stb_ps_hash *h = GetHash(ps); for (i=0; i < h->count; ++i) if (!stb_ps_empty(h->table[i])) if (!func(h->table[i], data)) return STB_FALSE; return STB_TRUE; } } return STB_TRUE; /* NOTREACHED */ } int stb_ps_count (stb_ps *ps) { switch (3 & (int) ps) { case STB_ps_direct: return ps != NULL; case STB_ps_bucket: { stb_ps_bucket *b = GetBucket(ps); return (b->p[0] != NULL) + (b->p[1] != NULL) + (b->p[2] != NULL) + (b->p[3] != NULL); } case STB_ps_array: { stb_ps_array *a = GetArray(ps); return a->count; } case STB_ps_hash: { stb_ps_hash *h = GetHash(ps); return h->count; } } return 0; } void ** stb_ps_fastlist(stb_ps *ps, int *count) { static void *storage; switch (3 & (int) ps) { case STB_ps_direct: if (ps == NULL) { *count = 0; return NULL; } storage = ps; *count = 1; return &storage; case STB_ps_bucket: { stb_ps_bucket *b = GetBucket(ps); *count = STB_BUCKET_SIZE; return b->p; } case STB_ps_array: { stb_ps_array *a = GetArray(ps); *count = a->count; return a->p; } case STB_ps_hash: { stb_ps_hash *h = GetHash(ps); *count = h->size; return h->table; } } return NULL; /* NOTREACHED */ } int stb_ps_subset(stb_ps *bigger, stb_ps *smaller) { int i, listlen; void **list = stb_ps_fastlist(smaller, &listlen); for(i=0; i < listlen; ++i) if (stb_ps_fastlist_valid(list[i])) if (!stb_ps_find(bigger, list[i])) return 0; return 1; } int stb_ps_eq(stb_ps *p0, stb_ps *p1) { if (stb_ps_count(p0) != stb_ps_count(p1)) return 0; return stb_ps_subset(p0, p1); } #undef GetBucket #undef GetArray #undef GetHash #undef EncodeBucket #undef EncodeArray #undef EncodeHash #endif ////////////////////////////////////////////////////////////////////////////// // // Random Numbers via Meresenne Twister or LCG // STB_EXTERN unsigned long stb_srandLCG(unsigned long seed); STB_EXTERN unsigned long stb_randLCG(void); STB_EXTERN double stb_frandLCG(void); STB_EXTERN void stb_srand(unsigned long seed); STB_EXTERN unsigned long stb_rand(void); STB_EXTERN double stb_frand(void); STB_EXTERN void stb_shuffle(void *p, size_t n, size_t sz, unsigned long seed); STB_EXTERN void stb_reverse(void *p, size_t n, size_t sz); STB_EXTERN unsigned long stb_randLCG_explicit(unsigned long seed); #define stb_rand_define(x,y) \ \ unsigned long x(void) \ { \ static unsigned long stb__rand = y; \ stb__rand = stb__rand * 2147001325 + 715136305; /* BCPL */ \ return 0x31415926 ^ ((stb__rand >> 16) + (stb__rand << 16)); \ } #ifdef STB_DEFINE unsigned long stb_randLCG_explicit(unsigned long seed) { return seed * 2147001325 + 715136305; } static unsigned long stb__rand_seed=0; unsigned long stb_srandLCG(unsigned long seed) { unsigned long previous = stb__rand_seed; stb__rand_seed = seed; return previous; } unsigned long stb_randLCG(void) { stb__rand_seed = stb__rand_seed * 2147001325 + 715136305; // BCPL generator // shuffle non-random bits to the middle, and xor to decorrelate with seed return 0x31415926 ^ ((stb__rand_seed >> 16) + (stb__rand_seed << 16)); } double stb_frandLCG(void) { return stb_randLCG() / ((double) (1 << 16) * (1 << 16)); } void stb_shuffle(void *p, size_t n, size_t sz, unsigned long seed) { char *a; unsigned long old_seed; int i; if (seed) old_seed = stb_srandLCG(seed); a = (char *) p + (n-1) * sz; for (i=n; i > 1; --i) { int j = stb_randLCG() % i; stb_swap(a, (char *) p + j * sz, sz); a -= sz; } if (seed) stb_srandLCG(old_seed); } void stb_reverse(void *p, size_t n, size_t sz) { int i,j = n-1; for (i=0; i < j; ++i,--j) { stb_swap((char *) p + i * sz, (char *) p + j * sz, sz); } } // public domain Mersenne Twister by Michael Brundage #define STB__MT_LEN 624 int stb__mt_index = STB__MT_LEN*sizeof(unsigned long)+1; unsigned long stb__mt_buffer[STB__MT_LEN]; void stb_srand(unsigned long seed) { int i; unsigned long old = stb_srandLCG(seed); for (i = 0; i < STB__MT_LEN; i++) stb__mt_buffer[i] = stb_randLCG(); stb_srandLCG(old); stb__mt_index = STB__MT_LEN*sizeof(unsigned long); } #define STB__MT_IA 397 #define STB__MT_IB (STB__MT_LEN - STB__MT_IA) #define STB__UPPER_MASK 0x80000000 #define STB__LOWER_MASK 0x7FFFFFFF #define STB__MATRIX_A 0x9908B0DF #define STB__TWIST(b,i,j) ((b)[i] & STB__UPPER_MASK) | ((b)[j] & STB__LOWER_MASK) #define STB__MAGIC(s) (((s)&1)*STB__MATRIX_A) unsigned long stb_rand() { unsigned long * b = stb__mt_buffer; int idx = stb__mt_index; unsigned long s,r; int i; if (idx >= STB__MT_LEN*sizeof(unsigned long)) { if (idx > STB__MT_LEN*sizeof(unsigned long)) stb_srand(0); idx = 0; i = 0; for (; i < STB__MT_IB; i++) { s = STB__TWIST(b, i, i+1); b[i] = b[i + STB__MT_IA] ^ (s >> 1) ^ STB__MAGIC(s); } for (; i < STB__MT_LEN-1; i++) { s = STB__TWIST(b, i, i+1); b[i] = b[i - STB__MT_IB] ^ (s >> 1) ^ STB__MAGIC(s); } s = STB__TWIST(b, STB__MT_LEN-1, 0); b[STB__MT_LEN-1] = b[STB__MT_IA-1] ^ (s >> 1) ^ STB__MAGIC(s); } stb__mt_index = idx + sizeof(unsigned long); r = *(unsigned long *)((unsigned char *)b + idx); r ^= (r >> 11); r ^= (r << 7) & 0x9D2C5680; r ^= (r << 15) & 0xEFC60000; r ^= (r >> 18); return r; } double stb_frand(void) { return stb_rand() / ((double) (1 << 16) * (1 << 16)); } #endif ////////////////////////////////////////////////////////////////////////////// // // stb_dupe // // stb_dupe is a duplicate-finding system for very, very large data // structures--large enough that sorting is too slow, but not so large // that we can't keep all the data in memory. using it works as follows: // // 1. create an stb_dupe: // provide a hash function // provide an equality function // provide an estimate for the size // optionally provide a comparison function // // 2. traverse your data, 'adding' pointers to the stb_dupe // // 3. finish and ask for duplicates // // the stb_dupe will discard its intermediate data and build // a collection of sorted lists of duplicates, with non-duplicate // entries omitted entirely // // // Implementation strategy: // // while collecting the N items, we keep a hash table of approximate // size sqrt(N). (if you tell use the N up front, the hash table is // just that size exactly) // // each entry in the hash table is just an stb__arr of pointers (no need // to use stb_ps, because we don't need to delete from these) // // for step 3, for each entry in the hash table, we apply stb_dupe to it // recursively. once the size gets small enough (or doesn't decrease // significantly), we switch to either using qsort() on the comparison // function, or else we just do the icky N^2 gather typedef struct stb_dupe stb_dupe; typedef int (*stb_compare_func)(void *a, void *b); typedef int (*stb_hash_func)(void *a, unsigned int seed); STB_EXTERN void stb_dupe_free(stb_dupe *sd); STB_EXTERN stb_dupe *stb_dupe_create(stb_hash_func hash, stb_compare_func eq, int size, stb_compare_func ineq); STB_EXTERN void stb_dupe_add(stb_dupe *sd, void *item); STB_EXTERN void stb_dupe_finish(stb_dupe *sd); STB_EXTERN int stb_dupe_numsets(stb_dupe *sd); STB_EXTERN void **stb_dupe_set(stb_dupe *sd, int num); STB_EXTERN int stb_dupe_set_count(stb_dupe *sd, int num); struct stb_dupe { void ***hash_table; int hash_size; int size_log2; int population; int hash_shift; stb_hash_func hash; stb_compare_func eq; stb_compare_func ineq; void ***dupes; }; #ifdef STB_DEFINE int stb_dupe_numsets(stb_dupe *sd) { assert(sd->hash_table == NULL); return stb_arr_len(sd->dupes); } void **stb_dupe_set(stb_dupe *sd, int num) { assert(sd->hash_table == NULL); return sd->dupes[num]; } int stb_dupe_set_count(stb_dupe *sd, int num) { assert(sd->hash_table == NULL); return stb_arr_len(sd->dupes[num]); } stb_dupe *stb_dupe_create(stb_hash_func hash, stb_compare_func eq, int size, stb_compare_func ineq) { int i, hsize; stb_dupe *sd = (stb_dupe *) malloc(sizeof(*sd)); sd->size_log2 = 4; hsize = 1 << sd->size_log2; while (hsize * hsize < size) { ++sd->size_log2; hsize *= 2; } sd->hash = hash; sd->eq = eq; sd->ineq = ineq; sd->hash_shift = 0; sd->population = 0; sd->hash_size = hsize; sd->hash_table = (void ***) malloc(sizeof(*sd->hash_table) * hsize); for (i=0; i < hsize; ++i) sd->hash_table[i] = NULL; sd->dupes = NULL; return sd; } void stb_dupe_add(stb_dupe *sd, void *item) { stb_uint32 hash = sd->hash(item, sd->hash_shift); int z = hash & (sd->hash_size-1); stb_arr_push(sd->hash_table[z], item); ++sd->population; } void stb_dupe_free(stb_dupe *sd) { int i; for (i=0; i < stb_arr_len(sd->dupes); ++i) if (sd->dupes[i]) stb_arr_free(sd->dupes[i]); stb_arr_free(sd->dupes); free(sd); } static stb_compare_func stb__compare; static int stb__dupe_compare(const void *a, const void *b) { void *p = *(void **) a; void *q = *(void **) b; return stb__compare(p,q); } void stb_dupe_finish(stb_dupe *sd) { int i,j,k; assert(sd->dupes == NULL); for (i=0; i < sd->hash_size; ++i) { void ** list = sd->hash_table[i]; if (list != NULL) { int n = stb_arr_len(list); // @TODO: measure to find good numbers instead of just making them up! int thresh = (sd->ineq ? 200 : 20); // if n is large enough to be worth it, and n is smaller than // before (so we can guarantee we'll use a smaller hash table); // and there are enough hash bits left, assuming full 32-bit hash if (n > thresh && n < (sd->population >> 3) && sd->hash_shift + sd->size_log2*2 < 32) { // recursively process this row using stb_dupe, O(N log log N) stb_dupe *d = stb_dupe_create(sd->hash, sd->eq, n, sd->ineq); d->hash_shift = stb_randLCG_explicit(sd->hash_shift); for (j=0; j < n; ++j) stb_dupe_add(d, list[j]); stb_arr_free(sd->hash_table[i]); stb_dupe_finish(d); for (j=0; j < stb_arr_len(d->dupes); ++j) { stb_arr_push(sd->dupes, d->dupes[j]); d->dupes[j] = NULL; // take over ownership } stb_dupe_free(d); } else if (sd->ineq) { // process this row using qsort(), O(N log N) stb__compare = sd->ineq; qsort(list, n, sizeof(list[0]), stb__dupe_compare); // find equal subsequences of the list for (j=0; j < n-1; ) { // find a subsequence from j..k for (k=j; k < n; ++k) // only use ineq so eq can be left undefined if (sd->ineq(list[j], list[k])) break; // k is the first one not in the subsequence if (k-j > 1) { void **mylist = NULL; stb_arr_setlen(mylist, k-j); memcpy(mylist, list+j, sizeof(list[j]) * (k-j)); stb_arr_push(sd->dupes, mylist); } j = k; } stb_arr_free(sd->hash_table[i]); } else { // process this row using eq(), O(N^2) for (j=0; j < n; ++j) { if (list[j] != NULL) { void **output = NULL; for (k=j+1; k < n; ++k) { if (sd->eq(list[j], list[k])) { if (output == NULL) stb_arr_push(output, list[j]); stb_arr_push(output, list[k]); list[k] = NULL; } } list[j] = NULL; if (output) stb_arr_push(sd->dupes, output); } } stb_arr_free(sd->hash_table[i]); } } } free(sd->hash_table); sd->hash_table = NULL; } #endif ////////////////////////////////////////////////////////////////////////////// // // templatized Sort routine // // This is an attempt to implement a templated sorting algorithm. // To use it, you have to explicitly instantiate it as a _function_, // then you call that function. This allows the comparison to be inlined, // giving the sort similar performance to C++ sorts. // // It implements quicksort with three-way-median partitioning (generally // well-behaved), with a final insertion sort pass. // // When you define the compare expression, you should assume you have // elements of your array pointed to by 'a' and 'b', and perform the comparison // on those. OR you can use one or more statements; first say '0;', then // write whatever code you want, and compute the result into a variable 'c'. #define stb_declare_sort(FUNCNAME, TYPE) \ void FUNCNAME(TYPE *p, int n) #define stb_define_sort(FUNCNAME,TYPE,COMPARE) \ stb__define_sort( void, FUNCNAME,TYPE,COMPARE) #define stb_define_sort_static(FUNCNAME,TYPE,COMPARE) \ stb__define_sort(static void, FUNCNAME,TYPE,COMPARE) #define stb__define_sort(MODE, FUNCNAME, TYPE, COMPARE) \ \ static void STB_(FUNCNAME,_ins_sort)(TYPE *p, int n) \ { \ int i,j; \ for (i=1; i < n; ++i) { \ TYPE t = p[i], *a = &t; \ j = i; \ while (j > 0) { \ TYPE *b = &p[j-1]; \ int c = COMPARE; \ if (!c) break; \ p[j] = p[j-1]; \ --j; \ } \ if (i != j) \ p[j] = t; \ } \ } \ \ static void STB_(FUNCNAME,_quicksort)(TYPE *p, int n) \ { \ /* threshhold for transitioning to insertion sort */ \ while (n > 12) { \ TYPE *a,*b,t; \ int c01,c12,c,m,i,j; \ \ /* compute median of three */ \ m = n >> 1; \ a = &p[0]; \ b = &p[m]; \ c = COMPARE; \ c01 = c; \ a = &p[m]; \ b = &p[n-1]; \ c = COMPARE; \ c12 = c; \ /* 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; \ a = &p[0]; \ b = &p[n-1]; \ c = COMPARE; \ /* 0>mid && midn => n; 0 0 */ \ /* 0n: 0>n => 0; 0 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 */ \ b = &p[0]; \ for (;;++i) { \ a=&p[i]; \ c = COMPARE; \ if (!c) break; \ } \ a = &p[0]; \ for (;;--j) { \ b=&p[j]; \ c = COMPARE; \ if (!c) 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)) { \ STB_(FUNCNAME,_quicksort)(p,j); \ p = p+i; \ n = n-i; \ } else { \ STB_(FUNCNAME,_quicksort)(p+i, n-i); \ n = j; \ } \ } \ } \ \ MODE FUNCNAME(TYPE *p, int n) \ { \ STB_(FUNCNAME, _quicksort)(p, n); \ STB_(FUNCNAME, _ins_sort)(p, n); \ } \ ////////////////////////////////////////////////////////////////////////////// // // stb_bitset an array of booleans indexed by integers // typedef stb_uint32 stb_bitset; STB_EXTERN stb_bitset *stb_bitset_new(int value, int len); #define stb_bitset_clearall(arr,len) (memset(arr, 0, 4 * (len))) #define stb_bitset_setall(arr,len) (memset(arr, 255, 4 * (len))) #define stb_bitset_setbit(arr,n) ((arr)[(n) >> 5] |= (1 << (n & 31))) #define stb_bitset_clearbit(arr,n) ((arr)[(n) >> 5] &= ~(1 << (n & 31))) #define stb_bitset_testbit(arr,n) ((arr)[(n) >> 5] & (1 << (n & 31))) STB_EXTERN stb_bitset *stb_bitset_union(stb_bitset *p0, stb_bitset *p1, int len); STB_EXTERN int *stb_bitset_getlist(stb_bitset *out, int start, int end); STB_EXTERN int stb_bitset_eq(stb_bitset *p0, stb_bitset *p1, int len); STB_EXTERN int stb_bitset_disjoint(stb_bitset *p0, stb_bitset *p1, int len); STB_EXTERN int stb_bitset_disjoint_0(stb_bitset *p0, stb_bitset *p1, int len); STB_EXTERN int stb_bitset_subset(stb_bitset *bigger, stb_bitset *smaller, int len); STB_EXTERN int stb_bitset_unioneq_changed(stb_bitset *p0, stb_bitset *p1, int len); #ifdef STB_DEFINE int stb_bitset_eq(stb_bitset *p0, stb_bitset *p1, int len) { int i; for (i=0; i < len; ++i) if (p0[i] != p1[i]) return 0; return 1; } int stb_bitset_disjoint(stb_bitset *p0, stb_bitset *p1, int len) { int i; for (i=0; i < len; ++i) if (p0[i] & p1[i]) return 0; return 1; } int stb_bitset_disjoint_0(stb_bitset *p0, stb_bitset *p1, int len) { int i; for (i=0; i < len; ++i) if ((p0[i] | p1[i]) != 0xffffffff) return 0; return 1; } int stb_bitset_subset(stb_bitset *bigger, stb_bitset *smaller, int len) { int i; for (i=0; i < len; ++i) if ((bigger[i] & smaller[i]) != smaller[i]) return 0; return 1; } stb_bitset *stb_bitset_union(stb_bitset *p0, stb_bitset *p1, int len) { int i; stb_bitset *d = (stb_bitset *) malloc(sizeof(*d) * len); for (i=0; i < len; ++i) d[i] = p0[i] | p1[i]; return d; } int stb_bitset_unioneq_changed(stb_bitset *p0, stb_bitset *p1, int len) { int i, changed=0; for (i=0; i < len; ++i) { stb_bitset d = p0[i] | p1[i]; if (d != p0[i]) { p0[i] = d; changed = 1; } } return changed; } stb_bitset *stb_bitset_new(int value, int len) { int i; stb_bitset *d = (stb_bitset *) malloc(sizeof(*d) * len); if (value) value = 0xffffffff; for (i=0; i < len; ++i) d[i] = value; return d; } int *stb_bitset_getlist(stb_bitset *out, int start, int end) { int *list = NULL; int i; for (i=start; i < end; ++i) if (stb_bitset_testbit(out, i)) stb_arr_push(list, i); return list; } #endif ////////////////////////////////////////////////////////////////////////////// // // stb_wordwrap quality word-wrapping for fixed-width fonts // STB_EXTERN int stb_wordwrap(int *pairs, int pair_max, int count, char *str); STB_EXTERN int *stb_wordwrapalloc(int count, char *str); #ifdef STB_DEFINE int stb_wordwrap(int *pairs, int pair_max, int count, char *str) { int n=0,i=0, start=0,nonwhite=0; if (pairs == NULL) pair_max = 0x7ffffff0; else pair_max *= 2; // parse for(;;) { int s=i; // first whitespace char; last nonwhite+1 int w; // word start // accept whitespace while (isspace(str[i])) { if (str[i] == '\n' || str[i] == '\r') { if (str[i] + str[i+1] == '\n' + '\r') ++i; if (n >= pair_max) return -1; if (pairs) pairs[n] = start, pairs[n+1] = s-start; n += 2; nonwhite=0; start = i+1; s = start; } ++i; } if (i >= start+count) { // we've gone off the end using whitespace if (nonwhite) { if (n >= pair_max) return -1; if (pairs) pairs[n] = start, pairs[n+1] = s-start; n += 2; start = s = i; nonwhite=0; } else { // output all the whitespace while (i >= start+count) { if (n >= pair_max) return -1; if (pairs) pairs[n] = start, pairs[n+1] = count; n += 2; start += count; } s = start; } } if (str[i] == 0) break; // now scan out a word and see if it fits w = i; while (str[i] && !isspace(str[i])) { ++i; } // wrapped? if (i > start + count) { // huge? if (i-s <= count) { if (n >= pair_max) return -1; if (pairs) pairs[n] = start, pairs[n+1] = s-start; n += 2; start = w; } else { // This word is longer than one line. If we wrap it onto N lines // there are leftover chars. do those chars fit on the cur line? // But if we have leading whitespace, we force it to start here. if ((w-start) + ((i-w) % count) <= count || !nonwhite) { // output a full line if (n >= pair_max) return -1; if (pairs) pairs[n] = start, pairs[n+1] = count; n += 2; start += count; w = start; } else { // output a partial line, trimming trailing whitespace if (s != start) { if (n >= pair_max) return -1; if (pairs) pairs[n] = start, pairs[n+1] = s-start; n += 2; start = w; } } // now output full lines as needed while (start + count <= i) { if (n >= pair_max) return -1; if (pairs) pairs[n] = start, pairs[n+1] = count; n += 2; start += count; } } } nonwhite=1; } if (start < i) { if (n >= pair_max) return -1; if (pairs) pairs[n] = start, pairs[n+1] = i-start; n += 2; } return n>>1; } int *stb_wordwrapalloc(int count, char *str) { int n = stb_wordwrap(NULL,0,count,str); int *z = NULL; stb_arr_setlen(z, n*2); stb_wordwrap(z, n, count, str); return z; } #endif ////////////////////////////////////////////////////////////////////////////// // // stb_match: wildcards and regexping // STB_EXTERN int stb_wildmatch (char *expr, char *candidate); STB_EXTERN int stb_wildmatchi(char *expr, char *candidate); STB_EXTERN int stb_wildfind (char *expr, char *candidate); STB_EXTERN int stb_wildfindi (char *expr, char *candidate); STB_EXTERN int stb_regex(char *regex, char *candidate); typedef struct stb_matcher stb_matcher; STB_EXTERN stb_matcher *stb_regex_matcher(char *regex); STB_EXTERN int stb_matcher_match(stb_matcher *m, char *str); STB_EXTERN int stb_matcher_find(stb_matcher *m, char *str); STB_EXTERN void stb_matcher_free(stb_matcher *f); STB_EXTERN stb_matcher *stb_lex_matcher(void); STB_EXTERN int stb_lex_item(stb_matcher *m, char *str, int result); STB_EXTERN int stb_lex_item_wild(stb_matcher *matcher, char *regex, int result); STB_EXTERN int stb_lex(stb_matcher *m, char *str, int *len); #ifdef STB_DEFINE static int stb__match_qstring(char *candidate, char *qstring, int qlen, int insensitive) { int i; if (insensitive) { for (i=0; i < qlen; ++i) if (qstring[i] == '?') { if (!candidate[i]) return 0; } else if (tolower(qstring[i]) != tolower(candidate[i])) return 0; } else { for (i=0; i < qlen; ++i) if (qstring[i] == '?') { if (!candidate[i]) return 0; } else if (qstring[i] != candidate[i]) return 0; } return 1; } static int stb__find_qstring(char *candidate, char *qstring, int qlen, int insensitive) { char c; int offset=0; while (*qstring == '?') { ++qstring; --qlen; ++candidate; if (qlen == 0) return 0; if (*candidate == 0) return -1; } c = *qstring++; --qlen; if (insensitive) c = tolower(c); while (candidate[offset]) { if (c == (insensitive ? tolower(candidate[offset]) : candidate[offset])) if (stb__match_qstring(candidate+offset+1, qstring, qlen, insensitive)) return offset; ++offset; } return -1; } int stb__wildmatch_raw2(char *expr, char *candidate, int search, int insensitive) { int where=0; int start = -1; if (!search) { // parse to first '*' if (*expr != '*') start = 0; while (*expr != '*') { if (!*expr) return *candidate == 0 ? 0 : -1; if (*expr == '?') { if (!*candidate) return -1; } else { if (insensitive) { if (tolower(*candidate) != tolower(*expr)) return -1; } else if (*candidate != *expr) return -1; } ++candidate, ++expr, ++where; } } else { // 0-length search string if (!*expr) return 0; } assert(search || *expr == '*'); if (!search) ++expr; // implicit '*' at this point while (*expr) { int o=0; // combine redundant * characters while (expr[0] == '*') ++expr; // ok, at this point, expr[-1] == '*', // and expr[0] != '*' if (!expr[0]) return start >= 0 ? start : 0; // now find next '*' o = 0; while (expr[o] != '*') { if (expr[o] == 0) break; ++o; } // if no '*', scan to end, then match at end if (expr[o] == 0 && !search) { int z; for (z=0; z < o; ++z) if (candidate[z] == 0) return -1; while (candidate[z]) ++z; // ok, now check if they match if (stb__match_qstring(candidate+z-o, expr, o, insensitive)) return start >= 0 ? start : 0; return -1; } else { // if yes '*', then do stb__find_qmatch on the intervening chars int n = stb__find_qstring(candidate, expr, o, insensitive); if (n < 0) return -1; if (start < 0) start = where + n; expr += o; candidate += n+o; } if (*expr == 0) { assert(search); return start; } assert(*expr == '*'); ++expr; } return start >= 0 ? start : 0; } int stb__wildmatch_raw(char *expr, char *candidate, int search, int insensitive) { char buffer[256]; // handle multiple search strings char *s = strchr(expr, ';'); char *last = expr; while (s) { int z; // need to allow for non-writeable strings... assume they're small if (s - last < 256) { stb_strncpy(buffer, last, s-last+1); z = stb__wildmatch_raw2(buffer, candidate, search, insensitive); } else { *s = 0; z = stb__wildmatch_raw2(last, candidate, search, insensitive); *s = ';'; } if (z >= 0) return z; last = s+1; s = strchr(last, ';'); } return stb__wildmatch_raw2(last, candidate, search, insensitive); } int stb_wildmatch(char *expr, char *candidate) { return stb__wildmatch_raw(expr, candidate, 0,0) >= 0; } int stb_wildmatchi(char *expr, char *candidate) { return stb__wildmatch_raw(expr, candidate, 0,1) >= 0; } int stb_wildfind(char *expr, char *candidate) { return stb__wildmatch_raw(expr, candidate, 1,0); } int stb_wildfindi(char *expr, char *candidate) { return stb__wildmatch_raw(expr, candidate, 1,1); } typedef struct { stb_int16 transition[256]; } stb_dfa; // an NFA node represents a state you're in; it then has // an arbitrary number of edges dangling off of it // note this isn't utf8-y typedef struct { stb_int16 match; // character/set to match stb_uint16 node; // output node to go to } stb_nfa_edge; typedef struct { stb_int16 goal; // does reaching this win the prize? stb_uint8 active; // is this in the active list stb_nfa_edge *out; stb_uint16 *eps; // list of epsilon closures } stb_nfa_node; #define STB__DFA_UNDEF -1 #define STB__DFA_GOAL -2 #define STB__DFA_END -3 #define STB__DFA_MGOAL -4 #define STB__DFA_VALID 0 #define STB__NFA_STOP_GOAL -1 // compiled regexp struct stb_matcher { stb_uint16 start_node; stb_int16 dfa_start; stb_uint32 *charset; int num_charset; int match_start; stb_nfa_node *nodes; int does_lex; // dfa matcher stb_dfa * dfa; stb_uint32 * dfa_mapping; stb_int16 * dfa_result; int num_words_per_dfa; }; static int stb__add_node(stb_matcher *matcher) { stb_nfa_node z; z.active = 0; z.eps = 0; z.goal = 0; z.out = 0; stb_arr_push(matcher->nodes, z); return stb_arr_len(matcher->nodes)-1; } static void stb__add_epsilon(stb_matcher *matcher, int from, int to) { assert(from != to); if (matcher->nodes[from].eps == NULL) stb_arr_malloc((void **) &matcher->nodes[from].eps, matcher); stb_arr_push(matcher->nodes[from].eps, to); } static void stb__add_edge(stb_matcher *matcher, int from, int to, int type) { stb_nfa_edge z = { type, to }; if (matcher->nodes[from].out == NULL) stb_arr_malloc((void **) &matcher->nodes[from].out, matcher); stb_arr_push(matcher->nodes[from].out, z); } static char *stb__reg_parse_alt(stb_matcher *m, int s, char *r, stb_uint16 *e); static char *stb__reg_parse(stb_matcher *matcher, int start, char *regex, stb_uint16 *end) { int n; int last_start = -1; stb_uint16 last_end = start; while (*regex) { switch (*regex) { case '(': last_start = last_end; regex = stb__reg_parse_alt(matcher, last_end, regex+1, &last_end); if (regex == NULL || *regex != ')') return NULL; ++regex; break; case '|': case ')': *end = last_end; return regex; case '?': if (last_start < 0) return NULL; stb__add_epsilon(matcher, last_start, last_end); ++regex; break; case '*': if (last_start < 0) return NULL; stb__add_epsilon(matcher, last_start, last_end); // fall through case '+': if (last_start < 0) return NULL; stb__add_epsilon(matcher, last_end, last_start); // prevent links back to last_end from chaining to last_start n = stb__add_node(matcher); stb__add_epsilon(matcher, last_end, n); last_end = n; ++regex; break; case '{': // not supported! // @TODO: given {n,m}, clone last_start to last_end m times, // and include epsilons from start to first m-n blocks return NULL; case '\\': ++regex; if (!*regex) return NULL; // fallthrough default: // match exactly this character n = stb__add_node(matcher); stb__add_edge(matcher, last_end, n, *regex); last_start = last_end; last_end = n; ++regex; break; case '$': n = stb__add_node(matcher); stb__add_edge(matcher, last_end, n, '\n'); last_start = last_end; last_end = n; ++regex; break; case '.': n = stb__add_node(matcher); stb__add_edge(matcher, last_end, n, -1); last_start = last_end; last_end = n; ++regex; break; case '[': { stb_uint8 flags[256]; int invert = 0,z; ++regex; if (matcher->num_charset == 0) { matcher->charset = (stb_uint *) stb_malloc(matcher, sizeof(*matcher->charset) * 256); memset(matcher->charset, 0, sizeof(*matcher->charset) * 256); } memset(flags,0,sizeof(flags)); // leading ^ is special if (*regex == '^') ++regex, invert = 1; // leading ] is special if (*regex == ']') { flags[']'] = 1; ++regex; } while (*regex != ']') { stb_uint a; if (!*regex) return NULL; a = *regex++; if (regex[0] == '-' && regex[1] != ']') { stb_uint i,b = regex[1]; regex += 2; if (b == 0) return NULL; if (a > b) return NULL; for (i=a; i <= b; ++i) flags[i] = 1; } else flags[a] = 1; } ++regex; if (invert) { int i; for (i=0; i < 256; ++i) flags[i] = 1-flags[i]; } // now check if any existing charset matches for (z=0; z < matcher->num_charset; ++z) { int i, k[2] = { 0, 1 << z}; for (i=0; i < 256; ++i) { unsigned int f = k[flags[i]]; if ((matcher->charset[i] & k[1]) != f) break; } if (i == 256) break; } if (z == matcher->num_charset) { int i; ++matcher->num_charset; if (matcher->num_charset > 32) { assert(0); /* NOTREACHED */ return NULL; // too many charsets, oops } for (i=0; i < 256; ++i) if (flags[i]) matcher->charset[i] |= (1 << z); } n = stb__add_node(matcher); stb__add_edge(matcher, last_end, n, -2 - z); last_start = last_end; last_end = n; break; } } } *end = last_end; return regex; } static char *stb__reg_parse_alt(stb_matcher *matcher, int start, char *regex, stb_uint16 *end) { stb_uint16 last_end = start; stb_uint16 main_end; int head, tail; head = stb__add_node(matcher); stb__add_epsilon(matcher, start, head); regex = stb__reg_parse(matcher, head, regex, &last_end); if (regex == NULL) return NULL; if (*regex == 0 || *regex == ')') { *end = last_end; return regex; } main_end = last_end; tail = stb__add_node(matcher); stb__add_epsilon(matcher, last_end, tail); // start alternatives from the same starting node; use epsilon // transitions to combine their endings while(*regex && *regex != ')') { assert(*regex == '|'); head = stb__add_node(matcher); stb__add_epsilon(matcher, start, head); regex = stb__reg_parse(matcher, head, regex+1, &last_end); if (regex == NULL) return NULL; stb__add_epsilon(matcher, last_end, tail); } *end = tail; return regex; } static char *stb__wild_parse(stb_matcher *matcher, int start, char *str, stb_uint16 *end) { int n; stb_uint16 last_end; last_end = stb__add_node(matcher); stb__add_epsilon(matcher, start, last_end); while (*str) { switch (*str) { // fallthrough default: // match exactly this character n = stb__add_node(matcher); if (toupper(*str) == tolower(*str)) { stb__add_edge(matcher, last_end, n, *str); } else { stb__add_edge(matcher, last_end, n, tolower(*str)); stb__add_edge(matcher, last_end, n, toupper(*str)); } last_end = n; ++str; break; case '?': n = stb__add_node(matcher); stb__add_edge(matcher, last_end, n, -1); last_end = n; ++str; break; case '*': n = stb__add_node(matcher); stb__add_edge(matcher, last_end, n, -1); stb__add_epsilon(matcher, last_end, n); stb__add_epsilon(matcher, n, last_end); last_end = n; ++str; break; } } // now require end of string to match n = stb__add_node(matcher); stb__add_edge(matcher, last_end, n, 0); last_end = n; *end = last_end; return str; } static int stb__opt(stb_matcher *m, int n) { for(;;) { stb_nfa_node *p = &m->nodes[n]; if (p->goal) return n; if (stb_arr_len(p->out)) return n; if (stb_arr_len(p->eps) != 1) return n; n = p->eps[0]; } } static void stb__optimize(stb_matcher *m) { // if the target of any edge is a node with exactly // one out-epsilon, shorten it int i,j; for (i=0; i < stb_arr_len(m->nodes); ++i) { stb_nfa_node *p = &m->nodes[i]; for (j=0; j < stb_arr_len(p->out); ++j) p->out[j].node = stb__opt(m,p->out[j].node); for (j=0; j < stb_arr_len(p->eps); ++j) p->eps[j] = stb__opt(m,p->eps[j] ); } m->start_node = stb__opt(m,m->start_node); } void stb_matcher_free(stb_matcher *f) { stb_free(f); } static stb_matcher *stb__alloc_matcher(void) { stb_matcher *matcher = (stb_matcher *) stb_malloc(0,sizeof(*matcher)); matcher->start_node = 0; stb_arr_malloc((void **) &matcher->nodes, matcher); matcher->num_charset = 0; matcher->match_start = 0; matcher->does_lex = 0; matcher->dfa_start = STB__DFA_UNDEF; stb_arr_malloc((void **) &matcher->dfa, matcher); stb_arr_malloc((void **) &matcher->dfa_mapping, matcher); stb_arr_malloc((void **) &matcher->dfa_result, matcher); stb__add_node(matcher); return matcher; } static void stb__lex_reset(stb_matcher *matcher) { // flush cached dfa data stb_arr_setlen(matcher->dfa, 0); stb_arr_setlen(matcher->dfa_mapping, 0); stb_arr_setlen(matcher->dfa_result, 0); matcher->dfa_start = STB__DFA_UNDEF; } stb_matcher *stb_regex_matcher(char *regex) { char *z; stb_uint16 end; stb_matcher *matcher = stb__alloc_matcher(); if (*regex == '^') { matcher->match_start = 1; ++regex; } z = stb__reg_parse_alt(matcher, matcher->start_node, regex, &end); if (!z || *z) { stb_free(matcher); return NULL; } ((matcher->nodes)[(int) end]).goal = STB__NFA_STOP_GOAL; return matcher; } stb_matcher *stb_lex_matcher(void) { stb_matcher *matcher = stb__alloc_matcher(); matcher->match_start = 1; matcher->does_lex = 1; return matcher; } int stb_lex_item(stb_matcher *matcher, char *regex, int result) { char *z; stb_uint16 end; z = stb__reg_parse_alt(matcher, matcher->start_node, regex, &end); if (z == NULL) return 0; stb__lex_reset(matcher); matcher->nodes[(int) end].goal = result; return 1; } int stb_lex_item_wild(stb_matcher *matcher, char *regex, int result) { char *z; stb_uint16 end; z = stb__wild_parse(matcher, matcher->start_node, regex, &end); if (z == NULL) return 0; stb__lex_reset(matcher); matcher->nodes[(int) end].goal = result; return 1; } static void stb__clear(stb_matcher *m, stb_uint16 *list) { int i; for (i=0; i < stb_arr_len(list); ++i) m->nodes[(int) list[i]].active = 0; } static int stb__clear_goalcheck(stb_matcher *m, stb_uint16 *list) { int i, t=0; for (i=0; i < stb_arr_len(list); ++i) { t += m->nodes[(int) list[i]].goal; m->nodes[(int) list[i]].active = 0; } return t; } static stb_uint16 * stb__add_if_inactive(stb_matcher *m, stb_uint16 *list, int n) { if (!m->nodes[n].active) { stb_arr_push(list, n); m->nodes[n].active = 1; } return list; } static stb_uint16 * stb__eps_closure(stb_matcher *m, stb_uint16 *list) { int i,n = stb_arr_len(list); for(i=0; i < n; ++i) { stb_uint16 *e = m->nodes[(int) list[i]].eps; if (e) { int j,k = stb_arr_len(e); for (j=0; j < k; ++j) list = stb__add_if_inactive(m, list, e[j]); n = stb_arr_len(list); } } return list; } int stb_matcher_match(stb_matcher *m, char *str) { int result = 0; int i,j,y,z; stb_uint16 *previous = NULL; stb_uint16 *current = NULL; stb_uint16 *temp; stb_arr_setsize(previous, 4); stb_arr_setsize(current, 4); previous = stb__add_if_inactive(m, previous, m->start_node); previous = stb__eps_closure(m,previous); stb__clear(m, previous); while (*str && stb_arr_len(previous)) { y = stb_arr_len(previous); for (i=0; i < y; ++i) { stb_nfa_node *n = &m->nodes[(int) previous[i]]; z = stb_arr_len(n->out); for (j=0; j < z; ++j) { if (n->out[j].match >= 0) { if (n->out[j].match == *str) current = stb__add_if_inactive(m, current, n->out[j].node); } else if (n->out[j].match == -1) { if (*str != '\n') current = stb__add_if_inactive(m, current, n->out[j].node); } else if (n->out[j].match < -1) { int z = -n->out[j].match - 2; if (m->charset[(stb_uint8) *str] & (1 << z)) current = stb__add_if_inactive(m, current, n->out[j].node); } } } stb_arr_setlen(previous, 0); temp = previous; previous = current; current = temp; previous = stb__eps_closure(m,previous); stb__clear(m, previous); ++str; } // transition to pick up a '$' at the end y = stb_arr_len(previous); for (i=0; i < y; ++i) m->nodes[(int) previous[i]].active = 1; for (i=0; i < y; ++i) { stb_nfa_node *n = &m->nodes[(int) previous[i]]; z = stb_arr_len(n->out); for (j=0; j < z; ++j) { if (n->out[j].match == '\n') current = stb__add_if_inactive(m, current, n->out[j].node); } } previous = stb__eps_closure(m,previous); stb__clear(m, previous); y = stb_arr_len(previous); for (i=0; i < y; ++i) if (m->nodes[(int) previous[i]].goal) result = 1; stb_arr_free(previous); stb_arr_free(current); return result && *str == 0; } stb_int16 stb__get_dfa_node(stb_matcher *m, stb_uint16 *list) { stb_uint16 node; stb_uint32 data[8], *state, *newstate; int i,j,n; state = (stb_uint32 *) stb_temp(data, m->num_words_per_dfa * 4); memset(state, 0, m->num_words_per_dfa*4); n = stb_arr_len(list); for (i=0; i < n; ++i) { int x = list[i]; state[x >> 5] |= 1 << (x & 31); } // @TODO use a hash table n = stb_arr_len(m->dfa_mapping); i=j=0; for(; j < n; ++i, j += m->num_words_per_dfa) { // @TODO special case for <= 32 if (!memcmp(state, m->dfa_mapping + j, m->num_words_per_dfa*4)) { node = i; goto done; } } assert(stb_arr_len(m->dfa) == i); node = i; newstate = stb_arr_addn(m->dfa_mapping, m->num_words_per_dfa); memcpy(newstate, state, m->num_words_per_dfa*4); // set all transitions to 'unknown' stb_arr_add(m->dfa); memset(m->dfa[i].transition, -1, sizeof(m->dfa[i].transition)); if (m->does_lex) { int result = -1; n = stb_arr_len(list); for (i=0; i < n; ++i) { if (m->nodes[(int) list[i]].goal > result) result = m->nodes[(int) list[i]].goal; } stb_arr_push(m->dfa_result, result); } done: stb_tempfree(data, state); return node; } static int stb__matcher_dfa(stb_matcher *m, char *str_c, int *len) { stb_uint8 *str = (stb_uint8 *) str_c; stb_int16 node,prevnode; stb_dfa *trans; int match_length = 0; stb_int16 match_result=0; if (m->dfa_start == STB__DFA_UNDEF) { stb_uint16 *list; m->num_words_per_dfa = (stb_arr_len(m->nodes)+31) >> 5; stb__optimize(m); list = stb__add_if_inactive(m, NULL, m->start_node); list = stb__eps_closure(m,list); if (m->does_lex) { m->dfa_start = stb__get_dfa_node(m,list); stb__clear(m, list); // DON'T allow start state to be a goal state! // this allows people to specify regexes that can match 0 // characters without them actually matching (also we don't // check _before_ advancing anyway if (m->dfa_start <= STB__DFA_MGOAL) m->dfa_start = -(m->dfa_start - STB__DFA_MGOAL); } else { if (stb__clear_goalcheck(m, list)) m->dfa_start = STB__DFA_GOAL; else m->dfa_start = stb__get_dfa_node(m,list); } stb_arr_free(list); } prevnode = STB__DFA_UNDEF; node = m->dfa_start; trans = m->dfa; if (m->dfa_start == STB__DFA_GOAL) return 1; for(;;) { assert(node >= STB__DFA_VALID); // fast inner DFA loop; especially if STB__DFA_VALID is 0 do { prevnode = node; node = trans[node].transition[*str++]; } while (node >= STB__DFA_VALID); assert(node >= STB__DFA_MGOAL - stb_arr_len(m->dfa)); assert(node < stb_arr_len(m->dfa)); // special case for lex: need _longest_ match, so notice goal // state without stopping if (node <= STB__DFA_MGOAL) { match_length = str - (stb_uint8 *) str_c; node = -(node - STB__DFA_MGOAL); match_result = node; continue; } // slow NFA->DFA conversion // or we hit the goal or the end of the string, but those // can only happen once per search... if (node == STB__DFA_UNDEF) { // build a list -- @TODO special case <= 32 states // heck, use a more compact data structure for <= 16 and <= 8 ?! // @TODO keep states/newstates around instead of reallocating them stb_uint16 *states = NULL; stb_uint16 *newstates = NULL; int i,j,y,z; stb_uint32 *flags = &m->dfa_mapping[prevnode * m->num_words_per_dfa]; assert(prevnode != STB__DFA_UNDEF); stb_arr_setsize(states, 4); stb_arr_setsize(newstates,4); for (j=0; j < m->num_words_per_dfa; ++j) { for (i=0; i < 32; ++i) { if (*flags & (1 << i)) stb_arr_push(states, j*32+i); } ++flags; } // states is now the states we were in in the previous node; // so now we can compute what node it transitions to on str[-1] y = stb_arr_len(states); for (i=0; i < y; ++i) { stb_nfa_node *n = &m->nodes[(int) states[i]]; z = stb_arr_len(n->out); for (j=0; j < z; ++j) { if (n->out[j].match >= 0) { if (n->out[j].match == str[-1] || (str[-1] == 0 && n->out[j].match == '\n')) newstates = stb__add_if_inactive(m, newstates, n->out[j].node); } else if (n->out[j].match == -1) { if (str[-1] != '\n' && str[-1]) newstates = stb__add_if_inactive(m, newstates, n->out[j].node); } else if (n->out[j].match < -1) { int z = -n->out[j].match - 2; if (m->charset[str[-1]] & (1 << z)) newstates = stb__add_if_inactive(m, newstates, n->out[j].node); } } } // AND add in the start state! if (!m->match_start || (str[-1] == '\n' && !m->does_lex)) newstates = stb__add_if_inactive(m, newstates, m->start_node); // AND epsilon close it newstates = stb__eps_closure(m, newstates); // if it's a goal state, then that's all there is to it if (stb__clear_goalcheck(m, newstates)) { if (m->does_lex) { match_length = str - (stb_uint8 *) str_c; node = stb__get_dfa_node(m,newstates); match_result = node; node = -node + STB__DFA_MGOAL; trans = m->dfa; // could have gotten realloc()ed } else node = STB__DFA_GOAL; } else if (str[-1] == 0 || stb_arr_len(newstates) == 0) { node = STB__DFA_END; } else { node = stb__get_dfa_node(m,newstates); trans = m->dfa; // could have gotten realloc()ed } trans[prevnode].transition[str[-1]] = node; if (node <= STB__DFA_MGOAL) node = -(node - STB__DFA_MGOAL); stb_arr_free(newstates); stb_arr_free(states); } if (node == STB__DFA_GOAL) { return 1; } if (node == STB__DFA_END) { if (m->does_lex) { if (match_result) { if (len) *len = match_length; return m->dfa_result[(int) match_result]; } } return 0; } assert(node != STB__DFA_UNDEF); } } int stb_matcher_find(stb_matcher *m, char *str) { assert(m->does_lex == 0); return stb__matcher_dfa(m, str, NULL); } int stb_lex(stb_matcher *m, char *str, int *len) { assert(m->does_lex); return stb__matcher_dfa(m, str, len); } int stb_regex(char *regex, char *str) { static stb_perfect p; static stb_matcher ** matchers; static char ** regexps; static char ** regexp_cache; static unsigned short *mapping; int z = stb_perfect_hash(&p, (int) regex); if (z >= 0) { if (strcmp(regex, regexp_cache[(int) mapping[z]])) { int i = mapping[z]; stb_matcher_free(matchers[i]); free(regexp_cache[i]); regexps[i] = regex; regexp_cache[i] = strdup(regex); matchers[i] = stb_regex_matcher(regex); } } else { int i,n; if (regex == NULL) { for (i=0; i < stb_arr_len(matchers); ++i) { stb_matcher_free(matchers[i]); free(regexp_cache[i]); } stb_arr_free(matchers); stb_arr_free(regexps); stb_arr_free(regexp_cache); stb_perfect_destroy(&p); free(mapping); mapping = NULL; return -1; } stb_arr_push(regexps, regex); stb_arr_push(regexp_cache, strdup(regex)); stb_arr_push(matchers, stb_regex_matcher(regex)); stb_perfect_destroy(&p); n = stb_perfect_create(&p, (unsigned int *) (char **) regexps, stb_arr_len(regexps)); mapping = (unsigned short *) realloc(mapping, n * sizeof(*mapping)); for (i=0; i < stb_arr_len(regexps); ++i) mapping[stb_perfect_hash(&p, (int) regexps[i])] = i; z = stb_perfect_hash(&p, (int) regex); } return stb_matcher_find(matchers[(int) mapping[z]], str); } #endif // STB_DEFINE #if 0 ////////////////////////////////////////////////////////////////////////////// // // C source-code introspection // // runtime structure typedef struct { char *name; char *type; // base type char *comment; // content of comment field int size; // size of base type int offset; // field offset int arrcount[8]; // array sizes; -1 = pointer indirection; 0 = end of list } stb_info_field; typedef struct { char *structname; int size; int num_fields; stb_info_field *fields; } stb_info_struct; extern stb_info_struct stb_introspect_output[]; // STB_EXTERN void stb_introspect_precompiled(stb_info_struct *compiled); STB_EXTERN void stb__introspect(char *path, char *file); #define stb_introspect_ship() stb__introspect(NULL, NULL, stb__introspect_output) #ifdef STB_SHIP #define stb_introspect() stb_introspect_ship() #define stb_introspect_path(p) stb_introspect_ship() #else // bootstrapping: define stb_introspect() (or 'path') the first time #define stb_introspect() stb__introspect(NULL, __FILE__, NULL) #define stb_introspect_auto() stb__introspect(NULL, __FILE__, stb__introspect_output) #define stb_introspect_path(p) stb__introspect(p, __FILE__, NULL) #define stb_introspect_path(p) stb__introspect(p, __FILE__, NULL) #endif #ifdef STB_DEFINE #ifndef STB_INTROSPECT_CPP #ifdef __cplusplus #define STB_INTROSPECT_CPP 1 #else #define STB_INTROSPECT_CPP 0 #endif #endif void stb_introspect_precompiled(stb_info_struct *compiled) { } static void stb__introspect_filename(char *buffer, char *path) { #if STB_INTROSPECT_CPP sprintf(buffer, "%s/stb_introspect.cpp", path); #else sprintf(buffer, "%s/stb_introspect.c", path); #endif } static void stb__introspect_compute(char *path, char *file) { int i; char ** include_list = NULL; char ** introspect_list = NULL; FILE *f; f = fopen(file, "w"); if (!f) return; fputs("// if you get compiler errors, change the following 0 to a 1:\n", f); fputs("#define STB_INTROSPECT_INVALID 0\n\n", f); fputs("// this will force the code to compile, and force the introspector\n", f); fputs("// to run and then exit, allowing you to recompile\n\n\n", f); fputs("#include \"stb.h\"\n\n",f ); fputs("#if STB_INTROSPECT_INVALID\n", f); fputs(" stb_info_struct stb__introspect_output[] = { (void *) 1 }\n", f); fputs("#else\n\n", f); for (i=0; i < stb_arr_len(include_list); ++i) fprintf(f, " #include \"%s\"\n", include_list[i]); fputs(" stb_info_struct stb__introspect_output[] =\n{\n", f); for (i=0; i < stb_arr_len(introspect_list); ++i) fprintf(f, " stb_introspect_%s,\n", introspect_list[i]); fputs(" };\n", f); fputs("#endif\n", f); fclose(f); } static stb_info_struct *stb__introspect_info; #ifndef STB_SHIP #endif void stb__introspect(char *path, char *file, stb_info_struct *compiled) { static int first=1; if (!first) return; first=0; stb__introspect_info = compiled; #ifndef STB_SHIP if (path || file) { int bail_flag = compiled && compiled[0].structname == (void *) 1; int needs_building = bail_flag; struct stb__stat st; char buffer[1024], buffer2[1024]; if (!path) { stb_splitpath(buffer, file, STB_PATH); path = buffer; } // bail if the source path doesn't exist if (!stb_fexists(path)) return; stb__introspect_filename(buffer2, path); // get source/include files timestamps, compare to output-file timestamp; // if mismatched, regenerate if (stb__stat(buffer2, &st)) needs_building = STB_TRUE; { // find any file that contains an introspection command and is newer // if needs_building is already true, we don't need to do this test, // but we still need these arrays, so go ahead and get them char **all[3]; all[0] = stb_readdir_files_mask(path, "*.h"); all[1] = stb_readdir_files_mask(path, "*.c"); all[2] = stb_readdir_files_mask(path, "*.cpp"); int i,j; if (needs_building) { for (j=0; j < 3; ++j) { for (i=0; i < stb_arr_len(all[j]); ++i) { struct stb__stat st2; if (!stb__stat(all[j][i], &st2)) { if (st.st_mtime < st2.st_mtime) { char *z = stb_filec(all[j][i], NULL); int found=STB_FALSE; while (y) { y = strstr(y, "//si"); if (y && isspace(y[4])) { found = STB_TRUE; break; } } needs_building = STB_TRUE; goto done; } } } } done:; } char *z = stb_filec(all[i], NULL), *y = z; int found=STB_FALSE; while (y) { y = strstr(y, "//si"); if (y && isspace(y[4])) { found = STB_TRUE; break; } } if (found) stb_arr_push(introspect_h, strdup(all[i])); free(z); } } stb_readdir_free(all); if (!needs_building) { for (i=0; i < stb_arr_len(introspect_h); ++i) { struct stb__stat st2; if (!stb__stat(introspect_h[i], &st2)) if (st.st_mtime < st2.st_mtime) needs_building = STB_TRUE; } } if (needs_building) { stb__introspect_compute(path, buffer2); } } } #endif } #endif #endif #ifdef STB_INTROSPECT // compile-time code-generator #define INTROSPECT(x) int main(int argc, char **argv) { stb__introspect(__FILE__); return 0; } #define FILE(x) void stb__introspect(char *filename) { char *file = stb_file(filename, NULL); char *s = file, *t, **p; char *out_name = "stb_introspect.c"; char *out_path; STB_ARR(char) filelist = NULL; int i,n; if (!file) stb_fatal("Couldn't open %s", filename); out_path = stb_splitpathdup(filename, STB_PATH); // search for the macros while (*s) { char buffer[256]; while (*s && !isupper(*s)) ++s; s = stb_strtok_invert(buffer, s, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); s = stb_skipwhite(s); if (*s == '(') { ++s; t = strchr(s, ')'); if (t == NULL) stb_fatal("Error parsing %s", filename); } } } #endif ////////////////////////////////////////////////////////////////////////////// // // STB-C sliding-window dictionary compression // // This uses a DEFLATE-style sliding window, but no bitwise entropy. // Everything is on byte boundaries, so you could then apply a byte-wise // entropy code, though that's nowhere near as effective. // // An STB-C stream begins with a 16-byte header: // 4 bytes: 0x57 0xBC 0x00 0x00 // 8 bytes: big-endian size of decompressed data, 64-bits // 4 bytes: big-endian size of window (how far back decompressor may need) // // The following symbols appear in the stream (these were determined ad hoc, // not by analysis): // // [dict] 00000100 yyyyyyyy yyyyyyyy yyyyyyyy xxxxxxxx xxxxxxxx // [END] 00000101 11111010 cccccccc cccccccc cccccccc cccccccc // [dict] 00000110 yyyyyyyy yyyyyyyy yyyyyyyy xxxxxxxx // [literals] 00000111 zzzzzzzz zzzzzzzz // [literals] 00001zzz zzzzzzzz // [dict] 00010yyy yyyyyyyy yyyyyyyy xxxxxxxx xxxxxxxx // [dict] 00011yyy yyyyyyyy yyyyyyyy xxxxxxxx // [literals] 001zzzzz // [dict] 01yyyyyy yyyyyyyy xxxxxxxx // [dict] 1xxxxxxx yyyyyyyy // // xxxxxxxx: match length - 1 // yyyyyyyy: backwards distance - 1 // zzzzzzzz: num literals - 1 // cccccccc: adler32 checksum of decompressed data // (all big-endian) STB_EXTERN stb_uint stb_decompress_length(stb_uchar *input); STB_EXTERN stb_uint stb_decompress(stb_uchar *out,stb_uchar *in,stb_uint len); STB_EXTERN stb_uint stb_compress (stb_uchar *out,stb_uchar *in,stb_uint len); STB_EXTERN void stb_compress_window(int z); STB_EXTERN void stb_compress_hashsize(unsigned int z); STB_EXTERN int stb_compress_tofile(char *filename, char *in, stb_uint len); STB_EXTERN int stb_compress_intofile(FILE *f, char *input, stb_uint len); STB_EXTERN char *stb_decompress_fromfile(char *filename, stb_uint *len); STB_EXTERN int stb_compress_stream_start(FILE *f); STB_EXTERN void stb_compress_stream_end(int close); STB_EXTERN void stb_write(char *data, int data_len); #ifdef STB_DEFINE stb_uint stb_decompress_length(stb_uchar *input) { return (input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11]; } //////////////////// decompressor /////////////////////// // simple implementation that just writes whole thing into big block static unsigned char *stb__barrier; static unsigned char *stb__barrier2; static unsigned char *stb__barrier3; static unsigned char *stb__barrier4; static stb_uchar *stb__dout; static void stb__match(stb_uchar *data, stb_uint length) { // INVERSE of memmove... write each byte before copying the next... assert (stb__dout + length <= stb__barrier); if (stb__dout + length > stb__barrier) { stb__dout += length; return; } if (data < stb__barrier4) { stb__dout = stb__barrier+1; return; } while (length--) *stb__dout++ = *data++; } static void stb__lit(stb_uchar *data, stb_uint length) { assert (stb__dout + length <= stb__barrier); if (stb__dout + length > stb__barrier) { stb__dout += length; return; } if (data < stb__barrier2) { stb__dout = stb__barrier+1; return; } memcpy(stb__dout, data, length); stb__dout += length; } #define stb__in2(x) ((i[x] << 8) + i[(x)+1]) #define stb__in3(x) ((i[x] << 16) + stb__in2((x)+1)) #define stb__in4(x) ((i[x] << 24) + stb__in3((x)+1)) static stb_uchar *stb_decompress_token(stb_uchar *i) { if (*i >= 0x20) { // use fewer if's for cases that expand small if (*i >= 0x80) stb__match(stb__dout-i[1]-1, i[0] - 0x80 + 1), i += 2; else if (*i >= 0x40) stb__match(stb__dout-(stb__in2(0) - 0x4000 + 1), i[2]+1), i += 3; else /* *i >= 0x20 */ stb__lit(i+1, i[0] - 0x20 + 1), i += 1 + (i[0] - 0x20 + 1); } else { // more ifs for cases that expand large, since overhead is amortized if (*i >= 0x18) stb__match(stb__dout-(stb__in3(0) - 0x180000 + 1), i[3]+1), i += 4; else if (*i >= 0x10) stb__match(stb__dout-(stb__in3(0) - 0x100000 + 1), stb__in2(3)+1), i += 5; else if (*i >= 0x08) stb__lit(i+2, stb__in2(0) - 0x0800 + 1), i += 2 + (stb__in2(0) - 0x0800 + 1); else if (*i == 0x07) stb__lit(i+3, stb__in2(1) + 1), i += 3 + (stb__in2(1) + 1); else if (*i == 0x06) stb__match(stb__dout-(stb__in3(1)+1), i[4]+1), i += 5; else if (*i == 0x04) stb__match(stb__dout-(stb__in3(1)+1), stb__in2(4)+1), i += 6; } return i; } stb_uint stb_decompress(stb_uchar *output, stb_uchar *i, stb_uint length) { stb_uint olen; if (stb__in4(0) != 0x57bC0000) return 0; if (stb__in4(4) != 0) return 0; // error! stream is > 4GB olen = stb_decompress_length(i); stb__barrier2 = i; stb__barrier3 = i+length; stb__barrier = output + olen; stb__barrier4 = output; i += 16; stb__dout = output; while (1) { stb_uchar *old_i = i; i = stb_decompress_token(i); if (i == old_i) { if (*i == 0x05 && i[1] == 0xfa) { assert(stb__dout == output + olen); if (stb__dout != output + olen) return 0; if (stb_adler32(1, output, olen) != (stb_uint) stb__in4(2)) return 0; return olen; } else { assert(0); /* NOTREACHED */ return 0; } } assert(stb__dout <= output + olen); if (stb__dout > output + olen) return 0; } } char *stb_decompress_fromfile(char *filename, unsigned int *len) { unsigned int n; char *q; unsigned char *p; FILE *f = fopen(filename, "rb"); if (f == NULL) return NULL; fseek(f, 0, SEEK_END); n = ftell(f); fseek(f, 0, SEEK_SET); p = (unsigned char * ) malloc(n); if (p == NULL) return NULL; fread(p, 1, n, f); fclose(f); if (p == NULL) return NULL; if (p[0] != 0x57 || p[1] != 0xBc || p[2] || p[3]) { free(p); return NULL; } q = (char *) malloc(stb_decompress_length(p)+1); if (!q) { free(p); return NULL; } *len = stb_decompress((unsigned char *) q, p, n); if (*len) q[*len] = 0; free(p); return q; } #if 0 // streaming decompressor static struct { stb__uchar *in_buffer; stb__uchar *match; stb__uint pending_literals; stb__uint pending_match; } xx; static void stb__match(stb_uchar *data, stb_uint length) { // INVERSE of memmove... write each byte before copying the next... assert (stb__dout + length <= stb__barrier); if (stb__dout + length > stb__barrier) { stb__dout += length; return; } if (data < stb__barrier2) { stb__dout = stb__barrier+1; return; } while (length--) *stb__dout++ = *data++; } static void stb__lit(stb_uchar *data, stb_uint length) { assert (stb__dout + length <= stb__barrier); if (stb__dout + length > stb__barrier) { stb__dout += length; return; } if (data < stb__barrier2) { stb__dout = stb__barrier+1; return; } memcpy(stb__dout, data, length); stb__dout += length; } static void sx_match(stb_uchar *data, stb_uint length) { xx.match = data; xx.pending_match = length; } static void sx_lit(stb_uchar *data, stb_uint length) { xx.pending_lit = length; } static int stb_decompress_token_state(void) { stb__uchar *i = xx.in_buffer; if (*i >= 0x20) { // use fewer if's for cases that expand small if (*i >= 0x80) sx_match(stb__dout-i[1]-1, i[0] - 0x80 + 1), i += 2; else if (*i >= 0x40) sx_match(stb__dout-(stb__in2(0) - 0x4000 + 1), i[2]+1), i += 3; else /* *i >= 0x20 */ sx_lit(i+1, i[0] - 0x20 + 1), i += 1; } else { // more ifs for cases that expand large, since overhead is amortized if (*i >= 0x18) sx_match(stb__dout-(stb__in3(0) - 0x180000 + 1), i[3]+1), i += 4; else if (*i >= 0x10) sx_match(stb__dout-(stb__in3(0) - 0x100000 + 1), stb__in2(3)+1), i += 5; else if (*i >= 0x08) sx_lit(i+2, stb__in2(0) - 0x0800 + 1), i += 2; else if (*i == 0x07) sx_lit(i+3, stb__in2(1) + 1), i += 3; else if (*i == 0x06) sx_match(stb__dout-(stb__in3(1)+1), i[4]+1), i += 5; else if (*i == 0x04) sx_match(stb__dout-(stb__in3(1)+1), stb__in2(4)+1), i += 6; else return 0; } xx.in_buffer = i; return 1; } #endif //////////////////// compressor /////////////////////// static unsigned int stb_matchlen(stb_uchar *m1, stb_uchar *m2, stb_uint maxlen) { stb_uint i; for (i=0; i < maxlen; ++i) if (m1[i] != m2[i]) return i; return i; } // simple implementation that just takes the source data in a big block static stb_uchar *stb__out; static FILE *stb__outfile; static stb_uint stb__outbytes; static void stb__write(unsigned char v) { fputc(v, stb__outfile); ++stb__outbytes; } #define stb_out(v) (stb__out ? *stb__out++ = (stb_uchar) (v) : stb__write((stb_uchar) (v))) static void stb_out2(stb_uint v) { stb_out(v >> 8); stb_out(v); } static void stb_out3(stb_uint v) { stb_out(v >> 16); stb_out(v >> 8); stb_out(v); } static void stb_out4(stb_uint v) { stb_out(v >> 24); stb_out(v >> 16); stb_out(v >> 8 ); stb_out(v); } static void outliterals(stb_uchar *in, int numlit) { while (numlit > 65536) { outliterals(in,65536); in += 65536; numlit -= 65536; } if (numlit == 0) ; else if (numlit <= 32) stb_out (0x000020 + numlit-1); else if (numlit <= 2048) stb_out2(0x000800 + numlit-1); else /* numlit <= 65536) */ stb_out3(0x070000 + numlit-1); if (stb__out) { memcpy(stb__out,in,numlit); stb__out += numlit; } else fwrite(in, 1, numlit, stb__outfile); } static int stb__window = 0x40000; // 256K void stb_compress_window(int z) { if (z >= 0x1000000) z = 0x1000000; // limit of implementation if (z < 0x100) z = 0x100; // insanely small stb__window = z; } static int stb_not_crap(int best, int dist) { return ((best > 2 && dist <= 0x00100) || (best > 5 && dist <= 0x04000) || (best > 7 && dist <= 0x80000)); } static stb_uint stb__hashsize = 32768; void stb_compress_hashsize(unsigned int y) { unsigned int z = 1024; while (z < y) z <<= 1; stb__hashsize = z >> 2; // pass in bytes, store #pointers } // note that you can play with the hashing functions all you // want without needing to change the decompressor #define stb__hc(q,h,c) (((h) << 7) + ((h) >> 25) + q[c]) #define stb__hc2(q,h,c,d) (((h) << 14) + ((h) >> 18) + (q[c] << 7) + q[d]) #define stb__hc3(q,c,d,e) ((q[c] << 14) + (q[d] << 7) + q[e]) static stb_uint32 stb__running_adler; static int stb_compress_chunk(stb_uchar *history, stb_uchar *start, stb_uchar *end, int length, int *pending_literals, stb_uchar **chash, stb_uint mask) { int window = stb__window; stb_uint match_max; stb_uchar *lit_start = start - *pending_literals; stb_uchar *q = start; #define STB__SCRAMBLE(h) (((h) + ((h) >> 16)) & mask) // stop short of the end so we don't scan off the end doing // the hashing; this means we won't compress the last few bytes // unless they were part of something longer while (q < start+length && q+12 < end) { int m; stb_uint h1,h2,h3,h4, h; stb_uchar *t; int best = 2, dist=0; if (q+65536 > end) match_max = end-q; else match_max = 65536; #define stb__nc(b,d) ((d) <= window && ((b) > 9 || stb_not_crap(b,d))) #define STB__TRY(t,p) /* avoid retrying a match we already tried */ \ if (p ? dist != q-t : 1) \ if ((m = stb_matchlen(t, q, match_max)) > best) \ if (stb__nc(m,q-(t))) \ best = m, dist = q - (t) // rather than search for all matches, only try 4 candidate locations, // chosen based on 4 different hash functions of different lengths. // this strategy is inspired by LZO; hashing is unrolled here using the // 'hc' macro h = stb__hc3(q,0, 1, 2); h1 = STB__SCRAMBLE(h); t = chash[h1]; if (t) STB__TRY(t,0); h = stb__hc2(q,h, 3, 4); h2 = STB__SCRAMBLE(h); h = stb__hc2(q,h, 5, 6); t = chash[h2]; if (t) STB__TRY(t,1); h = stb__hc2(q,h, 7, 8); h3 = STB__SCRAMBLE(h); h = stb__hc2(q,h, 9,10); t = chash[h3]; if (t) STB__TRY(t,1); h = stb__hc2(q,h,11,12); h4 = STB__SCRAMBLE(h); t = chash[h4]; if (t) STB__TRY(t,1); // because we use a shared hash table, can only update it // _after_ we've probed all of them chash[h1] = chash[h2] = chash[h3] = chash[h4] = q; if (best > 2) assert(dist > 0); // see if our best match qualifies if (best < 3) { // fast path literals ++q; } else if (best > 2 && best <= 0x80 && dist <= 0x100) { outliterals(lit_start, q-lit_start); lit_start = (q += best); stb_out(0x80 + best-1); stb_out(dist-1); } else if (best > 5 && best <= 0x100 && dist <= 0x4000) { outliterals(lit_start, q-lit_start); lit_start = (q += best); stb_out2(0x4000 + dist-1); stb_out(best-1); } else if (best > 7 && best <= 0x100 && dist <= 0x80000) { outliterals(lit_start, q-lit_start); lit_start = (q += best); stb_out3(0x180000 + dist-1); stb_out(best-1); } else if (best > 8 && best <= 0x10000 && dist <= 0x80000) { outliterals(lit_start, q-lit_start); lit_start = (q += best); stb_out3(0x100000 + dist-1); stb_out2(best-1); } else if (best > 9 && dist <= 0x1000000) { if (best > 65536) best = 65536; outliterals(lit_start, q-lit_start); lit_start = (q += best); if (best <= 0x100) { stb_out(0x06); stb_out3(dist-1); stb_out(best-1); } else { stb_out(0x04); stb_out3(dist-1); stb_out2(best-1); } } else { // fallback literals if no match was a balanced tradeoff ++q; } } // if we didn't get all the way, add the rest to literals if (q-start < length) q = start+length; // the literals are everything from lit_start to q *pending_literals = (q - lit_start); stb__running_adler = stb_adler32(stb__running_adler, start, q - start); return q - start; } static int stb_compress_inner(stb_uchar *input, stb_uint length) { int literals = 0; stb_uint len,i; stb_uchar **chash; chash = (stb_uchar**) malloc(stb__hashsize * sizeof(stb_uchar*)); if (chash == NULL) return 0; // failure for (i=0; i < stb__hashsize; ++i) chash[i] = NULL; // stream signature stb_out(0x57); stb_out(0xbc); stb_out2(0); stb_out4(0); // 64-bit length requires 32-bit leading 0 stb_out4(length); stb_out4(stb__window); stb__running_adler = 1; len = stb_compress_chunk(input, input, input+length, length, &literals, chash, stb__hashsize-1); assert(len == length); outliterals(input+length - literals, literals); free(chash); stb_out2(0x05fa); // end opcode stb_out4(stb__running_adler); return 1; // success } stb_uint stb_compress(stb_uchar *out, stb_uchar *input, stb_uint length) { stb__out = out; stb__outfile = NULL; stb_compress_inner(input, length); return stb__out - out; } int stb_compress_tofile(char *filename, char *input, unsigned int length) { //int maxlen = length + 512 + (length >> 2); // total guess //char *buffer = (char *) malloc(maxlen); //int blen = stb_compress((stb_uchar*)buffer, (stb_uchar*)input, length); stb__out = NULL; stb__outfile = fopen(filename, "wb"); if (!stb__outfile) return 0; stb__outbytes = 0; if (!stb_compress_inner((stb_uchar*)input, length)) return 0; fclose(stb__outfile); return stb__outbytes; } int stb_compress_intofile(FILE *f, char *input, unsigned int length) { //int maxlen = length + 512 + (length >> 2); // total guess //char *buffer = (char*)malloc(maxlen); //int blen = stb_compress((stb_uchar*)buffer, (stb_uchar*)input, length); stb__out = NULL; stb__outfile = f; if (!stb__outfile) return 0; stb__outbytes = 0; if (!stb_compress_inner((stb_uchar*)input, length)) return 0; return stb__outbytes; } ////////////////////// streaming I/O version ///////////////////// static size_t stb_out_backpatch_id(void) { if (stb__out) return (size_t) stb__out; else return ftell(stb__outfile); } static void stb_out_backpatch(size_t id, stb_uint value) { stb_uchar data[4] = { value >> 24, value >> 16, value >> 8, value }; if (stb__out) { memcpy((void *) id, data, 4); } else { stb_uint where = ftell(stb__outfile); fseek(stb__outfile, id, SEEK_SET); fwrite(data, 4, 1, stb__outfile); fseek(stb__outfile, where, SEEK_SET); } } // ok, the wraparound buffer was a total failure. let's instead // use a copying-in-place buffer, which lets us share the code. // This is way less efficient but it'll do for now. static struct { stb_uchar *buffer; int size; // physical size of buffer in bytes int valid; // amount of valid data in bytes int start; // bytes of data already output int window; int fsize; int pending_literals; // bytes not-quite output but counted in start int length_id; stb_uint total_bytes; stb_uchar **chash; stb_uint hashmask; } xtb; static int stb_compress_streaming_start(void) { stb_uint i; xtb.size = stb__window * 3; xtb.buffer = (stb_uchar*)malloc(xtb.size); if (!xtb.buffer) return 0; xtb.chash = (stb_uchar**)malloc(sizeof(*xtb.chash) * stb__hashsize); if (!xtb.chash) { free(xtb.buffer); return 0; } for (i=0; i < stb__hashsize; ++i) xtb.chash[i] = NULL; xtb.hashmask = stb__hashsize-1; xtb.valid = 0; xtb.start = 0; xtb.window = stb__window; xtb.fsize = stb__window; xtb.pending_literals = 0; xtb.total_bytes = 0; // stream signature stb_out(0x57); stb_out(0xbc); stb_out2(0); stb_out4(0); // 64-bit length requires 32-bit leading 0 xtb.length_id = stb_out_backpatch_id(); stb_out4(0); // we don't know the output length yet stb_out4(stb__window); stb__running_adler = 1; return 1; } static int stb_compress_streaming_end(void) { // flush out any remaining data stb_compress_chunk(xtb.buffer, xtb.buffer+xtb.start, xtb.buffer+xtb.valid, xtb.valid-xtb.start, &xtb.pending_literals, xtb.chash, xtb.hashmask); // write out pending literals outliterals(xtb.buffer + xtb.valid - xtb.pending_literals, xtb.pending_literals); stb_out2(0x05fa); // end opcode stb_out4(stb__running_adler); stb_out_backpatch(xtb.length_id, xtb.total_bytes); free(xtb.buffer); free(xtb.chash); return 1; } void stb_write(char *data, int data_len) { stb_uint i; // @TODO: fast path for filling the buffer and doing nothing else // if (xtb.valid + data_len < xtb.size) xtb.total_bytes += data_len; while (data_len) { // fill buffer if (xtb.valid < xtb.size) { int amt = xtb.size - xtb.valid; if (data_len < amt) amt = data_len; memcpy(xtb.buffer + xtb.valid, data, amt); data_len -= amt; data += amt; xtb.valid += amt; } if (xtb.valid < xtb.size) return; // at this point, the buffer is full // if we can process some data, go for it; make sure // we leave an 'fsize's worth of data, though if (xtb.start + xtb.fsize < xtb.valid) { int amount = (xtb.valid - xtb.fsize) - xtb.start; int n; assert(amount > 0); n = stb_compress_chunk(xtb.buffer, xtb.buffer + xtb.start, xtb.buffer + xtb.valid, amount, &xtb.pending_literals, xtb.chash, xtb.hashmask); xtb.start += n; } assert(xtb.start + xtb.fsize >= xtb.valid); // at this point, our future size is too small, so we // need to flush some history. we, in fact, flush exactly // one window's worth of history { int flush = xtb.window; assert(xtb.start >= flush); assert(xtb.valid >= flush); // if 'pending literals' extends back into the shift region, // write them out if (xtb.start - xtb.pending_literals < flush) { outliterals(xtb.buffer + xtb.start - xtb.pending_literals, xtb.pending_literals); xtb.pending_literals = 0; } // now shift the window memmove(xtb.buffer, xtb.buffer + flush, xtb.valid - flush); xtb.start -= flush; xtb.valid -= flush; for (i=0; i <= xtb.hashmask; ++i) if (xtb.chash[i] < xtb.buffer + flush) xtb.chash[i] = NULL; else xtb.chash[i] -= flush; } // and now that we've made room for more data, go back to the top } } int stb_compress_stream_start(FILE *f) { stb__out = NULL; stb__outfile = f; if (f == NULL) return 0; if (!stb_compress_streaming_start()) return 0; return 1; } void stb_compress_stream_end(int close) { stb_compress_streaming_end(); if (close && stb__outfile) { fclose(stb__outfile); } } #endif // STB_DEFINE ////////////////////////////////////////////////////////////////////////////// // // File abstraction... tired of not having this... we can write // compressors to be layers over these that auto-close their children. typedef struct stbfile { int (*getbyte)(struct stbfile *); // -1 on EOF unsigned int (*getdata)(struct stbfile *, void *block, unsigned int len); int (*putbyte)(struct stbfile *, int byte); unsigned int (*putdata)(struct stbfile *, void *block, unsigned int len); unsigned int (*size)(struct stbfile *); unsigned int (*tell)(struct stbfile *); void (*backpatch)(struct stbfile *, unsigned int tell, void *block, unsigned int len); void (*close)(struct stbfile *); FILE *f; // file to fread/fwrite unsigned char *buffer; // input/output buffer unsigned char *indata, *inend; // input buffer union { int various; void *ptr; }; } stbfile; STB_EXTERN unsigned int stb_getc(stbfile *f); // read STB_EXTERN int stb_putc(stbfile *f, int ch); // write STB_EXTERN unsigned int stb_getdata(stbfile *f, void *buffer, unsigned int len); // read STB_EXTERN unsigned int stb_putdata(stbfile *f, void *buffer, unsigned int len); // write STB_EXTERN unsigned int stb_tell(stbfile *f); // read STB_EXTERN unsigned int stb_size(stbfile *f); // read/write STB_EXTERN void stb_backpatch(stbfile *f, unsigned int tell, void *buffer, unsigned int len); // write #ifdef STB_DEFINE unsigned int stb_getc(stbfile *f) { return f->getbyte(f); } int stb_putc(stbfile *f, int ch) { return f->putbyte(f, ch); } unsigned int stb_getdata(stbfile *f, void *buffer, unsigned int len) { return f->getdata(f, buffer, len); } unsigned int stb_putdata(stbfile *f, void *buffer, unsigned int len) { return f->putdata(f, buffer, len); } void stb_close(stbfile *f) { f->close(f); free(f); } unsigned int stb_tell(stbfile *f) { return f->tell(f); } unsigned int stb_size(stbfile *f) { return f->size(f); } void stb_backpatch(stbfile *f, unsigned int tell, void *buffer, unsigned int len) { f->backpatch(f,tell,buffer,len); } // FILE * implementation static int stb__fgetbyte(stbfile *f) { return fgetc(f->f); } static int stb__fputbyte(stbfile *f, int ch) { return fputc(ch, f->f)==0; } static unsigned int stb__fgetdata(stbfile *f, void *buffer, unsigned int len) { return fread(buffer,1,len,f->f); } static unsigned int stb__fputdata(stbfile *f, void *buffer, unsigned int len) { return fwrite(buffer,1,len,f->f); } static unsigned int stb__fsize(stbfile *f) { return stb_filelen(f->f); } static unsigned int stb__ftell(stbfile *f) { return ftell(f->f); } static void stb__fbackpatch(stbfile *f, unsigned int where, void *buffer, unsigned int len) { fseek(f->f, where, SEEK_SET); fwrite(buffer, 1, len, f->f); fseek(f->f, 0, SEEK_END); } static void stb__fclose(stbfile *f) { fclose(f->f); } stbfile *stb_openf(FILE *f) { stbfile m = { stb__fgetbyte, stb__fgetdata, stb__fputbyte, stb__fputdata, stb__fsize, stb__ftell, stb__fbackpatch, stb__fclose, 0,0,0, }; stbfile *z = (stbfile *) malloc(sizeof(*z)); if (z) { *z = m; z->f = f; } return z; } static int stb__nogetbyte(stbfile *f) { assert(0); return -1; } static unsigned int stb__nogetdata(stbfile *f, void *buffer, unsigned int len) { assert(0); return 0; } static int stb__noputbyte(stbfile *f, int ch) { assert(0); return 0; } static unsigned int stb__noputdata(stbfile *f, void *buffer, unsigned int len) { assert(0); return 0; } static void stb__nobackpatch(stbfile *f, unsigned int where, void *buffer, unsigned int len) { assert(0); } static int stb__bgetbyte(stbfile *s) { if (s->indata < s->inend) return *s->indata++; else return -1; } static unsigned int stb__bgetdata(stbfile *s, void *buffer, unsigned int len) { if (s->indata + len > s->inend) len = s->inend - s->indata; memcpy(buffer, s->indata, len); s->indata += len; return len; } static unsigned int stb__bsize(stbfile *s) { return s->inend - s->buffer; } static unsigned int stb__btell(stbfile *s) { return s->indata - s->buffer; } static void stb__bclose(stbfile *s) { if (s->various) free(s->buffer); } stbfile *stb_open_inbuffer(void *buffer, unsigned int len) { stbfile m = { stb__bgetbyte, stb__bgetdata, stb__noputbyte, stb__noputdata, stb__bsize, stb__btell, stb__nobackpatch, stb__bclose }; stbfile *z = (stbfile *) malloc(sizeof(*z)); if (z) { *z = m; z->buffer = (unsigned char *) buffer; z->indata = z->buffer; z->inend = z->indata + len; } return z; } stbfile *stb_open_inbuffer_free(void *buffer, unsigned int len) { stbfile *z = stb_open_inbuffer(buffer, len); if (z) z->various = 1; // free return z; } #ifndef STB_VERSION // if we've been cut-and-pasted elsewhere, you get a limited // version of stb_open, without the 'k' flag and utf8 support static void stb__fclose2(stbfile *f) { fclose(f->f); } stbfile *stb_open(char *filename, char *mode) { FILE *f = fopen(filename, mode); stbfile *s; if (f == NULL) return NULL; s = stb_openf(f); if (s) s->close = stb__fclose2; return s; } #else // the full version depends on some code in stb.h; this // also includes the memory buffer output format implemented with stb_arr static void stb__fclose2(stbfile *f) { stb_fclose(f->f, f->various); } stbfile *stb_open(char *filename, char *mode) { FILE *f = stb_fopen(filename, mode[0] == 'k' ? mode+1 : mode); stbfile *s; if (f == NULL) return NULL; s = stb_openf(f); if (s) { s->close = stb__fclose2; s->various = mode[0] == 'k' ? stb_keep_if_different : stb_keep_yes; } return s; } static int stb__aputbyte(stbfile *f, int ch) { stb_arr_push(f->buffer, ch); return 1; } static unsigned int stb__aputdata(stbfile *f, void *data, unsigned int len) { memcpy(stb_arr_addn(f->buffer, (int) len), data, len); return len; } static unsigned int stb__asize(stbfile *f) { return stb_arr_len(f->buffer); } static void stb__abackpatch(stbfile *f, unsigned int where, void *data, unsigned int len) { memcpy(f->buffer+where, data, len); } static void stb__aclose(stbfile *f) { *(unsigned char **) f->ptr = f->buffer; } stbfile *stb_open_outbuffer(unsigned char **update_on_close) { stbfile m = { stb__nogetbyte, stb__nogetdata, stb__aputbyte, stb__aputdata, stb__asize, stb__asize, stb__abackpatch, stb__aclose }; stbfile *z = (stbfile *) malloc(sizeof(*z)); if (z) { z->ptr = update_on_close; *z = m; } return z; } #endif #endif ////////////////////////////////////////////////////////////////////////////// // // Arithmetic coder... based on cbloom's notes on the subject, should be // less code than a huffman code. typedef struct { unsigned int range_low; unsigned int range_high; unsigned int code, range; // decode int buffered_u8; int pending_ffs; stbfile *output; } stb_arith; STB_EXTERN void stb_arith_init_encode(stb_arith *a, stbfile *out); STB_EXTERN void stb_arith_init_decode(stb_arith *a, stbfile *in); STB_EXTERN stbfile *stb_arith_encode_close(stb_arith *a); STB_EXTERN stbfile *stb_arith_decode_close(stb_arith *a); STB_EXTERN void stb_arith_encode(stb_arith *a, unsigned int totalfreq, unsigned int freq, unsigned int cumfreq); STB_EXTERN void stb_arith_encode_log2(stb_arith *a, unsigned int totalfreq2, unsigned int freq, unsigned int cumfreq); STB_EXTERN unsigned int stb_arith_decode_value(stb_arith *a, unsigned int totalfreq); STB_EXTERN void stb_arith_decode_advance(stb_arith *a, unsigned int totalfreq, unsigned int freq, unsigned int cumfreq); STB_EXTERN unsigned int stb_arith_decode_value_log2(stb_arith *a, unsigned int totalfreq2); STB_EXTERN void stb_arith_decode_advance_log2(stb_arith *a, unsigned int totalfreq2, unsigned int freq, unsigned int cumfreq); STB_EXTERN void stb_arith_encode_byte(stb_arith *a, int byte); STB_EXTERN int stb_arith_decode_byte(stb_arith *a); // this is a memory-inefficient way of doing things, but it's // fast(?) and simple typedef struct { unsigned short cumfreq; unsigned short samples; } stb_arith_symstate_item; typedef struct { int num_sym; unsigned int pow2; int countdown; stb_arith_symstate_item data[1]; } stb_arith_symstate; #ifdef STB_DEFINE void stb_arith_init_encode(stb_arith *a, stbfile *out) { a->range_low = 0; a->range_high = 0xffffffff; a->pending_ffs = -1; // means no buffered character currently, to speed up normal case a->output = out; } static void stb__arith_carry(stb_arith *a) { int i; assert(a->pending_ffs != -1); // can't carry with no data stb_putc(a->output, a->buffered_u8); for (i=0; i < a->pending_ffs; ++i) stb_putc(a->output, 0); } static void stb__arith_putbyte(stb_arith *a, int byte) { if (a->pending_ffs) { if (a->pending_ffs == -1) { // means no buffered data; encoded for fast path efficiency if (byte == 0xff) stb_putc(a->output, byte); // just write it immediately else { a->buffered_u8 = byte; a->pending_ffs = 0; } } else if (byte == 0xff) { ++a->pending_ffs; } else { int i; stb_putc(a->output, a->buffered_u8); for (i=0; i < a->pending_ffs; ++i) stb_putc(a->output, 0xff); } } else if (byte == 0xff) { ++a->pending_ffs; } else { // fast path stb_putc(a->output, a->buffered_u8); a->buffered_u8 = byte; } } static void stb__arith_flush(stb_arith *a) { if (a->pending_ffs >= 0) { int i; stb_putc(a->output, a->buffered_u8); for (i=0; i < a->pending_ffs; ++i) stb_putc(a->output, 0xff); } } static void stb__renorm_encoder(stb_arith *a) { stb__arith_putbyte(a, a->range_low >> 24); a->range_low <<= 8; a->range_high = (a->range_high << 8) | 0xff; } static void stb__renorm_decoder(stb_arith *a) { int c = stb_getc(a->output); a->code = (a->code << 8) + (c >= 0 ? c : 0); // if EOF, insert 0 } void stb_arith_encode(stb_arith *a, unsigned int totalfreq, unsigned int freq, unsigned int cumfreq) { unsigned int range = a->range_high - a->range_low; unsigned int old = a->range_low; range /= totalfreq; a->range_low += range * cumfreq; a->range_high = a->range_low + range*freq; if (a->range_low < old) stb__arith_carry(a); while (a->range_high - a->range_low < 0x1000000) stb__renorm_encoder(a); } void stb_arith_encode_log2(stb_arith *a, unsigned int totalfreq2, unsigned int freq, unsigned int cumfreq) { unsigned int range = a->range_high - a->range_low; unsigned int old = a->range_low; range >>= totalfreq2; a->range_low += range * cumfreq; a->range_high = a->range_low + range*freq; if (a->range_low < old) stb__arith_carry(a); while (a->range_high - a->range_low < 0x1000000) stb__renorm_encoder(a); } unsigned int stb_arith_decode_value(stb_arith *a, unsigned int totalfreq) { unsigned int freqsize = a->range / totalfreq; unsigned int z = a->code / freqsize; return z >= totalfreq ? totalfreq-1 : z; } void stb_arith_decode_advance(stb_arith *a, unsigned int totalfreq, unsigned int freq, unsigned int cumfreq) { unsigned int freqsize = a->range / totalfreq; // @OPTIMIZE, share with above divide somehow? a->code -= freqsize * cumfreq; a->range = freqsize * freq; while (a->range < 0x1000000) stb__renorm_decoder(a); } unsigned int stb_arith_decode_value_log2(stb_arith *a, unsigned int totalfreq2) { unsigned int freqsize = a->range >> totalfreq2; unsigned int z = a->code / freqsize; return z >= (1U<range >> totalfreq2; a->code -= freqsize * cumfreq; a->range = freqsize * freq; while (a->range < 0x1000000) stb__renorm_decoder(a); } stbfile *stb_arith_encode_close(stb_arith *a) { // put exactly as many bytes as we'll read, so we can turn on/off arithmetic coding in a stream stb__arith_putbyte(a, a->range_low >> 24); stb__arith_putbyte(a, a->range_low >> 16); stb__arith_putbyte(a, a->range_low >> 8); stb__arith_putbyte(a, a->range_low >> 0); stb__arith_flush(a); return a->output; } stbfile *stb_arith_decode_close(stb_arith *a) { return a->output; } // this is a simple power-of-two based model -- using // power of two means we need one divide per decode, // not two. #define POW2_LIMIT 12 stb_arith_symstate *stb_arith_state_create(int num_sym) { stb_arith_symstate *s = (stb_arith_symstate *) malloc(sizeof(*s) + (num_sym-1) * sizeof(s->data[0])); if (s) { int i, cf, cf_next, next; int start_freq, extra; s->num_sym = num_sym; s->pow2 = 4; while (s->pow2 < 15 && (1 << s->pow2) < 3*num_sym) { ++s->pow2; } start_freq = (1 << s->pow2) / num_sym; assert(start_freq >= 1); extra = (1 << s->pow2) % num_sym; // now set up the initial stats if (s->pow2 < POW2_LIMIT) next = 0; else next = 1; cf = cf_next = 0; for (i=0; i < extra; ++i) { s->data[i].cumfreq = cf; s->data[i].samples = next; cf += start_freq+1; cf_next += next; } for (; i < num_sym; ++i) { s->data[i].cumfreq = cf; s->data[i].samples = next; cf += start_freq; cf_next += next; } assert(cf == (1 << s->pow2)); // now, how long should we go until we have 2 << s->pow2 samples? s->countdown = (2 << s->pow2) - cf - cf_next; } return s; } static void stb_arith_state_rescale(stb_arith_symstate *s) { if (s->pow2 < POW2_LIMIT) { int pcf, cf, cf_next, next, i; ++s->pow2; if (s->pow2 < POW2_LIMIT) next = 0; else next = 1; cf = cf_next = 0; pcf = 0; for (i=0; i < s->num_sym; ++i) { int sample = s->data[i].cumfreq - pcf + s->data[i].samples; s->data[i].cumfreq = cf; cf += sample; s->data[i].samples = next; cf_next += next; } assert(cf == (1 << s->pow2)); s->countdown = (2 << s->pow2) - cf - cf_next; } else { int pcf, cf, cf_next, i; cf = cf_next = 0; pcf = 0; for (i=0; i < s->num_sym; ++i) { int sample = (s->data[i].cumfreq - pcf + s->data[i].samples) >> 1; s->data[i].cumfreq = cf; cf += sample; s->data[i].samples = 1; cf_next += 1; } assert(cf == (1 << s->pow2)); // this isn't necessarily true, due to rounding down! s->countdown = (2 << s->pow2) - cf - cf_next; } } void stb_arith_encode_byte(stb_arith *a, int byte) { } int stb_arith_decode_byte(stb_arith *a) { return -1; } #endif ////////////////////////////////////////////////////////////////////////////// // // Threads // #ifndef _WIN32 #ifdef STB_THREADS #error "threads not implemented except for Windows" #endif #endif // call this function to free any global variables for memory testing STB_EXTERN void stb_thread_cleanup(void); typedef void * (*stb_thread_func)(void *); // do not rely on these types, this is an implementation detail. // compare against STB_THREAD_NULL and ST_SEMAPHORE_NULL typedef void *stb_thread; typedef void *stb_semaphore; typedef void *stb_mutex; typedef struct stb__sync *stb_sync; #define STB_SEMAPHORE_NULL NULL #define STB_THREAD_NULL NULL #define STB_MUTEX_NULL NULL #define STB_SYNC_NULL NULL // get the number of processors (limited to those in the affinity mask for this process). STB_EXTERN int stb_processor_count(void); // force to run on a single core -- needed for RDTSC to work, e.g. for iprof STB_EXTERN void stb_force_uniprocessor(void); // stb_work functions: queue up work to be done by some worker threads // set number of threads to serve the queue; you can change this on the fly, // but if you decrease it, it won't decrease until things currently on the // queue are finished STB_EXTERN void stb_work_numthreads(int n); // set maximum number of units in the queue; you can only set this BEFORE running any work functions STB_EXTERN int stb_work_maxunits(int n); // enqueue some work to be done (can do this from any thread, or even from a piece of work); // return value of f is stored in *return_code if non-NULL STB_EXTERN int stb_work(stb_thread_func f, void *d, volatile void **return_code); // as above, but stb_sync_reach is called on 'rel' after work is complete STB_EXTERN int stb_work_reach(stb_thread_func f, void *d, volatile void **return_code, stb_sync rel); // necessary to call this when using volatile to order writes/reads STB_EXTERN void stb_barrier(void); // support for independent queues with their own threads typedef struct stb__workqueue stb_workqueue; STB_EXTERN stb_workqueue*stb_workq_new(int numthreads, int max_units); STB_EXTERN stb_workqueue*stb_workq_new_flags(int numthreads, int max_units, int no_add_mutex, int no_remove_mutex); STB_EXTERN void stb_workq_delete(stb_workqueue *q); STB_EXTERN void stb_workq_numthreads(stb_workqueue *q, int n); STB_EXTERN int stb_workq(stb_workqueue *q, stb_thread_func f, void *d, volatile void **return_code); STB_EXTERN int stb_workq_reach(stb_workqueue *q, stb_thread_func f, void *d, volatile void **return_code, stb_sync rel); STB_EXTERN int stb_workq_length(stb_workqueue *q); STB_EXTERN stb_thread stb_create_thread (stb_thread_func f, void *d); STB_EXTERN stb_thread stb_create_thread2(stb_thread_func f, void *d, volatile void **return_code, stb_semaphore rel); STB_EXTERN void stb_destroy_thread(stb_thread t); STB_EXTERN stb_semaphore stb_sem_new(int max_val); STB_EXTERN stb_semaphore stb_sem_new_extra(int max_val, int start_val); STB_EXTERN void stb_sem_delete (stb_semaphore s); STB_EXTERN void stb_sem_waitfor(stb_semaphore s); STB_EXTERN void stb_sem_release(stb_semaphore s); STB_EXTERN stb_mutex stb_mutex_new(void); STB_EXTERN void stb_mutex_delete(stb_mutex m); STB_EXTERN void stb_mutex_begin(stb_mutex m); STB_EXTERN void stb_mutex_end(stb_mutex m); STB_EXTERN stb_sync stb_sync_new(void); STB_EXTERN void stb_sync_delete(stb_sync s); STB_EXTERN int stb_sync_set_target(stb_sync s, int count); STB_EXTERN void stb_sync_reach_and_wait(stb_sync s); // wait for 'target' reachers STB_EXTERN int stb_sync_reach(stb_sync s); typedef struct stb__threadqueue stb_threadqueue; #define STB_THREADQ_DYNAMIC 0 STB_EXTERN stb_threadqueue *stb_threadq_new(int item_size, int num_items, int many_add, int many_remove); STB_EXTERN void stb_threadq_delete(stb_threadqueue *tq); STB_EXTERN int stb_threadq_get(stb_threadqueue *tq, void *output); STB_EXTERN void stb_threadq_get_block(stb_threadqueue *tq, void *output); STB_EXTERN int stb_threadq_add(stb_threadqueue *tq, void *input); // can return FALSE if STB_THREADQ_DYNAMIC and attempt to grow fails STB_EXTERN int stb_threadq_add_block(stb_threadqueue *tq, void *input); #ifdef STB_THREADS #ifdef STB_DEFINE typedef struct { stb_thread_func f; void *d; volatile void **return_val; stb_semaphore sem; } stb__thread; // this is initialized along all possible paths to create threads, therefore // it's always initialized before any other threads are create, therefore // it's free of races AS LONG AS you only create threads through stb_* static stb_mutex stb__threadmutex, stb__workmutex; static void stb__threadmutex_init(void) { if (stb__threadmutex == STB_SEMAPHORE_NULL) { stb__threadmutex = stb_mutex_new(); stb__workmutex = stb_mutex_new(); } } #ifdef STB_THREAD_TEST volatile float stb__t1=1, stb__t2; static void stb__wait(int n) { float z = 0; int i; for (i=0; i < n; ++i) z += 1 / (stb__t1+i); stb__t2 = z; } #else #define stb__wait(x) #endif #ifdef _WIN32 // avoid including windows.h -- note that our definitions aren't // exactly the same (we don't define the security descriptor struct) // so if you want to include windows.h, make sure you do it first. #include #ifndef _WINDOWS_ // check windows.h guard #define STB__IMPORT STB_EXTERN __declspec(dllimport) #define STB__DW unsigned long STB__IMPORT int __stdcall TerminateThread(void *, STB__DW); STB__IMPORT void * __stdcall CreateSemaphoreA(void *sec, long,long,char*); STB__IMPORT int __stdcall CloseHandle(void *); STB__IMPORT STB__DW __stdcall WaitForSingleObject(void *, STB__DW); STB__IMPORT int __stdcall ReleaseSemaphore(void *, long, long *); STB__IMPORT void __stdcall Sleep(STB__DW); #endif // necessary to call this when using volatile to order writes/reads void stb_barrier(void) { #ifdef MemoryBarrier MemoryBarrier(); #else long temp; __asm xchg temp,eax; #endif } static void stb__thread_run(void *t) { void *res; stb__thread info = * (stb__thread *) t; free(t); res = info.f(info.d); if (info.return_val) *info.return_val = res; if (info.sem != STB_SEMAPHORE_NULL) stb_sem_release(info.sem); } static stb_thread stb_create_thread_raw(stb_thread_func f, void *d, volatile void **return_code, stb_semaphore rel) { #ifdef _MT #if defined(STB_FASTMALLOC) && !defined(STB_FASTMALLOC_ITS_OKAY_I_ONLY_MALLOC_IN_ONE_THREAD) stb_fatal("Error! Cannot use STB_FASTMALLOC with threads.\n"); return STB_THREAD_NULL; #else unsigned long id; stb__thread *data = (stb__thread *) malloc(sizeof(*data)); if (!data) return NULL; stb__threadmutex_init(); data->f = f; data->d = d; data->return_val = return_code; data->sem = rel; id = _beginthread(stb__thread_run, 0, data); if (id == -1) return NULL; return (void *) id; #endif #else #ifdef STB_NO_STB_STRINGS stb_fatal("Invalid compilation"); #else stb_fatal("Must compile mult-threaded to use stb_thread/stb_work."); #endif return NULL; #endif } // trivial win32 wrappers void stb_destroy_thread(stb_thread t) { TerminateThread(t,0); } stb_semaphore stb_sem_new(int maxv) {return CreateSemaphoreA(NULL,0,maxv,NULL); } stb_semaphore stb_sem_new_extra(int maxv,int start){return CreateSemaphoreA(NULL,start,maxv,NULL); } void stb_sem_delete(stb_semaphore s) { if (s != NULL) CloseHandle(s); } void stb_sem_waitfor(stb_semaphore s) { WaitForSingleObject(s, 0xffffffff); } // INFINITE void stb_sem_release(stb_semaphore s) { ReleaseSemaphore(s,1,NULL); } static void stb__thread_sleep(int ms) { Sleep(ms); } #ifndef _WINDOWS_ STB__IMPORT int __stdcall GetProcessAffinityMask(void *, STB__DW *, STB__DW *); STB__IMPORT void * __stdcall GetCurrentProcess(void); STB__IMPORT int __stdcall SetProcessAffinityMask(void *, STB__DW); #endif int stb_processor_count(void) { unsigned long proc,sys; GetProcessAffinityMask(GetCurrentProcess(), &proc, &sys); return stb_bitcount(proc); } void stb_force_uniprocessor(void) { unsigned long proc,sys; GetProcessAffinityMask(GetCurrentProcess(), &proc, &sys); if (stb_bitcount(proc) > 1) { int z; for (z=0; z < 32; ++z) if (proc & (1 << z)) break; if (z < 32) { proc = 1 << z; SetProcessAffinityMask(GetCurrentProcess(), proc); } } } #ifdef _WINDOWS_ #define STB_MUTEX_NATIVE void *stb_mutex_new(void) { CRITICAL_SECTION *p = (CRITICAL_SECTION *) malloc(sizeof(*p)); if (p) #if _WIN32_WINNT >= 0x0500 InitializeCriticalSectionAndSpinCount(p, 500); #else InitializeCriticalSection(p); #endif return p; } void stb_mutex_delete(void *p) { if (p) { DeleteCriticalSection((CRITICAL_SECTION *) p); free(p); } } void stb_mutex_begin(void *p) { stb__wait(500); if (p) EnterCriticalSection((CRITICAL_SECTION *) p); } void stb_mutex_end(void *p) { if (p) LeaveCriticalSection((CRITICAL_SECTION *) p); stb__wait(500); } #endif // _WINDOWS_ #if 0 // for future reference, // InterlockedCompareExchange for x86: int cas64_mp(void * dest, void * xcmp, void * xxchg) { __asm { mov esi, [xxchg] ; exchange mov ebx, [esi + 0] mov ecx, [esi + 4] mov esi, [xcmp] ; comparand mov eax, [esi + 0] mov edx, [esi + 4] mov edi, [dest] ; destination lock cmpxchg8b [edi] jz yyyy; mov [esi + 0], eax; mov [esi + 4], edx; yyyy: xor eax, eax; setz al; }; inline unsigned __int64 _InterlockedCompareExchange64(volatile unsigned __int64 *dest ,unsigned __int64 exchange ,unsigned __int64 comperand) { //value returned in eax::edx __asm { lea esi,comperand; lea edi,exchange; mov eax,[esi]; mov edx,4[esi]; mov ebx,[edi]; mov ecx,4[edi]; mov esi,dest; lock CMPXCHG8B [esi]; } #endif // #if 0 #endif // _WIN32 stb_thread stb_create_thread2(stb_thread_func f, void *d, volatile void **return_code, stb_semaphore rel) { return stb_create_thread_raw(f,d,return_code,rel); } stb_thread stb_create_thread(stb_thread_func f, void *d) { return stb_create_thread2(f,d,NULL,STB_SEMAPHORE_NULL); } // mutex implemented by wrapping semaphore #ifndef STB_MUTEX_NATIVE stb_mutex stb_mutex_new(void) { return stb_sem_new_extra(1,1); } void stb_mutex_delete(stb_mutex m) { stb_sem_delete (m); } void stb_mutex_begin(stb_mutex m) { stb__wait(500); if (m) stb_sem_waitfor(m); } void stb_mutex_end(stb_mutex m) { if (m) stb_sem_release(m); stb__wait(500); } #endif // thread merge operation struct stb__sync { int target; // target number of threads to hit it int sofar; // total threads that hit it int waiting; // total threads waiting stb_mutex start; // mutex to prevent starting again before finishing previous stb_mutex mutex; // mutex while tweaking state stb_semaphore release; // semaphore wake up waiting threads // we have to wake them up one at a time, rather than using a single release // call, because win32 semaphores don't let you dynamically change the max count! }; stb_sync stb_sync_new(void) { stb_sync s = (stb_sync) malloc(sizeof(*s)); if (!s) return s; s->target = s->sofar = s->waiting = 0; s->mutex = stb_mutex_new(); s->start = stb_mutex_new(); s->release = stb_sem_new(1); if (s->mutex == STB_MUTEX_NULL || s->release == STB_SEMAPHORE_NULL || s->start == STB_MUTEX_NULL) { stb_mutex_delete(s->mutex); stb_mutex_delete(s->mutex); stb_sem_delete(s->release); free(s); return NULL; } return s; } void stb_sync_delete(stb_sync s) { if (s->waiting) { // it's bad to delete while there are threads waiting! // shall we wait for them to reach, or just bail? just bail assert(0); } stb_mutex_delete(s->mutex); stb_mutex_delete(s->release); free(s); } int stb_sync_set_target(stb_sync s, int count) { // don't allow setting a target until the last one is fully released; // note that this can lead to inefficient pipelining, and maybe we'd // be better off ping-ponging between two internal syncs? // I tried seeing how often this happened using TryEnterCriticalSection // and could _never_ get it to happen in imv(stb), even with more threads // than processors. So who knows! stb_mutex_begin(s->start); // this mutex is pointless, since it's not valid for threads // to call reach() before anyone calls set_target() anyway stb_mutex_begin(s->mutex); assert(s->target == 0); // enforced by start mutex s->target = count; s->sofar = 0; s->waiting = 0; stb_mutex_end(s->mutex); return STB_TRUE; } void stb__sync_release(stb_sync s) { if (s->waiting) stb_sem_release(s->release); else { s->target = 0; stb_mutex_end(s->start); } } int stb_sync_reach(stb_sync s) { int n; stb_mutex_begin(s->mutex); assert(s->sofar < s->target); n = ++s->sofar; // record this value to avoid possible race if we did 'return s->sofar'; if (s->sofar == s->target) stb__sync_release(s); stb_mutex_end(s->mutex); return n; } void stb_sync_reach_and_wait(stb_sync s) { stb_mutex_begin(s->mutex); assert(s->sofar < s->target); ++s->sofar; if (s->sofar == s->target) { stb__sync_release(s); stb_mutex_end(s->mutex); } else { ++s->waiting; // we're waiting, so one more waiter stb_mutex_end(s->mutex); // release the mutex to other threads stb_sem_waitfor(s->release); // wait for merge completion stb_mutex_begin(s->mutex); // on merge completion, grab the mutex --s->waiting; // we're done waiting stb__sync_release(s); // restart the next waiter stb_mutex_end(s->mutex); // and now we're done // this ends the same as the first case, but it's a lot // clearer to understand without sharing the code } } struct stb__threadqueue { stb_mutex add, remove; stb_semaphore nonempty, nonfull; int head_blockers; // number of threads blocking--used to know whether to release(avail) int tail_blockers; int head, tail, array_size, growable; int item_size; char *data; }; static int stb__tq_wrap(volatile stb_threadqueue *z, int p) { if (p == z->array_size) return p - z->array_size; else return p; } int stb__threadq_get_raw(stb_threadqueue *tq2, void *output, int block) { volatile stb_threadqueue *tq = (volatile stb_threadqueue *) tq2; if (tq->head == tq->tail && !block) return 0; stb_mutex_begin(tq->remove); while (tq->head == tq->tail) { if (!block) { stb_mutex_end(tq->remove); return 0; } ++tq->head_blockers; stb_mutex_end(tq->remove); stb_sem_waitfor(tq->nonempty); stb_mutex_begin(tq->remove); --tq->head_blockers; } memcpy(output, tq->data + tq->head*tq->item_size, tq->item_size); stb_barrier(); tq->head = stb__tq_wrap(tq, tq->head+1); stb_sem_release(tq->nonfull); if (tq->head_blockers) // can't check if actually non-empty due to race? stb_sem_release(tq->nonempty); // if there are other blockers, wake one stb_mutex_end(tq->remove); return STB_TRUE; } int stb__threadq_grow(volatile stb_threadqueue *tq) { int n; char *p; assert(tq->remove != STB_MUTEX_NULL); // must have this to allow growth! stb_mutex_begin(tq->remove); n = tq->array_size * 2; p = (char *) realloc(tq->data, n * tq->item_size); if (p == NULL) { stb_mutex_end(tq->remove); stb_mutex_end(tq->add); return STB_FALSE; } if (tq->tail < tq->head) { memcpy(p + tq->array_size * tq->item_size, p, tq->tail * tq->item_size); tq->tail += tq->array_size; } tq->data = p; tq->array_size = n; stb_mutex_end(tq->remove); return STB_TRUE; } int stb__threadq_add_raw(stb_threadqueue *tq2, void *input, int block) { int tail,pos; volatile stb_threadqueue *tq = (volatile stb_threadqueue *) tq2; stb_mutex_begin(tq->add); for(;;) { pos = tq->tail; tail = stb__tq_wrap(tq, pos+1); if (tail != tq->head) break; // full if (tq->growable) { if (!stb__threadq_grow(tq)) { stb_mutex_end(tq->add); return STB_FALSE; // out of memory } } else if (!block) { stb_mutex_end(tq->add); return STB_FALSE; } else { ++tq->tail_blockers; stb_mutex_end(tq->add); stb_sem_waitfor(tq->nonfull); stb_mutex_begin(tq->add); --tq->tail_blockers; } } memcpy(tq->data + tq->item_size * pos, input, tq->item_size); stb_barrier(); tq->tail = tail; stb_sem_release(tq->nonempty); if (tq->tail_blockers) // can't check if actually non-full due to race? stb_sem_release(tq->nonfull); stb_mutex_end(tq->add); return STB_TRUE; } int stb_threadq_length(stb_threadqueue *tq2) { int a,b,n; volatile stb_threadqueue *tq = (volatile stb_threadqueue *) tq2; stb_mutex_begin(tq->add); a = tq->head; b = tq->tail; n = tq->array_size; stb_mutex_end(tq->add); if (a > b) b += n; return b-a; } int stb_threadq_get(stb_threadqueue *tq, void *output) { return stb__threadq_get_raw(tq, output, STB_FALSE); } void stb_threadq_get_block(stb_threadqueue *tq, void *output) { stb__threadq_get_raw(tq, output, STB_TRUE); } int stb_threadq_add(stb_threadqueue *tq, void *input) { return stb__threadq_add_raw(tq, input, STB_FALSE); } int stb_threadq_add_block(stb_threadqueue *tq, void *input) { return stb__threadq_add_raw(tq, input, STB_TRUE); } void stb_threadq_delete(stb_threadqueue *tq) { if (tq) { free(tq->data); stb_mutex_delete(tq->add); stb_mutex_delete(tq->remove); stb_sem_delete(tq->nonempty); stb_sem_delete(tq->nonfull); free(tq); } } #define STB_THREADQUEUE_DYNAMIC 0 stb_threadqueue *stb_threadq_new(int item_size, int num_items, int many_add, int many_remove) { int error=0; stb_threadqueue *tq = (stb_threadqueue *) malloc(sizeof(*tq)); if (tq == NULL) return NULL; if (num_items == STB_THREADQUEUE_DYNAMIC) { tq->growable = STB_TRUE; num_items = 32; } else tq->growable = STB_FALSE; tq->item_size = item_size; tq->array_size = num_items+1; tq->add = tq->remove = STB_MUTEX_NULL; tq->nonempty = tq->nonfull = STB_SEMAPHORE_NULL; tq->data = NULL; if (many_add) { tq->add = stb_mutex_new(); if (tq->add == STB_MUTEX_NULL) goto error; } if (many_remove || tq->growable) { tq->remove = stb_mutex_new(); if (tq->remove == STB_MUTEX_NULL) goto error; } tq->nonempty = stb_sem_new(1); if (tq->nonempty == STB_SEMAPHORE_NULL) goto error; tq->nonfull = stb_sem_new(1); if (tq->nonfull == STB_SEMAPHORE_NULL) goto error; tq->data = (char *) malloc(tq->item_size * tq->array_size); if (tq->data == NULL) goto error; tq->head = tq->tail = 0; tq->head_blockers = tq->tail_blockers = 0; return tq; error: stb_threadq_delete(tq); return NULL; } typedef struct { stb_thread_func f; void *d; volatile void **retval; stb_sync sync; } stb__workinfo; //static volatile stb__workinfo *stb__work; struct stb__workqueue { int numthreads; stb_threadqueue *tq; }; static stb_workqueue *stb__work_global; static void *stb__thread_workloop(void *p) { volatile stb_workqueue *q = (volatile stb_workqueue *) p; for(;;) { void *z; stb__workinfo w; stb_threadq_get_block(q->tq, &w); if (w.f == NULL) // null work is a signal to end the thread return NULL; z = w.f(w.d); if (w.retval) { stb_barrier(); *w.retval = z; } if (w.sync != STB_SYNC_NULL) stb_sync_reach(w.sync); } } stb_workqueue *stb_workq_new(int num_threads, int max_units) { return stb_workq_new_flags(num_threads, max_units, 0,0); } stb_workqueue *stb_workq_new_flags(int numthreads, int max_units, int no_add_mutex, int no_remove_mutex) { stb_workqueue *q = (stb_workqueue *) malloc(sizeof(*q)); if (q == NULL) return NULL; q->tq = stb_threadq_new(sizeof(stb__workinfo), max_units, !no_add_mutex, !no_remove_mutex); if (q->tq == NULL) { free(q); return NULL; } q->numthreads = 0; stb_workq_numthreads(q, numthreads); return q; } void stb_workq_delete(stb_workqueue *q) { while (stb_workq_length(q) != 0) stb__thread_sleep(1); stb_threadq_delete(q->tq); free(q); } static int stb__work_maxitems = STB_THREADQUEUE_DYNAMIC; static void stb_work_init(int num_threads) { if (stb__work_global == NULL) { stb__threadmutex_init(); stb_mutex_begin(stb__workmutex); stb_barrier(); if (*(stb_workqueue * volatile *) &stb__work_global == NULL) stb__work_global = stb_workq_new(num_threads, stb__work_maxitems); stb_mutex_end(stb__workmutex); } } static int stb__work_raw(stb_workqueue *q, stb_thread_func f, void *d, volatile void **return_code, stb_sync rel) { stb__workinfo w; if (q == NULL) { stb_work_init(1); q = stb__work_global; } w.f = f; w.d = d; w.retval = return_code; w.sync = rel; return stb_threadq_add(q->tq, &w); } int stb_workq_length(stb_workqueue *q) { return stb_threadq_length(q->tq); } int stb_workq(stb_workqueue *q, stb_thread_func f, void *d, volatile void **return_code) { if (f == NULL) return 0; return stb_workq_reach(q, f, d, return_code, NULL); } int stb_workq_reach(stb_workqueue *q, stb_thread_func f, void *d, volatile void **return_code, stb_sync rel) { if (f == NULL) return 0; return stb__work_raw(q, f, d, return_code, rel); } static void stb__workq_numthreads(stb_workqueue *q, int n) { while (q->numthreads < n) { stb_create_thread(stb__thread_workloop, q); ++q->numthreads; } while (q->numthreads > n) { stb__work_raw(q, NULL, NULL, NULL, NULL); --q->numthreads; } } void stb_workq_numthreads(stb_workqueue *q, int n) { stb_mutex_begin(stb__threadmutex); stb__workq_numthreads(q,n); stb_mutex_end(stb__threadmutex); } int stb_work_maxunits(int n) { if (stb__work_global == NULL) { stb__work_maxitems = n; stb_work_init(1); } return stb__work_maxitems; } int stb_work(stb_thread_func f, void *d, volatile void **return_code) { return stb_workq(stb__work_global, f,d,return_code); } int stb_work_reach(stb_thread_func f, void *d, volatile void **return_code, stb_sync rel) { return stb_workq_reach(stb__work_global, f,d,return_code,rel); } void stb_work_numthreads(int n) { if (stb__work_global == NULL) stb_work_init(n); else stb_workq_numthreads(stb__work_global, n); } #endif // STB_DEFINE ////////////////////////////////////////////////////////////////////////////// // // Background disk I/O // // #define STB_BGIO_READ_ALL (-1) STB_EXTERN int stb_bgio_read (char *filename, int offset, int len, stb_uchar **result, int *olen); STB_EXTERN int stb_bgio_readf (FILE *f , int offset, int len, stb_uchar **result, int *olen); STB_EXTERN int stb_bgio_read_to (char *filename, int offset, int len, stb_uchar *buffer, int *olen); STB_EXTERN int stb_bgio_readf_to(FILE *f , int offset, int len, stb_uchar *buffer, int *olen); typedef struct { int have_data; int is_valid; int is_dir; time_t filetime; stb_int64 filesize; } stb_bgstat; STB_EXTERN int stb_bgio_stat (char *filename, stb_bgstat *result); #ifdef STB_DEFINE static stb_workqueue *stb__diskio; static stb_mutex stb__diskio_mutex; void stb_thread_cleanup(void) { if (stb__work_global) stb_workq_delete(stb__work_global); stb__work_global = NULL; if (stb__threadmutex) stb_mutex_delete(stb__threadmutex); stb__threadmutex = NULL; if (stb__workmutex) stb_mutex_delete(stb__workmutex); stb__workmutex = NULL; if (stb__diskio) stb_workq_delete(stb__diskio); stb__diskio = NULL; if (stb__diskio_mutex)stb_mutex_delete(stb__diskio_mutex);stb__diskio_mutex= NULL; } typedef struct { char *filename; FILE *f; int offset; int len; stb_bgstat *stat_out; stb_uchar *output; stb_uchar **result; int *len_output; int *flag; } stb__disk_command; #define STB__MAX_DISK_COMMAND 100 static stb__disk_command stb__dc_queue[STB__MAX_DISK_COMMAND]; static int stb__dc_offset; void stb__io_init(void) { if (!stb__diskio) { stb__threadmutex_init(); stb_mutex_begin(stb__threadmutex); stb_barrier(); if (*(stb_thread * volatile *) &stb__diskio == NULL) { stb__diskio_mutex = stb_mutex_new(); // use many threads so OS can try to schedule seeks stb__diskio = stb_workq_new_flags(16,STB__MAX_DISK_COMMAND,STB_FALSE,STB_FALSE); } stb_mutex_end(stb__threadmutex); } } static void * stb__io_error(stb__disk_command *dc) { if (dc->len_output) *dc->len_output = 0; if (dc->result) *dc->result = NULL; if (dc->flag) *dc->flag = -1; return NULL; } static void * stb__io_task(void *p) { stb__disk_command *dc = (stb__disk_command *) p; int len; FILE *f; stb_uchar *buf; if (dc->stat_out) { struct _stati64 s; if (!_stati64(dc->filename, &s)) { dc->stat_out->filesize = s.st_size; dc->stat_out->filetime = s.st_mtime; dc->stat_out->is_dir = s.st_mode & _S_IFDIR; dc->stat_out->is_valid = (s.st_mode & _S_IFREG) || dc->stat_out->is_dir; } else dc->stat_out->is_valid = 0; stb_barrier(); dc->stat_out->have_data = 1; free(dc->filename); return 0; } if (dc->f) { #ifdef WIN32 f = _fdopen(_dup(_fileno(dc->f)), "rb"); #else f = fdopen(dup(fileno(dc->f)), "rb"); #endif if (!f) return stb__io_error(dc); } else { f = fopen(dc->filename, "rb"); free(dc->filename); if (!f) return stb__io_error(dc); } len = dc->len; if (len < 0) { fseek(f, 0, SEEK_END); len = ftell(f) - dc->offset; } if (fseek(f, dc->offset, SEEK_SET)) { fclose(f); return stb__io_error(dc); } if (dc->output) buf = dc->output; else { buf = (stb_uchar *) malloc(len); if (buf == NULL) { fclose(f); return stb__io_error(dc); } } len = fread(buf, 1, len, f); fclose(f); if (dc->len_output) *dc->len_output = len; if (dc->result) *dc->result = buf; if (dc->flag) *dc->flag = 1; return NULL; } int stb__io_add(char *fname, FILE *f, int off, int len, stb_uchar *out, stb_uchar **result, int *olen, int *flag, stb_bgstat *stat) { int res; stb__io_init(); // do memory allocation outside of mutex if (fname) fname = strdup(fname); stb_mutex_begin(stb__diskio_mutex); { stb__disk_command *dc = &stb__dc_queue[stb__dc_offset]; dc->filename = fname; dc->f = f; dc->offset = off; dc->len = len; dc->output = out; dc->result = result; dc->len_output = olen; dc->flag = flag; dc->stat_out = stat; res = stb_workq(stb__diskio, stb__io_task, dc, NULL); if (res) stb__dc_offset = (stb__dc_offset + 1 == STB__MAX_DISK_COMMAND ? 0 : stb__dc_offset+1); } stb_mutex_end(stb__diskio_mutex); return res; } int stb_bgio_read(char *filename, int offset, int len, stb_uchar **result, int *olen) { return stb__io_add(filename,NULL,offset,len,NULL,result,olen,NULL,NULL); } int stb_bgio_readf(FILE *f, int offset, int len, stb_uchar **result, int *olen) { return stb__io_add(NULL,f,offset,len,NULL,result,olen,NULL,NULL); } int stb_bgio_read_to(char *filename, int offset, int len, stb_uchar *buffer, int *olen) { return stb__io_add(filename,NULL,offset,len,buffer,NULL,olen,NULL,NULL); } int stb_bgio_readf_to(FILE *f, int offset, int len, stb_uchar *buffer, int *olen) { return stb__io_add(NULL,f,offset,len,buffer,NULL,olen,NULL,NULL); } STB_EXTERN int stb_bgio_stat (char *filename, stb_bgstat *result) { result->have_data = 0; return stb__io_add(filename,NULL,0,0,0,NULL,0,NULL, result); } #endif #endif ////////////////////////////////////////////////////////////////////////////// // // Fast malloc implementation // // This is a clone of TCMalloc, but without the thread support. // 1. large objects are allocated directly, page-aligned // 2. small objects are allocated in homogeonous heaps, 0 overhead // // We keep an allocation table for pages a la TCMalloc. This would // require 4MB for the entire address space, but we only allocate // the parts that are in use. The overhead from using homogenous heaps // everywhere is 3MB. (That is, if you allocate 1 object of each size, // you'll use 3MB.) #if defined(STB_DEFINE) && (defined(_WIN32) || defined(STB_FASTMALLOC)) #ifdef _WIN32 #ifndef _WINDOWS_ #ifndef STB__IMPORT #define STB__IMPORT STB_EXTERN __declspec(dllimport) #define STB__DW unsigned long #endif STB__IMPORT void * __stdcall VirtualAlloc(void *p, unsigned long size, unsigned long type, unsigned long protect); STB__IMPORT int __stdcall VirtualFree(void *p, unsigned long size, unsigned long freetype); #endif #define stb__alloc_pages_raw(x) (stb_uint32) VirtualAlloc(NULL, (x), 0x3000, 0x04) #define stb__dealloc_pages_raw(p) VirtualFree((void *) p, 0, 0x8000) #else #error "Platform not currently supported" #endif typedef struct stb__span { int start, len; struct stb__span *next, *prev; void *first_free; unsigned short list; // 1..256 free; 257..511 sizeclass; 0=large block short allocations; // # outstanding allocations for sizeclass } stb__span; // 24 static stb__span **stb__span_for_page; static int stb__firstpage, stb__lastpage; static void stb__update_page_range(int first, int last) { stb__span **sfp; int i, f,l; if (first >= stb__firstpage && last <= stb__lastpage) return; if (stb__span_for_page == NULL) { f = first; l = f+stb_max(last-f, 16384); l = stb_min(l, 1<<20); } else if (last > stb__lastpage) { f = stb__firstpage; l = f + (stb__lastpage - f) * 2; l = stb_clamp(last, l,1<<20); } else { l = stb__lastpage; f = l - (l - stb__firstpage) * 2; f = stb_clamp(f, 0,first); } sfp = (stb__span **) stb__alloc_pages_raw(sizeof(void *) * (l-f)); for (i=f; i < stb__firstpage; ++i) sfp[i - f] = NULL; for ( ; i < stb__lastpage ; ++i) sfp[i - f] = stb__span_for_page[i - stb__firstpage]; for ( ; i < l ; ++i) sfp[i - f] = NULL; if (stb__span_for_page) stb__dealloc_pages_raw(stb__span_for_page); stb__firstpage = f; stb__lastpage = l; stb__span_for_page = sfp; } static stb__span *stb__span_free=NULL; static stb__span *stb__span_first, *stb__span_end; static stb__span *stb__span_alloc(void) { stb__span *s = stb__span_free; if (s) stb__span_free = s->next; else { if (!stb__span_first) { stb__span_first = (stb__span *) stb__alloc_pages_raw(65536); if (stb__span_first == NULL) return NULL; stb__span_end = stb__span_first + (65536 / sizeof(stb__span)); } s = stb__span_first++; if (stb__span_first == stb__span_end) stb__span_first = NULL; } return s; } static stb__span *stb__spanlist[512]; static void stb__spanlist_unlink(stb__span *s) { if (s->prev) s->prev->next = s->next; else { int n = s->list; assert(stb__spanlist[n] == s); stb__spanlist[n] = s->next; } if (s->next) s->next->prev = s->prev; s->next = s->prev = NULL; s->list = 0; } static void stb__spanlist_add(int n, stb__span *s) { s->list = n; s->next = stb__spanlist[n]; s->prev = NULL; stb__spanlist[n] = s; if (s->next) s->next->prev = s; } #define stb__page_shift 12 #define stb__page_size (1 << stb__page_shift) #define stb__page_number(x) ((x) >> stb__page_shift) #define stb__page_address(x) ((x) << stb__page_shift) static void stb__set_span_for_page(stb__span *s) { int i; for (i=0; i < s->len; ++i) stb__span_for_page[s->start + i - stb__firstpage] = s; } static stb__span *stb__coalesce(stb__span *a, stb__span *b) { assert(a->start + a->len == b->start); if (a->list) stb__spanlist_unlink(a); if (b->list) stb__spanlist_unlink(b); a->len += b->len; b->len = 0; b->next = stb__span_free; stb__span_free = b; stb__set_span_for_page(a); return a; } static void stb__free_span(stb__span *s) { stb__span *n = NULL; if (s->start > stb__firstpage) { n = stb__span_for_page[s->start-1 - stb__firstpage]; if (n && n->allocations == -2 && n->start + n->len == s->start) s = stb__coalesce(n,s); } if (s->start + s->len < stb__lastpage) { n = stb__span_for_page[s->start + s->len - stb__firstpage]; if (n && n->allocations == -2 && s->start + s->len == n->start) s = stb__coalesce(s,n); } s->allocations = -2; stb__spanlist_add(s->len > 256 ? 256 : s->len, s); } static stb__span *stb__alloc_pages(int num) { stb__span *s = stb__span_alloc(); int p; if (!s) return NULL; p = stb__alloc_pages_raw(num << stb__page_shift); if (p == 0) { s->next = stb__span_free; stb__span_free = s; return 0; } assert(stb__page_address(stb__page_number(p)) == p); p = stb__page_number(p); stb__update_page_range(p, p+num); s->start = p; s->len = num; s->next = NULL; s->prev = NULL; stb__set_span_for_page(s); return s; } static stb__span *stb__alloc_span(int pagecount) { int i; stb__span *p = NULL; for(i=pagecount; i < 256; ++i) if (stb__spanlist[i]) { p = stb__spanlist[i]; break; } if (!p) { p = stb__spanlist[256]; while (p && p->len < pagecount) p = p->next; } if (!p) { p = stb__alloc_pages(pagecount < 16 ? 16 : pagecount); if (p == NULL) return 0; } else stb__spanlist_unlink(p); if (p->len > pagecount) { stb__span *q = stb__span_alloc(); if (q) { q->start = p->start + pagecount; q->len = p->len - pagecount; p->len = pagecount; for (i=0; i < q->len; ++i) stb__span_for_page[q->start+i - stb__firstpage] = q; stb__spanlist_add(q->len > 256 ? 256 : q->len, q); } } return p; } #define STB__MAX_SMALL_SIZE 32768 #define STB__MAX_SIZE_CLASSES 256 static unsigned char stb__class_base[32]; static unsigned char stb__class_shift[32]; static unsigned char stb__pages_for_class[STB__MAX_SIZE_CLASSES]; static int stb__size_for_class[STB__MAX_SIZE_CLASSES]; stb__span *stb__get_nonempty_sizeclass(int c) { int s = c + 256, i, size, tsize; // remap to span-list index char *z; void *q; stb__span *p = stb__spanlist[s]; if (p) { if (p->first_free) return p; // fast path: it's in the first one in list for (p=p->next; p; p=p->next) if (p->first_free) { // move to front for future queries stb__spanlist_unlink(p); stb__spanlist_add(s, p); return p; } } // no non-empty ones, so allocate a new one p = stb__alloc_span(stb__pages_for_class[c]); if (!p) return NULL; // create the free list up front size = stb__size_for_class[c]; tsize = stb__pages_for_class[c] << stb__page_shift; i = 0; z = (char *) stb__page_address(p->start); q = NULL; while (i + size <= tsize) { * (void **) z = q; q = z; z += size; i += size; } p->first_free = q; p->allocations = 0; stb__spanlist_add(s,p); return p; } static int stb__sizeclass(size_t sz) { int z = stb_log2_floor(sz); // -1 below to group e.g. 13,14,15,16 correctly return stb__class_base[z] + ((sz-1) >> stb__class_shift[z]); } static void stb__init_sizeclass(void) { int i, size, overhead; int align_shift = 2; // allow 4-byte and 12-byte blocks as well, vs. TCMalloc int next_class = 1; int last_log = 0; for (i = 0; i < align_shift; i++) { stb__class_base [i] = next_class; stb__class_shift[i] = align_shift; } for (size = 1 << align_shift; size <= STB__MAX_SMALL_SIZE; size += 1 << align_shift) { i = stb_log2_floor(size); if (i > last_log) { if (size == 16) ++align_shift; // switch from 4-byte to 8-byte alignment else if (size >= 128 && align_shift < 8) ++align_shift; stb__class_base[i] = next_class - ((size-1) >> align_shift); stb__class_shift[i] = align_shift; last_log = i; } stb__size_for_class[next_class++] = size; } for (i=1; i <= STB__MAX_SMALL_SIZE; ++i) assert(i <= stb__size_for_class[stb__sizeclass(i)]); overhead = 0; for (i = 1; i < next_class; i++) { int s = stb__size_for_class[i]; size = stb__page_size; while (size % s > size >> 3) size += stb__page_size; stb__pages_for_class[i] = (unsigned char) (size >> stb__page_shift); overhead += size; } assert(overhead < (4 << 20)); // make sure it's under 4MB of overhead } #ifdef STB_DEBUG #define stb__smemset(a,b,c) memset((void *) a, b, c) #elif defined(STB_FASTMALLOC_INIT) #define stb__smemset(a,b,c) memset((void *) a, b, c) #else #define stb__smemset(a,b,c) #endif void *stb_smalloc(size_t sz) { stb__span *s; if (sz == 0) return NULL; if (stb__size_for_class[1] == 0) stb__init_sizeclass(); if (sz > STB__MAX_SMALL_SIZE) { s = stb__alloc_span((sz + stb__page_size - 1) >> stb__page_shift); if (s == NULL) return NULL; s->list = 0; s->next = s->prev = NULL; s->allocations = -32767; stb__smemset(stb__page_address(s->start), 0xcd, (sz+3)&~3); return (void *) stb__page_address(s->start); } else { void *p; int c = stb__sizeclass(sz); s = stb__spanlist[256+c]; if (!s || !s->first_free) s = stb__get_nonempty_sizeclass(c); if (s == NULL) return NULL; p = s->first_free; s->first_free = * (void **) p; ++s->allocations; stb__smemset(p,0xcd, sz); return p; } } int stb_ssize(void *p) { stb__span *s; if (p == NULL) return 0; s = stb__span_for_page[stb__page_number((stb_uint) p) - stb__firstpage]; if (s->list >= 256) { return stb__size_for_class[s->list - 256]; } else { assert(s->list == 0); return s->len << stb__page_shift; } } void stb_sfree(void *p) { stb__span *s; if (p == NULL) return; s = stb__span_for_page[stb__page_number((stb_uint) p) - stb__firstpage]; if (s->list >= 256) { stb__smemset(p, 0xfe, stb__size_for_class[s->list-256]); * (void **) p = s->first_free; s->first_free = p; if (--s->allocations == 0) { stb__spanlist_unlink(s); stb__free_span(s); } } else { assert(s->list == 0); stb__smemset(p, 0xfe, stb_ssize(p)); stb__free_span(s); } } void *stb_srealloc(void *p, size_t sz) { size_t cur_size; if (p == NULL) return stb_smalloc(sz); if (sz == 0) { stb_sfree(p); return NULL; } cur_size = stb_ssize(p); if (sz > cur_size || sz <= (cur_size >> 1)) { void *q; if (sz > cur_size && sz < (cur_size << 1)) sz = cur_size << 1; q = stb_smalloc(sz); if (q == NULL) return NULL; memcpy(q, p, sz < cur_size ? sz : cur_size); stb_sfree(p); return q; } return p; } void *stb_scalloc(size_t n, size_t sz) { void *p; if (n == 0 || sz == 0) return NULL; if (stb_log2_ceil(n) + stb_log2_ceil(n) >= 32) return NULL; p = stb_smalloc(n*sz); if (p) memset(p, 0, n*sz); return p; } char *stb_sstrdup(char *s) { int n = strlen(s); char *p = (char *) stb_smalloc(n+1); if (p) strcpy(p,s); return p; } #endif // STB_DEFINE ////////////////////////////////////////////////////////////////////////////// // // Source code constants // // This is a trivial system to let you specify constants in source code, // then while running you can change the constants. // // Note that you can't wrap the #defines, because we need to know their // names. So we provide a pre-wrapped version without 'STB_' for convenience; // to request it, #define STB_CONVENIENT_H, yielding: // KI -- integer // KU -- unsigned integer // KF -- float // KD -- double // KS -- string constant // // Defaults to functioning in debug build, not in release builds. // To force on, define STB_ALWAYS_H #ifdef STB_CONVENIENT_H #define KI(x) STB_I(x) #define KU(x) STB_UI(x) #define KF(x) STB_F(x) #define KD(x) STB_D(x) #define KS(x) STB_S(x) #endif STB_EXTERN void stb_source_path(char *str); #ifdef STB_DEFINE char *stb__source_path; void stb_source_path(char *path) { stb__source_path = path; } char *stb__get_sourcefile_path(char *file) { static char filebuf[512]; if (stb__source_path) { sprintf(filebuf, "%s/%s", stb__source_path, file); if (stb_fexists(filebuf)) return filebuf; } if (stb_fexists(file)) return file; sprintf(filebuf, "../%s", file); if (!stb_fexists(filebuf)) return filebuf; return file; } #endif #define STB_F(x) ((float) STB_H(x)) #define STB_UI(x) ((unsigned int) STB_I(x)) #if !defined(STB_DEBUG) && !defined(STB_ALWAYS_H) #define STB_D(x) ((double) (x)) #define STB_I(x) ((int) (x)) #define STB_S(x) ((char *) (x)) #else #define STB_D(x) stb__double_constant(__FILE__, __LINE__-1, (x)) #define STB_I(x) stb__int_constant(__FILE__, __LINE__-1, (x)) #define STB_S(x) stb__string_constant(__FILE__, __LINE__-1, (x)) STB_EXTERN double stb__double_constant(char *file, int line, double x); STB_EXTERN int stb__int_constant(char *file, int line, int x); STB_EXTERN char * stb__string_constant(char *file, int line, char *str); #ifdef STB_DEFINE enum { STB__CTYPE_int, STB__CTYPE_uint, STB__CTYPE_float, STB__CTYPE_double, STB__CTYPE_string, }; typedef struct { int line; int type; union { int ival; double dval; char *sval; }; } stb__Entry; typedef struct { stb__Entry *entries; char *filename; time_t timestamp; char **file_data; int file_len; unsigned short *line_index; } stb__FileEntry; static void stb__constant_parse(stb__FileEntry *f, int i) { char *s; int n; if (!stb_arr_valid(f->entries, i)) return; n = f->entries[i].line; if (n >= f->file_len) return; s = f->file_data[n]; switch (f->entries[i].type) { case STB__CTYPE_float: while (*s) { if (!strncmp(s, "STB_D(", 6)) { s+=6; goto matched_float; } if (!strncmp(s, "STB_F(", 6)) { s+=6; goto matched_float; } if (!strncmp(s, "KD(", 3)) { s+=3; goto matched_float; } if (!strncmp(s, "KF(", 3)) { s+=3; goto matched_float; } ++s; } break; matched_float: f->entries[i].dval = strtod(s, NULL); break; case STB__CTYPE_int: while (*s) { if (!strncmp(s, "STB_I(", 6)) { s+=6; goto matched_int; } if (!strncmp(s, "STB_UI(", 7)) { s+=7; goto matched_int; } if (!strncmp(s, "KI(", 3)) { s+=3; goto matched_int; } if (!strncmp(s, "KU(", 3)) { s+=3; goto matched_int; } ++s; } break; matched_int: { int neg=0; s = stb_skipwhite(s); while (*s == '-') { neg = !neg; s = stb_skipwhite(s+1); } // handle '- - 5', pointlessly if (s[0] == '0' && tolower(s[1]) == 'x') f->entries[i].ival = strtol(s, NULL, 16); else if (s[0] == '0') f->entries[i].ival = strtol(s, NULL, 8); else f->entries[i].ival = strtol(s, NULL, 10); if (neg) f->entries[i].ival = -f->entries[i].ival; break; } case STB__CTYPE_string: // @TODO break; } } static stb_sdict *stb__constant_file_hash; stb__Entry *stb__constant_get_entry(char *filename, int line, int type) { int i; stb__FileEntry *f; if (stb__constant_file_hash == NULL) stb__constant_file_hash = stb_sdict_new(STB_TRUE); f = (stb__FileEntry*) stb_sdict_get(stb__constant_file_hash, filename); if (f == NULL) { char *s = stb__get_sourcefile_path(filename); if (s == NULL || !stb_fexists(s)) return 0; f = (stb__FileEntry *) malloc(sizeof(*f)); f->timestamp = stb_ftimestamp(s); f->file_data = stb_stringfile(s, &f->file_len); f->filename = strdup(s); // cache the full path f->entries = NULL; f->line_index = 0; stb_arr_setlen(f->line_index, f->file_len); memset(f->line_index, 0xff, stb_arr_storage(f->line_index)); } else { time_t t = stb_ftimestamp(f->filename); if (f->timestamp != t) { f->timestamp = t; free(f->file_data); f->file_data = stb_stringfile(f->filename, &f->file_len); stb_arr_setlen(f->line_index, f->file_len); for (i=0; i < stb_arr_len(f->entries); ++i) stb__constant_parse(f, i); } } if (line >= f->file_len) return 0; if (f->line_index[line] >= stb_arr_len(f->entries)) { // need a new entry int n = stb_arr_len(f->entries); stb__Entry e; e.line = line; if (line < f->file_len) f->line_index[line] = n; e.type = type; stb_arr_push(f->entries, e); stb__constant_parse(f, n); } return f->entries + f->line_index[line]; } double stb__double_constant(char *file, int line, double x) { stb__Entry *e = stb__constant_get_entry(file, line, STB__CTYPE_float); if (!e) return x; return e->dval; } int stb__int_constant(char *file, int line, int x) { stb__Entry *e = stb__constant_get_entry(file, line, STB__CTYPE_int); if (!e) return x; return e->ival; } char * stb__string_constant(char *file, int line, char *x) { stb__Entry *e = stb__constant_get_entry(file, line, STB__CTYPE_string); if (!e) return x; return e->sval; } #endif // STB_DEFINE #endif // !STB_DEBUG && !STB_ALWAYS_H #ifdef STB_STUA ////////////////////////////////////////////////////////////////////////// // // stua: little scripting language // // define STB_STUA to compile it // // see http://nothings.org/stb/stb_stua.html for documentation // // basic parsing model: // // lexical analysis // use stb_lex() to parse tokens; keywords get their own tokens // // parsing: // recursive descent parser. too much of a hassle to make an unambiguous // LR(1) grammar, and one-pass generation is clumsier (recursive descent // makes it easier to e.g. compile nested functions). on the other hand, // dictionary syntax required hackery to get extra lookahead. // // codegen: // output into an evaluation tree, using array indices as 'pointers' // // run: // traverse the tree; support for 'break/continue/return' is tricky // // garbage collection: // stu__mark and sweep; explicit stack with non-stu__compile_global_scope roots typedef stb_int32 stua_obj; typedef stb_idict stua_dict; STB_EXTERN void stua_run_script(char *s); STB_EXTERN void stua_uninit(void); extern stua_obj stua_globals; STB_EXTERN double stua_number(stua_obj z); STB_EXTERN stua_obj stua_getnil(void); STB_EXTERN stua_obj stua_getfalse(void); STB_EXTERN stua_obj stua_gettrue(void); STB_EXTERN stua_obj stua_string(char *z); STB_EXTERN stua_obj stua_make_number(double d); STB_EXTERN stua_obj stua_box(int type, void *data, int size); enum { STUA_op_negate=129, STUA_op_shl, STUA_op_ge, STUA_op_shr, STUA_op_le, STUA_op_shru, STUA_op_last }; #define STUA_NO_VALUE 2 // equivalent to a tagged NULL STB_EXTERN stua_obj (*stua_overload)(int op, stua_obj a, stua_obj b, stua_obj c); STB_EXTERN stua_obj stua_error(char *err, ...); STB_EXTERN stua_obj stua_pushroot(stua_obj o); STB_EXTERN void stua_poproot ( void ); #ifdef STB_DEFINE // INTERPRETER // 31-bit floating point implementation // force the (1 << 30) bit (2nd highest bit) to be zero by re-biasing the exponent; // then shift and set the bottom bit static stua_obj stu__floatp(float *f) { unsigned int n = *(unsigned int *) f; unsigned int e = n & (0xff << 23); assert(sizeof(int) == 4 && sizeof(float) == 4); if (!e) // zero? n = n; // no change else if (e < (64 << 23)) // underflow of the packed encoding? n = (n & 0x80000000); // signed 0 else if (e > (190 << 23)) // overflow of the encoding? (or INF or NAN) n = (n & 0x80000000) + (127 << 23); // new INF encoding else n -= 0x20000000; // now we need to shuffle the bits so that the spare bit is at the bottom assert((n & 0x40000000) == 0); return (n & 0x80000000) + (n << 1) + 1; } static unsigned char stu__getfloat_addend[256]; static float stu__getfloat(stua_obj v) { unsigned int n; unsigned int e = ((unsigned int) v) >> 24; n = (int) v >> 1; // preserve high bit n += stu__getfloat_addend[e] << 24; return *(float *) &n; } stua_obj stua_float(float f) { return stu__floatp(&f); } static void stu__float_init(void) { int i; stu__getfloat_addend[0] = 0; // do nothing to biased exponent of 0 for (i=1; i < 127; ++i) stu__getfloat_addend[i] = 32; // undo the -0x20000000 stu__getfloat_addend[127] = 64; // convert packed INF to INF (0x3f -> 0x7f) for (i=0; i < 128; ++i) // for signed floats, remove the bit we just shifted down stu__getfloat_addend[128+i] = stu__getfloat_addend[i] - 64; } // Tagged data type implementation // TAGS: #define stu__int_tag 0 // of 2 bits // 00 int #define stu__float_tag 1 // of 1 bit // 01 float #define stu__ptr_tag 2 // of 2 bits // 10 boxed // 11 float #define stu__tag(x) ((x) & 3) #define stu__number(x) (stu__tag(x) != stu__ptr_tag) #define stu__isint(x) (stu__tag(x) == stu__int_tag) #define stu__int(x) ((x) >> 2) #define stu__float(x) (stu__getfloat(x)) #define stu__makeint(v) ((v)*4+stu__int_tag) // boxed data, and tag support for boxed data enum { STU___float = 1, STU___int = 2, STU___number = 3, STU___string = 4, STU___function = 5, STU___dict = 6, STU___boolean = 7, STU___error = 8, }; // boxed data #define STU__BOX short type, stua_gc typedef struct stu__box { STU__BOX; } stu__box; stu__box stu__nil = { 0, 1 }; stu__box stu__true = { STU___boolean, 1, }; stu__box stu__false = { STU___boolean, 1, }; #define stu__makeptr(v) ((stua_obj) (v) + stu__ptr_tag) #define stua_nil stu__makeptr(&stu__nil) #define stua_true stu__makeptr(&stu__true) #define stua_false stu__makeptr(&stu__false) stua_obj stua_getnil(void) { return stua_nil; } stua_obj stua_getfalse(void) { return stua_false; } stua_obj stua_gettrue(void) { return stua_true; } #define stu__ptr(x) ((stu__box *) ((x) - stu__ptr_tag)) #define stu__checkt(t,x) ((t) == STU___float ? ((x) & 1) == stu__float_tag : \ (t) == STU___int ? stu__isint(x) : \ (t) == STU___number ? stu__number(x) : \ stu__tag(x) == stu__ptr_tag && stu__ptr(x)->type == (t)) typedef struct { STU__BOX; void *ptr; } stu__wrapper; // implementation of a 'function' or function + closure typedef struct stu__func { STU__BOX; stua_obj closure_source; // 0 - regular function; 4 - C function // if closure, pointer to source function union { stua_obj closure_data; // partial-application data void *store; // pointer to free that holds 'code' stua_obj (*func)(stua_dict *context); } f; // closure ends here short *code; int num_param; stua_obj *param; // list of parameter strings } stu__func; // apply this to 'short *code' to get at data #define stu__const(f) ((stua_obj *) (f)) static void stu__free_func(stu__func *f) { if (f->closure_source == 0) free(f->f.store); if ((stb_uint) f->closure_source <= 4) free(f->param); free(f); } #define stu__pd(x) ((stua_dict *) stu__ptr(x)) #define stu__pw(x) ((stu__wrapper *) stu__ptr(x)) #define stu__pf(x) ((stu__func *) stu__ptr(x)) // garbage-collection static stu__box ** stu__gc_ptrlist; static stua_obj * stu__gc_root_stack; stua_obj stua_pushroot(stua_obj o) { stb_arr_push(stu__gc_root_stack, o); return o; } void stua_poproot ( void ) { stb_arr_pop(stu__gc_root_stack); } static stb_sdict *stu__strings; static void stu__mark(stua_obj z) { int i; stu__box *p = stu__ptr(z); if (p->stua_gc == 1) return; // already marked assert(p->stua_gc == 0); p->stua_gc = 1; switch(p->type) { case STU___function: { stu__func *f = (stu__func *) p; if ((stb_uint) f->closure_source <= 4) { if (f->closure_source == 0) { for (i=1; i <= f->code[0]; ++i) if (!stu__number(((stua_obj *) f->code)[-i])) stu__mark(((stua_obj *) f->code)[-i]); } for (i=0; i < f->num_param; ++i) stu__mark(f->param[i]); } else { stu__mark(f->closure_source); stu__mark(f->f.closure_data); } break; } case STU___dict: { stua_dict *e = (stua_dict *) p; for (i=0; i < e->limit; ++i) if (e->table[i].k != STB_IEMPTY && e->table[i].k != STB_IDEL) { if (!stu__number(e->table[i].k)) stu__mark((int) e->table[i].k); if (!stu__number(e->table[i].v)) stu__mark((int) e->table[i].v); } break; } } } static int stu__num_allocs, stu__size_allocs; static stua_obj stu__flow_val = stua_nil; // used for break & return static void stua_gc(int force) { int i; if (!force && stu__num_allocs == 0 && stu__size_allocs == 0) return; stu__num_allocs = stu__size_allocs = 0; //printf("[gc]\n"); // clear marks for (i=0; i < stb_arr_len(stu__gc_ptrlist); ++i) stu__gc_ptrlist[i]->stua_gc = 0; // stu__mark everything reachable stu__nil.stua_gc = stu__true.stua_gc = stu__false.stua_gc = 1; stu__mark(stua_globals); if (!stu__number(stu__flow_val)) stu__mark(stu__flow_val); for (i=0; i < stb_arr_len(stu__gc_root_stack); ++i) if (!stu__number(stu__gc_root_stack[i])) stu__mark(stu__gc_root_stack[i]); // sweep unreachables for (i=0; i < stb_arr_len(stu__gc_ptrlist);) { stu__box *z = stu__gc_ptrlist[i]; if (!z->stua_gc) { switch (z->type) { case STU___dict: stb_idict_destroy((stua_dict *) z); break; case STU___error: free(((stu__wrapper *) z)->ptr); break; case STU___string: stb_sdict_remove(stu__strings, (char*) ((stu__wrapper *) z)->ptr, NULL); free(z); break; case STU___function: stu__free_func((stu__func *) z); break; } // swap in the last item over this, and repeat z = stb_arr_pop(stu__gc_ptrlist); stu__gc_ptrlist[i] = z; } else ++i; } } static void stu__consider_gc(stua_obj x) { if (stu__size_allocs < 100000) return; if (stu__num_allocs < 10 && stu__size_allocs < 1000000) return; stb_arr_push(stu__gc_root_stack, x); stua_gc(0); stb_arr_pop(stu__gc_root_stack); } static stua_obj stu__makeobj(int type, void *data, int size, int safe_to_gc) { stua_obj x = stu__makeptr(data); ((stu__box *) data)->type = type; stb_arr_push(stu__gc_ptrlist, (stu__box *) data); stu__num_allocs += 1; stu__size_allocs += size; if (safe_to_gc) stu__consider_gc(x); return x; } stua_obj stua_box(int type, void *data, int size) { stu__wrapper *p = (stu__wrapper *) malloc(sizeof(*p)); p->ptr = data; return stu__makeobj(type, p, size, 0); } // a stu string can be directly compared for equality, because // they go into a hash table stua_obj stua_string(char *z) { stu__wrapper *b = (stu__wrapper *) stb_sdict_get(stu__strings, z); if (b == NULL) { int o = stua_box(STU___string, NULL, strlen(z) + sizeof(*b)); b = stu__pw(o); stb_sdict_add(stu__strings, z, b); stb_sdict_getkey(stu__strings, z, (char **) &b->ptr); } return stu__makeptr(b); } // stb_obj dictionary is just an stb_idict static void stu__set(stua_dict *d, stua_obj k, stua_obj v) { if (stb_idict_set(d, k, v)) stu__size_allocs += 8; } static stua_obj stu__get(stua_dict *d, stua_obj k, stua_obj res) { stb_idict_get_flag(d, k, &res); return res; } static stua_obj make_string(char *z, int len) { stua_obj s; char temp[256], *q = (char *) stb_temp(temp, len+1), *p = q; while (len > 0) { if (*z == '\\') { if (z[1] == 'n') *p = '\n'; else if (z[1] == 'r') *p = '\r'; else if (z[1] == 't') *p = '\t'; else *p = z[1]; p += 1; z += 2; len -= 2; } else { *p++ = *z++; len -= 1; } } *p = 0; s = stua_string(q); stb_tempfree(temp, q); return s; } enum token_names { T__none=128, ST_shl = STUA_op_shl, ST_ge = STUA_op_ge, ST_shr = STUA_op_shr, ST_le = STUA_op_le, ST_shru = STUA_op_shru, STU__negate = STUA_op_negate, ST__reset_numbering = STUA_op_last, ST_white, ST_id, ST_float, ST_decimal, ST_hex, ST_char,ST_string, ST_number, // make sure the keywords come _AFTER_ ST_id, so stb_lex prefer them ST_if, ST_while, ST_for, ST_eq, ST_nil, ST_then, ST_do, ST_in, ST_ne, ST_true, ST_else, ST_break, ST_let, ST_and, ST_false, ST_elseif, ST_continue, ST_into, ST_or, ST_repeat, ST_end, ST_as, ST_return, ST_var, ST_func, ST_catch, ST__frame, ST__max_terminals, STU__defaultparm, STU__seq, }; static stua_dict * stu__globaldict; stua_obj stua_globals; static enum { FLOW_normal, FLOW_continue, FLOW_break, FLOW_return, FLOW_error, } stu__flow; stua_obj stua_error(char *z, ...) { stua_obj a; char temp[4096], *x; va_list v; va_start(v,z); vsprintf(temp, z, v); va_end(v); x = strdup(temp); a = stua_box(STU___error, x, strlen(x)); stu__flow = FLOW_error; stu__flow_val = a; return stua_nil; } double stua_number(stua_obj z) { return stu__tag(z) == stu__int_tag ? stu__int(z) : stu__float(z); } stua_obj stua_make_number(double d) { double e = floor(d); if (e == d && e < (1 << 29) && e >= -(1 << 29)) return stu__makeint((int) e); else return stua_float((float) d); } stua_obj (*stua_overload)(int op, stua_obj a, stua_obj b, stua_obj c) = NULL; static stua_obj stu__op(int op, stua_obj a, stua_obj b, stua_obj c) { stua_obj r = STUA_NO_VALUE; if (op == '+') { if (stu__checkt(STU___string, a) && stu__checkt(STU___string, b)) { ;// @TODO: string concatenation } else if (stu__checkt(STU___function, a) && stu__checkt(STU___dict, b)) { stu__func *f = (stu__func *) malloc(12); assert(offsetof(stu__func, code)==12); f->closure_source = a; f->f.closure_data = b; return stu__makeobj(STU___function, f, 16, 1); } } if (stua_overload) r = stua_overload(op,a,b,c); if (stu__flow != FLOW_error && r == STUA_NO_VALUE) stua_error("Typecheck for operator %d", op), r=stua_nil; return r; } #define STU__EVAL2(a,b) \ a = stu__eval(stu__f[n+1]); if (stu__flow) break; stua_pushroot(a); \ b = stu__eval(stu__f[n+2]); stua_poproot(); if (stu__flow) break; #define STU__FB(op) \ STU__EVAL2(a,b) \ if (stu__tag(a) == stu__int_tag && stu__tag(b) == stu__int_tag) \ return ((a) op (b)); \ if (stu__number(a) && stu__number(b)) \ return stua_make_number(stua_number(a) op stua_number(b)); \ return stu__op(stu__f[n], a,b, stua_nil) #define STU__F(op) \ STU__EVAL2(a,b) \ if (stu__number(a) && stu__number(b)) \ return stua_make_number(stua_number(a) op stua_number(b)); \ return stu__op(stu__f[n], a,b, stua_nil) #define STU__I(op) \ STU__EVAL2(a,b) \ if (stu__tag(a) == stu__int_tag && stu__tag(b) == stu__int_tag) \ return stu__makeint(stu__int(a) op stu__int(b)); \ return stu__op(stu__f[n], a,b, stua_nil) #define STU__C(op) \ STU__EVAL2(a,b) \ if (stu__number(a) && stu__number(b)) \ return (stua_number(a) op stua_number(b)) ? stua_true : stua_false; \ return stu__op(stu__f[n], a,b, stua_nil) #define STU__CE(op) \ STU__EVAL2(a,b) \ return (a op b) ? stua_true : stua_false static short *stu__f; static stua_obj stu__f_obj; static stua_dict *stu__c; static stua_obj stu__funceval(stua_obj fo, stua_obj co); static int stu__cond(stua_obj x) { if (stu__flow) return 0; if (!stu__checkt(STU___boolean, x)) x = stu__op('!', x, stua_nil, stua_nil); if (x == stua_true ) return 1; if (x == stua_false) return 0; stu__flow = FLOW_error; return 0; } // had to manually eliminate tailcall recursion for debugging complex stuff #define TAILCALL(x) n = (x); goto top; static stua_obj stu__eval(int n) { top: if (stu__flow >= FLOW_return) return stua_nil; // is this needed? if (n < 0) return stu__const(stu__f)[n]; assert(n != 0 && n != 1); switch (stu__f[n]) { stua_obj a,b,c; case ST_catch: a = stu__eval(stu__f[n+1]); if (stu__flow == FLOW_error) { a=stu__flow_val; stu__flow = FLOW_normal; } return a; case ST_var: b = stu__eval(stu__f[n+2]); if (stu__flow) break; stu__set(stu__c, stu__const(stu__f)[stu__f[n+1]], b); return b; case STU__seq: stu__eval(stu__f[n+1]); if (stu__flow) break; TAILCALL(stu__f[n+2]); case ST_if: if (!stu__cond(stu__eval(stu__f[n+1]))) return stua_nil; TAILCALL(stu__f[n+2]); case ST_else: a = stu__cond(stu__eval(stu__f[n+1])); TAILCALL(stu__f[n + 2 + !a]); #define STU__HANDLE_BREAK \ if (stu__flow >= FLOW_break) { \ if (stu__flow == FLOW_break) { \ a = stu__flow_val; \ stu__flow = FLOW_normal; \ stu__flow_val = stua_nil; \ return a; \ } \ return stua_nil; \ } case ST_as: stu__eval(stu__f[n+3]); STU__HANDLE_BREAK // fallthrough! case ST_while: a = stua_nil; stua_pushroot(a); while (stu__cond(stu__eval(stu__f[n+1]))) { stua_poproot(); a = stu__eval(stu__f[n+2]); STU__HANDLE_BREAK stu__flow = FLOW_normal; // clear 'continue' flag stua_pushroot(a); if (stu__f[n+3]) stu__eval(stu__f[n+3]); STU__HANDLE_BREAK stu__flow = FLOW_normal; // clear 'continue' flag } stua_poproot(); return a; case ST_break: stu__flow = FLOW_break; stu__flow_val = stu__eval(stu__f[n+1]); break; case ST_continue:stu__flow = FLOW_continue; break; case ST_return: stu__flow = FLOW_return; stu__flow_val = stu__eval(stu__f[n+1]); break; case ST__frame: return stu__f_obj; case '[': STU__EVAL2(a,b); if (stu__checkt(STU___dict, a)) return stu__get(stu__pd(a), b, stua_nil); return stu__op(stu__f[n], a, b, stua_nil); case '=': a = stu__eval(stu__f[n+2]); if (stu__flow) break; n = stu__f[n+1]; if (stu__f[n] == ST_id) { if (!stb_idict_update(stu__c, stu__const(stu__f)[stu__f[n+1]], a)) if (!stb_idict_update(stu__globaldict, stu__const(stu__f)[stu__f[n+1]], a)) return stua_error("Assignment to undefined variable"); } else if (stu__f[n] == '[') { stua_pushroot(a); b = stu__eval(stu__f[n+1]); if (stu__flow) { stua_poproot(); break; } stua_pushroot(b); c = stu__eval(stu__f[n+2]); stua_poproot(); stua_poproot(); if (stu__flow) break; if (!stu__checkt(STU___dict, b)) return stua_nil; stu__set(stu__pd(b), c, a); } else { return stu__op(stu__f[n], stu__eval(n), a, stua_nil); } return a; case STU__defaultparm: a = stu__eval(stu__f[n+2]); stu__flow = FLOW_normal; if (stb_idict_add(stu__c, stu__const(stu__f)[stu__f[n+1]], a)) stu__size_allocs += 8; return stua_nil; case ST_id: a = stu__get(stu__c, stu__const(stu__f)[stu__f[n+1]], STUA_NO_VALUE); // try local variable return a != STUA_NO_VALUE // else try stu__compile_global_scope variable ? a : stu__get(stu__globaldict, stu__const(stu__f)[stu__f[n+1]], stua_nil); case STU__negate:a = stu__eval(stu__f[n+1]); if (stu__flow) break; return stu__isint(a) ? -a : stu__op(stu__f[n], a, stua_nil, stua_nil); case '~': a = stu__eval(stu__f[n+1]); if (stu__flow) break; return stu__isint(a) ? (~a)&~3 : stu__op(stu__f[n], a, stua_nil, stua_nil); case '!': a = stu__eval(stu__f[n+1]); if (stu__flow) break; a = stu__cond(a); if (stu__flow) break; return a ? stua_true : stua_false; case ST_eq: STU__CE(==); case ST_le: STU__C(<=); case '<': STU__C(<); case ST_ne: STU__CE(!=); case ST_ge: STU__C(>=); case '>': STU__C(>); case '+' : STU__FB(+); case '*': STU__F(*); case '&': STU__I(&); case ST_shl: STU__I(<<); case '-' : STU__FB(-); case '/': STU__F(/); case '|': STU__I(|); case ST_shr: STU__I(>>); case '%': STU__I(%); case '^': STU__I(^); case ST_shru: STU__EVAL2(a,b); if (stu__tag(a) == stu__int_tag && stu__tag(b) == stu__int_tag) return stu__makeint((unsigned) stu__int(a) >> stu__int(b)); return stu__op(stu__f[n], a,b, stua_nil); case ST_and: a = stu__eval(stu__f[n+1]); b = stu__cond(a); if (stu__flow) break; return a ? stu__eval(stu__f[n+2]) : a; case ST_or : a = stu__eval(stu__f[n+1]); b = stu__cond(a); if (stu__flow) break; return a ? b : stu__eval(stu__f[n+2]); case'(':case':': STU__EVAL2(a,b); if (!stu__checkt(STU___function, a)) return stu__op(stu__f[n], a,b, stua_nil); if (!stu__checkt(STU___dict, b)) return stua_nil; if (stu__f[n] == ':') b = stu__makeobj(STU___dict, stb_idict_copy(stu__pd(b)), stb_idict_memory_usage(stu__pd(b)), 0); a = stu__funceval(a,b); return a; case '{' : { stua_dict *d; d = stb_idict_new_size(stu__f[n+1] > 40 ? 64 : 16); if (d == NULL) return stua_nil; // breakpoint fodder c = stu__makeobj(STU___dict, d, 32, 1); stua_pushroot(c); a = stu__f[n+1]; for (b=0; b < a; ++b) { stua_obj x = stua_pushroot(stu__eval(stu__f[n+2 + b*2 + 0])); stua_obj y = stu__eval(stu__f[n+2 + b*2 + 1]); stua_poproot(); if (stu__flow) { stua_poproot(); return stua_nil; } stu__set(d, x, y); } stua_poproot(); return c; } default: if (stu__f[n] < 0) return stu__const(stu__f)[stu__f[n]]; assert(0); /* NOTREACHED */ // internal error! } return stua_nil; } int stb__stua_nesting; static stua_obj stu__funceval(stua_obj fo, stua_obj co) { stu__func *f = stu__pf(fo); stua_dict *context = stu__pd(co); int i,j; stua_obj p; short *tf = stu__f; // save previous function stua_dict *tc = stu__c; if (stu__flow == FLOW_error) return stua_nil; assert(stu__flow == FLOW_normal); stua_pushroot(fo); stua_pushroot(co); stu__consider_gc(stua_nil); while ((stb_uint) f->closure_source > 4) { // add data from closure to context stua_dict *e = (stua_dict *) stu__pd(f->f.closure_data); for (i=0; i < e->limit; ++i) if (e->table[i].k != STB_IEMPTY && e->table[i].k != STB_IDEL) if (stb_idict_add(context, e->table[i].k, e->table[i].v)) stu__size_allocs += 8; // use add so if it's already defined, we don't override it; that way // explicit parameters win over applied ones, and most recent applications // win over previous ones f = stu__pf(f->closure_source); } for (j=0, i=0; i < f->num_param; ++i) // if it doesn't already exist, add it from the numbered parameters if (stb_idict_add(context, f->param[i], stu__get(context, stu__int(j), stua_nil))) ++j; // @TODO: if (stu__get(context, stu__int(f->num_param+1)) != STUA_NO_VALUE) // error: too many parameters // @TODO: ditto too few parameters if (f->closure_source == 4) p = f->f.func(context); else { stu__f = f->code, stu__c = context; stu__f_obj = co; ++stb__stua_nesting; if (stu__f[1]) p = stu__eval(stu__f[1]); else p = stua_nil; --stb__stua_nesting; stu__f = tf, stu__c = tc; // restore previous function if (stu__flow == FLOW_return) { stu__flow = FLOW_normal; p = stu__flow_val; stu__flow_val = stua_nil; } } stua_poproot(); stua_poproot(); return p; } // Parser static int stu__tok; static stua_obj stu__tokval; static char *stu__curbuf, *stu__bufstart; static stb_matcher *stu__lex_matcher; static unsigned char stu__prec[ST__max_terminals], stu__end[ST__max_terminals]; static void stu__nexttoken(void) { int len; retry: stu__tok = stb_lex(stu__lex_matcher, stu__curbuf, &len); if (stu__tok == 0) return; switch(stu__tok) { case ST_white : stu__curbuf += len; goto retry; case T__none : stu__tok = *stu__curbuf; break; case ST_string: stu__tokval = make_string(stu__curbuf+1, len-2); break; case ST_id : stu__tokval = make_string(stu__curbuf, len); break; case ST_hex : stu__tokval = stu__makeint(strtol(stu__curbuf+2,NULL,16)); stu__tok = ST_number; break; case ST_decimal: stu__tokval = stu__makeint(strtol(stu__curbuf ,NULL,10)); stu__tok = ST_number; break; case ST_float : stu__tokval = stua_float((float) atof(stu__curbuf)) ; stu__tok = ST_number; break; case ST_char : stu__tokval = stu__curbuf[2] == '\\' ? stu__curbuf[3] : stu__curbuf[2]; if (stu__curbuf[3] == 't') stu__tokval = '\t'; if (stu__curbuf[3] == 'n') stu__tokval = '\n'; if (stu__curbuf[3] == 'r') stu__tokval = '\r'; stu__tokval = stu__makeint(stu__tokval); stu__tok = ST_number; break; } stu__curbuf += len; } static struct { int stu__tok; char *regex; } stu__lexemes[] = { ST_white , "([ \t\n\r]|/\\*(.|\n)*\\*/|//[^\r\n]*([\r\n]|$))+", ST_id , "[_a-zA-Z][_a-zA-Z0-9]*", ST_hex , "0x[0-9a-fA-F]+", ST_decimal, "[0-9]+[0-9]*", ST_float , "[0-9]+\\.?[0-9]*([eE][-+]?[0-9]+)?", ST_float , "\\.[0-9]+([eE][-+]?[0-9]+)?", ST_char , "c'(\\\\.|[^\\'])'", ST_string , "\"(\\\\.|[^\\\"\n\r])*\"", ST_string , "\'(\\\\.|[^\\\'\n\r])*\'", #define stua_key4(a,b,c,d) ST_##a, #a, ST_##b, #b, ST_##c, #c, ST_##d, #d, stua_key4(if,then,else,elseif) stua_key4(while,do,for,in) stua_key4(func,var,let,break) stua_key4(nil,true,false,end) stua_key4(return,continue,as,repeat) stua_key4(_frame,catch,catch,catch) ST_shl, "<<", ST_and, "&&", ST_eq, "==", ST_ge, ">=", ST_shr, ">>", ST_or , "||", ST_ne, "!=", ST_le, "<=", ST_shru,">>>", ST_into, "=>", T__none, ".", }; typedef struct { stua_obj *data; // constants being compiled short *code; // code being compiled stua_dict *locals; short *non_local_refs; } stu__comp_func; static stu__comp_func stu__pfunc; static stu__comp_func *func_stack = NULL; static void stu__push_func_comp(void) { stb_arr_push(func_stack, stu__pfunc); stu__pfunc.data = NULL; stu__pfunc.code = NULL; stu__pfunc.locals = stb_idict_new_size(16); stu__pfunc.non_local_refs = NULL; stb_arr_push(stu__pfunc.code, 0); // number of data items stb_arr_push(stu__pfunc.code, 1); // starting execution address } static void stu__pop_func_comp(void) { stb_arr_free(stu__pfunc.code); stb_arr_free(stu__pfunc.data); stb_idict_destroy(stu__pfunc.locals); stb_arr_free(stu__pfunc.non_local_refs); stu__pfunc = stb_arr_pop(func_stack); } // if an id is a reference to an outer lexical scope, this // function returns the "name" of it, and updates the stack // structures to make sure the names are propogated in. static int stu__nonlocal_id(stua_obj var_obj) { stua_obj dummy, var = var_obj; int i, n = stb_arr_len(func_stack), j,k; if (stb_idict_get_flag(stu__pfunc.locals, var, &dummy)) return 0; for (i=n-1; i > 1; --i) { if (stb_idict_get_flag(func_stack[i].locals, var, &dummy)) break; } if (i <= 1) return 0; // stu__compile_global_scope j = i; // need to access variable from j'th frame for (i=0; i < stb_arr_len(stu__pfunc.non_local_refs); ++i) if (stu__pfunc.non_local_refs[i] == j) return j-n; stb_arr_push(stu__pfunc.non_local_refs, j-n); // now make sure all the parents propogate it down for (k=n-1; k > 1; --k) { if (j-k >= 0) return j-n; // comes direct from this parent for(i=0; i < stb_arr_len(func_stack[k].non_local_refs); ++i) if (func_stack[k].non_local_refs[i] == j-k) return j-n; stb_arr_push(func_stack[k].non_local_refs, j-k); } assert (k != 1); return j-n; } static int stu__off(void) { return stb_arr_len(stu__pfunc.code); } static void stu__cc(int a) { assert(a >= -2000 && a < 5000); stb_arr_push(stu__pfunc.code, a); } static int stu__cc1(int a) { stu__cc(a); return stu__off()-1; } static int stu__cc2(int a, int b) { stu__cc(a); stu__cc(b); return stu__off()-2; } static int stu__cc3(int a, int b, int c) { if (a == '=') assert(c != 0); stu__cc(a); stu__cc(b); stu__cc(c); return stu__off()-3; } static int stu__cc4(int a, int b, int c, int d) { stu__cc(a); stu__cc(b); stu__cc(c); stu__cc(d); return stu__off()-4; } static int stu__cdv(stua_obj p) { int i; assert(p != STUA_NO_VALUE); for (i=0; i < stb_arr_len(stu__pfunc.data); ++i) if (stu__pfunc.data[i] == p) break; if (i == stb_arr_len(stu__pfunc.data)) stb_arr_push(stu__pfunc.data, p); return ~i; } static int stu__cdt(void) { int z = stu__cdv(stu__tokval); stu__nexttoken(); return z; } static int stu__seq(int a, int b) { return !a ? b : !b ? a : stu__cc3(STU__seq, a,b); } static char stu__comp_err_str[1024]; static int stu__comp_err_line; static int stu__err(char *str, ...) { va_list v; char *s = stu__bufstart; stu__comp_err_line = 1; while (s < stu__curbuf) { if (s[0] == '\n' || s[0] == '\r') { if (s[0]+s[1] == '\n' + '\r') ++s; ++stu__comp_err_line; } ++s; } va_start(v, str); vsprintf(stu__comp_err_str, str, v); va_end(v); return 0; } static int stu__accept(int p) { if (stu__tok != p) return 0; stu__nexttoken(); return 1; } static int stu__demand(int p) { if (stu__accept(p)) return 1; return stu__err("Didn't find expected stu__tok"); } static int stu__demandv(int p, stua_obj *val) { if (stu__tok == p || p==0) { *val = stu__tokval; stu__nexttoken(); return 1; } else return 0; } static int stu__expr(int p); int stu__nexpr(int p) { stu__nexttoken(); return stu__expr(p); } static int stu__statements(int once, int as); static int stu__parse_if(void) // parse both ST_if and ST_elseif { int b,c,a; a = stu__nexpr(1); if (!a) return 0; if (!stu__demand(ST_then)) return stu__err("expecting THEN"); b = stu__statements(0,0); if (!b) return 0; if (b == 1) b = -1; if (stu__tok == ST_elseif) { return stu__parse_if(); } else if (stu__accept(ST_else)) { c = stu__statements(0,0); if (!c) return 0; if (!stu__demand(ST_end)) return stu__err("expecting END after else clause"); return stu__cc4(ST_else, a, b, c); } else { if (!stu__demand(ST_end)) return stu__err("expecting END in if statement"); return stu__cc3(ST_if, a, b); } } int stu__varinit(int z, int in_globals) { int a,b; stu__nexttoken(); while (stu__demandv(ST_id, &b)) { if (!stb_idict_add(stu__pfunc.locals, b, 1)) if (!in_globals) return stu__err("Redefined variable %s.", stu__pw(b)->ptr); if (stu__accept('=')) { a = stu__expr(1); if (!a) return 0; } else a = stu__cdv(stua_nil); z = stu__seq(z, stu__cc3(ST_var, stu__cdv(b), a)); if (!stu__accept(',')) break; } return z; } static int stu__compile_unary(int z, int outparm, int require_inparm) { int op = stu__tok, a, b; stu__nexttoken(); if (outparm) { if (require_inparm || (stu__tok && stu__tok != ST_end && stu__tok != ST_else && stu__tok != ST_elseif && stu__tok !=';')) { a = stu__expr(1); if (!a) return 0; } else a = stu__cdv(stua_nil); b = stu__cc2(op, a); } else b = stu__cc1(op); return stu__seq(z,b); } static int stu__assign(void) { int z; stu__accept(ST_let); z = stu__expr(1); if (!z) return 0; if (stu__accept('=')) { int y,p = (z >= 0 ? stu__pfunc.code[z] : 0); if (z < 0 || (p != ST_id && p != '[')) return stu__err("Invalid lvalue in assignment"); y = stu__assign(); if (!y) return 0; z = stu__cc3('=', z, y); } return z; } static int stu__statements(int once, int stop_while) { int a,b, c, z=0; for(;;) { switch (stu__tok) { case ST_if : a = stu__parse_if(); if (!a) return 0; z = stu__seq(z, a); break; case ST_while : if (stop_while) return (z ? z:1); a = stu__nexpr(1); if (!a) return 0; if (stu__accept(ST_as)) c = stu__statements(0,0); else c = 0; if (!stu__demand(ST_do)) return stu__err("expecting DO"); b = stu__statements(0,0); if (!b) return 0; if (!stu__demand(ST_end)) return stu__err("expecting END"); if (b == 1) b = -1; z = stu__seq(z, stu__cc4(ST_while, a, b, c)); break; case ST_repeat : stu__nexttoken(); c = stu__statements(0,1); if (!c) return 0; if (!stu__demand(ST_while)) return stu__err("expecting WHILE"); a = stu__expr(1); if (!a) return 0; if (!stu__demand(ST_do)) return stu__err("expecting DO"); b = stu__statements(0,0); if (!b) return 0; if (!stu__demand(ST_end)) return stu__err("expecting END"); if (b == 1) b = -1; z = stu__seq(z, stu__cc4(ST_as, a, b, c)); break; case ST_catch : a = stu__nexpr(1); if (!a) return 0; z = stu__seq(z, stu__cc2(ST_catch, a)); break; case ST_var : z = stu__varinit(z,0); break; case ST_return : z = stu__compile_unary(z,1,1); break; case ST_continue:z = stu__compile_unary(z,0,0); break; case ST_break : z = stu__compile_unary(z,1,0); break; case ST_into : if (z == 0 && !once) return stu__err("=> cannot be first statement in block"); a = stu__nexpr(99); b = (a >= 0? stu__pfunc.code[a] : 0); if (a < 0 || (b != ST_id && b != '[')) return stu__err("Invalid lvalue on right side of =>"); z = stu__cc3('=', a, z); break; default : if (stu__end[stu__tok]) return once ? 0 : (z ? z:1); a = stu__assign(); if (!a) return 0; stu__accept(';'); if (stu__tok && !stu__end[stu__tok]) { if (a < 0) return stu__err("Constant has no effect"); if (stu__pfunc.code[a] != '(' && stu__pfunc.code[a] != '=') return stu__err("Expression has no effect"); } z = stu__seq(z, a); break; } if (!z) return 0; stu__accept(';'); if (once && stu__tok != ST_into) return z; } } static int stu__postexpr(int z, int p); static int stu__dictdef(int end, int *count) { int z,n=0,i,flags=0; short *dict=NULL; stu__nexttoken(); while (stu__tok != end) { if (stu__tok == ST_id) { stua_obj id = stu__tokval; stu__nexttoken(); if (stu__tok == '=') { flags |= 1; stb_arr_push(dict, stu__cdv(id)); z = stu__nexpr(1); if (!z) return 0; } else { z = stu__cc2(ST_id, stu__cdv(id)); z = stu__postexpr(z,1); if (!z) return 0; flags |= 2; stb_arr_push(dict, stu__cdv(stu__makeint(n++))); } } else { z = stu__expr(1); if (!z) return 0; flags |= 2; stb_arr_push(dict, stu__cdv(stu__makeint(n++))); } if (end != ')' && flags == 3) { z=stu__err("can't mix initialized and uninitialized defs"); goto done;} stb_arr_push(dict, z); if (!stu__accept(',')) break; } if (!stu__demand(end)) return stu__err(end == ')' ? "Expecting ) at end of function call" : "Expecting } at end of dictionary definition"); z = stu__cc2('{', stb_arr_len(dict)/2); for (i=0; i < stb_arr_len(dict); ++i) stu__cc(dict[i]); if (count) *count = n; done: stb_arr_free(dict); return z; } static int stu__comp_id(void) { int z,d; d = stu__nonlocal_id(stu__tokval); if (d == 0) return z = stu__cc2(ST_id, stu__cdt()); // access a non-local frame by naming it with the appropriate int assert(d < 0); z = stu__cdv(d); // relative frame # is the 'variable' in our local frame z = stu__cc2(ST_id, z); // now access that dictionary return stu__cc3('[', z, stu__cdt()); // now access the variable from that dir } static stua_obj stu__funcdef(stua_obj *id, stua_obj *func); static int stu__expr(int p) { int z; // unary switch (stu__tok) { case ST_number: z = stu__cdt(); break; case ST_string: z = stu__cdt(); break; // @TODO - string concatenation like C case ST_id : z = stu__comp_id(); break; case ST__frame: z = stu__cc1(ST__frame); stu__nexttoken(); break; case ST_func : z = stu__funcdef(NULL,NULL); break; case ST_if : z = stu__parse_if(); break; case ST_nil : z = stu__cdv(stua_nil); stu__nexttoken(); break; case ST_true : z = stu__cdv(stua_true); stu__nexttoken(); break; case ST_false : z = stu__cdv(stua_false); stu__nexttoken(); break; case '-' : z = stu__nexpr(99); if (z) z=stu__cc2(STU__negate,z); else return z; break; case '!' : z = stu__nexpr(99); if (z) z=stu__cc2('!',z); else return z; break; case '~' : z = stu__nexpr(99); if (z) z=stu__cc2('~',z); else return z; break; case '{' : z = stu__dictdef('}', NULL); break; default : return stu__err("Unexpected token"); case '(' : stu__nexttoken(); z = stu__statements(0,0); if (!stu__demand(')')) return stu__err("Expecting )"); } return stu__postexpr(z,p); } static int stu__postexpr(int z, int p) { int q; // postfix while (stu__tok == '(' || stu__tok == '[' || stu__tok == '.') { if (stu__accept('.')) { // MUST be followed by a plain identifier! use [] for other stuff if (stu__tok != ST_id) return stu__err("Must follow . with plain name; try [] instead"); z = stu__cc3('[', z, stu__cdv(stu__tokval)); stu__nexttoken(); } else if (stu__accept('[')) { while (stu__tok != ']') { int r = stu__expr(1); if (!r) return 0; z = stu__cc3('[', z, r); if (!stu__accept(',')) break; } if (!stu__demand(']')) return stu__err("Expecting ]"); } else { int n, p = stu__dictdef(')', &n); if (!p) return 0; #if 0 // this is incorrect! if (z > 0 && stu__pfunc.code[z] == ST_id) { stua_obj q = stu__get(stu__globaldict, stu__pfunc.data[-stu__pfunc.code[z+1]-1], stua_nil); if (stu__checkt(STU___function, q)) if ((stu__pf(q))->num_param != n) return stu__err("Incorrect number of parameters"); } #endif z = stu__cc3('(', z, p); } } // binop - this implementation taken from lcc for (q=stu__prec[stu__tok]; q >= p; --q) { while (stu__prec[stu__tok] == q) { int o = stu__tok, y = stu__nexpr(p+1); if (!y) return 0; z = stu__cc3(o,z,y); } } return z; } static stua_obj stu__finish_func(stua_obj *param, int start) { int n, size; stu__func *f = (stu__func *) malloc(sizeof(*f)); f->closure_source = 0; f->num_param = stb_arr_len(param); f->param = (int *) stb_copy(param, f->num_param * sizeof(*f->param)); size = stb_arr_storage(stu__pfunc.code) + stb_arr_storage(stu__pfunc.data) + sizeof(*f) + 8; f->f.store = malloc(stb_arr_storage(stu__pfunc.code) + stb_arr_storage(stu__pfunc.data)); f->code = (short *) ((char *) f->f.store + stb_arr_storage(stu__pfunc.data)); memcpy(f->code, stu__pfunc.code, stb_arr_storage(stu__pfunc.code)); f->code[1] = start; f->code[0] = stb_arr_len(stu__pfunc.data); for (n=0; n < f->code[0]; ++n) ((stua_obj *) f->code)[-1-n] = stu__pfunc.data[n]; return stu__makeobj(STU___function, f, size, 0); } static int stu__funcdef(stua_obj *id, stua_obj *result) { int n,z=0,i,q; stua_obj *param = NULL; short *nonlocal; stua_obj v,f=stua_nil; assert(stu__tok == ST_func); stu__nexttoken(); if (id) { if (!stu__demandv(ST_id, id)) return stu__err("Expecting function name"); } else stu__accept(ST_id); if (!stu__demand('(')) return stu__err("Expecting ( for function parameter"); stu__push_func_comp(); while (stu__tok != ')') { if (!stu__demandv(ST_id, &v)) { z=stu__err("Expecting parameter name"); goto done; } stb_idict_add(stu__pfunc.locals, v, 1); if (stu__tok == '=') { n = stu__nexpr(1); if (!n) { z=0; goto done; } z = stu__seq(z, stu__cc3(STU__defaultparm, stu__cdv(v), n)); } else stb_arr_push(param, v); if (!stu__accept(',')) break; } if (!stu__demand(')')) { z=stu__err("Expecting ) at end of parameter list"); goto done; } n = stu__statements(0,0); if (!n) { z=0; goto done; } if (!stu__demand(ST_end)) { z=stu__err("Expecting END at end of function"); goto done; } if (n == 1) n = 0; n = stu__seq(z,n); f = stu__finish_func(param, n); if (result) { *result = f; z=1; stu__pop_func_comp(); } else { nonlocal = stu__pfunc.non_local_refs; stu__pfunc.non_local_refs = NULL; stu__pop_func_comp(); z = stu__cdv(f); if (nonlocal) { // build a closure with references to the needed frames short *initcode = NULL; for (i=0; i < stb_arr_len(nonlocal); ++i) { int k = nonlocal[i], p; stb_arr_push(initcode, stu__cdv(k)); if (k == -1) p = stu__cc1(ST__frame); else { p = stu__cdv(stu__makeint(k+1)); p = stu__cc2(ST_id, p); } stb_arr_push(initcode, p); } q = stu__cc2('{', stb_arr_len(nonlocal)); for (i=0; i < stb_arr_len(initcode); ++i) stu__cc(initcode[i]); z = stu__cc3('+', z, q); stb_arr_free(initcode); } stb_arr_free(nonlocal); } done: stb_arr_free(param); if (!z) stu__pop_func_comp(); return z; } static int stu__compile_global_scope(void) { stua_obj o; int z=0; stu__push_func_comp(); while (stu__tok != 0) { if (stu__tok == ST_func) { stua_obj id, f; if (!stu__funcdef(&id,&f)) goto error; stu__set(stu__globaldict, id, f); } else if (stu__tok == ST_var) { z = stu__varinit(z,1); if (!z) goto error; } else { int y = stu__statements(1,0); if (!y) goto error; z = stu__seq(z,y); } stu__accept(';'); } o = stu__finish_func(NULL, z); stu__pop_func_comp(); o = stu__funceval(o, stua_globals); // initialize stu__globaldict if (stu__flow == FLOW_error) printf("Error: %s\n", ((stu__wrapper *) stu__ptr(stu__flow_val))->ptr); return 1; error: stu__pop_func_comp(); return 0; } stua_obj stu__myprint(stua_dict *context) { stua_obj x = stu__get(context, stua_string("x"), stua_nil); if ((x & 1) == stu__float_tag) printf("%f", stu__getfloat(x)); else if (stu__tag(x) == stu__int_tag) printf("%d", stu__int(x)); else { stu__wrapper *s = stu__pw(x); if (s->type == STU___string || s->type == STU___error) printf("%s", s->ptr); else if (s->type == STU___dict) printf("{{dictionary}}"); else if (s->type == STU___function) printf("[[function]]"); else printf("[[ERROR:%s]]", s->ptr); } return x; } void stua_init(void) { if (!stu__globaldict) { int i; stua_obj s; stu__func *f; stu__prec[ST_and] = stu__prec[ST_or] = 1; stu__prec[ST_eq ] = stu__prec[ST_ne] = stu__prec[ST_le] = stu__prec[ST_ge] = stu__prec['>' ] = stu__prec['<'] = 2; stu__prec[':'] = 3; stu__prec['&'] = stu__prec['|'] = stu__prec['^'] = 4; stu__prec['+'] = stu__prec['-'] = 5; stu__prec['*'] = stu__prec['/'] = stu__prec['%'] = stu__prec[ST_shl]= stu__prec[ST_shr]= stu__prec[ST_shru]= 6; stu__end[')'] = stu__end[ST_end] = stu__end[ST_else] = 1; stu__end[ST_do] = stu__end[ST_elseif] = 1; stu__float_init(); stu__lex_matcher = stb_lex_matcher(); for (i=0; i < sizeof(stu__lexemes)/sizeof(stu__lexemes[0]); ++i) stb_lex_item(stu__lex_matcher, stu__lexemes[i].regex, stu__lexemes[i].stu__tok); stu__globaldict = stb_idict_new_size(64); stua_globals = stu__makeobj(STU___dict, stu__globaldict, 0,0); stu__strings = stb_sdict_new(0); stu__curbuf = stu__bufstart = "func _print(x) end\n" "func print()\n var x=0 while _frame[x] != nil as x=x+1 do _print(_frame[x]) end end\n"; stu__nexttoken(); if (!stu__compile_global_scope()) printf("Compile error in line %d: %s\n", stu__comp_err_line, stu__comp_err_str); s = stu__get(stu__globaldict, stua_string("_print"), stua_nil); if (stu__tag(s) == stu__ptr_tag && stu__ptr(s)->type == STU___function) { f = stu__pf(s); free(f->f.store); f->closure_source = 4; f->f.func = stu__myprint; f->code = NULL; } } } void stua_uninit(void) { if (stu__globaldict) { stb_idict_remove_all(stu__globaldict); stb_arr_setlen(stu__gc_root_stack, 0); stua_gc(1); stb_idict_destroy(stu__globaldict); stb_sdict_delete(stu__strings); stb_matcher_free(stu__lex_matcher); stb_arr_free(stu__gc_ptrlist); stb_arr_free(func_stack); stb_arr_free(stu__gc_root_stack); stu__globaldict = NULL; } } void stua_run_script(char *s) { stua_init(); stu__curbuf = stu__bufstart = s; stu__nexttoken(); stu__flow = FLOW_normal; if (!stu__compile_global_scope()) printf("Compile error in line %d: %s\n", stu__comp_err_line, stu__comp_err_str); stua_gc(1); } #endif // STB_DEFINE #endif // STB_STUA #undef STB_EXTERN #endif // STB_INCLUDE_STB_H /* ------------------------------------------------------------------------------ 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. ------------------------------------------------------------------------------ */ uTox/third_party/stb/stb/docs/0000700000175000001440000000000014003056224015334 5ustar rakusersuTox/third_party/stb/stb/docs/why_public_domain.md0000600000175000001440000001161714003056224021362 0ustar rakusersMy collected rationales for placing these libraries in the public domain: 1. Public domain vs. viral licenses Why is this library public domain? Because more people will use it. Because it's not viral, people are not obligated to give back, so you could argue that it hurts the development of it, and then because it doesn't develop as well it's not as good, and then because it's not as good, in the long run maybe fewer people will use it. I have total respect for that opinion, but I just don't believe it myself for most software. 2. Public domain vs. attribution-required licenses The primary difference between public domain and, say, a Creative Commons commercial / non-share-alike / attribution license is solely the requirement for attribution. (Similarly the BSD license and such.) While I would *appreciate* acknowledgement and attribution, I believe that it is foolish to place a legal encumberment (i.e. a license) on the software *solely* to get attribution. In other words, I'm arguing that PD is superior to the BSD license and the Creative Commons 'Attribution' license. If the license offers anything besides attribution -- as does, e.g., CC NonCommercial-ShareAlike, or the GPL -- that's a separate discussion. 3. Other aspects of BSD-style licenses besides attribution Permissive licenses like zlib and BSD license are perfectly reasonable in their requirements, but they are very wordy and have only two benefits over public domain: legally-mandated attribution and liability-control. I do not believe these are worth the excessive verbosity and user-unfriendliness these licenses induce, especially in the single-file case where those licenses tend to be at the top of the file, the first thing you see. To the specific points, I have had no trouble receiving attribution for my libraries; liability in the face of no explicit disclaimer of liability is an open question, but one I have a lot of difficulty imagining there being any actual doubt about in court. Sometimes I explicitly note in my libraries that I make no guarantees about them being fit for purpose, but it's pretty absurd to do this; as a whole, it comes across as "here is a library to decode vorbis audio files, but it may not actually work and if you have problems it's not my fault, but also please report bugs so I can fix them"--so dumb! 4. full discussion from stb_howto.txt on what YOU should do for YOUR libs ``` EASY-TO-COMPLY LICENSE I make my libraries public domain. You don't have to. But my goal in releasing stb-style libraries is to reduce friction for potential users as much as possible. That means: a. easy to build (what this file is mostly about) b. easy to invoke (which requires good API design) c. easy to deploy (which is about licensing) I choose to place all my libraries in the public domain, abjuring copyright, rather than license the libraries. This has some benefits and some drawbacks. Any license which is "viral" to modifications causes worries for lawyers, even if their programmers aren't modifying it. Any license which requires crediting in documentation adds friction which can add up. Valve used to have a page with a list of all of these on their web site, and it was insane, and obviously nobody ever looked at it so why would you care whether your credit appeared there? Permissive licenses like zlib and BSD license are perfectly reasonable, but they are very wordy and have only two benefits over public domain: legally-mandated attribution and liability-control. I do not believe these are worth the excessive verbosity and user-unfriendliness these licenses induce, especially in the single-file case where those licenses tend to be at the top of the file, the first thing you see. (To the specific points, I have had no trouble receiving attribution for my libraries; liability in the face of no explicit disclaimer of liability is an open question.) However, public domain has frictions of its own, because public domain declarations aren't necessary recognized in the USA and some other locations. For that reason, I recommend a declaration along these lines: // This software is dual-licensed to the public domain and under the following // license: you are granted a perpetual, irrevocable license to copy, modify, // publish, and distribute this file as you see fit. I typically place this declaration at the end of the initial comment block of the file and just say 'public domain' at the top. I have had people say they couldn't use one of my libraries because it was only "public domain" and didn't have the additional fallback clause, who asked if I could dual-license it under a traditional license. My answer: they can create a derivative work by modifying one character, and then license that however they like. (Indeed, *adding* the zlib or BSD license would be such a modification!) Unfortunately, their lawyers reportedly didn't like that answer. :( ``` uTox/third_party/stb/stb/docs/stb_voxel_render_interview.md0000600000175000001440000001605314003056224023325 0ustar rakusers# An interview with STB about stb_voxel_render.h **Q:** I suppose you really like Minecraft? **A:** Not really. I mean, I do own it and play it some, and I do watch YouTube videos of other people playing it once in a while, but I'm not saying it's that great. But I do love voxels. I've been playing with voxel rendering since the mid-late 90's when we were still doing software rendering and thinking maybe polygons weren't the answer. Once GPUs came along that kind of died off, at least until Minecraft brought it back to attention. **Q:** Do you expect people will make a lot of Minecraft clones with this? **A:** I hope not! For one thing, it's a terrible idea for the developer. Remember before Minecraft was on the Xbox 360, there were a ton of "indie" clones (some maybe making decent money even), but then the real Minecraft came out and just crushed them (as far as I know). It's just not something you really want to compete with. The reason I made this library is because I'd like to see more games with Minecraft's *art style*, not necessary its *gameplay*. I can understand the urge to clone the gameplay. When you have a world made of voxels/blocks, there are a few things that become incredibly easy to do that would otherwise be very hard (at least for an indie) to do in 3D. One thing is that procedural generation becomes much easier. Another is that destructible environments are easy. Another is that you have a world where your average user can build stuff that they find satisfactory. Minecraft is at a sort of local maximum, a sweet spot, where it leverages all of those easy-to-dos. And so I'm sure it's hard to look at the space of 'games using voxels' and move away from that local maximum, to give up some of that. But I think that's what people should do. **Q:** So what else can people do with stb_voxel_render? **A:** All of those benefits I mentioned above are still valid even if you stay away from the sweet spot. You can make a 3D roguelike without player-creation/destruction that uses procedural generation. You could make a shooter with pre-designed maps but destructible environments. And I'm sure there are other possible benefits to using voxels/blocks. Hopefully this will make it easier for people to explore the space. The library has a pretty wide range of features to allow people to come up with some distinctive looks. For example, the art style of Continue?9876543210 was one of the inspirations for trying to make the multitexturing capabilities flexible. I'm terrible at art, so this isn't really something I can come up with myself, but I tried to put in flexible technology that could be used multiple ways. One thing I did intentionally was try to make it possible to make nicer looking ground terrain, using the half-height slopes and "weird slopes". There are Minecraft mods with drivable cars and they just go up these blocky slopes and, like, what? So I wanted you to be able to make smoother terrain, either just for the look, or for vehicles etc. Also, you can spatially cross-fade between two ground textures for that classic bad dirt/grass transition that has shipped in plenty of professional games. Of course, you could just use a separate non-voxel ground renderer for all of this. But this way, you can seamlessly integrate everything else with it. E.g. in your authoring tool (or procedural generation) you can make smooth ground and then cut a sharp-edged hole in it for a building's basement or whatever. Another thing you can do is work at a very different scale. In Minecraft, a person is just under 2 blocks tall. In Ace of Spades, a person is just under 3 blocks tall. Why not 4 or 6? Well, partly because you just need a lot more voxels; if a meter is 2 voxels in Mineraft and 4 voxels in your game, and you draw the same number of voxels due to hardware limits, then your game has half the view distance of Minecraft. Since stb_voxel_render is designed to keep the meshes small and render efficiently, you can push the view distance out further than Minecraft--or use a similar view distance and a higher voxel resolution. You could also stop making infinite worlds and work at entirely different scales; where Minecraft is 1 voxel per meter, you could have 20 voxels per meter and make a small arena that's 50 meters wide and 5 meters tall. Back when the voxel game Voxatron was announced, the weekend after the trailer came out I wrote my own little GPU-accelerated version of the engine and thought that was pretty cool. I've been tempted many times to extract that and release it as a library, but I don't want to steal Voxatron's thunder so I've avoided it. You could use this engine to do the same kind of thing, although it won't be as efficient as an engine dedicated to that style of thing would be. **Q:** What one thing would you really like to see somebody do? **A:** Before Unity, 3D has seemed deeply problematic in the indie space. Software like GameMaker has tried to support 3D but it seems like little of note has been done with it. Minecraft has shown that people can build worlds with the Minecraft toolset far more easily than we've ever seen from those other tools. Obviously people have done great things with Unity, but those people are much closer to professional developers; typically they still need real 3D modelling and all of that stuff. So what I'd really like to see is someone build some kind of voxel-game-construction-set. Start with stb_voxel_render, maybe expose all the flexibility of stb_voxel_render (so people can do different things). Thrown in lua or something else for scripting, make some kind of editor that feels at least as good as Minecraft and Infinifactory, and see where that gets you. **Q:** Why'd you make this library? **A:** Mainly as a way of releasing this technology I've been working on since 2011 and seemed unlikely to ever ship myself. In 2011 I was playing the voxel shooter Ace of Spades. One of the maps that we played on was a partial port of Broville (which is the first Minecraft map in stb_voxel_render release trailer). I'd made a bunch of procedural level generators for the game, and I started trying to make a city generator inspired by Broville. But I realized it would be a lot of work, and of very little value (most of my maps didn't get much play because people preferred to play on maps where they could charge straight at the enemies and shoot them as fast as possible). So I wrote my own voxel engine and started working on a procedural city game. But I got bogged down after I finally got the road generator working and never got anywhere with building generation or gameplay. stb_voxel_render is actually a complete rewrite from scratch, but it's based a lot on what I learned from that previous work. **Q:** About the release video... how long did that take to edit? **A:** About seven or eight hours. I had the first version done in maybe six or seven hours, but then I realized I'd left out one clip, and when I went back to add it I also gussied up a couple other moments in the video. But there was something basically identical to it that was done in around six. **Q:** Ok, that's it. Thanks, me. **A:** Thanks *me!* uTox/third_party/stb/stb/docs/stb_howto.txt0000600000175000001440000001573214003056224020117 0ustar rakusersLessons learned about how to make a header-file library V1.0 September 2013 Sean Barrett Things to do in an stb-style header-file library, and rationales: 1. #define LIBRARYNAME_IMPLEMENTATION Use a symbol like the above to control creating the implementation. (I used a far-less-clear name in my first header-file library; it became clear that was a mistake once I had multiple libraries.) Include a "header-file" section with header-file guards and declarations for all the functions, but only guard the implementation with LIBRARYNAME_IMPLEMENTATION, not the header-file guard. That way, if client's header file X includes your header file for declarations, they can still include header file X in the source file that creates the implementation; if you guard the implementation too, then the first include (before the #define) creates the declarations, and the second one (after the #define) does nothing. 2. AVOID DEPENDENCIES Don't rely on anything other than the C standard libraries. (If you're creating a library specifically to leverage/wrap some other library, then obviously you can rely on that library. But if that library is public domain, you might be better off directly embedding the source, to reduce dependencies for your clients. But of course now you have to update whenever that library updates.) If you use stdlib, consider wrapping all stdlib calls in macros, and then conditionally define those macros to the stdlib function, allowing the user to replace them. For functions with side effects, like memory allocations, consider letting the user pass in a context and pass that in to the macros. (The stdlib versions will ignore the parameter.) Otherwise, users may have to use global or thread-local variables to achieve the same effect. 3. AVOID MALLOC You can't always do this, but when you can, embedded developers will appreciate it. I almost never bother avoiding, as it's too much work (and in some cases is pretty infeasible; see http://nothings.org/gamedev/font_rendering_malloc.txt ). But it's definitely something one of the things I've gotten the most pushback on from potential users. 4. ALLOW STATIC IMPLEMENTATION Have a #define which makes function declarations and function definitions static. This makes the implementation private to the source file that creates it. This allows people to use your library multiple times in their project without collision. (This is only necessary if your library has configuration macros or global state, or if your library has multiple versions that are not backwards compatible. I've run into both of those cases.) 5. MAKE ACCESSIBLE FROM C Making your code accessible from C instead of C++ (i.e. either coding in C, or using extern "C") makes it more straightforward to be used in C and in other languages, which often only have support for C bindings, not C++. (One of the earliest results I found in googling for stb_image was a Haskell wrapper.) Otherwise, people have to wrap it in another set of function calls, and the whole point here is to make it convenient for people to use, isn't it? (See below.) I prefer to code entirely in C, so the source file that instantiates the implementation can be C itself, for those crazy people out there who are programming in C. But it's probably not a big hardship for a C programmer to create a single C++ source file to instantiate your library. 6. NAMESPACE PRIVATE FUNCTIONS Try to avoid having names in your source code that will cause conflicts with identical names in client code. You can do this either by namespacing in C++, or prefixing with your library name in C. In C, generally, I use the same prefix for API functions and private symbols, such as "stbtt_" for stb_truetype; but private functions (and static globals) use a second underscore as in "stbtt__" to further minimize the chance of additional collisions in the unlikely but not impossible event that users write wrapper functions that have names of the form "stbtt_". (Consider the user that has used "stbtt_foo" *successfully*, and then upgrades to a new version of your library which has a new private function named either "stbtt_foo" or "stbtt__foo".) Note that the double-underscore is reserved for use by the compiler, but (1) there is nothing reserved for "middleware", i.e. libraries desiring to avoid conflicts with user symbols have no other good options, and (2) in practice no compilers use double-underscore in the middle rather than the beginning/end. (Unfortunately, there is at least one videogame-console compiler that will warn about double-underscores by default.) 7. EASY-TO-COMPLY LICENSE I make my libraries public domain. You don't have to. But my goal in releasing stb-style libraries is to reduce friction for potential users as much as possible. That means: a. easy to build (what this file is mostly about) b. easy to invoke (which requires good API design) c. easy to deploy (which is about licensing) I choose to place all my libraries in the public domain, abjuring copyright, rather than license the libraries. This has some benefits and some drawbacks. Any license which is "viral" to modifications causes worries for lawyers, even if their programmers aren't modifying it. Any license which requires crediting in documentation adds friction which can add up. Valve used to have a page with a list of all of these on their web site, and it was insane, and obviously nobody ever looked at it so why would you care whether your credit appeared there? Permissive licenses like zlib and BSD license are perfectly reasonable, but they are very wordy and have only two benefits over public domain: legally-mandated attribution and liability-control. I do not believe these are worth the excessive verbosity and user-unfriendliness these licenses induce, especially in the single-file case where those licenses tend to be at the top of the file, the first thing you see. (To the specific points, I have had no trouble receiving attribution for my libraries; liability in the face of no explicit disclaimer of liability is an open question.) However, public domain has frictions of its own, because public domain declarations aren't necessary recognized in the USA and some other locations. For that reason, I recommend a declaration along these lines: // This software is dual-licensed to the public domain and under the following // license: you are granted a perpetual, irrevocable license to copy, modify, // publish, and distribute this file as you see fit. I typically place this declaration at the end of the initial comment block of the file and just say 'public domain' at the top. I have had people say they couldn't use one of my libraries because it was only "public domain" and didn't have the additional fallback clause, who asked if I could dual-license it under a traditional license. My answer: they can create a derivative work by modifying one character, and then license that however they like. (Indeed, *adding* the zlib or BSD license would be such a modification!) Unfortunately, their lawyers reportedly didn't like that answer. :( uTox/third_party/stb/stb/docs/other_libs.md0000600000175000001440000000006514003056224020013 0ustar rakusersMoved to https://github.com/nothings/single_file_libsuTox/third_party/stb/stb/deprecated/0000700000175000001440000000000014003056224016504 5ustar rakusersuTox/third_party/stb/stb/deprecated/stretchy_buffer.txt0000600000175000001440000000215114003056224022444 0ustar rakusers// stretchy buffer // init: NULL // free: sbfree() // push_back: sbpush() // size: sbcount() // #define sbfree(a) ((a) ? free(stb__sbraw(a)),0 : 0) #define sbpush(a,v) (stb__sbmaybegrow(a,1), (a)[stb__sbn(a)++] = (v)) #define sbcount(a) ((a) ? stb__sbn(a) : 0) #define sbadd(a,n) (stb__sbmaybegrow(a,n), stb__sbn(a)+=(n), &(a)[stb__sbn(a)-(n)]) #define sblast(a) ((a)[stb__sbn(a)-1]) #include #define stb__sbraw(a) ((int *) (a) - 2) #define stb__sbm(a) stb__sbraw(a)[0] #define stb__sbn(a) stb__sbraw(a)[1] #define stb__sbneedgrow(a,n) ((a)==0 || stb__sbn(a)+n >= stb__sbm(a)) #define stb__sbmaybegrow(a,n) (stb__sbneedgrow(a,(n)) ? stb__sbgrow(a,n) : 0) #define stb__sbgrow(a,n) stb__sbgrowf((void **) &(a), (n), sizeof(*(a))) static void stb__sbgrowf(void **arr, int increment, int itemsize) { int m = *arr ? 2*stb__sbm(*arr)+increment : increment+1; void *p = realloc(*arr ? stb__sbraw(*arr) : 0, itemsize * m + sizeof(int)*2); assert(p); if (p) { if (!*arr) ((int *) p)[1] = 0; *arr = (void *) ((int *) p + 2); stb__sbm(*arr) = m; } } uTox/third_party/stb/stb/deprecated/stb_image.c0000600000175000001440000044275714003056224020627 0ustar rakusers/* stb_image - v1.35 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c when you control the images you're loading no warranty implied; use at your own risk QUICK NOTES: Primarily of interest to game developers and other people who can avoid problematic images and only need the trivial interface JPEG baseline (no JPEG progressive) PNG 8-bit-per-channel only TGA (not sure what subset, if a subset) BMP non-1bpp, non-RLE PSD (composited view only, no extra channels) GIF (*comp always reports as 4-channel) HDR (radiance rgbE format) PIC (Softimage PIC) - decode from memory or through FILE (define STBI_NO_STDIO to remove code) - decode from arbitrary I/O callbacks - overridable dequantizing-IDCT, YCbCr-to-RGB conversion (define STBI_SIMD) Latest revisions: 1.35 (2014-05-27) warnings, bugfixes, TGA optimization, etc 1.34 (unknown ) warning fix 1.33 (2011-07-14) minor fixes suggested by Dave Moore 1.32 (2011-07-13) info support for all filetypes (SpartanJ) 1.31 (2011-06-19) a few more leak fixes, bug in PNG handling (SpartanJ) 1.30 (2011-06-11) added ability to load files via io callbacks (Ben Wenger) 1.29 (2010-08-16) various warning fixes from Aurelien Pocheville 1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ) See end of file for full revision history. TODO: stbi_info support for BMP,PSD,HDR,PIC ============================ Contributors ========================= Image formats Bug fixes & warning fixes Sean Barrett (jpeg, png, bmp) Marc LeBlanc Nicolas Schulz (hdr, psd) Christpher Lloyd Jonathan Dummer (tga) Dave Moore Jean-Marc Lienher (gif) Won Chun Tom Seddon (pic) the Horde3D community Thatcher Ulrich (psd) Janez Zemva Jonathan Blow Laurent Gomila Extensions, features Aruelien Pocheville Jetro Lauha (stbi_info) Ryamond Barbiero James "moose2000" Brown (iPhone PNG) David Woo Ben "Disch" Wenger (io callbacks) Roy Eltham Martin "SpartanJ" Golini Luke Graham Thomas Ruf John Bartholomew Optimizations & bugfixes Ken Hamada Fabian "ryg" Giesen Cort Stratton Arseny Kapoulkine Blazej Dariusz Roszkowski Thibault Reuille If your name should be here but Paul Du Bois isn't let Sean know. Guillaume George */ #ifndef STBI_INCLUDE_STB_IMAGE_H #define STBI_INCLUDE_STB_IMAGE_H // To get a header file for this, either cut and paste the header, // or create stb_image.h, #define STBI_HEADER_FILE_ONLY, and // then include stb_image.c from it. //// begin header file //////////////////////////////////////////////////// // // Limitations: // - no jpeg progressive support // - non-HDR formats support 8-bit samples only (jpeg, png) // - no delayed line count (jpeg) -- IJG doesn't support either // - no 1-bit BMP // - GIF always returns *comp=4 // // Basic usage (see HDR discussion below): // int x,y,n; // unsigned char *data = stbi_load(filename, &x, &y, &n, 0); // // ... process data if not NULL ... // // ... x = width, y = height, n = # 8-bit components per pixel ... // // ... replace '0' with '1'..'4' to force that many components per pixel // // ... but 'n' will always be the number that it would have been if you said 0 // stbi_image_free(data) // // Standard parameters: // int *x -- outputs image width in pixels // int *y -- outputs image height in pixels // int *comp -- outputs # of image components in image file // int req_comp -- if non-zero, # of image components requested in result // // The return value from an image loader is an 'unsigned char *' which points // to the pixel data. The pixel data consists of *y scanlines of *x pixels, // with each pixel consisting of N interleaved 8-bit components; the first // pixel pointed to is top-left-most in the image. There is no padding between // image scanlines or between pixels, regardless of format. The number of // components N is 'req_comp' if req_comp is non-zero, or *comp otherwise. // If req_comp is non-zero, *comp has the number of components that _would_ // have been output otherwise. E.g. if you set req_comp to 4, you will always // get RGBA output, but you can check *comp to easily see if it's opaque. // // An output image with N components has the following components interleaved // in this order in each pixel: // // N=#comp components // 1 grey // 2 grey, alpha // 3 red, green, blue // 4 red, green, blue, alpha // // If image loading fails for any reason, the return value will be NULL, // and *x, *y, *comp will be unchanged. The function stbi_failure_reason() // can be queried for an extremely brief, end-user unfriendly explanation // of why the load failed. Define STBI_NO_FAILURE_STRINGS to avoid // compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly // more user-friendly ones. // // Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. // // =========================================================================== // // iPhone PNG support: // // By default we convert iphone-formatted PNGs back to RGB; nominally they // would silently load as BGR, except the existing code should have just // failed on such iPhone PNGs. But you can disable this conversion by // by calling stbi_convert_iphone_png_to_rgb(0), in which case // you will always just get the native iphone "format" through. // // Call stbi_set_unpremultiply_on_load(1) as well to force a divide per // pixel to remove any premultiplied alpha *only* if the image file explicitly // says there's premultiplied data (currently only happens in iPhone images, // and only if iPhone convert-to-rgb processing is on). // // =========================================================================== // // HDR image support (disable by defining STBI_NO_HDR) // // stb_image now supports loading HDR images in general, and currently // the Radiance .HDR file format, although the support is provided // generically. You can still load any file through the existing interface; // if you attempt to load an HDR file, it will be automatically remapped to // LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; // both of these constants can be reconfigured through this interface: // // stbi_hdr_to_ldr_gamma(2.2f); // stbi_hdr_to_ldr_scale(1.0f); // // (note, do not use _inverse_ constants; stbi_image will invert them // appropriately). // // Additionally, there is a new, parallel interface for loading files as // (linear) floats to preserve the full dynamic range: // // float *data = stbi_loadf(filename, &x, &y, &n, 0); // // If you load LDR images through this interface, those images will // be promoted to floating point values, run through the inverse of // constants corresponding to the above: // // stbi_ldr_to_hdr_scale(1.0f); // stbi_ldr_to_hdr_gamma(2.2f); // // Finally, given a filename (or an open file or memory block--see header // file for details) containing image data, you can query for the "most // appropriate" interface to use (that is, whether the image is HDR or // not), using: // // stbi_is_hdr(char *filename); // // =========================================================================== // // I/O callbacks // // I/O callbacks allow you to read from arbitrary sources, like packaged // files or some other source. Data read from callbacks are processed // through a small internal buffer (currently 128 bytes) to try to reduce // overhead. // // The three functions you must define are "read" (reads some bytes of data), // "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). #ifndef STBI_NO_STDIO #if defined(_MSC_VER) && _MSC_VER >= 1400 #define _CRT_SECURE_NO_WARNINGS // suppress warnings about fopen() #pragma warning(push) #pragma warning(disable:4996) // suppress even more warnings about fopen() #endif #include #endif // STBI_NO_STDIO #define STBI_VERSION 1 enum { STBI_default = 0, // only used for req_comp STBI_grey = 1, STBI_grey_alpha = 2, STBI_rgb = 3, STBI_rgb_alpha = 4 }; typedef unsigned char stbi_uc; #ifdef __cplusplus extern "C" { #endif ////////////////////////////////////////////////////////////////////////////// // // PRIMARY API - works on images of any type // // // load image by filename, open file, or memory buffer // extern stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); #ifndef STBI_NO_STDIO extern stbi_uc *stbi_load (char const *filename, int *x, int *y, int *comp, int req_comp); extern stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); // for stbi_load_from_file, file pointer is left pointing immediately after image #endif typedef struct { int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative int (*eof) (void *user); // returns nonzero if we are at end of file/data } stbi_io_callbacks; extern stbi_uc *stbi_load_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp); #ifndef STBI_NO_HDR extern float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); #ifndef STBI_NO_STDIO extern float *stbi_loadf (char const *filename, int *x, int *y, int *comp, int req_comp); extern float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); #endif extern float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp); extern void stbi_hdr_to_ldr_gamma(float gamma); extern void stbi_hdr_to_ldr_scale(float scale); extern void stbi_ldr_to_hdr_gamma(float gamma); extern void stbi_ldr_to_hdr_scale(float scale); #endif // STBI_NO_HDR // stbi_is_hdr is always defined extern int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); extern int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); #ifndef STBI_NO_STDIO extern int stbi_is_hdr (char const *filename); extern int stbi_is_hdr_from_file(FILE *f); #endif // STBI_NO_STDIO // get a VERY brief reason for failure // NOT THREADSAFE extern const char *stbi_failure_reason (void); // free the loaded image -- this is just free() extern void stbi_image_free (void *retval_from_stbi_load); // get image dimensions & components without fully decoding extern int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); extern int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); #ifndef STBI_NO_STDIO extern int stbi_info (char const *filename, int *x, int *y, int *comp); extern int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); #endif // for image formats that explicitly notate that they have premultiplied alpha, // we just return the colors as stored in the file. set this flag to force // unpremultiplication. results are undefined if the unpremultiply overflow. extern void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); // indicate whether we should process iphone images back to canonical format, // or just pass them through "as-is" extern void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); // ZLIB client - used by PNG, available for other purposes extern char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); extern char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); extern char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); extern int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); extern char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); extern int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); // define faster low-level operations (typically SIMD support) #ifdef STBI_SIMD typedef void (*stbi_idct_8x8)(stbi_uc *out, int out_stride, short data[64], unsigned short *dequantize); // compute an integer IDCT on "input" // input[x] = data[x] * dequantize[x] // write results to 'out': 64 samples, each run of 8 spaced by 'out_stride' // CLAMP results to 0..255 typedef void (*stbi_YCbCr_to_RGB_run)(stbi_uc *output, stbi_uc const *y, stbi_uc const *cb, stbi_uc const *cr, int count, int step); // compute a conversion from YCbCr to RGB // 'count' pixels // write pixels to 'output'; each pixel is 'step' bytes (either 3 or 4; if 4, write '255' as 4th), order R,G,B // y: Y input channel // cb: Cb input channel; scale/biased to be 0..255 // cr: Cr input channel; scale/biased to be 0..255 extern void stbi_install_idct(stbi_idct_8x8 func); extern void stbi_install_YCbCr_to_RGB(stbi_YCbCr_to_RGB_run func); #endif // STBI_SIMD #ifdef __cplusplus } #endif // // //// end header file ///////////////////////////////////////////////////// #endif // STBI_INCLUDE_STB_IMAGE_H #ifndef STBI_HEADER_FILE_ONLY #ifndef STBI_NO_HDR #include // ldexp #include // strcmp, strtok #endif #ifndef STBI_NO_STDIO #include #endif #include #include #include #include #include // ptrdiff_t on osx #ifndef _MSC_VER #ifdef __cplusplus #define stbi_inline inline #else #define stbi_inline #endif #else #define stbi_inline __forceinline #endif #ifdef _MSC_VER typedef unsigned char stbi__uint8; typedef unsigned short stbi__uint16; typedef signed short stbi__int16; typedef unsigned int stbi__uint32; typedef signed int stbi__int32; #else #include typedef uint8_t stbi__uint8; typedef uint16_t stbi__uint16; typedef int16_t stbi__int16; typedef uint32_t stbi__uint32; typedef int32_t stbi__int32; #endif // should produce compiler error if size is wrong typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; #ifdef _MSC_VER #define STBI_NOTUSED(v) (void)(v) #else #define STBI_NOTUSED(v) (void)sizeof(v) #endif #ifdef _MSC_VER #define STBI_HAS_LROTL #endif #ifdef STBI_HAS_LROTL #define stbi_lrot(x,y) _lrotl(x,y) #else #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) #endif /////////////////////////////////////////////// // // stbi struct and start_xxx functions // stbi structure is our basic context used by all images, so it // contains all the IO context, plus some basic image information typedef struct { stbi__uint32 img_x, img_y; int img_n, img_out_n; stbi_io_callbacks io; void *io_user_data; int read_from_callbacks; int buflen; stbi__uint8 buffer_start[128]; stbi__uint8 *img_buffer, *img_buffer_end; stbi__uint8 *img_buffer_original; } stbi; static void refill_buffer(stbi *s); // initialize a memory-decode context static void start_mem(stbi *s, stbi__uint8 const *buffer, int len) { s->io.read = NULL; s->read_from_callbacks = 0; s->img_buffer = s->img_buffer_original = (stbi__uint8 *) buffer; s->img_buffer_end = (stbi__uint8 *) buffer+len; } // initialize a callback-based context static void start_callbacks(stbi *s, stbi_io_callbacks *c, void *user) { s->io = *c; s->io_user_data = user; s->buflen = sizeof(s->buffer_start); s->read_from_callbacks = 1; s->img_buffer_original = s->buffer_start; refill_buffer(s); } #ifndef STBI_NO_STDIO static int stdio_read(void *user, char *data, int size) { return (int) fread(data,1,size,(FILE*) user); } static void stdio_skip(void *user, int n) { fseek((FILE*) user, n, SEEK_CUR); } static int stdio_eof(void *user) { return feof((FILE*) user); } static stbi_io_callbacks stbi_stdio_callbacks = { stdio_read, stdio_skip, stdio_eof, }; static void start_file(stbi *s, FILE *f) { start_callbacks(s, &stbi_stdio_callbacks, (void *) f); } //static void stop_file(stbi *s) { } #endif // !STBI_NO_STDIO static void stbi_rewind(stbi *s) { // conceptually rewind SHOULD rewind to the beginning of the stream, // but we just rewind to the beginning of the initial buffer, because // we only use it after doing 'test', which only ever looks at at most 92 bytes s->img_buffer = s->img_buffer_original; } static int stbi_jpeg_test(stbi *s); static stbi_uc *stbi_jpeg_load(stbi *s, int *x, int *y, int *comp, int req_comp); static int stbi_jpeg_info(stbi *s, int *x, int *y, int *comp); static int stbi_png_test(stbi *s); static stbi_uc *stbi_png_load(stbi *s, int *x, int *y, int *comp, int req_comp); static int stbi_png_info(stbi *s, int *x, int *y, int *comp); static int stbi_bmp_test(stbi *s); static stbi_uc *stbi_bmp_load(stbi *s, int *x, int *y, int *comp, int req_comp); static int stbi_tga_test(stbi *s); static stbi_uc *stbi_tga_load(stbi *s, int *x, int *y, int *comp, int req_comp); static int stbi_tga_info(stbi *s, int *x, int *y, int *comp); static int stbi_psd_test(stbi *s); static stbi_uc *stbi_psd_load(stbi *s, int *x, int *y, int *comp, int req_comp); #ifndef STBI_NO_HDR static int stbi_hdr_test(stbi *s); static float *stbi_hdr_load(stbi *s, int *x, int *y, int *comp, int req_comp); #endif static int stbi_pic_test(stbi *s); static stbi_uc *stbi_pic_load(stbi *s, int *x, int *y, int *comp, int req_comp); static int stbi_gif_test(stbi *s); static stbi_uc *stbi_gif_load(stbi *s, int *x, int *y, int *comp, int req_comp); static int stbi_gif_info(stbi *s, int *x, int *y, int *comp); // this is not threadsafe static const char *failure_reason; const char *stbi_failure_reason(void) { return failure_reason; } static int e(const char *str) { failure_reason = str; return 0; } // e - error // epf - error returning pointer to float // epuc - error returning pointer to unsigned char #ifdef STBI_NO_FAILURE_STRINGS #define e(x,y) 0 #elif defined(STBI_FAILURE_USERMSG) #define e(x,y) e(y) #else #define e(x,y) e(x) #endif #define epf(x,y) ((float *) (e(x,y)?NULL:NULL)) #define epuc(x,y) ((unsigned char *) (e(x,y)?NULL:NULL)) void stbi_image_free(void *retval_from_stbi_load) { free(retval_from_stbi_load); } #ifndef STBI_NO_HDR static float *ldr_to_hdr(stbi_uc *data, int x, int y, int comp); static stbi_uc *hdr_to_ldr(float *data, int x, int y, int comp); #endif static unsigned char *stbi_load_main(stbi *s, int *x, int *y, int *comp, int req_comp) { if (stbi_jpeg_test(s)) return stbi_jpeg_load(s,x,y,comp,req_comp); if (stbi_png_test(s)) return stbi_png_load(s,x,y,comp,req_comp); if (stbi_bmp_test(s)) return stbi_bmp_load(s,x,y,comp,req_comp); if (stbi_gif_test(s)) return stbi_gif_load(s,x,y,comp,req_comp); if (stbi_psd_test(s)) return stbi_psd_load(s,x,y,comp,req_comp); if (stbi_pic_test(s)) return stbi_pic_load(s,x,y,comp,req_comp); #ifndef STBI_NO_HDR if (stbi_hdr_test(s)) { float *hdr = stbi_hdr_load(s, x,y,comp,req_comp); return hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); } #endif // test tga last because it's a crappy test! if (stbi_tga_test(s)) return stbi_tga_load(s,x,y,comp,req_comp); return epuc("unknown image type", "Image not of any known type, or corrupt"); } #ifndef STBI_NO_STDIO unsigned char *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) { FILE *f = fopen(filename, "rb"); unsigned char *result; if (!f) return epuc("can't fopen", "Unable to open file"); result = stbi_load_from_file(f,x,y,comp,req_comp); fclose(f); return result; } unsigned char *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { unsigned char *result; stbi s; start_file(&s,f); result = stbi_load_main(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); } return result; } #endif //!STBI_NO_STDIO unsigned char *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi s; start_mem(&s,buffer,len); return stbi_load_main(&s,x,y,comp,req_comp); } unsigned char *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi s; start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi_load_main(&s,x,y,comp,req_comp); } #ifndef STBI_NO_HDR float *stbi_loadf_main(stbi *s, int *x, int *y, int *comp, int req_comp) { unsigned char *data; #ifndef STBI_NO_HDR if (stbi_hdr_test(s)) return stbi_hdr_load(s,x,y,comp,req_comp); #endif data = stbi_load_main(s, x, y, comp, req_comp); if (data) return ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); return epf("unknown image type", "Image not of any known type, or corrupt"); } float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi s; start_mem(&s,buffer,len); return stbi_loadf_main(&s,x,y,comp,req_comp); } float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi s; start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi_loadf_main(&s,x,y,comp,req_comp); } #ifndef STBI_NO_STDIO float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) { FILE *f = fopen(filename, "rb"); float *result; if (!f) return epf("can't fopen", "Unable to open file"); result = stbi_loadf_from_file(f,x,y,comp,req_comp); fclose(f); return result; } float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { stbi s; start_file(&s,f); return stbi_loadf_main(&s,x,y,comp,req_comp); } #endif // !STBI_NO_STDIO #endif // !STBI_NO_HDR // these is-hdr-or-not is defined independent of whether STBI_NO_HDR is // defined, for API simplicity; if STBI_NO_HDR is defined, it always // reports false! int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) { #ifndef STBI_NO_HDR stbi s; start_mem(&s,buffer,len); return stbi_hdr_test(&s); #else STBI_NOTUSED(buffer); STBI_NOTUSED(len); return 0; #endif } #ifndef STBI_NO_STDIO extern int stbi_is_hdr (char const *filename) { FILE *f = fopen(filename, "rb"); int result=0; if (f) { result = stbi_is_hdr_from_file(f); fclose(f); } return result; } extern int stbi_is_hdr_from_file(FILE *f) { #ifndef STBI_NO_HDR stbi s; start_file(&s,f); return stbi_hdr_test(&s); #else return 0; #endif } #endif // !STBI_NO_STDIO extern int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) { #ifndef STBI_NO_HDR stbi s; start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi_hdr_test(&s); #else return 0; #endif } #ifndef STBI_NO_HDR static float h2l_gamma_i=1.0f/2.2f, h2l_scale_i=1.0f; static float l2h_gamma=2.2f, l2h_scale=1.0f; void stbi_hdr_to_ldr_gamma(float gamma) { h2l_gamma_i = 1/gamma; } void stbi_hdr_to_ldr_scale(float scale) { h2l_scale_i = 1/scale; } void stbi_ldr_to_hdr_gamma(float gamma) { l2h_gamma = gamma; } void stbi_ldr_to_hdr_scale(float scale) { l2h_scale = scale; } #endif ////////////////////////////////////////////////////////////////////////////// // // Common code used by all image loaders // enum { SCAN_load=0, SCAN_type, SCAN_header }; static void refill_buffer(stbi *s) { int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); if (n == 0) { // at end of file, treat same as if from memory, but need to handle case // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file s->read_from_callbacks = 0; s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start+1; *s->img_buffer = 0; } else { s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start + n; } } stbi_inline static int get8(stbi *s) { if (s->img_buffer < s->img_buffer_end) return *s->img_buffer++; if (s->read_from_callbacks) { refill_buffer(s); return *s->img_buffer++; } return 0; } stbi_inline static int at_eof(stbi *s) { if (s->io.read) { if (!(s->io.eof)(s->io_user_data)) return 0; // if feof() is true, check if buffer = end // special case: we've only got the special 0 character at the end if (s->read_from_callbacks == 0) return 1; } return s->img_buffer >= s->img_buffer_end; } stbi_inline static stbi__uint8 get8u(stbi *s) { return (stbi__uint8) get8(s); } static void skip(stbi *s, int n) { if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { s->img_buffer = s->img_buffer_end; (s->io.skip)(s->io_user_data, n - blen); return; } } s->img_buffer += n; } static int getn(stbi *s, stbi_uc *buffer, int n) { if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { int res, count; memcpy(buffer, s->img_buffer, blen); count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); res = (count == (n-blen)); s->img_buffer = s->img_buffer_end; return res; } } if (s->img_buffer+n <= s->img_buffer_end) { memcpy(buffer, s->img_buffer, n); s->img_buffer += n; return 1; } else return 0; } static int get16(stbi *s) { int z = get8(s); return (z << 8) + get8(s); } static stbi__uint32 get32(stbi *s) { stbi__uint32 z = get16(s); return (z << 16) + get16(s); } static int get16le(stbi *s) { int z = get8(s); return z + (get8(s) << 8); } static stbi__uint32 get32le(stbi *s) { stbi__uint32 z = get16le(s); return z + (get16le(s) << 16); } ////////////////////////////////////////////////////////////////////////////// // // generic converter from built-in img_n to req_comp // individual types do this automatically as much as possible (e.g. jpeg // does all cases internally since it needs to colorspace convert anyway, // and it never has alpha, so very few cases ). png can automatically // interleave an alpha=255 channel, but falls back to this for other cases // // assume data buffer is malloced, so malloc a new one and free that one // only failure mode is malloc failing static stbi__uint8 compute_y(int r, int g, int b) { return (stbi__uint8) (((r*77) + (g*150) + (29*b)) >> 8); } static unsigned char *convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) { int i,j; unsigned char *good; if (req_comp == img_n) return data; assert(req_comp >= 1 && req_comp <= 4); good = (unsigned char *) malloc(req_comp * x * y); if (good == NULL) { free(data); return epuc("outofmem", "Out of memory"); } for (j=0; j < (int) y; ++j) { unsigned char *src = data + j * x * img_n ; unsigned char *dest = good + j * x * req_comp; #define COMBO(a,b) ((a)*8+(b)) #define CASE(a,b) case COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) // convert source image with img_n components to one with req_comp components; // avoid switch per pixel, so use switch per scanline and massive macros switch (COMBO(img_n, req_comp)) { CASE(1,2) dest[0]=src[0], dest[1]=255; break; CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; break; CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; break; CASE(2,1) dest[0]=src[0]; break; CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; break; CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; break; CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; break; CASE(3,1) dest[0]=compute_y(src[0],src[1],src[2]); break; CASE(3,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = 255; break; CASE(4,1) dest[0]=compute_y(src[0],src[1],src[2]); break; CASE(4,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = src[3]; break; CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; break; default: assert(0); } #undef CASE } free(data); return good; } #ifndef STBI_NO_HDR static float *ldr_to_hdr(stbi_uc *data, int x, int y, int comp) { int i,k,n; float *output = (float *) malloc(x * y * comp * sizeof(float)); if (output == NULL) { free(data); return epf("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { output[i*comp + k] = (float) pow(data[i*comp+k]/255.0f, l2h_gamma) * l2h_scale; } if (k < comp) output[i*comp + k] = data[i*comp+k]/255.0f; } free(data); return output; } #define float2int(x) ((int) (x)) static stbi_uc *hdr_to_ldr(float *data, int x, int y, int comp) { int i,k,n; stbi_uc *output = (stbi_uc *) malloc(x * y * comp); if (output == NULL) { free(data); return epuc("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { float z = (float) pow(data[i*comp+k]*h2l_scale_i, h2l_gamma_i) * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi__uint8) float2int(z); } if (k < comp) { float z = data[i*comp+k] * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi__uint8) float2int(z); } } free(data); return output; } #endif ////////////////////////////////////////////////////////////////////////////// // // "baseline" JPEG/JFIF decoder (not actually fully baseline implementation) // // simple implementation // - channel subsampling of at most 2 in each dimension // - doesn't support delayed output of y-dimension // - simple interface (only one output format: 8-bit interleaved RGB) // - doesn't try to recover corrupt jpegs // - doesn't allow partial loading, loading multiple at once // - still fast on x86 (copying globals into locals doesn't help x86) // - allocates lots of intermediate memory (full size of all components) // - non-interleaved case requires this anyway // - allows good upsampling (see next) // high-quality // - upsampled channels are bilinearly interpolated, even across blocks // - quality integer IDCT derived from IJG's 'slow' // performance // - fast huffman; reasonable integer IDCT // - uses a lot of intermediate memory, could cache poorly // - load http://nothings.org/remote/anemones.jpg 3 times on 2.8Ghz P4 // stb_jpeg: 1.34 seconds (MSVC6, default release build) // stb_jpeg: 1.06 seconds (MSVC6, processor = Pentium Pro) // IJL11.dll: 1.08 seconds (compiled by intel) // IJG 1998: 0.98 seconds (MSVC6, makefile provided by IJG) // IJG 1998: 0.95 seconds (MSVC6, makefile + proc=PPro) // huffman decoding acceleration #define FAST_BITS 9 // larger handles more cases; smaller stomps less cache typedef struct { stbi__uint8 fast[1 << FAST_BITS]; // weirdly, repacking this into AoS is a 10% speed loss, instead of a win stbi__uint16 code[256]; stbi__uint8 values[256]; stbi__uint8 size[257]; unsigned int maxcode[18]; int delta[17]; // old 'firstsymbol' - old 'firstcode' } huffman; typedef struct { #ifdef STBI_SIMD unsigned short dequant2[4][64]; #endif stbi *s; huffman huff_dc[4]; huffman huff_ac[4]; stbi__uint8 dequant[4][64]; // sizes for components, interleaved MCUs int img_h_max, img_v_max; int img_mcu_x, img_mcu_y; int img_mcu_w, img_mcu_h; // definition of jpeg image component struct { int id; int h,v; int tq; int hd,ha; int dc_pred; int x,y,w2,h2; stbi__uint8 *data; void *raw_data; stbi__uint8 *linebuf; } img_comp[4]; stbi__uint32 code_buffer; // jpeg entropy-coded buffer int code_bits; // number of valid bits unsigned char marker; // marker seen while filling entropy buffer int nomore; // flag if we saw a marker so must stop int scan_n, order[4]; int restart_interval, todo; } jpeg; static int build_huffman(huffman *h, int *count) { int i,j,k=0,code; // build size list for each symbol (from JPEG spec) for (i=0; i < 16; ++i) for (j=0; j < count[i]; ++j) h->size[k++] = (stbi__uint8) (i+1); h->size[k] = 0; // compute actual symbols (from jpeg spec) code = 0; k = 0; for(j=1; j <= 16; ++j) { // compute delta to add to code to compute symbol id h->delta[j] = k - code; if (h->size[k] == j) { while (h->size[k] == j) h->code[k++] = (stbi__uint16) (code++); if (code-1 >= (1 << j)) return e("bad code lengths","Corrupt JPEG"); } // compute largest code + 1 for this size, preshifted as needed later h->maxcode[j] = code << (16-j); code <<= 1; } h->maxcode[j] = 0xffffffff; // build non-spec acceleration table; 255 is flag for not-accelerated memset(h->fast, 255, 1 << FAST_BITS); for (i=0; i < k; ++i) { int s = h->size[i]; if (s <= FAST_BITS) { int c = h->code[i] << (FAST_BITS-s); int m = 1 << (FAST_BITS-s); for (j=0; j < m; ++j) { h->fast[c+j] = (stbi__uint8) i; } } } return 1; } static void grow_buffer_unsafe(jpeg *j) { do { int b = j->nomore ? 0 : get8(j->s); if (b == 0xff) { int c = get8(j->s); if (c != 0) { j->marker = (unsigned char) c; j->nomore = 1; return; } } j->code_buffer |= b << (24 - j->code_bits); j->code_bits += 8; } while (j->code_bits <= 24); } // (1 << n) - 1 static stbi__uint32 bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; // decode a jpeg huffman value from the bitstream stbi_inline static int decode(jpeg *j, huffman *h) { unsigned int temp; int c,k; if (j->code_bits < 16) grow_buffer_unsafe(j); // look at the top FAST_BITS and determine what symbol ID it is, // if the code is <= FAST_BITS c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); k = h->fast[c]; if (k < 255) { int s = h->size[k]; if (s > j->code_bits) return -1; j->code_buffer <<= s; j->code_bits -= s; return h->values[k]; } // naive test is to shift the code_buffer down so k bits are // valid, then test against maxcode. To speed this up, we've // preshifted maxcode left so that it has (16-k) 0s at the // end; in other words, regardless of the number of bits, it // wants to be compared against something shifted to have 16; // that way we don't need to shift inside the loop. temp = j->code_buffer >> 16; for (k=FAST_BITS+1 ; ; ++k) if (temp < h->maxcode[k]) break; if (k == 17) { // error! code not found j->code_bits -= 16; return -1; } if (k > j->code_bits) return -1; // convert the huffman code to the symbol id c = ((j->code_buffer >> (32 - k)) & bmask[k]) + h->delta[k]; assert((((j->code_buffer) >> (32 - h->size[c])) & bmask[h->size[c]]) == h->code[c]); // convert the id to a symbol j->code_bits -= k; j->code_buffer <<= k; return h->values[c]; } // combined JPEG 'receive' and JPEG 'extend', since baseline // always extends everything it receives. stbi_inline static int extend_receive(jpeg *j, int n) { unsigned int m = 1 << (n-1); unsigned int k; if (j->code_bits < n) grow_buffer_unsafe(j); #if 1 k = stbi_lrot(j->code_buffer, n); j->code_buffer = k & ~bmask[n]; k &= bmask[n]; j->code_bits -= n; #else k = (j->code_buffer >> (32 - n)) & bmask[n]; j->code_bits -= n; j->code_buffer <<= n; #endif // the following test is probably a random branch that won't // predict well. I tried to table accelerate it but failed. // maybe it's compiling as a conditional move? if (k < m) return (-1 << n) + k + 1; else return k; } // given a value that's at position X in the zigzag stream, // where does it appear in the 8x8 matrix coded as row-major? static stbi__uint8 dezigzag[64+15] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, // let corrupt input sample past end 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 }; // decode one 64-entry block-- static int decode_block(jpeg *j, short data[64], huffman *hdc, huffman *hac, int b) { int diff,dc,k; int t = decode(j, hdc); if (t < 0) return e("bad huffman code","Corrupt JPEG"); // 0 all the ac values now so we can do it 32-bits at a time memset(data,0,64*sizeof(data[0])); diff = t ? extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; data[0] = (short) dc; // decode AC components, see JPEG spec k = 1; do { int r,s; int rs = decode(j, hac); if (rs < 0) return e("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (rs != 0xf0) break; // end block k += 16; } else { k += r; // decode into unzigzag'd location data[dezigzag[k++]] = (short) extend_receive(j,s); } } while (k < 64); return 1; } // take a -128..127 value and clamp it and convert to 0..255 stbi_inline static stbi__uint8 clamp(int x) { // trick to use a single test to catch both cases if ((unsigned int) x > 255) { if (x < 0) return 0; if (x > 255) return 255; } return (stbi__uint8) x; } #define f2f(x) (int) (((x) * 4096 + 0.5)) #define fsh(x) ((x) << 12) // derived from jidctint -- DCT_ISLOW #define IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ p2 = s2; \ p3 = s6; \ p1 = (p2+p3) * f2f(0.5411961f); \ t2 = p1 + p3*f2f(-1.847759065f); \ t3 = p1 + p2*f2f( 0.765366865f); \ p2 = s0; \ p3 = s4; \ t0 = fsh(p2+p3); \ t1 = fsh(p2-p3); \ x0 = t0+t3; \ x3 = t0-t3; \ x1 = t1+t2; \ x2 = t1-t2; \ t0 = s7; \ t1 = s5; \ t2 = s3; \ t3 = s1; \ p3 = t0+t2; \ p4 = t1+t3; \ p1 = t0+t3; \ p2 = t1+t2; \ p5 = (p3+p4)*f2f( 1.175875602f); \ t0 = t0*f2f( 0.298631336f); \ t1 = t1*f2f( 2.053119869f); \ t2 = t2*f2f( 3.072711026f); \ t3 = t3*f2f( 1.501321110f); \ p1 = p5 + p1*f2f(-0.899976223f); \ p2 = p5 + p2*f2f(-2.562915447f); \ p3 = p3*f2f(-1.961570560f); \ p4 = p4*f2f(-0.390180644f); \ t3 += p1+p4; \ t2 += p2+p3; \ t1 += p2+p4; \ t0 += p1+p3; #ifdef STBI_SIMD typedef unsigned short stbi_dequantize_t; #else typedef stbi__uint8 stbi_dequantize_t; #endif // .344 seconds on 3*anemones.jpg static void idct_block(stbi__uint8 *out, int out_stride, short data[64], stbi_dequantize_t *dequantize) { int i,val[64],*v=val; stbi_dequantize_t *dq = dequantize; stbi__uint8 *o; short *d = data; // columns for (i=0; i < 8; ++i,++d,++dq, ++v) { // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 && d[40]==0 && d[48]==0 && d[56]==0) { // no shortcut 0 seconds // (1|2|3|4|5|6|7)==0 0 seconds // all separate -0.047 seconds // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds int dcterm = d[0] * dq[0] << 2; v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; } else { IDCT_1D(d[ 0]*dq[ 0],d[ 8]*dq[ 8],d[16]*dq[16],d[24]*dq[24], d[32]*dq[32],d[40]*dq[40],d[48]*dq[48],d[56]*dq[56]) // constants scaled things up by 1<<12; let's bring them back // down, but keep 2 extra bits of precision x0 += 512; x1 += 512; x2 += 512; x3 += 512; v[ 0] = (x0+t3) >> 10; v[56] = (x0-t3) >> 10; v[ 8] = (x1+t2) >> 10; v[48] = (x1-t2) >> 10; v[16] = (x2+t1) >> 10; v[40] = (x2-t1) >> 10; v[24] = (x3+t0) >> 10; v[32] = (x3-t0) >> 10; } } for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { // no fast case since the first 1D IDCT spread components out IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) // constants scaled things up by 1<<12, plus we had 1<<2 from first // loop, plus horizontal and vertical each scale by sqrt(8) so together // we've got an extra 1<<3, so 1<<17 total we need to remove. // so we want to round that, which means adding 0.5 * 1<<17, // aka 65536. Also, we'll end up with -128 to 127 that we want // to encode as 0..255 by adding 128, so we'll add that before the shift x0 += 65536 + (128<<17); x1 += 65536 + (128<<17); x2 += 65536 + (128<<17); x3 += 65536 + (128<<17); // tried computing the shifts into temps, or'ing the temps to see // if any were out of range, but that was slower o[0] = clamp((x0+t3) >> 17); o[7] = clamp((x0-t3) >> 17); o[1] = clamp((x1+t2) >> 17); o[6] = clamp((x1-t2) >> 17); o[2] = clamp((x2+t1) >> 17); o[5] = clamp((x2-t1) >> 17); o[3] = clamp((x3+t0) >> 17); o[4] = clamp((x3-t0) >> 17); } } #ifdef STBI_SIMD static stbi_idct_8x8 stbi_idct_installed = idct_block; void stbi_install_idct(stbi_idct_8x8 func) { stbi_idct_installed = func; } #endif #define MARKER_none 0xff // if there's a pending marker from the entropy stream, return that // otherwise, fetch from the stream and get a marker. if there's no // marker, return 0xff, which is never a valid marker value static stbi__uint8 get_marker(jpeg *j) { stbi__uint8 x; if (j->marker != MARKER_none) { x = j->marker; j->marker = MARKER_none; return x; } x = get8u(j->s); if (x != 0xff) return MARKER_none; while (x == 0xff) x = get8u(j->s); return x; } // in each scan, we'll have scan_n components, and the order // of the components is specified by order[] #define RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) // after a restart interval, reset the entropy decoder and // the dc prediction static void reset(jpeg *j) { j->code_bits = 0; j->code_buffer = 0; j->nomore = 0; j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = 0; j->marker = MARKER_none; j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, // since we don't even allow 1<<30 pixels } static int parse_entropy_coded_data(jpeg *z) { reset(z); if (z->scan_n == 1) { int i,j; #ifdef STBI_SIMD __declspec(align(16)) #endif short data[64]; int n = z->order[0]; // non-interleaved data, we just need to process one block at a time, // in trivial scanline order // number of blocks to do just depends on how many actual "pixels" this // component has, independent of interleaved MCU blocking and such int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { if (!decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+z->img_comp[n].ha, n)) return 0; #ifdef STBI_SIMD stbi_idct_installed(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data, z->dequant2[z->img_comp[n].tq]); #else idct_block(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data, z->dequant[z->img_comp[n].tq]); #endif // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) grow_buffer_unsafe(z); // if it's NOT a restart, then just bail, so we get corrupt data // rather than no data if (!RESTART(z->marker)) return 1; reset(z); } } } } else { // interleaved! int i,j,k,x,y; short data[64]; for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order for (k=0; k < z->scan_n; ++k) { int n = z->order[k]; // scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component for (y=0; y < z->img_comp[n].v; ++y) { for (x=0; x < z->img_comp[n].h; ++x) { int x2 = (i*z->img_comp[n].h + x)*8; int y2 = (j*z->img_comp[n].v + y)*8; if (!decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+z->img_comp[n].ha, n)) return 0; #ifdef STBI_SIMD stbi_idct_installed(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data, z->dequant2[z->img_comp[n].tq]); #else idct_block(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data, z->dequant[z->img_comp[n].tq]); #endif } } } // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) grow_buffer_unsafe(z); // if it's NOT a restart, then just bail, so we get corrupt data // rather than no data if (!RESTART(z->marker)) return 1; reset(z); } } } } return 1; } static int process_marker(jpeg *z, int m) { int L; switch (m) { case MARKER_none: // no marker found return e("expected marker","Corrupt JPEG"); case 0xC2: // SOF - progressive return e("progressive jpeg","JPEG format not supported (progressive)"); case 0xDD: // DRI - specify restart interval if (get16(z->s) != 4) return e("bad DRI len","Corrupt JPEG"); z->restart_interval = get16(z->s); return 1; case 0xDB: // DQT - define quantization table L = get16(z->s)-2; while (L > 0) { int q = get8(z->s); int p = q >> 4; int t = q & 15,i; if (p != 0) return e("bad DQT type","Corrupt JPEG"); if (t > 3) return e("bad DQT table","Corrupt JPEG"); for (i=0; i < 64; ++i) z->dequant[t][dezigzag[i]] = get8u(z->s); #ifdef STBI_SIMD for (i=0; i < 64; ++i) z->dequant2[t][i] = z->dequant[t][i]; #endif L -= 65; } return L==0; case 0xC4: // DHT - define huffman table L = get16(z->s)-2; while (L > 0) { stbi__uint8 *v; int sizes[16],i,n=0; int q = get8(z->s); int tc = q >> 4; int th = q & 15; if (tc > 1 || th > 3) return e("bad DHT header","Corrupt JPEG"); for (i=0; i < 16; ++i) { sizes[i] = get8(z->s); n += sizes[i]; } L -= 17; if (tc == 0) { if (!build_huffman(z->huff_dc+th, sizes)) return 0; v = z->huff_dc[th].values; } else { if (!build_huffman(z->huff_ac+th, sizes)) return 0; v = z->huff_ac[th].values; } for (i=0; i < n; ++i) v[i] = get8u(z->s); L -= n; } return L==0; } // check for comment block or APP blocks if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { skip(z->s, get16(z->s)-2); return 1; } return 0; } // after we see SOS static int process_scan_header(jpeg *z) { int i; int Ls = get16(z->s); z->scan_n = get8(z->s); if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return e("bad SOS component count","Corrupt JPEG"); if (Ls != 6+2*z->scan_n) return e("bad SOS len","Corrupt JPEG"); for (i=0; i < z->scan_n; ++i) { int id = get8(z->s), which; int q = get8(z->s); for (which = 0; which < z->s->img_n; ++which) if (z->img_comp[which].id == id) break; if (which == z->s->img_n) return 0; z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return e("bad DC huff","Corrupt JPEG"); z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return e("bad AC huff","Corrupt JPEG"); z->order[i] = which; } if (get8(z->s) != 0) return e("bad SOS","Corrupt JPEG"); get8(z->s); // should be 63, but might be 0 if (get8(z->s) != 0) return e("bad SOS","Corrupt JPEG"); return 1; } static int process_frame_header(jpeg *z, int scan) { stbi *s = z->s; int Lf,p,i,q, h_max=1,v_max=1,c; Lf = get16(s); if (Lf < 11) return e("bad SOF len","Corrupt JPEG"); // JPEG p = get8(s); if (p != 8) return e("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline s->img_y = get16(s); if (s->img_y == 0) return e("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG s->img_x = get16(s); if (s->img_x == 0) return e("0 width","Corrupt JPEG"); // JPEG requires c = get8(s); if (c != 3 && c != 1) return e("bad component count","Corrupt JPEG"); // JFIF requires s->img_n = c; for (i=0; i < c; ++i) { z->img_comp[i].data = NULL; z->img_comp[i].linebuf = NULL; } if (Lf != 8+3*s->img_n) return e("bad SOF len","Corrupt JPEG"); for (i=0; i < s->img_n; ++i) { z->img_comp[i].id = get8(s); if (z->img_comp[i].id != i+1) // JFIF requires if (z->img_comp[i].id != i) // some version of jpegtran outputs non-JFIF-compliant files! return e("bad component ID","Corrupt JPEG"); q = get8(s); z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return e("bad H","Corrupt JPEG"); z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return e("bad V","Corrupt JPEG"); z->img_comp[i].tq = get8(s); if (z->img_comp[i].tq > 3) return e("bad TQ","Corrupt JPEG"); } if (scan != SCAN_load) return 1; if ((1 << 30) / s->img_x / s->img_n < s->img_y) return e("too large", "Image too large to decode"); for (i=0; i < s->img_n; ++i) { if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; } // compute interleaved mcu info z->img_h_max = h_max; z->img_v_max = v_max; z->img_mcu_w = h_max * 8; z->img_mcu_h = v_max * 8; z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; for (i=0; i < s->img_n; ++i) { // number of effective pixels (e.g. for non-interleaved MCU) z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; // to simplify generation, we'll allocate enough memory to decode // the bogus oversized data from using interleaved MCUs and their // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't // discard the extra data until colorspace conversion z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; z->img_comp[i].raw_data = malloc(z->img_comp[i].w2 * z->img_comp[i].h2+15); if (z->img_comp[i].raw_data == NULL) { for(--i; i >= 0; --i) { free(z->img_comp[i].raw_data); z->img_comp[i].data = NULL; } return e("outofmem", "Out of memory"); } // align blocks for installable-idct using mmx/sse z->img_comp[i].data = (stbi__uint8*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); z->img_comp[i].linebuf = NULL; } return 1; } // use comparisons since in some cases we handle more than one case (e.g. SOF) #define DNL(x) ((x) == 0xdc) #define SOI(x) ((x) == 0xd8) #define EOI(x) ((x) == 0xd9) #define SOF(x) ((x) == 0xc0 || (x) == 0xc1) #define SOS(x) ((x) == 0xda) static int decode_jpeg_header(jpeg *z, int scan) { int m; z->marker = MARKER_none; // initialize cached marker to empty m = get_marker(z); if (!SOI(m)) return e("no SOI","Corrupt JPEG"); if (scan == SCAN_type) return 1; m = get_marker(z); while (!SOF(m)) { if (!process_marker(z,m)) return 0; m = get_marker(z); while (m == MARKER_none) { // some files have extra padding after their blocks, so ok, we'll scan if (at_eof(z->s)) return e("no SOF", "Corrupt JPEG"); m = get_marker(z); } } if (!process_frame_header(z, scan)) return 0; return 1; } static int decode_jpeg_image(jpeg *j) { int m; j->restart_interval = 0; if (!decode_jpeg_header(j, SCAN_load)) return 0; m = get_marker(j); while (!EOI(m)) { if (SOS(m)) { if (!process_scan_header(j)) return 0; if (!parse_entropy_coded_data(j)) return 0; if (j->marker == MARKER_none ) { // handle 0s at the end of image data from IP Kamera 9060 while (!at_eof(j->s)) { int x = get8(j->s); if (x == 255) { j->marker = get8u(j->s); break; } else if (x != 0) { return 0; } } // if we reach eof without hitting a marker, get_marker() below will fail and we'll eventually return 0 } } else { if (!process_marker(j, m)) return 0; } m = get_marker(j); } return 1; } // static jfif-centered resampling (across block boundaries) typedef stbi__uint8 *(*resample_row_func)(stbi__uint8 *out, stbi__uint8 *in0, stbi__uint8 *in1, int w, int hs); #define div4(x) ((stbi__uint8) ((x) >> 2)) static stbi__uint8 *resample_row_1(stbi__uint8 *out, stbi__uint8 *in_near, stbi__uint8 *in_far, int w, int hs) { STBI_NOTUSED(out); STBI_NOTUSED(in_far); STBI_NOTUSED(w); STBI_NOTUSED(hs); return in_near; } static stbi__uint8* resample_row_v_2(stbi__uint8 *out, stbi__uint8 *in_near, stbi__uint8 *in_far, int w, int hs) { // need to generate two samples vertically for every one in input int i; STBI_NOTUSED(hs); for (i=0; i < w; ++i) out[i] = div4(3*in_near[i] + in_far[i] + 2); return out; } static stbi__uint8* resample_row_h_2(stbi__uint8 *out, stbi__uint8 *in_near, stbi__uint8 *in_far, int w, int hs) { // need to generate two samples horizontally for every one in input int i; stbi__uint8 *input = in_near; if (w == 1) { // if only one sample, can't do any interpolation out[0] = out[1] = input[0]; return out; } out[0] = input[0]; out[1] = div4(input[0]*3 + input[1] + 2); for (i=1; i < w-1; ++i) { int n = 3*input[i]+2; out[i*2+0] = div4(n+input[i-1]); out[i*2+1] = div4(n+input[i+1]); } out[i*2+0] = div4(input[w-2]*3 + input[w-1] + 2); out[i*2+1] = input[w-1]; STBI_NOTUSED(in_far); STBI_NOTUSED(hs); return out; } #define div16(x) ((stbi__uint8) ((x) >> 4)) static stbi__uint8 *resample_row_hv_2(stbi__uint8 *out, stbi__uint8 *in_near, stbi__uint8 *in_far, int w, int hs) { // need to generate 2x2 samples for every one in input int i,t0,t1; if (w == 1) { out[0] = out[1] = div4(3*in_near[0] + in_far[0] + 2); return out; } t1 = 3*in_near[0] + in_far[0]; out[0] = div4(t1+2); for (i=1; i < w; ++i) { t0 = t1; t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = div16(3*t0 + t1 + 8); out[i*2 ] = div16(3*t1 + t0 + 8); } out[w*2-1] = div4(t1+2); STBI_NOTUSED(hs); return out; } static stbi__uint8 *resample_row_generic(stbi__uint8 *out, stbi__uint8 *in_near, stbi__uint8 *in_far, int w, int hs) { // resample with nearest-neighbor int i,j; STBI_NOTUSED(in_far); for (i=0; i < w; ++i) for (j=0; j < hs; ++j) out[i*hs+j] = in_near[i]; return out; } #define float2fixed(x) ((int) ((x) * 65536 + 0.5)) // 0.38 seconds on 3*anemones.jpg (0.25 with processor = Pro) // VC6 without processor=Pro is generating multiple LEAs per multiply! static void YCbCr_to_RGB_row(stbi__uint8 *out, const stbi__uint8 *y, const stbi__uint8 *pcb, const stbi__uint8 *pcr, int count, int step) { int i; for (i=0; i < count; ++i) { int y_fixed = (y[i] << 16) + 32768; // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr*float2fixed(1.40200f); g = y_fixed - cr*float2fixed(0.71414f) - cb*float2fixed(0.34414f); b = y_fixed + cb*float2fixed(1.77200f); r >>= 16; g >>= 16; b >>= 16; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi__uint8)r; out[1] = (stbi__uint8)g; out[2] = (stbi__uint8)b; out[3] = 255; out += step; } } #ifdef STBI_SIMD static stbi_YCbCr_to_RGB_run stbi_YCbCr_installed = YCbCr_to_RGB_row; void stbi_install_YCbCr_to_RGB(stbi_YCbCr_to_RGB_run func) { stbi_YCbCr_installed = func; } #endif // clean up the temporary component buffers static void cleanup_jpeg(jpeg *j) { int i; for (i=0; i < j->s->img_n; ++i) { if (j->img_comp[i].data) { free(j->img_comp[i].raw_data); j->img_comp[i].data = NULL; } if (j->img_comp[i].linebuf) { free(j->img_comp[i].linebuf); j->img_comp[i].linebuf = NULL; } } } typedef struct { resample_row_func resample; stbi__uint8 *line0,*line1; int hs,vs; // expansion factor in each axis int w_lores; // horizontal pixels pre-expansion int ystep; // how far through vertical expansion we are int ypos; // which pre-expansion row we're on } stbi_resample; static stbi__uint8 *load_jpeg_image(jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) { int n, decode_n; // validate req_comp if (req_comp < 0 || req_comp > 4) return epuc("bad req_comp", "Internal error"); z->s->img_n = 0; // load a jpeg image from whichever source if (!decode_jpeg_image(z)) { cleanup_jpeg(z); return NULL; } // determine actual number of components to generate n = req_comp ? req_comp : z->s->img_n; if (z->s->img_n == 3 && n < 3) decode_n = 1; else decode_n = z->s->img_n; // resample and color-convert { int k; unsigned int i,j; stbi__uint8 *output; stbi__uint8 *coutput[4]; stbi_resample res_comp[4]; for (k=0; k < decode_n; ++k) { stbi_resample *r = &res_comp[k]; // allocate line buffer big enough for upsampling off the edges // with upsample factor of 4 z->img_comp[k].linebuf = (stbi__uint8 *) malloc(z->s->img_x + 3); if (!z->img_comp[k].linebuf) { cleanup_jpeg(z); return epuc("outofmem", "Out of memory"); } r->hs = z->img_h_max / z->img_comp[k].h; r->vs = z->img_v_max / z->img_comp[k].v; r->ystep = r->vs >> 1; r->w_lores = (z->s->img_x + r->hs-1) / r->hs; r->ypos = 0; r->line0 = r->line1 = z->img_comp[k].data; if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; else if (r->hs == 1 && r->vs == 2) r->resample = resample_row_v_2; else if (r->hs == 2 && r->vs == 1) r->resample = resample_row_h_2; else if (r->hs == 2 && r->vs == 2) r->resample = resample_row_hv_2; else r->resample = resample_row_generic; } // can't error after this so, this is safe output = (stbi__uint8 *) malloc(n * z->s->img_x * z->s->img_y + 1); if (!output) { cleanup_jpeg(z); return epuc("outofmem", "Out of memory"); } // now go ahead and resample for (j=0; j < z->s->img_y; ++j) { stbi__uint8 *out = output + n * z->s->img_x * j; for (k=0; k < decode_n; ++k) { stbi_resample *r = &res_comp[k]; int y_bot = r->ystep >= (r->vs >> 1); coutput[k] = r->resample(z->img_comp[k].linebuf, y_bot ? r->line1 : r->line0, y_bot ? r->line0 : r->line1, r->w_lores, r->hs); if (++r->ystep >= r->vs) { r->ystep = 0; r->line0 = r->line1; if (++r->ypos < z->img_comp[k].y) r->line1 += z->img_comp[k].w2; } } if (n >= 3) { stbi__uint8 *y = coutput[0]; if (z->s->img_n == 3) { #ifdef STBI_SIMD stbi_YCbCr_installed(out, y, coutput[1], coutput[2], z->s->img_x, n); #else YCbCr_to_RGB_row(out, y, coutput[1], coutput[2], z->s->img_x, n); #endif } else for (i=0; i < z->s->img_x; ++i) { out[0] = out[1] = out[2] = y[i]; out[3] = 255; // not used if n==3 out += n; } } else { stbi__uint8 *y = coutput[0]; if (n == 1) for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; else for (i=0; i < z->s->img_x; ++i) *out++ = y[i], *out++ = 255; } } cleanup_jpeg(z); *out_x = z->s->img_x; *out_y = z->s->img_y; if (comp) *comp = z->s->img_n; // report original components, not output return output; } } static unsigned char *stbi_jpeg_load(stbi *s, int *x, int *y, int *comp, int req_comp) { jpeg j; j.s = s; return load_jpeg_image(&j, x,y,comp,req_comp); } static int stbi_jpeg_test(stbi *s) { int r; jpeg j; j.s = s; r = decode_jpeg_header(&j, SCAN_type); stbi_rewind(s); return r; } static int stbi_jpeg_info_raw(jpeg *j, int *x, int *y, int *comp) { if (!decode_jpeg_header(j, SCAN_header)) { stbi_rewind( j->s ); return 0; } if (x) *x = j->s->img_x; if (y) *y = j->s->img_y; if (comp) *comp = j->s->img_n; return 1; } static int stbi_jpeg_info(stbi *s, int *x, int *y, int *comp) { jpeg j; j.s = s; return stbi_jpeg_info_raw(&j, x, y, comp); } // public domain zlib decode v0.2 Sean Barrett 2006-11-18 // simple implementation // - all input must be provided in an upfront buffer // - all output is written to a single output buffer (can malloc/realloc) // performance // - fast huffman // fast-way is faster to check than jpeg huffman, but slow way is slower #define ZFAST_BITS 9 // accelerate all cases in default tables #define ZFAST_MASK ((1 << ZFAST_BITS) - 1) // zlib-style huffman encoding // (jpegs packs from left, zlib from right, so can't share code) typedef struct { stbi__uint16 fast[1 << ZFAST_BITS]; stbi__uint16 firstcode[16]; int maxcode[17]; stbi__uint16 firstsymbol[16]; stbi__uint8 size[288]; stbi__uint16 value[288]; } zhuffman; stbi_inline static int bitreverse16(int n) { n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); return n; } stbi_inline static int bit_reverse(int v, int bits) { assert(bits <= 16); // to bit reverse n bits, reverse 16 and shift // e.g. 11 bits, bit reverse and shift away 5 return bitreverse16(v) >> (16-bits); } static int zbuild_huffman(zhuffman *z, stbi__uint8 *sizelist, int num) { int i,k=0; int code, next_code[16], sizes[17]; // DEFLATE spec for generating codes memset(sizes, 0, sizeof(sizes)); memset(z->fast, 255, sizeof(z->fast)); for (i=0; i < num; ++i) ++sizes[sizelist[i]]; sizes[0] = 0; for (i=1; i < 16; ++i) assert(sizes[i] <= (1 << i)); code = 0; for (i=1; i < 16; ++i) { next_code[i] = code; z->firstcode[i] = (stbi__uint16) code; z->firstsymbol[i] = (stbi__uint16) k; code = (code + sizes[i]); if (sizes[i]) if (code-1 >= (1 << i)) return e("bad codelengths","Corrupt JPEG"); z->maxcode[i] = code << (16-i); // preshift for inner loop code <<= 1; k += sizes[i]; } z->maxcode[16] = 0x10000; // sentinel for (i=0; i < num; ++i) { int s = sizelist[i]; if (s) { int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; z->size[c] = (stbi__uint8)s; z->value[c] = (stbi__uint16)i; if (s <= ZFAST_BITS) { int k = bit_reverse(next_code[s],s); while (k < (1 << ZFAST_BITS)) { z->fast[k] = (stbi__uint16) c; k += (1 << s); } } ++next_code[s]; } } return 1; } // zlib-from-memory implementation for PNG reading // because PNG allows splitting the zlib stream arbitrarily, // and it's annoying structurally to have PNG call ZLIB call PNG, // we require PNG read all the IDATs and combine them into a single // memory buffer typedef struct { stbi__uint8 *zbuffer, *zbuffer_end; int num_bits; stbi__uint32 code_buffer; char *zout; char *zout_start; char *zout_end; int z_expandable; zhuffman z_length, z_distance; } zbuf; stbi_inline static int zget8(zbuf *z) { if (z->zbuffer >= z->zbuffer_end) return 0; return *z->zbuffer++; } static void fill_bits(zbuf *z) { do { assert(z->code_buffer < (1U << z->num_bits)); z->code_buffer |= zget8(z) << z->num_bits; z->num_bits += 8; } while (z->num_bits <= 24); } stbi_inline static unsigned int zreceive(zbuf *z, int n) { unsigned int k; if (z->num_bits < n) fill_bits(z); k = z->code_buffer & ((1 << n) - 1); z->code_buffer >>= n; z->num_bits -= n; return k; } stbi_inline static int zhuffman_decode(zbuf *a, zhuffman *z) { int b,s,k; if (a->num_bits < 16) fill_bits(a); b = z->fast[a->code_buffer & ZFAST_MASK]; if (b < 0xffff) { s = z->size[b]; a->code_buffer >>= s; a->num_bits -= s; return z->value[b]; } // not resolved by fast table, so compute it the slow way // use jpeg approach, which requires MSbits at top k = bit_reverse(a->code_buffer, 16); for (s=ZFAST_BITS+1; ; ++s) if (k < z->maxcode[s]) break; if (s == 16) return -1; // invalid code! // code size is s, so: b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; assert(z->size[b] == s); a->code_buffer >>= s; a->num_bits -= s; return z->value[b]; } static int expand(zbuf *z, int n) // need to make room for n bytes { char *q; int cur, limit; if (!z->z_expandable) return e("output buffer limit","Corrupt PNG"); cur = (int) (z->zout - z->zout_start); limit = (int) (z->zout_end - z->zout_start); while (cur + n > limit) limit *= 2; q = (char *) realloc(z->zout_start, limit); if (q == NULL) return e("outofmem", "Out of memory"); z->zout_start = q; z->zout = q + cur; z->zout_end = q + limit; return 1; } static int length_base[31] = { 3,4,5,6,7,8,9,10,11,13, 15,17,19,23,27,31,35,43,51,59, 67,83,99,115,131,163,195,227,258,0,0 }; static int length_extra[31]= { 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; static int dist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, 257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; static int dist_extra[32] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; static int parse_huffman_block(zbuf *a) { for(;;) { int z = zhuffman_decode(a, &a->z_length); if (z < 256) { if (z < 0) return e("bad huffman code","Corrupt PNG"); // error in huffman codes if (a->zout >= a->zout_end) if (!expand(a, 1)) return 0; *a->zout++ = (char) z; } else { stbi__uint8 *p; int len,dist; if (z == 256) return 1; z -= 257; len = length_base[z]; if (length_extra[z]) len += zreceive(a, length_extra[z]); z = zhuffman_decode(a, &a->z_distance); if (z < 0) return e("bad huffman code","Corrupt PNG"); dist = dist_base[z]; if (dist_extra[z]) dist += zreceive(a, dist_extra[z]); if (a->zout - a->zout_start < dist) return e("bad dist","Corrupt PNG"); if (a->zout + len > a->zout_end) if (!expand(a, len)) return 0; p = (stbi__uint8 *) (a->zout - dist); while (len--) *a->zout++ = *p++; } } } static int compute_huffman_codes(zbuf *a) { static stbi__uint8 length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; zhuffman z_codelength; stbi__uint8 lencodes[286+32+137];//padding for maximum single op stbi__uint8 codelength_sizes[19]; int i,n; int hlit = zreceive(a,5) + 257; int hdist = zreceive(a,5) + 1; int hclen = zreceive(a,4) + 4; memset(codelength_sizes, 0, sizeof(codelength_sizes)); for (i=0; i < hclen; ++i) { int s = zreceive(a,3); codelength_sizes[length_dezigzag[i]] = (stbi__uint8) s; } if (!zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; n = 0; while (n < hlit + hdist) { int c = zhuffman_decode(a, &z_codelength); assert(c >= 0 && c < 19); if (c < 16) lencodes[n++] = (stbi__uint8) c; else if (c == 16) { c = zreceive(a,2)+3; memset(lencodes+n, lencodes[n-1], c); n += c; } else if (c == 17) { c = zreceive(a,3)+3; memset(lencodes+n, 0, c); n += c; } else { assert(c == 18); c = zreceive(a,7)+11; memset(lencodes+n, 0, c); n += c; } } if (n != hlit+hdist) return e("bad codelengths","Corrupt PNG"); if (!zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; if (!zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; return 1; } static int parse_uncompressed_block(zbuf *a) { stbi__uint8 header[4]; int len,nlen,k; if (a->num_bits & 7) zreceive(a, a->num_bits & 7); // discard // drain the bit-packed data into header k = 0; while (a->num_bits > 0) { header[k++] = (stbi__uint8) (a->code_buffer & 255); // wtf this warns? a->code_buffer >>= 8; a->num_bits -= 8; } assert(a->num_bits == 0); // now fill header the normal way while (k < 4) header[k++] = (stbi__uint8) zget8(a); len = header[1] * 256 + header[0]; nlen = header[3] * 256 + header[2]; if (nlen != (len ^ 0xffff)) return e("zlib corrupt","Corrupt PNG"); if (a->zbuffer + len > a->zbuffer_end) return e("read past buffer","Corrupt PNG"); if (a->zout + len > a->zout_end) if (!expand(a, len)) return 0; memcpy(a->zout, a->zbuffer, len); a->zbuffer += len; a->zout += len; return 1; } static int parse_zlib_header(zbuf *a) { int cmf = zget8(a); int cm = cmf & 15; /* int cinfo = cmf >> 4; */ int flg = zget8(a); if ((cmf*256+flg) % 31 != 0) return e("bad zlib header","Corrupt PNG"); // zlib spec if (flg & 32) return e("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png if (cm != 8) return e("bad compression","Corrupt PNG"); // DEFLATE required for png // window = 1 << (8 + cinfo)... but who cares, we fully buffer output return 1; } // @TODO: should statically initialize these for optimal thread safety static stbi__uint8 default_length[288], default_distance[32]; static void init_defaults(void) { int i; // use <= to match clearly with spec for (i=0; i <= 143; ++i) default_length[i] = 8; for ( ; i <= 255; ++i) default_length[i] = 9; for ( ; i <= 279; ++i) default_length[i] = 7; for ( ; i <= 287; ++i) default_length[i] = 8; for (i=0; i <= 31; ++i) default_distance[i] = 5; } int stbi_png_partial; // a quick hack to only allow decoding some of a PNG... I should implement real streaming support instead static int parse_zlib(zbuf *a, int parse_header) { int final, type; if (parse_header) if (!parse_zlib_header(a)) return 0; a->num_bits = 0; a->code_buffer = 0; do { final = zreceive(a,1); type = zreceive(a,2); if (type == 0) { if (!parse_uncompressed_block(a)) return 0; } else if (type == 3) { return 0; } else { if (type == 1) { // use fixed code lengths if (!default_distance[31]) init_defaults(); if (!zbuild_huffman(&a->z_length , default_length , 288)) return 0; if (!zbuild_huffman(&a->z_distance, default_distance, 32)) return 0; } else { if (!compute_huffman_codes(a)) return 0; } if (!parse_huffman_block(a)) return 0; } if (stbi_png_partial && a->zout - a->zout_start > 65536) break; } while (!final); return 1; } static int do_zlib(zbuf *a, char *obuf, int olen, int exp, int parse_header) { a->zout_start = obuf; a->zout = obuf; a->zout_end = obuf + olen; a->z_expandable = exp; return parse_zlib(a, parse_header); } char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) { zbuf a; char *p = (char *) malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi__uint8 *) buffer; a.zbuffer_end = (stbi__uint8 *) buffer + len; if (do_zlib(&a, p, initial_size, 1, 1)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { free(a.zout_start); return NULL; } } char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) { return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); } char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) { zbuf a; char *p = (char *) malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi__uint8 *) buffer; a.zbuffer_end = (stbi__uint8 *) buffer + len; if (do_zlib(&a, p, initial_size, 1, parse_header)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { free(a.zout_start); return NULL; } } int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) { zbuf a; a.zbuffer = (stbi__uint8 *) ibuffer; a.zbuffer_end = (stbi__uint8 *) ibuffer + ilen; if (do_zlib(&a, obuffer, olen, 0, 1)) return (int) (a.zout - a.zout_start); else return -1; } char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) { zbuf a; char *p = (char *) malloc(16384); if (p == NULL) return NULL; a.zbuffer = (stbi__uint8 *) buffer; a.zbuffer_end = (stbi__uint8 *) buffer+len; if (do_zlib(&a, p, 16384, 1, 0)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { free(a.zout_start); return NULL; } } int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) { zbuf a; a.zbuffer = (stbi__uint8 *) ibuffer; a.zbuffer_end = (stbi__uint8 *) ibuffer + ilen; if (do_zlib(&a, obuffer, olen, 0, 0)) return (int) (a.zout - a.zout_start); else return -1; } // public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 // simple implementation // - only 8-bit samples // - no CRC checking // - allocates lots of intermediate memory // - avoids problem of streaming data between subsystems // - avoids explicit window management // performance // - uses stb_zlib, a PD zlib implementation with fast huffman decoding typedef struct { stbi__uint32 length; stbi__uint32 type; } chunk; #define PNG_TYPE(a,b,c,d) (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) static chunk get_chunk_header(stbi *s) { chunk c; c.length = get32(s); c.type = get32(s); return c; } static int check_png_header(stbi *s) { static stbi__uint8 png_sig[8] = { 137,80,78,71,13,10,26,10 }; int i; for (i=0; i < 8; ++i) if (get8u(s) != png_sig[i]) return e("bad png sig","Not a PNG"); return 1; } typedef struct { stbi *s; stbi__uint8 *idata, *expanded, *out; } png; enum { F_none=0, F_sub=1, F_up=2, F_avg=3, F_paeth=4, F_avg_first, F_paeth_first }; static stbi__uint8 first_row_filter[5] = { F_none, F_sub, F_none, F_avg_first, F_paeth_first }; static int paeth(int a, int b, int c) { int p = a + b - c; int pa = abs(p-a); int pb = abs(p-b); int pc = abs(p-c); if (pa <= pb && pa <= pc) return a; if (pb <= pc) return b; return c; } // create the png data from post-deflated data static int create_png_image_raw(png *a, stbi__uint8 *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y) { stbi *s = a->s; stbi__uint32 i,j,stride = x*out_n; int k; int img_n = s->img_n; // copy it into a local for later assert(out_n == s->img_n || out_n == s->img_n+1); if (stbi_png_partial) y = 1; a->out = (stbi__uint8 *) malloc(x * y * out_n); if (!a->out) return e("outofmem", "Out of memory"); if (!stbi_png_partial) { if (s->img_x == x && s->img_y == y) { if (raw_len != (img_n * x + 1) * y) return e("not enough pixels","Corrupt PNG"); } else { // interlaced: if (raw_len < (img_n * x + 1) * y) return e("not enough pixels","Corrupt PNG"); } } for (j=0; j < y; ++j) { stbi__uint8 *cur = a->out + stride*j; stbi__uint8 *prior = cur - stride; int filter = *raw++; if (filter > 4) return e("invalid filter","Corrupt PNG"); // if first row, use special filter that doesn't sample previous row if (j == 0) filter = first_row_filter[filter]; // handle first pixel explicitly for (k=0; k < img_n; ++k) { switch (filter) { case F_none : cur[k] = raw[k]; break; case F_sub : cur[k] = raw[k]; break; case F_up : cur[k] = raw[k] + prior[k]; break; case F_avg : cur[k] = raw[k] + (prior[k]>>1); break; case F_paeth : cur[k] = (stbi__uint8) (raw[k] + paeth(0,prior[k],0)); break; case F_avg_first : cur[k] = raw[k]; break; case F_paeth_first: cur[k] = raw[k]; break; } } if (img_n != out_n) cur[img_n] = 255; raw += img_n; cur += out_n; prior += out_n; // this is a little gross, so that we don't switch per-pixel or per-component if (img_n == out_n) { #define CASE(f) \ case f: \ for (i=x-1; i >= 1; --i, raw+=img_n,cur+=img_n,prior+=img_n) \ for (k=0; k < img_n; ++k) switch (filter) { CASE(F_none) cur[k] = raw[k]; break; CASE(F_sub) cur[k] = raw[k] + cur[k-img_n]; break; CASE(F_up) cur[k] = raw[k] + prior[k]; break; CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-img_n])>>1); break; CASE(F_paeth) cur[k] = (stbi__uint8) (raw[k] + paeth(cur[k-img_n],prior[k],prior[k-img_n])); break; CASE(F_avg_first) cur[k] = raw[k] + (cur[k-img_n] >> 1); break; CASE(F_paeth_first) cur[k] = (stbi__uint8) (raw[k] + paeth(cur[k-img_n],0,0)); break; } #undef CASE } else { assert(img_n+1 == out_n); #define CASE(f) \ case f: \ for (i=x-1; i >= 1; --i, cur[img_n]=255,raw+=img_n,cur+=out_n,prior+=out_n) \ for (k=0; k < img_n; ++k) switch (filter) { CASE(F_none) cur[k] = raw[k]; break; CASE(F_sub) cur[k] = raw[k] + cur[k-out_n]; break; CASE(F_up) cur[k] = raw[k] + prior[k]; break; CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-out_n])>>1); break; CASE(F_paeth) cur[k] = (stbi__uint8) (raw[k] + paeth(cur[k-out_n],prior[k],prior[k-out_n])); break; CASE(F_avg_first) cur[k] = raw[k] + (cur[k-out_n] >> 1); break; CASE(F_paeth_first) cur[k] = (stbi__uint8) (raw[k] + paeth(cur[k-out_n],0,0)); break; } #undef CASE } } return 1; } static int create_png_image(png *a, stbi__uint8 *raw, stbi__uint32 raw_len, int out_n, int interlaced) { stbi__uint8 *final; int p; int save; if (!interlaced) return create_png_image_raw(a, raw, raw_len, out_n, a->s->img_x, a->s->img_y); save = stbi_png_partial; stbi_png_partial = 0; // de-interlacing final = (stbi__uint8 *) malloc(a->s->img_x * a->s->img_y * out_n); for (p=0; p < 7; ++p) { int xorig[] = { 0,4,0,2,0,1,0 }; int yorig[] = { 0,0,4,0,2,0,1 }; int xspc[] = { 8,8,4,4,2,2,1 }; int yspc[] = { 8,8,8,4,4,2,2 }; int i,j,x,y; // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; if (x && y) { if (!create_png_image_raw(a, raw, raw_len, out_n, x, y)) { free(final); return 0; } for (j=0; j < y; ++j) for (i=0; i < x; ++i) memcpy(final + (j*yspc[p]+yorig[p])*a->s->img_x*out_n + (i*xspc[p]+xorig[p])*out_n, a->out + (j*x+i)*out_n, out_n); free(a->out); raw += (x*out_n+1)*y; raw_len -= (x*out_n+1)*y; } } a->out = final; stbi_png_partial = save; return 1; } static int compute_transparency(png *z, stbi__uint8 tc[3], int out_n) { stbi *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi__uint8 *p = z->out; // compute color-based transparency, assuming we've // already got 255 as the alpha value in the output assert(out_n == 2 || out_n == 4); if (out_n == 2) { for (i=0; i < pixel_count; ++i) { p[1] = (p[0] == tc[0] ? 0 : 255); p += 2; } } else { for (i=0; i < pixel_count; ++i) { if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) p[3] = 0; p += 4; } } return 1; } static int expand_palette(png *a, stbi__uint8 *palette, int len, int pal_img_n) { stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; stbi__uint8 *p, *temp_out, *orig = a->out; p = (stbi__uint8 *) malloc(pixel_count * pal_img_n); if (p == NULL) return e("outofmem", "Out of memory"); // between here and free(out) below, exitting would leak temp_out = p; if (pal_img_n == 3) { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p += 3; } } else { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p[3] = palette[n+3]; p += 4; } } free(a->out); a->out = temp_out; STBI_NOTUSED(len); return 1; } static int stbi_unpremultiply_on_load = 0; static int stbi_de_iphone_flag = 0; void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) { stbi_unpremultiply_on_load = flag_true_if_should_unpremultiply; } void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) { stbi_de_iphone_flag = flag_true_if_should_convert; } static void stbi_de_iphone(png *z) { stbi *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi__uint8 *p = z->out; if (s->img_out_n == 3) { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi__uint8 t = p[0]; p[0] = p[2]; p[2] = t; p += 3; } } else { assert(s->img_out_n == 4); if (stbi_unpremultiply_on_load) { // convert bgr to rgb and unpremultiply for (i=0; i < pixel_count; ++i) { stbi__uint8 a = p[3]; stbi__uint8 t = p[0]; if (a) { p[0] = p[2] * 255 / a; p[1] = p[1] * 255 / a; p[2] = t * 255 / a; } else { p[0] = p[2]; p[2] = t; } p += 4; } } else { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi__uint8 t = p[0]; p[0] = p[2]; p[2] = t; p += 4; } } } } static int parse_png_file(png *z, int scan, int req_comp) { stbi__uint8 palette[1024], pal_img_n=0; stbi__uint8 has_trans=0, tc[3]; stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; int first=1,k,interlace=0, iphone=0; stbi *s = z->s; z->expanded = NULL; z->idata = NULL; z->out = NULL; if (!check_png_header(s)) return 0; if (scan == SCAN_type) return 1; for (;;) { chunk c = get_chunk_header(s); switch (c.type) { case PNG_TYPE('C','g','B','I'): iphone = stbi_de_iphone_flag; skip(s, c.length); break; case PNG_TYPE('I','H','D','R'): { int depth,color,comp,filter; if (!first) return e("multiple IHDR","Corrupt PNG"); first = 0; if (c.length != 13) return e("bad IHDR len","Corrupt PNG"); s->img_x = get32(s); if (s->img_x > (1 << 24)) return e("too large","Very large image (corrupt?)"); s->img_y = get32(s); if (s->img_y > (1 << 24)) return e("too large","Very large image (corrupt?)"); depth = get8(s); if (depth != 8) return e("8bit only","PNG not supported: 8-bit only"); color = get8(s); if (color > 6) return e("bad ctype","Corrupt PNG"); if (color == 3) pal_img_n = 3; else if (color & 1) return e("bad ctype","Corrupt PNG"); comp = get8(s); if (comp) return e("bad comp method","Corrupt PNG"); filter= get8(s); if (filter) return e("bad filter method","Corrupt PNG"); interlace = get8(s); if (interlace>1) return e("bad interlace method","Corrupt PNG"); if (!s->img_x || !s->img_y) return e("0-pixel image","Corrupt PNG"); if (!pal_img_n) { s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); if ((1 << 30) / s->img_x / s->img_n < s->img_y) return e("too large", "Image too large to decode"); if (scan == SCAN_header) return 1; } else { // if paletted, then pal_n is our final components, and // img_n is # components to decompress/filter. s->img_n = 1; if ((1 << 30) / s->img_x / 4 < s->img_y) return e("too large","Corrupt PNG"); // if SCAN_header, have to scan to see if we have a tRNS } break; } case PNG_TYPE('P','L','T','E'): { if (first) return e("first not IHDR", "Corrupt PNG"); if (c.length > 256*3) return e("invalid PLTE","Corrupt PNG"); pal_len = c.length / 3; if (pal_len * 3 != c.length) return e("invalid PLTE","Corrupt PNG"); for (i=0; i < pal_len; ++i) { palette[i*4+0] = get8u(s); palette[i*4+1] = get8u(s); palette[i*4+2] = get8u(s); palette[i*4+3] = 255; } break; } case PNG_TYPE('t','R','N','S'): { if (first) return e("first not IHDR", "Corrupt PNG"); if (z->idata) return e("tRNS after IDAT","Corrupt PNG"); if (pal_img_n) { if (scan == SCAN_header) { s->img_n = 4; return 1; } if (pal_len == 0) return e("tRNS before PLTE","Corrupt PNG"); if (c.length > pal_len) return e("bad tRNS len","Corrupt PNG"); pal_img_n = 4; for (i=0; i < c.length; ++i) palette[i*4+3] = get8u(s); } else { if (!(s->img_n & 1)) return e("tRNS with alpha","Corrupt PNG"); if (c.length != (stbi__uint32) s->img_n*2) return e("bad tRNS len","Corrupt PNG"); has_trans = 1; for (k=0; k < s->img_n; ++k) tc[k] = (stbi__uint8) get16(s); // non 8-bit images will be larger } break; } case PNG_TYPE('I','D','A','T'): { if (first) return e("first not IHDR", "Corrupt PNG"); if (pal_img_n && !pal_len) return e("no PLTE","Corrupt PNG"); if (scan == SCAN_header) { s->img_n = pal_img_n; return 1; } if (ioff + c.length > idata_limit) { stbi__uint8 *p; if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; while (ioff + c.length > idata_limit) idata_limit *= 2; p = (stbi__uint8 *) realloc(z->idata, idata_limit); if (p == NULL) return e("outofmem", "Out of memory"); z->idata = p; } if (!getn(s, z->idata+ioff,c.length)) return e("outofdata","Corrupt PNG"); ioff += c.length; break; } case PNG_TYPE('I','E','N','D'): { stbi__uint32 raw_len; if (first) return e("first not IHDR", "Corrupt PNG"); if (scan != SCAN_load) return 1; if (z->idata == NULL) return e("no IDAT","Corrupt PNG"); z->expanded = (stbi__uint8 *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, 16384, (int *) &raw_len, !iphone); if (z->expanded == NULL) return 0; // zlib should set error free(z->idata); z->idata = NULL; if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) s->img_out_n = s->img_n+1; else s->img_out_n = s->img_n; if (!create_png_image(z, z->expanded, raw_len, s->img_out_n, interlace)) return 0; if (has_trans) if (!compute_transparency(z, tc, s->img_out_n)) return 0; if (iphone && s->img_out_n > 2) stbi_de_iphone(z); if (pal_img_n) { // pal_img_n == 3 or 4 s->img_n = pal_img_n; // record the actual colors we had s->img_out_n = pal_img_n; if (req_comp >= 3) s->img_out_n = req_comp; if (!expand_palette(z, palette, pal_len, s->img_out_n)) return 0; } free(z->expanded); z->expanded = NULL; return 1; } default: // if critical, fail if (first) return e("first not IHDR", "Corrupt PNG"); if ((c.type & (1 << 29)) == 0) { #ifndef STBI_NO_FAILURE_STRINGS // not threadsafe static char invalid_chunk[] = "XXXX chunk not known"; invalid_chunk[0] = (stbi__uint8) (c.type >> 24); invalid_chunk[1] = (stbi__uint8) (c.type >> 16); invalid_chunk[2] = (stbi__uint8) (c.type >> 8); invalid_chunk[3] = (stbi__uint8) (c.type >> 0); #endif return e(invalid_chunk, "PNG not supported: unknown chunk type"); } skip(s, c.length); break; } // end of chunk, read and skip CRC get32(s); } } static unsigned char *do_png(png *p, int *x, int *y, int *n, int req_comp) { unsigned char *result=NULL; if (req_comp < 0 || req_comp > 4) return epuc("bad req_comp", "Internal error"); if (parse_png_file(p, SCAN_load, req_comp)) { result = p->out; p->out = NULL; if (req_comp && req_comp != p->s->img_out_n) { result = convert_format(result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); p->s->img_out_n = req_comp; if (result == NULL) return result; } *x = p->s->img_x; *y = p->s->img_y; if (n) *n = p->s->img_n; } free(p->out); p->out = NULL; free(p->expanded); p->expanded = NULL; free(p->idata); p->idata = NULL; return result; } static unsigned char *stbi_png_load(stbi *s, int *x, int *y, int *comp, int req_comp) { png p; p.s = s; return do_png(&p, x,y,comp,req_comp); } static int stbi_png_test(stbi *s) { int r; r = check_png_header(s); stbi_rewind(s); return r; } static int stbi_png_info_raw(png *p, int *x, int *y, int *comp) { if (!parse_png_file(p, SCAN_header, 0)) { stbi_rewind( p->s ); return 0; } if (x) *x = p->s->img_x; if (y) *y = p->s->img_y; if (comp) *comp = p->s->img_n; return 1; } static int stbi_png_info(stbi *s, int *x, int *y, int *comp) { png p; p.s = s; return stbi_png_info_raw(&p, x, y, comp); } // Microsoft/Windows BMP image static int bmp_test(stbi *s) { int sz; if (get8(s) != 'B') return 0; if (get8(s) != 'M') return 0; get32le(s); // discard filesize get16le(s); // discard reserved get16le(s); // discard reserved get32le(s); // discard data offset sz = get32le(s); if (sz == 12 || sz == 40 || sz == 56 || sz == 108) return 1; return 0; } static int stbi_bmp_test(stbi *s) { int r = bmp_test(s); stbi_rewind(s); return r; } // returns 0..31 for the highest set bit static int high_bit(unsigned int z) { int n=0; if (z == 0) return -1; if (z >= 0x10000) n += 16, z >>= 16; if (z >= 0x00100) n += 8, z >>= 8; if (z >= 0x00010) n += 4, z >>= 4; if (z >= 0x00004) n += 2, z >>= 2; if (z >= 0x00002) n += 1, z >>= 1; return n; } static int bitcount(unsigned int a) { a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits a = (a + (a >> 8)); // max 16 per 8 bits a = (a + (a >> 16)); // max 32 per 8 bits return a & 0xff; } static int shiftsigned(int v, int shift, int bits) { int result; int z=0; if (shift < 0) v <<= -shift; else v >>= shift; result = v; z = bits; while (z < 8) { result += v >> z; z += bits; } return result; } static stbi_uc *bmp_load(stbi *s, int *x, int *y, int *comp, int req_comp) { stbi__uint8 *out; unsigned int mr=0,mg=0,mb=0,ma=0, fake_a=0; stbi_uc pal[256][4]; int psize=0,i,j,compress=0,width; int bpp, flip_vertically, pad, target, offset, hsz; if (get8(s) != 'B' || get8(s) != 'M') return epuc("not BMP", "Corrupt BMP"); get32le(s); // discard filesize get16le(s); // discard reserved get16le(s); // discard reserved offset = get32le(s); hsz = get32le(s); if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108) return epuc("unknown BMP", "BMP type not supported: unknown"); if (hsz == 12) { s->img_x = get16le(s); s->img_y = get16le(s); } else { s->img_x = get32le(s); s->img_y = get32le(s); } if (get16le(s) != 1) return epuc("bad BMP", "bad BMP"); bpp = get16le(s); if (bpp == 1) return epuc("monochrome", "BMP type not supported: 1-bit"); flip_vertically = ((int) s->img_y) > 0; s->img_y = abs((int) s->img_y); if (hsz == 12) { if (bpp < 24) psize = (offset - 14 - 24) / 3; } else { compress = get32le(s); if (compress == 1 || compress == 2) return epuc("BMP RLE", "BMP type not supported: RLE"); get32le(s); // discard sizeof get32le(s); // discard hres get32le(s); // discard vres get32le(s); // discard colorsused get32le(s); // discard max important if (hsz == 40 || hsz == 56) { if (hsz == 56) { get32le(s); get32le(s); get32le(s); get32le(s); } if (bpp == 16 || bpp == 32) { mr = mg = mb = 0; if (compress == 0) { if (bpp == 32) { mr = 0xffu << 16; mg = 0xffu << 8; mb = 0xffu << 0; ma = 0xffu << 24; fake_a = 1; // @TODO: check for cases like alpha value is all 0 and switch it to 255 STBI_NOTUSED(fake_a); } else { mr = 31u << 10; mg = 31u << 5; mb = 31u << 0; } } else if (compress == 3) { mr = get32le(s); mg = get32le(s); mb = get32le(s); // not documented, but generated by photoshop and handled by mspaint if (mr == mg && mg == mb) { // ?!?!? return epuc("bad BMP", "bad BMP"); } } else return epuc("bad BMP", "bad BMP"); } } else { assert(hsz == 108); mr = get32le(s); mg = get32le(s); mb = get32le(s); ma = get32le(s); get32le(s); // discard color space for (i=0; i < 12; ++i) get32le(s); // discard color space parameters } if (bpp < 16) psize = (offset - 14 - hsz) >> 2; } s->img_n = ma ? 4 : 3; if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 target = req_comp; else target = s->img_n; // if they want monochrome, we'll post-convert out = (stbi_uc *) malloc(target * s->img_x * s->img_y); if (!out) return epuc("outofmem", "Out of memory"); if (bpp < 16) { int z=0; if (psize == 0 || psize > 256) { free(out); return epuc("invalid", "Corrupt BMP"); } for (i=0; i < psize; ++i) { pal[i][2] = get8u(s); pal[i][1] = get8u(s); pal[i][0] = get8u(s); if (hsz != 12) get8(s); pal[i][3] = 255; } skip(s, offset - 14 - hsz - psize * (hsz == 12 ? 3 : 4)); if (bpp == 4) width = (s->img_x + 1) >> 1; else if (bpp == 8) width = s->img_x; else { free(out); return epuc("bad bpp", "Corrupt BMP"); } pad = (-width)&3; for (j=0; j < (int) s->img_y; ++j) { for (i=0; i < (int) s->img_x; i += 2) { int v=get8(s),v2=0; if (bpp == 4) { v2 = v & 15; v >>= 4; } out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; if (i+1 == (int) s->img_x) break; v = (bpp == 8) ? get8(s) : v2; out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; } skip(s, pad); } } else { int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; int z = 0; int easy=0; skip(s, offset - 14 - hsz); if (bpp == 24) width = 3 * s->img_x; else if (bpp == 16) width = 2*s->img_x; else /* bpp = 32 and pad = 0 */ width=0; pad = (-width) & 3; if (bpp == 24) { easy = 1; } else if (bpp == 32) { if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) easy = 2; } if (!easy) { if (!mr || !mg || !mb) { free(out); return epuc("bad masks", "Corrupt BMP"); } // right shift amt to put high bit in position #7 rshift = high_bit(mr)-7; rcount = bitcount(mr); gshift = high_bit(mg)-7; gcount = bitcount(mg); bshift = high_bit(mb)-7; bcount = bitcount(mb); ashift = high_bit(ma)-7; acount = bitcount(ma); } for (j=0; j < (int) s->img_y; ++j) { if (easy) { for (i=0; i < (int) s->img_x; ++i) { int a; out[z+2] = get8u(s); out[z+1] = get8u(s); out[z+0] = get8u(s); z += 3; a = (easy == 2 ? get8(s) : 255); if (target == 4) out[z++] = (stbi__uint8) a; } } else { for (i=0; i < (int) s->img_x; ++i) { stbi__uint32 v = (stbi__uint32) (bpp == 16 ? get16le(s) : get32le(s)); int a; out[z++] = (stbi__uint8) shiftsigned(v & mr, rshift, rcount); out[z++] = (stbi__uint8) shiftsigned(v & mg, gshift, gcount); out[z++] = (stbi__uint8) shiftsigned(v & mb, bshift, bcount); a = (ma ? shiftsigned(v & ma, ashift, acount) : 255); if (target == 4) out[z++] = (stbi__uint8) a; } } skip(s, pad); } } if (flip_vertically) { stbi_uc t; for (j=0; j < (int) s->img_y>>1; ++j) { stbi_uc *p1 = out + j *s->img_x*target; stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; for (i=0; i < (int) s->img_x*target; ++i) { t = p1[i], p1[i] = p2[i], p2[i] = t; } } } if (req_comp && req_comp != target) { out = convert_format(out, target, req_comp, s->img_x, s->img_y); if (out == NULL) return out; // convert_format frees input on failure } *x = s->img_x; *y = s->img_y; if (comp) *comp = s->img_n; return out; } static stbi_uc *stbi_bmp_load(stbi *s,int *x, int *y, int *comp, int req_comp) { return bmp_load(s, x,y,comp,req_comp); } // Targa Truevision - TGA // by Jonathan Dummer static int tga_info(stbi *s, int *x, int *y, int *comp) { int tga_w, tga_h, tga_comp; int sz; get8u(s); // discard Offset sz = get8u(s); // color type if( sz > 1 ) { stbi_rewind(s); return 0; // only RGB or indexed allowed } sz = get8u(s); // image type // only RGB or grey allowed, +/- RLE if ((sz != 1) && (sz != 2) && (sz != 3) && (sz != 9) && (sz != 10) && (sz != 11)) return 0; skip(s,9); tga_w = get16le(s); if( tga_w < 1 ) { stbi_rewind(s); return 0; // test width } tga_h = get16le(s); if( tga_h < 1 ) { stbi_rewind(s); return 0; // test height } sz = get8(s); // bits per pixel // only RGB or RGBA or grey allowed if ((sz != 8) && (sz != 16) && (sz != 24) && (sz != 32)) { stbi_rewind(s); return 0; } tga_comp = sz; if (x) *x = tga_w; if (y) *y = tga_h; if (comp) *comp = tga_comp / 8; return 1; // seems to have passed everything } int stbi_tga_info(stbi *s, int *x, int *y, int *comp) { return tga_info(s, x, y, comp); } static int tga_test(stbi *s) { int sz; get8u(s); // discard Offset sz = get8u(s); // color type if ( sz > 1 ) return 0; // only RGB or indexed allowed sz = get8u(s); // image type if ( (sz != 1) && (sz != 2) && (sz != 3) && (sz != 9) && (sz != 10) && (sz != 11) ) return 0; // only RGB or grey allowed, +/- RLE get16(s); // discard palette start get16(s); // discard palette length get8(s); // discard bits per palette color entry get16(s); // discard x origin get16(s); // discard y origin if ( get16(s) < 1 ) return 0; // test width if ( get16(s) < 1 ) return 0; // test height sz = get8(s); // bits per pixel if ( (sz != 8) && (sz != 16) && (sz != 24) && (sz != 32) ) return 0; // only RGB or RGBA or grey allowed return 1; // seems to have passed everything } static int stbi_tga_test(stbi *s) { int res = tga_test(s); stbi_rewind(s); return res; } static stbi_uc *tga_load(stbi *s, int *x, int *y, int *comp, int req_comp) { // read in the TGA header stuff int tga_offset = get8u(s); int tga_indexed = get8u(s); int tga_image_type = get8u(s); int tga_is_RLE = 0; int tga_palette_start = get16le(s); int tga_palette_len = get16le(s); int tga_palette_bits = get8u(s); int tga_x_origin = get16le(s); int tga_y_origin = get16le(s); int tga_width = get16le(s); int tga_height = get16le(s); int tga_bits_per_pixel = get8u(s); int tga_comp = tga_bits_per_pixel / 8; int tga_inverted = get8u(s); // image data unsigned char *tga_data; unsigned char *tga_palette = NULL; int i, j; unsigned char raw_data[4]; int RLE_count = 0; int RLE_repeating = 0; int read_next_pixel = 1; // do a tiny bit of precessing if ( tga_image_type >= 8 ) { tga_image_type -= 8; tga_is_RLE = 1; } /* int tga_alpha_bits = tga_inverted & 15; */ tga_inverted = 1 - ((tga_inverted >> 5) & 1); // error check if ( //(tga_indexed) || (tga_width < 1) || (tga_height < 1) || (tga_image_type < 1) || (tga_image_type > 3) || ((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16) && (tga_bits_per_pixel != 24) && (tga_bits_per_pixel != 32)) ) { return NULL; // we don't report this as a bad TGA because we don't even know if it's TGA } // If I'm paletted, then I'll use the number of bits from the palette if ( tga_indexed ) { tga_comp = tga_palette_bits / 8; } // tga info *x = tga_width; *y = tga_height; if (comp) *comp = tga_comp; tga_data = (unsigned char*)malloc( tga_width * tga_height * req_comp ); if (!tga_data) return epuc("outofmem", "Out of memory"); // skip to the data's starting position (offset usually = 0) skip(s, tga_offset ); if ( !tga_indexed && !tga_is_RLE) { for (i=0; i < tga_height; ++i) { int y = tga_inverted ? tga_height -i - 1 : i; stbi__uint8 *tga_row = tga_data + y*tga_width*tga_comp; getn(s, tga_row, tga_width * tga_comp); } } else { // do I need to load a palette? if ( tga_indexed) { // any data to skip? (offset usually = 0) skip(s, tga_palette_start ); // load the palette tga_palette = (unsigned char*)malloc( tga_palette_len * tga_palette_bits / 8 ); if (!tga_palette) { free(tga_data); return epuc("outofmem", "Out of memory"); } if (!getn(s, tga_palette, tga_palette_len * tga_palette_bits / 8 )) { free(tga_data); free(tga_palette); return epuc("bad palette", "Corrupt TGA"); } } // load the data for (i=0; i < tga_width * tga_height; ++i) { // if I'm in RLE mode, do I need to get a RLE chunk? if ( tga_is_RLE ) { if ( RLE_count == 0 ) { // yep, get the next byte as a RLE command int RLE_cmd = get8u(s); RLE_count = 1 + (RLE_cmd & 127); RLE_repeating = RLE_cmd >> 7; read_next_pixel = 1; } else if ( !RLE_repeating ) { read_next_pixel = 1; } } else { read_next_pixel = 1; } // OK, if I need to read a pixel, do it now if ( read_next_pixel ) { // load however much data we did have if ( tga_indexed ) { // read in 1 byte, then perform the lookup int pal_idx = get8u(s); if ( pal_idx >= tga_palette_len ) { // invalid index pal_idx = 0; } pal_idx *= tga_bits_per_pixel / 8; for (j = 0; j*8 < tga_bits_per_pixel; ++j) { raw_data[j] = tga_palette[pal_idx+j]; } } else { // read in the data raw for (j = 0; j*8 < tga_bits_per_pixel; ++j) { raw_data[j] = get8u(s); } } // clear the reading flag for the next pixel read_next_pixel = 0; } // end of reading a pixel // copy data for (j = 0; j < tga_comp; ++j) tga_data[i*tga_comp+j] = raw_data[j]; // in case we're in RLE mode, keep counting down --RLE_count; } // do I need to invert the image? if ( tga_inverted ) { for (j = 0; j*2 < tga_height; ++j) { int index1 = j * tga_width * req_comp; int index2 = (tga_height - 1 - j) * tga_width * req_comp; for (i = tga_width * req_comp; i > 0; --i) { unsigned char temp = tga_data[index1]; tga_data[index1] = tga_data[index2]; tga_data[index2] = temp; ++index1; ++index2; } } } // clear my palette, if I had one if ( tga_palette != NULL ) { free( tga_palette ); } } // swap RGB if (tga_comp >= 3) { unsigned char* tga_pixel = tga_data; for (i=0; i < tga_width * tga_height; ++i) { unsigned char temp = tga_pixel[0]; tga_pixel[0] = tga_pixel[2]; tga_pixel[2] = temp; tga_pixel += tga_comp; } } // convert to target component count if (req_comp && req_comp != tga_comp) tga_data = convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); // the things I do to get rid of an error message, and yet keep // Microsoft's C compilers happy... [8^( tga_palette_start = tga_palette_len = tga_palette_bits = tga_x_origin = tga_y_origin = 0; // OK, done return tga_data; } static stbi_uc *stbi_tga_load(stbi *s, int *x, int *y, int *comp, int req_comp) { return tga_load(s,x,y,comp,req_comp); } // ************************************************************************************************* // Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB static int psd_test(stbi *s) { if (get32(s) != 0x38425053) return 0; // "8BPS" else return 1; } static int stbi_psd_test(stbi *s) { int r = psd_test(s); stbi_rewind(s); return r; } static stbi_uc *psd_load(stbi *s, int *x, int *y, int *comp, int req_comp) { int pixelCount; int channelCount, compression; int channel, i, count, len; int w,h; stbi__uint8 *out; // Check identifier if (get32(s) != 0x38425053) // "8BPS" return epuc("not PSD", "Corrupt PSD image"); // Check file type version. if (get16(s) != 1) return epuc("wrong version", "Unsupported version of PSD image"); // Skip 6 reserved bytes. skip(s, 6 ); // Read the number of channels (R, G, B, A, etc). channelCount = get16(s); if (channelCount < 0 || channelCount > 16) return epuc("wrong channel count", "Unsupported number of channels in PSD image"); // Read the rows and columns of the image. h = get32(s); w = get32(s); // Make sure the depth is 8 bits. if (get16(s) != 8) return epuc("unsupported bit depth", "PSD bit depth is not 8 bit"); // Make sure the color mode is RGB. // Valid options are: // 0: Bitmap // 1: Grayscale // 2: Indexed color // 3: RGB color // 4: CMYK color // 7: Multichannel // 8: Duotone // 9: Lab color if (get16(s) != 3) return epuc("wrong color format", "PSD is not in RGB color format"); // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) skip(s,get32(s) ); // Skip the image resources. (resolution, pen tool paths, etc) skip(s, get32(s) ); // Skip the reserved data. skip(s, get32(s) ); // Find out if the data is compressed. // Known values: // 0: no compression // 1: RLE compressed compression = get16(s); if (compression > 1) return epuc("bad compression", "PSD has an unknown compression format"); // Create the destination image. out = (stbi_uc *) malloc(4 * w*h); if (!out) return epuc("outofmem", "Out of memory"); pixelCount = w*h; // Initialize the data to zero. //memset( out, 0, pixelCount * 4 ); // Finally, the image data. if (compression) { // RLE as used by .PSD and .TIFF // Loop until you get the number of unpacked bytes you are expecting: // Read the next source byte into n. // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. // Else if n is 128, noop. // Endloop // The RLE-compressed data is preceeded by a 2-byte data count for each row in the data, // which we're going to just skip. skip(s, h * channelCount * 2 ); // Read the RLE data by channel. for (channel = 0; channel < 4; channel++) { stbi__uint8 *p; p = out+channel; if (channel >= channelCount) { // Fill this channel with default data. for (i = 0; i < pixelCount; i++) *p = (channel == 3 ? 255 : 0), p += 4; } else { // Read the RLE data. count = 0; while (count < pixelCount) { len = get8(s); if (len == 128) { // No-op. } else if (len < 128) { // Copy next len+1 bytes literally. len++; count += len; while (len) { *p = get8u(s); p += 4; len--; } } else if (len > 128) { stbi__uint8 val; // Next -len+1 bytes in the dest are replicated from next source byte. // (Interpret len as a negative 8-bit int.) len ^= 0x0FF; len += 2; val = get8u(s); count += len; while (len) { *p = val; p += 4; len--; } } } } } } else { // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) // where each channel consists of an 8-bit value for each pixel in the image. // Read the data by channel. for (channel = 0; channel < 4; channel++) { stbi__uint8 *p; p = out + channel; if (channel > channelCount) { // Fill this channel with default data. for (i = 0; i < pixelCount; i++) *p = channel == 3 ? 255 : 0, p += 4; } else { // Read the data. for (i = 0; i < pixelCount; i++) *p = get8u(s), p += 4; } } } if (req_comp && req_comp != 4) { out = convert_format(out, 4, req_comp, w, h); if (out == NULL) return out; // convert_format frees input on failure } if (comp) *comp = channelCount; *y = h; *x = w; return out; } static stbi_uc *stbi_psd_load(stbi *s, int *x, int *y, int *comp, int req_comp) { return psd_load(s,x,y,comp,req_comp); } // ************************************************************************************************* // Softimage PIC loader // by Tom Seddon // // See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format // See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ static int pic_is4(stbi *s,const char *str) { int i; for (i=0; i<4; ++i) if (get8(s) != (stbi_uc)str[i]) return 0; return 1; } static int pic_test(stbi *s) { int i; if (!pic_is4(s,"\x53\x80\xF6\x34")) return 0; for(i=0;i<84;++i) get8(s); if (!pic_is4(s,"PICT")) return 0; return 1; } typedef struct { stbi_uc size,type,channel; } pic_packet_t; static stbi_uc *pic_readval(stbi *s, int channel, stbi_uc *dest) { int mask=0x80, i; for (i=0; i<4; ++i, mask>>=1) { if (channel & mask) { if (at_eof(s)) return epuc("bad file","PIC file too short"); dest[i]=get8u(s); } } return dest; } static void pic_copyval(int channel,stbi_uc *dest,const stbi_uc *src) { int mask=0x80,i; for (i=0;i<4; ++i, mask>>=1) if (channel&mask) dest[i]=src[i]; } static stbi_uc *pic_load2(stbi *s,int width,int height,int *comp, stbi_uc *result) { int act_comp=0,num_packets=0,y,chained; pic_packet_t packets[10]; // this will (should...) cater for even some bizarre stuff like having data // for the same channel in multiple packets. do { pic_packet_t *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return epuc("bad format","too many packets"); packet = &packets[num_packets++]; chained = get8(s); packet->size = get8u(s); packet->type = get8u(s); packet->channel = get8u(s); act_comp |= packet->channel; if (at_eof(s)) return epuc("bad file","file too short (reading packets)"); if (packet->size != 8) return epuc("bad format","packet isn't 8bpp"); } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? for(y=0; ytype) { default: return epuc("bad format","packet has bad compression type"); case 0: {//uncompressed int x; for(x=0;xchannel,dest)) return 0; break; } case 1://Pure RLE { int left=width, i; while (left>0) { stbi_uc count,value[4]; count=get8u(s); if (at_eof(s)) return epuc("bad file","file too short (pure read count)"); if (count > left) count = (stbi__uint8) left; if (!pic_readval(s,packet->channel,value)) return 0; for(i=0; ichannel,dest,value); left -= count; } } break; case 2: {//Mixed RLE int left=width; while (left>0) { int count = get8(s), i; if (at_eof(s)) return epuc("bad file","file too short (mixed read count)"); if (count >= 128) { // Repeated stbi_uc value[4]; int i; if (count==128) count = get16(s); else count -= 127; if (count > left) return epuc("bad file","scanline overrun"); if (!pic_readval(s,packet->channel,value)) return 0; for(i=0;ichannel,dest,value); } else { // Raw ++count; if (count>left) return epuc("bad file","scanline overrun"); for(i=0;ichannel,dest)) return 0; } left-=count; } break; } } } } return result; } static stbi_uc *pic_load(stbi *s,int *px,int *py,int *comp,int req_comp) { stbi_uc *result; int i, x,y; for (i=0; i<92; ++i) get8(s); x = get16(s); y = get16(s); if (at_eof(s)) return epuc("bad file","file too short (pic header)"); if ((1 << 28) / x < y) return epuc("too large", "Image too large to decode"); get32(s); //skip `ratio' get16(s); //skip `fields' get16(s); //skip `pad' // intermediate buffer is RGBA result = (stbi_uc *) malloc(x*y*4); memset(result, 0xff, x*y*4); if (!pic_load2(s,x,y,comp, result)) { free(result); result=0; } *px = x; *py = y; if (req_comp == 0) req_comp = *comp; result=convert_format(result,4,req_comp,x,y); return result; } static int stbi_pic_test(stbi *s) { int r = pic_test(s); stbi_rewind(s); return r; } static stbi_uc *stbi_pic_load(stbi *s, int *x, int *y, int *comp, int req_comp) { return pic_load(s,x,y,comp,req_comp); } // ************************************************************************************************* // GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb typedef struct stbi_gif_lzw_struct { stbi__int16 prefix; stbi__uint8 first; stbi__uint8 suffix; } stbi_gif_lzw; typedef struct stbi_gif_struct { int w,h; stbi_uc *out; // output buffer (always 4 components) int flags, bgindex, ratio, transparent, eflags; stbi__uint8 pal[256][4]; stbi__uint8 lpal[256][4]; stbi_gif_lzw codes[4096]; stbi__uint8 *color_table; int parse, step; int lflags; int start_x, start_y; int max_x, max_y; int cur_x, cur_y; int line_size; } stbi_gif; static int gif_test(stbi *s) { int sz; if (get8(s) != 'G' || get8(s) != 'I' || get8(s) != 'F' || get8(s) != '8') return 0; sz = get8(s); if (sz != '9' && sz != '7') return 0; if (get8(s) != 'a') return 0; return 1; } static int stbi_gif_test(stbi *s) { int r = gif_test(s); stbi_rewind(s); return r; } static void stbi_gif_parse_colortable(stbi *s, stbi__uint8 pal[256][4], int num_entries, int transp) { int i; for (i=0; i < num_entries; ++i) { pal[i][2] = get8u(s); pal[i][1] = get8u(s); pal[i][0] = get8u(s); pal[i][3] = transp ? 0 : 255; } } static int stbi_gif_header(stbi *s, stbi_gif *g, int *comp, int is_info) { stbi__uint8 version; if (get8(s) != 'G' || get8(s) != 'I' || get8(s) != 'F' || get8(s) != '8') return e("not GIF", "Corrupt GIF"); version = get8u(s); if (version != '7' && version != '9') return e("not GIF", "Corrupt GIF"); if (get8(s) != 'a') return e("not GIF", "Corrupt GIF"); failure_reason = ""; g->w = get16le(s); g->h = get16le(s); g->flags = get8(s); g->bgindex = get8(s); g->ratio = get8(s); g->transparent = -1; if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments if (is_info) return 1; if (g->flags & 0x80) stbi_gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); return 1; } static int stbi_gif_info_raw(stbi *s, int *x, int *y, int *comp) { stbi_gif g; if (!stbi_gif_header(s, &g, comp, 1)) { stbi_rewind( s ); return 0; } if (x) *x = g.w; if (y) *y = g.h; return 1; } static void stbi_out_gif_code(stbi_gif *g, stbi__uint16 code) { stbi__uint8 *p, *c; // recurse to decode the prefixes, since the linked-list is backwards, // and working backwards through an interleaved image would be nasty if (g->codes[code].prefix >= 0) stbi_out_gif_code(g, g->codes[code].prefix); if (g->cur_y >= g->max_y) return; p = &g->out[g->cur_x + g->cur_y]; c = &g->color_table[g->codes[code].suffix * 4]; if (c[3] >= 128) { p[0] = c[2]; p[1] = c[1]; p[2] = c[0]; p[3] = c[3]; } g->cur_x += 4; if (g->cur_x >= g->max_x) { g->cur_x = g->start_x; g->cur_y += g->step; while (g->cur_y >= g->max_y && g->parse > 0) { g->step = (1 << g->parse) * g->line_size; g->cur_y = g->start_y + (g->step >> 1); --g->parse; } } } static stbi__uint8 *stbi_process_gif_raster(stbi *s, stbi_gif *g) { stbi__uint8 lzw_cs; stbi__int32 len, code; stbi__uint32 first; stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; stbi_gif_lzw *p; lzw_cs = get8u(s); clear = 1 << lzw_cs; first = 1; codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; bits = 0; valid_bits = 0; for (code = 0; code < clear; code++) { g->codes[code].prefix = -1; g->codes[code].first = (stbi__uint8) code; g->codes[code].suffix = (stbi__uint8) code; } // support no starting clear code avail = clear+2; oldcode = -1; len = 0; for(;;) { if (valid_bits < codesize) { if (len == 0) { len = get8(s); // start new block if (len == 0) return g->out; } --len; bits |= (stbi__int32) get8(s) << valid_bits; valid_bits += 8; } else { stbi__int32 code = bits & codemask; bits >>= codesize; valid_bits -= codesize; // @OPTIMIZE: is there some way we can accelerate the non-clear path? if (code == clear) { // clear code codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; avail = clear + 2; oldcode = -1; first = 0; } else if (code == clear + 1) { // end of stream code skip(s, len); while ((len = get8(s)) > 0) skip(s,len); return g->out; } else if (code <= avail) { if (first) return epuc("no clear code", "Corrupt GIF"); if (oldcode >= 0) { p = &g->codes[avail++]; if (avail > 4096) return epuc("too many codes", "Corrupt GIF"); p->prefix = (stbi__int16) oldcode; p->first = g->codes[oldcode].first; p->suffix = (code == avail) ? p->first : g->codes[code].first; } else if (code == avail) return epuc("illegal code in raster", "Corrupt GIF"); stbi_out_gif_code(g, (stbi__uint16) code); if ((avail & codemask) == 0 && avail <= 0x0FFF) { codesize++; codemask = (1 << codesize) - 1; } oldcode = code; } else { return epuc("illegal code in raster", "Corrupt GIF"); } } } } static void stbi_fill_gif_background(stbi_gif *g) { int i; stbi__uint8 *c = g->pal[g->bgindex]; // @OPTIMIZE: write a dword at a time for (i = 0; i < g->w * g->h * 4; i += 4) { stbi__uint8 *p = &g->out[i]; p[0] = c[2]; p[1] = c[1]; p[2] = c[0]; p[3] = c[3]; } } // this function is designed to support animated gifs, although stb_image doesn't support it static stbi__uint8 *stbi_gif_load_next(stbi *s, stbi_gif *g, int *comp, int req_comp) { int i; stbi__uint8 *old_out = 0; if (g->out == 0) { if (!stbi_gif_header(s, g, comp,0)) return 0; // failure_reason set by stbi_gif_header g->out = (stbi__uint8 *) malloc(4 * g->w * g->h); if (g->out == 0) return epuc("outofmem", "Out of memory"); stbi_fill_gif_background(g); } else { // animated-gif-only path if (((g->eflags & 0x1C) >> 2) == 3) { old_out = g->out; g->out = (stbi__uint8 *) malloc(4 * g->w * g->h); if (g->out == 0) return epuc("outofmem", "Out of memory"); memcpy(g->out, old_out, g->w*g->h*4); } } for (;;) { switch (get8(s)) { case 0x2C: /* Image Descriptor */ { stbi__int32 x, y, w, h; stbi__uint8 *o; x = get16le(s); y = get16le(s); w = get16le(s); h = get16le(s); if (((x + w) > (g->w)) || ((y + h) > (g->h))) return epuc("bad Image Descriptor", "Corrupt GIF"); g->line_size = g->w * 4; g->start_x = x * 4; g->start_y = y * g->line_size; g->max_x = g->start_x + w * 4; g->max_y = g->start_y + h * g->line_size; g->cur_x = g->start_x; g->cur_y = g->start_y; g->lflags = get8(s); if (g->lflags & 0x40) { g->step = 8 * g->line_size; // first interlaced spacing g->parse = 3; } else { g->step = g->line_size; g->parse = 0; } if (g->lflags & 0x80) { stbi_gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); g->color_table = (stbi__uint8 *) g->lpal; } else if (g->flags & 0x80) { for (i=0; i < 256; ++i) // @OPTIMIZE: reset only the previous transparent g->pal[i][3] = 255; if (g->transparent >= 0 && (g->eflags & 0x01)) g->pal[g->transparent][3] = 0; g->color_table = (stbi__uint8 *) g->pal; } else return epuc("missing color table", "Corrupt GIF"); o = stbi_process_gif_raster(s, g); if (o == NULL) return NULL; if (req_comp && req_comp != 4) o = convert_format(o, 4, req_comp, g->w, g->h); return o; } case 0x21: // Comment Extension. { int len; if (get8(s) == 0xF9) { // Graphic Control Extension. len = get8(s); if (len == 4) { g->eflags = get8(s); get16le(s); // delay g->transparent = get8(s); } else { skip(s, len); break; } } while ((len = get8(s)) != 0) skip(s, len); break; } case 0x3B: // gif stream termination code return (stbi__uint8 *) 1; default: return epuc("unknown code", "Corrupt GIF"); } } } static stbi_uc *stbi_gif_load(stbi *s, int *x, int *y, int *comp, int req_comp) { stbi__uint8 *u = 0; stbi_gif g={0}; u = stbi_gif_load_next(s, &g, comp, req_comp); if (u == (void *) 1) u = 0; // end of animated gif marker if (u) { *x = g.w; *y = g.h; } return u; } static int stbi_gif_info(stbi *s, int *x, int *y, int *comp) { return stbi_gif_info_raw(s,x,y,comp); } // ************************************************************************************************* // Radiance RGBE HDR loader // originally by Nicolas Schulz #ifndef STBI_NO_HDR static int hdr_test(stbi *s) { const char *signature = "#?RADIANCE\n"; int i; for (i=0; signature[i]; ++i) if (get8(s) != signature[i]) return 0; return 1; } static int stbi_hdr_test(stbi* s) { int r = hdr_test(s); stbi_rewind(s); return r; } #define HDR_BUFLEN 1024 static char *hdr_gettoken(stbi *z, char *buffer) { int len=0; char c = '\0'; c = (char) get8(z); while (!at_eof(z) && c != '\n') { buffer[len++] = c; if (len == HDR_BUFLEN-1) { // flush to end of line while (!at_eof(z) && get8(z) != '\n') ; break; } c = (char) get8(z); } buffer[len] = 0; return buffer; } static void hdr_convert(float *output, stbi_uc *input, int req_comp) { if ( input[3] != 0 ) { float f1; // Exponent f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); if (req_comp <= 2) output[0] = (input[0] + input[1] + input[2]) * f1 / 3; else { output[0] = input[0] * f1; output[1] = input[1] * f1; output[2] = input[2] * f1; } if (req_comp == 2) output[1] = 1; if (req_comp == 4) output[3] = 1; } else { switch (req_comp) { case 4: output[3] = 1; /* fallthrough */ case 3: output[0] = output[1] = output[2] = 0; break; case 2: output[1] = 1; /* fallthrough */ case 1: output[0] = 0; break; } } } static float *hdr_load(stbi *s, int *x, int *y, int *comp, int req_comp) { char buffer[HDR_BUFLEN]; char *token; int valid = 0; int width, height; stbi_uc *scanline; float *hdr_data; int len; unsigned char count, value; int i, j, k, c1,c2, z; // Check identifier if (strcmp(hdr_gettoken(s,buffer), "#?RADIANCE") != 0) return epf("not HDR", "Corrupt HDR image"); // Parse header for(;;) { token = hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) return epf("unsupported format", "Unsupported HDR format"); // Parse width and height // can't use sscanf() if we're not using stdio! token = hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) return epf("unsupported data layout", "Unsupported HDR format"); token += 3; height = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) return epf("unsupported data layout", "Unsupported HDR format"); token += 3; width = (int) strtol(token, NULL, 10); *x = width; *y = height; *comp = 3; if (req_comp == 0) req_comp = 3; // Read data hdr_data = (float *) malloc(height * width * req_comp * sizeof(float)); // Load image data // image data is stored as some number of sca if ( width < 8 || width >= 32768) { // Read flat data for (j=0; j < height; ++j) { for (i=0; i < width; ++i) { stbi_uc rgbe[4]; main_decode_loop: getn(s, rgbe, 4); hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); } } } else { // Read RLE-encoded data scanline = NULL; for (j = 0; j < height; ++j) { c1 = get8(s); c2 = get8(s); len = get8(s); if (c1 != 2 || c2 != 2 || (len & 0x80)) { // not run-length encoded, so we have to actually use THIS data as a decoded // pixel (note this can't be a valid pixel--one of RGB must be >= 128) stbi__uint8 rgbe[4]; rgbe[0] = (stbi__uint8) c1; rgbe[1] = (stbi__uint8) c2; rgbe[2] = (stbi__uint8) len; rgbe[3] = (stbi__uint8) get8u(s); hdr_convert(hdr_data, rgbe, req_comp); i = 1; j = 0; free(scanline); goto main_decode_loop; // yes, this makes no sense } len <<= 8; len |= get8(s); if (len != width) { free(hdr_data); free(scanline); return epf("invalid decoded scanline length", "corrupt HDR"); } if (scanline == NULL) scanline = (stbi_uc *) malloc(width * 4); for (k = 0; k < 4; ++k) { i = 0; while (i < width) { count = get8u(s); if (count > 128) { // Run value = get8u(s); count -= 128; for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = value; } else { // Dump for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = get8u(s); } } } for (i=0; i < width; ++i) hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); } free(scanline); } return hdr_data; } static float *stbi_hdr_load(stbi *s, int *x, int *y, int *comp, int req_comp) { return hdr_load(s,x,y,comp,req_comp); } static int stbi_hdr_info(stbi *s, int *x, int *y, int *comp) { char buffer[HDR_BUFLEN]; char *token; int valid = 0; if (strcmp(hdr_gettoken(s,buffer), "#?RADIANCE") != 0) { stbi_rewind( s ); return 0; } for(;;) { token = hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) { stbi_rewind( s ); return 0; } token = hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) { stbi_rewind( s ); return 0; } token += 3; *y = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) { stbi_rewind( s ); return 0; } token += 3; *x = (int) strtol(token, NULL, 10); *comp = 3; return 1; } #endif // STBI_NO_HDR static int stbi_bmp_info(stbi *s, int *x, int *y, int *comp) { int hsz; if (get8(s) != 'B' || get8(s) != 'M') { stbi_rewind( s ); return 0; } skip(s,12); hsz = get32le(s); if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108) { stbi_rewind( s ); return 0; } if (hsz == 12) { *x = get16le(s); *y = get16le(s); } else { *x = get32le(s); *y = get32le(s); } if (get16le(s) != 1) { stbi_rewind( s ); return 0; } *comp = get16le(s) / 8; return 1; } static int stbi_psd_info(stbi *s, int *x, int *y, int *comp) { int channelCount; if (get32(s) != 0x38425053) { stbi_rewind( s ); return 0; } if (get16(s) != 1) { stbi_rewind( s ); return 0; } skip(s, 6); channelCount = get16(s); if (channelCount < 0 || channelCount > 16) { stbi_rewind( s ); return 0; } *y = get32(s); *x = get32(s); if (get16(s) != 8) { stbi_rewind( s ); return 0; } if (get16(s) != 3) { stbi_rewind( s ); return 0; } *comp = 4; return 1; } static int stbi_pic_info(stbi *s, int *x, int *y, int *comp) { int act_comp=0,num_packets=0,chained; pic_packet_t packets[10]; skip(s, 92); *x = get16(s); *y = get16(s); if (at_eof(s)) return 0; if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { stbi_rewind( s ); return 0; } skip(s, 8); do { pic_packet_t *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return 0; packet = &packets[num_packets++]; chained = get8(s); packet->size = get8u(s); packet->type = get8u(s); packet->channel = get8u(s); act_comp |= packet->channel; if (at_eof(s)) { stbi_rewind( s ); return 0; } if (packet->size != 8) { stbi_rewind( s ); return 0; } } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); return 1; } static int stbi_info_main(stbi *s, int *x, int *y, int *comp) { if (stbi_jpeg_info(s, x, y, comp)) return 1; if (stbi_png_info(s, x, y, comp)) return 1; if (stbi_gif_info(s, x, y, comp)) return 1; if (stbi_bmp_info(s, x, y, comp)) return 1; if (stbi_psd_info(s, x, y, comp)) return 1; if (stbi_pic_info(s, x, y, comp)) return 1; #ifndef STBI_NO_HDR if (stbi_hdr_info(s, x, y, comp)) return 1; #endif // test tga last because it's a crappy test! if (stbi_tga_info(s, x, y, comp)) return 1; return e("unknown image type", "Image not of any known type, or corrupt"); } #ifndef STBI_NO_STDIO int stbi_info(char const *filename, int *x, int *y, int *comp) { FILE *f = fopen(filename, "rb"); int result; if (!f) return e("can't fopen", "Unable to open file"); result = stbi_info_from_file(f, x, y, comp); fclose(f); return result; } int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) { int r; stbi s; long pos = ftell(f); start_file(&s, f); r = stbi_info_main(&s,x,y,comp); fseek(f,pos,SEEK_SET); return r; } #endif // !STBI_NO_STDIO int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) { stbi s; start_mem(&s,buffer,len); return stbi_info_main(&s,x,y,comp); } int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) { stbi s; start_callbacks(&s, (stbi_io_callbacks *) c, user); return stbi_info_main(&s,x,y,comp); } #endif // STBI_HEADER_FILE_ONLY #if !defined(STBI_NO_STDIO) && defined(_MSC_VER) && _MSC_VER >= 1400 #pragma warning(pop) #endif /* revision history: 1.35 (2014-05-27) various warnings fix broken STBI_SIMD path fix bug where stbi_load_from_file no longer left file pointer in correct place fix broken non-easy path for 32-bit BMP (possibly never used) TGA optimization by Arseny Kapoulkine 1.34 (unknown) use STBI_NOTUSED in resample_row_generic(), fix one more leak in tga failure case 1.33 (2011-07-14) make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements 1.32 (2011-07-13) support for "info" function for all supported filetypes (SpartanJ) 1.31 (2011-06-20) a few more leak fixes, bug in PNG handling (SpartanJ) 1.30 (2011-06-11) added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) removed deprecated format-specific test/load functions removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) fix inefficiency in decoding 32-bit BMP (David Woo) 1.29 (2010-08-16) various warning fixes from Aurelien Pocheville 1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ) 1.27 (2010-08-01) cast-to-stbi__uint8 to fix warnings 1.26 (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ 1.25 (2010-07-17) refix trans_data warning (Won Chun) 1.24 (2010-07-12) perf improvements reading from files on platforms with lock-heavy fgetc() minor perf improvements for jpeg deprecated type-specific functions so we'll get feedback if they're needed attempt to fix trans_data warning (Won Chun) 1.23 fixed bug in iPhone support 1.22 (2010-07-10) removed image *writing* support stbi_info support from Jetro Lauha GIF support from Jean-Marc Lienher iPhone PNG-extensions from James Brown warning-fixes from Nicolas Schulz and Janez Zemva (i.e. Janez (U+017D)emva) 1.21 fix use of 'stbi__uint8' in header (reported by jon blow) 1.20 added support for Softimage PIC, by Tom Seddon 1.19 bug in interlaced PNG corruption check (found by ryg) 1.18 2008-08-02 fix a threading bug (local mutable static) 1.17 support interlaced PNG 1.16 major bugfix - convert_format converted one too many pixels 1.15 initialize some fields for thread safety 1.14 fix threadsafe conversion bug header-file-only version (#define STBI_HEADER_FILE_ONLY before including) 1.13 threadsafe 1.12 const qualifiers in the API 1.11 Support installable IDCT, colorspace conversion routines 1.10 Fixes for 64-bit (don't use "unsigned long") optimized upsampling by Fabian "ryg" Giesen 1.09 Fix format-conversion for PSD code (bad global variables!) 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz 1.07 attempt to fix C++ warning/errors again 1.06 attempt to fix C++ warning/errors again 1.05 fix TGA loading to return correct *comp and use good luminance calc 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR 1.02 support for (subset of) HDR files, float interface for preferred access to them 1.01 fix bug: possible bug in handling right-side up bmps... not sure fix bug: the stbi_bmp_load() and stbi_tga_load() functions didn't work at all 1.00 interface to zlib that skips zlib header 0.99 correct handling of alpha in palette 0.98 TGA loader by lonesock; dynamically add loaders (untested) 0.97 jpeg errors on too large a file; also catch another malloc failure 0.96 fix detection of invalid v value - particleman@mollyrocket forum 0.95 during header scan, seek to markers in case of padding 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same 0.93 handle jpegtran output; verbose errors 0.92 read 4,8,16,24,32-bit BMP files of several formats 0.91 output 24-bit Windows 3.0 BMP files 0.90 fix a few more warnings; bump version number to approach 1.0 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd 0.60 fix compiling as c++ 0.59 fix warnings: merge Dave Moore's -Wall fixes 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available 0.56 fix bug: zlib uncompressed mode len vs. nlen 0.55 fix bug: restart_interval not initialized to 0 0.54 allow NULL for 'int *comp' 0.53 fix bug in png 3->4; speedup png decoding 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments 0.51 obey req_comp requests, 1-component jpegs return as 1-component, on 'test' only check type, not whether we support this variant 0.50 first released version */ uTox/third_party/stb/stb/deprecated/rrsprintf.h0000600000175000001440000010632214003056224020714 0ustar rakusers#ifndef RR_SPRINTF_H_INCLUDE #define RR_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 RR_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 rrsprintf( char * buf, char const * fmt, ... ) int rrsnprintf( char * buf, int count, char const * fmt, ... ) Convert an arg list into a buffer. rrsnprintf always returns a zero-terminated string (unlike regular snprintf). int rrvsprintf( char * buf, char const * fmt, va_list va ) int rrvsnprintf( char * buf, int count, char const * fmt, va_list va ) Convert a va_list arg list into a buffer. rrvsnprintf always returns a zero-terminated string (unlike regular snprintf). int rrvsprintfcb( RRSPRINTFCB * callback, void * user, char * buf, char const * fmt, va_list va ) typedef char * RRSPRINTFCB( char const * buf, void * user, int len ); Convert into a buffer, calling back every RR_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 RR_SPRINTF_MIN characters. // you return the next buffer to use or 0 to stop converting void rrsetseparators( 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 RR_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" 1024 is "1.0 k", "%$.2d" 2536000 is "2.42 m", etc. 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!) */ #ifdef RR_SPRINTF_STATIC #define RRPUBLIC_DEC static #define RRPUBLIC_DEF static #else #ifdef __cplusplus #define RRPUBLIC_DEC extern "C" #define RRPUBLIC_DEF extern "C" #else #define RRPUBLIC_DEC extern #define RRPUBLIC_DEF #endif #endif #include // for va_list() #ifndef RR_SPRINTF_MIN #define RR_SPRINTF_MIN 512 // how many characters per callback #endif typedef char * RRSPRINTFCB( char * buf, void * user, int len ); #ifndef RR_SPRINTF_DECORATE #define RR_SPRINTF_DECORATE(name) rr##name // define this before including if you want to change the names #endif #ifndef RR_SPRINTF_IMPLEMENTATION RRPUBLIC_DEF int RR_SPRINTF_DECORATE( vsprintf )( char * buf, char const * fmt, va_list va ); RRPUBLIC_DEF int RR_SPRINTF_DECORATE( vsnprintf )( char * buf, int count, char const * fmt, va_list va ); RRPUBLIC_DEF int RR_SPRINTF_DECORATE( sprintf ) ( char * buf, char const * fmt, ... ); RRPUBLIC_DEF int RR_SPRINTF_DECORATE( snprintf )( char * buf, int count, char const * fmt, ... ); RRPUBLIC_DEF int RR_SPRINTF_DECORATE( vsprintfcb )( RRSPRINTFCB * callback, void * user, char * buf, char const * fmt, va_list va ); RRPUBLIC_DEF void RR_SPRINTF_DECORATE( setseparators )( char comma, char period ); #else #include // for va_arg() #define rU32 unsigned int #define rS32 signed int #ifdef _MSC_VER #define rU64 unsigned __int64 #define rS64 signed __int64 #else #define rU64 unsigned long long #define rS64 signed long long #endif #define rU16 unsigned short #ifndef rUINTa #if defined(__ppc64__) || defined(__aarch64__) || defined(_M_X64) || defined(__x86_64__) || defined(__x86_64) #define rUINTa rU64 #else #define rUINTa rU32 #endif #endif #ifndef RR_SPRINTF_MSVC_MODE // used for MSVC2013 and earlier (MSVC2015 matches GCC) #if defined(_MSC_VER) && (_MSC_VER<1900) #define RR_SPRINTF_MSVC_MODE #endif #endif #ifdef RR_SPRINTF_NOUNALIGNED // define this before inclusion to force rrsprint to always use aligned accesses #define RR_UNALIGNED(code) #else #define RR_UNALIGNED(code) code #endif #ifndef RR_SPRINTF_NOFLOAT // internal float utility functions static rS32 rrreal_to_str( char const * * start, rU32 * len, char *out, rS32 * decimal_pos, double value, rU32 frac_digits ); static rS32 rrreal_to_parts( rS64 * bits, rS32 * expo, double value ); #define RRSPECIAL 0x7000 #endif static char RRperiod='.'; static char RRcomma=','; static char rrdiglookup[201]="00010203040506070809101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899"; RRPUBLIC_DEF void RR_SPRINTF_DECORATE( setseparators )( char pcomma, char pperiod ) { RRperiod=pperiod; RRcomma=pcomma; } RRPUBLIC_DEF int RR_SPRINTF_DECORATE( vsprintfcb )( RRSPRINTFCB * 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(;;) { rS32 fw,pr,tz; rU32 fl; #define LJ 1 #define LP 2 #define LS 4 #define LX 8 #define LZ 16 #define BI 32 #define CS 64 #define NG 128 #define KI 256 #define HW 512 // macros for the callback buffer stuff #define chk_cb_bufL(bytes) { int len = (int)(bf-buf); if ((len+(bytes))>=RR_SPRINTF_MIN) { tlen+=len; if (0==(bf=buf=callback(buf,user,len))) goto done; } } #define chk_cb_buf(bytes) { if ( callback ) { chk_cb_bufL(bytes); } } #define flush_cb() { chk_cb_bufL(RR_SPRINTF_MIN-1); } //flush if there is even one byte in the buffer #define cb_buf_clamp(cl,v) cl = v; if ( callback ) { int lg = RR_SPRINTF_MIN-(int)(bf-buf); if (cl>lg) cl=lg; } // fast copy everything up to the next % (or end of string) for(;;) { while (((rUINTa)f)&3) { schk1: if (f[0]=='%') goto scandd; schk2: if (f[0]==0) goto endfmt; chk_cb_buf(1); *bf++=f[0]; ++f; } for(;;) { rU32 v,c; v=*(rU32*)f; c=(~v)&0x80808080; if ((v-0x26262626)&c) goto schk1; if ((v-0x01010101)&c) goto schk2; if (callback) if ((RR_SPRINTF_MIN-(int)(bf-buf))<4) goto schk1; *(rU32*)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 just case '-': fl|=LJ; ++f; continue; // if we have leading plus case '+': fl|=LP; ++f; continue; // if we have leading space case ' ': fl|=LS; ++f; continue; // if we have leading 0x case '#': fl|=LX; ++f; continue; // if we have thousand commas case '\'': fl|=CS; ++f; continue; // if we have kilo marker case '$': fl|=KI; ++f; continue; // if we have leading zero case '0': fl|=LZ; ++f; goto flags_done; default: goto flags_done; } } flags_done: // get the field width if ( f[0] == '*' ) {fw = va_arg(va,rU32); ++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,rU32); ++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|=HW; ++f; break; // are we 64-bit (unix style) case 'l': ++f; if ( f[0]=='l') { fl|=BI; ++f; } break; // are we 64-bit on intmax? (c99) case 'j': fl|=BI; ++f; break; // are we 64-bit on size_t or ptrdiff_t? (c99) case 'z': case 't': fl|=((sizeof(char*)==8)?BI:0); ++f; break; // are we 64-bit (msft style) case 'I': if ( ( f[1]=='6') && ( f[2]=='4') ) { fl|=BI; f+=3; } else if ( ( f[1]=='3') && ( f[2]=='2') ) { f+=3; } else { fl|=((sizeof(void*)==8)?BI:0); ++f; } break; default: break; } // handle each replacement switch( f[0] ) { #define NUMSZ 512 // big enough for e308 (with commas) or e-307 char num[NUMSZ]; char lead[8]; char tail[8]; char *s; char const *h; rU32 l,n,cs; rU64 n64; #ifndef RR_SPRINTF_NOFLOAT double fv; #endif rS32 dp; char const * sn; case 's': // get the string s = va_arg(va,char*); if (s==0) s = (char*)"null"; // get the length sn = s; for(;;) { if ((((rUINTa)sn)&3)==0) break; lchk: if (sn[0]==0) goto ld; ++sn; } n = 0xffffffff; if (pr>=0) { n=(rU32)(sn-s); if (n>=(rU32)pr) goto ld; n=((rU32)(pr-n))>>2; } while(n) { rU32 v=*(rU32*)sn; if ((v-0x01010101)&(~v)&0x80808080UL) goto lchk; sn+=4; --n; } goto lchk; ld: l = (rU32) ( sn - s ); // clamp to precision if ( l > (rU32)pr ) l = pr; 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 + 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 RR_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; dp = 0; cs = 0; goto scopy; #else case 'A': // float h=hexu; goto hexfloat; case 'a': // hex float h=hex; hexfloat: fv = va_arg(va,double); if (pr==-1) pr=6; // default is 6 // read the double into a string if ( rrreal_to_parts( (rS64*)&n64, &dp, fv ) ) fl |= NG; s = num+64; // sign lead[0]=0; if (fl&NG) { lead[0]=1; lead[1]='-'; } else if (fl&LS) { lead[0]=1; lead[1]=' '; } else if (fl&LP) { lead[0]=1; lead[1]='+'; }; if (dp==-1023) dp=(n64)?-1022:0; else n64|=(((rU64)1)<<52); n64<<=(64-56); if (pr<15) n64+=((((rU64)8)<<56)>>(pr*4)); // add leading chars #ifdef RR_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++=RRperiod; sn = s; // print the bits n = pr; if (n>13) n = 13; if (pr>(rS32)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 h=hexu; goto dosmallfloat; case 'g': // float h=hex; dosmallfloat: 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 ( rrreal_to_str( &sn, &l, num, &dp, fv, (pr-1)|0x80000000 ) ) fl |= NG; // clamp the precision and delete extra zeros after clamp n = pr; if ( l > (rU32)pr ) l = pr; while ((l>1)&&(pr)&&(sn[l-1]=='0')) { --pr; --l; } // should we use %e if ((dp<=-4)||(dp>(rS32)n)) { if ( pr > (rS32)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 sematics for %f if(dp>0) { pr=(dp<(rS32)l)?l-dp:0; } else { pr = -dp+((pr>(rS32)l)?l:pr); } goto dofloatfromg; case 'E': // float h=hexu; goto doexp; case 'e': // float h=hex; doexp: fv = va_arg(va,double); if (pr==-1) pr=6; // default is 6 // read the double into a string if ( rrreal_to_str( &sn, &l, num, &dp, fv, pr|0x80000000 ) ) fl |= NG; doexpfromg: tail[0]=0; lead[0]=0; if (fl&NG) { lead[0]=1; lead[1]='-'; } else if (fl&LS) { lead[0]=1; lead[1]=' '; } else if (fl&LP) { lead[0]=1; lead[1]='+'; }; if ( dp == RRSPECIAL ) { s=(char*)sn; cs=0; pr=0; goto scopy; } s=num+64; // handle leading chars *s++=sn[0]; if (pr) *s++=RRperiod; // handle after decimal if ((l-1)>(rU32)pr) l=pr+1; for(n=1;n=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&KI) {while(fl<0x4000000) { if ((fv<1024.0) && (fv>-1024.0)) break; fv/=1024.0; fl+=0x1000000; }} if (pr==-1) pr=6; // default is 6 // read the double into a string if ( rrreal_to_str( &sn, &l, num, &dp, fv, pr ) ) fl |= NG; dofloatfromg: tail[0]=0; // sign lead[0]=0; if (fl&NG) { lead[0]=1; lead[1]='-'; } else if (fl&LS) { lead[0]=1; lead[1]=' '; } else if (fl&LP) { lead[0]=1; lead[1]='+'; }; if ( dp == RRSPECIAL ) { s=(char*)sn; cs=0; pr=0; goto scopy; } s=num+64; // handle the three decimal varieties if (dp<=0) { rS32 i; // handle 0.000*000xxxx *s++='0'; if (pr) *s++=RRperiod; n=-dp; if((rS32)n>pr) n=pr; i=n; while(i) { if ((((rUINTa)s)&3)==0) break; *s++='0'; --i; } while(i>=4) { *(rU32*)s=0x30303030; s+=4; i-=4; } while(i) { *s++='0'; --i; } if ((rS32)(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&CS)?((600-(rU32)dp)%3):0; if ((rU32)dp>=l) { // handle xxxx000*000.0 n=0; for(;;) { if ((fl&CS) && (++cs==4)) { cs = 0; *s++=RRcomma; } else { *s++=sn[n]; ++n; if (n>=l) break; } } if (n<(rU32)dp) { n = dp - n; if ((fl&CS)==0) { while(n) { if ((((rUINTa)s)&3)==0) break; *s++='0'; --n; } while(n>=4) { *(rU32*)s=0x30303030; s+=4; n-=4; } } while(n) { if ((fl&CS) && (++cs==4)) { cs = 0; *s++=RRcomma; } else { *s++='0'; --n; } } } cs = (int)(s-(num+64)) + (3<<24); // cs is how many tens if (pr) { *s++=RRperiod; tz=pr;} } else { // handle xxxxx.xxxx000*000 n=0; for(;;) { if ((fl&CS) && (++cs==4)) { cs = 0; *s++=RRcomma; } else { *s++=sn[n]; ++n; if (n>=(rU32)dp) break; } } cs = (int)(s-(num+64)) + (3<<24); // cs is how many tens if (pr) *s++=RRperiod; if ((l-dp)>(rU32)pr) l=pr+dp; while(n>24) { tail[2]="_kmgt"[fl>>24]; tail[0]=2; } } }; flt_lead: // get the length that we copied l = (rU32) ( s-(num+64) ); s=num+64; goto scopy; #endif case 'B': // upper binary h = hexu; goto binary; case 'b': // lower binary h = hex; binary: lead[0]=0; if (fl&LX) { 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&LX) { lead[0]=1;lead[1]='0'; } l=(3<<4)|(3<<8); goto radixnum; case 'p': // pointer fl |= (sizeof(void*)==8)?BI:0; pr = sizeof(void*)*2; fl &= ~LZ; // 'p' only prints the pointer with zeros // drop through to X case 'X': // upper binary h = hexu; goto dohexb; case 'x': // lower binary h = hex; dohexb: l=(4<<4)|(4<<8); lead[0]=0; if (fl&LX) { lead[0]=2;lead[1]='0';lead[2]=h[16]; } radixnum: // get the number if ( fl&BI ) n64 = va_arg(va,rU64); else n64 = va_arg(va,rU32); s = num + 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 = ( ((l>>4)&15)) << 24; goto scopy; } } // convert to string for(;;) { *--s = h[n64&((1<<(l>>8))-1)]; n64>>=(l>>8); if ( ! ( (n64) || ((rS32) ( (num+NUMSZ) - s ) < pr ) ) ) break; if ( fl&CS) { ++l; if ((l&15)==((l>>4)&15)) { l&=~15; *--s=RRcomma; } } }; // get the tens and the comma pos cs = (rU32) ( (num+NUMSZ) - s ) + ( ( ((l>>4)&15)) << 24 ); // get the length that we copied l = (rU32) ( (num+NUMSZ) - s ); // copy it goto scopy; case 'u': // unsigned case 'i': case 'd': // integer // get the integer and abs it if ( fl&BI ) { rS64 i64 = va_arg(va,rS64); n64 = (rU64)i64; if ((f[0]!='u') && (i64<0)) { n64=(rU64)-i64; fl|=NG; } } else { rS32 i = va_arg(va,rS32); n64 = (rU32)i; if ((f[0]!='u') && (i<0)) { n64=(rU32)-i; fl|=NG; } } #ifndef RR_SPRINTF_NOFLOAT if (fl&KI) { if (n64<1024) pr=0; else if (pr==-1) pr=1; fv=(double)(rS64)n64; goto doafloat; } #endif // convert to string s = num+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 = (rU32)( n64 % 100000000); n64 /= 100000000; } else {n = (rU32)n64; n64 = 0; } if((fl&CS)==0) { while(n) { s-=2; *(rU16*)s=*(rU16*)&rrdiglookup[(n%100)*2]; n/=100; } } while (n) { if ( ( fl&CS) && (l++==3) ) { l=0; *--s=RRcomma; --o; } else { *--s=(char)(n%10)+'0'; n/=10; } } if (n64==0) { if ((s[0]=='0') && (s!=(num+NUMSZ))) ++s; break; } while (s!=o) if ( ( fl&CS) && (l++==3) ) { l=0; *--s=RRcomma; --o; } else { *--s='0'; } } tail[0]=0; // sign lead[0]=0; if (fl&NG) { lead[0]=1; lead[1]='-'; } else if (fl&LS) { lead[0]=1; lead[1]=' '; } else if (fl&LP) { lead[0]=1; lead[1]='+'; }; // get the length that we copied l = (rU32) ( (num+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<(rS32)l) pr = l; n = pr + lead[0] + tail[0] + tz; if (fw<(rS32)n) fw = n; fw -= n; pr -= l; // handle right justify and leading zeros if ( (fl&LJ)==0 ) { if (fl&LZ) // if leading zeros, everything is in pr { pr = (fw>pr)?fw:pr; fw = 0; } else { fl &= ~CS; // if no leading zeros, then no commas } } // copy the spaces and/or zeros if (fw+pr) { rS32 i; rU32 c; // copy leading spaces (or when doing %8.4d stuff) if ( (fl&LJ)==0 ) while(fw>0) { cb_buf_clamp(i,fw); fw -= i; while(i) { if ((((rUINTa)bf)&3)==0) break; *bf++=' '; --i; } while(i>=4) { *(rU32*)bf=0x20202020; bf+=4; i-=4; } while (i) {*bf++=' '; --i;} chk_cb_buf(1); } // copy leader sn=lead+1; while(lead[0]) { cb_buf_clamp(i,lead[0]); lead[0] -= (char)i; while (i) {*bf++=*sn++; --i;} chk_cb_buf(1); } // copy leading zeros c = cs >> 24; cs &= 0xffffff; cs = (fl&CS)?((rU32)(c-((pr+cs)%(c+1)))):0; while(pr>0) { cb_buf_clamp(i,pr); pr -= i; if((fl&CS)==0) { while(i) { if ((((rUINTa)bf)&3)==0) break; *bf++='0'; --i; } while(i>=4) { *(rU32*)bf=0x30303030; bf+=4; i-=4; } } while (i) { if((fl&CS) && (cs++==c)) { cs = 0; *bf++=RRcomma; } else *bf++='0'; --i; } chk_cb_buf(1); } } // copy leader if there is still one sn=lead+1; while(lead[0]) { rS32 i; cb_buf_clamp(i,lead[0]); lead[0] -= (char)i; while (i) {*bf++=*sn++; --i;} chk_cb_buf(1); } // copy the string n = l; while (n) { rS32 i; cb_buf_clamp(i,n); n-=i; RR_UNALIGNED( while(i>=4) { *(rU32*)bf=*(rU32*)s; bf+=4; s+=4; i-=4; } ) while (i) {*bf++=*s++; --i;} chk_cb_buf(1); } // copy trailing zeros while(tz) { rS32 i; cb_buf_clamp(i,tz); tz -= i; while(i) { if ((((rUINTa)bf)&3)==0) break; *bf++='0'; --i; } while(i>=4) { *(rU32*)bf=0x30303030; bf+=4; i-=4; } while (i) {*bf++='0'; --i;} chk_cb_buf(1); } // copy tail if there is one sn=tail+1; while(tail[0]) { rS32 i; cb_buf_clamp(i,tail[0]); tail[0] -= (char)i; while (i) {*bf++=*sn++; --i;} chk_cb_buf(1); } // handle the left justify if (fl&LJ) if (fw>0) { while (fw) { rS32 i; cb_buf_clamp(i,fw); fw-=i; while(i) { if ((((rUINTa)bf)&3)==0) break; *bf++=' '; --i; } while(i>=4) { *(rU32*)bf=0x20202020; bf+=4; i-=4; } while (i--) *bf++=' '; chk_cb_buf(1); } } break; default: // unknown, just copy code s = num + NUMSZ -1; *s = f[0]; l = 1; fw=pr=fl=0; lead[0]=0; tail[0]=0; pr = 0; dp = 0; cs = 0; goto scopy; } ++f; } endfmt: if (!callback) *bf = 0; else flush_cb(); done: return tlen + (int)(bf-buf); } // cleanup #undef LJ #undef LP #undef LS #undef LX #undef LZ #undef BI #undef CS #undef NG #undef KI #undef NUMSZ #undef chk_cb_bufL #undef chk_cb_buf #undef flush_cb #undef cb_buf_clamp // ============================================================================ // wrapper functions RRPUBLIC_DEF int RR_SPRINTF_DECORATE( sprintf )( char * buf, char const * fmt, ... ) { va_list va; va_start( va, fmt ); return RR_SPRINTF_DECORATE( vsprintfcb )( 0, 0, buf, fmt, va ); } typedef struct RRCCS { char * buf; int count; char tmp[ RR_SPRINTF_MIN ]; } RRCCS; static char * rrclampcallback( char * buf, void * user, int len ) { RRCCS * c = (RRCCS*)user; if ( len > c->count ) len = c->count; if (len) { if ( buf != c->buf ) { char * s, * d, * se; d = c->buf; s = buf; se = buf+len; do{ *d++ = *s++; } while (sbuf += len; c->count -= len; } if ( c->count <= 0 ) return 0; return ( c->count >= RR_SPRINTF_MIN ) ? c->buf : c->tmp; // go direct into buffer if you can } RRPUBLIC_DEF int RR_SPRINTF_DECORATE( vsnprintf )( char * buf, int count, char const * fmt, va_list va ) { RRCCS c; int l; if ( count == 0 ) return 0; c.buf = buf; c.count = count; RR_SPRINTF_DECORATE( vsprintfcb )( rrclampcallback, &c, rrclampcallback(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 l; } RRPUBLIC_DEF int RR_SPRINTF_DECORATE( snprintf )( char * buf, int count, char const * fmt, ... ) { va_list va; va_start( va, fmt ); return RR_SPRINTF_DECORATE( vsnprintf )( buf, count, fmt, va ); } RRPUBLIC_DEF int RR_SPRINTF_DECORATE( vsprintf )( char * buf, char const * fmt, va_list va ) { return RR_SPRINTF_DECORATE( vsprintfcb )( 0, 0, buf, fmt, va ); } // ======================================================================= // low level float utility functions #ifndef RR_SPRINTF_NOFLOAT // copies d to bits w/ strict aliasing (this compiles to nothing on /Ox) #define RRCOPYFP(dest,src) { int cn; for(cn=0;cn<8;cn++) ((char*)&dest)[cn]=((char*)&src)[cn]; } // get float info static rS32 rrreal_to_parts( rS64 * bits, rS32 * expo, double value ) { double d; rS64 b = 0; // load value and round at the frac_digits d = value; RRCOPYFP( b, d ); *bits = b & ((((rU64)1)<<52)-1); *expo = ((b >> 52) & 2047)-1023; return (rS32)(b >> 63); } static double const rrbot[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 rrnegbot[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 rrnegboterr[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 rrtop[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 rrnegtop[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 rrtoperr[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 rrnegtoperr[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 rU64 const rrpot[20]={1,10,100,1000, 10000,100000,1000000,10000000, 100000000,1000000000,10000000000,100000000000, 1000000000000,10000000000000,100000000000000,1000000000000000, 10000000000000000,100000000000000000,1000000000000000000,10000000000000000000U }; #define rrtento19th ((rU64)1000000000000000000) #else static rU64 const rrpot[20]={1,10,100,1000, 10000,100000,1000000,10000000, 100000000,1000000000,10000000000ULL,100000000000ULL, 1000000000000ULL,10000000000000ULL,100000000000000ULL,1000000000000000ULL, 10000000000000000ULL,100000000000000000ULL,1000000000000000000ULL,10000000000000000000ULL }; #define rrtento19th (1000000000000000000ULL) #endif #define rrddmulthi(oh,ol,xh,yh) \ { \ double ahi=0,alo,bhi=0,blo; \ rS64 bt; \ oh = xh * yh; \ RRCOPYFP(bt,xh); bt&=((~(rU64)0)<<27); RRCOPYFP(ahi,bt); alo = xh-ahi; \ RRCOPYFP(bt,yh); bt&=((~(rU64)0)<<27); RRCOPYFP(bhi,bt); blo = yh-bhi; \ ol = ((ahi*bhi-oh)+ahi*blo+alo*bhi)+alo*blo; \ } #define rrddtoS64(ob,xh,xl) \ { \ double ahi=0,alo,vh,t;\ ob = (rS64)ph;\ vh=(double)ob;\ ahi = ( xh - vh );\ t = ( ahi - xh );\ alo = (xh-(ahi-t))-(vh+t);\ ob += (rS64)(ahi+alo+xl);\ } #define rrddrenorm(oh,ol) { double s; s=oh+ol; ol=ol-(s-oh); oh=s; } #define rrddmultlo(oh,ol,xh,xl,yh,yl) \ ol = ol + ( xh*yl + xl*yh ); \ #define rrddmultlos(oh,ol,xh,yl) \ ol = ol + ( xh*yl ); \ static void rrraise_to_power10( double *ohi, double *olo, double d, rS32 power ) // power can be -323 to +350 { double ph, pl; if ((power>=0) && (power<=22)) { rrddmulthi(ph,pl,d,rrbot[power]); } else { rS32 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; rrddmulthi(ph,pl,d,rrnegbot[eb]); rrddmultlos(ph,pl,d,rrnegboterr[eb]); } if (et) { rrddrenorm(ph,pl); --et; rrddmulthi(p2h,p2l,ph,rrnegtop[et]); rrddmultlo(p2h,p2l,ph,pl,rrnegtop[et],rrnegtoperr[et]); ph=p2h;pl=p2l; } } else { if (eb) { e = eb; if (eb>22) eb=22; e -= eb; rrddmulthi(ph,pl,d,rrbot[eb]); if ( e ) { rrddrenorm(ph,pl); rrddmulthi(p2h,p2l,ph,rrbot[e]); rrddmultlos(p2h,p2l,rrbot[e],pl); ph=p2h;pl=p2l; } } if (et) { rrddrenorm(ph,pl); --et; rrddmulthi(p2h,p2l,ph,rrtop[et]); rrddmultlo(p2h,p2l,ph,pl,rrtop[et],rrtoperr[et]); ph=p2h;pl=p2l; } } } rrddrenorm(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 rS32 rrreal_to_str( char const * * start, rU32 * len, char *out, rS32 * decimal_pos, double value, rU32 frac_digits ) { double d; rS64 bits = 0; rS32 expo, e, ng, tens; d = value; RRCOPYFP(bits,d); expo = (bits >> 52) & 2047; ng = (rS32)(bits >> 63); if (ng) d=-d; if ( expo == 2047 ) // is nan or inf? { *start = (bits&((((rU64)1)<<52)-1)) ? "NaN" : "Inf"; *decimal_pos = RRSPECIAL; *len = 3; return ng; } if ( expo == 0 ) // is zero or denormal { if ((bits<<1)==0) // do zero { *decimal_pos = 1; *start = out; out[0] = '0'; *len = 1; return ng; } // find the right expo for denormals { rS64 v = ((rU64)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 rrraise_to_power10( &ph, &pl, d, 18-tens ); // get full as much precision from double-double as possible rrddtoS64( bits, ph,pl ); // check if we undershot if ( ((rU64)bits) >= rrtento19th ) ++tens; } // now do the rounding in integer land frac_digits = ( frac_digits & 0x80000000 ) ? ( (frac_digits&0x7ffffff) + 1 ) : ( tens + frac_digits ); if ( ( frac_digits < 24 ) ) { rU32 dg = 1; if ((rU64)bits >= rrpot[9] ) dg=10; while( (rU64)bits >= rrpot[dg] ) { ++dg; if (dg==20) goto noround; } if ( frac_digits < dg ) { rU64 r; // add 0.5 at the right position and round e = dg - frac_digits; if ( (rU32)e >= 24 ) goto noround; r = rrpot[e]; bits = bits + (r/2); if ( (rU64)bits >= rrpot[dg] ) ++tens; bits /= r; } noround:; } // kill long trailing runs of zeros if ( bits ) { rU32 n; for(;;) { if ( bits<=0xffffffff ) break; if (bits%1000) goto donez; bits/=1000; } n = (rU32)bits; while ((n%1000)==0) n/=1000; bits=n; donez:; } // convert to string out += 64; e = 0; for(;;) { rU32 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 = (rU32)( bits % 100000000); bits /= 100000000; } else {n = (rU32)bits; bits = 0; } while(n) { out-=2; *(rU16*)out=*(rU16*)&rrdiglookup[(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 rrddmulthi #undef rrddrenorm #undef rrddmultlo #undef rrddmultlos #undef RRSPECIAL #undef RRCOPYFP #endif // clean up #undef rU16 #undef rU32 #undef rS32 #undef rU64 #undef rS64 #undef RRPUBLIC_DEC #undef RRPUBLIC_DEF #undef RR_SPRINTF_DECORATE #undef RR_UNALIGNED #endif #endif uTox/third_party/stb/stb/data/0000700000175000001440000000000014003056224015315 5ustar rakusersuTox/third_party/stb/stb/data/map_03.png0000600000175000001440000002262414003056224017112 0ustar rakusersPNG  IHDRZvt_%[IDATx^Ѳ먮(q.NήVw 6z`bIDZq8t4<:9Xj+>[̼ߚz>|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ʩ@@@@@@@!T@@@@@@:C @@@@@@@;;A@@@#    @d       !TN     <l@@@*     e@*B@@@@@@tvPY E   ptREI@?5s7j ZG:* ?' @'C й|SWOy7T5]Yp}G9>E! &. ~# +$V*5Y:  `08=ѹK =}*q˵X*sGveM/j7I\>OҎZ|wy Oز<5z-xwQ]'AP!";@ y4NHJG= OV*o|IMN宓Ԑi}?G=fהtbq{O+Ւ'z+?;е / lCG~/};ZzPU5Cg/ >~%'DK_@;m@ 6:Sf51eOW{ 1ݩ6 Iz@3j:2p,:@Mp8=RccYG* 堮 @/z&`8%r @Re/2$pWhBHcTgjA/)m剎'0G Pޕdo4/Z7U?{CS!1#\\L> (@0 @P@#.    6)  !T@@@@@2 !T@@`'     %W@gw!      tvP9       @gw@xOp@@@@@@: @@@@@@@7@es PpB      T@@@@@   T@@@"  @Nr7~N 6>P@0 - ߉-C#i[C+@{[00"!G0 [)A0 X@   @eK T.`h@ `@P@+$6GP`ڱ 0U ,LDΌ `*XlN  cϋ N@@Q(CN|CIENDB`uTox/third_party/stb/stb/data/map_01.png0000600000175000001440000007364114003056224017115 0ustar rakusersPNG  IHDRZvt_whIDATx^ٖp\C\,YFHJjhHɣ_LORJWsR 4{iJ/HH ϯ#! "+|$FSF[-h#v%YA~5p 0;^ɯF4f`*2[o[_=4IKC@4sćA\w@\ISvK m~ԲUa@@pAb2 ΉT,pЛm2A@ñ[>cxKA6Km5'i,0D ݥuJƺ@ߥWxM fj򭳺d6=fc݇r'(VwRq#b:v# d&m=x@@h {:PT )q{q@fńXVz]8_GcwCcav0x.%h1(}n^vݣN$0IdLJǟ_:)aXq,/4/d,-(|Afi.A8AC:UXӺ3]lv1clL4y{ĵ s4"7 u~H2غ< EHlgwXF2{tmcq? 5ߛЅE5ߦR>7ۦ;m8^?p1^?x*Tg'q[_-M_mJßV4"8QC.Kutְ ug 90 cB9nN韧J3;[`mW: UL i1VK|w먜3mPY.pinb$V)twBmcm<0q@gmctη]p 2NO2Q("߯\Ef7_}+9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>xiGDXS|QBV@2$Myr!:`B9 0Pu,Խώl{ӹ׆<xH('(\XLi(xe 0M\uoBL(&)1p G2u4&]?ŦgL@^*XmUWKgS%6Dne,.4שhL8))Z ٶPhCXzF] 0I BGu4%~Xd {%)qqg ~*+km\w2Sbs;阠mO6pBO q4X눟h\N53?lQY(Xq 0CbNHBZHgB~wi 7N$,> !Mbs{Gt.N`G7" }}&ܚV2|I01dX'-kpf,r=܈}6$)QqALW#rT7im<-c^`TgѪIENDB`uTox/third_party/stb/stb/data/herringbone/0000700000175000001440000000000014003056224017617 5ustar rakusersuTox/third_party/stb/stb/data/herringbone/template_square_rooms_with_random_rects.png0000600000175000001440000001124414003056224030536 0ustar rakusersPNG  IHDRl. pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!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1$'ca D $7*o6HZ/ :uB, O3Nź'lBaBRv-Rې5#{lH|chR\*J5TA7$O"$2=*u^"e 6e$t+zKtt1IgOXOvݯě=$;}XtKxԇ 5m1^o {!M/M id/axfBEL8 o dՊL, {@fO>828f#?/LF"ˏ7p|#f,kă6" $7#Y $1O'īik7Җm :6DBlQMz%R_:;c*Tߑ5cWyf,><$kuc'f!$T/w"G6ƨ d0aE$z2!" ہ ){d#H^sAd0IvaG#q> A8ąe;cSa&uնP.$4W6z1Ss<{o3&7w-G"$bx[XH.0yɊ5>1 7WS`MI\yq]l0YWjhlA(0A*+P}D d1B X5 XLO^f㓤fw,4t6] fX&#˧C"oFļR#mIǨR 7ZLDQٹَT T])6/3v[2g1e5e6CxvR~'" oC|Gz Up~>1B`Y%I H8a*LBG Qoz "M*b`!H侑.:Rkz&UhM#wR7A 7H0&~AJ]zc0bhG"9T ݩRPP6P(85`.h;}mz{Oxm:c%n<͹U6Zm~K81l~䣴T|,䍂YK#\A !U|e*|*cbP~эj%"*$٥Ʒ?ףN|h(0?׍hո&J&#tɌwӒd1F<]l#w![t7 N.IENDB`uTox/third_party/stb/stb/data/herringbone/template_sean_dungeon.png0000600000175000001440000002402514003056224024672 0ustar rakusersPNG  IHDR$l pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@q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;9..}p#T1gY$XwC*/kC^IBp#һ) R#Y[ip%/ O‹ȊG+ ~%SŊg=EV&IRE#榨:di)b㿉0tjaz~--aFQmwY:zKҴP6t*F !6exd q֡4hI^Bӹ  Wo!1WW* }vwLFCBj?}?7]nD共b-sZHBZlCI'bOOX|#Â:2%Ȳ1^d+1@6Ob(KzfYQkl gXP%ܞLLsL(10 b oVޛ FC/VY5>vO*SC*YfF(/fRpxܼV ru;k瞲r\\U9)qA]ZQp.}MZHYSf*Y[9[5GösElbzM(0 qÁ J\Px ENb;U4d۩%"0(wM#Y?Ζ{)C='GX*6d1*|nƷWCGǐPQpϿbК1̧vn2@Jݲ*VEC%$=l_lA줛55)T D%V4IM]nܰPjn>2\Ԍa<B݃0ʺڑCWWU;։&Ӂ4w-3F^ Wc_kȱ7h2IT=ZV݀gmxY IENDB`uTox/third_party/stb/stb/data/herringbone/template_rooms_limit_connectivity.png0000600000175000001440000001676014003056224027367 0ustar rakusersPNG  IHDR  pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'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}I3/4dK E:8-uprB\\WyBp~wtݹe`S!wJB(Sn=urloo[df<Qkϙp^]?2wouU%^vI,-91|N'؊gpw5d˃/AG:8![u4dKN5`NOC62$)E(Zx>j!e2w‘$;Z?VY[<-q`;&[vȖْɖْs 8qotF~/tV[|$I&[tId玥+h S9҇ lGcmݺuKȣ-:{4щ`}]ZG^&Aym,YɖE/-p$[Z۲#[W2! =Fܣn~O2VI,M`?ɖ<ƳtH?QbXKIENDB`uTox/third_party/stb/stb/data/herringbone/template_rooms_and_corridors_2_wide_diagonal_bias.png0000600000175000001440000001014114003056224032353 0ustar rakusersPNG  IHDRT[ pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6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O:wCj(姏$>N drK0u00PܚȲKb0s+0PK `] q*nXnX p(V-X@}M o-E(])Z!jJJꑲ9Y娿+ V0`ǦXQ͉lw*1*y1S*C)}P:bUOVͩXZ%Ep R!~S==FN6JX#h?LUe'h94% JǮbRGsItJr8 X(mF>ְܰ:+M9,CukVG)r:nX5xNR dnX$F}7:!{Kqb߸p k#tE߰ n mEUpޡUU^JRVqj},ܰ*cAB5b!bp(jT A5%TSR A Z,׽)ST8h#!z΂#`xi6Q!PR[K2e|I&,',BPVX l7Q)^VX2T5*ڌ+XчRer.X *m5n@U-<ұUd(XuhPLλh"lU5ojY$=`XU^JRVqXa*b\p(X]bQ A+Z!jJJ!葲9b%B?OÞƊBi{z2O_|KI\)mCmwn݉{GJ-ּ]\jDTP,ĥ(kAXY>ZNNJh"R PV"' * _e [RؽkDmw,X%RzMu)o)!O>,Oorr\ %p㐓ѭԸobr DJrBbUޣJ@a bUE/>FR8Iy~~>,?kR_0J dBܰV%, CsxC (e{E+XՔ2PJJj(e_zsoS/8KSxW"kr=`56:'c`v VYVa(V P,(XELT@OLʸnIENDB`uTox/third_party/stb/stb/data/herringbone/template_maze_plus_2_wide.png0000600000175000001440000003152514003056224025460 0ustar rakusersPNG  IHDRf2N pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(R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!bN!0z"9| $kHw 1riNI&#E/}h.r )kY1*dF<ӌL#`c< А `ܝ8 1#ye!8ՓU[J؆F\DF<njT(%]3`y<NIV^٠Mg8<)FPFSHC2(,S<#W!R$})$Q%am \5 HIENDB`uTox/third_party/stb/stb/data/herringbone/template_limited_connectivity.png0000600000175000001440000001511014003056224026445 0ustar rakusersPNG  IHDR  pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMf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^p>b i/[-[ zk|gR!MJwߟ؟|g!HJC͆iÆj5N.06ɦfT @>g* R+ggYĖғRz[JObK9_ҵkա(kUY:7-ߝ-Q?x @yɝU(Ε}wJ{RsX<`DL+~hWQR%zd$w>[VܻwXe"kGu2:. y2{{N<P̫MCψ-]dҟLRJb9/۹rm?6>x9ΑU+w#o0~!jyַ $Q̶ōScϨ@r|yw5GBNK]Ly4X:SΜ/^(=t~ӬblcM6-#nimNj bͯ$T6Alimc[ZtAt0H.B<МbKަزS=*[%sV7d7*^ܨlx{jSv;G[vHHbKަsbKLؒ%o5N m -1]iIENDB`uTox/third_party/stb/stb/data/herringbone/template_limit_connectivity_fat.png0000600000175000001440000001477714003056224027010 0ustar rakusersPNG  IHDR  pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAA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h;hc8пNw /) ~뉾½eh>O/ori F^J/RJÜdHYnQ: 0=1x?%-Sþ |^ Oa c adMcJ!X,F8%8C`7A[=iFk-T 0lPC:oR]=S' žva7G~A[3656br_J43Y=}qʘ^`z Lj .ZL_̕:aDwXb}rV(a 0\@"COꋫ0#r=dA Erxj|G8B'pt8{Lor #[~*kYL~Y @ ϭ !뛋Rw\G [pţcX- "YfH&yhѓ,pX[Z(ʉey^!V㙤qZm4aǿY.oX0I#SiMamdoOTB2V/2f3=m0'I1yGȉz>9Hx <~>6K\cXßt TTUr2|P*I*z 1cJւԵs3i}an3I!awC``b߄in8bfȓRrgIENDB`uTox/third_party/stb/stb/data/herringbone/template_horizontal_corridors_v2.png0000600000175000001440000001317714003056224027121 0ustar rakusersPNG  IHDR pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷO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D,Yn=G"10 U&m"hJ;şP1ѥdC7 w?G,0p6V;(Ghi DEX&l1z谬8j ??gqDZ4^b,|FDf$b`5m{̌F?{sPJ l[:||'voSGQ9;[]vH1`tK)R,{]Hw KX,ۅvavug| C"?v:3 K 7nb?hm ,X钒t#ÆMe|Ti|?l! Tק}cZ&Hذ8Xg,n$ystۗrÍ>v IP aڎCa`}s!jdn Q_ ܦl!:6!mX\9Qe3;ɸ.JO͝pdLn6,綊!4" l=% N+IENDB`uTox/third_party/stb/stb/data/herringbone/template_horizontal_corridors_v1.png0000600000175000001440000001256314003056224027116 0ustar rakusersPNG  IHDR pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl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Rwܑ 3?g߃^]H}}7tޱ]عn}G0@1!?kë8c&CT1DCbOJ*|ٿNJON?}å6~9bD'DruWbD'vP+gBrǿ犾EwSs3MŸF5a;[bgCs!FQ ތ d8}/<.ooߣb\*b^;{X@\Ѱ0bj.mj3~<7̏s1D>[1Đ?!!-&'izzع`Ly`|Tc~0ػ*ҋuB÷s4% fP 13,g@Db#>!QbCD>n} Gt^a/U;?0qn'Z#w/k|c/_˔Y.}uįF>A10~!2>yg eg^2``(֦3OHsꅌg gB):<ۯݾߗ~(~]?'~%`& 85р$sASwa|CBc;״~/)Υk;^yrMS`aaWF;A#{qXY!M˾y1qAȽ0|eyb (G102/IENDB`uTox/third_party/stb/stb/data/herringbone/template_corner_caves.png0000600000175000001440000002217114003056224024676 0ustar rakusersPNG  IHDR j pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>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%T; 'Q 9R#JȡW{P5zJ{rQcX4,۳%m~Z\\ W"TpzzB \W@%V gZINx/ܗڥm.RKg*\ɱVt꟏qjb^_$gHG1}*P{*9uvu{r+ޗ6ᰘmqS{PsMd6"tvOfsNA Ar2g }IAr:N'}p R +G<^ Su'@ Vc|9S\5^m-S[Ηᦚ<,C>FI2~-^)W(''L1kp3p]W-[&+qΟ5'* 3Eo أbwfDDlq{DD;A)'RǸp9E&]&J86`~IENDB`uTox/third_party/stb/stb/data/herringbone/template_caves_limit_connectivity.png0000600000175000001440000002510214003056224027317 0ustar rakusersPNG  IHDR  pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8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i~utJ>4-y!l"[-U鈔9HQ}rD2=d o *Rz:s͙ۼRLɖ(lI6h^<{XN}rU>FRG;$J/qG2פ}L0E^&u9XD^+*gwN0|Rޏ}H?=cM }C$m)?%̦ gu[&-H4$7*$TO"" DCd˂u)ɱ,sZ‚Yٞ9#2jI62L6RDt%[*8H"%Y!a-G8L0h]>cQ$. ЀpDDJ^Wg["\64tJk-="[@ qܞo8X4Wo};NْȖCvnHsheڈpIENDB`uTox/third_party/stb/stb/data/herringbone/license.txt0000600000175000001440000000031014003056224021776 0ustar rakusersAll files in this directory are in the public domain. Where a public domain declaration is not recognized, you are granted a license to freely use, modify, and redistribute them in any way you choose.uTox/third_party/stb/stb/data/easy_font_raw.png0000600000175000001440000000120514003056224020663 0ustar rakusersPNG  IHDR 9fPLTE1IDATx^햁j0 D)ogMdlTuRlɑ/IF]ۼBDݏ6{3Ѩ{<1yK8{ v`8b[ S{&@iEzXmu;JXMzYH55mWn=̪}b(`Z(,":EJ¦Ir*Lr282|>j- ;# ʢ!#VUy7+izAȒ4`Q$ 5I-7.mk1j%C%UbmjQtM*bYv,hbҲZb?8p}e8 KwbIrC@cU;Q)Yd-JfgZDW,E3 Χsy7*@̓qx.U\>rXt0ϥ\t΢j<ګEb|*W!tb2@N4IENDB`uTox/third_party/stb/stb/data/atari_8bit_font_revised.png0000600000175000001440000000335114003056224022624 0ustar rakusersPNG  IHDR u3 pHYs  iCCPPhotoshop ICC profilexc``$PPTR~!11 !/?/020|pYɕ4\PTp(%8 CzyIA c HRvA cHvH3c OIjE s~AeQfzFcJ~RBpeqIjng^r~QA~QbIj ^<#U*( >1H.-*%CC"C= o]KW0cc btY9y!K[z,٦}cg͡3#nM4}2?~ 4] cHRMz%u0`:o_FKIDATxYђ0 MlIv͔nYJ 1%!bmC"[>}ܰ{{uQν!jm^h aQFfz;&3kβqfr6>Ӡ >A`|<_ xdk?+_|g<&\ӠU!J\&;AeΞrf!_@u[5ZCqaG3w&O e9}Xi&r> LhB``J`pΒ!\̣P1Ԃ+e{Nq> ΝyR0 ?`[Y1͍^#3;@ֳ -x3wfp4n&yy^J2GlB*C9D#.n@+;}뚢|%,,H󓅮> lpbVƒ7qn }O1e)| qX5[۲&WRLwV&2Ƕ@BsYm֮qޤh/ p 54o?ᕂJ@PzF}a+4O1d +oe#ߢz;%bL u^.]D stb === single-file public domain (or MIT licensed) libraries for C/C++ Most libraries by stb, except: stb_dxt by Fabian "ryg" Giesen, stb_image_resize by Jorge L. "VinoBS" Rodriguez, and stb_sprintf by Jeff Roberts. library | lastest version | category | LoC | description --------------------- | ---- | -------- | --- | -------------------------------- **[stb_vorbis.c](stb_vorbis.c)** | 1.11 | audio | 5449 | decode ogg vorbis files from file/memory to float/16-bit signed output **[stb_image.h](stb_image.h)** | 2.16 | graphics | 7187 | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC **[stb_truetype.h](stb_truetype.h)** | 1.17 | graphics | 4566 | parse, decode, and rasterize characters from truetype fonts **[stb_image_write.h](stb_image_write.h)** | 1.07 | graphics | 1458 | image writing to disk: PNG, TGA, BMP **[stb_image_resize.h](stb_image_resize.h)** | 0.95 | graphics | 2627 | resize images larger/smaller with good quality **[stb_rect_pack.h](stb_rect_pack.h)** | 0.11 | graphics | 624 | simple 2D rectangle packer with decent quality **[stb_sprintf.h](stb_sprintf.h)** | 1.03 | utility | 1812 | fast sprintf, snprintf for C/C++ **[stretchy_buffer.h](stretchy_buffer.h)** | 1.02 | utility | 257 | typesafe dynamic array for C (i.e. approximation to vector<>), doesn't compile as C++ **[stb_textedit.h](stb_textedit.h)** | 1.11 | user interface | 1393 | guts of a text editor for games etc implementing them from scratch **[stb_voxel_render.h](stb_voxel_render.h)** | 0.85 | 3D graphics | 3803 | Minecraft-esque voxel rendering "engine" with many more features **[stb_dxt.h](stb_dxt.h)** | 1.07 | 3D graphics | 719 | Fabian "ryg" Giesen's real-time DXT compressor **[stb_perlin.h](stb_perlin.h)** | 0.3 | 3D graphics | 316 | revised Perlin noise (3D input, 1D output) **[stb_easy_font.h](stb_easy_font.h)** | 1.0 | 3D graphics | 303 | quick-and-dirty easy-to-deploy bitmap font for printing frame rate, etc **[stb_tilemap_editor.h](stb_tilemap_editor.h)** | 0.38 | game dev | 4172 | embeddable tilemap editor **[stb_herringbone_wa...](stb_herringbone_wang_tile.h)** | 0.6 | game dev | 1220 | herringbone Wang tile map generator **[stb_c_lexer.h](stb_c_lexer.h)** | 0.09 | parsing | 962 | simplify writing parsers for C-like languages **[stb_divide.h](stb_divide.h)** | 0.91 | math | 419 | more useful 32-bit modulus e.g. "euclidean divide" **[stb_connected_comp...](stb_connected_components.h)** | 0.95 | misc | 1045 | incrementally compute reachability on grids **[stb.h](stb.h)** | 2.30 | misc | 14328 | helper functions for C, mostly redundant in C++; basically author's personal stuff **[stb_leakcheck.h](stb_leakcheck.h)** | 0.4 | misc | 186 | quick-and-dirty malloc/free leak-checking Total libraries: 20 Total lines of C code: 52846 FAQ --- #### What's the license? These libraries are in the public domain. You can do anything you want with them. You have no legal obligation to do anything else, although I appreciate attribution. They are also licensed under the MIT open source license, if you have lawyers who are unhappy with public domain. Every source file includes an explicit dual-license for you to choose from. #### Are there other single-file public-domain/open source libraries with minimal dependencies out there? [Yes.](https://github.com/nothings/single_file_libs) #### If I wrap an stb library in a new library, does the new library have to be public domain/MIT? No, because it's public domain you can freely relicense it to whatever license your new library wants to be. #### What's the deal with SSE support in GCC-based compilers? stb_image will either use SSE2 (if you compile with -msse2) or will not use any SIMD at all, rather than trying to detect the processor at runtime and handle it correctly. As I understand it, the approved path in GCC for runtime-detection require you to use multiple source files, one for each CPU configuration. Because stb_image is a header-file library that compiles in only one source file, there's no approved way to build both an SSE-enabled and a non-SSE-enabled variation. While we've tried to work around it, we've had multiple issues over the years due to specific versions of gcc breaking what we're doing, so we've given up on it. See https://github.com/nothings/stb/issues/280 and https://github.com/nothings/stb/issues/410 for examples. #### Some of these libraries seem redundant to existing open source libraries. Are they better somehow? Generally they're only better in that they're easier to integrate, easier to use, and easier to release (single file; good API; no attribution requirement). They may be less featureful, slower, and/or use more memory. If you're already using an equivalent library, there's probably no good reason to switch. #### Can I link directly to the table of stb libraries? You can use [this URL](https://github.com/nothings/stb#stb_libs) to link directly to that list. #### Why do you list "lines of code"? It's a terrible metric. Just to give you some idea of the internal complexity of the library, to help you manage your expectations, or to let you know what you're getting into. While not all the libraries are written in the same style, they're certainly similar styles, and so comparisons between the libraries are probably still meaningful. Note though that the lines do include both the implementation, the part that corresponds to a header file, and the documentation. #### Why single-file headers? Windows doesn't have standard directories where libraries live. That makes deploying libraries in Windows a lot more painful than open source developers on Unix-derivates generally realize. (It also makes library dependencies a lot worse in Windows.) There's also a common problem in Windows where a library was built against a different version of the runtime library, which causes link conflicts and confusion. Shipping the libs as headers means you normally just compile them straight into your project without making libraries, thus sidestepping that problem. Making them a single file makes it very easy to just drop them into a project that needs them. (Of course you can still put them in a proper shared library tree if you want.) Why not two files, one a header and one an implementation? The difference between 10 files and 9 files is not a big deal, but the difference between 2 files and 1 file is a big deal. You don't need to zip or tar the files up, you don't have to remember to attach *two* files, etc. #### Why "stb"? Is this something to do with Set-Top Boxes? No, they are just the initials for my name, Sean T. Barrett. This was not chosen out of egomania, but as a moderately sane way of namespacing the filenames and source function names. #### Will you add more image types to stb_image.h? If people submit them, I generally add them, but the goal of stb_image is less for applications like image viewer apps (which need to support every type of image under the sun) and more for things like games which can choose what images to use, so I may decline to add them if they're too rare or if the size of implementation vs. apparent benefit is too low. #### Do you have any advice on how to create my own single-file library? Yes. https://github.com/nothings/stb/blob/master/docs/stb_howto.txt #### Why public domain? I prefer it over GPL, LGPL, BSD, zlib, etc. for many reasons. Some of them are listed here: https://github.com/nothings/stb/blob/master/docs/why_public_domain.md #### Why C? Primarily, because I use C, not C++. But it does also make it easier for other people to use them from other languages. #### Why not C99? stdint.h, declare-anywhere, etc. I still use MSVC 6 (1998) as my IDE because it has better human factors for me than later versions of MSVC. uTox/third_party/stb/stb/.travis.yml0000600000175000001440000000007414003056224016520 0ustar rakuserslanguage: C install: true script: - cd tests - make all uTox/third_party/stb/stb/.github/0000700000175000001440000000000014003056224015744 5ustar rakusersuTox/third_party/stb/stb/.github/PULL_REQUEST_TEMPLATE.md0000600000175000001440000000116314003056224021550 0ustar rakusers* Delete this list before clicking CREATE PULL REQUEST * Make sure you're using a special branch just for this pull request. (Sometimes people unknowingly use a default branch, then later update that branch, which updates the pull request with the other changes if it hasn't been merged yet.) * Do NOT update the version number in the file. (This just causes conflicts.) * Do add your name to the list of contributors. (Don't worry about the formatting.) I'll try to remember to add it if you don't, but I sometimes forget as it's an extra step. If you get something above wrong, don't fret it, it's not the end of the world. uTox/third_party/stb/stb/.github/CONTRIBUTING.md0000600000175000001440000000170314003056224020200 0ustar rakusersPull Requests and Issues are both welcome. # Responsiveness General priority order is: * Crashes * Bugs * Warnings * Enhancements (new features, performance improvement, etc) Pull requests get priority over Issues. Some pull requests I take as written; some I modify myself; some I will request changes before accepting them. Because I've ended up supporting a lot of libraries (20 as I write this, with more on the way), I am somewhat slow to address things. Many issues have been around for a long time. # Pull requests * Do NOT update the version number in the file. (This just causes conflicts.) * Do add your name to the list of contributors. (Don't worry about the formatting.) I'll try to remember to add it if you don't, but I sometimes forget as it's an extra step. # Specific libraries I generally do not want new file formats for stb_image because we are trying to improve its security, so increasing its attack surface is counter-productive. uTox/third_party/stb/stb/.git0000600000175000001440000000006214003056224015170 0ustar rakusersgitdir: ../../../.git/modules/third_party/stb/stb uTox/third_party/stb/CMakeLists.txt0000600000175000001440000000021314003056216016353 0ustar rakusersproject(stb LANGUAGES C) add_library(${PROJECT_NAME} STATIC stb.c ) target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC . ) uTox/third_party/qrcodegen/0000700000175000001440000000000014003056216014774 5ustar rakusersuTox/third_party/qrcodegen/qrcodegen/0000700000175000001440000000000014003056224016742 5ustar rakusersuTox/third_party/qrcodegen/qrcodegen/rust/0000700000175000001440000000000014003056224017737 5ustar rakusersuTox/third_party/qrcodegen/qrcodegen/rust/src/0000700000175000001440000000000014003056224020526 5ustar rakusersuTox/third_party/qrcodegen/qrcodegen/rust/src/lib.rs0000600000175000001440000011364714003056224021660 0ustar rakusers/* * QR Code generator library (Rust) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ /*---- QrCode functionality ----*/ // Represents an immutable square grid of black and white cells for a QR Code symbol, and // provides static functions to create a QR Code from user-supplied textual or binary data. // This struct covers the QR Code model 2 specification, supporting all versions (sizes) // from 1 to 40, all 4 error correction levels, and only 3 character encoding modes. pub struct QrCode { // This QR Code symbol's version number, which is always between 1 and 40 (inclusive). version: Version, // The width and height of this QR Code symbol, measured in modules. // Always equal to version × 4 + 17, in the range 21 to 177. size: i32, // The error correction level used in this QR Code symbol. errorcorrectionlevel: QrCodeEcc, // The mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer). // Note that even if a constructor was called with automatic masking requested // (mask = -1), the resulting object will still have a mask value between 0 and 7. mask: Mask, // The modules of this QR Code symbol (false = white, true = black) modules: Vec, // Indicates function modules that are not subjected to masking isfunction: Vec, } impl QrCode { /*---- Public static factory functions ----*/ // Returns a QR Code symbol representing the given Unicode text string at the given error correction level. // As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer Unicode // code points (not UTF-8 code units) if the low error correction level is used. The smallest possible // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than // the ecl argument if it can be done without increasing the version. Returns a wrapped QrCode if successful, // or None if the data is too long to fit in any version at the given ECC level. pub fn encode_text(text: &str, ecl: QrCodeEcc) -> Option { let chrs: Vec = text.chars().collect(); let segs: Vec = QrSegment::make_segments(&chrs); QrCode::encode_segments(&segs, ecl) } // Returns a QR Code symbol representing the given binary data string at the given error correction level. // This function always encodes using the binary segment mode, not any text mode. The maximum number of // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. // Returns a wrapped QrCode if successful, or None if the data is too long to fit in any version at the given ECC level. pub fn encode_binary(data: &[u8], ecl: QrCodeEcc) -> Option { let segs: Vec = vec![QrSegment::make_bytes(data)]; QrCode::encode_segments(&segs, ecl) } // Returns a QR Code symbol representing the given data segments at the given error correction // level or higher. The smallest possible QR Code version is automatically chosen for the output. // This function allows the user to create a custom sequence of segments that switches // between modes (such as alphanumeric and binary) to encode text more efficiently. // This function is considered to be lower level than simply encoding text or binary data. // Returns a wrapped QrCode if successful, or None if the data is too long to fit in any version at the given ECC level. pub fn encode_segments(segs: &[QrSegment], ecl: QrCodeEcc) -> Option { QrCode::encode_segments_advanced(segs, ecl, QrCode_MIN_VERSION, QrCode_MAX_VERSION, None, true) } // Returns a QR Code symbol representing the given data segments with the given encoding parameters. // The smallest possible QR Code version within the given range is automatically chosen for the output. // This function allows the user to create a custom sequence of segments that switches // between modes (such as alphanumeric and binary) to encode text more efficiently. // This function is considered to be lower level than simply encoding text or binary data. // Returns a wrapped QrCode if successful, or None if the data is too long to fit // in any version in the given range at the given ECC level. pub fn encode_segments_advanced(segs: &[QrSegment], mut ecl: QrCodeEcc, minversion: Version, maxversion: Version, mask: Option, boostecl: bool) -> Option { assert!(minversion.value() <= maxversion.value(), "Invalid value"); // Find the minimal version number to use let mut version = minversion; let datausedbits: usize; loop { // Number of data bits available let datacapacitybits: usize = QrCode::get_num_data_codewords(version, ecl) * 8; if let Some(n) = QrSegment::get_total_bits(segs, version) { if n <= datacapacitybits { datausedbits = n; break; // This version number is found to be suitable } } if version.value() >= maxversion.value() { // All versions in the range could not fit the given data return None; } version = Version::new(version.value() + 1); } // Increase the error correction level while the data still fits in the current version number for newecl in &[QrCodeEcc::Medium, QrCodeEcc::Quartile, QrCodeEcc::High] { if boostecl && datausedbits <= QrCode::get_num_data_codewords(version, *newecl) * 8 { ecl = *newecl; } } // Create the data bit string by concatenating all segments let datacapacitybits: usize = QrCode::get_num_data_codewords(version, ecl) * 8; let mut bb = BitBuffer(Vec::new()); for seg in segs { bb.append_bits(seg.mode.mode_bits(), 4); bb.append_bits(seg.numchars as u32, seg.mode.num_char_count_bits(version)); bb.0.extend_from_slice(&seg.data); } // Add terminator and pad up to a byte if applicable let numzerobits = std::cmp::min(4, datacapacitybits - bb.0.len()); bb.append_bits(0, numzerobits as u8); let numzerobits = bb.0.len().wrapping_neg() & 7; bb.append_bits(0, numzerobits as u8); // Pad with alternate bytes until data capacity is reached let mut padbyte: u32 = 0xEC; while bb.0.len() < datacapacitybits { bb.append_bits(padbyte, 8); padbyte ^= 0xEC ^ 0x11; } assert_eq!(bb.0.len() % 8, 0, "Assertion error"); let mut bytes = vec![0u8; bb.0.len() / 8]; for (i, bit) in bb.0.iter().enumerate() { bytes[i >> 3] |= (*bit as u8) << (7 - (i & 7)); } // Create the QR Code symbol Some(QrCode::encode_codewords(version, ecl, &bytes, mask)) } /*---- Constructors ----*/ // Creates a new QR Code symbol with the given version number, error correction level, // binary data array, and mask number. This is a cumbersome low-level constructor that // should not be invoked directly by the user. To go one level up, see the encode_segments() function. pub fn encode_codewords(ver: Version, ecl: QrCodeEcc, datacodewords: &[u8], mask: Option) -> QrCode { // Initialize fields let size: usize = (ver.value() as usize) * 4 + 17; let mut result = QrCode { version: ver, size: size as i32, mask: Mask::new(0), // Dummy value errorcorrectionlevel: ecl, modules: vec![false; size * size], // Entirely white grid isfunction: vec![false; size * size], }; // Draw function patterns, draw all codewords, do masking result.draw_function_patterns(); let allcodewords: Vec = result.append_error_correction(datacodewords); result.draw_codewords(&allcodewords); result.handle_constructor_masking(mask); result } // Returns this QR Code's version, in the range [1, 40]. pub fn version(&self) -> Version { self.version } // Returns this QR Code's size, in the range [21, 177]. pub fn size(&self) -> i32 { self.size } // Returns this QR Code's error correction level. pub fn error_correction_level(&self) -> QrCodeEcc { self.errorcorrectionlevel } // Returns this QR Code's mask, in the range [0, 7]. pub fn mask(&self) -> Mask { self.mask } // Returns the color of the module (pixel) at the given coordinates, which is either // false for white or true for black. The top left corner has the coordinates (x=0, y=0). // If the given coordinates are out of bounds, then 0 (white) is returned. pub fn get_module(&self, x: i32, y: i32) -> bool { 0 <= x && x < self.size && 0 <= y && y < self.size && self.module(x, y) } // Returns the color of the module at the given coordinates, which must be in bounds. fn module(&self, x: i32, y: i32) -> bool { self.modules[(y * self.size + x) as usize] } // Returns a mutable reference to the module's color at the given coordinates, which must be in bounds. fn module_mut(&mut self, x: i32, y: i32) -> &mut bool { &mut self.modules[(y * self.size + x) as usize] } // Based on the given number of border modules to add as padding, this returns a // string whose contents represents an SVG XML file that depicts this QR Code symbol. // Note that Unix newlines (\n) are always used, regardless of the platform. pub fn to_svg_string(&self, border: i32) -> String { assert!(border >= 0, "Border must be non-negative"); let mut result: String = String::new(); result.push_str("\n"); result.push_str("\n"); result.push_str(&format!( "\n", self.size + border * 2)); result.push_str("\t\n"); result.push_str("\t\n"); result.push_str("\n"); result } /*---- Private helper methods for constructor: Drawing function modules ----*/ fn draw_function_patterns(&mut self) { // Draw horizontal and vertical timing patterns let size: i32 = self.size; for i in 0 .. size { self.set_function_module(6, i, i % 2 == 0); self.set_function_module(i, 6, i % 2 == 0); } // Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules) self.draw_finder_pattern(3, 3); self.draw_finder_pattern(size - 4, 3); self.draw_finder_pattern(3, size - 4); // Draw numerous alignment patterns let alignpatpos: Vec = QrCode::get_alignment_pattern_positions(self.version); let numalign: usize = alignpatpos.len(); for i in 0 .. numalign { for j in 0 .. numalign { if i == 0 && j == 0 || i == 0 && j == numalign - 1 || i == numalign - 1 && j == 0 { continue; // Skip the three finder corners } else { self.draw_alignment_pattern(alignpatpos[i], alignpatpos[j]); } } } // Draw configuration data self.draw_format_bits(Mask::new(0)); // Dummy mask value; overwritten later in the constructor self.draw_version(); } // Draws two copies of the format bits (with its own error correction code) // based on the given mask and this object's error correction level field. fn draw_format_bits(&mut self, mask: Mask) { // Calculate error correction code and pack bits let size: i32 = self.size; // errcorrlvl is uint2, mask is uint3 let mut data: u32 = self.errorcorrectionlevel.format_bits() << 3 | (mask.value() as u32); let mut rem: u32 = data; for _ in 0 .. 10 { rem = (rem << 1) ^ ((rem >> 9) * 0x537); } data = data << 10 | rem; data ^= 0x5412; // uint15 assert_eq!(data >> 15, 0, "Assertion error"); // Draw first copy for i in 0 .. 6 { self.set_function_module(8, i, (data >> i) & 1 != 0); } self.set_function_module(8, 7, (data >> 6) & 1 != 0); self.set_function_module(8, 8, (data >> 7) & 1 != 0); self.set_function_module(7, 8, (data >> 8) & 1 != 0); for i in 9 .. 15 { self.set_function_module(14 - i, 8, (data >> i) & 1 != 0); } // Draw second copy for i in 0 .. 8 { self.set_function_module(size - 1 - i, 8, (data >> i) & 1 != 0); } for i in 8 .. 15 { self.set_function_module(8, size - 15 + i, (data >> i) & 1 != 0); } self.set_function_module(8, size - 8, true); } // Draws two copies of the version bits (with its own error correction code), // based on this object's version field (which only has an effect for 7 <= version <= 40). fn draw_version(&mut self) { if self.version.value() < 7 { return; } // Calculate error correction code and pack bits let mut rem: u32 = self.version.value() as u32; // version is uint6, in the range [7, 40] for _ in 0 .. 12 { rem = (rem << 1) ^ ((rem >> 11) * 0x1F25); } let data: u32 = (self.version.value() as u32) << 12 | rem; // uint18 assert!(data >> 18 == 0, "Assertion error"); // Draw two copies for i in 0 .. 18 { let bit: bool = (data >> i) & 1 != 0; let a: i32 = self.size - 11 + i % 3; let b: i32 = i / 3; self.set_function_module(a, b, bit); self.set_function_module(b, a, bit); } } // Draws a 9*9 finder pattern including the border separator, with the center module at (x, y). fn draw_finder_pattern(&mut self, x: i32, y: i32) { for i in -4 .. 5 { for j in -4 .. 5 { let xx: i32 = x + j; let yy: i32 = y + i; if 0 <= xx && xx < self.size && 0 <= yy && yy < self.size { let dist: i32 = std::cmp::max(i.abs(), j.abs()); // Chebyshev/infinity norm self.set_function_module(xx, yy, dist != 2 && dist != 4); } } } } // Draws a 5*5 alignment pattern, with the center module at (x, y). fn draw_alignment_pattern(&mut self, x: i32, y: i32) { for i in -2 .. 3 { for j in -2 .. 3 { self.set_function_module(x + j, y + i, std::cmp::max(i.abs(), j.abs()) != 1); } } } // Sets the color of a module and marks it as a function module. // Only used by the constructor. Coordinates must be in range. fn set_function_module(&mut self, x: i32, y: i32, isblack: bool) { *self.module_mut(x, y) = isblack; self.isfunction[(y * self.size + x) as usize] = true; } /*---- Private helper methods for constructor: Codewords and masking ----*/ // Returns a new byte string representing the given data with the appropriate error correction // codewords appended to it, based on this object's version and error correction level. fn append_error_correction(&self, data: &[u8]) -> Vec { assert_eq!(data.len(), QrCode::get_num_data_codewords(self.version, self.errorcorrectionlevel), "Illegal argument"); // Calculate parameter numbers let numblocks: usize = QrCode::table_get(&NUM_ERROR_CORRECTION_BLOCKS, self.version, self.errorcorrectionlevel); let blockecclen: usize = QrCode::table_get(&ECC_CODEWORDS_PER_BLOCK, self.version, self.errorcorrectionlevel); let rawcodewords: usize = QrCode::get_num_raw_data_modules(self.version) / 8; let numshortblocks: usize = numblocks - rawcodewords % numblocks; let shortblocklen: usize = rawcodewords / numblocks; // Split data into blocks and append ECC to each block let mut blocks = Vec::>::with_capacity(numblocks); let rs = ReedSolomonGenerator::new(blockecclen); let mut k: usize = 0; for i in 0 .. numblocks { let mut dat = Vec::::with_capacity(shortblocklen + 1); dat.extend_from_slice(&data[k .. k + shortblocklen - blockecclen + ((i >= numshortblocks) as usize)]); k += dat.len(); let ecc: Vec = rs.get_remainder(&dat); if i < numshortblocks { dat.push(0); } dat.extend_from_slice(&ecc); blocks.push(dat); } // Interleave (not concatenate) the bytes from every block into a single sequence let mut result = Vec::::with_capacity(rawcodewords); for i in 0 .. shortblocklen + 1 { for j in 0 .. numblocks { // Skip the padding byte in short blocks if i != shortblocklen - blockecclen || j >= numshortblocks { result.push(blocks[j][i]); } } } result } // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire // data area of this QR Code symbol. Function modules need to be marked off before this is called. fn draw_codewords(&mut self, data: &[u8]) { assert_eq!(data.len(), QrCode::get_num_raw_data_modules(self.version) / 8, "Illegal argument"); let mut i: usize = 0; // Bit index into the data // Do the funny zigzag scan let mut right: i32 = self.size - 1; while right >= 1 { // Index of right column in each column pair if right == 6 { right = 5; } for vert in 0 .. self.size { // Vertical counter for j in 0 .. 2 { let x: i32 = right - j; // Actual x coordinate let upward: bool = (right + 1) & 2 == 0; let y: i32 = if upward { self.size - 1 - vert } else { vert }; // Actual y coordinate if !self.isfunction[(y * self.size + x) as usize] && i < data.len() * 8 { *self.module_mut(x, y) = (data[i >> 3] >> (7 - (i & 7))) & 1 != 0; i += 1; } // If there are any remainder bits (0 to 7), they are already // set to 0/false/white when the grid of modules was initialized } } right -= 2; } assert_eq!(i, data.len() * 8, "Assertion error"); } // XORs the data modules in this QR Code with the given mask pattern. Due to XOR's mathematical // properties, calling applyMask(m) twice with the same value is equivalent to no change at all. // This means it is possible to apply a mask, undo it, and try another mask. Note that a final // well-formed QR Code symbol needs exactly one mask applied (not zero, not two, etc.). fn apply_mask(&mut self, mask: Mask) { let mask = mask.value(); for y in 0 .. self.size { for x in 0 .. self.size { let invert: bool = match mask { 0 => (x + y) % 2 == 0, 1 => y % 2 == 0, 2 => x % 3 == 0, 3 => (x + y) % 3 == 0, 4 => (x / 3 + y / 2) % 2 == 0, 5 => x * y % 2 + x * y % 3 == 0, 6 => (x * y % 2 + x * y % 3) % 2 == 0, 7 => ((x + y) % 2 + x * y % 3) % 2 == 0, _ => panic!("Assertion error"), }; *self.module_mut(x, y) ^= invert & !self.isfunction[(y * self.size + x) as usize]; } } } // A messy helper function for the constructors. This QR Code must be in an unmasked state when this // method is called. The given argument is the requested mask, which is -1 for auto or 0 to 7 for fixed. // This method applies and returns the actual mask chosen, from 0 to 7. fn handle_constructor_masking(&mut self, mut mask: Option) { if mask.is_none() { // Automatically choose best mask let mut minpenalty: i32 = std::i32::MAX; for i in 0u8 .. 8 { let newmask = Mask::new(i); self.draw_format_bits(newmask); self.apply_mask(newmask); let penalty: i32 = self.get_penalty_score(); if penalty < minpenalty { mask = Some(newmask); minpenalty = penalty; } self.apply_mask(newmask); // Undoes the mask due to XOR } } let msk: Mask = mask.unwrap(); self.draw_format_bits(msk); // Overwrite old format bits self.apply_mask(msk); // Apply the final choice of mask self.mask = msk; } // Calculates and returns the penalty score based on state of this QR Code's current modules. // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score. fn get_penalty_score(&self) -> i32 { let mut result: i32 = 0; let size: i32 = self.size; // Adjacent modules in row having same color for y in 0 .. size { let mut colorx: bool = false; let mut runx: i32 = 0; for x in 0 .. size { if x == 0 || self.module(x, y) != colorx { colorx = self.module(x, y); runx = 1; } else { runx += 1; if runx == 5 { result += PENALTY_N1; } else if runx > 5 { result += 1; } } } } // Adjacent modules in column having same color for x in 0 .. size { let mut colory: bool = false; let mut runy: i32 = 0; for y in 0 .. size { if y == 0 || self.module(x, y) != colory { colory = self.module(x, y); runy = 1; } else { runy += 1; if runy == 5 { result += PENALTY_N1; } else if runy > 5 { result += 1; } } } } // 2*2 blocks of modules having same color for y in 0 .. size - 1 { for x in 0 .. size - 1 { let color: bool = self.module(x, y); if color == self.module(x + 1, y) && color == self.module(x, y + 1) && color == self.module(x + 1, y + 1) { result += PENALTY_N2; } } } // Finder-like pattern in rows for y in 0 .. size { let mut bits: u32 = 0; for x in 0 .. size { bits = ((bits << 1) & 0x7FF) | (self.module(x, y) as u32); if x >= 10 && (bits == 0x05D || bits == 0x5D0) { // Needs 11 bits accumulated result += PENALTY_N3; } } } // Finder-like pattern in columns for x in 0 .. size { let mut bits: u32 = 0; for y in 0 .. size { bits = ((bits << 1) & 0x7FF) | (self.module(x, y) as u32); if y >= 10 && (bits == 0x05D || bits == 0x5D0) { // Needs 11 bits accumulated result += PENALTY_N3; } } } // Balance of black and white modules let mut black: i32 = 0; for color in &self.modules { black += *color as i32; } let total: i32 = size * size; // Find smallest k such that (45-5k)% <= dark/total <= (55+5k)% let mut k: i32 = 0; while black*20 < (9-k)*total || black*20 > (11+k)*total { result += PENALTY_N4; k += 1; } result } /*---- Private static helper functions ----*/ // Returns a set of positions of the alignment patterns in ascending order. These positions are // used on both the x and y axes. Each value in the resulting list is in the range [0, 177). // This stateless pure function could be implemented as table of 40 variable-length lists of unsigned bytes. fn get_alignment_pattern_positions(ver: Version) -> Vec { let ver = ver.value(); if ver == 1 { vec![] } else { let numalign: i32 = (ver as i32) / 7 + 2; let step: i32 = if ver != 32 { // ceil((size - 13) / (2*numAlign - 2)) * 2 ((ver as i32) * 4 + numalign * 2 + 1) / (2 * numalign - 2) * 2 } else { // C-C-C-Combo breaker! 26 }; let mut result = vec![6i32]; let mut pos: i32 = (ver as i32) * 4 + 10; for _ in 0 .. numalign - 1 { result.insert(1, pos); pos -= step; } result } } // Returns the number of data bits that can be stored in a QR Code of the given version number, after // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8. // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table. fn get_num_raw_data_modules(ver: Version) -> usize { let ver = ver.value(); let mut result: usize = (16 * (ver as usize) + 128) * (ver as usize) + 64; if ver >= 2 { let numalign: usize = (ver as usize) / 7 + 2; result -= (25 * numalign - 10) * numalign - 55; if ver >= 7 { result -= 18 * 2; // Subtract version information } } result } // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any // QR Code of the given version number and error correction level, with remainder bits discarded. // This stateless pure function could be implemented as a (40*4)-cell lookup table. fn get_num_data_codewords(ver: Version, ecl: QrCodeEcc) -> usize { QrCode::get_num_raw_data_modules(ver) / 8 - QrCode::table_get(&ECC_CODEWORDS_PER_BLOCK, ver, ecl) * QrCode::table_get(&NUM_ERROR_CORRECTION_BLOCKS, ver, ecl) } // Returns an entry from the given table based on the given values. fn table_get(table: &'static [[i8; 41]; 4], ver: Version, ecl: QrCodeEcc) -> usize { table[ecl.ordinal()][ver.value() as usize] as usize } } /*---- Public constants ----*/ pub const QrCode_MIN_VERSION: Version = Version( 1); pub const QrCode_MAX_VERSION: Version = Version(40); /*---- Private tables of constants ----*/ // For use in get_penalty_score(), when evaluating which mask is best. const PENALTY_N1: i32 = 3; const PENALTY_N2: i32 = 3; const PENALTY_N3: i32 = 40; const PENALTY_N4: i32 = 10; static ECC_CODEWORDS_PER_BLOCK: [[i8; 41]; 4] = [ // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // Low [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28], // Medium [-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // Quartile [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // High ]; static NUM_ERROR_CORRECTION_BLOCKS: [[i8; 41]; 4] = [ // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25], // Low [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49], // Medium [-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68], // Quartile [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81], // High ]; /*---- QrCodeEcc functionality ----*/ // Represents the error correction level used in a QR Code symbol. Immutable. #[derive(Clone, Copy)] pub enum QrCodeEcc { Low, Medium, Quartile, High, } impl QrCodeEcc { // Returns an unsigned 2-bit integer (in the range 0 to 3). fn ordinal(&self) -> usize { match *self { QrCodeEcc::Low => 0, QrCodeEcc::Medium => 1, QrCodeEcc::Quartile => 2, QrCodeEcc::High => 3, } } // Returns an unsigned 2-bit integer (in the range 0 to 3). fn format_bits(&self) -> u32 { match *self { QrCodeEcc::Low => 1, QrCodeEcc::Medium => 0, QrCodeEcc::Quartile => 3, QrCodeEcc::High => 2, } } } /*---- ReedSolomonGenerator functionality ----*/ // Computes the Reed-Solomon error correction codewords for a sequence of data codewords // at a given degree. Objects are immutable, and the state only depends on the degree. // This class exists because each data block in a QR Code shares the same the divisor polynomial. struct ReedSolomonGenerator { // Coefficients of the divisor polynomial, stored from highest to lowest power, excluding the leading term which // is always 1. For example the polynomial x^3 + 255x^2 + 8x + 93 is stored as the uint8 array {255, 8, 93}. coefficients: Vec, } impl ReedSolomonGenerator { // Creates a Reed-Solomon ECC generator for the given degree. This could be implemented // as a lookup table over all possible parameter values, instead of as an algorithm. fn new(degree: usize) -> ReedSolomonGenerator { assert!(1 <= degree && degree <= 255, "Degree out of range"); // Start with the monomial x^0 let mut coefs = vec![0u8; degree - 1]; coefs.push(1); // Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}), // drop the highest term, and store the rest of the coefficients in order of descending powers. // Note that r = 0x02, which is a generator element of this field GF(2^8/0x11D). let mut root: u8 = 1; for _ in 0 .. degree { // Unused variable i // Multiply the current product by (x - r^i) for j in 0 .. degree { coefs[j] = ReedSolomonGenerator::multiply(coefs[j], root); if j + 1 < coefs.len() { coefs[j] ^= coefs[j + 1]; } } root = ReedSolomonGenerator::multiply(root, 0x02); } ReedSolomonGenerator { coefficients: coefs } } // Computes and returns the Reed-Solomon error correction codewords for the given sequence of data codewords. fn get_remainder(&self, data: &[u8]) -> Vec { // Compute the remainder by performing polynomial division let mut result = vec![0u8; self.coefficients.len()]; for b in data { let factor: u8 = b ^ result.remove(0); result.push(0); for (x, y) in result.iter_mut().zip(self.coefficients.iter()) { *x ^= ReedSolomonGenerator::multiply(*y, factor); } } result } // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8. fn multiply(x: u8, y: u8) -> u8 { // Russian peasant multiplication let mut z: u8 = 0; for i in (0 .. 8).rev() { z = (z << 1) ^ ((z >> 7) * 0x1D); z ^= ((y >> i) & 1) * x; } z } } /*---- QrSegment functionality ----*/ // Represents a character string to be encoded in a QR Code symbol. // Each segment has a mode, and a sequence of characters that is already // encoded as a sequence of bits. Instances of this struct are immutable. pub struct QrSegment { // The mode indicator for this segment. mode: QrSegmentMode, // The length of this segment's unencoded data, measured in characters. numchars: usize, // The bits of this segment. data: Vec, } impl QrSegment { /*---- Static factory functions ----*/ // Returns a segment representing the given binary data encoded in byte mode. pub fn make_bytes(data: &[u8]) -> QrSegment { let mut bb = BitBuffer(Vec::with_capacity(data.len() * 8)); for b in data { bb.append_bits(*b as u32, 8); } QrSegment::new(QrSegmentMode::Byte, data.len(), bb.0) } // Returns a segment representing the given string of decimal digits encoded in numeric mode. // Panics if the string contains non-digit characters. pub fn make_numeric(text: &[char]) -> QrSegment { let mut bb = BitBuffer(Vec::with_capacity(text.len() * 3 + (text.len() + 2) / 3)); let mut accumdata: u32 = 0; let mut accumcount: u32 = 0; for c in text { assert!('0' <= *c && *c <= '9', "String contains non-numeric characters"); accumdata = accumdata * 10 + ((*c as u32) - ('0' as u32)); accumcount += 1; if accumcount == 3 { bb.append_bits(accumdata, 10); accumdata = 0; accumcount = 0; } } if accumcount > 0 { // 1 or 2 digits remaining bb.append_bits(accumdata, (accumcount as u8) * 3 + 1); } QrSegment::new(QrSegmentMode::Numeric, text.len(), bb.0) } // Returns a segment representing the given text string encoded in alphanumeric mode. // The characters allowed are: 0 to 9, A to Z (uppercase only), space, dollar, percent, asterisk, // plus, hyphen, period, slash, colon. Panics if the string contains non-encodable characters. pub fn make_alphanumeric(text: &[char]) -> QrSegment { let mut bb = BitBuffer(Vec::with_capacity(text.len() * 5 + (text.len() + 1) / 2)); let mut accumdata: u32 = 0; let mut accumcount: u32 = 0; for c in text { let i = match ALPHANUMERIC_CHARSET.iter().position(|x| *x == *c) { None => panic!("String contains unencodable characters in alphanumeric mode"), Some(j) => j, }; accumdata = accumdata * 45 + (i as u32); accumcount += 1; if accumcount == 2 { bb.append_bits(accumdata, 11); accumdata = 0; accumcount = 0; } } if accumcount > 0 { // 1 character remaining bb.append_bits(accumdata, 6); } QrSegment::new(QrSegmentMode::Alphanumeric, text.len(), bb.0) } // Returns a new mutable list of zero or more segments to represent the given Unicode text string. // The result may use various segment modes and switch modes to optimize the length of the bit stream. pub fn make_segments(text: &[char]) -> Vec { if text.is_empty() { vec![] } else if QrSegment::is_numeric(text) { vec![QrSegment::make_numeric(text)] } else if QrSegment::is_alphanumeric(text) { vec![QrSegment::make_alphanumeric(text)] } else { let s: String = text.iter().cloned().collect(); vec![QrSegment::make_bytes(s.as_bytes())] } } // Returns a segment representing an Extended Channel Interpretation // (ECI) designator with the given assignment value. pub fn make_eci(assignval: u32) -> QrSegment { let mut bb = BitBuffer(Vec::with_capacity(24)); if assignval < (1 << 7) { bb.append_bits(assignval, 8); } else if assignval < (1 << 14) { bb.append_bits(2, 2); bb.append_bits(assignval, 14); } else if assignval < 1_000_000 { bb.append_bits(6, 3); bb.append_bits(assignval, 21); } else { panic!("ECI assignment value out of range"); } QrSegment::new(QrSegmentMode::Eci, 0, bb.0) } // Creates a new QR Code data segment with the given parameters and data. pub fn new(mode: QrSegmentMode, numchars: usize, data: Vec) -> QrSegment { QrSegment { mode: mode, numchars: numchars, data: data, } } /*---- Instance field getters ----*/ // Returns the mode indicator for this segment. pub fn mode(&self) -> QrSegmentMode { self.mode } // Returns the length of this segment's unencoded data, measured in characters. pub fn num_chars(&self) -> usize { self.numchars } // Returns a view of the bits of this segment. pub fn data(&self) -> &Vec { &self.data } /*---- Other static functions ----*/ // Package-private helper function. fn get_total_bits(segs: &[QrSegment], version: Version) -> Option { let mut result: usize = 0; for seg in segs { let ccbits = seg.mode.num_char_count_bits(version); if seg.numchars >= 1 << ccbits { return None; } match result.checked_add(4 + (ccbits as usize) + seg.data.len()) { None => return None, Some(val) => result = val, } } Some(result) } // Tests whether the given string can be encoded as a segment in alphanumeric mode. fn is_alphanumeric(text: &[char]) -> bool { text.iter().all(|c| ALPHANUMERIC_CHARSET.contains(c)) } // Tests whether the given string can be encoded as a segment in numeric mode. fn is_numeric(text: &[char]) -> bool { text.iter().all(|c| '0' <= *c && *c <= '9') } } // The set of all legal characters in alphanumeric mode, // where each character value maps to the index in the string. static ALPHANUMERIC_CHARSET: [char; 45] = ['0','1','2','3','4','5','6','7','8','9', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', ' ','$','%','*','+','-','.','/',':']; /*---- QrSegmentMode functionality ----*/ // The mode field of a segment. Immutable. #[derive(Clone, Copy)] pub enum QrSegmentMode { Numeric, Alphanumeric, Byte, Kanji, Eci, } impl QrSegmentMode { // Returns an unsigned 4-bit integer value (range 0 to 15) // representing the mode indicator bits for this mode object. fn mode_bits(&self) -> u32 { match *self { QrSegmentMode::Numeric => 0x1, QrSegmentMode::Alphanumeric => 0x2, QrSegmentMode::Byte => 0x4, QrSegmentMode::Kanji => 0x8, QrSegmentMode::Eci => 0x7, } } // Returns the bit width of the segment character count field // for this mode object at the given version number. pub fn num_char_count_bits(&self, ver: Version) -> u8 { let array: [u8; 3] = match *self { QrSegmentMode::Numeric => [10, 12, 14], QrSegmentMode::Alphanumeric => [ 9, 11, 13], QrSegmentMode::Byte => [ 8, 16, 16], QrSegmentMode::Kanji => [ 8, 10, 12], QrSegmentMode::Eci => [ 0, 0, 0], }; let ver = ver.value(); if 1 <= ver && ver <= 9 { array[0] } else if 10 <= ver && ver <= 26 { array[1] } else if 27 <= ver && ver <= 40 { array[2] } else { panic!("Version number out of range"); } } } /*---- Bit buffer functionality ----*/ pub struct BitBuffer(pub Vec); impl BitBuffer { // Appends the given number of low bits of the given value // to this sequence. Requires 0 <= val < 2^len. pub fn append_bits(&mut self, val: u32, len: u8) { assert!(len < 32 && (val >> len) == 0 || len == 32, "Value out of range"); for i in (0 .. len).rev() { // Append bit by bit self.0.push((val >> i) & 1 != 0); } } } /*---- Miscellaneous values ----*/ #[derive(Copy, Clone)] pub struct Version(u8); impl Version { pub fn new(ver: u8) -> Self { assert!(QrCode_MIN_VERSION.value() <= ver && ver <= QrCode_MAX_VERSION.value(), "Version number out of range"); Version(ver) } pub fn value(&self) -> u8 { self.0 } } #[derive(Copy, Clone)] pub struct Mask(u8); impl Mask { pub fn new(mask: u8) -> Self { assert!(mask <= 7, "Mask value out of range"); Mask(mask) } pub fn value(&self) -> u8 { self.0 } } uTox/third_party/qrcodegen/qrcodegen/rust/examples/0000700000175000001440000000000014003056224021555 5ustar rakusersuTox/third_party/qrcodegen/qrcodegen/rust/examples/qrcodegen-worker.rs0000600000175000001440000000746414003056224025416 0ustar rakusers/* * QR Code generator test worker (Rust) * * This program reads data and encoding parameters from standard input and writes * QR Code bitmaps to standard output. The I/O format is one integer per line. * Run with no command line arguments. The program is intended for automated * batch testing of end-to-end functionality of this QR Code generator library. * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ extern crate qrcodegen; use qrcodegen::Mask; use qrcodegen::QrCode; use qrcodegen::QrCodeEcc; use qrcodegen::QrSegment; use qrcodegen::Version; fn main() { loop { // Read data length or exit let length: i16 = read_int(); if length == -1 { break; } // Read data bytes let mut data = Vec::::with_capacity(length as usize); for _ in 0 .. length { let b: i16 = read_int(); assert_eq!((b as u8) as i16, b, "Byte value out of range"); data.push(b as u8); } let isascii: bool = data.iter().all(|b| *b < 128); // Read encoding parameters let errcorlvl = read_int(); let minversion = read_int(); let maxversion = read_int(); let mask = read_int(); let boostecl = read_int(); assert!(0 <= errcorlvl && errcorlvl <= 3); assert!((qrcodegen::QrCode_MIN_VERSION.value() as i16) <= minversion && minversion <= maxversion && maxversion <= (qrcodegen::QrCode_MAX_VERSION.value() as i16)); assert!(-1 <= mask && mask <= 7); assert!(boostecl >> 1 == 0); // Make segments for encoding let segs: Vec; if isascii { let chrs: Vec = std::str::from_utf8(&data).unwrap().chars().collect(); segs = QrSegment::make_segments(&chrs); } else { segs = vec![QrSegment::make_bytes(&data)]; } // Try to make QR Code symbol let msk = if mask == -1 { None } else { Some(Mask::new(mask as u8)) }; match QrCode::encode_segments_advanced(&segs, ECC_LEVELS[errcorlvl as usize], Version::new(minversion as u8), Version::new(maxversion as u8), msk, boostecl != 0) { Some(qr) => { // Print grid of modules println!("{}", qr.version().value()); for y in 0 .. qr.size() { for x in 0 .. qr.size() { println!("{}", qr.get_module(x, y) as i8); } } }, None => println!("-1"), } use std::io::Write; std::io::stdout().flush().unwrap(); } } fn read_int() -> i16 { let mut line = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut chrs: Vec = line.chars().collect(); assert_eq!(chrs.pop().unwrap(), '\n'); let line: String = chrs.iter().cloned().collect(); match line.parse::() { Ok(x) => x, Err(_) => panic!("Invalid number"), } } static ECC_LEVELS: [QrCodeEcc; 4] = [ QrCodeEcc::Low, QrCodeEcc::Medium, QrCodeEcc::Quartile, QrCodeEcc::High, ]; uTox/third_party/qrcodegen/qrcodegen/rust/examples/qrcodegen-demo.rs0000600000175000001440000001667014003056224025030 0ustar rakusers/* * QR Code generator demo (Rust) * * Run this command-line program with no arguments. The program computes a bunch of demonstration * QR Codes and prints them to the console. Also, the SVG code for one QR Code is printed as a sample. * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ extern crate qrcodegen; use qrcodegen::Mask; use qrcodegen::QrCode; use qrcodegen::QrCodeEcc; use qrcodegen::QrSegment; use qrcodegen::QrCode_MAX_VERSION; use qrcodegen::QrCode_MIN_VERSION; // The main application program. fn main() { do_basic_demo(); do_variety_demo(); do_segment_demo(); do_mask_demo(); } /*---- Demo suite ----*/ // Creates a single QR Code, then prints it to the console. fn do_basic_demo() { let text: &'static str = "Hello, world!"; // User-supplied Unicode text let errcorlvl: QrCodeEcc = QrCodeEcc::Low; // Error correction level // Make and print the QR Code symbol let qr: QrCode = QrCode::encode_text(text, errcorlvl).unwrap(); print_qr(&qr); println!("{}", qr.to_svg_string(4)); } // Creates a variety of QR Codes that exercise different features of the library, and prints each one to the console. fn do_variety_demo() { // Numeric mode encoding (3.33 bits per digit) let qr = QrCode::encode_text("314159265358979323846264338327950288419716939937510", QrCodeEcc::Medium).unwrap(); print_qr(&qr); // Alphanumeric mode encoding (5.5 bits per character) let qr = QrCode::encode_text("DOLLAR-AMOUNT:$39.87 PERCENTAGE:100.00% OPERATIONS:+-*/", QrCodeEcc::High).unwrap(); print_qr(&qr); // Unicode text as UTF-8 let qr = QrCode::encode_text("こんにちwa、世界! αβγδ", QrCodeEcc::Quartile).unwrap(); print_qr(&qr); // Moderately large QR Code using longer text (from Lewis Carroll's Alice in Wonderland) let qr = QrCode::encode_text(concat!( "Alice was beginning to get very tired of sitting by her sister on the bank, ", "and of having nothing to do: once or twice she had peeped into the book her sister was reading, ", "but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice ", "'without pictures or conversations?' So she was considering in her own mind (as well as she could, ", "for the hot day made her feel very sleepy and stupid), whether the pleasure of making a ", "daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly ", "a White Rabbit with pink eyes ran close by her."), QrCodeEcc::High).unwrap(); print_qr(&qr); } // Creates QR Codes with manually specified segments for better compactness. fn do_segment_demo() { // Illustration "silver" let silver0 = "THE SQUARE ROOT OF 2 IS 1."; let silver1 = "41421356237309504880168872420969807856967187537694807317667973799"; let qr = QrCode::encode_text(&[silver0, silver1].concat(), QrCodeEcc::Low).unwrap(); print_qr(&qr); let segs = vec![ QrSegment::make_alphanumeric(&to_chars(silver0)), QrSegment::make_numeric(&to_chars(silver1)), ]; let qr = QrCode::encode_segments(&segs, QrCodeEcc::Low).unwrap(); print_qr(&qr); // Illustration "golden" let golden0 = "Golden ratio φ = 1."; let golden1 = "6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911374"; let golden2 = "......"; let qr = QrCode::encode_text(&[golden0, golden1, golden2].concat(), QrCodeEcc::Low).unwrap(); print_qr(&qr); let segs = vec![ QrSegment::make_bytes(golden0.as_bytes()), QrSegment::make_numeric(&to_chars(golden1)), QrSegment::make_alphanumeric(&to_chars(golden2)), ]; let qr = QrCode::encode_segments(&segs, QrCodeEcc::Low).unwrap(); print_qr(&qr); // Illustration "Madoka": kanji, kana, Greek, Cyrillic, full-width Latin characters let madoka = "「魔法少女まどか☆マギカ」って、 ИАИ desu κα?"; let qr = QrCode::encode_text(madoka, QrCodeEcc::Low).unwrap(); print_qr(&qr); let kanjichars: Vec = vec![ // Kanji mode encoding (13 bits per character) 0x0035, 0x1002, 0x0FC0, 0x0AED, 0x0AD7, 0x015C, 0x0147, 0x0129, 0x0059, 0x01BD, 0x018D, 0x018A, 0x0036, 0x0141, 0x0144, 0x0001, 0x0000, 0x0249, 0x0240, 0x0249, 0x0000, 0x0104, 0x0105, 0x0113, 0x0115, 0x0000, 0x0208, 0x01FF, 0x0008, ]; let mut bb = qrcodegen::BitBuffer(Vec::new()); for c in &kanjichars { bb.append_bits(*c, 13); } let segs = vec![ QrSegment::new(qrcodegen::QrSegmentMode::Kanji, kanjichars.len(), bb.0), ]; let qr = QrCode::encode_segments(&segs, QrCodeEcc::Low).unwrap(); print_qr(&qr); } // Creates QR Codes with the same size and contents but different mask patterns. fn do_mask_demo() { // Project Nayuki URL let segs = QrSegment::make_segments(&to_chars("https://www.nayuki.io/")); let qr = QrCode::encode_segments_advanced(&segs, QrCodeEcc::High, QrCode_MIN_VERSION, QrCode_MAX_VERSION, None, true).unwrap(); // Automatic mask print_qr(&qr); let qr = QrCode::encode_segments_advanced(&segs, QrCodeEcc::High, QrCode_MIN_VERSION, QrCode_MAX_VERSION, Some(Mask::new(3)), true).unwrap(); // Force mask 3 print_qr(&qr); // Chinese text as UTF-8 let segs = QrSegment::make_segments(&to_chars("維基百科(Wikipedia,聆聽i/ˌwɪkᵻˈpiːdi.ə/)是一個自由內容、公開編輯且多語言的網路百科全書協作計畫")); let qr = QrCode::encode_segments_advanced(&segs, QrCodeEcc::Medium, QrCode_MIN_VERSION, QrCode_MAX_VERSION, Some(Mask::new(0)), true).unwrap(); // Force mask 0 print_qr(&qr); let qr = QrCode::encode_segments_advanced(&segs, QrCodeEcc::Medium, QrCode_MIN_VERSION, QrCode_MAX_VERSION, Some(Mask::new(1)), true).unwrap(); // Force mask 1 print_qr(&qr); let qr = QrCode::encode_segments_advanced(&segs, QrCodeEcc::Medium, QrCode_MIN_VERSION, QrCode_MAX_VERSION, Some(Mask::new(5)), true).unwrap(); // Force mask 5 print_qr(&qr); let qr = QrCode::encode_segments_advanced(&segs, QrCodeEcc::Medium, QrCode_MIN_VERSION, QrCode_MAX_VERSION, Some(Mask::new(7)), true).unwrap(); // Force mask 7 print_qr(&qr); } /*---- Utilities ----*/ // Prints the given QrCode object to the console. fn print_qr(qr: &QrCode) { let border: i32 = 4; for y in -border .. qr.size() + border { for x in -border .. qr.size() + border { let c: char = if qr.get_module(x, y) { '█' } else { ' ' }; print!("{0}{0}", c); } println!(); } println!(); } // Converts the given borrowed string slice to a new character vector. fn to_chars(text: &str) -> Vec { text.chars().collect() } uTox/third_party/qrcodegen/qrcodegen/rust/Readme.markdown0000600000175000001440000000440514003056224022705 0ustar rakusersQR Code generator library ========================= Introduction ------------ This project aims to be the best, clearest QR Code generator library. The primary goals are flexible options and absolute correctness. Secondary goals are compact implementation size and good documentation comments. Home page with live JavaScript demo, extensive descriptions, and competitor comparisons: https://www.nayuki.io/page/qr-code-generator-library Features -------- Core features: * Available in 6 programming languages, all with nearly equal functionality: Java, JavaScript, Python, C++, C, Rust * Significantly shorter code but more documentation comments compared to competing libraries * Supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard * Output formats: Raw modules/pixels of the QR symbol, SVG XML string * Encodes numeric and special-alphanumeric text in less space than general text * Open source code under the permissive MIT License Manual parameters: * User can specify minimum and maximum version numbers allowed, then library will automatically choose smallest version in the range that fits the data * User can specify mask pattern manually, otherwise library will automatically evaluate all 8 masks and select the optimal one * User can specify absolute error correction level, or allow the library to boost it if it doesn't increase the version number * User can create a list of data segments manually and add ECI segments Examples -------- extern crate qrcodegen; use qrcodegen::QrCode; use qrcodegen::QrCodeEcc; use qrcodegen::QrSegment; // Simple operation let qr0 = QrCode::encode_text("Hello, world!", QrCodeEcc::Medium).unwrap(); let svg = qr0.to_svg_string(4); // Manual operation let chrs: Vec = "3141592653589793238462643383".chars().collect(); let segs = QrSegment::make_segments(&chrs); let qr1 = QrCode::encode_segments_advanced( &segs, QrCodeEcc::High, 5, 5, Some(2), false).unwrap(); for y in 0 .. qr1.size() { for x in 0 .. qr1.size() { (... paint qr1.get_module(x, y) ...) } } More complete set of examples: https://github.com/nayuki/QR-Code-generator/blob/master/rust/examples/qrcodegen-demo.rs . uTox/third_party/qrcodegen/qrcodegen/rust/Cargo.toml0000600000175000001440000000062114003056224021670 0ustar rakusers[package] name = "qrcodegen" version = "1.2.1" authors = ["Project Nayuki"] description = "High-quality QR Code generator library" homepage = "https://www.nayuki.io/page/qr-code-generator-library" repository = "https://github.com/nayuki/QR-Code-generator" readme = "Readme.markdown" keywords = ["qr-code", "barcode", "encoder", "image"] categories = ["encoding", "multimedia::images"] license = "MIT" uTox/third_party/qrcodegen/qrcodegen/python/0000700000175000001440000000000014003056224020263 5ustar rakusersuTox/third_party/qrcodegen/qrcodegen/python/setup.py0000600000175000001440000001107014003056224021776 0ustar rakusers# # QR Code generator Distutils script (Python 2, 3) # # Copyright (c) Project Nayuki. (MIT License) # https://www.nayuki.io/page/qr-code-generator-library # # 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. # import setuptools setuptools.setup( name = "qrcodegen", description = "High quality QR Code generator library for Python 2 and 3", version = "1.2.0", platforms = "OS Independent", license = "MIT License", author = "Project Nayuki", author_email = "me@nayuki.io", url = "https://www.nayuki.io/page/qr-code-generator-library", classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Multimedia :: Graphics", "Topic :: Software Development :: Libraries :: Python Modules", ], long_description = """========================= QR Code generator library ========================= Introduction ------------ This project aims to be the best, clearest QR Code generator library. The primary goals are flexible options and absolute correctness. Secondary goals are compact implementation size and good documentation comments. Home page with live JavaScript demo, extensive descriptions, and competitor comparisons: https://www.nayuki.io/page/qr-code-generator-library Features -------- Core features: * Available in 6 programming languages, all with nearly equal functionality: Java, JavaScript, Python, C++, C, Rust * Significantly shorter code but more documentation comments compared to competing libraries * Supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard * Output formats: Raw modules/pixels of the QR symbol, SVG XML string * Encodes numeric and special-alphanumeric text in less space than general text * Open source code under the permissive MIT License Manual parameters: * User can specify minimum and maximum version numbers allowed, then library will automatically choose smallest version in the range that fits the data * User can specify mask pattern manually, otherwise library will automatically evaluate all 8 masks and select the optimal one * User can specify absolute error correction level, or allow the library to boost it if it doesn't increase the version number * User can create a list of data segments manually and add ECI segments Usage ----- Install this package by downloading the source code ZIP file from PyPI_, or by running ``pip install qrcodegen``. Examples: from qrcodegen import * # Simple operation qr0 = QrCode.encode_text("Hello, world!", QrCode.Ecc.MEDIUM) svg = qr0.to_svg_str(4) # Manual operation segs = QrSegment.make_segments("3141592653589793238462643383") qr1 = QrCode.encode_segments(segs, QrCode.Ecc.HIGH, 5, 5, 2, False) border = 4 for y in range(-border, qr1.get_size() + border): for x in range(-border, qr1.get_size() + border): color = qr1.get_module(x, y) # False for white, True for black # (... paint the module onto pixels ...) More complete set of examples: https://github.com/nayuki/QR-Code-generator/blob/master/python/qrcodegen-demo.py . API documentation is in the source file itself, with a summary comment at the top: https://github.com/nayuki/QR-Code-generator/blob/master/python/qrcodegen.py . .. _PyPI: https://pypi.python.org/pypi/qrcodegen""", py_modules = ["qrcodegen"], ) uTox/third_party/qrcodegen/qrcodegen/python/setup.cfg0000600000175000001440000000003414003056224022103 0ustar rakusers[bdist_wheel] universal = 1 uTox/third_party/qrcodegen/qrcodegen/python/qrcodegen.py0000600000175000001440000010325714003056224022616 0ustar rakusers# # QR Code generator library (Python 2, 3) # # Copyright (c) Project Nayuki. (MIT License) # https://www.nayuki.io/page/qr-code-generator-library # # 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. # import itertools, re, sys """ This module "qrcodegen", public members: - Class QrCode: - Function encode_text(str text, QrCode.Ecc ecl) -> QrCode - Function encode_binary(bytes data, QrCode.Ecc ecl) -> QrCode - Function encode_segments(list segs, QrCode.Ecc ecl, int minversion=1, int maxversion=40, mask=-1, boostecl=true) -> QrCode - Constants int MIN_VERSION, MAX_VERSION - Constructor QrCode(bytes datacodewords, int mask, int version, QrCode.Ecc ecl) - Method get_version() -> int - Method get_size() -> int - Method get_error_correction_level() -> QrCode.Ecc - Method get_mask() -> int - Method get_module(int x, int y) -> bool - Method to_svg_str(int border) -> str - Enum Ecc: - Constants LOW, MEDIUM, QUARTILE, HIGH - Field int ordinal - Class QrSegment: - Function make_bytes(bytes data) -> QrSegment - Function make_numeric(str digits) -> QrSegment - Function make_alphanumeric(str text) -> QrSegment - Function make_segments(str text) -> list - Function make_eci(int assignval) -> QrSegment - Constructor QrSegment(QrSegment.Mode mode, int numch, list bitdata) - Method get_mode() -> QrSegment.Mode - Method get_num_chars() -> int - Method get_bits() -> list - Constants regex NUMERIC_REGEX, ALPHANUMERIC_REGEX - Enum Mode: - Constants NUMERIC, ALPHANUMERIC, BYTE, KANJI, ECI """ # ---- QR Code symbol class ---- class QrCode(object): """Represents an immutable square grid of black or white cells for a QR Code symbol. This class covers the QR Code model 2 specification, supporting all versions (sizes) from 1 to 40, all 4 error correction levels.""" # ---- Public static factory functions ---- @staticmethod def encode_text(text, ecl): """Returns a QR Code symbol representing the specified Unicode text string at the specified error correction level. As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.""" segs = QrSegment.make_segments(text) return QrCode.encode_segments(segs, ecl) @staticmethod def encode_binary(data, ecl): """Returns a QR Code symbol representing the given binary data string at the given error correction level. This function always encodes using the binary segment mode, not any text mode. The maximum number of bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.""" if not isinstance(data, (bytes, bytearray)): raise TypeError("Byte string/list expected") return QrCode.encode_segments([QrSegment.make_bytes(data)], ecl) @staticmethod def encode_segments(segs, ecl, minversion=1, maxversion=40, mask=-1, boostecl=True): """Returns a QR Code symbol representing the given data segments with the given encoding parameters. The smallest possible QR Code version within the given range is automatically chosen for the output. This function allows the user to create a custom sequence of segments that switches between modes (such as alphanumeric and binary) to encode text more efficiently. This function is considered to be lower level than simply encoding text or binary data.""" if not (QrCode.MIN_VERSION <= minversion <= maxversion <= QrCode.MAX_VERSION) or not (-1 <= mask <= 7): raise ValueError("Invalid value") # Find the minimal version number to use for version in range(minversion, maxversion + 1): datacapacitybits = QrCode._get_num_data_codewords(version, ecl) * 8 # Number of data bits available datausedbits = QrSegment.get_total_bits(segs, version) if datausedbits is not None and datausedbits <= datacapacitybits: break # This version number is found to be suitable if version >= maxversion: # All versions in the range could not fit the given data raise ValueError("Data too long") if datausedbits is None: raise AssertionError() # Increase the error correction level while the data still fits in the current version number for newecl in (QrCode.Ecc.MEDIUM, QrCode.Ecc.QUARTILE, QrCode.Ecc.HIGH): if boostecl and datausedbits <= QrCode._get_num_data_codewords(version, newecl) * 8: ecl = newecl # Create the data bit string by concatenating all segments datacapacitybits = QrCode._get_num_data_codewords(version, ecl) * 8 bb = _BitBuffer() for seg in segs: bb.append_bits(seg.get_mode().get_mode_bits(), 4) bb.append_bits(seg.get_num_chars(), seg.get_mode().num_char_count_bits(version)) bb.extend(seg._bitdata) # Add terminator and pad up to a byte if applicable bb.append_bits(0, min(4, datacapacitybits - len(bb))) bb.append_bits(0, -len(bb) % 8) # Note: Python's modulo on negative numbers behaves better than C family languages # Pad with alternate bytes until data capacity is reached for padbyte in itertools.cycle((0xEC, 0x11)): if len(bb) >= datacapacitybits: break bb.append_bits(padbyte, 8) assert len(bb) % 8 == 0 # Create the QR Code symbol return QrCode(bb.get_bytes(), mask, version, ecl) # ---- Public constants ---- MIN_VERSION = 1 MAX_VERSION = 40 # ---- Constructor ---- def __init__(self, datacodewords, mask, version, errcorlvl): """Creates a new QR Code symbol with the given version number, error correction level, binary data array, and mask number. mask = -1 is for automatic choice, or 0 to 7 for fixed choice. This is a cumbersome low-level constructor that should not be invoked directly by the user. To go one level up, see the QrCode.encode_segments() function.""" # Check arguments and handle simple scalar fields if not (-1 <= mask <= 7): raise ValueError("Mask value out of range") if not (QrCode.MIN_VERSION <= version <= QrCode.MAX_VERSION): raise ValueError("Version value out of range") if not isinstance(errcorlvl, QrCode.Ecc): raise TypeError("QrCode.Ecc expected") self._version = version self._errcorlvl = errcorlvl self._size = version * 4 + 17 if len(datacodewords) != QrCode._get_num_data_codewords(version, errcorlvl): raise ValueError("Invalid array length") # Initialize grids of modules self._modules = [[False] * self._size for _ in range(self._size)] # The modules of the QR symbol; start with entirely white grid self._isfunction = [[False] * self._size for _ in range(self._size)] # Indicates function modules that are not subjected to masking # Draw function patterns, draw all codewords self._draw_function_patterns() allcodewords = self._append_error_correction(datacodewords) self._draw_codewords(allcodewords) # Handle masking if mask == -1: # Automatically choose best mask minpenalty = 1 << 32 for i in range(8): self._draw_format_bits(i) self._apply_mask(i) penalty = self._get_penalty_score() if penalty < minpenalty: mask = i minpenalty = penalty self._apply_mask(i) # Undoes the mask due to XOR assert 0 <= mask <= 7 self._draw_format_bits(mask) # Overwrite old format bits self._apply_mask(mask) # Apply the final choice of mask self._mask = mask # ---- Accessor methods ---- def get_version(self): """Returns this QR Code symbol's version number, which is always between 1 and 40 (inclusive).""" return self._version def get_size(self): """Returns the width and height of this QR Code symbol, measured in modules. Always equal to version * 4 + 17, in the range 21 to 177.""" return self._size def get_error_correction_level(self): """Returns the error correction level used in this QR Code symbol.""" return self._errcorlvl def get_mask(self): """Returns the mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer). Note that even if a constructor was called with automatic masking requested (mask = -1), the resulting object will still have a mask value between 0 and 7.""" return self._mask def get_module(self, x, y): """Returns the color of the module (pixel) at the given coordinates, which is either False for white or True for black. The top left corner has the coordinates (x=0, y=0). If the given coordinates are out of bounds, then False (white) is returned.""" return (0 <= x < self._size) and (0 <= y < self._size) and self._modules[y][x] # ---- Public instance methods ---- def to_svg_str(self, border): """Based on the given number of border modules to add as padding, this returns a string whose contents represents an SVG XML file that depicts this QR Code symbol.""" if border < 0: raise ValueError("Border must be non-negative") parts = [] for y in range(-border, self._size + border): for x in range(-border, self._size + border): if self.get_module(x, y): parts.append("M{},{}h1v1h-1z".format(x + border, y + border)) return """ """.format(self._size + border * 2, " ".join(parts)) # ---- Private helper methods for constructor: Drawing function modules ---- def _draw_function_patterns(self): # Draw horizontal and vertical timing patterns for i in range(self._size): self._set_function_module(6, i, i % 2 == 0) self._set_function_module(i, 6, i % 2 == 0) # Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules) self._draw_finder_pattern(3, 3) self._draw_finder_pattern(self._size - 4, 3) self._draw_finder_pattern(3, self._size - 4) # Draw numerous alignment patterns alignpatpos = QrCode._get_alignment_pattern_positions(self._version) numalign = len(alignpatpos) skips = ((0, 0), (0, numalign - 1), (numalign - 1, 0)) # Skip the three finder corners for i in range(numalign): for j in range(numalign): if (i, j) not in skips: self._draw_alignment_pattern(alignpatpos[i], alignpatpos[j]) # Draw configuration data self._draw_format_bits(0) # Dummy mask value; overwritten later in the constructor self._draw_version() def _draw_format_bits(self, mask): """Draws two copies of the format bits (with its own error correction code) based on the given mask and this object's error correction level field.""" # Calculate error correction code and pack bits data = self._errcorlvl.formatbits << 3 | mask # errCorrLvl is uint2, mask is uint3 rem = data for _ in range(10): rem = (rem << 1) ^ ((rem >> 9) * 0x537) data = data << 10 | rem data ^= 0x5412 # uint15 assert data >> 15 == 0 # Draw first copy for i in range(0, 6): self._set_function_module(8, i, (data >> i) & 1 != 0) self._set_function_module(8, 7, (data >> 6) & 1 != 0) self._set_function_module(8, 8, (data >> 7) & 1 != 0) self._set_function_module(7, 8, (data >> 8) & 1 != 0) for i in range(9, 15): self._set_function_module(14 - i, 8, (data >> i) & 1 != 0) # Draw second copy for i in range(0, 8): self._set_function_module(self._size - 1 - i, 8, (data >> i) & 1 != 0) for i in range(8, 15): self._set_function_module(8, self._size - 15 + i, (data >> i) & 1 != 0) self._set_function_module(8, self._size - 8, True) def _draw_version(self): """Draws two copies of the version bits (with its own error correction code), based on this object's version field (which only has an effect for 7 <= version <= 40).""" if self._version < 7: return # Calculate error correction code and pack bits rem = self._version # version is uint6, in the range [7, 40] for _ in range(12): rem = (rem << 1) ^ ((rem >> 11) * 0x1F25) data = self._version << 12 | rem # uint18 assert data >> 18 == 0 # Draw two copies for i in range(18): bit = (data >> i) & 1 != 0 a, b = self._size - 11 + i % 3, i // 3 self._set_function_module(a, b, bit) self._set_function_module(b, a, bit) def _draw_finder_pattern(self, x, y): """Draws a 9*9 finder pattern including the border separator, with the center module at (x, y).""" for i in range(-4, 5): for j in range(-4, 5): xx, yy = x + j, y + i if (0 <= xx < self._size) and (0 <= yy < self._size): # Chebyshev/infinity norm self._set_function_module(xx, yy, max(abs(i), abs(j)) not in (2, 4)) def _draw_alignment_pattern(self, x, y): """Draws a 5*5 alignment pattern, with the center module at (x, y).""" for i in range(-2, 3): for j in range(-2, 3): self._set_function_module(x + j, y + i, max(abs(i), abs(j)) != 1) def _set_function_module(self, x, y, isblack): """Sets the color of a module and marks it as a function module. Only used by the constructor. Coordinates must be in range.""" assert type(isblack) is bool self._modules[y][x] = isblack self._isfunction[y][x] = True # ---- Private helper methods for constructor: Codewords and masking ---- def _append_error_correction(self, data): """Returns a new byte string representing the given data with the appropriate error correction codewords appended to it, based on this object's version and error correction level.""" version = self._version assert len(data) == QrCode._get_num_data_codewords(version, self._errcorlvl) # Calculate parameter numbers numblocks = QrCode._NUM_ERROR_CORRECTION_BLOCKS[self._errcorlvl.ordinal][version] blockecclen = QrCode._ECC_CODEWORDS_PER_BLOCK[self._errcorlvl.ordinal][version] rawcodewords = QrCode._get_num_raw_data_modules(version) // 8 numshortblocks = numblocks - rawcodewords % numblocks shortblocklen = rawcodewords // numblocks # Split data into blocks and append ECC to each block blocks = [] rs = _ReedSolomonGenerator(blockecclen) k = 0 for i in range(numblocks): dat = data[k : k + shortblocklen - blockecclen + (0 if i < numshortblocks else 1)] k += len(dat) ecc = rs.get_remainder(dat) if i < numshortblocks: dat.append(0) dat.extend(ecc) blocks.append(dat) assert k == len(data) # Interleave (not concatenate) the bytes from every block into a single sequence result = [] for i in range(len(blocks[0])): for (j, blk) in enumerate(blocks): # Skip the padding byte in short blocks if i != shortblocklen - blockecclen or j >= numshortblocks: result.append(blk[i]) assert len(result) == rawcodewords return result def _draw_codewords(self, data): """Draws the given sequence of 8-bit codewords (data and error correction) onto the entire data area of this QR Code symbol. Function modules need to be marked off before this is called.""" assert len(data) == QrCode._get_num_raw_data_modules(self._version) // 8 i = 0 # Bit index into the data # Do the funny zigzag scan for right in range(self._size - 1, 0, -2): # Index of right column in each column pair if right <= 6: right -= 1 for vert in range(self._size): # Vertical counter for j in range(2): x = right - j # Actual x coordinate upward = (right + 1) & 2 == 0 y = (self._size - 1 - vert) if upward else vert # Actual y coordinate if not self._isfunction[y][x] and i < len(data) * 8: self._modules[y][x] = (data[i >> 3] >> (7 - (i & 7))) & 1 != 0 i += 1 # If there are any remainder bits (0 to 7), they are already # set to 0/false/white when the grid of modules was initialized assert i == len(data) * 8 def _apply_mask(self, mask): """XORs the data modules in this QR Code with the given mask pattern. Due to XOR's mathematical properties, calling applyMask(m) twice with the same value is equivalent to no change at all. This means it is possible to apply a mask, undo it, and try another mask. Note that a final well-formed QR Code symbol needs exactly one mask applied (not zero, not two, etc.).""" if not (0 <= mask <= 7): raise ValueError("Mask value out of range") masker = QrCode._MASK_PATTERNS[mask] for y in range(self._size): for x in range(self._size): self._modules[y][x] ^= (masker(x, y) == 0) and (not self._isfunction[y][x]) def _get_penalty_score(self): """Calculates and returns the penalty score based on state of this QR Code's current modules. This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.""" result = 0 size = self._size modules = self._modules # Adjacent modules in row having same color for y in range(size): for x in range(size): if x == 0 or modules[y][x] != colorx: colorx = modules[y][x] runx = 1 else: runx += 1 if runx == 5: result += QrCode._PENALTY_N1 elif runx > 5: result += 1 # Adjacent modules in column having same color for x in range(size): for y in range(size): if y == 0 or modules[y][x] != colory: colory = modules[y][x] runy = 1 else: runy += 1 if runy == 5: result += QrCode._PENALTY_N1 elif runy > 5: result += 1 # 2*2 blocks of modules having same color for y in range(size - 1): for x in range(size - 1): if modules[y][x] == modules[y][x + 1] == modules[y + 1][x] == modules[y + 1][x + 1]: result += QrCode._PENALTY_N2 # Finder-like pattern in rows for y in range(size): bits = 0 for x in range(size): bits = ((bits << 1) & 0x7FF) | (1 if modules[y][x] else 0) if x >= 10 and bits in (0x05D, 0x5D0): # Needs 11 bits accumulated result += QrCode._PENALTY_N3 # Finder-like pattern in columns for x in range(size): bits = 0 for y in range(size): bits = ((bits << 1) & 0x7FF) | (1 if modules[y][x] else 0) if y >= 10 and bits in (0x05D, 0x5D0): # Needs 11 bits accumulated result += QrCode._PENALTY_N3 # Balance of black and white modules black = sum((1 if cell else 0) for row in modules for cell in row) total = size**2 # Find smallest k such that (45-5k)% <= dark/total <= (55+5k)% for k in itertools.count(): if (9-k)*total <= black*20 <= (11+k)*total: break result += QrCode._PENALTY_N4 return result # ---- Private static helper functions ---- @staticmethod def _get_alignment_pattern_positions(ver): """Returns a sequence of positions of the alignment patterns in ascending order. These positions are used on both the x and y axes. Each value in the resulting sequence is in the range [0, 177). This stateless pure function could be implemented as table of 40 variable-length lists of integers.""" if not (QrCode.MIN_VERSION <= ver <= QrCode.MAX_VERSION): raise ValueError("Version number out of range") elif ver == 1: return [] else: numalign = ver // 7 + 2 if ver != 32: # ceil((size - 13) / (2*numalign - 2)) * 2 step = (ver * 4 + numalign * 2 + 1) // (2 * numalign - 2) * 2 else: # C-C-C-Combo breaker! step = 26 result = [6] pos = ver * 4 + 10 for _ in range(numalign - 1): result.insert(1, pos) pos -= step return result @staticmethod def _get_num_raw_data_modules(ver): """Returns the number of data bits that can be stored in a QR Code of the given version number, after all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8. The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.""" if not (QrCode.MIN_VERSION <= ver <= QrCode.MAX_VERSION): raise ValueError("Version number out of range") result = (16 * ver + 128) * ver + 64 if ver >= 2: numalign = ver // 7 + 2 result -= (25 * numalign - 10) * numalign - 55 if ver >= 7: result -= 18 * 2 # Subtract version information return result @staticmethod def _get_num_data_codewords(ver, ecl): """Returns the number of 8-bit data (i.e. not error correction) codewords contained in any QR Code of the given version number and error correction level, with remainder bits discarded. This stateless pure function could be implemented as a (40*4)-cell lookup table.""" if not (QrCode.MIN_VERSION <= ver <= QrCode.MAX_VERSION): raise ValueError("Version number out of range") return QrCode._get_num_raw_data_modules(ver) // 8 \ - QrCode._ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] \ * QrCode._NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver] # ---- Private tables of constants ---- # For use in getPenaltyScore(), when evaluating which mask is best. _PENALTY_N1 = 3 _PENALTY_N2 = 3 _PENALTY_N3 = 40 _PENALTY_N4 = 10 _ECC_CODEWORDS_PER_BLOCK = ( # Version: (note that index 0 is for padding, and is set to an illegal value) # 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level (None, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30), # Low (None, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28), # Medium (None, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30), # Quartile (None, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30)) # High _NUM_ERROR_CORRECTION_BLOCKS = ( # Version: (note that index 0 is for padding, and is set to an illegal value) # 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level (None, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25), # Low (None, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49), # Medium (None, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68), # Quartile (None, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81)) # High _MASK_PATTERNS = ( (lambda x, y: (x + y) % 2 ), (lambda x, y: y % 2 ), (lambda x, y: x % 3 ), (lambda x, y: (x + y) % 3 ), (lambda x, y: (x // 3 + y // 2) % 2 ), (lambda x, y: x * y % 2 + x * y % 3 ), (lambda x, y: (x * y % 2 + x * y % 3) % 2 ), (lambda x, y: ((x + y) % 2 + x * y % 3) % 2), ) # ---- Public helper enumeration ---- class Ecc(object): """Represents the error correction level used in a QR Code symbol.""" # Private constructor def __init__(self, i, fb): self.ordinal = i # (Public) In the range 0 to 3 (unsigned 2-bit integer) self.formatbits = fb # (Package-private) In the range 0 to 3 (unsigned 2-bit integer) # Public constants. Create them outside the class. Ecc.LOW = Ecc(0, 1) Ecc.MEDIUM = Ecc(1, 0) Ecc.QUARTILE = Ecc(2, 3) Ecc.HIGH = Ecc(3, 2) # ---- Data segment class ---- class QrSegment(object): """Represents a character string to be encoded in a QR Code symbol. Each segment has a mode, and a sequence of characters that is already encoded as a sequence of bits. Instances of this class are immutable. This segment class imposes no length restrictions, but QR Codes have restrictions. Even in the most favorable conditions, a QR Code can only hold 7089 characters of data. Any segment longer than this is meaningless for the purpose of generating QR Codes.""" # ---- Public static factory functions ---- @staticmethod def make_bytes(data): """Returns a segment representing the given binary data encoded in byte mode.""" py3 = sys.version_info.major >= 3 if (py3 and isinstance(data, str)) or (not py3 and isinstance(data, unicode)): raise TypeError("Byte string/list expected") if not py3 and isinstance(data, str): data = bytearray(data) bb = _BitBuffer() for b in data: bb.append_bits(b, 8) return QrSegment(QrSegment.Mode.BYTE, len(data), bb) @staticmethod def make_numeric(digits): """Returns a segment representing the given string of decimal digits encoded in numeric mode.""" if QrSegment.NUMERIC_REGEX.match(digits) is None: raise ValueError("String contains non-numeric characters") bb = _BitBuffer() for i in range(0, len(digits) - 2, 3): # Process groups of 3 bb.append_bits(int(digits[i : i + 3]), 10) rem = len(digits) % 3 if rem > 0: # 1 or 2 digits remaining bb.append_bits(int(digits[-rem : ]), rem * 3 + 1) return QrSegment(QrSegment.Mode.NUMERIC, len(digits), bb) @staticmethod def make_alphanumeric(text): """Returns a segment representing the given text string encoded in alphanumeric mode. The characters allowed are: 0 to 9, A to Z (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.""" if QrSegment.ALPHANUMERIC_REGEX.match(text) is None: raise ValueError("String contains unencodable characters in alphanumeric mode") bb = _BitBuffer() for i in range(0, len(text) - 1, 2): # Process groups of 2 temp = QrSegment._ALPHANUMERIC_ENCODING_TABLE[text[i]] * 45 temp += QrSegment._ALPHANUMERIC_ENCODING_TABLE[text[i + 1]] bb.append_bits(temp, 11) if len(text) % 2 > 0: # 1 character remaining bb.append_bits(QrSegment._ALPHANUMERIC_ENCODING_TABLE[text[-1]], 6) return QrSegment(QrSegment.Mode.ALPHANUMERIC, len(text), bb) @staticmethod def make_segments(text): """Returns a new mutable list of zero or more segments to represent the given Unicode text string. The result may use various segment modes and switch modes to optimize the length of the bit stream.""" if not (isinstance(text, str) or (sys.version_info.major < 3 and isinstance(text, unicode))): raise TypeError("Text string expected") # Select the most efficient segment encoding automatically if text == "": return [] elif QrSegment.NUMERIC_REGEX.match(text) is not None: return [QrSegment.make_numeric(text)] elif QrSegment.ALPHANUMERIC_REGEX.match(text) is not None: return [QrSegment.make_alphanumeric(text)] else: return [QrSegment.make_bytes(text.encode("UTF-8"))] @staticmethod def make_eci(assignval): """Returns a segment representing an Extended Channel Interpretation (ECI) designator with the given assignment value.""" bb = _BitBuffer() if 0 <= assignval < (1 << 7): bb.append_bits(assignval, 8) elif (1 << 7) <= assignval < (1 << 14): bb.append_bits(2, 2) bb.append_bits(assignval, 14) elif (1 << 14) <= assignval < 1000000: bb.append_bits(6, 3) bb.append_bits(assignval, 21) else: raise ValueError("ECI assignment value out of range") return QrSegment(QrSegment.Mode.ECI, 0, bb) # ---- Constructor ---- def __init__(self, mode, numch, bitdata): if numch < 0 or not isinstance(mode, QrSegment.Mode): raise ValueError() self._mode = mode self._numchars = numch self._bitdata = list(bitdata) # Make defensive copy # ---- Accessor methods ---- def get_mode(self): return self._mode def get_num_chars(self): return self._numchars def get_bits(self): return list(self._bitdata) # Make defensive copy # Package-private helper function. @staticmethod def get_total_bits(segs, version): if not (QrCode.MIN_VERSION <= version <= QrCode.MAX_VERSION): raise ValueError("Version number out of range") result = 0 for seg in segs: ccbits = seg.get_mode().num_char_count_bits(version) # Fail if segment length value doesn't fit in the length field's bit-width if seg.get_num_chars() >= (1 << ccbits): return None result += 4 + ccbits + len(seg._bitdata) return result # ---- Constants ---- # (Public) Can test whether a string is encodable in numeric mode (such as by using make_numeric()) NUMERIC_REGEX = re.compile(r"[0-9]*\Z") # (Public) Can test whether a string is encodable in alphanumeric mode (such as by using make_alphanumeric()) ALPHANUMERIC_REGEX = re.compile(r"[A-Z0-9 $%*+./:-]*\Z") # (Private) Dictionary of "0"->0, "A"->10, "$"->37, etc. _ALPHANUMERIC_ENCODING_TABLE = {ch: i for (i, ch) in enumerate("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:")} # ---- Public helper enumeration ---- class Mode(object): """The mode field of a segment. Immutable.""" # Private constructor def __init__(self, modebits, charcounts): self._modebits = modebits self._charcounts = charcounts # Package-private method def get_mode_bits(self): """Returns an unsigned 4-bit integer value (range 0 to 15) representing the mode indicator bits for this mode object.""" return self._modebits # Package-private method def num_char_count_bits(self, ver): """Returns the bit width of the segment character count field for this mode object at the given version number.""" if 1 <= ver <= 9: return self._charcounts[0] elif 10 <= ver <= 26: return self._charcounts[1] elif 27 <= ver <= 40: return self._charcounts[2] else: raise ValueError("Version number out of range") # Public constants. Create them outside the class. Mode.NUMERIC = Mode(0x1, (10, 12, 14)) Mode.ALPHANUMERIC = Mode(0x2, ( 9, 11, 13)) Mode.BYTE = Mode(0x4, ( 8, 16, 16)) Mode.KANJI = Mode(0x8, ( 8, 10, 12)) Mode.ECI = Mode(0x7, ( 0, 0, 0)) # ---- Private helper classes ---- class _ReedSolomonGenerator(object): """Computes the Reed-Solomon error correction codewords for a sequence of data codewords at a given degree. Objects are immutable, and the state only depends on the degree. This class exists because each data block in a QR Code shares the same the divisor polynomial.""" def __init__(self, degree): """Creates a Reed-Solomon ECC generator for the given degree. This could be implemented as a lookup table over all possible parameter values, instead of as an algorithm.""" if degree < 1 or degree > 255: raise ValueError("Degree out of range") # Start with the monomial x^0 self.coefficients = [0] * (degree - 1) + [1] # Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}), # drop the highest term, and store the rest of the coefficients in order of descending powers. # Note that r = 0x02, which is a generator element of this field GF(2^8/0x11D). root = 1 for _ in range(degree): # Unused variable i # Multiply the current product by (x - r^i) for j in range(degree): self.coefficients[j] = _ReedSolomonGenerator._multiply(self.coefficients[j], root) if j + 1 < degree: self.coefficients[j] ^= self.coefficients[j + 1] root = _ReedSolomonGenerator._multiply(root, 0x02) def get_remainder(self, data): """Computes and returns the Reed-Solomon error correction codewords for the given sequence of data codewords. The returned object is always a new byte list. This method does not alter this object's state (because it is immutable).""" # Compute the remainder by performing polynomial division result = [0] * len(self.coefficients) for b in data: factor = b ^ result.pop(0) result.append(0) for i in range(len(result)): result[i] ^= _ReedSolomonGenerator._multiply(self.coefficients[i], factor) return result @staticmethod def _multiply(x, y): """Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.""" if x >> 8 != 0 or y >> 8 != 0: raise ValueError("Byte out of range") # Russian peasant multiplication z = 0 for i in reversed(range(8)): z = (z << 1) ^ ((z >> 7) * 0x11D) z ^= ((y >> i) & 1) * x assert z >> 8 == 0 return z class _BitBuffer(list): """An appendable sequence of bits (0's and 1's).""" def get_bytes(self): """Packs this buffer's bits into bytes in big endian, padding with '0' bit values, and returns the new list.""" result = [0] * ((len(self) + 7) // 8) for (i, bit) in enumerate(self): result[i >> 3] |= bit << (7 - (i & 7)) return result def append_bits(self, val, n): """Appends the given number of low bits of the given value to this sequence. Requires 0 <= val < 2^n.""" if n < 0 or val >> n != 0: raise ValueError("Value out of range") self.extend(((val >> i) & 1) for i in reversed(range(n))) uTox/third_party/qrcodegen/qrcodegen/python/qrcodegen-worker.py0000600000175000001440000000556114003056224024124 0ustar rakusers# # QR Code generator test worker (Python 2, 3) # # This program reads data and encoding parameters from standard input and writes # QR Code bitmaps to standard output. The I/O format is one integer per line. # Run with no command line arguments. The program is intended for automated # batch testing of end-to-end functionality of this QR Code generator library. # # Copyright (c) Project Nayuki. (MIT License) # https://www.nayuki.io/page/qr-code-generator-library # # 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. # from __future__ import print_function import sys import qrcodegen py3 = sys.version_info.major >= 3 def read_int(): return int((input if py3 else raw_input)()) def main(): while True: # Read data or exit length = read_int() if length == -1: break data = [read_int() for _ in range(length)] # Read encoding parameters errcorlvl = read_int() minversion = read_int() maxversion = read_int() mask = read_int() boostecl = read_int() # Make segments for encoding if all((b < 128) for b in data): # Is ASCII segs = qrcodegen.QrSegment.make_segments("".join(chr(b) for b in data)) elif py3: segs = [qrcodegen.QrSegment.make_bytes(bytes(data))] else: segs = [qrcodegen.QrSegment.make_bytes("".join(chr(b) for b in data))] try: # Try to make QR Code symbol qr = qrcodegen.QrCode.encode_segments(segs, ECC_LEVELS[errcorlvl], minversion, maxversion, mask, boostecl != 0) # Print grid of modules print(qr.get_version()) for y in range(qr.get_size()): for x in range(qr.get_size()): print(1 if qr.get_module(x, y) else 0) except ValueError as e: if e.args[0] != "Data too long": raise print(-1) sys.stdout.flush() ECC_LEVELS = ( qrcodegen.QrCode.Ecc.LOW, qrcodegen.QrCode.Ecc.MEDIUM, qrcodegen.QrCode.Ecc.QUARTILE, qrcodegen.QrCode.Ecc.HIGH, ) if __name__ == "__main__": main() uTox/third_party/qrcodegen/qrcodegen/python/qrcodegen-demo.py0000600000175000001440000001673114003056224023540 0ustar rakusers# # QR Code generator demo (Python 2, 3) # # Run this command-line program with no arguments. The program computes a bunch of demonstration # QR Codes and prints them to the console. Also, the SVG code for one QR Code is printed as a sample. # # Copyright (c) Project Nayuki. (MIT License) # https://www.nayuki.io/page/qr-code-generator-library # # 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. # from __future__ import print_function from qrcodegen import QrCode, QrSegment def main(): """The main application program.""" do_basic_demo() do_variety_demo() do_segment_demo() do_mask_demo() # ---- Demo suite ---- def do_basic_demo(): """Creates a single QR Code, then prints it to the console.""" text = u"Hello, world!" # User-supplied Unicode text errcorlvl = QrCode.Ecc.LOW # Error correction level # Make and print the QR Code symbol qr = QrCode.encode_text(text, errcorlvl) print_qr(qr) print(qr.to_svg_str(4)) def do_variety_demo(): """Creates a variety of QR Codes that exercise different features of the library, and prints each one to the console.""" # Numeric mode encoding (3.33 bits per digit) qr = QrCode.encode_text("314159265358979323846264338327950288419716939937510", QrCode.Ecc.MEDIUM) print_qr(qr) # Alphanumeric mode encoding (5.5 bits per character) qr = QrCode.encode_text("DOLLAR-AMOUNT:$39.87 PERCENTAGE:100.00% OPERATIONS:+-*/", QrCode.Ecc.HIGH) print_qr(qr) # Unicode text as UTF-8 qr = QrCode.encode_text(u"\u3053\u3093\u306B\u3061\u0077\u0061\u3001\u4E16\u754C\uFF01\u0020\u03B1\u03B2\u03B3\u03B4", QrCode.Ecc.QUARTILE) print_qr(qr) # Moderately large QR Code using longer text (from Lewis Carroll's Alice in Wonderland) qr = QrCode.encode_text( "Alice was beginning to get very tired of sitting by her sister on the bank, " "and of having nothing to do: once or twice she had peeped into the book her sister was reading, " "but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice " "'without pictures or conversations?' So she was considering in her own mind (as well as she could, " "for the hot day made her feel very sleepy and stupid), whether the pleasure of making a " "daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly " "a White Rabbit with pink eyes ran close by her.", QrCode.Ecc.HIGH) print_qr(qr) def do_segment_demo(): """Creates QR Codes with manually specified segments for better compactness.""" # Illustration "silver" silver0 = "THE SQUARE ROOT OF 2 IS 1." silver1 = "41421356237309504880168872420969807856967187537694807317667973799" qr = QrCode.encode_text(silver0 + silver1, QrCode.Ecc.LOW) print_qr(qr) segs = [ QrSegment.make_alphanumeric(silver0), QrSegment.make_numeric(silver1)] qr = QrCode.encode_segments(segs, QrCode.Ecc.LOW) print_qr(qr) # Illustration "golden" golden0 = u"Golden ratio \u03C6 = 1." golden1 = u"6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911374" golden2 = u"......" qr = QrCode.encode_text(golden0 + golden1 + golden2, QrCode.Ecc.LOW) print_qr(qr) segs = [ QrSegment.make_bytes(golden0.encode("UTF-8")), QrSegment.make_numeric(golden1), QrSegment.make_alphanumeric(golden2)] qr = QrCode.encode_segments(segs, QrCode.Ecc.LOW) print_qr(qr) # Illustration "Madoka": kanji, kana, Greek, Cyrillic, full-width Latin characters madoka = u"\u300C\u9B54\u6CD5\u5C11\u5973\u307E\u3069\u304B\u2606\u30DE\u30AE\u30AB\u300D\u3063\u3066\u3001\u3000\u0418\u0410\u0418\u3000\uFF44\uFF45\uFF53\uFF55\u3000\u03BA\u03B1\uFF1F" qr = QrCode.encode_text(madoka, QrCode.Ecc.LOW) print_qr(qr) kanjiCharBits = [ # Kanji mode encoding (13 bits per character) 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, ] segs = [QrSegment(QrSegment.Mode.KANJI, len(kanjiCharBits) // 13, kanjiCharBits)] qr = QrCode.encode_segments(segs, QrCode.Ecc.LOW) print_qr(qr) def do_mask_demo(): """Creates QR Codes with the same size and contents but different mask patterns.""" # Project Nayuki URL segs = QrSegment.make_segments("https://www.nayuki.io/") print_qr(QrCode.encode_segments(segs, QrCode.Ecc.HIGH, mask=-1)) # Automatic mask print_qr(QrCode.encode_segments(segs, QrCode.Ecc.HIGH, mask=3)) # Force mask 3 # Chinese text as UTF-8 segs = QrSegment.make_segments( u"\u7DAD\u57FA\u767E\u79D1\uFF08\u0057\u0069\u006B\u0069\u0070\u0065\u0064\u0069\u0061\uFF0C" "\u8046\u807D\u0069\u002F\u02CC\u0077\u026A\u006B\u1D7B\u02C8\u0070\u0069\u02D0\u0064\u0069" "\u002E\u0259\u002F\uFF09\u662F\u4E00\u500B\u81EA\u7531\u5167\u5BB9\u3001\u516C\u958B\u7DE8" "\u8F2F\u4E14\u591A\u8A9E\u8A00\u7684\u7DB2\u8DEF\u767E\u79D1\u5168\u66F8\u5354\u4F5C\u8A08" "\u756B") print_qr(QrCode.encode_segments(segs, QrCode.Ecc.MEDIUM, mask=0)) # Force mask 0 print_qr(QrCode.encode_segments(segs, QrCode.Ecc.MEDIUM, mask=1)) # Force mask 1 print_qr(QrCode.encode_segments(segs, QrCode.Ecc.MEDIUM, mask=5)) # Force mask 5 print_qr(QrCode.encode_segments(segs, QrCode.Ecc.MEDIUM, mask=7)) # Force mask 7 # ---- Utilities ---- def print_qr(qrcode): """Prints the given QrCode object to the console.""" border = 4 for y in range(-border, qrcode.get_size() + border): for x in range(-border, qrcode.get_size() + border): print(u"\u2588 "[1 if qrcode.get_module(x,y) else 0] * 2, end="") print() print() # Run the main program if __name__ == "__main__": main() uTox/third_party/qrcodegen/qrcodegen/python/qrcodegen-batch-test.py0000600000175000001440000001044714003056224024650 0ustar rakusers# # QR Code generator batch test (Python 3) # # Runs various versions of the QR Code generator test worker as subprocesses, # feeds each one the same random input, and compares their output for equality. # # Copyright (c) Project Nayuki. (MIT License) # https://www.nayuki.io/page/qr-code-generator-library # # 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. # from __future__ import print_function import itertools, random, subprocess, sys, time if sys.version_info.major < 3: raise RuntimeError("Requires Python 3+") CHILD_PROGRAMS = [ ["python2", "../python/qrcodegen-worker.py"], # Python 2 program ["python3", "../python/qrcodegen-worker.py"], # Python 3 program ["java", "-cp", "../java", "io/nayuki/qrcodegen/QrCodeGeneratorWorker"], # Java program ["../c/qrcodegen-worker"], # C program ["../cpp/QrCodeGeneratorWorker"], # C++ program ["../rust/target/debug/examples/qrcodegen-worker"], # Rust program ] subprocs = [] def main(): # Launch workers global subprocs try: for args in CHILD_PROGRAMS: subprocs.append(subprocess.Popen(args, universal_newlines=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)) except FileNotFoundError: write_all(-1) raise # Check if any died time.sleep(0.3) if any(proc.poll() is not None for proc in subprocs): for proc in subprocs: if proc.poll() is None: print(-1, file=proc.stdin) proc.stdin.flush() sys.exit("Error: One or more workers failed to start") # Do tests for i in itertools.count(): print("Trial {}: ".format(i), end="") do_trial() print() def do_trial(): mode = random.randrange(4) if mode == 0: # Numeric length = round((2 * 7089) ** random.random()) data = [random.randrange(48, 58) for _ in range(length)] elif mode == 1: # Alphanumeric length = round((2 * 4296) ** random.random()) data = [ord(random.choice("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:")) for _ in range(length)] elif mode == 2: # ASCII length = round((2 * 2953) ** random.random()) data = [random.randrange(128) for _ in range(length)] elif mode == 3: # Byte length = round((2 * 2953) ** random.random()) data = [random.randrange(256) for _ in range(length)] else: raise AssertionError() write_all(length) for b in data: write_all(b) errcorlvl = random.randrange(4) minversion = random.randint(1, 40) maxversion = random.randint(1, 40) if minversion > maxversion: minversion, maxversion = maxversion, minversion mask = -1 if random.random() < 0.5: mask = random.randrange(8) boostecl = int(random.random() < 0.2) print("mode={} len={} ecl={} minv={} maxv={} mask={} boost={}".format(mode, length, errcorlvl, minversion, maxversion, mask, boostecl), end="") write_all(errcorlvl) write_all(minversion) write_all(maxversion) write_all(mask) write_all(boostecl) flush_all() version = read_verify() print(" version={}".format(version), end="") if version == -1: return size = version * 4 + 17 for _ in range(size**2): read_verify() def write_all(val): for proc in subprocs: print(val, file=proc.stdin) def flush_all(): for proc in subprocs: proc.stdin.flush() def read_verify(): val = subprocs[0].stdout.readline().rstrip("\r\n") for proc in subprocs[1 : ]: if proc.stdout.readline().rstrip("\r\n") != val: raise ValueError("Mismatch") return int(val) if __name__ == "__main__": main() uTox/third_party/qrcodegen/qrcodegen/javascript/0000700000175000001440000000000014003056224021110 5ustar rakusersuTox/third_party/qrcodegen/qrcodegen/javascript/qrcodegen.js0000600000175000001440000011505614003056224023427 0ustar rakusers/* * QR Code generator library (JavaScript) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ "use strict"; /* * Module "qrcodegen", public members: * - Class QrCode: * - Function encodeText(str text, QrCode.Ecc ecl) -> QrCode * - Function encodeBinary(list data, QrCode.Ecc ecl) -> QrCode * - Function encodeSegments(list segs, QrCode.Ecc ecl, * int minVersion=1, int maxVersion=40, mask=-1, boostEcl=true) -> QrCode * - Constants int MIN_VERSION, MAX_VERSION * - Constructor QrCode(list datacodewords, int mask, int version, QrCode.Ecc ecl) * - Fields int version, size, mask * - Field QrCode.Ecc errorCorrectionLevel * - Method getModule(int x, int y) -> bool * - Method drawCanvas(int scale, int border, HTMLCanvasElement canvas) -> void * - Method toSvgString(int border) -> str * - Enum Ecc: * - Constants LOW, MEDIUM, QUARTILE, HIGH * - Field int ordinal * - Class QrSegment: * - Function makeBytes(list data) -> QrSegment * - Function makeNumeric(str data) -> QrSegment * - Function makeAlphanumeric(str data) -> QrSegment * - Function makeSegments(str text) -> list * - Function makeEci(int assignVal) -> QrSegment * - Constructor QrSegment(QrSegment.Mode mode, int numChars, list bitData) * - Field QrSegment.Mode mode * - Field int numChars * - Method getBits() -> list * - Constants RegExp NUMERIC_REGEX, ALPHANUMERIC_REGEX * - Enum Mode: * - Constants NUMERIC, ALPHANUMERIC, BYTE, KANJI, ECI */ var qrcodegen = new function() { /*---- QR Code symbol class ----*/ /* * A class that represents an immutable square grid of black and white cells for a QR Code symbol, * with associated static functions to create a QR Code from user-supplied textual or binary data. * This class covers the QR Code model 2 specification, supporting all versions (sizes) * from 1 to 40, all 4 error correction levels. * This constructor creates a new QR Code symbol with the given version number, error correction level, binary data array, * and mask number. mask = -1 is for automatic choice, or 0 to 7 for fixed choice. This is a cumbersome low-level constructor * that should not be invoked directly by the user. To go one level up, see the QrCode.encodeSegments() function. */ this.QrCode = function(datacodewords, mask, version, errCorLvl) { /*---- Constructor ----*/ // Check arguments and handle simple scalar fields if (mask < -1 || mask > 7) throw "Mask value out of range"; if (version < MIN_VERSION || version > MAX_VERSION) throw "Version value out of range"; var size = version * 4 + 17; // Initialize both grids to be size*size arrays of Boolean false var row = []; for (var i = 0; i < size; i++) row.push(false); var modules = []; var isFunction = []; for (var i = 0; i < size; i++) { modules.push(row.slice()); isFunction.push(row.slice()); } // Handle grid fields, draw function patterns, draw all codewords drawFunctionPatterns(); var allCodewords = appendErrorCorrection(datacodewords); drawCodewords(allCodewords); // Handle masking if (mask == -1) { // Automatically choose best mask var minPenalty = Infinity; for (var i = 0; i < 8; i++) { drawFormatBits(i); applyMask(i); var penalty = getPenaltyScore(); if (penalty < minPenalty) { mask = i; minPenalty = penalty; } applyMask(i); // Undoes the mask due to XOR } } if (mask < 0 || mask > 7) throw "Assertion error"; drawFormatBits(mask); // Overwrite old format bits applyMask(mask); // Apply the final choice of mask /*---- Read-only instance properties ----*/ // This QR Code symbol's version number, which is always between 1 and 40 (inclusive). Object.defineProperty(this, "version", {value:version}); // The width and height of this QR Code symbol, measured in modules. // Always equal to version * 4 + 17, in the range 21 to 177. Object.defineProperty(this, "size", {value:size}); // The error correction level used in this QR Code symbol. Object.defineProperty(this, "errorCorrectionLevel", {value:errCorLvl}); // The mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer). // Note that even if the constructor was called with automatic masking requested // (mask = -1), the resulting object will still have a mask value between 0 and 7. Object.defineProperty(this, "mask", {value:mask}); /*---- Accessor methods ----*/ // (Public) Returns the color of the module (pixel) at the given coordinates, which is either // false for white or true for black. The top left corner has the coordinates (x=0, y=0). // If the given coordinates are out of bounds, then false (white) is returned. this.getModule = function(x, y) { return 0 <= x && x < size && 0 <= y && y < size && modules[y][x]; }; // (Package-private) Tests whether the module at the given coordinates is a function module (true) or not (false). // The top left corner has the coordinates (x=0, y=0). If the given coordinates are out of bounds, then false is returned. // The JavaScript version of this library has this method because it is impossible to access private variables of another object. this.isFunctionModule = function(x, y) { if (0 <= x && x < size && 0 <= y && y < size) return isFunction[y][x]; else return false; // Infinite border }; /*---- Public instance methods ----*/ // Draws this QR Code symbol with the given module scale and number of modules onto the given HTML canvas element. // The canvas will be resized to a width and height of (this.size + border * 2) * scale. The painted image will be purely // black and white with no transparent regions. The scale must be a positive integer, and the border must be a non-negative integer. this.drawCanvas = function(scale, border, canvas) { if (scale <= 0 || border < 0) throw "Value out of range"; var width = (size + border * 2) * scale; canvas.width = width; canvas.height = width; var ctx = canvas.getContext("2d"); for (var y = -border; y < size + border; y++) { for (var x = -border; x < size + border; x++) { ctx.fillStyle = this.getModule(x, y) ? "#000000" : "#FFFFFF"; ctx.fillRect((x + border) * scale, (y + border) * scale, scale, scale); } } }; // Based on the given number of border modules to add as padding, this returns a // string whose contents represents an SVG XML file that depicts this QR Code symbol. // Note that Unix newlines (\n) are always used, regardless of the platform. this.toSvgString = function(border) { if (border < 0) throw "Border must be non-negative"; var result = '\n'; result += '\n'; result += '\n'; result += '\t\n'; result += '\t>> 9) * 0x537); data = data << 10 | rem; data ^= 0x5412; // uint15 if (data >>> 15 != 0) throw "Assertion error"; // Draw first copy for (var i = 0; i <= 5; i++) setFunctionModule(8, i, ((data >>> i) & 1) != 0); setFunctionModule(8, 7, ((data >>> 6) & 1) != 0); setFunctionModule(8, 8, ((data >>> 7) & 1) != 0); setFunctionModule(7, 8, ((data >>> 8) & 1) != 0); for (var i = 9; i < 15; i++) setFunctionModule(14 - i, 8, ((data >>> i) & 1) != 0); // Draw second copy for (var i = 0; i <= 7; i++) setFunctionModule(size - 1 - i, 8, ((data >>> i) & 1) != 0); for (var i = 8; i < 15; i++) setFunctionModule(8, size - 15 + i, ((data >>> i) & 1) != 0); setFunctionModule(8, size - 8, true); } // Draws two copies of the version bits (with its own error correction code), // based on this object's version field (which only has an effect for 7 <= version <= 40). function drawVersion() { if (version < 7) return; // Calculate error correction code and pack bits var rem = version; // version is uint6, in the range [7, 40] for (var i = 0; i < 12; i++) rem = (rem << 1) ^ ((rem >>> 11) * 0x1F25); var data = version << 12 | rem; // uint18 if (data >>> 18 != 0) throw "Assertion error"; // Draw two copies for (var i = 0; i < 18; i++) { var bit = ((data >>> i) & 1) != 0; var a = size - 11 + i % 3, b = Math.floor(i / 3); setFunctionModule(a, b, bit); setFunctionModule(b, a, bit); } } // Draws a 9*9 finder pattern including the border separator, with the center module at (x, y). function drawFinderPattern(x, y) { for (var i = -4; i <= 4; i++) { for (var j = -4; j <= 4; j++) { var dist = Math.max(Math.abs(i), Math.abs(j)); // Chebyshev/infinity norm var xx = x + j, yy = y + i; if (0 <= xx && xx < size && 0 <= yy && yy < size) setFunctionModule(xx, yy, dist != 2 && dist != 4); } } } // Draws a 5*5 alignment pattern, with the center module at (x, y). function drawAlignmentPattern(x, y) { for (var i = -2; i <= 2; i++) { for (var j = -2; j <= 2; j++) setFunctionModule(x + j, y + i, Math.max(Math.abs(i), Math.abs(j)) != 1); } } // Sets the color of a module and marks it as a function module. // Only used by the constructor. Coordinates must be in range. function setFunctionModule(x, y, isBlack) { modules[y][x] = isBlack; isFunction[y][x] = true; } /*---- Private helper methods for constructor: Codewords and masking ----*/ // Returns a new byte string representing the given data with the appropriate error correction // codewords appended to it, based on this object's version and error correction level. function appendErrorCorrection(data) { if (data.length != QrCode.getNumDataCodewords(version, errCorLvl)) throw "Invalid argument"; // Calculate parameter numbers var numBlocks = QrCode.NUM_ERROR_CORRECTION_BLOCKS[errCorLvl.ordinal][version]; var blockEccLen = QrCode.ECC_CODEWORDS_PER_BLOCK[errCorLvl.ordinal][version]; var rawCodewords = Math.floor(QrCode.getNumRawDataModules(version) / 8); var numShortBlocks = numBlocks - rawCodewords % numBlocks; var shortBlockLen = Math.floor(rawCodewords / numBlocks); // Split data into blocks and append ECC to each block var blocks = []; var rs = new ReedSolomonGenerator(blockEccLen); for (var i = 0, k = 0; i < numBlocks; i++) { var dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1)); k += dat.length; var ecc = rs.getRemainder(dat); if (i < numShortBlocks) dat.push(0); ecc.forEach(function(b) { dat.push(b); }); blocks.push(dat); } // Interleave (not concatenate) the bytes from every block into a single sequence var result = []; for (var i = 0; i < blocks[0].length; i++) { for (var j = 0; j < blocks.length; j++) { // Skip the padding byte in short blocks if (i != shortBlockLen - blockEccLen || j >= numShortBlocks) result.push(blocks[j][i]); } } if (result.length != rawCodewords) throw "Assertion error"; return result; } // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire // data area of this QR Code symbol. Function modules need to be marked off before this is called. function drawCodewords(data) { if (data.length != Math.floor(QrCode.getNumRawDataModules(version) / 8)) throw "Invalid argument"; var i = 0; // Bit index into the data // Do the funny zigzag scan for (var right = size - 1; right >= 1; right -= 2) { // Index of right column in each column pair if (right == 6) right = 5; for (var vert = 0; vert < size; vert++) { // Vertical counter for (var j = 0; j < 2; j++) { var x = right - j; // Actual x coordinate var upward = ((right + 1) & 2) == 0; var y = upward ? size - 1 - vert : vert; // Actual y coordinate if (!isFunction[y][x] && i < data.length * 8) { modules[y][x] = ((data[i >>> 3] >>> (7 - (i & 7))) & 1) != 0; i++; } // If there are any remainder bits (0 to 7), they are already // set to 0/false/white when the grid of modules was initialized } } } if (i != data.length * 8) throw "Assertion error"; } // XORs the data modules in this QR Code with the given mask pattern. Due to XOR's mathematical // properties, calling applyMask(m) twice with the same value is equivalent to no change at all. // This means it is possible to apply a mask, undo it, and try another mask. Note that a final // well-formed QR Code symbol needs exactly one mask applied (not zero, not two, etc.). function applyMask(mask) { if (mask < 0 || mask > 7) throw "Mask value out of range"; for (var y = 0; y < size; y++) { for (var x = 0; x < size; x++) { var invert; switch (mask) { case 0: invert = (x + y) % 2 == 0; break; case 1: invert = y % 2 == 0; break; case 2: invert = x % 3 == 0; break; case 3: invert = (x + y) % 3 == 0; break; case 4: invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 == 0; break; case 5: invert = x * y % 2 + x * y % 3 == 0; break; case 6: invert = (x * y % 2 + x * y % 3) % 2 == 0; break; case 7: invert = ((x + y) % 2 + x * y % 3) % 2 == 0; break; default: throw "Assertion error"; } modules[y][x] ^= invert & !isFunction[y][x]; } } } // Calculates and returns the penalty score based on state of this QR Code's current modules. // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score. function getPenaltyScore() { var result = 0; // Adjacent modules in row having same color for (var y = 0; y < size; y++) { for (var x = 0, runX, colorX; x < size; x++) { if (x == 0 || modules[y][x] != colorX) { colorX = modules[y][x]; runX = 1; } else { runX++; if (runX == 5) result += QrCode.PENALTY_N1; else if (runX > 5) result++; } } } // Adjacent modules in column having same color for (var x = 0; x < size; x++) { for (var y = 0, runY, colorY; y < size; y++) { if (y == 0 || modules[y][x] != colorY) { colorY = modules[y][x]; runY = 1; } else { runY++; if (runY == 5) result += QrCode.PENALTY_N1; else if (runY > 5) result++; } } } // 2*2 blocks of modules having same color for (var y = 0; y < size - 1; y++) { for (var x = 0; x < size - 1; x++) { var color = modules[y][x]; if ( color == modules[y][x + 1] && color == modules[y + 1][x] && color == modules[y + 1][x + 1]) result += QrCode.PENALTY_N2; } } // Finder-like pattern in rows for (var y = 0; y < size; y++) { for (var x = 0, bits = 0; x < size; x++) { bits = ((bits << 1) & 0x7FF) | (modules[y][x] ? 1 : 0); if (x >= 10 && (bits == 0x05D || bits == 0x5D0)) // Needs 11 bits accumulated result += QrCode.PENALTY_N3; } } // Finder-like pattern in columns for (var x = 0; x < size; x++) { for (var y = 0, bits = 0; y < size; y++) { bits = ((bits << 1) & 0x7FF) | (modules[y][x] ? 1 : 0); if (y >= 10 && (bits == 0x05D || bits == 0x5D0)) // Needs 11 bits accumulated result += QrCode.PENALTY_N3; } } // Balance of black and white modules var black = 0; modules.forEach(function(row) { row.forEach(function(color) { if (color) black++; }); }); var total = size * size; // Find smallest k such that (45-5k)% <= dark/total <= (55+5k)% for (var k = 0; black*20 < (9-k)*total || black*20 > (11+k)*total; k++) result += QrCode.PENALTY_N4; return result; } }; /*---- Public static factory functions for QrCode ----*/ /* * Returns a QR Code symbol representing the specified Unicode text string at the specified error correction level. * As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer * Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible * QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the * ecl argument if it can be done without increasing the version. */ this.QrCode.encodeText = function(text, ecl) { var segs = qrcodegen.QrSegment.makeSegments(text); return this.encodeSegments(segs, ecl); }; /* * Returns a QR Code symbol representing the given binary data string at the given error correction level. * This function always encodes using the binary segment mode, not any text mode. The maximum number of * bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. * The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. */ this.QrCode.encodeBinary = function(data, ecl) { var seg = qrcodegen.QrSegment.makeBytes(data); return this.encodeSegments([seg], ecl); }; /* * Returns a QR Code symbol representing the given data segments with the given encoding parameters. * The smallest possible QR Code version within the given range is automatically chosen for the output. * This function allows the user to create a custom sequence of segments that switches * between modes (such as alphanumeric and binary) to encode text more efficiently. * This function is considered to be lower level than simply encoding text or binary data. */ this.QrCode.encodeSegments = function(segs, ecl, minVersion, maxVersion, mask, boostEcl) { if (minVersion == undefined) minVersion = MIN_VERSION; if (maxVersion == undefined) maxVersion = MAX_VERSION; if (mask == undefined) mask = -1; if (boostEcl == undefined) boostEcl = true; if (!(MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= MAX_VERSION) || mask < -1 || mask > 7) throw "Invalid value"; // Find the minimal version number to use var version, dataUsedBits; for (version = minVersion; ; version++) { var dataCapacityBits = QrCode.getNumDataCodewords(version, ecl) * 8; // Number of data bits available dataUsedBits = qrcodegen.QrSegment.getTotalBits(segs, version); if (dataUsedBits != null && dataUsedBits <= dataCapacityBits) break; // This version number is found to be suitable if (version >= maxVersion) // All versions in the range could not fit the given data throw "Data too long"; } // Increase the error correction level while the data still fits in the current version number [this.Ecc.MEDIUM, this.Ecc.QUARTILE, this.Ecc.HIGH].forEach(function(newEcl) { if (boostEcl && dataUsedBits <= QrCode.getNumDataCodewords(version, newEcl) * 8) ecl = newEcl; }); // Create the data bit string by concatenating all segments var dataCapacityBits = QrCode.getNumDataCodewords(version, ecl) * 8; var bb = new BitBuffer(); segs.forEach(function(seg) { bb.appendBits(seg.mode.modeBits, 4); bb.appendBits(seg.numChars, seg.mode.numCharCountBits(version)); seg.getBits().forEach(function(bit) { bb.push(bit); }); }); // Add terminator and pad up to a byte if applicable bb.appendBits(0, Math.min(4, dataCapacityBits - bb.length)); bb.appendBits(0, (8 - bb.length % 8) % 8); // Pad with alternate bytes until data capacity is reached for (var padByte = 0xEC; bb.length < dataCapacityBits; padByte ^= 0xEC ^ 0x11) bb.appendBits(padByte, 8); if (bb.length % 8 != 0) throw "Assertion error"; // Create the QR Code symbol return new this(bb.getBytes(), mask, version, ecl); }; /*---- Public constants for QrCode ----*/ var MIN_VERSION = 1; var MAX_VERSION = 40; Object.defineProperty(this.QrCode, "MIN_VERSION", {value:MIN_VERSION}); Object.defineProperty(this.QrCode, "MAX_VERSION", {value:MAX_VERSION}); /*---- Private static helper functions QrCode ----*/ var QrCode = {}; // Private object to assign properties to. Not the same object as 'this.QrCode'. // Returns a sequence of positions of the alignment patterns in ascending order. These positions are // used on both the x and y axes. Each value in the resulting sequence is in the range [0, 177). // This stateless pure function could be implemented as table of 40 variable-length lists of integers. QrCode.getAlignmentPatternPositions = function(ver) { if (ver < MIN_VERSION || ver > MAX_VERSION) throw "Version number out of range"; else if (ver == 1) return []; else { var size = ver * 4 + 17; var numAlign = Math.floor(ver / 7) + 2; var step; if (ver != 32) step = Math.ceil((size - 13) / (2 * numAlign - 2)) * 2; else // C-C-C-Combo breaker! step = 26; var result = [6]; for (var i = 0, pos = size - 7; i < numAlign - 1; i++, pos -= step) result.splice(1, 0, pos); return result; } }; // Returns the number of data bits that can be stored in a QR Code of the given version number, after // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8. // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table. QrCode.getNumRawDataModules = function(ver) { if (ver < MIN_VERSION || ver > MAX_VERSION) throw "Version number out of range"; var result = (16 * ver + 128) * ver + 64; if (ver >= 2) { var numAlign = Math.floor(ver / 7) + 2; result -= (25 * numAlign - 10) * numAlign - 55; if (ver >= 7) result -= 18 * 2; // Subtract version information } return result; }; // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any // QR Code of the given version number and error correction level, with remainder bits discarded. // This stateless pure function could be implemented as a (40*4)-cell lookup table. QrCode.getNumDataCodewords = function(ver, ecl) { if (ver < MIN_VERSION || ver > MAX_VERSION) throw "Version number out of range"; return Math.floor(QrCode.getNumRawDataModules(ver) / 8) - QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver]; }; /*---- Private tables of constants for QrCode ----*/ // For use in getPenaltyScore(), when evaluating which mask is best. QrCode.PENALTY_N1 = 3; QrCode.PENALTY_N2 = 3; QrCode.PENALTY_N3 = 40; QrCode.PENALTY_N4 = 10; QrCode.ECC_CODEWORDS_PER_BLOCK = [ // Version: (note that index 0 is for padding, and is set to an illegal value) // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level [null, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // Low [null, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28], // Medium [null, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // Quartile [null, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // High ]; QrCode.NUM_ERROR_CORRECTION_BLOCKS = [ // Version: (note that index 0 is for padding, and is set to an illegal value) // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level [null, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25], // Low [null, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49], // Medium [null, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68], // Quartile [null, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81], // High ]; /*---- Public helper enumeration ----*/ /* * Represents the error correction level used in a QR Code symbol. */ this.QrCode.Ecc = { // Constants declared in ascending order of error protection LOW : new Ecc(0, 1), MEDIUM : new Ecc(1, 0), QUARTILE: new Ecc(2, 3), HIGH : new Ecc(3, 2), }; // Private constructor. function Ecc(ord, fb) { // (Public) In the range 0 to 3 (unsigned 2-bit integer) Object.defineProperty(this, "ordinal", {value:ord}); // (Package-private) In the range 0 to 3 (unsigned 2-bit integer) Object.defineProperty(this, "formatBits", {value:fb}); } /*---- Data segment class ----*/ /* * A public class that represents a character string to be encoded in a QR Code symbol. * Each segment has a mode, and a sequence of characters that is already encoded as * a sequence of bits. Instances of this class are immutable. * This segment class imposes no length restrictions, but QR Codes have restrictions. * Even in the most favorable conditions, a QR Code can only hold 7089 characters of data. * Any segment longer than this is meaningless for the purpose of generating QR Codes. */ this.QrSegment = function(mode, numChars, bitData) { if (numChars < 0 || !(mode instanceof Mode)) throw "Invalid argument"; bitData = bitData.slice(); // Make defensive copy // The mode indicator for this segment. Object.defineProperty(this, "mode", {value:mode}); // The length of this segment's unencoded data, measured in characters. Always zero or positive. Object.defineProperty(this, "numChars", {value:numChars}); // Returns a copy of all bits, which is an array of 0s and 1s. this.getBits = function() { return bitData.slice(); // Make defensive copy }; }; /*---- Public static factory functions for QrSegment ----*/ /* * Returns a segment representing the given binary data encoded in byte mode. */ this.QrSegment.makeBytes = function(data) { var bb = new BitBuffer(); data.forEach(function(b) { bb.appendBits(b, 8); }); return new this(this.Mode.BYTE, data.length, bb); }; /* * Returns a segment representing the given string of decimal digits encoded in numeric mode. */ this.QrSegment.makeNumeric = function(digits) { if (!this.NUMERIC_REGEX.test(digits)) throw "String contains non-numeric characters"; var bb = new BitBuffer(); var i; for (i = 0; i + 3 <= digits.length; i += 3) // Process groups of 3 bb.appendBits(parseInt(digits.substr(i, 3), 10), 10); var rem = digits.length - i; if (rem > 0) // 1 or 2 digits remaining bb.appendBits(parseInt(digits.substring(i), 10), rem * 3 + 1); return new this(this.Mode.NUMERIC, digits.length, bb); }; /* * Returns a segment representing the given text string encoded in alphanumeric mode. * The characters allowed are: 0 to 9, A to Z (uppercase only), space, * dollar, percent, asterisk, plus, hyphen, period, slash, colon. */ this.QrSegment.makeAlphanumeric = function(text) { if (!this.ALPHANUMERIC_REGEX.test(text)) throw "String contains unencodable characters in alphanumeric mode"; var bb = new BitBuffer(); var i; for (i = 0; i + 2 <= text.length; i += 2) { // Process groups of 2 var temp = QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45; temp += QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1)); bb.appendBits(temp, 11); } if (i < text.length) // 1 character remaining bb.appendBits(QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6); return new this(this.Mode.ALPHANUMERIC, text.length, bb); }; /* * Returns a new mutable list of zero or more segments to represent the given Unicode text string. * The result may use various segment modes and switch modes to optimize the length of the bit stream. */ this.QrSegment.makeSegments = function(text) { // Select the most efficient segment encoding automatically if (text == "") return []; else if (this.NUMERIC_REGEX.test(text)) return [this.makeNumeric(text)]; else if (this.ALPHANUMERIC_REGEX.test(text)) return [this.makeAlphanumeric(text)]; else return [this.makeBytes(toUtf8ByteArray(text))]; }; /* * Returns a segment representing an Extended Channel Interpretation * (ECI) designator with the given assignment value. */ this.QrSegment.makeEci = function(assignVal) { var bb = new BitBuffer(); if (0 <= assignVal && assignVal < (1 << 7)) bb.appendBits(assignVal, 8); else if ((1 << 7) <= assignVal && assignVal < (1 << 14)) { bb.appendBits(2, 2); bb.appendBits(assignVal, 14); } else if ((1 << 14) <= assignVal && assignVal < 1000000) { bb.appendBits(6, 3); bb.appendBits(assignVal, 21); } else throw "ECI assignment value out of range"; return new this(this.Mode.ECI, 0, bb); }; // Package-private helper function. this.QrSegment.getTotalBits = function(segs, version) { if (version < MIN_VERSION || version > MAX_VERSION) throw "Version number out of range"; var result = 0; for (var i = 0; i < segs.length; i++) { var seg = segs[i]; var ccbits = seg.mode.numCharCountBits(version); // Fail if segment length value doesn't fit in the length field's bit-width if (seg.numChars >= (1 << ccbits)) return null; result += 4 + ccbits + seg.getBits().length; } return result; }; /*---- Constants for QrSegment ----*/ var QrSegment = {}; // Private object to assign properties to. Not the same object as 'this.QrSegment'. // (Public) Can test whether a string is encodable in numeric mode (such as by using QrSegment.makeNumeric()). this.QrSegment.NUMERIC_REGEX = /^[0-9]*$/; // (Public) Can test whether a string is encodable in alphanumeric mode (such as by using QrSegment.makeAlphanumeric()). this.QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/; // (Private) The set of all legal characters in alphanumeric mode, where each character value maps to the index in the string. QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; /*---- Public helper enumeration ----*/ /* * Represents the mode field of a segment. Immutable. */ this.QrSegment.Mode = { // Constants NUMERIC : new Mode(0x1, [10, 12, 14]), ALPHANUMERIC: new Mode(0x2, [ 9, 11, 13]), BYTE : new Mode(0x4, [ 8, 16, 16]), KANJI : new Mode(0x8, [ 8, 10, 12]), ECI : new Mode(0x7, [ 0, 0, 0]), }; // Private constructor. function Mode(mode, ccbits) { // (Package-private) An unsigned 4-bit integer value (range 0 to 15) representing the mode indicator bits for this mode object. Object.defineProperty(this, "modeBits", {value:mode}); // (Package-private) Returns the bit width of the segment character count field for this mode object at the given version number. this.numCharCountBits = function(ver) { if ( 1 <= ver && ver <= 9) return ccbits[0]; else if (10 <= ver && ver <= 26) return ccbits[1]; else if (27 <= ver && ver <= 40) return ccbits[2]; else throw "Version number out of range"; }; } /*---- Private helper functions and classes ----*/ // Returns a new array of bytes representing the given string encoded in UTF-8. function toUtf8ByteArray(str) { str = encodeURI(str); var result = []; for (var i = 0; i < str.length; i++) { if (str.charAt(i) != "%") result.push(str.charCodeAt(i)); else { result.push(parseInt(str.substr(i + 1, 2), 16)); i += 2; } } return result; } /* * A private helper class that computes the Reed-Solomon error correction codewords for a sequence of * data codewords at a given degree. Objects are immutable, and the state only depends on the degree. * This class exists because each data block in a QR Code shares the same the divisor polynomial. * This constructor creates a Reed-Solomon ECC generator for the given degree. This could be implemented * as a lookup table over all possible parameter values, instead of as an algorithm. */ function ReedSolomonGenerator(degree) { if (degree < 1 || degree > 255) throw "Degree out of range"; // Coefficients of the divisor polynomial, stored from highest to lowest power, excluding the leading term which // is always 1. For example the polynomial x^3 + 255x^2 + 8x + 93 is stored as the uint8 array {255, 8, 93}. var coefficients = []; // Start with the monomial x^0 for (var i = 0; i < degree - 1; i++) coefficients.push(0); coefficients.push(1); // Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}), // drop the highest term, and store the rest of the coefficients in order of descending powers. // Note that r = 0x02, which is a generator element of this field GF(2^8/0x11D). var root = 1; for (var i = 0; i < degree; i++) { // Multiply the current product by (x - r^i) for (var j = 0; j < coefficients.length; j++) { coefficients[j] = ReedSolomonGenerator.multiply(coefficients[j], root); if (j + 1 < coefficients.length) coefficients[j] ^= coefficients[j + 1]; } root = ReedSolomonGenerator.multiply(root, 0x02); } // Computes and returns the Reed-Solomon error correction codewords for the given // sequence of data codewords. The returned object is always a new byte array. // This method does not alter this object's state (because it is immutable). this.getRemainder = function(data) { // Compute the remainder by performing polynomial division var result = coefficients.map(function() { return 0; }); data.forEach(function(b) { var factor = b ^ result.shift(); result.push(0); for (var i = 0; i < result.length; i++) result[i] ^= ReedSolomonGenerator.multiply(coefficients[i], factor); }); return result; }; } // This static function returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and // result are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8. ReedSolomonGenerator.multiply = function(x, y) { if (x >>> 8 != 0 || y >>> 8 != 0) throw "Byte out of range"; // Russian peasant multiplication var z = 0; for (var i = 7; i >= 0; i--) { z = (z << 1) ^ ((z >>> 7) * 0x11D); z ^= ((y >>> i) & 1) * x; } if (z >>> 8 != 0) throw "Assertion error"; return z; }; /* * A private helper class that represents an appendable sequence of bits. * This constructor creates an empty bit buffer (length 0). */ function BitBuffer() { // Packs this buffer's bits into bytes in big endian, // padding with '0' bit values, and returns the new array. this.getBytes = function() { var result = []; while (result.length * 8 < this.length) result.push(0); this.forEach(function(bit, i) { result[i >>> 3] |= bit << (7 - (i & 7)); }); return result; }; // Appends the given number of low bits of the given value // to this sequence. Requires 0 <= val < 2^len. this.appendBits = function(val, len) { if (len < 0 || len > 31 || val >>> len != 0) throw "Value out of range"; for (var i = len - 1; i >= 0; i--) // Append bit by bit this.push((val >>> i) & 1); }; } BitBuffer.prototype = Object.create(Array.prototype); }; ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������uTox/third_party/qrcodegen/qrcodegen/javascript/qrcodegen-js-demo.html������������������������������0000600�0001750�0000144�00000012515�14003056224�025307� 0����������������������������������������������������������������������������������������������������ustar �rak�����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ QR Code generator library demo (JavaScript)

QR Code generator demo library (JavaScript)

Text string:
QR Code:
Error correction:
Output format:
Border: modules
Scale: pixels per module
Version range: Minimum = , maximum =
Mask pattern: (−1 for automatic, 0 to 7 for manual)
Boost ECC:
Statistics:
SVG XML code:

Copyright © Project Nayuki – https://www.nayuki.io/page/qr-code-generator-library

uTox/third_party/qrcodegen/qrcodegen/javascript/qrcodegen-demo.js0000600000175000001440000001366314003056224024352 0ustar rakusers/* * QR Code generator demo (JavaScript) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ "use strict"; function redrawQrCode() { // Show/hide rows based on bitmap/vector image output var bitmapOutput = document.getElementById("output-format-bitmap").checked; var scaleRow = document.getElementById("scale-row"); var svgXmlRow = document.getElementById("svg-xml-row"); if (bitmapOutput) { scaleRow.style.removeProperty("display"); svgXmlRow.style.display = "none"; } else { scaleRow.style.display = "none"; svgXmlRow.style.removeProperty("display"); } var svgXml = document.getElementById("svg-xml-output"); svgXml.value = ""; // Reset output images in case of early termination var canvas = document.getElementById("qrcode-canvas"); var svg = document.getElementById("qrcode-svg"); canvas.style.display = "none"; svg.style.display = "none"; // Returns a QrCode.Ecc object based on the radio buttons in the HTML form. function getInputErrorCorrectionLevel() { if (document.getElementById("errcorlvl-medium").checked) return qrcodegen.QrCode.Ecc.MEDIUM; else if (document.getElementById("errcorlvl-quartile").checked) return qrcodegen.QrCode.Ecc.QUARTILE; else if (document.getElementById("errcorlvl-high").checked) return qrcodegen.QrCode.Ecc.HIGH; else // In case no radio button is depressed return qrcodegen.QrCode.Ecc.LOW; } // Get form inputs and compute QR Code var ecl = getInputErrorCorrectionLevel(); var text = document.getElementById("text-input").value; var segs = qrcodegen.QrSegment.makeSegments(text); var minVer = parseInt(document.getElementById("version-min-input").value, 10); var maxVer = parseInt(document.getElementById("version-max-input").value, 10); var mask = parseInt(document.getElementById("mask-input").value, 10); var boostEcc = document.getElementById("boost-ecc-input").checked; var qr = qrcodegen.QrCode.encodeSegments(segs, ecl, minVer, maxVer, mask, boostEcc); // Draw image output var border = parseInt(document.getElementById("border-input").value, 10); if (border < 0 || border > 100) return; if (bitmapOutput) { var scale = parseInt(document.getElementById("scale-input").value, 10); if (scale <= 0 || scale > 30) return; qr.drawCanvas(scale, border, canvas); canvas.style.removeProperty("display"); } else { var code = qr.toSvgString(border); svg.setAttribute("viewBox", / viewBox="([^"]*)"/.exec(code)[1]); svg.querySelector("path").setAttribute("d", / d="([^"]*)"/.exec(code)[1]); svg.style.removeProperty("display"); svgXml.value = qr.toSvgString(border); } // Returns a string to describe the given list of segments. function describeSegments(segs) { if (segs.length == 0) return "none"; else if (segs.length == 1) { var mode = segs[0].mode; var Mode = qrcodegen.QrSegment.Mode; if (mode == Mode.NUMERIC ) return "numeric"; if (mode == Mode.ALPHANUMERIC) return "alphanumeric"; if (mode == Mode.BYTE ) return "byte"; if (mode == Mode.KANJI ) return "kanji"; return "unknown"; } else return "multiple"; } // Returns the number of Unicode code points in the given UTF-16 string. function countUnicodeChars(str) { var result = 0; for (var i = 0; i < str.length; i++, result++) { var c = str.charCodeAt(i); if (c < 0xD800 || c >= 0xE000) continue; else if (0xD800 <= c && c < 0xDC00) { // High surrogate i++; var d = str.charCodeAt(i); if (0xDC00 <= d && d < 0xE000) // Low surrogate continue; } throw "Invalid UTF-16 string"; } return result; } // Show the QR Code symbol's statistics as a string var stats = "QR Code version = " + qr.version + ", "; stats += "mask pattern = " + qr.mask + ", "; stats += "character count = " + countUnicodeChars(text) + ",\n"; stats += "encoding mode = " + describeSegments(segs) + ", "; stats += "error correction = level " + "LMQH".charAt(qr.errorCorrectionLevel.ordinal) + ", "; stats += "data bits = " + qrcodegen.QrSegment.getTotalBits(segs, qr.version) + "."; var elem = document.getElementById("statistics-output"); while (elem.firstChild != null) elem.removeChild(elem.firstChild); elem.appendChild(document.createTextNode(stats)); } function handleVersionMinMax(which) { var minElem = document.getElementById("version-min-input"); var maxElem = document.getElementById("version-max-input"); var minVal = parseInt(minElem.value, 10); var maxVal = parseInt(maxElem.value, 10); minVal = Math.max(Math.min(minVal, qrcodegen.QrCode.MAX_VERSION), qrcodegen.QrCode.MIN_VERSION); maxVal = Math.max(Math.min(maxVal, qrcodegen.QrCode.MAX_VERSION), qrcodegen.QrCode.MIN_VERSION); if (which == "min" && minVal > maxVal) maxVal = minVal; else if (which == "max" && maxVal < minVal) minVal = maxVal; minElem.value = minVal.toString(); maxElem.value = maxVal.toString(); redrawQrCode(); } redrawQrCode(); uTox/third_party/qrcodegen/qrcodegen/java/0000700000175000001440000000000014003056224017663 5ustar rakusersuTox/third_party/qrcodegen/qrcodegen/java/io/0000700000175000001440000000000014003056224020272 5ustar rakusersuTox/third_party/qrcodegen/qrcodegen/java/io/nayuki/0000700000175000001440000000000014003056224021572 5ustar rakusersuTox/third_party/qrcodegen/qrcodegen/java/io/nayuki/qrcodegen/0000700000175000001440000000000014003056224023541 5ustar rakusersuTox/third_party/qrcodegen/qrcodegen/java/io/nayuki/qrcodegen/QrSegmentAdvanced.java0000600000175000001440000010342414003056224027745 0ustar rakusers/* * QR Code generator library - Optional advanced logic (Java) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ package io.nayuki.qrcodegen; import static io.nayuki.qrcodegen.QrSegment.Mode.ALPHANUMERIC; import static io.nayuki.qrcodegen.QrSegment.Mode.BYTE; import static io.nayuki.qrcodegen.QrSegment.Mode.NUMERIC; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; import java.util.List; import java.util.Objects; public final class QrSegmentAdvanced { /*---- Optimal list of segments encoder ----*/ /** * Returns a new mutable list of zero or more segments to represent the specified Unicode text string. * The resulting list optimally minimizes the total encoded bit length, subjected to the constraints given * by the specified {error correction level, minimum version number, maximum version number}, plus the additional * constraint that the segment modes {NUMERIC, ALPHANUMERIC, BYTE} can be used but KANJI cannot be used. *

This function can be viewed as a significantly more sophisticated and slower replacement * for {@link QrSegment#makeSegments(String)}, but requiring more input parameters in a way * that overlaps with {@link QrCode#encodeSegments(List,QrCode.Ecc,int,int,int,boolean)}.

* @param text the text to be encoded, which can be any Unicode string * @param ecl the error correction level to use * @param minVersion the minimum allowed version of the QR symbol (at least 1) * @param maxVersion the maximum allowed version of the QR symbol (at most 40) * @return a list of segments containing the text, minimizing the bit length with respect to the constraints * @throws NullPointerException if the data or error correction level is {@code null} * @throws IllegalArgumentException if 1 ≤ minVersion ≤ maxVersion ≤ 40 is violated, * or if the data is too long to fit in a QR Code at maxVersion at the ECL */ public static List makeSegmentsOptimally(String text, QrCode.Ecc ecl, int minVersion, int maxVersion) { // Check arguments Objects.requireNonNull(text); Objects.requireNonNull(ecl); if (!(1 <= minVersion && minVersion <= maxVersion && maxVersion <= 40)) throw new IllegalArgumentException("Invalid value"); // Iterate through version numbers, and make tentative segments List segs = null; for (int version = minVersion; version <= maxVersion; version++) { if (version == minVersion || version == 10 || version == 27) segs = makeSegmentsOptimally(text, version); // Check if the segments fit int dataCapacityBits = QrCode.getNumDataCodewords(version, ecl) * 8; int dataUsedBits = QrSegment.getTotalBits(segs, version); if (dataUsedBits != -1 && dataUsedBits <= dataCapacityBits) return segs; } throw new IllegalArgumentException("Data too long"); } // Returns a list of segments that is optimal for the given text at the given version number. private static List makeSegmentsOptimally(String text, int version) { byte[] data = text.getBytes(StandardCharsets.UTF_8); int[][] bitCosts = computeBitCosts(data, version); QrSegment.Mode[] charModes = computeCharacterModes(data, version, bitCosts); return splitIntoSegments(data, charModes); } private static int[][] computeBitCosts(byte[] data, int version) { // Segment header sizes, measured in 1/6 bits int bytesCost = (4 + BYTE .numCharCountBits(version)) * 6; int alphnumCost = (4 + ALPHANUMERIC.numCharCountBits(version)) * 6; int numberCost = (4 + NUMERIC .numCharCountBits(version)) * 6; // result[mode][len] is the number of 1/6 bits to encode the first len characters of the text, ending in the mode int[][] result = new int[3][data.length + 1]; Arrays.fill(result[1], Integer.MAX_VALUE / 2); Arrays.fill(result[2], Integer.MAX_VALUE / 2); result[0][0] = bytesCost; result[1][0] = alphnumCost; result[2][0] = numberCost; // Calculate the cost table using dynamic programming for (int i = 0; i < data.length; i++) { // Encode a character int j = i + 1; char c = (char)data[i]; result[0][j] = result[0][i] + 48; // 8 bits per byte if (isAlphanumeric(c)) result[1][j] = result[1][i] + 33; // 5.5 bits per alphanumeric char if (isNumeric(c)) result[2][j] = result[2][i] + 20; // 3.33 bits per digit // Switch modes, rounding up fractional bits result[0][j] = Math.min((Math.min(result[1][j], result[2][j]) + 5) / 6 * 6 + bytesCost , result[0][j]); result[1][j] = Math.min((Math.min(result[2][j], result[0][j]) + 5) / 6 * 6 + alphnumCost, result[1][j]); result[2][j] = Math.min((Math.min(result[0][j], result[1][j]) + 5) / 6 * 6 + numberCost , result[2][j]); } return result; } private static QrSegment.Mode[] computeCharacterModes(byte[] data, int version, int[][] bitCosts) { // Segment header sizes, measured in 1/6 bits int bytesCost = (4 + BYTE .numCharCountBits(version)) * 6; int alphnumCost = (4 + ALPHANUMERIC.numCharCountBits(version)) * 6; int numberCost = (4 + NUMERIC .numCharCountBits(version)) * 6; // Infer the mode used for last character by taking the minimum QrSegment.Mode curMode; int end = bitCosts[0].length - 1; if (bitCosts[0][end] <= Math.min(bitCosts[1][end], bitCosts[2][end])) curMode = BYTE; else if (bitCosts[1][end] <= bitCosts[2][end]) curMode = ALPHANUMERIC; else curMode = NUMERIC; // Work backwards to calculate optimal encoding mode for each character QrSegment.Mode[] result = new QrSegment.Mode[data.length]; if (data.length == 0) return result; result[data.length - 1] = curMode; for (int i = data.length - 2; i >= 0; i--) { char c = (char)data[i]; if (curMode == NUMERIC) { if (isNumeric(c)) curMode = NUMERIC; else if (isAlphanumeric(c) && (bitCosts[1][i] + 33 + 5) / 6 * 6 + numberCost == bitCosts[2][i + 1]) curMode = ALPHANUMERIC; else curMode = BYTE; } else if (curMode == ALPHANUMERIC) { if (isNumeric(c) && (bitCosts[2][i] + 20 + 5) / 6 * 6 + alphnumCost == bitCosts[1][i + 1]) curMode = NUMERIC; else if (isAlphanumeric(c)) curMode = ALPHANUMERIC; else curMode = BYTE; } else if (curMode == BYTE) { if (isNumeric(c) && (bitCosts[2][i] + 20 + 5) / 6 * 6 + bytesCost == bitCosts[0][i + 1]) curMode = NUMERIC; else if (isAlphanumeric(c) && (bitCosts[1][i] + 33 + 5) / 6 * 6 + bytesCost == bitCosts[0][i + 1]) curMode = ALPHANUMERIC; else curMode = BYTE; } else throw new AssertionError(); result[i] = curMode; } return result; } private static List splitIntoSegments(byte[] data, QrSegment.Mode[] charModes) { List result = new ArrayList<>(); if (data.length == 0) return result; // Accumulate run of modes QrSegment.Mode curMode = charModes[0]; int start = 0; for (int i = 1; i < data.length; i++) { if (charModes[i] != curMode) { if (curMode == BYTE) result.add(QrSegment.makeBytes(Arrays.copyOfRange(data, start, i))); else { String temp = new String(data, start, i - start, StandardCharsets.US_ASCII); if (curMode == NUMERIC) result.add(QrSegment.makeNumeric(temp)); else if (curMode == ALPHANUMERIC) result.add(QrSegment.makeAlphanumeric(temp)); else throw new AssertionError(); } curMode = charModes[i]; start = i; } } // Final segment if (curMode == BYTE) result.add(QrSegment.makeBytes(Arrays.copyOfRange(data, start, data.length))); else { String temp = new String(data, start, data.length - start, StandardCharsets.US_ASCII); if (curMode == NUMERIC) result.add(QrSegment.makeNumeric(temp)); else if (curMode == ALPHANUMERIC) result.add(QrSegment.makeAlphanumeric(temp)); else throw new AssertionError(); } return result; } private static boolean isAlphanumeric(char c) { return isNumeric(c) || 'A' <= c && c <= 'Z' || " $%*+./:-".indexOf(c) != -1; } private static boolean isNumeric(char c) { return '0' <= c && c <= '9'; } /*---- Kanji mode segment encoder ----*/ /** * Returns a segment representing the specified string encoded in kanji mode. *

Note that broadly speaking, the set of encodable characters are {kanji used in Japan, hiragana, katakana, * Asian punctuation, full-width ASCII}.
* In particular, non-encodable characters are {normal ASCII, half-width katakana, more extensive Chinese hanzi}. * @param text the text to be encoded, which must fall in the kanji mode subset of characters * @return a segment containing the data * @throws NullPointerException if the string is {@code null} * @throws IllegalArgumentException if the string contains non-kanji-mode characters * @see #isEncodableAsKanji(String) */ public static QrSegment makeKanjiSegment(String text) { Objects.requireNonNull(text); BitBuffer bb = new BitBuffer(); for (int i = 0; i < text.length(); i++) { int val = UNICODE_TO_QR_KANJI[text.charAt(i)]; if (val == -1) throw new IllegalArgumentException("String contains non-kanji-mode characters"); bb.appendBits(val, 13); } return new QrSegment(QrSegment.Mode.KANJI, text.length(), bb); } /** * Tests whether the specified text string can be encoded as a segment in kanji mode. *

Note that broadly speaking, the set of encodable characters are {kanji used in Japan, hiragana, katakana, * Asian punctuation, full-width ASCII}.
* In particular, non-encodable characters are {normal ASCII, half-width katakana, more extensive Chinese hanzi}. * @param text the string to test for encodability * @return {@code true} if and only if the string can be encoded in kanji mode * @throws NullPointerException if the string is {@code null} * @see #makeKanjiSegment(String) */ public static boolean isEncodableAsKanji(String text) { Objects.requireNonNull(text); for (int i = 0; i < text.length(); i++) { if (UNICODE_TO_QR_KANJI[text.charAt(i)] == -1) return false; } return true; } // Data derived from ftp://ftp.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT private static final String PACKED_QR_KANJI_TO_UNICODE = "MAAwATAC/wz/DjD7/xr/G/8f/wEwmzCcALT/QACo/z7/4/8/MP0w/jCdMJ4wA07dMAUwBjAHMPwgFSAQ/w8AXDAcIBb/XCAmICUgGCAZIBwgHf8I/wkwFDAV/zv/Pf9b/10wCDAJMAowCzAMMA0wDjAPMBAwEf8LIhIAsQDX//8A9/8dImD/HP8eImYiZyIeIjQmQiZA" + "ALAgMiAzIQP/5f8EAKIAo/8F/wP/Bv8K/yAApyYGJgUlyyXPJc4lxyXGJaEloCWzJbIlvSW8IDswEiGSIZAhkSGTMBP/////////////////////////////IggiCyKGIocigiKDIioiKf////////////////////8iJyIoAKwh0iHUIgAiA///////////////////" + "//////////8iICKlIxIiAiIHImEiUiJqImsiGiI9Ih0iNSIrIiz//////////////////yErIDAmbyZtJmogICAhALb//////////yXv/////////////////////////////////////////////////xD/Ef8S/xP/FP8V/xb/F/8Y/xn///////////////////8h" + "/yL/I/8k/yX/Jv8n/yj/Kf8q/yv/LP8t/y7/L/8w/zH/Mv8z/zT/Nf82/zf/OP85/zr///////////////////9B/0L/Q/9E/0X/Rv9H/0j/Sf9K/0v/TP9N/07/T/9Q/1H/Uv9T/1T/Vf9W/1f/WP9Z/1r//////////zBBMEIwQzBEMEUwRjBHMEgwSTBKMEswTDBN" + "ME4wTzBQMFEwUjBTMFQwVTBWMFcwWDBZMFowWzBcMF0wXjBfMGAwYTBiMGMwZDBlMGYwZzBoMGkwajBrMGwwbTBuMG8wcDBxMHIwczB0MHUwdjB3MHgweTB6MHswfDB9MH4wfzCAMIEwgjCDMIQwhTCGMIcwiDCJMIowizCMMI0wjjCPMJAwkTCSMJP/////////////" + "////////////////////////MKEwojCjMKQwpTCmMKcwqDCpMKowqzCsMK0wrjCvMLAwsTCyMLMwtDC1MLYwtzC4MLkwujC7MLwwvTC+ML8wwDDBMMIwwzDEMMUwxjDHMMgwyTDKMMswzDDNMM4wzzDQMNEw0jDTMNQw1TDWMNcw2DDZMNow2zDcMN0w3jDf//8w4DDh" + "MOIw4zDkMOUw5jDnMOgw6TDqMOsw7DDtMO4w7zDwMPEw8jDzMPQw9TD2/////////////////////wORA5IDkwOUA5UDlgOXA5gDmQOaA5sDnAOdA54DnwOgA6EDowOkA6UDpgOnA6gDqf////////////////////8DsQOyA7MDtAO1A7YDtwO4A7kDugO7A7wDvQO+" + "A78DwAPBA8MDxAPFA8YDxwPIA8n/////////////////////////////////////////////////////////////////////////////////////////////////////////////BBAEEQQSBBMEFAQVBAEEFgQXBBgEGQQaBBsEHAQdBB4EHwQgBCEEIgQjBCQEJQQm" + "BCcEKAQpBCoEKwQsBC0ELgQv////////////////////////////////////////BDAEMQQyBDMENAQ1BFEENgQ3BDgEOQQ6BDsEPAQ9//8EPgQ/BEAEQQRCBEMERARFBEYERwRIBEkESgRLBEwETQROBE///////////////////////////////////yUAJQIlDCUQ" + "JRglFCUcJSwlJCU0JTwlASUDJQ8lEyUbJRclIyUzJSslOyVLJSAlLyUoJTclPyUdJTAlJSU4JUL/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + "/////////////////////////////////////06cVRZaA5Y/VMBhG2MoWfaQIoR1gxx6UGCqY+FuJWXthGaCppv1aJNXJ2WhYnFbm1nQhnuY9H1ifb6bjmIWfJ+It1uJXrVjCWaXaEiVx5eNZ09O5U8KT01PnVBJVvJZN1nUWgFcCWDfYQ9hcGYTaQVwunVPdXB5+32t" + "fe+Aw4QOiGOLApBVkHpTO06VTqVX34CykMF4704AWPFuopA4ejKDKIKLnC9RQVNwVL1U4VbgWftfFZjybeuA5IUt////////lmKWcJagl/tUC1PzW4dwz3+9j8KW6FNvnVx6uk4ReJOB/G4mVhhVBGsdhRqcO1nlU6ltZnTclY9WQk6RkEuW8oNPmQxT4VW2WzBfcWYg" + "ZvNoBGw4bPNtKXRbdsh6Tpg0gvGIW4pgku1tsnWrdsqZxWCmiwGNipWyaY5TrVGG//9XElgwWURbtF72YChjqWP0bL9vFHCOcRRxWXHVcz9+AYJ2gtGFl5BgkludG1hpZbxsWnUlUflZLlllX4Bf3GK8ZfpqKmsna7Rzi3/BiVadLJ0OnsRcoWyWg3tRBFxLYbaBxmh2" + "cmFOWU/6U3hgaW4pek+X804LUxZO7k9VTz1PoU9zUqBT71YJWQ9awVu2W+F50WaHZ5xntmtMbLNwa3PCeY15vno8e4eCsYLbgwSDd4Pvg9OHZoqyVimMqI/mkE6XHoaKT8Rc6GIRcll1O4Hlgr2G/ozAlsWZE5nVTstPGonjVt5YSljKXvtf62AqYJRgYmHQYhJi0GU5" + "////////m0FmZmiwbXdwcHVMdoZ9dYKlh/mVi5aOjJ1R8VK+WRZUs1uzXRZhaGmCba94jYTLiFeKcpOnmrhtbJmohtlXo2f/hs6SDlKDVodUBF7TYuFkuWg8aDhru3NyeLp6a4maidKNa48DkO2Vo5aUl2lbZlyzaX2YTZhOY5t7IGor//9qf2i2nA1vX1JyVZ1gc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6UU2EJYQhsuXZS////////iu2POFUvT1FRKlLHU8tbpV59YKBhgmPWZwln2m5nbYxzNnM3dTF5UIjVipiQSpCRkPWWxIeNWRVOiE9ZTg6KiY8/mBBQrV58WZZbuV64Y9pj+mTBZtxpSmnYbQtutnGUdSh6r3+K" + "gACESYTJiYGLIY4KkGWWfZkKYX5ikWsy//9sg210f8x//G3Af4WHuoj4Z2WDsZg8lvdtG31hhD2Rak5xU3VdUGsEb+uFzYYtiadSKVQPXGVnTmiodAZ0g3XiiM+I4ZHMluKWeF+Lc4d6y4ROY6B1ZVKJbUFunHQJdVl4a3ySloZ63J+NT7ZhbmXFhlxOhk6uUNpOIVHM" + "W+5lmWiBbbxzH3ZCd616HHzngm+K0pB8kc+WdZgYUpt90VArU5hnl23LcdB0M4HojyqWo5xXnp90YFhBbZl9L5heTuRPNk+LUbdSsV26YBxzsnk8gtOSNJa3lvaXCp6Xn2Jmpmt0UhdSo3DIiMJeyWBLYZBvI3FJfD599IBv////////hO6QI5MsVEKbb2rTcImMwo3v" + "lzJStFpBXspfBGcXaXxplG1qbw9yYnL8e+2AAYB+h0uQzlFtnpN5hICLkzKK1lAtVIyKcWtqjMSBB2DRZ6Cd8k6ZTpicEIprhcGFaGkAbn54l4FV////////////////////////////////////////////////////////////////////////////////////////" + "/////////////////////////////18MThBOFU4qTjFONk48Tj9OQk5WTlhOgk6FjGtOioISXw1Ojk6eTp9OoE6iTrBOs062Ts5OzU7ETsZOwk7XTt5O7U7fTvdPCU9aTzBPW09dT1dPR092T4hPj0+YT3tPaU9wT5FPb0+GT5ZRGE/UT99Pzk/YT9tP0U/aT9BP5E/l" + "UBpQKFAUUCpQJVAFTxxP9lAhUClQLE/+T+9QEVAGUENQR2cDUFVQUFBIUFpQVlBsUHhQgFCaUIVQtFCy////////UMlQylCzUMJQ1lDeUOVQ7VDjUO5Q+VD1UQlRAVECURZRFVEUURpRIVE6UTdRPFE7UT9RQFFSUUxRVFFievhRaVFqUW5RgFGCVthRjFGJUY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N2mXaadrB2tHa4drl2unbCds121nbSdt524Xbldud26oYvdvt3CHcHdwR3KXckdx53JXcmdxt3N3c4d0d3Wndod2t3W3dld393fnd5d453i3eRd6B3nnewd7Z3uXe/d7x3vXe7" + "d8d3zXfXd9p33Hfjd+53/HgMeBJ5JnggeSp4RXiOeHR4hnh8eJp4jHijeLV4qniveNF4xnjLeNR4vni8eMV4ynjs////////eOd42nj9ePR5B3kSeRF5GXkseSt5QHlgeVd5X3laeVV5U3l6eX95inmdeaefS3mqea55s3m5ebp5yXnVeed57HnheeN6CHoNehh6GXog" + "eh95gHoxejt6Pno3ekN6V3pJemF6Ynppn516cHp5en16iHqXepV6mHqWeql6yHqw//96tnrFesR6v5CDesd6ynrNes961XrTetl62nrdeuF64nrmeu168HsCew97CnsGezN7GHsZex57NXsoezZ7UHt6ewR7TXsLe0x7RXt1e2V7dHtne3B7cXtse257nXuYe597jXuc" + "e5p7i3uSe497XXuZe8t7wXvMe897tHvGe9176XwRfBR75nvlfGB8AHwHfBN783v3fBd8DXv2fCN8J3wqfB98N3wrfD18THxDfFR8T3xAfFB8WHxffGR8VnxlfGx8dXyDfJB8pHytfKJ8q3yhfKh8s3yyfLF8rny5fL18wHzFfMJ82HzSfNx84ps7fO988nz0fPZ8+n0G" + "////////fQJ9HH0VfQp9RX1LfS59Mn0/fTV9Rn1zfVZ9Tn1yfWh9bn1PfWN9k32JfVt9j319fZt9un2ufaN9tX3Hfb19q349faJ9r33cfbh9n32wfdh93X3kfd59+33yfeF+BX4KfiN+IX4SfjF+H34Jfgt+In5GfmZ+O341fjl+Q343//9+Mn46fmd+XX5Wfl5+WX5a" + "fnl+an5pfnx+e36DfdV+fY+ufn9+iH6Jfox+kn6QfpN+lH6Wfo5+m36cfzh/On9Ff0x/TX9Of1B/UX9Vf1R/WH9ff2B/aH9pf2d/eH+Cf4Z/g3+If4d/jH+Uf55/nX+af6N/r3+yf7l/rn+2f7iLcX/Ff8Z/yn/Vf9R/4X/mf+l/83/5mNyABo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nVGdUJ1ZnXKdiZ2Hnaudb516nZqdpJ2pnbKdxJ3BnbuduJ26ncadz53Cndmd0534nead7Z3vnf2eGp4bnh6edZ55nn2egZ6InouejJ6SnpWekZ6dnqWeqZ64nqqerZdhnsyezp7PntCe1J7cnt6e3Z7gnuWe6J7v//+e9J72nvee+Z77nvye/Z8Hnwh2t58VnyGfLJ8+" + "n0qfUp9Un2OfX59gn2GfZp9nn2yfap93n3Kfdp+Vn5yfoFgvaceQWXRkUdxxmf//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + "/////////////////////////////////////////////w=="; private static short[] UNICODE_TO_QR_KANJI = new short[65536]; static { // Unpack the Shift JIS table into a more computation-friendly form Arrays.fill(UNICODE_TO_QR_KANJI, (short)-1); byte[] bytes = Base64.getDecoder().decode(PACKED_QR_KANJI_TO_UNICODE); for (int i = 0; i < bytes.length; i += 2) { int j = ((bytes[i] & 0xFF) << 8) | (bytes[i + 1] & 0xFF); if (j == 0xFFFF) continue; if (UNICODE_TO_QR_KANJI[j] != -1) throw new AssertionError(); UNICODE_TO_QR_KANJI[j] = (short)(i / 2); } } } uTox/third_party/qrcodegen/qrcodegen/java/io/nayuki/qrcodegen/QrSegment.java0000600000175000001440000002437214003056224026323 0ustar rakusers/* * QR Code generator library (Java) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ package io.nayuki.qrcodegen; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.regex.Pattern; /** * Represents a character string to be encoded in a QR Code symbol. Each segment has * a mode, and a sequence of characters that is already encoded as a sequence of bits. * Instances of this class are immutable. *

This segment class imposes no length restrictions, but QR Codes have restrictions. * Even in the most favorable conditions, a QR Code can only hold 7089 characters of data. * Any segment longer than this is meaningless for the purpose of generating QR Codes.

*/ public final class QrSegment { /*---- Static factory functions ----*/ /** * Returns a segment representing the specified binary data encoded in byte mode. * @param data the binary data * @return a segment containing the data * @throws NullPointerException if the array is {@code null} */ public static QrSegment makeBytes(byte[] data) { Objects.requireNonNull(data); BitBuffer bb = new BitBuffer(); for (byte b : data) bb.appendBits(b & 0xFF, 8); return new QrSegment(Mode.BYTE, data.length, bb); } /** * Returns a segment representing the specified string of decimal digits encoded in numeric mode. * @param digits a string consisting of digits from 0 to 9 * @return a segment containing the data * @throws NullPointerException if the string is {@code null} * @throws IllegalArgumentException if the string contains non-digit characters */ public static QrSegment makeNumeric(String digits) { Objects.requireNonNull(digits); if (!NUMERIC_REGEX.matcher(digits).matches()) throw new IllegalArgumentException("String contains non-numeric characters"); BitBuffer bb = new BitBuffer(); int i; for (i = 0; i + 3 <= digits.length(); i += 3) // Process groups of 3 bb.appendBits(Integer.parseInt(digits.substring(i, i + 3)), 10); int rem = digits.length() - i; if (rem > 0) // 1 or 2 digits remaining bb.appendBits(Integer.parseInt(digits.substring(i)), rem * 3 + 1); return new QrSegment(Mode.NUMERIC, digits.length(), bb); } /** * Returns a segment representing the specified text string encoded in alphanumeric mode. * The characters allowed are: 0 to 9, A to Z (uppercase only), space, * dollar, percent, asterisk, plus, hyphen, period, slash, colon. * @param text a string of text, with only certain characters allowed * @return a segment containing the data * @throws NullPointerException if the string is {@code null} * @throws IllegalArgumentException if the string contains non-encodable characters */ public static QrSegment makeAlphanumeric(String text) { Objects.requireNonNull(text); if (!ALPHANUMERIC_REGEX.matcher(text).matches()) throw new IllegalArgumentException("String contains unencodable characters in alphanumeric mode"); BitBuffer bb = new BitBuffer(); int i; for (i = 0; i + 2 <= text.length(); i += 2) { // Process groups of 2 int temp = ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45; temp += ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1)); bb.appendBits(temp, 11); } if (i < text.length()) // 1 character remaining bb.appendBits(ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6); return new QrSegment(Mode.ALPHANUMERIC, text.length(), bb); } /** * Returns a new mutable list of zero or more segments to represent the specified Unicode text string. * The result may use various segment modes and switch modes to optimize the length of the bit stream. * @param text the text to be encoded, which can be any Unicode string * @return a list of segments containing the text * @throws NullPointerException if the text is {@code null} */ public static List makeSegments(String text) { Objects.requireNonNull(text); // Select the most efficient segment encoding automatically List result = new ArrayList<>(); if (text.equals("")); // Leave result empty else if (NUMERIC_REGEX.matcher(text).matches()) result.add(makeNumeric(text)); else if (ALPHANUMERIC_REGEX.matcher(text).matches()) result.add(makeAlphanumeric(text)); else result.add(makeBytes(text.getBytes(StandardCharsets.UTF_8))); return result; } /** * Returns a segment representing an Extended Channel Interpretation * (ECI) designator with the specified assignment value. * @param assignVal the ECI assignment number (see the AIM ECI specification) * @return a segment containing the data * @throws IllegalArgumentException if the value is outside the range [0, 106) */ public static QrSegment makeEci(int assignVal) { BitBuffer bb = new BitBuffer(); if (0 <= assignVal && assignVal < (1 << 7)) bb.appendBits(assignVal, 8); else if ((1 << 7) <= assignVal && assignVal < (1 << 14)) { bb.appendBits(2, 2); bb.appendBits(assignVal, 14); } else if ((1 << 14) <= assignVal && assignVal < 1000000) { bb.appendBits(6, 3); bb.appendBits(assignVal, 21); } else throw new IllegalArgumentException("ECI assignment value out of range"); return new QrSegment(Mode.ECI, 0, bb); } /*---- Instance fields ----*/ /** The mode indicator for this segment. Never {@code null}. */ public final Mode mode; /** The length of this segment's unencoded data, measured in characters. Always zero or positive. */ public final int numChars; /** The data bits of this segment. Accessed through {@link getBits()}. Not {@code null}. */ final BitBuffer data; /*---- Constructor ----*/ /** * Creates a new QR Code data segment with the specified parameters and data. * @param md the mode, which is not {@code null} * @param numCh the data length in characters, which is non-negative * @param data the data bits of this segment, which is not {@code null} * @throws NullPointerException if the mode or bit buffer is {@code null} * @throws IllegalArgumentException if the character count is negative */ public QrSegment(Mode md, int numCh, BitBuffer data) { Objects.requireNonNull(md); Objects.requireNonNull(data); if (numCh < 0) throw new IllegalArgumentException("Invalid value"); mode = md; numChars = numCh; this.data = data.clone(); // Make defensive copy } /*---- Methods ----*/ /** * Returns the data bits of this segment. * @return the data bits of this segment (not {@code null}) */ public BitBuffer getBits() { return data.clone(); // Make defensive copy } // Package-private helper function. static int getTotalBits(List segs, int version) { Objects.requireNonNull(segs); if (version < 1 || version > 40) throw new IllegalArgumentException("Version number out of range"); long result = 0; for (QrSegment seg : segs) { Objects.requireNonNull(seg); int ccbits = seg.mode.numCharCountBits(version); // Fail if segment length value doesn't fit in the length field's bit-width if (seg.numChars >= (1 << ccbits)) return -1; result += 4L + ccbits + seg.data.bitLength(); if (result > Integer.MAX_VALUE) return -1; } return (int)result; } /*---- Constants ----*/ /** Can test whether a string is encodable in numeric mode (such as by using {@link #makeNumeric(String)}). */ public static final Pattern NUMERIC_REGEX = Pattern.compile("[0-9]*"); /** Can test whether a string is encodable in alphanumeric mode (such as by using {@link #makeAlphanumeric(String)}). */ public static final Pattern ALPHANUMERIC_REGEX = Pattern.compile("[A-Z0-9 $%*+./:-]*"); /** The set of all legal characters in alphanumeric mode, where each character value maps to the index in the string. */ private static final String ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; /*---- Public helper enumeration ----*/ /** * The mode field of a segment. Immutable. Provides methods to retrieve closely related values. */ public enum Mode { /*-- Constants --*/ NUMERIC (0x1, 10, 12, 14), ALPHANUMERIC(0x2, 9, 11, 13), BYTE (0x4, 8, 16, 16), KANJI (0x8, 8, 10, 12), ECI (0x7, 0, 0, 0); /*-- Fields --*/ /** An unsigned 4-bit integer value (range 0 to 15) representing the mode indicator bits for this mode object. */ final int modeBits; private final int[] numBitsCharCount; /*-- Constructor --*/ private Mode(int mode, int... ccbits) { this.modeBits = mode; numBitsCharCount = ccbits; } /*-- Method --*/ /** * Returns the bit width of the segment character count field for this mode object at the specified version number. * @param ver the version number, which is between 1 to 40, inclusive * @return the number of bits for the character count, which is between 8 to 16, inclusive * @throws IllegalArgumentException if the version number is out of range */ int numCharCountBits(int ver) { if ( 1 <= ver && ver <= 9) return numBitsCharCount[0]; else if (10 <= ver && ver <= 26) return numBitsCharCount[1]; else if (27 <= ver && ver <= 40) return numBitsCharCount[2]; else throw new IllegalArgumentException("Version number out of range"); } } } uTox/third_party/qrcodegen/qrcodegen/java/io/nayuki/qrcodegen/QrCodeGeneratorWorker.java0000600000175000001440000000712414003056224030630 0ustar rakusers/* * QR Code generator test worker (Java) * * This program reads data and encoding parameters from standard input and writes * QR Code bitmaps to standard output. The I/O format is one integer per line. * Run with no command line arguments. The program is intended for automated * batch testing of end-to-end functionality of this QR Code generator library. * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ package io.nayuki.qrcodegen; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; import java.util.Scanner; public final class QrCodeGeneratorWorker { public static void main(String[] args) { // Set up input stream and start loop try (Scanner input = new Scanner(System.in, "US-ASCII")) { input.useDelimiter("\r\n|\n|\r"); while (processCase(input)); } } private static boolean processCase(Scanner input) { // Read data length or exit int length = input.nextInt(); if (length == -1) return false; if (length > Short.MAX_VALUE) throw new RuntimeException(); // Read data bytes boolean isAscii = true; byte[] data = new byte[length]; for (int i = 0; i < data.length; i++) { int b = input.nextInt(); if (b < 0 || b > 255) throw new RuntimeException(); data[i] = (byte)b; isAscii &= b < 128; } // Read encoding parameters int errCorLvl = input.nextInt(); int minVersion = input.nextInt(); int maxVersion = input.nextInt(); int mask = input.nextInt(); int boostEcl = input.nextInt(); if (!(0 <= errCorLvl && errCorLvl <= 3) || !(-1 <= mask && mask <= 7) || (boostEcl >>> 1) != 0 || !(QrCode.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= QrCode.MAX_VERSION)) throw new RuntimeException(); // Make segments for encoding List segs; if (isAscii) segs = QrSegment.makeSegments(new String(data, StandardCharsets.US_ASCII)); else segs = Arrays.asList(QrSegment.makeBytes(data)); try { // Try to make QR Code symbol QrCode qr = QrCode.encodeSegments(segs, QrCode.Ecc.values()[errCorLvl], minVersion, maxVersion, mask, boostEcl != 0); // Print grid of modules System.out.println(qr.version); for (int y = 0; y < qr.size; y++) { for (int x = 0; x < qr.size; x++) System.out.println(qr.getModule(x, y) ? 1 : 0); } } catch (IllegalArgumentException e) { if (!e.getMessage().equals("Data too long")) throw e; System.out.println(-1); } System.out.flush(); return true; } } uTox/third_party/qrcodegen/qrcodegen/java/io/nayuki/qrcodegen/QrCodeGeneratorDemo.java0000600000175000001440000002036014003056224030240 0ustar rakusers/* * QR Code generator demo (Java) * * Run this command-line program with no arguments. The program creates/overwrites a bunch of * PNG and SVG files in the current working directory to demonstrate the creation of QR Codes. * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ package io.nayuki.qrcodegen; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; import javax.imageio.ImageIO; public final class QrCodeGeneratorDemo { // The main application program. public static void main(String[] args) throws IOException { doBasicDemo(); doVarietyDemo(); doSegmentDemo(); doMaskDemo(); } /*---- Demo suite ----*/ // Creates a single QR Code, then writes it to a PNG file and an SVG file. private static void doBasicDemo() throws IOException { String text = "Hello, world!"; // User-supplied Unicode text QrCode.Ecc errCorLvl = QrCode.Ecc.LOW; // Error correction level QrCode qr = QrCode.encodeText(text, errCorLvl); // Make the QR Code symbol BufferedImage img = qr.toImage(10, 4); // Convert to bitmap image File imgFile = new File("hello-world-QR.png"); // File path for output ImageIO.write(img, "png", imgFile); // Write image to file String svg = qr.toSvgString(4); // Convert to SVG XML code try (Writer out = new OutputStreamWriter( new FileOutputStream("hello-world-QR.svg"), StandardCharsets.UTF_8)) { out.write(svg); // Create/overwrite file and write SVG data } } // Creates a variety of QR Codes that exercise different features of the library, and writes each one to file. private static void doVarietyDemo() throws IOException { QrCode qr; // Numeric mode encoding (3.33 bits per digit) qr = QrCode.encodeText("314159265358979323846264338327950288419716939937510", QrCode.Ecc.MEDIUM); writePng(qr.toImage(13, 1), "pi-digits-QR.png"); // Alphanumeric mode encoding (5.5 bits per character) qr = QrCode.encodeText("DOLLAR-AMOUNT:$39.87 PERCENTAGE:100.00% OPERATIONS:+-*/", QrCode.Ecc.HIGH); writePng(qr.toImage(10, 2), "alphanumeric-QR.png"); // Unicode text as UTF-8 qr = QrCode.encodeText("こんにちwa、世界! αβγδ", QrCode.Ecc.QUARTILE); writePng(qr.toImage(10, 3), "unicode-QR.png"); // Moderately large QR Code using longer text (from Lewis Carroll's Alice in Wonderland) qr = QrCode.encodeText( "Alice was beginning to get very tired of sitting by her sister on the bank, " + "and of having nothing to do: once or twice she had peeped into the book her sister was reading, " + "but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice " + "'without pictures or conversations?' So she was considering in her own mind (as well as she could, " + "for the hot day made her feel very sleepy and stupid), whether the pleasure of making a " + "daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly " + "a White Rabbit with pink eyes ran close by her.", QrCode.Ecc.HIGH); writePng(qr.toImage(6, 10), "alice-wonderland-QR.png"); } // Creates QR Codes with manually specified segments for better compactness. private static void doSegmentDemo() throws IOException { QrCode qr; List segs; // Illustration "silver" String silver0 = "THE SQUARE ROOT OF 2 IS 1."; String silver1 = "41421356237309504880168872420969807856967187537694807317667973799"; qr = QrCode.encodeText(silver0 + silver1, QrCode.Ecc.LOW); writePng(qr.toImage(10, 3), "sqrt2-monolithic-QR.png"); segs = Arrays.asList( QrSegment.makeAlphanumeric(silver0), QrSegment.makeNumeric(silver1)); qr = QrCode.encodeSegments(segs, QrCode.Ecc.LOW); writePng(qr.toImage(10, 3), "sqrt2-segmented-QR.png"); // Illustration "golden" String golden0 = "Golden ratio φ = 1."; String golden1 = "6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911374"; String golden2 = "......"; qr = QrCode.encodeText(golden0 + golden1 + golden2, QrCode.Ecc.LOW); writePng(qr.toImage(8, 5), "phi-monolithic-QR.png"); segs = Arrays.asList( QrSegment.makeBytes(golden0.getBytes(StandardCharsets.UTF_8)), QrSegment.makeNumeric(golden1), QrSegment.makeAlphanumeric(golden2)); qr = QrCode.encodeSegments(segs, QrCode.Ecc.LOW); writePng(qr.toImage(8, 5), "phi-segmented-QR.png"); // Illustration "Madoka": kanji, kana, Greek, Cyrillic, full-width Latin characters String madoka = "「魔法少女まどか☆マギカ」って、 ИАИ desu κα?"; qr = QrCode.encodeText(madoka, QrCode.Ecc.LOW); writePng(qr.toImage(9, 4), "madoka-utf8-QR.png"); int[] kanjiChars = { // Kanji mode encoding (13 bits per character) 0x0035, 0x1002, 0x0FC0, 0x0AED, 0x0AD7, 0x015C, 0x0147, 0x0129, 0x0059, 0x01BD, 0x018D, 0x018A, 0x0036, 0x0141, 0x0144, 0x0001, 0x0000, 0x0249, 0x0240, 0x0249, 0x0000, 0x0104, 0x0105, 0x0113, 0x0115, 0x0000, 0x0208, 0x01FF, 0x0008, }; BitBuffer bb = new BitBuffer(); for (int c : kanjiChars) bb.appendBits(c, 13); segs = Arrays.asList(new QrSegment(QrSegment.Mode.KANJI, kanjiChars.length, bb)); qr = QrCode.encodeSegments(segs, QrCode.Ecc.LOW); writePng(qr.toImage(9, 4), "madoka-kanji-QR.png"); } // Creates QR Codes with the same size and contents but different mask patterns. private static void doMaskDemo() throws IOException { QrCode qr; List segs; // Project Nayuki URL segs = QrSegment.makeSegments("https://www.nayuki.io/"); qr = QrCode.encodeSegments(segs, QrCode.Ecc.HIGH, QrCode.MIN_VERSION, QrCode.MAX_VERSION, -1, true); // Automatic mask writePng(qr.toImage(8, 6), "project-nayuki-automask-QR.png"); qr = QrCode.encodeSegments(segs, QrCode.Ecc.HIGH, QrCode.MIN_VERSION, QrCode.MAX_VERSION, 3, true); // Force mask 3 writePng(qr.toImage(8, 6), "project-nayuki-mask3-QR.png"); // Chinese text as UTF-8 segs = QrSegment.makeSegments("維基百科(Wikipedia,聆聽i/ˌwɪkᵻˈpiːdi.ə/)是一個自由內容、公開編輯且多語言的網路百科全書協作計畫"); qr = QrCode.encodeSegments(segs, QrCode.Ecc.MEDIUM, QrCode.MIN_VERSION, QrCode.MAX_VERSION, 0, true); // Force mask 0 writePng(qr.toImage(10, 3), "unicode-mask0-QR.png"); qr = QrCode.encodeSegments(segs, QrCode.Ecc.MEDIUM, QrCode.MIN_VERSION, QrCode.MAX_VERSION, 1, true); // Force mask 1 writePng(qr.toImage(10, 3), "unicode-mask1-QR.png"); qr = QrCode.encodeSegments(segs, QrCode.Ecc.MEDIUM, QrCode.MIN_VERSION, QrCode.MAX_VERSION, 5, true); // Force mask 5 writePng(qr.toImage(10, 3), "unicode-mask5-QR.png"); qr = QrCode.encodeSegments(segs, QrCode.Ecc.MEDIUM, QrCode.MIN_VERSION, QrCode.MAX_VERSION, 7, true); // Force mask 7 writePng(qr.toImage(10, 3), "unicode-mask7-QR.png"); } /*---- Utilities ----*/ // Helper function to reduce code duplication. private static void writePng(BufferedImage img, String filepath) throws IOException { ImageIO.write(img, "png", new File(filepath)); } } uTox/third_party/qrcodegen/qrcodegen/java/io/nayuki/qrcodegen/QrCode.java0000600000175000001440000010464214003056224025572 0ustar rakusers/* * QR Code generator library (Java) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ package io.nayuki.qrcodegen; import java.awt.image.BufferedImage; import java.util.Arrays; import java.util.List; import java.util.Objects; /** * Represents an immutable square grid of black and white cells for a QR Code symbol, and * provides static functions to create a QR Code from user-supplied textual or binary data. *

This class covers the QR Code model 2 specification, supporting all versions (sizes) * from 1 to 40, all 4 error correction levels, and only 3 character encoding modes.

*/ public final class QrCode { /*---- Public static factory functions ----*/ /** * Returns a QR Code symbol representing the specified Unicode text string at the specified error correction level. * As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer * Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible * QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the * ecl argument if it can be done without increasing the version. * @param text the text to be encoded, which can be any Unicode string * @param ecl the error correction level to use (will be boosted) * @return a QR Code representing the text * @throws NullPointerException if the text or error correction level is {@code null} * @throws IllegalArgumentException if the text fails to fit in the largest version QR Code, which means it is too long */ public static QrCode encodeText(String text, Ecc ecl) { Objects.requireNonNull(text); Objects.requireNonNull(ecl); List segs = QrSegment.makeSegments(text); return encodeSegments(segs, ecl); } /** * Returns a QR Code symbol representing the specified binary data string at the specified error correction level. * This function always encodes using the binary segment mode, not any text mode. The maximum number of * bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. * The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. * @param data the binary data to encode * @param ecl the error correction level to use (will be boosted) * @return a QR Code representing the binary data * @throws NullPointerException if the data or error correction level is {@code null} * @throws IllegalArgumentException if the data fails to fit in the largest version QR Code, which means it is too long */ public static QrCode encodeBinary(byte[] data, Ecc ecl) { Objects.requireNonNull(data); Objects.requireNonNull(ecl); QrSegment seg = QrSegment.makeBytes(data); return encodeSegments(Arrays.asList(seg), ecl); } /** * Returns a QR Code symbol representing the specified data segments at the specified error correction * level or higher. The smallest possible QR Code version is automatically chosen for the output. *

This function allows the user to create a custom sequence of segments that switches * between modes (such as alphanumeric and binary) to encode text more efficiently. * This function is considered to be lower level than simply encoding text or binary data.

* @param segs the segments to encode * @param ecl the error correction level to use (will be boosted) * @return a QR Code representing the segments * @throws NullPointerException if the list of segments, a segment, or the error correction level is {@code null} * @throws IllegalArgumentException if the data is too long to fit in the largest version QR Code at the ECL */ public static QrCode encodeSegments(List segs, Ecc ecl) { return encodeSegments(segs, ecl, MIN_VERSION, MAX_VERSION, -1, true); } /** * Returns a QR Code symbol representing the specified data segments with the specified encoding parameters. * The smallest possible QR Code version within the specified range is automatically chosen for the output. *

This function allows the user to create a custom sequence of segments that switches * between modes (such as alphanumeric and binary) to encode text more efficiently. * This function is considered to be lower level than simply encoding text or binary data.

* @param segs the segments to encode * @param ecl the error correction level to use (may be boosted) * @param minVersion the minimum allowed version of the QR symbol (at least 1) * @param maxVersion the maximum allowed version of the QR symbol (at most 40) * @param mask the mask pattern to use, which is either -1 for automatic choice or from 0 to 7 for fixed choice * @param boostEcl increases the error correction level if it can be done without increasing the version number * @return a QR Code representing the segments * @throws NullPointerException if the list of segments, a segment, or the error correction level is {@code null} * @throws IllegalArgumentException if 1 ≤ minVersion ≤ maxVersion ≤ 40 is violated, or if mask * < −1 or mask > 7, or if the data is too long to fit in a QR Code at maxVersion at the ECL */ public static QrCode encodeSegments(List segs, Ecc ecl, int minVersion, int maxVersion, int mask, boolean boostEcl) { Objects.requireNonNull(segs); Objects.requireNonNull(ecl); if (!(MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= MAX_VERSION) || mask < -1 || mask > 7) throw new IllegalArgumentException("Invalid value"); // Find the minimal version number to use int version, dataUsedBits; for (version = minVersion; ; version++) { int dataCapacityBits = getNumDataCodewords(version, ecl) * 8; // Number of data bits available dataUsedBits = QrSegment.getTotalBits(segs, version); if (dataUsedBits != -1 && dataUsedBits <= dataCapacityBits) break; // This version number is found to be suitable if (version >= maxVersion) // All versions in the range could not fit the given data throw new IllegalArgumentException("Data too long"); } if (dataUsedBits == -1) throw new AssertionError(); // Increase the error correction level while the data still fits in the current version number for (Ecc newEcl : Ecc.values()) { if (boostEcl && dataUsedBits <= getNumDataCodewords(version, newEcl) * 8) ecl = newEcl; } // Create the data bit string by concatenating all segments int dataCapacityBits = getNumDataCodewords(version, ecl) * 8; BitBuffer bb = new BitBuffer(); for (QrSegment seg : segs) { bb.appendBits(seg.mode.modeBits, 4); bb.appendBits(seg.numChars, seg.mode.numCharCountBits(version)); bb.appendData(seg); } // Add terminator and pad up to a byte if applicable bb.appendBits(0, Math.min(4, dataCapacityBits - bb.bitLength())); bb.appendBits(0, (8 - bb.bitLength() % 8) % 8); // Pad with alternate bytes until data capacity is reached for (int padByte = 0xEC; bb.bitLength() < dataCapacityBits; padByte ^= 0xEC ^ 0x11) bb.appendBits(padByte, 8); if (bb.bitLength() % 8 != 0) throw new AssertionError(); // Create the QR Code symbol return new QrCode(version, ecl, bb.getBytes(), mask); } /*---- Public constants ----*/ public static final int MIN_VERSION = 1; public static final int MAX_VERSION = 40; /*---- Instance fields ----*/ // Public immutable scalar parameters /** This QR Code symbol's version number, which is always between 1 and 40 (inclusive). */ public final int version; /** The width and height of this QR Code symbol, measured in modules. * Always equal to version × 4 + 17, in the range 21 to 177. */ public final int size; /** The error correction level used in this QR Code symbol. Never {@code null}. */ public final Ecc errorCorrectionLevel; /** The mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer). * Note that even if a constructor was called with automatic masking requested * (mask = -1), the resulting object will still have a mask value between 0 and 7. */ public final int mask; // Private grids of modules/pixels (conceptually immutable) private boolean[][] modules; // The modules of this QR Code symbol (false = white, true = black) private boolean[][] isFunction; // Indicates function modules that are not subjected to masking /*---- Constructors ----*/ /** * Creates a new QR Code symbol with the specified version number, error correction level, binary data array, and mask number. *

This is a cumbersome low-level constructor that should not be invoked directly by the user. * To go one level up, see the {@link #encodeSegments(List,Ecc)} function.

* @param ver the version number to use, which must be in the range 1 to 40, inclusive * @param ecl the error correction level to use * @param dataCodewords the raw binary user data to encode * @param mask the mask pattern to use, which is either -1 for automatic choice or from 0 to 7 for fixed choice * @throws NullPointerException if the byte array or error correction level is {@code null} * @throws IllegalArgumentException if the version or mask value is out of range */ public QrCode(int ver, Ecc ecl, byte[] dataCodewords, int mask) { // Check arguments Objects.requireNonNull(ecl); if (ver < MIN_VERSION || ver > MAX_VERSION || mask < -1 || mask > 7) throw new IllegalArgumentException("Value out of range"); Objects.requireNonNull(dataCodewords); // Initialize fields version = ver; size = ver * 4 + 17; errorCorrectionLevel = ecl; modules = new boolean[size][size]; // Entirely white grid isFunction = new boolean[size][size]; // Draw function patterns, draw all codewords, do masking drawFunctionPatterns(); byte[] allCodewords = appendErrorCorrection(dataCodewords); drawCodewords(allCodewords); this.mask = handleConstructorMasking(mask); } /*---- Public instance methods ----*/ /** * Returns the color of the module (pixel) at the specified coordinates, which is either * false for white or true for black. The top left corner has the coordinates (x=0, y=0). * If the specified coordinates are out of bounds, then false (white) is returned. * @param x the x coordinate, where 0 is the left edge and size−1 is the right edge * @param y the y coordinate, where 0 is the top edge and size−1 is the bottom edge * @return the module's color, which is either false (white) or true (black) */ public boolean getModule(int x, int y) { return 0 <= x && x < size && 0 <= y && y < size && modules[y][x]; } /** * Returns a new image object representing this QR Code, with the specified module scale and number * of border modules. For example, the arguments scale=10, border=4 means to pad the QR Code symbol * with 4 white border modules on all four edges, then use 10*10 pixels to represent each module. * The resulting image only contains the hex colors 000000 and FFFFFF. * @param scale the module scale factor, which must be positive * @param border the number of border modules to add, which must be non-negative * @return an image representing this QR Code, with padding and scaling * @throws IllegalArgumentException if the scale or border is out of range */ public BufferedImage toImage(int scale, int border) { if (scale <= 0 || border < 0) throw new IllegalArgumentException("Value out of range"); BufferedImage result = new BufferedImage((size + border * 2) * scale, (size + border * 2) * scale, BufferedImage.TYPE_INT_RGB); for (int y = 0; y < result.getHeight(); y++) { for (int x = 0; x < result.getWidth(); x++) { boolean val = getModule(x / scale - border, y / scale - border); result.setRGB(x, y, val ? 0x000000 : 0xFFFFFF); } } return result; } /** * Based on the specified number of border modules to add as padding, this returns a * string whose contents represents an SVG XML file that depicts this QR Code symbol. * Note that Unix newlines (\n) are always used, regardless of the platform. * @param border the number of border modules to add, which must be non-negative * @return a string representing this QR Code as an SVG document */ public String toSvgString(int border) { if (border < 0) throw new IllegalArgumentException("Border must be non-negative"); StringBuilder sb = new StringBuilder(); sb.append("\n"); sb.append("\n"); sb.append(String.format( "\n", size + border * 2)); sb.append("\t\n"); sb.append("\t\n"); sb.append("\n"); return sb.toString(); } /*---- Private helper methods for constructor: Drawing function modules ----*/ private void drawFunctionPatterns() { // Draw horizontal and vertical timing patterns for (int i = 0; i < size; i++) { setFunctionModule(6, i, i % 2 == 0); setFunctionModule(i, 6, i % 2 == 0); } // Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules) drawFinderPattern(3, 3); drawFinderPattern(size - 4, 3); drawFinderPattern(3, size - 4); // Draw numerous alignment patterns int[] alignPatPos = getAlignmentPatternPositions(version); int numAlign = alignPatPos.length; for (int i = 0; i < numAlign; i++) { for (int j = 0; j < numAlign; j++) { if (i == 0 && j == 0 || i == 0 && j == numAlign - 1 || i == numAlign - 1 && j == 0) continue; // Skip the three finder corners else drawAlignmentPattern(alignPatPos[i], alignPatPos[j]); } } // Draw configuration data drawFormatBits(0); // Dummy mask value; overwritten later in the constructor drawVersion(); } // Draws two copies of the format bits (with its own error correction code) // based on the given mask and this object's error correction level field. private void drawFormatBits(int mask) { // Calculate error correction code and pack bits int data = errorCorrectionLevel.formatBits << 3 | mask; // errCorrLvl is uint2, mask is uint3 int rem = data; for (int i = 0; i < 10; i++) rem = (rem << 1) ^ ((rem >>> 9) * 0x537); data = data << 10 | rem; data ^= 0x5412; // uint15 if (data >>> 15 != 0) throw new AssertionError(); // Draw first copy for (int i = 0; i <= 5; i++) setFunctionModule(8, i, ((data >>> i) & 1) != 0); setFunctionModule(8, 7, ((data >>> 6) & 1) != 0); setFunctionModule(8, 8, ((data >>> 7) & 1) != 0); setFunctionModule(7, 8, ((data >>> 8) & 1) != 0); for (int i = 9; i < 15; i++) setFunctionModule(14 - i, 8, ((data >>> i) & 1) != 0); // Draw second copy for (int i = 0; i <= 7; i++) setFunctionModule(size - 1 - i, 8, ((data >>> i) & 1) != 0); for (int i = 8; i < 15; i++) setFunctionModule(8, size - 15 + i, ((data >>> i) & 1) != 0); setFunctionModule(8, size - 8, true); } // Draws two copies of the version bits (with its own error correction code), // based on this object's version field (which only has an effect for 7 <= version <= 40). private void drawVersion() { if (version < 7) return; // Calculate error correction code and pack bits int rem = version; // version is uint6, in the range [7, 40] for (int i = 0; i < 12; i++) rem = (rem << 1) ^ ((rem >>> 11) * 0x1F25); int data = version << 12 | rem; // uint18 if (data >>> 18 != 0) throw new AssertionError(); // Draw two copies for (int i = 0; i < 18; i++) { boolean bit = ((data >>> i) & 1) != 0; int a = size - 11 + i % 3, b = i / 3; setFunctionModule(a, b, bit); setFunctionModule(b, a, bit); } } // Draws a 9*9 finder pattern including the border separator, with the center module at (x, y). private void drawFinderPattern(int x, int y) { for (int i = -4; i <= 4; i++) { for (int j = -4; j <= 4; j++) { int dist = Math.max(Math.abs(i), Math.abs(j)); // Chebyshev/infinity norm int xx = x + j, yy = y + i; if (0 <= xx && xx < size && 0 <= yy && yy < size) setFunctionModule(xx, yy, dist != 2 && dist != 4); } } } // Draws a 5*5 alignment pattern, with the center module at (x, y). private void drawAlignmentPattern(int x, int y) { for (int i = -2; i <= 2; i++) { for (int j = -2; j <= 2; j++) setFunctionModule(x + j, y + i, Math.max(Math.abs(i), Math.abs(j)) != 1); } } // Sets the color of a module and marks it as a function module. // Only used by the constructor. Coordinates must be in range. private void setFunctionModule(int x, int y, boolean isBlack) { modules[y][x] = isBlack; isFunction[y][x] = true; } /*---- Private helper methods for constructor: Codewords and masking ----*/ // Returns a new byte string representing the given data with the appropriate error correction // codewords appended to it, based on this object's version and error correction level. private byte[] appendErrorCorrection(byte[] data) { if (data.length != getNumDataCodewords(version, errorCorrectionLevel)) throw new IllegalArgumentException(); // Calculate parameter numbers int numBlocks = NUM_ERROR_CORRECTION_BLOCKS[errorCorrectionLevel.ordinal()][version]; int blockEccLen = ECC_CODEWORDS_PER_BLOCK[errorCorrectionLevel.ordinal()][version]; int rawCodewords = getNumRawDataModules(version) / 8; int numShortBlocks = numBlocks - rawCodewords % numBlocks; int shortBlockLen = rawCodewords / numBlocks; // Split data into blocks and append ECC to each block byte[][] blocks = new byte[numBlocks][]; ReedSolomonGenerator rs = new ReedSolomonGenerator(blockEccLen); for (int i = 0, k = 0; i < numBlocks; i++) { byte[] dat = Arrays.copyOfRange(data, k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1)); byte[] block = Arrays.copyOf(dat, shortBlockLen + 1); k += dat.length; byte[] ecc = rs.getRemainder(dat); System.arraycopy(ecc, 0, block, block.length - blockEccLen, ecc.length); blocks[i] = block; } // Interleave (not concatenate) the bytes from every block into a single sequence byte[] result = new byte[rawCodewords]; for (int i = 0, k = 0; i < blocks[0].length; i++) { for (int j = 0; j < blocks.length; j++) { // Skip the padding byte in short blocks if (i != shortBlockLen - blockEccLen || j >= numShortBlocks) { result[k] = blocks[j][i]; k++; } } } return result; } // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire // data area of this QR Code symbol. Function modules need to be marked off before this is called. private void drawCodewords(byte[] data) { Objects.requireNonNull(data); if (data.length != getNumRawDataModules(version) / 8) throw new IllegalArgumentException(); int i = 0; // Bit index into the data // Do the funny zigzag scan for (int right = size - 1; right >= 1; right -= 2) { // Index of right column in each column pair if (right == 6) right = 5; for (int vert = 0; vert < size; vert++) { // Vertical counter for (int j = 0; j < 2; j++) { int x = right - j; // Actual x coordinate boolean upward = ((right + 1) & 2) == 0; int y = upward ? size - 1 - vert : vert; // Actual y coordinate if (!isFunction[y][x] && i < data.length * 8) { modules[y][x] = ((data[i >>> 3] >>> (7 - (i & 7))) & 1) != 0; i++; } // If there are any remainder bits (0 to 7), they are already // set to 0/false/white when the grid of modules was initialized } } } if (i != data.length * 8) throw new AssertionError(); } // XORs the data modules in this QR Code with the given mask pattern. Due to XOR's mathematical // properties, calling applyMask(m) twice with the same value is equivalent to no change at all. // This means it is possible to apply a mask, undo it, and try another mask. Note that a final // well-formed QR Code symbol needs exactly one mask applied (not zero, not two, etc.). private void applyMask(int mask) { if (mask < 0 || mask > 7) throw new IllegalArgumentException("Mask value out of range"); for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) { boolean invert; switch (mask) { case 0: invert = (x + y) % 2 == 0; break; case 1: invert = y % 2 == 0; break; case 2: invert = x % 3 == 0; break; case 3: invert = (x + y) % 3 == 0; break; case 4: invert = (x / 3 + y / 2) % 2 == 0; break; case 5: invert = x * y % 2 + x * y % 3 == 0; break; case 6: invert = (x * y % 2 + x * y % 3) % 2 == 0; break; case 7: invert = ((x + y) % 2 + x * y % 3) % 2 == 0; break; default: throw new AssertionError(); } modules[y][x] ^= invert & !isFunction[y][x]; } } } // A messy helper function for the constructors. This QR Code must be in an unmasked state when this // method is called. The given argument is the requested mask, which is -1 for auto or 0 to 7 for fixed. // This method applies and returns the actual mask chosen, from 0 to 7. private int handleConstructorMasking(int mask) { if (mask == -1) { // Automatically choose best mask int minPenalty = Integer.MAX_VALUE; for (int i = 0; i < 8; i++) { drawFormatBits(i); applyMask(i); int penalty = getPenaltyScore(); if (penalty < minPenalty) { mask = i; minPenalty = penalty; } applyMask(i); // Undoes the mask due to XOR } } if (mask < 0 || mask > 7) throw new AssertionError(); drawFormatBits(mask); // Overwrite old format bits applyMask(mask); // Apply the final choice of mask return mask; // The caller shall assign this value to the final-declared field } // Calculates and returns the penalty score based on state of this QR Code's current modules. // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score. private int getPenaltyScore() { int result = 0; // Adjacent modules in row having same color for (int y = 0; y < size; y++) { boolean colorX = false; for (int x = 0, runX = 0; x < size; x++) { if (x == 0 || modules[y][x] != colorX) { colorX = modules[y][x]; runX = 1; } else { runX++; if (runX == 5) result += PENALTY_N1; else if (runX > 5) result++; } } } // Adjacent modules in column having same color for (int x = 0; x < size; x++) { boolean colorY = false; for (int y = 0, runY = 0; y < size; y++) { if (y == 0 || modules[y][x] != colorY) { colorY = modules[y][x]; runY = 1; } else { runY++; if (runY == 5) result += PENALTY_N1; else if (runY > 5) result++; } } } // 2*2 blocks of modules having same color for (int y = 0; y < size - 1; y++) { for (int x = 0; x < size - 1; x++) { boolean color = modules[y][x]; if ( color == modules[y][x + 1] && color == modules[y + 1][x] && color == modules[y + 1][x + 1]) result += PENALTY_N2; } } // Finder-like pattern in rows for (int y = 0; y < size; y++) { for (int x = 0, bits = 0; x < size; x++) { bits = ((bits << 1) & 0x7FF) | (modules[y][x] ? 1 : 0); if (x >= 10 && (bits == 0x05D || bits == 0x5D0)) // Needs 11 bits accumulated result += PENALTY_N3; } } // Finder-like pattern in columns for (int x = 0; x < size; x++) { for (int y = 0, bits = 0; y < size; y++) { bits = ((bits << 1) & 0x7FF) | (modules[y][x] ? 1 : 0); if (y >= 10 && (bits == 0x05D || bits == 0x5D0)) // Needs 11 bits accumulated result += PENALTY_N3; } } // Balance of black and white modules int black = 0; for (boolean[] row : modules) { for (boolean color : row) { if (color) black++; } } int total = size * size; // Find smallest k such that (45-5k)% <= dark/total <= (55+5k)% for (int k = 0; black*20 < (9-k)*total || black*20 > (11+k)*total; k++) result += PENALTY_N4; return result; } /*---- Private static helper functions ----*/ // Returns a set of positions of the alignment patterns in ascending order. These positions are // used on both the x and y axes. Each value in the resulting array is in the range [0, 177). // This stateless pure function could be implemented as table of 40 variable-length lists of unsigned bytes. private static int[] getAlignmentPatternPositions(int ver) { if (ver < MIN_VERSION || ver > MAX_VERSION) throw new IllegalArgumentException("Version number out of range"); else if (ver == 1) return new int[]{}; else { int numAlign = ver / 7 + 2; int step; if (ver != 32) { // ceil((size - 13) / (2*numAlign - 2)) * 2 step = (ver * 4 + numAlign * 2 + 1) / (2 * numAlign - 2) * 2; } else // C-C-C-Combo breaker! step = 26; int[] result = new int[numAlign]; result[0] = 6; for (int i = result.length - 1, pos = ver * 4 + 10; i >= 1; i--, pos -= step) result[i] = pos; return result; } } // Returns the number of data bits that can be stored in a QR Code of the given version number, after // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8. // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table. private static int getNumRawDataModules(int ver) { if (ver < MIN_VERSION || ver > MAX_VERSION) throw new IllegalArgumentException("Version number out of range"); int size = ver * 4 + 17; int result = size * size; // Number of modules in the whole QR symbol square result -= 64 * 3; // Subtract the three finders with separators result -= 15 * 2 + 1; // Subtract the format information and black module result -= (size - 16) * 2; // Subtract the timing patterns // The five lines above are equivalent to: int result = (16 * ver + 128) * ver + 64; if (ver >= 2) { int numAlign = ver / 7 + 2; result -= (numAlign - 1) * (numAlign - 1) * 25; // Subtract alignment patterns not overlapping with timing patterns result -= (numAlign - 2) * 2 * 20; // Subtract alignment patterns that overlap with timing patterns // The two lines above are equivalent to: result -= (25 * numAlign - 10) * numAlign - 55; if (ver >= 7) result -= 18 * 2; // Subtract version information } return result; } // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any // QR Code of the given version number and error correction level, with remainder bits discarded. // This stateless pure function could be implemented as a (40*4)-cell lookup table. static int getNumDataCodewords(int ver, Ecc ecl) { if (ver < MIN_VERSION || ver > MAX_VERSION) throw new IllegalArgumentException("Version number out of range"); return getNumRawDataModules(ver) / 8 - ECC_CODEWORDS_PER_BLOCK[ecl.ordinal()][ver] * NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal()][ver]; } /*---- Private tables of constants ----*/ // For use in getPenaltyScore(), when evaluating which mask is best. private static final int PENALTY_N1 = 3; private static final int PENALTY_N2 = 3; private static final int PENALTY_N3 = 40; private static final int PENALTY_N4 = 10; private static final byte[][] ECC_CODEWORDS_PER_BLOCK = { // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level {-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Low {-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28}, // Medium {-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Quartile {-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // High }; private static final byte[][] NUM_ERROR_CORRECTION_BLOCKS = { // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level {-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25}, // Low {-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49}, // Medium {-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68}, // Quartile {-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81}, // High }; /*---- Public helper enumeration ----*/ /** * Represents the error correction level used in a QR Code symbol. */ public enum Ecc { // These enum constants must be declared in ascending order of error protection, // for the sake of the implicit ordinal() method and values() function. LOW(1), MEDIUM(0), QUARTILE(3), HIGH(2); // In the range 0 to 3 (unsigned 2-bit integer). final int formatBits; // Constructor. private Ecc(int fb) { formatBits = fb; } } /*---- Private helper class ----*/ /** * Computes the Reed-Solomon error correction codewords for a sequence of data codewords * at a given degree. Objects are immutable, and the state only depends on the degree. * This class exists because each data block in a QR Code shares the same the divisor polynomial. */ private static final class ReedSolomonGenerator { /*-- Immutable field --*/ // Coefficients of the divisor polynomial, stored from highest to lowest power, excluding the leading term which // is always 1. For example the polynomial x^3 + 255x^2 + 8x + 93 is stored as the uint8 array {255, 8, 93}. private final byte[] coefficients; /*-- Constructor --*/ /** * Creates a Reed-Solomon ECC generator for the specified degree. This could be implemented * as a lookup table over all possible parameter values, instead of as an algorithm. * @param degree the divisor polynomial degree, which must be between 1 and 255 * @throws IllegalArgumentException if degree < 1 or degree > 255 */ public ReedSolomonGenerator(int degree) { if (degree < 1 || degree > 255) throw new IllegalArgumentException("Degree out of range"); // Start with the monomial x^0 coefficients = new byte[degree]; coefficients[degree - 1] = 1; // Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}), // drop the highest term, and store the rest of the coefficients in order of descending powers. // Note that r = 0x02, which is a generator element of this field GF(2^8/0x11D). int root = 1; for (int i = 0; i < degree; i++) { // Multiply the current product by (x - r^i) for (int j = 0; j < coefficients.length; j++) { coefficients[j] = (byte)multiply(coefficients[j] & 0xFF, root); if (j + 1 < coefficients.length) coefficients[j] ^= coefficients[j + 1]; } root = multiply(root, 0x02); } } /*-- Method --*/ /** * Computes and returns the Reed-Solomon error correction codewords for the specified * sequence of data codewords. The returned object is always a new byte array. * This method does not alter this object's state (because it is immutable). * @param data the sequence of data codewords * @return the Reed-Solomon error correction codewords * @throws NullPointerException if the data is {@code null} */ public byte[] getRemainder(byte[] data) { Objects.requireNonNull(data); // Compute the remainder by performing polynomial division byte[] result = new byte[coefficients.length]; for (byte b : data) { int factor = (b ^ result[0]) & 0xFF; System.arraycopy(result, 1, result, 0, result.length - 1); result[result.length - 1] = 0; for (int i = 0; i < result.length; i++) result[i] ^= multiply(coefficients[i] & 0xFF, factor); } return result; } /*-- Static function --*/ // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8. private static int multiply(int x, int y) { if (x >>> 8 != 0 || y >>> 8 != 0) throw new IllegalArgumentException("Byte out of range"); // Russian peasant multiplication int z = 0; for (int i = 7; i >= 0; i--) { z = (z << 1) ^ ((z >>> 7) * 0x11D); z ^= ((y >>> i) & 1) * x; } if (z >>> 8 != 0) throw new AssertionError(); return z; } } } uTox/third_party/qrcodegen/qrcodegen/java/io/nayuki/qrcodegen/BitBuffer.java0000600000175000001440000000754014003056224026264 0ustar rakusers/* * QR Code generator library (Java) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ package io.nayuki.qrcodegen; import java.util.BitSet; import java.util.Objects; /** * An appendable sequence of bits (0's and 1's). */ public final class BitBuffer implements Cloneable { /*---- Fields ----*/ private BitSet data; private int bitLength; /*---- Constructor ----*/ /** * Constructs an empty bit buffer (length 0). */ public BitBuffer() { data = new BitSet(); bitLength = 0; } /*---- Methods ----*/ /** * Returns the length of this sequence, which is a non-negative value. * @return the length of this sequence */ public int bitLength() { return bitLength; } /** * Returns the bit at the specified index, yielding 0 or 1. * @param index the index to get the bit at * @return the bit at the specified index * @throws IndexOutOfBoundsException if index < 0 or index ≥ bitLength */ public int getBit(int index) { if (index < 0 || index >= bitLength) throw new IndexOutOfBoundsException(); return data.get(index) ? 1 : 0; } /** * Packs this buffer's bits into bytes in big endian, * padding with '0' bit values, and returns the new array. * @return this sequence as a new array of bytes (not {@code null}) */ public byte[] getBytes() { byte[] result = new byte[(bitLength + 7) / 8]; for (int i = 0; i < bitLength; i++) result[i >>> 3] |= data.get(i) ? 1 << (7 - (i & 7)) : 0; return result; } /** * Appends the specified number of low bits of the specified value * to this sequence. Requires 0 ≤ val < 2len. * @param val the value to append * @param len the number of low bits in the value to take */ public void appendBits(int val, int len) { if (len < 0 || len > 31 || val >>> len != 0) throw new IllegalArgumentException("Value out of range"); for (int i = len - 1; i >= 0; i--, bitLength++) // Append bit by bit data.set(bitLength, ((val >>> i) & 1) != 0); } /** * Appends the bit data of the specified segment to this bit buffer. * @param seg the segment whose data to append (not {@code null}) * @throws NullPointerException if the segment is {@code null} */ public void appendData(QrSegment seg) { Objects.requireNonNull(seg); BitBuffer bb = seg.data; for (int i = 0; i < bb.bitLength; i++, bitLength++) // Append bit by bit data.set(bitLength, bb.data.get(i)); } /** * Returns a copy of this bit buffer object. * @return a copy of this bit buffer object */ public BitBuffer clone() { try { BitBuffer result = (BitBuffer)super.clone(); result.data = (BitSet)result.data.clone(); return result; } catch (CloneNotSupportedException e) { throw new AssertionError(e); } } } uTox/third_party/qrcodegen/qrcodegen/cpp/0000700000175000001440000000000014003056224017524 5ustar rakusersuTox/third_party/qrcodegen/qrcodegen/cpp/QrSegment.hpp0000600000175000001440000001247314003056224022153 0ustar rakusers/* * QR Code generator library (C++) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ #pragma once #include #include #include "BitBuffer.hpp" namespace qrcodegen { /* * Represents a character string to be encoded in a QR Code symbol. Each segment has * a mode, and a sequence of characters that is already encoded as a sequence of bits. * Instances of this class are immutable. * This segment class imposes no length restrictions, but QR Codes have restrictions. * Even in the most favorable conditions, a QR Code can only hold 7089 characters of data. * Any segment longer than this is meaningless for the purpose of generating QR Codes. */ class QrSegment final { /*---- Public helper enumeration ----*/ /* * The mode field of a segment. Immutable. Provides methods to retrieve closely related values. */ public: class Mode final { /*-- Constants --*/ public: static const Mode NUMERIC; public: static const Mode ALPHANUMERIC; public: static const Mode BYTE; public: static const Mode KANJI; public: static const Mode ECI; /*-- Fields --*/ private: int modeBits; private: int numBitsCharCount[3]; /*-- Constructor --*/ private: Mode(int mode, int cc0, int cc1, int cc2); /*-- Methods --*/ /* * (Package-private) Returns the mode indicator bits, which is an unsigned 4-bit value (range 0 to 15). */ public: int getModeBits() const; /* * (Package-private) Returns the bit width of the segment character count field for this mode object at the given version number. */ public: int numCharCountBits(int ver) const; }; /*---- Public static factory functions ----*/ /* * Returns a segment representing the given binary data encoded in byte mode. */ public: static QrSegment makeBytes(const std::vector &data); /* * Returns a segment representing the given string of decimal digits encoded in numeric mode. */ public: static QrSegment makeNumeric(const char *digits); /* * Returns a segment representing the given text string encoded in alphanumeric mode. * The characters allowed are: 0 to 9, A to Z (uppercase only), space, * dollar, percent, asterisk, plus, hyphen, period, slash, colon. */ public: static QrSegment makeAlphanumeric(const char *text); /* * Returns a list of zero or more segments to represent the given text string. * The result may use various segment modes and switch modes to optimize the length of the bit stream. */ public: static std::vector makeSegments(const char *text); /* * Returns a segment representing an Extended Channel Interpretation * (ECI) designator with the given assignment value. */ public: static QrSegment makeEci(long assignVal); /*---- Public static helper functions ----*/ /* * Tests whether the given string can be encoded as a segment in alphanumeric mode. */ public: static bool isAlphanumeric(const char *text); /* * Tests whether the given string can be encoded as a segment in numeric mode. */ public: static bool isNumeric(const char *text); /*---- Instance fields ----*/ /* The mode indicator for this segment. */ private: Mode mode; /* The length of this segment's unencoded data, measured in characters. Always zero or positive. */ private: int numChars; /* The data bits of this segment. */ private: std::vector data; /*---- Constructor ----*/ /* * Creates a new QR Code data segment with the given parameters and data. */ public: QrSegment(Mode md, int numCh, const std::vector &dt); /* * Creates a new QR Code data segment with the given parameters and data. */ public: QrSegment(Mode md, int numCh, std::vector &&dt); /*---- Methods ----*/ public: Mode getMode() const; public: int getNumChars() const; public: const std::vector &getData() const; // Package-private helper function. public: static int getTotalBits(const std::vector &segs, int version); /*---- Private constant ----*/ /* The set of all legal characters in alphanumeric mode, where each character value maps to the index in the string. */ private: static const char *ALPHANUMERIC_CHARSET; }; } uTox/third_party/qrcodegen/qrcodegen/cpp/QrSegment.cpp0000600000175000001440000001431014003056224022136 0ustar rakusers/* * QR Code generator library (C++) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ #include #include #include #include "QrSegment.hpp" using std::uint8_t; using std::vector; namespace qrcodegen { QrSegment::Mode::Mode(int mode, int cc0, int cc1, int cc2) : modeBits(mode) { numBitsCharCount[0] = cc0; numBitsCharCount[1] = cc1; numBitsCharCount[2] = cc2; } int QrSegment::Mode::getModeBits() const { return modeBits; } int QrSegment::Mode::numCharCountBits(int ver) const { if ( 1 <= ver && ver <= 9) return numBitsCharCount[0]; else if (10 <= ver && ver <= 26) return numBitsCharCount[1]; else if (27 <= ver && ver <= 40) return numBitsCharCount[2]; else throw "Version number out of range"; } const QrSegment::Mode QrSegment::Mode::NUMERIC (0x1, 10, 12, 14); const QrSegment::Mode QrSegment::Mode::ALPHANUMERIC(0x2, 9, 11, 13); const QrSegment::Mode QrSegment::Mode::BYTE (0x4, 8, 16, 16); const QrSegment::Mode QrSegment::Mode::KANJI (0x8, 8, 10, 12); const QrSegment::Mode QrSegment::Mode::ECI (0x7, 0, 0, 0); QrSegment QrSegment::makeBytes(const vector &data) { if (data.size() > INT_MAX) throw "Data too long"; BitBuffer bb; for (uint8_t b : data) bb.appendBits(b, 8); return QrSegment(Mode::BYTE, static_cast(data.size()), std::move(bb)); } QrSegment QrSegment::makeNumeric(const char *digits) { BitBuffer bb; int accumData = 0; int accumCount = 0; int charCount = 0; for (; *digits != '\0'; digits++, charCount++) { char c = *digits; if (c < '0' || c > '9') throw "String contains non-numeric characters"; accumData = accumData * 10 + (c - '0'); accumCount++; if (accumCount == 3) { bb.appendBits(accumData, 10); accumData = 0; accumCount = 0; } } if (accumCount > 0) // 1 or 2 digits remaining bb.appendBits(accumData, accumCount * 3 + 1); return QrSegment(Mode::NUMERIC, charCount, std::move(bb)); } QrSegment QrSegment::makeAlphanumeric(const char *text) { BitBuffer bb; int accumData = 0; int accumCount = 0; int charCount = 0; for (; *text != '\0'; text++, charCount++) { const char *temp = std::strchr(ALPHANUMERIC_CHARSET, *text); if (temp == nullptr) throw "String contains unencodable characters in alphanumeric mode"; accumData = accumData * 45 + (temp - ALPHANUMERIC_CHARSET); accumCount++; if (accumCount == 2) { bb.appendBits(accumData, 11); accumData = 0; accumCount = 0; } } if (accumCount > 0) // 1 character remaining bb.appendBits(accumData, 6); return QrSegment(Mode::ALPHANUMERIC, charCount, std::move(bb)); } vector QrSegment::makeSegments(const char *text) { // Select the most efficient segment encoding automatically vector result; if (*text == '\0'); // Leave result empty else if (isNumeric(text)) result.push_back(makeNumeric(text)); else if (isAlphanumeric(text)) result.push_back(makeAlphanumeric(text)); else { vector bytes; for (; *text != '\0'; text++) bytes.push_back(static_cast(*text)); result.push_back(makeBytes(bytes)); } return result; } QrSegment QrSegment::makeEci(long assignVal) { BitBuffer bb; if (0 <= assignVal && assignVal < (1 << 7)) bb.appendBits(assignVal, 8); else if ((1 << 7) <= assignVal && assignVal < (1 << 14)) { bb.appendBits(2, 2); bb.appendBits(assignVal, 14); } else if ((1 << 14) <= assignVal && assignVal < 1000000L) { bb.appendBits(6, 3); bb.appendBits(assignVal, 21); } else throw "ECI assignment value out of range"; return QrSegment(Mode::ECI, 0, std::move(bb)); } QrSegment::QrSegment(Mode md, int numCh, const std::vector &dt) : mode(md), numChars(numCh), data(dt) { if (numCh < 0) throw "Invalid value"; } QrSegment::QrSegment(Mode md, int numCh, std::vector &&dt) : mode(md), numChars(numCh), data(std::move(dt)) { if (numCh < 0) throw "Invalid value"; } int QrSegment::getTotalBits(const vector &segs, int version) { if (version < 1 || version > 40) throw "Version number out of range"; int result = 0; for (const QrSegment &seg : segs) { int ccbits = seg.mode.numCharCountBits(version); // Fail if segment length value doesn't fit in the length field's bit-width if (seg.numChars >= (1L << ccbits)) return -1; if (4 + ccbits > INT_MAX - result) return -1; result += 4 + ccbits; if (seg.data.size() > static_cast(INT_MAX - result)) return -1; result += static_cast(seg.data.size()); } return result; } bool QrSegment::isAlphanumeric(const char *text) { for (; *text != '\0'; text++) { if (std::strchr(ALPHANUMERIC_CHARSET, *text) == nullptr) return false; } return true; } bool QrSegment::isNumeric(const char *text) { for (; *text != '\0'; text++) { char c = *text; if (c < '0' || c > '9') return false; } return true; } QrSegment::Mode QrSegment::getMode() const { return mode; } int QrSegment::getNumChars() const { return numChars; } const std::vector &QrSegment::getData() const { return data; } const char *QrSegment::ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; } uTox/third_party/qrcodegen/qrcodegen/cpp/QrCodeGeneratorWorker.cpp0000600000175000001440000000636114003056224024456 0ustar rakusers/* * QR Code generator test worker (C++) * * This program reads data and encoding parameters from standard input and writes * QR Code bitmaps to standard output. The I/O format is one integer per line. * Run with no command line arguments. The program is intended for automated * batch testing of end-to-end functionality of this QR Code generator library. * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ #include #include #include #include #include #include "QrCode.hpp" using qrcodegen::QrCode; using qrcodegen::QrSegment; static const QrCode::Ecc *(ECC_LEVELS[]) = { &QrCode::Ecc::LOW, &QrCode::Ecc::MEDIUM, &QrCode::Ecc::QUARTILE, &QrCode::Ecc::HIGH, }; int main() { while (true) { // Read data length or exit int length; std::cin >> length; if (length == -1) break; // Read data bytes bool isAscii = true; std::vector data; for (int i = 0; i < length; i++) { int b; std::cin >> b; data.push_back((uint8_t)b); isAscii &= 0 < b && b < 128; } // Read encoding parameters int errCorLvl, minVersion, maxVersion, mask, boostEcl; std::cin >> errCorLvl; std::cin >> minVersion; std::cin >> maxVersion; std::cin >> mask; std::cin >> boostEcl; // Make list of segments std::vector segs; if (isAscii) { std::vector text(data.cbegin(), data.cend()); text.push_back('\0'); segs = QrSegment::makeSegments(text.data()); } else segs.push_back(QrSegment::makeBytes(data)); try { // Try to make QR Code symbol const QrCode qr = QrCode::encodeSegments(segs, *ECC_LEVELS[errCorLvl], minVersion, maxVersion, mask, boostEcl == 1); // Print grid of modules std::cout << qr.getVersion() << std::endl; for (int y = 0; y < qr.getSize(); y++) { for (int x = 0; x < qr.getSize(); x++) std::cout << (qr.getModule(x, y) ? 1 : 0) << std::endl; } } catch (const char *msg) { if (strcmp(msg, "Data too long") != 0) { std::cerr << msg << std::endl; return EXIT_FAILURE; } std::cout << -1 << std::endl; } std::cout << std::flush; } return EXIT_SUCCESS; } uTox/third_party/qrcodegen/qrcodegen/cpp/QrCodeGeneratorDemo.cpp0000600000175000001440000002017714003056224024072 0ustar rakusers/* * QR Code generator demo (C++) * * Run this command-line program with no arguments. The program computes a bunch of demonstration * QR Codes and prints them to the console. Also, the SVG code for one QR Code is printed as a sample. * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ #include #include #include #include #include #include #include "BitBuffer.hpp" #include "QrCode.hpp" using std::uint8_t; using qrcodegen::QrCode; using qrcodegen::QrSegment; // Function prototypes static void doBasicDemo(); static void doVarietyDemo(); static void doSegmentDemo(); static void doMaskDemo(); static void printQr(const QrCode &qr); // The main application program. int main() { doBasicDemo(); doVarietyDemo(); doSegmentDemo(); doMaskDemo(); return EXIT_SUCCESS; } /*---- Demo suite ----*/ // Creates a single QR Code, then prints it to the console. static void doBasicDemo() { const char *text = "Hello, world!"; // User-supplied text const QrCode::Ecc errCorLvl = QrCode::Ecc::LOW; // Error correction level // Make and print the QR Code symbol const QrCode qr = QrCode::encodeText(text, errCorLvl); printQr(qr); std::cout << qr.toSvgString(4) << std::endl; } // Creates a variety of QR Codes that exercise different features of the library, and prints each one to the console. static void doVarietyDemo() { // Numeric mode encoding (3.33 bits per digit) const QrCode qr1 = QrCode::encodeText("314159265358979323846264338327950288419716939937510", QrCode::Ecc::MEDIUM); printQr(qr1); // Alphanumeric mode encoding (5.5 bits per character) const QrCode qr2 = QrCode::encodeText("DOLLAR-AMOUNT:$39.87 PERCENTAGE:100.00% OPERATIONS:+-*/", QrCode::Ecc::HIGH); printQr(qr2); // Unicode text as UTF-8 const QrCode qr3 = QrCode::encodeText("\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1wa\xE3\x80\x81\xE4\xB8\x96\xE7\x95\x8C\xEF\xBC\x81\x20\xCE\xB1\xCE\xB2\xCE\xB3\xCE\xB4", QrCode::Ecc::QUARTILE); printQr(qr3); // Moderately large QR Code using longer text (from Lewis Carroll's Alice in Wonderland) const QrCode qr4 = QrCode::encodeText( "Alice was beginning to get very tired of sitting by her sister on the bank, " "and of having nothing to do: once or twice she had peeped into the book her sister was reading, " "but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice " "'without pictures or conversations?' So she was considering in her own mind (as well as she could, " "for the hot day made her feel very sleepy and stupid), whether the pleasure of making a " "daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly " "a White Rabbit with pink eyes ran close by her.", QrCode::Ecc::HIGH); printQr(qr4); } // Creates QR Codes with manually specified segments for better compactness. static void doSegmentDemo() { // Illustration "silver" const char *silver0 = "THE SQUARE ROOT OF 2 IS 1."; const char *silver1 = "41421356237309504880168872420969807856967187537694807317667973799"; const QrCode qr0 = QrCode::encodeText( (std::string(silver0) + silver1).c_str(), QrCode::Ecc::LOW); printQr(qr0); const QrCode qr1 = QrCode::encodeSegments( {QrSegment::makeAlphanumeric(silver0), QrSegment::makeNumeric(silver1)}, QrCode::Ecc::LOW); printQr(qr1); // Illustration "golden" const char *golden0 = "Golden ratio \xCF\x86 = 1."; const char *golden1 = "6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911374"; const char *golden2 = "......"; const QrCode qr2 = QrCode::encodeText( (std::string(golden0) + golden1 + golden2).c_str(), QrCode::Ecc::LOW); printQr(qr2); std::vector bytes(golden0, golden0 + std::strlen(golden0)); const QrCode qr3 = QrCode::encodeSegments( {QrSegment::makeBytes(bytes), QrSegment::makeNumeric(golden1), QrSegment::makeAlphanumeric(golden2)}, QrCode::Ecc::LOW); printQr(qr3); // Illustration "Madoka": kanji, kana, Greek, Cyrillic, full-width Latin characters const char *madoka = // Encoded in UTF-8 "\xE3\x80\x8C\xE9\xAD\x94\xE6\xB3\x95\xE5" "\xB0\x91\xE5\xA5\xB3\xE3\x81\xBE\xE3\x81" "\xA9\xE3\x81\x8B\xE2\x98\x86\xE3\x83\x9E" "\xE3\x82\xAE\xE3\x82\xAB\xE3\x80\x8D\xE3" "\x81\xA3\xE3\x81\xA6\xE3\x80\x81\xE3\x80" "\x80\xD0\x98\xD0\x90\xD0\x98\xE3\x80\x80" "\xEF\xBD\x84\xEF\xBD\x85\xEF\xBD\x93\xEF" "\xBD\x95\xE3\x80\x80\xCE\xBA\xCE\xB1\xEF" "\xBC\x9F"; const QrCode qr4 = QrCode::encodeText(madoka, QrCode::Ecc::LOW); printQr(qr4); const std::vector kanjiChars{ // Kanji mode encoding (13 bits per character) 0x0035, 0x1002, 0x0FC0, 0x0AED, 0x0AD7, 0x015C, 0x0147, 0x0129, 0x0059, 0x01BD, 0x018D, 0x018A, 0x0036, 0x0141, 0x0144, 0x0001, 0x0000, 0x0249, 0x0240, 0x0249, 0x0000, 0x0104, 0x0105, 0x0113, 0x0115, 0x0000, 0x0208, 0x01FF, 0x0008, }; qrcodegen::BitBuffer bb; for (int c : kanjiChars) bb.appendBits(c, 13); const QrCode qr5 = QrCode::encodeSegments( {QrSegment(QrSegment::Mode::KANJI, kanjiChars.size(), bb)}, QrCode::Ecc::LOW); printQr(qr5); } // Creates QR Codes with the same size and contents but different mask patterns. static void doMaskDemo() { // Project Nayuki URL std::vector segs0 = QrSegment::makeSegments("https://www.nayuki.io/"); printQr(QrCode::encodeSegments(segs0, QrCode::Ecc::HIGH, QrCode::MIN_VERSION, QrCode::MAX_VERSION, -1, true)); // Automatic mask printQr(QrCode::encodeSegments(segs0, QrCode::Ecc::HIGH, QrCode::MIN_VERSION, QrCode::MAX_VERSION, 3, true)); // Force mask 3 // Chinese text as UTF-8 std::vector segs1 = QrSegment::makeSegments( "\xE7\xB6\xAD\xE5\x9F\xBA\xE7\x99\xBE\xE7\xA7\x91\xEF\xBC\x88\x57\x69\x6B\x69\x70" "\x65\x64\x69\x61\xEF\xBC\x8C\xE8\x81\x86\xE8\x81\xBD\x69\x2F\xCB\x8C\x77\xC9\xAA" "\x6B\xE1\xB5\xBB\xCB\x88\x70\x69\xCB\x90\x64\x69\x2E\xC9\x99\x2F\xEF\xBC\x89\xE6" "\x98\xAF\xE4\xB8\x80\xE5\x80\x8B\xE8\x87\xAA\xE7\x94\xB1\xE5\x85\xA7\xE5\xAE\xB9" "\xE3\x80\x81\xE5\x85\xAC\xE9\x96\x8B\xE7\xB7\xA8\xE8\xBC\xAF\xE4\xB8\x94\xE5\xA4" "\x9A\xE8\xAA\x9E\xE8\xA8\x80\xE7\x9A\x84\xE7\xB6\xB2\xE8\xB7\xAF\xE7\x99\xBE\xE7" "\xA7\x91\xE5\x85\xA8\xE6\x9B\xB8\xE5\x8D\x94\xE4\xBD\x9C\xE8\xA8\x88\xE7\x95\xAB"); printQr(QrCode::encodeSegments(segs1, QrCode::Ecc::MEDIUM, QrCode::MIN_VERSION, QrCode::MAX_VERSION, 0, true)); // Force mask 0 printQr(QrCode::encodeSegments(segs1, QrCode::Ecc::MEDIUM, QrCode::MIN_VERSION, QrCode::MAX_VERSION, 1, true)); // Force mask 1 printQr(QrCode::encodeSegments(segs1, QrCode::Ecc::MEDIUM, QrCode::MIN_VERSION, QrCode::MAX_VERSION, 5, true)); // Force mask 5 printQr(QrCode::encodeSegments(segs1, QrCode::Ecc::MEDIUM, QrCode::MIN_VERSION, QrCode::MAX_VERSION, 7, true)); // Force mask 7 } /*---- Utilities ----*/ // Prints the given QR Code to the console. static void printQr(const QrCode &qr) { int border = 4; for (int y = -border; y < qr.getSize() + border; y++) { for (int x = -border; x < qr.getSize() + border; x++) { std::cout << (qr.getModule(x, y) ? "##" : " "); } std::cout << std::endl; } std::cout << std::endl; } uTox/third_party/qrcodegen/qrcodegen/cpp/QrCode.hpp0000600000175000001440000003045514003056224021423 0ustar rakusers/* * QR Code generator library (C++) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ #pragma once #include #include #include #include "QrSegment.hpp" namespace qrcodegen { /* * Represents an immutable square grid of black and white cells for a QR Code symbol, and * provides static functions to create a QR Code from user-supplied textual or binary data. * This class covers the QR Code model 2 specification, supporting all versions (sizes) * from 1 to 40, all 4 error correction levels, and only 3 character encoding modes. */ class QrCode final { /*---- Public helper enumeration ----*/ /* * Represents the error correction level used in a QR Code symbol. */ public: class Ecc final { // Constants declared in ascending order of error protection. public: const static Ecc LOW, MEDIUM, QUARTILE, HIGH; // Fields. private: int ordinal; private: int formatBits; // Constructor. private: Ecc(int ord, int fb); // (Public) Returns a value in the range 0 to 3 (unsigned 2-bit integer). public: int getOrdinal() const; // (Package-private) Returns a value in the range 0 to 3 (unsigned 2-bit integer). public: int getFormatBits() const; }; /*---- Public static factory functions ----*/ /* * Returns a QR Code symbol representing the specified Unicode text string at the specified error correction level. * As a conservative upper bound, this function is guaranteed to succeed for strings that have 2953 or fewer * UTF-8 code units (not Unicode code points) if the low error correction level is used. The smallest possible * QR Code version is automatically chosen for the output. The ECC level of the result may be higher than * the ecl argument if it can be done without increasing the version. */ public: static QrCode encodeText(const char *text, Ecc ecl); /* * Returns a QR Code symbol representing the given binary data string at the given error correction level. * This function always encodes using the binary segment mode, not any text mode. The maximum number of * bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. * The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. */ public: static QrCode encodeBinary(const std::vector &data, Ecc ecl); /* * Returns a QR Code symbol representing the given data segments with the given encoding parameters. * The smallest possible QR Code version within the given range is automatically chosen for the output. * This function allows the user to create a custom sequence of segments that switches * between modes (such as alphanumeric and binary) to encode text more efficiently. * This function is considered to be lower level than simply encoding text or binary data. */ public: static QrCode encodeSegments(const std::vector &segs, Ecc ecl, int minVersion=1, int maxVersion=40, int mask=-1, bool boostEcl=true); // All optional parameters /*---- Public constants ----*/ public: static constexpr int MIN_VERSION = 1; public: static constexpr int MAX_VERSION = 40; /*---- Instance fields ----*/ // Immutable scalar parameters /* This QR Code symbol's version number, which is always between 1 and 40 (inclusive). */ private: int version; /* The width and height of this QR Code symbol, measured in modules. * Always equal to version × 4 + 17, in the range 21 to 177. */ private: int size; /* The error correction level used in this QR Code symbol. */ private: Ecc errorCorrectionLevel; /* The mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer). * Note that even if a constructor was called with automatic masking requested * (mask = -1), the resulting object will still have a mask value between 0 and 7. */ private: int mask; // Private grids of modules/pixels (conceptually immutable) private: std::vector > modules; // The modules of this QR Code symbol (false = white, true = black) private: std::vector > isFunction; // Indicates function modules that are not subjected to masking /*---- Constructors ----*/ /* * Creates a new QR Code symbol with the given version number, error correction level, binary data array, * and mask number. This is a cumbersome low-level constructor that should not be invoked directly by the user. * To go one level up, see the encodeSegments() function. */ public: QrCode(int ver, Ecc ecl, const std::vector &dataCodewords, int mask); /*---- Public instance methods ----*/ public: int getVersion() const; public: int getSize() const; public: Ecc getErrorCorrectionLevel() const; public: int getMask() const; /* * Returns the color of the module (pixel) at the given coordinates, which is either * false for white or true for black. The top left corner has the coordinates (x=0, y=0). * If the given coordinates are out of bounds, then false (white) is returned. */ public: bool getModule(int x, int y) const; /* * Based on the given number of border modules to add as padding, this returns a * string whose contents represents an SVG XML file that depicts this QR Code symbol. * Note that Unix newlines (\n) are always used, regardless of the platform. */ public: std::string toSvgString(int border) const; /*---- Private helper methods for constructor: Drawing function modules ----*/ private: void drawFunctionPatterns(); // Draws two copies of the format bits (with its own error correction code) // based on the given mask and this object's error correction level field. private: void drawFormatBits(int mask); // Draws two copies of the version bits (with its own error correction code), // based on this object's version field (which only has an effect for 7 <= version <= 40). private: void drawVersion(); // Draws a 9*9 finder pattern including the border separator, with the center module at (x, y). private: void drawFinderPattern(int x, int y); // Draws a 5*5 alignment pattern, with the center module at (x, y). private: void drawAlignmentPattern(int x, int y); // Sets the color of a module and marks it as a function module. // Only used by the constructor. Coordinates must be in range. private: void setFunctionModule(int x, int y, bool isBlack); // Returns the color of the module at the given coordinates, which must be in range. private: bool module(int x, int y) const; /*---- Private helper methods for constructor: Codewords and masking ----*/ // Returns a new byte string representing the given data with the appropriate error correction // codewords appended to it, based on this object's version and error correction level. private: std::vector appendErrorCorrection(const std::vector &data) const; // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire // data area of this QR Code symbol. Function modules need to be marked off before this is called. private: void drawCodewords(const std::vector &data); // XORs the data modules in this QR Code with the given mask pattern. Due to XOR's mathematical // properties, calling applyMask(m) twice with the same value is equivalent to no change at all. // This means it is possible to apply a mask, undo it, and try another mask. Note that a final // well-formed QR Code symbol needs exactly one mask applied (not zero, not two, etc.). private: void applyMask(int mask); // A messy helper function for the constructors. This QR Code must be in an unmasked state when this // method is called. The given argument is the requested mask, which is -1 for auto or 0 to 7 for fixed. // This method applies and returns the actual mask chosen, from 0 to 7. private: int handleConstructorMasking(int mask); // Calculates and returns the penalty score based on state of this QR Code's current modules. // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score. private: long getPenaltyScore() const; /*---- Private static helper functions ----*/ // Returns a set of positions of the alignment patterns in ascending order. These positions are // used on both the x and y axes. Each value in the resulting array is in the range [0, 177). // This stateless pure function could be implemented as table of 40 variable-length lists of unsigned bytes. private: static std::vector getAlignmentPatternPositions(int ver); // Returns the number of data bits that can be stored in a QR Code of the given version number, after // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8. // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table. private: static int getNumRawDataModules(int ver); // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any // QR Code of the given version number and error correction level, with remainder bits discarded. // This stateless pure function could be implemented as a (40*4)-cell lookup table. private: static int getNumDataCodewords(int ver, Ecc ecl); /*---- Private tables of constants ----*/ // For use in getPenaltyScore(), when evaluating which mask is best. private: static const int PENALTY_N1; private: static const int PENALTY_N2; private: static const int PENALTY_N3; private: static const int PENALTY_N4; private: static const std::int8_t ECC_CODEWORDS_PER_BLOCK[4][41]; private: static const std::int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41]; /*---- Private helper class ----*/ /* * Computes the Reed-Solomon error correction codewords for a sequence of data codewords * at a given degree. Objects are immutable, and the state only depends on the degree. * This class exists because each data block in a QR Code shares the same the divisor polynomial. */ private: class ReedSolomonGenerator final { /*-- Immutable field --*/ // Coefficients of the divisor polynomial, stored from highest to lowest power, excluding the leading term which // is always 1. For example the polynomial x^3 + 255x^2 + 8x + 93 is stored as the uint8 array {255, 8, 93}. private: std::vector coefficients; /*-- Constructor --*/ /* * Creates a Reed-Solomon ECC generator for the given degree. This could be implemented * as a lookup table over all possible parameter values, instead of as an algorithm. */ public: ReedSolomonGenerator(int degree); /*-- Method --*/ /* * Computes and returns the Reed-Solomon error correction codewords for the given * sequence of data codewords. The returned object is always a new byte array. * This method does not alter this object's state (because it is immutable). */ public: std::vector getRemainder(const std::vector &data) const; /*-- Static function --*/ // Returns the product of the two given field elements modulo GF(2^8/0x11D). // All inputs are valid. This could be implemented as a 256*256 lookup table. private: static std::uint8_t multiply(std::uint8_t x, std::uint8_t y); }; }; } uTox/third_party/qrcodegen/qrcodegen/cpp/QrCode.cpp0000600000175000001440000005015114003056224021411 0ustar rakusers/* * QR Code generator library (C++) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ #include #include #include #include #include #include #include "BitBuffer.hpp" #include "QrCode.hpp" using std::int8_t; using std::uint8_t; using std::size_t; using std::vector; namespace qrcodegen { QrCode::Ecc::Ecc(int ord, int fb) : ordinal(ord), formatBits(fb) {} int QrCode::Ecc::getOrdinal() const { return ordinal; } int QrCode::Ecc::getFormatBits() const { return formatBits; } const QrCode::Ecc QrCode::Ecc::LOW (0, 1); const QrCode::Ecc QrCode::Ecc::MEDIUM (1, 0); const QrCode::Ecc QrCode::Ecc::QUARTILE(2, 3); const QrCode::Ecc QrCode::Ecc::HIGH (3, 2); QrCode QrCode::encodeText(const char *text, Ecc ecl) { vector segs(QrSegment::makeSegments(text)); return encodeSegments(segs, ecl); } QrCode QrCode::encodeBinary(const vector &data, Ecc ecl) { vector segs{QrSegment::makeBytes(data)}; return encodeSegments(segs, ecl); } QrCode QrCode::encodeSegments(const vector &segs, Ecc ecl, int minVersion, int maxVersion, int mask, bool boostEcl) { if (!(MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= MAX_VERSION) || mask < -1 || mask > 7) throw "Invalid value"; // Find the minimal version number to use int version, dataUsedBits; for (version = minVersion; ; version++) { int dataCapacityBits = getNumDataCodewords(version, ecl) * 8; // Number of data bits available dataUsedBits = QrSegment::getTotalBits(segs, version); if (dataUsedBits != -1 && dataUsedBits <= dataCapacityBits) break; // This version number is found to be suitable if (version >= maxVersion) // All versions in the range could not fit the given data throw "Data too long"; } if (dataUsedBits == -1) throw "Assertion error"; // Increase the error correction level while the data still fits in the current version number for (Ecc newEcl : vector{Ecc::MEDIUM, Ecc::QUARTILE, Ecc::HIGH}) { if (boostEcl && dataUsedBits <= getNumDataCodewords(version, newEcl) * 8) ecl = newEcl; } // Create the data bit string by concatenating all segments size_t dataCapacityBits = getNumDataCodewords(version, ecl) * 8; BitBuffer bb; for (const QrSegment &seg : segs) { bb.appendBits(seg.getMode().getModeBits(), 4); bb.appendBits(seg.getNumChars(), seg.getMode().numCharCountBits(version)); bb.insert(bb.end(), seg.getData().begin(), seg.getData().end()); } // Add terminator and pad up to a byte if applicable bb.appendBits(0, std::min(4, dataCapacityBits - bb.size())); bb.appendBits(0, (8 - bb.size() % 8) % 8); // Pad with alternate bytes until data capacity is reached for (uint8_t padByte = 0xEC; bb.size() < dataCapacityBits; padByte ^= 0xEC ^ 0x11) bb.appendBits(padByte, 8); if (bb.size() % 8 != 0) throw "Assertion error"; // Create the QR Code symbol return QrCode(version, ecl, bb.getBytes(), mask); } QrCode::QrCode(int ver, Ecc ecl, const vector &dataCodewords, int mask) : // Initialize fields version(ver), size(MIN_VERSION <= ver && ver <= MAX_VERSION ? ver * 4 + 17 : -1), // Avoid signed overflow undefined behavior errorCorrectionLevel(ecl), modules(size, vector(size)), // Entirely white grid isFunction(size, vector(size)) { // Check arguments if (ver < MIN_VERSION || ver > MAX_VERSION || mask < -1 || mask > 7) throw "Value out of range"; // Draw function patterns, draw all codewords, do masking drawFunctionPatterns(); const vector allCodewords(appendErrorCorrection(dataCodewords)); drawCodewords(allCodewords); this->mask = handleConstructorMasking(mask); } int QrCode::getVersion() const { return version; } int QrCode::getSize() const { return size; } QrCode::Ecc QrCode::getErrorCorrectionLevel() const { return errorCorrectionLevel; } int QrCode::getMask() const { return mask; } bool QrCode::getModule(int x, int y) const { return 0 <= x && x < size && 0 <= y && y < size && module(x, y); } std::string QrCode::toSvgString(int border) const { if (border < 0) throw "Border must be non-negative"; std::ostringstream sb; sb << "\n"; sb << "\n"; sb << "\n"; sb << "\t\n"; sb << "\t\n"; sb << "\n"; return sb.str(); } void QrCode::drawFunctionPatterns() { // Draw horizontal and vertical timing patterns for (int i = 0; i < size; i++) { setFunctionModule(6, i, i % 2 == 0); setFunctionModule(i, 6, i % 2 == 0); } // Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules) drawFinderPattern(3, 3); drawFinderPattern(size - 4, 3); drawFinderPattern(3, size - 4); // Draw numerous alignment patterns const vector alignPatPos(getAlignmentPatternPositions(version)); int numAlign = alignPatPos.size(); for (int i = 0; i < numAlign; i++) { for (int j = 0; j < numAlign; j++) { if ((i == 0 && j == 0) || (i == 0 && j == numAlign - 1) || (i == numAlign - 1 && j == 0)) continue; // Skip the three finder corners else drawAlignmentPattern(alignPatPos.at(i), alignPatPos.at(j)); } } // Draw configuration data drawFormatBits(0); // Dummy mask value; overwritten later in the constructor drawVersion(); } void QrCode::drawFormatBits(int mask) { // Calculate error correction code and pack bits int data = errorCorrectionLevel.getFormatBits() << 3 | mask; // errCorrLvl is uint2, mask is uint3 int rem = data; for (int i = 0; i < 10; i++) rem = (rem << 1) ^ ((rem >> 9) * 0x537); data = data << 10 | rem; data ^= 0x5412; // uint15 if (data >> 15 != 0) throw "Assertion error"; // Draw first copy for (int i = 0; i <= 5; i++) setFunctionModule(8, i, ((data >> i) & 1) != 0); setFunctionModule(8, 7, ((data >> 6) & 1) != 0); setFunctionModule(8, 8, ((data >> 7) & 1) != 0); setFunctionModule(7, 8, ((data >> 8) & 1) != 0); for (int i = 9; i < 15; i++) setFunctionModule(14 - i, 8, ((data >> i) & 1) != 0); // Draw second copy for (int i = 0; i <= 7; i++) setFunctionModule(size - 1 - i, 8, ((data >> i) & 1) != 0); for (int i = 8; i < 15; i++) setFunctionModule(8, size - 15 + i, ((data >> i) & 1) != 0); setFunctionModule(8, size - 8, true); } void QrCode::drawVersion() { if (version < 7) return; // Calculate error correction code and pack bits int rem = version; // version is uint6, in the range [7, 40] for (int i = 0; i < 12; i++) rem = (rem << 1) ^ ((rem >> 11) * 0x1F25); long data = (long)version << 12 | rem; // uint18 if (data >> 18 != 0) throw "Assertion error"; // Draw two copies for (int i = 0; i < 18; i++) { bool bit = ((data >> i) & 1) != 0; int a = size - 11 + i % 3, b = i / 3; setFunctionModule(a, b, bit); setFunctionModule(b, a, bit); } } void QrCode::drawFinderPattern(int x, int y) { for (int i = -4; i <= 4; i++) { for (int j = -4; j <= 4; j++) { int dist = std::max(std::abs(i), std::abs(j)); // Chebyshev/infinity norm int xx = x + j, yy = y + i; if (0 <= xx && xx < size && 0 <= yy && yy < size) setFunctionModule(xx, yy, dist != 2 && dist != 4); } } } void QrCode::drawAlignmentPattern(int x, int y) { for (int i = -2; i <= 2; i++) { for (int j = -2; j <= 2; j++) setFunctionModule(x + j, y + i, std::max(std::abs(i), std::abs(j)) != 1); } } void QrCode::setFunctionModule(int x, int y, bool isBlack) { modules.at(y).at(x) = isBlack; isFunction.at(y).at(x) = true; } bool QrCode::module(int x, int y) const { return modules.at(y).at(x); } vector QrCode::appendErrorCorrection(const vector &data) const { if (data.size() != static_cast(getNumDataCodewords(version, errorCorrectionLevel))) throw "Invalid argument"; // Calculate parameter numbers int numBlocks = NUM_ERROR_CORRECTION_BLOCKS[errorCorrectionLevel.getOrdinal()][version]; int blockEccLen = ECC_CODEWORDS_PER_BLOCK[errorCorrectionLevel.getOrdinal()][version]; int rawCodewords = getNumRawDataModules(version) / 8; int numShortBlocks = numBlocks - rawCodewords % numBlocks; int shortBlockLen = rawCodewords / numBlocks; // Split data into blocks and append ECC to each block vector > blocks; const ReedSolomonGenerator rs(blockEccLen); for (int i = 0, k = 0; i < numBlocks; i++) { vector dat(data.cbegin() + k, data.cbegin() + (k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1))); k += dat.size(); const vector ecc(rs.getRemainder(dat)); if (i < numShortBlocks) dat.push_back(0); dat.insert(dat.end(), ecc.cbegin(), ecc.cend()); blocks.push_back(std::move(dat)); } // Interleave (not concatenate) the bytes from every block into a single sequence vector result; for (int i = 0; static_cast(i) < blocks.at(0).size(); i++) { for (int j = 0; static_cast(j) < blocks.size(); j++) { // Skip the padding byte in short blocks if (i != shortBlockLen - blockEccLen || j >= numShortBlocks) result.push_back(blocks.at(j).at(i)); } } if (result.size() != static_cast(rawCodewords)) throw "Assertion error"; return result; } void QrCode::drawCodewords(const vector &data) { if (data.size() != static_cast(getNumRawDataModules(version) / 8)) throw "Invalid argument"; size_t i = 0; // Bit index into the data // Do the funny zigzag scan for (int right = size - 1; right >= 1; right -= 2) { // Index of right column in each column pair if (right == 6) right = 5; for (int vert = 0; vert < size; vert++) { // Vertical counter for (int j = 0; j < 2; j++) { int x = right - j; // Actual x coordinate bool upward = ((right + 1) & 2) == 0; int y = upward ? size - 1 - vert : vert; // Actual y coordinate if (!isFunction.at(y).at(x) && i < data.size() * 8) { modules.at(y).at(x) = ((data.at(i >> 3) >> (7 - (i & 7))) & 1) != 0; i++; } // If there are any remainder bits (0 to 7), they are already // set to 0/false/white when the grid of modules was initialized } } } if (static_cast(i) != data.size() * 8) throw "Assertion error"; } void QrCode::applyMask(int mask) { if (mask < 0 || mask > 7) throw "Mask value out of range"; for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) { bool invert; switch (mask) { case 0: invert = (x + y) % 2 == 0; break; case 1: invert = y % 2 == 0; break; case 2: invert = x % 3 == 0; break; case 3: invert = (x + y) % 3 == 0; break; case 4: invert = (x / 3 + y / 2) % 2 == 0; break; case 5: invert = x * y % 2 + x * y % 3 == 0; break; case 6: invert = (x * y % 2 + x * y % 3) % 2 == 0; break; case 7: invert = ((x + y) % 2 + x * y % 3) % 2 == 0; break; default: throw "Assertion error"; } modules.at(y).at(x) = modules.at(y).at(x) ^ (invert & !isFunction.at(y).at(x)); } } } int QrCode::handleConstructorMasking(int mask) { if (mask == -1) { // Automatically choose best mask long minPenalty = LONG_MAX; for (int i = 0; i < 8; i++) { drawFormatBits(i); applyMask(i); long penalty = getPenaltyScore(); if (penalty < minPenalty) { mask = i; minPenalty = penalty; } applyMask(i); // Undoes the mask due to XOR } } if (mask < 0 || mask > 7) throw "Assertion error"; drawFormatBits(mask); // Overwrite old format bits applyMask(mask); // Apply the final choice of mask return mask; // The caller shall assign this value to the final-declared field } long QrCode::getPenaltyScore() const { long result = 0; // Adjacent modules in row having same color for (int y = 0; y < size; y++) { bool colorX; for (int x = 0, runX; x < size; x++) { if (x == 0 || module(x, y) != colorX) { colorX = module(x, y); runX = 1; } else { runX++; if (runX == 5) result += PENALTY_N1; else if (runX > 5) result++; } } } // Adjacent modules in column having same color for (int x = 0; x < size; x++) { bool colorY; for (int y = 0, runY; y < size; y++) { if (y == 0 || module(x, y) != colorY) { colorY = module(x, y); runY = 1; } else { runY++; if (runY == 5) result += PENALTY_N1; else if (runY > 5) result++; } } } // 2*2 blocks of modules having same color for (int y = 0; y < size - 1; y++) { for (int x = 0; x < size - 1; x++) { bool color = module(x, y); if ( color == module(x + 1, y) && color == module(x, y + 1) && color == module(x + 1, y + 1)) result += PENALTY_N2; } } // Finder-like pattern in rows for (int y = 0; y < size; y++) { for (int x = 0, bits = 0; x < size; x++) { bits = ((bits << 1) & 0x7FF) | (module(x, y) ? 1 : 0); if (x >= 10 && (bits == 0x05D || bits == 0x5D0)) // Needs 11 bits accumulated result += PENALTY_N3; } } // Finder-like pattern in columns for (int x = 0; x < size; x++) { for (int y = 0, bits = 0; y < size; y++) { bits = ((bits << 1) & 0x7FF) | (module(x, y) ? 1 : 0); if (y >= 10 && (bits == 0x05D || bits == 0x5D0)) // Needs 11 bits accumulated result += PENALTY_N3; } } // Balance of black and white modules int black = 0; for (const vector &row : modules) { for (bool color : row) { if (color) black++; } } int total = size * size; // Find smallest k such that (45-5k)% <= dark/total <= (55+5k)% for (int k = 0; black*20L < (9L-k)*total || black*20L > (11L+k)*total; k++) result += PENALTY_N4; return result; } vector QrCode::getAlignmentPatternPositions(int ver) { if (ver < MIN_VERSION || ver > MAX_VERSION) throw "Version number out of range"; else if (ver == 1) return vector(); else { int numAlign = ver / 7 + 2; int step; if (ver != 32) { // ceil((size - 13) / (2*numAlign - 2)) * 2 step = (ver * 4 + numAlign * 2 + 1) / (2 * numAlign - 2) * 2; } else // C-C-C-Combo breaker! step = 26; vector result; for (int i = 0, pos = ver * 4 + 10; i < numAlign - 1; i++, pos -= step) result.insert(result.begin(), pos); result.insert(result.begin(), 6); return result; } } int QrCode::getNumRawDataModules(int ver) { if (ver < MIN_VERSION || ver > MAX_VERSION) throw "Version number out of range"; int result = (16 * ver + 128) * ver + 64; if (ver >= 2) { int numAlign = ver / 7 + 2; result -= (25 * numAlign - 10) * numAlign - 55; if (ver >= 7) result -= 18 * 2; // Subtract version information } return result; } int QrCode::getNumDataCodewords(int ver, Ecc ecl) { if (ver < MIN_VERSION || ver > MAX_VERSION) throw "Version number out of range"; return getNumRawDataModules(ver) / 8 - ECC_CODEWORDS_PER_BLOCK[ecl.getOrdinal()][ver] * NUM_ERROR_CORRECTION_BLOCKS[ecl.getOrdinal()][ver]; } /*---- Tables of constants ----*/ const int QrCode::PENALTY_N1 = 3; const int QrCode::PENALTY_N2 = 3; const int QrCode::PENALTY_N3 = 40; const int QrCode::PENALTY_N4 = 10; const int8_t QrCode::ECC_CODEWORDS_PER_BLOCK[4][41] = { // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level {-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Low {-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28}, // Medium {-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Quartile {-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // High }; const int8_t QrCode::NUM_ERROR_CORRECTION_BLOCKS[4][41] = { // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level {-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25}, // Low {-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49}, // Medium {-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68}, // Quartile {-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81}, // High }; QrCode::ReedSolomonGenerator::ReedSolomonGenerator(int degree) : coefficients() { if (degree < 1 || degree > 255) throw "Degree out of range"; // Start with the monomial x^0 coefficients.resize(degree); coefficients.at(degree - 1) = 1; // Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}), // drop the highest term, and store the rest of the coefficients in order of descending powers. // Note that r = 0x02, which is a generator element of this field GF(2^8/0x11D). uint8_t root = 1; for (int i = 0; i < degree; i++) { // Multiply the current product by (x - r^i) for (size_t j = 0; j < coefficients.size(); j++) { coefficients.at(j) = multiply(coefficients.at(j), root); if (j + 1 < coefficients.size()) coefficients.at(j) ^= coefficients.at(j + 1); } root = multiply(root, 0x02); } } vector QrCode::ReedSolomonGenerator::getRemainder(const vector &data) const { // Compute the remainder by performing polynomial division vector result(coefficients.size()); for (uint8_t b : data) { uint8_t factor = b ^ result.at(0); result.erase(result.begin()); result.push_back(0); for (size_t j = 0; j < result.size(); j++) result.at(j) ^= multiply(coefficients.at(j), factor); } return result; } uint8_t QrCode::ReedSolomonGenerator::multiply(uint8_t x, uint8_t y) { // Russian peasant multiplication int z = 0; for (int i = 7; i >= 0; i--) { z = (z << 1) ^ ((z >> 7) * 0x11D); z ^= ((y >> i) & 1) * x; } if (z >> 8 != 0) throw "Assertion error"; return static_cast(z); } } uTox/third_party/qrcodegen/qrcodegen/cpp/Makefile0000600000175000001440000000412314003056224021166 0ustar rakusers# # Makefile for QR Code generator (C++) # # Copyright (c) Project Nayuki. (MIT License) # https://www.nayuki.io/page/qr-code-generator-library # # 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. # # ---- Configuration options ---- # External/implicit variables: # - CXX: The C++ compiler, such as g++ or clang++. # - CXXFLAGS: Any extra user-specified compiler flags (can be blank). # Mandatory compiler flags CXXFLAGS += -std=c++11 # Diagnostics. Adding '-fsanitize=address' is helpful for most versions of Clang and newer versions of GCC. CXXFLAGS += -Wall -fsanitize=undefined # Optimization level CXXFLAGS += -O1 # ---- Controlling make ---- # Clear default suffix rules .SUFFIXES: # Don't delete object files .SECONDARY: # Stuff concerning goals .DEFAULT_GOAL = all .PHONY: all clean # ---- Targets to build ---- LIBSRC = BitBuffer QrCode QrSegment MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker # Build all binaries all: $(MAINS) # Delete build output clean: rm -f -- $(MAINS) # Executable files %: %.cpp $(LIBSRC:=.cpp) $(LIBSRC:=.hpp) $(CXX) $(CXXFLAGS) -o $@ $< $(LIBSRC:=.cpp) uTox/third_party/qrcodegen/qrcodegen/cpp/BitBuffer.hpp0000600000175000001440000000354714003056224022120 0ustar rakusers/* * QR Code generator library (C++) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ #pragma once #include #include namespace qrcodegen { /* * An appendable sequence of bits (0's and 1's). */ class BitBuffer final : public std::vector { /*---- Constructor ----*/ // Creates an empty bit buffer (length 0). public: BitBuffer(); /*---- Methods ----*/ // Packs this buffer's bits into bytes in big endian, // padding with '0' bit values, and returns the new vector. public: std::vector getBytes() const; // Appends the given number of low bits of the given value // to this sequence. Requires 0 <= val < 2^len. public: void appendBits(std::uint32_t val, int len); }; } uTox/third_party/qrcodegen/qrcodegen/cpp/BitBuffer.cpp0000600000175000001440000000344314003056224022106 0ustar rakusers/* * QR Code generator library (C++) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ #include "BitBuffer.hpp" namespace qrcodegen { BitBuffer::BitBuffer() : std::vector() {} std::vector BitBuffer::getBytes() const { std::vector result(size() / 8 + (size() % 8 == 0 ? 0 : 1)); for (std::size_t i = 0; i < size(); i++) result[i >> 3] |= (*this)[i] ? 1 << (7 - (i & 7)) : 0; return result; } void BitBuffer::appendBits(std::uint32_t val, int len) { if (len < 0 || len > 31 || val >> len != 0) throw "Value out of range"; for (int i = len - 1; i >= 0; i--) // Append bit by bit this->push_back(((val >> i) & 1) != 0); } } uTox/third_party/qrcodegen/qrcodegen/c/0000700000175000001440000000000014003056224017164 5ustar rakusersuTox/third_party/qrcodegen/qrcodegen/c/qrcodegen.h0000600000175000001440000002644314003056224021317 0ustar rakusers/* * QR Code generator library (C) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ #pragma once #include #include #include /*---- Enum and struct types----*/ /* * The error correction level used in a QR Code symbol. */ enum qrcodegen_Ecc { qrcodegen_Ecc_LOW = 0, qrcodegen_Ecc_MEDIUM, qrcodegen_Ecc_QUARTILE, qrcodegen_Ecc_HIGH, }; /* * The mask pattern used in a QR Code symbol. */ enum qrcodegen_Mask { // A special value to tell the QR Code encoder to // automatically select an appropriate mask pattern qrcodegen_Mask_AUTO = -1, // The eight actual mask patterns qrcodegen_Mask_0 = 0, qrcodegen_Mask_1, qrcodegen_Mask_2, qrcodegen_Mask_3, qrcodegen_Mask_4, qrcodegen_Mask_5, qrcodegen_Mask_6, qrcodegen_Mask_7, }; /* * The mode field of a segment. */ enum qrcodegen_Mode { qrcodegen_Mode_NUMERIC, qrcodegen_Mode_ALPHANUMERIC, qrcodegen_Mode_BYTE, qrcodegen_Mode_KANJI, qrcodegen_Mode_ECI, }; /* * A segment of user/application data that a QR Code symbol can convey. * Each segment has a mode, a character count, and character/general data that is * already encoded as a sequence of bits. The maximum allowed bit length is 32767, * because even the largest QR Code (version 40) has only 31329 modules. */ struct qrcodegen_Segment { // The mode indicator for this segment. enum qrcodegen_Mode mode; // The length of this segment's unencoded data. Always in the range [0, 32767]. // For numeric, alphanumeric, and kanji modes, this measures in Unicode code points. // For byte mode, this measures in bytes (raw binary data, text in UTF-8, or other encodings). // For ECI mode, this is always zero. int numChars; // The data bits of this segment, packed in bitwise big endian. // Can be null if the bit length is zero. uint8_t *data; // The number of valid data bits used in the buffer. Requires // 0 <= bitLength <= 32767, and bitLength <= (capacity of data array) * 8. int bitLength; }; /*---- Macro constants and functions ----*/ // The minimum and maximum defined QR Code version numbers for Model 2. #define qrcodegen_VERSION_MIN 1 #define qrcodegen_VERSION_MAX 40 // Calculates the number of bytes needed to store any QR Code up to and including the given version number, // as a compile-time constant. For example, 'uint8_t buffer[qrcodegen_BUFFER_LEN_FOR_VERSION(25)];' // can store any single QR Code from version 1 to 25, inclusive. // Requires qrcodegen_VERSION_MIN <= n <= qrcodegen_VERSION_MAX. #define qrcodegen_BUFFER_LEN_FOR_VERSION(n) ((((n) * 4 + 17) * ((n) * 4 + 17) + 7) / 8 + 1) // The worst-case number of bytes needed to store one QR Code, up to and including // version 40. This value equals 3918, which is just under 4 kilobytes. // Use this more convenient value to avoid calculating tighter memory bounds for buffers. #define qrcodegen_BUFFER_LEN_MAX qrcodegen_BUFFER_LEN_FOR_VERSION(qrcodegen_VERSION_MAX) /*---- Functions to generate QR Codes ----*/ /* * Encodes the given text string to a QR Code symbol, returning true if encoding succeeded. * If the data is too long to fit in any version in the given range * at the given ECC level, then false is returned. * - The input text must be encoded in UTF-8 and contain no NULs. * - The variables ecl and mask must correspond to enum constant values. * - Requires 1 <= minVersion <= maxVersion <= 40. * - The arrays tempBuffer and qrcode must each have a length * of at least qrcodegen_BUFFER_LEN_FOR_VERSION(maxVersion). * - After the function returns, tempBuffer contains no useful data. * - If successful, the resulting QR Code may use numeric, * alphanumeric, or byte mode to encode the text. * - In the most optimistic case, a QR Code at version 40 with low ECC * can hold any UTF-8 string up to 2953 bytes, or any alphanumeric string * up to 4296 characters, or any digit string up to 7089 characters. * These numbers represent the hard upper limit of the QR Code standard. * - Please consult the QR Code specification for information on * data capacities per version, ECC level, and text encoding mode. */ bool qrcodegen_encodeText(const char *text, uint8_t tempBuffer[], uint8_t qrcode[], enum qrcodegen_Ecc ecl, int minVersion, int maxVersion, enum qrcodegen_Mask mask, bool boostEcl); /* * Encodes the given binary data to a QR Code symbol, returning true if encoding succeeded. * If the data is too long to fit in any version in the given range * at the given ECC level, then false is returned. * - The input array range dataAndTemp[0 : dataLen] should normally be * valid UTF-8 text, but is not required by the QR Code standard. * - The variables ecl and mask must correspond to enum constant values. * - Requires 1 <= minVersion <= maxVersion <= 40. * - The arrays dataAndTemp and qrcode must each have a length * of at least qrcodegen_BUFFER_LEN_FOR_VERSION(maxVersion). * - After the function returns, the contents of dataAndTemp may have changed, * and does not represent useful data anymore. * - If successful, the resulting QR Code will use byte mode to encode the data. * - In the most optimistic case, a QR Code at version 40 with low ECC can hold any byte * sequence up to length 2953. This is the hard upper limit of the QR Code standard. * - Please consult the QR Code specification for information on * data capacities per version, ECC level, and text encoding mode. */ bool qrcodegen_encodeBinary(uint8_t dataAndTemp[], size_t dataLen, uint8_t qrcode[], enum qrcodegen_Ecc ecl, int minVersion, int maxVersion, enum qrcodegen_Mask mask, bool boostEcl); /* * Tests whether the given string can be encoded as a segment in alphanumeric mode. */ bool qrcodegen_isAlphanumeric(const char *text); /* * Tests whether the given string can be encoded as a segment in numeric mode. */ bool qrcodegen_isNumeric(const char *text); /* * Returns the number of bytes (uint8_t) needed for the data buffer of a segment * containing the given number of characters using the given mode. Notes: * - Returns SIZE_MAX on failure, i.e. numChars > INT16_MAX or * the number of needed bits exceeds INT16_MAX (i.e. 32767). * - Otherwise, all valid results are in the range [0, ceil(INT16_MAX / 8)], i.e. at most 4096. * - It is okay for the user to allocate more bytes for the buffer than needed. * - For byte mode, numChars measures the number of bytes, not Unicode code points. * - For ECI mode, numChars must be 0, and the worst-case number of bytes is returned. * An actual ECI segment can have shorter data. For non-ECI modes, the result is exact. */ size_t qrcodegen_calcSegmentBufferSize(enum qrcodegen_Mode mode, size_t numChars); /* * Returns a segment representing the given binary data encoded in byte mode. */ struct qrcodegen_Segment qrcodegen_makeBytes(const uint8_t data[], size_t len, uint8_t buf[]); /* * Returns a segment representing the given string of decimal digits encoded in numeric mode. */ struct qrcodegen_Segment qrcodegen_makeNumeric(const char *digits, uint8_t buf[]); /* * Returns a segment representing the given text string encoded in alphanumeric mode. * The characters allowed are: 0 to 9, A to Z (uppercase only), space, * dollar, percent, asterisk, plus, hyphen, period, slash, colon. */ struct qrcodegen_Segment qrcodegen_makeAlphanumeric(const char *text, uint8_t buf[]); /* * Returns a segment representing an Extended Channel Interpretation * (ECI) designator with the given assignment value. */ struct qrcodegen_Segment qrcodegen_makeEci(long assignVal, uint8_t buf[]); /* * Renders a QR Code symbol representing the given data segments at the given error correction * level or higher. The smallest possible QR Code version is automatically chosen for the output. * Returns true if QR Code creation succeeded, or false if the data is too long to fit in any version. * This function allows the user to create a custom sequence of segments that switches * between modes (such as alphanumeric and binary) to encode text more efficiently. * This function is considered to be lower level than simply encoding text or binary data. * To save memory, the segments' data buffers can alias/overlap tempBuffer, and will * result in them being clobbered, but the QR Code output will still be correct. * But the qrcode array must not overlap tempBuffer or any segment's data buffer. */ bool qrcodegen_encodeSegments(const struct qrcodegen_Segment segs[], size_t len, enum qrcodegen_Ecc ecl, uint8_t tempBuffer[], uint8_t qrcode[]); /* * Renders a QR Code symbol representing the given data segments with the given encoding parameters. * Returns true if QR Code creation succeeded, or false if the data is too long to fit in the range of versions. * The smallest possible QR Code version within the given range is automatically chosen for the output. * This function allows the user to create a custom sequence of segments that switches * between modes (such as alphanumeric and binary) to encode text more efficiently. * This function is considered to be lower level than simply encoding text or binary data. * To save memory, the segments' data buffers can alias/overlap tempBuffer, and will * result in them being clobbered, but the QR Code output will still be correct. * But the qrcode array must not overlap tempBuffer or any segment's data buffer. */ bool qrcodegen_encodeSegmentsAdvanced(const struct qrcodegen_Segment segs[], size_t len, enum qrcodegen_Ecc ecl, int minVersion, int maxVersion, int mask, bool boostEcl, uint8_t tempBuffer[], uint8_t qrcode[]); /*---- Functions to extract raw data from QR Codes ----*/ /* * Returns the side length of the given QR Code, assuming that encoding succeeded. * The result is in the range [21, 177]. Note that the length of the array buffer * is related to the side length - every 'uint8_t qrcode[]' must have length at least * qrcodegen_BUFFER_LEN_FOR_VERSION(version), which equals ceil(size^2 / 8 + 1). */ int qrcodegen_getSize(const uint8_t qrcode[]); /* * Returns the color of the module (pixel) at the given coordinates, which is either * false for white or true for black. The top left corner has the coordinates (x=0, y=0). * If the given coordinates are out of bounds, then false (white) is returned. */ bool qrcodegen_getModule(const uint8_t qrcode[], int x, int y); uTox/third_party/qrcodegen/qrcodegen/c/qrcodegen.c0000600000175000001440000011570514003056224021312 0ustar rakusers/* * QR Code generator library (C) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ #include #include #include #include #include "qrcodegen.h" #ifndef QRCODEGEN_TEST #define testable static // Keep functions private #else // Expose private functions #ifndef __cplusplus #define testable #else // Needed for const variables because they are treated as implicitly 'static' in C++ #define testable extern #endif #endif /*---- Forward declarations for private functions ----*/ // Regarding all public and private functions defined in this source file: // - They require all pointer/array arguments to be not null. // - They only read input scalar/array arguments, write to output pointer/array // arguments, and return scalar values; they are "pure" functions. // - They don't read mutable global variables or write to any global variables. // - They don't perform I/O, read the clock, print to console, etc. // - They allocate a small and constant amount of stack memory. // - They don't allocate or free any memory on the heap. // - They don't recurse or mutually recurse. All the code // could be inlined into the top-level public functions. // - They run in at most quadratic time with respect to input arguments. // Most functions run in linear time, and some in constant time. // There are no unbounded loops or non-obvious termination conditions. // - They are completely thread-safe if the caller does not give the // same writable buffer to concurrent calls to these functions. testable void appendBitsToBuffer(unsigned int val, int numBits, uint8_t buffer[], int *bitLen); testable void appendErrorCorrection(uint8_t data[], int version, enum qrcodegen_Ecc ecl, uint8_t result[]); testable int getNumDataCodewords(int version, enum qrcodegen_Ecc ecl); testable int getNumRawDataModules(int version); testable void calcReedSolomonGenerator(int degree, uint8_t result[]); testable void calcReedSolomonRemainder(const uint8_t data[], int dataLen, const uint8_t generator[], int degree, uint8_t result[]); testable uint8_t finiteFieldMultiply(uint8_t x, uint8_t y); testable void initializeFunctionModules(int version, uint8_t qrcode[]); static void drawWhiteFunctionModules(uint8_t qrcode[], int version); static void drawFormatBits(enum qrcodegen_Ecc ecl, enum qrcodegen_Mask mask, uint8_t qrcode[]); testable int getAlignmentPatternPositions(int version, uint8_t result[7]); static void fillRectangle(int left, int top, int width, int height, uint8_t qrcode[]); static void drawCodewords(const uint8_t data[], int dataLen, uint8_t qrcode[]); static void applyMask(const uint8_t functionModules[], uint8_t qrcode[], enum qrcodegen_Mask mask); static long getPenaltyScore(const uint8_t qrcode[]); testable bool getModule(const uint8_t qrcode[], int x, int y); testable void setModule(uint8_t qrcode[], int x, int y, bool isBlack); testable void setModuleBounded(uint8_t qrcode[], int x, int y, bool isBlack); testable int calcSegmentBitLength(enum qrcodegen_Mode mode, size_t numChars); testable int getTotalBits(const struct qrcodegen_Segment segs[], size_t len, int version); static int numCharCountBits(enum qrcodegen_Mode mode, int version); /*---- Private tables of constants ----*/ // For checking text and encoding segments. static const char *ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; // For generating error correction codes. testable const int8_t ECC_CODEWORDS_PER_BLOCK[4][41] = { // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level {-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Low {-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28}, // Medium {-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Quartile {-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // High }; // For generating error correction codes. testable const int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41] = { // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level {-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25}, // Low {-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49}, // Medium {-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68}, // Quartile {-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81}, // High }; // For automatic mask pattern selection. static const int PENALTY_N1 = 3; static const int PENALTY_N2 = 3; static const int PENALTY_N3 = 40; static const int PENALTY_N4 = 10; /*---- High-level QR Code encoding functions ----*/ // Public function - see documentation comment in header file. bool qrcodegen_encodeText(const char *text, uint8_t tempBuffer[], uint8_t qrcode[], enum qrcodegen_Ecc ecl, int minVersion, int maxVersion, enum qrcodegen_Mask mask, bool boostEcl) { size_t textLen = strlen(text); if (textLen == 0) return qrcodegen_encodeSegmentsAdvanced(NULL, 0, ecl, minVersion, maxVersion, mask, boostEcl, tempBuffer, qrcode); size_t bufLen = qrcodegen_BUFFER_LEN_FOR_VERSION(maxVersion); struct qrcodegen_Segment seg; if (qrcodegen_isNumeric(text)) { if (qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_NUMERIC, textLen) > bufLen) goto fail; seg = qrcodegen_makeNumeric(text, tempBuffer); } else if (qrcodegen_isAlphanumeric(text)) { if (qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_ALPHANUMERIC, textLen) > bufLen) goto fail; seg = qrcodegen_makeAlphanumeric(text, tempBuffer); } else { if (textLen > bufLen) goto fail; for (size_t i = 0; i < textLen; i++) tempBuffer[i] = (uint8_t)text[i]; seg.mode = qrcodegen_Mode_BYTE; seg.bitLength = calcSegmentBitLength(seg.mode, textLen); if (seg.bitLength == -1) goto fail; seg.numChars = (int)textLen; seg.data = tempBuffer; } return qrcodegen_encodeSegmentsAdvanced(&seg, 1, ecl, minVersion, maxVersion, mask, boostEcl, tempBuffer, qrcode); fail: qrcode[0] = 0; // Set size to invalid value for safety return false; } // Public function - see documentation comment in header file. bool qrcodegen_encodeBinary(uint8_t dataAndTemp[], size_t dataLen, uint8_t qrcode[], enum qrcodegen_Ecc ecl, int minVersion, int maxVersion, enum qrcodegen_Mask mask, bool boostEcl) { struct qrcodegen_Segment seg; seg.mode = qrcodegen_Mode_BYTE; seg.bitLength = calcSegmentBitLength(seg.mode, dataLen); if (seg.bitLength == -1) { qrcode[0] = 0; // Set size to invalid value for safety return false; } seg.numChars = (int)dataLen; seg.data = dataAndTemp; return qrcodegen_encodeSegmentsAdvanced(&seg, 1, ecl, minVersion, maxVersion, mask, boostEcl, dataAndTemp, qrcode); } // Appends the given sequence of bits to the given byte-based bit buffer, increasing the bit length. testable void appendBitsToBuffer(unsigned int val, int numBits, uint8_t buffer[], int *bitLen) { assert(0 <= numBits && numBits <= 16 && (unsigned long)val >> numBits == 0); for (int i = numBits - 1; i >= 0; i--, (*bitLen)++) buffer[*bitLen >> 3] |= ((val >> i) & 1) << (7 - (*bitLen & 7)); } /*---- Error correction code generation functions ----*/ // Appends error correction bytes to each block of the given data array, then interleaves bytes // from the blocks and stores them in the result array. data[0 : rawCodewords - totalEcc] contains // the input data. data[rawCodewords - totalEcc : rawCodewords] is used as a temporary work area // and will be clobbered by this function. The final answer is stored in result[0 : rawCodewords]. testable void appendErrorCorrection(uint8_t data[], int version, enum qrcodegen_Ecc ecl, uint8_t result[]) { // Calculate parameter numbers assert(0 <= (int)ecl && (int)ecl < 4 && qrcodegen_VERSION_MIN <= version && version <= qrcodegen_VERSION_MAX); int numBlocks = NUM_ERROR_CORRECTION_BLOCKS[(int)ecl][version]; int blockEccLen = ECC_CODEWORDS_PER_BLOCK[(int)ecl][version]; int rawCodewords = getNumRawDataModules(version) / 8; int dataLen = rawCodewords - blockEccLen * numBlocks; int numShortBlocks = numBlocks - rawCodewords % numBlocks; int shortBlockDataLen = rawCodewords / numBlocks - blockEccLen; // Split data into blocks and append ECC after all data uint8_t generator[30]; calcReedSolomonGenerator(blockEccLen, generator); for (int i = 0, j = dataLen, k = 0; i < numBlocks; i++) { int blockLen = shortBlockDataLen; if (i >= numShortBlocks) blockLen++; calcReedSolomonRemainder(&data[k], blockLen, generator, blockEccLen, &data[j]); j += blockEccLen; k += blockLen; } // Interleave (not concatenate) the bytes from every block into a single sequence for (int i = 0, k = 0; i < numBlocks; i++) { for (int j = 0, l = i; j < shortBlockDataLen; j++, k++, l += numBlocks) result[l] = data[k]; if (i >= numShortBlocks) k++; } for (int i = numShortBlocks, k = (numShortBlocks + 1) * shortBlockDataLen, l = numBlocks * shortBlockDataLen; i < numBlocks; i++, k += shortBlockDataLen + 1, l++) result[l] = data[k]; for (int i = 0, k = dataLen; i < numBlocks; i++) { for (int j = 0, l = dataLen + i; j < blockEccLen; j++, k++, l += numBlocks) result[l] = data[k]; } } // Returns the number of 8-bit codewords that can be used for storing data (not ECC), // for the given version number and error correction level. The result is in the range [9, 2956]. testable int getNumDataCodewords(int version, enum qrcodegen_Ecc ecl) { int v = version, e = (int)ecl; assert(0 <= e && e < 4 && qrcodegen_VERSION_MIN <= v && v <= qrcodegen_VERSION_MAX); return getNumRawDataModules(v) / 8 - ECC_CODEWORDS_PER_BLOCK[e][v] * NUM_ERROR_CORRECTION_BLOCKS[e][v]; } // Returns the number of data bits that can be stored in a QR Code of the given version number, after // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8. // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table. testable int getNumRawDataModules(int version) { assert(qrcodegen_VERSION_MIN <= version && version <= qrcodegen_VERSION_MAX); int result = (16 * version + 128) * version + 64; if (version >= 2) { int numAlign = version / 7 + 2; result -= (25 * numAlign - 10) * numAlign - 55; if (version >= 7) result -= 18 * 2; // Subtract version information } return result; } /*---- Reed-Solomon ECC generator functions ----*/ // Calculates the Reed-Solomon generator polynomial of the given degree, storing in result[0 : degree]. testable void calcReedSolomonGenerator(int degree, uint8_t result[]) { // Start with the monomial x^0 assert(1 <= degree && degree <= 30); memset(result, 0, degree * sizeof(result[0])); result[degree - 1] = 1; // Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}), // drop the highest term, and store the rest of the coefficients in order of descending powers. // Note that r = 0x02, which is a generator element of this field GF(2^8/0x11D). uint8_t root = 1; for (int i = 0; i < degree; i++) { // Multiply the current product by (x - r^i) for (int j = 0; j < degree; j++) { result[j] = finiteFieldMultiply(result[j], root); if (j + 1 < degree) result[j] ^= result[j + 1]; } root = finiteFieldMultiply(root, 0x02); } } // Calculates the remainder of the polynomial data[0 : dataLen] when divided by the generator[0 : degree], where all // polynomials are in big endian and the generator has an implicit leading 1 term, storing the result in result[0 : degree]. testable void calcReedSolomonRemainder(const uint8_t data[], int dataLen, const uint8_t generator[], int degree, uint8_t result[]) { // Perform polynomial division assert(1 <= degree && degree <= 30); memset(result, 0, degree * sizeof(result[0])); for (int i = 0; i < dataLen; i++) { uint8_t factor = data[i] ^ result[0]; memmove(&result[0], &result[1], (degree - 1) * sizeof(result[0])); result[degree - 1] = 0; for (int j = 0; j < degree; j++) result[j] ^= finiteFieldMultiply(generator[j], factor); } } // Returns the product of the two given field elements modulo GF(2^8/0x11D). // All inputs are valid. This could be implemented as a 256*256 lookup table. testable uint8_t finiteFieldMultiply(uint8_t x, uint8_t y) { // Russian peasant multiplication uint8_t z = 0; for (int i = 7; i >= 0; i--) { z = (z << 1) ^ ((z >> 7) * 0x11D); z ^= ((y >> i) & 1) * x; } return z; } /*---- Drawing function modules ----*/ // Clears the given QR Code grid with white modules for the given // version's size, then marks every function module as black. testable void initializeFunctionModules(int version, uint8_t qrcode[]) { // Initialize QR Code int qrsize = version * 4 + 17; memset(qrcode, 0, ((qrsize * qrsize + 7) / 8 + 1) * sizeof(qrcode[0])); qrcode[0] = (uint8_t)qrsize; // Fill horizontal and vertical timing patterns fillRectangle(6, 0, 1, qrsize, qrcode); fillRectangle(0, 6, qrsize, 1, qrcode); // Fill 3 finder patterns (all corners except bottom right) and format bits fillRectangle(0, 0, 9, 9, qrcode); fillRectangle(qrsize - 8, 0, 8, 9, qrcode); fillRectangle(0, qrsize - 8, 9, 8, qrcode); // Fill numerous alignment patterns uint8_t alignPatPos[7] = {0}; int numAlign = getAlignmentPatternPositions(version, alignPatPos); for (int i = 0; i < numAlign; i++) { for (int j = 0; j < numAlign; j++) { if ((i == 0 && j == 0) || (i == 0 && j == numAlign - 1) || (i == numAlign - 1 && j == 0)) continue; // Skip the three finder corners else fillRectangle(alignPatPos[i] - 2, alignPatPos[j] - 2, 5, 5, qrcode); } } // Fill version blocks if (version >= 7) { fillRectangle(qrsize - 11, 0, 3, 6, qrcode); fillRectangle(0, qrsize - 11, 6, 3, qrcode); } } // Draws white function modules and possibly some black modules onto the given QR Code, without changing // non-function modules. This does not draw the format bits. This requires all function modules to be previously // marked black (namely by initializeFunctionModules()), because this may skip redrawing black function modules. static void drawWhiteFunctionModules(uint8_t qrcode[], int version) { // Draw horizontal and vertical timing patterns int qrsize = qrcodegen_getSize(qrcode); for (int i = 7; i < qrsize - 7; i += 2) { setModule(qrcode, 6, i, false); setModule(qrcode, i, 6, false); } // Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules) for (int i = -4; i <= 4; i++) { for (int j = -4; j <= 4; j++) { int dist = abs(i); if (abs(j) > dist) dist = abs(j); if (dist == 2 || dist == 4) { setModuleBounded(qrcode, 3 + j, 3 + i, false); setModuleBounded(qrcode, qrsize - 4 + j, 3 + i, false); setModuleBounded(qrcode, 3 + j, qrsize - 4 + i, false); } } } // Draw numerous alignment patterns uint8_t alignPatPos[7] = {0}; int numAlign = getAlignmentPatternPositions(version, alignPatPos); for (int i = 0; i < numAlign; i++) { for (int j = 0; j < numAlign; j++) { if ((i == 0 && j == 0) || (i == 0 && j == numAlign - 1) || (i == numAlign - 1 && j == 0)) continue; // Skip the three finder corners else { for (int k = -1; k <= 1; k++) { for (int l = -1; l <= 1; l++) setModule(qrcode, alignPatPos[i] + l, alignPatPos[j] + k, k == 0 && l == 0); } } } } // Draw version blocks if (version >= 7) { // Calculate error correction code and pack bits int rem = version; // version is uint6, in the range [7, 40] for (int i = 0; i < 12; i++) rem = (rem << 1) ^ ((rem >> 11) * 0x1F25); long data = (long)version << 12 | rem; // uint18 assert(data >> 18 == 0); // Draw two copies for (int i = 0; i < 6; i++) { for (int j = 0; j < 3; j++) { int k = qrsize - 11 + j; setModule(qrcode, k, i, (data & 1) != 0); setModule(qrcode, i, k, (data & 1) != 0); data >>= 1; } } } } // Draws two copies of the format bits (with its own error correction code) based // on the given mask and error correction level. This always draws all modules of // the format bits, unlike drawWhiteFunctionModules() which might skip black modules. static void drawFormatBits(enum qrcodegen_Ecc ecl, enum qrcodegen_Mask mask, uint8_t qrcode[]) { // Calculate error correction code and pack bits assert(0 <= (int)mask && (int)mask <= 7); int data = -1; // Dummy value switch (ecl) { case qrcodegen_Ecc_LOW : data = 1; break; case qrcodegen_Ecc_MEDIUM : data = 0; break; case qrcodegen_Ecc_QUARTILE: data = 3; break; case qrcodegen_Ecc_HIGH : data = 2; break; default: assert(false); } data = data << 3 | (int)mask; // ecl-derived value is uint2, mask is uint3 int rem = data; for (int i = 0; i < 10; i++) rem = (rem << 1) ^ ((rem >> 9) * 0x537); data = data << 10 | rem; data ^= 0x5412; // uint15 assert(data >> 15 == 0); // Draw first copy for (int i = 0; i <= 5; i++) setModule(qrcode, 8, i, ((data >> i) & 1) != 0); setModule(qrcode, 8, 7, ((data >> 6) & 1) != 0); setModule(qrcode, 8, 8, ((data >> 7) & 1) != 0); setModule(qrcode, 7, 8, ((data >> 8) & 1) != 0); for (int i = 9; i < 15; i++) setModule(qrcode, 14 - i, 8, ((data >> i) & 1) != 0); // Draw second copy int qrsize = qrcodegen_getSize(qrcode); for (int i = 0; i <= 7; i++) setModule(qrcode, qrsize - 1 - i, 8, ((data >> i) & 1) != 0); for (int i = 8; i < 15; i++) setModule(qrcode, 8, qrsize - 15 + i, ((data >> i) & 1) != 0); setModule(qrcode, 8, qrsize - 8, true); } // Calculates the positions of alignment patterns in ascending order for the given version number, // storing them to the given array and returning an array length in the range [0, 7]. testable int getAlignmentPatternPositions(int version, uint8_t result[7]) { if (version == 1) return 0; int numAlign = version / 7 + 2; int step; if (version != 32) { // ceil((size - 13) / (2*numAlign - 2)) * 2 step = (version * 4 + numAlign * 2 + 1) / (2 * numAlign - 2) * 2; } else // C-C-C-Combo breaker! step = 26; for (int i = numAlign - 1, pos = version * 4 + 10; i >= 1; i--, pos -= step) result[i] = pos; result[0] = 6; return numAlign; } // Sets every pixel in the range [left : left + width] * [top : top + height] to black. static void fillRectangle(int left, int top, int width, int height, uint8_t qrcode[]) { for (int dy = 0; dy < height; dy++) { for (int dx = 0; dx < width; dx++) setModule(qrcode, left + dx, top + dy, true); } } /*---- Drawing data modules and masking ----*/ // Draws the raw codewords (including data and ECC) onto the given QR Code. This requires the initial state of // the QR Code to be black at function modules and white at codeword modules (including unused remainder bits). static void drawCodewords(const uint8_t data[], int dataLen, uint8_t qrcode[]) { int qrsize = qrcodegen_getSize(qrcode); int i = 0; // Bit index into the data // Do the funny zigzag scan for (int right = qrsize - 1; right >= 1; right -= 2) { // Index of right column in each column pair if (right == 6) right = 5; for (int vert = 0; vert < qrsize; vert++) { // Vertical counter for (int j = 0; j < 2; j++) { int x = right - j; // Actual x coordinate bool upward = ((right + 1) & 2) == 0; int y = upward ? qrsize - 1 - vert : vert; // Actual y coordinate if (!getModule(qrcode, x, y) && i < dataLen * 8) { bool black = ((data[i >> 3] >> (7 - (i & 7))) & 1) != 0; setModule(qrcode, x, y, black); i++; } // If there are any remainder bits (0 to 7), they are already // set to 0/false/white when the grid of modules was initialized } } } assert(i == dataLen * 8); } // XORs the data modules in this QR Code with the given mask pattern. Due to XOR's mathematical // properties, calling applyMask(..., m) twice with the same value is equivalent to no change at all. // This means it is possible to apply a mask, undo it, and try another mask. Note that a final // well-formed QR Code symbol needs exactly one mask applied (not zero, not two, etc.). static void applyMask(const uint8_t functionModules[], uint8_t qrcode[], enum qrcodegen_Mask mask) { assert(0 <= (int)mask && (int)mask <= 7); // Disallows qrcodegen_Mask_AUTO int qrsize = qrcodegen_getSize(qrcode); for (int y = 0; y < qrsize; y++) { for (int x = 0; x < qrsize; x++) { if (getModule(functionModules, x, y)) continue; bool invert = false; // Dummy value switch ((int)mask) { case 0: invert = (x + y) % 2 == 0; break; case 1: invert = y % 2 == 0; break; case 2: invert = x % 3 == 0; break; case 3: invert = (x + y) % 3 == 0; break; case 4: invert = (x / 3 + y / 2) % 2 == 0; break; case 5: invert = x * y % 2 + x * y % 3 == 0; break; case 6: invert = (x * y % 2 + x * y % 3) % 2 == 0; break; case 7: invert = ((x + y) % 2 + x * y % 3) % 2 == 0; break; default: assert(false); } bool val = getModule(qrcode, x, y); setModule(qrcode, x, y, val ^ invert); } } } // Calculates and returns the penalty score based on state of the given QR Code's current modules. // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score. static long getPenaltyScore(const uint8_t qrcode[]) { int qrsize = qrcodegen_getSize(qrcode); long result = 0; // Adjacent modules in row having same color for (int y = 0; y < qrsize; y++) { bool colorX; for (int x = 0, runX; x < qrsize; x++) { if (x == 0 || getModule(qrcode, x, y) != colorX) { colorX = getModule(qrcode, x, y); runX = 1; } else { runX++; if (runX == 5) result += PENALTY_N1; else if (runX > 5) result++; } } } // Adjacent modules in column having same color for (int x = 0; x < qrsize; x++) { bool colorY; for (int y = 0, runY; y < qrsize; y++) { if (y == 0 || getModule(qrcode, x, y) != colorY) { colorY = getModule(qrcode, x, y); runY = 1; } else { runY++; if (runY == 5) result += PENALTY_N1; else if (runY > 5) result++; } } } // 2*2 blocks of modules having same color for (int y = 0; y < qrsize - 1; y++) { for (int x = 0; x < qrsize - 1; x++) { bool color = getModule(qrcode, x, y); if ( color == getModule(qrcode, x + 1, y) && color == getModule(qrcode, x, y + 1) && color == getModule(qrcode, x + 1, y + 1)) result += PENALTY_N2; } } // Finder-like pattern in rows for (int y = 0; y < qrsize; y++) { for (int x = 0, bits = 0; x < qrsize; x++) { bits = ((bits << 1) & 0x7FF) | (getModule(qrcode, x, y) ? 1 : 0); if (x >= 10 && (bits == 0x05D || bits == 0x5D0)) // Needs 11 bits accumulated result += PENALTY_N3; } } // Finder-like pattern in columns for (int x = 0; x < qrsize; x++) { for (int y = 0, bits = 0; y < qrsize; y++) { bits = ((bits << 1) & 0x7FF) | (getModule(qrcode, x, y) ? 1 : 0); if (y >= 10 && (bits == 0x05D || bits == 0x5D0)) // Needs 11 bits accumulated result += PENALTY_N3; } } // Balance of black and white modules int black = 0; for (int y = 0; y < qrsize; y++) { for (int x = 0; x < qrsize; x++) { if (getModule(qrcode, x, y)) black++; } } int total = qrsize * qrsize; // Find smallest k such that (45-5k)% <= dark/total <= (55+5k)% for (int k = 0; black*20L < (9L-k)*total || black*20L > (11L+k)*total; k++) result += PENALTY_N4; return result; } /*---- Basic QR Code information ----*/ // Public function - see documentation comment in header file. int qrcodegen_getSize(const uint8_t qrcode[]) { assert(qrcode != NULL); int result = qrcode[0]; assert((qrcodegen_VERSION_MIN * 4 + 17) <= result && result <= (qrcodegen_VERSION_MAX * 4 + 17)); return result; } // Public function - see documentation comment in header file. bool qrcodegen_getModule(const uint8_t qrcode[], int x, int y) { assert(qrcode != NULL); int qrsize = qrcode[0]; return (0 <= x && x < qrsize && 0 <= y && y < qrsize) && getModule(qrcode, x, y); } // Gets the module at the given coordinates, which must be in bounds. testable bool getModule(const uint8_t qrcode[], int x, int y) { int qrsize = qrcode[0]; assert(21 <= qrsize && qrsize <= 177 && 0 <= x && x < qrsize && 0 <= y && y < qrsize); int index = y * qrsize + x; int bitIndex = index & 7; int byteIndex = (index >> 3) + 1; return ((qrcode[byteIndex] >> bitIndex) & 1) != 0; } // Sets the module at the given coordinates, which must be in bounds. testable void setModule(uint8_t qrcode[], int x, int y, bool isBlack) { int qrsize = qrcode[0]; assert(21 <= qrsize && qrsize <= 177 && 0 <= x && x < qrsize && 0 <= y && y < qrsize); int index = y * qrsize + x; int bitIndex = index & 7; int byteIndex = (index >> 3) + 1; if (isBlack) qrcode[byteIndex] |= 1 << bitIndex; else qrcode[byteIndex] &= (1 << bitIndex) ^ 0xFF; } // Sets the module at the given coordinates, doing nothing if out of bounds. testable void setModuleBounded(uint8_t qrcode[], int x, int y, bool isBlack) { int qrsize = qrcode[0]; if (0 <= x && x < qrsize && 0 <= y && y < qrsize) setModule(qrcode, x, y, isBlack); } /*---- Segment handling ----*/ // Public function - see documentation comment in header file. bool qrcodegen_isAlphanumeric(const char *text) { assert(text != NULL); for (; *text != '\0'; text++) { if (strchr(ALPHANUMERIC_CHARSET, *text) == NULL) return false; } return true; } // Public function - see documentation comment in header file. bool qrcodegen_isNumeric(const char *text) { assert(text != NULL); for (; *text != '\0'; text++) { if (*text < '0' || *text > '9') return false; } return true; } // Public function - see documentation comment in header file. size_t qrcodegen_calcSegmentBufferSize(enum qrcodegen_Mode mode, size_t numChars) { int temp = calcSegmentBitLength(mode, numChars); if (temp == -1) return SIZE_MAX; assert(0 <= temp && temp <= INT16_MAX); return ((size_t)temp + 7) / 8; } // Returns the number of data bits needed to represent a segment // containing the given number of characters using the given mode. Notes: // - Returns -1 on failure, i.e. numChars > INT16_MAX or // the number of needed bits exceeds INT16_MAX (i.e. 32767). // - Otherwise, all valid results are in the range [0, INT16_MAX]. // - For byte mode, numChars measures the number of bytes, not Unicode code points. // - For ECI mode, numChars must be 0, and the worst-case number of bits is returned. // An actual ECI segment can have shorter data. For non-ECI modes, the result is exact. testable int calcSegmentBitLength(enum qrcodegen_Mode mode, size_t numChars) { const int LIMIT = INT16_MAX; // Can be configured as high as INT_MAX if (numChars > (unsigned int)LIMIT) return -1; int n = (int)numChars; int result = -2; if (mode == qrcodegen_Mode_NUMERIC) { // n * 3 + ceil(n / 3) if (n > LIMIT / 3) goto overflow; result = n * 3; int temp = n / 3 + (n % 3 == 0 ? 0 : 1); if (temp > LIMIT - result) goto overflow; result += temp; } else if (mode == qrcodegen_Mode_ALPHANUMERIC) { // n * 5 + ceil(n / 2) if (n > LIMIT / 5) goto overflow; result = n * 5; int temp = n / 2 + n % 2; if (temp > LIMIT - result) goto overflow; result += temp; } else if (mode == qrcodegen_Mode_BYTE) { if (n > LIMIT / 8) goto overflow; result = n * 8; } else if (mode == qrcodegen_Mode_KANJI) { if (n > LIMIT / 13) goto overflow; result = n * 13; } else if (mode == qrcodegen_Mode_ECI && numChars == 0) result = 3 * 8; assert(0 <= result && result <= LIMIT); return result; overflow: return -1; } // Public function - see documentation comment in header file. struct qrcodegen_Segment qrcodegen_makeBytes(const uint8_t data[], size_t len, uint8_t buf[]) { assert(data != NULL || len == 0); struct qrcodegen_Segment result; result.mode = qrcodegen_Mode_BYTE; result.bitLength = calcSegmentBitLength(result.mode, len); assert(result.bitLength != -1); result.numChars = (int)len; if (len > 0) memcpy(buf, data, len * sizeof(buf[0])); result.data = buf; return result; } // Public function - see documentation comment in header file. struct qrcodegen_Segment qrcodegen_makeNumeric(const char *digits, uint8_t buf[]) { assert(digits != NULL); struct qrcodegen_Segment result; size_t len = strlen(digits); result.mode = qrcodegen_Mode_NUMERIC; int bitLen = calcSegmentBitLength(result.mode, len); assert(bitLen != -1); result.numChars = (int)len; if (bitLen > 0) memset(buf, 0, ((size_t)bitLen + 7) / 8 * sizeof(buf[0])); result.bitLength = 0; unsigned int accumData = 0; int accumCount = 0; for (; *digits != '\0'; digits++) { char c = *digits; assert('0' <= c && c <= '9'); accumData = accumData * 10 + (c - '0'); accumCount++; if (accumCount == 3) { appendBitsToBuffer(accumData, 10, buf, &result.bitLength); accumData = 0; accumCount = 0; } } if (accumCount > 0) // 1 or 2 digits remaining appendBitsToBuffer(accumData, accumCount * 3 + 1, buf, &result.bitLength); assert(result.bitLength == bitLen); result.data = buf; return result; } // Public function - see documentation comment in header file. struct qrcodegen_Segment qrcodegen_makeAlphanumeric(const char *text, uint8_t buf[]) { assert(text != NULL); struct qrcodegen_Segment result; size_t len = strlen(text); result.mode = qrcodegen_Mode_ALPHANUMERIC; int bitLen = calcSegmentBitLength(result.mode, len); assert(bitLen != -1); result.numChars = (int)len; if (bitLen > 0) memset(buf, 0, ((size_t)bitLen + 7) / 8 * sizeof(buf[0])); result.bitLength = 0; unsigned int accumData = 0; int accumCount = 0; for (; *text != '\0'; text++) { const char *temp = strchr(ALPHANUMERIC_CHARSET, *text); assert(temp != NULL); accumData = accumData * 45 + (temp - ALPHANUMERIC_CHARSET); accumCount++; if (accumCount == 2) { appendBitsToBuffer(accumData, 11, buf, &result.bitLength); accumData = 0; accumCount = 0; } } if (accumCount > 0) // 1 character remaining appendBitsToBuffer(accumData, 6, buf, &result.bitLength); assert(result.bitLength == bitLen); result.data = buf; return result; } // Public function - see documentation comment in header file. struct qrcodegen_Segment qrcodegen_makeEci(long assignVal, uint8_t buf[]) { struct qrcodegen_Segment result; result.mode = qrcodegen_Mode_ECI; result.numChars = 0; result.bitLength = 0; if (0 <= assignVal && assignVal < (1 << 7)) { memset(buf, 0, 1 * sizeof(buf[0])); appendBitsToBuffer(assignVal, 8, buf, &result.bitLength); } else if ((1 << 7) <= assignVal && assignVal < (1 << 14)) { memset(buf, 0, 2 * sizeof(buf[0])); appendBitsToBuffer(2, 2, buf, &result.bitLength); appendBitsToBuffer(assignVal, 14, buf, &result.bitLength); } else if ((1 << 14) <= assignVal && assignVal < 1000000L) { memset(buf, 0, 3 * sizeof(buf[0])); appendBitsToBuffer(6, 3, buf, &result.bitLength); appendBitsToBuffer(assignVal >> 10, 11, buf, &result.bitLength); appendBitsToBuffer(assignVal & 0x3FF, 10, buf, &result.bitLength); } else assert(false); result.data = buf; return result; } // Public function - see documentation comment in header file. bool qrcodegen_encodeSegments(const struct qrcodegen_Segment segs[], size_t len, enum qrcodegen_Ecc ecl, uint8_t tempBuffer[], uint8_t qrcode[]) { return qrcodegen_encodeSegmentsAdvanced(segs, len, ecl, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, -1, true, tempBuffer, qrcode); } // Public function - see documentation comment in header file. bool qrcodegen_encodeSegmentsAdvanced(const struct qrcodegen_Segment segs[], size_t len, enum qrcodegen_Ecc ecl, int minVersion, int maxVersion, int mask, bool boostEcl, uint8_t tempBuffer[], uint8_t qrcode[]) { assert(segs != NULL || len == 0); assert(qrcodegen_VERSION_MIN <= minVersion && minVersion <= maxVersion && maxVersion <= qrcodegen_VERSION_MAX); assert(0 <= (int)ecl && (int)ecl <= 3 && -1 <= (int)mask && (int)mask <= 7); // Find the minimal version number to use int version, dataUsedBits; for (version = minVersion; ; version++) { int dataCapacityBits = getNumDataCodewords(version, ecl) * 8; // Number of data bits available dataUsedBits = getTotalBits(segs, len, version); if (dataUsedBits != -1 && dataUsedBits <= dataCapacityBits) break; // This version number is found to be suitable if (version >= maxVersion) { // All versions in the range could not fit the given data qrcode[0] = 0; // Set size to invalid value for safety return false; } } assert(dataUsedBits != -1); // Increase the error correction level while the data still fits in the current version number for (int i = (int)qrcodegen_Ecc_MEDIUM; i <= (int)qrcodegen_Ecc_HIGH; i++) { if (boostEcl && dataUsedBits <= getNumDataCodewords(version, (enum qrcodegen_Ecc)i) * 8) ecl = (enum qrcodegen_Ecc)i; } // Create the data bit string by concatenating all segments int dataCapacityBits = getNumDataCodewords(version, ecl) * 8; memset(qrcode, 0, qrcodegen_BUFFER_LEN_FOR_VERSION(version) * sizeof(qrcode[0])); int bitLen = 0; for (size_t i = 0; i < len; i++) { const struct qrcodegen_Segment *seg = &segs[i]; unsigned int modeBits = 0; // Dummy value switch (seg->mode) { case qrcodegen_Mode_NUMERIC : modeBits = 0x1; break; case qrcodegen_Mode_ALPHANUMERIC: modeBits = 0x2; break; case qrcodegen_Mode_BYTE : modeBits = 0x4; break; case qrcodegen_Mode_KANJI : modeBits = 0x8; break; case qrcodegen_Mode_ECI : modeBits = 0x7; break; default: assert(false); } appendBitsToBuffer(modeBits, 4, qrcode, &bitLen); appendBitsToBuffer(seg->numChars, numCharCountBits(seg->mode, version), qrcode, &bitLen); for (int j = 0; j < seg->bitLength; j++) appendBitsToBuffer((seg->data[j >> 3] >> (7 - (j & 7))) & 1, 1, qrcode, &bitLen); } // Add terminator and pad up to a byte if applicable int terminatorBits = dataCapacityBits - bitLen; if (terminatorBits > 4) terminatorBits = 4; appendBitsToBuffer(0, terminatorBits, qrcode, &bitLen); appendBitsToBuffer(0, (8 - bitLen % 8) % 8, qrcode, &bitLen); // Pad with alternate bytes until data capacity is reached for (uint8_t padByte = 0xEC; bitLen < dataCapacityBits; padByte ^= 0xEC ^ 0x11) appendBitsToBuffer(padByte, 8, qrcode, &bitLen); assert(bitLen % 8 == 0); // Draw function and data codeword modules appendErrorCorrection(qrcode, version, ecl, tempBuffer); initializeFunctionModules(version, qrcode); drawCodewords(tempBuffer, getNumRawDataModules(version) / 8, qrcode); drawWhiteFunctionModules(qrcode, version); initializeFunctionModules(version, tempBuffer); // Handle masking if (mask == qrcodegen_Mask_AUTO) { // Automatically choose best mask long minPenalty = LONG_MAX; for (int i = 0; i < 8; i++) { drawFormatBits(ecl, (enum qrcodegen_Mask)i, qrcode); applyMask(tempBuffer, qrcode, (enum qrcodegen_Mask)i); long penalty = getPenaltyScore(qrcode); if (penalty < minPenalty) { mask = (enum qrcodegen_Mask)i; minPenalty = penalty; } applyMask(tempBuffer, qrcode, (enum qrcodegen_Mask)i); // Undoes the mask due to XOR } } assert(0 <= (int)mask && (int)mask <= 7); drawFormatBits(ecl, mask, qrcode); applyMask(tempBuffer, qrcode, mask); return true; } // Returns the number of bits needed to encode the given list of segments at the given version. // The result is in the range [0, 32767] if successful. Otherwise, -1 is returned if any segment // has more characters than allowed by that segment's mode's character count field at the version, // or if the actual answer exceeds INT16_MAX. testable int getTotalBits(const struct qrcodegen_Segment segs[], size_t len, int version) { assert(segs != NULL || len == 0); assert(qrcodegen_VERSION_MIN <= version && version <= qrcodegen_VERSION_MAX); int result = 0; for (size_t i = 0; i < len; i++) { int numChars = segs[i].numChars; int bitLength = segs[i].bitLength; assert(0 <= numChars && numChars <= INT16_MAX); assert(0 <= bitLength && bitLength <= INT16_MAX); int ccbits = numCharCountBits(segs[i].mode, version); assert(0 <= ccbits && ccbits <= 16); // Fail if segment length value doesn't fit in the length field's bit-width if (numChars >= (1L << ccbits)) return -1; long temp = 4L + ccbits + bitLength; if (temp > INT16_MAX - result) return -1; result += temp; } assert(0 <= result && result <= INT16_MAX); return result; } // Returns the bit width of the segment character count field for the // given mode at the given version number. The result is in the range [0, 16]. static int numCharCountBits(enum qrcodegen_Mode mode, int version) { assert(qrcodegen_VERSION_MIN <= version && version <= qrcodegen_VERSION_MAX); int i = -1; // Dummy value if ( 1 <= version && version <= 9) i = 0; else if (10 <= version && version <= 26) i = 1; else if (27 <= version && version <= 40) i = 2; else assert(false); switch (mode) { case qrcodegen_Mode_NUMERIC : { static const int temp[] = {10, 12, 14}; return temp[i]; } case qrcodegen_Mode_ALPHANUMERIC: { static const int temp[] = { 9, 11, 13}; return temp[i]; } case qrcodegen_Mode_BYTE : { static const int temp[] = { 8, 16, 16}; return temp[i]; } case qrcodegen_Mode_KANJI : { static const int temp[] = { 8, 10, 12}; return temp[i]; } case qrcodegen_Mode_ECI : return 0; default: assert(false); } return -1; // Dummy value } uTox/third_party/qrcodegen/qrcodegen/c/qrcodegen-worker.c0000600000175000001440000000747714003056224022627 0ustar rakusers/* * QR Code generator test worker (C) * * This program reads data and encoding parameters from standard input and writes * QR Code bitmaps to standard output. The I/O format is one integer per line. * Run with no command line arguments. The program is intended for automated * batch testing of end-to-end functionality of this QR Code generator library. * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ #include #include #include #include #include #include #include "qrcodegen.h" #ifndef __cplusplus #define MALLOC(num, type) malloc((num) * sizeof(type)) #else #define MALLOC(num, type) static_cast(malloc((num) * sizeof(type))) #endif int main(void) { while (true) { // Read data length or exit int length; if (scanf("%d", &length) != 1) return EXIT_FAILURE; if (length == -1) break; // Read data bytes bool isAscii = true; uint8_t *data = MALLOC(length, uint8_t); if (data == NULL) { perror("malloc"); return EXIT_FAILURE; } for (int i = 0; i < length; i++) { int b; if (scanf("%d", &b) != 1) return EXIT_FAILURE; data[i] = (uint8_t)b; isAscii &= 0 < b && b < 128; } // Read encoding parameters int errCorLvl, minVersion, maxVersion, mask, boostEcl; if (scanf("%d %d %d %d %d", &errCorLvl, &minVersion, &maxVersion, &mask, &boostEcl) != 5) return EXIT_FAILURE; // Allocate memory for QR Code int bufferLen = qrcodegen_BUFFER_LEN_FOR_VERSION(maxVersion); uint8_t *qrcode = MALLOC(bufferLen, uint8_t); uint8_t *tempBuffer = MALLOC(bufferLen, uint8_t); if (qrcode == NULL || tempBuffer == NULL) { perror("malloc"); return EXIT_FAILURE; } // Try to make QR Code symbol bool ok; if (isAscii) { char *text = MALLOC(length + 1, char); for (int i = 0; i < length; i++) text[i] = (char)data[i]; text[length] = '\0'; ok = qrcodegen_encodeText(text, tempBuffer, qrcode, (enum qrcodegen_Ecc)errCorLvl, minVersion, maxVersion, (enum qrcodegen_Mask)mask, boostEcl == 1); free(text); } else if (length <= bufferLen) { memcpy(tempBuffer, data, length * sizeof(data[0])); ok = qrcodegen_encodeBinary(tempBuffer, (size_t)length, qrcode, (enum qrcodegen_Ecc)errCorLvl, minVersion, maxVersion, (enum qrcodegen_Mask)mask, boostEcl == 1); } else ok = false; free(data); free(tempBuffer); if (ok) { // Print grid of modules int size = qrcodegen_getSize(qrcode); printf("%d\n", (size - 17) / 4); for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) printf("%d\n", qrcodegen_getModule(qrcode, x, y) ? 1 : 0); } } else printf("-1\n"); free(qrcode); fflush(stdout); } return EXIT_SUCCESS; } uTox/third_party/qrcodegen/qrcodegen/c/qrcodegen-test.c0000600000175000001440000007056114003056224022267 0ustar rakusers/* * QR Code generator test suite (C) * * When compiling this program, the library qrcodegen.c needs QRCODEGEN_TEST * to be defined. Run this command line program with no arguments. * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ #include #include #include #include #include #include #include #include #include #include "qrcodegen.h" #define ARRAY_LENGTH(name) (sizeof(name) / sizeof(name[0])) #ifndef __cplusplus #define MALLOC(num, type) malloc((num) * sizeof(type)) #else #define MALLOC(num, type) static_cast(malloc((num) * sizeof(type))) #endif // Global variables static int numTestCases = 0; // Prototypes of private functions under test extern const int8_t ECC_CODEWORDS_PER_BLOCK[4][41]; extern const int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41]; void appendBitsToBuffer(unsigned int val, int numBits, uint8_t buffer[], int *bitLen); void appendErrorCorrection(uint8_t data[], int version, enum qrcodegen_Ecc ecl, uint8_t result[]); int getNumDataCodewords(int version, enum qrcodegen_Ecc ecl); int getNumRawDataModules(int version); void calcReedSolomonGenerator(int degree, uint8_t result[]); void calcReedSolomonRemainder(const uint8_t data[], int dataLen, const uint8_t generator[], int degree, uint8_t result[]); uint8_t finiteFieldMultiply(uint8_t x, uint8_t y); void initializeFunctionModules(int version, uint8_t qrcode[]); int getAlignmentPatternPositions(int version, uint8_t result[7]); bool getModule(const uint8_t qrcode[], int x, int y); void setModule(uint8_t qrcode[], int x, int y, bool isBlack); void setModuleBounded(uint8_t qrcode[], int x, int y, bool isBlack); int calcSegmentBitLength(enum qrcodegen_Mode mode, size_t numChars); int getTotalBits(const struct qrcodegen_Segment segs[], size_t len, int version); /*---- Test cases ----*/ static void testAppendBitsToBuffer(void) { { uint8_t buf[1] = {0}; int bitLen = 0; appendBitsToBuffer(0, 0, buf, &bitLen); assert(bitLen == 0); assert(buf[0] == 0); appendBitsToBuffer(1, 1, buf, &bitLen); assert(bitLen == 1); assert(buf[0] == 0x80); appendBitsToBuffer(0, 1, buf, &bitLen); assert(bitLen == 2); assert(buf[0] == 0x80); appendBitsToBuffer(5, 3, buf, &bitLen); assert(bitLen == 5); assert(buf[0] == 0xA8); appendBitsToBuffer(6, 3, buf, &bitLen); assert(bitLen == 8); assert(buf[0] == 0xAE); numTestCases++; } { uint8_t buf[6] = {0}; int bitLen = 0; appendBitsToBuffer(16942, 16, buf, &bitLen); assert(bitLen == 16); assert(buf[0] == 0x42 && buf[1] == 0x2E && buf[2] == 0x00 && buf[3] == 0x00 && buf[4] == 0x00 && buf[5] == 0x00); appendBitsToBuffer(10, 7, buf, &bitLen); assert(bitLen == 23); assert(buf[0] == 0x42 && buf[1] == 0x2E && buf[2] == 0x14 && buf[3] == 0x00 && buf[4] == 0x00 && buf[5] == 0x00); appendBitsToBuffer(15, 4, buf, &bitLen); assert(bitLen == 27); assert(buf[0] == 0x42 && buf[1] == 0x2E && buf[2] == 0x15 && buf[3] == 0xE0 && buf[4] == 0x00 && buf[5] == 0x00); appendBitsToBuffer(26664, 15, buf, &bitLen); assert(bitLen == 42); assert(buf[0] == 0x42 && buf[1] == 0x2E && buf[2] == 0x15 && buf[3] == 0xFA && buf[4] == 0x0A && buf[5] == 0x00); numTestCases++; } } // Ported from the Java version of the code. static uint8_t *appendErrorCorrectionReference(const uint8_t *data, int version, enum qrcodegen_Ecc ecl) { // Calculate parameter numbers int numBlocks = NUM_ERROR_CORRECTION_BLOCKS[(int)ecl][version]; int blockEccLen = ECC_CODEWORDS_PER_BLOCK[(int)ecl][version]; int rawCodewords = getNumRawDataModules(version) / 8; int numShortBlocks = numBlocks - rawCodewords % numBlocks; int shortBlockLen = rawCodewords / numBlocks; // Split data into blocks and append ECC to each block uint8_t **blocks = MALLOC(numBlocks, uint8_t*); uint8_t *generator = MALLOC(blockEccLen, uint8_t); calcReedSolomonGenerator(blockEccLen, generator); for (int i = 0, k = 0; i < numBlocks; i++) { uint8_t *block = MALLOC(shortBlockLen + 1, uint8_t); int blockDataLen = shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1); memcpy(block, &data[k], blockDataLen * sizeof(uint8_t)); calcReedSolomonRemainder(&data[k], blockDataLen, generator, blockEccLen, &block[shortBlockLen + 1 - blockEccLen]); k += blockDataLen; blocks[i] = block; } free(generator); // Interleave (not concatenate) the bytes from every block into a single sequence uint8_t *result = MALLOC(rawCodewords, uint8_t); for (int i = 0, k = 0; i < shortBlockLen + 1; i++) { for (int j = 0; j < numBlocks; j++) { // Skip the padding byte in short blocks if (i != shortBlockLen - blockEccLen || j >= numShortBlocks) { result[k] = blocks[j][i]; k++; } } } for (int i = 0; i < numBlocks; i++) free(blocks[i]); free(blocks); return result; } static void testAppendErrorCorrection(void) { for (int version = 1; version <= 40; version++) { for (int ecl = 0; ecl < 4; ecl++) { int dataLen = getNumDataCodewords(version, (enum qrcodegen_Ecc)ecl); uint8_t *pureData = MALLOC(dataLen, uint8_t); for (int i = 0; i < dataLen; i++) pureData[i] = rand() % 256; uint8_t *expectOutput = appendErrorCorrectionReference(pureData, version, (enum qrcodegen_Ecc)ecl); int dataAndEccLen = getNumRawDataModules(version) / 8; uint8_t *paddedData = MALLOC(dataAndEccLen, uint8_t); memcpy(paddedData, pureData, dataLen * sizeof(uint8_t)); uint8_t *actualOutput = MALLOC(dataAndEccLen, uint8_t); appendErrorCorrection(paddedData, version, (enum qrcodegen_Ecc)ecl, actualOutput); assert(memcmp(actualOutput, expectOutput, dataAndEccLen * sizeof(uint8_t)) == 0); free(pureData); free(expectOutput); free(paddedData); free(actualOutput); numTestCases++; } } } static void testGetNumDataCodewords(void) { const int cases[][3] = { { 3, 1, 44}, { 3, 2, 34}, { 3, 3, 26}, { 6, 0, 136}, { 7, 0, 156}, { 9, 0, 232}, { 9, 1, 182}, {12, 3, 158}, {15, 0, 523}, {16, 2, 325}, {19, 3, 341}, {21, 0, 932}, {22, 0, 1006}, {22, 1, 782}, {22, 3, 442}, {24, 0, 1174}, {24, 3, 514}, {28, 0, 1531}, {30, 3, 745}, {32, 3, 845}, {33, 0, 2071}, {33, 3, 901}, {35, 0, 2306}, {35, 1, 1812}, {35, 2, 1286}, {36, 3, 1054}, {37, 3, 1096}, {39, 1, 2216}, {40, 1, 2334}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { const int *tc = cases[i]; assert(getNumDataCodewords(tc[0], (enum qrcodegen_Ecc)tc[1]) == tc[2]); numTestCases++; } } static void testGetNumRawDataModules(void) { const int cases[][2] = { { 1, 208}, { 2, 359}, { 3, 567}, { 6, 1383}, { 7, 1568}, {12, 3728}, {15, 5243}, {18, 7211}, {22, 10068}, {26, 13652}, {32, 19723}, {37, 25568}, {40, 29648}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { const int *tc = cases[i]; assert(getNumRawDataModules(tc[0]) == tc[1]); numTestCases++; } } static void testCalcReedSolomonGenerator(void) { uint8_t generator[30]; calcReedSolomonGenerator(1, generator); assert(generator[0] == 0x01); numTestCases++; calcReedSolomonGenerator(2, generator); assert(generator[0] == 0x03); assert(generator[1] == 0x02); numTestCases++; calcReedSolomonGenerator(5, generator); assert(generator[0] == 0x1F); assert(generator[1] == 0xC6); assert(generator[2] == 0x3F); assert(generator[3] == 0x93); assert(generator[4] == 0x74); numTestCases++; calcReedSolomonGenerator(30, generator); assert(generator[ 0] == 0xD4); assert(generator[ 1] == 0xF6); assert(generator[ 5] == 0xC0); assert(generator[12] == 0x16); assert(generator[13] == 0xD9); assert(generator[20] == 0x12); assert(generator[27] == 0x6A); assert(generator[29] == 0x96); numTestCases++; } static void testCalcReedSolomonRemainder(void) { { uint8_t data[1]; uint8_t generator[3]; uint8_t remainder[ARRAY_LENGTH(generator)]; calcReedSolomonGenerator(ARRAY_LENGTH(generator), generator); calcReedSolomonRemainder(data, 0, generator, ARRAY_LENGTH(generator), remainder); assert(remainder[0] == 0); assert(remainder[1] == 0); assert(remainder[2] == 0); numTestCases++; } { uint8_t data[2] = {0, 1}; uint8_t generator[4]; uint8_t remainder[ARRAY_LENGTH(generator)]; calcReedSolomonGenerator(ARRAY_LENGTH(generator), generator); calcReedSolomonRemainder(data, ARRAY_LENGTH(data), generator, ARRAY_LENGTH(generator), remainder); assert(remainder[0] == generator[0]); assert(remainder[1] == generator[1]); assert(remainder[2] == generator[2]); assert(remainder[3] == generator[3]); numTestCases++; } { uint8_t data[5] = {0x03, 0x3A, 0x60, 0x12, 0xC7}; uint8_t generator[5]; uint8_t remainder[ARRAY_LENGTH(generator)]; calcReedSolomonGenerator(ARRAY_LENGTH(generator), generator); calcReedSolomonRemainder(data, ARRAY_LENGTH(data), generator, ARRAY_LENGTH(generator), remainder); assert(remainder[0] == 0xCB); assert(remainder[1] == 0x36); assert(remainder[2] == 0x16); assert(remainder[3] == 0xFA); assert(remainder[4] == 0x9D); numTestCases++; } { uint8_t data[43] = { 0x38, 0x71, 0xDB, 0xF9, 0xD7, 0x28, 0xF6, 0x8E, 0xFE, 0x5E, 0xE6, 0x7D, 0x7D, 0xB2, 0xA5, 0x58, 0xBC, 0x28, 0x23, 0x53, 0x14, 0xD5, 0x61, 0xC0, 0x20, 0x6C, 0xDE, 0xDE, 0xFC, 0x79, 0xB0, 0x8B, 0x78, 0x6B, 0x49, 0xD0, 0x1A, 0xAD, 0xF3, 0xEF, 0x52, 0x7D, 0x9A, }; uint8_t generator[30]; uint8_t remainder[ARRAY_LENGTH(generator)]; calcReedSolomonGenerator(ARRAY_LENGTH(generator), generator); calcReedSolomonRemainder(data, ARRAY_LENGTH(data), generator, ARRAY_LENGTH(generator), remainder); assert(remainder[ 0] == 0xCE); assert(remainder[ 1] == 0xF0); assert(remainder[ 2] == 0x31); assert(remainder[ 3] == 0xDE); assert(remainder[ 8] == 0xE1); assert(remainder[12] == 0xCA); assert(remainder[17] == 0xE3); assert(remainder[19] == 0x85); assert(remainder[20] == 0x50); assert(remainder[24] == 0xBE); assert(remainder[29] == 0xB3); numTestCases++; } } static void testFiniteFieldMultiply(void) { const uint8_t cases[][3] = { {0x00, 0x00, 0x00}, {0x01, 0x01, 0x01}, {0x02, 0x02, 0x04}, {0x00, 0x6E, 0x00}, {0xB2, 0xDD, 0xE6}, {0x41, 0x11, 0x25}, {0xB0, 0x1F, 0x11}, {0x05, 0x75, 0xBC}, {0x52, 0xB5, 0xAE}, {0xA8, 0x20, 0xA4}, {0x0E, 0x44, 0x9F}, {0xD4, 0x13, 0xA0}, {0x31, 0x10, 0x37}, {0x6C, 0x58, 0xCB}, {0xB6, 0x75, 0x3E}, {0xFF, 0xFF, 0xE2}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { const uint8_t *tc = cases[i]; assert(finiteFieldMultiply(tc[0], tc[1]) == tc[2]); numTestCases++; } } static void testInitializeFunctionModulesEtc(void) { for (int ver = 1; ver <= 40; ver++) { uint8_t *qrcode = MALLOC(qrcodegen_BUFFER_LEN_FOR_VERSION(ver), uint8_t); assert(qrcode != NULL); initializeFunctionModules(ver, qrcode); int size = qrcodegen_getSize(qrcode); if (ver == 1) assert(size == 21); else if (ver == 40) assert(size == 177); else assert(size == ver * 4 + 17); bool hasWhite = false; bool hasBlack = false; for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) { bool color = qrcodegen_getModule(qrcode, x, y); if (color) hasBlack = true; else hasWhite = true; } } assert(hasWhite && hasBlack); free(qrcode); numTestCases++; } } static void testGetAlignmentPatternPositions(void) { const int cases[][9] = { { 1, 0, -1, -1, -1, -1, -1, -1, -1}, { 2, 2, 6, 18, -1, -1, -1, -1, -1}, { 3, 2, 6, 22, -1, -1, -1, -1, -1}, { 6, 2, 6, 34, -1, -1, -1, -1, -1}, { 7, 3, 6, 22, 38, -1, -1, -1, -1}, { 8, 3, 6, 24, 42, -1, -1, -1, -1}, {16, 4, 6, 26, 50, 74, -1, -1, -1}, {25, 5, 6, 32, 58, 84, 110, -1, -1}, {32, 6, 6, 34, 60, 86, 112, 138, -1}, {33, 6, 6, 30, 58, 86, 114, 142, -1}, {39, 7, 6, 26, 54, 82, 110, 138, 166}, {40, 7, 6, 30, 58, 86, 114, 142, 170}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { const int *tc = cases[i]; uint8_t pos[7]; int num = getAlignmentPatternPositions(tc[0], pos); assert(num == tc[1]); for (int j = 0; j < num; j++) assert(pos[j] == tc[2 + j]); numTestCases++; } } static void testGetSetModule(void) { uint8_t qrcode[qrcodegen_BUFFER_LEN_FOR_VERSION(23)]; initializeFunctionModules(23, qrcode); int size = qrcodegen_getSize(qrcode); for (int y = 0; y < size; y++) { // Clear all to white for (int x = 0; x < size; x++) setModule(qrcode, x, y, false); } for (int y = 0; y < size; y++) { // Check all white for (int x = 0; x < size; x++) assert(qrcodegen_getModule(qrcode, x, y) == false); } for (int y = 0; y < size; y++) { // Set all to black for (int x = 0; x < size; x++) setModule(qrcode, x, y, true); } for (int y = 0; y < size; y++) { // Check all black for (int x = 0; x < size; x++) assert(qrcodegen_getModule(qrcode, x, y) == true); } // Set some out of bounds modules to white setModuleBounded(qrcode, -1, -1, false); setModuleBounded(qrcode, -1, 0, false); setModuleBounded(qrcode, 0, -1, false); setModuleBounded(qrcode, size, 5, false); setModuleBounded(qrcode, 72, size, false); setModuleBounded(qrcode, size, size, false); for (int y = 0; y < size; y++) { // Check all black for (int x = 0; x < size; x++) assert(qrcodegen_getModule(qrcode, x, y) == true); } // Set some modules to white setModule(qrcode, 3, 8, false); setModule(qrcode, 61, 49, false); for (int y = 0; y < size; y++) { // Check most black for (int x = 0; x < size; x++) { bool white = (x == 3 && y == 8) || (x == 61 && y == 49); assert(qrcodegen_getModule(qrcode, x, y) != white); } } numTestCases++; } static void testGetSetModuleRandomly(void) { uint8_t qrcode[qrcodegen_BUFFER_LEN_FOR_VERSION(1)]; initializeFunctionModules(1, qrcode); int size = qrcodegen_getSize(qrcode); bool modules[21][21]; for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) modules[y][x] = qrcodegen_getModule(qrcode, x, y); } long trials = 100000; for (long i = 0; i < trials; i++) { int x = rand() % (size * 2) - size / 2; int y = rand() % (size * 2) - size / 2; bool isInBounds = 0 <= x && x < size && 0 <= y && y < size; bool oldColor = isInBounds && modules[y][x]; if (isInBounds) assert(getModule(qrcode, x, y) == oldColor); assert(qrcodegen_getModule(qrcode, x, y) == oldColor); bool newColor = rand() % 2 == 0; if (isInBounds) modules[y][x] = newColor; if (isInBounds && rand() % 2 == 0) setModule(qrcode, x, y, newColor); else setModuleBounded(qrcode, x, y, newColor); } numTestCases++; } static void testIsAlphanumeric(void) { struct TestCase { bool answer; const char *text; }; const struct TestCase cases[] = { {true, ""}, {true, "0"}, {true, "A"}, {false, "a"}, {true, " "}, {true, "."}, {true, "*"}, {false, ","}, {false, "|"}, {false, "@"}, {true, "XYZ"}, {false, "XYZ!"}, {true, "79068"}, {true, "+123 ABC$"}, {false, "\x01"}, {false, "\x7F"}, {false, "\x80"}, {false, "\xC0"}, {false, "\xFF"}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { assert(qrcodegen_isAlphanumeric(cases[i].text) == cases[i].answer); numTestCases++; } } static void testIsNumeric(void) { struct TestCase { bool answer; const char *text; }; const struct TestCase cases[] = { {true, ""}, {true, "0"}, {false, "A"}, {false, "a"}, {false, " "}, {false, "."}, {false, "*"}, {false, ","}, {false, "|"}, {false, "@"}, {false, "XYZ"}, {false, "XYZ!"}, {true, "79068"}, {false, "+123 ABC$"}, {false, "\x01"}, {false, "\x7F"}, {false, "\x80"}, {false, "\xC0"}, {false, "\xFF"}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { assert(qrcodegen_isNumeric(cases[i].text) == cases[i].answer); numTestCases++; } } static void testCalcSegmentBufferSize(void) { { const size_t cases[][2] = { {0, 0}, {1, 1}, {2, 1}, {3, 2}, {4, 2}, {5, 3}, {6, 3}, {1472, 614}, {2097, 874}, {5326, 2220}, {9828, 4095}, {9829, 4096}, {9830, 4096}, {9831, SIZE_MAX}, {9832, SIZE_MAX}, {12000, SIZE_MAX}, {28453, SIZE_MAX}, {55555, SIZE_MAX}, {SIZE_MAX / 6, SIZE_MAX}, {SIZE_MAX / 4, SIZE_MAX}, {SIZE_MAX / 2, SIZE_MAX}, {SIZE_MAX / 1, SIZE_MAX}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { assert(qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_NUMERIC, cases[i][0]) == cases[i][1]); numTestCases++; } } { const size_t cases[][2] = { {0, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 3}, {5, 4}, {6, 5}, {1472, 1012}, {2097, 1442}, {5326, 3662}, {5955, 4095}, {5956, 4095}, {5957, 4096}, {5958, SIZE_MAX}, {5959, SIZE_MAX}, {12000, SIZE_MAX}, {28453, SIZE_MAX}, {55555, SIZE_MAX}, {SIZE_MAX / 10, SIZE_MAX}, {SIZE_MAX / 8, SIZE_MAX}, {SIZE_MAX / 5, SIZE_MAX}, {SIZE_MAX / 2, SIZE_MAX}, {SIZE_MAX / 1, SIZE_MAX}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { assert(qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_ALPHANUMERIC, cases[i][0]) == cases[i][1]); numTestCases++; } } { const size_t cases[][2] = { {0, 0}, {1, 1}, {2, 2}, {3, 3}, {1472, 1472}, {2097, 2097}, {4094, 4094}, {4095, 4095}, {4096, SIZE_MAX}, {4097, SIZE_MAX}, {5957, SIZE_MAX}, {12000, SIZE_MAX}, {28453, SIZE_MAX}, {55555, SIZE_MAX}, {SIZE_MAX / 16 + 1, SIZE_MAX}, {SIZE_MAX / 14, SIZE_MAX}, {SIZE_MAX / 9, SIZE_MAX}, {SIZE_MAX / 7, SIZE_MAX}, {SIZE_MAX / 4, SIZE_MAX}, {SIZE_MAX / 3, SIZE_MAX}, {SIZE_MAX / 2, SIZE_MAX}, {SIZE_MAX / 1, SIZE_MAX}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { assert(qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_BYTE, cases[i][0]) == cases[i][1]); numTestCases++; } } { const size_t cases[][2] = { {0, 0}, {1, 2}, {2, 4}, {3, 5}, {1472, 2392}, {2097, 3408}, {2519, 4094}, {2520, 4095}, {2521, SIZE_MAX}, {5957, SIZE_MAX}, {2522, SIZE_MAX}, {12000, SIZE_MAX}, {28453, SIZE_MAX}, {55555, SIZE_MAX}, {SIZE_MAX / 13 + 1, SIZE_MAX}, {SIZE_MAX / 12, SIZE_MAX}, {SIZE_MAX / 9, SIZE_MAX}, {SIZE_MAX / 4, SIZE_MAX}, {SIZE_MAX / 3, SIZE_MAX}, {SIZE_MAX / 2, SIZE_MAX}, {SIZE_MAX / 1, SIZE_MAX}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { assert(qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_KANJI, cases[i][0]) == cases[i][1]); numTestCases++; } } { assert(qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_ECI, 0) == 3); numTestCases++; } } static void testCalcSegmentBitLength(void) { { const int cases[][2] = { {0, 0}, {1, 4}, {2, 7}, {3, 10}, {4, 14}, {5, 17}, {6, 20}, {1472, 4907}, {2097, 6990}, {5326, 17754}, {9828, 32760}, {9829, 32764}, {9830, 32767}, {9831, -1}, {9832, -1}, {12000, -1}, {28453, -1}, {INT_MAX / 3, -1}, {INT_MAX / 2, -1}, {INT_MAX / 1, -1}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { assert(calcSegmentBitLength(qrcodegen_Mode_NUMERIC, cases[i][0]) == cases[i][1]); numTestCases++; } } { const int cases[][2] = { {0, 0}, {1, 6}, {2, 11}, {3, 17}, {4, 22}, {5, 28}, {6, 33}, {1472, 8096}, {2097, 11534}, {5326, 29293}, {5955, 32753}, {5956, 32758}, {5957, 32764}, {5958, -1}, {5959, -1}, {12000, -1}, {28453, -1}, {INT_MAX / 5, -1}, {INT_MAX / 4, -1}, {INT_MAX / 3, -1}, {INT_MAX / 2, -1}, {INT_MAX / 1, -1}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { assert(calcSegmentBitLength(qrcodegen_Mode_ALPHANUMERIC, cases[i][0]) == cases[i][1]); numTestCases++; } } { const int cases[][2] = { {0, 0}, {1, 8}, {2, 16}, {3, 24}, {1472, 11776}, {2097, 16776}, {4094, 32752}, {4095, 32760}, {4096, -1}, {4097, -1}, {5957, -1}, {12000, -1}, {28453, -1}, {INT_MAX / 8 + 1, -1}, {INT_MAX / 7, -1}, {INT_MAX / 6, -1}, {INT_MAX / 5, -1}, {INT_MAX / 4, -1}, {INT_MAX / 3, -1}, {INT_MAX / 2, -1}, {INT_MAX / 1, -1}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { assert(calcSegmentBitLength(qrcodegen_Mode_BYTE, cases[i][0]) == cases[i][1]); numTestCases++; } } { const int cases[][2] = { {0, 0}, {1, 13}, {2, 26}, {3, 39}, {1472, 19136}, {2097, 27261}, {2519, 32747}, {2520, 32760}, {2521, -1}, {5957, -1}, {2522, -1}, {12000, -1}, {28453, -1}, {INT_MAX / 13 + 1, -1}, {INT_MAX / 12, -1}, {INT_MAX / 9, -1}, {INT_MAX / 4, -1}, {INT_MAX / 3, -1}, {INT_MAX / 2, -1}, {INT_MAX / 1, -1}, }; for (size_t i = 0; i < ARRAY_LENGTH(cases); i++) { assert(calcSegmentBitLength(qrcodegen_Mode_KANJI, cases[i][0]) == cases[i][1]); numTestCases++; } } { assert(calcSegmentBitLength(qrcodegen_Mode_ECI, 0) == 24); numTestCases++; } } static void testMakeBytes(void) { { struct qrcodegen_Segment seg = qrcodegen_makeBytes(NULL, 0, NULL); assert(seg.mode == qrcodegen_Mode_BYTE); assert(seg.numChars == 0); assert(seg.bitLength == 0); numTestCases++; } { const uint8_t data[] = {0x00}; uint8_t buf[1]; struct qrcodegen_Segment seg = qrcodegen_makeBytes(data, 1, buf); assert(seg.numChars == 1); assert(seg.bitLength == 8); assert(seg.data[0] == 0x00); numTestCases++; } { const uint8_t data[] = {0xEF, 0xBB, 0xBF}; uint8_t buf[3]; struct qrcodegen_Segment seg = qrcodegen_makeBytes(data, 3, buf); assert(seg.numChars == 3); assert(seg.bitLength == 24); assert(seg.data[0] == 0xEF); assert(seg.data[1] == 0xBB); assert(seg.data[2] == 0xBF); numTestCases++; } } static void testMakeNumeric(void) { { struct qrcodegen_Segment seg = qrcodegen_makeNumeric("", NULL); assert(seg.mode == qrcodegen_Mode_NUMERIC); assert(seg.numChars == 0); assert(seg.bitLength == 0); numTestCases++; } { uint8_t buf[1]; struct qrcodegen_Segment seg = qrcodegen_makeNumeric("9", buf); assert(seg.numChars == 1); assert(seg.bitLength == 4); assert(seg.data[0] == 0x90); numTestCases++; } { uint8_t buf[1]; struct qrcodegen_Segment seg = qrcodegen_makeNumeric("81", buf); assert(seg.numChars == 2); assert(seg.bitLength == 7); assert(seg.data[0] == 0xA2); numTestCases++; } { uint8_t buf[2]; struct qrcodegen_Segment seg = qrcodegen_makeNumeric("673", buf); assert(seg.numChars == 3); assert(seg.bitLength == 10); assert(seg.data[0] == 0xA8); assert(seg.data[1] == 0x40); numTestCases++; } { uint8_t buf[5]; struct qrcodegen_Segment seg = qrcodegen_makeNumeric("3141592653", buf); assert(seg.numChars == 10); assert(seg.bitLength == 34); assert(seg.data[0] == 0x4E); assert(seg.data[1] == 0x89); assert(seg.data[2] == 0xF4); assert(seg.data[3] == 0x24); assert(seg.data[4] == 0xC0); numTestCases++; } } static void testMakeAlphanumeric(void) { { struct qrcodegen_Segment seg = qrcodegen_makeAlphanumeric("", NULL); assert(seg.mode == qrcodegen_Mode_ALPHANUMERIC); assert(seg.numChars == 0); assert(seg.bitLength == 0); numTestCases++; } { uint8_t buf[1]; struct qrcodegen_Segment seg = qrcodegen_makeAlphanumeric("A", buf); assert(seg.numChars == 1); assert(seg.bitLength == 6); assert(seg.data[0] == 0x28); numTestCases++; } { uint8_t buf[2]; struct qrcodegen_Segment seg = qrcodegen_makeAlphanumeric("%:", buf); assert(seg.numChars == 2); assert(seg.bitLength == 11); assert(seg.data[0] == 0xDB); assert(seg.data[1] == 0x40); numTestCases++; } { uint8_t buf[3]; struct qrcodegen_Segment seg = qrcodegen_makeAlphanumeric("Q R", buf); assert(seg.numChars == 3); assert(seg.bitLength == 17); assert(seg.data[0] == 0x96); assert(seg.data[1] == 0xCD); assert(seg.data[2] == 0x80); numTestCases++; } } static void testMakeEci(void) { { uint8_t buf[1]; struct qrcodegen_Segment seg = qrcodegen_makeEci(127, buf); assert(seg.mode == qrcodegen_Mode_ECI); assert(seg.numChars == 0); assert(seg.bitLength == 8); assert(seg.data[0] == 0x7F); numTestCases++; } { uint8_t buf[2]; struct qrcodegen_Segment seg = qrcodegen_makeEci(10345, buf); assert(seg.numChars == 0); assert(seg.bitLength == 16); assert(seg.data[0] == 0xA8); assert(seg.data[1] == 0x69); numTestCases++; } { uint8_t buf[3]; struct qrcodegen_Segment seg = qrcodegen_makeEci(999999, buf); assert(seg.numChars == 0); assert(seg.bitLength == 24); assert(seg.data[0] == 0xCF); assert(seg.data[1] == 0x42); assert(seg.data[2] == 0x3F); numTestCases++; } } static void testGetTotalBits(void) { { assert(getTotalBits(NULL, 0, 1) == 0); numTestCases++; assert(getTotalBits(NULL, 0, 40) == 0); numTestCases++; } { struct qrcodegen_Segment segs[] = { {qrcodegen_Mode_BYTE, 3, NULL, 24}, }; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 2) == 36); numTestCases++; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 10) == 44); numTestCases++; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 39) == 44); numTestCases++; } { struct qrcodegen_Segment segs[] = { {qrcodegen_Mode_ECI, 0, NULL, 8}, {qrcodegen_Mode_NUMERIC, 7, NULL, 24}, {qrcodegen_Mode_ALPHANUMERIC, 1, NULL, 6}, {qrcodegen_Mode_KANJI, 4, NULL, 52}, }; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 9) == 133); numTestCases++; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 21) == 139); numTestCases++; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 27) == 145); numTestCases++; } { struct qrcodegen_Segment segs[] = { {qrcodegen_Mode_BYTE, 4093, NULL, 32744}, }; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 1) == -1); numTestCases++; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 10) == 32764); numTestCases++; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 27) == 32764); numTestCases++; } { struct qrcodegen_Segment segs[] = { {qrcodegen_Mode_NUMERIC, 2047, NULL, 6824}, {qrcodegen_Mode_NUMERIC, 2047, NULL, 6824}, {qrcodegen_Mode_NUMERIC, 2047, NULL, 6824}, {qrcodegen_Mode_NUMERIC, 2047, NULL, 6824}, {qrcodegen_Mode_NUMERIC, 1617, NULL, 5390}, }; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 1) == -1); numTestCases++; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 10) == 32766); numTestCases++; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 27) == -1); numTestCases++; } { struct qrcodegen_Segment segs[] = { {qrcodegen_Mode_KANJI, 255, NULL, 3315}, {qrcodegen_Mode_KANJI, 255, NULL, 3315}, {qrcodegen_Mode_KANJI, 255, NULL, 3315}, {qrcodegen_Mode_KANJI, 255, NULL, 3315}, {qrcodegen_Mode_KANJI, 255, NULL, 3315}, {qrcodegen_Mode_KANJI, 255, NULL, 3315}, {qrcodegen_Mode_KANJI, 255, NULL, 3315}, {qrcodegen_Mode_KANJI, 255, NULL, 3315}, {qrcodegen_Mode_KANJI, 255, NULL, 3315}, {qrcodegen_Mode_ALPHANUMERIC, 511, NULL, 2811}, }; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 9) == 32767); numTestCases++; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 26) == -1); numTestCases++; assert(getTotalBits(segs, ARRAY_LENGTH(segs), 40) == -1); numTestCases++; } } /*---- Main runner ----*/ int main(void) { srand(time(NULL)); testAppendBitsToBuffer(); testAppendErrorCorrection(); testGetNumDataCodewords(); testGetNumRawDataModules(); testCalcReedSolomonGenerator(); testCalcReedSolomonRemainder(); testFiniteFieldMultiply(); testInitializeFunctionModulesEtc(); testGetAlignmentPatternPositions(); testGetSetModule(); testGetSetModuleRandomly(); testIsAlphanumeric(); testIsNumeric(); testCalcSegmentBufferSize(); testCalcSegmentBitLength(); testMakeBytes(); testMakeNumeric(); testMakeAlphanumeric(); testMakeEci(); testGetTotalBits(); printf("All %d test cases passed\n", numTestCases); return EXIT_SUCCESS; } uTox/third_party/qrcodegen/qrcodegen/c/qrcodegen-demo.c0000600000175000001440000002762514003056224022237 0ustar rakusers/* * QR Code generator demo (C) * * Run this command-line program with no arguments. The program * computes a demonstration QR Codes and print it to the console. * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * 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. */ #include #include #include #include #include #include "qrcodegen.h" // Function prototypes static void doBasicDemo(void); static void doVarietyDemo(void); static void doSegmentDemo(void); static void doMaskDemo(void); static void printQr(const uint8_t qrcode[]); // The main application program. int main(void) { doBasicDemo(); doVarietyDemo(); doSegmentDemo(); doMaskDemo(); return EXIT_SUCCESS; } /*---- Demo suite ----*/ // Creates a single QR Code, then prints it to the console. static void doBasicDemo(void) { const char *text = "Hello, world!"; // User-supplied text enum qrcodegen_Ecc errCorLvl = qrcodegen_Ecc_LOW; // Error correction level // Make and print the QR Code symbol uint8_t qrcode[qrcodegen_BUFFER_LEN_MAX]; uint8_t tempBuffer[qrcodegen_BUFFER_LEN_MAX]; bool ok = qrcodegen_encodeText(text, tempBuffer, qrcode, errCorLvl, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true); if (ok) printQr(qrcode); } // Creates a variety of QR Codes that exercise different features of the library, and prints each one to the console. static void doVarietyDemo(void) { { // Numeric mode encoding (3.33 bits per digit) uint8_t qrcode[qrcodegen_BUFFER_LEN_MAX]; uint8_t tempBuffer[qrcodegen_BUFFER_LEN_MAX]; bool ok = qrcodegen_encodeText("314159265358979323846264338327950288419716939937510", tempBuffer, qrcode, qrcodegen_Ecc_MEDIUM, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true); if (ok) printQr(qrcode); } { // Alphanumeric mode encoding (5.5 bits per character) uint8_t qrcode[qrcodegen_BUFFER_LEN_MAX]; uint8_t tempBuffer[qrcodegen_BUFFER_LEN_MAX]; bool ok = qrcodegen_encodeText("DOLLAR-AMOUNT:$39.87 PERCENTAGE:100.00% OPERATIONS:+-*/", tempBuffer, qrcode, qrcodegen_Ecc_HIGH, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true); if (ok) printQr(qrcode); } { // Unicode text as UTF-8 const char *text = "\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1wa\xE3\x80\x81\xE4\xB8\x96\xE7\x95\x8C\xEF\xBC\x81\x20\xCE\xB1\xCE\xB2\xCE\xB3\xCE\xB4"; uint8_t qrcode[qrcodegen_BUFFER_LEN_MAX]; uint8_t tempBuffer[qrcodegen_BUFFER_LEN_MAX]; bool ok = qrcodegen_encodeText(text, tempBuffer, qrcode, qrcodegen_Ecc_QUARTILE, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true); if (ok) printQr(qrcode); } { // Moderately large QR Code using longer text (from Lewis Carroll's Alice in Wonderland) const char *text = "Alice was beginning to get very tired of sitting by her sister on the bank, " "and of having nothing to do: once or twice she had peeped into the book her sister was reading, " "but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice " "'without pictures or conversations?' So she was considering in her own mind (as well as she could, " "for the hot day made her feel very sleepy and stupid), whether the pleasure of making a " "daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly " "a White Rabbit with pink eyes ran close by her."; uint8_t qrcode[qrcodegen_BUFFER_LEN_MAX]; uint8_t tempBuffer[qrcodegen_BUFFER_LEN_MAX]; bool ok = qrcodegen_encodeText(text, tempBuffer, qrcode, qrcodegen_Ecc_HIGH, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true); if (ok) printQr(qrcode); } } // Creates QR Codes with manually specified segments for better compactness. static void doSegmentDemo(void) { { // Illustration "silver" const char *silver0 = "THE SQUARE ROOT OF 2 IS 1."; const char *silver1 = "41421356237309504880168872420969807856967187537694807317667973799"; uint8_t qrcode[qrcodegen_BUFFER_LEN_MAX]; uint8_t tempBuffer[qrcodegen_BUFFER_LEN_MAX]; bool ok; { char *concat = calloc(strlen(silver0) + strlen(silver1) + 1, sizeof(char)); strcat(concat, silver0); strcat(concat, silver1); ok = qrcodegen_encodeText(concat, tempBuffer, qrcode, qrcodegen_Ecc_LOW, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true); if (ok) printQr(qrcode); free(concat); } { uint8_t *segBuf0 = malloc(qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_ALPHANUMERIC, strlen(silver0)) * sizeof(uint8_t)); uint8_t *segBuf1 = malloc(qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_NUMERIC, strlen(silver1)) * sizeof(uint8_t)); struct qrcodegen_Segment segs[] = { qrcodegen_makeAlphanumeric(silver0, segBuf0), qrcodegen_makeNumeric(silver1, segBuf1), }; ok = qrcodegen_encodeSegments(segs, sizeof(segs) / sizeof(segs[0]), qrcodegen_Ecc_LOW, tempBuffer, qrcode); free(segBuf0); free(segBuf1); if (ok) printQr(qrcode); } } { // Illustration "golden" const char *golden0 = "Golden ratio \xCF\x86 = 1."; const char *golden1 = "6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911374"; const char *golden2 = "......"; uint8_t qrcode[qrcodegen_BUFFER_LEN_MAX]; uint8_t tempBuffer[qrcodegen_BUFFER_LEN_MAX]; bool ok; { char *concat = calloc(strlen(golden0) + strlen(golden1) + strlen(golden2) + 1, sizeof(char)); strcat(concat, golden0); strcat(concat, golden1); strcat(concat, golden2); ok = qrcodegen_encodeText(concat, tempBuffer, qrcode, qrcodegen_Ecc_LOW, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true); if (ok) printQr(qrcode); free(concat); } { uint8_t *bytes = malloc(strlen(golden0) * sizeof(uint8_t)); for (size_t i = 0, len = strlen(golden0); i < len; i++) bytes[i] = (uint8_t)golden0[i]; uint8_t *segBuf0 = malloc(qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_BYTE, strlen(golden0)) * sizeof(uint8_t)); uint8_t *segBuf1 = malloc(qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_NUMERIC, strlen(golden1)) * sizeof(uint8_t)); uint8_t *segBuf2 = malloc(qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_ALPHANUMERIC, strlen(golden2)) * sizeof(uint8_t)); struct qrcodegen_Segment segs[] = { qrcodegen_makeBytes(bytes, strlen(golden0), segBuf0), qrcodegen_makeNumeric(golden1, segBuf1), qrcodegen_makeAlphanumeric(golden2, segBuf2), }; free(bytes); ok = qrcodegen_encodeSegments(segs, sizeof(segs) / sizeof(segs[0]), qrcodegen_Ecc_LOW, tempBuffer, qrcode); free(segBuf0); free(segBuf1); free(segBuf2); if (ok) printQr(qrcode); } } { // Illustration "Madoka": kanji, kana, Greek, Cyrillic, full-width Latin characters uint8_t qrcode[qrcodegen_BUFFER_LEN_MAX]; uint8_t tempBuffer[qrcodegen_BUFFER_LEN_MAX]; bool ok; { const char *madoka = // Encoded in UTF-8 "\xE3\x80\x8C\xE9\xAD\x94\xE6\xB3\x95\xE5" "\xB0\x91\xE5\xA5\xB3\xE3\x81\xBE\xE3\x81" "\xA9\xE3\x81\x8B\xE2\x98\x86\xE3\x83\x9E" "\xE3\x82\xAE\xE3\x82\xAB\xE3\x80\x8D\xE3" "\x81\xA3\xE3\x81\xA6\xE3\x80\x81\xE3\x80" "\x80\xD0\x98\xD0\x90\xD0\x98\xE3\x80\x80" "\xEF\xBD\x84\xEF\xBD\x85\xEF\xBD\x93\xEF" "\xBD\x95\xE3\x80\x80\xCE\xBA\xCE\xB1\xEF" "\xBC\x9F"; ok = qrcodegen_encodeText(madoka, tempBuffer, qrcode, qrcodegen_Ecc_LOW, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true); if (ok) printQr(qrcode); } { const int kanjiChars[] = { // Kanji mode encoding (13 bits per character) 0x0035, 0x1002, 0x0FC0, 0x0AED, 0x0AD7, 0x015C, 0x0147, 0x0129, 0x0059, 0x01BD, 0x018D, 0x018A, 0x0036, 0x0141, 0x0144, 0x0001, 0x0000, 0x0249, 0x0240, 0x0249, 0x0000, 0x0104, 0x0105, 0x0113, 0x0115, 0x0000, 0x0208, 0x01FF, 0x0008, }; size_t len = sizeof(kanjiChars) / sizeof(kanjiChars[0]); uint8_t *segBuf = calloc(qrcodegen_calcSegmentBufferSize(qrcodegen_Mode_KANJI, len), sizeof(uint8_t)); struct qrcodegen_Segment seg; seg.mode = qrcodegen_Mode_KANJI; seg.numChars = len; seg.bitLength = 0; for (size_t i = 0; i < len; i++) { for (int j = 12; j >= 0; j--, seg.bitLength++) segBuf[seg.bitLength >> 3] |= ((kanjiChars[i] >> j) & 1) << (7 - (seg.bitLength & 7)); } seg.data = segBuf; ok = qrcodegen_encodeSegments(&seg, 1, qrcodegen_Ecc_LOW, tempBuffer, qrcode); free(segBuf); if (ok) printQr(qrcode); } } } // Creates QR Codes with the same size and contents but different mask patterns. static void doMaskDemo(void) { { // Project Nayuki URL uint8_t qrcode[qrcodegen_BUFFER_LEN_MAX]; uint8_t tempBuffer[qrcodegen_BUFFER_LEN_MAX]; bool ok; ok = qrcodegen_encodeText("https://www.nayuki.io/", tempBuffer, qrcode, qrcodegen_Ecc_HIGH, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true); if (ok) printQr(qrcode); ok = qrcodegen_encodeText("https://www.nayuki.io/", tempBuffer, qrcode, qrcodegen_Ecc_HIGH, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_3, true); if (ok) printQr(qrcode); } { // Chinese text as UTF-8 const char *text = "\xE7\xB6\xAD\xE5\x9F\xBA\xE7\x99\xBE\xE7\xA7\x91\xEF\xBC\x88\x57\x69\x6B\x69\x70" "\x65\x64\x69\x61\xEF\xBC\x8C\xE8\x81\x86\xE8\x81\xBD\x69\x2F\xCB\x8C\x77\xC9\xAA" "\x6B\xE1\xB5\xBB\xCB\x88\x70\x69\xCB\x90\x64\x69\x2E\xC9\x99\x2F\xEF\xBC\x89\xE6" "\x98\xAF\xE4\xB8\x80\xE5\x80\x8B\xE8\x87\xAA\xE7\x94\xB1\xE5\x85\xA7\xE5\xAE\xB9" "\xE3\x80\x81\xE5\x85\xAC\xE9\x96\x8B\xE7\xB7\xA8\xE8\xBC\xAF\xE4\xB8\x94\xE5\xA4" "\x9A\xE8\xAA\x9E\xE8\xA8\x80\xE7\x9A\x84\xE7\xB6\xB2\xE8\xB7\xAF\xE7\x99\xBE\xE7" "\xA7\x91\xE5\x85\xA8\xE6\x9B\xB8\xE5\x8D\x94\xE4\xBD\x9C\xE8\xA8\x88\xE7\x95\xAB"; uint8_t qrcode[qrcodegen_BUFFER_LEN_MAX]; uint8_t tempBuffer[qrcodegen_BUFFER_LEN_MAX]; bool ok; ok = qrcodegen_encodeText(text, tempBuffer, qrcode, qrcodegen_Ecc_MEDIUM, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_0, true); if (ok) printQr(qrcode); ok = qrcodegen_encodeText(text, tempBuffer, qrcode, qrcodegen_Ecc_MEDIUM, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_1, true); if (ok) printQr(qrcode); ok = qrcodegen_encodeText(text, tempBuffer, qrcode, qrcodegen_Ecc_MEDIUM, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_5, true); if (ok) printQr(qrcode); ok = qrcodegen_encodeText(text, tempBuffer, qrcode, qrcodegen_Ecc_MEDIUM, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_7, true); if (ok) printQr(qrcode); } } /*---- Utilities ----*/ // Prints the given QR Code to the console. static void printQr(const uint8_t qrcode[]) { int size = qrcodegen_getSize(qrcode); int border = 4; for (int y = -border; y < size + border; y++) { for (int x = -border; x < size + border; x++) { fputs((qrcodegen_getModule(qrcode, x, y) ? "##" : " "), stdout); } fputs("\n", stdout); } fputs("\n", stdout); } uTox/third_party/qrcodegen/qrcodegen/c/Makefile0000600000175000001440000000446514003056224020637 0ustar rakusers# # Makefile for QR Code generator (C) # # Copyright (c) Project Nayuki. (MIT License) # https://www.nayuki.io/page/qr-code-generator-library # # 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. # # ---- Configuration options ---- # External/implicit variables: # - CC: The C compiler, such as gcc or clang. # - CFLAGS: Any extra user-specified compiler flags (can be blank). # Mandatory compiler flags CFLAGS += -std=c99 # Diagnostics. Adding '-fsanitize=address' is helpful for most versions of Clang and newer versions of GCC. CFLAGS += -Wall -fsanitize=undefined # Optimization level CFLAGS += -O1 # ---- Controlling make ---- # Clear default suffix rules .SUFFIXES: # Don't delete object files .SECONDARY: # Stuff concerning goals .DEFAULT_GOAL = all .PHONY: all clean # ---- Targets to build ---- LIBSRC = qrcodegen LIBFILE = libqrcodegen.so MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker # Build all binaries all: $(LIBFILE) $(MAINS) # Delete build output clean: rm -f -- $(LIBFILE) $(MAINS) # Shared library $(LIBFILE): $(LIBSRC:=.c) $(LIBSRC:=.h) $(CC) $(CFLAGS) -fPIC -shared -o $@ $(LIBSRC:=.c) # Executable files %: %.c $(LIBFILE) $(CC) $(CFLAGS) -o $@ $^ # Special executable qrcodegen-test: qrcodegen-test.c $(LIBSRC:=.c) $(LIBSRC:=.h) $(CC) $(CFLAGS) -DQRCODEGEN_TEST -o $@ $< $(LIBSRC:=.c) uTox/third_party/qrcodegen/qrcodegen/Readme.markdown0000600000175000001440000001611014003056224021704 0ustar rakusersQR Code generator library ========================= Introduction ------------ This project aims to be the best, clearest QR Code generator library in multiple languages. The primary goals are flexible options and absolute correctness. Secondary goals are compact implementation size and good documentation comments. Home page with live JavaScript demo, extensive descriptions, and competitor comparisons: [https://www.nayuki.io/page/qr-code-generator-library](https://www.nayuki.io/page/qr-code-generator-library) Features -------- Core features: * Available in 6 programming languages, all with nearly equal functionality: Java, JavaScript, Python, C++, C, Rust * Significantly shorter code but more documentation comments compared to competing libraries * Supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard * Output formats: Raw modules/pixels of the QR symbol (all languages), SVG XML string (all languages except C), `BufferedImage` raster bitmap (Java only), HTML5 canvas (JavaScript only) * Encodes numeric and special-alphanumeric text in less space than general text * Open source code under the permissive MIT License Manual parameters: * User can specify minimum and maximum version numbers allowed, then library will automatically choose smallest version in the range that fits the data * User can specify mask pattern manually, otherwise library will automatically evaluate all 8 masks and select the optimal one * User can specify absolute error correction level, or allow the library to boost it if it doesn't increase the version number * User can create a list of data segments manually and add ECI segments (all languages except C) Optional advanced features (Java only): * Encodes Japanese Unicode text in kanji mode to save a lot of space compared to UTF-8 bytes * Computes optimal segment mode switching for text with mixed numeric/alphanumeric/general parts Examples -------- Java language: import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; import io.nayuki.qrcodegen.*; // Simple operation QrCode qr0 = QrCode.encodeText("Hello, world!", QrCode.Ecc.MEDIUM); BufferedImage img = qr0.toImage(4, 10); ImageIO.write(img, "png", new File("qr-code.png")); // Manual operation List segs = QrSegment.makeSegments("3141592653589793238462643383"); QrCode qr1 = QrCode.encodeSegments(segs, QrCode.Ecc.HIGH, 5, 5, 2, false); for (int y = 0; y < qr1.size; y++) { for (int x = 0; x < qr1.size; x++) { (... paint qr1.getModule(x, y) ...) } } JavaScript language: // Name abbreviated for the sake of these examples here var QRC = qrcodegen.QrCode; // Simple operation var qr0 = QRC.encodeText("Hello, world!", QRC.Ecc.MEDIUM); var svg = qr0.toSvgString(4); // Manual operation var segs = qrcodegen.QrSegment.makeSegments("3141592653589793238462643383"); var qr1 = QRC.encodeSegments(segs, QRC.Ecc.HIGH, 5, 5, 2, false); for (var y = 0; y < qr1.size; y++) { for (var x = 0; x < qr1.size; x++) { (... paint qr1.getModule(x, y) ...) } } Python language: from qrcodegen import * # Simple operation qr0 = QrCode.encode_text("Hello, world!", QrCode.Ecc.MEDIUM) svg = qr0.to_svg_str(4) # Manual operation segs = QrSegment.make_segments("3141592653589793238462643383") qr1 = QrCode.encode_segments(segs, QrCode.Ecc.HIGH, 5, 5, 2, False) for y in range(qr1.get_size()): for x in range(qr1.get_size()): (... paint qr1.get_module(x, y) ...) C++ language: #include #include #include "QrCode.hpp" using namespace qrcodegen; // Simple operation QrCode qr0 = QrCode::encodeText("Hello, world!", QrCode::Ecc::MEDIUM); std::string svg = qr0.toSvgString(4); // Manual operation std::vector segs = QrSegment::makeSegments("3141592653589793238462643383"); QrCode qr1 = QrCode::encodeSegments( segs, QrCode::Ecc::HIGH, 5, 5, 2, false); for (int y = 0; y < qr1.size; y++) { for (int x = 0; x < qr1.size; x++) { (... paint qr1.getModule(x, y) ...) } } C language: #include #include #include "qrcodegen.h" // Text data uint8_t qr0[qrcodegen_BUFFER_LEN_MAX]; uint8_t tempBuffer[qrcodegen_BUFFER_LEN_MAX]; bool ok = qrcodegen_encodeText("Hello, world!", tempBuffer, qr0, qrcodegen_Ecc_MEDIUM, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true); if (!ok) return; int size = qrcodegen_getSize(qr0); for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) { (... paint qrcodegen_getModule(qr0, x, y) ...) } } // Binary data uint8_t dataAndTemp[qrcodegen_BUFFER_LEN_FOR_VERSION(7)] = {0xE3, 0x81, 0x82}; uint8_t qr1[qrcodegen_BUFFER_LEN_FOR_VERSION(7)]; ok = qrcodegen_encodeBinary(dataAndTemp, 3, qr1, qrcodegen_Ecc_HIGH, 2, 7, qrcodegen_Mask_4, false); Rust language: extern crate qrcodegen; use qrcodegen::QrCode; use qrcodegen::QrCodeEcc; use qrcodegen::QrSegment; // Simple operation let qr0 = QrCode::encode_text("Hello, world!", QrCodeEcc::Medium).unwrap(); let svg = qr0.to_svg_string(4); // Manual operation let chrs: Vec = "3141592653589793238462643383".chars().collect(); let segs = QrSegment::make_segments(&chrs); let qr1 = QrCode::encode_segments_advanced( &segs, QrCodeEcc::High, 5, 5, Some(2), false).unwrap(); for y in 0 .. qr1.size() { for x in 0 .. qr1.size() { (... paint qr1.get_module(x, y) ...) } } More information about QR Code technology and this library's design can be found on the project home page. License ------- Copyright © 2017 Project Nayuki. (MIT License) [https://www.nayuki.io/page/qr-code-generator-library](https://www.nayuki.io/page/qr-code-generator-library) 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. uTox/third_party/qrcodegen/qrcodegen/.git0000600000175000001440000000007614003056222017531 0ustar rakusersgitdir: ../../../.git/modules/third_party/qrcodegen/qrcodegen uTox/third_party/qrcodegen/CMakeLists.txt0000600000175000001440000000025514003056216017540 0ustar rakusersproject(qrcodegen LANGUAGES C) add_library(${PROJECT_NAME} STATIC qrcodegen/c/qrcodegen.c ) target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC qrcodegen/c ) uTox/third_party/minini/0000700000175000001440000000000014003056216014310 5ustar rakusersuTox/third_party/minini/minini/0000700000175000001440000000000014003056224015572 5ustar rakusersuTox/third_party/minini/minini/doc/0000700000175000001440000000000014003056224016337 5ustar rakusersuTox/third_party/minini/minini/doc/minIni.pdf0000600000175000001440000042700114003056224020263 0ustar rakusers%PDF-1.5 % 23 0 obj <> stream x[K7 W * 4zK{9R%qf쵳[A(>̈ iEp'w' 2%qJ9L2 ŏwJH iSd_',ml,Hr]ǒhZh6%Y/%lڇQ.yd9;PjNdg+<N}*R%Lш S(Oi$O2y'p ∆ճ1AQEaoMl 8vPZZju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H`^$9b -z] \d9$0܎0"&+o!S$YPŵypIals9 };rn<ԹN}6]|Zo>MWt2JNu'~gr5CjNH ^Oz%pd}IksSu%bSd3:^4ͧL8U[1I}^۸C)%`H[IlؙE՛6q&0 EaTO2ȁeem zk *l_ߺ kD2B(x{ jP{qʸ;ՋW䅧vV8,K*vQ zDr6f6k샘H9NkG480n !=rڵOTk؁ &@1Dzq"sћ>N =T%x =z0ڱöc2!N[p/1Kj1Laئ]aZ_Icݦ~ ~a'*H2LLp:Qq"&=3NEҽo?Y_/B|#䗋eh\כɓc=ի o|wwSߦyxij/a.Nyb`_<:EHP -uvġdMr]/Ula bnQE5ZNܝiqˀmAڎSEi;zUڂbk a!LI'ҏY\=&ذ;'6RA%W`6QvƤMuE?t >l 3$uz"U~"C z%&2 34 Qp*Xxu[%\%\K])yh_k`mi;`cױĵۧf>':ۉvb͸ԔUMYեMY5㓲j]/Size 409/W[1 3 2]/Filter/FlateDecode/Length 914>> stream x-Ypw b 8-"IPPB!$KbOX JZ 7WfL%n\9o~}Ϝ>$م;q$SGD&BVf[`$V`DsxP%v43:lPJi"GcJB_q*~g3&485 vU*ru9a@%'$qf1;'*%~WU\]Jq`*A8, 9ߒTJ^y?~%9cfbʶ'~GRkȣp48qJp)#R3*gbD^7i6\f &;|NSU= *>KSqN8ss4Ay8MBC%6h m.X6Whog-Ÿ7` nMXe>[qnX;q=Xxaj x :Ǔx Oc,'F>3.^KxU[x]uq= N{cd{hO|@$쉶Ѷmd #include "minIni.h" class minIni { public: minIni(const wxString& filename) : iniFilename(filename) { } bool getbool(const wxString& Section, const wxString& Key, bool DefValue=false) const { return ini_getbool(Section.utf8_str(), Key.utf8_str(), int(DefValue), iniFilename.utf8_str()) != 0; } long getl(const wxString& Section, const wxString& Key, long DefValue=0) const { return ini_getl(Section.utf8_str(), Key.utf8_str(), DefValue, iniFilename.utf8_str()); } int geti(const wxString& Section, const wxString& Key, int DefValue=0) const { return static_cast(ini_getl(Section.utf8_str(), Key.utf8_str(), (long)DefValue, iniFilename.utf8_str())); } wxString gets(const wxString& Section, const wxString& Key, const wxString& DefValue=wxT("")) const { char buffer[INI_BUFFERSIZE]; ini_gets(Section.utf8_str(), Key.utf8_str(), DefValue.utf8_str(), buffer, INI_BUFFERSIZE, iniFilename.utf8_str()); wxString result = wxString::FromUTF8(buffer); return result; } wxString getsection(int idx) const { char buffer[INI_BUFFERSIZE]; ini_getsection(idx, buffer, INI_BUFFERSIZE, iniFilename.utf8_str()); wxString result = wxString::FromUTF8(buffer); return result; } wxString getkey(const wxString& Section, int idx) const { char buffer[INI_BUFFERSIZE]; ini_getkey(Section.utf8_str(), idx, buffer, INI_BUFFERSIZE, iniFilename.utf8_str()); wxString result = wxString::FromUTF8(buffer); return result; } #if defined INI_REAL INI_REAL getf(const wxString& Section, wxString& Key, INI_REAL DefValue=0) const { return ini_getf(Section.utf8_str(), Key.utf8_str(), DefValue, iniFilename.utf8_str()); } #endif #if ! defined INI_READONLY bool put(const wxString& Section, const wxString& Key, long Value) const { return ini_putl(Section.utf8_str(), Key.utf8_str(), Value, iniFilename.utf8_str()) != 0; } bool put(const wxString& Section, const wxString& Key, int Value) const { return ini_putl(Section.utf8_str(), Key.utf8_str(), (long)Value, iniFilename.utf8_str()) != 0; } bool put(const wxString& Section, const wxString& Key, bool Value) const { return ini_putl(Section.utf8_str(), Key.utf8_str(), (long)Value, iniFilename.utf8_str()) != 0; } bool put(const wxString& Section, const wxString& Key, const wxString& Value) const { return ini_puts(Section.utf8_str(), Key.utf8_str(), Value.utf8_str(), iniFilename.utf8_str()) != 0; } bool put(const wxString& Section, const wxString& Key, const char* Value) const { return ini_puts(Section.utf8_str(), Key.utf8_str(), Value, iniFilename.utf8_str()) != 0; } #if defined INI_REAL bool put(const wxString& Section, const wxString& Key, INI_REAL Value) const { return ini_putf(Section.utf8_str(), Key.utf8_str(), Value, iniFilename.utf8_str()) != 0; } #endif bool del(const wxString& Section, const wxString& Key) const { return ini_puts(Section.utf8_str(), Key.utf8_str(), 0, iniFilename.utf8_str()) != 0; } bool del(const wxString& Section) const { return ini_puts(Section.utf8_str(), 0, 0, iniFilename.utf8_str()) != 0; } #endif private: wxString iniFilename; }; #endif /* WXMININI_H */ uTox/third_party/minini/minini/dev/testplain.ini0000600000175000001440000000006414003056224021056 0ustar rakusersString=noot # trailing commment #comment=3 Val=1 uTox/third_party/minini/minini/dev/test2.cc0000600000175000001440000000351714003056224017730 0ustar rakusers/* gcc -o minIni.o -c minIni.c g++ -o test2.o -c test2.cc g++ -o test2 test2.o minIni.o ./test2 */ #include #include #include using namespace std ; #include "minIni.h" int main(void) { minIni ini("test.ini"); string s; /* string reading */ s = ini.gets( "first", "string" , "aap" ); assert(s == "noot"); s = ini.gets( "second", "string" , "aap" ); assert(s == "mies"); s = ini.gets( "first", "dummy" , "aap" ); assert(s == "aap"); cout << "1. String reading tests passed" << endl ; /* value reading */ long n; n = ini.getl("first", "val", -1 ); assert(n==1); n = ini.getl("second", "val", -1); assert(n==2); n = ini.getl("first", "dummy", -1); assert(n==-1); cout << "2. Value reading tests passed" << endl ; /* string writing */ bool b; b = ini.put("first", "alt", "flagged as \"correct\""); assert(b); s = ini.gets("first", "alt", "aap"); assert(s=="flagged as \"correct\""); b = ini.put("second", "alt", "correct"); assert(b); s = ini.gets("second", "alt", "aap"); assert(s=="correct"); b = ini.put("third", "alt", "correct"); assert(b); s = ini.gets("third", "alt", "aap" ); assert(s=="correct"); cout << "3. String writing tests passed" << endl; /* section/key enumeration */ cout << "4. section/key enumeration; file contents follows" << endl; string section; for (int is = 0; section = ini.getsection(is), section.length() > 0; is++) { cout << " [" << section.c_str() << "]" << endl; for (int ik = 0; s = ini.getkey(section, ik), s.length() > 0; ik++) { cout << "\t" << s.c_str() << endl; } } /* string deletion */ b = ini.del("first", "alt"); assert(b); b = ini.del("second", "alt"); assert(b); b = ini.del("third"); assert(b); cout << "5. string deletion passed " << endl; return 0; } uTox/third_party/minini/minini/dev/test.ini0000600000175000001440000000014114003056224020026 0ustar rakusers[First] String=noot # trailing commment Val=1 [Second] Val = 2 #comment=3 String = mies uTox/third_party/minini/minini/dev/test.c0000600000175000001440000000741314003056224017502 0ustar rakusers/* Simple test program * * gcc -o test test.c minIni.c */ #include #include #include #include "minIni.h" #define sizearray(a) (sizeof(a) / sizeof((a)[0])) const char inifile[] = "test.ini"; const char inifile2[] = "testplain.ini"; int Callback(const char *section, const char *key, const char *value, void *userdata) { (void)userdata; /* this parameter is not used in this example */ printf(" [%s]\t%s=%s\n", section, key, value); return 1; } int main(void) { char str[100]; long n; int s, k; char section[50]; /* string reading */ n = ini_gets("first", "string", "dummy", str, sizearray(str), inifile); assert(n==4 && strcmp(str,"noot")==0); n = ini_gets("second", "string", "dummy", str, sizearray(str), inifile); assert(n==4 && strcmp(str,"mies")==0); n = ini_gets("first", "undefined", "dummy", str, sizearray(str), inifile); assert(n==5 && strcmp(str,"dummy")==0); /* ----- */ n = ini_gets("", "string", "dummy", str, sizearray(str), inifile2); assert(n==4 && strcmp(str,"noot")==0); n = ini_gets(NULL, "string", "dummy", str, sizearray(str), inifile2); assert(n==4 && strcmp(str,"noot")==0); /* ----- */ printf("1. String reading tests passed\n"); /* value reading */ n = ini_getl("first", "val", -1, inifile); assert(n==1); n = ini_getl("second", "val", -1, inifile); assert(n==2); n = ini_getl("first", "undefined", -1, inifile); assert(n==-1); /* ----- */ n = ini_getl(NULL, "val", -1, inifile2); assert(n==1); /* ----- */ printf("2. Value reading tests passed\n"); /* string writing */ n = ini_puts("first", "alt", "flagged as \"correct\"", inifile); assert(n==1); n = ini_gets("first", "alt", "dummy", str, sizearray(str), inifile); assert(n==20 && strcmp(str,"flagged as \"correct\"")==0); /* ----- */ n = ini_puts("second", "alt", "correct", inifile); assert(n==1); n = ini_gets("second", "alt", "dummy", str, sizearray(str), inifile); assert(n==7 && strcmp(str,"correct")==0); /* ----- */ n = ini_puts("third", "test", "correct", inifile); assert(n==1); n = ini_gets("third", "test", "dummy", str, sizearray(str), inifile); assert(n==7 && strcmp(str,"correct")==0); /* ----- */ n = ini_puts("second", "alt", "overwrite", inifile); assert(n==1); n = ini_gets("second", "alt", "dummy", str, sizearray(str), inifile); assert(n==9 && strcmp(str,"overwrite")==0); /* ----- */ n = ini_puts("second", "alt", "123456789", inifile); assert(n==1); n = ini_gets("second", "alt", "dummy", str, sizearray(str), inifile); assert(n==9 && strcmp(str,"123456789")==0); /* ----- */ n = ini_puts(NULL, "alt", "correct", inifile2); assert(n==1); n = ini_gets(NULL, "alt", "dummy", str, sizearray(str), inifile2); assert(n==7 && strcmp(str,"correct")==0); /* ----- */ printf("3. String writing tests passed\n"); /* section/key enumeration */ printf("4. Section/key enumertion, file structure follows\n"); for (s = 0; ini_getsection(s, section, sizearray(section), inifile) > 0; s++) { printf(" [%s]\n", section); for (k = 0; ini_getkey(section, k, str, sizearray(str), inifile) > 0; k++) { printf("\t%s\n", str); } /* for */ } /* for */ /* browsing through the file */ printf("5. browse through all settings, file field list follows\n"); ini_browse(Callback, NULL, inifile); /* string deletion */ n = ini_puts("first", "alt", NULL, inifile); assert(n==1); n = ini_puts("second", "alt", NULL, inifile); assert(n==1); n = ini_puts("third", NULL, NULL, inifile); assert(n==1); /* ----- */ n = ini_puts(NULL, "alt", NULL, inifile2); assert(n==1); printf("6. String deletion tests passed\n"); return 0; } uTox/third_party/minini/minini/dev/minIni.h0000600000175000001440000001347014003056224017753 0ustar rakusers/* minIni - Multi-Platform INI file parser, suitable for embedded systems * * Copyright (c) CompuPhase, 2008-2017 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy * of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * * Version: $Id: minIni.h 53 2015-01-18 13:35:11Z thiadmer.riemersma@gmail.com $ */ #ifndef MININI_H #define MININI_H #include "minGlue.h" #if (defined _UNICODE || defined __UNICODE__ || defined UNICODE) && !defined INI_ANSIONLY #include #define mTCHAR TCHAR #else /* force TCHAR to be "char", but only for minIni */ #define mTCHAR char #endif #if !defined INI_BUFFERSIZE #define INI_BUFFERSIZE 512 #endif #if defined __cplusplus extern "C" { #endif int ini_getbool(const mTCHAR *Section, const mTCHAR *Key, int DefValue, const mTCHAR *Filename); long ini_getl(const mTCHAR *Section, const mTCHAR *Key, long DefValue, const mTCHAR *Filename); int ini_gets(const mTCHAR *Section, const mTCHAR *Key, const mTCHAR *DefValue, mTCHAR *Buffer, int BufferSize, const mTCHAR *Filename); int ini_getsection(int idx, mTCHAR *Buffer, int BufferSize, const mTCHAR *Filename); int ini_getkey(const mTCHAR *Section, int idx, mTCHAR *Buffer, int BufferSize, const mTCHAR *Filename); #if defined INI_REAL INI_REAL ini_getf(const mTCHAR *Section, const mTCHAR *Key, INI_REAL DefValue, const mTCHAR *Filename); #endif #if !defined INI_READONLY int ini_putl(const mTCHAR *Section, const mTCHAR *Key, long Value, const mTCHAR *Filename); int ini_puts(const mTCHAR *Section, const mTCHAR *Key, const mTCHAR *Value, const mTCHAR *Filename); #if defined INI_REAL int ini_putf(const mTCHAR *Section, const mTCHAR *Key, INI_REAL Value, const mTCHAR *Filename); #endif #endif /* INI_READONLY */ #if !defined INI_NOBROWSE typedef int (*INI_CALLBACK)(const mTCHAR *Section, const mTCHAR *Key, const mTCHAR *Value, void *UserData); int ini_browse(INI_CALLBACK Callback, void *UserData, const mTCHAR *Filename); #endif /* INI_NOBROWSE */ #if defined __cplusplus } #endif #if defined __cplusplus #if defined __WXWINDOWS__ #include "wxMinIni.h" #else #include /* The C++ class in minIni.h was contributed by Steven Van Ingelgem. */ class minIni { public: minIni(const std::string& filename) : iniFilename(filename) { } bool getbool(const std::string& Section, const std::string& Key, bool DefValue=false) const { return ini_getbool(Section.c_str(), Key.c_str(), int(DefValue), iniFilename.c_str()) != 0; } long getl(const std::string& Section, const std::string& Key, long DefValue=0) const { return ini_getl(Section.c_str(), Key.c_str(), DefValue, iniFilename.c_str()); } int geti(const std::string& Section, const std::string& Key, int DefValue=0) const { return static_cast(this->getl(Section, Key, long(DefValue))); } std::string gets(const std::string& Section, const std::string& Key, const std::string& DefValue="") const { char buffer[INI_BUFFERSIZE]; ini_gets(Section.c_str(), Key.c_str(), DefValue.c_str(), buffer, INI_BUFFERSIZE, iniFilename.c_str()); return buffer; } std::string getsection(int idx) const { char buffer[INI_BUFFERSIZE]; ini_getsection(idx, buffer, INI_BUFFERSIZE, iniFilename.c_str()); return buffer; } std::string getkey(const std::string& Section, int idx) const { char buffer[INI_BUFFERSIZE]; ini_getkey(Section.c_str(), idx, buffer, INI_BUFFERSIZE, iniFilename.c_str()); return buffer; } #if defined INI_REAL INI_REAL getf(const std::string& Section, const std::string& Key, INI_REAL DefValue=0) const { return ini_getf(Section.c_str(), Key.c_str(), DefValue, iniFilename.c_str()); } #endif #if ! defined INI_READONLY bool put(const std::string& Section, const std::string& Key, long Value) const { return ini_putl(Section.c_str(), Key.c_str(), Value, iniFilename.c_str()) != 0; } bool put(const std::string& Section, const std::string& Key, int Value) const { return ini_putl(Section.c_str(), Key.c_str(), (long)Value, iniFilename.c_str()) != 0; } bool put(const std::string& Section, const std::string& Key, bool Value) const { return ini_putl(Section.c_str(), Key.c_str(), (long)Value, iniFilename.c_str()) != 0; } bool put(const std::string& Section, const std::string& Key, const std::string& Value) const { return ini_puts(Section.c_str(), Key.c_str(), Value.c_str(), iniFilename.c_str()) != 0; } bool put(const std::string& Section, const std::string& Key, const char* Value) const { return ini_puts(Section.c_str(), Key.c_str(), Value, iniFilename.c_str()) != 0; } #if defined INI_REAL bool put(const std::string& Section, const std::string& Key, INI_REAL Value) const { return ini_putf(Section.c_str(), Key.c_str(), Value, iniFilename.c_str()) != 0; } #endif bool del(const std::string& Section, const std::string& Key) const { return ini_puts(Section.c_str(), Key.c_str(), 0, iniFilename.c_str()) != 0; } bool del(const std::string& Section) const { return ini_puts(Section.c_str(), 0, 0, iniFilename.c_str()) != 0; } #endif private: std::string iniFilename; }; #endif /* __WXWINDOWS__ */ #endif /* __cplusplus */ #endif /* MININI_H */ uTox/third_party/minini/minini/dev/minIni.c0000600000175000001440000007404314003056224017751 0ustar rakusers/* minIni - Multi-Platform INI file parser, suitable for embedded systems * * These routines are in part based on the article "Multiplatform .INI Files" * by Joseph J. Graf in the March 1994 issue of Dr. Dobb's Journal. * * Copyright (c) CompuPhase, 2008-2017 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy * of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * * Version: $Id: minIni.c 53 2015-01-18 13:35:11Z thiadmer.riemersma@gmail.com $ */ #if (defined _UNICODE || defined __UNICODE__ || defined UNICODE) && !defined INI_ANSIONLY # if !defined UNICODE /* for Windows */ # define UNICODE # endif # if !defined _UNICODE /* for C library */ # define _UNICODE # endif #endif #define MININI_IMPLEMENTATION #include "minIni.h" #if defined NDEBUG #define assert(e) #else #include #endif #if !defined __T || defined INI_ANSIONLY #include #include #include #define TCHAR char #define __T(s) s #define _tcscat strcat #define _tcschr strchr #define _tcscmp strcmp #define _tcscpy strcpy #define _tcsicmp stricmp #define _tcslen strlen #define _tcsncmp strncmp #define _tcsnicmp strnicmp #define _tcsrchr strrchr #define _tcstol strtol #define _tcstod strtod #define _totupper toupper #define _stprintf sprintf #define _tfgets fgets #define _tfputs fputs #define _tfopen fopen #define _tremove remove #define _trename rename #endif #if defined __linux || defined __linux__ #define __LINUX__ #elif defined FREEBSD && !defined __FreeBSD__ #define __FreeBSD__ #elif defined(_MSC_VER) #pragma warning(disable: 4996) /* for Microsoft Visual C/C++ */ #endif #if !defined strnicmp && !defined PORTABLE_STRNICMP #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ #define strnicmp strncasecmp #endif #endif #if !defined _totupper #define _totupper toupper #endif #if !defined INI_LINETERM #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ #define INI_LINETERM __T("\n") #else #define INI_LINETERM __T("\r\n") #endif #endif #if !defined INI_FILETYPE #error Missing definition for INI_FILETYPE. #endif #if !defined sizearray #define sizearray(a) (sizeof(a) / sizeof((a)[0])) #endif enum quote_option { QUOTE_NONE, QUOTE_ENQUOTE, QUOTE_DEQUOTE, }; #if defined PORTABLE_STRNICMP int strnicmp(const TCHAR *s1, const TCHAR *s2, size_t n) { while (n-- != 0 && (*s1 || *s2)) { register int c1, c2; c1 = *s1++; if ('a' <= c1 && c1 <= 'z') c1 += ('A' - 'a'); c2 = *s2++; if ('a' <= c2 && c2 <= 'z') c2 += ('A' - 'a'); if (c1 != c2) return c1 - c2; } /* while */ return 0; } #endif /* PORTABLE_STRNICMP */ static TCHAR *skipleading(const TCHAR *str) { assert(str != NULL); while ('\0' < *str && *str <= ' ') str++; return (TCHAR *)str; } static TCHAR *skiptrailing(const TCHAR *str, const TCHAR *base) { assert(str != NULL); assert(base != NULL); while (str > base && '\0' < *(str-1) && *(str-1) <= ' ') str--; return (TCHAR *)str; } static TCHAR *striptrailing(TCHAR *str) { TCHAR *ptr = skiptrailing(_tcschr(str, '\0'), str); assert(ptr != NULL); *ptr = '\0'; return str; } static TCHAR *ini_strncpy(TCHAR *dest, const TCHAR *source, size_t maxlen, enum quote_option option) { size_t d, s; assert(maxlen>0); assert(source != NULL && dest != NULL); assert((dest < source || (dest == source && option != QUOTE_ENQUOTE)) || dest > source + strlen(source)); if (option == QUOTE_ENQUOTE && maxlen < 3) option = QUOTE_NONE; /* cannot store two quotes and a terminating zero in less than 3 characters */ switch (option) { case QUOTE_NONE: for (d = 0; d < maxlen - 1 && source[d] != '\0'; d++) dest[d] = source[d]; assert(d < maxlen); dest[d] = '\0'; break; case QUOTE_ENQUOTE: d = 0; dest[d++] = '"'; for (s = 0; source[s] != '\0' && d < maxlen - 2; s++, d++) { if (source[s] == '"') { if (d >= maxlen - 3) break; /* no space to store the escape character plus the one that follows it */ dest[d++] = '\\'; } /* if */ dest[d] = source[s]; } /* for */ dest[d++] = '"'; dest[d] = '\0'; break; case QUOTE_DEQUOTE: for (d = s = 0; source[s] != '\0' && d < maxlen - 1; s++, d++) { if ((source[s] == '"' || source[s] == '\\') && source[s + 1] == '"') s++; dest[d] = source[s]; } /* for */ dest[d] = '\0'; break; default: assert(0); } /* switch */ return dest; } static TCHAR *cleanstring(TCHAR *string, enum quote_option *quotes) { int isstring; TCHAR *ep; assert(string != NULL); assert(quotes != NULL); /* Remove a trailing comment */ isstring = 0; for (ep = string; *ep != '\0' && ((*ep != ';' && *ep != '#') || isstring); ep++) { if (*ep == '"') { if (*(ep + 1) == '"') ep++; /* skip "" (both quotes) */ else isstring = !isstring; /* single quote, toggle isstring */ } else if (*ep == '\\' && *(ep + 1) == '"') { ep++; /* skip \" (both quotes */ } /* if */ } /* for */ assert(ep != NULL && (*ep == '\0' || *ep == ';' || *ep == '#')); *ep = '\0'; /* terminate at a comment */ striptrailing(string); /* Remove double quotes surrounding a value */ *quotes = QUOTE_NONE; if (*string == '"' && (ep = _tcschr(string, '\0')) != NULL && *(ep - 1) == '"') { string++; *--ep = '\0'; *quotes = QUOTE_DEQUOTE; /* this is a string, so remove escaped characters */ } /* if */ return string; } static int getkeystring(INI_FILETYPE *fp, const TCHAR *Section, const TCHAR *Key, int idxSection, int idxKey, TCHAR *Buffer, int BufferSize, INI_FILEPOS *mark) { TCHAR *sp, *ep; int len, idx; enum quote_option quotes; TCHAR LocalBuffer[INI_BUFFERSIZE]; assert(fp != NULL); /* Move through file 1 line at a time until a section is matched or EOF. If * parameter Section is NULL, only look at keys above the first section. If * idxSection is postive, copy the relevant section name. */ len = (Section != NULL) ? (int)_tcslen(Section) : 0; if (len > 0 || idxSection >= 0) { assert(idxSection >= 0 || Section != NULL); idx = -1; do { if (!ini_read(LocalBuffer, INI_BUFFERSIZE, fp)) return 0; sp = skipleading(LocalBuffer); ep = _tcsrchr(sp, ']'); } while (*sp != '[' || ep == NULL || (((int)(ep-sp-1) != len || Section == NULL || _tcsnicmp(sp+1,Section,len) != 0) && ++idx != idxSection)); if (idxSection >= 0) { if (idx == idxSection) { assert(ep != NULL); assert(*ep == ']'); *ep = '\0'; ini_strncpy(Buffer, sp + 1, BufferSize, QUOTE_NONE); return 1; } /* if */ return 0; /* no more section found */ } /* if */ } /* if */ /* Now that the section has been found, find the entry. * Stop searching upon leaving the section's area. */ assert(Key != NULL || idxKey >= 0); len = (Key != NULL) ? (int)_tcslen(Key) : 0; idx = -1; do { if (mark != NULL) ini_tell(fp, mark); /* optionally keep the mark to the start of the line */ if (!ini_read(LocalBuffer,INI_BUFFERSIZE,fp) || *(sp = skipleading(LocalBuffer)) == '[') return 0; sp = skipleading(LocalBuffer); ep = _tcschr(sp, '='); /* Parse out the equal sign */ if (ep == NULL) ep = _tcschr(sp, ':'); } while (*sp == ';' || *sp == '#' || ep == NULL || ((len == 0 || (int)(skiptrailing(ep,sp)-sp) != len || _tcsnicmp(sp,Key,len) != 0) && ++idx != idxKey)); if (idxKey >= 0) { if (idx == idxKey) { assert(ep != NULL); assert(*ep == '=' || *ep == ':'); *ep = '\0'; striptrailing(sp); ini_strncpy(Buffer, sp, BufferSize, QUOTE_NONE); return 1; } /* if */ return 0; /* no more key found (in this section) */ } /* if */ /* Copy up to BufferSize chars to buffer */ assert(ep != NULL); assert(*ep == '=' || *ep == ':'); sp = skipleading(ep + 1); sp = cleanstring(sp, "es); /* Remove a trailing comment */ ini_strncpy(Buffer, sp, BufferSize, quotes); return 1; } /** ini_gets() * \param Section the name of the section to search for * \param Key the name of the entry to find the value of * \param DefValue default string in the event of a failed read * \param Buffer a pointer to the buffer to copy into * \param BufferSize the maximum number of characters to copy * \param Filename the name and full path of the .ini file to read from * * \return the number of characters copied into the supplied buffer */ int ini_gets(const TCHAR *Section, const TCHAR *Key, const TCHAR *DefValue, TCHAR *Buffer, int BufferSize, const TCHAR *Filename) { INI_FILETYPE fp; int ok = 0; if (Buffer == NULL || BufferSize <= 0 || Key == NULL) return 0; if (ini_openread(Filename, &fp)) { ok = getkeystring(&fp, Section, Key, -1, -1, Buffer, BufferSize, NULL); (void)ini_close(&fp); } /* if */ if (!ok) ini_strncpy(Buffer, (DefValue != NULL) ? DefValue : __T(""), BufferSize, QUOTE_NONE); return (int)_tcslen(Buffer); } /** ini_getl() * \param Section the name of the section to search for * \param Key the name of the entry to find the value of * \param DefValue the default value in the event of a failed read * \param Filename the name of the .ini file to read from * * \return the value located at Key */ long ini_getl(const TCHAR *Section, const TCHAR *Key, long DefValue, const TCHAR *Filename) { TCHAR LocalBuffer[64]; int len = ini_gets(Section, Key, __T(""), LocalBuffer, sizearray(LocalBuffer), Filename); return (len == 0) ? DefValue : ((len >= 2 && _totupper((int)LocalBuffer[1]) == 'X') ? _tcstol(LocalBuffer, NULL, 16) : _tcstol(LocalBuffer, NULL, 10)); } #if defined INI_REAL /** ini_getf() * \param Section the name of the section to search for * \param Key the name of the entry to find the value of * \param DefValue the default value in the event of a failed read * \param Filename the name of the .ini file to read from * * \return the value located at Key */ INI_REAL ini_getf(const TCHAR *Section, const TCHAR *Key, INI_REAL DefValue, const TCHAR *Filename) { TCHAR LocalBuffer[64]; int len = ini_gets(Section, Key, __T(""), LocalBuffer, sizearray(LocalBuffer), Filename); return (len == 0) ? DefValue : ini_atof(LocalBuffer); } #endif /** ini_getbool() * \param Section the name of the section to search for * \param Key the name of the entry to find the value of * \param DefValue default value in the event of a failed read; it should * zero (0) or one (1). * \param Filename the name and full path of the .ini file to read from * * A true boolean is found if one of the following is matched: * - A string starting with 'y' or 'Y' * - A string starting with 't' or 'T' * - A string starting with '1' * * A false boolean is found if one of the following is matched: * - A string starting with 'n' or 'N' * - A string starting with 'f' or 'F' * - A string starting with '0' * * \return the true/false flag as interpreted at Key */ int ini_getbool(const TCHAR *Section, const TCHAR *Key, int DefValue, const TCHAR *Filename) { TCHAR LocalBuffer[2] = __T(""); int ret; ini_gets(Section, Key, __T(""), LocalBuffer, sizearray(LocalBuffer), Filename); LocalBuffer[0] = (TCHAR)_totupper((int)LocalBuffer[0]); if (LocalBuffer[0] == 'Y' || LocalBuffer[0] == '1' || LocalBuffer[0] == 'T') ret = 1; else if (LocalBuffer[0] == 'N' || LocalBuffer[0] == '0' || LocalBuffer[0] == 'F') ret = 0; else ret = DefValue; return(ret); } /** ini_getsection() * \param idx the zero-based sequence number of the section to return * \param Buffer a pointer to the buffer to copy into * \param BufferSize the maximum number of characters to copy * \param Filename the name and full path of the .ini file to read from * * \return the number of characters copied into the supplied buffer */ int ini_getsection(int idx, TCHAR *Buffer, int BufferSize, const TCHAR *Filename) { INI_FILETYPE fp; int ok = 0; if (Buffer == NULL || BufferSize <= 0 || idx < 0) return 0; if (ini_openread(Filename, &fp)) { ok = getkeystring(&fp, NULL, NULL, idx, -1, Buffer, BufferSize, NULL); (void)ini_close(&fp); } /* if */ if (!ok) *Buffer = '\0'; return (int)_tcslen(Buffer); } /** ini_getkey() * \param Section the name of the section to browse through, or NULL to * browse through the keys outside any section * \param idx the zero-based sequence number of the key to return * \param Buffer a pointer to the buffer to copy into * \param BufferSize the maximum number of characters to copy * \param Filename the name and full path of the .ini file to read from * * \return the number of characters copied into the supplied buffer */ int ini_getkey(const TCHAR *Section, int idx, TCHAR *Buffer, int BufferSize, const TCHAR *Filename) { INI_FILETYPE fp; int ok = 0; if (Buffer == NULL || BufferSize <= 0 || idx < 0) return 0; if (ini_openread(Filename, &fp)) { ok = getkeystring(&fp, Section, NULL, -1, idx, Buffer, BufferSize, NULL); (void)ini_close(&fp); } /* if */ if (!ok) *Buffer = '\0'; return (int)_tcslen(Buffer); } #if !defined INI_NOBROWSE /** ini_browse() * \param Callback a pointer to a function that will be called for every * setting in the INI file. * \param UserData arbitrary data, which the function passes on the the * \c Callback function * \param Filename the name and full path of the .ini file to read from * * \return 1 on success, 0 on failure (INI file not found) * * \note The \c Callback function must return 1 to continue * browsing through the INI file, or 0 to stop. Even when the * callback stops the browsing, this function will return 1 * (for success). */ int ini_browse(INI_CALLBACK Callback, void *UserData, const TCHAR *Filename) { TCHAR LocalBuffer[INI_BUFFERSIZE]; int lenSec, lenKey; enum quote_option quotes; INI_FILETYPE fp; if (Callback == NULL) return 0; if (!ini_openread(Filename, &fp)) return 0; LocalBuffer[0] = '\0'; /* copy an empty section in the buffer */ lenSec = (int)_tcslen(LocalBuffer) + 1; for ( ;; ) { TCHAR *sp, *ep; if (!ini_read(LocalBuffer + lenSec, INI_BUFFERSIZE - lenSec, &fp)) break; sp = skipleading(LocalBuffer + lenSec); /* ignore empty strings and comments */ if (*sp == '\0' || *sp == ';' || *sp == '#') continue; /* see whether we reached a new section */ ep = _tcsrchr(sp, ']'); if (*sp == '[' && ep != NULL) { *ep = '\0'; ini_strncpy(LocalBuffer, sp + 1, INI_BUFFERSIZE, QUOTE_NONE); lenSec = (int)_tcslen(LocalBuffer) + 1; continue; } /* if */ /* not a new section, test for a key/value pair */ ep = _tcschr(sp, '='); /* test for the equal sign or colon */ if (ep == NULL) ep = _tcschr(sp, ':'); if (ep == NULL) continue; /* invalid line, ignore */ *ep++ = '\0'; /* split the key from the value */ striptrailing(sp); ini_strncpy(LocalBuffer + lenSec, sp, INI_BUFFERSIZE - lenSec, QUOTE_NONE); lenKey = (int)_tcslen(LocalBuffer + lenSec) + 1; /* clean up the value */ sp = skipleading(ep); sp = cleanstring(sp, "es); /* Remove a trailing comment */ ini_strncpy(LocalBuffer + lenSec + lenKey, sp, INI_BUFFERSIZE - lenSec - lenKey, quotes); /* call the callback */ if (!Callback(LocalBuffer, LocalBuffer + lenSec, LocalBuffer + lenSec + lenKey, UserData)) break; } /* for */ (void)ini_close(&fp); return 1; } #endif /* INI_NOBROWSE */ #if ! defined INI_READONLY static void ini_tempname(TCHAR *dest, const TCHAR *source, int maxlength) { TCHAR *p; ini_strncpy(dest, source, maxlength, QUOTE_NONE); p = _tcsrchr(dest, '\0'); assert(p != NULL); *(p - 1) = '~'; } static enum quote_option check_enquote(const TCHAR *Value) { const TCHAR *p; /* run through the value, if it has trailing spaces, or '"', ';' or '#' * characters, enquote it */ assert(Value != NULL); for (p = Value; *p != '\0' && *p != '"' && *p != ';' && *p != '#'; p++) /* nothing */; return (*p != '\0' || (p > Value && *(p - 1) == ' ')) ? QUOTE_ENQUOTE : QUOTE_NONE; } static void writesection(TCHAR *LocalBuffer, const TCHAR *Section, INI_FILETYPE *fp) { if (Section != NULL && _tcslen(Section) > 0) { TCHAR *p; LocalBuffer[0] = '['; ini_strncpy(LocalBuffer + 1, Section, INI_BUFFERSIZE - 4, QUOTE_NONE); /* -1 for '[', -1 for ']', -2 for '\r\n' */ p = _tcsrchr(LocalBuffer, '\0'); assert(p != NULL); *p++ = ']'; _tcscpy(p, INI_LINETERM); /* copy line terminator (typically "\n") */ if (fp != NULL) (void)ini_write(LocalBuffer, fp); } /* if */ } static void writekey(TCHAR *LocalBuffer, const TCHAR *Key, const TCHAR *Value, INI_FILETYPE *fp) { TCHAR *p; enum quote_option option = check_enquote(Value); ini_strncpy(LocalBuffer, Key, INI_BUFFERSIZE - 3, QUOTE_NONE); /* -1 for '=', -2 for '\r\n' */ p = _tcsrchr(LocalBuffer, '\0'); assert(p != NULL); *p++ = '='; ini_strncpy(p, Value, INI_BUFFERSIZE - (p - LocalBuffer) - 2, option); /* -2 for '\r\n' */ p = _tcsrchr(LocalBuffer, '\0'); assert(p != NULL); _tcscpy(p, INI_LINETERM); /* copy line terminator (typically "\n") */ if (fp != NULL) (void)ini_write(LocalBuffer, fp); } static int cache_accum(const TCHAR *string, int *size, int max) { int len = (int)_tcslen(string); if (*size + len >= max) return 0; *size += len; return 1; } static int cache_flush(TCHAR *buffer, int *size, INI_FILETYPE *rfp, INI_FILETYPE *wfp, INI_FILEPOS *mark) { int terminator_len = (int)_tcslen(INI_LINETERM); int pos = 0; (void)ini_seek(rfp, mark); assert(buffer != NULL); buffer[0] = '\0'; assert(size != NULL); assert(*size <= INI_BUFFERSIZE); while (pos < *size) { (void)ini_read(buffer + pos, INI_BUFFERSIZE - pos, rfp); while (pos < *size && buffer[pos] != '\0') pos++; /* cannot use _tcslen() because buffer may not be zero-terminated */ } /* while */ if (buffer[0] != '\0') { assert(pos > 0 && pos <= INI_BUFFERSIZE); if (pos == INI_BUFFERSIZE) pos--; buffer[pos] = '\0'; /* force zero-termination (may be left unterminated in the above while loop) */ (void)ini_write(buffer, wfp); } ini_tell(rfp, mark); /* update mark */ *size = 0; /* return whether the buffer ended with a line termination */ return (pos > terminator_len) && (_tcscmp(buffer + pos - terminator_len, INI_LINETERM) == 0); } static int close_rename(INI_FILETYPE *rfp, INI_FILETYPE *wfp, const TCHAR *filename, TCHAR *buffer) { (void)ini_close(rfp); (void)ini_close(wfp); (void)ini_remove(filename); (void)ini_tempname(buffer, filename, INI_BUFFERSIZE); (void)ini_rename(buffer, filename); return 1; } /** ini_puts() * \param Section the name of the section to write the string in * \param Key the name of the entry to write, or NULL to erase all keys in the section * \param Value a pointer to the buffer the string, or NULL to erase the key * \param Filename the name and full path of the .ini file to write to * * \return 1 if successful, otherwise 0 */ int ini_puts(const TCHAR *Section, const TCHAR *Key, const TCHAR *Value, const TCHAR *Filename) { INI_FILETYPE rfp; INI_FILETYPE wfp; INI_FILEPOS mark; INI_FILEPOS head, tail; TCHAR *sp, *ep; TCHAR LocalBuffer[INI_BUFFERSIZE]; int len, match, flag, cachelen; assert(Filename != NULL); if (!ini_openread(Filename, &rfp)) { /* If the .ini file doesn't exist, make a new file */ if (Key != NULL && Value != NULL) { if (!ini_openwrite(Filename, &wfp)) return 0; writesection(LocalBuffer, Section, &wfp); writekey(LocalBuffer, Key, Value, &wfp); (void)ini_close(&wfp); } /* if */ return 1; } /* if */ /* If parameters Key and Value are valid (so this is not an "erase" request) * and the setting already exists, there are two short-cuts to avoid rewriting * the INI file. */ if (Key != NULL && Value != NULL) { ini_tell(&rfp, &mark); match = getkeystring(&rfp, Section, Key, -1, -1, LocalBuffer, sizearray(LocalBuffer), &head); if (match) { /* if the current setting is identical to the one to write, there is * nothing to do. */ if (_tcscmp(LocalBuffer,Value) == 0) { (void)ini_close(&rfp); return 1; } /* if */ /* if the new setting has the same length as the current setting, and the * glue file permits file read/write access, we can modify in place. */ #if defined ini_openrewrite /* we already have the start of the (raw) line, get the end too */ ini_tell(&rfp, &tail); /* create new buffer (without writing it to file) */ writekey(LocalBuffer, Key, Value, NULL); if (_tcslen(LocalBuffer) == (size_t)(tail - head)) { /* length matches, close the file & re-open for read/write, then * write at the correct position */ (void)ini_close(&rfp); if (!ini_openrewrite(Filename, &wfp)) return 0; (void)ini_seek(&wfp, &head); (void)ini_write(LocalBuffer, &wfp); (void)ini_close(&wfp); return 1; } /* if */ #endif } /* if */ /* key not found, or different value & length -> proceed (but rewind the * input file first) */ (void)ini_seek(&rfp, &mark); } /* if */ /* Get a temporary file name to copy to. Use the existing name, but with * the last character set to a '~'. */ ini_tempname(LocalBuffer, Filename, INI_BUFFERSIZE); if (!ini_openwrite(LocalBuffer, &wfp)) { (void)ini_close(&rfp); return 0; } /* if */ (void)ini_tell(&rfp, &mark); cachelen = 0; /* Move through the file one line at a time until a section is * matched or until EOF. Copy to temp file as it is read. */ len = (Section != NULL) ? (int)_tcslen(Section) : 0; if (len > 0) { do { if (!ini_read(LocalBuffer, INI_BUFFERSIZE, &rfp)) { /* Failed to find section, so add one to the end */ flag = cache_flush(LocalBuffer, &cachelen, &rfp, &wfp, &mark); if (Key!=NULL && Value!=NULL) { if (!flag) (void)ini_write(INI_LINETERM, &wfp); /* force a new line behind the last line of the INI file */ writesection(LocalBuffer, Section, &wfp); writekey(LocalBuffer, Key, Value, &wfp); } /* if */ return close_rename(&rfp, &wfp, Filename, LocalBuffer); /* clean up and rename */ } /* if */ /* Copy the line from source to dest, but not if this is the section that * we are looking for and this section must be removed */ sp = skipleading(LocalBuffer); ep = _tcsrchr(sp, ']'); match = (*sp == '[' && ep != NULL && (int)(ep-sp-1) == len && _tcsnicmp(sp + 1,Section,len) == 0); if (!match || Key != NULL) { if (!cache_accum(LocalBuffer, &cachelen, INI_BUFFERSIZE)) { cache_flush(LocalBuffer, &cachelen, &rfp, &wfp, &mark); (void)ini_read(LocalBuffer, INI_BUFFERSIZE, &rfp); cache_accum(LocalBuffer, &cachelen, INI_BUFFERSIZE); } /* if */ } /* if */ } while (!match); } /* if */ cache_flush(LocalBuffer, &cachelen, &rfp, &wfp, &mark); /* when deleting a section, the section head that was just found has not been * copied to the output file, but because this line was not "accumulated" in * the cache, the position in the input file was reset to the point just * before the section; this must now be skipped (again) */ if (Key == NULL) { (void)ini_read(LocalBuffer, INI_BUFFERSIZE, &rfp); (void)ini_tell(&rfp, &mark); } /* if */ /* Now that the section has been found, find the entry. Stop searching * upon leaving the section's area. Copy the file as it is read * and create an entry if one is not found. */ len = (Key != NULL) ? (int)_tcslen(Key) : 0; for( ;; ) { if (!ini_read(LocalBuffer, INI_BUFFERSIZE, &rfp)) { /* EOF without an entry so make one */ flag = cache_flush(LocalBuffer, &cachelen, &rfp, &wfp, &mark); if (Key!=NULL && Value!=NULL) { if (!flag) (void)ini_write(INI_LINETERM, &wfp); /* force a new line behind the last line of the INI file */ writekey(LocalBuffer, Key, Value, &wfp); } /* if */ return close_rename(&rfp, &wfp, Filename, LocalBuffer); /* clean up and rename */ } /* if */ sp = skipleading(LocalBuffer); ep = _tcschr(sp, '='); /* Parse out the equal sign */ if (ep == NULL) ep = _tcschr(sp, ':'); match = (ep != NULL && len > 0 && (int)(skiptrailing(ep,sp)-sp) == len && _tcsnicmp(sp,Key,len) == 0); if ((Key != NULL && match) || *sp == '[') break; /* found the key, or found a new section */ /* copy other keys in the section */ if (Key == NULL) { (void)ini_tell(&rfp, &mark); /* we are deleting the entire section, so update the read position */ } else { if (!cache_accum(LocalBuffer, &cachelen, INI_BUFFERSIZE)) { cache_flush(LocalBuffer, &cachelen, &rfp, &wfp, &mark); (void)ini_read(LocalBuffer, INI_BUFFERSIZE, &rfp); cache_accum(LocalBuffer, &cachelen, INI_BUFFERSIZE); } /* if */ } /* if */ } /* for */ /* the key was found, or we just dropped on the next section (meaning that it * wasn't found); in both cases we need to write the key, but in the latter * case, we also need to write the line starting the new section after writing * the key */ flag = (*sp == '['); cache_flush(LocalBuffer, &cachelen, &rfp, &wfp, &mark); if (Key != NULL && Value != NULL) writekey(LocalBuffer, Key, Value, &wfp); /* cache_flush() reset the "read pointer" to the start of the line with the * previous key or the new section; read it again (because writekey() destroyed * the buffer) */ (void)ini_read(LocalBuffer, INI_BUFFERSIZE, &rfp); if (flag) { /* the new section heading needs to be copied to the output file */ cache_accum(LocalBuffer, &cachelen, INI_BUFFERSIZE); } else { /* forget the old key line */ (void)ini_tell(&rfp, &mark); } /* if */ /* Copy the rest of the INI file */ while (ini_read(LocalBuffer, INI_BUFFERSIZE, &rfp)) { if (!cache_accum(LocalBuffer, &cachelen, INI_BUFFERSIZE)) { cache_flush(LocalBuffer, &cachelen, &rfp, &wfp, &mark); (void)ini_read(LocalBuffer, INI_BUFFERSIZE, &rfp); cache_accum(LocalBuffer, &cachelen, INI_BUFFERSIZE); } /* if */ } /* while */ cache_flush(LocalBuffer, &cachelen, &rfp, &wfp, &mark); return close_rename(&rfp, &wfp, Filename, LocalBuffer); /* clean up and rename */ } /* Ansi C "itoa" based on Kernighan & Ritchie's "Ansi C" book. */ #define ABS(v) ((v) < 0 ? -(v) : (v)) static void strreverse(TCHAR *str) { int i, j; for (i = 0, j = (int)_tcslen(str) - 1; i < j; i++, j--) { TCHAR t = str[i]; str[i] = str[j]; str[j] = t; } /* for */ } static void long2str(long value, TCHAR *str) { int i = 0; long sign = value; /* generate digits in reverse order */ do { int n = (int)(value % 10); /* get next lowest digit */ str[i++] = (TCHAR)(ABS(n) + '0'); /* handle case of negative digit */ } while (value /= 10); /* delete the lowest digit */ if (sign < 0) str[i++] = '-'; str[i] = '\0'; strreverse(str); } /** ini_putl() * \param Section the name of the section to write the value in * \param Key the name of the entry to write * \param Value the value to write * \param Filename the name and full path of the .ini file to write to * * \return 1 if successful, otherwise 0 */ int ini_putl(const TCHAR *Section, const TCHAR *Key, long Value, const TCHAR *Filename) { TCHAR LocalBuffer[32]; long2str(Value, LocalBuffer); return ini_puts(Section, Key, LocalBuffer, Filename); } #if defined INI_REAL /** ini_putf() * \param Section the name of the section to write the value in * \param Key the name of the entry to write * \param Value the value to write * \param Filename the name and full path of the .ini file to write to * * \return 1 if successful, otherwise 0 */ int ini_putf(const TCHAR *Section, const TCHAR *Key, INI_REAL Value, const TCHAR *Filename) { TCHAR LocalBuffer[64]; ini_ftoa(LocalBuffer, Value); return ini_puts(Section, Key, LocalBuffer, Filename); } #endif /* INI_REAL */ #endif /* !INI_READONLY */ uTox/third_party/minini/minini/dev/minGlue.h0000600000175000001440000000314114003056224020122 0ustar rakusers/* Glue functions for the minIni library, based on the C/C++ stdio library * * Or better said: this file contains macros that maps the function interface * used by minIni to the standard C/C++ file I/O functions. * * By CompuPhase, 2008-2014 * This "glue file" is in the public domain. It is distributed without * warranties or conditions of any kind, either express or implied. */ /* map required file I/O types and functions to the standard C library */ #include #define INI_FILETYPE FILE* #define ini_openread(filename,file) ((*(file) = fopen((filename),"rb")) != NULL) #define ini_openwrite(filename,file) ((*(file) = fopen((filename),"wb")) != NULL) #define ini_openrewrite(filename,file) ((*(file) = fopen((filename),"r+b")) != NULL) #define ini_close(file) (fclose(*(file)) == 0) #define ini_read(buffer,size,file) (fgets((buffer),(size),*(file)) != NULL) #define ini_write(buffer,file) (fputs((buffer),*(file)) >= 0) #define ini_rename(source,dest) (rename((source), (dest)) == 0) #define ini_remove(filename) (remove(filename) == 0) #define INI_FILEPOS long int #define ini_tell(file,pos) (*(pos) = ftell(*(file))) #define ini_seek(file,pos) (fseek(*(file), *(pos), SEEK_SET) == 0) /* for floating-point support, define additional types and functions */ #define INI_REAL float #define ini_ftoa(string,value) sprintf((string),"%f",(value)) #define ini_atof(string) (INI_REAL)strtod((string),NULL) uTox/third_party/minini/minini/dev/minGlue-stdio.h0000600000175000001440000000312214003056224021241 0ustar rakusers/* Glue functions for the minIni library, based on the C/C++ stdio library * * Or better said: this file contains macros that maps the function interface * used by minIni to the standard C/C++ file I/O functions. * * By CompuPhase, 2008-2014 * This "glue file" is in the public domain. It is distributed without * warranties or conditions of any kind, either express or implied. */ /* map required file I/O types and functions to the standard C library */ #include #define INI_FILETYPE FILE* #define ini_openread(filename,file) ((*(file) = fopen((filename),"rb")) != NULL) #define ini_openwrite(filename,file) ((*(file) = fopen((filename),"wb")) != NULL) #define ini_openrewrite(filename,file) ((*(file) = fopen((filename),"r+b")) != NULL) #define ini_close(file) (fclose(*(file)) == 0) #define ini_read(buffer,size,file) (fgets((buffer),(size),*(file)) != NULL) #define ini_write(buffer,file) (fputs((buffer),*(file)) >= 0) #define ini_rename(source,dest) (rename((source), (dest)) == 0) #define ini_remove(filename) (remove(filename) == 0) #define INI_FILEPOS long int #define ini_tell(file,pos) (*(pos) = ftell(*(file))) #define ini_seek(file,pos) (fseek(*(file), *(pos), SEEK_SET) == 0) /* for floating-point support, define additional types and functions */ #define INI_REAL float #define ini_ftoa(string,value) sprintf((string),"%f",(value)) #define ini_atof(string) (INI_REAL)strtod((string),NULL) uTox/third_party/minini/minini/dev/minGlue-mdd.h0000600000175000001440000000441214003056224020666 0ustar rakusers/* minIni glue functions for Microchip's "Memory Disk Drive" file system * library, as presented in Microchip application note AN1045. * * By CompuPhase, 2011-2014 * This "glue file" is in the public domain. It is distributed without * warranties or conditions of any kind, either express or implied. * * (The "Microchip Memory Disk Drive File System" is copyright (c) Microchip * Technology Incorporated, and licensed at its own terms.) */ #define INI_BUFFERSIZE 256 /* maximum line length, maximum path length */ #include "MDD File System\fsio.h" #include #define INI_FILETYPE FSFILE* #define ini_openread(filename,file) ((*(file) = FSfopen((filename),FS_READ)) != NULL) #define ini_openwrite(filename,file) ((*(file) = FSfopen((filename),FS_WRITE)) != NULL) #define ini_openrewrite(filename,file) ((*(file) = fopen((filename),FS_READPLUS)) != NULL) #define ini_close(file) (FSfclose(*(file)) == 0) #define ini_write(buffer,file) (FSfwrite((buffer), 1, strlen(buffer), (*file)) > 0) #define ini_remove(filename) (FSremove((filename)) == 0) #define INI_FILEPOS long int #define ini_tell(file,pos) (*(pos) = FSftell(*(file))) #define ini_seek(file,pos) (FSfseek(*(file), *(pos), SEEK_SET) == 0) /* Since the Memory Disk Drive file system library reads only blocks of files, * the function to read a text line does so by "over-reading" a block of the * of the maximum size and truncating it behind the end-of-line. */ static int ini_read(char *buffer, int size, INI_FILETYPE *file) { size_t numread = size; char *eol; if ((numread = FSfread(buffer, 1, size, *file)) == 0) return 0; /* at EOF */ if ((eol = strchr(buffer, '\n')) == NULL) eol = strchr(buffer, '\r'); if (eol != NULL) { /* terminate the buffer */ *++eol = '\0'; /* "unread" the data that was read too much */ FSfseek(*file, - (int)(numread - (size_t)(eol - buffer)), SEEK_CUR); } /* if */ return 1; } #ifndef INI_READONLY static int ini_rename(const char *source, const char *dest) { FSFILE* ftmp = FSfopen((source), FS_READ); FSrename((dest), ftmp); return FSfclose(ftmp) == 0; } #endif uTox/third_party/minini/minini/dev/minGlue-ffs.h0000600000175000001440000000242614003056224020703 0ustar rakusers/* Glue functions for the minIni library, based on the "FAT Filing System" * library by embedded-code.com * * By CompuPhase, 2008-2012 * This "glue file" is in the public domain. It is distributed without * warranties or conditions of any kind, either express or implied. * * (The "FAT Filing System" library itself is copyright embedded-code.com, and * licensed at its own terms.) */ #define INI_BUFFERSIZE 256 /* maximum line length, maximum path length */ #include #define INI_FILETYPE FFS_FILE* #define ini_openread(filename,file) ((*(file) = ffs_fopen((filename),"r")) != NULL) #define ini_openwrite(filename,file) ((*(file) = ffs_fopen((filename),"w")) != NULL) #define ini_close(file) (ffs_fclose(*(file)) == 0) #define ini_read(buffer,size,file) (ffs_fgets((buffer),(size),*(file)) != NULL) #define ini_write(buffer,file) (ffs_fputs((buffer),*(file)) >= 0) #define ini_rename(source,dest) (ffs_rename((source), (dest)) == 0) #define ini_remove(filename) (ffs_remove(filename) == 0) #define INI_FILEPOS long #define ini_tell(file,pos) (ffs_fgetpos(*(file), (pos)) == 0) #define ini_seek(file,pos) (ffs_fsetpos(*(file), (pos)) == 0) uTox/third_party/minini/minini/dev/minGlue-efsl.h0000600000175000001440000000473014003056224021056 0ustar rakusers/* Glue functions for the minIni library, based on the EFS Library, see * http://www.efsl.be/ * * By CompuPhase, 2008-2012 * This "glue file" is in the public domain. It is distributed without * warranties or conditions of any kind, either express or implied. * * (EFSL is copyright 2005-2006 Lennart Ysboodt and Michael De Nil, and * licensed under the GPL with an exception clause for static linking.) */ #define INI_BUFFERSIZE 256 /* maximum line length, maximum path length */ #define INI_LINETERM "\r\n" /* set line termination explicitly */ #include "efs.h" extern EmbeddedFileSystem g_efs; #define INI_FILETYPE EmbeddedFile #define ini_openread(filename,file) (file_fopen((file), &g_efs.myFs, (char*)(filename), 'r') == 0) #define ini_openwrite(filename,file) (file_fopen((file), &g_efs.myFs, (char*)(filename), 'w') == 0) #define ini_close(file) file_fclose(file) #define ini_read(buffer,size,file) (file_read((file), (size), (buffer)) > 0) #define ini_write(buffer,file) (file_write((file), strlen(buffer), (char*)(buffer)) > 0) #define ini_remove(filename) rmfile(&g_efs.myFs, (char*)(filename)) #define INI_FILEPOS euint32 #define ini_tell(file,pos) (*(pos) = (file)->FilePtr)) #define ini_seek(file,pos) file_setpos((file), (*pos)) #if ! defined INI_READONLY /* EFSL lacks a rename function, so instead we copy the file to the new name * and delete the old file */ static int ini_rename(char *source, const char *dest) { EmbeddedFile fr, fw; int n; if (file_fopen(&fr, &g_efs.myFs, source, 'r') != 0) return 0; if (rmfile(&g_efs.myFs, (char*)dest) != 0) return 0; if (file_fopen(&fw, &g_efs.myFs, (char*)dest, 'w') != 0) return 0; /* With some "insider knowledge", we can save some memory: the "source" * parameter holds a filename that was built from the "dest" parameter. It * was built in buffer and this buffer has the size INI_BUFFERSIZE. We can * reuse this buffer for copying the file. */ while (n=file_read(&fr, INI_BUFFERSIZE, source)) file_write(&fw, n, source); file_fclose(&fr); file_fclose(&fw); /* Now we need to delete the source file. However, we have garbled the buffer * that held the filename of the source. So we need to build it again. */ ini_tempname(source, dest, INI_BUFFERSIZE); return rmfile(&g_efs.myFs, source) == 0; } #endif uTox/third_party/minini/minini/dev/minGlue-ccs.h0000600000175000001440000000450614003056224020676 0ustar rakusers/* minIni glue functions for FAT library by CCS, Inc. (as provided with their * PIC MCU compiler) * * By CompuPhase, 2011-2012 * This "glue file" is in the public domain. It is distributed without * warranties or conditions of any kind, either express or implied. * * (The FAT library is copyright (c) 2007 Custom Computer Services, and * licensed at its own terms.) */ #define INI_BUFFERSIZE 256 /* maximum line length, maximum path length */ #ifndef FAT_PIC_C #error FAT library must be included before this module #endif #define const /* keyword not supported by CCS */ #define INI_FILETYPE FILE #define ini_openread(filename,file) (fatopen((filename), "r", (file)) == GOODEC) #define ini_openwrite(filename,file) (fatopen((filename), "w", (file)) == GOODEC) #define ini_close(file) (fatclose((file)) == 0) #define ini_read(buffer,size,file) (fatgets((buffer), (size), (file)) != NULL) #define ini_write(buffer,file) (fatputs((buffer), (file)) == GOODEC) #define ini_remove(filename) (rm_file((filename)) == 0) #define INI_FILEPOS fatpos_t #define ini_tell(file,pos) (fatgetpos((file), (pos)) == 0) #define ini_seek(file,pos) (fatsetpos((file), (pos)) == 0) #ifndef INI_READONLY /* CCS FAT library lacks a rename function, so instead we copy the file to the * new name and delete the old file */ static int ini_rename(char *source, char *dest) { FILE fr, fw; int n; if (fatopen(source, "r", &fr) != GOODEC) return 0; if (rm_file(dest) != 0) return 0; if (fatopen(dest, "w", &fw) != GOODEC) return 0; /* With some "insider knowledge", we can save some memory: the "source" * parameter holds a filename that was built from the "dest" parameter. It * was built in a local buffer with the size INI_BUFFERSIZE. We can reuse * this buffer for copying the file. */ while (n=fatread(source, 1, INI_BUFFERSIZE, &fr)) fatwrite(source, 1, n, &fw); fatclose(&fr); fatclose(&fw); /* Now we need to delete the source file. However, we have garbled the buffer * that held the filename of the source. So we need to build it again. */ ini_tempname(source, dest, INI_BUFFERSIZE); return rm_file(source) == 0; } #endif uTox/third_party/minini/minini/dev/minGlue-FatFs.h0000600000175000001440000000323314003056224021125 0ustar rakusers/* Glue functions for the minIni library, based on the FatFs and Petit-FatFs * libraries, see http://elm-chan.org/fsw/ff/00index_e.html * * By CompuPhase, 2008-2012 * This "glue file" is in the public domain. It is distributed without * warranties or conditions of any kind, either express or implied. * * (The FatFs and Petit-FatFs libraries are copyright by ChaN and licensed at * its own terms.) */ #define INI_BUFFERSIZE 256 /* maximum line length, maximum path length */ /* You must set _USE_STRFUNC to 1 or 2 in the include file ff.h (or tff.h) * to enable the "string functions" fgets() and fputs(). */ #include "ff.h" /* include tff.h for Tiny-FatFs */ #define INI_FILETYPE FIL #define ini_openread(filename,file) (f_open((file), (filename), FA_READ+FA_OPEN_EXISTING) == FR_OK) #define ini_openwrite(filename,file) (f_open((file), (filename), FA_WRITE+FA_CREATE_ALWAYS) == FR_OK) #define ini_close(file) (f_close(file) == FR_OK) #define ini_read(buffer,size,file) f_gets((buffer), (size),(file)) #define ini_write(buffer,file) f_puts((buffer), (file)) #define ini_remove(filename) (f_unlink(filename) == FR_OK) #define INI_FILEPOS DWORD #define ini_tell(file,pos) (*(pos) = f_tell((file))) #define ini_seek(file,pos) (f_lseek((file), *(pos)) == FR_OK) static int ini_rename(TCHAR *source, const TCHAR *dest) { /* Function f_rename() does not allow drive letters in the destination file */ char *drive = strchr(dest, ':'); drive = (drive == NULL) ? dest : drive + 1; return (f_rename(source, drive) == FR_OK); } uTox/third_party/minini/minini/README.md0000600000175000001440000002323314003056224017056 0ustar rakusers# minIni minIni is a portable and configurable library for reading and writing ".INI" files. At 830 lines of commented source code (version 1.2), minIni truly is a "mini" INI file parser, especially considering its features. The library does not require the file I/O functions from the standard C/C++ library, but instead lets you configure the file I/O interface to use via macros. minIni uses limited stack space and does not use dynamic memory (malloc and friends) at all. Some minor variations on standard INI files are supported too, notably minIni supports INI files that lack sections. # Acknowledgement minIni is derived from an earlier INI file parser (which I wrote) for desktop systems. In turn, that earlier parser was a re-write of the code from the article "Multiplatform .INI Files" by Joseph J. Graf in the March 1994 issue of Dr. Dobb's Journal. In other words, minIni has its roots in the work of Joseph Graf (even though the code has been almost completely re-written). # Features minIni is a programmer's library to read and write "INI" files in embedded systems. minIni takes little resources, can be configured for various kinds of file I/O libraries and provides functionality for reading, writing and deleting keys from an INI file. Although the main feature of minIni is that it is small and minimal, it has a few other features: * minIni supports reading keys that are outside a section, and it thereby supports configuration files that do not use sections (but that are otherwise compatible with INI files). * You may use a colon to separate key and value; the colon is equivalent to the equal sign. That is, the strings "Name: Value" and "Name=Value" have the same meaning. * The hash character ("#") is an alternative for the semicolon to start a comment. Trailing comments (i.e. behind a key/value pair on a line) are allowed. * Leading and trailing white space around key names and values is ignored. * When writing a value that contains a comment character (";" or "#"), that value will automatically be put between double quotes; when reading the value, these quotes are removed. When a double-quote itself appears in the setting, these characters are escaped. * Section and key enumeration are supported. * You can optionally set the line termination (for text files) that minIni will use. (This is a compile-time setting, not a run-time setting.) * Since writing speed is much lower than reading speed in Flash memory (SD/MMC cards, USB memory sticks), minIni minimizes "file writes" at the expense of double "file reads". * The memory footprint is deterministic. There is no dynamic memory allocation. ## INI file reading paradigms There are two approaches to reading settings from an INI file. One way is to call a function, such as GetProfileString() for every section and key that you need. This is especially convenient if there is a large INI file, but you only need a few settings from that file at any time —especially if the INI file can also change while your program runs. This is the approach that the Microsoft Windows API uses. The above procedure is quite inefficient, however, when you need to retrieve quite a few settings in a row from the INI file —especially if the INI file is not cached in memory (which it isn't, in minIni). A different approach to getting settings from an INI file is to call a "parsing" function and let that function call the application back with the section and key names plus the associated data. XML parsing libraries often use this approach; see for example the Expat library. minIni supports both approaches. For reading a single setting, use functions like ini_gets(). For the callback approach, implement a callback and call ini_browse(). See the minIni manual for details. # INI file syntax INI files are best known from Microsoft Windows, but they are also used with applications that run on other platforms (although their file extension is sometimes ".cfg" instead of ".ini"). INI files have a simple syntax with name/value pairs in a plain text file. The name must be unique (per section) and the value must fit on a single line. INI files are commonly separated into sections —in minIni, this is optional. A section is a name between square brackets, like "[Network]" in the example below. ``` [Network] hostname=My Computer address=dhcp dns = 192.168.1.1 ``` In the API and in this documentation, the "name" for a setting is denoted as the key for the setting. The key and the value are separated by an equal sign ("="). minIni supports the colon (":") as an alternative to the equal sign for the key/value delimiter. Leading a trailing spaces around values or key names are removed. If you need to include leading and/or trailing spaces in a value, put the value between double quotes. The ini_gets() function (from the minIni library, see the minIni manual) strips off the double quotes from the returned value. Function ini_puts() adds double quotes if the value to write contains trailing white space (or special characters). minIni ignores spaces around the "=" or ":" delimiters, but it does not ignore spaces between the brackets in a section name. In other words, it is best not to put spaces behind the opening bracket "[" or before the closing bracket "]" of a section name. Comments in the INI must start with a semicolon (";") or a hash character ("#"), and run to the end of the line. A comment can be a line of its own, or it may follow a key/value pair (the "#" character and trailing comments are extensions of minIni). For more details on the format, please see http://en.wikipedia.org/wiki/INI_file. # Adapting minIni to a file system The minIni library must be configured for a platform with the help of a so- called "glue file". This glue file contains macros (and possibly functions) that map file reading and writing functions used by the minIni library to those provided by the operating system. The glue file must be called "minGlue.h". To get you started, the minIni distribution comes with the following example glue files: * a glue file that maps to the standard C/C++ library (specifically the file I/O functions from the "stdio" package), * a glue file for Microchip's "Memory Disk Drive File System Library" (see http://www.microchip.com/), * a glue file for the FAT library provided with the CCS PIC compiler (see http://www.ccsinfo.com/) * a glue file for the EFS Library (EFSL, http://www.efsl.be/), * and a glue file for the FatFs and Petit-FatFs libraries (http://elm-chan.org/fsw/ff/00index_e.html). The minIni library does not rely on the availability of a standard C library, because embedded operating systems may have limited support for file I/O. Even on full operating systems, separating the file I/O from the INI format parsing carries advantages, because it allows you to cache the INI file and thereby enhance performance. The glue file must specify the type that identifies a file, whether it is a handle or a pointer. For the standard C/C++ file I/O library, this would be: ```C #define INI_FILETYPE FILE* ``` If you are not using the standard C/C++ file I/O library, chances are that you need a different handle or "structure" to identify the storage than the ubiquitous "FILE*" type. For example, the glue file for the FatFs library uses the following declaration: ```C #define INI_FILETYPE FIL ``` The minIni functions declare variables of this INI_FILETYPE type and pass these variables to sub-functions (including the glue interface functions) by reference. For "write support", another type that must be defined is for variables that hold the "current position" in a file. For the standard C/C++ I/O library, this is "fpos_t". Another item that needs to be configured is the buffer size. The functions in the minIni library allocate this buffer on the stack, so the buffer size is directly related to the stack usage. In addition, the buffer size determines the maximum line length that is supported in the INI file and the maximum path name length for the temporary file. For example, minGlue.h could contain the definition: ```C #define INI_BUFFERSIZE 512 ``` The above macro limits the line length of the INI files supported by minIni to 512 characters. The temporary file is only used when writing to INI files. The minIni routines copy/change the INI file to a temporary file and then rename that temporary file to the original file. This approach uses the least amount of memory. The path name of the temporary file is the same as the input file, but with the last character set to a tilde ("~"). Below is an example of a glue file (this is the one that maps to the C/C++ "stdio" library). ```C #include #define INI_FILETYPE FILE* #define ini_openread(filename,file) ((*(file) = fopen((filename),"r")) != NULL) #define ini_openwrite(filename,file) ((*(file) = fopen((filename),"w")) != NULL) #define ini_close(file) (fclose(*(file)) == 0) #define ini_read(buffer,size,file) (fgets((buffer),(size),*(file)) != NULL) #define ini_write(buffer,file) (fputs((buffer),*(file)) >= 0) #define ini_rename(source,dest) (rename((source), (dest)) == 0) #define ini_remove(filename) (remove(filename) == 0) #define INI_FILEPOS fpos_t #define ini_tell(file,pos) (fgetpos(*(file), (pos)) == 0) #define ini_seek(file,pos) (fsetpos(*(file), (pos)) == 0) ``` As you can see, a glue file is mostly a set of macros that wraps one function definition around another. The glue file may contain more settings, for support of rational numbers, to explicitly set the line termination character(s), or to disable write support (for example). See the manual that comes with the archive for the details. uTox/third_party/minini/minini/NOTICE0000600000175000001440000000102314003056224016474 0ustar rakusersminIni is a programmer's library to read and write "INI" files in embedded systems. The library takes little resources and can be configured for various kinds of file I/O libraries. The method for portable INI file management in minIni is, in part based, on the article "Multiplatform .INI Files" by Joseph J. Graf in the March 1994 issue of Dr. Dobb's Journal. The C++ class in minIni.h was contributed by Steven Van Ingelgem. The option to compile minIni as a read-only library was contributed by Luca Bassanello. uTox/third_party/minini/minini/LICENSE0000600000175000001440000002504714003056224016611 0ustar rakusers Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ EXCEPTION TO THE APACHE 2.0 LICENSE As a special exception to the Apache License 2.0 (and referring to the definitions in Section 1 of this license), you may link, statically or dynamically, the "Work" to other modules to produce an executable file containing portions of the "Work", and distribute that executable file in "Object" form under the terms of your choice, without any of the additional requirements listed in Section 4 of the Apache License 2.0. This exception applies only to redistributions in "Object" form (not "Source" form) and only if no modifications have been made to the "Work". TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. uTox/third_party/minini/minini/.git0000600000175000001440000000007014003056220016351 0ustar rakusersgitdir: ../../../.git/modules/third_party/minini/minini uTox/third_party/minini/CMakeLists.txt0000600000175000001440000000024514003056216017053 0ustar rakusersproject(minini LANGUAGES C) add_library(${PROJECT_NAME} STATIC minini/dev/minIni.c ) target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC minini/dev ) uTox/third_party/CMakeLists.txt0000600000175000001440000000014414003056216015566 0ustar rakusersadd_cflag("-Wno-error") add_subdirectory(minini) add_subdirectory(qrcodegen) add_subdirectory(stb) uTox/tests/0000700000175000001440000000000014003056216011636 5ustar rakusersuTox/tests/test_chrono.c0000600000175000001440000000365314003056216014342 0ustar rakusers#include "../src/chrono.c" #include "test.h" #include #include /* START_TEST (test_chrono_finished) { CHRONO_INFO info; info.ptr = 0; info.step = 5; info.interval_ms = 5; info.finished = false; chrono_start(&info); yieldcpu(30); chrono_end(&info); ck_assert_msg((intptr_t)info.ptr == 30, "Expected 30 got: %u", info.ptr); } END_TEST */ void thread_callback(void *args) { *(bool *)args = true; } START_TEST(test_chrono_target) { /* * Chrono info should be mallocated in real code. * This function can't exit until the thread exits so it is safe * to use the stack. */ CHRONO_INFO info; bool finished = false; info.ptr = 0; info.step = 5; info.interval_ms = 5; info.finished = false; info.target = (uint8_t *)30; info.callback = thread_callback; info.cb_data = &finished; chrono_start(&info); yieldcpu(30); // allow thread to run and exit while (!finished) { yieldcpu(1); } ck_assert_msg((intptr_t)info.ptr == 30, "Expected 30 got: %u", info.ptr); } END_TEST void callback(void *arg) { *(int *)arg = 10; } START_TEST(test_chrono_callback) { int arg = 0; chrono_callback(1, callback, &arg); ck_assert_msg((intptr_t)arg == 10, "Expected callback_arg to be 10 got: %d", arg); } END_TEST static Suite *suite(void) { Suite *s = suite_create("Chrono"); //MK_TEST_CASE(chrono_finished); // re-enable when the finished field of the chrono info struct is used MK_TEST_CASE(chrono_target); MK_TEST_CASE(chrono_callback) return s; } int main(int argc, char *argv[]) { srand((unsigned int) time(NULL)); Suite *run = suite(); SRunner *test_runner = srunner_create(run); int number_failed = 0; srunner_run_all(test_runner, CK_NORMAL); number_failed = srunner_ntests_failed(test_runner); srunner_free(test_runner); return number_failed; } uTox/tests/test_chatlog.c0000600000175000001440000000514514003056216014471 0ustar rakusers#include "test.h" #include #include #include #include "../src/macros.h" #include "../src/chatlog.c" #include "../src/text.c" #define MOCK_FRIEND_ID "6460FF76319AF777A999ABA2024D5D0AEB202360688ECBABFE56C9403B872D2F" void native_export_chatlog_init(uint32_t friend_number) { char* name = strdup("chatlog_export.txt"); FILE *file = fopen(name, "wb"); if (file) { utox_export_chatlog(MOCK_FRIEND_ID, file); } else { FAIL_FATAL("unable to open file for writing: %s", name); } free(name); } bool test_write_chatlog(); bool test_read_chatlog(); int main() { int result = 0; RUN_TEST(test_write_chatlog) RUN_TEST(test_read_chatlog) return result; } uint8_t* create_mock_message(size_t *length) { LOG_FILE_MSG_HEADER header; memset(&header, 0, sizeof(header)); char* author = strdup("tox user"); size_t author_length = 9; size_t msg_length = strlen("This is a test message."); char* msg = strdup("This is a test message."); header.log_version = LOGFILE_SAVE_VERSION; header.time = time(NULL); header.author_length = author_length; header.msg_length = msg_length; header.author = 1; // we are the message author header.receipt = 1; header.msg_type = 1; // MSG_TYPE_TEXT; *length = sizeof(header) + msg_length + author_length + 1; /* extra \n char */ uint8_t *data = calloc(1, *length); if (!data) { FAIL_FATAL("Can't calloc for chat logging data. size: %lu", *length); } memcpy(data, &header, sizeof(header)); memcpy(data + sizeof(header), author, author_length); memcpy(data + sizeof(header) + author_length, msg, msg_length); strcpy2(data + *length - 1, "\n"); free(author); free(msg); return data; } /** * // TODO is there an automated way to track test coverage in C? * @covers utox_save_chatlog() */ bool test_write_chatlog() { char id_str[TOX_PUBLIC_KEY_SIZE * 2] = MOCK_FRIEND_ID; size_t length1; uint8_t *data1 = create_mock_message(&length1); uint64_t disk_offset1 = utox_save_chatlog(id_str, data1, length1); LOG("disk offset 1: %lu", disk_offset1); assert(disk_offset1 == 0); size_t length2; uint8_t *data2 = create_mock_message(&length2); uint64_t disk_offset2 = utox_save_chatlog(id_str, data2, length2); LOG("disk offset 2: %lu", disk_offset2); assert(disk_offset2 == length1); free(data1); free(data2); return true; } bool test_read_chatlog() { LOG_INFO("test", "testing..."); // FAIL("not good!"); // TODO implement return true; } uTox/tests/test.h0000600000175000001440000000201714003056216012770 0ustar rakusers#include "../src/debug.h" #include "../src/settings.h" #include #include #include #include #include #include #define MK_TEST_CASE(TRGT) \ TCase *case_##TRGT = tcase_create(#TRGT); \ tcase_add_test(case_##TRGT, test_##TRGT); \ suite_add_tcase(s, case_##TRGT); // // define some testing helpers // // run a test method and print its name to create a nicely readable testing output #define RUN_TEST(t) printf("\033[01mtest: " #t "...\033[0m\n"); if (t()) { printf(" -> \033[01;32msuccess.\033[0m\n"); } else { printf(" -> \033[01;31mfail.\033[0m\n"); result = 1; } // print a message #define LOG(m, ...) printf(" " m "\n", ## __VA_ARGS__ ); // print message and return false (i.e. fail current test method) #define FAIL(m, ...) printf(" \033[31m" m "\033[0m\n", ## __VA_ARGS__ ); return false; // print message and exit unsuccessfully #define FAIL_FATAL(m, ...) printf(" \033[31m" m "\033[0m\n", ## __VA_ARGS__ ); exit(1); uTox/tests/run_tests.sh0000700000175000001440000000020214003056216014215 0ustar rakusers#!/bin/sh -e cd "@utoxTESTS_BINARY_DIR@" # remove ./tox folder before each test to have clean environment rm -rf ./tox ctest -VV uTox/tests/mock/0000700000175000001440000000000014003056216012567 5ustar rakusersuTox/tests/mock/mock_threads.c0000600000175000001440000000044614003056216015404 0ustar rakusers#include void thread(void * (*func)(void *), void *args) { pthread_t thread_temp; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 1 << 20); pthread_create(&thread_temp, &attr, func, args); pthread_attr_destroy(&attr); } uTox/tests/mock/mock_system_calls.c0000600000175000001440000000013714003056216016451 0ustar rakusers#include #include void yieldcpu(uint32_t ms) { usleep(ms * 1000); } uTox/tests/mock/mock_settings.c0000600000175000001440000000352014003056216015606 0ustar rakusers#include "branding.h" #include "settings.h" #include "../test.h" SETTINGS settings = { .utox_last_version = UTOX_VERSION_NUMBER, // .last_version // included here to match the full struct .show_splash = false, // Low level settings (network, profile, portable-mode) .disableudp = false, .enableipv6 = true, .proxyenable = false, .force_proxy = false, .proxy_port = 0, // Tox level settings .block_friend_requests = false, .save_encryption = true, // testing always in portable mode to not touch any real tox profile! .portable_mode = true, // User interface settings .close_to_tray = false, .logging_enabled = true, .audio_filtering_enabled = true, .start_in_tray = false, .auto_startup = false, .push_to_talk = false, .audio_preview = false, .video_preview = false, .no_typing_notifications = true, .use_mini_flist = false, // .inline_video // included here to match the full struct .use_long_time_msg = true, .accept_inline_images = true, // Notifications / Alerts .audible_notifications_enabled = true, .status_notifications = true, .group_notifications = 0, .verbose = LOG_LVL_ERROR, .debug_file = NULL, // .theme // included here to match the full struct // OS interface settings .window_height = 480, .window_width = 640, .window_baseline = 0, .window_maximized = 0, }; void config_load(void) { FAIL_FATAL("called a mocked function, this should not happen: %s", __FUNCTION__); } void config_save(void) { FAIL_FATAL("called a mocked function, this should not happen: %s", __FUNCTION__); } uTox/tests/mock/mock_logging.c0000600000175000001440000000036614003056216015401 0ustar rakusers#include "../test.h" // make sure tests are logging everything int utox_verbosity() { return 100; }; void debug(const char *fmt, ...){ va_list list; va_start(list, fmt); printf(" "); vprintf(fmt, list); va_end(list); } uTox/tests/mock/mock_filesys.c0000600000175000001440000000236714003056216015434 0ustar rakusers#include "../../src/filesys.h" #include "../../src/native/filesys.h" #include "../../src/filesys.c" #include "../../src/posix/filesys.c" // TODO copied from xlib/filesys.c might be possible to keep this DRY at some point bool native_remove_file(const uint8_t *name, size_t length, bool portable_mode) { char path[UTOX_FILE_NAME_LENGTH] = { 0 }; // TODO this is duplicated in more methods, make this portable thing a common method in filesys.c if (portable_mode) { snprintf((char *)path, UTOX_FILE_NAME_LENGTH, "./tox/"); } else { snprintf((char *)path, UTOX_FILE_NAME_LENGTH, "%s/.config/tox/", getenv("HOME")); } if (strlen((const char *)path) + length >= UTOX_FILE_NAME_LENGTH) { LOG_DEBUG("Filesys", "File/directory name too long, unable to remove" ); return false; } else { snprintf((char *)path + strlen((const char *)path), UTOX_FILE_NAME_LENGTH - strlen((const char *)path), "%.*s", (int)length, (char *)name); } if (remove((const char *)path)) { LOG_ERR("NATIVE", "Unable to delete file!\n\t\t%s" , path); return false; } else { LOG_INFO("NATIVE", "File deleted!" ); LOG_DEBUG("Filesys", "\t%s" , path); } return true; } uTox/tests/CMakeLists.txt0000600000175000001440000000214014003056216014375 0ustar rakusersproject(utoxTESTS LANGUAGES C) include(CTest) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") find_package(Check REQUIRED) link_directories(${CHECK_LIBRARY_DIRS}) function(make_test name) add_executable(test_${name} test_${name}.c) set_target_properties(test_${name} PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter") target_link_libraries(test_${name} utox-test-mock ${CHECK_LIBRARIES}) add_test(NAME test_${name} COMMAND test_${name}) endfunction() configure_file(${utoxTESTS_SOURCE_DIR}/run_tests.sh ${uTox_BINARY_DIR}/run_tests.sh) # # generic testing defines # include_directories("../src") add_library(utox-test-mock mock/mock_filesys.c mock/mock_settings.c mock/mock_logging.c mock/mock_threads.c mock/mock_system_calls.c ) set_target_properties(utox-test-mock PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter") target_link_libraries(utox-test-mock pthread) # # tests # # TODO add a cmake macro for adding tests, this will be too verbose if we add more. make_test(chatlog) make_test(chrono) uTox/src/0000700000175000001440000000000014003056216011263 5ustar rakusersuTox/src/xlib/0000700000175000001440000000000014003056216012221 5ustar rakusersuTox/src/xlib/window.h0000600000175000001440000000177014003056216013710 0ustar rakusers#ifndef XLIB_WINDOW_H #define XLIB_WINDOW_H #include "../window.h" #include "../native/window.h" #include #include #include #include #include #include #include #include #include extern Display *display; extern Screen *default_screen; extern int def_screen_num; extern Window root_window; extern Visual *default_visual; // TODO move extern UTOX_WINDOW *curr; extern int default_depth; struct native_window { struct utox_window _; // Global struct shared across all platforms Window window; GC gc; Visual *visual; Pixmap drawbuf; Picture renderpic; Picture colorpic; XRenderPictFormat *pictformat; }; extern struct native_window main_window; extern struct native_window popup_window; extern struct native_window scr_grab_window; extern struct native_window tray_pop; void window_set_focus(UTOX_WINDOW *win); #endif uTox/src/xlib/window.c0000600000175000001440000002360714003056216013706 0ustar rakusers#include "window.h" #include "main.h" #include "../branding.h" #include "../debug.h" #include "../macros.h" #include "../native/thread.h" #include "../native/time.h" #include "../ui/draw.h" #include "../layout/background.h" #include "../layout/notify.h" #include "../main.h" // MAIN_WIDTH, MAIN_HEIGHT #include #include #include #include Display *display; Screen *default_screen; int def_screen_num; Window root_window; Visual *default_visual; UTOX_WINDOW *curr; int default_depth; struct native_window main_window; struct native_window popup_window; struct native_window scr_grab_window; struct native_window tray_pop; bool native_window_init(void) { if ((display = XOpenDisplay(NULL)) == NULL) { LOG_ERR("XLIB Wind", "Cannot open display, must exit"); return false; } default_screen = DefaultScreenOfDisplay(display); def_screen_num = DefaultScreen(display); default_visual = DefaultVisual(display, def_screen_num); default_depth = DefaultDepth(display, def_screen_num); root_window = RootWindow(display, def_screen_num); return true; } static UTOX_WINDOW *native_window_create(UTOX_WINDOW *window, char *title, unsigned int class, int x, int y, int w, int h, int min_width, int min_height, void *gui_panel, bool override) { if (!window) { return NULL; } XSetWindowAttributes attrib = { .background_pixel = WhitePixel(display, def_screen_num), .border_pixel = BlackPixel(display, def_screen_num), .override_redirect = override, .event_mask = ExposureMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | FocusChangeMask | PropertyChangeMask, }; window->window = XCreateWindow(display, root_window, x, y, w, h, 0, default_depth, InputOutput, default_visual, class, &attrib); /* Generate the title XLib needs */ char *title_name = strdup(title); XTextProperty native_window_name; // Why? if (XStringListToTextProperty(&title_name, 1, &native_window_name) == 0 ) { LOG_ERR("XLIB Wind", "FATAL ERROR: Unable to alloc for a sting during window creation"); XDestroyWindow(display, window->window); return NULL; } // "Because FUCK your use of sane coding strategies" -Xlib... probably... free(title_name); /* I was getting some errors before, and made this change, but I'm not convinced * these can't be moved to the stack. I'd rather not XAlloc but it works now so * in true Linux fashion DON'T TOUCH ANYTHING THAT WORKS! */ /* Allocate memory for xlib... */ XSizeHints *size_hints = XAllocSizeHints(); XWMHints *wm_hints = XAllocWMHints(); XClassHint *class_hints = XAllocClassHint(); if (!size_hints || !wm_hints || !class_hints) { LOG_ERR("XLIB Wind", "XLIB_Windows: couldn't allocate memory."); XDestroyWindow(display, window->window); return NULL; } /* Set the Size information used by sane WMs */ size_hints->flags = PPosition | PBaseSize | PMinSize | PMaxSize | PWinGravity; size_hints->x = x; size_hints->y = y; size_hints->base_width = w; size_hints->base_height = h; size_hints->min_width = min_width ? min_width : w; size_hints->min_height = min_height ? min_height : h; size_hints->max_width = w * 100; size_hints->max_height = h * 100; size_hints->win_gravity = NorthEastGravity; /* We default to main, this could be wrong */ wm_hints->flags = StateHint | InputHint | WindowGroupHint; wm_hints->initial_state = NormalState; wm_hints->input = true; wm_hints->window_group = main_window.window; /* Allows WMs to find shared resources */ class_hints->res_name = "utox"; class_hints->res_class = "uTox"; XSetWMProperties(display, window->window, &native_window_name, NULL, NULL, 0, size_hints, wm_hints, class_hints); XFree(native_window_name.value); XFree(size_hints); XFree(wm_hints); XFree(class_hints); window->_.x = x; window->_.y = y; window->_.w = w; window->_.h = h; window->_.panel = gui_panel; return window; } void native_window_raze(UTOX_WINDOW *window) { if (window) { // do stuff } else { // don't do stuff } } UTOX_WINDOW *native_window_create_main(int x, int y, int w, int h, char **UNUSED(argv), int UNUSED(argc)) { char title[256]; snprintf(title, 256, "%s %s (version: %s)", TITLE, SUB_TITLE, VERSION); if (!native_window_create(&main_window, title, CWBackPixmap | CWBorderPixel | CWEventMask, x, y, w, h, MAIN_WIDTH, MAIN_HEIGHT, &panel_root, false)) { LOG_FATAL_ERR(EXIT_FAILURE,"XLIB Wind", "Unable to create main window."); } Atom a_pid = XInternAtom(display, "_NET_WM_PID", 0); uint pid = getpid(); XChangeProperty(display, main_window.window, a_pid, XA_CARDINAL, 32, PropModeReplace, (uint8_t *)&pid, 1); native_window_set_target(&main_window); return &main_window; } static void set_window_defaults(UTOX_WINDOW *win) { const Atom a_type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", 0); const Atom a_util = XInternAtom(display, "_NET_WM_WINDOW_TYPE_UTILITY", 0); XChangeProperty(display, win->window, a_type, XA_ATOM, 32, PropModeReplace, (uint8_t *)&a_util, 1); Atom list[] = { wm_delete_window, }; XSetWMProtocols(display, win->window, list, 1); /* create the draw buffer */ win->drawbuf = XCreatePixmap(display, win->window, win->_.w, win->_.h, default_depth); /* catch WM_DELETE_WINDOW */ XSetWMProtocols(display, win->window, &wm_delete_window, 1); win->gc = XCreateGC(display, root_window, 0, 0); XWindowAttributes attr; XGetWindowAttributes(display, root_window, &attr); win->pictformat = XRenderFindVisualFormat(display, attr.visual); /* Xft draw context/color */ win->renderpic = XRenderCreatePicture(display, win->drawbuf, win->pictformat, 0, NULL); XRenderColor xrcolor = { 0,0,0,0 }; win->colorpic = XRenderCreateSolidFill(display, &xrcolor); } UTOX_WINDOW *native_window_create_video(int UNUSED(x), int UNUSED(y), int UNUSED(w), int UNUSED(h)) { return NULL; } UTOX_WINDOW *native_window_find_notify(void *window) { UTOX_WINDOW *win = &popup_window; while (win) { if (win->window == *(Window *)window) { return win; } win = win->_.next; } return NULL; } UTOX_WINDOW *native_window_create_notify(int x, int y, int w, int h, PANEL *panel) { UTOX_WINDOW *next = NULL; if (!popup_window.window) { next = &popup_window; } else { next = calloc(1, sizeof(UTOX_WINDOW)); if (!next) { LOG_FATAL_ERR(EXIT_FAILURE, "XIB Wind", "Unable to allocate data for popup window."); } } UTOX_WINDOW *win = native_window_create(next, "uTox Alert", CWBackPixmap | CWBorderPixel | CWEventMask | CWColormap | CWOverrideRedirect, x, y, w, h, w, h, &panel_notify_generic, true); if (!win) { LOG_ERR("XLIB Wind", "XLIB_WIN:\tUnable to Alloc for a notification window"); return NULL; } Atom a_pid = XInternAtom(display, "_NET_WM_PID", 0); uint pid = getpid(); XChangeProperty(display, win->window, a_pid, XA_CARDINAL, 32, PropModeReplace, (uint8_t *)&pid, 1); Atom a_type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", 0); Atom a_util = XInternAtom(display, "_NET_WM_WINDOW_TYPE_UTILITY", 0); XChangeProperty(display, win->window, a_type, XA_ATOM, 32, PropModeReplace, (uint8_t *)&a_util, 1); set_window_defaults(win); XMapWindow(display, win->window); UTOX_WINDOW *head = &popup_window; while (head->_.next) { head = head->_.next; } if (win != &popup_window){ head->_.next = win; } win->_.panel = panel; return win; } UTOX_WINDOW *native_window_create_traypop(int x, int y, int w, int h, PANEL *panel) { UTOX_WINDOW *next = NULL; if (!tray_pop.window) { next = &popup_window; } // Set the real x, as caller give x/y as root mouse locations x -= w; UTOX_WINDOW *win = native_window_create(next, "uTox Tray Popup", CWBackPixmap | CWBorderPixel | CWEventMask | CWColormap | CWOverrideRedirect, x, y, w, h, w, h, &panel_notify_generic, true); if (!win) { LOG_ERR("XLIB Wind", "XLIB_WIN:\tUnable to Alloc for a tray popup"); return NULL; } set_window_defaults(win); XMapWindow(display, win->window); win->_.panel = panel; return win; } static void notify_tween_thread(void *obj) { UTOX_WINDOW *target = obj; if (!target) { return; } XEvent ev = { .xclient = { .type = ClientMessage, .display = display, .window = target->window, .message_type = XRedraw, .format = 8, .data = { .s = { 0, 0 } } } }; while (target->_.y > 2) { target->_.y -= 2; XMoveWindow(display, target->window, target->_.x, target->_.y); enddraw(0, 0, 400, 150); XSendEvent(display, target->window, 0, 0, &ev); XFlush(display); yieldcpu(1); } } static UTOX_WINDOW *focus; void window_set_focus(UTOX_WINDOW *win) { focus = win; } void native_window_tween(UTOX_WINDOW *win) { thread(notify_tween_thread, win); } void native_window_create_screen_select() { return; } bool native_window_set_target(UTOX_WINDOW *new_win) { if (new_win == curr) { return false; } curr = new_win; return true; } uTox/src/xlib/video.c0000600000175000001440000002146114003056216013501 0ustar rakusers#include "main.h" #include "screen_grab.h" #include "window.h" #include "../debug.h" #include "../macros.h" #include "../ui.h" #include "../av/video.h" #include "../native/time.h" #include "../main.h" #include #include #include #include #include #define MAX_VID_WINDOWS 32 // TODO drop this for dynamic allocation static Window video_win[MAX_VID_WINDOWS]; // TODO we should allocate this dynamically but this'll work for now static Window preview; // Video preview uint16_t find_video_windows(Window w) { if (w == preview) { return UINT16_MAX; } for (unsigned i = 0; i < MAX_VID_WINDOWS; ++i ) { if (w == video_win[i]) { return i; } } return UINT16_MAX; } void video_frame(uint16_t id, uint8_t *img_data, uint16_t width, uint16_t height, bool resize) { if (!img_data) { LOG_DEBUG("Video", "Received a null video frame. Skipping..."); return; } Window *win = &video_win[id]; if (id == UINT16_MAX) { // Preview window win = &preview; } else if (id >= MAX_VID_WINDOWS) { LOG_TRACE("Video", "Window ID too large (>=%d)", MAX_VID_WINDOWS); return; } if (!*win) { LOG_TRACE("Video", "frame for null window %u" , id); return; } if (resize) { XWindowChanges changes = {.width = width, .height = height }; XConfigureWindow(display, *win, CWWidth | CWHeight, &changes); } XWindowAttributes attrs; XGetWindowAttributes(display, *win, &attrs); XImage image = { .width = attrs.width, .height = attrs.height, .depth = 24, .bits_per_pixel = 32, .format = ZPixmap, .byte_order = LSBFirst, .bitmap_unit = 8, .bitmap_bit_order = LSBFirst, .bytes_per_line = attrs.width * 4, .red_mask = 0xFF0000, .green_mask = 0xFF00, .blue_mask = 0xFF, .data = (char *)img_data }; /* scale image if needed */ uint8_t *new_data = NULL; if (attrs.width != width && attrs.height != height){ new_data = malloc(attrs.width * attrs.height * 4); if (!new_data) { LOG_FATAL_ERR(EXIT_MALLOC, "Video", "Could not allocate memory for scaled image."); } scale_rgbx_image(img_data, width, height, new_data, attrs.width, attrs.height); image.data = (char *)new_data; } GC default_gc = DefaultGC(display, def_screen_num); Pixmap pixmap = XCreatePixmap(display, main_window.window, attrs.width, attrs.height, default_depth); XPutImage(display, pixmap, default_gc, &image, 0, 0, 0, 0, attrs.width, attrs.height); XCopyArea(display, pixmap, *win, default_gc, 0, 0, attrs.width, attrs.height, 0, 0); XFreePixmap(display, pixmap); if (new_data) { free(new_data); } } void video_begin(uint16_t id, char *name, uint16_t name_length, uint16_t width, uint16_t height) { Window *win = &video_win[id]; if (id == UINT16_MAX) { // Preview window win = &preview; } else if (id >= MAX_VID_WINDOWS) { LOG_TRACE("Video", "Window ID too large (>=%d)", MAX_VID_WINDOWS); return; } if (*win) { return; } *win = XCreateSimpleWindow(display, RootWindow(display, def_screen_num), 0, 0, width, height, 0, BlackPixel(display, def_screen_num), WhitePixel(display, def_screen_num)); // Fallback name in ISO8859-1. XStoreName(display, *win, "Video Preview"); // UTF-8 name for those WMs that can display it. XChangeProperty(display, *win, XA_NET_NAME, XA_UTF8_STRING, 8, PropModeReplace, (uint8_t *)name, name_length); XSetWMProtocols(display, *win, &wm_delete_window, 1); /* set WM_CLASS */ XClassHint hint = {.res_name = "utoxvideo", .res_class = "utoxvideo" }; XSetClassHint(display, *win, &hint); XMapWindow(display, *win); LOG_TRACE("Video", "new window %u" , id); } void video_end(uint16_t id) { Window *win = &video_win[id]; if (id == UINT16_MAX) { // Preview window win = &preview; } else if (id >= MAX_VID_WINDOWS) { LOG_TRACE("Video", "Window ID too large (>=%d)", MAX_VID_WINDOWS); return; } XDestroyWindow(display, *win); *win = None; LOG_NOTE("Video", "killed window %u" , id); } static Display *deskdisplay; static int deskscreen; XShmSegmentInfo shminfo; void initshm(void) { deskdisplay = XOpenDisplay(NULL); deskscreen = DefaultScreen(deskdisplay); LOG_TRACE("Video", "desktop: %u %u" , default_screen->width, default_screen->height); max_video_width = default_screen->width; max_video_height = default_screen->height; } uint16_t native_video_detect(void) { char dev_name[] = "/dev/videoXX", *first = NULL; uint16_t device_count = 1; /* start at 1 for the desktop input */ // Indicate that we support desktop capturing. utox_video_append_device((void *)1, 1, (void *)STR_VIDEO_IN_DESKTOP, 0); for (int i = 0; i != 64; i++) { /* TODO: magic numbers are bad mm'kay? */ snprintf(dev_name + 10, sizeof(dev_name) - 10, "%i", i); struct stat st; if (-1 == stat(dev_name, &st)) { continue; // LOG_TRACE("Video", "Cannot identify '%s': %d, %s" , dev_name, errno, strerror(errno)); // return 0; } if (!S_ISCHR(st.st_mode)) { continue; // LOG_TRACE("Video", "%s is no device" , dev_name); // return 0; } char *p = malloc(sizeof(void *) + sizeof(dev_name)), *pp = p + sizeof(void *); memcpy(p, &pp, sizeof(void *)); memcpy(p + sizeof(void *), dev_name, sizeof(dev_name)); if (!first) { first = pp; utox_video_append_device((void *)p, 0, p + sizeof(void *), 1); } else { utox_video_append_device((void *)p, 0, p + sizeof(void *), 0); } device_count++; } initshm(); return device_count; } static uint16_t video_x, video_y; bool native_video_init(void *handle) { if (isdesktop(handle)) { utox_v4l_fd = -1; GRAB_POS grab = grab_pos(); video_x = MIN(grab.dn_x, grab.up_x); video_y = MIN(grab.dn_y, grab.up_y); video_width = MAX(grab.dn_x, grab.up_x) - MIN(grab.dn_x, grab.up_x); video_height = MAX(grab.dn_y, grab.up_y) - MIN(grab.dn_y, grab.up_y); if (video_width & 1) { if (video_x & 1) { video_x--; } video_width++; } if (video_height & 1) { if (video_y & 1) { video_y--; } video_height++; } if (!(screen_image = XShmCreateImage(deskdisplay, DefaultVisual(deskdisplay, deskscreen), DefaultDepth(deskdisplay, deskscreen), ZPixmap, NULL, &shminfo, video_width, video_height))) { return false; } if ((shminfo.shmid = shmget(IPC_PRIVATE, screen_image->bytes_per_line * screen_image->height, IPC_CREAT | 0777)) < 0) { return false; } if ((shminfo.shmaddr = screen_image->data = (char *)shmat(shminfo.shmid, 0, 0)) == (char *)-1) { return false; } shminfo.readOnly = False; if (!XShmAttach(deskdisplay, &shminfo)) { return false; } return true; } return v4l_init(handle); } void native_video_close(void *handle) { if (isdesktop(handle)) { XShmDetach(deskdisplay, &shminfo); return; } v4l_close(); } bool native_video_startread(void) { if (utox_v4l_fd == -1) { return true; } return v4l_startread(); } bool native_video_endread(void) { if (utox_v4l_fd == -1) { return true; } return v4l_endread(); } int native_video_getframe(uint8_t *y, uint8_t *u, uint8_t *v, uint16_t width, uint16_t height) { if (utox_v4l_fd == -1) { static uint64_t lasttime; uint64_t t = get_time(); if (t - lasttime >= (uint64_t)1000 * 1000 * 1000 / 24) { XShmGetImage(deskdisplay, RootWindow(deskdisplay, deskscreen), screen_image, video_x, video_y, AllPlanes); if (width != video_width || height != video_height) { LOG_ERR("v4l", "width/height mismatch %u %u != %u %u", width, height, screen_image->width, screen_image->height); return 0; } bgrxtoyuv420(y, u, v, (uint8_t *)screen_image->data, screen_image->width, screen_image->height); lasttime = t; return 1; } return 0; } return v4l_getframe(y, u, v, width, height); } uTox/src/xlib/v4l.c0000600000175000001440000002255114003056216013101 0ustar rakusers#include "main.h" #include "../debug.h" #include "../macros.h" #include "../av/video.h" // video super globals #include #include #include #include #include #include #include int utox_v4l_fd = -1; #include #if defined(__linux__) || defined(__FreeBSD__) || defined(__kFreeBSD__) || defined(__DragonFly__) // FreeBSD and DragonFlyBSD will have the proper includes after installing v4l_compat #include #elif defined(__OpenBSD__) || defined(__NetBSD__) // OpenBSD and NetBSD have V4L in base #include #else #error "Unsupported platform for V4L" #endif #ifndef NO_V4LCONVERT #include #endif #define CLEAR(x) memset(&(x), 0, sizeof(x)) static int xioctl(int fh, unsigned long request, void *arg) { int r; do { r = ioctl(fh, request, arg); } while (-1 == r && EINTR == errno); return r; } struct buffer { void * start; size_t length; }; static struct buffer *buffers; static uint32_t n_buffers; #ifndef NO_V4LCONVERT static struct v4lconvert_data *v4lconvert_data; #endif static struct v4l2_format fmt, dest_fmt = { //.type = V4L2_BUF_TYPE_VIDEO_CAPTURE, .fmt = { .pix = { .pixelformat = V4L2_PIX_FMT_YUV420, //.field = V4L2_FIELD_NONE, }, }, }; bool v4l_init(char *dev_name) { utox_v4l_fd = open(dev_name, O_RDWR /* required */ | O_NONBLOCK, 0); if (-1 == utox_v4l_fd) { LOG_TRACE("v4l", "Cannot open '%s': %d, %s" , dev_name, errno, strerror(errno)); return 0; } struct v4l2_capability cap; struct v4l2_cropcap cropcap; struct v4l2_crop crop; unsigned int min; if (-1 == xioctl(utox_v4l_fd, VIDIOC_QUERYCAP, &cap)) { if (EINVAL == errno) { LOG_TRACE("v4l", "%s is no V4L2 device" , dev_name); } else { LOG_TRACE("v4l", "VIDIOC_QUERYCAP error %d, %s" , errno, strerror(errno)); } return 0; } if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { LOG_TRACE("v4l", "%s is no video capture device" , dev_name); return 0; } if (!(cap.capabilities & V4L2_CAP_STREAMING)) { LOG_TRACE("v4l", "%s does not support streaming i/o" , dev_name); return 0; } /* Select video input, video standard and tune here. */ CLEAR(cropcap); cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (0 == xioctl(utox_v4l_fd, VIDIOC_CROPCAP, &cropcap)) { crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; crop.c = cropcap.defrect; /* reset to default */ if (-1 == xioctl(utox_v4l_fd, VIDIOC_S_CROP, &crop)) { switch (errno) { case EINVAL: /* Cropping not supported. */ break; default: /* Errors ignored. */ break; } } } else { /* Errors ignored. */ } #ifndef NO_V4LCONVERT v4lconvert_data = v4lconvert_create(utox_v4l_fd); #endif CLEAR(fmt); fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (-1 == xioctl(utox_v4l_fd, VIDIOC_G_FMT, &fmt)) { LOG_TRACE("v4l", "VIDIOC_S_FMT error %d, %s" , errno, strerror(errno)); return 0; } /*if (fmt.fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV) { LOG_ERR("v4l", "Unsupported video format: %u %u %u %u\n", fmt.fmt.pix.width, fmt.fmt.pix.height, fmt.fmt.pix.pixelformat, fmt.fmt.pix.field); }*/ video_width = fmt.fmt.pix.width; video_height = fmt.fmt.pix.height; dest_fmt.fmt.pix.width = fmt.fmt.pix.width; dest_fmt.fmt.pix.height = fmt.fmt.pix.height; LOG_TRACE("v4l", "Video size: %u %u" , video_width, video_height); /* Buggy driver paranoia. */ min = fmt.fmt.pix.width * 2; if (fmt.fmt.pix.bytesperline < min) fmt.fmt.pix.bytesperline = min; min = fmt.fmt.pix.bytesperline * fmt.fmt.pix.height; if (fmt.fmt.pix.sizeimage < min) fmt.fmt.pix.sizeimage = min; /* part 3*/ // uint32_t buffer_size = fmt.fmt.pix.sizeimage; struct v4l2_requestbuffers req; CLEAR(req); req.count = 4; req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; req.memory = V4L2_MEMORY_MMAP; // V4L2_MEMORY_USERPTR; if (-1 == xioctl(utox_v4l_fd, VIDIOC_REQBUFS, &req)) { if (EINVAL == errno) { LOG_TRACE("v4l", "%s does not support x i/o" , dev_name); } else { LOG_TRACE("v4l", "VIDIOC_REQBUFS error %d, %s" , errno, strerror(errno)); } return 0; } if (req.count < 2) { LOG_FATAL_ERR(EXIT_MALLOC, "v4l", "Insufficient buffer memory on %s", dev_name); } buffers = calloc(req.count, sizeof(*buffers)); for (n_buffers = 0; n_buffers < req.count; ++n_buffers) { struct v4l2_buffer buf; CLEAR(buf); buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; buf.index = n_buffers; if (-1 == xioctl(utox_v4l_fd, VIDIOC_QUERYBUF, &buf)) { LOG_TRACE("v4l", "VIDIOC_QUERYBUF error %d, %s" , errno, strerror(errno)); return 0; } buffers[n_buffers].length = buf.length; buffers[n_buffers].start = mmap(NULL /* start anywhere */, buf.length, PROT_READ | PROT_WRITE /* required */, MAP_SHARED /* recommended */, utox_v4l_fd, buf.m.offset); if (MAP_FAILED == buffers[n_buffers].start) { LOG_TRACE("v4l", "mmap error %d, %s" , errno, strerror(errno)); return 0; } } /*buffers = calloc(4, sizeof(*buffers)); if (!buffers) { LOG_TRACE("v4l", "Out of memory" ); return 0; } for (n_buffers = 0; n_buffers < 4; ++n_buffers) { buffers[n_buffers].length = buffer_size; buffers[n_buffers].start = malloc(buffer_size); if (!buffers[n_buffers].start) { LOG_TRACE("v4l", "Out of memory" ); return 0; } }*/ return 1; } void v4l_close(void) { size_t i; for (i = 0; i < n_buffers; ++i) { if (-1 == munmap(buffers[i].start, buffers[i].length)) { LOG_TRACE("v4l", "munmap error" ); } } close(utox_v4l_fd); } bool v4l_startread(void) { LOG_TRACE("v4l", "start webcam" ); size_t i; enum v4l2_buf_type type; for (i = 0; i < n_buffers; ++i) { struct v4l2_buffer buf; CLEAR(buf); buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; // V4L2_MEMORY_USERPTR; buf.index = i; // buf.m.userptr = (unsigned long)buffers[i].start; // buf.length = buffers[i].length; if (-1 == xioctl(utox_v4l_fd, VIDIOC_QBUF, &buf)) { LOG_TRACE("v4l", "VIDIOC_QBUF error %d, %s" , errno, strerror(errno)); return 0; } } type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (-1 == xioctl(utox_v4l_fd, VIDIOC_STREAMON, &type)) { LOG_TRACE("v4l", "VIDIOC_STREAMON error %d, %s" , errno, strerror(errno)); return 0; } return 1; } bool v4l_endread(void) { LOG_TRACE("v4l", "stop webcam" ); enum v4l2_buf_type type; type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (-1 == xioctl(utox_v4l_fd, VIDIOC_STREAMOFF, &type)) { LOG_TRACE("v4l", "VIDIOC_STREAMOFF error %d, %s" , errno, strerror(errno)); return 0; } return 1; } int v4l_getframe(uint8_t *y, uint8_t *UNUSED(u), uint8_t *UNUSED(v), uint16_t width, uint16_t height) { if (width != video_width || height != video_height) { LOG_TRACE("V4L", "width/height mismatch %u %u != %u %u" , width, height, video_width, video_height); return 0; } struct v4l2_buffer buf; // unsigned int i; CLEAR(buf); buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; // V4L2_MEMORY_USERPTR; if (-1 == ioctl(utox_v4l_fd, VIDIOC_DQBUF, &buf)) { switch (errno) { case EINTR: case EAGAIN: return 0; case EIO: /* Could ignore EIO, see spec. */ /* fall through */ default: LOG_TRACE("v4l", "VIDIOC_DQBUF error %d, %s" , errno, strerror(errno)); return -1; } } /*for (i = 0; i < n_buffers; ++i) if (buf.m.userptr == (unsigned long)buffers[i].start && buf.length == buffers[i].length) break; if(i >= n_buffers) { LOG_TRACE("v4l", "fatal error" ); return 0; }*/ void *data = (void *)buffers[buf.index].start; // length = buf.bytesused //(void*)buf.m.userptr /* assumes planes are continuous memory */ #ifndef NO_V4LCONVERT int result = v4lconvert_convert(v4lconvert_data, &fmt, &dest_fmt, data, buf.bytesused, y, (video_width * video_height * 3) / 2); if (result == -1) { LOG_TRACE("v4l", "v4lconvert_convert error %s" , v4lconvert_get_error_message(v4lconvert_data)); } #else if (fmt.fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) { yuv422to420(y, u, v, data, video_width, video_height); } else { } #endif if (-1 == xioctl(utox_v4l_fd, VIDIOC_QBUF, &buf)) { LOG_TRACE("v4l", "VIDIOC_QBUF error %d, %s" , errno, strerror(errno)); } #ifndef NO_V4LCONVERT return (result == -1 ? 0 : 1); #else return 1; #endif } uTox/src/xlib/tray.h0000600000175000001440000000067514003056216013363 0ustar rakusers#ifndef XLIB_TRAY_H #define XLIB_TRAY_H #include "main.h" #include "window.h" #include #include #include #include // TODO fine the correct header for these, or consider an enum #define SYSTEM_TRAY_REQUEST_DOCK 0 #define SYSTEM_TRAY_BEGIN_MESSAGE 1 #define SYSTEM_TRAY_CANCEL_MESSAGE 2 void create_tray_icon(void); void destroy_tray_icon(void); bool tray_window_event(XEvent *event); #endif uTox/src/xlib/tray.c0000600000175000001440000002637414003056216013362 0ustar rakusers#include "tray.h" #include "window.h" #include "../debug.h" #include "../macros.h" #include "../native/image.h" #include "../native/ui.h" #include "../layout/tray.h" #include #include #include // Converted to a binary and linked at build time extern uint8_t _binary_icons_utox_128x128_png_start; extern uint8_t _binary_icons_utox_128x128_png_end; static void send_message(Display *dpy, /* display */ Window w, /* sender (tray window) */ long message, /* message opcode */ long data1, /* message data 1 */ long data2, /* message data 2 */ long data3 /* message data 3 */) { XEvent ev; memset(&ev, 0, sizeof(ev)); ev.xclient.type = ClientMessage; ev.xclient.window = w; ev.xclient.message_type = XInternAtom(dpy, "_NET_SYSTEM_TRAY_OPCODE", False); ev.xclient.format = 32; ev.xclient.data.l[0] = CurrentTime; ev.xclient.data.l[1] = message; ev.xclient.data.l[2] = data1; ev.xclient.data.l[3] = data2; ev.xclient.data.l[4] = data3; XSendEvent(dpy, w, False, NoEventMask, &ev); XSync(dpy, False); } struct native_window tray_window = { ._.x = 0, ._.y = 0, ._.w = 128u, ._.h = 128u, ._.next = NULL, ._.panel = NULL, .window = 0, .gc = 0, .visual = NULL, .drawbuf = 0, .renderpic = 0, .pictformat = NULL, }; static void tray_reposition(void) { LOG_NOTE("XLib Tray", "Reposition Tray"); uint32_t null; XGetGeometry(display, tray_window.window, &root_window, &tray_window._.x, &tray_window._.y, &tray_window._.w, &tray_window._.h, &null, &null); LOG_NOTE("XLib Tray", "New geometry x %u y %u w %u h %u", tray_window._.x, tray_window._.y, tray_window._.w, tray_window._.h); LOG_INFO("XLib Tray", "Setting to square"); tray_window._.w = tray_window._.h = MIN(tray_window._.w, tray_window._.h); XResizeWindow(display, tray_window.window, tray_window._.w, tray_window._.h); XFreePixmap(display, tray_window.drawbuf); tray_window.drawbuf = XCreatePixmap(display, tray_window.window, tray_window._.w, tray_window._.h, default_depth); XRenderFreePicture(display, tray_window.renderpic); tray_window.renderpic = XRenderCreatePicture(display, tray_window.drawbuf, tray_window.pictformat, 0, NULL); // XMoveResizeWindow(display, tray_window.window, tray_window._.x, tray_window._.y, // tray_window._.w, tray_window._.h); /* TODO use xcb instead of xlib here! xcb_get_geometry_cookie_t xcb_get_geometry (xcb_connection_t *connection, xcb_drawable_t drawable ); xcb_get_geometry_reply_t *xcb_get_geometry_reply (xcb_connection_t *connection, xcb_get_geometry_cookie_t cookie, xcb_generic_error_t **error); free (geom);*/ } static void draw_tray_icon(void) { LOG_NOTE("XLib Tray", "Draw Tray"); uint16_t width, height; uint8_t *icon_data = &_binary_icons_utox_128x128_png_start; size_t icon_size = &_binary_icons_utox_128x128_png_end - &_binary_icons_utox_128x128_png_start; NATIVE_IMAGE *icon = utox_image_to_native(icon_data, icon_size, &width, &height, 0); if (NATIVE_IMAGE_IS_VALID(icon)) { /* Get tray window size */ /* Resize the image from what the system tray dock tells us to be */ double scale = (tray_window._.w > tray_window._.h) ? (double)tray_window._.h / width : (double)tray_window._.w / height; image_set_scale(icon, scale); image_set_filter(icon, FILTER_BILINEAR); /* Draw the image and copy to the window */ XSetForeground(display, tray_window.gc, 0xFFFFFF); XFillRectangle(display, tray_window.drawbuf, tray_window.gc, 0, 0, tray_window._.w, tray_window._.h); /* TODO: copy method of grabbing background for tray from tray.c:tray_update_root_bg_pmap() (stalonetray) */ XRenderComposite(display, PictOpOver, icon->rgb, icon->alpha, tray_window.renderpic, 0, 0, 0, 0, 0, 0, tray_window._.w, tray_window._.h); XCopyArea(display, tray_window.drawbuf, tray_window.window, tray_window.gc, 0, 0, tray_window._.w, tray_window._.h, 0, 0); free(icon); } else { LOG_ERR("XLIB TRAY", "Tray no workie, that not gud!"); } } static void tray_xembed(XClientMessageEvent *ev) { LOG_NOTE("XEMBED Tray", "ClientMessage on display %u", ev->display); LOG_NOTE("XEMBED Tray", "Format (%i) as long %lu %lu parent window %lu proto version %lu %lu", ev->format, ev->data.l[0], ev->data.l[1], ev->data.l[2], ev->data.l[3], ev->data.l[4]); tray_reposition(); draw_tray_icon(); } void create_tray_icon(void) { LOG_NOTE("XLib Tray", "Create Tray Icon"); LOG_NOTE("XLib Tray", "Resolution %u %u", tray_window._.w, tray_window._.h); tray_window.window = XCreateSimpleWindow(display, RootWindow(display, def_screen_num), 0, 0, tray_window._.w, tray_window._.h, 0, BlackPixel(display, def_screen_num), WhitePixel(display, def_screen_num)); XSelectInput(display, tray_window.window, ExposureMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | StructureNotifyMask | FocusChangeMask | PropertyChangeMask); /* Get ready to draw a tray icon */ tray_window.gc = XCreateGC(display, root_window, 0, 0); tray_window.drawbuf = XCreatePixmap(display, tray_window.window, tray_window._.w, tray_window._.h, default_depth); XWindowAttributes attr; XGetWindowAttributes(display, root_window, &attr); // Todo, try and alloc on the stack for this XSizeHints *size_hints = XAllocSizeHints(); size_hints->flags = PSize | PBaseSize | PMinSize | PMaxSize; size_hints->base_width = tray_window._.w; size_hints->base_height = tray_window._.h; size_hints->min_width = 16; size_hints->min_height = 16; size_hints->max_width = tray_window._.w; size_hints->max_height = tray_window._.h; XSetWMNormalHints(display, tray_window.window, size_hints); XFree(size_hints); tray_window.pictformat = XRenderFindVisualFormat(display, attr.visual); tray_window.renderpic = XRenderCreatePicture(display, tray_window.drawbuf, tray_window.pictformat, 0, NULL); /* Send icon to the tray */ send_message(display, XGetSelectionOwner(display, XInternAtom(display, "_NET_SYSTEM_TRAY_S0", false)), SYSTEM_TRAY_REQUEST_DOCK, tray_window.window, 0, 0); /* Draw the tray */ draw_tray_icon(); } void destroy_tray_icon(void) { XDestroyWindow(display, tray_window.window); } bool tray_window_event(XEvent *event) { if (event->xany.window != tray_window.window) { LOG_WARN("TRAY", "in %u ours %u", event->xany.window, tray_window.window); return false; } switch (event->type) { case Expose: { LOG_NOTE("XLib Tray", "Expose"); draw_tray_icon(); return true; } case NoExpose: { LOG_INFO("XLib Tray", "NoExpose"); return true; } case ClientMessage: { XClientMessageEvent msg = event->xclient; if (msg.message_type == XInternAtom(msg.display, "_XEMBED", true)) { tray_xembed(&msg); return true; } char *name = XGetAtomName(msg.display, msg.message_type); LOG_ERR("XLib Tray", "ClientMessage send_event %u display %u atom %u -- %s", msg.send_event, msg.display, msg.message_type, name); LOG_WARN("XLib Tray", "Format (%i) as long %lu %lu %lu %lu %lu", msg.format, msg.data.l[0], msg.data.l[1], msg.data.l[2], msg.data.l[3], msg.data.l[4]); return true; } case ConfigureNotify: { LOG_NOTE("XLib Tray", "Tray configure event"); XConfigureEvent *ev = &event->xconfigure; tray_window._.x = ev->x; tray_window._.y = ev->y; if (tray_window._.w != (unsigned)ev->width || tray_window._.h != (unsigned)ev->height) { LOG_NOTE("Tray", "Tray resized w:%i h:%i\n", ev->width, ev->height); if ((unsigned)ev->width > tray_window._.w || (unsigned)ev->height > tray_window._.h) { tray_window._.w = ev->width; tray_window._.h = ev->height; XFreePixmap(ev->display, tray_window.drawbuf); tray_window.drawbuf = XCreatePixmap(ev->display, tray_window.window, tray_window._.w, tray_window._.h, 24); // TODO get default_depth from X not code XRenderFreePicture(ev->display, tray_window.renderpic); tray_window.renderpic = XRenderCreatePicture(ev->display, tray_window.drawbuf, XRenderFindStandardFormat(ev->display, PictStandardRGB24), 0, NULL); } tray_window._.w = ev->width; tray_window._.h = ev->height; draw_tray_icon(); } return true; } case ButtonPress: { LOG_INFO("XLib Tray", "ButtonPress"); // Can't ignore this if you want mup -_- SRSLY Xlib? return true; } case ButtonRelease: { LOG_INFO("XLib Tray", "ButtonRelease"); XButtonEvent *ev = &event->xbutton; switch (ev->button) { case Button1: { togglehide(); break; } case Button3: { LOG_WARN("XLib Tray", "Button 3 %i %i", ev->x_root, ev->y_root); native_window_create_traypop(ev->x_root, ev->y_root, 300, 60, &panel_tray); } } return true; } case MapNotify: { LOG_INFO("XLib Tray", "MapNotify"); return true; } case FocusIn: { LOG_INFO("XLib Tray", "FocusIn"); return true; } case FocusOut: { LOG_INFO("XLib Tray", "FocusOut"); return true; } case EnterNotify: { LOG_INFO("XLib Tray", "EnterNotify"); return true; } case LeaveNotify: { LOG_INFO("XLib Tray", "LeaveNotify"); return true; } case ReparentNotify: { LOG_WARN("XLib Tray", "ReparentNotify"); return true; } default: { LOG_ERR("XLib Tray", "Incoming tray window event (%u)", event->type); break; } } LOG_ERR("XLib tray", "Reached end of function, this is bad juju!"); return false; } uTox/src/xlib/screen_grab.h0000600000175000001440000000043414003056216014647 0ustar rakusers#ifndef XLIB_SCREEN_GRAB_H #define XLIB_SCREEN_GRAB_H #include typedef struct { int dn_x, dn_y; int up_x, up_y; } GRAB_POS; void grab_dn(int x, int y); void grab_up(int x, int y); GRAB_POS grab_pos(void); void native_screen_grab_desktop(bool video); #endif uTox/src/xlib/screen_grab.c0000600000175000001440000000106614003056216014644 0ustar rakusers#include "screen_grab.h" #include "main.h" #include "window.h" #include "../ui.h" GRAB_POS grab; void grab_dn(int x, int y) { grab.dn_x = x; grab.dn_y = y; } void grab_up(int x, int y) { grab.up_x = x; grab.up_y = y; } GRAB_POS grab_pos(void) { return grab; } void native_screen_grab_desktop(bool video) { pointergrab = 1 + video; XGrabPointer(display, main_window.window, False, Button1MotionMask | ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, cursors[CURSOR_SELECT], CurrentTime); } uTox/src/xlib/mmenu.h0000600000175000001440000000062114003056216013514 0ustar rakusers#ifndef MMENU_H #define MMENU_H #ifdef UNITY #include "xlib/mmenu.h" extern bool unity_running; #endif /* Function which removes an entry from the messaging menu * Is called by xlib/{list,event}.c and takes in parameter a friend ID */ void mm_rm_entry(uint8_t *f_id); /* Function which sets the user status in the messaging menu * Is called by the ui */ void mm_set_status(int status); #endif uTox/src/xlib/mmenu.c0000600000175000001440000001123214003056216013507 0ustar rakusers#ifdef UNITY #include "../self.h" #include #include MessagingMenuApp * mmapp; UnityLauncherEntry *launcher; GMainLoop * mmloop; bool unity_running; char f_name_data[TOX_MAX_NAME_LENGTH] = ""; char f_id_data[TOX_PUBLIC_KEY_SIZE * 2 + 1] = ""; char f_id_data_on_minimize[TOX_PUBLIC_KEY_SIZE * 2 + 1] = ""; uint_fast32_t unread_friends = 0; // Checks if the current desktop is unity bool is_unity_running() { if (strcmp(getenv("XDG_CURRENT_DESKTOP"), "Unity") == 0) { return 1; } else { return 0; } } // Runs the main event loop void run_mmloop() { g_main_loop_run(mmloop); } // Function called once the user presses an entry in the MessagingMenu static void source_activated(MessagingMenuApp *mmapp_, const gchar *source_id, gpointer user_data) { // TODO } // Sets the user status in the Messaging Menu void mm_set_status(int status) { switch (status) { case 0: messaging_menu_app_set_status(mmapp, MESSAGING_MENU_STATUS_AVAILABLE); break; case 1: messaging_menu_app_set_status(mmapp, MESSAGING_MENU_STATUS_AWAY); break; case 2: messaging_menu_app_set_status(mmapp, MESSAGING_MENU_STATUS_BUSY); break; } } // Function called once the user changes its status in the MessagingMenu static void status_changed(MessagingMenuApp *mmapp_, gint status, gpointer user_data) { switch (status) { case MESSAGING_MENU_STATUS_AVAILABLE: self.status = 0; postmessage_toxcore(TOX_SETSTATUS, 0, 0, NULL); break; case MESSAGING_MENU_STATUS_AWAY: self.status = 1; postmessage_toxcore(TOX_SETSTATUS, 1, 0, NULL); break; case MESSAGING_MENU_STATUS_BUSY: self.status = 2; postmessage_toxcore(TOX_SETSTATUS, 2, 0, NULL); break; default: self.status = 1; postmessage_toxcore(TOX_SETSTATUS, 1, 0, NULL); break; } drawalpha(BM_ONLINE + status, SELF_STATUS_X + BM_STATUSAREA_WIDTH / 2 - BM_STATUS_WIDTH / 2, SELF_STATUS_Y + BM_STATUSAREA_HEIGHT / 2 - BM_STATUS_WIDTH / 2, BM_STATUS_WIDTH, BM_STATUS_WIDTH, status_color[status]); } // Registers the app in the Unity Messaging Menu void mm_register() { mmapp = messaging_menu_app_new("utox.desktop"); launcher = unity_launcher_entry_get_for_desktop_id("utox.desktop"); messaging_menu_app_register(mmapp); g_signal_connect(mmapp, "activate-source", G_CALLBACK(source_activated), NULL); g_signal_connect(mmapp, "status-changed", G_CALLBACK(status_changed), NULL); mmloop = g_main_loop_new(NULL, FALSE); thread(run_mmloop, NULL); } // Unregisters the app from the Unity Messaging Menu void mm_unregister() { messaging_menu_app_unregister(mmapp); g_object_unref(mmapp); g_main_loop_unref(mmloop); } // Saves the current user ID when minimized void mm_save_cid() { strcpy((char *)f_id_data_on_minimize, (char *)f_id_data); } // Checks if a user is in the Messaging Menu bool is_in_mm(uint8_t *f_id) { if (f_id == NULL) { strcpy((char *)f_id_data, (char *)f_id_data_on_minimize); } else { cid_to_string(f_id_data, f_id); f_id_data[TOX_PUBLIC_KEY_SIZE * 2] = '\0'; } if (f_id_data[0] != '\0') { if (messaging_menu_app_has_source(mmapp, (gchar *)f_id_data)) { return 1; } } return 0; } // Adds an entry to the MessagingMenu gboolean add_source() { messaging_menu_app_append_source(mmapp, (gchar *)f_id_data, NULL, (gchar *)f_name_data); messaging_menu_app_draw_attention(mmapp, (gchar *)f_id_data); unread_friends++; unity_launcher_entry_set_count(launcher, unread_friends); if (unread_friends == 1) { unity_launcher_entry_set_count_visible(launcher, TRUE); } return FALSE; } // Adds a new notification to the Messaging Menu. void mm_notify(char *f_name, uint8_t *f_id) { if (!is_in_mm(f_id)) { strncpy((char *)f_name_data, (char *)f_name, TOX_MAX_NAME_LENGTH); g_idle_add(add_source, NULL); } } // Removes a source from the MessagingMenu gboolean remove_source() { messaging_menu_app_remove_source(mmapp, (gchar *)f_id_data); unread_friends--; unity_launcher_entry_set_count(launcher, unread_friends); if (unread_friends == 0) { unity_launcher_entry_set_count_visible(launcher, FALSE); } return FALSE; } // Removes a notification from the Messaging Menu. void mm_rm_entry(uint8_t *f_id) { if (is_in_mm(f_id)) { g_idle_add(remove_source, NULL); } } #endif uTox/src/xlib/main.h0000600000175000001440000000435314003056216013325 0ustar rakusers#if defined(MAIN_H) && !defined(XLIB_MAIN_H) #error "We should never include main from different platforms." #endif #ifndef XLIB_MAIN_H #define XLIB_MAIN_H #define MAIN_H #ifdef HAVE_DBUS #include "dbus.h" #endif #include "../ui/svg.h" #include #include #include #include #include #include #include #include typedef struct native_image NATIVE_IMAGE; struct native_image { // This is really a Picture, but it is just a typedef for XID, and I didn't // want to clutter namespace with #include for it. XID rgb; XID alpha; }; extern Atom wm_protocols, wm_delete_window; extern Atom XA_CLIPBOARD, XA_NET_NAME, XA_UTF8_STRING, targets, XA_INCR; extern Atom XdndAware, XdndEnter, XdndLeave, XdndPosition, XdndStatus, XdndDrop, XdndSelection, XdndDATA, XdndActionCopy; extern Atom XA_URI_LIST, XA_PNG_IMG; extern Atom XRedraw; extern Picture bitmap[BM_ENDMARKER]; extern Cursor cursors[8]; /* Screen grab vars */ extern uint8_t pointergrab; extern bool _redraw; extern XImage *screen_image; extern int utox_v4l_fd; /* dynamically load libgtk */ extern void *libgtk; extern struct utox_clipboard { int len; char data[UINT16_MAX]; // TODO: De-hardcode this value. } clipboard; extern struct utox_primary { int len; char data[UINT16_MAX]; // TODO: De-hardcode this value. } primary; extern struct utox_pastebuf { int len, left; Atom type; char *data; } pastebuf; Picture ximage_to_picture(XImage *img, const XRenderPictFormat *format); bool doevent(XEvent *event); void togglehide(void); void pasteprimary(void); void setclipboard(void); void pastebestformat(const Atom atoms[], size_t len, Atom selection); void formaturilist(char *out, const char *in, size_t len); void pastedata(void *data, Atom type, size_t len, bool select); // Brute Force, the video window we got a close command on (xlib/video.c) uint16_t find_video_windows(Window w); // video4linux bool v4l_init(char *dev_name); void v4l_close(void); bool v4l_startread(void); bool v4l_endread(void); int v4l_getframe(uint8_t *y, uint8_t *u, uint8_t *v, uint16_t width, uint16_t height); #endif uTox/src/xlib/main.c0000600000175000001440000006750514003056216013330 0ustar rakusers#include "main.h" #include "dbus.h" #include "freetype.h" #include "gtk.h" #include "tray.h" #include "window.h" #include "../avatar.h" #include "../debug.h" #include "../filesys.h" #include "../flist.h" #include "../friend.h" #include "../macros.h" #include "../main.h" // MAIN_WIDTH, MAIN_WIDTH, parse_args, utox_init #include "../settings.h" #include "../text.h" #include "../theme.h" #include "../tox.h" #include "../utox.h" #include "../av/utox_av.h" #include "../native/image.h" #include "../native/notify.h" #include "../native/ui.h" #include "../ui/draw.h" #include "../ui/edit.h" #include "../layout/background.h" #include "../layout/friend.h" #include "../layout/group.h" #include "../layout/settings.h" #include "stb.h" #include #include #include #include #include #include Atom wm_protocols, wm_delete_window; Atom XA_CLIPBOARD, XA_NET_NAME, XA_UTF8_STRING, targets, XA_INCR; Atom XdndAware, XdndEnter, XdndLeave, XdndPosition, XdndStatus, XdndDrop, XdndSelection, XdndDATA, XdndActionCopy; Atom XA_URI_LIST, XA_PNG_IMG; Atom XRedraw; Picture bitmap[BM_ENDMARKER]; Cursor cursors[8]; uint8_t pointergrab; bool _redraw; XImage *screen_image; void *libgtk; struct utox_clipboard clipboard; struct utox_primary primary; struct utox_pastebuf pastebuf; static bool hidden = false; XIC xic = NULL; static XSizeHints *xsh = NULL; static bool shutdown = false; void setclipboard(void) { XSetSelectionOwner(display, XA_CLIPBOARD, main_window.window, CurrentTime); } void postmessage_utox(UTOX_MSG msg, uint16_t param1, uint16_t param2, void *data) { XEvent event = { .xclient = { .window = 0, .type = ClientMessage, .message_type = msg, .format = 8, .data = { .s = { param1, param2 } } } }; memcpy(&event.xclient.data.s[2], &data, sizeof(void *)); XSendEvent(display, main_window.window, False, 0, &event); XFlush(display); } static FILE * ptt_keyboard_handle; static Display *ptt_display; void init_ptt(void) { settings.push_to_talk = 1; char path[UTOX_FILE_NAME_LENGTH]; snprintf(path, UTOX_FILE_NAME_LENGTH, "%s/.config/tox/ppt-kbd", getenv("HOME")); // TODO DRY ptt_keyboard_handle = fopen((const char *)path, "r"); if (!ptt_keyboard_handle) { LOG_TRACE("XLIB", "Could not access ptt-kbd in data directory" ); ptt_display = XOpenDisplay(0); XSynchronize(ptt_display, True); } } #if defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) #include #endif #if defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) static bool linux_check_ptt(void) { /* First, we try for direct access to the keyboard. */ int ptt_key = KEY_LEFTCTRL; // TODO allow user to change this... if (ptt_keyboard_handle) { /* Nice! we have direct access to the keyboard! */ char key_map[KEY_MAX / 8 + 1]; // Create a byte array the size of the number of keys memset(key_map, 0, sizeof(key_map)); ioctl(fileno(ptt_keyboard_handle), EVIOCGKEY(sizeof(key_map)), key_map); // Fill the keymap with the current // keyboard state int keyb = key_map[ptt_key / 8]; // The key we want (and the seven others around it) int mask = 1 << (ptt_key % 8); // Put 1 in the same column as our key state if (keyb & mask) { LOG_TRACE("XLIB", "PTT key is down" ); return true; } else { LOG_TRACE("XLIB", "PTT key is up" ); return false; } } /* Okay nope, let's fallback to xinput... *pouts* * Fall back to Querying the X for the current keymap. */ ptt_key = XKeysymToKeycode(display, XK_Control_L); char keys[32] = { 0 }; /* We need our own connection, so that we don't block the main display... No idea why... */ if (ptt_display) { XQueryKeymap(ptt_display, keys); if (keys[ptt_key / 8] & (0x1 << (ptt_key % 8))) { LOG_TRACE("XLIB", "PTT key is down (according to XQueryKeymap" ); return true; } else { LOG_TRACE("XLIB", "PTT key is up (according to XQueryKeymap" ); return false; } } /* Couldn't access the keyboard directly, and XQuery failed, this is really bad! */ LOG_ERR("XLIB", "Unable to access keyboard, you need to read the manual on how to enable utox to\nhave access to your " "keyboard.\nDisable push to talk to suppress this message.\n"); return false; } #else static bool bsd_check_ptt(void) { return false; } #endif bool check_ptt_key(void) { if (!settings.push_to_talk) { // LOG_TRACE("XLIB", "PTT is disabled" ); return true; /* If push to talk is disabled, return true. */ } #if defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) return linux_check_ptt(); #else return bsd_check_ptt(); #endif } void exit_ptt(void) { if (ptt_keyboard_handle) { fclose(ptt_keyboard_handle); } if (ptt_display) { XCloseDisplay(ptt_display); } settings.push_to_talk = 0; } void image_set_scale(NATIVE_IMAGE *image, double scale) { uint32_t r = (uint32_t)(65536.0 / scale); /* transformation matrix to scale image */ XTransform trans = { { { r, 0, 0 }, { 0, r, 0 }, { 0, 0, 65536 } } }; XRenderSetPictureTransform(display, image->rgb, &trans); if (image->alpha) { XRenderSetPictureTransform(display, image->alpha, &trans); } } void image_set_filter(NATIVE_IMAGE *image, uint8_t filter) { const char *xfilter; switch (filter) { case FILTER_NEAREST: xfilter = FilterNearest; break; case FILTER_BILINEAR: xfilter = FilterBilinear; break; default: LOG_TRACE("XLIB", "Warning: Tried to set image to unrecognized filter(%u)." , filter); return; } XRenderSetPictureFilter(display, image->rgb, xfilter, NULL, 0); if (image->alpha) { XRenderSetPictureFilter(display, image->alpha, xfilter, NULL, 0); } } void thread(void *func(void *), void *args) { pthread_t thread_temp; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 1 << 20); pthread_create(&thread_temp, &attr, func, args); pthread_attr_destroy(&attr); } void yieldcpu(uint32_t ms) { usleep(1000 * ms); } uint64_t get_time(void) { struct timespec ts; #ifdef CLOCK_MONOTONIC_RAW clock_gettime(CLOCK_MONOTONIC_RAW, &ts); #else clock_gettime(CLOCK_MONOTONIC, &ts); #endif return ((uint64_t)ts.tv_sec * (1000 * 1000 * 1000)) + (uint64_t)ts.tv_nsec; } void openurl(char *str) { if (try_open_tox_uri(str)) { redraw(); return; } char *cmd = "xdg-open"; if (!fork()) { execlp(cmd, cmd, str, (char *)0); exit(127); } waitpid(-1, NULL, WNOHANG); /* reap last child */ } void openfilesend(void) { if (libgtk) { ugtk_openfilesend(); } } void openfileavatar(void) { if (libgtk) { ugtk_openfileavatar(); } } void setselection(char *data, uint16_t length) { if (!length) { return; } memcpy(primary.data, data, length); primary.len = length; XSetSelectionOwner(display, XA_PRIMARY, main_window.window, CurrentTime); } /** Toggles the main window to/from hidden to tray/shown. */ void togglehide(void) { if (hidden) { XMoveWindow(display, main_window.window, main_window._.x, main_window._.y); XMapWindow(display, main_window.window); redraw(); hidden = 0; } else { XWithdrawWindow(display, main_window.window, def_screen_num); hidden = 1; } } void pasteprimary(void) { Window owner = XGetSelectionOwner(display, XA_PRIMARY); if (owner) { XConvertSelection(display, XA_PRIMARY, XA_UTF8_STRING, targets, main_window.window, CurrentTime); } } void copy(int value) { int len; if (edit_active()) { len = edit_copy((char *)clipboard.data, sizeof(clipboard.data)); } else if (flist_get_sel_friend()) { len = messages_selection(&messages_friend, clipboard.data, sizeof(clipboard.data), value); } else if (flist_get_sel_group()) { len = messages_selection(&messages_group, clipboard.data, sizeof(clipboard.data), value); } else { LOG_ERR("XLIB", "Copy from Unsupported flist type."); return; } if (len) { clipboard.len = len; setclipboard(); } } int hold_x11s_hand(Display *UNUSED(d), XErrorEvent *event) { LOG_ERR("XLIB", "X11 err:\tX11 tried to kill itself, so I hit him with a shovel."); LOG_ERR("XLIB", " err:\tResource: %lu || Serial %lu", event->resourceid, event->serial); LOG_ERR("XLIB", " err:\tError code: %u || Request: %u || Minor: %u", event->error_code, event->request_code, event->minor_code); LOG_ERR("uTox", "This would be a great time to submit a bug!"); return 0; } void paste(void) { Window owner = XGetSelectionOwner(display, XA_CLIPBOARD); /* Ask owner for supported types */ if (owner) { XEvent event = { .xselectionrequest = { .type = SelectionRequest, .send_event = True, .display = display, .owner = owner, .requestor = main_window.window, .target = targets, .selection = XA_CLIPBOARD, .property = XA_ATOM, .time = CurrentTime } }; XSendEvent(display, owner, 0, NoEventMask, &event); XFlush(display); } } void pastebestformat(const Atom atoms[], size_t len, Atom selection) { XSetErrorHandler(hold_x11s_hand); const Atom supported[] = { XA_PNG_IMG, XA_URI_LIST, XA_UTF8_STRING }; size_t i, j; for (i = 0; i < len; i++) { char *name = XGetAtomName(display, atoms[i]); if (name) { LOG_TRACE("XLIB", "Supported type: %s" , name); } else { LOG_TRACE("XLIB", "Unsupported type!!: Likely a bug, please report!" ); } } for (i = 0; i < len; i++) { for (j = 0; j < COUNTOF(supported); j++) { if (atoms[i] == supported[j]) { XConvertSelection(display, selection, supported[j], targets, main_window.window, CurrentTime); return; } } } } static bool ishexdigit(char c) { c = toupper(c); return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F'); } static char hexdecode(char upper, char lower) { upper = toupper(upper); lower = toupper(lower); return (upper >= 'A' ? upper - 'A' + 10 : upper - '0') * 16 + (lower >= 'A' ? lower - 'A' + 10 : lower - '0'); } void formaturilist(char *out, const char *in, size_t len) { size_t i, removed = 0, start = 0; for (i = 0; i < len; i++) { // Replace CRLF with LF if (in[i] == '\r') { memcpy(out + start - removed, in + start, i - start); start = i + 1; removed++; } else if (in[i] == '%' && i + 2 < len && ishexdigit(in[i + 1]) && ishexdigit(in[i + 2])) { memcpy(out + start - removed, in + start, i - start); out[i - removed] = hexdecode(in[i + 1], in[i + 2]); start = i + 3; removed += 2; } } if (start != len) { memcpy(out + start - removed, in + start, len - start); } out[len - removed] = 0; // out[len - removed - 1] = '\n'; } // TODO(robinli): Go over this function and see if either len or size are removable. void pastedata(void *data, Atom type, size_t len, bool select) { size_t size = len; if (type == XA_PNG_IMG) { FRIEND *f = flist_get_sel_friend(); if (!f) { LOG_ERR("XLIB", "Can't paste data to missing friend."); return; } uint16_t width, height; NATIVE_IMAGE *native_image = utox_image_to_native(data, size, &width, &height, 0); if (NATIVE_IMAGE_IS_VALID(native_image)) { LOG_INFO("XLIB MAIN", "Pasted image: %dx%d", width, height); UTOX_IMAGE png_image = malloc(size); if (!png_image){ LOG_ERR("XLIB", "Could not allocate memory for an image"); free(native_image); return; } memcpy(png_image, data, size); friend_sendimage(f, native_image, width, height, png_image, size); } } else if (type == XA_URI_LIST) { FRIEND *f = flist_get_sel_friend(); if (!f) { LOG_ERR("XLIB", "Can't paste data to missing friend."); return; } char *path = malloc(len + 1); if (!path) { LOG_ERR("XLIB", "Could not allocate memory for path."); return; } formaturilist(path, (char *)data, len); postmessage_toxcore(TOX_FILE_SEND_NEW, f->number, 0xFFFF, path); } else if (type == XA_UTF8_STRING && edit_active()) { edit_paste(data, len, select); } } // converts an XImage to a Picture usable by XRender, uses XRenderPictFormat given by // 'format', uses the default format if it is NULL Picture ximage_to_picture(XImage *img, const XRenderPictFormat *format) { Pixmap pixmap = XCreatePixmap(display, main_window.window, img->width, img->height, img->depth); GC legc = XCreateGC(display, pixmap, 0, NULL); XPutImage(display, pixmap, legc, img, 0, 0, 0, 0, img->width, img->height); if (format == NULL) { format = XRenderFindVisualFormat(display, default_visual); } Picture picture = XRenderCreatePicture(display, pixmap, format, 0, NULL); XFreeGC(display, legc); XFreePixmap(display, pixmap); return picture; } void loadalpha(int bm, void *data, int width, int height) { if (bm < 0){ LOG_ERR("XLIB", "Can not get object from array. Index %d", bm); return; } XImage *img = XCreateImage(display, CopyFromParent, 8, ZPixmap, 0, data, width, height, 8, 0); // create picture that only holds alpha values // NOTE: the XImage made earlier should really be freed, but calling XDestroyImage on it will also // automatically free the data it's pointing to(which we don't want), so there's no easy way to destroy them // currently bitmap[bm] = ximage_to_picture(img, XRenderFindStandardFormat(display, PictStandardA8)); } /* generates an alpha bitmask based on the alpha channel in given rgba_data * returned picture will have 1 byte for each pixel, and have the same width and height as input */ static Picture generate_alpha_bitmask(const uint8_t *rgba_data, uint16_t width, uint16_t height, uint32_t rgba_size) { // we don't need to free this, that's done by XDestroyImage() uint8_t *out = malloc(rgba_size / 4); uint32_t i, j; for (i = j = 0; i < rgba_size; i += 4, j++) { out[j] = (rgba_data + i)[3] & 0xFF; // take only alpha values } // create 1-byte-per-pixel image and convert it to a Alpha-format Picture XImage *img = XCreateImage(display, CopyFromParent, 8, ZPixmap, 0, (char *)out, width, height, 8, width); Picture picture = ximage_to_picture(img, XRenderFindStandardFormat(display, PictStandardA8)); XDestroyImage(img); return picture; } /* Swaps out the PNG color order for the native color order */ static void native_color_mask(uint8_t *data, uint32_t size, uint32_t mask_red, uint32_t mask_blue, uint32_t mask_green) { uint8_t red, blue, green; uint32_t *dest; for (uint32_t i = 0; i < size; i += 4) { red = (data + i)[0] & 0xFF; green = (data + i)[1] & 0xFF; blue = (data + i)[2] & 0xFF; dest = (uint32_t*)(data + i); *dest = (red | (red << 8) | (red << 16) | (red << 24)) & mask_red; *dest |= (blue | (blue << 8) | (blue << 16) | (blue << 24)) & mask_blue; *dest |= (green | (green << 8) | (green << 16) | (green << 24)) & mask_green; } } NATIVE_IMAGE *utox_image_to_native(const UTOX_IMAGE data, size_t size, uint16_t *w, uint16_t *h, bool keep_alpha) { int width, height, bpp; uint8_t *rgba_data = stbi_load_from_memory(data, size, &width, &height, &bpp, 4); // we don't need to free this, that's done by XDestroyImage() if (rgba_data == NULL || width == 0 || height == 0) { return None; // invalid png data } uint32_t rgba_size = width * height * 4; Picture alpha = (bpp == 4 && keep_alpha) ? generate_alpha_bitmask(rgba_data, width, height, rgba_size) : None; native_color_mask(rgba_data, rgba_size, default_visual->red_mask, default_visual->blue_mask, default_visual->green_mask); XImage *img = XCreateImage(display, default_visual, default_depth, ZPixmap, 0, (char *)rgba_data, width, height, 32, width * 4); Picture rgb = ximage_to_picture(img, NULL); XDestroyImage(img); *w = width; *h = height; NATIVE_IMAGE *image = malloc(sizeof(NATIVE_IMAGE)); if (image == NULL) { LOG_ERR("utox_image_to_native", "Could not allocate memory for image." ); return NULL; } image->rgb = rgb; image->alpha = alpha; return image; } void image_free(NATIVE_IMAGE *image) { if (!image) { return; } XRenderFreePicture(display, image->rgb); if (image->alpha) { XRenderFreePicture(display, image->alpha); } free(image); } /** Sets file system permissions to something slightly safer. * * returns 0 and 1 on success and failure. */ int ch_mod(uint8_t *file) { return chmod((char *)file, S_IRUSR | S_IWUSR); } void flush_file(FILE *file) { fflush(file); int fd = fileno(file); fsync(fd); } void setscale(void) { unsigned int i; for (i = 0; i != COUNTOF(bitmap); i++) { if (bitmap[i]) { XRenderFreePicture(display, bitmap[i]); } } svg_draw(0); if (xsh) { XFree(xsh); } // TODO, fork this to a function xsh = XAllocSizeHints(); xsh->flags = PMinSize; xsh->min_width = SCALE(MAIN_WIDTH); xsh->min_height = SCALE(MAIN_HEIGHT); XSetWMNormalHints(display, main_window.window, xsh); if (settings.window_width > (uint32_t)SCALE(MAIN_WIDTH) && settings.window_height > (uint32_t)SCALE(MAIN_HEIGHT)) { /* won't get a resize event, call this manually */ ui_size(settings.window_width, settings.window_height); } } void setscale_fonts(void) { freefonts(); loadfonts(); font_small_lineheight = (font[FONT_TEXT].info[0].face->size->metrics.height + (1 << 5)) >> 6; // font_msg_lineheight = (font[FONT_MSG].info[0].face->size->metrics.height + (1 << 5)) >> 6; } void notify(char *title, uint16_t UNUSED(title_length), const char *msg, uint16_t msg_length, void *object, bool is_group) { if (have_focus) { return; } uint8_t *f_cid = NULL; if (is_group) { // GROUPCHAT *obj = object; } else { FRIEND *obj = object; if (friend_has_avatar(obj)) { f_cid = obj->id_bin; } } XWMHints hints = {.flags = 256 }; XSetWMHints(display, main_window.window, &hints); #ifdef HAVE_DBUS char *str = tohtml(msg, msg_length); dbus_notify(title, str, f_cid); free(str); #else (void)title; // I don't like this either, but this is all going away soon! (void)msg; (void)msg_length; #endif #ifdef UNITY if (unity_running) { mm_notify(obj->name, f_cid); } #else (void)f_cid; #endif } void showkeyboard(bool UNUSED(show)) {} void edit_will_deactivate(void) {} void update_tray(void) {} static void atom_init(void) { wm_protocols = XInternAtom(display, "WM_PROTOCOLS", 0); wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", 0); XA_CLIPBOARD = XInternAtom(display, "CLIPBOARD", 0); XA_NET_NAME = XInternAtom(display, "_NET_WM_NAME", 0); XA_UTF8_STRING = XInternAtom(display, "UTF8_STRING", 1); if (XA_UTF8_STRING == None) { XA_UTF8_STRING = XA_STRING; } targets = XInternAtom(display, "TARGETS", 0); XA_INCR = XInternAtom(display, "INCR", false); XdndAware = XInternAtom(display, "XdndAware", false); XdndEnter = XInternAtom(display, "XdndEnter", false); XdndLeave = XInternAtom(display, "XdndLeave", false); XdndPosition = XInternAtom(display, "XdndPosition", false); XdndStatus = XInternAtom(display, "XdndStatus", false); XdndDrop = XInternAtom(display, "XdndDrop", false); XdndSelection = XInternAtom(display, "XdndSelection", false); XdndDATA = XInternAtom(display, "XdndDATA", false); XdndActionCopy = XInternAtom(display, "XdndActionCopy", false); XA_URI_LIST = XInternAtom(display, "text/uri-list", false); XA_PNG_IMG = XInternAtom(display, "image/png", false); XRedraw = XInternAtom(display, "XRedraw", false); } static void cursors_init(void) { cursors[CURSOR_NONE] = XCreateFontCursor(display, XC_left_ptr); cursors[CURSOR_HAND] = XCreateFontCursor(display, XC_hand2); cursors[CURSOR_TEXT] = XCreateFontCursor(display, XC_xterm); cursors[CURSOR_SELECT] = XCreateFontCursor(display, XC_crosshair); cursors[CURSOR_ZOOM_IN] = XCreateFontCursor(display, XC_target); cursors[CURSOR_ZOOM_OUT] = XCreateFontCursor(display, XC_target); } static void signal_handler(int signal) { LOG_INFO("XLIB MAIN", "Got signal: %s (%i)", strsignal(signal), signal); shutdown = true; } #include "../ui/dropdown.h" // this is for dropdown.language TODO provide API int main(int argc, char *argv[]) { if (!XInitThreads()) { LOG_FATAL_ERR(EXIT_FAILURE, "XLIB MAIN", "XInitThreads failed."); } if (!native_window_init()) { return 2; } initfonts(); #ifdef HAVE_DBUS LOG_INFO("XLIB MAIN", "Compiled with dbus support!"); #endif int8_t should_launch_at_startup; int8_t set_show_window; bool allow_root; parse_args(argc, argv, &should_launch_at_startup, &set_show_window, &allow_root); if (getuid() == 0 && !allow_root){ LOG_FATAL_ERR(EXIT_FAILURE, "XLIB MAIN", "You can't run uTox as root unless --allow-root is set."); } // We need to parse_args before calling utox_init() utox_init(); if (should_launch_at_startup == 1 || should_launch_at_startup == -1) { LOG_NOTE("XLIB", "Start on boot not supported on this OS, please use your distro suggested method!\n"); } LOG_INFO("XLIB MAIN", "Setting theme to:\t%d", settings.theme); theme_load(settings.theme); XSetErrorHandler(hold_x11s_hand); XIM xim; setlocale(LC_ALL, ""); XSetLocaleModifiers(""); if ((xim = XOpenIM(display, 0, 0, 0)) == NULL) { LOG_ERR("XLIB", "Cannot open input method"); } atom_init(); native_window_create_main(settings.window_x, settings.window_y, settings.window_width, settings.window_height, argv, argc); main_window.gc = DefaultGC(display, def_screen_num); main_window.drawbuf = XCreatePixmap(display, main_window.window, settings.window_width, settings.window_height, default_depth); /* choose available libraries for optional UI stuff */ if (!(libgtk = ugtk_load())) { // try Qt } /* catch WM_DELETE_WINDOW */ XSetWMProtocols(display, main_window.window, &wm_delete_window, 1); struct sigaction action; action.sa_handler = &signal_handler; /* catch terminating signals */ sigaction(SIGINT, &action, NULL); sigaction(SIGHUP, &action, NULL); sigaction(SIGTERM, &action, NULL); /* set drag and drog version */ Atom dndversion = 3; XChangeProperty(display, main_window.window, XdndAware, XA_ATOM, 32, PropModeReplace, (uint8_t *)&dndversion, 1); /* initialize fontconfig */ loadfonts(); setfont(FONT_TEXT); cursors_init(); ui_rescale(0); /* */ XGCValues gcval; gcval.foreground = XWhitePixel(display, 0); gcval.function = GXxor; gcval.background = XBlackPixel(display, 0); gcval.plane_mask = gcval.background ^ gcval.foreground; gcval.subwindow_mode = IncludeInferiors; /* GC for the */ scr_grab_window.gc = XCreateGC(display, RootWindow(display, def_screen_num), GCFunction | GCForeground | GCBackground | GCSubwindowMode, &gcval); XWindowAttributes attr; XGetWindowAttributes(display, root_window, &attr); main_window.pictformat = XRenderFindVisualFormat(display, attr.visual); // XRenderPictFormat *pictformat = XRenderFindStandardFormat(display, PictStandardA8); /* Xft draw context/color */ main_window.renderpic = XRenderCreatePicture(display, main_window.drawbuf, main_window.pictformat, 0, NULL); XRenderColor xrcolor = { 0,0,0,0 }; main_window.colorpic = XRenderCreateSolidFill(display, &xrcolor); if (set_show_window) { if (set_show_window == 1) { settings.start_in_tray = 0; } else if (set_show_window == -1) { settings.start_in_tray = 1; } } /* make the window visible */ if (settings.start_in_tray) { togglehide(); } else { XMapWindow(display, main_window.window); } if (xim) { if ((xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, main_window.window, XNFocusWindow, main_window.window, NULL))) { XSetICFocus(xic); } else { LOG_ERR("XLIB", "Cannot open input method"); XCloseIM(xim); xim = 0; } } /* set the width/height of the drawing region */ ui_size(settings.window_width, settings.window_height); create_tray_icon(); /* Registers the app in the Unity MM */ #ifdef UNITY unity_running = is_unity_running(); if (unity_running) { mm_register(); } #endif /* draw */ native_window_set_target(&main_window); panel_draw(&panel_root, 0, 0, settings.window_width, settings.window_height); // start toxcore thread thread(toxcore_thread, NULL); /* event loop */ while (!shutdown) { XEvent event; XNextEvent(display, &event); if (!doevent(&event)) { break; } if (XPending(display)) { continue; } if (_redraw) { native_window_set_target(&main_window); panel_draw(&panel_root, 0, 0, settings.window_width, settings.window_height); _redraw = 0; } } Window root_return, child_return; int x_return, y_return; unsigned int width_return, height_return, i; XGetGeometry(display, main_window.window, &root_return, &x_return, &y_return, &width_return, &height_return, &i, &i); XTranslateCoordinates(display, main_window.window, root_return, 0, 0, &x_return, &y_return, &child_return); settings.window_x = x_return < 0 ? 0 : x_return; settings.window_y = y_return < 0 ? 0 : y_return; settings.window_width = width_return; settings.window_height = height_return; config_save(); postmessage_utoxav(UTOXAV_KILL, 0, 0, NULL); postmessage_toxcore(TOX_KILL, 0, 0, NULL); /* free client thread stuff */ if (libgtk) { } destroy_tray_icon(); FcFontSetSortDestroy(fs); freefonts(); XFreePixmap(display, main_window.drawbuf); XFreeGC(display, scr_grab_window.gc); XRenderFreePicture(display, main_window.renderpic); XRenderFreePicture(display, main_window.colorpic); if (xic) { XDestroyIC(xic); } if (xim) { XCloseIM(xim); } XDestroyWindow(display, main_window.window); XCloseDisplay(display); /* Unregisters the app from the Unity MM */ #ifdef UNITY if (unity_running) { mm_unregister(); } #endif // wait for tox_thread to exit while (tox_thread_init) { yieldcpu(1); } return 0; } /* Dummy functions used in other systems... */ void launch_at_startup(bool UNUSED(is_launch_at_startup)) {} uTox/src/xlib/keysym2ucs.h0000600000175000001440000020634514003056216014524 0ustar rakusers/* $XFree86$ * This module converts keysym values into the corresponding ISO 10646 * (UCS, Unicode) values. * * The array keysymtab[] contains pairs of X11 keysym values for graphical * characters and the corresponding Unicode value. The function * keysym2ucs() maps a keysym onto a Unicode value using a binary search, * therefore keysymtab[] must remain SORTED by keysym value. * * The keysym -> UTF-8 conversion will hopefully one day be provided * by Xlib via XmbLookupString() and should ideally not have to be * done in X applications. But we are not there yet. * * We allow to represent any UCS character in the range U-00000000 to * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff. * This admittedly does not cover the entire 31-bit space of UCS, but * it does cover all of the characters up to U-10FFFF, which can be * represented by UTF-16, and more, and it is very unlikely that higher * UCS codes will ever be assigned by ISO. So to get Unicode character * U+ABCD you can directly use keysym 0x0100abcd. * * NOTE: The comments in the table below contain the actual character * encoded in UTF-8, so for viewing and editing best use an editor in * UTF-8 mode. * * Author: Markus G. Kuhn , * University of Cambridge, April 2001 * * Special thanks to Richard Verhoeven for preparing * an initial draft of the mapping table. * * This software is in the public domain. Share and enjoy! * * AUTOMATICALLY GENERATED FILE, DO NOT EDIT !!! (unicode/convmap.pl) */ #ifndef KEYSYM2UCS_H #define KEYSYM2UCS_H #include #include struct codepair { unsigned short keysym; unsigned short ucs; } keysymtab[] = { { 0x01a1, 0x0104 }, /* Aogonek Ą LATIN CAPITAL LETTER A WITH OGONEK */ { 0x01a2, 0x02d8 }, /* breve ˘ BREVE */ { 0x01a3, 0x0141 }, /* Lstroke Ł LATIN CAPITAL LETTER L WITH STROKE */ { 0x01a5, 0x013d }, /* Lcaron Ľ LATIN CAPITAL LETTER L WITH CARON */ { 0x01a6, 0x015a }, /* Sacute Ś LATIN CAPITAL LETTER S WITH ACUTE */ { 0x01a9, 0x0160 }, /* Scaron Š LATIN CAPITAL LETTER S WITH CARON */ { 0x01aa, 0x015e }, /* Scedilla Ş LATIN CAPITAL LETTER S WITH CEDILLA */ { 0x01ab, 0x0164 }, /* Tcaron Ť LATIN CAPITAL LETTER T WITH CARON */ { 0x01ac, 0x0179 }, /* Zacute Ź LATIN CAPITAL LETTER Z WITH ACUTE */ { 0x01ae, 0x017d }, /* Zcaron Ž LATIN CAPITAL LETTER Z WITH CARON */ { 0x01af, 0x017b }, /* Zabovedot Ż LATIN CAPITAL LETTER Z WITH DOT ABOVE */ { 0x01b1, 0x0105 }, /* aogonek ą LATIN SMALL LETTER A WITH OGONEK */ { 0x01b2, 0x02db }, /* ogonek ˛ OGONEK */ { 0x01b3, 0x0142 }, /* lstroke ł LATIN SMALL LETTER L WITH STROKE */ { 0x01b5, 0x013e }, /* lcaron ľ LATIN SMALL LETTER L WITH CARON */ { 0x01b6, 0x015b }, /* sacute ś LATIN SMALL LETTER S WITH ACUTE */ { 0x01b7, 0x02c7 }, /* caron ˇ CARON */ { 0x01b9, 0x0161 }, /* scaron š LATIN SMALL LETTER S WITH CARON */ { 0x01ba, 0x015f }, /* scedilla ş LATIN SMALL LETTER S WITH CEDILLA */ { 0x01bb, 0x0165 }, /* tcaron ť LATIN SMALL LETTER T WITH CARON */ { 0x01bc, 0x017a }, /* zacute ź LATIN SMALL LETTER Z WITH ACUTE */ { 0x01bd, 0x02dd }, /* doubleacute ˝ DOUBLE ACUTE ACCENT */ { 0x01be, 0x017e }, /* zcaron ž LATIN SMALL LETTER Z WITH CARON */ { 0x01bf, 0x017c }, /* zabovedot ż LATIN SMALL LETTER Z WITH DOT ABOVE */ { 0x01c0, 0x0154 }, /* Racute Ŕ LATIN CAPITAL LETTER R WITH ACUTE */ { 0x01c3, 0x0102 }, /* Abreve Ă LATIN CAPITAL LETTER A WITH BREVE */ { 0x01c5, 0x0139 }, /* Lacute Ĺ LATIN CAPITAL LETTER L WITH ACUTE */ { 0x01c6, 0x0106 }, /* Cacute Ć LATIN CAPITAL LETTER C WITH ACUTE */ { 0x01c8, 0x010c }, /* Ccaron Č LATIN CAPITAL LETTER C WITH CARON */ { 0x01ca, 0x0118 }, /* Eogonek Ę LATIN CAPITAL LETTER E WITH OGONEK */ { 0x01cc, 0x011a }, /* Ecaron Ě LATIN CAPITAL LETTER E WITH CARON */ { 0x01cf, 0x010e }, /* Dcaron Ď LATIN CAPITAL LETTER D WITH CARON */ { 0x01d0, 0x0110 }, /* Dstroke Đ LATIN CAPITAL LETTER D WITH STROKE */ { 0x01d1, 0x0143 }, /* Nacute Ń LATIN CAPITAL LETTER N WITH ACUTE */ { 0x01d2, 0x0147 }, /* Ncaron Ň LATIN CAPITAL LETTER N WITH CARON */ { 0x01d5, 0x0150 }, /* Odoubleacute Ő LATIN CAPITAL LETTER O WITH DOUBLE ACUTE */ { 0x01d8, 0x0158 }, /* Rcaron Ř LATIN CAPITAL LETTER R WITH CARON */ { 0x01d9, 0x016e }, /* Uring Ů LATIN CAPITAL LETTER U WITH RING ABOVE */ { 0x01db, 0x0170 }, /* Udoubleacute Ű LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */ { 0x01de, 0x0162 }, /* Tcedilla Ţ LATIN CAPITAL LETTER T WITH CEDILLA */ { 0x01e0, 0x0155 }, /* racute ŕ LATIN SMALL LETTER R WITH ACUTE */ { 0x01e3, 0x0103 }, /* abreve ă LATIN SMALL LETTER A WITH BREVE */ { 0x01e5, 0x013a }, /* lacute ĺ LATIN SMALL LETTER L WITH ACUTE */ { 0x01e6, 0x0107 }, /* cacute ć LATIN SMALL LETTER C WITH ACUTE */ { 0x01e8, 0x010d }, /* ccaron č LATIN SMALL LETTER C WITH CARON */ { 0x01ea, 0x0119 }, /* eogonek ę LATIN SMALL LETTER E WITH OGONEK */ { 0x01ec, 0x011b }, /* ecaron ě LATIN SMALL LETTER E WITH CARON */ { 0x01ef, 0x010f }, /* dcaron ď LATIN SMALL LETTER D WITH CARON */ { 0x01f0, 0x0111 }, /* dstroke đ LATIN SMALL LETTER D WITH STROKE */ { 0x01f1, 0x0144 }, /* nacute ń LATIN SMALL LETTER N WITH ACUTE */ { 0x01f2, 0x0148 }, /* ncaron ň LATIN SMALL LETTER N WITH CARON */ { 0x01f5, 0x0151 }, /* odoubleacute ő LATIN SMALL LETTER O WITH DOUBLE ACUTE */ { 0x01f8, 0x0159 }, /* rcaron ř LATIN SMALL LETTER R WITH CARON */ { 0x01f9, 0x016f }, /* uring ů LATIN SMALL LETTER U WITH RING ABOVE */ { 0x01fb, 0x0171 }, /* udoubleacute ű LATIN SMALL LETTER U WITH DOUBLE ACUTE */ { 0x01fe, 0x0163 }, /* tcedilla ţ LATIN SMALL LETTER T WITH CEDILLA */ { 0x01ff, 0x02d9 }, /* abovedot ˙ DOT ABOVE */ { 0x02a1, 0x0126 }, /* Hstroke Ħ LATIN CAPITAL LETTER H WITH STROKE */ { 0x02a6, 0x0124 }, /* Hcircumflex Ĥ LATIN CAPITAL LETTER H WITH CIRCUMFLEX */ { 0x02a9, 0x0130 }, /* Iabovedot İ LATIN CAPITAL LETTER I WITH DOT ABOVE */ { 0x02ab, 0x011e }, /* Gbreve Ğ LATIN CAPITAL LETTER G WITH BREVE */ { 0x02ac, 0x0134 }, /* Jcircumflex Ĵ LATIN CAPITAL LETTER J WITH CIRCUMFLEX */ { 0x02b1, 0x0127 }, /* hstroke ħ LATIN SMALL LETTER H WITH STROKE */ { 0x02b6, 0x0125 }, /* hcircumflex ĥ LATIN SMALL LETTER H WITH CIRCUMFLEX */ { 0x02b9, 0x0131 }, /* idotless ı LATIN SMALL LETTER DOTLESS I */ { 0x02bb, 0x011f }, /* gbreve ğ LATIN SMALL LETTER G WITH BREVE */ { 0x02bc, 0x0135 }, /* jcircumflex ĵ LATIN SMALL LETTER J WITH CIRCUMFLEX */ { 0x02c5, 0x010a }, /* Cabovedot Ċ LATIN CAPITAL LETTER C WITH DOT ABOVE */ { 0x02c6, 0x0108 }, /* Ccircumflex Ĉ LATIN CAPITAL LETTER C WITH CIRCUMFLEX */ { 0x02d5, 0x0120 }, /* Gabovedot Ġ LATIN CAPITAL LETTER G WITH DOT ABOVE */ { 0x02d8, 0x011c }, /* Gcircumflex Ĝ LATIN CAPITAL LETTER G WITH CIRCUMFLEX */ { 0x02dd, 0x016c }, /* Ubreve Ŭ LATIN CAPITAL LETTER U WITH BREVE */ { 0x02de, 0x015c }, /* Scircumflex Ŝ LATIN CAPITAL LETTER S WITH CIRCUMFLEX */ { 0x02e5, 0x010b }, /* cabovedot ċ LATIN SMALL LETTER C WITH DOT ABOVE */ { 0x02e6, 0x0109 }, /* ccircumflex ĉ LATIN SMALL LETTER C WITH CIRCUMFLEX */ { 0x02f5, 0x0121 }, /* gabovedot ġ LATIN SMALL LETTER G WITH DOT ABOVE */ { 0x02f8, 0x011d }, /* gcircumflex ĝ LATIN SMALL LETTER G WITH CIRCUMFLEX */ { 0x02fd, 0x016d }, /* ubreve ŭ LATIN SMALL LETTER U WITH BREVE */ { 0x02fe, 0x015d }, /* scircumflex ŝ LATIN SMALL LETTER S WITH CIRCUMFLEX */ { 0x03a2, 0x0138 }, /* kra ĸ LATIN SMALL LETTER KRA */ { 0x03a3, 0x0156 }, /* Rcedilla Ŗ LATIN CAPITAL LETTER R WITH CEDILLA */ { 0x03a5, 0x0128 }, /* Itilde Ĩ LATIN CAPITAL LETTER I WITH TILDE */ { 0x03a6, 0x013b }, /* Lcedilla Ļ LATIN CAPITAL LETTER L WITH CEDILLA */ { 0x03aa, 0x0112 }, /* Emacron Ē LATIN CAPITAL LETTER E WITH MACRON */ { 0x03ab, 0x0122 }, /* Gcedilla Ģ LATIN CAPITAL LETTER G WITH CEDILLA */ { 0x03ac, 0x0166 }, /* Tslash Ŧ LATIN CAPITAL LETTER T WITH STROKE */ { 0x03b3, 0x0157 }, /* rcedilla ŗ LATIN SMALL LETTER R WITH CEDILLA */ { 0x03b5, 0x0129 }, /* itilde ĩ LATIN SMALL LETTER I WITH TILDE */ { 0x03b6, 0x013c }, /* lcedilla ļ LATIN SMALL LETTER L WITH CEDILLA */ { 0x03ba, 0x0113 }, /* emacron ē LATIN SMALL LETTER E WITH MACRON */ { 0x03bb, 0x0123 }, /* gcedilla ģ LATIN SMALL LETTER G WITH CEDILLA */ { 0x03bc, 0x0167 }, /* tslash ŧ LATIN SMALL LETTER T WITH STROKE */ { 0x03bd, 0x014a }, /* ENG Ŋ LATIN CAPITAL LETTER ENG */ { 0x03bf, 0x014b }, /* eng ŋ LATIN SMALL LETTER ENG */ { 0x03c0, 0x0100 }, /* Amacron Ā LATIN CAPITAL LETTER A WITH MACRON */ { 0x03c7, 0x012e }, /* Iogonek Į LATIN CAPITAL LETTER I WITH OGONEK */ { 0x03cc, 0x0116 }, /* Eabovedot Ė LATIN CAPITAL LETTER E WITH DOT ABOVE */ { 0x03cf, 0x012a }, /* Imacron Ī LATIN CAPITAL LETTER I WITH MACRON */ { 0x03d1, 0x0145 }, /* Ncedilla Ņ LATIN CAPITAL LETTER N WITH CEDILLA */ { 0x03d2, 0x014c }, /* Omacron Ō LATIN CAPITAL LETTER O WITH MACRON */ { 0x03d3, 0x0136 }, /* Kcedilla Ķ LATIN CAPITAL LETTER K WITH CEDILLA */ { 0x03d9, 0x0172 }, /* Uogonek Ų LATIN CAPITAL LETTER U WITH OGONEK */ { 0x03dd, 0x0168 }, /* Utilde Ũ LATIN CAPITAL LETTER U WITH TILDE */ { 0x03de, 0x016a }, /* Umacron Ū LATIN CAPITAL LETTER U WITH MACRON */ { 0x03e0, 0x0101 }, /* amacron ā LATIN SMALL LETTER A WITH MACRON */ { 0x03e7, 0x012f }, /* iogonek į LATIN SMALL LETTER I WITH OGONEK */ { 0x03ec, 0x0117 }, /* eabovedot ė LATIN SMALL LETTER E WITH DOT ABOVE */ { 0x03ef, 0x012b }, /* imacron ī LATIN SMALL LETTER I WITH MACRON */ { 0x03f1, 0x0146 }, /* ncedilla ņ LATIN SMALL LETTER N WITH CEDILLA */ { 0x03f2, 0x014d }, /* omacron ō LATIN SMALL LETTER O WITH MACRON */ { 0x03f3, 0x0137 }, /* kcedilla ķ LATIN SMALL LETTER K WITH CEDILLA */ { 0x03f9, 0x0173 }, /* uogonek ų LATIN SMALL LETTER U WITH OGONEK */ { 0x03fd, 0x0169 }, /* utilde ũ LATIN SMALL LETTER U WITH TILDE */ { 0x03fe, 0x016b }, /* umacron ū LATIN SMALL LETTER U WITH MACRON */ { 0x047e, 0x203e }, /* overline ‾ OVERLINE */ { 0x04a1, 0x3002 }, /* kana_fullstop 。 IDEOGRAPHIC FULL STOP */ { 0x04a2, 0x300c }, /* kana_openingbracket 「 LEFT CORNER BRACKET */ { 0x04a3, 0x300d }, /* kana_closingbracket 」 RIGHT CORNER BRACKET */ { 0x04a4, 0x3001 }, /* kana_comma 、 IDEOGRAPHIC COMMA */ { 0x04a5, 0x30fb }, /* kana_conjunctive ・ KATAKANA MIDDLE DOT */ { 0x04a6, 0x30f2 }, /* kana_WO ヲ KATAKANA LETTER WO */ { 0x04a7, 0x30a1 }, /* kana_a ァ KATAKANA LETTER SMALL A */ { 0x04a8, 0x30a3 }, /* kana_i ィ KATAKANA LETTER SMALL I */ { 0x04a9, 0x30a5 }, /* kana_u ゥ KATAKANA LETTER SMALL U */ { 0x04aa, 0x30a7 }, /* kana_e ェ KATAKANA LETTER SMALL E */ { 0x04ab, 0x30a9 }, /* kana_o ォ KATAKANA LETTER SMALL O */ { 0x04ac, 0x30e3 }, /* kana_ya ャ KATAKANA LETTER SMALL YA */ { 0x04ad, 0x30e5 }, /* kana_yu ュ KATAKANA LETTER SMALL YU */ { 0x04ae, 0x30e7 }, /* kana_yo ョ KATAKANA LETTER SMALL YO */ { 0x04af, 0x30c3 }, /* kana_tsu ッ KATAKANA LETTER SMALL TU */ { 0x04b0, 0x30fc }, /* prolongedsound ー KATAKANA-HIRAGANA PROLONGED SOUND MARK */ { 0x04b1, 0x30a2 }, /* kana_A ア KATAKANA LETTER A */ { 0x04b2, 0x30a4 }, /* kana_I イ KATAKANA LETTER I */ { 0x04b3, 0x30a6 }, /* kana_U ウ KATAKANA LETTER U */ { 0x04b4, 0x30a8 }, /* kana_E エ KATAKANA LETTER E */ { 0x04b5, 0x30aa }, /* kana_O オ KATAKANA LETTER O */ { 0x04b6, 0x30ab }, /* kana_KA カ KATAKANA LETTER KA */ { 0x04b7, 0x30ad }, /* kana_KI キ KATAKANA LETTER KI */ { 0x04b8, 0x30af }, /* kana_KU ク KATAKANA LETTER KU */ { 0x04b9, 0x30b1 }, /* kana_KE ケ KATAKANA LETTER KE */ { 0x04ba, 0x30b3 }, /* kana_KO コ KATAKANA LETTER KO */ { 0x04bb, 0x30b5 }, /* kana_SA サ KATAKANA LETTER SA */ { 0x04bc, 0x30b7 }, /* kana_SHI シ KATAKANA LETTER SI */ { 0x04bd, 0x30b9 }, /* kana_SU ス KATAKANA LETTER SU */ { 0x04be, 0x30bb }, /* kana_SE セ KATAKANA LETTER SE */ { 0x04bf, 0x30bd }, /* kana_SO ソ KATAKANA LETTER SO */ { 0x04c0, 0x30bf }, /* kana_TA タ KATAKANA LETTER TA */ { 0x04c1, 0x30c1 }, /* kana_CHI チ KATAKANA LETTER TI */ { 0x04c2, 0x30c4 }, /* kana_TSU ツ KATAKANA LETTER TU */ { 0x04c3, 0x30c6 }, /* kana_TE テ KATAKANA LETTER TE */ { 0x04c4, 0x30c8 }, /* kana_TO ト KATAKANA LETTER TO */ { 0x04c5, 0x30ca }, /* kana_NA ナ KATAKANA LETTER NA */ { 0x04c6, 0x30cb }, /* kana_NI ニ KATAKANA LETTER NI */ { 0x04c7, 0x30cc }, /* kana_NU ヌ KATAKANA LETTER NU */ { 0x04c8, 0x30cd }, /* kana_NE ネ KATAKANA LETTER NE */ { 0x04c9, 0x30ce }, /* kana_NO ノ KATAKANA LETTER NO */ { 0x04ca, 0x30cf }, /* kana_HA ハ KATAKANA LETTER HA */ { 0x04cb, 0x30d2 }, /* kana_HI ヒ KATAKANA LETTER HI */ { 0x04cc, 0x30d5 }, /* kana_FU フ KATAKANA LETTER HU */ { 0x04cd, 0x30d8 }, /* kana_HE ヘ KATAKANA LETTER HE */ { 0x04ce, 0x30db }, /* kana_HO ホ KATAKANA LETTER HO */ { 0x04cf, 0x30de }, /* kana_MA マ KATAKANA LETTER MA */ { 0x04d0, 0x30df }, /* kana_MI ミ KATAKANA LETTER MI */ { 0x04d1, 0x30e0 }, /* kana_MU ム KATAKANA LETTER MU */ { 0x04d2, 0x30e1 }, /* kana_ME メ KATAKANA LETTER ME */ { 0x04d3, 0x30e2 }, /* kana_MO モ KATAKANA LETTER MO */ { 0x04d4, 0x30e4 }, /* kana_YA ヤ KATAKANA LETTER YA */ { 0x04d5, 0x30e6 }, /* kana_YU ユ KATAKANA LETTER YU */ { 0x04d6, 0x30e8 }, /* kana_YO ヨ KATAKANA LETTER YO */ { 0x04d7, 0x30e9 }, /* kana_RA ラ KATAKANA LETTER RA */ { 0x04d8, 0x30ea }, /* kana_RI リ KATAKANA LETTER RI */ { 0x04d9, 0x30eb }, /* kana_RU ル KATAKANA LETTER RU */ { 0x04da, 0x30ec }, /* kana_RE レ KATAKANA LETTER RE */ { 0x04db, 0x30ed }, /* kana_RO ロ KATAKANA LETTER RO */ { 0x04dc, 0x30ef }, /* kana_WA ワ KATAKANA LETTER WA */ { 0x04dd, 0x30f3 }, /* kana_N ン KATAKANA LETTER N */ { 0x04de, 0x309b }, /* voicedsound ゛ KATAKANA-HIRAGANA VOICED SOUND MARK */ { 0x04df, 0x309c }, /* semivoicedsound ゜ KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK */ { 0x05ac, 0x060c }, /* Arabic_comma ، ARABIC COMMA */ { 0x05bb, 0x061b }, /* Arabic_semicolon ؛ ARABIC SEMICOLON */ { 0x05bf, 0x061f }, /* Arabic_question_mark ؟ ARABIC QUESTION MARK */ { 0x05c1, 0x0621 }, /* Arabic_hamza ء ARABIC LETTER HAMZA */ { 0x05c2, 0x0622 }, /* Arabic_maddaonalef آ ARABIC LETTER ALEF WITH MADDA ABOVE */ { 0x05c3, 0x0623 }, /* Arabic_hamzaonalef أ ARABIC LETTER ALEF WITH HAMZA ABOVE */ { 0x05c4, 0x0624 }, /* Arabic_hamzaonwaw ؤ ARABIC LETTER WAW WITH HAMZA ABOVE */ { 0x05c5, 0x0625 }, /* Arabic_hamzaunderalef إ ARABIC LETTER ALEF WITH HAMZA BELOW */ { 0x05c6, 0x0626 }, /* Arabic_hamzaonyeh ئ ARABIC LETTER YEH WITH HAMZA ABOVE */ { 0x05c7, 0x0627 }, /* Arabic_alef ا ARABIC LETTER ALEF */ { 0x05c8, 0x0628 }, /* Arabic_beh ب ARABIC LETTER BEH */ { 0x05c9, 0x0629 }, /* Arabic_tehmarbuta ة ARABIC LETTER TEH MARBUTA */ { 0x05ca, 0x062a }, /* Arabic_teh ت ARABIC LETTER TEH */ { 0x05cb, 0x062b }, /* Arabic_theh ث ARABIC LETTER THEH */ { 0x05cc, 0x062c }, /* Arabic_jeem ج ARABIC LETTER JEEM */ { 0x05cd, 0x062d }, /* Arabic_hah ح ARABIC LETTER HAH */ { 0x05ce, 0x062e }, /* Arabic_khah خ ARABIC LETTER KHAH */ { 0x05cf, 0x062f }, /* Arabic_dal د ARABIC LETTER DAL */ { 0x05d0, 0x0630 }, /* Arabic_thal ذ ARABIC LETTER THAL */ { 0x05d1, 0x0631 }, /* Arabic_ra ر ARABIC LETTER REH */ { 0x05d2, 0x0632 }, /* Arabic_zain ز ARABIC LETTER ZAIN */ { 0x05d3, 0x0633 }, /* Arabic_seen س ARABIC LETTER SEEN */ { 0x05d4, 0x0634 }, /* Arabic_sheen ش ARABIC LETTER SHEEN */ { 0x05d5, 0x0635 }, /* Arabic_sad ص ARABIC LETTER SAD */ { 0x05d6, 0x0636 }, /* Arabic_dad ض ARABIC LETTER DAD */ { 0x05d7, 0x0637 }, /* Arabic_tah ط ARABIC LETTER TAH */ { 0x05d8, 0x0638 }, /* Arabic_zah ظ ARABIC LETTER ZAH */ { 0x05d9, 0x0639 }, /* Arabic_ain ع ARABIC LETTER AIN */ { 0x05da, 0x063a }, /* Arabic_ghain غ ARABIC LETTER GHAIN */ { 0x05e0, 0x0640 }, /* Arabic_tatweel ـ ARABIC TATWEEL */ { 0x05e1, 0x0641 }, /* Arabic_feh ف ARABIC LETTER FEH */ { 0x05e2, 0x0642 }, /* Arabic_qaf ق ARABIC LETTER QAF */ { 0x05e3, 0x0643 }, /* Arabic_kaf ك ARABIC LETTER KAF */ { 0x05e4, 0x0644 }, /* Arabic_lam ل ARABIC LETTER LAM */ { 0x05e5, 0x0645 }, /* Arabic_meem م ARABIC LETTER MEEM */ { 0x05e6, 0x0646 }, /* Arabic_noon ن ARABIC LETTER NOON */ { 0x05e7, 0x0647 }, /* Arabic_ha ه ARABIC LETTER HEH */ { 0x05e8, 0x0648 }, /* Arabic_waw و ARABIC LETTER WAW */ { 0x05e9, 0x0649 }, /* Arabic_alefmaksura ى ARABIC LETTER ALEF MAKSURA */ { 0x05ea, 0x064a }, /* Arabic_yeh ي ARABIC LETTER YEH */ { 0x05eb, 0x064b }, /* Arabic_fathatan ً ARABIC FATHATAN */ { 0x05ec, 0x064c }, /* Arabic_dammatan ٌ ARABIC DAMMATAN */ { 0x05ed, 0x064d }, /* Arabic_kasratan ٍ ARABIC KASRATAN */ { 0x05ee, 0x064e }, /* Arabic_fatha َ ARABIC FATHA */ { 0x05ef, 0x064f }, /* Arabic_damma ُ ARABIC DAMMA */ { 0x05f0, 0x0650 }, /* Arabic_kasra ِ ARABIC KASRA */ { 0x05f1, 0x0651 }, /* Arabic_shadda ّ ARABIC SHADDA */ { 0x05f2, 0x0652 }, /* Arabic_sukun ْ ARABIC SUKUN */ { 0x06a1, 0x0452 }, /* Serbian_dje ђ CYRILLIC SMALL LETTER DJE */ { 0x06a2, 0x0453 }, /* Macedonia_gje ѓ CYRILLIC SMALL LETTER GJE */ { 0x06a3, 0x0451 }, /* Cyrillic_io ё CYRILLIC SMALL LETTER IO */ { 0x06a4, 0x0454 }, /* Ukrainian_ie є CYRILLIC SMALL LETTER UKRAINIAN IE */ { 0x06a5, 0x0455 }, /* Macedonia_dse ѕ CYRILLIC SMALL LETTER DZE */ { 0x06a6, 0x0456 }, /* Ukrainian_i і CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I */ { 0x06a7, 0x0457 }, /* Ukrainian_yi ї CYRILLIC SMALL LETTER YI */ { 0x06a8, 0x0458 }, /* Cyrillic_je ј CYRILLIC SMALL LETTER JE */ { 0x06a9, 0x0459 }, /* Cyrillic_lje љ CYRILLIC SMALL LETTER LJE */ { 0x06aa, 0x045a }, /* Cyrillic_nje њ CYRILLIC SMALL LETTER NJE */ { 0x06ab, 0x045b }, /* Serbian_tshe ћ CYRILLIC SMALL LETTER TSHE */ { 0x06ac, 0x045c }, /* Macedonia_kje ќ CYRILLIC SMALL LETTER KJE */ { 0x06ae, 0x045e }, /* Byelorussian_shortu ў CYRILLIC SMALL LETTER SHORT U */ { 0x06af, 0x045f }, /* Cyrillic_dzhe џ CYRILLIC SMALL LETTER DZHE */ { 0x06b0, 0x2116 }, /* numerosign № NUMERO SIGN */ { 0x06b1, 0x0402 }, /* Serbian_DJE Ђ CYRILLIC CAPITAL LETTER DJE */ { 0x06b2, 0x0403 }, /* Macedonia_GJE Ѓ CYRILLIC CAPITAL LETTER GJE */ { 0x06b3, 0x0401 }, /* Cyrillic_IO Ё CYRILLIC CAPITAL LETTER IO */ { 0x06b4, 0x0404 }, /* Ukrainian_IE Є CYRILLIC CAPITAL LETTER UKRAINIAN IE */ { 0x06b5, 0x0405 }, /* Macedonia_DSE Ѕ CYRILLIC CAPITAL LETTER DZE */ { 0x06b6, 0x0406 }, /* Ukrainian_I І CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I */ { 0x06b7, 0x0407 }, /* Ukrainian_YI Ї CYRILLIC CAPITAL LETTER YI */ { 0x06b8, 0x0408 }, /* Cyrillic_JE Ј CYRILLIC CAPITAL LETTER JE */ { 0x06b9, 0x0409 }, /* Cyrillic_LJE Љ CYRILLIC CAPITAL LETTER LJE */ { 0x06ba, 0x040a }, /* Cyrillic_NJE Њ CYRILLIC CAPITAL LETTER NJE */ { 0x06bb, 0x040b }, /* Serbian_TSHE Ћ CYRILLIC CAPITAL LETTER TSHE */ { 0x06bc, 0x040c }, /* Macedonia_KJE Ќ CYRILLIC CAPITAL LETTER KJE */ { 0x06be, 0x040e }, /* Byelorussian_SHORTU Ў CYRILLIC CAPITAL LETTER SHORT U */ { 0x06bf, 0x040f }, /* Cyrillic_DZHE Џ CYRILLIC CAPITAL LETTER DZHE */ { 0x06c0, 0x044e }, /* Cyrillic_yu ю CYRILLIC SMALL LETTER YU */ { 0x06c1, 0x0430 }, /* Cyrillic_a а CYRILLIC SMALL LETTER A */ { 0x06c2, 0x0431 }, /* Cyrillic_be б CYRILLIC SMALL LETTER BE */ { 0x06c3, 0x0446 }, /* Cyrillic_tse ц CYRILLIC SMALL LETTER TSE */ { 0x06c4, 0x0434 }, /* Cyrillic_de д CYRILLIC SMALL LETTER DE */ { 0x06c5, 0x0435 }, /* Cyrillic_ie е CYRILLIC SMALL LETTER IE */ { 0x06c6, 0x0444 }, /* Cyrillic_ef ф CYRILLIC SMALL LETTER EF */ { 0x06c7, 0x0433 }, /* Cyrillic_ghe г CYRILLIC SMALL LETTER GHE */ { 0x06c8, 0x0445 }, /* Cyrillic_ha х CYRILLIC SMALL LETTER HA */ { 0x06c9, 0x0438 }, /* Cyrillic_i и CYRILLIC SMALL LETTER I */ { 0x06ca, 0x0439 }, /* Cyrillic_shorti й CYRILLIC SMALL LETTER SHORT I */ { 0x06cb, 0x043a }, /* Cyrillic_ka к CYRILLIC SMALL LETTER KA */ { 0x06cc, 0x043b }, /* Cyrillic_el л CYRILLIC SMALL LETTER EL */ { 0x06cd, 0x043c }, /* Cyrillic_em м CYRILLIC SMALL LETTER EM */ { 0x06ce, 0x043d }, /* Cyrillic_en н CYRILLIC SMALL LETTER EN */ { 0x06cf, 0x043e }, /* Cyrillic_o о CYRILLIC SMALL LETTER O */ { 0x06d0, 0x043f }, /* Cyrillic_pe п CYRILLIC SMALL LETTER PE */ { 0x06d1, 0x044f }, /* Cyrillic_ya я CYRILLIC SMALL LETTER YA */ { 0x06d2, 0x0440 }, /* Cyrillic_er р CYRILLIC SMALL LETTER ER */ { 0x06d3, 0x0441 }, /* Cyrillic_es с CYRILLIC SMALL LETTER ES */ { 0x06d4, 0x0442 }, /* Cyrillic_te т CYRILLIC SMALL LETTER TE */ { 0x06d5, 0x0443 }, /* Cyrillic_u у CYRILLIC SMALL LETTER U */ { 0x06d6, 0x0436 }, /* Cyrillic_zhe ж CYRILLIC SMALL LETTER ZHE */ { 0x06d7, 0x0432 }, /* Cyrillic_ve в CYRILLIC SMALL LETTER VE */ { 0x06d8, 0x044c }, /* Cyrillic_softsign ь CYRILLIC SMALL LETTER SOFT SIGN */ { 0x06d9, 0x044b }, /* Cyrillic_yeru ы CYRILLIC SMALL LETTER YERU */ { 0x06da, 0x0437 }, /* Cyrillic_ze з CYRILLIC SMALL LETTER ZE */ { 0x06db, 0x0448 }, /* Cyrillic_sha ш CYRILLIC SMALL LETTER SHA */ { 0x06dc, 0x044d }, /* Cyrillic_e э CYRILLIC SMALL LETTER E */ { 0x06dd, 0x0449 }, /* Cyrillic_shcha щ CYRILLIC SMALL LETTER SHCHA */ { 0x06de, 0x0447 }, /* Cyrillic_che ч CYRILLIC SMALL LETTER CHE */ { 0x06df, 0x044a }, /* Cyrillic_hardsign ъ CYRILLIC SMALL LETTER HARD SIGN */ { 0x06e0, 0x042e }, /* Cyrillic_YU Ю CYRILLIC CAPITAL LETTER YU */ { 0x06e1, 0x0410 }, /* Cyrillic_A А CYRILLIC CAPITAL LETTER A */ { 0x06e2, 0x0411 }, /* Cyrillic_BE Б CYRILLIC CAPITAL LETTER BE */ { 0x06e3, 0x0426 }, /* Cyrillic_TSE Ц CYRILLIC CAPITAL LETTER TSE */ { 0x06e4, 0x0414 }, /* Cyrillic_DE Д CYRILLIC CAPITAL LETTER DE */ { 0x06e5, 0x0415 }, /* Cyrillic_IE Е CYRILLIC CAPITAL LETTER IE */ { 0x06e6, 0x0424 }, /* Cyrillic_EF Ф CYRILLIC CAPITAL LETTER EF */ { 0x06e7, 0x0413 }, /* Cyrillic_GHE Г CYRILLIC CAPITAL LETTER GHE */ { 0x06e8, 0x0425 }, /* Cyrillic_HA Х CYRILLIC CAPITAL LETTER HA */ { 0x06e9, 0x0418 }, /* Cyrillic_I И CYRILLIC CAPITAL LETTER I */ { 0x06ea, 0x0419 }, /* Cyrillic_SHORTI Й CYRILLIC CAPITAL LETTER SHORT I */ { 0x06eb, 0x041a }, /* Cyrillic_KA К CYRILLIC CAPITAL LETTER KA */ { 0x06ec, 0x041b }, /* Cyrillic_EL Л CYRILLIC CAPITAL LETTER EL */ { 0x06ed, 0x041c }, /* Cyrillic_EM М CYRILLIC CAPITAL LETTER EM */ { 0x06ee, 0x041d }, /* Cyrillic_EN Н CYRILLIC CAPITAL LETTER EN */ { 0x06ef, 0x041e }, /* Cyrillic_O О CYRILLIC CAPITAL LETTER O */ { 0x06f0, 0x041f }, /* Cyrillic_PE П CYRILLIC CAPITAL LETTER PE */ { 0x06f1, 0x042f }, /* Cyrillic_YA Я CYRILLIC CAPITAL LETTER YA */ { 0x06f2, 0x0420 }, /* Cyrillic_ER Р CYRILLIC CAPITAL LETTER ER */ { 0x06f3, 0x0421 }, /* Cyrillic_ES С CYRILLIC CAPITAL LETTER ES */ { 0x06f4, 0x0422 }, /* Cyrillic_TE Т CYRILLIC CAPITAL LETTER TE */ { 0x06f5, 0x0423 }, /* Cyrillic_U У CYRILLIC CAPITAL LETTER U */ { 0x06f6, 0x0416 }, /* Cyrillic_ZHE Ж CYRILLIC CAPITAL LETTER ZHE */ { 0x06f7, 0x0412 }, /* Cyrillic_VE В CYRILLIC CAPITAL LETTER VE */ { 0x06f8, 0x042c }, /* Cyrillic_SOFTSIGN Ь CYRILLIC CAPITAL LETTER SOFT SIGN */ { 0x06f9, 0x042b }, /* Cyrillic_YERU Ы CYRILLIC CAPITAL LETTER YERU */ { 0x06fa, 0x0417 }, /* Cyrillic_ZE З CYRILLIC CAPITAL LETTER ZE */ { 0x06fb, 0x0428 }, /* Cyrillic_SHA Ш CYRILLIC CAPITAL LETTER SHA */ { 0x06fc, 0x042d }, /* Cyrillic_E Э CYRILLIC CAPITAL LETTER E */ { 0x06fd, 0x0429 }, /* Cyrillic_SHCHA Щ CYRILLIC CAPITAL LETTER SHCHA */ { 0x06fe, 0x0427 }, /* Cyrillic_CHE Ч CYRILLIC CAPITAL LETTER CHE */ { 0x06ff, 0x042a }, /* Cyrillic_HARDSIGN Ъ CYRILLIC CAPITAL LETTER HARD SIGN */ { 0x07a1, 0x0386 }, /* Greek_ALPHAaccent Ά GREEK CAPITAL LETTER ALPHA WITH TONOS */ { 0x07a2, 0x0388 }, /* Greek_EPSILONaccent Έ GREEK CAPITAL LETTER EPSILON WITH TONOS */ { 0x07a3, 0x0389 }, /* Greek_ETAaccent Ή GREEK CAPITAL LETTER ETA WITH TONOS */ { 0x07a4, 0x038a }, /* Greek_IOTAaccent Ί GREEK CAPITAL LETTER IOTA WITH TONOS */ { 0x07a5, 0x03aa }, /* Greek_IOTAdiaeresis Ϊ GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */ { 0x07a7, 0x038c }, /* Greek_OMICRONaccent Ό GREEK CAPITAL LETTER OMICRON WITH TONOS */ { 0x07a8, 0x038e }, /* Greek_UPSILONaccent Ύ GREEK CAPITAL LETTER UPSILON WITH TONOS */ { 0x07a9, 0x03ab }, /* Greek_UPSILONdieresis Ϋ GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA */ { 0x07ab, 0x038f }, /* Greek_OMEGAaccent Ώ GREEK CAPITAL LETTER OMEGA WITH TONOS */ { 0x07ae, 0x0385 }, /* Greek_accentdieresis ΅ GREEK DIALYTIKA TONOS */ { 0x07af, 0x2015 }, /* Greek_horizbar ― HORIZONTAL BAR */ { 0x07b1, 0x03ac }, /* Greek_alphaaccent ά GREEK SMALL LETTER ALPHA WITH TONOS */ { 0x07b2, 0x03ad }, /* Greek_epsilonaccent έ GREEK SMALL LETTER EPSILON WITH TONOS */ { 0x07b3, 0x03ae }, /* Greek_etaaccent ή GREEK SMALL LETTER ETA WITH TONOS */ { 0x07b4, 0x03af }, /* Greek_iotaaccent ί GREEK SMALL LETTER IOTA WITH TONOS */ { 0x07b5, 0x03ca }, /* Greek_iotadieresis ϊ GREEK SMALL LETTER IOTA WITH DIALYTIKA */ { 0x07b6, 0x0390 }, /* Greek_iotaaccentdieresis ΐ GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS */ { 0x07b7, 0x03cc }, /* Greek_omicronaccent ό GREEK SMALL LETTER OMICRON WITH TONOS */ { 0x07b8, 0x03cd }, /* Greek_upsilonaccent ύ GREEK SMALL LETTER UPSILON WITH TONOS */ { 0x07b9, 0x03cb }, /* Greek_upsilondieresis ϋ GREEK SMALL LETTER UPSILON WITH DIALYTIKA */ { 0x07ba, 0x03b0 }, /* Greek_upsilonaccentdieresis ΰ GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS */ { 0x07bb, 0x03ce }, /* Greek_omegaaccent ώ GREEK SMALL LETTER OMEGA WITH TONOS */ { 0x07c1, 0x0391 }, /* Greek_ALPHA Α GREEK CAPITAL LETTER ALPHA */ { 0x07c2, 0x0392 }, /* Greek_BETA Β GREEK CAPITAL LETTER BETA */ { 0x07c3, 0x0393 }, /* Greek_GAMMA Γ GREEK CAPITAL LETTER GAMMA */ { 0x07c4, 0x0394 }, /* Greek_DELTA Δ GREEK CAPITAL LETTER DELTA */ { 0x07c5, 0x0395 }, /* Greek_EPSILON Ε GREEK CAPITAL LETTER EPSILON */ { 0x07c6, 0x0396 }, /* Greek_ZETA Ζ GREEK CAPITAL LETTER ZETA */ { 0x07c7, 0x0397 }, /* Greek_ETA Η GREEK CAPITAL LETTER ETA */ { 0x07c8, 0x0398 }, /* Greek_THETA Θ GREEK CAPITAL LETTER THETA */ { 0x07c9, 0x0399 }, /* Greek_IOTA Ι GREEK CAPITAL LETTER IOTA */ { 0x07ca, 0x039a }, /* Greek_KAPPA Κ GREEK CAPITAL LETTER KAPPA */ { 0x07cb, 0x039b }, /* Greek_LAMBDA Λ GREEK CAPITAL LETTER LAMDA */ { 0x07cc, 0x039c }, /* Greek_MU Μ GREEK CAPITAL LETTER MU */ { 0x07cd, 0x039d }, /* Greek_NU Ν GREEK CAPITAL LETTER NU */ { 0x07ce, 0x039e }, /* Greek_XI Ξ GREEK CAPITAL LETTER XI */ { 0x07cf, 0x039f }, /* Greek_OMICRON Ο GREEK CAPITAL LETTER OMICRON */ { 0x07d0, 0x03a0 }, /* Greek_PI Π GREEK CAPITAL LETTER PI */ { 0x07d1, 0x03a1 }, /* Greek_RHO Ρ GREEK CAPITAL LETTER RHO */ { 0x07d2, 0x03a3 }, /* Greek_SIGMA Σ GREEK CAPITAL LETTER SIGMA */ { 0x07d4, 0x03a4 }, /* Greek_TAU Τ GREEK CAPITAL LETTER TAU */ { 0x07d5, 0x03a5 }, /* Greek_UPSILON Υ GREEK CAPITAL LETTER UPSILON */ { 0x07d6, 0x03a6 }, /* Greek_PHI Φ GREEK CAPITAL LETTER PHI */ { 0x07d7, 0x03a7 }, /* Greek_CHI Χ GREEK CAPITAL LETTER CHI */ { 0x07d8, 0x03a8 }, /* Greek_PSI Ψ GREEK CAPITAL LETTER PSI */ { 0x07d9, 0x03a9 }, /* Greek_OMEGA Ω GREEK CAPITAL LETTER OMEGA */ { 0x07e1, 0x03b1 }, /* Greek_alpha α GREEK SMALL LETTER ALPHA */ { 0x07e2, 0x03b2 }, /* Greek_beta β GREEK SMALL LETTER BETA */ { 0x07e3, 0x03b3 }, /* Greek_gamma γ GREEK SMALL LETTER GAMMA */ { 0x07e4, 0x03b4 }, /* Greek_delta δ GREEK SMALL LETTER DELTA */ { 0x07e5, 0x03b5 }, /* Greek_epsilon ε GREEK SMALL LETTER EPSILON */ { 0x07e6, 0x03b6 }, /* Greek_zeta ζ GREEK SMALL LETTER ZETA */ { 0x07e7, 0x03b7 }, /* Greek_eta η GREEK SMALL LETTER ETA */ { 0x07e8, 0x03b8 }, /* Greek_theta θ GREEK SMALL LETTER THETA */ { 0x07e9, 0x03b9 }, /* Greek_iota ι GREEK SMALL LETTER IOTA */ { 0x07ea, 0x03ba }, /* Greek_kappa κ GREEK SMALL LETTER KAPPA */ { 0x07eb, 0x03bb }, /* Greek_lambda λ GREEK SMALL LETTER LAMDA */ { 0x07ec, 0x03bc }, /* Greek_mu μ GREEK SMALL LETTER MU */ { 0x07ed, 0x03bd }, /* Greek_nu ν GREEK SMALL LETTER NU */ { 0x07ee, 0x03be }, /* Greek_xi ξ GREEK SMALL LETTER XI */ { 0x07ef, 0x03bf }, /* Greek_omicron ο GREEK SMALL LETTER OMICRON */ { 0x07f0, 0x03c0 }, /* Greek_pi π GREEK SMALL LETTER PI */ { 0x07f1, 0x03c1 }, /* Greek_rho ρ GREEK SMALL LETTER RHO */ { 0x07f2, 0x03c3 }, /* Greek_sigma σ GREEK SMALL LETTER SIGMA */ { 0x07f3, 0x03c2 }, /* Greek_finalsmallsigma ς GREEK SMALL LETTER FINAL SIGMA */ { 0x07f4, 0x03c4 }, /* Greek_tau τ GREEK SMALL LETTER TAU */ { 0x07f5, 0x03c5 }, /* Greek_upsilon υ GREEK SMALL LETTER UPSILON */ { 0x07f6, 0x03c6 }, /* Greek_phi φ GREEK SMALL LETTER PHI */ { 0x07f7, 0x03c7 }, /* Greek_chi χ GREEK SMALL LETTER CHI */ { 0x07f8, 0x03c8 }, /* Greek_psi ψ GREEK SMALL LETTER PSI */ { 0x07f9, 0x03c9 }, /* Greek_omega ω GREEK SMALL LETTER OMEGA */ { 0x08a1, 0x23b7 }, /* leftradical ⎷ ??? */ { 0x08a2, 0x250c }, /* topleftradical ┌ BOX DRAWINGS LIGHT DOWN AND RIGHT */ { 0x08a3, 0x2500 }, /* horizconnector ─ BOX DRAWINGS LIGHT HORIZONTAL */ { 0x08a4, 0x2320 }, /* topintegral ⌠ TOP HALF INTEGRAL */ { 0x08a5, 0x2321 }, /* botintegral ⌡ BOTTOM HALF INTEGRAL */ { 0x08a6, 0x2502 }, /* vertconnector │ BOX DRAWINGS LIGHT VERTICAL */ { 0x08a7, 0x23a1 }, /* topleftsqbracket ⎡ ??? */ { 0x08a8, 0x23a3 }, /* botleftsqbracket ⎣ ??? */ { 0x08a9, 0x23a4 }, /* toprightsqbracket ⎤ ??? */ { 0x08aa, 0x23a6 }, /* botrightsqbracket ⎦ ??? */ { 0x08ab, 0x239b }, /* topleftparens ⎛ ??? */ { 0x08ac, 0x239d }, /* botleftparens ⎝ ??? */ { 0x08ad, 0x239e }, /* toprightparens ⎞ ??? */ { 0x08ae, 0x23a0 }, /* botrightparens ⎠ ??? */ { 0x08af, 0x23a8 }, /* leftmiddlecurlybrace ⎨ ??? */ { 0x08b0, 0x23ac }, /* rightmiddlecurlybrace ⎬ ??? */ /* 0x08b1 topleftsummation ? ??? */ /* 0x08b2 botleftsummation ? ??? */ /* 0x08b3 topvertsummationconnector ? ??? */ /* 0x08b4 botvertsummationconnector ? ??? */ /* 0x08b5 toprightsummation ? ??? */ /* 0x08b6 botrightsummation ? ??? */ /* 0x08b7 rightmiddlesummation ? ??? */ { 0x08bc, 0x2264 }, /* lessthanequal ≤ LESS-THAN OR EQUAL TO */ { 0x08bd, 0x2260 }, /* notequal ≠ NOT EQUAL TO */ { 0x08be, 0x2265 }, /* greaterthanequal ≥ GREATER-THAN OR EQUAL TO */ { 0x08bf, 0x222b }, /* integral ∫ INTEGRAL */ { 0x08c0, 0x2234 }, /* therefore ∴ THEREFORE */ { 0x08c1, 0x221d }, /* variation ∝ PROPORTIONAL TO */ { 0x08c2, 0x221e }, /* infinity ∞ INFINITY */ { 0x08c5, 0x2207 }, /* nabla ∇ NABLA */ { 0x08c8, 0x223c }, /* approximate ∼ TILDE OPERATOR */ { 0x08c9, 0x2243 }, /* similarequal ≃ ASYMPTOTICALLY EQUAL TO */ { 0x08cd, 0x21d4 }, /* ifonlyif ⇔ LEFT RIGHT DOUBLE ARROW */ { 0x08ce, 0x21d2 }, /* implies ⇒ RIGHTWARDS DOUBLE ARROW */ { 0x08cf, 0x2261 }, /* identical ≡ IDENTICAL TO */ { 0x08d6, 0x221a }, /* radical √ SQUARE ROOT */ { 0x08da, 0x2282 }, /* includedin ⊂ SUBSET OF */ { 0x08db, 0x2283 }, /* includes ⊃ SUPERSET OF */ { 0x08dc, 0x2229 }, /* intersection ∩ INTERSECTION */ { 0x08dd, 0x222a }, /* union ∪ UNION */ { 0x08de, 0x2227 }, /* logicaland ∧ LOGICAL AND */ { 0x08df, 0x2228 }, /* logicalor ∨ LOGICAL OR */ { 0x08ef, 0x2202 }, /* partialderivative ∂ PARTIAL DIFFERENTIAL */ { 0x08f6, 0x0192 }, /* function ƒ LATIN SMALL LETTER F WITH HOOK */ { 0x08fb, 0x2190 }, /* leftarrow ← LEFTWARDS ARROW */ { 0x08fc, 0x2191 }, /* uparrow ↑ UPWARDS ARROW */ { 0x08fd, 0x2192 }, /* rightarrow → RIGHTWARDS ARROW */ { 0x08fe, 0x2193 }, /* downarrow ↓ DOWNWARDS ARROW */ /* 0x09df blank ? ??? */ { 0x09e0, 0x25c6 }, /* soliddiamond ◆ BLACK DIAMOND */ { 0x09e1, 0x2592 }, /* checkerboard ▒ MEDIUM SHADE */ { 0x09e2, 0x2409 }, /* ht ␉ SYMBOL FOR HORIZONTAL TABULATION */ { 0x09e3, 0x240c }, /* ff ␌ SYMBOL FOR FORM FEED */ { 0x09e4, 0x240d }, /* cr ␍ SYMBOL FOR CARRIAGE RETURN */ { 0x09e5, 0x240a }, /* lf ␊ SYMBOL FOR LINE FEED */ { 0x09e8, 0x2424 }, /* nl ␤ SYMBOL FOR NEWLINE */ { 0x09e9, 0x240b }, /* vt ␋ SYMBOL FOR VERTICAL TABULATION */ { 0x09ea, 0x2518 }, /* lowrightcorner ┘ BOX DRAWINGS LIGHT UP AND LEFT */ { 0x09eb, 0x2510 }, /* uprightcorner ┐ BOX DRAWINGS LIGHT DOWN AND LEFT */ { 0x09ec, 0x250c }, /* upleftcorner ┌ BOX DRAWINGS LIGHT DOWN AND RIGHT */ { 0x09ed, 0x2514 }, /* lowleftcorner └ BOX DRAWINGS LIGHT UP AND RIGHT */ { 0x09ee, 0x253c }, /* crossinglines ┼ BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */ { 0x09ef, 0x23ba }, /* horizlinescan1 ⎺ HORIZONTAL SCAN LINE-1 (Unicode 3.2 draft) */ { 0x09f0, 0x23bb }, /* horizlinescan3 ⎻ HORIZONTAL SCAN LINE-3 (Unicode 3.2 draft) */ { 0x09f1, 0x2500 }, /* horizlinescan5 ─ BOX DRAWINGS LIGHT HORIZONTAL */ { 0x09f2, 0x23bc }, /* horizlinescan7 ⎼ HORIZONTAL SCAN LINE-7 (Unicode 3.2 draft) */ { 0x09f3, 0x23bd }, /* horizlinescan9 ⎽ HORIZONTAL SCAN LINE-9 (Unicode 3.2 draft) */ { 0x09f4, 0x251c }, /* leftt ├ BOX DRAWINGS LIGHT VERTICAL AND RIGHT */ { 0x09f5, 0x2524 }, /* rightt ┤ BOX DRAWINGS LIGHT VERTICAL AND LEFT */ { 0x09f6, 0x2534 }, /* bott ┴ BOX DRAWINGS LIGHT UP AND HORIZONTAL */ { 0x09f7, 0x252c }, /* topt ┬ BOX DRAWINGS LIGHT DOWN AND HORIZONTAL */ { 0x09f8, 0x2502 }, /* vertbar │ BOX DRAWINGS LIGHT VERTICAL */ { 0x0aa1, 0x2003 }, /* emspace   EM SPACE */ { 0x0aa2, 0x2002 }, /* enspace   EN SPACE */ { 0x0aa3, 0x2004 }, /* em3space   THREE-PER-EM SPACE */ { 0x0aa4, 0x2005 }, /* em4space   FOUR-PER-EM SPACE */ { 0x0aa5, 0x2007 }, /* digitspace   FIGURE SPACE */ { 0x0aa6, 0x2008 }, /* punctspace   PUNCTUATION SPACE */ { 0x0aa7, 0x2009 }, /* thinspace   THIN SPACE */ { 0x0aa8, 0x200a }, /* hairspace   HAIR SPACE */ { 0x0aa9, 0x2014 }, /* emdash — EM DASH */ { 0x0aaa, 0x2013 }, /* endash – EN DASH */ /* 0x0aac signifblank ? ??? */ { 0x0aae, 0x2026 }, /* ellipsis … HORIZONTAL ELLIPSIS */ { 0x0aaf, 0x2025 }, /* doubbaselinedot ‥ TWO DOT LEADER */ { 0x0ab0, 0x2153 }, /* onethird ⅓ VULGAR FRACTION ONE THIRD */ { 0x0ab1, 0x2154 }, /* twothirds ⅔ VULGAR FRACTION TWO THIRDS */ { 0x0ab2, 0x2155 }, /* onefifth ⅕ VULGAR FRACTION ONE FIFTH */ { 0x0ab3, 0x2156 }, /* twofifths ⅖ VULGAR FRACTION TWO FIFTHS */ { 0x0ab4, 0x2157 }, /* threefifths ⅗ VULGAR FRACTION THREE FIFTHS */ { 0x0ab5, 0x2158 }, /* fourfifths ⅘ VULGAR FRACTION FOUR FIFTHS */ { 0x0ab6, 0x2159 }, /* onesixth ⅙ VULGAR FRACTION ONE SIXTH */ { 0x0ab7, 0x215a }, /* fivesixths ⅚ VULGAR FRACTION FIVE SIXTHS */ { 0x0ab8, 0x2105 }, /* careof ℅ CARE OF */ { 0x0abb, 0x2012 }, /* figdash ‒ FIGURE DASH */ { 0x0abc, 0x2329 }, /* leftanglebracket 〈 LEFT-POINTING ANGLE BRACKET */ /* 0x0abd decimalpoint ? ??? */ { 0x0abe, 0x232a }, /* rightanglebracket 〉 RIGHT-POINTING ANGLE BRACKET */ /* 0x0abf marker ? ??? */ { 0x0ac3, 0x215b }, /* oneeighth ⅛ VULGAR FRACTION ONE EIGHTH */ { 0x0ac4, 0x215c }, /* threeeighths ⅜ VULGAR FRACTION THREE EIGHTHS */ { 0x0ac5, 0x215d }, /* fiveeighths ⅝ VULGAR FRACTION FIVE EIGHTHS */ { 0x0ac6, 0x215e }, /* seveneighths ⅞ VULGAR FRACTION SEVEN EIGHTHS */ { 0x0ac9, 0x2122 }, /* trademark ™ TRADE MARK SIGN */ { 0x0aca, 0x2613 }, /* signaturemark ☓ SALTIRE */ /* 0x0acb trademarkincircle ? ??? */ { 0x0acc, 0x25c1 }, /* leftopentriangle ◁ WHITE LEFT-POINTING TRIANGLE */ { 0x0acd, 0x25b7 }, /* rightopentriangle ▷ WHITE RIGHT-POINTING TRIANGLE */ { 0x0ace, 0x25cb }, /* emopencircle ○ WHITE CIRCLE */ { 0x0acf, 0x25af }, /* emopenrectangle ▯ WHITE VERTICAL RECTANGLE */ { 0x0ad0, 0x2018 }, /* leftsinglequotemark ‘ LEFT SINGLE QUOTATION MARK */ { 0x0ad1, 0x2019 }, /* rightsinglequotemark ’ RIGHT SINGLE QUOTATION MARK */ { 0x0ad2, 0x201c }, /* leftdoublequotemark “ LEFT DOUBLE QUOTATION MARK */ { 0x0ad3, 0x201d }, /* rightdoublequotemark ” RIGHT DOUBLE QUOTATION MARK */ { 0x0ad4, 0x211e }, /* prescription ℞ PRESCRIPTION TAKE */ { 0x0ad6, 0x2032 }, /* minutes ′ PRIME */ { 0x0ad7, 0x2033 }, /* seconds ″ DOUBLE PRIME */ { 0x0ad9, 0x271d }, /* latincross ✝ LATIN CROSS */ /* 0x0ada hexagram ? ??? */ { 0x0adb, 0x25ac }, /* filledrectbullet ▬ BLACK RECTANGLE */ { 0x0adc, 0x25c0 }, /* filledlefttribullet ◀ BLACK LEFT-POINTING TRIANGLE */ { 0x0add, 0x25b6 }, /* filledrighttribullet ▶ BLACK RIGHT-POINTING TRIANGLE */ { 0x0ade, 0x25cf }, /* emfilledcircle ● BLACK CIRCLE */ { 0x0adf, 0x25ae }, /* emfilledrect ▮ BLACK VERTICAL RECTANGLE */ { 0x0ae0, 0x25e6 }, /* enopencircbullet ◦ WHITE BULLET */ { 0x0ae1, 0x25ab }, /* enopensquarebullet ▫ WHITE SMALL SQUARE */ { 0x0ae2, 0x25ad }, /* openrectbullet ▭ WHITE RECTANGLE */ { 0x0ae3, 0x25b3 }, /* opentribulletup △ WHITE UP-POINTING TRIANGLE */ { 0x0ae4, 0x25bd }, /* opentribulletdown ▽ WHITE DOWN-POINTING TRIANGLE */ { 0x0ae5, 0x2606 }, /* openstar ☆ WHITE STAR */ { 0x0ae6, 0x2022 }, /* enfilledcircbullet • BULLET */ { 0x0ae7, 0x25aa }, /* enfilledsqbullet ▪ BLACK SMALL SQUARE */ { 0x0ae8, 0x25b2 }, /* filledtribulletup ▲ BLACK UP-POINTING TRIANGLE */ { 0x0ae9, 0x25bc }, /* filledtribulletdown ▼ BLACK DOWN-POINTING TRIANGLE */ { 0x0aea, 0x261c }, /* leftpointer ☜ WHITE LEFT POINTING INDEX */ { 0x0aeb, 0x261e }, /* rightpointer ☞ WHITE RIGHT POINTING INDEX */ { 0x0aec, 0x2663 }, /* club ♣ BLACK CLUB SUIT */ { 0x0aed, 0x2666 }, /* diamond ♦ BLACK DIAMOND SUIT */ { 0x0aee, 0x2665 }, /* heart ♥ BLACK HEART SUIT */ { 0x0af0, 0x2720 }, /* maltesecross ✠ MALTESE CROSS */ { 0x0af1, 0x2020 }, /* dagger † DAGGER */ { 0x0af2, 0x2021 }, /* doubledagger ‡ DOUBLE DAGGER */ { 0x0af3, 0x2713 }, /* checkmark ✓ CHECK MARK */ { 0x0af4, 0x2717 }, /* ballotcross ✗ BALLOT X */ { 0x0af5, 0x266f }, /* musicalsharp ♯ MUSIC SHARP SIGN */ { 0x0af6, 0x266d }, /* musicalflat ♭ MUSIC FLAT SIGN */ { 0x0af7, 0x2642 }, /* malesymbol ♂ MALE SIGN */ { 0x0af8, 0x2640 }, /* femalesymbol ♀ FEMALE SIGN */ { 0x0af9, 0x260e }, /* telephone ☎ BLACK TELEPHONE */ { 0x0afa, 0x2315 }, /* telephonerecorder ⌕ TELEPHONE RECORDER */ { 0x0afb, 0x2117 }, /* phonographcopyright ℗ SOUND RECORDING COPYRIGHT */ { 0x0afc, 0x2038 }, /* caret ‸ CARET */ { 0x0afd, 0x201a }, /* singlelowquotemark ‚ SINGLE LOW-9 QUOTATION MARK */ { 0x0afe, 0x201e }, /* doublelowquotemark „ DOUBLE LOW-9 QUOTATION MARK */ /* 0x0aff cursor ? ??? */ { 0x0ba3, 0x003c }, /* leftcaret < LESS-THAN SIGN */ { 0x0ba6, 0x003e }, /* rightcaret > GREATER-THAN SIGN */ { 0x0ba8, 0x2228 }, /* downcaret ∨ LOGICAL OR */ { 0x0ba9, 0x2227 }, /* upcaret ∧ LOGICAL AND */ { 0x0bc0, 0x00af }, /* overbar ¯ MACRON */ { 0x0bc2, 0x22a5 }, /* downtack ⊥ UP TACK */ { 0x0bc3, 0x2229 }, /* upshoe ∩ INTERSECTION */ { 0x0bc4, 0x230a }, /* downstile ⌊ LEFT FLOOR */ { 0x0bc6, 0x005f }, /* underbar _ LOW LINE */ { 0x0bca, 0x2218 }, /* jot ∘ RING OPERATOR */ { 0x0bcc, 0x2395 }, /* quad ⎕ APL FUNCTIONAL SYMBOL QUAD */ { 0x0bce, 0x22a4 }, /* uptack ⊤ DOWN TACK */ { 0x0bcf, 0x25cb }, /* circle ○ WHITE CIRCLE */ { 0x0bd3, 0x2308 }, /* upstile ⌈ LEFT CEILING */ { 0x0bd6, 0x222a }, /* downshoe ∪ UNION */ { 0x0bd8, 0x2283 }, /* rightshoe ⊃ SUPERSET OF */ { 0x0bda, 0x2282 }, /* leftshoe ⊂ SUBSET OF */ { 0x0bdc, 0x22a2 }, /* lefttack ⊢ RIGHT TACK */ { 0x0bfc, 0x22a3 }, /* righttack ⊣ LEFT TACK */ { 0x0cdf, 0x2017 }, /* hebrew_doublelowline ‗ DOUBLE LOW LINE */ { 0x0ce0, 0x05d0 }, /* hebrew_aleph א HEBREW LETTER ALEF */ { 0x0ce1, 0x05d1 }, /* hebrew_bet ב HEBREW LETTER BET */ { 0x0ce2, 0x05d2 }, /* hebrew_gimel ג HEBREW LETTER GIMEL */ { 0x0ce3, 0x05d3 }, /* hebrew_dalet ד HEBREW LETTER DALET */ { 0x0ce4, 0x05d4 }, /* hebrew_he ה HEBREW LETTER HE */ { 0x0ce5, 0x05d5 }, /* hebrew_waw ו HEBREW LETTER VAV */ { 0x0ce6, 0x05d6 }, /* hebrew_zain ז HEBREW LETTER ZAYIN */ { 0x0ce7, 0x05d7 }, /* hebrew_chet ח HEBREW LETTER HET */ { 0x0ce8, 0x05d8 }, /* hebrew_tet ט HEBREW LETTER TET */ { 0x0ce9, 0x05d9 }, /* hebrew_yod י HEBREW LETTER YOD */ { 0x0cea, 0x05da }, /* hebrew_finalkaph ך HEBREW LETTER FINAL KAF */ { 0x0ceb, 0x05db }, /* hebrew_kaph כ HEBREW LETTER KAF */ { 0x0cec, 0x05dc }, /* hebrew_lamed ל HEBREW LETTER LAMED */ { 0x0ced, 0x05dd }, /* hebrew_finalmem ם HEBREW LETTER FINAL MEM */ { 0x0cee, 0x05de }, /* hebrew_mem מ HEBREW LETTER MEM */ { 0x0cef, 0x05df }, /* hebrew_finalnun ן HEBREW LETTER FINAL NUN */ { 0x0cf0, 0x05e0 }, /* hebrew_nun נ HEBREW LETTER NUN */ { 0x0cf1, 0x05e1 }, /* hebrew_samech ס HEBREW LETTER SAMEKH */ { 0x0cf2, 0x05e2 }, /* hebrew_ayin ע HEBREW LETTER AYIN */ { 0x0cf3, 0x05e3 }, /* hebrew_finalpe ף HEBREW LETTER FINAL PE */ { 0x0cf4, 0x05e4 }, /* hebrew_pe פ HEBREW LETTER PE */ { 0x0cf5, 0x05e5 }, /* hebrew_finalzade ץ HEBREW LETTER FINAL TSADI */ { 0x0cf6, 0x05e6 }, /* hebrew_zade צ HEBREW LETTER TSADI */ { 0x0cf7, 0x05e7 }, /* hebrew_qoph ק HEBREW LETTER QOF */ { 0x0cf8, 0x05e8 }, /* hebrew_resh ר HEBREW LETTER RESH */ { 0x0cf9, 0x05e9 }, /* hebrew_shin ש HEBREW LETTER SHIN */ { 0x0cfa, 0x05ea }, /* hebrew_taw ת HEBREW LETTER TAV */ { 0x0da1, 0x0e01 }, /* Thai_kokai ก THAI CHARACTER KO KAI */ { 0x0da2, 0x0e02 }, /* Thai_khokhai ข THAI CHARACTER KHO KHAI */ { 0x0da3, 0x0e03 }, /* Thai_khokhuat ฃ THAI CHARACTER KHO KHUAT */ { 0x0da4, 0x0e04 }, /* Thai_khokhwai ค THAI CHARACTER KHO KHWAI */ { 0x0da5, 0x0e05 }, /* Thai_khokhon ฅ THAI CHARACTER KHO KHON */ { 0x0da6, 0x0e06 }, /* Thai_khorakhang ฆ THAI CHARACTER KHO RAKHANG */ { 0x0da7, 0x0e07 }, /* Thai_ngongu ง THAI CHARACTER NGO NGU */ { 0x0da8, 0x0e08 }, /* Thai_chochan จ THAI CHARACTER CHO CHAN */ { 0x0da9, 0x0e09 }, /* Thai_choching ฉ THAI CHARACTER CHO CHING */ { 0x0daa, 0x0e0a }, /* Thai_chochang ช THAI CHARACTER CHO CHANG */ { 0x0dab, 0x0e0b }, /* Thai_soso ซ THAI CHARACTER SO SO */ { 0x0dac, 0x0e0c }, /* Thai_chochoe ฌ THAI CHARACTER CHO CHOE */ { 0x0dad, 0x0e0d }, /* Thai_yoying ญ THAI CHARACTER YO YING */ { 0x0dae, 0x0e0e }, /* Thai_dochada ฎ THAI CHARACTER DO CHADA */ { 0x0daf, 0x0e0f }, /* Thai_topatak ฏ THAI CHARACTER TO PATAK */ { 0x0db0, 0x0e10 }, /* Thai_thothan ฐ THAI CHARACTER THO THAN */ { 0x0db1, 0x0e11 }, /* Thai_thonangmontho ฑ THAI CHARACTER THO NANGMONTHO */ { 0x0db2, 0x0e12 }, /* Thai_thophuthao ฒ THAI CHARACTER THO PHUTHAO */ { 0x0db3, 0x0e13 }, /* Thai_nonen ณ THAI CHARACTER NO NEN */ { 0x0db4, 0x0e14 }, /* Thai_dodek ด THAI CHARACTER DO DEK */ { 0x0db5, 0x0e15 }, /* Thai_totao ต THAI CHARACTER TO TAO */ { 0x0db6, 0x0e16 }, /* Thai_thothung ถ THAI CHARACTER THO THUNG */ { 0x0db7, 0x0e17 }, /* Thai_thothahan ท THAI CHARACTER THO THAHAN */ { 0x0db8, 0x0e18 }, /* Thai_thothong ธ THAI CHARACTER THO THONG */ { 0x0db9, 0x0e19 }, /* Thai_nonu น THAI CHARACTER NO NU */ { 0x0dba, 0x0e1a }, /* Thai_bobaimai บ THAI CHARACTER BO BAIMAI */ { 0x0dbb, 0x0e1b }, /* Thai_popla ป THAI CHARACTER PO PLA */ { 0x0dbc, 0x0e1c }, /* Thai_phophung ผ THAI CHARACTER PHO PHUNG */ { 0x0dbd, 0x0e1d }, /* Thai_fofa ฝ THAI CHARACTER FO FA */ { 0x0dbe, 0x0e1e }, /* Thai_phophan พ THAI CHARACTER PHO PHAN */ { 0x0dbf, 0x0e1f }, /* Thai_fofan ฟ THAI CHARACTER FO FAN */ { 0x0dc0, 0x0e20 }, /* Thai_phosamphao ภ THAI CHARACTER PHO SAMPHAO */ { 0x0dc1, 0x0e21 }, /* Thai_moma ม THAI CHARACTER MO MA */ { 0x0dc2, 0x0e22 }, /* Thai_yoyak ย THAI CHARACTER YO YAK */ { 0x0dc3, 0x0e23 }, /* Thai_rorua ร THAI CHARACTER RO RUA */ { 0x0dc4, 0x0e24 }, /* Thai_ru ฤ THAI CHARACTER RU */ { 0x0dc5, 0x0e25 }, /* Thai_loling ล THAI CHARACTER LO LING */ { 0x0dc6, 0x0e26 }, /* Thai_lu ฦ THAI CHARACTER LU */ { 0x0dc7, 0x0e27 }, /* Thai_wowaen ว THAI CHARACTER WO WAEN */ { 0x0dc8, 0x0e28 }, /* Thai_sosala ศ THAI CHARACTER SO SALA */ { 0x0dc9, 0x0e29 }, /* Thai_sorusi ษ THAI CHARACTER SO RUSI */ { 0x0dca, 0x0e2a }, /* Thai_sosua ส THAI CHARACTER SO SUA */ { 0x0dcb, 0x0e2b }, /* Thai_hohip ห THAI CHARACTER HO HIP */ { 0x0dcc, 0x0e2c }, /* Thai_lochula ฬ THAI CHARACTER LO CHULA */ { 0x0dcd, 0x0e2d }, /* Thai_oang อ THAI CHARACTER O ANG */ { 0x0dce, 0x0e2e }, /* Thai_honokhuk ฮ THAI CHARACTER HO NOKHUK */ { 0x0dcf, 0x0e2f }, /* Thai_paiyannoi ฯ THAI CHARACTER PAIYANNOI */ { 0x0dd0, 0x0e30 }, /* Thai_saraa ะ THAI CHARACTER SARA A */ { 0x0dd1, 0x0e31 }, /* Thai_maihanakat ั THAI CHARACTER MAI HAN-AKAT */ { 0x0dd2, 0x0e32 }, /* Thai_saraaa า THAI CHARACTER SARA AA */ { 0x0dd3, 0x0e33 }, /* Thai_saraam ำ THAI CHARACTER SARA AM */ { 0x0dd4, 0x0e34 }, /* Thai_sarai ิ THAI CHARACTER SARA I */ { 0x0dd5, 0x0e35 }, /* Thai_saraii ี THAI CHARACTER SARA II */ { 0x0dd6, 0x0e36 }, /* Thai_saraue ึ THAI CHARACTER SARA UE */ { 0x0dd7, 0x0e37 }, /* Thai_sarauee ื THAI CHARACTER SARA UEE */ { 0x0dd8, 0x0e38 }, /* Thai_sarau ุ THAI CHARACTER SARA U */ { 0x0dd9, 0x0e39 }, /* Thai_sarauu ู THAI CHARACTER SARA UU */ { 0x0dda, 0x0e3a }, /* Thai_phinthu ฺ THAI CHARACTER PHINTHU */ /* 0x0dde Thai_maihanakat_maitho ? ??? */ { 0x0ddf, 0x0e3f }, /* Thai_baht ฿ THAI CURRENCY SYMBOL BAHT */ { 0x0de0, 0x0e40 }, /* Thai_sarae เ THAI CHARACTER SARA E */ { 0x0de1, 0x0e41 }, /* Thai_saraae แ THAI CHARACTER SARA AE */ { 0x0de2, 0x0e42 }, /* Thai_sarao โ THAI CHARACTER SARA O */ { 0x0de3, 0x0e43 }, /* Thai_saraaimaimuan ใ THAI CHARACTER SARA AI MAIMUAN */ { 0x0de4, 0x0e44 }, /* Thai_saraaimaimalai ไ THAI CHARACTER SARA AI MAIMALAI */ { 0x0de5, 0x0e45 }, /* Thai_lakkhangyao ๅ THAI CHARACTER LAKKHANGYAO */ { 0x0de6, 0x0e46 }, /* Thai_maiyamok ๆ THAI CHARACTER MAIYAMOK */ { 0x0de7, 0x0e47 }, /* Thai_maitaikhu ็ THAI CHARACTER MAITAIKHU */ { 0x0de8, 0x0e48 }, /* Thai_maiek ่ THAI CHARACTER MAI EK */ { 0x0de9, 0x0e49 }, /* Thai_maitho ้ THAI CHARACTER MAI THO */ { 0x0dea, 0x0e4a }, /* Thai_maitri ๊ THAI CHARACTER MAI TRI */ { 0x0deb, 0x0e4b }, /* Thai_maichattawa ๋ THAI CHARACTER MAI CHATTAWA */ { 0x0dec, 0x0e4c }, /* Thai_thanthakhat ์ THAI CHARACTER THANTHAKHAT */ { 0x0ded, 0x0e4d }, /* Thai_nikhahit ํ THAI CHARACTER NIKHAHIT */ { 0x0df0, 0x0e50 }, /* Thai_leksun ๐ THAI DIGIT ZERO */ { 0x0df1, 0x0e51 }, /* Thai_leknung ๑ THAI DIGIT ONE */ { 0x0df2, 0x0e52 }, /* Thai_leksong ๒ THAI DIGIT TWO */ { 0x0df3, 0x0e53 }, /* Thai_leksam ๓ THAI DIGIT THREE */ { 0x0df4, 0x0e54 }, /* Thai_leksi ๔ THAI DIGIT FOUR */ { 0x0df5, 0x0e55 }, /* Thai_lekha ๕ THAI DIGIT FIVE */ { 0x0df6, 0x0e56 }, /* Thai_lekhok ๖ THAI DIGIT SIX */ { 0x0df7, 0x0e57 }, /* Thai_lekchet ๗ THAI DIGIT SEVEN */ { 0x0df8, 0x0e58 }, /* Thai_lekpaet ๘ THAI DIGIT EIGHT */ { 0x0df9, 0x0e59 }, /* Thai_lekkao ๙ THAI DIGIT NINE */ { 0x0ea1, 0x3131 }, /* Hangul_Kiyeog ㄱ HANGUL LETTER KIYEOK */ { 0x0ea2, 0x3132 }, /* Hangul_SsangKiyeog ㄲ HANGUL LETTER SSANGKIYEOK */ { 0x0ea3, 0x3133 }, /* Hangul_KiyeogSios ㄳ HANGUL LETTER KIYEOK-SIOS */ { 0x0ea4, 0x3134 }, /* Hangul_Nieun ㄴ HANGUL LETTER NIEUN */ { 0x0ea5, 0x3135 }, /* Hangul_NieunJieuj ㄵ HANGUL LETTER NIEUN-CIEUC */ { 0x0ea6, 0x3136 }, /* Hangul_NieunHieuh ㄶ HANGUL LETTER NIEUN-HIEUH */ { 0x0ea7, 0x3137 }, /* Hangul_Dikeud ㄷ HANGUL LETTER TIKEUT */ { 0x0ea8, 0x3138 }, /* Hangul_SsangDikeud ㄸ HANGUL LETTER SSANGTIKEUT */ { 0x0ea9, 0x3139 }, /* Hangul_Rieul ㄹ HANGUL LETTER RIEUL */ { 0x0eaa, 0x313a }, /* Hangul_RieulKiyeog ㄺ HANGUL LETTER RIEUL-KIYEOK */ { 0x0eab, 0x313b }, /* Hangul_RieulMieum ㄻ HANGUL LETTER RIEUL-MIEUM */ { 0x0eac, 0x313c }, /* Hangul_RieulPieub ㄼ HANGUL LETTER RIEUL-PIEUP */ { 0x0ead, 0x313d }, /* Hangul_RieulSios ㄽ HANGUL LETTER RIEUL-SIOS */ { 0x0eae, 0x313e }, /* Hangul_RieulTieut ㄾ HANGUL LETTER RIEUL-THIEUTH */ { 0x0eaf, 0x313f }, /* Hangul_RieulPhieuf ㄿ HANGUL LETTER RIEUL-PHIEUPH */ { 0x0eb0, 0x3140 }, /* Hangul_RieulHieuh ㅀ HANGUL LETTER RIEUL-HIEUH */ { 0x0eb1, 0x3141 }, /* Hangul_Mieum ㅁ HANGUL LETTER MIEUM */ { 0x0eb2, 0x3142 }, /* Hangul_Pieub ㅂ HANGUL LETTER PIEUP */ { 0x0eb3, 0x3143 }, /* Hangul_SsangPieub ㅃ HANGUL LETTER SSANGPIEUP */ { 0x0eb4, 0x3144 }, /* Hangul_PieubSios ㅄ HANGUL LETTER PIEUP-SIOS */ { 0x0eb5, 0x3145 }, /* Hangul_Sios ㅅ HANGUL LETTER SIOS */ { 0x0eb6, 0x3146 }, /* Hangul_SsangSios ㅆ HANGUL LETTER SSANGSIOS */ { 0x0eb7, 0x3147 }, /* Hangul_Ieung ㅇ HANGUL LETTER IEUNG */ { 0x0eb8, 0x3148 }, /* Hangul_Jieuj ㅈ HANGUL LETTER CIEUC */ { 0x0eb9, 0x3149 }, /* Hangul_SsangJieuj ㅉ HANGUL LETTER SSANGCIEUC */ { 0x0eba, 0x314a }, /* Hangul_Cieuc ㅊ HANGUL LETTER CHIEUCH */ { 0x0ebb, 0x314b }, /* Hangul_Khieuq ㅋ HANGUL LETTER KHIEUKH */ { 0x0ebc, 0x314c }, /* Hangul_Tieut ㅌ HANGUL LETTER THIEUTH */ { 0x0ebd, 0x314d }, /* Hangul_Phieuf ㅍ HANGUL LETTER PHIEUPH */ { 0x0ebe, 0x314e }, /* Hangul_Hieuh ㅎ HANGUL LETTER HIEUH */ { 0x0ebf, 0x314f }, /* Hangul_A ㅏ HANGUL LETTER A */ { 0x0ec0, 0x3150 }, /* Hangul_AE ㅐ HANGUL LETTER AE */ { 0x0ec1, 0x3151 }, /* Hangul_YA ㅑ HANGUL LETTER YA */ { 0x0ec2, 0x3152 }, /* Hangul_YAE ㅒ HANGUL LETTER YAE */ { 0x0ec3, 0x3153 }, /* Hangul_EO ㅓ HANGUL LETTER EO */ { 0x0ec4, 0x3154 }, /* Hangul_E ㅔ HANGUL LETTER E */ { 0x0ec5, 0x3155 }, /* Hangul_YEO ㅕ HANGUL LETTER YEO */ { 0x0ec6, 0x3156 }, /* Hangul_YE ㅖ HANGUL LETTER YE */ { 0x0ec7, 0x3157 }, /* Hangul_O ㅗ HANGUL LETTER O */ { 0x0ec8, 0x3158 }, /* Hangul_WA ㅘ HANGUL LETTER WA */ { 0x0ec9, 0x3159 }, /* Hangul_WAE ㅙ HANGUL LETTER WAE */ { 0x0eca, 0x315a }, /* Hangul_OE ㅚ HANGUL LETTER OE */ { 0x0ecb, 0x315b }, /* Hangul_YO ㅛ HANGUL LETTER YO */ { 0x0ecc, 0x315c }, /* Hangul_U ㅜ HANGUL LETTER U */ { 0x0ecd, 0x315d }, /* Hangul_WEO ㅝ HANGUL LETTER WEO */ { 0x0ece, 0x315e }, /* Hangul_WE ㅞ HANGUL LETTER WE */ { 0x0ecf, 0x315f }, /* Hangul_WI ㅟ HANGUL LETTER WI */ { 0x0ed0, 0x3160 }, /* Hangul_YU ㅠ HANGUL LETTER YU */ { 0x0ed1, 0x3161 }, /* Hangul_EU ㅡ HANGUL LETTER EU */ { 0x0ed2, 0x3162 }, /* Hangul_YI ㅢ HANGUL LETTER YI */ { 0x0ed3, 0x3163 }, /* Hangul_I ㅣ HANGUL LETTER I */ { 0x0ed4, 0x11a8 }, /* Hangul_J_Kiyeog ᆨ HANGUL JONGSEONG KIYEOK */ { 0x0ed5, 0x11a9 }, /* Hangul_J_SsangKiyeog ᆩ HANGUL JONGSEONG SSANGKIYEOK */ { 0x0ed6, 0x11aa }, /* Hangul_J_KiyeogSios ᆪ HANGUL JONGSEONG KIYEOK-SIOS */ { 0x0ed7, 0x11ab }, /* Hangul_J_Nieun ᆫ HANGUL JONGSEONG NIEUN */ { 0x0ed8, 0x11ac }, /* Hangul_J_NieunJieuj ᆬ HANGUL JONGSEONG NIEUN-CIEUC */ { 0x0ed9, 0x11ad }, /* Hangul_J_NieunHieuh ᆭ HANGUL JONGSEONG NIEUN-HIEUH */ { 0x0eda, 0x11ae }, /* Hangul_J_Dikeud ᆮ HANGUL JONGSEONG TIKEUT */ { 0x0edb, 0x11af }, /* Hangul_J_Rieul ᆯ HANGUL JONGSEONG RIEUL */ { 0x0edc, 0x11b0 }, /* Hangul_J_RieulKiyeog ᆰ HANGUL JONGSEONG RIEUL-KIYEOK */ { 0x0edd, 0x11b1 }, /* Hangul_J_RieulMieum ᆱ HANGUL JONGSEONG RIEUL-MIEUM */ { 0x0ede, 0x11b2 }, /* Hangul_J_RieulPieub ᆲ HANGUL JONGSEONG RIEUL-PIEUP */ { 0x0edf, 0x11b3 }, /* Hangul_J_RieulSios ᆳ HANGUL JONGSEONG RIEUL-SIOS */ { 0x0ee0, 0x11b4 }, /* Hangul_J_RieulTieut ᆴ HANGUL JONGSEONG RIEUL-THIEUTH */ { 0x0ee1, 0x11b5 }, /* Hangul_J_RieulPhieuf ᆵ HANGUL JONGSEONG RIEUL-PHIEUPH */ { 0x0ee2, 0x11b6 }, /* Hangul_J_RieulHieuh ᆶ HANGUL JONGSEONG RIEUL-HIEUH */ { 0x0ee3, 0x11b7 }, /* Hangul_J_Mieum ᆷ HANGUL JONGSEONG MIEUM */ { 0x0ee4, 0x11b8 }, /* Hangul_J_Pieub ᆸ HANGUL JONGSEONG PIEUP */ { 0x0ee5, 0x11b9 }, /* Hangul_J_PieubSios ᆹ HANGUL JONGSEONG PIEUP-SIOS */ { 0x0ee6, 0x11ba }, /* Hangul_J_Sios ᆺ HANGUL JONGSEONG SIOS */ { 0x0ee7, 0x11bb }, /* Hangul_J_SsangSios ᆻ HANGUL JONGSEONG SSANGSIOS */ { 0x0ee8, 0x11bc }, /* Hangul_J_Ieung ᆼ HANGUL JONGSEONG IEUNG */ { 0x0ee9, 0x11bd }, /* Hangul_J_Jieuj ᆽ HANGUL JONGSEONG CIEUC */ { 0x0eea, 0x11be }, /* Hangul_J_Cieuc ᆾ HANGUL JONGSEONG CHIEUCH */ { 0x0eeb, 0x11bf }, /* Hangul_J_Khieuq ᆿ HANGUL JONGSEONG KHIEUKH */ { 0x0eec, 0x11c0 }, /* Hangul_J_Tieut ᇀ HANGUL JONGSEONG THIEUTH */ { 0x0eed, 0x11c1 }, /* Hangul_J_Phieuf ᇁ HANGUL JONGSEONG PHIEUPH */ { 0x0eee, 0x11c2 }, /* Hangul_J_Hieuh ᇂ HANGUL JONGSEONG HIEUH */ { 0x0eef, 0x316d }, /* Hangul_RieulYeorinHieuh ㅭ HANGUL LETTER RIEUL-YEORINHIEUH */ { 0x0ef0, 0x3171 }, /* Hangul_SunkyeongeumMieum ㅱ HANGUL LETTER KAPYEOUNMIEUM */ { 0x0ef1, 0x3178 }, /* Hangul_SunkyeongeumPieub ㅸ HANGUL LETTER KAPYEOUNPIEUP */ { 0x0ef2, 0x317f }, /* Hangul_PanSios ㅿ HANGUL LETTER PANSIOS */ { 0x0ef3, 0x3181 }, /* Hangul_KkogjiDalrinIeung ㆁ HANGUL LETTER YESIEUNG */ { 0x0ef4, 0x3184 }, /* Hangul_SunkyeongeumPhieuf ㆄ HANGUL LETTER KAPYEOUNPHIEUPH */ { 0x0ef5, 0x3186 }, /* Hangul_YeorinHieuh ㆆ HANGUL LETTER YEORINHIEUH */ { 0x0ef6, 0x318d }, /* Hangul_AraeA ㆍ HANGUL LETTER ARAEA */ { 0x0ef7, 0x318e }, /* Hangul_AraeAE ㆎ HANGUL LETTER ARAEAE */ { 0x0ef8, 0x11eb }, /* Hangul_J_PanSios ᇫ HANGUL JONGSEONG PANSIOS */ { 0x0ef9, 0x11f0 }, /* Hangul_J_KkogjiDalrinIeung ᇰ HANGUL JONGSEONG YESIEUNG */ { 0x0efa, 0x11f9 }, /* Hangul_J_YeorinHieuh ᇹ HANGUL JONGSEONG YEORINHIEUH */ { 0x0eff, 0x20a9 }, /* Korean_Won ₩ WON SIGN */ { 0x13a4, 0x20ac }, /* Euro € EURO SIGN */ { 0x13bc, 0x0152 }, /* OE Œ LATIN CAPITAL LIGATURE OE */ { 0x13bd, 0x0153 }, /* oe œ LATIN SMALL LIGATURE OE */ { 0x13be, 0x0178 }, /* Ydiaeresis Ÿ LATIN CAPITAL LETTER Y WITH DIAERESIS */ { 0x20ac, 0x20ac }, /* EuroSign € EURO SIGN */ }; static uint32_t keysym2ucs(KeySym keysym) { int min = 0; int max = sizeof(keysymtab) / sizeof(struct codepair) - 1; int mid; /* first check for Latin-1 characters (1:1 mapping) */ if ((keysym >= 0x0020 && keysym <= 0x007e) || (keysym >= 0x00a0 && keysym <= 0x00ff)) return keysym; /* also check for directly encoded 24-bit UCS characters */ if ((keysym & 0xff000000) == 0x01000000) return keysym & 0x00ffffff; /* binary search in table */ while (max >= min) { mid = (min + max) / 2; if (keysymtab[mid].keysym < keysym) min = mid + 1; else if (keysymtab[mid].keysym > keysym) max = mid - 1; else { /* found it */ return keysymtab[mid].ucs; } } /* no matching Unicode value found */ return ~0; } #endif uTox/src/xlib/gtk.h0000600000175000001440000000126414003056216013164 0ustar rakusers#ifndef UTOX_GTK_H #define UTOX_GTK_H #include typedef struct file_transfer FILE_TRANSFER; typedef struct msg_header MSG_HEADER; typedef struct file_transfer FILE_TRANSFER; typedef struct { char *name; uint8_t *data; int data_size; } FILE_IMAGE; void ugtk_openfilesend(void); void ugtk_openfileavatar(void); void ugtk_native_select_dir_ft(uint32_t fid, FILE_TRANSFER *file); void ugtk_file_save_inline(MSG_HEADER *msg); void ugtk_save_chatlog(uint32_t friend_number); /** * @brief Save passed image to selected file. * * Takes ownership of file_image. */ void ugtk_file_save_image_png(FILE_IMAGE *file_image); void *ugtk_load(void); #endif // UTOX_GTK_H uTox/src/xlib/gtk.c0000600000175000001440000004604314003056216013163 0ustar rakusers#include "gtk.h" #include "../avatar.h" #include "../chatlog.h" #include "../debug.h" #include "../file_transfers.h" #include "../filesys.h" #include "../flist.h" #include "../friend.h" #include "../macros.h" #include "../text.h" #include "../tox.h" #include "../ui.h" #include "../utox.h" #include "../main.h" #include "../native/thread.h" #include "stb.h" #include #include #include #include #include #define LIBGTK_FILENAME "libgtk-3.so" #define LIBGTK_FILENAME_FALLBACK "libgtk-3.so.0" #define GTK_FILE_CHOOSER_ACTION_OPEN 0 #define GTK_FILE_CHOOSER_ACTION_SAVE 1 #define GTK_RESPONSE_ACCEPT -3 #define GTK_RESPONSE_CANCEL -6 typedef struct GSList GSList; struct GSList { void * data; GSList *next; }; /* Each of the following transiently segfaults we we use the pre-existing name. * So we have to clobber each of the real names with something localized */ void (*utoxGTK_free)(void *); void (*utoxGTK_slist_free)(GSList *); unsigned long (*utoxGTK_signal_connect_data)(void *, const char *, void *, void *, void *, int); void (*utoxGTK_object_unref)(void *); void (*utoxGTK_init)(int *, char ***); bool (*utoxGTK_events_pending)(void); bool (*utoxGTK_main_iteration)(void); void (*utoxGTK_widget_set_margin_left)(void *, int); void (*utoxGTK_widget_set_margin_right)(void *, int); void (*utoxGTK_widget_destroy)(void *); void *(*utoxGTK_message_dialog_new)(void *, int, int, int, const char *, ...); int (*utoxGTK_dialog_run)(void *); void *(*utoxGTK_file_chooser_dialog_new)(const char *, void *, int, const char *, ...); void (*utoxGTK_file_chooser_set_select_multiple)(void *, bool); void (*utoxGTK_file_chooser_set_current_name)(void *, const char *); char *(*utoxGTK_file_chooser_get_filename)(void *); GSList *(*utoxGTK_file_chooser_get_filenames)(void *); void (*utoxGTK_file_chooser_set_do_overwrite_confirmation)(void *, bool); void (*utoxGTK_file_chooser_set_filter)(void *, void *); char *(*utoxGTK_file_chooser_get_preview_filename)(void *); void (*utoxGTK_file_chooser_set_preview_widget)(void *, void *); void (*utoxGTK_file_chooser_set_preview_widget_active)(void *, bool); void *(*utoxGTK_file_filter_new)(void); void (*utoxGTK_file_filter_add_mime_type)(void *, const char *); void *(*utoxGTK_image_new)(void); void (*utoxGTK_image_set_from_pixbuf)(void *, void *); void *(*utoxGDK_pixbuf_new_from_file)(const char *, void **); void *(*utoxGDK_pixbuf_new_from_file_at_size)(const char *, int, int, void **); int (*utoxGDK_pixbuf_get_width)(const void *); int (*utoxGDK_pixbuf_get_height)(const void *); static bool utoxGTK_open; static void update_image_preview(void *filechooser, void *image) { #define MAX_PREVIEW_SIZE 256 char *filename = utoxGTK_file_chooser_get_preview_filename(filechooser); if (!filename) return; // load preview void *pixbuf = utoxGDK_pixbuf_new_from_file(filename, NULL); if (!pixbuf) { utoxGTK_free(filename); utoxGTK_file_chooser_set_preview_widget_active(filechooser, false); return; } // if preview too big load smaller if (utoxGDK_pixbuf_get_width(pixbuf) > MAX_PREVIEW_SIZE || utoxGDK_pixbuf_get_height(pixbuf) > MAX_PREVIEW_SIZE) { utoxGTK_object_unref(pixbuf); pixbuf = utoxGDK_pixbuf_new_from_file_at_size(filename, MAX_PREVIEW_SIZE, MAX_PREVIEW_SIZE, NULL); } utoxGTK_free(filename); if (!pixbuf) { utoxGTK_file_chooser_set_preview_widget_active(filechooser, false); return; } // pad to MAX_PREVIEW_SIZE + 3px margins int margin = (MAX_PREVIEW_SIZE + 6 - utoxGDK_pixbuf_get_width(pixbuf)) / 2; utoxGTK_widget_set_margin_left(image, margin); utoxGTK_widget_set_margin_right(image, margin); // set preview utoxGTK_image_set_from_pixbuf(image, pixbuf); utoxGTK_object_unref(pixbuf); utoxGTK_file_chooser_set_preview_widget_active(filechooser, true); } static void ugtk_opensendthread(void *args) { size_t fid = (size_t)args; void *dialog = utoxGTK_file_chooser_dialog_new((const char *)S(SEND_FILE), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, "_Cancel", GTK_RESPONSE_CANCEL, "_Open", GTK_RESPONSE_ACCEPT, NULL); utoxGTK_file_chooser_set_select_multiple(dialog, true); void *preview = utoxGTK_image_new(); utoxGTK_file_chooser_set_preview_widget(dialog, preview); utoxGTK_signal_connect_data(dialog, "update-preview", update_image_preview, preview, NULL, 0); int result = utoxGTK_dialog_run(dialog); if (result == GTK_RESPONSE_ACCEPT) { GSList *list = utoxGTK_file_chooser_get_filenames(dialog), *p = list; while (p) { UTOX_MSG_FT *send = calloc(1, sizeof(UTOX_MSG_FT)); if (!send) { LOG_ERR("GTK", "GTK:\tUnabled to malloc for to send an FT msg"); while(p) { utoxGTK_free(p->data); p = p->next; } utoxGTK_slist_free(list); utoxGTK_open = false; return; } LOG_INFO("GTK", "Sending file %s" , p->data); send->file = fopen(p->data, "rb"); send->name = (uint8_t*)strdup(p->data); postmessage_toxcore(TOX_FILE_SEND_NEW, (uint32_t)fid, 0, send); utoxGTK_free(p->data); p = p->next; } utoxGTK_slist_free(list); } utoxGTK_widget_destroy(dialog); while (utoxGTK_events_pending()) { utoxGTK_main_iteration(); } utoxGTK_open = false; } static void ugtk_openavatarthread(void *UNUSED(args)) { void *dialog = utoxGTK_file_chooser_dialog_new((const char *)S(SELECT_AVATAR_TITLE), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, "_Cancel", GTK_RESPONSE_CANCEL, "_Open", GTK_RESPONSE_ACCEPT, NULL); void *filter = utoxGTK_file_filter_new(); utoxGTK_file_filter_add_mime_type(filter, "image/jpeg"); utoxGTK_file_filter_add_mime_type(filter, "image/png"); utoxGTK_file_filter_add_mime_type(filter, "image/bmp"); utoxGTK_file_filter_add_mime_type(filter, "image/gif"); utoxGTK_file_chooser_set_filter(dialog, filter); void *preview = utoxGTK_image_new(); utoxGTK_file_chooser_set_preview_widget(dialog, preview); utoxGTK_signal_connect_data(dialog, "update-preview", update_image_preview, preview, NULL, 0); while (utoxGTK_dialog_run(dialog) == GTK_RESPONSE_ACCEPT) { char *filename = utoxGTK_file_chooser_get_filename(dialog); int size; int width, height, bpp; uint8_t *img = stbi_load(filename, &width, &height, &bpp, 0); uint8_t *file_data = stbi_write_png_to_mem(img, 0, width, height, bpp, &size); free(img); utoxGTK_free(filename); if (!file_data) { void *message_dialog = utoxGTK_message_dialog_new(dialog, 0, 1, 2, (const char *)S(CANT_FIND_FILE_OR_EMPTY)); utoxGTK_dialog_run(message_dialog); utoxGTK_widget_destroy(message_dialog); } else if (size > UTOX_AVATAR_MAX_DATA_LENGTH) { free(file_data); char size_str[16]; int len = sprint_humanread_bytes(size_str, sizeof(size_str), UTOX_AVATAR_MAX_DATA_LENGTH); char err_str[265] = { 0 }; snprintf((char *)err_str, 265, "%s%.*s (%ikb loaded)", S(AVATAR_TOO_LARGE_MAX_SIZE_IS), len, size_str, (size / 1024)); void *message_dialog = utoxGTK_message_dialog_new(dialog, 0, 1, 2, err_str); utoxGTK_dialog_run(message_dialog); utoxGTK_widget_destroy(message_dialog); } else { postmessage_utox(SELF_AVATAR_SET, size, 0, file_data); break; } } utoxGTK_widget_destroy(dialog); while (utoxGTK_events_pending()) { utoxGTK_main_iteration(); } utoxGTK_open = false; } void show_messagebox(const char *UNUSED(caption), uint16_t UNUSED(caption_length), const char *message, uint16_t UNUSED(message_length)) { utoxGTK_open = true; void *dialog = utoxGTK_message_dialog_new(NULL, 0, 1, 1, message); utoxGTK_dialog_run(dialog); utoxGTK_widget_destroy(dialog); while (utoxGTK_events_pending()) { utoxGTK_main_iteration(); } utoxGTK_open = false; } static void ugtk_savethread(void *args) { FILE_TRANSFER *file = args; while (1) { // TODO, save current dir, and filename and preload them to gtk dialog if save fails. /* Create a GTK save window */ void *dialog = utoxGTK_file_chooser_dialog_new((const char *)S(WHERE_TO_SAVE_FILE), NULL, GTK_FILE_CHOOSER_ACTION_SAVE, "_Cancel", GTK_RESPONSE_CANCEL, "_Open", GTK_RESPONSE_ACCEPT, NULL); /* Get incoming file name for GTK */ char buf[file->name_length + 1]; snprintf(buf, file->name_length + 1, "%.*s", (int)file->name_length, file->name); utoxGTK_file_chooser_set_current_name(dialog, buf); utoxGTK_file_chooser_set_do_overwrite_confirmation(dialog, true); /* Users can create folders when saving. */ // TODO ENABLE BELOW! // utoxGTK_file_chooser_set_create_folders(dialog, TRUE); int result = utoxGTK_dialog_run(dialog); if (result == GTK_RESPONSE_ACCEPT) { char *name = utoxGTK_file_chooser_get_filename(dialog); char *path = strdup(name); // utoxGTK_free(name) LOG_TRACE("GTK", "name: %s\npath: %s" , name, path); /* can we really write this file? */ FILE *fp = fopen(path, "w"); if (fp == NULL) { /* No, we can't display error, jump to top. */ if (errno == EACCES) { LOG_TRACE("GTK", "File write permission denied." ); void *errordialog = utoxGTK_message_dialog_new(dialog, 1, 3, 2, // parent, destroy_with_parent, // utoxGTK_error_message, utoxGTK_buttons_close "Error writing to file '%s'", name); utoxGTK_dialog_run(errordialog); utoxGTK_widget_destroy(errordialog); utoxGTK_widget_destroy(dialog); free(path); continue; } LOG_TRACE("GTK", "Unknown file write error..." ); free(path); break; } fclose(fp); /* write test passed, we're done! */ utoxGTK_widget_destroy(dialog); utoxGTK_main_iteration(); utoxGTK_widget_destroy(dialog); postmessage_utox(FILE_INCOMING_ACCEPT, file->friend_number, (file->file_number >> 16), path); break; } else if (result == GTK_RESPONSE_CANCEL) { LOG_TRACE("GTK", "Aborting in progress file..." ); } /* catch all */ utoxGTK_widget_destroy(dialog); break; } while (utoxGTK_events_pending()) { utoxGTK_main_iteration(); } utoxGTK_open = false; } static void ugtk_save_data_thread(void *args) { MSG_HEADER *msg = args; void *dialog = utoxGTK_file_chooser_dialog_new((const char *)S(SAVE_FILE), NULL, GTK_FILE_CHOOSER_ACTION_SAVE, "_Cancel", GTK_RESPONSE_CANCEL, "_Save", GTK_RESPONSE_ACCEPT, NULL); utoxGTK_file_chooser_set_current_name(dialog, msg->via.ft.name); int result = utoxGTK_dialog_run(dialog); if (result == GTK_RESPONSE_ACCEPT) { char *name = utoxGTK_file_chooser_get_filename(dialog); FILE *fp = fopen(name, "wb"); if (fp) { fwrite(msg->via.ft.data, msg->via.ft.data_size, 1, fp); fclose(fp); if (!msg->via.ft.path) { msg->via.ft.path_length = strlen(name); msg->via.ft.path = calloc(1, msg->via.ft.path_length + 1); } if (msg->via.ft.path) { snprintf((char *)msg->via.ft.path, UTOX_FILE_NAME_LENGTH, "%s", name); } msg->via.ft.inline_png = false; } } utoxGTK_widget_destroy(dialog); while (utoxGTK_events_pending()) { utoxGTK_main_iteration(); } utoxGTK_open = false; } static void ugtk_save_chatlog_thread(void *args) { size_t friend_number = (size_t)args; FRIEND *f = get_friend(friend_number); if (!f) { LOG_ERR("GTK", "Could not get friend with number: %u", friend_number); utoxGTK_open = false; return; } char name[TOX_MAX_NAME_LENGTH + sizeof ".txt"]; snprintf(name, sizeof name, "%.*s.txt", (int)f->name_length, f->name); void *dialog = utoxGTK_file_chooser_dialog_new((const char *)S(SAVE_FILE), NULL, GTK_FILE_CHOOSER_ACTION_SAVE, "_Cancel", GTK_RESPONSE_CANCEL, "_Save", GTK_RESPONSE_ACCEPT, NULL); utoxGTK_file_chooser_set_current_name(dialog, name); int result = utoxGTK_dialog_run(dialog); if (result == GTK_RESPONSE_ACCEPT) { char *file_name = utoxGTK_file_chooser_get_filename(dialog); FILE *fp = fopen(file_name, "wb"); if (fp) { utox_export_chatlog(f->id_str, fp); } } utoxGTK_widget_destroy(dialog); while (utoxGTK_events_pending()) { utoxGTK_main_iteration(); } utoxGTK_open = false; } static void ugtk_save_image_png_thread(void *args) { FILE_IMAGE *image = args; char name[TOX_MAX_NAME_LENGTH + sizeof ".png"] = { 0 }; snprintf(name, sizeof name, "%s.png", image->name); void *dialog = utoxGTK_file_chooser_dialog_new((const char *)S(SAVE_FILE), NULL, GTK_FILE_CHOOSER_ACTION_SAVE, "_Cancel", GTK_RESPONSE_CANCEL, "_Save", GTK_RESPONSE_ACCEPT, NULL); void *filter = utoxGTK_file_filter_new(); utoxGTK_file_filter_add_mime_type(filter, "image/png"); utoxGTK_file_chooser_set_filter(dialog, filter); utoxGTK_file_chooser_set_current_name(dialog, name); int result = utoxGTK_dialog_run(dialog); if (result == GTK_RESPONSE_ACCEPT) { char *file_name = utoxGTK_file_chooser_get_filename(dialog); FILE *file = fopen(file_name, "wb"); if (file) { fwrite(image->data, image->data_size, 1, file); fclose(file); } else { LOG_ERR("GTK", "Could not open file %s for write.", file_name); } free(file_name); } utoxGTK_widget_destroy(dialog); while (utoxGTK_events_pending()) { utoxGTK_main_iteration(); } utoxGTK_open = false; free(image); } void ugtk_openfilesend(void) { if (utoxGTK_open) { return; } FRIEND *f = flist_get_sel_friend(); if (!f) { LOG_ERR("GTK", "Unable to get friend from flist."); return; } utoxGTK_open = true; uint32_t number = f->number; thread(ugtk_opensendthread, (void*)(size_t)number); } void ugtk_openfileavatar(void) { if (utoxGTK_open) { return; } utoxGTK_open = true; thread(ugtk_openavatarthread, NULL); } void ugtk_native_select_dir_ft(uint32_t UNUSED(fid), FILE_TRANSFER *file) { if (utoxGTK_open) { return; } utoxGTK_open = true; thread(ugtk_savethread, file); } void ugtk_file_save_inline(MSG_HEADER *msg) { if (utoxGTK_open) { return; } utoxGTK_open = true; thread(ugtk_save_data_thread, msg); } void ugtk_file_save_image_png(FILE_IMAGE *image) { if (utoxGTK_open) { return; } utoxGTK_open = true; thread(ugtk_save_image_png_thread, image); } void ugtk_save_chatlog(uint32_t friend_number) { if (utoxGTK_open) { return; } // We just care about sending a single uint, but we don't want to overflow a buffer size_t fnum = friend_number; utoxGTK_open = true; thread(ugtk_save_chatlog_thread, (void *)fnum); // No need to create and pass a pointer for a single u32 } /* macro to link and test each of the gtk functions we need. * This is likely more specific than in it needs to be, so * when you rewrite this, aim for generic */ #define U_DLLOAD(trgt, name) \ do { \ utoxGTK_##name = dlsym(lib, #trgt "_" #name); \ if (!utoxGTK_##name) { \ LOG_ERR("GTK", "Unable to load " #name " (%s)", dlerror()); \ dlclose(lib); \ return NULL; \ } \ } while (0) #define U_DLLOAD_GDK(name) \ do { \ utoxGDK_##name = dlsym(lib, "gdk_" #name); \ if (!utoxGDK_##name) { \ LOG_ERR("GTK", "Unable to load " #name " (%s)", dlerror()); \ dlclose(lib); \ return NULL; \ } \ } while (0) void *ugtk_load(void) { // return NULL; void *lib = dlopen(LIBGTK_FILENAME, RTLD_LAZY); if (!lib) { //try again with libgtk-3.so.0 if the first one failed LOG_INFO("GTK", "Failed loading: %s. Falling back to %s", LIBGTK_FILENAME, LIBGTK_FILENAME_FALLBACK); lib = dlopen(LIBGTK_FILENAME_FALLBACK, RTLD_LAZY); } if (lib) { LOG_TRACE("GTK", "have GTK" ); U_DLLOAD(gtk, init); U_DLLOAD(gtk, main_iteration); U_DLLOAD(gtk, events_pending); U_DLLOAD(gtk, file_chooser_dialog_new); U_DLLOAD(gtk, file_filter_new); U_DLLOAD(gtk, message_dialog_new); U_DLLOAD(gtk, dialog_run); U_DLLOAD(gtk, file_chooser_get_filename); U_DLLOAD(gtk, file_chooser_get_filenames); U_DLLOAD(gtk, file_chooser_set_do_overwrite_confirmation); U_DLLOAD(gtk, file_chooser_set_select_multiple); U_DLLOAD(gtk, file_chooser_set_current_name); U_DLLOAD(gtk, file_chooser_set_filter); U_DLLOAD(gtk, file_filter_add_mime_type); U_DLLOAD(gtk, widget_destroy); U_DLLOAD(gtk, file_chooser_get_preview_filename); U_DLLOAD(gtk, file_chooser_set_preview_widget_active); U_DLLOAD(gtk, file_chooser_set_preview_widget); U_DLLOAD(gtk, image_new); U_DLLOAD(gtk, image_set_from_pixbuf); U_DLLOAD(gtk, widget_set_margin_left); U_DLLOAD(gtk, widget_set_margin_right); U_DLLOAD(g, slist_free); U_DLLOAD(g, free); U_DLLOAD(g, signal_connect_data); U_DLLOAD(g, object_unref); U_DLLOAD_GDK(pixbuf_new_from_file); U_DLLOAD_GDK(pixbuf_new_from_file_at_size); U_DLLOAD_GDK(pixbuf_get_width); U_DLLOAD_GDK(pixbuf_get_height); utoxGTK_init(NULL, NULL); return lib; } return NULL; } uTox/src/xlib/freetype.h0000600000175000001440000000201714003056216014217 0ustar rakusers#ifndef XLIB_FREETYPE_H #define XLIB_FREETYPE_H #include #include #include #include #include FT_LCD_FILTER_H #include // fontconfig.h must be before fcfreetype.h #include #define PIXELS(x) (((x) + 32) / 64) typedef struct { uint32_t ucs4; int16_t x, y; uint16_t width, height, xadvance, xxxx; Picture pic; } GLYPH; typedef struct { FT_Face face; FcCharSet *cs; } FONT_INFO; typedef struct { FcPattern *pattern; FONT_INFO *info; GLYPH * glyphs[128]; } FONT; extern FT_Library ftlib; extern FONT font[16], *sfont; extern FcCharSet *charset; extern FcFontSet *fs; extern bool ft_vert, ft_swap_blue_red; Picture loadglyphpic(uint8_t *data, int width, int height, int pitch, bool no_subpixel, bool vertical, bool swap_blue_red); GLYPH *font_getglyph(FONT *f, uint32_t ch); void initfonts(void); void loadfonts(void); void freefonts(void); #endif uTox/src/xlib/freetype.c0000600000175000001440000003561014003056216014217 0ustar rakusers#include "freetype.h" #include "main.h" #include "window.h" #include "../debug.h" #include "../macros.h" #include "../ui.h" #define UTOX_FONT_XLIB "Roboto" FT_Library ftlib; FONT font[16], *sfont; FcCharSet *charset; FcFontSet *fs; bool ft_vert, ft_swap_blue_red; static void font_info_open(FONT_INFO *i, FcPattern *pattern); Picture loadglyphpic(uint8_t *data, int width, int height, int pitch, bool no_subpixel, bool vertical, bool swap_blue_red) { if (!width || !height) { return None; } Picture picture; GC legc; Pixmap pixmap; XImage *img; if (no_subpixel) { pixmap = XCreatePixmap(display, main_window.window, width, height, 8); img = XCreateImage(display, CopyFromParent, 8, ZPixmap, 0, (char *)data, width, height, 8, 0); legc = XCreateGC(display, pixmap, 0, NULL); XPutImage(display, pixmap, legc, img, 0, 0, 0, 0, width, height); picture = XRenderCreatePicture(display, pixmap, XRenderFindStandardFormat(display, PictStandardA8), 0, NULL); } else { uint32_t *rgbx, *p, *end; rgbx = malloc(4 * width * height); if (!rgbx) { return None; } p = rgbx; int i = height; if (!vertical) { do { end = p + width; while (p != end) { *p++ = swap_blue_red ? RGB(data[2], data[1], data[0]) : RGB(data[0], data[1], data[2]); data += 3; } data += pitch - width * 3; } while (--i); } else { do { end = p + width; while (p != end) { *p++ = swap_blue_red ? RGB(data[2 * pitch], data[1 * pitch], data[0]) : RGB(data[0], data[1 * pitch], data[2 * pitch]); data += 1; } data += (pitch - width) + (pitch * 2); } while (--i); } pixmap = XCreatePixmap(display, main_window.window, width, height, default_depth); img = XCreateImage(display, CopyFromParent, default_depth, ZPixmap, 0, (char *)rgbx, width, height, 32, 0); legc = XCreateGC(display, pixmap, 0, NULL); XPutImage(display, pixmap, legc, img, 0, 0, 0, 0, width, height); XRenderPictureAttributes attr = {.component_alpha = 1 }; picture = XRenderCreatePicture(display, pixmap, XRenderFindStandardFormat(display, PictStandardRGB24), CPComponentAlpha, &attr); free(rgbx); } XFreeGC(display, legc); XFreePixmap(display, pixmap); return picture; } GLYPH *font_getglyph(FONT *f, uint32_t ch) { uint32_t hash = ch % 128; GLYPH * g = f->glyphs[hash], *s = g; if (g) { while (g->ucs4 != ~0u) { if (g->ucs4 == ch) { return g; } g++; } if (!FcCharSetHasChar(charset, ch)) { return NULL; } uint32_t count = (uint32_t)(g - s); g = realloc(s, (count + 2) * sizeof(GLYPH)); if (!g) { return NULL; } f->glyphs[hash] = g; g += count; } else { if (!FcCharSetHasChar(charset, ch)) { return NULL; } g = malloc(sizeof(GLYPH) * 2); if (!g) { return NULL; } f->glyphs[hash] = g; } // return FcCharSetHasChar (pub->charset, ucs4); FONT_INFO *i = f->info; while (i->face) { if (FcCharSetHasChar(i->cs, ch)) { break; } i++; } if (!i->face) { uint32_t count = (uint32_t)(i - f->info); i = realloc(f->info, (count + 2) * sizeof(FONT_INFO)); if (!i) { return NULL; } f->info = i; i += count; i[1].face = NULL; int j; for (j = 0; j != fs->nfont; j++) { FcCharSet *cs; FcPatternGetCharSet(fs->fonts[j], FC_CHARSET, 0, &cs); if (FcCharSetHasChar(cs, ch)) { FcPattern *p = FcPatternDuplicate(fs->fonts[j]); double size; if (!FcPatternGetDouble(f->pattern, FC_PIXEL_SIZE, 0, &size)) { FcPatternAddDouble(p, FC_PIXEL_SIZE, size); } font_info_open(i, p); FcPatternDestroy(p); break; } } if (!i->face) { // something went wrong LOG_TRACE("Freetype", "???" ); return NULL; } } int lcd_filter = FC_LCD_DEFAULT; FcPatternGetInteger(f->pattern, FC_LCD_FILTER, 0, &lcd_filter); FT_Library_SetLcdFilter(ftlib, lcd_filter); int ft_flags = FT_LOAD_DEFAULT; int ft_render_flags = FT_RENDER_MODE_NORMAL; bool hinting = 1, antialias = 1, vertical_layout = 0, autohint = 0; FcPatternGetBool(f->pattern, FC_HINTING, 0, (int *)&hinting); FcPatternGetBool(f->pattern, FC_ANTIALIAS, 0, (int *)&antialias); FcPatternGetBool(f->pattern, FC_VERTICAL_LAYOUT, 0, (int *)&vertical_layout); FcPatternGetBool(f->pattern, FC_AUTOHINT, 0, (int *)&autohint); int hint_style = FC_HINT_FULL; FcPatternGetInteger(f->pattern, FC_HINT_STYLE, 0, (int *)&hint_style); // int weight; // FcPatternGetInteger(f->pattern, FC_WEIGHT, 0, (int *)&weight); int subpixel = FC_RGBA_NONE; FcPatternGetInteger(f->pattern, FC_RGBA, 0, (int *)&subpixel); bool no_subpixel = (subpixel == FC_RGBA_NONE); bool vert = ft_vert; if (no_subpixel) { ft_render_flags = FT_RENDER_MODE_NORMAL; } else { ft_render_flags |= (vert ? FT_RENDER_MODE_LCD_V : FT_RENDER_MODE_LCD); } if (antialias) { if (hint_style == FC_HINT_NONE) { ft_flags |= FT_LOAD_NO_HINTING; } else if (hint_style == FC_HINT_SLIGHT) { ft_flags |= FT_LOAD_TARGET_LIGHT; } else if (hint_style == FC_HINT_FULL && !no_subpixel) { ft_flags |= (vert ? FT_LOAD_TARGET_LCD_V : FT_LOAD_TARGET_LCD); } else { ft_flags |= FT_LOAD_TARGET_NORMAL; } } else { ft_flags |= FT_LOAD_TARGET_MONO; ft_render_flags = FT_RENDER_MODE_NORMAL; } if (vertical_layout) ft_flags |= FT_LOAD_VERTICAL_LAYOUT; if (autohint) ft_flags |= FT_LOAD_FORCE_AUTOHINT; g[1].ucs4 = ~0; FT_Load_Char(i->face, ch, ft_flags); FT_Render_Glyph(i->face->glyph, ft_render_flags); FT_GlyphSlotRec *p = i->face->glyph; g->ucs4 = ch; g->x = p->bitmap_left; g->y = PIXELS(i->face->size->metrics.ascender) - p->bitmap_top; g->height = p->bitmap.rows; g->xadvance = (p->advance.x + (1 << 5)) >> 6; if (p->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) { unsigned int r, x; uint8_t * mybuf = malloc(p->bitmap.width * g->height); uint8_t * sline = p->bitmap.buffer, *dest = mybuf; g->width = p->bitmap.width; for (r = 0; r < g->height; r++, sline += p->bitmap.pitch) { for (x = 0; x < g->width; x++, dest++) { *dest = (sline[(x >> 3)] & (0x80 >> (x & 7))) * 0xff; } } free(p->bitmap.buffer); p->bitmap.buffer = mybuf; no_subpixel = 1; } else if (p->bitmap.pixel_mode == FT_PIXEL_MODE_GRAY) { g->width = p->bitmap.width; no_subpixel = 1; } else if (p->bitmap.pixel_mode == FT_PIXEL_MODE_LCD) { g->width = p->bitmap.width / 3; no_subpixel = 0; vert = 0; } else if (p->bitmap.pixel_mode == FT_PIXEL_MODE_LCD_V) { g->width = p->bitmap.width; g->height = p->bitmap.rows / 3; no_subpixel = 0; vert = 1; } else { g->width = p->bitmap.width; no_subpixel = 0; } // LOG_TRACE("Freetype", "%u %u %u %u %C" , PIXELS(i->face->size->metrics.height), g->width, g->height, p->bitmap.pitch, ch); g->pic = loadglyphpic(p->bitmap.buffer, g->width, g->height, p->bitmap.pitch, no_subpixel, vert, ft_swap_blue_red); return g; } void initfonts(void) { if (!FcInit()) { // error LOG_ERR("Freetype", "FcInit failed."); } FT_Init_FreeType(&ftlib); FcResult result; FcPattern *pat = FcPatternCreate(); FcPatternAddString(pat, FC_FAMILY, (uint8_t *)UTOX_FONT_XLIB); FcConfigSubstitute(0, pat, FcMatchPattern); FcDefaultSubstitute(pat); fs = FcFontSort(NULL, pat, 0, &charset, &result); FcPatternDestroy(pat); } /*static void default_sub(FcPattern *pattern) { //this is actually mostly useless //FcValue v; //double dpi; //FcPatternAddBool (pattern, XFT_RENDER, XftDefaultGetBool (dpy, XFT_RENDER, screen, XftDefaultHasRender (dpy))); FcPatternAddBool (pattern, FC_ANTIALIAS, True); FcPatternAddBool (pattern, FC_EMBOLDEN, False); FcPatternAddBool (pattern, FC_HINTING, True); FcPatternAddInteger (pattern, FC_HINT_STYLE, FC_HINT_FULL); FcPatternAddBool (pattern, FC_AUTOHINT, False); int subpixel = FC_RGBA_UNKNOWN; //if (XftDefaultHasRender (dpy)) { int render_order = XRenderQuerySubpixelOrder (display, screen); switch (render_order) { default: case SubPixelUnknown: subpixel = FC_RGBA_UNKNOWN; break; case SubPixelHorizontalRGB: subpixel = FC_RGBA_RGB; break; case SubPixelHorizontalBGR: subpixel = FC_RGBA_BGR; break; case SubPixelVerticalRGB: subpixel = FC_RGBA_VRGB; break; case SubPixelVerticalBGR: subpixel = FC_RGBA_VBGR; break; case SubPixelNone: subpixel = FC_RGBA_NONE; break; } } FcPatternAddInteger (pattern, FC_RGBA, subpixel); FcPatternAddInteger (pattern, FC_LCD_FILTER, FC_LCD_DEFAULT); FcPatternAddBool (pattern, FC_MINSPACE, False); //dpi = (((double) DisplayHeight (dpy, screen) * 25.4) / (double) DisplayHeightMM (dpy, screen)); //FcPatternAddDouble (pattern, FC_DPI, dpi); FcPatternAddDouble (pattern, FC_SCALE, 1.0); //FcPatternAddInteger (pattern, XFT_MAX_GLYPH_MEMORY, XftDefaultGetInteger (dpy, XFT_MAX_GLYPH_MEMORY, screen, XFT_FONT_MAX_GLYPH_MEMORY)); FcDefaultSubstitute (pattern); }*/ static void font_info_open(FONT_INFO *i, FcPattern *pattern) { uint8_t * filename; int id = 0; double size; FcMatrix *font_matrix; /*FT_Matrix matrix = { .xx = 0x10000, .xy = 0, .yx = 0, .yy = 0x10000, };*/ FcPatternGetString(pattern, FC_FILE, 0, &filename); FcPatternGetInteger(pattern, FC_INDEX, 0, &id); FcPatternGetCharSet(pattern, FC_CHARSET, 0, &i->cs); if (FcPatternGetMatrix(pattern, FC_MATRIX, 0, &font_matrix) == FcResultMatch) { LOG_TRACE("Freetype", "has a matrix" ); } FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &size); int ft_error = FT_New_Face(ftlib, (char *)filename, id, &i->face); if (ft_error != 0) { LOG_TRACE("Freetype", "Freetype error %u %s %i" , ft_error, filename, id); return; } ft_error = FT_Set_Char_Size(i->face, (size * 64.0 + 0.5), (size * 64.0 + 0.5), 0, 0); if (ft_error != 0) { LOG_TRACE("Freetype", "Freetype error %u %lf" , ft_error, size); return; } // LOG_TRACE("Freetype", "Loaded font %s %u %i %i" , filename, id, PIXELS(i->face->ascender), PIXELS(i->face->descender)); } static bool font_open(FONT *a_font, ...) { /* add error checks */ va_list va; FcPattern *pat; FcPattern *match; FcResult result; va_start(va, a_font); pat = FcPatternVaBuild(NULL, va); va_end(va); FcConfigSubstitute(NULL, pat, FcMatchPattern); // default_sub(pat); match = FcFontMatch(NULL, pat, &result); FcPatternDestroy(pat); a_font->info = malloc(sizeof(FONT_INFO) * 2); font_info_open(a_font->info, match); a_font->pattern = match; a_font->info[1].face = NULL; return true; } void loadfonts(void) { int render_order = XRenderQuerySubpixelOrder(display, def_screen_num); if (render_order == SubPixelHorizontalBGR || render_order == SubPixelVerticalBGR) { ft_swap_blue_red = 1; LOG_TRACE("Freetype", "ft_swap_blue_red" ); } if (render_order == SubPixelVerticalBGR || render_order == SubPixelVerticalRGB) { ft_vert = 1; LOG_TRACE("Freetype", "ft_vert" ); } font_open(&font[FONT_TEXT], FC_FAMILY, FcTypeString, UTOX_FONT_XLIB, FC_PIXEL_SIZE, FcTypeDouble, UI_FSCALE(12.0), FC_WEIGHT, FcTypeInteger, FC_WEIGHT_NORMAL, FC_SLANT, FcTypeInteger, FC_SLANT_ROMAN, NULL); font_open(&font[FONT_TITLE], FC_FAMILY, FcTypeString, UTOX_FONT_XLIB, FC_PIXEL_SIZE, FcTypeDouble, UI_FSCALE(12.0), FC_WEIGHT, FcTypeInteger, FC_WEIGHT_BOLD, NULL); font_open(&font[FONT_SELF_NAME], FC_FAMILY, FcTypeString, UTOX_FONT_XLIB, FC_PIXEL_SIZE, FcTypeDouble, UI_FSCALE(14.0), FC_WEIGHT, FcTypeInteger, FC_WEIGHT_BOLD, NULL); font_open(&font[FONT_STATUS], FC_FAMILY, FcTypeString, UTOX_FONT_XLIB, FC_PIXEL_SIZE, FcTypeDouble, UI_FSCALE(11.0), FC_WEIGHT, FcTypeInteger, FC_WEIGHT_NORMAL, FC_SLANT, FcTypeInteger, FC_SLANT_ROMAN, NULL); font_open(&font[FONT_LIST_NAME], FC_FAMILY, FcTypeString, UTOX_FONT_XLIB, FC_PIXEL_SIZE, FcTypeDouble, UI_FSCALE(12.0), FC_WEIGHT, FcTypeInteger, FC_WEIGHT_NORMAL, FC_SLANT, FcTypeInteger, FC_SLANT_ROMAN, NULL); // font_open(&font[FONT_MSG], FC_FAMILY, FcTypeString, UTOX_FONT_XLIB, FC_PIXEL_SIZE, FcTypeDouble, UI_FSCALE(11.0), // FC_WEIGHT, FcTypeInteger, FC_WEIGHT_LIGHT, NULL); // font_open(&font[FONT_MSG_NAME], FC_FAMILY, FcTypeString, UTOX_FONT_XLIB, FC_PIXEL_SIZE, FcTypeDouble, UI_FSCALE(10.0), // FC_WEIGHT, FcTypeInteger, FC_WEIGHT_LIGHT, NULL); font_open(&font[FONT_MISC], FC_FAMILY, FcTypeString, UTOX_FONT_XLIB, FC_PIXEL_SIZE, FcTypeDouble, UI_FSCALE(10.0), FC_WEIGHT, FcTypeInteger, FC_WEIGHT_NORMAL, FC_SLANT, FcTypeInteger, FC_SLANT_ROMAN, NULL); // font_open(&font[FONT_MSG_LINK], FC_FAMILY, FcTypeString, UTOX_FONT_XLIB, FC_PIXEL_SIZE, FcTypeDouble, UI_FSCALE(11.0), // FC_WEIGHT, FcTypeInteger, FC_WEIGHT_LIGHT, NULL); } void freefonts(void) { for (size_t i = 0; i < COUNTOF(font); i++) { FONT *f = &font[i]; if (f->pattern) { FcPatternDestroy(f->pattern); } if (f->info) { FONT_INFO *fi = f->info; while (fi->face) { FT_Done_Face(fi->face); fi++; } free(f->info); } for (size_t j = 0; j < COUNTOF(f->glyphs); j++) { GLYPH *g = f->glyphs[j]; if (g) { while (g->ucs4 != ~0u) { if (g->pic) { XRenderFreePicture(display, g->pic); } g++; } free(f->glyphs[j]); f->glyphs[j] = NULL; } } } } uTox/src/xlib/filesys.c0000600000175000001440000002007714003056216014053 0ustar rakusers#include "main.h" #include "gtk.h" #include "../chatlog.h" #include "../debug.h" #include "../file_transfers.h" #include "../filesys.h" #include "../friend.h" #include "../settings.h" #include "../tox.h" #include #include #include #if 0 // commented because this function is deprecated, but I'm not ready to delete all this code yet /** Takes data from µTox and saves it, just how the OS likes it saved! */ size_t native_save_data(const uint8_t *name, size_t name_length, const uint8_t *data, size_t length, bool append) { char path[UTOX_FILE_NAME_LENGTH] = { 0 }; char atomic_path[UTOX_FILE_NAME_LENGTH] = { 0 }; FILE *file; size_t offset = 0; if (settings.portable_mode) { snprintf(path, UTOX_FILE_NAME_LENGTH, "./tox/"); } else { snprintf(path, UTOX_FILE_NAME_LENGTH, "%s/.config/tox/", getenv("HOME")); } mkdir(path, 0700); snprintf(path + strlen(path), UTOX_FILE_NAME_LENGTH - strlen(path), "%s", name); if (append) { file = fopen(path, "ab"); } else { if (strlen(path) + name_length >= UTOX_FILE_NAME_LENGTH - strlen(".atomic")) { LOG_TRACE("Filesys", "Save directory name too long" ); return 0; } else { snprintf(atomic_path, UTOX_FILE_NAME_LENGTH, "%s.atomic", path); } file = fopen(atomic_path, "wb"); } if (file) { offset = ftello(file); fwrite(data, length, 1, file); fclose(file); if (append) { return offset; } if (rename(atomic_path, path)) { /* Consider backing up this file instead of overwriting it. */ LOG_TRACE("Filesys", "%sUnable to move file!" , atomic_path); return 0; } return 1; } else { LOG_TRACE("Filesys", "Unable to open %s to write save" , path); return 0; } return 0; } #endif /** Takes data from µTox and loads it up! */ uint8_t *native_load_data(const uint8_t *name, size_t name_length, size_t *out_size) { char path[UTOX_FILE_NAME_LENGTH] = { 0 }; if (settings.portable_mode) { snprintf((char *)path, UTOX_FILE_NAME_LENGTH, "./tox/"); } else { snprintf((char *)path, UTOX_FILE_NAME_LENGTH, "%s/.config/tox/", getenv("HOME")); } if (strlen(path) + name_length >= UTOX_FILE_NAME_LENGTH) { LOG_TRACE("Filesys", "Load directory name too long" ); return 0; } else { snprintf(path + strlen(path), UTOX_FILE_NAME_LENGTH - strlen(path), "%s", name); } FILE *file = fopen(path, "rb"); if (!file) { // LOG_TRACE("Filesys", "Unable to open/read %s" , path); if (out_size) { *out_size = 0; } return NULL; } fseek(file, 0, SEEK_END); size_t size = ftell(file); uint8_t *data = calloc(size + 1, 1); // needed for the ending null byte if (!data) { fclose(file); if (out_size) { *out_size = 0; } return NULL; } else { fseek(file, 0, SEEK_SET); if (fread(data, size, 1, file) != 1) { LOG_TRACE("Filesys", "Read error on %s" , path); fclose(file); free(data); if (out_size) { *out_size = 0; } return NULL; } fclose(file); } if (out_size) { *out_size = size; } return data; } void native_export_chatlog_init(uint32_t friend_number) { if (libgtk) { ugtk_save_chatlog(friend_number); } else { char name[TOX_MAX_NAME_LENGTH + sizeof(".txt")]; FRIEND *f = get_friend(friend_number); if (!f) { LOG_ERR("Filesys", "Could not get friend with number: %u", friend_number); return; } snprintf((char *)name, sizeof(name), "%.*s.txt", (int)f->name_length, f->name); FILE *file = fopen((char *)name, "wb"); if (file) { utox_export_chatlog(get_friend(friend_number)->id_str, file); } } } bool native_remove_file(const uint8_t *name, size_t length, bool portable_mode) { char path[UTOX_FILE_NAME_LENGTH] = { 0 }; if (portable_mode) { snprintf((char *)path, UTOX_FILE_NAME_LENGTH, "./tox/"); } else { snprintf((char *)path, UTOX_FILE_NAME_LENGTH, "%s/.config/tox/", getenv("HOME")); } if (strlen((const char *)path) + length >= UTOX_FILE_NAME_LENGTH) { LOG_DEBUG("Filesys", "File/directory name too long, unable to remove" ); return false; } else { snprintf((char *)path + strlen((const char *)path), UTOX_FILE_NAME_LENGTH - strlen((const char *)path), "%.*s", (int)length, (char *)name); } if (remove((const char *)path)) { LOG_ERR("NATIVE", "Unable to delete file!\n\t\t%s" , path); return false; } else { LOG_INFO("NATIVE", "File deleted!" ); LOG_DEBUG("Filesys", "\t%s" , path); } return true; } void native_select_dir_ft(uint32_t fid, uint32_t file_number, FILE_TRANSFER *file) { if (libgtk) { ugtk_native_select_dir_ft(fid, file); } else { // fall back to working dir char *path = malloc(file->name_length + 1); memcpy(path, file->name, file->name_length); path[file->name_length] = 0; postmessage_toxcore(TOX_FILE_ACCEPT, fid, file_number, path); } } void native_autoselect_dir_ft(uint32_t fid, FILE_TRANSFER *file) { if (file == NULL){ LOG_TRACE("Native", " file is null." ); return; } uint8_t *path = malloc(file->name_length + 1); if (path == NULL) { LOG_ERR("Native", "Could not allocate memory."); return; } if (settings.portable_mode) { snprintf((char *)path, UTOX_FILE_NAME_LENGTH, "./tox/Tox_Auto_Accept/"); native_create_dir(path); snprintf((char *)path, UTOX_FILE_NAME_LENGTH, "./tox/Tox_Auto_Accept/%.*s", (int)file->name_length, file->name); } else { memcpy(path, file->name, file->name_length); path[file->name_length] = 0; } LOG_NOTE("Native", "Auto Accept Directory: \"%s\"" , path); postmessage_toxcore(TOX_FILE_ACCEPT, fid, file->file_number, path); } // TODO: This function has the worst name. void file_save_inline_image_png(MSG_HEADER *msg) { if (libgtk) { ugtk_file_save_inline(msg); } else { // fall back to working dir inline.png FILE *fp = fopen("inline.png", "wb"); if (fp) { fwrite(msg->via.ft.data, 1, msg->via.ft.data_size, fp); fclose(fp); snprintf((char *)msg->via.ft.path, UTOX_FILE_NAME_LENGTH, "inline.png"); msg->via.ft.inline_png = false; } } } bool native_save_image_png(char *name, uint8_t *image, int image_size) { if (libgtk) { FILE_IMAGE *file_image = calloc(1, sizeof(FILE_IMAGE)); if (!file_image) { LOG_ERR("Native", "Could not allocate memory."); return false; } file_image->name = name; file_image->data = image; file_image->data_size = image_size; ugtk_file_save_image_png(file_image); return true; } char path[TOX_MAX_NAME_LENGTH + sizeof(".png")] = { 0 }; snprintf(path, sizeof(path), "%s.png", name); FILE *file = fopen(path, "wb"); if (!file) { LOG_ERR("Native", "Could not open file %s for write.", path); return false; } fwrite(image, image_size, 1, file); fclose(file); return true; } int file_lock(FILE *file, uint64_t start, size_t length) { struct flock fl; fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; fl.l_start = start; fl.l_len = length; int result = fcntl(fileno(file), F_SETLK, &fl); if (result == -1) { return 0; } return 1; } int file_unlock(FILE *file, uint64_t start, size_t length) { struct flock fl; fl.l_type = F_UNLCK; fl.l_whence = SEEK_SET; fl.l_start = start; fl.l_len = length; int result = fcntl(fileno(file), F_SETLK, &fl); if (result == -1) { return 0; } return 1; } uTox/src/xlib/event.c0000600000175000001440000006173614003056216013525 0ustar rakusers#include "main.h" #include "screen_grab.h" #include "tray.h" #include "window.h" #include "../debug.h" #include "../flist.h" #include "../friend.h" #include "../macros.h" #include "../notify.h" #include "../self.h" #include "../settings.h" #include "../tox.h" #include "../ui.h" #include "../utox.h" #include "../av/utox_av.h" #include "../native/clipboard.h" #include "../native/keyboard.h" #include "../native/notify.h" #include "../native/ui.h" #include "../ui/draw.h" // Needed for enddraw. This should probably be changed. #include "../ui/edit.h" #include "../ui/button.h" #include "keysym2ucs.h" #include #include #include #include "../layout/friend.h" #include "../layout/group.h" #include "../layout/settings.h" #include "../layout/sidebar.h" #include "stb.h" extern XIC xic; bool have_focus = false; static void mouse_move(XMotionEvent *event, UTOX_WINDOW *window) { if (pointergrab) { // TODO super globals are bad mm'kay? GRAB_POS grab = grab_pos(); XDrawRectangle(display, RootWindow(display, def_screen_num), scr_grab_window.gc, MIN(grab.dn_x, grab.up_x), MIN(grab.dn_y, grab.up_y), grab.dn_x < grab.up_x ? grab.up_x - grab.dn_x : grab.dn_x - grab.up_x, grab.dn_y < grab.up_y ? grab.up_y - grab.dn_y : grab.dn_y - grab.up_y); grab_up(event->x_root, event->y_root); grab = grab_pos(); XDrawRectangle(display, RootWindow(display, def_screen_num), scr_grab_window.gc, MIN(grab.dn_x, grab.up_x), MIN(grab.dn_y, grab.up_y), grab.dn_x < grab.up_x ? grab.up_x - grab.dn_x : grab.dn_x - grab.up_x, grab.dn_y < grab.up_y ? grab.up_y - grab.dn_y : grab.dn_y - grab.up_y); return; } static int mx, my; int dx, dy; dx = event->x - mx; dy = event->y - my; mx = event->x; my = event->y; cursor = CURSOR_NONE; panel_mmove(window->_.panel, 0, 0, window->_.w, window->_.h, event->x, event->y, dx, dy); XDefineCursor(display, window->window, cursors[cursor]); // uncomment this to log mouse movements. Commented because it spams too much //LOG_TRACE("XLIB", "MotionEvent: (%u %u) %u", event->x, event->y, event->state); } static void mouse_down(XButtonEvent *event, UTOX_WINDOW *window) { switch (event->button) { case Button1: { if (pointergrab) { grab_up(event->x_root, event->y_root); grab_dn(event->x_root, event->y_root); return; } // todo: better double/triple click detect static Time lastclick, lastclick2; panel_mmove(window->_.panel, 0, 0, window->_.w, window->_.h, event->x, event->y, 0, 0); panel_mdown(window->_.panel); if (event->time - lastclick < 300) { bool triclick = (event->time - lastclick2 < 600); panel_dclick(window->_.panel, triclick); if (triclick) { lastclick = 0; } } lastclick2 = lastclick; lastclick = event->time; break; } case Button2: { pasteprimary(); break; } case Button3: { if (pointergrab) { XUngrabPointer(display, CurrentTime); pointergrab = 0; break; } panel_mright(window->_.panel); break; } case Button4: { // TODO: determine precise deltas if possible panel_mwheel(window->_.panel, 0, 0, window->_.w, window->_.h, 1.0, 0); break; } case Button5: { // TODO: determine precise deltas if possible panel_mwheel(window->_.panel, 0, 0, window->_.w, window->_.h, -1.0, 0); break; } } LOG_TRACE("XLIB", "ButtonEvent: %u %u", event->state, event->button); } static void mouse_up(XButtonEvent *event, UTOX_WINDOW *window) { switch (event->button) { case Button1: { if (pointergrab) { XUngrabPointer(display, CurrentTime); GRAB_POS grab = grab_pos(); if (grab.dn_x < grab.up_x) { grab.up_x -= grab.dn_x; } else { int w = grab.dn_x - grab.up_x; grab.dn_x = grab.up_x; grab.up_x = w; } if (grab.dn_y < grab.up_y) { grab.up_y -= grab.dn_y; } else { int w = grab.dn_y - grab.up_y; grab.dn_y = grab.up_y; grab.up_y = w; } /* enforce min size */ if (grab.up_x * grab.up_y < 100) { pointergrab = 0; break; } XDrawRectangle(display, RootWindow(display, def_screen_num), scr_grab_window.gc, grab.dn_x, grab.dn_y, grab.up_x, grab.up_y); if (pointergrab == 1) { FRIEND *f = flist_get_sel_friend(); if (f && f->online) { XImage *img = XGetImage(display, RootWindow(display, def_screen_num), grab.dn_x, grab.dn_y, grab.up_x, grab.up_y, XAllPlanes(), ZPixmap); if (img) { uint8_t * temp, *p; uint32_t *pp = (void *)img->data, *end = &pp[img->width * img->height]; p = temp = malloc(img->width * img->height * 3); while (pp != end) { uint32_t i = *pp++; *p++ = i >> 16; *p++ = i >> 8; *p++ = i; } int size = -1; uint8_t *out = stbi_write_png_to_mem(temp, 0, img->width, img->height, 3, &size); free(temp); uint16_t w = img->width; uint16_t h = img->height; NATIVE_IMAGE *image = malloc(sizeof(NATIVE_IMAGE)); image->rgb = ximage_to_picture(img, NULL); image->alpha = None; friend_sendimage(f, image, w, h, (UTOX_IMAGE)out, size); } } } else { postmessage_utoxav(UTOXAV_SET_VIDEO_IN, 1, 0, NULL); } pointergrab = 0; } else { panel_mup(window->_.panel); } break; } } LOG_TRACE("XLIB", "ButtonEvent: %u %u", event->state, event->button); } // Should return false if the result of the action should close/exit the window. static bool popup_event(XEvent *event, UTOX_WINDOW *win) { switch (event->type) { case Expose: { LOG_TRACE("XLIB", "Main window expose"); native_window_set_target(win); panel_draw(win->_.panel , 0, 0, win->_.w, win->_.h); XCopyArea(display, win->drawbuf, win->window, win->gc, 0, 0, win->_.w, win->_.h, 0, 0); break; } case ClientMessage: { /* This could be noop code, I'm not convinced we need to support _NET_WM_PING but * in case we do, we already have the response ready. */ Atom ping = XInternAtom(display, "_NET_WM_PING", 0); if ((Atom)event->xclient.data.l[0] == ping) { LOG_TRACE("XLIB", "ping"); event->xany.window = root_window; XSendEvent(display, root_window, False, NoEventMask, event); } else { LOG_TRACE("XLIB", "not ping"); } break; } case MotionNotify: { mouse_move(&event->xmotion, win); break; } case ButtonPress: { mouse_down(&event->xbutton, win); break; } case ButtonRelease: { mouse_up(&event->xbutton, win); break; } case EnterNotify: { LOG_TRACE("XLIB", "set focus"); window_set_focus(win); break; } case LeaveNotify: { break; } default: { LOG_WARN("XLIB", "other event: %u", event->type); break; } } return true; } bool doevent(XEvent *event) { if (XFilterEvent(event, None)) { return true; } if (event->xany.window && event->xany.window != main_window.window) { if (native_window_find_notify(&event->xany.window)) { // TODO perhaps we should roll this into one? return popup_event(event, native_window_find_notify(&event->xany.window)); // return true; } if (tray_window_event(event)) { return true; } if (event->type == ClientMessage) { XClientMessageEvent *ev = &event->xclient; if ((Atom)event->xclient.data.l[0] == wm_delete_window) { uint32_t r = find_video_windows(ev->window); if (r == UINT32_MAX) { return true; } postmessage_utoxav(UTOXAV_STOP_VIDEO, r, (r == UINT16_MAX), NULL); } } return true; } switch (event->type) { case Expose: { enddraw(0, 0, settings.window_width, settings.window_height); break; } case FocusIn: { if (xic) { XSetICFocus(xic); } #ifdef UNITY if (unity_running) { mm_rm_entry(NULL); } #endif have_focus = true; XWMHints hints = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; XSetWMHints(display, main_window.window, &hints); break; } case FocusOut: { if (xic) { XUnsetICFocus(xic); } #ifdef UNITY if (unity_running) { mm_save_cid(); } #endif have_focus = false; break; } case ConfigureNotify: { XConfigureEvent *ev = &event->xconfigure; main_window._.x = ev->x; main_window._.y = ev->y; if (settings.window_width != (unsigned)ev->width || settings.window_height != (unsigned)ev->height) { // Resize XFreePixmap(display, main_window.drawbuf); main_window.drawbuf = XCreatePixmap(display, main_window.window, ev->width + 10, ev->height + 10, default_depth); XRenderFreePicture(display, main_window.renderpic); main_window.renderpic = XRenderCreatePicture(display, main_window.drawbuf, main_window.pictformat, 0, NULL); main_window._.w = settings.window_width = ev->width; main_window._.h = settings.window_height = ev->height; ui_size(settings.window_width, settings.window_height); redraw(); } break; } case LeaveNotify: { ui_mouseleave(); break; } case MotionNotify: { mouse_move(&event->xmotion, &main_window); break; } case ButtonPress: { mouse_down(&event->xbutton, &main_window); break; } case ButtonRelease: { mouse_up(&event->xbutton, &main_window); } case KeyRelease: { // XKeyEvent *ev = event->xkey; // KeySym sym = XLookupKeysym(ev, 0); break; } case KeyPress: { XKeyEvent *ev = &event->xkey; KeySym sym = XLookupKeysym(ev, 0); // XKeycodeToKeysym(display, ev->keycode, 0) if (pointergrab && sym == XK_Escape) { XUngrabPointer(display, CurrentTime); pointergrab = 0; break; } wchar_t buffer[16]; int len; if (xic) { len = XwcLookupString(xic, ev, buffer, sizeof(buffer), &sym, NULL); } else { len = XLookupString(ev, (char *)buffer, sizeof(buffer), &sym, NULL); } if (sym == XK_ISO_Left_Tab) { // XK_ISO_Left_Tab == Shift+Tab, but we just look at whether shift is pressed sym = XK_Tab; } else if (sym >= XK_KP_0 && sym <= XK_KP_9) { // normalize keypad and non-keypad numbers sym = sym - XK_KP_0 + XK_0; } // NOTE: Don't use keys like KEY_TAB, KEY_PAGEUP, etc. from xlib/main.h here, they're // overwritten by linux header linux/input.h, so they'll be different if (ev->state & ControlMask) { if ((sym == XK_Tab && (ev->state & ShiftMask)) || sym == XK_Page_Up) { flist_previous_tab(); redraw(); break; } else if (sym == XK_Tab || sym == XK_Page_Down) { flist_next_tab(); redraw(); break; } else if (sym == XK_Home) { flist_first_tab(); redraw(); break; } else if (sym == XK_End) { flist_last_tab(); redraw(); break; } else if (sym == 'f') { edit_setfocus(&edit_search); redraw(); break; } else if (sym == 'F') { if (button_filter_friends.on_mup) { button_filter_friends.on_mup(); redraw(); break; } } } if (ev->state & ControlMask || ev->state & Mod1Mask) { // Mod1Mask == alt if (sym >= XK_1 && sym <= XK_9) { flist_selectchat(sym - XK_1); redraw(); break; } else if (sym == XK_0) { flist_selectchat(9); redraw(); break; } } if (!edit_active()) { if (messages_char(sym)) { redraw(); break; } if (ev->state & ControlMask) { if (sym == 'c' || sym == 'C') { if (flist_get_sel_friend()) { clipboard.len = messages_selection(&messages_friend, clipboard.data, sizeof(clipboard.data), 0); } else if (flist_get_sel_group()) { clipboard.len = messages_selection(&messages_group, clipboard.data, sizeof(clipboard.data), 0); } setclipboard(); break; } } /* Focus message input field if ctrl isn't pressed, * to make sure you can still copy text from the chat log */ if (sym != XK_Control_L) { edit_setfocus(&edit_chat_msg_friend); edit_char(KEY_END, 1, 0); } } if (edit_active()) { if (sym == XK_Escape) { edit_resetfocus(); redraw(); break; } if (ev->state & ControlMask) { switch (sym) { case 'v': case 'V': paste(); return true; case 'c': case 'C': case XK_Insert: copy(0); return true; case 'x': case 'X': copy(0); edit_char(KEY_DEL, 1, 0); return true; case 'w': case 'W': /* Sent ctrl + backspace to active edit */ edit_char(KEY_BACK, 1, 4); return true; } } if (ev->state & ShiftMask) { switch (sym) { case XK_Insert: paste(); return true; case XK_Delete: copy(0); edit_char(KEY_DEL, 1, 0); return true; } } if (sym == XK_KP_Enter) { sym = XK_Return; } if (sym == XK_Return && (ev->state & ShiftMask)) { edit_char('\n', 0, 0); break; } if (sym == XK_KP_Space) { sym = XK_space; } if (sym >= XK_KP_Home && sym <= XK_KP_Begin) { sym -= 0x45; } if (sym >= XK_KP_Multiply && sym <= XK_KP_Equal) { sym -= 0xFF80; } if (!sym) { int i; for (i = 0; i < len; i++) edit_char(buffer[i], (ev->state & ControlMask) != 0, ev->state); } uint32_t key = keysym2ucs(sym); if (key != ~0u) { edit_char(key, (ev->state & ControlMask) != 0, ev->state); } else { edit_char(sym, 1, ev->state); } } break; } case SelectionNotify: { LOG_NOTE("XLib Event", "SelectionNotify" ); XSelectionEvent *ev = &event->xselection; if (ev->property == None) { break; } Atom type; int format; void *data; long unsigned int len, bytes_left; XGetWindowProperty(display, main_window.window, ev->property, 0, ~0L, True, AnyPropertyType, &type, &format, &len, &bytes_left, (unsigned char **)&data); if (!data) { break; } LOG_INFO("Event", "Type: %s" , XGetAtomName(ev->display, type)); LOG_INFO("Event", "Property: %s" , XGetAtomName(ev->display, ev->property)); if (ev->property == XA_ATOM) { pastebestformat((Atom *)data, len, ev->selection); } else if (ev->property == XdndDATA) { FRIEND *f = flist_get_sel_friend(); if (!f) { LOG_ERR("Event", "Could not get selected friend."); return false; } char *path = calloc(len + 1, 1); formaturilist(path, (char *)data, len); postmessage_toxcore(TOX_FILE_SEND_NEW, f->number, 0xFFFF, path); } else if (type == XA_INCR) { if (pastebuf.data) { /* already pasting something, give up on that */ free(pastebuf.data); pastebuf.data = NULL; } pastebuf.len = *(unsigned long *)data; pastebuf.left = pastebuf.len; pastebuf.data = malloc(pastebuf.len); /* Deleting the window property triggers incremental paste */ } else { LOG_ERR("XLib Event", "Type %s || Prop %s ", XGetAtomName(ev->display, type), XGetAtomName(ev->display, ev->property)); pastedata(data, type, len, ev->selection == XA_PRIMARY); } XFree(data); break; } case SelectionRequest: { XSelectionRequestEvent *ev = &event->xselectionrequest; XEvent resp = { .xselection = { .type = SelectionNotify, .property = ev->property, .requestor = ev->requestor, .selection = ev->selection, .target = ev->target, .time = ev->time } }; if (ev->target == XA_UTF8_STRING || ev->target == XA_STRING) { if (ev->selection == XA_PRIMARY) { XChangeProperty(display, ev->requestor, ev->property, ev->target, 8, PropModeReplace, (const unsigned char *)primary.data, primary.len); } else { XChangeProperty(display, ev->requestor, ev->property, ev->target, 8, PropModeReplace, (const unsigned char *)clipboard.data, clipboard.len); } } else if (ev->target == targets) { Atom supported[] = { XA_STRING, XA_UTF8_STRING }; XChangeProperty(display, ev->requestor, ev->property, XA_ATOM, 32, PropModeReplace, (void *)&supported, COUNTOF(supported)); } else { LOG_NOTE("XLIB selection request", " unknown request"); resp.xselection.property = None; } XSendEvent(display, ev->requestor, 0, 0, &resp); break; } case PropertyNotify: { XPropertyEvent *ev = &event->xproperty; if (ev->state == PropertyNewValue && ev->atom == targets && pastebuf.data) { LOG_TRACE("Event", "Property changed: %s" , XGetAtomName(display, ev->atom)); Atom type; int format; unsigned long int len, bytes_left; void * data; XGetWindowProperty(display, main_window.window, ev->atom, 0, ~0L, True, AnyPropertyType, &type, &format, &len, &bytes_left, (unsigned char **)&data); if (len == 0) { LOG_TRACE("Event", "Got 0 length data, pasting" ); pastedata(pastebuf.data, type, pastebuf.len, False); pastebuf.data = NULL; break; } if (pastebuf.left > 0 && (unsigned)pastebuf.left < len) { pastebuf.len += len - pastebuf.left; pastebuf.data = realloc(pastebuf.data, pastebuf.len); pastebuf.left = len; } memcpy(pastebuf.data + pastebuf.len - pastebuf.left, data, len); pastebuf.left -= len; XFree(data); } break; } case ClientMessage: { XClientMessageEvent *ev = &event->xclient; if (ev->window == 0) { void *data; memcpy(&data, &ev->data.s[2], sizeof(void *)); utox_message_dispatch(ev->message_type, ev->data.s[0], ev->data.s[1], data); break; } if (ev->message_type == wm_protocols) { if ((Atom)event->xclient.data.l[0] == wm_delete_window) { if (settings.close_to_tray) { LOG_TRACE("Event", "Closing to tray." ); togglehide(); } else { return false; } } break; } if (ev->message_type == XdndEnter) { LOG_TRACE("Event", "enter" ); } else if (ev->message_type == XdndPosition) { Window src = ev->data.l[0]; XEvent reply_event = {.xclient = {.type = ClientMessage, .display = display, .window = src, .message_type = XdndStatus, .format = 32, .data = {.l = { main_window.window, 1, 0, 0, XdndActionCopy } } } }; XSendEvent(display, src, 0, 0, &reply_event); // LOG_TRACE("Event", "position (version=%u)" , ev->data.l[1] >> 24); } else if (ev->message_type == XdndStatus) { LOG_TRACE("Event", "status" ); } else if (ev->message_type == XdndDrop) { XConvertSelection(display, XdndSelection, XA_STRING, XdndDATA, main_window.window, CurrentTime); LOG_NOTE("XLIB", "Drag was dropped"); } else if (ev->message_type == XdndLeave) { LOG_TRACE("Event", "leave" ); } else { LOG_TRACE("Event", "dragshit" ); } break; } } return true; } uTox/src/xlib/drawing.c0000600000175000001440000001405714003056216014031 0ustar rakusers#include "../ui/draw.h" #include "freetype.h" #include "main.h" #include "window.h" #include "../debug.h" #include "../text.h" #include "../ui.h" #include static uint32_t scolor; void redraw(void) { _redraw = 1; } void force_redraw(void) { XEvent ev = { .xclient = { .type = ClientMessage, .display = display, .window = curr->window, .message_type = XRedraw, .format = 8, .data = { .s = { 0, 0 } } } }; _redraw = 1; XSendEvent(display, curr->window, 0, 0, &ev); XFlush(display); } void draw_image(const NATIVE_IMAGE *image, int x, int y, uint32_t width, uint32_t height, uint32_t imgx, uint32_t imgy) { XRenderComposite(display, PictOpOver, image->rgb, image->alpha, curr->renderpic, imgx, imgy, imgx, imgy, x, y, width, height); } void draw_inline_image(uint8_t *img_data, size_t size, uint16_t w, uint16_t h, int x, int y) { if (!curr->visual) { LOG_ERR("Xlib drawing", "Could not draw inline image"); return; } const uint8_t *rgba_data = img_data; // we don't need to free this, that's done by XDestroyImage() uint8_t *out = malloc(size); uint32_t *target; for (uint32_t i = 0; i < size; i += 4) { // colors are read into red, blue and green and written into the target pointer const uint8_t red = (rgba_data + i)[0] & 0xFF; const uint8_t green = (rgba_data + i)[1] & 0xFF; const uint8_t blue = (rgba_data + i)[2] & 0xFF; target = (uint32_t *)(out + i); *target = (red | (red << 8) | (red << 16) | (red << 24)) & curr->visual->red_mask; *target |= (blue | (blue << 8) | (blue << 16) | (blue << 24)) & curr->visual->blue_mask; *target |= (green | (green << 8) | (green << 16) | (green << 24)) & curr->visual->green_mask; } XImage *img = XCreateImage(display, curr->visual, default_depth, ZPixmap, 0, (char *)out, w, h, 32, w * 4); Picture rgb = ximage_to_picture(img, NULL); // 4 bpp -> RGBA Picture alpha = None; NATIVE_IMAGE *image = malloc(sizeof(NATIVE_IMAGE)); image->rgb = rgb; image->alpha = alpha; XDestroyImage(img); draw_image(image, x, y, w, h, 0, 0); free(image); } void drawalpha(int bm, int x, int y, int width, int height, uint32_t color) { XRenderColor xrcolor = {.red = ((color >> 8) & 0xFF00) | 0x80, .green = ((color)&0xFF00) | 0x80, .blue = ((color << 8) & 0xFF00) | 0x80, .alpha = 0xFFFF }; Picture src = XRenderCreateSolidFill(display, &xrcolor); XRenderComposite(display, PictOpOver, src, bitmap[bm], curr->renderpic, 0, 0, 0, 0, x, y, width, height); XRenderFreePicture(display, src); } static int _drawtext(int x, int xmax, int y, const char *str, uint16_t length) { GLYPH * g; uint8_t len; uint32_t ch; while (length) { len = utf8_len_read(str, &ch); str += len; length -= len; g = font_getglyph(sfont, ch); if (g) { if (x + g->xadvance + SCALE(10) > xmax && length) { return -x; } if (g->pic) { XRenderComposite(display, PictOpOver, curr->colorpic, g->pic, curr->renderpic, 0, 0, 0, 0, x + g->x, y + g->y, g->width, g->height); } x += g->xadvance; } } return x; } // Needs to be included after ../ui/draw.h #include "../shared/freetype-text.c" void draw_rect_frame(int x, int y, int width, int height, uint32_t color) { XSetForeground(display, curr->gc, color); XDrawRectangle(display, curr->drawbuf, curr->gc, x, y, width - 1, height - 1); } void drawrect(int x, int y, int right, int bottom, uint32_t color) { XSetForeground(display, curr->gc, color); XFillRectangle(display, curr->drawbuf, curr->gc, x, y, right - x, bottom - y); } void draw_rect_fill(int x, int y, int width, int height, uint32_t color) { XSetForeground(display, curr->gc, color); XFillRectangle(display, curr->drawbuf, curr->gc, x, y, width, height); } void drawhline(int x, int y, int x2, uint32_t color) { XSetForeground(display, curr->gc, color); XDrawLine(display, curr->drawbuf, curr->gc, x, y, x2, y); } void drawvline(int x, int y, int y2, uint32_t color) { XSetForeground(display, curr->gc, color); XDrawLine(display, curr->drawbuf, curr->gc, x, y, x, y2); } uint32_t setcolor(uint32_t color) { XRenderColor xrcolor; xrcolor.red = ((color >> 8) & 0xFF00) | 0x80; xrcolor.green = ((color)&0xFF00) | 0x80; xrcolor.blue = ((color << 8) & 0xFF00) | 0x80; xrcolor.alpha = 0xFFFF; XRenderFreePicture(display, curr->colorpic); curr->colorpic = XRenderCreateSolidFill(display, &xrcolor); uint32_t old = scolor; scolor = color; // xftcolor.pixel = color; XSetForeground(display, curr->gc, color); return old; } static XRectangle clip[16]; static int clipk; void pushclip(int left, int top, int width, int height) { if (!clipk) { // XSetClipMask(display, curr->gc, curr->drawbuf); } XRectangle *r = &clip[clipk++]; r->x = left; r->y = top; r->width = width; r->height = height; XSetClipRectangles(display, curr->gc, 0, 0, r, 1, Unsorted); XRenderSetPictureClipRectangles(display, curr->renderpic, 0, 0, r, 1); } void popclip(void) { clipk--; if (!clipk) { XSetClipMask(display, curr->gc, None); XRenderPictureAttributes pa; pa.clip_mask = None; XRenderChangePicture(display, curr->renderpic, CPClipMask, &pa); return; } XRectangle *r = &clip[clipk - 1]; XSetClipRectangles(display, curr->gc, 0, 0, r, 1, Unsorted); XRenderSetPictureClipRectangles(display, curr->renderpic, 0, 0, r, 1); } void enddraw(int x, int y, int width, int height) { XCopyArea(display, curr->drawbuf, curr->window, curr->gc, x, y, width, height, x, y); } uTox/src/xlib/dbus.h0000600000175000001440000000026714003056216013336 0ustar rakusers/* dbus.h */ #ifndef uDBUS_H #define uDBUS_H #ifdef HAVE_DBUS #include void dbus_notify(char *title, char *content, uint8_t *cid); #endif // HAVE_DBUS #endif // uDBUS_H uTox/src/xlib/dbus.c0000600000175000001440000000776214003056216013340 0ustar rakusers#ifdef HAVE_DBUS #include "dbus.h" #include "../debug.h" #include "../macros.h" #include "../text.h" #include #include #include #define NOTIFY_OBJECT "/org/freedesktop/Notifications" #define NOTIFY_INTERFACE "org.freedesktop.Notifications" static sig_atomic_t done; static int notify_build_message(DBusMessage *notify_msg, char *title, char *content, uint8_t *UNUSED(cid)) { DBusMessageIter args[4]; char * app_name = "uTox"; uint32_t replaces_id = -1; char * app_icon = ""; int32_t timeout = 5000; dbus_bool_t m = 0; char * key = "foo"; int value = 42; /* TODO we can use dbus to show the notifying users avatar, we don't do so anymore because the directory/save * functions were changed */ dbus_message_iter_init_append(notify_msg, &args[0]); m |= dbus_message_iter_append_basic(&args[0], DBUS_TYPE_STRING, &app_name); m |= dbus_message_iter_append_basic(&args[0], DBUS_TYPE_UINT32, &replaces_id); m |= dbus_message_iter_append_basic(&args[0], DBUS_TYPE_STRING, &app_icon); m |= dbus_message_iter_append_basic(&args[0], DBUS_TYPE_STRING, &title); m |= dbus_message_iter_append_basic(&args[0], DBUS_TYPE_STRING, &content); m |= dbus_message_iter_open_container(&args[0], DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &args[1]); /*for (i = 0; array[i]; i++ ) m |= dbus_message_iter_append_basic(&args[1], DBUS_TYPE_STRING, &array[i]);*/ m |= dbus_message_iter_close_container(&args[0], &args[1]); m |= dbus_message_iter_open_container(&args[0], DBUS_TYPE_ARRAY, "{sv}", &args[1]); /* usually {sv} for dictionaries */ m |= dbus_message_iter_open_container(&args[1], DBUS_TYPE_DICT_ENTRY, NULL, &args[2]); m |= dbus_message_iter_append_basic(&args[2], DBUS_TYPE_STRING, &key); m |= dbus_message_iter_open_container(&args[2], DBUS_TYPE_VARIANT, DBUS_TYPE_INT32_AS_STRING, &args[3]); m |= dbus_message_iter_append_basic(&args[3], DBUS_TYPE_INT32, &value); m |= dbus_message_iter_close_container(&args[2], &args[3]); m |= dbus_message_iter_close_container(&args[1], &args[2]); m |= dbus_message_iter_close_container(&args[0], &args[1]); m |= dbus_message_iter_append_basic(&args[0], DBUS_TYPE_INT32, &timeout); return m; } static void notify_callback(DBusPendingCall *UNUSED(pending), void *UNUSED(user_data)) { done = 1; } void dbus_notify(char *title, char *content, uint8_t *cid) { DBusMessage * msg; DBusConnection * conn; DBusError err; DBusPendingCall *pending; dbus_error_init(&err); conn = dbus_bus_get(DBUS_BUS_SESSION, &err); if (dbus_error_is_set(&err)) { LOG_ERR("Dbus", "Connection Error (%s)\n", err.message); dbus_error_free(&err); } if (!conn) { return; } msg = dbus_message_new_method_call(NULL, NOTIFY_OBJECT, NOTIFY_INTERFACE, "Notify"); if (!msg) { // fprintf(stderr, "Message Null\n"); // exit(1); return; } dbus_message_set_auto_start(msg, TRUE); dbus_message_set_destination(msg, NOTIFY_INTERFACE); /* append arguments UINT32 org.freedesktop.Notifications.Notify (STRING app_name, UINT32 replaces_id, STRING app_icon, STRING summary, STRING body, ARRAY actions, DICT hints, INT32 expire_timeout); */ if (!notify_build_message(msg, title, content, cid)) { // fprintf(stderr, "Out Of Memory!\n"); return; } dbus_error_init(&err); if (!dbus_connection_send_with_reply(conn, msg, &pending, -1)) { LOG_FATAL_ERR(EXIT_FAILURE, "Dbus", "Sending failed!"); } if (!dbus_pending_call_set_notify(pending, ¬ify_callback, NULL, NULL)) { // fprintf(stderr, "Callback failed!"); return; } while (!done) { dbus_connection_read_write_dispatch(conn, -1); } dbus_message_unref(msg); dbus_connection_unref(conn); return; } #endif uTox/src/xlib/audio.c0000600000175000001440000000040114003056216013463 0ustar rakusers#include "../macros.h" #include #include void audio_detect(void) {} bool audio_init(void *UNUSED(handle)) { return 0; } bool audio_close(void *UNUSED(handle)) { return 0; } bool audio_frame(int16_t *UNUSED(buffer)) { return 0; } uTox/src/xlib/CMakeLists.txt0000600000175000001440000001071014003056216014762 0ustar rakusersproject(utoxNATIVE LANGUAGES C) option(ENABLE_DBUS "Compile with dbus notification support" ON) if(ENABLE_DBUS) find_package(DBus REQUIRED) include_directories(${DBUS_INCLUDE_DIRS}) add_cflag("-DHAVE_DBUS=1") endif() ######################################### ## Native Icon data ######################################### add_custom_command(OUTPUT icon.o COMMAND cd ${uTox_SOURCE_DIR}/ && ld -r -b binary -o ${utoxNATIVE_BINARY_DIR}/icon.o icons/utox-128x128.png DEPENDS ../../icons/utox-128x128.png ) set_source_files_properties( icon.o PROPERTIES EXTERNAL_OBJECT true GENERATED true ) add_library(icon STATIC icon.o) set_target_properties( icon PROPERTIES LINKER_LANGUAGE C ) ######################################### ## Native Interface ######################################### add_library(utoxNATIVE STATIC audio.c $<$:dbus.c> drawing.c event.c filesys.c freetype.c gtk.c main.c $<$:mmenu.c> screen_grab.c tray.c v4l.c video.c window.c ../posix/filesys.c ) find_package(Freetype REQUIRED) include_directories(${FREETYPE_INCLUDE_DIRS}) message("Found Freetype version ${FREETYPE_VERSION_STRING}") message("Freetype include: ${FREETYPE_INCLUDE_DIRS}") message("Freetype library: ${FREETYPE_LIBRARIES}") find_package(libfontconfig REQUIRED) include_directories("${LIBFONTCONFIG_INCLUDE_DIRS}") message("FontConfig include: ${LIBFONTCONFIG_INCLUDE_DIRS}") message("FontConfig library: ${LIBFONTCONFIG_LIBRARIES}") message("X include: ${X11_INCLUDE_DIR}") message("X library: ${X11_LIBRARIES}") message("Xrender include: ${X11_Xrender_INCLUDE_PATH}") message("Xrender library: ${X11_Xrender_LIB}") find_package(libv4lconvert REQUIRED) include_directories("${LIBV4LCONVERT_INCLUDE_DIRS}") message("V4Lconvert include: ${LIBV4LCONVERT_INCLUDE_DIRS}") message("V4Lconvert library: ${LIBV4LCONVERT_LIBRARIES}") if(ENABLE_DBUS AND DBUS_LIBRARIES) message("DBus include: ${DBUS_INCLUDE_DIRS}") message("DBus library: ${DBUS_LIBRARIES}") else() set(DBUS_LIBRARIES "") endif() target_link_libraries(utoxNATIVE PUBLIC icon ${LIBV4LCONVERT_LIBRARIES} ${LIBFONTCONFIG_LIBRARIES} ${X11_LIBRARIES} ${X11_Xrender_LIB} ${FREETYPE_LIBRARIES} ${DBUS_LIBRARIES} PRIVATE stb ) if(LINUX OR NETBSD) target_link_libraries(utoxNATIVE PUBLIC resolv ) endif() if(LINUX) target_link_libraries(utoxNATIVE PUBLIC dl ) endif() include(GNUInstallDirs) install(FILES ../utox.desktop DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" ) install(FILES ../../man/utox.1 DESTINATION "${CMAKE_INSTALL_MANDIR}/man1" ) install(FILES ../../icons/utox-14x14.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/14x14/apps" ) install(FILES ../../icons/utox-16x16.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" ) install(FILES ../../icons/utox-22x22.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/22x22/apps" ) install(FILES ../../icons/utox-24x24.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/24x24/apps" ) install(FILES ../../icons/utox-32x32.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps" ) install(FILES ../../icons/utox-36x36.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/36x36/apps" ) install(FILES ../../icons/utox-48x48.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" ) install(FILES ../../icons/utox-64x64.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/64x64/apps" ) install(FILES ../../icons/utox-72x72.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/72x72/apps" ) install(FILES ../../icons/utox-96x96.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/96x96/apps" ) install(FILES ../../icons/utox-128x128.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps" ) install(FILES ../../icons/utox-256x256.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps" ) install(FILES ../../icons/utox-512x512.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/512x512/apps" ) install(FILES ../../icons/utox.svg DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps" ) uTox/src/windows/0000700000175000001440000000000014003056216012755 5ustar rakusersuTox/src/windows/window.h0000600000175000001440000000051114003056216014434 0ustar rakusers#ifndef WIN_WINDOW_H #define WIN_WINDOW_H #include "../native/window.h" #include struct native_window { struct utox_window _; HWND window; HDC window_DC; HDC draw_DC; HDC mem_DC; HBITMAP draw_BM; }; extern UTOX_WINDOW main_window; extern HINSTANCE curr_instance; #endif uTox/src/windows/window.c0000600000175000001440000001036214003056216014434 0ustar rakusers#include "window.h" #include "main.h" #include "notify.h" #include "events.h" #include "../branding.h" #include "../debug.h" #include "../macros.h" #include "../ui.h" #include #include static HWND l_main; HINSTANCE curr_instance; UTOX_WINDOW main_window; void native_window_init(HINSTANCE instance) { static const wchar_t main_classname[] = L"uTox"; curr_instance = instance; black_icon = LoadIcon(curr_instance, MAKEINTRESOURCE(101)); unread_messages_icon = LoadIcon(curr_instance, MAKEINTRESOURCE(102)); WNDCLASSW main_window_class = { .style = CS_OWNDC | CS_DBLCLKS, .lpfnWndProc = WindowProc, .hInstance = instance, .hIcon = black_icon, .lpszClassName = main_classname, }; RegisterClassW(&main_window_class); } void native_window_raze(UTOX_WINDOW *UNUSED(window)) { } static bool update_DC_BM(UTOX_WINDOW *win, int w, int h) { win->window_DC = GetDC(win->window); win->draw_DC = CreateCompatibleDC(win->window_DC); win->mem_DC = CreateCompatibleDC(win->draw_DC); win->draw_BM = CreateCompatibleBitmap(win->window_DC, w, h); return true; } UTOX_WINDOW *native_window_create_main(int x, int y, int w, int h) { static const wchar_t class[] = L"uTox"; char pretitle[128]; snprintf(pretitle, 128, "%s %s (version : %s)", TITLE, SUB_TITLE, VERSION); size_t title_size = strlen(pretitle) + 1; wchar_t title[title_size]; mbstowcs(title, pretitle, title_size); main_window.window = CreateWindowExW(0, class, title, WS_OVERLAPPEDWINDOW, x, y, w, h, NULL, NULL, NULL, NULL); // We may need to do this after MW_CREATE is called update_DC_BM(&main_window, w, h); return &main_window; } HWND native_window_create_video(int x, int y, int w, int h) { LOG_DEBUG("Windows WM", "Creating video window"); wchar_t title[128]; // %S for single-byte char, non-standard behaviour swprintf(title, 128, L"%S", S(WINDOW_TITLE_VIDEO_PREVIEW)); HWND win = CreateWindowExW(0, L"uTox", title, WS_OVERLAPPEDWINDOW, x, y, w, h, NULL, NULL, curr_instance, NULL); if (!win) { LOG_ERR("Windows WM", "ERROR trying to create video window"); LOG_ERR("debug", "%u", GetLastError()); } return win; } UTOX_WINDOW *popup = NULL; UTOX_WINDOW *native_window_create_notify(int x, int y, int w, int h, PANEL *panel) { static uint16_t notification_number = 0; static wchar_t class_name[] = L"uTox Notification"; HICON notify_black_icon = LoadIcon(curr_instance, MAKEINTRESOURCE(101)); WNDCLASSW notify_window_class = { .style = CS_DBLCLKS, .lpfnWndProc = notify_msg_sys, .hInstance = curr_instance, .hIcon = notify_black_icon, .lpszClassName = class_name, .hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH), }; RegisterClassW(¬ify_window_class); char pre[128]; snprintf(pre, 128, "uTox popup window %u", notification_number++); size_t title_size = strlen(pre) + 1; wchar_t title[title_size]; mbstowcs(title, pre, title_size); HWND window = CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW, class_name, title, WS_POPUP, x, y, w, h, l_main, NULL, NULL, NULL); if (!popup) { popup = calloc(1, sizeof(UTOX_WINDOW)); // FIXME leaks if (!popup) { LOG_ERR("Windows Wind", "NativeWindow:\tUnable to alloc to create window container"); return NULL; } } popup->window = window; update_DC_BM(popup, w, h); // In case we even need to raise this window to the top most z position. // SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); ShowWindow(window, SW_SHOWNOACTIVATE); popup->_.panel = panel; return popup; } UTOX_WINDOW *native_window_find_notify(void *window) { UTOX_WINDOW *win = popup; while (win) { if (win->window == *(HWND *)window) { return win; } win = win->_.next; } return NULL; } void native_window_create_screen_select(void) { return; } void native_window_tween(UTOX_WINDOW *UNUSED(win)) { return; } uTox/src/windows/video.c0000600000175000001440000000335614003056216014240 0ustar rakusers#include "main.h" #include "../debug.h" void video_frame(uint16_t id, uint8_t *img_data, uint16_t width, uint16_t height, bool resize) { if (!img_data) { LOG_DEBUG("Windows Video", "Received a null frame. Skipping..."); return; } HWND *hwin; if (id >= UINT16_MAX) { hwin = &preview_hwnd; } else { hwin = &video_hwnd[id]; } if (!hwin || !*hwin) { LOG_ERR("Windows Video", "frame for null window [%u]", id); return; } if (resize) { RECT r = {.left = 0, .top = 0, .right = width, .bottom = height }; AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW, 0); int w, h; w = r.right - r.left; h = r.bottom - r.top; if (w > GetSystemMetrics(SM_CXSCREEN)) { w = GetSystemMetrics(SM_CXSCREEN); } if (h > GetSystemMetrics(SM_CYSCREEN)) { h = GetSystemMetrics(SM_CYSCREEN); } SetWindowPos(*hwin, 0, 0, 0, w, h, SWP_NOZORDER | SWP_NOMOVE); } BITMAPINFO bmi = {.bmiHeader = { .biSize = sizeof(BITMAPINFOHEADER), .biWidth = width, .biHeight = -height, .biPlanes = 1, .biBitCount = 32, .biCompression = BI_RGB, } }; RECT r = { 0, 0, 0, 0 }; GetClientRect(*hwin, &r); HDC dc = GetDC(*hwin); if (width == r.right && height == r.bottom) { SetDIBitsToDevice(dc, 0, 0, width, height, 0, 0, 0, height, img_data, &bmi, DIB_RGB_COLORS); } else { StretchDIBits(dc, 0, 0, r.right, r.bottom, 0, 0, width, height, img_data, &bmi, DIB_RGB_COLORS, SRCCOPY); } } uTox/src/windows/utox.rc0000600000175000001440000000160014003056216014301 0ustar rakusers101 ICON "../../icons/icon.ico" 102 ICON "../../icons/icon_unread.ico" #if defined __WIN32__ || defined _WIN32 || defined __CYGWIN__ #include #endif #include "../branding.h" VS_VERSION_INFO VERSIONINFO FILEVERSION VER_MAJOR,VER_MINOR,VER_PATCH PRODUCTVERSION VER_MAJOR,VER_MINOR,VER_PATCH BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904E4" BEGIN VALUE "CompanyName", TITLE VALUE "FileDescription", UTOX_FILE_DESCRIPTION VALUE "FileVersion", VERSION VALUE "InternalName", TITLE VALUE "LegalCopyright", UTOX_COPYRIGHT VALUE "OriginalFilename", UTOX_FILENAME_WINDOWS VALUE "ProductName", TITLE VALUE "ProductVersion", VERSION END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0800, 1200 END ENDuTox/src/windows/utf8.h0000600000175000001440000000216314003056216014020 0ustar rakusers#ifndef WIN_UTF8_H #define WIN_UTF8_H #include #include #include // TODO: Maybe this should be a more generic text-util Windows header. /** Translate a char* from UTF-8 encoding to OS native; * This function could compromise the security of application. Use it properly. * * Accepts char pointer, native array pointer, length of input; * Returns: number of chars written, or 0 on failure. * */ int utf8tonative(const char *str, wchar_t *out, int length); int utf8_to_nativestr(const char *str, wchar_t *out, int length); /** * @brief Translate a null terminated OS native string to UTF-8 char*. * This function could compromise the security of application. Use it properly. * * @param str_in native array pointer. * @param str_out char pointer. * @param size of output buffer. * */ int native_to_utf8str(const wchar_t *str_in, char *str_out, uint32_t max_size); /** * Replaces all Windows-forbidden characters in the filename with underscores. * * @param filename a null-terminated string. * @return resulted filename is valid or not. */ bool sanitize_filename(uint8_t *filename); #endif uTox/src/windows/utf8.c0000600000175000001440000000430014003056216014006 0ustar rakusers#include "utf8.h" #include int utf8tonative(const char *str, wchar_t *out, int length) { return MultiByteToWideChar(CP_UTF8, 0, (char *)str, length, out, length); } /** * Caution! * * Using the MultiByteToWideChar function incorrectly can compromise the security of your application. Calling this * function can easily cause a buffer overrun because the size of the input buffer indicated by lpMultiByteStr equals * the number of bytes in the string, while the size of the output buffer indicated by lpWideCharStr equals the number * of characters. To avoid a buffer overrun, your application must specify a buffer size appropriate for the data type * the buffer receives. * For more information, see Security Considerations: International Features. */ int utf8_to_nativestr(const char *str, wchar_t *out, int length) { /* must be null terminated string ↓ */ return MultiByteToWideChar(CP_UTF8, 0, str, -1, out, length); } /** * Caution! * * Using the WideCharToMultiByte function incorrectly can compromise the security of your application. Calling this * function can easily cause a buffer overrun because the size of the input buffer indicated by lpWideCharStr equals the * number of characters in the Unicode string, while the size of the output buffer indicated by lpMultiByteStr equals * the number of bytes. To avoid a buffer overrun, your application must specify a buffer size appropriate for the data * type the buffer receives. * Data converted from UTF-16 to non-Unicode encodings is subject to data loss, because a code page might not be able to * represent every character used in the specific Unicode data. * For more information, see Security Considerations: International Features. */ int native_to_utf8str(const wchar_t *str_in, char *str_out, uint32_t max_size) { return WideCharToMultiByte(CP_UTF8, 0, str_in, -1, str_out, max_size, NULL, NULL); } // TODO, add utf8 support bool sanitize_filename(uint8_t *filename) { for (size_t i = 0; filename[i] != '\0'; ++i) { if (filename[i] < 32) { return false; } if (strchr("<>:\"/\\|?*", filename[i])) { filename[i] = '_'; } } return true; } uTox/src/windows/screen_grab.h0000600000175000001440000000025514003056216015404 0ustar rakusers#ifndef WIN_SCREENGRAB_H #define WIN_SCREENGRAB_H #include void screen_grab_init(HINSTANCE app_instance); void native_screen_grab_desktop(bool video); #endif uTox/src/windows/screen_grab.c0000600000175000001440000001453514003056216015405 0ustar rakusers#include "main.h" #include "../debug.h" #include "../flist.h" #include "../friend.h" #include "../tox.h" #include "../av/utox_av.h" #include "stb.h" #include static HWND grab_window; static HINSTANCE grab_instance; static bool desktopgrab_video = false; // creates an UTOX_NATIVE image based on given arguments // image should be freed with image_free static NATIVE_IMAGE *create_utox_image(HBITMAP bmp, bool has_alpha, uint32_t width, uint32_t height) { NATIVE_IMAGE *image = malloc(sizeof(NATIVE_IMAGE)); if (!image) { LOG_ERR("NATIVE Screengrab", "create_utox_image:\t Could not allocate memory for image."); return NULL; } image->bitmap = bmp; image->has_alpha = has_alpha; image->width = width; image->height = height; image->scaled_width = width; image->scaled_height = height; image->stretch_mode = COLORONCOLOR; return image; } static void sendbitmap(HDC mem, HBITMAP hbm, int width, int height) { if (width == 0 || height == 0) { return; } BITMAPINFO info = { .bmiHeader = { .biSize = sizeof(BITMAPINFOHEADER), .biWidth = width, .biHeight = -height, .biPlanes = 1, .biBitCount = 24, .biCompression = BI_RGB, } }; void *bits = malloc((width + 3) * height * 3); GetDIBits(mem, hbm, 0, height, bits, &info, DIB_RGB_COLORS); uint8_t pbytes = width & 3, *p = bits, *pp = bits, *end = p + width * height * 3; // uint32_t offset = 0; while (p != end) { int i; for (i = 0; i != width; i++) { uint8_t b = pp[i * 3]; p[i * 3] = pp[i * 3 + 2]; p[i * 3 + 1] = pp[i * 3 + 1]; p[i * 3 + 2] = b; } p += width * 3; pp += width * 3 + pbytes; } int size = 0; UTOX_IMAGE out = stbi_write_png_to_mem(bits, 0, width, height, 3, &size); free(bits); NATIVE_IMAGE *image = create_utox_image(hbm, 0, width, height); friend_sendimage(flist_get_sel_friend(), image, width, height, out, size); } static LRESULT CALLBACK screen_grab_sys(HWND window, UINT msg, WPARAM wParam, LPARAM lParam) { POINT p = {.x = GET_X_LPARAM(lParam), .y = GET_Y_LPARAM(lParam) }; ClientToScreen(window, &p); static bool mdown = false; switch (msg) { case WM_MOUSEMOVE: { if (!mdown) { break; } HDC dc = GetDC(window); BitBlt(dc, video_grab_x, video_grab_y, video_grab_w - video_grab_x, video_grab_h - video_grab_y, dc, video_grab_x, video_grab_y, BLACKNESS); video_grab_w = p.x; video_grab_h = p.y; BitBlt(dc, video_grab_x, video_grab_y, video_grab_w - video_grab_x, video_grab_h - video_grab_y, dc, video_grab_x, video_grab_y, WHITENESS); ReleaseDC(window, dc); return false; } case WM_LBUTTONDOWN: { mdown = true; video_grab_x = video_grab_w = p.x; video_grab_y = video_grab_h = p.y; SetCapture(window); return false; } case WM_LBUTTONUP: { mdown = false; ReleaseCapture(); if (video_grab_x < video_grab_w) { video_grab_w -= video_grab_x; } else { const int w = video_grab_x - video_grab_w; video_grab_x = video_grab_w; video_grab_w = w; } if (video_grab_y < video_grab_h) { video_grab_h -= video_grab_y; } else { const int h = video_grab_y - video_grab_h; video_grab_y = video_grab_h; video_grab_h = h; } if (desktopgrab_video) { DestroyWindow(window); postmessage_utoxav(UTOXAV_SET_VIDEO_IN, 1, 0, NULL); } else { if (flist_get_sel_friend()) { FRIEND *f = flist_get_sel_friend(); if (f->online) { DestroyWindow(window); HWND dwnd = GetDesktopWindow(); HDC ddc = GetDC(dwnd); HDC mem = CreateCompatibleDC(ddc); HBITMAP capture = CreateCompatibleBitmap(ddc, video_grab_w, video_grab_h); SelectObject(mem, capture); BitBlt(mem, 0, 0, video_grab_w, video_grab_h, ddc, video_grab_x, video_grab_y, SRCCOPY | CAPTUREBLT); sendbitmap(mem, capture, video_grab_w, video_grab_h); ReleaseDC(dwnd, ddc); DeleteDC(mem); } } } return false; } } return DefWindowProcW(window, msg, wParam, lParam); } void screen_grab_init(HINSTANCE app_instance) { HICON screengrab_black_icon = LoadIcon(app_instance, MAKEINTRESOURCE(101)); wchar_t screen_grab_class[] = L"uToxgrab"; WNDCLASSW grab_window_class = { .hInstance = app_instance, .lpfnWndProc = screen_grab_sys, .lpszClassName = screen_grab_class, .hIcon = screengrab_black_icon, .hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH), }; RegisterClassW(&grab_window_class); grab_instance = app_instance; } void native_screen_grab_desktop(bool video) { int x = GetSystemMetrics(SM_XVIRTUALSCREEN); int y = GetSystemMetrics(SM_YVIRTUALSCREEN); int w = GetSystemMetrics(SM_CXVIRTUALSCREEN); int h = GetSystemMetrics(SM_CYVIRTUALSCREEN); LOG_TRACE("Native Screengrab", "result: %i %i %i %i" , x, y, w, h); grab_window = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_LAYERED, L"uToxgrab", L"Tox", WS_POPUP, x, y, w, h, NULL, NULL, grab_instance, NULL); if (!grab_window) { LOG_TRACE("Native Screengrab", "CreateWindowExW() failed" ); return; } SetLayeredWindowAttributes(grab_window, 0xFFFFFF, 128, LWA_ALPHA | LWA_COLORKEY); // UpdateLayeredWindow(main_window.window, NULL, NULL, NULL, NULL, NULL, 0xFFFFFF, ULW_ALPHA | ULW_COLORKEY); ShowWindow(grab_window, SW_SHOW); SetForegroundWindow(grab_window); desktopgrab_video = video; } uTox/src/windows/os_video.c0000600000175000001440000004306114003056216014736 0ustar rakusers#include "window.h" #include "main.h" #include "../debug.h" #include "../macros.h" #include "../av/video.h" #include "../native/time.h" #include "../../langs/i18n_decls.h" #include #ifdef __CRT__NO_INLINE #undef __CRT__NO_INLINE #include #define __CRT__NO_INLINE #else #include #endif #include // amvideo.h must be included after dshow #include #include int video_grab_x, video_grab_y, video_grab_w, video_grab_h; static IGraphBuilder * pGraph; static IBaseFilter * pGrabberF; static IMediaControl * pControl; static ISampleGrabber *pGrabber; // TODO: free resources correctly (on failure, etc) static IBaseFilter *pNullF = NULL; static IPin * pPin = NULL; static IPin * pIPin; static HWND desktopwnd; static HDC desktopdc, capturedc; static HBITMAP capturebitmap; static bool capturedesktop; static void * dibits; static uint16_t video_x, video_y; void video_begin(uint16_t id, char *UNUSED(name), uint16_t UNUSED(name_length), uint16_t width, uint16_t height) { HWND *h; if (id >= UINT16_MAX) { h = &preview_hwnd; } else { h = &video_hwnd[id]; } if (*h) { // Video already started. // TODO: We should really call this function in a smarter way. return; } RECT r = { .left = 0, .right = width, .top = 0, .bottom = height }; AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW, 0); width = r.right - r.left; height = r.bottom - r.top; if (width > GetSystemMetrics(SM_CXSCREEN)) { width = GetSystemMetrics(SM_CXSCREEN); } if (height > GetSystemMetrics(SM_CYSCREEN)) { height = GetSystemMetrics(SM_CYSCREEN); } *h = native_window_create_video(0, 0, width, height); if (!*h) { LOG_ERR("Win OSVideo", "Unable to create this window w%uh%u", width, height); } ShowWindow(*h, SW_SHOW); } void video_end(uint16_t id) { if (id >= UINT16_MAX) { DestroyWindow(preview_hwnd); preview_hwnd = NULL; } else { if (video_hwnd[id]) { DestroyWindow(video_hwnd[id]); } video_hwnd[id] = NULL; } } volatile bool newframe = 0; uint8_t *frame_data; HRESULT STDMETHODCALLTYPE test_SampleCB(ISampleGrabberCB *UNUSED(lpMyObj), double UNUSED(SampleTime), IMediaSample *pSample) { // you can call functions like: // REFERENCE_TIME tStart, tStop; uint8_t *sampleBuffer; pSample->lpVtbl->GetPointer(pSample, (BYTE **)&sampleBuffer); uint16_t length = pSample->lpVtbl->GetActualDataLength(pSample); /*pSample->GetTime(&tStart, &tStop); */ if (length == video_width * video_height * 3) { uint8_t *p = frame_data + video_width * video_height * 3; for (int y = 0; y != video_height; y++) { p -= video_width * 3; memcpy(p, sampleBuffer, video_width * 3); sampleBuffer += video_width * 3; } newframe = 1; } // LOG_TRACE("Video", "frame %u" , length); return S_OK; } STDMETHODIMP test_QueryInterface(ISampleGrabberCB *UNUSED(lpMyObj), REFIID UNUSED(riid), LPVOID FAR *UNUSED(lppvObj)) { return 0; } STDMETHODIMP_(ULONG) test_AddRef(ISampleGrabberCB *UNUSED(lpMyObj)) { return 1; } STDMETHODIMP_(ULONG) test_Release(ISampleGrabberCB *lpMyObj) { free(lpMyObj->lpVtbl); free(lpMyObj); return 0; } #define SafeRelease(x) \ if (*(x)) { \ (*(x))->lpVtbl->Release(*(x)); \ } HRESULT IsPinConnected(IPin *local_pPin, BOOL *pResult) { IPin * pTmp = NULL; HRESULT hr = local_pPin->lpVtbl->ConnectedTo(local_pPin, &pTmp); if (SUCCEEDED(hr)) { *pResult = TRUE; } else if (hr == VFW_E_NOT_CONNECTED) { // The pin is not connected. This is not an error for our purposes. *pResult = FALSE; hr = S_OK; } SafeRelease(&pTmp); return hr; } HRESULT IsPinDirection(IPin *local_pPin, PIN_DIRECTION dir, BOOL *pResult) { PIN_DIRECTION pinDir; HRESULT hr = local_pPin->lpVtbl->QueryDirection(local_pPin, &pinDir); if (SUCCEEDED(hr)) { *pResult = (pinDir == dir); } return hr; } HRESULT MatchPin(IPin *local_pPin, PIN_DIRECTION direction, BOOL bShouldBeConnected, BOOL *pResult) { // assert(pResult != NULL); BOOL bMatch = FALSE; BOOL bIsConnected = FALSE; HRESULT hr = IsPinConnected(local_pPin, &bIsConnected); if (SUCCEEDED(hr)) { if (bIsConnected == bShouldBeConnected) { hr = IsPinDirection(local_pPin, direction, &bMatch); } } if (SUCCEEDED(hr)) { *pResult = bMatch; } return hr; } HRESULT FindUnconnectedPin(IBaseFilter *pFilter, PIN_DIRECTION PinDir, IPin **ppPin) { IEnumPins *pEnum = NULL; IPin * local_pPin = NULL; BOOL bFound = FALSE; HRESULT hr = pFilter->lpVtbl->EnumPins(pFilter, &pEnum); if (FAILED(hr)) { goto done; } while (S_OK == pEnum->lpVtbl->Next(pEnum, 1, &local_pPin, NULL)) { hr = MatchPin(local_pPin, PinDir, FALSE, &bFound); if (FAILED(hr)) { goto done; } if (bFound) { *ppPin = local_pPin; (*ppPin)->lpVtbl->AddRef(*ppPin); break; } SafeRelease(&local_pPin); } if (!bFound) { hr = VFW_E_NOT_FOUND; } done: SafeRelease(&local_pPin); SafeRelease(&pEnum); return hr; } IPin *ConnectFilters2(IGraphBuilder *_pGraph, IPin *pOut, IBaseFilter *pDest) { IPin *pIn = NULL; // Find an input pin on the downstream filter. HRESULT hr = FindUnconnectedPin(pDest, PINDIR_INPUT, &pIn); if (SUCCEEDED(hr)) { // Try to connect them. hr = pGraph->lpVtbl->Connect(_pGraph, pOut, pIn); pIn->lpVtbl->Release(pIn); } return SUCCEEDED(hr) ? pIn : NULL; } HRESULT ConnectFilters(IGraphBuilder *_pGraph, IBaseFilter *pSrc, IBaseFilter *pDest) { IPin *pOut = NULL; // Find an output pin on the first filter. HRESULT hr = FindUnconnectedPin(pSrc, PINDIR_OUTPUT, &pOut); if (SUCCEEDED(hr)) { if (!ConnectFilters2(_pGraph, pOut, pDest)) { hr = 1; } pOut->lpVtbl->Release(pOut); } return hr; } uint16_t native_video_detect(void) { // Indicate that we support desktop capturing. utox_video_append_device((void *)1, 1, (void *)STR_VIDEO_IN_DESKTOP, 0); max_video_width = GetSystemMetrics(SM_CXVIRTUALSCREEN); max_video_height = GetSystemMetrics(SM_CYVIRTUALSCREEN); HRESULT hr; CoInitialize(NULL); IMediaEventEx *pEvent; hr = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IGraphBuilder, (void **)&pGraph); if (FAILED(hr)) { return 0; } hr = pGraph->lpVtbl->QueryInterface(pGraph, &IID_IMediaControl, (void **)&pControl); if (FAILED(hr)) { return 0; } hr = pGraph->lpVtbl->QueryInterface(pGraph, &IID_IMediaEventEx, (void **)&pEvent); if (FAILED(hr)) { return 0; } hr = CoCreateInstance(&CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (void **)&pGrabberF); if (FAILED(hr)) { return 0; } hr = pGraph->lpVtbl->AddFilter(pGraph, pGrabberF, L"Sample Grabber"); if (FAILED(hr)) { return 0; } hr = pGrabberF->lpVtbl->QueryInterface(pGrabberF, &IID_ISampleGrabber, (void **)&pGrabber); if (FAILED(hr)) { return 0; } AM_MEDIA_TYPE mt = { .majortype = MEDIATYPE_Video, .subtype = MEDIASUBTYPE_RGB24, }; hr = pGrabber->lpVtbl->SetMediaType(pGrabber, &mt); if (FAILED(hr)) { return 0; } ICreateDevEnum *pSysDevEnum = NULL; hr = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, &IID_ICreateDevEnum, (void **)&pSysDevEnum); if (FAILED(hr)) { LOG_TRACE("Video", "CoCreateInstance failed()" ); return 0; } // Obtain a class enumerator for the video compressor category. IEnumMoniker *pEnumCat = NULL; hr = pSysDevEnum->lpVtbl->CreateClassEnumerator(pSysDevEnum, &CLSID_VideoInputDeviceCategory, &pEnumCat, 0); if (hr != S_OK) { pSysDevEnum->lpVtbl->Release(pSysDevEnum); LOG_TRACE("Video", "CreateClassEnumerator failed()" ); return 0; } IBaseFilter *pFilter = NULL; IMoniker * pMoniker = NULL; uint16_t device_count = 1; /* start at 1 because we support desktop grabbing */ LOG_TRACE("Video", "Windows Video Devices:" ); ULONG cFetched; while (pEnumCat->lpVtbl->Next(pEnumCat, 1, &pMoniker, &cFetched) == S_OK) { IPropertyBag *pPropBag; hr = pMoniker->lpVtbl->BindToStorage(pMoniker, 0, 0, &IID_IPropertyBag, (void **)&pPropBag); if (SUCCEEDED(hr)) { // To retrieve the filter's friendly name, do the following: VARIANT varName; VariantInit(&varName); hr = pPropBag->lpVtbl->Read(pPropBag, L"FriendlyName", &varName, 0); if (SUCCEEDED(hr)) { if (varName.vt == VT_BSTR) { LOG_TRACE("Video", "\tFriendly name: %ls" , varName.bstrVal); } else { LOG_TRACE("Video", "\tEw, got an unfriendly name" ); } // To create an instance of the filter, do the following: hr = pMoniker->lpVtbl->BindToObject(pMoniker, NULL, NULL, &IID_IBaseFilter, (void **)&pFilter); if (SUCCEEDED(hr)) { int len = wcslen(varName.bstrVal); char *data = malloc(sizeof(*pFilter) + len * 2); WideCharToMultiByte(CP_UTF8, 0, varName.bstrVal, -1, data + sizeof(*pFilter), len * 2, NULL, 0); memcpy(data, &pFilter, sizeof(pFilter)); utox_video_append_device(data, 0, data + 8, 1); device_count++; } } else { LOG_TRACE("Video", "Windows Video Code:\tcouldn't get a name for this device, this is a bug, please report!" ); } VariantClear(&varName); // Now add the filter to the graph. // Remember to release pFilter later. pPropBag->lpVtbl->Release(pPropBag); } pMoniker->lpVtbl->Release(pMoniker); } pEnumCat->lpVtbl->Release(pEnumCat); pSysDevEnum->lpVtbl->Release(pSysDevEnum); hr = CoCreateInstance(&CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (void **)&pNullF); if (FAILED(hr)) { LOG_TRACE("Video", "CoCreateInstance failed" ); return 0; } hr = pGraph->lpVtbl->AddFilter(pGraph, pNullF, L"Null Filter"); if (FAILED(hr)) { LOG_TRACE("Video", "AddFilter failed" ); return 0; } hr = ConnectFilters(pGraph, pGrabberF, pNullF); if (FAILED(hr)) { LOG_TRACE("Video", "ConnectFilters (2) failed" ); return 0; } /* I think this generates and formats the call back to copy each frame from the webcam */ ISampleGrabberCB *test; test = malloc(sizeof(ISampleGrabberCB)); test->lpVtbl = malloc(sizeof(*(test->lpVtbl))); // no idea what im doing here /* Yeah, me neither... */ test->lpVtbl->QueryInterface = test_QueryInterface; test->lpVtbl->AddRef = test_AddRef; test->lpVtbl->Release = test_Release; test->lpVtbl->SampleCB = test_SampleCB; test->lpVtbl->BufferCB = 0; /* I think this sets the call back for each frame... */ hr = pGrabber->lpVtbl->SetCallback(pGrabber, test, 0); if (FAILED(hr)) { return 0; } return device_count; } bool native_video_init(void *handle) { if ((size_t)handle == 1) { video_x = video_grab_x; video_y = video_grab_y; video_width = video_grab_w; video_height = video_grab_h; if (video_width & 1) { if (video_x & 1) { video_x--; } video_width++; } if (video_width & 2) { video_width -= 2; } if (video_height & 1) { if (video_y & 1) { video_y--; } video_height++; } LOG_TRACE("Video", "size: %u %u" , video_width, video_height); desktopwnd = GetDesktopWindow(); if (!desktopwnd) { LOG_TRACE("Video", "GetDesktopWindow() failed" ); return 0; } if (!(desktopdc = GetDC(desktopwnd))) { LOG_TRACE("Video", "GetDC(desktopwnd) failed" ); return 0; } if (!(capturedc = CreateCompatibleDC(desktopdc))) { LOG_TRACE("Video", "CreateCompatibleDC(desktopdc) failed" ); return 0; } if (!(capturebitmap = CreateCompatibleBitmap(desktopdc, video_width, video_height))) { LOG_TRACE("Video", "CreateCompatibleBitmap(desktopdc) failed" ); return 0; } SelectObject(capturedc, capturebitmap); dibits = malloc(video_width * video_height * 3); capturedesktop = 1; return 1; } else { capturedesktop = 0; } HRESULT hr; IBaseFilter *pFilter = handle; hr = pGraph->lpVtbl->AddFilter(pGraph, pFilter, L"Video Capture"); if (FAILED(hr)) { LOG_TRACE("Video", "AddFilter failed" ); return 0; } IEnumPins *pEnum = NULL; /* build filter graph */ hr = pFilter->lpVtbl->EnumPins(pFilter, &pEnum); if (FAILED(hr)) { LOG_TRACE("Video", "EnumPins failed" ); return 0; } while (S_OK == pEnum->lpVtbl->Next(pEnum, 1, &pPin, NULL)) { pIPin = ConnectFilters2(pGraph, pPin, pGrabberF); SafeRelease(&pPin); if (pIPin) { break; } } if (FAILED(hr)) { LOG_TRACE("Video", "failed to connect a filter" ); return 0; } IAMStreamConfig *pConfig = NULL; AM_MEDIA_TYPE * pmt = NULL; hr = pPin->lpVtbl->QueryInterface(pPin, &IID_IAMStreamConfig, (void **)&pConfig); if (FAILED(hr)) { LOG_TRACE("Video", "Windows Video device: QueryInterface failed" ); return 0; } hr = pConfig->lpVtbl->GetFormat(pConfig, &pmt); if (FAILED(hr)) { LOG_TRACE("Video", "Windows Video device: GetFormat failed" ); return 0; } BITMAPINFOHEADER *bmiHeader; if (IsEqualGUID(&pmt->formattype, &FORMAT_VideoInfo)) { VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER *)pmt->pbFormat; bmiHeader = &(pvi->bmiHeader); video_width = bmiHeader->biWidth; video_height = bmiHeader->biHeight; } else { LOG_TRACE("Video", "got bad format" ); video_width = 0; video_height = 0; } frame_data = malloc((size_t)video_width * video_height * 3); LOG_TRACE("Video", "Windows video init:\n\twidth height %u %u" , video_width, video_height); return 1; } void native_video_close(void *handle) { if ((size_t)handle == 1) { ReleaseDC(desktopwnd, desktopdc); DeleteDC(capturedc); DeleteObject(capturebitmap); free(dibits); capturedesktop = 0; return; } LOG_NOTE("Video", "Closing webcam"); IBaseFilter *pFilter = handle; if (FAILED(pGraph->lpVtbl->RemoveFilter(pGraph, pFilter))) { LOG_ERR("Video", "Failed to close webcam. (1)"); return; } if (FAILED(pGraph->lpVtbl->Disconnect(pGraph, pPin))) { LOG_ERR("Video", "Failed to close webcam. (2)"); return; } if (FAILED(pGraph->lpVtbl->Disconnect(pGraph, pIPin))) { LOG_ERR("Video", "Failed to close webcam. (3)"); return; } } int native_video_getframe(uint8_t *y, uint8_t *u, uint8_t *v, uint16_t width, uint16_t height) { if (width != video_width || height != video_height) { LOG_TRACE("Video", "width/height mismatch %u %u != %u %u" , width, height, video_width, video_height); return 0; } if (capturedesktop) { static uint64_t lasttime; uint64_t t = get_time(); if (t - lasttime >= (uint64_t)1000 * 1000 * 1000 / 24) { BITMAPINFO info = {.bmiHeader = { .biSize = sizeof(BITMAPINFOHEADER), .biWidth = video_width, .biHeight = -(int)video_height, .biPlanes = 1, .biBitCount = 24, .biCompression = BI_RGB, } }; BitBlt(capturedc, 0, 0, video_width, video_height, desktopdc, video_x, video_y, SRCCOPY | CAPTUREBLT); GetDIBits(capturedc, capturebitmap, 0, video_height, dibits, &info, DIB_RGB_COLORS); bgrtoyuv420(y, u, v, dibits, video_width, video_height); lasttime = t; return 1; } return 0; } if (newframe) { newframe = 0; bgrtoyuv420(y, u, v, frame_data, video_width, video_height); return 1; } return 0; } bool native_video_startread(void) { if (capturedesktop) { return 1; } LOG_TRACE("Video", "start webcam" ); HRESULT hr; hr = pControl->lpVtbl->Run(pControl); if (FAILED(hr)) { LOG_TRACE("Video", "Run failed" ); return 0; } return 1; } bool native_video_endread(void) { if (capturedesktop) { return 1; } LOG_TRACE("Video", "stop webcam" ); HRESULT hr; hr = pControl->lpVtbl->StopWhenReady(pControl); if (FAILED(hr)) { LOG_TRACE("Video", "Stop failed" ); return 0; } return 1; } uTox/src/windows/notify.h0000600000175000001440000000032014003056216014433 0ustar rakusers#ifndef WIN_NOTIFY_H #define WIN_NOTIFY_H #include LRESULT CALLBACK notify_msg_sys(HWND window, UINT msg, WPARAM wParam, LPARAM lParam); void native_notify_init(HINSTANCE app_instance); #endif uTox/src/windows/notify.c0000600000175000001440000001301714003056216014435 0ustar rakusers#include "notify.h" #include "main.h" #include "utf8.h" #include "window.h" #include "../debug.h" #include "../macros.h" #include "../self.h" #include "../text.h" #include "../ui.h" #include "../native/notify.h" #include "../native/window.h" #include /** * A null-terminated string that specifies a title for a balloon notification. * This title appears in a larger font immediately above the text. * It can have a maximum of 64 characters, including the terminating null character. * https://msdn.microsoft.com/en-us/library/windows/desktop/bb773352(v=vs.85).aspx */ static const uint16_t MAX_TITLE_LENGTH = 64 - 1; /** * A null-terminated string that specifies the text to display in a balloon notification. * It can have a maximum of 256 characters, including the terminating null character. * https://msdn.microsoft.com/en-us/library/windows/desktop/bb773352(v=vs.85).aspx */ static const uint16_t MAX_MSG_LENGTH = 256 - 1; bool have_focus = false; /** Creates a tray balloon popup with the message, and flashes the main window * * accepts: char *title, title length, char *msg, msg length; * returns void; */ void notify(char *title, uint16_t title_length, const char *msg, uint16_t msg_length, void *UNUSED(object), bool UNUSED(is_group)) { if (have_focus || self.status == 2) { return; } FlashWindow(main_window.window, true); flashing = true; NOTIFYICONDATAW nid = { .cbSize = sizeof(nid), .hWnd = main_window.window, .uFlags = NIF_ICON | NIF_INFO, .hIcon = unread_messages_icon, .uTimeout = 5000, .dwInfoFlags = 0, }; uint16_t title_len = safe_shrink(title, title_length, MAX_TITLE_LENGTH); utf8tonative(title, nid.szInfoTitle, title_len); uint16_t msg_len = safe_shrink(msg, msg_length, MAX_MSG_LENGTH); utf8tonative(msg, nid.szInfo, msg_len); Shell_NotifyIconW(NIM_MODIFY, &nid); } static void redraw_notify(UTOX_WINDOW *win) { LOG_TRACE("Notify", "redraw start"); native_window_set_target(win); panel_draw(win->_.panel, 0, 0, win->_.w, win->_.h); SelectObject(win->draw_DC, win->draw_BM); BitBlt(win->window_DC, win->_.x, win->_.y, win->_.w, win->_.h, win->draw_DC, win->_.x, win->_.y, SRCCOPY); LOG_TRACE("Notify", "redraw end"); } LRESULT CALLBACK notify_msg_sys(HWND window, UINT msg, WPARAM wParam, LPARAM lParam) { UTOX_WINDOW *win = native_window_find_notify(&window); static int mdown_x, mdown_y; switch (msg) { case WM_QUIT: { LOG_TRACE("Notify", "QUIT"); break; } case WM_CLOSE: { LOG_TRACE("Notify", "CLOSE"); break; } case WM_DESTROY: { LOG_TRACE("Notify", "DESTROY"); break; } case WM_GETMINMAXINFO: { LOG_TRACE("Notify", "MINMAX_INFO"); POINT min = { SCALE(200), SCALE(200) }; ((MINMAXINFO *)lParam)->ptMinTrackSize = min; break; } case WM_CREATE: { LOG_ERR("Win Notify", "NOTIFY::\tCreate"); if (win) { win->window_DC = GetDC(window); win->draw_DC = CreateCompatibleDC(win->window_DC); win->mem_DC = CreateCompatibleDC(win->draw_DC); return false; } break; } case WM_SIZE: { LOG_ERR("Win Notify", "NOTIFY::\tSize"); int w, h; w = GET_X_LPARAM(lParam); h = GET_Y_LPARAM(lParam); if (w != 0) { RECT r; GetClientRect(window, &r); w = r.right; h = r.bottom; if (win) { if (win->draw_BM) { DeleteObject(win->draw_BM); } win->draw_BM = CreateCompatibleBitmap(win->window_DC, w, h); redraw_notify(win); } } break; } case WM_ERASEBKGND: { LOG_ERR("Win Notify", "NOTIFY::\tBGND"); redraw_notify(win); return true; } case WM_PAINT: { LOG_ERR("Win Notify", "NOTIFY::\tPAINT"); PAINTSTRUCT ps; BeginPaint(window, &ps); RECT r = ps.rcPaint; BitBlt(win->window_DC, r.left, r.top, r.right - r.left, r.bottom - r.top, win->draw_DC, r.left, r.top, SRCCOPY); EndPaint(window, &ps); return false; } case WM_MOUSEMOVE: { // LOG_TRACE("Notify", "MMOVE"); return false; } case WM_LBUTTONDOWN: { mdown_x = GET_X_LPARAM(lParam); mdown_y = GET_Y_LPARAM(lParam); LOG_TRACE("Notify", "Left down %i %i", mdown_x, mdown_y); break; } case WM_LBUTTONUP: { LOG_TRACE("Notify", "Left up"); ReleaseCapture(); redraw_notify(win); break; } case WM_LBUTTONDBLCLK: { LOG_TRACE("Notify", "Dbl click, going to close"); DestroyWindow(window); break; } case WM_RBUTTONDOWN: { LOG_TRACE("Notify", "R BTN DOWN"); break; } case WM_RBUTTONUP: { LOG_TRACE("Notify", "R BTN UP"); break; } } return DefWindowProcW(window, msg, wParam, lParam); } static HINSTANCE current_instance = NULL; void native_notify_init(HINSTANCE instance) { current_instance = instance; } uTox/src/windows/main.h0000600000175000001440000000421214003056216014053 0ustar rakusers#if defined(MAIN_H) && !defined(WINDOWS_MAIN_H) #error "We should never include main from different platforms." #endif #ifndef WINDOWS_MAIN_H #define WINDOWS_MAIN_H #define MAIN_H #undef _WIN32_WINNT #define _WIN32_WINNT 0x0600 #ifndef WINVER #define WINVER 0x410 #endif #include #include #undef CLEARTYPE_QUALITY #define CLEARTYPE_QUALITY 5 #define STRSAFE_NO_DEPRECATE #include #include #define STRSAFE_NO_DEPRECATE #include #include #include #define WM_NOTIFYICON (WM_APP + 0) #define WM_TOX (WM_APP + 1) extern const CLSID CLSID_SampleGrabber; extern const CLSID CLSID_NullRenderer; enum { MENU_TEXTINPUT = 101, MENU_MESSAGES = 102, }; extern HFONT font[32]; extern HCURSOR cursors[8]; extern HICON black_icon, unread_messages_icon; extern HBRUSH hdc_brush; extern HWND video_hwnd[128]; // todo fixme extern HWND preview_hwnd; // todo fixme extern bool flashing; extern bool hidden; // internal representation of an image typedef struct native_image { HBITMAP bitmap; // 32 bit bitmap containing // red, green, blue and alpha bool has_alpha; // whether bitmap has an alpha channel // width and height in pixels of the bitmap uint32_t width, height; // width and height in pixels the image should be drawn to uint32_t scaled_width, scaled_height; // stretch mode used when stretching this image, either // COLORONCOLOR(ugly and fast), or HALFTONE(prettier and slower) int stretch_mode; } NATIVE_IMAGE; // static char save_path[280]; extern char portable_mode_save_path[MAX_PATH]; // WM_COMMAND enum { TRAY_SHOWHIDE, TRAY_EXIT, TRAY_STATUS_AVAILABLE, TRAY_STATUS_AWAY, TRAY_STATUS_BUSY, }; extern int video_grab_x, video_grab_y, video_grab_w, video_grab_h; LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); /* Included in dnd.c */ void dnd_init(HWND window); void tray_icon_init(HWND window, HICON icon); // Converts a Windows wide null-terminated string to utf8. int native_to_utf8str(const wchar_t *str_in, char *str_out, uint32_t max_size); #endif uTox/src/windows/main.c0000600000175000001440000010112114003056216014043 0ustar rakusers#include "main.h" #include "notify.h" #include "screen_grab.h" #include "utf8.h" #include "window.h" #include "../avatar.h" #include "../chatlog.h" #include "../commands.h" #include "../debug.h" #include "../file_transfers.h" #include "../filesys.h" #include "../flist.h" #include "../friend.h" #include "../macros.h" #include "../main.h" // Lots of things. :( #include "../self.h" #include "../settings.h" #include "../text.h" #include "../theme.h" #include "../tox.h" #include "../ui.h" #include "../utox.h" #include "../av/utox_av.h" #include "../native/filesys.h" #include "../native/notify.h" #include "../native/os.h" #include "../ui/draw.h" #include "../ui/edit.h" #include "../ui/svg.h" #include "../layout/background.h" // TODO do we want to remove this? #include "../layout/friend.h" #include "../layout/group.h" #include "stb.h" #include #include HFONT font[32]; HCURSOR cursors[8]; HICON black_icon, unread_messages_icon; HBRUSH hdc_brush; HWND video_hwnd[128]; // todo fixme HWND preview_hwnd; // todo fixme char portable_mode_save_path[MAX_PATH]; /** * A null-terminated string that specifies the text for a standard tooltip. * For Windows 2000 and later, szTip can have a maximum of 128 characters, * including the terminating null character. * https://msdn.microsoft.com/en-us/library/windows/desktop/bb773352(v=vs.85).aspx */ static const uint8_t MAX_TIP_LENGTH = 128 - 1; bool flashing = false; bool hidden = false; void native_export_chatlog_init(uint32_t friend_number) { FRIEND *f = get_friend(friend_number); if (!f) { LOG_ERR("Windows", "Could not get friend with number: %u", friend_number); return; } char *path = calloc(1, UTOX_FILE_NAME_LENGTH); if (!path) { LOG_ERR("Windows", "Could not allocate memory."); return; } snprintf(path, UTOX_FILE_NAME_LENGTH, "%.*s.txt", (int)f->name_length, f->name); wchar_t filepath[UTOX_FILE_NAME_LENGTH] = { 0 }; utf8_to_nativestr(path, filepath, UTOX_FILE_NAME_LENGTH * 2); OPENFILENAMEW ofn = { .lStructSize = sizeof(OPENFILENAMEW), .lpstrFilter = L".txt", .lpstrFile = filepath, .nMaxFile = UTOX_FILE_NAME_LENGTH, .Flags = OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT, .lpstrDefExt = L"txt", }; if (GetSaveFileNameW(&ofn)) { path = calloc(1, UTOX_FILE_NAME_LENGTH); if (!path) { LOG_ERR("Windows", "Could not allocate memory."); return; } native_to_utf8str(filepath, path, UTOX_FILE_NAME_LENGTH); FILE *file = utox_get_file_simple(path, UTOX_FILE_OPTS_WRITE); if (file) { utox_export_chatlog(f->id_str, file); } else { LOG_ERR("Windows", "Opening file %s failed.", path); } } else { LOG_ERR("Windows", "Unable to open file and export chatlog."); } free(path); } void native_select_dir_ft(uint32_t fid, uint32_t num, FILE_TRANSFER *file) { if (!sanitize_filename(file->name)) { LOG_ERR("Windows", "Filename is invalid and could not be sanitized."); return; } wchar_t filepath[UTOX_FILE_NAME_LENGTH] = { 0 }; utf8_to_nativestr((char *)file->name, filepath, file->name_length * 2); OPENFILENAMEW ofn = { .lStructSize = sizeof(OPENFILENAMEW), .lpstrFile = filepath, .nMaxFile = UTOX_FILE_NAME_LENGTH, .Flags = OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT, }; if (GetSaveFileNameW(&ofn)) { char *path = calloc(1, UTOX_FILE_NAME_LENGTH); if (!path) { LOG_ERR("Windows", "Could not allocate memory for path."); return; } native_to_utf8str(filepath, path, UTOX_FILE_NAME_LENGTH * 2); postmessage_toxcore(TOX_FILE_ACCEPT, fid, num, path); } else { LOG_ERR("Windows", "Unable to Get save file for incoming FT."); } } void native_autoselect_dir_ft(uint32_t fid, FILE_TRANSFER *file) { wchar_t *autoaccept_folder = NULL; if (settings.portable_mode) { autoaccept_folder = calloc(1, UTOX_FILE_NAME_LENGTH * sizeof(wchar_t)); utf8_to_nativestr(portable_mode_save_path, autoaccept_folder, strlen(portable_mode_save_path) * 2); } else if (SHGetKnownFolderPath((REFKNOWNFOLDERID)&FOLDERID_Downloads, KF_FLAG_CREATE, NULL, &autoaccept_folder) != S_OK) { LOG_ERR("Windows", "Unable to get auto accept file folder."); return; } wchar_t subpath[UTOX_FILE_NAME_LENGTH] = { 0 }; swprintf(subpath, UTOX_FILE_NAME_LENGTH, L"%ls%ls", autoaccept_folder, L"\\Tox_Auto_Accept"); if (settings.portable_mode) { free(autoaccept_folder); } else { CoTaskMemFree(autoaccept_folder); } CreateDirectoryW(subpath, NULL); if (!sanitize_filename(file->name)) { LOG_ERR("Windows", "Filename is invalid and could not be sanitized."); return; } wchar_t filename[UTOX_FILE_NAME_LENGTH] = { 0 }; utf8_to_nativestr((char *)file->name, filename, file->name_length * 2); wchar_t fullpath[UTOX_FILE_NAME_LENGTH] = { 0 }; swprintf(fullpath, UTOX_FILE_NAME_LENGTH, L"%ls\\%ls", subpath, filename); char *path = calloc(1, UTOX_FILE_NAME_LENGTH); if (!path) { LOG_ERR("Windows", "Could not allocate memory for path."); return; } native_to_utf8str(fullpath, path, UTOX_FILE_NAME_LENGTH); postmessage_toxcore(TOX_FILE_ACCEPT_AUTO, fid, file->file_number, path); } void launch_at_startup(bool should) { const wchar_t *run_key_path = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run"; if (should) { HKEY hKey; if (RegOpenKeyW(HKEY_CURRENT_USER, run_key_path, &hKey) == ERROR_SUCCESS) { wchar_t path[UTOX_FILE_NAME_LENGTH * 2]; uint16_t path_length = GetModuleFileNameW(NULL, path + 1, UTOX_FILE_NAME_LENGTH * 2); path[0] = '\"'; path[path_length + 1] = '\"'; path[path_length + 2] = '\0'; path_length += 2; // 2 bytes per wchar_t uint16_t ret = RegSetKeyValueW(hKey, NULL, L"uTox", REG_SZ, path, path_length * 2); if (ret == ERROR_SUCCESS) { LOG_INFO("Windows", "Set uTox to run at startup."); } else { LOG_ERR("Windows", "Unable to set Registry key for startup."); } RegCloseKey(hKey); } } else { HKEY hKey; if (ERROR_SUCCESS == RegOpenKeyW(HKEY_CURRENT_USER, run_key_path, &hKey)) { uint16_t ret = RegDeleteKeyValueW(hKey, NULL, L"uTox"); if (ret == ERROR_SUCCESS) { LOG_INFO("Windows", "Set uTox to not run at startup."); } else { LOG_ERR("Windows", "Unable to delete Registry key for startup."); } RegCloseKey(hKey); } } } /** Open system file browser dialog */ void openfilesend(void) { wchar_t dir[UTOX_FILE_NAME_LENGTH]; GetCurrentDirectoryW(COUNTOF(dir), dir); wchar_t filepath[UTOX_FILE_NAME_LENGTH] = { 0 }; OPENFILENAMEW ofn = { .lStructSize = sizeof(OPENFILENAMEW), .hwndOwner = main_window.window, .lpstrFile = filepath, .nMaxFile = UTOX_FILE_NAME_LENGTH, .Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST, }; if (GetOpenFileNameW(&ofn)) { FRIEND *f = flist_get_sel_friend(); if (!f) { LOG_ERR("Windows", "Unable to get friend for file send msg."); return; } UTOX_MSG_FT *msg = calloc(1, sizeof(UTOX_MSG_FT)); if (!msg) { LOG_ERR("Windows", "Unable to calloc for file send msg."); return; } char *path = calloc(1, UTOX_FILE_NAME_LENGTH); if (!path) { LOG_ERR("Windows", "Could not allocate memory for path."); return; } native_to_utf8str(filepath, path, UTOX_FILE_NAME_LENGTH); msg->file = utox_get_file_simple(path, UTOX_FILE_OPTS_READ); msg->name = (uint8_t *)path; postmessage_toxcore(TOX_FILE_SEND_NEW, f->number, 0, msg); } else { LOG_ERR("Windows", "GetOpenFileName() failed."); } SetCurrentDirectoryW(dir); } void show_messagebox(const char *caption, uint16_t caption_length, const char *message, uint16_t message_length) { wchar_t message_native[message_length]; memset(message_native, 0, message_length); utf8_to_nativestr(message, message_native, message_length * 2); wchar_t caption_native[caption_length]; memset(caption_native, 0, caption_length); utf8_to_nativestr(caption, caption_native, caption_length * 2); MessageBoxW(NULL, message ? message_native : NULL, caption ? caption_native : NULL, MB_ICONWARNING); } void openfileavatar(void) { char *filepath = calloc(1, UTOX_FILE_NAME_LENGTH); if (!filepath) { LOG_ERR("Windows", "Could not allocate memory for path."); return; } wchar_t dir[UTOX_FILE_NAME_LENGTH]; GetCurrentDirectoryW(COUNTOF(dir), dir); OPENFILENAME ofn = { .lStructSize = sizeof(OPENFILENAME), .lpstrFilter = "Supported Images\0*.GIF;*.PNG;*.JPG;*.JPEG" // TODO: add all the supported types. "All Files\0*.*\0" "GIF Files\0*.GIF\0" "PNG Files\0*.PNG\0" "JPG Files\0*.JPG;*.JPEG\0" "\0", .hwndOwner = main_window.window, .lpstrFile = filepath, .nMaxFile = UTOX_FILE_NAME_LENGTH, .Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST, }; while (1) { // loop until we have a good file or the user closed the dialog if (!GetOpenFileName(&ofn)) { LOG_TRACE("Windows", "GetOpenFileName() failed when trying to grab an avatar."); break; } int width, height, bpp, size; uint8_t *file_data = stbi_load(filepath, &width, &height, &bpp, 0); uint8_t *img = stbi_write_png_to_mem(file_data, 0, width, height, bpp, &size); free(file_data); if (!img) { MessageBox(NULL, (const char *)S(CANT_FIND_FILE_OR_EMPTY), NULL, MB_ICONWARNING); continue; } if (size > UTOX_AVATAR_MAX_DATA_LENGTH) { free(img); char message[1024]; if (sizeof(message) < (unsigned)SLEN(AVATAR_TOO_LARGE_MAX_SIZE_IS) + 16) { LOG_ERR("Windows", "AVATAR_TOO_LARGE message is larger than allocated buffer(%llu bytes)\n", sizeof(message)); break; } // create message containing text that selected avatar is too large and what the max size is int len = sprintf(message, "%.*s", SLEN(AVATAR_TOO_LARGE_MAX_SIZE_IS), S(AVATAR_TOO_LARGE_MAX_SIZE_IS)); len += sprint_humanread_bytes(message + len, sizeof(message) - len, UTOX_AVATAR_MAX_DATA_LENGTH); message[len++] = '\0'; MessageBox(NULL, message, NULL, MB_ICONWARNING); continue; } postmessage_utox(SELF_AVATAR_SET, size, 0, img); break; } free(filepath); SetCurrentDirectoryW(dir); } void file_save_inline_image_png(MSG_HEADER *msg) { wchar_t filepath[UTOX_FILE_NAME_LENGTH] = { 0 }; utf8_to_nativestr((char *)msg->via.ft.name, filepath, msg->via.ft.name_length * 2); OPENFILENAMEW ofn = { .lStructSize = sizeof(OPENFILENAMEW), .hwndOwner = main_window.window, .lpstrFile = filepath, .nMaxFile = UTOX_FILE_NAME_LENGTH, .lpstrDefExt = L"png", .lpstrFilter = L"PNG Files\0*.png\0", .Flags = OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST, }; if (GetSaveFileNameW(&ofn)) { char *path = calloc(1, UTOX_FILE_NAME_LENGTH); if (!path) { LOG_ERR("Windows", "Could not allocate memory for path."); return; } native_to_utf8str(filepath, path, UTOX_FILE_NAME_LENGTH); FILE *file = utox_get_file_simple(path, UTOX_FILE_OPTS_WRITE); if (file) { fwrite(msg->via.ft.data, msg->via.ft.data_size, 1, file); fclose(file); msg->via.ft.path = calloc(1, UTOX_FILE_NAME_LENGTH); if (!msg->via.ft.path) { LOG_ERR("Windows", "Could not allocate memory for path."); free(path); return; } msg->via.ft.path = (uint8_t *)strdup(path); msg->via.ft.name = basename(strdup(path)); msg->via.ft.name_length = strlen((char *)msg->via.ft.name); msg->via.ft.inline_png = false; } else { LOG_ERR("Windows", "file_save_inline_image_png:\tCouldn't open path: `%s` to save inline file.", path); } free(path); } else { LOG_ERR("Windows", "GetSaveFileName() failed"); } } bool native_save_image_png(const char *name, const uint8_t *image, const int image_size) { wchar_t filepath[UTOX_FILE_NAME_LENGTH] = { 0 }; size_t length = strlen(name); utf8_to_nativestr(name, filepath, length * 2); OPENFILENAMEW ofn = { .lStructSize = sizeof(OPENFILENAMEW), .hwndOwner = main_window.window, .lpstrFile = filepath, .nMaxFile = UTOX_FILE_NAME_LENGTH, .lpstrDefExt = L"png", .lpstrFilter = L"PNG Files\0*.png\0", .Flags = OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST, }; if (GetSaveFileNameW(&ofn)) { char *path = calloc(1, UTOX_FILE_NAME_LENGTH); if (!path) { LOG_ERR("Windows", "Could not allocate memory for path."); return false; } native_to_utf8str(filepath, path, UTOX_FILE_NAME_LENGTH); FILE *file = utox_get_file_simple(path, UTOX_FILE_OPTS_WRITE); if (!file) { LOG_ERR("Windows", "Could not open file %s for write.", path); free(path); return false; } fwrite(image, image_size, 1, file); fclose(file); free(path); return true; } return false; } void postmessage_utox(UTOX_MSG msg, uint16_t param1, uint16_t param2, void *data) { PostMessage(main_window.window, WM_TOX + (msg), ((param1) << 16) | (param2), (LPARAM)data); } void init_ptt(void) { settings.push_to_talk = true; } bool check_ptt_key(void) { if (!settings.push_to_talk) { // PTT is disabled. Always send audio. return true; } if (GetAsyncKeyState(VK_LCONTROL)) { return true; } return false; } void exit_ptt(void) { settings.push_to_talk = false; } void thread(void func(void *), void *args) { _beginthread(func, 0, args); } void yieldcpu(uint32_t ms) { Sleep(ms); } uint64_t get_time(void) { return ((uint64_t)clock() * 1000 * 1000); } void setselection(char *UNUSED(data), uint16_t UNUSED(length)) { // TODO: Implement. } void copy(int value) { const uint32_t max_size = UINT16_MAX + 1; char data[max_size]; //! TODO: De-hardcode this value. memset(data, 0, sizeof(data)); int len = 0; if (edit_active()) { len = edit_copy(data, max_size - 1); data[len] = 0; } else if (flist_get_sel_friend()) { len = messages_selection(&messages_friend, data, max_size, value); } else if (flist_get_sel_group()) { len = messages_selection(&messages_group, data, max_size, value); } else { return; } HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * 2); wchar_t *d = GlobalLock(hMem); utf8tonative(data, d, len + 1); // because data is nullterminated GlobalUnlock(hMem); OpenClipboard(main_window.window); EmptyClipboard(); SetClipboardData(CF_UNICODETEXT, hMem); CloseClipboard(); } /* TODO DRY, this exists in screen_grab.c */ static NATIVE_IMAGE *create_utox_image(HBITMAP bmp, bool has_alpha, uint32_t width, uint32_t height) { NATIVE_IMAGE *image = calloc(1, sizeof(NATIVE_IMAGE)); if (!image) { LOG_ERR("Windows", "Could not allocate memory for image."); return NULL; } image->bitmap = bmp; image->has_alpha = has_alpha; image->width = width; image->height = height; image->scaled_width = width; image->scaled_height = height; image->stretch_mode = COLORONCOLOR; return image; } /* TODO DRY, this exists in screen_grab.c */ static void sendbitmap(HDC mem, HBITMAP hbm, int width, int height) { if (width == 0 || height == 0) { return; } BITMAPINFO info = { .bmiHeader = { .biSize = sizeof(BITMAPINFOHEADER), .biWidth = width, .biHeight = -(int)height, .biPlanes = 1, .biBitCount = 24, .biCompression = BI_RGB, } }; void *bits = calloc(1, (width + 3) * height * 3); GetDIBits(mem, hbm, 0, height, bits, &info, DIB_RGB_COLORS); uint8_t pbytes = width & 3; uint8_t *p = bits; uint8_t *pp = bits; uint8_t *end = p + width * height * 3; while (p != end) { for (int i = 0; i != width; i++) { uint8_t b = pp[i * 3]; p[i * 3] = pp[i * 3 + 2]; p[i * 3 + 1] = pp[i * 3 + 1]; p[i * 3 + 2] = b; } p += width * 3; pp += width * 3 + pbytes; } int size = 0; UTOX_IMAGE out = stbi_write_png_to_mem(bits, 0, width, height, 3, &size); free(bits); NATIVE_IMAGE *image = create_utox_image(hbm, 0, width, height); friend_sendimage(flist_get_sel_friend(), image, width, height, out, size); } void paste(void) { OpenClipboard(NULL); HANDLE h = GetClipboardData(CF_UNICODETEXT); if (!h) { h = GetClipboardData(CF_BITMAP); if (h && flist_get_sel_friend()) { FRIEND *f = flist_get_sel_friend(); if (!f->online) { return; } BITMAP bm; GetObject(h, sizeof(bm), &bm); HDC tempdc = CreateCompatibleDC(NULL); SelectObject(tempdc, h); HBITMAP copy = CreateCompatibleBitmap(main_window.mem_DC, bm.bmWidth, bm.bmHeight); SelectObject(main_window.mem_DC, copy); BitBlt(main_window.mem_DC, 0, 0, bm.bmWidth, bm.bmHeight, tempdc, 0, 0, SRCCOPY); sendbitmap(main_window.mem_DC, copy, bm.bmWidth, bm.bmHeight); DeleteDC(tempdc); } } else { wchar_t *d = GlobalLock(h); char data[65536]; // TODO: De-hardcode this value. int len = WideCharToMultiByte(CP_UTF8, 0, d, -1, data, sizeof(data), NULL, NULL); if (edit_active()) { edit_paste(data, len, false); } } GlobalUnlock(h); CloseClipboard(); } NATIVE_IMAGE *utox_image_to_native(const UTOX_IMAGE data, size_t size, uint16_t *w, uint16_t *h, bool keep_alpha) { int width, height, bpp; uint8_t *rgba_data = stbi_load_from_memory(data, size, &width, &height, &bpp, 4); if (rgba_data == NULL || width == 0 || height == 0) { return NULL; // invalid image } BITMAPINFO bmi = { .bmiHeader = { .biSize = sizeof(BITMAPINFOHEADER), .biWidth = width, .biHeight = -height, .biPlanes = 1, .biBitCount = 32, .biCompression = BI_RGB, } }; // create device independent bitmap, we can write the bytes to out // to put them in the bitmap uint8_t *out; HBITMAP bmp = CreateDIBSection(main_window.mem_DC, &bmi, DIB_RGB_COLORS, (void **)&out, NULL, 0); // convert RGBA data to internal format // pre-applying the alpha if we're keeping the alpha channel, // put the result in out // NOTE: input pixels are in format RGBA, output is BGRA uint8_t *p, *end = rgba_data + width * height * 4; p = rgba_data; if (keep_alpha) { uint8_t alpha; do { alpha = p[3]; out[0] = p[2] * (alpha / 255.0); // pre-apply alpha out[1] = p[1] * (alpha / 255.0); out[2] = p[0] * (alpha / 255.0); out[3] = alpha; out += 4; p += 4; } while (p != end); } else { do { out[0] = p[2]; out[1] = p[1]; out[2] = p[0]; out[3] = 0; out += 4; p += 4; } while (p != end); } free(rgba_data); NATIVE_IMAGE *image = create_utox_image(bmp, keep_alpha, width, height); *w = width; *h = height; return image; } void image_free(NATIVE_IMAGE *image) { if (!image) { return; } DeleteObject(image->bitmap); free(image); } void flush_file(FILE *file) { fflush(file); int fd = _fileno(file); _commit(fd); } int ch_mod(uint8_t *UNUSED(file)) { /* You're probably looking for ./xlib as windows is lamesauce and wants nothing to do with sane permissions */ return true; } int file_lock(FILE *file, uint64_t start, size_t length) { OVERLAPPED lock_overlap; lock_overlap.Offset = start; lock_overlap.OffsetHigh = start + length; lock_overlap.hEvent = 0; return !LockFileEx(file, LOCKFILE_FAIL_IMMEDIATELY, 0, start, start + length, &lock_overlap); } int file_unlock(FILE *file, uint64_t start, size_t length) { OVERLAPPED lock_overlap; lock_overlap.Offset = start; lock_overlap.OffsetHigh = start + length; lock_overlap.hEvent = 0; return UnlockFileEx(file, 0, start, start + length, &lock_overlap); } void showkeyboard(bool UNUSED(show)) {} /* Added for android support. */ void edit_will_deactivate(void) {} /* Redraws the main UI window */ void redraw(void) { native_window_set_target(&main_window); SelectObject(main_window.draw_DC, main_window.draw_BM); panel_draw(&panel_root, 0, 0, settings.window_width, settings.window_height); } /** * update_tray(void) * creates a win32 NOTIFYICONDATAW struct, sets the tiptab flag, gives *hwnd, * sets struct .cbSize, and resets the tibtab to native self.name; */ void update_tray(void) { uint16_t length = self.name_length + sizeof(" : ") + self.statusmsg_length; char tip[length]; memset(tip, 0, length); length = snprintf(tip, length, "%.*s : %.*s", self.name_length, self.name, self.statusmsg_length, self.statusmsg); NOTIFYICONDATAW nid = { .uFlags = NIF_TIP, .hWnd = main_window.window, .cbSize = sizeof(nid), }; uint16_t msg_len = safe_shrink(tip, length, MAX_TIP_LENGTH); utf8_to_nativestr(tip, nid.szTip, msg_len); Shell_NotifyIconW(NIM_MODIFY, &nid); } void force_redraw(void) { redraw(); } void openurl(char *str) { if (try_open_tox_uri(str)) { redraw(); return; } wchar_t url[UTOX_FILE_NAME_LENGTH] = { 0 }; utf8tonative(str, url, UTOX_FILE_NAME_LENGTH); ShellExecuteW(NULL, L"open", url, NULL, NULL, SW_SHOW); } void freefonts() { for (size_t i = 0; i != COUNTOF(font); i++) { if (font[i]) { DeleteObject(font[i]); } } } void loadfonts() { LOGFONT lf = { .lfWeight = FW_NORMAL, //.lfCharSet = ANSI_CHARSET, .lfOutPrecision = OUT_TT_PRECIS, .lfQuality = DEFAULT_QUALITY, .lfFaceName = "DejaVu Sans", }; lf.lfHeight = (SCALE(-24) - 1) / 2; font[FONT_TEXT] = CreateFontIndirect(&lf); lf.lfHeight = (SCALE(-22) - 1) / 2; font[FONT_STATUS] = CreateFontIndirect(&lf); lf.lfHeight = (SCALE(-24) - 1) / 2; font[FONT_LIST_NAME] = CreateFontIndirect(&lf); lf.lfWeight = FW_BOLD; font[FONT_TITLE] = CreateFontIndirect(&lf); lf.lfHeight = (SCALE(-28) - 1) / 2; font[FONT_SELF_NAME] = CreateFontIndirect(&lf); lf.lfHeight = (SCALE(-20) - 1) / 2; font[FONT_MISC] = CreateFontIndirect(&lf); /*lf.lfWeight = FW_NORMAL; //FW_LIGHT <- light fonts don't antialias font[FONT_MSG_NAME] = CreateFontIndirect(&lf); lf.lfHeight = F(11); font[FONT_MSG] = CreateFontIndirect(&lf); lf.lfUnderline = 1; font[FONT_MSG_LINK] = CreateFontIndirect(&lf);*/ SelectObject(main_window.draw_DC, font[FONT_TEXT]); TEXTMETRIC tm; GetTextMetrics(main_window.draw_DC, &tm); font_small_lineheight = tm.tmHeight + tm.tmExternalLeading; // SelectObject(main_window.draw_DC, font[FONT_MSG]); // GetTextMetrics(main_window.draw_DC, &tm); // font_msg_lineheight = tm.tmHeight + tm.tmExternalLeading; } void setscale_fonts(void) { freefonts(); loadfonts(); } void setscale(void) { svg_draw(1); } /* * CommandLineToArgvA implementation since CommandLineToArgvA doesn't exist in win32 api * Limitation: nested quotation marks are not handled * Credit: http://alter.org.ua/docs/win/args */ static PCHAR *CommandLineToArgvA(PCHAR CmdLine, int *_argc) { ULONG len = strlen(CmdLine); ULONG i = ((len + 2) / 2) * sizeof(PVOID) + sizeof(PVOID); PCHAR *argv = (PCHAR *)GlobalAlloc(GMEM_FIXED, i + (len + 2) * sizeof(CHAR)); PCHAR _argv = (PCHAR)(((PUCHAR)argv) + i); ULONG argc = 0; argv[argc] = _argv; i = 0; BOOLEAN in_QM = FALSE; BOOLEAN in_TEXT = FALSE; BOOLEAN in_SPACE = TRUE; CHAR a; ULONG j = 0; while ((a = CmdLine[i])) { if (in_QM) { if (a == '\"') { in_QM = FALSE; } else { _argv[j] = a; j++; } } else { switch (a) { case '\"': in_QM = TRUE; in_TEXT = TRUE; if (in_SPACE) { argv[argc] = _argv + j; argc++; } in_SPACE = FALSE; break; case ' ': case '\t': case '\n': case '\r': if (in_TEXT) { _argv[j] = '\0'; j++; } in_TEXT = FALSE; in_SPACE = TRUE; break; default: in_TEXT = TRUE; if (in_SPACE) { argv[argc] = _argv + j; argc++; } _argv[j] = a; j++; in_SPACE = FALSE; break; } } i++; } _argv[j] = '\0'; argv[argc] = NULL; (*_argc) = argc; return argv; } void tray_icon_init(HWND parent, HICON icon) { NOTIFYICONDATA nid = { .uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP, .uCallbackMessage = WM_NOTIFYICON, .hIcon = icon, .szTip = "uTox default tooltip", .hWnd = parent, .cbSize = sizeof(nid), }; Shell_NotifyIcon(NIM_ADD, &nid); } static void tray_icon_decon(HWND parent) { NOTIFYICONDATA nid = { .hWnd = parent, .cbSize = sizeof(nid), }; Shell_NotifyIcon(NIM_DELETE, &nid); } static void cursors_init(void) { cursors[CURSOR_NONE] = LoadCursor(NULL, IDC_ARROW); cursors[CURSOR_HAND] = LoadCursor(NULL, IDC_HAND); cursors[CURSOR_TEXT] = LoadCursor(NULL, IDC_IBEAM); cursors[CURSOR_SELECT] = LoadCursor(NULL, IDC_CROSS); cursors[CURSOR_ZOOM_IN] = LoadCursor(NULL, IDC_SIZEALL); cursors[CURSOR_ZOOM_OUT] = LoadCursor(NULL, IDC_SIZEALL); } static bool win_init_mutex(HANDLE *mutex, HINSTANCE hInstance, PSTR cmd, const char *instance_id) { *mutex = CreateMutex(NULL, false, instance_id); if (!mutex) { LOG_FATAL_ERR(-4, "Win Mutex", "Unable to create windows mutex."); } if (GetLastError() == ERROR_ALREADY_EXISTS) { HWND window = FindWindow(TITLE, NULL); if (window) { COPYDATASTRUCT data = { .cbData = strlen(cmd), .lpData = cmd }; SendMessage(window, WM_COPYDATA, (WPARAM)hInstance, (LPARAM)&data); LOG_FATAL_ERR(-3, "Win Mutex", "Message sent."); } LOG_FATAL_ERR(-3, "Win Mutex", "Error getting mutex or window."); } return true; } /** client main() * * Main thread * generates settings, loads settings from save file, generates main UI, starts * tox, generates tray icon, handles client messages. Cleans up, and exits. * * also handles call from other apps. */ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE UNUSED(hPrevInstance), PSTR cmd, int nCmdShow) { pthread_mutex_init(&messages_lock, NULL); int argc; PCHAR *argv = CommandLineToArgvA(GetCommandLineA(), &argc); if (!argv) { printf("Init error -- CommandLineToArgvA failed."); return -5; } int8_t should_launch_at_startup, set_show_window; parse_args(argc, argv, &should_launch_at_startup, &set_show_window, NULL); GlobalFree(argv); char instance_id[MAX_PATH]; if (settings.portable_mode == true) { /* force the working directory if opened with portable command */ const HMODULE hModule = GetModuleHandle(NULL); GetModuleFileName(hModule, instance_id, MAX_PATH); char *utox_path = strdup(instance_id); char *utox_folder = dirname(utox_path); SetCurrentDirectory(utox_folder); strcpy(portable_mode_save_path, utox_folder); free(utox_path); sanitize_filename((uint8_t *)instance_id); } else { strcpy(instance_id, TITLE); } // We call utox_init after parse_args() utox_init(); LOG_WARN("WinMain", "Normal windows build"); #ifdef GIT_VERSION LOG_NOTE("WinMain", "uTox version %s \n", GIT_VERSION); #endif /* if opened with argument, check if uTox is already open and pass the argument to the existing process */ HANDLE utox_mutex; win_init_mutex(&utox_mutex, hInstance, cmd, instance_id); if (should_launch_at_startup == 1) { launch_at_startup(1); } else if (should_launch_at_startup == -1) { launch_at_startup(0); } cursors_init(); native_window_init(hInstance); // Needed to generate the Windows window class we use. screen_grab_init(hInstance); OleInitialize(NULL); theme_load(settings.theme); settings.window_width = MAX((uint32_t)SCALE(MAIN_WIDTH), settings.window_width); settings.window_height = MAX((uint32_t)SCALE(MAIN_HEIGHT), settings.window_height); char pretitle[128]; snprintf(pretitle, 128, "%s %s (version : %s)", TITLE, SUB_TITLE, VERSION); size_t title_size = strlen(pretitle) + 1; wchar_t title[title_size]; mbstowcs(title, pretitle, title_size); native_window_create_main(settings.window_x, settings.window_y, settings.window_width, settings.window_height); native_notify_init(hInstance); hdc_brush = GetStockObject(DC_BRUSH); tray_icon_init(main_window.window, LoadIcon(hInstance, MAKEINTRESOURCE(101))); SetBkMode(main_window.draw_DC, TRANSPARENT); dnd_init(main_window.window); // start tox thread (main_window.window needs to be set first) thread(toxcore_thread, NULL); // wait for tox_thread init while (!tox_thread_init && !settings.save_encryption) { yieldcpu(1); } if (*cmd) { const int len = strlen(cmd); do_tox_url((uint8_t *)cmd, len); } redraw(); update_tray(); /* From --set flag */ if (set_show_window) { if (set_show_window == 1) { settings.start_in_tray = false; } else if (set_show_window == -1) { settings.start_in_tray = true; } } if (settings.start_in_tray) { ShowWindow(main_window.window, SW_HIDE); hidden = true; } else { ShowWindow(main_window.window, nCmdShow); } MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } RECT wndrect = { 0 }; GetWindowRect(main_window.window, &wndrect); settings.window_x = wndrect.left < 0 ? 0 : wndrect.left; settings.window_y = wndrect.top < 0 ? 0 : wndrect.top; settings.window_width = (wndrect.right - wndrect.left); settings.window_height = (wndrect.bottom - wndrect.top); config_save(); /* kill threads */ postmessage_utoxav(UTOXAV_KILL, 0, 0, NULL); postmessage_toxcore(TOX_KILL, 0, 0, NULL); /* cleanup */ tray_icon_decon(main_window.window); // wait for tox_thread to exit while (tox_thread_init) { yieldcpu(10); } // TODO: This should be a non-zero value determined by a message's wParam. return 0; } uTox/src/windows/filesys.c0000600000175000001440000002037614003056216014611 0ustar rakusers#include "main.h" #include "utf8.h" #include "../debug.h" #include "../filesys.h" #include "../settings.h" #include #include #include #include char *native_get_filepath(const char *name) { char *path = calloc(1, UTOX_FILE_NAME_LENGTH); if (!path) { LOG_ERR("WinFilesys", "Unable to allocate memory for file path."); return NULL; } if (settings.portable_mode) { strcpy(path, portable_mode_save_path); } else { if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path))) { if (FAILED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, path))) { strcpy(path, portable_mode_save_path); } } } snprintf(path + strlen(path), UTOX_FILE_NAME_LENGTH - strlen(path), "\\Tox\\"); if (strlen(path) + strlen(name) >= UTOX_FILE_NAME_LENGTH) { LOG_ERR("WinFilesys", "Load directory name too long"); free(path); return NULL; } snprintf(path + strlen(path), UTOX_FILE_NAME_LENGTH - strlen(path), "%s", name); return path; } static FILE* get_file(wchar_t path[UTOX_FILE_NAME_LENGTH], UTOX_FILE_OPTS opts) { // assert(UTOX_FILE_NAME_LENGTH <= (32,767 wide characters) ); DWORD rw = 0; char mode[4] = { 0 }; DWORD create = OPEN_EXISTING; if (opts & UTOX_FILE_OPTS_READ) { rw |= GENERIC_READ; mode[0] = 'r'; if (opts & UTOX_FILE_OPTS_WRITE || opts & UTOX_FILE_OPTS_APPEND) { rw |= GENERIC_WRITE; create = OPEN_ALWAYS; } } else if (opts & UTOX_FILE_OPTS_APPEND) { rw |= GENERIC_WRITE; mode[0] = 'a'; create = OPEN_ALWAYS; } else if (opts & UTOX_FILE_OPTS_WRITE) { rw |= GENERIC_WRITE; mode[0] = 'w'; create = CREATE_ALWAYS; } else { LOG_ERR("WinFilesys", "get_file called with invalid opts"); return NULL; } mode[1] = 'b'; if ((opts & (UTOX_FILE_OPTS_WRITE | UTOX_FILE_OPTS_APPEND)) && (opts & UTOX_FILE_OPTS_READ)) { mode[2] = '+'; } HANDLE WINAPI winFile = CreateFileW(path, rw, FILE_SHARE_READ, NULL, create, FILE_ATTRIBUTE_NORMAL, NULL); const int handle = _open_osfhandle((intptr_t)winFile, 0); if (handle == -1) { return NULL; } return _fdopen(handle, mode); } FILE *native_get_file_simple(const char *path, UTOX_FILE_OPTS opts) { //TODO: Check for forbidden opts (only read, write and append allowed) wchar_t wide_path[UTOX_FILE_NAME_LENGTH] = { 0 }; utf8_to_nativestr(path, wide_path, UTOX_FILE_NAME_LENGTH * 2); FILE *f = get_file(wide_path, opts); if (!f) { LOG_ERR("WinFilesys", "Could not open file: %s", path); return NULL; } return f; } FILE *native_get_file(const uint8_t *name, size_t *size, UTOX_FILE_OPTS opts, bool portable_mode) { char path[UTOX_FILE_NAME_LENGTH] = { 0 }; if (portable_mode) { strcpy(path, portable_mode_save_path); } else { if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path))) { if (FAILED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, path))) { strcpy(path, portable_mode_save_path); } } } if (opts > UTOX_FILE_OPTS_DELETE) { LOG_ERR("WinFilesys", "Don't call native_get_file with UTOX_FILE_OPTS_DELETE in combination with other options."); return NULL; } else if (opts & UTOX_FILE_OPTS_WRITE && opts & UTOX_FILE_OPTS_APPEND) { LOG_ERR("WinFilesys", "Don't call native_get_file with UTOX_FILE_OPTS_WRITE in combination with UTOX_FILE_OPTS_APPEND."); return NULL; } snprintf(path + strlen(path), UTOX_FILE_NAME_LENGTH - strlen(path), "/Tox/"); if (strlen(path) + strlen((char *)name) >= UTOX_FILE_NAME_LENGTH) { LOG_ERR("WinFilesys", "Load directory name too long"); return NULL; } char *tmp_path = _strdup((char *)name); // free() doesn't work if I touch this pointer at all, so.. char *path_pointer = tmp_path; // this pointer gets to hold the original location to free. if (!tmp_path) { LOG_FATAL_ERR(EXIT_MALLOC, "WinFilesys", "Unable to allocate memory for file path."); } // Append the subfolder to the path and remove it from the name. for (char *folder_divider = strstr(tmp_path, "/"); folder_divider != NULL; folder_divider = strstr(tmp_path, "/")) { ++folder_divider; // Skip over the / we're pointing to. snprintf(path + strlen(path), strlen(tmp_path) - strlen(folder_divider), tmp_path); char *new_path = tmp_path + strlen(tmp_path) - strlen(folder_divider); tmp_path = new_path; } if (opts & UTOX_FILE_OPTS_WRITE || opts & UTOX_FILE_OPTS_MKDIR) { if (!native_create_dir((uint8_t *)path)) { LOG_ERR("WinFilesys", "Failed to create path %s.", path); } } snprintf(path + strlen(path), UTOX_FILE_NAME_LENGTH - strlen(path), "%s", tmp_path); free(path_pointer); for (size_t i = 0; path[i] != '\0'; ++i) { if (path[i] == '/') { path[i] = '\\'; } } if (opts == UTOX_FILE_OPTS_DELETE) { if (!DeleteFile(path)) { LOG_ERR("WinFilesys", "Could not delete file: %s - Error: %d" , path, GetLastError()); } return NULL; } FILE *fp = native_get_file_simple(path, opts); if (!fp) { if (opts > UTOX_FILE_OPTS_READ) { LOG_NOTE("WinFilesys", "Could not open %s for writing.", path); } return NULL; } if (size && opts & UTOX_FILE_OPTS_READ) { fseek(fp, 0, SEEK_END); *size = ftell(fp); fseek(fp, 0, SEEK_SET); } return fp; } /** Try to create a path; * * Accepts null-terminated utf8 path. * Returns: true if folder exists, false otherwise * */ bool native_create_dir(const uint8_t *filepath) { // Maybe switch this to SHCreateDirectoryExW at some point. uint8_t path[UTOX_FILE_NAME_LENGTH] = { 0 }; strcpy((char *)path, (char *)filepath); for (size_t i = 0; path[i] != '\0'; ++i) { if (path[i] == '/') { path[i] = '\\'; } } const int error = SHCreateDirectoryEx(NULL, (char *)path, NULL); switch(error) { case ERROR_SUCCESS: LOG_NOTE("WinFilesys", "Created path: `%s` - %d" , filepath, error); // fallthrough case ERROR_FILE_EXISTS: case ERROR_ALREADY_EXISTS: return true; break; case ERROR_BAD_PATHNAME: LOG_WARN("WinFilesys", "Unable to create path: `%s` - bad path name." , filepath); return false; break; case ERROR_FILENAME_EXCED_RANGE: case ERROR_PATH_NOT_FOUND: case ERROR_CANCELLED: default: LOG_ERR("WinFilesys", "Unable to create path: `%s` - error %d" , filepath, error); return false; break; } } bool native_remove_file(const uint8_t *name, size_t length, bool portable_mode) { char path[UTOX_FILE_NAME_LENGTH] = { 0 }; if (portable_mode) { strcpy(path, portable_mode_save_path); } else { bool have_path = false; have_path = SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path)); if (!have_path) { have_path = SUCCEEDED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, path)); } if (!have_path) { strcpy(path, portable_mode_save_path); have_path = true; } } if (strlen(path) + length >= UTOX_FILE_NAME_LENGTH) { LOG_TRACE("WinFilesys", "File/directory name too long, unable to remove" ); return false; } else { snprintf(path + strlen(path), UTOX_FILE_NAME_LENGTH - strlen(path), "\\Tox\\%.*s", (int)length, (char *)name); } if (remove(path)) { LOG_ERR("WinFilesys", "Unable to delete file!\n\t\t%s" , path); return false; } else { LOG_INFO("WinFilesys", "File deleted!" ); LOG_TRACE("WinFilesys", "\t%s" , path); } return true; } bool native_move_file(const uint8_t *current_name, const uint8_t *new_name) { if (!current_name || !new_name) { return false; } return MoveFile((char *)current_name, (char *)new_name); } uTox/src/windows/example.reg0000600000175000001440000000124414003056216015112 0ustar rakusersWindows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\tox] @="URL:Tox Protocol" "URL Protocol"="" [HKEY_CLASSES_ROOT\tox\DefaultIcon] @="C:\\winTox\\bin\\winTox.exe,101" [HKEY_CLASSES_ROOT\tox\shell] [HKEY_CLASSES_ROOT\tox\shell\open] [HKEY_CLASSES_ROOT\tox\shell\open\command] @="C:\\winTox\\bin\\winTox.exe %1" uTox/src/windows/events.h0000600000175000001440000000023214003056216014431 0ustar rakusers#ifndef WIN_EVENTS_H #define WIN_EVENTS_H #include LRESULT CALLBACK WindowProc(HWND window, UINT msg, WPARAM wParam, LPARAM lParam); #endif uTox/src/windows/events.c0000600000175000001440000003456114003056216014440 0ustar rakusers#include "events.h" #include "main.h" #include "window.h" #include "../commands.h" #include "../debug.h" #include "../flist.h" #include "../friend.h" #include "../macros.h" #include "../self.h" #include "../settings.h" #include "../theme.h" #include "../tox.h" #include "../utox.h" #include "../av/utox_av.h" #include "../native/clipboard.h" #include "../native/keyboard.h" #include "../native/notify.h" #include "../native/ui.h" #include "../ui/dropdown.h" #include "../ui/edit.h" #include "../ui/svg.h" #include "../layout/background.h" #include "../layout/notify.h" #include "../layout/settings.h" #include #include "../main.h" // main_width static TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, 0, 0, }; static bool mouse_tracked = false; /** Toggles the main window to/from hidden to tray/shown. */ static void togglehide(int show) { if (hidden || show) { ShowWindow(main_window.window, SW_RESTORE); SetForegroundWindow(main_window.window); redraw(); hidden = false; } else { ShowWindow(main_window.window, SW_HIDE); hidden = true; } } /** Right click context menu for the tray icon */ static void ShowContextMenu(void) { POINT pt; GetCursorPos(&pt); HMENU hMenu = CreatePopupMenu(); if (hMenu) { InsertMenu(hMenu, -1, MF_BYPOSITION, TRAY_SHOWHIDE, hidden ? "Restore" : "Hide"); InsertMenu(hMenu, -1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); InsertMenu(hMenu, -1, MF_BYPOSITION | ((self.status == TOX_USER_STATUS_NONE) ? MF_CHECKED : 0), TRAY_STATUS_AVAILABLE, "Available"); InsertMenu(hMenu, -1, MF_BYPOSITION | ((self.status == TOX_USER_STATUS_AWAY) ? MF_CHECKED : 0), TRAY_STATUS_AWAY, "Away"); InsertMenu(hMenu, -1, MF_BYPOSITION | ((self.status == TOX_USER_STATUS_BUSY) ? MF_CHECKED : 0), TRAY_STATUS_BUSY, "Busy"); InsertMenu(hMenu, -1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); InsertMenu(hMenu, -1, MF_BYPOSITION, TRAY_EXIT, "Exit"); // note: must set window to the foreground or the // menu won't disappear when it should SetForegroundWindow(main_window.window); TrackPopupMenu(hMenu, TPM_BOTTOMALIGN, pt.x, pt.y, 0, main_window.window, NULL); DestroyMenu(hMenu); } } /* TODO should this be moved to window.c? */ static void move_window(int x, int y){ LOG_TRACE("Win events", "delta x == %i\n", x); LOG_TRACE("Win events", "delta y == %i\n", y); SetWindowPos(main_window.window, 0, main_window._.x + x, main_window._.y + y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOREDRAW); main_window._.x += x; main_window._.y += y; } #define setstatus(x) \ if (self.status != x) { \ postmessage_toxcore(TOX_SELF_SET_STATE, x, 0, NULL); \ self.status = x; \ redraw(); \ } /** Handles all callback requests from winmain(); * * handles the window functions internally, and ships off the tox calls to tox */ LRESULT CALLBACK WindowProc(HWND window, UINT msg, WPARAM wParam, LPARAM lParam) { static int mx, my; static bool mdown = false; static int mdown_x, mdown_y; static uint32_t taskbar_created; if (main_window.window && window != main_window.window) { if (msg == WM_DESTROY) { if (window == preview_hwnd) { if (settings.video_preview) { settings.video_preview = false; postmessage_utoxav(UTOXAV_STOP_VIDEO, UINT16_MAX, 0, NULL); } return false; } for (uint8_t i = 0; i < self.friend_list_count; i++) { if (video_hwnd[i] == window) { FRIEND *f = get_friend(i); postmessage_utoxav(UTOXAV_STOP_VIDEO, f->number, 0, NULL); break; } } } LOG_TRACE("WinEvent", "Uncaught event %u & %u", wParam, lParam); return DefWindowProcW(window, msg, wParam, lParam); } switch (msg) { case WM_QUIT: case WM_CLOSE: case WM_DESTROY: { if (settings.close_to_tray) { LOG_INFO("Events", "Closing to tray." ); togglehide(0); return true; } else { PostQuitMessage(0); return false; } } case WM_GETMINMAXINFO: { POINT min = { SCALE(MAIN_WIDTH), SCALE(MAIN_HEIGHT) }; ((MINMAXINFO *)lParam)->ptMinTrackSize = min; break; } case WM_CREATE: { LOG_INFO("Windows", "WM_CREATE"); taskbar_created = RegisterWindowMessage(TEXT("TaskbarCreated")); return false; } case WM_SIZE: { switch (wParam) { case SIZE_MAXIMIZED: { settings.window_maximized = true; break; } case SIZE_RESTORED: { settings.window_maximized = false; break; } } int w = GET_X_LPARAM(lParam); int h = GET_Y_LPARAM(lParam); if (w != 0) { RECT r; GetClientRect(window, &r); w = r.right; h = r.bottom; settings.window_width = w; settings.window_height = h; ui_rescale(dropdown_dpi.selected + 5); ui_size(w, h); if (main_window.draw_BM) { DeleteObject(main_window.draw_BM); } main_window.draw_BM = CreateCompatibleBitmap(main_window.window_DC, settings.window_width, settings.window_height); SelectObject(main_window.window_DC, main_window.draw_BM); redraw(); } break; } case WM_SETFOCUS: { if (flashing) { FlashWindow(main_window.window, false); flashing = false; NOTIFYICONDATAW nid = { .uFlags = NIF_ICON, .hWnd = main_window.window, .hIcon = black_icon, .cbSize = sizeof(nid), }; Shell_NotifyIconW(NIM_MODIFY, &nid); } have_focus = true; break; } case WM_KILLFOCUS: { have_focus = false; break; } case WM_ERASEBKGND: { return true; } case WM_PAINT: { PAINTSTRUCT ps; BeginPaint(window, &ps); RECT r = ps.rcPaint; BitBlt(main_window.window_DC, r.left, r.top, r.right - r.left, r.bottom - r.top, main_window.draw_DC, r.left, r.top, SRCCOPY); EndPaint(window, &ps); return false; } case WM_SYSKEYDOWN: // called instead of WM_KEYDOWN when ALT is down or F10 is pressed case WM_KEYDOWN: { bool control = (GetKeyState(VK_CONTROL) & 0x80) != 0; bool shift = (GetKeyState(VK_SHIFT) & 0x80) != 0; bool alt = (GetKeyState(VK_MENU) & 0x80) != 0; /* Be careful not to clobber alt+num symbols */ if (wParam >= VK_NUMPAD0 && wParam <= VK_NUMPAD9) { // normalize keypad and non-keypad numbers wParam = wParam - VK_NUMPAD0 + '0'; } if (control && wParam == 'C') { copy(0); return false; } if (control) { if ((wParam == VK_TAB && shift) || wParam == VK_PRIOR) { flist_previous_tab(); redraw(); return false; } else if (wParam == VK_TAB || wParam == VK_NEXT) { flist_next_tab(); redraw(); return false; } } if (control && !alt) { if (wParam >= '1' && wParam <= '9') { flist_selectchat(wParam - '1'); redraw(); return false; } else if (wParam == '0') { flist_selectchat(9); redraw(); return false; } } if (edit_active()) { if (control) { switch (wParam) { case 'V': paste(); return false; case 'X': copy(0); edit_char(KEY_DEL, 1, 0); return false; } } if (control || ((wParam < 'A' || wParam > 'Z') && wParam != VK_RETURN && wParam != VK_BACK)) { edit_char(wParam, 1, (control << 2) | shift); } } else { messages_char(wParam); redraw(); // TODO maybe if this break; } break; } case WM_CHAR: { if (edit_active()) { if (wParam == KEY_RETURN && (GetKeyState(VK_SHIFT) & 0x80)) { wParam = '\n'; } if (wParam != KEY_TAB) { edit_char(wParam, 0, 0); } } return false; } case WM_MOUSEWHEEL: { double delta = (double)GET_WHEEL_DELTA_WPARAM(wParam); mx = GET_X_LPARAM(lParam); my = GET_Y_LPARAM(lParam); panel_mwheel(&panel_root, mx, my, settings.window_width, settings.window_height, delta / (double)(WHEEL_DELTA), 1); return false; } case WM_MOUSEMOVE: { int x, y, dx, dy; x = GET_X_LPARAM(lParam); y = GET_Y_LPARAM(lParam); dx = x - mx; dy = y - my; mx = x; my = y; if (btn_move_window_down) { move_window(x - mdown_x, y - mdown_y); } cursor = 0; panel_mmove(&panel_root, 0, 0, settings.window_width, settings.window_height, x, y, dx, dy); SetCursor(cursors[cursor]); if (!mouse_tracked) { TrackMouseEvent(&tme); mouse_tracked = true; } return false; } case WM_LBUTTONDOWN: { mdown_x = GET_X_LPARAM(lParam); mdown_y = GET_Y_LPARAM(lParam); // Intentional fall through to save the original mdown location. } // fallthrough case WM_LBUTTONDBLCLK: { mdown = true; int x = GET_X_LPARAM(lParam); int y = GET_Y_LPARAM(lParam); if (x != mx || y != my) { panel_mmove(&panel_root, 0, 0, settings.window_width, settings.window_height, x, y, x - mx, y - my); mx = x; my = y; } // double redraw> panel_mdown(&panel_root); if (msg == WM_LBUTTONDBLCLK) { panel_dclick(&panel_root, 0); } SetCapture(window); break; } case WM_RBUTTONDOWN: { panel_mright(&panel_root); break; } case WM_RBUTTONUP: { break; } case WM_LBUTTONUP: { ReleaseCapture(); break; } case WM_CAPTURECHANGED: { if (mdown) { panel_mup(&panel_root); mdown = false; } break; } case WM_MOUSELEAVE: { ui_mouseleave(); mouse_tracked = false; btn_move_window_down = false; LOG_TRACE("Win events", "mouse leave\n"); break; } case WM_COMMAND: { int menu = LOWORD(wParam); //, msg = HIWORD(wParam); switch (menu) { case TRAY_SHOWHIDE: { togglehide(0); break; } case TRAY_EXIT: { PostQuitMessage(0); break; } case TRAY_STATUS_AVAILABLE: { setstatus(TOX_USER_STATUS_NONE); break; } case TRAY_STATUS_AWAY: { setstatus(TOX_USER_STATUS_AWAY); break; } case TRAY_STATUS_BUSY: { setstatus(TOX_USER_STATUS_BUSY); break; } } break; } case WM_NOTIFYICON: { int message = LOWORD(lParam); switch (message) { case WM_MOUSEMOVE: { break; } case WM_LBUTTONDOWN: { togglehide(0); break; } case WM_LBUTTONDBLCLK: { togglehide(1); break; } case WM_LBUTTONUP: { break; } case WM_RBUTTONDOWN: { break; } case WM_RBUTTONUP: case WM_CONTEXTMENU: { ShowContextMenu(); break; } } return false; } case WM_COPYDATA: { togglehide(1); SetForegroundWindow(window); COPYDATASTRUCT *data = (void *)lParam; if (data->lpData) { do_tox_url(data->lpData, data->cbData); } return false; } case WM_TOX ... WM_TOX + 128: { utox_message_dispatch(msg - WM_TOX, wParam >> 16, wParam, (void *)lParam); return false; } default: { if (msg == taskbar_created) { tray_icon_init(main_window.window, black_icon); } break; } } return DefWindowProcW(window, msg, wParam, lParam); } uTox/src/windows/drawing.c0000600000175000001440000002336514003056216014567 0ustar rakusers#include "main.h" #include "utf8.h" #include "window.h" #include "../debug.h" #include "../macros.h" #include "../native/image.h" #include "../ui/svg.h" UTOX_WINDOW *curr = NULL; void *bitmap[BM_ENDMARKER + 1]; BLENDFUNCTION blend_function = { .BlendOp = AC_SRC_OVER, .BlendFlags = 0, .SourceConstantAlpha = 0xFF, .AlphaFormat = AC_SRC_ALPHA }; void drawalpha(int bm, int x, int y, int width, int height, uint32_t color) { if (!bitmap[bm]) { return; } BITMAPINFO bmi = { .bmiHeader = { .biSize = sizeof(BITMAPINFOHEADER), .biWidth = width, .biHeight = -height, .biPlanes = 1, .biBitCount = 32, .biCompression = BI_RGB, } }; // create pointer to beginning and end of the alpha-channel-only bitmap uint8_t *alpha_pixel = bitmap[bm], *end = alpha_pixel + width * height; // create temporary bitmap we'll combine the alpha and colors on uint32_t *out_pixel; HBITMAP temp = CreateDIBSection(curr->mem_DC, &bmi, DIB_RGB_COLORS, (void **)&out_pixel, NULL, 0); SelectObject(curr->mem_DC, temp); // create pixels for the drawable bitmap based on the alpha value of // each pixel in the alpha bitmap and the color given by 'color', // the Win32 API requires we pre-apply our alpha channel as well by // doing (color * alpha / 255) for each color channel // NOTE: Input color is in the format 0BGR, output pixel is in the format BGRA while (alpha_pixel != end) { uint8_t alpha = *alpha_pixel++; *out_pixel++ = (((color & 0xFF) * alpha / 255) << 16) // red | ((((color >> 8) & 0xFF) * alpha / 255) << 8) // green | ((((color >> 16) & 0xFF) * alpha / 255) << 0) // blue | (alpha << 24); // alpha } // draw temporary bitmap on screen AlphaBlend(curr->draw_DC, x, y, width, height, curr->mem_DC, 0, 0, width, height, blend_function); // clean up DeleteObject(temp); } void image_set_filter(NATIVE_IMAGE *image, uint8_t filter) { switch (filter) { case FILTER_NEAREST: image->stretch_mode = COLORONCOLOR; break; case FILTER_BILINEAR: image->stretch_mode = HALFTONE; break; default: LOG_TRACE("Drawing", "Warning: Tried to set image to unrecognized filter(%u)." , filter); return; } } void image_set_scale(NATIVE_IMAGE *image, double img_scale) { image->scaled_width = (uint32_t)(((double)image->width * img_scale) + 0.5); image->scaled_height = (uint32_t)(((double)image->height * img_scale) + 0.5); } static bool image_is_stretched(const NATIVE_IMAGE *image) { return image->width != image->scaled_width || image->height != image->scaled_height; } // NOTE: This function is way more complicated than the XRender variant, because // the Win32 API is a lot more limited, so all scaling, clipping, and handling // transparency has to be done explicitly void draw_image(const NATIVE_IMAGE *image, int x, int y, uint32_t width, uint32_t height, uint32_t imgx, uint32_t imgy) { HDC drawdc; // device context we'll do the eventual drawing with HBITMAP tmp = NULL; // used when scaling if (!image_is_stretched(image)) { SelectObject(curr->mem_DC, image->bitmap); drawdc = curr->mem_DC; } else { // temporary device context for the scaling operation drawdc = CreateCompatibleDC(NULL); // set stretch mode from image SetStretchBltMode(drawdc, image->stretch_mode); // scaled bitmap will be drawn onto this bitmap tmp = CreateCompatibleBitmap(curr->mem_DC, image->scaled_width, image->scaled_height); SelectObject(drawdc, tmp); SelectObject(curr->mem_DC, image->bitmap); // stretch image onto temporary bitmap if (image->has_alpha) { AlphaBlend(drawdc, 0, 0, image->scaled_width, image->scaled_height, curr->mem_DC, 0, 0, image->width, image->height, blend_function); } else { StretchBlt(drawdc, 0, 0, image->scaled_width, image->scaled_height, curr->mem_DC, 0, 0, image->width, image->height, SRCCOPY); } } // clip and draw if (image->has_alpha) { AlphaBlend(curr->draw_DC, x, y, width, height, drawdc, imgx, imgy, width, height, blend_function); } else { BitBlt(curr->draw_DC, x, y, width, height, drawdc, imgx, imgy, SRCCOPY); } // clean up if (image_is_stretched(image)) { DeleteObject(tmp); DeleteDC(drawdc); } } void draw_inline_image(uint8_t *img_data, size_t UNUSED(size), uint16_t w, uint16_t h, int x, int y) { BITMAPINFO bmi = { .bmiHeader = { .biSize = sizeof(BITMAPINFOHEADER), .biWidth = w, .biHeight = -h, .biPlanes = 1, .biBitCount = 32, .biCompression = BI_RGB, } }; SetDIBitsToDevice(curr->draw_DC, x, y, w, h, 0, 0, 0, h, img_data, &bmi, DIB_RGB_COLORS); } void drawtext(int x, int y, const char *str, uint16_t length) { wchar_t out[length]; length = utf8tonative(str, out, length); TextOutW(curr->draw_DC, x, y, out, length); } int drawtext_getwidth(int x, int y, const char *str, uint16_t length) { wchar_t out[length]; length = utf8tonative(str, out, length); SIZE size; TextOutW(curr->draw_DC, x, y, out, length); GetTextExtentPoint32W(curr->draw_DC, out, length, &size); return size.cx; } void drawtextwidth(int x, int width, int y, const char *str, uint16_t length) { wchar_t out[length]; length = utf8tonative(str, out, length); RECT r = { x, y, x + width, y + 256 }; DrawTextW(curr->draw_DC, out, length, &r, DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX); } void drawtextwidth_right(int x, int width, int y, const char *str, uint16_t length) { wchar_t out[length]; length = utf8tonative(str, out, length); RECT r = { x, y, x + width, y + 256 }; DrawTextW(curr->draw_DC, out, length, &r, DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX | DT_RIGHT); } void drawtextrange(int x, int x2, int y, const char *str, uint16_t length) { wchar_t out[length]; length = utf8tonative(str, out, length); RECT r = { x, y, x2, y + 256 }; DrawTextW(curr->draw_DC, out, length, &r, DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX); } void drawtextrangecut(int x, int x2, int y, const char *str, uint16_t length) { wchar_t out[length]; length = utf8tonative(str, out, length); RECT r = { x, y, x2, y + 256 }; DrawTextW(curr->draw_DC, out, length, &r, DT_SINGLELINE | DT_NOPREFIX); } int textwidth(const char *str, uint16_t length) { wchar_t out[length]; length = utf8tonative(str, out, length); SIZE size; GetTextExtentPoint32W(curr->draw_DC, out, length, &size); return size.cx; } int textfit(const char *str, uint16_t len, int width) { wchar_t out[len]; int length = utf8tonative(str, out, len); int fit; SIZE size; GetTextExtentExPointW(curr->draw_DC, out, length, width, &fit, NULL, &size); return WideCharToMultiByte(CP_UTF8, 0, out, fit, (char *)str, len, NULL, 0); } int textfit_near(const char *str, uint16_t len, int width) { /*todo: near*/ wchar_t out[len]; int length = utf8tonative(str, out, len); int fit; SIZE size; GetTextExtentExPointW(curr->draw_DC, out, length, width, &fit, NULL, &size); return WideCharToMultiByte(CP_UTF8, 0, out, fit, (char *)str, len, NULL, 0); } void draw_rect_frame(int x, int y, int width, int height, uint32_t color) { RECT r = { x, y, x + width, y + height }; SetDCBrushColor(curr->draw_DC, color); FrameRect(curr->draw_DC, &r, hdc_brush); } void draw_rect_fill(int x, int y, int width, int height, uint32_t color) { RECT r = { x, y, x + width, y + height }; SetDCBrushColor(curr->draw_DC, color); FillRect(curr->draw_DC, &r, hdc_brush); } void drawrect(int x, int y, int right, int bottom, uint32_t color) { RECT r = { x, y, right, bottom }; SetDCBrushColor(curr->draw_DC, color); FillRect(curr->draw_DC, &r, hdc_brush); } void drawhline(int x, int y, int x2, uint32_t color) { RECT r = { x, y, x2, y + 1 }; SetDCBrushColor(curr->draw_DC, color); FillRect(curr->draw_DC, &r, hdc_brush); } void drawvline(int x, int y, int y2, uint32_t color) { RECT r = { x, y, x + 1, y2 }; SetDCBrushColor(curr->draw_DC, color); FillRect(curr->draw_DC, &r, hdc_brush); } void setfont(int id) { SelectObject(curr->draw_DC, font[id]); } uint32_t setcolor(uint32_t color) { return SetTextColor(curr->draw_DC, color); } RECT clip[16]; static int clipk; void pushclip(int left, int top, int width, int height) { int right = left + width, bottom = top + height; RECT *r = &clip[clipk++]; r->left = left; r->top = top; r->right = right; r->bottom = bottom; HRGN rgn = CreateRectRgn(left, top, right, bottom); SelectClipRgn(curr->draw_DC, rgn); DeleteObject(rgn); } void popclip(void) { clipk--; if (!clipk) { SelectClipRgn(curr->draw_DC, NULL); return; } RECT *r = &clip[clipk - 1]; HRGN rgn = CreateRectRgn(r->left, r->top, r->right, r->bottom); SelectClipRgn(curr->draw_DC, rgn); DeleteObject(rgn); } void enddraw(int x, int y, int width, int height) { SelectObject(curr->window_DC, curr->draw_BM); BitBlt(curr->window_DC, x, y, width, height, curr->draw_DC, x, y, SRCCOPY); } void loadalpha(int bm, void *data, int UNUSED(width), int UNUSED(height)) { bitmap[bm] = data; } bool native_window_set_target(UTOX_WINDOW *window) { if (curr != window) { curr = window; return true; } return false; } uTox/src/windows/dnd.c0000600000175000001440000000757114003056216013702 0ustar rakusers#include "main.h" #include "../filesys.h" #include "../file_transfers.h" #include "../flist.h" #include "../friend.h" #include "../debug.h" #include "../tox.h" #include "../macros.h" typedef struct { IDropTarget dt; LONG ref; } my_IDropTarget; ULONG __stdcall dnd_AddRef(IDropTarget *lpMyObj) { my_IDropTarget *p = (void*)lpMyObj; return InterlockedIncrement(&p->ref); } ULONG __stdcall dnd_Release(IDropTarget *lpMyObj) { my_IDropTarget *p = (void*)lpMyObj; LONG count = InterlockedDecrement(&p->ref); if (!count) { free(lpMyObj->lpVtbl); free(lpMyObj); } return count; } HRESULT __stdcall dnd_QueryInterface(IDropTarget *lpMyObj, REFIID riid, LPVOID FAR *lppvObj) { *lppvObj = NULL; // PRINT_GUID (riid); if (IsEqualIID (riid, &IID_IUnknown) || IsEqualIID (riid, &IID_IDropTarget)) { dnd_AddRef (lpMyObj); *lppvObj = lpMyObj; return S_OK; } return E_NOINTERFACE; } HRESULT __stdcall dnd_DragEnter(IDropTarget *UNUSED(lpMyObj), IDataObject *UNUSED(pDataObject), DWORD UNUSED(grfKeyState), POINTL UNUSED(pt), DWORD *pdwEffect) { *pdwEffect = DROPEFFECT_COPY; return S_OK; } HRESULT __stdcall dnd_DragOver(IDropTarget *UNUSED(lpMyObj), DWORD UNUSED(grfKeyState), POINTL UNUSED(pt), DWORD *pdwEffect) { *pdwEffect = DROPEFFECT_COPY; return S_OK; } HRESULT __stdcall dnd_DragLeave(IDropTarget *UNUSED(lpMyObj)) { return S_OK; } HRESULT __stdcall dnd_Drop(IDropTarget *UNUSED(lpMyObj), IDataObject *pDataObject, DWORD UNUSED(grfKeyState), POINTL UNUSED(pt), DWORD *pdwEffect) { *pdwEffect = DROPEFFECT_COPY; LOG_NOTE("DnD", "Dropped!" ); if (!flist_get_sel_friend()) { return S_OK; } FORMATETC format = { .cfFormat = CF_HDROP, .dwAspect = DVASPECT_CONTENT, .lindex = -1, .tymed = TYMED_HGLOBAL, }; STGMEDIUM medium; HRESULT r = pDataObject->lpVtbl->GetData(pDataObject, &format, &medium); if (r == S_OK) { HDROP h = medium.hGlobal; int count = DragQueryFile(h, ~0, NULL, 0); LOG_INFO("WINDND", "%u files dropped\n", count); for (int i = 0; i < count; i++) { LOG_NOTE("WINDND", "Sending file number %i", i); UTOX_MSG_FT *msg = calloc(1, sizeof(UTOX_MSG_FT)); if (!msg) { LOG_ERR("WINDND", "Unable to alloc for UTOX_MSG_FT"); return 0; } char *path = calloc(1, UTOX_FILE_NAME_LENGTH); if (!path) { LOG_ERR("WINDND", "Unable to alloc for UTOX_MSG_FT"); free(msg); return 0; } DragQueryFile(h, i, path, UTOX_FILE_NAME_LENGTH); msg->file = fopen(path, "rb"); if (!msg->file) { LOG_ERR("WINDND", "Unable to read file %s" , path); free(msg); free(path); return 0; } msg->name = (uint8_t *)path; postmessage_toxcore(TOX_FILE_SEND_NEW, flist_get_sel_friend()->number, 0, msg); LOG_INFO("WINDND", "File number %i sent!" , i); } ReleaseStgMedium(&medium); } else { LOG_ERR("WINDND", "itz failed! %lX", r); } return S_OK; } void dnd_init(HWND window) { my_IDropTarget *p; p = malloc(sizeof(my_IDropTarget)); p->dt.lpVtbl = malloc(sizeof(*(p->dt.lpVtbl))); p->ref = 0; p->dt.lpVtbl->QueryInterface = dnd_QueryInterface; p->dt.lpVtbl->AddRef = dnd_AddRef; p->dt.lpVtbl->Release = dnd_Release; p->dt.lpVtbl->DragEnter = dnd_DragEnter; p->dt.lpVtbl->DragLeave = dnd_DragLeave; p->dt.lpVtbl->DragOver = dnd_DragOver; p->dt.lpVtbl->Drop = dnd_Drop; CoLockObjectExternal((struct IUnknown*)p, TRUE, FALSE); RegisterDragDrop(window, (IDropTarget*)p); } uTox/src/windows/audio.c0000600000175000001440000001602114003056216014224 0ustar rakusers#include "main.h" #include "../debug.h" #include "../macros.h" #include #include #include #include #include #include // REFERENCE_TIME time units per second and per millisecond #define REFTIMES_PER_SEC 10000000 #define REFTIMES_PER_MILLISEC 10000 #define EXIT_ON_ERROR(hres) \ if (FAILED(hres)) { \ goto Exit; \ } #define SAFE_RELEASE(punk) \ if ((punk) != NULL) { \ (punk)->lpVtbl->Release(punk); \ (punk) = NULL; \ } IAudioClient * pAudioClient = NULL; IAudioCaptureClient *pCaptureClient = NULL; WAVEFORMATEX * pwfx = NULL; // const GUID IID_IMMDeviceEnumerator = {0xa95664d2, 0x9614, 0x4f35, {0xa7,0x46, 0xde,0x8d,0xb6,0x36,0x17,0xe6}}; // const CLSID CLSID_MMDeviceEnumerator = {0xbcde0395, 0xe52f, 0x467c, {0x8e,0x3d, 0xc4,0x57,0x92,0x91,0x69,0x2e}}; // const GUID IID_IAudioClient = {0x1cb9ad4c, 0xdbfa, 0x4c32, {0xb1,0x78, 0xc2,0xf5,0x68,0xa7,0x03,0xb2}}; // const GUID KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = {STATIC_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT}; // const GUID KSDATAFORMAT_SUBTYPE_PCM = {STATIC_KSDATAFORMAT_SUBTYPE_PCM}; const GUID IID_IAudioCaptureClient_utox = { 0xc8adbd64, 0xe71e, 0x48a0, { 0xa4, 0xde, 0x18, 0x5c, 0x39, 0x5c, 0xd3, 0x17 } }; /* note: only works when loopback is 48khz 2 channel floating*/ void audio_detect(void) { HRESULT hr; REFERENCE_TIME hnsRequestedDuration = REFTIMES_PER_SEC; // REFERENCE_TIME hnsActualDuration; UINT32 bufferFrameCount; IMMDeviceEnumerator *pEnumerator = NULL; IMMDevice * pDevice = NULL; IMMDeviceCollection *pDeviceCollection = NULL; // BOOL bDone = FALSE; UINT count; // HANDLE hEvent = NULL; CoInitialize(NULL); hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &IID_IMMDeviceEnumerator, (void **)&pEnumerator); EXIT_ON_ERROR(hr) hr = pEnumerator->lpVtbl->EnumAudioEndpoints(pEnumerator, eAll, DEVICE_STATE_ACTIVE, &pDeviceCollection); EXIT_ON_ERROR(hr) hr = pDeviceCollection->lpVtbl->GetCount(pDeviceCollection, &count); EXIT_ON_ERROR(hr) LOG_TRACE("Windows", "Audio out devices %u" , count); hr = pEnumerator->lpVtbl->GetDefaultAudioEndpoint(pEnumerator, eRender, eConsole, &pDevice); EXIT_ON_ERROR(hr) hr = pDevice->lpVtbl->Activate(pDevice, &IID_IAudioClient, CLSCTX_ALL, NULL, (void **)&pAudioClient); EXIT_ON_ERROR(hr) hr = pAudioClient->lpVtbl->GetMixFormat(pAudioClient, &pwfx); EXIT_ON_ERROR(hr) LOG_INFO("Windows Audio", "default audio format: %u %u %u %lu %lu %u %u\n", WAVE_FORMAT_PCM, pwfx->wFormatTag, pwfx->nChannels, pwfx->nSamplesPerSec, pwfx->nAvgBytesPerSec, pwfx->wBitsPerSample, pwfx->nBlockAlign); if (pwfx->nSamplesPerSec != 48000 || pwfx->nChannels != 2 || pwfx->wFormatTag != WAVE_FORMAT_EXTENSIBLE) { LOG_TRACE("Windows", "Audio - unsupported format for loopback" ); goto Exit; } WAVEFORMATEXTENSIBLE *wfx = (void *)pwfx; if (memcmp(&KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, &wfx->SubFormat, sizeof(wfx->SubFormat)) != 0) { goto Exit; } /* if(memcmp(&KSDATAFORMAT_SUBTYPE_PCM, &wfx->SubFormat, sizeof(wfx->SubFormat)) == 0) { printf("pcm\n"); } else { printf("unknown\n"); }*/ hr = pAudioClient->lpVtbl->Initialize(pAudioClient, AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_LOOPBACK, hnsRequestedDuration, 0, pwfx, NULL); EXIT_ON_ERROR(hr) /*AUDCLNT_STREAMFLAGS_EVENTCALLBACK hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); if (hEvent == NULL) { hr = E_FAIL; goto Exit; } hr = pAudioClient->lpVtbl-> EXIT_ON_ERROR(hr)*/ // Get the size of the allocated buffer. hr = pAudioClient->lpVtbl->GetBufferSize(pAudioClient, &bufferFrameCount); EXIT_ON_ERROR(hr) hr = pAudioClient->lpVtbl->GetService(pAudioClient, &IID_IAudioCaptureClient_utox, (void **)&pCaptureClient); EXIT_ON_ERROR(hr) LOG_TRACE("Windows", "Audio frame count %u && Samples/s %lu" , bufferFrameCount, pwfx->nSamplesPerSec); // postmessage_utox(AUDIO_IN_DEVICE, STR_AUDIO_IN_DEFAULT_LOOPBACK, 0, (void*)(size_t)1); // this has no effect on my system, so I'm commenting it out, if you can't get audio, try enabling this again! return; Exit: CoTaskMemFree(pwfx); SAFE_RELEASE(pEnumerator) SAFE_RELEASE(pDevice) SAFE_RELEASE(pAudioClient) SAFE_RELEASE(pCaptureClient) LOG_ERR("Windows", "Audio_init fail: %lu" , hr); } bool audio_init(void *UNUSED(handle)) { return SUCCEEDED(pAudioClient->lpVtbl->Start(pAudioClient)); } bool audio_close(void *UNUSED(handle)) { return SUCCEEDED(pAudioClient->lpVtbl->Stop(pAudioClient)); } static void *convertsamples(int16_t *dest, float *src, uint16_t samples) { if (!src) { memset(dest, 0, samples * 2); return NULL; } for (uint16_t i = 0; i != samples; i++) { float x = *src++; const float y = *src++; x = (x + y) * INT16_MAX / 2.0; if (x > INT16_MAX) { x = INT16_MAX; } else if (x < INT16_MIN) { x = INT16_MIN; } int16_t v = lrintf(x); *dest++ = v; // x; } return src; } bool audio_frame(int16_t *buffer) { // HRESULT hr; UINT32 numFramesAvailable; UINT32 packetLength = 0; BYTE * pData; DWORD flags; pCaptureClient->lpVtbl->GetNextPacketSize(pCaptureClient, &packetLength); // hr = pCaptureClient->lpVtbl->GetNextPacketSize(pCaptureClient, &packetLength); // EXIT_ON_ERROR(hr) while (packetLength != 0) { // Get the available data in the shared buffer. pCaptureClient->lpVtbl->GetBuffer(pCaptureClient, &pData, &numFramesAvailable, &flags, NULL, NULL); // hr = pCaptureClient->lpVtbl->GetBuffer(pCaptureClient, &pData, &numFramesAvailable, &flags, NULL, NULL); // EXIT_ON_ERROR(hr) if (flags & AUDCLNT_BUFFERFLAGS_SILENT) { pData = NULL; // Tell CopyData to write silence. } if (numFramesAvailable != 480) { LOG_ERR("Windows Audio", "Incorrect number of frames available."); } static bool frame = true; convertsamples(&buffer[frame ? 0 : 480], (void *)pData, 480); frame = !frame; // Copy the available capture data to the audio sink. // printf("%u\n", numFramesAvailable); // hr = pMySink->CopyData(pData, numFramesAvailable, &bDone); // EXIT_ON_ERROR(hr) pCaptureClient->lpVtbl->ReleaseBuffer(pCaptureClient, numFramesAvailable); // hr = pCaptureClient->lpVtbl->ReleaseBuffer(pCaptureClient, numFramesAvailable); // EXIT_ON_ERROR(hr) if (frame) { return true; } pCaptureClient->lpVtbl->GetNextPacketSize(pCaptureClient, &packetLength); // hr = pCaptureClient->lpVtbl->GetNextPacketSize(pCaptureClient, &packetLength); // EXIT_ON_ERROR(hr) } return false; } uTox/src/windows/CMakeLists.txt0000600000175000001440000000127714003056216015526 0ustar rakusersproject(utoxNATIVE LANGUAGES C) ######################################### ## Native Icon data ######################################### enable_language(RC) ######################################### ## Native Interface ######################################### add_library(utoxNATIVE STATIC audio.c dnd.c drawing.c events.c filesys.c main.c notify.c os_video.c screen_grab.c utf8.c video.c window.c ) target_link_libraries(utoxNATIVE PUBLIC iphlpapi ws2_32 gdi32 msimg32 dnsapi comdlg32 winmm ole32 oleaut32 strmiids shell32 opus PRIVATE stb ) set(WINDOWS_ICON utox.rc) uTox/src/window.h0000600000175000001440000000213214003056216012743 0ustar rakusers#ifndef WINDOW_H #define WINDOW_H typedef struct native_window UTOX_WINDOW; typedef struct panel PANEL; /** window_raze() * * Cleans and frees all the data related to a created window. */ void window_raze(UTOX_WINDOW *window); /** window_create_video() * * Currently a no-op * * Creates a window struct for a popout video window. */ void window_create_video(int x, int y, int w, int h); /** window_find_notify() * * Finds the struct for a popout interactive notification, when given * the "native" type of window. Eg, HWND in Win32 or Window for XLIB */ UTOX_WINDOW *window_find_notify(void *window); /** window_create_notify() * * Create an interactive notification window and struct. */ UTOX_WINDOW *window_create_notify(int x, int y, int w, int h, PANEL *panel); /** window_tween() * * Example code to move a window off screen. * * Pointless UI fun. */ void window_tween(UTOX_WINDOW *win); /** window_create_screen_select() * * Creates the special window for selecting a portion of screen for * screen sharing or desktop images. */ void window_create_screen_select(void); #endif uTox/src/window.c0000600000175000001440000000115414003056216012741 0ustar rakusers#include "window.h" #include "native/window.h" void window_raze(UTOX_WINDOW *window) { native_window_raze(window); } void window_create_video(int x, int y, int w, int h) { native_window_create_video(x, y, w, h); } UTOX_WINDOW *window_find_notify(void *window) { return native_window_find_notify(window); } UTOX_WINDOW *window_create_notify(int x, int y, int w, int h, PANEL *panel) { return native_window_create_notify(x, y, w, h, panel); } void window_tween(UTOX_WINDOW *win) { native_window_tween(win); } void window_create_screen_select(void) { native_window_create_screen_select(); } uTox/src/utox_theme.ini0000600000175000001440000000512414003056216014151 0ustar rakusers# This is an example uTox theme. Copy it to ~/.config/tox/utox_theme.ini. # A list of keys is in theme.h, remove COLOR_ from the front. # Colours specified in hex #---- Main chat area ---- COLOR_MAIN_BACKGROUND = FFFFFF COLOR_MAIN_TEXT = 333333 COLOR_MAIN_TEXT_CHAT = 000000 COLOR_MAIN_TEXT_SUBTEXT = 414141 COLOR_MAIN_TEXT_ACTION = 4E4EC8 COLOR_MAIN_TEXT_QUOTE = 008000 COLOR_MAIN_TEXT_URL = 001FFF COLOR_MAIN_TEXT_HINT = 969696 #---- Friend list header and bottom-left buttons ---- COLOR_MENU_BACKGROUND = 1C1C1C COLOR_MENU_TEXT = FFFFFF COLOR_MENU_SUBTEXT = D1D1D1 COLOR_MENU_HOVER_BACKGROUND = 282828 COLOR_MENU_ACTIVE_BACKGROUND = 414141 COLOR_MENU_ACTIVE_TEXT = FFFFFF #---- Friend list ---- COLOR_LIST_BACKGROUND = 414141 COLOR_LIST_HOVER_BACKGROUND = 505050 COLOR_LIST_TEXT = FFFFFF COLOR_LIST_SUBTEXT = D1D1D1 #---- Groupchat user list and title ---- COLOR_GROUP_SELF = 6BC260 COLOR_GROUP_PEER = 969696 COLOR_GROUP_AUDIO = C84E4E COLOR_GROUP_MUTED = 4E4EC8 #---- Text selection ---- COLOR_SELECTION_BACKGROUND = 333333 COLOR_SELECTION_TEXT = FFFFFF #---- Inputs, dropdowns & tooltips ---- COLOR_EDGE_NORMAL = C0C0C0 COLOR_EDGE_HOVER = 969696 COLOR_EDGE_ACTIVE = 4EA6EA COLOR_ACTIVEOPTION_BKGRND = D1D1D1 COLOR_ACTIVEOPTION_TEXT = 333333 #---- Auxiliary style for inputs/dropdowns ("Search friends" bar) ---- COLOR_AUX_BACKGROUND = 313131 COLOR_AUX_EDGE_NORMAL = 313131 COLOR_AUX_EDGE_HOVER = 999999 COLOR_AUX_EDGE_ACTIVE = 1A73B7 COLOR_AUX_TEXT = FFFFFF COLOR_AUX_ACTIVEOPTION_BKGRND = 505050 COLOR_AUX_ACTIVEOPTION_TEXT = FFFFFF #---- Status circles ---- COLOR_STATUS_ONLINE = 6BC260 COLOR_STATUS_AWAY = CEBF45 COLOR_STATUS_BUSY = C84E4E #---- Buttons ---- COLOR_BTN_SUCCESS_BKGRND = 6BC260 COLOR_BTN_SUCCESS_TEXT = FFFFFF COLOR_BTN_SUCCESS_BKGRND_HOVER = 76D56A COLOR_BTN_SUCCESS_TEXT_HOVER = FFFFFF COLOR_BTN_WARNING_BKGRND = CEBF45 COLOR_BTN_WARNING_TEXT = FFFFFF COLOR_BTN_WARNING_BKGRND_HOVER = E3D24C COLOR_BTN_WARNING_TEXT_HOVER = FFFFFF COLOR_BTN_DANGER_BACKGROUND = C84E4E COLOR_BTN_DANGER_TEXT = FFFFFF COLOR_BTN_DANGER_BKGRND_HOVER = DC5656 COLOR_BTN_DANGER_TEXT_HOVER = FFFFFF COLOR_BTN_DISABLED_BKGRND = D1D1D1 COLOR_BTN_DISABLED_TEXT = FFFFFF COLOR_BTN_DISABLED_TRANSFER = 414141 COLOR_BTN_INPROGRESS_BKGRND = 4EA6EA COLOR_BTN_INPROGRESS_TEXT = FFFFFF uTox/src/utox.h0000600000175000001440000000340514003056216012437 0ustar rakusers#ifndef UTOX_H #define UTOX_H #include /* uTox client thread messages (received by the client thread) */ typedef enum utox_msg_id { /* General core and networking messages */ TOX_DONE, // 0 DHT_CONNECTED, /* OS interaction/integration messages*/ AUDIO_IN_DEVICE, AUDIO_OUT_DEVICE, /* Client/User Interface messages. */ REDRAW, TOOLTIP_SHOW, SELF_AVATAR_SET, UPDATE_TRAY, PROFILE_DID_LOAD, /* File transfer messages */ FILE_SEND_NEW, FILE_INCOMING_NEW, FILE_INCOMING_NEW_INLINE, FILE_INCOMING_NEW_INLINE_DONE, FILE_INCOMING_ACCEPT, FILE_STATUS_UPDATE, FILE_STATUS_UPDATE_DATA, FILE_STATUS_DONE, /* Friend interaction messages. */ /* Handshake */ FRIEND_ONLINE, FRIEND_NAME, FRIEND_STATUS_MESSAGE, FRIEND_STATE, FRIEND_AVATAR_SET, FRIEND_AVATAR_UNSET, /* Interactions */ FRIEND_TYPING, FRIEND_MESSAGE, FRIEND_MESSAGE_UPDATE, /* Adding and deleting */ FRIEND_INCOMING_REQUEST, FRIEND_ACCEPT_REQUEST, FRIEND_SEND_REQUEST, FRIEND_ADD_NO_REQ, FRIEND_REMOVE, /* Audio & Video calls, */ AV_CALL_INCOMING, AV_CALL_RINGING, AV_CALL_ACCEPTED, AV_CALL_DISCONNECTED, AV_VIDEO_FRAME, AV_INLINE_FRAME, AV_CLOSE_WINDOW, /* Group interactions, commented out for the new groupchats (coming soon maybe?) */ GROUP_ADD, GROUP_MESSAGE, GROUP_PEER_ADD, GROUP_PEER_DEL, GROUP_PEER_NAME, GROUP_PEER_CHANGE, GROUP_TOPIC, GROUP_AUDIO_START, GROUP_AUDIO_END, GROUP_UPDATE, } UTOX_MSG; void postmessage_utox(UTOX_MSG msg, uint16_t param1, uint16_t param2, void *data); void utox_message_dispatch(UTOX_MSG utox_msg_id, uint16_t param1, uint16_t param2, void *data); #endif uTox/src/utox.desktop0000600000175000001440000000047014003056216013660 0ustar rakusers[Desktop Entry] Version=1.0 Type=Application Name=uTox Comment=A lightweight Tox client Comment[ru]=легковесный клиент Tox Comment[de]=Ein leichtgewichtiger Tox Client TryExec=utox Exec=utox Icon=utox Categories=InstantMessaging;AudioVideo;Network; Terminal=false MimeType=x-scheme-handler/tox; uTox/src/utox.c0000600000175000001440000005314714003056216012442 0ustar rakusers#include "utox.h" #include "avatar.h" #include "commands.h" #include "debug.h" #include "file_transfers.h" #include "filesys.h" #include "flist.h" #include "friend.h" #include "groups.h" #include "settings.h" #include "tox.h" #include "av/utox_av.h" #include "av/video.h" #include "ui/dropdown.h" #include "ui/edit.h" #include "ui/tooltip.h" #include "layout/friend.h" #include "layout/settings.h" // TODO including native.h files should never be needed, refactor filesys.h to provide necessary API #include "native/filesys.h" #include "native/notify.h" #include "native/ui.h" #include "native/video.h" #include #include /** Translates status code to text then sends back to the user */ static void file_notify(FRIEND *f, MSG_HEADER *msg) { STRING *str; switch (msg->via.ft.file_status) { case FILE_TRANSFER_STATUS_NONE: { str = SPTR(TRANSFER_NEW); break; } case FILE_TRANSFER_STATUS_ACTIVE: { str = SPTR(TRANSFER_STARTED); break; } case FILE_TRANSFER_STATUS_PAUSED_BOTH: { str = SPTR(TRANSFER___); break; } case FILE_TRANSFER_STATUS_PAUSED_US: case FILE_TRANSFER_STATUS_PAUSED_THEM: { str = SPTR(TRANSFER_PAUSED); break; } case FILE_TRANSFER_STATUS_KILLED: { str = SPTR(TRANSFER_CANCELLED); break; } case FILE_TRANSFER_STATUS_COMPLETED: { str = SPTR(TRANSFER_COMPLETE); break; } case FILE_TRANSFER_STATUS_BROKEN: default: { // render unknown status as "transfer broken" str = SPTR(TRANSFER_BROKEN); break; } } friend_notify_msg(f, str->str, str->length); } static void call_notify(FRIEND *f, uint8_t status) { STRING *str; switch (status) { case UTOX_AV_INVITE: { str = SPTR(CALL_INVITED); break; } case UTOX_AV_RINGING: { str = SPTR(CALL_RINGING); break; } case UTOX_AV_STARTED: { str = SPTR(CALL_STARTED); break; } default: { // render unknown status as "call canceled" str = SPTR(CALL_CANCELLED); break; } } friend_notify_msg(f, str->str, str->length); } void utox_message_dispatch(UTOX_MSG utox_msg_id, uint16_t param1, uint16_t param2, void *data) { switch (utox_msg_id) { /* General core and networking messages */ case TOX_DONE: { /* Does nothing. */ break; } case DHT_CONNECTED: { /* param1: connection status (1 = connected, 0 = disconnected) */ tox_connected = param1; if (tox_connected) { LOG_NOTE("uTox", "Connected to DHT!" ); } else { LOG_NOTE("uTox", "Disconnected from DHT!" ); } redraw(); break; } /* OS interaction/integration messages */ case AUDIO_IN_DEVICE: { /* param1: string * param2: default device? * data: device identifier. */ if (UI_STRING_ID_INVALID == param1) { dropdown_list_add_hardcoded(&dropdown_audio_in, data, data); } else { dropdown_list_add_localized(&dropdown_audio_in, param1, data); } if (settings.audio_device_in == (uint16_t)~0 && param2) { settings.audio_device_in = (dropdown_audio_in.dropcount - 1); } if (settings.audio_device_in != 0 && (dropdown_audio_in.dropcount - 1) == settings.audio_device_in) { postmessage_utoxav(UTOXAV_SET_AUDIO_IN, 0, 0, data); dropdown_audio_in.selected = settings.audio_device_in; settings.audio_device_in = 0; } break; } case AUDIO_OUT_DEVICE: { dropdown_list_add_hardcoded(&dropdown_audio_out, data, data); if (settings.audio_device_out != 0 && (dropdown_audio_out.dropcount - 1) == settings.audio_device_out) { postmessage_utoxav(UTOXAV_SET_AUDIO_OUT, 0, 0, data); dropdown_audio_out.selected = settings.audio_device_out; settings.audio_device_out = 0; } break; } /* Client/User Interface messages. */ case REDRAW: { if (param1) { ui_rescale(ui_scale); } else { ui_set_scale(0); } redraw(); break; } case TOOLTIP_SHOW: { tooltip_show(); redraw(); break; } case SELF_AVATAR_SET: { /* param1: size of data * data: png data */ self_set_and_save_avatar(data, param1); free(data); redraw(); break; } case UPDATE_TRAY: { update_tray(); break; } case PROFILE_DID_LOAD: { if (g_select_add_friend_later) { g_select_add_friend_later = 0; flist_selectaddfriend(); } redraw(); break; } /* File transfer messages */ // data: FILE_TRANSFER *file // param1: uint32_t friend_number // param2: uint32_t file_number case FILE_SEND_NEW: { if (!data) { break; } FRIEND *f = get_friend(param1); if (!f) { LOG_ERR("uTox", "Could not get friend with number: %u", param1); return; } FILE_TRANSFER *file = data; MSG_HEADER *m = message_add_type_file(&f->msg, param2, file->incoming, file->inline_img, file->status, file->name, file->name_length, file->target_size, file->current_size); file_notify(f, m); ft_set_ui_data(file->friend_number, file->file_number, m); free(data); redraw(); break; } case FILE_INCOMING_NEW: { if (!data) { break; } FRIEND *f = get_friend(param1); if (!f) { LOG_ERR("uTox", "Could not get friend with number: %u", param1); return; } FILE_TRANSFER *file = data; if (f->ft_autoaccept) { LOG_TRACE("Toxcore", "Auto Accept enabled for this friend: sending accept to system" ); native_autoselect_dir_ft(param1, file); } MSG_HEADER *m = message_add_type_file(&f->msg, (param2 + 1) << 16, file->incoming, file->inline_img, file->status, file->name, file->name_length, file->target_size, file->current_size); file_notify(f, m); ft_set_ui_data(file->friend_number, file->file_number, m); free(data); redraw(); break; } case FILE_INCOMING_NEW_INLINE: { if (!data) { break; } FRIEND *f = get_friend(param1); if (!f) { LOG_ERR("uTox", "Could not get friend with number: %u", param1); return; } // Process image data uint16_t width, height; uint8_t *image; memcpy(&width, data, sizeof(uint16_t)); memcpy(&height, (uint8_t *)data + sizeof(uint16_t), sizeof(uint16_t)); memcpy(&image, (uint8_t *)data + sizeof(uint16_t) * 2, sizeof(uint8_t *)); // Save and store image friend_recvimage(f, (NATIVE_IMAGE *)image, width, height); redraw(); free(data); break; } case FILE_INCOMING_NEW_INLINE_DONE: { if (!data) { break; } FRIEND *f = get_friend(param1); if (!f) { LOG_ERR("uTox", "Could not get friend with number: %u", param1); return; } FILE_TRANSFER *file = data; // Add file transfer message so user can save the inline. MSG_HEADER *m = message_add_type_file(&f->msg, param2, file->incoming, file->inline_img, file->status, file->name, file->name_length, file->target_size, file->current_size); file_notify(f, m); ft_set_ui_data(file->friend_number, file->file_number, m); redraw(); break; } case FILE_INCOMING_ACCEPT: { postmessage_toxcore(TOX_FILE_ACCEPT, param1, param2 << 16, data); break; } case FILE_STATUS_UPDATE: { if (!data) { break; } FILE_TRANSFER *file = data; if (file->ui_data) { file->ui_data->via.ft.progress = file->current_size; file->ui_data->via.ft.speed = file->speed; file->ui_data->via.ft.file_status = param1; } free(data); redraw(); break; } case FILE_STATUS_UPDATE_DATA: { if (!data) { break; } FILE_TRANSFER *file = data; if (file->ui_data) { if (param1 == FILE_TRANSFER_STATUS_COMPLETED) { if (file->in_memory) { file->ui_data->via.ft.data = file->via.memory; file->ui_data->via.ft.data_size = file->current_size; } else { memcpy(file->ui_data->via.ft.path, file->path, UTOX_FILE_NAME_LENGTH); } } } file->decon_wait = false; LOG_NOTE("uTox", "FT data was saved" ); redraw(); break; } // data: MSG_HEADER *ui_data // param1: UTOX_FILE_TRANSFER_STATUS file_status // File is done, failed or broken. case FILE_STATUS_DONE: { LOG_INFO("uTox", "FT done. Updating UI."); if (!data) { LOG_INFO("uTox", "FT done but no data about it."); break; } MSG_HEADER *msg = data; msg->via.ft.file_status = param1; redraw(); break; } /* Friend interaction messages. */ /* Handshake * param1: friend id * param2: new online status(bool) */ case FRIEND_ONLINE: { FRIEND *f = get_friend(param1); if (friend_set_online(f, param2)) { redraw(); } messages_send_from_queue(&f->msg, param1); break; } case FRIEND_NAME: { FRIEND *f = get_friend(param1); friend_setname(f, data, param2); redraw(); free(data); break; } case FRIEND_STATUS_MESSAGE: { FRIEND *f = get_friend(param1); free(f->status_message); f->status_length = param2; f->status_message = data; redraw(); break; } case FRIEND_STATE: { FRIEND *f = get_friend(param1); f->status = param2; redraw(); break; } case FRIEND_AVATAR_SET: { /* param1: friend id * param2: png size * data: png data */ FRIEND *f = get_friend(param1); uint8_t *avatar = data; size_t size = param2; avatar_set(f->avatar, avatar, size); avatar_save(f->id_str, avatar, size); free(avatar); redraw(); break; } case FRIEND_AVATAR_UNSET: { FRIEND *f = get_friend(param1); avatar_unset(f->avatar); // remove avatar from disk avatar_delete(f->id_str); redraw(); break; } /* Interactions */ case FRIEND_TYPING: { FRIEND *f = get_friend(param1); friend_set_typing(f, param2); redraw(); break; } case FRIEND_MESSAGE: { // TODO implement notification //notify_new(NULL, NULL); redraw(); break; } case FRIEND_MESSAGE_UPDATE: { redraw(); break; } /* Adding and deleting */ case FRIEND_INCOMING_REQUEST: { /* data: pointer to FREQUEST structure */ flist_add_frequest(get_frequest(param1)); redraw(); break; } case FRIEND_ACCEPT_REQUEST: { /* confirmation that friend has been added to friend list (accept) */ FREQUEST *req = data; FRIEND *f = get_friend(param1); if (!f) { LOG_ERR("uTox", "Could not get friend with number: %u", param2); return; } flist_add_friend_accepted(f, req); flist_reselect_current(); redraw(); break; } case FRIEND_ADD_NO_REQ: { /* confirmation that friend has been added to friend list (add) */ if (param1) { /* friend was not added */ addfriend_status = param2; } else { /* friend was added */ edit_add_new_friend_id.length = 0; edit_add_new_friend_msg.length = 0; FRIEND *f = get_friend(param2); if (!f) { LOG_ERR("uTox", "Could not get friend with number: %u", param2); free(data); return; } flist_add_friend(f, NULL, 0); flist_selectchat(f->number); addfriend_status = ADDF_NOFREQUESTSENT; } free(data); redraw(); break; } case FRIEND_SEND_REQUEST: { /* confirmation that friend has been added to friend list (add) */ if (param1) { /* friend was not added */ addfriend_status = param2; } else { /* friend was added */ FRIEND *f = get_friend(param2); if (!f) { edit_add_new_friend_id.length = 0; edit_add_new_friend_msg.length = 0; LOG_ERR("uTox", "Could not get friend with number: %u", param2); free(data); return; } memcpy(f->id_bin, data, TOX_PUBLIC_KEY_SIZE); char *request_message = strdup(edit_add_new_friend_msg.data); if (request_message) { flist_add_friend(f, request_message, edit_add_new_friend_msg.length); free(request_message); } else { LOG_ERR("uTox", "Could not allocate memory for request message."); } flist_selectchat(f->number); addfriend_status = ADDF_SENT; edit_add_new_friend_id.length = 0; edit_add_new_friend_msg.length = 0; } free(data); redraw(); break; } case FRIEND_REMOVE: { FRIEND *f = data; // commented out in case you have multiple clients in the same data dir // and remove one as friend from the other // (it would remove his avatar locally too otherwise) // char cid[TOX_PUBLIC_KEY_SIZE * 2]; // cid_to_string(cid, f->cid); // delete_saved_avatar(friend_number); friend_free(f); break; } case AV_CALL_INCOMING: { FRIEND *f = get_friend(param1); if (!f) { LOG_ERR("uTox", "Could not get friend with number: %u", param1); return; } call_notify(f, UTOX_AV_INVITE); redraw(); break; } case AV_CALL_RINGING: { FRIEND *f = get_friend(param1); if (!f) { LOG_ERR("uTox", "Could not get friend with number: %u", param1); return; } call_notify(f, UTOX_AV_RINGING); redraw(); break; } case AV_CALL_ACCEPTED: { FRIEND *f = get_friend(param1); if (!f) { LOG_ERR("uTox", "Could not get friend with number: %u", param1); return; } call_notify(f, UTOX_AV_STARTED); redraw(); break; } case AV_CALL_DISCONNECTED: { FRIEND *f = get_friend(param1); if (!f) { LOG_ERR("uTox", "Could not get friend with number: %u", param1); return; } call_notify(f, UTOX_AV_NONE); redraw(); break; } case AV_VIDEO_FRAME: { /* param1: video handle to send frame to (friend id + 1 or 0 for preview) param2: self preview frame for pending call. data: packaged frame data */ UTOX_FRAME_PKG *frame = data; STRING *s = SPTR(WINDOW_TITLE_VIDEO_PREVIEW); // TODO: Don't try to start a new video session every frame. video_begin(param1, s->str, s->length, frame->w, frame->h); video_frame(param1, frame->img, frame->w, frame->h, 0); free(frame->img); free(data); redraw(); break; } case AV_INLINE_FRAME: { redraw(); break; } case AV_CLOSE_WINDOW: { LOG_INFO("uTox", "Closing video feed" ); video_end(param1); redraw(); break; } /* Group chat functions */ case GROUP_ADD: { /* param1: group number param2: whether its an av call or not */ GROUPCHAT *g = get_group(param1); if (!g) { return; } flist_add_group(g); flist_select_last(); redraw(); break; } case GROUP_MESSAGE: { GROUPCHAT *g = get_group(param1); if (!g) { return; } GROUPCHAT *selected = flist_get_sel_group(); if (selected != g) { g->unread_msg = true; } redraw(); // ui_drawmain(); break; } case GROUP_PEER_DEL: { GROUPCHAT *g = get_group(param1); if (!g) { return; } if (g->av_group) { g->last_recv_audio[param2] = g->last_recv_audio[g->peer_count]; g->last_recv_audio[g->peer_count] = 0; group_av_peer_remove(g, param2); g->source[param2] = g->source[g->peer_count]; } snprintf((char *)g->topic, sizeof(g->topic), "%u users in chat", g->peer_count); g->topic_length = strnlen(g->topic, sizeof(g->topic) - 1); redraw(); break; } case GROUP_PEER_ADD: case GROUP_PEER_NAME: case GROUP_PEER_CHANGE: { /* param1: group number * param2: peer number */ GROUPCHAT *g = get_group(param1); if (!g) { return; } snprintf((char *)g->topic, sizeof(g->topic), "%u users in chat", g->peer_count); g->topic_length = strnlen(g->topic, sizeof(g->topic) - 1); GROUPCHAT *selected = flist_get_sel_group(); if (selected != g) { g->unread_msg = true; } redraw(); break; } case GROUP_TOPIC: { GROUPCHAT *g = get_group(param1); if (!g) { return; } if (param2 > sizeof(g->name)) { memcpy(g->name, data, sizeof(g->name)); g->name_length = sizeof(g->name); } else { memcpy(g->name, data, param2); g->name_length = param2; } free(data); redraw(); break; } case GROUP_AUDIO_START: { /* param1: group number */ GROUPCHAT *g = get_group(param1); if (!g) { LOG_ERR("uTox", "Can't get group %u", param1); return; } if (g->av_group) { LOG_INFO("uTox", "We are in an audio group starting call."); g->active_call = true; postmessage_utoxav(UTOXAV_GROUPCALL_START, param1, 0, NULL); redraw(); } break; } case GROUP_AUDIO_END: { /* param1: group number */ GROUPCHAT *g = get_group(param1); if (!g) { LOG_ERR("uTox", "Can't get group %u", param1); return; } LOG_INFO("uTox", "We are in an audio group ending call."); g->active_call = false; postmessage_utoxav(UTOXAV_GROUPCALL_END, param1, 0, NULL); redraw(); break; } case GROUP_UPDATE: { redraw(); break; } } } uTox/src/ui_i18n.h0000600000175000001440000001403314003056216012713 0ustar rakusers#ifndef UI_I18N_H #define UI_I18N_H //"CZECH" "Čeština" #define _LANG_ID LANG_CS LANG_POSIX_LOCALE("cs_CZ") LANG_WINDOWS_ID(0x0405) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/cs.h" #undef _LANG_ID //"BULGARIAN" "Български" #define _LANG_ID LANG_BG LANG_POSIX_LOCALE("bg_BG") LANG_WINDOWS_ID(0x0402) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/bg.h" #undef _LANG_ID //"GERMAN" "Deutsch" #define _LANG_ID LANG_DE LANG_POSIX_LOCALE("de_DE") LANG_WINDOWS_ID(0x0407) LANG_PRIORITY(-1) // Ensure this lang gets chosen for unknown de locales. #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/de.h" #undef _LANG_ID //"ENGLISH" "English" #define _LANG_ID LANG_EN LANG_POSIX_LOCALE("en_US") LANG_WINDOWS_ID(0x0409) LANG_PRIORITY(-1) // Ensure this lang gets chosen for unknown en locales. #include "../langs/en.h" #undef _LANG_ID //"SPANISH" "Spanish" #define _LANG_ID LANG_ES LANG_POSIX_LOCALE("es_ES") LANG_WINDOWS_ID(0x040A) LANG_PRIORITY(-1) // Ensure this lang gets chosen for unknown es locales. #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/es.h" #undef _LANG_ID //"FRENCH" "Français" #define _LANG_ID LANG_FR LANG_POSIX_LOCALE("fr_FR") LANG_WINDOWS_ID(0x040C) LANG_PRIORITY(-1) // Ensure this lang gets chosen for unknown fr locales. #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/fr.h" #undef _LANG_ID //"HINDI" "Hindi" #define _LANG_ID LANG_HI LANG_POSIX_LOCALE("hi_IN") LANG_WINDOWS_ID(0x0439) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/hi.h" #undef _LANG_ID //"JAPANESE" "日本語" #define _LANG_ID LANG_JA LANG_POSIX_LOCALE("ja_JP") LANG_WINDOWS_ID(0x0411) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/ja.h" #undef _LANG_ID //"ITALIAN" "Italiano" #define _LANG_ID LANG_IT LANG_POSIX_LOCALE("it_IT") LANG_WINDOWS_ID(0x0410) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/it.h" #undef _LANG_ID //"LATVIAN" "Latviešu" #define _LANG_ID LANG_LV LANG_POSIX_LOCALE("lv_LV") LANG_WINDOWS_ID(0x0426) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/lv.h" #undef _LANG_ID //"DUTCH" "Nederlands" #define _LANG_ID LANG_NL LANG_POSIX_LOCALE("nl_NL") LANG_WINDOWS_ID(0x0413) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/nl.h" #undef _LANG_ID //"NORWEGIAN" "Norsk" #define _LANG_ID LANG_NO LANG_POSIX_LOCALE("no_NO") LANG_WINDOWS_ID(0x0414) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/no.h" #undef _LANG_ID //"POLISH" "Polski" #define _LANG_ID LANG_PL LANG_POSIX_LOCALE("pl_PL") LANG_WINDOWS_ID(0x0415) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/pl.h" #undef _LANG_ID //"BRAZILIAN PORTUGUESE" "Português brasileiro" #define _LANG_ID LANG_BR LANG_POSIX_LOCALE("pt_BR") LANG_WINDOWS_ID(0x0416) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/br.h" #undef _LANG_ID //"ROMANIAN" "Română" #define _LANG_ID LANG_RO LANG_POSIX_LOCALE("ro_RO") LANG_WINDOWS_ID(0x0418) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/ro.h" #undef _LANG_ID //"RUSSIAN" "Русский" #define _LANG_ID LANG_RU LANG_POSIX_LOCALE("ru_RU") LANG_WINDOWS_ID(0x0419) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/ru.h" #undef _LANG_ID //"TURKISH" "Türk" #define _LANG_ID LANG_TR LANG_POSIX_LOCALE("tr_TR") LANG_WINDOWS_ID(0x041F) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/tr.h" #undef _LANG_ID //"UKRAINIAN" "Українська" #define _LANG_ID LANG_UK LANG_POSIX_LOCALE("uk_UA") LANG_WINDOWS_ID(0x0422) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/uk.h" #undef _LANG_ID //"SIMPLIFIED CHINESE" "简体中文" #define _LANG_ID LANG_CN LANG_POSIX_LOCALE("zh_CN") LANG_WINDOWS_ID(0x0804) LANG_PRIORITY(-1) // Ensure this lang gets chosen for unknown zh locales. #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/cn.h" #undef _LANG_ID //"TRADITIONAL CHINESE" "繁體中文" #define _LANG_ID LANG_TW LANG_POSIX_LOCALE("zh_TW") LANG_WINDOWS_ID(0x0404) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/tw.h" #undef _LANG_ID //"DANISH" "Dansk" #define _LANG_ID LANG_DK LANG_POSIX_LOCALE("da_DK") LANG_WINDOWS_ID(0x0406) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/dk.h" #undef _LANG_ID //"SWEDISH" "Svenska" #define _LANG_ID LANG_SV LANG_POSIX_LOCALE("sv_SE") LANG_WINDOWS_ID(0x041d) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/sv.h" #undef _LANG_ID //"HUNGARIAN" "Magyar" #define _LANG_ID LANG_HU LANG_POSIX_LOCALE("hu_HU") LANG_WINDOWS_ID(0x040E) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/hu.h" #undef _LANG_ID //"PORTUGUESE" "Português de Portugal" #define _LANG_ID LANG_PT LANG_POSIX_LOCALE("pt_PT") LANG_WINDOWS_ID(0x0816) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/pt.h" #undef _LANG_ID //"ESPERANTO" "Esperanto" #define _LANG_ID LANG_EO LANG_POSIX_LOCALE("eo") // LANG_WINDOWS_ID(0x0000) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/eo.h" #undef _LANG_ID //"CROATIAN" "hrvatski" #define _LANG_ID LANG_HR LANG_POSIX_LOCALE("hr_HR") LANG_WINDOWS_ID(0x041A) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/hr.h" #undef _LANG_ID //"ESTONIAN" "eesti" #define _LANG_ID LANG_ET LANG_POSIX_LOCALE("et_EE") LANG_WINDOWS_ID(0x0425) #include "../langs/en.h" //fallback to English for untranslated things #include "../langs/et.h" #undef _LANG_ID #endif uTox/src/ui_i18n.c0000600000175000001440000001236714003056216012716 0ustar rakusers#include "../langs/i18n_decls.h" #include "sized_string.h" #include "macros.h" #include #include #ifdef msgid #error "msgid is already defined" #endif #ifdef msgstr #error "msgstr is already defined" #endif #ifdef LANG_POSIX_LOCALE #error "LANG_POSIX_LOCALE is already defined" #endif #ifdef LANG_WINDOWS_ID #error "LANG_WINDOWS_ID is already defined" #endif #ifdef LANG_PRIORITY #error "LANG_PRIORITY is already defined" #endif /***** Parsing localized strings *****/ #define msgid(x) curr_id = (STR_##x); #define msgstr(x) \ localized_strings[_LANG_ID][curr_id].str = (x); \ localized_strings[_LANG_ID][curr_id].length = sizeof(x) - 1; #define LANG_WINDOWS_ID(x) #define LANG_POSIX_LOCALE(x) #define LANG_PRIORITY(x) static STRING canary = STRING_INIT("BUG. PLEASE REPORT."); static void init_strings(STRING (*localized_strings)[NUM_STRS]) { for (UTOX_LANG i = 0; i < NUM_LANGS; i++) { for (UTOX_I18N_STR j = 0; j < NUM_STRS; j++) { localized_strings[i][j] = canary; } } UTOX_I18N_STR curr_id = 0; #include "ui_i18n.h" } #undef LANG_PRIORITY #undef LANG_POSIX_LOCALE #undef LANG_WINDOWS_ID #undef msgstr #undef msgid STRING *ui_gettext(UTOX_LANG lang, UTOX_I18N_STR string_id) { static STRING localized_strings[NUM_LANGS][NUM_STRS]; static int ready = 0; if (!ready) { init_strings(localized_strings); ready = 1; } if ((lang >= NUM_LANGS) || (string_id >= NUM_STRS)) { return &canary; } return &localized_strings[lang][string_id]; } /***** Parsing detection by POSIX locale *****/ #define msgid(x) #define msgstr(x) #define LANG_WINDOWS_ID(x) #define LANG_POSIX_LOCALE(x) posix_locales[_LANG_ID] = (x); #define LANG_PRIORITY(x) priorities[_LANG_ID] = (x); static void init_posix_locales(const char *UNUSED(posix_locales[]), int8_t UNUSED(priorities[])) { #include "ui_i18n.h" } #undef LANG_PRIORITY #undef LANG_POSIX_LOCALE #undef LANG_WINDOWS_ID #undef msgstr #undef msgid UTOX_LANG ui_guess_lang_by_posix_locale(const char *locale, UTOX_LANG deflt) { static const char *posix_locales[NUM_LANGS]; static int8_t priorities[NUM_LANGS]; static int ready = 0; if (!ready) { init_posix_locales(posix_locales, priorities); ready = 1; } UTOX_LANG found_lang = 0; int8_t found_prio = INT8_MAX; // Try detecting by full prefix match first. for (UTOX_LANG i = 0; i < NUM_LANGS; i++) { const char *l = posix_locales[i]; if (!l) { continue; } if (strstr(locale, l)) { if (found_prio > priorities[i]) { found_lang = i; found_prio = priorities[i]; } } } if (found_prio < INT8_MAX) { return found_lang; } // It appears we haven't found exact language_territory // match (e.g. zh_TW) for given locale. , // Try stripping territory off and search only by language part. for (UTOX_LANG i = 0; i < NUM_LANGS; i++) { const char *l = posix_locales[i]; if (!l) { continue; } char *sep = strchr(l, '_'); if (!sep) { continue; } if (!strncmp(locale, l, sep - l)) { if (found_prio > priorities[i]) { found_lang = i; found_prio = priorities[i]; } } } return found_prio < INT8_MAX ? found_lang : deflt; } /***** Parsing detection by Windows language id *****/ #define msgid(x) #define msgstr(x) #define LANG_WINDOWS_ID(x) windows_lang_ids[_LANG_ID] = (x); #define LANG_POSIX_LOCALE(x) #define LANG_PRIORITY(x) priorities[_LANG_ID] = (x); static void init_windows_lang_ids(uint16_t UNUSED(windows_lang_ids[]), int8_t UNUSED(priorities[])) { #include "ui_i18n.h" } #undef LANG_PRIORITY #undef LANG_POSIX_LOCALE #undef LANG_WINDOWS_ID #undef msgstr #undef msgid UTOX_LANG ui_guess_lang_by_windows_lang_id(uint16_t lang_id, UTOX_LANG deflt) { static uint16_t windows_lang_ids[NUM_LANGS]; static int8_t priorities[NUM_LANGS]; static int ready = 0; if (!ready) { init_windows_lang_ids(windows_lang_ids, priorities); ready = 1; } UTOX_LANG found_lang = 0; int8_t found_prio = INT8_MAX; // Try detecting by full match first, including sublanguage part. for (UTOX_LANG i = 0; i < NUM_LANGS; i++) { uint16_t l = windows_lang_ids[i]; if (!l) { continue; } if (l == lang_id) { if (found_prio > priorities[i]) { found_lang = i; found_prio = priorities[i]; } } } if (found_prio < INT8_MAX) { return found_lang; } // It appears we haven't found exact id match. // Try matching by the lower 8 bits, which contain language family part. for (UTOX_LANG i = 0; i < NUM_LANGS; i++) { uint16_t l = windows_lang_ids[i]; if (!l) { continue; } if ((l & 0xFF) == (lang_id & 0xFF)) { if (found_prio > priorities[i]) { found_lang = i; found_prio = priorities[i]; } } } return found_prio < INT8_MAX ? found_lang : deflt; } uTox/src/ui/0000700000175000001440000000000014003056216011700 5ustar rakusersuTox/src/ui/tooltip.h0000600000175000001440000000103614003056216013545 0ustar rakusers#ifndef TOOLTIP_H #define TOOLTIP_H #include typedef struct maybe_i18nal_string MAYBE_I18NAL_STRING; typedef struct tooltip { int x, y, width, height; bool visible; bool can_show; bool mouse_down; bool thread; MAYBE_I18NAL_STRING *tt_text; } TOOLTIP; // removes the tooltip, requires a redraw void tooltip_reset(void); void tooltip_draw(void); bool tooltip_mmove(void); bool tooltip_mdown(void); bool tooltip_mup(void); void tooltip_show(void); void tooltip_new(MAYBE_I18NAL_STRING *text); #endif uTox/src/ui/tooltip.c0000600000175000001440000000730614003056216013546 0ustar rakusers#include "tooltip.h" #include "draw.h" #include "../macros.h" #include "../settings.h" #include "../theme.h" #include "../ui.h" #include "../utox.h" #include "../native/thread.h" #include "../native/time.h" static TOOLTIP tooltip; #define TOOLTIP_WIDTH SCALE(24) #define TOOLTIP_HEIGHT SCALE(24) #define TOOLTIP_YOFFSET 12 static void calculate_pos_and_width(TOOLTIP *b, int *x, int *w) { *x = b->x; *w = b->width; // Increase width if needed, so that tooltip text fits. if (maybe_i18nal_string_is_valid(b->tt_text)) { const STRING *s = maybe_i18nal_string_get(b->tt_text); const int needed_w = textwidth(s->str, s->length) + SCALE(8); if (*w < needed_w) { *w = needed_w; } } // Push away from the right border to fit. if (*x + *w >= (int)settings.window_width) { *x -= *w; } // Draw only within window if (*x < 0) { *x = 0; } } volatile bool kill_thread; void tooltip_reset(void) { TOOLTIP *b = &tooltip; b->visible = false; b->can_show = false; if (b->thread) { kill_thread = true; b->thread = false; } } void tooltip_draw(void) { TOOLTIP *b = &tooltip; if (!b->visible) { return; } // Ensure that font is set before calculating position and width. setfont(FONT_TEXT); setcolor(COLOR_MAIN_TEXT); int x, w; calculate_pos_and_width(b, &x, &w); draw_rect_fill(x, b->y, w, b->height, COLOR_BKGRND_MAIN); STRING *s = maybe_i18nal_string_get(b->tt_text); drawtext(x + SCALE(4), b->y + SCALE(4), s->str, s->length); draw_rect_frame(x, b->y, w, b->height, COLOR_EDGE_NORMAL); } bool tooltip_mmove(void) { TOOLTIP *b = &tooltip; b->can_show = false; if (!b->visible) { return false; } b->visible = false; if (b->thread) { kill_thread = true; b->thread = false; } return true; } bool tooltip_mdown(void) { TOOLTIP *b = &tooltip; b->can_show = false; b->mouse_down = true; b->visible = false; if (b->thread) { kill_thread = true; b->thread = false; } return false; } bool tooltip_mup(void) { TOOLTIP *b = &tooltip; b->can_show = false; b->mouse_down = false; if (b->thread) { kill_thread = true; b->thread = false; } return false; } void tooltip_show(void) { TOOLTIP *b = &tooltip; if (!b->can_show) { return; } b->y = mouse.y + TOOLTIP_YOFFSET; b->height = TOOLTIP_HEIGHT; if (b->y + b->height >= (int)settings.window_height) { b->y -= (b->height + TOOLTIP_YOFFSET); } b->x = mouse.x; b->width = TOOLTIP_WIDTH; b->visible = true; if (b->thread) { kill_thread = true; b->thread = false; } } volatile bool reset_time; static void tooltip_thread(void *UNUSED(args)) { uint64_t last_move_time = ~0; while (1) { if (kill_thread) { break; } if (reset_time) { last_move_time = get_time() + 500 * 1000 * 1000; reset_time = 0; } if (get_time() > last_move_time) { postmessage_utox(TOOLTIP_SHOW, 0, 0, NULL); last_move_time = ~0; } yieldcpu(100); } kill_thread = false; } // This is being called every time the mouse is moving above a button void tooltip_new(MAYBE_I18NAL_STRING *text) { TOOLTIP *tip = &tooltip; tip->can_show = true; tip->tt_text = text; if (tip->visible || tip->mouse_down) { return; } if (!tip->thread && !kill_thread) { thread(tooltip_thread, NULL); tip->thread = true; } reset_time = 1; } uTox/src/ui/text.h0000600000175000001440000000230414003056216013036 0ustar rakusers#ifndef UI_TEXT_H #define UI_TEXT_H #include #include typedef struct scrollable SCROLLABLE; /** Used to draw text within a specified box, starting with the x, y, of the first line of the text. Followed by right, top, then bottom borders of the box we're allowed to draw within. If any line would be drawn OUTSIDE of the box, it is skipped. */ int utox_draw_text_multiline_within_box(int x, int y, int right, int top, int bottom, uint16_t lineheight, const char *data, uint16_t length, uint16_t h, uint16_t hlen, uint16_t mark, uint16_t marklen, bool multiline); uint16_t hittextmultiline(int mx, int right, int my, int height, uint16_t lineheight, char *str, uint16_t length, bool multiline); int text_height(int right, uint16_t lineheight, char *str, uint16_t length); uint16_t text_lineup(int width, int height, uint16_t p, uint16_t lineheight, char *str, uint16_t length, SCROLLABLE *scroll); uint16_t text_linedown(int width, int height, uint16_t p, uint16_t lineheight, char *str, uint16_t length, SCROLLABLE *scroll); #endif uTox/src/ui/text.c0000600000175000001440000003057014003056216013037 0ustar rakusers#include "text.h" #include "draw.h" #include "scrollable.h" #include "../text.h" #include "../theme.h" #include #include static void text_draw_word_hl(int x, int y, const char *str, uint16_t length, int d, int h, int hlen, uint16_t lineheight) { // Draw cursor /* multiline drawing goes word by word so str is not what you think it will be * drawing word by word could be the WORST way to go about it. (It's at least super frustrating without the * documentation). Ideally I'd like to process in one loop through, then draw in the next, but that's a fix for * another time. */ h -= d; if (h + hlen < 0 || h > length) { drawtext(x, y, str, length); return; } else if (hlen == 0) { drawtext(x, y, str, length); int w = textwidth(str, h + hlen); drawvline(x + w, y, y + lineheight, COLOR_MAIN_TEXT); return; } if (h < 0) { hlen += h; h = 0; if (hlen < 0) { hlen = 0; } } if (h + hlen > length) { hlen = length - h; } int width = drawtext_getwidth(x, y, str, h); uint32_t color = setcolor(COLOR_SELECTION_TEXT); int w = textwidth(str + h, hlen); draw_rect_fill(x + width, y, w, lineheight, COLOR_SELECTION_BACKGROUND); drawtext(x + width, y, str + h, hlen); width += w; setcolor(color); drawtext(x + width, y, str + h + hlen, length - (h + hlen)); } static void drawtextmark(int x, int y, const char *str, uint16_t length, int d, int h, int hlen, uint16_t lineheight) { h -= d; if (h + hlen < 0 || h > length || hlen == 0) { return; } if (h < 0) { hlen += h; h = 0; if (hlen < 0) { hlen = 0; } } if (h + hlen > length) { hlen = length - h; } int width = textwidth(str, h); int w = textwidth(str + h, hlen); drawhline(x + width, y + lineheight - 1, x + width + w, COLOR_MAIN_TEXT); } int utox_draw_text_multiline_within_box(int x, int y, /* x, y of the top left corner of the box */ int right, int top, int bottom, uint16_t lineheight, const char *data, uint16_t length, /* text, and length of the text*/ uint16_t h, uint16_t hlen, uint16_t mark, uint16_t marklen, bool multiline) { uint32_t c1, c2; bool greentext = 0, link = 0, draw = y + lineheight >= top; int xc = x; const char *a_mark = data, *b_mark = a_mark, *end = a_mark + length; while (1) { if (a_mark != end) { if (*a_mark == '>' && (a_mark == data || *(a_mark - 1) == '\n')) { c1 = setcolor(COLOR_MAIN_TEXT_QUOTE); greentext = 1; } if ((a_mark == data || *(a_mark - 1) == '\n' || *(a_mark - 1) == ' ') && ( (end - a_mark >= 7 && memcmp(a_mark, "http://", 7) == 0) || (end - a_mark >= 8 && memcmp(a_mark, "https://", 8) == 0) || (end - a_mark >= 4 && memcmp(a_mark, "tox:", 4) == 0)) ) { c2 = setcolor(COLOR_MAIN_TEXT_URL); link = 1; } if (a_mark == data || *(a_mark - 1) == '\n') { const char *r = a_mark; while (r != end && *r != '\n') { r++; } if (r != data && *(r - 1) == '<') { if (greentext) { setcolor(COLOR_MAIN_TEXT_RED); } else { greentext = 1; c1 = setcolor(COLOR_MAIN_TEXT_RED); } } } } if (a_mark == end || *a_mark == ' ' || *a_mark == '\n') { int count = a_mark - b_mark, w = textwidth(b_mark, count); while (x + w > right) { if (multiline && x == xc) { int fit = textfit(b_mark, count, right - x); if (draw) { text_draw_word_hl(x, y, b_mark, fit, b_mark - data, h, hlen, lineheight); drawtextmark(x, y, b_mark, fit, b_mark - data, mark, marklen, lineheight); } count -= fit; b_mark += fit; y += lineheight; draw = (y + lineheight >= top && y < bottom); } else if (!multiline) { int fit = textfit(b_mark, count, right - x); if (draw) { text_draw_word_hl(x, y, b_mark, fit, b_mark - data, h, hlen, lineheight); drawtextmark(x, y, b_mark, fit, b_mark - data, mark, marklen, lineheight); } return y + lineheight; } else { y += lineheight; draw = (y + lineheight >= top && y < bottom); int l = utf8_len(b_mark); count -= l; b_mark += l; } x = xc; w = textwidth(b_mark, count); } if (draw) { text_draw_word_hl(x, y, b_mark, count, b_mark - data, h, hlen, lineheight); drawtextmark(x, y, b_mark, count, b_mark - data, mark, marklen, lineheight); } x += w; b_mark = a_mark; if (link) { setcolor(c2); link = 0; } if (a_mark == end) { if (greentext) { setcolor(c1); // greentext = 0; This is a dead assignment. Was something meant to be done with this? } break; } if (*a_mark == '\n') { if (greentext) { setcolor(c1); greentext = 0; } y += lineheight; draw = (y + lineheight >= top && y < bottom); b_mark += utf8_len(b_mark); x = xc; } } a_mark += utf8_len(a_mark); } return y + lineheight; } uint16_t hittextmultiline(int mx, int right, int my, int height, uint16_t lineheight, char *str, uint16_t length, bool multiline) { if (my < 0) { return 0; } if (my >= height) { return length; } int x = 0; char *a = str, *b = str, *end = str + length; while (1) { if (a == end || *a == '\n' || *a == ' ') { int count = a - b, w = textwidth(b, a - b); while (x + w > right && my >= lineheight) { if (multiline && x == 0) { int fit = textfit(b, count, right); count -= fit; b += fit; my -= lineheight; height -= lineheight; } else if (!multiline) { break; } else { my -= lineheight; height -= lineheight; int l = utf8_len(b); count -= l; b += l; } if (my >= -lineheight && my < 0) { x = mx; break; } x = 0; w = textwidth(b, count); } if (a == end) { if (my >= lineheight) { return length; } break; } if ((my >= 0 && my < lineheight) && (mx < 0 || (mx >= x && mx < x + w))) { break; } x += w; b = a; if (*a == '\n') { if (my >= 0 && my < lineheight) { // x = mx; This is a dead assignment. Was something meant to be done with this? return a - str; } b += utf8_len(b); my -= lineheight; height -= lineheight; x = 0; } } a += utf8_len(a); } int fit; if (mx >= right) { fit = textfit(b, a - b, right - x); } else if (mx - x > 0) { int len = a - b; fit = textfit_near(b, len + (a != end), mx - x); } else { fit = 0; } return (b - str) + fit; } int text_height(int right, uint16_t lineheight, char *str, uint16_t length) { int x = 0, y = 0; char *a = str, *b = a, *end = a + length; while (1) { if (a == end || *a == ' ' || *a == '\n') { int count = a - b, w = textwidth(b, count); while (x + w > right) { if (x == 0) { int fit = textfit(b, count, right); count -= fit; if (fit == 0 && (count != 0 || *b == '\n')) { return 0; } b += fit; y += lineheight; } else { y += lineheight; int l = utf8_len(b); count -= l; b += l; } x = 0; w = textwidth(b, count); } x += w; b = a; if (a == end) { break; } if (*a == '\n') { y += lineheight; b += utf8_len(b); x = 0; } } a += utf8_len(a); } y += lineheight; return y; } static void textxy(int width, uint16_t pp, uint16_t lineheight, char *str, uint16_t length, int *outx, int *outy) { int x = 0, y = 0; char *a = str, *b = str, *end = str + length, *p = str + pp; while (1) { if (a == end || *a == '\n' || *a == ' ') { int count = a - b, w = textwidth(b, a - b); while (x + w > width) { if (x == 0) { int fit = textfit(b, count, width); if (p >= b && p < b + fit) { break; } count -= fit; b += fit; y += lineheight; } else { y += lineheight; int l = utf8_len(b); count -= l; b += l; } x = 0; w = textwidth(b, count); } if (p >= b && p < b + count) { w = textwidth(b, p - b); a = end; } x += w; if (a == end) { break; } b = a; if (*a == '\n') { if (p == a) { break; } b += utf8_len(b); y += lineheight; x = 0; } } a += utf8_len(a); } *outx = x; *outy = y; } uint16_t text_lineup(int width, int height, uint16_t p, uint16_t lineheight, char *str, uint16_t length, SCROLLABLE *scroll) { // lazy int x, y; textxy(width, p, lineheight, str, length, &x, &y); if (y == 0) { scroll->d = 0.0; return 0; } y -= lineheight; if (scroll->content_height > height) { double d1 = (double)y / (double)(scroll->content_height - height); double d2 = (double)(y - height + lineheight) / (double)(scroll->content_height - height); if (d1 < scroll->d) { scroll->d = d1; } else if (d2 > scroll->d) { scroll->d = d2; } } return hittextmultiline(x, width, y, INT_MAX, lineheight, str, length, 1); } uint16_t text_linedown(int width, int height, uint16_t p, uint16_t lineheight, char *str, uint16_t length, SCROLLABLE *scroll) { // lazy int x, y; textxy(width, p, lineheight, str, length, &x, &y); y += lineheight; if (scroll->content_height > height) { double d1 = (double)y / (double)(scroll->content_height - height); double d2 = (double)(y - height + lineheight) / (double)(scroll->content_height - height); if (d2 > scroll->d) { scroll->d = d2 > 1.0 ? 1.0 : d2; } else if (d1 < scroll->d) { scroll->d = d1; } } return hittextmultiline(x, width, y, INT_MAX, lineheight, str, length, 1); } uTox/src/ui/switch.h0000600000175000001440000000263714003056216013364 0ustar rakusers#ifndef SWITCH_H #define SWITCH_H #include "panel.h" #include "svg.h" #include "../ui.h" #include #include typedef struct uiswitch UISWITCH; struct uiswitch { PANEL panel; SVG_IMG style_outer; SVG_IMG style_toggle; SVG_IMG style_icon_off; SVG_IMG style_icon_on; // Width/height of the toggle and the icons. Used for centering. int toggle_w, toggle_h, icon_off_w, icon_off_h, icon_on_w, icon_on_h; // Background RGB color, when Idle/Hovered/Pressed respectively. uint32_t bg_color, // Switch normal background color sw_color, // Switch 'toggle' color hover_color, // Switch mouse over color press_color, // Switch mouse down color disabled_color; // Switch disabled bg color MAYBE_I18NAL_STRING tooltip_text; bool switch_on; bool mouseover, mousedown, disabled, nodraw; void (*onright)(void); // called when right mouse uiswitch goes down void (*on_mup)(void); void (*update)(UISWITCH *s); }; void switch_draw(UISWITCH *s, int x, int y, int width, int height); bool switch_mmove(UISWITCH *s, int x, int y, int width, int height, int mx, int my, int dx, int dy); bool switch_mdown(UISWITCH *s); bool switch_mright(UISWITCH *s); bool switch_mwheel(UISWITCH *s, int height, double d, bool smooth); bool switch_mup(UISWITCH *s); bool switch_mleave(UISWITCH *s); void switch_update(UISWITCH *s); #endif uTox/src/ui/switch.c0000600000175000001440000001002314003056216013343 0ustar rakusers#include "switch.h" #include "draw.h" #include "tooltip.h" #include "../macros.h" #include "../ui.h" #include "../theme.h" static void calculate_pos_and_width(UISWITCH *s, int *x, int *w) { int old_w = *w; // Push away from the right border to fit, // if our panel is right-adjusted. if (s->panel.x < 0) { *x -= *w - old_w; } } void switch_draw(UISWITCH *s, int x, int y, int w, int h) { // Switch is hidden if (s->nodraw) { return; } // If `update` function is defined, call it on each draw if (s->update) { s->update(s); } // Switch background color uint32_t color = s->mousedown ? s->press_color : (s->mouseover ? s->hover_color : s->bg_color); drawalpha(s->style_outer, x, y, w, h, s->disabled ? s->disabled_color : color); // SVG offsets, used for centering int tx = ((w / 2 - s->toggle_w) / 2), ty = ((h - s->toggle_h) / 2), ix0 = ((w / 2 - s->icon_off_w) / 2), iy0 = ((h - s->icon_off_h) / 2), ix1 = ((w / 2 - s->icon_on_w) / 2), iy1 = ((h - s->icon_on_h) / 2); if (s->style_toggle) { if (s->switch_on) { drawalpha(s->style_toggle, x + (w / 2) + tx, y + ty, s->toggle_w, s->toggle_h, s->sw_color); } else { drawalpha(s->style_toggle, x + tx, y + ty, s->toggle_w, s->toggle_h, s->sw_color); } } if (s->style_icon_off && !s->switch_on) { drawalpha(s->style_icon_off, x + (w / 2) + ix0, y + iy0, s->icon_off_w, s->icon_off_h, s->sw_color); } else if (s->style_icon_on && s->switch_on) { drawalpha(s->style_icon_on, x + ix1, y + iy1, s->icon_on_w, s->icon_on_h, s->sw_color); } } bool switch_mmove(UISWITCH *s, int UNUSED(x), int UNUSED(y), int width, int height, int mx, int my, int UNUSED(dx), int UNUSED(dy)) { // Ensure that font is set before calculating position and width. setfont(FONT_SELF_NAME); int real_x = 0, real_w = width; calculate_pos_and_width(s, &real_x, &real_w); bool mouseover = inrect(mx, my, real_x, 0, real_w, height); if (mouseover) { if (!s->disabled) { cursor = CURSOR_HAND; } if (maybe_i18nal_string_is_valid(&s->tooltip_text)) { tooltip_new(&s->tooltip_text); } } if (mouseover != s->mouseover) { s->mouseover = mouseover; return 1; } return 0; } bool switch_mdown(UISWITCH *s) { if (!s->mousedown && s->mouseover) { s->mousedown = 1; return 1; } return 0; } bool switch_mright(UISWITCH *s) { if (s->mouseover && s->onright) { s->onright(); return 1; } return 0; } bool switch_mwheel(UISWITCH *UNUSED(s), int UNUSED(height), double UNUSED(d), bool UNUSED(smooth)) { return 0; } bool switch_mup(UISWITCH *s) { // ignore click when switch is disabled if (s->mousedown && !s->disabled) { if (s->mouseover) { s->switch_on = !s->switch_on; s->on_mup(); } s->mousedown = 0; return 1; } s->mousedown = 0; return 0; } bool switch_mleave(UISWITCH *s) { if (s->mouseover) { s->mouseover = 0; return 1; } return 0; } static void switch_set_colors(UISWITCH *s) { if (s->switch_on) { s->bg_color = COLOR_BTN_SUCCESS_BKGRND; s->sw_color = COLOR_BTN_SUCCESS_TEXT; s->press_color = COLOR_BTN_SUCCESS_BKGRND_HOVER; s->hover_color = COLOR_BTN_SUCCESS_BKGRND_HOVER; } else { s->bg_color = COLOR_BTN_DISABLED_BKGRND; s->sw_color = COLOR_BTN_DISABLED_FORGRND; s->hover_color = COLOR_BTN_DISABLED_BKGRND_HOVER; s->press_color = COLOR_BTN_DISABLED_BKGRND_HOVER; } } static void switch_set_size(UISWITCH *s) { s->toggle_w = BM_SWITCH_TOGGLE_WIDTH; s->toggle_h = BM_SWITCH_TOGGLE_HEIGHT; s->icon_off_w = BM_FB_WIDTH; s->icon_off_h = BM_FB_HEIGHT; s->icon_on_w = BM_FB_WIDTH; s->icon_on_h = BM_FB_HEIGHT; } void switch_update(UISWITCH *s) { switch_set_colors(s); switch_set_size(s); } uTox/src/ui/svg.h0000600000175000001440000000670514003056216012662 0ustar rakusers#ifndef SVG_H #define SVG_H #include /* Scroll bar rounded corners top and bottom */ #define BM_SCROLLHALF_WIDTH SCROLL_WIDTH #define BM_SCROLLHALF_HEIGHT (SCROLL_WIDTH / 2) /* No idea */ #define BM_STATUSAREA_WIDTH SCALE(20) #define BM_STATUSAREA_HEIGHT SCALE(40) /* Text button on the add a new friend page */ #define _BM_ADD_WIDTH 18 #define BM_ADD_WIDTH SCALE(18) #define BM_STATUS_WIDTH SCALE(9) #define BM_STATUS_NOTIFY_WIDTH SCALE(14) #define BM_NMSG_WIDTH SCALE(18) /* Standard large size button */ #define _BM_LBUTTON_WIDTH 52 #define _BM_LBUTTON_HEIGHT 40 #define BM_LBUTTON_WIDTH SCALE(52) #define BM_LBUTTON_HEIGHT SCALE(40) /* Standard small size button */ #define _BM_SBUTTON_WIDTH 52 #define _BM_SBUTTON_HEIGHT 20 #define BM_SBUTTON_WIDTH SCALE(52) #define BM_SBUTTON_HEIGHT SCALE(20) #define _BM_SWITCH_WIDTH 60 #define _BM_SWITCH_HEIGHT 25 #define BM_SWITCH_WIDTH SCALE(60) #define BM_SWITCH_HEIGHT SCALE(25) #define _BM_SWITCH_TOGGLE_WIDTH 26 #define _BM_SWITCH_TOGGLE_HEIGHT 21 #define BM_SWITCH_TOGGLE_WIDTH SCALE(26) #define BM_SWITCH_TOGGLE_HEIGHT SCALE(21) /* File transfer buttons */ #define BM_FT_WIDTH SCALE(250) #define BM_FT_HEIGHT SCALE(52) #define BM_FTM_WIDTH SCALE(226) #define BM_FTB_WIDTH SCALE(26) #define BM_FTB_HEIGHT SCALE(28) #define BM_FT_CAP_WIDTH SCALE(30) /* something to do with contacts? */ #define BM_CONTACT_WIDTH SCALE(40) /* no idea */ #define _BM_LBICON_WIDTH 22 #define BM_LBICON_WIDTH SCALE(22) #define _BM_LBICON_HEIGHT 20 #define BM_LBICON_HEIGHT SCALE(20) /* small file transfer button maybe? */ #define BM_FB_WIDTH SCALE(12) #define BM_FB_HEIGHT SCALE(10) /* small button placements */ #define _BM_CHAT_BUTTON_WIDTH 40 #define BM_CHAT_BUTTON_WIDTH SCALE(40) #define _BM_CHAT_BUTTON_HEIGHT 40 #define BM_CHAT_BUTTON_HEIGHT SCALE(40) /* camera box */ #define _BM_CHAT_BUTTON_OVERLAY_WIDTH 28 #define BM_CHAT_BUTTON_OVERLAY_WIDTH SCALE(28) #define _BM_CHAT_BUTTON_OVERLAY_HEIGHT 28 #define BM_CHAT_BUTTON_OVERLAY_HEIGHT SCALE(28) /* Large chat button */ #define _BM_CHAT_SEND_WIDTH 56 #define BM_CHAT_SEND_WIDTH SCALE(56) #define _BM_CHAT_SEND_HEIGHT 40 #define BM_CHAT_SEND_HEIGHT SCALE(40) /* Chat speech bubble */ #define _BM_CHAT_SEND_OVERLAY_WIDTH 40 #define BM_CHAT_SEND_OVERLAY_WIDTH SCALE(40) #define _BM_CHAT_SEND_OVERLAY_HEIGHT 32 #define BM_CHAT_SEND_OVERLAY_HEIGHT SCALE(32) #define _BM_FILE_WIDTH 22 #define BM_FILE_WIDTH SCALE(22) #define _BM_FILE_HEIGHT 20 #define BM_FILE_HEIGHT SCALE(20) #define _BM_FILE_BIG_WIDTH 44 #define BM_FILE_BIG_WIDTH SCALE(44) #define _BM_FILE_BIG_HEIGHT 40 #define BM_FILE_BIG_HEIGHT SCALE(40) #define _BM_CI_WIDTH 20 #define BM_CI_WIDTH SCALE(20) /* SVG Bitmap names. */ typedef enum { BM_ONLINE = 1, BM_AWAY, BM_BUSY, BM_OFFLINE, BM_STATUS_NOTIFY, BM_ADD, BM_GROUPS, BM_TRANSFER, BM_SETTINGS, BM_SETTINGS_THREE_BAR, BM_LBUTTON, BM_SBUTTON, BM_SWITCH, BM_SWITCH_TOGGLE, BM_CONTACT, BM_CONTACT_MINI, BM_GROUP, BM_GROUP_MINI, BM_FILE, BM_DECLINE, BM_CALL, BM_VIDEO, BM_FT, BM_FTM, BM_FTB1, BM_FTB2, BM_FT_CAP, BM_NO, BM_PAUSE, BM_RESUME, BM_YES, BM_SCROLLHALFTOP, BM_SCROLLHALFBOT, BM_SCROLLHALFTOP_SMALL, BM_SCROLLHALFBOT_SMALL, BM_STATUSAREA, BM_CHAT_BUTTON_LEFT, BM_CHAT_BUTTON_RIGHT, BM_CHAT_BUTTON_OVERLAY_SCREENSHOT, BM_CHAT_SEND, BM_CHAT_SEND_OVERLAY, BM_ENDMARKER, } SVG_IMG; bool svg_draw(bool needmemory); #endif uTox/src/ui/svg.c0000600000175000001440000007321714003056216012657 0ustar rakusers#include "svg.h" #include "draw.h" #include "../debug.h" #include "../ui.h" #include "../macros.h" #include #include #define SQRT2 1.41421356237309504880168872420969807856967187537694807317667973799 static uint8_t pixel(double d) { if (d >= 1.0) { return 0; } else if (d <= 0.0) { return 0xFF; } else { return (1.0 - d) * 255.0; } } static uint8_t pixelmin(double d, uint8_t p) { if (d >= 1.0) { return p; } else if (d <= 0.0) { return 0; } else { uint8_t value = d * 255.0; if (value >= p) { return p; } else { return value; } } } static uint8_t pixelmax(double d, uint8_t p) { if (d >= 1.0) { return p; } else if (d <= 0.0) { return 0xFF; } else { uint8_t value = (1.0 - d) * 255.0; if (value >= p) { return value; } else { return p; } } } static void drawrectrounded(uint8_t *data, int width, int height, int radius) { double hw = (double)radius - 0.5; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { if ((x < radius || x >= width - radius) && (y < radius || y >= height - radius)) { double dx, dy; dx = (x < radius) ? x - hw : x + hw - width + 1.0; dy = (y < radius) ? y - hw : y + hw - height + 1.0; double d = sqrt(dx * dx + dy * dy) - hw; *data++ = pixel(d); } else { *data++ = 0xFF; } } } } static void drawrectroundedex(uint8_t *data, int width, int height, int radius, uint8_t flags) { bool left = ((flags & 1) != 0); /* 0001 */ bool right = ((flags & 2) != 0); /* 0010 */ bool top = ((flags & 4) != 0); /* 0100 */ bool bottom = ((flags & 8) != 0); /* 1000 */ double hw = (double)radius - 0.5; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { if (((left && x < radius) || (right && x >= width - radius)) && ((top && y < radius) || (bottom && y >= height - radius))) { double dx = (x < radius) ? x - hw : x + hw - width + 1.0; double dy = (y < radius) ? y - hw : y + hw - height + 1.0; double d = sqrt(dx * dx + dy * dy) - hw; *data++ = pixel(d); } else { *data++ = 0xFF; } } } } static void drawrectroundedsub(uint8_t *p, int width, int UNUSED(height), int sx, int sy, int sw, int sh, int radius) { double hw = (double)radius - 0.5; for (int y = sy; y != sy + sh; y++) { for (int x = sx; x != sx + sw; x++) { uint8_t *data = &p[y * width + x]; x -= sx; y -= sy; if ((x < radius || x >= sw - radius) && (y < radius || y >= sh - radius)) { double dx = (x < radius) ? x - hw : x + hw - sw + 1.0; double dy = (y < radius) ? y - hw : y + hw - sh + 1.0; double d = sqrt(dx * dx + dy * dy) - hw; *data = pixel(d); } else { *data = 0xFF; } x += sx; y += sy; } } } static void drawrectroundedneg(uint8_t *p, int width, int UNUSED(height), int sx, int sy, int sw, int sh, int radius) { double hw = (double)radius - 0.5; for (int y = sy; y != sy + sh; y++) { for (int x = sx; x != sx + sw; x++) { uint8_t *data = &p[y * width + x]; x -= sx; y -= sy; if ((x < radius || x >= sw - radius) && (y < radius || y >= sh - radius)) { double dx = (x < radius) ? x - hw : x + hw - sw + 1.0; double dy = (y < radius) ? y - hw : y + hw - sh + 1.0; double d = sqrt(dx * dx + dy * dy) - hw; *data = 0xFF - pixel(d); } else { *data = 0; } x += sx; y += sy; } } } static void drawcircle(uint8_t *data, int width) { double hw = (double)width / 2.0 - 0.5; for (int y = 0; y != width; y++) { for (int x = 0; x != width; x++) { double dx = (x - hw), dy = (y - hw); double d = sqrt(dx * dx + dy * dy) - hw + 0.5; *data++ = pixel(d); } } } static void drawnewcircle(uint8_t *data, int width, int height, double cx, double cy, double subwidth) { double hw = cx - 0.5, vw = cy - 0.5, sw = (double)subwidth / 2.0; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { double dx = (x - hw), dy = (y - vw); double d = sqrt(dx * dx + dy * dy) - sw; *data = pixelmax(d, *data); data++; } } } static void drawnewcircle2(uint8_t *data, int width, int height, double cx, double cy, double subwidth, uint8_t flags) { double hw = cx - 0.5, vw = cy - 0.5, sw = (double)subwidth / 2.0; bool b = (flags & 1) != 0; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { double dx = (x - hw), dy = (y - vw); if (b && dy > 0) { dy *= 1.25; } if (!b && dx > 0) { dx *= 1.25; } double d = sqrt(dx * dx + dy * dy) - sw; if ((b && dx < 0) || (!b && dy < 0)) { *data++ = pixel(d); } else { *data = pixelmax(d, *data); data++; } } } } static void drawhead(uint8_t *data, int width, double cx, double cy, double subwidth) { double hw = (double)cx - 0.5, vw = (double)cy - 0.5, sw = (double)subwidth / 2.0; for (int y = 0; y != width; y++) { for (int x = 0; x != width; x++) { double dx = (x - hw), dy = (y - vw); if (dy > 0) { dy *= 0.75; } double d = sqrt(dx * dx + dy * dy) - sw; *data = pixelmax(d, *data); data++; } } } static void drawsubcircle(uint8_t *data, int width, int height, double cx, double cy, double subwidth) { double hw = cx - 0.5, vw = cy - 0.5, sw = subwidth / 2.0; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { double dx = (x - hw), dy = (y - vw); double d = sqrt(dx * dx + dy * dy) - sw; *data = pixelmin(d, *data); data++; } } } static void drawcross(uint8_t *data, int width) { double hw = 0.5 * (double)(width - 1); double w = 0.0625 * (double)width; for (int y = 0; y != width; y++) { for (int x = 0; x != width; x++) { double dx = fabs(x - hw), dy = fabs(y - hw); double d = fmin(dx, dy) - w; *data++ = pixel(d); } } } static void drawxcross(uint8_t *data, int width, int height, int radius) { double cx = 0.5 * (double)(width - 1); double cy = 0.5 * (double)(height - 1); double w = 0.0625 * (double)radius; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { double dx = (double)x - cx, dy = (double)y - cy; double d1 = (SQRT2 / 2.0) * fabs(dx + dy), d2 = (SQRT2 / 2.0) * fabs(dx - dy); double d = fmin(d1, d2) - w; d = fmax(fabs(dx) + fabs(dy) - (SQRT2 / 2.0) * (double)height - w, d); *data = pixelmax(d, *data); data++; } } } static void drawline(uint8_t *data, int width, int height, double sx, double sy, double span, double radius) { double cx = sx - 0.5, cy = sy - 0.5; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { double dx = (double)x - cx, dy = (double)y - cy; double d = (SQRT2 / 2.0) * fabs(dx + dy) - radius; d = fmax(fabs(dx) + fabs(dy) - (SQRT2 / 2.0) * (double)span - radius, d); *data = pixelmax(d, *data); data++; } } } static void drawlinedown(uint8_t *data, int width, int height, double sx, double sy, double span, double radius) { double cx = sx - 0.5, cy = sy - 0.5; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { double dx = (double)x - cx, dy = (double)y - cy; double d = (SQRT2 / 2.0) * fabs(dx - dy) - radius; d = fmax(fabs(dx) + fabs(dy) - (SQRT2 / 2.0) * (double)span - radius, d); *data = pixelmax(d, *data); data++; } } } static void svgdraw_line_neg(uint8_t *data, int width, int height, double sx, double sy, double span, double radius) { double cx = sx - 0.5, cy = sy - 0.5; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { double dx = (double)x - cx, dy = (double)y - cy; double d = (SQRT2 / 2.0) * fabs(dx + dy) - radius; d = fmax(fabs(dx) + fabs(dy) - (SQRT2 / 2.0) * (double)span - radius, d); *data = pixelmin(d, *data); data++; } } } static void svgdraw_line_down_neg(uint8_t *data, int width, int height, double sx, double sy, double span, double radius) { double cx = sx - 0.5, cy = sy - 0.5; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { double dx = (double)x - cx, dy = (double)y - cy; double d = (SQRT2 / 2.0) * fabs(dx - dy) - radius; d = fmax(fabs(dx) + fabs(dy) - (SQRT2 / 2.0) * (double)span - radius, d); *data = pixelmin(d, *data); data++; } } } static void drawlinevert(uint8_t *data, int width, int height, double sx, double w) { double cx = sx + w / 2.0 - 0.5; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { double d = fabs((double)x - cx) - w / 2.0; *data = pixelmax(d, *data); data++; } } } static void drawtri(uint8_t *data, int width, int height, double sx, double sy, double size, uint8_t dir) { double cx = sx - 0.5, cy = sy - 0.5; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { double dx = (double)x - cx, dy = (double)y - cy; if (!dir) { if (dx < 0.0 && dy > 0.0) { double d = -dx + dy - size; *data = pixelmax(d, *data); } } else { if (dx > 0.0 && dy < 0.0) { double d = dx - dy - size; *data = pixelmax(d, *data); } } data++; } } } static void drawlineround(uint8_t *data, int width, int height, double sx, double sy, double span, double radius, double subwidth, uint8_t flags) { double cx = sx - 0.5, cy = sy - 0.5, sw = (double)subwidth / 2.0; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { double dx = (double)x - cx, dy = (double)y - cy; double d = (SQRT2 / 2.0) * fabs(dx + dy) - radius; d = fmax(fabs(dx) + fabs(dy) - (SQRT2 / 2.0) * (double)span - radius, d); double ddx, ddy, d2; if (!flags) { ddx = (double)x - cx - span * SQRT2; ddy = (double)y - cy + span * SQRT2; d2 = sqrt(ddx * ddx + ddy * ddy) - sw; d = fmin(d, d2); } ddx = (double)x - cx + span * SQRT2; ddy = (double)y - cy - span * SQRT2; d2 = sqrt(ddx * ddx + ddy * ddy) - sw; d = fmin(d, d2); *data = pixelmax(d, *data); data++; } } } static void drawlineroundempty(uint8_t *data, int width, int height, double sx, double sy, double span, double radius, double subwidth) { double cx = sx - 0.5, cy = sy - 0.5, sw = (double)subwidth / 2.0; for (int y = 0; y != height; y++) { for (int x = 0; x != width; x++) { double dx = (double)x - cx, dy = (double)y - cy; double d = (SQRT2 / 2.0) * fabs(dx + dy) - radius; d = fmax(fabs(dx) + fabs(dy) - (SQRT2 / 2.0) * (double)span - radius, d); double ddx = (double)x - cx - span * SQRT2, ddy = (double)y - cy + span * SQRT2; double d2 = sqrt(ddx * ddx + ddy * ddy) - sw; d = fmin(d, d2); ddx = (double)x - cx + span * SQRT2; ddy = (double)y - cy - span * SQRT2; d2 = sqrt(ddx * ddx + ddy * ddy) - sw; d = fmin(d, d2); *data = pixelmin(d, *data); data++; } } } static void drawgroup(uint8_t *data, int width) { double s = (double)width / BM_CONTACT_WIDTH; drawnewcircle(data, width, s * SCALE(18), s * SCALE(10), s * SCALE(18), s * SCALE(15)); drawnewcircle(data, width, s * SCALE(18), s * SCALE(30), s * SCALE(18), s * SCALE(15)); drawsubcircle(data, width, width, s * SCALE(10), s * SCALE(8), s * SCALE(9)); drawsubcircle(data, width, width, s * SCALE(30), s * SCALE(8), s * SCALE(9)); drawhead(data, width, s * SCALE(10), s * SCALE(6), s * SCALE(9)); drawhead(data, width, s * SCALE(30), s * SCALE(6), s * SCALE(9)); drawnewcircle(data, width, s * SCALE(40), s * SCALE(20), s * SCALE(40), s * SCALE(29)); drawsubcircle(data, width, width, s * SCALE(20), s * SCALE(24), s * SCALE(13)); drawsubcircle(data, width, width, s * SCALE(20), s * SCALE(16), s * SCALE(19)); drawhead(data, width, s * SCALE(20), s * SCALE(16), s * SCALE(15)); } bool svg_draw(bool needmemory) { static uint8_t *svg_data = NULL; if (svg_data) { free(svg_data); } /* Build what we expect the size to be. * This section uses unnamed shortcuts, so it really serves no purpose and makes it harder to debug, it needs to be * fixed, without shortcuts, and proper comments... TODO FIXME */ // comments behind the lines match with the comments of the code below that fills the memory int size = SCROLL_WIDTH * SCROLL_WIDTH + /* Scroll bars top bottom halves */ SCROLL_WIDTH * SCROLL_WIDTH / 2 + /* Scroll bars top bottom halves (small)*/ BM_STATUSAREA_WIDTH * BM_STATUSAREA_HEIGHT + /* status area */ /* Panel buttons */ BM_ADD_WIDTH * BM_ADD_WIDTH + /* Draw panel Button: Add */ BM_ADD_WIDTH * BM_ADD_WIDTH + /* New group bitmap */ BM_ADD_WIDTH * BM_ADD_WIDTH + /* Draw panel Button: Transfer */ BM_ADD_WIDTH * BM_ADD_WIDTH + /* Settings gear bitmap */ BM_CONTACT_WIDTH * BM_CONTACT_WIDTH + /* Contact avatar default bitmap */ BM_CONTACT_WIDTH / 2 * BM_CONTACT_WIDTH / 2 + /* Contact avatar default bitmap for mini roster */ BM_CONTACT_WIDTH * BM_CONTACT_WIDTH + /* Group heads default bitmap */ BM_CONTACT_WIDTH / 2 * BM_CONTACT_WIDTH / 2 + /* Group heads default bitmap for mini roster */ BM_FILE_WIDTH * BM_FILE_HEIGHT + /* Draw button icon overlays: file paper clip */ BM_LBICON_WIDTH * BM_LBICON_HEIGHT + /* Call button icon */ BM_LBICON_WIDTH * BM_LBICON_HEIGHT + /* Call button icon */ BM_LBICON_WIDTH * BM_LBICON_HEIGHT + /* Video start end bitmap */ BM_STATUS_WIDTH * BM_STATUS_WIDTH + /* user status: online */ BM_STATUS_WIDTH * BM_STATUS_WIDTH + /* user status: away */ BM_STATUS_WIDTH * BM_STATUS_WIDTH + /* user status: busy */ BM_STATUS_WIDTH * BM_STATUS_WIDTH + /* user status: offline */ BM_STATUS_NOTIFY_WIDTH * BM_STATUS_NOTIFY_WIDTH + /* user status: notification */ BM_LBUTTON_WIDTH * BM_LBUTTON_HEIGHT + /* Generic Large Button */ BM_SBUTTON_WIDTH * BM_SBUTTON_HEIGHT + /* Generic Small Button */ BM_SWITCH_WIDTH * BM_SWITCH_HEIGHT + /* Switch */ BM_SWITCH_TOGGLE_WIDTH * BM_SWITCH_TOGGLE_HEIGHT + /* Switch toggle */ /* File transfer */ BM_FT_CAP_WIDTH * BM_FTB_HEIGHT + BM_FT_WIDTH * BM_FT_HEIGHT + BM_FTM_WIDTH * BM_FT_HEIGHT + (BM_FTB_WIDTH * (BM_FTB_HEIGHT + SCALE(1)) + BM_FTB_WIDTH * BM_FTB_HEIGHT) + BM_FB_WIDTH * BM_FB_HEIGHT * 4 + /* Chat Buttons */ BM_CHAT_BUTTON_WIDTH * BM_CHAT_BUTTON_HEIGHT * 2 + // Chat button 1, 2 BM_CHAT_SEND_WIDTH * BM_CHAT_SEND_HEIGHT + BM_CHAT_SEND_OVERLAY_WIDTH * BM_CHAT_SEND_OVERLAY_HEIGHT + BM_CHAT_BUTTON_OVERLAY_WIDTH * BM_CHAT_BUTTON_OVERLAY_HEIGHT; svg_data = calloc(1, size); if (!svg_data) { return false; } uint8_t *p = svg_data; /* Scroll bars top bottom halves */ drawcircle(p, SCROLL_WIDTH); loadalpha(BM_SCROLLHALFTOP, p, SCROLL_WIDTH, SCROLL_WIDTH / 2); loadalpha(BM_SCROLLHALFBOT, p + SCROLL_WIDTH * SCROLL_WIDTH / 2, SCROLL_WIDTH, SCROLL_WIDTH / 2); p += SCROLL_WIDTH * SCROLL_WIDTH; /* Scroll bars top bottom halves (small)*/ drawcircle(p, SCROLL_WIDTH / 2); loadalpha(BM_SCROLLHALFTOP_SMALL, p, SCROLL_WIDTH / 2, SCROLL_WIDTH / 4); loadalpha(BM_SCROLLHALFBOT_SMALL, p + SCROLL_WIDTH / 2 * SCROLL_WIDTH / 4, SCROLL_WIDTH / 2, SCROLL_WIDTH / 4); p += SCROLL_WIDTH * SCROLL_WIDTH / 2; /* status area */ drawrectrounded(p, BM_STATUSAREA_WIDTH, BM_STATUSAREA_HEIGHT, SCALE(4)); loadalpha(BM_STATUSAREA, p, BM_STATUSAREA_WIDTH, BM_STATUSAREA_HEIGHT); p += BM_STATUSAREA_WIDTH * BM_STATUSAREA_HEIGHT; /* Draw panel Button: Add */ drawcross(p, BM_ADD_WIDTH); loadalpha(BM_ADD, p, BM_ADD_WIDTH, BM_ADD_WIDTH); p += BM_ADD_WIDTH * BM_ADD_WIDTH; /* New group bitmap */ drawgroup(p, BM_ADD_WIDTH); loadalpha(BM_GROUPS, p, BM_ADD_WIDTH, BM_ADD_WIDTH); p += BM_ADD_WIDTH * BM_ADD_WIDTH; /* Draw panel Button: Transfer */ drawline(p, BM_ADD_WIDTH, BM_ADD_WIDTH, SCALE(6), SCALE(6), SCALE(10), SCALE(1.5)); drawline(p, BM_ADD_WIDTH, BM_ADD_WIDTH, SCALE(12), SCALE(12), SCALE(10), SCALE(1.5)); drawtri(p, BM_ADD_WIDTH, BM_ADD_WIDTH, SCALE(12), 0, SCALE(8), 0); drawtri(p, BM_ADD_WIDTH, BM_ADD_WIDTH, SCALE(6), SCALE(18), SCALE(8), 1); loadalpha(BM_TRANSFER, p, BM_ADD_WIDTH, BM_ADD_WIDTH); p += BM_ADD_WIDTH * BM_ADD_WIDTH; /* Settings gear bitmap */ drawcross(p, BM_ADD_WIDTH); drawxcross(p, BM_ADD_WIDTH, BM_ADD_WIDTH, BM_ADD_WIDTH); drawnewcircle(p, BM_ADD_WIDTH, BM_ADD_WIDTH, 0.5 * BM_ADD_WIDTH, 0.5 * BM_ADD_WIDTH, SCALE(14)); drawsubcircle(p, BM_ADD_WIDTH, BM_ADD_WIDTH, 0.5 * BM_ADD_WIDTH, 0.5 * BM_ADD_WIDTH, SCALE(6)); loadalpha(BM_SETTINGS, p, BM_ADD_WIDTH, BM_ADD_WIDTH); p += BM_ADD_WIDTH * BM_ADD_WIDTH; /* Contact avatar default bitmap */ drawnewcircle(p, BM_CONTACT_WIDTH, SCALE(36), SCALE(20), SCALE(36), SCALE(28)); drawsubcircle(p, BM_CONTACT_WIDTH, BM_CONTACT_WIDTH, SCALE(20), SCALE(20), SCALE(12)); drawhead(p, BM_CONTACT_WIDTH, SCALE(20), SCALE(12), SCALE(16)); loadalpha(BM_CONTACT, p, BM_CONTACT_WIDTH, BM_CONTACT_WIDTH); p += BM_CONTACT_WIDTH * BM_CONTACT_WIDTH; /* Contact avatar default bitmap for mini roster */ drawnewcircle(p, BM_CONTACT_WIDTH / 2, SCALE(18), SCALE(10), SCALE(18), SCALE(14)); drawsubcircle(p, BM_CONTACT_WIDTH / 2, BM_CONTACT_WIDTH / 2, SCALE(10), SCALE(10), SCALE(6)); drawhead(p, BM_CONTACT_WIDTH / 2, SCALE(10), SCALE(6), SCALE(8)); loadalpha(BM_CONTACT_MINI, p, BM_CONTACT_WIDTH / 2, BM_CONTACT_WIDTH / 2); p += BM_CONTACT_WIDTH / 2 * BM_CONTACT_WIDTH / 2; /* Group heads default bitmap */ drawgroup(p, BM_CONTACT_WIDTH); loadalpha(BM_GROUP, p, BM_CONTACT_WIDTH, BM_CONTACT_WIDTH); p += BM_CONTACT_WIDTH * BM_CONTACT_WIDTH; /* Group heads default bitmap for mini roster */ drawgroup(p, BM_CONTACT_WIDTH / 2); loadalpha(BM_GROUP_MINI, p, BM_CONTACT_WIDTH / 2, BM_CONTACT_WIDTH / 2); p += BM_CONTACT_WIDTH / 2 * BM_CONTACT_WIDTH / 2; /* Draw button icon overlays. */ drawlineround(p, BM_FILE_WIDTH, BM_FILE_HEIGHT, UI_FSCALE(10), UI_FSCALE(10), UI_FSCALE(2), UI_FSCALE(8.3), UI_FSCALE(14), 0); drawlineroundempty(p, BM_FILE_WIDTH, BM_FILE_HEIGHT, UI_FSCALE(10), UI_FSCALE(10), UI_FSCALE(2), UI_FSCALE(6.5), UI_FSCALE(11)); drawsubcircle(p, BM_FILE_WIDTH, BM_FILE_HEIGHT, UI_FSCALE(11), UI_FSCALE(18), UI_FSCALE(6)); drawlineround(p, BM_FILE_WIDTH, BM_FILE_HEIGHT, UI_FSCALE(12), UI_FSCALE(12), UI_FSCALE(1), UI_FSCALE(4.5), UI_FSCALE(7.5), 1); drawlineroundempty(p, BM_FILE_WIDTH, BM_FILE_HEIGHT, UI_FSCALE(13), UI_FSCALE(11), UI_FSCALE(1.5), UI_FSCALE(3), UI_FSCALE(5.5)); loadalpha(BM_FILE, p, BM_FILE_WIDTH, BM_FILE_HEIGHT); p += BM_FILE_WIDTH * BM_FILE_HEIGHT; /* Decline call button icon */ drawnewcircle(p, BM_LBICON_WIDTH, BM_LBICON_HEIGHT, SCALE(11), SCALE(25), SCALE(38)); drawsubcircle(p, BM_LBICON_WIDTH, BM_LBICON_HEIGHT, SCALE(11), SCALE(25), SCALE(30)); drawnewcircle(p, BM_LBICON_WIDTH, BM_LBICON_HEIGHT, SCALE(3), SCALE(11), SCALE(6)); drawnewcircle(p, BM_LBICON_WIDTH, BM_LBICON_HEIGHT, SCALE(19.5), SCALE(11), SCALE(6)); loadalpha(BM_DECLINE, p, BM_LBICON_WIDTH, BM_LBICON_HEIGHT); p += BM_LBICON_WIDTH * BM_LBICON_HEIGHT; /* Call button icon */ drawnewcircle(p, BM_LBICON_WIDTH, BM_LBICON_HEIGHT, SCALE(1), 0, SCALE(38)); drawsubcircle(p, BM_LBICON_WIDTH, BM_LBICON_HEIGHT, SCALE(1), 0, SCALE(30)); drawnewcircle2(p, BM_LBICON_WIDTH, BM_LBICON_HEIGHT, SCALE(18), SCALE(4), SCALE(6), 0); drawnewcircle2(p, BM_LBICON_WIDTH, BM_LBICON_HEIGHT, SCALE(6), SCALE(16), SCALE(6), 1); loadalpha(BM_CALL, p, BM_LBICON_WIDTH, BM_LBICON_HEIGHT); p += BM_LBICON_WIDTH * BM_LBICON_HEIGHT; /* Video start end bitmap */ uint8_t *data = p; /* left triangle lens thing */ for (int y = 0; y != BM_LBICON_HEIGHT; y++) { for (int x = 0; x != SCALE(8); x++) { double d = abs(y - SCALE(9)) - 0.66 * (SCALE(8) - x); *data++ = pixel(d); } data += BM_LBICON_WIDTH - SCALE(8); } drawrectroundedsub(p, BM_LBICON_WIDTH, BM_LBICON_HEIGHT, SCALE(8), SCALE(1), SCALE(14), SCALE(14), SCALE(1)); loadalpha(BM_VIDEO, p, BM_LBICON_WIDTH, BM_LBICON_HEIGHT); p += BM_LBICON_WIDTH * BM_LBICON_HEIGHT; /* user status: online */ int s = BM_STATUS_WIDTH * BM_STATUS_WIDTH; drawcircle(p, BM_STATUS_WIDTH); loadalpha(BM_ONLINE, p, BM_STATUS_WIDTH, BM_STATUS_WIDTH); p += s; /* user status: away */ drawcircle(p, BM_STATUS_WIDTH); drawsubcircle(p, BM_STATUS_WIDTH, BM_STATUS_WIDTH / 2, 0.5 * BM_STATUS_WIDTH, 0.5 * BM_STATUS_WIDTH, SCALE(6)); loadalpha(BM_AWAY, p, BM_STATUS_WIDTH, BM_STATUS_WIDTH); p += s; /* user status: busy */ drawcircle(p, BM_STATUS_WIDTH); drawsubcircle(p, BM_STATUS_WIDTH, BM_STATUS_WIDTH / 2, 0.5 * BM_STATUS_WIDTH, 0.5 * BM_STATUS_WIDTH, SCALE(6)); loadalpha(BM_BUSY, p, BM_STATUS_WIDTH, BM_STATUS_WIDTH); p += s; /* user status: offline */ drawcircle(p, BM_STATUS_WIDTH); drawsubcircle(p, BM_STATUS_WIDTH, BM_STATUS_WIDTH, 0.5 * BM_STATUS_WIDTH, 0.5 * BM_STATUS_WIDTH, SCALE(6)); loadalpha(BM_OFFLINE, p, BM_STATUS_WIDTH, BM_STATUS_WIDTH); p += s; /* user status: notification */ drawcircle(p, BM_STATUS_NOTIFY_WIDTH); drawsubcircle(p, BM_STATUS_NOTIFY_WIDTH, BM_STATUS_NOTIFY_WIDTH, 0.5 * BM_STATUS_NOTIFY_WIDTH, 0.5 * BM_STATUS_NOTIFY_WIDTH, SCALE(10)); loadalpha(BM_STATUS_NOTIFY, p, BM_STATUS_NOTIFY_WIDTH, BM_STATUS_NOTIFY_WIDTH); p += BM_STATUS_NOTIFY_WIDTH * BM_STATUS_NOTIFY_WIDTH; /* Generic button icons */ drawrectrounded(p, BM_LBUTTON_WIDTH, BM_LBUTTON_HEIGHT, SCALE(4)); loadalpha(BM_LBUTTON, p, BM_LBUTTON_WIDTH, BM_LBUTTON_HEIGHT); p += BM_LBUTTON_WIDTH * BM_LBUTTON_HEIGHT; drawrectrounded(p, BM_SBUTTON_WIDTH, BM_SBUTTON_HEIGHT, SCALE(4)); loadalpha(BM_SBUTTON, p, BM_SBUTTON_WIDTH, BM_SBUTTON_HEIGHT); p += BM_SBUTTON_WIDTH * BM_SBUTTON_HEIGHT; /* Outer part of the switch */ drawrectrounded(p, BM_SWITCH_WIDTH, BM_SWITCH_HEIGHT, SCALE(4)); loadalpha(BM_SWITCH, p, BM_SWITCH_WIDTH, BM_SWITCH_HEIGHT); p += BM_SWITCH_WIDTH * BM_SWITCH_HEIGHT; /* Switch toggle */ drawrectrounded(p, BM_SWITCH_TOGGLE_WIDTH, BM_SWITCH_TOGGLE_HEIGHT, SCALE(4)); loadalpha(BM_SWITCH_TOGGLE, p, BM_SWITCH_TOGGLE_WIDTH, BM_SWITCH_TOGGLE_HEIGHT); p += BM_SWITCH_TOGGLE_WIDTH * BM_SWITCH_TOGGLE_HEIGHT; /* Draw file transfer buttons */ drawrectroundedex(p, BM_FT_CAP_WIDTH, BM_FTB_HEIGHT, SCALE(4), 13); loadalpha(BM_FT_CAP, p, BM_FT_CAP_WIDTH, BM_FTB_HEIGHT); p += BM_FT_CAP_WIDTH * BM_FTB_HEIGHT; drawrectrounded(p, BM_FT_WIDTH, BM_FT_HEIGHT, SCALE(4)); loadalpha(BM_FT, p, BM_FT_WIDTH, BM_FT_HEIGHT); p += BM_FT_WIDTH * BM_FT_HEIGHT; drawrectroundedex(p, BM_FTM_WIDTH, BM_FT_HEIGHT, SCALE(4), 13); loadalpha(BM_FTM, p, BM_FTM_WIDTH, BM_FT_HEIGHT); p += BM_FTM_WIDTH * BM_FT_HEIGHT; drawrectroundedex(p, BM_FTB_WIDTH, BM_FTB_HEIGHT + SCALE(1), SCALE(4), 0); loadalpha(BM_FTB1, p, BM_FTB_WIDTH, BM_FTB_HEIGHT + SCALE(1)); p += BM_FTB_WIDTH * (BM_FTB_HEIGHT + SCALE(1)); drawrectroundedex(p, BM_FTB_WIDTH, BM_FTB_HEIGHT, SCALE(4), 14); loadalpha(BM_FTB2, p, BM_FTB_WIDTH, BM_FTB_HEIGHT); p += BM_FTB_WIDTH * BM_FTB_HEIGHT; /* Used by the next few lines */ s = BM_FB_WIDTH * BM_FB_HEIGHT; drawxcross(p, BM_FB_WIDTH, BM_FB_HEIGHT, BM_FB_HEIGHT); loadalpha(BM_NO, p, BM_FB_WIDTH, BM_FB_HEIGHT); p += s; drawlinevert(p, BM_FB_WIDTH, BM_FB_HEIGHT, SCALE(1.5), SCALE(2.5)); drawlinevert(p, BM_FB_WIDTH, BM_FB_HEIGHT, SCALE(8.5), SCALE(2.5)); loadalpha(BM_PAUSE, p, BM_FB_WIDTH, BM_FB_HEIGHT); p += s; drawline(p, BM_FB_WIDTH, BM_FB_HEIGHT, SCALE(2.5), SCALE(7), SCALE(5), SCALE(1)); drawline(p, BM_FB_WIDTH, BM_FB_HEIGHT, SCALE(8), SCALE(7), SCALE(5), SCALE(1)); drawlinedown(p, BM_FB_WIDTH, BM_FB_HEIGHT, SCALE(2.5), SCALE(2.5), SCALE(5), SCALE(1)); drawlinedown(p, BM_FB_WIDTH, BM_FB_HEIGHT, SCALE(8), SCALE(2.5), SCALE(5), SCALE(1)); loadalpha(BM_RESUME, p, BM_FB_WIDTH, BM_FB_HEIGHT); p += s; drawline(p, BM_FB_WIDTH, BM_FB_HEIGHT, SCALE(8), SCALE(6), SCALE(8), SCALE(1)); drawlinedown(p, BM_FB_WIDTH, BM_FB_HEIGHT, SCALE(3), SCALE(6), SCALE(3.5), SCALE(1)); loadalpha(BM_YES, p, BM_FB_WIDTH, BM_FB_HEIGHT); p += s; /* the two small chat buttons... */ drawrectroundedex(p, BM_CHAT_BUTTON_WIDTH, BM_CHAT_BUTTON_HEIGHT, SCALE(4), 13); loadalpha(BM_CHAT_BUTTON_LEFT, p, BM_CHAT_BUTTON_WIDTH, BM_CHAT_BUTTON_HEIGHT); p += BM_CHAT_BUTTON_WIDTH * BM_CHAT_BUTTON_HEIGHT; drawrectroundedex(p, BM_CHAT_BUTTON_WIDTH, BM_CHAT_BUTTON_HEIGHT, SCALE(4), 0); loadalpha(BM_CHAT_BUTTON_RIGHT, p, BM_CHAT_BUTTON_WIDTH, BM_CHAT_BUTTON_HEIGHT); p += BM_CHAT_BUTTON_WIDTH * BM_CHAT_BUTTON_HEIGHT; /* Draw chat send button */ drawrectroundedex(p, BM_CHAT_SEND_WIDTH, BM_CHAT_SEND_HEIGHT, SCALE(8), 14); loadalpha(BM_CHAT_SEND, p, BM_CHAT_SEND_WIDTH, BM_CHAT_SEND_HEIGHT); p += BM_CHAT_SEND_WIDTH * BM_CHAT_SEND_HEIGHT; /* Draw chat send overlay */ drawnewcircle(p, BM_CHAT_SEND_OVERLAY_WIDTH, BM_CHAT_SEND_OVERLAY_HEIGHT, SCALE(20), SCALE(14), SCALE(26)); drawtri(p, BM_CHAT_SEND_OVERLAY_WIDTH, BM_CHAT_SEND_OVERLAY_HEIGHT, SCALE(30), SCALE(18), SCALE(12), 0); loadalpha(BM_CHAT_SEND_OVERLAY, p, BM_CHAT_SEND_OVERLAY_WIDTH, BM_CHAT_SEND_OVERLAY_HEIGHT); p += BM_CHAT_SEND_OVERLAY_WIDTH * BM_CHAT_SEND_OVERLAY_HEIGHT; /* screen shot button overlay */ /* Rounded frame */ drawrectroundedsub(p, BM_CHAT_BUTTON_OVERLAY_WIDTH, BM_CHAT_BUTTON_OVERLAY_HEIGHT, SCALE(1), SCALE(1), BM_CHAT_BUTTON_OVERLAY_WIDTH - (SCALE(8)), BM_CHAT_BUTTON_OVERLAY_HEIGHT - (SCALE(8)), SCALE(1)); drawrectroundedneg(p, BM_CHAT_BUTTON_OVERLAY_WIDTH, BM_CHAT_BUTTON_OVERLAY_HEIGHT, /* width, height */ SCALE(4), SCALE(4), /* start x, y */ BM_CHAT_BUTTON_OVERLAY_WIDTH - (SCALE(12)), BM_CHAT_BUTTON_OVERLAY_HEIGHT - (SCALE(12)), SCALE(1)); /* camera shutter circle */ drawnewcircle(p, BM_CHAT_BUTTON_OVERLAY_WIDTH, BM_CHAT_BUTTON_OVERLAY_HEIGHT, BM_CHAT_BUTTON_OVERLAY_WIDTH * 0.75, BM_CHAT_BUTTON_OVERLAY_HEIGHT * 0.75, SCALE(12)); drawsubcircle(p, BM_CHAT_BUTTON_OVERLAY_WIDTH, BM_CHAT_BUTTON_OVERLAY_HEIGHT, BM_CHAT_BUTTON_OVERLAY_WIDTH * 0.75, BM_CHAT_BUTTON_OVERLAY_HEIGHT * 0.75, SCALE(4)); /* shutter lines */ svgdraw_line_neg(p, BM_CHAT_BUTTON_OVERLAY_WIDTH, BM_CHAT_BUTTON_OVERLAY_HEIGHT, BM_CHAT_BUTTON_OVERLAY_WIDTH * 0.80, BM_CHAT_BUTTON_OVERLAY_HEIGHT * 0.65, SCALE(4), 0.1); svgdraw_line_neg(p, BM_CHAT_BUTTON_OVERLAY_WIDTH, BM_CHAT_BUTTON_OVERLAY_HEIGHT, BM_CHAT_BUTTON_OVERLAY_WIDTH * 0.73, BM_CHAT_BUTTON_OVERLAY_HEIGHT * 0.87, SCALE(4), 0.1); svgdraw_line_down_neg(p, BM_CHAT_BUTTON_OVERLAY_WIDTH, BM_CHAT_BUTTON_OVERLAY_HEIGHT, BM_CHAT_BUTTON_OVERLAY_WIDTH * 0.65, BM_CHAT_BUTTON_OVERLAY_HEIGHT * 0.70, SCALE(4), 0.1); svgdraw_line_down_neg(p, BM_CHAT_BUTTON_OVERLAY_WIDTH, BM_CHAT_BUTTON_OVERLAY_HEIGHT, BM_CHAT_BUTTON_OVERLAY_WIDTH * 0.85, BM_CHAT_BUTTON_OVERLAY_HEIGHT * 0.81, SCALE(4), 0.1); loadalpha(BM_CHAT_BUTTON_OVERLAY_SCREENSHOT, p, BM_CHAT_BUTTON_OVERLAY_WIDTH, BM_CHAT_BUTTON_OVERLAY_HEIGHT); p += BM_CHAT_BUTTON_OVERLAY_WIDTH * BM_CHAT_BUTTON_OVERLAY_HEIGHT; if (p - svg_data != size) { LOG_WARN("SVG", "SVG data size mismatch..."); } if (!needmemory) { free(svg_data); svg_data = NULL; } return true; } uTox/src/ui/scrollable.h0000600000175000001440000000130714003056216014176 0ustar rakusers#ifndef SCROLLABLE_H #define SCROLLABLE_H #include "panel.h" #include struct scrollable { PANEL panel; uint32_t color; int x; bool small; double d; bool left, mousedown, mouseover, mouseover2; int content_height; }; void scroll_draw(SCROLLABLE *s, int x, int y, int width, int height); int scroll_gety(SCROLLABLE *s, int height); bool scroll_mmove(SCROLLABLE *s, int x, int y, int width, int height, int mx, int my, int dx, int dy); bool scroll_mdown(SCROLLABLE *s); bool scroll_mright(SCROLLABLE *s); bool scroll_mwheel(SCROLLABLE *s, int height, double delta, bool smooth); bool scroll_mup(SCROLLABLE *s); bool scroll_mleave(SCROLLABLE *s); #endif uTox/src/ui/scrollable.c0000600000175000001440000000735414003056216014201 0ustar rakusers#include "scrollable.h" #include "draw.h" #include "svg.h" #include "../macros.h" #include "../ui.h" void scroll_draw(SCROLLABLE *s, int x, int y, int width, int height) { uint32_t c = s->content_height; uint32_t h = height, m, dy; uint32_t scroll_width = 0; if (s->small) { scroll_width = SCROLL_WIDTH / 2; } else { scroll_width = SCROLL_WIDTH; } if (h >= c) { // If h(eight) > c(ontent height), don't draw anything. return; } else { m = (h * h) / c; double d = (h - m); dy = (s->d * d) + 0.5; } y += dy; x += s->x; if (!s->left) { x += width - scroll_width; } drawalpha(s->small ? BM_SCROLLHALFTOP_SMALL : BM_SCROLLHALFTOP, x, y, scroll_width, scroll_width / 2, s->color); y += scroll_width / 2; int y2 = y + m - scroll_width; if (scroll_width > m) { y2 = y; } drawrect(x, y, x + scroll_width, y2, s->color); drawalpha(s->small ? BM_SCROLLHALFBOT_SMALL : BM_SCROLLHALFBOT, x, y2, scroll_width, scroll_width / 2, s->color); } int scroll_gety(SCROLLABLE *s, int height) { int c = s->content_height; if (c > height) { return (s->d * (double)(c - height)) + 0.5; } return 0; } bool scroll_mmove(SCROLLABLE *s, int UNUSED(px), int UNUSED(py), int width, int height, int x, int y, int UNUSED(dx), int dy) { bool draw = false; bool hit = inrect(x, y, s->left ? 0 : (width - SCROLL_WIDTH), 0, SCROLL_WIDTH, height); if (s->mouseover != hit) { s->mouseover = hit; draw = true; } s->mouseover2 = inrect(x, y, 0, 0, width, height); if (s->mousedown) { uint32_t c = s->content_height; uint32_t h = height; if (c > h) { uint32_t m = (h * h) / c; double d = (h - m); s->d = ((s->d * d) + (double)dy) / d; if (s->d < 0.0) { s->d = 0.0; } else if (s->d >= 1.0) { s->d = 1.0; } draw = true; } } return draw; } bool scroll_mdown(SCROLLABLE *s) { if (s->mouseover) { s->mousedown = 1; return true; } return false; } bool scroll_mright(SCROLLABLE *UNUSED(s)) { return false; } bool scroll_mwheel(SCROLLABLE *s, int height, double delta, bool smooth) { /* Variable which controls scroll speed. How much one scroll step * moves viewport */ double scroll_speed_multip = 5.0; if (s->mouseover2) { uint32_t content_height = s->content_height; uint32_t port_height = height; if (content_height > port_height) { /* Scrolling is relative to amount of total content in component */ if (smooth) { // this seems to be the magic equation that makes it scroll at the same speed // regardless of how big the port is compared to the content. s->d -= (delta * (32.0 * port_height / content_height) / content_height) * scroll_speed_multip; } else { uint32_t magic = (port_height * port_height) / content_height; double fred = (port_height - magic); s->d -= 16.0 * delta / fred; } if (s->d < 0.0) { s->d = 0.0; } else if (s->d >= 1.0) { s->d = 1.0; } return true; } } return false; } bool scroll_mup(SCROLLABLE *s) { if (s->mousedown) { s->mousedown = 0; return true; } return false; } bool scroll_mleave(SCROLLABLE *s) { if (s->mouseover) { s->mouseover = 0; return true; } s->mouseover2 = 0; return false; } uTox/src/ui/panel.h0000600000175000001440000000126614003056216013157 0ustar rakusers#ifndef UI_PANEL_H #define UI_PANEL_H #include typedef enum { PANEL_NONE, PANEL_MAIN, PANEL_MESSAGES, PANEL_INLINE_VIDEO, PANEL_LIST, PANEL_BUTTON, PANEL_SWITCH, PANEL_DROPDOWN, PANEL_EDIT, PANEL_SCROLLABLE, } PANEL_TYPE; typedef struct panel PANEL; typedef struct scrollable SCROLLABLE; typedef void ui_draw_cb(int x, int y, int w, int h); typedef void ui_update_cb(int width, int height, int scale); struct panel { PANEL_TYPE type; bool disabled; int x, y, width, height; SCROLLABLE *content_scroll; ui_draw_cb *drawfunc; ui_update_cb *update; void *object; PANEL **child; }; #endif // UI_PANEL_H uTox/src/ui/edit.h0000600000175000001440000000442014003056216013000 0ustar rakusers#ifndef UI_EDIT_H #define UI_EDIT_H #include "panel.h" #include "../ui.h" /* TODO replace windows functions, multiline edits, add missing edit functions (ex: double click to select word)*/ #include #include typedef struct scrollable SCROLLABLE; typedef struct edit_change { bool remove, padding; uint16_t start, length; char data[]; } EDIT_CHANGE; typedef struct edit EDIT; struct edit { PANEL panel; bool multiline, mouseover, noborder, readonly, select_completely, vcentered, password; uint16_t mouseover_char, length; uint16_t width, height; uint16_t history_cur, history_length; EDIT_CHANGE **history; SCROLLABLE *scroll; char * data; size_t data_size; MAYBE_I18NAL_STRING empty_str; UI_ELEMENT_STYLE style; void (*onenter)(EDIT *edit); void (*onchange)(EDIT *edit); void (*ontab)(EDIT *edit); void (*onshifttab)(EDIT *edit); void (*onlosefocus)(EDIT *edit); }; void edit_draw(EDIT *edit, int x, int y, int width, int height); bool edit_mmove(EDIT *edit, int x, int y, int width, int height, int mx, int my, int dx, int dy); bool edit_mdown(EDIT *edit); bool edit_dclick(EDIT *edit, bool triclick); bool edit_mright(EDIT *edit); bool edit_mwheel(EDIT *edit, int height, double d, bool smooth); bool edit_mup(EDIT *edit); bool edit_mleave(EDIT *edit); void edit_do(EDIT *edit, uint16_t start, uint16_t length, bool remove); void edit_press(void); void edit_char(uint32_t ch, bool control, uint8_t flags); int edit_selection(EDIT *edit, char *data, int len); int edit_copy(char *data, int len); void edit_paste(char *data, int len, bool select); bool edit_active(void); EDIT *edit_get_active(void); void edit_resetfocus(void); void edit_setfocus(EDIT *edit); void edit_setstr(EDIT *edit, char *str, uint16_t length); void edit_setcursorpos(EDIT *edit, uint16_t pos); uint16_t edit_getcursorpos(void); // set outloc and outlen to the mark range. // returns 1 if the mark range is valid for the current edit, // else 0. // a mark range is valid when *outlen != 0 and there is an active edit. bool edit_getmark(uint16_t *outloc, uint16_t *outlen); void edit_setmark(uint16_t loc, uint16_t len); void edit_setselectedrange(uint16_t loc, uint16_t len); #endif // UI_EDIT_H uTox/src/ui/edit.c0000600000175000001440000006572514003056216013012 0ustar rakusers#include "edit.h" #include "contextmenu.h" #include "draw.h" #include "scrollable.h" #include "text.h" #include "../debug.h" #include "../macros.h" #include "../settings.h" #include "../text.h" #include "../theme.h" #include "../ui.h" #include "../native/clipboard.h" #include "../native/keyboard.h" #include "../native/os.h" #include "../native/ui.h" #include #include #include static EDIT *active_edit; static struct { uint16_t start, length; uint16_t p1, p2; // IME mark (underline) uint16_t mark_start, mark_length; } edit_sel; static bool edit_select; static void setactive(EDIT *edit) { if (edit != active_edit) { edit_will_deactivate(); if (active_edit && active_edit->onlosefocus) { active_edit->onlosefocus(active_edit); } active_edit = edit; } } void edit_draw(EDIT *edit, int x, int y, int width, int height) { if (width - SCALE(8) - SCALE(SCROLL_WIDTH) < 0) { // why? return; } if (settings.window_baseline && y > (int)settings.window_baseline - font_small_lineheight - SCALE(8)) { y = settings.window_baseline - font_small_lineheight - SCALE(8); } edit->width = width - SCALE(8) - (edit->multiline ? SCALE(SCROLL_WIDTH) : 0); edit->height = height - SCALE(8); // load colors for this style uint32_t color_bg, color_border, color_border_h, color_border_a, color_text; switch (edit->style) { case AUXILIARY_STYLE: color_bg = COLOR_BKGRND_AUX; color_border = COLOR_AUX_EDGE_NORMAL; color_border_h = COLOR_AUX_EDGE_HOVER; color_border_a = COLOR_AUX_EDGE_ACTIVE; color_text = COLOR_AUX_TEXT; break; default: color_bg = COLOR_BKGRND_MAIN; color_border = COLOR_EDGE_NORMAL; color_border_h = COLOR_EDGE_HOVER; color_border_a = COLOR_EDGE_ACTIVE; color_text = COLOR_MAIN_TEXT; break; } if (!edit->noborder) { draw_rect_frame(x, y, width, height, (edit == active_edit) ? color_border_a : (edit->mouseover ? color_border_h : color_border)); } draw_rect_fill(x + 1, y + 1, width - SCALE(2), height - SCALE(2), color_bg); setfont(FONT_TEXT); setcolor(color_text); int yy = y; if (edit->multiline) { pushclip(x + 1, y + 1, width - 2, height - 2); SCROLLABLE *scroll = edit->scroll; scroll->content_height = text_height(width - SCALE(8) - SCALE(SCROLL_WIDTH), font_small_lineheight, edit->data, edit->length) + SCALE(8); scroll_draw(scroll, x, y, width, height); yy -= scroll_gety(scroll, height); } /* because the search field has a padding of 3.5 SCALEs */ float top_offset = 2.0; if (edit->vcentered && !edit->multiline) { top_offset = (height - font_small_lineheight) / (SCALE(4.0)); } // display an edit hint if there's no text in the field if (!edit->length && maybe_i18nal_string_is_valid(&edit->empty_str)) { STRING *empty_str_text = maybe_i18nal_string_get(&edit->empty_str); setcolor(COLOR_MAIN_TEXT_HINT); drawtext(x + SCALE(4), yy + SCALE(top_offset* 2), empty_str_text->str, empty_str_text->length); } bool is_active = (edit == active_edit); char *star = NULL; if (edit->password && edit->length) { star = malloc(edit->length); if (!star) { LOG_FATAL_ERR(EXIT_MALLOC, "UI Edit", "Unable to malloc for password field"); } /* Generate the stars for this password */ memset(star, '*', edit->length); } utox_draw_text_multiline_within_box( x + SCALE(4), yy + SCALE(top_offset * 2), x + width - SCALE(4) - (edit->multiline ? SCALE(SCROLL_WIDTH) : 0), y, y + height, font_small_lineheight, star ? star : edit->data, edit->length, is_active ? edit_sel.start : UINT16_MAX, is_active ? edit_sel.length : UINT16_MAX, is_active ? edit_sel.mark_start : 0, is_active ? edit_sel.mark_length : 0, edit->multiline); free(star); if (edit->multiline) { popclip(); } } bool edit_mmove(EDIT *edit, int px, int py, int width, int height, int x, int y, int dx, int dy) { if (settings.window_baseline && py > (int)settings.window_baseline - font_small_lineheight - SCALE(8)) { y += py - (settings.window_baseline - font_small_lineheight - SCALE(8)); py = settings.window_baseline - font_small_lineheight - SCALE(8); } bool need_redraw = 0; bool mouseover = inrect(x, y, 0, 0, width - (edit->multiline ? SCALE(SCROLL_WIDTH) : 0), height); if (mouseover) { cursor = CURSOR_TEXT; } if (mouseover != edit->mouseover) { edit->mouseover = mouseover; if (edit != active_edit) { need_redraw = 1; } } if (edit->multiline) { need_redraw |= scroll_mmove(edit->scroll, px, py, width, height, x, y, dx, dy); y += scroll_gety(edit->scroll, height); } if (edit == active_edit && edit_select) { if (edit->select_completely) { edit_setfocus(edit); need_redraw = 1; return need_redraw; } setfont(FONT_TEXT); edit_sel.p2 = hittextmultiline(x - SCALE(4), width - SCALE(8) - (edit->multiline ? SCALE(SCROLL_WIDTH) : 0), y - SCALE(4), INT_MAX, font_small_lineheight, edit->data, edit->length, edit->multiline); uint16_t start, length; if (edit_sel.p2 > edit_sel.p1) { start = edit_sel.p1; length = edit_sel.p2 - edit_sel.p1; } else { start = edit_sel.p2; length = edit_sel.p1 - edit_sel.p2; } if (start != edit_sel.start || length != edit_sel.length) { edit_sel.start = start; edit_sel.length = length; need_redraw = 1; } } else if (mouseover) { setfont(FONT_TEXT); edit->mouseover_char = hittextmultiline(x - SCALE(4), width - SCALE(8) - (edit->multiline ? SCALE(SCROLL_WIDTH) : 0), y - SCALE(4), INT_MAX, font_small_lineheight, edit->data, edit->length, edit->multiline); } return need_redraw; } bool edit_mdown(EDIT *edit) { if (edit->mouseover_char > edit->length) { edit->mouseover_char = edit->length; } if (edit->multiline) { if (scroll_mdown(edit->scroll)) { return 1; } } if (edit->mouseover) { edit_sel.start = edit_sel.p1 = edit_sel.p2 = edit->mouseover_char; edit_sel.length = 0; edit_select = 1; setactive(edit); showkeyboard(1); return 1; } else if (edit == active_edit) { edit_resetfocus(); } return 0; } bool edit_dclick(EDIT *edit, bool triclick) { if (edit != active_edit) { return false; } if (edit->mouseover_char > edit->length) { edit->mouseover_char = edit->length; } uint16_t i = edit->mouseover_char; while (i != 0 && edit->data[i - 1] != '\n' /* If it's a dclick, also set ' ' as boundary, else do nothing. */ && (!triclick ? (edit->data[i - 1] != ' ') : 1)) { i -= utf8_unlen(edit->data + i); } edit_sel.start = edit_sel.p1 = i; i = edit->mouseover_char; while (i != edit->length && edit->data[i] != '\n' /* If it's a dclick, also set ' ' as boundary, else do nothing. */ && (!triclick ? (edit->data[i] != ' ') : 1)) { i += utf8_len(edit->data + i); } edit_sel.p2 = i; edit_sel.length = i - edit_sel.start; return true; } static void contextmenu_edit_onselect(uint8_t i) { switch (i) { case 0: copy(0); edit_char(KEY_DEL, 1, 0); break; case 1: copy(0); break; case 2: paste(); break; case 3: edit_char(KEY_DEL, 1, 0); break; case 4: /* Send a ctrl + a to the active edit */ edit_char('A', 1, 4); break; } } bool edit_mright(EDIT *edit) { static UTOX_I18N_STR menu_edit[] = { STR_CUT, STR_COPY, STR_PASTE, STR_DELETE, STR_SELECTALL }; if (edit->mouseover_char > edit->length) { edit->mouseover_char = edit->length; } if (edit->mouseover) { EDIT *active = active_edit; if (active != edit) { setactive(edit); edit_sel.start = edit_sel.p1 = edit_sel.p2 = edit->mouseover_char; edit_sel.length = 0; edit_select = 1; } contextmenu_new(COUNTOF(menu_edit), menu_edit, contextmenu_edit_onselect); return true; } else if (active_edit == edit) { edit_resetfocus(); // lose focus if right mouse button is pressed somewhere else return true; // redraw } return false; } void edit_press(void) { edit_sel.start = edit_sel.p1 = edit_sel.p2 = active_edit->mouseover_char; edit_sel.length = 0; } bool edit_mwheel(EDIT *edit, int height, double d, bool smooth) { if (edit->multiline) { return scroll_mwheel(edit->scroll, height - SCALE(8), d, smooth); } return false; } bool edit_mup(EDIT *edit) { if (edit->multiline) { if (scroll_mup(edit->scroll)) { return true; } } if (edit_select && edit == active_edit) { setselection(edit->data + edit_sel.start, edit_sel.length); edit_select = 0; } return false; } bool edit_mleave(EDIT *edit) { if (edit->mouseover) { edit->mouseover = false; return true; } return false; } static void edit_redraw(void) { redraw(); } static uint16_t edit_change_do(EDIT *edit, EDIT_CHANGE *c) { uint16_t r = c->start; if (c->remove) { memmove(edit->data + c->start + c->length, edit->data + c->start, edit->length - c->start); memcpy(edit->data + c->start, c->data, c->length); edit->length += c->length; r += c->length; } else { edit->length -= c->length; memmove(edit->data + c->start, edit->data + c->start + c->length, edit->length - c->start); } c->remove = !c->remove; return r; } void edit_do(EDIT *edit, uint16_t start, uint16_t length, bool remove) { EDIT_CHANGE *new_change; if (edit->history_cur != edit->history_length) { uint16_t i = edit->history_cur; while (i != edit->history_length) { free(edit->history[i++]); } } edit->history = realloc(edit->history, (edit->history_cur + 1) * sizeof(void *)); if (!edit->history) { LOG_FATAL_ERR(EXIT_MALLOC, "UI Edit", "Unable to realloc for edit history, this should never happen!"); } new_change = calloc(1, sizeof(EDIT_CHANGE) + length); if (!new_change) { LOG_FATAL_ERR(EXIT_MALLOC, "UI Edit", "Unable to calloc for new EDIT_CHANGE, this should never happen!"); } new_change->remove = remove; new_change->start = start; new_change->length = length; memcpy(new_change->data, edit->data + start, length); edit->history[edit->history_cur] = new_change; edit->history_cur++; edit->history_length = edit->history_cur; } static uint16_t edit_undo(EDIT *edit) { uint16_t r = UINT16_MAX; if (edit->history_cur) { edit->history_cur--; r = edit_change_do(edit, edit->history[edit->history_cur]); } return r; } static uint16_t edit_redo(EDIT *edit) { uint16_t r = UINT16_MAX; if (edit->history_cur != edit->history_length) { r = edit_change_do(edit, edit->history[edit->history_cur]); edit->history_cur++; } return r; } static void edit_del(EDIT *edit) { if (edit->readonly) { return; } char *p = active_edit->data + edit_sel.start; if (edit_sel.length) { edit_do(edit, edit_sel.start, edit_sel.length, 1); memmove(p, p + edit_sel.length, active_edit->length - (edit_sel.start + edit_sel.length)); active_edit->length -= edit_sel.length; } else if (edit_sel.start < active_edit->length) { uint8_t len = utf8_len(p); edit_do(edit, edit_sel.start, len, 1); memmove(p, p + len, active_edit->length - edit_sel.start - len); active_edit->length -= len; } edit_sel.p1 = edit_sel.start; edit_sel.p2 = edit_sel.start; edit_sel.length = 0; } #define updatesel() \ if (edit_sel.p1 <= edit_sel.p2) { \ edit_sel.start = edit_sel.p1; \ edit_sel.length = edit_sel.p2 - edit_sel.p1; \ } else { \ edit_sel.start = edit_sel.p2; \ edit_sel.length = edit_sel.p1 - edit_sel.p2; \ } enum { EMOD_SHIFT = (1 << 0), EMOD_CTRL = (1 << 2), }; void edit_char(uint32_t ch, bool control, uint8_t flags) { if (!active_edit) { LOG_ERR("UI Edit", "Stopped you from crashing because no edit was active or something."); return; } EDIT *edit = active_edit; // TODO this is bad // shift: flags & 1 // control: flags & 4 if (control || (ch <= 0x1F && (!edit->multiline || ch != '\n')) || (ch >= 0x7f && ch <= 0x9F)) { bool modified = false; switch (ch) { case KEY_BACK: { if (edit->readonly) { return; } if (edit_sel.length == 0) { uint16_t p = edit_sel.start; if (p == 0) { break; } modified = true; /* same as ctrl+left */ if (flags & EMOD_CTRL) { while (p != 0 && edit->data[p - 1] == ' ') { p--; } } if (p != 0) { do { p -= utf8_unlen(&edit->data[p]); } while ((flags & EMOD_CTRL) && p != 0 && edit->data[p - 1] != ' ' && edit->data[p - 1] != '\n'); } uint16_t len = edit_sel.start - p; edit_do(edit, edit_sel.start - len, len, 1); memmove(edit->data + edit_sel.start - len, edit->data + edit_sel.start, edit->length - edit_sel.start); edit->length -= len; edit_sel.start -= len; edit_sel.p1 = edit_sel.start; edit_sel.p2 = edit_sel.start; break; } edit_del(edit); modified = true; break; } case KEY_DEL: { edit_del(edit); modified = true; break; } case KEY_LEFT: { uint16_t p = edit_sel.p2; if (p != 0) { if (flags & EMOD_CTRL) { while (p != 0 && edit->data[p - 1] == ' ') { p--; } } if (p != 0) { do { p -= utf8_unlen(&edit->data[p]); } while ((flags & EMOD_CTRL) && p != 0 && edit->data[p - 1] != ' ' && edit->data[p - 1] != '\n'); } } if (flags & EMOD_SHIFT) { edit_sel.p2 = p; updatesel(); } else { if (edit_sel.length) { p = edit_sel.start; } edit_sel.p1 = p; edit_sel.p2 = p; edit_sel.start = p; edit_sel.length = 0; } break; } case KEY_RIGHT: { uint16_t p = edit_sel.p2; if (flags & EMOD_CTRL) { while (p != edit->length && edit->data[p] == ' ') { p++; } } do { if (p == edit->length) { break; } p += utf8_len(&edit->data[p]); } while ((flags & EMOD_CTRL) && edit->data[p] != ' ' && edit->data[p] != '\n'); if (flags & EMOD_SHIFT) { edit_sel.p2 = p; updatesel(); } else { if (edit_sel.length) { p = edit_sel.start + edit_sel.length; } edit_sel.p1 = p; edit_sel.p2 = p; edit_sel.start = p; edit_sel.length = 0; } break; } case KEY_UP: { if (!edit->multiline) { break; } setfont(FONT_TEXT); edit_sel.p2 = text_lineup(edit->width, edit->height, edit_sel.p2, font_small_lineheight, edit->data, edit->length, edit->scroll); if (!(flags & EMOD_SHIFT)) { edit_sel.p1 = edit_sel.p2; } updatesel(); break; } case KEY_DOWN: { if (!edit->multiline) { break; } setfont(FONT_TEXT); edit_sel.p2 = text_linedown(edit->width, edit->height, edit_sel.p2, font_small_lineheight, edit->data, edit->length, edit->scroll); if (!(flags & EMOD_SHIFT)) { edit_sel.p1 = edit_sel.p2; } updatesel(); break; } case KEY_PAGEUP: { if (!edit->multiline) { break; } edit->scroll->d = 0.0; break; } case KEY_PAGEDOWN: { if (!edit->multiline) { break; } edit->scroll->d = 1.0; break; } case KEY_HOME: { uint16_t p = edit_sel.p2; if (p == 0 && !edit_sel.length) { break; } if (flags & EMOD_CTRL) { p = 0; } else { while (p != 0 && edit->data[p - 1] != '\n') { --p; } } if (flags & EMOD_SHIFT) { edit_sel.p2 = p; updatesel(); } else { edit_sel.p1 = p; edit_sel.p2 = p; edit_sel.start = p; edit_sel.length = 0; } break; } case KEY_END: { uint16_t p = edit_sel.p2; if (p == edit->length && !edit_sel.length) { break; } if (flags & EMOD_CTRL) { p = edit->length; } else { while (edit->data[p] != '\n' && p != edit->length) { p++; } } if (flags & EMOD_SHIFT) { edit_sel.p2 = p; updatesel(); } else { edit_sel.p1 = p; edit_sel.p2 = p; edit_sel.start = p; edit_sel.length = 0; } break; } case 'a': case 'A': { edit_sel.p1 = 0; edit_sel.p2 = active_edit->length; edit_sel.start = 0; edit_sel.length = active_edit->length; setselection(active_edit->data, active_edit->length); break; } case 'z': { uint16_t p = edit_undo(edit); if (p != UINT16_MAX) { edit_sel.p1 = p; edit_sel.p2 = p; edit_sel.start = p; edit_sel.length = 0; modified = true; } break; } case 'Z': case 'y': case 'Y': { uint16_t p = edit_redo(edit); if (p != UINT16_MAX) { edit_sel.p1 = p; edit_sel.p2 = p; edit_sel.start = p; edit_sel.length = 0; modified = false; } break; } case KEY_RETURN: { modified = true; if (edit->onenter && !(flags & EMOD_CTRL)) { edit->onenter(edit); /*dirty*/ if (edit->length == 0) { for (uint16_t i = 0; i != edit->history_length; i++) { free(edit->history[i]); } free(edit->history); edit->history = NULL; edit->history_cur = 0; edit->history_length = 0; edit_sel.p1 = 0; edit_sel.p2 = 0; edit_sel.start = 0; edit_sel.length = 0; } } break; } case KEY_TAB: { if ((flags & EMOD_SHIFT) && !(flags & EMOD_CTRL) && edit->onshifttab) { edit->onshifttab(edit); } else if (!(flags & EMOD_CTRL) && edit->ontab) { edit->ontab(edit); } break; } } edit_select = 0; if (modified && edit->onchange) { edit->onchange(edit); } edit_redraw(); } else if (!edit->readonly) { uint8_t len = unicode_to_utf8_len(ch); char *p = edit->data + edit_sel.start; if ((size_t)edit->length - edit_sel.length + len >= edit->data_size) { return; } if (edit_sel.length) { edit_do(edit, edit_sel.start, edit_sel.length, 1); } memmove(p + len, p + edit_sel.length, edit->length - (edit_sel.start + edit_sel.length)); edit->length -= edit_sel.length; unicode_to_utf8(ch, edit->data + edit_sel.start); edit->length += len; edit_do(edit, edit_sel.start, len, 0); edit_sel.start += len; edit_sel.p1 = edit_sel.start; edit_sel.p2 = edit_sel.p1; edit_sel.length = 0; if (edit->onchange) { edit->onchange(edit); } edit_redraw(); } } int edit_selection(EDIT *edit, char *data, int UNUSED(len)) { if (data) { memcpy(data, edit->data + edit_sel.start, edit_sel.length); } return edit_sel.length; } int edit_copy(char *data, int len) { return edit_selection(active_edit, data, len); } void edit_paste(char *data, int length, bool select) { if (!active_edit) { return; } if (active_edit->readonly) { return; } length = utf8_validate((uint8_t *)data, length); const int maxlen = (active_edit->data_size - 1) - active_edit->length + edit_sel.length; int newlen = 0, i = 0; while (i < length) { const uint8_t len = utf8_len(data + i); const bool not_linebreak = !active_edit->multiline || data[i] != '\n'; const bool is_multibyte = len > 1; const bool is_control_char = is_multibyte ? (uint8_t)data[i] == 0xC2 && (uint8_t)data[i + 1] <= 0x9F : data[i] <= 0x1F && not_linebreak; const bool is_delete = data[i] == 0x7F; if (is_delete || is_control_char) { // Ignore these characters } else { if (newlen + len > maxlen) { break; } if (newlen != i) { memcpy(data + newlen, data + i, len); } newlen += len; } i += len; } if (newlen == 0) { return; } char *p = active_edit->data + edit_sel.start; if (edit_sel.length) { edit_do(active_edit, edit_sel.start, edit_sel.length, 1); } memmove(p + newlen, p + edit_sel.length, active_edit->length - (edit_sel.start + edit_sel.length)); memcpy(p, data, newlen); edit_do(active_edit, edit_sel.start, newlen, 0); active_edit->length += newlen - edit_sel.length; if (select) { edit_sel.length = newlen; setselection(active_edit->data + edit_sel.start, newlen); } else { edit_sel.start = edit_sel.start + newlen; edit_sel.length = 0; } edit_sel.p1 = edit_sel.start; edit_sel.p2 = edit_sel.start + edit_sel.length; if (active_edit->onchange) { active_edit->onchange(active_edit); } edit_redraw(); } void edit_resetfocus(void) { edit_select = 0; setactive(NULL); } void edit_setfocus(EDIT *edit) { if (active_edit == edit) { return; } edit_select = 0; edit_sel.start = edit_sel.p1 = 0; edit_sel.length = edit_sel.p2 = edit->length; edit_sel.mark_start = 0; edit_sel.mark_length = 0; setactive(edit); } bool edit_active(void) { return (active_edit != NULL); } EDIT *edit_get_active(void) { return active_edit; } void edit_setstr(EDIT *edit, char *str, uint16_t length) { uint16_t maxlength; maxlength = edit->data_size - 1; if (length >= maxlength) { length = maxlength; } edit->length = length; memcpy(edit->data, str, length); if (edit->onchange) { edit->onchange(edit); } } void edit_setcursorpos(EDIT *edit, uint16_t pos) { if (pos <= edit->length) { edit_sel.p1 = pos; } else { edit_sel.p1 = edit->length; } edit_sel.p2 = edit_sel.start = edit_sel.p1; edit_sel.length = 0; } uint16_t edit_getcursorpos(void) { return edit_sel.p1 < edit_sel.p2 ? edit_sel.p1 : edit_sel.p2; } bool edit_getmark(uint16_t *outloc, uint16_t *outlen) { if (outloc) { *outloc = edit_sel.mark_start; } if (outlen) { *outlen = edit_sel.mark_length; } return (active_edit && edit_sel.mark_length) ? 1 : 0; } void edit_setmark(uint16_t loc, uint16_t len) { edit_sel.mark_start = loc; edit_sel.mark_length = len; } void edit_setselectedrange(uint16_t loc, uint16_t len) { edit_sel.start = edit_sel.p1 = loc; edit_sel.length = len; edit_sel.p2 = loc + len; } uTox/src/ui/dropdown.h0000600000175000001440000000253114003056216013710 0ustar rakusers#ifndef UI_DROPDOWN_H #define UI_DROPDOWN_H #include "panel.h" #include "../ui.h" #include // userdata of list-based dropdown consists of these records typedef struct { MAYBE_I18NAL_STRING name; void * handle; } DROP_ELEMENT; typedef struct dropdown { PANEL panel; bool mouseover, open, skip_mup; uint16_t dropcount, selected, over; void (*onselect)(uint16_t, const struct dropdown *); STRING *(*ondisplay)(uint16_t, const struct dropdown *); UI_ELEMENT_STYLE style; void *userdata; } DROPDOWN; void dropdown_drawactive(void); void dropdown_draw(DROPDOWN *b, int x, int y, int width, int height); bool dropdown_mmove(DROPDOWN *b, int x, int y, int width, int height, int mx, int my, int dx, int dy); bool dropdown_mdown(DROPDOWN *b); bool dropdown_mright(DROPDOWN *b); bool dropdown_mwheel(DROPDOWN *b, int height, double d, bool smooth); bool dropdown_mup(DROPDOWN *b); bool dropdown_mleave(DROPDOWN *b); bool dropdown_close(DROPDOWN *b); STRING *simple_dropdown_ondisplay(uint16_t, const DROPDOWN *); STRING *dropdown_list_ondisplay(uint16_t i, const DROPDOWN *dm); void dropdown_list_add_hardcoded(DROPDOWN *d, char *name, void *handle); void dropdown_list_add_localized(DROPDOWN *d, UTOX_I18N_STR string_id, void *handle); void dropdown_list_clear(DROPDOWN *); #endif // UI_DROPDOWN_H uTox/src/ui/dropdown.c0000600000175000001440000001765014003056216013713 0ustar rakusers#include "dropdown.h" #include "draw.h" #include "../macros.h" #include "../settings.h" #include "../theme.h" #include #include static DROPDOWN *active_dropdown; static int active_x, active_y, active_width, active_height; /* Show selected first, then skip selected */ #define index(d, i) (i == 0 ? d->selected : ((i > d->selected) ? i : i - 1)) // Draw background rectangles for a dropdown void dropdown_drawactive(void) { DROPDOWN *drop = active_dropdown; if (!drop) { return; } // load colors for this style uint32_t color_bg, color_border, color_aoptbg, color_aopttext, color_text; switch (drop->style) { case AUXILIARY_STYLE: color_bg = COLOR_BKGRND_AUX; color_border = COLOR_AUX_EDGE_ACTIVE; color_aoptbg = COLOR_AUX_ACTIVEOPTION_BKGRND; color_aopttext = COLOR_AUX_ACTIVEOPTION_TEXT; color_text = COLOR_AUX_TEXT; break; default: color_bg = COLOR_BKGRND_MAIN; color_border = COLOR_EDGE_ACTIVE; color_aoptbg = COLOR_ACTIVEOPTION_BKGRND; color_aopttext = COLOR_ACTIVEOPTION_TEXT; color_text = COLOR_MAIN_TEXT; break; } int x = active_x, y = active_y, w = active_width, h = active_height; int i, sign = 1; // Increase width if needed, so that all menu items fit. for (i = 0; i != drop->dropcount; i++) { STRING *e = drop->ondisplay(i, drop); int needed_w = textwidth(e->str, e->length) + SCALE(8); if (w < needed_w) { w = needed_w; } } if (y + h * drop->dropcount > (int)settings.window_height) { // y -= h * (drop->dropcount - 1); // sign = -1; } y -= h * drop->selected; draw_rect_fill(x, y, w, h * drop->dropcount, color_bg); draw_rect_frame(x, y, w, h * drop->dropcount, color_border); //if (sign == -1) { // y += h * (drop->dropcount - 1); //} for (i = 0; i != drop->dropcount; i++) { // int j = index(drop, i); int j = i; STRING *e = drop->ondisplay(j, drop); if (j == drop->over) { draw_rect_fill(x + 1, y + 1, w - 2, h - 2, color_aoptbg); setcolor(color_aopttext); } else { setcolor(color_text); } setfont(FONT_TEXT); drawtext(x + SCALE(4), y + SCALE(4), e->str, e->length); y += sign * h; } } // Draw collapsed dropdown void dropdown_draw(DROPDOWN *d, int x, int y, int width, int height) { if (!d->open) { // load colors for this style uint32_t color_bg, color_border, color_border_h, color_text; switch (d->style) { case AUXILIARY_STYLE: color_bg = COLOR_BKGRND_AUX; color_border = COLOR_AUX_EDGE_NORMAL; color_border_h = COLOR_AUX_EDGE_HOVER; color_text = COLOR_AUX_TEXT; break; default: color_bg = COLOR_BKGRND_MAIN; color_border = COLOR_EDGE_NORMAL; color_border_h = COLOR_EDGE_HOVER; color_text = COLOR_MAIN_TEXT; break; } draw_rect_frame(x, y, width, height, (d->mouseover ? color_border_h : color_border)); draw_rect_fill(x + 1, y + 1, width - 2, height - 2, color_bg); if (d->dropcount) { setfont(FONT_TEXT); setcolor(color_text); STRING *text = d->ondisplay(d->selected, d); drawtextwidth(x + SCALE(4), width - SCALE(8), y + SCALE(4), text->str, text->length); } } else { active_x = x; active_y = y; active_width = width; active_height = height; } } bool dropdown_mmove(DROPDOWN *d, int UNUSED(x), int y, int w, int h, int mx, int my, int UNUSED(dx), int UNUSED(dy)) { if (d->open) { bool mouseover; if (my > 0) { mouseover = inrect(mx, my, 0, 0, w, MIN(h * d->dropcount, (int)settings.window_height)); } else { mouseover = mx >= 0 && mx <= w && abs(my) <= h * d->selected; } if (d->mouseover != mouseover) { d->mouseover = mouseover; } if (mouseover) { d->skip_mup = true; } else { d->over = false; d->skip_mup = false; return true; } int over = my / h + d->selected; if (y + h * d->dropcount > (int)settings.window_height) { // over = my > 0 ? 0 : ((-my) / h + 1); } if (my < 0) over--; if (over < d->dropcount) { // over = index(d, over); if (over != d->over) { d->over = over; return true; } } } else { bool mouseover = inrect(mx, my, 0, 0, w, h); if (d->mouseover != mouseover) { d->mouseover = mouseover; return true; } } return false; } bool dropdown_mdown(DROPDOWN *d) { if (d->mouseover && d->dropcount) { d->open = true; active_dropdown = d; return true; } if (d->skip_mup) { return dropdown_close(d); } return false; } bool dropdown_close(DROPDOWN *d) { d->open = false; active_dropdown = NULL; return true; } bool dropdown_mright(DROPDOWN *UNUSED(d)) { return false; } bool dropdown_mwheel(DROPDOWN *UNUSED(d), int UNUSED(height), double UNUSED(dlta), bool UNUSED(smooth)) { return false; } bool dropdown_mup(DROPDOWN *d) { if (d->open) { if (!d->mouseover) { return dropdown_close(d); } if (d->skip_mup) { d->skip_mup = false; dropdown_close(d); if (d->over < d->dropcount) { d->selected = d->over; d->onselect(d->selected, d); } return true; } else { d->skip_mup = true; } return false; } return false; } bool dropdown_mleave(DROPDOWN *d) { if (d->mouseover) { d->mouseover = false; return true; } return false; } /***** list-based dropdown menu start *****/ // Appends localization-independent menu item. void dropdown_list_add_hardcoded(DROPDOWN *d, char *name, void *handle) { void *p = realloc(d->userdata, (d->dropcount + 1) * sizeof(DROP_ELEMENT)); if (!p) { return; } d->userdata = p; DROP_ELEMENT *e = &((DROP_ELEMENT *)d->userdata)[d->dropcount++]; maybe_i18nal_string_set_plain(&e->name, name, strlen((char *)name)); e->handle = handle; } // Appends localized menu item. void dropdown_list_add_localized(DROPDOWN *d, UTOX_I18N_STR string_id, void *handle) { void *p = realloc(d->userdata, (d->dropcount + 1) * sizeof(DROP_ELEMENT)); if (!p) { return; } d->userdata = p; DROP_ELEMENT *e = &((DROP_ELEMENT *)d->userdata)[d->dropcount++]; maybe_i18nal_string_set_i18nal(&e->name, string_id); e->handle = handle; } // Clears menu (removes all menu items of a list-based dropdown). void dropdown_list_clear(DROPDOWN *d) { free(d->userdata); d->userdata = NULL; d->dropcount = 0; d->over = false; d->selected = 0; } // Generic display function for list-based dropdowns, // userdata of which is an array of DROP_ELEMENTs. STRING *dropdown_list_ondisplay(uint16_t i, const DROPDOWN *dm) { DROP_ELEMENT *e = &((DROP_ELEMENT *)dm->userdata)[i]; return maybe_i18nal_string_get(&e->name); } /***** list-based dropdown menu end *****/ /***** simple localized dropdown menu start *****/ // Generic display function for simple dropdowns, // userdata of which is a simple array of UI_STRING_IDs. STRING *simple_dropdown_ondisplay(uint16_t i, const DROPDOWN *dm) { return SPTRFORLANG(settings.language, ((UTOX_I18N_STR *)dm->userdata)[i]); } /***** simple localized dropdown menu end *****/ uTox/src/ui/draw.h0000600000175000001440000000267514003056216013022 0ustar rakusers#ifndef UI_DRAW_H #define UI_DRAW_H #include extern int font_small_lineheight, font_msg_lineheight; void drawtext(int x, int y, const char *str, uint16_t length); int drawtext_getwidth(int x, int y, const char *str, uint16_t length); void drawtextwidth(int x, int width, int y, const char *str, uint16_t length); void drawtextwidth_right(int x, int width, int y, const char *str, uint16_t length); void drawtextrange(int x, int x2, int y, const char *str, uint16_t length); void drawtextrangecut(int x, int x2, int y, const char *str, uint16_t length); int textwidth(const char *str, uint16_t length); int textfit(const char *str, uint16_t length, int width); int textfit_near(const char *str, uint16_t length, int width); void drawrect(int x, int y, int right, int bottom, uint32_t color); void draw_rect_frame(int x, int y, int width, int height, uint32_t color); void draw_rect_fill(int x, int y, int width, int height, uint32_t color); void drawhline(int x, int y, int x2, uint32_t color); void drawvline(int x, int y, int y2, uint32_t color); #define drawpixel(x, y, color) drawvline(x, y, (y) + 1, color) void setfont(int id); uint32_t setcolor(uint32_t color); void pushclip(int x, int y, int width, int height); void popclip(void); void enddraw(int x, int y, int width, int height); void drawalpha(int bm, int x, int y, int width, int height, uint32_t color); void loadalpha(int bm, void *data, int width, int height); #endif uTox/src/ui/draw.c0000600000175000001440000000010314003056216012775 0ustar rakusers#include "draw.h" int font_small_lineheight, font_msg_lineheight; uTox/src/ui/contextmenu.h0000600000175000001440000000143014003056216014422 0ustar rakusers#ifndef UI_CONTEXTMENU_H #define UI_CONTEXTMENU_H #include "../ui.h" #include #include typedef struct contextmenu { int x, y, width, height; bool open; uint8_t count, over, down; void (*onselect)(uint8_t); STRING *(*ondisplay)(uint8_t, const struct contextmenu *); void *userdata; } CONTEXTMENU; void contextmenu_draw(void); bool contextmenu_mmove(int mx, int my, int dx, int dy); bool contextmenu_mdown(void); bool contextmenu_mup(void); bool contextmenu_mleave(void); void contextmenu_new(uint8_t count, UTOX_I18N_STR *menu_string_ids, void (*onselect)(uint8_t)); void contextmenu_new_ex(uint8_t count, void *userdata, void (*onselect)(uint8_t), STRING *(*ondisplay)(uint8_t, const CONTEXTMENU *)); #endif uTox/src/ui/contextmenu.c0000600000175000001440000000756614003056216014435 0ustar rakusers#include "contextmenu.h" #include "draw.h" #include "../macros.h" #include "../settings.h" #include "../theme.h" #include "../ui.h" static CONTEXTMENU context_menu; #define CONTEXT_WIDTH (SCALE(120)) #define CONTEXT_HEIGHT (SCALE(24)) static void calculate_pos_and_width(CONTEXTMENU *b, int *x, int *w) { uint8_t i; *x = b->x; *w = b->width; // Increase width if needed, so that all menu items fit. for (i = 0; i < b->count; i++) { STRING *name = b->ondisplay(i, b); int needed_w = textwidth(name->str, name->length) + SCALE(8); if (*w < needed_w) { *w = needed_w; } } // Push away from the right border to fit. if (*x + *w >= (int)settings.window_width) { *x -= *w; } } void contextmenu_draw(void) { CONTEXTMENU *b = &context_menu; if (!b->open) { return; } setfont(FONT_TEXT); int x, w, active_h; calculate_pos_and_width(b, &x, &w); draw_rect_fill(x, b->y, w, b->height, COLOR_BKGRND_MAIN); active_h = b->y + b->over * CONTEXT_HEIGHT; draw_rect_fill(x, active_h, w, CONTEXT_HEIGHT, COLOR_ACTIVEOPTION_BKGRND); int i; for (i = 0; i != b->count; i++) { // Ensure that font is set before calculating position and width. STRING *name = b->ondisplay(i, b); setcolor((active_h == b->y + i * CONTEXT_HEIGHT) ? COLOR_ACTIVEOPTION_TEXT : COLOR_MAIN_TEXT); drawtext(x + SCALE(4), b->y + SCALE(4) + i * CONTEXT_HEIGHT, name->str, name->length); } draw_rect_frame(x, b->y, w, b->height, COLOR_EDGE_ACTIVE); } bool contextmenu_mmove(int mx, int my, int UNUSED(dx), int UNUSED(dy)) { CONTEXTMENU *b = &context_menu; if (!b->open) { return 0; } cursor = CURSOR_NONE; // Ensure that font is set before calculating position and width. setfont(FONT_TEXT); setcolor(COLOR_BKGRND_MAIN); int x, w; calculate_pos_and_width(b, &x, &w); bool mouseover = inrect(mx, my, x, b->y, w, b->height); if (!mouseover) { if (b->over != 0xFF) { b->over = 0xFF; return 1; } return 0; } uint8_t over = (my - b->y) / CONTEXT_HEIGHT; if (over >= b->count) { over = 0xFF; } if (over != b->over) { b->over = over; return 1; } return 0; } bool contextmenu_mdown(void) { CONTEXTMENU *b = &context_menu; if (!b->open) { return 0; } if (b->over != 0xFF) { b->down = b->over; } else { b->open = 0; } return 1; } bool contextmenu_mup(void) { CONTEXTMENU *b = &context_menu; if (!b->open) { return 0; } if (b->over == b->down) { b->onselect(b->over); b->open = 0; return 1; } return 0; } bool contextmenu_mleave(void) { CONTEXTMENU *b = &context_menu; if (!b->open) { return 0; } if (b->over != 0xFF) { b->over = 0xFF; return 1; } return 0; } void contextmenu_new_ex(uint8_t count, void *userdata, void (*onselect)(uint8_t), STRING *(*ondisplay)(uint8_t, const CONTEXTMENU *)) { CONTEXTMENU *b = &context_menu; b->y = mouse.y; b->height = CONTEXT_HEIGHT * count; if (b->y + b->height >= (int)settings.window_height) { b->y -= b->height; } b->x = mouse.x; b->width = CONTEXT_WIDTH; b->open = true; b->count = count; b->over = 0xFF; b->onselect = onselect; b->ondisplay = ondisplay; b->userdata = userdata; } static STRING *contextmenu_localized_ondisplay(uint8_t i, const CONTEXTMENU *cm) { return SPTRFORLANG(settings.language, ((UTOX_I18N_STR *)cm->userdata)[i]); } void contextmenu_new(uint8_t count, UTOX_I18N_STR *menu_string_ids, void (*onselect)(uint8_t)) { contextmenu_new_ex(count, menu_string_ids, onselect, contextmenu_localized_ondisplay); } uTox/src/ui/button.h0000600000175000001440000000312414003056216013366 0ustar rakusers#ifndef UI_BUTTON_H #define UI_BUTTON_H #include "panel.h" #include "../ui.h" #include #include typedef struct button BUTTON; struct button { PANEL panel; /* Button bitmap id, * fill is top-left aligned * icon is centered. */ int bm_fill, bm_icon; // Width & height of bm_icon. Used for centering. int icon_w, icon_h; // Background RGB color for bm picture, when Idle/Hovered/Pressed respectively. uint32_t c1, // Button normal background color c2, // Button hover background color c3, // Button active (press) background color ct1, // Button contents (text or icon) color ct2, // Button contents (text or icon) hover color cd; MAYBE_I18NAL_STRING button_text; MAYBE_I18NAL_STRING tooltip_text; bool mouseover, mousedown, disabled, nodraw; void (*onright)(void); // called when right mouse button goes down void (*on_mdn)(void); void (*on_mup)(void); void (*update)(BUTTON *b); }; void button_draw(BUTTON *b, int x, int y, int width, int height); bool button_mmove(BUTTON *b, int x, int y, int width, int height, int mx, int my, int dx, int dy); bool button_mdown(BUTTON *b); bool button_mup(BUTTON *b); bool button_mright(BUTTON *b); bool button_mwheel(BUTTON *b, int height, double d, bool smooth); bool button_mleave(BUTTON *b); // TODO these may move void button_setcolors_success(BUTTON *b); void button_setcolors_danger(BUTTON *b); void button_setcolors_warning(BUTTON *b); void button_setcolors_disabled(BUTTON *b); #endif // UI_BUTTON_H uTox/src/ui/button.c0000600000175000001440000001204614003056216013364 0ustar rakusers#include "button.h" #include "draw.h" #include "tooltip.h" #include "../macros.h" #include "../theme.h" #include "../ui.h" static void calculate_pos_and_width(BUTTON *b, int *x, int *w) { int real_w = *w; // Increase width if needed, so that button text fits. if (maybe_i18nal_string_is_valid(&b->button_text)) { STRING *str = maybe_i18nal_string_get(&b->button_text); int min_w = textwidth(str->str, str->length); if (*w < min_w) { *w = min_w + SCALE(12); // 12 seems like a perfectly fine number, // eventually we should use logic here. } } // Push away from the right border to fit, // if our panel is right-adjusted. if (b->panel.x < 0) { *x -= *w - real_w; } } void button_draw(BUTTON *b, int x, int y, int width, int height) { // If `update` function is defined, call it on each draw if (b->update) { b->update(b); } // Button is hidden if (b->nodraw) { return; } // Ensure that font is set before calculating position and width. setfont(FONT_SELF_NAME); // Button contents color uint32_t color_text = b->mousedown ? b->ct2 : (b->mouseover ? b->ct2 : b->ct1); setcolor(color_text); int real_w = width; calculate_pos_and_width(b, &x, &width); // Button background color uint32_t color_bg = b->mousedown ? b->c3 : (b->mouseover ? b->c2 : b->c1); if (b->bm_fill) { drawalpha(b->bm_fill, x, y, real_w, height, color_bg); } else { draw_rect_fill(x, y, real_w, height, b->disabled ? b->cd : color_bg); } if (b->bm_icon) { const int icon_x = real_w / 2 - SCALE(b->icon_w) / 2; const int icon_y = height / 2 - SCALE(b->icon_h) / 2; drawalpha(b->bm_icon, x + icon_x, y + icon_y, SCALE(b->icon_w), SCALE(b->icon_h), color_text); } if (maybe_i18nal_string_is_valid(&b->button_text)) { if (b->bm_fill) { while (width > real_w) { // The text didn't fit into the original width. // Fill the rest of the new width with the image // and hope for the best. drawalpha(b->bm_fill, x + width - real_w, y, real_w, height, color_bg); width -= real_w / 2 + 1; } } STRING *s = maybe_i18nal_string_get(&b->button_text); drawtext(x + SCALE(6), y + SCALE(2), s->str, s->length); } } bool button_mmove(BUTTON *b, int UNUSED(x), int UNUSED(y), int width, int height, int mx, int my, int UNUSED(dx), int UNUSED(dy)) { // Ensure that font is set before calculating position and width. setfont(FONT_SELF_NAME); int real_x = 0, real_w = width; calculate_pos_and_width(b, &real_x, &real_w); bool mouseover = inrect(mx, my, real_x, 0, real_w, height); if (mouseover) { if (!b->disabled) { cursor = CURSOR_HAND; } if (maybe_i18nal_string_is_valid(&b->tooltip_text)) { tooltip_new(&b->tooltip_text); } } if (mouseover != b->mouseover) { b->mouseover = mouseover; return 1; } return 0; } bool button_mdown(BUTTON *b) { if (b->mouseover) { if (!b->mousedown && b->on_mdn) { b->on_mdn(); } b->mousedown = true; return 1; } return 0; } bool button_mup(BUTTON *b) { if (b->mousedown) { if (b->mouseover && b->on_mup) { b->on_mup(); } b->mousedown = 0; return 1; } return 0; } bool button_mright(BUTTON *b) { if (b->mouseover && b->onright) { b->onright(); return 1; } return 0; } bool button_mwheel(BUTTON *UNUSED(b), int UNUSED(height), double UNUSED(d), bool UNUSED(smooth)) { return 0; } bool button_mleave(BUTTON *b) { if (b->mouseover) { b->mouseover = 0; return 1; } return 0; } // Logic update functions // TODO should these live here? // TODO delete button_setcolor_* and move this setting and logic to the struct /* Quick color change functions */ void button_setcolors_success(BUTTON *b) { b->c1 = COLOR_BTN_SUCCESS_BKGRND; b->c2 = COLOR_BTN_SUCCESS_BKGRND_HOVER; b->c3 = COLOR_BTN_SUCCESS_BKGRND_HOVER; b->ct1 = COLOR_BTN_SUCCESS_TEXT; b->ct2 = COLOR_BTN_SUCCESS_TEXT_HOVER; } void button_setcolors_danger(BUTTON *b) { b->c1 = COLOR_BTN_DANGER_BACKGROUND; b->c2 = COLOR_BTN_DANGER_BKGRND_HOVER; b->c3 = COLOR_BTN_DANGER_BKGRND_HOVER; b->ct1 = COLOR_BTN_DANGER_TEXT; b->ct2 = COLOR_BTN_DANGER_TEXT_HOVER; } void button_setcolors_warning(BUTTON *b) { b->c1 = COLOR_BTN_WARNING_BKGRND; b->c2 = COLOR_BTN_WARNING_BKGRND_HOVER; b->c3 = COLOR_BTN_WARNING_BKGRND_HOVER; b->ct1 = COLOR_BTN_WARNING_TEXT; b->ct2 = COLOR_BTN_WARNING_TEXT_HOVER; } void button_setcolors_disabled(BUTTON *b) { b->c1 = COLOR_BTN_DISABLED_BKGRND; b->c2 = COLOR_BTN_DISABLED_BKGRND; b->c3 = COLOR_BTN_DISABLED_BKGRND; b->ct1 = COLOR_BTN_DISABLED_TEXT; b->ct2 = COLOR_BTN_DISABLED_TEXT; } uTox/src/ui/CMakeLists.txt0000600000175000001440000000035414003056216014444 0ustar rakusersproject(utoxUI LANGUAGES C) add_library(utoxUI STATIC button.c contextmenu.c draw.c dropdown.c edit.c scrollable.c svg.c switch.c text.c tooltip.c ) target_link_libraries(utoxUI utoxLAYOUT) uTox/src/ui.h0000600000175000001440000001454314003056216012062 0ustar rakusers#ifndef UI_H #define UI_H #include "sized_string.h" #include "../langs/i18n_decls.h" #include "settings.h" #include #include typedef struct native_image NATIVE_IMAGE; typedef struct panel PANEL; typedef struct scrollable SCROLLABLE; #define S(x) (ui_gettext(settings.language, (STR_##x))->str) #define SLEN(x) (ui_gettext(settings.language, (STR_##x))->length) #define SPTR(x) (ui_gettext(settings.language, (STR_##x))) /* if UTOX_STR_WIDTH, is giving you a bad size you've probably changed setfont() from the string you're trying to get * the size of. Either store the size before changing, or swap it -> run UTOX_STR_WIDTH() -> swap back. */ #define UTOX_STR_WIDTH(x) (textwidth((ui_gettext(settings.language, (STR_##x))->str), \ (ui_gettext(settings.language, (STR_##x))->length))) #define SPTRFORLANG(l, x) (ui_gettext((l), (x))) // TODO: Create ui_native headers or something. // This is hard to read. I know. I'm sorry. // This is to stop a circular dependency between svg.c and xlib/main.h. #if defined __WIN32__ || defined _WIN32 || defined __CYGWIN__ // Windows supplies its own RGB function. #include // TODO, don't do this #elif defined __ANDROID__ #define RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16)) #elif defined __OBJC__ // xlib and cocoa use the same format for this, but I left both cases here // in case I want to use this #ifdef construct elsewhere. #define RGB(r, g, b) (((r) << 16) | ((g) << 8) | (b)) #else #define RGB(r, g, b) (((r) << 16) | ((g) << 8) | (b)) #endif // Mouse stuff enum { CURSOR_NONE, CURSOR_TEXT, CURSOR_HAND, CURSOR_SELECT, CURSOR_ZOOM_IN, CURSOR_ZOOM_OUT, }; extern struct utox_mouse { int x, y; } mouse; extern uint8_t cursor; extern bool mdown; enum { FONT_TEXT, FONT_TITLE, FONT_SELF_NAME, FONT_STATUS, FONT_LIST_NAME, FONT_MISC, FONT_END, }; typedef enum { MAIN_STYLE, // white style, used in right side AUXILIARY_STYLE, // gray style, used on friends side } UI_ELEMENT_STYLE; typedef struct maybe_i18nal_string { STRING plain; UTOX_I18N_STR i18nal; } MAYBE_I18NAL_STRING; void maybe_i18nal_string_set_plain(MAYBE_I18NAL_STRING *, char *str, uint16_t length); void maybe_i18nal_string_set_i18nal(MAYBE_I18NAL_STRING *, UTOX_I18N_STR); STRING *maybe_i18nal_string_get(MAYBE_I18NAL_STRING *); bool maybe_i18nal_string_is_valid(MAYBE_I18NAL_STRING *); /* draws an image in the style of an avatar at within rect (x,y,targetwidth,targetheight) * this means: resize the image while keeping proportion so that the dimension(width or height) that has the smallest * rational difference to the targetdimension becomes exactly targetdimension, then * crop the image so it fits in the (x,y,targetwidth,targetheight) rect, and * set the position if a dimension is too large so it's centered on the middle * * first argument is the image to draw, width and height are the width and height of the input image */ void draw_avatar_image(NATIVE_IMAGE *image, int x, int y, uint32_t width, uint32_t height, uint32_t targetwidth, uint32_t targetheight); void ui_set_scale(uint8_t scale); void ui_rescale(uint8_t scale); void ui_size(int width, int height); void ui_mouseleave(void); void panel_draw(PANEL *p, int x, int y, int width, int height); bool panel_mmove(PANEL *p, int x, int y, int width, int height, int mx, int my, int dx, int dy); void panel_mdown(PANEL *p); bool panel_dclick(PANEL *p, bool triclick); bool panel_mright(PANEL *p); bool panel_mwheel(PANEL *p, int x, int y, int width, int height, double d, bool smooth); bool panel_mup(PANEL *p); bool panel_mleave(PANEL *p); extern char search_data[1024]; // TODO this is NOT where this belongs extern double ui_scale; #define SCALE(x) ((int)(((double)x) * (ui_scale / 10.0))) #define SCALE_DIV(x) (((int)(((double)x) * (ui_scale / 10.0))) ?: 1) #define UI_FSCALE(x) (((double)x) * (ui_scale / 10.0)) #define UI_FSCALE_DIV(x) ((((double)x) * (ui_scale / 10.0)) ?: 1) #define UN_SCALE(x) (((int)(((double)x) / (ui_scale / 10.0)))) #define drawstr(x, y, i) drawtext(x, y, S(i), SLEN(i)) #define drawstr_getwidth(x, y, str) drawtext_getwidth(x, y, (char *)str, sizeof(str) - 1) #define strwidth(x) textwidth((char *)x, sizeof(x) - 1) /* colors */ #define GRAY(x) (((x) << 16) | ((x) << 8) | (x)) #define BLACK 0 #define C_RED RGB(200, 78, 78) #define C_SCROLL GRAY(209) /* These are the new defines to help align UI elements, the new ones must use a _top/_bottom/ or _left/_right or * _width/_height postfix, and should be used to replace the originals whenever possible. * If you're able to replace an original, replace all occurrences, and delete the define. */ /* User badge */ #define SIDEBAR_PADDING 6 #define SIDEBAR_AVATAR_TOP 5 #define SIDEBAR_AVATAR_LEFT 5 #define SIDEBAR_AVATAR_WIDTH 10 #define SIDEBAR_AVATAR_HEIGHT 10 #define SIDEBAR_NAME_TOP 10 #define SIDEBAR_NAME_LEFT 50 #define SIDEBAR_NAME_WIDTH 145 #define SIDEBAR_NAME_HEIGHT 18 #define SIDEBAR_STATUSMSG_TOP 28 #define SIDEBAR_STATUSMSG_LEFT 50 #define SIDEBAR_STATUSMSG_WIDTH 145 #define SIDEBAR_STATUSMSG_HEIGHT 18 /* Sidebar buttons and settings */ #define SIDEBAR_FILTER_FRIENDS_TOP 50 #define SIDEBAR_FILTER_FRIENDS_LEFT 5 #define SIDEBAR_FILTER_FRIENDS_WIDTH 168 #define SIDEBAR_FILTER_FRIENDS_HEIGHT 16 /* Roster defines */ #define ROSTER_LEFT 16 #define ROSTER_BOTTOM -30 #define ROSTER_BOX_HEIGHT 50 #define ROSTER_AVATAR_TOP 5 #define ROSTER_AVATAR_LEFT 10 #define ROSTER_NAME_TOP 12 /* Sidebar Lower search box and setting button */ #define SIDEBAR_SEARCH_TOP -30 #define SIDEBAR_SEARCH_LEFT 0 #define SIDEBAR_SEARCH_WIDTH 199 #define SIDEBAR_SEARCH_HEIGHT 30 #define SIDEBAR_BUTTON_TOP -30 #define SIDEBAR_BUTTON_LEFT 200 #define SIDEBAR_BUTTON_WIDTH 30 #define SIDEBAR_BUTTON_HEIGHT 30 /* Main box/Chat box size settings */ #define CHAT_BOX_TOP -52 /* size of the bottom message box */ #define MAIN_TOP_FRAME_THIN 30 #define MAIN_TOP_FRAME_THICK 60 /* Global UI size settings... */ #define SCROLL_WIDTH 8 // must be divisible by 2 #define FILE_TRANSFER_BOX_HEIGHT 28 /* Main panel defines */ #define MAIN_TOP 60 /* Legacy defines, instead of using these, you should replace them with something more descriptive */ #define LIST_Y2 86 #define LIST_BUTTON_Y -26 #define MESSAGES_SPACING 4 #define MESSAGES_X 94 #define TIME_WIDTH 45 #define TIME_WIDTH_LONG 60 #define NAME_OFFSET 14 #endif uTox/src/ui.c0000600000175000001440000004211514003056216012051 0ustar rakusers#include "ui.h" #include "flist.h" #include "inline_video.h" #include "macros.h" #include "messages.h" #include "settings.h" #include "layout/background.h" #include "layout/create.h" #include "layout/friend.h" #include "layout/group.h" #include "layout/notify.h" #include "layout/settings.h" #include "layout/sidebar.h" #include "native/image.h" #include "native/ui.h" #include "ui/button.h" #include "ui/contextmenu.h" #include "ui/draw.h" #include "ui/dropdown.h" #include "ui/edit.h" #include "ui/panel.h" #include "ui/scrollable.h" #include "ui/switch.h" #include "ui/text.h" #include "ui/tooltip.h" struct utox_mouse mouse; uint8_t cursor; bool mdown; char search_data[1024]; // TODO this is NOT where this belongs double ui_scale; /* These remain for legacy reasons, PANEL_MAIN calls these by default when not given it's own function to call */ static void background_draw(PANEL *UNUSED(p), int UNUSED(x), int UNUSED(y), int UNUSED(width), int UNUSED(height)) { return; } static bool background_mmove(PANEL *UNUSED(p), int UNUSED(x), int UNUSED(y), int UNUSED(width), int UNUSED(height), int UNUSED(mx), int UNUSED(my), int UNUSED(dx), int UNUSED(dy)) { return false; } static bool background_mdown(PANEL *UNUSED(p)) { return false; } static bool background_mright(PANEL *UNUSED(p)) { return false; } static bool background_mwheel(PANEL *UNUSED(p), int UNUSED(height), double UNUSED(d), bool UNUSED(smooth)) { return false; } static bool background_mup(PANEL *UNUSED(p)) { return false; } static bool background_mleave(PANEL *UNUSED(p)) { return false; } /***** MAYBE_I18NAL_STRING helpers start *****/ void maybe_i18nal_string_set_plain(MAYBE_I18NAL_STRING *mis, char *str, uint16_t length) { mis->i18nal = UI_STRING_ID_INVALID; mis->plain.length = length; mis->plain.str = str; } void maybe_i18nal_string_set_i18nal(MAYBE_I18NAL_STRING *mis, UTOX_I18N_STR string_id) { mis->plain.str = NULL; mis->plain.length = 0; mis->i18nal = string_id; } STRING *maybe_i18nal_string_get(MAYBE_I18NAL_STRING *mis) { if (mis->plain.str) { return &mis->plain; } return SPTRFORLANG(settings.language, mis->i18nal); } bool maybe_i18nal_string_is_valid(MAYBE_I18NAL_STRING *mis) { return (mis->plain.str || ((UI_STRING_ID_INVALID != mis->i18nal) && (mis->i18nal < NUM_STRS))); } /*********************************************************************** * * * Panel layout size set functions. * * * **********************************************************************/ static void sidepanel_USERBADGE(void) { // Converting DEFINES to magic because this will be moved to layout/ // and will then get a different format/selection } static void sidepanel_FLIST(void) { scrollbar_flist.panel.y = 0; // scrollbar_flist.panel.width = 230; // TODO remove? scrollbar_flist.panel.height = -1; panel_flist.x = 0; panel_flist.y = 70; panel_flist.width = 230; // TODO remove? panel_flist.height = ROSTER_BOTTOM; button_add_new_contact.panel.disabled = true; } static void settings_PROFILE(void) { panel_settings_profile.y = 32; } static void settings_UI(void) { panel_settings_ui.y = 32; } static void settings_AV(void) { panel_settings_av.y = 32; #ifndef AUDIO_FILTERING const uint16_t start_draw_y = 30; const uint16_t preview_button_pos_y = 245; #else const uint16_t start_draw_y = 60; const uint16_t preview_button_pos_y = 275; CREATE_SWITCH(audio_filtering, 10, 40, _BM_SWITCH_WIDTH, _BM_SWITCH_HEIGHT); #endif const uint16_t draw_y_vect = 30; CREATE_DROPDOWN(audio_in, 10, (start_draw_y + draw_y_vect + 5), 24, 360); CREATE_DROPDOWN(audio_out, 10, (start_draw_y + draw_y_vect + 57), 24, 360); CREATE_EDIT(video_fps, 10, (start_draw_y + draw_y_vect + 110), 360, 24); CREATE_DROPDOWN(video, 10, (start_draw_y + draw_y_vect + 162), 24, 360); CREATE_BUTTON(callpreview, 10, (preview_button_pos_y + 35), _BM_LBUTTON_WIDTH, _BM_LBUTTON_HEIGHT); CREATE_BUTTON(videopreview, 70, (preview_button_pos_y + 35), _BM_LBUTTON_WIDTH, _BM_LBUTTON_HEIGHT); } static void settings_NOTIFY(void) { panel_settings_notifications.y = 32; } static void settings_ADV(void) { panel_settings_adv.y = 32; const int show_nospam_x = 30 + UN_SCALE(MAX(UTOX_STR_WIDTH(SHOW_UI_PASSWORD), UTOX_STR_WIDTH(HIDE_UI_PASSWORD))); CREATE_BUTTON(show_nospam, show_nospam_x, 177, _BM_SBUTTON_WIDTH, _BM_SBUTTON_HEIGHT); const int revert_nospam_x = 30 + UN_SCALE(UTOX_STR_WIDTH(RANDOMIZE_NOSPAM)); CREATE_BUTTON(revert_nospam, revert_nospam_x, 265, _BM_SBUTTON_WIDTH, _BM_SBUTTON_HEIGHT); } void ui_set_scale(uint8_t scale) { if (scale >= 5 && scale <= 25) { ui_scale = scale; } else if (scale != 0) { return ui_set_scale(10); } } void ui_rescale(uint8_t scale) { ui_set_scale(scale); flist_re_scale(); setscale_fonts(); setfont(FONT_SELF_NAME); /* DEFAULT positions */ panel_main.y = 0; scrollbar_settings.panel.y = 32; /* TODO magic numbers are bad */ scrollbar_settings.content_height = 300; /* TODO magic numbers are bad */ panel_settings_master.y = 0; panel_settings_devices.y = 32; panel_settings_adv.y = 32; scrollbar_friend.panel.y = MAIN_TOP; scrollbar_friend.panel.height = CHAT_BOX_TOP; messages_friend.y = MAIN_TOP; messages_friend.height = CHAT_BOX_TOP - 10; messages_friend.width = -SCROLL_WIDTH; scrollbar_group.panel.y = MAIN_TOP; scrollbar_group.panel.height = CHAT_BOX_TOP; messages_group.y = MAIN_TOP; messages_group.height = CHAT_BOX_TOP; messages_group.width = -SCROLL_WIDTH; setfont(FONT_SELF_NAME); sidepanel_USERBADGE(); sidepanel_FLIST(); settings_PROFILE(); settings_UI(); settings_AV(); settings_NOTIFY(); settings_ADV(); // FIXME for testing, remove CREATE_BUTTON(notify_create, 2, 2, BM_SBUTTON_WIDTH, BM_SBUTTON_HEIGHT); CREATE_BUTTON(notify_one, 0, -50, 40, 50); CREATE_BUTTON(notify_two, 200, -50, 40, 50); CREATE_BUTTON(notify_three, -40, -50, 40, 50); CREATE_BUTTON(move_notify, -40, -40, 40, 40); /* Setting pages */ uint32_t settings_x = 4; CREATE_BUTTON(settings_sub_profile, settings_x, 0, 12, 28); settings_x += 20 + UN_SCALE(UTOX_STR_WIDTH(PROFILE_BUTTON)); #ifdef ENABLE_MULTIDEVICE CREATE_BUTTON(settings_sub_devices, settings_x, 0, 12, 28); settings_x += 20 + UN_SCALE(UTOX_STR_WIDTH(DEVICES_BUTTON)); #endif CREATE_BUTTON(settings_sub_ui, settings_x, 0, 12, 28); settings_x += 20 + UN_SCALE(UTOX_STR_WIDTH(USER_INTERFACE_BUTTON)); CREATE_BUTTON(settings_sub_av, settings_x, 0, 12, 28); settings_x += 20 + UN_SCALE(UTOX_STR_WIDTH(AUDIO_VIDEO_BUTTON)); CREATE_BUTTON(settings_sub_notifications, settings_x, 0, 12, 28); settings_x += 20 + UN_SCALE(UTOX_STR_WIDTH(NOTIFICATIONS_BUTTON)); CREATE_BUTTON(settings_sub_adv, settings_x, 0, 12, 28); /* Devices */ CREATE_BUTTON(add_new_device_to_self, -10 - BM_SBUTTON_WIDTH, 28, BM_SBUTTON_WIDTH, BM_SBUTTON_HEIGHT); CREATE_EDIT(add_new_device_to_self, 10, 27, 0 - UTOX_STR_WIDTH(ADD) - BM_SBUTTON_WIDTH, 24); setfont(FONT_TEXT); CREATE_EDIT(chat_msg_group, 6, -46, -10 - BM_CHAT_SEND_WIDTH, 40); setscale(); } /* Use the preprocessor to build function prototypes for all user interactions * These are functions that are (must be) defined elsewhere. The preprocessor in this case creates the prototypes that * will then be used by panel_draw_core to call the correct function */ #define MAKE_FUNC(ret, x, ...) \ static ret (*x##func[])(void *p, ##__VA_ARGS__) = { \ (void *)background_##x, (void *)messages_##x, (void *)inline_video_##x, (void *)flist_##x, (void *)button_##x, \ (void *)switch_##x, (void *)dropdown_##x, (void *)edit_##x, (void *)scroll_##x, \ }; MAKE_FUNC(void, draw, int x, int y, int width, int height); MAKE_FUNC(bool, mmove, int x, int y, int width, int height, int mx, int my, int dx, int dy); MAKE_FUNC(bool, mdown); MAKE_FUNC(bool, mright); MAKE_FUNC(bool, mwheel, int height, double d); MAKE_FUNC(bool, mup); MAKE_FUNC(bool, mleave); #undef MAKE_FUNC /* Use the preprocessor to add code to adjust the x,y cords for panels or sub panels. * If neg value place x/y from the right/bottom of panel. * * change the relative * * if w/h <0 use parent panel width (maybe?) */ #define FIX_XY_CORDS_FOR_SUBPANELS() \ { \ int relx = (p->x < 0) ? width + SCALE(p->x) : SCALE(p->x); \ int rely = (p->y < 0) ? height + SCALE(p->y) : SCALE(p->y); \ x += relx; \ y += rely; \ width = (p->width <= 0) ? width + SCALE(p->width) - relx : SCALE(p->width); \ height = (p->height <= 0) ? height + SCALE(p->height) - rely : SCALE(p->height); \ } static void panel_update(PANEL *p, int x, int y, int width, int height) { FIX_XY_CORDS_FOR_SUBPANELS(); switch (p->type) { case PANEL_NONE: { if (p == &panel_settings_devices) { #ifdef ENABLE_MULTIDEVICE devices_update_ui(); #endif } break; } case PANEL_MESSAGES: { if (p->object) { MESSAGES *m = p->object; m->width = width; messages_updateheight(m, width); } break; } default: { break; } } PANEL **pp = p->child; if (pp) { if (p->update) { p->update(width, height, ui_scale); } PANEL *subp; while ((subp = *pp++)) { panel_update(subp, x, y, width, height); } } } void draw_avatar_image(NATIVE_IMAGE *image, int x, int y, uint32_t width, uint32_t height, uint32_t targetwidth, uint32_t targetheight) { /* get smallest of width or height */ const double scale = (width > height) ? (double)targetheight / height : (double)targetwidth / width; image_set_scale(image, scale); image_set_filter(image, FILTER_BILINEAR); /* set position to show the middle of the image in the center */ const int xpos = (int)((double)width * scale / 2 - (double)targetwidth / 2); const int ypos = (int)((double)height * scale / 2 - (double)targetheight / 2); draw_image(image, x, y, targetwidth, targetheight, xpos, ypos); image_set_scale(image, 1.0); image_set_filter(image, FILTER_NEAREST); } void ui_size(int width, int height) { panel_update(&panel_root, 0, 0, width, height); tooltip_reset(); panel_side_bar.disabled = false; panel_main.x = panel_flist.width; if (settings.magic_flist_enabled) { if (width <= panel_flist.width * 2 || height > width) { panel_side_bar.disabled = true; panel_main.x = 0; } } } void ui_mouseleave(void) { panel_mleave(&panel_root); tooltip_reset(); redraw(); } static void panel_draw_core(PANEL *p, int x, int y, int width, int height) { FIX_XY_CORDS_FOR_SUBPANELS(); if (p->content_scroll) { pushclip(x, y, width, height); y -= scroll_gety(p->content_scroll, height); } if (p->type) { drawfunc[p->type - 1](p, x, y, width, height); } else { if (p->drawfunc) { p->drawfunc(x, y, width, height); } } PANEL **pp = p->child; if (pp) { PANEL *subp; while ((subp = *pp++)) { if (!subp->disabled) { panel_draw_core(subp, x, y, width, height); } } } if (p->content_scroll) { popclip(); } } void panel_draw(PANEL *p, int x, int y, int width, int height) { FIX_XY_CORDS_FOR_SUBPANELS(); panel_draw_core(p, x, y, width, height); // popclip(); dropdown_drawactive(); contextmenu_draw(); tooltip_draw(); enddraw(x, y, width, height); } bool panel_mmove(PANEL *p, int x, int y, int width, int height, int mx, int my, int dx, int dy) { if (p == &panel_root) { mouse.x = mx; mouse.y = my; } mx -= (p->x < 0) ? width + SCALE(p->x) : SCALE(p->x); my -= (p->y < 0) ? height + SCALE(p->y) : SCALE(p->y); FIX_XY_CORDS_FOR_SUBPANELS(); int mmy = my; if (p->content_scroll) { const int scroll_y = scroll_gety(p->content_scroll, height); if (my < 0) { mmy = -1; } else if (my >= height) { mmy = 1024 * 1024 * 1024; // large value } else { mmy = my + scroll_y; } y -= scroll_y; my += scroll_y; } bool draw = p->type ? mmovefunc[p->type - 1](p, x, y, width, height, mx, mmy, dx, dy) : false; // Has to be called before children mmove if (p == &panel_root) { draw |= tooltip_mmove(); } PANEL **pp = p->child; if (pp) { PANEL *subp; while ((subp = *pp++)) { if (!subp->disabled) { draw |= panel_mmove(subp, x, y, width, height, mx, my, dx, dy); } } } if (p == &panel_root) { draw |= contextmenu_mmove(mx, my, dx, dy); if (draw) { redraw(); } } return draw; } static bool panel_mdown_sub(PANEL *p) { if (p->type && mdownfunc[p->type - 1](p)) { return true; } PANEL **pp = p->child; if (pp) { PANEL *subp; while ((subp = *pp++)) { if (!subp->disabled) { if (panel_mdown_sub(subp)) { return true; } } } } return false; } void panel_mdown(PANEL *p) { if (contextmenu_mdown() || tooltip_mdown()) { redraw(); return; } bool draw = edit_active(); PANEL **pp = p->child; if (pp) { PANEL *subp; while ((subp = *pp++)) { if (!subp->disabled) { draw |= panel_mdown_sub(subp); } } } if (draw) { redraw(); } } bool panel_dclick(PANEL *p, bool triclick) { bool draw = false; if (p->type == PANEL_EDIT) { draw = edit_dclick((EDIT *)p, triclick); } else if (p->type == PANEL_MESSAGES) { draw = messages_dclick(p, triclick); } PANEL **pp = p->child; if (pp) { PANEL *subp; while ((subp = *pp++)) { if (!subp->disabled) { draw = panel_dclick(subp, triclick); if (draw) { break; } } } } if (draw && p == &panel_root) { redraw(); } return draw; } bool panel_mright(PANEL *p) { bool draw = p->type ? mrightfunc[p->type - 1](p) : false; PANEL **pp = p->child; if (pp) { PANEL *subp; while ((subp = *pp++)) { if (!subp->disabled) { draw |= panel_mright(subp); } } } if (draw && p == &panel_root) { redraw(); } return draw; } bool panel_mwheel(PANEL *p, int x, int y, int width, int height, double d, bool smooth) { FIX_XY_CORDS_FOR_SUBPANELS(); bool draw = p->type ? mwheelfunc[p->type - 1](p, height, d) : false; PANEL **pp = p->child; if (pp) { PANEL *subp; while ((subp = *pp++)) { if (!subp->disabled) { draw |= panel_mwheel(subp, x, y, width, height, d, smooth); } } } if (draw && p == &panel_root) { redraw(); } return draw; } bool panel_mup(PANEL *p) { if (p == &panel_root && contextmenu_mup()) { tooltip_mup(); redraw(); return true; } bool draw = p->type ? mupfunc[p->type - 1](p) : false; PANEL **pp = p->child; if (pp) { PANEL *subp; while ((subp = *pp++)) { if (!subp->disabled) { draw |= panel_mup(subp); } } } if (p == &panel_root) { tooltip_mup(); if (draw) { redraw(); } } return draw; } bool panel_mleave(PANEL *p) { bool draw = p->type ? mleavefunc[p->type - 1](p) : false; PANEL **pp = p->child; if (pp) { PANEL *subp; while ((subp = *pp++)) { if (!subp->disabled) { draw |= panel_mleave(subp); } } } if (p == &panel_root) { draw |= contextmenu_mleave(); if (draw) { redraw(); } } return draw; } uTox/src/tox_callbacks.h0000600000175000001440000000031714003056216014250 0ustar rakusers#ifndef TOX_CALLBACKS_H #define TOX_CALLBACKS_H #include void utox_set_callbacks_friends(Tox *tox); void utox_set_callbacks_groups(Tox *tox); void utox_set_callbacks_mdevice(Tox *tox); #endif uTox/src/tox_callbacks.c0000600000175000001440000003635014003056216014251 0ustar rakusers#include "tox_callbacks.h" #include "avatar.h" #include "file_transfers.h" #include "friend.h" #include "groups.h" #include "debug.h" #include "macros.h" #include "settings.h" #include "text.h" #include "utox.h" #include "ui.h" #include "av/audio.h" #include "av/utox_av.h" #include #include #include static void callback_friend_request(Tox *UNUSED(tox), const uint8_t *id, const uint8_t *msg, size_t length, void *UNUSED(userdata)) { if (settings.block_friend_requests) { LOG_WARN("Tox Callbacks", "Friend request ignored."); // TODO move to friend.c return; } length = utf8_validate(msg, length); uint16_t r_number = friend_request_new(id, msg, length); postmessage_utox(FRIEND_INCOMING_REQUEST, r_number, 0, NULL); postmessage_audio(UTOXAUDIO_PLAY_NOTIFICATION, NOTIFY_TONE_FRIEND_REQUEST, 0, NULL); } static void callback_friend_message(Tox *UNUSED(tox), uint32_t friend_number, TOX_MESSAGE_TYPE type, const uint8_t *message, size_t length, void *UNUSED(userdata)) { /* send message to UI */ FRIEND *f = get_friend(friend_number); if (!f) { LOG_ERR("Tox Callbacks", "Could not get friend with number: %u", friend_number); return; } switch (type) { case TOX_MESSAGE_TYPE_NORMAL: { message_add_type_text(&f->msg, 0, (char *)message, length, 1, 0); LOG_INFO("Tox Callbacks", "Friend\t%u\t--\tStandard Message: %.*s" , friend_number, (int)length, message); break; } case TOX_MESSAGE_TYPE_ACTION: { message_add_type_action(&f->msg, 0, (char *)message, length, 1, 0); LOG_INFO("Tox Callbacks", "Friend\t%u\t--\tAction Message: %.*s" , friend_number, (int)length, message); break; } default: { LOG_ERR("Tox Callbacks", "Friend\t%u\t--\tUnsupported message type: %.*s" , friend_number, (int)length, message); break; } } friend_notify_msg(f, (char *)message, length); } static void callback_name_change(Tox *UNUSED(tox), uint32_t fid, const uint8_t *newname, size_t length, void *UNUSED(userdata)) { length = utf8_validate(newname, length); void *data = malloc(length); if (!data) { LOG_FATAL_ERR(EXIT_MALLOC, "Tox Callbacks", "Could not alloc for name change callback (%uB)", length); } memcpy(data, newname, length); postmessage_utox(FRIEND_NAME, fid, length, data); LOG_INFO("Tox Callbacks", "Friend\t%u\t--\tName:\t%.*s", fid, (int)length, newname); } static void callback_status_message(Tox *UNUSED(tox), uint32_t fid, const uint8_t *newstatus, size_t length, void *UNUSED(userdata)) { length = utf8_validate(newstatus, length); void *data = malloc(length); if (!data) { LOG_FATAL_ERR(EXIT_MALLOC, "Tox Callbacks", "Could not alloc for name change callback (%uB)", length); } memcpy(data, newstatus, length); postmessage_utox(FRIEND_STATUS_MESSAGE, fid, length, data); LOG_INFO("Tox Callbacks", "Friend\t%u\t--\tStatus Message:\t%.*s", fid, (int)length, newstatus); } static void callback_user_status(Tox *UNUSED(tox), uint32_t fid, TOX_USER_STATUS status, void *UNUSED(userdata)) { postmessage_utox(FRIEND_STATE, fid, status, NULL); LOG_INFO("Tox Callbacks", "Friend\t%u\t--\tState:\t%u", fid, status); } static void callback_typing_change(Tox *UNUSED(tox), uint32_t fid, bool is_typing, void *UNUSED(userdata)) { postmessage_utox(FRIEND_TYPING, fid, is_typing, NULL); LOG_DEBUG("Tox Callbacks", "Friend\t%u\t--\tTyping:\t%u", fid, is_typing); } static void callback_read_receipt(Tox *UNUSED(tox), uint32_t fid, uint32_t receipt, void *UNUSED(userdata)) { FRIEND *f = get_friend(fid); if (!f) { LOG_ERR("Tox Callbacks", "Could not get friend with number: %u", fid); return; } messages_clear_receipt(&f->msg, receipt); LOG_INFO("Tox Callbacks", "Friend\t%u\t--\tReceipt:\t%u", fid, receipt); } static void callback_connection_status(Tox *tox, uint32_t fid, TOX_CONNECTION status, void *UNUSED(userdata)) { FRIEND *f = get_friend(fid); if (!f) { LOG_ERR("Tox Callbacks", "Could not get friend with number: %u", fid); return; } if (f->online && !status) { ft_friend_offline(tox, fid); if (f->call_state_self || f->call_state_friend) { utox_av_local_disconnect(NULL, fid); /* TODO HACK, toxav doesn't supply a toxav_get_toxav_from_tox() yet. */ } } else if (!f->online && !!status) { ft_friend_online(tox, fid); /* resend avatar info (in case it changed) */ /* Avatars must be sent LAST or they will clobber existing file transfers! */ avatar_on_friend_online(tox, fid); friend_notify_status(f, (uint8_t *)f->status_message, f->status_length, S(STATUS_ONLINE)); } postmessage_utox(FRIEND_ONLINE, fid, !!status, NULL); if (status == TOX_CONNECTION_UDP) { LOG_INFO("Tox Callbacks", "Friend\t%u\t--\tOnline (UDP)", fid); } else if (status == TOX_CONNECTION_TCP) { LOG_INFO("Tox Callbacks", "Friend\t%u\t--\tOnline (TCP)", fid); } else { LOG_INFO("Tox Callbacks", "Friend\t%u\t--\tOffline", fid); friend_notify_status(f, NULL, 0, S(STATUS_OFFLINE)); } } void utox_set_callbacks_friends(Tox *tox) { tox_callback_friend_request(tox, callback_friend_request); tox_callback_friend_message(tox, callback_friend_message); tox_callback_friend_name(tox, callback_name_change); tox_callback_friend_status_message(tox, callback_status_message); tox_callback_friend_status(tox, callback_user_status); tox_callback_friend_typing(tox, callback_typing_change); tox_callback_friend_read_receipt(tox, callback_read_receipt); tox_callback_friend_connection_status(tox, callback_connection_status); } void callback_av_group_audio(void *tox, uint32_t groupnumber, uint32_t peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata); static void callback_group_invite(Tox *tox, uint32_t fid, TOX_CONFERENCE_TYPE type, const uint8_t *data, size_t length, void *UNUSED(userdata)) { LOG_NOTE("Tox Callbacks", "Group Invite (friend %i || type %u)", fid, type); uint32_t gid = UINT32_MAX; if (type == TOX_CONFERENCE_TYPE_TEXT) { gid = tox_conference_join(tox, fid, data, length, NULL); } else if (type == TOX_CONFERENCE_TYPE_AV) { gid = toxav_join_av_groupchat(tox, fid, data, length, callback_av_group_audio, NULL); } if (gid == UINT32_MAX) { LOG_ERR("Tox Callbacks", "Could not join group with type: %u", type); return; } GROUPCHAT *g = get_group(gid); if (!g) { g = group_create(gid, type == TOX_CONFERENCE_TYPE_AV ? true : false, NULL); if (!g) { LOG_ERR("Tox Callbacks", "Failed to create group (number: %u type: %u)", gid, type); } } else { group_init(g, gid, type == TOX_CONFERENCE_TYPE_AV ? true : false, NULL); } LOG_NOTE("Tox Callbacks", "auto join successful group number %u", gid); postmessage_utox(GROUP_ADD, gid, 0, tox); } static void callback_group_message(Tox *UNUSED(tox), uint32_t gid, uint32_t pid, TOX_MESSAGE_TYPE type, const uint8_t *message, size_t length, void *UNUSED(userdata)) { GROUPCHAT *g = get_group(gid); switch (type) { case TOX_MESSAGE_TYPE_ACTION: { LOG_TRACE("Tox Callbacks", "Group Action (%u, %u): %.*s" , gid, pid, (int)length, message); group_add_message(g, pid, message, length, MSG_TYPE_ACTION_TEXT); break; } case TOX_MESSAGE_TYPE_NORMAL: { LOG_INFO("Tox Callbacks", "Group Message (%u, %u): %.*s", gid, pid, (int)length, message); group_add_message(g, pid, message, length, MSG_TYPE_TEXT); break; } } group_notify_msg(g, (const char *)message, length); postmessage_utox(GROUP_MESSAGE, gid, pid, NULL); } static void callback_group_peer_name_change(Tox *UNUSED(tox), uint32_t gid, uint32_t pid, const uint8_t *name, size_t length, void *UNUSED(userdata)){ LOG_DEBUG("Tox Callbacks", "Group:\tPeer name change (%u, %u)" , gid, pid); GROUPCHAT *g = get_group(gid); if (!g) { LOG_ERR("Tox Callbacks", "Could not get groupchat: %u", gid); return; } if (g->peer) { if (!g->peer[pid]) { LOG_ERR("Tox Callbacks", "Tox Group:\tERROR, can't set a name, for non-existent peer!" ); return; } } else { // TODO can't happen LOG_ERR("Tox Callbacks", "Tox Group:\tERROR, can't set a name, for non-existent Group!" ); } length = utf8_validate(name, length); group_peer_name_change(g, pid, name, length); postmessage_utox(GROUP_PEER_NAME, gid, pid, NULL); } static void callback_group_peer_list_changed(Tox *tox, uint32_t gid, void *UNUSED(userdata)){ GROUPCHAT *g = get_group(gid); if (!g) { LOG_ERR("Tox Callbacks", "Could not get group: %u", gid); return; } pthread_mutex_lock(&messages_lock); /* make sure that messages has posted before we continue */ group_reset_peerlist(g); uint32_t number_peers = tox_conference_peer_count(tox, gid, NULL); g->peer = calloc(number_peers, sizeof(void *)); if (!g->peer) { LOG_FATAL_ERR(EXIT_MALLOC, "Tox Callbacks", "Group:\tToxcore is very broken, but we couldn't alloc here."); } /* I'm about to break some uTox style here, because I'm expecting * the API to change soon, and I just can't when it's this broken */ for (uint32_t i = 0; i < number_peers; ++i) { uint8_t tmp[TOX_MAX_NAME_LENGTH]; size_t len = tox_conference_peer_get_name_size(tox, gid, i, NULL); tox_conference_peer_get_name(tox, gid, i, tmp, NULL); GROUP_PEER *peer = calloc(1, sizeof(*peer) + len + 1); if (!peer) { LOG_FATAL_ERR(EXIT_MALLOC, "Group", "Toxcore is very broken, but we couldn't calloc here."); } /* name and id number (it's worthless, but it's needed */ memcpy(peer->name, tmp, len); peer->name_length = len; peer->id = i; /* get static random color */ uint8_t pkey[TOX_PUBLIC_KEY_SIZE]; tox_conference_peer_get_public_key(tox, gid, i, pkey, NULL); uint64_t pkey_to_number = 0; for (int key_i = 0; key_i < TOX_PUBLIC_KEY_SIZE; ++key_i) { pkey_to_number += pkey[key_i]; } /* uTox doesnt' really use this for too much so let's fuck with the random seed. * If you know crypto, and cringe, I know me too... you can blame @irungentoo */ srand(pkey_to_number); peer->name_color = RGB(rand(), rand(), rand()); g->peer[i] = peer; } g->peer_count = number_peers; postmessage_utox(GROUP_PEER_CHANGE, gid, 0, NULL); pthread_mutex_unlock(&messages_lock); /* make sure that messages has posted before we continue */ } static void callback_group_topic(Tox *UNUSED(tox), uint32_t gid, uint32_t pid, const uint8_t *title, size_t length, void *UNUSED(userdata)) { length = utf8_validate(title, length); if (!length) return; uint8_t *copy_title = malloc(length); if (!copy_title) return; memcpy(copy_title, title, length); postmessage_utox(GROUP_TOPIC, gid, length, copy_title); LOG_TRACE("Tox Callbacks", "Group Title (%u, %u): %.*s" , gid, pid, (int)length, title); } void callback_group_connected(Tox *UNUSED(tox), uint32_t gid, void *UNUSED(userdata)){ GROUPCHAT *g = get_group(gid); if (!g) { LOG_ERR("Tox Callbacks", "Toxcore says we're connected to a non-existent groupchat %u.", gid); return; } g->connected = true; LOG_TRACE("Tox Callbacks", "Connected to groupchat %u.", gid); } void utox_set_callbacks_groups(Tox *tox) { tox_callback_conference_invite(tox, callback_group_invite); tox_callback_conference_message(tox, callback_group_message); tox_callback_conference_peer_name(tox, callback_group_peer_name_change); tox_callback_conference_title(tox, callback_group_topic); tox_callback_conference_peer_list_changed(tox, callback_group_peer_list_changed); tox_callback_conference_connected(tox, callback_group_connected); } #ifdef ENABLE_MULTIDEVICE static void callback_friend_list_change(Tox *tox, void *user_data) { LOG_ERR("Tox Callbacks", "friend list change, updating roster"); flist_dump_contacts(); utox_friend_list_init(tox); flist_reload_contacts(); } static void callback_mdev_self_name(Tox *tox, uint32_t dev_num, const uint8_t *name, size_t length, void *UNUSED(userdata)) { LOG_TRACE("Tox Callbacks", "Name changed on remote device %u", dev_num); memcpy(self.name, name, length); self.name_length = length; edit_setstr(&edit_name, self.name, self.name_length); postmessage_utox(REDRAW, 0, 0, NULL); } typedef void tox_mdev_self_status_message_cb(Tox *tox, uint32_t device_number, const uint8_t *status_message, size_t len, void *user_data); static void callback_mdev_self_status_msg(Tox *tox, uint32_t dev_num, const uint8_t *smsg, size_t length, void *UNUSED(userdata)) { LOG_TRACE("Tox Callbacks", "Status Message changed on remote device %u", dev_num); memcpy(self.statusmsg, smsg, length); self.statusmsg_length = length; edit_setstr(&edit_status, self.statusmsg, self.statusmsg_length); postmessage_utox(REDRAW, 0, 0, NULL); } static void callback_mdev_self_state(Tox *tox, uint32_t device_number, TOX_USER_STATUS state, void *user_data) { self.status = state; } static void callback_device_sent_message(Tox *tox, uint32_t sending_device, uint32_t target_friend, TOX_MESSAGE_TYPE type, uint8_t *msg, size_t msg_length) { LOG_TRACE("Tox Callbacks", "Message sent from other device %u\n\t\t%.*s" , sending_device, (uint32_t)msg_length, msg); switch (type) { case TOX_MESSAGE_TYPE_NORMAL: { message_add_type_text(&friend[target_friend].msg, 1, msg, msg_length, 1, 0); break; } case TOX_MESSAGE_TYPE_ACTION: { message_add_type_action(&friend[target_friend].msg, 1, msg, msg_length, 1, 0); break; } default: { LOG_ERR("Tox Callbacks", "Message from Friend\t%u\t--\tof unsupported type: %.*s", target_friend, (uint32_t)msg_length, msg); } } friend_notify_msg(&friend[target_friend], msg, msg_length); postmessage_utox(FRIEND_MESSAGE_UPDATE, target_friend, 0, NULL); } void utox_set_callbacks_mdevice(Tox *tox) { tox_callback_friend_list_change(tox, callback_friend_list_change, NULL); tox_callback_mdev_self_status_message(tox, callback_mdev_self_status_msg, NULL); tox_callback_mdev_self_name(tox, callback_mdev_self_name, NULL); tox_callback_mdev_self_state(tox, callback_mdev_self_state, NULL); tox_callback_mdev_sent_message(tox, callback_device_sent_message, NULL); } #endif uTox/src/tox_bootstrap.h0000600000175000001440000002406514003056216014354 0ustar rakusers#ifndef TOX_BOOTSTRAP_H #define TOX_BOOTSTRAP_H // // IMPORTANT: This file is generated by the /tools/update-bootstrap.py script, do not edit manually. // struct bootstrap_node { char *address; bool ipv6; uint16_t port_udp; uint16_t port_tcp; uint8_t key[32]; } bootstrap_nodes[] = { /* by dvor, NL */ { "185.14.30.213", false, 443, 443, { 0x25, 0x55, 0x76, 0x3C, 0x8C, 0x46, 0x04, 0x95, 0xB1, 0x41, 0x57, 0xD2, 0x34, 0xDD, 0x56, 0xB8, 0x63, 0x00, 0xA2, 0x39, 0x55, 0x54, 0xBC, 0xAE, 0x46, 0x21, 0xAC, 0x34, 0x5B, 0x8C, 0x1B, 0x1B, } }, /* by dvor, NL */ { "2a00:1ca8:a7::e8b", true, 443, 443, { 0x25, 0x55, 0x76, 0x3C, 0x8C, 0x46, 0x04, 0x95, 0xB1, 0x41, 0x57, 0xD2, 0x34, 0xDD, 0x56, 0xB8, 0x63, 0x00, 0xA2, 0x39, 0x55, 0x54, 0xBC, 0xAE, 0x46, 0x21, 0xAC, 0x34, 0x5B, 0x8C, 0x1B, 0x1B, } }, /* by CeBe, DE */ { "136.243.141.187", false, 443, 443, { 0x6E, 0xE1, 0xFA, 0xDE, 0x9F, 0x55, 0xCC, 0x79, 0x38, 0x23, 0x4C, 0xC0, 0x7C, 0x86, 0x40, 0x81, 0xFC, 0x60, 0x6D, 0x8F, 0xE7, 0xB7, 0x51, 0xED, 0xA2, 0x17, 0xF2, 0x68, 0xF1, 0x07, 0x8A, 0x39, } }, /* by CeBe, DE */ { "2a01:4f8:212:2459::a:1337", true, 443, 443, { 0x6E, 0xE1, 0xFA, 0xDE, 0x9F, 0x55, 0xCC, 0x79, 0x38, 0x23, 0x4C, 0xC0, 0x7C, 0x86, 0x40, 0x81, 0xFC, 0x60, 0x6D, 0x8F, 0xE7, 0xB7, 0x51, 0xED, 0xA2, 0x17, 0xF2, 0x68, 0xF1, 0x07, 0x8A, 0x39, } }, /* by pucetox, DE */ { "148.251.23.146", false, 2306, 2306, { 0x7A, 0xED, 0x21, 0xF9, 0x4D, 0x82, 0xB0, 0x57, 0x74, 0xF6, 0x97, 0xB2, 0x09, 0x62, 0x8C, 0xD5, 0xA9, 0xAD, 0x17, 0xE0, 0xC0, 0x73, 0xD9, 0x32, 0x90, 0x76, 0xA4, 0xC2, 0x8E, 0xD2, 0x81, 0x47, } }, /* by pucetox, DE */ { "2a01:4f8:201:8493::2", true, 2306, 2306, { 0x7A, 0xED, 0x21, 0xF9, 0x4D, 0x82, 0xB0, 0x57, 0x74, 0xF6, 0x97, 0xB2, 0x09, 0x62, 0x8C, 0xD5, 0xA9, 0xAD, 0x17, 0xE0, 0xC0, 0x73, 0xD9, 0x32, 0x90, 0x76, 0xA4, 0xC2, 0x8E, 0xD2, 0x81, 0x47, } }, /* by Cactus, RU */ { "193.124.186.205", false, 5228, 33445, { 0x99, 0x06, 0xD6, 0x5F, 0x2A, 0x47, 0x51, 0x06, 0x8A, 0x59, 0xD3, 0x05, 0x05, 0xC5, 0xFC, 0x8A, 0xE1, 0xA9, 0x5E, 0x08, 0x43, 0xAE, 0x93, 0x72, 0xEA, 0xFA, 0x3B, 0xAB, 0x6A, 0xC1, 0x6C, 0x2C, } }, /* by Cactus, RU */ { "2a02:f680:1:1100::542a", true, 5228, 33445, { 0x99, 0x06, 0xD6, 0x5F, 0x2A, 0x47, 0x51, 0x06, 0x8A, 0x59, 0xD3, 0x05, 0x05, 0xC5, 0xFC, 0x8A, 0xE1, 0xA9, 0x5E, 0x08, 0x43, 0xAE, 0x93, 0x72, 0xEA, 0xFA, 0x3B, 0xAB, 0x6A, 0xC1, 0x6C, 0x2C, } }, /* by Manolis, DE */ { "130.133.110.14", false, 33445, 33445, { 0x46, 0x1F, 0xA3, 0x77, 0x6E, 0xF0, 0xFA, 0x65, 0x5F, 0x1A, 0x05, 0x47, 0x7D, 0xF1, 0xB3, 0xB6, 0x14, 0xF7, 0xD6, 0xB1, 0x24, 0xF7, 0xDB, 0x1D, 0xD4, 0xFE, 0x3C, 0x08, 0xB0, 0x3B, 0x64, 0x0F, } }, /* by Manolis, DE */ { "2001:6f8:1c3c:babe::14:1", true, 33445, 33445, { 0x46, 0x1F, 0xA3, 0x77, 0x6E, 0xF0, 0xFA, 0x65, 0x5F, 0x1A, 0x05, 0x47, 0x7D, 0xF1, 0xB3, 0xB6, 0x14, 0xF7, 0xD6, 0xB1, 0x24, 0xF7, 0xDB, 0x1D, 0xD4, 0xFE, 0x3C, 0x08, 0xB0, 0x3B, 0x64, 0x0F, } }, /* by fluke571, SI */ { "194.249.212.109", false, 33445, 33445, { 0x3C, 0xEE, 0x1F, 0x05, 0x40, 0x81, 0xE7, 0xA0, 0x11, 0x23, 0x48, 0x83, 0xBC, 0x4F, 0xC3, 0x9F, 0x66, 0x1A, 0x55, 0xB7, 0x36, 0x37, 0xA5, 0xAC, 0x29, 0x3D, 0xDF, 0x12, 0x51, 0xD9, 0x43, 0x2B, } }, /* by fluke571, SI */ { "2001:1470:fbfe::109", true, 33445, 33445, { 0x3C, 0xEE, 0x1F, 0x05, 0x40, 0x81, 0xE7, 0xA0, 0x11, 0x23, 0x48, 0x83, 0xBC, 0x4F, 0xC3, 0x9F, 0x66, 0x1A, 0x55, 0xB7, 0x36, 0x37, 0xA5, 0xAC, 0x29, 0x3D, 0xDF, 0x12, 0x51, 0xD9, 0x43, 0x2B, } }, /* by ru_maniac, US */ { "104.223.122.15", false, 33445, 3389, { 0x0F, 0xB9, 0x6E, 0xEB, 0xFB, 0x16, 0x50, 0xDD, 0xB5, 0x2E, 0x70, 0xCF, 0x77, 0x3D, 0xDF, 0xCA, 0xBE, 0x25, 0xA9, 0x5C, 0xC3, 0xBB, 0x50, 0xFC, 0x25, 0x10, 0x82, 0xE4, 0xB6, 0x3E, 0xF8, 0x2A, } }, /* by ru_maniac, US */ { "2607:ff48:aa81:800::35eb:1", true, 33445, 3389, { 0x0F, 0xB9, 0x6E, 0xEB, 0xFB, 0x16, 0x50, 0xDD, 0xB5, 0x2E, 0x70, 0xCF, 0x77, 0x3D, 0xDF, 0xCA, 0xBE, 0x25, 0xA9, 0x5C, 0xC3, 0xBB, 0x50, 0xFC, 0x25, 0x10, 0x82, 0xE4, 0xB6, 0x3E, 0xF8, 0x2A, } }, /* by a68366, FR */ { "51.254.84.212", false, 33445, 33445, { 0xAE, 0xC2, 0x04, 0xB9, 0xA4, 0x50, 0x14, 0x12, 0xD5, 0xF0, 0xBB, 0x67, 0xD9, 0xC8, 0x1B, 0x5D, 0xB3, 0xEE, 0x6A, 0xDA, 0x64, 0x12, 0x2D, 0x32, 0xA3, 0xE9, 0xB0, 0x93, 0xD5, 0x44, 0x32, 0x7D, } }, /* by a68366, FR */ { "2001:41d0:a:1a3b::18", true, 33445, 33445, { 0xAE, 0xC2, 0x04, 0xB9, 0xA4, 0x50, 0x14, 0x12, 0xD5, 0xF0, 0xBB, 0x67, 0xD9, 0xC8, 0x1B, 0x5D, 0xB3, 0xEE, 0x6A, 0xDA, 0x64, 0x12, 0x2D, 0x32, 0xA3, 0xE9, 0xB0, 0x93, 0xD5, 0x44, 0x32, 0x7D, } }, /* by ru_maniac, RU */ { "185.58.206.164", false, 33445, 33445, { 0x24, 0x15, 0x64, 0x72, 0x04, 0x1E, 0x5F, 0x22, 0x0D, 0x1F, 0xA1, 0x1D, 0x9D, 0xF3, 0x2F, 0x7A, 0xD6, 0x97, 0xD5, 0x98, 0x45, 0x70, 0x1C, 0xDD, 0x7B, 0xE7, 0xD1, 0x78, 0x5E, 0xB9, 0xDB, 0x39, } }, /* by ru_maniac, RU */ { "2a02:f680:1:1100::3313", true, 33445, 33445, { 0x24, 0x15, 0x64, 0x72, 0x04, 0x1E, 0x5F, 0x22, 0x0D, 0x1F, 0xA1, 0x1D, 0x9D, 0xF3, 0x2F, 0x7A, 0xD6, 0x97, 0xD5, 0x98, 0x45, 0x70, 0x1C, 0xDD, 0x7B, 0xE7, 0xD1, 0x78, 0x5E, 0xB9, 0xDB, 0x39, } }, /* by strngr, UA */ { "195.93.190.6", false, 33445, 33445, { 0xFB, 0x4C, 0xE0, 0xDD, 0xEF, 0xEE, 0xD4, 0x5F, 0x26, 0x91, 0x70, 0x53, 0xE5, 0xD2, 0x4B, 0xDD, 0xA0, 0xFA, 0x0A, 0x3D, 0x83, 0xA6, 0x72, 0xA9, 0xDA, 0x23, 0x75, 0x92, 0x8B, 0x37, 0x02, 0x3D, } }, /* by strngr, UA */ { "2a01:d0:ffff:a8a::2", true, 33445, 33445, { 0xFB, 0x4C, 0xE0, 0xDD, 0xEF, 0xEE, 0xD4, 0x5F, 0x26, 0x91, 0x70, 0x53, 0xE5, 0xD2, 0x4B, 0xDD, 0xA0, 0xFA, 0x0A, 0x3D, 0x83, 0xA6, 0x72, 0xA9, 0xDA, 0x23, 0x75, 0x92, 0x8B, 0x37, 0x02, 0x3D, } }, /* by HooinKyoma, SE */ { "95.215.44.78", false, 33445, 3389, { 0x67, 0x2D, 0xBE, 0x27, 0xB4, 0xAD, 0xB9, 0xD5, 0xFB, 0x10, 0x5A, 0x6B, 0xB6, 0x48, 0xB2, 0xF8, 0xFD, 0xB8, 0x9B, 0x33, 0x23, 0x48, 0x6A, 0x7A, 0x21, 0x96, 0x83, 0x16, 0xE0, 0x12, 0x02, 0x3C, } }, /* by HooinKyoma, SE */ { "2a02:7aa0:1619::c6fe:d0cb", true, 33445, 3389, { 0x67, 0x2D, 0xBE, 0x27, 0xB4, 0xAD, 0xB9, 0xD5, 0xFB, 0x10, 0x5A, 0x6B, 0xB6, 0x48, 0xB2, 0xF8, 0xFD, 0xB8, 0x9B, 0x33, 0x23, 0x48, 0x6A, 0x7A, 0x21, 0x96, 0x83, 0x16, 0xE0, 0x12, 0x02, 0x3C, } }, /* by LittleVulpix, FR */ { "163.172.136.118", false, 33445, 3389, { 0x2C, 0x28, 0x9F, 0x9F, 0x37, 0xC2, 0x0D, 0x09, 0xDA, 0x83, 0x56, 0x55, 0x88, 0xBF, 0x49, 0x6F, 0xAB, 0x37, 0x64, 0x85, 0x3F, 0xA3, 0x81, 0x41, 0x81, 0x7A, 0x72, 0xE3, 0xF1, 0x8A, 0xCA, 0x0B, } }, /* by LittleVulpix, FR */ { "2001:bc8:4400:2100::1c:50f", true, 33445, 3389, { 0x2C, 0x28, 0x9F, 0x9F, 0x37, 0xC2, 0x0D, 0x09, 0xDA, 0x83, 0x56, 0x55, 0x88, 0xBF, 0x49, 0x6F, 0xAB, 0x37, 0x64, 0x85, 0x3F, 0xA3, 0x81, 0x41, 0x81, 0x7A, 0x72, 0xE3, 0xF1, 0x8A, 0xCA, 0x0B, } }, /* by Yani, NL */ { "37.97.185.116", false, 33445, 33445, { 0xE5, 0x9A, 0x0E, 0x71, 0xAD, 0xA2, 0x0D, 0x35, 0xBD, 0x1B, 0x09, 0x57, 0x05, 0x9D, 0x7E, 0xF7, 0xE7, 0x79, 0x2B, 0x3D, 0x68, 0x0A, 0xE2, 0x5C, 0x6F, 0x4D, 0xBB, 0xA0, 0x91, 0x14, 0xD1, 0x65, } }, /* by linxon, RU */ { "80.87.193.193", false, 33445, 3389, { 0xB3, 0x82, 0x55, 0xEE, 0x4B, 0x05, 0x49, 0x24, 0xF6, 0xD7, 0x9A, 0x5E, 0x6E, 0x58, 0x89, 0xEC, 0x94, 0xB6, 0xAD, 0xF6, 0xFE, 0x99, 0x06, 0xF9, 0x7A, 0x3D, 0x01, 0xE3, 0xD0, 0x83, 0x22, 0x3A, } }, /* by linxon, RU */ { "2a01:230:2:6::46a8", true, 33445, 3389, { 0xB3, 0x82, 0x55, 0xEE, 0x4B, 0x05, 0x49, 0x24, 0xF6, 0xD7, 0x9A, 0x5E, 0x6E, 0x58, 0x89, 0xEC, 0x94, 0xB6, 0xAD, 0xF6, 0xFE, 0x99, 0x06, 0xF9, 0x7A, 0x3D, 0x01, 0xE3, 0xD0, 0x83, 0x22, 0x3A, } }, /* by Stranger, UA */ { "46.229.52.198", false, 33445, 33445, { 0x81, 0x3C, 0x8F, 0x41, 0x87, 0x83, 0x3E, 0xF0, 0x65, 0x5B, 0x10, 0xF7, 0x75, 0x21, 0x41, 0xA3, 0x52, 0x24, 0x84, 0x62, 0xA5, 0x67, 0x52, 0x9A, 0x38, 0xB6, 0xBB, 0xF7, 0x3E, 0x97, 0x93, 0x07, } }, /* by himura, RU */ { "85.21.144.224", false, 33445, 33445, { 0x8F, 0x73, 0x8B, 0xBC, 0x8F, 0xA9, 0x39, 0x46, 0x70, 0xBC, 0xAB, 0x14, 0x6C, 0x67, 0xA5, 0x07, 0xB9, 0x90, 0x7C, 0x8E, 0x56, 0x4E, 0x28, 0xC2, 0xB5, 0x9B, 0xEB, 0xB2, 0xFF, 0x68, 0x71, 0x1B, } }, /* by dolohow, FR */ { "37.187.122.30", false, 33445, 3389, { 0xBE, 0xB7, 0x1F, 0x97, 0xED, 0x9C, 0x99, 0xC0, 0x4B, 0x84, 0x89, 0xBB, 0x75, 0x57, 0x9E, 0xB4, 0xDC, 0x6A, 0xB6, 0xF4, 0x41, 0xB6, 0x03, 0xD6, 0x35, 0x33, 0x12, 0x2F, 0x18, 0x58, 0xB5, 0x1D, } }, /* by Busindre, US */ { "205.185.116.116", false, 33445, 33445, { 0xA1, 0x79, 0xB0, 0x97, 0x49, 0xAC, 0x82, 0x6F, 0xF0, 0x1F, 0x37, 0xA9, 0x61, 0x3F, 0x6B, 0x57, 0x11, 0x8A, 0xE0, 0x14, 0xD4, 0x19, 0x6A, 0x0E, 0x11, 0x05, 0xA9, 0x8F, 0x93, 0xA5, 0x47, 0x02, } }, /* by Busindre, US */ { "198.98.51.198", false, 33445, 3389, { 0x1D, 0x5A, 0x5F, 0x2F, 0x5D, 0x62, 0x33, 0x05, 0x8B, 0xF0, 0x25, 0x9B, 0x09, 0x62, 0x2F, 0xB4, 0x0B, 0x48, 0x2E, 0x4F, 0xA0, 0x93, 0x1E, 0xB8, 0xFD, 0x3A, 0xB8, 0xE7, 0xBF, 0x7D, 0xAF, 0x6F, } }, /* by Busindre, US */ { "2605:6400:1:fed5:22:45af:ec10:f329", true, 33445, 3389, { 0x1D, 0x5A, 0x5F, 0x2F, 0x5D, 0x62, 0x33, 0x05, 0x8B, 0xF0, 0x25, 0x9B, 0x09, 0x62, 0x2F, 0xB4, 0x0B, 0x48, 0x2E, 0x4F, 0xA0, 0x93, 0x1E, 0xB8, 0xFD, 0x3A, 0xB8, 0xE7, 0xBF, 0x7D, 0xAF, 0x6F, } }, /* by wildermesser, CA */ { "104.233.104.126", false, 33445, 33445, { 0xED, 0xEE, 0x8F, 0x2E, 0x83, 0x9A, 0x57, 0x82, 0x0D, 0xE3, 0xDA, 0x41, 0x56, 0xD8, 0x83, 0x50, 0xE5, 0x3D, 0x41, 0x61, 0x44, 0x70, 0x68, 0xA3, 0x45, 0x7E, 0xE8, 0xF5, 0x9F, 0x36, 0x24, 0x14, } }, }; #endif uTox/src/tox.h0000600000175000001440000000673014003056216012256 0ustar rakusers/* todo: proper system for posting messages to the toxcore thread, comments, better names (?), proper cleanup of a/v and * a/v thread*/ /* -proper unpause/pause file transfers, resuming file transfers + what if new file transfer with same id gets created before the main thread receives the message for the old one? >= GiB file sizes with FILE_*_PROGRESS on 32bit */ /* details about messages and their (param1, param2, data) values are in the message handlers in tox.c*/ #ifndef UTOX_TOX_H #define UTOX_TOX_H #include #include #include #include typedef uint8_t *UTOX_IMAGE; typedef struct { uint8_t msg; uint32_t param1, param2; void * data; } TOX_MSG; typedef enum UTOX_ENC_ERR { UTOX_ENC_ERR_NONE, UTOX_ENC_ERR_LENGTH, UTOX_ENC_ERR_BAD_PASS, UTOX_ENC_ERR_BAD_DATA, UTOX_ENC_ERR_UNKNOWN } UTOX_ENC_ERR; /* toxcore thread messages (sent from the client thread) */ enum { /* SHUTDOWNEVERYTHING! */ TOX_KILL, // 0 TOX_SAVE, /* Change our settings in core */ TOX_SELF_SET_NAME, TOX_SELF_SET_STATUS, TOX_SELF_SET_STATE, TOX_SELF_CHANGE_NOSPAM, TOX_SELF_NEW_DEVICE, /* Wooo pixturs */ TOX_AVATAR_SET, TOX_AVATAR_UNSET, /* Interact with contacts */ TOX_FRIEND_NEW, TOX_FRIEND_NEW_DEVICE, TOX_FRIEND_ACCEPT, TOX_FRIEND_DELETE, TOX_FRIEND_ONLINE, TOX_FRIEND_NEW_NO_REQ, /* Default actions */ TOX_SEND_MESSAGE, TOX_SEND_ACTION, /* Should we deprecate this, now that core uses a single function? */ TOX_SEND_TYPING, /* File Transfers */ TOX_FILE_ACCEPT, TOX_FILE_ACCEPT_AUTO, TOX_FILE_SEND_NEW, TOX_FILE_SEND_NEW_INLINE, TOX_FILE_SEND_NEW_SLASH, TOX_FILE_RESUME, TOX_FILE_PAUSE, TOX_FILE_CANCEL, /* Audio/Video Calls */ TOX_CALL_SEND, TOX_CALL_INCOMING, TOX_CALL_ANSWER, TOX_CALL_PAUSE_AUDIO, TOX_CALL_PAUSE_VIDEO, TOX_CALL_RESUME_AUDIO, TOX_CALL_RESUME_VIDEO, TOX_CALL_DISCONNECT, TOX_GROUP_CREATE, TOX_GROUP_JOIN, TOX_GROUP_PART, TOX_GROUP_SEND_INVITE, TOX_GROUP_SET_TOPIC, TOX_GROUP_SEND_MESSAGE, TOX_GROUP_SEND_ACTION, TOX_GROUP_AUDIO_START, TOX_GROUP_AUDIO_END, }; struct TOX_SEND_INLINE_MSG { size_t image_size; UTOX_IMAGE image; }; /* AV STATUS LIST */ enum { UTOX_AV_NONE, UTOX_AV_INVITE, UTOX_AV_RINGING, UTOX_AV_STARTED, }; typedef enum { // tox_thread is not initialized yet UTOX_TOX_THREAD_INIT_NONE = 0, // tox_thread is initialized successfully // this means a tox instance has been created UTOX_TOX_THREAD_INIT_SUCCESS = 1, // tox_thread is initialized but not successfully // this means a tox instance may have not been created UTOX_TOX_THREAD_INIT_ERROR = 2, } UTOX_TOX_THREAD_INIT; extern UTOX_TOX_THREAD_INIT tox_thread_init; /* Inter-thread communication vars. */ extern TOX_MSG tox_msg, audio_msg, toxav_msg; extern volatile bool tox_thread_msg, audio_thread_msg, video_thread_msg; extern bool tox_connected; void tox_after_load(Tox *tox); /* toxcore thread */ void *toxcore_thread(void *args); /* send a message to the toxcore thread */ void postmessage_toxcore(uint8_t msg, uint32_t param1, uint32_t param2, void *data); void tox_settingschanged(void); /* convert tox id to string * notes: dest must be (TOX_FRIEND_ADDRESS_SIZE * 2) bytes large, src must be TOX_FRIEND_ADDRESS_SIZE bytes large */ void id_to_string(char *dest, uint8_t *src); #endif uTox/src/tox.c0000600000175000001440000011715314003056216012253 0ustar rakusers#include "tox.h" #include "avatar.h" #include "file_transfers.h" #include "flist.h" #include "friend.h" #include "groups.h" #include "debug.h" #include "macros.h" #include "self.h" #include "settings.h" #include "text.h" #include "tox_bootstrap.h" #include "tox_callbacks.h" #include "utox.h" #include "av/audio.h" #include "av/utox_av.h" #include "av/video.h" #include "ui/edit.h" // FIXME the toxcore thread shouldn't be interacting directly with the UI #include "ui/switch.h" // FIXME the toxcore thread shouldn't be interacting directly with the UI #include "ui/dropdown.h" #include "layout/background.h" #include "layout/settings.h" #include "native/thread.h" #include "native/time.h" #include #include #include #include #include #include "main.h" // utox_data_save/load, DEFAULT_NAME, DEFAULT_STATUS UTOX_TOX_THREAD_INIT tox_thread_init; TOX_MSG tox_msg, audio_msg, toxav_msg; volatile bool tox_thread_msg, audio_thread_msg, video_thread_msg; bool tox_connected; static bool save_needed = true; enum { LOG_FILE_MSG_TYPE_TEXT = 0, LOG_FILE_MSG_TYPE_ACTION = 1, }; typedef struct { uint64_t time; uint16_t namelen, length; uint8_t flags; uint8_t msg_type; uint8_t zeroes[2]; } LOG_FILE_MSG_HEADER_COMPAT; static void tox_thread_message(Tox *tox, ToxAV *av, uint64_t time, uint8_t msg, uint32_t param1, uint32_t param2, void *data); void postmessage_toxcore(uint8_t msg, uint32_t param1, uint32_t param2, void *data) { while (tox_thread_msg) { yieldcpu(1); } if (!tox_thread_init) { /* Tox is not yet active, drop message (Probably a mistake) */ return; } tox_msg.msg = msg; tox_msg.param1 = param1; tox_msg.param2 = param2; tox_msg.data = data; tox_thread_msg = 1; } static int utox_encrypt_data(void *clear_text, size_t clear_length, uint8_t *cypher_data) { size_t passphrase_length = edit_profile_password.length; if (passphrase_length < 4) { return UTOX_ENC_ERR_LENGTH; } uint8_t passphrase[passphrase_length]; memcpy(passphrase, edit_profile_password.data, passphrase_length); TOX_ERR_ENCRYPTION err = 0; tox_pass_encrypt((uint8_t *)clear_text, clear_length, (uint8_t *)passphrase, passphrase_length, cypher_data, &err); if (err) { LOG_FATAL_ERR(EXIT_FAILURE, "Toxcore", "Fatal Error; unable to encrypt data!\n"); } return err; } static int utox_decrypt_data(void *cypher_data, size_t cypher_length, uint8_t *clear_text) { size_t passphrase_length = edit_profile_password.length; if (passphrase_length < 4) { return UTOX_ENC_ERR_LENGTH; } uint8_t passphrase[passphrase_length]; memcpy(passphrase, edit_profile_password.data, passphrase_length); TOX_ERR_DECRYPTION err = 0; tox_pass_decrypt((uint8_t *)cypher_data, cypher_length, (uint8_t *)passphrase, passphrase_length, clear_text, &err); switch (err) { case TOX_ERR_DECRYPTION_OK: return 0; case TOX_ERR_DECRYPTION_NULL: case TOX_ERR_DECRYPTION_INVALID_LENGTH: return UTOX_ENC_ERR_LENGTH; case TOX_ERR_DECRYPTION_BAD_FORMAT: return UTOX_ENC_ERR_BAD_DATA; case TOX_ERR_DECRYPTION_KEY_DERIVATION_FAILED: return UTOX_ENC_ERR_UNKNOWN; case TOX_ERR_DECRYPTION_FAILED: return UTOX_ENC_ERR_BAD_PASS; } return -1; } /* bootstrap to dht with bootstrap_nodes */ static void toxcore_bootstrap(Tox *tox, bool ipv6_enabled) { static unsigned int j = 0; if (j == 0) { j = rand(); } int i = 0; while (i < 4) { struct bootstrap_node *d = &bootstrap_nodes[j++ % COUNTOF(bootstrap_nodes)]; // do not add IPv6 bootstrap nodes if IPv6 is not enabled if (!ipv6_enabled && d->ipv6) { continue; } LOG_TRACE("Toxcore", "Bootstrapping with node %s udp: %d, tcp: %d", d->address, d->port_udp, d->port_tcp); tox_bootstrap(tox, d->address, d->port_udp, d->key, 0); tox_add_tcp_relay(tox, d->address, d->port_tcp, d->key, 0); i++; } } static void set_callbacks(Tox *tox) { utox_set_callbacks_friends(tox); utox_set_callbacks_groups(tox); #ifdef ENABLE_MULTIDEVICE utox_set_callbacks_mdevice(tox); #endif utox_set_callbacks_file_transfer(tox); } void tox_after_load(Tox *tox) { utox_friend_list_init(tox); init_groups(tox); #ifdef ENABLE_MULTIDEVICE // self.group_list_count = tox_self_get_(tox); self.device_list_count = tox_self_get_device_count(tox); // devices_update_list(); utox_devices_init(); devices_update_ui(); uint32_t i; for (i = 0; i < self.device_list_count; ++i) { utox_device_init(tox, i); } #endif self.name_length = tox_self_get_name_size(tox); tox_self_get_name(tox, (uint8_t *)self.name); self.statusmsg_length = tox_self_get_status_message_size(tox); tox_self_get_status_message(tox, (uint8_t *)self.statusmsg); self.status = tox_self_get_status(tox); } static void load_defaults(Tox *tox) { uint8_t *name = (uint8_t *)DEFAULT_NAME, *status = (uint8_t *)DEFAULT_STATUS; uint16_t name_len = sizeof(DEFAULT_NAME) - 1, status_len = sizeof(DEFAULT_STATUS) - 1; tox_self_set_name(tox, name, name_len, 0); tox_self_set_status_message(tox, status, status_len, 0); } static void write_save(Tox *tox) { /* Get toxsave info from tox*/ size_t clear_length = tox_get_savedata_size(tox); size_t encrypted_length = clear_length + TOX_PASS_ENCRYPTION_EXTRA_LENGTH; uint8_t *clear_data = calloc(1, clear_length); uint8_t *encrypted_data = calloc(1, encrypted_length); if (!clear_data || !encrypted_data) { LOG_FATAL_ERR(EXIT_FAILURE, "Toxcore", "Could not allocate memory for savedata.\n"); } tox_get_savedata(tox, clear_data); if (edit_profile_password.length == 0) { // user doesn't use encryption save_needed = utox_data_save_tox(clear_data, clear_length); LOG_TRACE("Toxcore", "Unencrypted save data written" ); } else { UTOX_ENC_ERR enc_err = utox_encrypt_data(clear_data, clear_length, encrypted_data); if (enc_err) { /* encryption failed, write clear text data */ save_needed = utox_data_save_tox(clear_data, clear_length); LOG_TRACE("Toxcore", "\n\n\t\tWARNING UTOX WAS UNABLE TO ENCRYPT DATA!\n\t\tDATA WRITTEN IN CLEAR TEXT!\n" ); } else { save_needed = utox_data_save_tox(encrypted_data, encrypted_length); LOG_TRACE("Toxcore", "Encrypted save data written" ); } } free(encrypted_data); free(clear_data); } void tox_settingschanged(void) { // free everything tox_connected = 0; #ifdef ENABLE_MULTIDEVICE utox_devices_decon(); #endif flist_freeall(); dropdown_list_clear(&dropdown_audio_in); dropdown_list_clear(&dropdown_audio_out); dropdown_list_clear(&dropdown_video); LOG_NOTE("Toxcore", "Restarting Toxcore"); postmessage_toxcore(TOX_KILL, 1, 0, NULL); // send the reconfig message! while (!tox_thread_init) { yieldcpu(1); } } /* 6 seconds */ #define UTOX_TYPING_NOTIFICATION_TIMEOUT (6ul * 1000 * 1000 * 1000) static struct { Tox * tox; uint16_t friendnumber; uint64_t time; bool sent_value; bool sent; } typing_state = { .tox = NULL, .friendnumber = 0, .time = 0, .sent_value = 0, }; static void utox_thread_work_for_typing_notifications(Tox *tox, uint64_t time) { if (typing_state.tox != tox) { // Guard against Tox engine restarts. return; } bool is_typing = (time < typing_state.time + UTOX_TYPING_NOTIFICATION_TIMEOUT); if (typing_state.sent_value ^ is_typing) { // Need to send an update. if (tox_self_set_typing(tox, typing_state.friendnumber, is_typing, 0)) { // Successfully sent. Mark new state. typing_state.sent_value = is_typing; LOG_TRACE("Toxcore", "Sent typing state to friend (%d): %d" , typing_state.friendnumber, typing_state.sent_value); } } } static int load_toxcore_save(struct Tox_Options *options) { settings.save_encryption = 0; size_t raw_length; uint8_t *raw_data = utox_data_load_tox(&raw_length); /* Check if we're loading a saved profile */ if (!raw_data || !raw_length) { // No save file at all, create new profile! return -2; } if (!tox_is_data_encrypted(raw_data)) { LOG_INFO("Toxcore", "Using unencrypted save file"); options->savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE; options->savedata_data = raw_data; options->savedata_length = raw_length; return 0; } size_t cleartext_length = raw_length - TOX_PASS_ENCRYPTION_EXTRA_LENGTH; uint8_t *clear_data = calloc(1, cleartext_length); settings.save_encryption = 1; LOG_INFO("Toxcore", "Using encrypted data, trying password: "); UTOX_ENC_ERR decrypt_err = utox_decrypt_data(raw_data, raw_length, clear_data); if (decrypt_err) { if (decrypt_err == UTOX_ENC_ERR_LENGTH) { LOG_WARN("Toxcore", "Password too short!\r"); } else if (decrypt_err == UTOX_ENC_ERR_BAD_PASS) { LOG_ERR("Toxcore", "Couldn't decrypt, wrong password?\r"); } else { LOG_ERR("Toxcore", "Unknown error, please file a bug report!" ); } return -1; } if (!clear_data || !cleartext_length) { return -1; } options->savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE; options->savedata_data = clear_data; options->savedata_length = cleartext_length; return 0; } static void log_callback(Tox *UNUSED(tox), TOX_LOG_LEVEL level, const char *file, uint32_t line, const char *func, const char *message, void *UNUSED(user_data)) { if (message && file && line) { LOG_NET_TRACE("Toxcore", "TOXCORE LOGGING ERROR (%u): %s" , level, message); LOG_NET_TRACE("Toxcore", " in: %s:%u" , file, line); } else if (func) { LOG_NET_TRACE("Toxcore", "TOXCORE LOGGING ERROR: %s" , func); } else { LOG_ERR("Toxcore logging", "TOXCORE LOGGING is broken!!:\tOpen an bug upstream"); } } // initialize toxcore based on current settings // returns 0 on success // returns -1 on temporary error (waiting for password encryption) // returns -2 on fatal error static int init_toxcore(Tox **tox) { tox_thread_init = UTOX_TOX_THREAD_INIT_NONE; int save_status = 0; struct Tox_Options topt; tox_options_default(&topt); // tox_options_set_start_port(&topt, 0); // tox_options_set_end_port(&topt, 0); tox_options_set_log_callback(&topt, log_callback); tox_options_set_ipv6_enabled(&topt, settings.enableipv6); tox_options_set_udp_enabled(&topt, !settings.disableudp); tox_options_set_proxy_type(&topt, TOX_PROXY_TYPE_NONE); tox_options_set_proxy_host(&topt, (char *)settings.proxy_ip); tox_options_set_proxy_port(&topt, settings.proxy_port); #ifdef ENABLE_MULTIDEVICE tox_options_set_mdev_mirror_sent(&topt, 1); #endif save_status = load_toxcore_save(&topt); // TODO tox.c shouldn't be interacting with the UI on this level if (save_status == -1) { /* Save file exist, couldn't decrypt, don't start a tox instance TODO: throw an error to the UI! */ panel_profile_password.disabled = false; panel_settings_master.disabled = true; edit_setfocus(&edit_profile_password); postmessage_utox(REDRAW, 0, 0, NULL); return -1; } else if (save_status == -2) { /* New profile! */ panel_profile_password.disabled = true; panel_settings_master.disabled = false; } else { panel_profile_password.disabled = true; if (settings.show_splash) { panel_splash_page.disabled = false; } else { panel_settings_master.disabled = false; } edit_resetfocus(); } postmessage_utox(REDRAW, 0, 0, NULL); if (settings.proxyenable) { topt.proxy_type = TOX_PROXY_TYPE_SOCKS5; } // Create main connection LOG_INFO("Toxcore", "Creating New Toxcore instance.\n" "\t\tIPv6 : %u\n" "\t\tUDP : %u\n" "\t\tProxy: %u %s %u", topt.ipv6_enabled, topt.udp_enabled, topt.proxy_type, topt.proxy_host, topt.proxy_port); TOX_ERR_NEW tox_new_err = 0; *tox = tox_new(&topt, &tox_new_err); if (*tox == NULL) { if (settings.force_proxy) { LOG_ERR("Toxcore", "\t\tError #%u, Not going to try without proxy because of user settings.", tox_new_err); return -2; } LOG_ERR("Toxcore", "\t\tError #%u, Going to try without proxy.", tox_new_err); // reset proxy options as well as GUI and settings topt.proxy_type = TOX_PROXY_TYPE_NONE; settings.proxyenable = settings.force_proxy = 0; switch_proxy.switch_on = 0; *tox = tox_new(&topt, &tox_new_err); if (*tox == NULL) { LOG_ERR("Toxcore", "\t\tError #%u, Going to try without IPv6.", tox_new_err); // reset IPv6 options as well as GUI and settings topt.ipv6_enabled = 0; switch_ipv6.switch_on = settings.enableipv6 = 0; *tox = tox_new(&topt, &tox_new_err); if (*tox == NULL) { LOG_ERR("Toxcore", "\t\tFatal Error creating a Tox instance... Error #%u", tox_new_err); return -2; } } } free((void *)topt.savedata_data); /* Give toxcore the functions to call */ set_callbacks(*tox); /* Connect to bootstrapped nodes in "tox_bootstrap.h" */ toxcore_bootstrap(*tox, settings.enableipv6); if (save_status == -2) { LOG_NOTE("Toxcore", "No save file, using defaults" ); load_defaults(*tox); } tox_after_load(*tox); return 0; } /** void toxcore_thread(void) * * Main tox function, starts a new toxcore for utox to use, and then spawns its * threads. * * Accepts and returns nothing. */ void *toxcore_thread(void *UNUSED(args)) { ToxAV *av = NULL; bool reconfig = 1; int toxcore_init_err = 0; while (reconfig) { reconfig = 0; Tox *tox = NULL; toxcore_init_err = init_toxcore(&tox); if (toxcore_init_err == -2) { // fatal failure, unable to create tox instance LOG_ERR("Toxcore", "Unable to create Tox Instance (%d)" , toxcore_init_err); // set init to true because other code is waiting for it. // but indicate error state tox_thread_init = UTOX_TOX_THREAD_INIT_ERROR; while (!reconfig) { // Waiting for a message triggering the next reconfigure // avoid trying the creation of thousands of tox instances before user changes the settings if (tox_thread_msg) { TOX_MSG *msg = &tox_msg; if (msg->msg == TOX_KILL) { reconfig = (bool) msg->param1; tox_thread_init = UTOX_TOX_THREAD_INIT_NONE; } // tox is not configured at this point ignore all other messages tox_thread_msg = 0; } else { yieldcpu(300); } } continue; } else if (toxcore_init_err) { /* Couldn't init toxcore, probably waiting for user password */ yieldcpu(300); tox_thread_init = UTOX_TOX_THREAD_INIT_NONE; // ignore all messages in this stage tox_thread_msg = 0; reconfig = 1; continue; } else { init_self(tox); TOXAV_ERR_NEW toxav_error; av = toxav_new(tox, &toxav_error); if (!av) { LOG_ERR("Toxcore", "Unable to get ToxAV (%u)" , toxav_error); } tox_thread_init = UTOX_TOX_THREAD_INIT_SUCCESS; /* init the friends list. */ flist_start(); postmessage_utox(UPDATE_TRAY, 0, 0, NULL); postmessage_utox(PROFILE_DID_LOAD, 0, 0, NULL); thread(utox_av_ctrl_thread, NULL); postmessage_utoxav(UTOXAV_NEW_TOX_INSTANCE, 0, 0, av); } bool connected = 0; uint64_t last_save = get_time(), last_connection = get_time(), time; while (1) { // Put toxcore to work tox_iterate(tox, NULL); // Check currents connection if (!!tox_self_get_connection_status(tox) != connected) { connected = !connected; postmessage_utox(DHT_CONNECTED, connected, 0, NULL); } /* Wait 10 Billion ticks then verify connection. */ time = get_time(); if (time - last_connection >= (uint64_t)10 * 1000 * 1000 * 1000) { last_connection = time; if (!connected) { toxcore_bootstrap(tox, settings.enableipv6); } // save every 1000. if (save_needed || (time - last_save >= (uint64_t)1000 * 1000 * 1000 * 1000)) { // Save tox data write_save(tox); last_save = time; } } // If there's a message, load it, and send to the tox message thread if (tox_thread_msg) { TOX_MSG *msg = &tox_msg; if (msg->msg == TOX_KILL) { reconfig = msg->param1; // reconfig if needed tox_thread_msg = 0; tox_thread_init = UTOX_TOX_THREAD_INIT_NONE; break; } tox_thread_message(tox, av, time, msg->msg, msg->param1, msg->param2, msg->data); tox_thread_msg = 0; typing_state.sent = (msg->msg == TOX_SEND_MESSAGE || msg->msg == TOX_SEND_ACTION); } if (!settings.no_typing_notifications) { // Thread active transfers and check if friend is typing utox_thread_work_for_typing_notifications(tox, time); } /* Ask toxcore how many ms to wait, then wait at the most 20ms */ uint32_t interval = tox_iteration_interval(tox); yieldcpu((interval > 20) ? 20 : interval); } /* If for anyreason, we exit, write the save, and clear the password */ write_save(tox); edit_setstr(&edit_profile_password, (char *)"", 0); postmessage_utoxav(UTOXAV_KILL, 0, 0, NULL); while (utox_av_ctrl_init) { yieldcpu(1); } LOG_TRACE("Toxcore", "tox thread ending"); tox_kill(tox); } tox_thread_init = UTOX_TOX_THREAD_INIT_NONE; free_friends(); raze_groups(); LOG_TRACE("Toxcore", "Tox thread:\tClean exit!"); return NULL; } /** General recommendations for working with threads in uTox * * There are two main threads, the tox worker thread, that interacts with Toxcore, and receives the callbacks. The other * is the 'uTox' thread that interacts with the user, (rather sends information to the GUI.) The tox thread and the uTox * thread may interact with each other, as you see fit. However the Toxcore thread has child threads that are a bit * temperamental. The ToxAV thread is a child of the Toxcore thread, and therefore will ideally only be called by the tox * thread. The ToxAV thread also has two children of its own, an audio and a video thread. Both a & v threads should * only be called by the ToxAV thread to avoid deadlocks. */ static void tox_thread_message(Tox *tox, ToxAV *av, uint64_t time, uint8_t msg, uint32_t param1, uint32_t param2, void *data) { switch (msg) { case TOX_SAVE: { save_needed = 1; break; } /* Change Self in core */ case TOX_SELF_SET_NAME: { /* param1: name length * data: name */ tox_self_set_name(tox, data, param1, 0); save_needed = 1; break; } case TOX_SELF_SET_STATUS: { /* param1: status length * data: status message */ tox_self_set_status_message(tox, data, param1, 0); save_needed = 1; break; } case TOX_SELF_SET_STATE: { /* param1: status */ tox_self_set_status(tox, param1); save_needed = 1; break; } case TOX_SELF_CHANGE_NOSPAM: { /* param1: new nospam value */ char *old_id = self.id_str; self.nospam = param1; sprintf(self.nospam_str, "%08X", self.nospam); tox_self_set_nospam(tox, self.nospam); /* update tox id */ tox_self_get_address(tox, self.id_binary); id_to_string(self.id_str, self.id_binary); LOG_TRACE("Toxcore", "Tox ID: %.*s" , (int)self.id_str_length, self.id_str); /* Update avatar */ avatar_move((uint8_t *)old_id, (uint8_t *)self.id_str); edit_setstr(&edit_nospam, self.nospam_str, sizeof(uint32_t) * 2); save_needed = true; break; } case TOX_SELF_NEW_DEVICE: { #ifdef ENABLE_MULTIDEVICE TOX_ERR_DEVICE_ADD error = 0; tox_self_add_device(tox, data + TOX_ADDRESS_SIZE, param1, data, &error); if (error) { LOG_ERR("Toxcore", "problem with adding device to self %u" , error); } else { self.device_list_count++; } #endif break; } /* Avatar status */ case TOX_AVATAR_SET: { /* param1: avatar format * param2: length of avatar data * data: raw avatar data (PNG) */ avatar_set_self(data, param2); save_needed = 1; break; } case TOX_AVATAR_UNSET: { avatar_unset_self(); save_needed = 1; break; } /* Interact with contacts */ case TOX_FRIEND_NEW: { /* param1: length of message * data: friend id + message */ uint32_t fid; TOX_ERR_FRIEND_ADD f_err; if (!param1) { STRING *default_add_msg = SPTR(DEFAULT_FRIEND_REQUEST_MESSAGE); fid = tox_friend_add(tox, data, (const uint8_t *)default_add_msg->str, default_add_msg->length, &f_err); } else { fid = tox_friend_add(tox, data, (uint8_t *)data + TOX_ADDRESS_SIZE, param1, &f_err); } if (f_err != TOX_ERR_FRIEND_ADD_OK) { uint8_t addf_error; switch (f_err) { case TOX_ERR_FRIEND_ADD_TOO_LONG: addf_error = ADDF_TOOLONG; break; case TOX_ERR_FRIEND_ADD_NO_MESSAGE: addf_error = ADDF_NOMESSAGE; break; case TOX_ERR_FRIEND_ADD_OWN_KEY: addf_error = ADDF_OWNKEY; break; case TOX_ERR_FRIEND_ADD_ALREADY_SENT: addf_error = ADDF_ALREADYSENT; break; case TOX_ERR_FRIEND_ADD_BAD_CHECKSUM: addf_error = ADDF_BADCHECKSUM; break; case TOX_ERR_FRIEND_ADD_SET_NEW_NOSPAM: addf_error = ADDF_SETNEWNOSPAM; break; case TOX_ERR_FRIEND_ADD_MALLOC: addf_error = ADDF_NOMEM; break; default: addf_error = ADDF_UNKNOWN; break; } postmessage_utox(FRIEND_SEND_REQUEST, 1, addf_error, data); } else { utox_friend_init(tox, fid); postmessage_utox(FRIEND_SEND_REQUEST, 0, fid, data); } save_needed = 1; break; } case TOX_FRIEND_NEW_DEVICE: { #ifdef ENABLE_MULTIDEVICE LOG_INFO("Toxcore", "Adding new device to peer %u" , param1); tox_friend_add_device(tox, data, param1, 0); free(data); save_needed = 1; #endif break; } case TOX_FRIEND_NEW_NO_REQ: { /* data: friend's public key */ TOX_ERR_FRIEND_ADD f_err; uint32_t fid = tox_friend_add_norequest(tox, data, &f_err); if (!f_err) { utox_friend_init(tox, fid); postmessage_utox(FRIEND_ADD_NO_REQ, 0, fid, data); } else { char hex_id[TOX_ADDRESS_SIZE * 2]; id_to_string(hex_id, data); LOG_TRACE("Toxcore", "Unable to accept friend %s, error num = %i" , hex_id, fid); free(data); } save_needed = 1; break; } case TOX_FRIEND_ACCEPT: { /* data: FREQUEST */ FREQUEST *req = data; TOX_ERR_FRIEND_ADD f_err; uint32_t fid = tox_friend_add_norequest(tox, req->bin_id, &f_err); if (!f_err) { utox_friend_init(tox, fid); postmessage_utox(FRIEND_ACCEPT_REQUEST, fid, 0, req); } else { char hex_id[TOX_ADDRESS_SIZE * 2]; id_to_string(hex_id, req->bin_id); LOG_TRACE("Toxcore", "Unable to accept friend %s, error num = %i" , hex_id, fid); } save_needed = 1; break; } case TOX_FRIEND_DELETE: { /* param1: friend # */ tox_friend_delete(tox, param1, 0); postmessage_utox(FRIEND_REMOVE, 0, 0, data); save_needed = 1; break; } case TOX_FRIEND_ONLINE: { /* Moved to the call back... */ break; } /* Default actions */ case TOX_SEND_MESSAGE: case TOX_SEND_ACTION: { /* param1: friend # * param2: message length * data: message */ MSG_HEADER *mmsg = (MSG_HEADER *)data; TOX_MESSAGE_TYPE type; if (msg == TOX_SEND_ACTION) { type = TOX_MESSAGE_TYPE_ACTION; } else { type = TOX_MESSAGE_TYPE_NORMAL; } uint8_t *next = (uint8_t *)mmsg->via.txt.msg; while (param2 > TOX_MAX_MESSAGE_LENGTH) { uint16_t len = TOX_MAX_MESSAGE_LENGTH - utf8_unlen((char *)next + TOX_MAX_MESSAGE_LENGTH); tox_friend_send_message(tox, param1, type, next, len, 0); param2 -= len; next += len; } TOX_ERR_FRIEND_SEND_MESSAGE error = 0; // Send last or only message mmsg->receipt = tox_friend_send_message(tox, param1, type, next, param2, &error); mmsg->receipt_time = 0; LOG_INFO("Toxcore", "Sending message, receipt %u" , mmsg->receipt); if (error) { LOG_ERR("Toxcore", "Error sending message... %u" , error); } break; } case TOX_SEND_TYPING: { /* param1: friend # */ // Check if user has switched to another friend window chat. // Take care not to react on obsolete data from old Tox instance. bool need_resetting = (typing_state.tox == tox) && (typing_state.friendnumber != param1) && (typing_state.sent_value); if (need_resetting) { // Tell previous friend that he's betrayed. tox_self_set_typing(tox, typing_state.friendnumber, 0, 0); // Mark that new friend doesn't know that we're typing yet. typing_state.sent_value = 0; } // Mark us as typing to this friend at the moment. // utox_thread_work_for_typing_notifications() will // send a notification if it deems necessary. typing_state.tox = tox; typing_state.friendnumber = param1; // UINT64_MAX will set the is_typing in utox_thread_work_for_typing_notifications to 0 // and send typing state 0 to friend when message is sent typing_state.time = (typing_state.sent) ? UINT64_MAX : time; // LOG_TRACE("Toxcore", "Set typing state for friend (%d): %d" , typing_state.friendnumber, typing_state.sent_value); break; } /* File transfers are so in right now. */ case TOX_FILE_SEND_NEW: case TOX_FILE_SEND_NEW_SLASH: { /* param1: friend # * param2: offset of first file name in data * data: file names */ if (param2 == 0) { // This is the new default. Where the caller sends an opened file. UTOX_MSG_FT *msg = data; ft_send_file(tox, param1, msg->file, msg->name, strlen((char*)msg->name), NULL); free(msg->name); free(msg); break; } break; } case TOX_FILE_SEND_NEW_INLINE: { /* param1: friend id data: pointer to a TOX_SEND_INLINE_MSG struct */ LOG_INFO("Toxcore", "Sending picture inline." ); struct TOX_SEND_INLINE_MSG *img = data; uint8_t name[] = "utox-inline.png"; ft_send_data(tox, param1, img->image, img->image_size, name, strlen((char *)name)); free(data); break; } case TOX_FILE_ACCEPT: case TOX_FILE_ACCEPT_AUTO: { /* param1: friend # * param2: file # * data: path to write file */ if (utox_file_start_write(param1, param2, (const char *)data)) { /* tox, friend#, file#, START_FILE */ ft_local_control(tox, param1, param2, TOX_FILE_CONTROL_RESUME); } else { ft_local_control(tox, param1, param2, TOX_FILE_CONTROL_CANCEL); } free(data); break; } case TOX_FILE_RESUME: { if (data) { param2 = ((FILE_TRANSFER*)data)->file_number; } ft_local_control(tox, param1, param2, TOX_FILE_CONTROL_RESUME); break; } case TOX_FILE_PAUSE: { if (data) { param2 = ((FILE_TRANSFER*)data)->file_number; } ft_local_control(tox, param1, param2, TOX_FILE_CONTROL_PAUSE); break; } case TOX_FILE_CANCEL: { if (data) { param2 = ((FILE_TRANSFER*)data)->file_number; } ft_local_control(tox, param1, param2, TOX_FILE_CONTROL_CANCEL); break; } /* Audio & Video */ case TOX_CALL_SEND: { /* param1: friend # */ /* Set the video bitrate, if we're starting a video call. */ int v_bitrate = 0; if (param2) { v_bitrate = UTOX_DEFAULT_BITRATE_V; LOG_TRACE("Toxcore", "Sending video call to friend %u" , param1); } else { v_bitrate = 0; LOG_TRACE("Toxcore", "Sending call to friend %u" , param1); } postmessage_utoxav(UTOXAV_OUTGOING_CALL_PENDING, param1, param2, NULL); TOXAV_ERR_CALL error = 0; toxav_call(av, param1, UTOX_DEFAULT_BITRATE_A, v_bitrate, &error); if (error) { switch (error) { case TOXAV_ERR_CALL_MALLOC: { LOG_TRACE("Toxcore", "Error making call to friend %u; Unable to malloc for this call." , param1); break; } case TOXAV_ERR_CALL_FRIEND_ALREADY_IN_CALL: { /* This shouldn't happen, but just in case toxav gets a call before uTox gets this message we * can just pretend like we're answering a call... */ LOG_TRACE("Toxcore", "Error making call to friend %u; Already in call." , param1); LOG_TRACE("Toxcore", "Forwarding and accepting call!" ); TOXAV_ERR_ANSWER ans_error = 0; toxav_answer(av, param1, UTOX_DEFAULT_BITRATE_A, v_bitrate, &ans_error); if (ans_error) { LOG_TRACE("Toxcore", "Error trying to toxav_answer error (%i)" , ans_error); } else { postmessage_utoxav(UTOXAV_OUTGOING_CALL_ACCEPTED, param1, param2, NULL); } postmessage_utox(AV_CALL_ACCEPTED, param1, 0, NULL); break; } default: { /* Un-handled errors TOXAV_ERR_CALL_SYNC, TOXAV_ERR_CALL_FRIEND_NOT_FOUND, TOXAV_ERR_CALL_FRIEND_NOT_CONNECTED, TOXAV_ERR_CALL_FRIEND_ALREADY_IN_CALL, TOXAV_ERR_CALL_INVALID_BIT_RATE,*/ LOG_TRACE("Toxcore", "Error making call to %u, error num is %i." , param1, error); break; } } } else { postmessage_utox(AV_CALL_RINGING, param1, param2, NULL); } break; } case TOX_CALL_INCOMING: { /* This is a call back, todo remove */ break; } case TOX_CALL_ANSWER: { /* param1: Friend_number # * param2: Accept Video? # */ TOXAV_ERR_ANSWER error = 0; int v_bitrate = 0; if (param2) { v_bitrate = UTOX_DEFAULT_BITRATE_V; LOG_TRACE("Toxcore", "Answering video call." ); } else { v_bitrate = 0; LOG_TRACE("Toxcore", "Answering audio call." ); } toxav_answer(av, param1, UTOX_DEFAULT_BITRATE_A, v_bitrate, &error); if (error) { LOG_TRACE("Toxcore", "Error trying to toxav_answer error (%i)" , error); } else { postmessage_utoxav(UTOXAV_INCOMING_CALL_ANSWER, param1, param2, NULL); } postmessage_utox(AV_CALL_ACCEPTED, param1, 0, NULL); break; } case TOX_CALL_PAUSE_AUDIO: { /* param1: friend # */ LOG_TRACE("Toxcore", "TODO bug, please report 001!!" ); break; } case TOX_CALL_PAUSE_VIDEO: { /* param1: friend # */ LOG_TRACE("Toxcore", "Ending video for active call!" ); utox_av_local_call_control(av, param1, TOXAV_CALL_CONTROL_HIDE_VIDEO); break; } case TOX_CALL_RESUME_AUDIO: { /* param1: friend # */ LOG_TRACE("Toxcore", "TODO bug, please report 002!!" ); break; } case TOX_CALL_RESUME_VIDEO: { /* param1: friend # */ LOG_TRACE("Toxcore", "Starting video for active call!" ); utox_av_local_call_control(av, param1, TOXAV_CALL_CONTROL_SHOW_VIDEO); get_friend(param1)->call_state_self |= TOXAV_FRIEND_CALL_STATE_SENDING_V | TOXAV_FRIEND_CALL_STATE_ACCEPTING_V; break; } case TOX_CALL_DISCONNECT: { /* param1: friend_number */ utox_av_local_disconnect(av, param1); break; } /* Groups are broken while we await the new GCs getting merged. */ /* TOX_GROUP_JOIN, TOX_GROUP_PART, // 30 TOX_GROUP_INVITE, TOX_GROUP_SET_TOPIC, TOX_GROUP_SEND_MESSAGE, TOX_GROUP_SEND_ACTION, TOX_GROUP_AUDIO_START, // 35 TOX_GROUP_AUDIO_END,*/ case TOX_GROUP_CREATE: { int g_num = -1; TOX_ERR_CONFERENCE_NEW error = 0; if (param2) { // TODO FIX THIS AFTER NEW GROUP API g_num = toxav_add_av_groupchat(tox, callback_av_group_audio, NULL); } else { g_num = tox_conference_new(tox, &error); } if (g_num == -1) { LOG_ERR("Tox", "Failed to create groupchat."); break; } GROUPCHAT *g = get_group(g_num); if (!g) { g = group_create(g_num, param2, NULL); if (!g) { LOG_ERR("Tox", "Failed creating group (number: %u type: %u)", g_num, param2); break; } } else { group_init(g, g_num, param2, NULL); } postmessage_utox(GROUP_ADD, g_num, param2, NULL); uint8_t pkey[TOX_PUBLIC_KEY_SIZE]; tox_conference_peer_get_public_key(tox, g_num, 0, pkey, NULL); uint64_t pkey_to_number = 0; for (int key_i = 0; key_i < TOX_PUBLIC_KEY_SIZE; ++key_i) { pkey_to_number += pkey[key_i]; } srand(pkey_to_number); uint32_t name_color = RGB(rand(), rand(), rand()); group_peer_add(g, 0, 1, name_color); group_peer_name_change(g, 0, (uint8_t *)self.name, self.name_length); postmessage_utox(GROUP_PEER_ADD, g_num, 0, NULL); save_needed = true; break; } case TOX_GROUP_JOIN: { break; } case TOX_GROUP_PART: { /* param1: group # */ postmessage_utoxav(UTOXAV_GROUPCALL_END, param1, param1, NULL); TOX_ERR_CONFERENCE_DELETE error = 0; tox_conference_delete(tox, param1, &error); save_needed = true; break; } case TOX_GROUP_SEND_INVITE: { /* param1: group # * param2: friend # */ TOX_ERR_CONFERENCE_INVITE error = 0; tox_conference_invite(tox, param2, param1, &error); save_needed = true; break; } case TOX_GROUP_SET_TOPIC: { /* param1: group # * param2: topic length * data: topic */ TOX_ERR_CONFERENCE_TITLE error = 0; tox_conference_set_title(tox, param1, data, param2, &error); postmessage_utox(GROUP_TOPIC, param1, param2, data); save_needed = true; break; } case TOX_GROUP_SEND_MESSAGE: case TOX_GROUP_SEND_ACTION: { /* param1: group # * param2: message length * data: message */ TOX_MESSAGE_TYPE type; type = (msg == TOX_GROUP_SEND_ACTION ? TOX_MESSAGE_TYPE_ACTION : TOX_MESSAGE_TYPE_NORMAL); TOX_ERR_CONFERENCE_SEND_MESSAGE error = 0; tox_conference_send_message(tox, param1, type, data, param2, &error); free(data); if (error) { LOG_ERR("Toxcore", "Error sending groupchat message... %u" , error); } break; } case TOX_GROUP_AUDIO_START: { // We have to take the long way around, because the UI shouldn't depend on AV LOG_INFO("Toxcore", "Staring call in groupchat %u", param1); postmessage_utox(GROUP_AUDIO_START, param1, 0, NULL); break; } case TOX_GROUP_AUDIO_END: { // We have to take the long way around, because the UI shouldn't depend on AV LOG_INFO("Toxcore", "Ending call in groupchat %u", param1); postmessage_utox(GROUP_AUDIO_END, param1, 0, NULL); break; } } // End of switch. } void id_to_string(char *dest, uint8_t *src) { to_hex(dest, src, TOX_ADDRESS_SIZE); } uTox/src/theme_tables.h0000600000175000001440000000023414003056216014071 0ustar rakusers#ifndef THEME_TABLES_H #define THEME_TABLES_H #include "theme.h" extern const char *COLOUR_NAME_TABLE[]; extern uint32_t *COLOUR_POINTER_TABLE[]; #endif uTox/src/theme_tables.c0000600000175000001440000001707314003056216014075 0ustar rakusers#include "theme_tables.h" #include /* NULL */ const char *COLOUR_NAME_TABLE[] = { "MAIN_BACKGROUND", "ALT_BACKGROUND", "MAIN_TEXT", "MAIN_CHATTEXT", "MAIN_SUBTEXT", "MAIN_ACTIONTEXT", "MAIN_QUOTETEXT", "MAIN_REDTEXT", "MAIN_URLTEXT", "MAIN_HINTTEXT", "MENU_BACKGROUND", "MENU_TEXT", "MENU_SUBTEXT", "MENU_BKGRND_HOVER", "MENU_ACTIVE_BACKGROUND", "MENU_ACTIVE_TEXT", "MSG_USER", "MSG_USER_PEND", "MSG_USER_ERROR", "MSG_CONTACT", "LIST_BACKGROUND", "LIST_BKGRND_HOVER", "LIST_TEXT", "LIST_SUBTEXT", "GROUP_SELF", "GROUP_PEER", "GROUP_AUDIO", "GROUP_MUTED", "SELECTION_BACKGROUND", "SELECTION_TEXT", "EDGE_NORMAL", "EDGE_HOVER", "EDGE_ACTIVE", "ACTIVEOPTION_BACKGROUND", "ACTIVEOPTION_TEXT", "AUX_BACKGROUND", "AUX_EDGE_NORMAL", "AUX_EDGE_HOVER", "AUX_EDGE_ACTIVE", "AUX_TEXT", "AUX_ACTIVEOPTION_BACKGROUND", "AUX_ACTIVEOPTION_TEXT", "STATUS_ONLINE", "STATUS_AWAY", "STATUS_BUSY", "BUTTON_SUCCESS_BACKGROUND", "BUTTON_SUCCESS_TEXT", "BUTTON_SUCCESS_BKGRND_HOVER", "BUTTON_SUCCESS_TEXT_HOVER", "BUTTON_WARNING_BACKGROUND", "BUTTON_WARNING_TEXT", "BUTTON_WARNING_BKGRND_HOVER", "BUTTON_WARNING_TEXT_HOVER", "BUTTON_DANGER_BACKGROUND", "BUTTON_DANGER_TEXT", "BUTTON_DANGER_BKGRND_HOVER", "BUTTON_DANGER_TEXT_HOVER", "BUTTON_DISABLED_BACKGROUND", "TRANSFER_PROGRESS_OVERLAY_PAUSED", "BUTTON_DISABLED_TEXT", "BUTTON_DISABLED_TRANSFER", "BUTTON_INPROGRESS_BACKGROUND", "TRANSFER_PROGRESS_OVERLAY_ACTIVE", "BUTTON_INPROGRESS_TEXT", NULL }; uint32_t *COLOUR_POINTER_TABLE[] = { &COLOR_BKGRND_MAIN, &COLOR_BKGRND_ALT, &COLOR_MAIN_TEXT, &COLOR_MAIN_TEXT_CHAT, &COLOR_MAIN_TEXT_SUBTEXT, &COLOR_MAIN_TEXT_ACTION, &COLOR_MAIN_TEXT_QUOTE, &COLOR_MAIN_TEXT_RED, &COLOR_MAIN_TEXT_URL, &COLOR_MAIN_TEXT_HINT, &COLOR_BKGRND_MENU, &COLOR_MENU_TEXT, &COLOR_MENU_TEXT_SUBTEXT, &COLOR_BKGRND_MENU_HOVER, &COLOR_BKGRND_MENU_ACTIVE, &COLOR_MENU_TEXT_ACTIVE, &COLOR_MSG_USER, &COLOR_MSG_USER_PEND, &COLOR_MSG_USER_ERROR, &COLOR_MSG_CONTACT, &COLOR_BKGRND_LIST, &COLOR_BKGRND_LIST_HOVER, &COLOR_LIST_TEXT, &COLOR_LIST_TEXT_SUBTEXT, &COLOR_GROUP_SELF, &COLOR_GROUP_PEER, &COLOR_GROUP_AUDIO, &COLOR_GROUP_MUTED, &COLOR_SELECTION_BACKGROUND, &COLOR_SELECTION_TEXT, &COLOR_EDGE_NORMAL, &COLOR_EDGE_HOVER, &COLOR_EDGE_ACTIVE, &COLOR_ACTIVEOPTION_BKGRND, &COLOR_ACTIVEOPTION_TEXT, &COLOR_BKGRND_AUX, &COLOR_AUX_EDGE_NORMAL, &COLOR_AUX_EDGE_HOVER, &COLOR_AUX_EDGE_ACTIVE, &COLOR_AUX_TEXT, &COLOR_AUX_ACTIVEOPTION_BKGRND, &COLOR_AUX_ACTIVEOPTION_TEXT, &COLOR_STATUS_ONLINE, &COLOR_STATUS_AWAY, &COLOR_STATUS_BUSY, &COLOR_BTN_SUCCESS_BKGRND, &COLOR_BTN_SUCCESS_TEXT, &COLOR_BTN_SUCCESS_BKGRND_HOVER, &COLOR_BTN_SUCCESS_TEXT_HOVER, &COLOR_BTN_WARNING_BKGRND, &COLOR_BTN_WARNING_TEXT, &COLOR_BTN_WARNING_BKGRND_HOVER, &COLOR_BTN_WARNING_TEXT_HOVER, &COLOR_BTN_DANGER_BACKGROUND, &COLOR_BTN_DANGER_TEXT, &COLOR_BTN_DANGER_BKGRND_HOVER, &COLOR_BTN_DANGER_TEXT_HOVER, &COLOR_BTN_DISABLED_BKGRND, &COLOR_BTN_DISABLED_FORGRND, &COLOR_BTN_DISABLED_TEXT, &COLOR_BTN_DISABLED_TRANSFER, &COLOR_BTN_INPROGRESS_BKGRND, &COLOR_BTN_INPROGRESS_FORGRND, &COLOR_BTN_INPROGRESS_TEXT, NULL }; uTox/src/theme.h0000600000175000001440000000564614003056216012553 0ustar rakusers#ifndef THEME_H #define THEME_H #include typedef enum { THEME_DEFAULT, THEME_LIGHT, THEME_DARK, THEME_HIGHCONTRAST, THEME_CUSTOM, THEME_ZENBURN, THEME_SOLARIZED_LIGHT, THEME_SOLARIZED_DARK, // TODO: THEME_XRESOURCE } THEME; /* Colors for drawing the backgrounds */ extern uint32_t COLOR_BKGRND_MAIN; extern uint32_t COLOR_BKGRND_ALT; extern uint32_t COLOR_BKGRND_AUX; extern uint32_t COLOR_BKGRND_MENU; extern uint32_t COLOR_BKGRND_MENU_HOVER; extern uint32_t COLOR_BKGRND_MENU_ACTIVE; extern uint32_t COLOR_BKGRND_LIST; extern uint32_t COLOR_BKGRND_LIST_HOVER; extern uint32_t COLOR_MAIN_TEXT; extern uint32_t COLOR_MAIN_TEXT_CHAT; extern uint32_t COLOR_MAIN_TEXT_SUBTEXT; extern uint32_t COLOR_MAIN_TEXT_ACTION; extern uint32_t COLOR_MAIN_TEXT_QUOTE; extern uint32_t COLOR_MAIN_TEXT_RED; extern uint32_t COLOR_MAIN_TEXT_URL; extern uint32_t COLOR_MAIN_TEXT_HINT; extern uint32_t COLOR_MSG_USER; extern uint32_t COLOR_MSG_USER_PEND; extern uint32_t COLOR_MSG_USER_ERROR; extern uint32_t COLOR_MSG_CONTACT; extern uint32_t COLOR_MENU_TEXT; extern uint32_t COLOR_MENU_TEXT_SUBTEXT; extern uint32_t COLOR_MENU_TEXT_ACTIVE; extern uint32_t COLOR_LIST_TEXT; extern uint32_t COLOR_LIST_TEXT_SUBTEXT; extern uint32_t COLOR_AUX_EDGE_NORMAL; extern uint32_t COLOR_AUX_EDGE_HOVER; extern uint32_t COLOR_AUX_EDGE_ACTIVE; extern uint32_t COLOR_AUX_TEXT; extern uint32_t COLOR_AUX_ACTIVEOPTION_BKGRND; extern uint32_t COLOR_AUX_ACTIVEOPTION_TEXT; extern uint32_t COLOR_GROUP_SELF; extern uint32_t COLOR_GROUP_PEER; extern uint32_t COLOR_GROUP_AUDIO; extern uint32_t COLOR_GROUP_MUTED; extern uint32_t COLOR_SELECTION_BACKGROUND; extern uint32_t COLOR_SELECTION_TEXT; extern uint32_t COLOR_EDGE_NORMAL; extern uint32_t COLOR_EDGE_ACTIVE; extern uint32_t COLOR_EDGE_HOVER; extern uint32_t COLOR_ACTIVEOPTION_BKGRND; extern uint32_t COLOR_ACTIVEOPTION_TEXT; extern uint32_t COLOR_STATUS_ONLINE; extern uint32_t COLOR_STATUS_AWAY; extern uint32_t COLOR_STATUS_BUSY; extern uint32_t COLOR_BTN_SUCCESS_BKGRND; extern uint32_t COLOR_BTN_SUCCESS_TEXT; extern uint32_t COLOR_BTN_SUCCESS_BKGRND_HOVER; extern uint32_t COLOR_BTN_SUCCESS_TEXT_HOVER; extern uint32_t COLOR_BTN_WARNING_BKGRND; extern uint32_t COLOR_BTN_WARNING_TEXT; extern uint32_t COLOR_BTN_WARNING_BKGRND_HOVER; extern uint32_t COLOR_BTN_WARNING_TEXT_HOVER; extern uint32_t COLOR_BTN_DANGER_BACKGROUND; extern uint32_t COLOR_BTN_DANGER_TEXT; extern uint32_t COLOR_BTN_DANGER_BKGRND_HOVER; extern uint32_t COLOR_BTN_DANGER_TEXT_HOVER; extern uint32_t COLOR_BTN_DISABLED_BKGRND; extern uint32_t COLOR_BTN_DISABLED_TEXT; extern uint32_t COLOR_BTN_DISABLED_BKGRND_HOVER; extern uint32_t COLOR_BTN_DISABLED_TRANSFER; extern uint32_t COLOR_BTN_INPROGRESS_BKGRND; extern uint32_t COLOR_BTN_INPROGRESS_TEXT; extern uint32_t COLOR_BTN_DISABLED_FORGRND; extern uint32_t COLOR_BTN_INPROGRESS_FORGRND; void theme_load(const THEME loadtheme); extern uint32_t status_color[4]; #endif uTox/src/theme.c0000600000175000001440000007447314003056216012552 0ustar rakusers#include "theme.h" #include "debug.h" #include "filesys.h" #include "theme_tables.h" #include "ui.h" #include #include #define COLOR_PROC(a_ulColor) RGB((a_ulColor >> 16) & 0x0000FF, (a_ulColor >> 8) & 0x0000FF, a_ulColor & 0x0000FF) /* Solarized color scheme */ #define SOLAR_BASE03 0x002b36 #define SOLAR_BASE02 0x073642 #define SOLAR_BASE01 0x586e75 #define SOLAR_BASE00 0x657b83 #define SOLAR_BASE0 0x839496 #define SOLAR_BASE1 0x93a1a1 #define SOLAR_BASE2 0xeee8d5 #define SOLAR_BASE3 0xfdf6e3 #define SOLAR_YELLOW 0xb58900 #define SOLAR_ORANGE 0xcb4b16 #define SOLAR_RED 0xdc322f #define SOLAR_MAGENTA 0xd33682 #define SOLAR_VIOLET 0x6c71c4 #define SOLAR_BLUE 0x268bd2 #define SOLAR_CYAN 0x2aa198 #define SOLAR_GREEN 0x859900 uint32_t COLOR_BKGRND_MAIN; uint32_t COLOR_BKGRND_ALT; uint32_t COLOR_BKGRND_AUX; uint32_t COLOR_BKGRND_MENU; uint32_t COLOR_BKGRND_MENU_HOVER; uint32_t COLOR_BKGRND_MENU_ACTIVE; uint32_t COLOR_BKGRND_LIST; uint32_t COLOR_BKGRND_LIST_HOVER; uint32_t COLOR_MAIN_TEXT; uint32_t COLOR_MAIN_TEXT_CHAT; uint32_t COLOR_MAIN_TEXT_SUBTEXT; uint32_t COLOR_MAIN_TEXT_ACTION; uint32_t COLOR_MAIN_TEXT_QUOTE; uint32_t COLOR_MAIN_TEXT_RED; uint32_t COLOR_MAIN_TEXT_URL; uint32_t COLOR_MAIN_TEXT_HINT; uint32_t COLOR_MSG_USER; uint32_t COLOR_MSG_USER_PEND; uint32_t COLOR_MSG_USER_ERROR; uint32_t COLOR_MSG_CONTACT; uint32_t COLOR_MENU_TEXT; uint32_t COLOR_MENU_TEXT_SUBTEXT; uint32_t COLOR_MENU_TEXT_ACTIVE; uint32_t COLOR_LIST_TEXT; uint32_t COLOR_LIST_TEXT_SUBTEXT; uint32_t COLOR_AUX_EDGE_NORMAL; uint32_t COLOR_AUX_EDGE_HOVER; uint32_t COLOR_AUX_EDGE_ACTIVE; uint32_t COLOR_AUX_TEXT; uint32_t COLOR_AUX_ACTIVEOPTION_BKGRND; uint32_t COLOR_AUX_ACTIVEOPTION_TEXT; uint32_t COLOR_GROUP_SELF; uint32_t COLOR_GROUP_PEER; uint32_t COLOR_GROUP_AUDIO; uint32_t COLOR_GROUP_MUTED; uint32_t COLOR_SELECTION_BACKGROUND; uint32_t COLOR_SELECTION_TEXT; uint32_t COLOR_EDGE_NORMAL; uint32_t COLOR_EDGE_ACTIVE; uint32_t COLOR_EDGE_HOVER; uint32_t COLOR_ACTIVEOPTION_BKGRND; uint32_t COLOR_ACTIVEOPTION_TEXT; uint32_t COLOR_STATUS_ONLINE; uint32_t COLOR_STATUS_AWAY; uint32_t COLOR_STATUS_BUSY; uint32_t COLOR_BTN_SUCCESS_BKGRND; uint32_t COLOR_BTN_SUCCESS_TEXT; uint32_t COLOR_BTN_SUCCESS_BKGRND_HOVER; uint32_t COLOR_BTN_SUCCESS_TEXT_HOVER; uint32_t COLOR_BTN_WARNING_BKGRND; uint32_t COLOR_BTN_WARNING_TEXT; uint32_t COLOR_BTN_WARNING_BKGRND_HOVER; uint32_t COLOR_BTN_WARNING_TEXT_HOVER; uint32_t COLOR_BTN_DANGER_BACKGROUND; uint32_t COLOR_BTN_DANGER_TEXT; uint32_t COLOR_BTN_DANGER_BKGRND_HOVER; uint32_t COLOR_BTN_DANGER_TEXT_HOVER; uint32_t COLOR_BTN_DISABLED_BKGRND; uint32_t COLOR_BTN_DISABLED_TEXT; uint32_t COLOR_BTN_DISABLED_BKGRND_HOVER; uint32_t COLOR_BTN_DISABLED_TRANSFER; uint32_t COLOR_BTN_INPROGRESS_BKGRND; uint32_t COLOR_BTN_INPROGRESS_TEXT; uint32_t COLOR_BTN_DISABLED_FORGRND; uint32_t COLOR_BTN_INPROGRESS_FORGRND; uint32_t status_color[4]; /** * Loads a custom theme and sets out to the size of the data * * Returns a pointer to the theme data on success, the caller needs to free this * Returns NULL on failure */ static uint8_t *utox_data_load_custom_theme(size_t *out); static void read_custom_theme(const uint8_t *data, size_t length); static uint32_t try_parse_hex_colour(char *color, bool *error); void theme_load(const THEME loadtheme) { // Update the settings dropdown UI // ==== Default theme ==== // ---- Background Colors ---- COLOR_BKGRND_MAIN = COLOR_PROC(0xffffff); COLOR_BKGRND_ALT = COLOR_PROC(0xaaaaaa); COLOR_BKGRND_AUX = COLOR_PROC(0x313131); COLOR_BKGRND_LIST = COLOR_PROC(0x414141); COLOR_BKGRND_LIST_HOVER = COLOR_PROC(0x505050); COLOR_BKGRND_MENU = COLOR_PROC(0x1c1c1c); COLOR_BKGRND_MENU_HOVER = COLOR_PROC(0x282828); COLOR_BKGRND_MENU_ACTIVE = COLOR_PROC(0x414141); /* ---- Text Colors --- */ COLOR_MAIN_TEXT = COLOR_PROC(0x333333); COLOR_MAIN_TEXT_CHAT = COLOR_PROC(0x000000); COLOR_MAIN_TEXT_SUBTEXT = COLOR_PROC(0x414141); COLOR_MAIN_TEXT_ACTION = COLOR_PROC(0x4e4ec8); COLOR_MAIN_TEXT_QUOTE = COLOR_PROC(0x008000); COLOR_MAIN_TEXT_RED = COLOR_PROC(0xFF0000); COLOR_MAIN_TEXT_URL = COLOR_PROC(0x001fff); COLOR_MAIN_TEXT_HINT = COLOR_PROC(0x969696); /* Message window colors */ COLOR_MSG_USER = COLOR_MAIN_TEXT_SUBTEXT; COLOR_MSG_USER_PEND = COLOR_MAIN_TEXT_ACTION; COLOR_MSG_USER_ERROR = COLOR_MAIN_TEXT_RED; COLOR_MSG_CONTACT = COLOR_MAIN_TEXT; //---- Friend list header and bottom-left buttons ---- COLOR_MENU_TEXT = COLOR_BKGRND_MAIN; COLOR_MENU_TEXT_SUBTEXT = COLOR_PROC(0xd1d1d1); COLOR_MENU_TEXT_ACTIVE = COLOR_BKGRND_MAIN; //---- Friend list ---- COLOR_LIST_TEXT = COLOR_MENU_TEXT; COLOR_LIST_TEXT_SUBTEXT = COLOR_MENU_TEXT_SUBTEXT; //---- Groupchat user list and title ---- COLOR_GROUP_SELF = COLOR_PROC(0x6bc260); COLOR_GROUP_PEER = COLOR_MAIN_TEXT_HINT; COLOR_GROUP_AUDIO = COLOR_PROC(0xc84e4e); COLOR_GROUP_MUTED = COLOR_MAIN_TEXT_ACTION; //---- Text selection ---- COLOR_SELECTION_BACKGROUND = COLOR_MAIN_TEXT; COLOR_SELECTION_TEXT = COLOR_BKGRND_MAIN; //---- Inputs, dropdowns & tooltips ---- COLOR_EDGE_NORMAL = COLOR_PROC(0xc0c0c0); COLOR_EDGE_HOVER = COLOR_PROC(0x969696); COLOR_EDGE_ACTIVE = COLOR_PROC(0x4ea6ea); COLOR_ACTIVEOPTION_BKGRND = COLOR_PROC(0xd1d1d1); COLOR_ACTIVEOPTION_TEXT = COLOR_MAIN_TEXT; //---- Auxiliary style for inputs/dropdowns ("Search friends" bar) ---- COLOR_AUX_EDGE_NORMAL = COLOR_BKGRND_AUX; COLOR_AUX_EDGE_HOVER = COLOR_PROC(0x999999); COLOR_AUX_EDGE_ACTIVE = COLOR_PROC(0x1A73B7); COLOR_AUX_TEXT = COLOR_LIST_TEXT; COLOR_AUX_ACTIVEOPTION_BKGRND = COLOR_BKGRND_LIST_HOVER; COLOR_AUX_ACTIVEOPTION_TEXT = COLOR_AUX_TEXT; //---- Status circles ---- COLOR_STATUS_ONLINE = COLOR_PROC(0x6bc260); COLOR_STATUS_AWAY = COLOR_PROC(0xcebf45); COLOR_STATUS_BUSY = COLOR_PROC(0xc84e4e); //---- Buttons ---- COLOR_BTN_SUCCESS_BKGRND = COLOR_STATUS_ONLINE; COLOR_BTN_SUCCESS_BKGRND_HOVER = COLOR_PROC(0x76d56a); COLOR_BTN_SUCCESS_TEXT = COLOR_BKGRND_MAIN; COLOR_BTN_SUCCESS_TEXT_HOVER = COLOR_BKGRND_MAIN; COLOR_BTN_WARNING_BKGRND = COLOR_STATUS_AWAY; COLOR_BTN_WARNING_BKGRND_HOVER = COLOR_PROC(0xe3d24c); COLOR_BTN_WARNING_TEXT = COLOR_BKGRND_MAIN; COLOR_BTN_WARNING_TEXT_HOVER = COLOR_BKGRND_MAIN; COLOR_BTN_DANGER_BACKGROUND = COLOR_STATUS_BUSY; COLOR_BTN_DANGER_BKGRND_HOVER = COLOR_PROC(0xdc5656); COLOR_BTN_DANGER_TEXT = COLOR_BKGRND_MAIN; COLOR_BTN_DANGER_TEXT_HOVER = COLOR_BKGRND_MAIN; COLOR_BTN_DISABLED_BKGRND = COLOR_PROC(0xd1d1d1); COLOR_BTN_DISABLED_BKGRND_HOVER = COLOR_BKGRND_LIST_HOVER; COLOR_BTN_DISABLED_TEXT = COLOR_BKGRND_MAIN; COLOR_BTN_DISABLED_TRANSFER = COLOR_BKGRND_LIST; COLOR_BTN_DISABLED_FORGRND = COLOR_PROC(0xb3b3b3); COLOR_BTN_INPROGRESS_BKGRND = COLOR_PROC(0x4ea6ea); COLOR_BTN_INPROGRESS_TEXT = COLOR_BKGRND_MAIN; COLOR_BTN_INPROGRESS_FORGRND = COLOR_PROC(0x76baef); switch (loadtheme) { case THEME_DARK: { COLOR_BKGRND_MAIN = COLOR_PROC(0x333333); COLOR_BKGRND_ALT = COLOR_PROC(0x151515); COLOR_BKGRND_LIST = COLOR_PROC(0x222222); COLOR_BKGRND_LIST_HOVER = COLOR_PROC(0x151515); COLOR_BKGRND_MENU = COLOR_PROC(0x171717); COLOR_BKGRND_AUX = COLOR_BKGRND_MENU; COLOR_BKGRND_MENU_HOVER = COLOR_BKGRND_LIST_HOVER; COLOR_BKGRND_MENU_ACTIVE = COLOR_BKGRND_LIST; COLOR_MAIN_TEXT = COLOR_PROC(0xdfdfdf); COLOR_MAIN_TEXT_CHAT = COLOR_PROC(0xffffff); COLOR_MAIN_TEXT_SUBTEXT = COLOR_PROC(0xbbbbbb); COLOR_MAIN_TEXT_ACTION = COLOR_PROC(0x27a9bc); COLOR_MAIN_TEXT_URL = COLOR_MAIN_TEXT_ACTION; COLOR_MAIN_TEXT_QUOTE = COLOR_PROC(0x55b317); COLOR_MSG_USER = COLOR_MAIN_TEXT_SUBTEXT; COLOR_MSG_USER_PEND = COLOR_PROC(0x66ccff); COLOR_MSG_USER_ERROR = COLOR_MAIN_TEXT_RED; COLOR_MSG_CONTACT = COLOR_MAIN_TEXT; COLOR_MENU_TEXT_ACTIVE = COLOR_MAIN_TEXT; COLOR_GROUP_MUTED = COLOR_MAIN_TEXT_URL; COLOR_SELECTION_BACKGROUND = COLOR_MAIN_TEXT; COLOR_SELECTION_TEXT = COLOR_BKGRND_MAIN; COLOR_EDGE_NORMAL = COLOR_PROC(0x555555); COLOR_EDGE_ACTIVE = COLOR_PROC(0x228888); COLOR_EDGE_HOVER = COLOR_PROC(0x999999); COLOR_ACTIVEOPTION_BKGRND = COLOR_PROC(0x228888); COLOR_ACTIVEOPTION_TEXT = COLOR_MAIN_TEXT; COLOR_AUX_EDGE_NORMAL = COLOR_BKGRND_AUX; COLOR_AUX_EDGE_ACTIVE = COLOR_EDGE_ACTIVE; COLOR_AUX_ACTIVEOPTION_BKGRND = COLOR_ACTIVEOPTION_BKGRND; COLOR_BTN_SUCCESS_BKGRND = COLOR_PROC(0x414141); COLOR_BTN_SUCCESS_TEXT = COLOR_PROC(0x33a63d); COLOR_BTN_SUCCESS_BKGRND_HOVER = COLOR_PROC(0x455147); COLOR_BTN_SUCCESS_TEXT_HOVER = COLOR_PROC(0x6eff3a); COLOR_BTN_WARNING_BKGRND = COLOR_PROC(0x414141); COLOR_BTN_WARNING_TEXT = COLOR_PROC(0xbd9e22); COLOR_BTN_WARNING_BKGRND_HOVER = COLOR_PROC(0x4c493c); COLOR_BTN_WARNING_TEXT_HOVER = COLOR_PROC(0xff8d2a); COLOR_BTN_DANGER_BACKGROUND = COLOR_PROC(0x414141); COLOR_BTN_DANGER_TEXT = COLOR_PROC(0xbd2525); COLOR_BTN_DANGER_BKGRND_HOVER = COLOR_PROC(0x513939); COLOR_BTN_DANGER_TEXT_HOVER = COLOR_PROC(0xfa2626); COLOR_BTN_DISABLED_BKGRND = COLOR_PROC(0x414141); COLOR_BTN_DISABLED_TEXT = COLOR_MAIN_TEXT; COLOR_BTN_DISABLED_TRANSFER = COLOR_BTN_DISABLED_TEXT; COLOR_BTN_DISABLED_FORGRND = COLOR_PROC(0x666666); COLOR_BTN_INPROGRESS_BKGRND = COLOR_BTN_DISABLED_BKGRND; COLOR_BTN_INPROGRESS_TEXT = COLOR_MAIN_TEXT_URL; COLOR_BTN_INPROGRESS_FORGRND = COLOR_PROC(0x2f656a); break; } case THEME_LIGHT: { COLOR_BKGRND_AUX = COLOR_PROC(0xe0e0e0); COLOR_BKGRND_LIST = COLOR_PROC(0xf0f0f0); COLOR_BKGRND_LIST_HOVER = COLOR_PROC(0xe0e0e0); COLOR_BKGRND_MENU = COLOR_BKGRND_LIST; COLOR_BKGRND_MENU_HOVER = COLOR_PROC(0xe0e0e0); COLOR_BKGRND_MENU_ACTIVE = COLOR_PROC(0x555555); COLOR_LIST_TEXT = COLOR_MAIN_TEXT; COLOR_LIST_TEXT_SUBTEXT = COLOR_MAIN_TEXT_SUBTEXT; COLOR_MENU_TEXT = COLOR_PROC(0x555555); COLOR_MENU_TEXT_ACTIVE = COLOR_PROC(0xffffff); COLOR_MENU_TEXT_SUBTEXT = COLOR_PROC(0x414141); COLOR_EDGE_NORMAL = COLOR_PROC(0xc0c0c0); COLOR_EDGE_HOVER = COLOR_PROC(0x707070); COLOR_ACTIVEOPTION_BKGRND = COLOR_PROC(0xc2e0ff); COLOR_ACTIVEOPTION_TEXT = COLOR_MAIN_TEXT; COLOR_AUX_EDGE_NORMAL = COLOR_BKGRND_AUX; COLOR_AUX_EDGE_HOVER = COLOR_PROC(0x999999); COLOR_AUX_EDGE_ACTIVE = COLOR_EDGE_ACTIVE; COLOR_AUX_TEXT = COLOR_LIST_TEXT; COLOR_AUX_ACTIVEOPTION_BKGRND = COLOR_ACTIVEOPTION_BKGRND; COLOR_AUX_ACTIVEOPTION_TEXT = COLOR_AUX_TEXT; break; } case THEME_HIGHCONTRAST: { COLOR_BKGRND_MAIN = COLOR_PROC(0xffffff); COLOR_BKGRND_AUX = COLOR_BKGRND_MAIN; COLOR_BKGRND_LIST = COLOR_PROC(0x444444); COLOR_BKGRND_LIST_HOVER = COLOR_PROC(0x000001); COLOR_BKGRND_MENU = COLOR_BKGRND_MAIN; COLOR_BKGRND_MENU_HOVER = COLOR_BKGRND_MAIN; COLOR_BKGRND_MENU_ACTIVE = COLOR_BKGRND_LIST_HOVER; COLOR_MAIN_TEXT = COLOR_PROC(0x000001); COLOR_MAIN_TEXT_CHAT = COLOR_MAIN_TEXT; COLOR_MAIN_TEXT_SUBTEXT = COLOR_MAIN_TEXT; COLOR_MAIN_TEXT_ACTION = COLOR_PROC(0x0000ff); COLOR_MAIN_TEXT_QUOTE = COLOR_PROC(0x00ff00); COLOR_MAIN_TEXT_URL = COLOR_MAIN_TEXT_ACTION; COLOR_MAIN_TEXT_HINT = COLOR_MAIN_TEXT; COLOR_MENU_TEXT = COLOR_MAIN_TEXT; COLOR_MENU_TEXT_SUBTEXT = COLOR_MAIN_TEXT; COLOR_MENU_TEXT_ACTIVE = COLOR_BKGRND_MAIN; COLOR_LIST_TEXT = COLOR_BKGRND_MAIN; COLOR_LIST_TEXT_SUBTEXT = COLOR_BKGRND_MAIN; COLOR_GROUP_SELF = COLOR_PROC(0x00ff00); COLOR_GROUP_PEER = COLOR_MAIN_TEXT_HINT; COLOR_GROUP_AUDIO = COLOR_PROC(0xff0000); COLOR_GROUP_MUTED = COLOR_MAIN_TEXT_URL; COLOR_SELECTION_BACKGROUND = COLOR_MAIN_TEXT; COLOR_SELECTION_TEXT = COLOR_BKGRND_MAIN; COLOR_EDGE_NORMAL = COLOR_MAIN_TEXT; COLOR_EDGE_ACTIVE = COLOR_MAIN_TEXT; COLOR_EDGE_HOVER = COLOR_MAIN_TEXT; COLOR_ACTIVEOPTION_BKGRND = COLOR_MAIN_TEXT; COLOR_ACTIVEOPTION_TEXT = COLOR_BKGRND_MAIN; COLOR_AUX_EDGE_NORMAL = COLOR_EDGE_NORMAL; COLOR_AUX_EDGE_HOVER = COLOR_EDGE_NORMAL; COLOR_AUX_EDGE_ACTIVE = COLOR_EDGE_ACTIVE; COLOR_AUX_TEXT = COLOR_MAIN_TEXT; COLOR_AUX_ACTIVEOPTION_BKGRND = COLOR_ACTIVEOPTION_BKGRND; COLOR_AUX_ACTIVEOPTION_TEXT = COLOR_ACTIVEOPTION_TEXT; COLOR_STATUS_ONLINE = COLOR_PROC(0x00ff00); COLOR_STATUS_AWAY = COLOR_PROC(0xffff00); COLOR_STATUS_BUSY = COLOR_PROC(0xff0000); COLOR_BTN_SUCCESS_BKGRND = COLOR_PROC(0x00ff00); COLOR_BTN_SUCCESS_TEXT = COLOR_BKGRND_MAIN; COLOR_BTN_SUCCESS_BKGRND_HOVER = COLOR_PROC(0x00ff00); COLOR_BTN_SUCCESS_TEXT_HOVER = COLOR_BKGRND_MAIN; COLOR_BTN_WARNING_BKGRND = COLOR_PROC(0xffff00); COLOR_BTN_WARNING_TEXT = COLOR_BKGRND_MAIN; COLOR_BTN_WARNING_BKGRND_HOVER = COLOR_PROC(0xffff00); COLOR_BTN_WARNING_TEXT_HOVER = COLOR_BKGRND_MAIN; COLOR_BTN_DANGER_BACKGROUND = COLOR_PROC(0xff0000); COLOR_BTN_DANGER_TEXT = COLOR_BKGRND_MAIN; COLOR_BTN_DANGER_BKGRND_HOVER = COLOR_PROC(0xff0000); COLOR_BTN_DANGER_TEXT_HOVER = COLOR_BKGRND_MAIN; COLOR_BTN_DISABLED_BKGRND = COLOR_PROC(0x444444); COLOR_BTN_DISABLED_TEXT = COLOR_MAIN_TEXT; COLOR_BTN_DISABLED_TRANSFER = COLOR_BKGRND_MAIN; COLOR_BTN_DISABLED_FORGRND = COLOR_PROC(0x000000); COLOR_BTN_INPROGRESS_TEXT = COLOR_BTN_DISABLED_TEXT; COLOR_BTN_INPROGRESS_BKGRND = COLOR_PROC(0x00ffff); break; } case THEME_ZENBURN: { COLOR_BKGRND_MAIN = COLOR_PROC(0x3f3f3f); COLOR_BKGRND_AUX = COLOR_BKGRND_MAIN; COLOR_BKGRND_LIST = COLOR_PROC(0x5f5f5f); COLOR_BKGRND_LIST_HOVER = COLOR_PROC(0x7f7f7f); COLOR_BKGRND_MENU = COLOR_BKGRND_MAIN; COLOR_BKGRND_MENU_HOVER = COLOR_PROC(0x7f9f7f); COLOR_BKGRND_MENU_ACTIVE = COLOR_BKGRND_MENU_HOVER; COLOR_MAIN_TEXT = COLOR_PROC(0xdcdccc); COLOR_MAIN_TEXT_CHAT = COLOR_MAIN_TEXT; COLOR_MAIN_TEXT_SUBTEXT = COLOR_MAIN_TEXT; COLOR_MAIN_TEXT_ACTION = COLOR_PROC(0xd0bf8f); COLOR_MAIN_TEXT_QUOTE = COLOR_PROC(0x7f9f7f); COLOR_MAIN_TEXT_RED = COLOR_PROC(0xcc9393); COLOR_MAIN_TEXT_URL = COLOR_PROC(0x6ca0a3); COLOR_MAIN_TEXT_HINT = COLOR_MAIN_TEXT; COLOR_MSG_USER = COLOR_MAIN_TEXT; COLOR_MSG_USER_PEND = COLOR_MAIN_TEXT_ACTION; COLOR_MSG_USER_ERROR = COLOR_MAIN_TEXT_RED; COLOR_MSG_CONTACT = COLOR_MAIN_TEXT; COLOR_MENU_TEXT = COLOR_MAIN_TEXT; COLOR_MENU_TEXT_SUBTEXT = COLOR_MAIN_TEXT; COLOR_MENU_TEXT_ACTIVE = COLOR_MAIN_TEXT; COLOR_LIST_TEXT = COLOR_MAIN_TEXT; COLOR_LIST_TEXT_SUBTEXT = COLOR_MAIN_TEXT; COLOR_GROUP_SELF = COLOR_MAIN_TEXT; COLOR_GROUP_PEER = COLOR_MAIN_TEXT; COLOR_GROUP_AUDIO = COLOR_MAIN_TEXT_QUOTE; COLOR_GROUP_MUTED = COLOR_MAIN_TEXT_ACTION; COLOR_SELECTION_BACKGROUND = COLOR_MAIN_TEXT_QUOTE; COLOR_SELECTION_TEXT = COLOR_MAIN_TEXT; COLOR_EDGE_NORMAL = COLOR_BKGRND_LIST; COLOR_EDGE_ACTIVE = COLOR_MAIN_TEXT; COLOR_EDGE_HOVER = COLOR_MAIN_TEXT_QUOTE; COLOR_ACTIVEOPTION_BKGRND = COLOR_MAIN_TEXT_QUOTE; COLOR_ACTIVEOPTION_TEXT = COLOR_MAIN_TEXT; COLOR_AUX_EDGE_NORMAL = COLOR_BKGRND_LIST; COLOR_AUX_EDGE_HOVER = COLOR_MAIN_TEXT_QUOTE; COLOR_AUX_EDGE_ACTIVE = COLOR_MAIN_TEXT; COLOR_AUX_TEXT = COLOR_MAIN_TEXT; COLOR_AUX_ACTIVEOPTION_BKGRND = COLOR_MAIN_TEXT_QUOTE; COLOR_AUX_ACTIVEOPTION_TEXT = COLOR_MAIN_TEXT; COLOR_STATUS_ONLINE = COLOR_MAIN_TEXT_QUOTE; COLOR_STATUS_AWAY = COLOR_MAIN_TEXT_ACTION; COLOR_STATUS_BUSY = COLOR_MAIN_TEXT_RED; COLOR_BTN_SUCCESS_BKGRND = COLOR_MAIN_TEXT_QUOTE; COLOR_BTN_SUCCESS_TEXT = COLOR_MAIN_TEXT; COLOR_BTN_SUCCESS_BKGRND_HOVER = COLOR_PROC(0xbfebbf); COLOR_BTN_SUCCESS_TEXT_HOVER = COLOR_PROC(0xffffff); COLOR_BTN_WARNING_BKGRND = COLOR_MAIN_TEXT_ACTION; COLOR_BTN_WARNING_TEXT = COLOR_BTN_SUCCESS_TEXT_HOVER; COLOR_BTN_WARNING_BKGRND_HOVER = COLOR_PROC(0xf0dfaf); COLOR_BTN_WARNING_TEXT_HOVER = COLOR_BTN_SUCCESS_TEXT_HOVER; COLOR_BTN_DANGER_BACKGROUND = COLOR_STATUS_AWAY; COLOR_BTN_DANGER_TEXT = COLOR_MAIN_TEXT; COLOR_BTN_DANGER_BKGRND_HOVER = COLOR_PROC(0xdca3a3); COLOR_BTN_DANGER_TEXT_HOVER = COLOR_BTN_SUCCESS_TEXT_HOVER; COLOR_BTN_DISABLED_BKGRND = COLOR_BKGRND_LIST; COLOR_BTN_DISABLED_TEXT = COLOR_MAIN_TEXT; COLOR_BTN_DISABLED_BKGRND_HOVER = COLOR_BKGRND_LIST_HOVER; COLOR_BTN_DISABLED_TRANSFER = COLOR_MAIN_TEXT; COLOR_BTN_DISABLED_FORGRND = COLOR_BKGRND_LIST_HOVER; COLOR_BTN_INPROGRESS_BKGRND = COLOR_PROC(0xc1c1a4); COLOR_BTN_INPROGRESS_TEXT = COLOR_BKGRND_MAIN; COLOR_BTN_INPROGRESS_FORGRND = COLOR_MAIN_TEXT; break; } case THEME_SOLARIZED_DARK: { COLOR_BKGRND_MAIN = COLOR_PROC(SOLAR_BASE03); COLOR_BKGRND_ALT = COLOR_PROC(SOLAR_BASE02); COLOR_BKGRND_AUX = COLOR_BKGRND_ALT; COLOR_BKGRND_LIST = COLOR_BKGRND_ALT; COLOR_BKGRND_LIST_HOVER = COLOR_PROC(SOLAR_BASE01); COLOR_BKGRND_MENU = COLOR_PROC(SOLAR_BASE03); COLOR_BKGRND_MENU_HOVER = COLOR_PROC(SOLAR_CYAN); COLOR_BKGRND_MENU_ACTIVE = COLOR_BKGRND_ALT; COLOR_MAIN_TEXT = COLOR_PROC(SOLAR_BASE2); COLOR_MAIN_TEXT_CHAT = COLOR_MAIN_TEXT; COLOR_MAIN_TEXT_SUBTEXT = COLOR_PROC(SOLAR_BASE1); COLOR_MAIN_TEXT_ACTION = COLOR_PROC(SOLAR_BASE3); COLOR_MAIN_TEXT_QUOTE = COLOR_MAIN_TEXT_SUBTEXT; COLOR_MAIN_TEXT_RED = COLOR_PROC(SOLAR_RED); COLOR_MAIN_TEXT_URL = COLOR_PROC(SOLAR_MAGENTA); COLOR_MAIN_TEXT_HINT = COLOR_PROC(SOLAR_VIOLET); COLOR_MSG_USER = COLOR_MAIN_TEXT_SUBTEXT; COLOR_MSG_USER_PEND = COLOR_MAIN_TEXT_ACTION; COLOR_MSG_USER_ERROR = COLOR_MAIN_TEXT_RED; COLOR_MSG_CONTACT = COLOR_MAIN_TEXT; COLOR_MENU_TEXT = COLOR_MAIN_TEXT; COLOR_MENU_TEXT_SUBTEXT = COLOR_MAIN_TEXT_SUBTEXT; COLOR_MENU_TEXT_ACTIVE = COLOR_MAIN_TEXT; COLOR_LIST_TEXT = COLOR_MAIN_TEXT; COLOR_LIST_TEXT_SUBTEXT = COLOR_MAIN_TEXT_SUBTEXT; COLOR_GROUP_SELF = COLOR_PROC(SOLAR_GREEN); COLOR_GROUP_PEER = COLOR_MAIN_TEXT_HINT; COLOR_GROUP_AUDIO = COLOR_PROC(SOLAR_RED); COLOR_GROUP_MUTED = COLOR_MAIN_TEXT_ACTION; COLOR_SELECTION_BACKGROUND = COLOR_MAIN_TEXT; COLOR_SELECTION_TEXT = COLOR_BKGRND_MAIN; COLOR_EDGE_NORMAL = COLOR_PROC(SOLAR_VIOLET); COLOR_EDGE_HOVER = COLOR_PROC(SOLAR_BLUE); COLOR_EDGE_ACTIVE = COLOR_PROC(SOLAR_ORANGE); COLOR_ACTIVEOPTION_BKGRND = COLOR_BKGRND_LIST_HOVER; COLOR_ACTIVEOPTION_TEXT = COLOR_MAIN_TEXT; COLOR_AUX_EDGE_NORMAL = COLOR_BKGRND_AUX; COLOR_AUX_EDGE_HOVER = COLOR_PROC(SOLAR_VIOLET); COLOR_AUX_EDGE_ACTIVE = COLOR_PROC(SOLAR_CYAN); COLOR_AUX_TEXT = COLOR_LIST_TEXT; COLOR_AUX_ACTIVEOPTION_BKGRND = COLOR_BKGRND_LIST_HOVER; COLOR_AUX_ACTIVEOPTION_TEXT = COLOR_AUX_TEXT; COLOR_STATUS_ONLINE = COLOR_PROC(SOLAR_GREEN); COLOR_STATUS_AWAY = COLOR_PROC(SOLAR_YELLOW); COLOR_STATUS_BUSY = COLOR_PROC(SOLAR_RED); COLOR_BTN_SUCCESS_BKGRND = COLOR_STATUS_ONLINE; COLOR_BTN_SUCCESS_TEXT = COLOR_MAIN_TEXT; COLOR_BTN_SUCCESS_BKGRND_HOVER = COLOR_PROC(SOLAR_CYAN); COLOR_BTN_SUCCESS_TEXT_HOVER = COLOR_BKGRND_MAIN; COLOR_BTN_WARNING_BKGRND = COLOR_STATUS_AWAY; COLOR_BTN_WARNING_TEXT = COLOR_MAIN_TEXT; COLOR_BTN_WARNING_BKGRND_HOVER = COLOR_PROC(SOLAR_ORANGE); COLOR_BTN_WARNING_TEXT_HOVER = COLOR_BKGRND_MAIN; COLOR_BTN_DANGER_BACKGROUND = COLOR_STATUS_BUSY; COLOR_BTN_DANGER_TEXT = COLOR_MAIN_TEXT; COLOR_BTN_DANGER_BKGRND_HOVER = COLOR_PROC(SOLAR_MAGENTA); COLOR_BTN_DANGER_TEXT_HOVER = COLOR_BKGRND_MAIN; COLOR_BTN_DISABLED_BKGRND = COLOR_PROC(SOLAR_BASE00); COLOR_BTN_DISABLED_TEXT = COLOR_BKGRND_MAIN; COLOR_BTN_DISABLED_BKGRND_HOVER = COLOR_BKGRND_LIST_HOVER; COLOR_BTN_DISABLED_TRANSFER = COLOR_BKGRND_LIST; COLOR_BTN_DISABLED_FORGRND = COLOR_PROC(SOLAR_ORANGE); COLOR_BTN_INPROGRESS_FORGRND = COLOR_PROC(SOLAR_MAGENTA); COLOR_BTN_INPROGRESS_BKGRND = COLOR_PROC(SOLAR_VIOLET); COLOR_BTN_INPROGRESS_TEXT = COLOR_BKGRND_MAIN; break; } case THEME_SOLARIZED_LIGHT: { COLOR_BKGRND_MAIN = COLOR_PROC(SOLAR_BASE3); COLOR_BKGRND_ALT = COLOR_PROC(SOLAR_BASE2); COLOR_BKGRND_AUX = COLOR_BKGRND_ALT; COLOR_BKGRND_LIST = COLOR_BKGRND_ALT; COLOR_BKGRND_LIST_HOVER = COLOR_PROC(SOLAR_BASE1); COLOR_BKGRND_MENU = COLOR_BKGRND_ALT; COLOR_BKGRND_MENU_HOVER = COLOR_PROC(SOLAR_CYAN); COLOR_BKGRND_MENU_ACTIVE = COLOR_BKGRND_ALT; COLOR_MAIN_TEXT = COLOR_PROC(SOLAR_BASE02); COLOR_MAIN_TEXT_CHAT = COLOR_MAIN_TEXT; COLOR_MAIN_TEXT_SUBTEXT = COLOR_PROC(SOLAR_BASE01); COLOR_MAIN_TEXT_ACTION = COLOR_PROC(SOLAR_BASE03); COLOR_MAIN_TEXT_QUOTE = COLOR_MAIN_TEXT_SUBTEXT; COLOR_MAIN_TEXT_RED = COLOR_PROC(SOLAR_RED); COLOR_MAIN_TEXT_URL = COLOR_PROC(SOLAR_MAGENTA); COLOR_MAIN_TEXT_HINT = COLOR_PROC(SOLAR_VIOLET); COLOR_MSG_USER = COLOR_MAIN_TEXT_SUBTEXT; COLOR_MSG_USER_PEND = COLOR_MAIN_TEXT_ACTION; COLOR_MSG_USER_ERROR = COLOR_MAIN_TEXT_RED; COLOR_MSG_CONTACT = COLOR_MAIN_TEXT; COLOR_MENU_TEXT = COLOR_MAIN_TEXT; COLOR_MENU_TEXT_SUBTEXT = COLOR_MAIN_TEXT_SUBTEXT; COLOR_MENU_TEXT_ACTIVE = COLOR_MAIN_TEXT; COLOR_LIST_TEXT = COLOR_MAIN_TEXT; COLOR_LIST_TEXT_SUBTEXT = COLOR_MAIN_TEXT_SUBTEXT; COLOR_GROUP_SELF = COLOR_PROC(SOLAR_GREEN); COLOR_GROUP_PEER = COLOR_MAIN_TEXT_HINT; COLOR_GROUP_AUDIO = COLOR_PROC(SOLAR_RED); COLOR_GROUP_MUTED = COLOR_MAIN_TEXT_ACTION; COLOR_SELECTION_BACKGROUND = COLOR_MAIN_TEXT; COLOR_SELECTION_TEXT = COLOR_BKGRND_MAIN; COLOR_EDGE_NORMAL = COLOR_PROC(SOLAR_VIOLET); COLOR_EDGE_HOVER = COLOR_PROC(SOLAR_BLUE); COLOR_EDGE_ACTIVE = COLOR_PROC(SOLAR_CYAN); COLOR_ACTIVEOPTION_BKGRND = COLOR_BKGRND_LIST_HOVER; COLOR_ACTIVEOPTION_TEXT = COLOR_MAIN_TEXT; COLOR_AUX_EDGE_NORMAL = COLOR_BKGRND_AUX; COLOR_AUX_EDGE_HOVER = COLOR_PROC(SOLAR_VIOLET); COLOR_AUX_EDGE_ACTIVE = COLOR_PROC(SOLAR_CYAN); COLOR_AUX_TEXT = COLOR_LIST_TEXT; COLOR_AUX_ACTIVEOPTION_BKGRND = COLOR_BKGRND_LIST_HOVER; COLOR_AUX_ACTIVEOPTION_TEXT = COLOR_AUX_TEXT; COLOR_STATUS_ONLINE = COLOR_PROC(SOLAR_GREEN); COLOR_STATUS_AWAY = COLOR_PROC(SOLAR_YELLOW); COLOR_STATUS_BUSY = COLOR_PROC(SOLAR_RED); COLOR_BTN_SUCCESS_BKGRND = COLOR_STATUS_ONLINE; COLOR_BTN_SUCCESS_TEXT = COLOR_MAIN_TEXT; COLOR_BTN_SUCCESS_BKGRND_HOVER = COLOR_PROC(SOLAR_CYAN); COLOR_BTN_SUCCESS_TEXT_HOVER = COLOR_BKGRND_MAIN; COLOR_BTN_WARNING_BKGRND = COLOR_STATUS_AWAY; COLOR_BTN_WARNING_TEXT = COLOR_MAIN_TEXT; COLOR_BTN_WARNING_BKGRND_HOVER = COLOR_PROC(SOLAR_ORANGE); COLOR_BTN_WARNING_TEXT_HOVER = COLOR_BKGRND_MAIN; COLOR_BTN_DANGER_BACKGROUND = COLOR_STATUS_BUSY; COLOR_BTN_DANGER_TEXT = COLOR_MAIN_TEXT; COLOR_BTN_DANGER_BKGRND_HOVER = COLOR_PROC(SOLAR_MAGENTA); COLOR_BTN_DANGER_TEXT_HOVER = COLOR_BKGRND_MAIN; COLOR_BTN_DISABLED_BKGRND = COLOR_PROC(SOLAR_BASE0); COLOR_BTN_DISABLED_TEXT = COLOR_BKGRND_MAIN; COLOR_BTN_DISABLED_BKGRND_HOVER = COLOR_BKGRND_LIST_HOVER; COLOR_BTN_DISABLED_TRANSFER = COLOR_BKGRND_LIST; COLOR_BTN_DISABLED_FORGRND = COLOR_PROC(SOLAR_ORANGE); COLOR_BTN_INPROGRESS_BKGRND = COLOR_PROC(SOLAR_VIOLET); COLOR_BTN_INPROGRESS_TEXT = COLOR_BKGRND_MAIN; COLOR_BTN_INPROGRESS_FORGRND = COLOR_PROC(SOLAR_MAGENTA); break; } case THEME_CUSTOM: { size_t size; uint8_t *themedata = utox_data_load_custom_theme(&size); if (!themedata) { return; } read_custom_theme(themedata, size); free(themedata); break; } case THEME_DEFAULT: { // Set above the switch. break; } } status_color[0] = COLOR_STATUS_ONLINE; status_color[1] = COLOR_STATUS_AWAY; status_color[2] = COLOR_STATUS_BUSY; status_color[3] = COLOR_STATUS_BUSY; } uint32_t *find_colour_pointer(char *color) { while (*color == 0 || *color == ' ' || *color == '\t') { ++color; } for (int l = strlen(color) - 1; l > 0; --l) { if (color[l] != ' ' && color[l] != '\t') { color[l + 1] = '\0'; break; } } // Skip past "COLOR_" prefix if (!strncmp(color, "COLOR_", 6)) { color += 6; } LOG_INFO("Theme", "Color: %s" , color); for (int i = 0;; ++i) { const char *s = COLOUR_NAME_TABLE[i]; if (!s) { break; } if (!strcmp(color, s)) { return COLOUR_POINTER_TABLE[i]; } } return NULL; } static uint32_t try_parse_hex_colour(char *color, bool *error) { while (*color == 0 || *color == ' ' || *color == '\t') { color++; } for (int l = strlen(color) - 1; l > 0; --l) { if (color[l] != ' ' && color[l] != '\n') { color[++l] = '\0'; if (l != 6) { *error = true; return 0; } break; } } char hex[3] = { 0 }; memcpy(hex, color, 2); unsigned char red = strtol(hex, NULL, 16); memcpy(hex, color + 2, 2); unsigned char green = strtol(hex, NULL, 16); memcpy(hex, color + 4, 2); unsigned char blue = strtol(hex, NULL, 16); return RGB(red, green, blue); } static void read_custom_theme(const uint8_t *data, size_t length) { while (length) { char *line = (char *)data; while (*line != 0) { if (*line == '#') { *line = 0; break; } ++line; --length; } char *color = strpbrk(line, "="); if (!color || color == line) { continue; } *color++ = 0; uint32_t *colorp = find_colour_pointer(line); if (!colorp) { continue; } bool err = false; const uint32_t col = try_parse_hex_colour(color, &err); if (err) { LOG_ERR("Theme", "Error: Parsing hex color failed."); continue; } else { *colorp = COLOR_PROC(col); } } } static uint8_t *utox_data_load_custom_theme(size_t *out) { FILE *fp = utox_get_file("utox_theme.ini", out, UTOX_FILE_OPTS_READ); if (fp == NULL) { LOG_ERR("Theme", "Failed to open custom theme file."); return NULL; } uint8_t *data = calloc(1, *out + 1); if (data == NULL) { LOG_ERR("Theme", "Failed to allocate memory for custom theme."); fclose(fp); return NULL; } if (fread(data, *out, 1, fp) != 1) { LOG_ERR("Theme", "Could not read custom theme from file."); fclose(fp); free(data); return NULL; } fclose(fp); return data; } uTox/src/text.h0000600000175000001440000000337214003056216012427 0ustar rakusers#ifndef TEXT_H #define TEXT_H #include #include /** convert number of bytes to human readable string * returns number of characters written * notes: dest MUST be at least size characters large */ int sprint_humanread_bytes(char *dest, unsigned int size, uint64_t bytes); /** length of a utf-8 character * returns the size of the character in bytes * returns -1 if the size of the character is greater than len or if the character is invalid */ uint8_t utf8_len(const char *data); /* read the character into ch */ uint8_t utf8_len_read(const char *data, uint32_t *ch); /* backwards length */ uint8_t utf8_unlen(char *data); /* remove invalid characters from utf8 string * returns the new length after invalid characters have been removed */ int utf8_validate(const uint8_t *data, int len); uint8_t unicode_to_utf8_len(uint32_t ch); void unicode_to_utf8(uint32_t ch, char *dst); /* compare first n bytes of s1 and s2, ignoring the case of alpha chars * match: returns 0 * no match: returns 1 * notes: n must be <= length of s1 and <= length of s2 */ bool memcmp_case(const char *s1, const char *s2, uint32_t n); /* replace html entities (<,>,&) with html */ char *tohtml(const char *str, uint16_t len); void to_hex(char *out, uint8_t *in, int size); /* returns non-zero if substring is found */ bool strstr_case(const char *a, const char *b); /** * @brief Shrink UTF-8 string down to provided length * without splitting last UTF-8 multi-bytes character. * * @param string UTF-8 string to shrink. * @param string_length Length of UTF-8 string. * @param shrink_length Desirable length of shrunk string. * @return shrunk length. */ uint16_t safe_shrink(const char *string, uint16_t string_length, uint16_t shrink_length); #endif uTox/src/text.c0000600000175000001440000001634014003056216012421 0ustar rakusers#include "text.h" #include "macros.h" #include #include #include #include #include /* returns the length of the string written to `dest` */ int sprint_humanread_bytes(char *dest, unsigned int size, uint64_t bytes) { char * str[] = { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB" }; int max_id = COUNTOF(str) - 1; int i = 0; double f = bytes; while ((bytes >= 1024) && (i < max_id)) { bytes /= 1024; f /= 1024.0; i++; } size_t r; r = snprintf((char *)dest, size, "[%" PRIu64, bytes); if (r >= size) { // truncated r = size - 1; } else { // missing decimals r += snprintf((char *)dest + r, size - r, " %s]", str[i]); if (r >= size) { // truncated r = size - 1; } } return r; } uint8_t utf8_len(const char *data) { if (!(*data & 0x80)) { return 1; } uint8_t bytes = 1, i; for (i = 6; i != 0xFF; i--) { if (!((*data >> i) & 1)) { break; } bytes++; } // no validation, instead validate all utf8 when received return bytes; } uint8_t utf8_len_read(const char *data, uint32_t *ch) { uint8_t a = data[0]; if (!(a & 0x80)) { *ch = data[0]; return 1; } if (!(a & 0x20)) { *ch = ((data[0] & 0x1F) << 6) | (data[1] & 0x3F); return 2; } if (!(a & 0x10)) { *ch = ((data[0] & 0xF) << 12) | ((data[1] & 0x3F) << 6) | (data[2] & 0x3F); return 3; } if (!(a & 8)) { *ch = ((data[0] & 0x7) << 18) | ((data[1] & 0x3F) << 12) | ((data[2] & 0x3F) << 6) | (data[3] & 0x3F); return 4; } if (!(a & 4)) { *ch = ((data[0] & 0x3) << 24) | ((data[1] & 0x3F) << 18) | ((data[2] & 0x3F) << 12) | ((data[3] & 0x3F) << 6) | (data[4] & 0x3F); return 5; } if (!(a & 2)) { *ch = ((data[0] & 0x1) << 30) | ((data[1] & 0x3F) << 24) | ((data[2] & 0x3F) << 18) | ((data[3] & 0x3F) << 12) | ((data[4] & 0x3F) << 6) | (data[5] & 0x3F); return 6; } // never happen return 0; } uint8_t utf8_unlen(char *data) { uint8_t len = 1; if (*(data - 1) & 0x80) { do { len++; } while (!(*(data - len) & 0x40)); } return len; } /* I've had some issues with this function in the past when it's given malformed data. * irungentoo has previouslly said, it'll never fail when given a valid utf-8 string, however the * utf8 standard says that applications are required to handle and correctlly respond to malformed * strings as they have been used in the past to create security expliots. This function is known to * enter an endless state, or segv on bad strings. Either way, that's bad and needs to be fixed. * TODO(grayhatter) TODO(anyone) */ int utf8_validate(const uint8_t *data, int len) { // stops when an invalid character is reached const uint8_t *a = data, *end = data + len; while (a != end) { if (!(*a & 0x80)) { a++; continue; } uint8_t bytes = 1, i; for (i = 6; i != 0xFF; i--) { if (!((*a >> i) & 1)) { break; } bytes++; } if (bytes == 1 || bytes == 8) { break; } // Validate the utf8 if (a + bytes > end) { break; } for (i = 1; i < bytes; i++) { if (!(a[i] & 0x80) || (a[i] & 0x40)) { return a - data; } } a += bytes; } return a - data; } uint8_t unicode_to_utf8_len(uint32_t ch) { if (ch > 0x1FFFFF) { return 0; } return 4 - (ch <= 0xFFFF) - (ch <= 0x7FF) - (ch <= 0x7F); } void unicode_to_utf8(uint32_t ch, char *dst) { uint32_t HB = (uint32_t)0x80; uint32_t SB = (uint32_t)0x3F; if (ch <= 0x7F) { dst[0] = (uint8_t)ch; return; // 1; } if (ch <= 0x7FF) { dst[0] = (uint8_t)((ch >> 6) | (uint32_t)0xC0); dst[1] = (uint8_t)((ch & SB) | HB); return; // 2; } if (ch <= 0xFFFF) { dst[0] = (uint8_t)((ch >> 12) | (uint32_t)0xE0); dst[1] = (uint8_t)(((ch >> 6) & SB) | HB); dst[2] = (uint8_t)((ch & SB) | HB); return; // 3; } if (ch <= 0x1FFFFF) { dst[0] = (uint8_t)((ch >> 18) | (uint32_t)0xF0); dst[1] = (uint8_t)(((ch >> 12) & SB) | HB); dst[2] = (uint8_t)(((ch >> 6) & SB) | HB); dst[3] = (uint8_t)((ch & SB) | HB); return; // 4; } return; // 0; } bool memcmp_case(const char *s1, const char *s2, uint32_t n) { uint32_t i; for (i = 0; i < n; i++) { char c1, c2; c1 = s1[i]; c2 = s2[i]; if (c1 >= (char)'a' && c1 <= (char)'z') { c1 += ('A' - 'a'); } if (c2 >= (char)'a' && c2 <= (char)'z') { c2 += ('A' - 'a'); } if (c1 != c2) { return 1; } } return 0; } char *tohtml(const char *str, uint16_t length) { uint16_t i = 0; int len = 0; while (i != length) { switch (str[i]) { case '<': case '>': { len += 3; break; } case '&': { len += 4; break; } } i += utf8_len(str + i); } char *out = malloc(length + len + 1); i = 0; len = 0; while (i != length) { switch (str[i]) { case '<': case '>': { memcpy(out + len, str[i] == '>' ? ">" : "<", 4); len += 4; i++; break; } case '&': { memcpy(out + len, "&", 5); len += 5; i++; break; } default: { uint16_t r = utf8_len(str + i); memcpy(out + len, str + i, r); len += r; i += r; break; } } } out[len] = 0; return out; } void to_hex(char *out, uint8_t *in, int size) { while (size--) { if (*in >> 4 < 0xA) { *out++ = '0' + (*in >> 4); } else { *out++ = 'A' + (*in >> 4) - 0xA; } if ((*in & 0xf) < 0xA) { *out++ = '0' + (*in & 0xF); } else { *out++ = 'A' + (*in & 0xF) - 0xA; } in++; } } bool strstr_case(const char *a, const char *b) { const char *c = b; while (*a) { if (tolower(*a) != tolower(*c)) { c = b; } if (tolower(*a) == tolower(*c)) { c++; if (!*c) { return 1; } } a++; } return 0; } uint16_t safe_shrink(const char *string, uint16_t string_length, uint16_t shrink_length) { if (!string) { return 0; } uint16_t length = 0; while (length < string_length) { uint8_t char_length = utf8_len(&string[length]); length += char_length; if (length >= shrink_length) { length -= char_length; break; } } return length; } uTox/src/sized_string.h0000600000175000001440000000034514003056216014144 0ustar rakusers#ifndef SIZED_STRING_H #define SIZED_STRING_H #include typedef struct sized_string { char *str; uint16_t length; } STRING; #define STRING_INIT(x) \ { .str = (char *)x, .length = sizeof(x) - 1 } #endif uTox/src/shared/0000700000175000001440000000000014003056216012531 5ustar rakusersuTox/src/shared/freetype-text.c0000600000175000001440000000353114003056216015506 0ustar rakusers#include #include void drawtext(int x, int y, const char *str, uint16_t length) { _drawtext(x, INT_MAX, y, str, length); } int drawtext_getwidth(int x, int y, const char *str, uint16_t length) { return _drawtext(x, INT_MAX, y, str, length) - x; } void drawtextrange(int x, int xmax, int y, const char *str, uint16_t length) { x = _drawtext(x, xmax, y, str, length); if (x < 0) { _drawtext(-x, INT_MAX, y, (char *)"...", 3); } } void drawtextwidth(int x, int width, int y, const char *str, uint16_t length) { drawtextrange(x, x + width, y, str, length); } int textwidth(const char *str, uint16_t length) { int x = 0; while (length) { uint32_t ch; const uint8_t len = utf8_len_read(str, &ch); str += len; length -= len; const GLYPH *g = font_getglyph(sfont, ch); if (g) { x += g->xadvance; } } return x; } void drawtextwidth_right(int x, int width, int y, const char *str, uint16_t length) { const int w = textwidth(str, length); if (w <= width) { drawtext(x + width - w, y, str, length); } else { drawtextrange(x, x + width, y, str, length); } } // FIXME: The next two functions are identical. Delete one? int textfit(const char *str, uint16_t length, int width) { int x = 0; uint16_t i = 0; while (i != length) { uint32_t ch; const uint8_t len = utf8_len_read(str, &ch); str += len; const GLYPH *g = font_getglyph(sfont, ch); if (g) { x += g->xadvance; if (x > width) { return i; } } i += len; } return length; } int textfit_near(const char *str, uint16_t length, int width) { return textfit(str, length, width); } void setfont(int id) { sfont = &font[id]; } uTox/src/settings.h0000600000175000001440000000357014003056216013303 0ustar rakusers#ifndef SETTINGS_H #define SETTINGS_H #include "debug.h" #include "../langs/i18n_decls.h" #include #include #include /* House keeping for uTox save file. */ #define UTOX_SAVE_VERSION 4 #define DEFAULT_FPS 25 typedef struct utox_settings { uint8_t save_version; uint32_t last_version; uint32_t utox_last_version; bool show_splash; // Tox level settings bool block_friend_requests; bool save_encryption; // User interface settings UTOX_LANG language; bool audio_filtering_enabled; bool push_to_talk; bool audio_preview; bool video_preview; bool no_typing_notifications; bool inline_video; bool use_long_time_msg; bool accept_inline_images; // UX Settings bool logging_enabled; bool close_to_tray; bool start_in_tray; bool auto_startup; bool use_mini_flist; bool filter; bool magic_flist_enabled; // Notifications / Alerts bool audible_notifications_enabled; bool status_notifications; uint8_t group_notifications; uint16_t audio_device_out; uint16_t audio_device_in; uint8_t video_fps; LOG_LVL verbose; FILE * debug_file; uint32_t theme; uint8_t scale; // OS interface settings uint32_t window_x; uint32_t window_y; uint32_t window_height; uint32_t window_width; uint32_t window_baseline; bool window_maximized; // Low level settings (network, profile, portable-mode) bool portable_mode; bool disableudp; bool enableipv6; bool proxyenable; bool force_proxy; uint16_t proxy_port; uint8_t proxy_ip[255]; /* coincides with TOX_MAX_HOSTNAME_LENGTH from toxcore */ } SETTINGS; extern SETTINGS settings; /* * Loads settings from disk */ void config_load(void); /* * Writes settings to disk */ void config_save(void); #endif uTox/src/settings.c0000600000175000001440000004313114003056216013273 0ustar rakusers#include "settings.h" #include "debug.h" #include "flist.h" #include "groups.h" #include "tox.h" // TODO do we want to include the UI headers here? // Or would it be better to supply a callback after settings are loaded? #include "ui/edit.h" #include "ui/switch.h" #include "ui/dropdown.h" #include "layout/settings.h" #include "native/filesys.h" #include "native/keyboard.h" // UTOX_VERSION_NUMBER, MAIN_HEIGHT, MAIN_WIDTH, all save things.. #include "main.h" #include #include #include #define MATCH(x, y) (strcasecmp(x, y) == 0) #define BOOL_TO_STR(b) b ? "true" : "false" #define STR_TO_BOOL(s) (strcasecmp(s, "true") == 0) #define NAMEOF(s) strchr((const char *)(#s), '>') == NULL \ ? #s : (strchr((const char *)(#s), '>') + 1) static const char *config_file_name = "utox_save.ini"; /** * Config section names. */ typedef enum { GENERAL_SECTION, INTERFACE_SECTION, AV_SECTION, NOTIFICATIONS_SECTION, ADVANCED_SECTION, UNKNOWN_SECTION } CONFIG_SECTION; static const char *config_sections[UNKNOWN_SECTION + 1] = { "general", "interface", "av", "notifications", "advanced", NULL }; SETTINGS settings = { .last_version = UTOX_VERSION_NUMBER, .utox_last_version = UTOX_VERSION_NUMBER, .show_splash = false, // Tox level settings .block_friend_requests = false, .save_encryption = true, // User interface settings .language = LANG_EN, .audio_filtering_enabled = true, .push_to_talk = false, .audio_preview = false, .video_preview = false, .no_typing_notifications = true, .use_long_time_msg = true, .accept_inline_images = true, // UX Settings .logging_enabled = true, .close_to_tray = false, .start_in_tray = false, .auto_startup = false, .use_mini_flist = false, .magic_flist_enabled = false, // Notifications / Alerts .audible_notifications_enabled = true, .status_notifications = true, .group_notifications = GNOTIFY_ALWAYS, .audio_device_out = 0, .audio_device_in = 0, .video_fps = DEFAULT_FPS, .verbose = LOG_LVL_ERROR, .debug_file = NULL, .theme = UINT32_MAX, // OS interface settings .window_x = 0, .window_y = 0, .window_height = MAIN_HEIGHT, .window_width = MAIN_WIDTH, .window_baseline = 0, .window_maximized = false, // Low level settings (network, profile, portable-mode) .disableudp = false, .enableipv6 = true, .proxyenable = false, .force_proxy = false, .proxy_port = 0, }; static void write_config_value_int(const char *filename, const char *section, const char *key, const long value) { if (ini_putl(section, key, value, filename) != 1) { LOG_ERR("Settings", "Unable to save config value: %lu.", value); } } #define WRITE_CONFIG_VALUE_INT(SECTION, VALUE) \ write_config_value_int(config_path, config_sections[SECTION], \ NAMEOF(VALUE), VALUE) static void write_config_value_str(const char *filename, const char *section, const char *key, const char *value) { if (ini_puts(section, key, value, filename) != 1) { LOG_ERR("Settings", "Unable to save config value: %s.", value); } } #define WRITE_CONFIG_VALUE_STR(SECTION, VALUE) \ write_config_value_str(config_path, config_sections[SECTION], \ NAMEOF(VALUE), (const char *)VALUE) static void write_config_value_bool(const char *filename, const char *section, const char *key, const bool value) { if (ini_puts(section, key, BOOL_TO_STR(value), filename) != 1) { LOG_ERR("Settings", "Unable to save config value: %s.", value); } } #define WRITE_CONFIG_VALUE_BOOL(SECTION, VALUE) \ write_config_value_bool(config_path, config_sections[SECTION], \ NAMEOF(VALUE), VALUE) static CONFIG_SECTION get_section(const char *section) { if (MATCH(config_sections[GENERAL_SECTION], section)) { return GENERAL_SECTION; } else if (MATCH(config_sections[INTERFACE_SECTION], section)) { return INTERFACE_SECTION; } else if (MATCH(config_sections[AV_SECTION], section)) { return AV_SECTION; } else if (MATCH(config_sections[NOTIFICATIONS_SECTION], section)) { return NOTIFICATIONS_SECTION; } else if (MATCH(config_sections[ADVANCED_SECTION], section)) { return ADVANCED_SECTION; } else { return UNKNOWN_SECTION; } } static void parse_general_section(SETTINGS *config, const char *key, const char *value) { if (MATCH(NAMEOF(config->save_version), key)) { config->save_version = atoi(value); } else if (MATCH(NAMEOF(config->utox_last_version), key)) { config->utox_last_version = atoi(value); } } static void parse_interface_section(SETTINGS *config, const char *key, const char *value) { if (MATCH(NAMEOF(config->language), key)) { config->language = atoi(value); } else if (MATCH(NAMEOF(config->window_x), key)) { config->window_x = atoi(value); } else if (MATCH(NAMEOF(config->window_y), key)) { config->window_y = atoi(value); } else if (MATCH(NAMEOF(config->window_width), key)) { config->window_width = atoi(value); } else if (MATCH(NAMEOF(config->window_height), key)) { config->window_height = atoi(value); } else if (MATCH(NAMEOF(config->theme), key)) { // Allow users to override theme on the cmdline. if (config->theme == UINT32_MAX) { config->theme = atoi(value); } } else if (MATCH(NAMEOF(config->scale), key)) { config->scale = atoi(value); } else if (MATCH(NAMEOF(config->logging_enabled), key)) { config->logging_enabled = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->close_to_tray), key)) { config->close_to_tray = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->start_in_tray), key)) { config->start_in_tray = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->auto_startup), key)) { config->auto_startup = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->use_mini_flist), key)) { config->use_mini_flist = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->filter), key)) { config->filter = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->magic_flist_enabled), key)) { config->magic_flist_enabled = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->use_long_time_msg), key)) { config->use_long_time_msg = STR_TO_BOOL(value); } } static void parse_av_section(SETTINGS *config, const char *key, const char *value) { if (MATCH(NAMEOF(config->push_to_talk), key)) { config->push_to_talk = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->audio_filtering_enabled), key)) { config->audio_filtering_enabled = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->audio_device_in), key)) { config->audio_device_in = atoi(value); } else if (MATCH(NAMEOF(config->audio_device_out), key)) { config->audio_device_out = atoi(value); } else if (MATCH(NAMEOF(config->video_fps), key)) { char *temp; uint16_t value_fps = strtol((char *)value, &temp, 0); if (*temp == '\0' && value_fps >= 1 && value_fps <= UINT8_MAX) { settings.video_fps = value_fps; return; } LOG_WARN("Settings", "Fps value (%s) is invalid. It must be integer in range of [1,%u].", value, UINT8_MAX); } } static void parse_notifications_section(SETTINGS *config, const char *key, const char *value) { if (MATCH(NAMEOF(config->audible_notifications_enabled), key)) { config->audible_notifications_enabled = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->status_notifications), key)) { config->status_notifications = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->no_typing_notifications), key)) { config->no_typing_notifications = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->group_notifications), key)) { config->group_notifications = atoi(value); } } static void parse_advanced_section(SETTINGS *config, const char *key, const char *value) { if (MATCH(NAMEOF(config->enableipv6), key)) { config->enableipv6 = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->disableudp), key)) { config->disableudp = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->proxyenable), key)) { config->proxyenable = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->proxy_port), key)) { config->proxy_port = atoi(value); } else if (MATCH(NAMEOF(config->proxy_ip), key)) { strcpy((char *)config->proxy_ip, value); } else if (MATCH(NAMEOF(config->force_proxy), key)) { config->force_proxy = STR_TO_BOOL(value); } else if (MATCH(NAMEOF(config->block_friend_requests), key)) { config->block_friend_requests = STR_TO_BOOL(value); } } static int config_parser(const char *section, const char *key, const char *value, void *config_v) { SETTINGS *config = (SETTINGS *)config_v; switch (get_section(section)) { case GENERAL_SECTION: { parse_general_section(config, key, value); break; } case INTERFACE_SECTION: { parse_interface_section(config, key, value); break; } case AV_SECTION: { parse_av_section(config, key, value); break; } case NOTIFICATIONS_SECTION: { parse_notifications_section(config, key, value); break; } case ADVANCED_SECTION: { parse_advanced_section(config, key, value); break; } case UNKNOWN_SECTION: { LOG_NOTE("Settings", "Unknown section in config file: %s", section); break; } } return 1; } static bool utox_load_config(void) { char *config_path = utox_get_filepath(config_file_name); if (!config_path) { LOG_ERR("Settings", "Unable to get %s path.", config_file_name); return false; } if (!ini_browse(config_parser, &settings, config_path)) { LOG_ERR("Settings", "Unable to parse %s.", config_file_name); free(config_path); return false; } free(config_path); return true; } static bool create_config_folder(char *config_path) { char *last_slash = strrchr(config_path, '/'); if (!last_slash) { last_slash = strrchr(config_path, '\\'); } char *save_folder = strdup(config_path); save_folder[last_slash - config_path + 1] = '\0'; if (!native_create_dir((uint8_t *)save_folder)) { LOG_ERR("Settings", "Failed to create save folder %s.", save_folder); free(save_folder); return false; } free(save_folder); return true; } static bool utox_save_config(void) { char *config_path = utox_get_filepath(config_file_name); if (!config_path) { LOG_ERR("Settings", "Unable to get %s path.", config_file_name); return false; } if (!create_config_folder(config_path)) { free(config_path); return false; } SETTINGS *config = &settings; // general WRITE_CONFIG_VALUE_INT(GENERAL_SECTION, config->save_version); WRITE_CONFIG_VALUE_INT(GENERAL_SECTION, config->utox_last_version); // interface WRITE_CONFIG_VALUE_INT(INTERFACE_SECTION, config->language); WRITE_CONFIG_VALUE_INT(INTERFACE_SECTION, config->window_x); WRITE_CONFIG_VALUE_INT(INTERFACE_SECTION, config->window_y); WRITE_CONFIG_VALUE_INT(INTERFACE_SECTION, config->window_width); WRITE_CONFIG_VALUE_INT(INTERFACE_SECTION, config->window_height); WRITE_CONFIG_VALUE_INT(INTERFACE_SECTION, config->theme); WRITE_CONFIG_VALUE_INT(INTERFACE_SECTION, config->scale); WRITE_CONFIG_VALUE_BOOL(INTERFACE_SECTION, config->logging_enabled); WRITE_CONFIG_VALUE_BOOL(INTERFACE_SECTION, config->close_to_tray); WRITE_CONFIG_VALUE_BOOL(INTERFACE_SECTION, config->start_in_tray); WRITE_CONFIG_VALUE_BOOL(INTERFACE_SECTION, config->auto_startup); WRITE_CONFIG_VALUE_BOOL(INTERFACE_SECTION, config->use_mini_flist); WRITE_CONFIG_VALUE_BOOL(INTERFACE_SECTION, config->filter); WRITE_CONFIG_VALUE_BOOL(INTERFACE_SECTION, config->magic_flist_enabled); WRITE_CONFIG_VALUE_BOOL(INTERFACE_SECTION, config->use_long_time_msg); // av WRITE_CONFIG_VALUE_BOOL(AV_SECTION, config->push_to_talk); WRITE_CONFIG_VALUE_BOOL(AV_SECTION, config->audio_filtering_enabled); WRITE_CONFIG_VALUE_INT(AV_SECTION, config->audio_device_in); WRITE_CONFIG_VALUE_INT(AV_SECTION, config->audio_device_out); WRITE_CONFIG_VALUE_INT(AV_SECTION, config->video_fps); // TODO: video_input_device // notifications WRITE_CONFIG_VALUE_BOOL(NOTIFICATIONS_SECTION, config->audible_notifications_enabled); WRITE_CONFIG_VALUE_BOOL(NOTIFICATIONS_SECTION, config->status_notifications); WRITE_CONFIG_VALUE_BOOL(NOTIFICATIONS_SECTION, config->no_typing_notifications); WRITE_CONFIG_VALUE_INT(NOTIFICATIONS_SECTION, config->group_notifications); // advanced WRITE_CONFIG_VALUE_BOOL(ADVANCED_SECTION, config->enableipv6); WRITE_CONFIG_VALUE_BOOL(ADVANCED_SECTION, config->disableudp); WRITE_CONFIG_VALUE_BOOL(ADVANCED_SECTION, config->proxyenable); WRITE_CONFIG_VALUE_INT(ADVANCED_SECTION, config->proxy_port); WRITE_CONFIG_VALUE_STR(ADVANCED_SECTION, config->proxy_ip); WRITE_CONFIG_VALUE_BOOL(ADVANCED_SECTION, config->force_proxy); WRITE_CONFIG_VALUE_BOOL(ADVANCED_SECTION, config->block_friend_requests); free(config_path); return true; } static void init_default_settings(void) { settings.enableipv6 = true; settings.disableudp = false; settings.proxyenable = false; settings.force_proxy = false; // Allow users to override theme on the cmdline. if (settings.theme == UINT32_MAX) { settings.theme = 0; } settings.audio_filtering_enabled = true; settings.audible_notifications_enabled = true; } void config_load(void) { bool config_loaded = utox_load_config(); if (!config_loaded) { LOG_ERR("Settings", "Unable to load uTox settings. Use defaults."); init_default_settings(); } /* UX Settings */ dropdown_language.selected = dropdown_language.over = settings.language; if (settings.window_width < MAIN_WIDTH) { settings.window_width = MAIN_WIDTH; } if (settings.window_height < MAIN_HEIGHT) { settings.window_height = MAIN_HEIGHT; } dropdown_theme.selected = dropdown_theme.over = settings.theme; if (settings.scale > 30) { settings.scale = 30; } else if (settings.scale < 5) { settings.scale = 10; } dropdown_dpi.selected = dropdown_dpi.over = settings.scale - 5; switch_save_chat_history.switch_on = settings.logging_enabled; switch_close_to_tray.switch_on = settings.close_to_tray; switch_start_in_tray.switch_on = settings.start_in_tray; switch_auto_startup.switch_on = settings.auto_startup; switch_mini_contacts.switch_on = settings.use_mini_flist; flist_set_filter(settings.filter); switch_magic_sidebar.switch_on = settings.magic_flist_enabled; /* Network settings */ switch_ipv6.switch_on = settings.enableipv6; switch_udp.switch_on = !settings.disableudp; switch_udp.panel.disabled = settings.force_proxy; switch_proxy.switch_on = settings.proxyenable != 0; switch_proxy_force.switch_on = settings.force_proxy; switch_proxy_force.panel.disabled = settings.proxyenable == 0; /* AV */ switch_push_to_talk.switch_on = settings.push_to_talk; switch_audio_filtering.switch_on = settings.audio_filtering_enabled; if (settings.video_fps == 0) { settings.video_fps = DEFAULT_FPS; } snprintf((char *)edit_video_fps.data, edit_video_fps.data_size, "%u", settings.video_fps); edit_video_fps.length = strnlen((char *)edit_video_fps.data, edit_video_fps.data_size - 1); /* Notifications */ switch_audible_notifications.switch_on = settings.audible_notifications_enabled; switch_status_notifications.switch_on = settings.status_notifications; switch_typing_notes.switch_on = !settings.no_typing_notifications; settings.group_notifications = dropdown_global_group_notifications.selected = dropdown_global_group_notifications.over = settings.group_notifications; /* Advanced */ edit_proxy_ip.length = strnlen((char *)settings.proxy_ip, sizeof(settings.proxy_ip)); strncpy((char *)edit_proxy_ip.data, (char *)settings.proxy_ip, edit_proxy_ip.length); if (settings.proxy_port) { snprintf((char *)edit_proxy_port.data, edit_proxy_port.data_size, "%u", settings.proxy_port); edit_proxy_port.length = strnlen((char *)edit_proxy_port.data, edit_proxy_port.data_size - 1); } ui_set_scale(settings.scale); if (settings.push_to_talk) { init_ptt(); } if (!config_loaded) { config_save(); } } void config_save(void) { settings.save_version = UTOX_SAVE_VERSION; settings.filter = !!flist_get_filter(); settings.audio_device_in = dropdown_audio_in.selected; settings.audio_device_out = dropdown_audio_out.selected; LOG_NOTE("uTox", "Saving uTox settings."); if (!utox_save_config()) { LOG_ERR("uTox", "Unable to save uTox settings."); } } uTox/src/self.h0000600000175000001440000000164514003056216012375 0ustar rakusers#ifndef SELF_H #define SELF_H #include #include "native/image.h" typedef struct avatar AVATAR; #define TOX_ADDRESS_STR_SIZE TOX_ADDRESS_SIZE * 2 extern struct utox_self { uint8_t status; char name[TOX_MAX_NAME_LENGTH]; char statusmsg[TOX_MAX_STATUS_MESSAGE_LENGTH]; size_t name_length, statusmsg_length; size_t friend_list_count; size_t friend_list_size; size_t groups_list_count; size_t groups_list_size; size_t device_list_count; size_t device_list_size; char id_str[TOX_ADDRESS_SIZE * 2]; size_t id_str_length; NATIVE_IMAGE *qr_image; int qr_image_size; uint8_t *qr_data; int qr_data_size; uint8_t id_binary[TOX_ADDRESS_SIZE]; uint32_t nospam; uint32_t old_nospam; char nospam_str[(sizeof(uint32_t) * 2) + 1]; AVATAR *avatar; uint8_t *png_data; size_t png_size; } self; void init_self(Tox *tox); #endif uTox/src/self.c0000600000175000001440000000206614003056216012366 0ustar rakusers#include "self.h" #include "avatar.h" #include "debug.h" #include "qr.h" #include "tox.h" #include "ui/edit.h" #include "layout/settings.h" #include "native/filesys.h" #include #include #include struct utox_self self; void init_self(Tox *tox) { /* Set local info for self */ edit_setstr(&edit_name, self.name, self.name_length); edit_setstr(&edit_status_msg, self.statusmsg, self.statusmsg_length); /* Get tox id, and gets the hex version for utox */ tox_self_get_address(tox, self.id_binary); id_to_string(self.id_str, self.id_binary); self.id_str_length = TOX_ADDRESS_SIZE * 2; LOG_TRACE("Self INIT", "Tox ID: %.*s" , (int)self.id_str_length, self.id_str); qr_setup(self.id_str, &self.qr_data, &self.qr_data_size, &self.qr_image, &self.qr_image_size); /* Get nospam */ self.nospam = tox_self_get_nospam(tox); self.old_nospam = self.nospam; sprintf(self.nospam_str, "%08X", self.nospam); edit_setstr(&edit_nospam, self.nospam_str, sizeof(uint32_t) * 2); avatar_init_self(); } uTox/src/screen_grab.h0000600000175000001440000000024414003056216013710 0ustar rakusers#ifndef SCREEN_GRAB_H #define SCREEN_GRAB_H #include void native_screen_grab_desktop(bool video); void utox_screen_grab_desktop(bool video); #endif uTox/src/screen_grab.c0000600000175000001440000000015714003056216013706 0ustar rakusers#include "screen_grab.h" void utox_screen_grab_desktop(bool video) { native_screen_grab_desktop(video); } uTox/src/qr.h0000600000175000001440000000026614003056216012064 0ustar rakusers#include typedef struct native_image NATIVE_IMAGE; void qr_setup(const char *id_str, uint8_t **qr_data, int *qr_data_size, NATIVE_IMAGE **qr_image, int *qr_image_size); uTox/src/qr.c0000600000175000001440000000423714003056216012061 0ustar rakusers#include "qr.h" #include "debug.h" #include "stb.h" #include "tox.h" #include "self.h" #include "native/image.h" #include #include #include #include #define QR_BORDER_SIZE 4 /* unit: QR modules */ static bool generate_qr(const char *text, uint8_t *qrcode) { uint8_t temp_buffer[qrcodegen_BUFFER_LEN_MAX]; return qrcodegen_encodeText(text, temp_buffer, qrcode, qrcodegen_Ecc_MEDIUM, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true); } static void convert_qr_to_rgb(const uint8_t *qrcode, uint8_t size, uint8_t *pixels) { /* skip first border on y and x axis */ uint16_t i = ((QR_BORDER_SIZE * size) + QR_BORDER_SIZE) * 3; for (uint8_t y = 0; y < qrcodegen_getSize(qrcode); y++) { for (uint8_t x = 0; x < qrcodegen_getSize(qrcode); x++) { bool black = qrcodegen_getModule(qrcode, x, y); pixels[i] = pixels[i + 1] = pixels[i + 2] = black ? 0x00 : 0xFF; i += 3; } /* skip border until end of line and border on start of next line */ i += (QR_BORDER_SIZE * 2) * 3; } } void qr_setup(const char *id_str, uint8_t **qr_data, int *qr_data_size, NATIVE_IMAGE **qr_image, int *qr_image_size) { const uint8_t channel_number = 3; uint8_t qrcode[qrcodegen_BUFFER_LEN_MAX] = { 0 }; char tox_uri[TOX_ADDRESS_STR_SIZE + sizeof("tox:")]; snprintf(tox_uri, sizeof(tox_uri), "tox:%.*s", (unsigned int) TOX_ADDRESS_STR_SIZE, id_str); if (!generate_qr(tox_uri, qrcode)) { LOG_ERR("QR", "Unable to generate QR code from Tox URI."); return; } *qr_image_size = qrcodegen_getSize(qrcode); *qr_image_size += QR_BORDER_SIZE * 2; /* add border on both sides */ uint8_t pixels[*qr_image_size * *qr_image_size * channel_number]; memset(pixels, 0xFF, sizeof(pixels)); /* make it all white */ convert_qr_to_rgb(qrcode, *qr_image_size, pixels); *qr_data = stbi_write_png_to_mem(pixels, 0, *qr_image_size, *qr_image_size, channel_number, qr_data_size); uint16_t native_size = *qr_image_size; *qr_image = utox_image_to_native(*qr_data, *qr_data_size, &native_size, &native_size, false); } uTox/src/posix/0000700000175000001440000000000014003056216012425 5ustar rakusersuTox/src/posix/filesys.c0000600000175000001440000001232514003056216014254 0ustar rakusers#include "../filesys.h" #include "../debug.h" #include "../settings.h" #include "../native/filesys.h" #include #include #include #include #include #include bool native_create_dir_tree(const char *path) { size_t size = strlen(path); if (size < 2) { // memory bounds check return false; } char *buff = calloc(1, size); if (!buff) { LOG_ERR("Filesys", "Unable to allocate memory for buffer."); return false; } for (size_t i = 1; i < size; ++i) { // i = 1 to skip root '/' if (path[i] == '/') { memcpy(buff, path, i + 1); if (!native_create_dir((uint8_t *)buff)) { free(buff); return false; } } } free(buff); return true; } // native get "valid" file path char *native_get_filepath(const char *name) { char *path = calloc(1, UTOX_FILE_NAME_LENGTH); if (!path) { LOG_ERR("Filesys", "Unable to allocate memory for file path."); return NULL; } if (settings.portable_mode) { snprintf(path, UTOX_FILE_NAME_LENGTH, "./tox/"); } else { snprintf(path, UTOX_FILE_NAME_LENGTH, "%s/.config/tox/", getenv("HOME")); } if (strlen(path) + strlen(name) >= UTOX_FILE_NAME_LENGTH) { LOG_ERR("Filesys", "Load directory name too long" ); free(path); return NULL; } if (!native_create_dir_tree(path)) { free(path); return NULL; } // add file name snprintf(path + strlen(path), UTOX_FILE_NAME_LENGTH - strlen(path), "%s", name); return path; } bool native_create_dir(const uint8_t *filepath) { const int status = mkdir((char *)filepath, S_IRWXU); if (status == 0 || errno == EEXIST) { return true; } LOG_WARN("Filesys", "Unable to create directory %s. Error: %d", filepath, errno); return false; } // TODO: DRY. This function exists in both posix/filesys.c and in android/main.c static void opts_to_sysmode(UTOX_FILE_OPTS opts, char *mode) { if (opts & UTOX_FILE_OPTS_READ) { mode[0] = 'r'; // Reading is first, don't clobber files. } else if (opts & UTOX_FILE_OPTS_APPEND) { mode[0] = 'a'; // Then appending, again, don't clobber files. } else if (opts & UTOX_FILE_OPTS_WRITE) { mode[0] = 'w'; // Writing is the final option we'll look at. } mode[1] = 'b'; // does nothing on posix >C89, but hey, why not? if ((opts & (UTOX_FILE_OPTS_WRITE | UTOX_FILE_OPTS_APPEND)) && (opts & UTOX_FILE_OPTS_READ)) { mode[2] = '+'; } mode[3] = 0; } FILE *native_get_file_simple(const char *path, UTOX_FILE_OPTS opts) { char mode[4] = { 0 }; opts_to_sysmode(opts, mode); FILE *fp = fopen(path, mode); if (!fp && opts & UTOX_FILE_OPTS_READ && opts & UTOX_FILE_OPTS_WRITE) { LOG_WARN("POSIX", "Unable to simple open, falling back to fd" ); // read won't create a file if it doesn't already exist. If we're allowed to write, let's try // to create the file, then reopen it. int fd = open(path, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); fp = fdopen(fd, mode); } return fp; } FILE *native_get_file(const uint8_t *name, size_t *size, UTOX_FILE_OPTS opts, bool portable_mode) { uint8_t path[UTOX_FILE_NAME_LENGTH] = { 0 }; if (portable_mode) { snprintf((char *)path, UTOX_FILE_NAME_LENGTH, "./tox/"); } else { snprintf((char *)path, UTOX_FILE_NAME_LENGTH, "%s/.config/tox/", getenv("HOME")); } // native_get_file should never be called with DELETE in combination with other FILE_OPTS. assert(opts <= UTOX_FILE_OPTS_DELETE); // WRITE and APPEND are mutually exclusive. WRITE will serve you a blank file. APPEND will append (duh). assert((opts & UTOX_FILE_OPTS_WRITE && opts & UTOX_FILE_OPTS_APPEND) == false); if (opts & UTOX_FILE_OPTS_WRITE || opts & UTOX_FILE_OPTS_MKDIR) { if (!native_create_dir(path)) { return NULL; } } if (strlen((char *)path) + strlen((char *)name) >= UTOX_FILE_NAME_LENGTH) { LOG_ERR("Filesys", "Load directory name too long" ); return NULL; } else { snprintf((char *)path + strlen((char *)path), UTOX_FILE_NAME_LENGTH - strlen((char *)path), "%s", name); } if (opts == UTOX_FILE_OPTS_DELETE) { LOG_DEBUG("Filesys", "removing file %s", path); remove((char *)path); return NULL; } if (opts & UTOX_FILE_OPTS_MKDIR) { // remove file name from path uint8_t push; uint8_t *p = path + strlen((char *)path); while (*--p != '/'); push = *++p; *p = 0; native_create_dir(path); *p = push; } FILE *fp = native_get_file_simple((char *)path, opts); if (fp == NULL) { LOG_TRACE("Filesys", "Could not open %s" , path); return NULL; } if (size != NULL) { fseek(fp, 0, SEEK_END); *size = ftell(fp); fseek(fp, 0, SEEK_SET); } return fp; } bool native_move_file(const uint8_t *current_name, const uint8_t *new_name) { if(!current_name || !new_name) { return false; } return rename((char *)current_name, (char *)new_name); } uTox/src/notify.h0000600000175000001440000000052514003056216012750 0ustar rakusers#ifndef NOTIFY_H #define NOTIFY_H typedef struct native_window UTOX_WINDOW; typedef enum { NOTIFY_TYPE_NONE, NOTIFY_TYPE_MSG, NOTIFY_TYPE_CALL, NOTIFY_TYPE_CALL_VIDEO, } NOTIFY_TYPE; typedef enum { TWEEN_NONE, TWEEN_UP, } NOTIFY_TWEEN; UTOX_WINDOW *notify_new(NOTIFY_TYPE type); void notify_tween(void); #endif uTox/src/notify.c0000600000175000001440000000200514003056216012736 0ustar rakusers#include "notify.h" #include "debug.h" #include "window.h" #include "layout/notify.h" #include "native/window.h" #include #include static uint16_t notification_number = 0; UTOX_WINDOW *notify_new(NOTIFY_TYPE type) { LOG_NOTE("Notifier", "Notify:\tCreating Notification #%u", notification_number); const int notify_w = 400; const int notify_h = 150; const int x = 30; const int y = 30 + (20 + notify_h) * notification_number; ++notification_number; PANEL *panel; switch (type) { case NOTIFY_TYPE_NONE: { return NULL; } case NOTIFY_TYPE_MSG: { panel = &panel_notify_generic; break; } case NOTIFY_TYPE_CALL: case NOTIFY_TYPE_CALL_VIDEO: { panel = &panel_notify_generic; // TODO create a video call panel type break; } } UTOX_WINDOW *w = window_create_notify(x, y, notify_w, notify_h, panel); native_window_set_target(w); return w; } uTox/src/native/0000700000175000001440000000000014003056216012551 5ustar rakusersuTox/src/native/xlib/0000700000175000001440000000000014003056216013507 5ustar rakusersuTox/src/native/xlib/keycodes.h0000600000175000001440000000073414003056216015474 0ustar rakusers#ifndef NATIVE_XLIB_KEYCODES_H #define NATIVE_XLIB_KEYCODES_H #define XK_MISCELLANY #include #define KEY_BACK XK_BackSpace #define KEY_RETURN XK_Return #define KEY_LEFT XK_Left #define KEY_RIGHT XK_Right #define KEY_TAB XK_Tab #define KEY_LEFT_TAB XK_ISO_Left_Tab #define KEY_DEL XK_Delete #define KEY_END XK_End #define KEY_HOME XK_Home #define KEY_UP XK_Up #define KEY_DOWN XK_Down #define KEY_PAGEUP XK_Page_Up #define KEY_PAGEDOWN XK_Page_Down #endif uTox/src/native/xlib/image.h0000600000175000001440000000027314003056216014746 0ustar rakusers#ifndef NATIVE_XLIB_IMAGE_H #define NATIVE_XLIB_IMAGE_H #include #define NATIVE_IMAGE_IS_VALID(x) (None != (x)) #define NATIVE_IMAGE_HAS_ALPHA(x) (None != (x->alpha)) #endif uTox/src/native/window.h0000600000175000001440000000305214003056216014233 0ustar rakusers#ifndef NATIVE_WINDOW_H #define NATIVE_WINDOW_H #include typedef struct native_window UTOX_WINDOW; typedef struct panel PANEL; // The following is a hollow struct with window vars common across all platforms // Each platform's window struct starts with this, then follows with their own // specific includes. struct utox_window { UTOX_WINDOW *next; int x, y; unsigned w, h; PANEL *panel; }; void native_window_raze(UTOX_WINDOW *win); UTOX_WINDOW *native_window_find_notify(void *win); UTOX_WINDOW *native_window_create_traypop(int x, int y, int w, int h, PANEL *panel); UTOX_WINDOW *native_window_create_notify(int x, int y, int w, int h, PANEL *panel); void native_window_tween(UTOX_WINDOW *win); void native_window_create_screen_select(void); /** * Sets the target of the next series of drawing commands. * * Returns true if the window was changed. * false if the window is the same. */ bool native_window_set_target(UTOX_WINDOW *new_win); // These deal with platform-specific structures #if defined __WIN32__ || defined _WIN32 || defined __CYGWIN__ #include void native_window_init(HINSTANCE instance); HWND native_window_create_video(int x, int y, int w, int h); UTOX_WINDOW *native_window_create_main(int x, int y, int w, int h); #else // Everything else. bool native_window_init(void); UTOX_WINDOW *native_window_create_video(int x, int y, int w, int h); UTOX_WINDOW *native_window_create_main(int x, int y, int w, int h, char **argv, int argc); #endif #endif // NATIVE_WINDOW_H uTox/src/native/win/0000700000175000001440000000000014003056216013346 5ustar rakusersuTox/src/native/win/keycodes.h0000600000175000001440000000061014003056216015324 0ustar rakusers#ifndef NATIVE_WIN_KEYCODES_H #define NATIVE_WIN_KEYCODES_H #include #define KEY_BACK VK_BACK #define KEY_RETURN VK_RETURN #define KEY_LEFT VK_LEFT #define KEY_RIGHT VK_RIGHT #define KEY_TAB VK_TAB #define KEY_DEL VK_DELETE #define KEY_END VK_END #define KEY_HOME VK_HOME #define KEY_UP VK_UP #define KEY_DOWN VK_DOWN #define KEY_PAGEUP VK_PRIOR #define KEY_PAGEDOWN VK_NEXT #endif uTox/src/native/win/image.h0000600000175000001440000000023714003056216014605 0ustar rakusers#ifndef NATIVE_WIN_IMAGE_H #define NATIVE_WIN_IMAGE_H #define NATIVE_IMAGE_IS_VALID(x) (NULL != (x)) #define NATIVE_IMAGE_HAS_ALPHA(x) (x->has_alpha) #endif uTox/src/native/video.h0000600000175000001440000000241014003056216014027 0ustar rakusers#ifndef NATIVE_VIDEO_H #define NATIVE_VIDEO_H #include #include void video_frame(uint16_t id, uint8_t *img_data, uint16_t width, uint16_t height, bool resize); /** * Opens the OS window for the incoming video frames * * @param id The id number of the friend * Use UINT16_MAX for the preview window * currently any value > UINT16_MAX will be treaded as the * preview window * TODO: move this window handle to the friend struct? * TODO: fix static alloc of the window handles * @param name Name for the title of the window * @param name_length length of @name in bytes * @param width starting size of the video frame * @param height starting size of the video frame */ void video_begin(uint16_t id, char *name, uint16_t name_length, uint16_t width, uint16_t height); void video_end(uint16_t id); uint16_t native_video_detect(void); bool native_video_init(void *handle); void native_video_close(void *handle); int native_video_getframe(uint8_t *y, uint8_t *u, uint8_t *v, uint16_t width, uint16_t height); bool native_video_startread(void); bool native_video_endread(void); // OS X only. void desktopgrab(bool video); #endif uTox/src/native/ui.h0000600000175000001440000000021614003056216013340 0ustar rakusers#ifndef NATIVE_UI_H #define NATIVE_UI_H void redraw(void); void force_redraw(void); void setscale(void); void setscale_fonts(void); #endif uTox/src/native/time.h0000600000175000001440000000011614003056216013660 0ustar rakusers#ifndef NATIVE_TIME_H #define NATIVE_TIME_H uint64_t get_time(void); #endif uTox/src/native/thread.h0000600000175000001440000000020114003056216014164 0ustar rakusers#ifndef NATIVE_THREAD_H #define NATIVE_THREAD_H void thread(void func(void *), void *args); void yieldcpu(uint32_t ms); #endif uTox/src/native/os.h0000600000175000001440000000073514003056216013352 0ustar rakusers#ifndef NATIVE_OS_H #define NATIVE_OS_H // OS-specific cleanup function for when edits are defocused. Commit IME state, etc. // OS X only. void edit_will_deactivate(void); // Android only. void showkeyboard(bool show); // Linux, OS X, and Windows. void openurl(char *str); // Linux only. void setselection(char *data, uint16_t length); // inserts/deletes a value into the registry to launch uTox after boot // OS X and Windows void launch_at_startup(bool should); #endif uTox/src/native/notify.h0000600000175000001440000000033614003056216014236 0ustar rakusers#ifndef NATIVE_NOTIFY_H #define NATIVE_NOTIFY_H extern bool have_focus; void update_tray(void); void notify(char *title, uint16_t title_length, const char *msg, uint16_t msg_length, void *object, bool is_group); #endif uTox/src/native/main.h0000600000175000001440000000070114003056216013646 0ustar rakusers// Uncomment when the native function cleanup is done. // #if defined(NATIVE_MAIN_H) // #error "The main function should only ever be included once." // #endif #ifndef NATIVE_MAIN_H #define NATIVE_MAIN_H #if defined __WIN32__ || defined _WIN32 || defined __CYGWIN__ #include "../windows/main.h" #elif defined __ANDROID__ #include "../android/main.h" #elif defined __OBJC__ #include "../cocoa/main.h" #else #include "../xlib/main.h" #endif #endif uTox/src/native/keyboard.h0000600000175000001440000000122414003056216014523 0ustar rakusers#ifndef NATIVE_KEYBOARD_H #define NATIVE_KEYBOARD_H // Push-to-talk // Enable push-to-talk. void init_ptt(void); // Disable push-to-talk. void exit_ptt(void); // Returns a bool indicating whether you should send audio or not. bool check_ptt_key(void); // TODO: Make it possible to rebind push-to-talk key. // Unimplemented. bool get_ptt_key(void); // Unimplemented. bool set_ptt_key(void); // Native keycodes #if defined __WIN32__ || defined _WIN32 || defined __CYGWIN__ #include "win/keycodes.h" #elif defined __ANDROID__ #include "android/keycodes.h" #elif defined __OBJC__ #include "cocoa/keycodes.h" #else #include "xlib/keycodes.h" #endif #endif uTox/src/native/image.h0000600000175000001440000000376714003056216014023 0ustar rakusers#ifndef NATIVE_IMAGE_H #define NATIVE_IMAGE_H typedef struct native_image NATIVE_IMAGE; typedef uint8_t *UTOX_IMAGE; enum { FILTER_NEAREST, // ugly and quick filtering FILTER_BILINEAR // prettier and a bit slower filtering }; /* set filtering method used when resizing given image to one of above enum */ void image_set_filter(NATIVE_IMAGE *image, uint8_t filter); /* set scale of image so that when it's drawn it will be `scale' times as large(2.0 for double size, 0.5 for half, etc.) * notes: theoretically lowest possible scale is (1.0/65536.0), highest is 65536.0, values outside of this range will * create weird issues * scaling will be rounded to pixels, so it might not be exact */ void image_set_scale(NATIVE_IMAGE *image, double scale); /* draws an utox image with or without alpha channel into the rect of (x,y,width,height) on the screen, * starting at position (imgx,imgy) of the image * WARNING: Windows can fail to show the image at all if the rect (imgx,imgy,width,height) contains even 1 pixel outside * of * the image's size AFTER SCALING, so be careful. * TODO: improve this so this function is safer to use */ void draw_image(const NATIVE_IMAGE *image, int x, int y, uint32_t width, uint32_t height, uint32_t imgx, uint32_t imgy); /* Native wrapper to ready and call draw_image */ void draw_inline_image(uint8_t *img_data, size_t size, uint16_t w, uint16_t h, int x, int y); /* converts a png to a NATIVE_IMAGE, returns a pointer to it, keeping alpha channel only if keep_alpha is 1 */ NATIVE_IMAGE *utox_image_to_native(const UTOX_IMAGE, size_t size, uint16_t *w, uint16_t *h, bool keep_alpha); /* free an image created by utox_image_to_native */ void image_free(NATIVE_IMAGE *image); // OS-dependent macros #if defined __WIN32__ || defined _WIN32 || defined __CYGWIN__ #include "win/image.h" #elif defined __ANDROID__ #include "android/image.h" #elif defined __OBJC__ // TODO: OS X uses functions instead of macros. #include "main.h" #else #include "xlib/image.h" #endif #endif uTox/src/native/filesys.h0000600000175000001440000000340514003056216014404 0ustar rakusers#ifndef NATIVE_FILESYS_H #define NATIVE_FILESYS_H // For UTOX_FILE_OPTS #include "../filesys.h" #include typedef struct file_transfer FILE_TRANSFER; FILE *native_get_file(const uint8_t *name, size_t *size, UTOX_FILE_OPTS opts, bool portable_mode); FILE *native_get_file_simple(const char *name, UTOX_FILE_OPTS opts); /** given a filename, native_remove_file will delete that file from the local config dir */ bool native_remove_file(const uint8_t *name, size_t length, bool portable_mode); bool native_move_file(const uint8_t *current_name, const uint8_t *new_name); // shows a file chooser to the user and calls utox_export_chatlog in turn // TODO not let this depend on chatlogs // TODO refactor this to be a simple filechooser which returns the file instead void native_export_chatlog_init(uint32_t friend_number); // TODO same as for chatlogs, this is mainly native because of the file selector thing typedef struct msg_header MSG_HEADER; void file_save_inline_image_png(MSG_HEADER *msg); // TODO same as for chatlogs, this is mainly native because of the file selector thing bool native_save_image_png(const char *name, const uint8_t *image, const int image_size); typedef struct file_transfer FILE_TRANSFER; void native_autoselect_dir_ft(uint32_t fid, FILE_TRANSFER *file); void native_select_dir_ft(uint32_t fid, uint32_t num, FILE_TRANSFER *file); /** * @brief Get full path of the file in the Tox profile folder. * * @param name name of the file. * @return null-terminated string, or NULL on failure. */ char *native_get_filepath(const char *name); // OS interface replacements void flush_file(FILE *file); int ch_mod(uint8_t *file); int file_lock(FILE *file, uint64_t start, size_t length); int file_unlock(FILE *file, uint64_t start, size_t length); #endif uTox/src/native/dialog.h0000600000175000001440000000063314003056216014165 0ustar rakusers#ifndef NATIVE_DIALOG_H #define NATIVE_DIALOG_H // Linux, OS X, and Windows. void openfilesend(void); // Use the file picker to select an avatar and set it as the user's. // Linux, OS X, and Windows. void openfileavatar(void); /** * @brief Show a platform-independent message box. */ void show_messagebox(const char *caption, uint16_t caption_length, const char *message, uint16_t message_length); #endif uTox/src/native/cocoa/0000700000175000001440000000000014003056216013635 5ustar rakusersuTox/src/native/cocoa/keycodes.h0000600000175000001440000000121314003056216015613 0ustar rakusers#ifndef NATIVE_COCOA_KEYCODES_H #define NATIVE_COCOA_KEYCODES_H #include #define CARBON_K(x) (x + 255) #define KEY_BACK CARBON_K(kVK_Delete) #define KEY_RETURN CARBON_K(kVK_Return) #define KEY_LEFT CARBON_K(kVK_LeftArrow) #define KEY_RIGHT CARBON_K(kVK_RightArrow) #define KEY_TAB CARBON_K(kVK_Tab) #define KEY_LEFT_TAB CARBON_K(kVK_ISO_Left_Tab) #define KEY_DEL CARBON_K(kVK_ForwardDelete) #define KEY_END CARBON_K(kVK_End) #define KEY_HOME CARBON_K(kVK_Home) #define KEY_UP CARBON_K(kVK_UpArrow) #define KEY_DOWN CARBON_K(kVK_DownArrow) #define KEY_PAGEUP CARBON_K(kVK_PageUp) #define KEY_PAGEDOWN CARBON_K(kVK_PageDown) #endif uTox/src/native/clipboard.h0000600000175000001440000000014714003056216014665 0ustar rakusers#ifndef NATIVE_CLIPBOARD_H #define NATIVE_CLIPBOARD_H void copy(int value); void paste(void); #endif uTox/src/native/audio.h0000600000175000001440000000065014003056216014026 0ustar rakusers#ifndef NATIVE_AUDIO_H #define NATIVE_AUDIO_H #include #include // Audio void audio_detect(void); bool audio_init(void *handle); bool audio_close(void *handle); bool audio_frame(int16_t *buffer); #if defined __ANDROID__ void audio_play(int32_t call_index, const int16_t *data, int length, uint8_t channels); void audio_begin(int32_t call_index); void audio_end(int32_t call_index); #endif #endif uTox/src/native/android/0000700000175000001440000000000014003056216014171 5ustar rakusersuTox/src/native/android/keycodes.h0000600000175000001440000000047014003056216016153 0ustar rakusers#ifndef NATIVE_ANDROID_KEYCODES_H #define NATIVE_ANDROID_KEYCODES_H #define KEY_BACK 1 #define KEY_RETURN 2 #define KEY_LEFT 3 #define KEY_RIGHT 4 #define KEY_TAB 7 #define KEY_DEL 8 #define KEY_END 9 #define KEY_HOME 10 #define KEY_UP 5 #define KEY_DOWN 6 #define KEY_PAGEUP 11 #define KEY_PAGEDOWN 12 #endif uTox/src/native/android/image.h0000600000175000001440000000016314003056216015426 0ustar rakusers#ifndef NATIVE_ANDROID_IMAGE_H #define NATIVE_ANDROID_IMAGE_H #define NATIVE_IMAGE_IS_VALID(x) (0 != (x)) #endif uTox/src/messages.h0000600000175000001440000001212014003056216013241 0ustar rakusers#ifndef MESSAGES_H #define MESSAGES_H #include "ui/panel.h" #include #include #include extern pthread_mutex_t messages_lock; typedef struct native_image NATIVE_IMAGE; typedef enum UTOX_MSG_TYPE { MSG_TYPE_NULL, /* MSG_TEXT must start here */ MSG_TYPE_TEXT, MSG_TYPE_ACTION_TEXT, MSG_TYPE_NOTICE, MSG_TYPE_NOTICE_DAY_CHANGE, // Separated so I can localize this later! /* MSG_TEXT should end here */ // MSG_TYPE_OTHER, // Unused, expect to separate MSG_TEXT type MSG_TYPE_IMAGE, // MSG_TYPE_IMAGE_HISTORY, MSG_TYPE_FILE, // MSG_TYPE_FILE_HISTORY, // MSG_TYPE_CALL_ACTIVE, // MSG_TYPE_CALL_HISTORY, } UTOX_MSG_TYPE; typedef struct { char *author; uint16_t author_length; uint16_t length; char *msg; } MSG_TEXT; typedef struct { char *author; uint16_t author_length; uint16_t length; char *msg; uint32_t author_id; uint32_t author_color; } MSG_GROUP; typedef struct { uint32_t w, h; bool zoom; double position; NATIVE_IMAGE *image; } MSG_IMG; typedef struct msg_file { uint8_t file_status; uint32_t file_number; char *name; size_t name_length; // Location on disk uint8_t *path; size_t path_length; // In memory pointer uint8_t *data; size_t data_size; uint32_t speed; uint64_t size, progress; bool inline_png; } MSG_FILE; /* Generic Message type */ typedef struct msg_header { UTOX_MSG_TYPE msg_type; // true, if we're the author, false, if someone else. bool our_msg; uint32_t height; time_t time; uint64_t disk_offset; uint32_t receipt; time_t receipt_time; union { MSG_TEXT txt; MSG_TEXT action; MSG_TEXT notice; MSG_TEXT notice_day; MSG_GROUP grp; MSG_IMG img; MSG_FILE ft; } via; } MSG_HEADER; // Type for indexing into MSG_DATA->data array of messages typedef struct messages { PANEL panel; // false for Friendchat, true for Groupchat. bool is_groupchat; // Tox friendnumber/groupnumber uint32_t id; int height, width; // Position and length of an URL in the message under the mouse, // if present. cursor_over_uri == UINT16_MAX if there's none. uint32_t cursor_over_uri, urllen; // Was the url pressed by the mouse. uint32_t cursor_down_uri; uint32_t cursor_over_msg, cursor_over_position, cursor_down_msg, cursor_down_position; uint32_t sel_start_msg, sel_end_msg, sel_start_position, sel_end_position; // true if we're in the middle of selection operation // (mousedown without mouseup yet). bool selecting_text; bool cursor_over_time; // Number of messages in data array. uint32_t number; // Number of extra to speedup realloc. int8_t extra; // Pointers at various message structs, at most MAX_BACKLOG_MESSAGES. MSG_HEADER **data; // Field for preserving position of text scroll double scroll; } MESSAGES; uint32_t message_add_group(MESSAGES *m, MSG_HEADER *msg); uint32_t message_add_type_text(MESSAGES *m, bool auth, const char *msgtxt, uint16_t length, bool log, bool send); uint32_t message_add_type_action(MESSAGES *m, bool auth, const char *msgtxt, uint16_t length, bool log, bool send); uint32_t message_add_type_notice(MESSAGES *m, const char *msgtxt, uint16_t length, bool log); uint32_t message_add_type_image(MESSAGES *m, bool auth, NATIVE_IMAGE *img, uint16_t width, uint16_t height, bool log); MSG_HEADER *message_add_type_file(MESSAGES *m, uint32_t file_number, bool incoming, bool image, uint8_t status, const uint8_t *name, size_t name_size, size_t target_size, size_t current_size); // Returns true if data was logged. bool message_log_to_disk(MESSAGES *m, MSG_HEADER *msg); // Returns true if data was read from log. bool messages_read_from_log(uint32_t friend_number); void messages_send_from_queue(MESSAGES *m, uint32_t friend_number); void messages_clear_receipt(MESSAGES *m, uint32_t receipt_number); /** Formats all messages from self and friends, and then call draw functions * to write them to the UI. * * accepts: messages struct *pointer, int x,y positions, int width,height */ void messages_draw(PANEL *panel, int x, int y, int width, int height); bool messages_mmove(PANEL *panel, int px, int py, int width, int height, int mx, int my, int dx, int dy); bool messages_mdown(PANEL *panel); bool messages_dclick(PANEL *panel, bool triclick); bool messages_mright(PANEL *panel); bool messages_mwheel(PANEL *panel, int height, double d, bool smooth); // Always returns false. bool messages_mup(PANEL *panel); bool messages_mleave(PANEL *m); // Relay keypress to message panel. // Returns bool indicating whether a redraw is needed or not. bool messages_char(uint32_t ch); int messages_selection(PANEL *panel, char *buffer, uint32_t len, bool names); void messages_updateheight(MESSAGES *m, int width); void messages_init(MESSAGES *m, uint32_t friend_number); void message_free(MSG_HEADER *msg); void messages_clear_all(MESSAGES *m); #endif uTox/src/messages.c0000600000175000001440000017722414003056216013255 0ustar rakusers#include "messages.h" #include "chatlog.h" #include "file_transfers.h" #include "filesys.h" #include "flist.h" #include "friend.h" #include "groups.h" #include "debug.h" #include "macros.h" #include "self.h" #include "settings.h" #include "text.h" #include "theme.h" #include "tox.h" #include "utox.h" #include "ui/contextmenu.h" #include "ui/draw.h" #include "ui/scrollable.h" #include "ui/svg.h" #include "ui/text.h" #include "layout/friend.h" #include "layout/group.h" #include "native/clipboard.h" // TODO including native .h files should never be needed, refactor filesys.h to provide necessary API #include "native/filesys.h" #include "native/image.h" #include "native/keyboard.h" #include "native/os.h" #include #include #define UTOX_MAX_BACKLOG_MESSAGES 256 pthread_mutex_t messages_lock; /** Appends a messages from self or friend to the message list; * will realloc or trim messages as needed; * * also handles auto scrolling selections with messages * * accepts: MESSAGES *pointer, MESSAGE *pointer, MSG_DATA *pointer */ static int get_time_width() { return SCALE(settings.use_long_time_msg ? TIME_WIDTH_LONG : TIME_WIDTH); } static int msgheight(MSG_HEADER *msg, int width) { switch (msg->msg_type) { case MSG_TYPE_NULL: { LOG_ERR("Messages", "Invalid message type in msgheight."); return 0; } case MSG_TYPE_TEXT: case MSG_TYPE_ACTION_TEXT: case MSG_TYPE_NOTICE: case MSG_TYPE_NOTICE_DAY_CHANGE: { int theight = text_height(abs(width - SCALE(MESSAGES_X) - get_time_width()), font_small_lineheight, msg->via.txt.msg, msg->via.txt.length); return (theight == 0) ? 0 : theight + MESSAGES_SPACING; } case MSG_TYPE_IMAGE: { uint32_t maxwidth = width - SCALE(MESSAGES_X) - get_time_width(); if (msg->via.img.zoom || msg->via.img.w <= maxwidth) { return msg->via.img.h + MESSAGES_SPACING; } return msg->via.img.h * maxwidth / msg->via.img.w + MESSAGES_SPACING; } case MSG_TYPE_FILE: { return FILE_TRANSFER_BOX_HEIGHT + MESSAGES_SPACING; } } return 0; } static int msgheight_group(MSG_HEADER *msg, int width) { switch (msg->msg_type) { case MSG_TYPE_TEXT: case MSG_TYPE_ACTION_TEXT: case MSG_TYPE_NOTICE: case MSG_TYPE_NOTICE_DAY_CHANGE: { int theight = text_height(abs(width - SCALE(MESSAGES_X) - get_time_width()), font_small_lineheight, msg->via.grp.msg, msg->via.grp.length); return (theight == 0) ? 0 : theight + MESSAGES_SPACING; } default: { LOG_TRACE("Messages", "Error, can't set this group message height" ); } } return 0; } static int message_setheight(MESSAGES *m, MSG_HEADER *msg) { if (m->width == 0) { return 0; } setfont(FONT_TEXT); if (m->is_groupchat) { msg->height = msgheight_group(msg, m->width); } else { msg->height = msgheight(msg, m->width); } return msg->height; } static void message_updateheight(MESSAGES *m, MSG_HEADER *msg) { if (m->width == 0) { return; } setfont(FONT_TEXT); m->height -= msg->height; msg->height = message_setheight(m, msg); m->height += msg->height; } static uint32_t message_add(MESSAGES *m, MSG_HEADER *msg) { pthread_mutex_lock(&messages_lock); if (m->number < UTOX_MAX_BACKLOG_MESSAGES) { if (!m->data || m->extra <= 0) { if (m->data) { m->data = realloc(m->data, (m->number + 10) * sizeof(void *)); m->extra += 10; } else { m->number = 0; m->data = calloc(20, sizeof(void *)); m->extra = 20; } if (!m->data) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "\n\n\nFATAL ERROR TRYING TO REALLOC FOR MESSAGES.\nTHIS IS A BUG, PLEASE REPORT!\n\n\n"); } } m->data[m->number++] = msg; m->extra--; } else { m->height -= m->data[0]->height; message_free(m->data[0]); memmove(m->data, m->data + 1, (UTOX_MAX_BACKLOG_MESSAGES - 1) * sizeof(MSG_HEADER *)); m->data[UTOX_MAX_BACKLOG_MESSAGES - 1] = msg; // Scroll selection up so that it stays over the same messages. if (m->sel_start_msg != UINT32_MAX) { if (0 < m->sel_start_msg) { m->sel_start_msg--; } else { m->sel_start_position = 0; } } if (m->sel_end_msg != UINT32_MAX) { if (0 < m->sel_end_msg) { m->sel_end_msg--; } else { m->sel_end_position = 0; } } if (m->cursor_down_msg != UINT32_MAX) { if (0 < m->cursor_down_msg) { m->cursor_down_msg--; } else { m->cursor_down_position = 0; } } if (m->cursor_over_msg != UINT32_MAX) { if (0 < m->cursor_over_msg) { m->cursor_over_msg--; } else { m->cursor_over_position = 0; } } } message_updateheight(m, msg); if (m->is_groupchat) { const GROUPCHAT *groupchat = flist_get_sel_group(); if (groupchat && groupchat == get_group(m->id)) { m->panel.content_scroll->content_height = m->height; } } else { const FRIEND *friend = flist_get_sel_friend(); if (friend && friend == get_friend(m->id)) { m->panel.content_scroll->content_height = m->height; } } pthread_mutex_unlock(&messages_lock); return m->number; } static bool msg_add_day_notice(MESSAGES *m, time_t last, time_t next) { /* The tm struct is shared, we have to do it this way */ int ltime_year = 0, ltime_mon = 0, ltime_day = 0; struct tm *msg_time = localtime(&last); ltime_year = msg_time->tm_year; ltime_mon = msg_time->tm_mon; ltime_day = msg_time->tm_mday; msg_time = localtime(&next); if (ltime_year >= msg_time->tm_year && (ltime_year != msg_time->tm_year || ltime_mon >= msg_time->tm_mon) && (ltime_year != msg_time->tm_year || ltime_mon != msg_time->tm_mon || ltime_day >= msg_time->tm_mday)) { return false; } MSG_HEADER *msg = calloc(1, sizeof(MSG_HEADER)); if (!msg) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Couldn't allocate memory for day notice."); } time(&msg->time); msg->our_msg = 0; msg->msg_type = MSG_TYPE_NOTICE_DAY_CHANGE; msg->via.notice_day.msg = calloc(1, 256); if (!msg->via.notice_day.msg) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Couldn't allocate memory for day notice."); } msg->via.notice_day.length = strftime((char *)msg->via.notice_day.msg, 256, "Day has changed to %A %B %d %Y", msg_time); if (0 == msg->via.notice_day.length) { LOG_ERR("Messages", "Couldn't compose day notice message."); free(msg->via.notice_day.msg); free(msg); return false; } message_add(m, msg); return true; } /* TODO leaving this here is a little hacky, but it was the fastest way * without considering if I should expose messages_add */ uint32_t message_add_group(MESSAGES *m, MSG_HEADER *msg) { return message_add(m, msg); } /* TODO This function and message_add_type_action() are essentially pasta. */ uint32_t message_add_type_text(MESSAGES *m, bool auth, const char *msgtxt, uint16_t length, bool log, bool send) { FRIEND *f = get_friend(m->id); if (!f) { LOG_ERR("Messages", "Could not get friend with id: %u", m->id); return UINT32_MAX; } MSG_HEADER *msg = calloc(1, sizeof(MSG_HEADER)); if (!msg) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Could not allocate memory for a message."); } msg->via.txt.length = length; msg->via.txt.msg = calloc(1, length); if (!msg->via.txt.msg) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Could not allocate memory for message."); } memcpy(msg->via.txt.msg, msgtxt, length); time(&msg->time); msg->our_msg = auth; msg->msg_type = MSG_TYPE_TEXT; if (auth) { msg->via.txt.author_length = self.name_length; if (!send) { msg->receipt = 0; msg->receipt_time = 1; } } else { msg->via.txt.author_length = f->name_length; } if (m->data && m->number) { MSG_HEADER *day_msg = m->data[m->number ? m->number - 1 : 0]; msg_add_day_notice(m, day_msg->time, msg->time); } if (log) { message_log_to_disk(m, msg); } if (auth && send) { postmessage_toxcore(TOX_SEND_MESSAGE, m->id, length, msg); } return message_add(m, msg); } uint32_t message_add_type_action(MESSAGES *m, bool auth, const char *msgtxt, uint16_t length, bool log, bool send) { FRIEND *f = get_friend(m->id); if (!f) { LOG_ERR("Messages", "Could not get friend with number: %u", m->id); return UINT32_MAX; } MSG_HEADER *msg = calloc(1, sizeof(MSG_HEADER)); if (!msg) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Could not get the message header."); } msg->via.action.length = length; msg->via.action.msg = calloc(1, length); if (!msg->via.action.msg) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Could not allocate memory for message."); } memcpy(msg->via.action.msg, msgtxt, length); time(&msg->time); msg->our_msg = auth; msg->msg_type = MSG_TYPE_ACTION_TEXT; if (auth) { msg->via.txt.author_length = self.name_length; if (!send) { msg->receipt = 0; msg->receipt_time = 1; } } else { msg->via.txt.author_length = f->name_length; } if (log) { message_log_to_disk(m, msg); } if (auth && send) { postmessage_toxcore(TOX_SEND_ACTION, f->number, length, msg); } return message_add(m, msg); } uint32_t message_add_type_notice(MESSAGES *m, const char *msgtxt, uint16_t length, bool log) { MSG_HEADER *msg = calloc(1, sizeof(MSG_HEADER)); if (!msg) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Couldn't allocate memory for notice."); } msg->via.notice.length = length; msg->via.notice.msg = calloc(1, length); if (!msg->via.notice.msg) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Couldn't allocate memory for notice."); } memcpy(msg->via.notice.msg, msgtxt, length); time(&msg->time); msg->our_msg = 0; msg->msg_type = MSG_TYPE_NOTICE; msg->via.txt.author_length = self.name_length; msg->receipt_time = time(NULL); if (log) { message_log_to_disk(m, msg); } return message_add(m, msg); } uint32_t message_add_type_image(MESSAGES *m, bool auth, NATIVE_IMAGE *img, uint16_t width, uint16_t height, bool UNUSED(log)) { if (!NATIVE_IMAGE_IS_VALID(img)) { return 0; } MSG_HEADER *msg = calloc(1, sizeof(MSG_HEADER)); if (!msg) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Could not allocate memory for message header."); } time(&msg->time); msg->our_msg = auth; msg->msg_type = MSG_TYPE_IMAGE; msg->via.img.w = width; msg->via.img.h = height; msg->via.img.zoom = 0; msg->via.img.image = img; msg->via.img.position = 0.0; return message_add(m, msg); } /* TODO FIX THIS SECTION TO MATCH ABOVE! */ /* Called by new file transfer to add a new message to the msg list */ MSG_HEADER *message_add_type_file(MESSAGES *m, uint32_t file_number, bool incoming, bool image, uint8_t status, const uint8_t *name, size_t name_size, size_t target_size, size_t current_size) { MSG_HEADER *msg = calloc(1, sizeof(MSG_HEADER)); if (!msg) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Could not allocate memory for message header."); } time(&msg->time); msg->our_msg = !incoming; msg->msg_type = MSG_TYPE_FILE; msg->via.ft.file_status = status; msg->via.ft.file_number = file_number; msg->via.ft.size = target_size; msg->via.ft.progress = current_size; msg->via.ft.speed = 0; msg->via.ft.inline_png = image; msg->via.ft.name_length = name_size; msg->via.ft.name = calloc(1, name_size + 1); if (!msg->via.ft.name) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Could not allocate memory for the file name."); } memcpy(msg->via.ft.name, name, msg->via.ft.name_length); if (image) { msg->via.ft.path = NULL; } else { // It's a file msg->via.ft.path = calloc(1, UTOX_FILE_NAME_LENGTH); if (!msg->via.ft.path) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Could not allocate memory for the file path."); } } message_add(m, msg); return msg; } bool message_log_to_disk(MESSAGES *m, MSG_HEADER *msg) { if (m->is_groupchat) { /* We don't support logging groupchats yet */ return false; } if (!settings.logging_enabled) { return false; } FRIEND *f = get_friend(m->id); if (!f) { LOG_ERR("Messages", "Could not get friend with number: %u", m->id); return false; } if (f->skip_msg_logging) { return false; } LOG_FILE_MSG_HEADER header; memset(&header, 0, sizeof(header)); switch (msg->msg_type) { case MSG_TYPE_TEXT: case MSG_TYPE_ACTION_TEXT: case MSG_TYPE_NOTICE: { size_t author_length; char *author; if (msg->our_msg) { author_length = self.name_length; author = self.name; } else { author_length = f->name_length; author = f->name; } header.log_version = LOGFILE_SAVE_VERSION; header.time = msg->time; header.author_length = author_length; header.msg_length = msg->via.txt.length; header.author = msg->our_msg; header.receipt = !!msg->receipt_time; // bool only header.msg_type = msg->msg_type; size_t length = sizeof(header) + msg->via.txt.length + author_length + 1; /* extra \n char*/ uint8_t *data = calloc(1, length); if (!data) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Can't calloc for chat logging data. size:%lu", length); } memcpy(data, &header, sizeof(header)); memcpy(data + sizeof(header), author, author_length); memcpy(data + sizeof(header) + author_length, msg->via.txt.msg, msg->via.txt.length); strcpy2(data + length - 1, "\n"); msg->disk_offset = utox_save_chatlog(f->id_str, data, length); free(data); return true; } default: { LOG_NOTE("Messages", "uTox Logging:\tUnsupported message type %i", msg->msg_type); } } return false; } bool messages_read_from_log(uint32_t friend_number) { size_t actual_count = 0; FRIEND *f = get_friend(friend_number); if (!f) { LOG_ERR("Messages", "Could not get friend with number: %u", friend_number); return false; } MSG_HEADER **data = utox_load_chatlog(f->id_str, &actual_count, UTOX_MAX_BACKLOG_MESSAGES, 0); if (!data) { if (actual_count > 0) { LOG_ERR("Messages", "uTox Logging:\tFound chat log entries, but couldn't get any data. This is a problem."); } return false; } MSG_HEADER **p = data; MSG_HEADER *msg; time_t last = 0; while (actual_count--) { msg = *p++; if (!msg) { continue; } if (msg_add_day_notice(&f->msg, last, msg->time)) { last = msg->time; } message_add(&f->msg, msg); } free(data); return true; } void messages_send_from_queue(MESSAGES *m, uint32_t friend_number) { uint32_t start = m->number; uint8_t seek_num = 3; /* this magic number is the number of messages we'll skip looking for the first unsent */ pthread_mutex_lock(&messages_lock); int queue_count = 0; /* seek back to find first queued message * I hate this nest too, but it's readable */ while (start) { --start; if (++queue_count > 25) { break; } if (m->data[start]) { MSG_HEADER *msg = m->data[start]; if (msg->msg_type == MSG_TYPE_TEXT || msg->msg_type == MSG_TYPE_ACTION_TEXT) { if (msg->our_msg) { if (msg->receipt_time) { if (!seek_num--) { break; } } } } } } int sent_count = 0; /* start sending messages, hopefully in order */ while (start < m->number && sent_count <= 25) { if (m->data[start]) { MSG_HEADER *msg = m->data[start]; if (msg->msg_type == MSG_TYPE_TEXT || msg->msg_type == MSG_TYPE_ACTION_TEXT) { if (msg->our_msg && !msg->receipt_time) { postmessage_toxcore((msg->msg_type == MSG_TYPE_TEXT ? TOX_SEND_MESSAGE : TOX_SEND_ACTION), friend_number, msg->via.txt.length, msg); ++sent_count; } } } ++start; } pthread_mutex_unlock(&messages_lock); } void messages_clear_receipt(MESSAGES *m, uint32_t receipt_number) { pthread_mutex_lock(&messages_lock); uint32_t start = m->number; while (start--) { if (!m->data[start]) { continue; } MSG_HEADER *msg = m->data[start]; if (msg->msg_type != MSG_TYPE_TEXT && msg->msg_type != MSG_TYPE_ACTION_TEXT) { continue; } if (msg->receipt != receipt_number) { continue; } msg->receipt = -1; time(&msg->receipt_time); LOG_FILE_MSG_HEADER header; memset(&header, 0, sizeof(header)); header.log_version = LOGFILE_SAVE_VERSION; header.time = msg->time; header.author_length = msg->via.txt.author_length; header.msg_length = msg->via.txt.length; header.author = 1; header.receipt = 1; header.msg_type = msg->msg_type; size_t length = sizeof(header); uint8_t *data = calloc(1, length); if (!data) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Couldn't allocate memory for message."); } memcpy(data, &header, length); char *hex = get_friend(m->id)->id_str; if (msg->disk_offset) { LOG_TRACE("Messages", "Updating message -> disk_offset is %lu" , msg->disk_offset); utox_update_chatlog(hex, msg->disk_offset, data, length); } else if (msg->disk_offset == 0 && start <= 1 && receipt_number == 1) { /* This could get messy if receipt is 1, msg position is 0, and the offset is actually wrong, * But I couldn't come up with any other way to verify the rare case of a bad offset * start <= 1 to offset for the day change notification */ LOG_TRACE("Messages", "Updating first message -> disk_offset is %lu" , msg->disk_offset); utox_update_chatlog(hex, msg->disk_offset, data, length); } else { LOG_ERR("Messages", "Messages:\tUnable to update this message...\n" "\t\tmsg->disk_offset %lu && m->number %u receipt_number %u \n", msg->disk_offset, m->number, receipt_number); } free(data); postmessage_utox(FRIEND_MESSAGE_UPDATE, 0, 0, NULL); /* Used to redraw the screen */ pthread_mutex_unlock(&messages_lock); return; } LOG_ERR("Messages", "Received a receipt for a message we don't have a record of. %u", receipt_number); pthread_mutex_unlock(&messages_lock); } static void messages_draw_timestamp(int x, int y, const time_t *time) { struct tm *ltime = localtime(time); char timestr[9]; uint16_t len; if (settings.use_long_time_msg) { snprintf(timestr, sizeof(timestr), "%.2u:%.2u:%.2u", ltime->tm_hour, ltime->tm_min, ltime->tm_sec); x -= textwidth("24:60:00", sizeof "24:60:00" - 1); } else { snprintf(timestr, sizeof(timestr), "%u:%.2u", ltime->tm_hour, ltime->tm_min); x -= textwidth("24:60", sizeof "24:60" - 1); } len = strnlen(timestr, sizeof(timestr) - 1); setcolor(COLOR_MAIN_TEXT_SUBTEXT); setfont(FONT_MISC); drawtext(x - MESSAGES_SPACING, y, timestr, len); } static void messages_draw_author(int x, int y, int w, char *name, uint32_t length, uint32_t color) { setcolor(color); setfont(FONT_TEXT); drawtextwidth_right(x, w, y, name, length); } static int messages_draw_text(const char *msg, size_t length, uint32_t msg_height, uint8_t msg_type, bool author, bool receipt, uint16_t highlight_start, uint16_t highlight_end, int x, int y, int w, int UNUSED(h)) { switch (msg_type) { case MSG_TYPE_TEXT: { if (author) { if (receipt) { setcolor(COLOR_MSG_USER); } else { setcolor(COLOR_MSG_USER_PEND); } } else { setcolor(COLOR_MSG_CONTACT); } break; } case MSG_TYPE_NOTICE: case MSG_TYPE_NOTICE_DAY_CHANGE: case MSG_TYPE_ACTION_TEXT: { setcolor(COLOR_MAIN_TEXT_ACTION); break; } } setfont(FONT_TEXT); int ny = utox_draw_text_multiline_within_box(x, y, w + x, MAIN_TOP, y + msg_height, font_small_lineheight, msg, length, highlight_start, highlight_end, 0, 0, 1); if (ny < y || (uint32_t)(ny - y) + MESSAGES_SPACING != msg_height) { LOG_TRACE("Messages", "Text Draw Error:\ty %i | ny %i | mheight %u | width %i " , y, ny, msg_height, w); } return ny; } /* draws an inline image at rect (x,y,width,height) * maxwidth is maximum width the image can take in * zoom is whether the image is currently zoomed in * position is the y position along the image the player has scrolled */ static int messages_draw_image(MSG_IMG *img, int x, int y, uint32_t maxwidth) { image_set_filter(img->image, FILTER_BILINEAR); if (!img->zoom && img->w > maxwidth) { image_set_scale(img->image, (double)maxwidth / img->w); draw_image(img->image, x, y, maxwidth, img->h * maxwidth / img->w, 0, 0); image_set_scale(img->image, 1.0); } else if (img->w > maxwidth) { draw_image(img->image, x, y, maxwidth, img->h, (int)((double)(img->w - maxwidth) * img->position), 0); } else { draw_image(img->image, x, y, img->w, img->h, 0, 0); } return (img->zoom || img->w <= maxwidth) ? img->h : img->h * maxwidth / img->w; } /* Draw macros added, to reduce future line edits. */ #define DRAW_FT_RECT(color) draw_rect_fill(dx, y, d_width, FILE_TRANSFER_BOX_HEIGHT, color) #define DRAW_FT_PROG(color) draw_rect_fill(dx, y, prog_bar, FILE_TRANSFER_BOX_HEIGHT, color) #define DRAW_FT_CAP(bg, fg) \ do { \ drawalpha(BM_FT_CAP, dx - room_for_clip, y, BM_FT_CAP_WIDTH, BM_FTB_HEIGHT, bg); \ drawalpha(BM_FILE, dx - room_for_clip + SCALE(4), y + SCALE(4), BM_FILE_WIDTH, BM_FILE_HEIGHT, fg); \ } while (0) /* Always first */ #define DRAW_FT_NO_BTN() \ do { \ drawalpha(BM_FTB1, btnx, tbtn_bg_y, btn_bg_w, tbtn_bg_h, \ (mouse_left_btn ? COLOR_BTN_DANGER_BKGRND_HOVER : COLOR_BTN_SUCCESS_BKGRND)); \ drawalpha(BM_NO, btnx + ((btn_bg_w - btnw) / 2), tbtn_y, btnw, btnh, \ (mouse_left_btn ? COLOR_BTN_DANGER_TEXT_HOVER : COLOR_BTN_DANGER_TEXT)); \ } while (0) /* Always last */ #define DRAW_FT_YES_BTN() \ do { \ drawalpha(BM_FTB2, btnx + btn_bg_w + SCALE(2), tbtn_bg_y, btn_bg_w, tbtn_bg_h, \ (mouse_rght_btn ? COLOR_BTN_SUCCESS_BKGRND_HOVER : COLOR_BTN_SUCCESS_BKGRND)); \ drawalpha(BM_YES, btnx + btn_bg_w + SCALE(2) + ((btn_bg_w - btnw) / 2), tbtn_y, btnw, btnh, \ (mouse_rght_btn ? COLOR_BTN_SUCCESS_TEXT_HOVER : COLOR_BTN_SUCCESS_TEXT)); \ } while (0) #define DRAW_FT_PAUSE_BTN() \ do { \ drawalpha(BM_FTB2, btnx + btn_bg_w + SCALE(2), tbtn_bg_y, btn_bg_w, tbtn_bg_h, \ (mouse_rght_btn ? COLOR_BTN_SUCCESS_BKGRND_HOVER : COLOR_BTN_SUCCESS_BKGRND)); \ drawalpha(BM_PAUSE, btnx + btn_bg_w + SCALE(2) + ((btn_bg_w - btnw) / 2), tbtn_y, btnw, btnh, \ (mouse_rght_btn ? COLOR_BTN_SUCCESS_TEXT_HOVER : COLOR_BTN_SUCCESS_TEXT)); \ } while (0) #define DRAW_FT_RESUME_BTN() \ do { \ drawalpha(BM_FTB2, btnx + btn_bg_w + SCALE(2), tbtn_bg_y, btn_bg_w, tbtn_bg_h, \ (mouse_rght_btn ? COLOR_BTN_SUCCESS_BKGRND_HOVER : COLOR_BTN_SUCCESS_BKGRND)); \ drawalpha(BM_RESUME, btnx + btn_bg_w + SCALE(2) + ((btn_bg_w - btnw) / 2), tbtn_y, btnw, btnh, \ (mouse_rght_btn ? COLOR_BTN_SUCCESS_TEXT_HOVER : COLOR_BTN_SUCCESS_TEXT)); \ } while (0) #define DRAW_FT_TEXT_RIGHT(str, len) \ do { \ wbound -= (textwidth(str, len) + (SCALE(12))); \ drawtext(wbound, y + SCALE(8), str, len); \ } while (0) #define DRAW_FT_ALPH_RIGHT(bm, col) \ do { \ wbound -= btnw + (SCALE(12)); \ drawalpha(bm, wbound, tbtn_y, btnw, btnh, col); \ } while (0) #define DRAWSTR_FT_RIGHT(t) DRAW_FT_TEXT_RIGHT(S(t), SLEN(t)) static void messages_draw_filetransfer(MESSAGES *m, MSG_FILE *file, uint32_t i, int x, int y, int w, int UNUSED(h)) { // Used in macros. int room_for_clip = BM_FT_CAP_WIDTH + SCALE(2); int dx = x + SCALE(MESSAGES_X) + room_for_clip; int d_width = w - SCALE(MESSAGES_X) - get_time_width() - room_for_clip; /* Mouse Positions */ bool mo = (m->cursor_over_msg == i); bool mouse_over = (mo && m->cursor_over_position) ? 1 : 0; bool mouse_rght_btn = (mo && m->cursor_over_position == 2) ? 1 : 0; bool mouse_left_btn = (mo && m->cursor_over_position == 1) ? 1 : 0; /* Button Background */ int btn_bg_w = BM_FTB_WIDTH; /* Button Background heights */ int tbtn_bg_y = y; int tbtn_bg_h = BM_FTB_HEIGHT; /* Top button info */ int btnx = dx + d_width - (btn_bg_w * 2) - SCALE(2); int tbtn_y = y + SCALE(8); int btnw = BM_FB_WIDTH; int btnh = BM_FB_HEIGHT; long double file_percent = (double)file->progress / (double)file->size; if (file->progress > file->size) { file->progress = file->size; file_percent = 1.0; } char ft_text[file->name_length + 128]; size_t ft_text_length; snprintf(ft_text, sizeof(ft_text), "%.*s ", (int)file->name_length, file->name); ft_text_length = strnlen(ft_text, sizeof(ft_text) - 1); ft_text_length += sprint_humanread_bytes(ft_text + ft_text_length, sizeof(ft_text) - ft_text_length, file->size); setfont(FONT_MISC); setcolor(COLOR_BKGRND_MAIN); int wbound = dx + d_width - SCALE(6); switch (file->file_status) { case FILE_TRANSFER_STATUS_NONE: case FILE_TRANSFER_STATUS_ACTIVE: case FILE_TRANSFER_STATUS_PAUSED_US: case FILE_TRANSFER_STATUS_PAUSED_BOTH: case FILE_TRANSFER_STATUS_PAUSED_THEM: { int ftb_allowance = (BM_FTB_WIDTH * 2) + (SCALE(4)); d_width -= ftb_allowance; wbound -= ftb_allowance; break; } default: { // we'll round the corner even without buttons. d_width -= btn_bg_w; break; } } // progress rectangle uint32_t prog_bar = (file->size == 0) ? 0 : ((long double)d_width * file_percent); switch (file->file_status) { case FILE_TRANSFER_STATUS_COMPLETED: { /* If mouse over use hover color */ uint32_t text = mouse_over ? COLOR_BTN_SUCCESS_TEXT_HOVER : COLOR_BTN_SUCCESS_TEXT, background = mouse_over ? COLOR_BTN_SUCCESS_BKGRND_HOVER : COLOR_BTN_SUCCESS_BKGRND; setcolor(text); DRAW_FT_CAP(background, text); DRAW_FT_RECT(background); drawalpha(BM_FTB2, dx + d_width, tbtn_bg_y, btn_bg_w, tbtn_bg_h, background); if (file->inline_png) { DRAWSTR_FT_RIGHT(CLICKTOSAVE); } else { DRAWSTR_FT_RIGHT(CLICKTOOPEN); } DRAW_FT_ALPH_RIGHT(BM_YES, text); break; } case FILE_TRANSFER_STATUS_KILLED: { setcolor(COLOR_BTN_DANGER_TEXT); DRAW_FT_CAP(COLOR_BTN_DANGER_BACKGROUND, COLOR_BTN_DANGER_TEXT); DRAW_FT_RECT(COLOR_BTN_DANGER_BACKGROUND); drawalpha(BM_FTB2, dx + d_width, tbtn_bg_y, btn_bg_w, tbtn_bg_h, COLOR_BTN_DANGER_BACKGROUND); DRAWSTR_FT_RIGHT(TRANSFER_CANCELLED); DRAW_FT_ALPH_RIGHT(BM_NO, COLOR_BTN_DANGER_TEXT); break; } case FILE_TRANSFER_STATUS_BROKEN: { setcolor(COLOR_BTN_DANGER_TEXT); DRAW_FT_CAP(COLOR_BTN_DANGER_BACKGROUND, COLOR_BTN_DANGER_TEXT); DRAW_FT_RECT(COLOR_BTN_DANGER_BACKGROUND); drawalpha(BM_FTB2, dx + d_width, tbtn_bg_y, btn_bg_w, tbtn_bg_h, COLOR_BTN_DANGER_BACKGROUND); DRAWSTR_FT_RIGHT(TRANSFER_BROKEN); DRAW_FT_ALPH_RIGHT(BM_NO, COLOR_BTN_DANGER_TEXT); break; } case FILE_TRANSFER_STATUS_NONE: { /* ↑ used for incoming transfers */ setcolor(COLOR_BTN_DISABLED_TRANSFER); DRAW_FT_CAP(COLOR_BTN_DISABLED_BKGRND, COLOR_BTN_DISABLED_TRANSFER); DRAW_FT_RECT(COLOR_BTN_DISABLED_BKGRND); DRAW_FT_NO_BTN(); DRAW_FT_YES_BTN(); DRAW_FT_PROG(COLOR_BTN_DISABLED_FORGRND); break; } case FILE_TRANSFER_STATUS_ACTIVE: { setcolor(COLOR_BTN_INPROGRESS_TEXT); DRAW_FT_CAP(COLOR_BTN_INPROGRESS_BKGRND, COLOR_BTN_INPROGRESS_TEXT); DRAW_FT_RECT(COLOR_BTN_INPROGRESS_BKGRND); DRAW_FT_NO_BTN(); DRAW_FT_PAUSE_BTN(); char speed[32] = {0}; size_t speed_len; speed_len = sprint_humanread_bytes(speed, sizeof(speed), file->speed); snprintf(speed + speed_len, sizeof(speed) - speed_len, "/s %lus", file->speed ? (file->size - file->progress) / file->speed : 0); speed_len = strnlen(speed, sizeof(speed) - 1); DRAW_FT_TEXT_RIGHT(speed, speed_len); DRAW_FT_PROG(COLOR_BTN_INPROGRESS_FORGRND); break; } case FILE_TRANSFER_STATUS_PAUSED_US: case FILE_TRANSFER_STATUS_PAUSED_BOTH: case FILE_TRANSFER_STATUS_PAUSED_THEM: { setcolor(COLOR_BTN_DISABLED_TRANSFER); DRAW_FT_CAP(COLOR_BTN_DISABLED_BKGRND, COLOR_BTN_DISABLED_TRANSFER); DRAW_FT_RECT(COLOR_BTN_DISABLED_BKGRND); DRAW_FT_NO_BTN(); if (file->file_status == FILE_TRANSFER_STATUS_PAUSED_BOTH || file->file_status == FILE_TRANSFER_STATUS_PAUSED_US) { /* Paused by at least us */ DRAW_FT_RESUME_BTN(); } else { /* Paused only by them */ DRAW_FT_PAUSE_BTN(); } DRAW_FT_PROG(COLOR_BTN_DISABLED_FORGRND); break; } } setfont(FONT_TEXT); drawtextrange(dx + SCALE(10), wbound - SCALE(10), y + SCALE(6), ft_text, ft_text_length); } /* This is a bit hacky, and likely would benefit from being moved to a whole new section including separating * group messages/functions from friend messages and functions from inside ui.c. * * Ideally group and friend messages wouldn't even need to know about each other. */ static int messages_draw_group(MESSAGES *m, MSG_HEADER *msg, uint32_t curr_msg_i, int x, int y, int width, int height) { uint32_t h1 = UINT32_MAX, h2 = UINT32_MAX; if ((m->sel_start_msg > curr_msg_i && m->sel_end_msg > curr_msg_i) || (m->sel_start_msg < curr_msg_i && m->sel_end_msg < curr_msg_i)) { /* Out side the highlight area */ h1 = UINT32_MAX; h2 = UINT32_MAX; } else { if (m->sel_start_msg < curr_msg_i) { h1 = 0; } else { h1 = m->sel_start_position; } if (m->sel_end_msg > curr_msg_i) { h2 = msg->via.grp.length; } else { h2 = m->sel_end_position; } } /* error check */ if ((m->sel_start_msg == m->sel_end_msg && m->sel_start_position == m->sel_end_position) || h1 == h2) { h1 = UINT32_MAX; h2 = UINT32_MAX; } messages_draw_author(x, y, SCALE(MESSAGES_X - NAME_OFFSET), msg->via.grp.author, msg->via.grp.author_length, msg->via.grp.author_color); messages_draw_timestamp(x + width, y, &msg->time); return messages_draw_text(msg->via.grp.msg, msg->via.grp.length, msg->height, msg->msg_type, msg->our_msg, 1, h1, h2, x + SCALE(MESSAGES_X), y, width - get_time_width() - SCALE(MESSAGES_X), height) + MESSAGES_SPACING; } static int messages_time_change(MESSAGES *m, MSG_HEADER *msg, size_t index, int x, int y, int width, int height) { uint32_t h1 = UINT32_MAX, h2 = UINT32_MAX; if ((m->sel_start_msg > index && m->sel_end_msg > index) || (m->sel_start_msg < index && m->sel_end_msg < index)) { /* Out side the highlight area */ h1 = UINT32_MAX; h2 = UINT32_MAX; } else { if (m->sel_start_msg < index) { h1 = 0; } else { h1 = m->sel_start_position; } if (m->sel_end_msg > index) { h2 = msg->via.notice.length; } else { h2 = m->sel_end_position; } } /* error check */ if ((m->sel_start_msg == m->sel_end_msg && m->sel_start_position == m->sel_end_position) || h1 == h2) { h1 = UINT32_MAX; h2 = UINT32_MAX; } /* text.c is super broken, so we have to be hacky here */ if (h2 != msg->via.notice.length) { if (m->sel_end_msg != index) { h2 = msg->via.notice.length - h2; } else { h2 -= h1; } } return messages_draw_text(msg->via.notice.msg, msg->via.notice.length, msg->height, msg->msg_type, msg->our_msg, msg->receipt_time, h1, h2, x + SCALE(MESSAGES_X), y, width - get_time_width() - SCALE(MESSAGES_X), height); } /** Formats all messages from self and friends, and then call draw functions * to write them to the UI. * * accepts: messages struct *pointer, int x,y positions, int width,height */ void messages_draw(PANEL *panel, int x, int y, int width, int height) { if (width - SCALE(MESSAGES_X) - get_time_width() <= 0) { return; } pthread_mutex_lock(&messages_lock); MESSAGES *m = panel->object; // Do not draw author name next to every message uint8_t lastauthor = 0xFF; // Message iterator MSG_HEADER **p = m->data; uint32_t n = m->number; if (m->width != width) { m->width = width; messages_updateheight(m, width - SCALE(MESSAGES_X) + get_time_width()); y -= scroll_gety(panel->content_scroll, height); } // Go through messages for (size_t curr_msg_i = 0; curr_msg_i != n; curr_msg_i++) { MSG_HEADER *msg = *p++; /* Decide if we should even bother drawing this message. */ if (msg->height == 0) { /* Empty message */ pthread_mutex_unlock(&messages_lock); return; } else if (y + msg->height <= (unsigned)SCALE(MAIN_TOP)) { /* message is exclusively above the viewing window */ y += msg->height; continue; } else if (y >= height + SCALE(100)) { // NOTE: should not be constant 100 /* Message is exclusively below the viewing window */ break; } // Draw the names for groups or friends if (m->is_groupchat) { y = messages_draw_group(m, msg, curr_msg_i, x, y, width, height); continue; } else { bool draw_author = true; switch (msg->msg_type) { case MSG_TYPE_NULL: { // This shouldn't happen. LOG_ERR("Messages", "Invalid message type in messages_draw."); break; } case MSG_TYPE_ACTION_TEXT: { // Always draw name next to action message lastauthor = ~0; break; } case MSG_TYPE_TEXT: case MSG_TYPE_IMAGE: case MSG_TYPE_FILE: { draw_author = true; break; } case MSG_TYPE_NOTICE: case MSG_TYPE_NOTICE_DAY_CHANGE: { draw_author = false; break; } } if (draw_author) { if (msg->our_msg != lastauthor || y < SCALE(MAIN_TOP) + font_small_lineheight) { int msg_y = y; // If previous author label is invisible (i.e. above top side of the messages window) // than clear its old place by drawing a rectangle with background colour. // After that we are able to draw a new author label at the same place. if (y < SCALE(MAIN_TOP) + font_small_lineheight) { msg_y = SCALE(MAIN_TOP); // MAIN_TOP + 1 because otherwise it cuts off one pixel from TOP FRAME somehow draw_rect_fill(x, SCALE(MAIN_TOP) + 1, SCALE(MESSAGES_X), font_small_lineheight, COLOR_BKGRND_MAIN); } FRIEND *f = get_friend(m->id); if (msg->our_msg) { messages_draw_author(x, msg_y, SCALE(MESSAGES_X - NAME_OFFSET), self.name, self.name_length, COLOR_MAIN_TEXT_SUBTEXT); } else if (f->alias) { messages_draw_author(x, msg_y, SCALE(MESSAGES_X - NAME_OFFSET), f->alias, f->alias_length, COLOR_MAIN_TEXT_CHAT); } else { messages_draw_author(x, msg_y, SCALE(MESSAGES_X - NAME_OFFSET), f->name, f->name_length, COLOR_MAIN_TEXT_CHAT); } lastauthor = msg->our_msg; } } } // Draw message contents switch (msg->msg_type) { case MSG_TYPE_NULL: { LOG_ERR("Messages", "Error msg type is null"); break; } case MSG_TYPE_TEXT: case MSG_TYPE_ACTION_TEXT: case MSG_TYPE_NOTICE: { // Draw timestamps messages_draw_timestamp(x + width, y, &msg->time); y = messages_time_change(m, msg, curr_msg_i, x, y, width, height); break; } case MSG_TYPE_NOTICE_DAY_CHANGE: { y = messages_time_change(m, msg, curr_msg_i, x, y, width, height); break; } // Draw image case MSG_TYPE_IMAGE: { y += messages_draw_image(&msg->via.img, x + SCALE(MESSAGES_X), y, width - SCALE(MESSAGES_X) - get_time_width()); break; } // Draw file transfer case MSG_TYPE_FILE: { messages_draw_filetransfer(m, &msg->via.ft, curr_msg_i, x, y, width, height); y += FILE_TRANSFER_BOX_HEIGHT; break; } } y += MESSAGES_SPACING; } pthread_mutex_unlock(&messages_lock); } static bool messages_mmove_text(MESSAGES *m, int width, int mx, int my, int dy, char *message, uint32_t msg_height, uint16_t msg_length) { if (mx < width - get_time_width()) { cursor = CURSOR_TEXT; } m->cursor_over_position = hittextmultiline(mx - SCALE(MESSAGES_X), width - SCALE(MESSAGES_X) - get_time_width(), (my < 0 ? 0 : my), msg_height, font_small_lineheight, message, msg_length, 1); if (my < 0 || my >= dy || mx < SCALE(MESSAGES_X) || m->cursor_over_position == msg_length) { m->cursor_over_uri = UINT32_MAX; return 0; } bool prev_cursor_down_uri = m->cursor_down_uri; if (m->cursor_over_uri != UINT32_MAX) { m->cursor_down_uri = 0; m->cursor_over_uri = UINT32_MAX; } /* Seek back to the last word/line break */ char *str = message + m->cursor_over_position; while (str != message) { str--; if (*str == ' ' || *str == '\n') { str++; break; } } /* Check if it's a URI we handle TODO: handle moar! */ char *end = message + msg_length; while (str != end && *str != ' ' && *str != '\n') { if (str == message || *(str - 1) == '\n' || *(str - 1) == ' ') { if (m->cursor_over_uri == UINT32_MAX && end - str >= 7 && (strncmp(str, "http://", 7) == 0)) { cursor = CURSOR_HAND; m->cursor_over_uri = str - message; } else if (m->cursor_over_uri == UINT32_MAX && end - str >= 8 && (strncmp(str, "https://", 8) == 0)) { cursor = CURSOR_HAND; m->cursor_over_uri = str - message; } else if (m->cursor_over_uri == UINT32_MAX && end - str >= 4 && (strncmp(str, "tox:", 4) == 0)) { cursor = CURSOR_HAND; m->cursor_over_uri = str - message; } } str++; } if (m->cursor_over_uri != UINT32_MAX) { m->urllen = (str - message) - m->cursor_over_uri; m->cursor_down_uri = prev_cursor_down_uri; LOG_TRACE("Messages", "urllen %u" , m->urllen); } return 0; } static bool messages_mmove_image(MSG_IMG *image, uint32_t max_width, int mx, int my) { if (image->w > max_width) { mx -= SCALE(MESSAGES_X); int w = image->w > max_width ? max_width : image->w; int h = (image->zoom || image->w <= max_width) ? image->h : image->h * max_width / image->w; if (mx >= 0 && my >= 0 && mx < w && my < h) { cursor = CURSOR_ZOOM_IN + image->zoom; return 1; } } return 0; } static uint8_t messages_mmove_filetransfer(int mx, int my, int width) { mx -= SCALE(10); /* Why? */ if (mx >= 0 && mx < width && my >= 0 && my < FILE_TRANSFER_BOX_HEIGHT) { if (mx >= width - get_time_width() - (BM_FTB_WIDTH * 2) - SCALE(2) - SCROLL_WIDTH && mx <= width - get_time_width() - SCROLL_WIDTH) { if (mx >= width - get_time_width() - BM_FTB_WIDTH - SCROLL_WIDTH) { // mouse is over the right button (pause / accept) return 2; } else { // mouse is over the left button (cancel) return 1; } } return 3; } return 0; } bool messages_mmove(PANEL *panel, int UNUSED(px), int UNUSED(py), int width, int UNUSED(height), int mx, int my, int dx, int UNUSED(dy)) { MESSAGES *m = panel->object; m->cursor_over_time = inrect(mx, my, width - get_time_width(), 0, get_time_width(), m->height); if (m->cursor_down_msg < m->number) { uint32_t maxwidth = width - SCALE(MESSAGES_X) - get_time_width(); MSG_HEADER *msg = m->data[m->cursor_down_msg]; if ((msg->msg_type == MSG_TYPE_IMAGE) && (msg->via.img.w > maxwidth)) { msg->via.img.position -= (double)dx / (double)(msg->via.img.w - maxwidth); if (msg->via.img.position > 1.0) { msg->via.img.position = 1.0; } else if (msg->via.img.position < 0.0) { msg->via.img.position = 0.0; } cursor = CURSOR_ZOOM_OUT; return true; } } if (mx < 0 || my < 0 || my > m->height) { if (m->cursor_over_msg != UINT32_MAX) { m->cursor_over_msg = UINT32_MAX; return true; } return false; } setfont(FONT_TEXT); MSG_HEADER **p = m->data; uint32_t i = 0; bool need_redraw = false; while (i < m->number) { MSG_HEADER *msg = *p++; int dy = msg->height; /* dy is the wrong name here, you should change it! */ if (my >= 0 && my < dy) { m->cursor_over_msg = i; switch (msg->msg_type) { case MSG_TYPE_NULL: { LOG_ERR("Messages", "Invalid message type in messages_mmove."); return false; } case MSG_TYPE_TEXT: case MSG_TYPE_ACTION_TEXT: case MSG_TYPE_NOTICE: case MSG_TYPE_NOTICE_DAY_CHANGE: { if (m->is_groupchat) { messages_mmove_text(m, width, mx, my, dy, msg->via.grp.msg, msg->height, msg->via.grp.length); } else { messages_mmove_text(m, width, mx, my, dy, msg->via.txt.msg, msg->height, msg->via.txt.length); } if (m->cursor_down_msg != UINT32_MAX && (m->cursor_down_position != m->cursor_over_position || m->cursor_down_msg != m->cursor_over_msg)) { m->selecting_text = 1; } break; } case MSG_TYPE_IMAGE: { m->cursor_over_position = messages_mmove_image(&msg->via.img, (width - SCALE(MESSAGES_X) - get_time_width()), mx, my); break; } case MSG_TYPE_FILE: { m->cursor_over_position = messages_mmove_filetransfer(mx, my, width); if (m->cursor_over_position) { need_redraw = true; } break; } } if (i != m->cursor_over_msg && m->cursor_over_msg != UINT32_MAX && (msg->msg_type == MSG_TYPE_FILE || m->data[m->cursor_over_msg]->msg_type == MSG_TYPE_FILE)) { need_redraw = true; // Redraw file on hover-in/out. } if (m->selecting_text) { need_redraw = true; if (m->cursor_down_msg != m->cursor_over_msg || m->cursor_down_position <= m->cursor_over_position) { m->sel_start_position = m->cursor_down_position; m->sel_end_position = m->cursor_over_position; } else { m->sel_start_position = m->cursor_over_position; m->sel_end_position = m->cursor_down_position; } if (m->cursor_down_msg <= m->cursor_over_msg) { m->sel_start_msg = m->cursor_down_msg; m->sel_end_msg = m->cursor_over_msg; } else { m->sel_start_msg = m->cursor_over_msg; m->sel_end_msg = m->cursor_down_msg; m->sel_start_position = m->cursor_over_position; m->sel_end_position = m->cursor_down_position; } } return need_redraw; } my -= dy; i++; } return false; } bool messages_mdown(PANEL *panel) { MESSAGES *m = panel->object; m->cursor_down_msg = UINT32_MAX; if (m->cursor_over_msg != UINT32_MAX) { MSG_HEADER *msg = m->data[m->cursor_over_msg]; switch (msg->msg_type) { case MSG_TYPE_NULL: { LOG_ERR("Messages", "Invalid message type in messages_mdown."); return false; } case MSG_TYPE_TEXT: case MSG_TYPE_ACTION_TEXT: case MSG_TYPE_NOTICE: case MSG_TYPE_NOTICE_DAY_CHANGE: { if (m->cursor_over_uri != UINT32_MAX) { m->cursor_down_uri = m->cursor_over_uri; LOG_TRACE("Messages", "mdn dURI %u, oURI %u" , m->cursor_down_uri, m->cursor_over_uri); } m->sel_start_msg = m->sel_end_msg = m->cursor_down_msg = m->cursor_over_msg; m->sel_start_position = m->sel_end_position = m->cursor_down_position = m->cursor_over_position; break; } case MSG_TYPE_IMAGE: { if (m->cursor_over_position) { if (!msg->via.img.zoom) { msg->via.img.zoom = 1; message_updateheight(m, msg); } else { m->cursor_down_msg = m->cursor_over_msg; } } break; } case MSG_TYPE_FILE: { if (m->cursor_over_position == 0) { break; } FRIEND *f = get_friend(m->id); FILE_TRANSFER *ft; uint32_t ft_number = msg->via.ft.file_number; if (ft_number >= (1 << 16)) { ft = &f->ft_incoming[(ft_number >> 16) - 1]; // TODO, abstraction needed } else { ft = &f->ft_outgoing[ft_number]; // TODO, abstraction needed } if (msg->via.ft.file_status == FILE_TRANSFER_STATUS_COMPLETED) { if (m->cursor_over_position) { if (msg->via.ft.inline_png) { file_save_inline_image_png(msg); } else { openurl((char *)msg->via.ft.path); } } return true; } if (m->cursor_over_position == 2) { // Right button, should be accept/pause/resume if (!msg->our_msg && msg->via.ft.file_status == FILE_TRANSFER_STATUS_NONE) { native_select_dir_ft(m->id, msg->via.ft.file_number, ft); return true; } if (msg->via.ft.file_status == FILE_TRANSFER_STATUS_ACTIVE) { postmessage_toxcore(TOX_FILE_PAUSE, m->id, msg->via.ft.file_number, ft); } else { postmessage_toxcore(TOX_FILE_RESUME, m->id, msg->via.ft.file_number, ft); } } else if (m->cursor_over_position == 1) { // Should be cancel postmessage_toxcore(TOX_FILE_CANCEL, m->id, msg->via.ft.file_number, ft); } return true; } } return true; } else if (m->sel_start_msg != m->sel_end_msg || m->sel_start_position != m->sel_end_position) { m->sel_start_msg = 0; m->sel_end_msg = 0; m->sel_start_position = 0; m->sel_end_position = 0; return true; } return false; } bool messages_dclick(PANEL *panel, bool triclick) { MESSAGES *m = panel->object; if (m->cursor_over_time) { settings.use_long_time_msg = !settings.use_long_time_msg; return true; } if (m->cursor_over_msg == UINT32_MAX) { return false; } MSG_HEADER *msg = m->data[m->cursor_over_msg]; switch (msg->msg_type) { case MSG_TYPE_NULL: { LOG_ERR("Messages", "Invalid message type in messages_dclick."); return false; } case MSG_TYPE_FILE: case MSG_TYPE_NOTICE: case MSG_TYPE_NOTICE_DAY_CHANGE: { return false; } case MSG_TYPE_TEXT: case MSG_TYPE_ACTION_TEXT: { m->sel_start_msg = m->sel_end_msg = m->cursor_over_msg; uint16_t i = m->cursor_over_position; while (i != 0 && msg->via.txt.msg[i - 1] != '\n' /* If it's a dclick, also set ' ' as boundary, else do nothing. */ && (!triclick ? (msg->via.txt.msg[i - 1] != ' ') : 1)) { i -= utf8_unlen(msg->via.txt.msg + i); } m->sel_start_position = i; i = m->cursor_over_position; while (i != msg->via.txt.length && msg->via.txt.msg[i] != '\n' /* If it's a dclick, also set ' ' as boundary, else do nothing. */ && (!triclick ? (msg->via.txt.msg[i] != ' ') : 1)) { i += utf8_len(msg->via.txt.msg + i); } m->sel_end_position = i; uint32_t diff = m->sel_end_position - m->sel_start_position; setselection(msg->via.txt.msg + m->sel_start_position, diff); return true; } case MSG_TYPE_IMAGE: { if (m->cursor_over_position) { if (msg->via.img.zoom) { msg->via.img.zoom = 0; message_updateheight(m, msg); } } return true; } } return false; } static void contextmenu_messages_onselect(uint8_t i) { copy(!!i); /* if not 0 force a 1 */ } bool messages_mright(PANEL *panel) { const MESSAGES *m = panel->object; if (m->cursor_over_msg == UINT32_MAX) { return false; } const MSG_HEADER *msg = m->data[m->cursor_over_msg]; switch (msg->msg_type) { case MSG_TYPE_NULL: { LOG_ERR("Messages", "Invalid message type in messages_mdown."); return false; } case MSG_TYPE_TEXT: case MSG_TYPE_ACTION_TEXT: { static UTOX_I18N_STR menu_copy[] = { STR_COPY, STR_COPY_WITH_NAMES }; contextmenu_new(COUNTOF(menu_copy), menu_copy, contextmenu_messages_onselect); return true; } case MSG_TYPE_NOTICE: case MSG_TYPE_NOTICE_DAY_CHANGE: case MSG_TYPE_IMAGE: case MSG_TYPE_FILE: { return false; } } LOG_FATAL_ERR(EXIT_FAILURE, "Messages", "Congratulations, you've reached dead code. Please report this."); } bool messages_mwheel(PANEL *UNUSED(panel), int UNUSED(height), double UNUSED(d), bool UNUSED(smooth)) { return false; } bool messages_mup(PANEL *panel) { MESSAGES *m = panel->object; if (!m->data) { return false; } if (m->cursor_over_msg != UINT32_MAX) { MSG_HEADER *msg = m->data[m->cursor_over_msg]; if (msg->msg_type == MSG_TYPE_TEXT) { if (m->cursor_over_uri != UINT32_MAX && m->cursor_down_uri == m->cursor_over_uri && m->cursor_over_position >= m->cursor_over_uri && m->cursor_over_position <= m->cursor_over_uri + m->urllen - 1 /* - 1 Don't open on white space */ && !m->selecting_text) { LOG_TRACE("Messages", "mup dURI %u, oURI %u" , m->cursor_down_uri, m->cursor_over_uri); char url[m->urllen + 1]; memcpy(url, msg->via.txt.msg + m->cursor_over_uri, m->urllen * sizeof(char)); url[m->urllen] = 0; openurl(url); m->cursor_down_uri = 0; } } } if (m->selecting_text) { const uint32_t max_selection_size = UINT16_MAX + 1; char *sel = calloc(1, max_selection_size); if (!sel) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "Couldn't allocate memory for selection."); } setselection(sel, messages_selection(panel, sel, max_selection_size, 0)); free(sel); m->selecting_text = 0; } m->cursor_down_msg = UINT32_MAX; return false; } bool messages_mleave(PANEL *UNUSED(m)) { return false; } int messages_selection(PANEL *panel, char *buffer, uint32_t len, bool names) { MESSAGES *m = panel->object; if (m->number == 0) { return 0; } uint32_t i = m->sel_start_msg, n = m->sel_end_msg + 1; MSG_HEADER **dp = &m->data[i]; char *p = buffer; while (i != UINT32_MAX && i != n) { const MSG_HEADER *msg = *dp++; if (names && (i != m->sel_start_msg || m->sel_start_position == 0)) { if (m->is_groupchat) { memcpy(p, msg->via.grp.author, msg->via.grp.author_length); p += msg->via.grp.author_length; len -= msg->via.grp.author_length; } else { const FRIEND *f = get_friend(m->id); if (!msg->our_msg) { if (len <= f->name_length) { break; } memcpy(p, f->name, f->name_length); p += f->name_length; len -= f->name_length; } else { if (len <= self.name_length) { break; } memcpy(p, self.name, self.name_length); p += self.name_length; len -= self.name_length; } } if (len <= 2) { break; } strcpy2(p, ": "); p += 2; len -= 2; } switch (msg->msg_type) { case MSG_TYPE_NULL: { LOG_ERR("Messages", "Invalid message type in messages_selection."); return 0; } case MSG_TYPE_TEXT: case MSG_TYPE_ACTION_TEXT: { char *data; uint16_t length; if (i == m->sel_start_msg) { if (i == m->sel_end_msg) { data = msg->via.txt.msg + m->sel_start_position; length = m->sel_end_position - m->sel_start_position; } else { data = msg->via.txt.msg + m->sel_start_position; length = msg->via.txt.length - m->sel_start_position; } } else if (i == m->sel_end_msg) { data = msg->via.txt.msg; length = m->sel_end_position; } else { data = msg->via.txt.msg; length = msg->via.txt.length; } if (len <= length) { *p = 0; return p - buffer; } memcpy(p, data, length); p += length; len -= length; break; } case MSG_TYPE_IMAGE: case MSG_TYPE_FILE: case MSG_TYPE_NOTICE: case MSG_TYPE_NOTICE_DAY_CHANGE: { // Do nothing. break; } } i++; if (i != n) { #ifdef __WIN32__ if (len <= 2) { break; } *p++ = '\r'; *p++ = '\n'; len -= 2; #else if (len <= 1) { break; } *p++ = '\n'; len--; #endif } } return p - buffer; } void messages_updateheight(MESSAGES *m, int width) { if (!m->data || !width) { return; } setfont(FONT_TEXT); uint32_t height = 0; for (uint32_t i = 0; i < m->number; ++i) { height += message_setheight(m, (void *)m->data[i]); } m->panel.content_scroll->content_height = m->height = height; } bool messages_char(uint32_t ch) { MESSAGES *m; if (flist_get_sel_friend()) { m = messages_friend.object; } else if (flist_get_sel_group()) { m = messages_group.object; } else { LOG_TRACE("Messages", "Can't type to nowhere"); return false; } switch (ch) { // TODO: probably need to fix this section :< m->panel.content scroll is likely to be wrong. case KEY_PAGEUP: { SCROLLABLE *scroll = m->panel.content_scroll; scroll->d -= 0.25; // TODO: Change to a full chat-screen height. if (scroll->d < 0.0) { scroll->d = 0.0; } return true; } case KEY_PAGEDOWN: { SCROLLABLE *scroll = m->panel.content_scroll; scroll->d += 0.25; // TODO: Change to a full chat-screen height. if (scroll->d > 1.0) { scroll->d = 1.0; } return true; } case KEY_HOME: { m->panel.content_scroll->d = 0.0; return true; } case KEY_END: { m->panel.content_scroll->d = 1.0; return true; } } return false; } void messages_init(MESSAGES *m, uint32_t friend_number) { if (m->data) { messages_clear_all(m); } pthread_mutex_lock(&messages_lock); memset(m, 0, sizeof(*m)); m->id = friend_number; m->extra = 20; m->data = calloc(20, sizeof(void *)); if (!m->data) { LOG_FATAL_ERR(EXIT_MALLOC, "Messages", "\n\n\nFATAL ERROR TRYING TO CALLOC FOR MESSAGES.\nTHIS IS A BUG, PLEASE REPORT!\n\n\n"); } pthread_mutex_unlock(&messages_lock); } void message_free(MSG_HEADER *msg) { // The group messages are free()d in groups.c (group_free(GROUPCHAT *g)) switch (msg->msg_type) { case MSG_TYPE_NULL: { LOG_ERR("Messages", "Invalid message type in message_free."); break; } case MSG_TYPE_IMAGE: { image_free(msg->via.img.image); break; } case MSG_TYPE_FILE: { free(msg->via.ft.name); free(msg->via.ft.path); free(msg->via.ft.data); break; } case MSG_TYPE_NOTICE_DAY_CHANGE: { free(msg->via.notice_day.msg); break; } case MSG_TYPE_TEXT: { free(msg->via.txt.msg); break; } case MSG_TYPE_ACTION_TEXT: { free(msg->via.action.msg); break; } case MSG_TYPE_NOTICE: { free(msg->via.notice.msg); break; } } free(msg); } void messages_clear_all(MESSAGES *m) { pthread_mutex_lock(&messages_lock); for (uint32_t i = 0; i < m->number; i++) { message_free(m->data[i]); } free(m->data); m->data = NULL; m->number = 0; m->extra = 0; m->height = 0; m->sel_start_msg = m->sel_end_msg = m->sel_start_position = m->sel_end_position = 0; pthread_mutex_unlock(&messages_lock); } uTox/src/main.h0000600000175000001440000000327514003056216012371 0ustar rakusers#ifndef UTOX_MAIN_H #define UTOX_MAIN_H /********************************************************** * Includes *********************************************************/ #include /********************************************************** * uTox Versions and header information *********************************************************/ #include "branding.h" /********************************************************** * UI and Toxcore Limits *********************************************************/ #if TOX_VERSION_IS_API_COMPATIBLE(0, 2, 0) // YAY!! #else #error "Unable to compile uTox with this Toxcore version. uTox expects v0.2.*!" #endif #define MAIN_WIDTH 750 #define MAIN_HEIGHT 500 #ifndef __OBJC__ #define volatile(x)(x) #endif /* Support for large files. */ #define _LARGEFILE_SOURCE #define _FILE_OFFSET_BITS 64 #if TOX_VERSION_MAJOR > 0 #define ENABLE_MULTIDEVICE 1 #endif enum { USER_STATUS_AVAILABLE, USER_STATUS_AWAY_IDLE, USER_STATUS_DO_NOT_DISTURB, }; /** * Takes data and the size of data and writes it to the disk * * Returns a bool indicating whether a save is needed */ bool utox_data_save_tox(uint8_t *data, size_t length); /** * Reads the tox data from the disk and sets size * * Returns a pointer to the tox data, the caller needs to free it * Returns NULL on failure */ uint8_t *utox_data_load_tox(size_t *size); /** * Parses the arguments passed to uTox */ void parse_args(int argc, char *argv[], int8_t *should_launch_at_startup, int8_t *set_show_window, bool *allow_root); /** * Initialize uTox */ void utox_init(void); /** * Free used resources */ void utox_raze(void); #endif uTox/src/main.c0000600000175000001440000002260314003056216012360 0ustar rakusers#include "main.h" #include "debug.h" #include "settings.h" #include "theme.h" #include "native/filesys.h" #include "native/main.h" #include "native/thread.h" #include "av/utox_av.h" #include #include #include /* The utox_ functions contained in src/main.c are wrappers for the platform native_ functions * if you need to localize them to a specific platform, move them from here, to each * src//main.x and change from utox_ to native_ */ bool utox_data_save_tox(uint8_t *data, size_t length) { FILE *fp = utox_get_file("tox_save.tox", NULL, UTOX_FILE_OPTS_WRITE); if (!fp) { LOG_ERR("uTox", "Can not open tox_save.tox to write to it."); return true; } if (fwrite(data, length, 1, fp) != 1) { LOG_ERR("uTox", "Unable to write Tox save to file."); fclose(fp); return true; } flush_file(fp); fclose(fp); return false; } uint8_t *utox_data_load_tox(size_t *size) { const char name[][20] = { "tox_save.tox", "tox_save.tox.atomic", "tox_save.tmp", "tox_save" }; for (uint8_t i = 0; i < 4; i++) { size_t length = 0; FILE *fp = utox_get_file(name[i], &length, UTOX_FILE_OPTS_READ); if (!fp) { continue; } uint8_t *data = calloc(1, length + 1); if (!data) { LOG_ERR("uTox", "Could not allocate memory for tox save."); fclose(fp); // Quit. We're out of memory, calloc will fail again. return NULL; } if (fread(data, length, 1, fp) != 1) { LOG_ERR("uTox", "Could not read: %s.", name[i]); fclose(fp); free(data); // Return NULL, because if a Tox save exits we don't want to fall // back to an old version, we need the user to decide what to do. return NULL; } fclose(fp); *size = length; return data; } return NULL; } bool utox_data_save_ftinfo(char hex[TOX_PUBLIC_KEY_SIZE * 2], uint8_t *data, size_t length) { char name[TOX_PUBLIC_KEY_SIZE * 2 + sizeof(".ftinfo")]; snprintf(name, sizeof(name), "%.*s.ftinfo", TOX_PUBLIC_KEY_SIZE * 2, hex); FILE *fp = utox_get_file(name, NULL, UTOX_FILE_OPTS_WRITE); if (fp == NULL) { return false; } if (fwrite(data, length, 1, fp) != 1) { LOG_ERR("uTox", "Unable to write ftinfo to file."); fclose(fp); return false; } fclose(fp); return true; } /* Shared function between all four platforms */ void parse_args(int argc, char *argv[], int8_t *should_launch_at_startup, int8_t *set_show_window, bool *allow_root ) { // set default options if (should_launch_at_startup) { *should_launch_at_startup = 0; } if (set_show_window) { *set_show_window = 0; } if (allow_root) { *allow_root = false; } static struct option long_options[] = { { "theme", required_argument, NULL, 't' }, { "portable", no_argument, NULL, 'p' }, { "set", required_argument, NULL, 's' }, { "unset", required_argument, NULL, 'u' }, { "version", no_argument, NULL, 0 }, { "silent", no_argument, NULL, 'S' }, { "verbose", no_argument, NULL, 'v' }, { "help", no_argument, NULL, 'h' }, { "debug", required_argument, NULL, 1 }, { "allow-root", no_argument, NULL, 2 }, { 0, 0, 0, 0 } }; settings.debug_file = stdout; int opt, long_index = 0; while ((opt = getopt_long(argc, argv, "t:ps:u:nvh", long_options, &long_index)) != -1) { // loop through each option; ":" after each option means an argument is required switch (opt) { case 't': { if (!strcmp(optarg, "default")) { settings.theme = THEME_DEFAULT; } else if (!strcmp(optarg, "dark")) { settings.theme = THEME_DARK; } else if (!strcmp(optarg, "light")) { settings.theme = THEME_LIGHT; } else if (!strcmp(optarg, "highcontrast")) { settings.theme = THEME_HIGHCONTRAST; } else if (!strcmp(optarg, "zenburn")) { settings.theme = THEME_ZENBURN; } else if (!strcmp(optarg, "solarized-light")) { settings.theme = THEME_SOLARIZED_LIGHT; } else if (!strcmp(optarg, "solarized-dark")) { settings.theme = THEME_SOLARIZED_DARK; } else { LOG_NORM("Please specify correct theme (please check user manual for list of correct values).\n"); exit(EXIT_FAILURE); } break; } case 'p': { LOG_INFO("uTox", "Launching uTox in portable mode: All data will be saved to the tox folder in the current " "working directory\n"); settings.portable_mode = 1; break; } case 's': { if (!strcmp(optarg, "start-on-boot")) { if (should_launch_at_startup) { *should_launch_at_startup = 1; } } else if (!strcmp(optarg, "show-window")) { if (set_show_window) { *set_show_window = 1; } } else if (!strcmp(optarg, "hide-window")) { if (set_show_window) { *set_show_window = -1; } } else { LOG_NORM("Please specify a correct set option (please check user manual for list of correct values).\n"); exit(EXIT_FAILURE); } break; } case 'u': { if (!strcmp(optarg, "start-on-boot")) { if (should_launch_at_startup) { *should_launch_at_startup = -1; } } else { LOG_NORM("Please specify a correct unset option (please check user manual for list of correct values).\n"); exit(EXIT_FAILURE); } break; } case 0: { LOG_NORM("uTox version: %s\n", VERSION); #ifdef GIT_VERSION LOG_NORM("git version %s\n", GIT_VERSION); #endif exit(EXIT_SUCCESS); } case 'S': { settings.verbose = LOG_LVL_FATAL; break; } case 'v': { settings.verbose++; break; } case 1: { settings.debug_file = fopen(optarg, "a+"); if (!settings.debug_file) { settings.debug_file = stdout; LOG_NORM("Could not open %s. Logging to stdout.\n", optarg); } break; } case 2: { if (allow_root) { *allow_root = true; } break; } case 'h': { LOG_NORM("µTox - Lightweight Tox client version %s.\n\n", VERSION); LOG_NORM("The following options are available:\n"); LOG_NORM(" -t --theme= Specify a UI theme, where can be one of default, " "dark, light, highcontrast, zenburn, solarized-light, solarized-dark.\n"); LOG_NORM(" -p --portable Launch in portable mode: All data will be saved to the tox " "folder in the current working directory.\n"); LOG_NORM(" -s --set= uTox/src/cocoa/Info.plist.in0000600000175000001440000000272014003056216014727 0ustar rakusers CFBundleDevelopmentRegion en CFBundleExecutable @EXECUTABLE_NAME@ CFBundleIconFile @APPLE_ICON@ CFBundleIdentifier io.utox.future CFBundleInfoDictionaryVersion 6.0 CFBundleName uTox CFBundleDisplayName uTox (Alpha) CFBundleSpokenName u Tox CFBundlePackageType APPL CFBundleShortVersionString @PROJECT_VERSION@ CFBundleVersion @PROJECT_VERSION@ LSMinimumSystemVersion @CMAKE_OSX_DEPLOYMENT_TARGET@ NSHumanReadableCopyright @PROJECT_COPYRIGHT@ NSMainNibFile @APPLE_MENU@ NSPrincipalClass NSApplication CFBundleURLTypes CFBundleURLName Tox CFBundleTypeRole Viewer CFBundleURLSchemes tox uTox/src/cocoa/CMakeLists.txt0000600000175000001440000000132714003056216015114 0ustar rakusersproject(utoxNATIVE LANGUAGES C) add_library(utoxNATIVE STATIC ../posix/filesys.c drawing.m grabdesktop.m interaction.m main.m MainMenu.xib video.m window.c ) target_link_libraries(utoxNATIVE PUBLIC "-framework AppKit" "-framework ApplicationServices" "-framework AVFoundation" "-framework Cocoa" "-framework CoreData" "-framework CoreFoundation" "-framework CoreGraphics" "-framework CoreMedia" "-framework CoreText" "-framework CoreVideo" "-framework Foundation" "-framework OpenAL" "-framework OpenGL" "-framework QuartzCore" -lresolv PRIVATE stb ) uTox/src/chrono.h0000600000175000001440000000127414003056216012732 0ustar rakusers#ifndef CHRONO_H #define CHRONO_H #include #include struct chrono_info { uint8_t *ptr, *target; int step; uint32_t interval_ms; bool finished; void (*callback)(void *); void *cb_data; }; typedef struct chrono_info CHRONO_INFO; extern bool chrono_thread_init; /* * Starts the chrono thread using the information from info * Returns true on success * Returns false on failure */ bool chrono_start(CHRONO_INFO *info); /* * Ends the chrono thread * Returns true on success * Returns false on failure */ bool chrono_end(CHRONO_INFO *info); /* * Sleep and then */ void chrono_callback(uint32_t ms, void func(void *), void *funcargs); #endif uTox/src/chrono.c0000600000175000001440000000223614003056216012724 0ustar rakusers#include "chrono.h" #include "debug.h" #include "macros.h" #include #include #include #include "native/thread.h" bool chrono_thread_init = false; static void chrono_thread(void *args) { LOG_INFO("Chono", "Thread starting"); CHRONO_INFO *info = args; chrono_thread_init = true; while (info->ptr != info->target) { info->ptr += info->step; yieldcpu(info->interval_ms); } chrono_thread_init = false; if (info->callback) { info->callback(info->cb_data); } LOG_INFO("Chrono", "Thread exited cleanly"); } bool chrono_start(CHRONO_INFO *info) { if (!info) { LOG_ERR("Chrono", "Chrono info structure is null."); return false; } thread(chrono_thread, info); return true; } bool chrono_end(CHRONO_INFO *info) { if (!info) { LOG_ERR("Chrono", "Chrono info is null"); return false; } (*info).finished = true; while (chrono_thread_init) { //wait for thread to die yieldcpu(1); } return true; } void chrono_callback(uint32_t ms, void func(void *), void *funcargs) { yieldcpu(ms); func(funcargs); } uTox/src/chatlog.h0000600000175000001440000000317314003056216013063 0ustar rakusers#ifndef CHATLOG_H #define CHATLOG_H #include #include #include #include #define LOGFILE_SAVE_VERSION 3 typedef struct { uint8_t log_version; time_t time; size_t author_length; size_t msg_length; uint8_t author : 1; uint8_t receipt : 1; uint8_t flags : 5; uint8_t deleted : 1; uint8_t msg_type; uint8_t zeroes[2]; } LOG_FILE_MSG_HEADER; typedef struct msg_header MSG_HEADER; /** * Saves chat log for friend with id hex * * Returns the offset on success * Returns 0 on failure */ size_t utox_save_chatlog(char hex[TOX_PUBLIC_KEY_SIZE * 2], uint8_t *data, size_t length); // This one actually does the work of reading the logfile information. MSG_HEADER **utox_load_chatlog(char hex[TOX_PUBLIC_KEY_SIZE * 2], size_t *size, uint32_t count, uint32_t skip); /** utox_update_chatlog Updates the data for this friend's history. * * When given a friend_number and offset, utox_update_chatlog will overwrite the file, with * the supplied data * length. It makes no attempt to verify the data or length, it'll just * write blindly. */ bool utox_update_chatlog(char hex[TOX_PUBLIC_KEY_SIZE * 2], size_t offset, uint8_t *data, size_t length); /** * Deletes the chat log file for the friend with id hex * * Returns bool indicating if it succeeded */ bool utox_remove_friend_chatlog(char hex[TOX_PUBLIC_KEY_SIZE * 2]); /** * Setup for exporting the chat log to plain text */ void utox_export_chatlog_init(uint32_t friend_number); /** * Export the chat log to plain text */ void utox_export_chatlog(char hex[TOX_PUBLIC_KEY_SIZE * 2], FILE *dest_file); #endif uTox/src/chatlog.c0000600000175000001440000002401314003056216013052 0ustar rakusers#include "chatlog.h" #include "filesys.h" // TODO including native.h files should never be needed, refactor filesys.h to provide necessary API #include "debug.h" #include "messages.h" #include "text.h" #include "native/filesys.h" #include #include static FILE* chatlog_get_file(char hex[TOX_PUBLIC_KEY_SIZE * 2], bool append) { char name[TOX_PUBLIC_KEY_SIZE * 2 + sizeof(".new.txt")]; snprintf(name, sizeof(name), "%.*s.new.txt", TOX_PUBLIC_KEY_SIZE * 2, hex); FILE *file; if (append) { file = utox_get_file(name, NULL, UTOX_FILE_OPTS_READ | UTOX_FILE_OPTS_WRITE | UTOX_FILE_OPTS_MKDIR); if (!file) { return NULL; } fseek(file, 0, SEEK_END); } else { file = utox_get_file(name, NULL, UTOX_FILE_OPTS_READ); } return file; } size_t utox_save_chatlog(char hex[TOX_PUBLIC_KEY_SIZE * 2], uint8_t *data, size_t length) { FILE *fp = chatlog_get_file(hex, true); if (!fp) { LOG_ERR("uTox", "Error getting a file handle for this chatlog!"); return 0; } // Seek to the beginning of the file first because grayhatter has had issues with this on Windows. // (and he really doesn't want uTox eating people's chat logs) fseeko(fp, 0, SEEK_SET); fseeko(fp, 0, SEEK_END); off_t offset = ftello(fp); fwrite(data, length, 1, fp); fclose(fp); return offset; } static size_t utox_count_chatlog(char hex[TOX_PUBLIC_KEY_SIZE * 2]) { FILE *file = chatlog_get_file(hex, false); if (!file) { return 0; } LOG_FILE_MSG_HEADER header; size_t records_count = 0; while (fread(&header, sizeof(header), 1, file) == 1) { fseeko(file, header.author_length + header.msg_length + 1, SEEK_CUR); records_count++; } if (ferror(file) || !feof(file)) { /* TODO: consider removing or truncating the log file. * If !feof() this means that the file has an incomplete record, * which would prevent it from loading forever, even though * new records will keep being appended as usual. */ LOG_ERR("Chatlog", "Log read err; trying to count history for friend %.*s", TOX_PUBLIC_KEY_SIZE * 2, hex); fclose(file); return 0; } fclose(file); return records_count; } /* TODO create fxn that will try to recover a corrupt chat history. * * In the majority of bug reports the corrupt message is often the first, so in * theory we should be able to trim the start of the chatlog up to and including * the first \n char. We may have to do so multiple times, but once we find the * first valid message everything else should "work" */ MSG_HEADER **utox_load_chatlog(char hex[TOX_PUBLIC_KEY_SIZE * 2], size_t *size, uint32_t count, uint32_t skip) { /* Because every platform is different, we have to ask them to open the file for us. * However once we have it, every platform does the same thing, this should prevent issues * from occurring on a single platform. */ size_t records_count = utox_count_chatlog(hex); if (skip >= records_count) { if (skip > 0) { LOG_ERR("Chatlog", "Error, skipped all records"); } else { LOG_INFO("Chatlog", "No log exists."); } return NULL; } FILE *file = chatlog_get_file(hex, false); if (!file) { LOG_TRACE("Chatlog", "Log read:\tUnable to access file provided."); return NULL; } if (count > (records_count - skip)) { count = records_count - skip; } MSG_HEADER **data = calloc(count + 1, sizeof(MSG_HEADER *)); MSG_HEADER **start = data; if (!data) { LOG_ERR("Chatlog", "Log read:\tCouldn't allocate memory for log entries."); fclose(file); return NULL; } size_t start_at = records_count - count - skip; size_t actual_count = 0; size_t file_offset = 0; LOG_FILE_MSG_HEADER header; while (fread(&header, sizeof(header), 1, file) == 1) { if (start_at) { fseeko(file, header.author_length, SEEK_CUR); /* Skip the recorded author */ fseeko(file, header.msg_length, SEEK_CUR); /* Skip the message */ fseeko(file, 1, SEEK_CUR); /* Skip the newline char */ start_at--; file_offset = ftello(file); continue; } if (count) { /* we have to skip the author name for now, it's left here for group chats support in the future */ fseeko(file, header.author_length, SEEK_CUR); if (header.msg_length > 1 << 16) { LOG_ERR("Chatlog", "Can't malloc that much, you'll probably have to move or delete your" " history for this peer.\n\t\tFriend number %.*s, count %u," " actual_count %lu, start at %lu, error size %lu.\n", TOX_PUBLIC_KEY_SIZE * 2, hex, count, actual_count, start_at, header.msg_length); if (size) { *size = 0; } fclose(file); return start; } MSG_HEADER *msg = calloc(1, sizeof(MSG_HEADER)); if (!msg) { LOG_ERR("Chatlog", "Unable to malloc... sorry!"); free(start); fclose(file); return NULL; } msg->our_msg = header.author; msg->receipt_time = header.receipt; msg->time = header.time; msg->msg_type = header.msg_type; msg->disk_offset = file_offset; msg->via.txt.length = header.msg_length; msg->via.txt.msg = calloc(1, msg->via.txt.length); if (!msg->via.txt.msg) { LOG_ERR("Chatlog", "Unable to malloc for via.txt.msg... sorry!"); free(start); free(msg); fclose(file); return NULL; } msg->via.txt.author_length = header.author_length; // TODO: msg->via.txt.author used to be allocated but left empty. Commented out for now. // msg->via.txt.author = calloc(1, msg->via.txt.author_length); // if (!msg->via.txt.author) { // LOG_ERR("Chatlog", "Unable to malloc for via.txt.author... sorry!"); // free(msg->via.txt.msg); // free(msg); // fclose(file); // return NULL; // } if (fread(msg->via.txt.msg, msg->via.txt.length, 1, file) != 1) { LOG_ERR("Chatlog", "Log read:\tError reading record %u of length %u at offset %lu: stopping.", count, msg->via.txt.length, msg->disk_offset); // free(msg->via.txt.author); free(msg->via.txt.msg); free(msg); break; } msg->via.txt.length = utf8_validate((uint8_t *)msg->via.txt.msg, msg->via.txt.length); *data++ = msg; --count; ++actual_count; fseeko(file, 1, SEEK_CUR); /* seek an extra \n char */ file_offset = ftello(file); } } fclose(file); if (size) { *size = actual_count; } return start; } bool utox_update_chatlog(char hex[TOX_PUBLIC_KEY_SIZE * 2], size_t offset, uint8_t *data, size_t length) { FILE *file = chatlog_get_file(hex, true); if (!file) { LOG_ERR("History", "Unable to access file provided."); return false; } if (fseeko(file, offset, SEEK_SET)) { LOG_ERR("Chatlog", "History:\tUnable to seek to position %lu in file provided.", offset); fclose(file); return false; } fwrite(data, length, 1, file); fclose(file); return true; } bool utox_remove_friend_chatlog(char hex[TOX_PUBLIC_KEY_SIZE * 2]) { char name[TOX_PUBLIC_KEY_SIZE * 2 + sizeof(".new.txt")]; snprintf(name, sizeof(name), "%.*s.new.txt", TOX_PUBLIC_KEY_SIZE * 2, hex); return utox_remove_file((uint8_t*)name, sizeof(name)); } void utox_export_chatlog_init(uint32_t friend_number) { native_export_chatlog_init(friend_number); } void utox_export_chatlog(char hex[TOX_PUBLIC_KEY_SIZE * 2], FILE *dest_file) { if (!dest_file) { return; } LOG_FILE_MSG_HEADER header; FILE *file = chatlog_get_file(hex, false); struct tm *tm_curr; struct tm_tmp { int tm_year; int tm_mon; int tm_mday; } tm_prev = { .tm_mday = 1}; while (fread(&header, sizeof(header), 1, file) == 1) { tm_curr = localtime(&header.time); if (tm_curr->tm_year > tm_prev.tm_year || (tm_curr->tm_year == tm_prev.tm_year && tm_curr->tm_mon > tm_prev.tm_mon) || (tm_curr->tm_year == tm_prev.tm_year && tm_curr->tm_mon == tm_prev.tm_mon && tm_curr->tm_mday > tm_prev.tm_mday)) { char buffer[128]; size_t len = strftime(buffer, 128, "Day has changed to %A %B %d %Y\n", tm_curr); fwrite(buffer, len, 1, dest_file); } /* Write Timestamp */ fprintf(dest_file, "[%02d:%02d]", tm_curr->tm_hour, tm_curr->tm_min); tm_prev.tm_year = tm_curr->tm_year; tm_prev.tm_mon = tm_curr->tm_mon; tm_prev.tm_mday = tm_curr->tm_mday; int c; if (header.msg_type == MSG_TYPE_NOTICE) { fseek(file, header.author_length, SEEK_CUR); } else { /* Write Author */ fwrite(" <", 2, 1, dest_file); for (size_t i = 0; i < header.author_length; ++i) { c = fgetc(file); if (c != EOF) { fputc(c, dest_file); } } fwrite(">", 1, 1, dest_file); } /* Write text */ fwrite(" ", 1, 1, dest_file); for (size_t i = 0; i < header.msg_length; ++i) { c = fgetc(file); if (c != EOF) { fputc(c, dest_file); } } c = fgetc(file); /* the newline char */ fputc(c, dest_file); } fclose(file); fclose(dest_file); } uTox/src/branding.h.in0000600000175000001440000000137214003056216013632 0ustar rakusers/** * uTox Versions and header information * * This file contains defines regarding uTox branding and version information * It is generated from branding.h.in which cmake will generate to branding.h */ #define TITLE "uTox" #define SUB_TITLE "(Alpha)" #define VERSION "@PROJECT_VERSION@" #define VER_MAJOR @PROJECT_VERSION_MAJOR@ #define VER_MINOR @PROJECT_VERSION_MINOR@ #define VER_PATCH @PROJECT_VERSION_PATCH@ #define UTOX_VERSION_NUMBER (VER_MAJOR << 16 | VER_MINOR << 8 | VER_PATCH) // Assembly info #define UTOX_FILE_DESCRIPTION "The lightweight Tox client" #define UTOX_COPYRIGHT "@PROJECT_COPYRIGHT@" #define UTOX_FILENAME_WINDOWS "uTox.exe" // Defaults #define DEFAULT_NAME "uTox User" #define DEFAULT_STATUS "Toxing on uTox, from the future!" uTox/src/branding.h0000600000175000001440000000132114003056216013217 0ustar rakusers/** * uTox Versions and header information * * This file contains defines regarding uTox branding and version information * It is generated from branding.h.in which cmake will generate to branding.h */ #define TITLE "uTox" #define SUB_TITLE "(Alpha)" #define VERSION "0.18.1" #define VER_MAJOR 0 #define VER_MINOR 18 #define VER_PATCH 1 #define UTOX_VERSION_NUMBER (VER_MAJOR << 16 | VER_MINOR << 8 | VER_PATCH) // Assembly info #define UTOX_FILE_DESCRIPTION "The lightweight Tox client" #define UTOX_COPYRIGHT "Copyleft 2021 uTox contributors. Some rights reserved." #define UTOX_FILENAME_WINDOWS "uTox.exe" // Defaults #define DEFAULT_NAME "uTox User" #define DEFAULT_STATUS "Toxing on uTox, from the future!" uTox/src/avatar.h0000600000175000001440000001000314003056216012706 0ustar rakusers#ifndef AVATAR_H #define AVATAR_H #include typedef struct native_image NATIVE_IMAGE; // TODO: remove? #define UTOX_AVATAR_MAX_DATA_LENGTH (64 * 1024) // NOTE: increasing this above 64k might cause // issues with other clients who do stupid things. #define UTOX_AVATAR_FORMAT_NONE 0 #define UTOX_AVATAR_FORMAT_PNG 1 /* data needed for each avatar in memory */ typedef struct avatar { NATIVE_IMAGE *img; /* converted avatar image to draw */ size_t size; uint16_t width, height; /* width and height of image (in pixels) */ uint8_t format; /* one of TOX_AVATAR_FORMAT */ uint8_t hash[TOX_HASH_LENGTH]; /* tox_hash for the png data of this avatar */ } AVATAR; /* Whether user's avatar is set. */ #define self_has_avatar() (self.avatar && self.avatar->format != UTOX_AVATAR_FORMAT_NONE) /* Whether friend f's avatar is set, where f is a pointer to a friend struct */ #define friend_has_avatar(f) (f) && (f->avatar->format != UTOX_AVATAR_FORMAT_NONE) /** tries to load avatar from disk for given client id string and set avatar based on saved png data * avatar is avatar to initialize. Will be unset if no file is found on disk or if file is corrupt or too large, * otherwise will be set to avatar found on disk * id is cid string of whose avatar to find(see also avatar_load in avatar.c) * if png_data_out is not NULL, the png data loaded from disk will be copied to it. * if it is not null, it should be at least UTOX_AVATAR_MAX_DATA_LENGTH bytes long * if png_size_out is not null, the size of the png data will be stored in it * * returns: true on successful loading, false on failure */ bool avatar_init(char hexid[TOX_PUBLIC_KEY_SIZE * 2], AVATAR *avatar); /** Converts png data given by data to a NATIVE_IMAGE and uses that to populate the avatar struct * avatar is pointer to an avatar struct to store result in. Remains unchanged if function fails. * data is pointer to png data to convert * size is size of data * * on success: returns true * on failure: returns false * * notes: fails if given size is larger than UTOX_AVATAR_MAX_DATA_LENGTH or data is not valid PNG data */ bool avatar_set(AVATAR *avatar, const uint8_t *data, size_t size); /* Helper function to set the user's avatar. */ bool avatar_set_self(const uint8_t *data, size_t size); /* Helper function to unset the user's avatar. */ void avatar_unset_self(void); /* Helper function to delete user's avatar file. */ void avatar_delete_self(void); /* Unsets an avatar by setting its format to UTOX_AVATAR_FORMAT_NONE and freeing its image. */ void avatar_unset(AVATAR *avatar); /** Sets own avatar based on given png data and saves it to disk if successful. * data is png data to set avatar to. * size is size of data. * * on success: returns true * on failure: returns false * * Notes: Fails if size is too large or data is not a valid png file. */ bool self_set_and_save_avatar(const uint8_t *data, uint32_t size); /* Unsets own avatar and removes it from disk */ bool avatar_remove_self(void); /** Call this every time friend_number goes online from the tox_do thread. * * on success: returns true * on failure: returns false */ bool avatar_on_friend_online(Tox *tox, uint32_t friend_number); /** Colled by incoming file transfers to change the avater. * * If size <=0, we'll unset the avatar, else we'll set and update the friend */ void utox_incoming_avatar(uint32_t friend_number, uint8_t *avatar, size_t size); /* Saves the avatar for user with hexid * * returns true on success * returns false on failure */ bool avatar_save(char hexid[TOX_PUBLIC_KEY_SIZE * 2], const uint8_t *data, size_t length); /* Deletes the avatar for user with hexid * * returns true on success * returns false on failure */ bool avatar_delete(char hexid[TOX_PUBLIC_KEY_SIZE * 2]); /* Helper function to initialize the user's avatar */ bool avatar_init_self(void); /* Moves the avatar to its new name */ bool avatar_move(const uint8_t *source, const uint8_t *dest); #endif uTox/src/avatar.c0000600000175000001440000001457414003056216012722 0ustar rakusers#include "avatar.h" #include "debug.h" #include "file_transfers.h" #include "filesys.h" #include "self.h" #include "tox.h" #include "native/image.h" #include #include /* frees the image of an avatar, does nothing if image is NULL */ static void avatar_free_image(AVATAR *avatar) { if (avatar) { image_free(avatar->img); avatar->img = NULL; avatar->size = 0; } } bool avatar_save(char hexid[TOX_PUBLIC_KEY_SIZE * 2], const uint8_t *data, size_t length) { char name[sizeof("avatars/") + TOX_PUBLIC_KEY_SIZE * 2 + sizeof(".png")] = { 0 }; FILE *fp; snprintf(name, sizeof("avatars/") + TOX_PUBLIC_KEY_SIZE * 2 + sizeof(".png"), "avatars/%.*s.png", TOX_PUBLIC_KEY_SIZE * 2, hexid); fp = utox_get_file(name, NULL, UTOX_FILE_OPTS_WRITE | UTOX_FILE_OPTS_MKDIR); if (!fp) { LOG_WARN("Avatar", "Could not save avatar for: %.*s", TOX_PUBLIC_KEY_SIZE * 2, hexid); return false; } fwrite(data, length, 1, fp); fclose(fp); return true; } static uint8_t *load_img_data(char hexid[TOX_PUBLIC_KEY_SIZE * 2], size_t *out_size) { char name[sizeof("avatars/") + TOX_PUBLIC_KEY_SIZE * 2 + sizeof(".png")] = { 0 }; snprintf(name, sizeof("avatars/") + TOX_PUBLIC_KEY_SIZE * 2 + sizeof(".png"), "avatars/%.*s.png", TOX_PUBLIC_KEY_SIZE * 2, hexid); size_t size = 0; FILE *fp = utox_get_file(name, &size, UTOX_FILE_OPTS_READ); if (fp == NULL) { LOG_TRACE("Avatar", "Could not read: %s", name); return NULL; } uint8_t *data = calloc(1, size); if (data == NULL) { LOG_ERR("Avatar", "Could not allocate memory for file of size %zu.", size); fclose(fp); return NULL; } if (fread(data, size, 1, fp) != 1) { LOG_WARN("Avatar", "Could not read from open file: %s", name); fclose(fp); free(data); return NULL; } fclose(fp); if (out_size) { *out_size = size; } return data; } bool avatar_delete(char hexid[TOX_PUBLIC_KEY_SIZE * 2]) { char name[sizeof("avatars/") + TOX_PUBLIC_KEY_SIZE * 2 + sizeof(".png")] = { 0 }; snprintf(name, sizeof(name), "avatars/%.*s.png", TOX_PUBLIC_KEY_SIZE * 2, hexid); int name_len = strnlen(name, sizeof(name) - 1); return utox_remove_file((uint8_t *)name, name_len); } static bool avatar_load(char hexid[TOX_PUBLIC_KEY_SIZE * 2], AVATAR *avatar, size_t *size_out) { size_t size = 0; uint8_t *img = load_img_data(hexid, &size); if (!img) { LOG_DEBUG("Avatar", "Unable to get saved avatar from disk for friend %.*s" , TOX_PUBLIC_KEY_SIZE * 2, hexid); return false; } if (size > UTOX_AVATAR_MAX_DATA_LENGTH) { free(img); LOG_WARN("Avatar", "Saved avatar file for friend (%.*s) too large for tox" , TOX_PUBLIC_KEY_SIZE * 2, hexid); return false; } avatar->img = utox_image_to_native(img, size, &avatar->width, &avatar->height, true); if (avatar->img) { avatar->format = UTOX_AVATAR_FORMAT_PNG; avatar->size = size; tox_hash(avatar->hash, img, size); if (size_out) { *size_out = size; } if (avatar == self.avatar) { // We need to save our avatar in PNG format so we can send it to friends! self.png_data = img; self.png_size = size; } else { free(img); } return true; } free(img); return false; } bool avatar_set(AVATAR *avatar, const uint8_t *data, size_t size) { if (avatar == NULL) { LOG_DEBUG("Avatar", "avatar is null."); return false; } if (size > UTOX_AVATAR_MAX_DATA_LENGTH) { LOG_ERR("Avatar", " avatar too large"); return false; } avatar_free_image(avatar); NATIVE_IMAGE *image = utox_image_to_native((UTOX_IMAGE)data, size, &avatar->width, &avatar->height, true); if (!NATIVE_IMAGE_IS_VALID(image)) { LOG_DEBUG("Avatar", "avatar is invalid"); return false; } avatar->img = image; avatar->format = UTOX_AVATAR_FORMAT_PNG; avatar->size = size; tox_hash(avatar->hash, data, size); return true; } /* sets self avatar, see self_set_and_save_avatar */ bool avatar_set_self(const uint8_t *data, size_t size) { return avatar_set(self.avatar, data, size); } void avatar_unset(AVATAR *avatar) { if (avatar == NULL) { LOG_TRACE("Avatar", " avatar is null" ); return; } avatar->format = UTOX_AVATAR_FORMAT_NONE; avatar_free_image(avatar); } void avatar_unset_self(void) { avatar_unset(self.avatar); } bool avatar_init(char hexid[TOX_PUBLIC_KEY_SIZE * 2], AVATAR *avatar) { avatar_unset(avatar); return avatar_load(hexid, avatar, NULL); } bool avatar_init_self(void) { self.avatar = calloc(1, sizeof(AVATAR)); if (self.avatar == NULL) { return false; } return avatar_load(self.id_str, self.avatar, NULL); } bool self_set_and_save_avatar(const uint8_t *data, uint32_t size) { if (avatar_set_self(data, size)) { avatar_save(self.id_str, data, size); return true; } return false; } void avatar_delete_self(void) { avatar_unset(self.avatar); avatar_delete(self.id_str); postmessage_toxcore(TOX_AVATAR_UNSET, 0, 0, NULL); } bool avatar_on_friend_online(Tox *tox, uint32_t friend_number) { if (!self.png_data) { uint8_t *avatar_data = load_img_data(self.id_str, &self.png_size); if (!avatar_data) { LOG_WARN("Avatar", "Unable to get out avatar data to send to friend."); self.png_data = NULL; self.png_size = 0; return false; } self.png_data = avatar_data; } ft_send_avatar(tox, friend_number); return true; } bool avatar_move(const uint8_t *source, const uint8_t *dest) { uint8_t current_name[sizeof("avatars/") + TOX_PUBLIC_KEY_SIZE * 2 + sizeof(".png")] = { 0 }; uint8_t new_name[sizeof("avatars/") + TOX_PUBLIC_KEY_SIZE * 2 + sizeof(".png")] = { 0 }; snprintf((char *)current_name, sizeof("avatars/") + TOX_PUBLIC_KEY_SIZE * 2 + sizeof(".png"), "avatars/%.*s.png", TOX_PUBLIC_KEY_SIZE * 2, source); snprintf((char *)new_name, sizeof("avatars/") + TOX_PUBLIC_KEY_SIZE * 2 + sizeof(".png"), "avatars/%.*s.png", TOX_PUBLIC_KEY_SIZE * 2, dest); return utox_move_file(current_name, new_name); } uTox/src/av/0000700000175000001440000000000014003056216011671 5ustar rakusersuTox/src/av/video.h0000600000175000001440000000464714003056216013165 0ustar rakusers#ifndef VIDEO_H #define VIDEO_H #include #include #include extern uint16_t video_width, video_height, max_video_width, max_video_height; extern bool utox_video_thread_init; #define UTOX_DEFAULT_BITRATE_V 5000 #define UTOX_MIN_BITRATE_VIDEO 512 // UTOX_DEFAULT_VID_WIDTH, HEIGHT are unused. #define UTOX_DEFAULT_VID_WIDTH 1280 #define UTOX_DEFAULT_VID_HEIGHT 720 /* Check self */ #define SELF_SEND_VIDEO(f_number) (get_friend(f_number) && (!!(get_friend(f_number)->call_state_self & TOXAV_FRIEND_CALL_STATE_SENDING_V))) #define SELF_ACCEPT_VIDEO(f_number) (get_friend(f_number) && (!!(get_friend(f_number)->call_state_self & TOXAV_FRIEND_CALL_STATE_ACCEPTING_V))) /* Check friend */ #define FRIEND_SENDING_VIDEO(f_number) (get_friend(f_number) && (!!(get_friend(f_number)->call_state_friend & TOXAV_FRIEND_CALL_STATE_SENDING_V))) #define FRIEND_ACCEPTING_VIDEO(f_number) (get_friend(f_number) && (!!(get_friend(f_number)->call_state_friend & TOXAV_FRIEND_CALL_STATE_ACCEPTING_V))) /* Check both */ #define SEND_VIDEO_FRAME(f_number) (SELF_SEND_VIDEO(f_number) && FRIEND_ACCEPTING_VIDEO(f_number)) typedef struct UTOX_AV_VIDEO_FRAME { uint16_t w, h; uint8_t *y, *u, *v; } utox_av_video_frame; typedef struct utox_frame_pkg { uint16_t w, h; size_t size; void *img; } UTOX_FRAME_PKG; void utox_video_append_device(void *device, bool localized, void *name, bool default_); bool utox_video_change_device(uint16_t i); bool utox_video_start(bool preview); bool utox_video_stop(bool preview); void utox_video_thread(void *args); void postmessage_video(uint8_t msg, uint32_t param1, uint32_t param2, void *data); // Color format conversion functions void yuv420tobgr(uint16_t width, uint16_t height, const uint8_t *y, const uint8_t *u, const uint8_t *v, unsigned int ystride, unsigned int ustride, unsigned int vstride, uint8_t *out); void yuv422to420(uint8_t *plane_y, uint8_t *plane_u, uint8_t *plane_v, uint8_t *input, uint16_t width, uint16_t height); void bgrtoyuv420(uint8_t *plane_y, uint8_t *plane_u, uint8_t *plane_v, uint8_t *rgb, uint16_t width, uint16_t height); void bgrxtoyuv420(uint8_t *plane_y, uint8_t *plane_u, uint8_t *plane_v, uint8_t *rgb, uint16_t width, uint16_t height); // TODO: Documentation. void scale_rgbx_image(uint8_t *old_rgbx, uint16_t old_width, uint16_t old_height, uint8_t *new_rgbx, uint16_t new_width, uint16_t new_height); #endif uTox/src/av/video.c0000600000175000001440000004064314003056216013154 0ustar rakusers#include "video.h" #include "utox_av.h" #include "../friend.h" #include "../debug.h" #include "../macros.h" #include "../self.h" #include "../settings.h" #include "../tox.h" #include "../utox.h" #include "../native/thread.h" #include "../native/video.h" #include #include #include #include #include bool utox_video_thread_init = false; uint16_t video_width, video_height, max_video_width, max_video_height; static void * video_device[16] = { NULL }; /* TODO; magic number */ static int16_t video_device_count = 0; static uint32_t video_device_current = 0; static bool video_active = false; static utox_av_video_frame utox_video_frame; static bool video_device_status = false; static vpx_image_t input; static pthread_mutex_t video_thread_lock; static bool video_device_init(void *handle) { // initialize video (will populate video_width and video_height) if (handle == (void *)1) { if (!native_video_init((void *)1)) { LOG_TRACE("uToxVideo", "native_video_init() failed for desktop" ); return false; } } else { if (!handle || !native_video_init(*(void **)handle)) { LOG_TRACE("uToxVideo", "native_video_init() failed webcam" ); return false; } } vpx_img_alloc(&input, VPX_IMG_FMT_I420, video_width, video_height, 1); utox_video_frame.y = input.planes[0]; utox_video_frame.u = input.planes[1]; utox_video_frame.v = input.planes[2]; utox_video_frame.w = input.d_w; utox_video_frame.h = input.d_h; LOG_NOTE("uToxVideo", "video init done!" ); video_device_status = true; return true; } static void close_video_device(void *handle) { if (handle >= (void *)2) { native_video_close(*(void **)handle); vpx_img_free(&input); } video_device_status = false; } static bool video_device_start(void) { if (video_device_status) { native_video_startread(); video_active = true; return true; } video_active = false; return false; } static bool video_device_stop(void) { if (video_device_status) { native_video_endread(); video_active = false; return true; } video_active = false; return false; } #include "../ui/dropdown.h" #include "../layout/settings.h" // TODO move? void utox_video_append_device(void *device, bool localized, void *name, bool default_) { video_device[video_device_count++] = device; if (localized) { // Device name is localized with name containing UTOX_I18N_STR. // device is device handle pointer. dropdown_list_add_localized(&dropdown_video, (UTOX_I18N_STR)name, device); } else { // Device name is a hardcoded string. // device is a pointer to a buffer, that contains device handle pointer, // followed by device name string. dropdown_list_add_hardcoded(&dropdown_video, name, *(void **)device); } /* TODO remove all default settings */ // default == true, if this device will be chosen by video detecting code. if (default_) { dropdown_video.selected = dropdown_video.over = (dropdown_video.dropcount - 1); } } bool utox_video_change_device(uint16_t device_number) { pthread_mutex_lock(&video_thread_lock); static bool _was_active = false; if (!device_number) { video_device_current = 0; if (video_active) { video_device_stop(); close_video_device(video_device[video_device_current]); if (settings.video_preview) { settings.video_preview = false; postmessage_utox(AV_CLOSE_WINDOW, 0, 0, NULL); } } LOG_TRACE("uToxVideo", "Disabled Video device (none)" ); goto mutex_unlock; } if (video_active) { _was_active = true; video_device_stop(); close_video_device(video_device[video_device_current]); } else { _was_active = false; } video_device_current = device_number; if (!video_device_init(video_device[device_number])) { goto mutex_unlock; } if (!_was_active) { /* Just grab the new frame size */ if (video_device_status) { close_video_device(video_device[video_device_current]); } goto mutex_unlock; } LOG_TRACE("uToxVideo", "Trying to restart video with new device..." ); if (!video_device_start()) { LOG_ERR("uToxVideo", "Error, unable to start new device..."); if (settings.video_preview) { settings.video_preview = false; postmessage_utox(AV_CLOSE_WINDOW, 0, 0, NULL); } goto mutex_unlock; } pthread_mutex_unlock(&video_thread_lock); return true; mutex_unlock: pthread_mutex_unlock(&video_thread_lock); return false; } bool utox_video_start(bool preview) { if (video_active) { LOG_NOTE("uToxVideo", "video already running" ); return true; } if (!video_device_current) { LOG_NOTE("uToxVideo", "Not starting device None" ); return false; } if (preview) { settings.video_preview = true; } if (video_device_init(video_device[video_device_current]) && video_device_start()) { video_active = true; LOG_NOTE("uToxVideo", "started video" ); return true; } LOG_ERR("uToxVideo", "Unable to start video."); return false; } bool utox_video_stop(bool UNUSED(preview)) { if (!video_active) { LOG_TRACE("uToxVideo", "video already stopped!" ); return false; } video_active = false; settings.video_preview = false; postmessage_utox(AV_CLOSE_WINDOW, 0, 0, NULL); video_device_stop(); close_video_device(video_device[video_device_current]); LOG_TRACE("uToxVideo", "stopped video" ); return true; } static TOX_MSG video_msg; void postmessage_video(uint8_t msg, uint32_t param1, uint32_t param2, void *data) { while (video_thread_msg) { yieldcpu(1); } video_msg.msg = msg; video_msg.param1 = param1; video_msg.param2 = param2; video_msg.data = data; video_thread_msg = true; } // Populates the video device dropdown. static void init_video_devices(void) { // Add always-present null video input device. utox_video_append_device(NULL, 1, (void *)STR_VIDEO_IN_NONE, 1); // select a video device (autodectect) video_device_current = native_video_detect(); if (video_device_current) { // open the video device to get some info e.g. frame size // close it afterwards to not block the device while it is not used if (video_device_init(video_device[video_device_current])) { close_video_device(video_device[video_device_current]); } } } void utox_video_thread(void *args) { ToxAV *av = args; pthread_mutex_init(&video_thread_lock, NULL); init_video_devices(); utox_video_thread_init = 1; while (1) { if (video_thread_msg) { if (!video_msg.msg || video_msg.msg == UTOXVIDEO_KILL) { break; } switch (video_msg.msg) { case UTOXVIDEO_NEW_AV_INSTANCE: { av = video_msg.data; init_video_devices(); break; } } video_thread_msg = false; } if (video_active) { pthread_mutex_lock(&video_thread_lock); // capturing is enabled, capture frames const int r = native_video_getframe(utox_video_frame.y, utox_video_frame.u, utox_video_frame.v, utox_video_frame.w, utox_video_frame.h); if (r == 1) { if (settings.video_preview) { /* Make a copy of the video frame for uTox to display */ UTOX_FRAME_PKG *frame = malloc(sizeof(UTOX_FRAME_PKG)); frame->w = utox_video_frame.w; frame->h = utox_video_frame.h; frame->img = malloc(utox_video_frame.w * utox_video_frame.h * 4); yuv420tobgr(utox_video_frame.w, utox_video_frame.h, utox_video_frame.y, utox_video_frame.u, utox_video_frame.v, utox_video_frame.w, (utox_video_frame.w / 2), (utox_video_frame.w / 2), frame->img); postmessage_utox(AV_VIDEO_FRAME, UINT16_MAX, 1, (void *)frame); } size_t active_video_count = 0; for (size_t i = 0; i < self.friend_list_count; i++) { if (SEND_VIDEO_FRAME(i)) { LOG_TRACE("uToxVideo", "sending video frame to friend %lu" , i); active_video_count++; TOXAV_ERR_SEND_FRAME error = 0; FRIEND *f = get_friend(i); if (!f) { LOG_ERR("uToxVideo", "Could not get friend to send him video frame %lu", i); continue; } toxav_video_send_frame(av, f->number, utox_video_frame.w, utox_video_frame.h, utox_video_frame.y, utox_video_frame.u, utox_video_frame.v, &error); // LOG_TRACE("uToxVideo", "Sent video frame to friend %u" , i); if (error) { if (error == TOXAV_ERR_SEND_FRAME_SYNC) { LOG_ERR("uToxVideo", "Vid Frame sync error: w=%u h=%u", utox_video_frame.w, utox_video_frame.h); } else if (error == TOXAV_ERR_SEND_FRAME_PAYLOAD_TYPE_DISABLED) { LOG_ERR("uToxVideo", "ToxAV disagrees with our AV state for friend %lu, self %u, friend %u", i, f->call_state_self, f->call_state_friend); } else { LOG_ERR("uToxVideo", "toxav_send_video error friend: %i error: %u", f->number, error); } } else { if (active_video_count >= UTOX_MAX_CALLS) { LOG_ERR("uToxVideo", "Trying to send video frame to too many peers. Please report this bug!"); break; } } } } } else if (r == -1) { LOG_ERR("uToxVideo", "Err... something really bad happened trying to get this frame, I'm just going " "to plots now!"); video_device_stop(); close_video_device(video_device); } pthread_mutex_unlock(&video_thread_lock); yieldcpu(1000 / settings.video_fps); /* 60fps = 16.666ms || 25 fps = 40ms || the data quality is SO much better at 25... */ continue; /* We're running video, so don't sleep for an extra 100 ms */ } yieldcpu(100); } video_device_count = 0; video_device_current = 0; video_active = false; for (uint8_t i = 0; i < 16; ++i) { video_device[i] = NULL; } video_thread_msg = 0; utox_video_thread_init = 0; LOG_TRACE("uToxVideo", "Clean thread exit!"); } void yuv420tobgr(uint16_t width, uint16_t height, const uint8_t *y, const uint8_t *u, const uint8_t *v, unsigned int ystride, unsigned int ustride, unsigned int vstride, uint8_t *out) { for (unsigned long int i = 0; i < height; ++i) { for (unsigned long int j = 0; j < width; ++j) { uint8_t *point = out + 4 * ((i * width) + j); int t_y = y[((i * ystride) + j)]; const int t_u = u[(((i / 2) * ustride) + (j / 2))]; const int t_v = v[(((i / 2) * vstride) + (j / 2))]; t_y = t_y < 16 ? 16 : t_y; const int r = (298 * (t_y - 16) + 409 * (t_v - 128) + 128) >> 8; const int g = (298 * (t_y - 16) - 100 * (t_u - 128) - 208 * (t_v - 128) + 128) >> 8; const int b = (298 * (t_y - 16) + 516 * (t_u - 128) + 128) >> 8; point[2] = r > 255 ? 255 : r < 0 ? 0 : r; point[1] = g > 255 ? 255 : g < 0 ? 0 : g; point[0] = b > 255 ? 255 : b < 0 ? 0 : b; point[3] = ~0; } } } void yuv422to420(uint8_t *plane_y, uint8_t *plane_u, uint8_t *plane_v, uint8_t *input, uint16_t width, uint16_t height) { const uint8_t *end = input + width * height * 2; while (input != end) { uint8_t *line_end = input + width * 2; while (input != line_end) { *plane_y++ = *input++; *plane_v++ = *input++; *plane_y++ = *input++; *plane_u++ = *input++; } line_end = input + width * 2; while (input != line_end) { *plane_y++ = *input++; input++; // u *plane_y++ = *input++; input++; // v } } } static uint8_t rgb_to_y(int r, int g, int b) { const int y = ((9798 * r + 19235 * g + 3736 * b) >> 15); return y > 255 ? 255 : y < 0 ? 0 : y; } static uint8_t rgb_to_u(int r, int g, int b) { const int u = ((-5538 * r + -10846 * g + 16351 * b) >> 15) + 128; return u > 255 ? 255 : u < 0 ? 0 : u; } static uint8_t rgb_to_v(int r, int g, int b) { const int v = ((16351 * r + -13697 * g + -2664 * b) >> 15) + 128; return v > 255 ? 255 : v < 0 ? 0 : v; } void bgrtoyuv420(uint8_t *plane_y, uint8_t *plane_u, uint8_t *plane_v, uint8_t *rgb, uint16_t width, uint16_t height) { uint8_t *p; uint8_t r, g, b; for (uint16_t y = 0; y != height; y += 2) { p = rgb; for (uint16_t x = 0; x != width; x++) { b = *rgb++; g = *rgb++; r = *rgb++; *plane_y++ = rgb_to_y(r, g, b); } for (uint16_t x = 0; x != width / 2; x++) { b = *rgb++; g = *rgb++; r = *rgb++; *plane_y++ = rgb_to_y(r, g, b); b = *rgb++; g = *rgb++; r = *rgb++; *plane_y++ = rgb_to_y(r, g, b); b = ((int)b + (int)*(rgb - 6) + (int)*p + (int)*(p + 3) + 2) / 4; p++; g = ((int)g + (int)*(rgb - 5) + (int)*p + (int)*(p + 3) + 2) / 4; p++; r = ((int)r + (int)*(rgb - 4) + (int)*p + (int)*(p + 3) + 2) / 4; p++; *plane_u++ = rgb_to_u(r, g, b); *plane_v++ = rgb_to_v(r, g, b); p += 3; } } } void bgrxtoyuv420(uint8_t *plane_y, uint8_t *plane_u, uint8_t *plane_v, uint8_t *rgb, uint16_t width, uint16_t height) { uint8_t *p; uint8_t r, g, b; for (uint16_t y = 0; y != height; y += 2) { p = rgb; for (uint16_t x = 0; x != width; x++) { b = *rgb++; g = *rgb++; r = *rgb++; rgb++; *plane_y++ = rgb_to_y(r, g, b); } for (uint16_t x = 0; x != width / 2; x++) { b = *rgb++; g = *rgb++; r = *rgb++; rgb++; *plane_y++ = rgb_to_y(r, g, b); b = *rgb++; g = *rgb++; r = *rgb++; rgb++; *plane_y++ = rgb_to_y(r, g, b); b = ((int)b + (int)*(rgb - 8) + (int)*p + (int)*(p + 4) + 2) / 4; p++; g = ((int)g + (int)*(rgb - 7) + (int)*p + (int)*(p + 4) + 2) / 4; p++; r = ((int)r + (int)*(rgb - 6) + (int)*p + (int)*(p + 4) + 2) / 4; p++; p++; *plane_u++ = rgb_to_u(r, g, b); *plane_v++ = rgb_to_v(r, g, b); p += 4; } } } void scale_rgbx_image(uint8_t *old_rgbx, uint16_t old_width, uint16_t old_height, uint8_t *new_rgbx, uint16_t new_width, uint16_t new_height) { for (int y = 0; y != new_height; y++) { const int y0 = y * old_height / new_height; for (int x = 0; x != new_width; x++) { const int x0 = x * old_width / new_width; const int a = x + y * new_width; const int b = x0 + y0 * old_width; new_rgbx[a * 4] = old_rgbx[b * 4]; new_rgbx[a * 4 + 1] = old_rgbx[b * 4 + 1]; new_rgbx[a * 4 + 2] = old_rgbx[b * 4 + 2]; } } } uTox/src/av/utox_av.h0000600000175000001440000000360014003056216013530 0ustar rakusers/* toxav thread messages (sent from the client thread to the audio or video thread) */ #ifndef UTOX_AV_H #define UTOX_AV_H #include // if it weren't for TOXAV_CALL_CONTROL we could move this to the .c #include extern bool utox_av_ctrl_init; #define UTOX_MAX_CALLS 16 // UTOX_MAX_VIDEO_CALLS is never used. Remove? #define UTOX_MAX_VIDEO_CALLS 32 /* utox av thread commands */ enum { UTOXAV_KILL, UTOXAV_INCOMING_CALL_PENDING, UTOXAV_INCOMING_CALL_ANSWER, UTOXAV_INCOMING_CALL_REJECT, UTOXAV_OUTGOING_CALL_PENDING, UTOXAV_OUTGOING_CALL_ACCEPTED, UTOXAV_OUTGOING_CALL_REJECTED, UTOXAV_CALL_END, UTOXAV_GROUPCALL_START, UTOXAV_GROUPCALL_END, UTOXAV_START_AUDIO, UTOXAV_STOP_AUDIO, UTOXAV_START_VIDEO, UTOXAV_STOP_VIDEO, UTOXAV_SET_AUDIO_IN, UTOXAV_SET_AUDIO_OUT, UTOXAV_SET_VIDEO_IN, UTOXAV_SET_VIDEO_OUT, UTOXAV_NEW_TOX_INSTANCE, }; enum { // kill the video thread UTOXVIDEO_KILL, UTOXVIDEO_NEW_AV_INSTANCE, /* UTOXVIDEO_RECORD_START, UTOXVIDEO_RECORD_STOP, UTOXVIDEO_SET, UTOXVIDEO_PREVIEW_START, UTOXVIDEO_PREVIEW_STOP, */ }; typedef struct groupchat GROUPCHAT; /* send a message to the toxav thread */ void postmessage_utoxav(uint8_t msg, uint32_t param1, uint32_t param2, void *data); void utox_av_ctrl_thread(void *args); void utox_av_local_disconnect(ToxAV *av, int32_t friend_number); void utox_av_local_call_control(ToxAV *av, uint32_t friend_number, TOXAV_CALL_CONTROL control); void set_av_callbacks(ToxAV *av); void callback_av_group_audio(void *tox, uint32_t groupnumber, uint32_t peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata); void group_av_peer_add(GROUPCHAT *g, int peernumber); void group_av_peer_remove(GROUPCHAT *g, int peernumber); #endif uTox/src/av/utox_av.c0000600000175000001440000005520314003056216013531 0ustar rakusers#include "utox_av.h" #include "audio.h" #include "video.h" #include "../debug.h" #include "../flist.h" #include "../friend.h" #include "../groups.h" #include "../inline_video.h" #include "../macros.h" #include "../tox.h" #include "../utox.h" #include "../ui.h" #include "../native/audio.h" #include "../native/thread.h" #include #include bool utox_av_ctrl_init = false; static bool toxav_thread_msg = 0; void postmessage_utoxav(uint8_t msg, uint32_t param1, uint32_t param2, void *data) { while (toxav_thread_msg && utox_av_ctrl_init) { /* I'm not convinced this is the best way */ yieldcpu(1); } toxav_msg.msg = msg; toxav_msg.param1 = param1; toxav_msg.param2 = param2; toxav_msg.data = data; toxav_thread_msg = 1; } void utox_av_ctrl_thread(void *UNUSED(args)) { ToxAV *av = NULL; utox_av_ctrl_init = 1; LOG_TRACE("uToxAv", "Toxav thread init" ); volatile uint32_t call_count = 0; volatile bool audio_in = 0; // volatile bool video_on = 0; while (1) { if (toxav_thread_msg) { TOX_MSG *msg = &toxav_msg; if (msg->msg == UTOXAV_KILL) { break; } else if (msg->msg == UTOXAV_NEW_TOX_INSTANCE) { if (av) { /* toxcore restart */ toxav_kill(av); postmessage_audio(UTOXAUDIO_NEW_AV_INSTANCE, 0, 0, msg->data); postmessage_video(UTOXVIDEO_NEW_AV_INSTANCE, 0, 0, msg->data); } else { thread(utox_audio_thread, msg->data); thread(utox_video_thread, msg->data); } av = msg->data; set_av_callbacks(av); } if (!utox_audio_thread_init || !utox_video_thread_init) { yieldcpu(10); } switch (msg->msg) { case UTOXAV_INCOMING_CALL_PENDING: { call_count++; postmessage_audio(UTOXAUDIO_PLAY_RINGTONE, msg->param1, msg->param2, NULL); break; } case UTOXAV_INCOMING_CALL_ANSWER: { FRIEND *f = get_friend(msg->param1); if (!f) { LOG_ERR("uToxAV", "Could not to get friend when INCOMING_CALL_ANSWER %u", msg->param1); break; } f->call_started = time(NULL); message_add_type_notice(&f->msg, S(CALL_STARTED), SLEN(CALL_STARTED), true); postmessage_audio(UTOXAUDIO_STOP_RINGTONE, msg->param1, msg->param2, NULL); postmessage_audio(UTOXAUDIO_START_FRIEND, msg->param1, msg->param2, NULL); f->call_state_self = (TOXAV_FRIEND_CALL_STATE_SENDING_A | TOXAV_FRIEND_CALL_STATE_ACCEPTING_A); if (msg->param2) { utox_video_start(0); f->call_state_self |= (TOXAV_FRIEND_CALL_STATE_SENDING_V | TOXAV_FRIEND_CALL_STATE_ACCEPTING_V); } break; } case UTOXAV_INCOMING_CALL_REJECT: { call_count--; postmessage_audio(UTOXAUDIO_STOP_RINGTONE, msg->param1, msg->param2, NULL); break; } case UTOXAV_OUTGOING_CALL_PENDING: { call_count++; postmessage_audio(UTOXAUDIO_PLAY_RINGTONE, msg->param1, msg->param2, NULL); FRIEND *f = get_friend(msg->param1); if (!f) { LOG_ERR("uToxAV", "Could not to get friend when OUTGOING_CALL_PENDING %u", msg->param1); break; } f->call_state_self = (TOXAV_FRIEND_CALL_STATE_SENDING_A | TOXAV_FRIEND_CALL_STATE_ACCEPTING_A); if (msg->param2) { utox_video_start(0); f->call_state_self |= (TOXAV_FRIEND_CALL_STATE_SENDING_V | TOXAV_FRIEND_CALL_STATE_ACCEPTING_V); } break; } case UTOXAV_OUTGOING_CALL_ACCEPTED: { FRIEND *f = get_friend(msg->param1); if (!f) { LOG_ERR("uToxAV", "Could not to get friend when OUTGOING_CALL_ACCEPTED %u", msg->param1); break; } f->call_started = time(NULL); message_add_type_notice(&f->msg, S(CALL_STARTED), SLEN(CALL_STARTED), true); postmessage_audio(UTOXAUDIO_START_FRIEND, msg->param1, msg->param2, NULL); postmessage_audio(UTOXAUDIO_STOP_RINGTONE, msg->param1, msg->param2, NULL); LOG_NOTE("uToxAV", "Call accepted by friend" ); break; } case UTOXAV_OUTGOING_CALL_REJECTED: { postmessage_audio(UTOXAUDIO_STOP_RINGTONE, msg->param1, msg->param2, NULL); break; } case UTOXAV_CALL_END: { call_count--; FRIEND *f = get_friend(msg->param1); if (f && f->call_state_self & (TOXAV_FRIEND_CALL_STATE_SENDING_V | TOXAV_FRIEND_CALL_STATE_ACCEPTING_V)) { utox_video_stop(false); } if (f && f->call_started != 0) { char notice_msg[64]; int duration = difftime(time(NULL), f->call_started); snprintf(notice_msg, sizeof(notice_msg), "%s: %02u:%02u:%02u", S(CALL_ENDED), duration / 3600, (duration / 60) % 60, duration % 60); int notice_msg_len = strnlen(notice_msg, sizeof(notice_msg) - 1); if (notice_msg_len < 64) { message_add_type_notice(&f->msg, notice_msg, notice_msg_len, true); } f->call_started = 0; } postmessage_audio(UTOXAUDIO_STOP_FRIEND, msg->param1, msg->param2, NULL); postmessage_audio(UTOXAUDIO_STOP_RINGTONE, msg->param1, msg->param2, NULL); break; } case UTOXAV_GROUPCALL_START: { call_count++; LOG_INFO("uToxAv", "Starting group call in groupchat %u", msg->param1); postmessage_audio(UTOXAUDIO_GROUPCHAT_START, msg->param1, msg->param2, NULL); break; } case UTOXAV_GROUPCALL_END: { GROUPCHAT *g = get_group(msg->param1); if (!g) { LOG_ERR("uToxAv", "Could not get group %u", msg->param1); break; } if (!call_count) { LOG_ERR("uToxAv", "Trying to end a call when no call is active."); break; } LOG_INFO("uToxAv", "Ending group call in groupchat %u", msg->param1); postmessage_audio(UTOXAUDIO_GROUPCHAT_STOP, msg->param1, msg->param2, NULL); call_count--; break; } case UTOXAV_START_AUDIO: { if (msg->param1) { /* Start audio preview */ call_count++; LOG_TRACE("uToxAV", "Starting Audio Preview" ); postmessage_audio(UTOXAUDIO_START_PREVIEW, 0, 0, NULL); } break; } case UTOXAV_STOP_AUDIO: { if (!call_count) { LOG_TRACE("uToxAV", "WARNING, trying to stop audio while already closed!\nThis is bad!" ); break; } if (msg->param1) { call_count--; LOG_TRACE("uToxAV", "Stopping Audio Preview" ); postmessage_audio(UTOXAUDIO_STOP_PREVIEW, 0, 0, NULL); } break; } case UTOXAV_START_VIDEO: { if (msg->param2) { utox_video_start(1); } else { utox_video_start(0); TOXAV_ERR_BIT_RATE_SET bitrate_err = 0; toxav_video_set_bit_rate(av, msg->param1, UTOX_DEFAULT_BITRATE_V, &bitrate_err); } break; } case UTOXAV_STOP_VIDEO: { if (msg->param2) { utox_video_stop(1); } else { utox_video_stop(0); TOXAV_ERR_BIT_RATE_SET bitrate_err = 0; toxav_video_set_bit_rate(av, msg->param1, -1, &bitrate_err); } postmessage_utox(AV_CLOSE_WINDOW, msg->param1, 0, NULL); break; } case UTOXAV_SET_AUDIO_IN: { LOG_TRACE("uToxAV", "Set audio in" ); if (audio_in) { postmessage_audio(UTOXAUDIO_CHANGE_MIC, 0, 0, NULL); } utox_audio_in_device_set(msg->data); if (msg->data != utox_audio_in_device_get()) { LOG_TRACE("uToxAV", "Error changing audio in" ); audio_in = 0; call_count = 0; break; } // TODO get a count in audio.c and allow count restore // if (audio_in) { // utox_audio_in_device_open(); // utox_audio_in_listen(); // } break; } case UTOXAV_SET_AUDIO_OUT: { LOG_TRACE("uToxAV", "Set audio out" ); postmessage_audio(UTOXAUDIO_CHANGE_SPEAKER, 0, 0, NULL); utox_audio_out_device_set(msg->data); break; } case UTOXAV_SET_VIDEO_IN: { utox_video_change_device(msg->param1); LOG_TRACE("uToxAV", "Changed video input device" ); break; } case UTOXAV_SET_VIDEO_OUT: { break; } } } toxav_thread_msg = false; if (av) { toxav_iterate(av); yieldcpu(toxav_iteration_interval(av)); } else { yieldcpu(10); } } postmessage_audio(UTOXAUDIO_KILL, 0, 0, NULL); postmessage_video(UTOXVIDEO_KILL, 0, 0, NULL); // Wait for all a/v threads to return 0 while (utox_audio_thread_init || utox_video_thread_init) { yieldcpu(1); } toxav_kill(av); utox_av_ctrl_init = false; LOG_NOTE("UTOXAV", "Clean thread exit!"); return; } static void utox_av_incoming_call(ToxAV *UNUSED(av), uint32_t friend_number, bool audio, bool video, void *UNUSED(userdata)) { LOG_TRACE("uToxAV", "A/V Invite (%u)" , friend_number); FRIEND *f = get_friend(friend_number); if (!f) { LOG_ERR("uToxAV", "Unable to get friend %u for A/V invite.", friend_number); return; } f->call_state_self = 0; f->call_state_friend = (audio << 2 | video << 3 | audio << 4 | video << 5); LOG_TRACE("uToxAV", "uTox AV:\tcall friend (%u) state for incoming call: %i" , friend_number, f->call_state_friend); postmessage_utoxav(UTOXAV_INCOMING_CALL_PENDING, friend_number, 0, NULL); postmessage_utox(AV_CALL_INCOMING, friend_number, video, NULL); } static void utox_av_remote_disconnect(ToxAV *UNUSED(av), int32_t friend_number) { LOG_TRACE("uToxAV", "Remote disconnect from friend %u" , friend_number); FRIEND *f = get_friend(friend_number); if (!f) { LOG_ERR("uToxAV", "Unable to get friend %u for remote disconnect.", friend_number); return; } postmessage_utoxav(UTOXAV_CALL_END, friend_number, 0, NULL); f->call_state_self = 0; f->call_state_friend = 0; postmessage_utox(AV_CLOSE_WINDOW, friend_number + 1, 0, NULL); postmessage_utox(AV_CALL_DISCONNECTED, friend_number, 0, NULL); } void utox_av_local_disconnect(ToxAV *av, int32_t friend_number) { TOXAV_ERR_CALL_CONTROL error = 0; if (av) { /* TODO HACK: tox_callbacks doesn't have access to toxav, so it just sets it as NULL, this is bad! */ toxav_call_control(av, friend_number, TOXAV_CALL_CONTROL_CANCEL, &error); } switch (error) { case TOXAV_ERR_CALL_CONTROL_OK: { LOG_NOTE("uToxAV", "ToxAV has disconnected!" ); break; } case TOXAV_ERR_CALL_CONTROL_SYNC: { LOG_ERR("uToxAV", "ToxAV sync error!"); break; } case TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_FOUND: { LOG_ERR("uToxAV", "ToxAV friend #%i not found." , friend_number); break; } case TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_IN_CALL: { LOG_ERR("uToxAV", "ToxAV no existing call for friend #%i." , friend_number); break; } case TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION: { LOG_NOTE("uToxAV", "Call already paused, or already running." ); break; } } FRIEND *f = get_friend(friend_number); if (!f) { LOG_ERR("uToxAV", "Unable to get friend %u for A/V disconnect.", friend_number); return; } f->call_state_self = 0; f->call_state_friend = 0; postmessage_utox(AV_CLOSE_WINDOW, friend_number + 1, 0, NULL); /* TODO move all of this into a static function in that file !*/ postmessage_utox(AV_CALL_DISCONNECTED, friend_number, 0, NULL); postmessage_utoxav(UTOXAV_CALL_END, friend_number, 0, NULL); } void utox_av_local_call_control(ToxAV *av, uint32_t friend_number, TOXAV_CALL_CONTROL control) { TOXAV_ERR_CALL_CONTROL err = 0; toxav_call_control(av, friend_number, control, &err); if (err) { LOG_TRACE("uToxAV", "Local call control error!" ); return; } TOXAV_ERR_BIT_RATE_SET bitrate_err = 0; FRIEND *f = get_friend(friend_number); if (!f) { LOG_ERR("uToxAV", "Unable to get friend %u for local call control.", friend_number); return; } switch (control) { case TOXAV_CALL_CONTROL_HIDE_VIDEO: { toxav_video_set_bit_rate(av, friend_number, 0, &bitrate_err); postmessage_utoxav(UTOXAV_STOP_VIDEO, friend_number, 0, NULL); f->call_state_self &= (0xFF ^ TOXAV_FRIEND_CALL_STATE_SENDING_V); break; } case TOXAV_CALL_CONTROL_SHOW_VIDEO: { toxav_video_set_bit_rate(av, friend_number, UTOX_DEFAULT_BITRATE_V, &bitrate_err); postmessage_utoxav(UTOXAV_START_VIDEO, friend_number, 0, NULL); f->call_state_self |= TOXAV_FRIEND_CALL_STATE_SENDING_V; break; } default: { LOG_ERR("uToxAV", "Unhandled local call control"); } // TODO // TOXAV_CALL_CONTROL_RESUME, // TOXAV_CALL_CONTROL_PAUSE, // TOXAV_CALL_CONTROL_CANCEL, // TOXAV_CALL_CONTROL_MUTE_AUDIO, // TOXAV_CALL_CONTROL_UNMUTE_AUDIO, } if (bitrate_err) { LOG_ERR("uToxAV", "Error setting/changing video bitrate"); } } // responds to a audio frame call back from toxav static void utox_av_incoming_frame_a(ToxAV *UNUSED(av), uint32_t friend_number, const int16_t *pcm, size_t sample_count, uint8_t channels, uint32_t sample_rate, void *UNUSED(userdata)) { // LOG_TRACE("uToxAv", "Incoming audio frame for friend %u " , friend_number); #ifdef NATIVE_ANDROID_AUDIO audio_play(friend_number, pcm, sample_count, channels); #else sourceplaybuffer(friend_number, pcm, sample_count, channels, sample_rate); #endif } static void utox_av_incoming_frame_v(ToxAV *UNUSED(toxAV), uint32_t friend_number, uint16_t width, uint16_t height, const uint8_t *y, const uint8_t *u, const uint8_t *v, int32_t ystride, int32_t ustride, int32_t vstride, void *UNUSED(user_data)) { /* copy the vpx_image */ /* 4 bits for the H*W, then a pixel for each color * size */ LOG_TRACE("uToxAV", "new video frame from friend %u" , friend_number); FRIEND *f = get_friend(friend_number); if (f == NULL) { LOG_ERR("uToxAV", "Incoming frame for a friend we don't know about! (%u)", friend_number); return; } f->video_width = width; f->video_height = height; size_t size = width * height * 4; UTOX_FRAME_PKG *frame = calloc(1, sizeof(UTOX_FRAME_PKG)); if (!frame) { LOG_ERR("uToxAV", "Can't malloc for incoming frame."); return; } frame->w = width; frame->h = height; frame->size = size; frame->img = malloc(size); if (!frame->img) { LOG_TRACE("uToxAV", "Could not allocate memory for image."); free(frame); return; } yuv420tobgr(width, height, y, u, v, ystride, ustride, vstride, frame->img); if (f->video_inline) { if (!inline_set_frame(width, height, size, frame->img)) { LOG_ERR("uToxAV", "Error setting frame for inline video."); } postmessage_utox(AV_INLINE_FRAME, friend_number, 0, NULL); free(frame->img); free(frame); } else { postmessage_utox(AV_VIDEO_FRAME, friend_number, 0, (void *)frame); } } static void utox_audio_friend_accepted(ToxAV *av, uint32_t friend_number, uint32_t state) { /* First accepted call back */ LOG_NOTE("uToxAV", "Friend accepted call" ); FRIEND *f = get_friend(friend_number); if (!f) { LOG_FATAL_ERR(EXIT_FAILURE, "uToxAV", "Unable to get friend when A/V call accepted %u", friend_number); } f->call_state_friend = state; if (SELF_SEND_VIDEO(friend_number) && !FRIEND_ACCEPTING_VIDEO(friend_number)) { utox_av_local_call_control(av, friend_number, TOXAV_CALL_CONTROL_HIDE_VIDEO); } postmessage_utoxav(UTOXAV_OUTGOING_CALL_ACCEPTED, friend_number, 0, NULL); postmessage_utox(AV_CALL_ACCEPTED, friend_number, 0, NULL); } /** respond to a Audio Video state change call back from toxav */ static void utox_callback_av_change_state(ToxAV *av, uint32_t friend_number, uint32_t state, void *UNUSED(userdata)) { FRIEND *f = get_friend(friend_number); if (!f) { LOG_ERR("uToxAV", "Unable to get friend when A/V state changed %u", friend_number); return; } if (state == 1) { // handle error LOG_ERR("uToxAV", "Change state with an error, this should never happen. Please send bug report!"); utox_av_remote_disconnect(av, friend_number); return; } else if (state == 2) { LOG_NOTE("uToxAV", "Call ended with friend_number %u." , friend_number); utox_av_remote_disconnect(av, friend_number); return; } else if (!f->call_state_friend) { utox_audio_friend_accepted(av, friend_number, state); } if (f->call_state_friend ^ (state & TOXAV_FRIEND_CALL_STATE_SENDING_A)) { if (state & TOXAV_FRIEND_CALL_STATE_SENDING_A) { LOG_INFO("uToxAV", "Friend %u is now sending audio." , friend_number); } else { LOG_INFO("uToxAV", "Friend %u is no longer sending audio." , friend_number); } } if (f->call_state_friend ^ (state & TOXAV_FRIEND_CALL_STATE_SENDING_V)) { if (state & TOXAV_FRIEND_CALL_STATE_SENDING_V) { LOG_INFO("uToxAV", "Friend %u is now sending video." , friend_number); } else { LOG_INFO("uToxAV", "Friend %u is no longer sending video." , friend_number); flist_reselect_current(); } } if (f->call_state_friend ^ (state & TOXAV_FRIEND_CALL_STATE_ACCEPTING_A)) { if (state & TOXAV_FRIEND_CALL_STATE_ACCEPTING_A) { LOG_INFO("uToxAV", "Friend %u is now accepting audio." , friend_number); } else { LOG_INFO("uToxAV", "Friend %u is no longer accepting audio." , friend_number); } } if (f->call_state_friend ^ (state & TOXAV_FRIEND_CALL_STATE_ACCEPTING_V)) { if (state & TOXAV_FRIEND_CALL_STATE_ACCEPTING_V) { LOG_INFO("uToxAV", "Friend %u is now accepting video." , friend_number); } else { LOG_INFO("uToxAV", "Friend %u is no longer accepting video." , friend_number); } } f->call_state_friend = state; } static void utox_incoming_video_rate_change(ToxAV *AV, uint32_t f_num, uint32_t v_bitrate, void *UNUSED(ud)) { /* Just accept what toxav wants the bitrate to be... */ if (v_bitrate > (uint32_t)UTOX_MIN_BITRATE_VIDEO) { TOXAV_ERR_BIT_RATE_SET error = 0; toxav_video_set_bit_rate(AV, f_num, v_bitrate, &error); if (error) { LOG_ERR("ToxAV", "Setting new Video bitrate has failed with error #%u" , error); } else { LOG_NOTE("uToxAV", "Video bitrate changed to %u" , v_bitrate); } } else { LOG_NOTE("uToxAV", "Video bitrate unchanged %u is less than %u" , v_bitrate, UTOX_MIN_BITRATE_VIDEO); } } static void utox_incoming_audio_rate_change(ToxAV *AV, uint32_t friend_number, uint32_t audio_bitrate, void *UNUSED(userdata)){ if (audio_bitrate > (uint32_t)UTOX_MIN_BITRATE_VIDEO) { TOXAV_ERR_BIT_RATE_SET error = 0; toxav_video_set_bit_rate(AV, friend_number, audio_bitrate, &error); if (error) { LOG_ERR("ToxAV", "Setting new audio bitrate has failed with error #%u" , error); } else { LOG_NOTE("uToxAV", "Audio bitrate changed to %u" , audio_bitrate); } } else { LOG_NOTE("uToxAV", "Audio bitrate unchanged %u is less than %u" , audio_bitrate, UTOX_MIN_BITRATE_AUDIO); } } void set_av_callbacks(ToxAV *av) { /* Friend update callbacks */ toxav_callback_call(av, &utox_av_incoming_call, NULL); toxav_callback_call_state(av, &utox_callback_av_change_state, NULL); /* Incoming data callbacks */ toxav_callback_audio_receive_frame(av, &utox_av_incoming_frame_a, NULL); toxav_callback_video_receive_frame(av, &utox_av_incoming_frame_v, NULL); /* Data type change callbacks. */ toxav_callback_video_bit_rate(av, &utox_incoming_video_rate_change, NULL); toxav_callback_audio_bit_rate(av, &utox_incoming_audio_rate_change, NULL); } uTox/src/av/filter_audio.h0000600000175000001440000000055214003056216014514 0ustar rakusers#ifndef FILTER_AUDIO_H #define FILTER_AUDIO_H #include #ifdef AUDIO_FILTERING #include #else #include typedef uint8_t Filter_Audio; #endif extern Filter_Audio *f_a; /* * enable/disable audio filtering according to settings * * returns resulting status of audio filtering */ bool filter_audio_check(void); #endif uTox/src/av/filter_audio.c0000600000175000001440000000142614003056216014510 0ustar rakusers#include "filter_audio.h" #include "audio.h" #include "../settings.h" #include #ifdef AUDIO_FILTERING #include #endif Filter_Audio *f_a = NULL; bool filter_audio_check(void) { #ifdef AUDIO_FILTERING if (!f_a && settings.audio_filtering_enabled) { f_a = new_filter_audio(UTOX_DEFAULT_SAMPLE_RATE_A); if (!f_a) { LOG_INFO("Filter Audio", "filter audio failed" ); return false; } LOG_INFO("Filter Audio", "filter audio on" ); } else if (f_a && !settings.audio_filtering_enabled) { kill_filter_audio(f_a); f_a = NULL; LOG_INFO("Filter Audio", "filter audio off" ); return false; } return settings.audio_filtering_enabled; #else return false; #endif } uTox/src/av/audio.h0000600000175000001440000000531114003056216013145 0ustar rakusers#ifndef AUDIO_H #define AUDIO_H #include #include #include #ifdef __APPLE__ #include #else #include #endif extern bool utox_audio_thread_init; enum { // kill the audio thread UTOXAUDIO_KILL, UTOXAUDIO_CHANGE_MIC, UTOXAUDIO_CHANGE_SPEAKER, UTOXAUDIO_START_FRIEND, UTOXAUDIO_STOP_FRIEND, UTOXAUDIO_GROUPCHAT_START, UTOXAUDIO_GROUPCHAT_STOP, UTOXAUDIO_START_PREVIEW, UTOXAUDIO_STOP_PREVIEW, UTOXAUDIO_PLAY_RINGTONE, UTOXAUDIO_STOP_RINGTONE, UTOXAUDIO_PLAY_NOTIFICATION, UTOXAUDIO_STOP_NOTIFICATION, UTOXAUDIO_NEW_AV_INSTANCE, }; enum { NOTIFY_TONE_NONE, NOTIFY_TONE_FRIEND_ONLINE, NOTIFY_TONE_FRIEND_OFFLINE, NOTIFY_TONE_FRIEND_NEW_MSG, NOTIFY_TONE_FRIEND_REQUEST, }; #define UTOX_DEFAULT_BITRATE_A 32 #define UTOX_MIN_BITRATE_AUDIO UTOX_DEFAULT_BITRATE_A //TODO: Find out what the minimum bit rate should be #define UTOX_DEFAULT_FRAME_A 20 #define UTOX_DEFAULT_SAMPLE_RATE_A 48000 #define UTOX_DEFAULT_AUDIO_CHANNELS 1 /* Check self */ #define UTOX_SENDING_AUDIO(f_number) (!!(get_friend(f_number)->call_state_self & TOXAV_FRIEND_CALL_STATE_SENDING_A)) // UTOX_ACCEPTING_AUDIO is unused. Delete? #define UTOX_ACCEPTING_AUDIO(f_number) (!!(get_friend(f_number)->call_state_self & TOXAV_FRIEND_CALL_STATE_ACCEPTING_A)) /* Check friend */ #define UTOX_AVAILABLE_AUDIO(f_number) (!!(get_friend(f_number)->call_state_friend & TOXAV_FRIEND_CALL_STATE_SENDING_A)) /* Check both */ #define UTOX_SEND_AUDIO(f_number) \ (!!(get_friend(f_number)->call_state_self & TOXAV_FRIEND_CALL_STATE_SENDING_A) \ && !!(get_friend(f_number)->call_state_friend & TOXAV_FRIEND_CALL_STATE_ACCEPTING_A)) // UTOX_ACCEPT_AUDIO is unused. Delete? #define UTOX_ACCEPT_AUDIO(f_number) \ (!!(get_friend(f_number)->call_state_self & TOXAV_FRIEND_CALL_STATE_ACCEPTING_A) \ && !!(get_friend(f_number)->call_state_friend & TOXAV_FRIEND_CALL_STATE_SENDING_A)) bool utox_audio_in_device_set(ALCdevice *new_device); bool utox_audio_out_device_set(ALCdevice *new_device); ALCdevice *utox_audio_in_device_get(void); // utox_audio_out_device_get is unused. Delete? ALCdevice *utox_audio_out_device_get(void); void utox_audio_in_device_open(void); void utox_audio_in_device_close(void); void utox_audio_in_listen(void); void utox_audio_in_ignore(void); void sourceplaybuffer(unsigned int i, const int16_t *data, int samples, uint8_t channels, unsigned int sample_rate); /* send a message to the audio thread */ void postmessage_audio(uint8_t msg, uint32_t param1, uint32_t param2, void *data); void utox_audio_thread(void *args); #endif uTox/src/av/audio.c0000600000175000001440000010102314003056216013135 0ustar rakusers#include "audio.h" #include "utox_av.h" #include "filter_audio.h" #include "../native/audio.h" #include "../native/keyboard.h" #include "../native/thread.h" #include "../native/time.h" #include "../debug.h" #include "../friend.h" #include "../groups.h" #include "../macros.h" #include "../main.h" // USER_STATUS_* #include "../self.h" #include "../settings.h" #include "../tox.h" #include "../utox.h" #include "../../langs/i18n_decls.h" #include #include #include #include #ifdef __APPLE__ #include #include #else #include #include #ifdef AUDIO_FILTERING #include #endif /* include for compatibility with older versions of OpenAL */ #ifndef ALC_ALL_DEVICES_SPECIFIER #include #endif #endif #ifdef AUDIO_FILTERING #include #endif static void utox_filter_audio_kill(Filter_Audio *filter_audio_handle) { #ifdef AUDIO_FILTERING kill_filter_audio(filter_audio_handle); #else (void)filter_audio_handle; #endif } bool utox_audio_thread_init = false; static ALCdevice *audio_out_handle, *audio_in_handle; static void * audio_out_device, *audio_in_device; static bool speakers_on, microphone_on; static int16_t speakers_count, microphone_count; /* TODO hacky fix. This source list should be a VLA with a way to link sources to friends. * NO SRSLY don't leave this like this! */ static ALuint ringtone, preview, notifytone; static ALuint RingBuffer, ToneBuffer; static bool audio_in_device_open(void) { if (!audio_in_device) { return false; } if (audio_in_device == (void *)1) { audio_in_handle = (void *)1; return true; } alGetError(); audio_in_handle = alcCaptureOpenDevice(audio_in_device, UTOX_DEFAULT_SAMPLE_RATE_A, AL_FORMAT_MONO16, (UTOX_DEFAULT_FRAME_A * UTOX_DEFAULT_SAMPLE_RATE_A * 4) / 1000); if (alGetError() == AL_NO_ERROR) { return true; } return false; } static bool audio_in_device_close(void) { if (audio_in_handle) { if (audio_in_handle == (void *)1) { audio_in_handle = NULL; microphone_on = false; return false; } if (microphone_on) { alcCaptureStop(audio_in_handle); } alcCaptureCloseDevice(audio_in_handle); } audio_in_handle = NULL; microphone_on = false; return false; } static bool audio_in_listen(void) { if (microphone_on) { microphone_count++; return true; } if (audio_in_handle) { if (audio_in_device == (void *)1) { audio_init(audio_in_handle); return true; } alcCaptureStart(audio_in_handle); } else if (audio_in_device) { /* Unable to get handle, try to open it again. */ audio_in_device_open(); if (audio_in_handle) { alcCaptureStart(audio_in_handle); } else { LOG_TRACE("uTox Audio", "Unable to listen to device!" ); } } if (audio_in_handle) { microphone_on = true; microphone_count = 1; return true; } microphone_on = false; microphone_count = 0; return false; } static bool audio_in_ignore(void) { if (!microphone_on) { return false; } if (--microphone_count > 0) { return true; } if (audio_in_handle) { if (audio_in_handle == (void *)1) { audio_close(audio_in_handle); microphone_on = false; microphone_count = 0; return false; } alcCaptureStop(audio_in_handle); } microphone_on = false; microphone_count = 0; return false; } bool utox_audio_in_device_set(ALCdevice *new_device) { if (microphone_on || microphone_count) { return false; } if (new_device) { audio_in_device = new_device; LOG_TRACE("uTox Audio", "Audio in device changed." ); return true; } audio_in_device = NULL; audio_in_handle = NULL; LOG_ERR("uTox Audio", "Audio out device set to null." ); return false; } ALCdevice *utox_audio_in_device_get(void) { if (audio_in_handle) { return audio_in_device; } return NULL; } static ALCcontext *context; static bool audio_out_device_open(void) { if (speakers_on) { speakers_count++; return true; } audio_out_handle = alcOpenDevice(audio_out_device); if (!audio_out_handle) { LOG_TRACE("uTox Audio", "alcOpenDevice() failed" ); speakers_on = false; return false; } context = alcCreateContext(audio_out_handle, NULL); if (!alcMakeContextCurrent(context)) { LOG_TRACE("uTox Audio", "alcMakeContextCurrent() failed" ); alcCloseDevice(audio_out_handle); audio_out_handle = NULL; speakers_on = false; return false; } ALint error; alGetError(); /* clear errors */ /* Create the buffers for the ringtone */ alGenSources((ALuint)1, &preview); if ((error = alGetError()) != AL_NO_ERROR) { LOG_TRACE("uTox Audio", "Error generating source with err %x" , error); speakers_on = false; speakers_count = 0; return false; } /* Create the buffers for incoming audio */ alGenSources((ALuint)1, &ringtone); if ((error = alGetError()) != AL_NO_ERROR) { LOG_TRACE("uTox Audio", "Error generating source with err %x" , error); speakers_on = false; speakers_count = 0; return false; } alGenSources((ALuint)1, ¬ifytone); if ((error = alGetError()) != AL_NO_ERROR) { LOG_TRACE("uTox Audio", "Error generating source with err %x" , error); speakers_on = false; speakers_count = 0; return false; } speakers_on = true; speakers_count = 1; return true; } static bool audio_out_device_close(void) { if (!audio_out_handle) { return false; } if (!speakers_on) { return false; } if (--speakers_count > 0) { return true; } alDeleteSources((ALuint)1, &preview); alDeleteSources((ALuint)1, &ringtone); alDeleteSources((ALuint)1, ¬ifytone); alcMakeContextCurrent(NULL); alcDestroyContext(context); alcCloseDevice(audio_out_handle); audio_out_handle = NULL; speakers_on = false; speakers_count = 0; return false; } bool utox_audio_out_device_set(ALCdevice *new_device) { if (new_device) { audio_out_device = new_device; LOG_TRACE("uTox Audio", "Audio out device changed." ); return true; } audio_out_device = NULL; audio_out_handle = NULL; LOG_TRACE("uTox Audio", "Audio in device set to null." ); return false; } ALCdevice *utox_audio_out_device_get(void) { if (audio_out_handle) { return audio_out_device; } return NULL; } void sourceplaybuffer(unsigned int f, const int16_t *data, int samples, uint8_t channels, unsigned int sample_rate) { if (!channels || channels > 2) { return; } ALuint source; if (f >= self.friend_list_size) { source = preview; } else { source = get_friend(f)->audio_dest; } ALuint bufid; ALint processed = 0, queued = 16; alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed); alGetSourcei(source, AL_BUFFERS_QUEUED, &queued); alSourcei(source, AL_LOOPING, AL_FALSE); if (processed) { ALuint bufids[processed]; alSourceUnqueueBuffers(source, processed, bufids); alDeleteBuffers(processed - 1, bufids + 1); bufid = bufids[0]; } else if (queued < 16) { alGenBuffers(1, &bufid); } else { LOG_TRACE("uTox Audio", "dropped audio frame" ); return; } alBufferData(bufid, (channels == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, data, samples * 2 * channels, sample_rate); alSourceQueueBuffers(source, 1, &bufid); // LOG_TRACE("uTox Audio", "audio frame || samples == %i channels == %u rate == %u " , samples, channels, sample_rate); ALint state; alGetSourcei(source, AL_SOURCE_STATE, &state); if (state != AL_PLAYING) { alSourcePlay(source); // LOG_TRACE("uTox Audio", "Starting source %u" , i); } } static void audio_in_init(void) { const char *audio_in_device_list; audio_in_device_list = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER); if (audio_in_device_list) { audio_in_device = (void *)audio_in_device_list; LOG_TRACE("uTox Audio", "input device list:" ); while (*audio_in_device_list) { LOG_TRACE("uTox Audio", "\t%s" , audio_in_device_list); postmessage_utox(AUDIO_IN_DEVICE, UI_STRING_ID_INVALID, 0, (void *)audio_in_device_list); audio_in_device_list += strlen(audio_in_device_list) + 1; } } postmessage_utox(AUDIO_IN_DEVICE, STR_AUDIO_IN_NONE, 0, NULL); audio_detect(); /* Get audio devices for windows */ } static void audio_out_init(void) { const char *audio_out_device_list; if (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT")) { audio_out_device_list = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); } else { audio_out_device_list = alcGetString(NULL, ALC_DEVICE_SPECIFIER); } if (audio_out_device_list) { audio_out_device = (void *)audio_out_device_list; LOG_TRACE("uTox Audio", "output device list:" ); while (*audio_out_device_list) { LOG_TRACE("uTox Audio", "\t%s" , audio_out_device_list); postmessage_utox(AUDIO_OUT_DEVICE, 0, 0, (void *)audio_out_device_list); audio_out_device_list += strlen(audio_out_device_list) + 1; } } audio_out_handle = alcOpenDevice(audio_out_device); if (!audio_out_handle) { LOG_TRACE("uTox Audio", "alcOpenDevice() failed" ); return; } int attrlist[] = { ALC_FREQUENCY, UTOX_DEFAULT_SAMPLE_RATE_A, ALC_INVALID }; context = alcCreateContext(audio_out_handle, attrlist); if (!alcMakeContextCurrent(context)) { LOG_TRACE("uTox Audio", "alcMakeContextCurrent() failed" ); alcCloseDevice(audio_out_handle); return; } // ALint error; // alGetError(); /* clear errors */ // alGenSources((ALuint)1, &ringtone); // if ((error = alGetError()) != AL_NO_ERROR) { // LOG_TRACE("uTox Audio", "Error generating source with err %x" , error); // return; // } // alGenSources((ALuint)1, &preview); // if ((error = alGetError()) != AL_NO_ERROR) { // LOG_TRACE("uTox Audio", "Error generating source with err %x" , error); // return; // } alcCloseDevice(audio_out_handle); } static bool audio_source_init(ALuint *source) { ALint error; alGetError(); alGenSources((ALuint)1, source); if ((error = alGetError()) != AL_NO_ERROR) { LOG_TRACE("uTox Audio", "Error generating source with err %x" , error); return false; } return true; } static void audio_source_raze(ALuint *source) { LOG_INFO("Audio", "Deleting source"); alDeleteSources((ALuint)1, source); } // clang-format off enum { NOTE_none, NOTE_c3_sharp, NOTE_g3, NOTE_b3, NOTE_c4, NOTE_a4, NOTE_b4, NOTE_e4, NOTE_f4, NOTE_c5, NOTE_d5, NOTE_e5, NOTE_f5, NOTE_g5, NOTE_a5, NOTE_c6_sharp, NOTE_e6, }; static struct { uint8_t note; double freq; } notes[] = { {NOTE_none, 1 }, /* Can't be 0 or openal will skip this note/time */ {NOTE_c3_sharp, 138.59 }, {NOTE_g3, 196.00 }, {NOTE_b3, 246.94 }, {NOTE_c4, 261.63 }, {NOTE_a4, 440.f }, {NOTE_b4, 493.88 }, {NOTE_e4, 329.63 }, {NOTE_f4, 349.23 }, {NOTE_c5, 523.25 }, {NOTE_d5, 587.33 }, {NOTE_e5, 659.25 }, {NOTE_f5, 698.46 }, {NOTE_g5, 783.99 }, {NOTE_a5, 880.f }, {NOTE_c6_sharp, 1108.73 }, {NOTE_e6, 1318.51 }, }; static struct melodies { /* C99 6.7.8/10 uninitialized arithmetic types are 0 this is what we want. */ uint8_t count; uint8_t volume; uint8_t fade; uint8_t notes[8]; } normal_ring[16] = { {1, 14, 1, {NOTE_f5, }}, {1, 14, 1, {NOTE_f5, }}, {1, 14, 1, {NOTE_f5, }}, {1, 14, 1, {NOTE_c6_sharp, }}, {1, 14, 0, {NOTE_c5, }}, {1, 14, 1, {NOTE_c5, }}, {0, 0, 0, {0, }}, }, friend_offline[4] = { {1, 14, 1, {NOTE_c4, }}, {1, 14, 1, {NOTE_g3, }}, {1, 14, 1, {NOTE_g3, }}, {0, 0, 0, {0, }}, }, friend_online[4] = { {1, 14, 0, {NOTE_g3, }}, {1, 14, 1, {NOTE_g3, }}, {1, 14, 1, {NOTE_a4, }}, {1, 14, 1, {NOTE_b4, }}, }, friend_new_msg[8] = { {1, 0, 0, {0, }}, /* 3/8 sec of silence for spammy friends */ {1, 0, 0, {0, }}, {1, 0, 0, {0, }}, {1, 9, 0, {NOTE_g5, }}, {1, 9, 1, {NOTE_g5, }}, {1, 12, 1, {NOTE_a4, }}, {1, 10, 1, {NOTE_a4, }}, {1, 0, 0, {0, }}, }, friend_request[8] = { {1, 9, 0, {NOTE_g5, }}, {1, 9, 1, {NOTE_g5, }}, {1, 12, 1, {NOTE_b3, }}, {1, 10, 1, {NOTE_b3, }}, {1, 9, 0, {NOTE_g5, }}, {1, 9, 1, {NOTE_g5, }}, {1, 12, 1, {NOTE_b3, }}, {1, 10, 0, {NOTE_b3, }}, }; // clang-format on typedef struct melodies MELODY; // TODO: These should be functions rather than macros that only work in a specific context. #define FADE_STEP_OUT() (1 - ((double)(index % (sample_rate / notes_per_sec)) / (sample_rate / notes_per_sec))) #define FADE_STEP_IN() (((double)(index % (sample_rate / notes_per_sec)) / (sample_rate / notes_per_sec))) // GEN_NOTE_RAW is unused. Delete? #define GEN_NOTE_RAW(x, a) ((a * base_amplitude) * (sin((tau * x) * index / sample_rate))) #define GEN_NOTE_NUM(x, a) ((a * base_amplitude) * (sin((tau * notes[x].freq) * index / sample_rate))) #define GEN_NOTE_NUM_FADE(x, a) \ ((a * base_amplitude * FADE_STEP_OUT()) * (sin((tau * notes[x].freq) * index / sample_rate))) // GEN_NOTE_NUM_FADE_IN is unused. Delete? #define GEN_NOTE_NUM_FADE_IN(x, a) \ ((a * base_amplitude * FADE_STEP_IN()) * (sin((tau * notes[x].freq) * index / sample_rate))) static void generate_melody(MELODY melody[], uint32_t seconds, uint32_t notes_per_sec, ALuint *target) { ALint error; alGetError(); /* clear errors */ alGenBuffers((ALuint)1, target); if ((error = alGetError()) != AL_NO_ERROR) { LOG_TRACE("uTox Audio", "Error generating buffer with err %i" , error); return; } const uint32_t sample_rate = 22000; const uint32_t base_amplitude = 1000; const double tau = 6.283185307179586476925286766559; const size_t buf_size = seconds * sample_rate * 2; // 16 bit (2 bytes per sample) int16_t *samples = calloc(buf_size, sizeof(int16_t)); if (!samples) { LOG_TRACE("uTox Audio", "Unable to generate ringtone buffer!" ); return; } for (uint64_t index = 0; index < buf_size; ++index) { /* index / sample rate `mod` seconds. will give you full second long notes * you can change the length each tone is played by changing notes_per_sec * but you'll need to add additional case to cover the entire span of time */ const int position = ((index / (sample_rate / notes_per_sec)) % (seconds * notes_per_sec)); for (int i = 0; i < melody[position].count; ++i) { if (melody[position].fade) { samples[index] += GEN_NOTE_NUM_FADE(melody[position].notes[i], melody[position].volume); } else { samples[index] += GEN_NOTE_NUM(melody[position].notes[i], melody[position].volume); } } } alBufferData(*target, AL_FORMAT_MONO16, samples, buf_size, sample_rate); free(samples); } static void generate_tone_call_ringtone() { generate_melody(normal_ring, 4, 4, &RingBuffer); } static void generate_tone_friend_offline() { generate_melody(friend_offline, 1, 4, &ToneBuffer); } static void generate_tone_friend_online() { generate_melody(friend_online, 1, 4, &ToneBuffer); } static void generate_tone_friend_new_msg() { generate_melody(friend_new_msg, 1, 8, &ToneBuffer); } static void generate_tone_friend_request() { generate_melody(friend_request, 1, 8, &ToneBuffer); } void postmessage_audio(uint8_t msg, uint32_t param1, uint32_t param2, void *data) { while (audio_thread_msg && utox_audio_thread_init) { yieldcpu(1); } audio_msg.msg = msg; audio_msg.param1 = param1; audio_msg.param2 = param2; audio_msg.data = data; audio_thread_msg = 1; } // TODO: This function is 300 lines long. Cut it up. void utox_audio_thread(void *args) { time_t close_device_time = 0; ToxAV *av = args; #ifdef AUDIO_FILTERING LOG_INFO("uTox Audio", "Audio Filtering" #ifdef ALC_LOOPBACK_CAPTURE_SAMPLES " and Echo cancellation" #endif " enabled in this build" ); #endif // bool call[MAX_CALLS] = {0}, preview = 0; const int perframe = (UTOX_DEFAULT_FRAME_A * UTOX_DEFAULT_SAMPLE_RATE_A) / 1000; uint8_t buf[perframe * 2 * UTOX_DEFAULT_AUDIO_CHANNELS]; //, dest[perframe * 2 * UTOX_DEFAULT_AUDIO_CHANNELS]; memset(buf, 0, sizeof(buf)); LOG_TRACE("uTox Audio", "frame size: %u" , perframe); /* init Microphone */ audio_in_init(); // audio_in_device_open(); // audio_in_listen(); /* init Speakers */ audio_out_init(); // audio_out_device_open(); // audio_out_device_close(); #define PREVIEW_BUFFER_SIZE (UTOX_DEFAULT_SAMPLE_RATE_A / 2) int16_t *preview_buffer = calloc(PREVIEW_BUFFER_SIZE, 2); if (!preview_buffer) { LOG_ERR("uTox Audio", "Unable to allocate memory for preview buffer."); return; } unsigned int preview_buffer_index = 0; bool preview_on = false; utox_audio_thread_init = true; while (1) { if (audio_thread_msg) { const TOX_MSG *m = &audio_msg; if (m->msg == UTOXAUDIO_KILL) { break; } int call_ringing = 0; switch (m->msg) { case UTOXAUDIO_CHANGE_MIC: { while (audio_in_ignore()) { continue; } while (audio_in_device_close()) { continue; } break; } case UTOXAUDIO_CHANGE_SPEAKER: { while (audio_out_device_close()) { continue; } break; } case UTOXAUDIO_START_FRIEND: { FRIEND *f = get_friend(m->param1); if (f && !f->audio_dest) { audio_source_init(&f->audio_dest); } audio_out_device_open(); audio_in_listen(); break; } case UTOXAUDIO_STOP_FRIEND: { FRIEND *f = get_friend(m->param1); if (f && f->audio_dest) { audio_source_raze(&f->audio_dest); f->audio_dest = 0; } audio_in_ignore(); audio_out_device_close(); break; } case UTOXAUDIO_GROUPCHAT_START: { LOG_DEBUG("Audio", "Starting Groupchat Audio %u", m->param1); GROUPCHAT *g = get_group(m->param1); if (!g) { LOG_ERR("uTox Audio", "Could not get group %u", m->param1); break; } if (!g->audio_dest) { audio_source_init(&g->audio_dest); } audio_out_device_open(); audio_in_listen(); break; } case UTOXAUDIO_GROUPCHAT_STOP: { LOG_DEBUG("Audio", "Stopping Groupchat Audio %u", m->param1); GROUPCHAT *g = get_group(m->param1); if (!g) { LOG_ERR("uTox Audio", "Could not get group %u", m->param1); break; } if (g->audio_dest) { audio_source_raze(&g->audio_dest); g->audio_dest = 0; } audio_in_ignore(); audio_out_device_close(); break; } case UTOXAUDIO_START_PREVIEW: { preview_on = true; audio_out_device_open(); audio_in_listen(); break; } case UTOXAUDIO_STOP_PREVIEW: { preview_on = false; audio_in_ignore(); audio_out_device_close(); break; } case UTOXAUDIO_PLAY_RINGTONE: { if (settings.audible_notifications_enabled && self.status != USER_STATUS_DO_NOT_DISTURB) { LOG_INFO("uTox Audio", "Going to start ringtone!" ); audio_out_device_open(); generate_tone_call_ringtone(); alSourcei(ringtone, AL_LOOPING, AL_TRUE); alSourcei(ringtone, AL_BUFFER, RingBuffer); alSourcePlay(ringtone); call_ringing++; } break; } case UTOXAUDIO_STOP_RINGTONE: { call_ringing--; LOG_INFO("uTox Audio", "Going to stop ringtone!" ); alSourceStop(ringtone); yieldcpu(5); audio_out_device_close(); break; } case UTOXAUDIO_PLAY_NOTIFICATION: { if (settings.audible_notifications_enabled && self.status == USER_STATUS_AVAILABLE) { LOG_INFO("uTox Audio", "Going to start notification tone!" ); if (close_device_time <= time(NULL)) { audio_out_device_open(); } switch (m->param1) { case NOTIFY_TONE_FRIEND_ONLINE: { generate_tone_friend_online(); break; } case NOTIFY_TONE_FRIEND_OFFLINE: { generate_tone_friend_offline(); break; } case NOTIFY_TONE_FRIEND_NEW_MSG: { generate_tone_friend_new_msg(); break; } case NOTIFY_TONE_FRIEND_REQUEST: { generate_tone_friend_request(); break; } } alSourcei(notifytone, AL_LOOPING, AL_FALSE); alSourcei(notifytone, AL_BUFFER, ToneBuffer); alSourcePlay(notifytone); time(&close_device_time); close_device_time += 10; LOG_INFO("uTox Audio", "close device set!" ); } break; } case UTOXAUDIO_STOP_NOTIFICATION: { break; } case UTOXAUDIO_NEW_AV_INSTANCE: { av = m->data; audio_in_init(); audio_out_init(); } } audio_thread_msg = 0; if (close_device_time && time(NULL) >= close_device_time) { LOG_INFO("uTox Audio", "close device triggered!" ); audio_out_device_close(); close_device_time = 0; } } settings.audio_filtering_enabled = filter_audio_check(); bool sleep = true; if (microphone_on) { ALint samples; bool frame = 0; /* If we have a device_in we're on linux so we can just call OpenAL, otherwise we're on something else so * we'll need to call audio_frame() to add to the buffer for us. */ if (audio_in_handle == (void *)1) { frame = audio_frame((void *)buf); if (frame) { /* We have an audio frame to use, continue without sleeping. */ sleep = false; } } else { alcGetIntegerv(audio_in_handle, ALC_CAPTURE_SAMPLES, sizeof(samples), &samples); if (samples >= perframe) { alcCaptureSamples(audio_in_handle, buf, perframe); frame = true; if (samples >= perframe * 2) { sleep = false; } } } #ifdef AUDIO_FILTERING #ifdef ALC_LOOPBACK_CAPTURE_SAMPLES if (f_a && settings.audio_filtering_enabled) { alcGetIntegerv(audio_out_device, ALC_LOOPBACK_CAPTURE_SAMPLES, sizeof(samples), &samples); if (samples >= perframe) { int16_t buffer[perframe]; alcCaptureSamplesLoopback(audio_out_handle, buffer, perframe); pass_audio_output(f_a, buffer, perframe); set_echo_delay_ms(f_a, UTOX_DEFAULT_FRAME_A); if (samples >= perframe * 2) { sleep = false; } } } #endif #endif if (frame) { bool voice = true; #ifdef AUDIO_FILTERING if (f_a) { const int ret = filter_audio(f_a, (int16_t *)buf, perframe); if (ret == -1) { LOG_TRACE("uTox Audio", "filter audio error" ); } if (ret == 0) { voice = false; } } #endif /* If push to talk, we don't have to do anything */ if (!check_ptt_key()) { voice = false; // PTT is up, send nothing. } if (preview_on) { if (preview_buffer_index + perframe > PREVIEW_BUFFER_SIZE) { preview_buffer_index = 0; } sourceplaybuffer(self.friend_list_size, preview_buffer + preview_buffer_index, perframe, UTOX_DEFAULT_AUDIO_CHANNELS, UTOX_DEFAULT_SAMPLE_RATE_A); if (voice) { memcpy(preview_buffer + preview_buffer_index, buf, perframe * sizeof(int16_t)); } else { memset(preview_buffer + preview_buffer_index, 0, perframe * sizeof(int16_t)); } preview_buffer_index += perframe; } if (voice) { size_t active_call_count = 0; for (size_t i = 0; i < self.friend_list_count; i++) { if (UTOX_SEND_AUDIO(i)) { active_call_count++; TOXAV_ERR_SEND_FRAME error = 0; // LOG_TRACE("uTox Audio", "Sending audio frame!" ); FRIEND *f = get_friend(i); if (!f) { LOG_ERR("uToxAV", "Unable to get friend when sending audio frame %u", i); continue; } toxav_audio_send_frame(av, f->number, (const int16_t *)buf, perframe, UTOX_DEFAULT_AUDIO_CHANNELS, UTOX_DEFAULT_SAMPLE_RATE_A, &error); if (error) { LOG_TRACE("uTox Audio", "toxav_send_audio error friend == %lu, error == %i" , i, error); } else { // LOG_TRACE("uTox Audio", "Send a frame to friend %i" ,i); if (active_call_count >= UTOX_MAX_CALLS) { LOG_TRACE("uTox Audio", "We're calling more peers than allowed by UTOX_MAX_CALLS, This is a bug" ); break; } } } } Tox *tox = toxav_get_tox(av); uint32_t num_chats = tox_conference_get_chatlist_size(tox); if (num_chats) { for (size_t i = 0 ; i < num_chats; ++i) { if (get_group(i) && get_group(i)->active_call) { LOG_TRACE("uTox Audio", "Sending audio in groupchat %u", i); toxav_group_send_audio(tox, i, (int16_t *)buf, perframe, UTOX_DEFAULT_AUDIO_CHANNELS, UTOX_DEFAULT_SAMPLE_RATE_A); } } } } } } if (sleep) { yieldcpu(50); } } utox_filter_audio_kill(f_a); f_a = NULL; // missing some cleanup ? alDeleteSources(1, &ringtone); alDeleteSources(1, &preview); alDeleteBuffers(1, &RingBuffer); while (audio_in_device_close()) { continue; } while (audio_out_device_close()) {continue; } audio_thread_msg = 0; utox_audio_thread_init = false; free(preview_buffer); LOG_TRACE("uTox Audio", "Clean thread exit!"); } void callback_av_group_audio(void *UNUSED(tox), uint32_t groupnumber, uint32_t peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *UNUSED(userdata)) { GROUPCHAT *g = get_group(groupnumber); if (!g) { LOG_ERR("uTox Audio", "Could not get group with number: %i", groupnumber); return; } LOG_INFO("uTox Audio", "Received audio in groupchat %i from peer %i", groupnumber, peernumber); if (!g->active_call) { LOG_INFO("uTox Audio", "Packets for inactive call %u", groupnumber); return; } uint64_t time = get_time(); if (time - g->last_recv_audio[peernumber] > (uint64_t)1 * 1000 * 1000 * 1000) { postmessage_utox(GROUP_UPDATE, groupnumber, peernumber, NULL); } g->last_recv_audio[peernumber] = time; if (channels < 1 || channels > 2) { LOG_ERR("uTox Audio", "Can't continue, with channel > 2 or < 1."); return; } if (g->muted) { LOG_INFO("uTox Audio", "Group %u audio muted.", groupnumber); return; } ALuint bufid; ALint processed = 0, queued = 16; alGetSourcei(g->source[peernumber], AL_BUFFERS_PROCESSED, &processed); alGetSourcei(g->source[peernumber], AL_BUFFERS_QUEUED, &queued); alSourcei(g->source[peernumber], AL_LOOPING, AL_FALSE); if (processed) { ALuint bufids[processed]; alSourceUnqueueBuffers(g->source[peernumber], processed, bufids); alDeleteBuffers(processed - 1, bufids + 1); bufid = bufids[0]; } else if(queued < 16) { alGenBuffers(1, &bufid); } else { LOG_WARN("uTox Audio", "dropped audio frame %i %i" , groupnumber, peernumber); return; } alBufferData(bufid, (channels == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, pcm, samples * 2 * channels, sample_rate); alSourceQueueBuffers(g->source[peernumber], 1, &bufid); ALint state; alGetSourcei(g->source[peernumber], AL_SOURCE_STATE, &state); if (state != AL_PLAYING) { alSourcePlay(g->source[peernumber]); LOG_DEBUG("uTox Audio", "Starting source %i %i" , groupnumber, peernumber); } } void group_av_peer_add(GROUPCHAT *g, int peernumber) { if (!g || peernumber < 0) { LOG_ERR("uTox Audio", "Invalid groupchat or peer number"); return; } LOG_INFO("uTox Audio", "Adding source for peer %u in group %u", peernumber, g->number); alGenSources(1, &g->source[peernumber]); } void group_av_peer_remove(GROUPCHAT *g, int peernumber) { if (!g || peernumber < 0) { LOG_ERR("uTox Audio", "Invalid groupchat or peer number"); return; } LOG_INFO("uTox Audio", "Deleting source for peer %u in group %u", peernumber, g->number); alDeleteSources(1, &g->source[peernumber]); } uTox/src/av/CMakeLists.txt0000600000175000001440000000167214003056216014441 0ustar rakusersproject(utoxAV LANGUAGES C) add_library(utoxAV STATIC utox_av.c audio.c video.c filter_audio.c ) if(WIN32) target_link_libraries(utoxAV OpenAL32) # Windows needs to be linked against OpenAL32 elseif(APPLE) find_package(libopus REQUIRED) include_directories(${LIBOPUS_INCLUDE_DIRS}) target_link_libraries(utoxAV ${LIBOPUS_LIBRARIES}) # Link OSX against opus else() # Both openal and opus are required for the static Linux builds on Jenkins. find_package(libopus REQUIRED) include_directories(${LIBOPUS_INCLUDE_DIRS}) target_link_libraries(utoxAV ${LIBOPUS_LIBRARIES}) find_package(OpenAL REQUIRED) include_directories(${OPENAL_INCLUDE_DIR}) target_link_libraries(utoxAV ${OPENAL_LIBRARY}) endif() if(ENABLE_FILTERAUDIO) find_package(libfilteraudio REQUIRED) include_directories(${LIBFILTERAUDIO_INCLUDE_DIRS}) target_link_libraries(utoxAV ${LIBFILTERAUDIO_LIBRARIES}) endif() uTox/src/android/0000700000175000001440000000000014003056216012703 5ustar rakusersuTox/src/android/window.c0000600000175000001440000000211014003056216014352 0ustar rakusers#include "../window.h" #include #include bool native_window_init(void) { return true; } static UTOX_WINDOW *native_window_create(UTOX_WINDOW *window, char *title, unsigned int class, int x, int y, int w, int h, int min_width, int min_height, void *gui_panel, bool override) { return NULL; } void native_window_raze(UTOX_WINDOW *window) { } UTOX_WINDOW *native_window_create_main(int x, int y, int w, int h, char **argv, int argc) { return NULL; } void native_window_create_video() { return; } UTOX_WINDOW *native_window_find_notify(void *window) { return NULL; } UTOX_WINDOW *native_window_create_notify(int x, int y, int w, int h, void* panel) { return NULL; } static void notify_tween_thread(void *obj) { } void window_set_focus(UTOX_WINDOW *win) { } void native_window_tween(UTOX_WINDOW *win) { } void native_window_create_screen_select() { } bool native_window_set_target(UTOX_WINDOW *new_win) { return true; } void native_screen_grab_desktop(bool video) { } uTox/src/android/res/0000700000175000001440000000000014003056216013474 5ustar rakusersuTox/src/android/res/drawable/0000700000175000001440000000000014003056216015255 5ustar rakusersuTox/src/android/res/drawable/i.png0000600000175000001440000001614614003056216016225 0ustar rakusersPNG  IHDR\rf-IDATxy\TƟaFtDPAǃi"izͅ,ͭ,,-.4%E ˭ wSqx\D DYgTX̙sfsɜ<9ĩ̂@8 r<|wHp/. 3$1eAT4Ӆ,8`xDI,`%("O{(<$[lA V e\w'%1գH)CʆDIjRxM 靁|`%O"R[NWS w_n'xg$8 (Wm>E#8`(?p6Pf4+%1QȋlДiN=CM~+gl|y8q((giVWdEI(xk>Lxg3YM~iiL+5%0Gb5A$f1 @-`LL8 %lrI!h'JyFA(kpl6+(~Ξk$DIYpx`3 #Ǡ2?o'ɔ߻OCnݺpl6#OzIKOY@i{~4oZl^ 5U< `h G٥k]pHpNnnŃ'LessW2ӠAWGzU~mk'կQ=8)3 ɋ/Zj!/\k"fMWwuPPPn>y $@Dʹ85yCS09Ns aDɹ}zr^=W:s)uR L#^q9jI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UwC)&)))322ܝe$cU)RLVe8þl޴۷+)۶mk W_5g5)RfBӤ$Uljj'd5)RB,״ӞQ>̚9ѝ;wHiػwog5 +HR0~j;y͛XE <Ki<ŬQ/o QӘ_J;wTd(R\rW_y5J cF :j)Cn:x%JƍQ)[l6?m\wo9)??E(?i⤩1kc*+i\{ א)YYY M4ahԨQFY$Iş,~">>Mʍ:LOAXzhژ;;{5WBCCE[nÎ;gϞ]<')((`ogqc2/ IKK Q 6[tJ__| .??_=<]l6wK*@r׬B:`e&OuVMpp>Ks͝1Xnc\R [7^3|l(r(6.vvHHHo0~Rv-&@J?v\hQ~hڂu-UVV ŠU+橽oV/ 9R/Jx:~zۊU+}Ye F >'/(((wsZmMxӫ_>ض]<զ=},]u欙+W|U] zVe)'frʫ"""Rnt Ovnnǯu}>cRv"[t}\rNqP.{?^__|__ LpzxO|QK.Z̅p^(ª1 Lg E ,PΏ +Vb ω^!C +V peD8?^/ S ! P BB(B@!! P# O W^e.s LAs"sO2ٱcG5@8Nx)<3 INNv*L;VA:/5g+7o| ˄' Z< H)7RۯF2YI"R|n/x_NN`萡6o<pI=92"r]i׮Y[%2"?mPPPC!GC`\Jxl6\Z+t:Yj|rdKMDZ+#kFH!JZRY/BS߀K z^8zN^(%m!)+D!!UQ+i!%{ s֍e]/iX?BJQkqfQn[_R*: Jbɬ#!brav=ZR"!ÉtYB]O=xʱ7ii)&?MX[BWEI(džrQZz!&/!e(oʵ13v֘"^#!` ?8YQ3ܨ+g O7CpXW?C" @Ϲ@\ؑP3P"|C qv%g ?_8?KTB+fpj@_!NIs|)JEISkd yDTm*uy/`j&4P@u!܃m).8 vQϫa決qX5IENDB`uTox/src/android/main.h0000600000175000001440000000115314003056216014002 0ustar rakusers#if defined(MAIN_H) && !defined(ANDROID_MAIN_H) #error "We should never include main from different platforms." #endif #ifndef ANDROID_MAIN_H #define ANDROID_MAIN_H #define MAIN_H #include #include #include #include #include #include #include #include #include #include #include // Early include to obtain GLuint. #include typedef struct native_image { GLuint img; } NATIVE_IMAGE; #define ANDROID_INTERNAL_SAVE "/data/data/tox.client.utox/files/" #endif uTox/src/android/main.c0000600000175000001440000005723714003056216014013 0ustar rakusers#include "main.h" #include "gl.h" #include "freetype.h" #include "../debug.h" #include "../filesys.h" #include "../flist.h" #include "../main.h" #include "../settings.h" #include "../theme.h" #include "../tox.h" #include "../ui.h" #include "../utox.h" #include "../ui/svg.h" #include "../ui/edit.h" #include "../layout/background.h" #include "../native/keyboard.h" #include "../native/notify.h" #include "stb.h" #include #include #include #include #include #include #include #include #include static volatile bool destroy; bool have_focus = false; static bool shift; static ANativeActivity * activity; static ANativeWindow * window; static volatile ANativeWindow *windowN; static AInputQueue * inputQueue; static volatile AInputQueue * inputQueueNew; static volatile ARect rect; static volatile bool _redraw; const char *internalPath[UTOX_FILE_NAME_LENGTH]; static int pipefd[2]; typedef struct { uint32_t msg; uint16_t param1, param2; void * data; } PIPING; void postmessage_utox(UTOX_MSG msg, uint16_t param1, uint16_t param2, void *data) { PIPING piping = {.msg = msg, .param1 = param1, .param2 = param2, .data = data }; write(pipefd[1], &piping, sizeof(PIPING)); } void init_ptt(void) { settings.push_to_talk = 0; /* android is unsupported */ } bool check_ptt_key(void) { return 1; /* android is unsupported */ } void exit_ptt(void) { settings.push_to_talk = 0; /* android is unsupported */ } void image_set_filter(NATIVE_IMAGE *image, uint8_t filter) { /* Unsupported on android */ } void image_set_scale(NATIVE_IMAGE *image, double scale) { /* Unsupported on android */ } void draw_image(const NATIVE_IMAGE *data, int x, int y, uint32_t width, uint32_t height, uint32_t imgx, uint32_t imgy) { GL_draw_image(data, x, y, width, height, imgx, imgy); } void draw_inline_image(uint8_t *img_data, size_t size, uint16_t w, uint16_t h, int x, int y) { draw_image(img_data, x, y, w, h, 0, 0); } void thread(void func(void *), void *args) { pthread_t thread_temp; pthread_create(&thread_temp, NULL, (void *(*)(void *))func, args); } void yieldcpu(uint32_t ms) { usleep(1000 * ms); } uint64_t get_time(void) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC_RAW, &ts); return ((uint64_t)ts.tv_sec * (1000 * 1000 * 1000)) + (uint64_t)ts.tv_nsec; } /* These functions aren't support on Andorid HELP? * TODO: fix these! */ void copy(int value) { /* Unsupported on android */ } void paste(void) { /* Unsupported on android */ } void openurl(char *str) { /* Unsupported on android */ } void openfilesend(void) { /* Unsupported on android */ } void openfileavatar(void) { /* Unsupported on android */ } typedef struct msg_header MSG_HEADER; void file_save_inline_image_png(MSG_HEADER *msg) { /* Unsupported on android */ } void setselection(char *data, uint16_t length) { /* Unsupported on android */ } void edit_will_deactivate(void) { /* Unsupported on android */ } NATIVE_IMAGE *utox_image_to_native(const UTOX_IMAGE data, size_t size, uint16_t *w, uint16_t *h, bool keep_alpha) { return GL_utox_image_to_native(data, size, w, h, keep_alpha); } void image_free(NATIVE_IMAGE *image) { if (!image) { return; } GLuint texture = image; glDeleteTextures(1, &texture); } // TODO: DRY. This function exists in both posix/filesys.c and in android/main.c // Make a posix native_get_file that you pass a complete path to instead of letting it construct // one would fix this. static void opts_to_sysmode(UTOX_FILE_OPTS opts, char *mode) { if (opts & UTOX_FILE_OPTS_READ) { mode[0] = 'r'; } if (opts & UTOX_FILE_OPTS_APPEND) { mode[0] = 'a'; } else if (opts & UTOX_FILE_OPTS_WRITE) { mode[0] = 'w'; } mode[1] = 'b'; if ((opts & (UTOX_FILE_OPTS_WRITE | UTOX_FILE_OPTS_APPEND)) && (opts & UTOX_FILE_OPTS_READ)) { mode[2] = '+'; } mode[3] = 0; return; } FILE *native_get_file_simple(const char *path, UTOX_FILE_OPTS opts) { char mode[4] = { 0 }; opts_to_sysmode(opts, mode); FILE *fp = fopen(path, mode); if (!fp && opts & UTOX_FILE_OPTS_READ && opts & UTOX_FILE_OPTS_WRITE) { LOG_WARN("Android Native", "Unable to simple open, falling back to fd" ); // read won't create a file if it doesn't already exist. If we're allowed to write, let's try // to create the file, then reopen it. int fd = open(path, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); fp = fdopen(fd, mode); } return fp; } FILE *native_get_file(const uint8_t *name, size_t *size, UTOX_FILE_OPTS opts, bool portable_mode) { uint8_t path[UTOX_FILE_NAME_LENGTH] = { 0 }; snprintf(path, UTOX_FILE_NAME_LENGTH, ANDROID_INTERNAL_SAVE); // native_get_file should never be called with DELETE in combination with other FILE_OPTS. assert(opts <= UTOX_FILE_OPTS_DELETE); // WRITE and APPEND are mutually exclusive. WRITE will serve you a blank file. APPEND will append (duh). assert((opts & UTOX_FILE_OPTS_WRITE && opts & UTOX_FILE_OPTS_APPEND) == false); if (opts & UTOX_FILE_OPTS_READ || opts & UTOX_FILE_OPTS_MKDIR) { if (!native_create_dir(path)) { return NULL; } } if (strlen((char *)path) + strlen((char *)name) >= UTOX_FILE_NAME_LENGTH) { LOG_TRACE("Android Native", "Load directory name too long" ); return NULL; } else { snprintf((char *)path + strlen((char *)path), UTOX_FILE_NAME_LENGTH - strlen((char *)path), "%s", name); } if (opts == UTOX_FILE_OPTS_DELETE) { remove((char *)path); return NULL; } FILE *fp = native_get_file_simple((char *)path, opts); if (fp == NULL) { LOG_NOTE("Android Native", "Could not open %s" , path); return NULL; } if (size != NULL) { fseek(fp, 0, SEEK_END); *size = ftell(fp); fseek(fp, 0, SEEK_SET); } return fp; } bool native_move_file(const uint8_t *current_name, const uint8_t *new_name) { if(!current_name || !new_name) { return false; } return rename((char *)current_name, (char *)new_name); } void native_select_dir_ft(uint32_t fid, void *file) { return; /* TODO unsupported on android //fall back to working dir char *path = malloc(file->name_length + 1); memcpy(path, file->name, file->name_length); path[file->name_length] = 0; postmessage_toxcore(TOX_FILE_ACCEPT, fid, file->filenumber, path); */ } void native_autoselect_dir_ft(uint32_t fid, void *file) { return; /* TODO unsupported on android /* TODO: maybe do something different here? char *path = malloc(file->name_length + 1); memcpy(path, file->name, file->name_length); path[file->name_length] = 0; postmessage_toxcore(TOX_FILE_ACCEPT, fid, file->file_number, path); */ } bool native_create_dir(const uint8_t *filepath) { const int status = mkdir((char *)filepath, S_IRWXU); if (status == 0 || errno == EEXIST) { return true; } return false; } bool native_remove_file(const uint8_t *name, size_t length, bool portable_mode) { uint8_t path[UTOX_FILE_NAME_LENGTH] = { 0 }; snprintf((char *)path, UTOX_FILE_NAME_LENGTH, ANDROID_INTERNAL_SAVE); if (strlen((const char *)path) + length >= UTOX_FILE_NAME_LENGTH) { LOG_TRACE("Android Native", "File/directory name too long, unable to remove" ); return 0; } else { snprintf((char *)path + strlen((const char *)path), UTOX_FILE_NAME_LENGTH - strlen((const char *)path), "%.*s", (int)length, (char *)name); } if (remove((const char *)path)) { LOG_ERR("Android Native", "Unable to delete file!\n\t\t%s" , path); return 0; } else { LOG_INFO("Android Native", "File deleted!" ); LOG_TRACE("Android Native", "\t%s" , path); } return 1; } void native_export_chatlog_init(uint32_t friend_number) { /* Unsupported on Android */ } bool native_save_image_png(const char *name, const uint8_t *image, const int image_size) { /* Unsupported on Android */ } void flush_file(FILE *file) { fflush(file); int fd = fileno(file); fsync(fd); } int ch_mod(uint8_t *file) { /* You're probably looking for ./xlib as android isn't working when this was written. */ return -1; } int file_lock(FILE *file, uint64_t start, size_t length) { // Unsupported on android return 0; } bool native_video_init(void *handle) { return 0; /* Unsupported on android */ } void native_video_close(void *handle) { /* Unsupported on android */ } bool native_video_startread(void) { return 1; /* Unsupported on android */ } bool native_video_endread(void) { return 1; /* Unsupported on android */ } int native_video_getframe(uint8_t *y, uint8_t *u, uint8_t *v, uint16_t width, uint16_t height) { return 0; /* Unsupported on android */ } int file_unlock(FILE *file, uint64_t start, size_t length) { return 0; /* Unsupported on android */ } void setscale_fonts(void) { freefonts(); loadfonts(); } void setscale(void) { if (window) { svg_draw(0); } setscale_fonts(); } void notify(char *title, uint16_t title_length, const char *msg, uint16_t msg_length, void *object, bool is_group) { /* Unsupported on android */ } void desktopgrab(bool video) { /* Unsupported on android */ } void video_frame(uint16_t id, uint8_t *img_data, uint16_t width, uint16_t height, bool resize) { /* Unsupported on android */ } void video_begin(uint16_t id, char *name, uint16_t name_length, uint16_t width, uint16_t height) { /* Unsupported on android */ } void video_end(uint16_t id) { /* Unsupported on android */ } uint16_t native_video_detect(void) { return 0; /* Unsupported on android */ } bool video_init(void *handle) { return 0; /* Unsupported on android */ } void video_close(void *handle) { /* Unsupported on android */ } bool video_startread(void) { return 1; /* Unsupported on android */ } bool video_endread(void) { return 1; /* Unsupported on android */ } int video_getframe(uint8_t *y, uint8_t *u, uint8_t *v, uint16_t width, uint16_t height) { return 0; /* Unsupported on android */ } #define MAP(x, y) case AKEYCODE_##x : return y #define MAPS(x, y, z) case AKEYCODE_##x : return ((shift) ? z : y) #define MAPC(x) case AKEYCODE_##x : return (#x[0] + ((shift) ? 0 : ('a' - 'A'))) #define MAPN(x, y) case AKEYCODE_##x : return ((shift) ? y : #x[0]) static uint32_t getkeychar(int32_t key) /* get a character from an android keycode */ { switch (key) { MAP(ENTER, KEY_RETURN); MAP(DEL, KEY_BACK); MAP(DPAD_LEFT, KEY_LEFT); MAP(DPAD_RIGHT, KEY_RIGHT); MAP(DPAD_UP, KEY_UP); MAP(DPAD_DOWN, KEY_DOWN); MAP(SPACE, ' '); MAPS(MINUS, '-', '_'); MAPS(EQUALS, '=', '+'); MAPS(LEFT_BRACKET, '[', '{'); MAPS(RIGHT_BRACKET, ']', '}'); MAPS(BACKSLASH, '\\', '|'); MAPS(SEMICOLON, ';', ':'); MAPS(APOSTROPHE, '\'', '\"'); MAPS(COMMA, ',', '<'); MAPS(PERIOD, '.', '>'); MAPS(SLASH, '/', '?'); MAPS(GRAVE, '`', '~'); MAP(AT, '@'); MAP(STAR, '*'); MAP(PLUS, '+'); MAPC(A); MAPC(B); MAPC(C); MAPC(D); MAPC(E); MAPC(F); MAPC(G); MAPC(H); MAPC(I); MAPC(J); MAPC(K); MAPC(L); MAPC(M); MAPC(N); MAPC(O); MAPC(P); MAPC(Q); MAPC(R); MAPC(S); MAPC(T); MAPC(U); MAPC(V); MAPC(W); MAPC(X); MAPC(Y); MAPC(Z); MAPN(0, ')'); MAPN(1, '!'); MAPN(2, '@'); MAPN(3, '#'); MAPN(4, '$'); MAPN(5, '%'); MAPN(6, '^'); MAPN(7, '&'); MAPN(8, '*'); MAPN(9, '('); default: { LOG_TRACE("Android", "un-mapped %u", key); break; } } return 0; #undef MAP #undef MAPC } void redraw(void) { _redraw = 1; } void force_redraw(void) { redraw(); } void update_tray(void) { /* Unsupported on android */ } void utox_android_redraw_window(void) { if (!_redraw) { return; } _redraw = GL_utox_android_redraw_window(); panel_draw(&panel_root, 0, 0, settings.window_width, settings.window_height); } int lx = 0, ly = 0; uint64_t p_last_down; bool p_down, already_up; static void utox_andoid_input(AInputQueue *in_queue, AInputEvent *event) { if (AInputQueue_preDispatchEvent(inputQueue, event) == 0) { int32_t handled = 1; int32_t type = AInputEvent_getType(event); if (type == AINPUT_EVENT_TYPE_MOTION) { int32_t action = AMotionEvent_getAction(event); int32_t pointer_index = ((action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT); int32_t action_bits = (action & AMOTION_EVENT_ACTION_MASK); float x = AMotionEvent_getX(event, pointer_index); float y = AMotionEvent_getY(event, pointer_index); switch (action_bits) { case AMOTION_EVENT_ACTION_DOWN: case AMOTION_EVENT_ACTION_POINTER_DOWN: { lx = x; ly = y; panel_mmove(&panel_root, 0, 0, settings.window_width, settings.window_height, x, y, 0, 0); panel_mdown(&panel_root); // pointer[pointer_index].down = true; // pointer[pointer_index].x = x; // pointer[pointer_index].y = y; // pointerinput2(pointer_index); already_up = 0; LOG_TRACE("Android", "down %f %f, %u" , x, y, pointer_index); p_down = 1; p_last_down = get_time(); break; } case AMOTION_EVENT_ACTION_UP: case AMOTION_EVENT_ACTION_POINTER_UP: { // panel_mmove(&panel_root, 0, 0, width, height, x, y, 0); if (!already_up) { panel_mup(&panel_root); panel_mleave(&panel_root); } // pointer[pointer_index].down = false; // pointer[pointer_index].x = x; // pointer[pointer_index].y = y; // pointerinput(pointer_index); LOG_TRACE("Android", "up %f %f, %u" , x, y, pointer_index); p_down = 0; break; } case AMOTION_EVENT_ACTION_MOVE: { panel_mmove(&panel_root, 0, 0, settings.window_width, settings.window_height, x, y, x - lx, y - ly); if (lx != (int)x || ly != (int)y) { p_down = 0; lx = x; ly = y; LOG_TRACE("Android", "move %f %f, %u" , x, y, pointer_index); } // pointer[pointer_index].x = x; // pointer[pointer_index].y = y; break; } } } else if (type == AINPUT_EVENT_TYPE_KEY) { int32_t action = AMotionEvent_getAction(event); int32_t key = AKeyEvent_getKeyCode(event); if (action == AKEY_EVENT_ACTION_DOWN) { switch (key) { case AKEYCODE_VOLUME_UP: case AKEYCODE_VOLUME_DOWN: { handled = 0; break; } case AKEYCODE_MENU: { // open menu break; } case AKEYCODE_SHIFT_LEFT: case AKEYCODE_SHIFT_RIGHT: { shift = 1; break; } case AKEYCODE_BACK: { // ANativeActivity_finish(activity); break; } default: { uint32_t c = getkeychar(key); if (c != 0) { if (edit_active()) { // LOG_TRACE("Android", "%u" , c); edit_char(c, 0, 0); } // inputchar(c); } break; } } } else if (action == AKEY_EVENT_ACTION_UP) { if (key == AKEYCODE_SHIFT_LEFT || key == AKEYCODE_SHIFT_RIGHT) { shift = 0; } } } AInputQueue_finishEvent(inputQueue, event, handled); } } static void android_main(struct android_app *state) { utox_init(); theme_load(THEME_DEFAULT); settings.verbose = ~0; // Make sure glue isn't stripped // ANativeActivity* nativeActivity = state->activity; // internalPath = nativeActivity->internalDataPath; pipe(pipefd); fcntl(pipefd[0], F_SETFL, O_NONBLOCK); // Override to max spam for android settings.verbose = LOG_LVL_TRACE; thread(toxcore_thread, NULL); initfonts(); ui_rescale(12); /* wait for tox thread to start */ while (!tox_thread_init) { yieldcpu(1); } /* Code has been changed, this probably should be moved! */ flist_start(); ui_rescale(15); while (!destroy) { if (p_down && (p_last_down + 500 * 1000 * 1000) < get_time()) { panel_mup(&panel_root); panel_mright(&panel_root); p_down = 0; already_up = 1; } inputQueue = (AInputQueue *)inputQueueNew; if (inputQueue != NULL) { AInputEvent *event = NULL; while (AInputQueue_hasEvents(inputQueue) && AInputQueue_getEvent(inputQueue, &event) >= 0) { utox_andoid_input(inputQueue, event); } } int rlen, len; PIPING piping; while ((len = read(pipefd[0], (void *)&piping, sizeof(PIPING))) > 0) { LOG_TRACE("Android", "Piping %u %u" , len, sizeof(PIPING)); while (len != sizeof(PIPING)) { if ((rlen = read(pipefd[0], (void *)&piping + len, sizeof(PIPING) - len)) > 0) { len += rlen; } } utox_message_dispatch(piping.msg, piping.param1, piping.param2, piping.data); } ANativeWindow *win = (ANativeWindow *)windowN; if (win != window) { // new window if (window != NULL) { LOG_INFO("AndroidNative", "Replace old Window"); freefonts(); GL_raze_surface(); } window = win; if (window != NULL) { if (init_display(window) == false) { LOG_INFO("AndroidNative", "init_err"); ANativeActivity_finish(activity); break; } } } if (window != NULL && have_focus) { utox_android_redraw_window(); } usleep(1000); } LOG_TRACE("Android", "ANDROID DESTROYED" ); } void showkeyboard(bool show) { JavaVM *vm = activity->vm; JNIEnv *env = activity->env; JavaVMAttachArgs lJavaVMAttachArgs; lJavaVMAttachArgs.version = JNI_VERSION_1_6; lJavaVMAttachArgs.name = "NativeThread"; lJavaVMAttachArgs.group = NULL; (*vm)->AttachCurrentThread(vm, &env, &lJavaVMAttachArgs); // error check jobject lNativeActivity = activity->clazz; jclass ClassNativeActivity = (*env)->GetObjectClass(env, lNativeActivity); jclass ClassInputMethodManager = (*env)->FindClass(env, "android/view/inputmethod/InputMethodManager"); jfieldID fid = (*env)->GetFieldID(env, ClassNativeActivity, "mIMM", "Landroid/view/inputmethod/InputMethodManager;"); jobject lInputMethodManager = (*env)->GetObjectField(env, lNativeActivity, fid); jmethodID MethodGetWindow = (*env)->GetMethodID(env, ClassNativeActivity, "getWindow", "()Landroid/view/Window;"); jobject lWindow = (*env)->CallObjectMethod(env, lNativeActivity, MethodGetWindow); jclass ClassWindow = (*env)->FindClass(env, "android/view/Window"); jmethodID MethodGetDecorView = (*env)->GetMethodID(env, ClassWindow, "getDecorView", "()Landroid/view/View;"); jobject lDecorView = (*env)->CallObjectMethod(env, lWindow, MethodGetDecorView); if (show) { jmethodID MethodShowSoftInput = (*env)->GetMethodID(env, ClassInputMethodManager, "showSoftInput", "(Landroid/view/View;I)Z"); jboolean lResult = (*env)->CallBooleanMethod(env, lInputMethodManager, MethodShowSoftInput, lDecorView, 0); utox_android_redraw_window(); } else { jclass ClassView = (*env)->FindClass(env, "android/view/View"); jmethodID MethodGetWindowToken = (*env)->GetMethodID(env, ClassView, "getWindowToken", "()Landroid/os/IBinder;"); jobject lBinder = (*env)->CallObjectMethod(env, lDecorView, MethodGetWindowToken); jmethodID MethodHideSoftInput = (*env)->GetMethodID(env, ClassInputMethodManager, "hideSoftInputFromWindow", "(Landroid/os/IBinder;I)Z"); jboolean lRes = (*env)->CallBooleanMethod(env, lInputMethodManager, MethodHideSoftInput, lBinder, 0); } /*jmethodID MethodToggle = (*env)->GetMethodID(env, ClassInputMethodManager, "toggleSoftInput", "(II)V"); (*env)->CallVoidMethod(env, lInputMethodManager, MethodToggle, 0, 0);*/ (*vm)->DetachCurrentThread(vm); } static void onDestroy(ANativeActivity *act) { destroy = 1; } static void onNativeWindowCreated(ANativeActivity *act, ANativeWindow *win) { LOG_NOTE("AndroidNative", "Native Window Made"); windowN = win; } static void onNativeWindowDestroyed(ANativeActivity *act, ANativeWindow *win) { LOG_NOTE("AndroidNative", "Native Window Killed"); windowN = NULL; } static void onWindowFocusChanged(ANativeActivity *act, int focus) { have_focus = (focus != 0); } static void onInputQueueCreated(ANativeActivity *act, AInputQueue *queue) { inputQueueNew = queue; } static void onInputQueueDestroyed(ANativeActivity *act, AInputQueue *queue) { inputQueueNew = NULL; } static void onContentRectChanged(ANativeActivity *activity, const ARect *r) { rect = *r; LOG_TRACE("AndroidNative", "window changed rect: %u %u %u %u" , rect.left, rect.right, rect.top, rect.bottom); settings.window_baseline = rect.bottom; _redraw = 1; } __attribute__((externally_visible)) void ANativeActivity_onCreate(ANativeActivity *act, void *savedState, size_t savedStateSize) { if (!act) { return; } activity = act; // Add callbacks here (find them in android/native_activity.h) act->callbacks->onDestroy = onDestroy; act->callbacks->onNativeWindowCreated = onNativeWindowCreated; act->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyed; act->callbacks->onWindowFocusChanged = onWindowFocusChanged; act->callbacks->onInputQueueCreated = onInputQueueCreated; act->callbacks->onInputQueueDestroyed = onInputQueueDestroyed; act->callbacks->onContentRectChanged = onContentRectChanged; // start main thread (android_main) pthread_t thread; pthread_attr_t myattr; pthread_attr_init(&myattr); pthread_attr_setdetachstate(&myattr, PTHREAD_CREATE_DETACHED); pthread_create(&thread, &myattr, (void *(*)(void *))android_main, NULL); } void launch_at_startup(bool should) {} uTox/src/android/logging.h0000600000175000001440000000015214003056216014502 0ustar rakusers#include #define debug(...) (__android_log_print(ANDROID_LOG_INFO, "utox", __VA_ARGS__)) uTox/src/android/gl.h0000600000175000001440000000422414003056216013462 0ustar rakusers#ifndef ANDROID_GL_H #define ANDROID_GL_H #include #include #include #include #define _GNU_SOURCE #include typedef struct native_image NATIVE_IMAGE; typedef struct { int16_t x, y; uint16_t tx, ty; } VERTEX2D; typedef struct { VERTEX2D vertex[4]; } QUAD2D; void makeglyph(QUAD2D *quad, int16_t x, int16_t y, uint16_t mx, uint16_t my, uint16_t width, uint16_t height); uint32_t setcolor(uint32_t a); void drawrect(int x, int y, int right, int bottom, uint32_t color); void draw_rect_fill(int x, int y, int width, int height, uint32_t color); void draw_rect_frame(int x, int y, int width, int height, uint32_t color); void drawhline(int x, int y, int x2, uint32_t color); void drawvline(int x, int y, int y2, uint32_t color); void drawalpha(int bm, int x, int y, int width, int height, uint32_t color); void loadalpha(int bm, void *data, int width, int height); void pushclip(int left, int top, int w, int h); void popclip(void); void enddraw(int x, int y, int width, int height); bool gl_init(void); /* gl initialization with EGL */ bool init_display(ANativeWindow *window); void GL_draw_image(const NATIVE_IMAGE *data, int x, int y, uint32_t width, uint32_t height, uint32_t imgx, uint32_t imgy); NATIVE_IMAGE *GL_utox_image_to_native(const uint8_t *data, size_t size, uint16_t *w, uint16_t *h, bool keep_alpha); int GL_utox_android_redraw_window(); void GL_raze_surface(void); int GL_drawtext(int x, int xmax, int y, char *str, uint16_t length); #if 0 void drawimage(NATIVE_IMAGE data, int x, int y, int width, int height, int maxwidth, bool zoom, double position) { GLuint texture = data; if(!zoom && width > maxwidth) { makequad(&quads[0], x, y, x + maxwidth, y + (height * maxwidth / width)); } else { makequad(&quads[0], x - (int)((double)(width - maxwidth) * position), y, x + width, y + height); } glBindTexture(GL_TEXTURE_2D, texture); float one[] = {1.0, 1.0, 1.0}; float zero[] = {0.0, 0.0, 0.0}; glUniform3fv(k, 1, one); glUniform3fv(k2, 1, zero); glDrawQuads(0, 1); glUniform3fv(k2, 1, one); } #endif #endif // ANDROID_GL_H uTox/src/android/gl.c0000600000175000001440000003736214003056216013466 0ustar rakusers#include "gl.h" #include "freetype.h" #include "main.h" #include "../native/ui.h" #include "../debug.h" #include "../macros.h" #include "../settings.h" #include "../text.h" #include "../ui.h" #include "../ui/svg.h" #include "../main.h" // stbi const char vertex_shader[] = "uniform vec4 matrix;" "attribute vec2 pos;" "attribute vec2 tex;" "varying vec2 x;" "void main(){" "x = tex / 32768.0;" "gl_Position = vec4((pos + matrix.xy) * matrix.zw, 0.0, 1.0);" "}", fragment_shader[] = #ifndef NO_OPENGL_ES "precision mediump float;" #endif "uniform sampler2D samp;" "uniform vec3 k;" "uniform vec3 k2;" "varying vec2 x;" "void main(){" "gl_FragColor = (texture2D(samp, x) + vec4(k2, 0.0)) * vec4(k, 1.0);" "}"; static GLuint prog, white; static GLint matrix, k, k2, samp; static GLuint bitmap[BM_ENDMARKER]; static QUAD2D quads[64]; static EGLDisplay display; static EGLSurface surface; static EGLContext context; static EGLConfig config; #ifndef NO_OPENGL_ES #define glDrawQuads(x, y) glDrawElements(GL_TRIANGLES, (y)*6, GL_UNSIGNED_BYTE, &quad_indices[(x)*6]) static uint8_t quad_indices[384]; #else #define glDrawQuads(x, y) glDrawArrays(GL_QUADS, (x), 4 * (y)) #endif static void makequad(QUAD2D *quad, int16_t x, int16_t y, int16_t right, int16_t bottom) { quad->vertex[0].x = x; quad->vertex[0].y = y; quad->vertex[0].tx = 0; quad->vertex[0].ty = 0; quad->vertex[1].x = right; quad->vertex[1].y = y; quad->vertex[1].tx = 32768; quad->vertex[1].ty = 0; quad->vertex[2].x = right; quad->vertex[2].y = bottom; quad->vertex[2].tx = 32768; quad->vertex[2].ty = 32768; quad->vertex[3].x = x; quad->vertex[3].y = bottom; quad->vertex[3].tx = 0; quad->vertex[3].ty = 32768; } static void makeline(QUAD2D *quad, int16_t x, int16_t y, int16_t x2, int16_t y2) { quad->vertex[0].x = x; quad->vertex[0].y = y; quad->vertex[1].x = x2; quad->vertex[1].y = y2; } void makeglyph(QUAD2D *quad, int16_t x, int16_t y, uint16_t mx, uint16_t my, uint16_t width, uint16_t height) { quad->vertex[0].x = x; quad->vertex[0].y = y; quad->vertex[0].tx = mx * 64; quad->vertex[0].ty = my * 64; quad->vertex[1].x = x + width; quad->vertex[1].y = y; quad->vertex[1].tx = (mx + width) * 64; quad->vertex[1].ty = my * 64; quad->vertex[2].x = x + width; quad->vertex[2].y = y + height; quad->vertex[2].tx = (mx + width) * 64; quad->vertex[2].ty = (my + height) * 64; quad->vertex[3].x = x; quad->vertex[3].y = y + height; quad->vertex[3].tx = mx * 64; quad->vertex[3].ty = (my + height) * 64; } static void set_color(uint32_t a) { union { uint32_t c; struct { uint8_t r, g, b, a; }; } color; color.c = a; float c[] = { (float)color.r / 255.0, (float)color.g / 255.0, (float)color.b / 255.0 }; glUniform3fv(k, 1, c); } uint32_t colori; float colorf[3]; uint32_t setcolor(uint32_t a) { union { uint32_t c; struct { uint8_t r, g, b, a; }; } color; color.c = a; colorf[0] = (float)color.r / 255.0; colorf[1] = (float)color.g / 255.0; colorf[2] = (float)color.b / 255.0; uint32_t s = colori; colori = a; return s; } void drawrect(int x, int y, int right, int bottom, uint32_t color) { set_color(color); glBindTexture(GL_TEXTURE_2D, white); makequad(&quads[0], x, y, right, bottom); glDrawQuads(0, 1); } void draw_rect_fill(int x, int y, int width, int height, uint32_t color) { drawrect(x, y, x + width, y + height, color); } void draw_rect_frame(int x, int y, int width, int height, uint32_t color) { set_color(color); glBindTexture(GL_TEXTURE_2D, white); makequad(&quads[0], x, y, x + width, y + height); glDrawArrays(GL_LINE_LOOP, 0, 4); } void drawhline(int x, int y, int x2, uint32_t color) { set_color(color); glBindTexture(GL_TEXTURE_2D, white); makeline(&quads[0], x, y + 1, x2, y + 1); glDrawArrays(GL_LINES, 0, 2); } void drawvline(int x, int y, int y2, uint32_t color) { set_color(color); glBindTexture(GL_TEXTURE_2D, white); makeline(&quads[0], x + 1, y, x + 1, y2); glDrawArrays(GL_LINES, 0, 2); } void drawalpha(int bm, int x, int y, int width, int height, uint32_t color) { set_color(color); glBindTexture(GL_TEXTURE_2D, bitmap[bm]); makequad(&quads[0], x, y, x + width, y + height); glDrawQuads(0, 1); } void loadalpha(int bm, void *data, int width, int height) { glBindTexture(GL_TEXTURE_2D, bitmap[bm]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data); } typedef struct { int16_t x, y; uint16_t width, height; } RECT; static RECT clip[16]; static int clipk; void pushclip(int left, int top, int w, int h) { if (!clipk) { glEnable(GL_SCISSOR_TEST); } RECT *r = &clip[clipk++]; r->x = left; r->y = settings.window_height - (top + h); r->width = w; r->height = h; glScissor(r->x, r->y, r->width, r->height); } void popclip(void) { clipk--; if (!clipk) { glDisable(GL_SCISSOR_TEST); return; } RECT *r = &clip[clipk - 1]; glScissor(r->x, r->y, r->width, r->height); } void enddraw(int x, int y, int width, int height) { LOG_TRACE("AndroidGL", "Going to swap buffers"); if (!eglSwapBuffers(display, surface)) { LOG_ERR("AndroidGL", "OpenGL Swap errored! %d", eglGetError()); } } bool gl_init(void) { LOG_INFO("AndroidGL", "gl init\n"); GLuint vertshader, fragshader; GLint status; const GLchar *data; vertshader = glCreateShader(GL_VERTEX_SHADER); if (!vertshader) { LOG_TRACE("gl", "glCreateShader() failed (vert)" ); return false; } data = vertex_shader; glShaderSource(vertshader, 1, &data, NULL); glCompileShader(vertshader); glGetShaderiv(vertshader, GL_COMPILE_STATUS, &status); if (!status) { LOG_TRACE("gl", "glCompileShader() failed (vert):\n%s" , data); GLint infologsize = 0; glGetShaderiv(vertshader, GL_INFO_LOG_LENGTH, &infologsize); if (infologsize) { char *infolog = malloc(infologsize); glGetShaderInfoLog(vertshader, infologsize, NULL, (GLbyte *)infolog); LOG_TRACE("gl", "Infolog: %s" , infolog); free(infolog); } return false; } fragshader = glCreateShader(GL_FRAGMENT_SHADER); if (!fragshader) { return false; } data = &fragment_shader[0]; glShaderSource(fragshader, 1, &data, NULL); glCompileShader(fragshader); glGetShaderiv(fragshader, GL_COMPILE_STATUS, &status); if (!status) { LOG_TRACE("gl", "glCompileShader failed (frag):\n%s" , data); GLint infologsize = 0; glGetShaderiv(fragshader, GL_INFO_LOG_LENGTH, &infologsize); if (infologsize) { char *infolog = malloc(infologsize); glGetShaderInfoLog(fragshader, infologsize, NULL, (GLbyte *)infolog); LOG_TRACE("gl", "Infolog: %s" , infolog); free(infolog); } return false; } prog = glCreateProgram(); glAttachShader(prog, vertshader); glAttachShader(prog, fragshader); glBindAttribLocation(prog, 0, "pos"); glBindAttribLocation(prog, 1, "tex"); glLinkProgram(prog); glGetProgramiv(prog, GL_LINK_STATUS, &status); if (!status) { LOG_TRACE("gl", "glLinkProgram failed" ); GLint infologsize = 0; glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &infologsize); if (infologsize) { char *infolog = malloc(infologsize); glGetShaderInfoLog(prog, infologsize, NULL, (GLbyte *)infolog); LOG_TRACE("gl", "Infolog: %s" , infolog); free(infolog); } return false; } glUseProgram(prog); matrix = glGetUniformLocation(prog, "matrix"); k = glGetUniformLocation(prog, "k"); k2 = glGetUniformLocation(prog, "k2"); samp = glGetUniformLocation(prog, "samp"); LOG_TRACE("gl", "uniforms: %i %i %i" , matrix, k, samp); GLint zero = 0; float one[] = { 1.0, 1.0, 1.0 }; glUniform1iv(samp, 1, &zero); glUniform3fv(k2, 1, one); uint8_t wh = { 255 }; glGenTextures(1, &white); glBindTexture(GL_TEXTURE_2D, white); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1, 1, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &wh); // glVertexAttribPointer(0, 2, GL_SHORT, GL_FALSE, sizeof(VERTEX2D), &quads[0]); glVertexAttribPointer(1, 2, GL_UNSIGNED_SHORT, GL_FALSE, sizeof(VERTEX2D), &quads[0].vertex[0].tx); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); // Alpha blending glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); // glPixelStorei(GL_UNPACK_ALIGNMENT, 1); #ifndef NO_OPENGL_ES uint8_t i = 0; uint16_t ii = 0; do { quad_indices[ii] = i + 0; quad_indices[ii + 1] = i + 1; quad_indices[ii + 2] = i + 3; quad_indices[ii + 3] = i + 3; quad_indices[ii + 4] = i + 1; quad_indices[ii + 5] = i + 2; i += 4; ii += 6; } while (i); #endif glGenTextures(COUNTOF(bitmap), bitmap); svg_draw(0); loadfonts(); float vec[4]; vec[0] = -(float)settings.window_width / 2.0; vec[1] = -(float)settings.window_height / 2.0; vec[2] = 2.0 / (float)settings.window_width; vec[3] = -2.0 / (float)settings.window_height; glUniform4fv(matrix, 1, vec); LOG_INFO("AndroidGL", "GL init ready w %u h %u", settings.window_width, settings.window_height); ui_size(settings.window_width, settings.window_height); glViewport(0, 0, settings.window_width, settings.window_height); redraw(); return true; } /* gl initialization with EGL */ bool init_display(ANativeWindow *window) { LOG_INFO("AndroidGL", "gl display init\n"); const EGLint attrib_list[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; const EGLint attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 0, EGL_NONE }; EGLint numConfigs; display = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(display, NULL, NULL); eglChooseConfig(display, attribs, &config, 1, &numConfigs); EGLint format; eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format); ANativeWindow_setBuffersGeometry(window, 0, 0, format); surface = eglCreateWindowSurface(display, config, window, NULL); context = eglCreateContext(display, config, NULL, attrib_list); if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) { LOG_ERR("AndroidGL", "eglMakeCurrent failed!"); return false; } int32_t w, h; eglQuerySurface(display, surface, EGL_WIDTH, &w); eglQuerySurface(display, surface, EGL_HEIGHT, &h); settings.window_width = w; settings.window_height = h; bool init = gl_init(); if (init == false) { LOG_ERR("AndroidGL", "gl_init failed :<"); } return init; } void GL_draw_image(const NATIVE_IMAGE *data, int x, int y, uint32_t width, uint32_t height, uint32_t imgx, uint32_t imgy) { GLuint texture = data->img; makequad(&quads[0], x - imgx, y - imgy, x + width, y + height); glBindTexture(GL_TEXTURE_2D, texture); float one[] = { 1.0, 1.0, 1.0 }; float zero[] = { 0.0, 0.0, 0.0 }; glUniform3fv(k, 1, one); glUniform3fv(k2, 1, zero); glDrawQuads(0, 1); glUniform3fv(k2, 1, one); } NATIVE_IMAGE *GL_utox_image_to_native(const uint8_t *data, size_t size, uint16_t *w, uint16_t *h, bool keep_alpha) { unsigned width, height, bpp; uint8_t *out = stbi_load_from_memory(data, size, &width, &height, &bpp, 3); if (out == NULL || width == 0 || height == 0) { return 0; } *w = width; *h = height; GLuint texture = 0; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, out); free(out); return texture; } // Returns 1 if redraw is needed int GL_utox_android_redraw_window() { LOG_DEBUG("AndroidGL", "Redraw window"); int32_t new_width, new_height; eglQuerySurface(display, surface, EGL_WIDTH, &new_width); eglQuerySurface(display, surface, EGL_HEIGHT, &new_height); if (new_width != (int32_t)settings.window_width || new_height != (int32_t)settings.window_height) { LOG_DEBUG("AndroidGL", "Redraw window new size"); settings.window_width = new_width; settings.window_height = new_height; float vec[4]; vec[0] = -(float)settings.window_width / 2.0; vec[1] = -(float)settings.window_height / 2.0; vec[2] = 2.0 / (float)settings.window_width; vec[3] = -2.0 / (float)settings.window_height; glUniform4fv(matrix, 1, vec); ui_size(settings.window_width, settings.window_height); glViewport(0, 0, settings.window_width, settings.window_height); return 1; } return 0; } void GL_raze_surface(void) { // eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(display, context); eglDestroySurface(display, surface); eglTerminate(display); } int GL_drawtext(int x, int xmax, int y, char *str, uint16_t length) { glUniform3fv(k, 1, colorf); glBindTexture(GL_TEXTURE_2D, sfont->texture); int c = 0; while (length > 0) { uint32_t ch; uint8_t len = utf8_len_read(str, &ch); str += len; length -= len; GLYPH *g = font_getglyph(sfont, ch); if (g) { if (x + g->xadvance > xmax) { x = -x; break; } if (c == 64) { glDrawQuads(0, 64); c = 0; } makeglyph(&quads[c++], x + g->x, y + g->y, g->mx, g->my, g->width, g->height); x += g->xadvance; } } glDrawQuads(0, c); return x; } #if 0 void drawimage(NATIVE_IMAGE data, int x, int y, int width, int height, int maxwidth, bool zoom, double position) { GLuint texture = data; if(!zoom && width > maxwidth) { makequad(&quads[0], x, y, x + maxwidth, y + (height * maxwidth / width)); } else { makequad(&quads[0], x - (int)((double)(width - maxwidth) * position), y, x + width, y + height); } glBindTexture(GL_TEXTURE_2D, texture); float one[] = {1.0, 1.0, 1.0}; float zero[] = {0.0, 0.0, 0.0}; glUniform3fv(k, 1, one); glUniform3fv(k2, 1, zero); glDrawQuads(0, 1); glUniform3fv(k2, 1, one); } #endif uTox/src/android/freetype.h0000600000175000001440000000117014003056216014700 0ustar rakusers#ifndef ANDROID_FREETYPE_H #define ANDROID_FREETYPE_H #include #include #include #include typedef struct { uint32_t ucs4; int16_t x, y; uint16_t width, height, xadvance, xxxx; int16_t mx, my; } GLYPH; typedef struct { FT_Face face; uint8_t *fontmap; uint16_t x, y, my, height; GLuint texture; GLYPH * glyphs[128]; } FONT; extern FT_Library ftlib; extern FONT font[16], *sfont; GLYPH *font_getglyph(FONT *f, uint32_t ch); void initfonts(void); void loadfonts(void); void freefonts(void); #endif // ANDROID_FREETYPE_H uTox/src/android/freetype.c0000600000175000001440000000733714003056216014706 0ustar rakusers#include "main.h" #include "freetype.h" #include "gl.h" #include "../macros.h" #include "../ui.h" #include "../ui/draw.h" #define PIXELS(x) (((x) + 32) / 64) FT_Library ftlib; FONT font[16], *sfont; GLYPH *font_getglyph(FONT *f, uint32_t ch) { uint32_t hash = ch % 128; GLYPH * g = f->glyphs[hash], *s = g; if (g) { while (g->ucs4 != ~0) { if (g->ucs4 == ch) { return g; } g++; } uint32_t count = (uint32_t)(g - s); g = realloc(s, (count + 2) * sizeof(GLYPH)); if (!g) { return NULL; } f->glyphs[hash] = g; g += count; } else { g = malloc(sizeof(GLYPH) * 2); if (!g) { return NULL; } f->glyphs[hash] = g; } g[1].ucs4 = ~0; FT_UInt index = FT_Get_Char_Index(f->face, ch); FT_Load_Glyph(f->face, index, FT_LOAD_RENDER); FT_GlyphSlotRec *p = f->face->glyph; g->ucs4 = ch; g->x = p->bitmap_left; g->y = PIXELS(f->face->size->metrics.ascender) - p->bitmap_top; g->width = p->bitmap.width; g->height = p->bitmap.rows; g->xadvance = (p->advance.x + (1 << 5)) >> 6; if (f->x + g->width > 512) { f->x = 0; f->y = f->my; } g->mx = f->x; g->my = f->y; glBindTexture(GL_TEXTURE_2D, f->texture); glTexSubImage2D(GL_TEXTURE_2D, 0, f->x, f->y, g->width, g->height, GL_ALPHA, GL_UNSIGNED_BYTE, p->bitmap.buffer); f->x += g->width; if (f->y + g->height > f->my) { f->my = f->y + g->height; } return g; } void initfonts(void) { FT_Init_FreeType(&ftlib); } static bool font_open(FONT *f, double size, uint8_t weight) { FT_New_Face(ftlib, "/system/fonts/Roboto-Regular.ttf", 0, &f->face); FT_Set_Char_Size(f->face, (size * 64.0 + 0.5), (size * 64.0 + 0.5), 0, 0); f->fontmap = malloc(512 * 512); f->x = 0; f->y = 0; f->my = 0; f->height = 512; glGenTextures(1, &f->texture); glBindTexture(GL_TEXTURE_2D, f->texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 512, 512, 0, GL_ALPHA, GL_UNSIGNED_BYTE, f->fontmap); return 1; } void loadfonts(void) { font_open(&font[FONT_TEXT], SCALE(12.0), 0); font_open(&font[FONT_TITLE], SCALE(12.0), 1); font_open(&font[FONT_SELF_NAME], SCALE(14.0), 1); font_open(&font[FONT_STATUS], SCALE(11.0), 0); font_open(&font[FONT_LIST_NAME], SCALE(12.0), 0); // font_open(&font[FONT_MSG], F(11.0), 2); // font_open(&font[FONT_MSG_NAME], F(10.0), 2); font_open(&font[FONT_MISC], SCALE(10.0), 0); // font_open(&font[FONT_MSG_LINK], F(11.0), 2); font_small_lineheight = (font[FONT_TEXT].face->size->metrics.height + (1 << 5)) >> 6; // font_msg_lineheight = (font[FONT_MSG].face->size->metrics.height + (1 << 5)) >> 6; } void freefonts(void) { for (size_t i = 0; i != COUNTOF(font); i++) { FONT *f = &font[i]; if (f->face) { FT_Done_Face(f->face); } for (size_t j = 0; j != COUNTOF(f->glyphs); j++) { GLYPH *g = f->glyphs[j]; if (g) { /*while(g->ucs4 != ~0) { if(g->pic) { XRenderFreePicture(display, g->pic); } g++; }*/ free(f->glyphs[j]); f->glyphs[j] = NULL; } } } } static int _drawtext(int x, int xmax, int y, char *str, uint16_t length) { return GL_drawtext(x, xmax, y, str, length); } #include "../shared/freetype-text.c" uTox/src/android/audio.c0000600000175000001440000002405614003056216014161 0ustar rakusers/* uTox audio using OpenSL * todo: error checking, only record when needed, audio sources only in "playing" state when they have something to * play(does it make a difference?) */ #include "main.h" #include "../debug.h" #include "../settings.h" #include "../macros.h" #include "../utox.h" #include "../native/audio.h" #include "../native/thread.h" #include "../../langs/i18n_decls.h" #include #include #include #include "../native/audio.h" static SLObjectItf engineObject = NULL; static SLEngineItf engineEngine; static SLObjectItf outputMixObject = NULL; static SLObjectItf recorderObject = NULL; static SLRecordItf recorderRecord; static SLAndroidSimpleBufferQueueItf recorderBufferQueue; #define FRAMES (960 * 3) static short recbuf[960 * 2]; typedef struct { SLObjectItf player; SLAndroidSimpleBufferQueueItf queue; uint8_t channels; uint8_t value; volatile bool queued[8]; uint8_t unqueue; short * buf; } AUDIO_PLAYER; AUDIO_PLAYER loopback, call_player[32]; static SLDataFormat_PCM format_pcm = {.formatType = SL_DATAFORMAT_PCM, .numChannels = 1, .samplesPerSec = SL_SAMPLINGRATE_48, .bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16, .containerSize = SL_PCMSAMPLEFORMAT_FIXED_16, .channelMask = SL_SPEAKER_FRONT_CENTER, .endianness = SL_BYTEORDER_LITTLEENDIAN }; volatile bool call[32]; pthread_mutex_t callback_lock; void * frames[128]; uint8_t frame_count; void playCallback(SLAndroidSimpleBufferQueueItf bq, void *context) { AUDIO_PLAYER *p = context; p->queued[p->unqueue++] = 0; if (p->unqueue == 8) { p->unqueue = 0; } } void init_player(AUDIO_PLAYER *p, uint8_t channels) { format_pcm.numChannels = channels; format_pcm.channelMask = ((channels == 1) ? SL_SPEAKER_FRONT_CENTER : (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT)); p->channels = channels; SLDataLocator_AndroidSimpleBufferQueue loc_bufq = { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 8 }; SLDataSource audioSrc = { &loc_bufq, &format_pcm }; SLDataLocator_OutputMix loc_outmix = { SL_DATALOCATOR_OUTPUTMIX, outputMixObject }; SLDataSink audioSnk = { &loc_outmix, NULL }; SLPlayItf bqPlayerPlay; const SLInterfaceID ids[] = { SL_IID_BUFFERQUEUE }; const SLboolean reqs[] = { SL_BOOLEAN_TRUE }; (*engineEngine)->CreateAudioPlayer(engineEngine, &p->player, &audioSrc, &audioSnk, 1, ids, reqs); (*p->player)->Realize(p->player, SL_BOOLEAN_FALSE); (*p->player)->GetInterface(p->player, SL_IID_PLAY, &bqPlayerPlay); (*p->player)->GetInterface(p->player, SL_IID_BUFFERQUEUE, &p->queue); (*p->queue)->RegisterCallback(p->queue, playCallback, p); (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING); p->buf = malloc(960 * 2 * 8 * channels); } void close_player(AUDIO_PLAYER *p) { (*p->player)->Destroy(p->player); free(p->buf); memset(p, 0, sizeof(*p)); } static void player_queue(AUDIO_PLAYER *p, const int16_t *data, uint8_t channels) { if (channels != p->channels && p->player) { close_player(p); } if (!p->player) { init_player(p, channels); } SLresult result; if (!p->queued[p->value]) { p->queued[p->value] = 1; memcpy(&p->buf[p->value * 960 * channels], data, 960 * 2 * channels); result = (*p->queue)->Enqueue(p->queue, &p->buf[p->value * 960 * channels], 960 * 2 * channels); p->value++; if (p->value == 8) { p->value = 0; } } else { LOG_TRACE("Audio", "dropped" ); } } /* thread dedicated to encoding audio frames */ /* todo: exit */ void encoder_thread(void *arg) { while (1) { void * frame; uint8_t c; pthread_mutex_lock(&callback_lock); c = frame_count; if (c) { frame = frames[0]; memmove(&frames[0], &frames[1], (c - 1) * sizeof(void *)); frame_count--; } pthread_mutex_unlock(&callback_lock); if (c) { if (settings.audio_preview) { player_queue(&loopback, frame, 1); } // TODO fix this int i; for (i = 0; i < 32; i++) { if (call[i]) { int r; uint8_t dest[960 * 2]; /*if((r = toxav_prepare_audio_frame(arg, i, dest, sizeof(dest), frame, 960)) < 0) { LOG_TRACE("Audio", "toxav_prepare_audio_frame error %i" , r); continue; } if((r = toxav_send_audio(arg, i, dest, r)) < 0) { LOG_TRACE("Audio", "toxav_send_audio error %i %s" , r, strerror(errno)); }*/ // toxav_audio_send_frame(av, friend[i].number, (const int16_t *)buf, perframe, // UTOX_DEFAULT_AUDIO_CHANNELS, UTOX_DEFAULT_SAMPLE_RATE_A, NULL); } } free(frame); } if (c <= 1) { yieldcpu(1); } } } /* these two callbacks assume they will be called from the same thread (not at the same time from different threads) */ void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context) { SLresult result; static bool b; short * buf = &recbuf[b ? 960 : 0]; pthread_mutex_lock(&callback_lock); if (frame_count == 128) { LOG_TRACE("Audio", "problem~!~" ); } else { void *frame = malloc(960 * 2); memcpy(frame, buf, 960 * 2); frames[frame_count++] = frame; } result = (*bq)->Enqueue(bq, buf, 960 * 2); b = !b; pthread_mutex_unlock(&callback_lock); } bool createAudioRecorder(void) { SLresult result; // configure audio source SLDataLocator_IODevice loc_dev = { SL_DATALOCATOR_IODEVICE, SL_IODEVICE_AUDIOINPUT, SL_DEFAULTDEVICEID_AUDIOINPUT, NULL }; SLDataSource audioSrc = { &loc_dev, NULL }; // configure audio sink SLDataLocator_AndroidSimpleBufferQueue loc_bq = { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2 }; SLDataSink audioSnk = { &loc_bq, &format_pcm }; // create audio recorder // (requires the RECORD_AUDIO permission) const SLInterfaceID id[1] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE }; const SLboolean req[1] = { SL_BOOLEAN_TRUE }; result = (*engineEngine)->CreateAudioRecorder(engineEngine, &recorderObject, &audioSrc, &audioSnk, 1, id, req); if (SL_RESULT_SUCCESS != result) { return 0; } // realize the audio recorder result = (*recorderObject)->Realize(recorderObject, SL_BOOLEAN_FALSE); if (SL_RESULT_SUCCESS != result) { return 0; } // get the record interface result = (*recorderObject)->GetInterface(recorderObject, SL_IID_RECORD, &recorderRecord); // get the buffer queue interface result = (*recorderObject)->GetInterface(recorderObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &recorderBufferQueue); // register callback on the buffer queue result = (*recorderBufferQueue)->RegisterCallback(recorderBufferQueue, bqRecorderCallback, NULL); pthread_mutex_init(&callback_lock, NULL); // thread(encoder_thread, av); return 1; } void startRecording(void) { SLresult result; result = (*recorderRecord)->SetRecordState(recorderRecord, SL_RECORDSTATE_STOPPED); result = (*recorderBufferQueue)->Clear(recorderBufferQueue); result = (*recorderBufferQueue)->Enqueue(recorderBufferQueue, &recbuf[0], 960 * 2); result = (*recorderBufferQueue)->Enqueue(recorderBufferQueue, &recbuf[960], 960 * 2); result = (*recorderRecord)->SetRecordState(recorderRecord, SL_RECORDSTATE_RECORDING); } void stopRecording(void) { SLresult result; result = (*recorderRecord)->SetRecordState(recorderRecord, SL_RECORDSTATE_STOPPED); result = (*recorderBufferQueue)->Clear(recorderBufferQueue); pthread_mutex_lock(&callback_lock); unsigned int i; for (i = 0; i < frame_count; ++i) { free(frames[i]); frames[i] = NULL; } frame_count = 0; pthread_mutex_unlock(&callback_lock); } void createEngine(void) { SLresult result; result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL); result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE); result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine); result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, NULL, NULL); result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE); init_player(&loopback, 1); } /* ASSUMES LENGTH == 960 */ void audio_play(int32_t call_index, const int16_t *data, int length, uint8_t channels) { player_queue(&call_player[call_index], data, channels); } void audio_begin(int32_t call_index) { call[call_index] = 1; } void audio_end(int32_t call_index) { call[call_index] = 0; } void audio_detect(void) { createEngine(); createAudioRecorder(); postmessage_utox(AUDIO_IN_DEVICE, STR_AUDIO_IN_ANDROID, 1, (void *)(size_t)1); } bool audio_init(void *handle) { startRecording(); return 1; } bool audio_close(void *handle) { stopRecording(); return 1; } bool audio_frame(int16_t *buffer) { void * frame; uint8_t c; pthread_mutex_lock(&callback_lock); c = frame_count; if (c) { frame = frames[0]; memmove(&frames[0], &frames[1], (c - 1) * sizeof(void *)); frame_count--; } pthread_mutex_unlock(&callback_lock); if (c) { memcpy(buffer, frame, 960 * 2); free(frame); return 1; } return 0; } uTox/src/android/AndroidManifest.xml.in0000600000175000001440000000340014003056216017100 0ustar rakusers uTox/src/android/AndroidManifest.xml0000600000175000001440000000336514003056216016505 0ustar rakusers uTox/src/android/.idea/0000700000175000001440000000000014003056216013663 5ustar rakusersuTox/src/android/.idea/workspace.xml0000600000175000001440000004637414003056216016423 0ustar rakusers 1458026631571 uTox/src/android/.idea/vcs.xml0000600000175000001440000000033614003056216015204 0ustar rakusers uTox/src/android/.idea/modules.xml0000600000175000001440000000041214003056216016054 0ustar rakusers uTox/src/android/.idea/misc.xml0000600000175000001440000000124214003056216015341 0ustar rakusers uTox/src/android/.idea/copyright/0000700000175000001440000000000014003056216015673 5ustar rakusersuTox/src/android/.idea/copyright/profiles_settings.xml0000600000175000001440000000011414003056216022156 0ustar rakusers uTox/src/android/.idea/compiler.xml0000600000175000001440000000125614003056216016225 0ustar rakusers uTox/src/android/.idea/android.iml0000600000175000001440000000052014003056216016005 0ustar rakusers uTox/src/android/.idea/.name0000600000175000001440000000000714003056216014603 0ustar rakusersandroiduTox/screenshots/0000700000175000001440000000000014003056216013034 5ustar rakusersuTox/screenshots/utox-windows10.png0000600000175000001440000461667214003056216016422 0ustar rakusersPNG  IHDRp<%&sRGBgAMA aIDATx^v쾏N{Qg;=\BAFg/ An$3'J7ؑTe7m^GGa$NwbWY$:lctlEI=C6DV.oԥ#m/njclgaC@} d##U{99GI'aװf QlgPFFɶX y@il|QF>k;p֗clR+ߝFߒV/UB_x$_`L}]:&Ҧ74OwDH=YIjZJ=\>+nA,=qqrq3al_P6#GR=X-n3ƦAm:`J=zDqO(N|~w#o ۵7 ? r`JgsZkM4$$>hϒoqYa+?d~ۑYzQR:މ+}zӜ!#H@o4U5~62\<_pt6rl#y=!H%"%\S[D:$8I'e[^wQ ސrn7y##%=>,V{ |v _̳U,]R kɕXvdU>#|Ew}h9fy31K#M¾'T!&B}.h2!i$g -eʥˁ-5Epܔ] lϖܖ>0if'w6r>:-]ƓQWBv(+`Pys,W|$F gYoNܓ)=RLOs@yiIR僔6CoyD.H_xQ,ɔ I5 .߾ʈ77O'@s>x2L@JI:K.9gͣ]<r$,-YrHiH^D̓:(̟i5?9%ϯx1Vs &yx= h y)y= ] ?˺Y?/3]Yvv= 7#0tyZpxj8cYutfLo~6* 7"9]n%8^zKѼxX ރ3<1>r3T1>` n5&_齀dNg*KFk=ao|,EgW$?5|%y.uh!VDן$Z/}l61.ڦ@=T=x2W!y#g: -?>e&M[3޸XɱWK]m$ +YGוc.nSu޵vqXvqliۙ[ݍ:!iF< 8t%{NF:HԦϥuG`[]0/-нj1=nD~}:ouG )V w{L\Yzؕ-/g?]tˣwV_OUƖ^ޡWtyԣ_'wg鍵Oq=C쏓#>^ui'Q<uɆs ]p|GFΑpҏ+<3oR!3>@U]c"}[; H:5fG{7: r¸:ZGq~u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