diff --git a/.github/ISSUE_TEMPLATE/new-issue-template.md b/.github/ISSUE_TEMPLATE/new-issue-template.md
index 096eb28cb..4bac86e82 100644
--- a/.github/ISSUE_TEMPLATE/new-issue-template.md
+++ b/.github/ISSUE_TEMPLATE/new-issue-template.md
@@ -21,6 +21,7 @@ Please, before submitting a new issue verify and check:
- [ ] I tested it on latest raylib version from master branch
- [ ] I checked there is no similar issue already reported
+ - [ ] I checked the documentation on the [wiki](https://github.com/raysan5/raylib/wiki)
- [ ] My code has no errors or misuse of raylib
### Issue description
diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml
index dcee5a46b..838d7a341 100644
--- a/.github/workflows/android.yml
+++ b/.github/workflows/android.yml
@@ -82,7 +82,7 @@ jobs:
tar -czvf ${{ env.RELEASE_NAME }}.tar.gz ${{ env.RELEASE_NAME }}
- name: Upload Artifacts
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: ${{ env.RELEASE_NAME }}.tar.gz
path: ./build/${{ env.RELEASE_NAME }}.tar.gz
diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index fc2885a94..0e13b8e8f 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -36,7 +36,7 @@ jobs:
runs-on: windows-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
@@ -75,7 +75,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index 59cbfe334..3c1ef62b8 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -94,7 +94,7 @@ jobs:
tar -czvf ${{ env.RELEASE_NAME }}.tar.gz ${{ env.RELEASE_NAME }}
- name: Upload Artifacts
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: ${{ env.RELEASE_NAME }}.tar.gz
path: ./build/${{ env.RELEASE_NAME }}.tar.gz
diff --git a/.github/workflows/linux_examples.yml b/.github/workflows/linux_examples.yml
index 3084af05c..3ed2dc796 100644
--- a/.github/workflows/linux_examples.yml
+++ b/.github/workflows/linux_examples.yml
@@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Setup Environment
run: |
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
index 0bcdf9c0a..a9a036bd4 100644
--- a/.github/workflows/macos.yml
+++ b/.github/workflows/macos.yml
@@ -99,7 +99,7 @@ jobs:
tar -czvf ${{ env.RELEASE_NAME }}.tar.gz ${{ env.RELEASE_NAME }}
- name: Upload Artifacts
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: ${{ env.RELEASE_NAME }}.tar.gz
path: ./build/${{ env.RELEASE_NAME }}.tar.gz
diff --git a/.github/workflows/webassembly.yml b/.github/workflows/webassembly.yml
index b5d2ba6ca..b50cd8c46 100644
--- a/.github/workflows/webassembly.yml
+++ b/.github/workflows/webassembly.yml
@@ -29,7 +29,7 @@ jobs:
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v11
with:
- version: 3.0.0
+ version: 3.1.30
actions-cache-folder: 'emsdk-cache'
- name: Setup Release Version
@@ -69,7 +69,7 @@ jobs:
shell: cmd
- name: Upload Artifacts
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: ${{ env.RELEASE_NAME }}.zip
path: ./build/${{ env.RELEASE_NAME }}.zip
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index bdbe06887..cf9a9f33e 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -74,10 +74,25 @@ jobs:
# Setup MSBuild.exe path if required
- name: Setup MSBuild
- uses: microsoft/setup-msbuild@v1.0.2
+ uses: microsoft/setup-msbuild@v1.1
if: matrix.compiler == 'msvc16'
- - name: Build Library (MinGW-w64)
+ - name: Build Library (MinGW-w64 32bit)
+ run: |
+ cd src
+ x86_64-w64-mingw32-gcc.exe --version
+ windres.exe --version
+ dir C:\msys64\mingw64\bin
+ make PLATFORM=PLATFORM_DESKTOP CC=x86_64-w64-mingw32-gcc.exe RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CUSTOM_CFLAGS=-m32
+ //windres.exe -i raylib.dll.rc -o raylib.dll.rc.data -O coff --target=${{ matrix.WINDRES_ARCH }}
+ //make PLATFORM=PLATFORM_DESKTOP CC=${{ matrix.ARCH }}-w64-mingw32-gcc.exe RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
+ cd ..
+ shell: cmd
+ if: |
+ matrix.compiler == 'mingw-w64' &&
+ matrix.bits == 32
+
+ - name: Build Library (MinGW-w64 64bit)
run: |
cd src
${{ matrix.ARCH }}-w64-mingw32-gcc.exe --version
@@ -88,7 +103,9 @@ jobs:
make PLATFORM=PLATFORM_DESKTOP CC=${{ matrix.ARCH }}-w64-mingw32-gcc.exe RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
cd ..
shell: cmd
- if: matrix.compiler == 'mingw-w64'
+ if: |
+ matrix.compiler == 'mingw-w64' &&
+ matrix.bits == 64
- name: Build Library (MSVC16)
run: |
@@ -116,7 +133,7 @@ jobs:
shell: cmd
- name: Upload Artifacts
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: ${{ env.RELEASE_NAME }}.zip
path: ./build/${{ env.RELEASE_NAME }}.zip
diff --git a/.github/workflows/windows_examples.yml b/.github/workflows/windows_examples.yml
index 136273991..19e23cf1b 100644
--- a/.github/workflows/windows_examples.yml
+++ b/.github/workflows/windows_examples.yml
@@ -22,7 +22,7 @@ jobs:
runs-on: windows-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1
diff --git a/BINDINGS.md b/BINDINGS.md
index ec8e9d885..d4bd8fc21 100644
--- a/BINDINGS.md
+++ b/BINDINGS.md
@@ -6,65 +6,84 @@ Some people ported raylib to other languages in form of bindings or wrappers to
| name | raylib version | language | license | repo |
|:------------------:|:---------------:|:---------:|:----------:|-----------------------------------------------------------|
-| raylib | **4.2** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib | https://github.com/raysan5/raylib |
+| raylib | **4.5** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib | https://github.com/raysan5/raylib |
| raylib-boo | 3.7 | [Boo](http://boo-language.github.io/)| MIT | https://github.com/Rabios/raylib-boo |
-| Raylib-cs | **4.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib | https://github.com/ChrisDill/Raylib-cs |
-| Raylib-CsLo | **4.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | https://github.com/NotNotTech/Raylib-CsLo |
-| cl-raylib | **4.0** | [Common Lisp](https://common-lisp.net/) | MIT | https://github.com/longlene/cl-raylib |
-| raylib-cr | **4.0** | [Crystal](https://crystal-lang.org/) | Apache-2.0 | https://github.com/sol-vin/raylib-cr |
-| dart-raylib | **4.0** | [Dart](https://dart.dev/) | MIT | https://gitlab.com/wolfenrain/dart-raylib |
-| bindbc-raylib3 | **4.0** | [D](https://dlang.org/) | BSL-1.0 | https://github.com/o3o/bindbc-raylib3 |
-| dray | **4.0** | [D](https://dlang.org/) | Apache-2.0 | https://github.com/xdrie/dray |
-| raylib-d | **4.2** | [D](https://dlang.org/) | Zlib | https://github.com/schveiguy/raylib-d |
-| dlang_raylib | **4.0** | [D](https://dlang.org) | MPL-2.0 |https://github.com/rc-05/dlang_raylib |
+| Raylib-cs | **4.5** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib | https://github.com/ChrisDill/Raylib-cs |
+| Raylib-CsLo | 4.2 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | https://github.com/NotNotTech/Raylib-CsLo |
+| cl-raylib | 4.0 | [Common Lisp](https://common-lisp.net/) | MIT | https://github.com/longlene/cl-raylib |
+| claylib/wrap | **4.5** | [Common Lisp](https://common-lisp.net/) | Zlib | https://github.com/defun-games/claylib |
+| chez-raylib | **auto** | [Chez Scheme](https://cisco.github.io/ChezScheme/) | GPLv3 | https://github.com/Yunoinsky/chez-raylib |
+| raylib-cr | **4.6-dev (5e1a81)** | [Crystal](https://crystal-lang.org/) | Apache-2.0 | https://github.com/sol-vin/raylib-cr |
+| ray-cyber | 4.5 | [Cyber](https://cyberscript.dev) | MIT | https://github.com/fubark/ray-cyber |
+| raylib-c3 | **4.5** | [C3](https://c3-lang.org/) | Zlib | https://github.com/Its-Kenta/Raylib-C3 |
+| dart-raylib | 4.0 | [Dart](https://dart.dev/) | MIT | https://gitlab.com/wolfenrain/dart-raylib |
+| bindbc-raylib3 | **4.5** | [D](https://dlang.org/) | BSL-1.0 | https://github.com/o3o/bindbc-raylib3 |
+| dray | 4.2 | [D](https://dlang.org/) | Apache-2.0 | https://github.com/redthing1/dray |
+| raylib-d | **4.5** | [D](https://dlang.org/) | Zlib | https://github.com/schveiguy/raylib-d |
+| dlang_raylib | 4.0 | [D](https://dlang.org) | MPL-2.0 |https://github.com/rc-05/dlang_raylib |
| rayex | 3.7 | [elixir](https://elixir-lang.org/) | Apache-2.0 | https://github.com/shiryel/rayex |
-| raylib-factor | **4.0** | [Factor](https://factorcode.org/) | BSD | https://github.com/factor/factor/blob/master/extra/raylib/raylib.factor |
-| raylib-freebasic | **4.2** | [FreeBASIC](https://www.freebasic.net/) | MIT | https://github.com/WIITD/raylib-freebasic |
-| raylib-go | **4.2** | [Go](https://golang.org/) | Zlib | https://github.com/gen2brain/raylib-go |
-| raylib-guile | auto | [Guile](https://www.gnu.org/software/guile/) | Zlib | https://github.com/petelliott/raylib-guile |
+| raylib-factor | 4.0 | [Factor](https://factorcode.org/) | BSD | https://github.com/factor/factor/blob/master/extra/raylib/raylib.factor |
+| raylib-freebasic | **4.5** | [FreeBASIC](https://www.freebasic.net/) | MIT | https://github.com/WIITD/raylib-freebasic |
+| fortran-raylib | **4.5** | [Fortran](https://fortran-lang.org/) | ISC | https://github.com/interkosmos/fortran-raylib |
+| raylib for Pascal | **4.5** | [Object Pascal](https://en.wikipedia.org/wiki/Object_Pascal) | Modified Zlib | https://github.com/tinyBigGAMES/raylib |
+| raylib-go | 4.5 | [Go](https://golang.org/) | Zlib | https://github.com/gen2brain/raylib-go |
+| raylib-guile | **auto** | [Guile](https://www.gnu.org/software/guile/) | Zlib | https://github.com/petelliott/raylib-guile |
| gforth-raylib | 3.5 | [Gforth](https://gforth.org/) | MIT | https://github.com/ArnautDaniel/gforth-raylib |
-| raylib-hx | 4.0 | [Haxe](https://haxe.org/) | Zlib | https://github.com/foreignsasquatch/raylib-hx |
+| h-raylib | **4.6-dev** | [Haskell](https://haskell.org/) | Apache-2.0 | https://github.com/Anut-py/h-raylib |
+| raylib-hx | 4.2 | [Haxe](https://haxe.org/) | Zlib | https://github.com/foreignsasquatch/raylib-hx |
| hb-raylib | 3.5 | [Harbour](https://harbour.github.io) | MIT | https://github.com/MarcosLeonardoMendezGerencir/hb-raylib |
-| jaylib | **4.2** | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | GPLv3+CE | https://github.com/electronstudio/jaylib/ |
-| raylib-j | **4.0** | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | Zlib | https://github.com/CreedVI/Raylib-J |
-| raylib.jl | **4.2** | [Julia](https://julialang.org/) | Zlib | https://github.com/irishgreencitrus/raylib.jl |
+| jaylib | 4.5 | [Janet](https://janet-lang.org/) | MIT | https://github.com/janet-lang/jaylib |
+| jaylib | 4.2 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | GPLv3+CE | https://github.com/electronstudio/jaylib/ |
+| raylib-j | 4.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | Zlib | https://github.com/CreedVI/Raylib-J |
+| raylib.jl | 4.2 | [Julia](https://julialang.org/) | Zlib | https://github.com/irishgreencitrus/raylib.jl |
| kaylib | 3.7 | [Kotlin/native](https://kotlinlang.org) | ? | https://github.com/electronstudio/kaylib |
-| raylib-lua | **4.2** | [Lua](http://www.lua.org/) | ISC | https://github.com/TSnake41/raylib-lua |
-| raylua | **4.0** | [Lua](http://www.lua.org/) | MIT | https://github.com/Rabios/raylua |
+| kaylib | **4.5**| [Kotlin/native](https://kotlinlang.org) | Zlib | https://codeberg.org/Soutaisei/Kaylib |
+| raylib-lua | **4.5** | [Lua](http://www.lua.org/) | ISC | https://github.com/TSnake41/raylib-lua |
+| raylua | 4.0 | [Lua](http://www.lua.org/) | MIT | https://github.com/Rabios/raylua |
| nelua-raylib | 4.0 | [nelua](https://nelua.io/) | MIT | https://github.com/AKDev21/nelua-raylib |
+| Raylib.nelua | **4.5** | [nelua](https://nelua.io/) | Zlib | https://github.com/Its-Kenta/Raylib-Nelua |
| NimraylibNow! | 4.2 | [Nim](https://nim-lang.org/) | MIT | https://github.com/greenfork/nimraylib_now |
| raylib-Forever | auto | [Nim](https://nim-lang.org/) | ? | https://github.com/Guevara-chan/Raylib-Forever |
| naylib | auto | [Nim](https://nim-lang.org/) | MIT | https://github.com/planetis-m/naylib |
-| node-raylib | **4.0** | [Node.js](https://nodejs.org/en/) | Zlib | https://github.com/RobLoach/node-raylib |
+| node-raylib | **4.5** | [Node.js](https://nodejs.org/en/) | Zlib | https://github.com/RobLoach/node-raylib |
+| raylib-odin | **4.5** | [Odin](https://odin-lang.org/) | BSD-3Clause | https://github.com/odin-lang/Odin/tree/master/vendor/raylib |
| raylib_odin_bindings | 4.0-dev | [Odin](https://odin-lang.org/) | MIT | https://github.com/Deathbat2190/raylib_odin_bindings |
-| raylib-odin | **4.0** | [Odin](https://odin-lang.org/) | BSD-3Clause | https://github.com/odin-lang/Odin/tree/master/vendor/raylib |
-| raylib-ocaml | **4.0** | [OCaml](https://ocaml.org/) | MIT | https://github.com/tjammer/raylib-ocaml |
-| Ray4Laz | **4.2** | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal)| Zlib | https://github.com/GuvaCode/Ray4Laz |
-| Raylib.4.0.Pascal | **4.0** | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal)| Zlib | https://github.com/sysrpl/Raylib.4.0.Pascal |
+| raylib-ocaml | 4.2 | [OCaml](https://ocaml.org/) | MIT | https://github.com/tjammer/raylib-ocaml |
+| TurboRaylib | 4.2 | [Object Pascal](https://en.wikipedia.org/wiki/Object_Pascal) | MIT | https://github.com/turborium/TurboRaylib |
+| Ray4Laz | **4.5** | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal)| Zlib | https://github.com/GuvaCode/Ray4Laz |
+| Raylib.4.0.Pascal | 4.0 | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal)| Zlib | https://github.com/sysrpl/Raylib.4.0.Pascal |
| pyraylib | 3.7 | [Python](https://www.python.org/) | Zlib | https://github.com/Ho011/pyraylib |
-| raylib-python-cffi | **4.2** | [Python](https://www.python.org/) | EPL-2.0 | https://github.com/electronstudio/raylib-python-cffi |
-| raylib-php | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib | https://github.com/joseph-montanez/raylib-php |
+| raylib-python-cffi | 4.2 | [Python](https://www.python.org/) | EPL-2.0 | https://github.com/electronstudio/raylib-python-cffi |
+| raylibpyctbg | **4.5** | [Python](https://www.python.org/) | MIT | https://github.com/overdev/raylibpyctbg |
+| raylib-py | **4.5** | [Python](https://www.python.org/) | MIT | https://github.com/overdev/raylib-py |
+| raylib-python-ctypes | 4.6-dev | [Python](https://www.python.org/) | MIT | https://github.com/sDos280/raylib-python-ctypes |
+| raylib-php | **4.5** | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib | https://github.com/joseph-montanez/raylib-php |
| raylib-phpcpp | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib | https://github.com/oraoto/raylib-phpcpp |
-| raylibr | **4.0** | [R](https://www.r-project.org) | MIT | https://github.com/jeroenjanssens/raylibr |
+| raylibr | 4.0 | [R](https://www.r-project.org) | MIT | https://github.com/jeroenjanssens/raylibr |
+| raylib-ffi | 4.5 | [Rust](https://www.rust-lang.org/) | GPLv3 | https://github.com/ewpratten/raylib-ffi |
| raylib-rs | 3.5 | [Rust](https://www.rust-lang.org/) | Zlib | https://github.com/deltaphc/raylib-rs |
| Relib | 3.5 | [ReCT](https://github.com/RedCubeDev-ByteSpace/ReCT) | ? | https://github.com/RedCubeDev-ByteSpace/Relib |
-| racket-raylib | **4.0** | [Racket](https://racket-lang.org/) | MIT/Apache-2.0 | https://github.com/eutro/racket-raylib |
-| raylib-swift | **4.0** | [Swift](https://swift.org/) | MIT | https://github.com/STREGAsGate/Raylib |
+| racket-raylib | 4.0 | [Racket](https://racket-lang.org/) | MIT/Apache-2.0 | https://github.com/eutro/racket-raylib |
+| raylib-swift | 4.0 | [Swift](https://swift.org/) | MIT | https://github.com/STREGAsGate/Raylib |
| raylib-scopes | auto | [Scopes](http://scopes.rocks) | MIT | https://github.com/salotz/raylib-scopes |
| raylib-smallBasic | 4.1-dev | [SmallBASIC](https://github.com/smallbasic/SmallBASIC) | GPLv3 | https://github.com/smallbasic/smallbasic.plugins/tree/master/raylib |
-| raylib.v | **4.2** | [V](https://vlang.io/) | Zlib | https://github.com/irishgreencitrus/raylib.v |
-| raylib-wren | **4.0** | [Wren](http://wren.io/) | ISC | https://github.com/TSnake41/raylib-wren |
-| raylib-zig | **4.2** | [Zig](https://ziglang.org/) | MIT | https://github.com/Not-Nik/raylib-zig |
-| raylib.zig | **4.2** | [Zig](https://ziglang.org/) | MIT | https://github.com/ryupold/raylib.zig |
-| hare-raylib | auto | [Hare](https://harelang.org/) | Zlib | https://git.sr.ht/~evantj/hare-raylib |
-
-
+| raylib-umka | **4.5** | [Umka](https://github.com/vtereshkov/umka-lang) | Zlib | https://github.com/robloach/raylib-umka |
+| raylib.v | 4.2 | [V](https://vlang.io/) | Zlib | https://github.com/irishgreencitrus/raylib.v |
+| raylib-vapi | 4.2 | [Vala](https://vala.dev/) | Zlib | https://github.com/lxmcf/raylib-vapi |
+| raylib-wren | 4.0 | [Wren](http://wren.io/) | ISC | https://github.com/TSnake41/raylib-wren |
+| raylib-zig | 4.2 | [Zig](https://ziglang.org/) | MIT | https://github.com/Not-Nik/raylib-zig |
+| raylib.zig | **4.5** | [Zig](https://ziglang.org/) | MIT | https://github.com/ryupold/raylib.zig |
+| hare-raylib | **auto** | [Hare](https://harelang.org/) | Zlib | https://git.sr.ht/~evantj/hare-raylib |
+| raylib-sunder | **auto** | [Sunder](https://github.com/ashn-dot-dev/sunder) | 0BSD | https://github.com/ashn-dot-dev/raylib-sunder |
+| rayed-bqn | **auto** | [BQN](https://mlochbaum.github.io/BQN/) | MIT | https://github.com/Brian-ED/rayed-bqn |
+| rayjs | 4.6-dev | [QuickJS](https://bellard.org/quickjs/) | MIT | https://github.com/mode777/rayjs |
### Utility Wrapers
These are utility wrappers for specific languages, they are not required to use raylib in the language but may adapt the raylib API to be more inline with the language's pardigm.
| name | raylib version | language | license | repo |
|:------------------:|:-------------: | :--------:|:-------:|:-------------------------------------------------------------|
-| raylib-cpp | **4.2** | [C++](https://en.wikipedia.org/wiki/C%2B%2B) | Zlib | https://github.com/robloach/raylib-cpp |
+| raylib-cpp | **4.5** | [C++](https://en.wikipedia.org/wiki/C%2B%2B) | Zlib | https://github.com/robloach/raylib-cpp |
+| claylib | **4.5** | [Common Lisp](https://common-lisp.net/) | Zlib | https://github.com/defun-games/claylib |
### Older or Unmaintained Language Bindings
These are older raylib bindings that are more than 2 versions old or have not been maintained.
@@ -96,8 +115,6 @@ These are older raylib bindings that are more than 2 versions old or have not be
| raylib-ruby | 2.6 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/a0/raylib-ruby |
| raylib-ruby-ffi | 2.0 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/D3nX/raylib-ruby-ffi |
| raylib-mruby | 2.5-dev | [mruby](https://github.com/mruby/mruby) | https://github.com/lihaochen910/raylib-mruby |
-| raylib-py-ctbg | 2.6 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py-ctbg |
-| raylib-py | 2.0 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py |
| raylib-java | 2.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/XoanaIO/raylib-java |
| clj-raylib | 3.0 | [Clojure](https://clojure.org/) | https://github.com/lsevero/clj-raylib |
| QuickJS-raylib | 3.0 | [QuickJS](https://bellard.org/quickjs/) | https://github.com/sntg-p/QuickJS-raylib |
@@ -119,7 +136,6 @@ These are older raylib bindings that are more than 2 versions old or have not be
| raylib-jai | 3.1-dev | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | https://github.com/kujukuju/raylib-jai |
| ray.zig | 2.5 | [Zig](https://ziglang.org/) | https://github.com/BitPuffin/zig-raylib-experiments |
| raylib-Ada | 3.0 | [Ada](https://www.adacore.com/about-ada) | https://github.com/mimo/raylib-Ada |
-| jaylib | 3.0 | [Janet](https://janet-lang.org/) | https://github.com/janet-lang/jaylib |
| raykit | ? | [Kit](https://www.kitlang.org/) | https://github.com/Gamerfiend/raykit |
| ray.mod | 3.0 | [BlitzMax](https://blitzmax.org/) | https://github.com/bmx-ng/ray.mod |
| raylib-mosaic | 3.0 | [Mosaic](https://github.com/sal55/langs/tree/master/Mosaic) | https://github.com/pluckyporcupine/raylib-mosaic |
diff --git a/CHANGELOG b/CHANGELOG
index f1207ae5c..43ab3ab44 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,7 +1,187 @@
changelog
---------
-Current Release: raylib 4.2.0 (11 August 2022)
+Current Release: raylib 4.5.0 (18 March 2023)
+
+-------------------------------------------------------------------------
+Release: raylib 4.5 (18 March 2023)
+-------------------------------------------------------------------------
+KEY CHANGES:
+ - ADDED: Improved ANGLE support on Desktop platforms
+ - ADDED: rcamera module, simpler and more extendable
+ - ADDED: Support for M3D models and M3D/GLTF animations
+ - ADDED: Support QOA audio format (import/export)
+ - ADDED: rl_gputex module for compressed textures loading
+ - REDESIGNED: rlgl module for automatic render-batch limits checking
+ - REDESIGNED: rshapes module to minimize the rlgl dependency
+
+Detailed changes:
+[core] ADDED: RAYLIB_VERSION_* values to raylib.h (#2856) by @RobLoach
+[core] ADDED: Basic gamepad support for Android (#2709) by @deniska
+[core] ADDED: Support CAPS/NUM lock keys registering if locked
+[core] ADDED: _GNU_SOURCE define on Linux (#2729)
+[core] ADDED: SetWindowIcons() to set multiple icon image sizes
+[core] `WARNING`: RENAMED: Exported raylib version symbol to raylib_version #2671
+[core] REMOVED: Touch points on touch up events on Android (#2711) by @deniska
+[core] REVIEWED: Window position setup on InitWindow() (#2732) by @RandomErrorMessage
+[core] REVIEWED: Touchscreen input related functions on Android (#2702) by @deniska
+[core] REVIEWED: Viewport scaling on Android after context rebind (#2703) by @deniska
+[core] REVIEWED: ScanDirectoryFilesRecursively() (#2704)
+[core] REVIEWED: Gamepad mappings with latest gamecontrollerdb (#2725)
+[core] REVIEWED: Monitor order check on app initialization
+[core] REVIEWED: Application monitor when opening (#2728, #2731) by @RandomErrorMessage
+[core] REVIEWED: Gestures module to use GetTime() if available (#2733) by @RobLoach
+[core] REVIEWED: Resolve GLFW3 some symbols re-definition of windows.h in glfw3native (#2643) by @daipom
+[core] REVIEWED: OpenURL(), string buffer too short sometimes
+[core] REVIEWED: GetRandomValue() range limit warning (#2800) by @Pere001
+[core] REVIEWED: UnloadDirectoryFiles()
+[core] REVIEWED: GetKeyPressed(), out of range issue (#2814) by @daipom
+[core] REVIEWED: GetTime(), renamed variable 'time' to 'nanoSeconds' (#2816) by @jtainer
+[core] REVIEWED: LoadShaderFromMemory(), issue with shader linkage
+[core] REVIEWED: Avoid possible gamepad index as -1 (#2839)
+[core] REVIEWED: SetShaderValue*(), avoid setup uniforms for invalid locations
+[core] REVIEWED: GetClipboardText() on PLATFORM_WEB, permissions issues
+[core] REVIEWED: Initial window position for display-sized fullscreen (#2742) by @daipom
+[core] REVIEWED: Sticky touches input (#2857) by @ImazighenGhost
+[core] REVIEWED: Enable GetWindowHandle() on macOS (#2915) by @Not-Nik
+[core] REVIEWED: Window position always inits centered in current monitor
+[core] REVIEWED: IsWindowFocused() to consider Android App state (#2935)
+[core] REVIEWED: GetMonitorWidth() and GetMonitorHeight() (#2934)
+[core] REVIEWED: GetWindowHandle() to return Linux window (#2938)
+[core] REVIEWED: WindowDropCallback(), additional security check (#2943)
+[core] REVIEWED: Security checks for emscripten_run_script() (#2954)
+[utils] REVIEWED: TraceLog() message size limit overflow
+[rcamera] REDESIGNED: New implementation from scratch (#2563) by @Crydsch
+[rcamera] REVIEWED: Make orbital camera work as expected (#2926) by @JeffM2501
+[rcamera] REVIEWED: Multiple reviews on the new implementation
+[rcamera] ADDED: UpdateCameraPro(), supporting custom user inputs
+[rlgl] ADDED: OpenGL ES 2.0 support on PLATFORM_DESKTOP (#2840) by @wtnbgo
+[rlgl] ADDED: Separate blending modes for color and alpha, BLEND_CUSTOM_SEPARATE (#2741)
+[rlgl] ADDED: rlSetBlendFactorsSeparate and custom blend mode modification checks (#2741) by @pure01fx
+[rlgl] ADDED: RL_TEXTURE_MIPMAP_BIAS_RATIO support to `rlTextureParameters()` for OpenGL 3.3 #2674
+[rlgl] ADDED: rlCubemapParameters() (#2862) by @GithubPrankster
+[rlgl] ADDED: rlSetCullFace() (#2797) by @jtainer
+[rlgl] REMOVED: Mipmaps software generation for OpenGL 1.1
+[rlgl] REVIEWED: Check for extensions before enabling them (#2706) by @Not-Nik
+[rlgl] REVIEWED: SSBO usage to avoid long long data types
+[rlgl] REVIEWED: Enable DXT compression on __APPLE__ targets (#2694) by @Not-Nik
+[rlgl] REVIEWED: enums exposed and description comments
+[rlgl] REVIEWED: rlBindImageTexture(), correct data types (#2808) by @planetis-m
+[rlgl] REVIEWED: rlMultMatrixf(), use const pointer (#2807) by @planetis-m
+[rlgl] REVIEWED: Expose OpenGL blending mode factors and functions/equations
+[rlgl] REVIEWED: rLoadTextureDepth(), issue with depth textures on WebGL (#2824)
+[rlgl] REVIEWED: rlUnloadFramebuffer() (#2937)
+[raymath] ADDED: Vector2LineAngle() (#2887)
+[raymath] REVIEWED: Vector2Angle() (#2829, #2832) by @AlxHnr, @planetis-m
+[shapes] ADDED: CheckCollisionPointPoly() (#2685) by @acejacek
+[shapes] REVIEWED: DrawPixel*(), use RL_QUADS/RL_TRIANGLES (#2750) by @hatkidchan
+[shapes] REVIEWED: DrawLineBezier*(), fix bezier line breaking (#2735, #2767) by @nobytesgiven
+[textures] ADDED: ColorBrightness()
+[textures] ADDED: ColorTint()
+[textures] ADDED: ColorContrast()
+[textures] ADDED: Support for PNM images (.ppm, .pgm)
+[textures] ADDED: GenImagePerlinNoise()
+[textures] ADDED: GenImageText(), generate grayscale image from text byte data
+[textures] ADDED: ImageDrawCircleLines(), ImageDrawCircleLinesV() (#2713) by @RobLoach
+[textures] ADDED: ImageBlurGaussian() (#2770) by @nobytesgiven
+[textures] REVIEWED: Image fileformat support: PIC, PNM
+[textures] REVIEWED: ImageTextEx() and ImageDrawTextEx() scaling (#2756) by @hatkidchan
+[textures] `WARNING`: REMOVED: DrawTextureQuad()
+[textures] `WARNING`: REMOVED: DrawTexturePoly(), function moved to example: `textures_polygon`
+[textures] `WARNING`: REMOVED: DrawTextureTiled(),function implementation moved to the textures_tiled.c
+[text] ADDED: GetCodepointPrevious()
+[text] ADDED: UnloadUTF8(), aligned with LoadUTF8()
+[text] `WARNING`: RENAMED: TextCodepointsToUTF8() to LoadUTF8()
+[text] `WARNING`: RENAMED: GetCodepoint() -> GetCodepointNext()
+[text] REDESIGNED: GetCodepointNext()
+[text] REVIEWED: MeasureTextEx(), avoid crash on bad data
+[text] REVIEWED: UnloadFontData(), avoid crash on invalid font data
+[models] ADDED: Support M3D model file format (meshes and materials) (#2648) by @bztsrc
+[models] ADDED: Support for M3D animations (#2648) by @bztsrc
+[models] ADDED: GLTF animation support (#2844) by @charles-l
+[models] ADDED: DrawCapsule() and DrawCapsuleWires() (#2761) by @IanBand
+[models] ADDED: LoadMaterials(), MTL files loading, same code as OBJ loader (#2872) by @JeffM2501
+[models] `WARNING`: REMOVED: UnloadModelKeepMeshes()
+[models] `WARNING`: REMOVED: DrawCubeTexture(), DrawCubeTextureRec(), functions moved to new example: `models_draw_cube_texture`
+[models] REVIEWED: DrawMesh(), using SHADER_LOC_COLOR_SPECULAR as a material map (#2908) by @haved
+[models] REVIEWED: LoadM3D() vertex color support (#2878) by @GithubPrankster, @bztsrc
+[models] REVIEWED: GenMeshHeightmap() (#2716)
+[models] REVIEWED: LoadIQM() (#2676)
+[models] REVIEWED: Simplify .vox signature check (#2752) by @CrezyDud
+[models] REVIEWED: LoadIQM(), support bone names loading if available (#2882) by @PencilAmazing
+[models] REVIEWED: GenMeshTangents(), avoid crash on missing texcoords data (#2927)
+[audio] ADDED: Full support for QOA audio file format
+[audio] ADDED: Mixed audio processor (#2929) by @hatkidchan
+[audio] ADDED: IsWaveReady()`, IsSoundReady(), IsMusicReady() (#2892) by @RobLoach
+[audio] `WARNING`: REMOVED: Multichannel audio API: PlaySoundMulti(), StopSoundMulti()
+[audio] REVIEWED: Clear PCM buffer state when closing audio device (#2736) by @veins1
+[audio] REVIEWED: Android backend selected (#2118, #2875) by @planetis-m
+[audio] REVIEWED: Change default threading model for COM objects in miniaudio
+[multi] ADDED: IsShaderReady(), IsImageReady(), IsFontReady() (#2892) by @RobLoach
+[multi] ADDED: IsModelReady(), IsMaterialReady(), IsTextureReady(), IsRenderTextureReady() (#2895) by @RobLoach
+[multi] REVIEWED: Multiple code/comment typos by @sDos280
+[multi] REVIEWED: Grammar mistakes and typos (#2914) by @stickM4N
+[multi] REVIEWED: Use TRACELOG() macro instead of TraceLog() in internal modules (#2881) by @RobLoach
+[examples] ADDED: textures_textured_curve (#2821) by @JeffM2501
+[examples] ADDED: models_draw_cube_texture
+[examples] ADDED: models_loading_m3d (#2648) by @bztsrc
+[examples] ADDED: shaders_write_depth (#2836) by @BugraAlptekinSari
+[examples] ADDED: shaders_hybrid_render (#2919) by @BugraAlptekinSari
+[examples] REMOVED: audio_multichannel_sound
+[examples] RENAMED: Several shaders for naming consistency (#2707)
+[examples] RENAMED: lighting_instanced.fs to lighting_instancing.fs (glsl100) (#2805) by @gtrxAC
+[examples] REVIEWED: core_custom_logging.c (#2692) by @hartmannathan
+[examples] REVIEWED: core_camera_2d_platformer (#2687) by @skylar779
+[examples] REVIEWED: core_input_gamepad.c (#2903) by @planetis-m
+[examples] REVIEWED: core_custom_frame_control
+[examples] REVIEWED: core_drop_files (#2943)
+[examples] REVIEWED: text_rectangle_bounds (#2746) by @SzieberthAdam
+[examples] REVIEWED: textures_image_processing, added gaussian blurring (#2775) by @nobytesgiven
+[examples] REVIEWED: models_billboard, highlighting rotation and draw order (#2779) by @nobytesgiven
+[examples] REVIEWED: core_loading_thread, join thread on completion (#2845) by @planetis-m
+[examples] REVIEWED: models_loading_gltf
+[examples] REVIEWED: Shader lighting.fs for GLSL120 (#2651)
+[examples] REVIEWED: text_codepoints_loading.c
+[parser] REVIEWED: raylib-parser Makefile (#2765) by @Peter0x44
+[build] ADDED: Packaging for distros with deb-based and rpm-based packages (#2877) by @KOLANICH
+[build] ADDED: Linkage library -latomic on Linux (only required for ARM32)
+[build] ADDED: Required frameworks on macOS (#2793) by @SpexGuy
+[build] ADDED: WASM support for Zig build (#2901) by @Not-Nik
+[build] ADDED: New raylib examples as VS2022 project (to raylib solution)
+[build] REVIEWED: config.h format and inconsistencies
+[build] REVIEWED: Zig build to latest master, avoid deprecated functions (#2910) by @star-tek-mb
+[build] REVIEWED: CMake project template to easily target raylib version (#2700) by @RobLoach
+[build] REVIEWED: PATH for PLATFORM_WEB target (#2647) by @futureapricot
+[build] REVIEWED: build.zig to let user decide how to set build mode and linker fixes by @InKryption
+[build] REVIEWED: Deprecation error on Android API higher than 23 (#2778) by @anggape
+[build] REVIEWED: Android x86 Architecture name (#2783) by @IsaacTCB
+[build] REVIEWED: examples/build.zig for the latest Zig version (#2786) by @RomanAkberov
+[utils] REVIEWED: ExportDataAsCode() data types (#2787) by @RGDTAB
+[build] REVIEWED: Makefile emscripten path (#2785) by @Julianiolo
+[build] REVIEWED: Several compilation warnings (for strict rules)
+[build] REVIEWED: All github workflows using deprecated actions
+[build] REVIEWED: CMake when compiling for web (#2820) by @object71
+[build] REVIEWED: DLL build on Windows (#2951) by @Skaytacium
+[build] REVIEWED: Avoid MSVC warnings in raylib project (#2871) by @JeffM2501
+[build] REVIEWED: Paths in .bat files to build examples (#2870) by @masoudd
+[build] REVIEWED: CMake, use GLVND for old cmake versions (#2826) by @simendsjo
+[build] REVIEWED: Makefile, multiple tweaks
+[build] REVIEWED: CI action: linux_examples.yml
+[build] REVIEWED: CI action: cmake.yml
+[bindings] ADDED: h-raylib (Haskell) by @Anut-py
+[bindings] ADDED: raylib-c3 (C3) by @Its-Kenta
+[bindings] ADDED: raylib-umka (Umka) by @RobLoach
+[bindings] ADDED: chez-raylib (Chez Scheme) by @Yunoinsky
+[bindings] ADDED: raylib-python-ctypes (Python) by @sDos280
+[bindings] ADDED: claylib (Common Lisp) by @shelvick
+[bindings] ADDED: raylib-vapi (Vala) by @lxmcf
+[bindings] ADDED: TurboRaylib (Object Pascal) by @turborium
+[bindings] ADDED: Kaylib (Kotlin/Native) by @Its-Kenta
+[bindings] ADDED: Raylib-Nelua (Nelua) by @Its-Kenta
+[bindings] ADDED: Cyber (Cyber) by @fubark
+[bindings] ADDED: raylib-sunder (Sunder) by @ashn-dot-dev
+[bindings] ADDED: raylib BQN (#2962) by @Brian-ED
+[misc] REVIEWED: Update external libraries to latest versions
-------------------------------------------------------------------------
Release: raylib 4.2 (11 August 2022)
diff --git a/CMakeOptions.txt b/CMakeOptions.txt
index d76983391..83faa5637 100644
--- a/CMakeOptions.txt
+++ b/CMakeOptions.txt
@@ -38,14 +38,16 @@ cmake_dependent_option(SUPPORT_MODULE_RAUDIO "Include module: raudio" ON CUSTOMI
cmake_dependent_option(SUPPORT_CAMERA_SYSTEM "Provide camera module (rcamera.h) with multiple predefined cameras: free, 1st/3rd person, orbital" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_GESTURES_SYSTEM "Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_MOUSE_GESTURES "Mouse gestures are directly mapped like touches and processed by gestures system" ON CUSTOMIZE_BUILD ON)
-cmake_dependent_option(SUPPORT_SSH_KEYBOARD_RPI "Reconfigure standard input to receive key inputs, works with SSH connection" OFF CUSTOMIZE_BUILD OFF)
+cmake_dependent_option(SUPPORT_SSH_KEYBOARD_RPI "Reconfigure standard input to receive key inputs, works with SSH connection" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_DEFAULT_FONT "Default font is loaded on window initialization to be available for the user to render simple text. If enabled, uses external module functions to load default raylib font (module: text)" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_SCREEN_CAPTURE "Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_GIF_RECORDING "Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_BUSY_WAIT_LOOP "Use busy wait loop for timing sync instead of a high-resolution timer" OFF CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_EVENTS_WAITING "Wait for events passively (sleeping while no events) instead of polling them actively every frame" OFF CUSTOMIZE_BUILD OFF)
-cmake_dependent_option(SUPPORT_WINMM_HIGHRES_TIMER "Setting a higher resolution can improve the accuracy of time-out intervals in wait functions" OFF CUSTOMIZE_BUILD OFF)
+cmake_dependent_option(SUPPORT_WINMM_HIGHRES_TIMER "Setting a higher resolution can improve the accuracy of time-out intervals in wait functions" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_COMPRESSION_API "Support for compression API" ON CUSTOMIZE_BUILD ON)
+cmake_dependent_option(SUPPORT_EVENTS_AUTOMATION "Support automatic generated events, loading and recording of those events when required" OFF CUSTOMIZE_BUILD OFF)
+cmake_dependent_option(SUPPORT_CUSTOM_FRAME_CONTROL "Enabling this flag allows manual control of the frame processes, use at your own risk" OFF CUSTOMIZE_BUILD OFF)
# rshapes.c
cmake_dependent_option(SUPPORT_QUADS_DRAW_MODE "Use QUADS instead of TRIANGLES for drawing when possible. Some lines-based shapes could still use lines" ON CUSTOMIZE_BUILD ON)
@@ -57,13 +59,15 @@ cmake_dependent_option(SUPPORT_IMAGE_MANIPULATION "Support multiple image editin
cmake_dependent_option(SUPPORT_FILEFORMAT_PNG "Support loading PNG as textures" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_DDS "Support loading DDS as textures" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_HDR "Support loading HDR as textures" ON CUSTOMIZE_BUILD ON)
-cmake_dependent_option(SUPPORT_FILEFORMAT_KTX "Support loading KTX as textures" ON CUSTOMIZE_BUILD ON)
-cmake_dependent_option(SUPPORT_FILEFORMAT_ASTC "Support loading ASTC as textures" ON CUSTOMIZE_BUILD ON)
+cmake_dependent_option(SUPPORT_FILEFORMAT_PIC "Support loading PIC as textures" ${OFF} CUSTOMIZE_BUILD OFF)
+cmake_dependent_option(SUPPORT_FILEFORMAT_PNM "Support loading PNM as textures" ${OFF} CUSTOMIZE_BUILD OFF)
+cmake_dependent_option(SUPPORT_FILEFORMAT_KTX "Support loading KTX as textures" ${OFF} CUSTOMIZE_BUILD OFF)
+cmake_dependent_option(SUPPORT_FILEFORMAT_ASTC "Support loading ASTC as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_BMP "Support loading BMP as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_TGA "Support loading TGA as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_JPG "Support loading JPG as textures" ${OFF} CUSTOMIZE_BUILD OFF)
-cmake_dependent_option(SUPPORT_FILEFORMAT_GIF "Support loading GIF as textures" ${OFF} CUSTOMIZE_BUILD OFF)
-cmake_dependent_option(SUPPORT_FILEFORMAT_QOI "Support loading QOI as textures" ${OFF} CUSTOMIZE_BUILD OFF)
+cmake_dependent_option(SUPPORT_FILEFORMAT_GIF "Support loading GIF as textures" ON CUSTOMIZE_BUILD ON)
+cmake_dependent_option(SUPPORT_FILEFORMAT_QOI "Support loading QOI as textures" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_PSD "Support loading PSD as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_PKM "Support loading PKM as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_PVR "Support loading PVR as textures" ${OFF} CUSTOMIZE_BUILD OFF)
@@ -72,6 +76,7 @@ cmake_dependent_option(SUPPORT_FILEFORMAT_PVR "Support loading PVR as textures"
cmake_dependent_option(SUPPORT_FILEFORMAT_FNT "Support loading fonts in FNT format" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_TTF "Support loading font in TTF/OTF format" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_TEXT_MANIPULATION "Support text manipulation functions" ON CUSTOMIZE_BUILD ON)
+cmake_dependent_option(SUPPORT_FONT_ATLAS_WHITE_REC "Support white rec on font atlas bottom-right corner" ON CUSTOMIZE_BUILD ON)
# rmodels.c
cmake_dependent_option(SUPPORT_MESH_GENERATION "Support procedural mesh generation functions, uses external par_shapes.h library. NOTE: Some generated meshes DO NOT include generated texture coordinates" ON CUSTOMIZE_BUILD ON)
@@ -80,6 +85,7 @@ cmake_dependent_option(SUPPORT_FILEFORMAT_MTL "Support loading MTL file format"
cmake_dependent_option(SUPPORT_FILEFORMAT_IQM "Support loading IQM file format" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_GLTF "Support loading GLTF file format" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_VOX "Support loading VOX file format" ON CUSTOMIZE_BUILD ON)
+cmake_dependent_option(SUPPORT_FILEFORMAT_M3D "Support loading M3D file format" ON CUSTOMIZE_BUILD ON)
# raudio.c
cmake_dependent_option(SUPPORT_FILEFORMAT_WAV "Support loading WAV for sound" ON CUSTOMIZE_BUILD ON)
@@ -87,6 +93,7 @@ cmake_dependent_option(SUPPORT_FILEFORMAT_OGG "Support loading OGG for sound" O
cmake_dependent_option(SUPPORT_FILEFORMAT_XM "Support loading XM for sound" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_MOD "Support loading MOD for sound" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_MP3 "Support loading MP3 for sound" ON CUSTOMIZE_BUILD ON)
+cmake_dependent_option(SUPPORT_FILEFORMAT_QOA "Support loading QOA for sound" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_FLAC "Support loading FLAC for sound" ${OFF} CUSTOMIZE_BUILD OFF)
# utils.c
diff --git a/FAQ.md b/FAQ.md
index b933bf615..be06657b9 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -14,12 +14,13 @@
- [What does raylib provide that other engines or libraries don't?](#what-does-raylib-provide-that-other-engines-or-libraries-dont)
- [How does raylib compare to Unity/Unreal/Godot?](#how-does-raylib-compare-to-unityunrealgodot)
- [What development tools are required for raylib?](#what-development-tools-are-required-for-raylib)
-- [Which are raylib external dependencies?](#which-are-raylib-external-dependencies)
+- [What are raylib's external dependencies?](#what-are-raylibs-external-dependencies)
- [Can I use raylib with other technologies or libraries?](#can-i-use-raylib-with-other-technologies-or-libraries)
- [What file formats are supported by raylib?](#what-file-formats-are-supported-by-raylib)
- [Does raylib support the Vulkan API?](#does-raylib-support-the-vulkan-api)
- [What could I expect to see in raylib in the future?](#what-could-i-expect-to-see-in-raylib-in-the-future)
- [Who are the raylib developers?](#who-are-the-raylib-developers)
+- [MORE QUESTIONS...](https://github.com/raysan5/raylib/wiki/Frequently-Asked-Questions)
### What is raylib?
@@ -119,8 +120,8 @@ raylib can load data from multiple standard file formats:
- Image/Textures: PNG, BMP, TGA, JPG, GIF, QOI, PSD, DDS, HDR, KTX, ASTC, PKM, PVR
- Fonts: FNT (sprite font), TTF, OTF
- - Models/Meshes: OBJ, IQM, GLTF, VOX
- - Audio: WAV, OGG, MP3, FLAC, XM, MOD
+ - Models/Meshes: OBJ, IQM, GLTF, VOX, M3D
+ - Audio: WAV, OGG, MP3, FLAC, XM, MOD, QOA
### Does raylib support the Vulkan API?
diff --git a/HISTORY.md b/HISTORY.md
index cebac5362..735e66514 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -5,7 +5,7 @@ introduction
I started developing videogames in 2006 and some years later I started teaching videogames development to young people with artistic profile, most of students had never written a single line of code.
-I decided to start with C language basis and, after searching for the most simple and easy-to-use library to teach videogames programming, I found [WinBGI](http://www.codecutter.net/tools/winbgim/); it was great and it worked very well with students, in just a couple of weeks, those students that had never written a single line of code were able to program (and understand) a simple PONG game, some of them even a BREAKOUT!
+I decided to start with C language basis and, after searching for the most simple and easy-to-use library to teach videogames programming, I found [WinBGI](https://winbgim.codecutter.org/); it was great and it worked very well with students, in just a couple of weeks, those students that had never written a single line of code were able to program (and understand) a simple PONG game, some of them even a BREAKOUT!
But WinBGI was not the clearer and most organized library for my taste. There were lots of things I found confusing and some function names were not clear enough for most of the students; not to mention the lack of transparencies support and no hardware acceleration.
@@ -395,3 +395,40 @@ Highlights for `raylib 4.2`:
As always, there are more improvements than the key features listed, make sure to check raylib [CHANGELOG](CHANGELOG) for the detailed list of changes; for this release a `WARNING` flag has been added to all the changes that could affect bindings or productivity code. **raylib keeps improving one more version** and a special focus on maintainability has been put on the library for the future. Specific/advance functionality will be provided through **raylib-extras** repos and raylib main repo devlelopment will be focused on what made raylib popular: being a simple and easy-to-use library to **enjoy videogames programming**.
**Enjoy gamedev/tools/graphics programming!** :)
+
+notes on raylib 4.5
+-------------------
+
+It's been **7 months** since latest raylib release. As usual, **many parts of the library have been reviewed and improved** along those months. Many issues have been closed, staying under 10 open issues at the moment of this writting and also many PRs from contributors have been received, reviewed and merged into raylib library. Some new functions have been added and some others have been removed to improve library coherence and avoid moving too high level, giving the users the tools to implement advance functionality themselfs over raylib. Again, this is a big release with a considerable amount of changes and improvements. Here it is a small summary highlighting this new **rayib 4.5**.
+
+Some numbers for this release:
+
+ - **+100** closed issues (for a TOTAL of **+1340**!)
+ - **+350** commits since previous RELEASE (for a TOTAL of **+6350**!)
+ - **+25** functions ADDED to raylib API (for a TOTAL of **516**!)
+ - **+40** functions REVIEWED/REDESIGNED
+ - **+40** new contributors (for a TOTAL of **405**!)
+
+Highlights for `raylib 4.5`:
+
+ - **`NEW` Improved ANGLE support on Desktop platforms**: Support for OpenGL ES 2.0 on Desktop platforms (Windows, Linux, macOS) has been reviewed by @wtnbgo GitHub user. Now raylib can be compiled on desktop for OpenGL ES 2.0 and linked against [`ANGLE`](https://github.com/google/angle). This _small_ addition open the door to building raylib for all **ANGLE supported backends: Direct3D 11, Vulkan and Metal**. Please note that this new feature is still experimental and requires further testing!
+
+ - **`NEW` Camera module**: A brand new implementation from scratch for `rcamera` module, contributed by @Crydsch GitHub user! **New camera system is simpler, more flexible, more granular and more extendable**. Specific camera math transformations (movement/rotation) have been moved to individual functions, exposing them to users if required. Global state has been removed from the module and standalone usage has been greatly improved; now `rcamera.h` single-file header-only library can be used externally, independently of raylib. A new `UpdateCameraPro()` function has been added to address input-dependency of `UpdateCamera()`, now advance users have **full control over camera inputs and movement/rotation speeds**!
+
+ - **`NEW` Support for M3D models and M3D/GLTF animations**: 3d models animations support has been a limited aspect of raylib for long time, some versions ago IQM animations were supported but raylib 4.5 also adds support for the brand new [M3D file format](https://bztsrc.gitlab.io/model3d/), including animations and the long expected support for **GLTF animations**! The new M3D file format is **simple, portable, feature complete, extensible and open source**. It also provides a complete set of tools to export/visualize M3D models from/to Blender! Now raylib supports up to **3 model file-formats with animations**: `IQM`, `GLTF` and `M3D`.
+
+ - **`NEW` Support QOA audio format (import/export)**: Just a couple of months ago the new [QOA file format](https://qoaformat.org/) was published, a very simple, portable and open source quite-ok-audio file format. raylib already supports it, added to `raudio` module and including audio loading from file, loading from memory, streaming from file, streaming from memory and **exporting to QOA** audio format. **Because simplicity really matters to raylib!**
+
+ - **`NEW` Module for compressed textures loading**: [`rl_gputex`](https://github.com/raysan5/raylib/blob/master/src/external/rl_gputex.h), a portable single-file header-only small library to load compressed texture file-formats (DDS, PKM, KTX, PVR, ASTC). Provided functionality is not new to raylib but it was part of the raylib `rtextures` module, now it has been moved into a separate self-contained library, **improving portability**. Note that this module is only intended to **load compressed data from files, ready to be uploaded to GPU**, no compression/decompression functionality is provided. This change is a first step towards a better modularization of raylib library.
+
+ - **Reviewed `rlgl` module for automatic limits checking**: Again, [`rlgl`](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) has been reviewed to simplify usage. Now users do not need to worry about reaching the internal render-batch limits when they send their triangles to draw 2d/3d, `rlgl` manages it automatically! This change allows a **great simplification for other modules** like `rshapes`, `rtextures` and `rmodels` that do not need to worry about bufffer overflows and can just define as many vertex as desired!
+
+ - **Reviewed `rshapes` module to minimize the rlgl dependency**: Now `rshapes` 2d shapes drawing functions **only depend on 6 low-level functions**: `rlBegin()`, `rlEnd()`, `rlVertex3f()`, `rlTexCoord2f()`, `rlNormal3f()`, `rlSetTexture()`. With only those pseudo-OpenGl 1.1 minimal functionality, everything can be drawn! This improvement converts `rshapes` module in a **self-contained, portable shapes-drawing library that can be used independently of raylib**, as far as entry points for those 6 functions are provided by the user. It even allows to be used for software rendering, with the proper backend!
+
+ - **Added data structures validation functions**: Multiple functions have been added by @RobLoach GitHub user to ease the validation of raylib data structures: `IsImageReady()`, `IsTextureReady()`, `IsSoundReady()`... Now users have a simple mechanism to **make sure data has been correctly loaded**, instead of checking internal structure values by themselfs.
+
+As usual, those are only some highlights but there is much more! New image generators, new color transformation functionality, improved blending support for color/alpha, etc... Make sure to check raylib [CHANGELOG]([CHANGELOG](https://github.com/raysan5/raylib/blob/master/CHANGELOG)) for a detailed list of changes! Please, note that all breaking changes have been flagged with a `WARNING` in the CHANGELOG, specially useful for binding creators!
+
+**raylib keeps improving one more version** with a special focus on maintainability and sustainability. Always working towards making the library more **simple and easy-to-use**.
+
+Let's keep **enjoying games/tools/graphics programming!** :)
diff --git a/LICENSE b/LICENSE
index 2694b4748..91da62ed9 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
This software is provided "as-is", without any express or implied warranty. In no event
will the authors be held liable for any damages arising from the use of this software.
diff --git a/README.md b/README.md
index 9db359194..90de36ca5 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-
+
**raylib is a simple and easy-to-use library to enjoy videogames programming.**
@@ -14,7 +14,8 @@ Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
[](https://github.com/raysan5/raylib/releases)
[](https://github.com/raysan5/raylib/stargazers)
-[](https://github.com/raysan5/raylib/commits/master)
+[](https://github.com/raysan5/raylib/commits/master)
+[](https://github.com/sponsors/raysan5)
[](https://repology.org/project/raylib/versions)
[](LICENSE)
@@ -22,8 +23,6 @@ Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
[](https://www.reddit.com/r/raylib/)
[](https://www.youtube.com/c/raylib)
[](https://www.twitch.tv/raysan5)
-[](https://twitter.com/raysan5)
-
[](https://github.com/raysan5/raylib/actions?query=workflow%3AWindows)
[](https://github.com/raysan5/raylib/actions?query=workflow%3ALinux)
@@ -39,10 +38,10 @@ features
--------
- **NO external dependencies**, all required libraries are [bundled into raylib](https://github.com/raysan5/raylib/tree/master/src/external)
- Multiple platforms supported: **Windows, Linux, MacOS, RPI, Android, HTML5... and more!**
- - Written in plain C code (C99) in PascalCase/camelCase notation
+ - Written in plain C code (C99) using PascalCase/camelCase notation
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3, 4.3 or ES 2.0**)
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
- - Multiple **Fonts** formats supported (TTF, XNA fonts, AngelCode fonts)
+ - Multiple **Fonts** formats supported (TTF, Image fonts, AngelCode fonts)
- Multiple texture formats supported, including **compressed formats** (DXT, ETC, ASTC)
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
- Flexible Materials system, supporting classic maps and **PBR maps**
@@ -52,7 +51,7 @@ features
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
- **VR stereo rendering** support with configurable HMD device parameters
- Huge examples collection with [+120 code examples](https://github.com/raysan5/raylib/tree/master/examples)!
- - Bindings to [+50 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
+ - Bindings to [+60 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
- **Free and open source**.
basic example
diff --git a/ROADMAP.md b/ROADMAP.md
index f25f83459..61c6b56e3 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -3,16 +3,21 @@
Here it is a wishlist with features and ideas to improve the library. Note that features listed here are usually long term improvements or just describe a route to follow for the library. There are also some additional places to look for raylib improvements and ideas:
- [GitHub Issues](https://github.com/raysan5/raylib/issues) has several open issues for possible improvements or bugs to fix.
- - [raylib source code](https://github.com/raysan5/raylib/tree/master/src) has multiple *TODO* comments around code with pending things to review or improve.
- - raylib wishlists discussions (https://github.com/raysan5/raylib/discussions/1502, https://github.com/raysan5/raylib/discussions/2272) are open to everyone to ask for improvements, feel free to check and comment.
+ - [raylib source code](https://github.com/raysan5/raylib/tree/master/src) has multiple *TODO* comments around code with pending things to review or improve.
+ - raylib wishlists discussions are open to everyone to ask for improvements, feel free to check and comment:
+ - [raylib wishlist 2021](https://github.com/raysan5/raylib/discussions/1502)
+ - [raylib wishlist 2022](https://github.com/raysan5/raylib/discussions/2272)
+ - [raylib 5.0 wishlist](https://github.com/raysan5/raylib/discussions/2952)
_Current version of raylib is complete and functional but there is always room for improvements._
**raylib 4.x**
- - [ ] Redesign camera module (more flexible) ([#1143](https://github.com/raysan5/raylib/issues/1143), https://github.com/raysan5/raylib/discussions/2507)
+ - [ ] Split core module into separate platforms?
+ - [ ] Basic 2d software renderer, using `Image` provided API
- [ ] Redesign gestures system, improve touch inputs management
- - [ ] Redesign raudio module, implement miniaudio high-level provided features
- - [x] Better documentation and improved examples
+ - [ ] Redesign audio module, implement miniaudio high-level provided features
+ - [x] Redesign camera module (more flexible) ([#1143](https://github.com/raysan5/raylib/issues/1143), https://github.com/raysan5/raylib/discussions/2507)
+ - [x] Better documentation and improved examples, reviewed webpage with examples complexity level
- [x] Focus on HTML5 ([raylib 5k gamejam](https://itch.io/jam/raylib-5k-gamejam)) and embedded platforms (RPI and similar SOCs)
- [x] Additional support libraries: [raygui](https://github.com/raysan5/raygui), [rres](https://github.com/raysan5/rres)
@@ -23,23 +28,23 @@ _Current version of raylib is complete and functional but there is always room f
- Basic CPU/GPU stats system (memory, draws, time...) ([#1295](https://github.com/raysan5/raylib/issues/1295)) - _DISCARDED_
- Software rendering backend (avoiding OpenGL) ([#1370](https://github.com/raysan5/raylib/issues/1370)) - _DISCARDED_
- Network module (UDP): `rnet` ([#753](https://github.com/raysan5/raylib/issues/753)) - _DISCARDED_ - Use [nbnet](https://github.com/nathhB/nbnet).
-
+
**raylib 3.0**
- [x] Custom memory allocators support
- [x] Global variables moved to global context
- [x] Optimize data structures for pass-by-value
- [x] Trace log messages redesign ([#1065](https://github.com/raysan5/raylib/issues/1065))
- [x] Continuous Integration using GitHub Actions
-
+
**raylib 2.5**
- [x] Support Animated models
- [x] Support glTF models file format
- [x] Unicode support on text drawing
-
+
**raylib 2.0**
- [x] Removed external dependencies (GLFW3 and OpenAL)
- [x] Support TCC compiler (32bit and 64bit)
-
+
**raylib 1.8**
- [x] Improved Materials system with PBR support
- [x] Procedural image generation functions (spot, gradient, noise...)
@@ -50,7 +55,7 @@ _Current version of raylib is complete and functional but there is always room f
- [x] Support configuration flags
- [x] Improved build system for Android
- [x] Gamepad support on HTML5
-
+
**raylib 1.6**
- [x] Lua scripting support (raylib Lua wrapper)
- [x] Redesigned audio module
diff --git a/build.zig b/build.zig
new file mode 100644
index 000000000..12c0513f6
--- /dev/null
+++ b/build.zig
@@ -0,0 +1,7 @@
+const std = @import("std");
+const raylib = @import("src/build.zig");
+
+// This has been tested to work with zig master branch as of commit 87de821 or May 14 2023
+pub fn build(b: *std.Build) void {
+ raylib.build(b);
+}
diff --git a/cmake/CompileDefinitions.cmake b/cmake/CompileDefinitions.cmake
index 6c8d0d715..1458e2f3c 100644
--- a/cmake/CompileDefinitions.cmake
+++ b/cmake/CompileDefinitions.cmake
@@ -28,6 +28,8 @@ if (${CUSTOMIZE_BUILD})
define_if("raylib" SUPPORT_EVENTS_WAITING)
define_if("raylib" SUPPORT_WINMM_HIGHRES_TIMER)
define_if("raylib" SUPPORT_COMPRESSION_API)
+ define_if("raylib" SUPPORT_EVENTS_AUTOMATION)
+ define_if("raylib" SUPPORT_CUSTOM_FRAME_CONTROL)
define_if("raylib" SUPPORT_QUADS_DRAW_MODE)
define_if("raylib" SUPPORT_IMAGE_EXPORT)
define_if("raylib" SUPPORT_IMAGE_GENERATION)
@@ -35,6 +37,8 @@ if (${CUSTOMIZE_BUILD})
define_if("raylib" SUPPORT_FILEFORMAT_PNG)
define_if("raylib" SUPPORT_FILEFORMAT_DDS)
define_if("raylib" SUPPORT_FILEFORMAT_HDR)
+ define_if("raylib" SUPPORT_FILEFORMAT_PIC)
+ define_if("raylib" SUPPORT_FILEFORMAT_PNM)
define_if("raylib" SUPPORT_FILEFORMAT_KTX)
define_if("raylib" SUPPORT_FILEFORMAT_ASTC)
define_if("raylib" SUPPORT_FILEFORMAT_BMP)
@@ -54,11 +58,13 @@ if (${CUSTOMIZE_BUILD})
define_if("raylib" SUPPORT_FILEFORMAT_IQM)
define_if("raylib" SUPPORT_FILEFORMAT_GLTF)
define_if("raylib" SUPPORT_FILEFORMAT_VOX)
+ define_if("raylib" SUPPORT_FILEFORMAT_M3D)
define_if("raylib" SUPPORT_FILEFORMAT_WAV)
define_if("raylib" SUPPORT_FILEFORMAT_OGG)
define_if("raylib" SUPPORT_FILEFORMAT_XM)
define_if("raylib" SUPPORT_FILEFORMAT_MOD)
define_if("raylib" SUPPORT_FILEFORMAT_MP3)
+ define_if("raylib" SUPPORT_FILEFORMAT_QOA)
define_if("raylib" SUPPORT_FILEFORMAT_FLAC)
define_if("raylib" SUPPORT_STANDARD_FILEIO)
define_if("raylib" SUPPORT_TRACELOG)
@@ -68,17 +74,17 @@ if (${CUSTOMIZE_BUILD})
else ()
target_compile_definitions("raylib" PUBLIC "MAX_FILEPATH_LENGTH=512")
endif ()
-
+
target_compile_definitions("raylib" PUBLIC "MAX_GAMEPADS=4")
target_compile_definitions("raylib" PUBLIC "MAX_GAMEPAD_AXIS=8")
target_compile_definitions("raylib" PUBLIC "MAX_GAMEPAD_BUTTONS=32")
target_compile_definitions("raylib" PUBLIC "MAX_TOUCH_POINTS=10")
target_compile_definitions("raylib" PUBLIC "MAX_KEY_PRESSED_QUEUE=16")
-
+
target_compile_definitions("raylib" PUBLIC "STORAGE_DATA_FILE=\"storage.data\"")
- target_compile_definitions("raylib" PUBLIC "MAX_KEY_PRESSED_QUEUE=16")
+ target_compile_definitions("raylib" PUBLIC "MAX_CHAR_PRESSED_QUEUE=16")
target_compile_definitions("raylib" PUBLIC "MAX_DECOMPRESSION_SIZE=64")
-
+
if (${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_33" OR ${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_11")
target_compile_definitions("raylib" PUBLIC "DEFAULT_BATCH_BUFFER_ELEMENTS=8192")
elseif (${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_ES2")
diff --git a/cmake/InstallConfigurations.cmake b/cmake/InstallConfigurations.cmake
index 6a89ad55c..6c606e565 100644
--- a/cmake/InstallConfigurations.cmake
+++ b/cmake/InstallConfigurations.cmake
@@ -9,8 +9,7 @@ install(
# PKG_CONFIG_LIBS_PRIVATE is used in raylib.pc.in
if (NOT BUILD_SHARED_LIBS)
include(LibraryPathToLinkerFlags)
- library_path_to_linker_flags(__PKG_CONFIG_LIBS_PRIVATE "${LIBS_PRIVATE}")
- set(PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE} ${GLFW_PKG_LIBS})
+ set(PKG_CONFIG_LIBS_PRIVATE ${GLFW_PKG_LIBS})
string(REPLACE ";" " " PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE}")
elseif (BUILD_SHARED_LIBS)
set(PKG_CONFIG_LIBS_EXTRA "")
diff --git a/cmake/LibraryConfigurations.cmake b/cmake/LibraryConfigurations.cmake
index 1e60e8283..d12df3a00 100644
--- a/cmake/LibraryConfigurations.cmake
+++ b/cmake/LibraryConfigurations.cmake
@@ -1,3 +1,12 @@
+# Set OpenGL_GL_PREFERENCE to new "GLVND" even when legacy library exists and
+# cmake is <= 3.10
+#
+# See https://cmake.org/cmake/help/latest/policy/CMP0072.html for more
+# information.
+if(POLICY CMP0072)
+ cmake_policy(SET CMP0072 NEW)
+endif()
+
if (${PLATFORM} MATCHES "Desktop")
set(PLATFORM_CPP "PLATFORM_DESKTOP")
@@ -16,7 +25,7 @@ if (${PLATFORM} MATCHES "Desktop")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
find_package(OpenGL QUIET)
set(LIBS_PRIVATE ${OPENGL_LIBRARIES} winmm)
- else ()
+ elseif (UNIX)
find_library(pthread NAMES pthread)
find_package(OpenGL QUIET)
if ("${OPENGL_LIBRARIES}" STREQUAL "")
@@ -27,9 +36,22 @@ if (${PLATFORM} MATCHES "Desktop")
find_library(OSS_LIBRARY ossaudio)
endif ()
+ set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
+ else ()
+ find_library(pthread NAMES pthread)
+ find_package(OpenGL QUIET)
+ if ("${OPENGL_LIBRARIES}" STREQUAL "")
+ set(OPENGL_LIBRARIES "GL")
+ endif ()
+
set(LIBS_PRIVATE m atomic pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
- if (USE_AUDIO)
+ if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
+ find_library(OSS_LIBRARY ossaudio)
+ set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
+ endif ()
+
+ if (NOT "${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD" AND USE_AUDIO)
set(LIBS_PRIVATE ${LIBS_PRIVATE} dl)
endif ()
endif ()
@@ -45,7 +67,6 @@ elseif (${PLATFORM} MATCHES "Android")
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
list(APPEND raylib_sources ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
- add_definitions(-DANDROID -D__ANDROID_API__=21)
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -u ANativeActivity_onCreate -Wl,-undefined,dynamic_lookup")
@@ -85,7 +106,7 @@ elseif ("${PLATFORM}" MATCHES "DRM")
endif ()
-if (${OPENGL_VERSION})
+if (NOT ${OPENGL_VERSION} MATCHES "OFF")
set(${SUGGESTED_GRAPHICS} "${GRAPHICS}")
if (${OPENGL_VERSION} MATCHES "4.3")
set(GRAPHICS "GRAPHICS_API_OPENGL_43")
diff --git a/cmake/PackConfigurations.cmake b/cmake/PackConfigurations.cmake
index 74eded025..ad00ca6b6 100644
--- a/cmake/PackConfigurations.cmake
+++ b/cmake/PackConfigurations.cmake
@@ -1,5 +1,6 @@
# Packaging
SET(CPACK_PACKAGE_NAME "raylib")
+SET(CPACK_PACKAGE_CONTACT "raysan5")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Simple and easy-to-use library to enjoy videogames programming")
SET(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
SET(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
@@ -9,5 +10,9 @@ SET(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/../README.md")
SET(CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/../README.md")
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../LICENSE")
SET(CPACK_PACKAGE_FILE_NAME "raylib-${PROJECT_VERSION}$ENV{RAYLIB_PACKAGE_SUFFIX}")
-SET(CPACK_GENERATOR "ZIP;TGZ") # Remove this, if you want the NSIS installer on Windows
-include(CPack)
\ No newline at end of file
+SET(CPACK_GENERATOR "ZIP;TGZ;DEB;RPM") # Remove this, if you want the NSIS installer on Windows
+SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) # can be used to generate deps, slow and requires tools.
+SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libatomic1, libc6, libglfw3, libglu1-mesa | libglu1, libglx0, libopengl0")
+SET(CPACK_DEBIAN_PACKAGE_NAME "lib${CPACK_PACKAGE_NAME}-dev")
+SET(CPACK_RPM_PACKAGE_NAME "lib${CPACK_PACKAGE_NAME}-devel")
+include(CPack)
diff --git a/examples/Makefile b/examples/Makefile
index 52e803a56..52ab72f1f 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -2,7 +2,7 @@
#
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
#
-# Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+# Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
@@ -30,7 +30,7 @@ PLATFORM ?= PLATFORM_DESKTOP
# Define required raylib variables
PROJECT_NAME ?= raylib_examples
-RAYLIB_VERSION ?= 4.2.0
+RAYLIB_VERSION ?= 4.5.0
RAYLIB_PATH ?= ..
# Locations of raylib.h and libraylib.a/libraylib.so
@@ -51,6 +51,13 @@ USE_EXTERNAL_GLFW ?= FALSE
# NOTE: This variable is only used for PLATFORM_OS: LINUX
USE_WAYLAND_DISPLAY ?= FALSE
+# PLATFORM_WEB: Default properties
+BUILD_WEB_ASYNCIFY ?= TRUE
+BUILD_WEB_SHELL ?= $(RAYLIB_PATH)/src/minshell.html
+BUILD_WEB_HEAP_SIZE ?= 134217728
+BUILD_WEB_RESOURCES ?= TRUE
+BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
+
# Use cross-compiler for PLATFORM_RPI
ifeq ($(PLATFORM),PLATFORM_RPI)
USE_RPI_CROSS_COMPILER ?= FALSE
@@ -60,8 +67,8 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif
endif
-# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
-ifeq ($(PLATFORM),PLATFORM_DESKTOP)
+# Determine PLATFORM_OS in case PLATFORM_DESKTOP or PLATFORM_WEB selected
+ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB))
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT)
@@ -119,16 +126,18 @@ ifeq ($(PLATFORM),PLATFORM_DRM)
endif
# Define raylib release directory for compiled library
-RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
+RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_WEB)
- # Emscripten required variables
- EMSDK_PATH ?= C:/emsdk
- EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
- CLANG_PATH = $(EMSDK_PATH)/upstream/bin
- PYTHON_PATH = $(EMSDK_PATH)/python/3.9.2-1_64bit
- NODE_PATH = $(EMSDK_PATH)/node/14.15.5_64bit/bin
- export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH):$$(PATH)
+ ifeq ($(PLATFORM_OS),WINDOWS)
+ # Emscripten required variables
+ EMSDK_PATH ?= C:/emsdk
+ EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
+ CLANG_PATH = $(EMSDK_PATH)/upstream/bin
+ PYTHON_PATH = $(EMSDK_PATH)/python/3.9.2-1_64bit
+ NODE_PATH = $(EMSDK_PATH)/node/14.15.5_64bit/bin
+ export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH):$$(PATH)
+ endif
endif
# Define default C compiler: CC
@@ -195,9 +204,13 @@ ifeq ($(BUILD_MODE),DEBUG)
endif
else
ifeq ($(PLATFORM),PLATFORM_WEB)
- CFLAGS += -Os
+ ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
+ CFLAGS += -O3
+ else
+ CFLAGS += -Os
+ endif
else
- CFLAGS += -s -O1
+ CFLAGS += -O2
endif
endif
@@ -248,6 +261,11 @@ ifeq ($(PLATFORM),PLATFORM_DRM)
INCLUDE_PATHS += -I/usr/include/libdrm
endif
+# Include GLFW required for examples/others/rlgl_standalone.c
+ifeq ($(USE_EXTERNAL_GLFW),FALSE)
+all others: INCLUDE_PATHS += -I$(RAYLIB_PATH)/src/external/glfw/include
+endif
+
# Define library paths containing required libs: LDFLAGS
#------------------------------------------------------------------------------------------------
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
@@ -283,16 +301,32 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# --preload-file resources # specify a resources folder for data compilation
# --source-map-base # allow debugging in browser with source map
- LDFLAGS += -s USE_GLFW=3 -s ASYNCIFY -s TOTAL_MEMORY=67108864 -s FORCE_FILESYSTEM=1 --preload-file $(dir $<)resources@resources
+ LDFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -s FORCE_FILESYSTEM=1
+
+ # Build using asyncify
+ ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
+ LDFLAGS += -s ASYNCIFY
+ endif
+
+ # Add resources building if required
+ ifeq ($(BUILD_WEB_RESOURCES),TRUE)
+ LDFLAGS += --preload-file $(BUILD_WEB_RESOURCES_PATH)
+ endif
+
+ # Add debug mode flags if required
+ ifeq ($(BUILD_MODE),DEBUG)
+ LDFLAGS += -s ASSERTIONS=1 --profiling
+ endif
+
+ # Define a custom shell .html and output extension
+ LDFLAGS += --shell-file $(BUILD_WEB_SHELL)
+ EXT = .html
# NOTE: Simple raylib examples are compiled to be interpreter with asyncify, that way,
# we can compile same code for ALL platforms with no change required, but, working on bigger
# projects, code needs to be refactored to avoid a blocking while() loop, moving Update and Draw
# logic to a self contained function: UpdateDrawFrame(), check core_basic_window_web.c for reference.
- # Define a custom shell .html and output extension
- LDFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
- EXT = .html
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib
@@ -325,8 +359,8 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(RAYLIB_LIBTYPE),SHARED)
LDLIBS += -lc
endif
-
- # TODO: On ARM 32bit arch, miniaudio requires atomics library
+
+ # NOTE: On ARM 32bit arch, miniaudio requires atomics library
LDLIBS += -latomic
endif
ifeq ($(PLATFORM_OS),OSX)
@@ -376,6 +410,7 @@ CORE = \
core/core_input_gamepad \
core/core_input_multitouch \
core/core_input_gestures \
+ core/core_input_gestures_web \
core/core_2d_camera \
core/core_2d_camera_platformer \
core/core_2d_camera_mouse_zoom \
@@ -424,6 +459,7 @@ TEXTURES = \
textures/textures_image_generation \
textures/textures_image_loading \
textures/textures_image_processing \
+ textures/textures_image_rotate \
textures/textures_image_text \
textures/textures_to_image \
textures/textures_raw_data \
@@ -433,6 +469,7 @@ TEXTURES = \
textures/textures_sprite_anim \
textures/textures_sprite_button \
textures/textures_sprite_explosion \
+ textures/textures_textured_curve \
textures/textures_bunnymark \
textures/textures_blend_modes \
textures/textures_draw_tiled \
@@ -460,6 +497,7 @@ MODELS = \
models/models_billboard \
models/models_box_collisions \
models/models_cubicmap \
+ models/models_draw_cube_texture \
models/models_first_person_maze \
models/models_geometric_shapes \
models/models_mesh_generation \
@@ -493,22 +531,33 @@ SHADERS = \
shaders/shaders_spotlight \
shaders/shaders_hot_reloading \
shaders/shaders_mesh_instancing \
- shaders/shaders_multi_sample2d
+ shaders/shaders_multi_sample2d \
+ shaders/shaders_write_depth \
+ shaders/shaders_hybrid_render
AUDIO = \
audio/audio_module_playing \
audio/audio_music_stream \
audio/audio_raw_stream \
audio/audio_sound_loading \
- audio/audio_multichannel_sound \
- audio/audio_stream_effects
+ audio/audio_sound_multi \
+ audio/audio_stream_effects \
+ audio/audio_mixed_processor
+
+OTHERS = \
+ others/easings_testbed \
+ others/embedded_files_loading \
+ others/raylib_opengl_interop \
+ others/raymath_vector_angle \
+ others/rlgl_compute_shader \
+ others/rlgl_standalone
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
# Define processes to execute
#------------------------------------------------------------------------------------------------
# Default target entry
-all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO)
+all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) $(OTHERS)
core: $(CORE)
shapes: $(SHAPES)
@@ -517,6 +566,7 @@ text: $(TEXT)
models: $(MODELS)
shaders: $(SHADERS)
audio: $(AUDIO)
+others: $(OTHERS)
# Generic compilation pattern
# NOTE: Examples must be ready for Android compilation!
@@ -551,7 +601,10 @@ ifeq ($(PLATFORM),PLATFORM_DRM)
rm -fv *.o
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
- del *.o *.html *.js
+ ifeq ($(PLATFORM_OS),WINDOWS)
+ del *.wasm *.html *.js *.data
+ else
+ rm -f */*.wasm */*.html */*.js */*.data
+ endif
endif
@echo Cleaning done
-
diff --git a/examples/Makefile.Android b/examples/Makefile.Android
index 5d76fb761..267c4aa57 100644
--- a/examples/Makefile.Android
+++ b/examples/Makefile.Android
@@ -2,7 +2,7 @@
#
# raylib makefile for Android project (APK building)
#
-# Copyright (c) 2017-2022 Ramon Santamaria (@raysan5)
+# Copyright (c) 2017-2023 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
@@ -48,7 +48,7 @@ ifeq ($(ANDROID_ARCH),ARM64)
ANDROID_ARCH_NAME = arm64-v8a
endif
ifeq ($(ANDROID_ARCH),x86)
- ANDROID_ARCH_NAME = i686
+ ANDROID_ARCH_NAME = x86
endif
ifeq ($(ANDROID_ARCH),x86_64)
ANDROID_ARCH_NAME = x86_64
diff --git a/examples/Makefile.Web b/examples/Makefile.Web
index f6eb3bd9d..c381aee9b 100644
--- a/examples/Makefile.Web
+++ b/examples/Makefile.Web
@@ -2,7 +2,7 @@
#
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
#
-# Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+# Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
@@ -30,7 +30,7 @@ PLATFORM ?= PLATFORM_WEB
# Define required raylib variables
PROJECT_NAME ?= raylib_examples
-RAYLIB_VERSION ?= 4.2.0
+RAYLIB_VERSION ?= 4.5.0
RAYLIB_PATH ?= ..
# Locations of raylib.h and libraylib.a/libraylib.so
@@ -60,8 +60,8 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif
endif
-# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
-ifeq ($(PLATFORM),PLATFORM_DESKTOP)
+# Determine PLATFORM_OS in case PLATFORM_DESKTOP or PLATFORM_WEB selected
+ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB))
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT)
@@ -119,16 +119,18 @@ ifeq ($(PLATFORM),PLATFORM_DRM)
endif
# Define raylib release directory for compiled library
-RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
+RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_WEB)
- # Emscripten required variables
- EMSDK_PATH ?= C:/emsdk
- EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
- CLANG_PATH = $(EMSDK_PATH)/upstream/bin
- PYTHON_PATH = $(EMSDK_PATH)/python/3.9.2-1_64bit
- NODE_PATH = $(EMSDK_PATH)/node/14.15.5_64bit/bin
- export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH):$$(PATH)
+ ifeq ($(PLATFORM_OS),WINDOWS)
+ # Emscripten required variables
+ EMSDK_PATH ?= C:/emsdk
+ EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
+ CLANG_PATH = $(EMSDK_PATH)/upstream/bin
+ PYTHON_PATH = $(EMSDK_PATH)/python/3.9.2-1_64bit
+ NODE_PATH = $(EMSDK_PATH)/node/14.15.5_64bit/bin
+ export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH):$$(PATH)
+ endif
endif
# Define default C compiler: CC
@@ -195,9 +197,13 @@ ifeq ($(BUILD_MODE),DEBUG)
endif
else
ifeq ($(PLATFORM),PLATFORM_WEB)
- CFLAGS += -Os
+ ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
+ CFLAGS += -O3
+ else
+ CFLAGS += -Os
+ endif
else
- CFLAGS += -s -O1
+ CFLAGS += -s -O2
endif
endif
@@ -279,11 +285,12 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s ASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
# -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data
# -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off)
+ # -s EXPORTED_RUNTIME_METHODS=ccall # require exporting some LEGACY_RUNTIME functions, ccall() is required by miniaudio
# --profiling # include information for code profiling
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# --preload-file resources # specify a resources folder for data compilation
# --source-map-base # allow debugging in browser with source map
- LDFLAGS += -s USE_GLFW=3 -s ASYNCIFY
+ LDFLAGS += -s USE_GLFW=3 -s ASYNCIFY -s EXPORTED_RUNTIME_METHODS=ccall
# NOTE: Simple raylib examples are compiled to be interpreter with asyncify, that way,
# we can compile same code for ALL platforms with no change required, but, working on bigger
@@ -328,6 +335,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(RAYLIB_LIBTYPE),SHARED)
LDLIBS += -lc
endif
+
+ # NOTE: On ARM 32bit arch, miniaudio requires atomics library
+ LDLIBS += -latomic
endif
ifeq ($(PLATFORM_OS),OSX)
# Libraries for OSX 10.9 desktop compiling
@@ -376,6 +386,7 @@ CORE = \
core/core_input_gamepad \
core/core_input_multitouch \
core/core_input_gestures \
+ core/core_input_gestures_web \
core/core_2d_camera \
core/core_2d_camera_platformer \
core/core_2d_camera_mouse_zoom \
@@ -390,13 +401,13 @@ CORE = \
core/core_scissor_test \
core/core_storage_values \
core/core_vr_simulator \
- core/core_loading_thread \
core/core_window_flags \
core/core_window_letterbox \
core/core_window_should_close \
core/core_split_screen \
core/core_smooth_pixelperfect \
- core/core_custom_frame_control
+ core/core_custom_frame_control \
+ core/core_loading_thread
SHAPES = \
shapes/shapes_basic_shapes \
@@ -433,6 +444,7 @@ TEXTURES = \
textures/textures_sprite_anim \
textures/textures_sprite_button \
textures/textures_sprite_explosion \
+ textures/textures_textured_curve \
textures/textures_bunnymark \
textures/textures_blend_modes \
textures/textures_draw_tiled \
@@ -460,6 +472,7 @@ MODELS = \
models/models_billboard \
models/models_box_collisions \
models/models_cubicmap \
+ models/models_draw_cube_texture \
models/models_first_person_maze \
models/models_geometric_shapes \
models/models_mesh_generation \
@@ -467,6 +480,7 @@ MODELS = \
models/models_loading \
models/models_loading_vox \
models/models_loading_gltf \
+ models/models_loading_m3d \
models/models_orthographic_projection \
models/models_rlgl_solar_system \
models/models_skybox \
@@ -492,15 +506,17 @@ SHADERS = \
shaders/shaders_spotlight \
shaders/shaders_hot_reloading \
shaders/shaders_mesh_instancing \
- shaders/shaders_multi_sample2d
+ shaders/shaders_multi_sample2d \
+ shaders/shaders_write_depth \
+ shaders/shaders_hybrid_render
AUDIO = \
audio/audio_module_playing \
audio/audio_music_stream \
audio/audio_raw_stream \
audio/audio_sound_loading \
- audio/audio_multichannel_sound \
- audio/audio_stream_effects
+ audio/audio_stream_effects \
+ audio/audio_mixed_processor
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
@@ -544,12 +560,15 @@ core/core_input_multitouch: core/core_input_multitouch.c
core/core_input_gestures: core/core_input_gestures.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
+core/core_input_gestures_web: core/core_input_gestures_web.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
+
core/core_2d_camera: core/core_2d_camera.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_2d_camera_platformer: core/core_2d_camera_platformer.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
-
+
core/core_2d_camera_mouse_zoom: core/core_2d_camera_mouse_zoom.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@@ -590,13 +609,6 @@ core/core_vr_simulator: core/core_vr_simulator.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file core/resources/distortion100.fs@resources/distortion100.fs
-# NOTE: To use multi-threading raylib must be compiled with multi-theading support (-s USE_PTHREADS=1)
-# WARNING: For security reasons multi-threading is not supported on browsers, it requires cross-origin isolation (Oct.2021)
-# WARNING: It requires raylib to be compiled using -pthread, so atomic operations and thread-local data (if any)
-# in its source were transformed to non-atomic operations and non-thread-local data
-core/core_loading_thread: core/core_loading_thread.c
- $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s USE_PTHREADS=1
-
core/core_window_flags: core/core_window_flags.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@@ -612,6 +624,14 @@ core/core_custom_frame_control: core/core_custom_frame_control.c
core/core_window_should_close: core/core_window_should_close.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
+# NOTE: To use multi-threading raylib must be compiled with multi-theading support (-s USE_PTHREADS=1)
+# WARNING: For security reasons multi-threading is not supported on browsers, it requires cross-origin isolation (Oct.2021)
+# WARNING: It requires raylib to be compiled using -pthread, so atomic operations and thread-local data (if any)
+# in its source were transformed to non-atomic operations and non-thread-local data
+core/core_loading_thread: core/core_loading_thread.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s USE_PTHREADS=1
+
+
# Compile SHAPES examples
shapes/shapes_basic_shapes: shapes/shapes_basic_shapes.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@@ -731,6 +751,10 @@ textures/textures_sprite_explosion: textures/textures_sprite_explosion.c
--preload-file textures/resources/explosion.png@resources/explosion.png \
--preload-file textures/resources/boom.wav@resources/boom.wav
+textures/textures_textured_curve: textures/textures_textured_curve.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
+ --preload-file textures/resources/road.png@resources/road.png
+
textures/textures_bunnymark: textures/textures_bunnymark.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/resources/wabbit_alpha.png@resources/wabbit_alpha.png
@@ -836,6 +860,10 @@ models/models_cubicmap: models/models_cubicmap.c
--preload-file models/resources/cubicmap.png@resources/cubicmap.png \
--preload-file models/resources/cubicmap_atlas.png@resources/cubicmap_atlas.png
+models/models_draw_cube_texture: models/models_draw_cube_texture.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
+ --preload-file models/resources/cubicmap_atlas.png@resources/cubicmap_atlas.png
+
models/models_first_person_maze: models/models_first_person_maze.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file models/resources/cubicmap.png@resources/cubicmap.png \
@@ -867,6 +895,10 @@ models/models_loading_gltf: models/models_loading_gltf.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
--preload-file models/resources/models/gltf/robot.glb@resources/models/gltf/robot.glb
+models/models_loading_m3d: models/models_loading_m3d.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
+ --preload-file models/resources/models/m3d/cesium_man.m3d@resources/models/m3d/cesium_man.m3d
+
models/models_orthographic_projection: models/models_orthographic_projection.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@@ -947,13 +979,13 @@ shaders/shaders_basic_lighting: shaders/shaders_basic_lighting.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/texel_checker.png@resources/texel_checker.png \
--preload-file shaders/resources/shaders/glsl100/lighting.fs@resources/shaders/glsl100/lighting.fs \
- --preload-file shaders/resources/shaders/glsl100/base_lighting.vs@resources/shaders/glsl100/base_lighting.vs
+ --preload-file shaders/resources/shaders/glsl100/lighting.vs@resources/shaders/glsl100/lighting.vs
shaders/shaders_fog: shaders/shaders_fog.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/texel_checker.png@resources/texel_checker.png \
--preload-file shaders/resources/shaders/glsl100/fog.fs@resources/shaders/glsl100/fog.fs \
- --preload-file shaders/resources/shaders/glsl100/base_lighting.vs@resources/shaders/glsl100/base_lighting.vs
+ --preload-file shaders/resources/shaders/glsl100/lighting.vs@resources/shaders/glsl100/lighting.vs
shaders/shaders_simple_mask: shaders/shaders_simple_mask.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
@@ -972,10 +1004,9 @@ shaders/shaders_hot_reloading: shaders/shaders_hot_reloading.c
shaders/shaders_mesh_instancing: shaders/shaders_mesh_instancing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
- --preload-file shaders/resources/shaders/glsl100/base_lighting_instanced.vs@resources/shaders/glsl100/base_lighting_instanced.vs \
+ --preload-file shaders/resources/shaders/glsl100/lighting_instancing.vs@resources/shaders/glsl100/lighting_instancing.vs \
--preload-file shaders/resources/shaders/glsl100/lighting.fs@resources/shaders/glsl100/lighting.fs
-
shaders/shaders_multi_sample2d: shaders/shaders_multi_sample2d.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/color_mix.fs@resources/shaders/glsl100/color_mix.fs
@@ -985,6 +1016,15 @@ shaders/shaders_texture_outline: shaders/shaders_texture_outline.c
--preload-file shaders/resources/shaders/glsl100/outline.fs@resources/shaders/glsl100/outline.fs \
--preload-file shaders/resources/fudesumi.png@resources/fudesumi.png
+shaders/shaders_write_depth: shaders/shaders_write_depth.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
+ --preload-file shaders/resources/shaders/glsl100/write_depth.fs@resources/shaders/glsl100/write_depth.fs
+
+shaders/shaders_hybrid_render: shaders/shaders_hybrid_render.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
+ --preload-file shaders/resources/shaders/glsl100/hybrid_raymarch.fs@resources/shaders/glsl100/hybrid_raymarch.fs \
+ --preload-file shaders/resources/shaders/glsl100/hybrid_raster.fs@resources/shaders/glsl100/hybrid_raster.fs
+
# Compile AUDIO examples
audio/audio_module_playing: audio/audio_module_playing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
@@ -1002,15 +1042,15 @@ audio/audio_sound_loading: audio/audio_sound_loading.c
--preload-file audio/resources/sound.wav@resources/sound.wav \
--preload-file audio/resources/target.ogg@resources/target.ogg
-audio/audio_multichannel_sound: audio/audio_multichannel_sound.c
- $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
- --preload-file audio/resources/sound.wav@resources/sound.wav \
- --preload-file audio/resources/target.ogg@resources/target.ogg
-
audio/audio_stream_effects: audio/audio_stream_effects.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
--preload-file audio/resources/country.mp3@resources/country.mp3
+audio/audio_mixed_processor: audio/audio_mixed_processor.c
+ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
+ --preload-file audio/resources/country.mp3@resources/country.mp3 \
+ --preload-file audio/resources/coin.wav@resources/coin.wav
+
# Clean everything
clean:
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
diff --git a/examples/README.md b/examples/README.md
index 7a3e72f87..8399d677d 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -186,7 +186,6 @@ Examples using raylib audio functionality, including sound/music loading and pla
| 118 | [audio_music_stream](audio/audio_music_stream.c) |
| ⭐️☆☆☆ | 1.3 | **4.2** | [Ray](https://github.com/raysan5) |
| 119 | [audio_raw_stream](audio/audio_raw_stream.c) |
| ⭐️⭐️⭐️☆ | 1.6 | **4.2** | [Ray](https://github.com/raysan5) |
| 120 | [audio_sound_loading](audio/audio_sound_loading.c) |
| ⭐️☆☆☆ | 1.1 | 3.5 | [Ray](https://github.com/raysan5) |
-| 121 | [audio_multichannel_sound](audio/audio_multichannel_sound.c) |
| ⭐️☆☆☆ | 3.0 | 3.5 | [Chris Camacho](https://github.com/codifies) |
### category: others
diff --git a/examples/audio/audio_mixed_processor.c b/examples/audio/audio_mixed_processor.c
new file mode 100644
index 000000000..3a008f3e2
--- /dev/null
+++ b/examples/audio/audio_mixed_processor.c
@@ -0,0 +1,123 @@
+/*******************************************************************************************
+*
+* raylib [audio] example - Mixed audio processing
+*
+* Example originally created with raylib 4.2, last time updated with raylib 4.2
+*
+* Example contributed by hkc (@hatkidchan) and reviewed by Ramon Santamaria (@raysan5)
+*
+* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
+* BSD-like license that allows static linking with closed source software
+*
+* Copyright (c) 2023 hkc (@hatkidchan)
+*
+********************************************************************************************/
+#include "raylib.h"
+#include
+
+static float exponent = 1.0f; // Audio exponentiation value
+static float averageVolume[400] = { 0.0f }; // Average volume history
+
+//------------------------------------------------------------------------------------
+// Audio processing function
+//------------------------------------------------------------------------------------
+void ProcessAudio(void *buffer, unsigned int frames)
+{
+ float *samples = (float *)buffer; // Samples internally stored as s
+ float average = 0.0f; // Temporary average volume
+
+ for (unsigned int frame = 0; frame < frames; frame++)
+ {
+ float *left = &samples[frame * 2 + 0], *right = &samples[frame * 2 + 1];
+
+ *left = powf(fabsf(*left), exponent) * ( (*left < 0.0f)? -1.0f : 1.0f );
+ *right = powf(fabsf(*right), exponent) * ( (*right < 0.0f)? -1.0f : 1.0f );
+
+ average += fabsf(*left) / frames; // accumulating average volume
+ average += fabsf(*right) / frames;
+ }
+
+ // Moving history to the left
+ for (int i = 0; i < 399; i++) averageVolume[i] = averageVolume[i + 1];
+
+ averageVolume[399] = average; // Adding last average value
+}
+
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
+int main(void)
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [audio] example - processing mixed output");
+
+ InitAudioDevice(); // Initialize audio device
+
+ AttachAudioMixedProcessor(ProcessAudio);
+
+ Music music = LoadMusicStream("resources/country.mp3");
+ Sound sound = LoadSound("resources/coin.wav");
+
+ PlayMusicStream(music);
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ UpdateMusicStream(music); // Update music buffer with new stream data
+
+ // Modify processing variables
+ //----------------------------------------------------------------------------------
+ if (IsKeyPressed(KEY_LEFT)) exponent -= 0.05f;
+ if (IsKeyPressed(KEY_RIGHT)) exponent += 0.05f;
+
+ if (exponent <= 0.5f) exponent = 0.5f;
+ if (exponent >= 3.0f) exponent = 3.0f;
+
+ if (IsKeyPressed(KEY_SPACE)) PlaySound(sound);
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, LIGHTGRAY);
+
+ DrawText(TextFormat("EXPONENT = %.2f", exponent), 215, 180, 20, LIGHTGRAY);
+
+ DrawRectangle(199, 199, 402, 34, LIGHTGRAY);
+ for (int i = 0; i < 400; i++)
+ {
+ DrawLine(201 + i, 232 - averageVolume[i] * 32, 201 + i, 232, MAROON);
+ }
+ DrawRectangleLines(199, 199, 402, 34, GRAY);
+
+ DrawText("PRESS SPACE TO PLAY OTHER SOUND", 200, 250, 20, LIGHTGRAY);
+ DrawText("USE LEFT AND RIGHT ARROWS TO ALTER DISTORTION", 140, 280, 20, LIGHTGRAY);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadMusicStream(music); // Unload music stream buffers from RAM
+
+ DetachAudioMixedProcessor(ProcessAudio); // Disconnect audio processor
+
+ CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}
diff --git a/examples/audio/audio_mixed_processor.png b/examples/audio/audio_mixed_processor.png
new file mode 100644
index 000000000..8575a836d
Binary files /dev/null and b/examples/audio/audio_mixed_processor.png differ
diff --git a/examples/audio/audio_module_playing.c b/examples/audio/audio_module_playing.c
index e47db592b..bf5530fdc 100644
--- a/examples/audio/audio_module_playing.c
+++ b/examples/audio/audio_module_playing.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2016-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2016-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -79,6 +79,7 @@ int main(void)
{
StopMusicStream(music);
PlayMusicStream(music);
+ pause = false;
}
// Pause/Resume music playing
@@ -134,6 +135,14 @@ int main(void)
DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, MAROON);
DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, GRAY);
+ // Draw help instructions
+ DrawRectangle(20, 20, 425, 145, WHITE);
+ DrawRectangleLines(20, 20, 425, 145, GRAY);
+ DrawText("PRESS SPACE TO RESTART MUSIC", 40, 40, 20, BLACK);
+ DrawText("PRESS P TO PAUSE/RESUME", 40, 70, 20, BLACK);
+ DrawText("PRESS UP/DOWN TO CHANGE SPEED", 40, 100, 20, BLACK);
+ DrawText(TextFormat("SPEED: %f", pitch), 40, 130, 20, MAROON);
+
EndDrawing();
//----------------------------------------------------------------------------------
}
@@ -148,4 +157,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
-}
\ No newline at end of file
+}
diff --git a/examples/audio/audio_module_playing.png b/examples/audio/audio_module_playing.png
index 8bde9879d..63003e047 100644
Binary files a/examples/audio/audio_module_playing.png and b/examples/audio/audio_module_playing.png differ
diff --git a/examples/audio/audio_multichannel_sound.png b/examples/audio/audio_multichannel_sound.png
deleted file mode 100644
index 4b98b26e0..000000000
Binary files a/examples/audio/audio_multichannel_sound.png and /dev/null differ
diff --git a/examples/audio/audio_music_stream.c b/examples/audio/audio_music_stream.c
index 44b1faf0c..4cf29973d 100644
--- a/examples/audio/audio_music_stream.c
+++ b/examples/audio/audio_music_stream.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -34,7 +34,7 @@ int main(void)
float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f]
bool pause = false; // Music playing paused
- SetTargetFPS(30); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(30); // Set our game to run at 30 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
@@ -95,4 +95,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
-}
\ No newline at end of file
+}
diff --git a/examples/audio/audio_raw_stream.c b/examples/audio/audio_raw_stream.c
index afee42962..6befa765a 100644
--- a/examples/audio/audio_raw_stream.c
+++ b/examples/audio/audio_raw_stream.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5) and James Hofmann (@triplefox)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5) and James Hofmann (@triplefox)
*
********************************************************************************************/
@@ -43,7 +43,7 @@ void AudioInputCallback(void *buffer, unsigned int frames)
float incr = audioFrequency/44100.0f;
short *d = (short *)buffer;
- for (int i = 0; i < frames; i++)
+ for (unsigned int i = 0; i < frames; i++)
{
d[i] = (short)(32000.0f*sinf(2*PI*sineIdx));
sineIdx += incr;
diff --git a/examples/audio/audio_sound_loading.c b/examples/audio/audio_sound_loading.c
index 6a2670439..dae6516ee 100644
--- a/examples/audio/audio_sound_loading.c
+++ b/examples/audio/audio_sound_loading.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/audio/audio_multichannel_sound.c b/examples/audio/audio_sound_multi.c
similarity index 53%
rename from examples/audio/audio_multichannel_sound.c
rename to examples/audio/audio_sound_multi.c
index 3e6a612c8..d5472efab 100644
--- a/examples/audio/audio_multichannel_sound.c
+++ b/examples/audio/audio_sound_multi.c
@@ -1,20 +1,22 @@
/*******************************************************************************************
*
-* raylib [audio] example - Multichannel sound playing
+* raylib [audio] example - Playing sound multiple times
*
-* Example originally created with raylib 3.0, last time updated with raylib 3.5
-*
-* Example contributed by Chris Camacho (@chriscamacho) and reviewed by Ramon Santamaria (@raysan5)
+* Example originally created with raylib 4.6
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Chris Camacho (@chriscamacho) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2023 Jeffery Myers (@JeffM2501)
*
********************************************************************************************/
#include "raylib.h"
+#define MAX_SOUNDS 10
+Sound soundArray[MAX_SOUNDS] = { 0 };
+int currentSound;
+
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
@@ -25,16 +27,20 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
- InitWindow(screenWidth, screenHeight, "raylib [audio] example - Multichannel sound playing");
+ InitWindow(screenWidth, screenHeight, "raylib [audio] example - playing sound multiple times");
InitAudioDevice(); // Initialize audio device
- Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file
- Sound fxOgg = LoadSound("resources/target.ogg"); // Load OGG audio file
+ // load the sound list
+ soundArray[0] = LoadSound("resources/sound.wav"); // Load WAV audio file into the first slot as the 'source' sound
+ // this sound owns the sample data
+ for (int i = 1; i < MAX_SOUNDS; i++)
+ {
+ soundArray[i] = LoadSoundAlias(soundArray[0]); // Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
+ }
+ currentSound = 0; // set the sound list to the start
- SetSoundVolume(fxWav, 0.2f);
-
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
@@ -42,8 +48,16 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- if (IsKeyPressed(KEY_ENTER)) PlaySoundMulti(fxWav); // Play a new wav sound instance
- if (IsKeyPressed(KEY_SPACE)) PlaySoundMulti(fxOgg); // Play a new ogg sound instance
+ if (IsKeyPressed(KEY_SPACE))
+ {
+ PlaySound(soundArray[currentSound]); // play the next open sound slot
+ currentSound++; // increment the sound slot
+ if (currentSound >= MAX_SOUNDS) // if the sound slot is out of bounds, go back to 0
+ currentSound = 0;
+
+ // Note: a better way would be to look at the list for the first sound that is not playing and use that slot
+ }
+
//----------------------------------------------------------------------------------
// Draw
@@ -52,11 +66,7 @@ int main(void)
ClearBackground(RAYWHITE);
- DrawText("MULTICHANNEL SOUND PLAYING", 20, 20, 20, GRAY);
- DrawText("Press SPACE to play new ogg instance!", 200, 120, 20, LIGHTGRAY);
- DrawText("Press ENTER to play new wav instance!", 200, 180, 20, LIGHTGRAY);
-
- DrawText(TextFormat("CONCURRENT SOUNDS PLAYING: %02i", GetSoundsPlaying()), 220, 280, 20, RED);
+ DrawText("Press SPACE to PLAY a WAV sound!", 200, 180, 20, LIGHTGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
@@ -64,10 +74,9 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
- StopSoundMulti(); // We must stop the buffer pool before unloading
-
- UnloadSound(fxWav); // Unload sound data
- UnloadSound(fxOgg); // Unload sound data
+ for (int i = 1; i < MAX_SOUNDS; i++)
+ UnloadSoundAlias(soundArray[i]); // Unload sound aliases
+ UnloadSound(soundArray[0]); // Unload source sound data
CloseAudioDevice(); // Close audio device
@@ -75,4 +84,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
-}
+}
\ No newline at end of file
diff --git a/examples/audio/audio_stream_effects.c b/examples/audio/audio_stream_effects.c
index ddaeb7fb0..219305057 100644
--- a/examples/audio/audio_stream_effects.c
+++ b/examples/audio/audio_stream_effects.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2022-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/audio/resources/target.qoa b/examples/audio/resources/target.qoa
new file mode 100644
index 000000000..d48c4f9f0
Binary files /dev/null and b/examples/audio/resources/target.qoa differ
diff --git a/examples/build.zig b/examples/build.zig
index 3e6d68ade..6e13ab3da 100644
--- a/examples/build.zig
+++ b/examples/build.zig
@@ -1,10 +1,11 @@
const std = @import("std");
const builtin = @import("builtin");
-fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zig.CrossTarget) !*std.build.Step {
- // Standard release options allow the person running `zig build` to select
- // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
- const mode = b.standardReleaseOptions();
+// This has been tested to work with zig master branch as of commit 87de821 or May 14 2023
+fn add_module(comptime module: []const u8, b: *std.Build, target: std.zig.CrossTarget, optimize: std.builtin.OptimizeMode) !*std.Build.Step {
+ if (target.getOsTag() == .emscripten) {
+ @panic("Emscripten building via Zig unsupported");
+ }
const all = b.step(module, "All " ++ module ++ " examples");
const dir = try std.fs.cwd().openIterableDir(module, .{});
@@ -18,33 +19,33 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
// zig's mingw headers do not include pthread.h
if (std.mem.eql(u8, "core_loading_thread", name) and target.getOsTag() == .windows) continue;
- const exe = b.addExecutable(name, null);
- exe.addCSourceFile(path, switch (target.getOsTag()) {
- .windows => &[_][]const u8{},
- .linux => &[_][]const u8{},
- .macos => &[_][]const u8{"-DPLATFORM_DESKTOP"},
- else => @panic("Unsupported OS"),
+ const exe = b.addExecutable(.{
+ .name = name,
+ .target = target,
+ .optimize = optimize,
});
- exe.setTarget(target);
- exe.setBuildMode(mode);
+ exe.addCSourceFile(path, &[_][]const u8{});
exe.linkLibC();
exe.addObjectFile(switch (target.getOsTag()) {
- .windows => "../src/raylib.lib",
- .linux => "../src/libraylib.a",
- .macos => "../src/libraylib.a",
+ .windows => "../src/zig-out/lib/raylib.lib",
+ .linux => "../src/zig-out/lib/libraylib.a",
+ .macos => "../src/zig-out/lib/libraylib.a",
+ .emscripten => "../src/zig-out/lib/libraylib.a",
else => @panic("Unsupported OS"),
});
- exe.addIncludeDir("../src");
- exe.addIncludeDir("../src/external");
- exe.addIncludeDir("../src/external/glfw/include");
+ exe.addIncludePath("../src");
+ exe.addIncludePath("../src/external");
+ exe.addIncludePath("../src/external/glfw/include");
- switch (exe.target.toTarget().os.tag) {
+ switch (target.getOsTag()) {
.windows => {
exe.linkSystemLibrary("winmm");
exe.linkSystemLibrary("gdi32");
exe.linkSystemLibrary("opengl32");
- exe.addIncludeDir("external/glfw/deps/mingw");
+ exe.addIncludePath("external/glfw/deps/mingw");
+
+ exe.defineCMacro("PLATFORM_DESKTOP", null);
},
.linux => {
exe.linkSystemLibrary("GL");
@@ -52,6 +53,8 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
exe.linkSystemLibrary("dl");
exe.linkSystemLibrary("m");
exe.linkSystemLibrary("X11");
+
+ exe.defineCMacro("PLATFORM_DESKTOP", null);
},
.macos => {
exe.linkFramework("Foundation");
@@ -60,16 +63,16 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
exe.linkFramework("CoreAudio");
exe.linkFramework("CoreVideo");
exe.linkFramework("IOKit");
+
+ exe.defineCMacro("PLATFORM_DESKTOP", null);
},
else => {
@panic("Unsupported OS");
},
}
- exe.setOutputDir(module);
-
- var run = exe.run();
- run.step.dependOn(&b.addInstallArtifact(exe).step);
+ b.installArtifact(exe);
+ var run = b.addRunArtifact(exe);
run.cwd = module;
b.step(name, name).dependOn(&run.step);
all.dependOn(&exe.step);
@@ -77,21 +80,25 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
return all;
}
-pub fn build(b: *std.build.Builder) !void {
+pub fn build(b: *std.Build) !void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
+ // Standard optimization options allow the person running `zig build` to select
+ // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
+ // set a preferred release mode, allowing the user to decide how to optimize.
+ const optimize = b.standardOptimizeOption(.{});
const all = b.getInstallStep();
- all.dependOn(try add_module("audio", b, target));
- all.dependOn(try add_module("core", b, target));
- all.dependOn(try add_module("models", b, target));
- all.dependOn(try add_module("others", b, target));
- all.dependOn(try add_module("shaders", b, target));
- all.dependOn(try add_module("shapes", b, target));
- all.dependOn(try add_module("text", b, target));
- all.dependOn(try add_module("textures", b, target));
+ all.dependOn(try add_module("audio", b, target, optimize));
+ all.dependOn(try add_module("core", b, target, optimize));
+ all.dependOn(try add_module("models", b, target, optimize));
+ all.dependOn(try add_module("others", b, target, optimize));
+ all.dependOn(try add_module("shaders", b, target, optimize));
+ all.dependOn(try add_module("shapes", b, target, optimize));
+ all.dependOn(try add_module("text", b, target, optimize));
+ all.dependOn(try add_module("textures", b, target, optimize));
}
diff --git a/examples/core/core_2d_camera.c b/examples/core/core_2d_camera.c
index edc67a0a8..24cca6985 100644
--- a/examples/core/core_2d_camera.c
+++ b/examples/core/core_2d_camera.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2016-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2016-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_2d_camera_mouse_zoom.c b/examples/core/core_2d_camera_mouse_zoom.c
index 74ac76499..2e94d37a5 100644
--- a/examples/core/core_2d_camera_mouse_zoom.c
+++ b/examples/core/core_2d_camera_mouse_zoom.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2022 Jeffery Myers (@JeffM2501)
+* Copyright (c) 2022-2023 Jeffery Myers (@JeffM2501)
*
********************************************************************************************/
diff --git a/examples/core/core_2d_camera_platformer.c b/examples/core/core_2d_camera_platformer.c
index 5750e7a80..b149ea8c3 100644
--- a/examples/core/core_2d_camera_platformer.c
+++ b/examples/core/core_2d_camera_platformer.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 arvyy (@arvyy)
+* Copyright (c) 2019-2023 arvyy (@arvyy)
*
********************************************************************************************/
@@ -90,7 +90,7 @@ int main(void)
"Follow player center",
"Follow player center, but clamp to map edges",
"Follow player center; smoothed",
- "Follow player center horizontally; updateplayer center vertically after landing",
+ "Follow player center horizontally; update player center vertically after landing",
"Player push camera on getting too close to screen edge"
};
diff --git a/examples/core/core_3d_camera_first_person.c b/examples/core/core_3d_camera_first_person.c
index 3af829e25..6a2a115a7 100644
--- a/examples/core/core_3d_camera_first_person.c
+++ b/examples/core/core_3d_camera_first_person.c
@@ -7,11 +7,12 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
+#include "rcamera.h"
#define MAX_COLUMNS 20
@@ -29,11 +30,13 @@ int main(void)
// Define the camera to look into our 3d world (position, target, up vector)
Camera camera = { 0 };
- camera.position = (Vector3){ 4.0f, 2.0f, 4.0f };
- camera.target = (Vector3){ 0.0f, 1.8f, 0.0f };
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
- camera.fovy = 60.0f;
- camera.projection = CAMERA_PERSPECTIVE;
+ camera.position = (Vector3){ 0.0f, 2.0f, 4.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 60.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
+
+ int cameraMode = CAMERA_FIRST_PERSON;
// Generates some random columns
float heights[MAX_COLUMNS] = { 0 };
@@ -47,17 +50,93 @@ int main(void)
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
}
- SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person camera mode
+ DisableCursor(); // Limit cursor to relative movement inside the window
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ // Switch camera mode
+ if (IsKeyPressed(KEY_ONE))
+ {
+ cameraMode = CAMERA_FREE;
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Reset roll
+ }
+
+ if (IsKeyPressed(KEY_TWO))
+ {
+ cameraMode = CAMERA_FIRST_PERSON;
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Reset roll
+ }
+
+ if (IsKeyPressed(KEY_THREE))
+ {
+ cameraMode = CAMERA_THIRD_PERSON;
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Reset roll
+ }
+
+ if (IsKeyPressed(KEY_FOUR))
+ {
+ cameraMode = CAMERA_ORBITAL;
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Reset roll
+ }
+
+ // Switch camera projection
+ if (IsKeyPressed(KEY_P))
+ {
+ if (camera.projection == CAMERA_PERSPECTIVE)
+ {
+ // Create isometric view
+ cameraMode = CAMERA_THIRD_PERSON;
+ // Note: The target distance is related to the render distance in the orthographic projection
+ camera.position = (Vector3){ 0.0f, 2.0f, -100.0f };
+ camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
+ camera.projection = CAMERA_ORTHOGRAPHIC;
+ camera.fovy = 20.0f; // near plane width in CAMERA_ORTHOGRAPHIC
+ CameraYaw(&camera, -135 * DEG2RAD, true);
+ CameraPitch(&camera, -45 * DEG2RAD, true, true, false);
+ }
+ else if (camera.projection == CAMERA_ORTHOGRAPHIC)
+ {
+ // Reset to default view
+ cameraMode = CAMERA_THIRD_PERSON;
+ camera.position = (Vector3){ 0.0f, 2.0f, 10.0f };
+ camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
+ camera.projection = CAMERA_PERSPECTIVE;
+ camera.fovy = 60.0f;
+ }
+ }
+
+ // Update camera computes movement internally depending on the camera mode
+ // Some default standard keyboard/mouse inputs are hardcoded to simplify use
+ // For advance camera controls, it's reecommended to compute camera movement manually
+ UpdateCamera(&camera, cameraMode); // Update camera
+
+/*
+ // Camera PRO usage example (EXPERIMENTAL)
+ // This new camera function allows custom movement/rotation values to be directly provided
+ // as input parameters, with this approach, rcamera module is internally independent of raylib inputs
+ UpdateCameraPro(&camera,
+ (Vector3){
+ (IsKeyDown(KEY_W) || IsKeyDown(KEY_UP))*0.1f - // Move forward-backward
+ (IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN))*0.1f,
+ (IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT))*0.1f - // Move right-left
+ (IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT))*0.1f,
+ 0.0f // Move up-down
+ },
+ (Vector3){
+ GetMouseDelta().x*0.05f, // Rotation: yaw
+ GetMouseDelta().y*0.05f, // Rotation: pitch
+ 0.0f // Rotation: roll
+ },
+ GetMouseWheelMove()*2.0f); // Move to target (zoom)
+*/
//----------------------------------------------------------------------------------
// Draw
@@ -80,14 +159,39 @@ int main(void)
DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, MAROON);
}
+ // Draw player cube
+ if (cameraMode == CAMERA_THIRD_PERSON)
+ {
+ DrawCube(camera.target, 0.5f, 0.5f, 0.5f, PURPLE);
+ DrawCubeWires(camera.target, 0.5f, 0.5f, 0.5f, DARKPURPLE);
+ }
+
EndMode3D();
- DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5f));
- DrawRectangleLines( 10, 10, 220, 70, BLUE);
+ // Draw info boxes
+ DrawRectangle(5, 5, 330, 100, Fade(SKYBLUE, 0.5f));
+ DrawRectangleLines(5, 5, 330, 100, BLUE);
- DrawText("First person camera default controls:", 20, 20, 10, BLACK);
- DrawText("- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY);
- DrawText("- Mouse move to look around", 40, 60, 10, DARKGRAY);
+ DrawText("Camera controls:", 15, 15, 10, BLACK);
+ DrawText("- Move keys: W, A, S, D, Space, Left-Ctrl", 15, 30, 10, BLACK);
+ DrawText("- Look around: arrow keys or mouse", 15, 45, 10, BLACK);
+ DrawText("- Camera mode keys: 1, 2, 3, 4", 15, 60, 10, BLACK);
+ DrawText("- Zoom keys: num-plus, num-minus or mouse scroll", 15, 75, 10, BLACK);
+ DrawText("- Camera projection key: P", 15, 90, 10, BLACK);
+
+ DrawRectangle(600, 5, 195, 100, Fade(SKYBLUE, 0.5f));
+ DrawRectangleLines(600, 5, 195, 100, BLUE);
+
+ DrawText("Camera status:", 610, 15, 10, BLACK);
+ DrawText(TextFormat("- Mode: %s", (cameraMode == CAMERA_FREE) ? "FREE" :
+ (cameraMode == CAMERA_FIRST_PERSON) ? "FIRST_PERSON" :
+ (cameraMode == CAMERA_THIRD_PERSON) ? "THIRD_PERSON" :
+ (cameraMode == CAMERA_ORBITAL) ? "ORBITAL" : "CUSTOM"), 610, 30, 10, BLACK);
+ DrawText(TextFormat("- Projection: %s", (camera.projection == CAMERA_PERSPECTIVE) ? "PERSPECTIVE" :
+ (camera.projection == CAMERA_ORTHOGRAPHIC) ? "ORTHOGRAPHIC" : "CUSTOM"), 610, 45, 10, BLACK);
+ DrawText(TextFormat("- Position: (%06.3f, %06.3f, %06.3f)", camera.position.x, camera.position.y, camera.position.z), 610, 60, 10, BLACK);
+ DrawText(TextFormat("- Target: (%06.3f, %06.3f, %06.3f)", camera.target.x, camera.target.y, camera.target.z), 610, 75, 10, BLACK);
+ DrawText(TextFormat("- Up: (%06.3f, %06.3f, %06.3f)", camera.up.x, camera.up.y, camera.up.z), 610, 90, 10, BLACK);
EndDrawing();
//----------------------------------------------------------------------------------
diff --git a/examples/core/core_3d_camera_free.c b/examples/core/core_3d_camera_free.c
index b3b0b9b0b..59bd158a2 100644
--- a/examples/core/core_3d_camera_free.c
+++ b/examples/core/core_3d_camera_free.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -31,11 +31,11 @@ int main(void)
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
- camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
- SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
+ DisableCursor(); // Limit cursor to relative movement inside the window
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -45,7 +45,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_FREE);
if (IsKeyDown('Z')) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
//----------------------------------------------------------------------------------
diff --git a/examples/core/core_3d_camera_mode.c b/examples/core/core_3d_camera_mode.c
index ffa1acd6d..cb83a4a2b 100644
--- a/examples/core/core_3d_camera_mode.c
+++ b/examples/core/core_3d_camera_mode.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_3d_picking.c b/examples/core/core_3d_picking.c
index 8cd3a3fe1..c7bf94663 100644
--- a/examples/core/core_3d_picking.c
+++ b/examples/core/core_3d_picking.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -31,16 +31,13 @@ int main(void)
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
- camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
Ray ray = { 0 }; // Picking line ray
-
- RayCollision collision = { 0 };
-
- SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
+ RayCollision collision = { 0 }; // Ray collision hit info
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -50,7 +47,14 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ if (IsCursorHidden()) UpdateCamera(&camera, CAMERA_FIRST_PERSON);
+
+ // Toggle camera controls
+ if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT))
+ {
+ if (IsCursorHidden()) EnableCursor();
+ else DisableCursor();
+ }
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
{
@@ -93,10 +97,12 @@ int main(void)
EndMode3D();
- DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY);
+ DrawText("Try clicking on the box with your mouse!", 240, 10, 20, DARKGRAY);
if (collision.hit) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, (int)(screenHeight * 0.1f), 30, GREEN);
+ DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY);
+
DrawFPS(10, 10);
EndDrawing();
diff --git a/examples/core/core_basic_screen_manager.c b/examples/core/core_basic_screen_manager.c
index 1364982e8..a80572988 100644
--- a/examples/core/core_basic_screen_manager.c
+++ b/examples/core/core_basic_screen_manager.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2021-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2021-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_basic_window.c b/examples/core/core_basic_window.c
index 25937e4c3..5bfd186da 100644
--- a/examples/core/core_basic_window.c
+++ b/examples/core/core_basic_window.c
@@ -13,11 +13,11 @@
* Enjoy using raylib. :)
*
* Example originally created with raylib 1.0, last time updated with raylib 1.0
-
+*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_basic_window_web.c b/examples/core/core_basic_window_web.c
index 7dc47f9c9..7d83254a1 100644
--- a/examples/core/core_basic_window_web.c
+++ b/examples/core/core_basic_window_web.c
@@ -11,7 +11,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_custom_frame_control.c b/examples/core/core_custom_frame_control.c
index 016c6c448..9bfd25d3e 100644
--- a/examples/core/core_custom_frame_control.c
+++ b/examples/core/core_custom_frame_control.c
@@ -22,7 +22,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2021-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2021-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -86,8 +86,8 @@ int main(void)
DrawCircle((int)position, GetScreenHeight()/2 - 25, 50, RED);
- DrawText(TextFormat("%03.0f ms", timeCounter*1000.0f), position - 40, GetScreenHeight()/2 - 100, 20, MAROON);
- DrawText(TextFormat("PosX: %03.0f", position), position - 50, GetScreenHeight()/2 + 40, 20, BLACK);
+ DrawText(TextFormat("%03.0f ms", timeCounter*1000.0f), (int)position - 40, GetScreenHeight()/2 - 100, 20, MAROON);
+ DrawText(TextFormat("PosX: %03.0f", position), (int)position - 50, GetScreenHeight()/2 + 40, 20, BLACK);
DrawText("Circle is moving at a constant 200 pixels/sec,\nindependently of the frame rate.", 10, 10, 20, DARKGRAY);
DrawText("PRESS SPACE to PAUSE MOVEMENT", 10, GetScreenHeight() - 60, 20, GRAY);
@@ -115,7 +115,7 @@ int main(void)
deltaTime = (float)(currentTime - previousTime);
}
}
- else deltaTime = updateDrawTime; // Framerate could be variable
+ else deltaTime = (float)updateDrawTime; // Framerate could be variable
previousTime = currentTime;
//----------------------------------------------------------------------------------
diff --git a/examples/core/core_custom_logging.c b/examples/core/core_custom_logging.c
index 9794d14b9..b4da2d575 100644
--- a/examples/core/core_custom_logging.c
+++ b/examples/core/core_custom_logging.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2018-2022 Pablo Marcos Oltra (@pamarcos) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2018-2023 Pablo Marcos Oltra (@pamarcos) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_drop_files.c b/examples/core/core_drop_files.c
index 35ebc7689..9f6220393 100644
--- a/examples/core/core_drop_files.c
+++ b/examples/core/core_drop_files.c
@@ -9,12 +9,17 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
+#include // Required for: calloc(), free()
+
+#define MAX_FILEPATH_RECORDED 4096
+#define MAX_FILEPATH_SIZE 2048
+
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
@@ -27,7 +32,14 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files");
- FilePathList droppedFiles = { 0 };
+ int filePathCounter = 0;
+ char *filePaths[MAX_FILEPATH_RECORDED] = { 0 }; // We will register a maximum of filepaths
+
+ // Allocate space for the required file paths
+ for (int i = 0; i < MAX_FILEPATH_RECORDED; i++)
+ {
+ filePaths[i] = (char *)RL_CALLOC(MAX_FILEPATH_SIZE, 1);
+ }
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -39,11 +51,18 @@ int main(void)
//----------------------------------------------------------------------------------
if (IsFileDropped())
{
- // Is some files have been previously loaded, unload them
- if (droppedFiles.count > 0) UnloadDroppedFiles(droppedFiles);
-
- // Load new dropped files
- droppedFiles = LoadDroppedFiles();
+ FilePathList droppedFiles = LoadDroppedFiles();
+
+ for (int i = 0, offset = filePathCounter; i < droppedFiles.count; i++)
+ {
+ if (filePathCounter < (MAX_FILEPATH_RECORDED - 1))
+ {
+ TextCopy(filePaths[offset + i], droppedFiles.paths[i]);
+ filePathCounter++;
+ }
+ }
+
+ UnloadDroppedFiles(droppedFiles); // Unload filepaths from memory
}
//----------------------------------------------------------------------------------
@@ -53,20 +72,20 @@ int main(void)
ClearBackground(RAYWHITE);
- if (droppedFiles.count == 0) DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY);
+ if (filePathCounter == 0) DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY);
else
{
DrawText("Dropped files:", 100, 40, 20, DARKGRAY);
- for (int i = 0; i < droppedFiles.count; i++)
+ for (unsigned int i = 0; i < filePathCounter; i++)
{
if (i%2 == 0) DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f));
else DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f));
- DrawText(droppedFiles.paths[i], 120, 100 + 40*i, 10, GRAY);
+ DrawText(filePaths[i], 120, 100 + 40*i, 10, GRAY);
}
- DrawText("Drop new files...", 100, 110 + 40*droppedFiles.count, 20, DARKGRAY);
+ DrawText("Drop new files...", 100, 110 + 40*filePathCounter, 20, DARKGRAY);
}
EndDrawing();
@@ -75,7 +94,10 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
- UnloadDroppedFiles(droppedFiles); // Unload files memory
+ for (int i = 0; i < MAX_FILEPATH_RECORDED; i++)
+ {
+ RL_FREE(filePaths[i]); // Free allocated memory for all filepaths
+ }
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
diff --git a/examples/core/core_input_gamepad.c b/examples/core/core_input_gamepad.c
index 02ac17053..1eb516e85 100644
--- a/examples/core/core_input_gamepad.c
+++ b/examples/core/core_input_gamepad.c
@@ -13,7 +13,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -49,6 +49,8 @@ int main(void)
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
+ int gamepad = 0; // which gamepad to display
+
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
@@ -63,102 +65,114 @@ int main(void)
ClearBackground(RAYWHITE);
- if (IsGamepadAvailable(0))
- {
- DrawText(TextFormat("GP1: %s", GetGamepadName(0)), 10, 10, 10, BLACK);
+ if (IsKeyPressed(KEY_LEFT) && gamepad > 0) gamepad--;
+ if (IsKeyPressed(KEY_RIGHT)) gamepad++;
- if (TextIsEqual(GetGamepadName(0), XBOX360_NAME_ID) || TextIsEqual(GetGamepadName(0), XBOX360_LEGACY_NAME_ID))
+ if (IsGamepadAvailable(gamepad))
+ {
+ DrawText(TextFormat("GP%d: %s", gamepad, GetGamepadName(gamepad)), 10, 10, 10, BLACK);
+
+ if (true)
{
DrawTexture(texXboxPad, 0, 0, DARKGRAY);
// Draw buttons: xbox home
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE)) DrawCircle(394, 89, 19, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE)) DrawCircle(394, 89, 19, RED);
// Draw buttons: basic
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawCircle(436, 150, 9, RED);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawCircle(352, 150, 9, RED);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) DrawCircle(501, 151, 15, BLUE);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(536, 187, 15, LIME);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(572, 151, 15, MAROON);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_UP)) DrawCircle(536, 115, 15, GOLD);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawCircle(436, 150, 9, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawCircle(352, 150, 9, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) DrawCircle(501, 151, 15, BLUE);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(536, 187, 15, LIME);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(572, 151, 15, MAROON);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_UP)) DrawCircle(536, 115, 15, GOLD);
// Draw buttons: d-pad
DrawRectangle(317, 202, 19, 71, BLACK);
DrawRectangle(293, 228, 69, 19, BLACK);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_UP)) DrawRectangle(317, 202, 19, 26, RED);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(317, 202 + 45, 19, 26, RED);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(292, 228, 25, 19, RED);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(292 + 44, 228, 26, 19, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_UP)) DrawRectangle(317, 202, 19, 26, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(317, 202 + 45, 19, 26, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(292, 228, 25, 19, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(292 + 44, 228, 26, 19, RED);
// Draw buttons: left-right back
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawCircle(259, 61, 20, RED);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(536, 61, 20, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawCircle(259, 61, 20, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(536, 61, 20, RED);
// Draw axis: left joystick
+
+ Color leftGamepadColor = BLACK;
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_THUMB)) leftGamepadColor = RED;
DrawCircle(259, 152, 39, BLACK);
DrawCircle(259, 152, 34, LIGHTGRAY);
- DrawCircle(259 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X)*20),
- 152 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y)*20), 25, BLACK);
+ DrawCircle(259 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_X)*20),
+ 152 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_Y)*20), 25, leftGamepadColor);
// Draw axis: right joystick
+ Color rightGamepadColor = BLACK;
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_THUMB)) rightGamepadColor = RED;
DrawCircle(461, 237, 38, BLACK);
DrawCircle(461, 237, 33, LIGHTGRAY);
- DrawCircle(461 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X)*20),
- 237 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y)*20), 25, BLACK);
+ DrawCircle(461 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_X)*20),
+ 237 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_Y)*20), 25, rightGamepadColor);
// Draw axis: left-right triggers
DrawRectangle(170, 30, 15, 70, GRAY);
DrawRectangle(604, 30, 15, 70, GRAY);
- DrawRectangle(170, 30, 15, (int)(((1 + GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER))/2)*70), RED);
- DrawRectangle(604, 30, 15, (int)(((1 + GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER))/2)*70), RED);
+ DrawRectangle(170, 30, 15, (int)(((1 + GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_TRIGGER))/2)*70), RED);
+ DrawRectangle(604, 30, 15, (int)(((1 + GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_TRIGGER))/2)*70), RED);
- //DrawText(TextFormat("Xbox axis LT: %02.02f", GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER)), 10, 40, 10, BLACK);
- //DrawText(TextFormat("Xbox axis RT: %02.02f", GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER)), 10, 60, 10, BLACK);
+ //DrawText(TextFormat("Xbox axis LT: %02.02f", GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_TRIGGER)), 10, 40, 10, BLACK);
+ //DrawText(TextFormat("Xbox axis RT: %02.02f", GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_TRIGGER)), 10, 60, 10, BLACK);
}
- else if (TextIsEqual(GetGamepadName(0), PS3_NAME_ID))
+ else if (TextIsEqual(GetGamepadName(gamepad), PS3_NAME_ID))
{
DrawTexture(texPs3Pad, 0, 0, DARKGRAY);
// Draw buttons: ps
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE)) DrawCircle(396, 222, 13, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE)) DrawCircle(396, 222, 13, RED);
// Draw buttons: basic
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawRectangle(328, 170, 32, 13, RED);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawTriangle((Vector2){ 436, 168 }, (Vector2){ 436, 185 }, (Vector2){ 464, 177 }, RED);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_UP)) DrawCircle(557, 144, 13, LIME);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(586, 173, 13, RED);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(557, 203, 13, VIOLET);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) DrawCircle(527, 173, 13, PINK);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawRectangle(328, 170, 32, 13, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawTriangle((Vector2){ 436, 168 }, (Vector2){ 436, 185 }, (Vector2){ 464, 177 }, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_UP)) DrawCircle(557, 144, 13, LIME);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(586, 173, 13, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(557, 203, 13, VIOLET);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) DrawCircle(527, 173, 13, PINK);
// Draw buttons: d-pad
DrawRectangle(225, 132, 24, 84, BLACK);
DrawRectangle(195, 161, 84, 25, BLACK);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_UP)) DrawRectangle(225, 132, 24, 29, RED);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(225, 132 + 54, 24, 30, RED);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(195, 161, 30, 25, RED);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(195 + 54, 161, 30, 25, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_UP)) DrawRectangle(225, 132, 24, 29, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(225, 132 + 54, 24, 30, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(195, 161, 30, 25, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(195 + 54, 161, 30, 25, RED);
// Draw buttons: left-right back buttons
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawCircle(239, 82, 20, RED);
- if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(557, 82, 20, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawCircle(239, 82, 20, RED);
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(557, 82, 20, RED);
// Draw axis: left joystick
- DrawCircle(319, 255, 35, BLACK);
+ Color leftGamepadColor = BLACK;
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_THUMB)) leftGamepadColor = RED;
+ DrawCircle(319, 255, 35, leftGamepadColor);
DrawCircle(319, 255, 31, LIGHTGRAY);
- DrawCircle(319 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X) * 20),
- 255 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y) * 20), 25, BLACK);
+ DrawCircle(319 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_X) * 20),
+ 255 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_Y) * 20), 25, leftGamepadColor);
// Draw axis: right joystick
+ Color rightGamepadColor = BLACK;
+ if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_THUMB)) rightGamepadColor = RED;
DrawCircle(475, 255, 35, BLACK);
DrawCircle(475, 255, 31, LIGHTGRAY);
- DrawCircle(475 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X) * 20),
- 255 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y) * 20), 25, BLACK);
+ DrawCircle(475 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_X) * 20),
+ 255 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_Y) * 20), 25, rightGamepadColor);
// Draw axis: left-right triggers
DrawRectangle(169, 48, 15, 70, GRAY);
DrawRectangle(611, 48, 15, 70, GRAY);
- DrawRectangle(169, 48, 15, (int)(((1 - GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER)) / 2) * 70), RED);
- DrawRectangle(611, 48, 15, (int)(((1 - GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER)) / 2) * 70), RED);
+ DrawRectangle(169, 48, 15, (int)(((1 - GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_TRIGGER)) / 2) * 70), RED);
+ DrawRectangle(611, 48, 15, (int)(((1 - GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_TRIGGER)) / 2) * 70), RED);
}
else
{
@@ -174,12 +188,12 @@ int main(void)
DrawText(TextFormat("AXIS %i: %.02f", i, GetGamepadAxisMovement(0, i)), 20, 70 + 20*i, 10, DARKGRAY);
}
- if (GetGamepadButtonPressed() != -1) DrawText(TextFormat("DETECTED BUTTON: %i", GetGamepadButtonPressed()), 10, 430, 10, RED);
+ if (GetGamepadButtonPressed() != GAMEPAD_BUTTON_UNKNOWN) DrawText(TextFormat("DETECTED BUTTON: %i", GetGamepadButtonPressed()), 10, 430, 10, RED);
else DrawText("DETECTED BUTTON: NONE", 10, 430, 10, GRAY);
}
else
{
- DrawText("GP1: NOT DETECTED", 10, 10, 10, GRAY);
+ DrawText(TextFormat("GP%d: NOT DETECTED", gamepad), 10, 10, 10, GRAY);
DrawTexture(texXboxPad, 0, 0, LIGHTGRAY);
}
diff --git a/examples/core/core_input_gestures.c b/examples/core/core_input_gestures.c
index 012204ddd..312e78ffd 100644
--- a/examples/core/core_input_gestures.c
+++ b/examples/core/core_input_gestures.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2016-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2016-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_input_gestures_web.c b/examples/core/core_input_gestures_web.c
new file mode 100644
index 000000000..0129a983b
--- /dev/null
+++ b/examples/core/core_input_gestures_web.c
@@ -0,0 +1,338 @@
+/*******************************************************************************************
+*
+* raylib [core] example - Input Gestures for Web
+*
+* Example originally created with raylib 4.6-dev, last time updated with raylib 4.6-dev
+*
+* Example contributed by ubkp (@ubkp) and reviewed by Ramon Santamaria (@raysan5)
+*
+* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
+* BSD-like license that allows static linking with closed source software
+*
+* Copyright (c) 2023 ubkp (@ubkp)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#include "math.h" // Required for the protractor angle graphic drawing
+
+#if defined(PLATFORM_WEB)
+ #include // Required for the Web/HTML5
+#endif
+
+//--------------------------------------------------------------------------------------
+// Global definitions and declarations
+//--------------------------------------------------------------------------------------
+
+// Common variables definitions
+//--------------------------------------------------------------------------------------
+int screenWidth = 800; // Update depending on web canvas
+const int screenHeight = 450;
+Vector2 messagePosition = { 160, 7 };
+
+// Last gesture variables definitions
+//--------------------------------------------------------------------------------------
+int lastGesture = 0;
+Vector2 lastGesturePosition = { 165, 130 };
+
+// Gesture log variables definitions and functions declarations
+//--------------------------------------------------------------------------------------
+#define GESTURE_LOG_SIZE 20
+char gestureLog[GESTURE_LOG_SIZE][12] = { "" }; // The gesture log uses an array (as an inverted circular queue) to store the performed gestures
+int gestureLogIndex = GESTURE_LOG_SIZE; // The index for the inverted circular queue (moving from last to first direction, then looping around)
+int previousGesture = 0;
+
+char const *GetGestureName(int i)
+{
+ switch (i) {
+ case 0: return "None"; break;
+ case 1: return "Tap"; break;
+ case 2: return "Double Tap"; break;
+ case 4: return "Hold"; break;
+ case 8: return "Drag"; break;
+ case 16: return "Swipe Right"; break;
+ case 32: return "Swipe Left"; break;
+ case 64: return "Swipe Up"; break;
+ case 128: return "Swipe Down"; break;
+ case 256: return "Pinch In"; break;
+ case 512: return "Pinch Out"; break;
+ default: return "Unknown"; break;
+ }
+}
+
+Color GetGestureColor(int i)
+{
+ switch (i) {
+ case 0: return BLACK; break;
+ case 1: return BLUE; break;
+ case 2: return SKYBLUE; break;
+ case 4: return BLACK; break;
+ case 8: return LIME; break;
+ case 16: return RED; break;
+ case 32: return RED; break;
+ case 64: return RED; break;
+ case 128: return RED; break;
+ case 256: return VIOLET; break;
+ case 512: return ORANGE; break;
+ default: return BLACK; break;
+ }
+}
+
+int logMode = 1; // Log mode values: 0 shows repeated events; 1 hides repeated events; 2 shows repeated events but hide hold events; 3 hides repeated events and hide hold events
+
+Color gestureColor = { 0, 0, 0, 255 };
+Rectangle logButton1 = { 53, 7, 48, 26 };
+Rectangle logButton2 = { 108, 7, 36, 26 };
+Vector2 gestureLogPosition = { 10, 10 };
+
+// Protractor variables definitions
+//--------------------------------------------------------------------------------------
+float angleLength = 90.0f;
+float currentAngleDegrees = 0.0f;
+Vector2 finalVector = { 0.0f, 0.0f };
+char currentAngleStr[7] = "";
+Vector2 protractorPosition = { 266.0f, 315.0f };
+
+// Update
+//--------------------------------------------------------------------------------------
+void Update(void)
+{
+ // Handle common
+ //--------------------------------------------------------------------------------------
+ int i, ii; // Iterators that will be reused by all for loops
+ const int currentGesture = GetGestureDetected();
+ const float currentDragDegrees = GetGestureDragAngle();
+ const float currentPitchDegrees = GetGesturePinchAngle();
+ const int touchCount = GetTouchPointCount();
+
+ // Handle last gesture
+ //--------------------------------------------------------------------------------------
+ if ((currentGesture != 0) && (currentGesture != 4) && (currentGesture != previousGesture)) lastGesture = currentGesture; // Filter the meaningful gestures (1, 2, 8 to 512) for the display
+
+ // Handle gesture log
+ //--------------------------------------------------------------------------------------
+ if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
+ {
+ if (CheckCollisionPointRec(GetMousePosition(), logButton1))
+ {
+ switch (logMode)
+ {
+ case 3: logMode=2; break;
+ case 2: logMode=3; break;
+ case 1: logMode=0; break;
+ default: logMode=1; break;
+ }
+ }
+ else if (CheckCollisionPointRec(GetMousePosition(), logButton2))
+ {
+ switch (logMode)
+ {
+ case 3: logMode=1; break;
+ case 2: logMode=0; break;
+ case 1: logMode=3; break;
+ default: logMode=2; break;
+ }
+ }
+ }
+
+ int fillLog = 0; // Gate variable to be used to allow or not the gesture log to be filled
+ if (currentGesture !=0)
+ {
+ if (logMode == 3) // 3 hides repeated events and hide hold events
+ {
+ if (((currentGesture != 4) && (currentGesture != previousGesture)) || (currentGesture < 3)) fillLog = 1;
+ }
+ else if (logMode == 2) // 2 shows repeated events but hide hold events
+ {
+ if (currentGesture != 4) fillLog = 1;
+ }
+ else if (logMode == 1) // 1 hides repeated events
+ {
+ if (currentGesture != previousGesture) fillLog = 1;
+ }
+ else // 0 shows repeated events
+ {
+ fillLog = 1;
+ }
+ }
+
+ if (fillLog) // If one of the conditions from logMode was met, fill the gesture log
+ {
+ previousGesture = currentGesture;
+ gestureColor = GetGestureColor(currentGesture);
+ if (gestureLogIndex <= 0) gestureLogIndex = GESTURE_LOG_SIZE;
+ gestureLogIndex--;
+
+ // Copy the gesture respective name to the gesture log array
+ TextCopy(gestureLog[gestureLogIndex], GetGestureName(currentGesture));
+ }
+
+ // Handle protractor
+ //--------------------------------------------------------------------------------------
+ if (currentGesture > 255) // aka Pinch In and Pinch Out
+ {
+ currentAngleDegrees = currentPitchDegrees;
+ }
+ else if (currentGesture > 15) // aka Swipe Right, Swipe Left, Swipe Up and Swipe Down
+ {
+ currentAngleDegrees = currentDragDegrees;
+ }
+ else if (currentGesture > 0) // aka Tap, Doubletap, Hold and Grab
+ {
+ currentAngleDegrees = 0.0f;
+ }
+
+ float currentAngleRadians = ((currentAngleDegrees +90.0f)*PI/180); // Convert the current angle to Radians
+ finalVector = (Vector2){ (angleLength*sinf(currentAngleRadians)) + protractorPosition.x, (angleLength*cosf(currentAngleRadians)) + protractorPosition.y }; // Calculate the final vector for display
+
+ // Handle touch and mouse pointer points
+ //--------------------------------------------------------------------------------------
+ #define MAX_TOUCH_COUNT 32
+
+ Vector2 touchPosition[MAX_TOUCH_COUNT] = { 0 };
+ Vector2 mousePosition = {0, 0};
+ if (currentGesture != GESTURE_NONE)
+ {
+ if (touchCount != 0)
+ {
+ for (i = 0; i < touchCount; i++) touchPosition[i] = GetTouchPosition(i); // Fill the touch positions
+ }
+ else mousePosition = GetMousePosition();
+ }
+
+ // Draw
+ //--------------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ // Draw common
+ //--------------------------------------------------------------------------------------
+ DrawText("*", messagePosition.x + 5, messagePosition.y + 5, 10, BLACK);
+ DrawText("Example optimized for Web/HTML5\non Smartphones with Touch Screen.", messagePosition.x + 15, messagePosition.y + 5, 10, BLACK);
+ DrawText("*", messagePosition.x + 5, messagePosition.y + 35, 10, BLACK);
+ DrawText("While running on Desktop Web Browsers,\ninspect and turn on Touch Emulation.", messagePosition.x + 15, messagePosition.y + 35, 10, BLACK);
+
+ // Draw last gesture
+ //--------------------------------------------------------------------------------------
+ DrawText("Last gesture", lastGesturePosition.x + 33, lastGesturePosition.y - 47, 20, BLACK);
+ DrawText("Swipe Tap Pinch Touch", lastGesturePosition.x + 17, lastGesturePosition.y - 18, 10, BLACK);
+ DrawRectangle(lastGesturePosition.x + 20, lastGesturePosition.y, 20, 20, lastGesture == GESTURE_SWIPE_UP ? RED : LIGHTGRAY);
+ DrawRectangle(lastGesturePosition.x, lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_LEFT ? RED : LIGHTGRAY);
+ DrawRectangle(lastGesturePosition.x + 40, lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_RIGHT ? RED : LIGHTGRAY);
+ DrawRectangle(lastGesturePosition.x + 20, lastGesturePosition.y + 40, 20, 20, lastGesture == GESTURE_SWIPE_DOWN ? RED : LIGHTGRAY);
+ DrawCircle(lastGesturePosition.x + 80, lastGesturePosition.y + 16, 10, lastGesture == GESTURE_TAP ? BLUE : LIGHTGRAY);
+ DrawRing( (Vector2){lastGesturePosition.x + 103, lastGesturePosition.y + 16}, 6.0f, 11.0f, 0.0f, 360.0f, 0, lastGesture == GESTURE_DRAG ? LIME : LIGHTGRAY);
+ DrawCircle(lastGesturePosition.x + 80, lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
+ DrawCircle(lastGesturePosition.x + 103, lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
+ DrawTriangle((Vector2){ lastGesturePosition.x + 122, lastGesturePosition.y + 16 }, (Vector2){ lastGesturePosition.x + 137, lastGesturePosition.y + 26 }, (Vector2){ lastGesturePosition.x + 137, lastGesturePosition.y + 6 }, lastGesture == GESTURE_PINCH_OUT? ORANGE : LIGHTGRAY);
+ DrawTriangle((Vector2){ lastGesturePosition.x + 147, lastGesturePosition.y + 6 }, (Vector2){ lastGesturePosition.x + 147, lastGesturePosition.y + 26 }, (Vector2){ lastGesturePosition.x + 162, lastGesturePosition.y + 16 }, lastGesture == GESTURE_PINCH_OUT? ORANGE : LIGHTGRAY);
+ DrawTriangle((Vector2){ lastGesturePosition.x + 125, lastGesturePosition.y + 33 }, (Vector2){ lastGesturePosition.x + 125, lastGesturePosition.y + 53 }, (Vector2){ lastGesturePosition.x + 140, lastGesturePosition.y + 43 }, lastGesture == GESTURE_PINCH_IN? VIOLET : LIGHTGRAY);
+ DrawTriangle((Vector2){ lastGesturePosition.x + 144, lastGesturePosition.y + 43 }, (Vector2){ lastGesturePosition.x + 159, lastGesturePosition.y + 53 }, (Vector2){ lastGesturePosition.x + 159, lastGesturePosition.y + 33 }, lastGesture == GESTURE_PINCH_IN? VIOLET : LIGHTGRAY);
+ for (i = 0; i < 4; i++) DrawCircle(lastGesturePosition.x + 180, lastGesturePosition.y + 7 + i*15, 5, touchCount <= i? LIGHTGRAY : gestureColor);
+
+ // Draw gesture log
+ //--------------------------------------------------------------------------------------
+ DrawText("Log", gestureLogPosition.x, gestureLogPosition.y, 20, BLACK);
+
+ // Loop in both directions to print the gesture log array in the inverted order (and looping around if the index started somewhere in the middle)
+ for (i = 0, ii = gestureLogIndex; i < GESTURE_LOG_SIZE; i++, ii = (ii + 1) % GESTURE_LOG_SIZE) DrawText(gestureLog[ii], gestureLogPosition.x, gestureLogPosition.y + 410 - i*20, 20, (i == 0 ? gestureColor : LIGHTGRAY));
+ Color logButton1Color, logButton2Color;
+ switch (logMode)
+ {
+ case 3: logButton1Color=MAROON; logButton2Color=MAROON; break;
+ case 2: logButton1Color=GRAY; logButton2Color=MAROON; break;
+ case 1: logButton1Color=MAROON; logButton2Color=GRAY; break;
+ default: logButton1Color=GRAY; logButton2Color=GRAY; break;
+ }
+ DrawRectangleRec(logButton1, logButton1Color);
+ DrawText("Hide", logButton1.x + 7, logButton1.y + 3, 10, WHITE);
+ DrawText("Repeat", logButton1.x + 7, logButton1.y + 13, 10, WHITE);
+ DrawRectangleRec(logButton2, logButton2Color);
+ DrawText("Hide", logButton1.x + 62, logButton1.y + 3, 10, WHITE);
+ DrawText("Hold", logButton1.x + 62, logButton1.y + 13, 10, WHITE);
+
+ // Draw protractor
+ //--------------------------------------------------------------------------------------
+ DrawText("Angle", protractorPosition.x + 55, protractorPosition.y + 76, 10, BLACK);
+ const char *angleString = TextFormat("%f", currentAngleDegrees);
+ const int angleStringDot = TextFindIndex(angleString, ".");
+ const char *angleStringTrim = TextSubtext(angleString, 0, angleStringDot + 3);
+ DrawText( angleStringTrim, protractorPosition.x + 55, protractorPosition.y + 92, 20, gestureColor);
+ DrawCircle(protractorPosition.x, protractorPosition.y, 80.0f, WHITE);
+ DrawLineEx((Vector2){ protractorPosition.x - 90, protractorPosition.y }, (Vector2){ protractorPosition.x + 90, protractorPosition.y }, 3.0f, LIGHTGRAY);
+ DrawLineEx((Vector2){ protractorPosition.x, protractorPosition.y - 90 }, (Vector2){ protractorPosition.x, protractorPosition.y + 90 }, 3.0f, LIGHTGRAY);
+ DrawLineEx((Vector2){ protractorPosition.x - 80, protractorPosition.y - 45 }, (Vector2){ protractorPosition.x + 80, protractorPosition.y + 45 }, 3.0f, GREEN);
+ DrawLineEx((Vector2){ protractorPosition.x - 80, protractorPosition.y + 45 }, (Vector2){ protractorPosition.x + 80, protractorPosition.y - 45 }, 3.0f, GREEN);
+ DrawText("0", protractorPosition.x + 96, protractorPosition.y - 9, 20, BLACK);
+ DrawText("30", protractorPosition.x + 74, protractorPosition.y - 68, 20, BLACK);
+ DrawText("90", protractorPosition.x - 11, protractorPosition.y - 110, 20, BLACK);
+ DrawText("150", protractorPosition.x - 100, protractorPosition.y - 68, 20, BLACK);
+ DrawText("180", protractorPosition.x - 124, protractorPosition.y - 9, 20, BLACK);
+ DrawText("210", protractorPosition.x - 100, protractorPosition.y + 50, 20, BLACK);
+ DrawText("270", protractorPosition.x - 18, protractorPosition.y + 92, 20, BLACK);
+ DrawText("330", protractorPosition.x + 72, protractorPosition.y + 50, 20, BLACK);
+ if (currentAngleDegrees != 0.0f) DrawLineEx(protractorPosition, finalVector, 3.0f, gestureColor);
+
+ // Draw touch and mouse pointer points
+ //--------------------------------------------------------------------------------------
+ if (currentGesture != GESTURE_NONE)
+ {
+ if ( touchCount != 0 )
+ {
+ for (i = 0; i < touchCount; i++)
+ {
+ DrawCircleV(touchPosition[i], 50.0f, Fade(gestureColor, 0.5f));
+ DrawCircleV(touchPosition[i], 5.0f, gestureColor);
+ }
+
+ if (touchCount == 2) DrawLineEx(touchPosition[0], touchPosition[1], ((currentGesture == 512)? 8 : 12), gestureColor);
+ }
+ else
+ {
+ DrawCircleV(mousePosition, 35.0f, Fade(gestureColor, 0.5f));
+ DrawCircleV(mousePosition, 5.0f, gestureColor);
+ }
+ }
+
+ EndDrawing();
+ //--------------------------------------------------------------------------------------
+
+}
+
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
+int main(void)
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ #if defined( PLATFORM_WEB )
+ // Using Emscripten EM_ASM_INT macro, get the page canvas width
+ const int canvasWidth = EM_ASM_INT( return document.getElementById('canvas').getBoundingClientRect().width; );
+
+ if (canvasWidth > 400) screenWidth = canvasWidth;
+ else screenWidth = 400; // Set a minimum width for the screen
+ #endif
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures web");
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ //--------------------------------------------------------------------------------------
+ #if defined(PLATFORM_WEB)
+ emscripten_set_main_loop(Update, 0, 1);
+ #else
+ SetTargetFPS(60);
+ while (!WindowShouldClose()) Update(); // Detect window close button or ESC key
+ #endif
+ //--------------------------------------------------------------------------------------
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}
diff --git a/examples/core/core_input_gestures_web.png b/examples/core/core_input_gestures_web.png
new file mode 100644
index 000000000..dd604e84b
Binary files /dev/null and b/examples/core/core_input_gestures_web.png differ
diff --git a/examples/core/core_input_keys.c b/examples/core/core_input_keys.c
index 6020d577f..ccff24005 100644
--- a/examples/core/core_input_keys.c
+++ b/examples/core/core_input_keys.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_input_mouse.c b/examples/core/core_input_mouse.c
index 6e164f50b..874e16c30 100644
--- a/examples/core/core_input_mouse.c
+++ b/examples/core/core_input_mouse.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_input_mouse_wheel.c b/examples/core/core_input_mouse_wheel.c
index 1f384cd0c..826bad3a1 100644
--- a/examples/core/core_input_mouse_wheel.c
+++ b/examples/core/core_input_mouse_wheel.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_input_multitouch.c b/examples/core/core_input_multitouch.c
index 1eb6905b5..37817e5a0 100644
--- a/examples/core/core_input_multitouch.c
+++ b/examples/core/core_input_multitouch.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Berni (@Berni8k) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Berni (@Berni8k) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -39,8 +39,12 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- // Get multiple touchpoints
- for (int i = 0; i < MAX_TOUCH_POINTS; ++i) touchPositions[i] = GetTouchPosition(i);
+ // Get the touch point count ( how many fingers are touching the screen )
+ int tCount = GetTouchPointCount();
+ // Clamp touch points available ( set the maximum touch points allowed )
+ if(tCount > MAX_TOUCH_POINTS) tCount = MAX_TOUCH_POINTS;
+ // Get touch points positions
+ for (int i = 0; i < tCount; ++i) touchPositions[i] = GetTouchPosition(i);
//----------------------------------------------------------------------------------
// Draw
@@ -49,7 +53,7 @@ int main(void)
ClearBackground(RAYWHITE);
- for (int i = 0; i < MAX_TOUCH_POINTS; ++i)
+ for (int i = 0; i < tCount; ++i)
{
// Make sure point is not (0, 0) as this means there is no touch for it
if ((touchPositions[i].x > 0) && (touchPositions[i].y > 0))
@@ -72,4 +76,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
-}
\ No newline at end of file
+}
diff --git a/examples/core/core_loading_thread.c b/examples/core/core_loading_thread.c
index 09ec76460..0538dcee3 100644
--- a/examples/core/core_loading_thread.c
+++ b/examples/core/core_loading_thread.c
@@ -9,12 +9,13 @@
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
+// WARNING: This example does not build on Windows with MSVC compiler
#include "pthread.h" // POSIX style threads management
#include // C11 atomic data types
@@ -23,10 +24,10 @@
// Using C11 atomics for synchronization
// NOTE: A plain bool (or any plain data type for that matter) can't be used for inter-thread synchronization
-static atomic_bool dataLoaded = ATOMIC_VAR_INIT(false); // Data Loaded completion indicator
+static atomic_bool dataLoaded = false; // Data Loaded completion indicator
static void *LoadDataThread(void *arg); // Loading data thread function declaration
-static int dataProgress = 0; // Data progress accumulator
+static atomic_int dataProgress = 0; // Data progress accumulator
//------------------------------------------------------------------------------------
// Program main entry point
@@ -69,9 +70,13 @@ int main(void)
case STATE_LOADING:
{
framesCounter++;
- if (atomic_load(&dataLoaded))
+ if (atomic_load_explicit(&dataLoaded, memory_order_relaxed))
{
framesCounter = 0;
+ int error = pthread_join(threadId, NULL);
+ if (error != 0) TraceLog(LOG_ERROR, "Error joining loading thread");
+ else TraceLog(LOG_INFO, "Loading thread terminated successfully");
+
state = STATE_FINISHED;
}
} break;
@@ -80,8 +85,8 @@ int main(void)
if (IsKeyPressed(KEY_ENTER))
{
// Reset everything to launch again
- atomic_store(&dataLoaded, false);
- dataProgress = 0;
+ atomic_store_explicit(&dataLoaded, false, memory_order_relaxed);
+ atomic_store_explicit(&dataProgress, 0, memory_order_relaxed);
state = STATE_WAITING;
}
} break;
@@ -100,7 +105,7 @@ int main(void)
case STATE_WAITING: DrawText("PRESS ENTER to START LOADING DATA", 150, 170, 20, DARKGRAY); break;
case STATE_LOADING:
{
- DrawRectangle(150, 200, dataProgress, 60, SKYBLUE);
+ DrawRectangle(150, 200, atomic_load_explicit(&dataProgress, memory_order_relaxed), 60, SKYBLUE);
if ((framesCounter/15)%2) DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE);
} break;
@@ -141,11 +146,11 @@ static void *LoadDataThread(void *arg)
// We accumulate time over a global variable to be used in
// main thread as a progress bar
- dataProgress = timeCounter/10;
+ atomic_store_explicit(&dataProgress, timeCounter/10, memory_order_relaxed);
}
// When data has finished loading, we set global variable
- atomic_store(&dataLoaded, true);
+ atomic_store_explicit(&dataLoaded, true, memory_order_relaxed);
return NULL;
}
diff --git a/examples/core/core_random_values.c b/examples/core/core_random_values.c
index 9150b9f45..c2225bcaf 100644
--- a/examples/core/core_random_values.c
+++ b/examples/core/core_random_values.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_scissor_test.c b/examples/core/core_scissor_test.c
index f296a3acb..c2b853c05 100644
--- a/examples/core/core_scissor_test.c
+++ b/examples/core/core_scissor_test.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Chris Dill (@MysteriousSpace)
+* Copyright (c) 2019-2023 Chris Dill (@MysteriousSpace)
*
********************************************************************************************/
diff --git a/examples/core/core_smooth_pixelperfect.c b/examples/core/core_smooth_pixelperfect.c
index 36fb09c58..776706c00 100644
--- a/examples/core/core_smooth_pixelperfect.c
+++ b/examples/core/core_smooth_pixelperfect.c
@@ -10,7 +10,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2021-2022 Giancamillo Alessandroni (@NotManyIdeasDev) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2021-2023 Giancamillo Alessandroni (@NotManyIdeasDev) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_split_screen.c b/examples/core/core_split_screen.c
index 21bd9615a..50cfcf7ac 100644
--- a/examples/core/core_split_screen.c
+++ b/examples/core/core_split_screen.c
@@ -9,13 +9,12 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2021-2022 Jeffery Myers (@JeffM2501)
+* Copyright (c) 2021-2023 Jeffery Myers (@JeffM2501)
*
********************************************************************************************/
#include "raylib.h"
-Texture2D textureGrid = { 0 };
Camera cameraPlayer1 = { 0 };
Camera cameraPlayer2 = { 0 };
@@ -32,8 +31,8 @@ void DrawScene(void)
{
for (float z = -count*spacing; z <= count*spacing; z += spacing)
{
- DrawCubeTexture(textureGrid, (Vector3) { x, 1.5f, z }, 1, 1, 1, GREEN);
- DrawCubeTexture(textureGrid, (Vector3) { x, 0.5f, z }, 0.25f, 1, 0.25f, BROWN);
+ DrawCube((Vector3) { x, 1.5f, z }, 1, 1, 1, LIME);
+ DrawCube((Vector3) { x, 0.5f, z }, 0.25f, 1, 0.25f, BROWN);
}
}
@@ -54,13 +53,6 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [core] example - split screen");
- // Generate a simple texture to use for trees
- Image img = GenImageChecked(256, 256, 32, 32, DARKGRAY, WHITE);
- textureGrid = LoadTextureFromImage(img);
- UnloadImage(img);
- SetTextureFilter(textureGrid, TEXTURE_FILTER_ANISOTROPIC_16X);
- SetTextureWrap(textureGrid, TEXTURE_WRAP_CLAMP);
-
// Setup player 1 camera and screen
cameraPlayer1.fovy = 45.0f;
cameraPlayer1.up.y = 1.0f;
@@ -151,7 +143,6 @@ int main(void)
//--------------------------------------------------------------------------------------
UnloadRenderTexture(screenPlayer1); // Unload render texture
UnloadRenderTexture(screenPlayer2); // Unload render texture
- UnloadTexture(textureGrid); // Unload texture
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
diff --git a/examples/core/core_storage_values.c b/examples/core/core_storage_values.c
index c6f01217b..127399123 100644
--- a/examples/core/core_storage_values.c
+++ b/examples/core/core_storage_values.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_vr_simulator.c b/examples/core/core_vr_simulator.c
index f5dc4d55d..bc69cc698 100644
--- a/examples/core/core_vr_simulator.c
+++ b/examples/core/core_vr_simulator.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2017-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2017-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -95,11 +95,11 @@ int main(void)
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector
camera.fovy = 60.0f; // Camera field-of-view Y
- camera.projection = CAMERA_PERSPECTIVE; // Camera type
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
- SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set first person camera mode
+ DisableCursor(); // Limit cursor to relative movement inside the window
SetTargetFPS(90); // Set our game to run at 90 frames-per-second
//--------------------------------------------------------------------------------------
@@ -109,7 +109,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_FIRST_PERSON);
//----------------------------------------------------------------------------------
// Draw
diff --git a/examples/core/core_window_flags.c b/examples/core/core_window_flags.c
index 27a6e7b65..b1cbb1b64 100644
--- a/examples/core/core_window_flags.c
+++ b/examples/core/core_window_flags.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2020-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2020-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_window_letterbox.c b/examples/core/core_window_letterbox.c
index 774e8d99f..751fb14ab 100644
--- a/examples/core/core_window_letterbox.c
+++ b/examples/core/core_window_letterbox.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Anata (@anatagawa) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Anata (@anatagawa) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_window_should_close.c b/examples/core/core_window_should_close.c
index fa6b9b97b..f0392b013 100644
--- a/examples/core/core_window_should_close.c
+++ b/examples/core/core_window_should_close.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/core/core_world_screen.c b/examples/core/core_world_screen.c
index 80d9cf918..6c811a509 100644
--- a/examples/core/core_world_screen.c
+++ b/examples/core/core_world_screen.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -23,20 +23,20 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
- InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - core world screen");
// Define the camera to look into our 3d world
Camera camera = { 0 };
- camera.position = (Vector3){ 10.0f, 10.0f, 10.0f };
- camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
- camera.fovy = 45.0f;
- camera.projection = CAMERA_PERSPECTIVE;
+ camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
Vector2 cubeScreenPosition = { 0.0f, 0.0f };
- SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
+ DisableCursor(); // Limit cursor to relative movement inside the window
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -46,7 +46,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_THIRD_PERSON);
// Calculate cube screen space position (with a little offset to be in top)
cubeScreenPosition = GetWorldToScreen((Vector3){cubePosition.x, cubePosition.y + 2.5f, cubePosition.z}, camera);
@@ -68,7 +68,9 @@ int main(void)
EndMode3D();
DrawText("Enemy: 100 / 100", (int)cubeScreenPosition.x - MeasureText("Enemy: 100/100", 20)/2, (int)cubeScreenPosition.y, 20, BLACK);
- DrawText("Text is always on top of the cube", (screenWidth - MeasureText("Text is always on top of the cube", 20))/2, 25, 20, GRAY);
+
+ DrawText(TextFormat("Cube position in screen space coordinates: [%i, %i]", (int)cubeScreenPosition.x, (int)cubeScreenPosition.y), 10, 10, 20, LIME);
+ DrawText("Text 2d should be always on top of the cube", 10, 40, 20, GRAY);
EndDrawing();
//----------------------------------------------------------------------------------
diff --git a/examples/examples_template.c b/examples/examples_template.c
index 1ea615d4a..2b962d319 100644
--- a/examples/examples_template.c
+++ b/examples/examples_template.c
@@ -41,14 +41,14 @@
*
* raylib [core] example - Basic window
*
-* Example originally created with raylib 4.2, last time updated with raylib 4.2
+* Example originally created with raylib 4.5, last time updated with raylib 4.5
*
* Example contributed by (@) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2022 (@)
+* Copyright (c) 2023 (@)
*
********************************************************************************************/
diff --git a/examples/models/models_animation.c b/examples/models/models_animation.c
index 161b21995..ffe2d0124 100644
--- a/examples/models/models_animation.c
+++ b/examples/models/models_animation.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Culacant (@culacant) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Culacant (@culacant) and Ramon Santamaria (@raysan5)
*
********************************************************************************************
*
@@ -21,8 +21,6 @@
#include "raylib.h"
-#include
-
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
@@ -54,8 +52,7 @@ int main(void)
ModelAnimation *anims = LoadModelAnimations("resources/models/iqm/guyanim.iqm", &animsCount);
int animFrameCounter = 0;
- SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
-
+ DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -64,7 +61,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_FIRST_PERSON);
// Play animation when spacebar is held down
if (IsKeyDown(KEY_SPACE))
@@ -103,15 +100,11 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
- UnloadTexture(texture); // Unload texture
+ UnloadTexture(texture); // Unload texture
+ UnloadModelAnimations(anims, animsCount); // Unload model animations data
+ UnloadModel(model); // Unload model
- // Unload model animations data
- for (unsigned int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
- RL_FREE(anims);
-
- UnloadModel(model); // Unload model
-
- CloseWindow(); // Close window and OpenGL context
+ CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
diff --git a/examples/models/models_billboard.c b/examples/models/models_billboard.c
index 68a24e6a7..9b02a8af1 100644
--- a/examples/models/models_billboard.c
+++ b/examples/models/models_billboard.c
@@ -7,11 +7,12 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
+#include "raymath.h"
//------------------------------------------------------------------------------------
// Program main entry point
@@ -27,26 +28,46 @@ int main(void)
// Define the camera to look into our 3d world
Camera camera = { 0 };
- camera.position = (Vector3){ 5.0f, 4.0f, 5.0f };
- camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
- camera.fovy = 45.0f;
- camera.projection = CAMERA_PERSPECTIVE;
+ camera.position = (Vector3){ 5.0f, 4.0f, 5.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
- Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard
- Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard
+ Texture2D bill = LoadTexture("resources/billboard.png"); // Our billboard texture
+ Vector3 billPositionStatic = { 0.0f, 2.0f, 0.0f }; // Position of static billboard
+ Vector3 billPositionRotating = { 1.0f, 2.0f, 1.0f }; // Position of rotating billboard
- SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
+ // Entire billboard texture, source is used to take a segment from a larger texture.
+ Rectangle source = { 0.0f, 0.0f, (float)bill.width, (float)bill.height };
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ // NOTE: Billboard locked on axis-Y
+ Vector3 billUp = { 0.0f, 1.0f, 0.0f };
+
+ // Rotate around origin
+ // Here we choose to rotate around the image center
+ // NOTE: (-1, 1) is the range where origin.x, origin.y is inside the texture
+ Vector2 rotateOrigin = { 0.0f };
+
+ // Distance is needed for the correct billboard draw order
+ // Larger distance (further away from the camera) should be drawn prior to smaller distance.
+ float distanceStatic;
+ float distanceRotating;
+ float rotation = 0.0f;
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_ORBITAL);
+
+ rotation += 0.4f;
+ distanceStatic = Vector3Distance(camera.position, billPositionStatic);
+ distanceRotating = Vector3Distance(camera.position, billPositionRotating);
//----------------------------------------------------------------------------------
// Draw
@@ -59,8 +80,18 @@ int main(void)
DrawGrid(10, 1.0f); // Draw a grid
- DrawBillboard(camera, bill, billPosition, 2.0f, WHITE);
-
+ // Draw order matters!
+ if (distanceStatic > distanceRotating)
+ {
+ DrawBillboard(camera, bill, billPositionStatic, 2.0f, WHITE);
+ DrawBillboardPro(camera, bill, source, billPositionRotating, billUp, (Vector2) {1.0f, 1.0f}, rotateOrigin, rotation, WHITE);
+ }
+ else
+ {
+ DrawBillboardPro(camera, bill, source, billPositionRotating, billUp, (Vector2) {1.0f, 1.0f}, rotateOrigin, rotation, WHITE);
+ DrawBillboard(camera, bill, billPositionStatic, 2.0f, WHITE);
+ }
+
EndMode3D();
DrawFPS(10, 10);
diff --git a/examples/models/models_box_collisions.c b/examples/models/models_box_collisions.c
index db8eb1f2d..9cff5e058 100644
--- a/examples/models/models_box_collisions.c
+++ b/examples/models/models_box_collisions.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/models/models_cubicmap.c b/examples/models/models_cubicmap.c
index e9da0482f..e0a2b3089 100644
--- a/examples/models/models_cubicmap.c
+++ b/examples/models/models_cubicmap.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -26,7 +26,12 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
// Define the camera to look into our 3d world
- Camera camera = { { 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
+ Camera camera = { 0 };
+ camera.position = (Vector3){ 16.0f, 14.0f, 16.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM)
@@ -36,23 +41,21 @@ int main(void)
// NOTE: By default each cube is mapped to one part of texture atlas
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture
- model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
+ model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM
- SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
-
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_ORBITAL);
//----------------------------------------------------------------------------------
// Draw
diff --git a/examples/models/models_draw_cube_texture.c b/examples/models/models_draw_cube_texture.c
new file mode 100644
index 000000000..e43c3c844
--- /dev/null
+++ b/examples/models/models_draw_cube_texture.c
@@ -0,0 +1,245 @@
+/*******************************************************************************************
+*
+* raylib [models] example - Draw textured cube
+*
+* Example originally created with raylib 4.5, last time updated with raylib 4.5
+*
+* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
+* BSD-like license that allows static linking with closed source software
+*
+* Copyright (c) 2022-2023 Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#include "rlgl.h" // Required to define vertex data (immediate-mode style)
+
+//------------------------------------------------------------------------------------
+// Custom Functions Declaration
+//------------------------------------------------------------------------------------
+void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured
+void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color); // Draw cube with a region of a texture
+
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
+int main(void)
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [models] example - draw cube texture");
+
+ // Define the camera to look into our 3d world
+ Camera camera = { 0 };
+ camera.position = (Vector3){ 0.0f, 10.0f, 10.0f };
+ camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
+ camera.fovy = 45.0f;
+ camera.projection = CAMERA_PERSPECTIVE;
+
+ // Load texture to be applied to the cubes sides
+ Texture2D texture = LoadTexture("resources/cubicmap_atlas.png");
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ // TODO: Update your variables here
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ BeginMode3D(camera);
+
+ // Draw cube with an applied texture
+ DrawCubeTexture(texture, (Vector3){ -2.0f, 2.0f, 0.0f }, 2.0f, 4.0f, 2.0f, WHITE);
+
+ // Draw cube with an applied texture, but only a defined rectangle piece of the texture
+ DrawCubeTextureRec(texture, (Rectangle){ 0, texture.height/2, texture.width/2, texture.height/2 },
+ (Vector3){ 2.0f, 1.0f, 0.0f }, 2.0f, 2.0f, 2.0f, WHITE);
+
+ DrawGrid(10, 1.0f); // Draw a grid
+
+ EndMode3D();
+
+ DrawFPS(10, 10);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadTexture(texture); // Unload texture
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------------
+// Custom Functions Definition
+//------------------------------------------------------------------------------------
+// Draw cube textured
+// NOTE: Cube position is the center position
+void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color)
+{
+ float x = position.x;
+ float y = position.y;
+ float z = position.z;
+
+ // Set desired texture to be enabled while drawing following vertex data
+ rlSetTexture(texture.id);
+
+ // Vertex data transformation can be defined with the commented lines,
+ // but in this example we calculate the transformed vertex data directly when calling rlVertex3f()
+ //rlPushMatrix();
+ // NOTE: Transformation is applied in inverse order (scale -> rotate -> translate)
+ //rlTranslatef(2.0f, 0.0f, 0.0f);
+ //rlRotatef(45, 0, 1, 0);
+ //rlScalef(2.0f, 2.0f, 2.0f);
+
+ rlBegin(RL_QUADS);
+ rlColor4ub(color.r, color.g, color.b, color.a);
+ // Front Face
+ rlNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
+ rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
+ rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom Right Of The Texture and Quad
+ rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z + length/2); // Top Right Of The Texture and Quad
+ rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z + length/2); // Top Left Of The Texture and Quad
+ // Back Face
+ rlNormal3f(0.0f, 0.0f, - 1.0f); // Normal Pointing Away From Viewer
+ rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z - length/2); // Bottom Right Of The Texture and Quad
+ rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z - length/2); // Top Right Of The Texture and Quad
+ rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z - length/2); // Top Left Of The Texture and Quad
+ rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z - length/2); // Bottom Left Of The Texture and Quad
+ // Top Face
+ rlNormal3f(0.0f, 1.0f, 0.0f); // Normal Pointing Up
+ rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z - length/2); // Top Left Of The Texture and Quad
+ rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y + height/2, z + length/2); // Bottom Left Of The Texture and Quad
+ rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x + width/2, y + height/2, z + length/2); // Bottom Right Of The Texture and Quad
+ rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z - length/2); // Top Right Of The Texture and Quad
+ // Bottom Face
+ rlNormal3f(0.0f, - 1.0f, 0.0f); // Normal Pointing Down
+ rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x - width/2, y - height/2, z - length/2); // Top Right Of The Texture and Quad
+ rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x + width/2, y - height/2, z - length/2); // Top Left Of The Texture and Quad
+ rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
+ rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Right Of The Texture and Quad
+ // Right face
+ rlNormal3f(1.0f, 0.0f, 0.0f); // Normal Pointing Right
+ rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z - length/2); // Bottom Right Of The Texture and Quad
+ rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z - length/2); // Top Right Of The Texture and Quad
+ rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z + length/2); // Top Left Of The Texture and Quad
+ rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
+ // Left Face
+ rlNormal3f( - 1.0f, 0.0f, 0.0f); // Normal Pointing Left
+ rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z - length/2); // Bottom Left Of The Texture and Quad
+ rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Right Of The Texture and Quad
+ rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z + length/2); // Top Right Of The Texture and Quad
+ rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z - length/2); // Top Left Of The Texture and Quad
+ rlEnd();
+ //rlPopMatrix();
+
+ rlSetTexture(0);
+}
+
+// Draw cube with texture piece applied to all faces
+void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color)
+{
+ float x = position.x;
+ float y = position.y;
+ float z = position.z;
+ float texWidth = (float)texture.width;
+ float texHeight = (float)texture.height;
+
+ // Set desired texture to be enabled while drawing following vertex data
+ rlSetTexture(texture.id);
+
+ // We calculate the normalized texture coordinates for the desired texture-source-rectangle
+ // It means converting from (tex.width, tex.height) coordinates to [0.0f, 1.0f] equivalent
+ rlBegin(RL_QUADS);
+ rlColor4ub(color.r, color.g, color.b, color.a);
+
+ // Front face
+ rlNormal3f(0.0f, 0.0f, 1.0f);
+ rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x - width/2, y - height/2, z + length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x + width/2, y - height/2, z + length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
+ rlVertex3f(x + width/2, y + height/2, z + length/2);
+ rlTexCoord2f(source.x/texWidth, source.y/texHeight);
+ rlVertex3f(x - width/2, y + height/2, z + length/2);
+
+ // Back face
+ rlNormal3f(0.0f, 0.0f, - 1.0f);
+ rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x - width/2, y - height/2, z - length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
+ rlVertex3f(x - width/2, y + height/2, z - length/2);
+ rlTexCoord2f(source.x/texWidth, source.y/texHeight);
+ rlVertex3f(x + width/2, y + height/2, z - length/2);
+ rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x + width/2, y - height/2, z - length/2);
+
+ // Top face
+ rlNormal3f(0.0f, 1.0f, 0.0f);
+ rlTexCoord2f(source.x/texWidth, source.y/texHeight);
+ rlVertex3f(x - width/2, y + height/2, z - length/2);
+ rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x - width/2, y + height/2, z + length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x + width/2, y + height/2, z + length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
+ rlVertex3f(x + width/2, y + height/2, z - length/2);
+
+ // Bottom face
+ rlNormal3f(0.0f, - 1.0f, 0.0f);
+ rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
+ rlVertex3f(x - width/2, y - height/2, z - length/2);
+ rlTexCoord2f(source.x/texWidth, source.y/texHeight);
+ rlVertex3f(x + width/2, y - height/2, z - length/2);
+ rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x + width/2, y - height/2, z + length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x - width/2, y - height/2, z + length/2);
+
+ // Right face
+ rlNormal3f(1.0f, 0.0f, 0.0f);
+ rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x + width/2, y - height/2, z - length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
+ rlVertex3f(x + width/2, y + height/2, z - length/2);
+ rlTexCoord2f(source.x/texWidth, source.y/texHeight);
+ rlVertex3f(x + width/2, y + height/2, z + length/2);
+ rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x + width/2, y - height/2, z + length/2);
+
+ // Left face
+ rlNormal3f( - 1.0f, 0.0f, 0.0f);
+ rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x - width/2, y - height/2, z - length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x - width/2, y - height/2, z + length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
+ rlVertex3f(x - width/2, y + height/2, z + length/2);
+ rlTexCoord2f(source.x/texWidth, source.y/texHeight);
+ rlVertex3f(x - width/2, y + height/2, z - length/2);
+
+ rlEnd();
+
+ rlSetTexture(0);
+}
\ No newline at end of file
diff --git a/examples/models/models_draw_cube_texture.png b/examples/models/models_draw_cube_texture.png
new file mode 100644
index 000000000..45b3a13d1
Binary files /dev/null and b/examples/models/models_draw_cube_texture.png differ
diff --git a/examples/models/models_first_person_maze.c b/examples/models/models_first_person_maze.c
index b2211c57e..6a4345a8b 100644
--- a/examples/models/models_first_person_maze.c
+++ b/examples/models/models_first_person_maze.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -28,7 +28,13 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze");
// Define the camera to look into our 3d world
- Camera camera = { { 0.2f, 0.4f, 0.2f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
+ Camera camera = { 0 };
+ camera.position = (Vector3){ 0.2f, 0.4f, 0.2f }; // Camera position
+ camera.target = (Vector3){ 0.185f, 0.4f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
+ Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
Image imMap = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
Texture2D cubicmap = LoadTextureFromImage(imMap); // Convert image to texture to display (VRAM)
@@ -37,7 +43,7 @@ int main(void)
// NOTE: By default each cube is mapped to one part of texture atlas
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture
- model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
+ model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
// Get map image data to be used for collision detection
Color *mapPixels = LoadImageColors(imMap);
@@ -45,7 +51,7 @@ int main(void)
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
- SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set camera mode
+ DisableCursor(); // Limit cursor to relative movement inside the window
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -57,7 +63,7 @@ int main(void)
//----------------------------------------------------------------------------------
Vector3 oldCamPos = camera.position; // Store old camera position
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_FIRST_PERSON);
// Check player collision (we simplify to 2D collision detection)
Vector2 playerPos = { camera.position.x, camera.position.z };
diff --git a/examples/models/models_geometric_shapes.c b/examples/models/models_geometric_shapes.c
index 294c88252..33c406347 100644
--- a/examples/models/models_geometric_shapes.c
+++ b/examples/models/models_geometric_shapes.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -66,6 +66,9 @@ int main(void)
DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD);
DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK);
+ DrawCapsule ((Vector3){-3.0f, 1.5f, -4.0f}, (Vector3){-4.0f, -1.0f, -4.0f}, 1.2f, 8, 8, VIOLET);
+ DrawCapsuleWires((Vector3){-3.0f, 1.5f, -4.0f}, (Vector3){-4.0f, -1.0f, -4.0f}, 1.2f, 8, 8, PURPLE);
+
DrawGrid(10, 1.0f); // Draw a grid
EndMode3D();
diff --git a/examples/models/models_geometric_shapes.png b/examples/models/models_geometric_shapes.png
index 6076b4297..765abe197 100644
Binary files a/examples/models/models_geometric_shapes.png and b/examples/models/models_geometric_shapes.png differ
diff --git a/examples/models/models_heightmap.c b/examples/models/models_heightmap.c
index 189d07d75..e1c3e4fb6 100644
--- a/examples/models/models_heightmap.c
+++ b/examples/models/models_heightmap.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -26,30 +26,33 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
// Define our custom camera to look into our 3d world
- Camera camera = { { 18.0f, 18.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
+ Camera camera = { 0 };
+ camera.position = (Vector3){ 18.0f, 21.0f, 18.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
- Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
- Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
+ Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
+ Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
- Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM)
- Model model = LoadModelFromMesh(mesh); // Load model from generated mesh
+ Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM)
+ Model model = LoadModelFromMesh(mesh); // Load model from generated mesh
- model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
- Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Define model position
+ model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
+ Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Define model position
- UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
+ UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
- SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
-
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_ORBITAL);
//----------------------------------------------------------------------------------
// Draw
diff --git a/examples/models/models_loading.c b/examples/models/models_loading.c
index d40661412..4bce2a79e 100644
--- a/examples/models/models_loading.c
+++ b/examples/models/models_loading.c
@@ -20,7 +20,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -57,10 +57,10 @@ int main(void)
// NOTE: bounds are calculated from the original size of the model,
// if model is scaled on drawing, bounds must be also scaled
- SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
-
bool selected = false; // Selected object flag
+ DisableCursor(); // Limit cursor to relative movement inside the window
+
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -69,7 +69,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_FIRST_PERSON);
// Load new models/textures on drag&drop
if (IsFileDropped())
diff --git a/examples/models/models_loading_gltf.c b/examples/models/models_loading_gltf.c
index 01a084069..28847316a 100644
--- a/examples/models/models_loading_gltf.c
+++ b/examples/models/models_loading_gltf.c
@@ -1,13 +1,20 @@
/*******************************************************************************************
*
-* raylib [models] example - loading gltf
+* raylib [models] example - loading gltf with animations
+*
+* LIMITATIONS:
+* - Only supports 1 armature per file, and skips loading it if there are multiple armatures
+* - Only supports linear interpolation (default method in Blender when checked
+* "Always Sample Animations" when exporting a GLTF file)
+* - Only supports translation/rotation/scale animation channel.path,
+* weights not considered (i.e. morph targets)
*
* Example originally created with raylib 3.7, last time updated with raylib 4.2
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2020-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2020-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -27,18 +34,24 @@ int main(void)
// Define the camera to look into our 3d world
Camera camera = { 0 };
- camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
- camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
+ camera.position = (Vector3){ 5.0f, 5.0f, 5.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
- camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
- // Loaf gltf model
+ // Load gltf model
Model model = LoadModel("resources/models/gltf/robot.glb");
+ // Load gltf model animations
+ unsigned int animsCount = 0;
+ unsigned int animIndex = 0;
+ unsigned int animCurrentFrame = 0;
+ ModelAnimation *modelAnimations = LoadModelAnimations("resources/models/gltf/robot.glb", &animsCount);
+
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
- SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
+ DisableCursor(); // Limit cursor to relative movement inside the window
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -48,22 +61,33 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_THIRD_PERSON);
+ // Select current animation
+ if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) animIndex = (animIndex + 1)%animsCount;
+ else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) animIndex = (animIndex + animsCount - 1)%animsCount;
+
+ // Update model animation
+ ModelAnimation anim = modelAnimations[animIndex];
+ animCurrentFrame = (animCurrentFrame + 1)%anim.frameCount;
+ UpdateModelAnimation(model, anim, animCurrentFrame);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
- ClearBackground(SKYBLUE);
+ ClearBackground(RAYWHITE);
BeginMode3D(camera);
- DrawModel(model, position, 1.0f, WHITE);
- DrawGrid(10, 1.0f); // Draw a grid
+ DrawModel(model, position, 1.0f, WHITE); // Draw animated model
+ DrawGrid(10, 1.0f);
EndMode3D();
+ DrawText("Use the LEFT/RIGHT mouse buttons to switch animation", 10, 10, 20, GRAY);
+ DrawText(TextFormat("Animation: %s", anim.name), 10, GetScreenHeight() - 20, 10, DARKGRAY);
+
EndDrawing();
//----------------------------------------------------------------------------------
}
@@ -71,7 +95,7 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadModel(model); // Unload model and meshes/material
-
+
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
diff --git a/examples/models/models_loading_gltf.png b/examples/models/models_loading_gltf.png
index 654444b84..ce2a85284 100644
Binary files a/examples/models/models_loading_gltf.png and b/examples/models/models_loading_gltf.png differ
diff --git a/examples/models/models_loading_m3d.c b/examples/models/models_loading_m3d.c
index 819684073..1e56d51ca 100644
--- a/examples/models/models_loading_m3d.c
+++ b/examples/models/models_loading_m3d.c
@@ -2,7 +2,7 @@
*
* raylib [models] example - Load models M3D
*
-* Example originally created with raylib 4.5-dev, last time updated with raylib 4.5-dev
+* Example originally created with raylib 4.5, last time updated with raylib 4.5
*
* Example contributed by bzt (@bztsrc) and reviewed by Ramon Santamaria (@raysan5)
*
@@ -13,7 +13,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2022 bzt (@bztsrc)
+* Copyright (c) 2022-2023 bzt (@bztsrc)
*
********************************************************************************************/
@@ -33,14 +33,15 @@ int main(void)
// Define the camera to look into our 3d world
Camera camera = { 0 };
- camera.position = (Vector3){ 1.5f, 1.5f, 1.5f }; // Camera position
+ camera.position = (Vector3){ 1.5f, 1.5f, 1.5f }; // Camera position
camera.target = (Vector3){ 0.0f, 0.4f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
- camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
+
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
-
- char modelFileName[128] = "resources/models/m3d/CesiumMan.m3d";
+
+ char modelFileName[128] = "resources/models/m3d/cesium_man.m3d";
bool drawMesh = 1;
bool drawSkeleton = 1;
bool animPlaying = false; // Store anim state, what to draw
@@ -53,17 +54,17 @@ int main(void)
int animFrameCounter = 0, animId = 0;
ModelAnimation *anims = LoadModelAnimations(modelFileName, &animsCount); // Load skeletal animation data
- SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
+ DisableCursor(); // Limit cursor to relative movement inside the window
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_FIRST_PERSON);
if (animsCount)
{
@@ -71,27 +72,27 @@ int main(void)
if (IsKeyDown(KEY_SPACE) || IsKeyPressed(KEY_N))
{
animFrameCounter++;
-
+
if (animFrameCounter >= anims[animId].frameCount) animFrameCounter = 0;
-
+
UpdateModelAnimation(model, anims[animId], animFrameCounter);
animPlaying = true;
}
-
- // Select animation by pressing A
- if (IsKeyPressed(KEY_A))
+
+ // Select animation by pressing C
+ if (IsKeyPressed(KEY_C))
{
animFrameCounter = 0;
animId++;
-
+
if (animId >= animsCount) animId = 0;
UpdateModelAnimation(model, anims[animId], 0);
animPlaying = true;
}
}
-
+
// Toggle skeleton drawing
- if (IsKeyPressed(KEY_S)) drawSkeleton ^= 1;
+ if (IsKeyPressed(KEY_B)) drawSkeleton ^= 1;
// Toggle mesh drawing
if (IsKeyPressed(KEY_M)) drawMesh ^= 1;
@@ -111,19 +112,19 @@ int main(void)
// Draw the animated skeleton
if (drawSkeleton)
{
- // Loop to (boneCount - 1) because the last one is a special "no bone" bone,
+ // Loop to (boneCount - 1) because the last one is a special "no bone" bone,
// needed to workaround buggy models
// without a -1, we would always draw a cube at the origin
for (int i = 0; i < model.boneCount - 1; i++)
{
- // By default the model is loaded in bind-pose by LoadModel().
- // But if UpdateModelAnimation() has been called at least once
+ // By default the model is loaded in bind-pose by LoadModel().
+ // But if UpdateModelAnimation() has been called at least once
// then the model is already in animation pose, so we need the animated skeleton
if (!animPlaying || !animsCount)
{
// Display the bind-pose skeleton
DrawCube(model.bindPose[i].translation, 0.04f, 0.04f, 0.04f, RED);
-
+
if (model.bones[i].parent >= 0)
{
DrawLine3D(model.bindPose[i].translation,
@@ -134,7 +135,7 @@ int main(void)
{
// Display the frame-pose skeleton
DrawCube(anims[animId].framePoses[animFrameCounter][i].translation, 0.05f, 0.05f, 0.05f, RED);
-
+
if (anims[animId].bones[i].parent >= 0)
{
DrawLine3D(anims[animId].framePoses[animFrameCounter][i].translation,
@@ -148,9 +149,10 @@ int main(void)
EndMode3D();
- DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, GetScreenHeight() - 60, 10, MAROON);
- DrawText("PRESS A to CYCLE THROUGH ANIMATIONS", 10, GetScreenHeight() - 40, 10, DARKGRAY);
- DrawText("PRESS M to toggle MESH, S to toggle SKELETON DRAWING", 10, GetScreenHeight() - 20, 10, DARKGRAY);
+ DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, GetScreenHeight() - 80, 10, MAROON);
+ DrawText("PRESS N to STEP ONE ANIMATION FRAME", 10, GetScreenHeight() - 60, 10, DARKGRAY);
+ DrawText("PRESS C to CYCLE THROUGH ANIMATIONS", 10, GetScreenHeight() - 40, 10, DARKGRAY);
+ DrawText("PRESS M to toggle MESH, B to toggle SKELETON DRAWING", 10, GetScreenHeight() - 20, 10, DARKGRAY);
DrawText("(c) CesiumMan model by KhronosGroup", GetScreenWidth() - 210, GetScreenHeight() - 20, 10, GRAY);
EndDrawing();
diff --git a/examples/models/models_loading_m3d.png b/examples/models/models_loading_m3d.png
index 2214b8e01..9220419ad 100644
Binary files a/examples/models/models_loading_m3d.png and b/examples/models/models_loading_m3d.png differ
diff --git a/examples/models/models_loading_vox.c b/examples/models/models_loading_vox.c
index 80226d0a4..e148fd91a 100644
--- a/examples/models/models_loading_vox.c
+++ b/examples/models/models_loading_vox.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2021-2022 Johann Nadalutti (@procfxgen) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2021-2023 Johann Nadalutti (@procfxgen) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -43,7 +43,7 @@ int main(void)
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
- camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Load MagicaVoxel files
Model models[MAX_VOX_FILES] = { 0 };
@@ -69,8 +69,6 @@ int main(void)
int currentModel = 0;
- SetCameraMode(camera, CAMERA_ORBITAL); // Set a orbital camera mode
-
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -79,7 +77,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_ORBITAL);
// Cycle between models on mouse click
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) currentModel = (currentModel + 1)%MAX_VOX_FILES;
diff --git a/examples/models/models_mesh_generation.c b/examples/models/models_mesh_generation.c
index 35586c811..d17a20a12 100644
--- a/examples/models/models_mesh_generation.c
+++ b/examples/models/models_mesh_generation.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2017-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2017-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -68,8 +68,6 @@ int main(void)
int currentModel = 0;
- SetCameraMode(camera, CAMERA_ORBITAL); // Set a orbital camera mode
-
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -78,7 +76,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_ORBITAL);
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
{
diff --git a/examples/models/models_mesh_picking.c b/examples/models/models_mesh_picking.c
index 64aba2624..69d98aa18 100644
--- a/examples/models/models_mesh_picking.c
+++ b/examples/models/models_mesh_picking.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2017-2022 Joel Davis (@joeld42) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2017-2023 Joel Davis (@joeld42) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -36,7 +36,7 @@ int main(void)
camera.target = (Vector3){ 0.0f, 8.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
- camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Ray ray = { 0 }; // Picking ray
@@ -64,8 +64,6 @@ int main(void)
Vector3 sp = (Vector3){ -30.0f, 5.0f, 5.0f };
float sr = 4.0f;
- SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
-
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
@@ -73,7 +71,14 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ if (IsCursorHidden()) UpdateCamera(&camera, CAMERA_FIRST_PERSON); // Update camera
+
+ // Toggle camera controls
+ if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT))
+ {
+ if (IsCursorHidden()) EnableCursor();
+ else DisableCursor();
+ }
// Display information about closest hit
RayCollision collision = { 0 };
@@ -219,7 +224,7 @@ int main(void)
DrawText(TextFormat("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK);
}
- DrawText("Use Mouse to Move Camera", 10, 430, 10, GRAY);
+ DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY);
DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
diff --git a/examples/models/models_orthographic_projection.c b/examples/models/models_orthographic_projection.c
index cfdeb859b..098e4b20a 100644
--- a/examples/models/models_orthographic_projection.c
+++ b/examples/models/models_orthographic_projection.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2018-2022 Max Danielsson (@autious) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2018-2023 Max Danielsson (@autious) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/models/models_rlgl_solar_system.c b/examples/models/models_rlgl_solar_system.c
index a49b37d06..e458036fe 100644
--- a/examples/models/models_rlgl_solar_system.c
+++ b/examples/models/models_rlgl_solar_system.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2018-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2018-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -43,13 +43,11 @@ int main(void)
// Define the camera to look into our 3d world
Camera camera = { 0 };
- camera.position = (Vector3){ 16.0f, 16.0f, 16.0f };
- camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
- camera.fovy = 45.0f;
- camera.projection = CAMERA_PERSPECTIVE;
-
- SetCameraMode(camera, CAMERA_FREE);
+ camera.position = (Vector3){ 16.0f, 16.0f, 16.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
float rotationSpeed = 0.2f; // General system rotation speed
@@ -66,7 +64,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_ORBITAL);
earthRotation += (5.0f*rotationSpeed);
earthOrbitRotation += (365/360.0f*(5.0f*rotationSpeed)*rotationSpeed);
diff --git a/examples/models/models_skybox.c b/examples/models/models_skybox.c
index b6ce72b2a..34616de59 100644
--- a/examples/models/models_skybox.c
+++ b/examples/models/models_skybox.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2017-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2017-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -38,7 +38,12 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing");
// Define the camera to look into our 3d world
- Camera camera = { { 1.0f, 1.0f, 1.0f }, { 4.0f, 1.0f, 4.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
+ Camera camera = { 0 };
+ camera.position = (Vector3){ 1.0f, 1.0f, 1.0f }; // Camera position
+ camera.target = (Vector3){ 4.0f, 1.0f, 4.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Load skybox model
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
@@ -87,17 +92,17 @@ int main(void)
UnloadImage(img);
}
- SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person camera mode
+ DisableCursor(); // Limit cursor to relative movement inside the window
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_FIRST_PERSON);
// Load new cubemap texture on drag&drop
if (IsFileDropped())
diff --git a/examples/models/models_waving_cubes.c b/examples/models/models_waving_cubes.c
index f0737de3a..d382c998d 100644
--- a/examples/models/models_waving_cubes.c
+++ b/examples/models/models_waving_cubes.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Codecat (@codecat) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Codecat (@codecat) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -31,11 +31,11 @@ int main()
// Initialize the camera
Camera3D camera = { 0 };
- camera.position = (Vector3){ 30.0f, 20.0f, 30.0f };
- camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
- camera.fovy = 70.0f;
- camera.projection = CAMERA_PERSPECTIVE;
+ camera.position = (Vector3){ 30.0f, 20.0f, 30.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 70.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Specify the amount of blocks in each direction
const int numBlocks = 15;
diff --git a/examples/models/models_yaw_pitch_roll.c b/examples/models/models_yaw_pitch_roll.c
index d3db9d063..611ee3146 100644
--- a/examples/models/models_yaw_pitch_roll.c
+++ b/examples/models/models_yaw_pitch_roll.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2017-2022 Berni (@Berni8k) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2017-2023 Berni (@Berni8k) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/models/resources/models/gltf/robot.blend b/examples/models/resources/models/gltf/robot.blend
index d3bdac237..efe43c5e5 100644
Binary files a/examples/models/resources/models/gltf/robot.blend and b/examples/models/resources/models/gltf/robot.blend differ
diff --git a/examples/models/resources/models/gltf/robot.glb b/examples/models/resources/models/gltf/robot.glb
index 73f5bf44e..549011e75 100644
Binary files a/examples/models/resources/models/gltf/robot.glb and b/examples/models/resources/models/gltf/robot.glb differ
diff --git a/examples/models/resources/models/m3d/CesiumMan.m3d b/examples/models/resources/models/m3d/cesium_man.m3d
similarity index 100%
rename from examples/models/resources/models/m3d/CesiumMan.m3d
rename to examples/models/resources/models/m3d/cesium_man.m3d
diff --git a/examples/others/easings_testbed.c b/examples/others/easings_testbed.c
index 38f47dd09..227efd231 100644
--- a/examples/others/easings_testbed.c
+++ b/examples/others/easings_testbed.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Juan Miguel López (@flashback-fx ) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Juan Miguel López (@flashback-fx ) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/others/embedded_files_loading.c b/examples/others/embedded_files_loading.c
index 3e3bc7d44..64023539c 100644
--- a/examples/others/embedded_files_loading.c
+++ b/examples/others/embedded_files_loading.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2020-2022 Kristian Holmgren (@defutura) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2020-2023 Kristian Holmgren (@defutura) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/others/external/include/glad_gles2.h b/examples/others/external/include/glad_gles2.h
new file mode 100644
index 000000000..6c753d0a4
--- /dev/null
+++ b/examples/others/external/include/glad_gles2.h
@@ -0,0 +1,4774 @@
+/**
+ * Loader generated by glad 2.0.2 on Wed Dec 28 13:28:51 2022
+ *
+ * SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
+ *
+ * Generator: C/C++
+ * Specification: gl
+ * Extensions: 170
+ *
+ * APIs:
+ * - gles2=2.0
+ *
+ * Options:
+ * - ALIAS = False
+ * - DEBUG = False
+ * - HEADER_ONLY = True
+ * - LOADER = False
+ * - MX = False
+ * - ON_DEMAND = False
+ *
+ * Commandline:
+ * --api='gles2=2.0' --extensions='GL_EXT_EGL_image_array,GL_EXT_EGL_image_storage,GL_EXT_EGL_image_storage_compression,GL_EXT_YUV_target,GL_EXT_base_instance,GL_EXT_blend_func_extended,GL_EXT_blend_minmax,GL_EXT_buffer_storage,GL_EXT_clear_texture,GL_EXT_clip_control,GL_EXT_clip_cull_distance,GL_EXT_color_buffer_float,GL_EXT_color_buffer_half_float,GL_EXT_conservative_depth,GL_EXT_copy_image,GL_EXT_debug_label,GL_EXT_debug_marker,GL_EXT_depth_clamp,GL_EXT_discard_framebuffer,GL_EXT_disjoint_timer_query,GL_EXT_draw_buffers,GL_EXT_draw_buffers_indexed,GL_EXT_draw_elements_base_vertex,GL_EXT_draw_instanced,GL_EXT_draw_transform_feedback,GL_EXT_external_buffer,GL_EXT_float_blend,GL_EXT_fragment_shading_rate,GL_EXT_geometry_point_size,GL_EXT_geometry_shader,GL_EXT_gpu_shader5,GL_EXT_instanced_arrays,GL_EXT_map_buffer_range,GL_EXT_memory_object,GL_EXT_memory_object_fd,GL_EXT_memory_object_win32,GL_EXT_multi_draw_arrays,GL_EXT_multi_draw_indirect,GL_EXT_multisampled_compatibility,GL_EXT_multisampled_render_to_texture,GL_EXT_multisampled_render_to_texture2,GL_EXT_multiview_draw_buffers,GL_EXT_multiview_tessellation_geometry_shader,GL_EXT_multiview_texture_multisample,GL_EXT_multiview_timer_query,GL_EXT_occlusion_query_boolean,GL_EXT_polygon_offset_clamp,GL_EXT_post_depth_coverage,GL_EXT_primitive_bounding_box,GL_EXT_protected_textures,GL_EXT_pvrtc_sRGB,GL_EXT_raster_multisample,GL_EXT_read_format_bgra,GL_EXT_render_snorm,GL_EXT_robustness,GL_EXT_sRGB,GL_EXT_sRGB_write_control,GL_EXT_semaphore,GL_EXT_semaphore_fd,GL_EXT_semaphore_win32,GL_EXT_separate_depth_stencil,GL_EXT_separate_shader_objects,GL_EXT_shader_framebuffer_fetch,GL_EXT_shader_framebuffer_fetch_non_coherent,GL_EXT_shader_group_vote,GL_EXT_shader_implicit_conversions,GL_EXT_shader_integer_mix,GL_EXT_shader_io_blocks,GL_EXT_shader_non_constant_global_initializers,GL_EXT_shader_pixel_local_storage,GL_EXT_shader_pixel_local_storage2,GL_EXT_shader_samples_identical,GL_EXT_shader_texture_lod,GL_EXT_shadow_samplers,GL_EXT_sparse_texture,GL_EXT_sparse_texture2,GL_EXT_tessellation_point_size,GL_EXT_tessellation_shader,GL_EXT_texture_border_clamp,GL_EXT_texture_buffer,GL_EXT_texture_compression_astc_decode_mode,GL_EXT_texture_compression_bptc,GL_EXT_texture_compression_dxt1,GL_EXT_texture_compression_rgtc,GL_EXT_texture_compression_s3tc,GL_EXT_texture_compression_s3tc_srgb,GL_EXT_texture_cube_map_array,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_filter_minmax,GL_EXT_texture_format_BGRA8888,GL_EXT_texture_format_sRGB_override,GL_EXT_texture_mirror_clamp_to_edge,GL_EXT_texture_norm16,GL_EXT_texture_query_lod,GL_EXT_texture_rg,GL_EXT_texture_sRGB_R8,GL_EXT_texture_sRGB_RG8,GL_EXT_texture_sRGB_decode,GL_EXT_texture_shadow_lod,GL_EXT_texture_storage,GL_EXT_texture_storage_compression,GL_EXT_texture_type_2_10_10_10_REV,GL_EXT_texture_view,GL_EXT_unpack_subimage,GL_EXT_win32_keyed_mutex,GL_EXT_window_rectangles,GL_KHR_blend_equation_advanced,GL_KHR_blend_equation_advanced_coherent,GL_KHR_context_flush_control,GL_KHR_debug,GL_KHR_no_error,GL_KHR_parallel_shader_compile,GL_KHR_robust_buffer_access_behavior,GL_KHR_robustness,GL_KHR_shader_subgroup,GL_KHR_texture_compression_astc_hdr,GL_KHR_texture_compression_astc_ldr,GL_KHR_texture_compression_astc_sliced_3d,GL_OES_EGL_image,GL_OES_EGL_image_external,GL_OES_EGL_image_external_essl3,GL_OES_compressed_ETC1_RGB8_sub_texture,GL_OES_compressed_ETC1_RGB8_texture,GL_OES_compressed_paletted_texture,GL_OES_copy_image,GL_OES_depth24,GL_OES_depth32,GL_OES_depth_texture,GL_OES_draw_buffers_indexed,GL_OES_draw_elements_base_vertex,GL_OES_element_index_uint,GL_OES_fbo_render_mipmap,GL_OES_fragment_precision_high,GL_OES_geometry_point_size,GL_OES_geometry_shader,GL_OES_get_program_binary,GL_OES_gpu_shader5,GL_OES_mapbuffer,GL_OES_packed_depth_stencil,GL_OES_primitive_bounding_box,GL_OES_required_internalformat,GL_OES_rgb8_rgba8,GL_OES_sample_shading,GL_OES_sample_variables,GL_OES_shader_image_atomic,GL_OES_shader_io_blocks,GL_OES_shader_multisample_interpolation,GL_OES_standard_derivatives,GL_OES_stencil1,GL_OES_stencil4,GL_OES_surfaceless_context,GL_OES_tessellation_point_size,GL_OES_tessellation_shader,GL_OES_texture_3D,GL_OES_texture_border_clamp,GL_OES_texture_buffer,GL_OES_texture_compression_astc,GL_OES_texture_cube_map_array,GL_OES_texture_float,GL_OES_texture_float_linear,GL_OES_texture_half_float,GL_OES_texture_half_float_linear,GL_OES_texture_npot,GL_OES_texture_stencil8,GL_OES_texture_storage_multisample_2d_array,GL_OES_texture_view,GL_OES_vertex_array_object,GL_OES_vertex_half_float,GL_OES_vertex_type_10_10_10_2,GL_OES_viewport_array' c --header-only
+ *
+ * Online:
+ * http://glad.sh/#api=gles2%3D2.0&generator=c&options=HEADER_ONLY
+ *
+ */
+
+#ifndef GLAD_GLES2_H_
+#define GLAD_GLES2_H_
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wreserved-id-macro"
+#endif
+#ifdef __gl2_h_
+ #error OpenGL ES 2 header already included (API: gles2), remove previous include!
+#endif
+#define __gl2_h_ 1
+#ifdef __gles2_gl2_h_
+ #error OpenGL ES 2 header already included (API: gles2), remove previous include!
+#endif
+#define __gles2_gl2_h_ 1
+#ifdef __gl3_h_
+ #error OpenGL ES 3 header already included (API: gles2), remove previous include!
+#endif
+#define __gl3_h_ 1
+#ifdef __gles2_gl3_h_
+ #error OpenGL ES 3 header already included (API: gles2), remove previous include!
+#endif
+#define __gles2_gl3_h_ 1
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+#define GLAD_GLES2
+#define GLAD_OPTION_GLES2_HEADER_ONLY
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef GLAD_PLATFORM_H_
+#define GLAD_PLATFORM_H_
+
+#ifndef GLAD_PLATFORM_WIN32
+ #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
+ #define GLAD_PLATFORM_WIN32 1
+ #else
+ #define GLAD_PLATFORM_WIN32 0
+ #endif
+#endif
+
+#ifndef GLAD_PLATFORM_APPLE
+ #ifdef __APPLE__
+ #define GLAD_PLATFORM_APPLE 1
+ #else
+ #define GLAD_PLATFORM_APPLE 0
+ #endif
+#endif
+
+#ifndef GLAD_PLATFORM_EMSCRIPTEN
+ #ifdef __EMSCRIPTEN__
+ #define GLAD_PLATFORM_EMSCRIPTEN 1
+ #else
+ #define GLAD_PLATFORM_EMSCRIPTEN 0
+ #endif
+#endif
+
+#ifndef GLAD_PLATFORM_UWP
+ #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
+ #ifdef __has_include
+ #if __has_include()
+ #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
+ #endif
+ #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
+ #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
+ #endif
+ #endif
+
+ #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
+ #include
+ #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+ #define GLAD_PLATFORM_UWP 1
+ #endif
+ #endif
+
+ #ifndef GLAD_PLATFORM_UWP
+ #define GLAD_PLATFORM_UWP 0
+ #endif
+#endif
+
+#ifdef __GNUC__
+ #define GLAD_GNUC_EXTENSION __extension__
+#else
+ #define GLAD_GNUC_EXTENSION
+#endif
+
+#define GLAD_UNUSED(x) (void)(x)
+
+#ifndef GLAD_API_CALL
+ #if defined(GLAD_API_CALL_EXPORT)
+ #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
+ #if defined(GLAD_API_CALL_EXPORT_BUILD)
+ #if defined(__GNUC__)
+ #define GLAD_API_CALL __attribute__ ((dllexport)) extern
+ #else
+ #define GLAD_API_CALL __declspec(dllexport) extern
+ #endif
+ #else
+ #if defined(__GNUC__)
+ #define GLAD_API_CALL __attribute__ ((dllimport)) extern
+ #else
+ #define GLAD_API_CALL __declspec(dllimport) extern
+ #endif
+ #endif
+ #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
+ #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
+ #else
+ #define GLAD_API_CALL extern
+ #endif
+ #else
+ #define GLAD_API_CALL extern
+ #endif
+#endif
+
+#ifdef APIENTRY
+ #define GLAD_API_PTR APIENTRY
+#elif GLAD_PLATFORM_WIN32
+ #define GLAD_API_PTR __stdcall
+#else
+ #define GLAD_API_PTR
+#endif
+
+#ifndef GLAPI
+#define GLAPI GLAD_API_CALL
+#endif
+
+#ifndef GLAPIENTRY
+#define GLAPIENTRY GLAD_API_PTR
+#endif
+
+#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
+#define GLAD_VERSION_MAJOR(version) (version / 10000)
+#define GLAD_VERSION_MINOR(version) (version % 10000)
+
+#define GLAD_GENERATOR_VERSION "2.0.2"
+
+typedef void (*GLADapiproc)(void);
+
+typedef GLADapiproc (*GLADloadfunc)(const char *name);
+typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name);
+
+typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
+typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
+
+#endif /* GLAD_PLATFORM_H_ */
+
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_ACTIVE_PROGRAM_EXT 0x8259
+#define GL_ACTIVE_TEXTURE 0x84E0
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
+#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF
+#define GL_ALPHA 0x1906
+#define GL_ALPHA16F_EXT 0x881C
+#define GL_ALPHA32F_EXT 0x8816
+#define GL_ALPHA8_EXT 0x803C
+#define GL_ALPHA8_OES 0x803C
+#define GL_ALPHA_BITS 0x0D55
+#define GL_ALWAYS 0x0207
+#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A
+#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F
+#define GL_ARRAY_BUFFER 0x8892
+#define GL_ARRAY_BUFFER_BINDING 0x8894
+#define GL_ATTACHED_SHADERS 0x8B85
+#define GL_BACK 0x0405
+#define GL_BGRA8_EXT 0x93A1
+#define GL_BGRA_EXT 0x80E1
+#define GL_BLEND 0x0BE2
+#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285
+#define GL_BLEND_COLOR 0x8005
+#define GL_BLEND_DST_ALPHA 0x80CA
+#define GL_BLEND_DST_RGB 0x80C8
+#define GL_BLEND_EQUATION 0x8009
+#define GL_BLEND_EQUATION_ALPHA 0x883D
+#define GL_BLEND_EQUATION_RGB 0x8009
+#define GL_BLEND_SRC_ALPHA 0x80CB
+#define GL_BLEND_SRC_RGB 0x80C9
+#define GL_BLUE_BITS 0x0D54
+#define GL_BOOL 0x8B56
+#define GL_BOOL_VEC2 0x8B57
+#define GL_BOOL_VEC3 0x8B58
+#define GL_BOOL_VEC4 0x8B59
+#define GL_BUFFER_ACCESS_OES 0x88BB
+#define GL_BUFFER_IMMUTABLE_STORAGE_EXT 0x821F
+#define GL_BUFFER_KHR 0x82E0
+#define GL_BUFFER_MAPPED_OES 0x88BC
+#define GL_BUFFER_MAP_POINTER_OES 0x88BD
+#define GL_BUFFER_OBJECT_EXT 0x9151
+#define GL_BUFFER_SIZE 0x8764
+#define GL_BUFFER_STORAGE_FLAGS_EXT 0x8220
+#define GL_BUFFER_USAGE 0x8765
+#define GL_BYTE 0x1400
+#define GL_CCW 0x0901
+#define GL_CLAMP_TO_BORDER_EXT 0x812D
+#define GL_CLAMP_TO_BORDER_OES 0x812D
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT 0x00004000
+#define GL_CLIENT_STORAGE_BIT_EXT 0x0200
+#define GL_CLIP_DEPTH_MODE 0x935D
+#define GL_CLIP_DEPTH_MODE_EXT 0x935D
+#define GL_CLIP_DISTANCE0_EXT 0x3000
+#define GL_CLIP_DISTANCE1_EXT 0x3001
+#define GL_CLIP_DISTANCE2_EXT 0x3002
+#define GL_CLIP_DISTANCE3_EXT 0x3003
+#define GL_CLIP_DISTANCE4_EXT 0x3004
+#define GL_CLIP_DISTANCE5_EXT 0x3005
+#define GL_CLIP_DISTANCE6 0x3006
+#define GL_CLIP_DISTANCE6_EXT 0x3006
+#define GL_CLIP_DISTANCE7 0x3007
+#define GL_CLIP_DISTANCE7_EXT 0x3007
+#define GL_CLIP_ORIGIN 0x935C
+#define GL_CLIP_ORIGIN_EXT 0x935C
+#define GL_CLIP_PLANE0 0x3000
+#define GL_CLIP_PLANE1 0x3001
+#define GL_CLIP_PLANE2 0x3002
+#define GL_CLIP_PLANE3 0x3003
+#define GL_CLIP_PLANE4 0x3004
+#define GL_CLIP_PLANE5 0x3005
+#define GL_COLORBURN_KHR 0x929A
+#define GL_COLORDODGE_KHR 0x9299
+#define GL_COLOR_ATTACHMENT0 0x8CE0
+#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
+#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_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_ATTACHMENT_EXT 0x90F0
+#define GL_COLOR_BUFFER_BIT 0x00004000
+#define GL_COLOR_CLEAR_VALUE 0x0C22
+#define GL_COLOR_EXT 0x1800
+#define GL_COLOR_WRITEMASK 0x0C23
+#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_COMPLETION_STATUS_KHR 0x91B1
+#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD
+#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB
+#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
+#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_12x10_KHR 0x93BC
+#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
+#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0
+#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1
+#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
+#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2
+#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3
+#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
+#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4
+#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
+#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5
+#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6
+#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
+#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7
+#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
+#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8
+#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9
+#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_BPTC_UNORM_EXT 0x8E8C
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
+#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT 0x8E8E
+#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT 0x8E8F
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
+#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE
+#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
+#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_12x10_KHR 0x93DC
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9
+#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_SRGB_ALPHA_BPTC_UNORM_EXT 0x8E8D
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1
+#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
+#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54
+#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55
+#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002
+#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008
+#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008
+#define GL_CONTEXT_FLAG_PROTECTED_CONTENT_BIT_EXT 0x00000010
+#define GL_CONTEXT_LOST_KHR 0x0507
+#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x82FC
+#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x82FB
+#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3
+#define GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3
+#define GL_CULL_FACE 0x0B44
+#define GL_CULL_FACE_MODE 0x0B45
+#define GL_CURRENT_PROGRAM 0x8B8D
+#define GL_CURRENT_QUERY_EXT 0x8865
+#define GL_CURRENT_VERTEX_ATTRIB 0x8626
+#define GL_CW 0x0900
+#define GL_D3D12_FENCE_VALUE_EXT 0x9595
+#define GL_DARKEN_KHR 0x9297
+#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244
+#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245
+#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D
+#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145
+#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243
+#define GL_DEBUG_OUTPUT_KHR 0x92E0
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242
+#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146
+#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148
+#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147
+#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B
+#define GL_DEBUG_SOURCE_API_KHR 0x8246
+#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A
+#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B
+#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248
+#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249
+#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247
+#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D
+#define GL_DEBUG_TYPE_ERROR_KHR 0x824C
+#define GL_DEBUG_TYPE_MARKER_KHR 0x8268
+#define GL_DEBUG_TYPE_OTHER_KHR 0x8251
+#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250
+#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A
+#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F
+#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269
+#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E
+#define GL_DECODE_EXT 0x8A49
+#define GL_DECR 0x1E03
+#define GL_DECR_WRAP 0x8508
+#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581
+#define GL_DELETE_STATUS 0x8B80
+#define GL_DEPTH24_STENCIL8_OES 0x88F0
+#define GL_DEPTH_ATTACHMENT 0x8D00
+#define GL_DEPTH_BITS 0x0D56
+#define GL_DEPTH_BUFFER_BIT 0x00000100
+#define GL_DEPTH_CLAMP_EXT 0x864F
+#define GL_DEPTH_CLEAR_VALUE 0x0B73
+#define GL_DEPTH_COMPONENT 0x1902
+#define GL_DEPTH_COMPONENT16 0x81A5
+#define GL_DEPTH_COMPONENT16_OES 0x81A5
+#define GL_DEPTH_COMPONENT24_OES 0x81A6
+#define GL_DEPTH_COMPONENT32_OES 0x81A7
+#define GL_DEPTH_EXT 0x1801
+#define GL_DEPTH_FUNC 0x0B74
+#define GL_DEPTH_RANGE 0x0B70
+#define GL_DEPTH_STENCIL_OES 0x84F9
+#define GL_DEPTH_TEST 0x0B71
+#define GL_DEPTH_WRITEMASK 0x0B72
+#define GL_DEVICE_LUID_EXT 0x9599
+#define GL_DEVICE_NODE_MASK_EXT 0x959A
+#define GL_DEVICE_UUID_EXT 0x9597
+#define GL_DIFFERENCE_KHR 0x929E
+#define GL_DITHER 0x0BD0
+#define GL_DONT_CARE 0x1100
+#define GL_DRAW_BUFFER0_EXT 0x8825
+#define GL_DRAW_BUFFER10_EXT 0x882F
+#define GL_DRAW_BUFFER11_EXT 0x8830
+#define GL_DRAW_BUFFER12_EXT 0x8831
+#define GL_DRAW_BUFFER13_EXT 0x8832
+#define GL_DRAW_BUFFER14_EXT 0x8833
+#define GL_DRAW_BUFFER15_EXT 0x8834
+#define GL_DRAW_BUFFER1_EXT 0x8826
+#define GL_DRAW_BUFFER2_EXT 0x8827
+#define GL_DRAW_BUFFER3_EXT 0x8828
+#define GL_DRAW_BUFFER4_EXT 0x8829
+#define GL_DRAW_BUFFER5_EXT 0x882A
+#define GL_DRAW_BUFFER6_EXT 0x882B
+#define GL_DRAW_BUFFER7_EXT 0x882C
+#define GL_DRAW_BUFFER8_EXT 0x882D
+#define GL_DRAW_BUFFER9_EXT 0x882E
+#define GL_DRAW_BUFFER_EXT 0x0C01
+#define GL_DRIVER_UUID_EXT 0x9598
+#define GL_DST_ALPHA 0x0304
+#define GL_DST_COLOR 0x0306
+#define GL_DYNAMIC_DRAW 0x88E8
+#define GL_DYNAMIC_STORAGE_BIT_EXT 0x0100
+#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
+#define GL_EQUAL 0x0202
+#define GL_ETC1_RGB8_OES 0x8D64
+#define GL_EXCLUSION_KHR 0x92A0
+#define GL_EXCLUSIVE_EXT 0x8F11
+#define GL_EXTENSIONS 0x1F03
+#define GL_FALSE 0
+#define GL_FASTEST 0x1101
+#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D
+#define GL_FIRST_VERTEX_CONVENTION_OES 0x8E4D
+#define GL_FIXED 0x140C
+#define GL_FLOAT 0x1406
+#define GL_FLOAT_MAT2 0x8B5A
+#define GL_FLOAT_MAT3 0x8B5B
+#define GL_FLOAT_MAT4 0x8B5C
+#define GL_FLOAT_VEC2 0x8B50
+#define GL_FLOAT_VEC3 0x8B51
+#define GL_FLOAT_VEC4 0x8B52
+#define GL_FRACTIONAL_EVEN_EXT 0x8E7C
+#define GL_FRACTIONAL_EVEN_OES 0x8E7C
+#define GL_FRACTIONAL_ODD_EXT 0x8E7B
+#define GL_FRACTIONAL_ODD_OES 0x8E7B
+#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES 0x8E5D
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B
+#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
+#define GL_FRAGMENT_SHADING_RATE_ATTACHMENT_WITH_DEFAULT_FRAMEBUFFER_SUPPORTED_EXT 0x96DF
+#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_EXT 0x96D2
+#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_EXT 0x96D5
+#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_EXT 0x96D4
+#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_EXT 0x96D6
+#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_EXT 0x96D3
+#define GL_FRAGMENT_SHADING_RATE_NON_TRIVIAL_COMBINERS_SUPPORTED_EXT 0x8F6F
+#define GL_FRAGMENT_SHADING_RATE_WITH_SAMPLE_MASK_SUPPORTED_EXT 0x96DE
+#define GL_FRAGMENT_SHADING_RATE_WITH_SHADER_DEPTH_STENCIL_WRITES_SUPPORTED_EXT 0x96DD
+#define GL_FRAMEBUFFER 0x8D40
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_OES 0x8DA7
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
+#define GL_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
+#define GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT 0x9312
+#define GL_FRAMEBUFFER_DEFAULT_LAYERS_OES 0x9312
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
+#define GL_FRAMEBUFFER_INCOMPLETE_INSUFFICIENT_SHADER_COMBINED_LOCAL_STORAGE_EXT 0x9652
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_OES 0x8DA8
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
+#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
+#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219
+#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
+#define GL_FRONT 0x0404
+#define GL_FRONT_AND_BACK 0x0408
+#define GL_FRONT_FACE 0x0B46
+#define GL_FUNC_ADD 0x8006
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_GENERATE_MIPMAP_HINT 0x8192
+#define GL_GEOMETRY_LINKED_INPUT_TYPE_EXT 0x8917
+#define GL_GEOMETRY_LINKED_INPUT_TYPE_OES 0x8917
+#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT 0x8918
+#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_OES 0x8918
+#define GL_GEOMETRY_LINKED_VERTICES_OUT_EXT 0x8916
+#define GL_GEOMETRY_LINKED_VERTICES_OUT_OES 0x8916
+#define GL_GEOMETRY_SHADER_BIT_EXT 0x00000004
+#define GL_GEOMETRY_SHADER_BIT_OES 0x00000004
+#define GL_GEOMETRY_SHADER_EXT 0x8DD9
+#define GL_GEOMETRY_SHADER_INVOCATIONS_EXT 0x887F
+#define GL_GEOMETRY_SHADER_INVOCATIONS_OES 0x887F
+#define GL_GEOMETRY_SHADER_OES 0x8DD9
+#define GL_GEQUAL 0x0206
+#define GL_GPU_DISJOINT_EXT 0x8FBB
+#define GL_GREATER 0x0204
+#define GL_GREEN_BITS 0x0D53
+#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253
+#define GL_GUILTY_CONTEXT_RESET_KHR 0x8253
+#define GL_HALF_FLOAT_OES 0x8D61
+#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B
+#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C
+#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594
+#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A
+#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589
+#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586
+#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587
+#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588
+#define GL_HARDLIGHT_KHR 0x929B
+#define GL_HIGH_FLOAT 0x8DF2
+#define GL_HIGH_INT 0x8DF5
+#define GL_HSL_COLOR_KHR 0x92AF
+#define GL_HSL_HUE_KHR 0x92AD
+#define GL_HSL_LUMINOSITY_KHR 0x92B0
+#define GL_HSL_SATURATION_KHR 0x92AE
+#define GL_IMAGE_BUFFER_EXT 0x9051
+#define GL_IMAGE_BUFFER_OES 0x9051
+#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054
+#define GL_IMAGE_CUBE_MAP_ARRAY_OES 0x9054
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
+#define GL_INCLUSIVE_EXT 0x8F10
+#define GL_INCR 0x1E02
+#define GL_INCR_WRAP 0x8507
+#define GL_INFO_LOG_LENGTH 0x8B84
+#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254
+#define GL_INNOCENT_CONTEXT_RESET_KHR 0x8254
+#define GL_INT 0x1404
+#define GL_INT_10_10_10_2_OES 0x8DF7
+#define GL_INT_IMAGE_BUFFER_EXT 0x905C
+#define GL_INT_IMAGE_BUFFER_OES 0x905C
+#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F
+#define GL_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x905F
+#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910C
+#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0
+#define GL_INT_SAMPLER_BUFFER_OES 0x8DD0
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900E
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900E
+#define GL_INT_VEC2 0x8B53
+#define GL_INT_VEC3 0x8B54
+#define GL_INT_VEC4 0x8B55
+#define GL_INVALID_ENUM 0x0500
+#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
+#define GL_INVALID_OPERATION 0x0502
+#define GL_INVALID_VALUE 0x0501
+#define GL_INVERT 0x150A
+#define GL_ISOLINES_EXT 0x8E7A
+#define GL_ISOLINES_OES 0x8E7A
+#define GL_IS_PER_PATCH_EXT 0x92E7
+#define GL_IS_PER_PATCH_OES 0x92E7
+#define GL_KEEP 0x1E00
+#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E
+#define GL_LAST_VERTEX_CONVENTION_OES 0x8E4E
+#define GL_LAYER_PROVOKING_VERTEX_EXT 0x825E
+#define GL_LAYER_PROVOKING_VERTEX_OES 0x825E
+#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E
+#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531
+#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530
+#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F
+#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590
+#define GL_LAYOUT_GENERAL_EXT 0x958D
+#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591
+#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593
+#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592
+#define GL_LEQUAL 0x0203
+#define GL_LESS 0x0201
+#define GL_LIGHTEN_KHR 0x9298
+#define GL_LINEAR 0x2601
+#define GL_LINEAR_MIPMAP_LINEAR 0x2703
+#define GL_LINEAR_MIPMAP_NEAREST 0x2701
+#define GL_LINEAR_TILING_EXT 0x9585
+#define GL_LINES 0x0001
+#define GL_LINES_ADJACENCY_EXT 0x000A
+#define GL_LINES_ADJACENCY_OES 0x000A
+#define GL_LINE_LOOP 0x0002
+#define GL_LINE_STRIP 0x0003
+#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B
+#define GL_LINE_STRIP_ADJACENCY_OES 0x000B
+#define GL_LINE_WIDTH 0x0B21
+#define GL_LINK_STATUS 0x8B82
+#define GL_LOCATION_INDEX_EXT 0x930F
+#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252
+#define GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252
+#define GL_LOWER_LEFT 0x8CA1
+#define GL_LOWER_LEFT_EXT 0x8CA1
+#define GL_LOW_FLOAT 0x8DF0
+#define GL_LOW_INT 0x8DF3
+#define GL_LUID_SIZE_EXT 8
+#define GL_LUMINANCE 0x1909
+#define GL_LUMINANCE16F_EXT 0x881E
+#define GL_LUMINANCE32F_EXT 0x8818
+#define GL_LUMINANCE4_ALPHA4_OES 0x8043
+#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
+#define GL_LUMINANCE8_ALPHA8_OES 0x8045
+#define GL_LUMINANCE8_EXT 0x8040
+#define GL_LUMINANCE8_OES 0x8040
+#define GL_LUMINANCE_ALPHA 0x190A
+#define GL_LUMINANCE_ALPHA16F_EXT 0x881F
+#define GL_LUMINANCE_ALPHA32F_EXT 0x8819
+#define GL_MAP_COHERENT_BIT_EXT 0x0080
+#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010
+#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008
+#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004
+#define GL_MAP_PERSISTENT_BIT_EXT 0x0040
+#define GL_MAP_READ_BIT 0x0001
+#define GL_MAP_READ_BIT_EXT 0x0001
+#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020
+#define GL_MAP_WRITE_BIT 0x0002
+#define GL_MAP_WRITE_BIT_EXT 0x0002
+#define GL_MAX 0x8008
+#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073
+#define GL_MAX_CLIP_DISTANCES_EXT 0x0D32
+#define GL_MAX_CLIP_PLANES 0x0D32
+#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
+#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA
+#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES_EXT 0x82FA
+#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8A32
+#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8A32
+#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E1E
+#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E1E
+#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E1F
+#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E1F
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+#define GL_MAX_CULL_DISTANCES 0x82F9
+#define GL_MAX_CULL_DISTANCES_EXT 0x82F9
+#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C
+#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144
+#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143
+#define GL_MAX_DRAW_BUFFERS_EXT 0x8824
+#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT 0x88FC
+#define GL_MAX_EXT 0x8008
+#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5C
+#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_LAYERS_EXT 0x96DC
+#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_ASPECT_RATIO_EXT 0x96DB
+#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT_EXT 0x96DA
+#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH_EXT 0x96D8
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
+#define GL_MAX_FRAMEBUFFER_LAYERS_EXT 0x9317
+#define GL_MAX_FRAMEBUFFER_LAYERS_OES 0x9317
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT 0x92D5
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_OES 0x92D5
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT 0x92CF
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_OES 0x92CF
+#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT 0x90CD
+#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_OES 0x90CD
+#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT 0x9123
+#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_OES 0x9123
+#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT 0x9124
+#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_OES 0x9124
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_OES 0x8DE0
+#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT 0x8E5A
+#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_OES 0x8E5A
+#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT 0x90D7
+#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_OES 0x90D7
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_OES 0x8C29
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_OES 0x8DE1
+#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT 0x8A2C
+#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_OES 0x8A2C
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8DDF
+#define GL_MAX_LABEL_LENGTH_KHR 0x82E8
+#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2
+#define GL_MAX_PATCH_VERTICES_EXT 0x8E7D
+#define GL_MAX_PATCH_VERTICES_OES 0x8E7D
+#define GL_MAX_RASTER_SAMPLES_EXT 0x9329
+#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
+#define GL_MAX_SAMPLES_EXT 0x8D57
+#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_FAST_SIZE_EXT 0x9650
+#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_SIZE_EXT 0x9651
+#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0
+#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63
+#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT 0x8F67
+#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_EXT 0x9199
+#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_EXT 0x919A
+#define GL_MAX_SPARSE_TEXTURE_SIZE_EXT 0x9198
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT 0x92D3
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_OES 0x92D3
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT 0x92CD
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_OES 0x92CD
+#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT 0x90CB
+#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_OES 0x90CB
+#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT 0x886C
+#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_OES 0x886C
+#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT 0x8E83
+#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_OES 0x8E83
+#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT 0x90D8
+#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_OES 0x90D8
+#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT 0x8E81
+#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_OES 0x8E81
+#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT 0x8E85
+#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_OES 0x8E85
+#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT 0x8E89
+#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_OES 0x8E89
+#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E7F
+#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E7F
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT 0x92D4
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_OES 0x92D4
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT 0x92CE
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_OES 0x92CE
+#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT 0x90CC
+#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_OES 0x90CC
+#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT 0x886D
+#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_OES 0x886D
+#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT 0x8E86
+#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_OES 0x8E86
+#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT 0x90D9
+#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_OES 0x90D9
+#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT 0x8E82
+#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_OES 0x8E82
+#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT 0x8E8A
+#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_OES 0x8E8A
+#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E80
+#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E80
+#define GL_MAX_TESS_GEN_LEVEL_EXT 0x8E7E
+#define GL_MAX_TESS_GEN_LEVEL_OES 0x8E7E
+#define GL_MAX_TESS_PATCH_COMPONENTS_EXT 0x8E84
+#define GL_MAX_TESS_PATCH_COMPONENTS_OES 0x8E84
+#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B
+#define GL_MAX_TEXTURE_BUFFER_SIZE_OES 0x8C2B
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+#define GL_MAX_TEXTURE_SIZE 0x0D33
+#define GL_MAX_VARYING_VECTORS 0x8DFC
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
+#define GL_MAX_VIEWPORTS_OES 0x825B
+#define GL_MAX_VIEWPORT_DIMS 0x0D3A
+#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14
+#define GL_MEDIUM_FLOAT 0x8DF1
+#define GL_MEDIUM_INT 0x8DF4
+#define GL_MIN 0x8007
+#define GL_MIN_EXT 0x8007
+#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5B
+#define GL_MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT_EXT 0x96D9
+#define GL_MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH_EXT 0x96D7
+#define GL_MIN_SAMPLE_SHADING_VALUE_OES 0x8C37
+#define GL_MIRRORED_REPEAT 0x8370
+#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
+#define GL_MULTIPLY_KHR 0x9294
+#define GL_MULTISAMPLE_EXT 0x809D
+#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B
+#define GL_MULTIVIEW_EXT 0x90F1
+#define GL_NEAREST 0x2600
+#define GL_NEAREST_MIPMAP_LINEAR 0x2702
+#define GL_NEAREST_MIPMAP_NEAREST 0x2700
+#define GL_NEGATIVE_ONE_TO_ONE 0x935E
+#define GL_NEGATIVE_ONE_TO_ONE_EXT 0x935E
+#define GL_NEVER 0x0200
+#define GL_NICEST 0x1102
+#define GL_NONE 0
+#define GL_NOTEQUAL 0x0205
+#define GL_NO_ERROR 0
+#define GL_NO_RESET_NOTIFICATION_EXT 0x8261
+#define GL_NO_RESET_NOTIFICATION_KHR 0x8261
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_NUM_DEVICE_UUIDS_EXT 0x9596
+#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE
+#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
+#define GL_NUM_SPARSE_LEVELS_EXT 0x91AA
+#define GL_NUM_SURFACE_COMPRESSION_FIXED_RATES_EXT 0x8F6E
+#define GL_NUM_TILING_TYPES_EXT 0x9582
+#define GL_NUM_VIRTUAL_PAGE_SIZES_EXT 0x91A8
+#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15
+#define GL_ONE 1
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_ONE_MINUS_DST_ALPHA 0x0305
+#define GL_ONE_MINUS_DST_COLOR 0x0307
+#define GL_ONE_MINUS_SRC1_ALPHA_EXT 0x88FB
+#define GL_ONE_MINUS_SRC1_COLOR_EXT 0x88FA
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_ONE_MINUS_SRC_COLOR 0x0301
+#define GL_OPTIMAL_TILING_EXT 0x9584
+#define GL_OUT_OF_MEMORY 0x0505
+#define GL_OVERLAY_KHR 0x9296
+#define GL_PACK_ALIGNMENT 0x0D05
+#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
+#define GL_PALETTE4_RGB5_A1_OES 0x8B94
+#define GL_PALETTE4_RGB8_OES 0x8B90
+#define GL_PALETTE4_RGBA4_OES 0x8B93
+#define GL_PALETTE4_RGBA8_OES 0x8B91
+#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
+#define GL_PALETTE8_RGB5_A1_OES 0x8B99
+#define GL_PALETTE8_RGB8_OES 0x8B95
+#define GL_PALETTE8_RGBA4_OES 0x8B98
+#define GL_PALETTE8_RGBA8_OES 0x8B96
+#define GL_PATCHES_EXT 0x000E
+#define GL_PATCHES_OES 0x000E
+#define GL_PATCH_VERTICES_EXT 0x8E72
+#define GL_PATCH_VERTICES_OES 0x8E72
+#define GL_POINTS 0x0000
+#define GL_POLYGON_OFFSET_CLAMP 0x8E1B
+#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B
+#define GL_POLYGON_OFFSET_FACTOR 0x8038
+#define GL_POLYGON_OFFSET_FILL 0x8037
+#define GL_POLYGON_OFFSET_UNITS 0x2A00
+#define GL_PRIMITIVES_GENERATED_EXT 0x8C87
+#define GL_PRIMITIVES_GENERATED_OES 0x8C87
+#define GL_PRIMITIVE_BOUNDING_BOX_EXT 0x92BE
+#define GL_PRIMITIVE_BOUNDING_BOX_OES 0x92BE
+#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221
+#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED_OES 0x8221
+#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF
+#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
+#define GL_PROGRAM_KHR 0x82E2
+#define GL_PROGRAM_OBJECT_EXT 0x8B40
+#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A
+#define GL_PROGRAM_PIPELINE_KHR 0x82E4
+#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F
+#define GL_PROGRAM_SEPARABLE_EXT 0x8258
+#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B
+#define GL_QUADS_EXT 0x0007
+#define GL_QUADS_OES 0x0007
+#define GL_QUERY_COUNTER_BITS_EXT 0x8864
+#define GL_QUERY_KHR 0x82E3
+#define GL_QUERY_OBJECT_EXT 0x9153
+#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867
+#define GL_QUERY_RESULT_EXT 0x8866
+#define GL_R16F_EXT 0x822D
+#define GL_R16_EXT 0x822A
+#define GL_R16_SNORM_EXT 0x8F98
+#define GL_R32F_EXT 0x822E
+#define GL_R8_EXT 0x8229
+#define GL_R8_SNORM 0x8F94
+#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A
+#define GL_RASTER_MULTISAMPLE_EXT 0x9327
+#define GL_RASTER_SAMPLES_EXT 0x9328
+#define GL_READ_BUFFER_EXT 0x0C02
+#define GL_RED_BITS 0x0D52
+#define GL_RED_EXT 0x1903
+#define GL_REFERENCED_BY_GEOMETRY_SHADER_EXT 0x9309
+#define GL_REFERENCED_BY_GEOMETRY_SHADER_OES 0x9309
+#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT 0x9307
+#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_OES 0x9307
+#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT 0x9308
+#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_OES 0x9308
+#define GL_RENDERBUFFER 0x8D41
+#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
+#define GL_RENDERBUFFER_BINDING 0x8CA7
+#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
+#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
+#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
+#define GL_RENDERBUFFER_HEIGHT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
+#define GL_RENDERBUFFER_RED_SIZE 0x8D50
+#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
+#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
+#define GL_RENDERBUFFER_WIDTH 0x8D42
+#define GL_RENDERER 0x1F01
+#define GL_REPEAT 0x2901
+#define GL_REPLACE 0x1E01
+#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
+#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256
+#define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256
+#define GL_RG16F_EXT 0x822F
+#define GL_RG16_EXT 0x822C
+#define GL_RG16_SNORM_EXT 0x8F99
+#define GL_RG32F_EXT 0x8230
+#define GL_RG8_EXT 0x822B
+#define GL_RG8_SNORM 0x8F95
+#define GL_RGB 0x1907
+#define GL_RGB10_A2_EXT 0x8059
+#define GL_RGB10_EXT 0x8052
+#define GL_RGB16F_EXT 0x881B
+#define GL_RGB16_EXT 0x8054
+#define GL_RGB16_SNORM_EXT 0x8F9A
+#define GL_RGB32F_EXT 0x8815
+#define GL_RGB565 0x8D62
+#define GL_RGB565_OES 0x8D62
+#define GL_RGB5_A1 0x8057
+#define GL_RGB5_A1_OES 0x8057
+#define GL_RGB8_OES 0x8051
+#define GL_RGBA 0x1908
+#define GL_RGBA16F_EXT 0x881A
+#define GL_RGBA16_EXT 0x805B
+#define GL_RGBA16_SNORM_EXT 0x8F9B
+#define GL_RGBA32F_EXT 0x8814
+#define GL_RGBA4 0x8056
+#define GL_RGBA4_OES 0x8056
+#define GL_RGBA8_OES 0x8058
+#define GL_RGBA8_SNORM 0x8F97
+#define GL_RG_EXT 0x8227
+#define GL_SAMPLER 0x82E6
+#define GL_SAMPLER_2D 0x8B5E
+#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910B
+#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62
+#define GL_SAMPLER_3D_OES 0x8B5F
+#define GL_SAMPLER_BUFFER_EXT 0x8DC2
+#define GL_SAMPLER_BUFFER_OES 0x8DC2
+#define GL_SAMPLER_CUBE 0x8B60
+#define GL_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_OES 0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT 0x900D
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_OES 0x900D
+#define GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT 0x8BE7
+#define GL_SAMPLER_EXTERNAL_OES 0x8D66
+#define GL_SAMPLER_KHR 0x82E6
+#define GL_SAMPLES 0x80A9
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F
+#define GL_SAMPLE_BUFFERS 0x80A8
+#define GL_SAMPLE_COVERAGE 0x80A0
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#define GL_SAMPLE_SHADING_OES 0x8C36
+#define GL_SCISSOR_BOX 0x0C10
+#define GL_SCISSOR_TEST 0x0C11
+#define GL_SCREEN_KHR 0x9295
+#define GL_SHADER_BINARY_FORMATS 0x8DF8
+#define GL_SHADER_COMPILER 0x8DFA
+#define GL_SHADER_KHR 0x82E1
+#define GL_SHADER_OBJECT_EXT 0x8B48
+#define GL_SHADER_PIXEL_LOCAL_STORAGE_EXT 0x8F64
+#define GL_SHADER_SOURCE_LENGTH 0x8B88
+#define GL_SHADER_TYPE 0x8B4F
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#define GL_SHADING_RATE_1X1_PIXELS_EXT 0x96A6
+#define GL_SHADING_RATE_1X1_PIXELS_QCOM 0x96A6
+#define GL_SHADING_RATE_1X2_PIXELS_EXT 0x96A7
+#define GL_SHADING_RATE_1X2_PIXELS_QCOM 0x96A7
+#define GL_SHADING_RATE_1X4_PIXELS_EXT 0x96AA
+#define GL_SHADING_RATE_1X4_PIXELS_QCOM 0x96AA
+#define GL_SHADING_RATE_2X1_PIXELS_EXT 0x96A8
+#define GL_SHADING_RATE_2X1_PIXELS_QCOM 0x96A8
+#define GL_SHADING_RATE_2X2_PIXELS_EXT 0x96A9
+#define GL_SHADING_RATE_2X2_PIXELS_QCOM 0x96A9
+#define GL_SHADING_RATE_2X4_PIXELS_EXT 0x96AD
+#define GL_SHADING_RATE_2X4_PIXELS_QCOM 0x96AD
+#define GL_SHADING_RATE_4X1_PIXELS_EXT 0x96AB
+#define GL_SHADING_RATE_4X1_PIXELS_QCOM 0x96AB
+#define GL_SHADING_RATE_4X2_PIXELS_EXT 0x96AC
+#define GL_SHADING_RATE_4X2_PIXELS_QCOM 0x96AC
+#define GL_SHADING_RATE_4X4_PIXELS_EXT 0x96AE
+#define GL_SHADING_RATE_4X4_PIXELS_QCOM 0x96AE
+#define GL_SHADING_RATE_ATTACHMENT_EXT 0x96D1
+#define GL_SHADING_RATE_EXT 0x96D0
+#define GL_SHORT 0x1402
+#define GL_SKIP_DECODE_EXT 0x8A4A
+#define GL_SOFTLIGHT_KHR 0x929C
+#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_EXT 0x91A9
+#define GL_SR8_EXT 0x8FBD
+#define GL_SRC1_ALPHA_EXT 0x8589
+#define GL_SRC1_COLOR_EXT 0x88F9
+#define GL_SRC_ALPHA 0x0302
+#define GL_SRC_ALPHA_SATURATE 0x0308
+#define GL_SRC_ALPHA_SATURATE_EXT 0x0308
+#define GL_SRC_COLOR 0x0300
+#define GL_SRG8_EXT 0x8FBE
+#define GL_SRGB8_ALPHA8_EXT 0x8C43
+#define GL_SRGB_ALPHA_EXT 0x8C42
+#define GL_SRGB_EXT 0x8C40
+#define GL_STACK_OVERFLOW_KHR 0x0503
+#define GL_STACK_UNDERFLOW_KHR 0x0504
+#define GL_STATIC_DRAW 0x88E4
+#define GL_STENCIL_ATTACHMENT 0x8D20
+#define GL_STENCIL_BACK_FAIL 0x8801
+#define GL_STENCIL_BACK_FUNC 0x8800
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
+#define GL_STENCIL_BACK_REF 0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
+#define GL_STENCIL_BITS 0x0D57
+#define GL_STENCIL_BUFFER_BIT 0x00000400
+#define GL_STENCIL_CLEAR_VALUE 0x0B91
+#define GL_STENCIL_EXT 0x1802
+#define GL_STENCIL_FAIL 0x0B94
+#define GL_STENCIL_FUNC 0x0B92
+#define GL_STENCIL_INDEX1_OES 0x8D46
+#define GL_STENCIL_INDEX4_OES 0x8D47
+#define GL_STENCIL_INDEX8 0x8D48
+#define GL_STENCIL_INDEX8_OES 0x8D48
+#define GL_STENCIL_INDEX_OES 0x1901
+#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
+#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
+#define GL_STENCIL_REF 0x0B97
+#define GL_STENCIL_TEST 0x0B90
+#define GL_STENCIL_VALUE_MASK 0x0B93
+#define GL_STENCIL_WRITEMASK 0x0B98
+#define GL_STREAM_DRAW 0x88E0
+#define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004
+#define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008
+#define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001
+#define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040
+#define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080
+#define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010
+#define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020
+#define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002
+#define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535
+#define GL_SUBGROUP_SIZE_KHR 0x9532
+#define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534
+#define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533
+#define GL_SUBPIXEL_BITS 0x0D50
+#define GL_SURFACE_COMPRESSION_EXT 0x96C0
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_10BPC_EXT 0x96CD
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_11BPC_EXT 0x96CE
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_12BPC_EXT 0x96CF
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_1BPC_EXT 0x96C4
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_2BPC_EXT 0x96C5
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_3BPC_EXT 0x96C6
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_4BPC_EXT 0x96C7
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_5BPC_EXT 0x96C8
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_6BPC_EXT 0x96C9
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_7BPC_EXT 0x96CA
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_8BPC_EXT 0x96CB
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_9BPC_EXT 0x96CC
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_DEFAULT_EXT 0x96C2
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_NONE_EXT 0x96C1
+#define GL_TESS_CONTROL_OUTPUT_VERTICES_EXT 0x8E75
+#define GL_TESS_CONTROL_OUTPUT_VERTICES_OES 0x8E75
+#define GL_TESS_CONTROL_SHADER_BIT_EXT 0x00000008
+#define GL_TESS_CONTROL_SHADER_BIT_OES 0x00000008
+#define GL_TESS_CONTROL_SHADER_EXT 0x8E88
+#define GL_TESS_CONTROL_SHADER_OES 0x8E88
+#define GL_TESS_EVALUATION_SHADER_BIT_EXT 0x00000010
+#define GL_TESS_EVALUATION_SHADER_BIT_OES 0x00000010
+#define GL_TESS_EVALUATION_SHADER_EXT 0x8E87
+#define GL_TESS_EVALUATION_SHADER_OES 0x8E87
+#define GL_TESS_GEN_MODE_EXT 0x8E76
+#define GL_TESS_GEN_MODE_OES 0x8E76
+#define GL_TESS_GEN_POINT_MODE_EXT 0x8E79
+#define GL_TESS_GEN_POINT_MODE_OES 0x8E79
+#define GL_TESS_GEN_SPACING_EXT 0x8E77
+#define GL_TESS_GEN_SPACING_OES 0x8E77
+#define GL_TESS_GEN_VERTEX_ORDER_EXT 0x8E78
+#define GL_TESS_GEN_VERTEX_ORDER_OES 0x8E78
+#define GL_TEXTURE 0x1702
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#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_TEXTURE2 0x84C2
+#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_TEXTURE3 0x84C3
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+#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_TEXTURE_2D 0x0DE1
+#define GL_TEXTURE_2D_ARRAY 0x8C1A
+#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES 0x9102
+#define GL_TEXTURE_3D 0x806F
+#define GL_TEXTURE_3D_OES 0x806F
+#define GL_TEXTURE_ASTC_DECODE_PRECISION_EXT 0x8F69
+#define GL_TEXTURE_BINDING_2D 0x8069
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES 0x9105
+#define GL_TEXTURE_BINDING_3D_OES 0x806A
+#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C
+#define GL_TEXTURE_BINDING_BUFFER_OES 0x8C2C
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT 0x900A
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_OES 0x900A
+#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
+#define GL_TEXTURE_BORDER_COLOR_EXT 0x1004
+#define GL_TEXTURE_BORDER_COLOR_OES 0x1004
+#define GL_TEXTURE_BUFFER_BINDING_EXT 0x8C2A
+#define GL_TEXTURE_BUFFER_BINDING_OES 0x8C2A
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_OES 0x8C2D
+#define GL_TEXTURE_BUFFER_EXT 0x8C2A
+#define GL_TEXTURE_BUFFER_OES 0x8C2A
+#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT 0x919F
+#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_OES 0x919F
+#define GL_TEXTURE_BUFFER_OFFSET_EXT 0x919D
+#define GL_TEXTURE_BUFFER_OFFSET_OES 0x919D
+#define GL_TEXTURE_BUFFER_SIZE_EXT 0x919E
+#define GL_TEXTURE_BUFFER_SIZE_OES 0x919E
+#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D
+#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#define GL_TEXTURE_CUBE_MAP_ARRAY_EXT 0x9009
+#define GL_TEXTURE_CUBE_MAP_ARRAY_OES 0x9009
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#define GL_TEXTURE_EXTERNAL_OES 0x8D65
+#define GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT 0x8FBF
+#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F
+#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_TEXTURE_PROTECTED_EXT 0x8BFA
+#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366
+#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366
+#define GL_TEXTURE_SPARSE_EXT 0x91A6
+#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48
+#define GL_TEXTURE_TILING_EXT 0x9580
+#define GL_TEXTURE_VIEW_MIN_LAYER_EXT 0x82DD
+#define GL_TEXTURE_VIEW_MIN_LAYER_OES 0x82DD
+#define GL_TEXTURE_VIEW_MIN_LEVEL_EXT 0x82DB
+#define GL_TEXTURE_VIEW_MIN_LEVEL_OES 0x82DB
+#define GL_TEXTURE_VIEW_NUM_LAYERS_EXT 0x82DE
+#define GL_TEXTURE_VIEW_NUM_LAYERS_OES 0x82DE
+#define GL_TEXTURE_VIEW_NUM_LEVELS_EXT 0x82DC
+#define GL_TEXTURE_VIEW_NUM_LEVELS_OES 0x82DC
+#define GL_TEXTURE_WRAP_R_OES 0x8072
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+#define GL_TILING_TYPES_EXT 0x9583
+#define GL_TIMESTAMP_EXT 0x8E28
+#define GL_TIME_ELAPSED_EXT 0x88BF
+#define GL_TRANSFORM_FEEDBACK 0x8E22
+#define GL_TRIANGLES 0x0004
+#define GL_TRIANGLES_ADJACENCY_EXT 0x000C
+#define GL_TRIANGLES_ADJACENCY_OES 0x000C
+#define GL_TRIANGLE_FAN 0x0006
+#define GL_TRIANGLE_STRIP 0x0005
+#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D
+#define GL_TRIANGLE_STRIP_ADJACENCY_OES 0x000D
+#define GL_TRUE 1
+#define GL_UNDEFINED_VERTEX_EXT 0x8260
+#define GL_UNDEFINED_VERTEX_OES 0x8260
+#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255
+#define GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255
+#define GL_UNPACK_ALIGNMENT 0x0CF5
+#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2
+#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4
+#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_UNSIGNED_INT 0x1405
+#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6
+#define GL_UNSIGNED_INT_24_8_OES 0x84FA
+#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368
+#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067
+#define GL_UNSIGNED_INT_IMAGE_BUFFER_OES 0x9067
+#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A
+#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x906A
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910D
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_OES 0x8DD8
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900F
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900F
+#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17
+#define GL_UNSIGNED_SHORT 0x1403
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#define GL_UPPER_LEFT 0x8CA2
+#define GL_UPPER_LEFT_EXT 0x8CA2
+#define GL_UUID_SIZE_EXT 16
+#define GL_VALIDATE_STATUS 0x8B83
+#define GL_VENDOR 0x1F00
+#define GL_VERSION 0x1F02
+#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5
+#define GL_VERTEX_ARRAY_KHR 0x8074
+#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_VERTEX_SHADER_BIT_EXT 0x00000001
+#define GL_VIEWPORT 0x0BA2
+#define GL_VIEWPORT_BOUNDS_RANGE_OES 0x825D
+#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX_OES 0x825F
+#define GL_VIEWPORT_SUBPIXEL_BITS_OES 0x825C
+#define GL_VIRTUAL_PAGE_SIZE_INDEX_EXT 0x91A7
+#define GL_VIRTUAL_PAGE_SIZE_X_EXT 0x9195
+#define GL_VIRTUAL_PAGE_SIZE_Y_EXT 0x9196
+#define GL_VIRTUAL_PAGE_SIZE_Z_EXT 0x9197
+#define GL_WEIGHTED_AVERAGE_ARB 0x9367
+#define GL_WEIGHTED_AVERAGE_EXT 0x9367
+#define GL_WINDOW_RECTANGLE_EXT 0x8F12
+#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13
+#define GL_WRITE_ONLY_OES 0x88B9
+#define GL_ZERO 0
+#define GL_ZERO_TO_ONE 0x935F
+#define GL_ZERO_TO_ONE_EXT 0x935F
+
+
+#ifndef __khrplatform_h_
+#define __khrplatform_h_
+
+/*
+** Copyright (c) 2008-2018 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Khronos platform-specific types and definitions.
+ *
+ * The master copy of khrplatform.h is maintained in the Khronos EGL
+ * Registry repository at https://github.com/KhronosGroup/EGL-Registry
+ * The last semantic modification to khrplatform.h was at commit ID:
+ * 67a3e0864c2d75ea5287b9f3d2eb74a745936692
+ *
+ * Adopters may modify this file to suit their platform. Adopters are
+ * encouraged to submit platform specific modifications to the Khronos
+ * group so that they can be included in future versions of this file.
+ * Please submit changes by filing pull requests or issues on
+ * the EGL Registry repository linked above.
+ *
+ *
+ * See the Implementer's Guidelines for information about where this file
+ * should be located on your system and for more details of its use:
+ * http://www.khronos.org/registry/implementers_guide.pdf
+ *
+ * This file should be included as
+ * #include
+ * by Khronos client API header files that use its types and defines.
+ *
+ * The types in khrplatform.h should only be used to define API-specific types.
+ *
+ * Types defined in khrplatform.h:
+ * khronos_int8_t signed 8 bit
+ * khronos_uint8_t unsigned 8 bit
+ * khronos_int16_t signed 16 bit
+ * khronos_uint16_t unsigned 16 bit
+ * khronos_int32_t signed 32 bit
+ * khronos_uint32_t unsigned 32 bit
+ * khronos_int64_t signed 64 bit
+ * khronos_uint64_t unsigned 64 bit
+ * khronos_intptr_t signed same number of bits as a pointer
+ * khronos_uintptr_t unsigned same number of bits as a pointer
+ * khronos_ssize_t signed size
+ * khronos_usize_t unsigned size
+ * khronos_float_t signed 32 bit floating point
+ * khronos_time_ns_t unsigned 64 bit time in nanoseconds
+ * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
+ * nanoseconds
+ * khronos_stime_nanoseconds_t signed time interval in nanoseconds
+ * khronos_boolean_enum_t enumerated boolean type. This should
+ * only be used as a base type when a client API's boolean type is
+ * an enum. Client APIs which use an integer or other type for
+ * booleans cannot use this as the base type for their boolean.
+ *
+ * Tokens defined in khrplatform.h:
+ *
+ * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
+ *
+ * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
+ * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
+ *
+ * Calling convention macros defined in this file:
+ * KHRONOS_APICALL
+ * KHRONOS_GLAD_API_PTR
+ * KHRONOS_APIATTRIBUTES
+ *
+ * These may be used in function prototypes as:
+ *
+ * KHRONOS_APICALL void KHRONOS_GLAD_API_PTR funcname(
+ * int arg1,
+ * int arg2) KHRONOS_APIATTRIBUTES;
+ */
+
+#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
+# define KHRONOS_STATIC 1
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APICALL
+ *-------------------------------------------------------------------------
+ * This precedes the return type of the function in the function prototype.
+ */
+#if defined(KHRONOS_STATIC)
+ /* If the preprocessor constant KHRONOS_STATIC is defined, make the
+ * header compatible with static linking. */
+# define KHRONOS_APICALL
+#elif defined(_WIN32)
+# define KHRONOS_APICALL __declspec(dllimport)
+#elif defined (__SYMBIAN32__)
+# define KHRONOS_APICALL IMPORT_C
+#elif defined(__ANDROID__)
+# define KHRONOS_APICALL __attribute__((visibility("default")))
+#else
+# define KHRONOS_APICALL
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_GLAD_API_PTR
+ *-------------------------------------------------------------------------
+ * This follows the return type of the function and precedes the function
+ * name in the function prototype.
+ */
+#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
+ /* Win32 but not WinCE */
+# define KHRONOS_GLAD_API_PTR __stdcall
+#else
+# define KHRONOS_GLAD_API_PTR
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIATTRIBUTES
+ *-------------------------------------------------------------------------
+ * This follows the closing parenthesis of the function prototype arguments.
+ */
+#if defined (__ARMCC_2__)
+#define KHRONOS_APIATTRIBUTES __softfp
+#else
+#define KHRONOS_APIATTRIBUTES
+#endif
+
+/*-------------------------------------------------------------------------
+ * basic type definitions
+ *-----------------------------------------------------------------------*/
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
+
+
+/*
+ * Using
+ */
+#include
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+/*
+ * To support platform where unsigned long cannot be used interchangeably with
+ * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
+ * Ideally, we could just use (u)intptr_t everywhere, but this could result in
+ * ABI breakage if khronos_uintptr_t is changed from unsigned long to
+ * unsigned long long or similar (this results in different C++ name mangling).
+ * To avoid changes for existing platforms, we restrict usage of intptr_t to
+ * platforms where the size of a pointer is larger than the size of long.
+ */
+#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
+#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
+#define KHRONOS_USE_INTPTR_T
+#endif
+#endif
+
+#elif defined(__VMS ) || defined(__sgi)
+
+/*
+ * Using
+ */
+#include
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
+
+/*
+ * Win32
+ */
+typedef __int32 khronos_int32_t;
+typedef unsigned __int32 khronos_uint32_t;
+typedef __int64 khronos_int64_t;
+typedef unsigned __int64 khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(__sun__) || defined(__digital__)
+
+/*
+ * Sun or Digital
+ */
+typedef int khronos_int32_t;
+typedef unsigned int khronos_uint32_t;
+#if defined(__arch64__) || defined(_LP64)
+typedef long int khronos_int64_t;
+typedef unsigned long int khronos_uint64_t;
+#else
+typedef long long int khronos_int64_t;
+typedef unsigned long long int khronos_uint64_t;
+#endif /* __arch64__ */
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif 0
+
+/*
+ * Hypothetical platform with no float or int64 support
+ */
+typedef int khronos_int32_t;
+typedef unsigned int khronos_uint32_t;
+#define KHRONOS_SUPPORT_INT64 0
+#define KHRONOS_SUPPORT_FLOAT 0
+
+#else
+
+/*
+ * Generic fallback
+ */
+#include
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#endif
+
+
+/*
+ * Types that are (so far) the same on all platforms
+ */
+typedef signed char khronos_int8_t;
+typedef unsigned char khronos_uint8_t;
+typedef signed short int khronos_int16_t;
+typedef unsigned short int khronos_uint16_t;
+
+/*
+ * Types that differ between LLP64 and LP64 architectures - in LLP64,
+ * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
+ * to be the only LLP64 architecture in current use.
+ */
+#ifdef KHRONOS_USE_INTPTR_T
+typedef intptr_t khronos_intptr_t;
+typedef uintptr_t khronos_uintptr_t;
+#elif defined(_WIN64)
+typedef signed long long int khronos_intptr_t;
+typedef unsigned long long int khronos_uintptr_t;
+#else
+typedef signed long int khronos_intptr_t;
+typedef unsigned long int khronos_uintptr_t;
+#endif
+
+#if defined(_WIN64)
+typedef signed long long int khronos_ssize_t;
+typedef unsigned long long int khronos_usize_t;
+#else
+typedef signed long int khronos_ssize_t;
+typedef unsigned long int khronos_usize_t;
+#endif
+
+#if KHRONOS_SUPPORT_FLOAT
+/*
+ * Float type
+ */
+typedef float khronos_float_t;
+#endif
+
+#if KHRONOS_SUPPORT_INT64
+/* Time types
+ *
+ * These types can be used to represent a time interval in nanoseconds or
+ * an absolute Unadjusted System Time. Unadjusted System Time is the number
+ * of nanoseconds since some arbitrary system event (e.g. since the last
+ * time the system booted). The Unadjusted System Time is an unsigned
+ * 64 bit value that wraps back to 0 every 584 years. Time intervals
+ * may be either signed or unsigned.
+ */
+typedef khronos_uint64_t khronos_utime_nanoseconds_t;
+typedef khronos_int64_t khronos_stime_nanoseconds_t;
+#endif
+
+/*
+ * Dummy value used to pad enum types to 32 bits.
+ */
+#ifndef KHRONOS_MAX_ENUM
+#define KHRONOS_MAX_ENUM 0x7FFFFFFF
+#endif
+
+/*
+ * Enumerated boolean type
+ *
+ * Values other than zero should be considered to be true. Therefore
+ * comparisons should not be made against KHRONOS_TRUE.
+ */
+typedef enum {
+ KHRONOS_FALSE = 0,
+ KHRONOS_TRUE = 1,
+ KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
+} khronos_boolean_enum_t;
+
+#endif /* __khrplatform_h_ */
+typedef unsigned int GLenum;
+typedef unsigned char GLboolean;
+typedef unsigned int GLbitfield;
+typedef void GLvoid;
+typedef khronos_int8_t GLbyte;
+typedef khronos_uint8_t GLubyte;
+typedef khronos_int16_t GLshort;
+typedef khronos_uint16_t GLushort;
+typedef int GLint;
+typedef unsigned int GLuint;
+typedef khronos_int32_t GLclampx;
+typedef int GLsizei;
+typedef khronos_float_t GLfloat;
+typedef khronos_float_t GLclampf;
+typedef double GLdouble;
+typedef double GLclampd;
+typedef void *GLeglClientBufferEXT;
+typedef void *GLeglImageOES;
+typedef char GLchar;
+typedef char GLcharARB;
+#ifdef __APPLE__
+typedef void *GLhandleARB;
+#else
+typedef unsigned int GLhandleARB;
+#endif
+typedef khronos_uint16_t GLhalf;
+typedef khronos_uint16_t GLhalfARB;
+typedef khronos_int32_t GLfixed;
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef khronos_intptr_t GLintptr;
+#else
+typedef khronos_intptr_t GLintptr;
+#endif
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef khronos_intptr_t GLintptrARB;
+#else
+typedef khronos_intptr_t GLintptrARB;
+#endif
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef khronos_ssize_t GLsizeiptr;
+#else
+typedef khronos_ssize_t GLsizeiptr;
+#endif
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef khronos_ssize_t GLsizeiptrARB;
+#else
+typedef khronos_ssize_t GLsizeiptrARB;
+#endif
+typedef khronos_int64_t GLint64;
+typedef khronos_int64_t GLint64EXT;
+typedef khronos_uint64_t GLuint64;
+typedef khronos_uint64_t GLuint64EXT;
+typedef struct __GLsync *GLsync;
+struct _cl_context;
+struct _cl_event;
+typedef void (GLAD_API_PTR *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+typedef void (GLAD_API_PTR *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+typedef void (GLAD_API_PTR *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+typedef void (GLAD_API_PTR *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
+typedef unsigned short GLhalfNV;
+typedef GLintptr GLvdpauSurfaceNV;
+typedef void (GLAD_API_PTR *GLVULKANPROCNV)(void);
+
+
+#define GL_ES_VERSION_2_0 1
+GLAD_API_CALL int GLAD_GL_ES_VERSION_2_0;
+#define GL_EXT_EGL_image_array 1
+GLAD_API_CALL int GLAD_GL_EXT_EGL_image_array;
+#define GL_EXT_EGL_image_storage 1
+GLAD_API_CALL int GLAD_GL_EXT_EGL_image_storage;
+#define GL_EXT_EGL_image_storage_compression 1
+GLAD_API_CALL int GLAD_GL_EXT_EGL_image_storage_compression;
+#define GL_EXT_YUV_target 1
+GLAD_API_CALL int GLAD_GL_EXT_YUV_target;
+#define GL_EXT_base_instance 1
+GLAD_API_CALL int GLAD_GL_EXT_base_instance;
+#define GL_EXT_blend_func_extended 1
+GLAD_API_CALL int GLAD_GL_EXT_blend_func_extended;
+#define GL_EXT_blend_minmax 1
+GLAD_API_CALL int GLAD_GL_EXT_blend_minmax;
+#define GL_EXT_buffer_storage 1
+GLAD_API_CALL int GLAD_GL_EXT_buffer_storage;
+#define GL_EXT_clear_texture 1
+GLAD_API_CALL int GLAD_GL_EXT_clear_texture;
+#define GL_EXT_clip_control 1
+GLAD_API_CALL int GLAD_GL_EXT_clip_control;
+#define GL_EXT_clip_cull_distance 1
+GLAD_API_CALL int GLAD_GL_EXT_clip_cull_distance;
+#define GL_EXT_color_buffer_float 1
+GLAD_API_CALL int GLAD_GL_EXT_color_buffer_float;
+#define GL_EXT_color_buffer_half_float 1
+GLAD_API_CALL int GLAD_GL_EXT_color_buffer_half_float;
+#define GL_EXT_conservative_depth 1
+GLAD_API_CALL int GLAD_GL_EXT_conservative_depth;
+#define GL_EXT_copy_image 1
+GLAD_API_CALL int GLAD_GL_EXT_copy_image;
+#define GL_EXT_debug_label 1
+GLAD_API_CALL int GLAD_GL_EXT_debug_label;
+#define GL_EXT_debug_marker 1
+GLAD_API_CALL int GLAD_GL_EXT_debug_marker;
+#define GL_EXT_depth_clamp 1
+GLAD_API_CALL int GLAD_GL_EXT_depth_clamp;
+#define GL_EXT_discard_framebuffer 1
+GLAD_API_CALL int GLAD_GL_EXT_discard_framebuffer;
+#define GL_EXT_disjoint_timer_query 1
+GLAD_API_CALL int GLAD_GL_EXT_disjoint_timer_query;
+#define GL_EXT_draw_buffers 1
+GLAD_API_CALL int GLAD_GL_EXT_draw_buffers;
+#define GL_EXT_draw_buffers_indexed 1
+GLAD_API_CALL int GLAD_GL_EXT_draw_buffers_indexed;
+#define GL_EXT_draw_elements_base_vertex 1
+GLAD_API_CALL int GLAD_GL_EXT_draw_elements_base_vertex;
+#define GL_EXT_draw_instanced 1
+GLAD_API_CALL int GLAD_GL_EXT_draw_instanced;
+#define GL_EXT_draw_transform_feedback 1
+GLAD_API_CALL int GLAD_GL_EXT_draw_transform_feedback;
+#define GL_EXT_external_buffer 1
+GLAD_API_CALL int GLAD_GL_EXT_external_buffer;
+#define GL_EXT_float_blend 1
+GLAD_API_CALL int GLAD_GL_EXT_float_blend;
+#define GL_EXT_fragment_shading_rate 1
+GLAD_API_CALL int GLAD_GL_EXT_fragment_shading_rate;
+#define GL_EXT_geometry_point_size 1
+GLAD_API_CALL int GLAD_GL_EXT_geometry_point_size;
+#define GL_EXT_geometry_shader 1
+GLAD_API_CALL int GLAD_GL_EXT_geometry_shader;
+#define GL_EXT_gpu_shader5 1
+GLAD_API_CALL int GLAD_GL_EXT_gpu_shader5;
+#define GL_EXT_instanced_arrays 1
+GLAD_API_CALL int GLAD_GL_EXT_instanced_arrays;
+#define GL_EXT_map_buffer_range 1
+GLAD_API_CALL int GLAD_GL_EXT_map_buffer_range;
+#define GL_EXT_memory_object 1
+GLAD_API_CALL int GLAD_GL_EXT_memory_object;
+#define GL_EXT_memory_object_fd 1
+GLAD_API_CALL int GLAD_GL_EXT_memory_object_fd;
+#define GL_EXT_memory_object_win32 1
+GLAD_API_CALL int GLAD_GL_EXT_memory_object_win32;
+#define GL_EXT_multi_draw_arrays 1
+GLAD_API_CALL int GLAD_GL_EXT_multi_draw_arrays;
+#define GL_EXT_multi_draw_indirect 1
+GLAD_API_CALL int GLAD_GL_EXT_multi_draw_indirect;
+#define GL_EXT_multisampled_compatibility 1
+GLAD_API_CALL int GLAD_GL_EXT_multisampled_compatibility;
+#define GL_EXT_multisampled_render_to_texture 1
+GLAD_API_CALL int GLAD_GL_EXT_multisampled_render_to_texture;
+#define GL_EXT_multisampled_render_to_texture2 1
+GLAD_API_CALL int GLAD_GL_EXT_multisampled_render_to_texture2;
+#define GL_EXT_multiview_draw_buffers 1
+GLAD_API_CALL int GLAD_GL_EXT_multiview_draw_buffers;
+#define GL_EXT_multiview_tessellation_geometry_shader 1
+GLAD_API_CALL int GLAD_GL_EXT_multiview_tessellation_geometry_shader;
+#define GL_EXT_multiview_texture_multisample 1
+GLAD_API_CALL int GLAD_GL_EXT_multiview_texture_multisample;
+#define GL_EXT_multiview_timer_query 1
+GLAD_API_CALL int GLAD_GL_EXT_multiview_timer_query;
+#define GL_EXT_occlusion_query_boolean 1
+GLAD_API_CALL int GLAD_GL_EXT_occlusion_query_boolean;
+#define GL_EXT_polygon_offset_clamp 1
+GLAD_API_CALL int GLAD_GL_EXT_polygon_offset_clamp;
+#define GL_EXT_post_depth_coverage 1
+GLAD_API_CALL int GLAD_GL_EXT_post_depth_coverage;
+#define GL_EXT_primitive_bounding_box 1
+GLAD_API_CALL int GLAD_GL_EXT_primitive_bounding_box;
+#define GL_EXT_protected_textures 1
+GLAD_API_CALL int GLAD_GL_EXT_protected_textures;
+#define GL_EXT_pvrtc_sRGB 1
+GLAD_API_CALL int GLAD_GL_EXT_pvrtc_sRGB;
+#define GL_EXT_raster_multisample 1
+GLAD_API_CALL int GLAD_GL_EXT_raster_multisample;
+#define GL_EXT_read_format_bgra 1
+GLAD_API_CALL int GLAD_GL_EXT_read_format_bgra;
+#define GL_EXT_render_snorm 1
+GLAD_API_CALL int GLAD_GL_EXT_render_snorm;
+#define GL_EXT_robustness 1
+GLAD_API_CALL int GLAD_GL_EXT_robustness;
+#define GL_EXT_sRGB 1
+GLAD_API_CALL int GLAD_GL_EXT_sRGB;
+#define GL_EXT_sRGB_write_control 1
+GLAD_API_CALL int GLAD_GL_EXT_sRGB_write_control;
+#define GL_EXT_semaphore 1
+GLAD_API_CALL int GLAD_GL_EXT_semaphore;
+#define GL_EXT_semaphore_fd 1
+GLAD_API_CALL int GLAD_GL_EXT_semaphore_fd;
+#define GL_EXT_semaphore_win32 1
+GLAD_API_CALL int GLAD_GL_EXT_semaphore_win32;
+#define GL_EXT_separate_depth_stencil 1
+GLAD_API_CALL int GLAD_GL_EXT_separate_depth_stencil;
+#define GL_EXT_separate_shader_objects 1
+GLAD_API_CALL int GLAD_GL_EXT_separate_shader_objects;
+#define GL_EXT_shader_framebuffer_fetch 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_framebuffer_fetch;
+#define GL_EXT_shader_framebuffer_fetch_non_coherent 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_framebuffer_fetch_non_coherent;
+#define GL_EXT_shader_group_vote 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_group_vote;
+#define GL_EXT_shader_implicit_conversions 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_implicit_conversions;
+#define GL_EXT_shader_integer_mix 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_integer_mix;
+#define GL_EXT_shader_io_blocks 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_io_blocks;
+#define GL_EXT_shader_non_constant_global_initializers 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_non_constant_global_initializers;
+#define GL_EXT_shader_pixel_local_storage 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_pixel_local_storage;
+#define GL_EXT_shader_pixel_local_storage2 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_pixel_local_storage2;
+#define GL_EXT_shader_samples_identical 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_samples_identical;
+#define GL_EXT_shader_texture_lod 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_texture_lod;
+#define GL_EXT_shadow_samplers 1
+GLAD_API_CALL int GLAD_GL_EXT_shadow_samplers;
+#define GL_EXT_sparse_texture 1
+GLAD_API_CALL int GLAD_GL_EXT_sparse_texture;
+#define GL_EXT_sparse_texture2 1
+GLAD_API_CALL int GLAD_GL_EXT_sparse_texture2;
+#define GL_EXT_tessellation_point_size 1
+GLAD_API_CALL int GLAD_GL_EXT_tessellation_point_size;
+#define GL_EXT_tessellation_shader 1
+GLAD_API_CALL int GLAD_GL_EXT_tessellation_shader;
+#define GL_EXT_texture_border_clamp 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_border_clamp;
+#define GL_EXT_texture_buffer 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_buffer;
+#define GL_EXT_texture_compression_astc_decode_mode 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_compression_astc_decode_mode;
+#define GL_EXT_texture_compression_bptc 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_compression_bptc;
+#define GL_EXT_texture_compression_dxt1 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_compression_dxt1;
+#define GL_EXT_texture_compression_rgtc 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_compression_rgtc;
+#define GL_EXT_texture_compression_s3tc 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_compression_s3tc;
+#define GL_EXT_texture_compression_s3tc_srgb 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_compression_s3tc_srgb;
+#define GL_EXT_texture_cube_map_array 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_cube_map_array;
+#define GL_EXT_texture_filter_anisotropic 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_filter_anisotropic;
+#define GL_EXT_texture_filter_minmax 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_filter_minmax;
+#define GL_EXT_texture_format_BGRA8888 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_format_BGRA8888;
+#define GL_EXT_texture_format_sRGB_override 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_format_sRGB_override;
+#define GL_EXT_texture_mirror_clamp_to_edge 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_mirror_clamp_to_edge;
+#define GL_EXT_texture_norm16 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_norm16;
+#define GL_EXT_texture_query_lod 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_query_lod;
+#define GL_EXT_texture_rg 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_rg;
+#define GL_EXT_texture_sRGB_R8 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_sRGB_R8;
+#define GL_EXT_texture_sRGB_RG8 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_sRGB_RG8;
+#define GL_EXT_texture_sRGB_decode 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_sRGB_decode;
+#define GL_EXT_texture_shadow_lod 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_shadow_lod;
+#define GL_EXT_texture_storage 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_storage;
+#define GL_EXT_texture_storage_compression 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_storage_compression;
+#define GL_EXT_texture_type_2_10_10_10_REV 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_type_2_10_10_10_REV;
+#define GL_EXT_texture_view 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_view;
+#define GL_EXT_unpack_subimage 1
+GLAD_API_CALL int GLAD_GL_EXT_unpack_subimage;
+#define GL_EXT_win32_keyed_mutex 1
+GLAD_API_CALL int GLAD_GL_EXT_win32_keyed_mutex;
+#define GL_EXT_window_rectangles 1
+GLAD_API_CALL int GLAD_GL_EXT_window_rectangles;
+#define GL_KHR_blend_equation_advanced 1
+GLAD_API_CALL int GLAD_GL_KHR_blend_equation_advanced;
+#define GL_KHR_blend_equation_advanced_coherent 1
+GLAD_API_CALL int GLAD_GL_KHR_blend_equation_advanced_coherent;
+#define GL_KHR_context_flush_control 1
+GLAD_API_CALL int GLAD_GL_KHR_context_flush_control;
+#define GL_KHR_debug 1
+GLAD_API_CALL int GLAD_GL_KHR_debug;
+#define GL_KHR_no_error 1
+GLAD_API_CALL int GLAD_GL_KHR_no_error;
+#define GL_KHR_parallel_shader_compile 1
+GLAD_API_CALL int GLAD_GL_KHR_parallel_shader_compile;
+#define GL_KHR_robust_buffer_access_behavior 1
+GLAD_API_CALL int GLAD_GL_KHR_robust_buffer_access_behavior;
+#define GL_KHR_robustness 1
+GLAD_API_CALL int GLAD_GL_KHR_robustness;
+#define GL_KHR_shader_subgroup 1
+GLAD_API_CALL int GLAD_GL_KHR_shader_subgroup;
+#define GL_KHR_texture_compression_astc_hdr 1
+GLAD_API_CALL int GLAD_GL_KHR_texture_compression_astc_hdr;
+#define GL_KHR_texture_compression_astc_ldr 1
+GLAD_API_CALL int GLAD_GL_KHR_texture_compression_astc_ldr;
+#define GL_KHR_texture_compression_astc_sliced_3d 1
+GLAD_API_CALL int GLAD_GL_KHR_texture_compression_astc_sliced_3d;
+#define GL_OES_EGL_image 1
+GLAD_API_CALL int GLAD_GL_OES_EGL_image;
+#define GL_OES_EGL_image_external 1
+GLAD_API_CALL int GLAD_GL_OES_EGL_image_external;
+#define GL_OES_EGL_image_external_essl3 1
+GLAD_API_CALL int GLAD_GL_OES_EGL_image_external_essl3;
+#define GL_OES_compressed_ETC1_RGB8_sub_texture 1
+GLAD_API_CALL int GLAD_GL_OES_compressed_ETC1_RGB8_sub_texture;
+#define GL_OES_compressed_ETC1_RGB8_texture 1
+GLAD_API_CALL int GLAD_GL_OES_compressed_ETC1_RGB8_texture;
+#define GL_OES_compressed_paletted_texture 1
+GLAD_API_CALL int GLAD_GL_OES_compressed_paletted_texture;
+#define GL_OES_copy_image 1
+GLAD_API_CALL int GLAD_GL_OES_copy_image;
+#define GL_OES_depth24 1
+GLAD_API_CALL int GLAD_GL_OES_depth24;
+#define GL_OES_depth32 1
+GLAD_API_CALL int GLAD_GL_OES_depth32;
+#define GL_OES_depth_texture 1
+GLAD_API_CALL int GLAD_GL_OES_depth_texture;
+#define GL_OES_draw_buffers_indexed 1
+GLAD_API_CALL int GLAD_GL_OES_draw_buffers_indexed;
+#define GL_OES_draw_elements_base_vertex 1
+GLAD_API_CALL int GLAD_GL_OES_draw_elements_base_vertex;
+#define GL_OES_element_index_uint 1
+GLAD_API_CALL int GLAD_GL_OES_element_index_uint;
+#define GL_OES_fbo_render_mipmap 1
+GLAD_API_CALL int GLAD_GL_OES_fbo_render_mipmap;
+#define GL_OES_fragment_precision_high 1
+GLAD_API_CALL int GLAD_GL_OES_fragment_precision_high;
+#define GL_OES_geometry_point_size 1
+GLAD_API_CALL int GLAD_GL_OES_geometry_point_size;
+#define GL_OES_geometry_shader 1
+GLAD_API_CALL int GLAD_GL_OES_geometry_shader;
+#define GL_OES_get_program_binary 1
+GLAD_API_CALL int GLAD_GL_OES_get_program_binary;
+#define GL_OES_gpu_shader5 1
+GLAD_API_CALL int GLAD_GL_OES_gpu_shader5;
+#define GL_OES_mapbuffer 1
+GLAD_API_CALL int GLAD_GL_OES_mapbuffer;
+#define GL_OES_packed_depth_stencil 1
+GLAD_API_CALL int GLAD_GL_OES_packed_depth_stencil;
+#define GL_OES_primitive_bounding_box 1
+GLAD_API_CALL int GLAD_GL_OES_primitive_bounding_box;
+#define GL_OES_required_internalformat 1
+GLAD_API_CALL int GLAD_GL_OES_required_internalformat;
+#define GL_OES_rgb8_rgba8 1
+GLAD_API_CALL int GLAD_GL_OES_rgb8_rgba8;
+#define GL_OES_sample_shading 1
+GLAD_API_CALL int GLAD_GL_OES_sample_shading;
+#define GL_OES_sample_variables 1
+GLAD_API_CALL int GLAD_GL_OES_sample_variables;
+#define GL_OES_shader_image_atomic 1
+GLAD_API_CALL int GLAD_GL_OES_shader_image_atomic;
+#define GL_OES_shader_io_blocks 1
+GLAD_API_CALL int GLAD_GL_OES_shader_io_blocks;
+#define GL_OES_shader_multisample_interpolation 1
+GLAD_API_CALL int GLAD_GL_OES_shader_multisample_interpolation;
+#define GL_OES_standard_derivatives 1
+GLAD_API_CALL int GLAD_GL_OES_standard_derivatives;
+#define GL_OES_stencil1 1
+GLAD_API_CALL int GLAD_GL_OES_stencil1;
+#define GL_OES_stencil4 1
+GLAD_API_CALL int GLAD_GL_OES_stencil4;
+#define GL_OES_surfaceless_context 1
+GLAD_API_CALL int GLAD_GL_OES_surfaceless_context;
+#define GL_OES_tessellation_point_size 1
+GLAD_API_CALL int GLAD_GL_OES_tessellation_point_size;
+#define GL_OES_tessellation_shader 1
+GLAD_API_CALL int GLAD_GL_OES_tessellation_shader;
+#define GL_OES_texture_3D 1
+GLAD_API_CALL int GLAD_GL_OES_texture_3D;
+#define GL_OES_texture_border_clamp 1
+GLAD_API_CALL int GLAD_GL_OES_texture_border_clamp;
+#define GL_OES_texture_buffer 1
+GLAD_API_CALL int GLAD_GL_OES_texture_buffer;
+#define GL_OES_texture_compression_astc 1
+GLAD_API_CALL int GLAD_GL_OES_texture_compression_astc;
+#define GL_OES_texture_cube_map_array 1
+GLAD_API_CALL int GLAD_GL_OES_texture_cube_map_array;
+#define GL_OES_texture_float 1
+GLAD_API_CALL int GLAD_GL_OES_texture_float;
+#define GL_OES_texture_float_linear 1
+GLAD_API_CALL int GLAD_GL_OES_texture_float_linear;
+#define GL_OES_texture_half_float 1
+GLAD_API_CALL int GLAD_GL_OES_texture_half_float;
+#define GL_OES_texture_half_float_linear 1
+GLAD_API_CALL int GLAD_GL_OES_texture_half_float_linear;
+#define GL_OES_texture_npot 1
+GLAD_API_CALL int GLAD_GL_OES_texture_npot;
+#define GL_OES_texture_stencil8 1
+GLAD_API_CALL int GLAD_GL_OES_texture_stencil8;
+#define GL_OES_texture_storage_multisample_2d_array 1
+GLAD_API_CALL int GLAD_GL_OES_texture_storage_multisample_2d_array;
+#define GL_OES_texture_view 1
+GLAD_API_CALL int GLAD_GL_OES_texture_view;
+#define GL_OES_vertex_array_object 1
+GLAD_API_CALL int GLAD_GL_OES_vertex_array_object;
+#define GL_OES_vertex_half_float 1
+GLAD_API_CALL int GLAD_GL_OES_vertex_half_float;
+#define GL_OES_vertex_type_10_10_10_2 1
+GLAD_API_CALL int GLAD_GL_OES_vertex_type_10_10_10_2;
+#define GL_OES_viewport_array 1
+GLAD_API_CALL int GLAD_GL_OES_viewport_array;
+
+
+typedef GLboolean (GLAD_API_PTR *PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC)(GLuint memory, GLuint64 key, GLuint timeout);
+typedef void (GLAD_API_PTR *PFNGLACTIVESHADERPROGRAMEXTPROC)(GLuint pipeline, GLuint program);
+typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum texture);
+typedef void (GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader);
+typedef void (GLAD_API_PTR *PFNGLBEGINQUERYEXTPROC)(GLenum target, GLuint id);
+typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer);
+typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONEXTPROC)(GLuint program, GLuint color, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer);
+typedef void (GLAD_API_PTR *PFNGLBINDPROGRAMPIPELINEEXTPROC)(GLuint pipeline);
+typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer);
+typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture);
+typedef void (GLAD_API_PTR *PFNGLBINDVERTEXARRAYOESPROC)(GLuint array);
+typedef void (GLAD_API_PTR *PFNGLBLENDBARRIERKHRPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEIEXTPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEIOESPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONIEXTPROC)(GLuint buf, GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONIOESPROC)(GLuint buf, GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEIEXTPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEIOESPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCIEXTPROC)(GLuint buf, GLenum src, GLenum dst);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCIOESPROC)(GLuint buf, GLenum src, GLenum dst);
+typedef void (GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void * data, GLenum usage);
+typedef void (GLAD_API_PTR *PFNGLBUFFERSTORAGEEXTPROC)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags);
+typedef void (GLAD_API_PTR *PFNGLBUFFERSTORAGEEXTERNALEXTPROC)(GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags);
+typedef void (GLAD_API_PTR *PFNGLBUFFERSTORAGEMEMEXTPROC)(GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data);
+typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target);
+typedef void (GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield mask);
+typedef void (GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHFPROC)(GLfloat d);
+typedef void (GLAD_API_PTR *PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC)(GLsizei offset, GLsizei n, const GLuint * values);
+typedef void (GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint s);
+typedef void (GLAD_API_PTR *PFNGLCLEARTEXIMAGEEXTPROC)(GLuint texture, GLint level, GLenum format, GLenum type, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCLEARTEXSUBIMAGEEXTPROC)(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 (GLAD_API_PTR *PFNGLCLIPCONTROLEXTPROC)(GLenum origin, GLenum depth);
+typedef void (GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+typedef void (GLAD_API_PTR *PFNGLCOLORMASKIEXTPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef void (GLAD_API_PTR *PFNGLCOLORMASKIOESPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint shader);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE3DOESPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC)(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 (GLAD_API_PTR *PFNGLCOPYIMAGESUBDATAEXTPROC)(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 (GLAD_API_PTR *PFNGLCOPYIMAGESUBDATAOESPROC)(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 (GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE3DOESPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLCREATEMEMORYOBJECTSEXTPROC)(GLsizei n, GLuint * memoryObjects);
+typedef GLuint (GLAD_API_PTR *PFNGLCREATEPROGRAMPROC)(void);
+typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum type);
+typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROGRAMVEXTPROC)(GLenum type, GLsizei count, const GLchar *const* strings);
+typedef void (GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECALLBACKKHRPROC)(GLDEBUGPROCKHR callback, const void * userParam);
+typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECONTROLKHRPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled);
+typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGEINSERTKHRPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf);
+typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint * buffers);
+typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint * framebuffers);
+typedef void (GLAD_API_PTR *PFNGLDELETEMEMORYOBJECTSEXTPROC)(GLsizei n, const GLuint * memoryObjects);
+typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint program);
+typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPIPELINESEXTPROC)(GLsizei n, const GLuint * pipelines);
+typedef void (GLAD_API_PTR *PFNGLDELETEQUERIESEXTPROC)(GLsizei n, const GLuint * ids);
+typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint * renderbuffers);
+typedef void (GLAD_API_PTR *PFNGLDELETESEMAPHORESEXTPROC)(GLsizei n, const GLuint * semaphores);
+typedef void (GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint shader);
+typedef void (GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint * textures);
+typedef void (GLAD_API_PTR *PFNGLDELETEVERTEXARRAYSOESPROC)(GLsizei n, const GLuint * arrays);
+typedef void (GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum func);
+typedef void (GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean flag);
+typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEARRAYFVOESPROC)(GLuint first, GLsizei count, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEINDEXEDFOESPROC)(GLuint index, GLfloat n, GLfloat f);
+typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f);
+typedef void (GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader);
+typedef void (GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum cap);
+typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index);
+typedef void (GLAD_API_PTR *PFNGLDISABLEIEXTPROC)(GLenum target, GLuint index);
+typedef void (GLAD_API_PTR *PFNGLDISABLEIOESPROC)(GLenum target, GLuint index);
+typedef void (GLAD_API_PTR *PFNGLDISCARDFRAMEBUFFEREXTPROC)(GLenum target, GLsizei numAttachments, const GLenum * attachments);
+typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count);
+typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);
+typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDEXTPROC)(GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSEXTPROC)(GLsizei n, const GLenum * bufs);
+typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSINDEXEDEXTPROC)(GLint n, const GLenum * location, const GLint * indices);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXOESPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLuint baseinstance);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount);
+typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKEXTPROC)(GLenum mode, GLuint id);
+typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC)(GLenum mode, GLuint id, GLsizei instancecount);
+typedef void (GLAD_API_PTR *PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC)(GLenum target, GLeglImageOES image);
+typedef void (GLAD_API_PTR *PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC)(GLenum target, GLeglImageOES image, const GLint * attrib_list);
+typedef void (GLAD_API_PTR *PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)(GLenum target, GLeglImageOES image);
+typedef void (GLAD_API_PTR *PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC)(GLuint texture, GLeglImageOES image, const GLint * attrib_list);
+typedef void (GLAD_API_PTR *PFNGLENABLEPROC)(GLenum cap);
+typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index);
+typedef void (GLAD_API_PTR *PFNGLENABLEIEXTPROC)(GLenum target, GLuint index);
+typedef void (GLAD_API_PTR *PFNGLENABLEIOESPROC)(GLenum target, GLuint index);
+typedef void (GLAD_API_PTR *PFNGLENDQUERYEXTPROC)(GLenum target);
+typedef void (GLAD_API_PTR *PFNGLFINISHPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLFLUSHPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC)(GLenum target, GLintptr offset, GLsizeiptr length);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC)(GLuint target, GLsizei size);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERSHADINGRATEEXTPROC)(GLenum target, GLenum attachment, GLuint texture, GLint baseLayer, GLsizei numLayers, GLsizei texelWidth, GLsizei texelHeight);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE3DOESPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREEXTPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREOESPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level);
+typedef void (GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei n, GLuint * buffers);
+typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint * framebuffers);
+typedef void (GLAD_API_PTR *PFNGLGENPROGRAMPIPELINESEXTPROC)(GLsizei n, GLuint * pipelines);
+typedef void (GLAD_API_PTR *PFNGLGENQUERIESEXTPROC)(GLsizei n, GLuint * ids);
+typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint * renderbuffers);
+typedef void (GLAD_API_PTR *PFNGLGENSEMAPHORESEXTPROC)(GLsizei n, GLuint * semaphores);
+typedef void (GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei n, GLuint * textures);
+typedef void (GLAD_API_PTR *PFNGLGENVERTEXARRAYSOESPROC)(GLsizei n, GLuint * arrays);
+typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum target);
+typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders);
+typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean * data);
+typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETBUFFERPOINTERVOESPROC)(GLenum target, GLenum pname, void ** params);
+typedef GLuint (GLAD_API_PTR *PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog);
+typedef GLenum (GLAD_API_PTR *PFNGLGETERRORPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLGETFLOATI_VOESPROC)(GLenum target, GLuint index, GLfloat * data);
+typedef void (GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum pname, GLfloat * data);
+typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATAINDEXEXTPROC)(GLuint program, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETFRAGMENTSHADINGRATESEXTPROC)(GLsizei samples, GLsizei maxCount, GLsizei * count, GLenum * shadingRates);
+typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint * params);
+typedef GLsizei (GLAD_API_PTR *PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC)(GLuint target);
+typedef GLenum (GLAD_API_PTR *PFNGLGETGRAPHICSRESETSTATUSEXTPROC)(void);
+typedef GLenum (GLAD_API_PTR *PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLGETINTEGER64VEXTPROC)(GLenum pname, GLint64 * data);
+typedef void (GLAD_API_PTR *PFNGLGETINTEGERI_VEXTPROC)(GLenum target, GLuint index, GLint * data);
+typedef void (GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum pname, GLint * data);
+typedef void (GLAD_API_PTR *PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC)(GLuint memoryObject, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETOBJECTLABELEXTPROC)(GLenum type, GLuint object, GLsizei bufSize, GLsizei * length, GLchar * label);
+typedef void (GLAD_API_PTR *PFNGLGETOBJECTLABELKHRPROC)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label);
+typedef void (GLAD_API_PTR *PFNGLGETOBJECTPTRLABELKHRPROC)(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label);
+typedef void (GLAD_API_PTR *PFNGLGETPOINTERVKHRPROC)(GLenum pname, void ** params);
+typedef void (GLAD_API_PTR *PFNGLGETPROGRAMBINARYOESPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary);
+typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
+typedef void (GLAD_API_PTR *PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC)(GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
+typedef void (GLAD_API_PTR *PFNGLGETPROGRAMPIPELINEIVEXTPROC)(GLuint pipeline, GLenum pname, GLint * params);
+typedef GLint (GLAD_API_PTR *PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC)(GLuint program, GLenum programInterface, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTI64VEXTPROC)(GLuint id, GLenum pname, GLint64 * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTIVEXTPROC)(GLuint id, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUI64VEXTPROC)(GLuint id, GLenum pname, GLuint64 * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUIVEXTPROC)(GLuint id, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYIVEXTPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVEXTPROC)(GLuint sampler, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVOESPROC)(GLuint sampler, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVEXTPROC)(GLuint sampler, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVOESPROC)(GLuint sampler, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC)(GLuint semaphore, GLenum pname, GLuint64 * params);
+typedef void (GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
+typedef void (GLAD_API_PTR *PFNGLGETSHADERPRECISIONFORMATPROC)(GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision);
+typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source);
+typedef void (GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint * params);
+typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum name);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVEXTPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVOESPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVEXTPROC)(GLenum target, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVOESPROC)(GLenum target, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
+typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETUNSIGNEDBYTEI_VEXTPROC)(GLenum target, GLuint index, GLubyte * data);
+typedef void (GLAD_API_PTR *PFNGLGETUNSIGNEDBYTEVEXTPROC)(GLenum pname, GLubyte * data);
+typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void ** pointer);
+typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMFVEXTPROC)(GLuint program, GLint location, GLsizei bufSize, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMFVKHRPROC)(GLuint program, GLint location, GLsizei bufSize, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMIVEXTPROC)(GLuint program, GLint location, GLsizei bufSize, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMIVKHRPROC)(GLuint program, GLint location, GLsizei bufSize, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMUIVKHRPROC)(GLuint program, GLint location, GLsizei bufSize, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLHINTPROC)(GLenum target, GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLIMPORTMEMORYFDEXTPROC)(GLuint memory, GLuint64 size, GLenum handleType, GLint fd);
+typedef void (GLAD_API_PTR *PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC)(GLuint memory, GLuint64 size, GLenum handleType, void * handle);
+typedef void (GLAD_API_PTR *PFNGLIMPORTMEMORYWIN32NAMEEXTPROC)(GLuint memory, GLuint64 size, GLenum handleType, const void * name);
+typedef void (GLAD_API_PTR *PFNGLIMPORTSEMAPHOREFDEXTPROC)(GLuint semaphore, GLenum handleType, GLint fd);
+typedef void (GLAD_API_PTR *PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC)(GLuint semaphore, GLenum handleType, void * handle);
+typedef void (GLAD_API_PTR *PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC)(GLuint semaphore, GLenum handleType, const void * name);
+typedef void (GLAD_API_PTR *PFNGLINSERTEVENTMARKEREXTPROC)(GLsizei length, const GLchar * marker);
+typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint buffer);
+typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum cap);
+typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIEXTPROC)(GLenum target, GLuint index);
+typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIOESPROC)(GLenum target, GLuint index);
+typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer);
+typedef GLboolean (GLAD_API_PTR *PFNGLISMEMORYOBJECTEXTPROC)(GLuint memoryObject);
+typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint program);
+typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPIPELINEEXTPROC)(GLuint pipeline);
+typedef GLboolean (GLAD_API_PTR *PFNGLISQUERYEXTPROC)(GLuint id);
+typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer);
+typedef GLboolean (GLAD_API_PTR *PFNGLISSEMAPHOREEXTPROC)(GLuint semaphore);
+typedef GLboolean (GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint shader);
+typedef GLboolean (GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint texture);
+typedef GLboolean (GLAD_API_PTR *PFNGLISVERTEXARRAYOESPROC)(GLuint array);
+typedef void (GLAD_API_PTR *PFNGLLABELOBJECTEXTPROC)(GLenum type, GLuint object, GLsizei length, const GLchar * label);
+typedef void (GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat width);
+typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint program);
+typedef void * (GLAD_API_PTR *PFNGLMAPBUFFEROESPROC)(GLenum target, GLenum access);
+typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERRANGEEXTPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (GLAD_API_PTR *PFNGLMAXSHADERCOMPILERTHREADSKHRPROC)(GLuint count);
+typedef void (GLAD_API_PTR *PFNGLMEMORYOBJECTPARAMETERIVEXTPROC)(GLuint memoryObject, GLenum pname, const GLint * params);
+typedef void (GLAD_API_PTR *PFNGLMINSAMPLESHADINGOESPROC)(GLfloat value);
+typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSEXTPROC)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei primcount);
+typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC)(GLenum mode, const void * indirect, GLsizei drawcount, GLsizei stride);
+typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex);
+typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSEXTPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei primcount);
+typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC)(GLenum mode, GLenum type, const void * indirect, GLsizei drawcount, GLsizei stride);
+typedef void (GLAD_API_PTR *PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC)(GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags);
+typedef void (GLAD_API_PTR *PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC)(GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLOBJECTLABELKHRPROC)(GLenum identifier, GLuint name, GLsizei length, const GLchar * label);
+typedef void (GLAD_API_PTR *PFNGLOBJECTPTRLABELKHRPROC)(const void * ptr, GLsizei length, const GLchar * label);
+typedef void (GLAD_API_PTR *PFNGLPATCHPARAMETERIEXTPROC)(GLenum pname, GLint value);
+typedef void (GLAD_API_PTR *PFNGLPATCHPARAMETERIOESPROC)(GLenum pname, GLint value);
+typedef void (GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param);
+typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units);
+typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETCLAMPEXTPROC)(GLfloat factor, GLfloat units, GLfloat clamp);
+typedef void (GLAD_API_PTR *PFNGLPOPDEBUGGROUPKHRPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLPOPGROUPMARKEREXTPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLPRIMITIVEBOUNDINGBOXEXTPROC)(GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
+typedef void (GLAD_API_PTR *PFNGLPRIMITIVEBOUNDINGBOXOESPROC)(GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMBINARYOESPROC)(GLuint program, GLenum binaryFormat, const void * binary, GLint length);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMPARAMETERIEXTPROC)(GLuint program, GLenum pname, GLint value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1FEXTPROC)(GLuint program, GLint location, GLfloat v0);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1FVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1IEXTPROC)(GLuint program, GLint location, GLint v0);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1IVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UIEXTPROC)(GLuint program, GLint location, GLuint v0);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UIVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2FEXTPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2FVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2IEXTPROC)(GLuint program, GLint location, GLint v0, GLint v1);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2IVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UIEXTPROC)(GLuint program, GLint location, GLuint v0, GLuint v1);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UIVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3FEXTPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3FVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3IEXTPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3IVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UIEXTPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UIVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4FEXTPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4FVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4IEXTPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4IVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UIEXTPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UIVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPUSHDEBUGGROUPKHRPROC)(GLenum source, GLuint id, GLsizei length, const GLchar * message);
+typedef void (GLAD_API_PTR *PFNGLPUSHGROUPMARKEREXTPROC)(GLsizei length, const GLchar * marker);
+typedef void (GLAD_API_PTR *PFNGLQUERYCOUNTEREXTPROC)(GLuint id, GLenum target);
+typedef void (GLAD_API_PTR *PFNGLRASTERSAMPLESEXTPROC)(GLuint samples, GLboolean fixedsamplelocations);
+typedef void (GLAD_API_PTR *PFNGLREADBUFFERINDEXEDEXTPROC)(GLenum src, GLint index);
+typedef void (GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels);
+typedef void (GLAD_API_PTR *PFNGLREADNPIXELSEXTPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data);
+typedef void (GLAD_API_PTR *PFNGLREADNPIXELSKHRPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data);
+typedef GLboolean (GLAD_API_PTR *PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC)(GLuint memory, GLuint64 key);
+typedef void (GLAD_API_PTR *PFNGLRELEASESHADERCOMPILERPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVEXTPROC)(GLuint sampler, GLenum pname, const GLint * param);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVOESPROC)(GLuint sampler, GLenum pname, const GLint * param);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVEXTPROC)(GLuint sampler, GLenum pname, const GLuint * param);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVOESPROC)(GLuint sampler, GLenum pname, const GLuint * param);
+typedef void (GLAD_API_PTR *PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLSCISSORARRAYVOESPROC)(GLuint first, GLsizei count, const GLint * v);
+typedef void (GLAD_API_PTR *PFNGLSCISSORINDEXEDOESPROC)(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLSCISSORINDEXEDVOESPROC)(GLuint index, const GLint * v);
+typedef void (GLAD_API_PTR *PFNGLSEMAPHOREPARAMETERUI64VEXTPROC)(GLuint semaphore, GLenum pname, const GLuint64 * params);
+typedef void (GLAD_API_PTR *PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint * shaders, GLenum binaryFormat, const void * binary, GLsizei length);
+typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length);
+typedef void (GLAD_API_PTR *PFNGLSHADINGRATECOMBINEROPSEXTPROC)(GLenum combinerOp0, GLenum combinerOp1);
+typedef void (GLAD_API_PTR *PFNGLSHADINGRATEEXTPROC)(GLenum rate);
+typedef void (GLAD_API_PTR *PFNGLSIGNALSEMAPHOREEXTPROC)(GLuint semaphore, GLuint numBufferBarriers, const GLuint * buffers, GLuint numTextureBarriers, const GLuint * textures, const GLenum * dstLayouts);
+typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask);
+typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask);
+typedef void (GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint mask);
+typedef void (GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask);
+typedef void (GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass);
+typedef void (GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (GLAD_API_PTR *PFNGLTEXBUFFEREXTPROC)(GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (GLAD_API_PTR *PFNGLTEXBUFFEROESPROC)(GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (GLAD_API_PTR *PFNGLTEXBUFFERRANGEEXTPROC)(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (GLAD_API_PTR *PFNGLTEXBUFFERRANGEOESPROC)(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels);
+typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DOESPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels);
+typedef void (GLAD_API_PTR *PFNGLTEXPAGECOMMITMENTEXTPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVEXTPROC)(GLenum target, GLenum pname, const GLint * params);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVOESPROC)(GLenum target, GLenum pname, const GLint * params);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVEXTPROC)(GLenum target, GLenum pname, const GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVOESPROC)(GLenum target, GLenum pname, const GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint * params);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE1DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE2DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE3DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEATTRIBS2DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, const GLint * attrib_list);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEATTRIBS3DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, const GLint * attrib_list);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEMEM2DEXTPROC)(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEMEM3DEXTPROC)(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels);
+typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE3DOESPROC)(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 (GLAD_API_PTR *PFNGLTEXTURESTORAGE1DEXTPROC)(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGE2DEXTPROC)(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGE3DEXTPROC)(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGEMEM2DEXTPROC)(GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC)(GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGEMEM3DEXTPROC)(GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC)(GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXTUREVIEWEXTPROC)(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+typedef void (GLAD_API_PTR *PFNGLTEXTUREVIEWOESPROC)(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint location, GLint v0);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef GLboolean (GLAD_API_PTR *PFNGLUNMAPBUFFEROESPROC)(GLenum target);
+typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint program);
+typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMSTAGESEXTPROC)(GLuint pipeline, GLbitfield stages, GLuint program);
+typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint program);
+typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPIPELINEEXTPROC)(GLuint pipeline);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBDIVISOREXTPROC)(GLuint index, GLuint divisor);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer);
+typedef void (GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLVIEWPORTARRAYVOESPROC)(GLuint first, GLsizei count, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVIEWPORTINDEXEDFOESPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
+typedef void (GLAD_API_PTR *PFNGLVIEWPORTINDEXEDFVOESPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLWAITSEMAPHOREEXTPROC)(GLuint semaphore, GLuint numBufferBarriers, const GLuint * buffers, GLuint numTextureBarriers, const GLuint * textures, const GLenum * srcLayouts);
+typedef void (GLAD_API_PTR *PFNGLWINDOWRECTANGLESEXTPROC)(GLenum mode, GLsizei count, const GLint * box);
+
+GLAD_API_CALL PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC glad_glAcquireKeyedMutexWin32EXT;
+#define glAcquireKeyedMutexWin32EXT glad_glAcquireKeyedMutexWin32EXT
+GLAD_API_CALL PFNGLACTIVESHADERPROGRAMEXTPROC glad_glActiveShaderProgramEXT;
+#define glActiveShaderProgramEXT glad_glActiveShaderProgramEXT
+GLAD_API_CALL PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
+#define glActiveTexture glad_glActiveTexture
+GLAD_API_CALL PFNGLATTACHSHADERPROC glad_glAttachShader;
+#define glAttachShader glad_glAttachShader
+GLAD_API_CALL PFNGLBEGINQUERYEXTPROC glad_glBeginQueryEXT;
+#define glBeginQueryEXT glad_glBeginQueryEXT
+GLAD_API_CALL PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
+#define glBindAttribLocation glad_glBindAttribLocation
+GLAD_API_CALL PFNGLBINDBUFFERPROC glad_glBindBuffer;
+#define glBindBuffer glad_glBindBuffer
+GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONEXTPROC glad_glBindFragDataLocationEXT;
+#define glBindFragDataLocationEXT glad_glBindFragDataLocationEXT
+GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC glad_glBindFragDataLocationIndexedEXT;
+#define glBindFragDataLocationIndexedEXT glad_glBindFragDataLocationIndexedEXT
+GLAD_API_CALL PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
+#define glBindFramebuffer glad_glBindFramebuffer
+GLAD_API_CALL PFNGLBINDPROGRAMPIPELINEEXTPROC glad_glBindProgramPipelineEXT;
+#define glBindProgramPipelineEXT glad_glBindProgramPipelineEXT
+GLAD_API_CALL PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
+#define glBindRenderbuffer glad_glBindRenderbuffer
+GLAD_API_CALL PFNGLBINDTEXTUREPROC glad_glBindTexture;
+#define glBindTexture glad_glBindTexture
+GLAD_API_CALL PFNGLBINDVERTEXARRAYOESPROC glad_glBindVertexArrayOES;
+#define glBindVertexArrayOES glad_glBindVertexArrayOES
+GLAD_API_CALL PFNGLBLENDBARRIERKHRPROC glad_glBlendBarrierKHR;
+#define glBlendBarrierKHR glad_glBlendBarrierKHR
+GLAD_API_CALL PFNGLBLENDCOLORPROC glad_glBlendColor;
+#define glBlendColor glad_glBlendColor
+GLAD_API_CALL PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
+#define glBlendEquation glad_glBlendEquation
+GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
+#define glBlendEquationSeparate glad_glBlendEquationSeparate
+GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEIEXTPROC glad_glBlendEquationSeparateiEXT;
+#define glBlendEquationSeparateiEXT glad_glBlendEquationSeparateiEXT
+GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEIOESPROC glad_glBlendEquationSeparateiOES;
+#define glBlendEquationSeparateiOES glad_glBlendEquationSeparateiOES
+GLAD_API_CALL PFNGLBLENDEQUATIONIEXTPROC glad_glBlendEquationiEXT;
+#define glBlendEquationiEXT glad_glBlendEquationiEXT
+GLAD_API_CALL PFNGLBLENDEQUATIONIOESPROC glad_glBlendEquationiOES;
+#define glBlendEquationiOES glad_glBlendEquationiOES
+GLAD_API_CALL PFNGLBLENDFUNCPROC glad_glBlendFunc;
+#define glBlendFunc glad_glBlendFunc
+GLAD_API_CALL PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
+#define glBlendFuncSeparate glad_glBlendFuncSeparate
+GLAD_API_CALL PFNGLBLENDFUNCSEPARATEIEXTPROC glad_glBlendFuncSeparateiEXT;
+#define glBlendFuncSeparateiEXT glad_glBlendFuncSeparateiEXT
+GLAD_API_CALL PFNGLBLENDFUNCSEPARATEIOESPROC glad_glBlendFuncSeparateiOES;
+#define glBlendFuncSeparateiOES glad_glBlendFuncSeparateiOES
+GLAD_API_CALL PFNGLBLENDFUNCIEXTPROC glad_glBlendFunciEXT;
+#define glBlendFunciEXT glad_glBlendFunciEXT
+GLAD_API_CALL PFNGLBLENDFUNCIOESPROC glad_glBlendFunciOES;
+#define glBlendFunciOES glad_glBlendFunciOES
+GLAD_API_CALL PFNGLBUFFERDATAPROC glad_glBufferData;
+#define glBufferData glad_glBufferData
+GLAD_API_CALL PFNGLBUFFERSTORAGEEXTPROC glad_glBufferStorageEXT;
+#define glBufferStorageEXT glad_glBufferStorageEXT
+GLAD_API_CALL PFNGLBUFFERSTORAGEEXTERNALEXTPROC glad_glBufferStorageExternalEXT;
+#define glBufferStorageExternalEXT glad_glBufferStorageExternalEXT
+GLAD_API_CALL PFNGLBUFFERSTORAGEMEMEXTPROC glad_glBufferStorageMemEXT;
+#define glBufferStorageMemEXT glad_glBufferStorageMemEXT
+GLAD_API_CALL PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
+#define glBufferSubData glad_glBufferSubData
+GLAD_API_CALL PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
+#define glCheckFramebufferStatus glad_glCheckFramebufferStatus
+GLAD_API_CALL PFNGLCLEARPROC glad_glClear;
+#define glClear glad_glClear
+GLAD_API_CALL PFNGLCLEARCOLORPROC glad_glClearColor;
+#define glClearColor glad_glClearColor
+GLAD_API_CALL PFNGLCLEARDEPTHFPROC glad_glClearDepthf;
+#define glClearDepthf glad_glClearDepthf
+GLAD_API_CALL PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC glad_glClearPixelLocalStorageuiEXT;
+#define glClearPixelLocalStorageuiEXT glad_glClearPixelLocalStorageuiEXT
+GLAD_API_CALL PFNGLCLEARSTENCILPROC glad_glClearStencil;
+#define glClearStencil glad_glClearStencil
+GLAD_API_CALL PFNGLCLEARTEXIMAGEEXTPROC glad_glClearTexImageEXT;
+#define glClearTexImageEXT glad_glClearTexImageEXT
+GLAD_API_CALL PFNGLCLEARTEXSUBIMAGEEXTPROC glad_glClearTexSubImageEXT;
+#define glClearTexSubImageEXT glad_glClearTexSubImageEXT
+GLAD_API_CALL PFNGLCLIPCONTROLEXTPROC glad_glClipControlEXT;
+#define glClipControlEXT glad_glClipControlEXT
+GLAD_API_CALL PFNGLCOLORMASKPROC glad_glColorMask;
+#define glColorMask glad_glColorMask
+GLAD_API_CALL PFNGLCOLORMASKIEXTPROC glad_glColorMaskiEXT;
+#define glColorMaskiEXT glad_glColorMaskiEXT
+GLAD_API_CALL PFNGLCOLORMASKIOESPROC glad_glColorMaskiOES;
+#define glColorMaskiOES glad_glColorMaskiOES
+GLAD_API_CALL PFNGLCOMPILESHADERPROC glad_glCompileShader;
+#define glCompileShader glad_glCompileShader
+GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
+#define glCompressedTexImage2D glad_glCompressedTexImage2D
+GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE3DOESPROC glad_glCompressedTexImage3DOES;
+#define glCompressedTexImage3DOES glad_glCompressedTexImage3DOES
+GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
+#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D
+GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC glad_glCompressedTexSubImage3DOES;
+#define glCompressedTexSubImage3DOES glad_glCompressedTexSubImage3DOES
+GLAD_API_CALL PFNGLCOPYIMAGESUBDATAEXTPROC glad_glCopyImageSubDataEXT;
+#define glCopyImageSubDataEXT glad_glCopyImageSubDataEXT
+GLAD_API_CALL PFNGLCOPYIMAGESUBDATAOESPROC glad_glCopyImageSubDataOES;
+#define glCopyImageSubDataOES glad_glCopyImageSubDataOES
+GLAD_API_CALL PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
+#define glCopyTexImage2D glad_glCopyTexImage2D
+GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
+#define glCopyTexSubImage2D glad_glCopyTexSubImage2D
+GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE3DOESPROC glad_glCopyTexSubImage3DOES;
+#define glCopyTexSubImage3DOES glad_glCopyTexSubImage3DOES
+GLAD_API_CALL PFNGLCREATEMEMORYOBJECTSEXTPROC glad_glCreateMemoryObjectsEXT;
+#define glCreateMemoryObjectsEXT glad_glCreateMemoryObjectsEXT
+GLAD_API_CALL PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
+#define glCreateProgram glad_glCreateProgram
+GLAD_API_CALL PFNGLCREATESHADERPROC glad_glCreateShader;
+#define glCreateShader glad_glCreateShader
+GLAD_API_CALL PFNGLCREATESHADERPROGRAMVEXTPROC glad_glCreateShaderProgramvEXT;
+#define glCreateShaderProgramvEXT glad_glCreateShaderProgramvEXT
+GLAD_API_CALL PFNGLCULLFACEPROC glad_glCullFace;
+#define glCullFace glad_glCullFace
+GLAD_API_CALL PFNGLDEBUGMESSAGECALLBACKKHRPROC glad_glDebugMessageCallbackKHR;
+#define glDebugMessageCallbackKHR glad_glDebugMessageCallbackKHR
+GLAD_API_CALL PFNGLDEBUGMESSAGECONTROLKHRPROC glad_glDebugMessageControlKHR;
+#define glDebugMessageControlKHR glad_glDebugMessageControlKHR
+GLAD_API_CALL PFNGLDEBUGMESSAGEINSERTKHRPROC glad_glDebugMessageInsertKHR;
+#define glDebugMessageInsertKHR glad_glDebugMessageInsertKHR
+GLAD_API_CALL PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
+#define glDeleteBuffers glad_glDeleteBuffers
+GLAD_API_CALL PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
+#define glDeleteFramebuffers glad_glDeleteFramebuffers
+GLAD_API_CALL PFNGLDELETEMEMORYOBJECTSEXTPROC glad_glDeleteMemoryObjectsEXT;
+#define glDeleteMemoryObjectsEXT glad_glDeleteMemoryObjectsEXT
+GLAD_API_CALL PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
+#define glDeleteProgram glad_glDeleteProgram
+GLAD_API_CALL PFNGLDELETEPROGRAMPIPELINESEXTPROC glad_glDeleteProgramPipelinesEXT;
+#define glDeleteProgramPipelinesEXT glad_glDeleteProgramPipelinesEXT
+GLAD_API_CALL PFNGLDELETEQUERIESEXTPROC glad_glDeleteQueriesEXT;
+#define glDeleteQueriesEXT glad_glDeleteQueriesEXT
+GLAD_API_CALL PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
+#define glDeleteRenderbuffers glad_glDeleteRenderbuffers
+GLAD_API_CALL PFNGLDELETESEMAPHORESEXTPROC glad_glDeleteSemaphoresEXT;
+#define glDeleteSemaphoresEXT glad_glDeleteSemaphoresEXT
+GLAD_API_CALL PFNGLDELETESHADERPROC glad_glDeleteShader;
+#define glDeleteShader glad_glDeleteShader
+GLAD_API_CALL PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
+#define glDeleteTextures glad_glDeleteTextures
+GLAD_API_CALL PFNGLDELETEVERTEXARRAYSOESPROC glad_glDeleteVertexArraysOES;
+#define glDeleteVertexArraysOES glad_glDeleteVertexArraysOES
+GLAD_API_CALL PFNGLDEPTHFUNCPROC glad_glDepthFunc;
+#define glDepthFunc glad_glDepthFunc
+GLAD_API_CALL PFNGLDEPTHMASKPROC glad_glDepthMask;
+#define glDepthMask glad_glDepthMask
+GLAD_API_CALL PFNGLDEPTHRANGEARRAYFVOESPROC glad_glDepthRangeArrayfvOES;
+#define glDepthRangeArrayfvOES glad_glDepthRangeArrayfvOES
+GLAD_API_CALL PFNGLDEPTHRANGEINDEXEDFOESPROC glad_glDepthRangeIndexedfOES;
+#define glDepthRangeIndexedfOES glad_glDepthRangeIndexedfOES
+GLAD_API_CALL PFNGLDEPTHRANGEFPROC glad_glDepthRangef;
+#define glDepthRangef glad_glDepthRangef
+GLAD_API_CALL PFNGLDETACHSHADERPROC glad_glDetachShader;
+#define glDetachShader glad_glDetachShader
+GLAD_API_CALL PFNGLDISABLEPROC glad_glDisable;
+#define glDisable glad_glDisable
+GLAD_API_CALL PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
+#define glDisableVertexAttribArray glad_glDisableVertexAttribArray
+GLAD_API_CALL PFNGLDISABLEIEXTPROC glad_glDisableiEXT;
+#define glDisableiEXT glad_glDisableiEXT
+GLAD_API_CALL PFNGLDISABLEIOESPROC glad_glDisableiOES;
+#define glDisableiOES glad_glDisableiOES
+GLAD_API_CALL PFNGLDISCARDFRAMEBUFFEREXTPROC glad_glDiscardFramebufferEXT;
+#define glDiscardFramebufferEXT glad_glDiscardFramebufferEXT
+GLAD_API_CALL PFNGLDRAWARRAYSPROC glad_glDrawArrays;
+#define glDrawArrays glad_glDrawArrays
+GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC glad_glDrawArraysInstancedBaseInstanceEXT;
+#define glDrawArraysInstancedBaseInstanceEXT glad_glDrawArraysInstancedBaseInstanceEXT
+GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDEXTPROC glad_glDrawArraysInstancedEXT;
+#define glDrawArraysInstancedEXT glad_glDrawArraysInstancedEXT
+GLAD_API_CALL PFNGLDRAWBUFFERSEXTPROC glad_glDrawBuffersEXT;
+#define glDrawBuffersEXT glad_glDrawBuffersEXT
+GLAD_API_CALL PFNGLDRAWBUFFERSINDEXEDEXTPROC glad_glDrawBuffersIndexedEXT;
+#define glDrawBuffersIndexedEXT glad_glDrawBuffersIndexedEXT
+GLAD_API_CALL PFNGLDRAWELEMENTSPROC glad_glDrawElements;
+#define glDrawElements glad_glDrawElements
+GLAD_API_CALL PFNGLDRAWELEMENTSBASEVERTEXEXTPROC glad_glDrawElementsBaseVertexEXT;
+#define glDrawElementsBaseVertexEXT glad_glDrawElementsBaseVertexEXT
+GLAD_API_CALL PFNGLDRAWELEMENTSBASEVERTEXOESPROC glad_glDrawElementsBaseVertexOES;
+#define glDrawElementsBaseVertexOES glad_glDrawElementsBaseVertexOES
+GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC glad_glDrawElementsInstancedBaseInstanceEXT;
+#define glDrawElementsInstancedBaseInstanceEXT glad_glDrawElementsInstancedBaseInstanceEXT
+GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC glad_glDrawElementsInstancedBaseVertexBaseInstanceEXT;
+#define glDrawElementsInstancedBaseVertexBaseInstanceEXT glad_glDrawElementsInstancedBaseVertexBaseInstanceEXT
+GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC glad_glDrawElementsInstancedBaseVertexEXT;
+#define glDrawElementsInstancedBaseVertexEXT glad_glDrawElementsInstancedBaseVertexEXT
+GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC glad_glDrawElementsInstancedBaseVertexOES;
+#define glDrawElementsInstancedBaseVertexOES glad_glDrawElementsInstancedBaseVertexOES
+GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDEXTPROC glad_glDrawElementsInstancedEXT;
+#define glDrawElementsInstancedEXT glad_glDrawElementsInstancedEXT
+GLAD_API_CALL PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC glad_glDrawRangeElementsBaseVertexEXT;
+#define glDrawRangeElementsBaseVertexEXT glad_glDrawRangeElementsBaseVertexEXT
+GLAD_API_CALL PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC glad_glDrawRangeElementsBaseVertexOES;
+#define glDrawRangeElementsBaseVertexOES glad_glDrawRangeElementsBaseVertexOES
+GLAD_API_CALL PFNGLDRAWTRANSFORMFEEDBACKEXTPROC glad_glDrawTransformFeedbackEXT;
+#define glDrawTransformFeedbackEXT glad_glDrawTransformFeedbackEXT
+GLAD_API_CALL PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC glad_glDrawTransformFeedbackInstancedEXT;
+#define glDrawTransformFeedbackInstancedEXT glad_glDrawTransformFeedbackInstancedEXT
+GLAD_API_CALL PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glad_glEGLImageTargetRenderbufferStorageOES;
+#define glEGLImageTargetRenderbufferStorageOES glad_glEGLImageTargetRenderbufferStorageOES
+GLAD_API_CALL PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC glad_glEGLImageTargetTexStorageEXT;
+#define glEGLImageTargetTexStorageEXT glad_glEGLImageTargetTexStorageEXT
+GLAD_API_CALL PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glad_glEGLImageTargetTexture2DOES;
+#define glEGLImageTargetTexture2DOES glad_glEGLImageTargetTexture2DOES
+GLAD_API_CALL PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC glad_glEGLImageTargetTextureStorageEXT;
+#define glEGLImageTargetTextureStorageEXT glad_glEGLImageTargetTextureStorageEXT
+GLAD_API_CALL PFNGLENABLEPROC glad_glEnable;
+#define glEnable glad_glEnable
+GLAD_API_CALL PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
+#define glEnableVertexAttribArray glad_glEnableVertexAttribArray
+GLAD_API_CALL PFNGLENABLEIEXTPROC glad_glEnableiEXT;
+#define glEnableiEXT glad_glEnableiEXT
+GLAD_API_CALL PFNGLENABLEIOESPROC glad_glEnableiOES;
+#define glEnableiOES glad_glEnableiOES
+GLAD_API_CALL PFNGLENDQUERYEXTPROC glad_glEndQueryEXT;
+#define glEndQueryEXT glad_glEndQueryEXT
+GLAD_API_CALL PFNGLFINISHPROC glad_glFinish;
+#define glFinish glad_glFinish
+GLAD_API_CALL PFNGLFLUSHPROC glad_glFlush;
+#define glFlush glad_glFlush
+GLAD_API_CALL PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC glad_glFlushMappedBufferRangeEXT;
+#define glFlushMappedBufferRangeEXT glad_glFlushMappedBufferRangeEXT
+GLAD_API_CALL PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC glad_glFramebufferFetchBarrierEXT;
+#define glFramebufferFetchBarrierEXT glad_glFramebufferFetchBarrierEXT
+GLAD_API_CALL PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC glad_glFramebufferPixelLocalStorageSizeEXT;
+#define glFramebufferPixelLocalStorageSizeEXT glad_glFramebufferPixelLocalStorageSizeEXT
+GLAD_API_CALL PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
+#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer
+GLAD_API_CALL PFNGLFRAMEBUFFERSHADINGRATEEXTPROC glad_glFramebufferShadingRateEXT;
+#define glFramebufferShadingRateEXT glad_glFramebufferShadingRateEXT
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
+#define glFramebufferTexture2D glad_glFramebufferTexture2D
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC glad_glFramebufferTexture2DMultisampleEXT;
+#define glFramebufferTexture2DMultisampleEXT glad_glFramebufferTexture2DMultisampleEXT
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE3DOESPROC glad_glFramebufferTexture3DOES;
+#define glFramebufferTexture3DOES glad_glFramebufferTexture3DOES
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTUREEXTPROC glad_glFramebufferTextureEXT;
+#define glFramebufferTextureEXT glad_glFramebufferTextureEXT
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTUREOESPROC glad_glFramebufferTextureOES;
+#define glFramebufferTextureOES glad_glFramebufferTextureOES
+GLAD_API_CALL PFNGLFRONTFACEPROC glad_glFrontFace;
+#define glFrontFace glad_glFrontFace
+GLAD_API_CALL PFNGLGENBUFFERSPROC glad_glGenBuffers;
+#define glGenBuffers glad_glGenBuffers
+GLAD_API_CALL PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
+#define glGenFramebuffers glad_glGenFramebuffers
+GLAD_API_CALL PFNGLGENPROGRAMPIPELINESEXTPROC glad_glGenProgramPipelinesEXT;
+#define glGenProgramPipelinesEXT glad_glGenProgramPipelinesEXT
+GLAD_API_CALL PFNGLGENQUERIESEXTPROC glad_glGenQueriesEXT;
+#define glGenQueriesEXT glad_glGenQueriesEXT
+GLAD_API_CALL PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
+#define glGenRenderbuffers glad_glGenRenderbuffers
+GLAD_API_CALL PFNGLGENSEMAPHORESEXTPROC glad_glGenSemaphoresEXT;
+#define glGenSemaphoresEXT glad_glGenSemaphoresEXT
+GLAD_API_CALL PFNGLGENTEXTURESPROC glad_glGenTextures;
+#define glGenTextures glad_glGenTextures
+GLAD_API_CALL PFNGLGENVERTEXARRAYSOESPROC glad_glGenVertexArraysOES;
+#define glGenVertexArraysOES glad_glGenVertexArraysOES
+GLAD_API_CALL PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
+#define glGenerateMipmap glad_glGenerateMipmap
+GLAD_API_CALL PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
+#define glGetActiveAttrib glad_glGetActiveAttrib
+GLAD_API_CALL PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
+#define glGetActiveUniform glad_glGetActiveUniform
+GLAD_API_CALL PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
+#define glGetAttachedShaders glad_glGetAttachedShaders
+GLAD_API_CALL PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
+#define glGetAttribLocation glad_glGetAttribLocation
+GLAD_API_CALL PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
+#define glGetBooleanv glad_glGetBooleanv
+GLAD_API_CALL PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
+#define glGetBufferParameteriv glad_glGetBufferParameteriv
+GLAD_API_CALL PFNGLGETBUFFERPOINTERVOESPROC glad_glGetBufferPointervOES;
+#define glGetBufferPointervOES glad_glGetBufferPointervOES
+GLAD_API_CALL PFNGLGETDEBUGMESSAGELOGKHRPROC glad_glGetDebugMessageLogKHR;
+#define glGetDebugMessageLogKHR glad_glGetDebugMessageLogKHR
+GLAD_API_CALL PFNGLGETERRORPROC glad_glGetError;
+#define glGetError glad_glGetError
+GLAD_API_CALL PFNGLGETFLOATI_VOESPROC glad_glGetFloati_vOES;
+#define glGetFloati_vOES glad_glGetFloati_vOES
+GLAD_API_CALL PFNGLGETFLOATVPROC glad_glGetFloatv;
+#define glGetFloatv glad_glGetFloatv
+GLAD_API_CALL PFNGLGETFRAGDATAINDEXEXTPROC glad_glGetFragDataIndexEXT;
+#define glGetFragDataIndexEXT glad_glGetFragDataIndexEXT
+GLAD_API_CALL PFNGLGETFRAGMENTSHADINGRATESEXTPROC glad_glGetFragmentShadingRatesEXT;
+#define glGetFragmentShadingRatesEXT glad_glGetFragmentShadingRatesEXT
+GLAD_API_CALL PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
+#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv
+GLAD_API_CALL PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC glad_glGetFramebufferPixelLocalStorageSizeEXT;
+#define glGetFramebufferPixelLocalStorageSizeEXT glad_glGetFramebufferPixelLocalStorageSizeEXT
+GLAD_API_CALL PFNGLGETGRAPHICSRESETSTATUSEXTPROC glad_glGetGraphicsResetStatusEXT;
+#define glGetGraphicsResetStatusEXT glad_glGetGraphicsResetStatusEXT
+GLAD_API_CALL PFNGLGETGRAPHICSRESETSTATUSKHRPROC glad_glGetGraphicsResetStatusKHR;
+#define glGetGraphicsResetStatusKHR glad_glGetGraphicsResetStatusKHR
+GLAD_API_CALL PFNGLGETINTEGER64VEXTPROC glad_glGetInteger64vEXT;
+#define glGetInteger64vEXT glad_glGetInteger64vEXT
+GLAD_API_CALL PFNGLGETINTEGERI_VEXTPROC glad_glGetIntegeri_vEXT;
+#define glGetIntegeri_vEXT glad_glGetIntegeri_vEXT
+GLAD_API_CALL PFNGLGETINTEGERVPROC glad_glGetIntegerv;
+#define glGetIntegerv glad_glGetIntegerv
+GLAD_API_CALL PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC glad_glGetMemoryObjectParameterivEXT;
+#define glGetMemoryObjectParameterivEXT glad_glGetMemoryObjectParameterivEXT
+GLAD_API_CALL PFNGLGETOBJECTLABELEXTPROC glad_glGetObjectLabelEXT;
+#define glGetObjectLabelEXT glad_glGetObjectLabelEXT
+GLAD_API_CALL PFNGLGETOBJECTLABELKHRPROC glad_glGetObjectLabelKHR;
+#define glGetObjectLabelKHR glad_glGetObjectLabelKHR
+GLAD_API_CALL PFNGLGETOBJECTPTRLABELKHRPROC glad_glGetObjectPtrLabelKHR;
+#define glGetObjectPtrLabelKHR glad_glGetObjectPtrLabelKHR
+GLAD_API_CALL PFNGLGETPOINTERVKHRPROC glad_glGetPointervKHR;
+#define glGetPointervKHR glad_glGetPointervKHR
+GLAD_API_CALL PFNGLGETPROGRAMBINARYOESPROC glad_glGetProgramBinaryOES;
+#define glGetProgramBinaryOES glad_glGetProgramBinaryOES
+GLAD_API_CALL PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
+#define glGetProgramInfoLog glad_glGetProgramInfoLog
+GLAD_API_CALL PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC glad_glGetProgramPipelineInfoLogEXT;
+#define glGetProgramPipelineInfoLogEXT glad_glGetProgramPipelineInfoLogEXT
+GLAD_API_CALL PFNGLGETPROGRAMPIPELINEIVEXTPROC glad_glGetProgramPipelineivEXT;
+#define glGetProgramPipelineivEXT glad_glGetProgramPipelineivEXT
+GLAD_API_CALL PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC glad_glGetProgramResourceLocationIndexEXT;
+#define glGetProgramResourceLocationIndexEXT glad_glGetProgramResourceLocationIndexEXT
+GLAD_API_CALL PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
+#define glGetProgramiv glad_glGetProgramiv
+GLAD_API_CALL PFNGLGETQUERYOBJECTI64VEXTPROC glad_glGetQueryObjecti64vEXT;
+#define glGetQueryObjecti64vEXT glad_glGetQueryObjecti64vEXT
+GLAD_API_CALL PFNGLGETQUERYOBJECTIVEXTPROC glad_glGetQueryObjectivEXT;
+#define glGetQueryObjectivEXT glad_glGetQueryObjectivEXT
+GLAD_API_CALL PFNGLGETQUERYOBJECTUI64VEXTPROC glad_glGetQueryObjectui64vEXT;
+#define glGetQueryObjectui64vEXT glad_glGetQueryObjectui64vEXT
+GLAD_API_CALL PFNGLGETQUERYOBJECTUIVEXTPROC glad_glGetQueryObjectuivEXT;
+#define glGetQueryObjectuivEXT glad_glGetQueryObjectuivEXT
+GLAD_API_CALL PFNGLGETQUERYIVEXTPROC glad_glGetQueryivEXT;
+#define glGetQueryivEXT glad_glGetQueryivEXT
+GLAD_API_CALL PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
+#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv
+GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIIVEXTPROC glad_glGetSamplerParameterIivEXT;
+#define glGetSamplerParameterIivEXT glad_glGetSamplerParameterIivEXT
+GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIIVOESPROC glad_glGetSamplerParameterIivOES;
+#define glGetSamplerParameterIivOES glad_glGetSamplerParameterIivOES
+GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIUIVEXTPROC glad_glGetSamplerParameterIuivEXT;
+#define glGetSamplerParameterIuivEXT glad_glGetSamplerParameterIuivEXT
+GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIUIVOESPROC glad_glGetSamplerParameterIuivOES;
+#define glGetSamplerParameterIuivOES glad_glGetSamplerParameterIuivOES
+GLAD_API_CALL PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC glad_glGetSemaphoreParameterui64vEXT;
+#define glGetSemaphoreParameterui64vEXT glad_glGetSemaphoreParameterui64vEXT
+GLAD_API_CALL PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
+#define glGetShaderInfoLog glad_glGetShaderInfoLog
+GLAD_API_CALL PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat;
+#define glGetShaderPrecisionFormat glad_glGetShaderPrecisionFormat
+GLAD_API_CALL PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
+#define glGetShaderSource glad_glGetShaderSource
+GLAD_API_CALL PFNGLGETSHADERIVPROC glad_glGetShaderiv;
+#define glGetShaderiv glad_glGetShaderiv
+GLAD_API_CALL PFNGLGETSTRINGPROC glad_glGetString;
+#define glGetString glad_glGetString
+GLAD_API_CALL PFNGLGETTEXPARAMETERIIVEXTPROC glad_glGetTexParameterIivEXT;
+#define glGetTexParameterIivEXT glad_glGetTexParameterIivEXT
+GLAD_API_CALL PFNGLGETTEXPARAMETERIIVOESPROC glad_glGetTexParameterIivOES;
+#define glGetTexParameterIivOES glad_glGetTexParameterIivOES
+GLAD_API_CALL PFNGLGETTEXPARAMETERIUIVEXTPROC glad_glGetTexParameterIuivEXT;
+#define glGetTexParameterIuivEXT glad_glGetTexParameterIuivEXT
+GLAD_API_CALL PFNGLGETTEXPARAMETERIUIVOESPROC glad_glGetTexParameterIuivOES;
+#define glGetTexParameterIuivOES glad_glGetTexParameterIuivOES
+GLAD_API_CALL PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
+#define glGetTexParameterfv glad_glGetTexParameterfv
+GLAD_API_CALL PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
+#define glGetTexParameteriv glad_glGetTexParameteriv
+GLAD_API_CALL PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
+#define glGetUniformLocation glad_glGetUniformLocation
+GLAD_API_CALL PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
+#define glGetUniformfv glad_glGetUniformfv
+GLAD_API_CALL PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
+#define glGetUniformiv glad_glGetUniformiv
+GLAD_API_CALL PFNGLGETUNSIGNEDBYTEI_VEXTPROC glad_glGetUnsignedBytei_vEXT;
+#define glGetUnsignedBytei_vEXT glad_glGetUnsignedBytei_vEXT
+GLAD_API_CALL PFNGLGETUNSIGNEDBYTEVEXTPROC glad_glGetUnsignedBytevEXT;
+#define glGetUnsignedBytevEXT glad_glGetUnsignedBytevEXT
+GLAD_API_CALL PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
+#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv
+GLAD_API_CALL PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
+#define glGetVertexAttribfv glad_glGetVertexAttribfv
+GLAD_API_CALL PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
+#define glGetVertexAttribiv glad_glGetVertexAttribiv
+GLAD_API_CALL PFNGLGETNUNIFORMFVEXTPROC glad_glGetnUniformfvEXT;
+#define glGetnUniformfvEXT glad_glGetnUniformfvEXT
+GLAD_API_CALL PFNGLGETNUNIFORMFVKHRPROC glad_glGetnUniformfvKHR;
+#define glGetnUniformfvKHR glad_glGetnUniformfvKHR
+GLAD_API_CALL PFNGLGETNUNIFORMIVEXTPROC glad_glGetnUniformivEXT;
+#define glGetnUniformivEXT glad_glGetnUniformivEXT
+GLAD_API_CALL PFNGLGETNUNIFORMIVKHRPROC glad_glGetnUniformivKHR;
+#define glGetnUniformivKHR glad_glGetnUniformivKHR
+GLAD_API_CALL PFNGLGETNUNIFORMUIVKHRPROC glad_glGetnUniformuivKHR;
+#define glGetnUniformuivKHR glad_glGetnUniformuivKHR
+GLAD_API_CALL PFNGLHINTPROC glad_glHint;
+#define glHint glad_glHint
+GLAD_API_CALL PFNGLIMPORTMEMORYFDEXTPROC glad_glImportMemoryFdEXT;
+#define glImportMemoryFdEXT glad_glImportMemoryFdEXT
+GLAD_API_CALL PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC glad_glImportMemoryWin32HandleEXT;
+#define glImportMemoryWin32HandleEXT glad_glImportMemoryWin32HandleEXT
+GLAD_API_CALL PFNGLIMPORTMEMORYWIN32NAMEEXTPROC glad_glImportMemoryWin32NameEXT;
+#define glImportMemoryWin32NameEXT glad_glImportMemoryWin32NameEXT
+GLAD_API_CALL PFNGLIMPORTSEMAPHOREFDEXTPROC glad_glImportSemaphoreFdEXT;
+#define glImportSemaphoreFdEXT glad_glImportSemaphoreFdEXT
+GLAD_API_CALL PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC glad_glImportSemaphoreWin32HandleEXT;
+#define glImportSemaphoreWin32HandleEXT glad_glImportSemaphoreWin32HandleEXT
+GLAD_API_CALL PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC glad_glImportSemaphoreWin32NameEXT;
+#define glImportSemaphoreWin32NameEXT glad_glImportSemaphoreWin32NameEXT
+GLAD_API_CALL PFNGLINSERTEVENTMARKEREXTPROC glad_glInsertEventMarkerEXT;
+#define glInsertEventMarkerEXT glad_glInsertEventMarkerEXT
+GLAD_API_CALL PFNGLISBUFFERPROC glad_glIsBuffer;
+#define glIsBuffer glad_glIsBuffer
+GLAD_API_CALL PFNGLISENABLEDPROC glad_glIsEnabled;
+#define glIsEnabled glad_glIsEnabled
+GLAD_API_CALL PFNGLISENABLEDIEXTPROC glad_glIsEnablediEXT;
+#define glIsEnablediEXT glad_glIsEnablediEXT
+GLAD_API_CALL PFNGLISENABLEDIOESPROC glad_glIsEnablediOES;
+#define glIsEnablediOES glad_glIsEnablediOES
+GLAD_API_CALL PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
+#define glIsFramebuffer glad_glIsFramebuffer
+GLAD_API_CALL PFNGLISMEMORYOBJECTEXTPROC glad_glIsMemoryObjectEXT;
+#define glIsMemoryObjectEXT glad_glIsMemoryObjectEXT
+GLAD_API_CALL PFNGLISPROGRAMPROC glad_glIsProgram;
+#define glIsProgram glad_glIsProgram
+GLAD_API_CALL PFNGLISPROGRAMPIPELINEEXTPROC glad_glIsProgramPipelineEXT;
+#define glIsProgramPipelineEXT glad_glIsProgramPipelineEXT
+GLAD_API_CALL PFNGLISQUERYEXTPROC glad_glIsQueryEXT;
+#define glIsQueryEXT glad_glIsQueryEXT
+GLAD_API_CALL PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
+#define glIsRenderbuffer glad_glIsRenderbuffer
+GLAD_API_CALL PFNGLISSEMAPHOREEXTPROC glad_glIsSemaphoreEXT;
+#define glIsSemaphoreEXT glad_glIsSemaphoreEXT
+GLAD_API_CALL PFNGLISSHADERPROC glad_glIsShader;
+#define glIsShader glad_glIsShader
+GLAD_API_CALL PFNGLISTEXTUREPROC glad_glIsTexture;
+#define glIsTexture glad_glIsTexture
+GLAD_API_CALL PFNGLISVERTEXARRAYOESPROC glad_glIsVertexArrayOES;
+#define glIsVertexArrayOES glad_glIsVertexArrayOES
+GLAD_API_CALL PFNGLLABELOBJECTEXTPROC glad_glLabelObjectEXT;
+#define glLabelObjectEXT glad_glLabelObjectEXT
+GLAD_API_CALL PFNGLLINEWIDTHPROC glad_glLineWidth;
+#define glLineWidth glad_glLineWidth
+GLAD_API_CALL PFNGLLINKPROGRAMPROC glad_glLinkProgram;
+#define glLinkProgram glad_glLinkProgram
+GLAD_API_CALL PFNGLMAPBUFFEROESPROC glad_glMapBufferOES;
+#define glMapBufferOES glad_glMapBufferOES
+GLAD_API_CALL PFNGLMAPBUFFERRANGEEXTPROC glad_glMapBufferRangeEXT;
+#define glMapBufferRangeEXT glad_glMapBufferRangeEXT
+GLAD_API_CALL PFNGLMAXSHADERCOMPILERTHREADSKHRPROC glad_glMaxShaderCompilerThreadsKHR;
+#define glMaxShaderCompilerThreadsKHR glad_glMaxShaderCompilerThreadsKHR
+GLAD_API_CALL PFNGLMEMORYOBJECTPARAMETERIVEXTPROC glad_glMemoryObjectParameterivEXT;
+#define glMemoryObjectParameterivEXT glad_glMemoryObjectParameterivEXT
+GLAD_API_CALL PFNGLMINSAMPLESHADINGOESPROC glad_glMinSampleShadingOES;
+#define glMinSampleShadingOES glad_glMinSampleShadingOES
+GLAD_API_CALL PFNGLMULTIDRAWARRAYSEXTPROC glad_glMultiDrawArraysEXT;
+#define glMultiDrawArraysEXT glad_glMultiDrawArraysEXT
+GLAD_API_CALL PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC glad_glMultiDrawArraysIndirectEXT;
+#define glMultiDrawArraysIndirectEXT glad_glMultiDrawArraysIndirectEXT
+GLAD_API_CALL PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC glad_glMultiDrawElementsBaseVertexEXT;
+#define glMultiDrawElementsBaseVertexEXT glad_glMultiDrawElementsBaseVertexEXT
+GLAD_API_CALL PFNGLMULTIDRAWELEMENTSEXTPROC glad_glMultiDrawElementsEXT;
+#define glMultiDrawElementsEXT glad_glMultiDrawElementsEXT
+GLAD_API_CALL PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC glad_glMultiDrawElementsIndirectEXT;
+#define glMultiDrawElementsIndirectEXT glad_glMultiDrawElementsIndirectEXT
+GLAD_API_CALL PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC glad_glNamedBufferStorageExternalEXT;
+#define glNamedBufferStorageExternalEXT glad_glNamedBufferStorageExternalEXT
+GLAD_API_CALL PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC glad_glNamedBufferStorageMemEXT;
+#define glNamedBufferStorageMemEXT glad_glNamedBufferStorageMemEXT
+GLAD_API_CALL PFNGLOBJECTLABELKHRPROC glad_glObjectLabelKHR;
+#define glObjectLabelKHR glad_glObjectLabelKHR
+GLAD_API_CALL PFNGLOBJECTPTRLABELKHRPROC glad_glObjectPtrLabelKHR;
+#define glObjectPtrLabelKHR glad_glObjectPtrLabelKHR
+GLAD_API_CALL PFNGLPATCHPARAMETERIEXTPROC glad_glPatchParameteriEXT;
+#define glPatchParameteriEXT glad_glPatchParameteriEXT
+GLAD_API_CALL PFNGLPATCHPARAMETERIOESPROC glad_glPatchParameteriOES;
+#define glPatchParameteriOES glad_glPatchParameteriOES
+GLAD_API_CALL PFNGLPIXELSTOREIPROC glad_glPixelStorei;
+#define glPixelStorei glad_glPixelStorei
+GLAD_API_CALL PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
+#define glPolygonOffset glad_glPolygonOffset
+GLAD_API_CALL PFNGLPOLYGONOFFSETCLAMPEXTPROC glad_glPolygonOffsetClampEXT;
+#define glPolygonOffsetClampEXT glad_glPolygonOffsetClampEXT
+GLAD_API_CALL PFNGLPOPDEBUGGROUPKHRPROC glad_glPopDebugGroupKHR;
+#define glPopDebugGroupKHR glad_glPopDebugGroupKHR
+GLAD_API_CALL PFNGLPOPGROUPMARKEREXTPROC glad_glPopGroupMarkerEXT;
+#define glPopGroupMarkerEXT glad_glPopGroupMarkerEXT
+GLAD_API_CALL PFNGLPRIMITIVEBOUNDINGBOXEXTPROC glad_glPrimitiveBoundingBoxEXT;
+#define glPrimitiveBoundingBoxEXT glad_glPrimitiveBoundingBoxEXT
+GLAD_API_CALL PFNGLPRIMITIVEBOUNDINGBOXOESPROC glad_glPrimitiveBoundingBoxOES;
+#define glPrimitiveBoundingBoxOES glad_glPrimitiveBoundingBoxOES
+GLAD_API_CALL PFNGLPROGRAMBINARYOESPROC glad_glProgramBinaryOES;
+#define glProgramBinaryOES glad_glProgramBinaryOES
+GLAD_API_CALL PFNGLPROGRAMPARAMETERIEXTPROC glad_glProgramParameteriEXT;
+#define glProgramParameteriEXT glad_glProgramParameteriEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM1FEXTPROC glad_glProgramUniform1fEXT;
+#define glProgramUniform1fEXT glad_glProgramUniform1fEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM1FVEXTPROC glad_glProgramUniform1fvEXT;
+#define glProgramUniform1fvEXT glad_glProgramUniform1fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM1IEXTPROC glad_glProgramUniform1iEXT;
+#define glProgramUniform1iEXT glad_glProgramUniform1iEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM1IVEXTPROC glad_glProgramUniform1ivEXT;
+#define glProgramUniform1ivEXT glad_glProgramUniform1ivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM1UIEXTPROC glad_glProgramUniform1uiEXT;
+#define glProgramUniform1uiEXT glad_glProgramUniform1uiEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM1UIVEXTPROC glad_glProgramUniform1uivEXT;
+#define glProgramUniform1uivEXT glad_glProgramUniform1uivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM2FEXTPROC glad_glProgramUniform2fEXT;
+#define glProgramUniform2fEXT glad_glProgramUniform2fEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM2FVEXTPROC glad_glProgramUniform2fvEXT;
+#define glProgramUniform2fvEXT glad_glProgramUniform2fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM2IEXTPROC glad_glProgramUniform2iEXT;
+#define glProgramUniform2iEXT glad_glProgramUniform2iEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM2IVEXTPROC glad_glProgramUniform2ivEXT;
+#define glProgramUniform2ivEXT glad_glProgramUniform2ivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM2UIEXTPROC glad_glProgramUniform2uiEXT;
+#define glProgramUniform2uiEXT glad_glProgramUniform2uiEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM2UIVEXTPROC glad_glProgramUniform2uivEXT;
+#define glProgramUniform2uivEXT glad_glProgramUniform2uivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM3FEXTPROC glad_glProgramUniform3fEXT;
+#define glProgramUniform3fEXT glad_glProgramUniform3fEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM3FVEXTPROC glad_glProgramUniform3fvEXT;
+#define glProgramUniform3fvEXT glad_glProgramUniform3fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM3IEXTPROC glad_glProgramUniform3iEXT;
+#define glProgramUniform3iEXT glad_glProgramUniform3iEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM3IVEXTPROC glad_glProgramUniform3ivEXT;
+#define glProgramUniform3ivEXT glad_glProgramUniform3ivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM3UIEXTPROC glad_glProgramUniform3uiEXT;
+#define glProgramUniform3uiEXT glad_glProgramUniform3uiEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM3UIVEXTPROC glad_glProgramUniform3uivEXT;
+#define glProgramUniform3uivEXT glad_glProgramUniform3uivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM4FEXTPROC glad_glProgramUniform4fEXT;
+#define glProgramUniform4fEXT glad_glProgramUniform4fEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM4FVEXTPROC glad_glProgramUniform4fvEXT;
+#define glProgramUniform4fvEXT glad_glProgramUniform4fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM4IEXTPROC glad_glProgramUniform4iEXT;
+#define glProgramUniform4iEXT glad_glProgramUniform4iEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM4IVEXTPROC glad_glProgramUniform4ivEXT;
+#define glProgramUniform4ivEXT glad_glProgramUniform4ivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM4UIEXTPROC glad_glProgramUniform4uiEXT;
+#define glProgramUniform4uiEXT glad_glProgramUniform4uiEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM4UIVEXTPROC glad_glProgramUniform4uivEXT;
+#define glProgramUniform4uivEXT glad_glProgramUniform4uivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC glad_glProgramUniformMatrix2fvEXT;
+#define glProgramUniformMatrix2fvEXT glad_glProgramUniformMatrix2fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC glad_glProgramUniformMatrix2x3fvEXT;
+#define glProgramUniformMatrix2x3fvEXT glad_glProgramUniformMatrix2x3fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC glad_glProgramUniformMatrix2x4fvEXT;
+#define glProgramUniformMatrix2x4fvEXT glad_glProgramUniformMatrix2x4fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC glad_glProgramUniformMatrix3fvEXT;
+#define glProgramUniformMatrix3fvEXT glad_glProgramUniformMatrix3fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC glad_glProgramUniformMatrix3x2fvEXT;
+#define glProgramUniformMatrix3x2fvEXT glad_glProgramUniformMatrix3x2fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC glad_glProgramUniformMatrix3x4fvEXT;
+#define glProgramUniformMatrix3x4fvEXT glad_glProgramUniformMatrix3x4fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC glad_glProgramUniformMatrix4fvEXT;
+#define glProgramUniformMatrix4fvEXT glad_glProgramUniformMatrix4fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC glad_glProgramUniformMatrix4x2fvEXT;
+#define glProgramUniformMatrix4x2fvEXT glad_glProgramUniformMatrix4x2fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC glad_glProgramUniformMatrix4x3fvEXT;
+#define glProgramUniformMatrix4x3fvEXT glad_glProgramUniformMatrix4x3fvEXT
+GLAD_API_CALL PFNGLPUSHDEBUGGROUPKHRPROC glad_glPushDebugGroupKHR;
+#define glPushDebugGroupKHR glad_glPushDebugGroupKHR
+GLAD_API_CALL PFNGLPUSHGROUPMARKEREXTPROC glad_glPushGroupMarkerEXT;
+#define glPushGroupMarkerEXT glad_glPushGroupMarkerEXT
+GLAD_API_CALL PFNGLQUERYCOUNTEREXTPROC glad_glQueryCounterEXT;
+#define glQueryCounterEXT glad_glQueryCounterEXT
+GLAD_API_CALL PFNGLRASTERSAMPLESEXTPROC glad_glRasterSamplesEXT;
+#define glRasterSamplesEXT glad_glRasterSamplesEXT
+GLAD_API_CALL PFNGLREADBUFFERINDEXEDEXTPROC glad_glReadBufferIndexedEXT;
+#define glReadBufferIndexedEXT glad_glReadBufferIndexedEXT
+GLAD_API_CALL PFNGLREADPIXELSPROC glad_glReadPixels;
+#define glReadPixels glad_glReadPixels
+GLAD_API_CALL PFNGLREADNPIXELSEXTPROC glad_glReadnPixelsEXT;
+#define glReadnPixelsEXT glad_glReadnPixelsEXT
+GLAD_API_CALL PFNGLREADNPIXELSKHRPROC glad_glReadnPixelsKHR;
+#define glReadnPixelsKHR glad_glReadnPixelsKHR
+GLAD_API_CALL PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC glad_glReleaseKeyedMutexWin32EXT;
+#define glReleaseKeyedMutexWin32EXT glad_glReleaseKeyedMutexWin32EXT
+GLAD_API_CALL PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler;
+#define glReleaseShaderCompiler glad_glReleaseShaderCompiler
+GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
+#define glRenderbufferStorage glad_glRenderbufferStorage
+GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT;
+#define glRenderbufferStorageMultisampleEXT glad_glRenderbufferStorageMultisampleEXT
+GLAD_API_CALL PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
+#define glSampleCoverage glad_glSampleCoverage
+GLAD_API_CALL PFNGLSAMPLERPARAMETERIIVEXTPROC glad_glSamplerParameterIivEXT;
+#define glSamplerParameterIivEXT glad_glSamplerParameterIivEXT
+GLAD_API_CALL PFNGLSAMPLERPARAMETERIIVOESPROC glad_glSamplerParameterIivOES;
+#define glSamplerParameterIivOES glad_glSamplerParameterIivOES
+GLAD_API_CALL PFNGLSAMPLERPARAMETERIUIVEXTPROC glad_glSamplerParameterIuivEXT;
+#define glSamplerParameterIuivEXT glad_glSamplerParameterIuivEXT
+GLAD_API_CALL PFNGLSAMPLERPARAMETERIUIVOESPROC glad_glSamplerParameterIuivOES;
+#define glSamplerParameterIuivOES glad_glSamplerParameterIuivOES
+GLAD_API_CALL PFNGLSCISSORPROC glad_glScissor;
+#define glScissor glad_glScissor
+GLAD_API_CALL PFNGLSCISSORARRAYVOESPROC glad_glScissorArrayvOES;
+#define glScissorArrayvOES glad_glScissorArrayvOES
+GLAD_API_CALL PFNGLSCISSORINDEXEDOESPROC glad_glScissorIndexedOES;
+#define glScissorIndexedOES glad_glScissorIndexedOES
+GLAD_API_CALL PFNGLSCISSORINDEXEDVOESPROC glad_glScissorIndexedvOES;
+#define glScissorIndexedvOES glad_glScissorIndexedvOES
+GLAD_API_CALL PFNGLSEMAPHOREPARAMETERUI64VEXTPROC glad_glSemaphoreParameterui64vEXT;
+#define glSemaphoreParameterui64vEXT glad_glSemaphoreParameterui64vEXT
+GLAD_API_CALL PFNGLSHADERBINARYPROC glad_glShaderBinary;
+#define glShaderBinary glad_glShaderBinary
+GLAD_API_CALL PFNGLSHADERSOURCEPROC glad_glShaderSource;
+#define glShaderSource glad_glShaderSource
+GLAD_API_CALL PFNGLSHADINGRATECOMBINEROPSEXTPROC glad_glShadingRateCombinerOpsEXT;
+#define glShadingRateCombinerOpsEXT glad_glShadingRateCombinerOpsEXT
+GLAD_API_CALL PFNGLSHADINGRATEEXTPROC glad_glShadingRateEXT;
+#define glShadingRateEXT glad_glShadingRateEXT
+GLAD_API_CALL PFNGLSIGNALSEMAPHOREEXTPROC glad_glSignalSemaphoreEXT;
+#define glSignalSemaphoreEXT glad_glSignalSemaphoreEXT
+GLAD_API_CALL PFNGLSTENCILFUNCPROC glad_glStencilFunc;
+#define glStencilFunc glad_glStencilFunc
+GLAD_API_CALL PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
+#define glStencilFuncSeparate glad_glStencilFuncSeparate
+GLAD_API_CALL PFNGLSTENCILMASKPROC glad_glStencilMask;
+#define glStencilMask glad_glStencilMask
+GLAD_API_CALL PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
+#define glStencilMaskSeparate glad_glStencilMaskSeparate
+GLAD_API_CALL PFNGLSTENCILOPPROC glad_glStencilOp;
+#define glStencilOp glad_glStencilOp
+GLAD_API_CALL PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
+#define glStencilOpSeparate glad_glStencilOpSeparate
+GLAD_API_CALL PFNGLTEXBUFFEREXTPROC glad_glTexBufferEXT;
+#define glTexBufferEXT glad_glTexBufferEXT
+GLAD_API_CALL PFNGLTEXBUFFEROESPROC glad_glTexBufferOES;
+#define glTexBufferOES glad_glTexBufferOES
+GLAD_API_CALL PFNGLTEXBUFFERRANGEEXTPROC glad_glTexBufferRangeEXT;
+#define glTexBufferRangeEXT glad_glTexBufferRangeEXT
+GLAD_API_CALL PFNGLTEXBUFFERRANGEOESPROC glad_glTexBufferRangeOES;
+#define glTexBufferRangeOES glad_glTexBufferRangeOES
+GLAD_API_CALL PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
+#define glTexImage2D glad_glTexImage2D
+GLAD_API_CALL PFNGLTEXIMAGE3DOESPROC glad_glTexImage3DOES;
+#define glTexImage3DOES glad_glTexImage3DOES
+GLAD_API_CALL PFNGLTEXPAGECOMMITMENTEXTPROC glad_glTexPageCommitmentEXT;
+#define glTexPageCommitmentEXT glad_glTexPageCommitmentEXT
+GLAD_API_CALL PFNGLTEXPARAMETERIIVEXTPROC glad_glTexParameterIivEXT;
+#define glTexParameterIivEXT glad_glTexParameterIivEXT
+GLAD_API_CALL PFNGLTEXPARAMETERIIVOESPROC glad_glTexParameterIivOES;
+#define glTexParameterIivOES glad_glTexParameterIivOES
+GLAD_API_CALL PFNGLTEXPARAMETERIUIVEXTPROC glad_glTexParameterIuivEXT;
+#define glTexParameterIuivEXT glad_glTexParameterIuivEXT
+GLAD_API_CALL PFNGLTEXPARAMETERIUIVOESPROC glad_glTexParameterIuivOES;
+#define glTexParameterIuivOES glad_glTexParameterIuivOES
+GLAD_API_CALL PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
+#define glTexParameterf glad_glTexParameterf
+GLAD_API_CALL PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
+#define glTexParameterfv glad_glTexParameterfv
+GLAD_API_CALL PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
+#define glTexParameteri glad_glTexParameteri
+GLAD_API_CALL PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
+#define glTexParameteriv glad_glTexParameteriv
+GLAD_API_CALL PFNGLTEXSTORAGE1DEXTPROC glad_glTexStorage1DEXT;
+#define glTexStorage1DEXT glad_glTexStorage1DEXT
+GLAD_API_CALL PFNGLTEXSTORAGE2DEXTPROC glad_glTexStorage2DEXT;
+#define glTexStorage2DEXT glad_glTexStorage2DEXT
+GLAD_API_CALL PFNGLTEXSTORAGE3DEXTPROC glad_glTexStorage3DEXT;
+#define glTexStorage3DEXT glad_glTexStorage3DEXT
+GLAD_API_CALL PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC glad_glTexStorage3DMultisampleOES;
+#define glTexStorage3DMultisampleOES glad_glTexStorage3DMultisampleOES
+GLAD_API_CALL PFNGLTEXSTORAGEATTRIBS2DEXTPROC glad_glTexStorageAttribs2DEXT;
+#define glTexStorageAttribs2DEXT glad_glTexStorageAttribs2DEXT
+GLAD_API_CALL PFNGLTEXSTORAGEATTRIBS3DEXTPROC glad_glTexStorageAttribs3DEXT;
+#define glTexStorageAttribs3DEXT glad_glTexStorageAttribs3DEXT
+GLAD_API_CALL PFNGLTEXSTORAGEMEM2DEXTPROC glad_glTexStorageMem2DEXT;
+#define glTexStorageMem2DEXT glad_glTexStorageMem2DEXT
+GLAD_API_CALL PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC glad_glTexStorageMem2DMultisampleEXT;
+#define glTexStorageMem2DMultisampleEXT glad_glTexStorageMem2DMultisampleEXT
+GLAD_API_CALL PFNGLTEXSTORAGEMEM3DEXTPROC glad_glTexStorageMem3DEXT;
+#define glTexStorageMem3DEXT glad_glTexStorageMem3DEXT
+GLAD_API_CALL PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC glad_glTexStorageMem3DMultisampleEXT;
+#define glTexStorageMem3DMultisampleEXT glad_glTexStorageMem3DMultisampleEXT
+GLAD_API_CALL PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
+#define glTexSubImage2D glad_glTexSubImage2D
+GLAD_API_CALL PFNGLTEXSUBIMAGE3DOESPROC glad_glTexSubImage3DOES;
+#define glTexSubImage3DOES glad_glTexSubImage3DOES
+GLAD_API_CALL PFNGLTEXTURESTORAGE1DEXTPROC glad_glTextureStorage1DEXT;
+#define glTextureStorage1DEXT glad_glTextureStorage1DEXT
+GLAD_API_CALL PFNGLTEXTURESTORAGE2DEXTPROC glad_glTextureStorage2DEXT;
+#define glTextureStorage2DEXT glad_glTextureStorage2DEXT
+GLAD_API_CALL PFNGLTEXTURESTORAGE3DEXTPROC glad_glTextureStorage3DEXT;
+#define glTextureStorage3DEXT glad_glTextureStorage3DEXT
+GLAD_API_CALL PFNGLTEXTURESTORAGEMEM2DEXTPROC glad_glTextureStorageMem2DEXT;
+#define glTextureStorageMem2DEXT glad_glTextureStorageMem2DEXT
+GLAD_API_CALL PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC glad_glTextureStorageMem2DMultisampleEXT;
+#define glTextureStorageMem2DMultisampleEXT glad_glTextureStorageMem2DMultisampleEXT
+GLAD_API_CALL PFNGLTEXTURESTORAGEMEM3DEXTPROC glad_glTextureStorageMem3DEXT;
+#define glTextureStorageMem3DEXT glad_glTextureStorageMem3DEXT
+GLAD_API_CALL PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC glad_glTextureStorageMem3DMultisampleEXT;
+#define glTextureStorageMem3DMultisampleEXT glad_glTextureStorageMem3DMultisampleEXT
+GLAD_API_CALL PFNGLTEXTUREVIEWEXTPROC glad_glTextureViewEXT;
+#define glTextureViewEXT glad_glTextureViewEXT
+GLAD_API_CALL PFNGLTEXTUREVIEWOESPROC glad_glTextureViewOES;
+#define glTextureViewOES glad_glTextureViewOES
+GLAD_API_CALL PFNGLUNIFORM1FPROC glad_glUniform1f;
+#define glUniform1f glad_glUniform1f
+GLAD_API_CALL PFNGLUNIFORM1FVPROC glad_glUniform1fv;
+#define glUniform1fv glad_glUniform1fv
+GLAD_API_CALL PFNGLUNIFORM1IPROC glad_glUniform1i;
+#define glUniform1i glad_glUniform1i
+GLAD_API_CALL PFNGLUNIFORM1IVPROC glad_glUniform1iv;
+#define glUniform1iv glad_glUniform1iv
+GLAD_API_CALL PFNGLUNIFORM2FPROC glad_glUniform2f;
+#define glUniform2f glad_glUniform2f
+GLAD_API_CALL PFNGLUNIFORM2FVPROC glad_glUniform2fv;
+#define glUniform2fv glad_glUniform2fv
+GLAD_API_CALL PFNGLUNIFORM2IPROC glad_glUniform2i;
+#define glUniform2i glad_glUniform2i
+GLAD_API_CALL PFNGLUNIFORM2IVPROC glad_glUniform2iv;
+#define glUniform2iv glad_glUniform2iv
+GLAD_API_CALL PFNGLUNIFORM3FPROC glad_glUniform3f;
+#define glUniform3f glad_glUniform3f
+GLAD_API_CALL PFNGLUNIFORM3FVPROC glad_glUniform3fv;
+#define glUniform3fv glad_glUniform3fv
+GLAD_API_CALL PFNGLUNIFORM3IPROC glad_glUniform3i;
+#define glUniform3i glad_glUniform3i
+GLAD_API_CALL PFNGLUNIFORM3IVPROC glad_glUniform3iv;
+#define glUniform3iv glad_glUniform3iv
+GLAD_API_CALL PFNGLUNIFORM4FPROC glad_glUniform4f;
+#define glUniform4f glad_glUniform4f
+GLAD_API_CALL PFNGLUNIFORM4FVPROC glad_glUniform4fv;
+#define glUniform4fv glad_glUniform4fv
+GLAD_API_CALL PFNGLUNIFORM4IPROC glad_glUniform4i;
+#define glUniform4i glad_glUniform4i
+GLAD_API_CALL PFNGLUNIFORM4IVPROC glad_glUniform4iv;
+#define glUniform4iv glad_glUniform4iv
+GLAD_API_CALL PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
+#define glUniformMatrix2fv glad_glUniformMatrix2fv
+GLAD_API_CALL PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
+#define glUniformMatrix3fv glad_glUniformMatrix3fv
+GLAD_API_CALL PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
+#define glUniformMatrix4fv glad_glUniformMatrix4fv
+GLAD_API_CALL PFNGLUNMAPBUFFEROESPROC glad_glUnmapBufferOES;
+#define glUnmapBufferOES glad_glUnmapBufferOES
+GLAD_API_CALL PFNGLUSEPROGRAMPROC glad_glUseProgram;
+#define glUseProgram glad_glUseProgram
+GLAD_API_CALL PFNGLUSEPROGRAMSTAGESEXTPROC glad_glUseProgramStagesEXT;
+#define glUseProgramStagesEXT glad_glUseProgramStagesEXT
+GLAD_API_CALL PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
+#define glValidateProgram glad_glValidateProgram
+GLAD_API_CALL PFNGLVALIDATEPROGRAMPIPELINEEXTPROC glad_glValidateProgramPipelineEXT;
+#define glValidateProgramPipelineEXT glad_glValidateProgramPipelineEXT
+GLAD_API_CALL PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
+#define glVertexAttrib1f glad_glVertexAttrib1f
+GLAD_API_CALL PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
+#define glVertexAttrib1fv glad_glVertexAttrib1fv
+GLAD_API_CALL PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
+#define glVertexAttrib2f glad_glVertexAttrib2f
+GLAD_API_CALL PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
+#define glVertexAttrib2fv glad_glVertexAttrib2fv
+GLAD_API_CALL PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
+#define glVertexAttrib3f glad_glVertexAttrib3f
+GLAD_API_CALL PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
+#define glVertexAttrib3fv glad_glVertexAttrib3fv
+GLAD_API_CALL PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
+#define glVertexAttrib4f glad_glVertexAttrib4f
+GLAD_API_CALL PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
+#define glVertexAttrib4fv glad_glVertexAttrib4fv
+GLAD_API_CALL PFNGLVERTEXATTRIBDIVISOREXTPROC glad_glVertexAttribDivisorEXT;
+#define glVertexAttribDivisorEXT glad_glVertexAttribDivisorEXT
+GLAD_API_CALL PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
+#define glVertexAttribPointer glad_glVertexAttribPointer
+GLAD_API_CALL PFNGLVIEWPORTPROC glad_glViewport;
+#define glViewport glad_glViewport
+GLAD_API_CALL PFNGLVIEWPORTARRAYVOESPROC glad_glViewportArrayvOES;
+#define glViewportArrayvOES glad_glViewportArrayvOES
+GLAD_API_CALL PFNGLVIEWPORTINDEXEDFOESPROC glad_glViewportIndexedfOES;
+#define glViewportIndexedfOES glad_glViewportIndexedfOES
+GLAD_API_CALL PFNGLVIEWPORTINDEXEDFVOESPROC glad_glViewportIndexedfvOES;
+#define glViewportIndexedfvOES glad_glViewportIndexedfvOES
+GLAD_API_CALL PFNGLWAITSEMAPHOREEXTPROC glad_glWaitSemaphoreEXT;
+#define glWaitSemaphoreEXT glad_glWaitSemaphoreEXT
+GLAD_API_CALL PFNGLWINDOWRECTANGLESEXTPROC glad_glWindowRectanglesEXT;
+#define glWindowRectanglesEXT glad_glWindowRectanglesEXT
+
+
+
+
+
+GLAD_API_CALL int gladLoadGLES2UserPtr( GLADuserptrloadfunc load, void *userptr);
+GLAD_API_CALL int gladLoadGLES2( GLADloadfunc load);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+/* Source */
+#ifdef GLAD_GLES2_IMPLEMENTATION
+/**
+ * SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
+ */
+#include
+#include
+#include
+
+#ifndef GLAD_IMPL_UTIL_C_
+#define GLAD_IMPL_UTIL_C_
+
+#ifdef _MSC_VER
+#define GLAD_IMPL_UTIL_SSCANF sscanf_s
+#else
+#define GLAD_IMPL_UTIL_SSCANF sscanf
+#endif
+
+#endif /* GLAD_IMPL_UTIL_C_ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+int GLAD_GL_ES_VERSION_2_0 = 0;
+int GLAD_GL_EXT_EGL_image_array = 0;
+int GLAD_GL_EXT_EGL_image_storage = 0;
+int GLAD_GL_EXT_EGL_image_storage_compression = 0;
+int GLAD_GL_EXT_YUV_target = 0;
+int GLAD_GL_EXT_base_instance = 0;
+int GLAD_GL_EXT_blend_func_extended = 0;
+int GLAD_GL_EXT_blend_minmax = 0;
+int GLAD_GL_EXT_buffer_storage = 0;
+int GLAD_GL_EXT_clear_texture = 0;
+int GLAD_GL_EXT_clip_control = 0;
+int GLAD_GL_EXT_clip_cull_distance = 0;
+int GLAD_GL_EXT_color_buffer_float = 0;
+int GLAD_GL_EXT_color_buffer_half_float = 0;
+int GLAD_GL_EXT_conservative_depth = 0;
+int GLAD_GL_EXT_copy_image = 0;
+int GLAD_GL_EXT_debug_label = 0;
+int GLAD_GL_EXT_debug_marker = 0;
+int GLAD_GL_EXT_depth_clamp = 0;
+int GLAD_GL_EXT_discard_framebuffer = 0;
+int GLAD_GL_EXT_disjoint_timer_query = 0;
+int GLAD_GL_EXT_draw_buffers = 0;
+int GLAD_GL_EXT_draw_buffers_indexed = 0;
+int GLAD_GL_EXT_draw_elements_base_vertex = 0;
+int GLAD_GL_EXT_draw_instanced = 0;
+int GLAD_GL_EXT_draw_transform_feedback = 0;
+int GLAD_GL_EXT_external_buffer = 0;
+int GLAD_GL_EXT_float_blend = 0;
+int GLAD_GL_EXT_fragment_shading_rate = 0;
+int GLAD_GL_EXT_geometry_point_size = 0;
+int GLAD_GL_EXT_geometry_shader = 0;
+int GLAD_GL_EXT_gpu_shader5 = 0;
+int GLAD_GL_EXT_instanced_arrays = 0;
+int GLAD_GL_EXT_map_buffer_range = 0;
+int GLAD_GL_EXT_memory_object = 0;
+int GLAD_GL_EXT_memory_object_fd = 0;
+int GLAD_GL_EXT_memory_object_win32 = 0;
+int GLAD_GL_EXT_multi_draw_arrays = 0;
+int GLAD_GL_EXT_multi_draw_indirect = 0;
+int GLAD_GL_EXT_multisampled_compatibility = 0;
+int GLAD_GL_EXT_multisampled_render_to_texture = 0;
+int GLAD_GL_EXT_multisampled_render_to_texture2 = 0;
+int GLAD_GL_EXT_multiview_draw_buffers = 0;
+int GLAD_GL_EXT_multiview_tessellation_geometry_shader = 0;
+int GLAD_GL_EXT_multiview_texture_multisample = 0;
+int GLAD_GL_EXT_multiview_timer_query = 0;
+int GLAD_GL_EXT_occlusion_query_boolean = 0;
+int GLAD_GL_EXT_polygon_offset_clamp = 0;
+int GLAD_GL_EXT_post_depth_coverage = 0;
+int GLAD_GL_EXT_primitive_bounding_box = 0;
+int GLAD_GL_EXT_protected_textures = 0;
+int GLAD_GL_EXT_pvrtc_sRGB = 0;
+int GLAD_GL_EXT_raster_multisample = 0;
+int GLAD_GL_EXT_read_format_bgra = 0;
+int GLAD_GL_EXT_render_snorm = 0;
+int GLAD_GL_EXT_robustness = 0;
+int GLAD_GL_EXT_sRGB = 0;
+int GLAD_GL_EXT_sRGB_write_control = 0;
+int GLAD_GL_EXT_semaphore = 0;
+int GLAD_GL_EXT_semaphore_fd = 0;
+int GLAD_GL_EXT_semaphore_win32 = 0;
+int GLAD_GL_EXT_separate_depth_stencil = 0;
+int GLAD_GL_EXT_separate_shader_objects = 0;
+int GLAD_GL_EXT_shader_framebuffer_fetch = 0;
+int GLAD_GL_EXT_shader_framebuffer_fetch_non_coherent = 0;
+int GLAD_GL_EXT_shader_group_vote = 0;
+int GLAD_GL_EXT_shader_implicit_conversions = 0;
+int GLAD_GL_EXT_shader_integer_mix = 0;
+int GLAD_GL_EXT_shader_io_blocks = 0;
+int GLAD_GL_EXT_shader_non_constant_global_initializers = 0;
+int GLAD_GL_EXT_shader_pixel_local_storage = 0;
+int GLAD_GL_EXT_shader_pixel_local_storage2 = 0;
+int GLAD_GL_EXT_shader_samples_identical = 0;
+int GLAD_GL_EXT_shader_texture_lod = 0;
+int GLAD_GL_EXT_shadow_samplers = 0;
+int GLAD_GL_EXT_sparse_texture = 0;
+int GLAD_GL_EXT_sparse_texture2 = 0;
+int GLAD_GL_EXT_tessellation_point_size = 0;
+int GLAD_GL_EXT_tessellation_shader = 0;
+int GLAD_GL_EXT_texture_border_clamp = 0;
+int GLAD_GL_EXT_texture_buffer = 0;
+int GLAD_GL_EXT_texture_compression_astc_decode_mode = 0;
+int GLAD_GL_EXT_texture_compression_bptc = 0;
+int GLAD_GL_EXT_texture_compression_dxt1 = 0;
+int GLAD_GL_EXT_texture_compression_rgtc = 0;
+int GLAD_GL_EXT_texture_compression_s3tc = 0;
+int GLAD_GL_EXT_texture_compression_s3tc_srgb = 0;
+int GLAD_GL_EXT_texture_cube_map_array = 0;
+int GLAD_GL_EXT_texture_filter_anisotropic = 0;
+int GLAD_GL_EXT_texture_filter_minmax = 0;
+int GLAD_GL_EXT_texture_format_BGRA8888 = 0;
+int GLAD_GL_EXT_texture_format_sRGB_override = 0;
+int GLAD_GL_EXT_texture_mirror_clamp_to_edge = 0;
+int GLAD_GL_EXT_texture_norm16 = 0;
+int GLAD_GL_EXT_texture_query_lod = 0;
+int GLAD_GL_EXT_texture_rg = 0;
+int GLAD_GL_EXT_texture_sRGB_R8 = 0;
+int GLAD_GL_EXT_texture_sRGB_RG8 = 0;
+int GLAD_GL_EXT_texture_sRGB_decode = 0;
+int GLAD_GL_EXT_texture_shadow_lod = 0;
+int GLAD_GL_EXT_texture_storage = 0;
+int GLAD_GL_EXT_texture_storage_compression = 0;
+int GLAD_GL_EXT_texture_type_2_10_10_10_REV = 0;
+int GLAD_GL_EXT_texture_view = 0;
+int GLAD_GL_EXT_unpack_subimage = 0;
+int GLAD_GL_EXT_win32_keyed_mutex = 0;
+int GLAD_GL_EXT_window_rectangles = 0;
+int GLAD_GL_KHR_blend_equation_advanced = 0;
+int GLAD_GL_KHR_blend_equation_advanced_coherent = 0;
+int GLAD_GL_KHR_context_flush_control = 0;
+int GLAD_GL_KHR_debug = 0;
+int GLAD_GL_KHR_no_error = 0;
+int GLAD_GL_KHR_parallel_shader_compile = 0;
+int GLAD_GL_KHR_robust_buffer_access_behavior = 0;
+int GLAD_GL_KHR_robustness = 0;
+int GLAD_GL_KHR_shader_subgroup = 0;
+int GLAD_GL_KHR_texture_compression_astc_hdr = 0;
+int GLAD_GL_KHR_texture_compression_astc_ldr = 0;
+int GLAD_GL_KHR_texture_compression_astc_sliced_3d = 0;
+int GLAD_GL_OES_EGL_image = 0;
+int GLAD_GL_OES_EGL_image_external = 0;
+int GLAD_GL_OES_EGL_image_external_essl3 = 0;
+int GLAD_GL_OES_compressed_ETC1_RGB8_sub_texture = 0;
+int GLAD_GL_OES_compressed_ETC1_RGB8_texture = 0;
+int GLAD_GL_OES_compressed_paletted_texture = 0;
+int GLAD_GL_OES_copy_image = 0;
+int GLAD_GL_OES_depth24 = 0;
+int GLAD_GL_OES_depth32 = 0;
+int GLAD_GL_OES_depth_texture = 0;
+int GLAD_GL_OES_draw_buffers_indexed = 0;
+int GLAD_GL_OES_draw_elements_base_vertex = 0;
+int GLAD_GL_OES_element_index_uint = 0;
+int GLAD_GL_OES_fbo_render_mipmap = 0;
+int GLAD_GL_OES_fragment_precision_high = 0;
+int GLAD_GL_OES_geometry_point_size = 0;
+int GLAD_GL_OES_geometry_shader = 0;
+int GLAD_GL_OES_get_program_binary = 0;
+int GLAD_GL_OES_gpu_shader5 = 0;
+int GLAD_GL_OES_mapbuffer = 0;
+int GLAD_GL_OES_packed_depth_stencil = 0;
+int GLAD_GL_OES_primitive_bounding_box = 0;
+int GLAD_GL_OES_required_internalformat = 0;
+int GLAD_GL_OES_rgb8_rgba8 = 0;
+int GLAD_GL_OES_sample_shading = 0;
+int GLAD_GL_OES_sample_variables = 0;
+int GLAD_GL_OES_shader_image_atomic = 0;
+int GLAD_GL_OES_shader_io_blocks = 0;
+int GLAD_GL_OES_shader_multisample_interpolation = 0;
+int GLAD_GL_OES_standard_derivatives = 0;
+int GLAD_GL_OES_stencil1 = 0;
+int GLAD_GL_OES_stencil4 = 0;
+int GLAD_GL_OES_surfaceless_context = 0;
+int GLAD_GL_OES_tessellation_point_size = 0;
+int GLAD_GL_OES_tessellation_shader = 0;
+int GLAD_GL_OES_texture_3D = 0;
+int GLAD_GL_OES_texture_border_clamp = 0;
+int GLAD_GL_OES_texture_buffer = 0;
+int GLAD_GL_OES_texture_compression_astc = 0;
+int GLAD_GL_OES_texture_cube_map_array = 0;
+int GLAD_GL_OES_texture_float = 0;
+int GLAD_GL_OES_texture_float_linear = 0;
+int GLAD_GL_OES_texture_half_float = 0;
+int GLAD_GL_OES_texture_half_float_linear = 0;
+int GLAD_GL_OES_texture_npot = 0;
+int GLAD_GL_OES_texture_stencil8 = 0;
+int GLAD_GL_OES_texture_storage_multisample_2d_array = 0;
+int GLAD_GL_OES_texture_view = 0;
+int GLAD_GL_OES_vertex_array_object = 0;
+int GLAD_GL_OES_vertex_half_float = 0;
+int GLAD_GL_OES_vertex_type_10_10_10_2 = 0;
+int GLAD_GL_OES_viewport_array = 0;
+
+
+
+PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC glad_glAcquireKeyedMutexWin32EXT = NULL;
+PFNGLACTIVESHADERPROGRAMEXTPROC glad_glActiveShaderProgramEXT = NULL;
+PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL;
+PFNGLATTACHSHADERPROC glad_glAttachShader = NULL;
+PFNGLBEGINQUERYEXTPROC glad_glBeginQueryEXT = NULL;
+PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL;
+PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL;
+PFNGLBINDFRAGDATALOCATIONEXTPROC glad_glBindFragDataLocationEXT = NULL;
+PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC glad_glBindFragDataLocationIndexedEXT = NULL;
+PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL;
+PFNGLBINDPROGRAMPIPELINEEXTPROC glad_glBindProgramPipelineEXT = NULL;
+PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL;
+PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL;
+PFNGLBINDVERTEXARRAYOESPROC glad_glBindVertexArrayOES = NULL;
+PFNGLBLENDBARRIERKHRPROC glad_glBlendBarrierKHR = NULL;
+PFNGLBLENDCOLORPROC glad_glBlendColor = NULL;
+PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL;
+PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL;
+PFNGLBLENDEQUATIONSEPARATEIEXTPROC glad_glBlendEquationSeparateiEXT = NULL;
+PFNGLBLENDEQUATIONSEPARATEIOESPROC glad_glBlendEquationSeparateiOES = NULL;
+PFNGLBLENDEQUATIONIEXTPROC glad_glBlendEquationiEXT = NULL;
+PFNGLBLENDEQUATIONIOESPROC glad_glBlendEquationiOES = NULL;
+PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL;
+PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL;
+PFNGLBLENDFUNCSEPARATEIEXTPROC glad_glBlendFuncSeparateiEXT = NULL;
+PFNGLBLENDFUNCSEPARATEIOESPROC glad_glBlendFuncSeparateiOES = NULL;
+PFNGLBLENDFUNCIEXTPROC glad_glBlendFunciEXT = NULL;
+PFNGLBLENDFUNCIOESPROC glad_glBlendFunciOES = NULL;
+PFNGLBUFFERDATAPROC glad_glBufferData = NULL;
+PFNGLBUFFERSTORAGEEXTPROC glad_glBufferStorageEXT = NULL;
+PFNGLBUFFERSTORAGEEXTERNALEXTPROC glad_glBufferStorageExternalEXT = NULL;
+PFNGLBUFFERSTORAGEMEMEXTPROC glad_glBufferStorageMemEXT = NULL;
+PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL;
+PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL;
+PFNGLCLEARPROC glad_glClear = NULL;
+PFNGLCLEARCOLORPROC glad_glClearColor = NULL;
+PFNGLCLEARDEPTHFPROC glad_glClearDepthf = NULL;
+PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC glad_glClearPixelLocalStorageuiEXT = NULL;
+PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL;
+PFNGLCLEARTEXIMAGEEXTPROC glad_glClearTexImageEXT = NULL;
+PFNGLCLEARTEXSUBIMAGEEXTPROC glad_glClearTexSubImageEXT = NULL;
+PFNGLCLIPCONTROLEXTPROC glad_glClipControlEXT = NULL;
+PFNGLCOLORMASKPROC glad_glColorMask = NULL;
+PFNGLCOLORMASKIEXTPROC glad_glColorMaskiEXT = NULL;
+PFNGLCOLORMASKIOESPROC glad_glColorMaskiOES = NULL;
+PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL;
+PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL;
+PFNGLCOMPRESSEDTEXIMAGE3DOESPROC glad_glCompressedTexImage3DOES = NULL;
+PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL;
+PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC glad_glCompressedTexSubImage3DOES = NULL;
+PFNGLCOPYIMAGESUBDATAEXTPROC glad_glCopyImageSubDataEXT = NULL;
+PFNGLCOPYIMAGESUBDATAOESPROC glad_glCopyImageSubDataOES = NULL;
+PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL;
+PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL;
+PFNGLCOPYTEXSUBIMAGE3DOESPROC glad_glCopyTexSubImage3DOES = NULL;
+PFNGLCREATEMEMORYOBJECTSEXTPROC glad_glCreateMemoryObjectsEXT = NULL;
+PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL;
+PFNGLCREATESHADERPROC glad_glCreateShader = NULL;
+PFNGLCREATESHADERPROGRAMVEXTPROC glad_glCreateShaderProgramvEXT = NULL;
+PFNGLCULLFACEPROC glad_glCullFace = NULL;
+PFNGLDEBUGMESSAGECALLBACKKHRPROC glad_glDebugMessageCallbackKHR = NULL;
+PFNGLDEBUGMESSAGECONTROLKHRPROC glad_glDebugMessageControlKHR = NULL;
+PFNGLDEBUGMESSAGEINSERTKHRPROC glad_glDebugMessageInsertKHR = NULL;
+PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL;
+PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL;
+PFNGLDELETEMEMORYOBJECTSEXTPROC glad_glDeleteMemoryObjectsEXT = NULL;
+PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL;
+PFNGLDELETEPROGRAMPIPELINESEXTPROC glad_glDeleteProgramPipelinesEXT = NULL;
+PFNGLDELETEQUERIESEXTPROC glad_glDeleteQueriesEXT = NULL;
+PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL;
+PFNGLDELETESEMAPHORESEXTPROC glad_glDeleteSemaphoresEXT = NULL;
+PFNGLDELETESHADERPROC glad_glDeleteShader = NULL;
+PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL;
+PFNGLDELETEVERTEXARRAYSOESPROC glad_glDeleteVertexArraysOES = NULL;
+PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL;
+PFNGLDEPTHMASKPROC glad_glDepthMask = NULL;
+PFNGLDEPTHRANGEARRAYFVOESPROC glad_glDepthRangeArrayfvOES = NULL;
+PFNGLDEPTHRANGEINDEXEDFOESPROC glad_glDepthRangeIndexedfOES = NULL;
+PFNGLDEPTHRANGEFPROC glad_glDepthRangef = NULL;
+PFNGLDETACHSHADERPROC glad_glDetachShader = NULL;
+PFNGLDISABLEPROC glad_glDisable = NULL;
+PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL;
+PFNGLDISABLEIEXTPROC glad_glDisableiEXT = NULL;
+PFNGLDISABLEIOESPROC glad_glDisableiOES = NULL;
+PFNGLDISCARDFRAMEBUFFEREXTPROC glad_glDiscardFramebufferEXT = NULL;
+PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL;
+PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC glad_glDrawArraysInstancedBaseInstanceEXT = NULL;
+PFNGLDRAWARRAYSINSTANCEDEXTPROC glad_glDrawArraysInstancedEXT = NULL;
+PFNGLDRAWBUFFERSEXTPROC glad_glDrawBuffersEXT = NULL;
+PFNGLDRAWBUFFERSINDEXEDEXTPROC glad_glDrawBuffersIndexedEXT = NULL;
+PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL;
+PFNGLDRAWELEMENTSBASEVERTEXEXTPROC glad_glDrawElementsBaseVertexEXT = NULL;
+PFNGLDRAWELEMENTSBASEVERTEXOESPROC glad_glDrawElementsBaseVertexOES = NULL;
+PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC glad_glDrawElementsInstancedBaseInstanceEXT = NULL;
+PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC glad_glDrawElementsInstancedBaseVertexBaseInstanceEXT = NULL;
+PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC glad_glDrawElementsInstancedBaseVertexEXT = NULL;
+PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC glad_glDrawElementsInstancedBaseVertexOES = NULL;
+PFNGLDRAWELEMENTSINSTANCEDEXTPROC glad_glDrawElementsInstancedEXT = NULL;
+PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC glad_glDrawRangeElementsBaseVertexEXT = NULL;
+PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC glad_glDrawRangeElementsBaseVertexOES = NULL;
+PFNGLDRAWTRANSFORMFEEDBACKEXTPROC glad_glDrawTransformFeedbackEXT = NULL;
+PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC glad_glDrawTransformFeedbackInstancedEXT = NULL;
+PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glad_glEGLImageTargetRenderbufferStorageOES = NULL;
+PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC glad_glEGLImageTargetTexStorageEXT = NULL;
+PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glad_glEGLImageTargetTexture2DOES = NULL;
+PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC glad_glEGLImageTargetTextureStorageEXT = NULL;
+PFNGLENABLEPROC glad_glEnable = NULL;
+PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL;
+PFNGLENABLEIEXTPROC glad_glEnableiEXT = NULL;
+PFNGLENABLEIOESPROC glad_glEnableiOES = NULL;
+PFNGLENDQUERYEXTPROC glad_glEndQueryEXT = NULL;
+PFNGLFINISHPROC glad_glFinish = NULL;
+PFNGLFLUSHPROC glad_glFlush = NULL;
+PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC glad_glFlushMappedBufferRangeEXT = NULL;
+PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC glad_glFramebufferFetchBarrierEXT = NULL;
+PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC glad_glFramebufferPixelLocalStorageSizeEXT = NULL;
+PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL;
+PFNGLFRAMEBUFFERSHADINGRATEEXTPROC glad_glFramebufferShadingRateEXT = NULL;
+PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL;
+PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC glad_glFramebufferTexture2DMultisampleEXT = NULL;
+PFNGLFRAMEBUFFERTEXTURE3DOESPROC glad_glFramebufferTexture3DOES = NULL;
+PFNGLFRAMEBUFFERTEXTUREEXTPROC glad_glFramebufferTextureEXT = NULL;
+PFNGLFRAMEBUFFERTEXTUREOESPROC glad_glFramebufferTextureOES = NULL;
+PFNGLFRONTFACEPROC glad_glFrontFace = NULL;
+PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL;
+PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL;
+PFNGLGENPROGRAMPIPELINESEXTPROC glad_glGenProgramPipelinesEXT = NULL;
+PFNGLGENQUERIESEXTPROC glad_glGenQueriesEXT = NULL;
+PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL;
+PFNGLGENSEMAPHORESEXTPROC glad_glGenSemaphoresEXT = NULL;
+PFNGLGENTEXTURESPROC glad_glGenTextures = NULL;
+PFNGLGENVERTEXARRAYSOESPROC glad_glGenVertexArraysOES = NULL;
+PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL;
+PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL;
+PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL;
+PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL;
+PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL;
+PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL;
+PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL;
+PFNGLGETBUFFERPOINTERVOESPROC glad_glGetBufferPointervOES = NULL;
+PFNGLGETDEBUGMESSAGELOGKHRPROC glad_glGetDebugMessageLogKHR = NULL;
+PFNGLGETERRORPROC glad_glGetError = NULL;
+PFNGLGETFLOATI_VOESPROC glad_glGetFloati_vOES = NULL;
+PFNGLGETFLOATVPROC glad_glGetFloatv = NULL;
+PFNGLGETFRAGDATAINDEXEXTPROC glad_glGetFragDataIndexEXT = NULL;
+PFNGLGETFRAGMENTSHADINGRATESEXTPROC glad_glGetFragmentShadingRatesEXT = NULL;
+PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL;
+PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC glad_glGetFramebufferPixelLocalStorageSizeEXT = NULL;
+PFNGLGETGRAPHICSRESETSTATUSEXTPROC glad_glGetGraphicsResetStatusEXT = NULL;
+PFNGLGETGRAPHICSRESETSTATUSKHRPROC glad_glGetGraphicsResetStatusKHR = NULL;
+PFNGLGETINTEGER64VEXTPROC glad_glGetInteger64vEXT = NULL;
+PFNGLGETINTEGERI_VEXTPROC glad_glGetIntegeri_vEXT = NULL;
+PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL;
+PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC glad_glGetMemoryObjectParameterivEXT = NULL;
+PFNGLGETOBJECTLABELEXTPROC glad_glGetObjectLabelEXT = NULL;
+PFNGLGETOBJECTLABELKHRPROC glad_glGetObjectLabelKHR = NULL;
+PFNGLGETOBJECTPTRLABELKHRPROC glad_glGetObjectPtrLabelKHR = NULL;
+PFNGLGETPOINTERVKHRPROC glad_glGetPointervKHR = NULL;
+PFNGLGETPROGRAMBINARYOESPROC glad_glGetProgramBinaryOES = NULL;
+PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL;
+PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC glad_glGetProgramPipelineInfoLogEXT = NULL;
+PFNGLGETPROGRAMPIPELINEIVEXTPROC glad_glGetProgramPipelineivEXT = NULL;
+PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC glad_glGetProgramResourceLocationIndexEXT = NULL;
+PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL;
+PFNGLGETQUERYOBJECTI64VEXTPROC glad_glGetQueryObjecti64vEXT = NULL;
+PFNGLGETQUERYOBJECTIVEXTPROC glad_glGetQueryObjectivEXT = NULL;
+PFNGLGETQUERYOBJECTUI64VEXTPROC glad_glGetQueryObjectui64vEXT = NULL;
+PFNGLGETQUERYOBJECTUIVEXTPROC glad_glGetQueryObjectuivEXT = NULL;
+PFNGLGETQUERYIVEXTPROC glad_glGetQueryivEXT = NULL;
+PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL;
+PFNGLGETSAMPLERPARAMETERIIVEXTPROC glad_glGetSamplerParameterIivEXT = NULL;
+PFNGLGETSAMPLERPARAMETERIIVOESPROC glad_glGetSamplerParameterIivOES = NULL;
+PFNGLGETSAMPLERPARAMETERIUIVEXTPROC glad_glGetSamplerParameterIuivEXT = NULL;
+PFNGLGETSAMPLERPARAMETERIUIVOESPROC glad_glGetSamplerParameterIuivOES = NULL;
+PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC glad_glGetSemaphoreParameterui64vEXT = NULL;
+PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL;
+PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat = NULL;
+PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL;
+PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL;
+PFNGLGETSTRINGPROC glad_glGetString = NULL;
+PFNGLGETTEXPARAMETERIIVEXTPROC glad_glGetTexParameterIivEXT = NULL;
+PFNGLGETTEXPARAMETERIIVOESPROC glad_glGetTexParameterIivOES = NULL;
+PFNGLGETTEXPARAMETERIUIVEXTPROC glad_glGetTexParameterIuivEXT = NULL;
+PFNGLGETTEXPARAMETERIUIVOESPROC glad_glGetTexParameterIuivOES = NULL;
+PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL;
+PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL;
+PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL;
+PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL;
+PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL;
+PFNGLGETUNSIGNEDBYTEI_VEXTPROC glad_glGetUnsignedBytei_vEXT = NULL;
+PFNGLGETUNSIGNEDBYTEVEXTPROC glad_glGetUnsignedBytevEXT = NULL;
+PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL;
+PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL;
+PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL;
+PFNGLGETNUNIFORMFVEXTPROC glad_glGetnUniformfvEXT = NULL;
+PFNGLGETNUNIFORMFVKHRPROC glad_glGetnUniformfvKHR = NULL;
+PFNGLGETNUNIFORMIVEXTPROC glad_glGetnUniformivEXT = NULL;
+PFNGLGETNUNIFORMIVKHRPROC glad_glGetnUniformivKHR = NULL;
+PFNGLGETNUNIFORMUIVKHRPROC glad_glGetnUniformuivKHR = NULL;
+PFNGLHINTPROC glad_glHint = NULL;
+PFNGLIMPORTMEMORYFDEXTPROC glad_glImportMemoryFdEXT = NULL;
+PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC glad_glImportMemoryWin32HandleEXT = NULL;
+PFNGLIMPORTMEMORYWIN32NAMEEXTPROC glad_glImportMemoryWin32NameEXT = NULL;
+PFNGLIMPORTSEMAPHOREFDEXTPROC glad_glImportSemaphoreFdEXT = NULL;
+PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC glad_glImportSemaphoreWin32HandleEXT = NULL;
+PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC glad_glImportSemaphoreWin32NameEXT = NULL;
+PFNGLINSERTEVENTMARKEREXTPROC glad_glInsertEventMarkerEXT = NULL;
+PFNGLISBUFFERPROC glad_glIsBuffer = NULL;
+PFNGLISENABLEDPROC glad_glIsEnabled = NULL;
+PFNGLISENABLEDIEXTPROC glad_glIsEnablediEXT = NULL;
+PFNGLISENABLEDIOESPROC glad_glIsEnablediOES = NULL;
+PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL;
+PFNGLISMEMORYOBJECTEXTPROC glad_glIsMemoryObjectEXT = NULL;
+PFNGLISPROGRAMPROC glad_glIsProgram = NULL;
+PFNGLISPROGRAMPIPELINEEXTPROC glad_glIsProgramPipelineEXT = NULL;
+PFNGLISQUERYEXTPROC glad_glIsQueryEXT = NULL;
+PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL;
+PFNGLISSEMAPHOREEXTPROC glad_glIsSemaphoreEXT = NULL;
+PFNGLISSHADERPROC glad_glIsShader = NULL;
+PFNGLISTEXTUREPROC glad_glIsTexture = NULL;
+PFNGLISVERTEXARRAYOESPROC glad_glIsVertexArrayOES = NULL;
+PFNGLLABELOBJECTEXTPROC glad_glLabelObjectEXT = NULL;
+PFNGLLINEWIDTHPROC glad_glLineWidth = NULL;
+PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL;
+PFNGLMAPBUFFEROESPROC glad_glMapBufferOES = NULL;
+PFNGLMAPBUFFERRANGEEXTPROC glad_glMapBufferRangeEXT = NULL;
+PFNGLMAXSHADERCOMPILERTHREADSKHRPROC glad_glMaxShaderCompilerThreadsKHR = NULL;
+PFNGLMEMORYOBJECTPARAMETERIVEXTPROC glad_glMemoryObjectParameterivEXT = NULL;
+PFNGLMINSAMPLESHADINGOESPROC glad_glMinSampleShadingOES = NULL;
+PFNGLMULTIDRAWARRAYSEXTPROC glad_glMultiDrawArraysEXT = NULL;
+PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC glad_glMultiDrawArraysIndirectEXT = NULL;
+PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC glad_glMultiDrawElementsBaseVertexEXT = NULL;
+PFNGLMULTIDRAWELEMENTSEXTPROC glad_glMultiDrawElementsEXT = NULL;
+PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC glad_glMultiDrawElementsIndirectEXT = NULL;
+PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC glad_glNamedBufferStorageExternalEXT = NULL;
+PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC glad_glNamedBufferStorageMemEXT = NULL;
+PFNGLOBJECTLABELKHRPROC glad_glObjectLabelKHR = NULL;
+PFNGLOBJECTPTRLABELKHRPROC glad_glObjectPtrLabelKHR = NULL;
+PFNGLPATCHPARAMETERIEXTPROC glad_glPatchParameteriEXT = NULL;
+PFNGLPATCHPARAMETERIOESPROC glad_glPatchParameteriOES = NULL;
+PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL;
+PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL;
+PFNGLPOLYGONOFFSETCLAMPEXTPROC glad_glPolygonOffsetClampEXT = NULL;
+PFNGLPOPDEBUGGROUPKHRPROC glad_glPopDebugGroupKHR = NULL;
+PFNGLPOPGROUPMARKEREXTPROC glad_glPopGroupMarkerEXT = NULL;
+PFNGLPRIMITIVEBOUNDINGBOXEXTPROC glad_glPrimitiveBoundingBoxEXT = NULL;
+PFNGLPRIMITIVEBOUNDINGBOXOESPROC glad_glPrimitiveBoundingBoxOES = NULL;
+PFNGLPROGRAMBINARYOESPROC glad_glProgramBinaryOES = NULL;
+PFNGLPROGRAMPARAMETERIEXTPROC glad_glProgramParameteriEXT = NULL;
+PFNGLPROGRAMUNIFORM1FEXTPROC glad_glProgramUniform1fEXT = NULL;
+PFNGLPROGRAMUNIFORM1FVEXTPROC glad_glProgramUniform1fvEXT = NULL;
+PFNGLPROGRAMUNIFORM1IEXTPROC glad_glProgramUniform1iEXT = NULL;
+PFNGLPROGRAMUNIFORM1IVEXTPROC glad_glProgramUniform1ivEXT = NULL;
+PFNGLPROGRAMUNIFORM1UIEXTPROC glad_glProgramUniform1uiEXT = NULL;
+PFNGLPROGRAMUNIFORM1UIVEXTPROC glad_glProgramUniform1uivEXT = NULL;
+PFNGLPROGRAMUNIFORM2FEXTPROC glad_glProgramUniform2fEXT = NULL;
+PFNGLPROGRAMUNIFORM2FVEXTPROC glad_glProgramUniform2fvEXT = NULL;
+PFNGLPROGRAMUNIFORM2IEXTPROC glad_glProgramUniform2iEXT = NULL;
+PFNGLPROGRAMUNIFORM2IVEXTPROC glad_glProgramUniform2ivEXT = NULL;
+PFNGLPROGRAMUNIFORM2UIEXTPROC glad_glProgramUniform2uiEXT = NULL;
+PFNGLPROGRAMUNIFORM2UIVEXTPROC glad_glProgramUniform2uivEXT = NULL;
+PFNGLPROGRAMUNIFORM3FEXTPROC glad_glProgramUniform3fEXT = NULL;
+PFNGLPROGRAMUNIFORM3FVEXTPROC glad_glProgramUniform3fvEXT = NULL;
+PFNGLPROGRAMUNIFORM3IEXTPROC glad_glProgramUniform3iEXT = NULL;
+PFNGLPROGRAMUNIFORM3IVEXTPROC glad_glProgramUniform3ivEXT = NULL;
+PFNGLPROGRAMUNIFORM3UIEXTPROC glad_glProgramUniform3uiEXT = NULL;
+PFNGLPROGRAMUNIFORM3UIVEXTPROC glad_glProgramUniform3uivEXT = NULL;
+PFNGLPROGRAMUNIFORM4FEXTPROC glad_glProgramUniform4fEXT = NULL;
+PFNGLPROGRAMUNIFORM4FVEXTPROC glad_glProgramUniform4fvEXT = NULL;
+PFNGLPROGRAMUNIFORM4IEXTPROC glad_glProgramUniform4iEXT = NULL;
+PFNGLPROGRAMUNIFORM4IVEXTPROC glad_glProgramUniform4ivEXT = NULL;
+PFNGLPROGRAMUNIFORM4UIEXTPROC glad_glProgramUniform4uiEXT = NULL;
+PFNGLPROGRAMUNIFORM4UIVEXTPROC glad_glProgramUniform4uivEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC glad_glProgramUniformMatrix2fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC glad_glProgramUniformMatrix2x3fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC glad_glProgramUniformMatrix2x4fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC glad_glProgramUniformMatrix3fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC glad_glProgramUniformMatrix3x2fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC glad_glProgramUniformMatrix3x4fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC glad_glProgramUniformMatrix4fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC glad_glProgramUniformMatrix4x2fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC glad_glProgramUniformMatrix4x3fvEXT = NULL;
+PFNGLPUSHDEBUGGROUPKHRPROC glad_glPushDebugGroupKHR = NULL;
+PFNGLPUSHGROUPMARKEREXTPROC glad_glPushGroupMarkerEXT = NULL;
+PFNGLQUERYCOUNTEREXTPROC glad_glQueryCounterEXT = NULL;
+PFNGLRASTERSAMPLESEXTPROC glad_glRasterSamplesEXT = NULL;
+PFNGLREADBUFFERINDEXEDEXTPROC glad_glReadBufferIndexedEXT = NULL;
+PFNGLREADPIXELSPROC glad_glReadPixels = NULL;
+PFNGLREADNPIXELSEXTPROC glad_glReadnPixelsEXT = NULL;
+PFNGLREADNPIXELSKHRPROC glad_glReadnPixelsKHR = NULL;
+PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC glad_glReleaseKeyedMutexWin32EXT = NULL;
+PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler = NULL;
+PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL;
+PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT = NULL;
+PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL;
+PFNGLSAMPLERPARAMETERIIVEXTPROC glad_glSamplerParameterIivEXT = NULL;
+PFNGLSAMPLERPARAMETERIIVOESPROC glad_glSamplerParameterIivOES = NULL;
+PFNGLSAMPLERPARAMETERIUIVEXTPROC glad_glSamplerParameterIuivEXT = NULL;
+PFNGLSAMPLERPARAMETERIUIVOESPROC glad_glSamplerParameterIuivOES = NULL;
+PFNGLSCISSORPROC glad_glScissor = NULL;
+PFNGLSCISSORARRAYVOESPROC glad_glScissorArrayvOES = NULL;
+PFNGLSCISSORINDEXEDOESPROC glad_glScissorIndexedOES = NULL;
+PFNGLSCISSORINDEXEDVOESPROC glad_glScissorIndexedvOES = NULL;
+PFNGLSEMAPHOREPARAMETERUI64VEXTPROC glad_glSemaphoreParameterui64vEXT = NULL;
+PFNGLSHADERBINARYPROC glad_glShaderBinary = NULL;
+PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL;
+PFNGLSHADINGRATECOMBINEROPSEXTPROC glad_glShadingRateCombinerOpsEXT = NULL;
+PFNGLSHADINGRATEEXTPROC glad_glShadingRateEXT = NULL;
+PFNGLSIGNALSEMAPHOREEXTPROC glad_glSignalSemaphoreEXT = NULL;
+PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL;
+PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL;
+PFNGLSTENCILMASKPROC glad_glStencilMask = NULL;
+PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL;
+PFNGLSTENCILOPPROC glad_glStencilOp = NULL;
+PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL;
+PFNGLTEXBUFFEREXTPROC glad_glTexBufferEXT = NULL;
+PFNGLTEXBUFFEROESPROC glad_glTexBufferOES = NULL;
+PFNGLTEXBUFFERRANGEEXTPROC glad_glTexBufferRangeEXT = NULL;
+PFNGLTEXBUFFERRANGEOESPROC glad_glTexBufferRangeOES = NULL;
+PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL;
+PFNGLTEXIMAGE3DOESPROC glad_glTexImage3DOES = NULL;
+PFNGLTEXPAGECOMMITMENTEXTPROC glad_glTexPageCommitmentEXT = NULL;
+PFNGLTEXPARAMETERIIVEXTPROC glad_glTexParameterIivEXT = NULL;
+PFNGLTEXPARAMETERIIVOESPROC glad_glTexParameterIivOES = NULL;
+PFNGLTEXPARAMETERIUIVEXTPROC glad_glTexParameterIuivEXT = NULL;
+PFNGLTEXPARAMETERIUIVOESPROC glad_glTexParameterIuivOES = NULL;
+PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL;
+PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL;
+PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL;
+PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL;
+PFNGLTEXSTORAGE1DEXTPROC glad_glTexStorage1DEXT = NULL;
+PFNGLTEXSTORAGE2DEXTPROC glad_glTexStorage2DEXT = NULL;
+PFNGLTEXSTORAGE3DEXTPROC glad_glTexStorage3DEXT = NULL;
+PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC glad_glTexStorage3DMultisampleOES = NULL;
+PFNGLTEXSTORAGEATTRIBS2DEXTPROC glad_glTexStorageAttribs2DEXT = NULL;
+PFNGLTEXSTORAGEATTRIBS3DEXTPROC glad_glTexStorageAttribs3DEXT = NULL;
+PFNGLTEXSTORAGEMEM2DEXTPROC glad_glTexStorageMem2DEXT = NULL;
+PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC glad_glTexStorageMem2DMultisampleEXT = NULL;
+PFNGLTEXSTORAGEMEM3DEXTPROC glad_glTexStorageMem3DEXT = NULL;
+PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC glad_glTexStorageMem3DMultisampleEXT = NULL;
+PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL;
+PFNGLTEXSUBIMAGE3DOESPROC glad_glTexSubImage3DOES = NULL;
+PFNGLTEXTURESTORAGE1DEXTPROC glad_glTextureStorage1DEXT = NULL;
+PFNGLTEXTURESTORAGE2DEXTPROC glad_glTextureStorage2DEXT = NULL;
+PFNGLTEXTURESTORAGE3DEXTPROC glad_glTextureStorage3DEXT = NULL;
+PFNGLTEXTURESTORAGEMEM2DEXTPROC glad_glTextureStorageMem2DEXT = NULL;
+PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC glad_glTextureStorageMem2DMultisampleEXT = NULL;
+PFNGLTEXTURESTORAGEMEM3DEXTPROC glad_glTextureStorageMem3DEXT = NULL;
+PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC glad_glTextureStorageMem3DMultisampleEXT = NULL;
+PFNGLTEXTUREVIEWEXTPROC glad_glTextureViewEXT = NULL;
+PFNGLTEXTUREVIEWOESPROC glad_glTextureViewOES = NULL;
+PFNGLUNIFORM1FPROC glad_glUniform1f = NULL;
+PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL;
+PFNGLUNIFORM1IPROC glad_glUniform1i = NULL;
+PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL;
+PFNGLUNIFORM2FPROC glad_glUniform2f = NULL;
+PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL;
+PFNGLUNIFORM2IPROC glad_glUniform2i = NULL;
+PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL;
+PFNGLUNIFORM3FPROC glad_glUniform3f = NULL;
+PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL;
+PFNGLUNIFORM3IPROC glad_glUniform3i = NULL;
+PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL;
+PFNGLUNIFORM4FPROC glad_glUniform4f = NULL;
+PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL;
+PFNGLUNIFORM4IPROC glad_glUniform4i = NULL;
+PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL;
+PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL;
+PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL;
+PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL;
+PFNGLUNMAPBUFFEROESPROC glad_glUnmapBufferOES = NULL;
+PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL;
+PFNGLUSEPROGRAMSTAGESEXTPROC glad_glUseProgramStagesEXT = NULL;
+PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL;
+PFNGLVALIDATEPROGRAMPIPELINEEXTPROC glad_glValidateProgramPipelineEXT = NULL;
+PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL;
+PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL;
+PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL;
+PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL;
+PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL;
+PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL;
+PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL;
+PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL;
+PFNGLVERTEXATTRIBDIVISOREXTPROC glad_glVertexAttribDivisorEXT = NULL;
+PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL;
+PFNGLVIEWPORTPROC glad_glViewport = NULL;
+PFNGLVIEWPORTARRAYVOESPROC glad_glViewportArrayvOES = NULL;
+PFNGLVIEWPORTINDEXEDFOESPROC glad_glViewportIndexedfOES = NULL;
+PFNGLVIEWPORTINDEXEDFVOESPROC glad_glViewportIndexedfvOES = NULL;
+PFNGLWAITSEMAPHOREEXTPROC glad_glWaitSemaphoreEXT = NULL;
+PFNGLWINDOWRECTANGLESEXTPROC glad_glWindowRectanglesEXT = NULL;
+
+
+static void glad_gl_load_GL_ES_VERSION_2_0( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_ES_VERSION_2_0) return;
+ glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC) load(userptr, "glActiveTexture");
+ glad_glAttachShader = (PFNGLATTACHSHADERPROC) load(userptr, "glAttachShader");
+ glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load(userptr, "glBindAttribLocation");
+ glad_glBindBuffer = (PFNGLBINDBUFFERPROC) load(userptr, "glBindBuffer");
+ glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load(userptr, "glBindFramebuffer");
+ glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load(userptr, "glBindRenderbuffer");
+ glad_glBindTexture = (PFNGLBINDTEXTUREPROC) load(userptr, "glBindTexture");
+ glad_glBlendColor = (PFNGLBLENDCOLORPROC) load(userptr, "glBlendColor");
+ glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC) load(userptr, "glBlendEquation");
+ glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load(userptr, "glBlendEquationSeparate");
+ glad_glBlendFunc = (PFNGLBLENDFUNCPROC) load(userptr, "glBlendFunc");
+ glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load(userptr, "glBlendFuncSeparate");
+ glad_glBufferData = (PFNGLBUFFERDATAPROC) load(userptr, "glBufferData");
+ glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load(userptr, "glBufferSubData");
+ glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load(userptr, "glCheckFramebufferStatus");
+ glad_glClear = (PFNGLCLEARPROC) load(userptr, "glClear");
+ glad_glClearColor = (PFNGLCLEARCOLORPROC) load(userptr, "glClearColor");
+ glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC) load(userptr, "glClearDepthf");
+ glad_glClearStencil = (PFNGLCLEARSTENCILPROC) load(userptr, "glClearStencil");
+ glad_glColorMask = (PFNGLCOLORMASKPROC) load(userptr, "glColorMask");
+ glad_glCompileShader = (PFNGLCOMPILESHADERPROC) load(userptr, "glCompileShader");
+ glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load(userptr, "glCompressedTexImage2D");
+ glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load(userptr, "glCompressedTexSubImage2D");
+ glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load(userptr, "glCopyTexImage2D");
+ glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load(userptr, "glCopyTexSubImage2D");
+ glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC) load(userptr, "glCreateProgram");
+ glad_glCreateShader = (PFNGLCREATESHADERPROC) load(userptr, "glCreateShader");
+ glad_glCullFace = (PFNGLCULLFACEPROC) load(userptr, "glCullFace");
+ glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load(userptr, "glDeleteBuffers");
+ glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load(userptr, "glDeleteFramebuffers");
+ glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load(userptr, "glDeleteProgram");
+ glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load(userptr, "glDeleteRenderbuffers");
+ glad_glDeleteShader = (PFNGLDELETESHADERPROC) load(userptr, "glDeleteShader");
+ glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC) load(userptr, "glDeleteTextures");
+ glad_glDepthFunc = (PFNGLDEPTHFUNCPROC) load(userptr, "glDepthFunc");
+ glad_glDepthMask = (PFNGLDEPTHMASKPROC) load(userptr, "glDepthMask");
+ glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC) load(userptr, "glDepthRangef");
+ glad_glDetachShader = (PFNGLDETACHSHADERPROC) load(userptr, "glDetachShader");
+ glad_glDisable = (PFNGLDISABLEPROC) load(userptr, "glDisable");
+ glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load(userptr, "glDisableVertexAttribArray");
+ glad_glDrawArrays = (PFNGLDRAWARRAYSPROC) load(userptr, "glDrawArrays");
+ glad_glDrawElements = (PFNGLDRAWELEMENTSPROC) load(userptr, "glDrawElements");
+ glad_glEnable = (PFNGLENABLEPROC) load(userptr, "glEnable");
+ glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load(userptr, "glEnableVertexAttribArray");
+ glad_glFinish = (PFNGLFINISHPROC) load(userptr, "glFinish");
+ glad_glFlush = (PFNGLFLUSHPROC) load(userptr, "glFlush");
+ glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load(userptr, "glFramebufferRenderbuffer");
+ glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load(userptr, "glFramebufferTexture2D");
+ glad_glFrontFace = (PFNGLFRONTFACEPROC) load(userptr, "glFrontFace");
+ glad_glGenBuffers = (PFNGLGENBUFFERSPROC) load(userptr, "glGenBuffers");
+ glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load(userptr, "glGenFramebuffers");
+ glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load(userptr, "glGenRenderbuffers");
+ glad_glGenTextures = (PFNGLGENTEXTURESPROC) load(userptr, "glGenTextures");
+ glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load(userptr, "glGenerateMipmap");
+ glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load(userptr, "glGetActiveAttrib");
+ glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load(userptr, "glGetActiveUniform");
+ glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load(userptr, "glGetAttachedShaders");
+ glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load(userptr, "glGetAttribLocation");
+ glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC) load(userptr, "glGetBooleanv");
+ glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load(userptr, "glGetBufferParameteriv");
+ glad_glGetError = (PFNGLGETERRORPROC) load(userptr, "glGetError");
+ glad_glGetFloatv = (PFNGLGETFLOATVPROC) load(userptr, "glGetFloatv");
+ glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load(userptr, "glGetFramebufferAttachmentParameteriv");
+ glad_glGetIntegerv = (PFNGLGETINTEGERVPROC) load(userptr, "glGetIntegerv");
+ glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load(userptr, "glGetProgramInfoLog");
+ glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load(userptr, "glGetProgramiv");
+ glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load(userptr, "glGetRenderbufferParameteriv");
+ glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load(userptr, "glGetShaderInfoLog");
+ glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC) load(userptr, "glGetShaderPrecisionFormat");
+ glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load(userptr, "glGetShaderSource");
+ glad_glGetShaderiv = (PFNGLGETSHADERIVPROC) load(userptr, "glGetShaderiv");
+ glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
+ glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load(userptr, "glGetTexParameterfv");
+ glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load(userptr, "glGetTexParameteriv");
+ glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load(userptr, "glGetUniformLocation");
+ glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load(userptr, "glGetUniformfv");
+ glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load(userptr, "glGetUniformiv");
+ glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load(userptr, "glGetVertexAttribPointerv");
+ glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load(userptr, "glGetVertexAttribfv");
+ glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load(userptr, "glGetVertexAttribiv");
+ glad_glHint = (PFNGLHINTPROC) load(userptr, "glHint");
+ glad_glIsBuffer = (PFNGLISBUFFERPROC) load(userptr, "glIsBuffer");
+ glad_glIsEnabled = (PFNGLISENABLEDPROC) load(userptr, "glIsEnabled");
+ glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load(userptr, "glIsFramebuffer");
+ glad_glIsProgram = (PFNGLISPROGRAMPROC) load(userptr, "glIsProgram");
+ glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load(userptr, "glIsRenderbuffer");
+ glad_glIsShader = (PFNGLISSHADERPROC) load(userptr, "glIsShader");
+ glad_glIsTexture = (PFNGLISTEXTUREPROC) load(userptr, "glIsTexture");
+ glad_glLineWidth = (PFNGLLINEWIDTHPROC) load(userptr, "glLineWidth");
+ glad_glLinkProgram = (PFNGLLINKPROGRAMPROC) load(userptr, "glLinkProgram");
+ glad_glPixelStorei = (PFNGLPIXELSTOREIPROC) load(userptr, "glPixelStorei");
+ glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load(userptr, "glPolygonOffset");
+ glad_glReadPixels = (PFNGLREADPIXELSPROC) load(userptr, "glReadPixels");
+ glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC) load(userptr, "glReleaseShaderCompiler");
+ glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load(userptr, "glRenderbufferStorage");
+ glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load(userptr, "glSampleCoverage");
+ glad_glScissor = (PFNGLSCISSORPROC) load(userptr, "glScissor");
+ glad_glShaderBinary = (PFNGLSHADERBINARYPROC) load(userptr, "glShaderBinary");
+ glad_glShaderSource = (PFNGLSHADERSOURCEPROC) load(userptr, "glShaderSource");
+ glad_glStencilFunc = (PFNGLSTENCILFUNCPROC) load(userptr, "glStencilFunc");
+ glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load(userptr, "glStencilFuncSeparate");
+ glad_glStencilMask = (PFNGLSTENCILMASKPROC) load(userptr, "glStencilMask");
+ glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load(userptr, "glStencilMaskSeparate");
+ glad_glStencilOp = (PFNGLSTENCILOPPROC) load(userptr, "glStencilOp");
+ glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load(userptr, "glStencilOpSeparate");
+ glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC) load(userptr, "glTexImage2D");
+ glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC) load(userptr, "glTexParameterf");
+ glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load(userptr, "glTexParameterfv");
+ glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC) load(userptr, "glTexParameteri");
+ glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load(userptr, "glTexParameteriv");
+ glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load(userptr, "glTexSubImage2D");
+ glad_glUniform1f = (PFNGLUNIFORM1FPROC) load(userptr, "glUniform1f");
+ glad_glUniform1fv = (PFNGLUNIFORM1FVPROC) load(userptr, "glUniform1fv");
+ glad_glUniform1i = (PFNGLUNIFORM1IPROC) load(userptr, "glUniform1i");
+ glad_glUniform1iv = (PFNGLUNIFORM1IVPROC) load(userptr, "glUniform1iv");
+ glad_glUniform2f = (PFNGLUNIFORM2FPROC) load(userptr, "glUniform2f");
+ glad_glUniform2fv = (PFNGLUNIFORM2FVPROC) load(userptr, "glUniform2fv");
+ glad_glUniform2i = (PFNGLUNIFORM2IPROC) load(userptr, "glUniform2i");
+ glad_glUniform2iv = (PFNGLUNIFORM2IVPROC) load(userptr, "glUniform2iv");
+ glad_glUniform3f = (PFNGLUNIFORM3FPROC) load(userptr, "glUniform3f");
+ glad_glUniform3fv = (PFNGLUNIFORM3FVPROC) load(userptr, "glUniform3fv");
+ glad_glUniform3i = (PFNGLUNIFORM3IPROC) load(userptr, "glUniform3i");
+ glad_glUniform3iv = (PFNGLUNIFORM3IVPROC) load(userptr, "glUniform3iv");
+ glad_glUniform4f = (PFNGLUNIFORM4FPROC) load(userptr, "glUniform4f");
+ glad_glUniform4fv = (PFNGLUNIFORM4FVPROC) load(userptr, "glUniform4fv");
+ glad_glUniform4i = (PFNGLUNIFORM4IPROC) load(userptr, "glUniform4i");
+ glad_glUniform4iv = (PFNGLUNIFORM4IVPROC) load(userptr, "glUniform4iv");
+ glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load(userptr, "glUniformMatrix2fv");
+ glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load(userptr, "glUniformMatrix3fv");
+ glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load(userptr, "glUniformMatrix4fv");
+ glad_glUseProgram = (PFNGLUSEPROGRAMPROC) load(userptr, "glUseProgram");
+ glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load(userptr, "glValidateProgram");
+ glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load(userptr, "glVertexAttrib1f");
+ glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load(userptr, "glVertexAttrib1fv");
+ glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load(userptr, "glVertexAttrib2f");
+ glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load(userptr, "glVertexAttrib2fv");
+ glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load(userptr, "glVertexAttrib3f");
+ glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load(userptr, "glVertexAttrib3fv");
+ glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load(userptr, "glVertexAttrib4f");
+ glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load(userptr, "glVertexAttrib4fv");
+ glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load(userptr, "glVertexAttribPointer");
+ glad_glViewport = (PFNGLVIEWPORTPROC) load(userptr, "glViewport");
+}
+static void glad_gl_load_GL_EXT_EGL_image_storage( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_EGL_image_storage) return;
+ glad_glEGLImageTargetTexStorageEXT = (PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) load(userptr, "glEGLImageTargetTexStorageEXT");
+ glad_glEGLImageTargetTextureStorageEXT = (PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) load(userptr, "glEGLImageTargetTextureStorageEXT");
+}
+static void glad_gl_load_GL_EXT_base_instance( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_base_instance) return;
+ glad_glDrawArraysInstancedBaseInstanceEXT = (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC) load(userptr, "glDrawArraysInstancedBaseInstanceEXT");
+ glad_glDrawElementsInstancedBaseInstanceEXT = (PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC) load(userptr, "glDrawElementsInstancedBaseInstanceEXT");
+ glad_glDrawElementsInstancedBaseVertexBaseInstanceEXT = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC) load(userptr, "glDrawElementsInstancedBaseVertexBaseInstanceEXT");
+}
+static void glad_gl_load_GL_EXT_blend_func_extended( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_blend_func_extended) return;
+ glad_glBindFragDataLocationEXT = (PFNGLBINDFRAGDATALOCATIONEXTPROC) load(userptr, "glBindFragDataLocationEXT");
+ glad_glBindFragDataLocationIndexedEXT = (PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC) load(userptr, "glBindFragDataLocationIndexedEXT");
+ glad_glGetFragDataIndexEXT = (PFNGLGETFRAGDATAINDEXEXTPROC) load(userptr, "glGetFragDataIndexEXT");
+ glad_glGetProgramResourceLocationIndexEXT = (PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC) load(userptr, "glGetProgramResourceLocationIndexEXT");
+}
+static void glad_gl_load_GL_EXT_buffer_storage( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_buffer_storage) return;
+ glad_glBufferStorageEXT = (PFNGLBUFFERSTORAGEEXTPROC) load(userptr, "glBufferStorageEXT");
+}
+static void glad_gl_load_GL_EXT_clear_texture( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_clear_texture) return;
+ glad_glClearTexImageEXT = (PFNGLCLEARTEXIMAGEEXTPROC) load(userptr, "glClearTexImageEXT");
+ glad_glClearTexSubImageEXT = (PFNGLCLEARTEXSUBIMAGEEXTPROC) load(userptr, "glClearTexSubImageEXT");
+}
+static void glad_gl_load_GL_EXT_clip_control( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_clip_control) return;
+ glad_glClipControlEXT = (PFNGLCLIPCONTROLEXTPROC) load(userptr, "glClipControlEXT");
+}
+static void glad_gl_load_GL_EXT_copy_image( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_copy_image) return;
+ glad_glCopyImageSubDataEXT = (PFNGLCOPYIMAGESUBDATAEXTPROC) load(userptr, "glCopyImageSubDataEXT");
+}
+static void glad_gl_load_GL_EXT_debug_label( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_debug_label) return;
+ glad_glGetObjectLabelEXT = (PFNGLGETOBJECTLABELEXTPROC) load(userptr, "glGetObjectLabelEXT");
+ glad_glLabelObjectEXT = (PFNGLLABELOBJECTEXTPROC) load(userptr, "glLabelObjectEXT");
+}
+static void glad_gl_load_GL_EXT_debug_marker( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_debug_marker) return;
+ glad_glInsertEventMarkerEXT = (PFNGLINSERTEVENTMARKEREXTPROC) load(userptr, "glInsertEventMarkerEXT");
+ glad_glPopGroupMarkerEXT = (PFNGLPOPGROUPMARKEREXTPROC) load(userptr, "glPopGroupMarkerEXT");
+ glad_glPushGroupMarkerEXT = (PFNGLPUSHGROUPMARKEREXTPROC) load(userptr, "glPushGroupMarkerEXT");
+}
+static void glad_gl_load_GL_EXT_discard_framebuffer( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_discard_framebuffer) return;
+ glad_glDiscardFramebufferEXT = (PFNGLDISCARDFRAMEBUFFEREXTPROC) load(userptr, "glDiscardFramebufferEXT");
+}
+static void glad_gl_load_GL_EXT_disjoint_timer_query( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_disjoint_timer_query) return;
+ glad_glBeginQueryEXT = (PFNGLBEGINQUERYEXTPROC) load(userptr, "glBeginQueryEXT");
+ glad_glDeleteQueriesEXT = (PFNGLDELETEQUERIESEXTPROC) load(userptr, "glDeleteQueriesEXT");
+ glad_glEndQueryEXT = (PFNGLENDQUERYEXTPROC) load(userptr, "glEndQueryEXT");
+ glad_glGenQueriesEXT = (PFNGLGENQUERIESEXTPROC) load(userptr, "glGenQueriesEXT");
+ glad_glGetInteger64vEXT = (PFNGLGETINTEGER64VEXTPROC) load(userptr, "glGetInteger64vEXT");
+ glad_glGetQueryObjecti64vEXT = (PFNGLGETQUERYOBJECTI64VEXTPROC) load(userptr, "glGetQueryObjecti64vEXT");
+ glad_glGetQueryObjectivEXT = (PFNGLGETQUERYOBJECTIVEXTPROC) load(userptr, "glGetQueryObjectivEXT");
+ glad_glGetQueryObjectui64vEXT = (PFNGLGETQUERYOBJECTUI64VEXTPROC) load(userptr, "glGetQueryObjectui64vEXT");
+ glad_glGetQueryObjectuivEXT = (PFNGLGETQUERYOBJECTUIVEXTPROC) load(userptr, "glGetQueryObjectuivEXT");
+ glad_glGetQueryivEXT = (PFNGLGETQUERYIVEXTPROC) load(userptr, "glGetQueryivEXT");
+ glad_glIsQueryEXT = (PFNGLISQUERYEXTPROC) load(userptr, "glIsQueryEXT");
+ glad_glQueryCounterEXT = (PFNGLQUERYCOUNTEREXTPROC) load(userptr, "glQueryCounterEXT");
+}
+static void glad_gl_load_GL_EXT_draw_buffers( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_draw_buffers) return;
+ glad_glDrawBuffersEXT = (PFNGLDRAWBUFFERSEXTPROC) load(userptr, "glDrawBuffersEXT");
+}
+static void glad_gl_load_GL_EXT_draw_buffers_indexed( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_draw_buffers_indexed) return;
+ glad_glBlendEquationSeparateiEXT = (PFNGLBLENDEQUATIONSEPARATEIEXTPROC) load(userptr, "glBlendEquationSeparateiEXT");
+ glad_glBlendEquationiEXT = (PFNGLBLENDEQUATIONIEXTPROC) load(userptr, "glBlendEquationiEXT");
+ glad_glBlendFuncSeparateiEXT = (PFNGLBLENDFUNCSEPARATEIEXTPROC) load(userptr, "glBlendFuncSeparateiEXT");
+ glad_glBlendFunciEXT = (PFNGLBLENDFUNCIEXTPROC) load(userptr, "glBlendFunciEXT");
+ glad_glColorMaskiEXT = (PFNGLCOLORMASKIEXTPROC) load(userptr, "glColorMaskiEXT");
+ glad_glDisableiEXT = (PFNGLDISABLEIEXTPROC) load(userptr, "glDisableiEXT");
+ glad_glEnableiEXT = (PFNGLENABLEIEXTPROC) load(userptr, "glEnableiEXT");
+ glad_glIsEnablediEXT = (PFNGLISENABLEDIEXTPROC) load(userptr, "glIsEnablediEXT");
+}
+static void glad_gl_load_GL_EXT_draw_elements_base_vertex( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_draw_elements_base_vertex) return;
+ glad_glDrawElementsBaseVertexEXT = (PFNGLDRAWELEMENTSBASEVERTEXEXTPROC) load(userptr, "glDrawElementsBaseVertexEXT");
+ glad_glDrawElementsInstancedBaseVertexEXT = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC) load(userptr, "glDrawElementsInstancedBaseVertexEXT");
+ glad_glDrawRangeElementsBaseVertexEXT = (PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC) load(userptr, "glDrawRangeElementsBaseVertexEXT");
+ glad_glMultiDrawElementsBaseVertexEXT = (PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC) load(userptr, "glMultiDrawElementsBaseVertexEXT");
+}
+static void glad_gl_load_GL_EXT_draw_instanced( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_draw_instanced) return;
+ glad_glDrawArraysInstancedEXT = (PFNGLDRAWARRAYSINSTANCEDEXTPROC) load(userptr, "glDrawArraysInstancedEXT");
+ glad_glDrawElementsInstancedEXT = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC) load(userptr, "glDrawElementsInstancedEXT");
+}
+static void glad_gl_load_GL_EXT_draw_transform_feedback( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_draw_transform_feedback) return;
+ glad_glDrawTransformFeedbackEXT = (PFNGLDRAWTRANSFORMFEEDBACKEXTPROC) load(userptr, "glDrawTransformFeedbackEXT");
+ glad_glDrawTransformFeedbackInstancedEXT = (PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC) load(userptr, "glDrawTransformFeedbackInstancedEXT");
+}
+static void glad_gl_load_GL_EXT_external_buffer( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_external_buffer) return;
+ glad_glBufferStorageExternalEXT = (PFNGLBUFFERSTORAGEEXTERNALEXTPROC) load(userptr, "glBufferStorageExternalEXT");
+ glad_glNamedBufferStorageExternalEXT = (PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) load(userptr, "glNamedBufferStorageExternalEXT");
+}
+static void glad_gl_load_GL_EXT_fragment_shading_rate( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_fragment_shading_rate) return;
+ glad_glFramebufferShadingRateEXT = (PFNGLFRAMEBUFFERSHADINGRATEEXTPROC) load(userptr, "glFramebufferShadingRateEXT");
+ glad_glGetFragmentShadingRatesEXT = (PFNGLGETFRAGMENTSHADINGRATESEXTPROC) load(userptr, "glGetFragmentShadingRatesEXT");
+ glad_glShadingRateCombinerOpsEXT = (PFNGLSHADINGRATECOMBINEROPSEXTPROC) load(userptr, "glShadingRateCombinerOpsEXT");
+ glad_glShadingRateEXT = (PFNGLSHADINGRATEEXTPROC) load(userptr, "glShadingRateEXT");
+}
+static void glad_gl_load_GL_EXT_geometry_shader( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_geometry_shader) return;
+ glad_glFramebufferTextureEXT = (PFNGLFRAMEBUFFERTEXTUREEXTPROC) load(userptr, "glFramebufferTextureEXT");
+}
+static void glad_gl_load_GL_EXT_instanced_arrays( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_instanced_arrays) return;
+ glad_glDrawArraysInstancedEXT = (PFNGLDRAWARRAYSINSTANCEDEXTPROC) load(userptr, "glDrawArraysInstancedEXT");
+ glad_glDrawElementsInstancedEXT = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC) load(userptr, "glDrawElementsInstancedEXT");
+ glad_glVertexAttribDivisorEXT = (PFNGLVERTEXATTRIBDIVISOREXTPROC) load(userptr, "glVertexAttribDivisorEXT");
+}
+static void glad_gl_load_GL_EXT_map_buffer_range( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_map_buffer_range) return;
+ glad_glFlushMappedBufferRangeEXT = (PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) load(userptr, "glFlushMappedBufferRangeEXT");
+ glad_glMapBufferRangeEXT = (PFNGLMAPBUFFERRANGEEXTPROC) load(userptr, "glMapBufferRangeEXT");
+}
+static void glad_gl_load_GL_EXT_memory_object( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_memory_object) return;
+ glad_glBufferStorageMemEXT = (PFNGLBUFFERSTORAGEMEMEXTPROC) load(userptr, "glBufferStorageMemEXT");
+ glad_glCreateMemoryObjectsEXT = (PFNGLCREATEMEMORYOBJECTSEXTPROC) load(userptr, "glCreateMemoryObjectsEXT");
+ glad_glDeleteMemoryObjectsEXT = (PFNGLDELETEMEMORYOBJECTSEXTPROC) load(userptr, "glDeleteMemoryObjectsEXT");
+ glad_glGetMemoryObjectParameterivEXT = (PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) load(userptr, "glGetMemoryObjectParameterivEXT");
+ glad_glGetUnsignedBytei_vEXT = (PFNGLGETUNSIGNEDBYTEI_VEXTPROC) load(userptr, "glGetUnsignedBytei_vEXT");
+ glad_glGetUnsignedBytevEXT = (PFNGLGETUNSIGNEDBYTEVEXTPROC) load(userptr, "glGetUnsignedBytevEXT");
+ glad_glIsMemoryObjectEXT = (PFNGLISMEMORYOBJECTEXTPROC) load(userptr, "glIsMemoryObjectEXT");
+ glad_glMemoryObjectParameterivEXT = (PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) load(userptr, "glMemoryObjectParameterivEXT");
+ glad_glNamedBufferStorageMemEXT = (PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) load(userptr, "glNamedBufferStorageMemEXT");
+ glad_glTexStorageMem2DEXT = (PFNGLTEXSTORAGEMEM2DEXTPROC) load(userptr, "glTexStorageMem2DEXT");
+ glad_glTexStorageMem2DMultisampleEXT = (PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) load(userptr, "glTexStorageMem2DMultisampleEXT");
+ glad_glTexStorageMem3DEXT = (PFNGLTEXSTORAGEMEM3DEXTPROC) load(userptr, "glTexStorageMem3DEXT");
+ glad_glTexStorageMem3DMultisampleEXT = (PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) load(userptr, "glTexStorageMem3DMultisampleEXT");
+ glad_glTextureStorageMem2DEXT = (PFNGLTEXTURESTORAGEMEM2DEXTPROC) load(userptr, "glTextureStorageMem2DEXT");
+ glad_glTextureStorageMem2DMultisampleEXT = (PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) load(userptr, "glTextureStorageMem2DMultisampleEXT");
+ glad_glTextureStorageMem3DEXT = (PFNGLTEXTURESTORAGEMEM3DEXTPROC) load(userptr, "glTextureStorageMem3DEXT");
+ glad_glTextureStorageMem3DMultisampleEXT = (PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) load(userptr, "glTextureStorageMem3DMultisampleEXT");
+}
+static void glad_gl_load_GL_EXT_memory_object_fd( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_memory_object_fd) return;
+ glad_glImportMemoryFdEXT = (PFNGLIMPORTMEMORYFDEXTPROC) load(userptr, "glImportMemoryFdEXT");
+}
+static void glad_gl_load_GL_EXT_memory_object_win32( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_memory_object_win32) return;
+ glad_glImportMemoryWin32HandleEXT = (PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) load(userptr, "glImportMemoryWin32HandleEXT");
+ glad_glImportMemoryWin32NameEXT = (PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) load(userptr, "glImportMemoryWin32NameEXT");
+}
+static void glad_gl_load_GL_EXT_multi_draw_arrays( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_multi_draw_arrays) return;
+ glad_glMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC) load(userptr, "glMultiDrawArraysEXT");
+ glad_glMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC) load(userptr, "glMultiDrawElementsEXT");
+}
+static void glad_gl_load_GL_EXT_multi_draw_indirect( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_multi_draw_indirect) return;
+ glad_glMultiDrawArraysIndirectEXT = (PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC) load(userptr, "glMultiDrawArraysIndirectEXT");
+ glad_glMultiDrawElementsIndirectEXT = (PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC) load(userptr, "glMultiDrawElementsIndirectEXT");
+}
+static void glad_gl_load_GL_EXT_multisampled_render_to_texture( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_multisampled_render_to_texture) return;
+ glad_glFramebufferTexture2DMultisampleEXT = (PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) load(userptr, "glFramebufferTexture2DMultisampleEXT");
+ glad_glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) load(userptr, "glRenderbufferStorageMultisampleEXT");
+}
+static void glad_gl_load_GL_EXT_multiview_draw_buffers( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_multiview_draw_buffers) return;
+ glad_glDrawBuffersIndexedEXT = (PFNGLDRAWBUFFERSINDEXEDEXTPROC) load(userptr, "glDrawBuffersIndexedEXT");
+ glad_glGetIntegeri_vEXT = (PFNGLGETINTEGERI_VEXTPROC) load(userptr, "glGetIntegeri_vEXT");
+ glad_glReadBufferIndexedEXT = (PFNGLREADBUFFERINDEXEDEXTPROC) load(userptr, "glReadBufferIndexedEXT");
+}
+static void glad_gl_load_GL_EXT_occlusion_query_boolean( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_occlusion_query_boolean) return;
+ glad_glBeginQueryEXT = (PFNGLBEGINQUERYEXTPROC) load(userptr, "glBeginQueryEXT");
+ glad_glDeleteQueriesEXT = (PFNGLDELETEQUERIESEXTPROC) load(userptr, "glDeleteQueriesEXT");
+ glad_glEndQueryEXT = (PFNGLENDQUERYEXTPROC) load(userptr, "glEndQueryEXT");
+ glad_glGenQueriesEXT = (PFNGLGENQUERIESEXTPROC) load(userptr, "glGenQueriesEXT");
+ glad_glGetQueryObjectuivEXT = (PFNGLGETQUERYOBJECTUIVEXTPROC) load(userptr, "glGetQueryObjectuivEXT");
+ glad_glGetQueryivEXT = (PFNGLGETQUERYIVEXTPROC) load(userptr, "glGetQueryivEXT");
+ glad_glIsQueryEXT = (PFNGLISQUERYEXTPROC) load(userptr, "glIsQueryEXT");
+}
+static void glad_gl_load_GL_EXT_polygon_offset_clamp( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_polygon_offset_clamp) return;
+ glad_glPolygonOffsetClampEXT = (PFNGLPOLYGONOFFSETCLAMPEXTPROC) load(userptr, "glPolygonOffsetClampEXT");
+}
+static void glad_gl_load_GL_EXT_primitive_bounding_box( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_primitive_bounding_box) return;
+ glad_glPrimitiveBoundingBoxEXT = (PFNGLPRIMITIVEBOUNDINGBOXEXTPROC) load(userptr, "glPrimitiveBoundingBoxEXT");
+}
+static void glad_gl_load_GL_EXT_raster_multisample( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_raster_multisample) return;
+ glad_glRasterSamplesEXT = (PFNGLRASTERSAMPLESEXTPROC) load(userptr, "glRasterSamplesEXT");
+}
+static void glad_gl_load_GL_EXT_robustness( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_robustness) return;
+ glad_glGetGraphicsResetStatusEXT = (PFNGLGETGRAPHICSRESETSTATUSEXTPROC) load(userptr, "glGetGraphicsResetStatusEXT");
+ glad_glGetnUniformfvEXT = (PFNGLGETNUNIFORMFVEXTPROC) load(userptr, "glGetnUniformfvEXT");
+ glad_glGetnUniformivEXT = (PFNGLGETNUNIFORMIVEXTPROC) load(userptr, "glGetnUniformivEXT");
+ glad_glReadnPixelsEXT = (PFNGLREADNPIXELSEXTPROC) load(userptr, "glReadnPixelsEXT");
+}
+static void glad_gl_load_GL_EXT_semaphore( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_semaphore) return;
+ glad_glDeleteSemaphoresEXT = (PFNGLDELETESEMAPHORESEXTPROC) load(userptr, "glDeleteSemaphoresEXT");
+ glad_glGenSemaphoresEXT = (PFNGLGENSEMAPHORESEXTPROC) load(userptr, "glGenSemaphoresEXT");
+ glad_glGetSemaphoreParameterui64vEXT = (PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) load(userptr, "glGetSemaphoreParameterui64vEXT");
+ glad_glGetUnsignedBytei_vEXT = (PFNGLGETUNSIGNEDBYTEI_VEXTPROC) load(userptr, "glGetUnsignedBytei_vEXT");
+ glad_glGetUnsignedBytevEXT = (PFNGLGETUNSIGNEDBYTEVEXTPROC) load(userptr, "glGetUnsignedBytevEXT");
+ glad_glIsSemaphoreEXT = (PFNGLISSEMAPHOREEXTPROC) load(userptr, "glIsSemaphoreEXT");
+ glad_glSemaphoreParameterui64vEXT = (PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) load(userptr, "glSemaphoreParameterui64vEXT");
+ glad_glSignalSemaphoreEXT = (PFNGLSIGNALSEMAPHOREEXTPROC) load(userptr, "glSignalSemaphoreEXT");
+ glad_glWaitSemaphoreEXT = (PFNGLWAITSEMAPHOREEXTPROC) load(userptr, "glWaitSemaphoreEXT");
+}
+static void glad_gl_load_GL_EXT_semaphore_fd( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_semaphore_fd) return;
+ glad_glImportSemaphoreFdEXT = (PFNGLIMPORTSEMAPHOREFDEXTPROC) load(userptr, "glImportSemaphoreFdEXT");
+}
+static void glad_gl_load_GL_EXT_semaphore_win32( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_semaphore_win32) return;
+ glad_glImportSemaphoreWin32HandleEXT = (PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) load(userptr, "glImportSemaphoreWin32HandleEXT");
+ glad_glImportSemaphoreWin32NameEXT = (PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) load(userptr, "glImportSemaphoreWin32NameEXT");
+}
+static void glad_gl_load_GL_EXT_separate_shader_objects( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_separate_shader_objects) return;
+ glad_glActiveShaderProgramEXT = (PFNGLACTIVESHADERPROGRAMEXTPROC) load(userptr, "glActiveShaderProgramEXT");
+ glad_glBindProgramPipelineEXT = (PFNGLBINDPROGRAMPIPELINEEXTPROC) load(userptr, "glBindProgramPipelineEXT");
+ glad_glCreateShaderProgramvEXT = (PFNGLCREATESHADERPROGRAMVEXTPROC) load(userptr, "glCreateShaderProgramvEXT");
+ glad_glDeleteProgramPipelinesEXT = (PFNGLDELETEPROGRAMPIPELINESEXTPROC) load(userptr, "glDeleteProgramPipelinesEXT");
+ glad_glGenProgramPipelinesEXT = (PFNGLGENPROGRAMPIPELINESEXTPROC) load(userptr, "glGenProgramPipelinesEXT");
+ glad_glGetProgramPipelineInfoLogEXT = (PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) load(userptr, "glGetProgramPipelineInfoLogEXT");
+ glad_glGetProgramPipelineivEXT = (PFNGLGETPROGRAMPIPELINEIVEXTPROC) load(userptr, "glGetProgramPipelineivEXT");
+ glad_glIsProgramPipelineEXT = (PFNGLISPROGRAMPIPELINEEXTPROC) load(userptr, "glIsProgramPipelineEXT");
+ glad_glProgramParameteriEXT = (PFNGLPROGRAMPARAMETERIEXTPROC) load(userptr, "glProgramParameteriEXT");
+ glad_glProgramUniform1fEXT = (PFNGLPROGRAMUNIFORM1FEXTPROC) load(userptr, "glProgramUniform1fEXT");
+ glad_glProgramUniform1fvEXT = (PFNGLPROGRAMUNIFORM1FVEXTPROC) load(userptr, "glProgramUniform1fvEXT");
+ glad_glProgramUniform1iEXT = (PFNGLPROGRAMUNIFORM1IEXTPROC) load(userptr, "glProgramUniform1iEXT");
+ glad_glProgramUniform1ivEXT = (PFNGLPROGRAMUNIFORM1IVEXTPROC) load(userptr, "glProgramUniform1ivEXT");
+ glad_glProgramUniform1uiEXT = (PFNGLPROGRAMUNIFORM1UIEXTPROC) load(userptr, "glProgramUniform1uiEXT");
+ glad_glProgramUniform1uivEXT = (PFNGLPROGRAMUNIFORM1UIVEXTPROC) load(userptr, "glProgramUniform1uivEXT");
+ glad_glProgramUniform2fEXT = (PFNGLPROGRAMUNIFORM2FEXTPROC) load(userptr, "glProgramUniform2fEXT");
+ glad_glProgramUniform2fvEXT = (PFNGLPROGRAMUNIFORM2FVEXTPROC) load(userptr, "glProgramUniform2fvEXT");
+ glad_glProgramUniform2iEXT = (PFNGLPROGRAMUNIFORM2IEXTPROC) load(userptr, "glProgramUniform2iEXT");
+ glad_glProgramUniform2ivEXT = (PFNGLPROGRAMUNIFORM2IVEXTPROC) load(userptr, "glProgramUniform2ivEXT");
+ glad_glProgramUniform2uiEXT = (PFNGLPROGRAMUNIFORM2UIEXTPROC) load(userptr, "glProgramUniform2uiEXT");
+ glad_glProgramUniform2uivEXT = (PFNGLPROGRAMUNIFORM2UIVEXTPROC) load(userptr, "glProgramUniform2uivEXT");
+ glad_glProgramUniform3fEXT = (PFNGLPROGRAMUNIFORM3FEXTPROC) load(userptr, "glProgramUniform3fEXT");
+ glad_glProgramUniform3fvEXT = (PFNGLPROGRAMUNIFORM3FVEXTPROC) load(userptr, "glProgramUniform3fvEXT");
+ glad_glProgramUniform3iEXT = (PFNGLPROGRAMUNIFORM3IEXTPROC) load(userptr, "glProgramUniform3iEXT");
+ glad_glProgramUniform3ivEXT = (PFNGLPROGRAMUNIFORM3IVEXTPROC) load(userptr, "glProgramUniform3ivEXT");
+ glad_glProgramUniform3uiEXT = (PFNGLPROGRAMUNIFORM3UIEXTPROC) load(userptr, "glProgramUniform3uiEXT");
+ glad_glProgramUniform3uivEXT = (PFNGLPROGRAMUNIFORM3UIVEXTPROC) load(userptr, "glProgramUniform3uivEXT");
+ glad_glProgramUniform4fEXT = (PFNGLPROGRAMUNIFORM4FEXTPROC) load(userptr, "glProgramUniform4fEXT");
+ glad_glProgramUniform4fvEXT = (PFNGLPROGRAMUNIFORM4FVEXTPROC) load(userptr, "glProgramUniform4fvEXT");
+ glad_glProgramUniform4iEXT = (PFNGLPROGRAMUNIFORM4IEXTPROC) load(userptr, "glProgramUniform4iEXT");
+ glad_glProgramUniform4ivEXT = (PFNGLPROGRAMUNIFORM4IVEXTPROC) load(userptr, "glProgramUniform4ivEXT");
+ glad_glProgramUniform4uiEXT = (PFNGLPROGRAMUNIFORM4UIEXTPROC) load(userptr, "glProgramUniform4uiEXT");
+ glad_glProgramUniform4uivEXT = (PFNGLPROGRAMUNIFORM4UIVEXTPROC) load(userptr, "glProgramUniform4uivEXT");
+ glad_glProgramUniformMatrix2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) load(userptr, "glProgramUniformMatrix2fvEXT");
+ glad_glProgramUniformMatrix2x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) load(userptr, "glProgramUniformMatrix2x3fvEXT");
+ glad_glProgramUniformMatrix2x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) load(userptr, "glProgramUniformMatrix2x4fvEXT");
+ glad_glProgramUniformMatrix3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) load(userptr, "glProgramUniformMatrix3fvEXT");
+ glad_glProgramUniformMatrix3x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) load(userptr, "glProgramUniformMatrix3x2fvEXT");
+ glad_glProgramUniformMatrix3x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) load(userptr, "glProgramUniformMatrix3x4fvEXT");
+ glad_glProgramUniformMatrix4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) load(userptr, "glProgramUniformMatrix4fvEXT");
+ glad_glProgramUniformMatrix4x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) load(userptr, "glProgramUniformMatrix4x2fvEXT");
+ glad_glProgramUniformMatrix4x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) load(userptr, "glProgramUniformMatrix4x3fvEXT");
+ glad_glUseProgramStagesEXT = (PFNGLUSEPROGRAMSTAGESEXTPROC) load(userptr, "glUseProgramStagesEXT");
+ glad_glValidateProgramPipelineEXT = (PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) load(userptr, "glValidateProgramPipelineEXT");
+}
+static void glad_gl_load_GL_EXT_shader_framebuffer_fetch_non_coherent( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_shader_framebuffer_fetch_non_coherent) return;
+ glad_glFramebufferFetchBarrierEXT = (PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) load(userptr, "glFramebufferFetchBarrierEXT");
+}
+static void glad_gl_load_GL_EXT_shader_pixel_local_storage2( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_shader_pixel_local_storage2) return;
+ glad_glClearPixelLocalStorageuiEXT = (PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC) load(userptr, "glClearPixelLocalStorageuiEXT");
+ glad_glFramebufferPixelLocalStorageSizeEXT = (PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) load(userptr, "glFramebufferPixelLocalStorageSizeEXT");
+ glad_glGetFramebufferPixelLocalStorageSizeEXT = (PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) load(userptr, "glGetFramebufferPixelLocalStorageSizeEXT");
+}
+static void glad_gl_load_GL_EXT_sparse_texture( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_sparse_texture) return;
+ glad_glTexPageCommitmentEXT = (PFNGLTEXPAGECOMMITMENTEXTPROC) load(userptr, "glTexPageCommitmentEXT");
+}
+static void glad_gl_load_GL_EXT_tessellation_shader( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_tessellation_shader) return;
+ glad_glPatchParameteriEXT = (PFNGLPATCHPARAMETERIEXTPROC) load(userptr, "glPatchParameteriEXT");
+}
+static void glad_gl_load_GL_EXT_texture_border_clamp( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_texture_border_clamp) return;
+ glad_glGetSamplerParameterIivEXT = (PFNGLGETSAMPLERPARAMETERIIVEXTPROC) load(userptr, "glGetSamplerParameterIivEXT");
+ glad_glGetSamplerParameterIuivEXT = (PFNGLGETSAMPLERPARAMETERIUIVEXTPROC) load(userptr, "glGetSamplerParameterIuivEXT");
+ glad_glGetTexParameterIivEXT = (PFNGLGETTEXPARAMETERIIVEXTPROC) load(userptr, "glGetTexParameterIivEXT");
+ glad_glGetTexParameterIuivEXT = (PFNGLGETTEXPARAMETERIUIVEXTPROC) load(userptr, "glGetTexParameterIuivEXT");
+ glad_glSamplerParameterIivEXT = (PFNGLSAMPLERPARAMETERIIVEXTPROC) load(userptr, "glSamplerParameterIivEXT");
+ glad_glSamplerParameterIuivEXT = (PFNGLSAMPLERPARAMETERIUIVEXTPROC) load(userptr, "glSamplerParameterIuivEXT");
+ glad_glTexParameterIivEXT = (PFNGLTEXPARAMETERIIVEXTPROC) load(userptr, "glTexParameterIivEXT");
+ glad_glTexParameterIuivEXT = (PFNGLTEXPARAMETERIUIVEXTPROC) load(userptr, "glTexParameterIuivEXT");
+}
+static void glad_gl_load_GL_EXT_texture_buffer( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_texture_buffer) return;
+ glad_glTexBufferEXT = (PFNGLTEXBUFFEREXTPROC) load(userptr, "glTexBufferEXT");
+ glad_glTexBufferRangeEXT = (PFNGLTEXBUFFERRANGEEXTPROC) load(userptr, "glTexBufferRangeEXT");
+}
+static void glad_gl_load_GL_EXT_texture_storage( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_texture_storage) return;
+ glad_glTexStorage1DEXT = (PFNGLTEXSTORAGE1DEXTPROC) load(userptr, "glTexStorage1DEXT");
+ glad_glTexStorage2DEXT = (PFNGLTEXSTORAGE2DEXTPROC) load(userptr, "glTexStorage2DEXT");
+ glad_glTexStorage3DEXT = (PFNGLTEXSTORAGE3DEXTPROC) load(userptr, "glTexStorage3DEXT");
+ glad_glTextureStorage1DEXT = (PFNGLTEXTURESTORAGE1DEXTPROC) load(userptr, "glTextureStorage1DEXT");
+ glad_glTextureStorage2DEXT = (PFNGLTEXTURESTORAGE2DEXTPROC) load(userptr, "glTextureStorage2DEXT");
+ glad_glTextureStorage3DEXT = (PFNGLTEXTURESTORAGE3DEXTPROC) load(userptr, "glTextureStorage3DEXT");
+}
+static void glad_gl_load_GL_EXT_texture_storage_compression( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_texture_storage_compression) return;
+ glad_glTexStorageAttribs2DEXT = (PFNGLTEXSTORAGEATTRIBS2DEXTPROC) load(userptr, "glTexStorageAttribs2DEXT");
+ glad_glTexStorageAttribs3DEXT = (PFNGLTEXSTORAGEATTRIBS3DEXTPROC) load(userptr, "glTexStorageAttribs3DEXT");
+}
+static void glad_gl_load_GL_EXT_texture_view( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_texture_view) return;
+ glad_glTextureViewEXT = (PFNGLTEXTUREVIEWEXTPROC) load(userptr, "glTextureViewEXT");
+}
+static void glad_gl_load_GL_EXT_win32_keyed_mutex( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_win32_keyed_mutex) return;
+ glad_glAcquireKeyedMutexWin32EXT = (PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) load(userptr, "glAcquireKeyedMutexWin32EXT");
+ glad_glReleaseKeyedMutexWin32EXT = (PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) load(userptr, "glReleaseKeyedMutexWin32EXT");
+}
+static void glad_gl_load_GL_EXT_window_rectangles( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_window_rectangles) return;
+ glad_glWindowRectanglesEXT = (PFNGLWINDOWRECTANGLESEXTPROC) load(userptr, "glWindowRectanglesEXT");
+}
+static void glad_gl_load_GL_KHR_blend_equation_advanced( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_KHR_blend_equation_advanced) return;
+ glad_glBlendBarrierKHR = (PFNGLBLENDBARRIERKHRPROC) load(userptr, "glBlendBarrierKHR");
+}
+static void glad_gl_load_GL_KHR_debug( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_KHR_debug) return;
+ glad_glDebugMessageCallbackKHR = (PFNGLDEBUGMESSAGECALLBACKKHRPROC) load(userptr, "glDebugMessageCallbackKHR");
+ glad_glDebugMessageControlKHR = (PFNGLDEBUGMESSAGECONTROLKHRPROC) load(userptr, "glDebugMessageControlKHR");
+ glad_glDebugMessageInsertKHR = (PFNGLDEBUGMESSAGEINSERTKHRPROC) load(userptr, "glDebugMessageInsertKHR");
+ glad_glGetDebugMessageLogKHR = (PFNGLGETDEBUGMESSAGELOGKHRPROC) load(userptr, "glGetDebugMessageLogKHR");
+ glad_glGetObjectLabelKHR = (PFNGLGETOBJECTLABELKHRPROC) load(userptr, "glGetObjectLabelKHR");
+ glad_glGetObjectPtrLabelKHR = (PFNGLGETOBJECTPTRLABELKHRPROC) load(userptr, "glGetObjectPtrLabelKHR");
+ glad_glGetPointervKHR = (PFNGLGETPOINTERVKHRPROC) load(userptr, "glGetPointervKHR");
+ glad_glObjectLabelKHR = (PFNGLOBJECTLABELKHRPROC) load(userptr, "glObjectLabelKHR");
+ glad_glObjectPtrLabelKHR = (PFNGLOBJECTPTRLABELKHRPROC) load(userptr, "glObjectPtrLabelKHR");
+ glad_glPopDebugGroupKHR = (PFNGLPOPDEBUGGROUPKHRPROC) load(userptr, "glPopDebugGroupKHR");
+ glad_glPushDebugGroupKHR = (PFNGLPUSHDEBUGGROUPKHRPROC) load(userptr, "glPushDebugGroupKHR");
+}
+static void glad_gl_load_GL_KHR_parallel_shader_compile( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_KHR_parallel_shader_compile) return;
+ glad_glMaxShaderCompilerThreadsKHR = (PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) load(userptr, "glMaxShaderCompilerThreadsKHR");
+}
+static void glad_gl_load_GL_KHR_robustness( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_KHR_robustness) return;
+ glad_glGetGraphicsResetStatusKHR = (PFNGLGETGRAPHICSRESETSTATUSKHRPROC) load(userptr, "glGetGraphicsResetStatusKHR");
+ glad_glGetnUniformfvKHR = (PFNGLGETNUNIFORMFVKHRPROC) load(userptr, "glGetnUniformfvKHR");
+ glad_glGetnUniformivKHR = (PFNGLGETNUNIFORMIVKHRPROC) load(userptr, "glGetnUniformivKHR");
+ glad_glGetnUniformuivKHR = (PFNGLGETNUNIFORMUIVKHRPROC) load(userptr, "glGetnUniformuivKHR");
+ glad_glReadnPixelsKHR = (PFNGLREADNPIXELSKHRPROC) load(userptr, "glReadnPixelsKHR");
+}
+static void glad_gl_load_GL_OES_EGL_image( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_EGL_image) return;
+ glad_glEGLImageTargetRenderbufferStorageOES = (PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) load(userptr, "glEGLImageTargetRenderbufferStorageOES");
+ glad_glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) load(userptr, "glEGLImageTargetTexture2DOES");
+}
+static void glad_gl_load_GL_OES_copy_image( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_copy_image) return;
+ glad_glCopyImageSubDataOES = (PFNGLCOPYIMAGESUBDATAOESPROC) load(userptr, "glCopyImageSubDataOES");
+}
+static void glad_gl_load_GL_OES_draw_buffers_indexed( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_draw_buffers_indexed) return;
+ glad_glBlendEquationSeparateiOES = (PFNGLBLENDEQUATIONSEPARATEIOESPROC) load(userptr, "glBlendEquationSeparateiOES");
+ glad_glBlendEquationiOES = (PFNGLBLENDEQUATIONIOESPROC) load(userptr, "glBlendEquationiOES");
+ glad_glBlendFuncSeparateiOES = (PFNGLBLENDFUNCSEPARATEIOESPROC) load(userptr, "glBlendFuncSeparateiOES");
+ glad_glBlendFunciOES = (PFNGLBLENDFUNCIOESPROC) load(userptr, "glBlendFunciOES");
+ glad_glColorMaskiOES = (PFNGLCOLORMASKIOESPROC) load(userptr, "glColorMaskiOES");
+ glad_glDisableiOES = (PFNGLDISABLEIOESPROC) load(userptr, "glDisableiOES");
+ glad_glEnableiOES = (PFNGLENABLEIOESPROC) load(userptr, "glEnableiOES");
+ glad_glIsEnablediOES = (PFNGLISENABLEDIOESPROC) load(userptr, "glIsEnablediOES");
+}
+static void glad_gl_load_GL_OES_draw_elements_base_vertex( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_draw_elements_base_vertex) return;
+ glad_glDrawElementsBaseVertexOES = (PFNGLDRAWELEMENTSBASEVERTEXOESPROC) load(userptr, "glDrawElementsBaseVertexOES");
+ glad_glDrawElementsInstancedBaseVertexOES = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC) load(userptr, "glDrawElementsInstancedBaseVertexOES");
+ glad_glDrawRangeElementsBaseVertexOES = (PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC) load(userptr, "glDrawRangeElementsBaseVertexOES");
+ glad_glMultiDrawElementsBaseVertexEXT = (PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC) load(userptr, "glMultiDrawElementsBaseVertexEXT");
+}
+static void glad_gl_load_GL_OES_geometry_shader( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_geometry_shader) return;
+ glad_glFramebufferTextureOES = (PFNGLFRAMEBUFFERTEXTUREOESPROC) load(userptr, "glFramebufferTextureOES");
+}
+static void glad_gl_load_GL_OES_get_program_binary( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_get_program_binary) return;
+ glad_glGetProgramBinaryOES = (PFNGLGETPROGRAMBINARYOESPROC) load(userptr, "glGetProgramBinaryOES");
+ glad_glProgramBinaryOES = (PFNGLPROGRAMBINARYOESPROC) load(userptr, "glProgramBinaryOES");
+}
+static void glad_gl_load_GL_OES_mapbuffer( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_mapbuffer) return;
+ glad_glGetBufferPointervOES = (PFNGLGETBUFFERPOINTERVOESPROC) load(userptr, "glGetBufferPointervOES");
+ glad_glMapBufferOES = (PFNGLMAPBUFFEROESPROC) load(userptr, "glMapBufferOES");
+ glad_glUnmapBufferOES = (PFNGLUNMAPBUFFEROESPROC) load(userptr, "glUnmapBufferOES");
+}
+static void glad_gl_load_GL_OES_primitive_bounding_box( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_primitive_bounding_box) return;
+ glad_glPrimitiveBoundingBoxOES = (PFNGLPRIMITIVEBOUNDINGBOXOESPROC) load(userptr, "glPrimitiveBoundingBoxOES");
+}
+static void glad_gl_load_GL_OES_sample_shading( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_sample_shading) return;
+ glad_glMinSampleShadingOES = (PFNGLMINSAMPLESHADINGOESPROC) load(userptr, "glMinSampleShadingOES");
+}
+static void glad_gl_load_GL_OES_tessellation_shader( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_tessellation_shader) return;
+ glad_glPatchParameteriOES = (PFNGLPATCHPARAMETERIOESPROC) load(userptr, "glPatchParameteriOES");
+}
+static void glad_gl_load_GL_OES_texture_3D( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_texture_3D) return;
+ glad_glCompressedTexImage3DOES = (PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) load(userptr, "glCompressedTexImage3DOES");
+ glad_glCompressedTexSubImage3DOES = (PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) load(userptr, "glCompressedTexSubImage3DOES");
+ glad_glCopyTexSubImage3DOES = (PFNGLCOPYTEXSUBIMAGE3DOESPROC) load(userptr, "glCopyTexSubImage3DOES");
+ glad_glFramebufferTexture3DOES = (PFNGLFRAMEBUFFERTEXTURE3DOESPROC) load(userptr, "glFramebufferTexture3DOES");
+ glad_glTexImage3DOES = (PFNGLTEXIMAGE3DOESPROC) load(userptr, "glTexImage3DOES");
+ glad_glTexSubImage3DOES = (PFNGLTEXSUBIMAGE3DOESPROC) load(userptr, "glTexSubImage3DOES");
+}
+static void glad_gl_load_GL_OES_texture_border_clamp( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_texture_border_clamp) return;
+ glad_glGetSamplerParameterIivOES = (PFNGLGETSAMPLERPARAMETERIIVOESPROC) load(userptr, "glGetSamplerParameterIivOES");
+ glad_glGetSamplerParameterIuivOES = (PFNGLGETSAMPLERPARAMETERIUIVOESPROC) load(userptr, "glGetSamplerParameterIuivOES");
+ glad_glGetTexParameterIivOES = (PFNGLGETTEXPARAMETERIIVOESPROC) load(userptr, "glGetTexParameterIivOES");
+ glad_glGetTexParameterIuivOES = (PFNGLGETTEXPARAMETERIUIVOESPROC) load(userptr, "glGetTexParameterIuivOES");
+ glad_glSamplerParameterIivOES = (PFNGLSAMPLERPARAMETERIIVOESPROC) load(userptr, "glSamplerParameterIivOES");
+ glad_glSamplerParameterIuivOES = (PFNGLSAMPLERPARAMETERIUIVOESPROC) load(userptr, "glSamplerParameterIuivOES");
+ glad_glTexParameterIivOES = (PFNGLTEXPARAMETERIIVOESPROC) load(userptr, "glTexParameterIivOES");
+ glad_glTexParameterIuivOES = (PFNGLTEXPARAMETERIUIVOESPROC) load(userptr, "glTexParameterIuivOES");
+}
+static void glad_gl_load_GL_OES_texture_buffer( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_texture_buffer) return;
+ glad_glTexBufferOES = (PFNGLTEXBUFFEROESPROC) load(userptr, "glTexBufferOES");
+ glad_glTexBufferRangeOES = (PFNGLTEXBUFFERRANGEOESPROC) load(userptr, "glTexBufferRangeOES");
+}
+static void glad_gl_load_GL_OES_texture_storage_multisample_2d_array( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_texture_storage_multisample_2d_array) return;
+ glad_glTexStorage3DMultisampleOES = (PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC) load(userptr, "glTexStorage3DMultisampleOES");
+}
+static void glad_gl_load_GL_OES_texture_view( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_texture_view) return;
+ glad_glTextureViewOES = (PFNGLTEXTUREVIEWOESPROC) load(userptr, "glTextureViewOES");
+}
+static void glad_gl_load_GL_OES_vertex_array_object( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_vertex_array_object) return;
+ glad_glBindVertexArrayOES = (PFNGLBINDVERTEXARRAYOESPROC) load(userptr, "glBindVertexArrayOES");
+ glad_glDeleteVertexArraysOES = (PFNGLDELETEVERTEXARRAYSOESPROC) load(userptr, "glDeleteVertexArraysOES");
+ glad_glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC) load(userptr, "glGenVertexArraysOES");
+ glad_glIsVertexArrayOES = (PFNGLISVERTEXARRAYOESPROC) load(userptr, "glIsVertexArrayOES");
+}
+static void glad_gl_load_GL_OES_viewport_array( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_viewport_array) return;
+ glad_glDepthRangeArrayfvOES = (PFNGLDEPTHRANGEARRAYFVOESPROC) load(userptr, "glDepthRangeArrayfvOES");
+ glad_glDepthRangeIndexedfOES = (PFNGLDEPTHRANGEINDEXEDFOESPROC) load(userptr, "glDepthRangeIndexedfOES");
+ glad_glDisableiOES = (PFNGLDISABLEIOESPROC) load(userptr, "glDisableiOES");
+ glad_glEnableiOES = (PFNGLENABLEIOESPROC) load(userptr, "glEnableiOES");
+ glad_glGetFloati_vOES = (PFNGLGETFLOATI_VOESPROC) load(userptr, "glGetFloati_vOES");
+ glad_glIsEnablediOES = (PFNGLISENABLEDIOESPROC) load(userptr, "glIsEnablediOES");
+ glad_glScissorArrayvOES = (PFNGLSCISSORARRAYVOESPROC) load(userptr, "glScissorArrayvOES");
+ glad_glScissorIndexedOES = (PFNGLSCISSORINDEXEDOESPROC) load(userptr, "glScissorIndexedOES");
+ glad_glScissorIndexedvOES = (PFNGLSCISSORINDEXEDVOESPROC) load(userptr, "glScissorIndexedvOES");
+ glad_glViewportArrayvOES = (PFNGLVIEWPORTARRAYVOESPROC) load(userptr, "glViewportArrayvOES");
+ glad_glViewportIndexedfOES = (PFNGLVIEWPORTINDEXEDFOESPROC) load(userptr, "glViewportIndexedfOES");
+ glad_glViewportIndexedfvOES = (PFNGLVIEWPORTINDEXEDFVOESPROC) load(userptr, "glViewportIndexedfvOES");
+}
+
+
+
+#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
+#define GLAD_GL_IS_SOME_NEW_VERSION 1
+#else
+#define GLAD_GL_IS_SOME_NEW_VERSION 0
+#endif
+
+static int glad_gl_get_extensions( int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) {
+#if GLAD_GL_IS_SOME_NEW_VERSION
+ if(GLAD_VERSION_MAJOR(version) < 3) {
+#else
+ GLAD_UNUSED(version);
+ GLAD_UNUSED(out_num_exts_i);
+ GLAD_UNUSED(out_exts_i);
+#endif
+ if (glad_glGetString == NULL) {
+ return 0;
+ }
+ *out_exts = (const char *)glad_glGetString(GL_EXTENSIONS);
+#if GLAD_GL_IS_SOME_NEW_VERSION
+ } else {
+ unsigned int index = 0;
+ unsigned int num_exts_i = 0;
+ char **exts_i = NULL;
+ if (glad_glGetStringi == NULL || glad_glGetIntegerv == NULL) {
+ return 0;
+ }
+ glad_glGetIntegerv(GL_NUM_EXTENSIONS, (int*) &num_exts_i);
+ if (num_exts_i > 0) {
+ exts_i = (char **) malloc(num_exts_i * (sizeof *exts_i));
+ }
+ if (exts_i == NULL) {
+ return 0;
+ }
+ for(index = 0; index < num_exts_i; index++) {
+ const char *gl_str_tmp = (const char*) glad_glGetStringi(GL_EXTENSIONS, index);
+ size_t len = strlen(gl_str_tmp) + 1;
+
+ char *local_str = (char*) malloc(len * sizeof(char));
+ if(local_str != NULL) {
+ memcpy(local_str, gl_str_tmp, len * sizeof(char));
+ }
+
+ exts_i[index] = local_str;
+ }
+
+ *out_num_exts_i = num_exts_i;
+ *out_exts_i = exts_i;
+ }
+#endif
+ return 1;
+}
+static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) {
+ if (exts_i != NULL) {
+ unsigned int index;
+ for(index = 0; index < num_exts_i; index++) {
+ free((void *) (exts_i[index]));
+ }
+ free((void *)exts_i);
+ exts_i = NULL;
+ }
+}
+static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) {
+ if(GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) {
+ const char *extensions;
+ const char *loc;
+ const char *terminator;
+ extensions = exts;
+ if(extensions == NULL || ext == NULL) {
+ return 0;
+ }
+ while(1) {
+ loc = strstr(extensions, ext);
+ if(loc == NULL) {
+ return 0;
+ }
+ terminator = loc + strlen(ext);
+ if((loc == extensions || *(loc - 1) == ' ') &&
+ (*terminator == ' ' || *terminator == '\0')) {
+ return 1;
+ }
+ extensions = terminator;
+ }
+ } else {
+ unsigned int index;
+ for(index = 0; index < num_exts_i; index++) {
+ const char *e = exts_i[index];
+ if(strcmp(e, ext) == 0) {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+static GLADapiproc glad_gl_get_proc_from_userptr(void *userptr, const char* name) {
+ return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
+}
+
+static int glad_gl_find_extensions_gles2( int version) {
+ const char *exts = NULL;
+ unsigned int num_exts_i = 0;
+ char **exts_i = NULL;
+ if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0;
+
+ GLAD_GL_EXT_EGL_image_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_EGL_image_array");
+ GLAD_GL_EXT_EGL_image_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_EGL_image_storage");
+ GLAD_GL_EXT_EGL_image_storage_compression = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_EGL_image_storage_compression");
+ GLAD_GL_EXT_YUV_target = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_YUV_target");
+ GLAD_GL_EXT_base_instance = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_base_instance");
+ GLAD_GL_EXT_blend_func_extended = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_blend_func_extended");
+ GLAD_GL_EXT_blend_minmax = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_blend_minmax");
+ GLAD_GL_EXT_buffer_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_buffer_storage");
+ GLAD_GL_EXT_clear_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_clear_texture");
+ GLAD_GL_EXT_clip_control = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_clip_control");
+ GLAD_GL_EXT_clip_cull_distance = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_clip_cull_distance");
+ GLAD_GL_EXT_color_buffer_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_color_buffer_float");
+ GLAD_GL_EXT_color_buffer_half_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_color_buffer_half_float");
+ GLAD_GL_EXT_conservative_depth = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_conservative_depth");
+ GLAD_GL_EXT_copy_image = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_copy_image");
+ GLAD_GL_EXT_debug_label = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_debug_label");
+ GLAD_GL_EXT_debug_marker = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_debug_marker");
+ GLAD_GL_EXT_depth_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_depth_clamp");
+ GLAD_GL_EXT_discard_framebuffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_discard_framebuffer");
+ GLAD_GL_EXT_disjoint_timer_query = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_disjoint_timer_query");
+ GLAD_GL_EXT_draw_buffers = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_buffers");
+ GLAD_GL_EXT_draw_buffers_indexed = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_buffers_indexed");
+ GLAD_GL_EXT_draw_elements_base_vertex = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_elements_base_vertex");
+ GLAD_GL_EXT_draw_instanced = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_instanced");
+ GLAD_GL_EXT_draw_transform_feedback = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_transform_feedback");
+ GLAD_GL_EXT_external_buffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_external_buffer");
+ GLAD_GL_EXT_float_blend = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_float_blend");
+ GLAD_GL_EXT_fragment_shading_rate = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_fragment_shading_rate");
+ GLAD_GL_EXT_geometry_point_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_geometry_point_size");
+ GLAD_GL_EXT_geometry_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_geometry_shader");
+ GLAD_GL_EXT_gpu_shader5 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_gpu_shader5");
+ GLAD_GL_EXT_instanced_arrays = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_instanced_arrays");
+ GLAD_GL_EXT_map_buffer_range = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_map_buffer_range");
+ GLAD_GL_EXT_memory_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_memory_object");
+ GLAD_GL_EXT_memory_object_fd = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_memory_object_fd");
+ GLAD_GL_EXT_memory_object_win32 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_memory_object_win32");
+ GLAD_GL_EXT_multi_draw_arrays = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multi_draw_arrays");
+ GLAD_GL_EXT_multi_draw_indirect = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multi_draw_indirect");
+ GLAD_GL_EXT_multisampled_compatibility = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multisampled_compatibility");
+ GLAD_GL_EXT_multisampled_render_to_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multisampled_render_to_texture");
+ GLAD_GL_EXT_multisampled_render_to_texture2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multisampled_render_to_texture2");
+ GLAD_GL_EXT_multiview_draw_buffers = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multiview_draw_buffers");
+ GLAD_GL_EXT_multiview_tessellation_geometry_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multiview_tessellation_geometry_shader");
+ GLAD_GL_EXT_multiview_texture_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multiview_texture_multisample");
+ GLAD_GL_EXT_multiview_timer_query = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multiview_timer_query");
+ GLAD_GL_EXT_occlusion_query_boolean = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_occlusion_query_boolean");
+ GLAD_GL_EXT_polygon_offset_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_polygon_offset_clamp");
+ GLAD_GL_EXT_post_depth_coverage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_post_depth_coverage");
+ GLAD_GL_EXT_primitive_bounding_box = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_primitive_bounding_box");
+ GLAD_GL_EXT_protected_textures = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_protected_textures");
+ GLAD_GL_EXT_pvrtc_sRGB = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_pvrtc_sRGB");
+ GLAD_GL_EXT_raster_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_raster_multisample");
+ GLAD_GL_EXT_read_format_bgra = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_read_format_bgra");
+ GLAD_GL_EXT_render_snorm = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_render_snorm");
+ GLAD_GL_EXT_robustness = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_robustness");
+ GLAD_GL_EXT_sRGB = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_sRGB");
+ GLAD_GL_EXT_sRGB_write_control = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_sRGB_write_control");
+ GLAD_GL_EXT_semaphore = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_semaphore");
+ GLAD_GL_EXT_semaphore_fd = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_semaphore_fd");
+ GLAD_GL_EXT_semaphore_win32 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_semaphore_win32");
+ GLAD_GL_EXT_separate_depth_stencil = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_separate_depth_stencil");
+ GLAD_GL_EXT_separate_shader_objects = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_separate_shader_objects");
+ GLAD_GL_EXT_shader_framebuffer_fetch = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_framebuffer_fetch");
+ GLAD_GL_EXT_shader_framebuffer_fetch_non_coherent = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_framebuffer_fetch_non_coherent");
+ GLAD_GL_EXT_shader_group_vote = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_group_vote");
+ GLAD_GL_EXT_shader_implicit_conversions = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_implicit_conversions");
+ GLAD_GL_EXT_shader_integer_mix = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_integer_mix");
+ GLAD_GL_EXT_shader_io_blocks = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_io_blocks");
+ GLAD_GL_EXT_shader_non_constant_global_initializers = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_non_constant_global_initializers");
+ GLAD_GL_EXT_shader_pixel_local_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_pixel_local_storage");
+ GLAD_GL_EXT_shader_pixel_local_storage2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_pixel_local_storage2");
+ GLAD_GL_EXT_shader_samples_identical = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_samples_identical");
+ GLAD_GL_EXT_shader_texture_lod = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_texture_lod");
+ GLAD_GL_EXT_shadow_samplers = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shadow_samplers");
+ GLAD_GL_EXT_sparse_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_sparse_texture");
+ GLAD_GL_EXT_sparse_texture2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_sparse_texture2");
+ GLAD_GL_EXT_tessellation_point_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_tessellation_point_size");
+ GLAD_GL_EXT_tessellation_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_tessellation_shader");
+ GLAD_GL_EXT_texture_border_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_border_clamp");
+ GLAD_GL_EXT_texture_buffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_buffer");
+ GLAD_GL_EXT_texture_compression_astc_decode_mode = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_astc_decode_mode");
+ GLAD_GL_EXT_texture_compression_bptc = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_bptc");
+ GLAD_GL_EXT_texture_compression_dxt1 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_dxt1");
+ GLAD_GL_EXT_texture_compression_rgtc = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_rgtc");
+ GLAD_GL_EXT_texture_compression_s3tc = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_s3tc");
+ GLAD_GL_EXT_texture_compression_s3tc_srgb = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_s3tc_srgb");
+ GLAD_GL_EXT_texture_cube_map_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_cube_map_array");
+ GLAD_GL_EXT_texture_filter_anisotropic = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_filter_anisotropic");
+ GLAD_GL_EXT_texture_filter_minmax = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_filter_minmax");
+ GLAD_GL_EXT_texture_format_BGRA8888 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_format_BGRA8888");
+ GLAD_GL_EXT_texture_format_sRGB_override = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_format_sRGB_override");
+ GLAD_GL_EXT_texture_mirror_clamp_to_edge = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_mirror_clamp_to_edge");
+ GLAD_GL_EXT_texture_norm16 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_norm16");
+ GLAD_GL_EXT_texture_query_lod = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_query_lod");
+ GLAD_GL_EXT_texture_rg = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_rg");
+ GLAD_GL_EXT_texture_sRGB_R8 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_sRGB_R8");
+ GLAD_GL_EXT_texture_sRGB_RG8 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_sRGB_RG8");
+ GLAD_GL_EXT_texture_sRGB_decode = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_sRGB_decode");
+ GLAD_GL_EXT_texture_shadow_lod = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_shadow_lod");
+ GLAD_GL_EXT_texture_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_storage");
+ GLAD_GL_EXT_texture_storage_compression = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_storage_compression");
+ GLAD_GL_EXT_texture_type_2_10_10_10_REV = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_type_2_10_10_10_REV");
+ GLAD_GL_EXT_texture_view = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_view");
+ GLAD_GL_EXT_unpack_subimage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_unpack_subimage");
+ GLAD_GL_EXT_win32_keyed_mutex = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_win32_keyed_mutex");
+ GLAD_GL_EXT_window_rectangles = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_window_rectangles");
+ GLAD_GL_KHR_blend_equation_advanced = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_blend_equation_advanced");
+ GLAD_GL_KHR_blend_equation_advanced_coherent = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_blend_equation_advanced_coherent");
+ GLAD_GL_KHR_context_flush_control = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_context_flush_control");
+ GLAD_GL_KHR_debug = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_debug");
+ GLAD_GL_KHR_no_error = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_no_error");
+ GLAD_GL_KHR_parallel_shader_compile = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_parallel_shader_compile");
+ GLAD_GL_KHR_robust_buffer_access_behavior = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_robust_buffer_access_behavior");
+ GLAD_GL_KHR_robustness = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_robustness");
+ GLAD_GL_KHR_shader_subgroup = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_shader_subgroup");
+ GLAD_GL_KHR_texture_compression_astc_hdr = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_texture_compression_astc_hdr");
+ GLAD_GL_KHR_texture_compression_astc_ldr = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_texture_compression_astc_ldr");
+ GLAD_GL_KHR_texture_compression_astc_sliced_3d = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_texture_compression_astc_sliced_3d");
+ GLAD_GL_OES_EGL_image = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_EGL_image");
+ GLAD_GL_OES_EGL_image_external = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_EGL_image_external");
+ GLAD_GL_OES_EGL_image_external_essl3 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_EGL_image_external_essl3");
+ GLAD_GL_OES_compressed_ETC1_RGB8_sub_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_compressed_ETC1_RGB8_sub_texture");
+ GLAD_GL_OES_compressed_ETC1_RGB8_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_compressed_ETC1_RGB8_texture");
+ GLAD_GL_OES_compressed_paletted_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_compressed_paletted_texture");
+ GLAD_GL_OES_copy_image = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_copy_image");
+ GLAD_GL_OES_depth24 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_depth24");
+ GLAD_GL_OES_depth32 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_depth32");
+ GLAD_GL_OES_depth_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_depth_texture");
+ GLAD_GL_OES_draw_buffers_indexed = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_draw_buffers_indexed");
+ GLAD_GL_OES_draw_elements_base_vertex = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_draw_elements_base_vertex");
+ GLAD_GL_OES_element_index_uint = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_element_index_uint");
+ GLAD_GL_OES_fbo_render_mipmap = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_fbo_render_mipmap");
+ GLAD_GL_OES_fragment_precision_high = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_fragment_precision_high");
+ GLAD_GL_OES_geometry_point_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_geometry_point_size");
+ GLAD_GL_OES_geometry_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_geometry_shader");
+ GLAD_GL_OES_get_program_binary = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_get_program_binary");
+ GLAD_GL_OES_gpu_shader5 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_gpu_shader5");
+ GLAD_GL_OES_mapbuffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_mapbuffer");
+ GLAD_GL_OES_packed_depth_stencil = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_packed_depth_stencil");
+ GLAD_GL_OES_primitive_bounding_box = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_primitive_bounding_box");
+ GLAD_GL_OES_required_internalformat = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_required_internalformat");
+ GLAD_GL_OES_rgb8_rgba8 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_rgb8_rgba8");
+ GLAD_GL_OES_sample_shading = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_sample_shading");
+ GLAD_GL_OES_sample_variables = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_sample_variables");
+ GLAD_GL_OES_shader_image_atomic = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_shader_image_atomic");
+ GLAD_GL_OES_shader_io_blocks = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_shader_io_blocks");
+ GLAD_GL_OES_shader_multisample_interpolation = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_shader_multisample_interpolation");
+ GLAD_GL_OES_standard_derivatives = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_standard_derivatives");
+ GLAD_GL_OES_stencil1 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_stencil1");
+ GLAD_GL_OES_stencil4 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_stencil4");
+ GLAD_GL_OES_surfaceless_context = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_surfaceless_context");
+ GLAD_GL_OES_tessellation_point_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_tessellation_point_size");
+ GLAD_GL_OES_tessellation_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_tessellation_shader");
+ GLAD_GL_OES_texture_3D = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_3D");
+ GLAD_GL_OES_texture_border_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_border_clamp");
+ GLAD_GL_OES_texture_buffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_buffer");
+ GLAD_GL_OES_texture_compression_astc = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_compression_astc");
+ GLAD_GL_OES_texture_cube_map_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_cube_map_array");
+ GLAD_GL_OES_texture_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_float");
+ GLAD_GL_OES_texture_float_linear = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_float_linear");
+ GLAD_GL_OES_texture_half_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_half_float");
+ GLAD_GL_OES_texture_half_float_linear = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_half_float_linear");
+ GLAD_GL_OES_texture_npot = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_npot");
+ GLAD_GL_OES_texture_stencil8 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_stencil8");
+ GLAD_GL_OES_texture_storage_multisample_2d_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_storage_multisample_2d_array");
+ GLAD_GL_OES_texture_view = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_view");
+ GLAD_GL_OES_vertex_array_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_vertex_array_object");
+ GLAD_GL_OES_vertex_half_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_vertex_half_float");
+ GLAD_GL_OES_vertex_type_10_10_10_2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_vertex_type_10_10_10_2");
+ GLAD_GL_OES_viewport_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_viewport_array");
+
+ glad_gl_free_extensions(exts_i, num_exts_i);
+
+ return 1;
+}
+
+static int glad_gl_find_core_gles2(void) {
+ int i;
+ const char* version;
+ const char* prefixes[] = {
+ "OpenGL ES-CM ",
+ "OpenGL ES-CL ",
+ "OpenGL ES ",
+ "OpenGL SC ",
+ NULL
+ };
+ int major = 0;
+ int minor = 0;
+ version = (const char*) glad_glGetString(GL_VERSION);
+ if (!version) return 0;
+ for (i = 0; prefixes[i]; i++) {
+ const size_t length = strlen(prefixes[i]);
+ if (strncmp(version, prefixes[i], length) == 0) {
+ version += length;
+ break;
+ }
+ }
+
+ GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor);
+
+ GLAD_GL_ES_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;
+
+ return GLAD_MAKE_VERSION(major, minor);
+}
+
+int gladLoadGLES2UserPtr( GLADuserptrloadfunc load, void *userptr) {
+ int version;
+
+ glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
+ if(glad_glGetString == NULL) return 0;
+ if(glad_glGetString(GL_VERSION) == NULL) return 0;
+ version = glad_gl_find_core_gles2();
+
+ glad_gl_load_GL_ES_VERSION_2_0(load, userptr);
+
+ if (!glad_gl_find_extensions_gles2(version)) return 0;
+ glad_gl_load_GL_EXT_EGL_image_storage(load, userptr);
+ glad_gl_load_GL_EXT_base_instance(load, userptr);
+ glad_gl_load_GL_EXT_blend_func_extended(load, userptr);
+ glad_gl_load_GL_EXT_buffer_storage(load, userptr);
+ glad_gl_load_GL_EXT_clear_texture(load, userptr);
+ glad_gl_load_GL_EXT_clip_control(load, userptr);
+ glad_gl_load_GL_EXT_copy_image(load, userptr);
+ glad_gl_load_GL_EXT_debug_label(load, userptr);
+ glad_gl_load_GL_EXT_debug_marker(load, userptr);
+ glad_gl_load_GL_EXT_discard_framebuffer(load, userptr);
+ glad_gl_load_GL_EXT_disjoint_timer_query(load, userptr);
+ glad_gl_load_GL_EXT_draw_buffers(load, userptr);
+ glad_gl_load_GL_EXT_draw_buffers_indexed(load, userptr);
+ glad_gl_load_GL_EXT_draw_elements_base_vertex(load, userptr);
+ glad_gl_load_GL_EXT_draw_instanced(load, userptr);
+ glad_gl_load_GL_EXT_draw_transform_feedback(load, userptr);
+ glad_gl_load_GL_EXT_external_buffer(load, userptr);
+ glad_gl_load_GL_EXT_fragment_shading_rate(load, userptr);
+ glad_gl_load_GL_EXT_geometry_shader(load, userptr);
+ glad_gl_load_GL_EXT_instanced_arrays(load, userptr);
+ glad_gl_load_GL_EXT_map_buffer_range(load, userptr);
+ glad_gl_load_GL_EXT_memory_object(load, userptr);
+ glad_gl_load_GL_EXT_memory_object_fd(load, userptr);
+ glad_gl_load_GL_EXT_memory_object_win32(load, userptr);
+ glad_gl_load_GL_EXT_multi_draw_arrays(load, userptr);
+ glad_gl_load_GL_EXT_multi_draw_indirect(load, userptr);
+ glad_gl_load_GL_EXT_multisampled_render_to_texture(load, userptr);
+ glad_gl_load_GL_EXT_multiview_draw_buffers(load, userptr);
+ glad_gl_load_GL_EXT_occlusion_query_boolean(load, userptr);
+ glad_gl_load_GL_EXT_polygon_offset_clamp(load, userptr);
+ glad_gl_load_GL_EXT_primitive_bounding_box(load, userptr);
+ glad_gl_load_GL_EXT_raster_multisample(load, userptr);
+ glad_gl_load_GL_EXT_robustness(load, userptr);
+ glad_gl_load_GL_EXT_semaphore(load, userptr);
+ glad_gl_load_GL_EXT_semaphore_fd(load, userptr);
+ glad_gl_load_GL_EXT_semaphore_win32(load, userptr);
+ glad_gl_load_GL_EXT_separate_shader_objects(load, userptr);
+ glad_gl_load_GL_EXT_shader_framebuffer_fetch_non_coherent(load, userptr);
+ glad_gl_load_GL_EXT_shader_pixel_local_storage2(load, userptr);
+ glad_gl_load_GL_EXT_sparse_texture(load, userptr);
+ glad_gl_load_GL_EXT_tessellation_shader(load, userptr);
+ glad_gl_load_GL_EXT_texture_border_clamp(load, userptr);
+ glad_gl_load_GL_EXT_texture_buffer(load, userptr);
+ glad_gl_load_GL_EXT_texture_storage(load, userptr);
+ glad_gl_load_GL_EXT_texture_storage_compression(load, userptr);
+ glad_gl_load_GL_EXT_texture_view(load, userptr);
+ glad_gl_load_GL_EXT_win32_keyed_mutex(load, userptr);
+ glad_gl_load_GL_EXT_window_rectangles(load, userptr);
+ glad_gl_load_GL_KHR_blend_equation_advanced(load, userptr);
+ glad_gl_load_GL_KHR_debug(load, userptr);
+ glad_gl_load_GL_KHR_parallel_shader_compile(load, userptr);
+ glad_gl_load_GL_KHR_robustness(load, userptr);
+ glad_gl_load_GL_OES_EGL_image(load, userptr);
+ glad_gl_load_GL_OES_copy_image(load, userptr);
+ glad_gl_load_GL_OES_draw_buffers_indexed(load, userptr);
+ glad_gl_load_GL_OES_draw_elements_base_vertex(load, userptr);
+ glad_gl_load_GL_OES_geometry_shader(load, userptr);
+ glad_gl_load_GL_OES_get_program_binary(load, userptr);
+ glad_gl_load_GL_OES_mapbuffer(load, userptr);
+ glad_gl_load_GL_OES_primitive_bounding_box(load, userptr);
+ glad_gl_load_GL_OES_sample_shading(load, userptr);
+ glad_gl_load_GL_OES_tessellation_shader(load, userptr);
+ glad_gl_load_GL_OES_texture_3D(load, userptr);
+ glad_gl_load_GL_OES_texture_border_clamp(load, userptr);
+ glad_gl_load_GL_OES_texture_buffer(load, userptr);
+ glad_gl_load_GL_OES_texture_storage_multisample_2d_array(load, userptr);
+ glad_gl_load_GL_OES_texture_view(load, userptr);
+ glad_gl_load_GL_OES_vertex_array_object(load, userptr);
+ glad_gl_load_GL_OES_viewport_array(load, userptr);
+
+
+
+ return version;
+}
+
+
+int gladLoadGLES2( GLADloadfunc load) {
+ return gladLoadGLES2UserPtr( glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
+}
+
+
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GLAD_GLES2_IMPLEMENTATION */
+
diff --git a/examples/others/raylib_opengl_interop.c b/examples/others/raylib_opengl_interop.c
index 2acb62193..bcdbbbdd5 100644
--- a/examples/others/raylib_opengl_interop.c
+++ b/examples/others/raylib_opengl_interop.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2021-2022 Stephan Soller (@arkanis) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2021-2023 Stephan Soller (@arkanis) and Ramon Santamaria (@raysan5)
*
********************************************************************************************
*
@@ -26,21 +26,29 @@
#include "raylib.h"
-#include "rlgl.h" // Required for: rlDrawRenderBatchActive(), rlGetMatrixModelview(), rlGetMatrixProjection()
-#if defined(__APPLE__)
- #include // OpenGL 3 library for OSX
- #include // OpenGL 3 extensions library for OSX
-#else
- #include "glad.h" // Required for: OpenGL functionality
-#endif
-#include "raymath.h" // Required for: MatrixMultiply(), MatrixToFloat()
-
#if defined(PLATFORM_DESKTOP)
- #define GLSL_VERSION 330
+ #if defined(GRAPHICS_API_OPENGL_ES2)
+ #include "glad_gles2.h" // Required for: OpenGL functionality
+ #define glGenVertexArrays glGenVertexArraysOES
+ #define glBindVertexArray glBindVertexArrayOES
+ #define glDeleteVertexArrays glDeleteVertexArraysOES
+ #define GLSL_VERSION 100
+ #else
+ #if defined(__APPLE__)
+ #include // OpenGL 3 library for OSX
+ #include // OpenGL 3 extensions library for OSX
+ #else
+ #include "glad.h" // Required for: OpenGL functionality
+ #endif
+ #define GLSL_VERSION 330
+ #endif
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
#define GLSL_VERSION 100
#endif
+#include "rlgl.h" // Required for: rlDrawRenderBatchActive(), rlGetMatrixModelview(), rlGetMatrixProjection()
+#include "raymath.h" // Required for: MatrixMultiply(), MatrixToFloat()
+
#define MAX_PARTICLES 1000
// Particle type
@@ -97,7 +105,9 @@ int main(void)
glBindVertexArray(0);
// Allows the vertex shader to set the point size of each particle individually
+ #ifndef GRAPHICS_API_OPENGL_ES2
glEnable(GL_PROGRAM_POINT_SIZE);
+ #endif
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
diff --git a/examples/others/raymath_vector_angle.c b/examples/others/raymath_vector_angle.c
new file mode 100644
index 000000000..b193648fe
--- /dev/null
+++ b/examples/others/raymath_vector_angle.c
@@ -0,0 +1,106 @@
+/*******************************************************************************************
+*
+* raylib [shapes] example - Vector Angle
+*
+* Example originally created with raylib 1.0, last time updated with raylib 4.2
+*
+* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
+* BSD-like license that allows static linking with closed source software
+*
+* Copyright (c) 2023 Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#include "raymath.h"
+
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
+int main(void)
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [math] example - vector angle");
+
+ Vector2 v0 = { screenWidth/2, screenHeight/2 };
+ Vector2 v1 = { 100.0f, 80.0f };
+ Vector2 v2 = { 0 }; // Updated with mouse position
+
+ float angle = 0.0f; // Angle in degrees
+ int angleMode = 0; // 0-Vector2Angle(), 1-Vector2LineAngle()
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ if (IsKeyPressed(KEY_SPACE)) angleMode = !angleMode;
+
+ if (angleMode == 0)
+ {
+ // Calculate angle between two vectors, considering a common origin (v0)
+ v1 = Vector2Add(v0, (Vector2){ 100.0f, 80.0f });
+ v2 = GetMousePosition();
+ angle = Vector2Angle(Vector2Normalize(Vector2Subtract(v1, v0)), Vector2Normalize(Vector2Subtract(v2, v0)))*RAD2DEG;
+ }
+ else if (angleMode == 1)
+ {
+ // Calculate angle defined by a two vectors line, in reference to horizontal line
+ v1 = (Vector2){ screenWidth/2, screenHeight/2 };
+ v2 = GetMousePosition();
+ angle = Vector2LineAngle(v1, v2)*RAD2DEG;
+ }
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ if (angleMode == 0) DrawText("v0", v0.x, v0.y, 10, DARKGRAY);
+ DrawText("v1", v1.x, v1.y, 10, DARKGRAY);
+ DrawText("v2", v2.x, v2.y, 10, DARKGRAY);
+
+ if (angleMode == 0)
+ {
+ DrawText("MODE: Angle between V1 and V2", 10, 10, 20, BLACK);
+
+ DrawLineEx(v0, v1, 2.0f, BLACK);
+ DrawLineEx(v0, v2, 2.0f, RED);
+
+ float startangle = 90 - Vector2LineAngle(v0, v1)*RAD2DEG;
+ DrawCircleSector(v0, 40.0f, startangle, startangle + angle - 360.0f*(angle > 180.0f), 32, Fade(GREEN, 0.6f));
+ }
+ else if (angleMode == 1)
+ {
+ DrawText("MODE: Angle formed by line V1 to V2", 10, 10, 20, BLACK);
+
+ DrawLine(0, screenHeight/2, screenWidth, screenHeight/2, LIGHTGRAY);
+ DrawLineEx(v1, v2, 2.0f, RED);
+
+ DrawCircleSector(v1, 40.0f, 90.0f, 180 - angle - 90, 32, Fade(GREEN, 0.6f));
+ }
+
+ DrawText("Press SPACE to change MODE", 460, 10, 20, DARKGRAY);
+ DrawText(TextFormat("ANGLE: %2.2f", angle), 10, 40, 20, LIME);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}
diff --git a/examples/others/raymath_vector_angle.png b/examples/others/raymath_vector_angle.png
new file mode 100644
index 000000000..29995e002
Binary files /dev/null and b/examples/others/raymath_vector_angle.png differ
diff --git a/examples/others/reasings.h b/examples/others/reasings.h
index 8b14ba6aa..657ea242e 100644
--- a/examples/others/reasings.h
+++ b/examples/others/reasings.h
@@ -60,7 +60,7 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ---------------------------------------------------------------------------------
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
diff --git a/examples/others/rlgl_compute_shader.c b/examples/others/rlgl_compute_shader.c
index b74ed932f..544e0a534 100644
--- a/examples/others/rlgl_compute_shader.c
+++ b/examples/others/rlgl_compute_shader.c
@@ -12,7 +12,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2021-2022 Teddy Astie (@tsnake41)
+* Copyright (c) 2021-2023 Teddy Astie (@tsnake41)
*
********************************************************************************************/
@@ -74,10 +74,10 @@ int main(void)
unsigned int ssboA = rlLoadShaderBuffer(GOL_WIDTH*GOL_WIDTH*sizeof(unsigned int), NULL, RL_DYNAMIC_COPY);
unsigned int ssboB = rlLoadShaderBuffer(GOL_WIDTH*GOL_WIDTH*sizeof(unsigned int), NULL, RL_DYNAMIC_COPY);
unsigned int ssboTransfert = rlLoadShaderBuffer(sizeof(GolUpdateSSBO), NULL, RL_DYNAMIC_COPY);
-
+
GolUpdateSSBO transfertBuffer = { 0 };
- // Create a white texture of the size of the window to update
+ // Create a white texture of the size of the window to update
// each pixel of the window using the fragment shader: golRenderShader
Image whiteImage = GenImageColor(GOL_WIDTH, GOL_WIDTH, WHITE);
Texture whiteTex = LoadTextureFromImage(whiteImage);
@@ -105,7 +105,7 @@ int main(void)
{
// Send SSBO buffer to GPU
rlUpdateShaderBuffer(ssboTransfert, &transfertBuffer, sizeof(GolUpdateSSBO), 0);
-
+
// Process SSBO commands on GPU
rlEnableShader(golTransfertProgram);
rlBindShaderBuffer(ssboA, 1);
@@ -143,7 +143,7 @@ int main(void)
BeginShaderMode(golRenderShader);
DrawTexture(whiteTex, 0, 0, WHITE);
EndShaderMode();
-
+
DrawRectangleLines(GetMouseX() - brushSize/2, GetMouseY() - brushSize/2, brushSize, brushSize, RED);
DrawText("Use Mouse wheel to increase/decrease brush size", 10, 10, 20, WHITE);
diff --git a/examples/others/rlgl_standalone.c b/examples/others/rlgl_standalone.c
index 308699992..43cc3288e 100644
--- a/examples/others/rlgl_standalone.c
+++ b/examples/others/rlgl_standalone.c
@@ -29,7 +29,7 @@
* This example is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software:
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
diff --git a/examples/raylib_compile_execute.bat b/examples/raylib_compile_execute.bat
index 59a25fc51..0dc43e187 100644
--- a/examples/raylib_compile_execute.bat
+++ b/examples/raylib_compile_execute.bat
@@ -4,10 +4,10 @@
:: .
:: > Setup required Environment
:: -------------------------------------
-set RAYLIB_INCLUDE_DIR=C:\raylib\src
-set RAYLIB_LIB_DIR=C:\raylib\src
-set RAYLIB_RES_FILE=C:\raylib\src\raylib.rc.data
-set COMPILER_DIR=C:\raylib\mingw\bin
+set RAYLIB_INCLUDE_DIR=C:\raylib\raylib\src
+set RAYLIB_LIB_DIR=C:\raylib\raylib\src
+set RAYLIB_RES_FILE=C:\raylib\raylib\src\raylib.rc.data
+set COMPILER_DIR=C:\raylib\w64devkit\bin
set PATH=%PATH%;%COMPILER_DIR%
:: Get full filename path for input file %1
set FILENAME=%~f1
diff --git a/examples/raylib_makefile_example.bat b/examples/raylib_makefile_example.bat
index 83fa06e10..cc2fdc225 100644
--- a/examples/raylib_makefile_example.bat
+++ b/examples/raylib_makefile_example.bat
@@ -4,10 +4,10 @@
:: .
:: > Setup required Environment
:: -------------------------------------
-set RAYLIB_INCLUDE_DIR=C:\raylib\src
-set RAYLIB_LIB_DIR=C:\raylib\src
-set RAYLIB_RES_FILE=C:\raylib\src\raylib.rc.data
-set COMPILER_DIR=C:\raylib\mingw\bin
+set RAYLIB_INCLUDE_DIR=C:\raylib\raylib\src
+set RAYLIB_LIB_DIR=C:\raylib\raylib\src
+set RAYLIB_RES_FILE=C:\raylib\raylib\src\raylib.rc.data
+set COMPILER_DIR=C:\raylib\w64devkit\bin
set PATH=%PATH%;%COMPILER_DIR%
set FILENAME=%1
set FILENAME_FULL_PATH=%~f1
@@ -24,4 +24,4 @@ mingw32-make %FILENAME% -B PLATFORM=PLATFORM_DESKTOP
:: .
:: > Executing program
:: -------------------------
-cmd /c if exist %FILENAME_FULL_PATH%.exe %FILENAME_FULL_PATH%.exe
\ No newline at end of file
+cmd /c if exist %FILENAME_FULL_PATH%.exe %FILENAME_FULL_PATH%.exe
diff --git a/examples/shaders/resources/LICENSE.md b/examples/shaders/resources/LICENSE.md
index 96458eca5..7210e34b2 100644
--- a/examples/shaders/resources/LICENSE.md
+++ b/examples/shaders/resources/LICENSE.md
@@ -9,3 +9,5 @@
| raysan.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
| space.png | ❔ | ❔ | - |
| texel_checker.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [UV Checker Map Maker](http://uvchecker.byvalle.com/) |
+| cubicmap.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
+| spark_flame.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [EffectTextureMaker](https://mebiusbox.github.io/contents/EffectTextureMaker/) |
\ No newline at end of file
diff --git a/examples/shaders/resources/cubicmap_atlas.png b/examples/shaders/resources/cubicmap_atlas.png
new file mode 100644
index 000000000..9fc404a70
Binary files /dev/null and b/examples/shaders/resources/cubicmap_atlas.png differ
diff --git a/examples/shaders/resources/shaders/glsl100/hybrid_raster.fs b/examples/shaders/resources/shaders/glsl100/hybrid_raster.fs
new file mode 100644
index 000000000..28188a454
--- /dev/null
+++ b/examples/shaders/resources/shaders/glsl100/hybrid_raster.fs
@@ -0,0 +1,16 @@
+#version 100
+#extension GL_EXT_frag_depth : enable // Extension required for writing depth
+precision mediump float; // Precision required for OpenGL ES2 (WebGL)
+
+varying vec2 fragTexCoord;
+varying vec4 fragColor;
+
+uniform sampler2D texture0;
+uniform vec4 colDiffuse;
+
+void main()
+{
+ vec4 texelColor = texture2D(texture0, fragTexCoord);
+ gl_FragColor = texelColor*colDiffuse*fragColor;
+ gl_FragDepthEXT = gl_FragCoord.z;
+}
\ No newline at end of file
diff --git a/examples/shaders/resources/shaders/glsl100/hybrid_raymarch.fs b/examples/shaders/resources/shaders/glsl100/hybrid_raymarch.fs
new file mode 100644
index 000000000..6241186de
--- /dev/null
+++ b/examples/shaders/resources/shaders/glsl100/hybrid_raymarch.fs
@@ -0,0 +1,288 @@
+#version 100
+#extension GL_EXT_frag_depth : enable //Extension required for writing depth
+#extension GL_OES_standard_derivatives : enable //Extension used for fwidth()
+precision mediump float; // Precision required for OpenGL ES2 (WebGL)
+
+
+// Input vertex attributes (from vertex shader)
+varying vec2 fragTexCoord;
+varying vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 colDiffuse;
+
+// Custom Input Uniform
+uniform vec3 camPos;
+uniform vec3 camDir;
+uniform vec2 screenCenter;
+
+#define ZERO 0
+
+// https://learnopengl.com/Advanced-OpenGL/Depth-testing
+float CalcDepth(in vec3 rd, in float Idist){
+ float local_z = dot(normalize(camDir),rd)*Idist;
+ return (1.0/(local_z) - 1.0/0.01)/(1.0/1000.0 -1.0/0.01);
+}
+
+// https://iquilezles.org/articles/distfunctions/
+float sdHorseshoe( in vec3 p, in vec2 c, in float r, in float le, vec2 w )
+{
+ p.x = abs(p.x);
+ float l = length(p.xy);
+ p.xy = mat2(-c.x, c.y,
+ c.y, c.x)*p.xy;
+ p.xy = vec2((p.y>0.0 || p.x>0.0)?p.x:l*sign(-c.x),
+ (p.x>0.0)?p.y:l );
+ p.xy = vec2(p.x,abs(p.y-r))-vec2(le,0.0);
+
+ vec2 q = vec2(length(max(p.xy,0.0)) + min(0.0,max(p.x,p.y)),p.z);
+ vec2 d = abs(q) - w;
+ return min(max(d.x,d.y),0.0) + length(max(d,0.0));
+}
+
+// r = sphere's radius
+// h = cutting's plane's position
+// t = thickness
+float sdSixWayCutHollowSphere( vec3 p, float r, float h, float t )
+{
+ // Six way symetry Transformation
+ vec3 ap = abs(p);
+ if(ap.x < max(ap.y, ap.z)){
+ if(ap.y < ap.z) ap.xz = ap.zx;
+ else ap.xy = ap.yx;
+ }
+
+ vec2 q = vec2( length(ap.yz), ap.x );
+
+ float w = sqrt(r*r-h*h);
+
+ return ((h*q.x0.0 )
+ {
+ tmax = min( tmax, tp1 );
+ res = vec2( tp1, 1.0 );
+ }
+
+ float t = tmin;
+ for( int i=0; i<70 ; i++ )
+ {
+ if(t>tmax) break;
+ vec2 h = map( ro+rd*t );
+ if( abs(h.x)<(0.0001*t) )
+ {
+ res = vec2(t,h.y);
+ break;
+ }
+ t += h.x;
+ }
+
+ return res;
+}
+
+
+// https://iquilezles.org/articles/rmshadows
+float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax )
+{
+ // bounding volume
+ float tp = (0.8-ro.y)/rd.y; if( tp>0.0 ) tmax = min( tmax, tp );
+
+ float res = 1.0;
+ float t = mint;
+ for( int i=ZERO; i<24; i++ )
+ {
+ float h = map( ro + rd*t ).x;
+ float s = clamp(8.0*h/t,0.0,1.0);
+ res = min( res, s );
+ t += clamp( h, 0.01, 0.2 );
+ if( res<0.004 || t>tmax ) break;
+ }
+ res = clamp( res, 0.0, 1.0 );
+ return res*res*(3.0-2.0*res);
+}
+
+
+// https://iquilezles.org/articles/normalsSDF
+vec3 calcNormal( in vec3 pos )
+{
+ vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
+ return normalize( e.xyy*map( pos + e.xyy ).x +
+ e.yyx*map( pos + e.yyx ).x +
+ e.yxy*map( pos + e.yxy ).x +
+ e.xxx*map( pos + e.xxx ).x );
+}
+
+// https://iquilezles.org/articles/nvscene2008/rwwtt.pdf
+float calcAO( in vec3 pos, in vec3 nor )
+{
+ float occ = 0.0;
+ float sca = 1.0;
+ for( int i=ZERO; i<5; i++ )
+ {
+ float h = 0.01 + 0.12*float(i)/4.0;
+ float d = map( pos + h*nor ).x;
+ occ += (h-d)*sca;
+ sca *= 0.95;
+ if( occ>0.35 ) break;
+ }
+ return clamp( 1.0 - 3.0*occ, 0.0, 1.0 ) * (0.5+0.5*nor.y);
+}
+
+// https://iquilezles.org/articles/checkerfiltering
+float checkersGradBox( in vec2 p )
+{
+ // filter kernel
+ vec2 w = fwidth(p) + 0.001;
+ // analytical integral (box filter)
+ vec2 i = 2.0*(abs(fract((p-0.5*w)*0.5)-0.5)-abs(fract((p+0.5*w)*0.5)-0.5))/w;
+ // xor pattern
+ return 0.5 - 0.5*i.x*i.y;
+}
+
+// https://www.shadertoy.com/view/tdS3DG
+vec4 render( in vec3 ro, in vec3 rd)
+{
+ // background
+ vec3 col = vec3(0.7, 0.7, 0.9) - max(rd.y,0.0)*0.3;
+
+ // raycast scene
+ vec2 res = raycast(ro,rd);
+ float t = res.x;
+ float m = res.y;
+ if( m>-0.5 )
+ {
+ vec3 pos = ro + t*rd;
+ vec3 nor = (m<1.5) ? vec3(0.0,1.0,0.0) : calcNormal( pos );
+ vec3 ref = reflect( rd, nor );
+
+ // material
+ col = 0.2 + 0.2*sin( m*2.0 + vec3(0.0,1.0,2.0) );
+ float ks = 1.0;
+
+ if( m<1.5 )
+ {
+ float f = checkersGradBox( 3.0*pos.xz);
+ col = 0.15 + f*vec3(0.05);
+ ks = 0.4;
+ }
+
+ // lighting
+ float occ = calcAO( pos, nor );
+
+ vec3 lin = vec3(0.0);
+
+ // sun
+ {
+ vec3 lig = normalize( vec3(-0.5, 0.4, -0.6) );
+ vec3 hal = normalize( lig-rd );
+ float dif = clamp( dot( nor, lig ), 0.0, 1.0 );
+ //if( dif>0.0001 )
+ dif *= calcSoftshadow( pos, lig, 0.02, 2.5 );
+ float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0);
+ spe *= dif;
+ spe *= 0.04+0.96*pow(clamp(1.0-dot(hal,lig),0.0,1.0),5.0);
+ //spe *= 0.04+0.96*pow(clamp(1.0-sqrt(0.5*(1.0-dot(rd,lig))),0.0,1.0),5.0);
+ lin += col*2.20*dif*vec3(1.30,1.00,0.70);
+ lin += 5.00*spe*vec3(1.30,1.00,0.70)*ks;
+ }
+ // sky
+ {
+ float dif = sqrt(clamp( 0.5+0.5*nor.y, 0.0, 1.0 ));
+ dif *= occ;
+ float spe = smoothstep( -0.2, 0.2, ref.y );
+ spe *= dif;
+ spe *= 0.04+0.96*pow(clamp(1.0+dot(nor,rd),0.0,1.0), 5.0 );
+ //if( spe>0.001 )
+ spe *= calcSoftshadow( pos, ref, 0.02, 2.5 );
+ lin += col*0.60*dif*vec3(0.40,0.60,1.15);
+ lin += 2.00*spe*vec3(0.40,0.60,1.30)*ks;
+ }
+ // back
+ {
+ float dif = clamp( dot( nor, normalize(vec3(0.5,0.0,0.6))), 0.0, 1.0 )*clamp( 1.0-pos.y,0.0,1.0);
+ dif *= occ;
+ lin += col*0.55*dif*vec3(0.25,0.25,0.25);
+ }
+ // sss
+ {
+ float dif = pow(clamp(1.0+dot(nor,rd),0.0,1.0),2.0);
+ dif *= occ;
+ lin += col*0.25*dif*vec3(1.00,1.00,1.00);
+ }
+
+ col = lin;
+
+ col = mix( col, vec3(0.7,0.7,0.9), 1.0-exp( -0.0001*t*t*t ) );
+ }
+
+ return vec4(vec3( clamp(col,0.0,1.0) ),t);
+}
+
+vec3 CalcRayDir(vec2 nCoord){
+ vec3 horizontal = normalize(cross(camDir,vec3(.0 , 1.0, .0)));
+ vec3 vertical = normalize(cross(horizontal,camDir));
+ return normalize(camDir + horizontal*nCoord.x + vertical*nCoord.y);
+}
+
+mat3 setCamera()
+{
+ vec3 cw = normalize(camDir);
+ vec3 cp = vec3(0.0, 1.0 ,0.0);
+ vec3 cu = normalize( cross(cw,cp) );
+ vec3 cv = ( cross(cu,cw) );
+ return mat3( cu, cv, cw );
+}
+
+void main()
+{
+ vec2 nCoord = (gl_FragCoord.xy - screenCenter.xy)/screenCenter.y;
+ mat3 ca = setCamera();
+
+ // focal length
+ float fl = length(camDir);
+ vec3 rd = ca * normalize( vec3(nCoord,fl) );
+ vec3 color = vec3(nCoord/2.0 + 0.5, 0.0);
+ float depth = gl_FragCoord.z;
+ {
+ vec4 res = render( camPos - vec3(0.0, 0.0, 0.0) , rd );
+ color = res.xyz;
+ depth = CalcDepth(rd,res.w);
+ }
+ gl_FragColor = vec4(color , 1.0);
+ gl_FragDepthEXT = depth;
+}
\ No newline at end of file
diff --git a/examples/shaders/resources/shaders/glsl100/lighting_instanced.vs b/examples/shaders/resources/shaders/glsl100/lighting_instancing.vs
similarity index 100%
rename from examples/shaders/resources/shaders/glsl100/lighting_instanced.vs
rename to examples/shaders/resources/shaders/glsl100/lighting_instancing.vs
diff --git a/examples/shaders/resources/shaders/glsl100/wave.fs b/examples/shaders/resources/shaders/glsl100/wave.fs
index 50c4e02f3..cd4ba9de4 100644
--- a/examples/shaders/resources/shaders/glsl100/wave.fs
+++ b/examples/shaders/resources/shaders/glsl100/wave.fs
@@ -10,7 +10,7 @@ varying vec4 fragColor;
uniform sampler2D texture0;
uniform vec4 colDiffuse;
-uniform float secondes;
+uniform float seconds;
uniform vec2 size;
@@ -29,8 +29,8 @@ void main() {
float boxTop = 0.0;
vec2 p = fragTexCoord;
- p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth;
- p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight;
+ p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (seconds * speedX)) * ampX * pixelWidth;
+ p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (seconds * speedY)) * ampY * pixelHeight;
gl_FragColor = texture2D(texture0, p)*colDiffuse*fragColor;
}
diff --git a/examples/shaders/resources/shaders/glsl100/write_depth.fs b/examples/shaders/resources/shaders/glsl100/write_depth.fs
new file mode 100644
index 000000000..341c6115f
--- /dev/null
+++ b/examples/shaders/resources/shaders/glsl100/write_depth.fs
@@ -0,0 +1,17 @@
+#version 100
+#extension GL_EXT_frag_depth : enable
+precision mediump float; // Precision required for OpenGL ES2 (WebGL)
+
+varying vec2 fragTexCoord;
+varying vec4 fragColor;
+
+uniform sampler2D texture0;
+uniform vec4 colDiffuse;
+
+void main()
+{
+ vec4 texelColor = texture2D(texture0, fragTexCoord);
+
+ gl_FragColor = texelColor*colDiffuse*fragColor;
+ gl_FragDepthEXT = 1.0 - gl_FragCoord.z;
+}
\ No newline at end of file
diff --git a/examples/shaders/resources/shaders/glsl330/hybrid_raster.fs b/examples/shaders/resources/shaders/glsl330/hybrid_raster.fs
new file mode 100644
index 000000000..85ef492c0
--- /dev/null
+++ b/examples/shaders/resources/shaders/glsl330/hybrid_raster.fs
@@ -0,0 +1,14 @@
+#version 330
+
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+uniform sampler2D texture0;
+uniform vec4 colDiffuse;
+
+void main()
+{
+ vec4 texelColor = texture2D(texture0, fragTexCoord);
+ gl_FragColor = texelColor*colDiffuse*fragColor;
+ gl_FragDepth = gl_FragCoord.z;
+}
\ No newline at end of file
diff --git a/examples/shaders/resources/shaders/glsl330/hybrid_raymarch.fs b/examples/shaders/resources/shaders/glsl330/hybrid_raymarch.fs
new file mode 100644
index 000000000..5b66dd71c
--- /dev/null
+++ b/examples/shaders/resources/shaders/glsl330/hybrid_raymarch.fs
@@ -0,0 +1,284 @@
+# version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 colDiffuse;
+
+// Custom Input Uniform
+uniform vec3 camPos;
+uniform vec3 camDir;
+uniform vec2 screenCenter;
+
+#define ZERO 0
+
+// https://learnopengl.com/Advanced-OpenGL/Depth-testing
+float CalcDepth(in vec3 rd, in float Idist){
+ float local_z = dot(normalize(camDir),rd)*Idist;
+ return (1.0/(local_z) - 1.0/0.01)/(1.0/1000.0 -1.0/0.01);
+}
+
+// https://iquilezles.org/articles/distfunctions/
+float sdHorseshoe( in vec3 p, in vec2 c, in float r, in float le, vec2 w )
+{
+ p.x = abs(p.x);
+ float l = length(p.xy);
+ p.xy = mat2(-c.x, c.y,
+ c.y, c.x)*p.xy;
+ p.xy = vec2((p.y>0.0 || p.x>0.0)?p.x:l*sign(-c.x),
+ (p.x>0.0)?p.y:l );
+ p.xy = vec2(p.x,abs(p.y-r))-vec2(le,0.0);
+
+ vec2 q = vec2(length(max(p.xy,0.0)) + min(0.0,max(p.x,p.y)),p.z);
+ vec2 d = abs(q) - w;
+ return min(max(d.x,d.y),0.0) + length(max(d,0.0));
+}
+
+// r = sphere's radius
+// h = cutting's plane's position
+// t = thickness
+float sdSixWayCutHollowSphere( vec3 p, float r, float h, float t )
+{
+ // Six way symetry Transformation
+ vec3 ap = abs(p);
+ if(ap.x < max(ap.y, ap.z)){
+ if(ap.y < ap.z) ap.xz = ap.zx;
+ else ap.xy = ap.yx;
+ }
+
+ vec2 q = vec2( length(ap.yz), ap.x );
+
+ float w = sqrt(r*r-h*h);
+
+ return ((h*q.x0.0 )
+ {
+ tmax = min( tmax, tp1 );
+ res = vec2( tp1, 1.0 );
+ }
+
+ float t = tmin;
+ for( int i=0; i<70 ; i++ )
+ {
+ if(t>tmax) break;
+ vec2 h = map( ro+rd*t );
+ if( abs(h.x)<(0.0001*t) )
+ {
+ res = vec2(t,h.y);
+ break;
+ }
+ t += h.x;
+ }
+
+ return res;
+}
+
+
+// https://iquilezles.org/articles/rmshadows
+float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax )
+{
+ // bounding volume
+ float tp = (0.8-ro.y)/rd.y; if( tp>0.0 ) tmax = min( tmax, tp );
+
+ float res = 1.0;
+ float t = mint;
+ for( int i=ZERO; i<24; i++ )
+ {
+ float h = map( ro + rd*t ).x;
+ float s = clamp(8.0*h/t,0.0,1.0);
+ res = min( res, s );
+ t += clamp( h, 0.01, 0.2 );
+ if( res<0.004 || t>tmax ) break;
+ }
+ res = clamp( res, 0.0, 1.0 );
+ return res*res*(3.0-2.0*res);
+}
+
+
+// https://iquilezles.org/articles/normalsSDF
+vec3 calcNormal( in vec3 pos )
+{
+ vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
+ return normalize( e.xyy*map( pos + e.xyy ).x +
+ e.yyx*map( pos + e.yyx ).x +
+ e.yxy*map( pos + e.yxy ).x +
+ e.xxx*map( pos + e.xxx ).x );
+}
+
+// https://iquilezles.org/articles/nvscene2008/rwwtt.pdf
+float calcAO( in vec3 pos, in vec3 nor )
+{
+ float occ = 0.0;
+ float sca = 1.0;
+ for( int i=ZERO; i<5; i++ )
+ {
+ float h = 0.01 + 0.12*float(i)/4.0;
+ float d = map( pos + h*nor ).x;
+ occ += (h-d)*sca;
+ sca *= 0.95;
+ if( occ>0.35 ) break;
+ }
+ return clamp( 1.0 - 3.0*occ, 0.0, 1.0 ) * (0.5+0.5*nor.y);
+}
+
+// https://iquilezles.org/articles/checkerfiltering
+float checkersGradBox( in vec2 p )
+{
+ // filter kernel
+ vec2 w = fwidth(p) + 0.001;
+ // analytical integral (box filter)
+ vec2 i = 2.0*(abs(fract((p-0.5*w)*0.5)-0.5)-abs(fract((p+0.5*w)*0.5)-0.5))/w;
+ // xor pattern
+ return 0.5 - 0.5*i.x*i.y;
+}
+
+// https://www.shadertoy.com/view/tdS3DG
+vec4 render( in vec3 ro, in vec3 rd)
+{
+ // background
+ vec3 col = vec3(0.7, 0.7, 0.9) - max(rd.y,0.0)*0.3;
+
+ // raycast scene
+ vec2 res = raycast(ro,rd);
+ float t = res.x;
+ float m = res.y;
+ if( m>-0.5 )
+ {
+ vec3 pos = ro + t*rd;
+ vec3 nor = (m<1.5) ? vec3(0.0,1.0,0.0) : calcNormal( pos );
+ vec3 ref = reflect( rd, nor );
+
+ // material
+ col = 0.2 + 0.2*sin( m*2.0 + vec3(0.0,1.0,2.0) );
+ float ks = 1.0;
+
+ if( m<1.5 )
+ {
+ float f = checkersGradBox( 3.0*pos.xz);
+ col = 0.15 + f*vec3(0.05);
+ ks = 0.4;
+ }
+
+ // lighting
+ float occ = calcAO( pos, nor );
+
+ vec3 lin = vec3(0.0);
+
+ // sun
+ {
+ vec3 lig = normalize( vec3(-0.5, 0.4, -0.6) );
+ vec3 hal = normalize( lig-rd );
+ float dif = clamp( dot( nor, lig ), 0.0, 1.0 );
+ //if( dif>0.0001 )
+ dif *= calcSoftshadow( pos, lig, 0.02, 2.5 );
+ float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0);
+ spe *= dif;
+ spe *= 0.04+0.96*pow(clamp(1.0-dot(hal,lig),0.0,1.0),5.0);
+ //spe *= 0.04+0.96*pow(clamp(1.0-sqrt(0.5*(1.0-dot(rd,lig))),0.0,1.0),5.0);
+ lin += col*2.20*dif*vec3(1.30,1.00,0.70);
+ lin += 5.00*spe*vec3(1.30,1.00,0.70)*ks;
+ }
+ // sky
+ {
+ float dif = sqrt(clamp( 0.5+0.5*nor.y, 0.0, 1.0 ));
+ dif *= occ;
+ float spe = smoothstep( -0.2, 0.2, ref.y );
+ spe *= dif;
+ spe *= 0.04+0.96*pow(clamp(1.0+dot(nor,rd),0.0,1.0), 5.0 );
+ //if( spe>0.001 )
+ spe *= calcSoftshadow( pos, ref, 0.02, 2.5 );
+ lin += col*0.60*dif*vec3(0.40,0.60,1.15);
+ lin += 2.00*spe*vec3(0.40,0.60,1.30)*ks;
+ }
+ // back
+ {
+ float dif = clamp( dot( nor, normalize(vec3(0.5,0.0,0.6))), 0.0, 1.0 )*clamp( 1.0-pos.y,0.0,1.0);
+ dif *= occ;
+ lin += col*0.55*dif*vec3(0.25,0.25,0.25);
+ }
+ // sss
+ {
+ float dif = pow(clamp(1.0+dot(nor,rd),0.0,1.0),2.0);
+ dif *= occ;
+ lin += col*0.25*dif*vec3(1.00,1.00,1.00);
+ }
+
+ col = lin;
+
+ col = mix( col, vec3(0.7,0.7,0.9), 1.0-exp( -0.0001*t*t*t ) );
+ }
+
+ return vec4(vec3( clamp(col,0.0,1.0) ),t);
+}
+
+vec3 CalcRayDir(vec2 nCoord){
+ vec3 horizontal = normalize(cross(camDir,vec3(.0 , 1.0, .0)));
+ vec3 vertical = normalize(cross(horizontal,camDir));
+ return normalize(camDir + horizontal*nCoord.x + vertical*nCoord.y);
+}
+
+mat3 setCamera()
+{
+ vec3 cw = normalize(camDir);
+ vec3 cp = vec3(0.0, 1.0 ,0.0);
+ vec3 cu = normalize( cross(cw,cp) );
+ vec3 cv = ( cross(cu,cw) );
+ return mat3( cu, cv, cw );
+}
+
+void main()
+{
+ vec2 nCoord = (gl_FragCoord.xy - screenCenter.xy)/screenCenter.y;
+ mat3 ca = setCamera();
+
+ // focal length
+ float fl = length(camDir);
+ vec3 rd = ca * normalize( vec3(nCoord,fl) );
+ vec3 color = vec3(nCoord/2.0 + 0.5, 0.0);
+ float depth = gl_FragCoord.z;
+ {
+ vec4 res = render( camPos - vec3(0.0, 0.0, 0.0) , rd );
+ color = res.xyz;
+ depth = CalcDepth(rd,res.w);
+ }
+ gl_FragColor = vec4(color , 1.0);
+ gl_FragDepth = depth;
+}
\ No newline at end of file
diff --git a/examples/shaders/resources/shaders/glsl330/lightmap.fs b/examples/shaders/resources/shaders/glsl330/lightmap.fs
new file mode 100644
index 000000000..827473d25
--- /dev/null
+++ b/examples/shaders/resources/shaders/glsl330/lightmap.fs
@@ -0,0 +1,23 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec2 fragTexCoord2;
+in vec3 fragPosition;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform sampler2D texture1;
+
+// Output fragment color
+out vec4 finalColor;
+
+void main()
+{
+ // Texel color fetching from texture sampler
+ vec4 texelColor = texture(texture0, fragTexCoord);
+ vec4 texelColor2 = texture(texture1, fragTexCoord2);
+
+ finalColor = texelColor * texelColor2;
+}
diff --git a/examples/shaders/resources/shaders/glsl330/lightmap.vs b/examples/shaders/resources/shaders/glsl330/lightmap.vs
new file mode 100644
index 000000000..d92c2f097
--- /dev/null
+++ b/examples/shaders/resources/shaders/glsl330/lightmap.vs
@@ -0,0 +1,29 @@
+#version 330
+
+// Input vertex attributes
+in vec3 vertexPosition;
+in vec2 vertexTexCoord;
+in vec2 vertexTexCoord2;
+in vec4 vertexColor;
+
+// Input uniform values
+uniform mat4 mvp;
+uniform mat4 matModel;
+
+// Output vertex attributes (to fragment shader)
+out vec3 fragPosition;
+out vec2 fragTexCoord;
+out vec2 fragTexCoord2;
+out vec4 fragColor;
+
+void main()
+{
+ // Send vertex attributes to fragment shader
+ fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
+ fragTexCoord = vertexTexCoord;
+ fragTexCoord2 = vertexTexCoord2;
+ fragColor = vertexColor;
+
+ // Calculate final vertex position
+ gl_Position = mvp*vec4(vertexPosition, 1.0);
+}
diff --git a/examples/shaders/resources/shaders/glsl330/wave.fs b/examples/shaders/resources/shaders/glsl330/wave.fs
index 43efee234..1f22bee09 100644
--- a/examples/shaders/resources/shaders/glsl330/wave.fs
+++ b/examples/shaders/resources/shaders/glsl330/wave.fs
@@ -11,7 +11,7 @@ uniform vec4 colDiffuse;
// Output fragment color
out vec4 finalColor;
-uniform float secondes;
+uniform float seconds;
uniform vec2 size;
@@ -30,8 +30,8 @@ void main() {
float boxTop = 0.0;
vec2 p = fragTexCoord;
- p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth;
- p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight;
+ p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (seconds * speedX)) * ampX * pixelWidth;
+ p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (seconds * speedY)) * ampY * pixelHeight;
finalColor = texture(texture0, p)*colDiffuse*fragColor;
}
diff --git a/examples/shaders/resources/shaders/glsl330/write_depth.fs b/examples/shaders/resources/shaders/glsl330/write_depth.fs
new file mode 100644
index 000000000..f0e07beec
--- /dev/null
+++ b/examples/shaders/resources/shaders/glsl330/write_depth.fs
@@ -0,0 +1,20 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Input uniform values
+uniform sampler2D texture0;
+uniform vec4 colDiffuse;
+
+// Output fragment color
+out vec4 finalColor;
+
+void main()
+{
+ vec4 texelColor = texture(texture0, fragTexCoord);
+
+ finalColor = texelColor*colDiffuse*fragColor;
+ gl_FragDepth = 1.0 - finalColor.z;
+}
diff --git a/examples/shaders/resources/spark_flame.png b/examples/shaders/resources/spark_flame.png
new file mode 100644
index 000000000..72cea2e9b
Binary files /dev/null and b/examples/shaders/resources/spark_flame.png differ
diff --git a/examples/shaders/rlights.h b/examples/shaders/rlights.h
index cf0f7629a..d17bf7c2e 100644
--- a/examples/shaders/rlights.h
+++ b/examples/shaders/rlights.h
@@ -11,7 +11,7 @@
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2017-2022 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2017-2023 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
diff --git a/examples/shaders/shaders_basic_lighting.c b/examples/shaders/shaders_basic_lighting.c
index c557ecf73..61cec2e80 100644
--- a/examples/shaders/shaders_basic_lighting.c
+++ b/examples/shaders/shaders_basic_lighting.c
@@ -14,7 +14,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Chris Camacho (@codifies) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Chris Camacho (@codifies) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -50,7 +50,7 @@ int main(void)
camera.target = (Vector3){ 0.0f, 0.5f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
- camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Load plane model from a generated mesh
Model model = LoadModelFromMesh(GenMeshPlane(10.0f, 10.0f, 3, 3));
@@ -80,17 +80,15 @@ int main(void)
lights[2] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, 2 }, Vector3Zero(), GREEN, shader);
lights[3] = CreateLight(LIGHT_POINT, (Vector3){ 2, 1, -2 }, Vector3Zero(), BLUE, shader);
- SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
-
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_ORBITAL);
// Update the shader with the camera view vector (points towards { 0.0f, 0.0f, 0.0f })
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
diff --git a/examples/shaders/shaders_custom_uniform.c b/examples/shaders/shaders_custom_uniform.c
index 401328e0f..eaeca5e51 100644
--- a/examples/shaders/shaders_custom_uniform.c
+++ b/examples/shaders/shaders_custom_uniform.c
@@ -14,7 +14,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -42,11 +42,11 @@ int main(void)
// Define the camera to look into our 3d world
Camera camera = { 0 };
- camera.position = (Vector3){ 8.0f, 8.0f, 8.0f };
- camera.target = (Vector3){ 0.0f, 1.5f, 0.0f };
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
- camera.fovy = 45.0f;
- camera.projection = CAMERA_PERSPECTIVE;
+ camera.position = (Vector3){ 8.0f, 8.0f, 8.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 1.5f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Model model = LoadModel("resources/models/barracks.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/barracks_diffuse.png"); // Load model texture (diffuse map)
@@ -67,9 +67,6 @@ int main(void)
// Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
- // Setup orbital camera
- SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
-
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -78,7 +75,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_ORBITAL);
Vector2 mousePosition = GetMousePosition();
diff --git a/examples/shaders/shaders_eratosthenes.c b/examples/shaders/shaders_eratosthenes.c
index a1f4101ac..a481f3008 100644
--- a/examples/shaders/shaders_eratosthenes.c
+++ b/examples/shaders/shaders_eratosthenes.c
@@ -21,7 +21,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 ProfJski and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 ProfJski and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shaders/shaders_fog.c b/examples/shaders/shaders_fog.c
index de5c23df5..24a1c1068 100644
--- a/examples/shaders/shaders_fog.c
+++ b/examples/shaders/shaders_fog.c
@@ -14,7 +14,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Chris Camacho (@chriscamacho) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Chris Camacho (@chriscamacho) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -45,11 +45,12 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - fog");
// Define the camera to look into our 3d world
- Camera camera = {
- (Vector3){ 2.0f, 2.0f, 6.0f }, // position
- (Vector3){ 0.0f, 0.5f, 0.0f }, // target
- (Vector3){ 0.0f, 1.0f, 0.0f }, // up
- 45.0f, CAMERA_PERSPECTIVE }; // fov, type
+ Camera camera = { 0 };
+ camera.position = (Vector3){ 2.0f, 2.0f, 6.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 0.5f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Load models and texture
Model modelA = LoadModelFromMesh(GenMeshTorus(0.4f, 1.0f, 16, 32));
@@ -84,17 +85,15 @@ int main(void)
// Using just 1 point lights
CreateLight(LIGHT_POINT, (Vector3){ 0, 2, 6 }, Vector3Zero(), WHITE, shader);
- SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
-
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_ORBITAL);
if (IsKeyDown(KEY_UP))
{
diff --git a/examples/shaders/shaders_hot_reloading.c b/examples/shaders/shaders_hot_reloading.c
index e9aae3496..395d44cfe 100644
--- a/examples/shaders/shaders_hot_reloading.c
+++ b/examples/shaders/shaders_hot_reloading.c
@@ -10,7 +10,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2020-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2020-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -38,7 +38,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - hot reloading");
const char *fragShaderFileName = "resources/shaders/glsl%i/reload.fs";
- long fragShaderFileModTime = GetFileModTime(TextFormat(fragShaderFileName, GLSL_VERSION));
+ time_t fragShaderFileModTime = GetFileModTime(TextFormat(fragShaderFileName, GLSL_VERSION));
// Load raymarching shader
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
diff --git a/examples/shaders/shaders_hybrid_render.c b/examples/shaders/shaders_hybrid_render.c
new file mode 100644
index 000000000..f07917fb0
--- /dev/null
+++ b/examples/shaders/shaders_hybrid_render.c
@@ -0,0 +1,208 @@
+/*******************************************************************************************
+*
+* raylib [shaders] example - Hybrid Rendering
+*
+* Example originally created with raylib 4.2, last time updated with raylib 4.2
+*
+* Example contributed by Buğra Alptekin Sarı (@BugraAlptekinSari) and reviewed by Ramon Santamaria (@raysan5)
+*
+* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
+* BSD-like license that allows static linking with closed source software
+*
+* Copyright (c) 2022-2023 Buğra Alptekin Sarı (@BugraAlptekinSari)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+#include "rlgl.h"
+#include "math.h" // Used for tan()
+#include "raymath.h" // Used to calculate camera Direction
+
+#if defined(PLATFORM_DESKTOP)
+#define GLSL_VERSION 330
+#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
+#define GLSL_VERSION 100
+#endif
+
+//------------------------------------------------------------------------------------
+// Declare custom functions required for the example
+//------------------------------------------------------------------------------------
+// Load custom render texture, create a writable depth texture buffer
+static RenderTexture2D LoadRenderTextureDepthTex(int width, int height);
+// Unload render texture from GPU memory (VRAM)
+static void UnloadRenderTextureDepthTex(RenderTexture2D target);
+
+//------------------------------------------------------------------------------------
+// Declare custom Structs
+//------------------------------------------------------------------------------------
+
+typedef struct {
+ unsigned int camPos, camDir, screenCenter;
+}RayLocs ;
+
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
+int main(void)
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [shaders] example - write depth buffer");
+
+ // This Shader calculates pixel depth and color using raymarch
+ Shader shdrRaymarch = LoadShader(0, TextFormat("resources/shaders/glsl%i/hybrid_raymarch.fs", GLSL_VERSION));
+
+ // This Shader is a standard rasterization fragment shader with the addition of depth writing
+ // You are required to write depth for all shaders if one shader does it
+ Shader shdrRaster = LoadShader(0, TextFormat("resources/shaders/glsl%i/hybrid_raster.fs", GLSL_VERSION));
+
+ // Declare Struct used to store camera locs.
+ RayLocs marchLocs = {0};
+
+ // Fill the struct with shader locs.
+ marchLocs.camPos = GetShaderLocation(shdrRaymarch, "camPos");
+ marchLocs.camDir = GetShaderLocation(shdrRaymarch, "camDir");
+ marchLocs.screenCenter = GetShaderLocation(shdrRaymarch, "screenCenter");
+
+ // Transfer screenCenter position to shader. Which is used to calculate ray direction.
+ Vector2 screenCenter = {.x = screenWidth/2.0, .y = screenHeight/2.0};
+ SetShaderValue(shdrRaymarch, marchLocs.screenCenter , &screenCenter , SHADER_UNIFORM_VEC2);
+
+ // Use Customized function to create writable depth texture buffer
+ RenderTexture2D target = LoadRenderTextureDepthTex(screenWidth, screenHeight);
+
+ // Define the camera to look into our 3d world
+ Camera camera = {
+ .position = (Vector3){ 0.5f, 1.0f, 1.5f }, // Camera position
+ .target = (Vector3){ 0.0f, 0.5f, 0.0f }, // Camera looking at point
+ .up = (Vector3){ 0.0f, 1.0f, 0.0f }, // Camera up vector (rotation towards target)
+ .fovy = 45.0f, // Camera field-of-view Y
+ .projection = CAMERA_PERSPECTIVE // Camera projection type
+ };
+
+ // Camera FOV is pre-calculated in the camera Distance.
+ double camDist = 1.0/(tan(camera.fovy*0.5*DEG2RAD));
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ UpdateCamera(&camera, CAMERA_ORBITAL);
+
+ // Update Camera Postion in the ray march shader.
+ SetShaderValue(shdrRaymarch, marchLocs.camPos, &(camera.position), RL_SHADER_UNIFORM_VEC3);
+
+ // Update Camera Looking Vector. Vector length determines FOV.
+ Vector3 camDir = Vector3Scale( Vector3Normalize( Vector3Subtract(camera.target, camera.position)) , camDist);
+ SetShaderValue(shdrRaymarch, marchLocs.camDir, &(camDir), RL_SHADER_UNIFORM_VEC3);
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ // Draw into our custom render texture (framebuffer)
+ BeginTextureMode(target);
+ ClearBackground(WHITE);
+
+ // Raymarch Scene
+ rlEnableDepthTest(); //Manually enable Depth Test to handle multiple rendering methods.
+ BeginShaderMode(shdrRaymarch);
+ DrawRectangleRec((Rectangle){0,0,screenWidth,screenHeight},WHITE);
+ EndShaderMode();
+
+ // Raserize Scene
+ BeginMode3D(camera);
+ BeginShaderMode(shdrRaster);
+ DrawCubeWiresV((Vector3){ 0.0f, 0.5f, 1.0f }, (Vector3){ 1.0f, 1.0f, 1.0f }, RED);
+ DrawCubeV((Vector3){ 0.0f, 0.5f, 1.0f }, (Vector3){ 1.0f, 1.0f, 1.0f }, PURPLE);
+ DrawCubeWiresV((Vector3){ 0.0f, 0.5f, -1.0f }, (Vector3){ 1.0f, 1.0f, 1.0f }, DARKGREEN);
+ DrawCubeV((Vector3) { 0.0f, 0.5f, -1.0f }, (Vector3){ 1.0f, 1.0f, 1.0f }, YELLOW);
+ DrawGrid(10, 1.0f);
+ EndShaderMode();
+ EndMode3D();
+ EndTextureMode();
+
+ // Draw into screen our custom render texture
+ BeginDrawing();
+ ClearBackground(RAYWHITE);
+
+ DrawTextureRec(target.texture, (Rectangle) { 0, 0, screenWidth, -screenHeight }, (Vector2) { 0, 0 }, WHITE);
+ DrawFPS(10, 10);
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadRenderTextureDepthTex(target);
+ UnloadShader(shdrRaymarch);
+ UnloadShader(shdrRaster);
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------------
+// Define custom functions required for the example
+//------------------------------------------------------------------------------------
+// Load custom render texture, create a writable depth texture buffer
+RenderTexture2D LoadRenderTextureDepthTex(int width, int height)
+{
+ RenderTexture2D target = { 0 };
+
+ target.id = rlLoadFramebuffer(width, height); // Load an empty framebuffer
+
+ if (target.id > 0)
+ {
+ rlEnableFramebuffer(target.id);
+
+ // Create color texture (default to RGBA)
+ target.texture.id = rlLoadTexture(0, width, height, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1);
+ target.texture.width = width;
+ target.texture.height = height;
+ target.texture.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
+ target.texture.mipmaps = 1;
+
+ // Create depth texture buffer (instead of raylib default renderbuffer)
+ target.depth.id = rlLoadTextureDepth(width, height, false);
+ target.depth.width = width;
+ target.depth.height = height;
+ target.depth.format = 19; //DEPTH_COMPONENT_24BIT?
+ target.depth.mipmaps = 1;
+
+ // Attach color texture and depth texture to FBO
+ rlFramebufferAttach(target.id, target.texture.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_TEXTURE2D, 0);
+ rlFramebufferAttach(target.id, target.depth.id, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_TEXTURE2D, 0);
+
+ // Check if fbo is complete with attachments (valid)
+ if (rlFramebufferComplete(target.id)) TRACELOG(LOG_INFO, "FBO: [ID %i] Framebuffer object created successfully", target.id);
+
+ rlDisableFramebuffer();
+ }
+ else TRACELOG(LOG_WARNING, "FBO: Framebuffer object can not be created");
+
+ return target;
+}
+
+// Unload render texture from GPU memory (VRAM)
+void UnloadRenderTextureDepthTex(RenderTexture2D target)
+{
+ if (target.id > 0)
+ {
+ // Color texture attached to FBO is deleted
+ rlUnloadTexture(target.texture.id);
+ rlUnloadTexture(target.depth.id);
+
+ // NOTE: Depth texture is automatically
+ // queried and deleted before deleting framebuffer
+ rlUnloadFramebuffer(target.id);
+ }
+}
\ No newline at end of file
diff --git a/examples/shaders/shaders_hybrid_render.png b/examples/shaders/shaders_hybrid_render.png
new file mode 100644
index 000000000..0a63d19c2
Binary files /dev/null and b/examples/shaders/shaders_hybrid_render.png differ
diff --git a/examples/shaders/shaders_julia_set.c b/examples/shaders/shaders_julia_set.c
index 962c723b1..ee1988058 100644
--- a/examples/shaders/shaders_julia_set.c
+++ b/examples/shaders/shaders_julia_set.c
@@ -14,7 +14,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 eggmund (@eggmund) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 eggmund (@eggmund) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shaders/shaders_lightmap.c b/examples/shaders/shaders_lightmap.c
new file mode 100644
index 000000000..b636c8b28
--- /dev/null
+++ b/examples/shaders/shaders_lightmap.c
@@ -0,0 +1,173 @@
+/*******************************************************************************************
+*
+* raylib [shaders] example - lightmap
+*
+* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
+* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
+*
+* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3).
+*
+* Example contributed by Jussi Viitala (@nullstare) and reviewed by Ramon Santamaria (@raysan5)
+*
+* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
+* BSD-like license that allows static linking with closed source software
+*
+* Copyright (c) 2019-2023 Jussi Viitala (@nullstare) and Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include
+#include
+
+#include "raylib.h"
+#include "raymath.h"
+#include "rlgl.h"
+
+#if defined(PLATFORM_DESKTOP)
+ #define GLSL_VERSION 330
+#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
+ #define GLSL_VERSION 100
+#endif
+
+#define MAP_SIZE 10
+
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
+int main(void)
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
+ SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
+ InitWindow(screenWidth, screenHeight, "raylib [shaders] example - lightmap");
+
+ // Define the camera to look into our 3d world
+ Camera camera = { 0 };
+ camera.position = (Vector3){ 4.0f, 6.0f, 8.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
+
+ Mesh mesh = GenMeshPlane((float)MAP_SIZE, (float)MAP_SIZE, 1, 1);
+
+ // GenMeshPlane doesn't generate texcoords2 so we will upload them separately
+ mesh.texcoords2 = (float *)RL_MALLOC(mesh.vertexCount*2*sizeof(float));
+
+ // X // Y
+ mesh.texcoords2[0] = 0.0f; mesh.texcoords2[1] = 0.0f;
+ mesh.texcoords2[2] = 1.0f; mesh.texcoords2[3] = 0.0f;
+ mesh.texcoords2[4] = 0.0f; mesh.texcoords2[5] = 1.0f;
+ mesh.texcoords2[6] = 1.0f; mesh.texcoords2[7] = 1.0f;
+
+ // Load a new texcoords2 attributes buffer
+ mesh.vboId[SHADER_LOC_VERTEX_TEXCOORD02] = rlLoadVertexBuffer(mesh.texcoords2, mesh.vertexCount*2*sizeof(float), false);
+ rlEnableVertexArray(mesh.vaoId);
+
+ // Index 5 is for texcoords2
+ rlSetVertexAttribute(5, 2, RL_FLOAT, 0, 0, 0);
+ rlEnableVertexAttribute(5);
+ rlDisableVertexArray();
+
+ // Load lightmap shader
+ Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/lightmap.vs", GLSL_VERSION),
+ TextFormat("resources/shaders/glsl%i/lightmap.fs", GLSL_VERSION));
+
+ Texture texture = LoadTexture("resources/cubicmap_atlas.png");
+ Texture light = LoadTexture("resources/spark_flame.png");
+
+ GenTextureMipmaps(&texture);
+ SetTextureFilter(texture, TEXTURE_FILTER_TRILINEAR);
+
+ RenderTexture lightmap = LoadRenderTexture(MAP_SIZE, MAP_SIZE);
+
+ SetTextureFilter(lightmap.texture, TEXTURE_FILTER_TRILINEAR);
+
+ Material material = LoadMaterialDefault();
+ material.shader = shader;
+ material.maps[MATERIAL_MAP_ALBEDO].texture = texture;
+ material.maps[MATERIAL_MAP_METALNESS].texture = lightmap.texture;
+
+ // Drawing to lightmap
+ BeginTextureMode(lightmap);
+ ClearBackground(BLACK);
+
+ BeginBlendMode(BLEND_ADDITIVE);
+ DrawTexturePro(
+ light,
+ (Rectangle){ 0, 0, light.width, light.height },
+ (Rectangle){ 0, 0, 20, 20 },
+ (Vector2){ 10.0, 10.0 },
+ 0.0,
+ RED
+ );
+ DrawTexturePro(
+ light,
+ (Rectangle){ 0, 0, light.width, light.height },
+ (Rectangle){ 8, 4, 20, 20 },
+ (Vector2){ 10.0, 10.0 },
+ 0.0,
+ BLUE
+ );
+ DrawTexturePro(
+ light,
+ (Rectangle){ 0, 0, light.width, light.height },
+ (Rectangle){ 8, 8, 10, 10 },
+ (Vector2){ 5.0, 5.0 },
+ 0.0,
+ GREEN
+ );
+ BeginBlendMode(BLEND_ALPHA);
+ EndTextureMode();
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ UpdateCamera(&camera, CAMERA_ORBITAL);
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+ ClearBackground(RAYWHITE);
+
+ BeginMode3D(camera);
+ DrawMesh(mesh, material, MatrixIdentity());
+ EndMode3D();
+
+ DrawFPS(10, 10);
+
+ DrawTexturePro(
+ lightmap.texture,
+ (Rectangle){ 0, 0, -MAP_SIZE, -MAP_SIZE },
+ (Rectangle){ GetRenderWidth() - MAP_SIZE*8 - 10, 10, MAP_SIZE*8, MAP_SIZE*8 },
+ (Vector2){ 0.0, 0.0 },
+ 0.0,
+ WHITE);
+
+ DrawText("lightmap", GetRenderWidth() - 66, 16 + MAP_SIZE*8, 10, GRAY);
+ DrawText("10x10 pixels", GetRenderWidth() - 76, 30 + MAP_SIZE*8, 10, GRAY);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadMesh(mesh); // Unload the mesh
+ UnloadShader(shader); // Unload shader
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}
+
diff --git a/examples/shaders/shaders_lightmap.png b/examples/shaders/shaders_lightmap.png
new file mode 100644
index 000000000..0fd67a6e0
Binary files /dev/null and b/examples/shaders/shaders_lightmap.png differ
diff --git a/examples/shaders/shaders_mesh_instancing.c b/examples/shaders/shaders_mesh_instancing.c
index ce0855d94..7789f2cb0 100644
--- a/examples/shaders/shaders_mesh_instancing.c
+++ b/examples/shaders/shaders_mesh_instancing.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2020-2022 @seanpringle, Max (@moliad) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2020-2023 @seanpringle, Max (@moliad) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -44,11 +44,11 @@ int main(void)
// Define the camera to look into our 3d world
Camera camera = { 0 };
- camera.position = (Vector3){ -125.0f, 125.0f, -125.0f };
- camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
- camera.fovy = 45.0f;
- camera.projection = CAMERA_PERSPECTIVE;
+ camera.position = (Vector3){ -125.0f, 125.0f, -125.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Define mesh to be instanced
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
@@ -94,18 +94,15 @@ int main(void)
Material matDefault = LoadMaterialDefault();
matDefault.maps[MATERIAL_MAP_DIFFUSE].color = BLUE;
- // Set an orbital camera mode
- SetCameraMode(camera, CAMERA_ORBITAL);
-
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_ORBITAL);
// Update the light shader with the camera view position
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
diff --git a/examples/shaders/shaders_model_shader.c b/examples/shaders/shaders_model_shader.c
index 29c1948c9..e84ecbfbe 100644
--- a/examples/shaders/shaders_model_shader.c
+++ b/examples/shaders/shaders_model_shader.c
@@ -14,7 +14,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -42,11 +42,11 @@ int main(void)
// Define the camera to look into our 3d world
Camera camera = { 0 };
- camera.position = (Vector3){ 4.0f, 4.0f, 4.0f };
- camera.target = (Vector3){ 0.0f, 1.0f, -1.0f };
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
- camera.fovy = 45.0f;
- camera.projection = CAMERA_PERSPECTIVE;
+ camera.position = (Vector3){ 4.0f, 4.0f, 4.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 1.0f, -1.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Model model = LoadModel("resources/models/watermill.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/watermill_diffuse.png"); // Load model texture
@@ -60,17 +60,16 @@ int main(void)
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
- SetCameraMode(camera, CAMERA_FREE); // Set an orbital camera mode
-
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ DisableCursor(); // Limit cursor to relative movement inside the window
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_FIRST_PERSON);
//----------------------------------------------------------------------------------
// Draw
diff --git a/examples/shaders/shaders_multi_sample2d.c b/examples/shaders/shaders_multi_sample2d.c
index ae5470fff..d6f8803b7 100644
--- a/examples/shaders/shaders_multi_sample2d.c
+++ b/examples/shaders/shaders_multi_sample2d.c
@@ -14,7 +14,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2020-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2020-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shaders/shaders_palette_switch.c b/examples/shaders/shaders_palette_switch.c
index b47bbf16f..bb1eda4e0 100644
--- a/examples/shaders/shaders_palette_switch.c
+++ b/examples/shaders/shaders_palette_switch.c
@@ -16,7 +16,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Marco Lizza (@MarcoLizza) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Marco Lizza (@MarcoLizza) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shaders/shaders_postprocessing.c b/examples/shaders/shaders_postprocessing.c
index 758250f19..7f6bd0092 100644
--- a/examples/shaders/shaders_postprocessing.c
+++ b/examples/shaders/shaders_postprocessing.c
@@ -14,7 +14,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -75,13 +75,18 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader");
// Define the camera to look into our 3d world
- Camera camera = { { 2.0f, 3.0f, 2.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
+ Camera camera = { 0 };
+ camera.position = (Vector3){ 2.0f, 3.0f, 2.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Model model = LoadModel("resources/models/church.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/church_diffuse.png"); // Load model texture (diffuse map)
- model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture
+ model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture
- Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
+ Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
// Load all postpro shaders
// NOTE 1: All postpro shader use the base vertex shader (DEFAULT_VERTEX_SHADER)
@@ -107,18 +112,15 @@ int main(void)
// Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
- // Setup orbital camera
- SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
-
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_ORBITAL);
if (IsKeyPressed(KEY_RIGHT)) currentShader++;
else if (IsKeyPressed(KEY_LEFT)) currentShader--;
diff --git a/examples/shaders/shaders_raymarching.c b/examples/shaders/shaders_raymarching.c
index 8be45fb9f..7b34a5233 100644
--- a/examples/shaders/shaders_raymarching.c
+++ b/examples/shaders/shaders_raymarching.c
@@ -10,7 +10,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2018-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2018-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -40,8 +40,7 @@ int main(void)
camera.target = (Vector3){ 0.0f, 0.0f, 0.7f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 65.0f; // Camera field-of-view Y
-
- SetCameraMode(camera, CAMERA_FREE); // Set camera mode
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Load raymarching shader
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
@@ -58,15 +57,16 @@ int main(void)
float runTime = 0.0f;
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ DisableCursor(); // Limit cursor to relative movement inside the window
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_FIRST_PERSON);
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
float cameraTarget[3] = { camera.target.x, camera.target.y, camera.target.z };
diff --git a/examples/shaders/shaders_shapes_textures.c b/examples/shaders/shaders_shapes_textures.c
index ca6677fbd..d3ec8daf0 100644
--- a/examples/shaders/shaders_shapes_textures.c
+++ b/examples/shaders/shaders_shapes_textures.c
@@ -14,7 +14,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shaders/shaders_simple_mask.c b/examples/shaders/shaders_simple_mask.c
index d10878d77..6283ccbcc 100644
--- a/examples/shaders/shaders_simple_mask.c
+++ b/examples/shaders/shaders_simple_mask.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Chris Camacho (@chriscamacho) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Chris Camacho (@chriscamacho) and Ramon Santamaria (@raysan5)
*
********************************************************************************************
*
@@ -39,15 +39,15 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
- InitWindow(screenWidth, screenHeight, "raylib - simple shader mask");
+ InitWindow(screenWidth, screenHeight, "raylib [shaders] example - simple shader mask");
// Define the camera to look into our 3d world
Camera camera = { 0 };
- camera.position = (Vector3){ 0.0f, 1.0f, 2.0f };
- camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
- camera.fovy = 45.0f;
- camera.projection = CAMERA_PERSPECTIVE;
+ camera.position = (Vector3){ 0.0f, 1.0f, 2.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Define our three models to show the shader on
Mesh torus = GenMeshTorus(0.3f, 1, 16, 32);
@@ -83,17 +83,18 @@ int main(void)
model2.materials[0].shader = shader;
int framesCounter = 0;
- Vector3 rotation = { 0 }; // Model rotation angles
+ Vector3 rotation = { 0 }; // Model rotation angles
- SetTargetFPS(60); // Set to run at 60 frames-per-second
+ DisableCursor(); // Limit cursor to relative movement inside the window
+ SetTargetFPS(60); // Set to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_FIRST_PERSON);
framesCounter++;
rotation.x += 0.01f;
@@ -115,9 +116,9 @@ int main(void)
BeginMode3D(camera);
- DrawModel(model1, (Vector3){0.5,0,0}, 1, WHITE);
- DrawModelEx(model2, (Vector3){-.5,0,0}, (Vector3){1,1,0}, 50, (Vector3){1,1,1}, WHITE);
- DrawModel(model3,(Vector3){0,0,-1.5}, 1, WHITE);
+ DrawModel(model1, (Vector3){ 0.5f, 0.0f, 0.0f }, 1, WHITE);
+ DrawModelEx(model2, (Vector3){ -0.5f, 0.0f, 0.0f }, (Vector3){ 1.0f, 1.0f, 0.0f }, 50, (Vector3){ 1.0f, 1.0f, 1.0f }, WHITE);
+ DrawModel(model3,(Vector3){ 0.0f, 0.0f, -1.5f }, 1, WHITE);
DrawGrid(10, 1.0f); // Draw a grid
EndMode3D();
diff --git a/examples/shaders/shaders_spotlight.c b/examples/shaders/shaders_spotlight.c
index 6ddcd42f6..c96c983d0 100644
--- a/examples/shaders/shaders_spotlight.c
+++ b/examples/shaders/shaders_spotlight.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Chris Camacho (@chriscamacho) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Chris Camacho (@chriscamacho) and Ramon Santamaria (@raysan5)
*
********************************************************************************************
*
@@ -29,10 +29,8 @@
********************************************************************************************/
#include "raylib.h"
-#include "raymath.h"
-#include
-#include
+#include "raymath.h"
#if defined(PLATFORM_DESKTOP)
#define GLSL_VERSION 330
@@ -44,26 +42,26 @@
#define MAX_STARS 400
// Spot data
-typedef struct {
- Vector2 pos;
- Vector2 vel;
+typedef struct Spot {
+ Vector2 position;
+ Vector2 speed;
float inner;
float radius;
// Shader locations
- unsigned int posLoc;
+ unsigned int positionLoc;
unsigned int innerLoc;
unsigned int radiusLoc;
} Spot;
// Stars in the star field have a position and velocity
typedef struct Star {
- Vector2 pos;
- Vector2 vel;
+ Vector2 position;
+ Vector2 speed;
} Star;
-void UpdateStar(Star *s);
-void ResetStar(Star *s);
+static void UpdateStar(Star *s);
+static void ResetStar(Star *s);
//------------------------------------------------------------------------------------
// Program main entry point
@@ -75,7 +73,7 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
- InitWindow(screenWidth, screenHeight, "raylib - shader spotlight");
+ InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shader spotlight");
HideCursor();
Texture texRay = LoadTexture("resources/raysan.png");
@@ -108,7 +106,7 @@ int main(void)
innerName[6] = '0' + i;
radiusName[6] = '0' + i;
- spots[i].posLoc = GetShaderLocation(shdrSpot, posName);
+ spots[i].positionLoc = GetShaderLocation(shdrSpot, posName);
spots[i].innerLoc = GetShaderLocation(shdrSpot, innerName);
spots[i].radiusLoc = GetShaderLocation(shdrSpot, radiusName);
@@ -124,20 +122,20 @@ int main(void)
// and initialize the shader locations
for (int i = 0; i < MAX_SPOTS; i++)
{
- spots[i].pos.x = (float)GetRandomValue(64, screenWidth - 64);
- spots[i].pos.y = (float)GetRandomValue(64, screenHeight - 64);
- spots[i].vel = (Vector2){ 0, 0 };
+ spots[i].position.x = (float)GetRandomValue(64, screenWidth - 64);
+ spots[i].position.y = (float)GetRandomValue(64, screenHeight - 64);
+ spots[i].speed = (Vector2){ 0, 0 };
- while ((fabs(spots[i].vel.x) + fabs(spots[i].vel.y)) < 2)
+ while ((fabs(spots[i].speed.x) + fabs(spots[i].speed.y)) < 2)
{
- spots[i].vel.x = GetRandomValue(-400, 40) / 10.0f;
- spots[i].vel.y = GetRandomValue(-400, 40) / 10.0f;
+ spots[i].speed.x = GetRandomValue(-400, 40) / 10.0f;
+ spots[i].speed.y = GetRandomValue(-400, 40) / 10.0f;
}
spots[i].inner = 28.0f * (i + 1);
spots[i].radius = 48.0f * (i + 1);
- SetShaderValue(shdrSpot, spots[i].posLoc, &spots[i].pos.x, SHADER_UNIFORM_VEC2);
+ SetShaderValue(shdrSpot, spots[i].positionLoc, &spots[i].position.x, SHADER_UNIFORM_VEC2);
SetShaderValue(shdrSpot, spots[i].innerLoc, &spots[i].inner, SHADER_UNIFORM_FLOAT);
SetShaderValue(shdrSpot, spots[i].radiusLoc, &spots[i].radius, SHADER_UNIFORM_FLOAT);
}
@@ -161,21 +159,21 @@ int main(void)
if (i == 0)
{
Vector2 mp = GetMousePosition();
- spots[i].pos.x = mp.x;
- spots[i].pos.y = screenHeight - mp.y;
+ spots[i].position.x = mp.x;
+ spots[i].position.y = screenHeight - mp.y;
}
else
{
- spots[i].pos.x += spots[i].vel.x;
- spots[i].pos.y += spots[i].vel.y;
+ spots[i].position.x += spots[i].speed.x;
+ spots[i].position.y += spots[i].speed.y;
- if (spots[i].pos.x < 64) spots[i].vel.x = -spots[i].vel.x;
- if (spots[i].pos.x > (screenWidth - 64)) spots[i].vel.x = -spots[i].vel.x;
- if (spots[i].pos.y < 64) spots[i].vel.y = -spots[i].vel.y;
- if (spots[i].pos.y > (screenHeight - 64)) spots[i].vel.y = -spots[i].vel.y;
+ if (spots[i].position.x < 64) spots[i].speed.x = -spots[i].speed.x;
+ if (spots[i].position.x > (screenWidth - 64)) spots[i].speed.x = -spots[i].speed.x;
+ if (spots[i].position.y < 64) spots[i].speed.y = -spots[i].speed.y;
+ if (spots[i].position.y > (screenHeight - 64)) spots[i].speed.y = -spots[i].speed.y;
}
- SetShaderValue(shdrSpot, spots[i].posLoc, &spots[i].pos.x, SHADER_UNIFORM_VEC2);
+ SetShaderValue(shdrSpot, spots[i].positionLoc, &spots[i].position.x, SHADER_UNIFORM_VEC2);
}
// Draw
@@ -188,7 +186,7 @@ int main(void)
for (int n = 0; n < MAX_STARS; n++)
{
// Single pixel is just too small these days!
- DrawRectangle((int)stars[n].pos.x, (int)stars[n].pos.y, 2, 2, WHITE);
+ DrawRectangle((int)stars[n].position.x, (int)stars[n].position.y, 2, 2, WHITE);
}
for (int i = 0; i < 16; i++)
@@ -213,7 +211,6 @@ int main(void)
DrawText("Pitch Black", (int)(screenWidth*0.2f), screenHeight/2, 20, GREEN);
DrawText("Dark", (int)(screenWidth*.66f), screenHeight/2, 20, GREEN);
-
EndDrawing();
//----------------------------------------------------------------------------------
}
@@ -230,26 +227,26 @@ int main(void)
}
-void ResetStar(Star *s)
+static void ResetStar(Star *s)
{
- s->pos = (Vector2){ GetScreenWidth()/2.0f, GetScreenHeight()/2.0f };
+ s->position = (Vector2){ GetScreenWidth()/2.0f, GetScreenHeight()/2.0f };
do
{
- s->vel.x = (float)GetRandomValue(-1000, 1000)/100.0f;
- s->vel.y = (float)GetRandomValue(-1000, 1000)/100.0f;
+ s->speed.x = (float)GetRandomValue(-1000, 1000)/100.0f;
+ s->speed.y = (float)GetRandomValue(-1000, 1000)/100.0f;
- } while (!(fabs(s->vel.x) + (fabs(s->vel.y) > 1)));
+ } while (!(fabs(s->speed.x) + (fabs(s->speed.y) > 1)));
- s->pos = Vector2Add(s->pos, Vector2Multiply(s->vel, (Vector2){ 8.0f, 8.0f }));
+ s->position = Vector2Add(s->position, Vector2Multiply(s->speed, (Vector2){ 8.0f, 8.0f }));
}
-void UpdateStar(Star *s)
+static void UpdateStar(Star *s)
{
- s->pos = Vector2Add(s->pos, s->vel);
+ s->position = Vector2Add(s->position, s->speed);
- if ((s->pos.x < 0) || (s->pos.x > GetScreenWidth()) ||
- (s->pos.y < 0) || (s->pos.y > GetScreenHeight()))
+ if ((s->position.x < 0) || (s->position.x > GetScreenWidth()) ||
+ (s->position.y < 0) || (s->position.y > GetScreenHeight()))
{
ResetStar(s);
}
diff --git a/examples/shaders/shaders_texture_drawing.c b/examples/shaders/shaders_texture_drawing.c
index 6b82915b5..006168d57 100644
--- a/examples/shaders/shaders_texture_drawing.c
+++ b/examples/shaders/shaders_texture_drawing.c
@@ -11,7 +11,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Michał Ciesielski and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Michał Ciesielski and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shaders/shaders_texture_outline.c b/examples/shaders/shaders_texture_outline.c
index c81d3ff16..a28ab80e4 100644
--- a/examples/shaders/shaders_texture_outline.c
+++ b/examples/shaders/shaders_texture_outline.c
@@ -12,7 +12,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2021-2022 Samuel SKiff (@GoldenThumbs) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2021-2023 Samuel SKiff (@GoldenThumbs) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shaders/shaders_texture_waves.c b/examples/shaders/shaders_texture_waves.c
index cc250f1b9..27ad1f6e4 100644
--- a/examples/shaders/shaders_texture_waves.c
+++ b/examples/shaders/shaders_texture_waves.c
@@ -16,7 +16,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Anata (@anatagawa) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Anata (@anatagawa) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -46,7 +46,7 @@ int main(void)
// Load shader and setup location points and values
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/wave.fs", GLSL_VERSION));
- int secondsLoc = GetShaderLocation(shader, "secondes");
+ int secondsLoc = GetShaderLocation(shader, "seconds");
int freqXLoc = GetShaderLocation(shader, "freqX");
int freqYLoc = GetShaderLocation(shader, "freqY");
int ampXLoc = GetShaderLocation(shader, "ampX");
diff --git a/examples/shaders/shaders_write_depth.c b/examples/shaders/shaders_write_depth.c
new file mode 100644
index 000000000..048e297ad
--- /dev/null
+++ b/examples/shaders/shaders_write_depth.c
@@ -0,0 +1,167 @@
+/*******************************************************************************************
+*
+* raylib [shaders] example - Depth buffer writing
+*
+* Example originally created with raylib 4.2, last time updated with raylib 4.2
+*
+* Example contributed by Buğra Alptekin Sarı (@BugraAlptekinSari) and reviewed by Ramon Santamaria (@raysan5)
+*
+* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
+* BSD-like license that allows static linking with closed source software
+*
+* Copyright (c) 2022-2023 Buğra Alptekin Sarı (@BugraAlptekinSari)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#include "rlgl.h"
+
+#if defined(PLATFORM_DESKTOP)
+#define GLSL_VERSION 330
+#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
+#define GLSL_VERSION 100
+#endif
+
+//------------------------------------------------------------------------------------
+// Declare custom functions required for the example
+//------------------------------------------------------------------------------------
+// Load custom render texture, create a writable depth texture buffer
+static RenderTexture2D LoadRenderTextureDepthTex(int width, int height);
+
+// Unload render texture from GPU memory (VRAM)
+static void UnloadRenderTextureDepthTex(RenderTexture2D target);
+
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
+int main(void)
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [shaders] example - write depth buffer");
+
+ // The shader inverts the depth buffer by writing into it by `gl_FragDepth = 1 - gl_FragCoord.z;`
+ Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/write_depth.fs", GLSL_VERSION));
+
+ // Use Customized function to create writable depth texture buffer
+ RenderTexture2D target = LoadRenderTextureDepthTex(screenWidth, screenHeight);
+
+ // Define the camera to look into our 3d world
+ Camera camera = {
+ .position = (Vector3){ 2.0f, 2.0f, 3.0f }, // Camera position
+ .target = (Vector3){ 0.0f, 0.5f, 0.0f }, // Camera looking at point
+ .up = (Vector3){ 0.0f, 1.0f, 0.0f }, // Camera up vector (rotation towards target)
+ .fovy = 45.0f, // Camera field-of-view Y
+ .projection = CAMERA_PERSPECTIVE // Camera projection type
+ };
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ UpdateCamera(&camera, CAMERA_ORBITAL);
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+
+ // Draw into our custom render texture (framebuffer)
+ BeginTextureMode(target);
+ ClearBackground(WHITE);
+
+ BeginMode3D(camera);
+ BeginShaderMode(shader);
+ DrawCubeWiresV((Vector3){ 0.0f, 0.5f, 1.0f }, (Vector3){ 1.0f, 1.0f, 1.0f }, RED);
+ DrawCubeV((Vector3){ 0.0f, 0.5f, 1.0f }, (Vector3){ 1.0f, 1.0f, 1.0f }, PURPLE);
+ DrawCubeWiresV((Vector3){ 0.0f, 0.5f, -1.0f }, (Vector3){ 1.0f, 1.0f, 1.0f }, DARKGREEN);
+ DrawCubeV((Vector3) { 0.0f, 0.5f, -1.0f }, (Vector3){ 1.0f, 1.0f, 1.0f }, YELLOW);
+ DrawGrid(10, 1.0f);
+ EndShaderMode();
+ EndMode3D();
+ EndTextureMode();
+
+ // Draw into screen our custom render texture
+ BeginDrawing();
+ ClearBackground(RAYWHITE);
+
+ DrawTextureRec(target.texture, (Rectangle) { 0, 0, screenWidth, -screenHeight }, (Vector2) { 0, 0 }, WHITE);
+ DrawFPS(10, 10);
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadRenderTextureDepthTex(target);
+ UnloadShader(shader);
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------------
+// Define custom functions required for the example
+//------------------------------------------------------------------------------------
+// Load custom render texture, create a writable depth texture buffer
+RenderTexture2D LoadRenderTextureDepthTex(int width, int height)
+{
+ RenderTexture2D target = { 0 };
+
+ target.id = rlLoadFramebuffer(width, height); // Load an empty framebuffer
+
+ if (target.id > 0)
+ {
+ rlEnableFramebuffer(target.id);
+
+ // Create color texture (default to RGBA)
+ target.texture.id = rlLoadTexture(0, width, height, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1);
+ target.texture.width = width;
+ target.texture.height = height;
+ target.texture.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
+ target.texture.mipmaps = 1;
+
+ // Create depth texture buffer (instead of raylib default renderbuffer)
+ target.depth.id = rlLoadTextureDepth(width, height, false);
+ target.depth.width = width;
+ target.depth.height = height;
+ target.depth.format = 19; //DEPTH_COMPONENT_24BIT?
+ target.depth.mipmaps = 1;
+
+ // Attach color texture and depth texture to FBO
+ rlFramebufferAttach(target.id, target.texture.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_TEXTURE2D, 0);
+ rlFramebufferAttach(target.id, target.depth.id, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_TEXTURE2D, 0);
+
+ // Check if fbo is complete with attachments (valid)
+ if (rlFramebufferComplete(target.id)) TRACELOG(LOG_INFO, "FBO: [ID %i] Framebuffer object created successfully", target.id);
+
+ rlDisableFramebuffer();
+ }
+ else TRACELOG(LOG_WARNING, "FBO: Framebuffer object can not be created");
+
+ return target;
+}
+
+// Unload render texture from GPU memory (VRAM)
+void UnloadRenderTextureDepthTex(RenderTexture2D target)
+{
+ if (target.id > 0)
+ {
+ // Color texture attached to FBO is deleted
+ rlUnloadTexture(target.texture.id);
+ rlUnloadTexture(target.depth.id);
+
+ // NOTE: Depth texture is automatically
+ // queried and deleted before deleting framebuffer
+ rlUnloadFramebuffer(target.id);
+ }
+}
\ No newline at end of file
diff --git a/examples/shaders/shaders_write_depth.png b/examples/shaders/shaders_write_depth.png
new file mode 100644
index 000000000..5a56d7d25
Binary files /dev/null and b/examples/shaders/shaders_write_depth.png differ
diff --git a/examples/shapes/raygui.h b/examples/shapes/raygui.h
index 3e7dea442..63a27fa90 100644
--- a/examples/shapes/raygui.h
+++ b/examples/shapes/raygui.h
@@ -1,22 +1,38 @@
/*******************************************************************************************
*
-* raygui v3.2 - A simple and easy-to-use immediate-mode gui library
+* raygui v4.0-dev - A simple and easy-to-use immediate-mode gui library
*
* DESCRIPTION:
+* raygui is a tools-dev-focused immediate-mode-gui library based on raylib but also
+* available as a standalone library, as long as input and drawing functions are provided.
*
-* raygui is a tools-dev-focused immediate-mode-gui library based on raylib but also
-* available as a standalone library, as long as input and drawing functions are provided.
+* FEATURES:
+* - Immediate-mode gui, minimal retained data
+* - +25 controls provided (basic and advanced)
+* - Styling system for colors, font and metrics
+* - Icons supported, embeds a complete 1-bit icons pack
+* - Standalone usage mode option (custom graphics backends)
+* - Multiple tools provided for raygui development
*
-* Controls provided:
+* POSSIBLE IMPROVEMENTS:
+* - Redesign functions that require a value as parameter to be returned, pass by reference
+* - Better standalone mode API for easy plug of custom backends
+* - Externalize required inputs in some way, allow user customization
*
-* # Container/separators Controls
+* LIMITATIONS:
+* - No multi-line word-wraped text box support
+* - No auto-layout mechanism provided, up to the user to define controls position and size
+* - Standalone mode requires library modification and some user work to plug another backend
+*
+* CONTROLS PROVIDED:
+* # Container/separators Controls
* - WindowBox --> StatusBar, Panel
* - GroupBox --> Line
* - Line
* - Panel --> StatusBar
* - ScrollPanel --> StatusBar
*
-* # Basic Controls
+* # Basic Controls
* - Label
* - Button
* - LabelButton --> Label
@@ -26,7 +42,6 @@
* - ComboBox
* - DropdownBox
* - TextBox
-* - TextBoxMulti
* - ValueBox --> TextBox
* - Spinner --> Button, ValueBox
* - Slider
@@ -36,81 +51,124 @@
* - DummyRec
* - Grid
*
-* # Advance Controls
+* # Advance Controls
* - ListView
* - ColorPicker --> ColorPanel, ColorBarHue
* - MessageBox --> Window, Label, Button
* - TextInputBox --> Window, Label, TextBox, Button
*
-* It also provides a set of functions for styling the controls based on its properties (size, color).
+* It also provides a set of functions for styling the controls based on its properties (size, color).
*
*
* RAYGUI STYLE (guiStyle):
+* raygui uses a global data array for all gui style properties (allocated on data segment by default),
+* when a new style is loaded, it is loaded over the global style... but a default gui style could always be
+* recovered with GuiLoadStyleDefault() function, that overwrites the current style to the default one
*
-* raygui uses a global data array for all gui style properties (allocated on data segment by default),
-* when a new style is loaded, it is loaded over the global style... but a default gui style could always be
-* recovered with GuiLoadStyleDefault() function, that overwrites the current style to the default one
+* The global style array size is fixed and depends on the number of controls and properties:
*
-* The global style array size is fixed and depends on the number of controls and properties:
+* static unsigned int guiStyle[RAYGUI_MAX_CONTROLS*(RAYGUI_MAX_PROPS_BASE + RAYGUI_MAX_PROPS_EXTENDED)];
*
-* static unsigned int guiStyle[RAYGUI_MAX_CONTROLS*(RAYGUI_MAX_PROPS_BASE + RAYGUI_MAX_PROPS_EXTENDED)];
+* guiStyle size is by default: 16*(16 + 8) = 384*4 = 1536 bytes = 1.5 KB
*
-* guiStyle size is by default: 16*(16 + 8) = 384*4 = 1536 bytes = 1.5 KB
+* Note that the first set of BASE properties (by default guiStyle[0..15]) belong to the generic style
+* used for all controls, when any of those base values is set, it is automatically populated to all
+* controls, so, specific control values overwriting generic style should be set after base values.
*
-* Note that the first set of BASE properties (by default guiStyle[0..15]) belong to the generic style
-* used for all controls, when any of those base values is set, it is automatically populated to all
-* controls, so, specific control values overwriting generic style should be set after base values.
+* After the first BASE set we have the EXTENDED properties (by default guiStyle[16..23]), those
+* properties are actually common to all controls and can not be overwritten individually (like BASE ones)
+* Some of those properties are: TEXT_SIZE, TEXT_SPACING, LINE_COLOR, BACKGROUND_COLOR
*
-* After the first BASE set we have the EXTENDED properties (by default guiStyle[16..23]), those
-* properties are actually common to all controls and can not be overwritten individually (like BASE ones)
-* Some of those properties are: TEXT_SIZE, TEXT_SPACING, LINE_COLOR, BACKGROUND_COLOR
+* Custom control properties can be defined using the EXTENDED properties for each independent control.
*
-* Custom control properties can be defined using the EXTENDED properties for each independent control.
-*
-* TOOL: rGuiStyler is a visual tool to customize raygui style.
+* TOOL: rGuiStyler is a visual tool to customize raygui style: github.com/raysan5/rguistyler
*
*
* RAYGUI ICONS (guiIcons):
+* raygui could use a global array containing icons data (allocated on data segment by default),
+* a custom icons set could be loaded over this array using GuiLoadIcons(), but loaded icons set
+* must be same RAYGUI_ICON_SIZE and no more than RAYGUI_ICON_MAX_ICONS will be loaded
*
-* raygui could use a global array containing icons data (allocated on data segment by default),
-* a custom icons set could be loaded over this array using GuiLoadIcons(), but loaded icons set
-* must be same RAYGUI_ICON_SIZE and no more than RAYGUI_ICON_MAX_ICONS will be loaded
+* Every icon is codified in binary form, using 1 bit per pixel, so, every 16x16 icon
+* requires 8 integers (16*16/32) to be stored in memory.
*
-* Every icon is codified in binary form, using 1 bit per pixel, so, every 16x16 icon
-* requires 8 integers (16*16/32) to be stored in memory.
+* When the icon is draw, actually one quad per pixel is drawn if the bit for that pixel is set.
*
-* When the icon is draw, actually one quad per pixel is drawn if the bit for that pixel is set.
+* The global icons array size is fixed and depends on the number of icons and size:
*
-* The global icons array size is fixed and depends on the number of icons and size:
+* static unsigned int guiIcons[RAYGUI_ICON_MAX_ICONS*RAYGUI_ICON_DATA_ELEMENTS];
*
-* static unsigned int guiIcons[RAYGUI_ICON_MAX_ICONS*RAYGUI_ICON_DATA_ELEMENTS];
+* guiIcons size is by default: 256*(16*16/32) = 2048*4 = 8192 bytes = 8 KB
*
-* guiIcons size is by default: 256*(16*16/32) = 2048*4 = 8192 bytes = 8 KB
+* TOOL: rGuiIcons is a visual tool to customize/create raygui icons: github.com/raysan5/rguiicons
*
-* TOOL: rGuiIcons is a visual tool to customize raygui icons.
+* RAYGUI LAYOUT:
+* raygui currently does not provide an auto-layout mechanism like other libraries,
+* layouts must be defined manually on controls drawing, providing the right bounds Rectangle for it.
*
+* TOOL: rGuiLayout is a visual tool to create raygui layouts: github.com/raysan5/rguilayout
*
* CONFIGURATION:
+* #define RAYGUI_IMPLEMENTATION
+* Generates the implementation of the library into the included file.
+* If not defined, the library is in header only mode and can be included in other headers
+* or source files without problems. But only ONE file should hold the implementation.
*
-* #define RAYGUI_IMPLEMENTATION
-* Generates the implementation of the library into the included file.
-* If not defined, the library is in header only mode and can be included in other headers
-* or source files without problems. But only ONE file should hold the implementation.
+* #define RAYGUI_STANDALONE
+* Avoid raylib.h header inclusion in this file. Data types defined on raylib are defined
+* internally in the library and input management and drawing functions must be provided by
+* the user (check library implementation for further details).
*
-* #define RAYGUI_STANDALONE
-* Avoid raylib.h header inclusion in this file. Data types defined on raylib are defined
-* internally in the library and input management and drawing functions must be provided by
-* the user (check library implementation for further details).
+* #define RAYGUI_NO_ICONS
+* Avoid including embedded ricons data (256 icons, 16x16 pixels, 1-bit per pixel, 2KB)
*
-* #define RAYGUI_NO_ICONS
-* Avoid including embedded ricons data (256 icons, 16x16 pixels, 1-bit per pixel, 2KB)
-*
-* #define RAYGUI_CUSTOM_ICONS
-* Includes custom ricons.h header defining a set of custom icons,
-* this file can be generated using rGuiIcons tool
+* #define RAYGUI_CUSTOM_ICONS
+* Includes custom ricons.h header defining a set of custom icons,
+* this file can be generated using rGuiIcons tool
*
+* #define RAYGUI_DEBUG_TEXT_BOUNDS
+* Draw text bounds rectangles for debug
*
* VERSIONS HISTORY:
+* 4.0 (xx-Jun-2023) REDESIGNED: GuiScrollPanel(), get parameters by reference and return result value
+* REDESIGNED: GuiToggleGroup(), get parameters by reference and return result value
+* REDESIGNED: GuiComboBox(), get parameters by reference and return result value
+* REDESIGNED: GuiCheckBox(), get parameters by reference and return result value
+* REDESIGNED: GuiSlider(), get parameters by reference and return result value
+* REDESIGNED: GuiSliderBar(), get parameters by reference and return result value
+* REDESIGNED: GuiProgressBar(), get parameters by reference and return result value
+* REDESIGNED: GuiListView(), get parameters by reference and return result value
+* REDESIGNED: GuiColorPicker(), get parameters by reference and return result value
+* REDESIGNED: GuiColorPanel(), get parameters by reference and return result value
+* REDESIGNED: GuiColorBarAlpha(), get parameters by reference and return result value
+* REDESIGNED: GuiColorBarHue(), get parameters by reference and return result value
+* REDESIGNED: GuiGrid(), get parameters by reference and return result value
+* REDESIGNED: GuiGrid(), added extra parameter
+* REDESIGNED: GuiListViewEx(), change parameters order
+* REDESIGNED: All controls return result as int value
+*
+* 3.6 (10-May-2023) ADDED: New icon: SAND_TIMER
+* ADDED: GuiLoadStyleFromMemory() (binary only)
+* REVIEWED: GuiScrollBar() horizontal movement key
+* REVIEWED: GuiTextBox() crash on cursor movement
+* REVIEWED: GuiTextBox(), additional inputs support
+* REVIEWED: GuiLabelButton(), avoid text cut
+* REVIEWED: GuiTextInputBox(), password input
+* REVIEWED: Local GetCodepointNext(), aligned with raylib
+* REDESIGNED: GuiSlider*()/GuiScrollBar() to support out-of-bounds
+*
+* 3.5 (20-Apr-2023) ADDED: GuiTabBar(), based on GuiToggle()
+* ADDED: Helper functions to split text in separate lines
+* ADDED: Multiple new icons, useful for code editing tools
+* REMOVED: Unneeded icon editing functions
+* REMOVED: GuiTextBoxMulti(), very limited and broken
+* REMOVED: MeasureTextEx() dependency, logic directly implemented
+* REMOVED: DrawTextEx() dependency, logic directly implemented
+* REVIEWED: GuiScrollBar(), improve mouse-click behaviour
+* REVIEWED: Library header info, more info, better organized
+* REDESIGNED: GuiTextBox() to support cursor movement
+* REDESIGNED: GuiDrawText() to divide drawing by lines
+*
* 3.2 (22-May-2022) RENAMED: Some enum values, for unification, avoiding prefixes
* REMOVED: GuiScrollBar(), only internal
* REDESIGNED: GuiPanel() to support text parameter
@@ -120,6 +178,7 @@
* REDESIGNED: GuiColorBarAlpha() to support text parameter
* REDESIGNED: GuiColorBarHue() to support text parameter
* REDESIGNED: GuiTextInputBox() to support password
+*
* 3.1 (12-Jan-2022) REVIEWED: Default style for consistency (aligned with rGuiLayout v2.5 tool)
* REVIEWED: GuiLoadStyle() to support compressed font atlas image data and unload previous textures
* REVIEWED: External icons usage logic
@@ -127,10 +186,12 @@
* RENAMED: Multiple controls properties definitions to prepend RAYGUI_
* RENAMED: RICON_ references to RAYGUI_ICON_ for library consistency
* Projects updated and multiple tweaks
+*
* 3.0 (04-Nov-2021) Integrated ricons data to avoid external file
* REDESIGNED: GuiTextBoxMulti()
* REMOVED: GuiImageButton*()
* Multiple minor tweaks and bugs corrected
+*
* 2.9 (17-Mar-2021) REMOVED: Tooltip API
* 2.8 (03-May-2020) Centralized rectangles drawing to GuiDrawRectangle()
* 2.7 (20-Feb-2020) ADDED: Possible tooltips API
@@ -140,6 +201,7 @@
* Replaced property INNER_PADDING by TEXT_PADDING, renamed some properties
* ADDED: 8 new custom styles ready to use
* Multiple minor tweaks and bugs corrected
+*
* 2.5 (28-May-2019) Implemented extended GuiTextBox(), GuiValueBox(), GuiSpinner()
* 2.3 (29-Apr-2019) ADDED: rIcons auxiliar library and support for it, multiple controls reviewed
* Refactor all controls drawing mechanism to use control state
@@ -158,9 +220,13 @@
* 0.9 (07-Mar-2016) Reviewed and tested by Albert Martos, Ian Eito, Sergio Martinez and Ramon Santamaria.
* 0.8 (27-Aug-2015) Initial release. Implemented by Kevin Gato, Daniel Nicolás and Ramon Santamaria.
*
+* DEPENDENCIES:
+* raylib 4.5 Inputs reading (keyboard/mouse), shapes drawing, font loading and text drawing
+*
+* By default raygui depends on raylib mostly for the inputs and the drawing functionality but that dependency can be disabled
+* with the config flag RAYGUI_STANDALONE. In that case is up to the user to provide another backend to cover library needs.
*
* CONTRIBUTORS:
-*
* Ramon Santamaria: Supervision, review, redesign, update and maintenance
* Vlad Adrian: Complete rewrite of GuiTextBox() to support extended features (2019)
* Sergio Martinez: Review, testing (2015) and redesign of multiple controls (2018)
@@ -174,7 +240,7 @@
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -196,7 +262,10 @@
#ifndef RAYGUI_H
#define RAYGUI_H
-#define RAYGUI_VERSION "3.2"
+#define RAYGUI_VERSION_MAJOR 4
+#define RAYGUI_VERSION_MINOR 0
+#define RAYGUI_VERSION_PATCH 0
+#define RAYGUI_VERSION "4.0-dev"
#if !defined(RAYGUI_STANDALONE)
#include "raylib.h"
@@ -291,6 +360,15 @@
int format; // Data format (PixelFormat type)
} Texture2D;
+ // Image, pixel data stored in CPU memory (RAM)
+ typedef struct Image {
+ void *data; // Image raw data
+ int width; // Image base width
+ int height; // Image base height
+ int mipmaps; // Mipmap levels, 1 by default
+ int format; // Data format (PixelFormat type)
+ } Image;
+
// GlyphInfo, font characters glyphs info
typedef struct GlyphInfo {
int value; // Character value (Unicode)
@@ -304,10 +382,11 @@
// It should be redesigned to be provided by user
typedef struct Font {
int baseSize; // Base size (default chars height)
- int glyphCount; // Number of characters
- Texture2D texture; // Characters texture atlas
- Rectangle *recs; // Characters rectangles in texture
- GlyphInfo *chars; // Characters info data
+ int glyphCount; // Number of glyph characters
+ int glyphPadding; // Padding around the glyph characters
+ Texture2D texture; // Texture atlas containing the glyphs
+ Rectangle *recs; // Rectangles in texture for the glyphs
+ GlyphInfo *glyphs; // Glyphs info data
} Font;
#endif
@@ -442,6 +521,9 @@ typedef enum {
typedef enum {
TEXT_INNER_PADDING = 16, // TextBox/TextBoxMulti/ValueBox/Spinner inner text padding
TEXT_LINES_SPACING, // TextBoxMulti lines separation
+ TEXT_ALIGNMENT_VERTICAL, // TextBoxMulti vertical alignment: 0-CENTERED, 1-UP, 2-DOWN
+ TEXT_MULTILINE, // TextBox supports multiple lines
+ TEXT_WRAP_MODE // TextBox wrap mode for multiline: 0-NO_WRAP, 1-CHAR_WRAP, 2-WORD_WRAP
} GuiTextBoxProperty;
// Spinner
@@ -484,78 +566,86 @@ extern "C" { // Prevents name mangling of functions
#endif
// Global gui state control functions
-RAYGUIAPI void GuiEnable(void); // Enable gui controls (global state)
-RAYGUIAPI void GuiDisable(void); // Disable gui controls (global state)
-RAYGUIAPI void GuiLock(void); // Lock gui controls (global state)
-RAYGUIAPI void GuiUnlock(void); // Unlock gui controls (global state)
-RAYGUIAPI bool GuiIsLocked(void); // Check if gui is locked (global state)
-RAYGUIAPI void GuiFade(float alpha); // Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
-RAYGUIAPI void GuiSetState(int state); // Set gui state (global state)
-RAYGUIAPI int GuiGetState(void); // Get gui state (global state)
+RAYGUIAPI void GuiEnable(void); // Enable gui controls (global state)
+RAYGUIAPI void GuiDisable(void); // Disable gui controls (global state)
+RAYGUIAPI void GuiLock(void); // Lock gui controls (global state)
+RAYGUIAPI void GuiUnlock(void); // Unlock gui controls (global state)
+RAYGUIAPI bool GuiIsLocked(void); // Check if gui is locked (global state)
+RAYGUIAPI void GuiFade(float alpha); // Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
+RAYGUIAPI void GuiSetState(int state); // Set gui state (global state)
+RAYGUIAPI int GuiGetState(void); // Get gui state (global state)
// Font set/get functions
-RAYGUIAPI void GuiSetFont(Font font); // Set gui custom font (global state)
-RAYGUIAPI Font GuiGetFont(void); // Get gui custom font (global state)
+RAYGUIAPI void GuiSetFont(Font font); // Set gui custom font (global state)
+RAYGUIAPI Font GuiGetFont(void); // Get gui custom font (global state)
// Style set/get functions
-RAYGUIAPI void GuiSetStyle(int control, int property, int value); // Set one style property
-RAYGUIAPI int GuiGetStyle(int control, int property); // Get one style property
-
-// Container/separator controls, useful for controls organization
-RAYGUIAPI bool GuiWindowBox(Rectangle bounds, const char *title); // Window Box control, shows a window that can be closed
-RAYGUIAPI void GuiGroupBox(Rectangle bounds, const char *text); // Group Box control with text name
-RAYGUIAPI void GuiLine(Rectangle bounds, const char *text); // Line separator control, could contain text
-RAYGUIAPI void GuiPanel(Rectangle bounds, const char *text); // Panel control, useful to group controls
-RAYGUIAPI Rectangle GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content, Vector2 *scroll); // Scroll Panel control
-
-// Basic controls set
-RAYGUIAPI void GuiLabel(Rectangle bounds, const char *text); // Label control, shows text
-RAYGUIAPI bool GuiButton(Rectangle bounds, const char *text); // Button control, returns true when clicked
-RAYGUIAPI bool GuiLabelButton(Rectangle bounds, const char *text); // Label button control, show true when clicked
-RAYGUIAPI bool GuiToggle(Rectangle bounds, const char *text, bool active); // Toggle Button control, returns true when active
-RAYGUIAPI int GuiToggleGroup(Rectangle bounds, const char *text, int active); // Toggle Group control, returns active toggle index
-RAYGUIAPI bool GuiCheckBox(Rectangle bounds, const char *text, bool checked); // Check Box control, returns true when active
-RAYGUIAPI int GuiComboBox(Rectangle bounds, const char *text, int active); // Combo Box control, returns selected item index
-RAYGUIAPI bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMode); // Dropdown Box control, returns selected item
-RAYGUIAPI bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode); // Spinner control, returns selected value
-RAYGUIAPI bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode); // Value Box control, updates input text with numbers
-RAYGUIAPI bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode); // Text Box control, updates input text
-RAYGUIAPI bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode); // Text Box control with multiple lines
-RAYGUIAPI float GuiSlider(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Slider control, returns selected value
-RAYGUIAPI float GuiSliderBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Slider Bar control, returns selected value
-RAYGUIAPI float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Progress Bar control, shows current progress value
-RAYGUIAPI void GuiStatusBar(Rectangle bounds, const char *text); // Status Bar control, shows info text
-RAYGUIAPI void GuiDummyRec(Rectangle bounds, const char *text); // Dummy control for placeholders
-RAYGUIAPI Vector2 GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs); // Grid control, returns mouse cell position
-
-// Advance controls set
-RAYGUIAPI int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active); // List View control, returns selected list item index
-RAYGUIAPI int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active); // List View with extended parameters
-RAYGUIAPI int GuiMessageBox(Rectangle bounds, const char *title, const char *message, const char *buttons); // Message Box control, displays a message
-RAYGUIAPI int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text, int textMaxSize, int *secretViewActive); // Text Input Box control, ask for text, supports secret
-RAYGUIAPI Color GuiColorPicker(Rectangle bounds, const char *text, Color color); // Color Picker control (multiple color controls)
-RAYGUIAPI Color GuiColorPanel(Rectangle bounds, const char *text, Color color); // Color Panel control
-RAYGUIAPI float GuiColorBarAlpha(Rectangle bounds, const char *text, float alpha); // Color Bar Alpha control
-RAYGUIAPI float GuiColorBarHue(Rectangle bounds, const char *text, float value); // Color Bar Hue control
+RAYGUIAPI void GuiSetStyle(int control, int property, int value); // Set one style property
+RAYGUIAPI int GuiGetStyle(int control, int property); // Get one style property
// Styles loading functions
RAYGUIAPI void GuiLoadStyle(const char *fileName); // Load style file over global style variable (.rgs)
RAYGUIAPI void GuiLoadStyleDefault(void); // Load style default over global style
+// Tooltips management functions
+RAYGUIAPI void GuiEnableTooltip(void); // Enable gui tooltips (global state)
+RAYGUIAPI void GuiDisableTooltip(void); // Disable gui tooltips (global state)
+RAYGUIAPI void GuiSetTooltip(const char *tooltip); // Set tooltip string
+
// Icons functionality
RAYGUIAPI const char *GuiIconText(int iconId, const char *text); // Get text with icon id prepended (if supported)
+#if !defined(RAYGUI_NO_ICONS)
+RAYGUIAPI void GuiSetIconScale(int scale); // Set default icon drawing size
+RAYGUIAPI unsigned int *GuiGetIcons(void); // Get raygui icons data pointer
+RAYGUIAPI char **GuiLoadIcons(const char *fileName, bool loadIconsName); // Load raygui icons file (.rgi) into internal icons data
+RAYGUIAPI void GuiDrawIcon(int iconId, int posX, int posY, int pixelSize, Color color); // Draw icon using pixel size at specified position
+#endif
+
+
+// Controls
+//----------------------------------------------------------------------------------------------------------
+// Container/separator controls, useful for controls organization
+RAYGUIAPI int GuiWindowBox(Rectangle bounds, const char *title); // Window Box control, shows a window that can be closed
+RAYGUIAPI int GuiGroupBox(Rectangle bounds, const char *text); // Group Box control with text name
+RAYGUIAPI int GuiLine(Rectangle bounds, const char *text); // Line separator control, could contain text
+RAYGUIAPI int GuiPanel(Rectangle bounds, const char *text); // Panel control, useful to group controls
+RAYGUIAPI int GuiTabBar(Rectangle bounds, const char **text, int count, int *active); // Tab Bar control, returns TAB to be closed or -1
+RAYGUIAPI int GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content, Vector2 *scroll, Rectangle *view); // Scroll Panel control
+
+// Basic controls set
+RAYGUIAPI int GuiLabel(Rectangle bounds, const char *text); // Label control, shows text
+RAYGUIAPI int GuiButton(Rectangle bounds, const char *text); // Button control, returns true when clicked
+RAYGUIAPI int GuiLabelButton(Rectangle bounds, const char *text); // Label button control, show true when clicked
+RAYGUIAPI int GuiToggle(Rectangle bounds, const char *text, bool *active); // Toggle Button control, returns true when active
+RAYGUIAPI int GuiToggleGroup(Rectangle bounds, const char *text, int *active); // Toggle Group control, returns active toggle index
+RAYGUIAPI int GuiCheckBox(Rectangle bounds, const char *text, bool *checked); // Check Box control, returns true when active
+RAYGUIAPI int GuiComboBox(Rectangle bounds, const char *text, int *active); // Combo Box control, returns selected item index
+
+RAYGUIAPI int GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMode); // Dropdown Box control, returns selected item
+RAYGUIAPI int GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode); // Spinner control, returns selected value
+RAYGUIAPI int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode); // Value Box control, updates input text with numbers
+RAYGUIAPI int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode); // Text Box control, updates input text
+
+RAYGUIAPI int GuiSlider(Rectangle bounds, const char *textLeft, const char *textRight, float *value, float minValue, float maxValue); // Slider control, returns selected value
+RAYGUIAPI int GuiSliderBar(Rectangle bounds, const char *textLeft, const char *textRight, float *value, float minValue, float maxValue); // Slider Bar control, returns selected value
+RAYGUIAPI int GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRight, float *value, float minValue, float maxValue); // Progress Bar control, shows current progress value
+RAYGUIAPI int GuiStatusBar(Rectangle bounds, const char *text); // Status Bar control, shows info text
+RAYGUIAPI int GuiDummyRec(Rectangle bounds, const char *text); // Dummy control for placeholders
+RAYGUIAPI int GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs, Vector2 *mouseCell); // Grid control, returns mouse cell position
+
+// Advance controls set
+RAYGUIAPI int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int *active); // List View control, returns selected list item index
+RAYGUIAPI int GuiListViewEx(Rectangle bounds, const char **text, int count, int *scrollIndex, int *active, int *focus); // List View with extended parameters
+RAYGUIAPI int GuiMessageBox(Rectangle bounds, const char *title, const char *message, const char *buttons); // Message Box control, displays a message
+RAYGUIAPI int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text, int textMaxSize, bool *secretViewActive); // Text Input Box control, ask for text, supports secret
+RAYGUIAPI int GuiColorPicker(Rectangle bounds, const char *text, Color *color); // Color Picker control (multiple color controls)
+RAYGUIAPI int GuiColorPanel(Rectangle bounds, const char *text, Color *color); // Color Panel control
+RAYGUIAPI int GuiColorBarAlpha(Rectangle bounds, const char *text, float *alpha); // Color Bar Alpha control
+RAYGUIAPI int GuiColorBarHue(Rectangle bounds, const char *text, float *value); // Color Bar Hue control
+//----------------------------------------------------------------------------------------------------------
+
#if !defined(RAYGUI_NO_ICONS)
-RAYGUIAPI void GuiDrawIcon(int iconId, int posX, int posY, int pixelSize, Color color);
-
-RAYGUIAPI unsigned int *GuiGetIcons(void); // Get full icons data pointer
-RAYGUIAPI unsigned int *GuiGetIconData(int iconId); // Get icon bit data
-RAYGUIAPI void GuiSetIconData(int iconId, unsigned int *data); // Set icon bit data
-RAYGUIAPI void GuiSetIconScale(unsigned int scale); // Set icon scale (1 by default)
-
-RAYGUIAPI void GuiSetIconPixel(int iconId, int x, int y); // Set icon pixel value
-RAYGUIAPI void GuiClearIconPixel(int iconId, int x, int y); // Clear icon pixel value
-RAYGUIAPI bool GuiCheckIconPixel(int iconId, int x, int y); // Check icon pixel value
#if !defined(RAYGUI_CUSTOM_ICONS)
//----------------------------------------------------------------------------------
@@ -768,20 +858,20 @@ typedef enum {
ICON_FILE_NEW = 203,
ICON_FOLDER_ADD = 204,
ICON_ALARM = 205,
- ICON_206 = 206,
- ICON_207 = 207,
- ICON_208 = 208,
- ICON_209 = 209,
- ICON_210 = 210,
- ICON_211 = 211,
- ICON_212 = 212,
- ICON_213 = 213,
- ICON_214 = 214,
- ICON_215 = 215,
- ICON_216 = 216,
- ICON_217 = 217,
- ICON_218 = 218,
- ICON_219 = 219,
+ ICON_CPU = 206,
+ ICON_ROM = 207,
+ ICON_STEP_OVER = 208,
+ ICON_STEP_INTO = 209,
+ ICON_STEP_OUT = 210,
+ ICON_RESTART = 211,
+ ICON_BREAKPOINT_ON = 212,
+ ICON_BREAKPOINT_OFF = 213,
+ ICON_BURGER_MENU = 214,
+ ICON_CASE_SENSITIVE = 215,
+ ICON_REG_EXP = 216,
+ ICON_FOLDER = 217,
+ ICON_FILE = 218,
+ ICON_SAND_TIMER = 219,
ICON_220 = 220,
ICON_221 = 221,
ICON_222 = 222,
@@ -839,7 +929,7 @@ typedef enum {
#include // Required for: FILE, fopen(), fclose(), fprintf(), feof(), fscanf(), vsprintf() [GuiLoadStyle(), GuiLoadIcons()]
#include // Required for: malloc(), calloc(), free() [GuiLoadStyle(), GuiLoadIcons()]
-#include // Required for: strlen() [GuiTextBox(), GuiTextBoxMulti(), GuiValueBox()], memset(), memcpy()
+#include // Required for: strlen() [GuiTextBox(), GuiValueBox()], memset(), memcpy()
#include // Required for: va_list, va_start(), vfprintf(), va_end() [TextFormat()]
#include // Required for: roundf() [GuiColorPicker()]
@@ -849,6 +939,11 @@ typedef enum {
#define RAYGUI_CLITERAL(name) (name)
#endif
+// Check if two rectangles are equal, used to validate a slider bounds as an id
+#ifndef CHECK_BOUNDS_ID
+ #define CHECK_BOUNDS_ID(src, dst) ((src.x == dst.x) && (src.y == dst.y) && (src.width == dst.width) && (src.height == dst.height))
+#endif
+
#if !defined(RAYGUI_NO_ICONS) && !defined(RAYGUI_CUSTOM_ICONS)
// Embedded icons, no external file provided
@@ -875,264 +970,267 @@ typedef enum {
// guiIcons size is by default: 256*(16*16/32) = 2048*4 = 8192 bytes = 8 KB
//----------------------------------------------------------------------------------
static unsigned int guiIcons[RAYGUI_ICON_MAX_ICONS*RAYGUI_ICON_DATA_ELEMENTS] = {
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_NONE
- 0x3ff80000, 0x2f082008, 0x2042207e, 0x40027fc2, 0x40024002, 0x40024002, 0x40024002, 0x00007ffe, // ICON_FOLDER_FILE_OPEN
- 0x3ffe0000, 0x44226422, 0x400247e2, 0x5ffa4002, 0x57ea500a, 0x500a500a, 0x40025ffa, 0x00007ffe, // ICON_FILE_SAVE_CLASSIC
- 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024002, 0x44424282, 0x793e4102, 0x00000100, // ICON_FOLDER_OPEN
- 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024102, 0x44424102, 0x793e4282, 0x00000000, // ICON_FOLDER_SAVE
- 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x24442284, 0x21042104, 0x20042104, 0x00003ffc, // ICON_FILE_OPEN
- 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x21042104, 0x22842444, 0x20042104, 0x00003ffc, // ICON_FILE_SAVE
- 0x3ff00000, 0x201c2010, 0x00042004, 0x20041004, 0x20844784, 0x00841384, 0x20042784, 0x00003ffc, // ICON_FILE_EXPORT
- 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x22042204, 0x22042f84, 0x20042204, 0x00003ffc, // ICON_FILE_ADD
- 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x25042884, 0x25042204, 0x20042884, 0x00003ffc, // ICON_FILE_DELETE
- 0x3ff00000, 0x201c2010, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // ICON_FILETYPE_TEXT
- 0x3ff00000, 0x201c2010, 0x27042004, 0x244424c4, 0x26442444, 0x20642664, 0x20042004, 0x00003ffc, // ICON_FILETYPE_AUDIO
- 0x3ff00000, 0x201c2010, 0x26042604, 0x20042004, 0x35442884, 0x2414222c, 0x20042004, 0x00003ffc, // ICON_FILETYPE_IMAGE
- 0x3ff00000, 0x201c2010, 0x20c42004, 0x22442144, 0x22442444, 0x20c42144, 0x20042004, 0x00003ffc, // ICON_FILETYPE_PLAY
- 0x3ff00000, 0x3ffc2ff0, 0x3f3c2ff4, 0x3dbc2eb4, 0x3dbc2bb4, 0x3f3c2eb4, 0x3ffc2ff4, 0x00002ff4, // ICON_FILETYPE_VIDEO
- 0x3ff00000, 0x201c2010, 0x21842184, 0x21842004, 0x21842184, 0x21842184, 0x20042184, 0x00003ffc, // ICON_FILETYPE_INFO
- 0x0ff00000, 0x381c0810, 0x28042804, 0x28042804, 0x28042804, 0x28042804, 0x20102ffc, 0x00003ff0, // ICON_FILE_COPY
- 0x00000000, 0x701c0000, 0x079c1e14, 0x55a000f0, 0x079c00f0, 0x701c1e14, 0x00000000, 0x00000000, // ICON_FILE_CUT
- 0x01c00000, 0x13e41bec, 0x3f841004, 0x204420c4, 0x20442044, 0x20442044, 0x207c2044, 0x00003fc0, // ICON_FILE_PASTE
- 0x00000000, 0x3aa00fe0, 0x2abc2aa0, 0x2aa42aa4, 0x20042aa4, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_CURSOR_HAND
- 0x00000000, 0x003c000c, 0x030800c8, 0x30100c10, 0x10202020, 0x04400840, 0x01800280, 0x00000000, // ICON_CURSOR_POINTER
- 0x00000000, 0x00180000, 0x01f00078, 0x03e007f0, 0x07c003e0, 0x04000e40, 0x00000000, 0x00000000, // ICON_CURSOR_CLASSIC
- 0x00000000, 0x04000000, 0x11000a00, 0x04400a80, 0x01100220, 0x00580088, 0x00000038, 0x00000000, // ICON_PENCIL
- 0x04000000, 0x15000a00, 0x50402880, 0x14102820, 0x05040a08, 0x015c028c, 0x007c00bc, 0x00000000, // ICON_PENCIL_BIG
- 0x01c00000, 0x01400140, 0x01400140, 0x0ff80140, 0x0ff80808, 0x0aa80808, 0x0aa80aa8, 0x00000ff8, // ICON_BRUSH_CLASSIC
- 0x1ffc0000, 0x5ffc7ffe, 0x40004000, 0x00807f80, 0x01c001c0, 0x01c001c0, 0x01c001c0, 0x00000080, // ICON_BRUSH_PAINTER
- 0x00000000, 0x00800000, 0x01c00080, 0x03e001c0, 0x07f003e0, 0x036006f0, 0x000001c0, 0x00000000, // ICON_WATER_DROP
- 0x00000000, 0x3e003800, 0x1f803f80, 0x0c201e40, 0x02080c10, 0x00840104, 0x00380044, 0x00000000, // ICON_COLOR_PICKER
- 0x00000000, 0x07800300, 0x1fe00fc0, 0x3f883fd0, 0x0e021f04, 0x02040402, 0x00f00108, 0x00000000, // ICON_RUBBER
- 0x00c00000, 0x02800140, 0x08200440, 0x20081010, 0x2ffe3004, 0x03f807fc, 0x00e001f0, 0x00000040, // ICON_COLOR_BUCKET
- 0x00000000, 0x21843ffc, 0x01800180, 0x01800180, 0x01800180, 0x01800180, 0x03c00180, 0x00000000, // ICON_TEXT_T
- 0x00800000, 0x01400180, 0x06200340, 0x0c100620, 0x1ff80c10, 0x380c1808, 0x70067004, 0x0000f80f, // ICON_TEXT_A
- 0x78000000, 0x50004000, 0x00004800, 0x03c003c0, 0x03c003c0, 0x00100000, 0x0002000a, 0x0000000e, // ICON_SCALE
- 0x75560000, 0x5e004002, 0x54001002, 0x41001202, 0x408200fe, 0x40820082, 0x40820082, 0x00006afe, // ICON_RESIZE
- 0x00000000, 0x3f003f00, 0x3f003f00, 0x3f003f00, 0x00400080, 0x001c0020, 0x001c001c, 0x00000000, // ICON_FILTER_POINT
- 0x6d800000, 0x00004080, 0x40804080, 0x40800000, 0x00406d80, 0x001c0020, 0x001c001c, 0x00000000, // ICON_FILTER_BILINEAR
- 0x40080000, 0x1ffe2008, 0x14081008, 0x11081208, 0x10481088, 0x10081028, 0x10047ff8, 0x00001002, // ICON_CROP
- 0x00100000, 0x3ffc0010, 0x2ab03550, 0x22b02550, 0x20b02150, 0x20302050, 0x2000fff0, 0x00002000, // ICON_CROP_ALPHA
- 0x40000000, 0x1ff82000, 0x04082808, 0x01082208, 0x00482088, 0x00182028, 0x35542008, 0x00000002, // ICON_SQUARE_TOGGLE
- 0x00000000, 0x02800280, 0x06c006c0, 0x0ea00ee0, 0x1e901eb0, 0x3e883e98, 0x7efc7e8c, 0x00000000, // ICON_SYMMETRY
- 0x01000000, 0x05600100, 0x1d480d50, 0x7d423d44, 0x3d447d42, 0x0d501d48, 0x01000560, 0x00000100, // ICON_SYMMETRY_HORIZONTAL
- 0x01800000, 0x04200240, 0x10080810, 0x00001ff8, 0x00007ffe, 0x0ff01ff8, 0x03c007e0, 0x00000180, // ICON_SYMMETRY_VERTICAL
- 0x00000000, 0x010800f0, 0x02040204, 0x02040204, 0x07f00308, 0x1c000e00, 0x30003800, 0x00000000, // ICON_LENS
- 0x00000000, 0x061803f0, 0x08240c0c, 0x08040814, 0x0c0c0804, 0x23f01618, 0x18002400, 0x00000000, // ICON_LENS_BIG
- 0x00000000, 0x00000000, 0x1c7007c0, 0x638e3398, 0x1c703398, 0x000007c0, 0x00000000, 0x00000000, // ICON_EYE_ON
- 0x00000000, 0x10002000, 0x04700fc0, 0x610e3218, 0x1c703098, 0x001007a0, 0x00000008, 0x00000000, // ICON_EYE_OFF
- 0x00000000, 0x00007ffc, 0x40047ffc, 0x10102008, 0x04400820, 0x02800280, 0x02800280, 0x00000100, // ICON_FILTER_TOP
- 0x00000000, 0x40027ffe, 0x10082004, 0x04200810, 0x02400240, 0x02400240, 0x01400240, 0x000000c0, // ICON_FILTER
- 0x00800000, 0x00800080, 0x00000080, 0x3c9e0000, 0x00000000, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_POINT
- 0x00800000, 0x00800080, 0x00800080, 0x3f7e01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_SMALL
- 0x00800000, 0x00800080, 0x03e00080, 0x3e3e0220, 0x03e00220, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_BIG
- 0x01000000, 0x04400280, 0x01000100, 0x43842008, 0x43849ab2, 0x01002008, 0x04400100, 0x01000280, // ICON_TARGET_MOVE
- 0x01000000, 0x04400280, 0x01000100, 0x41042108, 0x41049ff2, 0x01002108, 0x04400100, 0x01000280, // ICON_CURSOR_MOVE
- 0x781e0000, 0x500a4002, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x4002500a, 0x0000781e, // ICON_CURSOR_SCALE
- 0x00000000, 0x20003c00, 0x24002800, 0x01000200, 0x00400080, 0x00140024, 0x003c0004, 0x00000000, // ICON_CURSOR_SCALE_RIGHT
- 0x00000000, 0x0004003c, 0x00240014, 0x00800040, 0x02000100, 0x28002400, 0x3c002000, 0x00000000, // ICON_CURSOR_SCALE_LEFT
- 0x00000000, 0x00100020, 0x10101fc8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // ICON_UNDO
- 0x00000000, 0x08000400, 0x080813f8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // ICON_REDO
- 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3f902020, 0x00400020, 0x00000000, // ICON_REREDO
- 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3fc82010, 0x00200010, 0x00000000, // ICON_MUTATE
- 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18101020, 0x00100fc8, 0x00000020, // ICON_ROTATE
- 0x00000000, 0x04000200, 0x240429fc, 0x20042204, 0x20442004, 0x3f942024, 0x00400020, 0x00000000, // ICON_REPEAT
- 0x00000000, 0x20001000, 0x22104c0e, 0x00801120, 0x11200040, 0x4c0e2210, 0x10002000, 0x00000000, // ICON_SHUFFLE
- 0x7ffe0000, 0x50024002, 0x44024802, 0x41024202, 0x40424082, 0x40124022, 0x4002400a, 0x00007ffe, // ICON_EMPTYBOX
- 0x00800000, 0x03e00080, 0x08080490, 0x3c9e0808, 0x08080808, 0x03e00490, 0x00800080, 0x00000000, // ICON_TARGET
- 0x00800000, 0x00800080, 0x00800080, 0x3ffe01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_SMALL_FILL
- 0x00800000, 0x00800080, 0x03e00080, 0x3ffe03e0, 0x03e003e0, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_BIG_FILL
- 0x01000000, 0x07c00380, 0x01000100, 0x638c2008, 0x638cfbbe, 0x01002008, 0x07c00100, 0x01000380, // ICON_TARGET_MOVE_FILL
- 0x01000000, 0x07c00380, 0x01000100, 0x610c2108, 0x610cfffe, 0x01002108, 0x07c00100, 0x01000380, // ICON_CURSOR_MOVE_FILL
- 0x781e0000, 0x6006700e, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x700e6006, 0x0000781e, // ICON_CURSOR_SCALE_FILL
- 0x00000000, 0x38003c00, 0x24003000, 0x01000200, 0x00400080, 0x000c0024, 0x003c001c, 0x00000000, // ICON_CURSOR_SCALE_RIGHT_FILL
- 0x00000000, 0x001c003c, 0x0024000c, 0x00800040, 0x02000100, 0x30002400, 0x3c003800, 0x00000000, // ICON_CURSOR_SCALE_LEFT_FILL
- 0x00000000, 0x00300020, 0x10301ff8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // ICON_UNDO_FILL
- 0x00000000, 0x0c000400, 0x0c081ff8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // ICON_REDO_FILL
- 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3ff02060, 0x00400060, 0x00000000, // ICON_REREDO_FILL
- 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3ff82030, 0x00200030, 0x00000000, // ICON_MUTATE_FILL
- 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18301020, 0x00300ff8, 0x00000020, // ICON_ROTATE_FILL
- 0x00000000, 0x06000200, 0x26042ffc, 0x20042204, 0x20442004, 0x3ff42064, 0x00400060, 0x00000000, // ICON_REPEAT_FILL
- 0x00000000, 0x30001000, 0x32107c0e, 0x00801120, 0x11200040, 0x7c0e3210, 0x10003000, 0x00000000, // ICON_SHUFFLE_FILL
- 0x00000000, 0x30043ffc, 0x24042804, 0x21042204, 0x20442084, 0x20142024, 0x3ffc200c, 0x00000000, // ICON_EMPTYBOX_SMALL
- 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX
- 0x00000000, 0x23c43ffc, 0x23c423c4, 0x200423c4, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_TOP
- 0x00000000, 0x3e043ffc, 0x3e043e04, 0x20043e04, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_TOP_RIGHT
- 0x00000000, 0x20043ffc, 0x20042004, 0x3e043e04, 0x3e043e04, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_RIGHT
- 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x3e042004, 0x3e043e04, 0x3ffc3e04, 0x00000000, // ICON_BOX_BOTTOM_RIGHT
- 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x23c42004, 0x23c423c4, 0x3ffc23c4, 0x00000000, // ICON_BOX_BOTTOM
- 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x207c2004, 0x207c207c, 0x3ffc207c, 0x00000000, // ICON_BOX_BOTTOM_LEFT
- 0x00000000, 0x20043ffc, 0x20042004, 0x207c207c, 0x207c207c, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_LEFT
- 0x00000000, 0x207c3ffc, 0x207c207c, 0x2004207c, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_TOP_LEFT
- 0x00000000, 0x20043ffc, 0x20042004, 0x23c423c4, 0x23c423c4, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_CENTER
- 0x7ffe0000, 0x40024002, 0x47e24182, 0x4ff247e2, 0x47e24ff2, 0x418247e2, 0x40024002, 0x00007ffe, // ICON_BOX_CIRCLE_MASK
- 0x7fff0000, 0x40014001, 0x40014001, 0x49555ddd, 0x4945495d, 0x400149c5, 0x40014001, 0x00007fff, // ICON_POT
- 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x404e40ce, 0x48125432, 0x4006540e, 0x00007ffe, // ICON_ALPHA_MULTIPLY
- 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x5c4e40ce, 0x44124432, 0x40065c0e, 0x00007ffe, // ICON_ALPHA_CLEAR
- 0x7ffe0000, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x00007ffe, // ICON_DITHERING
- 0x07fe0000, 0x1ffa0002, 0x7fea000a, 0x402a402a, 0x5b2a512a, 0x5128552a, 0x40205128, 0x00007fe0, // ICON_MIPMAPS
- 0x00000000, 0x1ff80000, 0x12481248, 0x12481ff8, 0x1ff81248, 0x12481248, 0x00001ff8, 0x00000000, // ICON_BOX_GRID
- 0x12480000, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x00001248, // ICON_GRID
- 0x00000000, 0x1c380000, 0x1c3817e8, 0x08100810, 0x08100810, 0x17e81c38, 0x00001c38, 0x00000000, // ICON_BOX_CORNERS_SMALL
- 0x700e0000, 0x700e5ffa, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x5ffa700e, 0x0000700e, // ICON_BOX_CORNERS_BIG
- 0x3f7e0000, 0x21422142, 0x21422142, 0x00003f7e, 0x21423f7e, 0x21422142, 0x3f7e2142, 0x00000000, // ICON_FOUR_BOXES
- 0x00000000, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x00000000, // ICON_GRID_FILL
- 0x7ffe0000, 0x7ffe7ffe, 0x77fe7000, 0x77fe77fe, 0x777e7700, 0x777e777e, 0x777e777e, 0x0000777e, // ICON_BOX_MULTISIZE
- 0x781e0000, 0x40024002, 0x00004002, 0x01800000, 0x00000180, 0x40020000, 0x40024002, 0x0000781e, // ICON_ZOOM_SMALL
- 0x781e0000, 0x40024002, 0x00004002, 0x03c003c0, 0x03c003c0, 0x40020000, 0x40024002, 0x0000781e, // ICON_ZOOM_MEDIUM
- 0x781e0000, 0x40024002, 0x07e04002, 0x07e007e0, 0x07e007e0, 0x400207e0, 0x40024002, 0x0000781e, // ICON_ZOOM_BIG
- 0x781e0000, 0x5ffa4002, 0x1ff85ffa, 0x1ff81ff8, 0x1ff81ff8, 0x5ffa1ff8, 0x40025ffa, 0x0000781e, // ICON_ZOOM_ALL
- 0x00000000, 0x2004381c, 0x00002004, 0x00000000, 0x00000000, 0x20040000, 0x381c2004, 0x00000000, // ICON_ZOOM_CENTER
- 0x00000000, 0x1db80000, 0x10081008, 0x10080000, 0x00001008, 0x10081008, 0x00001db8, 0x00000000, // ICON_BOX_DOTS_SMALL
- 0x35560000, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x35562002, 0x00000000, // ICON_BOX_DOTS_BIG
- 0x7ffe0000, 0x40024002, 0x48124ff2, 0x49924812, 0x48124992, 0x4ff24812, 0x40024002, 0x00007ffe, // ICON_BOX_CONCENTRIC
- 0x00000000, 0x10841ffc, 0x10841084, 0x1ffc1084, 0x10841084, 0x10841084, 0x00001ffc, 0x00000000, // ICON_BOX_GRID_BIG
- 0x00000000, 0x00000000, 0x10000000, 0x04000800, 0x01040200, 0x00500088, 0x00000020, 0x00000000, // ICON_OK_TICK
- 0x00000000, 0x10080000, 0x04200810, 0x01800240, 0x02400180, 0x08100420, 0x00001008, 0x00000000, // ICON_CROSS
- 0x00000000, 0x02000000, 0x00800100, 0x00200040, 0x00200010, 0x00800040, 0x02000100, 0x00000000, // ICON_ARROW_LEFT
- 0x00000000, 0x00400000, 0x01000080, 0x04000200, 0x04000800, 0x01000200, 0x00400080, 0x00000000, // ICON_ARROW_RIGHT
- 0x00000000, 0x00000000, 0x00000000, 0x08081004, 0x02200410, 0x00800140, 0x00000000, 0x00000000, // ICON_ARROW_DOWN
- 0x00000000, 0x00000000, 0x01400080, 0x04100220, 0x10040808, 0x00000000, 0x00000000, 0x00000000, // ICON_ARROW_UP
- 0x00000000, 0x02000000, 0x03800300, 0x03e003c0, 0x03e003f0, 0x038003c0, 0x02000300, 0x00000000, // ICON_ARROW_LEFT_FILL
- 0x00000000, 0x00400000, 0x01c000c0, 0x07c003c0, 0x07c00fc0, 0x01c003c0, 0x004000c0, 0x00000000, // ICON_ARROW_RIGHT_FILL
- 0x00000000, 0x00000000, 0x00000000, 0x0ff81ffc, 0x03e007f0, 0x008001c0, 0x00000000, 0x00000000, // ICON_ARROW_DOWN_FILL
- 0x00000000, 0x00000000, 0x01c00080, 0x07f003e0, 0x1ffc0ff8, 0x00000000, 0x00000000, 0x00000000, // ICON_ARROW_UP_FILL
- 0x00000000, 0x18a008c0, 0x32881290, 0x24822686, 0x26862482, 0x12903288, 0x08c018a0, 0x00000000, // ICON_AUDIO
- 0x00000000, 0x04800780, 0x004000c0, 0x662000f0, 0x08103c30, 0x130a0e18, 0x0000318e, 0x00000000, // ICON_FX
- 0x00000000, 0x00800000, 0x08880888, 0x2aaa0a8a, 0x0a8a2aaa, 0x08880888, 0x00000080, 0x00000000, // ICON_WAVE
- 0x00000000, 0x00600000, 0x01080090, 0x02040108, 0x42044204, 0x24022402, 0x00001800, 0x00000000, // ICON_WAVE_SINUS
- 0x00000000, 0x07f80000, 0x04080408, 0x04080408, 0x04080408, 0x7c0e0408, 0x00000000, 0x00000000, // ICON_WAVE_SQUARE
- 0x00000000, 0x00000000, 0x00a00040, 0x22084110, 0x08021404, 0x00000000, 0x00000000, 0x00000000, // ICON_WAVE_TRIANGULAR
- 0x00000000, 0x00000000, 0x04200000, 0x01800240, 0x02400180, 0x00000420, 0x00000000, 0x00000000, // ICON_CROSS_SMALL
- 0x00000000, 0x18380000, 0x12281428, 0x10a81128, 0x112810a8, 0x14281228, 0x00001838, 0x00000000, // ICON_PLAYER_PREVIOUS
- 0x00000000, 0x18000000, 0x11801600, 0x10181060, 0x10601018, 0x16001180, 0x00001800, 0x00000000, // ICON_PLAYER_PLAY_BACK
- 0x00000000, 0x00180000, 0x01880068, 0x18080608, 0x06081808, 0x00680188, 0x00000018, 0x00000000, // ICON_PLAYER_PLAY
- 0x00000000, 0x1e780000, 0x12481248, 0x12481248, 0x12481248, 0x12481248, 0x00001e78, 0x00000000, // ICON_PLAYER_PAUSE
- 0x00000000, 0x1ff80000, 0x10081008, 0x10081008, 0x10081008, 0x10081008, 0x00001ff8, 0x00000000, // ICON_PLAYER_STOP
- 0x00000000, 0x1c180000, 0x14481428, 0x15081488, 0x14881508, 0x14281448, 0x00001c18, 0x00000000, // ICON_PLAYER_NEXT
- 0x00000000, 0x03c00000, 0x08100420, 0x10081008, 0x10081008, 0x04200810, 0x000003c0, 0x00000000, // ICON_PLAYER_RECORD
- 0x00000000, 0x0c3007e0, 0x13c81818, 0x14281668, 0x14281428, 0x1c381c38, 0x08102244, 0x00000000, // ICON_MAGNET
- 0x07c00000, 0x08200820, 0x3ff80820, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // ICON_LOCK_CLOSE
- 0x07c00000, 0x08000800, 0x3ff80800, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // ICON_LOCK_OPEN
- 0x01c00000, 0x0c180770, 0x3086188c, 0x60832082, 0x60034781, 0x30062002, 0x0c18180c, 0x01c00770, // ICON_CLOCK
- 0x0a200000, 0x1b201b20, 0x04200e20, 0x04200420, 0x04700420, 0x0e700e70, 0x0e700e70, 0x04200e70, // ICON_TOOLS
- 0x01800000, 0x3bdc318c, 0x0ff01ff8, 0x7c3e1e78, 0x1e787c3e, 0x1ff80ff0, 0x318c3bdc, 0x00000180, // ICON_GEAR
- 0x01800000, 0x3ffc318c, 0x1c381ff8, 0x781e1818, 0x1818781e, 0x1ff81c38, 0x318c3ffc, 0x00000180, // ICON_GEAR_BIG
- 0x00000000, 0x08080ff8, 0x08081ffc, 0x0aa80aa8, 0x0aa80aa8, 0x0aa80aa8, 0x08080aa8, 0x00000ff8, // ICON_BIN
- 0x00000000, 0x00000000, 0x20043ffc, 0x08043f84, 0x04040f84, 0x04040784, 0x000007fc, 0x00000000, // ICON_HAND_POINTER
- 0x00000000, 0x24400400, 0x00001480, 0x6efe0e00, 0x00000e00, 0x24401480, 0x00000400, 0x00000000, // ICON_LASER
- 0x00000000, 0x03c00000, 0x08300460, 0x11181118, 0x11181118, 0x04600830, 0x000003c0, 0x00000000, // ICON_COIN
- 0x00000000, 0x10880080, 0x06c00810, 0x366c07e0, 0x07e00240, 0x00001768, 0x04200240, 0x00000000, // ICON_EXPLOSION
- 0x00000000, 0x3d280000, 0x2528252c, 0x3d282528, 0x05280528, 0x05e80528, 0x00000000, 0x00000000, // ICON_1UP
- 0x01800000, 0x03c003c0, 0x018003c0, 0x0ff007e0, 0x0bd00bd0, 0x0a500bd0, 0x02400240, 0x02400240, // ICON_PLAYER
- 0x01800000, 0x03c003c0, 0x118013c0, 0x03c81ff8, 0x07c003c8, 0x04400440, 0x0c080478, 0x00000000, // ICON_PLAYER_JUMP
- 0x3ff80000, 0x30183ff8, 0x30183018, 0x3ff83ff8, 0x03000300, 0x03c003c0, 0x03e00300, 0x000003e0, // ICON_KEY
- 0x3ff80000, 0x3ff83ff8, 0x33983ff8, 0x3ff83398, 0x3ff83ff8, 0x00000540, 0x0fe00aa0, 0x00000fe0, // ICON_DEMON
- 0x00000000, 0x0ff00000, 0x20041008, 0x25442004, 0x10082004, 0x06000bf0, 0x00000300, 0x00000000, // ICON_TEXT_POPUP
- 0x00000000, 0x11440000, 0x07f00be8, 0x1c1c0e38, 0x1c1c0c18, 0x07f00e38, 0x11440be8, 0x00000000, // ICON_GEAR_EX
- 0x00000000, 0x20080000, 0x0c601010, 0x07c00fe0, 0x07c007c0, 0x0c600fe0, 0x20081010, 0x00000000, // ICON_CRACK
- 0x00000000, 0x20080000, 0x0c601010, 0x04400fe0, 0x04405554, 0x0c600fe0, 0x20081010, 0x00000000, // ICON_CRACK_POINTS
- 0x00000000, 0x00800080, 0x01c001c0, 0x1ffc3ffe, 0x03e007f0, 0x07f003e0, 0x0c180770, 0x00000808, // ICON_STAR
- 0x0ff00000, 0x08180810, 0x08100818, 0x0a100810, 0x08180810, 0x08100818, 0x08100810, 0x00001ff8, // ICON_DOOR
- 0x0ff00000, 0x08100810, 0x08100810, 0x10100010, 0x4f902010, 0x10102010, 0x08100010, 0x00000ff0, // ICON_EXIT
- 0x00040000, 0x001f000e, 0x0ef40004, 0x12f41284, 0x0ef41214, 0x10040004, 0x7ffc3004, 0x10003000, // ICON_MODE_2D
- 0x78040000, 0x501f600e, 0x0ef44004, 0x12f41284, 0x0ef41284, 0x10140004, 0x7ffc300c, 0x10003000, // ICON_MODE_3D
- 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // ICON_CUBE
- 0x7fe00000, 0x5ff87ff0, 0x47fe4ffc, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // ICON_CUBE_FACE_TOP
- 0x7fe00000, 0x50386030, 0x47fe483c, 0x443e443e, 0x443e443e, 0x241e75fe, 0x0c06140e, 0x000007fe, // ICON_CUBE_FACE_LEFT
- 0x7fe00000, 0x50286030, 0x47fe4804, 0x47fe47fe, 0x47fe47fe, 0x27fe77fe, 0x0ffe17fe, 0x000007fe, // ICON_CUBE_FACE_FRONT
- 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x3ff27fe2, 0x0ffe1ffa, 0x000007fe, // ICON_CUBE_FACE_BOTTOM
- 0x7fe00000, 0x70286030, 0x7ffe7804, 0x7c227c02, 0x7c227c22, 0x3c127de2, 0x0c061c0a, 0x000007fe, // ICON_CUBE_FACE_RIGHT
- 0x7fe00000, 0x7fe87ff0, 0x7ffe7fe4, 0x7fe27fe2, 0x7fe27fe2, 0x24127fe2, 0x0c06140a, 0x000007fe, // ICON_CUBE_FACE_BACK
- 0x00000000, 0x2a0233fe, 0x22022602, 0x22022202, 0x2a022602, 0x00a033fe, 0x02080110, 0x00000000, // ICON_CAMERA
- 0x00000000, 0x200c3ffc, 0x000c000c, 0x3ffc000c, 0x30003000, 0x30003000, 0x3ffc3004, 0x00000000, // ICON_SPECIAL
- 0x00000000, 0x0022003e, 0x012201e2, 0x0100013e, 0x01000100, 0x79000100, 0x4f004900, 0x00007800, // ICON_LINK_NET
- 0x00000000, 0x44007c00, 0x45004600, 0x00627cbe, 0x00620022, 0x45007cbe, 0x44004600, 0x00007c00, // ICON_LINK_BOXES
- 0x00000000, 0x0044007c, 0x0010007c, 0x3f100010, 0x3f1021f0, 0x3f100010, 0x3f0021f0, 0x00000000, // ICON_LINK_MULTI
- 0x00000000, 0x0044007c, 0x00440044, 0x0010007c, 0x00100010, 0x44107c10, 0x440047f0, 0x00007c00, // ICON_LINK
- 0x00000000, 0x0044007c, 0x00440044, 0x0000007c, 0x00000010, 0x44007c10, 0x44004550, 0x00007c00, // ICON_LINK_BROKE
- 0x02a00000, 0x22a43ffc, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // ICON_TEXT_NOTES
- 0x3ffc0000, 0x20042004, 0x245e27c4, 0x27c42444, 0x2004201e, 0x201e2004, 0x20042004, 0x00003ffc, // ICON_NOTEBOOK
- 0x00000000, 0x07e00000, 0x04200420, 0x24243ffc, 0x24242424, 0x24242424, 0x3ffc2424, 0x00000000, // ICON_SUITCASE
- 0x00000000, 0x0fe00000, 0x08200820, 0x40047ffc, 0x7ffc5554, 0x40045554, 0x7ffc4004, 0x00000000, // ICON_SUITCASE_ZIP
- 0x00000000, 0x20043ffc, 0x3ffc2004, 0x13c81008, 0x100813c8, 0x10081008, 0x1ff81008, 0x00000000, // ICON_MAILBOX
- 0x00000000, 0x40027ffe, 0x5ffa5ffa, 0x5ffa5ffa, 0x40025ffa, 0x03c07ffe, 0x1ff81ff8, 0x00000000, // ICON_MONITOR
- 0x0ff00000, 0x6bfe7ffe, 0x7ffe7ffe, 0x68167ffe, 0x08106816, 0x08100810, 0x0ff00810, 0x00000000, // ICON_PRINTER
- 0x3ff80000, 0xfffe2008, 0x870a8002, 0x904a888a, 0x904a904a, 0x870a888a, 0xfffe8002, 0x00000000, // ICON_PHOTO_CAMERA
- 0x0fc00000, 0xfcfe0cd8, 0x8002fffe, 0x84428382, 0x84428442, 0x80028382, 0xfffe8002, 0x00000000, // ICON_PHOTO_CAMERA_FLASH
- 0x00000000, 0x02400180, 0x08100420, 0x20041008, 0x23c42004, 0x22442244, 0x3ffc2244, 0x00000000, // ICON_HOUSE
- 0x00000000, 0x1c700000, 0x3ff83ef8, 0x3ff83ff8, 0x0fe01ff0, 0x038007c0, 0x00000100, 0x00000000, // ICON_HEART
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x80000000, 0xe000c000, // ICON_CORNER
- 0x00000000, 0x14001c00, 0x15c01400, 0x15401540, 0x155c1540, 0x15541554, 0x1ddc1554, 0x00000000, // ICON_VERTICAL_BARS
- 0x00000000, 0x03000300, 0x1b001b00, 0x1b601b60, 0x1b6c1b60, 0x1b6c1b6c, 0x1b6c1b6c, 0x00000000, // ICON_VERTICAL_BARS_FILL
- 0x00000000, 0x00000000, 0x403e7ffe, 0x7ffe403e, 0x7ffe0000, 0x43fe43fe, 0x00007ffe, 0x00000000, // ICON_LIFE_BARS
- 0x7ffc0000, 0x43844004, 0x43844284, 0x43844004, 0x42844284, 0x42844284, 0x40044384, 0x00007ffc, // ICON_INFO
- 0x40008000, 0x10002000, 0x04000800, 0x01000200, 0x00400080, 0x00100020, 0x00040008, 0x00010002, // ICON_CROSSLINE
- 0x00000000, 0x1ff01ff0, 0x18301830, 0x1f001830, 0x03001f00, 0x00000300, 0x03000300, 0x00000000, // ICON_HELP
- 0x3ff00000, 0x2abc3550, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x00003ffc, // ICON_FILETYPE_ALPHA
- 0x3ff00000, 0x201c2010, 0x22442184, 0x28142424, 0x29942814, 0x2ff42994, 0x20042004, 0x00003ffc, // ICON_FILETYPE_HOME
- 0x07fe0000, 0x04020402, 0x7fe20402, 0x44224422, 0x44224422, 0x402047fe, 0x40204020, 0x00007fe0, // ICON_LAYERS_VISIBLE
- 0x07fe0000, 0x04020402, 0x7c020402, 0x44024402, 0x44024402, 0x402047fe, 0x40204020, 0x00007fe0, // ICON_LAYERS
- 0x00000000, 0x40027ffe, 0x7ffe4002, 0x40024002, 0x40024002, 0x40024002, 0x7ffe4002, 0x00000000, // ICON_WINDOW
- 0x09100000, 0x09f00910, 0x09100910, 0x00000910, 0x24a2779e, 0x27a224a2, 0x709e20a2, 0x00000000, // ICON_HIDPI
- 0x3ff00000, 0x201c2010, 0x2a842e84, 0x2e842a84, 0x2ba42004, 0x2aa42aa4, 0x20042ba4, 0x00003ffc, // ICON_FILETYPE_BINARY
- 0x00000000, 0x00000000, 0x00120012, 0x4a5e4bd2, 0x485233d2, 0x00004bd2, 0x00000000, 0x00000000, // ICON_HEX
- 0x01800000, 0x381c0660, 0x23c42004, 0x23c42044, 0x13c82204, 0x08101008, 0x02400420, 0x00000180, // ICON_SHIELD
- 0x007e0000, 0x20023fc2, 0x40227fe2, 0x400a403a, 0x400a400a, 0x400a400a, 0x4008400e, 0x00007ff8, // ICON_FILE_NEW
- 0x00000000, 0x0042007e, 0x40027fc2, 0x44024002, 0x5f024402, 0x44024402, 0x7ffe4002, 0x00000000, // ICON_FOLDER_ADD
- 0x44220000, 0x12482244, 0xf3cf0000, 0x14280420, 0x48122424, 0x08100810, 0x1ff81008, 0x03c00420, // ICON_ALARM
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_206
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_207
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_208
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_209
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_210
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_211
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_212
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_213
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_214
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_215
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_216
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_217
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_218
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_219
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_220
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_221
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_222
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_223
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_224
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_225
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_226
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_227
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_228
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_229
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_230
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_231
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_232
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_233
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_234
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_235
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_236
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_237
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_238
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_239
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_240
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_241
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_242
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_243
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_244
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_245
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_246
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_247
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_248
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_249
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_250
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_251
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_252
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_253
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_254
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_255
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_NONE
+ 0x3ff80000, 0x2f082008, 0x2042207e, 0x40027fc2, 0x40024002, 0x40024002, 0x40024002, 0x00007ffe, // ICON_FOLDER_FILE_OPEN
+ 0x3ffe0000, 0x44226422, 0x400247e2, 0x5ffa4002, 0x57ea500a, 0x500a500a, 0x40025ffa, 0x00007ffe, // ICON_FILE_SAVE_CLASSIC
+ 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024002, 0x44424282, 0x793e4102, 0x00000100, // ICON_FOLDER_OPEN
+ 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024102, 0x44424102, 0x793e4282, 0x00000000, // ICON_FOLDER_SAVE
+ 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x24442284, 0x21042104, 0x20042104, 0x00003ffc, // ICON_FILE_OPEN
+ 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x21042104, 0x22842444, 0x20042104, 0x00003ffc, // ICON_FILE_SAVE
+ 0x3ff00000, 0x201c2010, 0x00042004, 0x20041004, 0x20844784, 0x00841384, 0x20042784, 0x00003ffc, // ICON_FILE_EXPORT
+ 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x22042204, 0x22042f84, 0x20042204, 0x00003ffc, // ICON_FILE_ADD
+ 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x25042884, 0x25042204, 0x20042884, 0x00003ffc, // ICON_FILE_DELETE
+ 0x3ff00000, 0x201c2010, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // ICON_FILETYPE_TEXT
+ 0x3ff00000, 0x201c2010, 0x27042004, 0x244424c4, 0x26442444, 0x20642664, 0x20042004, 0x00003ffc, // ICON_FILETYPE_AUDIO
+ 0x3ff00000, 0x201c2010, 0x26042604, 0x20042004, 0x35442884, 0x2414222c, 0x20042004, 0x00003ffc, // ICON_FILETYPE_IMAGE
+ 0x3ff00000, 0x201c2010, 0x20c42004, 0x22442144, 0x22442444, 0x20c42144, 0x20042004, 0x00003ffc, // ICON_FILETYPE_PLAY
+ 0x3ff00000, 0x3ffc2ff0, 0x3f3c2ff4, 0x3dbc2eb4, 0x3dbc2bb4, 0x3f3c2eb4, 0x3ffc2ff4, 0x00002ff4, // ICON_FILETYPE_VIDEO
+ 0x3ff00000, 0x201c2010, 0x21842184, 0x21842004, 0x21842184, 0x21842184, 0x20042184, 0x00003ffc, // ICON_FILETYPE_INFO
+ 0x0ff00000, 0x381c0810, 0x28042804, 0x28042804, 0x28042804, 0x28042804, 0x20102ffc, 0x00003ff0, // ICON_FILE_COPY
+ 0x00000000, 0x701c0000, 0x079c1e14, 0x55a000f0, 0x079c00f0, 0x701c1e14, 0x00000000, 0x00000000, // ICON_FILE_CUT
+ 0x01c00000, 0x13e41bec, 0x3f841004, 0x204420c4, 0x20442044, 0x20442044, 0x207c2044, 0x00003fc0, // ICON_FILE_PASTE
+ 0x00000000, 0x3aa00fe0, 0x2abc2aa0, 0x2aa42aa4, 0x20042aa4, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_CURSOR_HAND
+ 0x00000000, 0x003c000c, 0x030800c8, 0x30100c10, 0x10202020, 0x04400840, 0x01800280, 0x00000000, // ICON_CURSOR_POINTER
+ 0x00000000, 0x00180000, 0x01f00078, 0x03e007f0, 0x07c003e0, 0x04000e40, 0x00000000, 0x00000000, // ICON_CURSOR_CLASSIC
+ 0x00000000, 0x04000000, 0x11000a00, 0x04400a80, 0x01100220, 0x00580088, 0x00000038, 0x00000000, // ICON_PENCIL
+ 0x04000000, 0x15000a00, 0x50402880, 0x14102820, 0x05040a08, 0x015c028c, 0x007c00bc, 0x00000000, // ICON_PENCIL_BIG
+ 0x01c00000, 0x01400140, 0x01400140, 0x0ff80140, 0x0ff80808, 0x0aa80808, 0x0aa80aa8, 0x00000ff8, // ICON_BRUSH_CLASSIC
+ 0x1ffc0000, 0x5ffc7ffe, 0x40004000, 0x00807f80, 0x01c001c0, 0x01c001c0, 0x01c001c0, 0x00000080, // ICON_BRUSH_PAINTER
+ 0x00000000, 0x00800000, 0x01c00080, 0x03e001c0, 0x07f003e0, 0x036006f0, 0x000001c0, 0x00000000, // ICON_WATER_DROP
+ 0x00000000, 0x3e003800, 0x1f803f80, 0x0c201e40, 0x02080c10, 0x00840104, 0x00380044, 0x00000000, // ICON_COLOR_PICKER
+ 0x00000000, 0x07800300, 0x1fe00fc0, 0x3f883fd0, 0x0e021f04, 0x02040402, 0x00f00108, 0x00000000, // ICON_RUBBER
+ 0x00c00000, 0x02800140, 0x08200440, 0x20081010, 0x2ffe3004, 0x03f807fc, 0x00e001f0, 0x00000040, // ICON_COLOR_BUCKET
+ 0x00000000, 0x21843ffc, 0x01800180, 0x01800180, 0x01800180, 0x01800180, 0x03c00180, 0x00000000, // ICON_TEXT_T
+ 0x00800000, 0x01400180, 0x06200340, 0x0c100620, 0x1ff80c10, 0x380c1808, 0x70067004, 0x0000f80f, // ICON_TEXT_A
+ 0x78000000, 0x50004000, 0x00004800, 0x03c003c0, 0x03c003c0, 0x00100000, 0x0002000a, 0x0000000e, // ICON_SCALE
+ 0x75560000, 0x5e004002, 0x54001002, 0x41001202, 0x408200fe, 0x40820082, 0x40820082, 0x00006afe, // ICON_RESIZE
+ 0x00000000, 0x3f003f00, 0x3f003f00, 0x3f003f00, 0x00400080, 0x001c0020, 0x001c001c, 0x00000000, // ICON_FILTER_POINT
+ 0x6d800000, 0x00004080, 0x40804080, 0x40800000, 0x00406d80, 0x001c0020, 0x001c001c, 0x00000000, // ICON_FILTER_BILINEAR
+ 0x40080000, 0x1ffe2008, 0x14081008, 0x11081208, 0x10481088, 0x10081028, 0x10047ff8, 0x00001002, // ICON_CROP
+ 0x00100000, 0x3ffc0010, 0x2ab03550, 0x22b02550, 0x20b02150, 0x20302050, 0x2000fff0, 0x00002000, // ICON_CROP_ALPHA
+ 0x40000000, 0x1ff82000, 0x04082808, 0x01082208, 0x00482088, 0x00182028, 0x35542008, 0x00000002, // ICON_SQUARE_TOGGLE
+ 0x00000000, 0x02800280, 0x06c006c0, 0x0ea00ee0, 0x1e901eb0, 0x3e883e98, 0x7efc7e8c, 0x00000000, // ICON_SYMMETRY
+ 0x01000000, 0x05600100, 0x1d480d50, 0x7d423d44, 0x3d447d42, 0x0d501d48, 0x01000560, 0x00000100, // ICON_SYMMETRY_HORIZONTAL
+ 0x01800000, 0x04200240, 0x10080810, 0x00001ff8, 0x00007ffe, 0x0ff01ff8, 0x03c007e0, 0x00000180, // ICON_SYMMETRY_VERTICAL
+ 0x00000000, 0x010800f0, 0x02040204, 0x02040204, 0x07f00308, 0x1c000e00, 0x30003800, 0x00000000, // ICON_LENS
+ 0x00000000, 0x061803f0, 0x08240c0c, 0x08040814, 0x0c0c0804, 0x23f01618, 0x18002400, 0x00000000, // ICON_LENS_BIG
+ 0x00000000, 0x00000000, 0x1c7007c0, 0x638e3398, 0x1c703398, 0x000007c0, 0x00000000, 0x00000000, // ICON_EYE_ON
+ 0x00000000, 0x10002000, 0x04700fc0, 0x610e3218, 0x1c703098, 0x001007a0, 0x00000008, 0x00000000, // ICON_EYE_OFF
+ 0x00000000, 0x00007ffc, 0x40047ffc, 0x10102008, 0x04400820, 0x02800280, 0x02800280, 0x00000100, // ICON_FILTER_TOP
+ 0x00000000, 0x40027ffe, 0x10082004, 0x04200810, 0x02400240, 0x02400240, 0x01400240, 0x000000c0, // ICON_FILTER
+ 0x00800000, 0x00800080, 0x00000080, 0x3c9e0000, 0x00000000, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_POINT
+ 0x00800000, 0x00800080, 0x00800080, 0x3f7e01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_SMALL
+ 0x00800000, 0x00800080, 0x03e00080, 0x3e3e0220, 0x03e00220, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_BIG
+ 0x01000000, 0x04400280, 0x01000100, 0x43842008, 0x43849ab2, 0x01002008, 0x04400100, 0x01000280, // ICON_TARGET_MOVE
+ 0x01000000, 0x04400280, 0x01000100, 0x41042108, 0x41049ff2, 0x01002108, 0x04400100, 0x01000280, // ICON_CURSOR_MOVE
+ 0x781e0000, 0x500a4002, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x4002500a, 0x0000781e, // ICON_CURSOR_SCALE
+ 0x00000000, 0x20003c00, 0x24002800, 0x01000200, 0x00400080, 0x00140024, 0x003c0004, 0x00000000, // ICON_CURSOR_SCALE_RIGHT
+ 0x00000000, 0x0004003c, 0x00240014, 0x00800040, 0x02000100, 0x28002400, 0x3c002000, 0x00000000, // ICON_CURSOR_SCALE_LEFT
+ 0x00000000, 0x00100020, 0x10101fc8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // ICON_UNDO
+ 0x00000000, 0x08000400, 0x080813f8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // ICON_REDO
+ 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3f902020, 0x00400020, 0x00000000, // ICON_REREDO
+ 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3fc82010, 0x00200010, 0x00000000, // ICON_MUTATE
+ 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18101020, 0x00100fc8, 0x00000020, // ICON_ROTATE
+ 0x00000000, 0x04000200, 0x240429fc, 0x20042204, 0x20442004, 0x3f942024, 0x00400020, 0x00000000, // ICON_REPEAT
+ 0x00000000, 0x20001000, 0x22104c0e, 0x00801120, 0x11200040, 0x4c0e2210, 0x10002000, 0x00000000, // ICON_SHUFFLE
+ 0x7ffe0000, 0x50024002, 0x44024802, 0x41024202, 0x40424082, 0x40124022, 0x4002400a, 0x00007ffe, // ICON_EMPTYBOX
+ 0x00800000, 0x03e00080, 0x08080490, 0x3c9e0808, 0x08080808, 0x03e00490, 0x00800080, 0x00000000, // ICON_TARGET
+ 0x00800000, 0x00800080, 0x00800080, 0x3ffe01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_SMALL_FILL
+ 0x00800000, 0x00800080, 0x03e00080, 0x3ffe03e0, 0x03e003e0, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_BIG_FILL
+ 0x01000000, 0x07c00380, 0x01000100, 0x638c2008, 0x638cfbbe, 0x01002008, 0x07c00100, 0x01000380, // ICON_TARGET_MOVE_FILL
+ 0x01000000, 0x07c00380, 0x01000100, 0x610c2108, 0x610cfffe, 0x01002108, 0x07c00100, 0x01000380, // ICON_CURSOR_MOVE_FILL
+ 0x781e0000, 0x6006700e, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x700e6006, 0x0000781e, // ICON_CURSOR_SCALE_FILL
+ 0x00000000, 0x38003c00, 0x24003000, 0x01000200, 0x00400080, 0x000c0024, 0x003c001c, 0x00000000, // ICON_CURSOR_SCALE_RIGHT_FILL
+ 0x00000000, 0x001c003c, 0x0024000c, 0x00800040, 0x02000100, 0x30002400, 0x3c003800, 0x00000000, // ICON_CURSOR_SCALE_LEFT_FILL
+ 0x00000000, 0x00300020, 0x10301ff8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // ICON_UNDO_FILL
+ 0x00000000, 0x0c000400, 0x0c081ff8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // ICON_REDO_FILL
+ 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3ff02060, 0x00400060, 0x00000000, // ICON_REREDO_FILL
+ 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3ff82030, 0x00200030, 0x00000000, // ICON_MUTATE_FILL
+ 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18301020, 0x00300ff8, 0x00000020, // ICON_ROTATE_FILL
+ 0x00000000, 0x06000200, 0x26042ffc, 0x20042204, 0x20442004, 0x3ff42064, 0x00400060, 0x00000000, // ICON_REPEAT_FILL
+ 0x00000000, 0x30001000, 0x32107c0e, 0x00801120, 0x11200040, 0x7c0e3210, 0x10003000, 0x00000000, // ICON_SHUFFLE_FILL
+ 0x00000000, 0x30043ffc, 0x24042804, 0x21042204, 0x20442084, 0x20142024, 0x3ffc200c, 0x00000000, // ICON_EMPTYBOX_SMALL
+ 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX
+ 0x00000000, 0x23c43ffc, 0x23c423c4, 0x200423c4, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_TOP
+ 0x00000000, 0x3e043ffc, 0x3e043e04, 0x20043e04, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_TOP_RIGHT
+ 0x00000000, 0x20043ffc, 0x20042004, 0x3e043e04, 0x3e043e04, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_RIGHT
+ 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x3e042004, 0x3e043e04, 0x3ffc3e04, 0x00000000, // ICON_BOX_BOTTOM_RIGHT
+ 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x23c42004, 0x23c423c4, 0x3ffc23c4, 0x00000000, // ICON_BOX_BOTTOM
+ 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x207c2004, 0x207c207c, 0x3ffc207c, 0x00000000, // ICON_BOX_BOTTOM_LEFT
+ 0x00000000, 0x20043ffc, 0x20042004, 0x207c207c, 0x207c207c, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_LEFT
+ 0x00000000, 0x207c3ffc, 0x207c207c, 0x2004207c, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_TOP_LEFT
+ 0x00000000, 0x20043ffc, 0x20042004, 0x23c423c4, 0x23c423c4, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_CENTER
+ 0x7ffe0000, 0x40024002, 0x47e24182, 0x4ff247e2, 0x47e24ff2, 0x418247e2, 0x40024002, 0x00007ffe, // ICON_BOX_CIRCLE_MASK
+ 0x7fff0000, 0x40014001, 0x40014001, 0x49555ddd, 0x4945495d, 0x400149c5, 0x40014001, 0x00007fff, // ICON_POT
+ 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x404e40ce, 0x48125432, 0x4006540e, 0x00007ffe, // ICON_ALPHA_MULTIPLY
+ 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x5c4e40ce, 0x44124432, 0x40065c0e, 0x00007ffe, // ICON_ALPHA_CLEAR
+ 0x7ffe0000, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x00007ffe, // ICON_DITHERING
+ 0x07fe0000, 0x1ffa0002, 0x7fea000a, 0x402a402a, 0x5b2a512a, 0x5128552a, 0x40205128, 0x00007fe0, // ICON_MIPMAPS
+ 0x00000000, 0x1ff80000, 0x12481248, 0x12481ff8, 0x1ff81248, 0x12481248, 0x00001ff8, 0x00000000, // ICON_BOX_GRID
+ 0x12480000, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x00001248, // ICON_GRID
+ 0x00000000, 0x1c380000, 0x1c3817e8, 0x08100810, 0x08100810, 0x17e81c38, 0x00001c38, 0x00000000, // ICON_BOX_CORNERS_SMALL
+ 0x700e0000, 0x700e5ffa, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x5ffa700e, 0x0000700e, // ICON_BOX_CORNERS_BIG
+ 0x3f7e0000, 0x21422142, 0x21422142, 0x00003f7e, 0x21423f7e, 0x21422142, 0x3f7e2142, 0x00000000, // ICON_FOUR_BOXES
+ 0x00000000, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x00000000, // ICON_GRID_FILL
+ 0x7ffe0000, 0x7ffe7ffe, 0x77fe7000, 0x77fe77fe, 0x777e7700, 0x777e777e, 0x777e777e, 0x0000777e, // ICON_BOX_MULTISIZE
+ 0x781e0000, 0x40024002, 0x00004002, 0x01800000, 0x00000180, 0x40020000, 0x40024002, 0x0000781e, // ICON_ZOOM_SMALL
+ 0x781e0000, 0x40024002, 0x00004002, 0x03c003c0, 0x03c003c0, 0x40020000, 0x40024002, 0x0000781e, // ICON_ZOOM_MEDIUM
+ 0x781e0000, 0x40024002, 0x07e04002, 0x07e007e0, 0x07e007e0, 0x400207e0, 0x40024002, 0x0000781e, // ICON_ZOOM_BIG
+ 0x781e0000, 0x5ffa4002, 0x1ff85ffa, 0x1ff81ff8, 0x1ff81ff8, 0x5ffa1ff8, 0x40025ffa, 0x0000781e, // ICON_ZOOM_ALL
+ 0x00000000, 0x2004381c, 0x00002004, 0x00000000, 0x00000000, 0x20040000, 0x381c2004, 0x00000000, // ICON_ZOOM_CENTER
+ 0x00000000, 0x1db80000, 0x10081008, 0x10080000, 0x00001008, 0x10081008, 0x00001db8, 0x00000000, // ICON_BOX_DOTS_SMALL
+ 0x35560000, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x35562002, 0x00000000, // ICON_BOX_DOTS_BIG
+ 0x7ffe0000, 0x40024002, 0x48124ff2, 0x49924812, 0x48124992, 0x4ff24812, 0x40024002, 0x00007ffe, // ICON_BOX_CONCENTRIC
+ 0x00000000, 0x10841ffc, 0x10841084, 0x1ffc1084, 0x10841084, 0x10841084, 0x00001ffc, 0x00000000, // ICON_BOX_GRID_BIG
+ 0x00000000, 0x00000000, 0x10000000, 0x04000800, 0x01040200, 0x00500088, 0x00000020, 0x00000000, // ICON_OK_TICK
+ 0x00000000, 0x10080000, 0x04200810, 0x01800240, 0x02400180, 0x08100420, 0x00001008, 0x00000000, // ICON_CROSS
+ 0x00000000, 0x02000000, 0x00800100, 0x00200040, 0x00200010, 0x00800040, 0x02000100, 0x00000000, // ICON_ARROW_LEFT
+ 0x00000000, 0x00400000, 0x01000080, 0x04000200, 0x04000800, 0x01000200, 0x00400080, 0x00000000, // ICON_ARROW_RIGHT
+ 0x00000000, 0x00000000, 0x00000000, 0x08081004, 0x02200410, 0x00800140, 0x00000000, 0x00000000, // ICON_ARROW_DOWN
+ 0x00000000, 0x00000000, 0x01400080, 0x04100220, 0x10040808, 0x00000000, 0x00000000, 0x00000000, // ICON_ARROW_UP
+ 0x00000000, 0x02000000, 0x03800300, 0x03e003c0, 0x03e003f0, 0x038003c0, 0x02000300, 0x00000000, // ICON_ARROW_LEFT_FILL
+ 0x00000000, 0x00400000, 0x01c000c0, 0x07c003c0, 0x07c00fc0, 0x01c003c0, 0x004000c0, 0x00000000, // ICON_ARROW_RIGHT_FILL
+ 0x00000000, 0x00000000, 0x00000000, 0x0ff81ffc, 0x03e007f0, 0x008001c0, 0x00000000, 0x00000000, // ICON_ARROW_DOWN_FILL
+ 0x00000000, 0x00000000, 0x01c00080, 0x07f003e0, 0x1ffc0ff8, 0x00000000, 0x00000000, 0x00000000, // ICON_ARROW_UP_FILL
+ 0x00000000, 0x18a008c0, 0x32881290, 0x24822686, 0x26862482, 0x12903288, 0x08c018a0, 0x00000000, // ICON_AUDIO
+ 0x00000000, 0x04800780, 0x004000c0, 0x662000f0, 0x08103c30, 0x130a0e18, 0x0000318e, 0x00000000, // ICON_FX
+ 0x00000000, 0x00800000, 0x08880888, 0x2aaa0a8a, 0x0a8a2aaa, 0x08880888, 0x00000080, 0x00000000, // ICON_WAVE
+ 0x00000000, 0x00600000, 0x01080090, 0x02040108, 0x42044204, 0x24022402, 0x00001800, 0x00000000, // ICON_WAVE_SINUS
+ 0x00000000, 0x07f80000, 0x04080408, 0x04080408, 0x04080408, 0x7c0e0408, 0x00000000, 0x00000000, // ICON_WAVE_SQUARE
+ 0x00000000, 0x00000000, 0x00a00040, 0x22084110, 0x08021404, 0x00000000, 0x00000000, 0x00000000, // ICON_WAVE_TRIANGULAR
+ 0x00000000, 0x00000000, 0x04200000, 0x01800240, 0x02400180, 0x00000420, 0x00000000, 0x00000000, // ICON_CROSS_SMALL
+ 0x00000000, 0x18380000, 0x12281428, 0x10a81128, 0x112810a8, 0x14281228, 0x00001838, 0x00000000, // ICON_PLAYER_PREVIOUS
+ 0x00000000, 0x18000000, 0x11801600, 0x10181060, 0x10601018, 0x16001180, 0x00001800, 0x00000000, // ICON_PLAYER_PLAY_BACK
+ 0x00000000, 0x00180000, 0x01880068, 0x18080608, 0x06081808, 0x00680188, 0x00000018, 0x00000000, // ICON_PLAYER_PLAY
+ 0x00000000, 0x1e780000, 0x12481248, 0x12481248, 0x12481248, 0x12481248, 0x00001e78, 0x00000000, // ICON_PLAYER_PAUSE
+ 0x00000000, 0x1ff80000, 0x10081008, 0x10081008, 0x10081008, 0x10081008, 0x00001ff8, 0x00000000, // ICON_PLAYER_STOP
+ 0x00000000, 0x1c180000, 0x14481428, 0x15081488, 0x14881508, 0x14281448, 0x00001c18, 0x00000000, // ICON_PLAYER_NEXT
+ 0x00000000, 0x03c00000, 0x08100420, 0x10081008, 0x10081008, 0x04200810, 0x000003c0, 0x00000000, // ICON_PLAYER_RECORD
+ 0x00000000, 0x0c3007e0, 0x13c81818, 0x14281668, 0x14281428, 0x1c381c38, 0x08102244, 0x00000000, // ICON_MAGNET
+ 0x07c00000, 0x08200820, 0x3ff80820, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // ICON_LOCK_CLOSE
+ 0x07c00000, 0x08000800, 0x3ff80800, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // ICON_LOCK_OPEN
+ 0x01c00000, 0x0c180770, 0x3086188c, 0x60832082, 0x60034781, 0x30062002, 0x0c18180c, 0x01c00770, // ICON_CLOCK
+ 0x0a200000, 0x1b201b20, 0x04200e20, 0x04200420, 0x04700420, 0x0e700e70, 0x0e700e70, 0x04200e70, // ICON_TOOLS
+ 0x01800000, 0x3bdc318c, 0x0ff01ff8, 0x7c3e1e78, 0x1e787c3e, 0x1ff80ff0, 0x318c3bdc, 0x00000180, // ICON_GEAR
+ 0x01800000, 0x3ffc318c, 0x1c381ff8, 0x781e1818, 0x1818781e, 0x1ff81c38, 0x318c3ffc, 0x00000180, // ICON_GEAR_BIG
+ 0x00000000, 0x08080ff8, 0x08081ffc, 0x0aa80aa8, 0x0aa80aa8, 0x0aa80aa8, 0x08080aa8, 0x00000ff8, // ICON_BIN
+ 0x00000000, 0x00000000, 0x20043ffc, 0x08043f84, 0x04040f84, 0x04040784, 0x000007fc, 0x00000000, // ICON_HAND_POINTER
+ 0x00000000, 0x24400400, 0x00001480, 0x6efe0e00, 0x00000e00, 0x24401480, 0x00000400, 0x00000000, // ICON_LASER
+ 0x00000000, 0x03c00000, 0x08300460, 0x11181118, 0x11181118, 0x04600830, 0x000003c0, 0x00000000, // ICON_COIN
+ 0x00000000, 0x10880080, 0x06c00810, 0x366c07e0, 0x07e00240, 0x00001768, 0x04200240, 0x00000000, // ICON_EXPLOSION
+ 0x00000000, 0x3d280000, 0x2528252c, 0x3d282528, 0x05280528, 0x05e80528, 0x00000000, 0x00000000, // ICON_1UP
+ 0x01800000, 0x03c003c0, 0x018003c0, 0x0ff007e0, 0x0bd00bd0, 0x0a500bd0, 0x02400240, 0x02400240, // ICON_PLAYER
+ 0x01800000, 0x03c003c0, 0x118013c0, 0x03c81ff8, 0x07c003c8, 0x04400440, 0x0c080478, 0x00000000, // ICON_PLAYER_JUMP
+ 0x3ff80000, 0x30183ff8, 0x30183018, 0x3ff83ff8, 0x03000300, 0x03c003c0, 0x03e00300, 0x000003e0, // ICON_KEY
+ 0x3ff80000, 0x3ff83ff8, 0x33983ff8, 0x3ff83398, 0x3ff83ff8, 0x00000540, 0x0fe00aa0, 0x00000fe0, // ICON_DEMON
+ 0x00000000, 0x0ff00000, 0x20041008, 0x25442004, 0x10082004, 0x06000bf0, 0x00000300, 0x00000000, // ICON_TEXT_POPUP
+ 0x00000000, 0x11440000, 0x07f00be8, 0x1c1c0e38, 0x1c1c0c18, 0x07f00e38, 0x11440be8, 0x00000000, // ICON_GEAR_EX
+ 0x00000000, 0x20080000, 0x0c601010, 0x07c00fe0, 0x07c007c0, 0x0c600fe0, 0x20081010, 0x00000000, // ICON_CRACK
+ 0x00000000, 0x20080000, 0x0c601010, 0x04400fe0, 0x04405554, 0x0c600fe0, 0x20081010, 0x00000000, // ICON_CRACK_POINTS
+ 0x00000000, 0x00800080, 0x01c001c0, 0x1ffc3ffe, 0x03e007f0, 0x07f003e0, 0x0c180770, 0x00000808, // ICON_STAR
+ 0x0ff00000, 0x08180810, 0x08100818, 0x0a100810, 0x08180810, 0x08100818, 0x08100810, 0x00001ff8, // ICON_DOOR
+ 0x0ff00000, 0x08100810, 0x08100810, 0x10100010, 0x4f902010, 0x10102010, 0x08100010, 0x00000ff0, // ICON_EXIT
+ 0x00040000, 0x001f000e, 0x0ef40004, 0x12f41284, 0x0ef41214, 0x10040004, 0x7ffc3004, 0x10003000, // ICON_MODE_2D
+ 0x78040000, 0x501f600e, 0x0ef44004, 0x12f41284, 0x0ef41284, 0x10140004, 0x7ffc300c, 0x10003000, // ICON_MODE_3D
+ 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // ICON_CUBE
+ 0x7fe00000, 0x5ff87ff0, 0x47fe4ffc, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // ICON_CUBE_FACE_TOP
+ 0x7fe00000, 0x50386030, 0x47fe483c, 0x443e443e, 0x443e443e, 0x241e75fe, 0x0c06140e, 0x000007fe, // ICON_CUBE_FACE_LEFT
+ 0x7fe00000, 0x50286030, 0x47fe4804, 0x47fe47fe, 0x47fe47fe, 0x27fe77fe, 0x0ffe17fe, 0x000007fe, // ICON_CUBE_FACE_FRONT
+ 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x3ff27fe2, 0x0ffe1ffa, 0x000007fe, // ICON_CUBE_FACE_BOTTOM
+ 0x7fe00000, 0x70286030, 0x7ffe7804, 0x7c227c02, 0x7c227c22, 0x3c127de2, 0x0c061c0a, 0x000007fe, // ICON_CUBE_FACE_RIGHT
+ 0x7fe00000, 0x7fe87ff0, 0x7ffe7fe4, 0x7fe27fe2, 0x7fe27fe2, 0x24127fe2, 0x0c06140a, 0x000007fe, // ICON_CUBE_FACE_BACK
+ 0x00000000, 0x2a0233fe, 0x22022602, 0x22022202, 0x2a022602, 0x00a033fe, 0x02080110, 0x00000000, // ICON_CAMERA
+ 0x00000000, 0x200c3ffc, 0x000c000c, 0x3ffc000c, 0x30003000, 0x30003000, 0x3ffc3004, 0x00000000, // ICON_SPECIAL
+ 0x00000000, 0x0022003e, 0x012201e2, 0x0100013e, 0x01000100, 0x79000100, 0x4f004900, 0x00007800, // ICON_LINK_NET
+ 0x00000000, 0x44007c00, 0x45004600, 0x00627cbe, 0x00620022, 0x45007cbe, 0x44004600, 0x00007c00, // ICON_LINK_BOXES
+ 0x00000000, 0x0044007c, 0x0010007c, 0x3f100010, 0x3f1021f0, 0x3f100010, 0x3f0021f0, 0x00000000, // ICON_LINK_MULTI
+ 0x00000000, 0x0044007c, 0x00440044, 0x0010007c, 0x00100010, 0x44107c10, 0x440047f0, 0x00007c00, // ICON_LINK
+ 0x00000000, 0x0044007c, 0x00440044, 0x0000007c, 0x00000010, 0x44007c10, 0x44004550, 0x00007c00, // ICON_LINK_BROKE
+ 0x02a00000, 0x22a43ffc, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // ICON_TEXT_NOTES
+ 0x3ffc0000, 0x20042004, 0x245e27c4, 0x27c42444, 0x2004201e, 0x201e2004, 0x20042004, 0x00003ffc, // ICON_NOTEBOOK
+ 0x00000000, 0x07e00000, 0x04200420, 0x24243ffc, 0x24242424, 0x24242424, 0x3ffc2424, 0x00000000, // ICON_SUITCASE
+ 0x00000000, 0x0fe00000, 0x08200820, 0x40047ffc, 0x7ffc5554, 0x40045554, 0x7ffc4004, 0x00000000, // ICON_SUITCASE_ZIP
+ 0x00000000, 0x20043ffc, 0x3ffc2004, 0x13c81008, 0x100813c8, 0x10081008, 0x1ff81008, 0x00000000, // ICON_MAILBOX
+ 0x00000000, 0x40027ffe, 0x5ffa5ffa, 0x5ffa5ffa, 0x40025ffa, 0x03c07ffe, 0x1ff81ff8, 0x00000000, // ICON_MONITOR
+ 0x0ff00000, 0x6bfe7ffe, 0x7ffe7ffe, 0x68167ffe, 0x08106816, 0x08100810, 0x0ff00810, 0x00000000, // ICON_PRINTER
+ 0x3ff80000, 0xfffe2008, 0x870a8002, 0x904a888a, 0x904a904a, 0x870a888a, 0xfffe8002, 0x00000000, // ICON_PHOTO_CAMERA
+ 0x0fc00000, 0xfcfe0cd8, 0x8002fffe, 0x84428382, 0x84428442, 0x80028382, 0xfffe8002, 0x00000000, // ICON_PHOTO_CAMERA_FLASH
+ 0x00000000, 0x02400180, 0x08100420, 0x20041008, 0x23c42004, 0x22442244, 0x3ffc2244, 0x00000000, // ICON_HOUSE
+ 0x00000000, 0x1c700000, 0x3ff83ef8, 0x3ff83ff8, 0x0fe01ff0, 0x038007c0, 0x00000100, 0x00000000, // ICON_HEART
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x80000000, 0xe000c000, // ICON_CORNER
+ 0x00000000, 0x14001c00, 0x15c01400, 0x15401540, 0x155c1540, 0x15541554, 0x1ddc1554, 0x00000000, // ICON_VERTICAL_BARS
+ 0x00000000, 0x03000300, 0x1b001b00, 0x1b601b60, 0x1b6c1b60, 0x1b6c1b6c, 0x1b6c1b6c, 0x00000000, // ICON_VERTICAL_BARS_FILL
+ 0x00000000, 0x00000000, 0x403e7ffe, 0x7ffe403e, 0x7ffe0000, 0x43fe43fe, 0x00007ffe, 0x00000000, // ICON_LIFE_BARS
+ 0x7ffc0000, 0x43844004, 0x43844284, 0x43844004, 0x42844284, 0x42844284, 0x40044384, 0x00007ffc, // ICON_INFO
+ 0x40008000, 0x10002000, 0x04000800, 0x01000200, 0x00400080, 0x00100020, 0x00040008, 0x00010002, // ICON_CROSSLINE
+ 0x00000000, 0x1ff01ff0, 0x18301830, 0x1f001830, 0x03001f00, 0x00000300, 0x03000300, 0x00000000, // ICON_HELP
+ 0x3ff00000, 0x2abc3550, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x00003ffc, // ICON_FILETYPE_ALPHA
+ 0x3ff00000, 0x201c2010, 0x22442184, 0x28142424, 0x29942814, 0x2ff42994, 0x20042004, 0x00003ffc, // ICON_FILETYPE_HOME
+ 0x07fe0000, 0x04020402, 0x7fe20402, 0x44224422, 0x44224422, 0x402047fe, 0x40204020, 0x00007fe0, // ICON_LAYERS_VISIBLE
+ 0x07fe0000, 0x04020402, 0x7c020402, 0x44024402, 0x44024402, 0x402047fe, 0x40204020, 0x00007fe0, // ICON_LAYERS
+ 0x00000000, 0x40027ffe, 0x7ffe4002, 0x40024002, 0x40024002, 0x40024002, 0x7ffe4002, 0x00000000, // ICON_WINDOW
+ 0x09100000, 0x09f00910, 0x09100910, 0x00000910, 0x24a2779e, 0x27a224a2, 0x709e20a2, 0x00000000, // ICON_HIDPI
+ 0x3ff00000, 0x201c2010, 0x2a842e84, 0x2e842a84, 0x2ba42004, 0x2aa42aa4, 0x20042ba4, 0x00003ffc, // ICON_FILETYPE_BINARY
+ 0x00000000, 0x00000000, 0x00120012, 0x4a5e4bd2, 0x485233d2, 0x00004bd2, 0x00000000, 0x00000000, // ICON_HEX
+ 0x01800000, 0x381c0660, 0x23c42004, 0x23c42044, 0x13c82204, 0x08101008, 0x02400420, 0x00000180, // ICON_SHIELD
+ 0x007e0000, 0x20023fc2, 0x40227fe2, 0x400a403a, 0x400a400a, 0x400a400a, 0x4008400e, 0x00007ff8, // ICON_FILE_NEW
+ 0x00000000, 0x0042007e, 0x40027fc2, 0x44024002, 0x5f024402, 0x44024402, 0x7ffe4002, 0x00000000, // ICON_FOLDER_ADD
+ 0x44220000, 0x12482244, 0xf3cf0000, 0x14280420, 0x48122424, 0x08100810, 0x1ff81008, 0x03c00420, // ICON_ALARM
+ 0x0aa00000, 0x1ff80aa0, 0x1068700e, 0x1008706e, 0x1008700e, 0x1008700e, 0x0aa01ff8, 0x00000aa0, // ICON_CPU
+ 0x07e00000, 0x04201db8, 0x04a01c38, 0x04a01d38, 0x04a01d38, 0x04a01d38, 0x04201d38, 0x000007e0, // ICON_ROM
+ 0x00000000, 0x03c00000, 0x3c382ff0, 0x3c04380c, 0x01800000, 0x03c003c0, 0x00000180, 0x00000000, // ICON_STEP_OVER
+ 0x01800000, 0x01800180, 0x01800180, 0x03c007e0, 0x00000180, 0x01800000, 0x03c003c0, 0x00000180, // ICON_STEP_INTO
+ 0x01800000, 0x07e003c0, 0x01800180, 0x01800180, 0x00000180, 0x01800000, 0x03c003c0, 0x00000180, // ICON_STEP_OUT
+ 0x00000000, 0x0ff003c0, 0x181c1c34, 0x303c301c, 0x30003000, 0x1c301800, 0x03c00ff0, 0x00000000, // ICON_RESTART
+ 0x00000000, 0x00000000, 0x07e003c0, 0x0ff00ff0, 0x0ff00ff0, 0x03c007e0, 0x00000000, 0x00000000, // ICON_BREAKPOINT_ON
+ 0x00000000, 0x00000000, 0x042003c0, 0x08100810, 0x08100810, 0x03c00420, 0x00000000, 0x00000000, // ICON_BREAKPOINT_OFF
+ 0x00000000, 0x00000000, 0x1ff81ff8, 0x1ff80000, 0x00001ff8, 0x1ff81ff8, 0x00000000, 0x00000000, // ICON_BURGER_MENU
+ 0x00000000, 0x00000000, 0x00880070, 0x0c880088, 0x1e8810f8, 0x3e881288, 0x00000000, 0x00000000, // ICON_CASE_SENSITIVE
+ 0x00000000, 0x02000000, 0x07000a80, 0x07001fc0, 0x02000a80, 0x00300030, 0x00000000, 0x00000000, // ICON_REG_EXP
+ 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x40024002, 0x40024002, 0x7ffe4002, 0x00000000, // ICON_FOLDER
+ 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x00003ffc, // ICON_FILE
+ 0x1ff00000, 0x20082008, 0x17d02fe8, 0x05400ba0, 0x09200540, 0x23881010, 0x2fe827c8, 0x00001ff0, // ICON_SAND_TIMER
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_220
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_221
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_222
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_223
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_224
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_225
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_226
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_227
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_228
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_229
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_230
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_231
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_232
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_233
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_234
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_235
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_236
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_237
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_238
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_239
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_240
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_241
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_242
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_243
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_244
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_245
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_246
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_247
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_248
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_249
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_250
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_251
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_252
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_253
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_254
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_255
};
+// NOTE: We keep a pointer to the icons array, useful to point to other sets if required
+static unsigned int *guiIconsPtr = guiIcons;
+
#endif // !RAYGUI_NO_ICONS && !RAYGUI_CUSTOM_ICONS
#ifndef RAYGUI_ICON_SIZE
@@ -1152,13 +1250,24 @@ typedef enum { BORDER = 0, BASE, TEXT, OTHER } GuiPropertyElement;
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
-static GuiState guiState = STATE_NORMAL; // Gui global state, if !STATE_NORMAL, forces defined state
+static GuiState guiState = STATE_NORMAL; // Gui global state, if !STATE_NORMAL, forces defined state
-static Font guiFont = { 0 }; // Gui current font (WARNING: highly coupled to raylib)
-static bool guiLocked = false; // Gui lock state (no inputs processed)
-static float guiAlpha = 1.0f; // Gui element transpacency on drawing
+static Font guiFont = { 0 }; // Gui current font (WARNING: highly coupled to raylib)
+static bool guiLocked = false; // Gui lock state (no inputs processed)
+static float guiAlpha = 1.0f; // Gui element transpacency on drawing
-static unsigned int guiIconScale = 1; // Gui icon default scale (if icons enabled)
+static unsigned int guiIconScale = 1; // Gui icon default scale (if icons enabled)
+
+static bool guiTooltip = false; // Tooltip enabled/disabled
+static const char *guiTooltipPtr = NULL; // Tooltip string pointer (string provided by user)
+
+static bool guiSliderDragging = false; // Gui slider drag state (no inputs processed except dragged slider)
+static Rectangle guiSliderActive = { 0 }; // Gui slider active bounds rectangle, used as an unique identifier
+
+static unsigned int textBoxCursorIndex = 0; // Cursor index, shared by all GuiTextBox*()
+//static int blinkCursorFrameCounter = 0; // Frame counter for cursor blinking
+static int autoCursorCooldownCounter = 0; // Cooldown frame counter for automatic cursor movement on key-down
+static int autoCursorDelayCounter = 0; // Delay frame counter for automatic cursor movement
//----------------------------------------------------------------------------------
// Style data array for all gui style properties (allocated on data segment by default)
@@ -1203,13 +1312,12 @@ static bool IsMouseButtonReleased(int button);
static bool IsKeyDown(int key);
static bool IsKeyPressed(int key);
-static int GetCharPressed(void); // -- GuiTextBox(), GuiTextBoxMulti(), GuiValueBox()
+static int GetCharPressed(void); // -- GuiTextBox(), GuiValueBox()
//-------------------------------------------------------------------------------
// Drawing required functions
//-------------------------------------------------------------------------------
static void DrawRectangle(int x, int y, int width, int height, Color color); // -- GuiDrawRectangle(), GuiDrawIcon()
-
static void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // -- GuiColorPicker()
//-------------------------------------------------------------------------------
@@ -1221,9 +1329,6 @@ static Texture2D LoadTextureFromImage(Image image); // -- GuiLoadStyle()
static void SetShapesTexture(Texture2D tex, Rectangle rec); // -- GuiLoadStyle()
static char *LoadFileText(const char *fileName); // -- GuiLoadStyle()
static const char *GetDirectoryPath(const char *filePath); // -- GuiLoadStyle()
-
-static Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // -- GetTextWidth(), GuiTextBoxMulti()
-static void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // -- GuiDrawText()
//-------------------------------------------------------------------------------
// raylib functions already implemented in raygui
@@ -1235,7 +1340,8 @@ static bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if
static const char *TextFormat(const char *text, ...); // Formatting of text with variables to 'embed'
static const char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings
static int TextToInteger(const char *text); // Get integer value from text
-static int GetCodepoint(const char *text, int *bytesProcessed); // Get next codepoint in a UTF-8 encoded text
+
+static int GetCodepointNext(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded text
static const char *CodepointToUTF8(int codepoint, int *byteSize); // Encode codepoint into UTF-8 text (char array size returned as parameter)
static void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2); // Draw rectangle vertical gradient
@@ -1246,18 +1352,22 @@ static void DrawRectangleGradientV(int posX, int posY, int width, int height, Co
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
//----------------------------------------------------------------------------------
-static int GetTextWidth(const char *text); // Gui get text width using default font
+static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize); // Load style from memory (binary only)
+
+static int GetTextWidth(const char *text); // Gui get text width using gui font and style
static Rectangle GetTextBounds(int control, Rectangle bounds); // Get text bounds considering control bounds
static const char *GetTextIcon(const char *text, int *iconId); // Get text icon if provided and move text cursor
static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color tint); // Gui draw text using default font
static void GuiDrawRectangle(Rectangle rec, int borderWidth, Color borderColor, Color color); // Gui draw rectangle using default raygui style
-static const char **GuiTextSplit(const char *text, int *count, int *textRow); // Split controls text into multiple strings
+static const char **GuiTextSplit(const char *text, char delimiter, int *count, int *textRow); // Split controls text into multiple strings
static Vector3 ConvertHSVtoRGB(Vector3 hsv); // Convert color data from HSV to RGB
static Vector3 ConvertRGBtoHSV(Vector3 rgb); // Convert color data from RGB to HSV
static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue); // Scroll bar control, used by GuiScrollPanel()
+static void GuiTooltip(Rectangle controlRec); // Draw tooltip using control rec position
+
//----------------------------------------------------------------------------------
// Gui Setup Functions Definition
@@ -1341,7 +1451,7 @@ int GuiGetStyle(int control, int property)
//----------------------------------------------------------------------------------
// Window Box control
-bool GuiWindowBox(Rectangle bounds, const char *title)
+int GuiWindowBox(Rectangle bounds, const char *title)
{
// Window title bar height (including borders)
// NOTE: This define is also used by GuiMessageBox() and GuiTextInputBox()
@@ -1349,8 +1459,8 @@ bool GuiWindowBox(Rectangle bounds, const char *title)
#define RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT 24
#endif
+ int result = 0;
//GuiState state = guiState;
- bool clicked = false;
int statusBarHeight = RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT;
@@ -1379,22 +1489,23 @@ bool GuiWindowBox(Rectangle bounds, const char *title)
#if defined(RAYGUI_NO_ICONS)
clicked = GuiButton(closeButtonRec, "x");
#else
- clicked = GuiButton(closeButtonRec, GuiIconText(ICON_CROSS_SMALL, NULL));
+ result = GuiButton(closeButtonRec, GuiIconText(ICON_CROSS_SMALL, NULL));
#endif
GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth);
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, tempTextAlignment);
//--------------------------------------------------------------------
- return clicked;
+ return result; // Window close button clicked: result = 1
}
// Group Box control with text name
-void GuiGroupBox(Rectangle bounds, const char *text)
+int GuiGroupBox(Rectangle bounds, const char *text)
{
#if !defined(RAYGUI_GROUPBOX_LINE_THICK)
#define RAYGUI_GROUPBOX_LINE_THICK 1
#endif
+ int result = 0;
GuiState state = guiState;
// Draw control
@@ -1405,10 +1516,12 @@ void GuiGroupBox(Rectangle bounds, const char *text)
GuiLine(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y - GuiGetStyle(DEFAULT, TEXT_SIZE)/2, bounds.width, (float)GuiGetStyle(DEFAULT, TEXT_SIZE) }, text);
//--------------------------------------------------------------------
+
+ return result;
}
// Line control
-void GuiLine(Rectangle bounds, const char *text)
+int GuiLine(Rectangle bounds, const char *text)
{
#if !defined(RAYGUI_LINE_ORIGIN_SIZE)
#define RAYGUI_LINE_MARGIN_TEXT 12
@@ -1417,6 +1530,7 @@ void GuiLine(Rectangle bounds, const char *text)
#define RAYGUI_LINE_TEXT_PADDING 4
#endif
+ int result = 0;
GuiState state = guiState;
Color color = Fade(GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)), guiAlpha);
@@ -1427,7 +1541,7 @@ void GuiLine(Rectangle bounds, const char *text)
else
{
Rectangle textBounds = { 0 };
- textBounds.width = (float)GetTextWidth(text);
+ textBounds.width = (float)GetTextWidth(text) + 2;
textBounds.height = bounds.height;
textBounds.x = bounds.x + RAYGUI_LINE_MARGIN_TEXT;
textBounds.y = bounds.y;
@@ -1438,15 +1552,18 @@ void GuiLine(Rectangle bounds, const char *text)
GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x + 12 + textBounds.width + 4, bounds.y + bounds.height/2, bounds.width - textBounds.width - RAYGUI_LINE_MARGIN_TEXT - RAYGUI_LINE_TEXT_PADDING, 1 }, 0, BLANK, color);
}
//--------------------------------------------------------------------
+
+ return result;
}
// Panel control
-void GuiPanel(Rectangle bounds, const char *text)
+int GuiPanel(Rectangle bounds, const char *text)
{
#if !defined(RAYGUI_PANEL_BORDER_WIDTH)
#define RAYGUI_PANEL_BORDER_WIDTH 1
#endif
+ int result = 0;
GuiState state = guiState;
// Text will be drawn as a header bar (if provided)
@@ -1467,13 +1584,91 @@ void GuiPanel(Rectangle bounds, const char *text)
GuiDrawRectangle(bounds, RAYGUI_PANEL_BORDER_WIDTH, Fade(GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED: LINE_COLOR)), guiAlpha),
Fade(GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BASE_COLOR_DISABLED : BACKGROUND_COLOR)), guiAlpha));
//--------------------------------------------------------------------
+
+ return result;
+}
+
+// Tab Bar control
+// NOTE: Using GuiToggle() for the TABS
+int GuiTabBar(Rectangle bounds, const char **text, int count, int *active)
+{
+ #define RAYGUI_TABBAR_ITEM_WIDTH 160
+
+ int result = -1;
+ GuiState state = guiState;
+
+ Rectangle tabBounds = { bounds.x, bounds.y, RAYGUI_TABBAR_ITEM_WIDTH, bounds.height };
+
+ if (*active < 0) *active = 0;
+ else if (*active > count - 1) *active = count - 1;
+
+ int offsetX = 0; // Required in case tabs go out of screen
+ offsetX = (*active + 2)*RAYGUI_TABBAR_ITEM_WIDTH - GetScreenWidth();
+ if (offsetX < 0) offsetX = 0;
+
+ bool toggle = false; // Required for individual toggles
+
+ // Draw control
+ //--------------------------------------------------------------------
+ for (int i = 0; i < count; i++)
+ {
+ tabBounds.x = bounds.x + (RAYGUI_TABBAR_ITEM_WIDTH + 4)*i - offsetX;
+
+ if (tabBounds.x < GetScreenWidth())
+ {
+ // Draw tabs as toggle controls
+ int textAlignment = GuiGetStyle(TOGGLE, TEXT_ALIGNMENT);
+ int textPadding = GuiGetStyle(TOGGLE, TEXT_PADDING);
+ GuiSetStyle(TOGGLE, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
+ GuiSetStyle(TOGGLE, TEXT_PADDING, 8);
+
+ if (i == (*active))
+ {
+ toggle = true;
+ GuiToggle(tabBounds, GuiIconText(12, text[i]), &toggle);
+ }
+ else
+ {
+ toggle = false;
+ GuiToggle(tabBounds, GuiIconText(12, text[i]), &toggle);
+ if (toggle) *active = i;
+ }
+
+ GuiSetStyle(TOGGLE, TEXT_PADDING, textPadding);
+ GuiSetStyle(TOGGLE, TEXT_ALIGNMENT, textAlignment);
+
+ // Draw tab close button
+ // NOTE: Only draw close button for curren tab: if (CheckCollisionPointRec(mousePoint, tabBounds))
+ int tempBorderWidth = GuiGetStyle(BUTTON, BORDER_WIDTH);
+ int tempTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
+ GuiSetStyle(BUTTON, BORDER_WIDTH, 1);
+ GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
+#if defined(RAYGUI_NO_ICONS)
+ if (GuiButton(RAYGUI_CLITERAL(Rectangle){ tabBounds.x + tabBounds.width - 14 - 5, tabBounds.y + 5, 14, 14 }, "x")) result = i;
+#else
+ if (GuiButton(RAYGUI_CLITERAL(Rectangle){ tabBounds.x + tabBounds.width - 14 - 5, tabBounds.y + 5, 14, 14 }, GuiIconText(ICON_CROSS_SMALL, NULL))) result = i;
+#endif
+ GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth);
+ GuiSetStyle(BUTTON, TEXT_ALIGNMENT, tempTextAlignment);
+ }
+ }
+
+ // Draw tab-bar bottom line
+ GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + bounds.height - 1, bounds.width, 1 }, 0, BLANK, GetColor(GuiGetStyle(TOGGLE, BORDER_COLOR_NORMAL)));
+ //--------------------------------------------------------------------
+
+ return result; // Return as result the current TAB closing requested
}
// Scroll Panel control
-Rectangle GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content, Vector2 *scroll)
+int GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content, Vector2 *scroll, Rectangle *view)
{
+ int result = 0;
GuiState state = guiState;
+ Rectangle temp = { 0 };
+ if (view == NULL) view = &temp;
+
Vector2 scrollPos = { 0.0f, 0.0f };
if (scroll != NULL) scrollPos = *scroll;
@@ -1501,17 +1696,17 @@ Rectangle GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content,
Rectangle verticalScrollBar = { (float)((GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)bounds.x + GuiGetStyle(DEFAULT, BORDER_WIDTH) : (float)bounds.x + bounds.width - verticalScrollBarWidth - GuiGetStyle(DEFAULT, BORDER_WIDTH)), (float)bounds.y + GuiGetStyle(DEFAULT, BORDER_WIDTH), (float)verticalScrollBarWidth, (float)bounds.height - horizontalScrollBarWidth - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) };
// Calculate view area (area without the scrollbars)
- Rectangle view = (GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)?
+ *view = (GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)?
RAYGUI_CLITERAL(Rectangle){ bounds.x + verticalScrollBarWidth + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.y + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - verticalScrollBarWidth, bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - horizontalScrollBarWidth } :
RAYGUI_CLITERAL(Rectangle){ bounds.x + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.y + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - verticalScrollBarWidth, bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - horizontalScrollBarWidth };
// Clip view area to the actual content size
- if (view.width > content.width) view.width = content.width;
- if (view.height > content.height) view.height = content.height;
+ if (view->width > content.width) view->width = content.width;
+ if (view->height > content.height) view->height = content.height;
float horizontalMin = hasHorizontalScrollBar? ((GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)-verticalScrollBarWidth : 0) - (float)GuiGetStyle(DEFAULT, BORDER_WIDTH) : (((float)GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)-verticalScrollBarWidth : 0) - (float)GuiGetStyle(DEFAULT, BORDER_WIDTH);
float horizontalMax = hasHorizontalScrollBar? content.width - bounds.width + (float)verticalScrollBarWidth + GuiGetStyle(DEFAULT, BORDER_WIDTH) - (((float)GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)verticalScrollBarWidth : 0) : (float)-GuiGetStyle(DEFAULT, BORDER_WIDTH);
- float verticalMin = hasVerticalScrollBar? 0 : -1;
+ float verticalMin = hasVerticalScrollBar? 0.0f : -1.0f;
float verticalMax = hasVerticalScrollBar? content.height - bounds.height + (float)horizontalScrollBarWidth + (float)GuiGetStyle(DEFAULT, BORDER_WIDTH) : (float)-GuiGetStyle(DEFAULT, BORDER_WIDTH);
// Update control
@@ -1541,8 +1736,8 @@ Rectangle GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content,
#endif
float wheelMove = GetMouseWheelMove();
- // Horizontal scroll (Shift + Mouse wheel)
- if (hasHorizontalScrollBar && (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_SHIFT))) scrollPos.x += wheelMove*20;
+ // Horizontal scroll ((Left Control or Left Shift) + Mouse wheel)
+ if (hasHorizontalScrollBar && (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_LEFT_SHIFT))) scrollPos.x += wheelMove*20;
else scrollPos.y += wheelMove*20; // Vertical scroll
}
}
@@ -1558,7 +1753,7 @@ Rectangle GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content,
//--------------------------------------------------------------------
if (text != NULL) GuiStatusBar(statusBar, text); // Draw panel header as status bar
- GuiDrawRectangle(bounds, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR))); // Draw background
+ GuiDrawRectangle(bounds, 0, BLANK, Fade(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)), guiAlpha)); // Draw background
// Save size of the scrollbar slider
const int slider = GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE);
@@ -1597,34 +1792,37 @@ Rectangle GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content,
if (scroll != NULL) *scroll = scrollPos;
- return view;
+ return result;
}
// Label control
-void GuiLabel(Rectangle bounds, const char *text)
+int GuiLabel(Rectangle bounds, const char *text)
{
+ int result = 0;
GuiState state = guiState;
// Update control
//--------------------------------------------------------------------
- // ...
+ //...
//--------------------------------------------------------------------
// Draw control
//--------------------------------------------------------------------
GuiDrawText(text, GetTextBounds(LABEL, bounds), GuiGetStyle(LABEL, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha));
//--------------------------------------------------------------------
+
+ return result;
}
// Button control, returns true when clicked
-bool GuiButton(Rectangle bounds, const char *text)
+int GuiButton(Rectangle bounds, const char *text)
{
+ int result = 0;
GuiState state = guiState;
- bool pressed = false;
// Update control
//--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && !guiLocked)
+ if ((state != STATE_DISABLED) && !guiLocked && !guiSliderDragging)
{
Vector2 mousePoint = GetMousePosition();
@@ -1634,7 +1832,7 @@ bool GuiButton(Rectangle bounds, const char *text)
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
else state = STATE_FOCUSED;
- if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) pressed = true;
+ if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) result = 1;
}
}
//--------------------------------------------------------------------
@@ -1643,24 +1841,26 @@ bool GuiButton(Rectangle bounds, const char *text)
//--------------------------------------------------------------------
GuiDrawRectangle(bounds, GuiGetStyle(BUTTON, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(BUTTON, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(BUTTON, BASE + (state*3))), guiAlpha));
GuiDrawText(text, GetTextBounds(BUTTON, bounds), GuiGetStyle(BUTTON, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(BUTTON, TEXT + (state*3))), guiAlpha));
+
+ if (state == STATE_FOCUSED) GuiTooltip(bounds);
//------------------------------------------------------------------
- return pressed;
+ return result; // Button pressed: result = 1
}
// Label button control
-bool GuiLabelButton(Rectangle bounds, const char *text)
+int GuiLabelButton(Rectangle bounds, const char *text)
{
GuiState state = guiState;
bool pressed = false;
// NOTE: We force bounds.width to be all text
- float textWidth = MeasureTextEx(guiFont, text, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING)).x;
- if (bounds.width < textWidth) bounds.width = textWidth;
+ float textWidth = (float)GetTextWidth(text);
+ if ((bounds.width - 2*GuiGetStyle(LABEL, BORDER_WIDTH) - 2*GuiGetStyle(LABEL, TEXT_PADDING)) < textWidth) bounds.width = textWidth + 2*GuiGetStyle(LABEL, BORDER_WIDTH) + 2*GuiGetStyle(LABEL, TEXT_PADDING) + 2;
// Update control
//--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && !guiLocked)
+ if ((state != STATE_DISABLED) && !guiLocked && !guiSliderDragging)
{
Vector2 mousePoint = GetMousePosition();
@@ -1684,13 +1884,17 @@ bool GuiLabelButton(Rectangle bounds, const char *text)
}
// Toggle Button control, returns true when active
-bool GuiToggle(Rectangle bounds, const char *text, bool active)
+int GuiToggle(Rectangle bounds, const char *text, bool *active)
{
+ int result = 0;
GuiState state = guiState;
+ bool temp = false;
+ if (active == NULL) active = &temp;
+
// Update control
//--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && !guiLocked)
+ if ((state != STATE_DISABLED) && !guiLocked && !guiSliderDragging)
{
Vector2 mousePoint = GetMousePosition();
@@ -1701,7 +1905,7 @@ bool GuiToggle(Rectangle bounds, const char *text, bool active)
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
{
state = STATE_NORMAL;
- active = !active;
+ *active = !(*active);
}
else state = STATE_FOCUSED;
}
@@ -1712,32 +1916,40 @@ bool GuiToggle(Rectangle bounds, const char *text, bool active)
//--------------------------------------------------------------------
if (state == STATE_NORMAL)
{
- GuiDrawRectangle(bounds, GuiGetStyle(TOGGLE, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TOGGLE, (active? BORDER_COLOR_PRESSED : (BORDER + state*3)))), guiAlpha), Fade(GetColor(GuiGetStyle(TOGGLE, (active? BASE_COLOR_PRESSED : (BASE + state*3)))), guiAlpha));
- GuiDrawText(text, GetTextBounds(TOGGLE, bounds), GuiGetStyle(TOGGLE, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(TOGGLE, (active? TEXT_COLOR_PRESSED : (TEXT + state*3)))), guiAlpha));
+ GuiDrawRectangle(bounds, GuiGetStyle(TOGGLE, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TOGGLE, ((*active)? BORDER_COLOR_PRESSED : (BORDER + state*3)))), guiAlpha), Fade(GetColor(GuiGetStyle(TOGGLE, ((*active)? BASE_COLOR_PRESSED : (BASE + state*3)))), guiAlpha));
+ GuiDrawText(text, GetTextBounds(TOGGLE, bounds), GuiGetStyle(TOGGLE, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(TOGGLE, ((*active)? TEXT_COLOR_PRESSED : (TEXT + state*3)))), guiAlpha));
}
else
{
GuiDrawRectangle(bounds, GuiGetStyle(TOGGLE, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TOGGLE, BORDER + state*3)), guiAlpha), Fade(GetColor(GuiGetStyle(TOGGLE, BASE + state*3)), guiAlpha));
GuiDrawText(text, GetTextBounds(TOGGLE, bounds), GuiGetStyle(TOGGLE, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(TOGGLE, TEXT + state*3)), guiAlpha));
}
+
+ if (state == STATE_FOCUSED) GuiTooltip(bounds);
//--------------------------------------------------------------------
- return active;
+ return result;
}
-// Toggle Group control, returns toggled button index
-int GuiToggleGroup(Rectangle bounds, const char *text, int active)
+// Toggle Group control, returns toggled button codepointIndex
+int GuiToggleGroup(Rectangle bounds, const char *text, int *active)
{
#if !defined(RAYGUI_TOGGLEGROUP_MAX_ITEMS)
#define RAYGUI_TOGGLEGROUP_MAX_ITEMS 32
#endif
+ int result = 0;
float initBoundsX = bounds.x;
+ int temp = 0;
+ if (active == NULL) active = &temp;
+
+ bool toggle = false; // Required for individual toggles
+
// Get substrings items from text (items pointers)
int rows[RAYGUI_TOGGLEGROUP_MAX_ITEMS] = { 0 };
int itemCount = 0;
- const char **items = GuiTextSplit(text, &itemCount, rows);
+ const char **items = GuiTextSplit(text, ';', &itemCount, rows);
int prevRow = rows[0];
@@ -1750,25 +1962,38 @@ int GuiToggleGroup(Rectangle bounds, const char *text, int active)
prevRow = rows[i];
}
- if (i == active) GuiToggle(bounds, items[i], true);
- else if (GuiToggle(bounds, items[i], false) == true) active = i;
+ if (i == (*active))
+ {
+ toggle = true;
+ GuiToggle(bounds, items[i], &toggle);
+ }
+ else
+ {
+ toggle = false;
+ GuiToggle(bounds, items[i], &toggle);
+ if (toggle) *active = i;
+ }
bounds.x += (bounds.width + GuiGetStyle(TOGGLE, GROUP_PADDING));
}
- return active;
+ return result;
}
// Check Box control, returns true when active
-bool GuiCheckBox(Rectangle bounds, const char *text, bool checked)
+int GuiCheckBox(Rectangle bounds, const char *text, bool *checked)
{
+ int result = 0;
GuiState state = guiState;
+ bool temp = false;
+ if (checked == NULL) checked = &temp;
+
Rectangle textBounds = { 0 };
if (text != NULL)
{
- textBounds.width = (float)GetTextWidth(text);
+ textBounds.width = (float)GetTextWidth(text) + 2;
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
textBounds.x = bounds.x + bounds.width + GuiGetStyle(CHECKBOX, TEXT_PADDING);
textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
@@ -1777,7 +2002,7 @@ bool GuiCheckBox(Rectangle bounds, const char *text, bool checked)
// Update control
//--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && !guiLocked)
+ if ((state != STATE_DISABLED) && !guiLocked && !guiSliderDragging)
{
Vector2 mousePoint = GetMousePosition();
@@ -1794,7 +2019,7 @@ bool GuiCheckBox(Rectangle bounds, const char *text, bool checked)
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
else state = STATE_FOCUSED;
- if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) checked = !checked;
+ if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) *checked = !(*checked);
}
}
//--------------------------------------------------------------------
@@ -1803,7 +2028,7 @@ bool GuiCheckBox(Rectangle bounds, const char *text, bool checked)
//--------------------------------------------------------------------
GuiDrawRectangle(bounds, GuiGetStyle(CHECKBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(CHECKBOX, BORDER + (state*3))), guiAlpha), BLANK);
- if (checked)
+ if (*checked)
{
Rectangle check = { bounds.x + GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING),
bounds.y + GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING),
@@ -1815,14 +2040,18 @@ bool GuiCheckBox(Rectangle bounds, const char *text, bool checked)
GuiDrawText(text, textBounds, (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_RIGHT)? TEXT_ALIGN_LEFT : TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha));
//--------------------------------------------------------------------
- return checked;
+ return result;
}
-// Combo Box control, returns selected item index
-int GuiComboBox(Rectangle bounds, const char *text, int active)
+// Combo Box control, returns selected item codepointIndex
+int GuiComboBox(Rectangle bounds, const char *text, int *active)
{
+ int result = 0;
GuiState state = guiState;
+ int temp = 0;
+ if (active == NULL) active = &temp;
+
bounds.width -= (GuiGetStyle(COMBOBOX, COMBO_BUTTON_WIDTH) + GuiGetStyle(COMBOBOX, COMBO_BUTTON_SPACING));
Rectangle selector = { (float)bounds.x + bounds.width + GuiGetStyle(COMBOBOX, COMBO_BUTTON_SPACING),
@@ -1830,14 +2059,14 @@ int GuiComboBox(Rectangle bounds, const char *text, int active)
// Get substrings items from text (items pointers, lengths and count)
int itemCount = 0;
- const char **items = GuiTextSplit(text, &itemCount, NULL);
+ const char **items = GuiTextSplit(text, ';', &itemCount, NULL);
- if (active < 0) active = 0;
- else if (active > itemCount - 1) active = itemCount - 1;
+ if (*active < 0) *active = 0;
+ else if (*active > (itemCount - 1)) *active = itemCount - 1;
// Update control
//--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && !guiLocked && (itemCount > 1))
+ if ((state != STATE_DISABLED) && !guiLocked && (itemCount > 1) && !guiSliderDragging)
{
Vector2 mousePoint = GetMousePosition();
@@ -1846,8 +2075,8 @@ int GuiComboBox(Rectangle bounds, const char *text, int active)
{
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
- active += 1;
- if (active >= itemCount) active = 0;
+ *active += 1;
+ if (*active >= itemCount) *active = 0; // Cyclic combobox
}
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
@@ -1860,7 +2089,7 @@ int GuiComboBox(Rectangle bounds, const char *text, int active)
//--------------------------------------------------------------------
// Draw combo box main
GuiDrawRectangle(bounds, GuiGetStyle(COMBOBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(COMBOBOX, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(COMBOBOX, BASE + (state*3))), guiAlpha));
- GuiDrawText(items[active], GetTextBounds(COMBOBOX, bounds), GuiGetStyle(COMBOBOX, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(COMBOBOX, TEXT + (state*3))), guiAlpha));
+ GuiDrawText(items[*active], GetTextBounds(COMBOBOX, bounds), GuiGetStyle(COMBOBOX, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(COMBOBOX, TEXT + (state*3))), guiAlpha));
// Draw selector using a custom button
// NOTE: BORDER_WIDTH and TEXT_ALIGNMENT forced values
@@ -1869,37 +2098,37 @@ int GuiComboBox(Rectangle bounds, const char *text, int active)
GuiSetStyle(BUTTON, BORDER_WIDTH, 1);
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
- GuiButton(selector, TextFormat("%i/%i", active + 1, itemCount));
+ GuiButton(selector, TextFormat("%i/%i", *active + 1, itemCount));
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, tempTextAlign);
GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth);
//--------------------------------------------------------------------
- return active;
+ return result;
}
// Dropdown Box control
// NOTE: Returns mouse click
-bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMode)
+int GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMode)
{
+ int result = 0;
GuiState state = guiState;
+
int itemSelected = *active;
int itemFocused = -1;
// Get substrings items from text (items pointers, lengths and count)
int itemCount = 0;
- const char **items = GuiTextSplit(text, &itemCount, NULL);
+ const char **items = GuiTextSplit(text, ';', &itemCount, NULL);
Rectangle boundsOpen = bounds;
boundsOpen.height = (itemCount + 1)*(bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING));
Rectangle itemBounds = bounds;
- bool pressed = false; // Check mouse button pressed
-
// Update control
//--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && (editMode || !guiLocked) && (itemCount > 1))
+ if ((state != STATE_DISABLED) && (editMode || !guiLocked) && (itemCount > 1) && !guiSliderDragging)
{
Vector2 mousePoint = GetMousePosition();
@@ -1910,11 +2139,11 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo
// Check if mouse has been pressed or released outside limits
if (!CheckCollisionPointRec(mousePoint, boundsOpen))
{
- if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) pressed = true;
+ if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) result = 1;
}
// Check if already selected item has been pressed again
- if (CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true;
+ if (CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) result = 1;
// Check focused and selected item
for (int i = 0; i < itemCount; i++)
@@ -1928,7 +2157,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo
if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
{
itemSelected = i;
- pressed = true; // Item selected, change to editMode = false
+ result = 1; // Item selected
}
break;
}
@@ -1942,7 +2171,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo
{
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
- pressed = true;
+ result = 1;
state = STATE_PRESSED;
}
else state = STATE_FOCUSED;
@@ -1991,29 +2220,68 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo
//--------------------------------------------------------------------
*active = itemSelected;
- return pressed;
+
+ // TODO: Use result to return more internal states: mouse-press out-of-bounds, mouse-press over selected-item...
+ return result; // Mouse click: result = 1
}
-// Text Box control, updates input text
-// NOTE 2: Returns if KEY_ENTER pressed (useful for data validation)
-bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
+// Text Box control
+// NOTE: Returns true on ENTER pressed (useful for data validation)
+int GuiTextBox(Rectangle bounds, char *text, int bufferSize, bool editMode)
{
- GuiState state = guiState;
- bool pressed = false;
+ #if !defined(RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN)
+ #define RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN 40 // Frames to wait for autocursor movement
+ #endif
+ #if !defined(RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY)
+ #define RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY 1 // Frames delay for autocursor movement
+ #endif
+ int result = 0;
+ GuiState state = guiState;
+
+ Rectangle textBounds = GetTextBounds(TEXTBOX, bounds);
+ int textWidth = GetTextWidth(text) - GetTextWidth(text + textBoxCursorIndex);
+ int textIndexOffset = 0; // Text index offset to start drawing in the box
+
+ int alignmentVertical = GuiGetStyle(TEXTBOX, TEXT_ALIGNMENT_VERTICAL);
+ int multiline = GuiGetStyle(TEXTBOX, TEXT_MULTILINE);
+
+ // Cursor rectangle
+ // NOTE: Position X value should be updated
Rectangle cursor = {
- bounds.x + GuiGetStyle(TEXTBOX, TEXT_PADDING) + GetTextWidth(text) + 2,
- bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE),
- 4,
+ textBounds.x + textWidth + GuiGetStyle(DEFAULT, TEXT_SPACING),
+ textBounds.y + textBounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE),
+ 2,
(float)GuiGetStyle(DEFAULT, TEXT_SIZE)*2
};
+ switch (alignmentVertical)
+ {
+ case 0: cursor.y = textBounds.y + textBounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE); break; // CENTERED
+ case 1: cursor.y = textBounds.y - GuiGetStyle(DEFAULT, TEXT_SIZE)/2; break; // UP
+ case 2: cursor.y = textBounds.y + textBounds.height; break; // DOWN
+ default: break;
+ }
+
if (cursor.height >= bounds.height) cursor.height = bounds.height - GuiGetStyle(TEXTBOX, BORDER_WIDTH)*2;
if (cursor.y < (bounds.y + GuiGetStyle(TEXTBOX, BORDER_WIDTH))) cursor.y = bounds.y + GuiGetStyle(TEXTBOX, BORDER_WIDTH);
+ // Auto-cursor movement logic
+ // NOTE: Cursor moves automatically when key down after some time
+ if (IsKeyDown(KEY_LEFT) || IsKeyDown(KEY_RIGHT) || IsKeyDown(KEY_UP) || IsKeyDown(KEY_DOWN) || IsKeyDown(KEY_BACKSPACE) || IsKeyDown(KEY_DELETE)) autoCursorCooldownCounter++;
+ else
+ {
+ autoCursorCooldownCounter = 0; // GLOBAL: Cursor cooldown counter
+ autoCursorDelayCounter = 0; // GLOBAL: Cursor delay counter
+ }
+
+ // Blink-cursor frame counter
+ //if (!autoCursorMode) blinkCursorFrameCounter++;
+ //else blinkCursorFrameCounter = 0;
+
// Update control
//--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && !guiLocked)
+ if ((state != STATE_DISABLED) && !guiLocked && !guiSliderDragging)
{
Vector2 mousePoint = GetMousePosition();
@@ -2021,51 +2289,158 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
{
state = STATE_PRESSED;
- int key = GetCharPressed(); // Returns codepoint as Unicode
- int keyCount = (int)strlen(text);
- int byteSize = 0;
- const char *textUTF8 = CodepointToUTF8(key, &byteSize);
-
- // Only allow keys in range [32..125]
- if ((keyCount + byteSize) < textSize)
+ // If text does not fit in the textbox and current cursor position is out of bounds,
+ // we add an index offset to text for drawing only what requires depending on cursor
+ while (textWidth >= textBounds.width)
{
- float maxWidth = (bounds.width - (GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING)*2));
+ int nextCodepointSize = 0;
+ GetCodepointNext(text + textIndexOffset, &nextCodepointSize);
- if ((GetTextWidth(text) < (maxWidth - GuiGetStyle(DEFAULT, TEXT_SIZE))) && (key >= 32))
+ textIndexOffset += nextCodepointSize;
+
+ textWidth = GetTextWidth(text + textIndexOffset) - GetTextWidth(text + textBoxCursorIndex);
+ }
+
+ unsigned int textLength = (unsigned int)strlen(text); // Get current text length
+ int codepoint = GetCharPressed(); // Get Unicode codepoint
+ if (multiline && IsKeyPressed(KEY_ENTER)) codepoint = (int)'\n';
+
+ if (textBoxCursorIndex > textLength) textBoxCursorIndex = textLength;
+
+ // Encode codepoint as UTF-8
+ int codepointSize = 0;
+ const char *charEncoded = CodepointToUTF8(codepoint, &codepointSize);
+
+ // Add codepoint to text, at current cursor position
+ // NOTE: Make sure we do not overflow buffer size
+ if (((multiline && (codepoint == (int)'\n')) || (codepoint >= 32)) && ((textLength + codepointSize) < bufferSize))
+ {
+ // Move forward data from cursor position
+ for (int i = (textLength + codepointSize); i > textBoxCursorIndex; i--) text[i] = text[i - codepointSize];
+
+ // Add new codepoint in current cursor position
+ for (int i = 0; i < codepointSize; i++) text[textBoxCursorIndex + i] = charEncoded[i];
+
+ textBoxCursorIndex += codepointSize;
+ textLength += codepointSize;
+
+ // Make sure text last character is EOL
+ text[textLength] = '\0';
+ }
+
+ // Move cursor to start
+ if ((textLength > 0) && IsKeyPressed(KEY_HOME))
+ {
+ textBoxCursorIndex = 0;
+ }
+
+ // Move cursor to end
+ if ((textLength > textBoxCursorIndex) && IsKeyPressed(KEY_END))
+ {
+ textBoxCursorIndex = textLength;
+ }
+
+ // Delete codepoint from text, after current cursor position
+ if ((textLength > textBoxCursorIndex) && (IsKeyPressed(KEY_DELETE) || (IsKeyDown(KEY_DELETE) && (autoCursorCooldownCounter >= RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN))))
+ {
+ autoCursorDelayCounter++;
+
+ if (IsKeyPressed(KEY_DELETE) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0) // Delay every movement some frames
{
- for (int i = 0; i < byteSize; i++)
+ int nextCodepointSize = 0;
+ GetCodepointNext(text + textBoxCursorIndex, &nextCodepointSize);
+
+ // Move backward text from cursor position
+ for (int i = textBoxCursorIndex; i < textLength; i++) text[i] = text[i + nextCodepointSize];
+
+ textLength -= codepointSize;
+
+ // Make sure text last character is EOL
+ text[textLength] = '\0';
+ }
+ }
+
+ // Delete codepoint from text, before current cursor position
+ if ((textLength > 0) && (IsKeyPressed(KEY_BACKSPACE) || (IsKeyDown(KEY_BACKSPACE) && (autoCursorCooldownCounter >= RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN))))
+ {
+ autoCursorDelayCounter++;
+
+ if (IsKeyPressed(KEY_BACKSPACE) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0) // Delay every movement some frames
+ {
+ int prevCodepointSize = 0;
+ GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
+
+ // Move backward text from cursor position
+ for (int i = (textBoxCursorIndex - prevCodepointSize); i < textLength; i++) text[i] = text[i + prevCodepointSize];
+
+ // Prevent cursor index from decrementing past 0
+ if (textBoxCursorIndex > 0)
{
- text[keyCount] = textUTF8[i];
- keyCount++;
+ textBoxCursorIndex -= codepointSize;
+ textLength -= codepointSize;
}
- text[keyCount] = '\0';
+ // Make sure text last character is EOL
+ text[textLength] = '\0';
}
}
- // Delete text
- if (keyCount > 0)
+ // Move cursor position with keys
+ //if (IsKeyDown(KEY_LEFT) && autoCursorMode)
+ if (IsKeyPressed(KEY_LEFT) || (IsKeyDown(KEY_LEFT) && (autoCursorCooldownCounter > RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN)))
{
- if (IsKeyPressed(KEY_BACKSPACE))
+ autoCursorDelayCounter++;
+
+ if (IsKeyPressed(KEY_LEFT) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0) // Delay every movement some frames
{
- while ((keyCount > 0) && ((text[--keyCount] & 0xc0) == 0x80));
- text[keyCount] = '\0';
+ int prevCodepointSize = 0;
+ GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
+
+ if (textBoxCursorIndex >= prevCodepointSize) textBoxCursorIndex -= prevCodepointSize;
+ }
+ }
+ else if (IsKeyPressed(KEY_RIGHT) || (IsKeyDown(KEY_RIGHT) && (autoCursorCooldownCounter > RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN)))
+ {
+ autoCursorDelayCounter++;
+
+ if (IsKeyPressed(KEY_RIGHT) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0) // Delay every movement some frames
+ {
+ int nextCodepointSize = 0;
+ GetCodepointNext(text + textBoxCursorIndex, &nextCodepointSize);
+
+ if ((textBoxCursorIndex + nextCodepointSize) <= textLength) textBoxCursorIndex += nextCodepointSize;
}
}
- if (IsKeyPressed(KEY_ENTER) || (!CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) pressed = true;
+ // TODO: Get cursor rectangle from mouse position
+ //cursor = GetCursorFromMousePosition(bounds, text, mouse); // Gui style considered internally, including wrapMode
- // Check text alignment to position cursor properly
- int textAlignment = GuiGetStyle(TEXTBOX, TEXT_ALIGNMENT);
- if (textAlignment == TEXT_ALIGN_CENTER) cursor.x = bounds.x + GetTextWidth(text)/2 + bounds.width/2 + 1;
- else if (textAlignment == TEXT_ALIGN_RIGHT) cursor.x = bounds.x + bounds.width - GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING);
+ // TODO: Get cursor rectangle from buffer index
+ //cursor = GetCursorFromIndex(bounds, text, index); // Gui style considered internally, including wrapMode
+
+ // Recalculate cursor position.y depending on textBoxCursorIndex
+ cursor.x = bounds.x + GuiGetStyle(TEXTBOX, TEXT_PADDING) + GetTextWidth(text + textIndexOffset) - GetTextWidth(text + textBoxCursorIndex) + GuiGetStyle(DEFAULT, TEXT_SPACING);
+ //if (multiline) cursor.y = GetTextLines()
+
+ // Finish text editing on ENTER (if not multiline mode) or mouse click outside bounds
+ if ((!multiline && IsKeyPressed(KEY_ENTER)) ||
+ (!CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)))
+ {
+ textBoxCursorIndex = 0; // GLOBAL: Reset the shared cursor index
+ result = 1;
+ }
}
else
{
if (CheckCollisionPointRec(mousePoint, bounds))
{
state = STATE_FOCUSED;
- if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true;
+
+ if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
+ {
+ textBoxCursorIndex = (int)strlen(text); // GLOBAL: Place cursor index to the end of current text
+ result = 1;
+ }
}
}
}
@@ -2081,23 +2456,51 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
{
GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_DISABLED)), guiAlpha));
}
- else GuiDrawRectangle(bounds, 1, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), BLANK);
+ else GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), BLANK);
- GuiDrawText(text, GetTextBounds(TEXTBOX, bounds), GuiGetStyle(TEXTBOX, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha));
+ // Draw text considering index offset if required
+ // NOTE: Text index offset depends on cursor position
+ GuiDrawText(text + textIndexOffset, textBounds, GuiGetStyle(TEXTBOX, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha));
// Draw cursor
- if (editMode) GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)), guiAlpha));
+ if (editMode)
+ {
+ //if (autoCursorMode || ((blinkCursorFrameCounter/40)%2 == 0))
+ GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)), guiAlpha));
+ }
+ else if (state == STATE_FOCUSED) GuiTooltip(bounds);
//--------------------------------------------------------------------
+ return result; // Mouse button pressed: result = 1
+}
+
+/*
+// Text Box control with multiple lines
+// NOTE: It's a regular GuiTextBox() but enabling multiline support,
+// unfortunately cursor placement is not working properly so the function is removed
+bool GuiTextBoxMulti(Rectangle bounds, char *text, int bufferSize, bool editMode)
+{
+ bool pressed = false;
+
+ GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT_VERTICAL, 1);
+ GuiSetStyle(TEXTBOX, TEXT_MULTILINE, 1);
+
+ // TODO: Implement methods to calculate cursor position properly
+ pressed = GuiTextBox(bounds, text, bufferSize, editMode);
+
+ GuiSetStyle(TEXTBOX, TEXT_MULTILINE, 0);
+ GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT_VERTICAL, 0);
+
return pressed;
}
+*/
// Spinner control, returns selected value
-bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode)
+int GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode)
{
+ int result = 1;
GuiState state = guiState;
- bool pressed = false;
int tempValue = *value;
Rectangle spinner = { bounds.x + GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_SPACING), bounds.y,
@@ -2108,7 +2511,7 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in
Rectangle textBounds = { 0 };
if (text != NULL)
{
- textBounds.width = (float)GetTextWidth(text);
+ textBounds.width = (float)GetTextWidth(text) + 2;
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
textBounds.x = bounds.x + bounds.width + GuiGetStyle(SPINNER, TEXT_PADDING);
textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
@@ -2117,7 +2520,7 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in
// Update control
//--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && !guiLocked)
+ if ((state != STATE_DISABLED) && !guiLocked && !guiSliderDragging)
{
Vector2 mousePoint = GetMousePosition();
@@ -2146,8 +2549,7 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in
// Draw control
//--------------------------------------------------------------------
- // TODO: Set Spinner properties for ValueBox
- pressed = GuiValueBox(spinner, NULL, &tempValue, minValue, maxValue, editMode);
+ result = GuiValueBox(spinner, NULL, &tempValue, minValue, maxValue, editMode);
// Draw value selector custom buttons
// NOTE: BORDER_WIDTH and TEXT_ALIGNMENT forced values
@@ -2164,19 +2566,19 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in
//--------------------------------------------------------------------
*value = tempValue;
- return pressed;
+ return result;
}
// Value Box control, updates input text with numbers
// NOTE: Requires static variables: frameCounter
-bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode)
+int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode)
{
#if !defined(RAYGUI_VALUEBOX_MAX_CHARS)
#define RAYGUI_VALUEBOX_MAX_CHARS 32
#endif
+ int result = 0;
GuiState state = guiState;
- bool pressed = false;
char textValue[RAYGUI_VALUEBOX_MAX_CHARS + 1] = "\0";
sprintf(textValue, "%i", *value);
@@ -2184,7 +2586,7 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i
Rectangle textBounds = { 0 };
if (text != NULL)
{
- textBounds.width = (float)GetTextWidth(text);
+ textBounds.width = (float)GetTextWidth(text) + 2;
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
textBounds.x = bounds.x + bounds.width + GuiGetStyle(VALUEBOX, TEXT_PADDING);
textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
@@ -2193,7 +2595,7 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i
// Update control
//--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && !guiLocked)
+ if ((state != STATE_DISABLED) && !guiLocked && !guiSliderDragging)
{
Vector2 mousePoint = GetMousePosition();
@@ -2237,7 +2639,7 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i
//if (*value > maxValue) *value = maxValue;
//else if (*value < minValue) *value = minValue;
- if (IsKeyPressed(KEY_ENTER) || (!CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) pressed = true;
+ if (IsKeyPressed(KEY_ENTER) || (!CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) result = 1;
}
else
{
@@ -2247,7 +2649,7 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i
if (CheckCollisionPointRec(mousePoint, bounds))
{
state = STATE_FOCUSED;
- if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true;
+ if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) result = 1;
}
}
}
@@ -2267,7 +2669,7 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i
if (editMode)
{
// NOTE: ValueBox internal text is always centered
- Rectangle cursor = { bounds.x + GetTextWidth(textValue)/2 + bounds.width/2 + 2, bounds.y + 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), 4, bounds.height - 4*GuiGetStyle(VALUEBOX, BORDER_WIDTH) };
+ Rectangle cursor = { bounds.x + GetTextWidth(textValue)/2 + bounds.width/2 + 1, bounds.y + 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), 4, bounds.height - 4*GuiGetStyle(VALUEBOX, BORDER_WIDTH) };
GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER_COLOR_PRESSED)), guiAlpha));
}
@@ -2275,190 +2677,20 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i
GuiDrawText(text, textBounds, (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_RIGHT)? TEXT_ALIGN_LEFT : TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha));
//--------------------------------------------------------------------
- return pressed;
-}
-
-// Text Box control with multiple lines
-bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
-{
- GuiState state = guiState;
- bool pressed = false;
-
- Rectangle textAreaBounds = {
- bounds.x + GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING),
- bounds.y + GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING),
- bounds.width - 2*(GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING)),
- bounds.height - 2*(GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING))
- };
-
- // Cursor position, [x, y] values should be updated
- Rectangle cursor = { 0, -1, 4, (float)GuiGetStyle(DEFAULT, TEXT_SIZE) + 2 };
-
- float scaleFactor = (float)GuiGetStyle(DEFAULT, TEXT_SIZE)/(float)guiFont.baseSize; // Character rectangle scaling factor
-
- // Update control
- //--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && !guiLocked)
- {
- Vector2 mousePoint = GetMousePosition();
-
- if (editMode)
- {
- state = STATE_PRESSED;
-
- // We get an Unicode codepoint
- int codepoint = GetCharPressed();
- int textLength = (int)strlen(text); // Length in bytes (UTF-8 string)
-
- // Introduce characters
- if (textLength < (textSize - 1))
- {
- if (IsKeyPressed(KEY_ENTER))
- {
- text[textLength] = '\n';
- textLength++;
- }
- else if (codepoint >= 32)
- {
- // Supports Unicode inputs -> Encoded to UTF-8
- int charUTF8Length = 0;
- const char *charEncoded = CodepointToUTF8(codepoint, &charUTF8Length);
- memcpy(text + textLength, charEncoded, charUTF8Length);
- textLength += charUTF8Length;
- }
- }
-
- // Delete characters
- if (textLength > 0)
- {
- if (IsKeyPressed(KEY_BACKSPACE))
- {
- if ((unsigned char)text[textLength - 1] < 127)
- {
- // Remove ASCII equivalent character (1 byte)
- textLength--;
- text[textLength] = '\0';
- }
- else
- {
- // Remove latest UTF-8 unicode character introduced (n bytes)
- int charUTF8Length = 0;
- while (((unsigned char)text[textLength - 1 - charUTF8Length] & 0b01000000) == 0) charUTF8Length++;
-
- textLength -= (charUTF8Length + 1);
- text[textLength] = '\0';
- }
- }
- }
-
- // Exit edit mode
- if (!CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true;
- }
- else
- {
- if (CheckCollisionPointRec(mousePoint, bounds))
- {
- state = STATE_FOCUSED;
- if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true;
- }
- }
- }
- //--------------------------------------------------------------------
-
- // Draw control
- //--------------------------------------------------------------------
- if (state == STATE_PRESSED)
- {
- GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_PRESSED)), guiAlpha));
- }
- else if (state == STATE_DISABLED)
- {
- GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_DISABLED)), guiAlpha));
- }
- else GuiDrawRectangle(bounds, 1, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), BLANK);
-
- int wrapMode = 1; // 0-No wrap, 1-Char wrap, 2-Word wrap
- Vector2 cursorPos = { textAreaBounds.x, textAreaBounds.y };
-
- //int lastSpacePos = 0;
- //int lastSpaceWidth = 0;
- //int lastSpaceCursorPos = 0;
-
- for (int i = 0, codepointLength = 0; text[i] != '\0'; i += codepointLength)
- {
- int codepoint = GetCodepoint(text + i, &codepointLength);
- int index = GetGlyphIndex(guiFont, codepoint); // If requested codepoint is not found, we get '?' (0x3f)
- Rectangle atlasRec = guiFont.recs[index];
- GlyphInfo glyphInfo = guiFont.glyphs[index]; // Glyph measures
-
- if ((codepointLength == 1) && (codepoint == '\n'))
- {
- cursorPos.y += (guiFont.baseSize*scaleFactor + GuiGetStyle(TEXTBOX, TEXT_LINES_SPACING)); // Line feed
- cursorPos.x = textAreaBounds.x; // Carriage return
- }
- else
- {
- if (wrapMode == 1)
- {
- int glyphWidth = 0;
- if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX;
- else glyphWidth += (int)(atlasRec.width + glyphInfo.offsetX);
-
- // Jump line if the end of the text box area has been reached
- if ((cursorPos.x + (glyphWidth*scaleFactor)) > (textAreaBounds.x + textAreaBounds.width))
- {
- cursorPos.y += (guiFont.baseSize*scaleFactor + GuiGetStyle(TEXTBOX, TEXT_LINES_SPACING)); // Line feed
- cursorPos.x = textAreaBounds.x; // Carriage return
- }
- }
- else if (wrapMode == 2)
- {
- /*
- if ((codepointLength == 1) && (codepoint == ' '))
- {
- lastSpacePos = i;
- lastSpaceWidth = 0;
- lastSpaceCursorPos = cursorPos.x;
- }
-
- // Jump line if last word reaches end of text box area
- if ((lastSpaceCursorPos + lastSpaceWidth) > (textAreaBounds.x + textAreaBounds.width))
- {
- cursorPos.y += 12; // Line feed
- cursorPos.x = textAreaBounds.x; // Carriage return
- }
- */
- }
-
- // Draw current character glyph
- DrawTextCodepoint(guiFont, codepoint, cursorPos, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha));
-
- int glyphWidth = 0;
- if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX;
- else glyphWidth += (int)(atlasRec.width + glyphInfo.offsetX);
-
- cursorPos.x += (glyphWidth*scaleFactor + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
- //if (i > lastSpacePos) lastSpaceWidth += (atlasRec.width + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
- }
- }
-
- cursor.x = cursorPos.x;
- cursor.y = cursorPos.y;
-
- // Draw cursor position considering text glyphs
- if (editMode) GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)), guiAlpha));
- //--------------------------------------------------------------------
-
- return pressed;
+ return result;
}
// Slider control with pro parameters
// NOTE: Other GuiSlider*() controls use this one
-float GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue, int sliderWidth)
+int GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight, float *value, float minValue, float maxValue, int sliderWidth)
{
+ int result = 0;
GuiState state = guiState;
- int sliderValue = (int)(((value - minValue)/(maxValue - minValue))*(bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH)));
+ float temp = (maxValue - minValue)/2.0f;
+ if (value == NULL) value = &temp;
+
+ int sliderValue = (int)(((*value - minValue)/(maxValue - minValue))*(bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH)));
Rectangle slider = { bounds.x, bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
0, bounds.height - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - 2*GuiGetStyle(SLIDER, SLIDER_PADDING) };
@@ -2480,14 +2712,32 @@ float GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight
{
Vector2 mousePoint = GetMousePosition();
- if (CheckCollisionPointRec(mousePoint, bounds))
+ if (guiSliderDragging) // Keep dragging outside of bounds
+ {
+ if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
+ {
+ if (CHECK_BOUNDS_ID(bounds, guiSliderActive))
+ {
+ // Get equivalent value and slider position from mousePoint.x
+ *value = ((maxValue - minValue)*(mousePoint.x - (float)(bounds.x + sliderWidth/2)))/(float)(bounds.width - sliderWidth) + minValue;
+ }
+ }
+ else
+ {
+ guiSliderDragging = false;
+ guiSliderActive = RAYGUI_CLITERAL(Rectangle){ 0, 0, 0, 0 };
+ }
+ }
+ else if (CheckCollisionPointRec(mousePoint, bounds))
{
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
{
state = STATE_PRESSED;
+ guiSliderDragging = true;
+ guiSliderActive = bounds; // Store bounds as an identifier when dragging starts
// Get equivalent value and slider position from mousePoint.x
- value = ((maxValue - minValue)*(mousePoint.x - (float)(bounds.x + sliderWidth/2)))/(float)(bounds.width - sliderWidth) + minValue;
+ *value = ((maxValue - minValue)*(mousePoint.x - (float)(bounds.x + sliderWidth/2)))/(float)(bounds.width - sliderWidth) + minValue;
if (sliderWidth > 0) slider.x = mousePoint.x - slider.width/2; // Slider
else if (sliderWidth == 0) slider.width = (float)sliderValue; // SliderBar
@@ -2495,8 +2745,8 @@ float GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight
else state = STATE_FOCUSED;
}
- if (value > maxValue) value = maxValue;
- else if (value < minValue) value = minValue;
+ if (*value > maxValue) *value = maxValue;
+ else if (*value < minValue) *value = minValue;
}
// Bar limits check
@@ -2543,35 +2793,39 @@ float GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight
}
//--------------------------------------------------------------------
- return value;
+ return result;
}
// Slider control extended, returns selected value and has text
-float GuiSlider(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue)
+int GuiSlider(Rectangle bounds, const char *textLeft, const char *textRight, float *value, float minValue, float maxValue)
{
return GuiSliderPro(bounds, textLeft, textRight, value, minValue, maxValue, GuiGetStyle(SLIDER, SLIDER_WIDTH));
}
// Slider Bar control extended, returns selected value
-float GuiSliderBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue)
+int GuiSliderBar(Rectangle bounds, const char *textLeft, const char *textRight, float *value, float minValue, float maxValue)
{
return GuiSliderPro(bounds, textLeft, textRight, value, minValue, maxValue, 0);
}
// Progress Bar control extended, shows current progress value
-float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue)
+int GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRight, float *value, float minValue, float maxValue)
{
+ int result = 0;
GuiState state = guiState;
+ float temp = (maxValue - minValue)/2.0f;
+ if (value == NULL) value = &temp;
+
Rectangle progress = { bounds.x + GuiGetStyle(PROGRESSBAR, BORDER_WIDTH),
bounds.y + GuiGetStyle(PROGRESSBAR, BORDER_WIDTH) + GuiGetStyle(PROGRESSBAR, PROGRESS_PADDING), 0,
bounds.height - 2*GuiGetStyle(PROGRESSBAR, BORDER_WIDTH) - 2*GuiGetStyle(PROGRESSBAR, PROGRESS_PADDING) };
// Update control
//--------------------------------------------------------------------
- if (value > maxValue) value = maxValue;
+ if (*value > maxValue) *value = maxValue;
- if (state != STATE_DISABLED) progress.width = ((float)(value/(maxValue - minValue))*(float)(bounds.width - 2*GuiGetStyle(PROGRESSBAR, BORDER_WIDTH)));
+ if (state != STATE_DISABLED) progress.width = ((float)(*value/(maxValue - minValue))*(float)(bounds.width - 2*GuiGetStyle(PROGRESSBAR, BORDER_WIDTH)));
//--------------------------------------------------------------------
// Draw control
@@ -2606,12 +2860,13 @@ float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRig
}
//--------------------------------------------------------------------
- return value;
+ return result;
}
// Status Bar control
-void GuiStatusBar(Rectangle bounds, const char *text)
+int GuiStatusBar(Rectangle bounds, const char *text)
{
+ int result = 0;
GuiState state = guiState;
// Draw control
@@ -2620,16 +2875,19 @@ void GuiStatusBar(Rectangle bounds, const char *text)
Fade(GetColor(GuiGetStyle(STATUSBAR, (state != STATE_DISABLED)? BASE_COLOR_NORMAL : BASE_COLOR_DISABLED)), guiAlpha));
GuiDrawText(text, GetTextBounds(STATUSBAR, bounds), GuiGetStyle(STATUSBAR, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(STATUSBAR, (state != STATE_DISABLED)? TEXT_COLOR_NORMAL : TEXT_COLOR_DISABLED)), guiAlpha));
//--------------------------------------------------------------------
+
+ return result;
}
// Dummy rectangle control, intended for placeholding
-void GuiDummyRec(Rectangle bounds, const char *text)
+int GuiDummyRec(Rectangle bounds, const char *text)
{
+ int result = 0;
GuiState state = guiState;
// Update control
//--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && !guiLocked)
+ if ((state != STATE_DISABLED) && !guiLocked && !guiSliderDragging)
{
Vector2 mousePoint = GetMousePosition();
@@ -2647,25 +2905,32 @@ void GuiDummyRec(Rectangle bounds, const char *text)
GuiDrawRectangle(bounds, 0, BLANK, Fade(GetColor(GuiGetStyle(DEFAULT, (state != STATE_DISABLED)? BASE_COLOR_NORMAL : BASE_COLOR_DISABLED)), guiAlpha));
GuiDrawText(text, GetTextBounds(DEFAULT, bounds), TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(BUTTON, (state != STATE_DISABLED)? TEXT_COLOR_NORMAL : TEXT_COLOR_DISABLED)), guiAlpha));
//------------------------------------------------------------------
+
+ return result;
}
// List View control
-int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active)
+int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int *active)
{
+ int result = 0;
int itemCount = 0;
const char **items = NULL;
- if (text != NULL) items = GuiTextSplit(text, &itemCount, NULL);
+ if (text != NULL) items = GuiTextSplit(text, ';', &itemCount, NULL);
- return GuiListViewEx(bounds, items, itemCount, NULL, scrollIndex, active);
+ result = GuiListViewEx(bounds, items, itemCount, scrollIndex, active, NULL);
+
+ return result;
}
// List View control with extended parameters
-int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active)
+int GuiListViewEx(Rectangle bounds, const char **text, int count, int *scrollIndex, int *active, int *focus)
{
+ int result = 0;
GuiState state = guiState;
+
int itemFocused = (focus == NULL)? -1 : *focus;
- int itemSelected = active;
+ int itemSelected = *active;
// Check if we need a scroll bar
bool useScrollBar = false;
@@ -2689,7 +2954,7 @@ int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, in
// Update control
//--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && !guiLocked)
+ if ((state != STATE_DISABLED) && !guiLocked && !guiSliderDragging)
{
Vector2 mousePoint = GetMousePosition();
@@ -2800,19 +3065,21 @@ int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, in
if (focus != NULL) *focus = itemFocused;
if (scrollIndex != NULL) *scrollIndex = startIndex;
- return itemSelected;
+ *active = itemSelected;
+ return result;
}
// Color Panel control
-Color GuiColorPanel(Rectangle bounds, const char *text, Color color)
+int GuiColorPanel(Rectangle bounds, const char *text, Color *color)
{
- const Color colWhite = { 255, 255, 255, 255 };
- const Color colBlack = { 0, 0, 0, 255 };
-
+ int result = 0;
GuiState state = guiState;
Vector2 pickerSelector = { 0 };
- Vector3 vcolor = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f };
+ const Color colWhite = { 255, 255, 255, 255 };
+ const Color colBlack = { 0, 0, 0, 255 };
+
+ Vector3 vcolor = { (float)color->r/255.0f, (float)color->g/255.0f, (float)color->b/255.0f };
Vector3 hsv = ConvertRGBtoHSV(vcolor);
pickerSelector.x = bounds.x + (float)hsv.y*bounds.width; // HSV: Saturation
@@ -2827,7 +3094,7 @@ Color GuiColorPanel(Rectangle bounds, const char *text, Color color)
// Update control
//--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && !guiLocked)
+ if ((state != STATE_DISABLED) && !guiLocked && !guiSliderDragging)
{
Vector2 mousePoint = GetMousePosition();
@@ -2850,10 +3117,10 @@ Color GuiColorPanel(Rectangle bounds, const char *text, Color color)
Vector3 rgb = ConvertHSVtoRGB(hsv);
// NOTE: Vector3ToColor() only available on raylib 1.8.1
- color = RAYGUI_CLITERAL(Color){ (unsigned char)(255.0f*rgb.x),
+ *color = RAYGUI_CLITERAL(Color){ (unsigned char)(255.0f*rgb.x),
(unsigned char)(255.0f*rgb.y),
(unsigned char)(255.0f*rgb.z),
- (unsigned char)(255.0f*(float)color.a/255.0f) };
+ (unsigned char)(255.0f*(float)color->a/255.0f) };
}
else state = STATE_FOCUSED;
@@ -2880,19 +3147,20 @@ Color GuiColorPanel(Rectangle bounds, const char *text, Color color)
GuiDrawRectangle(bounds, GuiGetStyle(COLORPICKER, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(COLORPICKER, BORDER + state*3)), guiAlpha), BLANK);
//--------------------------------------------------------------------
- return color;
+ return result;
}
// Color Bar Alpha control
// NOTE: Returns alpha value normalized [0..1]
-float GuiColorBarAlpha(Rectangle bounds, const char *text, float alpha)
+int GuiColorBarAlpha(Rectangle bounds, const char *text, float *alpha)
{
#if !defined(RAYGUI_COLORBARALPHA_CHECKED_SIZE)
#define RAYGUI_COLORBARALPHA_CHECKED_SIZE 10
#endif
+ int result = 0;
GuiState state = guiState;
- Rectangle selector = { (float)bounds.x + alpha*bounds.width - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT)/2, (float)bounds.y - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW), (float)GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT), (float)bounds.height + GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW)*2 };
+ Rectangle selector = { (float)bounds.x + (*alpha)*bounds.width - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT)/2, (float)bounds.y - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW), (float)GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT), (float)bounds.height + GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW)*2 };
// Update control
//--------------------------------------------------------------------
@@ -2900,16 +3168,34 @@ float GuiColorBarAlpha(Rectangle bounds, const char *text, float alpha)
{
Vector2 mousePoint = GetMousePosition();
- if (CheckCollisionPointRec(mousePoint, bounds) ||
- CheckCollisionPointRec(mousePoint, selector))
+ if (guiSliderDragging) // Keep dragging outside of bounds
+ {
+ if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
+ {
+ if (CHECK_BOUNDS_ID(bounds, guiSliderActive))
+ {
+ *alpha = (mousePoint.x - bounds.x)/bounds.width;
+ if (*alpha <= 0.0f) *alpha = 0.0f;
+ if (*alpha >= 1.0f) *alpha = 1.0f;
+ }
+ }
+ else
+ {
+ guiSliderDragging = false;
+ guiSliderActive = RAYGUI_CLITERAL(Rectangle){ 0, 0, 0, 0 };
+ }
+ }
+ else if (CheckCollisionPointRec(mousePoint, bounds) || CheckCollisionPointRec(mousePoint, selector))
{
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
{
state = STATE_PRESSED;
+ guiSliderDragging = true;
+ guiSliderActive = bounds; // Store bounds as an identifier when dragging starts
- alpha = (mousePoint.x - bounds.x)/bounds.width;
- if (alpha <= 0.0f) alpha = 0.0f;
- if (alpha >= 1.0f) alpha = 1.0f;
+ *alpha = (mousePoint.x - bounds.x)/bounds.width;
+ if (*alpha <= 0.0f) *alpha = 0.0f;
+ if (*alpha >= 1.0f) *alpha = 1.0f;
//selector.x = bounds.x + (int)(((alpha - 0)/(100 - 0))*(bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH))) - selector.width/2;
}
else state = STATE_FOCUSED;
@@ -2945,7 +3231,7 @@ float GuiColorBarAlpha(Rectangle bounds, const char *text, float alpha)
GuiDrawRectangle(selector, 0, BLANK, Fade(GetColor(GuiGetStyle(COLORPICKER, BORDER + state*3)), guiAlpha));
//--------------------------------------------------------------------
- return alpha;
+ return result;
}
// Color Bar Hue control
@@ -2954,10 +3240,11 @@ float GuiColorBarAlpha(Rectangle bounds, const char *text, float alpha)
// Color GuiColorBarSat() [WHITE->color]
// Color GuiColorBarValue() [BLACK->color], HSV/HSL
// float GuiColorBarLuminance() [BLACK->WHITE]
-float GuiColorBarHue(Rectangle bounds, const char *text, float hue)
+int GuiColorBarHue(Rectangle bounds, const char *text, float *hue)
{
+ int result = 0;
GuiState state = guiState;
- Rectangle selector = { (float)bounds.x - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW), (float)bounds.y + hue/360.0f*bounds.height - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT)/2, (float)bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW)*2, (float)GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT) };
+ Rectangle selector = { (float)bounds.x - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW), (float)bounds.y + (*hue)/360.0f*bounds.height - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT)/2, (float)bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW)*2, (float)GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT) };
// Update control
//--------------------------------------------------------------------
@@ -2965,16 +3252,34 @@ float GuiColorBarHue(Rectangle bounds, const char *text, float hue)
{
Vector2 mousePoint = GetMousePosition();
- if (CheckCollisionPointRec(mousePoint, bounds) ||
- CheckCollisionPointRec(mousePoint, selector))
+ if (guiSliderDragging) // Keep dragging outside of bounds
+ {
+ if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
+ {
+ if (CHECK_BOUNDS_ID(bounds, guiSliderActive))
+ {
+ *hue = (mousePoint.y - bounds.y)*360/bounds.height;
+ if (*hue <= 0.0f) *hue = 0.0f;
+ if (*hue >= 359.0f) *hue = 359.0f;
+ }
+ }
+ else
+ {
+ guiSliderDragging = false;
+ guiSliderActive = RAYGUI_CLITERAL(Rectangle){ 0, 0, 0, 0 };
+ }
+ }
+ else if (CheckCollisionPointRec(mousePoint, bounds) || CheckCollisionPointRec(mousePoint, selector))
{
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
{
state = STATE_PRESSED;
+ guiSliderDragging = true;
+ guiSliderActive = bounds; // Store bounds as an identifier when dragging starts
- hue = (mousePoint.y - bounds.y)*360/bounds.height;
- if (hue <= 0.0f) hue = 0.0f;
- if (hue >= 359.0f) hue = 359.0f;
+ *hue = (mousePoint.y - bounds.y)*360/bounds.height;
+ if (*hue <= 0.0f) *hue = 0.0f;
+ if (*hue >= 359.0f) *hue = 359.0f;
}
else state = STATE_FOCUSED;
@@ -2998,12 +3303,12 @@ float GuiColorBarHue(Rectangle bounds, const char *text, float hue)
if (state != STATE_DISABLED)
{
// Draw hue bar:color bars
- DrawRectangleGradientV((int)bounds.x, (int)(bounds.y), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 255, 0, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 255, 255, 0, 255 }, guiAlpha));
- DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + bounds.height/6), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 255, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 0, 255, 0, 255 }, guiAlpha));
- DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 2*(bounds.height/6)), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 0, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 0, 255, 255, 255 }, guiAlpha));
- DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 3*(bounds.height/6)), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 0, 255, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 0, 0, 255, 255 }, guiAlpha));
- DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 4*(bounds.height/6)), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 0, 0, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 255, 0, 255, 255 }, guiAlpha));
- DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 5*(bounds.height/6)), (int)bounds.width, (int)(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 255, 0, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 255, 0, 0, 255 }, guiAlpha));
+ DrawRectangleGradientV((int)bounds.x, (int)(bounds.y), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color){ 255, 0, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 255, 255, 0, 255 }, guiAlpha));
+ DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + bounds.height/6), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color){ 255, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 0, 255, 0, 255 }, guiAlpha));
+ DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 2*(bounds.height/6)), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color){ 0, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 0, 255, 255, 255 }, guiAlpha));
+ DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 3*(bounds.height/6)), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color){ 0, 255, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 0, 0, 255, 255 }, guiAlpha));
+ DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 4*(bounds.height/6)), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color){ 0, 0, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 255, 0, 255, 255 }, guiAlpha));
+ DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 5*(bounds.height/6)), (int)bounds.width, (int)(bounds.height/6), Fade(RAYGUI_CLITERAL(Color){ 255, 0, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 255, 0, 0, 255 }, guiAlpha));
}
else DrawRectangleGradientV((int)bounds.x, (int)bounds.y, (int)bounds.width, (int)bounds.height, Fade(Fade(GetColor(GuiGetStyle(COLORPICKER, BASE_COLOR_DISABLED)), 0.1f), guiAlpha), Fade(GetColor(GuiGetStyle(COLORPICKER, BORDER_COLOR_DISABLED)), guiAlpha));
@@ -3013,7 +3318,7 @@ float GuiColorBarHue(Rectangle bounds, const char *text, float hue)
GuiDrawRectangle(selector, 0, BLANK, Fade(GetColor(GuiGetStyle(COLORPICKER, BORDER + state*3)), guiAlpha));
//--------------------------------------------------------------------
- return hue;
+ return result;
}
// Color Picker control
@@ -3022,21 +3327,28 @@ float GuiColorBarHue(Rectangle bounds, const char *text, float hue)
// float GuiColorBarAlpha(Rectangle bounds, float alpha)
// float GuiColorBarHue(Rectangle bounds, float value)
// NOTE: bounds define GuiColorPanel() size
-Color GuiColorPicker(Rectangle bounds, const char *text, Color color)
+int GuiColorPicker(Rectangle bounds, const char *text, Color *color)
{
- color = GuiColorPanel(bounds, NULL, color);
+ int result = 0;
+
+ Color temp = { 200, 0, 0, 255 };
+ if (color == NULL) color = &temp;
+
+ GuiColorPanel(bounds, NULL, color);
Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height };
//Rectangle boundsAlpha = { bounds.x, bounds.y + bounds.height + GuiGetStyle(COLORPICKER, BARS_PADDING), bounds.width, GuiGetStyle(COLORPICKER, BARS_THICK) };
- Vector3 hsv = ConvertRGBtoHSV(RAYGUI_CLITERAL(Vector3){ color.r/255.0f, color.g/255.0f, color.b/255.0f });
- hsv.x = GuiColorBarHue(boundsHue, NULL, hsv.x);
+ Vector3 hsv = ConvertRGBtoHSV(RAYGUI_CLITERAL(Vector3){ (*color).r/255.0f, (*color).g/255.0f, (*color).b/255.0f });
+
+ GuiColorBarHue(boundsHue, NULL, &hsv.x);
+
//color.a = (unsigned char)(GuiColorBarAlpha(boundsAlpha, (float)color.a/255.0f)*255.0f);
Vector3 rgb = ConvertHSVtoRGB(hsv);
- color = RAYGUI_CLITERAL(Color){ (unsigned char)roundf(rgb.x*255.0f), (unsigned char)roundf(rgb.y*255.0f), (unsigned char)roundf(rgb.z*255.0f), color.a };
+ *color = RAYGUI_CLITERAL(Color){ (unsigned char)roundf(rgb.x*255.0f), (unsigned char)roundf(rgb.y*255.0f), (unsigned char)roundf(rgb.z*255.0f), (*color).a };
- return color;
+ return result;
}
// Message Box control
@@ -3049,27 +3361,27 @@ int GuiMessageBox(Rectangle bounds, const char *title, const char *message, cons
#define RAYGUI_MESSAGEBOX_BUTTON_PADDING 12
#endif
- int clicked = -1; // Returns clicked button from buttons list, 0 refers to closed window button
+ int result = -1; // Returns clicked button from buttons list, 0 refers to closed window button
int buttonCount = 0;
- const char **buttonsText = GuiTextSplit(buttons, &buttonCount, NULL);
+ const char **buttonsText = GuiTextSplit(buttons, ';', &buttonCount, NULL);
Rectangle buttonBounds = { 0 };
buttonBounds.x = bounds.x + RAYGUI_MESSAGEBOX_BUTTON_PADDING;
buttonBounds.y = bounds.y + bounds.height - RAYGUI_MESSAGEBOX_BUTTON_HEIGHT - RAYGUI_MESSAGEBOX_BUTTON_PADDING;
buttonBounds.width = (bounds.width - RAYGUI_MESSAGEBOX_BUTTON_PADDING*(buttonCount + 1))/buttonCount;
buttonBounds.height = RAYGUI_MESSAGEBOX_BUTTON_HEIGHT;
- Vector2 textSize = MeasureTextEx(guiFont, message, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), 1);
+ int textWidth = GetTextWidth(message);
Rectangle textBounds = { 0 };
- textBounds.x = bounds.x + bounds.width/2 - textSize.x/2;
+ textBounds.x = bounds.x + bounds.width/2 - textWidth/2;
textBounds.y = bounds.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + RAYGUI_MESSAGEBOX_BUTTON_PADDING;
- textBounds.width = textSize.x;
+ textBounds.width = (float)textWidth;
textBounds.height = bounds.height - RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - 3*RAYGUI_MESSAGEBOX_BUTTON_PADDING - RAYGUI_MESSAGEBOX_BUTTON_HEIGHT;
// Draw control
//--------------------------------------------------------------------
- if (GuiWindowBox(bounds, title)) clicked = 0;
+ if (GuiWindowBox(bounds, title)) result = 0;
int prevTextAlignment = GuiGetStyle(LABEL, TEXT_ALIGNMENT);
GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
@@ -3081,37 +3393,37 @@ int GuiMessageBox(Rectangle bounds, const char *title, const char *message, cons
for (int i = 0; i < buttonCount; i++)
{
- if (GuiButton(buttonBounds, buttonsText[i])) clicked = i + 1;
+ if (GuiButton(buttonBounds, buttonsText[i])) result = i + 1;
buttonBounds.x += (buttonBounds.width + RAYGUI_MESSAGEBOX_BUTTON_PADDING);
}
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, prevTextAlignment);
//--------------------------------------------------------------------
- return clicked;
+ return result;
}
// Text Input Box control, ask for text
-int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text, int textMaxSize, int *secretViewActive)
+int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text, int textMaxSize, bool *secretViewActive)
{
#if !defined(RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT)
- #define RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT 28
+ #define RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT 24
#endif
#if !defined(RAYGUI_TEXTINPUTBOX_BUTTON_PADDING)
#define RAYGUI_TEXTINPUTBOX_BUTTON_PADDING 12
#endif
#if !defined(RAYGUI_TEXTINPUTBOX_HEIGHT)
- #define RAYGUI_TEXTINPUTBOX_HEIGHT 28
+ #define RAYGUI_TEXTINPUTBOX_HEIGHT 26
#endif
// Used to enable text edit mode
// WARNING: No more than one GuiTextInputBox() should be open at the same time
static bool textEditMode = false;
- int btnIndex = -1;
+ int result = -1;
int buttonCount = 0;
- const char **buttonsText = GuiTextSplit(buttons, &buttonCount, NULL);
+ const char **buttonsText = GuiTextSplit(buttons, ';', &buttonCount, NULL);
Rectangle buttonBounds = { 0 };
buttonBounds.x = bounds.x + RAYGUI_TEXTINPUTBOX_BUTTON_PADDING;
buttonBounds.y = bounds.y + bounds.height - RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT - RAYGUI_TEXTINPUTBOX_BUTTON_PADDING;
@@ -3123,12 +3435,12 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co
Rectangle textBounds = { 0 };
if (message != NULL)
{
- Vector2 textSize = MeasureTextEx(guiFont, message, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), 1);
+ int textSize = GetTextWidth(message) + 2;
- textBounds.x = bounds.x + bounds.width/2 - textSize.x/2;
- textBounds.y = bounds.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + messageInputHeight/4 - textSize.y/2;
- textBounds.width = textSize.x;
- textBounds.height = textSize.y;
+ textBounds.x = bounds.x + bounds.width/2 - textSize/2;
+ textBounds.y = bounds.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + messageInputHeight/4 - (float)GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
+ textBounds.width = (float)textSize;
+ textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
}
Rectangle textBoxBounds = { 0 };
@@ -3141,7 +3453,7 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co
// Draw control
//--------------------------------------------------------------------
- if (GuiWindowBox(bounds, title)) btnIndex = 0;
+ if (GuiWindowBox(bounds, title)) result = 0;
// Draw message if available
if (message != NULL)
@@ -3155,10 +3467,10 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co
if (secretViewActive != NULL)
{
static char stars[] = "****************";
- if (GuiTextBox(RAYGUI_CLITERAL(Rectangle){ textBoxBounds.x, textBoxBounds.y, textBoxBounds.width - 4 - RAYGUI_TEXTINPUTBOX_HEIGHT, textBoxBounds.height },
+ if (GuiTextBox(RAYGUI_CLITERAL(Rectangle){ textBoxBounds.x, textBoxBounds.y, textBoxBounds.width - 4 - RAYGUI_TEXTINPUTBOX_HEIGHT, textBoxBounds.height },
((*secretViewActive == 1) || textEditMode)? text : stars, textMaxSize, textEditMode)) textEditMode = !textEditMode;
- *secretViewActive = GuiToggle(RAYGUI_CLITERAL(Rectangle){ textBoxBounds.x + textBoxBounds.width - RAYGUI_TEXTINPUTBOX_HEIGHT, textBoxBounds.y, RAYGUI_TEXTINPUTBOX_HEIGHT, RAYGUI_TEXTINPUTBOX_HEIGHT }, (*secretViewActive == 1)? "#44#" : "#45#", *secretViewActive);
+ GuiToggle(RAYGUI_CLITERAL(Rectangle){ textBoxBounds.x + textBoxBounds.width - RAYGUI_TEXTINPUTBOX_HEIGHT, textBoxBounds.y, RAYGUI_TEXTINPUTBOX_HEIGHT, RAYGUI_TEXTINPUTBOX_HEIGHT }, (*secretViewActive == 1)? "#44#" : "#45#", secretViewActive);
}
else
{
@@ -3170,52 +3482,53 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co
for (int i = 0; i < buttonCount; i++)
{
- if (GuiButton(buttonBounds, buttonsText[i])) btnIndex = i + 1;
+ if (GuiButton(buttonBounds, buttonsText[i])) result = i + 1;
buttonBounds.x += (buttonBounds.width + RAYGUI_MESSAGEBOX_BUTTON_PADDING);
}
+ if (result >= 0) textEditMode = false;
+
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, prevBtnTextAlignment);
//--------------------------------------------------------------------
- return btnIndex;
+ return result; // Result is the pressed button index
}
// Grid control
// NOTE: Returns grid mouse-hover selected cell
// About drawing lines at subpixel spacing, simple put, not easy solution:
// https://stackoverflow.com/questions/4435450/2d-opengl-drawing-lines-that-dont-exactly-fit-pixel-raster
-Vector2 GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs)
+int GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs, Vector2 *mouseCell)
{
// Grid lines alpha amount
#if !defined(RAYGUI_GRID_ALPHA)
#define RAYGUI_GRID_ALPHA 0.15f
#endif
+ int result = 0;
GuiState state = guiState;
+
Vector2 mousePoint = GetMousePosition();
- Vector2 currentCell = { -1, -1 };
+ Vector2 currentMouseCell = { 0 };
int linesV = ((int)(bounds.width/spacing))*subdivs + 1;
int linesH = ((int)(bounds.height/spacing))*subdivs + 1;
// Update control
//--------------------------------------------------------------------
- if ((state != STATE_DISABLED) && !guiLocked)
+ if ((state != STATE_DISABLED) && !guiLocked && !guiSliderDragging)
{
if (CheckCollisionPointRec(mousePoint, bounds))
{
- // NOTE: Cell values must be rounded to int
- currentCell.x = (int)((mousePoint.x - bounds.x)/spacing);
- currentCell.y = (int)((mousePoint.y - bounds.y)/spacing);
+ // NOTE: Cell values must be the upper left of the cell the mouse is in
+ currentMouseCell.x = floorf((mousePoint.x - bounds.x)/spacing);
+ currentMouseCell.y = floorf((mousePoint.y - bounds.y)/spacing);
}
}
//--------------------------------------------------------------------
// Draw control
//--------------------------------------------------------------------
-
- // TODO: Draw background panel?
-
switch (state)
{
case STATE_NORMAL:
@@ -3240,9 +3553,24 @@ Vector2 GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs)
default: break;
}
- return currentCell;
+ if (mouseCell != NULL) *mouseCell = currentMouseCell;
+ return result;
}
+//----------------------------------------------------------------------------------
+// Tooltip management functions
+// NOTE: Tooltips requires some global variables: tooltipPtr
+//----------------------------------------------------------------------------------
+// Enable gui tooltips (global state)
+void GuiEnableTooltip(void) { guiTooltip = true; }
+
+// Disable gui tooltips (global state)
+void GuiDisableTooltip(void) { guiTooltip = false; }
+
+// Set tooltip string
+void GuiSetTooltip(const char *tooltip) { guiTooltipPtr = tooltip; }
+
+
//----------------------------------------------------------------------------------
// Styles loading functions
//----------------------------------------------------------------------------------
@@ -3338,125 +3666,24 @@ void GuiLoadStyle(const char *fileName)
{
rgsFile = fopen(fileName, "rb");
- if (rgsFile == NULL) return;
-
- char signature[5] = { 0 };
- short version = 0;
- short reserved = 0;
- int propertyCount = 0;
-
- fread(signature, 1, 4, rgsFile);
- fread(&version, 1, sizeof(short), rgsFile);
- fread(&reserved, 1, sizeof(short), rgsFile);
- fread(&propertyCount, 1, sizeof(int), rgsFile);
-
- if ((signature[0] == 'r') &&
- (signature[1] == 'G') &&
- (signature[2] == 'S') &&
- (signature[3] == ' '))
+ if (rgsFile != NULL)
{
- short controlId = 0;
- short propertyId = 0;
- unsigned int propertyValue = 0;
+ fseek(rgsFile, 0, SEEK_END);
+ int fileDataSize = ftell(rgsFile);
+ fseek(rgsFile, 0, SEEK_SET);
- for (int i = 0; i < propertyCount; i++)
+ if (fileDataSize > 0)
{
- fread(&controlId, 1, sizeof(short), rgsFile);
- fread(&propertyId, 1, sizeof(short), rgsFile);
- fread(&propertyValue, 1, sizeof(unsigned int), rgsFile);
+ unsigned char *fileData = (unsigned char *)RL_MALLOC(fileDataSize*sizeof(unsigned char));
+ fread(fileData, sizeof(unsigned char), fileDataSize, rgsFile);
- if (controlId == 0) // DEFAULT control
- {
- // If a DEFAULT property is loaded, it is propagated to all controls
- // NOTE: All DEFAULT properties should be defined first in the file
- GuiSetStyle(0, (int)propertyId, propertyValue);
+ GuiLoadStyleFromMemory(fileData, fileDataSize);
- if (propertyId < RAYGUI_MAX_PROPS_BASE) for (int i = 1; i < RAYGUI_MAX_CONTROLS; i++) GuiSetStyle(i, (int)propertyId, propertyValue);
- }
- else GuiSetStyle((int)controlId, (int)propertyId, propertyValue);
+ RL_FREE(fileData);
}
- // Font loading is highly dependant on raylib API to load font data and image
-#if !defined(RAYGUI_STANDALONE)
- // Load custom font if available
- int fontDataSize = 0;
- fread(&fontDataSize, 1, sizeof(int), rgsFile);
-
- if (fontDataSize > 0)
- {
- Font font = { 0 };
- int fontType = 0; // 0-Normal, 1-SDF
- Rectangle whiteRec = { 0 };
-
- fread(&font.baseSize, 1, sizeof(int), rgsFile);
- fread(&font.glyphCount, 1, sizeof(int), rgsFile);
- fread(&fontType, 1, sizeof(int), rgsFile);
-
- // Load font white rectangle
- fread(&whiteRec, 1, sizeof(Rectangle), rgsFile);
-
- // Load font image parameters
- int fontImageUncompSize = 0;
- int fontImageCompSize = 0;
- fread(&fontImageUncompSize, 1, sizeof(int), rgsFile);
- fread(&fontImageCompSize, 1, sizeof(int), rgsFile);
-
- Image imFont = { 0 };
- imFont.mipmaps = 1;
- fread(&imFont.width, 1, sizeof(int), rgsFile);
- fread(&imFont.height, 1, sizeof(int), rgsFile);
- fread(&imFont.format, 1, sizeof(int), rgsFile);
-
- if (fontImageCompSize < fontImageUncompSize)
- {
- // Compressed font atlas image data (DEFLATE), it requires DecompressData()
- int dataUncompSize = 0;
- unsigned char *compData = (unsigned char *)RAYGUI_MALLOC(fontImageCompSize);
- fread(compData, 1, fontImageCompSize, rgsFile);
- imFont.data = DecompressData(compData, fontImageCompSize, &dataUncompSize);
-
- // Security check, dataUncompSize must match the provided fontImageUncompSize
- if (dataUncompSize != fontImageUncompSize) RAYGUI_LOG("WARNING: Uncompressed font atlas image data could be corrupted");
-
- RAYGUI_FREE(compData);
- }
- else
- {
- // Font atlas image data is not compressed
- imFont.data = (unsigned char *)RAYGUI_MALLOC(fontImageUncompSize);
- fread(imFont.data, 1, fontImageUncompSize, rgsFile);
- }
-
- if (font.texture.id != GetFontDefault().texture.id) UnloadTexture(font.texture);
- font.texture = LoadTextureFromImage(imFont);
- if (font.texture.id == 0) font = GetFontDefault();
-
- RAYGUI_FREE(imFont.data);
-
- // Load font recs data
- font.recs = (Rectangle *)RAYGUI_CALLOC(font.glyphCount, sizeof(Rectangle));
- for (int i = 0; i < font.glyphCount; i++) fread(&font.recs[i], 1, sizeof(Rectangle), rgsFile);
-
- // Load font chars info data
- font.glyphs = (GlyphInfo *)RAYGUI_CALLOC(font.glyphCount, sizeof(GlyphInfo));
- for (int i = 0; i < font.glyphCount; i++)
- {
- fread(&font.glyphs[i].value, 1, sizeof(int), rgsFile);
- fread(&font.glyphs[i].offsetX, 1, sizeof(int), rgsFile);
- fread(&font.glyphs[i].offsetY, 1, sizeof(int), rgsFile);
- fread(&font.glyphs[i].advanceX, 1, sizeof(int), rgsFile);
- }
-
- GuiSetFont(font);
-
- // Set font texture source rectangle to be used as white texture to draw shapes
- // NOTE: This way, all gui can be draw using a single draw call
- if ((whiteRec.width != 0) && (whiteRec.height != 0)) SetShapesTexture(font.texture, whiteRec);
- }
-#endif
+ fclose(rgsFile);
}
-
- fclose(rgsFile);
}
}
@@ -3493,9 +3720,9 @@ void GuiLoadStyleDefault(void)
GuiSetStyle(CHECKBOX, TEXT_ALIGNMENT, TEXT_ALIGN_RIGHT);
GuiSetStyle(TEXTBOX, TEXT_PADDING, 4);
GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
- GuiSetStyle(VALUEBOX, TEXT_PADDING, 4);
+ GuiSetStyle(VALUEBOX, TEXT_PADDING, 0);
GuiSetStyle(VALUEBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
- GuiSetStyle(SPINNER, TEXT_PADDING, 4);
+ GuiSetStyle(SPINNER, TEXT_PADDING, 0);
GuiSetStyle(SPINNER, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
GuiSetStyle(STATUSBAR, TEXT_PADDING, 8);
GuiSetStyle(STATUSBAR, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
@@ -3515,7 +3742,7 @@ void GuiLoadStyleDefault(void)
GuiSetStyle(COMBOBOX, COMBO_BUTTON_SPACING, 2);
GuiSetStyle(DROPDOWNBOX, ARROW_PADDING, 16);
GuiSetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING, 2);
- GuiSetStyle(TEXTBOX, TEXT_LINES_SPACING, 4);
+ GuiSetStyle(TEXTBOX, TEXT_LINES_SPACING, (int)((float)GuiGetStyle(DEFAULT, TEXT_SIZE)*1.5f));
GuiSetStyle(TEXTBOX, TEXT_INNER_PADDING, 4);
GuiSetStyle(SPINNER, SPIN_BUTTON_WIDTH, 24);
GuiSetStyle(SPINNER, SPIN_BUTTON_SPACING, 2);
@@ -3526,7 +3753,7 @@ void GuiLoadStyleDefault(void)
GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE, 16);
GuiSetStyle(SCROLLBAR, SCROLL_PADDING, 0);
GuiSetStyle(SCROLLBAR, SCROLL_SPEED, 12);
- GuiSetStyle(LISTVIEW, LIST_ITEMS_HEIGHT, 24);
+ GuiSetStyle(LISTVIEW, LIST_ITEMS_HEIGHT, 28);
GuiSetStyle(LISTVIEW, LIST_ITEMS_SPACING, 2);
GuiSetStyle(LISTVIEW, SCROLLBAR_WIDTH, 12);
GuiSetStyle(LISTVIEW, SCROLLBAR_SIDE, SCROLLBAR_RIGHT_SIDE);
@@ -3536,7 +3763,19 @@ void GuiLoadStyleDefault(void)
GuiSetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT, 8);
GuiSetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW, 2);
- guiFont = GetFontDefault(); // Initialize default font
+ if (guiFont.texture.id != GetFontDefault().texture.id)
+ {
+ // Unload previous font texture
+ UnloadTexture(guiFont.texture);
+
+ // Setup default raylib font
+ guiFont = GetFontDefault();
+
+ // NOTE: Default raylib font character 95 is a white square
+ Rectangle whiteChar = guiFont.recs[95];
+ // NOTE: We set up a 1px padding on char rectangle to avoid pixel bleeding on MSAA filtering
+ SetShapesTexture(guiFont.texture, RAYGUI_CLITERAL(Rectangle){ whiteChar.x + 1, whiteChar.y + 1, whiteChar.width - 2, whiteChar.height - 2 });
+ }
}
// Get text with icon id prepended
@@ -3554,28 +3793,27 @@ const char *GuiIconText(int iconId, const char *text)
{
memset(buffer, 0, 1024);
sprintf(buffer, "#%03i#", iconId);
-
+
for (int i = 5; i < 1024; i++)
{
buffer[i] = text[i - 5];
if (text[i - 5] == '\0') break;
}
-
+
return buffer;
}
- else
+ else
{
sprintf(iconBuffer, "#%03i#", iconId & 0x1ff);
-
+
return iconBuffer;
}
#endif
}
#if !defined(RAYGUI_NO_ICONS)
-
// Get full icons data pointer
-unsigned int *GuiGetIcons(void) { return guiIcons; }
+unsigned int *GuiGetIcons(void) { return guiIconsPtr; }
// Load raygui icons file (.rgi)
// NOTE: In case nameIds are required, they can be requested with loadIconsName,
@@ -3620,10 +3858,10 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName)
short iconSize = 0;
fread(signature, 1, 4, rgiFile);
- fread(&version, 1, sizeof(short), rgiFile);
- fread(&reserved, 1, sizeof(short), rgiFile);
- fread(&iconCount, 1, sizeof(short), rgiFile);
- fread(&iconSize, 1, sizeof(short), rgiFile);
+ fread(&version, sizeof(short), 1, rgiFile);
+ fread(&reserved, sizeof(short), 1, rgiFile);
+ fread(&iconCount, sizeof(short), 1, rgiFile);
+ fread(&iconSize, sizeof(short), 1, rgiFile);
if ((signature[0] == 'r') &&
(signature[1] == 'G') &&
@@ -3636,13 +3874,13 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName)
for (int i = 0; i < iconCount; i++)
{
guiIconsName[i] = (char *)RAYGUI_MALLOC(RAYGUI_ICON_MAX_NAME_LENGTH);
- fread(guiIconsName[i], RAYGUI_ICON_MAX_NAME_LENGTH, 1, rgiFile);
+ fread(guiIconsName[i], 1, RAYGUI_ICON_MAX_NAME_LENGTH, rgiFile);
}
}
else fseek(rgiFile, iconCount*RAYGUI_ICON_MAX_NAME_LENGTH, SEEK_CUR);
- // Read icons data directly over guiIcons data array
- fread(guiIcons, iconCount*(iconSize*iconSize/32), sizeof(unsigned int), rgiFile);
+ // Read icons data directly over internal icons array
+ fread(guiIconsPtr, sizeof(unsigned int), iconCount*(iconSize*iconSize/32), rgiFile);
}
fclose(rgiFile);
@@ -3660,7 +3898,7 @@ void GuiDrawIcon(int iconId, int posX, int posY, int pixelSize, Color color)
{
for (int k = 0; k < 32; k++)
{
- if (BIT_CHECK(guiIcons[iconId*RAYGUI_ICON_DATA_ELEMENTS + i], k))
+ if (BIT_CHECK(guiIconsPtr[iconId*RAYGUI_ICON_DATA_ELEMENTS + i], k))
{
#if !defined(RAYGUI_STANDALONE)
DrawRectangle(posX + (k%RAYGUI_ICON_SIZE)*pixelSize, posY + y*pixelSize, pixelSize, pixelSize, color);
@@ -3672,63 +3910,156 @@ void GuiDrawIcon(int iconId, int posX, int posY, int pixelSize, Color color)
}
}
-// Get icon bit data
-// NOTE: Bit data array grouped as unsigned int (RAYGUI_ICON_SIZE*RAYGUI_ICON_SIZE/32 elements)
-unsigned int *GuiGetIconData(int iconId)
+// Set icon drawing size
+void GuiSetIconScale(int scale)
{
- static unsigned int iconData[RAYGUI_ICON_DATA_ELEMENTS] = { 0 };
- memset(iconData, 0, RAYGUI_ICON_DATA_ELEMENTS*sizeof(unsigned int));
-
- if (iconId < RAYGUI_ICON_MAX_ICONS) memcpy(iconData, &guiIcons[iconId*RAYGUI_ICON_DATA_ELEMENTS], RAYGUI_ICON_DATA_ELEMENTS*sizeof(unsigned int));
-
- return iconData;
+ if (scale >= 1) guiIconScale = scale;
}
-// Set icon bit data
-// NOTE: Data must be provided as unsigned int array (RAYGUI_ICON_SIZE*RAYGUI_ICON_SIZE/32 elements)
-void GuiSetIconData(int iconId, unsigned int *data)
-{
- if (iconId < RAYGUI_ICON_MAX_ICONS) memcpy(&guiIcons[iconId*RAYGUI_ICON_DATA_ELEMENTS], data, RAYGUI_ICON_DATA_ELEMENTS*sizeof(unsigned int));
-}
-
-// Set icon scale (1 by default)
-void GuiSetIconScale(unsigned int scale)
-{
- guiIconScale = (scale < 1)? 1 : scale;
-}
-
-// Set icon pixel value
-void GuiSetIconPixel(int iconId, int x, int y)
-{
- #define BIT_SET(a,b) ((a) |= (1u<<(b)))
-
- // This logic works for any RAYGUI_ICON_SIZE pixels icons,
- // For example, in case of 16x16 pixels, every 2 lines fit in one unsigned int data element
- BIT_SET(guiIcons[iconId*RAYGUI_ICON_DATA_ELEMENTS + y/(sizeof(unsigned int)*8/RAYGUI_ICON_SIZE)], x + (y%(sizeof(unsigned int)*8/RAYGUI_ICON_SIZE)*RAYGUI_ICON_SIZE));
-}
-
-// Clear icon pixel value
-void GuiClearIconPixel(int iconId, int x, int y)
-{
- #define BIT_CLEAR(a,b) ((a) &= ~((1u)<<(b)))
-
- // This logic works for any RAYGUI_ICON_SIZE pixels icons,
- // For example, in case of 16x16 pixels, every 2 lines fit in one unsigned int data element
- BIT_CLEAR(guiIcons[iconId*RAYGUI_ICON_DATA_ELEMENTS + y/(sizeof(unsigned int)*8/RAYGUI_ICON_SIZE)], x + (y%(sizeof(unsigned int)*8/RAYGUI_ICON_SIZE)*RAYGUI_ICON_SIZE));
-}
-
-// Check icon pixel value
-bool GuiCheckIconPixel(int iconId, int x, int y)
-{
- #define BIT_CHECK(a,b) ((a) & (1u<<(b)))
-
- return (BIT_CHECK(guiIcons[iconId*8 + y/2], x + (y%2*16)));
-}
#endif // !RAYGUI_NO_ICONS
//----------------------------------------------------------------------------------
// Module specific Functions Definition
//----------------------------------------------------------------------------------
+
+// Load style from memory (binary only)
+static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
+{
+ unsigned char *fileDataPtr = (unsigned char *)fileData;
+
+ char signature[5] = { 0 };
+ short version = 0;
+ short reserved = 0;
+ int propertyCount = 0;
+
+ memcpy(signature, fileDataPtr, 4);
+ memcpy(&version, fileDataPtr + 4, sizeof(short));
+ memcpy(&reserved, fileDataPtr + 4 + 2, sizeof(short));
+ memcpy(&propertyCount, fileDataPtr + 4 + 2 + 2, sizeof(int));
+ fileDataPtr += 12;
+
+ if ((signature[0] == 'r') &&
+ (signature[1] == 'G') &&
+ (signature[2] == 'S') &&
+ (signature[3] == ' '))
+ {
+ short controlId = 0;
+ short propertyId = 0;
+ unsigned int propertyValue = 0;
+
+ for (int i = 0; i < propertyCount; i++)
+ {
+ memcpy(&controlId, fileDataPtr, sizeof(short));
+ memcpy(&propertyId, fileDataPtr + 2, sizeof(short));
+ memcpy(&propertyValue, fileDataPtr + 2 + 2, sizeof(unsigned int));
+ fileDataPtr += 8;
+
+ if (controlId == 0) // DEFAULT control
+ {
+ // If a DEFAULT property is loaded, it is propagated to all controls
+ // NOTE: All DEFAULT properties should be defined first in the file
+ GuiSetStyle(0, (int)propertyId, propertyValue);
+
+ if (propertyId < RAYGUI_MAX_PROPS_BASE) for (int i = 1; i < RAYGUI_MAX_CONTROLS; i++) GuiSetStyle(i, (int)propertyId, propertyValue);
+ }
+ else GuiSetStyle((int)controlId, (int)propertyId, propertyValue);
+ }
+
+ // Font loading is highly dependant on raylib API to load font data and image
+
+#if !defined(RAYGUI_STANDALONE)
+ // Load custom font if available
+ int fontDataSize = 0;
+ memcpy(&fontDataSize, fileDataPtr, sizeof(int));
+ fileDataPtr += 4;
+
+ if (fontDataSize > 0)
+ {
+ Font font = { 0 };
+ int fontType = 0; // 0-Normal, 1-SDF
+ Rectangle whiteRec = { 0 };
+
+ memcpy(&font.baseSize, fileDataPtr, sizeof(int));
+ memcpy(&font.glyphCount, fileDataPtr + 4, sizeof(int));
+ memcpy(&fontType, fileDataPtr + 4 + 4, sizeof(int));
+ fileDataPtr += 12;
+
+ // Load font white rectangle
+ memcpy(&whiteRec, fileDataPtr, sizeof(Rectangle));
+ fileDataPtr += 16;
+
+ // Load font image parameters
+ int fontImageUncompSize = 0;
+ int fontImageCompSize = 0;
+ memcpy(&fontImageUncompSize, fileDataPtr, sizeof(int));
+ memcpy(&fontImageCompSize, fileDataPtr + 4, sizeof(int));
+ fileDataPtr += 8;
+
+ Image imFont = { 0 };
+ imFont.mipmaps = 1;
+ memcpy(&imFont.width, fileDataPtr, sizeof(int));
+ memcpy(&imFont.height, fileDataPtr + 4, sizeof(int));
+ memcpy(&imFont.format, fileDataPtr + 4 + 4, sizeof(int));
+ fileDataPtr += 12;
+
+ if (fontImageCompSize < fontImageUncompSize)
+ {
+ // Compressed font atlas image data (DEFLATE), it requires DecompressData()
+ int dataUncompSize = 0;
+ unsigned char *compData = (unsigned char *)RAYGUI_MALLOC(fontImageCompSize);
+ memcpy(compData, fileDataPtr, fontImageCompSize);
+ fileDataPtr += fontImageCompSize;
+
+ imFont.data = DecompressData(compData, fontImageCompSize, &dataUncompSize);
+
+ // Security check, dataUncompSize must match the provided fontImageUncompSize
+ if (dataUncompSize != fontImageUncompSize) RAYGUI_LOG("WARNING: Uncompressed font atlas image data could be corrupted");
+
+ RAYGUI_FREE(compData);
+ }
+ else
+ {
+ // Font atlas image data is not compressed
+ imFont.data = (unsigned char *)RAYGUI_MALLOC(fontImageUncompSize);
+ memcpy(imFont.data, fileDataPtr, fontImageUncompSize);
+ fileDataPtr += fontImageUncompSize;
+ }
+
+ if (font.texture.id != GetFontDefault().texture.id) UnloadTexture(font.texture);
+ font.texture = LoadTextureFromImage(imFont);
+ if (font.texture.id == 0) font = GetFontDefault();
+
+ RAYGUI_FREE(imFont.data);
+
+ // Load font recs data
+ font.recs = (Rectangle *)RAYGUI_CALLOC(font.glyphCount, sizeof(Rectangle));
+ for (int i = 0; i < font.glyphCount; i++)
+ {
+ memcpy(&font.recs[i], fileDataPtr, sizeof(Rectangle));
+ fileDataPtr += sizeof(Rectangle);
+ }
+
+ // Load font chars info data
+ font.glyphs = (GlyphInfo *)RAYGUI_CALLOC(font.glyphCount, sizeof(GlyphInfo));
+ for (int i = 0; i < font.glyphCount; i++)
+ {
+ memcpy(&font.glyphs[i].value, fileDataPtr, sizeof(int));
+ memcpy(&font.glyphs[i].offsetX, fileDataPtr + 4, sizeof(int));
+ memcpy(&font.glyphs[i].offsetY, fileDataPtr + 8, sizeof(int));
+ memcpy(&font.glyphs[i].advanceX, fileDataPtr + 12, sizeof(int));
+ fileDataPtr += 16;
+ }
+
+ GuiSetFont(font);
+
+ // Set font texture source rectangle to be used as white texture to draw shapes
+ // NOTE: This way, all gui can be draw using a single draw call
+ if ((whiteRec.width != 0) && (whiteRec.height != 0)) SetShapesTexture(font.texture, whiteRec);
+ }
+#endif
+ }
+}
+
// Gui get text width considering icon
static int GetTextWidth(const char *text)
{
@@ -3736,14 +4067,14 @@ static int GetTextWidth(const char *text)
#define ICON_TEXT_PADDING 4
#endif
- Vector2 size = { 0 };
+ Vector2 textSize = { 0 };
int textIconOffset = 0;
if ((text != NULL) && (text[0] != '\0'))
{
if (text[0] == '#')
{
- for (int i = 1; (text[i] != '\0') && (i < 5); i++)
+ for (int i = 1; (i < 5) && (text[i] != '\0'); i++)
{
if (text[i] == '#')
{
@@ -3752,15 +4083,43 @@ static int GetTextWidth(const char *text)
}
}
}
-
+
+ text += textIconOffset;
+
// Make sure guiFont is set, GuiGetStyle() initializes it lazynessly
float fontSize = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
-
- size = MeasureTextEx(guiFont, text + textIconOffset, fontSize, (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
- if (textIconOffset > 0) size.x += (RAYGUI_ICON_SIZE - ICON_TEXT_PADDING);
+
+ // Custom MeasureText() implementation
+ if ((guiFont.texture.id > 0) && (text != NULL))
+ {
+ // Get size in bytes of text, considering end of line and line break
+ int size = 0;
+ for (int i = 0; i < MAX_LINE_BUFFER_SIZE; i++)
+ {
+ if ((text[i] != '\0') && (text[i] != '\n')) size++;
+ else break;
+ }
+
+ float scaleFactor = fontSize/(float)guiFont.baseSize;
+ textSize.y = (float)guiFont.baseSize*scaleFactor;
+ float glyphWidth = 0.0f;
+
+ for (int i = 0, codepointSize = 0; i < size; i += codepointSize)
+ {
+ int codepoint = GetCodepointNext(&text[i], &codepointSize);
+ int codepointIndex = GetGlyphIndex(guiFont, codepoint);
+
+ if (guiFont.glyphs[codepointIndex].advanceX == 0) glyphWidth = ((float)guiFont.recs[codepointIndex].width*scaleFactor + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
+ else glyphWidth = ((float)guiFont.glyphs[codepointIndex].advanceX*scaleFactor + GuiGetStyle(DEFAULT, TEXT_SPACING));
+
+ textSize.x += glyphWidth;
+ }
+ }
+
+ if (textIconOffset > 0) textSize.x += (RAYGUI_ICON_SIZE - ICON_TEXT_PADDING);
}
- return (int)size.x;
+ return (int)textSize.x;
}
// Get text bounds considering control bounds
@@ -3769,25 +4128,23 @@ static Rectangle GetTextBounds(int control, Rectangle bounds)
Rectangle textBounds = bounds;
textBounds.x = bounds.x + GuiGetStyle(control, BORDER_WIDTH);
- textBounds.y = bounds.y + GuiGetStyle(control, BORDER_WIDTH);
- textBounds.width = bounds.width - 2*GuiGetStyle(control, BORDER_WIDTH);
- textBounds.height = bounds.height - 2*GuiGetStyle(control, BORDER_WIDTH);
+ textBounds.y = bounds.y + GuiGetStyle(control, BORDER_WIDTH) + GuiGetStyle(control, TEXT_PADDING);
+ textBounds.width = bounds.width - 2*GuiGetStyle(control, BORDER_WIDTH) - 2*GuiGetStyle(control, TEXT_PADDING);
+ textBounds.height = bounds.height - 2*GuiGetStyle(control, BORDER_WIDTH) - 2*GuiGetStyle(control, TEXT_PADDING);
// Consider TEXT_PADDING properly, depends on control type and TEXT_ALIGNMENT
+ // TODO: Special cases (no label): COMBOBOX, DROPDOWNBOX, LISTVIEW (scrollbar?)
+ // More special cases (label on side): CHECKBOX, SLIDER, VALUEBOX, SPINNER
switch (control)
{
- case COMBOBOX: bounds.width -= (GuiGetStyle(control, COMBO_BUTTON_WIDTH) + GuiGetStyle(control, COMBO_BUTTON_SPACING)); break;
- case VALUEBOX: break; // NOTE: ValueBox text value always centered, text padding applies to label
default:
{
if (GuiGetStyle(control, TEXT_ALIGNMENT) == TEXT_ALIGN_RIGHT) textBounds.x -= GuiGetStyle(control, TEXT_PADDING);
else textBounds.x += GuiGetStyle(control, TEXT_PADDING);
- } break;
+ }
+ break;
}
- // TODO: Special cases (no label): COMBOBOX, DROPDOWNBOX, LISTVIEW (scrollbar?)
- // More special cases (label on side): CHECKBOX, SLIDER, VALUEBOX, SPINNER
-
return textBounds;
}
@@ -3822,6 +4179,39 @@ static const char *GetTextIcon(const char *text, int *iconId)
return text;
}
+// Get text divided into lines (by line-breaks '\n')
+const char **GetTextLines(const char *text, int *count)
+{
+ #define RAYGUI_MAX_TEXT_LINES 128
+
+ static const char *lines[RAYGUI_MAX_TEXT_LINES] = { 0 };
+ for (int i = 0; i < RAYGUI_MAX_TEXT_LINES; i++) lines[i] = NULL; // Init NULL pointers to substrings
+
+ int textSize = (int)strlen(text);
+
+ lines[0] = text;
+ int len = 0;
+ *count = 1;
+ int lineSize = 0; // Stores current line size, not returned
+
+ for (int i = 0, k = 0; (i < textSize) && (*count < RAYGUI_MAX_TEXT_LINES); i++)
+ {
+ if (text[i] == '\n')
+ {
+ lineSize = len;
+ k++;
+ lines[k] = &text[i + 1]; // WARNING: next value is valid?
+ len = 0;
+ *count += 1;
+ }
+ else len++;
+ }
+
+ //lines[*count - 1].size = len;
+
+ return lines;
+}
+
// Gui draw text using default font
static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color tint)
{
@@ -3831,70 +4221,120 @@ static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color
#define ICON_TEXT_PADDING 4
#endif
+ int alignmentVertical = GuiGetStyle(TEXTBOX, TEXT_ALIGNMENT_VERTICAL);
+
+ // We process the text lines one by one
if ((text != NULL) && (text[0] != '\0'))
{
- int iconId = 0;
- text = GetTextIcon(text, &iconId); // Check text for icon and move cursor
+ // Get text lines ('\n' delimiter) to process lines individually
+ // NOTE: We can't use GuiTextSplit() because it can be already used before calling
+ // GuiDrawText() and static buffer would be overriden :(
+ int lineCount = 0;
+ const char **lines = GetTextLines(text, &lineCount);
- // Get text position depending on alignment and iconId
- //---------------------------------------------------------------------------------
- Vector2 position = { bounds.x, bounds.y };
+ //Rectangle textBounds = GetTextBounds(LABEL, bounds);
+ float totalHeight = (float)(lineCount*GuiGetStyle(DEFAULT, TEXT_SIZE) + (lineCount - 1)*GuiGetStyle(DEFAULT, TEXT_SIZE)/2);
+ float posOffsetY = 0;
- // NOTE: We get text size after icon has been processed
- // TODO: REVIEW: We consider text size in case of line breaks! -> MeasureTextEx() depends on raylib!
- Vector2 textSize = MeasureTextEx(GuiGetFont(), text, GuiGetStyle(DEFAULT, TEXT_SIZE), GuiGetStyle(DEFAULT, TEXT_SPACING));
- //int textWidth = GetTextWidth(text);
- //int textHeight = GuiGetStyle(DEFAULT, TEXT_SIZE);
-
- // If text requires an icon, add size to measure
- if (iconId >= 0)
+ for (int i = 0; i < lineCount; i++)
{
- textSize.x += RAYGUI_ICON_SIZE*guiIconScale;
+ int iconId = 0;
+ lines[i] = GetTextIcon(lines[i], &iconId); // Check text for icon and move cursor
- // WARNING: If only icon provided, text could be pointing to EOF character: '\0'
- if ((text != NULL) && (text[0] != '\0')) textSize.x += ICON_TEXT_PADDING;
- }
+ // Get text position depending on alignment and iconId
+ //---------------------------------------------------------------------------------
+ Vector2 position = { bounds.x, bounds.y };
- // Check guiTextAlign global variables
- switch (alignment)
- {
- case TEXT_ALIGN_LEFT:
+ // NOTE: We get text size after icon has been processed
+ // WARNING: GetTextWidth() also processes text icon to get width! -> Really needed?
+ int textSizeX = GetTextWidth(lines[i]);
+
+ // If text requires an icon, add size to measure
+ if (iconId >= 0)
{
- position.x = bounds.x;
- position.y = bounds.y + bounds.height/2 - textSize.y/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height);
- } break;
- case TEXT_ALIGN_CENTER:
- {
- position.x = bounds.x + bounds.width/2 - textSize.x/2;
- position.y = bounds.y + bounds.height/2 - textSize.y/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height);
- } break;
- case TEXT_ALIGN_RIGHT:
- {
- position.x = bounds.x + bounds.width - textSize.x;
- position.y = bounds.y + bounds.height/2 - textSize.y/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height);
- } break;
- default: break;
- }
+ textSizeX += RAYGUI_ICON_SIZE*guiIconScale;
- // NOTE: Make sure we get pixel-perfect coordinates,
- // In case of decimals we got weird text positioning
- position.x = (float)((int)position.x);
- position.y = (float)((int)position.y);
- //---------------------------------------------------------------------------------
+ // WARNING: If only icon provided, text could be pointing to EOF character: '\0'
+ if ((lines[i] != NULL) && (lines[i][0] != '\0')) textSizeX += ICON_TEXT_PADDING;
+ }
- // Draw text (with icon if available)
- //---------------------------------------------------------------------------------
+ // Check guiTextAlign global variables
+ switch (alignment)
+ {
+ case TEXT_ALIGN_LEFT: position.x = bounds.x; break;
+ case TEXT_ALIGN_CENTER: position.x = bounds.x + bounds.width/2 - textSizeX/2; break;
+ case TEXT_ALIGN_RIGHT: position.x = bounds.x + bounds.width - textSizeX; break;
+ default: break;
+ }
+
+ switch (alignmentVertical)
+ {
+ case 0: position.y = bounds.y + posOffsetY + bounds.height/2 - totalHeight/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height); break; // CENTERED
+ case 1: position.y = bounds.y + posOffsetY; break; // UP
+ case 2: position.y = bounds.y + posOffsetY + bounds.height - totalHeight + TEXT_VALIGN_PIXEL_OFFSET(bounds.height); break; // DOWN
+ default: break;
+ }
+
+ // NOTE: Make sure we get pixel-perfect coordinates,
+ // In case of decimals we got weird text positioning
+ position.x = (float)((int)position.x);
+ position.y = (float)((int)position.y);
+ //---------------------------------------------------------------------------------
+
+ // Draw text (with icon if available)
+ //---------------------------------------------------------------------------------
#if !defined(RAYGUI_NO_ICONS)
- if (iconId >= 0)
- {
- // NOTE: We consider icon height, probably different than text size
- GuiDrawIcon(iconId, (int)position.x, (int)(bounds.y + bounds.height/2 - RAYGUI_ICON_SIZE*guiIconScale/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height)), guiIconScale, tint);
- position.x += (RAYGUI_ICON_SIZE*guiIconScale + ICON_TEXT_PADDING);
- }
+ if (iconId >= 0)
+ {
+ // NOTE: We consider icon height, probably different than text size
+ GuiDrawIcon(iconId, (int)position.x, (int)(bounds.y + bounds.height/2 - RAYGUI_ICON_SIZE*guiIconScale/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height)), guiIconScale, tint);
+ position.x += (RAYGUI_ICON_SIZE*guiIconScale + ICON_TEXT_PADDING);
+ }
#endif
- DrawTextEx(guiFont, text, position, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING), tint);
- //---------------------------------------------------------------------------------
+ //DrawTextEx(guiFont, text, position, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING), tint);
+
+ // Get size in bytes of text,
+ // considering end of line and line break
+ int size = 0;
+ for (int c = 0; (lines[i][c] != '\0') && (lines[i][c] != '\n'); c++, size++){ }
+ float scaleFactor = (float)GuiGetStyle(DEFAULT, TEXT_SIZE)/guiFont.baseSize;
+
+ int textOffsetY = 0;
+ float textOffsetX = 0.0f;
+ for (int c = 0, codepointSize = 0; c < size; c += codepointSize)
+ {
+ int codepoint = GetCodepointNext(&lines[i][c], &codepointSize);
+ int index = GetGlyphIndex(guiFont, codepoint);
+
+ // NOTE: Normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
+ // but we need to draw all of the bad bytes using the '?' symbol moving one byte
+ if (codepoint == 0x3f) codepointSize = 1;
+
+ if (codepoint == '\n') break; // WARNING: Lines are already processed manually, no need to keep drawing after this codepoint
+ else
+ {
+ if ((codepoint != ' ') && (codepoint != '\t'))
+ {
+ // Draw only required text glyphs fitting the bounds.width
+ if (textOffsetX < (bounds.width - guiFont.recs[index].width))
+ {
+ DrawTextCodepoint(guiFont, codepoint, RAYGUI_CLITERAL(Vector2){ position.x + textOffsetX, position.y + textOffsetY }, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), tint);
+ }
+ }
+
+ if (guiFont.glyphs[index].advanceX == 0) textOffsetX += ((float)guiFont.recs[index].width*scaleFactor + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
+ else textOffsetX += ((float)guiFont.glyphs[index].advanceX*scaleFactor + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
+ }
+ }
+
+ // TODO: Allow users to set line spacing for text: GuiSetStyle(TEXTBOX, TEXT_LINES_SPACING, x)
+ posOffsetY += (float)GuiGetStyle(DEFAULT, TEXT_SIZE)*1.5f;
+ //---------------------------------------------------------------------------------
+ }
}
+#if defined(RAYGUI_DEBUG_TEXT_BOUNDS)
+ GuiDrawRectangle(bounds, 0, WHITE, Fade(RED, 0.4f));
+#endif
}
// Gui draw rectangle using default raygui plain style with borders
@@ -3916,9 +4356,30 @@ static void GuiDrawRectangle(Rectangle rec, int borderWidth, Color borderColor,
}
}
+// Draw tooltip using control bounds
+static void GuiTooltip(Rectangle controlRec)
+{
+ if (!guiLocked && guiTooltip && (guiTooltipPtr != NULL) && !guiSliderDragging)
+ {
+ Vector2 textSize = MeasureTextEx(GuiGetFont(), guiTooltipPtr, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
+
+ if ((controlRec.x + textSize.x + 16) > GetScreenWidth()) controlRec.x -= (textSize.x + 16 - controlRec.width);
+
+ GuiPanel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, GuiGetStyle(DEFAULT, TEXT_SIZE) + 8.f }, NULL);
+
+ int textPadding = GuiGetStyle(LABEL, TEXT_PADDING);
+ int textAlignment = GuiGetStyle(LABEL, TEXT_ALIGNMENT);
+ GuiSetStyle(LABEL, TEXT_PADDING, 0);
+ GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
+ GuiLabel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, GuiGetStyle(DEFAULT, TEXT_SIZE) + 8.f }, guiTooltipPtr);
+ GuiSetStyle(LABEL, TEXT_ALIGNMENT, textAlignment);
+ GuiSetStyle(LABEL, TEXT_PADDING, textPadding);
+ }
+}
+
// Split controls text into multiple strings
// Also check for multiple columns (required by GuiToggleGroup())
-static const char **GuiTextSplit(const char *text, int *count, int *textRow)
+static const char **GuiTextSplit(const char *text, char delimiter, int *count, int *textRow)
{
// NOTE: Current implementation returns a copy of the provided string with '\0' (string end delimiter)
// inserted between strings defined by "delimiter" parameter. No memory is dynamically allocated,
@@ -3927,15 +4388,18 @@ static const char **GuiTextSplit(const char *text, int *count, int *textRow)
// 2. Maximum size of text to split is RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE
// NOTE: Those definitions could be externally provided if required
+ // TODO: HACK: GuiTextSplit() - Review how textRows are returned to user
+ // textRow is an externally provided array of integers that stores row number for every splitted string
+
#if !defined(RAYGUI_TEXTSPLIT_MAX_ITEMS)
- #define RAYGUI_TEXTSPLIT_MAX_ITEMS 128
+ #define RAYGUI_TEXTSPLIT_MAX_ITEMS 128
#endif
#if !defined(RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE)
- #define RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE 1024
+ #define RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE 1024
#endif
- static const char *result[RAYGUI_TEXTSPLIT_MAX_ITEMS] = { NULL };
- static char buffer[RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE] = { 0 };
+ static const char *result[RAYGUI_TEXTSPLIT_MAX_ITEMS] = { NULL }; // String pointers array (points to buffer data)
+ static char buffer[RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE] = { 0 }; // Buffer data (text input copy with '\0' added)
memset(buffer, 0, RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE);
result[0] = buffer;
@@ -3948,7 +4412,7 @@ static const char **GuiTextSplit(const char *text, int *count, int *textRow)
{
buffer[i] = text[i];
if (buffer[i] == '\0') break;
- else if ((buffer[i] == ';') || (buffer[i] == '\n'))
+ else if ((buffer[i] == delimiter) || (buffer[i] == '\n'))
{
result[counter] = buffer + i + 1;
@@ -4100,10 +4564,12 @@ static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
GuiState state = guiState;
// Is the scrollbar horizontal or vertical?
- bool isVertical = (bounds.width > bounds.height) ? false : true;
+ bool isVertical = (bounds.width > bounds.height)? false : true;
// The size (width or height depending on scrollbar type) of the spinner buttons
- const int spinnerSize = GuiGetStyle(SCROLLBAR, ARROWS_VISIBLE) ? (isVertical ? (int)bounds.width - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH) : (int)bounds.height - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH)) : 0;
+ const int spinnerSize = GuiGetStyle(SCROLLBAR, ARROWS_VISIBLE)?
+ (isVertical? (int)bounds.width - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH) :
+ (int)bounds.height - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH)) : 0;
// Arrow buttons [<] [>] [∧] [∨]
Rectangle arrowUpLeft = { 0 };
@@ -4119,25 +4585,40 @@ static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
if (value > maxValue) value = maxValue;
if (value < minValue) value = minValue;
- const int range = maxValue - minValue;
+ const int valueRange = maxValue - minValue;
int sliderSize = GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE);
// Calculate rectangles for all of the components
- arrowUpLeft = RAYGUI_CLITERAL(Rectangle) { (float)bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)spinnerSize, (float)spinnerSize };
+ arrowUpLeft = RAYGUI_CLITERAL(Rectangle){
+ (float)bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH),
+ (float)bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH),
+ (float)spinnerSize, (float)spinnerSize };
if (isVertical)
{
- arrowDownRight = RAYGUI_CLITERAL(Rectangle) { (float)bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)bounds.y + bounds.height - spinnerSize - GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)spinnerSize, (float)spinnerSize };
- scrollbar = RAYGUI_CLITERAL(Rectangle) { bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING), arrowUpLeft.y + arrowUpLeft.height, bounds.width - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING)), bounds.height - arrowUpLeft.height - arrowDownRight.height - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH) };
- sliderSize = (sliderSize >= scrollbar.height) ? ((int)scrollbar.height - 2) : sliderSize; // Make sure the slider won't get outside of the scrollbar
- slider = RAYGUI_CLITERAL(Rectangle) { (float)bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING), (float)scrollbar.y + (int)(((float)(value - minValue)/range)*(scrollbar.height - sliderSize)), (float)bounds.width - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING)), (float)sliderSize };
+ arrowDownRight = RAYGUI_CLITERAL(Rectangle){ (float)bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)bounds.y + bounds.height - spinnerSize - GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)spinnerSize, (float)spinnerSize };
+ scrollbar = RAYGUI_CLITERAL(Rectangle){ bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING), arrowUpLeft.y + arrowUpLeft.height, bounds.width - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING)), bounds.height - arrowUpLeft.height - arrowDownRight.height - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH) };
+
+ // Make sure the slider won't get outside of the scrollbar
+ sliderSize = (sliderSize >= scrollbar.height)? ((int)scrollbar.height - 2) : sliderSize;
+ slider = RAYGUI_CLITERAL(Rectangle){
+ bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING),
+ scrollbar.y + (int)(((float)(value - minValue)/valueRange)*(scrollbar.height - sliderSize)),
+ bounds.width - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING)),
+ (float)sliderSize };
}
- else
+ else // horizontal
{
- arrowDownRight = RAYGUI_CLITERAL(Rectangle) { (float)bounds.x + bounds.width - spinnerSize - GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)spinnerSize, (float)spinnerSize };
- scrollbar = RAYGUI_CLITERAL(Rectangle) { arrowUpLeft.x + arrowUpLeft.width, bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING), bounds.width - arrowUpLeft.width - arrowDownRight.width - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH), bounds.height - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING)) };
- sliderSize = (sliderSize >= scrollbar.width) ? ((int)scrollbar.width - 2) : sliderSize; // Make sure the slider won't get outside of the scrollbar
- slider = RAYGUI_CLITERAL(Rectangle) { (float)scrollbar.x + (int)(((float)(value - minValue)/range)*(scrollbar.width - sliderSize)), (float)bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING), (float)sliderSize, (float)bounds.height - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING)) };
+ arrowDownRight = RAYGUI_CLITERAL(Rectangle){ (float)bounds.x + bounds.width - spinnerSize - GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)spinnerSize, (float)spinnerSize };
+ scrollbar = RAYGUI_CLITERAL(Rectangle){ arrowUpLeft.x + arrowUpLeft.width, bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING), bounds.width - arrowUpLeft.width - arrowDownRight.width - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH), bounds.height - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING)) };
+
+ // Make sure the slider won't get outside of the scrollbar
+ sliderSize = (sliderSize >= scrollbar.width)? ((int)scrollbar.width - 2) : sliderSize;
+ slider = RAYGUI_CLITERAL(Rectangle){
+ scrollbar.x + (int)(((float)(value - minValue)/valueRange)*(scrollbar.width - sliderSize)),
+ bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING),
+ (float)sliderSize,
+ bounds.height - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING)) };
}
// Update control
@@ -4146,34 +4627,66 @@ static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
{
Vector2 mousePoint = GetMousePosition();
- if (CheckCollisionPointRec(mousePoint, bounds))
+ if (guiSliderDragging) // Keep dragging outside of bounds
+ {
+ if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
+ {
+ if (CHECK_BOUNDS_ID(bounds, guiSliderActive))
+ {
+ if (isVertical) value += (int)(GetMouseDelta().y/(scrollbar.height - slider.height)*valueRange);
+ else value += (int)(GetMouseDelta().x/(scrollbar.width - slider.width)*valueRange);
+ }
+ }
+ else
+ {
+ guiSliderDragging = false;
+ guiSliderActive = RAYGUI_CLITERAL(Rectangle){ 0, 0, 0, 0 };
+ }
+ }
+ else if (CheckCollisionPointRec(mousePoint, bounds))
{
state = STATE_FOCUSED;
+ guiSliderDragging = true;
+ guiSliderActive = bounds; // Store bounds as an identifier when dragging starts
// Handle mouse wheel
int wheel = (int)GetMouseWheelMove();
if (wheel != 0) value += wheel;
+ // Handle mouse button down
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
- if (CheckCollisionPointRec(mousePoint, arrowUpLeft)) value -= range/GuiGetStyle(SCROLLBAR, SCROLL_SPEED);
- else if (CheckCollisionPointRec(mousePoint, arrowDownRight)) value += range/GuiGetStyle(SCROLLBAR, SCROLL_SPEED);
+ // Check arrows click
+ if (CheckCollisionPointRec(mousePoint, arrowUpLeft)) value -= valueRange/GuiGetStyle(SCROLLBAR, SCROLL_SPEED);
+ else if (CheckCollisionPointRec(mousePoint, arrowDownRight)) value += valueRange/GuiGetStyle(SCROLLBAR, SCROLL_SPEED);
+ else if (!CheckCollisionPointRec(mousePoint, slider))
+ {
+ // If click on scrollbar position but not on slider, place slider directly on that position
+ if (isVertical) value = (int)(((float)(mousePoint.y - scrollbar.y - slider.height/2)*valueRange)/(scrollbar.height - slider.height) + minValue);
+ else value = (int)(((float)(mousePoint.x - scrollbar.x - slider.width/2)*valueRange)/(scrollbar.width - slider.width) + minValue);
+ }
state = STATE_PRESSED;
}
else if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
{
- if (!isVertical)
- {
- Rectangle scrollArea = { arrowUpLeft.x + arrowUpLeft.width, arrowUpLeft.y, scrollbar.width, bounds.height - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH) };
- if (CheckCollisionPointRec(mousePoint, scrollArea)) value = (int)(((float)(mousePoint.x - scrollArea.x - slider.width/2)*range)/(scrollArea.width - slider.width) + minValue);
- }
- else
- {
- Rectangle scrollArea = { arrowUpLeft.x, arrowUpLeft.y+arrowUpLeft.height, bounds.width - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH), scrollbar.height };
- if (CheckCollisionPointRec(mousePoint, scrollArea)) value = (int)(((float)(mousePoint.y - scrollArea.y - slider.height/2)*range)/(scrollArea.height - slider.height) + minValue);
- }
+ if (isVertical) value += (int)(GetMouseDelta().y/(scrollbar.height - slider.height)*valueRange);
+ else value += (int)(GetMouseDelta().x/(scrollbar.width - slider.width)*valueRange);
}
+
+ // Keyboard control on mouse hover scrollbar
+ /*
+ if (isVertical)
+ {
+ if (IsKeyDown(KEY_DOWN)) value += 5;
+ else if (IsKeyDown(KEY_UP)) value -= 5;
+ }
+ else
+ {
+ if (IsKeyDown(KEY_RIGHT)) value += 5;
+ else if (IsKeyDown(KEY_LEFT)) value -= 5;
+ }
+ */
}
// Normalize value
@@ -4193,14 +4706,18 @@ static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
if (GuiGetStyle(SCROLLBAR, ARROWS_VISIBLE))
{
#if defined(RAYGUI_NO_ICONS)
- GuiDrawText(isVertical ? "^" : "<", RAYGUI_CLITERAL(Rectangle){ arrowUpLeft.x, arrowUpLeft.y, isVertical ? bounds.width : bounds.height, isVertical ? bounds.width : bounds.height },
+ GuiDrawText(isVertical? "^" : "<",
+ RAYGUI_CLITERAL(Rectangle){ arrowUpLeft.x, arrowUpLeft.y, isVertical? bounds.width : bounds.height, isVertical? bounds.width : bounds.height },
TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))), guiAlpha));
- GuiDrawText(isVertical ? "v" : ">", RAYGUI_CLITERAL(Rectangle){ arrowDownRight.x, arrowDownRight.y, isVertical ? bounds.width : bounds.height, isVertical ? bounds.width : bounds.height },
+ GuiDrawText(isVertical? "v" : ">",
+ RAYGUI_CLITERAL(Rectangle){ arrowDownRight.x, arrowDownRight.y, isVertical? bounds.width : bounds.height, isVertical? bounds.width : bounds.height },
TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))), guiAlpha));
#else
- GuiDrawText(isVertical ? "#121#" : "#118#", RAYGUI_CLITERAL(Rectangle){ arrowUpLeft.x, arrowUpLeft.y, isVertical ? bounds.width : bounds.height, isVertical ? bounds.width : bounds.height },
+ GuiDrawText(isVertical? "#121#" : "#118#",
+ RAYGUI_CLITERAL(Rectangle){ arrowUpLeft.x, arrowUpLeft.y, isVertical? bounds.width : bounds.height, isVertical? bounds.width : bounds.height },
TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(SCROLLBAR, TEXT + state*3)), guiAlpha)); // ICON_ARROW_UP_FILL / ICON_ARROW_LEFT_FILL
- GuiDrawText(isVertical ? "#120#" : "#119#", RAYGUI_CLITERAL(Rectangle){ arrowDownRight.x, arrowDownRight.y, isVertical ? bounds.width : bounds.height, isVertical ? bounds.width : bounds.height },
+ GuiDrawText(isVertical? "#120#" : "#119#",
+ RAYGUI_CLITERAL(Rectangle){ arrowDownRight.x, arrowDownRight.y, isVertical? bounds.width : bounds.height, isVertical? bounds.width : bounds.height },
TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(SCROLLBAR, TEXT + state*3)), guiAlpha)); // ICON_ARROW_DOWN_FILL / ICON_ARROW_RIGHT_FILL
#endif
}
@@ -4286,7 +4803,7 @@ const char **TextSplit(const char *text, char delimiter, int *count)
// 2. Maximum size of text to split is RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE
#if !defined(RAYGUI_TEXTSPLIT_MAX_ITEMS)
- #define RAYGUI_TEXTSPLIT_MAX_ITEMS 128
+ #define RAYGUI_TEXTSPLIT_MAX_ITEMS 128
#endif
#if !defined(RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE)
#define RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE 1024
@@ -4384,107 +4901,43 @@ static const char *CodepointToUTF8(int codepoint, int *byteSize)
// Total number of bytes processed are returned as a parameter
// NOTE: the standard says U+FFFD should be returned in case of errors
// but that character is not supported by the default font in raylib
-static int GetCodepoint(const char *text, int *bytesProcessed)
+static int GetCodepointNext(const char *text, int *codepointSize)
{
-/*
- UTF-8 specs from https://www.ietf.org/rfc/rfc3629.txt
+ const char *ptr = text;
+ int codepoint = 0x3f; // Codepoint (defaults to '?')
+ *codepointSize = 1;
- Char. number range | UTF-8 octet sequence
- (hexadecimal) | (binary)
- --------------------+---------------------------------------------
- 0000 0000-0000 007F | 0xxxxxxx
- 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
- 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
- 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
-*/
- // NOTE: on decode errors we return as soon as possible
-
- int code = 0x3f; // Codepoint (defaults to '?')
- int octet = (unsigned char)(text[0]); // The first UTF8 octet
- *bytesProcessed = 1;
-
- if (octet <= 0x7f)
+ // Get current codepoint and bytes processed
+ if (0xf0 == (0xf8 & ptr[0]))
{
- // Only one octet (ASCII range x00-7F)
- code = text[0];
+ // 4 byte UTF-8 codepoint
+ if(((ptr[1] & 0xC0) ^ 0x80) || ((ptr[2] & 0xC0) ^ 0x80) || ((ptr[3] & 0xC0) ^ 0x80)) { return codepoint; } //10xxxxxx checks
+ codepoint = ((0x07 & ptr[0]) << 18) | ((0x3f & ptr[1]) << 12) | ((0x3f & ptr[2]) << 6) | (0x3f & ptr[3]);
+ *codepointSize = 4;
}
- else if ((octet & 0xe0) == 0xc0)
+ else if (0xe0 == (0xf0 & ptr[0]))
{
- // Two octets
-
- // [0]xC2-DF [1]UTF8-tail(x80-BF)
- unsigned char octet1 = text[1];
-
- if ((octet1 == '\0') || ((octet1 >> 6) != 2)) { *bytesProcessed = 2; return code; } // Unexpected sequence
-
- if ((octet >= 0xc2) && (octet <= 0xdf))
- {
- code = ((octet & 0x1f) << 6) | (octet1 & 0x3f);
- *bytesProcessed = 2;
- }
+ // 3 byte UTF-8 codepoint */
+ if(((ptr[1] & 0xC0) ^ 0x80) || ((ptr[2] & 0xC0) ^ 0x80)) { return codepoint; } //10xxxxxx checks
+ codepoint = ((0x0f & ptr[0]) << 12) | ((0x3f & ptr[1]) << 6) | (0x3f & ptr[2]);
+ *codepointSize = 3;
}
- else if ((octet & 0xf0) == 0xe0)
+ else if (0xc0 == (0xe0 & ptr[0]))
{
- // Three octets
- unsigned char octet1 = text[1];
- unsigned char octet2 = '\0';
-
- if ((octet1 == '\0') || ((octet1 >> 6) != 2)) { *bytesProcessed = 2; return code; } // Unexpected sequence
-
- octet2 = text[2];
-
- if ((octet2 == '\0') || ((octet2 >> 6) != 2)) { *bytesProcessed = 3; return code; } // Unexpected sequence
-
- // [0]xE0 [1]xA0-BF [2]UTF8-tail(x80-BF)
- // [0]xE1-EC [1]UTF8-tail [2]UTF8-tail(x80-BF)
- // [0]xED [1]x80-9F [2]UTF8-tail(x80-BF)
- // [0]xEE-EF [1]UTF8-tail [2]UTF8-tail(x80-BF)
-
- if (((octet == 0xe0) && !((octet1 >= 0xa0) && (octet1 <= 0xbf))) ||
- ((octet == 0xed) && !((octet1 >= 0x80) && (octet1 <= 0x9f)))) { *bytesProcessed = 2; return code; }
-
- if ((octet >= 0xe0) && (0 <= 0xef))
- {
- code = ((octet & 0xf) << 12) | ((octet1 & 0x3f) << 6) | (octet2 & 0x3f);
- *bytesProcessed = 3;
- }
+ // 2 byte UTF-8 codepoint
+ if((ptr[1] & 0xC0) ^ 0x80) { return codepoint; } //10xxxxxx checks
+ codepoint = ((0x1f & ptr[0]) << 6) | (0x3f & ptr[1]);
+ *codepointSize = 2;
}
- else if ((octet & 0xf8) == 0xf0)
+ else if (0x00 == (0x80 & ptr[0]))
{
- // Four octets
- if (octet > 0xf4) return code;
-
- unsigned char octet1 = text[1];
- unsigned char octet2 = '\0';
- unsigned char octet3 = '\0';
-
- if ((octet1 == '\0') || ((octet1 >> 6) != 2)) { *bytesProcessed = 2; return code; } // Unexpected sequence
-
- octet2 = text[2];
-
- if ((octet2 == '\0') || ((octet2 >> 6) != 2)) { *bytesProcessed = 3; return code; } // Unexpected sequence
-
- octet3 = text[3];
-
- if ((octet3 == '\0') || ((octet3 >> 6) != 2)) { *bytesProcessed = 4; return code; } // Unexpected sequence
-
- // [0]xF0 [1]x90-BF [2]UTF8-tail [3]UTF8-tail
- // [0]xF1-F3 [1]UTF8-tail [2]UTF8-tail [3]UTF8-tail
- // [0]xF4 [1]x80-8F [2]UTF8-tail [3]UTF8-tail
-
- if (((octet == 0xf0) && !((octet1 >= 0x90) && (octet1 <= 0xbf))) ||
- ((octet == 0xf4) && !((octet1 >= 0x80) && (octet1 <= 0x8f)))) { *bytesProcessed = 2; return code; } // Unexpected sequence
-
- if (octet >= 0xf0)
- {
- code = ((octet & 0x7) << 18) | ((octet1 & 0x3f) << 12) | ((octet2 & 0x3f) << 6) | (octet3 & 0x3f);
- *bytesProcessed = 4;
- }
+ // 1 byte UTF-8 codepoint
+ codepoint = ptr[0];
+ *codepointSize = 1;
}
- if (code > 0x10ffff) code = 0x3f; // Codepoints after U+10ffff are invalid
- return code;
+ return codepoint;
}
#endif // RAYGUI_STANDALONE
diff --git a/examples/shapes/reasings.h b/examples/shapes/reasings.h
index 8b14ba6aa..657ea242e 100644
--- a/examples/shapes/reasings.h
+++ b/examples/shapes/reasings.h
@@ -60,7 +60,7 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ---------------------------------------------------------------------------------
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
diff --git a/examples/shapes/resources/.gitkeep b/examples/shapes/resources/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/examples/shapes/shapes_basic_shapes.c b/examples/shapes/shapes_basic_shapes.c
index d06c2ee15..40056b4e7 100644
--- a/examples/shapes/shapes_basic_shapes.c
+++ b/examples/shapes/shapes_basic_shapes.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -51,7 +51,7 @@ int main(void)
DrawCircleGradient(screenWidth/5, 220, 60, GREEN, SKYBLUE);
DrawCircleLines(screenWidth/5, 340, 80, DARKBLUE);
- // Rectangle shapes and ines
+ // Rectangle shapes and lines
DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED);
DrawRectangleGradientH(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD);
DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE); // NOTE: Uses QUADS internally, not lines
@@ -83,4 +83,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
-}
\ No newline at end of file
+}
diff --git a/examples/shapes/shapes_bouncing_ball.c b/examples/shapes/shapes_bouncing_ball.c
index 19f58da65..5e43b80da 100644
--- a/examples/shapes/shapes_bouncing_ball.c
+++ b/examples/shapes/shapes_bouncing_ball.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shapes/shapes_collision_area.c b/examples/shapes/shapes_collision_area.c
index e83f83834..34d04811d 100644
--- a/examples/shapes/shapes_collision_area.c
+++ b/examples/shapes/shapes_collision_area.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shapes/shapes_colors_palette.c b/examples/shapes/shapes_colors_palette.c
index 49aad8a37..d55782550 100644
--- a/examples/shapes/shapes_colors_palette.c
+++ b/examples/shapes/shapes_colors_palette.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shapes/shapes_draw_circle_sector.c b/examples/shapes/shapes_draw_circle_sector.c
index 1fcd8aa48..1c283e151 100644
--- a/examples/shapes/shapes_draw_circle_sector.c
+++ b/examples/shapes/shapes_draw_circle_sector.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2018-2022 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2018-2023 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -35,8 +35,8 @@ int main(void)
float outerRadius = 180.0f;
float startAngle = 0.0f;
float endAngle = 180.0f;
- int segments = 0;
- int minSegments = 4;
+ float segments = 10.0f;
+ float minSegments = 4;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -58,16 +58,16 @@ int main(void)
DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
- DrawCircleSector(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3f));
- DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.6f));
+ DrawCircleSector(center, outerRadius, startAngle, endAngle, (int)segments, Fade(MAROON, 0.3f));
+ DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, (int)segments, Fade(MAROON, 0.6f));
// Draw GUI controls
//------------------------------------------------------------------------------
- startAngle = GuiSliderBar((Rectangle){ 600, 40, 120, 20}, "StartAngle", NULL, startAngle, 0, 720);
- endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", NULL, endAngle, 0, 720);
+ GuiSliderBar((Rectangle){ 600, 40, 120, 20}, "StartAngle", NULL, &startAngle, 0, 720);
+ GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", NULL, &endAngle, 0, 720);
- outerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20}, "Radius", NULL, outerRadius, 0, 200);
- segments = (int)GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", NULL, (float)segments, 0, 100);
+ GuiSliderBar((Rectangle){ 600, 140, 120, 20}, "Radius", NULL, &outerRadius, 0, 200);
+ GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", NULL, &segments, 0, 100);
//------------------------------------------------------------------------------
minSegments = (int)ceilf((endAngle - startAngle) / 90);
diff --git a/examples/shapes/shapes_draw_rectangle_rounded.c b/examples/shapes/shapes_draw_rectangle_rounded.c
index 9c527e5ef..a10e3c848 100644
--- a/examples/shapes/shapes_draw_rectangle_rounded.c
+++ b/examples/shapes/shapes_draw_rectangle_rounded.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2018-2022 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2018-2023 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -31,10 +31,10 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw rectangle rounded");
float roundness = 0.2f;
- int width = 200;
- int height = 100;
- int segments = 0;
- int lineThick = 1;
+ float width = 200.0f;
+ float height = 100.0f;
+ float segments = 0.0f;
+ float lineThick = 1.0f;
bool drawRect = false;
bool drawRoundedRect = true;
@@ -61,20 +61,20 @@ int main(void)
DrawRectangle(560, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
if (drawRect) DrawRectangleRec(rec, Fade(GOLD, 0.6f));
- if (drawRoundedRect) DrawRectangleRounded(rec, roundness, segments, Fade(MAROON, 0.2f));
- if (drawRoundedLines) DrawRectangleRoundedLines(rec,roundness, segments, (float)lineThick, Fade(MAROON, 0.4f));
+ if (drawRoundedRect) DrawRectangleRounded(rec, roundness, (int)segments, Fade(MAROON, 0.2f));
+ if (drawRoundedLines) DrawRectangleRoundedLines(rec, roundness, (int)segments, lineThick, Fade(MAROON, 0.4f));
// Draw GUI controls
//------------------------------------------------------------------------------
- width = (int)GuiSliderBar((Rectangle){ 640, 40, 105, 20 }, "Width", NULL, (float)width, 0, (float)GetScreenWidth() - 300);
- height = (int)GuiSliderBar((Rectangle){ 640, 70, 105, 20 }, "Height", NULL, (float)height, 0, (float)GetScreenHeight() - 50);
- roundness = GuiSliderBar((Rectangle){ 640, 140, 105, 20 }, "Roundness", NULL, roundness, 0.0f, 1.0f);
- lineThick = (int)GuiSliderBar((Rectangle){ 640, 170, 105, 20 }, "Thickness", NULL, (float)lineThick, 0, 20);
- segments = (int)GuiSliderBar((Rectangle){ 640, 240, 105, 20}, "Segments", NULL, (float)segments, 0, 60);
+ GuiSliderBar((Rectangle){ 640, 40, 105, 20 }, "Width", NULL, &width, 0, (float)GetScreenWidth() - 300);
+ GuiSliderBar((Rectangle){ 640, 70, 105, 20 }, "Height", NULL, &height, 0, (float)GetScreenHeight() - 50);
+ GuiSliderBar((Rectangle){ 640, 140, 105, 20 }, "Roundness", NULL, &roundness, 0.0f, 1.0f);
+ GuiSliderBar((Rectangle){ 640, 170, 105, 20 }, "Thickness", NULL, &lineThick, 0, 20);
+ GuiSliderBar((Rectangle){ 640, 240, 105, 20}, "Segments", NULL, &segments, 0, 60);
- drawRoundedRect = GuiCheckBox((Rectangle){ 640, 320, 20, 20 }, "DrawRoundedRect", drawRoundedRect);
- drawRoundedLines = GuiCheckBox((Rectangle){ 640, 350, 20, 20 }, "DrawRoundedLines", drawRoundedLines);
- drawRect = GuiCheckBox((Rectangle){ 640, 380, 20, 20}, "DrawRect", drawRect);
+ GuiCheckBox((Rectangle){ 640, 320, 20, 20 }, "DrawRoundedRect", &drawRoundedRect);
+ GuiCheckBox((Rectangle){ 640, 350, 20, 20 }, "DrawRoundedLines", &drawRoundedLines);
+ GuiCheckBox((Rectangle){ 640, 380, 20, 20}, "DrawRect", &drawRect);
//------------------------------------------------------------------------------
DrawText(TextFormat("MODE: %s", (segments >= 4)? "MANUAL" : "AUTO"), 640, 280, 10, (segments >= 4)? MAROON : DARKGRAY);
diff --git a/examples/shapes/shapes_draw_ring.c b/examples/shapes/shapes_draw_ring.c
index 6225d473c..47327b7ad 100644
--- a/examples/shapes/shapes_draw_ring.c
+++ b/examples/shapes/shapes_draw_ring.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2018-2022 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2018-2023 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -37,7 +37,7 @@ int main(void)
float startAngle = 0.0f;
float endAngle = 360.0f;
- int segments = 0;
+ float segments = 0.0f;
bool drawRing = true;
bool drawRingLines = false;
@@ -63,23 +63,23 @@ int main(void)
DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
- if (drawRing) DrawRing(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3f));
- if (drawRingLines) DrawRingLines(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4f));
- if (drawCircleLines) DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4f));
+ if (drawRing) DrawRing(center, innerRadius, outerRadius, startAngle, endAngle, (int)segments, Fade(MAROON, 0.3f));
+ if (drawRingLines) DrawRingLines(center, innerRadius, outerRadius, startAngle, endAngle, (int)segments, Fade(BLACK, 0.4f));
+ if (drawCircleLines) DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, (int)segments, Fade(BLACK, 0.4f));
// Draw GUI controls
//------------------------------------------------------------------------------
- startAngle = GuiSliderBar((Rectangle){ 600, 40, 120, 20 }, "StartAngle", NULL, startAngle, -450, 450);
- endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20 }, "EndAngle", NULL, endAngle, -450, 450);
+ GuiSliderBar((Rectangle){ 600, 40, 120, 20 }, "StartAngle", NULL, &startAngle, -450, 450);
+ GuiSliderBar((Rectangle){ 600, 70, 120, 20 }, "EndAngle", NULL, &endAngle, -450, 450);
- innerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20 }, "InnerRadius", NULL, innerRadius, 0, 100);
- outerRadius = GuiSliderBar((Rectangle){ 600, 170, 120, 20 }, "OuterRadius", NULL, outerRadius, 0, 200);
+ GuiSliderBar((Rectangle){ 600, 140, 120, 20 }, "InnerRadius", NULL, &innerRadius, 0, 100);
+ GuiSliderBar((Rectangle){ 600, 170, 120, 20 }, "OuterRadius", NULL, &outerRadius, 0, 200);
- segments = (int)GuiSliderBar((Rectangle){ 600, 240, 120, 20 }, "Segments", NULL, (float)segments, 0, 100);
+ GuiSliderBar((Rectangle){ 600, 240, 120, 20 }, "Segments", NULL, &segments, 0, 100);
- drawRing = GuiCheckBox((Rectangle){ 600, 320, 20, 20 }, "Draw Ring", drawRing);
- drawRingLines = GuiCheckBox((Rectangle){ 600, 350, 20, 20 }, "Draw RingLines", drawRingLines);
- drawCircleLines = GuiCheckBox((Rectangle){ 600, 380, 20, 20 }, "Draw CircleLines", drawCircleLines);
+ GuiCheckBox((Rectangle){ 600, 320, 20, 20 }, "Draw Ring", &drawRing);
+ GuiCheckBox((Rectangle){ 600, 350, 20, 20 }, "Draw RingLines", &drawRingLines);
+ GuiCheckBox((Rectangle){ 600, 380, 20, 20 }, "Draw CircleLines", &drawCircleLines);
//------------------------------------------------------------------------------
int minSegments = (int)ceilf((endAngle - startAngle)/90);
diff --git a/examples/shapes/shapes_easings_ball_anim.c b/examples/shapes/shapes_easings_ball_anim.c
index e6b595c32..866ec0971 100644
--- a/examples/shapes/shapes_easings_ball_anim.c
+++ b/examples/shapes/shapes_easings_ball_anim.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shapes/shapes_easings_box_anim.c b/examples/shapes/shapes_easings_box_anim.c
index 05cba1959..a854bf6c3 100644
--- a/examples/shapes/shapes_easings_box_anim.c
+++ b/examples/shapes/shapes_easings_box_anim.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shapes/shapes_easings_rectangle_array.c b/examples/shapes/shapes_easings_rectangle_array.c
index a2ab6397d..03916f5b4 100644
--- a/examples/shapes/shapes_easings_rectangle_array.c
+++ b/examples/shapes/shapes_easings_rectangle_array.c
@@ -10,7 +10,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shapes/shapes_following_eyes.c b/examples/shapes/shapes_following_eyes.c
index 43a50a79d..2137d797a 100644
--- a/examples/shapes/shapes_following_eyes.c
+++ b/examples/shapes/shapes_following_eyes.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shapes/shapes_lines_bezier.c b/examples/shapes/shapes_lines_bezier.c
index 76c232792..195281be3 100644
--- a/examples/shapes/shapes_lines_bezier.c
+++ b/examples/shapes/shapes_lines_bezier.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2017-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2017-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shapes/shapes_logo_raylib.c b/examples/shapes/shapes_logo_raylib.c
index 48005c7ae..4f625c2c8 100644
--- a/examples/shapes/shapes_logo_raylib.c
+++ b/examples/shapes/shapes_logo_raylib.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shapes/shapes_logo_raylib_anim.c b/examples/shapes/shapes_logo_raylib_anim.c
index 60e839f51..5d6dd3538 100644
--- a/examples/shapes/shapes_logo_raylib_anim.c
+++ b/examples/shapes/shapes_logo_raylib_anim.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shapes/shapes_rectangle_scaling.c b/examples/shapes/shapes_rectangle_scaling.c
index 0faeee2f3..18104b120 100644
--- a/examples/shapes/shapes_rectangle_scaling.c
+++ b/examples/shapes/shapes_rectangle_scaling.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2018-2022 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2018-2023 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/shapes/shapes_top_down_lights.c b/examples/shapes/shapes_top_down_lights.c
index d75d46d74..b09137cba 100644
--- a/examples/shapes/shapes_top_down_lights.c
+++ b/examples/shapes/shapes_top_down_lights.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2022 Jeffery Myers (@JeffM2501)
+* Copyright (c) 2022-2023 Jeffery Myers (@JeffM2501)
*
********************************************************************************************/
diff --git a/examples/text/text_codepoints_loading.c b/examples/text/text_codepoints_loading.c
index c68544030..1f3db0cf3 100644
--- a/examples/text/text_codepoints_loading.c
+++ b/examples/text/text_codepoints_loading.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2022-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/text/text_draw_3d.c b/examples/text/text_draw_3d.c
index f03ad7849..097e4fc67 100644
--- a/examples/text/text_draw_3d.c
+++ b/examples/text/text_draw_3d.c
@@ -22,7 +22,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2021-2022 Vlad Adrian (@demizdor)
+* Copyright (c) 2021-2023 Vlad Adrian (@demizdor)
*
********************************************************************************************/
@@ -96,15 +96,13 @@ int main(void)
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
- camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
- SetCameraMode(camera, CAMERA_ORBITAL);
+ int camera_mode = CAMERA_ORBITAL;
Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
-
// Use the default font
Font font = GetFontDefault();
float fontSize = 8.0f;
@@ -134,6 +132,10 @@ int main(void)
// Array filled with multiple random colors (when multicolor mode is set)
Color multi[TEXT_MAX_LAYERS] = {0};
+
+ DisableCursor(); // Limit cursor to relative movement inside the window
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
@@ -141,7 +143,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, camera_mode);
// Handle font files dropped
if (IsFileDropped())
@@ -152,13 +154,13 @@ int main(void)
if (IsFileExtension(droppedFiles.paths[0], ".ttf"))
{
UnloadFont(font);
- font = LoadFontEx(droppedFiles.paths[0], fontSize, 0, 0);
+ font = LoadFontEx(droppedFiles.paths[0], (int)fontSize, 0, 0);
}
else if (IsFileExtension(droppedFiles.paths[0], ".fnt"))
{
UnloadFont(font);
font = LoadFont(droppedFiles.paths[0]);
- fontSize = font.baseSize;
+ fontSize = (float)font.baseSize;
}
UnloadDroppedFiles(droppedFiles); // Unload filepaths from memory
@@ -181,12 +183,12 @@ int main(void)
if (spin)
{
camera.position = (Vector3){ -10.0f, 15.0f, -10.0f }; // Camera position
- SetCameraMode(camera, CAMERA_ORBITAL);
+ camera_mode = CAMERA_ORBITAL;
}
else
{
camera.position = (Vector3){ 10.0f, 10.0f, -10.0f }; // Camera position
- SetCameraMode(camera, CAMERA_FREE);
+ camera_mode = CAMERA_FREE;
}
}
@@ -742,7 +744,7 @@ static Vector3 MeasureTextWave3D(Font font, const char* text, float fontSize, fl
static Color GenerateRandomColor(float s, float v)
{
const float Phi = 0.618033988749895f; // Golden ratio conjugate
- float h = GetRandomValue(0, 360);
+ float h = (float)GetRandomValue(0, 360);
h = fmodf((h + h*Phi), 360.0f);
return ColorFromHSV(h, s, v);
}
diff --git a/examples/text/text_font_filters.c b/examples/text/text_font_filters.c
index 7d9082b5d..e6756713c 100644
--- a/examples/text/text_font_filters.c
+++ b/examples/text/text_font_filters.c
@@ -11,7 +11,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/text/text_font_loading.c b/examples/text/text_font_loading.c
index 6ebdbbcdd..2ded64f09 100644
--- a/examples/text/text_font_loading.c
+++ b/examples/text/text_font_loading.c
@@ -16,7 +16,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2016-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2016-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/text/text_font_sdf.c b/examples/text/text_font_sdf.c
index 9e7465019..6a223ae5c 100644
--- a/examples/text/text_font_sdf.c
+++ b/examples/text/text_font_sdf.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/text/text_font_spritefont.c b/examples/text/text_font_spritefont.c
index 109ab486b..b5df2d0dc 100644
--- a/examples/text/text_font_spritefont.c
+++ b/examples/text/text_font_spritefont.c
@@ -17,7 +17,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/text/text_format_text.c b/examples/text/text_format_text.c
index dbdbb0fdb..6b1b0456f 100644
--- a/examples/text/text_format_text.c
+++ b/examples/text/text_format_text.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/text/text_input_box.c b/examples/text/text_input_box.c
index 4d2eee442..f3923c1e9 100644
--- a/examples/text/text_input_box.c
+++ b/examples/text/text_input_box.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2017-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2017-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/text/text_raylib_fonts.c b/examples/text/text_raylib_fonts.c
index f08569a2e..8ef67c71d 100644
--- a/examples/text/text_raylib_fonts.c
+++ b/examples/text/text_raylib_fonts.c
@@ -10,7 +10,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2017-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2017-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/text/text_rectangle_bounds.c b/examples/text/text_rectangle_bounds.c
index d2c992dfd..886c348d5 100644
--- a/examples/text/text_rectangle_bounds.c
+++ b/examples/text/text_rectangle_bounds.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2018-2022 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2018-2023 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -263,6 +263,6 @@ static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec,
}
}
- textOffsetX += glyphWidth;
+ if ((textOffsetX != 0) || (codepoint != ' ')) textOffsetX += glyphWidth; // avoid leading spaces
}
-}
\ No newline at end of file
+}
diff --git a/examples/text/text_unicode.c b/examples/text/text_unicode.c
index 4af542655..b25e3273b 100644
--- a/examples/text/text_unicode.c
+++ b/examples/text/text_unicode.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -187,12 +187,11 @@ int main(void)
// Add a new set of emojis when SPACE is pressed
if (IsKeyPressed(KEY_SPACE)) RandomizeEmoji();
- // Set the selected emoji and copy its text to clipboard
+ // Set the selected emoji
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && (hovered != -1) && (hovered != selected))
{
selected = hovered;
selectedPos = hoveredPos;
- SetClipboardText(messages[emoji[selected].message].text);
}
Vector2 mouse = GetMousePosition();
@@ -267,7 +266,7 @@ int main(void)
a = b;
b = tmp;
}
-
+
if (msgRect.x + msgRect.width > screenWidth) msgRect.x -= (msgRect.x + msgRect.width) - screenWidth + 10;
// Draw chat bubble
@@ -287,11 +286,11 @@ int main(void)
DrawText(info, (int)pos.x, (int)pos.y, 10, RAYWHITE);
}
//------------------------------------------------------------------------------
-
+
// Draw the info text
DrawText("These emojis have something to tell you, click each to find out!", (screenWidth - 650)/2, screenHeight - 40, 20, GRAY);
DrawText("Each emoji is a unicode character from a font, not a texture... Press [SPACEBAR] to refresh", (screenWidth - 484)/2, screenHeight - 16, 10, GRAY);
-
+
EndDrawing();
//----------------------------------------------------------------------------------
}
@@ -342,7 +341,7 @@ static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec,
{
int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop
- float textOffsetY = 0; // Offset between lines (on line break '\n')
+ float textOffsetY = 0.0f; // Offset between lines (on line break '\n')
float textOffsetX = 0.0f; // Offset X to next character to draw
float scaleFactor = fontSize/(float)font.baseSize; // Character rectangle scaling factor
@@ -465,4 +464,4 @@ static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec,
textOffsetX += glyphWidth;
}
-}
\ No newline at end of file
+}
diff --git a/examples/text/text_writing_anim.c b/examples/text/text_writing_anim.c
index 6beb3e552..4ee67700e 100644
--- a/examples/text/text_writing_anim.c
+++ b/examples/text/text_writing_anim.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2016-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2016-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/resources/road.png b/examples/textures/resources/road.png
new file mode 100644
index 000000000..082f4cd2e
Binary files /dev/null and b/examples/textures/resources/road.png differ
diff --git a/examples/textures/textures_background_scrolling.c b/examples/textures/textures_background_scrolling.c
index 70b67c3de..55fa2115e 100644
--- a/examples/textures/textures_background_scrolling.c
+++ b/examples/textures/textures_background_scrolling.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_blend_modes.c b/examples/textures/textures_blend_modes.c
index b8131354a..246a98e47 100644
--- a/examples/textures/textures_blend_modes.c
+++ b/examples/textures/textures_blend_modes.c
@@ -11,7 +11,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2020-2022 Karlo Licudine (@accidentalrebel)
+* Copyright (c) 2020-2023 Karlo Licudine (@accidentalrebel)
*
********************************************************************************************/
diff --git a/examples/textures/textures_bunnymark.c b/examples/textures/textures_bunnymark.c
index 2cca8b48f..ede3036fa 100644
--- a/examples/textures/textures_bunnymark.c
+++ b/examples/textures/textures_bunnymark.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_draw_tiled.c b/examples/textures/textures_draw_tiled.c
index 908bf238d..34fe82ce4 100644
--- a/examples/textures/textures_draw_tiled.c
+++ b/examples/textures/textures_draw_tiled.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2020-2022 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2020-2023 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -20,6 +20,9 @@
#define MARGIN_SIZE 8 // Size for the margins
#define COLOR_SIZE 16 // Size of the color select buttons
+// Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.
+void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint);
+
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
@@ -168,3 +171,86 @@ int main(void)
return 0;
}
+// Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.
+void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint)
+{
+ if ((texture.id <= 0) || (scale <= 0.0f)) return; // Wanna see a infinite loop?!...just delete this line!
+ if ((source.width == 0) || (source.height == 0)) return;
+
+ int tileWidth = (int)(source.width*scale), tileHeight = (int)(source.height*scale);
+ if ((dest.width < tileWidth) && (dest.height < tileHeight))
+ {
+ // Can fit only one tile
+ DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)dest.width/tileWidth)*source.width, ((float)dest.height/tileHeight)*source.height},
+ (Rectangle){dest.x, dest.y, dest.width, dest.height}, origin, rotation, tint);
+ }
+ else if (dest.width <= tileWidth)
+ {
+ // Tiled vertically (one column)
+ int dy = 0;
+ for (;dy+tileHeight < dest.height; dy += tileHeight)
+ {
+ DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)dest.width/tileWidth)*source.width, source.height}, (Rectangle){dest.x, dest.y + dy, dest.width, (float)tileHeight}, origin, rotation, tint);
+ }
+
+ // Fit last tile
+ if (dy < dest.height)
+ {
+ DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)dest.width/tileWidth)*source.width, ((float)(dest.height - dy)/tileHeight)*source.height},
+ (Rectangle){dest.x, dest.y + dy, dest.width, dest.height - dy}, origin, rotation, tint);
+ }
+ }
+ else if (dest.height <= tileHeight)
+ {
+ // Tiled horizontally (one row)
+ int dx = 0;
+ for (;dx+tileWidth < dest.width; dx += tileWidth)
+ {
+ DrawTexturePro(texture, (Rectangle){source.x, source.y, source.width, ((float)dest.height/tileHeight)*source.height}, (Rectangle){dest.x + dx, dest.y, (float)tileWidth, dest.height}, origin, rotation, tint);
+ }
+
+ // Fit last tile
+ if (dx < dest.width)
+ {
+ DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)(dest.width - dx)/tileWidth)*source.width, ((float)dest.height/tileHeight)*source.height},
+ (Rectangle){dest.x + dx, dest.y, dest.width - dx, dest.height}, origin, rotation, tint);
+ }
+ }
+ else
+ {
+ // Tiled both horizontally and vertically (rows and columns)
+ int dx = 0;
+ for (;dx+tileWidth < dest.width; dx += tileWidth)
+ {
+ int dy = 0;
+ for (;dy+tileHeight < dest.height; dy += tileHeight)
+ {
+ DrawTexturePro(texture, source, (Rectangle){dest.x + dx, dest.y + dy, (float)tileWidth, (float)tileHeight}, origin, rotation, tint);
+ }
+
+ if (dy < dest.height)
+ {
+ DrawTexturePro(texture, (Rectangle){source.x, source.y, source.width, ((float)(dest.height - dy)/tileHeight)*source.height},
+ (Rectangle){dest.x + dx, dest.y + dy, (float)tileWidth, dest.height - dy}, origin, rotation, tint);
+ }
+ }
+
+ // Fit last column of tiles
+ if (dx < dest.width)
+ {
+ int dy = 0;
+ for (;dy+tileHeight < dest.height; dy += tileHeight)
+ {
+ DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)(dest.width - dx)/tileWidth)*source.width, source.height},
+ (Rectangle){dest.x + dx, dest.y + dy, dest.width - dx, (float)tileHeight}, origin, rotation, tint);
+ }
+
+ // Draw final tile in the bottom right corner
+ if (dy < dest.height)
+ {
+ DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)(dest.width - dx)/tileWidth)*source.width, ((float)(dest.height - dy)/tileHeight)*source.height},
+ (Rectangle){dest.x + dx, dest.y + dy, dest.width - dx, dest.height - dy}, origin, rotation, tint);
+ }
+ }
+ }
+}
diff --git a/examples/textures/textures_fog_of_war.c b/examples/textures/textures_fog_of_war.c
index d89386c86..433f364a6 100644
--- a/examples/textures/textures_fog_of_war.c
+++ b/examples/textures/textures_fog_of_war.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2018-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2018-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -51,7 +51,7 @@ int main(void)
// Load map tiles (generating 2 random tile ids for testing)
// NOTE: Map tile ids should be probably loaded from an external map file
- for (int i = 0; i < map.tilesY*map.tilesX; i++) map.tileIds[i] = GetRandomValue(0, 1);
+ for (unsigned int i = 0; i < map.tilesY*map.tilesX; i++) map.tileIds[i] = GetRandomValue(0, 1);
// Player position on the screen (pixel coordinates, not tile coordinates)
Vector2 playerPosition = { 180, 130 };
@@ -80,12 +80,12 @@ int main(void)
// Check player position to avoid moving outside tilemap limits
if (playerPosition.x < 0) playerPosition.x = 0;
- else if ((playerPosition.x + PLAYER_SIZE) > (map.tilesX*MAP_TILE_SIZE)) playerPosition.x = map.tilesX*MAP_TILE_SIZE - PLAYER_SIZE;
+ else if ((playerPosition.x + PLAYER_SIZE) > (map.tilesX*MAP_TILE_SIZE)) playerPosition.x = (float)map.tilesX*MAP_TILE_SIZE - PLAYER_SIZE;
if (playerPosition.y < 0) playerPosition.y = 0;
- else if ((playerPosition.y + PLAYER_SIZE) > (map.tilesY*MAP_TILE_SIZE)) playerPosition.y = map.tilesY*MAP_TILE_SIZE - PLAYER_SIZE;
+ else if ((playerPosition.y + PLAYER_SIZE) > (map.tilesY*MAP_TILE_SIZE)) playerPosition.y = (float)map.tilesY*MAP_TILE_SIZE - PLAYER_SIZE;
// Previous visited tiles are set to partial fog
- for (int i = 0; i < map.tilesX*map.tilesY; i++) if (map.tileFog[i] == 1) map.tileFog[i] = 2;
+ for (unsigned int i = 0; i < map.tilesX*map.tilesY; i++) if (map.tileFog[i] == 1) map.tileFog[i] = 2;
// Get current tile position from player pixel position
playerTileX = (int)((playerPosition.x + MAP_TILE_SIZE/2)/MAP_TILE_SIZE);
@@ -95,7 +95,7 @@ int main(void)
// NOTE: We check tilemap limits to avoid processing tiles out-of-array-bounds (it could crash program)
for (int y = (playerTileY - PLAYER_TILE_VISIBILITY); y < (playerTileY + PLAYER_TILE_VISIBILITY); y++)
for (int x = (playerTileX - PLAYER_TILE_VISIBILITY); x < (playerTileX + PLAYER_TILE_VISIBILITY); x++)
- if ((x >= 0) && (x < map.tilesX) && (y >= 0) && (y < map.tilesY)) map.tileFog[y*map.tilesX + x] = 1;
+ if ((x >= 0) && (x < (int)map.tilesX) && (y >= 0) && (y < (int)map.tilesY)) map.tileFog[y*map.tilesX + x] = 1;
//----------------------------------------------------------------------------------
// Draw
@@ -103,8 +103,8 @@ int main(void)
// Draw fog of war to a small render texture for automatic smoothing on scaling
BeginTextureMode(fogOfWar);
ClearBackground(BLANK);
- for (int y = 0; y < map.tilesY; y++)
- for (int x = 0; x < map.tilesX; x++)
+ for (unsigned int y = 0; y < map.tilesY; y++)
+ for (unsigned int x = 0; x < map.tilesX; x++)
if (map.tileFog[y*map.tilesX + x] == 0) DrawRectangle(x, y, 1, 1, BLACK);
else if (map.tileFog[y*map.tilesX + x] == 2) DrawRectangle(x, y, 1, 1, Fade(BLACK, 0.8f));
EndTextureMode();
@@ -113,9 +113,9 @@ int main(void)
ClearBackground(RAYWHITE);
- for (int y = 0; y < map.tilesY; y++)
+ for (unsigned int y = 0; y < map.tilesY; y++)
{
- for (int x = 0; x < map.tilesX; x++)
+ for (unsigned int x = 0; x < map.tilesX; x++)
{
// Draw tiles from id (and tile borders)
DrawRectangle(x*MAP_TILE_SIZE, y*MAP_TILE_SIZE, MAP_TILE_SIZE, MAP_TILE_SIZE,
@@ -129,8 +129,8 @@ int main(void)
// Draw fog of war (scaled to full map, bilinear filtering)
- DrawTexturePro(fogOfWar.texture, (Rectangle){ 0, 0, fogOfWar.texture.width, -fogOfWar.texture.height },
- (Rectangle){ 0, 0, map.tilesX*MAP_TILE_SIZE, map.tilesY*MAP_TILE_SIZE },
+ DrawTexturePro(fogOfWar.texture, (Rectangle){ 0, 0, (float)fogOfWar.texture.width, (float)-fogOfWar.texture.height },
+ (Rectangle){ 0, 0, (float)map.tilesX*MAP_TILE_SIZE, (float)map.tilesY*MAP_TILE_SIZE },
(Vector2){ 0, 0 }, 0.0f, WHITE);
// Draw player current tile
diff --git a/examples/textures/textures_gif_player.c b/examples/textures/textures_gif_player.c
index 099a71268..108522835 100644
--- a/examples/textures/textures_gif_player.c
+++ b/examples/textures/textures_gif_player.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2021-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2021-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_image_drawing.c b/examples/textures/textures_image_drawing.c
index 190fb8594..967cb52a4 100644
--- a/examples/textures/textures_image_drawing.c
+++ b/examples/textures/textures_image_drawing.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2016-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2016-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_image_generation.c b/examples/textures/textures_image_generation.c
index ed67be036..359dc236a 100644
--- a/examples/textures/textures_image_generation.c
+++ b/examples/textures/textures_image_generation.c
@@ -7,13 +7,13 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2O17-2022 Wilhem Barbier (@nounoursheureux) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2O17-2023 Wilhem Barbier (@nounoursheureux) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
-#define NUM_TEXTURES 6 // Currently we have 7 generation algorithms
+#define NUM_TEXTURES 9 // Currently we have 8 generation algorithms but some are have multiple purposes (Linear and Square Gradients)
//------------------------------------------------------------------------------------
// Program main entry point
@@ -27,28 +27,37 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [textures] example - procedural images generation");
- Image verticalGradient = GenImageGradientV(screenWidth, screenHeight, RED, BLUE);
- Image horizontalGradient = GenImageGradientH(screenWidth, screenHeight, RED, BLUE);
+ Image verticalGradient = GenImageGradientLinear(screenWidth, screenHeight, 0, RED, BLUE);
+ Image horizontalGradient = GenImageGradientLinear(screenWidth, screenHeight, 90, RED, BLUE);
+ Image diagonalGradient = GenImageGradientLinear(screenWidth, screenHeight, 45, RED, BLUE);
Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.0f, WHITE, BLACK);
+ Image squareGradient = GenImageGradientSquare(screenWidth, screenHeight, 0.0f, WHITE, BLACK);
Image checked = GenImageChecked(screenWidth, screenHeight, 32, 32, RED, BLUE);
Image whiteNoise = GenImageWhiteNoise(screenWidth, screenHeight, 0.5f);
+ Image perlinNoise = GenImagePerlinNoise(screenWidth, screenHeight, 50, 50, 4.0f);
Image cellular = GenImageCellular(screenWidth, screenHeight, 32);
Texture2D textures[NUM_TEXTURES] = { 0 };
textures[0] = LoadTextureFromImage(verticalGradient);
textures[1] = LoadTextureFromImage(horizontalGradient);
- textures[2] = LoadTextureFromImage(radialGradient);
- textures[3] = LoadTextureFromImage(checked);
- textures[4] = LoadTextureFromImage(whiteNoise);
- textures[5] = LoadTextureFromImage(cellular);
+ textures[2] = LoadTextureFromImage(diagonalGradient);
+ textures[3] = LoadTextureFromImage(radialGradient);
+ textures[4] = LoadTextureFromImage(squareGradient);
+ textures[5] = LoadTextureFromImage(checked);
+ textures[6] = LoadTextureFromImage(whiteNoise);
+ textures[7] = LoadTextureFromImage(perlinNoise);
+ textures[8] = LoadTextureFromImage(cellular);
// Unload image data (CPU RAM)
UnloadImage(verticalGradient);
UnloadImage(horizontalGradient);
+ UnloadImage(diagonalGradient);
UnloadImage(radialGradient);
+ UnloadImage(squareGradient);
UnloadImage(checked);
UnloadImage(whiteNoise);
+ UnloadImage(perlinNoise);
UnloadImage(cellular);
int currentTexture = 0;
@@ -83,10 +92,13 @@ int main(void)
{
case 0: DrawText("VERTICAL GRADIENT", 560, 10, 20, RAYWHITE); break;
case 1: DrawText("HORIZONTAL GRADIENT", 540, 10, 20, RAYWHITE); break;
- case 2: DrawText("RADIAL GRADIENT", 580, 10, 20, LIGHTGRAY); break;
- case 3: DrawText("CHECKED", 680, 10, 20, RAYWHITE); break;
- case 4: DrawText("WHITE NOISE", 640, 10, 20, RED); break;
- case 5: DrawText("CELLULAR", 670, 10, 20, RAYWHITE); break;
+ case 2: DrawText("DIAGONAL GRADIENT", 540, 10, 20, RAYWHITE); break;
+ case 3: DrawText("RADIAL GRADIENT", 580, 10, 20, LIGHTGRAY); break;
+ case 4: DrawText("SQUARE GRADIENT", 580, 10, 20, LIGHTGRAY); break;
+ case 5: DrawText("CHECKED", 680, 10, 20, RAYWHITE); break;
+ case 6: DrawText("WHITE NOISE", 640, 10, 20, RED); break;
+ case 7: DrawText("PERLIN NOISE", 640, 10, 20, RED); break;
+ case 8: DrawText("CELLULAR", 670, 10, 20, RAYWHITE); break;
default: break;
}
diff --git a/examples/textures/textures_image_loading.c b/examples/textures/textures_image_loading.c
index 1e5cb6c5a..b1bfe09f7 100644
--- a/examples/textures/textures_image_loading.c
+++ b/examples/textures/textures_image_loading.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_image_processing.c b/examples/textures/textures_image_processing.c
index 7786ab214..6e6c85482 100644
--- a/examples/textures/textures_image_processing.c
+++ b/examples/textures/textures_image_processing.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2016-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2016-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -17,7 +17,7 @@
#include // Required for: free()
-#define NUM_PROCESSES 8
+#define NUM_PROCESSES 9
typedef enum {
NONE = 0,
@@ -26,6 +26,7 @@ typedef enum {
COLOR_INVERT,
COLOR_CONTRAST,
COLOR_BRIGHTNESS,
+ GAUSSIAN_BLUR,
FLIP_VERTICAL,
FLIP_HORIZONTAL
} ImageProcess;
@@ -37,6 +38,7 @@ static const char *processText[] = {
"COLOR INVERT",
"COLOR CONTRAST",
"COLOR BRIGHTNESS",
+ "GAUSSIAN BLUR",
"FLIP VERTICAL",
"FLIP HORIZONTAL"
};
@@ -125,6 +127,7 @@ int main(void)
case COLOR_INVERT: ImageColorInvert(&imCopy); break;
case COLOR_CONTRAST: ImageColorContrast(&imCopy, -40); break;
case COLOR_BRIGHTNESS: ImageColorBrightness(&imCopy, -80); break;
+ case GAUSSIAN_BLUR: ImageBlurGaussian(&imCopy, 10); break;
case FLIP_VERTICAL: ImageFlipVertical(&imCopy); break;
case FLIP_HORIZONTAL: ImageFlipHorizontal(&imCopy); break;
default: break;
diff --git a/examples/textures/textures_image_rotate.c b/examples/textures/textures_image_rotate.c
new file mode 100644
index 000000000..a590e1e0a
--- /dev/null
+++ b/examples/textures/textures_image_rotate.c
@@ -0,0 +1,79 @@
+/*******************************************************************************************
+*
+* raylib [textures] example - Image Rotation
+*
+* Example originally created with raylib 1.0, last time updated with raylib 1.0
+*
+* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
+* BSD-like license that allows static linking with closed source software
+*
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#define NUM_TEXTURES 3
+
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
+int main(void)
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture rotation");
+
+ // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
+ Image image45 = LoadImage("resources/raylib_logo.png");
+ Image image90 = LoadImage("resources/raylib_logo.png");
+ Image imageNeg90 = LoadImage("resources/raylib_logo.png");
+
+ ImageRotate(&image45, 45);
+ ImageRotate(&image90, 90);
+ ImageRotate(&imageNeg90, -90);
+
+ Texture2D textures[NUM_TEXTURES] = { 0 };
+
+ textures[0] = LoadTextureFromImage(image45);
+ textures[1] = LoadTextureFromImage(image90);
+ textures[2] = LoadTextureFromImage(imageNeg90);
+
+ int currentTexture = 0;
+ //---------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) || IsKeyPressed(KEY_RIGHT))
+ {
+ currentTexture = (currentTexture + 1)%NUM_TEXTURES; // Cycle between the textures
+ }
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ DrawTexture(textures[currentTexture], screenWidth/2 - textures[currentTexture].width/2, screenHeight/2 - textures[currentTexture].height/2, WHITE);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ for (int i = 0; i < NUM_TEXTURES; i++) UnloadTexture(textures[i]);
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}
\ No newline at end of file
diff --git a/examples/textures/textures_image_rotate.png b/examples/textures/textures_image_rotate.png
new file mode 100644
index 000000000..64bbc54e4
Binary files /dev/null and b/examples/textures/textures_image_rotate.png differ
diff --git a/examples/textures/textures_image_text.c b/examples/textures/textures_image_text.c
index f4c919d53..50db688de 100644
--- a/examples/textures/textures_image_text.c
+++ b/examples/textures/textures_image_text.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2017-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2017-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_logo_raylib.c b/examples/textures/textures_logo_raylib.c
index 5afd14753..8bd865811 100644
--- a/examples/textures/textures_logo_raylib.c
+++ b/examples/textures/textures_logo_raylib.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_mouse_painting.c b/examples/textures/textures_mouse_painting.c
index eb6dc480a..e985cee0c 100644
--- a/examples/textures/textures_mouse_painting.c
+++ b/examples/textures/textures_mouse_painting.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Chris Dill (@MysteriousSpace) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Chris Dill (@MysteriousSpace) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_npatch_drawing.c b/examples/textures/textures_npatch_drawing.c
index 515ad9b52..f85aaa129 100644
--- a/examples/textures/textures_npatch_drawing.c
+++ b/examples/textures/textures_npatch_drawing.c
@@ -11,7 +11,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2018-2022 Jorge A. Gomes (@overdev) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2018-2023 Jorge A. Gomes (@overdev) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_particles_blending.c b/examples/textures/textures_particles_blending.c
index 7f1952f05..ec144ff4b 100644
--- a/examples/textures/textures_particles_blending.c
+++ b/examples/textures/textures_particles_blending.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2017-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2017-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_polygon.c b/examples/textures/textures_polygon.c
index 357862c32..cf59af979 100644
--- a/examples/textures/textures_polygon.c
+++ b/examples/textures/textures_polygon.c
@@ -9,15 +9,20 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2021-2022 Chris Camacho (@codifies) and Ramon Santamaria (@raysan5)
+* Copyright (c) 2021-2023 Chris Camacho (@codifies) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
+
+#include "rlgl.h" // Required for: Vertex definition
#include "raymath.h"
#define MAX_POINTS 11 // 10 points and back to the start
+// Draw textured polygon, defined by vertex and texture coordinates
+void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint);
+
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
@@ -86,7 +91,7 @@ int main(void)
DrawText("textured polygon", 20, 20, 20, DARKGRAY);
- DrawTexturePoly(texture, (Vector2){ GetScreenWidth()/2, GetScreenHeight()/2 },
+ DrawTexturePoly(texture, (Vector2){ GetScreenWidth()/2.0f, GetScreenHeight()/2.0f },
positions, texcoords, MAX_POINTS, WHITE);
EndDrawing();
@@ -102,3 +107,34 @@ int main(void)
return 0;
}
+
+// Draw textured polygon, defined by vertex and texture coordinates
+// NOTE: Polygon center must have straight line path to all points
+// without crossing perimeter, points must be in anticlockwise order
+void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint)
+{
+ rlSetTexture(texture.id);
+
+ // Texturing is only supported on RL_QUADS
+ rlBegin(RL_QUADS);
+
+ rlColor4ub(tint.r, tint.g, tint.b, tint.a);
+
+ for (int i = 0; i < pointCount - 1; i++)
+ {
+ rlTexCoord2f(0.5f, 0.5f);
+ rlVertex2f(center.x, center.y);
+
+ rlTexCoord2f(texcoords[i].x, texcoords[i].y);
+ rlVertex2f(points[i].x + center.x, points[i].y + center.y);
+
+ rlTexCoord2f(texcoords[i + 1].x, texcoords[i + 1].y);
+ rlVertex2f(points[i + 1].x + center.x, points[i + 1].y + center.y);
+
+ rlTexCoord2f(texcoords[i + 1].x, texcoords[i + 1].y);
+ rlVertex2f(points[i + 1].x + center.x, points[i + 1].y + center.y);
+ }
+ rlEnd();
+
+ rlSetTexture(0);
+}
diff --git a/examples/textures/textures_raw_data.c b/examples/textures/textures_raw_data.c
index cd0c9bf0e..22d7cc06f 100644
--- a/examples/textures/textures_raw_data.c
+++ b/examples/textures/textures_raw_data.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_sprite_anim.c b/examples/textures/textures_sprite_anim.c
index aa9f18aeb..99efe2eab 100644
--- a/examples/textures/textures_sprite_anim.c
+++ b/examples/textures/textures_sprite_anim.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_sprite_button.c b/examples/textures/textures_sprite_button.c
index 5e2a4011c..bd9891826 100644
--- a/examples/textures/textures_sprite_button.c
+++ b/examples/textures/textures_sprite_button.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_sprite_explosion.c b/examples/textures/textures_sprite_explosion.c
index 32c69849c..a6cbd3e5b 100644
--- a/examples/textures/textures_sprite_explosion.c
+++ b/examples/textures/textures_sprite_explosion.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2019-2022 Anata and Ramon Santamaria (@raysan5)
+* Copyright (c) 2019-2023 Anata and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_srcrec_dstrec.c b/examples/textures/textures_srcrec_dstrec.c
index 1839fc780..caf8f64b3 100644
--- a/examples/textures/textures_srcrec_dstrec.c
+++ b/examples/textures/textures_srcrec_dstrec.c
@@ -7,7 +7,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/examples/textures/textures_textured_curve.c b/examples/textures/textures_textured_curve.c
new file mode 100644
index 000000000..3c2f0606a
--- /dev/null
+++ b/examples/textures/textures_textured_curve.c
@@ -0,0 +1,259 @@
+/*******************************************************************************************
+*
+* raylib [textures] example - Draw a texture along a segmented curve
+*
+* Example originally created with raylib 4.5, last time updated with raylib 4.5
+*
+* Example contributed by Jeffery Myers and reviewed by Ramon Santamaria (@raysan5)
+*
+* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
+* BSD-like license that allows static linking with closed source software
+*
+* Copyright (c) 2022-2023 Jeffery Myers and Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+
+#include "raylib.h"
+
+#include "raymath.h"
+#include "rlgl.h"
+
+#include // Required for: powf()
+#include // Required for: NULL
+
+//----------------------------------------------------------------------------------
+// Global Variables Definition
+//----------------------------------------------------------------------------------
+static Texture texRoad = { 0 };
+
+static bool showCurve = false;
+
+static float curveWidth = 50;
+static int curveSegments = 24;
+
+static Vector2 curveStartPosition = { 0 };
+static Vector2 curveStartPositionTangent = { 0 };
+
+static Vector2 curveEndPosition = { 0 };
+static Vector2 curveEndPositionTangent = { 0 };
+
+static Vector2 *curveSelectedPoint = NULL;
+
+//----------------------------------------------------------------------------------
+// Module Functions Declaration
+//----------------------------------------------------------------------------------
+static void UpdateOptions(void);
+static void UpdateCurve(void);
+static void DrawCurve(void);
+static void DrawTexturedCurve(void);
+
+
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
+ SetConfigFlags(FLAG_VSYNC_HINT | FLAG_MSAA_4X_HINT);
+ InitWindow(screenWidth, screenHeight, "raylib [textures] examples - textured curve");
+
+ // Load the road texture
+ texRoad = LoadTexture("resources/road.png");
+ SetTextureFilter(texRoad, TEXTURE_FILTER_BILINEAR);
+
+ // Setup the curve
+ curveStartPosition = (Vector2){ 80, 100 };
+ curveStartPositionTangent = (Vector2){ 100, 300 };
+
+ curveEndPosition = (Vector2){ 700, 350 };
+ curveEndPositionTangent = (Vector2){ 600, 100 };
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ UpdateCurve();
+ UpdateOptions();
+
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ DrawTexturedCurve();
+ DrawCurve();
+
+ DrawText("Drag points to move curve, press SPACE to show/hide base curve", 10, 10, 10, DARKGRAY);
+ DrawText(TextFormat("Curve width: %2.0f (Use + and - to adjust)", curveWidth), 10, 30, 10, DARKGRAY);
+ DrawText(TextFormat("Curve segments: %d (Use LEFT and RIGHT to adjust)", curveSegments), 10, 50, 10, DARKGRAY);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadTexture(texRoad);
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------------
+// Module Functions Definition
+//----------------------------------------------------------------------------------
+static void DrawCurve(void)
+{
+ if (showCurve) DrawLineBezierCubic(curveStartPosition, curveEndPosition, curveStartPositionTangent, curveEndPositionTangent, 2, BLUE);
+
+ // Draw the various control points and highlight where the mouse is
+ DrawLineV(curveStartPosition, curveStartPositionTangent, SKYBLUE);
+ DrawLineV(curveEndPosition, curveEndPositionTangent, PURPLE);
+ Vector2 mouse = GetMousePosition();
+
+ if (CheckCollisionPointCircle(mouse, curveStartPosition, 6)) DrawCircleV(curveStartPosition, 7, YELLOW);
+ DrawCircleV(curveStartPosition, 5, RED);
+
+ if (CheckCollisionPointCircle(mouse, curveStartPositionTangent, 6)) DrawCircleV(curveStartPositionTangent, 7, YELLOW);
+ DrawCircleV(curveStartPositionTangent, 5, MAROON);
+
+ if (CheckCollisionPointCircle(mouse, curveEndPosition, 6)) DrawCircleV(curveEndPosition, 7, YELLOW);
+ DrawCircleV(curveEndPosition, 5, GREEN);
+
+ if (CheckCollisionPointCircle(mouse, curveEndPositionTangent, 6)) DrawCircleV(curveEndPositionTangent, 7, YELLOW);
+ DrawCircleV(curveEndPositionTangent, 5, DARKGREEN);
+}
+
+static void UpdateCurve(void)
+{
+ // If the mouse is not down, we are not editing the curve so clear the selection
+ if (!IsMouseButtonDown(MOUSE_LEFT_BUTTON))
+ {
+ curveSelectedPoint = NULL;
+ return;
+ }
+
+ // If a point was selected, move it
+ if (curveSelectedPoint)
+ {
+ *curveSelectedPoint = Vector2Add(*curveSelectedPoint, GetMouseDelta());
+ return;
+ }
+
+ // The mouse is down, and nothing was selected, so see if anything was picked
+ Vector2 mouse = GetMousePosition();
+
+ if (CheckCollisionPointCircle(mouse, curveStartPosition, 6)) curveSelectedPoint = &curveStartPosition;
+ else if (CheckCollisionPointCircle(mouse, curveStartPositionTangent, 6)) curveSelectedPoint = &curveStartPositionTangent;
+ else if (CheckCollisionPointCircle(mouse, curveEndPosition, 6)) curveSelectedPoint = &curveEndPosition;
+ else if (CheckCollisionPointCircle(mouse, curveEndPositionTangent, 6)) curveSelectedPoint = &curveEndPositionTangent;
+}
+
+static void DrawTexturedCurve(void)
+{
+ const float step = 1.0f/curveSegments;
+
+ Vector2 previous = curveStartPosition;
+ Vector2 previousTangent = { 0 };
+ float previousV = 0;
+
+ // We can't compute a tangent for the first point, so we need to reuse the tangent from the first segment
+ bool tangentSet = false;
+
+ Vector2 current = { 0 };
+ float t = 0.0f;
+
+ for (int i = 1; i <= curveSegments; i++)
+ {
+ // Segment the curve
+ t = step*i;
+ float a = powf(1 - t, 3);
+ float b = 3*powf(1 - t, 2)*t;
+ float c = 3*(1 - t)*powf(t, 2);
+ float d = powf(t, 3);
+
+ // Compute the endpoint for this segment
+ current.y = a*curveStartPosition.y + b*curveStartPositionTangent.y + c*curveEndPositionTangent.y + d*curveEndPosition.y;
+ current.x = a*curveStartPosition.x + b*curveStartPositionTangent.x + c*curveEndPositionTangent.x + d*curveEndPosition.x;
+
+ // Vector from previous to current
+ Vector2 delta = { current.x - previous.x, current.y - previous.y };
+
+ // The right hand normal to the delta vector
+ Vector2 normal = Vector2Normalize((Vector2){ -delta.y, delta.x });
+
+ // The v texture coordinate of the segment (add up the length of all the segments so far)
+ float v = previousV + Vector2Length(delta);
+
+ // Make sure the start point has a normal
+ if (!tangentSet)
+ {
+ previousTangent = normal;
+ tangentSet = true;
+ }
+
+ // Extend out the normals from the previous and current points to get the quad for this segment
+ Vector2 prevPosNormal = Vector2Add(previous, Vector2Scale(previousTangent, curveWidth));
+ Vector2 prevNegNormal = Vector2Add(previous, Vector2Scale(previousTangent, -curveWidth));
+
+ Vector2 currentPosNormal = Vector2Add(current, Vector2Scale(normal, curveWidth));
+ Vector2 currentNegNormal = Vector2Add(current, Vector2Scale(normal, -curveWidth));
+
+ // Draw the segment as a quad
+ rlSetTexture(texRoad.id);
+ rlBegin(RL_QUADS);
+
+ rlColor4ub(255,255,255,255);
+ rlNormal3f(0.0f, 0.0f, 1.0f);
+
+ rlTexCoord2f(0, previousV);
+ rlVertex2f(prevNegNormal.x, prevNegNormal.y);
+
+ rlTexCoord2f(1, previousV);
+ rlVertex2f(prevPosNormal.x, prevPosNormal.y);
+
+ rlTexCoord2f(1, v);
+ rlVertex2f(currentPosNormal.x, currentPosNormal.y);
+
+ rlTexCoord2f(0, v);
+ rlVertex2f(currentNegNormal.x, currentNegNormal.y);
+
+ rlEnd();
+
+ // The current step is the start of the next step
+ previous = current;
+ previousTangent = normal;
+ previousV = v;
+ }
+}
+
+static void UpdateOptions(void)
+{
+ if (IsKeyPressed(KEY_SPACE)) showCurve = !showCurve;
+
+ // Update with
+ if (IsKeyPressed(KEY_EQUAL)) curveWidth += 2;
+ if (IsKeyPressed(KEY_MINUS)) curveWidth -= 2;
+
+ if (curveWidth < 2) curveWidth = 2;
+
+ // Update segments
+ if (IsKeyPressed(KEY_LEFT)) curveSegments -= 2;
+ if (IsKeyPressed(KEY_RIGHT)) curveSegments += 2;
+
+ if (curveSegments < 2) curveSegments = 2;
+}
diff --git a/examples/textures/textures_textured_curve.png b/examples/textures/textures_textured_curve.png
new file mode 100644
index 000000000..6d5efacb6
Binary files /dev/null and b/examples/textures/textures_textured_curve.png differ
diff --git a/examples/textures/textures_to_image.c b/examples/textures/textures_to_image.c
index 9acdf2334..fd3c848e8 100644
--- a/examples/textures/textures_to_image.c
+++ b/examples/textures/textures_to_image.c
@@ -9,7 +9,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/parser/LICENSE b/parser/LICENSE
index fac92d37b..125d7dbae 100644
--- a/parser/LICENSE
+++ b/parser/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2021-2022 Ramon Santamaria (@raysan5)
+Copyright (c) 2021-2023 Ramon Santamaria (@raysan5)
This software is provided "as-is", without any express or implied warranty. In no event
will the authors be held liable for any damages arising from the use of this software.
diff --git a/parser/Makefile b/parser/Makefile
index e222f4e79..165192463 100644
--- a/parser/Makefile
+++ b/parser/Makefile
@@ -1,28 +1,50 @@
EXTENSION?=txt
FORMAT?=DEFAULT
+.PHONY: all parse clean raylib_api
-raylib_api:
- cc raylib_parser.c -o raylib_parser
- ./raylib_parser -i ../src/raylib.h -o raylib_api.txt -f DEFAULT -d RLAPI
- ./raylib_parser -i ../src/raylib.h -o raylib_api.json -f JSON -d RLAPI
- ./raylib_parser -i ../src/raylib.h -o raylib_api.xml -f XML -d RLAPI
- ./raylib_parser -i ../src/raylib.h -o raylib_api.lua -f LUA -d RLAPI
-all:
+raylib_parser: raylib_parser.c
cc raylib_parser.c -o raylib_parser
+
+raylib_api: ../src/raylib.h raylib_parser
+ FORMAT=DEFAULT EXTENSION=txt $(MAKE) raylib_api.txt
+ FORMAT=JSON EXTENSION=json $(MAKE) raylib_api.json
+ FORMAT=XML EXTENSION=xml $(MAKE) raylib_api.xml
+ FORMAT=LUA EXTENSION=lua $(MAKE) raylib_api.lua
+
+raylib_api.$(EXTENSION): ../src/raylib.h raylib_parser
+ ./raylib_parser -i ../src/raylib.h -o raylib_api.$(EXTENSION) -f $(FORMAT) -d RLAPI
+
+raymath_api.$(EXTENSION): ../src/raymath.h raylib_parser
+ ./raylib_parser -i ../src/raymath.h -o raymath_api.$(EXTENSION) -f $(FORMAT) -d RMAPI
+
+rlgl_api.$(EXTENSION): ../src/rlgl.h raylib_parser
+ ./raylib_parser -i ../src/rlgl.h -o rlgl_api.$(EXTENSION) -f $(FORMAT) -d RLAPI -t "RLGL IMPLEMENTATION"
+
+reasings_api.$(EXTENSION): ../examples/others/reasings.h raylib_parser
+ ./raylib_parser -i ../examples/others/reasings.h -o reasings_api.$(EXTENSION) -f $(FORMAT) -d EASEDEF
+
+rmem_api.$(EXTENSION): ../rmem.h raylib_parser
+ ./raylib_parser -i ../rmem.h -o rmem_api.$(EXTENSION) -f $(FORMAT) -d RMEMAPI -t "RMEM IMPLEMENTATION"
+
+physac_api.$(EXTENSION): ../physac.h raylib_parser
+ ./raylib_parser -i ../physac.h -o physac_api.$(EXTENSION) -f $(FORMAT) -d PHYSACDEF -t "PHYSAC IMPLEMENTATION"
+
+raygui_api.$(EXTENSION): ../raygui.h raylib_parser
+ ./raylib_parser -i ../raygui.h -o raygui_api.$(EXTENSION) -f $(FORMAT) -d RAYGUIAPI -t "RAYGUI IMPLEMENTATION"
+
+parse: raylib_api.$(EXTENSION) raymath_api.$(EXTENSION) rlgl_api.$(EXTENSION) rmem_api.$(EXTENSION) physac_api.$(EXTENSION) raygui_api.$(EXTENSION)
+
+
+# `make parse` (and therefore `make all) requires
+# rmem.h, physac.h and raygui.h to exist in the correct directory
+# API files for individual headers can be created likeso, provided the relevant header exists:
+# FORMAT=JSON EXTENSION=json make raygui_api.json
+all: raylib_parser
FORMAT=DEFAULT EXTENSION=txt $(MAKE) parse
FORMAT=JSON EXTENSION=json $(MAKE) parse
FORMAT=XML EXTENSION=xml $(MAKE) parse
FORMAT=LUA EXTENSION=lua $(MAKE) parse
-parse:
- ./raylib_parser -i ../src/raylib.h -o raylib_api.$(EXTENSION) -f $(FORMAT) -d RLAPI
- ./raylib_parser -i ../src/raymath.h -o raymath_api.$(EXTENSION) -f $(FORMAT) -d RMAPI
- ./raylib_parser -i ../src/rlgl.h -o rlgl_api.$(EXTENSION) -f $(FORMAT) -d RLAPI -t "RLGL IMPLEMENTATION"
- ./raylib_parser -i ../src/easings.h -o easings_api.$(EXTENSION) -f $(FORMAT) -d EASEDEF
- ./raylib_parser -i ../src/rmem.h -o rmem_api.$(EXTENSION) -f $(FORMAT) -d RMEMAPI -t "RMEM IMPLEMENTATION"
- ./raylib_parser -i ../physac.h -o physac_api.$(EXTENSION) -f $(FORMAT) -d PHYSACDEF -t "PHYSAC IMPLEMENTATION"
- ./raylib_parser -i ../raygui.h -o raygui_api.$(EXTENSION) -f $(FORMAT) -d RAYGUIAPI -t "RAYGUI IMPLEMENTATION"
-
clean:
rm -f raylib_parser *.json *.txt *.xml *.lua
diff --git a/parser/README.md b/parser/README.md
index 4d00fde06..0c55f20ea 100644
--- a/parser/README.md
+++ b/parser/README.md
@@ -19,7 +19,7 @@ Check `raylib_parser.c` for details about those structs.
// //
// more info and bugs-report: github.com/raysan5/raylib/parser //
// //
-// Copyright (c) 2021-2022 Ramon Santamaria (@raysan5) //
+// Copyright (c) 2021-2023 Ramon Santamaria (@raysan5) //
// //
//////////////////////////////////////////////////////////////////////////////////
diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json
index 11288bf1b..b42f03a83 100644
--- a/parser/output/raylib_api.json
+++ b/parser/output/raylib_api.json
@@ -6,10 +6,28 @@
"value": "",
"description": ""
},
+ {
+ "name": "RAYLIB_VERSION_MAJOR",
+ "type": "INT",
+ "value": 4,
+ "description": ""
+ },
+ {
+ "name": "RAYLIB_VERSION_MINOR",
+ "type": "INT",
+ "value": 6,
+ "description": ""
+ },
+ {
+ "name": "RAYLIB_VERSION_PATCH",
+ "type": "INT",
+ "value": 0,
+ "description": ""
+ },
{
"name": "RAYLIB_VERSION",
"type": "STRING",
- "value": "4.2",
+ "value": "4.6-dev",
"description": ""
},
{
@@ -385,7 +403,7 @@
},
{
"name": "Matrix",
- "description": "Matrix, 4x4 components, column major, OpenGL style, right handed",
+ "description": "Matrix, 4x4 components, column major, OpenGL style, right-handed",
"fields": [
{
"type": "float",
@@ -729,7 +747,7 @@
{
"type": "float",
"name": "fovy",
- "description": "Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic"
+ "description": "Camera field-of-view aperture in Y (degrees) in perspective, used as near plane width in orthographic"
},
{
"type": "int",
@@ -905,7 +923,7 @@
},
{
"name": "Transform",
- "description": "Transform, vectex transformation data",
+ "description": "Transform, vertex transformation data",
"fields": [
{
"type": "Vector3",
@@ -1014,6 +1032,11 @@
"type": "Transform **",
"name": "framePoses",
"description": "Poses array by frame"
+ },
+ {
+ "type": "char[32]",
+ "name": "name",
+ "description": "Animation name"
}
]
},
@@ -1045,12 +1068,12 @@
{
"type": "float",
"name": "distance",
- "description": "Distance to nearest hit"
+ "description": "Distance to the nearest hit"
},
{
"type": "Vector3",
"name": "point",
- "description": "Point of nearest hit"
+ "description": "Point of the nearest hit"
},
{
"type": "Vector3",
@@ -2051,7 +2074,7 @@
{
"name": "MOUSE_BUTTON_FORWARD",
"value": 5,
- "description": "Mouse button fordward (advanced mouse device)"
+ "description": "Mouse button forward (advanced mouse device)"
},
{
"name": "MOUSE_BUTTON_BACK",
@@ -2112,7 +2135,7 @@
{
"name": "MOUSE_CURSOR_RESIZE_ALL",
"value": 9,
- "description": "The omni-directional resize/move cursor shape"
+ "description": "The omnidirectional resize/move cursor shape"
},
{
"name": "MOUSE_CURSOR_NOT_ALLOWED",
@@ -2717,7 +2740,7 @@
{
"name": "CUBEMAP_LAYOUT_LINE_HORIZONTAL",
"value": 2,
- "description": "Layout is defined by an horizontal line with faces"
+ "description": "Layout is defined by a horizontal line with faces"
},
{
"name": "CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR",
@@ -2732,7 +2755,7 @@
{
"name": "CUBEMAP_LAYOUT_PANORAMA",
"value": 5,
- "description": "Layout is defined by a panorama image (equirectangular map)"
+ "description": "Layout is defined by a panorama image (equirrectangular map)"
}
]
},
@@ -2794,7 +2817,12 @@
{
"name": "BLEND_CUSTOM",
"value": 6,
- "description": "Blend textures using custom src/dst factors (use rlSetBlendMode())"
+ "description": "Blend textures using custom src/dst factors (use rlSetBlendFactors())"
+ },
+ {
+ "name": "BLEND_CUSTOM_SEPARATE",
+ "value": 7,
+ "description": "Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate())"
}
]
},
@@ -3144,7 +3172,7 @@
},
{
"name": "SetWindowIcon",
- "description": "Set icon for window (only PLATFORM_DESKTOP)",
+ "description": "Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)",
"returnType": "void",
"params": [
{
@@ -3153,6 +3181,21 @@
}
]
},
+ {
+ "name": "SetWindowIcons",
+ "description": "Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)",
+ "returnType": "void",
+ "params": [
+ {
+ "type": "Image *",
+ "name": "images"
+ },
+ {
+ "type": "int",
+ "name": "count"
+ }
+ ]
+ },
{
"name": "SetWindowTitle",
"description": "Set title for window (only PLATFORM_DESKTOP)",
@@ -3627,6 +3670,17 @@
}
]
},
+ {
+ "name": "IsShaderReady",
+ "description": "Check if a shader is ready",
+ "returnType": "bool",
+ "params": [
+ {
+ "type": "Shader",
+ "name": "shader"
+ }
+ ]
+ },
{
"name": "GetShaderLocation",
"description": "Get shader uniform location",
@@ -3971,7 +4025,7 @@
"returnType": "void *",
"params": [
{
- "type": "int",
+ "type": "unsigned int",
"name": "size"
}
]
@@ -3986,7 +4040,7 @@
"name": "ptr"
},
{
- "type": "int",
+ "type": "unsigned int",
"name": "size"
}
]
@@ -4119,7 +4173,7 @@
"returnType": "bool",
"params": [
{
- "type": "const char *",
+ "type": "const unsigned char *",
"name": "data"
},
{
@@ -4858,12 +4912,12 @@
"returnType": "float"
},
{
- "name": "SetCameraMode",
- "description": "Set camera mode (multiple camera modes available)",
+ "name": "UpdateCamera",
+ "description": "Update camera position for selected mode",
"returnType": "void",
"params": [
{
- "type": "Camera",
+ "type": "Camera *",
"name": "camera"
},
{
@@ -4873,77 +4927,25 @@
]
},
{
- "name": "UpdateCamera",
- "description": "Update camera position for selected mode",
+ "name": "UpdateCameraPro",
+ "description": "Update camera movement/rotation",
"returnType": "void",
"params": [
{
"type": "Camera *",
"name": "camera"
- }
- ]
- },
- {
- "name": "SetCameraPanControl",
- "description": "Set camera pan key to combine with mouse movement (free camera)",
- "returnType": "void",
- "params": [
- {
- "type": "int",
- "name": "keyPan"
- }
- ]
- },
- {
- "name": "SetCameraAltControl",
- "description": "Set camera alt key to combine with mouse movement (free camera)",
- "returnType": "void",
- "params": [
- {
- "type": "int",
- "name": "keyAlt"
- }
- ]
- },
- {
- "name": "SetCameraSmoothZoomControl",
- "description": "Set camera smooth zoom key to combine with mouse (free camera)",
- "returnType": "void",
- "params": [
- {
- "type": "int",
- "name": "keySmoothZoom"
- }
- ]
- },
- {
- "name": "SetCameraMoveControls",
- "description": "Set camera move controls (1st person and 3rd person cameras)",
- "returnType": "void",
- "params": [
- {
- "type": "int",
- "name": "keyFront"
},
{
- "type": "int",
- "name": "keyBack"
+ "type": "Vector3",
+ "name": "movement"
},
{
- "type": "int",
- "name": "keyRight"
+ "type": "Vector3",
+ "name": "rotation"
},
{
- "type": "int",
- "name": "keyLeft"
- },
- {
- "type": "int",
- "name": "keyUp"
- },
- {
- "type": "int",
- "name": "keyDown"
+ "type": "float",
+ "name": "zoom"
}
]
},
@@ -5995,6 +5997,25 @@
}
]
},
+ {
+ "name": "CheckCollisionPointPoly",
+ "description": "Check if point is within a polygon described by array of vertices",
+ "returnType": "bool",
+ "params": [
+ {
+ "type": "Vector2",
+ "name": "point"
+ },
+ {
+ "type": "Vector2 *",
+ "name": "points"
+ },
+ {
+ "type": "int",
+ "name": "pointCount"
+ }
+ ]
+ },
{
"name": "CheckCollisionLines",
"description": "Check the collision between two lines defined by two points each, returns collision point by reference",
@@ -6148,6 +6169,17 @@
"description": "Load image from screen buffer and (screenshot)",
"returnType": "Image"
},
+ {
+ "name": "IsImageReady",
+ "description": "Check if an image is ready",
+ "returnType": "bool",
+ "params": [
+ {
+ "type": "Image",
+ "name": "image"
+ }
+ ]
+ },
{
"name": "UnloadImage",
"description": "Unload image from CPU memory (RAM)",
@@ -6209,8 +6241,8 @@
]
},
{
- "name": "GenImageGradientV",
- "description": "Generate image: vertical gradient",
+ "name": "GenImageGradientLinear",
+ "description": "Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient",
"returnType": "Image",
"params": [
{
@@ -6221,36 +6253,17 @@
"type": "int",
"name": "height"
},
- {
- "type": "Color",
- "name": "top"
- },
- {
- "type": "Color",
- "name": "bottom"
- }
- ]
- },
- {
- "name": "GenImageGradientH",
- "description": "Generate image: horizontal gradient",
- "returnType": "Image",
- "params": [
{
"type": "int",
- "name": "width"
- },
- {
- "type": "int",
- "name": "height"
+ "name": "direction"
},
{
"type": "Color",
- "name": "left"
+ "name": "start"
},
{
"type": "Color",
- "name": "right"
+ "name": "end"
}
]
},
@@ -6281,6 +6294,33 @@
}
]
},
+ {
+ "name": "GenImageGradientSquare",
+ "description": "Generate image: square gradient",
+ "returnType": "Image",
+ "params": [
+ {
+ "type": "int",
+ "name": "width"
+ },
+ {
+ "type": "int",
+ "name": "height"
+ },
+ {
+ "type": "float",
+ "name": "density"
+ },
+ {
+ "type": "Color",
+ "name": "inner"
+ },
+ {
+ "type": "Color",
+ "name": "outer"
+ }
+ ]
+ },
{
"name": "GenImageChecked",
"description": "Generate image: checked",
@@ -6331,6 +6371,33 @@
}
]
},
+ {
+ "name": "GenImagePerlinNoise",
+ "description": "Generate image: perlin noise",
+ "returnType": "Image",
+ "params": [
+ {
+ "type": "int",
+ "name": "width"
+ },
+ {
+ "type": "int",
+ "name": "height"
+ },
+ {
+ "type": "int",
+ "name": "offsetX"
+ },
+ {
+ "type": "int",
+ "name": "offsetY"
+ },
+ {
+ "type": "float",
+ "name": "scale"
+ }
+ ]
+ },
{
"name": "GenImageCellular",
"description": "Generate image: cellular algorithm, bigger tileSize means bigger cells",
@@ -6350,6 +6417,25 @@
}
]
},
+ {
+ "name": "GenImageText",
+ "description": "Generate image: grayscale image from text data",
+ "returnType": "Image",
+ "params": [
+ {
+ "type": "int",
+ "name": "width"
+ },
+ {
+ "type": "int",
+ "name": "height"
+ },
+ {
+ "type": "const char *",
+ "name": "text"
+ }
+ ]
+ },
{
"name": "ImageCopy",
"description": "Create an image duplicate (useful for transformations)",
@@ -6527,6 +6613,21 @@
}
]
},
+ {
+ "name": "ImageBlurGaussian",
+ "description": "Apply Gaussian blur using a box blur approximation",
+ "returnType": "void",
+ "params": [
+ {
+ "type": "Image *",
+ "name": "image"
+ },
+ {
+ "type": "int",
+ "name": "blurSize"
+ }
+ ]
+ },
{
"name": "ImageResize",
"description": "Resize image (Bicubic scaling algorithm)",
@@ -6656,6 +6757,21 @@
}
]
},
+ {
+ "name": "ImageRotate",
+ "description": "Rotate image by input angle in degrees (-359 to 359) ",
+ "returnType": "void",
+ "params": [
+ {
+ "type": "Image *",
+ "name": "image"
+ },
+ {
+ "type": "int",
+ "name": "degrees"
+ }
+ ]
+ },
{
"name": "ImageRotateCW",
"description": "Rotate image clockwise 90deg",
@@ -6963,7 +7079,7 @@
},
{
"name": "ImageDrawCircle",
- "description": "Draw circle within an image",
+ "description": "Draw a filled circle within an image",
"returnType": "void",
"params": [
{
@@ -6990,7 +7106,57 @@
},
{
"name": "ImageDrawCircleV",
- "description": "Draw circle within an image (Vector version)",
+ "description": "Draw a filled circle within an image (Vector version)",
+ "returnType": "void",
+ "params": [
+ {
+ "type": "Image *",
+ "name": "dst"
+ },
+ {
+ "type": "Vector2",
+ "name": "center"
+ },
+ {
+ "type": "int",
+ "name": "radius"
+ },
+ {
+ "type": "Color",
+ "name": "color"
+ }
+ ]
+ },
+ {
+ "name": "ImageDrawCircleLines",
+ "description": "Draw circle outline within an image",
+ "returnType": "void",
+ "params": [
+ {
+ "type": "Image *",
+ "name": "dst"
+ },
+ {
+ "type": "int",
+ "name": "centerX"
+ },
+ {
+ "type": "int",
+ "name": "centerY"
+ },
+ {
+ "type": "int",
+ "name": "radius"
+ },
+ {
+ "type": "Color",
+ "name": "color"
+ }
+ ]
+ },
+ {
+ "name": "ImageDrawCircleLinesV",
+ "description": "Draw circle outline within an image (Vector version)",
"returnType": "void",
"params": [
{
@@ -7252,6 +7418,17 @@
}
]
},
+ {
+ "name": "IsTextureReady",
+ "description": "Check if a texture is ready",
+ "returnType": "bool",
+ "params": [
+ {
+ "type": "Texture2D",
+ "name": "texture"
+ }
+ ]
+ },
{
"name": "UnloadTexture",
"description": "Unload texture from GPU memory (VRAM)",
@@ -7263,6 +7440,17 @@
}
]
},
+ {
+ "name": "IsRenderTextureReady",
+ "description": "Check if a render texture is ready",
+ "returnType": "bool",
+ "params": [
+ {
+ "type": "RenderTexture2D",
+ "name": "target"
+ }
+ ]
+ },
{
"name": "UnloadRenderTexture",
"description": "Unload render texture from GPU memory (VRAM)",
@@ -7441,68 +7629,6 @@
}
]
},
- {
- "name": "DrawTextureQuad",
- "description": "Draw texture quad with tiling and offset parameters",
- "returnType": "void",
- "params": [
- {
- "type": "Texture2D",
- "name": "texture"
- },
- {
- "type": "Vector2",
- "name": "tiling"
- },
- {
- "type": "Vector2",
- "name": "offset"
- },
- {
- "type": "Rectangle",
- "name": "quad"
- },
- {
- "type": "Color",
- "name": "tint"
- }
- ]
- },
- {
- "name": "DrawTextureTiled",
- "description": "Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.",
- "returnType": "void",
- "params": [
- {
- "type": "Texture2D",
- "name": "texture"
- },
- {
- "type": "Rectangle",
- "name": "source"
- },
- {
- "type": "Rectangle",
- "name": "dest"
- },
- {
- "type": "Vector2",
- "name": "origin"
- },
- {
- "type": "float",
- "name": "rotation"
- },
- {
- "type": "float",
- "name": "scale"
- },
- {
- "type": "Color",
- "name": "tint"
- }
- ]
- },
{
"name": "DrawTexturePro",
"description": "Draw a part of a texture defined by a rectangle with 'pro' parameters",
@@ -7565,37 +7691,6 @@
}
]
},
- {
- "name": "DrawTexturePoly",
- "description": "Draw a textured polygon",
- "returnType": "void",
- "params": [
- {
- "type": "Texture2D",
- "name": "texture"
- },
- {
- "type": "Vector2",
- "name": "center"
- },
- {
- "type": "Vector2 *",
- "name": "points"
- },
- {
- "type": "Vector2 *",
- "name": "texcoords"
- },
- {
- "type": "int",
- "name": "pointCount"
- },
- {
- "type": "Color",
- "name": "tint"
- }
- ]
- },
{
"name": "Fade",
"description": "Get color with alpha applied, alpha goes from 0.0f to 1.0f",
@@ -7674,6 +7769,51 @@
}
]
},
+ {
+ "name": "ColorTint",
+ "description": "Get color multiplied with another color",
+ "returnType": "Color",
+ "params": [
+ {
+ "type": "Color",
+ "name": "color"
+ },
+ {
+ "type": "Color",
+ "name": "tint"
+ }
+ ]
+ },
+ {
+ "name": "ColorBrightness",
+ "description": "Get color with brightness correction, brightness factor goes from -1.0f to 1.0f",
+ "returnType": "Color",
+ "params": [
+ {
+ "type": "Color",
+ "name": "color"
+ },
+ {
+ "type": "float",
+ "name": "factor"
+ }
+ ]
+ },
+ {
+ "name": "ColorContrast",
+ "description": "Get color with contrast correction, contrast values between -1.0f and 1.0f",
+ "returnType": "Color",
+ "params": [
+ {
+ "type": "Color",
+ "name": "color"
+ },
+ {
+ "type": "float",
+ "name": "contrast"
+ }
+ ]
+ },
{
"name": "ColorAlpha",
"description": "Get color with alpha applied, alpha goes from 0.0f to 1.0f",
@@ -7861,6 +8001,17 @@
}
]
},
+ {
+ "name": "IsFontReady",
+ "description": "Check if a font is ready",
+ "returnType": "bool",
+ "params": [
+ {
+ "type": "Font",
+ "name": "font"
+ }
+ ]
+ },
{
"name": "LoadFontData",
"description": "Load font data for further use",
@@ -8221,6 +8372,32 @@
}
]
},
+ {
+ "name": "LoadUTF8",
+ "description": "Load UTF-8 text encoded from codepoints array",
+ "returnType": "char *",
+ "params": [
+ {
+ "type": "const int *",
+ "name": "codepoints"
+ },
+ {
+ "type": "int",
+ "name": "length"
+ }
+ ]
+ },
+ {
+ "name": "UnloadUTF8",
+ "description": "Unload UTF-8 text encoded from codepoints array",
+ "returnType": "void",
+ "params": [
+ {
+ "type": "char *",
+ "name": "text"
+ }
+ ]
+ },
{
"name": "LoadCodepoints",
"description": "Load all codepoints from a UTF-8 text string, codepoints count returned by parameter",
@@ -8269,7 +8446,37 @@
},
{
"type": "int *",
- "name": "bytesProcessed"
+ "name": "codepointSize"
+ }
+ ]
+ },
+ {
+ "name": "GetCodepointNext",
+ "description": "Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure",
+ "returnType": "int",
+ "params": [
+ {
+ "type": "const char *",
+ "name": "text"
+ },
+ {
+ "type": "int *",
+ "name": "codepointSize"
+ }
+ ]
+ },
+ {
+ "name": "GetCodepointPrevious",
+ "description": "Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure",
+ "returnType": "int",
+ "params": [
+ {
+ "type": "const char *",
+ "name": "text"
+ },
+ {
+ "type": "int *",
+ "name": "codepointSize"
}
]
},
@@ -8284,22 +8491,7 @@
},
{
"type": "int *",
- "name": "byteSize"
- }
- ]
- },
- {
- "name": "TextCodepointsToUTF8",
- "description": "Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!)",
- "returnType": "char *",
- "params": [
- {
- "type": "const int *",
- "name": "codepoints"
- },
- {
- "type": "int",
- "name": "length"
+ "name": "utf8Size"
}
]
},
@@ -8727,72 +8919,6 @@
}
]
},
- {
- "name": "DrawCubeTexture",
- "description": "Draw cube textured",
- "returnType": "void",
- "params": [
- {
- "type": "Texture2D",
- "name": "texture"
- },
- {
- "type": "Vector3",
- "name": "position"
- },
- {
- "type": "float",
- "name": "width"
- },
- {
- "type": "float",
- "name": "height"
- },
- {
- "type": "float",
- "name": "length"
- },
- {
- "type": "Color",
- "name": "color"
- }
- ]
- },
- {
- "name": "DrawCubeTextureRec",
- "description": "Draw cube with a region of a texture",
- "returnType": "void",
- "params": [
- {
- "type": "Texture2D",
- "name": "texture"
- },
- {
- "type": "Rectangle",
- "name": "source"
- },
- {
- "type": "Vector3",
- "name": "position"
- },
- {
- "type": "float",
- "name": "width"
- },
- {
- "type": "float",
- "name": "height"
- },
- {
- "type": "float",
- "name": "length"
- },
- {
- "type": "Color",
- "name": "color"
- }
- ]
- },
{
"name": "DrawSphere",
"description": "Draw sphere",
@@ -8990,6 +9116,68 @@
}
]
},
+ {
+ "name": "DrawCapsule",
+ "description": "Draw a capsule with the center of its sphere caps at startPos and endPos",
+ "returnType": "void",
+ "params": [
+ {
+ "type": "Vector3",
+ "name": "startPos"
+ },
+ {
+ "type": "Vector3",
+ "name": "endPos"
+ },
+ {
+ "type": "float",
+ "name": "radius"
+ },
+ {
+ "type": "int",
+ "name": "slices"
+ },
+ {
+ "type": "int",
+ "name": "rings"
+ },
+ {
+ "type": "Color",
+ "name": "color"
+ }
+ ]
+ },
+ {
+ "name": "DrawCapsuleWires",
+ "description": "Draw capsule wireframe with the center of its sphere caps at startPos and endPos",
+ "returnType": "void",
+ "params": [
+ {
+ "type": "Vector3",
+ "name": "startPos"
+ },
+ {
+ "type": "Vector3",
+ "name": "endPos"
+ },
+ {
+ "type": "float",
+ "name": "radius"
+ },
+ {
+ "type": "int",
+ "name": "slices"
+ },
+ {
+ "type": "int",
+ "name": "rings"
+ },
+ {
+ "type": "Color",
+ "name": "color"
+ }
+ ]
+ },
{
"name": "DrawPlane",
"description": "Draw a plane XZ",
@@ -9062,9 +9250,9 @@
]
},
{
- "name": "UnloadModel",
- "description": "Unload model (including meshes) from memory (RAM and/or VRAM)",
- "returnType": "void",
+ "name": "IsModelReady",
+ "description": "Check if a model is ready",
+ "returnType": "bool",
"params": [
{
"type": "Model",
@@ -9073,8 +9261,8 @@
]
},
{
- "name": "UnloadModelKeepMeshes",
- "description": "Unload model (but not meshes) from memory (RAM and/or VRAM)",
+ "name": "UnloadModel",
+ "description": "Unload model (including meshes) from memory (RAM and/or VRAM)",
"returnType": "void",
"params": [
{
@@ -9679,6 +9867,17 @@
"description": "Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)",
"returnType": "Material"
},
+ {
+ "name": "IsMaterialReady",
+ "description": "Check if a material is ready",
+ "returnType": "bool",
+ "params": [
+ {
+ "type": "Material",
+ "name": "material"
+ }
+ ]
+ },
{
"name": "UnloadMaterial",
"description": "Unload material from GPU memory (VRAM)",
@@ -10019,6 +10218,17 @@
}
]
},
+ {
+ "name": "IsWaveReady",
+ "description": "Checks if wave data is ready",
+ "returnType": "bool",
+ "params": [
+ {
+ "type": "Wave",
+ "name": "wave"
+ }
+ ]
+ },
{
"name": "LoadSound",
"description": "Load sound from file",
@@ -10041,6 +10251,17 @@
}
]
},
+ {
+ "name": "IsSoundReady",
+ "description": "Checks if a sound is ready",
+ "returnType": "bool",
+ "params": [
+ {
+ "type": "Sound",
+ "name": "sound"
+ }
+ ]
+ },
{
"name": "UpdateSound",
"description": "Update sound buffer with new data",
@@ -10156,27 +10377,6 @@
}
]
},
- {
- "name": "PlaySoundMulti",
- "description": "Play a sound (using multichannel buffer pool)",
- "returnType": "void",
- "params": [
- {
- "type": "Sound",
- "name": "sound"
- }
- ]
- },
- {
- "name": "StopSoundMulti",
- "description": "Stop any sound playing (using multichannel buffer pool)",
- "returnType": "void"
- },
- {
- "name": "GetSoundsPlaying",
- "description": "Get number of sounds playing in the multichannel",
- "returnType": "int"
- },
{
"name": "IsSoundPlaying",
"description": "Check if a sound is currently playing",
@@ -10338,6 +10538,17 @@
}
]
},
+ {
+ "name": "IsMusicReady",
+ "description": "Checks if a music stream is ready",
+ "returnType": "bool",
+ "params": [
+ {
+ "type": "Music",
+ "name": "music"
+ }
+ ]
+ },
{
"name": "UnloadMusicStream",
"description": "Unload music stream",
@@ -10516,6 +10727,17 @@
}
]
},
+ {
+ "name": "IsAudioStreamReady",
+ "description": "Checks if an audio stream is ready",
+ "returnType": "bool",
+ "params": [
+ {
+ "type": "AudioStream",
+ "name": "stream"
+ }
+ ]
+ },
{
"name": "UnloadAudioStream",
"description": "Unload audio stream and free memory",
@@ -10685,7 +10907,7 @@
},
{
"name": "AttachAudioStreamProcessor",
- "description": "",
+ "description": "Attach audio stream processor to stream",
"returnType": "void",
"params": [
{
@@ -10700,7 +10922,7 @@
},
{
"name": "DetachAudioStreamProcessor",
- "description": "",
+ "description": "Detach audio stream processor from stream",
"returnType": "void",
"params": [
{
@@ -10712,6 +10934,28 @@
"name": "processor"
}
]
+ },
+ {
+ "name": "AttachAudioMixedProcessor",
+ "description": "Attach audio stream processor to the entire audio pipeline",
+ "returnType": "void",
+ "params": [
+ {
+ "type": "AudioCallback",
+ "name": "processor"
+ }
+ ]
+ },
+ {
+ "name": "DetachAudioMixedProcessor",
+ "description": "Detach audio stream processor from the entire audio pipeline",
+ "returnType": "void",
+ "params": [
+ {
+ "type": "AudioCallback",
+ "name": "processor"
+ }
+ ]
}
]
}
diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua
index 1d80216de..ed11ac08f 100644
--- a/parser/output/raylib_api.lua
+++ b/parser/output/raylib_api.lua
@@ -6,10 +6,28 @@ return {
value = "",
description = ""
},
+ {
+ name = "RAYLIB_VERSION_MAJOR",
+ type = "INT",
+ value = 4,
+ description = ""
+ },
+ {
+ name = "RAYLIB_VERSION_MINOR",
+ type = "INT",
+ value = 6,
+ description = ""
+ },
+ {
+ name = "RAYLIB_VERSION_PATCH",
+ type = "INT",
+ value = 0,
+ description = ""
+ },
{
name = "RAYLIB_VERSION",
type = "STRING",
- value = "4.2",
+ value = "4.6-dev",
description = ""
},
{
@@ -385,7 +403,7 @@ return {
},
{
name = "Matrix",
- description = "Matrix, 4x4 components, column major, OpenGL style, right handed",
+ description = "Matrix, 4x4 components, column major, OpenGL style, right-handed",
fields = {
{
type = "float",
@@ -729,7 +747,7 @@ return {
{
type = "float",
name = "fovy",
- description = "Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic"
+ description = "Camera field-of-view aperture in Y (degrees) in perspective, used as near plane width in orthographic"
},
{
type = "int",
@@ -905,7 +923,7 @@ return {
},
{
name = "Transform",
- description = "Transform, vectex transformation data",
+ description = "Transform, vertex transformation data",
fields = {
{
type = "Vector3",
@@ -1014,6 +1032,11 @@ return {
type = "Transform **",
name = "framePoses",
description = "Poses array by frame"
+ },
+ {
+ type = "char[32]",
+ name = "name",
+ description = "Animation name"
}
}
},
@@ -1045,12 +1068,12 @@ return {
{
type = "float",
name = "distance",
- description = "Distance to nearest hit"
+ description = "Distance to the nearest hit"
},
{
type = "Vector3",
name = "point",
- description = "Point of nearest hit"
+ description = "Point of the nearest hit"
},
{
type = "Vector3",
@@ -2051,7 +2074,7 @@ return {
{
name = "MOUSE_BUTTON_FORWARD",
value = 5,
- description = "Mouse button fordward (advanced mouse device)"
+ description = "Mouse button forward (advanced mouse device)"
},
{
name = "MOUSE_BUTTON_BACK",
@@ -2112,7 +2135,7 @@ return {
{
name = "MOUSE_CURSOR_RESIZE_ALL",
value = 9,
- description = "The omni-directional resize/move cursor shape"
+ description = "The omnidirectional resize/move cursor shape"
},
{
name = "MOUSE_CURSOR_NOT_ALLOWED",
@@ -2717,7 +2740,7 @@ return {
{
name = "CUBEMAP_LAYOUT_LINE_HORIZONTAL",
value = 2,
- description = "Layout is defined by an horizontal line with faces"
+ description = "Layout is defined by a horizontal line with faces"
},
{
name = "CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR",
@@ -2732,7 +2755,7 @@ return {
{
name = "CUBEMAP_LAYOUT_PANORAMA",
value = 5,
- description = "Layout is defined by a panorama image (equirectangular map)"
+ description = "Layout is defined by a panorama image (equirrectangular map)"
}
}
},
@@ -2794,7 +2817,12 @@ return {
{
name = "BLEND_CUSTOM",
value = 6,
- description = "Blend textures using custom src/dst factors (use rlSetBlendMode())"
+ description = "Blend textures using custom src/dst factors (use rlSetBlendFactors())"
+ },
+ {
+ name = "BLEND_CUSTOM_SEPARATE",
+ value = 7,
+ description = "Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate())"
}
}
},
@@ -3087,12 +3115,21 @@ return {
},
{
name = "SetWindowIcon",
- description = "Set icon for window (only PLATFORM_DESKTOP)",
+ description = "Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)",
returnType = "void",
params = {
{type = "Image", name = "image"}
}
},
+ {
+ name = "SetWindowIcons",
+ description = "Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)",
+ returnType = "void",
+ params = {
+ {type = "Image *", name = "images"},
+ {type = "int", name = "count"}
+ }
+ },
{
name = "SetWindowTitle",
description = "Set title for window (only PLATFORM_DESKTOP)",
@@ -3462,6 +3499,14 @@ return {
{type = "const char *", name = "fsCode"}
}
},
+ {
+ name = "IsShaderReady",
+ description = "Check if a shader is ready",
+ returnType = "bool",
+ params = {
+ {type = "Shader", name = "shader"}
+ }
+ },
{
name = "GetShaderLocation",
description = "Get shader uniform location",
@@ -3673,7 +3718,7 @@ return {
description = "Internal memory allocator",
returnType = "void *",
params = {
- {type = "int", name = "size"}
+ {type = "unsigned int", name = "size"}
}
},
{
@@ -3682,7 +3727,7 @@ return {
returnType = "void *",
params = {
{type = "void *", name = "ptr"},
- {type = "int", name = "size"}
+ {type = "unsigned int", name = "size"}
}
},
{
@@ -3773,7 +3818,7 @@ return {
description = "Export data to code (.h), returns true on success",
returnType = "bool",
params = {
- {type = "const char *", name = "data"},
+ {type = "const unsigned char *", name = "data"},
{type = "unsigned int", name = "size"},
{type = "const char *", name = "fileName"}
}
@@ -4299,58 +4344,24 @@ return {
description = "Get gesture pinch angle",
returnType = "float"
},
- {
- name = "SetCameraMode",
- description = "Set camera mode (multiple camera modes available)",
- returnType = "void",
- params = {
- {type = "Camera", name = "camera"},
- {type = "int", name = "mode"}
- }
- },
{
name = "UpdateCamera",
description = "Update camera position for selected mode",
returnType = "void",
params = {
- {type = "Camera *", name = "camera"}
+ {type = "Camera *", name = "camera"},
+ {type = "int", name = "mode"}
}
},
{
- name = "SetCameraPanControl",
- description = "Set camera pan key to combine with mouse movement (free camera)",
+ name = "UpdateCameraPro",
+ description = "Update camera movement/rotation",
returnType = "void",
params = {
- {type = "int", name = "keyPan"}
- }
- },
- {
- name = "SetCameraAltControl",
- description = "Set camera alt key to combine with mouse movement (free camera)",
- returnType = "void",
- params = {
- {type = "int", name = "keyAlt"}
- }
- },
- {
- name = "SetCameraSmoothZoomControl",
- description = "Set camera smooth zoom key to combine with mouse (free camera)",
- returnType = "void",
- params = {
- {type = "int", name = "keySmoothZoom"}
- }
- },
- {
- name = "SetCameraMoveControls",
- description = "Set camera move controls (1st person and 3rd person cameras)",
- returnType = "void",
- params = {
- {type = "int", name = "keyFront"},
- {type = "int", name = "keyBack"},
- {type = "int", name = "keyRight"},
- {type = "int", name = "keyLeft"},
- {type = "int", name = "keyUp"},
- {type = "int", name = "keyDown"}
+ {type = "Camera *", name = "camera"},
+ {type = "Vector3", name = "movement"},
+ {type = "Vector3", name = "rotation"},
+ {type = "float", name = "zoom"}
}
},
{
@@ -4846,6 +4857,16 @@ return {
{type = "Vector2", name = "p3"}
}
},
+ {
+ name = "CheckCollisionPointPoly",
+ description = "Check if point is within a polygon described by array of vertices",
+ returnType = "bool",
+ params = {
+ {type = "Vector2", name = "point"},
+ {type = "Vector2 *", name = "points"},
+ {type = "int", name = "pointCount"}
+ }
+ },
{
name = "CheckCollisionLines",
description = "Check the collision between two lines defined by two points each, returns collision point by reference",
@@ -4930,6 +4951,14 @@ return {
description = "Load image from screen buffer and (screenshot)",
returnType = "Image"
},
+ {
+ name = "IsImageReady",
+ description = "Check if an image is ready",
+ returnType = "bool",
+ params = {
+ {type = "Image", name = "image"}
+ }
+ },
{
name = "UnloadImage",
description = "Unload image from CPU memory (RAM)",
@@ -4967,25 +4996,15 @@ return {
}
},
{
- name = "GenImageGradientV",
- description = "Generate image: vertical gradient",
+ name = "GenImageGradientLinear",
+ description = "Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient",
returnType = "Image",
params = {
{type = "int", name = "width"},
{type = "int", name = "height"},
- {type = "Color", name = "top"},
- {type = "Color", name = "bottom"}
- }
- },
- {
- name = "GenImageGradientH",
- description = "Generate image: horizontal gradient",
- returnType = "Image",
- params = {
- {type = "int", name = "width"},
- {type = "int", name = "height"},
- {type = "Color", name = "left"},
- {type = "Color", name = "right"}
+ {type = "int", name = "direction"},
+ {type = "Color", name = "start"},
+ {type = "Color", name = "end"}
}
},
{
@@ -5000,6 +5019,18 @@ return {
{type = "Color", name = "outer"}
}
},
+ {
+ name = "GenImageGradientSquare",
+ description = "Generate image: square gradient",
+ returnType = "Image",
+ params = {
+ {type = "int", name = "width"},
+ {type = "int", name = "height"},
+ {type = "float", name = "density"},
+ {type = "Color", name = "inner"},
+ {type = "Color", name = "outer"}
+ }
+ },
{
name = "GenImageChecked",
description = "Generate image: checked",
@@ -5023,6 +5054,18 @@ return {
{type = "float", name = "factor"}
}
},
+ {
+ name = "GenImagePerlinNoise",
+ description = "Generate image: perlin noise",
+ returnType = "Image",
+ params = {
+ {type = "int", name = "width"},
+ {type = "int", name = "height"},
+ {type = "int", name = "offsetX"},
+ {type = "int", name = "offsetY"},
+ {type = "float", name = "scale"}
+ }
+ },
{
name = "GenImageCellular",
description = "Generate image: cellular algorithm, bigger tileSize means bigger cells",
@@ -5033,6 +5076,16 @@ return {
{type = "int", name = "tileSize"}
}
},
+ {
+ name = "GenImageText",
+ description = "Generate image: grayscale image from text data",
+ returnType = "Image",
+ params = {
+ {type = "int", name = "width"},
+ {type = "int", name = "height"},
+ {type = "const char *", name = "text"}
+ }
+ },
{
name = "ImageCopy",
description = "Create an image duplicate (useful for transformations)",
@@ -5135,6 +5188,15 @@ return {
{type = "Image *", name = "image"}
}
},
+ {
+ name = "ImageBlurGaussian",
+ description = "Apply Gaussian blur using a box blur approximation",
+ returnType = "void",
+ params = {
+ {type = "Image *", name = "image"},
+ {type = "int", name = "blurSize"}
+ }
+ },
{
name = "ImageResize",
description = "Resize image (Bicubic scaling algorithm)",
@@ -5204,6 +5266,15 @@ return {
{type = "Image *", name = "image"}
}
},
+ {
+ name = "ImageRotate",
+ description = "Rotate image by input angle in degrees (-359 to 359) ",
+ returnType = "void",
+ params = {
+ {type = "Image *", name = "image"},
+ {type = "int", name = "degrees"}
+ }
+ },
{
name = "ImageRotateCW",
description = "Rotate image clockwise 90deg",
@@ -5382,7 +5453,7 @@ return {
},
{
name = "ImageDrawCircle",
- description = "Draw circle within an image",
+ description = "Draw a filled circle within an image",
returnType = "void",
params = {
{type = "Image *", name = "dst"},
@@ -5394,7 +5465,30 @@ return {
},
{
name = "ImageDrawCircleV",
- description = "Draw circle within an image (Vector version)",
+ description = "Draw a filled circle within an image (Vector version)",
+ returnType = "void",
+ params = {
+ {type = "Image *", name = "dst"},
+ {type = "Vector2", name = "center"},
+ {type = "int", name = "radius"},
+ {type = "Color", name = "color"}
+ }
+ },
+ {
+ name = "ImageDrawCircleLines",
+ description = "Draw circle outline within an image",
+ returnType = "void",
+ params = {
+ {type = "Image *", name = "dst"},
+ {type = "int", name = "centerX"},
+ {type = "int", name = "centerY"},
+ {type = "int", name = "radius"},
+ {type = "Color", name = "color"}
+ }
+ },
+ {
+ name = "ImageDrawCircleLinesV",
+ description = "Draw circle outline within an image (Vector version)",
returnType = "void",
params = {
{type = "Image *", name = "dst"},
@@ -5521,6 +5615,14 @@ return {
{type = "int", name = "height"}
}
},
+ {
+ name = "IsTextureReady",
+ description = "Check if a texture is ready",
+ returnType = "bool",
+ params = {
+ {type = "Texture2D", name = "texture"}
+ }
+ },
{
name = "UnloadTexture",
description = "Unload texture from GPU memory (VRAM)",
@@ -5529,6 +5631,14 @@ return {
{type = "Texture2D", name = "texture"}
}
},
+ {
+ name = "IsRenderTextureReady",
+ description = "Check if a render texture is ready",
+ returnType = "bool",
+ params = {
+ {type = "RenderTexture2D", name = "target"}
+ }
+ },
{
name = "UnloadRenderTexture",
description = "Unload render texture from GPU memory (VRAM)",
@@ -5626,32 +5736,6 @@ return {
{type = "Color", name = "tint"}
}
},
- {
- name = "DrawTextureQuad",
- description = "Draw texture quad with tiling and offset parameters",
- returnType = "void",
- params = {
- {type = "Texture2D", name = "texture"},
- {type = "Vector2", name = "tiling"},
- {type = "Vector2", name = "offset"},
- {type = "Rectangle", name = "quad"},
- {type = "Color", name = "tint"}
- }
- },
- {
- name = "DrawTextureTiled",
- description = "Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.",
- returnType = "void",
- params = {
- {type = "Texture2D", name = "texture"},
- {type = "Rectangle", name = "source"},
- {type = "Rectangle", name = "dest"},
- {type = "Vector2", name = "origin"},
- {type = "float", name = "rotation"},
- {type = "float", name = "scale"},
- {type = "Color", name = "tint"}
- }
- },
{
name = "DrawTexturePro",
description = "Draw a part of a texture defined by a rectangle with 'pro' parameters",
@@ -5678,19 +5762,6 @@ return {
{type = "Color", name = "tint"}
}
},
- {
- name = "DrawTexturePoly",
- description = "Draw a textured polygon",
- returnType = "void",
- params = {
- {type = "Texture2D", name = "texture"},
- {type = "Vector2", name = "center"},
- {type = "Vector2 *", name = "points"},
- {type = "Vector2 *", name = "texcoords"},
- {type = "int", name = "pointCount"},
- {type = "Color", name = "tint"}
- }
- },
{
name = "Fade",
description = "Get color with alpha applied, alpha goes from 0.0f to 1.0f",
@@ -5742,6 +5813,33 @@ return {
{type = "float", name = "value"}
}
},
+ {
+ name = "ColorTint",
+ description = "Get color multiplied with another color",
+ returnType = "Color",
+ params = {
+ {type = "Color", name = "color"},
+ {type = "Color", name = "tint"}
+ }
+ },
+ {
+ name = "ColorBrightness",
+ description = "Get color with brightness correction, brightness factor goes from -1.0f to 1.0f",
+ returnType = "Color",
+ params = {
+ {type = "Color", name = "color"},
+ {type = "float", name = "factor"}
+ }
+ },
+ {
+ name = "ColorContrast",
+ description = "Get color with contrast correction, contrast values between -1.0f and 1.0f",
+ returnType = "Color",
+ params = {
+ {type = "Color", name = "color"},
+ {type = "float", name = "contrast"}
+ }
+ },
{
name = "ColorAlpha",
description = "Get color with alpha applied, alpha goes from 0.0f to 1.0f",
@@ -5845,6 +5943,14 @@ return {
{type = "int", name = "glyphCount"}
}
},
+ {
+ name = "IsFontReady",
+ description = "Check if a font is ready",
+ returnType = "bool",
+ params = {
+ {type = "Font", name = "font"}
+ }
+ },
{
name = "LoadFontData",
description = "Load font data for further use",
@@ -6019,6 +6125,23 @@ return {
{type = "int", name = "codepoint"}
}
},
+ {
+ name = "LoadUTF8",
+ description = "Load UTF-8 text encoded from codepoints array",
+ returnType = "char *",
+ params = {
+ {type = "const int *", name = "codepoints"},
+ {type = "int", name = "length"}
+ }
+ },
+ {
+ name = "UnloadUTF8",
+ description = "Unload UTF-8 text encoded from codepoints array",
+ returnType = "void",
+ params = {
+ {type = "char *", name = "text"}
+ }
+ },
{
name = "LoadCodepoints",
description = "Load all codepoints from a UTF-8 text string, codepoints count returned by parameter",
@@ -6050,7 +6173,25 @@ return {
returnType = "int",
params = {
{type = "const char *", name = "text"},
- {type = "int *", name = "bytesProcessed"}
+ {type = "int *", name = "codepointSize"}
+ }
+ },
+ {
+ name = "GetCodepointNext",
+ description = "Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure",
+ returnType = "int",
+ params = {
+ {type = "const char *", name = "text"},
+ {type = "int *", name = "codepointSize"}
+ }
+ },
+ {
+ name = "GetCodepointPrevious",
+ description = "Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure",
+ returnType = "int",
+ params = {
+ {type = "const char *", name = "text"},
+ {type = "int *", name = "codepointSize"}
}
},
{
@@ -6059,16 +6200,7 @@ return {
returnType = "const char *",
params = {
{type = "int", name = "codepoint"},
- {type = "int *", name = "byteSize"}
- }
- },
- {
- name = "TextCodepointsToUTF8",
- description = "Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!)",
- returnType = "char *",
- params = {
- {type = "const int *", name = "codepoints"},
- {type = "int", name = "length"}
+ {type = "int *", name = "utf8Size"}
}
},
{
@@ -6303,33 +6435,6 @@ return {
{type = "Color", name = "color"}
}
},
- {
- name = "DrawCubeTexture",
- description = "Draw cube textured",
- returnType = "void",
- params = {
- {type = "Texture2D", name = "texture"},
- {type = "Vector3", name = "position"},
- {type = "float", name = "width"},
- {type = "float", name = "height"},
- {type = "float", name = "length"},
- {type = "Color", name = "color"}
- }
- },
- {
- name = "DrawCubeTextureRec",
- description = "Draw cube with a region of a texture",
- returnType = "void",
- params = {
- {type = "Texture2D", name = "texture"},
- {type = "Rectangle", name = "source"},
- {type = "Vector3", name = "position"},
- {type = "float", name = "width"},
- {type = "float", name = "height"},
- {type = "float", name = "length"},
- {type = "Color", name = "color"}
- }
- },
{
name = "DrawSphere",
description = "Draw sphere",
@@ -6416,6 +6521,32 @@ return {
{type = "Color", name = "color"}
}
},
+ {
+ name = "DrawCapsule",
+ description = "Draw a capsule with the center of its sphere caps at startPos and endPos",
+ returnType = "void",
+ params = {
+ {type = "Vector3", name = "startPos"},
+ {type = "Vector3", name = "endPos"},
+ {type = "float", name = "radius"},
+ {type = "int", name = "slices"},
+ {type = "int", name = "rings"},
+ {type = "Color", name = "color"}
+ }
+ },
+ {
+ name = "DrawCapsuleWires",
+ description = "Draw capsule wireframe with the center of its sphere caps at startPos and endPos",
+ returnType = "void",
+ params = {
+ {type = "Vector3", name = "startPos"},
+ {type = "Vector3", name = "endPos"},
+ {type = "float", name = "radius"},
+ {type = "int", name = "slices"},
+ {type = "int", name = "rings"},
+ {type = "Color", name = "color"}
+ }
+ },
{
name = "DrawPlane",
description = "Draw a plane XZ",
@@ -6461,16 +6592,16 @@ return {
}
},
{
- name = "UnloadModel",
- description = "Unload model (including meshes) from memory (RAM and/or VRAM)",
- returnType = "void",
+ name = "IsModelReady",
+ description = "Check if a model is ready",
+ returnType = "bool",
params = {
{type = "Model", name = "model"}
}
},
{
- name = "UnloadModelKeepMeshes",
- description = "Unload model (but not meshes) from memory (RAM and/or VRAM)",
+ name = "UnloadModel",
+ description = "Unload model (including meshes) from memory (RAM and/or VRAM)",
returnType = "void",
params = {
{type = "Model", name = "model"}
@@ -6781,6 +6912,14 @@ return {
description = "Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)",
returnType = "Material"
},
+ {
+ name = "IsMaterialReady",
+ description = "Check if a material is ready",
+ returnType = "bool",
+ params = {
+ {type = "Material", name = "material"}
+ }
+ },
{
name = "UnloadMaterial",
description = "Unload material from GPU memory (VRAM)",
@@ -6977,6 +7116,14 @@ return {
{type = "int", name = "dataSize"}
}
},
+ {
+ name = "IsWaveReady",
+ description = "Checks if wave data is ready",
+ returnType = "bool",
+ params = {
+ {type = "Wave", name = "wave"}
+ }
+ },
{
name = "LoadSound",
description = "Load sound from file",
@@ -6993,6 +7140,14 @@ return {
{type = "Wave", name = "wave"}
}
},
+ {
+ name = "IsSoundReady",
+ description = "Checks if a sound is ready",
+ returnType = "bool",
+ params = {
+ {type = "Sound", name = "sound"}
+ }
+ },
{
name = "UpdateSound",
description = "Update sound buffer with new data",
@@ -7069,24 +7224,6 @@ return {
{type = "Sound", name = "sound"}
}
},
- {
- name = "PlaySoundMulti",
- description = "Play a sound (using multichannel buffer pool)",
- returnType = "void",
- params = {
- {type = "Sound", name = "sound"}
- }
- },
- {
- name = "StopSoundMulti",
- description = "Stop any sound playing (using multichannel buffer pool)",
- returnType = "void"
- },
- {
- name = "GetSoundsPlaying",
- description = "Get number of sounds playing in the multichannel",
- returnType = "int"
- },
{
name = "IsSoundPlaying",
description = "Check if a sound is currently playing",
@@ -7185,6 +7322,14 @@ return {
{type = "int", name = "dataSize"}
}
},
+ {
+ name = "IsMusicReady",
+ description = "Checks if a music stream is ready",
+ returnType = "bool",
+ params = {
+ {type = "Music", name = "music"}
+ }
+ },
{
name = "UnloadMusicStream",
description = "Unload music stream",
@@ -7303,6 +7448,14 @@ return {
{type = "unsigned int", name = "channels"}
}
},
+ {
+ name = "IsAudioStreamReady",
+ description = "Checks if an audio stream is ready",
+ returnType = "bool",
+ params = {
+ {type = "AudioStream", name = "stream"}
+ }
+ },
{
name = "UnloadAudioStream",
description = "Unload audio stream and free memory",
@@ -7415,7 +7568,7 @@ return {
},
{
name = "AttachAudioStreamProcessor",
- description = "",
+ description = "Attach audio stream processor to stream",
returnType = "void",
params = {
{type = "AudioStream", name = "stream"},
@@ -7424,12 +7577,28 @@ return {
},
{
name = "DetachAudioStreamProcessor",
- description = "",
+ description = "Detach audio stream processor from stream",
returnType = "void",
params = {
{type = "AudioStream", name = "stream"},
{type = "AudioCallback", name = "processor"}
}
+ },
+ {
+ name = "AttachAudioMixedProcessor",
+ description = "Attach audio stream processor to the entire audio pipeline",
+ returnType = "void",
+ params = {
+ {type = "AudioCallback", name = "processor"}
+ }
+ },
+ {
+ name = "DetachAudioMixedProcessor",
+ description = "Detach audio stream processor from the entire audio pipeline",
+ returnType = "void",
+ params = {
+ {type = "AudioCallback", name = "processor"}
+ }
}
}
}
diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt
index d45d8ce63..0d0ccccf1 100644
--- a/parser/output/raylib_api.txt
+++ b/parser/output/raylib_api.txt
@@ -1,267 +1,282 @@
-Defines found: 53
+Defines found: 56
Define 001: RAYLIB_H
Name: RAYLIB_H
Type: GUARD
Value:
Description:
-Define 002: RAYLIB_VERSION
+Define 002: RAYLIB_VERSION_MAJOR
+ Name: RAYLIB_VERSION_MAJOR
+ Type: INT
+ Value: 4
+ Description:
+Define 003: RAYLIB_VERSION_MINOR
+ Name: RAYLIB_VERSION_MINOR
+ Type: INT
+ Value: 6
+ Description:
+Define 004: RAYLIB_VERSION_PATCH
+ Name: RAYLIB_VERSION_PATCH
+ Type: INT
+ Value: 0
+ Description:
+Define 005: RAYLIB_VERSION
Name: RAYLIB_VERSION
Type: STRING
- Value: "4.2"
+ Value: "4.6-dev"
Description:
-Define 003: __declspec(x)
+Define 006: __declspec(x)
Name: __declspec(x)
Type: MACRO
Value: __attribute__((x))
Description:
-Define 004: RLAPI
+Define 007: RLAPI
Name: RLAPI
Type: UNKNOWN
Value: __declspec(dllexport)
Description: We are building the library as a Win32 shared library (.dll)
-Define 005: PI
+Define 008: PI
Name: PI
Type: FLOAT
Value: 3.14159265358979323846
Description:
-Define 006: DEG2RAD
+Define 009: DEG2RAD
Name: DEG2RAD
Type: FLOAT_MATH
Value: (PI/180.0f)
Description:
-Define 007: RAD2DEG
+Define 010: RAD2DEG
Name: RAD2DEG
Type: FLOAT_MATH
Value: (180.0f/PI)
Description:
-Define 008: RL_MALLOC(sz)
+Define 011: RL_MALLOC(sz)
Name: RL_MALLOC(sz)
Type: MACRO
Value: malloc(sz)
Description:
-Define 009: RL_CALLOC(n,sz)
+Define 012: RL_CALLOC(n,sz)
Name: RL_CALLOC(n,sz)
Type: MACRO
Value: calloc(n,sz)
Description:
-Define 010: RL_REALLOC(ptr,sz)
+Define 013: RL_REALLOC(ptr,sz)
Name: RL_REALLOC(ptr,sz)
Type: MACRO
Value: realloc(ptr,sz)
Description:
-Define 011: RL_FREE(ptr)
+Define 014: RL_FREE(ptr)
Name: RL_FREE(ptr)
Type: MACRO
Value: free(ptr)
Description:
-Define 012: CLITERAL(type)
+Define 015: CLITERAL(type)
Name: CLITERAL(type)
Type: MACRO
Value: type
Description:
-Define 013: RL_COLOR_TYPE
+Define 016: RL_COLOR_TYPE
Name: RL_COLOR_TYPE
Type: GUARD
Value:
Description:
-Define 014: RL_RECTANGLE_TYPE
+Define 017: RL_RECTANGLE_TYPE
Name: RL_RECTANGLE_TYPE
Type: GUARD
Value:
Description:
-Define 015: RL_VECTOR2_TYPE
+Define 018: RL_VECTOR2_TYPE
Name: RL_VECTOR2_TYPE
Type: GUARD
Value:
Description:
-Define 016: RL_VECTOR3_TYPE
+Define 019: RL_VECTOR3_TYPE
Name: RL_VECTOR3_TYPE
Type: GUARD
Value:
Description:
-Define 017: RL_VECTOR4_TYPE
+Define 020: RL_VECTOR4_TYPE
Name: RL_VECTOR4_TYPE
Type: GUARD
Value:
Description:
-Define 018: RL_QUATERNION_TYPE
+Define 021: RL_QUATERNION_TYPE
Name: RL_QUATERNION_TYPE
Type: GUARD
Value:
Description:
-Define 019: RL_MATRIX_TYPE
+Define 022: RL_MATRIX_TYPE
Name: RL_MATRIX_TYPE
Type: GUARD
Value:
Description:
-Define 020: LIGHTGRAY
+Define 023: LIGHTGRAY
Name: LIGHTGRAY
Type: COLOR
Value: CLITERAL(Color){ 200, 200, 200, 255 }
Description: Light Gray
-Define 021: GRAY
+Define 024: GRAY
Name: GRAY
Type: COLOR
Value: CLITERAL(Color){ 130, 130, 130, 255 }
Description: Gray
-Define 022: DARKGRAY
+Define 025: DARKGRAY
Name: DARKGRAY
Type: COLOR
Value: CLITERAL(Color){ 80, 80, 80, 255 }
Description: Dark Gray
-Define 023: YELLOW
+Define 026: YELLOW
Name: YELLOW
Type: COLOR
Value: CLITERAL(Color){ 253, 249, 0, 255 }
Description: Yellow
-Define 024: GOLD
+Define 027: GOLD
Name: GOLD
Type: COLOR
Value: CLITERAL(Color){ 255, 203, 0, 255 }
Description: Gold
-Define 025: ORANGE
+Define 028: ORANGE
Name: ORANGE
Type: COLOR
Value: CLITERAL(Color){ 255, 161, 0, 255 }
Description: Orange
-Define 026: PINK
+Define 029: PINK
Name: PINK
Type: COLOR
Value: CLITERAL(Color){ 255, 109, 194, 255 }
Description: Pink
-Define 027: RED
+Define 030: RED
Name: RED
Type: COLOR
Value: CLITERAL(Color){ 230, 41, 55, 255 }
Description: Red
-Define 028: MAROON
+Define 031: MAROON
Name: MAROON
Type: COLOR
Value: CLITERAL(Color){ 190, 33, 55, 255 }
Description: Maroon
-Define 029: GREEN
+Define 032: GREEN
Name: GREEN
Type: COLOR
Value: CLITERAL(Color){ 0, 228, 48, 255 }
Description: Green
-Define 030: LIME
+Define 033: LIME
Name: LIME
Type: COLOR
Value: CLITERAL(Color){ 0, 158, 47, 255 }
Description: Lime
-Define 031: DARKGREEN
+Define 034: DARKGREEN
Name: DARKGREEN
Type: COLOR
Value: CLITERAL(Color){ 0, 117, 44, 255 }
Description: Dark Green
-Define 032: SKYBLUE
+Define 035: SKYBLUE
Name: SKYBLUE
Type: COLOR
Value: CLITERAL(Color){ 102, 191, 255, 255 }
Description: Sky Blue
-Define 033: BLUE
+Define 036: BLUE
Name: BLUE
Type: COLOR
Value: CLITERAL(Color){ 0, 121, 241, 255 }
Description: Blue
-Define 034: DARKBLUE
+Define 037: DARKBLUE
Name: DARKBLUE
Type: COLOR
Value: CLITERAL(Color){ 0, 82, 172, 255 }
Description: Dark Blue
-Define 035: PURPLE
+Define 038: PURPLE
Name: PURPLE
Type: COLOR
Value: CLITERAL(Color){ 200, 122, 255, 255 }
Description: Purple
-Define 036: VIOLET
+Define 039: VIOLET
Name: VIOLET
Type: COLOR
Value: CLITERAL(Color){ 135, 60, 190, 255 }
Description: Violet
-Define 037: DARKPURPLE
+Define 040: DARKPURPLE
Name: DARKPURPLE
Type: COLOR
Value: CLITERAL(Color){ 112, 31, 126, 255 }
Description: Dark Purple
-Define 038: BEIGE
+Define 041: BEIGE
Name: BEIGE
Type: COLOR
Value: CLITERAL(Color){ 211, 176, 131, 255 }
Description: Beige
-Define 039: BROWN
+Define 042: BROWN
Name: BROWN
Type: COLOR
Value: CLITERAL(Color){ 127, 106, 79, 255 }
Description: Brown
-Define 040: DARKBROWN
+Define 043: DARKBROWN
Name: DARKBROWN
Type: COLOR
Value: CLITERAL(Color){ 76, 63, 47, 255 }
Description: Dark Brown
-Define 041: WHITE
+Define 044: WHITE
Name: WHITE
Type: COLOR
Value: CLITERAL(Color){ 255, 255, 255, 255 }
Description: White
-Define 042: BLACK
+Define 045: BLACK
Name: BLACK
Type: COLOR
Value: CLITERAL(Color){ 0, 0, 0, 255 }
Description: Black
-Define 043: BLANK
+Define 046: BLANK
Name: BLANK
Type: COLOR
Value: CLITERAL(Color){ 0, 0, 0, 0 }
Description: Blank (Transparent)
-Define 044: MAGENTA
+Define 047: MAGENTA
Name: MAGENTA
Type: COLOR
Value: CLITERAL(Color){ 255, 0, 255, 255 }
Description: Magenta
-Define 045: RAYWHITE
+Define 048: RAYWHITE
Name: RAYWHITE
Type: COLOR
Value: CLITERAL(Color){ 245, 245, 245, 255 }
Description: My own White (raylib logo)
-Define 046: RL_BOOL_TYPE
+Define 049: RL_BOOL_TYPE
Name: RL_BOOL_TYPE
Type: GUARD
Value:
Description:
-Define 047: MOUSE_LEFT_BUTTON
+Define 050: MOUSE_LEFT_BUTTON
Name: MOUSE_LEFT_BUTTON
Type: UNKNOWN
Value: MOUSE_BUTTON_LEFT
Description:
-Define 048: MOUSE_RIGHT_BUTTON
+Define 051: MOUSE_RIGHT_BUTTON
Name: MOUSE_RIGHT_BUTTON
Type: UNKNOWN
Value: MOUSE_BUTTON_RIGHT
Description:
-Define 049: MOUSE_MIDDLE_BUTTON
+Define 052: MOUSE_MIDDLE_BUTTON
Name: MOUSE_MIDDLE_BUTTON
Type: UNKNOWN
Value: MOUSE_BUTTON_MIDDLE
Description:
-Define 050: MATERIAL_MAP_DIFFUSE
+Define 053: MATERIAL_MAP_DIFFUSE
Name: MATERIAL_MAP_DIFFUSE
Type: UNKNOWN
Value: MATERIAL_MAP_ALBEDO
Description:
-Define 051: MATERIAL_MAP_SPECULAR
+Define 054: MATERIAL_MAP_SPECULAR
Name: MATERIAL_MAP_SPECULAR
Type: UNKNOWN
Value: MATERIAL_MAP_METALNESS
Description:
-Define 052: SHADER_LOC_MAP_DIFFUSE
+Define 055: SHADER_LOC_MAP_DIFFUSE
Name: SHADER_LOC_MAP_DIFFUSE
Type: UNKNOWN
Value: SHADER_LOC_MAP_ALBEDO
Description:
-Define 053: SHADER_LOC_MAP_SPECULAR
+Define 056: SHADER_LOC_MAP_SPECULAR
Name: SHADER_LOC_MAP_SPECULAR
Type: UNKNOWN
Value: SHADER_LOC_MAP_METALNESS
@@ -289,7 +304,7 @@ Struct 03: Vector4 (4 fields)
Field[4]: float w // Vector w component
Struct 04: Matrix (16 fields)
Name: Matrix
- Description: Matrix, 4x4 components, column major, OpenGL style, right handed
+ Description: Matrix, 4x4 components, column major, OpenGL style, right-handed
Field[1]: float m0 // Matrix first row (4 components)
Field[2]: float m4 // Matrix first row (4 components)
Field[3]: float m8 // Matrix first row (4 components)
@@ -374,7 +389,7 @@ Struct 13: Camera3D (5 fields)
Field[1]: Vector3 position // Camera position
Field[2]: Vector3 target // Camera target it looks-at
Field[3]: Vector3 up // Camera up vector (rotation over its axis)
- Field[4]: float fovy // Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic
+ Field[4]: float fovy // Camera field-of-view aperture in Y (degrees) in perspective, used as near plane width in orthographic
Field[5]: int projection // Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
Struct 14: Camera2D (4 fields)
Name: Camera2D
@@ -420,7 +435,7 @@ Struct 18: Material (3 fields)
Field[3]: float[4] params // Material generic parameters (if required)
Struct 19: Transform (3 fields)
Name: Transform
- Description: Transform, vectex transformation data
+ Description: Transform, vertex transformation data
Field[1]: Vector3 translation // Translation
Field[2]: Quaternion rotation // Rotation
Field[3]: Vector3 scale // Scale
@@ -441,13 +456,14 @@ Struct 21: Model (9 fields)
Field[7]: int boneCount // Number of bones
Field[8]: BoneInfo * bones // Bones information (skeleton)
Field[9]: Transform * bindPose // Bones base transformation (pose)
-Struct 22: ModelAnimation (4 fields)
+Struct 22: ModelAnimation (5 fields)
Name: ModelAnimation
Description: ModelAnimation
Field[1]: int boneCount // Number of bones
Field[2]: int frameCount // Number of animation frames
Field[3]: BoneInfo * bones // Bones information (skeleton)
Field[4]: Transform ** framePoses // Poses array by frame
+ Field[5]: char[32] name // Animation name
Struct 23: Ray (2 fields)
Name: Ray
Description: Ray, ray for raycasting
@@ -457,8 +473,8 @@ Struct 24: RayCollision (4 fields)
Name: RayCollision
Description: RayCollision, ray hit information
Field[1]: bool hit // Did the ray hit something?
- Field[2]: float distance // Distance to nearest hit
- Field[3]: Vector3 point // Point of nearest hit
+ Field[2]: float distance // Distance to the nearest hit
+ Field[3]: Vector3 point // Point of the nearest hit
Field[4]: Vector3 normal // Surface normal of hit
Struct 25: BoundingBox (2 fields)
Name: BoundingBox
@@ -863,7 +879,7 @@ Enum 16: FontType (3 values)
Value[FONT_DEFAULT]: 0
Value[FONT_BITMAP]: 1
Value[FONT_SDF]: 2
-Enum 17: BlendMode (7 values)
+Enum 17: BlendMode (8 values)
Name: BlendMode
Description: Color blending modes (pre-defined)
Value[BLEND_ALPHA]: 0
@@ -873,6 +889,7 @@ Enum 17: BlendMode (7 values)
Value[BLEND_SUBTRACT_COLORS]: 4
Value[BLEND_ALPHA_PREMULTIPLY]: 5
Value[BLEND_CUSTOM]: 6
+ Value[BLEND_CUSTOM_SEPARATE]: 7
Enum 18: Gesture (11 values)
Name: Gesture
Description: Gesture
@@ -947,7 +964,7 @@ Callback 006: AudioCallback() (2 input parameters)
Param[1]: bufferData (type: void *)
Param[2]: frames (type: unsigned int)
-Functions found: 502
+Functions found: 518
Function 001: InitWindow() (3 input parameters)
Name: InitWindow
@@ -1039,252 +1056,258 @@ Function 017: RestoreWindow() (0 input parameters)
Function 018: SetWindowIcon() (1 input parameters)
Name: SetWindowIcon
Return type: void
- Description: Set icon for window (only PLATFORM_DESKTOP)
+ Description: Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)
Param[1]: image (type: Image)
-Function 019: SetWindowTitle() (1 input parameters)
+Function 019: SetWindowIcons() (2 input parameters)
+ Name: SetWindowIcons
+ Return type: void
+ Description: Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
+ Param[1]: images (type: Image *)
+ Param[2]: count (type: int)
+Function 020: SetWindowTitle() (1 input parameters)
Name: SetWindowTitle
Return type: void
Description: Set title for window (only PLATFORM_DESKTOP)
Param[1]: title (type: const char *)
-Function 020: SetWindowPosition() (2 input parameters)
+Function 021: SetWindowPosition() (2 input parameters)
Name: SetWindowPosition
Return type: void
Description: Set window position on screen (only PLATFORM_DESKTOP)
Param[1]: x (type: int)
Param[2]: y (type: int)
-Function 021: SetWindowMonitor() (1 input parameters)
+Function 022: SetWindowMonitor() (1 input parameters)
Name: SetWindowMonitor
Return type: void
Description: Set monitor for the current window (fullscreen mode)
Param[1]: monitor (type: int)
-Function 022: SetWindowMinSize() (2 input parameters)
+Function 023: SetWindowMinSize() (2 input parameters)
Name: SetWindowMinSize
Return type: void
Description: Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
Param[1]: width (type: int)
Param[2]: height (type: int)
-Function 023: SetWindowSize() (2 input parameters)
+Function 024: SetWindowSize() (2 input parameters)
Name: SetWindowSize
Return type: void
Description: Set window dimensions
Param[1]: width (type: int)
Param[2]: height (type: int)
-Function 024: SetWindowOpacity() (1 input parameters)
+Function 025: SetWindowOpacity() (1 input parameters)
Name: SetWindowOpacity
Return type: void
Description: Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
Param[1]: opacity (type: float)
-Function 025: GetWindowHandle() (0 input parameters)
+Function 026: GetWindowHandle() (0 input parameters)
Name: GetWindowHandle
Return type: void *
Description: Get native window handle
No input parameters
-Function 026: GetScreenWidth() (0 input parameters)
+Function 027: GetScreenWidth() (0 input parameters)
Name: GetScreenWidth
Return type: int
Description: Get current screen width
No input parameters
-Function 027: GetScreenHeight() (0 input parameters)
+Function 028: GetScreenHeight() (0 input parameters)
Name: GetScreenHeight
Return type: int
Description: Get current screen height
No input parameters
-Function 028: GetRenderWidth() (0 input parameters)
+Function 029: GetRenderWidth() (0 input parameters)
Name: GetRenderWidth
Return type: int
Description: Get current render width (it considers HiDPI)
No input parameters
-Function 029: GetRenderHeight() (0 input parameters)
+Function 030: GetRenderHeight() (0 input parameters)
Name: GetRenderHeight
Return type: int
Description: Get current render height (it considers HiDPI)
No input parameters
-Function 030: GetMonitorCount() (0 input parameters)
+Function 031: GetMonitorCount() (0 input parameters)
Name: GetMonitorCount
Return type: int
Description: Get number of connected monitors
No input parameters
-Function 031: GetCurrentMonitor() (0 input parameters)
+Function 032: GetCurrentMonitor() (0 input parameters)
Name: GetCurrentMonitor
Return type: int
Description: Get current connected monitor
No input parameters
-Function 032: GetMonitorPosition() (1 input parameters)
+Function 033: GetMonitorPosition() (1 input parameters)
Name: GetMonitorPosition
Return type: Vector2
Description: Get specified monitor position
Param[1]: monitor (type: int)
-Function 033: GetMonitorWidth() (1 input parameters)
+Function 034: GetMonitorWidth() (1 input parameters)
Name: GetMonitorWidth
Return type: int
Description: Get specified monitor width (current video mode used by monitor)
Param[1]: monitor (type: int)
-Function 034: GetMonitorHeight() (1 input parameters)
+Function 035: GetMonitorHeight() (1 input parameters)
Name: GetMonitorHeight
Return type: int
Description: Get specified monitor height (current video mode used by monitor)
Param[1]: monitor (type: int)
-Function 035: GetMonitorPhysicalWidth() (1 input parameters)
+Function 036: GetMonitorPhysicalWidth() (1 input parameters)
Name: GetMonitorPhysicalWidth
Return type: int
Description: Get specified monitor physical width in millimetres
Param[1]: monitor (type: int)
-Function 036: GetMonitorPhysicalHeight() (1 input parameters)
+Function 037: GetMonitorPhysicalHeight() (1 input parameters)
Name: GetMonitorPhysicalHeight
Return type: int
Description: Get specified monitor physical height in millimetres
Param[1]: monitor (type: int)
-Function 037: GetMonitorRefreshRate() (1 input parameters)
+Function 038: GetMonitorRefreshRate() (1 input parameters)
Name: GetMonitorRefreshRate
Return type: int
Description: Get specified monitor refresh rate
Param[1]: monitor (type: int)
-Function 038: GetWindowPosition() (0 input parameters)
+Function 039: GetWindowPosition() (0 input parameters)
Name: GetWindowPosition
Return type: Vector2
Description: Get window position XY on monitor
No input parameters
-Function 039: GetWindowScaleDPI() (0 input parameters)
+Function 040: GetWindowScaleDPI() (0 input parameters)
Name: GetWindowScaleDPI
Return type: Vector2
Description: Get window scale DPI factor
No input parameters
-Function 040: GetMonitorName() (1 input parameters)
+Function 041: GetMonitorName() (1 input parameters)
Name: GetMonitorName
Return type: const char *
Description: Get the human-readable, UTF-8 encoded name of the primary monitor
Param[1]: monitor (type: int)
-Function 041: SetClipboardText() (1 input parameters)
+Function 042: SetClipboardText() (1 input parameters)
Name: SetClipboardText
Return type: void
Description: Set clipboard text content
Param[1]: text (type: const char *)
-Function 042: GetClipboardText() (0 input parameters)
+Function 043: GetClipboardText() (0 input parameters)
Name: GetClipboardText
Return type: const char *
Description: Get clipboard text content
No input parameters
-Function 043: EnableEventWaiting() (0 input parameters)
+Function 044: EnableEventWaiting() (0 input parameters)
Name: EnableEventWaiting
Return type: void
Description: Enable waiting for events on EndDrawing(), no automatic event polling
No input parameters
-Function 044: DisableEventWaiting() (0 input parameters)
+Function 045: DisableEventWaiting() (0 input parameters)
Name: DisableEventWaiting
Return type: void
Description: Disable waiting for events on EndDrawing(), automatic events polling
No input parameters
-Function 045: SwapScreenBuffer() (0 input parameters)
+Function 046: SwapScreenBuffer() (0 input parameters)
Name: SwapScreenBuffer
Return type: void
Description: Swap back buffer with front buffer (screen drawing)
No input parameters
-Function 046: PollInputEvents() (0 input parameters)
+Function 047: PollInputEvents() (0 input parameters)
Name: PollInputEvents
Return type: void
Description: Register all input events
No input parameters
-Function 047: WaitTime() (1 input parameters)
+Function 048: WaitTime() (1 input parameters)
Name: WaitTime
Return type: void
Description: Wait for some time (halt program execution)
Param[1]: seconds (type: double)
-Function 048: ShowCursor() (0 input parameters)
+Function 049: ShowCursor() (0 input parameters)
Name: ShowCursor
Return type: void
Description: Shows cursor
No input parameters
-Function 049: HideCursor() (0 input parameters)
+Function 050: HideCursor() (0 input parameters)
Name: HideCursor
Return type: void
Description: Hides cursor
No input parameters
-Function 050: IsCursorHidden() (0 input parameters)
+Function 051: IsCursorHidden() (0 input parameters)
Name: IsCursorHidden
Return type: bool
Description: Check if cursor is not visible
No input parameters
-Function 051: EnableCursor() (0 input parameters)
+Function 052: EnableCursor() (0 input parameters)
Name: EnableCursor
Return type: void
Description: Enables cursor (unlock cursor)
No input parameters
-Function 052: DisableCursor() (0 input parameters)
+Function 053: DisableCursor() (0 input parameters)
Name: DisableCursor
Return type: void
Description: Disables cursor (lock cursor)
No input parameters
-Function 053: IsCursorOnScreen() (0 input parameters)
+Function 054: IsCursorOnScreen() (0 input parameters)
Name: IsCursorOnScreen
Return type: bool
Description: Check if cursor is on the screen
No input parameters
-Function 054: ClearBackground() (1 input parameters)
+Function 055: ClearBackground() (1 input parameters)
Name: ClearBackground
Return type: void
Description: Set background color (framebuffer clear color)
Param[1]: color (type: Color)
-Function 055: BeginDrawing() (0 input parameters)
+Function 056: BeginDrawing() (0 input parameters)
Name: BeginDrawing
Return type: void
Description: Setup canvas (framebuffer) to start drawing
No input parameters
-Function 056: EndDrawing() (0 input parameters)
+Function 057: EndDrawing() (0 input parameters)
Name: EndDrawing
Return type: void
Description: End canvas drawing and swap buffers (double buffering)
No input parameters
-Function 057: BeginMode2D() (1 input parameters)
+Function 058: BeginMode2D() (1 input parameters)
Name: BeginMode2D
Return type: void
Description: Begin 2D mode with custom camera (2D)
Param[1]: camera (type: Camera2D)
-Function 058: EndMode2D() (0 input parameters)
+Function 059: EndMode2D() (0 input parameters)
Name: EndMode2D
Return type: void
Description: Ends 2D mode with custom camera
No input parameters
-Function 059: BeginMode3D() (1 input parameters)
+Function 060: BeginMode3D() (1 input parameters)
Name: BeginMode3D
Return type: void
Description: Begin 3D mode with custom camera (3D)
Param[1]: camera (type: Camera3D)
-Function 060: EndMode3D() (0 input parameters)
+Function 061: EndMode3D() (0 input parameters)
Name: EndMode3D
Return type: void
Description: Ends 3D mode and returns to default 2D orthographic mode
No input parameters
-Function 061: BeginTextureMode() (1 input parameters)
+Function 062: BeginTextureMode() (1 input parameters)
Name: BeginTextureMode
Return type: void
Description: Begin drawing to render texture
Param[1]: target (type: RenderTexture2D)
-Function 062: EndTextureMode() (0 input parameters)
+Function 063: EndTextureMode() (0 input parameters)
Name: EndTextureMode
Return type: void
Description: Ends drawing to render texture
No input parameters
-Function 063: BeginShaderMode() (1 input parameters)
+Function 064: BeginShaderMode() (1 input parameters)
Name: BeginShaderMode
Return type: void
Description: Begin custom shader drawing
Param[1]: shader (type: Shader)
-Function 064: EndShaderMode() (0 input parameters)
+Function 065: EndShaderMode() (0 input parameters)
Name: EndShaderMode
Return type: void
Description: End custom shader drawing (use default shader)
No input parameters
-Function 065: BeginBlendMode() (1 input parameters)
+Function 066: BeginBlendMode() (1 input parameters)
Name: BeginBlendMode
Return type: void
Description: Begin blending mode (alpha, additive, multiplied, subtract, custom)
Param[1]: mode (type: int)
-Function 066: EndBlendMode() (0 input parameters)
+Function 067: EndBlendMode() (0 input parameters)
Name: EndBlendMode
Return type: void
Description: End blending mode (reset to default: alpha blending)
No input parameters
-Function 067: BeginScissorMode() (4 input parameters)
+Function 068: BeginScissorMode() (4 input parameters)
Name: BeginScissorMode
Return type: void
Description: Begin scissor mode (define screen area for following drawing)
@@ -1292,56 +1315,61 @@ Function 067: BeginScissorMode() (4 input parameters)
Param[2]: y (type: int)
Param[3]: width (type: int)
Param[4]: height (type: int)
-Function 068: EndScissorMode() (0 input parameters)
+Function 069: EndScissorMode() (0 input parameters)
Name: EndScissorMode
Return type: void
Description: End scissor mode
No input parameters
-Function 069: BeginVrStereoMode() (1 input parameters)
+Function 070: BeginVrStereoMode() (1 input parameters)
Name: BeginVrStereoMode
Return type: void
Description: Begin stereo rendering (requires VR simulator)
Param[1]: config (type: VrStereoConfig)
-Function 070: EndVrStereoMode() (0 input parameters)
+Function 071: EndVrStereoMode() (0 input parameters)
Name: EndVrStereoMode
Return type: void
Description: End stereo rendering (requires VR simulator)
No input parameters
-Function 071: LoadVrStereoConfig() (1 input parameters)
+Function 072: LoadVrStereoConfig() (1 input parameters)
Name: LoadVrStereoConfig
Return type: VrStereoConfig
Description: Load VR stereo config for VR simulator device parameters
Param[1]: device (type: VrDeviceInfo)
-Function 072: UnloadVrStereoConfig() (1 input parameters)
+Function 073: UnloadVrStereoConfig() (1 input parameters)
Name: UnloadVrStereoConfig
Return type: void
Description: Unload VR stereo config
Param[1]: config (type: VrStereoConfig)
-Function 073: LoadShader() (2 input parameters)
+Function 074: LoadShader() (2 input parameters)
Name: LoadShader
Return type: Shader
Description: Load shader from files and bind default locations
Param[1]: vsFileName (type: const char *)
Param[2]: fsFileName (type: const char *)
-Function 074: LoadShaderFromMemory() (2 input parameters)
+Function 075: LoadShaderFromMemory() (2 input parameters)
Name: LoadShaderFromMemory
Return type: Shader
Description: Load shader from code strings and bind default locations
Param[1]: vsCode (type: const char *)
Param[2]: fsCode (type: const char *)
-Function 075: GetShaderLocation() (2 input parameters)
+Function 076: IsShaderReady() (1 input parameters)
+ Name: IsShaderReady
+ Return type: bool
+ Description: Check if a shader is ready
+ Param[1]: shader (type: Shader)
+Function 077: GetShaderLocation() (2 input parameters)
Name: GetShaderLocation
Return type: int
Description: Get shader uniform location
Param[1]: shader (type: Shader)
Param[2]: uniformName (type: const char *)
-Function 076: GetShaderLocationAttrib() (2 input parameters)
+Function 078: GetShaderLocationAttrib() (2 input parameters)
Name: GetShaderLocationAttrib
Return type: int
Description: Get shader attribute location
Param[1]: shader (type: Shader)
Param[2]: attribName (type: const char *)
-Function 077: SetShaderValue() (4 input parameters)
+Function 079: SetShaderValue() (4 input parameters)
Name: SetShaderValue
Return type: void
Description: Set shader uniform value
@@ -1349,7 +1377,7 @@ Function 077: SetShaderValue() (4 input parameters)
Param[2]: locIndex (type: int)
Param[3]: value (type: const void *)
Param[4]: uniformType (type: int)
-Function 078: SetShaderValueV() (5 input parameters)
+Function 080: SetShaderValueV() (5 input parameters)
Name: SetShaderValueV
Return type: void
Description: Set shader uniform value vector
@@ -1358,54 +1386,54 @@ Function 078: SetShaderValueV() (5 input parameters)
Param[3]: value (type: const void *)
Param[4]: uniformType (type: int)
Param[5]: count (type: int)
-Function 079: SetShaderValueMatrix() (3 input parameters)
+Function 081: SetShaderValueMatrix() (3 input parameters)
Name: SetShaderValueMatrix
Return type: void
Description: Set shader uniform value (matrix 4x4)
Param[1]: shader (type: Shader)
Param[2]: locIndex (type: int)
Param[3]: mat (type: Matrix)
-Function 080: SetShaderValueTexture() (3 input parameters)
+Function 082: SetShaderValueTexture() (3 input parameters)
Name: SetShaderValueTexture
Return type: void
Description: Set shader uniform value for texture (sampler2d)
Param[1]: shader (type: Shader)
Param[2]: locIndex (type: int)
Param[3]: texture (type: Texture2D)
-Function 081: UnloadShader() (1 input parameters)
+Function 083: UnloadShader() (1 input parameters)
Name: UnloadShader
Return type: void
Description: Unload shader from GPU memory (VRAM)
Param[1]: shader (type: Shader)
-Function 082: GetMouseRay() (2 input parameters)
+Function 084: GetMouseRay() (2 input parameters)
Name: GetMouseRay
Return type: Ray
Description: Get a ray trace from mouse position
Param[1]: mousePosition (type: Vector2)
Param[2]: camera (type: Camera)
-Function 083: GetCameraMatrix() (1 input parameters)
+Function 085: GetCameraMatrix() (1 input parameters)
Name: GetCameraMatrix
Return type: Matrix
Description: Get camera transform matrix (view matrix)
Param[1]: camera (type: Camera)
-Function 084: GetCameraMatrix2D() (1 input parameters)
+Function 086: GetCameraMatrix2D() (1 input parameters)
Name: GetCameraMatrix2D
Return type: Matrix
Description: Get camera 2d transform matrix
Param[1]: camera (type: Camera2D)
-Function 085: GetWorldToScreen() (2 input parameters)
+Function 087: GetWorldToScreen() (2 input parameters)
Name: GetWorldToScreen
Return type: Vector2
Description: Get the screen space position for a 3d world space position
Param[1]: position (type: Vector3)
Param[2]: camera (type: Camera)
-Function 086: GetScreenToWorld2D() (2 input parameters)
+Function 088: GetScreenToWorld2D() (2 input parameters)
Name: GetScreenToWorld2D
Return type: Vector2
Description: Get the world space position for a 2d camera screen space position
Param[1]: position (type: Vector2)
Param[2]: camera (type: Camera2D)
-Function 087: GetWorldToScreenEx() (4 input parameters)
+Function 089: GetWorldToScreenEx() (4 input parameters)
Name: GetWorldToScreenEx
Return type: Vector2
Description: Get size position for a 3d world space position
@@ -1413,566 +1441,544 @@ Function 087: GetWorldToScreenEx() (4 input parameters)
Param[2]: camera (type: Camera)
Param[3]: width (type: int)
Param[4]: height (type: int)
-Function 088: GetWorldToScreen2D() (2 input parameters)
+Function 090: GetWorldToScreen2D() (2 input parameters)
Name: GetWorldToScreen2D
Return type: Vector2
Description: Get the screen space position for a 2d camera world space position
Param[1]: position (type: Vector2)
Param[2]: camera (type: Camera2D)
-Function 089: SetTargetFPS() (1 input parameters)
+Function 091: SetTargetFPS() (1 input parameters)
Name: SetTargetFPS
Return type: void
Description: Set target FPS (maximum)
Param[1]: fps (type: int)
-Function 090: GetFPS() (0 input parameters)
+Function 092: GetFPS() (0 input parameters)
Name: GetFPS
Return type: int
Description: Get current FPS
No input parameters
-Function 091: GetFrameTime() (0 input parameters)
+Function 093: GetFrameTime() (0 input parameters)
Name: GetFrameTime
Return type: float
Description: Get time in seconds for last frame drawn (delta time)
No input parameters
-Function 092: GetTime() (0 input parameters)
+Function 094: GetTime() (0 input parameters)
Name: GetTime
Return type: double
Description: Get elapsed time in seconds since InitWindow()
No input parameters
-Function 093: GetRandomValue() (2 input parameters)
+Function 095: GetRandomValue() (2 input parameters)
Name: GetRandomValue
Return type: int
Description: Get a random value between min and max (both included)
Param[1]: min (type: int)
Param[2]: max (type: int)
-Function 094: SetRandomSeed() (1 input parameters)
+Function 096: SetRandomSeed() (1 input parameters)
Name: SetRandomSeed
Return type: void
Description: Set the seed for the random number generator
Param[1]: seed (type: unsigned int)
-Function 095: TakeScreenshot() (1 input parameters)
+Function 097: TakeScreenshot() (1 input parameters)
Name: TakeScreenshot
Return type: void
Description: Takes a screenshot of current screen (filename extension defines format)
Param[1]: fileName (type: const char *)
-Function 096: SetConfigFlags() (1 input parameters)
+Function 098: SetConfigFlags() (1 input parameters)
Name: SetConfigFlags
Return type: void
Description: Setup init configuration flags (view FLAGS)
Param[1]: flags (type: unsigned int)
-Function 097: TraceLog() (3 input parameters)
+Function 099: TraceLog() (3 input parameters)
Name: TraceLog
Return type: void
Description: Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
Param[1]: logLevel (type: int)
Param[2]: text (type: const char *)
Param[3]: args (type: ...)
-Function 098: SetTraceLogLevel() (1 input parameters)
+Function 100: SetTraceLogLevel() (1 input parameters)
Name: SetTraceLogLevel
Return type: void
Description: Set the current threshold (minimum) log level
Param[1]: logLevel (type: int)
-Function 099: MemAlloc() (1 input parameters)
+Function 101: MemAlloc() (1 input parameters)
Name: MemAlloc
Return type: void *
Description: Internal memory allocator
- Param[1]: size (type: int)
-Function 100: MemRealloc() (2 input parameters)
+ Param[1]: size (type: unsigned int)
+Function 102: MemRealloc() (2 input parameters)
Name: MemRealloc
Return type: void *
Description: Internal memory reallocator
Param[1]: ptr (type: void *)
- Param[2]: size (type: int)
-Function 101: MemFree() (1 input parameters)
+ Param[2]: size (type: unsigned int)
+Function 103: MemFree() (1 input parameters)
Name: MemFree
Return type: void
Description: Internal memory free
Param[1]: ptr (type: void *)
-Function 102: OpenURL() (1 input parameters)
+Function 104: OpenURL() (1 input parameters)
Name: OpenURL
Return type: void
Description: Open URL with default system browser (if available)
Param[1]: url (type: const char *)
-Function 103: SetTraceLogCallback() (1 input parameters)
+Function 105: SetTraceLogCallback() (1 input parameters)
Name: SetTraceLogCallback
Return type: void
Description: Set custom trace log
Param[1]: callback (type: TraceLogCallback)
-Function 104: SetLoadFileDataCallback() (1 input parameters)
+Function 106: SetLoadFileDataCallback() (1 input parameters)
Name: SetLoadFileDataCallback
Return type: void
Description: Set custom file binary data loader
Param[1]: callback (type: LoadFileDataCallback)
-Function 105: SetSaveFileDataCallback() (1 input parameters)
+Function 107: SetSaveFileDataCallback() (1 input parameters)
Name: SetSaveFileDataCallback
Return type: void
Description: Set custom file binary data saver
Param[1]: callback (type: SaveFileDataCallback)
-Function 106: SetLoadFileTextCallback() (1 input parameters)
+Function 108: SetLoadFileTextCallback() (1 input parameters)
Name: SetLoadFileTextCallback
Return type: void
Description: Set custom file text data loader
Param[1]: callback (type: LoadFileTextCallback)
-Function 107: SetSaveFileTextCallback() (1 input parameters)
+Function 109: SetSaveFileTextCallback() (1 input parameters)
Name: SetSaveFileTextCallback
Return type: void
Description: Set custom file text data saver
Param[1]: callback (type: SaveFileTextCallback)
-Function 108: LoadFileData() (2 input parameters)
+Function 110: LoadFileData() (2 input parameters)
Name: LoadFileData
Return type: unsigned char *
Description: Load file data as byte array (read)
Param[1]: fileName (type: const char *)
Param[2]: bytesRead (type: unsigned int *)
-Function 109: UnloadFileData() (1 input parameters)
+Function 111: UnloadFileData() (1 input parameters)
Name: UnloadFileData
Return type: void
Description: Unload file data allocated by LoadFileData()
Param[1]: data (type: unsigned char *)
-Function 110: SaveFileData() (3 input parameters)
+Function 112: SaveFileData() (3 input parameters)
Name: SaveFileData
Return type: bool
Description: Save data to file from byte array (write), returns true on success
Param[1]: fileName (type: const char *)
Param[2]: data (type: void *)
Param[3]: bytesToWrite (type: unsigned int)
-Function 111: ExportDataAsCode() (3 input parameters)
+Function 113: ExportDataAsCode() (3 input parameters)
Name: ExportDataAsCode
Return type: bool
Description: Export data to code (.h), returns true on success
- Param[1]: data (type: const char *)
+ Param[1]: data (type: const unsigned char *)
Param[2]: size (type: unsigned int)
Param[3]: fileName (type: const char *)
-Function 112: LoadFileText() (1 input parameters)
+Function 114: LoadFileText() (1 input parameters)
Name: LoadFileText
Return type: char *
Description: Load text data from file (read), returns a '\0' terminated string
Param[1]: fileName (type: const char *)
-Function 113: UnloadFileText() (1 input parameters)
+Function 115: UnloadFileText() (1 input parameters)
Name: UnloadFileText
Return type: void
Description: Unload file text data allocated by LoadFileText()
Param[1]: text (type: char *)
-Function 114: SaveFileText() (2 input parameters)
+Function 116: SaveFileText() (2 input parameters)
Name: SaveFileText
Return type: bool
Description: Save text data to file (write), string must be '\0' terminated, returns true on success
Param[1]: fileName (type: const char *)
Param[2]: text (type: char *)
-Function 115: FileExists() (1 input parameters)
+Function 117: FileExists() (1 input parameters)
Name: FileExists
Return type: bool
Description: Check if file exists
Param[1]: fileName (type: const char *)
-Function 116: DirectoryExists() (1 input parameters)
+Function 118: DirectoryExists() (1 input parameters)
Name: DirectoryExists
Return type: bool
Description: Check if a directory path exists
Param[1]: dirPath (type: const char *)
-Function 117: IsFileExtension() (2 input parameters)
+Function 119: IsFileExtension() (2 input parameters)
Name: IsFileExtension
Return type: bool
Description: Check file extension (including point: .png, .wav)
Param[1]: fileName (type: const char *)
Param[2]: ext (type: const char *)
-Function 118: GetFileLength() (1 input parameters)
+Function 120: GetFileLength() (1 input parameters)
Name: GetFileLength
Return type: int
Description: Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)
Param[1]: fileName (type: const char *)
-Function 119: GetFileExtension() (1 input parameters)
+Function 121: GetFileExtension() (1 input parameters)
Name: GetFileExtension
Return type: const char *
Description: Get pointer to extension for a filename string (includes dot: '.png')
Param[1]: fileName (type: const char *)
-Function 120: GetFileName() (1 input parameters)
+Function 122: GetFileName() (1 input parameters)
Name: GetFileName
Return type: const char *
Description: Get pointer to filename for a path string
Param[1]: filePath (type: const char *)
-Function 121: GetFileNameWithoutExt() (1 input parameters)
+Function 123: GetFileNameWithoutExt() (1 input parameters)
Name: GetFileNameWithoutExt
Return type: const char *
Description: Get filename string without extension (uses static string)
Param[1]: filePath (type: const char *)
-Function 122: GetDirectoryPath() (1 input parameters)
+Function 124: GetDirectoryPath() (1 input parameters)
Name: GetDirectoryPath
Return type: const char *
Description: Get full path for a given fileName with path (uses static string)
Param[1]: filePath (type: const char *)
-Function 123: GetPrevDirectoryPath() (1 input parameters)
+Function 125: GetPrevDirectoryPath() (1 input parameters)
Name: GetPrevDirectoryPath
Return type: const char *
Description: Get previous directory path for a given path (uses static string)
Param[1]: dirPath (type: const char *)
-Function 124: GetWorkingDirectory() (0 input parameters)
+Function 126: GetWorkingDirectory() (0 input parameters)
Name: GetWorkingDirectory
Return type: const char *
Description: Get current working directory (uses static string)
No input parameters
-Function 125: GetApplicationDirectory() (0 input parameters)
+Function 127: GetApplicationDirectory() (0 input parameters)
Name: GetApplicationDirectory
Return type: const char *
Description: Get the directory if the running application (uses static string)
No input parameters
-Function 126: ChangeDirectory() (1 input parameters)
+Function 128: ChangeDirectory() (1 input parameters)
Name: ChangeDirectory
Return type: bool
Description: Change working directory, return true on success
Param[1]: dir (type: const char *)
-Function 127: IsPathFile() (1 input parameters)
+Function 129: IsPathFile() (1 input parameters)
Name: IsPathFile
Return type: bool
Description: Check if a given path is a file or a directory
Param[1]: path (type: const char *)
-Function 128: LoadDirectoryFiles() (1 input parameters)
+Function 130: LoadDirectoryFiles() (1 input parameters)
Name: LoadDirectoryFiles
Return type: FilePathList
Description: Load directory filepaths
Param[1]: dirPath (type: const char *)
-Function 129: LoadDirectoryFilesEx() (3 input parameters)
+Function 131: LoadDirectoryFilesEx() (3 input parameters)
Name: LoadDirectoryFilesEx
Return type: FilePathList
Description: Load directory filepaths with extension filtering and recursive directory scan
Param[1]: basePath (type: const char *)
Param[2]: filter (type: const char *)
Param[3]: scanSubdirs (type: bool)
-Function 130: UnloadDirectoryFiles() (1 input parameters)
+Function 132: UnloadDirectoryFiles() (1 input parameters)
Name: UnloadDirectoryFiles
Return type: void
Description: Unload filepaths
Param[1]: files (type: FilePathList)
-Function 131: IsFileDropped() (0 input parameters)
+Function 133: IsFileDropped() (0 input parameters)
Name: IsFileDropped
Return type: bool
Description: Check if a file has been dropped into window
No input parameters
-Function 132: LoadDroppedFiles() (0 input parameters)
+Function 134: LoadDroppedFiles() (0 input parameters)
Name: LoadDroppedFiles
Return type: FilePathList
Description: Load dropped filepaths
No input parameters
-Function 133: UnloadDroppedFiles() (1 input parameters)
+Function 135: UnloadDroppedFiles() (1 input parameters)
Name: UnloadDroppedFiles
Return type: void
Description: Unload dropped filepaths
Param[1]: files (type: FilePathList)
-Function 134: GetFileModTime() (1 input parameters)
+Function 136: GetFileModTime() (1 input parameters)
Name: GetFileModTime
Return type: long
Description: Get file modification time (last write time)
Param[1]: fileName (type: const char *)
-Function 135: CompressData() (3 input parameters)
+Function 137: CompressData() (3 input parameters)
Name: CompressData
Return type: unsigned char *
Description: Compress data (DEFLATE algorithm), memory must be MemFree()
Param[1]: data (type: const unsigned char *)
Param[2]: dataSize (type: int)
Param[3]: compDataSize (type: int *)
-Function 136: DecompressData() (3 input parameters)
+Function 138: DecompressData() (3 input parameters)
Name: DecompressData
Return type: unsigned char *
Description: Decompress data (DEFLATE algorithm), memory must be MemFree()
Param[1]: compData (type: const unsigned char *)
Param[2]: compDataSize (type: int)
Param[3]: dataSize (type: int *)
-Function 137: EncodeDataBase64() (3 input parameters)
+Function 139: EncodeDataBase64() (3 input parameters)
Name: EncodeDataBase64
Return type: char *
Description: Encode data to Base64 string, memory must be MemFree()
Param[1]: data (type: const unsigned char *)
Param[2]: dataSize (type: int)
Param[3]: outputSize (type: int *)
-Function 138: DecodeDataBase64() (2 input parameters)
+Function 140: DecodeDataBase64() (2 input parameters)
Name: DecodeDataBase64
Return type: unsigned char *
Description: Decode Base64 string data, memory must be MemFree()
Param[1]: data (type: const unsigned char *)
Param[2]: outputSize (type: int *)
-Function 139: IsKeyPressed() (1 input parameters)
+Function 141: IsKeyPressed() (1 input parameters)
Name: IsKeyPressed
Return type: bool
Description: Check if a key has been pressed once
Param[1]: key (type: int)
-Function 140: IsKeyDown() (1 input parameters)
+Function 142: IsKeyDown() (1 input parameters)
Name: IsKeyDown
Return type: bool
Description: Check if a key is being pressed
Param[1]: key (type: int)
-Function 141: IsKeyReleased() (1 input parameters)
+Function 143: IsKeyReleased() (1 input parameters)
Name: IsKeyReleased
Return type: bool
Description: Check if a key has been released once
Param[1]: key (type: int)
-Function 142: IsKeyUp() (1 input parameters)
+Function 144: IsKeyUp() (1 input parameters)
Name: IsKeyUp
Return type: bool
Description: Check if a key is NOT being pressed
Param[1]: key (type: int)
-Function 143: SetExitKey() (1 input parameters)
+Function 145: SetExitKey() (1 input parameters)
Name: SetExitKey
Return type: void
Description: Set a custom key to exit program (default is ESC)
Param[1]: key (type: int)
-Function 144: GetKeyPressed() (0 input parameters)
+Function 146: GetKeyPressed() (0 input parameters)
Name: GetKeyPressed
Return type: int
Description: Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty
No input parameters
-Function 145: GetCharPressed() (0 input parameters)
+Function 147: GetCharPressed() (0 input parameters)
Name: GetCharPressed
Return type: int
Description: Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty
No input parameters
-Function 146: IsGamepadAvailable() (1 input parameters)
+Function 148: IsGamepadAvailable() (1 input parameters)
Name: IsGamepadAvailable
Return type: bool
Description: Check if a gamepad is available
Param[1]: gamepad (type: int)
-Function 147: GetGamepadName() (1 input parameters)
+Function 149: GetGamepadName() (1 input parameters)
Name: GetGamepadName
Return type: const char *
Description: Get gamepad internal name id
Param[1]: gamepad (type: int)
-Function 148: IsGamepadButtonPressed() (2 input parameters)
+Function 150: IsGamepadButtonPressed() (2 input parameters)
Name: IsGamepadButtonPressed
Return type: bool
Description: Check if a gamepad button has been pressed once
Param[1]: gamepad (type: int)
Param[2]: button (type: int)
-Function 149: IsGamepadButtonDown() (2 input parameters)
+Function 151: IsGamepadButtonDown() (2 input parameters)
Name: IsGamepadButtonDown
Return type: bool
Description: Check if a gamepad button is being pressed
Param[1]: gamepad (type: int)
Param[2]: button (type: int)
-Function 150: IsGamepadButtonReleased() (2 input parameters)
+Function 152: IsGamepadButtonReleased() (2 input parameters)
Name: IsGamepadButtonReleased
Return type: bool
Description: Check if a gamepad button has been released once
Param[1]: gamepad (type: int)
Param[2]: button (type: int)
-Function 151: IsGamepadButtonUp() (2 input parameters)
+Function 153: IsGamepadButtonUp() (2 input parameters)
Name: IsGamepadButtonUp
Return type: bool
Description: Check if a gamepad button is NOT being pressed
Param[1]: gamepad (type: int)
Param[2]: button (type: int)
-Function 152: GetGamepadButtonPressed() (0 input parameters)
+Function 154: GetGamepadButtonPressed() (0 input parameters)
Name: GetGamepadButtonPressed
Return type: int
Description: Get the last gamepad button pressed
No input parameters
-Function 153: GetGamepadAxisCount() (1 input parameters)
+Function 155: GetGamepadAxisCount() (1 input parameters)
Name: GetGamepadAxisCount
Return type: int
Description: Get gamepad axis count for a gamepad
Param[1]: gamepad (type: int)
-Function 154: GetGamepadAxisMovement() (2 input parameters)
+Function 156: GetGamepadAxisMovement() (2 input parameters)
Name: GetGamepadAxisMovement
Return type: float
Description: Get axis movement value for a gamepad axis
Param[1]: gamepad (type: int)
Param[2]: axis (type: int)
-Function 155: SetGamepadMappings() (1 input parameters)
+Function 157: SetGamepadMappings() (1 input parameters)
Name: SetGamepadMappings
Return type: int
Description: Set internal gamepad mappings (SDL_GameControllerDB)
Param[1]: mappings (type: const char *)
-Function 156: IsMouseButtonPressed() (1 input parameters)
+Function 158: IsMouseButtonPressed() (1 input parameters)
Name: IsMouseButtonPressed
Return type: bool
Description: Check if a mouse button has been pressed once
Param[1]: button (type: int)
-Function 157: IsMouseButtonDown() (1 input parameters)
+Function 159: IsMouseButtonDown() (1 input parameters)
Name: IsMouseButtonDown
Return type: bool
Description: Check if a mouse button is being pressed
Param[1]: button (type: int)
-Function 158: IsMouseButtonReleased() (1 input parameters)
+Function 160: IsMouseButtonReleased() (1 input parameters)
Name: IsMouseButtonReleased
Return type: bool
Description: Check if a mouse button has been released once
Param[1]: button (type: int)
-Function 159: IsMouseButtonUp() (1 input parameters)
+Function 161: IsMouseButtonUp() (1 input parameters)
Name: IsMouseButtonUp
Return type: bool
Description: Check if a mouse button is NOT being pressed
Param[1]: button (type: int)
-Function 160: GetMouseX() (0 input parameters)
+Function 162: GetMouseX() (0 input parameters)
Name: GetMouseX
Return type: int
Description: Get mouse position X
No input parameters
-Function 161: GetMouseY() (0 input parameters)
+Function 163: GetMouseY() (0 input parameters)
Name: GetMouseY
Return type: int
Description: Get mouse position Y
No input parameters
-Function 162: GetMousePosition() (0 input parameters)
+Function 164: GetMousePosition() (0 input parameters)
Name: GetMousePosition
Return type: Vector2
Description: Get mouse position XY
No input parameters
-Function 163: GetMouseDelta() (0 input parameters)
+Function 165: GetMouseDelta() (0 input parameters)
Name: GetMouseDelta
Return type: Vector2
Description: Get mouse delta between frames
No input parameters
-Function 164: SetMousePosition() (2 input parameters)
+Function 166: SetMousePosition() (2 input parameters)
Name: SetMousePosition
Return type: void
Description: Set mouse position XY
Param[1]: x (type: int)
Param[2]: y (type: int)
-Function 165: SetMouseOffset() (2 input parameters)
+Function 167: SetMouseOffset() (2 input parameters)
Name: SetMouseOffset
Return type: void
Description: Set mouse offset
Param[1]: offsetX (type: int)
Param[2]: offsetY (type: int)
-Function 166: SetMouseScale() (2 input parameters)
+Function 168: SetMouseScale() (2 input parameters)
Name: SetMouseScale
Return type: void
Description: Set mouse scaling
Param[1]: scaleX (type: float)
Param[2]: scaleY (type: float)
-Function 167: GetMouseWheelMove() (0 input parameters)
+Function 169: GetMouseWheelMove() (0 input parameters)
Name: GetMouseWheelMove
Return type: float
Description: Get mouse wheel movement for X or Y, whichever is larger
No input parameters
-Function 168: GetMouseWheelMoveV() (0 input parameters)
+Function 170: GetMouseWheelMoveV() (0 input parameters)
Name: GetMouseWheelMoveV
Return type: Vector2
Description: Get mouse wheel movement for both X and Y
No input parameters
-Function 169: SetMouseCursor() (1 input parameters)
+Function 171: SetMouseCursor() (1 input parameters)
Name: SetMouseCursor
Return type: void
Description: Set mouse cursor
Param[1]: cursor (type: int)
-Function 170: GetTouchX() (0 input parameters)
+Function 172: GetTouchX() (0 input parameters)
Name: GetTouchX
Return type: int
Description: Get touch position X for touch point 0 (relative to screen size)
No input parameters
-Function 171: GetTouchY() (0 input parameters)
+Function 173: GetTouchY() (0 input parameters)
Name: GetTouchY
Return type: int
Description: Get touch position Y for touch point 0 (relative to screen size)
No input parameters
-Function 172: GetTouchPosition() (1 input parameters)
+Function 174: GetTouchPosition() (1 input parameters)
Name: GetTouchPosition
Return type: Vector2
Description: Get touch position XY for a touch point index (relative to screen size)
Param[1]: index (type: int)
-Function 173: GetTouchPointId() (1 input parameters)
+Function 175: GetTouchPointId() (1 input parameters)
Name: GetTouchPointId
Return type: int
Description: Get touch point identifier for given index
Param[1]: index (type: int)
-Function 174: GetTouchPointCount() (0 input parameters)
+Function 176: GetTouchPointCount() (0 input parameters)
Name: GetTouchPointCount
Return type: int
Description: Get number of touch points
No input parameters
-Function 175: SetGesturesEnabled() (1 input parameters)
+Function 177: SetGesturesEnabled() (1 input parameters)
Name: SetGesturesEnabled
Return type: void
Description: Enable a set of gestures using flags
Param[1]: flags (type: unsigned int)
-Function 176: IsGestureDetected() (1 input parameters)
+Function 178: IsGestureDetected() (1 input parameters)
Name: IsGestureDetected
Return type: bool
Description: Check if a gesture have been detected
Param[1]: gesture (type: int)
-Function 177: GetGestureDetected() (0 input parameters)
+Function 179: GetGestureDetected() (0 input parameters)
Name: GetGestureDetected
Return type: int
Description: Get latest detected gesture
No input parameters
-Function 178: GetGestureHoldDuration() (0 input parameters)
+Function 180: GetGestureHoldDuration() (0 input parameters)
Name: GetGestureHoldDuration
Return type: float
Description: Get gesture hold time in milliseconds
No input parameters
-Function 179: GetGestureDragVector() (0 input parameters)
+Function 181: GetGestureDragVector() (0 input parameters)
Name: GetGestureDragVector
Return type: Vector2
Description: Get gesture drag vector
No input parameters
-Function 180: GetGestureDragAngle() (0 input parameters)
+Function 182: GetGestureDragAngle() (0 input parameters)
Name: GetGestureDragAngle
Return type: float
Description: Get gesture drag angle
No input parameters
-Function 181: GetGesturePinchVector() (0 input parameters)
+Function 183: GetGesturePinchVector() (0 input parameters)
Name: GetGesturePinchVector
Return type: Vector2
Description: Get gesture pinch delta
No input parameters
-Function 182: GetGesturePinchAngle() (0 input parameters)
+Function 184: GetGesturePinchAngle() (0 input parameters)
Name: GetGesturePinchAngle
Return type: float
Description: Get gesture pinch angle
No input parameters
-Function 183: SetCameraMode() (2 input parameters)
- Name: SetCameraMode
- Return type: void
- Description: Set camera mode (multiple camera modes available)
- Param[1]: camera (type: Camera)
- Param[2]: mode (type: int)
-Function 184: UpdateCamera() (1 input parameters)
+Function 185: UpdateCamera() (2 input parameters)
Name: UpdateCamera
Return type: void
Description: Update camera position for selected mode
Param[1]: camera (type: Camera *)
-Function 185: SetCameraPanControl() (1 input parameters)
- Name: SetCameraPanControl
+ Param[2]: mode (type: int)
+Function 186: UpdateCameraPro() (4 input parameters)
+ Name: UpdateCameraPro
Return type: void
- Description: Set camera pan key to combine with mouse movement (free camera)
- Param[1]: keyPan (type: int)
-Function 186: SetCameraAltControl() (1 input parameters)
- Name: SetCameraAltControl
- Return type: void
- Description: Set camera alt key to combine with mouse movement (free camera)
- Param[1]: keyAlt (type: int)
-Function 187: SetCameraSmoothZoomControl() (1 input parameters)
- Name: SetCameraSmoothZoomControl
- Return type: void
- Description: Set camera smooth zoom key to combine with mouse (free camera)
- Param[1]: keySmoothZoom (type: int)
-Function 188: SetCameraMoveControls() (6 input parameters)
- Name: SetCameraMoveControls
- Return type: void
- Description: Set camera move controls (1st person and 3rd person cameras)
- Param[1]: keyFront (type: int)
- Param[2]: keyBack (type: int)
- Param[3]: keyRight (type: int)
- Param[4]: keyLeft (type: int)
- Param[5]: keyUp (type: int)
- Param[6]: keyDown (type: int)
-Function 189: SetShapesTexture() (2 input parameters)
+ Description: Update camera movement/rotation
+ Param[1]: camera (type: Camera *)
+ Param[2]: movement (type: Vector3)
+ Param[3]: rotation (type: Vector3)
+ Param[4]: zoom (type: float)
+Function 187: SetShapesTexture() (2 input parameters)
Name: SetShapesTexture
Return type: void
Description: Set texture and rectangle to be used on shapes drawing
Param[1]: texture (type: Texture2D)
Param[2]: source (type: Rectangle)
-Function 190: DrawPixel() (3 input parameters)
+Function 188: DrawPixel() (3 input parameters)
Name: DrawPixel
Return type: void
Description: Draw a pixel
Param[1]: posX (type: int)
Param[2]: posY (type: int)
Param[3]: color (type: Color)
-Function 191: DrawPixelV() (2 input parameters)
+Function 189: DrawPixelV() (2 input parameters)
Name: DrawPixelV
Return type: void
Description: Draw a pixel (Vector version)
Param[1]: position (type: Vector2)
Param[2]: color (type: Color)
-Function 192: DrawLine() (5 input parameters)
+Function 190: DrawLine() (5 input parameters)
Name: DrawLine
Return type: void
Description: Draw a line
@@ -1981,14 +1987,14 @@ Function 192: DrawLine() (5 input parameters)
Param[3]: endPosX (type: int)
Param[4]: endPosY (type: int)
Param[5]: color (type: Color)
-Function 193: DrawLineV() (3 input parameters)
+Function 191: DrawLineV() (3 input parameters)
Name: DrawLineV
Return type: void
Description: Draw a line (Vector version)
Param[1]: startPos (type: Vector2)
Param[2]: endPos (type: Vector2)
Param[3]: color (type: Color)
-Function 194: DrawLineEx() (4 input parameters)
+Function 192: DrawLineEx() (4 input parameters)
Name: DrawLineEx
Return type: void
Description: Draw a line defining thickness
@@ -1996,7 +2002,7 @@ Function 194: DrawLineEx() (4 input parameters)
Param[2]: endPos (type: Vector2)
Param[3]: thick (type: float)
Param[4]: color (type: Color)
-Function 195: DrawLineBezier() (4 input parameters)
+Function 193: DrawLineBezier() (4 input parameters)
Name: DrawLineBezier
Return type: void
Description: Draw a line using cubic-bezier curves in-out
@@ -2004,7 +2010,7 @@ Function 195: DrawLineBezier() (4 input parameters)
Param[2]: endPos (type: Vector2)
Param[3]: thick (type: float)
Param[4]: color (type: Color)
-Function 196: DrawLineBezierQuad() (5 input parameters)
+Function 194: DrawLineBezierQuad() (5 input parameters)
Name: DrawLineBezierQuad
Return type: void
Description: Draw line using quadratic bezier curves with a control point
@@ -2013,7 +2019,7 @@ Function 196: DrawLineBezierQuad() (5 input parameters)
Param[3]: controlPos (type: Vector2)
Param[4]: thick (type: float)
Param[5]: color (type: Color)
-Function 197: DrawLineBezierCubic() (6 input parameters)
+Function 195: DrawLineBezierCubic() (6 input parameters)
Name: DrawLineBezierCubic
Return type: void
Description: Draw line using cubic bezier curves with 2 control points
@@ -2023,14 +2029,14 @@ Function 197: DrawLineBezierCubic() (6 input parameters)
Param[4]: endControlPos (type: Vector2)
Param[5]: thick (type: float)
Param[6]: color (type: Color)
-Function 198: DrawLineStrip() (3 input parameters)
+Function 196: DrawLineStrip() (3 input parameters)
Name: DrawLineStrip
Return type: void
Description: Draw lines sequence
Param[1]: points (type: Vector2 *)
Param[2]: pointCount (type: int)
Param[3]: color (type: Color)
-Function 199: DrawCircle() (4 input parameters)
+Function 197: DrawCircle() (4 input parameters)
Name: DrawCircle
Return type: void
Description: Draw a color-filled circle
@@ -2038,7 +2044,7 @@ Function 199: DrawCircle() (4 input parameters)
Param[2]: centerY (type: int)
Param[3]: radius (type: float)
Param[4]: color (type: Color)
-Function 200: DrawCircleSector() (6 input parameters)
+Function 198: DrawCircleSector() (6 input parameters)
Name: DrawCircleSector
Return type: void
Description: Draw a piece of a circle
@@ -2048,7 +2054,7 @@ Function 200: DrawCircleSector() (6 input parameters)
Param[4]: endAngle (type: float)
Param[5]: segments (type: int)
Param[6]: color (type: Color)
-Function 201: DrawCircleSectorLines() (6 input parameters)
+Function 199: DrawCircleSectorLines() (6 input parameters)
Name: DrawCircleSectorLines
Return type: void
Description: Draw circle sector outline
@@ -2058,7 +2064,7 @@ Function 201: DrawCircleSectorLines() (6 input parameters)
Param[4]: endAngle (type: float)
Param[5]: segments (type: int)
Param[6]: color (type: Color)
-Function 202: DrawCircleGradient() (5 input parameters)
+Function 200: DrawCircleGradient() (5 input parameters)
Name: DrawCircleGradient
Return type: void
Description: Draw a gradient-filled circle
@@ -2067,14 +2073,14 @@ Function 202: DrawCircleGradient() (5 input parameters)
Param[3]: radius (type: float)
Param[4]: color1 (type: Color)
Param[5]: color2 (type: Color)
-Function 203: DrawCircleV() (3 input parameters)
+Function 201: DrawCircleV() (3 input parameters)
Name: DrawCircleV
Return type: void
Description: Draw a color-filled circle (Vector version)
Param[1]: center (type: Vector2)
Param[2]: radius (type: float)
Param[3]: color (type: Color)
-Function 204: DrawCircleLines() (4 input parameters)
+Function 202: DrawCircleLines() (4 input parameters)
Name: DrawCircleLines
Return type: void
Description: Draw circle outline
@@ -2082,7 +2088,7 @@ Function 204: DrawCircleLines() (4 input parameters)
Param[2]: centerY (type: int)
Param[3]: radius (type: float)
Param[4]: color (type: Color)
-Function 205: DrawEllipse() (5 input parameters)
+Function 203: DrawEllipse() (5 input parameters)
Name: DrawEllipse
Return type: void
Description: Draw ellipse
@@ -2091,7 +2097,7 @@ Function 205: DrawEllipse() (5 input parameters)
Param[3]: radiusH (type: float)
Param[4]: radiusV (type: float)
Param[5]: color (type: Color)
-Function 206: DrawEllipseLines() (5 input parameters)
+Function 204: DrawEllipseLines() (5 input parameters)
Name: DrawEllipseLines
Return type: void
Description: Draw ellipse outline
@@ -2100,7 +2106,7 @@ Function 206: DrawEllipseLines() (5 input parameters)
Param[3]: radiusH (type: float)
Param[4]: radiusV (type: float)
Param[5]: color (type: Color)
-Function 207: DrawRing() (7 input parameters)
+Function 205: DrawRing() (7 input parameters)
Name: DrawRing
Return type: void
Description: Draw ring
@@ -2111,7 +2117,7 @@ Function 207: DrawRing() (7 input parameters)
Param[5]: endAngle (type: float)
Param[6]: segments (type: int)
Param[7]: color (type: Color)
-Function 208: DrawRingLines() (7 input parameters)
+Function 206: DrawRingLines() (7 input parameters)
Name: DrawRingLines
Return type: void
Description: Draw ring outline
@@ -2122,7 +2128,7 @@ Function 208: DrawRingLines() (7 input parameters)
Param[5]: endAngle (type: float)
Param[6]: segments (type: int)
Param[7]: color (type: Color)
-Function 209: DrawRectangle() (5 input parameters)
+Function 207: DrawRectangle() (5 input parameters)
Name: DrawRectangle
Return type: void
Description: Draw a color-filled rectangle
@@ -2131,20 +2137,20 @@ Function 209: DrawRectangle() (5 input parameters)
Param[3]: width (type: int)
Param[4]: height (type: int)
Param[5]: color (type: Color)
-Function 210: DrawRectangleV() (3 input parameters)
+Function 208: DrawRectangleV() (3 input parameters)
Name: DrawRectangleV
Return type: void
Description: Draw a color-filled rectangle (Vector version)
Param[1]: position (type: Vector2)
Param[2]: size (type: Vector2)
Param[3]: color (type: Color)
-Function 211: DrawRectangleRec() (2 input parameters)
+Function 209: DrawRectangleRec() (2 input parameters)
Name: DrawRectangleRec
Return type: void
Description: Draw a color-filled rectangle
Param[1]: rec (type: Rectangle)
Param[2]: color (type: Color)
-Function 212: DrawRectanglePro() (4 input parameters)
+Function 210: DrawRectanglePro() (4 input parameters)
Name: DrawRectanglePro
Return type: void
Description: Draw a color-filled rectangle with pro parameters
@@ -2152,7 +2158,7 @@ Function 212: DrawRectanglePro() (4 input parameters)
Param[2]: origin (type: Vector2)
Param[3]: rotation (type: float)
Param[4]: color (type: Color)
-Function 213: DrawRectangleGradientV() (6 input parameters)
+Function 211: DrawRectangleGradientV() (6 input parameters)
Name: DrawRectangleGradientV
Return type: void
Description: Draw a vertical-gradient-filled rectangle
@@ -2162,7 +2168,7 @@ Function 213: DrawRectangleGradientV() (6 input parameters)
Param[4]: height (type: int)
Param[5]: color1 (type: Color)
Param[6]: color2 (type: Color)
-Function 214: DrawRectangleGradientH() (6 input parameters)
+Function 212: DrawRectangleGradientH() (6 input parameters)
Name: DrawRectangleGradientH
Return type: void
Description: Draw a horizontal-gradient-filled rectangle
@@ -2172,7 +2178,7 @@ Function 214: DrawRectangleGradientH() (6 input parameters)
Param[4]: height (type: int)
Param[5]: color1 (type: Color)
Param[6]: color2 (type: Color)
-Function 215: DrawRectangleGradientEx() (5 input parameters)
+Function 213: DrawRectangleGradientEx() (5 input parameters)
Name: DrawRectangleGradientEx
Return type: void
Description: Draw a gradient-filled rectangle with custom vertex colors
@@ -2181,7 +2187,7 @@ Function 215: DrawRectangleGradientEx() (5 input parameters)
Param[3]: col2 (type: Color)
Param[4]: col3 (type: Color)
Param[5]: col4 (type: Color)
-Function 216: DrawRectangleLines() (5 input parameters)
+Function 214: DrawRectangleLines() (5 input parameters)
Name: DrawRectangleLines
Return type: void
Description: Draw rectangle outline
@@ -2190,14 +2196,14 @@ Function 216: DrawRectangleLines() (5 input parameters)
Param[3]: width (type: int)
Param[4]: height (type: int)
Param[5]: color (type: Color)
-Function 217: DrawRectangleLinesEx() (3 input parameters)
+Function 215: DrawRectangleLinesEx() (3 input parameters)
Name: DrawRectangleLinesEx
Return type: void
Description: Draw rectangle outline with extended parameters
Param[1]: rec (type: Rectangle)
Param[2]: lineThick (type: float)
Param[3]: color (type: Color)
-Function 218: DrawRectangleRounded() (4 input parameters)
+Function 216: DrawRectangleRounded() (4 input parameters)
Name: DrawRectangleRounded
Return type: void
Description: Draw rectangle with rounded edges
@@ -2205,7 +2211,7 @@ Function 218: DrawRectangleRounded() (4 input parameters)
Param[2]: roundness (type: float)
Param[3]: segments (type: int)
Param[4]: color (type: Color)
-Function 219: DrawRectangleRoundedLines() (5 input parameters)
+Function 217: DrawRectangleRoundedLines() (5 input parameters)
Name: DrawRectangleRoundedLines
Return type: void
Description: Draw rectangle with rounded edges outline
@@ -2214,7 +2220,7 @@ Function 219: DrawRectangleRoundedLines() (5 input parameters)
Param[3]: segments (type: int)
Param[4]: lineThick (type: float)
Param[5]: color (type: Color)
-Function 220: DrawTriangle() (4 input parameters)
+Function 218: DrawTriangle() (4 input parameters)
Name: DrawTriangle
Return type: void
Description: Draw a color-filled triangle (vertex in counter-clockwise order!)
@@ -2222,7 +2228,7 @@ Function 220: DrawTriangle() (4 input parameters)
Param[2]: v2 (type: Vector2)
Param[3]: v3 (type: Vector2)
Param[4]: color (type: Color)
-Function 221: DrawTriangleLines() (4 input parameters)
+Function 219: DrawTriangleLines() (4 input parameters)
Name: DrawTriangleLines
Return type: void
Description: Draw triangle outline (vertex in counter-clockwise order!)
@@ -2230,21 +2236,21 @@ Function 221: DrawTriangleLines() (4 input parameters)
Param[2]: v2 (type: Vector2)
Param[3]: v3 (type: Vector2)
Param[4]: color (type: Color)
-Function 222: DrawTriangleFan() (3 input parameters)
+Function 220: DrawTriangleFan() (3 input parameters)
Name: DrawTriangleFan
Return type: void
Description: Draw a triangle fan defined by points (first vertex is the center)
Param[1]: points (type: Vector2 *)
Param[2]: pointCount (type: int)
Param[3]: color (type: Color)
-Function 223: DrawTriangleStrip() (3 input parameters)
+Function 221: DrawTriangleStrip() (3 input parameters)
Name: DrawTriangleStrip
Return type: void
Description: Draw a triangle strip defined by points
Param[1]: points (type: Vector2 *)
Param[2]: pointCount (type: int)
Param[3]: color (type: Color)
-Function 224: DrawPoly() (5 input parameters)
+Function 222: DrawPoly() (5 input parameters)
Name: DrawPoly
Return type: void
Description: Draw a regular polygon (Vector version)
@@ -2253,7 +2259,7 @@ Function 224: DrawPoly() (5 input parameters)
Param[3]: radius (type: float)
Param[4]: rotation (type: float)
Param[5]: color (type: Color)
-Function 225: DrawPolyLines() (5 input parameters)
+Function 223: DrawPolyLines() (5 input parameters)
Name: DrawPolyLines
Return type: void
Description: Draw a polygon outline of n sides
@@ -2262,7 +2268,7 @@ Function 225: DrawPolyLines() (5 input parameters)
Param[3]: radius (type: float)
Param[4]: rotation (type: float)
Param[5]: color (type: Color)
-Function 226: DrawPolyLinesEx() (6 input parameters)
+Function 224: DrawPolyLinesEx() (6 input parameters)
Name: DrawPolyLinesEx
Return type: void
Description: Draw a polygon outline of n sides with extended parameters
@@ -2272,13 +2278,13 @@ Function 226: DrawPolyLinesEx() (6 input parameters)
Param[4]: rotation (type: float)
Param[5]: lineThick (type: float)
Param[6]: color (type: Color)
-Function 227: CheckCollisionRecs() (2 input parameters)
+Function 225: CheckCollisionRecs() (2 input parameters)
Name: CheckCollisionRecs
Return type: bool
Description: Check collision between two rectangles
Param[1]: rec1 (type: Rectangle)
Param[2]: rec2 (type: Rectangle)
-Function 228: CheckCollisionCircles() (4 input parameters)
+Function 226: CheckCollisionCircles() (4 input parameters)
Name: CheckCollisionCircles
Return type: bool
Description: Check collision between two circles
@@ -2286,27 +2292,27 @@ Function 228: CheckCollisionCircles() (4 input parameters)
Param[2]: radius1 (type: float)
Param[3]: center2 (type: Vector2)
Param[4]: radius2 (type: float)
-Function 229: CheckCollisionCircleRec() (3 input parameters)
+Function 227: CheckCollisionCircleRec() (3 input parameters)
Name: CheckCollisionCircleRec
Return type: bool
Description: Check collision between circle and rectangle
Param[1]: center (type: Vector2)
Param[2]: radius (type: float)
Param[3]: rec (type: Rectangle)
-Function 230: CheckCollisionPointRec() (2 input parameters)
+Function 228: CheckCollisionPointRec() (2 input parameters)
Name: CheckCollisionPointRec
Return type: bool
Description: Check if point is inside rectangle
Param[1]: point (type: Vector2)
Param[2]: rec (type: Rectangle)
-Function 231: CheckCollisionPointCircle() (3 input parameters)
+Function 229: CheckCollisionPointCircle() (3 input parameters)
Name: CheckCollisionPointCircle
Return type: bool
Description: Check if point is inside circle
Param[1]: point (type: Vector2)
Param[2]: center (type: Vector2)
Param[3]: radius (type: float)
-Function 232: CheckCollisionPointTriangle() (4 input parameters)
+Function 230: CheckCollisionPointTriangle() (4 input parameters)
Name: CheckCollisionPointTriangle
Return type: bool
Description: Check if point is inside a triangle
@@ -2314,7 +2320,14 @@ Function 232: CheckCollisionPointTriangle() (4 input parameters)
Param[2]: p1 (type: Vector2)
Param[3]: p2 (type: Vector2)
Param[4]: p3 (type: Vector2)
-Function 233: CheckCollisionLines() (5 input parameters)
+Function 231: CheckCollisionPointPoly() (3 input parameters)
+ Name: CheckCollisionPointPoly
+ Return type: bool
+ Description: Check if point is within a polygon described by array of vertices
+ Param[1]: point (type: Vector2)
+ Param[2]: points (type: Vector2 *)
+ Param[3]: pointCount (type: int)
+Function 232: CheckCollisionLines() (5 input parameters)
Name: CheckCollisionLines
Return type: bool
Description: Check the collision between two lines defined by two points each, returns collision point by reference
@@ -2323,7 +2336,7 @@ Function 233: CheckCollisionLines() (5 input parameters)
Param[3]: startPos2 (type: Vector2)
Param[4]: endPos2 (type: Vector2)
Param[5]: collisionPoint (type: Vector2 *)
-Function 234: CheckCollisionPointLine() (4 input parameters)
+Function 233: CheckCollisionPointLine() (4 input parameters)
Name: CheckCollisionPointLine
Return type: bool
Description: Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]
@@ -2331,18 +2344,18 @@ Function 234: CheckCollisionPointLine() (4 input parameters)
Param[2]: p1 (type: Vector2)
Param[3]: p2 (type: Vector2)
Param[4]: threshold (type: int)
-Function 235: GetCollisionRec() (2 input parameters)
+Function 234: GetCollisionRec() (2 input parameters)
Name: GetCollisionRec
Return type: Rectangle
Description: Get collision rectangle for two rectangles collision
Param[1]: rec1 (type: Rectangle)
Param[2]: rec2 (type: Rectangle)
-Function 236: LoadImage() (1 input parameters)
+Function 235: LoadImage() (1 input parameters)
Name: LoadImage
Return type: Image
Description: Load image from file into CPU memory (RAM)
Param[1]: fileName (type: const char *)
-Function 237: LoadImageRaw() (5 input parameters)
+Function 236: LoadImageRaw() (5 input parameters)
Name: LoadImageRaw
Return type: Image
Description: Load image from RAW file data
@@ -2351,29 +2364,34 @@ Function 237: LoadImageRaw() (5 input parameters)
Param[3]: height (type: int)
Param[4]: format (type: int)
Param[5]: headerSize (type: int)
-Function 238: LoadImageAnim() (2 input parameters)
+Function 237: LoadImageAnim() (2 input parameters)
Name: LoadImageAnim
Return type: Image
Description: Load image sequence from file (frames appended to image.data)
Param[1]: fileName (type: const char *)
Param[2]: frames (type: int *)
-Function 239: LoadImageFromMemory() (3 input parameters)
+Function 238: LoadImageFromMemory() (3 input parameters)
Name: LoadImageFromMemory
Return type: Image
Description: Load image from memory buffer, fileType refers to extension: i.e. '.png'
Param[1]: fileType (type: const char *)
Param[2]: fileData (type: const unsigned char *)
Param[3]: dataSize (type: int)
-Function 240: LoadImageFromTexture() (1 input parameters)
+Function 239: LoadImageFromTexture() (1 input parameters)
Name: LoadImageFromTexture
Return type: Image
Description: Load image from GPU texture data
Param[1]: texture (type: Texture2D)
-Function 241: LoadImageFromScreen() (0 input parameters)
+Function 240: LoadImageFromScreen() (0 input parameters)
Name: LoadImageFromScreen
Return type: Image
Description: Load image from screen buffer and (screenshot)
No input parameters
+Function 241: IsImageReady() (1 input parameters)
+ Name: IsImageReady
+ Return type: bool
+ Description: Check if an image is ready
+ Param[1]: image (type: Image)
Function 242: UnloadImage() (1 input parameters)
Name: UnloadImage
Return type: void
@@ -2398,23 +2416,16 @@ Function 245: GenImageColor() (3 input parameters)
Param[1]: width (type: int)
Param[2]: height (type: int)
Param[3]: color (type: Color)
-Function 246: GenImageGradientV() (4 input parameters)
- Name: GenImageGradientV
+Function 246: GenImageGradientLinear() (5 input parameters)
+ Name: GenImageGradientLinear
Return type: Image
- Description: Generate image: vertical gradient
+ Description: Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient
Param[1]: width (type: int)
Param[2]: height (type: int)
- Param[3]: top (type: Color)
- Param[4]: bottom (type: Color)
-Function 247: GenImageGradientH() (4 input parameters)
- Name: GenImageGradientH
- Return type: Image
- Description: Generate image: horizontal gradient
- Param[1]: width (type: int)
- Param[2]: height (type: int)
- Param[3]: left (type: Color)
- Param[4]: right (type: Color)
-Function 248: GenImageGradientRadial() (5 input parameters)
+ Param[3]: direction (type: int)
+ Param[4]: start (type: Color)
+ Param[5]: end (type: Color)
+Function 247: GenImageGradientRadial() (5 input parameters)
Name: GenImageGradientRadial
Return type: Image
Description: Generate image: radial gradient
@@ -2423,6 +2434,15 @@ Function 248: GenImageGradientRadial() (5 input parameters)
Param[3]: density (type: float)
Param[4]: inner (type: Color)
Param[5]: outer (type: Color)
+Function 248: GenImageGradientSquare() (5 input parameters)
+ Name: GenImageGradientSquare
+ Return type: Image
+ Description: Generate image: square gradient
+ Param[1]: width (type: int)
+ Param[2]: height (type: int)
+ Param[3]: density (type: float)
+ Param[4]: inner (type: Color)
+ Param[5]: outer (type: Color)
Function 249: GenImageChecked() (6 input parameters)
Name: GenImageChecked
Return type: Image
@@ -2440,32 +2460,48 @@ Function 250: GenImageWhiteNoise() (3 input parameters)
Param[1]: width (type: int)
Param[2]: height (type: int)
Param[3]: factor (type: float)
-Function 251: GenImageCellular() (3 input parameters)
+Function 251: GenImagePerlinNoise() (5 input parameters)
+ Name: GenImagePerlinNoise
+ Return type: Image
+ Description: Generate image: perlin noise
+ Param[1]: width (type: int)
+ Param[2]: height (type: int)
+ Param[3]: offsetX (type: int)
+ Param[4]: offsetY (type: int)
+ Param[5]: scale (type: float)
+Function 252: GenImageCellular() (3 input parameters)
Name: GenImageCellular
Return type: Image
Description: Generate image: cellular algorithm, bigger tileSize means bigger cells
Param[1]: width (type: int)
Param[2]: height (type: int)
Param[3]: tileSize (type: int)
-Function 252: ImageCopy() (1 input parameters)
+Function 253: GenImageText() (3 input parameters)
+ Name: GenImageText
+ Return type: Image
+ Description: Generate image: grayscale image from text data
+ Param[1]: width (type: int)
+ Param[2]: height (type: int)
+ Param[3]: text (type: const char *)
+Function 254: ImageCopy() (1 input parameters)
Name: ImageCopy
Return type: Image
Description: Create an image duplicate (useful for transformations)
Param[1]: image (type: Image)
-Function 253: ImageFromImage() (2 input parameters)
+Function 255: ImageFromImage() (2 input parameters)
Name: ImageFromImage
Return type: Image
Description: Create an image from another image piece
Param[1]: image (type: Image)
Param[2]: rec (type: Rectangle)
-Function 254: ImageText() (3 input parameters)
+Function 256: ImageText() (3 input parameters)
Name: ImageText
Return type: Image
Description: Create an image from text (default font)
Param[1]: text (type: const char *)
Param[2]: fontSize (type: int)
Param[3]: color (type: Color)
-Function 255: ImageTextEx() (5 input parameters)
+Function 257: ImageTextEx() (5 input parameters)
Name: ImageTextEx
Return type: Image
Description: Create an image from text (custom sprite font)
@@ -2474,63 +2510,69 @@ Function 255: ImageTextEx() (5 input parameters)
Param[3]: fontSize (type: float)
Param[4]: spacing (type: float)
Param[5]: tint (type: Color)
-Function 256: ImageFormat() (2 input parameters)
+Function 258: ImageFormat() (2 input parameters)
Name: ImageFormat
Return type: void
Description: Convert image data to desired format
Param[1]: image (type: Image *)
Param[2]: newFormat (type: int)
-Function 257: ImageToPOT() (2 input parameters)
+Function 259: ImageToPOT() (2 input parameters)
Name: ImageToPOT
Return type: void
Description: Convert image to POT (power-of-two)
Param[1]: image (type: Image *)
Param[2]: fill (type: Color)
-Function 258: ImageCrop() (2 input parameters)
+Function 260: ImageCrop() (2 input parameters)
Name: ImageCrop
Return type: void
Description: Crop an image to a defined rectangle
Param[1]: image (type: Image *)
Param[2]: crop (type: Rectangle)
-Function 259: ImageAlphaCrop() (2 input parameters)
+Function 261: ImageAlphaCrop() (2 input parameters)
Name: ImageAlphaCrop
Return type: void
Description: Crop image depending on alpha value
Param[1]: image (type: Image *)
Param[2]: threshold (type: float)
-Function 260: ImageAlphaClear() (3 input parameters)
+Function 262: ImageAlphaClear() (3 input parameters)
Name: ImageAlphaClear
Return type: void
Description: Clear alpha channel to desired color
Param[1]: image (type: Image *)
Param[2]: color (type: Color)
Param[3]: threshold (type: float)
-Function 261: ImageAlphaMask() (2 input parameters)
+Function 263: ImageAlphaMask() (2 input parameters)
Name: ImageAlphaMask
Return type: void
Description: Apply alpha mask to image
Param[1]: image (type: Image *)
Param[2]: alphaMask (type: Image)
-Function 262: ImageAlphaPremultiply() (1 input parameters)
+Function 264: ImageAlphaPremultiply() (1 input parameters)
Name: ImageAlphaPremultiply
Return type: void
Description: Premultiply alpha channel
Param[1]: image (type: Image *)
-Function 263: ImageResize() (3 input parameters)
+Function 265: ImageBlurGaussian() (2 input parameters)
+ Name: ImageBlurGaussian
+ Return type: void
+ Description: Apply Gaussian blur using a box blur approximation
+ Param[1]: image (type: Image *)
+ Param[2]: blurSize (type: int)
+Function 266: ImageResize() (3 input parameters)
Name: ImageResize
Return type: void
Description: Resize image (Bicubic scaling algorithm)
Param[1]: image (type: Image *)
Param[2]: newWidth (type: int)
Param[3]: newHeight (type: int)
-Function 264: ImageResizeNN() (3 input parameters)
+Function 267: ImageResizeNN() (3 input parameters)
Name: ImageResizeNN
Return type: void
Description: Resize image (Nearest-Neighbor scaling algorithm)
Param[1]: image (type: Image *)
Param[2]: newWidth (type: int)
Param[3]: newHeight (type: int)
-Function 265: ImageResizeCanvas() (6 input parameters)
+Function 268: ImageResizeCanvas() (6 input parameters)
Name: ImageResizeCanvas
Return type: void
Description: Resize canvas and fill with color
@@ -2540,12 +2582,12 @@ Function 265: ImageResizeCanvas() (6 input parameters)
Param[4]: offsetX (type: int)
Param[5]: offsetY (type: int)
Param[6]: fill (type: Color)
-Function 266: ImageMipmaps() (1 input parameters)
+Function 269: ImageMipmaps() (1 input parameters)
Name: ImageMipmaps
Return type: void
Description: Compute all mipmap levels for a provided image
Param[1]: image (type: Image *)
-Function 267: ImageDither() (5 input parameters)
+Function 270: ImageDither() (5 input parameters)
Name: ImageDither
Return type: void
Description: Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
@@ -2554,103 +2596,109 @@ Function 267: ImageDither() (5 input parameters)
Param[3]: gBpp (type: int)
Param[4]: bBpp (type: int)
Param[5]: aBpp (type: int)
-Function 268: ImageFlipVertical() (1 input parameters)
+Function 271: ImageFlipVertical() (1 input parameters)
Name: ImageFlipVertical
Return type: void
Description: Flip image vertically
Param[1]: image (type: Image *)
-Function 269: ImageFlipHorizontal() (1 input parameters)
+Function 272: ImageFlipHorizontal() (1 input parameters)
Name: ImageFlipHorizontal
Return type: void
Description: Flip image horizontally
Param[1]: image (type: Image *)
-Function 270: ImageRotateCW() (1 input parameters)
+Function 273: ImageRotate() (2 input parameters)
+ Name: ImageRotate
+ Return type: void
+ Description: Rotate image by input angle in degrees (-359 to 359)
+ Param[1]: image (type: Image *)
+ Param[2]: degrees (type: int)
+Function 274: ImageRotateCW() (1 input parameters)
Name: ImageRotateCW
Return type: void
Description: Rotate image clockwise 90deg
Param[1]: image (type: Image *)
-Function 271: ImageRotateCCW() (1 input parameters)
+Function 275: ImageRotateCCW() (1 input parameters)
Name: ImageRotateCCW
Return type: void
Description: Rotate image counter-clockwise 90deg
Param[1]: image (type: Image *)
-Function 272: ImageColorTint() (2 input parameters)
+Function 276: ImageColorTint() (2 input parameters)
Name: ImageColorTint
Return type: void
Description: Modify image color: tint
Param[1]: image (type: Image *)
Param[2]: color (type: Color)
-Function 273: ImageColorInvert() (1 input parameters)
+Function 277: ImageColorInvert() (1 input parameters)
Name: ImageColorInvert
Return type: void
Description: Modify image color: invert
Param[1]: image (type: Image *)
-Function 274: ImageColorGrayscale() (1 input parameters)
+Function 278: ImageColorGrayscale() (1 input parameters)
Name: ImageColorGrayscale
Return type: void
Description: Modify image color: grayscale
Param[1]: image (type: Image *)
-Function 275: ImageColorContrast() (2 input parameters)
+Function 279: ImageColorContrast() (2 input parameters)
Name: ImageColorContrast
Return type: void
Description: Modify image color: contrast (-100 to 100)
Param[1]: image (type: Image *)
Param[2]: contrast (type: float)
-Function 276: ImageColorBrightness() (2 input parameters)
+Function 280: ImageColorBrightness() (2 input parameters)
Name: ImageColorBrightness
Return type: void
Description: Modify image color: brightness (-255 to 255)
Param[1]: image (type: Image *)
Param[2]: brightness (type: int)
-Function 277: ImageColorReplace() (3 input parameters)
+Function 281: ImageColorReplace() (3 input parameters)
Name: ImageColorReplace
Return type: void
Description: Modify image color: replace color
Param[1]: image (type: Image *)
Param[2]: color (type: Color)
Param[3]: replace (type: Color)
-Function 278: LoadImageColors() (1 input parameters)
+Function 282: LoadImageColors() (1 input parameters)
Name: LoadImageColors
Return type: Color *
Description: Load color data from image as a Color array (RGBA - 32bit)
Param[1]: image (type: Image)
-Function 279: LoadImagePalette() (3 input parameters)
+Function 283: LoadImagePalette() (3 input parameters)
Name: LoadImagePalette
Return type: Color *
Description: Load colors palette from image as a Color array (RGBA - 32bit)
Param[1]: image (type: Image)
Param[2]: maxPaletteSize (type: int)
Param[3]: colorCount (type: int *)
-Function 280: UnloadImageColors() (1 input parameters)
+Function 284: UnloadImageColors() (1 input parameters)
Name: UnloadImageColors
Return type: void
Description: Unload color data loaded with LoadImageColors()
Param[1]: colors (type: Color *)
-Function 281: UnloadImagePalette() (1 input parameters)
+Function 285: UnloadImagePalette() (1 input parameters)
Name: UnloadImagePalette
Return type: void
Description: Unload colors palette loaded with LoadImagePalette()
Param[1]: colors (type: Color *)
-Function 282: GetImageAlphaBorder() (2 input parameters)
+Function 286: GetImageAlphaBorder() (2 input parameters)
Name: GetImageAlphaBorder
Return type: Rectangle
Description: Get image alpha border rectangle
Param[1]: image (type: Image)
Param[2]: threshold (type: float)
-Function 283: GetImageColor() (3 input parameters)
+Function 287: GetImageColor() (3 input parameters)
Name: GetImageColor
Return type: Color
Description: Get image pixel color at (x, y) position
Param[1]: image (type: Image)
Param[2]: x (type: int)
Param[3]: y (type: int)
-Function 284: ImageClearBackground() (2 input parameters)
+Function 288: ImageClearBackground() (2 input parameters)
Name: ImageClearBackground
Return type: void
Description: Clear image background with given color
Param[1]: dst (type: Image *)
Param[2]: color (type: Color)
-Function 285: ImageDrawPixel() (4 input parameters)
+Function 289: ImageDrawPixel() (4 input parameters)
Name: ImageDrawPixel
Return type: void
Description: Draw pixel within an image
@@ -2658,14 +2706,14 @@ Function 285: ImageDrawPixel() (4 input parameters)
Param[2]: posX (type: int)
Param[3]: posY (type: int)
Param[4]: color (type: Color)
-Function 286: ImageDrawPixelV() (3 input parameters)
+Function 290: ImageDrawPixelV() (3 input parameters)
Name: ImageDrawPixelV
Return type: void
Description: Draw pixel within an image (Vector version)
Param[1]: dst (type: Image *)
Param[2]: position (type: Vector2)
Param[3]: color (type: Color)
-Function 287: ImageDrawLine() (6 input parameters)
+Function 291: ImageDrawLine() (6 input parameters)
Name: ImageDrawLine
Return type: void
Description: Draw line within an image
@@ -2675,7 +2723,7 @@ Function 287: ImageDrawLine() (6 input parameters)
Param[4]: endPosX (type: int)
Param[5]: endPosY (type: int)
Param[6]: color (type: Color)
-Function 288: ImageDrawLineV() (4 input parameters)
+Function 292: ImageDrawLineV() (4 input parameters)
Name: ImageDrawLineV
Return type: void
Description: Draw line within an image (Vector version)
@@ -2683,24 +2731,41 @@ Function 288: ImageDrawLineV() (4 input parameters)
Param[2]: start (type: Vector2)
Param[3]: end (type: Vector2)
Param[4]: color (type: Color)
-Function 289: ImageDrawCircle() (5 input parameters)
+Function 293: ImageDrawCircle() (5 input parameters)
Name: ImageDrawCircle
Return type: void
- Description: Draw circle within an image
+ Description: Draw a filled circle within an image
Param[1]: dst (type: Image *)
Param[2]: centerX (type: int)
Param[3]: centerY (type: int)
Param[4]: radius (type: int)
Param[5]: color (type: Color)
-Function 290: ImageDrawCircleV() (4 input parameters)
+Function 294: ImageDrawCircleV() (4 input parameters)
Name: ImageDrawCircleV
Return type: void
- Description: Draw circle within an image (Vector version)
+ Description: Draw a filled circle within an image (Vector version)
Param[1]: dst (type: Image *)
Param[2]: center (type: Vector2)
Param[3]: radius (type: int)
Param[4]: color (type: Color)
-Function 291: ImageDrawRectangle() (6 input parameters)
+Function 295: ImageDrawCircleLines() (5 input parameters)
+ Name: ImageDrawCircleLines
+ Return type: void
+ Description: Draw circle outline within an image
+ Param[1]: dst (type: Image *)
+ Param[2]: centerX (type: int)
+ Param[3]: centerY (type: int)
+ Param[4]: radius (type: int)
+ Param[5]: color (type: Color)
+Function 296: ImageDrawCircleLinesV() (4 input parameters)
+ Name: ImageDrawCircleLinesV
+ Return type: void
+ Description: Draw circle outline within an image (Vector version)
+ Param[1]: dst (type: Image *)
+ Param[2]: center (type: Vector2)
+ Param[3]: radius (type: int)
+ Param[4]: color (type: Color)
+Function 297: ImageDrawRectangle() (6 input parameters)
Name: ImageDrawRectangle
Return type: void
Description: Draw rectangle within an image
@@ -2710,7 +2775,7 @@ Function 291: ImageDrawRectangle() (6 input parameters)
Param[4]: width (type: int)
Param[5]: height (type: int)
Param[6]: color (type: Color)
-Function 292: ImageDrawRectangleV() (4 input parameters)
+Function 298: ImageDrawRectangleV() (4 input parameters)
Name: ImageDrawRectangleV
Return type: void
Description: Draw rectangle within an image (Vector version)
@@ -2718,14 +2783,14 @@ Function 292: ImageDrawRectangleV() (4 input parameters)
Param[2]: position (type: Vector2)
Param[3]: size (type: Vector2)
Param[4]: color (type: Color)
-Function 293: ImageDrawRectangleRec() (3 input parameters)
+Function 299: ImageDrawRectangleRec() (3 input parameters)
Name: ImageDrawRectangleRec
Return type: void
Description: Draw rectangle within an image
Param[1]: dst (type: Image *)
Param[2]: rec (type: Rectangle)
Param[3]: color (type: Color)
-Function 294: ImageDrawRectangleLines() (4 input parameters)
+Function 300: ImageDrawRectangleLines() (4 input parameters)
Name: ImageDrawRectangleLines
Return type: void
Description: Draw rectangle lines within an image
@@ -2733,7 +2798,7 @@ Function 294: ImageDrawRectangleLines() (4 input parameters)
Param[2]: rec (type: Rectangle)
Param[3]: thick (type: int)
Param[4]: color (type: Color)
-Function 295: ImageDraw() (5 input parameters)
+Function 301: ImageDraw() (5 input parameters)
Name: ImageDraw
Return type: void
Description: Draw a source image within a destination image (tint applied to source)
@@ -2742,7 +2807,7 @@ Function 295: ImageDraw() (5 input parameters)
Param[3]: srcRec (type: Rectangle)
Param[4]: dstRec (type: Rectangle)
Param[5]: tint (type: Color)
-Function 296: ImageDrawText() (6 input parameters)
+Function 302: ImageDrawText() (6 input parameters)
Name: ImageDrawText
Return type: void
Description: Draw text (using default font) within an image (destination)
@@ -2752,7 +2817,7 @@ Function 296: ImageDrawText() (6 input parameters)
Param[4]: posY (type: int)
Param[5]: fontSize (type: int)
Param[6]: color (type: Color)
-Function 297: ImageDrawTextEx() (7 input parameters)
+Function 303: ImageDrawTextEx() (7 input parameters)
Name: ImageDrawTextEx
Return type: void
Description: Draw text (custom sprite font) within an image (destination)
@@ -2763,69 +2828,79 @@ Function 297: ImageDrawTextEx() (7 input parameters)
Param[5]: fontSize (type: float)
Param[6]: spacing (type: float)
Param[7]: tint (type: Color)
-Function 298: LoadTexture() (1 input parameters)
+Function 304: LoadTexture() (1 input parameters)
Name: LoadTexture
Return type: Texture2D
Description: Load texture from file into GPU memory (VRAM)
Param[1]: fileName (type: const char *)
-Function 299: LoadTextureFromImage() (1 input parameters)
+Function 305: LoadTextureFromImage() (1 input parameters)
Name: LoadTextureFromImage
Return type: Texture2D
Description: Load texture from image data
Param[1]: image (type: Image)
-Function 300: LoadTextureCubemap() (2 input parameters)
+Function 306: LoadTextureCubemap() (2 input parameters)
Name: LoadTextureCubemap
Return type: TextureCubemap
Description: Load cubemap from image, multiple image cubemap layouts supported
Param[1]: image (type: Image)
Param[2]: layout (type: int)
-Function 301: LoadRenderTexture() (2 input parameters)
+Function 307: LoadRenderTexture() (2 input parameters)
Name: LoadRenderTexture
Return type: RenderTexture2D
Description: Load texture for rendering (framebuffer)
Param[1]: width (type: int)
Param[2]: height (type: int)
-Function 302: UnloadTexture() (1 input parameters)
+Function 308: IsTextureReady() (1 input parameters)
+ Name: IsTextureReady
+ Return type: bool
+ Description: Check if a texture is ready
+ Param[1]: texture (type: Texture2D)
+Function 309: UnloadTexture() (1 input parameters)
Name: UnloadTexture
Return type: void
Description: Unload texture from GPU memory (VRAM)
Param[1]: texture (type: Texture2D)
-Function 303: UnloadRenderTexture() (1 input parameters)
+Function 310: IsRenderTextureReady() (1 input parameters)
+ Name: IsRenderTextureReady
+ Return type: bool
+ Description: Check if a render texture is ready
+ Param[1]: target (type: RenderTexture2D)
+Function 311: UnloadRenderTexture() (1 input parameters)
Name: UnloadRenderTexture
Return type: void
Description: Unload render texture from GPU memory (VRAM)
Param[1]: target (type: RenderTexture2D)
-Function 304: UpdateTexture() (2 input parameters)
+Function 312: UpdateTexture() (2 input parameters)
Name: UpdateTexture
Return type: void
Description: Update GPU texture with new data
Param[1]: texture (type: Texture2D)
Param[2]: pixels (type: const void *)
-Function 305: UpdateTextureRec() (3 input parameters)
+Function 313: UpdateTextureRec() (3 input parameters)
Name: UpdateTextureRec
Return type: void
Description: Update GPU texture rectangle with new data
Param[1]: texture (type: Texture2D)
Param[2]: rec (type: Rectangle)
Param[3]: pixels (type: const void *)
-Function 306: GenTextureMipmaps() (1 input parameters)
+Function 314: GenTextureMipmaps() (1 input parameters)
Name: GenTextureMipmaps
Return type: void
Description: Generate GPU mipmaps for a texture
Param[1]: texture (type: Texture2D *)
-Function 307: SetTextureFilter() (2 input parameters)
+Function 315: SetTextureFilter() (2 input parameters)
Name: SetTextureFilter
Return type: void
Description: Set texture scaling filter mode
Param[1]: texture (type: Texture2D)
Param[2]: filter (type: int)
-Function 308: SetTextureWrap() (2 input parameters)
+Function 316: SetTextureWrap() (2 input parameters)
Name: SetTextureWrap
Return type: void
Description: Set texture wrapping mode
Param[1]: texture (type: Texture2D)
Param[2]: wrap (type: int)
-Function 309: DrawTexture() (4 input parameters)
+Function 317: DrawTexture() (4 input parameters)
Name: DrawTexture
Return type: void
Description: Draw a Texture2D
@@ -2833,14 +2908,14 @@ Function 309: DrawTexture() (4 input parameters)
Param[2]: posX (type: int)
Param[3]: posY (type: int)
Param[4]: tint (type: Color)
-Function 310: DrawTextureV() (3 input parameters)
+Function 318: DrawTextureV() (3 input parameters)
Name: DrawTextureV
Return type: void
Description: Draw a Texture2D with position defined as Vector2
Param[1]: texture (type: Texture2D)
Param[2]: position (type: Vector2)
Param[3]: tint (type: Color)
-Function 311: DrawTextureEx() (5 input parameters)
+Function 319: DrawTextureEx() (5 input parameters)
Name: DrawTextureEx
Return type: void
Description: Draw a Texture2D with extended parameters
@@ -2849,7 +2924,7 @@ Function 311: DrawTextureEx() (5 input parameters)
Param[3]: rotation (type: float)
Param[4]: scale (type: float)
Param[5]: tint (type: Color)
-Function 312: DrawTextureRec() (4 input parameters)
+Function 320: DrawTextureRec() (4 input parameters)
Name: DrawTextureRec
Return type: void
Description: Draw a part of a texture defined by a rectangle
@@ -2857,27 +2932,7 @@ Function 312: DrawTextureRec() (4 input parameters)
Param[2]: source (type: Rectangle)
Param[3]: position (type: Vector2)
Param[4]: tint (type: Color)
-Function 313: DrawTextureQuad() (5 input parameters)
- Name: DrawTextureQuad
- Return type: void
- Description: Draw texture quad with tiling and offset parameters
- Param[1]: texture (type: Texture2D)
- Param[2]: tiling (type: Vector2)
- Param[3]: offset (type: Vector2)
- Param[4]: quad (type: Rectangle)
- Param[5]: tint (type: Color)
-Function 314: DrawTextureTiled() (7 input parameters)
- Name: DrawTextureTiled
- Return type: void
- Description: Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.
- Param[1]: texture (type: Texture2D)
- Param[2]: source (type: Rectangle)
- Param[3]: dest (type: Rectangle)
- Param[4]: origin (type: Vector2)
- Param[5]: rotation (type: float)
- Param[6]: scale (type: float)
- Param[7]: tint (type: Color)
-Function 315: DrawTexturePro() (6 input parameters)
+Function 321: DrawTexturePro() (6 input parameters)
Name: DrawTexturePro
Return type: void
Description: Draw a part of a texture defined by a rectangle with 'pro' parameters
@@ -2887,7 +2942,7 @@ Function 315: DrawTexturePro() (6 input parameters)
Param[4]: origin (type: Vector2)
Param[5]: rotation (type: float)
Param[6]: tint (type: Color)
-Function 316: DrawTextureNPatch() (6 input parameters)
+Function 322: DrawTextureNPatch() (6 input parameters)
Name: DrawTextureNPatch
Return type: void
Description: Draws a texture (or part of it) that stretches or shrinks nicely
@@ -2897,98 +2952,106 @@ Function 316: DrawTextureNPatch() (6 input parameters)
Param[4]: origin (type: Vector2)
Param[5]: rotation (type: float)
Param[6]: tint (type: Color)
-Function 317: DrawTexturePoly() (6 input parameters)
- Name: DrawTexturePoly
- Return type: void
- Description: Draw a textured polygon
- Param[1]: texture (type: Texture2D)
- Param[2]: center (type: Vector2)
- Param[3]: points (type: Vector2 *)
- Param[4]: texcoords (type: Vector2 *)
- Param[5]: pointCount (type: int)
- Param[6]: tint (type: Color)
-Function 318: Fade() (2 input parameters)
+Function 323: Fade() (2 input parameters)
Name: Fade
Return type: Color
Description: Get color with alpha applied, alpha goes from 0.0f to 1.0f
Param[1]: color (type: Color)
Param[2]: alpha (type: float)
-Function 319: ColorToInt() (1 input parameters)
+Function 324: ColorToInt() (1 input parameters)
Name: ColorToInt
Return type: int
Description: Get hexadecimal value for a Color
Param[1]: color (type: Color)
-Function 320: ColorNormalize() (1 input parameters)
+Function 325: ColorNormalize() (1 input parameters)
Name: ColorNormalize
Return type: Vector4
Description: Get Color normalized as float [0..1]
Param[1]: color (type: Color)
-Function 321: ColorFromNormalized() (1 input parameters)
+Function 326: ColorFromNormalized() (1 input parameters)
Name: ColorFromNormalized
Return type: Color
Description: Get Color from normalized values [0..1]
Param[1]: normalized (type: Vector4)
-Function 322: ColorToHSV() (1 input parameters)
+Function 327: ColorToHSV() (1 input parameters)
Name: ColorToHSV
Return type: Vector3
Description: Get HSV values for a Color, hue [0..360], saturation/value [0..1]
Param[1]: color (type: Color)
-Function 323: ColorFromHSV() (3 input parameters)
+Function 328: ColorFromHSV() (3 input parameters)
Name: ColorFromHSV
Return type: Color
Description: Get a Color from HSV values, hue [0..360], saturation/value [0..1]
Param[1]: hue (type: float)
Param[2]: saturation (type: float)
Param[3]: value (type: float)
-Function 324: ColorAlpha() (2 input parameters)
+Function 329: ColorTint() (2 input parameters)
+ Name: ColorTint
+ Return type: Color
+ Description: Get color multiplied with another color
+ Param[1]: color (type: Color)
+ Param[2]: tint (type: Color)
+Function 330: ColorBrightness() (2 input parameters)
+ Name: ColorBrightness
+ Return type: Color
+ Description: Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
+ Param[1]: color (type: Color)
+ Param[2]: factor (type: float)
+Function 331: ColorContrast() (2 input parameters)
+ Name: ColorContrast
+ Return type: Color
+ Description: Get color with contrast correction, contrast values between -1.0f and 1.0f
+ Param[1]: color (type: Color)
+ Param[2]: contrast (type: float)
+Function 332: ColorAlpha() (2 input parameters)
Name: ColorAlpha
Return type: Color
Description: Get color with alpha applied, alpha goes from 0.0f to 1.0f
Param[1]: color (type: Color)
Param[2]: alpha (type: float)
-Function 325: ColorAlphaBlend() (3 input parameters)
+Function 333: ColorAlphaBlend() (3 input parameters)
Name: ColorAlphaBlend
Return type: Color
Description: Get src alpha-blended into dst color with tint
Param[1]: dst (type: Color)
Param[2]: src (type: Color)
Param[3]: tint (type: Color)
-Function 326: GetColor() (1 input parameters)
+Function 334: GetColor() (1 input parameters)
Name: GetColor
Return type: Color
Description: Get Color structure from hexadecimal value
Param[1]: hexValue (type: unsigned int)
-Function 327: GetPixelColor() (2 input parameters)
+Function 335: GetPixelColor() (2 input parameters)
Name: GetPixelColor
Return type: Color
Description: Get Color from a source pixel pointer of certain format
Param[1]: srcPtr (type: void *)
Param[2]: format (type: int)
-Function 328: SetPixelColor() (3 input parameters)
+Function 336: SetPixelColor() (3 input parameters)
Name: SetPixelColor
Return type: void
Description: Set color formatted into destination pixel pointer
Param[1]: dstPtr (type: void *)
Param[2]: color (type: Color)
Param[3]: format (type: int)
-Function 329: GetPixelDataSize() (3 input parameters)
+Function 337: GetPixelDataSize() (3 input parameters)
Name: GetPixelDataSize
Return type: int
Description: Get pixel data size in bytes for certain format
Param[1]: width (type: int)
Param[2]: height (type: int)
Param[3]: format (type: int)
-Function 330: GetFontDefault() (0 input parameters)
+Function 338: GetFontDefault() (0 input parameters)
Name: GetFontDefault
Return type: Font
Description: Get the default Font
No input parameters
-Function 331: LoadFont() (1 input parameters)
+Function 339: LoadFont() (1 input parameters)
Name: LoadFont
Return type: Font
Description: Load font from file into GPU memory (VRAM)
Param[1]: fileName (type: const char *)
-Function 332: LoadFontEx() (4 input parameters)
+Function 340: LoadFontEx() (4 input parameters)
Name: LoadFontEx
Return type: Font
Description: Load font from file with extended parameters, use NULL for fontChars and 0 for glyphCount to load the default character set
@@ -2996,14 +3059,14 @@ Function 332: LoadFontEx() (4 input parameters)
Param[2]: fontSize (type: int)
Param[3]: fontChars (type: int *)
Param[4]: glyphCount (type: int)
-Function 333: LoadFontFromImage() (3 input parameters)
+Function 341: LoadFontFromImage() (3 input parameters)
Name: LoadFontFromImage
Return type: Font
Description: Load font from Image (XNA style)
Param[1]: image (type: Image)
Param[2]: key (type: Color)
Param[3]: firstChar (type: int)
-Function 334: LoadFontFromMemory() (6 input parameters)
+Function 342: LoadFontFromMemory() (6 input parameters)
Name: LoadFontFromMemory
Return type: Font
Description: Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
@@ -3013,7 +3076,12 @@ Function 334: LoadFontFromMemory() (6 input parameters)
Param[4]: fontSize (type: int)
Param[5]: fontChars (type: int *)
Param[6]: glyphCount (type: int)
-Function 335: LoadFontData() (6 input parameters)
+Function 343: IsFontReady() (1 input parameters)
+ Name: IsFontReady
+ Return type: bool
+ Description: Check if a font is ready
+ Param[1]: font (type: Font)
+Function 344: LoadFontData() (6 input parameters)
Name: LoadFontData
Return type: GlyphInfo *
Description: Load font data for further use
@@ -3023,7 +3091,7 @@ Function 335: LoadFontData() (6 input parameters)
Param[4]: fontChars (type: int *)
Param[5]: glyphCount (type: int)
Param[6]: type (type: int)
-Function 336: GenImageFontAtlas() (6 input parameters)
+Function 345: GenImageFontAtlas() (6 input parameters)
Name: GenImageFontAtlas
Return type: Image
Description: Generate image font atlas using chars info
@@ -3033,30 +3101,30 @@ Function 336: GenImageFontAtlas() (6 input parameters)
Param[4]: fontSize (type: int)
Param[5]: padding (type: int)
Param[6]: packMethod (type: int)
-Function 337: UnloadFontData() (2 input parameters)
+Function 346: UnloadFontData() (2 input parameters)
Name: UnloadFontData
Return type: void
Description: Unload font chars info data (RAM)
Param[1]: chars (type: GlyphInfo *)
Param[2]: glyphCount (type: int)
-Function 338: UnloadFont() (1 input parameters)
+Function 347: UnloadFont() (1 input parameters)
Name: UnloadFont
Return type: void
Description: Unload font from GPU memory (VRAM)
Param[1]: font (type: Font)
-Function 339: ExportFontAsCode() (2 input parameters)
+Function 348: ExportFontAsCode() (2 input parameters)
Name: ExportFontAsCode
Return type: bool
Description: Export font as code file, returns true on success
Param[1]: font (type: Font)
Param[2]: fileName (type: const char *)
-Function 340: DrawFPS() (2 input parameters)
+Function 349: DrawFPS() (2 input parameters)
Name: DrawFPS
Return type: void
Description: Draw current FPS
Param[1]: posX (type: int)
Param[2]: posY (type: int)
-Function 341: DrawText() (5 input parameters)
+Function 350: DrawText() (5 input parameters)
Name: DrawText
Return type: void
Description: Draw text (using default font)
@@ -3065,7 +3133,7 @@ Function 341: DrawText() (5 input parameters)
Param[3]: posY (type: int)
Param[4]: fontSize (type: int)
Param[5]: color (type: Color)
-Function 342: DrawTextEx() (6 input parameters)
+Function 351: DrawTextEx() (6 input parameters)
Name: DrawTextEx
Return type: void
Description: Draw text using font and additional parameters
@@ -3075,7 +3143,7 @@ Function 342: DrawTextEx() (6 input parameters)
Param[4]: fontSize (type: float)
Param[5]: spacing (type: float)
Param[6]: tint (type: Color)
-Function 343: DrawTextPro() (8 input parameters)
+Function 352: DrawTextPro() (8 input parameters)
Name: DrawTextPro
Return type: void
Description: Draw text using Font and pro parameters (rotation)
@@ -3087,7 +3155,7 @@ Function 343: DrawTextPro() (8 input parameters)
Param[6]: fontSize (type: float)
Param[7]: spacing (type: float)
Param[8]: tint (type: Color)
-Function 344: DrawTextCodepoint() (5 input parameters)
+Function 353: DrawTextCodepoint() (5 input parameters)
Name: DrawTextCodepoint
Return type: void
Description: Draw one character (codepoint)
@@ -3096,7 +3164,7 @@ Function 344: DrawTextCodepoint() (5 input parameters)
Param[3]: position (type: Vector2)
Param[4]: fontSize (type: float)
Param[5]: tint (type: Color)
-Function 345: DrawTextCodepoints() (7 input parameters)
+Function 354: DrawTextCodepoints() (7 input parameters)
Name: DrawTextCodepoints
Return type: void
Description: Draw multiple character (codepoint)
@@ -3107,13 +3175,13 @@ Function 345: DrawTextCodepoints() (7 input parameters)
Param[5]: fontSize (type: float)
Param[6]: spacing (type: float)
Param[7]: tint (type: Color)
-Function 346: MeasureText() (2 input parameters)
+Function 355: MeasureText() (2 input parameters)
Name: MeasureText
Return type: int
Description: Measure string width for default font
Param[1]: text (type: const char *)
Param[2]: fontSize (type: int)
-Function 347: MeasureTextEx() (4 input parameters)
+Function 356: MeasureTextEx() (4 input parameters)
Name: MeasureTextEx
Return type: Vector2
Description: Measure string size for Font
@@ -3121,163 +3189,180 @@ Function 347: MeasureTextEx() (4 input parameters)
Param[2]: text (type: const char *)
Param[3]: fontSize (type: float)
Param[4]: spacing (type: float)
-Function 348: GetGlyphIndex() (2 input parameters)
+Function 357: GetGlyphIndex() (2 input parameters)
Name: GetGlyphIndex
Return type: int
Description: Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found
Param[1]: font (type: Font)
Param[2]: codepoint (type: int)
-Function 349: GetGlyphInfo() (2 input parameters)
+Function 358: GetGlyphInfo() (2 input parameters)
Name: GetGlyphInfo
Return type: GlyphInfo
Description: Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found
Param[1]: font (type: Font)
Param[2]: codepoint (type: int)
-Function 350: GetGlyphAtlasRec() (2 input parameters)
+Function 359: GetGlyphAtlasRec() (2 input parameters)
Name: GetGlyphAtlasRec
Return type: Rectangle
Description: Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found
Param[1]: font (type: Font)
Param[2]: codepoint (type: int)
-Function 351: LoadCodepoints() (2 input parameters)
+Function 360: LoadUTF8() (2 input parameters)
+ Name: LoadUTF8
+ Return type: char *
+ Description: Load UTF-8 text encoded from codepoints array
+ Param[1]: codepoints (type: const int *)
+ Param[2]: length (type: int)
+Function 361: UnloadUTF8() (1 input parameters)
+ Name: UnloadUTF8
+ Return type: void
+ Description: Unload UTF-8 text encoded from codepoints array
+ Param[1]: text (type: char *)
+Function 362: LoadCodepoints() (2 input parameters)
Name: LoadCodepoints
Return type: int *
Description: Load all codepoints from a UTF-8 text string, codepoints count returned by parameter
Param[1]: text (type: const char *)
Param[2]: count (type: int *)
-Function 352: UnloadCodepoints() (1 input parameters)
+Function 363: UnloadCodepoints() (1 input parameters)
Name: UnloadCodepoints
Return type: void
Description: Unload codepoints data from memory
Param[1]: codepoints (type: int *)
-Function 353: GetCodepointCount() (1 input parameters)
+Function 364: GetCodepointCount() (1 input parameters)
Name: GetCodepointCount
Return type: int
Description: Get total number of codepoints in a UTF-8 encoded string
Param[1]: text (type: const char *)
-Function 354: GetCodepoint() (2 input parameters)
+Function 365: GetCodepoint() (2 input parameters)
Name: GetCodepoint
Return type: int
Description: Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
Param[1]: text (type: const char *)
- Param[2]: bytesProcessed (type: int *)
-Function 355: CodepointToUTF8() (2 input parameters)
+ Param[2]: codepointSize (type: int *)
+Function 366: GetCodepointNext() (2 input parameters)
+ Name: GetCodepointNext
+ Return type: int
+ Description: Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
+ Param[1]: text (type: const char *)
+ Param[2]: codepointSize (type: int *)
+Function 367: GetCodepointPrevious() (2 input parameters)
+ Name: GetCodepointPrevious
+ Return type: int
+ Description: Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
+ Param[1]: text (type: const char *)
+ Param[2]: codepointSize (type: int *)
+Function 368: CodepointToUTF8() (2 input parameters)
Name: CodepointToUTF8
Return type: const char *
Description: Encode one codepoint into UTF-8 byte array (array length returned as parameter)
Param[1]: codepoint (type: int)
- Param[2]: byteSize (type: int *)
-Function 356: TextCodepointsToUTF8() (2 input parameters)
- Name: TextCodepointsToUTF8
- Return type: char *
- Description: Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!)
- Param[1]: codepoints (type: const int *)
- Param[2]: length (type: int)
-Function 357: TextCopy() (2 input parameters)
+ Param[2]: utf8Size (type: int *)
+Function 369: TextCopy() (2 input parameters)
Name: TextCopy
Return type: int
Description: Copy one string to another, returns bytes copied
Param[1]: dst (type: char *)
Param[2]: src (type: const char *)
-Function 358: TextIsEqual() (2 input parameters)
+Function 370: TextIsEqual() (2 input parameters)
Name: TextIsEqual
Return type: bool
Description: Check if two text string are equal
Param[1]: text1 (type: const char *)
Param[2]: text2 (type: const char *)
-Function 359: TextLength() (1 input parameters)
+Function 371: TextLength() (1 input parameters)
Name: TextLength
Return type: unsigned int
Description: Get text length, checks for '\0' ending
Param[1]: text (type: const char *)
-Function 360: TextFormat() (2 input parameters)
+Function 372: TextFormat() (2 input parameters)
Name: TextFormat
Return type: const char *
Description: Text formatting with variables (sprintf() style)
Param[1]: text (type: const char *)
Param[2]: args (type: ...)
-Function 361: TextSubtext() (3 input parameters)
+Function 373: TextSubtext() (3 input parameters)
Name: TextSubtext
Return type: const char *
Description: Get a piece of a text string
Param[1]: text (type: const char *)
Param[2]: position (type: int)
Param[3]: length (type: int)
-Function 362: TextReplace() (3 input parameters)
+Function 374: TextReplace() (3 input parameters)
Name: TextReplace
Return type: char *
Description: Replace text string (WARNING: memory must be freed!)
Param[1]: text (type: char *)
Param[2]: replace (type: const char *)
Param[3]: by (type: const char *)
-Function 363: TextInsert() (3 input parameters)
+Function 375: TextInsert() (3 input parameters)
Name: TextInsert
Return type: char *
Description: Insert text in a position (WARNING: memory must be freed!)
Param[1]: text (type: const char *)
Param[2]: insert (type: const char *)
Param[3]: position (type: int)
-Function 364: TextJoin() (3 input parameters)
+Function 376: TextJoin() (3 input parameters)
Name: TextJoin
Return type: const char *
Description: Join text strings with delimiter
Param[1]: textList (type: const char **)
Param[2]: count (type: int)
Param[3]: delimiter (type: const char *)
-Function 365: TextSplit() (3 input parameters)
+Function 377: TextSplit() (3 input parameters)
Name: TextSplit
Return type: const char **
Description: Split text into multiple strings
Param[1]: text (type: const char *)
Param[2]: delimiter (type: char)
Param[3]: count (type: int *)
-Function 366: TextAppend() (3 input parameters)
+Function 378: TextAppend() (3 input parameters)
Name: TextAppend
Return type: void
Description: Append text at specific position and move cursor!
Param[1]: text (type: char *)
Param[2]: append (type: const char *)
Param[3]: position (type: int *)
-Function 367: TextFindIndex() (2 input parameters)
+Function 379: TextFindIndex() (2 input parameters)
Name: TextFindIndex
Return type: int
Description: Find first text occurrence within a string
Param[1]: text (type: const char *)
Param[2]: find (type: const char *)
-Function 368: TextToUpper() (1 input parameters)
+Function 380: TextToUpper() (1 input parameters)
Name: TextToUpper
Return type: const char *
Description: Get upper case version of provided string
Param[1]: text (type: const char *)
-Function 369: TextToLower() (1 input parameters)
+Function 381: TextToLower() (1 input parameters)
Name: TextToLower
Return type: const char *
Description: Get lower case version of provided string
Param[1]: text (type: const char *)
-Function 370: TextToPascal() (1 input parameters)
+Function 382: TextToPascal() (1 input parameters)
Name: TextToPascal
Return type: const char *
Description: Get Pascal case notation version of provided string
Param[1]: text (type: const char *)
-Function 371: TextToInteger() (1 input parameters)
+Function 383: TextToInteger() (1 input parameters)
Name: TextToInteger
Return type: int
Description: Get integer value from text (negative values not supported)
Param[1]: text (type: const char *)
-Function 372: DrawLine3D() (3 input parameters)
+Function 384: DrawLine3D() (3 input parameters)
Name: DrawLine3D
Return type: void
Description: Draw a line in 3D world space
Param[1]: startPos (type: Vector3)
Param[2]: endPos (type: Vector3)
Param[3]: color (type: Color)
-Function 373: DrawPoint3D() (2 input parameters)
+Function 385: DrawPoint3D() (2 input parameters)
Name: DrawPoint3D
Return type: void
Description: Draw a point in 3D space, actually a small line
Param[1]: position (type: Vector3)
Param[2]: color (type: Color)
-Function 374: DrawCircle3D() (5 input parameters)
+Function 386: DrawCircle3D() (5 input parameters)
Name: DrawCircle3D
Return type: void
Description: Draw a circle in 3D world space
@@ -3286,7 +3371,7 @@ Function 374: DrawCircle3D() (5 input parameters)
Param[3]: rotationAxis (type: Vector3)
Param[4]: rotationAngle (type: float)
Param[5]: color (type: Color)
-Function 375: DrawTriangle3D() (4 input parameters)
+Function 387: DrawTriangle3D() (4 input parameters)
Name: DrawTriangle3D
Return type: void
Description: Draw a color-filled triangle (vertex in counter-clockwise order!)
@@ -3294,14 +3379,14 @@ Function 375: DrawTriangle3D() (4 input parameters)
Param[2]: v2 (type: Vector3)
Param[3]: v3 (type: Vector3)
Param[4]: color (type: Color)
-Function 376: DrawTriangleStrip3D() (3 input parameters)
+Function 388: DrawTriangleStrip3D() (3 input parameters)
Name: DrawTriangleStrip3D
Return type: void
Description: Draw a triangle strip defined by points
Param[1]: points (type: Vector3 *)
Param[2]: pointCount (type: int)
Param[3]: color (type: Color)
-Function 377: DrawCube() (5 input parameters)
+Function 389: DrawCube() (5 input parameters)
Name: DrawCube
Return type: void
Description: Draw cube
@@ -3310,14 +3395,14 @@ Function 377: DrawCube() (5 input parameters)
Param[3]: height (type: float)
Param[4]: length (type: float)
Param[5]: color (type: Color)
-Function 378: DrawCubeV() (3 input parameters)
+Function 390: DrawCubeV() (3 input parameters)
Name: DrawCubeV
Return type: void
Description: Draw cube (Vector version)
Param[1]: position (type: Vector3)
Param[2]: size (type: Vector3)
Param[3]: color (type: Color)
-Function 379: DrawCubeWires() (5 input parameters)
+Function 391: DrawCubeWires() (5 input parameters)
Name: DrawCubeWires
Return type: void
Description: Draw cube wires
@@ -3326,42 +3411,21 @@ Function 379: DrawCubeWires() (5 input parameters)
Param[3]: height (type: float)
Param[4]: length (type: float)
Param[5]: color (type: Color)
-Function 380: DrawCubeWiresV() (3 input parameters)
+Function 392: DrawCubeWiresV() (3 input parameters)
Name: DrawCubeWiresV
Return type: void
Description: Draw cube wires (Vector version)
Param[1]: position (type: Vector3)
Param[2]: size (type: Vector3)
Param[3]: color (type: Color)
-Function 381: DrawCubeTexture() (6 input parameters)
- Name: DrawCubeTexture
- Return type: void
- Description: Draw cube textured
- Param[1]: texture (type: Texture2D)
- Param[2]: position (type: Vector3)
- Param[3]: width (type: float)
- Param[4]: height (type: float)
- Param[5]: length (type: float)
- Param[6]: color (type: Color)
-Function 382: DrawCubeTextureRec() (7 input parameters)
- Name: DrawCubeTextureRec
- Return type: void
- Description: Draw cube with a region of a texture
- Param[1]: texture (type: Texture2D)
- Param[2]: source (type: Rectangle)
- Param[3]: position (type: Vector3)
- Param[4]: width (type: float)
- Param[5]: height (type: float)
- Param[6]: length (type: float)
- Param[7]: color (type: Color)
-Function 383: DrawSphere() (3 input parameters)
+Function 393: DrawSphere() (3 input parameters)
Name: DrawSphere
Return type: void
Description: Draw sphere
Param[1]: centerPos (type: Vector3)
Param[2]: radius (type: float)
Param[3]: color (type: Color)
-Function 384: DrawSphereEx() (5 input parameters)
+Function 394: DrawSphereEx() (5 input parameters)
Name: DrawSphereEx
Return type: void
Description: Draw sphere with extended parameters
@@ -3370,7 +3434,7 @@ Function 384: DrawSphereEx() (5 input parameters)
Param[3]: rings (type: int)
Param[4]: slices (type: int)
Param[5]: color (type: Color)
-Function 385: DrawSphereWires() (5 input parameters)
+Function 395: DrawSphereWires() (5 input parameters)
Name: DrawSphereWires
Return type: void
Description: Draw sphere wires
@@ -3379,7 +3443,7 @@ Function 385: DrawSphereWires() (5 input parameters)
Param[3]: rings (type: int)
Param[4]: slices (type: int)
Param[5]: color (type: Color)
-Function 386: DrawCylinder() (6 input parameters)
+Function 396: DrawCylinder() (6 input parameters)
Name: DrawCylinder
Return type: void
Description: Draw a cylinder/cone
@@ -3389,7 +3453,7 @@ Function 386: DrawCylinder() (6 input parameters)
Param[4]: height (type: float)
Param[5]: slices (type: int)
Param[6]: color (type: Color)
-Function 387: DrawCylinderEx() (6 input parameters)
+Function 397: DrawCylinderEx() (6 input parameters)
Name: DrawCylinderEx
Return type: void
Description: Draw a cylinder with base at startPos and top at endPos
@@ -3399,7 +3463,7 @@ Function 387: DrawCylinderEx() (6 input parameters)
Param[4]: endRadius (type: float)
Param[5]: sides (type: int)
Param[6]: color (type: Color)
-Function 388: DrawCylinderWires() (6 input parameters)
+Function 398: DrawCylinderWires() (6 input parameters)
Name: DrawCylinderWires
Return type: void
Description: Draw a cylinder/cone wires
@@ -3409,7 +3473,7 @@ Function 388: DrawCylinderWires() (6 input parameters)
Param[4]: height (type: float)
Param[5]: slices (type: int)
Param[6]: color (type: Color)
-Function 389: DrawCylinderWiresEx() (6 input parameters)
+Function 399: DrawCylinderWiresEx() (6 input parameters)
Name: DrawCylinderWiresEx
Return type: void
Description: Draw a cylinder wires with base at startPos and top at endPos
@@ -3419,51 +3483,71 @@ Function 389: DrawCylinderWiresEx() (6 input parameters)
Param[4]: endRadius (type: float)
Param[5]: sides (type: int)
Param[6]: color (type: Color)
-Function 390: DrawPlane() (3 input parameters)
+Function 400: DrawCapsule() (6 input parameters)
+ Name: DrawCapsule
+ Return type: void
+ Description: Draw a capsule with the center of its sphere caps at startPos and endPos
+ Param[1]: startPos (type: Vector3)
+ Param[2]: endPos (type: Vector3)
+ Param[3]: radius (type: float)
+ Param[4]: slices (type: int)
+ Param[5]: rings (type: int)
+ Param[6]: color (type: Color)
+Function 401: DrawCapsuleWires() (6 input parameters)
+ Name: DrawCapsuleWires
+ Return type: void
+ Description: Draw capsule wireframe with the center of its sphere caps at startPos and endPos
+ Param[1]: startPos (type: Vector3)
+ Param[2]: endPos (type: Vector3)
+ Param[3]: radius (type: float)
+ Param[4]: slices (type: int)
+ Param[5]: rings (type: int)
+ Param[6]: color (type: Color)
+Function 402: DrawPlane() (3 input parameters)
Name: DrawPlane
Return type: void
Description: Draw a plane XZ
Param[1]: centerPos (type: Vector3)
Param[2]: size (type: Vector2)
Param[3]: color (type: Color)
-Function 391: DrawRay() (2 input parameters)
+Function 403: DrawRay() (2 input parameters)
Name: DrawRay
Return type: void
Description: Draw a ray line
Param[1]: ray (type: Ray)
Param[2]: color (type: Color)
-Function 392: DrawGrid() (2 input parameters)
+Function 404: DrawGrid() (2 input parameters)
Name: DrawGrid
Return type: void
Description: Draw a grid (centered at (0, 0, 0))
Param[1]: slices (type: int)
Param[2]: spacing (type: float)
-Function 393: LoadModel() (1 input parameters)
+Function 405: LoadModel() (1 input parameters)
Name: LoadModel
Return type: Model
Description: Load model from files (meshes and materials)
Param[1]: fileName (type: const char *)
-Function 394: LoadModelFromMesh() (1 input parameters)
+Function 406: LoadModelFromMesh() (1 input parameters)
Name: LoadModelFromMesh
Return type: Model
Description: Load model from generated mesh (default material)
Param[1]: mesh (type: Mesh)
-Function 395: UnloadModel() (1 input parameters)
+Function 407: IsModelReady() (1 input parameters)
+ Name: IsModelReady
+ Return type: bool
+ Description: Check if a model is ready
+ Param[1]: model (type: Model)
+Function 408: UnloadModel() (1 input parameters)
Name: UnloadModel
Return type: void
Description: Unload model (including meshes) from memory (RAM and/or VRAM)
Param[1]: model (type: Model)
-Function 396: UnloadModelKeepMeshes() (1 input parameters)
- Name: UnloadModelKeepMeshes
- Return type: void
- Description: Unload model (but not meshes) from memory (RAM and/or VRAM)
- Param[1]: model (type: Model)
-Function 397: GetModelBoundingBox() (1 input parameters)
+Function 409: GetModelBoundingBox() (1 input parameters)
Name: GetModelBoundingBox
Return type: BoundingBox
Description: Compute model bounding box limits (considers all meshes)
Param[1]: model (type: Model)
-Function 398: DrawModel() (4 input parameters)
+Function 410: DrawModel() (4 input parameters)
Name: DrawModel
Return type: void
Description: Draw a model (with texture if set)
@@ -3471,7 +3555,7 @@ Function 398: DrawModel() (4 input parameters)
Param[2]: position (type: Vector3)
Param[3]: scale (type: float)
Param[4]: tint (type: Color)
-Function 399: DrawModelEx() (6 input parameters)
+Function 411: DrawModelEx() (6 input parameters)
Name: DrawModelEx
Return type: void
Description: Draw a model with extended parameters
@@ -3481,7 +3565,7 @@ Function 399: DrawModelEx() (6 input parameters)
Param[4]: rotationAngle (type: float)
Param[5]: scale (type: Vector3)
Param[6]: tint (type: Color)
-Function 400: DrawModelWires() (4 input parameters)
+Function 412: DrawModelWires() (4 input parameters)
Name: DrawModelWires
Return type: void
Description: Draw a model wires (with texture if set)
@@ -3489,7 +3573,7 @@ Function 400: DrawModelWires() (4 input parameters)
Param[2]: position (type: Vector3)
Param[3]: scale (type: float)
Param[4]: tint (type: Color)
-Function 401: DrawModelWiresEx() (6 input parameters)
+Function 413: DrawModelWiresEx() (6 input parameters)
Name: DrawModelWiresEx
Return type: void
Description: Draw a model wires (with texture if set) with extended parameters
@@ -3499,13 +3583,13 @@ Function 401: DrawModelWiresEx() (6 input parameters)
Param[4]: rotationAngle (type: float)
Param[5]: scale (type: Vector3)
Param[6]: tint (type: Color)
-Function 402: DrawBoundingBox() (2 input parameters)
+Function 414: DrawBoundingBox() (2 input parameters)
Name: DrawBoundingBox
Return type: void
Description: Draw bounding box (wires)
Param[1]: box (type: BoundingBox)
Param[2]: color (type: Color)
-Function 403: DrawBillboard() (5 input parameters)
+Function 415: DrawBillboard() (5 input parameters)
Name: DrawBillboard
Return type: void
Description: Draw a billboard texture
@@ -3514,7 +3598,7 @@ Function 403: DrawBillboard() (5 input parameters)
Param[3]: position (type: Vector3)
Param[4]: size (type: float)
Param[5]: tint (type: Color)
-Function 404: DrawBillboardRec() (6 input parameters)
+Function 416: DrawBillboardRec() (6 input parameters)
Name: DrawBillboardRec
Return type: void
Description: Draw a billboard texture defined by source
@@ -3524,7 +3608,7 @@ Function 404: DrawBillboardRec() (6 input parameters)
Param[4]: position (type: Vector3)
Param[5]: size (type: Vector2)
Param[6]: tint (type: Color)
-Function 405: DrawBillboardPro() (9 input parameters)
+Function 417: DrawBillboardPro() (9 input parameters)
Name: DrawBillboardPro
Return type: void
Description: Draw a billboard texture defined by source and rotation
@@ -3537,13 +3621,13 @@ Function 405: DrawBillboardPro() (9 input parameters)
Param[7]: origin (type: Vector2)
Param[8]: rotation (type: float)
Param[9]: tint (type: Color)
-Function 406: UploadMesh() (2 input parameters)
+Function 418: UploadMesh() (2 input parameters)
Name: UploadMesh
Return type: void
Description: Upload mesh vertex data in GPU and provide VAO/VBO ids
Param[1]: mesh (type: Mesh *)
Param[2]: dynamic (type: bool)
-Function 407: UpdateMeshBuffer() (5 input parameters)
+Function 419: UpdateMeshBuffer() (5 input parameters)
Name: UpdateMeshBuffer
Return type: void
Description: Update mesh vertex data in GPU for a specific buffer index
@@ -3552,19 +3636,19 @@ Function 407: UpdateMeshBuffer() (5 input parameters)
Param[3]: data (type: const void *)
Param[4]: dataSize (type: int)
Param[5]: offset (type: int)
-Function 408: UnloadMesh() (1 input parameters)
+Function 420: UnloadMesh() (1 input parameters)
Name: UnloadMesh
Return type: void
Description: Unload mesh data from CPU and GPU
Param[1]: mesh (type: Mesh)
-Function 409: DrawMesh() (3 input parameters)
+Function 421: DrawMesh() (3 input parameters)
Name: DrawMesh
Return type: void
Description: Draw a 3d mesh with material and transform
Param[1]: mesh (type: Mesh)
Param[2]: material (type: Material)
Param[3]: transform (type: Matrix)
-Function 410: DrawMeshInstanced() (4 input parameters)
+Function 422: DrawMeshInstanced() (4 input parameters)
Name: DrawMeshInstanced
Return type: void
Description: Draw multiple mesh instances with material and different transforms
@@ -3572,29 +3656,29 @@ Function 410: DrawMeshInstanced() (4 input parameters)
Param[2]: material (type: Material)
Param[3]: transforms (type: const Matrix *)
Param[4]: instances (type: int)
-Function 411: ExportMesh() (2 input parameters)
+Function 423: ExportMesh() (2 input parameters)
Name: ExportMesh
Return type: bool
Description: Export mesh data to file, returns true on success
Param[1]: mesh (type: Mesh)
Param[2]: fileName (type: const char *)
-Function 412: GetMeshBoundingBox() (1 input parameters)
+Function 424: GetMeshBoundingBox() (1 input parameters)
Name: GetMeshBoundingBox
Return type: BoundingBox
Description: Compute mesh bounding box limits
Param[1]: mesh (type: Mesh)
-Function 413: GenMeshTangents() (1 input parameters)
+Function 425: GenMeshTangents() (1 input parameters)
Name: GenMeshTangents
Return type: void
Description: Compute mesh tangents
Param[1]: mesh (type: Mesh *)
-Function 414: GenMeshPoly() (2 input parameters)
+Function 426: GenMeshPoly() (2 input parameters)
Name: GenMeshPoly
Return type: Mesh
Description: Generate polygonal mesh
Param[1]: sides (type: int)
Param[2]: radius (type: float)
-Function 415: GenMeshPlane() (4 input parameters)
+Function 427: GenMeshPlane() (4 input parameters)
Name: GenMeshPlane
Return type: Mesh
Description: Generate plane mesh (with subdivisions)
@@ -3602,42 +3686,42 @@ Function 415: GenMeshPlane() (4 input parameters)
Param[2]: length (type: float)
Param[3]: resX (type: int)
Param[4]: resZ (type: int)
-Function 416: GenMeshCube() (3 input parameters)
+Function 428: GenMeshCube() (3 input parameters)
Name: GenMeshCube
Return type: Mesh
Description: Generate cuboid mesh
Param[1]: width (type: float)
Param[2]: height (type: float)
Param[3]: length (type: float)
-Function 417: GenMeshSphere() (3 input parameters)
+Function 429: GenMeshSphere() (3 input parameters)
Name: GenMeshSphere
Return type: Mesh
Description: Generate sphere mesh (standard sphere)
Param[1]: radius (type: float)
Param[2]: rings (type: int)
Param[3]: slices (type: int)
-Function 418: GenMeshHemiSphere() (3 input parameters)
+Function 430: GenMeshHemiSphere() (3 input parameters)
Name: GenMeshHemiSphere
Return type: Mesh
Description: Generate half-sphere mesh (no bottom cap)
Param[1]: radius (type: float)
Param[2]: rings (type: int)
Param[3]: slices (type: int)
-Function 419: GenMeshCylinder() (3 input parameters)
+Function 431: GenMeshCylinder() (3 input parameters)
Name: GenMeshCylinder
Return type: Mesh
Description: Generate cylinder mesh
Param[1]: radius (type: float)
Param[2]: height (type: float)
Param[3]: slices (type: int)
-Function 420: GenMeshCone() (3 input parameters)
+Function 432: GenMeshCone() (3 input parameters)
Name: GenMeshCone
Return type: Mesh
Description: Generate cone/pyramid mesh
Param[1]: radius (type: float)
Param[2]: height (type: float)
Param[3]: slices (type: int)
-Function 421: GenMeshTorus() (4 input parameters)
+Function 433: GenMeshTorus() (4 input parameters)
Name: GenMeshTorus
Return type: Mesh
Description: Generate torus mesh
@@ -3645,7 +3729,7 @@ Function 421: GenMeshTorus() (4 input parameters)
Param[2]: size (type: float)
Param[3]: radSeg (type: int)
Param[4]: sides (type: int)
-Function 422: GenMeshKnot() (4 input parameters)
+Function 434: GenMeshKnot() (4 input parameters)
Name: GenMeshKnot
Return type: Mesh
Description: Generate trefoil knot mesh
@@ -3653,79 +3737,84 @@ Function 422: GenMeshKnot() (4 input parameters)
Param[2]: size (type: float)
Param[3]: radSeg (type: int)
Param[4]: sides (type: int)
-Function 423: GenMeshHeightmap() (2 input parameters)
+Function 435: GenMeshHeightmap() (2 input parameters)
Name: GenMeshHeightmap
Return type: Mesh
Description: Generate heightmap mesh from image data
Param[1]: heightmap (type: Image)
Param[2]: size (type: Vector3)
-Function 424: GenMeshCubicmap() (2 input parameters)
+Function 436: GenMeshCubicmap() (2 input parameters)
Name: GenMeshCubicmap
Return type: Mesh
Description: Generate cubes-based map mesh from image data
Param[1]: cubicmap (type: Image)
Param[2]: cubeSize (type: Vector3)
-Function 425: LoadMaterials() (2 input parameters)
+Function 437: LoadMaterials() (2 input parameters)
Name: LoadMaterials
Return type: Material *
Description: Load materials from model file
Param[1]: fileName (type: const char *)
Param[2]: materialCount (type: int *)
-Function 426: LoadMaterialDefault() (0 input parameters)
+Function 438: LoadMaterialDefault() (0 input parameters)
Name: LoadMaterialDefault
Return type: Material
Description: Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)
No input parameters
-Function 427: UnloadMaterial() (1 input parameters)
+Function 439: IsMaterialReady() (1 input parameters)
+ Name: IsMaterialReady
+ Return type: bool
+ Description: Check if a material is ready
+ Param[1]: material (type: Material)
+Function 440: UnloadMaterial() (1 input parameters)
Name: UnloadMaterial
Return type: void
Description: Unload material from GPU memory (VRAM)
Param[1]: material (type: Material)
-Function 428: SetMaterialTexture() (3 input parameters)
+Function 441: SetMaterialTexture() (3 input parameters)
Name: SetMaterialTexture
Return type: void
Description: Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...)
Param[1]: material (type: Material *)
Param[2]: mapType (type: int)
Param[3]: texture (type: Texture2D)
-Function 429: SetModelMeshMaterial() (3 input parameters)
+Function 442: SetModelMeshMaterial() (3 input parameters)
Name: SetModelMeshMaterial
Return type: void
Description: Set material for a mesh
Param[1]: model (type: Model *)
Param[2]: meshId (type: int)
Param[3]: materialId (type: int)
-Function 430: LoadModelAnimations() (2 input parameters)
+Function 443: LoadModelAnimations() (2 input parameters)
Name: LoadModelAnimations
Return type: ModelAnimation *
Description: Load model animations from file
Param[1]: fileName (type: const char *)
Param[2]: animCount (type: unsigned int *)
-Function 431: UpdateModelAnimation() (3 input parameters)
+Function 444: UpdateModelAnimation() (3 input parameters)
Name: UpdateModelAnimation
Return type: void
Description: Update model animation pose
Param[1]: model (type: Model)
Param[2]: anim (type: ModelAnimation)
Param[3]: frame (type: int)
-Function 432: UnloadModelAnimation() (1 input parameters)
+Function 445: UnloadModelAnimation() (1 input parameters)
Name: UnloadModelAnimation
Return type: void
Description: Unload animation data
Param[1]: anim (type: ModelAnimation)
-Function 433: UnloadModelAnimations() (2 input parameters)
+Function 446: UnloadModelAnimations() (2 input parameters)
Name: UnloadModelAnimations
Return type: void
Description: Unload animation array data
Param[1]: animations (type: ModelAnimation *)
Param[2]: count (type: unsigned int)
-Function 434: IsModelAnimationValid() (2 input parameters)
+Function 447: IsModelAnimationValid() (2 input parameters)
Name: IsModelAnimationValid
Return type: bool
Description: Check model animation skeleton match
Param[1]: model (type: Model)
Param[2]: anim (type: ModelAnimation)
-Function 435: CheckCollisionSpheres() (4 input parameters)
+Function 448: CheckCollisionSpheres() (4 input parameters)
Name: CheckCollisionSpheres
Return type: bool
Description: Check collision between two spheres
@@ -3733,40 +3822,40 @@ Function 435: CheckCollisionSpheres() (4 input parameters)
Param[2]: radius1 (type: float)
Param[3]: center2 (type: Vector3)
Param[4]: radius2 (type: float)
-Function 436: CheckCollisionBoxes() (2 input parameters)
+Function 449: CheckCollisionBoxes() (2 input parameters)
Name: CheckCollisionBoxes
Return type: bool
Description: Check collision between two bounding boxes
Param[1]: box1 (type: BoundingBox)
Param[2]: box2 (type: BoundingBox)
-Function 437: CheckCollisionBoxSphere() (3 input parameters)
+Function 450: CheckCollisionBoxSphere() (3 input parameters)
Name: CheckCollisionBoxSphere
Return type: bool
Description: Check collision between box and sphere
Param[1]: box (type: BoundingBox)
Param[2]: center (type: Vector3)
Param[3]: radius (type: float)
-Function 438: GetRayCollisionSphere() (3 input parameters)
+Function 451: GetRayCollisionSphere() (3 input parameters)
Name: GetRayCollisionSphere
Return type: RayCollision
Description: Get collision info between ray and sphere
Param[1]: ray (type: Ray)
Param[2]: center (type: Vector3)
Param[3]: radius (type: float)
-Function 439: GetRayCollisionBox() (2 input parameters)
+Function 452: GetRayCollisionBox() (2 input parameters)
Name: GetRayCollisionBox
Return type: RayCollision
Description: Get collision info between ray and box
Param[1]: ray (type: Ray)
Param[2]: box (type: BoundingBox)
-Function 440: GetRayCollisionMesh() (3 input parameters)
+Function 453: GetRayCollisionMesh() (3 input parameters)
Name: GetRayCollisionMesh
Return type: RayCollision
Description: Get collision info between ray and mesh
Param[1]: ray (type: Ray)
Param[2]: mesh (type: Mesh)
Param[3]: transform (type: Matrix)
-Function 441: GetRayCollisionTriangle() (4 input parameters)
+Function 454: GetRayCollisionTriangle() (4 input parameters)
Name: GetRayCollisionTriangle
Return type: RayCollision
Description: Get collision info between ray and triangle
@@ -3774,7 +3863,7 @@ Function 441: GetRayCollisionTriangle() (4 input parameters)
Param[2]: p1 (type: Vector3)
Param[3]: p2 (type: Vector3)
Param[4]: p3 (type: Vector3)
-Function 442: GetRayCollisionQuad() (5 input parameters)
+Function 455: GetRayCollisionQuad() (5 input parameters)
Name: GetRayCollisionQuad
Return type: RayCollision
Description: Get collision info between ray and quad
@@ -3783,148 +3872,143 @@ Function 442: GetRayCollisionQuad() (5 input parameters)
Param[3]: p2 (type: Vector3)
Param[4]: p3 (type: Vector3)
Param[5]: p4 (type: Vector3)
-Function 443: InitAudioDevice() (0 input parameters)
+Function 456: InitAudioDevice() (0 input parameters)
Name: InitAudioDevice
Return type: void
Description: Initialize audio device and context
No input parameters
-Function 444: CloseAudioDevice() (0 input parameters)
+Function 457: CloseAudioDevice() (0 input parameters)
Name: CloseAudioDevice
Return type: void
Description: Close the audio device and context
No input parameters
-Function 445: IsAudioDeviceReady() (0 input parameters)
+Function 458: IsAudioDeviceReady() (0 input parameters)
Name: IsAudioDeviceReady
Return type: bool
Description: Check if audio device has been initialized successfully
No input parameters
-Function 446: SetMasterVolume() (1 input parameters)
+Function 459: SetMasterVolume() (1 input parameters)
Name: SetMasterVolume
Return type: void
Description: Set master volume (listener)
Param[1]: volume (type: float)
-Function 447: LoadWave() (1 input parameters)
+Function 460: LoadWave() (1 input parameters)
Name: LoadWave
Return type: Wave
Description: Load wave data from file
Param[1]: fileName (type: const char *)
-Function 448: LoadWaveFromMemory() (3 input parameters)
+Function 461: LoadWaveFromMemory() (3 input parameters)
Name: LoadWaveFromMemory
Return type: Wave
Description: Load wave from memory buffer, fileType refers to extension: i.e. '.wav'
Param[1]: fileType (type: const char *)
Param[2]: fileData (type: const unsigned char *)
Param[3]: dataSize (type: int)
-Function 449: LoadSound() (1 input parameters)
+Function 462: IsWaveReady() (1 input parameters)
+ Name: IsWaveReady
+ Return type: bool
+ Description: Checks if wave data is ready
+ Param[1]: wave (type: Wave)
+Function 463: LoadSound() (1 input parameters)
Name: LoadSound
Return type: Sound
Description: Load sound from file
Param[1]: fileName (type: const char *)
-Function 450: LoadSoundFromWave() (1 input parameters)
+Function 464: LoadSoundFromWave() (1 input parameters)
Name: LoadSoundFromWave
Return type: Sound
Description: Load sound from wave data
Param[1]: wave (type: Wave)
-Function 451: UpdateSound() (3 input parameters)
+Function 465: IsSoundReady() (1 input parameters)
+ Name: IsSoundReady
+ Return type: bool
+ Description: Checks if a sound is ready
+ Param[1]: sound (type: Sound)
+Function 466: UpdateSound() (3 input parameters)
Name: UpdateSound
Return type: void
Description: Update sound buffer with new data
Param[1]: sound (type: Sound)
Param[2]: data (type: const void *)
Param[3]: sampleCount (type: int)
-Function 452: UnloadWave() (1 input parameters)
+Function 467: UnloadWave() (1 input parameters)
Name: UnloadWave
Return type: void
Description: Unload wave data
Param[1]: wave (type: Wave)
-Function 453: UnloadSound() (1 input parameters)
+Function 468: UnloadSound() (1 input parameters)
Name: UnloadSound
Return type: void
Description: Unload sound
Param[1]: sound (type: Sound)
-Function 454: ExportWave() (2 input parameters)
+Function 469: ExportWave() (2 input parameters)
Name: ExportWave
Return type: bool
Description: Export wave data to file, returns true on success
Param[1]: wave (type: Wave)
Param[2]: fileName (type: const char *)
-Function 455: ExportWaveAsCode() (2 input parameters)
+Function 470: ExportWaveAsCode() (2 input parameters)
Name: ExportWaveAsCode
Return type: bool
Description: Export wave sample data to code (.h), returns true on success
Param[1]: wave (type: Wave)
Param[2]: fileName (type: const char *)
-Function 456: PlaySound() (1 input parameters)
+Function 471: PlaySound() (1 input parameters)
Name: PlaySound
Return type: void
Description: Play a sound
Param[1]: sound (type: Sound)
-Function 457: StopSound() (1 input parameters)
+Function 472: StopSound() (1 input parameters)
Name: StopSound
Return type: void
Description: Stop playing a sound
Param[1]: sound (type: Sound)
-Function 458: PauseSound() (1 input parameters)
+Function 473: PauseSound() (1 input parameters)
Name: PauseSound
Return type: void
Description: Pause a sound
Param[1]: sound (type: Sound)
-Function 459: ResumeSound() (1 input parameters)
+Function 474: ResumeSound() (1 input parameters)
Name: ResumeSound
Return type: void
Description: Resume a paused sound
Param[1]: sound (type: Sound)
-Function 460: PlaySoundMulti() (1 input parameters)
- Name: PlaySoundMulti
- Return type: void
- Description: Play a sound (using multichannel buffer pool)
- Param[1]: sound (type: Sound)
-Function 461: StopSoundMulti() (0 input parameters)
- Name: StopSoundMulti
- Return type: void
- Description: Stop any sound playing (using multichannel buffer pool)
- No input parameters
-Function 462: GetSoundsPlaying() (0 input parameters)
- Name: GetSoundsPlaying
- Return type: int
- Description: Get number of sounds playing in the multichannel
- No input parameters
-Function 463: IsSoundPlaying() (1 input parameters)
+Function 475: IsSoundPlaying() (1 input parameters)
Name: IsSoundPlaying
Return type: bool
Description: Check if a sound is currently playing
Param[1]: sound (type: Sound)
-Function 464: SetSoundVolume() (2 input parameters)
+Function 476: SetSoundVolume() (2 input parameters)
Name: SetSoundVolume
Return type: void
Description: Set volume for a sound (1.0 is max level)
Param[1]: sound (type: Sound)
Param[2]: volume (type: float)
-Function 465: SetSoundPitch() (2 input parameters)
+Function 477: SetSoundPitch() (2 input parameters)
Name: SetSoundPitch
Return type: void
Description: Set pitch for a sound (1.0 is base level)
Param[1]: sound (type: Sound)
Param[2]: pitch (type: float)
-Function 466: SetSoundPan() (2 input parameters)
+Function 478: SetSoundPan() (2 input parameters)
Name: SetSoundPan
Return type: void
Description: Set pan for a sound (0.5 is center)
Param[1]: sound (type: Sound)
Param[2]: pan (type: float)
-Function 467: WaveCopy() (1 input parameters)
+Function 479: WaveCopy() (1 input parameters)
Name: WaveCopy
Return type: Wave
Description: Copy a wave to a new wave
Param[1]: wave (type: Wave)
-Function 468: WaveCrop() (3 input parameters)
+Function 480: WaveCrop() (3 input parameters)
Name: WaveCrop
Return type: void
Description: Crop a wave to defined samples range
Param[1]: wave (type: Wave *)
Param[2]: initSample (type: int)
Param[3]: finalSample (type: int)
-Function 469: WaveFormat() (4 input parameters)
+Function 481: WaveFormat() (4 input parameters)
Name: WaveFormat
Return type: void
Description: Convert wave data to desired format
@@ -3932,184 +4016,204 @@ Function 469: WaveFormat() (4 input parameters)
Param[2]: sampleRate (type: int)
Param[3]: sampleSize (type: int)
Param[4]: channels (type: int)
-Function 470: LoadWaveSamples() (1 input parameters)
+Function 482: LoadWaveSamples() (1 input parameters)
Name: LoadWaveSamples
Return type: float *
Description: Load samples data from wave as a 32bit float data array
Param[1]: wave (type: Wave)
-Function 471: UnloadWaveSamples() (1 input parameters)
+Function 483: UnloadWaveSamples() (1 input parameters)
Name: UnloadWaveSamples
Return type: void
Description: Unload samples data loaded with LoadWaveSamples()
Param[1]: samples (type: float *)
-Function 472: LoadMusicStream() (1 input parameters)
+Function 484: LoadMusicStream() (1 input parameters)
Name: LoadMusicStream
Return type: Music
Description: Load music stream from file
Param[1]: fileName (type: const char *)
-Function 473: LoadMusicStreamFromMemory() (3 input parameters)
+Function 485: LoadMusicStreamFromMemory() (3 input parameters)
Name: LoadMusicStreamFromMemory
Return type: Music
Description: Load music stream from data
Param[1]: fileType (type: const char *)
Param[2]: data (type: const unsigned char *)
Param[3]: dataSize (type: int)
-Function 474: UnloadMusicStream() (1 input parameters)
+Function 486: IsMusicReady() (1 input parameters)
+ Name: IsMusicReady
+ Return type: bool
+ Description: Checks if a music stream is ready
+ Param[1]: music (type: Music)
+Function 487: UnloadMusicStream() (1 input parameters)
Name: UnloadMusicStream
Return type: void
Description: Unload music stream
Param[1]: music (type: Music)
-Function 475: PlayMusicStream() (1 input parameters)
+Function 488: PlayMusicStream() (1 input parameters)
Name: PlayMusicStream
Return type: void
Description: Start music playing
Param[1]: music (type: Music)
-Function 476: IsMusicStreamPlaying() (1 input parameters)
+Function 489: IsMusicStreamPlaying() (1 input parameters)
Name: IsMusicStreamPlaying
Return type: bool
Description: Check if music is playing
Param[1]: music (type: Music)
-Function 477: UpdateMusicStream() (1 input parameters)
+Function 490: UpdateMusicStream() (1 input parameters)
Name: UpdateMusicStream
Return type: void
Description: Updates buffers for music streaming
Param[1]: music (type: Music)
-Function 478: StopMusicStream() (1 input parameters)
+Function 491: StopMusicStream() (1 input parameters)
Name: StopMusicStream
Return type: void
Description: Stop music playing
Param[1]: music (type: Music)
-Function 479: PauseMusicStream() (1 input parameters)
+Function 492: PauseMusicStream() (1 input parameters)
Name: PauseMusicStream
Return type: void
Description: Pause music playing
Param[1]: music (type: Music)
-Function 480: ResumeMusicStream() (1 input parameters)
+Function 493: ResumeMusicStream() (1 input parameters)
Name: ResumeMusicStream
Return type: void
Description: Resume playing paused music
Param[1]: music (type: Music)
-Function 481: SeekMusicStream() (2 input parameters)
+Function 494: SeekMusicStream() (2 input parameters)
Name: SeekMusicStream
Return type: void
Description: Seek music to a position (in seconds)
Param[1]: music (type: Music)
Param[2]: position (type: float)
-Function 482: SetMusicVolume() (2 input parameters)
+Function 495: SetMusicVolume() (2 input parameters)
Name: SetMusicVolume
Return type: void
Description: Set volume for music (1.0 is max level)
Param[1]: music (type: Music)
Param[2]: volume (type: float)
-Function 483: SetMusicPitch() (2 input parameters)
+Function 496: SetMusicPitch() (2 input parameters)
Name: SetMusicPitch
Return type: void
Description: Set pitch for a music (1.0 is base level)
Param[1]: music (type: Music)
Param[2]: pitch (type: float)
-Function 484: SetMusicPan() (2 input parameters)
+Function 497: SetMusicPan() (2 input parameters)
Name: SetMusicPan
Return type: void
Description: Set pan for a music (0.5 is center)
Param[1]: music (type: Music)
Param[2]: pan (type: float)
-Function 485: GetMusicTimeLength() (1 input parameters)
+Function 498: GetMusicTimeLength() (1 input parameters)
Name: GetMusicTimeLength
Return type: float
Description: Get music time length (in seconds)
Param[1]: music (type: Music)
-Function 486: GetMusicTimePlayed() (1 input parameters)
+Function 499: GetMusicTimePlayed() (1 input parameters)
Name: GetMusicTimePlayed
Return type: float
Description: Get current music time played (in seconds)
Param[1]: music (type: Music)
-Function 487: LoadAudioStream() (3 input parameters)
+Function 500: LoadAudioStream() (3 input parameters)
Name: LoadAudioStream
Return type: AudioStream
Description: Load audio stream (to stream raw audio pcm data)
Param[1]: sampleRate (type: unsigned int)
Param[2]: sampleSize (type: unsigned int)
Param[3]: channels (type: unsigned int)
-Function 488: UnloadAudioStream() (1 input parameters)
+Function 501: IsAudioStreamReady() (1 input parameters)
+ Name: IsAudioStreamReady
+ Return type: bool
+ Description: Checks if an audio stream is ready
+ Param[1]: stream (type: AudioStream)
+Function 502: UnloadAudioStream() (1 input parameters)
Name: UnloadAudioStream
Return type: void
Description: Unload audio stream and free memory
Param[1]: stream (type: AudioStream)
-Function 489: UpdateAudioStream() (3 input parameters)
+Function 503: UpdateAudioStream() (3 input parameters)
Name: UpdateAudioStream
Return type: void
Description: Update audio stream buffers with data
Param[1]: stream (type: AudioStream)
Param[2]: data (type: const void *)
Param[3]: frameCount (type: int)
-Function 490: IsAudioStreamProcessed() (1 input parameters)
+Function 504: IsAudioStreamProcessed() (1 input parameters)
Name: IsAudioStreamProcessed
Return type: bool
Description: Check if any audio stream buffers requires refill
Param[1]: stream (type: AudioStream)
-Function 491: PlayAudioStream() (1 input parameters)
+Function 505: PlayAudioStream() (1 input parameters)
Name: PlayAudioStream
Return type: void
Description: Play audio stream
Param[1]: stream (type: AudioStream)
-Function 492: PauseAudioStream() (1 input parameters)
+Function 506: PauseAudioStream() (1 input parameters)
Name: PauseAudioStream
Return type: void
Description: Pause audio stream
Param[1]: stream (type: AudioStream)
-Function 493: ResumeAudioStream() (1 input parameters)
+Function 507: ResumeAudioStream() (1 input parameters)
Name: ResumeAudioStream
Return type: void
Description: Resume audio stream
Param[1]: stream (type: AudioStream)
-Function 494: IsAudioStreamPlaying() (1 input parameters)
+Function 508: IsAudioStreamPlaying() (1 input parameters)
Name: IsAudioStreamPlaying
Return type: bool
Description: Check if audio stream is playing
Param[1]: stream (type: AudioStream)
-Function 495: StopAudioStream() (1 input parameters)
+Function 509: StopAudioStream() (1 input parameters)
Name: StopAudioStream
Return type: void
Description: Stop audio stream
Param[1]: stream (type: AudioStream)
-Function 496: SetAudioStreamVolume() (2 input parameters)
+Function 510: SetAudioStreamVolume() (2 input parameters)
Name: SetAudioStreamVolume
Return type: void
Description: Set volume for audio stream (1.0 is max level)
Param[1]: stream (type: AudioStream)
Param[2]: volume (type: float)
-Function 497: SetAudioStreamPitch() (2 input parameters)
+Function 511: SetAudioStreamPitch() (2 input parameters)
Name: SetAudioStreamPitch
Return type: void
Description: Set pitch for audio stream (1.0 is base level)
Param[1]: stream (type: AudioStream)
Param[2]: pitch (type: float)
-Function 498: SetAudioStreamPan() (2 input parameters)
+Function 512: SetAudioStreamPan() (2 input parameters)
Name: SetAudioStreamPan
Return type: void
Description: Set pan for audio stream (0.5 is centered)
Param[1]: stream (type: AudioStream)
Param[2]: pan (type: float)
-Function 499: SetAudioStreamBufferSizeDefault() (1 input parameters)
+Function 513: SetAudioStreamBufferSizeDefault() (1 input parameters)
Name: SetAudioStreamBufferSizeDefault
Return type: void
Description: Default size for new audio streams
Param[1]: size (type: int)
-Function 500: SetAudioStreamCallback() (2 input parameters)
+Function 514: SetAudioStreamCallback() (2 input parameters)
Name: SetAudioStreamCallback
Return type: void
Description: Audio thread callback to request new data
Param[1]: stream (type: AudioStream)
Param[2]: callback (type: AudioCallback)
-Function 501: AttachAudioStreamProcessor() (2 input parameters)
+Function 515: AttachAudioStreamProcessor() (2 input parameters)
Name: AttachAudioStreamProcessor
Return type: void
- Description:
+ Description: Attach audio stream processor to stream
Param[1]: stream (type: AudioStream)
Param[2]: processor (type: AudioCallback)
-Function 502: DetachAudioStreamProcessor() (2 input parameters)
+Function 516: DetachAudioStreamProcessor() (2 input parameters)
Name: DetachAudioStreamProcessor
Return type: void
- Description:
+ Description: Detach audio stream processor from stream
Param[1]: stream (type: AudioStream)
Param[2]: processor (type: AudioCallback)
+Function 517: AttachAudioMixedProcessor() (1 input parameters)
+ Name: AttachAudioMixedProcessor
+ Return type: void
+ Description: Attach audio stream processor to the entire audio pipeline
+ Param[1]: processor (type: AudioCallback)
+Function 518: DetachAudioMixedProcessor() (1 input parameters)
+ Name: DetachAudioMixedProcessor
+ Return type: void
+ Description: Detach audio stream processor from the entire audio pipeline
+ Param[1]: processor (type: AudioCallback)
diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml
index bbd99e86e..f450069cc 100644
--- a/parser/output/raylib_api.xml
+++ b/parser/output/raylib_api.xml
@@ -1,8 +1,11 @@
-
+
-
+
+
+
+
@@ -71,7 +74,7 @@
-
+
@@ -147,7 +150,7 @@
-
+
@@ -187,7 +190,7 @@
-
+
@@ -207,11 +210,12 @@
-
+
+
@@ -219,8 +223,8 @@
-
-
+
+
@@ -433,7 +437,7 @@
-
+
@@ -446,7 +450,7 @@
-
+
@@ -575,24 +579,25 @@
-
+
-
+
-
+
-
+
+
@@ -651,7 +656,7 @@
-
+
@@ -692,9 +697,13 @@
-
+
+
+
+
+
@@ -842,6 +851,9 @@
+
+
+
@@ -935,11 +947,11 @@
-
+
-
+
@@ -975,7 +987,7 @@
-
+
@@ -1189,29 +1201,15 @@
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
@@ -1486,6 +1484,11 @@
+
+
+
+
+
@@ -1527,6 +1530,9 @@
+
+
+
@@ -1543,17 +1549,12 @@
-
+
-
-
-
-
-
-
-
-
+
+
+
@@ -1562,6 +1563,13 @@
+
+
+
+
+
+
+
@@ -1575,11 +1583,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1627,6 +1647,10 @@
+
+
+
+
@@ -1661,6 +1685,10 @@
+
+
+
+
@@ -1742,14 +1770,27 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1818,9 +1859,15 @@
+
+
+
+
+
+
@@ -1868,22 +1915,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1900,14 +1931,6 @@
-
-
-
-
-
-
-
-
@@ -1929,6 +1952,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1979,6 +2014,9 @@
+
+
+
@@ -2073,6 +2111,13 @@
+
+
+
+
+
+
+
@@ -2085,15 +2130,19 @@
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
@@ -2207,23 +2256,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -2275,6 +2307,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2294,10 +2342,10 @@
-
+
-
+
@@ -2457,6 +2505,9 @@
+
+
+
@@ -2549,12 +2600,18 @@
+
+
+
+
+
+
@@ -2586,13 +2643,6 @@
-
-
-
-
-
-
-
@@ -2636,6 +2686,9 @@
+
+
+
@@ -2684,6 +2737,9 @@
+
+
+
@@ -2729,13 +2785,19 @@
-
+
-
+
+
+
+
+
+
+
diff --git a/parser/raylib_parser.c b/parser/raylib_parser.c
index 49b43f768..94ff95626 100644
--- a/parser/raylib_parser.c
+++ b/parser/raylib_parser.c
@@ -54,7 +54,7 @@
raylib-parser is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
BSD-like license that allows static linking with closed source software:
- Copyright (c) 2021-2022 Ramon Santamaria (@raysan5)
+ Copyright (c) 2021-2023 Ramon Santamaria (@raysan5)
**********************************************************************************************/
@@ -70,7 +70,7 @@
#define MAX_ALIASES_TO_PARSE 64 // Maximum number of aliases to parse
#define MAX_ENUMS_TO_PARSE 64 // Maximum number of enums to parse
#define MAX_CALLBACKS_TO_PARSE 64 // Maximum number of callbacks to parse
-#define MAX_FUNCS_TO_PARSE 512 // Maximum number of functions to parse
+#define MAX_FUNCS_TO_PARSE 1024 // Maximum number of functions to parse
#define MAX_LINE_LENGTH 512 // Maximum length of one line (including comments)
@@ -207,6 +207,12 @@ int main(int argc, char* argv[])
int length = 0;
char *buffer = LoadFileText(inFileName, &length);
+ if (buffer == NULL)
+ {
+ printf("Could not read input file: %s\n", inFileName);
+ return 1;
+ }
+
// Preprocess buffer to get separate lines
// NOTE: GetTextLines() also removes leading spaces/tabs
int linesCount = 0;
@@ -1067,7 +1073,7 @@ static void ShowCommandLineInfo(void)
printf("// //\n");
printf("// more info and bugs-report: github.com/raysan5/raylib/parser //\n");
printf("// //\n");
- printf("// Copyright (c) 2021-2022 Ramon Santamaria (@raysan5) //\n");
+ printf("// Copyright (c) 2021-2023 Ramon Santamaria (@raysan5) //\n");
printf("// //\n");
printf("//////////////////////////////////////////////////////////////////////////////////\n\n");
diff --git a/projects/4coder/Makefile b/projects/4coder/Makefile
index 4178920bb..0d254e340 100644
--- a/projects/4coder/Makefile
+++ b/projects/4coder/Makefile
@@ -2,7 +2,7 @@
#
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
#
-# Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+# Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt
index cfd924fba..cc606a4a2 100644
--- a/projects/CMake/CMakeLists.txt
+++ b/projects/CMake/CMakeLists.txt
@@ -5,12 +5,13 @@ project(example)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Dependencies
-set(RAYLIB_VERSION 4.2.0)
+set(RAYLIB_VERSION 4.5.0)
find_package(raylib ${RAYLIB_VERSION} QUIET) # QUIET or REQUIRED
if (NOT raylib_FOUND) # If there's none, fetch and build raylib
include(FetchContent)
FetchContent_Declare(
raylib
+ DOWNLOAD_EXTRACT_TIMESTAMP OFF
URL https://github.com/raysan5/raylib/archive/refs/tags/${RAYLIB_VERSION}.tar.gz
)
FetchContent_GetProperties(raylib)
diff --git a/projects/CMake/core_basic_window.c b/projects/CMake/core_basic_window.c
index 4357ae598..0e5542967 100644
--- a/projects/CMake/core_basic_window.c
+++ b/projects/CMake/core_basic_window.c
@@ -3,7 +3,7 @@
* raylib [core] example - Basic window (adapted for HTML5 platform)
*
* This example is prepared to compile for PLATFORM_WEB, PLATFORM_DESKTOP and PLATFORM_RPI
-* As you will notice, code structure is slightly diferent to the other examples...
+* As you will notice, code structure is slightly different to the other examples...
* To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning
*
* This example has been created using raylib 1.3 (www.raylib.com)
@@ -31,7 +31,7 @@ int screenHeight = 450;
void UpdateDrawFrame(void); // Update and Draw one frame
//----------------------------------------------------------------------------------
-// Main Enry Point
+// Main Entry Point
//----------------------------------------------------------------------------------
int main()
{
@@ -80,4 +80,4 @@ void UpdateDrawFrame(void)
EndDrawing();
//----------------------------------------------------------------------------------
-}
\ No newline at end of file
+}
diff --git a/projects/Geany/core_basic_window.c b/projects/Geany/core_basic_window.c
index dc1bba141..c4dd584a5 100644
--- a/projects/Geany/core_basic_window.c
+++ b/projects/Geany/core_basic_window.c
@@ -5,7 +5,7 @@
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
diff --git a/projects/Geany/raylib.c.tags b/projects/Geany/raylib.c.tags
index 78e6e7241..79a192a14 100644
--- a/projects/Geany/raylib.c.tags
+++ b/projects/Geany/raylib.c.tags
@@ -202,6 +202,7 @@ ImageDrawText|void|(Image *dst, Vector2 position, const char *text, int fontSize
ImageDrawTextEx|void|(Image *dst, Vector2 position, Font font, const char *text, float fontSize, float spacing, Color color);|
ImageFlipVertical|void|(Image *image);|
ImageFlipHorizontal|void|(Image *image);|
+ImageRotate|void|(Image *image, int degrees);|
ImageRotateCW|void|(Image *image);|
ImageRotateCCW|void|(Image *image);|
ImageColorTint|void|(Image *image, Color color);|
@@ -211,9 +212,9 @@ ImageColorContrast|void|(Image *image, float contrast);|
ImageColorBrightness|void|(Image *image, int brightness);|
ImageColorReplace|void|(Image *image, Color color, Color replace);|
GenImageColor|Image|(int width, int height, Color color);|
-GenImageGradientV|Image|(int width, int height, Color top, Color bottom);|
-GenImageGradientH|Image|(int width, int height, Color left, Color right);|
+GenImageGradientLinear|Image|(int width, int height, int direction, Color start, Color end);|
GenImageGradientRadial|Image|(int width, int height, float density, Color inner, Color outer);|
+GenImageGradientSquare|Image|(int width, int height, float density, Color inner, Color outer);|
GenImageChecked|Image|(int width, int height, int checksX, int checksY, Color col1, Color col2);|
GenImageWhiteNoise|Image|(int width, int height, float factor);|
GenImagePerlinNoise|Image|(int width, int height, int offsetX, int offsetY, float scale);|
diff --git a/projects/Notepad++/c_raylib.xml b/projects/Notepad++/c_raylib.xml
deleted file mode 100644
index 521c8a768..000000000
--- a/projects/Notepad++/c_raylib.xml
+++ /dev/null
@@ -1,3144 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/projects/Notepad++/npes_saved_w64devkit.txt b/projects/Notepad++/npes_saved_w64devkit.txt
index ec5f0412f..92375c24a 100644
Binary files a/projects/Notepad++/npes_saved_w64devkit.txt and b/projects/Notepad++/npes_saved_w64devkit.txt differ
diff --git a/projects/Notepad++/raylib_npp_parser/raylib_npp.xml b/projects/Notepad++/raylib_npp_parser/raylib_npp.xml
index 521c8a768..883183cef 100644
--- a/projects/Notepad++/raylib_npp_parser/raylib_npp.xml
+++ b/projects/Notepad++/raylib_npp_parser/raylib_npp.xml
@@ -65,10 +65,16 @@
-
+
+
+
+
+
+
+
@@ -181,7 +187,7 @@
-
+
@@ -313,6 +319,11 @@
+
+
+
+
+
@@ -459,7 +470,7 @@
-
+
@@ -521,7 +532,7 @@
-
+
@@ -878,41 +889,18 @@
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
@@ -1287,6 +1275,13 @@
+
+
+
+
+
+
+
@@ -1316,7 +1311,7 @@
-
+
@@ -1352,6 +1347,11 @@
+
+
+
+
+
@@ -1378,20 +1378,13 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
@@ -1403,6 +1396,15 @@
+
+
+
+
+
+
+
+
+
@@ -1420,6 +1422,15 @@
+
+
+
+
+
+
+
+
+
@@ -1427,6 +1438,13 @@
+
+
+
+
+
+
+
@@ -1498,6 +1516,12 @@
+
+
+
+
+
+
@@ -1546,6 +1570,12 @@
+
+
+
+
+
+
@@ -1669,7 +1699,7 @@
-
+
@@ -1678,7 +1708,24 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1773,11 +1820,21 @@
+
+
+
+
+
+
+
+
+
+
@@ -1849,26 +1906,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1889,16 +1926,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -1934,6 +1961,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2004,6 +2049,11 @@
+
+
+
+
+
@@ -2136,6 +2186,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -2155,19 +2216,25 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
@@ -2339,27 +2406,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -2425,6 +2471,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2460,13 +2526,13 @@
-
-
+
+
-
-
+
+
@@ -2694,6 +2760,11 @@
+
+
+
+
+
@@ -2839,6 +2910,11 @@
+
+
+
+
+
@@ -2849,6 +2925,11 @@
+
+
+
+
+
@@ -2900,17 +2981,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -2978,6 +3048,11 @@
+
+
+
+
+
@@ -3056,6 +3131,11 @@
+
+
+
+
+
@@ -3141,4 +3221,15 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h
index 4a9daf896..c32cdb26e 100644
--- a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h
+++ b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h
@@ -20,7 +20,8 @@ RLAPI void ToggleFullscreen(void); // Toggle wind
RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
-RLAPI void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP)
+RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)
+RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP)
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode)
@@ -50,7 +51,7 @@ RLAPI void DisableEventWaiting(void); // Disable wai
// Custom frame control functions
// NOTE: Those functions are intended for advance users that want full control over the frame processing
-// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timming + PollInputEvents()
+// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents()
// To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL
RLAPI void SwapScreenBuffer(void); // Swap back buffer with front buffer (screen drawing)
RLAPI void PollInputEvents(void); // Register all input events
@@ -91,6 +92,7 @@ RLAPI void UnloadVrStereoConfig(VrStereoConfig config); // Unload VR s
// NOTE: Shader functionality is not available on OpenGL 1.1
RLAPI Shader LoadShader(const char *vsFileName, const char *fsFileName); // Load shader from files and bind default locations
RLAPI Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode); // Load shader from code strings and bind default locations
+RLAPI bool IsShaderReady(Shader shader); // Check if a shader is ready
RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
RLAPI int GetShaderLocationAttrib(Shader shader, const char *attribName); // Get shader attribute location
RLAPI void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType); // Set shader uniform value
@@ -122,8 +124,8 @@ RLAPI void SetConfigFlags(unsigned int flags); // Setup init
RLAPI void TraceLog(int logLevel, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
RLAPI void SetTraceLogLevel(int logLevel); // Set the current threshold (minimum) log level
-RLAPI void *MemAlloc(int size); // Internal memory allocator
-RLAPI void *MemRealloc(void *ptr, int size); // Internal memory reallocator
+RLAPI void *MemAlloc(unsigned int size); // Internal memory allocator
+RLAPI void *MemRealloc(void *ptr, unsigned int size); // Internal memory reallocator
RLAPI void MemFree(void *ptr); // Internal memory free
RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available)
@@ -140,7 +142,7 @@ RLAPI void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom
RLAPI unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read)
RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData()
RLAPI bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write), returns true on success
-RLAPI bool ExportDataAsCode(const char *data, unsigned int size, const char *fileName); // Export data to code (.h), returns true on success
+RLAPI bool ExportDataAsCode(const unsigned char *data, unsigned int size, const char *fileName); // Export data to code (.h), returns true on success
RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string
RLAPI void UnloadFileText(char *text); // Unload file text data allocated by LoadFileText()
RLAPI bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success
@@ -234,13 +236,8 @@ RLAPI float GetGesturePinchAngle(void); // Get gesture pinch ang
//------------------------------------------------------------------------------------
// Camera System Functions (Module: rcamera)
//------------------------------------------------------------------------------------
-RLAPI void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available)
-RLAPI void UpdateCamera(Camera *camera); // Update camera position for selected mode
-
-RLAPI void SetCameraPanControl(int keyPan); // Set camera pan key to combine with mouse movement (free camera)
-RLAPI void SetCameraAltControl(int keyAlt); // Set camera alt key to combine with mouse movement (free camera)
-RLAPI void SetCameraSmoothZoomControl(int keySmoothZoom); // Set camera smooth zoom key to combine with mouse (free camera)
-RLAPI void SetCameraMoveControls(int keyFront, int keyBack, int keyRight, int keyLeft, int keyUp, int keyDown); // Set camera move controls (1st person and 3rd person cameras)
+RLAPI void UpdateCamera(Camera *camera, int mode); // Update camera position for selected mode
+RLAPI void UpdateCameraPro(Camera *camera, Vector3 movement, Vector3 rotation, float zoom); // Update camera movement/rotation
//------------------------------------------------------------------------------------
// Basic Shapes Drawing Functions (Module: shapes)
@@ -296,6 +293,7 @@ RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec);
RLAPI bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle
RLAPI bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); // Check if point is inside circle
RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); // Check if point is inside a triangle
+RLAPI bool CheckCollisionPointPoly(Vector2 point, Vector2 *points, int pointCount); // Check if point is within a polygon described by array of vertices
RLAPI bool CheckCollisionLines(Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2, Vector2 *collisionPoint); // Check the collision between two lines defined by two points each, returns collision point by reference
RLAPI bool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshold); // Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]
RLAPI Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); // Get collision rectangle for two rectangles collision
@@ -305,25 +303,28 @@ RLAPI Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2);
//------------------------------------------------------------------------------------
// Image loading functions
-// NOTE: This functions do not require GPU access
+// NOTE: These functions do not require GPU access
RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)
RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data
RLAPI Image LoadImageAnim(const char *fileName, int *frames); // Load image sequence from file (frames appended to image.data)
RLAPI Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load image from memory buffer, fileType refers to extension: i.e. '.png'
RLAPI Image LoadImageFromTexture(Texture2D texture); // Load image from GPU texture data
RLAPI Image LoadImageFromScreen(void); // Load image from screen buffer and (screenshot)
+RLAPI bool IsImageReady(Image image); // Check if an image is ready
RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM)
RLAPI bool ExportImage(Image image, const char *fileName); // Export image data to file, returns true on success
RLAPI bool ExportImageAsCode(Image image, const char *fileName); // Export image as code file defining an array of bytes, returns true on success
// Image generation functions
RLAPI Image GenImageColor(int width, int height, Color color); // Generate image: plain color
-RLAPI Image GenImageGradientV(int width, int height, Color top, Color bottom); // Generate image: vertical gradient
-RLAPI Image GenImageGradientH(int width, int height, Color left, Color right); // Generate image: horizontal gradient
+RLAPI Image GenImageGradientLinear(int width, int height, int direction, Color start, Color end); // Generate image: linear gradient
RLAPI Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); // Generate image: radial gradient
+RLAPI Image GenImageGradientSquare(int width, int height, float density, Color inner, Color outer); // Generate image: square gradient
RLAPI Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2); // Generate image: checked
RLAPI Image GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise
+RLAPI Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); // Generate image: perlin noise
RLAPI Image GenImageCellular(int width, int height, int tileSize); // Generate image: cellular algorithm, bigger tileSize means bigger cells
+RLAPI Image GenImageText(int width, int height, const char *text); // Generate image: grayscale image from text data
// Image manipulation functions
RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)
@@ -337,6 +338,7 @@ RLAPI void ImageAlphaCrop(Image *image, float threshold);
RLAPI void ImageAlphaClear(Image *image, Color color, float threshold); // Clear alpha channel to desired color
RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
RLAPI void ImageAlphaPremultiply(Image *image); // Premultiply alpha channel
+RLAPI void ImageBlurGaussian(Image *image, int blurSize); // Apply Gaussian blur using a box blur approximation
RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize image (Bicubic scaling algorithm)
RLAPI void ImageResizeNN(Image *image, int newWidth,int newHeight); // Resize image (Nearest-Neighbor scaling algorithm)
RLAPI void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill); // Resize canvas and fill with color
@@ -344,6 +346,7 @@ RLAPI void ImageMipmaps(Image *image);
RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
RLAPI void ImageFlipVertical(Image *image); // Flip image vertically
RLAPI void ImageFlipHorizontal(Image *image); // Flip image horizontally
+RLAPI void ImageRotate(Image *image, int degrees); // Rotate image by input angle in degrees (-359 to 359)
RLAPI void ImageRotateCW(Image *image); // Rotate image clockwise 90deg
RLAPI void ImageRotateCCW(Image *image); // Rotate image counter-clockwise 90deg
RLAPI void ImageColorTint(Image *image, Color color); // Modify image color: tint
@@ -366,8 +369,10 @@ RLAPI void ImageDrawPixel(Image *dst, int posX, int posY, Color color);
RLAPI void ImageDrawPixelV(Image *dst, Vector2 position, Color color); // Draw pixel within an image (Vector version)
RLAPI void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw line within an image
RLAPI void ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color); // Draw line within an image (Vector version)
-RLAPI void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color); // Draw circle within an image
-RLAPI void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color); // Draw circle within an image (Vector version)
+RLAPI void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color); // Draw a filled circle within an image
+RLAPI void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color); // Draw a filled circle within an image (Vector version)
+RLAPI void ImageDrawCircleLines(Image *dst, int centerX, int centerY, int radius, Color color); // Draw circle outline within an image
+RLAPI void ImageDrawCircleLinesV(Image *dst, Vector2 center, int radius, Color color); // Draw circle outline within an image (Vector version)
RLAPI void ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color color); // Draw rectangle within an image
RLAPI void ImageDrawRectangleV(Image *dst, Vector2 position, Vector2 size, Color color); // Draw rectangle within an image (Vector version)
RLAPI void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color); // Draw rectangle within an image
@@ -382,7 +387,9 @@ RLAPI Texture2D LoadTexture(const char *fileName);
RLAPI Texture2D LoadTextureFromImage(Image image); // Load texture from image data
RLAPI TextureCubemap LoadTextureCubemap(Image image, int layout); // Load cubemap from image, multiple image cubemap layouts supported
RLAPI RenderTexture2D LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer)
+RLAPI bool IsTextureReady(Texture2D texture); // Check if a texture is ready
RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)
+RLAPI bool IsRenderTextureReady(RenderTexture2D target); // Check if a render texture is ready
RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM)
RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data
RLAPI void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels); // Update GPU texture rectangle with new data
@@ -397,11 +404,8 @@ RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint);
RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters
RLAPI void DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle
-RLAPI void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint); // Draw texture quad with tiling and offset parameters
-RLAPI void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint); // Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.
-RLAPI void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draw a part of a texture defined by a rectangle with 'pro' parameters
-RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely
-RLAPI void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint); // Draw a textured polygon
+RLAPI void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draw a part of a texture defined by a rectangle with 'pro' parameters
+RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely
// Color/pixel related functions
RLAPI Color Fade(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f
@@ -410,6 +414,9 @@ RLAPI Vector4 ColorNormalize(Color color); // G
RLAPI Color ColorFromNormalized(Vector4 normalized); // Get Color from normalized values [0..1]
RLAPI Vector3 ColorToHSV(Color color); // Get HSV values for a Color, hue [0..360], saturation/value [0..1]
RLAPI Color ColorFromHSV(float hue, float saturation, float value); // Get a Color from HSV values, hue [0..360], saturation/value [0..1]
+RLAPI Color ColorTint(Color color, Color tint); // Get color multiplied with another color
+RLAPI Color ColorBrightness(Color color, float factor); // Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
+RLAPI Color ColorContrast(Color color, float contrast); // Get color with contrast correction, contrast values between -1.0f and 1.0f
RLAPI Color ColorAlpha(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f
RLAPI Color ColorAlphaBlend(Color dst, Color src, Color tint); // Get src alpha-blended into dst color with tint
RLAPI Color GetColor(unsigned int hexValue); // Get Color structure from hexadecimal value
@@ -427,6 +434,7 @@ RLAPI Font LoadFont(const char *fileName);
RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int glyphCount); // Load font from file with extended parameters, use NULL for fontChars and 0 for glyphCount to load the default character set
RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)
RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
+RLAPI bool IsFontReady(Font font); // Check if a font is ready
RLAPI GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount, int type); // Load font data for further use
RLAPI Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **recs, int glyphCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info
RLAPI void UnloadFontData(GlyphInfo *chars, int glyphCount); // Unload font chars info data (RAM)
@@ -449,12 +457,15 @@ RLAPI GlyphInfo GetGlyphInfo(Font font, int codepoint);
RLAPI Rectangle GetGlyphAtlasRec(Font font, int codepoint); // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found
// Text codepoints management functions (unicode characters)
-RLAPI int *LoadCodepoints(const char *text, int *count); // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter
-RLAPI void UnloadCodepoints(int *codepoints); // Unload codepoints data from memory
-RLAPI int GetCodepointCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string
-RLAPI int GetCodepoint(const char *text, int *bytesProcessed); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
-RLAPI const char *CodepointToUTF8(int codepoint, int *byteSize); // Encode one codepoint into UTF-8 byte array (array length returned as parameter)
-RLAPI char *TextCodepointsToUTF8(const int *codepoints, int length); // Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!)
+RLAPI char *LoadUTF8(const int *codepoints, int length); // Load UTF-8 text encoded from codepoints array
+RLAPI void UnloadUTF8(char *text); // Unload UTF-8 text encoded from codepoints array
+RLAPI int *LoadCodepoints(const char *text, int *count); // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter
+RLAPI void UnloadCodepoints(int *codepoints); // Unload codepoints data from memory
+RLAPI int GetCodepointCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string
+RLAPI int GetCodepoint(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
+RLAPI int GetCodepointNext(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
+RLAPI int GetCodepointPrevious(const char *text, int *codepointSize); // Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
+RLAPI const char *CodepointToUTF8(int codepoint, int *utf8Size); // Encode one codepoint into UTF-8 byte array (array length returned as parameter)
// Text strings management functions (no UTF-8 strings, only byte chars)
// NOTE: Some strings allocate memory internally for returned strings, just be careful!
@@ -488,8 +499,6 @@ RLAPI void DrawCube(Vector3 position, float width, float height, float length, C
RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version)
RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires
RLAPI void DrawCubeWiresV(Vector3 position, Vector3 size, Color color); // Draw cube wires (Vector version)
-RLAPI void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured
-RLAPI void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color); // Draw cube with a region of a texture
RLAPI void DrawSphere(Vector3 centerPos, float radius, Color color); // Draw sphere
RLAPI void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere with extended parameters
RLAPI void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires
@@ -497,6 +506,8 @@ RLAPI void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, f
RLAPI void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder with base at startPos and top at endPos
RLAPI void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires
RLAPI void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder wires with base at startPos and top at endPos
+RLAPI void DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color); // Draw a capsule with the center of its sphere caps at startPos and endPos
+RLAPI void DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color); // Draw capsule wireframe with the center of its sphere caps at startPos and endPos
RLAPI void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ
RLAPI void DrawRay(Ray ray, Color color); // Draw a ray line
RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0))
@@ -508,16 +519,16 @@ RLAPI void DrawGrid(int slices, float spacing);
// Model management functions
RLAPI Model LoadModel(const char *fileName); // Load model from files (meshes and materials)
RLAPI Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh (default material)
+RLAPI bool IsModelReady(Model model); // Check if a model is ready
RLAPI void UnloadModel(Model model); // Unload model (including meshes) from memory (RAM and/or VRAM)
-RLAPI void UnloadModelKeepMeshes(Model model); // Unload model (but not meshes) from memory (RAM and/or VRAM)
RLAPI BoundingBox GetModelBoundingBox(Model model); // Compute model bounding box limits (considers all meshes)
// Model drawing functions
-RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
+RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters
-RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set)
+RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set)
RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters
-RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
+RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 position, float size, Color tint); // Draw a billboard texture
RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint); // Draw a billboard texture defined by source
RLAPI void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint); // Draw a billboard texture defined by source and rotation
@@ -548,6 +559,7 @@ RLAPI Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize);
// Material loading/unloading functions
RLAPI Material *LoadMaterials(const char *fileName, int *materialCount); // Load materials from model file
RLAPI Material LoadMaterialDefault(void); // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)
+RLAPI bool IsMaterialReady(Material material); // Check if a material is ready
RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)
RLAPI void SetMaterialTexture(Material *material, int mapType, Texture2D texture); // Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...)
RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh
@@ -583,8 +595,10 @@ RLAPI void SetMasterVolume(float volume); // Set mas
// Wave/Sound loading/unloading functions
RLAPI Wave LoadWave(const char *fileName); // Load wave data from file
RLAPI Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load wave from memory buffer, fileType refers to extension: i.e. '.wav'
+RLAPI bool IsWaveReady(Wave wave); // Checks if wave data is ready
RLAPI Sound LoadSound(const char *fileName); // Load sound from file
RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data
+RLAPI bool IsSoundReady(Sound sound); // Checks if a sound is ready
RLAPI void UpdateSound(Sound sound, const void *data, int sampleCount); // Update sound buffer with new data
RLAPI void UnloadWave(Wave wave); // Unload wave data
RLAPI void UnloadSound(Sound sound); // Unload sound
@@ -596,9 +610,6 @@ RLAPI void PlaySound(Sound sound); // Play a
RLAPI void StopSound(Sound sound); // Stop playing a sound
RLAPI void PauseSound(Sound sound); // Pause a sound
RLAPI void ResumeSound(Sound sound); // Resume a paused sound
-RLAPI void PlaySoundMulti(Sound sound); // Play a sound (using multichannel buffer pool)
-RLAPI void StopSoundMulti(void); // Stop any sound playing (using multichannel buffer pool)
-RLAPI int GetSoundsPlaying(void); // Get number of sounds playing in the multichannel
RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)
RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
@@ -612,6 +623,7 @@ RLAPI void UnloadWaveSamples(float *samples); // Unload
// Music management functions
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
RLAPI Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, int dataSize); // Load music stream from data
+RLAPI bool IsMusicReady(Music music); // Checks if a music stream is ready
RLAPI void UnloadMusicStream(Music music); // Unload music stream
RLAPI void PlayMusicStream(Music music); // Start music playing
RLAPI bool IsMusicStreamPlaying(Music music); // Check if music is playing
@@ -628,6 +640,7 @@ RLAPI float GetMusicTimePlayed(Music music); // Get cur
// AudioStream management functions
RLAPI AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Load audio stream (to stream raw audio pcm data)
+RLAPI bool IsAudioStreamReady(AudioStream stream); // Checks if an audio stream is ready
RLAPI void UnloadAudioStream(AudioStream stream); // Unload audio stream and free memory
RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int frameCount); // Update audio stream buffers with data
RLAPI bool IsAudioStreamProcessed(AudioStream stream); // Check if any audio stream buffers requires refill
@@ -645,3 +658,6 @@ RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback);
RLAPI void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream
RLAPI void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Detach audio stream processor from stream
+RLAPI void AttachAudioMixedProcessor(AudioCallback processor); // Attach audio stream processor to the entire audio pipeline
+RLAPI void DetachAudioMixedProcessor(AudioCallback processor); // Detach audio stream processor from the entire audio pipeline
+
diff --git a/projects/VS2022/examples/audio_multichannel_sound.vcxproj b/projects/VS2022/examples/audio_sound_multi.vcxproj
similarity index 98%
rename from projects/VS2022/examples/audio_multichannel_sound.vcxproj
rename to projects/VS2022/examples/audio_sound_multi.vcxproj
index 91ab9095d..5bfed78fb 100644
--- a/projects/VS2022/examples/audio_multichannel_sound.vcxproj
+++ b/projects/VS2022/examples/audio_sound_multi.vcxproj
@@ -35,11 +35,11 @@
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}
Win32Proj
- audio_multichannel_sound
+ audio_sound_multi
10.0
- audio_multichannel_sound
+ audio_sound_multi
@@ -374,7 +374,7 @@
-
+
diff --git a/projects/VS2022/examples/models_loading_m3d.vcxproj b/projects/VS2022/examples/models_loading_m3d.vcxproj
new file mode 100644
index 000000000..f08b1ebb2
--- /dev/null
+++ b/projects/VS2022/examples/models_loading_m3d.vcxproj
@@ -0,0 +1,387 @@
+
+
+
+
+ Debug.DLL
+ Win32
+
+
+ Debug.DLL
+ x64
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release.DLL
+ Win32
+
+
+ Release.DLL
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}
+ Win32Proj
+ models_loading_m3d
+ 10.0
+ models_loading_m3d
+
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ $(SolutionDir)..\..\examples\models
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\models
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\models
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\models
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\models
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\models
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\models
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\models
+ WindowsLocalDebugger
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ /FS %(AdditionalOptions)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+ Copy Debug DLL to output directory
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+ Copy Debug DLL to output directory
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+
+
+ Copy Release DLL to output directory
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+
+
+ Copy Release DLL to output directory
+
+
+
+
+
+
+
+ {e89d61ac-55de-4482-afd4-df7242ebc859}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/VS2022/examples/rlgl_compute_shaders.vcxproj b/projects/VS2022/examples/rlgl_compute_shaders.vcxproj
index 14fe2f4ee..2e514f3d4 100644
--- a/projects/VS2022/examples/rlgl_compute_shaders.vcxproj
+++ b/projects/VS2022/examples/rlgl_compute_shaders.vcxproj
@@ -202,16 +202,15 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
Console
true
-
-
- opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
@@ -220,7 +219,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
/FS %(AdditionalOptions)
@@ -228,9 +227,8 @@
Console
true
-
-
- opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
@@ -239,16 +237,15 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
Console
true
-
-
- opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
@@ -261,16 +258,15 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
Console
true
-
-
- opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
@@ -285,7 +281,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -295,9 +291,8 @@
true
true
true
- opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
-
-
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
@@ -308,7 +303,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -318,9 +313,8 @@
true
true
true
- opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
-
-
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
@@ -331,7 +325,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -341,9 +335,8 @@
true
true
true
- opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
-
-
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
@@ -360,7 +353,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -370,9 +363,8 @@
true
true
true
- opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
-
-
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
@@ -382,9 +374,14 @@
-
+
+
+
+ {e89d61ac-55de-4482-afd4-df7242ebc859}
+
+
diff --git a/projects/VS2022/examples/rlgl_standalone.vcxproj b/projects/VS2022/examples/rlgl_standalone.vcxproj
index 466740431..707a73a91 100644
--- a/projects/VS2022/examples/rlgl_standalone.vcxproj
+++ b/projects/VS2022/examples/rlgl_standalone.vcxproj
@@ -202,7 +202,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
@@ -220,7 +220,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
/FS %(AdditionalOptions)
@@ -239,7 +239,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
@@ -261,7 +261,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
@@ -285,7 +285,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -308,7 +308,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -331,7 +331,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -360,7 +360,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;$(SolutionDir)..\..\examples\others\external\include;%(AdditionalIncludeDirectories)
CompileAsC
true
diff --git a/projects/VS2022/examples/shaders_hot_reloading.vcxproj b/projects/VS2022/examples/shaders_hot_reloading.vcxproj
index e10ec74e5..900246daf 100644
--- a/projects/VS2022/examples/shaders_hot_reloading.vcxproj
+++ b/projects/VS2022/examples/shaders_hot_reloading.vcxproj
@@ -202,7 +202,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -219,7 +219,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
/FS %(AdditionalOptions)
@@ -237,7 +237,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -258,7 +258,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -281,7 +281,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -303,7 +303,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -325,7 +325,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -353,7 +353,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
diff --git a/projects/VS2022/examples/shaders_hybrid_render.vcxproj b/projects/VS2022/examples/shaders_hybrid_render.vcxproj
new file mode 100644
index 000000000..ba8cdc58b
--- /dev/null
+++ b/projects/VS2022/examples/shaders_hybrid_render.vcxproj
@@ -0,0 +1,387 @@
+
+
+
+
+ Debug.DLL
+ Win32
+
+
+ Debug.DLL
+ x64
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release.DLL
+ Win32
+
+
+ Release.DLL
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}
+ Win32Proj
+ shaders_hybrid_render
+ 10.0
+ shaders_hybrid_render
+
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ /FS %(AdditionalOptions)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+ Copy Debug DLL to output directory
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+ Copy Debug DLL to output directory
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+
+
+ Copy Release DLL to output directory
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+
+
+ Copy Release DLL to output directory
+
+
+
+
+
+
+
+ {e89d61ac-55de-4482-afd4-df7242ebc859}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/VS2022/examples/shaders_write_depth.vcxproj b/projects/VS2022/examples/shaders_write_depth.vcxproj
new file mode 100644
index 000000000..18b1d8797
--- /dev/null
+++ b/projects/VS2022/examples/shaders_write_depth.vcxproj
@@ -0,0 +1,387 @@
+
+
+
+
+ Debug.DLL
+ Win32
+
+
+ Debug.DLL
+ x64
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release.DLL
+ Win32
+
+
+ Release.DLL
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}
+ Win32Proj
+ shaders_write_depth
+ 10.0
+ shaders_write_depth
+
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\shaders
+ WindowsLocalDebugger
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ /FS %(AdditionalOptions)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+ Copy Debug DLL to output directory
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+ Copy Debug DLL to output directory
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+
+
+ Copy Release DLL to output directory
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+
+
+ Copy Release DLL to output directory
+
+
+
+
+
+
+
+ {e89d61ac-55de-4482-afd4-df7242ebc859}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/VS2022/examples/shapes_draw_circle_sector.vcxproj b/projects/VS2022/examples/shapes_draw_circle_sector.vcxproj
index be37881fc..df61cdb1e 100644
--- a/projects/VS2022/examples/shapes_draw_circle_sector.vcxproj
+++ b/projects/VS2022/examples/shapes_draw_circle_sector.vcxproj
@@ -202,7 +202,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -219,7 +219,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
/FS %(AdditionalOptions)
@@ -237,7 +237,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -258,7 +258,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -281,7 +281,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -303,7 +303,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -325,7 +325,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -353,7 +353,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
diff --git a/projects/VS2022/examples/shapes_draw_rectangle_rounded.vcxproj b/projects/VS2022/examples/shapes_draw_rectangle_rounded.vcxproj
index af8ce6fd5..207d38f54 100644
--- a/projects/VS2022/examples/shapes_draw_rectangle_rounded.vcxproj
+++ b/projects/VS2022/examples/shapes_draw_rectangle_rounded.vcxproj
@@ -202,7 +202,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -219,7 +219,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
/FS %(AdditionalOptions)
@@ -237,7 +237,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -258,7 +258,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -281,7 +281,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -303,7 +303,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -325,7 +325,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -353,7 +353,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
diff --git a/projects/VS2022/examples/shapes_draw_ring.vcxproj b/projects/VS2022/examples/shapes_draw_ring.vcxproj
index 1488c9522..490e8e2c8 100644
--- a/projects/VS2022/examples/shapes_draw_ring.vcxproj
+++ b/projects/VS2022/examples/shapes_draw_ring.vcxproj
@@ -202,7 +202,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -219,7 +219,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
/FS %(AdditionalOptions)
@@ -237,7 +237,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -258,7 +258,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -281,7 +281,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -303,7 +303,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -325,7 +325,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -353,7 +353,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
diff --git a/projects/VS2022/examples/text_draw_3d.vcxproj b/projects/VS2022/examples/text_draw_3d.vcxproj
index c078bb010..0ea41840c 100644
--- a/projects/VS2022/examples/text_draw_3d.vcxproj
+++ b/projects/VS2022/examples/text_draw_3d.vcxproj
@@ -202,7 +202,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -219,7 +219,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
/FS %(AdditionalOptions)
@@ -237,7 +237,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -258,7 +258,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -281,7 +281,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -303,7 +303,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -325,7 +325,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -353,7 +353,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
diff --git a/projects/VS2022/examples/textures_fog_of_war.vcxproj b/projects/VS2022/examples/textures_fog_of_war.vcxproj
index aa93c01a8..344a38cc5 100644
--- a/projects/VS2022/examples/textures_fog_of_war.vcxproj
+++ b/projects/VS2022/examples/textures_fog_of_war.vcxproj
@@ -202,7 +202,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -219,7 +219,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
/FS %(AdditionalOptions)
@@ -237,7 +237,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -258,7 +258,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -281,7 +281,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -303,7 +303,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -325,7 +325,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -353,7 +353,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
diff --git a/projects/VS2022/examples/textures_polygon.vcxproj b/projects/VS2022/examples/textures_polygon.vcxproj
index 9467c8aeb..1788f426a 100644
--- a/projects/VS2022/examples/textures_polygon.vcxproj
+++ b/projects/VS2022/examples/textures_polygon.vcxproj
@@ -202,7 +202,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -219,7 +219,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
/FS %(AdditionalOptions)
@@ -237,7 +237,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -258,7 +258,7 @@
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
CompileAsC
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
@@ -281,7 +281,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -303,7 +303,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -325,7 +325,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
@@ -353,7 +353,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
CompileAsC
true
diff --git a/projects/VS2022/examples/textures_textured_curve.vcxproj b/projects/VS2022/examples/textures_textured_curve.vcxproj
new file mode 100644
index 000000000..9b989f72c
--- /dev/null
+++ b/projects/VS2022/examples/textures_textured_curve.vcxproj
@@ -0,0 +1,387 @@
+
+
+
+
+ Debug.DLL
+ Win32
+
+
+ Debug.DLL
+ x64
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release.DLL
+ Win32
+
+
+ Release.DLL
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}
+ Win32Proj
+ textures_textured_curve
+ 10.0
+ textures_textured_curve
+
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ true
+ $(DefaultPlatformToolset)
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+ Application
+ false
+ $(DefaultPlatformToolset)
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ true
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ false
+ $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\
+
+
+ $(SolutionDir)..\..\examples\textures
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\textures
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\textures
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\textures
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\textures
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\textures
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\textures
+ WindowsLocalDebugger
+
+
+ $(SolutionDir)..\..\examples\textures
+ WindowsLocalDebugger
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ /FS %(AdditionalOptions)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+ Copy Debug DLL to output directory
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)
+ CompileAsC
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+ Copy Debug DLL to output directory
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+
+
+ Copy Release DLL to output directory
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP
+ $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)
+ CompileAsC
+ true
+
+
+ Console
+ true
+ true
+ true
+ raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\
+
+
+ xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"
+
+
+ Copy Release DLL to output directory
+
+
+
+
+
+
+
+ {e89d61ac-55de-4482-afd4-df7242ebc859}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/VS2022/raylib.sln b/projects/VS2022/raylib.sln
index b4ab4201c..173637554 100644
--- a/projects/VS2022/raylib.sln
+++ b/projects/VS2022/raylib.sln
@@ -17,8 +17,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "textures_image_drawing", "e
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio_module_playing", "examples\audio_module_playing.vcxproj", "{E6784F91-4E4E-4956-A079-73FAB1AC7BE6}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio_multichannel_sound", "examples\audio_multichannel_sound.vcxproj", "{9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio_music_stream", "examples\audio_music_stream.vcxproj", "{BFB22AB2-041B-4A1B-80C0-1D4BE410C8A9}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio_raw_stream", "examples\audio_raw_stream.vcxproj", "{93A1F656-0D29-4C5E-B140-11F23FF5D6AB}"
@@ -263,6 +261,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "textures_polygon", "example
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio_stream_effects", "examples\audio_stream_effects.vcxproj", "{4A87569C-4BD3-4113-B4B9-573D65B3D3F8}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "textures_textured_curve", "examples\textures_textured_curve.vcxproj", "{769FF0C1-4424-4FA3-BC44-D7A7DA312A06}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "models_loading_m3d", "examples\models_loading_m3d.vcxproj", "{6D9E00D8-2893-45E4-9363-3F7F61D416BD}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_write_depth", "examples\shaders_write_depth.vcxproj", "{70B35F59-AFC2-4D8F-8833-5314D2047A81}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_hybrid_render", "examples\shaders_hybrid_render.vcxproj", "{3755E9F4-CB48-4EC3-B561-3B85964EBDEF}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio_sound_multi", "examples\audio_sound_multi.vcxproj", "{F81C5819-85B4-4D2E-B6DC-104A7634461B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug.DLL|x64 = Debug.DLL|x64
@@ -371,22 +379,6 @@ Global
{E6784F91-4E4E-4956-A079-73FAB1AC7BE6}.Release|x64.Build.0 = Release|x64
{E6784F91-4E4E-4956-A079-73FAB1AC7BE6}.Release|x86.ActiveCfg = Release|Win32
{E6784F91-4E4E-4956-A079-73FAB1AC7BE6}.Release|x86.Build.0 = Release|Win32
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Debug.DLL|x64.Build.0 = Debug.DLL|x64
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Debug|x64.ActiveCfg = Debug|x64
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Debug|x64.Build.0 = Debug|x64
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Debug|x86.ActiveCfg = Debug|Win32
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Debug|x86.Build.0 = Debug|Win32
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Release.DLL|x64.ActiveCfg = Release.DLL|x64
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Release.DLL|x64.Build.0 = Release.DLL|x64
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Release.DLL|x86.Build.0 = Release.DLL|Win32
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Release|x64.ActiveCfg = Release|x64
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Release|x64.Build.0 = Release|x64
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Release|x86.ActiveCfg = Release|Win32
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F}.Release|x86.Build.0 = Release|Win32
{BFB22AB2-041B-4A1B-80C0-1D4BE410C8A9}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64
{BFB22AB2-041B-4A1B-80C0-1D4BE410C8A9}.Debug.DLL|x64.Build.0 = Debug.DLL|x64
{BFB22AB2-041B-4A1B-80C0-1D4BE410C8A9}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
@@ -2207,6 +2199,86 @@ Global
{4A87569C-4BD3-4113-B4B9-573D65B3D3F8}.Release|x64.Build.0 = Release|x64
{4A87569C-4BD3-4113-B4B9-573D65B3D3F8}.Release|x86.ActiveCfg = Release|Win32
{4A87569C-4BD3-4113-B4B9-573D65B3D3F8}.Release|x86.Build.0 = Release|Win32
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Debug.DLL|x64.Build.0 = Debug.DLL|x64
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Debug|x64.ActiveCfg = Debug|x64
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Debug|x64.Build.0 = Debug|x64
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Debug|x86.ActiveCfg = Debug|Win32
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Debug|x86.Build.0 = Debug|Win32
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Release.DLL|x64.ActiveCfg = Release.DLL|x64
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Release.DLL|x64.Build.0 = Release.DLL|x64
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Release.DLL|x86.Build.0 = Release.DLL|Win32
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Release|x64.ActiveCfg = Release|x64
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Release|x64.Build.0 = Release|x64
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Release|x86.ActiveCfg = Release|Win32
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Release|x86.Build.0 = Release|Win32
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug.DLL|x64.Build.0 = Debug.DLL|x64
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug|x64.ActiveCfg = Debug|x64
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug|x64.Build.0 = Debug|x64
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug|x86.ActiveCfg = Debug|Win32
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug|x86.Build.0 = Debug|Win32
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release.DLL|x64.ActiveCfg = Release.DLL|x64
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release.DLL|x64.Build.0 = Release.DLL|x64
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release.DLL|x86.Build.0 = Release.DLL|Win32
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release|x64.ActiveCfg = Release|x64
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release|x64.Build.0 = Release|x64
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release|x86.ActiveCfg = Release|Win32
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release|x86.Build.0 = Release|Win32
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Debug.DLL|x64.Build.0 = Debug.DLL|x64
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Debug|x64.ActiveCfg = Debug|x64
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Debug|x64.Build.0 = Debug|x64
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Debug|x86.ActiveCfg = Debug|Win32
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Debug|x86.Build.0 = Debug|Win32
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Release.DLL|x64.ActiveCfg = Release.DLL|x64
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Release.DLL|x64.Build.0 = Release.DLL|x64
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Release.DLL|x86.Build.0 = Release.DLL|Win32
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Release|x64.ActiveCfg = Release|x64
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Release|x64.Build.0 = Release|x64
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Release|x86.ActiveCfg = Release|Win32
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81}.Release|x86.Build.0 = Release|Win32
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Debug.DLL|x64.Build.0 = Debug.DLL|x64
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Debug|x64.ActiveCfg = Debug|x64
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Debug|x64.Build.0 = Debug|x64
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Debug|x86.ActiveCfg = Debug|Win32
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Debug|x86.Build.0 = Debug|Win32
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Release.DLL|x64.ActiveCfg = Release.DLL|x64
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Release.DLL|x64.Build.0 = Release.DLL|x64
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Release.DLL|x86.Build.0 = Release.DLL|Win32
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Release|x64.ActiveCfg = Release|x64
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Release|x64.Build.0 = Release|x64
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Release|x86.ActiveCfg = Release|Win32
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF}.Release|x86.Build.0 = Release|Win32
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Debug.DLL|x64.Build.0 = Debug.DLL|x64
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Debug|x64.ActiveCfg = Debug|x64
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Debug|x64.Build.0 = Debug|x64
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Debug|x86.ActiveCfg = Debug|Win32
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Debug|x86.Build.0 = Debug|Win32
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Release.DLL|x64.ActiveCfg = Release.DLL|x64
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Release.DLL|x64.Build.0 = Release.DLL|x64
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Release.DLL|x86.Build.0 = Release.DLL|Win32
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Release|x64.ActiveCfg = Release|x64
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Release|x64.Build.0 = Release|x64
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Release|x86.ActiveCfg = Release|Win32
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -2217,7 +2289,6 @@ Global
{103B292B-049B-4B15-85A1-9F902840DB2C} = {DA049009-21FF-4AC0-84E4-830DD1BCD0CE}
{0C2D2F82-AE67-400C-B19C-8C9B957B132A} = {DA049009-21FF-4AC0-84E4-830DD1BCD0CE}
{E6784F91-4E4E-4956-A079-73FAB1AC7BE6} = {CC132A4D-D081-4C26-BFB9-AB11984054F8}
- {9875B0C8-3893-43F8-88B2-4BAAAE3E8E6F} = {CC132A4D-D081-4C26-BFB9-AB11984054F8}
{BFB22AB2-041B-4A1B-80C0-1D4BE410C8A9} = {CC132A4D-D081-4C26-BFB9-AB11984054F8}
{93A1F656-0D29-4C5E-B140-11F23FF5D6AB} = {CC132A4D-D081-4C26-BFB9-AB11984054F8}
{F81C5819-85B6-4D2E-B6DC-104A7634461B} = {CC132A4D-D081-4C26-BFB9-AB11984054F8}
@@ -2340,6 +2411,11 @@ Global
{27B110CC-43C0-400A-89D9-245E681647D7} = {8D3C83B7-F1E0-4C2E-9E34-EE5F6AB2502A}
{1DE84812-E143-4C4B-A61D-9267AAD55401} = {DA049009-21FF-4AC0-84E4-830DD1BCD0CE}
{4A87569C-4BD3-4113-B4B9-573D65B3D3F8} = {CC132A4D-D081-4C26-BFB9-AB11984054F8}
+ {769FF0C1-4424-4FA3-BC44-D7A7DA312A06} = {DA049009-21FF-4AC0-84E4-830DD1BCD0CE}
+ {6D9E00D8-2893-45E4-9363-3F7F61D416BD} = {AF5BEC5C-1F2B-4DA8-B12D-D09FE569237C}
+ {70B35F59-AFC2-4D8F-8833-5314D2047A81} = {5317807F-61D4-4E0F-B6DC-2D9F12621ED9}
+ {3755E9F4-CB48-4EC3-B561-3B85964EBDEF} = {5317807F-61D4-4E0F-B6DC-2D9F12621ED9}
+ {F81C5819-85B4-4D2E-B6DC-104A7634461B} = {CC132A4D-D081-4C26-BFB9-AB11984054F8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E926C768-6307-4423-A1EC-57E95B1FAB29}
diff --git a/projects/VSCode/Makefile b/projects/VSCode/Makefile
index 9b8cbea1f..9ab042e8f 100644
--- a/projects/VSCode/Makefile
+++ b/projects/VSCode/Makefile
@@ -166,7 +166,7 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# HTML5 emscripten compiler
- # WARNING: To compile to HTML5, code must be redesigned
+ # WARNING: To compile to HTML5, code must be redesigned
# to use emscripten.h and emscripten_set_main_loop()
CC = emcc
endif
@@ -301,12 +301,12 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
-
+
# On X11 requires also below libraries
LDLIBS += -lX11
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
-
+
# On Wayland windowing system, additional libraries requires
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
@@ -358,7 +358,7 @@ OBJS ?= main.c
# For Android platform we call a custom Makefile.Android
ifeq ($(PLATFORM),PLATFORM_ANDROID)
- MAKEFILE_PARAMS = -f Makefile.Android
+ MAKEFILE_PARAMS = -f Makefile.Android
export PROJECT_NAME
export SRC_DIR
else
diff --git a/projects/VSCode/Makefile.Android b/projects/VSCode/Makefile.Android
index 29d437b1b..7e41ea52f 100644
--- a/projects/VSCode/Makefile.Android
+++ b/projects/VSCode/Makefile.Android
@@ -50,7 +50,7 @@ PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME)
PROJECT_RESOURCES_PATH ?= resources
PROJECT_SOURCE_FILES ?= raylib_game.c
-# Some source files are placed in directories, when compiling to some
+# Some source files are placed in directories, when compiling to some
# output directory other than source, that directory must pre-exist.
# Here we get a list of required folders that need to be created on
# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors.
@@ -77,7 +77,7 @@ RAYLIB_LIB_PATH = $(RAYLIB_PATH)\src
# Shared libs must be added to APK if required
# NOTE: Generated NativeLoader.java automatically load those libraries
ifeq ($(RAYLIB_LIBTYPE),SHARED)
- PROJECT_SHARED_LIBS = lib/$(ANDROID_ARCH_NAME)/libraylib.so
+ PROJECT_SHARED_LIBS = lib/$(ANDROID_ARCH_NAME)/libraylib.so
endif
# Compiler and archiver
@@ -109,8 +109,8 @@ CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION)
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external/android/native_app_glue
# Linker options
-LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a
-LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
+LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a
+LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
# Force linking of library module to define symbol
LDFLAGS += -u ANativeActivity_onCreate
# Library paths containing required libs
@@ -141,7 +141,7 @@ all: create_temp_project_dirs \
# Create required temp directories for APK building
create_temp_project_dirs:
- if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH)
+ if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH)
if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj
if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src
if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com
@@ -163,15 +163,15 @@ create_temp_project_dirs:
define create_dir
if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1)
endef
-
+
# Copy required shared libs for integration into APK
# NOTE: If using shared libs they are loaded by generated NativeLoader.java
copy_project_required_libs:
ifeq ($(RAYLIB_LIBTYPE),SHARED)
- copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.so
+ copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.so
endif
ifeq ($(RAYLIB_LIBTYPE),STATIC)
- copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.a
+ copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.a
endif
# Copy project required resources: strings.xml, icon.png, assets
@@ -195,10 +195,10 @@ generate_loader_script:
ifeq ($(RAYLIB_LIBTYPE),SHARED)
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif
- @echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
+ @echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
-
+
# Generate AndroidManifest.xml with all the required options
# NOTE: Probably not the bet way to generate this file... but it works.
generate_android_manifest:
@@ -225,7 +225,7 @@ generate_android_manifest:
# Generate storekey for APK signing: $(PROJECT_NAME).keystore
# NOTE: Configure here your Distinguished Names (-dname) if required!
-generate_apk_keystore:
+generate_apk_keystore:
if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA
# Config project package and resource using AndroidManifest.xml and res/values/strings.xml
@@ -238,16 +238,16 @@ compile_native_app_glue:
$(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS)
$(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o
-# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so
+# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so
compile_project_code: $(OBJS)
$(CC) -o $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS)
# Compile all .c files required into object (.o) files
# NOTE: Those files will be linked into a shared library
$(PROJECT_BUILD_PATH)/obj/%.o:%.c
- $(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot
-
-# Compile project .java code into .class (Java bytecode)
+ $(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot
+
+# Compile project .java code into .class (Java bytecode)
compile_project_class:
$(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@@ -263,11 +263,11 @@ create_project_apk_package:
$(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin
cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS)
-# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk
+# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk
sign_project_apk_package:
$(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key
-# Create zip-aligned APK package: $(PROJECT_NAME).apk
+# Create zip-aligned APK package: $(PROJECT_NAME).apk
zipalign_project_apk_package:
$(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk
@@ -275,7 +275,7 @@ zipalign_project_apk_package:
# NOTE: Use -e (emulator) or -d (device) parameters if required
install:
$(ANDROID_PLATFORM_TOOLS)/adb install --abi $(ANDROID_ARCH_NAME) -rds $(PROJECT_NAME).apk
-
+
# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64)
check_device_abi:
$(ANDROID_PLATFORM_TOOLS)/adb shell getprop ro.product.cpu.abi
@@ -284,7 +284,7 @@ check_device_abi:
logcat:
$(ANDROID_PLATFORM_TOOLS)/adb logcat -c
$(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S
-
+
# Install and monitorize $(PROJECT_NAME).apk to default emulator/device
deploy:
$(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk
diff --git a/projects/VSCode/main.c b/projects/VSCode/main.c
index 2d7b121f9..f37b3b28d 100644
--- a/projects/VSCode/main.c
+++ b/projects/VSCode/main.c
@@ -15,7 +15,7 @@
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -39,7 +39,7 @@ static void UpdateDrawFrame(void); // Update and draw one frame
//----------------------------------------------------------------------------------
// Main entry point
//----------------------------------------------------------------------------------
-int main()
+int main()
{
// Initialization
//--------------------------------------------------------------------------------------
@@ -53,8 +53,6 @@ int main()
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.fovy = 60.0f;
camera.projection = CAMERA_PERSPECTIVE;
-
- SetCameraMode(camera, CAMERA_ORBITAL);
//--------------------------------------------------------------------------------------
@@ -84,7 +82,7 @@ static void UpdateDrawFrame(void)
{
// Update
//----------------------------------------------------------------------------------
- UpdateCamera(&camera);
+ UpdateCamera(&camera, CAMERA_ORBITAL);
//----------------------------------------------------------------------------------
// Draw
@@ -107,4 +105,4 @@ static void UpdateDrawFrame(void)
EndDrawing();
//----------------------------------------------------------------------------------
-}
\ No newline at end of file
+}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 21cd3d3f0..5092bdf47 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,7 +1,7 @@
# Setup the project and settings
project(raylib C)
-set(PROJECT_VERSION 4.2.0)
-set(API_VERSION 420)
+set(PROJECT_VERSION 4.5.0)
+set(API_VERSION 450)
include(GNUInstallDirs)
include(JoinPaths)
@@ -38,7 +38,9 @@ set(raylib_sources
)
# /cmake/GlfwImport.cmake handles the details around the inclusion of glfw
-include(GlfwImport)
+if (NOT ${PLATFORM} MATCHES "Web")
+ include(GlfwImport)
+endif ()
# Sets additional platform options and link libraries for each platform
# also selects the proper graphics API and version for that platform
@@ -60,7 +62,7 @@ if (NOT BUILD_SHARED_LIBS)
add_library(raylib_static ALIAS raylib)
else()
MESSAGE(STATUS "Building raylib shared library")
- if (MSVC)
+ if (WIN32)
target_compile_definitions(raylib
PRIVATE $
INTERFACE $
@@ -68,6 +70,10 @@ else()
endif ()
endif()
+if (${PLATFORM} MATCHES "Web")
+ target_link_options(raylib PRIVATE "-sUSE_GLFW=3")
+endif()
+
set_target_properties(raylib PROPERTIES
PUBLIC_HEADER "${raylib_public_headers}"
VERSION ${PROJECT_VERSION}
diff --git a/src/Makefile b/src/Makefile
index 291508edc..e9b68cd93 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -4,7 +4,7 @@
#
# Platforms supported:
# PLATFORM_DESKTOP: Windows (Win32, Win64)
-# PLATFORM_DESKTOP: Linux (i386, x64)
+# PLATFORM_DESKTOP: Linux (arm64, i386, x64)
# PLATFORM_DESKTOP: OSX/macOS (arm64, x86_64)
# PLATFORM_DESKTOP: FreeBSD, OpenBSD, NetBSD, DragonFly
# PLATFORM_ANDROID: Android (arm, i686, arm64, x86_64)
@@ -15,7 +15,7 @@
# Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline.
# Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline.
#
-# Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+# Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
@@ -45,8 +45,8 @@
PLATFORM ?= PLATFORM_DESKTOP
# Define required raylib variables
-RAYLIB_VERSION = 4.2.0
-RAYLIB_API_VERSION = 420
+RAYLIB_VERSION = 4.5.0
+RAYLIB_API_VERSION = 450
# Define raylib source code path
RAYLIB_SRC_PATH ?= ../src
@@ -95,12 +95,11 @@ USE_EXTERNAL_GLFW ?= FALSE
USE_WAYLAND_DISPLAY ?= FALSE
# Use cross-compiler for PLATFORM_RPI
-ifeq ($(PLATFORM),PLATFORM_RPI)
- USE_RPI_CROSS_COMPILER ?= FALSE
- ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
- RPI_TOOLCHAIN ?= C:/SysGCC/Raspberry
- RPI_TOOLCHAIN_SYSROOT ?= $(RPI_TOOLCHAIN)/arm-linux-gnueabihf/sysroot
- endif
+USE_RPI_CROSS_COMPILER ?= FALSE
+ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
+ RPI_TOOLCHAIN ?= C:/SysGCC/Raspberry
+ RPI_TOOLCHAIN_NAME ?= arm-linux-gnueabihf
+ RPI_TOOLCHAIN_SYSROOT ?= $(RPI_TOOLCHAIN)/$(RPI_TOOLCHAIN_NAME)/sysroot
endif
# Determine if the file has root access (only required to install raylib)
@@ -181,13 +180,15 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
- # Emscripten required variables
- EMSDK_PATH ?= C:/emsdk
- EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
- CLANG_PATH = $(EMSDK_PATH)/upstream/bin
- PYTHON_PATH = $(EMSDK_PATH)/python/3.9.2-1_64bit
- NODE_PATH = $(EMSDK_PATH)/node/14.15.5_64bit/bin
- export PATH := $(EMSDK_PATH):$(EMSCRIPTEN_PATH):$(CLANG_PATH):$(NODE_PATH):$(PYTHON_PATH):C:\raylib\MinGW\bin:$(PATH)
+ ifeq ($(PLATFORM_OS), WINDOWS)
+ # Emscripten required variables
+ EMSDK_PATH ?= C:/emsdk
+ EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
+ CLANG_PATH := $(EMSDK_PATH)/upstream/bin
+ PYTHON_PATH := $(EMSDK_PATH)/python/3.9.2-1_64bit
+ NODE_PATH := $(EMSDK_PATH)/node/14.15.5_64bit/bin
+ export PATH := $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:/raylib/MinGW/bin;$(PATH)
+ endif
endif
ifeq ($(PLATFORM),PLATFORM_ANDROID)
@@ -229,8 +230,10 @@ endif
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# By default use OpenGL 3.3 on desktop platforms
GRAPHICS ?= GRAPHICS_API_OPENGL_33
- #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
- #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
+ #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
+ #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
+ #GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3
+ #GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE)
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# On RPI OpenGL ES 2.0 must be used
@@ -243,6 +246,7 @@ endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0
GRAPHICS = GRAPHICS_API_OPENGL_ES2
+ #GRAPHICS = GRAPHICS_API_OPENGL_ES3 # Uncomment to use ES3/WebGL2 (preliminary support).
endif
ifeq ($(PLATFORM),PLATFORM_ANDROID)
# By default use OpenGL ES 2.0 on Android
@@ -269,8 +273,16 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# Define RPI cross-compiler
#CC = armv6j-hardfloat-linux-gnueabi-gcc
- CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
- AR = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-ar
+ CC = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-gcc
+ AR = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-ar
+ endif
+endif
+ifeq ($(PLATFORM),PLATFORM_DRM)
+ ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
+ # Define RPI cross-compiler
+ #CC = armv6j-hardfloat-linux-gnueabi-gcc
+ CC = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-gcc
+ AR = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-ar
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
@@ -387,7 +399,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
# -Werror=format-security
CFLAGS += -Wa,--noexecstack -Wformat -no-canonical-prefixes
# Preprocessor macro definitions
- CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) -DMAL_NO_OSS
+ CFLAGS += -D__ANDROID__ -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) -DMAL_NO_OSS
endif
# Define required compilation flags for raylib SHARED lib
@@ -407,6 +419,24 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS), LINUX)
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
CFLAGS += -D_GLFW_WAYLAND
+ LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
+
+ WL_PROTOCOLS_DIR := $(shell pkg-config wayland-protocols --variable=pkgdatadir)
+ WL_CLIENT_DIR := $(shell pkg-config wayland-client --variable=pkgdatadir)
+
+ wl_generate = \
+ $(eval protocol=$(1)) \
+ $(eval basename=$(2)) \
+ $(shell wayland-scanner client-header $(protocol) $(RAYLIB_SRC_PATH)/$(basename).h) \
+ $(shell wayland-scanner private-code $(protocol) $(RAYLIB_SRC_PATH)/$(basename)-code.h)
+
+ $(call wl_generate, $(WL_CLIENT_DIR)/wayland.xml, wayland-client-protocol)
+ $(call wl_generate, $(WL_PROTOCOLS_DIR)/stable/xdg-shell/xdg-shell.xml, wayland-xdg-shell-client-protocol)
+ $(call wl_generate, $(WL_PROTOCOLS_DIR)/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml, wayland-xdg-decoration-client-protocol)
+ $(call wl_generate, $(WL_PROTOCOLS_DIR)/stable/viewporter/viewporter.xml, wayland-viewporter-client-protocol)
+ $(call wl_generate, $(WL_PROTOCOLS_DIR)/unstable/relative-pointer/relative-pointer-unstable-v1.xml, wayland-relative-pointer-unstable-v1-client-protocol)
+ $(call wl_generate, $(WL_PROTOCOLS_DIR)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml, wayland-pointer-constraints-unstable-v1-client-protocol)
+ $(call wl_generate, $(WL_PROTOCOLS_DIR)/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml, wayland-idle-inhibit-unstable-v1-client-protocol)
endif
endif
endif
@@ -429,6 +459,10 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif
ifeq ($(PLATFORM),PLATFORM_DRM)
INCLUDE_PATHS += -I/usr/include/libdrm
+ ifeq ($(USE_RPI_CROSSCOMPILER), TRUE)
+ INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/usr/include
+ INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include
+ endif
endif
ifeq ($(PLATFORM),PLATFORM_ANDROID)
NATIVE_APP_GLUE = $(ANDROID_NDK)/sources/android/native_app_glue
@@ -477,9 +511,12 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif
ifeq ($(PLATFORM),PLATFORM_DRM)
LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
+ ifeq ($(USE_RPI_CROSSCOMPILER), TRUE)
+ INCLUDE_PATHS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib -L$(RPI_TOOLCHAIN_SYSROOT)/usr/lib
+ endif
endif
ifeq ($(PLATFORM),PLATFORM_ANDROID)
- LDFLAGS += -Wl,-soname,libraylib.$(API_VERSION).so -Wl,--exclude-libs,libatomic.a
+ LDFLAGS += -Wl,-soname,libraylib.$(RAYLIB_API_VERSION).so -Wl,--exclude-libs,libatomic.a
LDFLAGS += -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
# Force linking of library module to define symbol
LDFLAGS += -u ANativeActivity_onCreate
@@ -764,19 +801,19 @@ ifeq ($(ROOT),root)
# and $(RAYLIB_H_INSTALL_PATH). Please confirm each item.
ifeq ($(PLATFORM_OS),LINUX)
ifeq ($(RAYLIB_LIBTYPE),SHARED)
- rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so
- rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_API_VERSION)
- rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_VERSION)
- # Uncomment to clean up the runtime linker cache. See install target.
- ldconfig
+ rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so
+ rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_API_VERSION)
+ rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_VERSION)
+ # Uncomment to clean up the runtime linker cache. See install target.
+ ldconfig
else
- rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.a
+ rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.a
endif
rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raylib.h
rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raymath.h
rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rlgl.h
@echo "raylib development files removed!"
- else
+ else
@echo "This function currently works on GNU/Linux systems. Add yours today (^;"
endif
else
diff --git a/src/build.zig b/src/build.zig
index 8194e1e3c..27250f5ff 100644
--- a/src/build.zig
+++ b/src/build.zig
@@ -1,50 +1,106 @@
const std = @import("std");
-pub fn addRaylib(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.LibExeObjStep {
- // Standard release options allow the person running `zig build` to select
- // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
- const mode = b.standardReleaseOptions();
-
+// This has been tested to work with zig master branch as of commit 87de821 or May 14 2023
+pub fn addRaylib(b: *std.Build, target: std.zig.CrossTarget, optimize: std.builtin.OptimizeMode, options: Options) *std.Build.CompileStep {
const raylib_flags = &[_][]const u8{
"-std=gnu99",
- "-DPLATFORM_DESKTOP",
"-D_GNU_SOURCE",
"-DGL_SILENCE_DEPRECATION=199309L",
- "-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/1891
};
- const raylib = b.addStaticLibrary("raylib", srcdir ++ "/raylib.h");
- raylib.setTarget(target);
- raylib.setBuildMode(mode);
+ const raylib = b.addStaticLibrary(.{
+ .name = "raylib",
+ .target = target,
+ .optimize = optimize,
+ });
raylib.linkLibC();
- raylib.addIncludePath(srcdir ++ "/external/glfw/include");
+ // No GLFW required on PLATFORM_DRM
+ if (!options.platform_drm) {
+ raylib.addIncludePath(.{ .path = srcdir ++ "/external/glfw/include" });
+ }
raylib.addCSourceFiles(&.{
- srcdir ++ "/raudio.c",
srcdir ++ "/rcore.c",
- srcdir ++ "/rmodels.c",
- srcdir ++ "/rshapes.c",
- srcdir ++ "/rtext.c",
- srcdir ++ "/rtextures.c",
srcdir ++ "/utils.c",
}, raylib_flags);
- switch (raylib.target.toTarget().os.tag) {
+ if (options.raudio) {
+ raylib.addCSourceFiles(&.{
+ srcdir ++ "/raudio.c",
+ }, raylib_flags);
+ }
+ if (options.rmodels) {
+ raylib.addCSourceFiles(&.{
+ srcdir ++ "/rmodels.c",
+ }, &[_][]const u8{
+ "-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/1891
+ } ++ raylib_flags);
+ }
+ if (options.rshapes) {
+ raylib.addCSourceFiles(&.{
+ srcdir ++ "/rshapes.c",
+ }, raylib_flags);
+ }
+ if (options.rtext) {
+ raylib.addCSourceFiles(&.{
+ srcdir ++ "/rtext.c",
+ }, raylib_flags);
+ }
+ if (options.rtextures) {
+ raylib.addCSourceFiles(&.{
+ srcdir ++ "/rtextures.c",
+ }, raylib_flags);
+ }
+
+ var gen_step = std.build.Step.WriteFile.create(b);
+ raylib.step.dependOn(&gen_step.step);
+
+ if (options.raygui) {
+ _ = gen_step.add(srcdir ++ "/raygui.c", "#define RAYGUI_IMPLEMENTATION\n#include \"raygui.h\"\n");
+ raylib.addCSourceFile(.{ .file = .{ .path = srcdir ++ "/raygui.c" }, .flags = raylib_flags });
+ raylib.addIncludePath(.{ .path = srcdir });
+ raylib.addIncludePath(.{ .path = srcdir ++ "/../../raygui/src" });
+ }
+
+ switch (target.getOsTag()) {
.windows => {
raylib.addCSourceFiles(&.{srcdir ++ "/rglfw.c"}, raylib_flags);
raylib.linkSystemLibrary("winmm");
raylib.linkSystemLibrary("gdi32");
raylib.linkSystemLibrary("opengl32");
- raylib.addIncludePath("external/glfw/deps/mingw");
+ raylib.addIncludePath(.{ .path = "external/glfw/deps/mingw" });
+
+ raylib.defineCMacro("PLATFORM_DESKTOP", null);
},
.linux => {
- raylib.addCSourceFiles(&.{srcdir ++ "/rglfw.c"}, raylib_flags);
- raylib.linkSystemLibrary("GL");
- raylib.linkSystemLibrary("rt");
- raylib.linkSystemLibrary("dl");
- raylib.linkSystemLibrary("m");
- raylib.linkSystemLibrary("X11");
+ if (!options.platform_drm) {
+ raylib.addCSourceFiles(&.{srcdir ++ "/rglfw.c"}, raylib_flags);
+ raylib.linkSystemLibrary("GL");
+ raylib.linkSystemLibrary("rt");
+ raylib.linkSystemLibrary("dl");
+ raylib.linkSystemLibrary("m");
+ raylib.linkSystemLibrary("X11");
+ raylib.addLibraryPath(.{ .path = "/usr/lib" });
+ raylib.addIncludePath(.{ .path = "/usr/include" });
+
+ raylib.defineCMacro("PLATFORM_DESKTOP", null);
+ } else {
+ raylib.linkSystemLibrary("GLESv2");
+ raylib.linkSystemLibrary("EGL");
+ raylib.linkSystemLibrary("drm");
+ raylib.linkSystemLibrary("gbm");
+ raylib.linkSystemLibrary("pthread");
+ raylib.linkSystemLibrary("rt");
+ raylib.linkSystemLibrary("m");
+ raylib.linkSystemLibrary("dl");
+ raylib.addIncludePath(.{ .path = "/usr/include/libdrm" });
+
+ raylib.defineCMacro("PLATFORM_DRM", null);
+ raylib.defineCMacro("GRAPHICS_API_OPENGL_ES2", null);
+ raylib.defineCMacro("EGL_NO_X11", null);
+ raylib.defineCMacro("DEFAULT_BATCH_BUFFER_ELEMENT", "2048");
+ }
},
.freebsd, .openbsd, .netbsd, .dragonfly => {
raylib.addCSourceFiles(&.{srcdir ++ "/rglfw.c"}, raylib_flags);
@@ -58,6 +114,8 @@ pub fn addRaylib(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.
raylib.linkSystemLibrary("Xi");
raylib.linkSystemLibrary("Xxf86vm");
raylib.linkSystemLibrary("Xcursor");
+
+ raylib.defineCMacro("PLATFORM_DESKTOP", null);
},
.macos => {
// On macos rglfw.c include Objective-C files.
@@ -69,6 +127,28 @@ pub fn addRaylib(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.
raylib_flags ++ raylib_flags_extra_macos,
);
raylib.linkFramework("Foundation");
+ raylib.linkFramework("CoreServices");
+ raylib.linkFramework("CoreGraphics");
+ raylib.linkFramework("AppKit");
+ raylib.linkFramework("IOKit");
+
+ raylib.defineCMacro("PLATFORM_DESKTOP", null);
+ },
+ .emscripten => {
+ raylib.defineCMacro("PLATFORM_WEB", null);
+ raylib.defineCMacro("GRAPHICS_API_OPENGL_ES2", null);
+
+ if (b.sysroot == null) {
+ @panic("Pass '--sysroot \"$EMSDK/upstream/emscripten\"'");
+ }
+
+ const cache_include = std.fs.path.join(b.allocator, &.{ b.sysroot.?, "cache", "sysroot", "include" }) catch @panic("Out of memory");
+ defer b.allocator.free(cache_include);
+
+ var dir = std.fs.openDirAbsolute(cache_include, std.fs.Dir.OpenDirOptions{ .access_sub_paths = true, .no_follow = true }) catch @panic("No emscripten cache. Generate it!");
+ dir.close();
+
+ raylib.addIncludePath(.{ .path = cache_include });
},
else => {
@panic("Unsupported OS");
@@ -78,20 +158,53 @@ pub fn addRaylib(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.
return raylib;
}
-pub fn build(b: *std.build.Builder) void {
+pub const Options = struct {
+ raudio: bool = true,
+ rmodels: bool = true,
+ rshapes: bool = true,
+ rtext: bool = true,
+ rtextures: bool = true,
+ raygui: bool = false,
+ platform_drm: bool = false,
+};
+
+pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
+ // Standard optimization options allow the person running `zig build` to select
+ // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
+ // set a preferred release mode, allowing the user to decide how to optimize.
+ const optimize = b.standardOptimizeOption(.{});
- const lib = addRaylib(b, target);
- lib.setOutputDir(srcdir);
- lib.install();
+ const defaults = Options{};
+ const options = Options{
+ .platform_drm = b.option(bool, "platform_drm", "Compile raylib in native mode (no X11)") orelse defaults.platform_drm,
+ .raudio = b.option(bool, "raudio", "Compile with audio support") orelse defaults.raudio,
+ .rmodels = b.option(bool, "rmodels", "Compile with models support") orelse defaults.rmodels,
+ .rtext = b.option(bool, "rtext", "Compile with text support") orelse defaults.rtext,
+ .rtextures = b.option(bool, "rtextures", "Compile with textures support") orelse defaults.rtextures,
+ .rshapes = b.option(bool, "rshapes", "Compile with shapes support") orelse defaults.rshapes,
+ .raygui = b.option(bool, "raygui", "Compile with raygui support") orelse defaults.raygui,
+ };
+
+ const lib = addRaylib(b, target, optimize, options);
+
+ lib.installHeader("src/raylib.h", "raylib.h");
+ lib.installHeader("src/raymath.h", "raymath.h");
+ lib.installHeader("src/rlgl.h", "rlgl.h");
+
+ if (options.raygui) {
+ lib.installHeader("../raygui/src/raygui.h", "raygui.h");
+ }
+
+ b.installArtifact(lib);
}
-const srcdir = getSrcDir();
-
-fn getSrcDir() []const u8 {
- return std.fs.path.dirname(@src().file) orelse ".";
-}
+const srcdir = struct {
+ fn getSrcDir() []const u8 {
+ return std.fs.path.dirname(@src().file).?;
+ }
+}.getSrcDir();
diff --git a/src/config.h b/src/config.h
index 39d0b0f89..2c7d5e2d0 100644
--- a/src/config.h
+++ b/src/config.h
@@ -6,7 +6,7 @@
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2018-2022 Ahmad Fatoum & Ramon Santamaria (@raysan5)
+* Copyright (c) 2018-2023 Ahmad Fatoum & Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -25,64 +25,67 @@
*
**********************************************************************************************/
+#ifndef CONFIG_H
+#define CONFIG_H
+
//------------------------------------------------------------------------------------
// Module selection - Some modules could be avoided
// Mandatory modules: rcore, rlgl, utils
//------------------------------------------------------------------------------------
-#define SUPPORT_MODULE_RSHAPES 1
-#define SUPPORT_MODULE_RTEXTURES 1
-#define SUPPORT_MODULE_RTEXT 1 // WARNING: It requires SUPPORT_MODULE_RTEXTURES to load sprite font textures
-#define SUPPORT_MODULE_RMODELS 1
-#define SUPPORT_MODULE_RAUDIO 1
+#define SUPPORT_MODULE_RSHAPES 1
+#define SUPPORT_MODULE_RTEXTURES 1
+#define SUPPORT_MODULE_RTEXT 1 // WARNING: It requires SUPPORT_MODULE_RTEXTURES to load sprite font textures
+#define SUPPORT_MODULE_RMODELS 1
+#define SUPPORT_MODULE_RAUDIO 1
//------------------------------------------------------------------------------------
// Module: rcore - Configuration Flags
//------------------------------------------------------------------------------------
// Camera module is included (rcamera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital
-#define SUPPORT_CAMERA_SYSTEM 1
+#define SUPPORT_CAMERA_SYSTEM 1
// Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag
-#define SUPPORT_GESTURES_SYSTEM 1
+#define SUPPORT_GESTURES_SYSTEM 1
// Mouse gestures are directly mapped like touches and processed by gestures system
-#define SUPPORT_MOUSE_GESTURES 1
+#define SUPPORT_MOUSE_GESTURES 1
// Reconfigure standard input to receive key inputs, works with SSH connection.
-#define SUPPORT_SSH_KEYBOARD_RPI 1
+#define SUPPORT_SSH_KEYBOARD_RPI 1
// Setting a higher resolution can improve the accuracy of time-out intervals in wait functions.
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often.
-#define SUPPORT_WINMM_HIGHRES_TIMER 1
-// Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used
-//#define SUPPORT_BUSY_WAIT_LOOP 1
+#define SUPPORT_WINMM_HIGHRES_TIMER 1
+// Use busy wait loop for timing sync, if not defined, a high-resolution timer is set up and used
+//#define SUPPORT_BUSY_WAIT_LOOP 1
// Use a partial-busy wait loop, in this case frame sleeps for most of the time, but then runs a busy loop at the end for accuracy
#define SUPPORT_PARTIALBUSY_WAIT_LOOP
// Wait for events passively (sleeping while no events) instead of polling them actively every frame
-//#define SUPPORT_EVENTS_WAITING 1
+//#define SUPPORT_EVENTS_WAITING 1
// Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
-#define SUPPORT_SCREEN_CAPTURE 1
+#define SUPPORT_SCREEN_CAPTURE 1
// Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
-#define SUPPORT_GIF_RECORDING 1
+#define SUPPORT_GIF_RECORDING 1
// Support CompressData() and DecompressData() functions
-#define SUPPORT_COMPRESSION_API 1
+#define SUPPORT_COMPRESSION_API 1
// Support automatic generated events, loading and recording of those events when required
-//#define SUPPORT_EVENTS_AUTOMATION 1
+//#define SUPPORT_EVENTS_AUTOMATION 1
// Support custom frame control, only for advance users
-// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timming + PollInputEvents()
+// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents()
// Enabling this flag allows manual control of the frame processes, use at your own risk
-//#define SUPPORT_CUSTOM_FRAME_CONTROL 1
+//#define SUPPORT_CUSTOM_FRAME_CONTROL 1
// rcore: Configuration values
//------------------------------------------------------------------------------------
-#define MAX_FILEPATH_CAPACITY 8192 // Maximum file paths capacity
-#define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value)
+#define MAX_FILEPATH_CAPACITY 8192 // Maximum file paths capacity
+#define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value)
-#define MAX_KEYBOARD_KEYS 512 // Maximum number of keyboard keys supported
-#define MAX_MOUSE_BUTTONS 8 // Maximum number of mouse buttons supported
-#define MAX_GAMEPADS 4 // Maximum number of gamepads supported
-#define MAX_GAMEPAD_AXIS 8 // Maximum number of axis supported (per gamepad)
-#define MAX_GAMEPAD_BUTTONS 32 // Maximum number of buttons supported (per gamepad)
-#define MAX_TOUCH_POINTS 8 // Maximum number of touch points supported
-#define MAX_KEY_PRESSED_QUEUE 16 // Maximum number of keys in the key input queue
-#define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue
+#define MAX_KEYBOARD_KEYS 512 // Maximum number of keyboard keys supported
+#define MAX_MOUSE_BUTTONS 8 // Maximum number of mouse buttons supported
+#define MAX_GAMEPADS 4 // Maximum number of gamepads supported
+#define MAX_GAMEPAD_AXIS 8 // Maximum number of axis supported (per gamepad)
+#define MAX_GAMEPAD_BUTTONS 32 // Maximum number of buttons supported (per gamepad)
+#define MAX_TOUCH_POINTS 8 // Maximum number of touch points supported
+#define MAX_KEY_PRESSED_QUEUE 16 // Maximum number of keys in the key input queue
+#define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue
-#define MAX_DECOMPRESSION_SIZE 64 // Max size allocated for decompression in MB
+#define MAX_DECOMPRESSION_SIZE 64 // Max size allocated for decompression in MB
//------------------------------------------------------------------------------------
@@ -109,12 +112,12 @@
// Default shader vertex attribute names to set location points
// NOTE: When a new shader is loaded, the following locations are tried to be set for convenience
-#define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Binded by default to shader location: 0
-#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Binded by default to shader location: 1
-#define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Binded by default to shader location: 2
-#define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Binded by default to shader location: 3
-#define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Binded by default to shader location: 4
-#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Binded by default to shader location: 5
+#define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: 0
+#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: 1
+#define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: 2
+#define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: 3
+#define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: 4
+#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: 5
#define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix
#define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix
@@ -132,7 +135,7 @@
//------------------------------------------------------------------------------------
// Use QUADS instead of TRIANGLES for drawing when possible
// Some lines-based shapes could still use lines
-#define SUPPORT_QUADS_DRAW_MODE 1
+#define SUPPORT_QUADS_DRAW_MODE 1
//------------------------------------------------------------------------------------
@@ -147,7 +150,8 @@
#define SUPPORT_FILEFORMAT_QOI 1
//#define SUPPORT_FILEFORMAT_PSD 1
#define SUPPORT_FILEFORMAT_DDS 1
-#define SUPPORT_FILEFORMAT_HDR 1
+//#define SUPPORT_FILEFORMAT_HDR 1
+//#define SUPPORT_FILEFORMAT_PIC 1
//#define SUPPORT_FILEFORMAT_KTX 1
//#define SUPPORT_FILEFORMAT_ASTC 1
//#define SUPPORT_FILEFORMAT_PKM 1
@@ -155,12 +159,12 @@
#define SUPPORT_FILEFORMAT_SVG 1
// Support image export functionality (.png, .bmp, .tga, .jpg, .qoi)
-#define SUPPORT_IMAGE_EXPORT 1
+#define SUPPORT_IMAGE_EXPORT 1
// Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)
-#define SUPPORT_IMAGE_GENERATION 1
+#define SUPPORT_IMAGE_GENERATION 1
// Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop...
// If not defined, still some functions are supported: ImageFormat(), ImageCrop(), ImageToPOT()
-#define SUPPORT_IMAGE_MANIPULATION 1
+#define SUPPORT_IMAGE_MANIPULATION 1
//------------------------------------------------------------------------------------
@@ -168,51 +172,57 @@
//------------------------------------------------------------------------------------
// Default font is loaded on window initialization to be available for the user to render simple text
// NOTE: If enabled, uses external module functions to load default raylib font
-#define SUPPORT_DEFAULT_FONT 1
+#define SUPPORT_DEFAULT_FONT 1
// Selected desired font fileformats to be supported for loading
-#define SUPPORT_FILEFORMAT_FNT 1
-#define SUPPORT_FILEFORMAT_TTF 1
+#define SUPPORT_FILEFORMAT_FNT 1
+#define SUPPORT_FILEFORMAT_TTF 1
// Support text management functions
// If not defined, still some functions are supported: TextLength(), TextFormat()
-#define SUPPORT_TEXT_MANIPULATION 1
+#define SUPPORT_TEXT_MANIPULATION 1
+
+// On font atlas image generation [GenImageFontAtlas()], add a 3x3 pixels white rectangle
+// at the bottom-right corner of the atlas. It can be useful to for shapes drawing, to allow
+// drawing text and shapes with a single draw call [SetShapesTexture()].
+#define SUPPORT_FONT_ATLAS_WHITE_REC 1
// rtext: Configuration values
//------------------------------------------------------------------------------------
-#define MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers used on some functions:
+#define MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers used on some functions:
// TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal(), TextSplit()
-#define MAX_TEXTSPLIT_COUNT 128 // Maximum number of substrings to split: TextSplit()
+#define MAX_TEXTSPLIT_COUNT 128 // Maximum number of substrings to split: TextSplit()
//------------------------------------------------------------------------------------
// Module: rmodels - Configuration Flags
//------------------------------------------------------------------------------------
// Selected desired model fileformats to be supported for loading
-#define SUPPORT_FILEFORMAT_OBJ 1
-#define SUPPORT_FILEFORMAT_MTL 1
-#define SUPPORT_FILEFORMAT_IQM 1
-#define SUPPORT_FILEFORMAT_GLTF 1
-#define SUPPORT_FILEFORMAT_VOX 1
-#define SUPPORT_FILEFORMAT_M3D 1
+#define SUPPORT_FILEFORMAT_OBJ 1
+#define SUPPORT_FILEFORMAT_MTL 1
+#define SUPPORT_FILEFORMAT_IQM 1
+#define SUPPORT_FILEFORMAT_GLTF 1
+#define SUPPORT_FILEFORMAT_VOX 1
+#define SUPPORT_FILEFORMAT_M3D 1
// Support procedural mesh generation functions, uses external par_shapes.h library
// NOTE: Some generated meshes DO NOT include generated texture coordinates
-#define SUPPORT_MESH_GENERATION 1
+#define SUPPORT_MESH_GENERATION 1
// rmodels: Configuration values
//------------------------------------------------------------------------------------
-#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported
-#define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh
+#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported
+#define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh
//------------------------------------------------------------------------------------
// Module: raudio - Configuration Flags
//------------------------------------------------------------------------------------
// Desired audio fileformats to be supported for loading
-#define SUPPORT_FILEFORMAT_WAV 1
-#define SUPPORT_FILEFORMAT_OGG 1
-#define SUPPORT_FILEFORMAT_XM 1
-#define SUPPORT_FILEFORMAT_MOD 1
-#define SUPPORT_FILEFORMAT_MP3 1
-//#define SUPPORT_FILEFORMAT_FLAC 1
+#define SUPPORT_FILEFORMAT_WAV 1
+#define SUPPORT_FILEFORMAT_OGG 1
+#define SUPPORT_FILEFORMAT_MP3 1
+#define SUPPORT_FILEFORMAT_QOA 1
+//#define SUPPORT_FILEFORMAT_FLAC 1
+#define SUPPORT_FILEFORMAT_XM 1
+#define SUPPORT_FILEFORMAT_MOD 1
// raudio: Configuration values
//------------------------------------------------------------------------------------
@@ -226,12 +236,14 @@
// Module: utils - Configuration Flags
//------------------------------------------------------------------------------------
// Standard file io library (stdio.h) included
-#define SUPPORT_STANDARD_FILEIO
+#define SUPPORT_STANDARD_FILEIO 1
// Show TRACELOG() output messages
// NOTE: By default LOG_DEBUG traces not shown
-#define SUPPORT_TRACELOG 1
-//#define SUPPORT_TRACELOG_DEBUG 1
+#define SUPPORT_TRACELOG 1
+//#define SUPPORT_TRACELOG_DEBUG 1
// utils: Configuration values
//------------------------------------------------------------------------------------
-#define MAX_TRACELOG_MSG_LENGTH 128 // Max length of one trace-log message
+#define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message
+
+#endif // CONFIG_H
diff --git a/src/external/cgltf.h b/src/external/cgltf.h
index 02064103d..d2a909777 100644
--- a/src/external/cgltf.h
+++ b/src/external/cgltf.h
@@ -1,7 +1,7 @@
/**
* cgltf - a single-file glTF 2.0 parser written in C99.
*
- * Version: 1.12
+ * Version: 1.13
*
* Website: https://github.com/jkuhlmann/cgltf
*
@@ -65,7 +65,8 @@
*
* `cgltf_num_components` is a tiny utility that tells you the dimensionality of
* a certain accessor type. This can be used before `cgltf_accessor_unpack_floats` to help allocate
- * the necessary amount of memory.
+ * the necessary amount of memory. `cgltf_component_size` and `cgltf_calc_size` exist for
+ * similar purposes.
*
* `cgltf_accessor_read_float` reads a certain element from a non-sparse accessor and converts it to
* floating point, assuming that `cgltf_load_buffers` has already been called. The passed-in element
@@ -80,19 +81,16 @@
* `cgltf_accessor_read_index` is similar to its floating-point counterpart, but it returns size_t
* and only works with single-component data types.
*
- * `cgltf_result cgltf_copy_extras_json(const cgltf_data*, const cgltf_extras*,
- * char* dest, cgltf_size* dest_size)` allows users to retrieve the "extras" data that
- * can be attached to many glTF objects (which can be arbitrary JSON data). The
- * `cgltf_extras` struct stores the offsets of the start and end of the extras JSON data
- * as it appears in the complete glTF JSON data. This function copies the extras data
- * into the provided buffer. If `dest` is NULL, the length of the data is written into
- * `dest_size`. You can then parse this data using your own JSON parser
+ * `cgltf_copy_extras_json` allows users to retrieve the "extras" data that can be attached to many
+ * glTF objects (which can be arbitrary JSON data). This is a legacy function, consider using
+ * cgltf_extras::data directly instead. You can parse this data using your own JSON parser
* or, if you've included the cgltf implementation using the integrated JSMN JSON parser.
*/
#ifndef CGLTF_H_INCLUDED__
#define CGLTF_H_INCLUDED__
#include
+#include /* For uint8_t, uint32_t */
#ifdef __cplusplus
extern "C" {
@@ -256,8 +254,10 @@ typedef enum cgltf_data_free_method {
} cgltf_data_free_method;
typedef struct cgltf_extras {
- cgltf_size start_offset;
- cgltf_size end_offset;
+ cgltf_size start_offset; /* this field is deprecated and will be removed in the future; use data instead */
+ cgltf_size end_offset; /* this field is deprecated and will be removed in the future; use data instead */
+
+ char* data;
} cgltf_extras;
typedef struct cgltf_extension {
@@ -432,8 +432,6 @@ typedef struct cgltf_pbr_metallic_roughness
cgltf_float base_color_factor[4];
cgltf_float metallic_factor;
cgltf_float roughness_factor;
-
- cgltf_extras extras;
} cgltf_pbr_metallic_roughness;
typedef struct cgltf_pbr_specular_glossiness
@@ -833,14 +831,19 @@ void cgltf_free(cgltf_data* data);
void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix);
void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix);
+const uint8_t* cgltf_buffer_view_data(const cgltf_buffer_view* view);
+
cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size);
cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size);
cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index);
cgltf_size cgltf_num_components(cgltf_type type);
+cgltf_size cgltf_component_size(cgltf_component_type component_type);
+cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type);
cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count);
+/* this function is deprecated and will be removed in the future; use cgltf_extras::data instead */
cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size);
#ifdef __cplusplus
@@ -863,7 +866,6 @@ cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras*
#ifdef CGLTF_IMPLEMENTATION
-#include /* For uint8_t, uint32_t */
#include /* For strncpy */
#include /* For fopen */
#include /* For UINT_MAX etc */
@@ -905,15 +907,15 @@ enum jsmnerr {
};
typedef struct {
jsmntype_t type;
- int start;
- int end;
+ ptrdiff_t start;
+ ptrdiff_t end;
int size;
#ifdef JSMN_PARENT_LINKS
int parent;
#endif
} jsmntok_t;
typedef struct {
- unsigned int pos; /* offset in the JSON string */
+ size_t pos; /* offset in the JSON string */
unsigned int toknext; /* next token to allocate */
int toksuper; /* superior token node, e.g parent object or array */
} jsmn_parser;
@@ -924,12 +926,15 @@ static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t
*/
+#ifndef CGLTF_CONSTS
static const cgltf_size GlbHeaderSize = 12;
static const cgltf_size GlbChunkHeaderSize = 8;
static const uint32_t GlbVersion = 2;
static const uint32_t GlbMagic = 0x46546C67;
static const uint32_t GlbMagicJsonChunk = 0x4E4F534A;
static const uint32_t GlbMagicBinChunk = 0x004E4942;
+#define CGLTF_CONSTS
+#endif
#ifndef CGLTF_MALLOC
#define CGLTF_MALLOC(size) malloc(size)
@@ -1486,8 +1491,6 @@ cgltf_result cgltf_load_buffers(const cgltf_options* options, cgltf_data* data,
return cgltf_result_success;
}
-static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type);
-
static cgltf_size cgltf_calc_index_bound(cgltf_buffer_view* buffer_view, cgltf_size offset, cgltf_component_type component_type, cgltf_size count)
{
char* data = (char*)buffer_view->buffer->data + offset + buffer_view->offset;
@@ -1745,7 +1748,12 @@ cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras*
return cgltf_result_success;
}
-void cgltf_free_extensions(cgltf_data* data, cgltf_extension* extensions, cgltf_size extensions_count)
+static void cgltf_free_extras(cgltf_data* data, cgltf_extras* extras)
+{
+ data->memory.free_func(data->memory.user_data, extras->data);
+}
+
+static void cgltf_free_extensions(cgltf_data* data, cgltf_extension* extensions, cgltf_size extensions_count)
{
for (cgltf_size i = 0; i < extensions_count; ++i)
{
@@ -1755,6 +1763,12 @@ void cgltf_free_extensions(cgltf_data* data, cgltf_extension* extensions, cgltf_
data->memory.free_func(data->memory.user_data, extensions);
}
+static void cgltf_free_texture_view(cgltf_data* data, cgltf_texture_view* view)
+{
+ cgltf_free_extensions(data, view->extensions, view->extensions_count);
+ cgltf_free_extras(data, &view->extras);
+}
+
void cgltf_free(cgltf_data* data)
{
if (!data)
@@ -1770,6 +1784,7 @@ void cgltf_free(cgltf_data* data)
data->memory.free_func(data->memory.user_data, data->asset.min_version);
cgltf_free_extensions(data, data->asset.extensions, data->asset.extensions_count);
+ cgltf_free_extras(data, &data->asset.extras);
for (cgltf_size i = 0; i < data->accessors_count; ++i)
{
@@ -1780,8 +1795,12 @@ void cgltf_free(cgltf_data* data)
cgltf_free_extensions(data, data->accessors[i].sparse.extensions, data->accessors[i].sparse.extensions_count);
cgltf_free_extensions(data, data->accessors[i].sparse.indices_extensions, data->accessors[i].sparse.indices_extensions_count);
cgltf_free_extensions(data, data->accessors[i].sparse.values_extensions, data->accessors[i].sparse.values_extensions_count);
+ cgltf_free_extras(data, &data->accessors[i].sparse.extras);
+ cgltf_free_extras(data, &data->accessors[i].sparse.indices_extras);
+ cgltf_free_extras(data, &data->accessors[i].sparse.values_extras);
}
cgltf_free_extensions(data, data->accessors[i].extensions, data->accessors[i].extensions_count);
+ cgltf_free_extras(data, &data->accessors[i].extras);
}
data->memory.free_func(data->memory.user_data, data->accessors);
@@ -1791,6 +1810,7 @@ void cgltf_free(cgltf_data* data)
data->memory.free_func(data->memory.user_data, data->buffer_views[i].data);
cgltf_free_extensions(data, data->buffer_views[i].extensions, data->buffer_views[i].extensions_count);
+ cgltf_free_extras(data, &data->buffer_views[i].extras);
}
data->memory.free_func(data->memory.user_data, data->buffer_views);
@@ -1810,8 +1830,8 @@ void cgltf_free(cgltf_data* data)
data->memory.free_func(data->memory.user_data, data->buffers[i].uri);
cgltf_free_extensions(data, data->buffers[i].extensions, data->buffers[i].extensions_count);
+ cgltf_free_extras(data, &data->buffers[i].extras);
}
-
data->memory.free_func(data->memory.user_data, data->buffers);
for (cgltf_size i = 0; i < data->meshes_count; ++i)
@@ -1849,9 +1869,15 @@ void cgltf_free(cgltf_data* data)
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes);
}
+ for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k)
+ {
+ cgltf_free_extras(data, &data->meshes[i].primitives[j].mappings[k].extras);
+ }
+
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].mappings);
cgltf_free_extensions(data, data->meshes[i].primitives[j].extensions, data->meshes[i].primitives[j].extensions_count);
+ cgltf_free_extras(data, &data->meshes[i].primitives[j].extras);
}
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives);
@@ -1863,6 +1889,7 @@ void cgltf_free(cgltf_data* data)
}
cgltf_free_extensions(data, data->meshes[i].extensions, data->meshes[i].extensions_count);
+ cgltf_free_extras(data, &data->meshes[i].extras);
data->memory.free_func(data->memory.user_data, data->meshes[i].target_names);
}
@@ -1875,49 +1902,50 @@ void cgltf_free(cgltf_data* data)
if(data->materials[i].has_pbr_metallic_roughness)
{
- cgltf_free_extensions(data, data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.extensions, data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.extensions_count);
- cgltf_free_extensions(data, data->materials[i].pbr_metallic_roughness.base_color_texture.extensions, data->materials[i].pbr_metallic_roughness.base_color_texture.extensions_count);
+ cgltf_free_texture_view(data, &data->materials[i].pbr_metallic_roughness.metallic_roughness_texture);
+ cgltf_free_texture_view(data, &data->materials[i].pbr_metallic_roughness.base_color_texture);
}
if(data->materials[i].has_pbr_specular_glossiness)
{
- cgltf_free_extensions(data, data->materials[i].pbr_specular_glossiness.diffuse_texture.extensions, data->materials[i].pbr_specular_glossiness.diffuse_texture.extensions_count);
- cgltf_free_extensions(data, data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.extensions, data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.extensions_count);
+ cgltf_free_texture_view(data, &data->materials[i].pbr_specular_glossiness.diffuse_texture);
+ cgltf_free_texture_view(data, &data->materials[i].pbr_specular_glossiness.specular_glossiness_texture);
}
if(data->materials[i].has_clearcoat)
{
- cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_texture.extensions, data->materials[i].clearcoat.clearcoat_texture.extensions_count);
- cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_roughness_texture.extensions, data->materials[i].clearcoat.clearcoat_roughness_texture.extensions_count);
- cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_normal_texture.extensions, data->materials[i].clearcoat.clearcoat_normal_texture.extensions_count);
+ cgltf_free_texture_view(data, &data->materials[i].clearcoat.clearcoat_texture);
+ cgltf_free_texture_view(data, &data->materials[i].clearcoat.clearcoat_roughness_texture);
+ cgltf_free_texture_view(data, &data->materials[i].clearcoat.clearcoat_normal_texture);
}
if(data->materials[i].has_specular)
{
- cgltf_free_extensions(data, data->materials[i].specular.specular_texture.extensions, data->materials[i].specular.specular_texture.extensions_count);
- cgltf_free_extensions(data, data->materials[i].specular.specular_color_texture.extensions, data->materials[i].specular.specular_color_texture.extensions_count);
+ cgltf_free_texture_view(data, &data->materials[i].specular.specular_texture);
+ cgltf_free_texture_view(data, &data->materials[i].specular.specular_color_texture);
}
if(data->materials[i].has_transmission)
{
- cgltf_free_extensions(data, data->materials[i].transmission.transmission_texture.extensions, data->materials[i].transmission.transmission_texture.extensions_count);
+ cgltf_free_texture_view(data, &data->materials[i].transmission.transmission_texture);
}
if (data->materials[i].has_volume)
{
- cgltf_free_extensions(data, data->materials[i].volume.thickness_texture.extensions, data->materials[i].volume.thickness_texture.extensions_count);
+ cgltf_free_texture_view(data, &data->materials[i].volume.thickness_texture);
}
if(data->materials[i].has_sheen)
{
- cgltf_free_extensions(data, data->materials[i].sheen.sheen_color_texture.extensions, data->materials[i].sheen.sheen_color_texture.extensions_count);
- cgltf_free_extensions(data, data->materials[i].sheen.sheen_roughness_texture.extensions, data->materials[i].sheen.sheen_roughness_texture.extensions_count);
+ cgltf_free_texture_view(data, &data->materials[i].sheen.sheen_color_texture);
+ cgltf_free_texture_view(data, &data->materials[i].sheen.sheen_roughness_texture);
}
if(data->materials[i].has_iridescence)
{
- cgltf_free_extensions(data, data->materials[i].iridescence.iridescence_texture.extensions, data->materials[i].iridescence.iridescence_texture.extensions_count);
- cgltf_free_extensions(data, data->materials[i].iridescence.iridescence_thickness_texture.extensions, data->materials[i].iridescence.iridescence_thickness_texture.extensions_count);
+ cgltf_free_texture_view(data, &data->materials[i].iridescence.iridescence_texture);
+ cgltf_free_texture_view(data, &data->materials[i].iridescence.iridescence_thickness_texture);
}
- cgltf_free_extensions(data, data->materials[i].normal_texture.extensions, data->materials[i].normal_texture.extensions_count);
- cgltf_free_extensions(data, data->materials[i].occlusion_texture.extensions, data->materials[i].occlusion_texture.extensions_count);
- cgltf_free_extensions(data, data->materials[i].emissive_texture.extensions, data->materials[i].emissive_texture.extensions_count);
+ cgltf_free_texture_view(data, &data->materials[i].normal_texture);
+ cgltf_free_texture_view(data, &data->materials[i].occlusion_texture);
+ cgltf_free_texture_view(data, &data->materials[i].emissive_texture);
cgltf_free_extensions(data, data->materials[i].extensions, data->materials[i].extensions_count);
+ cgltf_free_extras(data, &data->materials[i].extras);
}
data->memory.free_func(data->memory.user_data, data->materials);
@@ -1929,6 +1957,7 @@ void cgltf_free(cgltf_data* data)
data->memory.free_func(data->memory.user_data, data->images[i].mime_type);
cgltf_free_extensions(data, data->images[i].extensions, data->images[i].extensions_count);
+ cgltf_free_extras(data, &data->images[i].extras);
}
data->memory.free_func(data->memory.user_data, data->images);
@@ -1936,7 +1965,9 @@ void cgltf_free(cgltf_data* data)
for (cgltf_size i = 0; i < data->textures_count; ++i)
{
data->memory.free_func(data->memory.user_data, data->textures[i].name);
+
cgltf_free_extensions(data, data->textures[i].extensions, data->textures[i].extensions_count);
+ cgltf_free_extras(data, &data->textures[i].extras);
}
data->memory.free_func(data->memory.user_data, data->textures);
@@ -1944,7 +1975,9 @@ void cgltf_free(cgltf_data* data)
for (cgltf_size i = 0; i < data->samplers_count; ++i)
{
data->memory.free_func(data->memory.user_data, data->samplers[i].name);
+
cgltf_free_extensions(data, data->samplers[i].extensions, data->samplers[i].extensions_count);
+ cgltf_free_extras(data, &data->samplers[i].extras);
}
data->memory.free_func(data->memory.user_data, data->samplers);
@@ -1955,6 +1988,7 @@ void cgltf_free(cgltf_data* data)
data->memory.free_func(data->memory.user_data, data->skins[i].joints);
cgltf_free_extensions(data, data->skins[i].extensions, data->skins[i].extensions_count);
+ cgltf_free_extras(data, &data->skins[i].extras);
}
data->memory.free_func(data->memory.user_data, data->skins);
@@ -1962,7 +1996,18 @@ void cgltf_free(cgltf_data* data)
for (cgltf_size i = 0; i < data->cameras_count; ++i)
{
data->memory.free_func(data->memory.user_data, data->cameras[i].name);
+
+ if (data->cameras[i].type == cgltf_camera_type_perspective)
+ {
+ cgltf_free_extras(data, &data->cameras[i].data.perspective.extras);
+ }
+ else if (data->cameras[i].type == cgltf_camera_type_orthographic)
+ {
+ cgltf_free_extras(data, &data->cameras[i].data.orthographic.extras);
+ }
+
cgltf_free_extensions(data, data->cameras[i].extensions, data->cameras[i].extensions_count);
+ cgltf_free_extras(data, &data->cameras[i].extras);
}
data->memory.free_func(data->memory.user_data, data->cameras);
@@ -1970,6 +2015,8 @@ void cgltf_free(cgltf_data* data)
for (cgltf_size i = 0; i < data->lights_count; ++i)
{
data->memory.free_func(data->memory.user_data, data->lights[i].name);
+
+ cgltf_free_extras(data, &data->lights[i].extras);
}
data->memory.free_func(data->memory.user_data, data->lights);
@@ -1979,7 +2026,19 @@ void cgltf_free(cgltf_data* data)
data->memory.free_func(data->memory.user_data, data->nodes[i].name);
data->memory.free_func(data->memory.user_data, data->nodes[i].children);
data->memory.free_func(data->memory.user_data, data->nodes[i].weights);
+
+ if (data->nodes[i].has_mesh_gpu_instancing)
+ {
+ for (cgltf_size j = 0; j < data->nodes[i].mesh_gpu_instancing.attributes_count; ++j)
+ {
+ data->memory.free_func(data->memory.user_data, data->nodes[i].mesh_gpu_instancing.attributes[j].name);
+ }
+
+ data->memory.free_func(data->memory.user_data, data->nodes[i].mesh_gpu_instancing.attributes);
+ }
+
cgltf_free_extensions(data, data->nodes[i].extensions, data->nodes[i].extensions_count);
+ cgltf_free_extras(data, &data->nodes[i].extras);
}
data->memory.free_func(data->memory.user_data, data->nodes);
@@ -1990,6 +2049,7 @@ void cgltf_free(cgltf_data* data)
data->memory.free_func(data->memory.user_data, data->scenes[i].nodes);
cgltf_free_extensions(data, data->scenes[i].extensions, data->scenes[i].extensions_count);
+ cgltf_free_extras(data, &data->scenes[i].extras);
}
data->memory.free_func(data->memory.user_data, data->scenes);
@@ -2000,16 +2060,19 @@ void cgltf_free(cgltf_data* data)
for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j)
{
cgltf_free_extensions(data, data->animations[i].samplers[j].extensions, data->animations[i].samplers[j].extensions_count);
+ cgltf_free_extras(data, &data->animations[i].samplers[j].extras);
}
data->memory.free_func(data->memory.user_data, data->animations[i].samplers);
for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j)
{
cgltf_free_extensions(data, data->animations[i].channels[j].extensions, data->animations[i].channels[j].extensions_count);
+ cgltf_free_extras(data, &data->animations[i].channels[j].extras);
}
data->memory.free_func(data->memory.user_data, data->animations[i].channels);
cgltf_free_extensions(data, data->animations[i].extensions, data->animations[i].extensions_count);
+ cgltf_free_extras(data, &data->animations[i].extras);
}
data->memory.free_func(data->memory.user_data, data->animations);
@@ -2017,11 +2080,14 @@ void cgltf_free(cgltf_data* data)
for (cgltf_size i = 0; i < data->variants_count; ++i)
{
data->memory.free_func(data->memory.user_data, data->variants[i].name);
+
+ cgltf_free_extras(data, &data->variants[i].extras);
}
data->memory.free_func(data->memory.user_data, data->variants);
cgltf_free_extensions(data, data->data_extensions, data->data_extensions_count);
+ cgltf_free_extras(data, &data->extras);
for (cgltf_size i = 0; i < data->extensions_used_count; ++i)
{
@@ -2152,7 +2218,7 @@ static cgltf_size cgltf_component_read_index(const void* in, cgltf_component_typ
case cgltf_component_type_r_32u:
return *((const uint32_t*) in);
case cgltf_component_type_r_32f:
- return (cgltf_size)*((const float*) in);
+ return (cgltf_size)((cgltf_ssize)*((const float*) in));
case cgltf_component_type_r_8u:
return *((const uint8_t*) in);
default:
@@ -2188,8 +2254,6 @@ static cgltf_float cgltf_component_read_float(const void* in, cgltf_component_ty
return (cgltf_float)cgltf_component_read_integer(in, component_type);
}
-static cgltf_size cgltf_component_size(cgltf_component_type component_type);
-
static cgltf_bool cgltf_element_read_float(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_bool normalized, cgltf_float* out, cgltf_size element_size)
{
cgltf_size num_components = cgltf_num_components(type);
@@ -2440,7 +2504,7 @@ static int cgltf_json_strcmp(jsmntok_t const* tok, const uint8_t* json_chunk, co
{
CGLTF_CHECK_TOKTYPE(*tok, JSMN_STRING);
size_t const str_len = strlen(str);
- size_t const name_length = tok->end - tok->start;
+ size_t const name_length = (size_t)(tok->end - tok->start);
return (str_len == name_length) ? strncmp((const char*)json_chunk + tok->start, str, str_len) : 128;
}
@@ -2448,7 +2512,7 @@ static int cgltf_json_to_int(jsmntok_t const* tok, const uint8_t* json_chunk)
{
CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE);
char tmp[128];
- int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1);
+ int size = (size_t)(tok->end - tok->start) < sizeof(tmp) ? (int)(tok->end - tok->start) : (int)(sizeof(tmp) - 1);
strncpy(tmp, (const char*)json_chunk + tok->start, size);
tmp[size] = 0;
return CGLTF_ATOI(tmp);
@@ -2458,7 +2522,7 @@ static cgltf_size cgltf_json_to_size(jsmntok_t const* tok, const uint8_t* json_c
{
CGLTF_CHECK_TOKTYPE_RETTYPE(*tok, JSMN_PRIMITIVE, cgltf_size);
char tmp[128];
- int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1);
+ int size = (size_t)(tok->end - tok->start) < sizeof(tmp) ? (int)(tok->end - tok->start) : (int)(sizeof(tmp) - 1);
strncpy(tmp, (const char*)json_chunk + tok->start, size);
tmp[size] = 0;
return (cgltf_size)CGLTF_ATOLL(tmp);
@@ -2468,7 +2532,7 @@ static cgltf_float cgltf_json_to_float(jsmntok_t const* tok, const uint8_t* json
{
CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE);
char tmp[128];
- int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1);
+ int size = (size_t)(tok->end - tok->start) < sizeof(tmp) ? (int)(tok->end - tok->start) : (int)(sizeof(tmp) - 1);
strncpy(tmp, (const char*)json_chunk + tok->start, size);
tmp[size] = 0;
return (cgltf_float)CGLTF_ATOF(tmp);
@@ -2476,7 +2540,7 @@ static cgltf_float cgltf_json_to_float(jsmntok_t const* tok, const uint8_t* json
static cgltf_bool cgltf_json_to_bool(jsmntok_t const* tok, const uint8_t* json_chunk)
{
- int size = tok->end - tok->start;
+ int size = (int)(tok->end - tok->start);
return size == 4 && memcmp(json_chunk + tok->start, "true", 4) == 0;
}
@@ -2542,7 +2606,7 @@ static int cgltf_parse_json_string(cgltf_options* options, jsmntok_t const* toke
{
return CGLTF_ERROR_JSON;
}
- int size = tokens[i].end - tokens[i].start;
+ int size = (int)(tokens[i].end - tokens[i].start);
char* result = (char*)options->memory.alloc_func(options->memory.user_data, size + 1);
if (!result)
{
@@ -2683,11 +2747,27 @@ static int cgltf_parse_json_attribute_list(cgltf_options* options, jsmntok_t con
return i;
}
-static int cgltf_parse_json_extras(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extras* out_extras)
+static int cgltf_parse_json_extras(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extras* out_extras)
{
- (void)json_chunk;
+ if (out_extras->data)
+ {
+ return CGLTF_ERROR_JSON;
+ }
+
+ /* fill deprecated fields for now, this will be removed in the future */
out_extras->start_offset = tokens[i].start;
out_extras->end_offset = tokens[i].end;
+
+ size_t start = tokens[i].start;
+ size_t size = tokens[i].end - start;
+ out_extras->data = (char*)options->memory.alloc_func(options->memory.user_data, size + 1);
+ if (!out_extras->data)
+ {
+ return CGLTF_ERROR_NOMEM;
+ }
+ strncpy(out_extras->data, (const char*)json_chunk + start, size);
+ out_extras->data[size] = '\0';
+
i = cgltf_skip_json(tokens, i);
return i;
}
@@ -2842,7 +2922,7 @@ static int cgltf_parse_json_material_mapping_data(cgltf_options* options, jsmnto
int material = -1;
int variants_tok = -1;
- cgltf_extras extras = {0, 0};
+ int extras_tok = -1;
for (int k = 0; k < obj_size; ++k)
{
@@ -2863,7 +2943,8 @@ static int cgltf_parse_json_material_mapping_data(cgltf_options* options, jsmnto
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &extras);
+ extras_tok = i + 1;
+ i = cgltf_skip_json(tokens, extras_tok);
}
else
{
@@ -2891,7 +2972,13 @@ static int cgltf_parse_json_material_mapping_data(cgltf_options* options, jsmnto
out_mappings[*offset].material = CGLTF_PTRINDEX(cgltf_material, material);
out_mappings[*offset].variant = variant;
- out_mappings[*offset].extras = extras;
+
+ if (extras_tok >= 0)
+ {
+ int e = cgltf_parse_json_extras(options, tokens, extras_tok, json_chunk, &out_mappings[*offset].extras);
+ if (e < 0)
+ return e;
+ }
(*offset)++;
}
@@ -3006,7 +3093,7 @@ static int cgltf_parse_json_primitive(cgltf_options* options, jsmntok_t const* t
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_prim->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_prim->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -3253,7 +3340,7 @@ static int cgltf_parse_json_accessor_sparse(cgltf_options* options, jsmntok_t co
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->indices_extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sparse->indices_extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -3296,7 +3383,7 @@ static int cgltf_parse_json_accessor_sparse(cgltf_options* options, jsmntok_t co
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->values_extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sparse->values_extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -3315,7 +3402,7 @@ static int cgltf_parse_json_accessor_sparse(cgltf_options* options, jsmntok_t co
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sparse->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -3438,7 +3525,7 @@ static int cgltf_parse_json_accessor(cgltf_options* options, jsmntok_t const* to
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_accessor->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_accessor->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -3544,7 +3631,7 @@ static int cgltf_parse_json_texture_view(cgltf_options* options, jsmntok_t const
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_texture_view->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_texture_view->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -3640,10 +3727,6 @@ static int cgltf_parse_json_pbr_metallic_roughness(cgltf_options* options, jsmnt
i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
&out_pbr->metallic_roughness_texture);
}
- else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
- {
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_pbr->extras);
- }
else
{
i = cgltf_skip_json(tokens, i+1);
@@ -4076,7 +4159,7 @@ static int cgltf_parse_json_image(cgltf_options* options, jsmntok_t const* token
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_image->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_image->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -4145,7 +4228,7 @@ static int cgltf_parse_json_sampler(cgltf_options* options, jsmntok_t const* tok
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sampler->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sampler->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -4194,7 +4277,7 @@ static int cgltf_parse_json_texture(cgltf_options* options, jsmntok_t const* tok
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_texture->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_texture->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -4357,7 +4440,7 @@ static int cgltf_parse_json_material(cgltf_options* options, jsmntok_t const* to
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_material->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_material->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -4710,7 +4793,7 @@ static int cgltf_parse_json_buffer_view(cgltf_options* options, jsmntok_t const*
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_buffer_view->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_buffer_view->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -4813,7 +4896,7 @@ static int cgltf_parse_json_buffer(cgltf_options* options, jsmntok_t const* toke
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_buffer->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_buffer->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -4897,7 +4980,7 @@ static int cgltf_parse_json_skin(cgltf_options* options, jsmntok_t const* tokens
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_skin->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_skin->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -4951,19 +5034,6 @@ static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* toke
{
i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_camera->name);
}
- else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0)
- {
- ++i;
- if (cgltf_json_strcmp(tokens + i, json_chunk, "perspective") == 0)
- {
- out_camera->type = cgltf_camera_type_perspective;
- }
- else if (cgltf_json_strcmp(tokens + i, json_chunk, "orthographic") == 0)
- {
- out_camera->type = cgltf_camera_type_orthographic;
- }
- ++i;
- }
else if (cgltf_json_strcmp(tokens+i, json_chunk, "perspective") == 0)
{
++i;
@@ -4973,6 +5043,11 @@ static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* toke
int data_size = tokens[i].size;
++i;
+ if (out_camera->type != cgltf_camera_type_invalid)
+ {
+ return CGLTF_ERROR_JSON;
+ }
+
out_camera->type = cgltf_camera_type_perspective;
for (int k = 0; k < data_size; ++k)
@@ -5007,7 +5082,7 @@ static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* toke
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->data.perspective.extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_camera->data.perspective.extras);
}
else
{
@@ -5029,6 +5104,11 @@ static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* toke
int data_size = tokens[i].size;
++i;
+ if (out_camera->type != cgltf_camera_type_invalid)
+ {
+ return CGLTF_ERROR_JSON;
+ }
+
out_camera->type = cgltf_camera_type_orthographic;
for (int k = 0; k < data_size; ++k)
@@ -5061,7 +5141,7 @@ static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* toke
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->data.orthographic.extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_camera->data.orthographic.extras);
}
else
{
@@ -5076,7 +5156,7 @@ static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* toke
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_camera->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -5209,7 +5289,7 @@ static int cgltf_parse_json_light(cgltf_options* options, jsmntok_t const* token
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_light->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_light->extras);
}
else
{
@@ -5335,7 +5415,7 @@ static int cgltf_parse_json_node(cgltf_options* options, jsmntok_t const* tokens
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_node->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_node->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -5473,7 +5553,7 @@ static int cgltf_parse_json_scene(cgltf_options* options, jsmntok_t const* token
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_scene->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_scene->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -5555,7 +5635,7 @@ static int cgltf_parse_json_animation_sampler(cgltf_options* options, jsmntok_t
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sampler->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sampler->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -5635,7 +5715,7 @@ static int cgltf_parse_json_animation_channel(cgltf_options* options, jsmntok_t
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_channel->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_channel->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -5717,7 +5797,7 @@ static int cgltf_parse_json_animation(cgltf_options* options, jsmntok_t const* t
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_animation->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_animation->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -5773,7 +5853,7 @@ static int cgltf_parse_json_variant(cgltf_options* options, jsmntok_t const* tok
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_variant->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_variant->extras);
}
else
{
@@ -5837,7 +5917,7 @@ static int cgltf_parse_json_asset(cgltf_options* options, jsmntok_t const* token
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_asset->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_asset->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -5884,7 +5964,7 @@ cgltf_size cgltf_num_components(cgltf_type type) {
}
}
-static cgltf_size cgltf_component_size(cgltf_component_type component_type) {
+cgltf_size cgltf_component_size(cgltf_component_type component_type) {
switch (component_type)
{
case cgltf_component_type_r_8:
@@ -5902,7 +5982,7 @@ static cgltf_size cgltf_component_size(cgltf_component_type component_type) {
}
}
-static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type)
+cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type)
{
cgltf_size component_size = cgltf_component_size(component_type);
if (type == cgltf_type_mat2 && component_size == 1)
@@ -5993,7 +6073,7 @@ static int cgltf_parse_json_root(cgltf_options* options, jsmntok_t const* tokens
}
else if (cgltf_json_strcmp(tokens+i, json_chunk, "extras") == 0)
{
- i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_data->extras);
+ i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_data->extras);
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
{
@@ -6420,7 +6500,7 @@ static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
* Fills token type and boundaries.
*/
static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
- int start, int end) {
+ ptrdiff_t start, ptrdiff_t end) {
token->type = type;
token->start = start;
token->end = end;
@@ -6433,7 +6513,7 @@ static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
size_t len, jsmntok_t *tokens, size_t num_tokens) {
jsmntok_t *token;
- int start;
+ ptrdiff_t start;
start = parser->pos;
@@ -6483,7 +6563,7 @@ static int jsmn_parse_string(jsmn_parser *parser, const char *js,
size_t len, jsmntok_t *tokens, size_t num_tokens) {
jsmntok_t *token;
- int start = parser->pos;
+ ptrdiff_t start = parser->pos;
parser->pos++;
diff --git a/src/external/dr_flac.h b/src/external/dr_flac.h
index e0b3649a2..0c43eed7f 100644
--- a/src/external/dr_flac.h
+++ b/src/external/dr_flac.h
@@ -1,6 +1,6 @@
/*
FLAC audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
-dr_flac - v0.12.31 - 2021-08-16
+dr_flac - v0.12.39 - 2022-09-17
David Reid - mackron@gmail.com
@@ -210,6 +210,9 @@ Build Options
#define DR_FLAC_NO_SIMD
Disables SIMD optimizations (SSE on x86/x64 architectures, NEON on ARM architectures). Use this if you are having compatibility issues with your compiler.
+#define DR_FLAC_NO_WCHAR
+ Disables all functions ending with `_w`. Use this if your compiler does not provide wchar.h. Not required if DR_FLAC_NO_STDIO is also defined.
+
Notes
@@ -232,7 +235,7 @@ extern "C" {
#define DRFLAC_VERSION_MAJOR 0
#define DRFLAC_VERSION_MINOR 12
-#define DRFLAC_VERSION_REVISION 31
+#define DRFLAC_VERSION_REVISION 39
#define DRFLAC_VERSION_STRING DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MAJOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MINOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_REVISION)
#include /* For size_t. */
@@ -244,7 +247,7 @@ typedef signed short drflac_int16;
typedef unsigned short drflac_uint16;
typedef signed int drflac_int32;
typedef unsigned int drflac_uint32;
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && !defined(__clang__)
typedef signed __int64 drflac_int64;
typedef unsigned __int64 drflac_uint64;
#else
@@ -261,7 +264,7 @@ typedef unsigned int drflac_uint32;
#pragma GCC diagnostic pop
#endif
#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__powerpc64__)
+#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined(_M_IA64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__powerpc64__)
typedef drflac_uint64 drflac_uintptr;
#else
typedef drflac_uint32 drflac_uintptr;
@@ -383,15 +386,13 @@ typedef enum
drflac_seek_origin_current
} drflac_seek_origin;
-/* Packing is important on this structure because we map this directly to the raw data within the SEEKTABLE metadata block. */
-#pragma pack(2)
+/* The order of members in this structure is important because we map this directly to the raw data within the SEEKTABLE metadata block. */
typedef struct
{
drflac_uint64 firstPCMFrame;
drflac_uint64 flacFrameOffset; /* The offset from the first byte of the header of the first frame. */
drflac_uint16 pcmFrameCount;
} drflac_seekpoint;
-#pragma pack()
typedef struct
{
@@ -1280,15 +1281,13 @@ typedef struct
const char* pRunningData;
} drflac_cuesheet_track_iterator;
-/* Packing is important on this structure because we map this directly to the raw data within the CUESHEET metadata block. */
-#pragma pack(4)
+/* The order of members here is important because we map this directly to the raw data within the CUESHEET metadata block. */
typedef struct
{
drflac_uint64 offset;
drflac_uint8 index;
drflac_uint8 reserved[3];
} drflac_cuesheet_track_index;
-#pragma pack()
typedef struct
{
@@ -1363,9 +1362,15 @@ DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterat
I am using "__inline__" only when we're compiling in strict ANSI mode.
*/
#if defined(__STRICT_ANSI__)
- #define DRFLAC_INLINE __inline__ __attribute__((always_inline))
+ #define DRFLAC_GNUC_INLINE_HINT __inline__
#else
- #define DRFLAC_INLINE inline __attribute__((always_inline))
+ #define DRFLAC_GNUC_INLINE_HINT inline
+ #endif
+
+ #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__)
+ #define DRFLAC_INLINE DRFLAC_GNUC_INLINE_HINT __attribute__((always_inline))
+ #else
+ #define DRFLAC_INLINE DRFLAC_GNUC_INLINE_HINT
#endif
#elif defined(__WATCOMC__)
#define DRFLAC_INLINE __inline
@@ -1378,7 +1383,7 @@ DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterat
#define DRFLAC_X64
#elif defined(__i386) || defined(_M_IX86)
#define DRFLAC_X86
-#elif defined(__arm__) || defined(_M_ARM) || defined(_M_ARM64)
+#elif defined(__arm__) || defined(_M_ARM) || defined(__arm64) || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
#define DRFLAC_ARM
#endif
@@ -1431,16 +1436,6 @@ Unfortuantely dr_flac depends on this for a few things so we're just going to di
#if defined(DRFLAC_ARM)
#if !defined(DRFLAC_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
#define DRFLAC_SUPPORT_NEON
- #endif
-
- /* Fall back to looking for the #include file. */
- #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
- #if !defined(DRFLAC_SUPPORT_NEON) && !defined(DRFLAC_NO_NEON) && __has_include()
- #define DRFLAC_SUPPORT_NEON
- #endif
- #endif
-
- #if defined(DRFLAC_SUPPORT_NEON)
#include
#endif
#endif
@@ -1519,9 +1514,7 @@ static DRFLAC_INLINE drflac_bool32 drflac_has_sse41(void)
{
#if defined(DRFLAC_SUPPORT_SSE41)
#if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE41)
- #if defined(DRFLAC_X64)
- return DRFLAC_TRUE; /* 64-bit targets always support SSE4.1. */
- #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE4_1__)
+ #if defined(__SSE4_1__) || defined(__AVX__)
return DRFLAC_TRUE; /* If the compiler is allowed to freely generate SSE41 code we can assume support. */
#else
#if defined(DRFLAC_NO_CPUID)
@@ -1586,18 +1579,21 @@ static DRFLAC_INLINE drflac_bool32 drflac_has_sse41(void)
extern __inline drflac_uint64 _watcom_bswap64(drflac_uint64);
#pragma aux _watcom_bswap16 = \
"xchg al, ah" \
- parm [ax] \
- modify [ax];
+ parm [ax] \
+ value [ax] \
+ modify nomemory;
#pragma aux _watcom_bswap32 = \
- "bswap eax" \
- parm [eax] \
- modify [eax];
+ "bswap eax" \
+ parm [eax] \
+ value [eax] \
+ modify nomemory;
#pragma aux _watcom_bswap64 = \
"bswap eax" \
"bswap edx" \
"xchg eax,edx" \
parm [eax edx] \
- modify [eax edx];
+ value [eax edx] \
+ modify nomemory;
#endif
@@ -1698,6 +1694,10 @@ typedef drflac_int32 drflac_result;
#define DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE 9
#define DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE 10
+#define DRFLAC_SEEKPOINT_SIZE_IN_BYTES 18
+#define DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES 36
+#define DRFLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES 12
+
#define drflac_align(x, a) ((((x) + (a) - 1) / (a)) * (a))
@@ -1909,6 +1909,12 @@ static DRFLAC_INLINE drflac_uint32 drflac__be2host_32(drflac_uint32 n)
return n;
}
+static DRFLAC_INLINE drflac_uint32 drflac__be2host_32_ptr_unaligned(const void* pData)
+{
+ const drflac_uint8* pNum = (drflac_uint8*)pData;
+ return *(pNum) << 24 | *(pNum+1) << 16 | *(pNum+2) << 8 | *(pNum+3);
+}
+
static DRFLAC_INLINE drflac_uint64 drflac__be2host_64(drflac_uint64 n)
{
if (drflac__is_little_endian()) {
@@ -1928,6 +1934,12 @@ static DRFLAC_INLINE drflac_uint32 drflac__le2host_32(drflac_uint32 n)
return n;
}
+static DRFLAC_INLINE drflac_uint32 drflac__le2host_32_ptr_unaligned(const void* pData)
+{
+ const drflac_uint8* pNum = (drflac_uint8*)pData;
+ return *pNum | *(pNum+1) << 8 | *(pNum+2) << 16 | *(pNum+3) << 24;
+}
+
static DRFLAC_INLINE drflac_uint32 drflac__unsynchsafe_32(drflac_uint32 n)
{
@@ -2429,6 +2441,10 @@ static DRFLAC_INLINE drflac_bool32 drflac__read_uint32(drflac_bs* bs, unsigned i
if (!drflac__reload_cache(bs)) {
return DRFLAC_FALSE;
}
+ if (bitCountLo > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
+ /* This happens when we get to end of stream */
+ return DRFLAC_FALSE;
+ }
*pResultOut = (resultHi << bitCountLo) | (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountLo);
bs->consumedBits += bitCountLo;
@@ -2684,6 +2700,10 @@ static drflac_bool32 drflac__find_and_seek_to_next_sync_code(drflac_bs* bs)
#if defined(__WATCOMC__) && defined(__386__)
#define DRFLAC_IMPLEMENT_CLZ_WATCOM
#endif
+#ifdef __MRC__
+#include
+#define DRFLAC_IMPLEMENT_CLZ_MRC
+#endif
static DRFLAC_INLINE drflac_uint32 drflac__clz_software(drflac_cache_t x)
{
@@ -2724,6 +2744,8 @@ static DRFLAC_INLINE drflac_bool32 drflac__is_lzcnt_supported(void)
/* Fast compile time check for ARM. */
#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
return DRFLAC_TRUE;
+#elif defined(__MRC__)
+ return DRFLAC_TRUE;
#else
/* If the compiler itself does not support the intrinsic then we'll need to return false. */
#ifdef DRFLAC_HAS_LZCNT_INTRINSIC
@@ -2833,6 +2855,15 @@ static DRFLAC_INLINE drflac_uint32 drflac__clz_msvc(drflac_cache_t x)
#ifdef DRFLAC_IMPLEMENT_CLZ_WATCOM
static __inline drflac_uint32 drflac__clz_watcom (drflac_uint32);
+#ifdef DRFLAC_IMPLEMENT_CLZ_WATCOM_LZCNT
+/* Use the LZCNT instruction (only available on some processors since the 2010s). */
+#pragma aux drflac__clz_watcom_lzcnt = \
+ "db 0F3h, 0Fh, 0BDh, 0C0h" /* lzcnt eax, eax */ \
+ parm [eax] \
+ value [eax] \
+ modify nomemory;
+#else
+/* Use the 386+-compatible implementation. */
#pragma aux drflac__clz_watcom = \
"bsr eax, eax" \
"xor eax, 31" \
@@ -2840,6 +2871,7 @@ static __inline drflac_uint32 drflac__clz_watcom (drflac_uint32);
value [eax] \
modify exact [eax] nomemory;
#endif
+#endif
static DRFLAC_INLINE drflac_uint32 drflac__clz(drflac_cache_t x)
{
@@ -2851,8 +2883,12 @@ static DRFLAC_INLINE drflac_uint32 drflac__clz(drflac_cache_t x)
{
#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
return drflac__clz_msvc(x);
+#elif defined(DRFLAC_IMPLEMENT_CLZ_WATCOM_LZCNT)
+ return drflac__clz_watcom_lzcnt(x);
#elif defined(DRFLAC_IMPLEMENT_CLZ_WATCOM)
return (x == 0) ? sizeof(x)*8 : drflac__clz_watcom(x);
+#elif defined(__MRC__)
+ return __cntlzw(x);
#else
return drflac__clz_software(x);
#endif
@@ -2872,9 +2908,24 @@ static DRFLAC_INLINE drflac_bool32 drflac__seek_past_next_set_bit(drflac_bs* bs,
}
}
+ if (bs->cache == 1) {
+ /* Not catching this would lead to undefined behaviour: a shift of a 32-bit number by 32 or more is undefined */
+ *pOffsetOut = zeroCounter + (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs) - 1;
+ if (!drflac__reload_cache(bs)) {
+ return DRFLAC_FALSE;
+ }
+
+ return DRFLAC_TRUE;
+ }
+
setBitOffsetPlus1 = drflac__clz(bs->cache);
setBitOffsetPlus1 += 1;
+ if (setBitOffsetPlus1 > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
+ /* This happens when we get to end of stream */
+ return DRFLAC_FALSE;
+ }
+
bs->consumedBits += setBitOffsetPlus1;
bs->cache <<= setBitOffsetPlus1;
@@ -2989,6 +3040,25 @@ static drflac_result drflac__read_utf8_coded_number(drflac_bs* bs, drflac_uint64
}
+static DRFLAC_INLINE drflac_uint32 drflac__ilog2_u32(drflac_uint32 x)
+{
+#if 1 /* Needs optimizing. */
+ drflac_uint32 result = 0;
+ while (x > 0) {
+ result += 1;
+ x >>= 1;
+ }
+
+ return result;
+#endif
+}
+
+static DRFLAC_INLINE drflac_bool32 drflac__use_64_bit_prediction(drflac_uint32 bitsPerSample, drflac_uint32 order, drflac_uint32 precision)
+{
+ /* https://web.archive.org/web/20220205005724/https://github.com/ietf-wg-cellar/flac-specification/blob/37a49aa48ba4ba12e8757badfc59c0df35435fec/rfc_backmatter.md */
+ return bitsPerSample + precision + drflac__ilog2_u32(order) > 32;
+}
+
/*
The next two functions are responsible for calculating the prediction.
@@ -2996,6 +3066,9 @@ The next two functions are responsible for calculating the prediction.
When the bits per sample is >16 we need to use 64-bit integer arithmetic because otherwise we'll run out of precision. It's
safe to assume this will be slower on 32-bit platforms so we use a more optimal solution when the bits per sample is <=16.
*/
+#if defined(__clang__)
+__attribute__((no_sanitize("signed-integer-overflow")))
+#endif
static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_32(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
{
drflac_int32 prediction = 0;
@@ -3231,7 +3304,7 @@ static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_64(drflac_uint32
Reference implementation for reading and decoding samples with residual. This is intentionally left unoptimized for the
sake of readability and should only be used as a reference.
*/
-static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
+static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
{
drflac_uint32 i;
@@ -3270,10 +3343,10 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drfla
}
- if (bitsPerSample+shift >= 32) {
- pSamplesOut[i] = decodedRice + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i);
+ if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
+ pSamplesOut[i] = decodedRice + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + i);
} else {
- pSamplesOut[i] = decodedRice + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i);
+ pSamplesOut[i] = decodedRice + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + i);
}
}
@@ -3370,6 +3443,10 @@ static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts(drflac_bs* bs, drflac
if (!drflac__reload_cache(bs)) {
return DRFLAC_FALSE;
}
+ if (bitCountLo > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
+ /* This happens when we get to end of stream */
+ return DRFLAC_FALSE;
+ }
}
riceParamPart = (drflac_uint32)(resultHi | DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, bitCountLo));
@@ -3450,6 +3527,10 @@ static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x1(drflac_bs* bs, drf
if (!drflac__reload_cache(bs)) {
return DRFLAC_FALSE;
}
+ if (riceParamPartLoBitCount > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
+ /* This happens when we get to end of stream */
+ return DRFLAC_FALSE;
+ }
bs_cache = bs->cache;
bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
@@ -3560,6 +3641,11 @@ static DRFLAC_INLINE drflac_bool32 drflac__seek_rice_parts(drflac_bs* bs, drflac
return DRFLAC_FALSE;
}
+ if (riceParamPartLoBitCount > DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
+ /* This happens when we get to end of stream */
+ return DRFLAC_FALSE;
+ }
+
bs_cache = bs->cache;
bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
}
@@ -3646,7 +3732,7 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar_zeroorde
return DRFLAC_TRUE;
}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
+static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
{
drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
drflac_uint32 zeroCountPart0 = 0;
@@ -3664,14 +3750,14 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_b
DRFLAC_ASSERT(bs != NULL);
DRFLAC_ASSERT(pSamplesOut != NULL);
- if (order == 0) {
- return drflac__decode_samples_with_residual__rice__scalar_zeroorder(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
+ if (lpcOrder == 0) {
+ return drflac__decode_samples_with_residual__rice__scalar_zeroorder(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
}
riceParamMask = (drflac_uint32)~((~0UL) << riceParam);
pSamplesOutEnd = pSamplesOut + (count & ~3);
- if (bitsPerSample+shift > 32) {
+ if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
while (pSamplesOut < pSamplesOutEnd) {
/*
Rice extraction. It's faster to do this one at a time against local variables than it is to use the x4 version
@@ -3699,10 +3785,10 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_b
riceParamPart2 = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
riceParamPart3 = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
- pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0);
- pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 1);
- pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 2);
- pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 3);
+ pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 0);
+ pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 1);
+ pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 2);
+ pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 3);
pSamplesOut += 4;
}
@@ -3730,10 +3816,10 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_b
riceParamPart2 = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
riceParamPart3 = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
- pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0);
- pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 1);
- pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 2);
- pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 3);
+ pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 0);
+ pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 1);
+ pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 2);
+ pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 3);
pSamplesOut += 4;
}
@@ -3753,10 +3839,10 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_b
/*riceParamPart0 = (riceParamPart0 >> 1) ^ (~(riceParamPart0 & 0x01) + 1);*/
/* Sample reconstruction. */
- if (bitsPerSample+shift > 32) {
- pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0);
+ if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
+ pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + 0);
} else {
- pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0);
+ pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + 0);
}
i += 1;
@@ -4212,20 +4298,20 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_64(drflac
return DRFLAC_TRUE;
}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
+static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
{
DRFLAC_ASSERT(bs != NULL);
DRFLAC_ASSERT(pSamplesOut != NULL);
/* In my testing the order is rarely > 12, so in this case I'm going to simplify the SSE implementation by only handling order <= 12. */
- if (order > 0 && order <= 12) {
- if (bitsPerSample+shift > 32) {
- return drflac__decode_samples_with_residual__rice__sse41_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
+ if (lpcOrder > 0 && lpcOrder <= 12) {
+ if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
+ return drflac__decode_samples_with_residual__rice__sse41_64(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
} else {
- return drflac__decode_samples_with_residual__rice__sse41_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
+ return drflac__decode_samples_with_residual__rice__sse41_32(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
}
} else {
- return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
+ return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
}
}
#endif
@@ -4364,7 +4450,7 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_32(drflac_
const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
- riceParamMask = ~((~0UL) << riceParam);
+ riceParamMask = (drflac_uint32)~((~0UL) << riceParam);
riceParamMask128 = vdupq_n_u32(riceParamMask);
riceParam128 = vdupq_n_s32(riceParam);
@@ -4550,10 +4636,13 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_
int32x4_t riceParam128;
int64x1_t shift64;
uint32x4_t one128;
+ int64x2_t prediction128 = { 0 };
+ uint32x4_t zeroCountPart128;
+ uint32x4_t riceParamPart128;
const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
- riceParamMask = ~((~0UL) << riceParam);
+ riceParamMask = (drflac_uint32)~((~0UL) << riceParam);
riceParamMask128 = vdupq_n_u32(riceParamMask);
riceParam128 = vdupq_n_s32(riceParam);
@@ -4562,7 +4651,7 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_
/*
Pre-loading the coefficients and prior samples is annoying because we need to ensure we don't try reading more than
- what's available in the input buffers. It would be conenient to use a fall-through switch to do this, but this results
+ what's available in the input buffers. It would be convenient to use a fall-through switch to do this, but this results
in strict aliasing warnings with GCC. To work around this I'm just doing something hacky. This feels a bit convoluted
so I think there's opportunity for this to be simplified.
*/
@@ -4630,10 +4719,6 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_
/* For this version we are doing one sample at a time. */
while (pDecodedSamples < pDecodedSamplesEnd) {
- int64x2_t prediction128;
- uint32x4_t zeroCountPart128;
- uint32x4_t riceParamPart128;
-
if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
@@ -4710,41 +4795,41 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_
return DRFLAC_TRUE;
}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
+static drflac_bool32 drflac__decode_samples_with_residual__rice__neon(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
{
DRFLAC_ASSERT(bs != NULL);
DRFLAC_ASSERT(pSamplesOut != NULL);
/* In my testing the order is rarely > 12, so in this case I'm going to simplify the NEON implementation by only handling order <= 12. */
- if (order > 0 && order <= 12) {
- if (bitsPerSample+shift > 32) {
- return drflac__decode_samples_with_residual__rice__neon_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
+ if (lpcOrder > 0 && lpcOrder <= 12) {
+ if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
+ return drflac__decode_samples_with_residual__rice__neon_64(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
} else {
- return drflac__decode_samples_with_residual__rice__neon_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
+ return drflac__decode_samples_with_residual__rice__neon_32(bs, count, riceParam, lpcOrder, lpcShift, coefficients, pSamplesOut);
}
} else {
- return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
+ return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
}
}
#endif
-static drflac_bool32 drflac__decode_samples_with_residual__rice(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
+static drflac_bool32 drflac__decode_samples_with_residual__rice(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
{
#if defined(DRFLAC_SUPPORT_SSE41)
if (drflac__gIsSSE41Supported) {
- return drflac__decode_samples_with_residual__rice__sse41(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
+ return drflac__decode_samples_with_residual__rice__sse41(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
} else
#elif defined(DRFLAC_SUPPORT_NEON)
if (drflac__gIsNEONSupported) {
- return drflac__decode_samples_with_residual__rice__neon(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
+ return drflac__decode_samples_with_residual__rice__neon(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
} else
#endif
{
/* Scalar fallback. */
#if 0
- return drflac__decode_samples_with_residual__rice__reference(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
+ return drflac__decode_samples_with_residual__rice__reference(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
#else
- return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
+ return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pSamplesOut);
#endif
}
}
@@ -4765,7 +4850,10 @@ static drflac_bool32 drflac__read_and_seek_residual__rice(drflac_bs* bs, drflac_
return DRFLAC_TRUE;
}
-static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 unencodedBitsPerSample, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
+#if defined(__clang__)
+__attribute__((no_sanitize("signed-integer-overflow")))
+#endif
+static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 unencodedBitsPerSample, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
{
drflac_uint32 i;
@@ -4782,10 +4870,10 @@ static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs*
pSamplesOut[i] = 0;
}
- if (bitsPerSample >= 24) {
- pSamplesOut[i] += drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i);
+ if (drflac__use_64_bit_prediction(bitsPerSample, lpcOrder, lpcPrecision)) {
+ pSamplesOut[i] += drflac__calculate_prediction_64(lpcOrder, lpcShift, coefficients, pSamplesOut + i);
} else {
- pSamplesOut[i] += drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i);
+ pSamplesOut[i] += drflac__calculate_prediction_32(lpcOrder, lpcShift, coefficients, pSamplesOut + i);
}
}
@@ -4798,7 +4886,7 @@ Reads and decodes the residual for the sub-frame the decoder is currently sittin
when the decoder is sitting at the very start of the RESIDUAL block. The first residuals will be ignored. The
and parameters are used to determine how many residual values need to be decoded.
*/
-static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 blockSize, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
+static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 blockSize, drflac_uint32 lpcOrder, drflac_int32 lpcShift, drflac_uint32 lpcPrecision, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
{
drflac_uint8 residualMethod;
drflac_uint8 partitionOrder;
@@ -4818,7 +4906,7 @@ static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_
}
/* Ignore the first values. */
- pDecodedSamples += order;
+ pDecodedSamples += lpcOrder;
if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
return DRFLAC_FALSE;
@@ -4833,11 +4921,11 @@ static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_
}
/* Validation check. */
- if ((blockSize / (1 << partitionOrder)) < order) {
+ if ((blockSize / (1 << partitionOrder)) < lpcOrder) {
return DRFLAC_FALSE;
}
- samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
+ samplesInPartition = (blockSize / (1 << partitionOrder)) - lpcOrder;
partitionsRemaining = (1 << partitionOrder);
for (;;) {
drflac_uint8 riceParam = 0;
@@ -4858,7 +4946,7 @@ static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_
}
if (riceParam != 0xFF) {
- if (!drflac__decode_samples_with_residual__rice(bs, bitsPerSample, samplesInPartition, riceParam, order, shift, coefficients, pDecodedSamples)) {
+ if (!drflac__decode_samples_with_residual__rice(bs, bitsPerSample, samplesInPartition, riceParam, lpcOrder, lpcShift, lpcPrecision, coefficients, pDecodedSamples)) {
return DRFLAC_FALSE;
}
} else {
@@ -4867,7 +4955,7 @@ static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_
return DRFLAC_FALSE;
}
- if (!drflac__decode_samples_with_residual__unencoded(bs, bitsPerSample, samplesInPartition, unencodedBitsPerSample, order, shift, coefficients, pDecodedSamples)) {
+ if (!drflac__decode_samples_with_residual__unencoded(bs, bitsPerSample, samplesInPartition, unencodedBitsPerSample, lpcOrder, lpcShift, lpcPrecision, coefficients, pDecodedSamples)) {
return DRFLAC_FALSE;
}
}
@@ -5036,7 +5124,7 @@ static drflac_bool32 drflac__decode_samples__fixed(drflac_bs* bs, drflac_uint32
pDecodedSamples[i] = sample;
}
- if (!drflac__decode_samples_with_residual(bs, subframeBitsPerSample, blockSize, lpcOrder, 0, lpcCoefficientsTable[lpcOrder], pDecodedSamples)) {
+ if (!drflac__decode_samples_with_residual(bs, subframeBitsPerSample, blockSize, lpcOrder, 0, 4, lpcCoefficientsTable[lpcOrder], pDecodedSamples)) {
return DRFLAC_FALSE;
}
@@ -5091,7 +5179,7 @@ static drflac_bool32 drflac__decode_samples__lpc(drflac_bs* bs, drflac_uint32 bl
}
}
- if (!drflac__decode_samples_with_residual(bs, bitsPerSample, blockSize, lpcOrder, lpcShift, coefficients, pDecodedSamples)) {
+ if (!drflac__decode_samples_with_residual(bs, bitsPerSample, blockSize, lpcOrder, lpcShift, lpcPrecision, coefficients, pDecodedSamples)) {
return DRFLAC_FALSE;
}
@@ -5219,6 +5307,9 @@ static drflac_bool32 drflac__read_next_flac_frame_header(drflac_bs* bs, drflac_u
return DRFLAC_FALSE;
}
crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 16);
+ if (header->blockSizeInPCMFrames == 0xFFFF) {
+ return DRFLAC_FALSE; /* Frame is too big. This is the size of the frame minus 1. The STREAMINFO block defines the max block size which is 16-bits. Adding one will make it 17 bits and therefore too big. */
+ }
header->blockSizeInPCMFrames += 1;
} else {
DRFLAC_ASSERT(blockSize >= 8);
@@ -5257,6 +5348,11 @@ static drflac_bool32 drflac__read_next_flac_frame_header(drflac_bs* bs, drflac_u
header->bitsPerSample = streaminfoBitsPerSample;
}
+ if (header->bitsPerSample != streaminfoBitsPerSample) {
+ /* If this subframe has a different bitsPerSample then streaminfo or the first frame, reject it */
+ return DRFLAC_FALSE;
+ }
+
if (!drflac__read_uint8(bs, 8, &header->crc8)) {
return DRFLAC_FALSE;
}
@@ -5343,6 +5439,11 @@ static drflac_bool32 drflac__decode_subframe(drflac_bs* bs, drflac_frame* frame,
subframeBitsPerSample += 1;
}
+ if (subframeBitsPerSample > 32) {
+ /* libFLAC and ffmpeg reject 33-bit subframes as well */
+ return DRFLAC_FALSE;
+ }
+
/* Need to handle wasted bits per sample. */
if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
return DRFLAC_FALSE;
@@ -6013,6 +6114,11 @@ static drflac_bool32 drflac__seek_to_pcm_frame__seek_table(drflac* pFlac, drflac
return DRFLAC_FALSE;
}
+ /* Do not use the seektable if pcmFramIndex is not coverd by it. */
+ if (pFlac->pSeekpoints[0].firstPCMFrame > pcmFrameIndex) {
+ return DRFLAC_FALSE;
+ }
+
for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
if (pFlac->pSeekpoints[iSeekpoint].firstPCMFrame >= pcmFrameIndex) {
break;
@@ -6360,7 +6466,7 @@ static void drflac__free_from_callbacks(void* p, const drflac_allocation_callbac
}
-static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_uint64* pFirstFramePos, drflac_uint64* pSeektablePos, drflac_uint32* pSeektableSize, drflac_allocation_callbacks* pAllocationCallbacks)
+static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_uint64* pFirstFramePos, drflac_uint64* pSeektablePos, drflac_uint32* pSeekpointCount, drflac_allocation_callbacks* pAllocationCallbacks)
{
/*
We want to keep track of the byte position in the stream of the seektable. At the time of calling this function we know that
@@ -6420,32 +6526,37 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
seektableSize = blockSize;
if (onMeta) {
+ drflac_uint32 seekpointCount;
drflac_uint32 iSeekpoint;
void* pRawData;
- pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
+ seekpointCount = blockSize/DRFLAC_SEEKPOINT_SIZE_IN_BYTES;
+
+ pRawData = drflac__malloc_from_callbacks(seekpointCount * sizeof(drflac_seekpoint), pAllocationCallbacks);
if (pRawData == NULL) {
return DRFLAC_FALSE;
}
- if (onRead(pUserData, pRawData, blockSize) != blockSize) {
- drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
- return DRFLAC_FALSE;
- }
-
- metadata.pRawData = pRawData;
- metadata.rawDataSize = blockSize;
- metadata.data.seektable.seekpointCount = blockSize/sizeof(drflac_seekpoint);
- metadata.data.seektable.pSeekpoints = (const drflac_seekpoint*)pRawData;
-
- /* Endian swap. */
- for (iSeekpoint = 0; iSeekpoint < metadata.data.seektable.seekpointCount; ++iSeekpoint) {
+ /* We need to read seekpoint by seekpoint and do some processing. */
+ for (iSeekpoint = 0; iSeekpoint < seekpointCount; ++iSeekpoint) {
drflac_seekpoint* pSeekpoint = (drflac_seekpoint*)pRawData + iSeekpoint;
+
+ if (onRead(pUserData, pSeekpoint, DRFLAC_SEEKPOINT_SIZE_IN_BYTES) != DRFLAC_SEEKPOINT_SIZE_IN_BYTES) {
+ drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
+ return DRFLAC_FALSE;
+ }
+
+ /* Endian swap. */
pSeekpoint->firstPCMFrame = drflac__be2host_64(pSeekpoint->firstPCMFrame);
pSeekpoint->flacFrameOffset = drflac__be2host_64(pSeekpoint->flacFrameOffset);
pSeekpoint->pcmFrameCount = drflac__be2host_16(pSeekpoint->pcmFrameCount);
}
+ metadata.pRawData = pRawData;
+ metadata.rawDataSize = blockSize;
+ metadata.data.seektable.seekpointCount = seekpointCount;
+ metadata.data.seektable.pSeekpoints = (const drflac_seekpoint*)pRawData;
+
onMeta(pUserDataMD, &metadata);
drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
@@ -6480,7 +6591,7 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
pRunningData = (const char*)pRawData;
pRunningDataEnd = (const char*)pRawData + blockSize;
- metadata.data.vorbis_comment.vendorLength = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
+ metadata.data.vorbis_comment.vendorLength = drflac__le2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
/* Need space for the rest of the block */
if ((pRunningDataEnd - pRunningData) - 4 < (drflac_int64)metadata.data.vorbis_comment.vendorLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
@@ -6488,7 +6599,7 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
return DRFLAC_FALSE;
}
metadata.data.vorbis_comment.vendor = pRunningData; pRunningData += metadata.data.vorbis_comment.vendorLength;
- metadata.data.vorbis_comment.commentCount = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
+ metadata.data.vorbis_comment.commentCount = drflac__le2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
/* Need space for 'commentCount' comments after the block, which at minimum is a drflac_uint32 per comment */
if ((pRunningDataEnd - pRunningData) / sizeof(drflac_uint32) < metadata.data.vorbis_comment.commentCount) { /* <-- Note the order of operations to avoid overflow to a valid value */
@@ -6506,7 +6617,7 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
return DRFLAC_FALSE;
}
- commentLength = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
+ commentLength = drflac__le2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
if (pRunningDataEnd - pRunningData < (drflac_int64)commentLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
return DRFLAC_FALSE;
@@ -6530,9 +6641,15 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
void* pRawData;
const char* pRunningData;
const char* pRunningDataEnd;
+ size_t bufferSize;
drflac_uint8 iTrack;
drflac_uint8 iIndex;
+ void* pTrackData;
+ /*
+ This needs to be loaded in two passes. The first pass is used to calculate the size of the memory allocation
+ we need for storing the necessary data. The second pass will fill that buffer with usable data.
+ */
pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
if (pRawData == NULL) {
return DRFLAC_FALSE;
@@ -6553,38 +6670,91 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
metadata.data.cuesheet.leadInSampleCount = drflac__be2host_64(*(const drflac_uint64*)pRunningData); pRunningData += 8;
metadata.data.cuesheet.isCD = (pRunningData[0] & 0x80) != 0; pRunningData += 259;
metadata.data.cuesheet.trackCount = pRunningData[0]; pRunningData += 1;
- metadata.data.cuesheet.pTrackData = pRunningData;
+ metadata.data.cuesheet.pTrackData = NULL; /* Will be filled later. */
- /* Check that the cuesheet tracks are valid before passing it to the callback */
- for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) {
- drflac_uint8 indexCount;
- drflac_uint32 indexPointSize;
+ /* Pass 1: Calculate the size of the buffer for the track data. */
+ {
+ const char* pRunningDataSaved = pRunningData; /* Will be restored at the end in preparation for the second pass. */
- if (pRunningDataEnd - pRunningData < 36) {
- drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
- return DRFLAC_FALSE;
+ bufferSize = metadata.data.cuesheet.trackCount * DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES;
+
+ for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) {
+ drflac_uint8 indexCount;
+ drflac_uint32 indexPointSize;
+
+ if (pRunningDataEnd - pRunningData < DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES) {
+ drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
+ return DRFLAC_FALSE;
+ }
+
+ /* Skip to the index point count */
+ pRunningData += 35;
+
+ indexCount = pRunningData[0];
+ pRunningData += 1;
+
+ bufferSize += indexCount * sizeof(drflac_cuesheet_track_index);
+
+ /* Quick validation check. */
+ indexPointSize = indexCount * DRFLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES;
+ if (pRunningDataEnd - pRunningData < (drflac_int64)indexPointSize) {
+ drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
+ return DRFLAC_FALSE;
+ }
+
+ pRunningData += indexPointSize;
}
- /* Skip to the index point count */
- pRunningData += 35;
- indexCount = pRunningData[0]; pRunningData += 1;
- indexPointSize = indexCount * sizeof(drflac_cuesheet_track_index);
- if (pRunningDataEnd - pRunningData < (drflac_int64)indexPointSize) {
- drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
- return DRFLAC_FALSE;
- }
-
- /* Endian swap. */
- for (iIndex = 0; iIndex < indexCount; ++iIndex) {
- drflac_cuesheet_track_index* pTrack = (drflac_cuesheet_track_index*)pRunningData;
- pRunningData += sizeof(drflac_cuesheet_track_index);
- pTrack->offset = drflac__be2host_64(pTrack->offset);
- }
+ pRunningData = pRunningDataSaved;
}
+ /* Pass 2: Allocate a buffer and fill the data. Validation was done in the step above so can be skipped. */
+ {
+ char* pRunningTrackData;
+
+ pTrackData = drflac__malloc_from_callbacks(bufferSize, pAllocationCallbacks);
+ if (pTrackData == NULL) {
+ drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
+ return DRFLAC_FALSE;
+ }
+
+ pRunningTrackData = (char*)pTrackData;
+
+ for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) {
+ drflac_uint8 indexCount;
+
+ DRFLAC_COPY_MEMORY(pRunningTrackData, pRunningData, DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES);
+ pRunningData += DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES-1; /* Skip forward, but not beyond the last byte in the CUESHEET_TRACK block which is the index count. */
+ pRunningTrackData += DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES-1;
+
+ /* Grab the index count for the next part. */
+ indexCount = pRunningData[0];
+ pRunningData += 1;
+ pRunningTrackData += 1;
+
+ /* Extract each track index. */
+ for (iIndex = 0; iIndex < indexCount; ++iIndex) {
+ drflac_cuesheet_track_index* pTrackIndex = (drflac_cuesheet_track_index*)pRunningTrackData;
+
+ DRFLAC_COPY_MEMORY(pRunningTrackData, pRunningData, DRFLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES);
+ pRunningData += DRFLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES;
+ pRunningTrackData += sizeof(drflac_cuesheet_track_index);
+
+ pTrackIndex->offset = drflac__be2host_64(pTrackIndex->offset);
+ }
+ }
+
+ metadata.data.cuesheet.pTrackData = pTrackData;
+ }
+
+ /* The original data is no longer needed. */
+ drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
+ pRawData = NULL;
+
onMeta(pUserDataMD, &metadata);
- drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
+ drflac__free_from_callbacks(pTrackData, pAllocationCallbacks);
+ pTrackData = NULL;
}
} break;
@@ -6615,28 +6785,28 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
pRunningData = (const char*)pRawData;
pRunningDataEnd = (const char*)pRawData + blockSize;
- metadata.data.picture.type = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
- metadata.data.picture.mimeLength = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
+ metadata.data.picture.type = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
+ metadata.data.picture.mimeLength = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
/* Need space for the rest of the block */
if ((pRunningDataEnd - pRunningData) - 24 < (drflac_int64)metadata.data.picture.mimeLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
return DRFLAC_FALSE;
}
- metadata.data.picture.mime = pRunningData; pRunningData += metadata.data.picture.mimeLength;
- metadata.data.picture.descriptionLength = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
+ metadata.data.picture.mime = pRunningData; pRunningData += metadata.data.picture.mimeLength;
+ metadata.data.picture.descriptionLength = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
/* Need space for the rest of the block */
if ((pRunningDataEnd - pRunningData) - 20 < (drflac_int64)metadata.data.picture.descriptionLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
return DRFLAC_FALSE;
}
- metadata.data.picture.description = pRunningData; pRunningData += metadata.data.picture.descriptionLength;
- metadata.data.picture.width = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
- metadata.data.picture.height = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
- metadata.data.picture.colorDepth = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
- metadata.data.picture.indexColorCount = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
- metadata.data.picture.pictureDataSize = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
+ metadata.data.picture.description = pRunningData; pRunningData += metadata.data.picture.descriptionLength;
+ metadata.data.picture.width = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
+ metadata.data.picture.height = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
+ metadata.data.picture.colorDepth = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
+ metadata.data.picture.indexColorCount = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
+ metadata.data.picture.pictureDataSize = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
metadata.data.picture.pPictureData = (const drflac_uint8*)pRunningData;
/* Need space for the picture after the block */
@@ -6714,9 +6884,9 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
}
}
- *pSeektablePos = seektablePos;
- *pSeektableSize = seektableSize;
- *pFirstFramePos = runningFilePos;
+ *pSeektablePos = seektablePos;
+ *pSeekpointCount = seektableSize / DRFLAC_SEEKPOINT_SIZE_IN_BYTES;
+ *pFirstFramePos = runningFilePos;
return DRFLAC_TRUE;
}
@@ -7746,11 +7916,11 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
drflac_uint32 wholeSIMDVectorCountPerChannel;
drflac_uint32 decodedSamplesAllocationSize;
#ifndef DR_FLAC_NO_OGG
- drflac_oggbs oggbs;
+ drflac_oggbs* pOggbs = NULL;
#endif
drflac_uint64 firstFramePos;
drflac_uint64 seektablePos;
- drflac_uint32 seektableSize;
+ drflac_uint32 seekpointCount;
drflac_allocation_callbacks allocationCallbacks;
drflac* pFlac;
@@ -7804,18 +7974,21 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
/* There's additional data required for Ogg streams. */
if (init.container == drflac_container_ogg) {
allocationSize += sizeof(drflac_oggbs);
- }
- DRFLAC_ZERO_MEMORY(&oggbs, sizeof(oggbs));
- if (init.container == drflac_container_ogg) {
- oggbs.onRead = onRead;
- oggbs.onSeek = onSeek;
- oggbs.pUserData = pUserData;
- oggbs.currentBytePos = init.oggFirstBytePos;
- oggbs.firstBytePos = init.oggFirstBytePos;
- oggbs.serialNumber = init.oggSerial;
- oggbs.bosPageHeader = init.oggBosHeader;
- oggbs.bytesRemainingInPage = 0;
+ pOggbs = (drflac_oggbs*)drflac__malloc_from_callbacks(sizeof(*pOggbs), &allocationCallbacks);
+ if (pOggbs == NULL) {
+ return NULL; /*DRFLAC_OUT_OF_MEMORY;*/
+ }
+
+ DRFLAC_ZERO_MEMORY(pOggbs, sizeof(*pOggbs));
+ pOggbs->onRead = onRead;
+ pOggbs->onSeek = onSeek;
+ pOggbs->pUserData = pUserData;
+ pOggbs->currentBytePos = init.oggFirstBytePos;
+ pOggbs->firstBytePos = init.oggFirstBytePos;
+ pOggbs->serialNumber = init.oggSerial;
+ pOggbs->bosPageHeader = init.oggBosHeader;
+ pOggbs->bytesRemainingInPage = 0;
}
#endif
@@ -7824,9 +7997,9 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
consist of only a single heap allocation. To this, the size of the seek table needs to be known, which we determine when reading
and decoding the metadata.
*/
- firstFramePos = 42; /* <-- We know we are at byte 42 at this point. */
- seektablePos = 0;
- seektableSize = 0;
+ firstFramePos = 42; /* <-- We know we are at byte 42 at this point. */
+ seektablePos = 0;
+ seekpointCount = 0;
if (init.hasMetadataBlocks) {
drflac_read_proc onReadOverride = onRead;
drflac_seek_proc onSeekOverride = onSeek;
@@ -7836,20 +8009,26 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
if (init.container == drflac_container_ogg) {
onReadOverride = drflac__on_read_ogg;
onSeekOverride = drflac__on_seek_ogg;
- pUserDataOverride = (void*)&oggbs;
+ pUserDataOverride = (void*)pOggbs;
}
#endif
- if (!drflac__read_and_decode_metadata(onReadOverride, onSeekOverride, onMeta, pUserDataOverride, pUserDataMD, &firstFramePos, &seektablePos, &seektableSize, &allocationCallbacks)) {
+ if (!drflac__read_and_decode_metadata(onReadOverride, onSeekOverride, onMeta, pUserDataOverride, pUserDataMD, &firstFramePos, &seektablePos, &seekpointCount, &allocationCallbacks)) {
+ #ifndef DR_FLAC_NO_OGG
+ drflac__free_from_callbacks(pOggbs, &allocationCallbacks);
+ #endif
return NULL;
}
- allocationSize += seektableSize;
+ allocationSize += seekpointCount * sizeof(drflac_seekpoint);
}
pFlac = (drflac*)drflac__malloc_from_callbacks(allocationSize, &allocationCallbacks);
if (pFlac == NULL) {
+ #ifndef DR_FLAC_NO_OGG
+ drflac__free_from_callbacks(pOggbs, &allocationCallbacks);
+ #endif
return NULL;
}
@@ -7859,8 +8038,12 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
#ifndef DR_FLAC_NO_OGG
if (init.container == drflac_container_ogg) {
- drflac_oggbs* pInternalOggbs = (drflac_oggbs*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize + seektableSize);
- *pInternalOggbs = oggbs;
+ drflac_oggbs* pInternalOggbs = (drflac_oggbs*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize + (seekpointCount * sizeof(drflac_seekpoint)));
+ DRFLAC_COPY_MEMORY(pInternalOggbs, pOggbs, sizeof(*pOggbs));
+
+ /* At this point the pOggbs object has been handed over to pInternalOggbs and can be freed. */
+ drflac__free_from_callbacks(pOggbs, &allocationCallbacks);
+ pOggbs = NULL;
/* The Ogg bistream needs to be layered on top of the original bitstream. */
pFlac->bs.onRead = drflac__on_read_ogg;
@@ -7884,7 +8067,7 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
{
/* If we have a seektable we need to load it now, making sure we move back to where we were previously. */
if (seektablePos != 0) {
- pFlac->seekpointCount = seektableSize / sizeof(*pFlac->pSeekpoints);
+ pFlac->seekpointCount = seekpointCount;
pFlac->pSeekpoints = (drflac_seekpoint*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize);
DRFLAC_ASSERT(pFlac->bs.onSeek != NULL);
@@ -7892,18 +8075,20 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
/* Seek to the seektable, then just read directly into our seektable buffer. */
if (pFlac->bs.onSeek(pFlac->bs.pUserData, (int)seektablePos, drflac_seek_origin_start)) {
- if (pFlac->bs.onRead(pFlac->bs.pUserData, pFlac->pSeekpoints, seektableSize) == seektableSize) {
- /* Endian swap. */
- drflac_uint32 iSeekpoint;
- for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
+ drflac_uint32 iSeekpoint;
+
+ for (iSeekpoint = 0; iSeekpoint < seekpointCount; iSeekpoint += 1) {
+ if (pFlac->bs.onRead(pFlac->bs.pUserData, pFlac->pSeekpoints + iSeekpoint, DRFLAC_SEEKPOINT_SIZE_IN_BYTES) == DRFLAC_SEEKPOINT_SIZE_IN_BYTES) {
+ /* Endian swap. */
pFlac->pSeekpoints[iSeekpoint].firstPCMFrame = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].firstPCMFrame);
pFlac->pSeekpoints[iSeekpoint].flacFrameOffset = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].flacFrameOffset);
pFlac->pSeekpoints[iSeekpoint].pcmFrameCount = drflac__be2host_16(pFlac->pSeekpoints[iSeekpoint].pcmFrameCount);
+ } else {
+ /* Failed to read the seektable. Pretend we don't have one. */
+ pFlac->pSeekpoints = NULL;
+ pFlac->seekpointCount = 0;
+ break;
}
- } else {
- /* Failed to read the seektable. Pretend we don't have one. */
- pFlac->pSeekpoints = NULL;
- pFlac->seekpointCount = 0;
}
/* We need to seek back to where we were. If this fails it's a critical error. */
@@ -7952,7 +8137,9 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
#ifndef DR_FLAC_NO_STDIO
#include
+#ifndef DR_FLAC_NO_WCHAR
#include /* For wcslen(), wcsrtombs() */
+#endif
/* drflac_result_from_errno() is only used for fopen() and wfopen() so putting it inside DR_WAV_NO_STDIO for now. If something else needs this later we can move it out. */
#include
@@ -8418,6 +8605,7 @@ fallback, so if you notice your compiler not detecting this properly I'm happy t
#endif
#endif
+#ifndef DR_FLAC_NO_WCHAR
static drflac_result drflac_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drflac_allocation_callbacks* pAllocationCallbacks)
{
if (ppFile != NULL) {
@@ -8446,10 +8634,23 @@ static drflac_result drflac_wfopen(FILE** ppFile, const wchar_t* pFilePath, cons
}
#else
/*
- Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can
- think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
- maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility.
+ Use fopen() on anything other than Windows. Requires a conversion. This is annoying because
+ fopen() is locale specific. The only real way I can think of to do this is with wcsrtombs(). Note
+ that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
+ maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler
+ error I'll look into improving compatibility.
*/
+
+ /*
+ Some compilers don't support wchar_t or wcsrtombs() which we're using below. In this case we just
+ need to abort with an error. If you encounter a compiler lacking such support, add it to this list
+ and submit a bug report and it'll be added to the library upstream.
+ */
+ #if defined(__DJGPP__)
+ {
+ /* Nothing to do here. This will fall through to the error check below. */
+ }
+ #else
{
mbstate_t mbs;
size_t lenMB;
@@ -8491,6 +8692,7 @@ static drflac_result drflac_wfopen(FILE** ppFile, const wchar_t* pFilePath, cons
drflac__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
}
+ #endif
if (*ppFile == NULL) {
return DRFLAC_ERROR;
@@ -8499,6 +8701,7 @@ static drflac_result drflac_wfopen(FILE** ppFile, const wchar_t* pFilePath, cons
return DRFLAC_SUCCESS;
}
+#endif
static size_t drflac__on_read_stdio(void* pUserData, void* bufferOut, size_t bytesToRead)
{
@@ -8531,6 +8734,7 @@ DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocati
return pFlac;
}
+#ifndef DR_FLAC_NO_WCHAR
DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
{
drflac* pFlac;
@@ -8548,6 +8752,7 @@ DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_all
return pFlac;
}
+#endif
DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
{
@@ -8567,6 +8772,7 @@ DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_
return pFlac;
}
+#ifndef DR_FLAC_NO_WCHAR
DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
{
drflac* pFlac;
@@ -8584,6 +8790,7 @@ DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, dr
return pFlac;
}
+#endif
#endif /* DR_FLAC_NO_STDIO */
static size_t drflac__on_read_memory(void* pUserData, void* bufferOut, size_t bytesToRead)
@@ -11781,7 +11988,7 @@ DRFLAC_API const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator
return NULL;
}
- length = drflac__le2host_32(*(const drflac_uint32*)pIter->pRunningData);
+ length = drflac__le2host_32_ptr_unaligned(pIter->pRunningData);
pIter->pRunningData += 4;
pComment = pIter->pRunningData;
@@ -11851,6 +12058,37 @@ DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterat
/*
REVISION HISTORY
================
+v0.12.39 - 2022-09-17
+ - Fix compilation with DJGPP.
+ - Fix compilation error with Visual Studio 2019 and the ARM build.
+ - Fix an error with SSE 4.1 detection.
+ - Add support for disabling wchar_t with DR_WAV_NO_WCHAR.
+ - Improve compatibility with compilers which lack support for explicit struct packing.
+ - Improve compatibility with low-end and embedded hardware by reducing the amount of stack
+ allocation when loading an Ogg encapsulated file.
+
+v0.12.38 - 2022-04-10
+ - Fix compilation error on older versions of GCC.
+
+v0.12.37 - 2022-02-12
+ - Improve ARM detection.
+
+v0.12.36 - 2022-02-07
+ - Fix a compilation error with the ARM build.
+
+v0.12.35 - 2022-02-06
+ - Fix a bug due to underestimating the amount of precision required for the prediction stage.
+ - Fix some bugs found from fuzz testing.
+
+v0.12.34 - 2022-01-07
+ - Fix some misalignment bugs when reading metadata.
+
+v0.12.33 - 2021-12-22
+ - Fix a bug with seeking when the seek table does not start at PCM frame 0.
+
+v0.12.32 - 2021-12-11
+ - Fix a warning with Clang.
+
v0.12.31 - 2021-08-16
- Silence some warnings.
diff --git a/src/external/dr_mp3.h b/src/external/dr_mp3.h
index 7d752d072..59876c877 100644
--- a/src/external/dr_mp3.h
+++ b/src/external/dr_mp3.h
@@ -1,6 +1,6 @@
/*
MP3 audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
-dr_mp3 - v0.6.31 - 2021-08-22
+dr_mp3 - v0.6.34 - 2022-09-17
David Reid - mackron@gmail.com
@@ -95,7 +95,7 @@ extern "C" {
#define DRMP3_VERSION_MAJOR 0
#define DRMP3_VERSION_MINOR 6
-#define DRMP3_VERSION_REVISION 31
+#define DRMP3_VERSION_REVISION 34
#define DRMP3_VERSION_STRING DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION)
#include /* For size_t. */
@@ -107,7 +107,7 @@ typedef signed short drmp3_int16;
typedef unsigned short drmp3_uint16;
typedef signed int drmp3_int32;
typedef unsigned int drmp3_uint32;
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && !defined(__clang__)
typedef signed __int64 drmp3_int64;
typedef unsigned __int64 drmp3_uint64;
#else
@@ -235,9 +235,15 @@ typedef drmp3_int32 drmp3_result;
I am using "__inline__" only when we're compiling in strict ANSI mode.
*/
#if defined(__STRICT_ANSI__)
- #define DRMP3_INLINE __inline__ __attribute__((always_inline))
+ #define DRMP3_GNUC_INLINE_HINT __inline__
#else
- #define DRMP3_INLINE inline __attribute__((always_inline))
+ #define DRMP3_GNUC_INLINE_HINT inline
+ #endif
+
+ #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__)
+ #define DRMP3_INLINE DRMP3_GNUC_INLINE_HINT __attribute__((always_inline))
+ #else
+ #define DRMP3_INLINE DRMP3_GNUC_INLINE_HINT
#endif
#elif defined(__WATCOMC__)
#define DRMP3_INLINE __inline
@@ -340,7 +346,6 @@ typedef struct
typedef struct
{
drmp3dec decoder;
- drmp3dec_frame_info frameInfo;
drmp3_uint32 channels;
drmp3_uint32 sampleRate;
drmp3_read_proc onRead;
@@ -595,7 +600,7 @@ DRMP3_API const char* drmp3_version_string(void)
#define DR_MP3_ONLY_SIMD
#endif
-#if ((defined(_MSC_VER) && _MSC_VER >= 1400) && (defined(_M_IX86) || defined(_M_X64))) || ((defined(__i386__) || defined(__x86_64__)) && defined(__SSE2__))
+#if ((defined(_MSC_VER) && _MSC_VER >= 1400) && defined(_M_X64)) || ((defined(__i386) || defined(_M_IX86) || defined(__i386__) || defined(__x86_64__)) && ((defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__)))
#if defined(_MSC_VER)
#include
#endif
@@ -1296,7 +1301,7 @@ static void drmp3_L3_huffman(float *dst, drmp3_bs *bs, const drmp3_L3_gr_info *g
static const drmp3_int16 tabindex[2*16] = { 0,32,64,98,0,132,180,218,292,364,426,538,648,746,0,1126,1460,1460,1460,1460,1460,1460,1460,1460,1842,1842,1842,1842,1842,1842,1842,1842 };
static const drmp3_uint8 g_linbits[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,6,8,10,13,4,5,6,7,8,9,11,13 };
-#define DRMP3_PEEK_BITS(n) (bs_cache >> (32 - n))
+#define DRMP3_PEEK_BITS(n) (bs_cache >> (32 - (n)))
#define DRMP3_FLUSH_BITS(n) { bs_cache <<= (n); bs_sh += (n); }
#define DRMP3_CHECK_BITS while (bs_sh >= 0) { bs_cache |= (drmp3_uint32)*bs_next_ptr++ << bs_sh; bs_sh -= 8; }
#define DRMP3_BSPOS ((bs_next_ptr - bs->buf)*8 - 24 + bs_sh)
@@ -1864,7 +1869,7 @@ static void drmp3d_DCT_II(float *grbuf, int n)
#if DRMP3_HAVE_SSE
#define DRMP3_VSAVE2(i, v) _mm_storel_pi((__m64 *)(void*)&y[i*18], v)
#else
-#define DRMP3_VSAVE2(i, v) vst1_f32((float32_t *)&y[i*18], vget_low_f32(v))
+#define DRMP3_VSAVE2(i, v) vst1_f32((float32_t *)&y[(i)*18], vget_low_f32(v))
#endif
for (i = 0; i < 7; i++, y += 4*18)
{
@@ -1880,7 +1885,7 @@ static void drmp3d_DCT_II(float *grbuf, int n)
DRMP3_VSAVE2(3, t[3][7]);
} else
{
-#define DRMP3_VSAVE4(i, v) DRMP3_VSTORE(&y[i*18], v)
+#define DRMP3_VSAVE4(i, v) DRMP3_VSTORE(&y[(i)*18], v)
for (i = 0; i < 7; i++, y += 4*18)
{
drmp3_f4 s = DRMP3_VADD(t[3][i], t[3][i + 1]);
@@ -2103,7 +2108,11 @@ static void drmp3d_synth(float *xl, drmp3d_sample_t *dstl, int nch, float *lins)
vst1_lane_s16(dstl + (49 + i)*nch, pcmb, 2);
#endif
#else
+ #if DRMP3_HAVE_SSE
static const drmp3_f4 g_scale = { 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f };
+ #else
+ const drmp3_f4 g_scale = vdupq_n_f32(1.0f/32768.0f);
+ #endif
a = DRMP3_VMUL(a, g_scale);
b = DRMP3_VMUL(b, g_scale);
#if DRMP3_HAVE_SSE
@@ -2406,8 +2415,6 @@ DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num
Main Public API
************************************************************************************************************************************************************/
-#include /* For sin() and exp(). */
-
#if defined(SIZE_MAX)
#define DRMP3_SIZE_MAX SIZE_MAX
#else
@@ -2427,7 +2434,7 @@ DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num
/* The size in bytes of each chunk of data to read from the MP3 stream. minimp3 recommends at least 16K, but in an attempt to reduce data movement I'm making this slightly larger. */
#ifndef DRMP3_DATA_CHUNK_SIZE
-#define DRMP3_DATA_CHUNK_SIZE DRMP3_MIN_DATA_CHUNK_SIZE*4
+#define DRMP3_DATA_CHUNK_SIZE (DRMP3_MIN_DATA_CHUNK_SIZE*4)
#endif
@@ -2472,24 +2479,6 @@ static DRMP3_INLINE drmp3_uint32 drmp3_gcf_u32(drmp3_uint32 a, drmp3_uint32 b)
}
-static DRMP3_INLINE double drmp3_sin(double x)
-{
- /* TODO: Implement custom sin(x). */
- return sin(x);
-}
-
-static DRMP3_INLINE double drmp3_exp(double x)
-{
- /* TODO: Implement custom exp(x). */
- return exp(x);
-}
-
-static DRMP3_INLINE double drmp3_cos(double x)
-{
- return drmp3_sin((DRMP3_PI_D*0.5) - x);
-}
-
-
static void* drmp3__malloc_default(size_t sz, void* pUserData)
{
(void)pUserData;
@@ -3434,10 +3423,23 @@ static drmp3_result drmp3_wfopen(FILE** ppFile, const wchar_t* pFilePath, const
}
#else
/*
- Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can
- think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
- maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility.
+ Use fopen() on anything other than Windows. Requires a conversion. This is annoying because
+ fopen() is locale specific. The only real way I can think of to do this is with wcsrtombs(). Note
+ that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
+ maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler
+ error I'll look into improving compatibility.
*/
+
+ /*
+ Some compilers don't support wchar_t or wcsrtombs() which we're using below. In this case we just
+ need to abort with an error. If you encounter a compiler lacking such support, add it to this list
+ and submit a bug report and it'll be added to the library upstream.
+ */
+ #if defined(__DJGPP__)
+ {
+ /* Nothing to do here. This will fall through to the error check below. */
+ }
+ #else
{
mbstate_t mbs;
size_t lenMB;
@@ -3479,6 +3481,7 @@ static drmp3_result drmp3_wfopen(FILE** ppFile, const wchar_t* pFilePath, const
drmp3__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
}
+ #endif
if (*ppFile == NULL) {
return DRMP3_ERROR;
@@ -4473,6 +4476,19 @@ counts rather than sample counts.
/*
REVISION HISTORY
================
+v0.6.34 - 2022-09-17
+ - Fix compilation with DJGPP.
+ - Fix compilation when compiling with x86 with no SSE2.
+ - Remove an unnecessary variable from the drmp3 structure.
+
+v0.6.33 - 2022-04-10
+ - Fix compilation error with the MSVC ARM64 build.
+ - Fix compilation error on older versions of GCC.
+ - Remove some unused functions.
+
+v0.6.32 - 2021-12-11
+ - Fix a warning with Clang.
+
v0.6.31 - 2021-08-22
- Fix a bug when loading from memory.
diff --git a/src/external/dr_wav.h b/src/external/dr_wav.h
index a119d66af..2f885a04c 100644
--- a/src/external/dr_wav.h
+++ b/src/external/dr_wav.h
@@ -1,6 +1,6 @@
/*
WAV audio loader and writer. Choice of public domain or MIT-0. See license statements at the end of this file.
-dr_wav - v0.13.4 - 2021-12-08
+dr_wav - v0.13.7 - 2022-09-17
David Reid - mackron@gmail.com
@@ -92,6 +92,9 @@ Build Options
#define DR_WAV_NO_STDIO
Disables APIs that initialize a decoder from a file such as `drwav_init_file()`, `drwav_init_file_write()`, etc.
+#define DR_WAV_NO_WCHAR
+ Disables all functions ending with `_w`. Use this if your compiler does not provide wchar.h. Not required if DR_WAV_NO_STDIO is also defined.
+
Notes
@@ -125,7 +128,7 @@ extern "C" {
#define DRWAV_VERSION_MAJOR 0
#define DRWAV_VERSION_MINOR 13
-#define DRWAV_VERSION_REVISION 4
+#define DRWAV_VERSION_REVISION 7
#define DRWAV_VERSION_STRING DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION)
#include /* For size_t. */
@@ -1297,14 +1300,21 @@ DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b);
#ifndef dr_wav_c
#define dr_wav_c
+#ifdef __MRC__
+/* MrC currently doesn't compile dr_wav correctly with any optimizations enabled. */
+#pragma options opt off
+#endif
+
#include
-#include /* For memcpy(), memset() */
+#include
#include /* For INT_MAX */
#ifndef DR_WAV_NO_STDIO
#include
+#ifndef DR_WAV_NO_WCHAR
#include
#endif
+#endif
/* Standard library stuff. */
#ifndef DRWAV_ASSERT
@@ -1359,9 +1369,15 @@ DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b);
I am using "__inline__" only when we're compiling in strict ANSI mode.
*/
#if defined(__STRICT_ANSI__)
- #define DRWAV_INLINE __inline__ __attribute__((always_inline))
+ #define DRWAV_GNUC_INLINE_HINT __inline__
#else
- #define DRWAV_INLINE inline __attribute__((always_inline))
+ #define DRWAV_GNUC_INLINE_HINT inline
+ #endif
+
+ #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__)
+ #define DRWAV_INLINE DRWAV_GNUC_INLINE_HINT __attribute__((always_inline))
+ #else
+ #define DRWAV_INLINE DRWAV_GNUC_INLINE_HINT
#endif
#elif defined(__WATCOMC__)
#define DRWAV_INLINE __inline
@@ -1966,7 +1982,7 @@ DRWAV_PRIVATE drwav_bool32 drwav__read_fmt(drwav_read_proc onRead, drwav_seek_pr
fmtOut->extendedSize = 0;
fmtOut->validBitsPerSample = 0;
fmtOut->channelMask = 0;
- memset(fmtOut->subFormat, 0, sizeof(fmtOut->subFormat));
+ DRWAV_ZERO_MEMORY(fmtOut->subFormat, sizeof(fmtOut->subFormat));
if (header.sizeInBytes > 16) {
drwav_uint8 fmt_cbSize[2];
@@ -2137,7 +2153,7 @@ DRWAV_PRIVATE void drwav__metadata_request_extra_memory_for_stage_2(drwav__metad
DRWAV_PRIVATE drwav_result drwav__metadata_alloc(drwav__metadata_parser* pParser, drwav_allocation_callbacks* pAllocationCallbacks)
{
if (pParser->extraCapacity != 0 || pParser->metadataCount != 0) {
- free(pParser->pData);
+ pAllocationCallbacks->onFree(pParser->pData, pAllocationCallbacks->pUserData);
pParser->pData = (drwav_uint8*)pAllocationCallbacks->onMalloc(drwav__metadata_memory_capacity(pParser), pAllocationCallbacks->pUserData);
pParser->pDataCursor = pParser->pData;
@@ -2316,6 +2332,17 @@ DRWAV_PRIVATE drwav_uint64 drwav__read_acid_to_metadata_obj(drwav__metadata_pars
return bytesRead;
}
+DRWAV_PRIVATE size_t drwav__strlen(const char* str)
+{
+ size_t result = 0;
+
+ while (*str++) {
+ result += 1;
+ }
+
+ return result;
+}
+
DRWAV_PRIVATE size_t drwav__strlen_clamped(const char* str, size_t maxToRead)
{
size_t result = 0;
@@ -2335,7 +2362,7 @@ DRWAV_PRIVATE char* drwav__metadata_copy_string(drwav__metadata_parser* pParser,
char* result = (char*)drwav__metadata_get_memory(pParser, len + 1, 1);
DRWAV_ASSERT(result != NULL);
- memcpy(result, str, len);
+ DRWAV_COPY_MEMORY(result, str, len);
result[len] = '\0';
return result;
@@ -2516,7 +2543,7 @@ DRWAV_PRIVATE drwav_uint64 drwav__read_bext_to_metadata_obj(drwav__metadata_pars
DRWAV_ASSERT(pMetadata->data.bext.pCodingHistory != NULL);
bytesRead += drwav__metadata_parser_read(pParser, pMetadata->data.bext.pCodingHistory, extraBytes, NULL);
- pMetadata->data.bext.codingHistorySize = (drwav_uint32)strlen(pMetadata->data.bext.pCodingHistory);
+ pMetadata->data.bext.codingHistorySize = (drwav_uint32)drwav__strlen(pMetadata->data.bext.pCodingHistory);
} else {
pMetadata->data.bext.pCodingHistory = NULL;
pMetadata->data.bext.codingHistorySize = 0;
@@ -2780,21 +2807,21 @@ DRWAV_PRIVATE drwav_uint64 drwav__metadata_process_chunk(drwav__metadata_parser*
if (bytesJustRead != DRWAV_BEXT_DESCRIPTION_BYTES) {
return bytesRead;
}
- allocSizeNeeded += strlen(buffer) + 1;
+ allocSizeNeeded += drwav__strlen(buffer) + 1;
buffer[DRWAV_BEXT_ORIGINATOR_NAME_BYTES] = '\0';
bytesJustRead = drwav__metadata_parser_read(pParser, buffer, DRWAV_BEXT_ORIGINATOR_NAME_BYTES, &bytesRead);
if (bytesJustRead != DRWAV_BEXT_ORIGINATOR_NAME_BYTES) {
return bytesRead;
}
- allocSizeNeeded += strlen(buffer) + 1;
+ allocSizeNeeded += drwav__strlen(buffer) + 1;
buffer[DRWAV_BEXT_ORIGINATOR_REF_BYTES] = '\0';
bytesJustRead = drwav__metadata_parser_read(pParser, buffer, DRWAV_BEXT_ORIGINATOR_REF_BYTES, &bytesRead);
if (bytesJustRead != DRWAV_BEXT_ORIGINATOR_REF_BYTES) {
return bytesRead;
}
- allocSizeNeeded += strlen(buffer) + 1;
+ allocSizeNeeded += drwav__strlen(buffer) + 1;
allocSizeNeeded += (size_t)pChunkHeader->sizeInBytes - DRWAV_BEXT_BYTES; /* Coding history. */
drwav__metadata_request_extra_memory_for_stage_2(pParser, allocSizeNeeded, 1);
@@ -3157,7 +3184,7 @@ DRWAV_PRIVATE drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc on
translatedFormatTag = drwav_bytes_to_u16(fmt.subFormat + 0);
}
- memset(&metadataParser, 0, sizeof(metadataParser));
+ DRWAV_ZERO_MEMORY(&metadataParser, sizeof(metadataParser));
/* Not tested on W64. */
if (!sequential && pWav->allowedMetadataTypes != drwav_metadata_type_none && (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64)) {
@@ -3746,7 +3773,7 @@ DRWAV_PRIVATE size_t drwav__write_or_count_metadata(drwav* pWav, drwav_metadata*
bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.maxMomentaryLoudness);
bytesWritten += drwav__write_or_count_u16ne_to_le(pWav, pMetadata->data.bext.maxShortTermLoudness);
- memset(reservedBuf, 0, sizeof(reservedBuf));
+ DRWAV_ZERO_MEMORY(reservedBuf, sizeof(reservedBuf));
bytesWritten += drwav__write_or_count(pWav, reservedBuf, sizeof(reservedBuf));
if (pMetadata->data.bext.codingHistorySize > 0) {
@@ -4704,6 +4731,7 @@ fallback, so if you notice your compiler not detecting this properly I'm happy t
#endif
#endif
+#ifndef DR_WAV_NO_WCHAR
DRWAV_PRIVATE drwav_result drwav_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drwav_allocation_callbacks* pAllocationCallbacks)
{
if (ppFile != NULL) {
@@ -4731,11 +4759,24 @@ DRWAV_PRIVATE drwav_result drwav_wfopen(FILE** ppFile, const wchar_t* pFilePath,
(void)pAllocationCallbacks;
}
#else
- /*
- Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can
- think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
- maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility.
+ /*
+ Use fopen() on anything other than Windows. Requires a conversion. This is annoying because
+ fopen() is locale specific. The only real way I can think of to do this is with wcsrtombs(). Note
+ that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
+ maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler
+ error I'll look into improving compatibility.
*/
+
+ /*
+ Some compilers don't support wchar_t or wcsrtombs() which we're using below. In this case we just
+ need to abort with an error. If you encounter a compiler lacking such support, add it to this list
+ and submit a bug report and it'll be added to the library upstream.
+ */
+ #if defined(__DJGPP__)
+ {
+ /* Nothing to do here. This will fall through to the error check below. */
+ }
+ #else
{
mbstate_t mbs;
size_t lenMB;
@@ -4777,6 +4818,7 @@ DRWAV_PRIVATE drwav_result drwav_wfopen(FILE** ppFile, const wchar_t* pFilePath,
drwav__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
}
+ #endif
if (*ppFile == NULL) {
return DRWAV_ERROR;
@@ -4785,6 +4827,7 @@ DRWAV_PRIVATE drwav_result drwav_wfopen(FILE** ppFile, const wchar_t* pFilePath,
return DRWAV_SUCCESS;
}
+#endif
DRWAV_PRIVATE size_t drwav__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead)
@@ -4840,6 +4883,7 @@ DRWAV_API drwav_bool32 drwav_init_file_ex(drwav* pWav, const char* filename, drw
return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, drwav_metadata_type_none, pAllocationCallbacks);
}
+#ifndef DR_WAV_NO_WCHAR
DRWAV_API drwav_bool32 drwav_init_file_w(drwav* pWav, const wchar_t* filename, const drwav_allocation_callbacks* pAllocationCallbacks)
{
return drwav_init_file_ex_w(pWav, filename, NULL, NULL, 0, pAllocationCallbacks);
@@ -4855,6 +4899,7 @@ DRWAV_API drwav_bool32 drwav_init_file_ex_w(drwav* pWav, const wchar_t* filename
/* This takes ownership of the FILE* object. */
return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, drwav_metadata_type_none, pAllocationCallbacks);
}
+#endif
DRWAV_API drwav_bool32 drwav_init_file_with_metadata(drwav* pWav, const char* filename, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
{
@@ -4867,6 +4912,7 @@ DRWAV_API drwav_bool32 drwav_init_file_with_metadata(drwav* pWav, const char* fi
return drwav_init_file__internal_FILE(pWav, pFile, NULL, NULL, flags, drwav_metadata_type_all_including_unknown, pAllocationCallbacks);
}
+#ifndef DR_WAV_NO_WCHAR
DRWAV_API drwav_bool32 drwav_init_file_with_metadata_w(drwav* pWav, const wchar_t* filename, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
{
FILE* pFile;
@@ -4877,6 +4923,7 @@ DRWAV_API drwav_bool32 drwav_init_file_with_metadata_w(drwav* pWav, const wchar_
/* This takes ownership of the FILE* object. */
return drwav_init_file__internal_FILE(pWav, pFile, NULL, NULL, flags, drwav_metadata_type_all_including_unknown, pAllocationCallbacks);
}
+#endif
DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal_FILE(drwav* pWav, FILE* pFile, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
@@ -4909,6 +4956,7 @@ DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal(drwav* pWav, const ch
return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
}
+#ifndef DR_WAV_NO_WCHAR
DRWAV_PRIVATE drwav_bool32 drwav_init_file_write_w__internal(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
{
FILE* pFile;
@@ -4919,6 +4967,7 @@ DRWAV_PRIVATE drwav_bool32 drwav_init_file_write_w__internal(drwav* pWav, const
/* This takes ownership of the FILE* object. */
return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
}
+#endif
DRWAV_API drwav_bool32 drwav_init_file_write(drwav* pWav, const char* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
{
@@ -4939,6 +4988,7 @@ DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames(drwav* pWav,
return drwav_init_file_write_sequential(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
}
+#ifndef DR_WAV_NO_WCHAR
DRWAV_API drwav_bool32 drwav_init_file_write_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
{
return drwav_init_file_write_w__internal(pWav, filename, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
@@ -4957,6 +5007,7 @@ DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames_w(drwav* pWav
return drwav_init_file_write_sequential_w(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
}
+#endif
#endif /* DR_WAV_NO_STDIO */
@@ -5441,8 +5492,8 @@ DRWAV_API drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetF
}
/* Make sure the sample is clamped. */
- if (targetFrameIndex >= pWav->totalPCMFrameCount) {
- targetFrameIndex = pWav->totalPCMFrameCount - 1;
+ if (targetFrameIndex > pWav->totalPCMFrameCount) {
+ targetFrameIndex = pWav->totalPCMFrameCount;
}
/*
@@ -7650,6 +7701,7 @@ DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32(const char* filen
}
+#ifndef DR_WAV_NO_WCHAR
DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
{
drwav wav;
@@ -7712,7 +7764,8 @@ DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32_w(const wchar_t*
return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
}
-#endif
+#endif /* DR_WAV_NO_WCHAR */
+#endif /* DR_WAV_NO_STDIO */
DRWAV_API drwav_int16* drwav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
{
@@ -7853,12 +7906,28 @@ DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b)
a[3] == b[3];
}
+#ifdef __MRC__
+/* Undo the pragma at the beginning of this file. */
+#pragma options opt reset
+#endif
+
#endif /* dr_wav_c */
#endif /* DR_WAV_IMPLEMENTATION */
/*
REVISION HISTORY
================
+v0.13.7 - 2022-09-17
+ - Fix compilation with DJGPP.
+ - Add support for disabling wchar_t with DR_WAV_NO_WCHAR.
+
+v0.13.6 - 2022-04-10
+ - Fix compilation error on older versions of GCC.
+ - Remove some dependencies on the standard library.
+
+v0.13.5 - 2022-01-26
+ - Fix an error when seeking to the end of the file.
+
v0.13.4 - 2021-12-08
- Fix some static analysis warnings.
diff --git a/src/external/glad_gles2.h b/src/external/glad_gles2.h
new file mode 100644
index 000000000..6c753d0a4
--- /dev/null
+++ b/src/external/glad_gles2.h
@@ -0,0 +1,4774 @@
+/**
+ * Loader generated by glad 2.0.2 on Wed Dec 28 13:28:51 2022
+ *
+ * SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
+ *
+ * Generator: C/C++
+ * Specification: gl
+ * Extensions: 170
+ *
+ * APIs:
+ * - gles2=2.0
+ *
+ * Options:
+ * - ALIAS = False
+ * - DEBUG = False
+ * - HEADER_ONLY = True
+ * - LOADER = False
+ * - MX = False
+ * - ON_DEMAND = False
+ *
+ * Commandline:
+ * --api='gles2=2.0' --extensions='GL_EXT_EGL_image_array,GL_EXT_EGL_image_storage,GL_EXT_EGL_image_storage_compression,GL_EXT_YUV_target,GL_EXT_base_instance,GL_EXT_blend_func_extended,GL_EXT_blend_minmax,GL_EXT_buffer_storage,GL_EXT_clear_texture,GL_EXT_clip_control,GL_EXT_clip_cull_distance,GL_EXT_color_buffer_float,GL_EXT_color_buffer_half_float,GL_EXT_conservative_depth,GL_EXT_copy_image,GL_EXT_debug_label,GL_EXT_debug_marker,GL_EXT_depth_clamp,GL_EXT_discard_framebuffer,GL_EXT_disjoint_timer_query,GL_EXT_draw_buffers,GL_EXT_draw_buffers_indexed,GL_EXT_draw_elements_base_vertex,GL_EXT_draw_instanced,GL_EXT_draw_transform_feedback,GL_EXT_external_buffer,GL_EXT_float_blend,GL_EXT_fragment_shading_rate,GL_EXT_geometry_point_size,GL_EXT_geometry_shader,GL_EXT_gpu_shader5,GL_EXT_instanced_arrays,GL_EXT_map_buffer_range,GL_EXT_memory_object,GL_EXT_memory_object_fd,GL_EXT_memory_object_win32,GL_EXT_multi_draw_arrays,GL_EXT_multi_draw_indirect,GL_EXT_multisampled_compatibility,GL_EXT_multisampled_render_to_texture,GL_EXT_multisampled_render_to_texture2,GL_EXT_multiview_draw_buffers,GL_EXT_multiview_tessellation_geometry_shader,GL_EXT_multiview_texture_multisample,GL_EXT_multiview_timer_query,GL_EXT_occlusion_query_boolean,GL_EXT_polygon_offset_clamp,GL_EXT_post_depth_coverage,GL_EXT_primitive_bounding_box,GL_EXT_protected_textures,GL_EXT_pvrtc_sRGB,GL_EXT_raster_multisample,GL_EXT_read_format_bgra,GL_EXT_render_snorm,GL_EXT_robustness,GL_EXT_sRGB,GL_EXT_sRGB_write_control,GL_EXT_semaphore,GL_EXT_semaphore_fd,GL_EXT_semaphore_win32,GL_EXT_separate_depth_stencil,GL_EXT_separate_shader_objects,GL_EXT_shader_framebuffer_fetch,GL_EXT_shader_framebuffer_fetch_non_coherent,GL_EXT_shader_group_vote,GL_EXT_shader_implicit_conversions,GL_EXT_shader_integer_mix,GL_EXT_shader_io_blocks,GL_EXT_shader_non_constant_global_initializers,GL_EXT_shader_pixel_local_storage,GL_EXT_shader_pixel_local_storage2,GL_EXT_shader_samples_identical,GL_EXT_shader_texture_lod,GL_EXT_shadow_samplers,GL_EXT_sparse_texture,GL_EXT_sparse_texture2,GL_EXT_tessellation_point_size,GL_EXT_tessellation_shader,GL_EXT_texture_border_clamp,GL_EXT_texture_buffer,GL_EXT_texture_compression_astc_decode_mode,GL_EXT_texture_compression_bptc,GL_EXT_texture_compression_dxt1,GL_EXT_texture_compression_rgtc,GL_EXT_texture_compression_s3tc,GL_EXT_texture_compression_s3tc_srgb,GL_EXT_texture_cube_map_array,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_filter_minmax,GL_EXT_texture_format_BGRA8888,GL_EXT_texture_format_sRGB_override,GL_EXT_texture_mirror_clamp_to_edge,GL_EXT_texture_norm16,GL_EXT_texture_query_lod,GL_EXT_texture_rg,GL_EXT_texture_sRGB_R8,GL_EXT_texture_sRGB_RG8,GL_EXT_texture_sRGB_decode,GL_EXT_texture_shadow_lod,GL_EXT_texture_storage,GL_EXT_texture_storage_compression,GL_EXT_texture_type_2_10_10_10_REV,GL_EXT_texture_view,GL_EXT_unpack_subimage,GL_EXT_win32_keyed_mutex,GL_EXT_window_rectangles,GL_KHR_blend_equation_advanced,GL_KHR_blend_equation_advanced_coherent,GL_KHR_context_flush_control,GL_KHR_debug,GL_KHR_no_error,GL_KHR_parallel_shader_compile,GL_KHR_robust_buffer_access_behavior,GL_KHR_robustness,GL_KHR_shader_subgroup,GL_KHR_texture_compression_astc_hdr,GL_KHR_texture_compression_astc_ldr,GL_KHR_texture_compression_astc_sliced_3d,GL_OES_EGL_image,GL_OES_EGL_image_external,GL_OES_EGL_image_external_essl3,GL_OES_compressed_ETC1_RGB8_sub_texture,GL_OES_compressed_ETC1_RGB8_texture,GL_OES_compressed_paletted_texture,GL_OES_copy_image,GL_OES_depth24,GL_OES_depth32,GL_OES_depth_texture,GL_OES_draw_buffers_indexed,GL_OES_draw_elements_base_vertex,GL_OES_element_index_uint,GL_OES_fbo_render_mipmap,GL_OES_fragment_precision_high,GL_OES_geometry_point_size,GL_OES_geometry_shader,GL_OES_get_program_binary,GL_OES_gpu_shader5,GL_OES_mapbuffer,GL_OES_packed_depth_stencil,GL_OES_primitive_bounding_box,GL_OES_required_internalformat,GL_OES_rgb8_rgba8,GL_OES_sample_shading,GL_OES_sample_variables,GL_OES_shader_image_atomic,GL_OES_shader_io_blocks,GL_OES_shader_multisample_interpolation,GL_OES_standard_derivatives,GL_OES_stencil1,GL_OES_stencil4,GL_OES_surfaceless_context,GL_OES_tessellation_point_size,GL_OES_tessellation_shader,GL_OES_texture_3D,GL_OES_texture_border_clamp,GL_OES_texture_buffer,GL_OES_texture_compression_astc,GL_OES_texture_cube_map_array,GL_OES_texture_float,GL_OES_texture_float_linear,GL_OES_texture_half_float,GL_OES_texture_half_float_linear,GL_OES_texture_npot,GL_OES_texture_stencil8,GL_OES_texture_storage_multisample_2d_array,GL_OES_texture_view,GL_OES_vertex_array_object,GL_OES_vertex_half_float,GL_OES_vertex_type_10_10_10_2,GL_OES_viewport_array' c --header-only
+ *
+ * Online:
+ * http://glad.sh/#api=gles2%3D2.0&generator=c&options=HEADER_ONLY
+ *
+ */
+
+#ifndef GLAD_GLES2_H_
+#define GLAD_GLES2_H_
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wreserved-id-macro"
+#endif
+#ifdef __gl2_h_
+ #error OpenGL ES 2 header already included (API: gles2), remove previous include!
+#endif
+#define __gl2_h_ 1
+#ifdef __gles2_gl2_h_
+ #error OpenGL ES 2 header already included (API: gles2), remove previous include!
+#endif
+#define __gles2_gl2_h_ 1
+#ifdef __gl3_h_
+ #error OpenGL ES 3 header already included (API: gles2), remove previous include!
+#endif
+#define __gl3_h_ 1
+#ifdef __gles2_gl3_h_
+ #error OpenGL ES 3 header already included (API: gles2), remove previous include!
+#endif
+#define __gles2_gl3_h_ 1
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+#define GLAD_GLES2
+#define GLAD_OPTION_GLES2_HEADER_ONLY
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef GLAD_PLATFORM_H_
+#define GLAD_PLATFORM_H_
+
+#ifndef GLAD_PLATFORM_WIN32
+ #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
+ #define GLAD_PLATFORM_WIN32 1
+ #else
+ #define GLAD_PLATFORM_WIN32 0
+ #endif
+#endif
+
+#ifndef GLAD_PLATFORM_APPLE
+ #ifdef __APPLE__
+ #define GLAD_PLATFORM_APPLE 1
+ #else
+ #define GLAD_PLATFORM_APPLE 0
+ #endif
+#endif
+
+#ifndef GLAD_PLATFORM_EMSCRIPTEN
+ #ifdef __EMSCRIPTEN__
+ #define GLAD_PLATFORM_EMSCRIPTEN 1
+ #else
+ #define GLAD_PLATFORM_EMSCRIPTEN 0
+ #endif
+#endif
+
+#ifndef GLAD_PLATFORM_UWP
+ #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
+ #ifdef __has_include
+ #if __has_include()
+ #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
+ #endif
+ #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
+ #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
+ #endif
+ #endif
+
+ #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
+ #include
+ #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+ #define GLAD_PLATFORM_UWP 1
+ #endif
+ #endif
+
+ #ifndef GLAD_PLATFORM_UWP
+ #define GLAD_PLATFORM_UWP 0
+ #endif
+#endif
+
+#ifdef __GNUC__
+ #define GLAD_GNUC_EXTENSION __extension__
+#else
+ #define GLAD_GNUC_EXTENSION
+#endif
+
+#define GLAD_UNUSED(x) (void)(x)
+
+#ifndef GLAD_API_CALL
+ #if defined(GLAD_API_CALL_EXPORT)
+ #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
+ #if defined(GLAD_API_CALL_EXPORT_BUILD)
+ #if defined(__GNUC__)
+ #define GLAD_API_CALL __attribute__ ((dllexport)) extern
+ #else
+ #define GLAD_API_CALL __declspec(dllexport) extern
+ #endif
+ #else
+ #if defined(__GNUC__)
+ #define GLAD_API_CALL __attribute__ ((dllimport)) extern
+ #else
+ #define GLAD_API_CALL __declspec(dllimport) extern
+ #endif
+ #endif
+ #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
+ #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
+ #else
+ #define GLAD_API_CALL extern
+ #endif
+ #else
+ #define GLAD_API_CALL extern
+ #endif
+#endif
+
+#ifdef APIENTRY
+ #define GLAD_API_PTR APIENTRY
+#elif GLAD_PLATFORM_WIN32
+ #define GLAD_API_PTR __stdcall
+#else
+ #define GLAD_API_PTR
+#endif
+
+#ifndef GLAPI
+#define GLAPI GLAD_API_CALL
+#endif
+
+#ifndef GLAPIENTRY
+#define GLAPIENTRY GLAD_API_PTR
+#endif
+
+#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
+#define GLAD_VERSION_MAJOR(version) (version / 10000)
+#define GLAD_VERSION_MINOR(version) (version % 10000)
+
+#define GLAD_GENERATOR_VERSION "2.0.2"
+
+typedef void (*GLADapiproc)(void);
+
+typedef GLADapiproc (*GLADloadfunc)(const char *name);
+typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name);
+
+typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
+typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
+
+#endif /* GLAD_PLATFORM_H_ */
+
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_ACTIVE_PROGRAM_EXT 0x8259
+#define GL_ACTIVE_TEXTURE 0x84E0
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
+#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF
+#define GL_ALPHA 0x1906
+#define GL_ALPHA16F_EXT 0x881C
+#define GL_ALPHA32F_EXT 0x8816
+#define GL_ALPHA8_EXT 0x803C
+#define GL_ALPHA8_OES 0x803C
+#define GL_ALPHA_BITS 0x0D55
+#define GL_ALWAYS 0x0207
+#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A
+#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F
+#define GL_ARRAY_BUFFER 0x8892
+#define GL_ARRAY_BUFFER_BINDING 0x8894
+#define GL_ATTACHED_SHADERS 0x8B85
+#define GL_BACK 0x0405
+#define GL_BGRA8_EXT 0x93A1
+#define GL_BGRA_EXT 0x80E1
+#define GL_BLEND 0x0BE2
+#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285
+#define GL_BLEND_COLOR 0x8005
+#define GL_BLEND_DST_ALPHA 0x80CA
+#define GL_BLEND_DST_RGB 0x80C8
+#define GL_BLEND_EQUATION 0x8009
+#define GL_BLEND_EQUATION_ALPHA 0x883D
+#define GL_BLEND_EQUATION_RGB 0x8009
+#define GL_BLEND_SRC_ALPHA 0x80CB
+#define GL_BLEND_SRC_RGB 0x80C9
+#define GL_BLUE_BITS 0x0D54
+#define GL_BOOL 0x8B56
+#define GL_BOOL_VEC2 0x8B57
+#define GL_BOOL_VEC3 0x8B58
+#define GL_BOOL_VEC4 0x8B59
+#define GL_BUFFER_ACCESS_OES 0x88BB
+#define GL_BUFFER_IMMUTABLE_STORAGE_EXT 0x821F
+#define GL_BUFFER_KHR 0x82E0
+#define GL_BUFFER_MAPPED_OES 0x88BC
+#define GL_BUFFER_MAP_POINTER_OES 0x88BD
+#define GL_BUFFER_OBJECT_EXT 0x9151
+#define GL_BUFFER_SIZE 0x8764
+#define GL_BUFFER_STORAGE_FLAGS_EXT 0x8220
+#define GL_BUFFER_USAGE 0x8765
+#define GL_BYTE 0x1400
+#define GL_CCW 0x0901
+#define GL_CLAMP_TO_BORDER_EXT 0x812D
+#define GL_CLAMP_TO_BORDER_OES 0x812D
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT 0x00004000
+#define GL_CLIENT_STORAGE_BIT_EXT 0x0200
+#define GL_CLIP_DEPTH_MODE 0x935D
+#define GL_CLIP_DEPTH_MODE_EXT 0x935D
+#define GL_CLIP_DISTANCE0_EXT 0x3000
+#define GL_CLIP_DISTANCE1_EXT 0x3001
+#define GL_CLIP_DISTANCE2_EXT 0x3002
+#define GL_CLIP_DISTANCE3_EXT 0x3003
+#define GL_CLIP_DISTANCE4_EXT 0x3004
+#define GL_CLIP_DISTANCE5_EXT 0x3005
+#define GL_CLIP_DISTANCE6 0x3006
+#define GL_CLIP_DISTANCE6_EXT 0x3006
+#define GL_CLIP_DISTANCE7 0x3007
+#define GL_CLIP_DISTANCE7_EXT 0x3007
+#define GL_CLIP_ORIGIN 0x935C
+#define GL_CLIP_ORIGIN_EXT 0x935C
+#define GL_CLIP_PLANE0 0x3000
+#define GL_CLIP_PLANE1 0x3001
+#define GL_CLIP_PLANE2 0x3002
+#define GL_CLIP_PLANE3 0x3003
+#define GL_CLIP_PLANE4 0x3004
+#define GL_CLIP_PLANE5 0x3005
+#define GL_COLORBURN_KHR 0x929A
+#define GL_COLORDODGE_KHR 0x9299
+#define GL_COLOR_ATTACHMENT0 0x8CE0
+#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
+#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_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_ATTACHMENT_EXT 0x90F0
+#define GL_COLOR_BUFFER_BIT 0x00004000
+#define GL_COLOR_CLEAR_VALUE 0x0C22
+#define GL_COLOR_EXT 0x1800
+#define GL_COLOR_WRITEMASK 0x0C23
+#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_COMPLETION_STATUS_KHR 0x91B1
+#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD
+#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB
+#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
+#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_12x10_KHR 0x93BC
+#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
+#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0
+#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1
+#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
+#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2
+#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3
+#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
+#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4
+#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
+#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5
+#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6
+#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
+#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7
+#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
+#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8
+#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9
+#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_BPTC_UNORM_EXT 0x8E8C
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
+#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT 0x8E8E
+#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT 0x8E8F
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
+#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE
+#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
+#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_12x10_KHR 0x93DC
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9
+#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_SRGB_ALPHA_BPTC_UNORM_EXT 0x8E8D
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1
+#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
+#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54
+#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55
+#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002
+#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008
+#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008
+#define GL_CONTEXT_FLAG_PROTECTED_CONTENT_BIT_EXT 0x00000010
+#define GL_CONTEXT_LOST_KHR 0x0507
+#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x82FC
+#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x82FB
+#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3
+#define GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3
+#define GL_CULL_FACE 0x0B44
+#define GL_CULL_FACE_MODE 0x0B45
+#define GL_CURRENT_PROGRAM 0x8B8D
+#define GL_CURRENT_QUERY_EXT 0x8865
+#define GL_CURRENT_VERTEX_ATTRIB 0x8626
+#define GL_CW 0x0900
+#define GL_D3D12_FENCE_VALUE_EXT 0x9595
+#define GL_DARKEN_KHR 0x9297
+#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244
+#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245
+#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D
+#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145
+#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243
+#define GL_DEBUG_OUTPUT_KHR 0x92E0
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242
+#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146
+#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148
+#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147
+#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B
+#define GL_DEBUG_SOURCE_API_KHR 0x8246
+#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A
+#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B
+#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248
+#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249
+#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247
+#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D
+#define GL_DEBUG_TYPE_ERROR_KHR 0x824C
+#define GL_DEBUG_TYPE_MARKER_KHR 0x8268
+#define GL_DEBUG_TYPE_OTHER_KHR 0x8251
+#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250
+#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A
+#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F
+#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269
+#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E
+#define GL_DECODE_EXT 0x8A49
+#define GL_DECR 0x1E03
+#define GL_DECR_WRAP 0x8508
+#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581
+#define GL_DELETE_STATUS 0x8B80
+#define GL_DEPTH24_STENCIL8_OES 0x88F0
+#define GL_DEPTH_ATTACHMENT 0x8D00
+#define GL_DEPTH_BITS 0x0D56
+#define GL_DEPTH_BUFFER_BIT 0x00000100
+#define GL_DEPTH_CLAMP_EXT 0x864F
+#define GL_DEPTH_CLEAR_VALUE 0x0B73
+#define GL_DEPTH_COMPONENT 0x1902
+#define GL_DEPTH_COMPONENT16 0x81A5
+#define GL_DEPTH_COMPONENT16_OES 0x81A5
+#define GL_DEPTH_COMPONENT24_OES 0x81A6
+#define GL_DEPTH_COMPONENT32_OES 0x81A7
+#define GL_DEPTH_EXT 0x1801
+#define GL_DEPTH_FUNC 0x0B74
+#define GL_DEPTH_RANGE 0x0B70
+#define GL_DEPTH_STENCIL_OES 0x84F9
+#define GL_DEPTH_TEST 0x0B71
+#define GL_DEPTH_WRITEMASK 0x0B72
+#define GL_DEVICE_LUID_EXT 0x9599
+#define GL_DEVICE_NODE_MASK_EXT 0x959A
+#define GL_DEVICE_UUID_EXT 0x9597
+#define GL_DIFFERENCE_KHR 0x929E
+#define GL_DITHER 0x0BD0
+#define GL_DONT_CARE 0x1100
+#define GL_DRAW_BUFFER0_EXT 0x8825
+#define GL_DRAW_BUFFER10_EXT 0x882F
+#define GL_DRAW_BUFFER11_EXT 0x8830
+#define GL_DRAW_BUFFER12_EXT 0x8831
+#define GL_DRAW_BUFFER13_EXT 0x8832
+#define GL_DRAW_BUFFER14_EXT 0x8833
+#define GL_DRAW_BUFFER15_EXT 0x8834
+#define GL_DRAW_BUFFER1_EXT 0x8826
+#define GL_DRAW_BUFFER2_EXT 0x8827
+#define GL_DRAW_BUFFER3_EXT 0x8828
+#define GL_DRAW_BUFFER4_EXT 0x8829
+#define GL_DRAW_BUFFER5_EXT 0x882A
+#define GL_DRAW_BUFFER6_EXT 0x882B
+#define GL_DRAW_BUFFER7_EXT 0x882C
+#define GL_DRAW_BUFFER8_EXT 0x882D
+#define GL_DRAW_BUFFER9_EXT 0x882E
+#define GL_DRAW_BUFFER_EXT 0x0C01
+#define GL_DRIVER_UUID_EXT 0x9598
+#define GL_DST_ALPHA 0x0304
+#define GL_DST_COLOR 0x0306
+#define GL_DYNAMIC_DRAW 0x88E8
+#define GL_DYNAMIC_STORAGE_BIT_EXT 0x0100
+#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
+#define GL_EQUAL 0x0202
+#define GL_ETC1_RGB8_OES 0x8D64
+#define GL_EXCLUSION_KHR 0x92A0
+#define GL_EXCLUSIVE_EXT 0x8F11
+#define GL_EXTENSIONS 0x1F03
+#define GL_FALSE 0
+#define GL_FASTEST 0x1101
+#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D
+#define GL_FIRST_VERTEX_CONVENTION_OES 0x8E4D
+#define GL_FIXED 0x140C
+#define GL_FLOAT 0x1406
+#define GL_FLOAT_MAT2 0x8B5A
+#define GL_FLOAT_MAT3 0x8B5B
+#define GL_FLOAT_MAT4 0x8B5C
+#define GL_FLOAT_VEC2 0x8B50
+#define GL_FLOAT_VEC3 0x8B51
+#define GL_FLOAT_VEC4 0x8B52
+#define GL_FRACTIONAL_EVEN_EXT 0x8E7C
+#define GL_FRACTIONAL_EVEN_OES 0x8E7C
+#define GL_FRACTIONAL_ODD_EXT 0x8E7B
+#define GL_FRACTIONAL_ODD_OES 0x8E7B
+#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES 0x8E5D
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B
+#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
+#define GL_FRAGMENT_SHADING_RATE_ATTACHMENT_WITH_DEFAULT_FRAMEBUFFER_SUPPORTED_EXT 0x96DF
+#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_EXT 0x96D2
+#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_EXT 0x96D5
+#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_EXT 0x96D4
+#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_EXT 0x96D6
+#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_EXT 0x96D3
+#define GL_FRAGMENT_SHADING_RATE_NON_TRIVIAL_COMBINERS_SUPPORTED_EXT 0x8F6F
+#define GL_FRAGMENT_SHADING_RATE_WITH_SAMPLE_MASK_SUPPORTED_EXT 0x96DE
+#define GL_FRAGMENT_SHADING_RATE_WITH_SHADER_DEPTH_STENCIL_WRITES_SUPPORTED_EXT 0x96DD
+#define GL_FRAMEBUFFER 0x8D40
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_OES 0x8DA7
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
+#define GL_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
+#define GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT 0x9312
+#define GL_FRAMEBUFFER_DEFAULT_LAYERS_OES 0x9312
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
+#define GL_FRAMEBUFFER_INCOMPLETE_INSUFFICIENT_SHADER_COMBINED_LOCAL_STORAGE_EXT 0x9652
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_OES 0x8DA8
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
+#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
+#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219
+#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
+#define GL_FRONT 0x0404
+#define GL_FRONT_AND_BACK 0x0408
+#define GL_FRONT_FACE 0x0B46
+#define GL_FUNC_ADD 0x8006
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_GENERATE_MIPMAP_HINT 0x8192
+#define GL_GEOMETRY_LINKED_INPUT_TYPE_EXT 0x8917
+#define GL_GEOMETRY_LINKED_INPUT_TYPE_OES 0x8917
+#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT 0x8918
+#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_OES 0x8918
+#define GL_GEOMETRY_LINKED_VERTICES_OUT_EXT 0x8916
+#define GL_GEOMETRY_LINKED_VERTICES_OUT_OES 0x8916
+#define GL_GEOMETRY_SHADER_BIT_EXT 0x00000004
+#define GL_GEOMETRY_SHADER_BIT_OES 0x00000004
+#define GL_GEOMETRY_SHADER_EXT 0x8DD9
+#define GL_GEOMETRY_SHADER_INVOCATIONS_EXT 0x887F
+#define GL_GEOMETRY_SHADER_INVOCATIONS_OES 0x887F
+#define GL_GEOMETRY_SHADER_OES 0x8DD9
+#define GL_GEQUAL 0x0206
+#define GL_GPU_DISJOINT_EXT 0x8FBB
+#define GL_GREATER 0x0204
+#define GL_GREEN_BITS 0x0D53
+#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253
+#define GL_GUILTY_CONTEXT_RESET_KHR 0x8253
+#define GL_HALF_FLOAT_OES 0x8D61
+#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B
+#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C
+#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594
+#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A
+#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589
+#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586
+#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587
+#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588
+#define GL_HARDLIGHT_KHR 0x929B
+#define GL_HIGH_FLOAT 0x8DF2
+#define GL_HIGH_INT 0x8DF5
+#define GL_HSL_COLOR_KHR 0x92AF
+#define GL_HSL_HUE_KHR 0x92AD
+#define GL_HSL_LUMINOSITY_KHR 0x92B0
+#define GL_HSL_SATURATION_KHR 0x92AE
+#define GL_IMAGE_BUFFER_EXT 0x9051
+#define GL_IMAGE_BUFFER_OES 0x9051
+#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054
+#define GL_IMAGE_CUBE_MAP_ARRAY_OES 0x9054
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
+#define GL_INCLUSIVE_EXT 0x8F10
+#define GL_INCR 0x1E02
+#define GL_INCR_WRAP 0x8507
+#define GL_INFO_LOG_LENGTH 0x8B84
+#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254
+#define GL_INNOCENT_CONTEXT_RESET_KHR 0x8254
+#define GL_INT 0x1404
+#define GL_INT_10_10_10_2_OES 0x8DF7
+#define GL_INT_IMAGE_BUFFER_EXT 0x905C
+#define GL_INT_IMAGE_BUFFER_OES 0x905C
+#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F
+#define GL_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x905F
+#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910C
+#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0
+#define GL_INT_SAMPLER_BUFFER_OES 0x8DD0
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900E
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900E
+#define GL_INT_VEC2 0x8B53
+#define GL_INT_VEC3 0x8B54
+#define GL_INT_VEC4 0x8B55
+#define GL_INVALID_ENUM 0x0500
+#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
+#define GL_INVALID_OPERATION 0x0502
+#define GL_INVALID_VALUE 0x0501
+#define GL_INVERT 0x150A
+#define GL_ISOLINES_EXT 0x8E7A
+#define GL_ISOLINES_OES 0x8E7A
+#define GL_IS_PER_PATCH_EXT 0x92E7
+#define GL_IS_PER_PATCH_OES 0x92E7
+#define GL_KEEP 0x1E00
+#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E
+#define GL_LAST_VERTEX_CONVENTION_OES 0x8E4E
+#define GL_LAYER_PROVOKING_VERTEX_EXT 0x825E
+#define GL_LAYER_PROVOKING_VERTEX_OES 0x825E
+#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E
+#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531
+#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530
+#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F
+#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590
+#define GL_LAYOUT_GENERAL_EXT 0x958D
+#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591
+#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593
+#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592
+#define GL_LEQUAL 0x0203
+#define GL_LESS 0x0201
+#define GL_LIGHTEN_KHR 0x9298
+#define GL_LINEAR 0x2601
+#define GL_LINEAR_MIPMAP_LINEAR 0x2703
+#define GL_LINEAR_MIPMAP_NEAREST 0x2701
+#define GL_LINEAR_TILING_EXT 0x9585
+#define GL_LINES 0x0001
+#define GL_LINES_ADJACENCY_EXT 0x000A
+#define GL_LINES_ADJACENCY_OES 0x000A
+#define GL_LINE_LOOP 0x0002
+#define GL_LINE_STRIP 0x0003
+#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B
+#define GL_LINE_STRIP_ADJACENCY_OES 0x000B
+#define GL_LINE_WIDTH 0x0B21
+#define GL_LINK_STATUS 0x8B82
+#define GL_LOCATION_INDEX_EXT 0x930F
+#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252
+#define GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252
+#define GL_LOWER_LEFT 0x8CA1
+#define GL_LOWER_LEFT_EXT 0x8CA1
+#define GL_LOW_FLOAT 0x8DF0
+#define GL_LOW_INT 0x8DF3
+#define GL_LUID_SIZE_EXT 8
+#define GL_LUMINANCE 0x1909
+#define GL_LUMINANCE16F_EXT 0x881E
+#define GL_LUMINANCE32F_EXT 0x8818
+#define GL_LUMINANCE4_ALPHA4_OES 0x8043
+#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
+#define GL_LUMINANCE8_ALPHA8_OES 0x8045
+#define GL_LUMINANCE8_EXT 0x8040
+#define GL_LUMINANCE8_OES 0x8040
+#define GL_LUMINANCE_ALPHA 0x190A
+#define GL_LUMINANCE_ALPHA16F_EXT 0x881F
+#define GL_LUMINANCE_ALPHA32F_EXT 0x8819
+#define GL_MAP_COHERENT_BIT_EXT 0x0080
+#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010
+#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008
+#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004
+#define GL_MAP_PERSISTENT_BIT_EXT 0x0040
+#define GL_MAP_READ_BIT 0x0001
+#define GL_MAP_READ_BIT_EXT 0x0001
+#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020
+#define GL_MAP_WRITE_BIT 0x0002
+#define GL_MAP_WRITE_BIT_EXT 0x0002
+#define GL_MAX 0x8008
+#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073
+#define GL_MAX_CLIP_DISTANCES_EXT 0x0D32
+#define GL_MAX_CLIP_PLANES 0x0D32
+#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
+#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA
+#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES_EXT 0x82FA
+#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8A32
+#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8A32
+#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E1E
+#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E1E
+#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E1F
+#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E1F
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+#define GL_MAX_CULL_DISTANCES 0x82F9
+#define GL_MAX_CULL_DISTANCES_EXT 0x82F9
+#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C
+#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144
+#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143
+#define GL_MAX_DRAW_BUFFERS_EXT 0x8824
+#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT 0x88FC
+#define GL_MAX_EXT 0x8008
+#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5C
+#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_LAYERS_EXT 0x96DC
+#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_ASPECT_RATIO_EXT 0x96DB
+#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT_EXT 0x96DA
+#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH_EXT 0x96D8
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
+#define GL_MAX_FRAMEBUFFER_LAYERS_EXT 0x9317
+#define GL_MAX_FRAMEBUFFER_LAYERS_OES 0x9317
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT 0x92D5
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_OES 0x92D5
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT 0x92CF
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_OES 0x92CF
+#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT 0x90CD
+#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_OES 0x90CD
+#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT 0x9123
+#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_OES 0x9123
+#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT 0x9124
+#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_OES 0x9124
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_OES 0x8DE0
+#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT 0x8E5A
+#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_OES 0x8E5A
+#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT 0x90D7
+#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_OES 0x90D7
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_OES 0x8C29
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_OES 0x8DE1
+#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT 0x8A2C
+#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_OES 0x8A2C
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8DDF
+#define GL_MAX_LABEL_LENGTH_KHR 0x82E8
+#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2
+#define GL_MAX_PATCH_VERTICES_EXT 0x8E7D
+#define GL_MAX_PATCH_VERTICES_OES 0x8E7D
+#define GL_MAX_RASTER_SAMPLES_EXT 0x9329
+#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
+#define GL_MAX_SAMPLES_EXT 0x8D57
+#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_FAST_SIZE_EXT 0x9650
+#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_SIZE_EXT 0x9651
+#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0
+#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63
+#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT 0x8F67
+#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_EXT 0x9199
+#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_EXT 0x919A
+#define GL_MAX_SPARSE_TEXTURE_SIZE_EXT 0x9198
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT 0x92D3
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_OES 0x92D3
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT 0x92CD
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_OES 0x92CD
+#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT 0x90CB
+#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_OES 0x90CB
+#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT 0x886C
+#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_OES 0x886C
+#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT 0x8E83
+#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_OES 0x8E83
+#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT 0x90D8
+#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_OES 0x90D8
+#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT 0x8E81
+#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_OES 0x8E81
+#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT 0x8E85
+#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_OES 0x8E85
+#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT 0x8E89
+#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_OES 0x8E89
+#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E7F
+#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E7F
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT 0x92D4
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_OES 0x92D4
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT 0x92CE
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_OES 0x92CE
+#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT 0x90CC
+#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_OES 0x90CC
+#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT 0x886D
+#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_OES 0x886D
+#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT 0x8E86
+#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_OES 0x8E86
+#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT 0x90D9
+#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_OES 0x90D9
+#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT 0x8E82
+#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_OES 0x8E82
+#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT 0x8E8A
+#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_OES 0x8E8A
+#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E80
+#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E80
+#define GL_MAX_TESS_GEN_LEVEL_EXT 0x8E7E
+#define GL_MAX_TESS_GEN_LEVEL_OES 0x8E7E
+#define GL_MAX_TESS_PATCH_COMPONENTS_EXT 0x8E84
+#define GL_MAX_TESS_PATCH_COMPONENTS_OES 0x8E84
+#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B
+#define GL_MAX_TEXTURE_BUFFER_SIZE_OES 0x8C2B
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+#define GL_MAX_TEXTURE_SIZE 0x0D33
+#define GL_MAX_VARYING_VECTORS 0x8DFC
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
+#define GL_MAX_VIEWPORTS_OES 0x825B
+#define GL_MAX_VIEWPORT_DIMS 0x0D3A
+#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14
+#define GL_MEDIUM_FLOAT 0x8DF1
+#define GL_MEDIUM_INT 0x8DF4
+#define GL_MIN 0x8007
+#define GL_MIN_EXT 0x8007
+#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5B
+#define GL_MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT_EXT 0x96D9
+#define GL_MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH_EXT 0x96D7
+#define GL_MIN_SAMPLE_SHADING_VALUE_OES 0x8C37
+#define GL_MIRRORED_REPEAT 0x8370
+#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
+#define GL_MULTIPLY_KHR 0x9294
+#define GL_MULTISAMPLE_EXT 0x809D
+#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B
+#define GL_MULTIVIEW_EXT 0x90F1
+#define GL_NEAREST 0x2600
+#define GL_NEAREST_MIPMAP_LINEAR 0x2702
+#define GL_NEAREST_MIPMAP_NEAREST 0x2700
+#define GL_NEGATIVE_ONE_TO_ONE 0x935E
+#define GL_NEGATIVE_ONE_TO_ONE_EXT 0x935E
+#define GL_NEVER 0x0200
+#define GL_NICEST 0x1102
+#define GL_NONE 0
+#define GL_NOTEQUAL 0x0205
+#define GL_NO_ERROR 0
+#define GL_NO_RESET_NOTIFICATION_EXT 0x8261
+#define GL_NO_RESET_NOTIFICATION_KHR 0x8261
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_NUM_DEVICE_UUIDS_EXT 0x9596
+#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE
+#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
+#define GL_NUM_SPARSE_LEVELS_EXT 0x91AA
+#define GL_NUM_SURFACE_COMPRESSION_FIXED_RATES_EXT 0x8F6E
+#define GL_NUM_TILING_TYPES_EXT 0x9582
+#define GL_NUM_VIRTUAL_PAGE_SIZES_EXT 0x91A8
+#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15
+#define GL_ONE 1
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_ONE_MINUS_DST_ALPHA 0x0305
+#define GL_ONE_MINUS_DST_COLOR 0x0307
+#define GL_ONE_MINUS_SRC1_ALPHA_EXT 0x88FB
+#define GL_ONE_MINUS_SRC1_COLOR_EXT 0x88FA
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_ONE_MINUS_SRC_COLOR 0x0301
+#define GL_OPTIMAL_TILING_EXT 0x9584
+#define GL_OUT_OF_MEMORY 0x0505
+#define GL_OVERLAY_KHR 0x9296
+#define GL_PACK_ALIGNMENT 0x0D05
+#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
+#define GL_PALETTE4_RGB5_A1_OES 0x8B94
+#define GL_PALETTE4_RGB8_OES 0x8B90
+#define GL_PALETTE4_RGBA4_OES 0x8B93
+#define GL_PALETTE4_RGBA8_OES 0x8B91
+#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
+#define GL_PALETTE8_RGB5_A1_OES 0x8B99
+#define GL_PALETTE8_RGB8_OES 0x8B95
+#define GL_PALETTE8_RGBA4_OES 0x8B98
+#define GL_PALETTE8_RGBA8_OES 0x8B96
+#define GL_PATCHES_EXT 0x000E
+#define GL_PATCHES_OES 0x000E
+#define GL_PATCH_VERTICES_EXT 0x8E72
+#define GL_PATCH_VERTICES_OES 0x8E72
+#define GL_POINTS 0x0000
+#define GL_POLYGON_OFFSET_CLAMP 0x8E1B
+#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B
+#define GL_POLYGON_OFFSET_FACTOR 0x8038
+#define GL_POLYGON_OFFSET_FILL 0x8037
+#define GL_POLYGON_OFFSET_UNITS 0x2A00
+#define GL_PRIMITIVES_GENERATED_EXT 0x8C87
+#define GL_PRIMITIVES_GENERATED_OES 0x8C87
+#define GL_PRIMITIVE_BOUNDING_BOX_EXT 0x92BE
+#define GL_PRIMITIVE_BOUNDING_BOX_OES 0x92BE
+#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221
+#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED_OES 0x8221
+#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF
+#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
+#define GL_PROGRAM_KHR 0x82E2
+#define GL_PROGRAM_OBJECT_EXT 0x8B40
+#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A
+#define GL_PROGRAM_PIPELINE_KHR 0x82E4
+#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F
+#define GL_PROGRAM_SEPARABLE_EXT 0x8258
+#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B
+#define GL_QUADS_EXT 0x0007
+#define GL_QUADS_OES 0x0007
+#define GL_QUERY_COUNTER_BITS_EXT 0x8864
+#define GL_QUERY_KHR 0x82E3
+#define GL_QUERY_OBJECT_EXT 0x9153
+#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867
+#define GL_QUERY_RESULT_EXT 0x8866
+#define GL_R16F_EXT 0x822D
+#define GL_R16_EXT 0x822A
+#define GL_R16_SNORM_EXT 0x8F98
+#define GL_R32F_EXT 0x822E
+#define GL_R8_EXT 0x8229
+#define GL_R8_SNORM 0x8F94
+#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A
+#define GL_RASTER_MULTISAMPLE_EXT 0x9327
+#define GL_RASTER_SAMPLES_EXT 0x9328
+#define GL_READ_BUFFER_EXT 0x0C02
+#define GL_RED_BITS 0x0D52
+#define GL_RED_EXT 0x1903
+#define GL_REFERENCED_BY_GEOMETRY_SHADER_EXT 0x9309
+#define GL_REFERENCED_BY_GEOMETRY_SHADER_OES 0x9309
+#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT 0x9307
+#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_OES 0x9307
+#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT 0x9308
+#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_OES 0x9308
+#define GL_RENDERBUFFER 0x8D41
+#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
+#define GL_RENDERBUFFER_BINDING 0x8CA7
+#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
+#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
+#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
+#define GL_RENDERBUFFER_HEIGHT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
+#define GL_RENDERBUFFER_RED_SIZE 0x8D50
+#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
+#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
+#define GL_RENDERBUFFER_WIDTH 0x8D42
+#define GL_RENDERER 0x1F01
+#define GL_REPEAT 0x2901
+#define GL_REPLACE 0x1E01
+#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
+#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256
+#define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256
+#define GL_RG16F_EXT 0x822F
+#define GL_RG16_EXT 0x822C
+#define GL_RG16_SNORM_EXT 0x8F99
+#define GL_RG32F_EXT 0x8230
+#define GL_RG8_EXT 0x822B
+#define GL_RG8_SNORM 0x8F95
+#define GL_RGB 0x1907
+#define GL_RGB10_A2_EXT 0x8059
+#define GL_RGB10_EXT 0x8052
+#define GL_RGB16F_EXT 0x881B
+#define GL_RGB16_EXT 0x8054
+#define GL_RGB16_SNORM_EXT 0x8F9A
+#define GL_RGB32F_EXT 0x8815
+#define GL_RGB565 0x8D62
+#define GL_RGB565_OES 0x8D62
+#define GL_RGB5_A1 0x8057
+#define GL_RGB5_A1_OES 0x8057
+#define GL_RGB8_OES 0x8051
+#define GL_RGBA 0x1908
+#define GL_RGBA16F_EXT 0x881A
+#define GL_RGBA16_EXT 0x805B
+#define GL_RGBA16_SNORM_EXT 0x8F9B
+#define GL_RGBA32F_EXT 0x8814
+#define GL_RGBA4 0x8056
+#define GL_RGBA4_OES 0x8056
+#define GL_RGBA8_OES 0x8058
+#define GL_RGBA8_SNORM 0x8F97
+#define GL_RG_EXT 0x8227
+#define GL_SAMPLER 0x82E6
+#define GL_SAMPLER_2D 0x8B5E
+#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910B
+#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62
+#define GL_SAMPLER_3D_OES 0x8B5F
+#define GL_SAMPLER_BUFFER_EXT 0x8DC2
+#define GL_SAMPLER_BUFFER_OES 0x8DC2
+#define GL_SAMPLER_CUBE 0x8B60
+#define GL_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_OES 0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT 0x900D
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_OES 0x900D
+#define GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT 0x8BE7
+#define GL_SAMPLER_EXTERNAL_OES 0x8D66
+#define GL_SAMPLER_KHR 0x82E6
+#define GL_SAMPLES 0x80A9
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F
+#define GL_SAMPLE_BUFFERS 0x80A8
+#define GL_SAMPLE_COVERAGE 0x80A0
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#define GL_SAMPLE_SHADING_OES 0x8C36
+#define GL_SCISSOR_BOX 0x0C10
+#define GL_SCISSOR_TEST 0x0C11
+#define GL_SCREEN_KHR 0x9295
+#define GL_SHADER_BINARY_FORMATS 0x8DF8
+#define GL_SHADER_COMPILER 0x8DFA
+#define GL_SHADER_KHR 0x82E1
+#define GL_SHADER_OBJECT_EXT 0x8B48
+#define GL_SHADER_PIXEL_LOCAL_STORAGE_EXT 0x8F64
+#define GL_SHADER_SOURCE_LENGTH 0x8B88
+#define GL_SHADER_TYPE 0x8B4F
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#define GL_SHADING_RATE_1X1_PIXELS_EXT 0x96A6
+#define GL_SHADING_RATE_1X1_PIXELS_QCOM 0x96A6
+#define GL_SHADING_RATE_1X2_PIXELS_EXT 0x96A7
+#define GL_SHADING_RATE_1X2_PIXELS_QCOM 0x96A7
+#define GL_SHADING_RATE_1X4_PIXELS_EXT 0x96AA
+#define GL_SHADING_RATE_1X4_PIXELS_QCOM 0x96AA
+#define GL_SHADING_RATE_2X1_PIXELS_EXT 0x96A8
+#define GL_SHADING_RATE_2X1_PIXELS_QCOM 0x96A8
+#define GL_SHADING_RATE_2X2_PIXELS_EXT 0x96A9
+#define GL_SHADING_RATE_2X2_PIXELS_QCOM 0x96A9
+#define GL_SHADING_RATE_2X4_PIXELS_EXT 0x96AD
+#define GL_SHADING_RATE_2X4_PIXELS_QCOM 0x96AD
+#define GL_SHADING_RATE_4X1_PIXELS_EXT 0x96AB
+#define GL_SHADING_RATE_4X1_PIXELS_QCOM 0x96AB
+#define GL_SHADING_RATE_4X2_PIXELS_EXT 0x96AC
+#define GL_SHADING_RATE_4X2_PIXELS_QCOM 0x96AC
+#define GL_SHADING_RATE_4X4_PIXELS_EXT 0x96AE
+#define GL_SHADING_RATE_4X4_PIXELS_QCOM 0x96AE
+#define GL_SHADING_RATE_ATTACHMENT_EXT 0x96D1
+#define GL_SHADING_RATE_EXT 0x96D0
+#define GL_SHORT 0x1402
+#define GL_SKIP_DECODE_EXT 0x8A4A
+#define GL_SOFTLIGHT_KHR 0x929C
+#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_EXT 0x91A9
+#define GL_SR8_EXT 0x8FBD
+#define GL_SRC1_ALPHA_EXT 0x8589
+#define GL_SRC1_COLOR_EXT 0x88F9
+#define GL_SRC_ALPHA 0x0302
+#define GL_SRC_ALPHA_SATURATE 0x0308
+#define GL_SRC_ALPHA_SATURATE_EXT 0x0308
+#define GL_SRC_COLOR 0x0300
+#define GL_SRG8_EXT 0x8FBE
+#define GL_SRGB8_ALPHA8_EXT 0x8C43
+#define GL_SRGB_ALPHA_EXT 0x8C42
+#define GL_SRGB_EXT 0x8C40
+#define GL_STACK_OVERFLOW_KHR 0x0503
+#define GL_STACK_UNDERFLOW_KHR 0x0504
+#define GL_STATIC_DRAW 0x88E4
+#define GL_STENCIL_ATTACHMENT 0x8D20
+#define GL_STENCIL_BACK_FAIL 0x8801
+#define GL_STENCIL_BACK_FUNC 0x8800
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
+#define GL_STENCIL_BACK_REF 0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
+#define GL_STENCIL_BITS 0x0D57
+#define GL_STENCIL_BUFFER_BIT 0x00000400
+#define GL_STENCIL_CLEAR_VALUE 0x0B91
+#define GL_STENCIL_EXT 0x1802
+#define GL_STENCIL_FAIL 0x0B94
+#define GL_STENCIL_FUNC 0x0B92
+#define GL_STENCIL_INDEX1_OES 0x8D46
+#define GL_STENCIL_INDEX4_OES 0x8D47
+#define GL_STENCIL_INDEX8 0x8D48
+#define GL_STENCIL_INDEX8_OES 0x8D48
+#define GL_STENCIL_INDEX_OES 0x1901
+#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
+#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
+#define GL_STENCIL_REF 0x0B97
+#define GL_STENCIL_TEST 0x0B90
+#define GL_STENCIL_VALUE_MASK 0x0B93
+#define GL_STENCIL_WRITEMASK 0x0B98
+#define GL_STREAM_DRAW 0x88E0
+#define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004
+#define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008
+#define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001
+#define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040
+#define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080
+#define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010
+#define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020
+#define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002
+#define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535
+#define GL_SUBGROUP_SIZE_KHR 0x9532
+#define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534
+#define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533
+#define GL_SUBPIXEL_BITS 0x0D50
+#define GL_SURFACE_COMPRESSION_EXT 0x96C0
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_10BPC_EXT 0x96CD
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_11BPC_EXT 0x96CE
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_12BPC_EXT 0x96CF
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_1BPC_EXT 0x96C4
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_2BPC_EXT 0x96C5
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_3BPC_EXT 0x96C6
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_4BPC_EXT 0x96C7
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_5BPC_EXT 0x96C8
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_6BPC_EXT 0x96C9
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_7BPC_EXT 0x96CA
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_8BPC_EXT 0x96CB
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_9BPC_EXT 0x96CC
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_DEFAULT_EXT 0x96C2
+#define GL_SURFACE_COMPRESSION_FIXED_RATE_NONE_EXT 0x96C1
+#define GL_TESS_CONTROL_OUTPUT_VERTICES_EXT 0x8E75
+#define GL_TESS_CONTROL_OUTPUT_VERTICES_OES 0x8E75
+#define GL_TESS_CONTROL_SHADER_BIT_EXT 0x00000008
+#define GL_TESS_CONTROL_SHADER_BIT_OES 0x00000008
+#define GL_TESS_CONTROL_SHADER_EXT 0x8E88
+#define GL_TESS_CONTROL_SHADER_OES 0x8E88
+#define GL_TESS_EVALUATION_SHADER_BIT_EXT 0x00000010
+#define GL_TESS_EVALUATION_SHADER_BIT_OES 0x00000010
+#define GL_TESS_EVALUATION_SHADER_EXT 0x8E87
+#define GL_TESS_EVALUATION_SHADER_OES 0x8E87
+#define GL_TESS_GEN_MODE_EXT 0x8E76
+#define GL_TESS_GEN_MODE_OES 0x8E76
+#define GL_TESS_GEN_POINT_MODE_EXT 0x8E79
+#define GL_TESS_GEN_POINT_MODE_OES 0x8E79
+#define GL_TESS_GEN_SPACING_EXT 0x8E77
+#define GL_TESS_GEN_SPACING_OES 0x8E77
+#define GL_TESS_GEN_VERTEX_ORDER_EXT 0x8E78
+#define GL_TESS_GEN_VERTEX_ORDER_OES 0x8E78
+#define GL_TEXTURE 0x1702
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#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_TEXTURE2 0x84C2
+#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_TEXTURE3 0x84C3
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+#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_TEXTURE_2D 0x0DE1
+#define GL_TEXTURE_2D_ARRAY 0x8C1A
+#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES 0x9102
+#define GL_TEXTURE_3D 0x806F
+#define GL_TEXTURE_3D_OES 0x806F
+#define GL_TEXTURE_ASTC_DECODE_PRECISION_EXT 0x8F69
+#define GL_TEXTURE_BINDING_2D 0x8069
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES 0x9105
+#define GL_TEXTURE_BINDING_3D_OES 0x806A
+#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C
+#define GL_TEXTURE_BINDING_BUFFER_OES 0x8C2C
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT 0x900A
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_OES 0x900A
+#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
+#define GL_TEXTURE_BORDER_COLOR_EXT 0x1004
+#define GL_TEXTURE_BORDER_COLOR_OES 0x1004
+#define GL_TEXTURE_BUFFER_BINDING_EXT 0x8C2A
+#define GL_TEXTURE_BUFFER_BINDING_OES 0x8C2A
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_OES 0x8C2D
+#define GL_TEXTURE_BUFFER_EXT 0x8C2A
+#define GL_TEXTURE_BUFFER_OES 0x8C2A
+#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT 0x919F
+#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_OES 0x919F
+#define GL_TEXTURE_BUFFER_OFFSET_EXT 0x919D
+#define GL_TEXTURE_BUFFER_OFFSET_OES 0x919D
+#define GL_TEXTURE_BUFFER_SIZE_EXT 0x919E
+#define GL_TEXTURE_BUFFER_SIZE_OES 0x919E
+#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D
+#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#define GL_TEXTURE_CUBE_MAP_ARRAY_EXT 0x9009
+#define GL_TEXTURE_CUBE_MAP_ARRAY_OES 0x9009
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#define GL_TEXTURE_EXTERNAL_OES 0x8D65
+#define GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT 0x8FBF
+#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F
+#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_TEXTURE_PROTECTED_EXT 0x8BFA
+#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366
+#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366
+#define GL_TEXTURE_SPARSE_EXT 0x91A6
+#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48
+#define GL_TEXTURE_TILING_EXT 0x9580
+#define GL_TEXTURE_VIEW_MIN_LAYER_EXT 0x82DD
+#define GL_TEXTURE_VIEW_MIN_LAYER_OES 0x82DD
+#define GL_TEXTURE_VIEW_MIN_LEVEL_EXT 0x82DB
+#define GL_TEXTURE_VIEW_MIN_LEVEL_OES 0x82DB
+#define GL_TEXTURE_VIEW_NUM_LAYERS_EXT 0x82DE
+#define GL_TEXTURE_VIEW_NUM_LAYERS_OES 0x82DE
+#define GL_TEXTURE_VIEW_NUM_LEVELS_EXT 0x82DC
+#define GL_TEXTURE_VIEW_NUM_LEVELS_OES 0x82DC
+#define GL_TEXTURE_WRAP_R_OES 0x8072
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+#define GL_TILING_TYPES_EXT 0x9583
+#define GL_TIMESTAMP_EXT 0x8E28
+#define GL_TIME_ELAPSED_EXT 0x88BF
+#define GL_TRANSFORM_FEEDBACK 0x8E22
+#define GL_TRIANGLES 0x0004
+#define GL_TRIANGLES_ADJACENCY_EXT 0x000C
+#define GL_TRIANGLES_ADJACENCY_OES 0x000C
+#define GL_TRIANGLE_FAN 0x0006
+#define GL_TRIANGLE_STRIP 0x0005
+#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D
+#define GL_TRIANGLE_STRIP_ADJACENCY_OES 0x000D
+#define GL_TRUE 1
+#define GL_UNDEFINED_VERTEX_EXT 0x8260
+#define GL_UNDEFINED_VERTEX_OES 0x8260
+#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255
+#define GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255
+#define GL_UNPACK_ALIGNMENT 0x0CF5
+#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2
+#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4
+#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_UNSIGNED_INT 0x1405
+#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6
+#define GL_UNSIGNED_INT_24_8_OES 0x84FA
+#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368
+#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067
+#define GL_UNSIGNED_INT_IMAGE_BUFFER_OES 0x9067
+#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A
+#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x906A
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910D
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_OES 0x8DD8
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900F
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900F
+#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17
+#define GL_UNSIGNED_SHORT 0x1403
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#define GL_UPPER_LEFT 0x8CA2
+#define GL_UPPER_LEFT_EXT 0x8CA2
+#define GL_UUID_SIZE_EXT 16
+#define GL_VALIDATE_STATUS 0x8B83
+#define GL_VENDOR 0x1F00
+#define GL_VERSION 0x1F02
+#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5
+#define GL_VERTEX_ARRAY_KHR 0x8074
+#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_VERTEX_SHADER_BIT_EXT 0x00000001
+#define GL_VIEWPORT 0x0BA2
+#define GL_VIEWPORT_BOUNDS_RANGE_OES 0x825D
+#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX_OES 0x825F
+#define GL_VIEWPORT_SUBPIXEL_BITS_OES 0x825C
+#define GL_VIRTUAL_PAGE_SIZE_INDEX_EXT 0x91A7
+#define GL_VIRTUAL_PAGE_SIZE_X_EXT 0x9195
+#define GL_VIRTUAL_PAGE_SIZE_Y_EXT 0x9196
+#define GL_VIRTUAL_PAGE_SIZE_Z_EXT 0x9197
+#define GL_WEIGHTED_AVERAGE_ARB 0x9367
+#define GL_WEIGHTED_AVERAGE_EXT 0x9367
+#define GL_WINDOW_RECTANGLE_EXT 0x8F12
+#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13
+#define GL_WRITE_ONLY_OES 0x88B9
+#define GL_ZERO 0
+#define GL_ZERO_TO_ONE 0x935F
+#define GL_ZERO_TO_ONE_EXT 0x935F
+
+
+#ifndef __khrplatform_h_
+#define __khrplatform_h_
+
+/*
+** Copyright (c) 2008-2018 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Khronos platform-specific types and definitions.
+ *
+ * The master copy of khrplatform.h is maintained in the Khronos EGL
+ * Registry repository at https://github.com/KhronosGroup/EGL-Registry
+ * The last semantic modification to khrplatform.h was at commit ID:
+ * 67a3e0864c2d75ea5287b9f3d2eb74a745936692
+ *
+ * Adopters may modify this file to suit their platform. Adopters are
+ * encouraged to submit platform specific modifications to the Khronos
+ * group so that they can be included in future versions of this file.
+ * Please submit changes by filing pull requests or issues on
+ * the EGL Registry repository linked above.
+ *
+ *
+ * See the Implementer's Guidelines for information about where this file
+ * should be located on your system and for more details of its use:
+ * http://www.khronos.org/registry/implementers_guide.pdf
+ *
+ * This file should be included as
+ * #include
+ * by Khronos client API header files that use its types and defines.
+ *
+ * The types in khrplatform.h should only be used to define API-specific types.
+ *
+ * Types defined in khrplatform.h:
+ * khronos_int8_t signed 8 bit
+ * khronos_uint8_t unsigned 8 bit
+ * khronos_int16_t signed 16 bit
+ * khronos_uint16_t unsigned 16 bit
+ * khronos_int32_t signed 32 bit
+ * khronos_uint32_t unsigned 32 bit
+ * khronos_int64_t signed 64 bit
+ * khronos_uint64_t unsigned 64 bit
+ * khronos_intptr_t signed same number of bits as a pointer
+ * khronos_uintptr_t unsigned same number of bits as a pointer
+ * khronos_ssize_t signed size
+ * khronos_usize_t unsigned size
+ * khronos_float_t signed 32 bit floating point
+ * khronos_time_ns_t unsigned 64 bit time in nanoseconds
+ * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
+ * nanoseconds
+ * khronos_stime_nanoseconds_t signed time interval in nanoseconds
+ * khronos_boolean_enum_t enumerated boolean type. This should
+ * only be used as a base type when a client API's boolean type is
+ * an enum. Client APIs which use an integer or other type for
+ * booleans cannot use this as the base type for their boolean.
+ *
+ * Tokens defined in khrplatform.h:
+ *
+ * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
+ *
+ * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
+ * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
+ *
+ * Calling convention macros defined in this file:
+ * KHRONOS_APICALL
+ * KHRONOS_GLAD_API_PTR
+ * KHRONOS_APIATTRIBUTES
+ *
+ * These may be used in function prototypes as:
+ *
+ * KHRONOS_APICALL void KHRONOS_GLAD_API_PTR funcname(
+ * int arg1,
+ * int arg2) KHRONOS_APIATTRIBUTES;
+ */
+
+#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
+# define KHRONOS_STATIC 1
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APICALL
+ *-------------------------------------------------------------------------
+ * This precedes the return type of the function in the function prototype.
+ */
+#if defined(KHRONOS_STATIC)
+ /* If the preprocessor constant KHRONOS_STATIC is defined, make the
+ * header compatible with static linking. */
+# define KHRONOS_APICALL
+#elif defined(_WIN32)
+# define KHRONOS_APICALL __declspec(dllimport)
+#elif defined (__SYMBIAN32__)
+# define KHRONOS_APICALL IMPORT_C
+#elif defined(__ANDROID__)
+# define KHRONOS_APICALL __attribute__((visibility("default")))
+#else
+# define KHRONOS_APICALL
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_GLAD_API_PTR
+ *-------------------------------------------------------------------------
+ * This follows the return type of the function and precedes the function
+ * name in the function prototype.
+ */
+#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
+ /* Win32 but not WinCE */
+# define KHRONOS_GLAD_API_PTR __stdcall
+#else
+# define KHRONOS_GLAD_API_PTR
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIATTRIBUTES
+ *-------------------------------------------------------------------------
+ * This follows the closing parenthesis of the function prototype arguments.
+ */
+#if defined (__ARMCC_2__)
+#define KHRONOS_APIATTRIBUTES __softfp
+#else
+#define KHRONOS_APIATTRIBUTES
+#endif
+
+/*-------------------------------------------------------------------------
+ * basic type definitions
+ *-----------------------------------------------------------------------*/
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
+
+
+/*
+ * Using
+ */
+#include
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+/*
+ * To support platform where unsigned long cannot be used interchangeably with
+ * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
+ * Ideally, we could just use (u)intptr_t everywhere, but this could result in
+ * ABI breakage if khronos_uintptr_t is changed from unsigned long to
+ * unsigned long long or similar (this results in different C++ name mangling).
+ * To avoid changes for existing platforms, we restrict usage of intptr_t to
+ * platforms where the size of a pointer is larger than the size of long.
+ */
+#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
+#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
+#define KHRONOS_USE_INTPTR_T
+#endif
+#endif
+
+#elif defined(__VMS ) || defined(__sgi)
+
+/*
+ * Using
+ */
+#include
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
+
+/*
+ * Win32
+ */
+typedef __int32 khronos_int32_t;
+typedef unsigned __int32 khronos_uint32_t;
+typedef __int64 khronos_int64_t;
+typedef unsigned __int64 khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(__sun__) || defined(__digital__)
+
+/*
+ * Sun or Digital
+ */
+typedef int khronos_int32_t;
+typedef unsigned int khronos_uint32_t;
+#if defined(__arch64__) || defined(_LP64)
+typedef long int khronos_int64_t;
+typedef unsigned long int khronos_uint64_t;
+#else
+typedef long long int khronos_int64_t;
+typedef unsigned long long int khronos_uint64_t;
+#endif /* __arch64__ */
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif 0
+
+/*
+ * Hypothetical platform with no float or int64 support
+ */
+typedef int khronos_int32_t;
+typedef unsigned int khronos_uint32_t;
+#define KHRONOS_SUPPORT_INT64 0
+#define KHRONOS_SUPPORT_FLOAT 0
+
+#else
+
+/*
+ * Generic fallback
+ */
+#include
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#endif
+
+
+/*
+ * Types that are (so far) the same on all platforms
+ */
+typedef signed char khronos_int8_t;
+typedef unsigned char khronos_uint8_t;
+typedef signed short int khronos_int16_t;
+typedef unsigned short int khronos_uint16_t;
+
+/*
+ * Types that differ between LLP64 and LP64 architectures - in LLP64,
+ * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
+ * to be the only LLP64 architecture in current use.
+ */
+#ifdef KHRONOS_USE_INTPTR_T
+typedef intptr_t khronos_intptr_t;
+typedef uintptr_t khronos_uintptr_t;
+#elif defined(_WIN64)
+typedef signed long long int khronos_intptr_t;
+typedef unsigned long long int khronos_uintptr_t;
+#else
+typedef signed long int khronos_intptr_t;
+typedef unsigned long int khronos_uintptr_t;
+#endif
+
+#if defined(_WIN64)
+typedef signed long long int khronos_ssize_t;
+typedef unsigned long long int khronos_usize_t;
+#else
+typedef signed long int khronos_ssize_t;
+typedef unsigned long int khronos_usize_t;
+#endif
+
+#if KHRONOS_SUPPORT_FLOAT
+/*
+ * Float type
+ */
+typedef float khronos_float_t;
+#endif
+
+#if KHRONOS_SUPPORT_INT64
+/* Time types
+ *
+ * These types can be used to represent a time interval in nanoseconds or
+ * an absolute Unadjusted System Time. Unadjusted System Time is the number
+ * of nanoseconds since some arbitrary system event (e.g. since the last
+ * time the system booted). The Unadjusted System Time is an unsigned
+ * 64 bit value that wraps back to 0 every 584 years. Time intervals
+ * may be either signed or unsigned.
+ */
+typedef khronos_uint64_t khronos_utime_nanoseconds_t;
+typedef khronos_int64_t khronos_stime_nanoseconds_t;
+#endif
+
+/*
+ * Dummy value used to pad enum types to 32 bits.
+ */
+#ifndef KHRONOS_MAX_ENUM
+#define KHRONOS_MAX_ENUM 0x7FFFFFFF
+#endif
+
+/*
+ * Enumerated boolean type
+ *
+ * Values other than zero should be considered to be true. Therefore
+ * comparisons should not be made against KHRONOS_TRUE.
+ */
+typedef enum {
+ KHRONOS_FALSE = 0,
+ KHRONOS_TRUE = 1,
+ KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
+} khronos_boolean_enum_t;
+
+#endif /* __khrplatform_h_ */
+typedef unsigned int GLenum;
+typedef unsigned char GLboolean;
+typedef unsigned int GLbitfield;
+typedef void GLvoid;
+typedef khronos_int8_t GLbyte;
+typedef khronos_uint8_t GLubyte;
+typedef khronos_int16_t GLshort;
+typedef khronos_uint16_t GLushort;
+typedef int GLint;
+typedef unsigned int GLuint;
+typedef khronos_int32_t GLclampx;
+typedef int GLsizei;
+typedef khronos_float_t GLfloat;
+typedef khronos_float_t GLclampf;
+typedef double GLdouble;
+typedef double GLclampd;
+typedef void *GLeglClientBufferEXT;
+typedef void *GLeglImageOES;
+typedef char GLchar;
+typedef char GLcharARB;
+#ifdef __APPLE__
+typedef void *GLhandleARB;
+#else
+typedef unsigned int GLhandleARB;
+#endif
+typedef khronos_uint16_t GLhalf;
+typedef khronos_uint16_t GLhalfARB;
+typedef khronos_int32_t GLfixed;
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef khronos_intptr_t GLintptr;
+#else
+typedef khronos_intptr_t GLintptr;
+#endif
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef khronos_intptr_t GLintptrARB;
+#else
+typedef khronos_intptr_t GLintptrARB;
+#endif
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef khronos_ssize_t GLsizeiptr;
+#else
+typedef khronos_ssize_t GLsizeiptr;
+#endif
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef khronos_ssize_t GLsizeiptrARB;
+#else
+typedef khronos_ssize_t GLsizeiptrARB;
+#endif
+typedef khronos_int64_t GLint64;
+typedef khronos_int64_t GLint64EXT;
+typedef khronos_uint64_t GLuint64;
+typedef khronos_uint64_t GLuint64EXT;
+typedef struct __GLsync *GLsync;
+struct _cl_context;
+struct _cl_event;
+typedef void (GLAD_API_PTR *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+typedef void (GLAD_API_PTR *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+typedef void (GLAD_API_PTR *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+typedef void (GLAD_API_PTR *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
+typedef unsigned short GLhalfNV;
+typedef GLintptr GLvdpauSurfaceNV;
+typedef void (GLAD_API_PTR *GLVULKANPROCNV)(void);
+
+
+#define GL_ES_VERSION_2_0 1
+GLAD_API_CALL int GLAD_GL_ES_VERSION_2_0;
+#define GL_EXT_EGL_image_array 1
+GLAD_API_CALL int GLAD_GL_EXT_EGL_image_array;
+#define GL_EXT_EGL_image_storage 1
+GLAD_API_CALL int GLAD_GL_EXT_EGL_image_storage;
+#define GL_EXT_EGL_image_storage_compression 1
+GLAD_API_CALL int GLAD_GL_EXT_EGL_image_storage_compression;
+#define GL_EXT_YUV_target 1
+GLAD_API_CALL int GLAD_GL_EXT_YUV_target;
+#define GL_EXT_base_instance 1
+GLAD_API_CALL int GLAD_GL_EXT_base_instance;
+#define GL_EXT_blend_func_extended 1
+GLAD_API_CALL int GLAD_GL_EXT_blend_func_extended;
+#define GL_EXT_blend_minmax 1
+GLAD_API_CALL int GLAD_GL_EXT_blend_minmax;
+#define GL_EXT_buffer_storage 1
+GLAD_API_CALL int GLAD_GL_EXT_buffer_storage;
+#define GL_EXT_clear_texture 1
+GLAD_API_CALL int GLAD_GL_EXT_clear_texture;
+#define GL_EXT_clip_control 1
+GLAD_API_CALL int GLAD_GL_EXT_clip_control;
+#define GL_EXT_clip_cull_distance 1
+GLAD_API_CALL int GLAD_GL_EXT_clip_cull_distance;
+#define GL_EXT_color_buffer_float 1
+GLAD_API_CALL int GLAD_GL_EXT_color_buffer_float;
+#define GL_EXT_color_buffer_half_float 1
+GLAD_API_CALL int GLAD_GL_EXT_color_buffer_half_float;
+#define GL_EXT_conservative_depth 1
+GLAD_API_CALL int GLAD_GL_EXT_conservative_depth;
+#define GL_EXT_copy_image 1
+GLAD_API_CALL int GLAD_GL_EXT_copy_image;
+#define GL_EXT_debug_label 1
+GLAD_API_CALL int GLAD_GL_EXT_debug_label;
+#define GL_EXT_debug_marker 1
+GLAD_API_CALL int GLAD_GL_EXT_debug_marker;
+#define GL_EXT_depth_clamp 1
+GLAD_API_CALL int GLAD_GL_EXT_depth_clamp;
+#define GL_EXT_discard_framebuffer 1
+GLAD_API_CALL int GLAD_GL_EXT_discard_framebuffer;
+#define GL_EXT_disjoint_timer_query 1
+GLAD_API_CALL int GLAD_GL_EXT_disjoint_timer_query;
+#define GL_EXT_draw_buffers 1
+GLAD_API_CALL int GLAD_GL_EXT_draw_buffers;
+#define GL_EXT_draw_buffers_indexed 1
+GLAD_API_CALL int GLAD_GL_EXT_draw_buffers_indexed;
+#define GL_EXT_draw_elements_base_vertex 1
+GLAD_API_CALL int GLAD_GL_EXT_draw_elements_base_vertex;
+#define GL_EXT_draw_instanced 1
+GLAD_API_CALL int GLAD_GL_EXT_draw_instanced;
+#define GL_EXT_draw_transform_feedback 1
+GLAD_API_CALL int GLAD_GL_EXT_draw_transform_feedback;
+#define GL_EXT_external_buffer 1
+GLAD_API_CALL int GLAD_GL_EXT_external_buffer;
+#define GL_EXT_float_blend 1
+GLAD_API_CALL int GLAD_GL_EXT_float_blend;
+#define GL_EXT_fragment_shading_rate 1
+GLAD_API_CALL int GLAD_GL_EXT_fragment_shading_rate;
+#define GL_EXT_geometry_point_size 1
+GLAD_API_CALL int GLAD_GL_EXT_geometry_point_size;
+#define GL_EXT_geometry_shader 1
+GLAD_API_CALL int GLAD_GL_EXT_geometry_shader;
+#define GL_EXT_gpu_shader5 1
+GLAD_API_CALL int GLAD_GL_EXT_gpu_shader5;
+#define GL_EXT_instanced_arrays 1
+GLAD_API_CALL int GLAD_GL_EXT_instanced_arrays;
+#define GL_EXT_map_buffer_range 1
+GLAD_API_CALL int GLAD_GL_EXT_map_buffer_range;
+#define GL_EXT_memory_object 1
+GLAD_API_CALL int GLAD_GL_EXT_memory_object;
+#define GL_EXT_memory_object_fd 1
+GLAD_API_CALL int GLAD_GL_EXT_memory_object_fd;
+#define GL_EXT_memory_object_win32 1
+GLAD_API_CALL int GLAD_GL_EXT_memory_object_win32;
+#define GL_EXT_multi_draw_arrays 1
+GLAD_API_CALL int GLAD_GL_EXT_multi_draw_arrays;
+#define GL_EXT_multi_draw_indirect 1
+GLAD_API_CALL int GLAD_GL_EXT_multi_draw_indirect;
+#define GL_EXT_multisampled_compatibility 1
+GLAD_API_CALL int GLAD_GL_EXT_multisampled_compatibility;
+#define GL_EXT_multisampled_render_to_texture 1
+GLAD_API_CALL int GLAD_GL_EXT_multisampled_render_to_texture;
+#define GL_EXT_multisampled_render_to_texture2 1
+GLAD_API_CALL int GLAD_GL_EXT_multisampled_render_to_texture2;
+#define GL_EXT_multiview_draw_buffers 1
+GLAD_API_CALL int GLAD_GL_EXT_multiview_draw_buffers;
+#define GL_EXT_multiview_tessellation_geometry_shader 1
+GLAD_API_CALL int GLAD_GL_EXT_multiview_tessellation_geometry_shader;
+#define GL_EXT_multiview_texture_multisample 1
+GLAD_API_CALL int GLAD_GL_EXT_multiview_texture_multisample;
+#define GL_EXT_multiview_timer_query 1
+GLAD_API_CALL int GLAD_GL_EXT_multiview_timer_query;
+#define GL_EXT_occlusion_query_boolean 1
+GLAD_API_CALL int GLAD_GL_EXT_occlusion_query_boolean;
+#define GL_EXT_polygon_offset_clamp 1
+GLAD_API_CALL int GLAD_GL_EXT_polygon_offset_clamp;
+#define GL_EXT_post_depth_coverage 1
+GLAD_API_CALL int GLAD_GL_EXT_post_depth_coverage;
+#define GL_EXT_primitive_bounding_box 1
+GLAD_API_CALL int GLAD_GL_EXT_primitive_bounding_box;
+#define GL_EXT_protected_textures 1
+GLAD_API_CALL int GLAD_GL_EXT_protected_textures;
+#define GL_EXT_pvrtc_sRGB 1
+GLAD_API_CALL int GLAD_GL_EXT_pvrtc_sRGB;
+#define GL_EXT_raster_multisample 1
+GLAD_API_CALL int GLAD_GL_EXT_raster_multisample;
+#define GL_EXT_read_format_bgra 1
+GLAD_API_CALL int GLAD_GL_EXT_read_format_bgra;
+#define GL_EXT_render_snorm 1
+GLAD_API_CALL int GLAD_GL_EXT_render_snorm;
+#define GL_EXT_robustness 1
+GLAD_API_CALL int GLAD_GL_EXT_robustness;
+#define GL_EXT_sRGB 1
+GLAD_API_CALL int GLAD_GL_EXT_sRGB;
+#define GL_EXT_sRGB_write_control 1
+GLAD_API_CALL int GLAD_GL_EXT_sRGB_write_control;
+#define GL_EXT_semaphore 1
+GLAD_API_CALL int GLAD_GL_EXT_semaphore;
+#define GL_EXT_semaphore_fd 1
+GLAD_API_CALL int GLAD_GL_EXT_semaphore_fd;
+#define GL_EXT_semaphore_win32 1
+GLAD_API_CALL int GLAD_GL_EXT_semaphore_win32;
+#define GL_EXT_separate_depth_stencil 1
+GLAD_API_CALL int GLAD_GL_EXT_separate_depth_stencil;
+#define GL_EXT_separate_shader_objects 1
+GLAD_API_CALL int GLAD_GL_EXT_separate_shader_objects;
+#define GL_EXT_shader_framebuffer_fetch 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_framebuffer_fetch;
+#define GL_EXT_shader_framebuffer_fetch_non_coherent 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_framebuffer_fetch_non_coherent;
+#define GL_EXT_shader_group_vote 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_group_vote;
+#define GL_EXT_shader_implicit_conversions 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_implicit_conversions;
+#define GL_EXT_shader_integer_mix 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_integer_mix;
+#define GL_EXT_shader_io_blocks 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_io_blocks;
+#define GL_EXT_shader_non_constant_global_initializers 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_non_constant_global_initializers;
+#define GL_EXT_shader_pixel_local_storage 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_pixel_local_storage;
+#define GL_EXT_shader_pixel_local_storage2 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_pixel_local_storage2;
+#define GL_EXT_shader_samples_identical 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_samples_identical;
+#define GL_EXT_shader_texture_lod 1
+GLAD_API_CALL int GLAD_GL_EXT_shader_texture_lod;
+#define GL_EXT_shadow_samplers 1
+GLAD_API_CALL int GLAD_GL_EXT_shadow_samplers;
+#define GL_EXT_sparse_texture 1
+GLAD_API_CALL int GLAD_GL_EXT_sparse_texture;
+#define GL_EXT_sparse_texture2 1
+GLAD_API_CALL int GLAD_GL_EXT_sparse_texture2;
+#define GL_EXT_tessellation_point_size 1
+GLAD_API_CALL int GLAD_GL_EXT_tessellation_point_size;
+#define GL_EXT_tessellation_shader 1
+GLAD_API_CALL int GLAD_GL_EXT_tessellation_shader;
+#define GL_EXT_texture_border_clamp 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_border_clamp;
+#define GL_EXT_texture_buffer 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_buffer;
+#define GL_EXT_texture_compression_astc_decode_mode 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_compression_astc_decode_mode;
+#define GL_EXT_texture_compression_bptc 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_compression_bptc;
+#define GL_EXT_texture_compression_dxt1 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_compression_dxt1;
+#define GL_EXT_texture_compression_rgtc 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_compression_rgtc;
+#define GL_EXT_texture_compression_s3tc 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_compression_s3tc;
+#define GL_EXT_texture_compression_s3tc_srgb 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_compression_s3tc_srgb;
+#define GL_EXT_texture_cube_map_array 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_cube_map_array;
+#define GL_EXT_texture_filter_anisotropic 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_filter_anisotropic;
+#define GL_EXT_texture_filter_minmax 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_filter_minmax;
+#define GL_EXT_texture_format_BGRA8888 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_format_BGRA8888;
+#define GL_EXT_texture_format_sRGB_override 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_format_sRGB_override;
+#define GL_EXT_texture_mirror_clamp_to_edge 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_mirror_clamp_to_edge;
+#define GL_EXT_texture_norm16 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_norm16;
+#define GL_EXT_texture_query_lod 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_query_lod;
+#define GL_EXT_texture_rg 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_rg;
+#define GL_EXT_texture_sRGB_R8 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_sRGB_R8;
+#define GL_EXT_texture_sRGB_RG8 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_sRGB_RG8;
+#define GL_EXT_texture_sRGB_decode 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_sRGB_decode;
+#define GL_EXT_texture_shadow_lod 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_shadow_lod;
+#define GL_EXT_texture_storage 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_storage;
+#define GL_EXT_texture_storage_compression 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_storage_compression;
+#define GL_EXT_texture_type_2_10_10_10_REV 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_type_2_10_10_10_REV;
+#define GL_EXT_texture_view 1
+GLAD_API_CALL int GLAD_GL_EXT_texture_view;
+#define GL_EXT_unpack_subimage 1
+GLAD_API_CALL int GLAD_GL_EXT_unpack_subimage;
+#define GL_EXT_win32_keyed_mutex 1
+GLAD_API_CALL int GLAD_GL_EXT_win32_keyed_mutex;
+#define GL_EXT_window_rectangles 1
+GLAD_API_CALL int GLAD_GL_EXT_window_rectangles;
+#define GL_KHR_blend_equation_advanced 1
+GLAD_API_CALL int GLAD_GL_KHR_blend_equation_advanced;
+#define GL_KHR_blend_equation_advanced_coherent 1
+GLAD_API_CALL int GLAD_GL_KHR_blend_equation_advanced_coherent;
+#define GL_KHR_context_flush_control 1
+GLAD_API_CALL int GLAD_GL_KHR_context_flush_control;
+#define GL_KHR_debug 1
+GLAD_API_CALL int GLAD_GL_KHR_debug;
+#define GL_KHR_no_error 1
+GLAD_API_CALL int GLAD_GL_KHR_no_error;
+#define GL_KHR_parallel_shader_compile 1
+GLAD_API_CALL int GLAD_GL_KHR_parallel_shader_compile;
+#define GL_KHR_robust_buffer_access_behavior 1
+GLAD_API_CALL int GLAD_GL_KHR_robust_buffer_access_behavior;
+#define GL_KHR_robustness 1
+GLAD_API_CALL int GLAD_GL_KHR_robustness;
+#define GL_KHR_shader_subgroup 1
+GLAD_API_CALL int GLAD_GL_KHR_shader_subgroup;
+#define GL_KHR_texture_compression_astc_hdr 1
+GLAD_API_CALL int GLAD_GL_KHR_texture_compression_astc_hdr;
+#define GL_KHR_texture_compression_astc_ldr 1
+GLAD_API_CALL int GLAD_GL_KHR_texture_compression_astc_ldr;
+#define GL_KHR_texture_compression_astc_sliced_3d 1
+GLAD_API_CALL int GLAD_GL_KHR_texture_compression_astc_sliced_3d;
+#define GL_OES_EGL_image 1
+GLAD_API_CALL int GLAD_GL_OES_EGL_image;
+#define GL_OES_EGL_image_external 1
+GLAD_API_CALL int GLAD_GL_OES_EGL_image_external;
+#define GL_OES_EGL_image_external_essl3 1
+GLAD_API_CALL int GLAD_GL_OES_EGL_image_external_essl3;
+#define GL_OES_compressed_ETC1_RGB8_sub_texture 1
+GLAD_API_CALL int GLAD_GL_OES_compressed_ETC1_RGB8_sub_texture;
+#define GL_OES_compressed_ETC1_RGB8_texture 1
+GLAD_API_CALL int GLAD_GL_OES_compressed_ETC1_RGB8_texture;
+#define GL_OES_compressed_paletted_texture 1
+GLAD_API_CALL int GLAD_GL_OES_compressed_paletted_texture;
+#define GL_OES_copy_image 1
+GLAD_API_CALL int GLAD_GL_OES_copy_image;
+#define GL_OES_depth24 1
+GLAD_API_CALL int GLAD_GL_OES_depth24;
+#define GL_OES_depth32 1
+GLAD_API_CALL int GLAD_GL_OES_depth32;
+#define GL_OES_depth_texture 1
+GLAD_API_CALL int GLAD_GL_OES_depth_texture;
+#define GL_OES_draw_buffers_indexed 1
+GLAD_API_CALL int GLAD_GL_OES_draw_buffers_indexed;
+#define GL_OES_draw_elements_base_vertex 1
+GLAD_API_CALL int GLAD_GL_OES_draw_elements_base_vertex;
+#define GL_OES_element_index_uint 1
+GLAD_API_CALL int GLAD_GL_OES_element_index_uint;
+#define GL_OES_fbo_render_mipmap 1
+GLAD_API_CALL int GLAD_GL_OES_fbo_render_mipmap;
+#define GL_OES_fragment_precision_high 1
+GLAD_API_CALL int GLAD_GL_OES_fragment_precision_high;
+#define GL_OES_geometry_point_size 1
+GLAD_API_CALL int GLAD_GL_OES_geometry_point_size;
+#define GL_OES_geometry_shader 1
+GLAD_API_CALL int GLAD_GL_OES_geometry_shader;
+#define GL_OES_get_program_binary 1
+GLAD_API_CALL int GLAD_GL_OES_get_program_binary;
+#define GL_OES_gpu_shader5 1
+GLAD_API_CALL int GLAD_GL_OES_gpu_shader5;
+#define GL_OES_mapbuffer 1
+GLAD_API_CALL int GLAD_GL_OES_mapbuffer;
+#define GL_OES_packed_depth_stencil 1
+GLAD_API_CALL int GLAD_GL_OES_packed_depth_stencil;
+#define GL_OES_primitive_bounding_box 1
+GLAD_API_CALL int GLAD_GL_OES_primitive_bounding_box;
+#define GL_OES_required_internalformat 1
+GLAD_API_CALL int GLAD_GL_OES_required_internalformat;
+#define GL_OES_rgb8_rgba8 1
+GLAD_API_CALL int GLAD_GL_OES_rgb8_rgba8;
+#define GL_OES_sample_shading 1
+GLAD_API_CALL int GLAD_GL_OES_sample_shading;
+#define GL_OES_sample_variables 1
+GLAD_API_CALL int GLAD_GL_OES_sample_variables;
+#define GL_OES_shader_image_atomic 1
+GLAD_API_CALL int GLAD_GL_OES_shader_image_atomic;
+#define GL_OES_shader_io_blocks 1
+GLAD_API_CALL int GLAD_GL_OES_shader_io_blocks;
+#define GL_OES_shader_multisample_interpolation 1
+GLAD_API_CALL int GLAD_GL_OES_shader_multisample_interpolation;
+#define GL_OES_standard_derivatives 1
+GLAD_API_CALL int GLAD_GL_OES_standard_derivatives;
+#define GL_OES_stencil1 1
+GLAD_API_CALL int GLAD_GL_OES_stencil1;
+#define GL_OES_stencil4 1
+GLAD_API_CALL int GLAD_GL_OES_stencil4;
+#define GL_OES_surfaceless_context 1
+GLAD_API_CALL int GLAD_GL_OES_surfaceless_context;
+#define GL_OES_tessellation_point_size 1
+GLAD_API_CALL int GLAD_GL_OES_tessellation_point_size;
+#define GL_OES_tessellation_shader 1
+GLAD_API_CALL int GLAD_GL_OES_tessellation_shader;
+#define GL_OES_texture_3D 1
+GLAD_API_CALL int GLAD_GL_OES_texture_3D;
+#define GL_OES_texture_border_clamp 1
+GLAD_API_CALL int GLAD_GL_OES_texture_border_clamp;
+#define GL_OES_texture_buffer 1
+GLAD_API_CALL int GLAD_GL_OES_texture_buffer;
+#define GL_OES_texture_compression_astc 1
+GLAD_API_CALL int GLAD_GL_OES_texture_compression_astc;
+#define GL_OES_texture_cube_map_array 1
+GLAD_API_CALL int GLAD_GL_OES_texture_cube_map_array;
+#define GL_OES_texture_float 1
+GLAD_API_CALL int GLAD_GL_OES_texture_float;
+#define GL_OES_texture_float_linear 1
+GLAD_API_CALL int GLAD_GL_OES_texture_float_linear;
+#define GL_OES_texture_half_float 1
+GLAD_API_CALL int GLAD_GL_OES_texture_half_float;
+#define GL_OES_texture_half_float_linear 1
+GLAD_API_CALL int GLAD_GL_OES_texture_half_float_linear;
+#define GL_OES_texture_npot 1
+GLAD_API_CALL int GLAD_GL_OES_texture_npot;
+#define GL_OES_texture_stencil8 1
+GLAD_API_CALL int GLAD_GL_OES_texture_stencil8;
+#define GL_OES_texture_storage_multisample_2d_array 1
+GLAD_API_CALL int GLAD_GL_OES_texture_storage_multisample_2d_array;
+#define GL_OES_texture_view 1
+GLAD_API_CALL int GLAD_GL_OES_texture_view;
+#define GL_OES_vertex_array_object 1
+GLAD_API_CALL int GLAD_GL_OES_vertex_array_object;
+#define GL_OES_vertex_half_float 1
+GLAD_API_CALL int GLAD_GL_OES_vertex_half_float;
+#define GL_OES_vertex_type_10_10_10_2 1
+GLAD_API_CALL int GLAD_GL_OES_vertex_type_10_10_10_2;
+#define GL_OES_viewport_array 1
+GLAD_API_CALL int GLAD_GL_OES_viewport_array;
+
+
+typedef GLboolean (GLAD_API_PTR *PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC)(GLuint memory, GLuint64 key, GLuint timeout);
+typedef void (GLAD_API_PTR *PFNGLACTIVESHADERPROGRAMEXTPROC)(GLuint pipeline, GLuint program);
+typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum texture);
+typedef void (GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader);
+typedef void (GLAD_API_PTR *PFNGLBEGINQUERYEXTPROC)(GLenum target, GLuint id);
+typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer);
+typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONEXTPROC)(GLuint program, GLuint color, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer);
+typedef void (GLAD_API_PTR *PFNGLBINDPROGRAMPIPELINEEXTPROC)(GLuint pipeline);
+typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer);
+typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture);
+typedef void (GLAD_API_PTR *PFNGLBINDVERTEXARRAYOESPROC)(GLuint array);
+typedef void (GLAD_API_PTR *PFNGLBLENDBARRIERKHRPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEIEXTPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEIOESPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONIEXTPROC)(GLuint buf, GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONIOESPROC)(GLuint buf, GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEIEXTPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEIOESPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCIEXTPROC)(GLuint buf, GLenum src, GLenum dst);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCIOESPROC)(GLuint buf, GLenum src, GLenum dst);
+typedef void (GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void * data, GLenum usage);
+typedef void (GLAD_API_PTR *PFNGLBUFFERSTORAGEEXTPROC)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags);
+typedef void (GLAD_API_PTR *PFNGLBUFFERSTORAGEEXTERNALEXTPROC)(GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags);
+typedef void (GLAD_API_PTR *PFNGLBUFFERSTORAGEMEMEXTPROC)(GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data);
+typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target);
+typedef void (GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield mask);
+typedef void (GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHFPROC)(GLfloat d);
+typedef void (GLAD_API_PTR *PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC)(GLsizei offset, GLsizei n, const GLuint * values);
+typedef void (GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint s);
+typedef void (GLAD_API_PTR *PFNGLCLEARTEXIMAGEEXTPROC)(GLuint texture, GLint level, GLenum format, GLenum type, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCLEARTEXSUBIMAGEEXTPROC)(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 (GLAD_API_PTR *PFNGLCLIPCONTROLEXTPROC)(GLenum origin, GLenum depth);
+typedef void (GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+typedef void (GLAD_API_PTR *PFNGLCOLORMASKIEXTPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef void (GLAD_API_PTR *PFNGLCOLORMASKIOESPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint shader);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE3DOESPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC)(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 (GLAD_API_PTR *PFNGLCOPYIMAGESUBDATAEXTPROC)(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 (GLAD_API_PTR *PFNGLCOPYIMAGESUBDATAOESPROC)(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 (GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE3DOESPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLCREATEMEMORYOBJECTSEXTPROC)(GLsizei n, GLuint * memoryObjects);
+typedef GLuint (GLAD_API_PTR *PFNGLCREATEPROGRAMPROC)(void);
+typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum type);
+typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROGRAMVEXTPROC)(GLenum type, GLsizei count, const GLchar *const* strings);
+typedef void (GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECALLBACKKHRPROC)(GLDEBUGPROCKHR callback, const void * userParam);
+typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECONTROLKHRPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled);
+typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGEINSERTKHRPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf);
+typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint * buffers);
+typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint * framebuffers);
+typedef void (GLAD_API_PTR *PFNGLDELETEMEMORYOBJECTSEXTPROC)(GLsizei n, const GLuint * memoryObjects);
+typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint program);
+typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPIPELINESEXTPROC)(GLsizei n, const GLuint * pipelines);
+typedef void (GLAD_API_PTR *PFNGLDELETEQUERIESEXTPROC)(GLsizei n, const GLuint * ids);
+typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint * renderbuffers);
+typedef void (GLAD_API_PTR *PFNGLDELETESEMAPHORESEXTPROC)(GLsizei n, const GLuint * semaphores);
+typedef void (GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint shader);
+typedef void (GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint * textures);
+typedef void (GLAD_API_PTR *PFNGLDELETEVERTEXARRAYSOESPROC)(GLsizei n, const GLuint * arrays);
+typedef void (GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum func);
+typedef void (GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean flag);
+typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEARRAYFVOESPROC)(GLuint first, GLsizei count, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEINDEXEDFOESPROC)(GLuint index, GLfloat n, GLfloat f);
+typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f);
+typedef void (GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader);
+typedef void (GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum cap);
+typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index);
+typedef void (GLAD_API_PTR *PFNGLDISABLEIEXTPROC)(GLenum target, GLuint index);
+typedef void (GLAD_API_PTR *PFNGLDISABLEIOESPROC)(GLenum target, GLuint index);
+typedef void (GLAD_API_PTR *PFNGLDISCARDFRAMEBUFFEREXTPROC)(GLenum target, GLsizei numAttachments, const GLenum * attachments);
+typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count);
+typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);
+typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDEXTPROC)(GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSEXTPROC)(GLsizei n, const GLenum * bufs);
+typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSINDEXEDEXTPROC)(GLint n, const GLenum * location, const GLint * indices);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXOESPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLuint baseinstance);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount);
+typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKEXTPROC)(GLenum mode, GLuint id);
+typedef void (GLAD_API_PTR *PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC)(GLenum mode, GLuint id, GLsizei instancecount);
+typedef void (GLAD_API_PTR *PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC)(GLenum target, GLeglImageOES image);
+typedef void (GLAD_API_PTR *PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC)(GLenum target, GLeglImageOES image, const GLint * attrib_list);
+typedef void (GLAD_API_PTR *PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)(GLenum target, GLeglImageOES image);
+typedef void (GLAD_API_PTR *PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC)(GLuint texture, GLeglImageOES image, const GLint * attrib_list);
+typedef void (GLAD_API_PTR *PFNGLENABLEPROC)(GLenum cap);
+typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index);
+typedef void (GLAD_API_PTR *PFNGLENABLEIEXTPROC)(GLenum target, GLuint index);
+typedef void (GLAD_API_PTR *PFNGLENABLEIOESPROC)(GLenum target, GLuint index);
+typedef void (GLAD_API_PTR *PFNGLENDQUERYEXTPROC)(GLenum target);
+typedef void (GLAD_API_PTR *PFNGLFINISHPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLFLUSHPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC)(GLenum target, GLintptr offset, GLsizeiptr length);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC)(GLuint target, GLsizei size);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERSHADINGRATEEXTPROC)(GLenum target, GLenum attachment, GLuint texture, GLint baseLayer, GLsizei numLayers, GLsizei texelWidth, GLsizei texelHeight);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE3DOESPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREEXTPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREOESPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level);
+typedef void (GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei n, GLuint * buffers);
+typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint * framebuffers);
+typedef void (GLAD_API_PTR *PFNGLGENPROGRAMPIPELINESEXTPROC)(GLsizei n, GLuint * pipelines);
+typedef void (GLAD_API_PTR *PFNGLGENQUERIESEXTPROC)(GLsizei n, GLuint * ids);
+typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint * renderbuffers);
+typedef void (GLAD_API_PTR *PFNGLGENSEMAPHORESEXTPROC)(GLsizei n, GLuint * semaphores);
+typedef void (GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei n, GLuint * textures);
+typedef void (GLAD_API_PTR *PFNGLGENVERTEXARRAYSOESPROC)(GLsizei n, GLuint * arrays);
+typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum target);
+typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders);
+typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean * data);
+typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETBUFFERPOINTERVOESPROC)(GLenum target, GLenum pname, void ** params);
+typedef GLuint (GLAD_API_PTR *PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog);
+typedef GLenum (GLAD_API_PTR *PFNGLGETERRORPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLGETFLOATI_VOESPROC)(GLenum target, GLuint index, GLfloat * data);
+typedef void (GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum pname, GLfloat * data);
+typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATAINDEXEXTPROC)(GLuint program, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETFRAGMENTSHADINGRATESEXTPROC)(GLsizei samples, GLsizei maxCount, GLsizei * count, GLenum * shadingRates);
+typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint * params);
+typedef GLsizei (GLAD_API_PTR *PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC)(GLuint target);
+typedef GLenum (GLAD_API_PTR *PFNGLGETGRAPHICSRESETSTATUSEXTPROC)(void);
+typedef GLenum (GLAD_API_PTR *PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLGETINTEGER64VEXTPROC)(GLenum pname, GLint64 * data);
+typedef void (GLAD_API_PTR *PFNGLGETINTEGERI_VEXTPROC)(GLenum target, GLuint index, GLint * data);
+typedef void (GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum pname, GLint * data);
+typedef void (GLAD_API_PTR *PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC)(GLuint memoryObject, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETOBJECTLABELEXTPROC)(GLenum type, GLuint object, GLsizei bufSize, GLsizei * length, GLchar * label);
+typedef void (GLAD_API_PTR *PFNGLGETOBJECTLABELKHRPROC)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label);
+typedef void (GLAD_API_PTR *PFNGLGETOBJECTPTRLABELKHRPROC)(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label);
+typedef void (GLAD_API_PTR *PFNGLGETPOINTERVKHRPROC)(GLenum pname, void ** params);
+typedef void (GLAD_API_PTR *PFNGLGETPROGRAMBINARYOESPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary);
+typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
+typedef void (GLAD_API_PTR *PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC)(GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
+typedef void (GLAD_API_PTR *PFNGLGETPROGRAMPIPELINEIVEXTPROC)(GLuint pipeline, GLenum pname, GLint * params);
+typedef GLint (GLAD_API_PTR *PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC)(GLuint program, GLenum programInterface, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTI64VEXTPROC)(GLuint id, GLenum pname, GLint64 * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTIVEXTPROC)(GLuint id, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUI64VEXTPROC)(GLuint id, GLenum pname, GLuint64 * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUIVEXTPROC)(GLuint id, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYIVEXTPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVEXTPROC)(GLuint sampler, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVOESPROC)(GLuint sampler, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVEXTPROC)(GLuint sampler, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVOESPROC)(GLuint sampler, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC)(GLuint semaphore, GLenum pname, GLuint64 * params);
+typedef void (GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
+typedef void (GLAD_API_PTR *PFNGLGETSHADERPRECISIONFORMATPROC)(GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision);
+typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source);
+typedef void (GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint * params);
+typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum name);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVEXTPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVOESPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVEXTPROC)(GLenum target, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVOESPROC)(GLenum target, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
+typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETUNSIGNEDBYTEI_VEXTPROC)(GLenum target, GLuint index, GLubyte * data);
+typedef void (GLAD_API_PTR *PFNGLGETUNSIGNEDBYTEVEXTPROC)(GLenum pname, GLubyte * data);
+typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void ** pointer);
+typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMFVEXTPROC)(GLuint program, GLint location, GLsizei bufSize, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMFVKHRPROC)(GLuint program, GLint location, GLsizei bufSize, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMIVEXTPROC)(GLuint program, GLint location, GLsizei bufSize, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMIVKHRPROC)(GLuint program, GLint location, GLsizei bufSize, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMUIVKHRPROC)(GLuint program, GLint location, GLsizei bufSize, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLHINTPROC)(GLenum target, GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLIMPORTMEMORYFDEXTPROC)(GLuint memory, GLuint64 size, GLenum handleType, GLint fd);
+typedef void (GLAD_API_PTR *PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC)(GLuint memory, GLuint64 size, GLenum handleType, void * handle);
+typedef void (GLAD_API_PTR *PFNGLIMPORTMEMORYWIN32NAMEEXTPROC)(GLuint memory, GLuint64 size, GLenum handleType, const void * name);
+typedef void (GLAD_API_PTR *PFNGLIMPORTSEMAPHOREFDEXTPROC)(GLuint semaphore, GLenum handleType, GLint fd);
+typedef void (GLAD_API_PTR *PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC)(GLuint semaphore, GLenum handleType, void * handle);
+typedef void (GLAD_API_PTR *PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC)(GLuint semaphore, GLenum handleType, const void * name);
+typedef void (GLAD_API_PTR *PFNGLINSERTEVENTMARKEREXTPROC)(GLsizei length, const GLchar * marker);
+typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint buffer);
+typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum cap);
+typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIEXTPROC)(GLenum target, GLuint index);
+typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIOESPROC)(GLenum target, GLuint index);
+typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer);
+typedef GLboolean (GLAD_API_PTR *PFNGLISMEMORYOBJECTEXTPROC)(GLuint memoryObject);
+typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint program);
+typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPIPELINEEXTPROC)(GLuint pipeline);
+typedef GLboolean (GLAD_API_PTR *PFNGLISQUERYEXTPROC)(GLuint id);
+typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer);
+typedef GLboolean (GLAD_API_PTR *PFNGLISSEMAPHOREEXTPROC)(GLuint semaphore);
+typedef GLboolean (GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint shader);
+typedef GLboolean (GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint texture);
+typedef GLboolean (GLAD_API_PTR *PFNGLISVERTEXARRAYOESPROC)(GLuint array);
+typedef void (GLAD_API_PTR *PFNGLLABELOBJECTEXTPROC)(GLenum type, GLuint object, GLsizei length, const GLchar * label);
+typedef void (GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat width);
+typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint program);
+typedef void * (GLAD_API_PTR *PFNGLMAPBUFFEROESPROC)(GLenum target, GLenum access);
+typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERRANGEEXTPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (GLAD_API_PTR *PFNGLMAXSHADERCOMPILERTHREADSKHRPROC)(GLuint count);
+typedef void (GLAD_API_PTR *PFNGLMEMORYOBJECTPARAMETERIVEXTPROC)(GLuint memoryObject, GLenum pname, const GLint * params);
+typedef void (GLAD_API_PTR *PFNGLMINSAMPLESHADINGOESPROC)(GLfloat value);
+typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSEXTPROC)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei primcount);
+typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC)(GLenum mode, const void * indirect, GLsizei drawcount, GLsizei stride);
+typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex);
+typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSEXTPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei primcount);
+typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC)(GLenum mode, GLenum type, const void * indirect, GLsizei drawcount, GLsizei stride);
+typedef void (GLAD_API_PTR *PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC)(GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags);
+typedef void (GLAD_API_PTR *PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC)(GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLOBJECTLABELKHRPROC)(GLenum identifier, GLuint name, GLsizei length, const GLchar * label);
+typedef void (GLAD_API_PTR *PFNGLOBJECTPTRLABELKHRPROC)(const void * ptr, GLsizei length, const GLchar * label);
+typedef void (GLAD_API_PTR *PFNGLPATCHPARAMETERIEXTPROC)(GLenum pname, GLint value);
+typedef void (GLAD_API_PTR *PFNGLPATCHPARAMETERIOESPROC)(GLenum pname, GLint value);
+typedef void (GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param);
+typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units);
+typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETCLAMPEXTPROC)(GLfloat factor, GLfloat units, GLfloat clamp);
+typedef void (GLAD_API_PTR *PFNGLPOPDEBUGGROUPKHRPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLPOPGROUPMARKEREXTPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLPRIMITIVEBOUNDINGBOXEXTPROC)(GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
+typedef void (GLAD_API_PTR *PFNGLPRIMITIVEBOUNDINGBOXOESPROC)(GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMBINARYOESPROC)(GLuint program, GLenum binaryFormat, const void * binary, GLint length);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMPARAMETERIEXTPROC)(GLuint program, GLenum pname, GLint value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1FEXTPROC)(GLuint program, GLint location, GLfloat v0);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1FVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1IEXTPROC)(GLuint program, GLint location, GLint v0);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1IVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UIEXTPROC)(GLuint program, GLint location, GLuint v0);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM1UIVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2FEXTPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2FVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2IEXTPROC)(GLuint program, GLint location, GLint v0, GLint v1);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2IVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UIEXTPROC)(GLuint program, GLint location, GLuint v0, GLuint v1);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM2UIVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3FEXTPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3FVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3IEXTPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3IVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UIEXTPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM3UIVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4FEXTPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4FVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4IEXTPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4IVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UIEXTPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORM4UIVEXTPROC)(GLuint program, GLint location, GLsizei count, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLPUSHDEBUGGROUPKHRPROC)(GLenum source, GLuint id, GLsizei length, const GLchar * message);
+typedef void (GLAD_API_PTR *PFNGLPUSHGROUPMARKEREXTPROC)(GLsizei length, const GLchar * marker);
+typedef void (GLAD_API_PTR *PFNGLQUERYCOUNTEREXTPROC)(GLuint id, GLenum target);
+typedef void (GLAD_API_PTR *PFNGLRASTERSAMPLESEXTPROC)(GLuint samples, GLboolean fixedsamplelocations);
+typedef void (GLAD_API_PTR *PFNGLREADBUFFERINDEXEDEXTPROC)(GLenum src, GLint index);
+typedef void (GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels);
+typedef void (GLAD_API_PTR *PFNGLREADNPIXELSEXTPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data);
+typedef void (GLAD_API_PTR *PFNGLREADNPIXELSKHRPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data);
+typedef GLboolean (GLAD_API_PTR *PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC)(GLuint memory, GLuint64 key);
+typedef void (GLAD_API_PTR *PFNGLRELEASESHADERCOMPILERPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVEXTPROC)(GLuint sampler, GLenum pname, const GLint * param);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVOESPROC)(GLuint sampler, GLenum pname, const GLint * param);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVEXTPROC)(GLuint sampler, GLenum pname, const GLuint * param);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVOESPROC)(GLuint sampler, GLenum pname, const GLuint * param);
+typedef void (GLAD_API_PTR *PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLSCISSORARRAYVOESPROC)(GLuint first, GLsizei count, const GLint * v);
+typedef void (GLAD_API_PTR *PFNGLSCISSORINDEXEDOESPROC)(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLSCISSORINDEXEDVOESPROC)(GLuint index, const GLint * v);
+typedef void (GLAD_API_PTR *PFNGLSEMAPHOREPARAMETERUI64VEXTPROC)(GLuint semaphore, GLenum pname, const GLuint64 * params);
+typedef void (GLAD_API_PTR *PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint * shaders, GLenum binaryFormat, const void * binary, GLsizei length);
+typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length);
+typedef void (GLAD_API_PTR *PFNGLSHADINGRATECOMBINEROPSEXTPROC)(GLenum combinerOp0, GLenum combinerOp1);
+typedef void (GLAD_API_PTR *PFNGLSHADINGRATEEXTPROC)(GLenum rate);
+typedef void (GLAD_API_PTR *PFNGLSIGNALSEMAPHOREEXTPROC)(GLuint semaphore, GLuint numBufferBarriers, const GLuint * buffers, GLuint numTextureBarriers, const GLuint * textures, const GLenum * dstLayouts);
+typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask);
+typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask);
+typedef void (GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint mask);
+typedef void (GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask);
+typedef void (GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass);
+typedef void (GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (GLAD_API_PTR *PFNGLTEXBUFFEREXTPROC)(GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (GLAD_API_PTR *PFNGLTEXBUFFEROESPROC)(GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (GLAD_API_PTR *PFNGLTEXBUFFERRANGEEXTPROC)(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (GLAD_API_PTR *PFNGLTEXBUFFERRANGEOESPROC)(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels);
+typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DOESPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels);
+typedef void (GLAD_API_PTR *PFNGLTEXPAGECOMMITMENTEXTPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVEXTPROC)(GLenum target, GLenum pname, const GLint * params);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVOESPROC)(GLenum target, GLenum pname, const GLint * params);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVEXTPROC)(GLenum target, GLenum pname, const GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVOESPROC)(GLenum target, GLenum pname, const GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint * params);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE1DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE2DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE3DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEATTRIBS2DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, const GLint * attrib_list);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEATTRIBS3DEXTPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, const GLint * attrib_list);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEMEM2DEXTPROC)(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEMEM3DEXTPROC)(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels);
+typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE3DOESPROC)(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 (GLAD_API_PTR *PFNGLTEXTURESTORAGE1DEXTPROC)(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGE2DEXTPROC)(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGE3DEXTPROC)(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGEMEM2DEXTPROC)(GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC)(GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGEMEM3DEXTPROC)(GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC)(GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset);
+typedef void (GLAD_API_PTR *PFNGLTEXTUREVIEWEXTPROC)(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+typedef void (GLAD_API_PTR *PFNGLTEXTUREVIEWOESPROC)(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint location, GLint v0);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef GLboolean (GLAD_API_PTR *PFNGLUNMAPBUFFEROESPROC)(GLenum target);
+typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint program);
+typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMSTAGESEXTPROC)(GLuint pipeline, GLbitfield stages, GLuint program);
+typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint program);
+typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPIPELINEEXTPROC)(GLuint pipeline);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBDIVISOREXTPROC)(GLuint index, GLuint divisor);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer);
+typedef void (GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLVIEWPORTARRAYVOESPROC)(GLuint first, GLsizei count, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVIEWPORTINDEXEDFOESPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
+typedef void (GLAD_API_PTR *PFNGLVIEWPORTINDEXEDFVOESPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLWAITSEMAPHOREEXTPROC)(GLuint semaphore, GLuint numBufferBarriers, const GLuint * buffers, GLuint numTextureBarriers, const GLuint * textures, const GLenum * srcLayouts);
+typedef void (GLAD_API_PTR *PFNGLWINDOWRECTANGLESEXTPROC)(GLenum mode, GLsizei count, const GLint * box);
+
+GLAD_API_CALL PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC glad_glAcquireKeyedMutexWin32EXT;
+#define glAcquireKeyedMutexWin32EXT glad_glAcquireKeyedMutexWin32EXT
+GLAD_API_CALL PFNGLACTIVESHADERPROGRAMEXTPROC glad_glActiveShaderProgramEXT;
+#define glActiveShaderProgramEXT glad_glActiveShaderProgramEXT
+GLAD_API_CALL PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
+#define glActiveTexture glad_glActiveTexture
+GLAD_API_CALL PFNGLATTACHSHADERPROC glad_glAttachShader;
+#define glAttachShader glad_glAttachShader
+GLAD_API_CALL PFNGLBEGINQUERYEXTPROC glad_glBeginQueryEXT;
+#define glBeginQueryEXT glad_glBeginQueryEXT
+GLAD_API_CALL PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
+#define glBindAttribLocation glad_glBindAttribLocation
+GLAD_API_CALL PFNGLBINDBUFFERPROC glad_glBindBuffer;
+#define glBindBuffer glad_glBindBuffer
+GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONEXTPROC glad_glBindFragDataLocationEXT;
+#define glBindFragDataLocationEXT glad_glBindFragDataLocationEXT
+GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC glad_glBindFragDataLocationIndexedEXT;
+#define glBindFragDataLocationIndexedEXT glad_glBindFragDataLocationIndexedEXT
+GLAD_API_CALL PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
+#define glBindFramebuffer glad_glBindFramebuffer
+GLAD_API_CALL PFNGLBINDPROGRAMPIPELINEEXTPROC glad_glBindProgramPipelineEXT;
+#define glBindProgramPipelineEXT glad_glBindProgramPipelineEXT
+GLAD_API_CALL PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
+#define glBindRenderbuffer glad_glBindRenderbuffer
+GLAD_API_CALL PFNGLBINDTEXTUREPROC glad_glBindTexture;
+#define glBindTexture glad_glBindTexture
+GLAD_API_CALL PFNGLBINDVERTEXARRAYOESPROC glad_glBindVertexArrayOES;
+#define glBindVertexArrayOES glad_glBindVertexArrayOES
+GLAD_API_CALL PFNGLBLENDBARRIERKHRPROC glad_glBlendBarrierKHR;
+#define glBlendBarrierKHR glad_glBlendBarrierKHR
+GLAD_API_CALL PFNGLBLENDCOLORPROC glad_glBlendColor;
+#define glBlendColor glad_glBlendColor
+GLAD_API_CALL PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
+#define glBlendEquation glad_glBlendEquation
+GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
+#define glBlendEquationSeparate glad_glBlendEquationSeparate
+GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEIEXTPROC glad_glBlendEquationSeparateiEXT;
+#define glBlendEquationSeparateiEXT glad_glBlendEquationSeparateiEXT
+GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEIOESPROC glad_glBlendEquationSeparateiOES;
+#define glBlendEquationSeparateiOES glad_glBlendEquationSeparateiOES
+GLAD_API_CALL PFNGLBLENDEQUATIONIEXTPROC glad_glBlendEquationiEXT;
+#define glBlendEquationiEXT glad_glBlendEquationiEXT
+GLAD_API_CALL PFNGLBLENDEQUATIONIOESPROC glad_glBlendEquationiOES;
+#define glBlendEquationiOES glad_glBlendEquationiOES
+GLAD_API_CALL PFNGLBLENDFUNCPROC glad_glBlendFunc;
+#define glBlendFunc glad_glBlendFunc
+GLAD_API_CALL PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
+#define glBlendFuncSeparate glad_glBlendFuncSeparate
+GLAD_API_CALL PFNGLBLENDFUNCSEPARATEIEXTPROC glad_glBlendFuncSeparateiEXT;
+#define glBlendFuncSeparateiEXT glad_glBlendFuncSeparateiEXT
+GLAD_API_CALL PFNGLBLENDFUNCSEPARATEIOESPROC glad_glBlendFuncSeparateiOES;
+#define glBlendFuncSeparateiOES glad_glBlendFuncSeparateiOES
+GLAD_API_CALL PFNGLBLENDFUNCIEXTPROC glad_glBlendFunciEXT;
+#define glBlendFunciEXT glad_glBlendFunciEXT
+GLAD_API_CALL PFNGLBLENDFUNCIOESPROC glad_glBlendFunciOES;
+#define glBlendFunciOES glad_glBlendFunciOES
+GLAD_API_CALL PFNGLBUFFERDATAPROC glad_glBufferData;
+#define glBufferData glad_glBufferData
+GLAD_API_CALL PFNGLBUFFERSTORAGEEXTPROC glad_glBufferStorageEXT;
+#define glBufferStorageEXT glad_glBufferStorageEXT
+GLAD_API_CALL PFNGLBUFFERSTORAGEEXTERNALEXTPROC glad_glBufferStorageExternalEXT;
+#define glBufferStorageExternalEXT glad_glBufferStorageExternalEXT
+GLAD_API_CALL PFNGLBUFFERSTORAGEMEMEXTPROC glad_glBufferStorageMemEXT;
+#define glBufferStorageMemEXT glad_glBufferStorageMemEXT
+GLAD_API_CALL PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
+#define glBufferSubData glad_glBufferSubData
+GLAD_API_CALL PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
+#define glCheckFramebufferStatus glad_glCheckFramebufferStatus
+GLAD_API_CALL PFNGLCLEARPROC glad_glClear;
+#define glClear glad_glClear
+GLAD_API_CALL PFNGLCLEARCOLORPROC glad_glClearColor;
+#define glClearColor glad_glClearColor
+GLAD_API_CALL PFNGLCLEARDEPTHFPROC glad_glClearDepthf;
+#define glClearDepthf glad_glClearDepthf
+GLAD_API_CALL PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC glad_glClearPixelLocalStorageuiEXT;
+#define glClearPixelLocalStorageuiEXT glad_glClearPixelLocalStorageuiEXT
+GLAD_API_CALL PFNGLCLEARSTENCILPROC glad_glClearStencil;
+#define glClearStencil glad_glClearStencil
+GLAD_API_CALL PFNGLCLEARTEXIMAGEEXTPROC glad_glClearTexImageEXT;
+#define glClearTexImageEXT glad_glClearTexImageEXT
+GLAD_API_CALL PFNGLCLEARTEXSUBIMAGEEXTPROC glad_glClearTexSubImageEXT;
+#define glClearTexSubImageEXT glad_glClearTexSubImageEXT
+GLAD_API_CALL PFNGLCLIPCONTROLEXTPROC glad_glClipControlEXT;
+#define glClipControlEXT glad_glClipControlEXT
+GLAD_API_CALL PFNGLCOLORMASKPROC glad_glColorMask;
+#define glColorMask glad_glColorMask
+GLAD_API_CALL PFNGLCOLORMASKIEXTPROC glad_glColorMaskiEXT;
+#define glColorMaskiEXT glad_glColorMaskiEXT
+GLAD_API_CALL PFNGLCOLORMASKIOESPROC glad_glColorMaskiOES;
+#define glColorMaskiOES glad_glColorMaskiOES
+GLAD_API_CALL PFNGLCOMPILESHADERPROC glad_glCompileShader;
+#define glCompileShader glad_glCompileShader
+GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
+#define glCompressedTexImage2D glad_glCompressedTexImage2D
+GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE3DOESPROC glad_glCompressedTexImage3DOES;
+#define glCompressedTexImage3DOES glad_glCompressedTexImage3DOES
+GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
+#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D
+GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC glad_glCompressedTexSubImage3DOES;
+#define glCompressedTexSubImage3DOES glad_glCompressedTexSubImage3DOES
+GLAD_API_CALL PFNGLCOPYIMAGESUBDATAEXTPROC glad_glCopyImageSubDataEXT;
+#define glCopyImageSubDataEXT glad_glCopyImageSubDataEXT
+GLAD_API_CALL PFNGLCOPYIMAGESUBDATAOESPROC glad_glCopyImageSubDataOES;
+#define glCopyImageSubDataOES glad_glCopyImageSubDataOES
+GLAD_API_CALL PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
+#define glCopyTexImage2D glad_glCopyTexImage2D
+GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
+#define glCopyTexSubImage2D glad_glCopyTexSubImage2D
+GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE3DOESPROC glad_glCopyTexSubImage3DOES;
+#define glCopyTexSubImage3DOES glad_glCopyTexSubImage3DOES
+GLAD_API_CALL PFNGLCREATEMEMORYOBJECTSEXTPROC glad_glCreateMemoryObjectsEXT;
+#define glCreateMemoryObjectsEXT glad_glCreateMemoryObjectsEXT
+GLAD_API_CALL PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
+#define glCreateProgram glad_glCreateProgram
+GLAD_API_CALL PFNGLCREATESHADERPROC glad_glCreateShader;
+#define glCreateShader glad_glCreateShader
+GLAD_API_CALL PFNGLCREATESHADERPROGRAMVEXTPROC glad_glCreateShaderProgramvEXT;
+#define glCreateShaderProgramvEXT glad_glCreateShaderProgramvEXT
+GLAD_API_CALL PFNGLCULLFACEPROC glad_glCullFace;
+#define glCullFace glad_glCullFace
+GLAD_API_CALL PFNGLDEBUGMESSAGECALLBACKKHRPROC glad_glDebugMessageCallbackKHR;
+#define glDebugMessageCallbackKHR glad_glDebugMessageCallbackKHR
+GLAD_API_CALL PFNGLDEBUGMESSAGECONTROLKHRPROC glad_glDebugMessageControlKHR;
+#define glDebugMessageControlKHR glad_glDebugMessageControlKHR
+GLAD_API_CALL PFNGLDEBUGMESSAGEINSERTKHRPROC glad_glDebugMessageInsertKHR;
+#define glDebugMessageInsertKHR glad_glDebugMessageInsertKHR
+GLAD_API_CALL PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
+#define glDeleteBuffers glad_glDeleteBuffers
+GLAD_API_CALL PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
+#define glDeleteFramebuffers glad_glDeleteFramebuffers
+GLAD_API_CALL PFNGLDELETEMEMORYOBJECTSEXTPROC glad_glDeleteMemoryObjectsEXT;
+#define glDeleteMemoryObjectsEXT glad_glDeleteMemoryObjectsEXT
+GLAD_API_CALL PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
+#define glDeleteProgram glad_glDeleteProgram
+GLAD_API_CALL PFNGLDELETEPROGRAMPIPELINESEXTPROC glad_glDeleteProgramPipelinesEXT;
+#define glDeleteProgramPipelinesEXT glad_glDeleteProgramPipelinesEXT
+GLAD_API_CALL PFNGLDELETEQUERIESEXTPROC glad_glDeleteQueriesEXT;
+#define glDeleteQueriesEXT glad_glDeleteQueriesEXT
+GLAD_API_CALL PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
+#define glDeleteRenderbuffers glad_glDeleteRenderbuffers
+GLAD_API_CALL PFNGLDELETESEMAPHORESEXTPROC glad_glDeleteSemaphoresEXT;
+#define glDeleteSemaphoresEXT glad_glDeleteSemaphoresEXT
+GLAD_API_CALL PFNGLDELETESHADERPROC glad_glDeleteShader;
+#define glDeleteShader glad_glDeleteShader
+GLAD_API_CALL PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
+#define glDeleteTextures glad_glDeleteTextures
+GLAD_API_CALL PFNGLDELETEVERTEXARRAYSOESPROC glad_glDeleteVertexArraysOES;
+#define glDeleteVertexArraysOES glad_glDeleteVertexArraysOES
+GLAD_API_CALL PFNGLDEPTHFUNCPROC glad_glDepthFunc;
+#define glDepthFunc glad_glDepthFunc
+GLAD_API_CALL PFNGLDEPTHMASKPROC glad_glDepthMask;
+#define glDepthMask glad_glDepthMask
+GLAD_API_CALL PFNGLDEPTHRANGEARRAYFVOESPROC glad_glDepthRangeArrayfvOES;
+#define glDepthRangeArrayfvOES glad_glDepthRangeArrayfvOES
+GLAD_API_CALL PFNGLDEPTHRANGEINDEXEDFOESPROC glad_glDepthRangeIndexedfOES;
+#define glDepthRangeIndexedfOES glad_glDepthRangeIndexedfOES
+GLAD_API_CALL PFNGLDEPTHRANGEFPROC glad_glDepthRangef;
+#define glDepthRangef glad_glDepthRangef
+GLAD_API_CALL PFNGLDETACHSHADERPROC glad_glDetachShader;
+#define glDetachShader glad_glDetachShader
+GLAD_API_CALL PFNGLDISABLEPROC glad_glDisable;
+#define glDisable glad_glDisable
+GLAD_API_CALL PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
+#define glDisableVertexAttribArray glad_glDisableVertexAttribArray
+GLAD_API_CALL PFNGLDISABLEIEXTPROC glad_glDisableiEXT;
+#define glDisableiEXT glad_glDisableiEXT
+GLAD_API_CALL PFNGLDISABLEIOESPROC glad_glDisableiOES;
+#define glDisableiOES glad_glDisableiOES
+GLAD_API_CALL PFNGLDISCARDFRAMEBUFFEREXTPROC glad_glDiscardFramebufferEXT;
+#define glDiscardFramebufferEXT glad_glDiscardFramebufferEXT
+GLAD_API_CALL PFNGLDRAWARRAYSPROC glad_glDrawArrays;
+#define glDrawArrays glad_glDrawArrays
+GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC glad_glDrawArraysInstancedBaseInstanceEXT;
+#define glDrawArraysInstancedBaseInstanceEXT glad_glDrawArraysInstancedBaseInstanceEXT
+GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDEXTPROC glad_glDrawArraysInstancedEXT;
+#define glDrawArraysInstancedEXT glad_glDrawArraysInstancedEXT
+GLAD_API_CALL PFNGLDRAWBUFFERSEXTPROC glad_glDrawBuffersEXT;
+#define glDrawBuffersEXT glad_glDrawBuffersEXT
+GLAD_API_CALL PFNGLDRAWBUFFERSINDEXEDEXTPROC glad_glDrawBuffersIndexedEXT;
+#define glDrawBuffersIndexedEXT glad_glDrawBuffersIndexedEXT
+GLAD_API_CALL PFNGLDRAWELEMENTSPROC glad_glDrawElements;
+#define glDrawElements glad_glDrawElements
+GLAD_API_CALL PFNGLDRAWELEMENTSBASEVERTEXEXTPROC glad_glDrawElementsBaseVertexEXT;
+#define glDrawElementsBaseVertexEXT glad_glDrawElementsBaseVertexEXT
+GLAD_API_CALL PFNGLDRAWELEMENTSBASEVERTEXOESPROC glad_glDrawElementsBaseVertexOES;
+#define glDrawElementsBaseVertexOES glad_glDrawElementsBaseVertexOES
+GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC glad_glDrawElementsInstancedBaseInstanceEXT;
+#define glDrawElementsInstancedBaseInstanceEXT glad_glDrawElementsInstancedBaseInstanceEXT
+GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC glad_glDrawElementsInstancedBaseVertexBaseInstanceEXT;
+#define glDrawElementsInstancedBaseVertexBaseInstanceEXT glad_glDrawElementsInstancedBaseVertexBaseInstanceEXT
+GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC glad_glDrawElementsInstancedBaseVertexEXT;
+#define glDrawElementsInstancedBaseVertexEXT glad_glDrawElementsInstancedBaseVertexEXT
+GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC glad_glDrawElementsInstancedBaseVertexOES;
+#define glDrawElementsInstancedBaseVertexOES glad_glDrawElementsInstancedBaseVertexOES
+GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDEXTPROC glad_glDrawElementsInstancedEXT;
+#define glDrawElementsInstancedEXT glad_glDrawElementsInstancedEXT
+GLAD_API_CALL PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC glad_glDrawRangeElementsBaseVertexEXT;
+#define glDrawRangeElementsBaseVertexEXT glad_glDrawRangeElementsBaseVertexEXT
+GLAD_API_CALL PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC glad_glDrawRangeElementsBaseVertexOES;
+#define glDrawRangeElementsBaseVertexOES glad_glDrawRangeElementsBaseVertexOES
+GLAD_API_CALL PFNGLDRAWTRANSFORMFEEDBACKEXTPROC glad_glDrawTransformFeedbackEXT;
+#define glDrawTransformFeedbackEXT glad_glDrawTransformFeedbackEXT
+GLAD_API_CALL PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC glad_glDrawTransformFeedbackInstancedEXT;
+#define glDrawTransformFeedbackInstancedEXT glad_glDrawTransformFeedbackInstancedEXT
+GLAD_API_CALL PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glad_glEGLImageTargetRenderbufferStorageOES;
+#define glEGLImageTargetRenderbufferStorageOES glad_glEGLImageTargetRenderbufferStorageOES
+GLAD_API_CALL PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC glad_glEGLImageTargetTexStorageEXT;
+#define glEGLImageTargetTexStorageEXT glad_glEGLImageTargetTexStorageEXT
+GLAD_API_CALL PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glad_glEGLImageTargetTexture2DOES;
+#define glEGLImageTargetTexture2DOES glad_glEGLImageTargetTexture2DOES
+GLAD_API_CALL PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC glad_glEGLImageTargetTextureStorageEXT;
+#define glEGLImageTargetTextureStorageEXT glad_glEGLImageTargetTextureStorageEXT
+GLAD_API_CALL PFNGLENABLEPROC glad_glEnable;
+#define glEnable glad_glEnable
+GLAD_API_CALL PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
+#define glEnableVertexAttribArray glad_glEnableVertexAttribArray
+GLAD_API_CALL PFNGLENABLEIEXTPROC glad_glEnableiEXT;
+#define glEnableiEXT glad_glEnableiEXT
+GLAD_API_CALL PFNGLENABLEIOESPROC glad_glEnableiOES;
+#define glEnableiOES glad_glEnableiOES
+GLAD_API_CALL PFNGLENDQUERYEXTPROC glad_glEndQueryEXT;
+#define glEndQueryEXT glad_glEndQueryEXT
+GLAD_API_CALL PFNGLFINISHPROC glad_glFinish;
+#define glFinish glad_glFinish
+GLAD_API_CALL PFNGLFLUSHPROC glad_glFlush;
+#define glFlush glad_glFlush
+GLAD_API_CALL PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC glad_glFlushMappedBufferRangeEXT;
+#define glFlushMappedBufferRangeEXT glad_glFlushMappedBufferRangeEXT
+GLAD_API_CALL PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC glad_glFramebufferFetchBarrierEXT;
+#define glFramebufferFetchBarrierEXT glad_glFramebufferFetchBarrierEXT
+GLAD_API_CALL PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC glad_glFramebufferPixelLocalStorageSizeEXT;
+#define glFramebufferPixelLocalStorageSizeEXT glad_glFramebufferPixelLocalStorageSizeEXT
+GLAD_API_CALL PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
+#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer
+GLAD_API_CALL PFNGLFRAMEBUFFERSHADINGRATEEXTPROC glad_glFramebufferShadingRateEXT;
+#define glFramebufferShadingRateEXT glad_glFramebufferShadingRateEXT
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
+#define glFramebufferTexture2D glad_glFramebufferTexture2D
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC glad_glFramebufferTexture2DMultisampleEXT;
+#define glFramebufferTexture2DMultisampleEXT glad_glFramebufferTexture2DMultisampleEXT
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE3DOESPROC glad_glFramebufferTexture3DOES;
+#define glFramebufferTexture3DOES glad_glFramebufferTexture3DOES
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTUREEXTPROC glad_glFramebufferTextureEXT;
+#define glFramebufferTextureEXT glad_glFramebufferTextureEXT
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTUREOESPROC glad_glFramebufferTextureOES;
+#define glFramebufferTextureOES glad_glFramebufferTextureOES
+GLAD_API_CALL PFNGLFRONTFACEPROC glad_glFrontFace;
+#define glFrontFace glad_glFrontFace
+GLAD_API_CALL PFNGLGENBUFFERSPROC glad_glGenBuffers;
+#define glGenBuffers glad_glGenBuffers
+GLAD_API_CALL PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
+#define glGenFramebuffers glad_glGenFramebuffers
+GLAD_API_CALL PFNGLGENPROGRAMPIPELINESEXTPROC glad_glGenProgramPipelinesEXT;
+#define glGenProgramPipelinesEXT glad_glGenProgramPipelinesEXT
+GLAD_API_CALL PFNGLGENQUERIESEXTPROC glad_glGenQueriesEXT;
+#define glGenQueriesEXT glad_glGenQueriesEXT
+GLAD_API_CALL PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
+#define glGenRenderbuffers glad_glGenRenderbuffers
+GLAD_API_CALL PFNGLGENSEMAPHORESEXTPROC glad_glGenSemaphoresEXT;
+#define glGenSemaphoresEXT glad_glGenSemaphoresEXT
+GLAD_API_CALL PFNGLGENTEXTURESPROC glad_glGenTextures;
+#define glGenTextures glad_glGenTextures
+GLAD_API_CALL PFNGLGENVERTEXARRAYSOESPROC glad_glGenVertexArraysOES;
+#define glGenVertexArraysOES glad_glGenVertexArraysOES
+GLAD_API_CALL PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
+#define glGenerateMipmap glad_glGenerateMipmap
+GLAD_API_CALL PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
+#define glGetActiveAttrib glad_glGetActiveAttrib
+GLAD_API_CALL PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
+#define glGetActiveUniform glad_glGetActiveUniform
+GLAD_API_CALL PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
+#define glGetAttachedShaders glad_glGetAttachedShaders
+GLAD_API_CALL PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
+#define glGetAttribLocation glad_glGetAttribLocation
+GLAD_API_CALL PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
+#define glGetBooleanv glad_glGetBooleanv
+GLAD_API_CALL PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
+#define glGetBufferParameteriv glad_glGetBufferParameteriv
+GLAD_API_CALL PFNGLGETBUFFERPOINTERVOESPROC glad_glGetBufferPointervOES;
+#define glGetBufferPointervOES glad_glGetBufferPointervOES
+GLAD_API_CALL PFNGLGETDEBUGMESSAGELOGKHRPROC glad_glGetDebugMessageLogKHR;
+#define glGetDebugMessageLogKHR glad_glGetDebugMessageLogKHR
+GLAD_API_CALL PFNGLGETERRORPROC glad_glGetError;
+#define glGetError glad_glGetError
+GLAD_API_CALL PFNGLGETFLOATI_VOESPROC glad_glGetFloati_vOES;
+#define glGetFloati_vOES glad_glGetFloati_vOES
+GLAD_API_CALL PFNGLGETFLOATVPROC glad_glGetFloatv;
+#define glGetFloatv glad_glGetFloatv
+GLAD_API_CALL PFNGLGETFRAGDATAINDEXEXTPROC glad_glGetFragDataIndexEXT;
+#define glGetFragDataIndexEXT glad_glGetFragDataIndexEXT
+GLAD_API_CALL PFNGLGETFRAGMENTSHADINGRATESEXTPROC glad_glGetFragmentShadingRatesEXT;
+#define glGetFragmentShadingRatesEXT glad_glGetFragmentShadingRatesEXT
+GLAD_API_CALL PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
+#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv
+GLAD_API_CALL PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC glad_glGetFramebufferPixelLocalStorageSizeEXT;
+#define glGetFramebufferPixelLocalStorageSizeEXT glad_glGetFramebufferPixelLocalStorageSizeEXT
+GLAD_API_CALL PFNGLGETGRAPHICSRESETSTATUSEXTPROC glad_glGetGraphicsResetStatusEXT;
+#define glGetGraphicsResetStatusEXT glad_glGetGraphicsResetStatusEXT
+GLAD_API_CALL PFNGLGETGRAPHICSRESETSTATUSKHRPROC glad_glGetGraphicsResetStatusKHR;
+#define glGetGraphicsResetStatusKHR glad_glGetGraphicsResetStatusKHR
+GLAD_API_CALL PFNGLGETINTEGER64VEXTPROC glad_glGetInteger64vEXT;
+#define glGetInteger64vEXT glad_glGetInteger64vEXT
+GLAD_API_CALL PFNGLGETINTEGERI_VEXTPROC glad_glGetIntegeri_vEXT;
+#define glGetIntegeri_vEXT glad_glGetIntegeri_vEXT
+GLAD_API_CALL PFNGLGETINTEGERVPROC glad_glGetIntegerv;
+#define glGetIntegerv glad_glGetIntegerv
+GLAD_API_CALL PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC glad_glGetMemoryObjectParameterivEXT;
+#define glGetMemoryObjectParameterivEXT glad_glGetMemoryObjectParameterivEXT
+GLAD_API_CALL PFNGLGETOBJECTLABELEXTPROC glad_glGetObjectLabelEXT;
+#define glGetObjectLabelEXT glad_glGetObjectLabelEXT
+GLAD_API_CALL PFNGLGETOBJECTLABELKHRPROC glad_glGetObjectLabelKHR;
+#define glGetObjectLabelKHR glad_glGetObjectLabelKHR
+GLAD_API_CALL PFNGLGETOBJECTPTRLABELKHRPROC glad_glGetObjectPtrLabelKHR;
+#define glGetObjectPtrLabelKHR glad_glGetObjectPtrLabelKHR
+GLAD_API_CALL PFNGLGETPOINTERVKHRPROC glad_glGetPointervKHR;
+#define glGetPointervKHR glad_glGetPointervKHR
+GLAD_API_CALL PFNGLGETPROGRAMBINARYOESPROC glad_glGetProgramBinaryOES;
+#define glGetProgramBinaryOES glad_glGetProgramBinaryOES
+GLAD_API_CALL PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
+#define glGetProgramInfoLog glad_glGetProgramInfoLog
+GLAD_API_CALL PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC glad_glGetProgramPipelineInfoLogEXT;
+#define glGetProgramPipelineInfoLogEXT glad_glGetProgramPipelineInfoLogEXT
+GLAD_API_CALL PFNGLGETPROGRAMPIPELINEIVEXTPROC glad_glGetProgramPipelineivEXT;
+#define glGetProgramPipelineivEXT glad_glGetProgramPipelineivEXT
+GLAD_API_CALL PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC glad_glGetProgramResourceLocationIndexEXT;
+#define glGetProgramResourceLocationIndexEXT glad_glGetProgramResourceLocationIndexEXT
+GLAD_API_CALL PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
+#define glGetProgramiv glad_glGetProgramiv
+GLAD_API_CALL PFNGLGETQUERYOBJECTI64VEXTPROC glad_glGetQueryObjecti64vEXT;
+#define glGetQueryObjecti64vEXT glad_glGetQueryObjecti64vEXT
+GLAD_API_CALL PFNGLGETQUERYOBJECTIVEXTPROC glad_glGetQueryObjectivEXT;
+#define glGetQueryObjectivEXT glad_glGetQueryObjectivEXT
+GLAD_API_CALL PFNGLGETQUERYOBJECTUI64VEXTPROC glad_glGetQueryObjectui64vEXT;
+#define glGetQueryObjectui64vEXT glad_glGetQueryObjectui64vEXT
+GLAD_API_CALL PFNGLGETQUERYOBJECTUIVEXTPROC glad_glGetQueryObjectuivEXT;
+#define glGetQueryObjectuivEXT glad_glGetQueryObjectuivEXT
+GLAD_API_CALL PFNGLGETQUERYIVEXTPROC glad_glGetQueryivEXT;
+#define glGetQueryivEXT glad_glGetQueryivEXT
+GLAD_API_CALL PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
+#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv
+GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIIVEXTPROC glad_glGetSamplerParameterIivEXT;
+#define glGetSamplerParameterIivEXT glad_glGetSamplerParameterIivEXT
+GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIIVOESPROC glad_glGetSamplerParameterIivOES;
+#define glGetSamplerParameterIivOES glad_glGetSamplerParameterIivOES
+GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIUIVEXTPROC glad_glGetSamplerParameterIuivEXT;
+#define glGetSamplerParameterIuivEXT glad_glGetSamplerParameterIuivEXT
+GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIUIVOESPROC glad_glGetSamplerParameterIuivOES;
+#define glGetSamplerParameterIuivOES glad_glGetSamplerParameterIuivOES
+GLAD_API_CALL PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC glad_glGetSemaphoreParameterui64vEXT;
+#define glGetSemaphoreParameterui64vEXT glad_glGetSemaphoreParameterui64vEXT
+GLAD_API_CALL PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
+#define glGetShaderInfoLog glad_glGetShaderInfoLog
+GLAD_API_CALL PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat;
+#define glGetShaderPrecisionFormat glad_glGetShaderPrecisionFormat
+GLAD_API_CALL PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
+#define glGetShaderSource glad_glGetShaderSource
+GLAD_API_CALL PFNGLGETSHADERIVPROC glad_glGetShaderiv;
+#define glGetShaderiv glad_glGetShaderiv
+GLAD_API_CALL PFNGLGETSTRINGPROC glad_glGetString;
+#define glGetString glad_glGetString
+GLAD_API_CALL PFNGLGETTEXPARAMETERIIVEXTPROC glad_glGetTexParameterIivEXT;
+#define glGetTexParameterIivEXT glad_glGetTexParameterIivEXT
+GLAD_API_CALL PFNGLGETTEXPARAMETERIIVOESPROC glad_glGetTexParameterIivOES;
+#define glGetTexParameterIivOES glad_glGetTexParameterIivOES
+GLAD_API_CALL PFNGLGETTEXPARAMETERIUIVEXTPROC glad_glGetTexParameterIuivEXT;
+#define glGetTexParameterIuivEXT glad_glGetTexParameterIuivEXT
+GLAD_API_CALL PFNGLGETTEXPARAMETERIUIVOESPROC glad_glGetTexParameterIuivOES;
+#define glGetTexParameterIuivOES glad_glGetTexParameterIuivOES
+GLAD_API_CALL PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
+#define glGetTexParameterfv glad_glGetTexParameterfv
+GLAD_API_CALL PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
+#define glGetTexParameteriv glad_glGetTexParameteriv
+GLAD_API_CALL PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
+#define glGetUniformLocation glad_glGetUniformLocation
+GLAD_API_CALL PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
+#define glGetUniformfv glad_glGetUniformfv
+GLAD_API_CALL PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
+#define glGetUniformiv glad_glGetUniformiv
+GLAD_API_CALL PFNGLGETUNSIGNEDBYTEI_VEXTPROC glad_glGetUnsignedBytei_vEXT;
+#define glGetUnsignedBytei_vEXT glad_glGetUnsignedBytei_vEXT
+GLAD_API_CALL PFNGLGETUNSIGNEDBYTEVEXTPROC glad_glGetUnsignedBytevEXT;
+#define glGetUnsignedBytevEXT glad_glGetUnsignedBytevEXT
+GLAD_API_CALL PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
+#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv
+GLAD_API_CALL PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
+#define glGetVertexAttribfv glad_glGetVertexAttribfv
+GLAD_API_CALL PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
+#define glGetVertexAttribiv glad_glGetVertexAttribiv
+GLAD_API_CALL PFNGLGETNUNIFORMFVEXTPROC glad_glGetnUniformfvEXT;
+#define glGetnUniformfvEXT glad_glGetnUniformfvEXT
+GLAD_API_CALL PFNGLGETNUNIFORMFVKHRPROC glad_glGetnUniformfvKHR;
+#define glGetnUniformfvKHR glad_glGetnUniformfvKHR
+GLAD_API_CALL PFNGLGETNUNIFORMIVEXTPROC glad_glGetnUniformivEXT;
+#define glGetnUniformivEXT glad_glGetnUniformivEXT
+GLAD_API_CALL PFNGLGETNUNIFORMIVKHRPROC glad_glGetnUniformivKHR;
+#define glGetnUniformivKHR glad_glGetnUniformivKHR
+GLAD_API_CALL PFNGLGETNUNIFORMUIVKHRPROC glad_glGetnUniformuivKHR;
+#define glGetnUniformuivKHR glad_glGetnUniformuivKHR
+GLAD_API_CALL PFNGLHINTPROC glad_glHint;
+#define glHint glad_glHint
+GLAD_API_CALL PFNGLIMPORTMEMORYFDEXTPROC glad_glImportMemoryFdEXT;
+#define glImportMemoryFdEXT glad_glImportMemoryFdEXT
+GLAD_API_CALL PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC glad_glImportMemoryWin32HandleEXT;
+#define glImportMemoryWin32HandleEXT glad_glImportMemoryWin32HandleEXT
+GLAD_API_CALL PFNGLIMPORTMEMORYWIN32NAMEEXTPROC glad_glImportMemoryWin32NameEXT;
+#define glImportMemoryWin32NameEXT glad_glImportMemoryWin32NameEXT
+GLAD_API_CALL PFNGLIMPORTSEMAPHOREFDEXTPROC glad_glImportSemaphoreFdEXT;
+#define glImportSemaphoreFdEXT glad_glImportSemaphoreFdEXT
+GLAD_API_CALL PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC glad_glImportSemaphoreWin32HandleEXT;
+#define glImportSemaphoreWin32HandleEXT glad_glImportSemaphoreWin32HandleEXT
+GLAD_API_CALL PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC glad_glImportSemaphoreWin32NameEXT;
+#define glImportSemaphoreWin32NameEXT glad_glImportSemaphoreWin32NameEXT
+GLAD_API_CALL PFNGLINSERTEVENTMARKEREXTPROC glad_glInsertEventMarkerEXT;
+#define glInsertEventMarkerEXT glad_glInsertEventMarkerEXT
+GLAD_API_CALL PFNGLISBUFFERPROC glad_glIsBuffer;
+#define glIsBuffer glad_glIsBuffer
+GLAD_API_CALL PFNGLISENABLEDPROC glad_glIsEnabled;
+#define glIsEnabled glad_glIsEnabled
+GLAD_API_CALL PFNGLISENABLEDIEXTPROC glad_glIsEnablediEXT;
+#define glIsEnablediEXT glad_glIsEnablediEXT
+GLAD_API_CALL PFNGLISENABLEDIOESPROC glad_glIsEnablediOES;
+#define glIsEnablediOES glad_glIsEnablediOES
+GLAD_API_CALL PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
+#define glIsFramebuffer glad_glIsFramebuffer
+GLAD_API_CALL PFNGLISMEMORYOBJECTEXTPROC glad_glIsMemoryObjectEXT;
+#define glIsMemoryObjectEXT glad_glIsMemoryObjectEXT
+GLAD_API_CALL PFNGLISPROGRAMPROC glad_glIsProgram;
+#define glIsProgram glad_glIsProgram
+GLAD_API_CALL PFNGLISPROGRAMPIPELINEEXTPROC glad_glIsProgramPipelineEXT;
+#define glIsProgramPipelineEXT glad_glIsProgramPipelineEXT
+GLAD_API_CALL PFNGLISQUERYEXTPROC glad_glIsQueryEXT;
+#define glIsQueryEXT glad_glIsQueryEXT
+GLAD_API_CALL PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
+#define glIsRenderbuffer glad_glIsRenderbuffer
+GLAD_API_CALL PFNGLISSEMAPHOREEXTPROC glad_glIsSemaphoreEXT;
+#define glIsSemaphoreEXT glad_glIsSemaphoreEXT
+GLAD_API_CALL PFNGLISSHADERPROC glad_glIsShader;
+#define glIsShader glad_glIsShader
+GLAD_API_CALL PFNGLISTEXTUREPROC glad_glIsTexture;
+#define glIsTexture glad_glIsTexture
+GLAD_API_CALL PFNGLISVERTEXARRAYOESPROC glad_glIsVertexArrayOES;
+#define glIsVertexArrayOES glad_glIsVertexArrayOES
+GLAD_API_CALL PFNGLLABELOBJECTEXTPROC glad_glLabelObjectEXT;
+#define glLabelObjectEXT glad_glLabelObjectEXT
+GLAD_API_CALL PFNGLLINEWIDTHPROC glad_glLineWidth;
+#define glLineWidth glad_glLineWidth
+GLAD_API_CALL PFNGLLINKPROGRAMPROC glad_glLinkProgram;
+#define glLinkProgram glad_glLinkProgram
+GLAD_API_CALL PFNGLMAPBUFFEROESPROC glad_glMapBufferOES;
+#define glMapBufferOES glad_glMapBufferOES
+GLAD_API_CALL PFNGLMAPBUFFERRANGEEXTPROC glad_glMapBufferRangeEXT;
+#define glMapBufferRangeEXT glad_glMapBufferRangeEXT
+GLAD_API_CALL PFNGLMAXSHADERCOMPILERTHREADSKHRPROC glad_glMaxShaderCompilerThreadsKHR;
+#define glMaxShaderCompilerThreadsKHR glad_glMaxShaderCompilerThreadsKHR
+GLAD_API_CALL PFNGLMEMORYOBJECTPARAMETERIVEXTPROC glad_glMemoryObjectParameterivEXT;
+#define glMemoryObjectParameterivEXT glad_glMemoryObjectParameterivEXT
+GLAD_API_CALL PFNGLMINSAMPLESHADINGOESPROC glad_glMinSampleShadingOES;
+#define glMinSampleShadingOES glad_glMinSampleShadingOES
+GLAD_API_CALL PFNGLMULTIDRAWARRAYSEXTPROC glad_glMultiDrawArraysEXT;
+#define glMultiDrawArraysEXT glad_glMultiDrawArraysEXT
+GLAD_API_CALL PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC glad_glMultiDrawArraysIndirectEXT;
+#define glMultiDrawArraysIndirectEXT glad_glMultiDrawArraysIndirectEXT
+GLAD_API_CALL PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC glad_glMultiDrawElementsBaseVertexEXT;
+#define glMultiDrawElementsBaseVertexEXT glad_glMultiDrawElementsBaseVertexEXT
+GLAD_API_CALL PFNGLMULTIDRAWELEMENTSEXTPROC glad_glMultiDrawElementsEXT;
+#define glMultiDrawElementsEXT glad_glMultiDrawElementsEXT
+GLAD_API_CALL PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC glad_glMultiDrawElementsIndirectEXT;
+#define glMultiDrawElementsIndirectEXT glad_glMultiDrawElementsIndirectEXT
+GLAD_API_CALL PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC glad_glNamedBufferStorageExternalEXT;
+#define glNamedBufferStorageExternalEXT glad_glNamedBufferStorageExternalEXT
+GLAD_API_CALL PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC glad_glNamedBufferStorageMemEXT;
+#define glNamedBufferStorageMemEXT glad_glNamedBufferStorageMemEXT
+GLAD_API_CALL PFNGLOBJECTLABELKHRPROC glad_glObjectLabelKHR;
+#define glObjectLabelKHR glad_glObjectLabelKHR
+GLAD_API_CALL PFNGLOBJECTPTRLABELKHRPROC glad_glObjectPtrLabelKHR;
+#define glObjectPtrLabelKHR glad_glObjectPtrLabelKHR
+GLAD_API_CALL PFNGLPATCHPARAMETERIEXTPROC glad_glPatchParameteriEXT;
+#define glPatchParameteriEXT glad_glPatchParameteriEXT
+GLAD_API_CALL PFNGLPATCHPARAMETERIOESPROC glad_glPatchParameteriOES;
+#define glPatchParameteriOES glad_glPatchParameteriOES
+GLAD_API_CALL PFNGLPIXELSTOREIPROC glad_glPixelStorei;
+#define glPixelStorei glad_glPixelStorei
+GLAD_API_CALL PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
+#define glPolygonOffset glad_glPolygonOffset
+GLAD_API_CALL PFNGLPOLYGONOFFSETCLAMPEXTPROC glad_glPolygonOffsetClampEXT;
+#define glPolygonOffsetClampEXT glad_glPolygonOffsetClampEXT
+GLAD_API_CALL PFNGLPOPDEBUGGROUPKHRPROC glad_glPopDebugGroupKHR;
+#define glPopDebugGroupKHR glad_glPopDebugGroupKHR
+GLAD_API_CALL PFNGLPOPGROUPMARKEREXTPROC glad_glPopGroupMarkerEXT;
+#define glPopGroupMarkerEXT glad_glPopGroupMarkerEXT
+GLAD_API_CALL PFNGLPRIMITIVEBOUNDINGBOXEXTPROC glad_glPrimitiveBoundingBoxEXT;
+#define glPrimitiveBoundingBoxEXT glad_glPrimitiveBoundingBoxEXT
+GLAD_API_CALL PFNGLPRIMITIVEBOUNDINGBOXOESPROC glad_glPrimitiveBoundingBoxOES;
+#define glPrimitiveBoundingBoxOES glad_glPrimitiveBoundingBoxOES
+GLAD_API_CALL PFNGLPROGRAMBINARYOESPROC glad_glProgramBinaryOES;
+#define glProgramBinaryOES glad_glProgramBinaryOES
+GLAD_API_CALL PFNGLPROGRAMPARAMETERIEXTPROC glad_glProgramParameteriEXT;
+#define glProgramParameteriEXT glad_glProgramParameteriEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM1FEXTPROC glad_glProgramUniform1fEXT;
+#define glProgramUniform1fEXT glad_glProgramUniform1fEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM1FVEXTPROC glad_glProgramUniform1fvEXT;
+#define glProgramUniform1fvEXT glad_glProgramUniform1fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM1IEXTPROC glad_glProgramUniform1iEXT;
+#define glProgramUniform1iEXT glad_glProgramUniform1iEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM1IVEXTPROC glad_glProgramUniform1ivEXT;
+#define glProgramUniform1ivEXT glad_glProgramUniform1ivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM1UIEXTPROC glad_glProgramUniform1uiEXT;
+#define glProgramUniform1uiEXT glad_glProgramUniform1uiEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM1UIVEXTPROC glad_glProgramUniform1uivEXT;
+#define glProgramUniform1uivEXT glad_glProgramUniform1uivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM2FEXTPROC glad_glProgramUniform2fEXT;
+#define glProgramUniform2fEXT glad_glProgramUniform2fEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM2FVEXTPROC glad_glProgramUniform2fvEXT;
+#define glProgramUniform2fvEXT glad_glProgramUniform2fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM2IEXTPROC glad_glProgramUniform2iEXT;
+#define glProgramUniform2iEXT glad_glProgramUniform2iEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM2IVEXTPROC glad_glProgramUniform2ivEXT;
+#define glProgramUniform2ivEXT glad_glProgramUniform2ivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM2UIEXTPROC glad_glProgramUniform2uiEXT;
+#define glProgramUniform2uiEXT glad_glProgramUniform2uiEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM2UIVEXTPROC glad_glProgramUniform2uivEXT;
+#define glProgramUniform2uivEXT glad_glProgramUniform2uivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM3FEXTPROC glad_glProgramUniform3fEXT;
+#define glProgramUniform3fEXT glad_glProgramUniform3fEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM3FVEXTPROC glad_glProgramUniform3fvEXT;
+#define glProgramUniform3fvEXT glad_glProgramUniform3fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM3IEXTPROC glad_glProgramUniform3iEXT;
+#define glProgramUniform3iEXT glad_glProgramUniform3iEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM3IVEXTPROC glad_glProgramUniform3ivEXT;
+#define glProgramUniform3ivEXT glad_glProgramUniform3ivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM3UIEXTPROC glad_glProgramUniform3uiEXT;
+#define glProgramUniform3uiEXT glad_glProgramUniform3uiEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM3UIVEXTPROC glad_glProgramUniform3uivEXT;
+#define glProgramUniform3uivEXT glad_glProgramUniform3uivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM4FEXTPROC glad_glProgramUniform4fEXT;
+#define glProgramUniform4fEXT glad_glProgramUniform4fEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM4FVEXTPROC glad_glProgramUniform4fvEXT;
+#define glProgramUniform4fvEXT glad_glProgramUniform4fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM4IEXTPROC glad_glProgramUniform4iEXT;
+#define glProgramUniform4iEXT glad_glProgramUniform4iEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM4IVEXTPROC glad_glProgramUniform4ivEXT;
+#define glProgramUniform4ivEXT glad_glProgramUniform4ivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM4UIEXTPROC glad_glProgramUniform4uiEXT;
+#define glProgramUniform4uiEXT glad_glProgramUniform4uiEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORM4UIVEXTPROC glad_glProgramUniform4uivEXT;
+#define glProgramUniform4uivEXT glad_glProgramUniform4uivEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC glad_glProgramUniformMatrix2fvEXT;
+#define glProgramUniformMatrix2fvEXT glad_glProgramUniformMatrix2fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC glad_glProgramUniformMatrix2x3fvEXT;
+#define glProgramUniformMatrix2x3fvEXT glad_glProgramUniformMatrix2x3fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC glad_glProgramUniformMatrix2x4fvEXT;
+#define glProgramUniformMatrix2x4fvEXT glad_glProgramUniformMatrix2x4fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC glad_glProgramUniformMatrix3fvEXT;
+#define glProgramUniformMatrix3fvEXT glad_glProgramUniformMatrix3fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC glad_glProgramUniformMatrix3x2fvEXT;
+#define glProgramUniformMatrix3x2fvEXT glad_glProgramUniformMatrix3x2fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC glad_glProgramUniformMatrix3x4fvEXT;
+#define glProgramUniformMatrix3x4fvEXT glad_glProgramUniformMatrix3x4fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC glad_glProgramUniformMatrix4fvEXT;
+#define glProgramUniformMatrix4fvEXT glad_glProgramUniformMatrix4fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC glad_glProgramUniformMatrix4x2fvEXT;
+#define glProgramUniformMatrix4x2fvEXT glad_glProgramUniformMatrix4x2fvEXT
+GLAD_API_CALL PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC glad_glProgramUniformMatrix4x3fvEXT;
+#define glProgramUniformMatrix4x3fvEXT glad_glProgramUniformMatrix4x3fvEXT
+GLAD_API_CALL PFNGLPUSHDEBUGGROUPKHRPROC glad_glPushDebugGroupKHR;
+#define glPushDebugGroupKHR glad_glPushDebugGroupKHR
+GLAD_API_CALL PFNGLPUSHGROUPMARKEREXTPROC glad_glPushGroupMarkerEXT;
+#define glPushGroupMarkerEXT glad_glPushGroupMarkerEXT
+GLAD_API_CALL PFNGLQUERYCOUNTEREXTPROC glad_glQueryCounterEXT;
+#define glQueryCounterEXT glad_glQueryCounterEXT
+GLAD_API_CALL PFNGLRASTERSAMPLESEXTPROC glad_glRasterSamplesEXT;
+#define glRasterSamplesEXT glad_glRasterSamplesEXT
+GLAD_API_CALL PFNGLREADBUFFERINDEXEDEXTPROC glad_glReadBufferIndexedEXT;
+#define glReadBufferIndexedEXT glad_glReadBufferIndexedEXT
+GLAD_API_CALL PFNGLREADPIXELSPROC glad_glReadPixels;
+#define glReadPixels glad_glReadPixels
+GLAD_API_CALL PFNGLREADNPIXELSEXTPROC glad_glReadnPixelsEXT;
+#define glReadnPixelsEXT glad_glReadnPixelsEXT
+GLAD_API_CALL PFNGLREADNPIXELSKHRPROC glad_glReadnPixelsKHR;
+#define glReadnPixelsKHR glad_glReadnPixelsKHR
+GLAD_API_CALL PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC glad_glReleaseKeyedMutexWin32EXT;
+#define glReleaseKeyedMutexWin32EXT glad_glReleaseKeyedMutexWin32EXT
+GLAD_API_CALL PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler;
+#define glReleaseShaderCompiler glad_glReleaseShaderCompiler
+GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
+#define glRenderbufferStorage glad_glRenderbufferStorage
+GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT;
+#define glRenderbufferStorageMultisampleEXT glad_glRenderbufferStorageMultisampleEXT
+GLAD_API_CALL PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
+#define glSampleCoverage glad_glSampleCoverage
+GLAD_API_CALL PFNGLSAMPLERPARAMETERIIVEXTPROC glad_glSamplerParameterIivEXT;
+#define glSamplerParameterIivEXT glad_glSamplerParameterIivEXT
+GLAD_API_CALL PFNGLSAMPLERPARAMETERIIVOESPROC glad_glSamplerParameterIivOES;
+#define glSamplerParameterIivOES glad_glSamplerParameterIivOES
+GLAD_API_CALL PFNGLSAMPLERPARAMETERIUIVEXTPROC glad_glSamplerParameterIuivEXT;
+#define glSamplerParameterIuivEXT glad_glSamplerParameterIuivEXT
+GLAD_API_CALL PFNGLSAMPLERPARAMETERIUIVOESPROC glad_glSamplerParameterIuivOES;
+#define glSamplerParameterIuivOES glad_glSamplerParameterIuivOES
+GLAD_API_CALL PFNGLSCISSORPROC glad_glScissor;
+#define glScissor glad_glScissor
+GLAD_API_CALL PFNGLSCISSORARRAYVOESPROC glad_glScissorArrayvOES;
+#define glScissorArrayvOES glad_glScissorArrayvOES
+GLAD_API_CALL PFNGLSCISSORINDEXEDOESPROC glad_glScissorIndexedOES;
+#define glScissorIndexedOES glad_glScissorIndexedOES
+GLAD_API_CALL PFNGLSCISSORINDEXEDVOESPROC glad_glScissorIndexedvOES;
+#define glScissorIndexedvOES glad_glScissorIndexedvOES
+GLAD_API_CALL PFNGLSEMAPHOREPARAMETERUI64VEXTPROC glad_glSemaphoreParameterui64vEXT;
+#define glSemaphoreParameterui64vEXT glad_glSemaphoreParameterui64vEXT
+GLAD_API_CALL PFNGLSHADERBINARYPROC glad_glShaderBinary;
+#define glShaderBinary glad_glShaderBinary
+GLAD_API_CALL PFNGLSHADERSOURCEPROC glad_glShaderSource;
+#define glShaderSource glad_glShaderSource
+GLAD_API_CALL PFNGLSHADINGRATECOMBINEROPSEXTPROC glad_glShadingRateCombinerOpsEXT;
+#define glShadingRateCombinerOpsEXT glad_glShadingRateCombinerOpsEXT
+GLAD_API_CALL PFNGLSHADINGRATEEXTPROC glad_glShadingRateEXT;
+#define glShadingRateEXT glad_glShadingRateEXT
+GLAD_API_CALL PFNGLSIGNALSEMAPHOREEXTPROC glad_glSignalSemaphoreEXT;
+#define glSignalSemaphoreEXT glad_glSignalSemaphoreEXT
+GLAD_API_CALL PFNGLSTENCILFUNCPROC glad_glStencilFunc;
+#define glStencilFunc glad_glStencilFunc
+GLAD_API_CALL PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
+#define glStencilFuncSeparate glad_glStencilFuncSeparate
+GLAD_API_CALL PFNGLSTENCILMASKPROC glad_glStencilMask;
+#define glStencilMask glad_glStencilMask
+GLAD_API_CALL PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
+#define glStencilMaskSeparate glad_glStencilMaskSeparate
+GLAD_API_CALL PFNGLSTENCILOPPROC glad_glStencilOp;
+#define glStencilOp glad_glStencilOp
+GLAD_API_CALL PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
+#define glStencilOpSeparate glad_glStencilOpSeparate
+GLAD_API_CALL PFNGLTEXBUFFEREXTPROC glad_glTexBufferEXT;
+#define glTexBufferEXT glad_glTexBufferEXT
+GLAD_API_CALL PFNGLTEXBUFFEROESPROC glad_glTexBufferOES;
+#define glTexBufferOES glad_glTexBufferOES
+GLAD_API_CALL PFNGLTEXBUFFERRANGEEXTPROC glad_glTexBufferRangeEXT;
+#define glTexBufferRangeEXT glad_glTexBufferRangeEXT
+GLAD_API_CALL PFNGLTEXBUFFERRANGEOESPROC glad_glTexBufferRangeOES;
+#define glTexBufferRangeOES glad_glTexBufferRangeOES
+GLAD_API_CALL PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
+#define glTexImage2D glad_glTexImage2D
+GLAD_API_CALL PFNGLTEXIMAGE3DOESPROC glad_glTexImage3DOES;
+#define glTexImage3DOES glad_glTexImage3DOES
+GLAD_API_CALL PFNGLTEXPAGECOMMITMENTEXTPROC glad_glTexPageCommitmentEXT;
+#define glTexPageCommitmentEXT glad_glTexPageCommitmentEXT
+GLAD_API_CALL PFNGLTEXPARAMETERIIVEXTPROC glad_glTexParameterIivEXT;
+#define glTexParameterIivEXT glad_glTexParameterIivEXT
+GLAD_API_CALL PFNGLTEXPARAMETERIIVOESPROC glad_glTexParameterIivOES;
+#define glTexParameterIivOES glad_glTexParameterIivOES
+GLAD_API_CALL PFNGLTEXPARAMETERIUIVEXTPROC glad_glTexParameterIuivEXT;
+#define glTexParameterIuivEXT glad_glTexParameterIuivEXT
+GLAD_API_CALL PFNGLTEXPARAMETERIUIVOESPROC glad_glTexParameterIuivOES;
+#define glTexParameterIuivOES glad_glTexParameterIuivOES
+GLAD_API_CALL PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
+#define glTexParameterf glad_glTexParameterf
+GLAD_API_CALL PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
+#define glTexParameterfv glad_glTexParameterfv
+GLAD_API_CALL PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
+#define glTexParameteri glad_glTexParameteri
+GLAD_API_CALL PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
+#define glTexParameteriv glad_glTexParameteriv
+GLAD_API_CALL PFNGLTEXSTORAGE1DEXTPROC glad_glTexStorage1DEXT;
+#define glTexStorage1DEXT glad_glTexStorage1DEXT
+GLAD_API_CALL PFNGLTEXSTORAGE2DEXTPROC glad_glTexStorage2DEXT;
+#define glTexStorage2DEXT glad_glTexStorage2DEXT
+GLAD_API_CALL PFNGLTEXSTORAGE3DEXTPROC glad_glTexStorage3DEXT;
+#define glTexStorage3DEXT glad_glTexStorage3DEXT
+GLAD_API_CALL PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC glad_glTexStorage3DMultisampleOES;
+#define glTexStorage3DMultisampleOES glad_glTexStorage3DMultisampleOES
+GLAD_API_CALL PFNGLTEXSTORAGEATTRIBS2DEXTPROC glad_glTexStorageAttribs2DEXT;
+#define glTexStorageAttribs2DEXT glad_glTexStorageAttribs2DEXT
+GLAD_API_CALL PFNGLTEXSTORAGEATTRIBS3DEXTPROC glad_glTexStorageAttribs3DEXT;
+#define glTexStorageAttribs3DEXT glad_glTexStorageAttribs3DEXT
+GLAD_API_CALL PFNGLTEXSTORAGEMEM2DEXTPROC glad_glTexStorageMem2DEXT;
+#define glTexStorageMem2DEXT glad_glTexStorageMem2DEXT
+GLAD_API_CALL PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC glad_glTexStorageMem2DMultisampleEXT;
+#define glTexStorageMem2DMultisampleEXT glad_glTexStorageMem2DMultisampleEXT
+GLAD_API_CALL PFNGLTEXSTORAGEMEM3DEXTPROC glad_glTexStorageMem3DEXT;
+#define glTexStorageMem3DEXT glad_glTexStorageMem3DEXT
+GLAD_API_CALL PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC glad_glTexStorageMem3DMultisampleEXT;
+#define glTexStorageMem3DMultisampleEXT glad_glTexStorageMem3DMultisampleEXT
+GLAD_API_CALL PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
+#define glTexSubImage2D glad_glTexSubImage2D
+GLAD_API_CALL PFNGLTEXSUBIMAGE3DOESPROC glad_glTexSubImage3DOES;
+#define glTexSubImage3DOES glad_glTexSubImage3DOES
+GLAD_API_CALL PFNGLTEXTURESTORAGE1DEXTPROC glad_glTextureStorage1DEXT;
+#define glTextureStorage1DEXT glad_glTextureStorage1DEXT
+GLAD_API_CALL PFNGLTEXTURESTORAGE2DEXTPROC glad_glTextureStorage2DEXT;
+#define glTextureStorage2DEXT glad_glTextureStorage2DEXT
+GLAD_API_CALL PFNGLTEXTURESTORAGE3DEXTPROC glad_glTextureStorage3DEXT;
+#define glTextureStorage3DEXT glad_glTextureStorage3DEXT
+GLAD_API_CALL PFNGLTEXTURESTORAGEMEM2DEXTPROC glad_glTextureStorageMem2DEXT;
+#define glTextureStorageMem2DEXT glad_glTextureStorageMem2DEXT
+GLAD_API_CALL PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC glad_glTextureStorageMem2DMultisampleEXT;
+#define glTextureStorageMem2DMultisampleEXT glad_glTextureStorageMem2DMultisampleEXT
+GLAD_API_CALL PFNGLTEXTURESTORAGEMEM3DEXTPROC glad_glTextureStorageMem3DEXT;
+#define glTextureStorageMem3DEXT glad_glTextureStorageMem3DEXT
+GLAD_API_CALL PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC glad_glTextureStorageMem3DMultisampleEXT;
+#define glTextureStorageMem3DMultisampleEXT glad_glTextureStorageMem3DMultisampleEXT
+GLAD_API_CALL PFNGLTEXTUREVIEWEXTPROC glad_glTextureViewEXT;
+#define glTextureViewEXT glad_glTextureViewEXT
+GLAD_API_CALL PFNGLTEXTUREVIEWOESPROC glad_glTextureViewOES;
+#define glTextureViewOES glad_glTextureViewOES
+GLAD_API_CALL PFNGLUNIFORM1FPROC glad_glUniform1f;
+#define glUniform1f glad_glUniform1f
+GLAD_API_CALL PFNGLUNIFORM1FVPROC glad_glUniform1fv;
+#define glUniform1fv glad_glUniform1fv
+GLAD_API_CALL PFNGLUNIFORM1IPROC glad_glUniform1i;
+#define glUniform1i glad_glUniform1i
+GLAD_API_CALL PFNGLUNIFORM1IVPROC glad_glUniform1iv;
+#define glUniform1iv glad_glUniform1iv
+GLAD_API_CALL PFNGLUNIFORM2FPROC glad_glUniform2f;
+#define glUniform2f glad_glUniform2f
+GLAD_API_CALL PFNGLUNIFORM2FVPROC glad_glUniform2fv;
+#define glUniform2fv glad_glUniform2fv
+GLAD_API_CALL PFNGLUNIFORM2IPROC glad_glUniform2i;
+#define glUniform2i glad_glUniform2i
+GLAD_API_CALL PFNGLUNIFORM2IVPROC glad_glUniform2iv;
+#define glUniform2iv glad_glUniform2iv
+GLAD_API_CALL PFNGLUNIFORM3FPROC glad_glUniform3f;
+#define glUniform3f glad_glUniform3f
+GLAD_API_CALL PFNGLUNIFORM3FVPROC glad_glUniform3fv;
+#define glUniform3fv glad_glUniform3fv
+GLAD_API_CALL PFNGLUNIFORM3IPROC glad_glUniform3i;
+#define glUniform3i glad_glUniform3i
+GLAD_API_CALL PFNGLUNIFORM3IVPROC glad_glUniform3iv;
+#define glUniform3iv glad_glUniform3iv
+GLAD_API_CALL PFNGLUNIFORM4FPROC glad_glUniform4f;
+#define glUniform4f glad_glUniform4f
+GLAD_API_CALL PFNGLUNIFORM4FVPROC glad_glUniform4fv;
+#define glUniform4fv glad_glUniform4fv
+GLAD_API_CALL PFNGLUNIFORM4IPROC glad_glUniform4i;
+#define glUniform4i glad_glUniform4i
+GLAD_API_CALL PFNGLUNIFORM4IVPROC glad_glUniform4iv;
+#define glUniform4iv glad_glUniform4iv
+GLAD_API_CALL PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
+#define glUniformMatrix2fv glad_glUniformMatrix2fv
+GLAD_API_CALL PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
+#define glUniformMatrix3fv glad_glUniformMatrix3fv
+GLAD_API_CALL PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
+#define glUniformMatrix4fv glad_glUniformMatrix4fv
+GLAD_API_CALL PFNGLUNMAPBUFFEROESPROC glad_glUnmapBufferOES;
+#define glUnmapBufferOES glad_glUnmapBufferOES
+GLAD_API_CALL PFNGLUSEPROGRAMPROC glad_glUseProgram;
+#define glUseProgram glad_glUseProgram
+GLAD_API_CALL PFNGLUSEPROGRAMSTAGESEXTPROC glad_glUseProgramStagesEXT;
+#define glUseProgramStagesEXT glad_glUseProgramStagesEXT
+GLAD_API_CALL PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
+#define glValidateProgram glad_glValidateProgram
+GLAD_API_CALL PFNGLVALIDATEPROGRAMPIPELINEEXTPROC glad_glValidateProgramPipelineEXT;
+#define glValidateProgramPipelineEXT glad_glValidateProgramPipelineEXT
+GLAD_API_CALL PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
+#define glVertexAttrib1f glad_glVertexAttrib1f
+GLAD_API_CALL PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
+#define glVertexAttrib1fv glad_glVertexAttrib1fv
+GLAD_API_CALL PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
+#define glVertexAttrib2f glad_glVertexAttrib2f
+GLAD_API_CALL PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
+#define glVertexAttrib2fv glad_glVertexAttrib2fv
+GLAD_API_CALL PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
+#define glVertexAttrib3f glad_glVertexAttrib3f
+GLAD_API_CALL PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
+#define glVertexAttrib3fv glad_glVertexAttrib3fv
+GLAD_API_CALL PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
+#define glVertexAttrib4f glad_glVertexAttrib4f
+GLAD_API_CALL PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
+#define glVertexAttrib4fv glad_glVertexAttrib4fv
+GLAD_API_CALL PFNGLVERTEXATTRIBDIVISOREXTPROC glad_glVertexAttribDivisorEXT;
+#define glVertexAttribDivisorEXT glad_glVertexAttribDivisorEXT
+GLAD_API_CALL PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
+#define glVertexAttribPointer glad_glVertexAttribPointer
+GLAD_API_CALL PFNGLVIEWPORTPROC glad_glViewport;
+#define glViewport glad_glViewport
+GLAD_API_CALL PFNGLVIEWPORTARRAYVOESPROC glad_glViewportArrayvOES;
+#define glViewportArrayvOES glad_glViewportArrayvOES
+GLAD_API_CALL PFNGLVIEWPORTINDEXEDFOESPROC glad_glViewportIndexedfOES;
+#define glViewportIndexedfOES glad_glViewportIndexedfOES
+GLAD_API_CALL PFNGLVIEWPORTINDEXEDFVOESPROC glad_glViewportIndexedfvOES;
+#define glViewportIndexedfvOES glad_glViewportIndexedfvOES
+GLAD_API_CALL PFNGLWAITSEMAPHOREEXTPROC glad_glWaitSemaphoreEXT;
+#define glWaitSemaphoreEXT glad_glWaitSemaphoreEXT
+GLAD_API_CALL PFNGLWINDOWRECTANGLESEXTPROC glad_glWindowRectanglesEXT;
+#define glWindowRectanglesEXT glad_glWindowRectanglesEXT
+
+
+
+
+
+GLAD_API_CALL int gladLoadGLES2UserPtr( GLADuserptrloadfunc load, void *userptr);
+GLAD_API_CALL int gladLoadGLES2( GLADloadfunc load);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+/* Source */
+#ifdef GLAD_GLES2_IMPLEMENTATION
+/**
+ * SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
+ */
+#include
+#include
+#include
+
+#ifndef GLAD_IMPL_UTIL_C_
+#define GLAD_IMPL_UTIL_C_
+
+#ifdef _MSC_VER
+#define GLAD_IMPL_UTIL_SSCANF sscanf_s
+#else
+#define GLAD_IMPL_UTIL_SSCANF sscanf
+#endif
+
+#endif /* GLAD_IMPL_UTIL_C_ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+int GLAD_GL_ES_VERSION_2_0 = 0;
+int GLAD_GL_EXT_EGL_image_array = 0;
+int GLAD_GL_EXT_EGL_image_storage = 0;
+int GLAD_GL_EXT_EGL_image_storage_compression = 0;
+int GLAD_GL_EXT_YUV_target = 0;
+int GLAD_GL_EXT_base_instance = 0;
+int GLAD_GL_EXT_blend_func_extended = 0;
+int GLAD_GL_EXT_blend_minmax = 0;
+int GLAD_GL_EXT_buffer_storage = 0;
+int GLAD_GL_EXT_clear_texture = 0;
+int GLAD_GL_EXT_clip_control = 0;
+int GLAD_GL_EXT_clip_cull_distance = 0;
+int GLAD_GL_EXT_color_buffer_float = 0;
+int GLAD_GL_EXT_color_buffer_half_float = 0;
+int GLAD_GL_EXT_conservative_depth = 0;
+int GLAD_GL_EXT_copy_image = 0;
+int GLAD_GL_EXT_debug_label = 0;
+int GLAD_GL_EXT_debug_marker = 0;
+int GLAD_GL_EXT_depth_clamp = 0;
+int GLAD_GL_EXT_discard_framebuffer = 0;
+int GLAD_GL_EXT_disjoint_timer_query = 0;
+int GLAD_GL_EXT_draw_buffers = 0;
+int GLAD_GL_EXT_draw_buffers_indexed = 0;
+int GLAD_GL_EXT_draw_elements_base_vertex = 0;
+int GLAD_GL_EXT_draw_instanced = 0;
+int GLAD_GL_EXT_draw_transform_feedback = 0;
+int GLAD_GL_EXT_external_buffer = 0;
+int GLAD_GL_EXT_float_blend = 0;
+int GLAD_GL_EXT_fragment_shading_rate = 0;
+int GLAD_GL_EXT_geometry_point_size = 0;
+int GLAD_GL_EXT_geometry_shader = 0;
+int GLAD_GL_EXT_gpu_shader5 = 0;
+int GLAD_GL_EXT_instanced_arrays = 0;
+int GLAD_GL_EXT_map_buffer_range = 0;
+int GLAD_GL_EXT_memory_object = 0;
+int GLAD_GL_EXT_memory_object_fd = 0;
+int GLAD_GL_EXT_memory_object_win32 = 0;
+int GLAD_GL_EXT_multi_draw_arrays = 0;
+int GLAD_GL_EXT_multi_draw_indirect = 0;
+int GLAD_GL_EXT_multisampled_compatibility = 0;
+int GLAD_GL_EXT_multisampled_render_to_texture = 0;
+int GLAD_GL_EXT_multisampled_render_to_texture2 = 0;
+int GLAD_GL_EXT_multiview_draw_buffers = 0;
+int GLAD_GL_EXT_multiview_tessellation_geometry_shader = 0;
+int GLAD_GL_EXT_multiview_texture_multisample = 0;
+int GLAD_GL_EXT_multiview_timer_query = 0;
+int GLAD_GL_EXT_occlusion_query_boolean = 0;
+int GLAD_GL_EXT_polygon_offset_clamp = 0;
+int GLAD_GL_EXT_post_depth_coverage = 0;
+int GLAD_GL_EXT_primitive_bounding_box = 0;
+int GLAD_GL_EXT_protected_textures = 0;
+int GLAD_GL_EXT_pvrtc_sRGB = 0;
+int GLAD_GL_EXT_raster_multisample = 0;
+int GLAD_GL_EXT_read_format_bgra = 0;
+int GLAD_GL_EXT_render_snorm = 0;
+int GLAD_GL_EXT_robustness = 0;
+int GLAD_GL_EXT_sRGB = 0;
+int GLAD_GL_EXT_sRGB_write_control = 0;
+int GLAD_GL_EXT_semaphore = 0;
+int GLAD_GL_EXT_semaphore_fd = 0;
+int GLAD_GL_EXT_semaphore_win32 = 0;
+int GLAD_GL_EXT_separate_depth_stencil = 0;
+int GLAD_GL_EXT_separate_shader_objects = 0;
+int GLAD_GL_EXT_shader_framebuffer_fetch = 0;
+int GLAD_GL_EXT_shader_framebuffer_fetch_non_coherent = 0;
+int GLAD_GL_EXT_shader_group_vote = 0;
+int GLAD_GL_EXT_shader_implicit_conversions = 0;
+int GLAD_GL_EXT_shader_integer_mix = 0;
+int GLAD_GL_EXT_shader_io_blocks = 0;
+int GLAD_GL_EXT_shader_non_constant_global_initializers = 0;
+int GLAD_GL_EXT_shader_pixel_local_storage = 0;
+int GLAD_GL_EXT_shader_pixel_local_storage2 = 0;
+int GLAD_GL_EXT_shader_samples_identical = 0;
+int GLAD_GL_EXT_shader_texture_lod = 0;
+int GLAD_GL_EXT_shadow_samplers = 0;
+int GLAD_GL_EXT_sparse_texture = 0;
+int GLAD_GL_EXT_sparse_texture2 = 0;
+int GLAD_GL_EXT_tessellation_point_size = 0;
+int GLAD_GL_EXT_tessellation_shader = 0;
+int GLAD_GL_EXT_texture_border_clamp = 0;
+int GLAD_GL_EXT_texture_buffer = 0;
+int GLAD_GL_EXT_texture_compression_astc_decode_mode = 0;
+int GLAD_GL_EXT_texture_compression_bptc = 0;
+int GLAD_GL_EXT_texture_compression_dxt1 = 0;
+int GLAD_GL_EXT_texture_compression_rgtc = 0;
+int GLAD_GL_EXT_texture_compression_s3tc = 0;
+int GLAD_GL_EXT_texture_compression_s3tc_srgb = 0;
+int GLAD_GL_EXT_texture_cube_map_array = 0;
+int GLAD_GL_EXT_texture_filter_anisotropic = 0;
+int GLAD_GL_EXT_texture_filter_minmax = 0;
+int GLAD_GL_EXT_texture_format_BGRA8888 = 0;
+int GLAD_GL_EXT_texture_format_sRGB_override = 0;
+int GLAD_GL_EXT_texture_mirror_clamp_to_edge = 0;
+int GLAD_GL_EXT_texture_norm16 = 0;
+int GLAD_GL_EXT_texture_query_lod = 0;
+int GLAD_GL_EXT_texture_rg = 0;
+int GLAD_GL_EXT_texture_sRGB_R8 = 0;
+int GLAD_GL_EXT_texture_sRGB_RG8 = 0;
+int GLAD_GL_EXT_texture_sRGB_decode = 0;
+int GLAD_GL_EXT_texture_shadow_lod = 0;
+int GLAD_GL_EXT_texture_storage = 0;
+int GLAD_GL_EXT_texture_storage_compression = 0;
+int GLAD_GL_EXT_texture_type_2_10_10_10_REV = 0;
+int GLAD_GL_EXT_texture_view = 0;
+int GLAD_GL_EXT_unpack_subimage = 0;
+int GLAD_GL_EXT_win32_keyed_mutex = 0;
+int GLAD_GL_EXT_window_rectangles = 0;
+int GLAD_GL_KHR_blend_equation_advanced = 0;
+int GLAD_GL_KHR_blend_equation_advanced_coherent = 0;
+int GLAD_GL_KHR_context_flush_control = 0;
+int GLAD_GL_KHR_debug = 0;
+int GLAD_GL_KHR_no_error = 0;
+int GLAD_GL_KHR_parallel_shader_compile = 0;
+int GLAD_GL_KHR_robust_buffer_access_behavior = 0;
+int GLAD_GL_KHR_robustness = 0;
+int GLAD_GL_KHR_shader_subgroup = 0;
+int GLAD_GL_KHR_texture_compression_astc_hdr = 0;
+int GLAD_GL_KHR_texture_compression_astc_ldr = 0;
+int GLAD_GL_KHR_texture_compression_astc_sliced_3d = 0;
+int GLAD_GL_OES_EGL_image = 0;
+int GLAD_GL_OES_EGL_image_external = 0;
+int GLAD_GL_OES_EGL_image_external_essl3 = 0;
+int GLAD_GL_OES_compressed_ETC1_RGB8_sub_texture = 0;
+int GLAD_GL_OES_compressed_ETC1_RGB8_texture = 0;
+int GLAD_GL_OES_compressed_paletted_texture = 0;
+int GLAD_GL_OES_copy_image = 0;
+int GLAD_GL_OES_depth24 = 0;
+int GLAD_GL_OES_depth32 = 0;
+int GLAD_GL_OES_depth_texture = 0;
+int GLAD_GL_OES_draw_buffers_indexed = 0;
+int GLAD_GL_OES_draw_elements_base_vertex = 0;
+int GLAD_GL_OES_element_index_uint = 0;
+int GLAD_GL_OES_fbo_render_mipmap = 0;
+int GLAD_GL_OES_fragment_precision_high = 0;
+int GLAD_GL_OES_geometry_point_size = 0;
+int GLAD_GL_OES_geometry_shader = 0;
+int GLAD_GL_OES_get_program_binary = 0;
+int GLAD_GL_OES_gpu_shader5 = 0;
+int GLAD_GL_OES_mapbuffer = 0;
+int GLAD_GL_OES_packed_depth_stencil = 0;
+int GLAD_GL_OES_primitive_bounding_box = 0;
+int GLAD_GL_OES_required_internalformat = 0;
+int GLAD_GL_OES_rgb8_rgba8 = 0;
+int GLAD_GL_OES_sample_shading = 0;
+int GLAD_GL_OES_sample_variables = 0;
+int GLAD_GL_OES_shader_image_atomic = 0;
+int GLAD_GL_OES_shader_io_blocks = 0;
+int GLAD_GL_OES_shader_multisample_interpolation = 0;
+int GLAD_GL_OES_standard_derivatives = 0;
+int GLAD_GL_OES_stencil1 = 0;
+int GLAD_GL_OES_stencil4 = 0;
+int GLAD_GL_OES_surfaceless_context = 0;
+int GLAD_GL_OES_tessellation_point_size = 0;
+int GLAD_GL_OES_tessellation_shader = 0;
+int GLAD_GL_OES_texture_3D = 0;
+int GLAD_GL_OES_texture_border_clamp = 0;
+int GLAD_GL_OES_texture_buffer = 0;
+int GLAD_GL_OES_texture_compression_astc = 0;
+int GLAD_GL_OES_texture_cube_map_array = 0;
+int GLAD_GL_OES_texture_float = 0;
+int GLAD_GL_OES_texture_float_linear = 0;
+int GLAD_GL_OES_texture_half_float = 0;
+int GLAD_GL_OES_texture_half_float_linear = 0;
+int GLAD_GL_OES_texture_npot = 0;
+int GLAD_GL_OES_texture_stencil8 = 0;
+int GLAD_GL_OES_texture_storage_multisample_2d_array = 0;
+int GLAD_GL_OES_texture_view = 0;
+int GLAD_GL_OES_vertex_array_object = 0;
+int GLAD_GL_OES_vertex_half_float = 0;
+int GLAD_GL_OES_vertex_type_10_10_10_2 = 0;
+int GLAD_GL_OES_viewport_array = 0;
+
+
+
+PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC glad_glAcquireKeyedMutexWin32EXT = NULL;
+PFNGLACTIVESHADERPROGRAMEXTPROC glad_glActiveShaderProgramEXT = NULL;
+PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL;
+PFNGLATTACHSHADERPROC glad_glAttachShader = NULL;
+PFNGLBEGINQUERYEXTPROC glad_glBeginQueryEXT = NULL;
+PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL;
+PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL;
+PFNGLBINDFRAGDATALOCATIONEXTPROC glad_glBindFragDataLocationEXT = NULL;
+PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC glad_glBindFragDataLocationIndexedEXT = NULL;
+PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL;
+PFNGLBINDPROGRAMPIPELINEEXTPROC glad_glBindProgramPipelineEXT = NULL;
+PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL;
+PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL;
+PFNGLBINDVERTEXARRAYOESPROC glad_glBindVertexArrayOES = NULL;
+PFNGLBLENDBARRIERKHRPROC glad_glBlendBarrierKHR = NULL;
+PFNGLBLENDCOLORPROC glad_glBlendColor = NULL;
+PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL;
+PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL;
+PFNGLBLENDEQUATIONSEPARATEIEXTPROC glad_glBlendEquationSeparateiEXT = NULL;
+PFNGLBLENDEQUATIONSEPARATEIOESPROC glad_glBlendEquationSeparateiOES = NULL;
+PFNGLBLENDEQUATIONIEXTPROC glad_glBlendEquationiEXT = NULL;
+PFNGLBLENDEQUATIONIOESPROC glad_glBlendEquationiOES = NULL;
+PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL;
+PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL;
+PFNGLBLENDFUNCSEPARATEIEXTPROC glad_glBlendFuncSeparateiEXT = NULL;
+PFNGLBLENDFUNCSEPARATEIOESPROC glad_glBlendFuncSeparateiOES = NULL;
+PFNGLBLENDFUNCIEXTPROC glad_glBlendFunciEXT = NULL;
+PFNGLBLENDFUNCIOESPROC glad_glBlendFunciOES = NULL;
+PFNGLBUFFERDATAPROC glad_glBufferData = NULL;
+PFNGLBUFFERSTORAGEEXTPROC glad_glBufferStorageEXT = NULL;
+PFNGLBUFFERSTORAGEEXTERNALEXTPROC glad_glBufferStorageExternalEXT = NULL;
+PFNGLBUFFERSTORAGEMEMEXTPROC glad_glBufferStorageMemEXT = NULL;
+PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL;
+PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL;
+PFNGLCLEARPROC glad_glClear = NULL;
+PFNGLCLEARCOLORPROC glad_glClearColor = NULL;
+PFNGLCLEARDEPTHFPROC glad_glClearDepthf = NULL;
+PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC glad_glClearPixelLocalStorageuiEXT = NULL;
+PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL;
+PFNGLCLEARTEXIMAGEEXTPROC glad_glClearTexImageEXT = NULL;
+PFNGLCLEARTEXSUBIMAGEEXTPROC glad_glClearTexSubImageEXT = NULL;
+PFNGLCLIPCONTROLEXTPROC glad_glClipControlEXT = NULL;
+PFNGLCOLORMASKPROC glad_glColorMask = NULL;
+PFNGLCOLORMASKIEXTPROC glad_glColorMaskiEXT = NULL;
+PFNGLCOLORMASKIOESPROC glad_glColorMaskiOES = NULL;
+PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL;
+PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL;
+PFNGLCOMPRESSEDTEXIMAGE3DOESPROC glad_glCompressedTexImage3DOES = NULL;
+PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL;
+PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC glad_glCompressedTexSubImage3DOES = NULL;
+PFNGLCOPYIMAGESUBDATAEXTPROC glad_glCopyImageSubDataEXT = NULL;
+PFNGLCOPYIMAGESUBDATAOESPROC glad_glCopyImageSubDataOES = NULL;
+PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL;
+PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL;
+PFNGLCOPYTEXSUBIMAGE3DOESPROC glad_glCopyTexSubImage3DOES = NULL;
+PFNGLCREATEMEMORYOBJECTSEXTPROC glad_glCreateMemoryObjectsEXT = NULL;
+PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL;
+PFNGLCREATESHADERPROC glad_glCreateShader = NULL;
+PFNGLCREATESHADERPROGRAMVEXTPROC glad_glCreateShaderProgramvEXT = NULL;
+PFNGLCULLFACEPROC glad_glCullFace = NULL;
+PFNGLDEBUGMESSAGECALLBACKKHRPROC glad_glDebugMessageCallbackKHR = NULL;
+PFNGLDEBUGMESSAGECONTROLKHRPROC glad_glDebugMessageControlKHR = NULL;
+PFNGLDEBUGMESSAGEINSERTKHRPROC glad_glDebugMessageInsertKHR = NULL;
+PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL;
+PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL;
+PFNGLDELETEMEMORYOBJECTSEXTPROC glad_glDeleteMemoryObjectsEXT = NULL;
+PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL;
+PFNGLDELETEPROGRAMPIPELINESEXTPROC glad_glDeleteProgramPipelinesEXT = NULL;
+PFNGLDELETEQUERIESEXTPROC glad_glDeleteQueriesEXT = NULL;
+PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL;
+PFNGLDELETESEMAPHORESEXTPROC glad_glDeleteSemaphoresEXT = NULL;
+PFNGLDELETESHADERPROC glad_glDeleteShader = NULL;
+PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL;
+PFNGLDELETEVERTEXARRAYSOESPROC glad_glDeleteVertexArraysOES = NULL;
+PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL;
+PFNGLDEPTHMASKPROC glad_glDepthMask = NULL;
+PFNGLDEPTHRANGEARRAYFVOESPROC glad_glDepthRangeArrayfvOES = NULL;
+PFNGLDEPTHRANGEINDEXEDFOESPROC glad_glDepthRangeIndexedfOES = NULL;
+PFNGLDEPTHRANGEFPROC glad_glDepthRangef = NULL;
+PFNGLDETACHSHADERPROC glad_glDetachShader = NULL;
+PFNGLDISABLEPROC glad_glDisable = NULL;
+PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL;
+PFNGLDISABLEIEXTPROC glad_glDisableiEXT = NULL;
+PFNGLDISABLEIOESPROC glad_glDisableiOES = NULL;
+PFNGLDISCARDFRAMEBUFFEREXTPROC glad_glDiscardFramebufferEXT = NULL;
+PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL;
+PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC glad_glDrawArraysInstancedBaseInstanceEXT = NULL;
+PFNGLDRAWARRAYSINSTANCEDEXTPROC glad_glDrawArraysInstancedEXT = NULL;
+PFNGLDRAWBUFFERSEXTPROC glad_glDrawBuffersEXT = NULL;
+PFNGLDRAWBUFFERSINDEXEDEXTPROC glad_glDrawBuffersIndexedEXT = NULL;
+PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL;
+PFNGLDRAWELEMENTSBASEVERTEXEXTPROC glad_glDrawElementsBaseVertexEXT = NULL;
+PFNGLDRAWELEMENTSBASEVERTEXOESPROC glad_glDrawElementsBaseVertexOES = NULL;
+PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC glad_glDrawElementsInstancedBaseInstanceEXT = NULL;
+PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC glad_glDrawElementsInstancedBaseVertexBaseInstanceEXT = NULL;
+PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC glad_glDrawElementsInstancedBaseVertexEXT = NULL;
+PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC glad_glDrawElementsInstancedBaseVertexOES = NULL;
+PFNGLDRAWELEMENTSINSTANCEDEXTPROC glad_glDrawElementsInstancedEXT = NULL;
+PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC glad_glDrawRangeElementsBaseVertexEXT = NULL;
+PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC glad_glDrawRangeElementsBaseVertexOES = NULL;
+PFNGLDRAWTRANSFORMFEEDBACKEXTPROC glad_glDrawTransformFeedbackEXT = NULL;
+PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC glad_glDrawTransformFeedbackInstancedEXT = NULL;
+PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glad_glEGLImageTargetRenderbufferStorageOES = NULL;
+PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC glad_glEGLImageTargetTexStorageEXT = NULL;
+PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glad_glEGLImageTargetTexture2DOES = NULL;
+PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC glad_glEGLImageTargetTextureStorageEXT = NULL;
+PFNGLENABLEPROC glad_glEnable = NULL;
+PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL;
+PFNGLENABLEIEXTPROC glad_glEnableiEXT = NULL;
+PFNGLENABLEIOESPROC glad_glEnableiOES = NULL;
+PFNGLENDQUERYEXTPROC glad_glEndQueryEXT = NULL;
+PFNGLFINISHPROC glad_glFinish = NULL;
+PFNGLFLUSHPROC glad_glFlush = NULL;
+PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC glad_glFlushMappedBufferRangeEXT = NULL;
+PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC glad_glFramebufferFetchBarrierEXT = NULL;
+PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC glad_glFramebufferPixelLocalStorageSizeEXT = NULL;
+PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL;
+PFNGLFRAMEBUFFERSHADINGRATEEXTPROC glad_glFramebufferShadingRateEXT = NULL;
+PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL;
+PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC glad_glFramebufferTexture2DMultisampleEXT = NULL;
+PFNGLFRAMEBUFFERTEXTURE3DOESPROC glad_glFramebufferTexture3DOES = NULL;
+PFNGLFRAMEBUFFERTEXTUREEXTPROC glad_glFramebufferTextureEXT = NULL;
+PFNGLFRAMEBUFFERTEXTUREOESPROC glad_glFramebufferTextureOES = NULL;
+PFNGLFRONTFACEPROC glad_glFrontFace = NULL;
+PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL;
+PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL;
+PFNGLGENPROGRAMPIPELINESEXTPROC glad_glGenProgramPipelinesEXT = NULL;
+PFNGLGENQUERIESEXTPROC glad_glGenQueriesEXT = NULL;
+PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL;
+PFNGLGENSEMAPHORESEXTPROC glad_glGenSemaphoresEXT = NULL;
+PFNGLGENTEXTURESPROC glad_glGenTextures = NULL;
+PFNGLGENVERTEXARRAYSOESPROC glad_glGenVertexArraysOES = NULL;
+PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL;
+PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL;
+PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL;
+PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL;
+PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL;
+PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL;
+PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL;
+PFNGLGETBUFFERPOINTERVOESPROC glad_glGetBufferPointervOES = NULL;
+PFNGLGETDEBUGMESSAGELOGKHRPROC glad_glGetDebugMessageLogKHR = NULL;
+PFNGLGETERRORPROC glad_glGetError = NULL;
+PFNGLGETFLOATI_VOESPROC glad_glGetFloati_vOES = NULL;
+PFNGLGETFLOATVPROC glad_glGetFloatv = NULL;
+PFNGLGETFRAGDATAINDEXEXTPROC glad_glGetFragDataIndexEXT = NULL;
+PFNGLGETFRAGMENTSHADINGRATESEXTPROC glad_glGetFragmentShadingRatesEXT = NULL;
+PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL;
+PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC glad_glGetFramebufferPixelLocalStorageSizeEXT = NULL;
+PFNGLGETGRAPHICSRESETSTATUSEXTPROC glad_glGetGraphicsResetStatusEXT = NULL;
+PFNGLGETGRAPHICSRESETSTATUSKHRPROC glad_glGetGraphicsResetStatusKHR = NULL;
+PFNGLGETINTEGER64VEXTPROC glad_glGetInteger64vEXT = NULL;
+PFNGLGETINTEGERI_VEXTPROC glad_glGetIntegeri_vEXT = NULL;
+PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL;
+PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC glad_glGetMemoryObjectParameterivEXT = NULL;
+PFNGLGETOBJECTLABELEXTPROC glad_glGetObjectLabelEXT = NULL;
+PFNGLGETOBJECTLABELKHRPROC glad_glGetObjectLabelKHR = NULL;
+PFNGLGETOBJECTPTRLABELKHRPROC glad_glGetObjectPtrLabelKHR = NULL;
+PFNGLGETPOINTERVKHRPROC glad_glGetPointervKHR = NULL;
+PFNGLGETPROGRAMBINARYOESPROC glad_glGetProgramBinaryOES = NULL;
+PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL;
+PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC glad_glGetProgramPipelineInfoLogEXT = NULL;
+PFNGLGETPROGRAMPIPELINEIVEXTPROC glad_glGetProgramPipelineivEXT = NULL;
+PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC glad_glGetProgramResourceLocationIndexEXT = NULL;
+PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL;
+PFNGLGETQUERYOBJECTI64VEXTPROC glad_glGetQueryObjecti64vEXT = NULL;
+PFNGLGETQUERYOBJECTIVEXTPROC glad_glGetQueryObjectivEXT = NULL;
+PFNGLGETQUERYOBJECTUI64VEXTPROC glad_glGetQueryObjectui64vEXT = NULL;
+PFNGLGETQUERYOBJECTUIVEXTPROC glad_glGetQueryObjectuivEXT = NULL;
+PFNGLGETQUERYIVEXTPROC glad_glGetQueryivEXT = NULL;
+PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL;
+PFNGLGETSAMPLERPARAMETERIIVEXTPROC glad_glGetSamplerParameterIivEXT = NULL;
+PFNGLGETSAMPLERPARAMETERIIVOESPROC glad_glGetSamplerParameterIivOES = NULL;
+PFNGLGETSAMPLERPARAMETERIUIVEXTPROC glad_glGetSamplerParameterIuivEXT = NULL;
+PFNGLGETSAMPLERPARAMETERIUIVOESPROC glad_glGetSamplerParameterIuivOES = NULL;
+PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC glad_glGetSemaphoreParameterui64vEXT = NULL;
+PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL;
+PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat = NULL;
+PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL;
+PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL;
+PFNGLGETSTRINGPROC glad_glGetString = NULL;
+PFNGLGETTEXPARAMETERIIVEXTPROC glad_glGetTexParameterIivEXT = NULL;
+PFNGLGETTEXPARAMETERIIVOESPROC glad_glGetTexParameterIivOES = NULL;
+PFNGLGETTEXPARAMETERIUIVEXTPROC glad_glGetTexParameterIuivEXT = NULL;
+PFNGLGETTEXPARAMETERIUIVOESPROC glad_glGetTexParameterIuivOES = NULL;
+PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL;
+PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL;
+PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL;
+PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL;
+PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL;
+PFNGLGETUNSIGNEDBYTEI_VEXTPROC glad_glGetUnsignedBytei_vEXT = NULL;
+PFNGLGETUNSIGNEDBYTEVEXTPROC glad_glGetUnsignedBytevEXT = NULL;
+PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL;
+PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL;
+PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL;
+PFNGLGETNUNIFORMFVEXTPROC glad_glGetnUniformfvEXT = NULL;
+PFNGLGETNUNIFORMFVKHRPROC glad_glGetnUniformfvKHR = NULL;
+PFNGLGETNUNIFORMIVEXTPROC glad_glGetnUniformivEXT = NULL;
+PFNGLGETNUNIFORMIVKHRPROC glad_glGetnUniformivKHR = NULL;
+PFNGLGETNUNIFORMUIVKHRPROC glad_glGetnUniformuivKHR = NULL;
+PFNGLHINTPROC glad_glHint = NULL;
+PFNGLIMPORTMEMORYFDEXTPROC glad_glImportMemoryFdEXT = NULL;
+PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC glad_glImportMemoryWin32HandleEXT = NULL;
+PFNGLIMPORTMEMORYWIN32NAMEEXTPROC glad_glImportMemoryWin32NameEXT = NULL;
+PFNGLIMPORTSEMAPHOREFDEXTPROC glad_glImportSemaphoreFdEXT = NULL;
+PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC glad_glImportSemaphoreWin32HandleEXT = NULL;
+PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC glad_glImportSemaphoreWin32NameEXT = NULL;
+PFNGLINSERTEVENTMARKEREXTPROC glad_glInsertEventMarkerEXT = NULL;
+PFNGLISBUFFERPROC glad_glIsBuffer = NULL;
+PFNGLISENABLEDPROC glad_glIsEnabled = NULL;
+PFNGLISENABLEDIEXTPROC glad_glIsEnablediEXT = NULL;
+PFNGLISENABLEDIOESPROC glad_glIsEnablediOES = NULL;
+PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL;
+PFNGLISMEMORYOBJECTEXTPROC glad_glIsMemoryObjectEXT = NULL;
+PFNGLISPROGRAMPROC glad_glIsProgram = NULL;
+PFNGLISPROGRAMPIPELINEEXTPROC glad_glIsProgramPipelineEXT = NULL;
+PFNGLISQUERYEXTPROC glad_glIsQueryEXT = NULL;
+PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL;
+PFNGLISSEMAPHOREEXTPROC glad_glIsSemaphoreEXT = NULL;
+PFNGLISSHADERPROC glad_glIsShader = NULL;
+PFNGLISTEXTUREPROC glad_glIsTexture = NULL;
+PFNGLISVERTEXARRAYOESPROC glad_glIsVertexArrayOES = NULL;
+PFNGLLABELOBJECTEXTPROC glad_glLabelObjectEXT = NULL;
+PFNGLLINEWIDTHPROC glad_glLineWidth = NULL;
+PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL;
+PFNGLMAPBUFFEROESPROC glad_glMapBufferOES = NULL;
+PFNGLMAPBUFFERRANGEEXTPROC glad_glMapBufferRangeEXT = NULL;
+PFNGLMAXSHADERCOMPILERTHREADSKHRPROC glad_glMaxShaderCompilerThreadsKHR = NULL;
+PFNGLMEMORYOBJECTPARAMETERIVEXTPROC glad_glMemoryObjectParameterivEXT = NULL;
+PFNGLMINSAMPLESHADINGOESPROC glad_glMinSampleShadingOES = NULL;
+PFNGLMULTIDRAWARRAYSEXTPROC glad_glMultiDrawArraysEXT = NULL;
+PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC glad_glMultiDrawArraysIndirectEXT = NULL;
+PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC glad_glMultiDrawElementsBaseVertexEXT = NULL;
+PFNGLMULTIDRAWELEMENTSEXTPROC glad_glMultiDrawElementsEXT = NULL;
+PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC glad_glMultiDrawElementsIndirectEXT = NULL;
+PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC glad_glNamedBufferStorageExternalEXT = NULL;
+PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC glad_glNamedBufferStorageMemEXT = NULL;
+PFNGLOBJECTLABELKHRPROC glad_glObjectLabelKHR = NULL;
+PFNGLOBJECTPTRLABELKHRPROC glad_glObjectPtrLabelKHR = NULL;
+PFNGLPATCHPARAMETERIEXTPROC glad_glPatchParameteriEXT = NULL;
+PFNGLPATCHPARAMETERIOESPROC glad_glPatchParameteriOES = NULL;
+PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL;
+PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL;
+PFNGLPOLYGONOFFSETCLAMPEXTPROC glad_glPolygonOffsetClampEXT = NULL;
+PFNGLPOPDEBUGGROUPKHRPROC glad_glPopDebugGroupKHR = NULL;
+PFNGLPOPGROUPMARKEREXTPROC glad_glPopGroupMarkerEXT = NULL;
+PFNGLPRIMITIVEBOUNDINGBOXEXTPROC glad_glPrimitiveBoundingBoxEXT = NULL;
+PFNGLPRIMITIVEBOUNDINGBOXOESPROC glad_glPrimitiveBoundingBoxOES = NULL;
+PFNGLPROGRAMBINARYOESPROC glad_glProgramBinaryOES = NULL;
+PFNGLPROGRAMPARAMETERIEXTPROC glad_glProgramParameteriEXT = NULL;
+PFNGLPROGRAMUNIFORM1FEXTPROC glad_glProgramUniform1fEXT = NULL;
+PFNGLPROGRAMUNIFORM1FVEXTPROC glad_glProgramUniform1fvEXT = NULL;
+PFNGLPROGRAMUNIFORM1IEXTPROC glad_glProgramUniform1iEXT = NULL;
+PFNGLPROGRAMUNIFORM1IVEXTPROC glad_glProgramUniform1ivEXT = NULL;
+PFNGLPROGRAMUNIFORM1UIEXTPROC glad_glProgramUniform1uiEXT = NULL;
+PFNGLPROGRAMUNIFORM1UIVEXTPROC glad_glProgramUniform1uivEXT = NULL;
+PFNGLPROGRAMUNIFORM2FEXTPROC glad_glProgramUniform2fEXT = NULL;
+PFNGLPROGRAMUNIFORM2FVEXTPROC glad_glProgramUniform2fvEXT = NULL;
+PFNGLPROGRAMUNIFORM2IEXTPROC glad_glProgramUniform2iEXT = NULL;
+PFNGLPROGRAMUNIFORM2IVEXTPROC glad_glProgramUniform2ivEXT = NULL;
+PFNGLPROGRAMUNIFORM2UIEXTPROC glad_glProgramUniform2uiEXT = NULL;
+PFNGLPROGRAMUNIFORM2UIVEXTPROC glad_glProgramUniform2uivEXT = NULL;
+PFNGLPROGRAMUNIFORM3FEXTPROC glad_glProgramUniform3fEXT = NULL;
+PFNGLPROGRAMUNIFORM3FVEXTPROC glad_glProgramUniform3fvEXT = NULL;
+PFNGLPROGRAMUNIFORM3IEXTPROC glad_glProgramUniform3iEXT = NULL;
+PFNGLPROGRAMUNIFORM3IVEXTPROC glad_glProgramUniform3ivEXT = NULL;
+PFNGLPROGRAMUNIFORM3UIEXTPROC glad_glProgramUniform3uiEXT = NULL;
+PFNGLPROGRAMUNIFORM3UIVEXTPROC glad_glProgramUniform3uivEXT = NULL;
+PFNGLPROGRAMUNIFORM4FEXTPROC glad_glProgramUniform4fEXT = NULL;
+PFNGLPROGRAMUNIFORM4FVEXTPROC glad_glProgramUniform4fvEXT = NULL;
+PFNGLPROGRAMUNIFORM4IEXTPROC glad_glProgramUniform4iEXT = NULL;
+PFNGLPROGRAMUNIFORM4IVEXTPROC glad_glProgramUniform4ivEXT = NULL;
+PFNGLPROGRAMUNIFORM4UIEXTPROC glad_glProgramUniform4uiEXT = NULL;
+PFNGLPROGRAMUNIFORM4UIVEXTPROC glad_glProgramUniform4uivEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC glad_glProgramUniformMatrix2fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC glad_glProgramUniformMatrix2x3fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC glad_glProgramUniformMatrix2x4fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC glad_glProgramUniformMatrix3fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC glad_glProgramUniformMatrix3x2fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC glad_glProgramUniformMatrix3x4fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC glad_glProgramUniformMatrix4fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC glad_glProgramUniformMatrix4x2fvEXT = NULL;
+PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC glad_glProgramUniformMatrix4x3fvEXT = NULL;
+PFNGLPUSHDEBUGGROUPKHRPROC glad_glPushDebugGroupKHR = NULL;
+PFNGLPUSHGROUPMARKEREXTPROC glad_glPushGroupMarkerEXT = NULL;
+PFNGLQUERYCOUNTEREXTPROC glad_glQueryCounterEXT = NULL;
+PFNGLRASTERSAMPLESEXTPROC glad_glRasterSamplesEXT = NULL;
+PFNGLREADBUFFERINDEXEDEXTPROC glad_glReadBufferIndexedEXT = NULL;
+PFNGLREADPIXELSPROC glad_glReadPixels = NULL;
+PFNGLREADNPIXELSEXTPROC glad_glReadnPixelsEXT = NULL;
+PFNGLREADNPIXELSKHRPROC glad_glReadnPixelsKHR = NULL;
+PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC glad_glReleaseKeyedMutexWin32EXT = NULL;
+PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler = NULL;
+PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL;
+PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT = NULL;
+PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL;
+PFNGLSAMPLERPARAMETERIIVEXTPROC glad_glSamplerParameterIivEXT = NULL;
+PFNGLSAMPLERPARAMETERIIVOESPROC glad_glSamplerParameterIivOES = NULL;
+PFNGLSAMPLERPARAMETERIUIVEXTPROC glad_glSamplerParameterIuivEXT = NULL;
+PFNGLSAMPLERPARAMETERIUIVOESPROC glad_glSamplerParameterIuivOES = NULL;
+PFNGLSCISSORPROC glad_glScissor = NULL;
+PFNGLSCISSORARRAYVOESPROC glad_glScissorArrayvOES = NULL;
+PFNGLSCISSORINDEXEDOESPROC glad_glScissorIndexedOES = NULL;
+PFNGLSCISSORINDEXEDVOESPROC glad_glScissorIndexedvOES = NULL;
+PFNGLSEMAPHOREPARAMETERUI64VEXTPROC glad_glSemaphoreParameterui64vEXT = NULL;
+PFNGLSHADERBINARYPROC glad_glShaderBinary = NULL;
+PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL;
+PFNGLSHADINGRATECOMBINEROPSEXTPROC glad_glShadingRateCombinerOpsEXT = NULL;
+PFNGLSHADINGRATEEXTPROC glad_glShadingRateEXT = NULL;
+PFNGLSIGNALSEMAPHOREEXTPROC glad_glSignalSemaphoreEXT = NULL;
+PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL;
+PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL;
+PFNGLSTENCILMASKPROC glad_glStencilMask = NULL;
+PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL;
+PFNGLSTENCILOPPROC glad_glStencilOp = NULL;
+PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL;
+PFNGLTEXBUFFEREXTPROC glad_glTexBufferEXT = NULL;
+PFNGLTEXBUFFEROESPROC glad_glTexBufferOES = NULL;
+PFNGLTEXBUFFERRANGEEXTPROC glad_glTexBufferRangeEXT = NULL;
+PFNGLTEXBUFFERRANGEOESPROC glad_glTexBufferRangeOES = NULL;
+PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL;
+PFNGLTEXIMAGE3DOESPROC glad_glTexImage3DOES = NULL;
+PFNGLTEXPAGECOMMITMENTEXTPROC glad_glTexPageCommitmentEXT = NULL;
+PFNGLTEXPARAMETERIIVEXTPROC glad_glTexParameterIivEXT = NULL;
+PFNGLTEXPARAMETERIIVOESPROC glad_glTexParameterIivOES = NULL;
+PFNGLTEXPARAMETERIUIVEXTPROC glad_glTexParameterIuivEXT = NULL;
+PFNGLTEXPARAMETERIUIVOESPROC glad_glTexParameterIuivOES = NULL;
+PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL;
+PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL;
+PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL;
+PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL;
+PFNGLTEXSTORAGE1DEXTPROC glad_glTexStorage1DEXT = NULL;
+PFNGLTEXSTORAGE2DEXTPROC glad_glTexStorage2DEXT = NULL;
+PFNGLTEXSTORAGE3DEXTPROC glad_glTexStorage3DEXT = NULL;
+PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC glad_glTexStorage3DMultisampleOES = NULL;
+PFNGLTEXSTORAGEATTRIBS2DEXTPROC glad_glTexStorageAttribs2DEXT = NULL;
+PFNGLTEXSTORAGEATTRIBS3DEXTPROC glad_glTexStorageAttribs3DEXT = NULL;
+PFNGLTEXSTORAGEMEM2DEXTPROC glad_glTexStorageMem2DEXT = NULL;
+PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC glad_glTexStorageMem2DMultisampleEXT = NULL;
+PFNGLTEXSTORAGEMEM3DEXTPROC glad_glTexStorageMem3DEXT = NULL;
+PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC glad_glTexStorageMem3DMultisampleEXT = NULL;
+PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL;
+PFNGLTEXSUBIMAGE3DOESPROC glad_glTexSubImage3DOES = NULL;
+PFNGLTEXTURESTORAGE1DEXTPROC glad_glTextureStorage1DEXT = NULL;
+PFNGLTEXTURESTORAGE2DEXTPROC glad_glTextureStorage2DEXT = NULL;
+PFNGLTEXTURESTORAGE3DEXTPROC glad_glTextureStorage3DEXT = NULL;
+PFNGLTEXTURESTORAGEMEM2DEXTPROC glad_glTextureStorageMem2DEXT = NULL;
+PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC glad_glTextureStorageMem2DMultisampleEXT = NULL;
+PFNGLTEXTURESTORAGEMEM3DEXTPROC glad_glTextureStorageMem3DEXT = NULL;
+PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC glad_glTextureStorageMem3DMultisampleEXT = NULL;
+PFNGLTEXTUREVIEWEXTPROC glad_glTextureViewEXT = NULL;
+PFNGLTEXTUREVIEWOESPROC glad_glTextureViewOES = NULL;
+PFNGLUNIFORM1FPROC glad_glUniform1f = NULL;
+PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL;
+PFNGLUNIFORM1IPROC glad_glUniform1i = NULL;
+PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL;
+PFNGLUNIFORM2FPROC glad_glUniform2f = NULL;
+PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL;
+PFNGLUNIFORM2IPROC glad_glUniform2i = NULL;
+PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL;
+PFNGLUNIFORM3FPROC glad_glUniform3f = NULL;
+PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL;
+PFNGLUNIFORM3IPROC glad_glUniform3i = NULL;
+PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL;
+PFNGLUNIFORM4FPROC glad_glUniform4f = NULL;
+PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL;
+PFNGLUNIFORM4IPROC glad_glUniform4i = NULL;
+PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL;
+PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL;
+PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL;
+PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL;
+PFNGLUNMAPBUFFEROESPROC glad_glUnmapBufferOES = NULL;
+PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL;
+PFNGLUSEPROGRAMSTAGESEXTPROC glad_glUseProgramStagesEXT = NULL;
+PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL;
+PFNGLVALIDATEPROGRAMPIPELINEEXTPROC glad_glValidateProgramPipelineEXT = NULL;
+PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL;
+PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL;
+PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL;
+PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL;
+PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL;
+PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL;
+PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL;
+PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL;
+PFNGLVERTEXATTRIBDIVISOREXTPROC glad_glVertexAttribDivisorEXT = NULL;
+PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL;
+PFNGLVIEWPORTPROC glad_glViewport = NULL;
+PFNGLVIEWPORTARRAYVOESPROC glad_glViewportArrayvOES = NULL;
+PFNGLVIEWPORTINDEXEDFOESPROC glad_glViewportIndexedfOES = NULL;
+PFNGLVIEWPORTINDEXEDFVOESPROC glad_glViewportIndexedfvOES = NULL;
+PFNGLWAITSEMAPHOREEXTPROC glad_glWaitSemaphoreEXT = NULL;
+PFNGLWINDOWRECTANGLESEXTPROC glad_glWindowRectanglesEXT = NULL;
+
+
+static void glad_gl_load_GL_ES_VERSION_2_0( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_ES_VERSION_2_0) return;
+ glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC) load(userptr, "glActiveTexture");
+ glad_glAttachShader = (PFNGLATTACHSHADERPROC) load(userptr, "glAttachShader");
+ glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load(userptr, "glBindAttribLocation");
+ glad_glBindBuffer = (PFNGLBINDBUFFERPROC) load(userptr, "glBindBuffer");
+ glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load(userptr, "glBindFramebuffer");
+ glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load(userptr, "glBindRenderbuffer");
+ glad_glBindTexture = (PFNGLBINDTEXTUREPROC) load(userptr, "glBindTexture");
+ glad_glBlendColor = (PFNGLBLENDCOLORPROC) load(userptr, "glBlendColor");
+ glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC) load(userptr, "glBlendEquation");
+ glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load(userptr, "glBlendEquationSeparate");
+ glad_glBlendFunc = (PFNGLBLENDFUNCPROC) load(userptr, "glBlendFunc");
+ glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load(userptr, "glBlendFuncSeparate");
+ glad_glBufferData = (PFNGLBUFFERDATAPROC) load(userptr, "glBufferData");
+ glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load(userptr, "glBufferSubData");
+ glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load(userptr, "glCheckFramebufferStatus");
+ glad_glClear = (PFNGLCLEARPROC) load(userptr, "glClear");
+ glad_glClearColor = (PFNGLCLEARCOLORPROC) load(userptr, "glClearColor");
+ glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC) load(userptr, "glClearDepthf");
+ glad_glClearStencil = (PFNGLCLEARSTENCILPROC) load(userptr, "glClearStencil");
+ glad_glColorMask = (PFNGLCOLORMASKPROC) load(userptr, "glColorMask");
+ glad_glCompileShader = (PFNGLCOMPILESHADERPROC) load(userptr, "glCompileShader");
+ glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load(userptr, "glCompressedTexImage2D");
+ glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load(userptr, "glCompressedTexSubImage2D");
+ glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load(userptr, "glCopyTexImage2D");
+ glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load(userptr, "glCopyTexSubImage2D");
+ glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC) load(userptr, "glCreateProgram");
+ glad_glCreateShader = (PFNGLCREATESHADERPROC) load(userptr, "glCreateShader");
+ glad_glCullFace = (PFNGLCULLFACEPROC) load(userptr, "glCullFace");
+ glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load(userptr, "glDeleteBuffers");
+ glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load(userptr, "glDeleteFramebuffers");
+ glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load(userptr, "glDeleteProgram");
+ glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load(userptr, "glDeleteRenderbuffers");
+ glad_glDeleteShader = (PFNGLDELETESHADERPROC) load(userptr, "glDeleteShader");
+ glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC) load(userptr, "glDeleteTextures");
+ glad_glDepthFunc = (PFNGLDEPTHFUNCPROC) load(userptr, "glDepthFunc");
+ glad_glDepthMask = (PFNGLDEPTHMASKPROC) load(userptr, "glDepthMask");
+ glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC) load(userptr, "glDepthRangef");
+ glad_glDetachShader = (PFNGLDETACHSHADERPROC) load(userptr, "glDetachShader");
+ glad_glDisable = (PFNGLDISABLEPROC) load(userptr, "glDisable");
+ glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load(userptr, "glDisableVertexAttribArray");
+ glad_glDrawArrays = (PFNGLDRAWARRAYSPROC) load(userptr, "glDrawArrays");
+ glad_glDrawElements = (PFNGLDRAWELEMENTSPROC) load(userptr, "glDrawElements");
+ glad_glEnable = (PFNGLENABLEPROC) load(userptr, "glEnable");
+ glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load(userptr, "glEnableVertexAttribArray");
+ glad_glFinish = (PFNGLFINISHPROC) load(userptr, "glFinish");
+ glad_glFlush = (PFNGLFLUSHPROC) load(userptr, "glFlush");
+ glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load(userptr, "glFramebufferRenderbuffer");
+ glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load(userptr, "glFramebufferTexture2D");
+ glad_glFrontFace = (PFNGLFRONTFACEPROC) load(userptr, "glFrontFace");
+ glad_glGenBuffers = (PFNGLGENBUFFERSPROC) load(userptr, "glGenBuffers");
+ glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load(userptr, "glGenFramebuffers");
+ glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load(userptr, "glGenRenderbuffers");
+ glad_glGenTextures = (PFNGLGENTEXTURESPROC) load(userptr, "glGenTextures");
+ glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load(userptr, "glGenerateMipmap");
+ glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load(userptr, "glGetActiveAttrib");
+ glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load(userptr, "glGetActiveUniform");
+ glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load(userptr, "glGetAttachedShaders");
+ glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load(userptr, "glGetAttribLocation");
+ glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC) load(userptr, "glGetBooleanv");
+ glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load(userptr, "glGetBufferParameteriv");
+ glad_glGetError = (PFNGLGETERRORPROC) load(userptr, "glGetError");
+ glad_glGetFloatv = (PFNGLGETFLOATVPROC) load(userptr, "glGetFloatv");
+ glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load(userptr, "glGetFramebufferAttachmentParameteriv");
+ glad_glGetIntegerv = (PFNGLGETINTEGERVPROC) load(userptr, "glGetIntegerv");
+ glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load(userptr, "glGetProgramInfoLog");
+ glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load(userptr, "glGetProgramiv");
+ glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load(userptr, "glGetRenderbufferParameteriv");
+ glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load(userptr, "glGetShaderInfoLog");
+ glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC) load(userptr, "glGetShaderPrecisionFormat");
+ glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load(userptr, "glGetShaderSource");
+ glad_glGetShaderiv = (PFNGLGETSHADERIVPROC) load(userptr, "glGetShaderiv");
+ glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
+ glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load(userptr, "glGetTexParameterfv");
+ glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load(userptr, "glGetTexParameteriv");
+ glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load(userptr, "glGetUniformLocation");
+ glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load(userptr, "glGetUniformfv");
+ glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load(userptr, "glGetUniformiv");
+ glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load(userptr, "glGetVertexAttribPointerv");
+ glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load(userptr, "glGetVertexAttribfv");
+ glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load(userptr, "glGetVertexAttribiv");
+ glad_glHint = (PFNGLHINTPROC) load(userptr, "glHint");
+ glad_glIsBuffer = (PFNGLISBUFFERPROC) load(userptr, "glIsBuffer");
+ glad_glIsEnabled = (PFNGLISENABLEDPROC) load(userptr, "glIsEnabled");
+ glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load(userptr, "glIsFramebuffer");
+ glad_glIsProgram = (PFNGLISPROGRAMPROC) load(userptr, "glIsProgram");
+ glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load(userptr, "glIsRenderbuffer");
+ glad_glIsShader = (PFNGLISSHADERPROC) load(userptr, "glIsShader");
+ glad_glIsTexture = (PFNGLISTEXTUREPROC) load(userptr, "glIsTexture");
+ glad_glLineWidth = (PFNGLLINEWIDTHPROC) load(userptr, "glLineWidth");
+ glad_glLinkProgram = (PFNGLLINKPROGRAMPROC) load(userptr, "glLinkProgram");
+ glad_glPixelStorei = (PFNGLPIXELSTOREIPROC) load(userptr, "glPixelStorei");
+ glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load(userptr, "glPolygonOffset");
+ glad_glReadPixels = (PFNGLREADPIXELSPROC) load(userptr, "glReadPixels");
+ glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC) load(userptr, "glReleaseShaderCompiler");
+ glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load(userptr, "glRenderbufferStorage");
+ glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load(userptr, "glSampleCoverage");
+ glad_glScissor = (PFNGLSCISSORPROC) load(userptr, "glScissor");
+ glad_glShaderBinary = (PFNGLSHADERBINARYPROC) load(userptr, "glShaderBinary");
+ glad_glShaderSource = (PFNGLSHADERSOURCEPROC) load(userptr, "glShaderSource");
+ glad_glStencilFunc = (PFNGLSTENCILFUNCPROC) load(userptr, "glStencilFunc");
+ glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load(userptr, "glStencilFuncSeparate");
+ glad_glStencilMask = (PFNGLSTENCILMASKPROC) load(userptr, "glStencilMask");
+ glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load(userptr, "glStencilMaskSeparate");
+ glad_glStencilOp = (PFNGLSTENCILOPPROC) load(userptr, "glStencilOp");
+ glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load(userptr, "glStencilOpSeparate");
+ glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC) load(userptr, "glTexImage2D");
+ glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC) load(userptr, "glTexParameterf");
+ glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load(userptr, "glTexParameterfv");
+ glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC) load(userptr, "glTexParameteri");
+ glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load(userptr, "glTexParameteriv");
+ glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load(userptr, "glTexSubImage2D");
+ glad_glUniform1f = (PFNGLUNIFORM1FPROC) load(userptr, "glUniform1f");
+ glad_glUniform1fv = (PFNGLUNIFORM1FVPROC) load(userptr, "glUniform1fv");
+ glad_glUniform1i = (PFNGLUNIFORM1IPROC) load(userptr, "glUniform1i");
+ glad_glUniform1iv = (PFNGLUNIFORM1IVPROC) load(userptr, "glUniform1iv");
+ glad_glUniform2f = (PFNGLUNIFORM2FPROC) load(userptr, "glUniform2f");
+ glad_glUniform2fv = (PFNGLUNIFORM2FVPROC) load(userptr, "glUniform2fv");
+ glad_glUniform2i = (PFNGLUNIFORM2IPROC) load(userptr, "glUniform2i");
+ glad_glUniform2iv = (PFNGLUNIFORM2IVPROC) load(userptr, "glUniform2iv");
+ glad_glUniform3f = (PFNGLUNIFORM3FPROC) load(userptr, "glUniform3f");
+ glad_glUniform3fv = (PFNGLUNIFORM3FVPROC) load(userptr, "glUniform3fv");
+ glad_glUniform3i = (PFNGLUNIFORM3IPROC) load(userptr, "glUniform3i");
+ glad_glUniform3iv = (PFNGLUNIFORM3IVPROC) load(userptr, "glUniform3iv");
+ glad_glUniform4f = (PFNGLUNIFORM4FPROC) load(userptr, "glUniform4f");
+ glad_glUniform4fv = (PFNGLUNIFORM4FVPROC) load(userptr, "glUniform4fv");
+ glad_glUniform4i = (PFNGLUNIFORM4IPROC) load(userptr, "glUniform4i");
+ glad_glUniform4iv = (PFNGLUNIFORM4IVPROC) load(userptr, "glUniform4iv");
+ glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load(userptr, "glUniformMatrix2fv");
+ glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load(userptr, "glUniformMatrix3fv");
+ glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load(userptr, "glUniformMatrix4fv");
+ glad_glUseProgram = (PFNGLUSEPROGRAMPROC) load(userptr, "glUseProgram");
+ glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load(userptr, "glValidateProgram");
+ glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load(userptr, "glVertexAttrib1f");
+ glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load(userptr, "glVertexAttrib1fv");
+ glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load(userptr, "glVertexAttrib2f");
+ glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load(userptr, "glVertexAttrib2fv");
+ glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load(userptr, "glVertexAttrib3f");
+ glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load(userptr, "glVertexAttrib3fv");
+ glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load(userptr, "glVertexAttrib4f");
+ glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load(userptr, "glVertexAttrib4fv");
+ glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load(userptr, "glVertexAttribPointer");
+ glad_glViewport = (PFNGLVIEWPORTPROC) load(userptr, "glViewport");
+}
+static void glad_gl_load_GL_EXT_EGL_image_storage( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_EGL_image_storage) return;
+ glad_glEGLImageTargetTexStorageEXT = (PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) load(userptr, "glEGLImageTargetTexStorageEXT");
+ glad_glEGLImageTargetTextureStorageEXT = (PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) load(userptr, "glEGLImageTargetTextureStorageEXT");
+}
+static void glad_gl_load_GL_EXT_base_instance( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_base_instance) return;
+ glad_glDrawArraysInstancedBaseInstanceEXT = (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC) load(userptr, "glDrawArraysInstancedBaseInstanceEXT");
+ glad_glDrawElementsInstancedBaseInstanceEXT = (PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC) load(userptr, "glDrawElementsInstancedBaseInstanceEXT");
+ glad_glDrawElementsInstancedBaseVertexBaseInstanceEXT = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC) load(userptr, "glDrawElementsInstancedBaseVertexBaseInstanceEXT");
+}
+static void glad_gl_load_GL_EXT_blend_func_extended( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_blend_func_extended) return;
+ glad_glBindFragDataLocationEXT = (PFNGLBINDFRAGDATALOCATIONEXTPROC) load(userptr, "glBindFragDataLocationEXT");
+ glad_glBindFragDataLocationIndexedEXT = (PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC) load(userptr, "glBindFragDataLocationIndexedEXT");
+ glad_glGetFragDataIndexEXT = (PFNGLGETFRAGDATAINDEXEXTPROC) load(userptr, "glGetFragDataIndexEXT");
+ glad_glGetProgramResourceLocationIndexEXT = (PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC) load(userptr, "glGetProgramResourceLocationIndexEXT");
+}
+static void glad_gl_load_GL_EXT_buffer_storage( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_buffer_storage) return;
+ glad_glBufferStorageEXT = (PFNGLBUFFERSTORAGEEXTPROC) load(userptr, "glBufferStorageEXT");
+}
+static void glad_gl_load_GL_EXT_clear_texture( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_clear_texture) return;
+ glad_glClearTexImageEXT = (PFNGLCLEARTEXIMAGEEXTPROC) load(userptr, "glClearTexImageEXT");
+ glad_glClearTexSubImageEXT = (PFNGLCLEARTEXSUBIMAGEEXTPROC) load(userptr, "glClearTexSubImageEXT");
+}
+static void glad_gl_load_GL_EXT_clip_control( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_clip_control) return;
+ glad_glClipControlEXT = (PFNGLCLIPCONTROLEXTPROC) load(userptr, "glClipControlEXT");
+}
+static void glad_gl_load_GL_EXT_copy_image( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_copy_image) return;
+ glad_glCopyImageSubDataEXT = (PFNGLCOPYIMAGESUBDATAEXTPROC) load(userptr, "glCopyImageSubDataEXT");
+}
+static void glad_gl_load_GL_EXT_debug_label( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_debug_label) return;
+ glad_glGetObjectLabelEXT = (PFNGLGETOBJECTLABELEXTPROC) load(userptr, "glGetObjectLabelEXT");
+ glad_glLabelObjectEXT = (PFNGLLABELOBJECTEXTPROC) load(userptr, "glLabelObjectEXT");
+}
+static void glad_gl_load_GL_EXT_debug_marker( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_debug_marker) return;
+ glad_glInsertEventMarkerEXT = (PFNGLINSERTEVENTMARKEREXTPROC) load(userptr, "glInsertEventMarkerEXT");
+ glad_glPopGroupMarkerEXT = (PFNGLPOPGROUPMARKEREXTPROC) load(userptr, "glPopGroupMarkerEXT");
+ glad_glPushGroupMarkerEXT = (PFNGLPUSHGROUPMARKEREXTPROC) load(userptr, "glPushGroupMarkerEXT");
+}
+static void glad_gl_load_GL_EXT_discard_framebuffer( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_discard_framebuffer) return;
+ glad_glDiscardFramebufferEXT = (PFNGLDISCARDFRAMEBUFFEREXTPROC) load(userptr, "glDiscardFramebufferEXT");
+}
+static void glad_gl_load_GL_EXT_disjoint_timer_query( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_disjoint_timer_query) return;
+ glad_glBeginQueryEXT = (PFNGLBEGINQUERYEXTPROC) load(userptr, "glBeginQueryEXT");
+ glad_glDeleteQueriesEXT = (PFNGLDELETEQUERIESEXTPROC) load(userptr, "glDeleteQueriesEXT");
+ glad_glEndQueryEXT = (PFNGLENDQUERYEXTPROC) load(userptr, "glEndQueryEXT");
+ glad_glGenQueriesEXT = (PFNGLGENQUERIESEXTPROC) load(userptr, "glGenQueriesEXT");
+ glad_glGetInteger64vEXT = (PFNGLGETINTEGER64VEXTPROC) load(userptr, "glGetInteger64vEXT");
+ glad_glGetQueryObjecti64vEXT = (PFNGLGETQUERYOBJECTI64VEXTPROC) load(userptr, "glGetQueryObjecti64vEXT");
+ glad_glGetQueryObjectivEXT = (PFNGLGETQUERYOBJECTIVEXTPROC) load(userptr, "glGetQueryObjectivEXT");
+ glad_glGetQueryObjectui64vEXT = (PFNGLGETQUERYOBJECTUI64VEXTPROC) load(userptr, "glGetQueryObjectui64vEXT");
+ glad_glGetQueryObjectuivEXT = (PFNGLGETQUERYOBJECTUIVEXTPROC) load(userptr, "glGetQueryObjectuivEXT");
+ glad_glGetQueryivEXT = (PFNGLGETQUERYIVEXTPROC) load(userptr, "glGetQueryivEXT");
+ glad_glIsQueryEXT = (PFNGLISQUERYEXTPROC) load(userptr, "glIsQueryEXT");
+ glad_glQueryCounterEXT = (PFNGLQUERYCOUNTEREXTPROC) load(userptr, "glQueryCounterEXT");
+}
+static void glad_gl_load_GL_EXT_draw_buffers( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_draw_buffers) return;
+ glad_glDrawBuffersEXT = (PFNGLDRAWBUFFERSEXTPROC) load(userptr, "glDrawBuffersEXT");
+}
+static void glad_gl_load_GL_EXT_draw_buffers_indexed( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_draw_buffers_indexed) return;
+ glad_glBlendEquationSeparateiEXT = (PFNGLBLENDEQUATIONSEPARATEIEXTPROC) load(userptr, "glBlendEquationSeparateiEXT");
+ glad_glBlendEquationiEXT = (PFNGLBLENDEQUATIONIEXTPROC) load(userptr, "glBlendEquationiEXT");
+ glad_glBlendFuncSeparateiEXT = (PFNGLBLENDFUNCSEPARATEIEXTPROC) load(userptr, "glBlendFuncSeparateiEXT");
+ glad_glBlendFunciEXT = (PFNGLBLENDFUNCIEXTPROC) load(userptr, "glBlendFunciEXT");
+ glad_glColorMaskiEXT = (PFNGLCOLORMASKIEXTPROC) load(userptr, "glColorMaskiEXT");
+ glad_glDisableiEXT = (PFNGLDISABLEIEXTPROC) load(userptr, "glDisableiEXT");
+ glad_glEnableiEXT = (PFNGLENABLEIEXTPROC) load(userptr, "glEnableiEXT");
+ glad_glIsEnablediEXT = (PFNGLISENABLEDIEXTPROC) load(userptr, "glIsEnablediEXT");
+}
+static void glad_gl_load_GL_EXT_draw_elements_base_vertex( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_draw_elements_base_vertex) return;
+ glad_glDrawElementsBaseVertexEXT = (PFNGLDRAWELEMENTSBASEVERTEXEXTPROC) load(userptr, "glDrawElementsBaseVertexEXT");
+ glad_glDrawElementsInstancedBaseVertexEXT = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC) load(userptr, "glDrawElementsInstancedBaseVertexEXT");
+ glad_glDrawRangeElementsBaseVertexEXT = (PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC) load(userptr, "glDrawRangeElementsBaseVertexEXT");
+ glad_glMultiDrawElementsBaseVertexEXT = (PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC) load(userptr, "glMultiDrawElementsBaseVertexEXT");
+}
+static void glad_gl_load_GL_EXT_draw_instanced( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_draw_instanced) return;
+ glad_glDrawArraysInstancedEXT = (PFNGLDRAWARRAYSINSTANCEDEXTPROC) load(userptr, "glDrawArraysInstancedEXT");
+ glad_glDrawElementsInstancedEXT = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC) load(userptr, "glDrawElementsInstancedEXT");
+}
+static void glad_gl_load_GL_EXT_draw_transform_feedback( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_draw_transform_feedback) return;
+ glad_glDrawTransformFeedbackEXT = (PFNGLDRAWTRANSFORMFEEDBACKEXTPROC) load(userptr, "glDrawTransformFeedbackEXT");
+ glad_glDrawTransformFeedbackInstancedEXT = (PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC) load(userptr, "glDrawTransformFeedbackInstancedEXT");
+}
+static void glad_gl_load_GL_EXT_external_buffer( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_external_buffer) return;
+ glad_glBufferStorageExternalEXT = (PFNGLBUFFERSTORAGEEXTERNALEXTPROC) load(userptr, "glBufferStorageExternalEXT");
+ glad_glNamedBufferStorageExternalEXT = (PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) load(userptr, "glNamedBufferStorageExternalEXT");
+}
+static void glad_gl_load_GL_EXT_fragment_shading_rate( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_fragment_shading_rate) return;
+ glad_glFramebufferShadingRateEXT = (PFNGLFRAMEBUFFERSHADINGRATEEXTPROC) load(userptr, "glFramebufferShadingRateEXT");
+ glad_glGetFragmentShadingRatesEXT = (PFNGLGETFRAGMENTSHADINGRATESEXTPROC) load(userptr, "glGetFragmentShadingRatesEXT");
+ glad_glShadingRateCombinerOpsEXT = (PFNGLSHADINGRATECOMBINEROPSEXTPROC) load(userptr, "glShadingRateCombinerOpsEXT");
+ glad_glShadingRateEXT = (PFNGLSHADINGRATEEXTPROC) load(userptr, "glShadingRateEXT");
+}
+static void glad_gl_load_GL_EXT_geometry_shader( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_geometry_shader) return;
+ glad_glFramebufferTextureEXT = (PFNGLFRAMEBUFFERTEXTUREEXTPROC) load(userptr, "glFramebufferTextureEXT");
+}
+static void glad_gl_load_GL_EXT_instanced_arrays( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_instanced_arrays) return;
+ glad_glDrawArraysInstancedEXT = (PFNGLDRAWARRAYSINSTANCEDEXTPROC) load(userptr, "glDrawArraysInstancedEXT");
+ glad_glDrawElementsInstancedEXT = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC) load(userptr, "glDrawElementsInstancedEXT");
+ glad_glVertexAttribDivisorEXT = (PFNGLVERTEXATTRIBDIVISOREXTPROC) load(userptr, "glVertexAttribDivisorEXT");
+}
+static void glad_gl_load_GL_EXT_map_buffer_range( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_map_buffer_range) return;
+ glad_glFlushMappedBufferRangeEXT = (PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) load(userptr, "glFlushMappedBufferRangeEXT");
+ glad_glMapBufferRangeEXT = (PFNGLMAPBUFFERRANGEEXTPROC) load(userptr, "glMapBufferRangeEXT");
+}
+static void glad_gl_load_GL_EXT_memory_object( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_memory_object) return;
+ glad_glBufferStorageMemEXT = (PFNGLBUFFERSTORAGEMEMEXTPROC) load(userptr, "glBufferStorageMemEXT");
+ glad_glCreateMemoryObjectsEXT = (PFNGLCREATEMEMORYOBJECTSEXTPROC) load(userptr, "glCreateMemoryObjectsEXT");
+ glad_glDeleteMemoryObjectsEXT = (PFNGLDELETEMEMORYOBJECTSEXTPROC) load(userptr, "glDeleteMemoryObjectsEXT");
+ glad_glGetMemoryObjectParameterivEXT = (PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) load(userptr, "glGetMemoryObjectParameterivEXT");
+ glad_glGetUnsignedBytei_vEXT = (PFNGLGETUNSIGNEDBYTEI_VEXTPROC) load(userptr, "glGetUnsignedBytei_vEXT");
+ glad_glGetUnsignedBytevEXT = (PFNGLGETUNSIGNEDBYTEVEXTPROC) load(userptr, "glGetUnsignedBytevEXT");
+ glad_glIsMemoryObjectEXT = (PFNGLISMEMORYOBJECTEXTPROC) load(userptr, "glIsMemoryObjectEXT");
+ glad_glMemoryObjectParameterivEXT = (PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) load(userptr, "glMemoryObjectParameterivEXT");
+ glad_glNamedBufferStorageMemEXT = (PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) load(userptr, "glNamedBufferStorageMemEXT");
+ glad_glTexStorageMem2DEXT = (PFNGLTEXSTORAGEMEM2DEXTPROC) load(userptr, "glTexStorageMem2DEXT");
+ glad_glTexStorageMem2DMultisampleEXT = (PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) load(userptr, "glTexStorageMem2DMultisampleEXT");
+ glad_glTexStorageMem3DEXT = (PFNGLTEXSTORAGEMEM3DEXTPROC) load(userptr, "glTexStorageMem3DEXT");
+ glad_glTexStorageMem3DMultisampleEXT = (PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) load(userptr, "glTexStorageMem3DMultisampleEXT");
+ glad_glTextureStorageMem2DEXT = (PFNGLTEXTURESTORAGEMEM2DEXTPROC) load(userptr, "glTextureStorageMem2DEXT");
+ glad_glTextureStorageMem2DMultisampleEXT = (PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) load(userptr, "glTextureStorageMem2DMultisampleEXT");
+ glad_glTextureStorageMem3DEXT = (PFNGLTEXTURESTORAGEMEM3DEXTPROC) load(userptr, "glTextureStorageMem3DEXT");
+ glad_glTextureStorageMem3DMultisampleEXT = (PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) load(userptr, "glTextureStorageMem3DMultisampleEXT");
+}
+static void glad_gl_load_GL_EXT_memory_object_fd( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_memory_object_fd) return;
+ glad_glImportMemoryFdEXT = (PFNGLIMPORTMEMORYFDEXTPROC) load(userptr, "glImportMemoryFdEXT");
+}
+static void glad_gl_load_GL_EXT_memory_object_win32( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_memory_object_win32) return;
+ glad_glImportMemoryWin32HandleEXT = (PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) load(userptr, "glImportMemoryWin32HandleEXT");
+ glad_glImportMemoryWin32NameEXT = (PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) load(userptr, "glImportMemoryWin32NameEXT");
+}
+static void glad_gl_load_GL_EXT_multi_draw_arrays( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_multi_draw_arrays) return;
+ glad_glMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC) load(userptr, "glMultiDrawArraysEXT");
+ glad_glMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC) load(userptr, "glMultiDrawElementsEXT");
+}
+static void glad_gl_load_GL_EXT_multi_draw_indirect( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_multi_draw_indirect) return;
+ glad_glMultiDrawArraysIndirectEXT = (PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC) load(userptr, "glMultiDrawArraysIndirectEXT");
+ glad_glMultiDrawElementsIndirectEXT = (PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC) load(userptr, "glMultiDrawElementsIndirectEXT");
+}
+static void glad_gl_load_GL_EXT_multisampled_render_to_texture( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_multisampled_render_to_texture) return;
+ glad_glFramebufferTexture2DMultisampleEXT = (PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) load(userptr, "glFramebufferTexture2DMultisampleEXT");
+ glad_glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) load(userptr, "glRenderbufferStorageMultisampleEXT");
+}
+static void glad_gl_load_GL_EXT_multiview_draw_buffers( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_multiview_draw_buffers) return;
+ glad_glDrawBuffersIndexedEXT = (PFNGLDRAWBUFFERSINDEXEDEXTPROC) load(userptr, "glDrawBuffersIndexedEXT");
+ glad_glGetIntegeri_vEXT = (PFNGLGETINTEGERI_VEXTPROC) load(userptr, "glGetIntegeri_vEXT");
+ glad_glReadBufferIndexedEXT = (PFNGLREADBUFFERINDEXEDEXTPROC) load(userptr, "glReadBufferIndexedEXT");
+}
+static void glad_gl_load_GL_EXT_occlusion_query_boolean( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_occlusion_query_boolean) return;
+ glad_glBeginQueryEXT = (PFNGLBEGINQUERYEXTPROC) load(userptr, "glBeginQueryEXT");
+ glad_glDeleteQueriesEXT = (PFNGLDELETEQUERIESEXTPROC) load(userptr, "glDeleteQueriesEXT");
+ glad_glEndQueryEXT = (PFNGLENDQUERYEXTPROC) load(userptr, "glEndQueryEXT");
+ glad_glGenQueriesEXT = (PFNGLGENQUERIESEXTPROC) load(userptr, "glGenQueriesEXT");
+ glad_glGetQueryObjectuivEXT = (PFNGLGETQUERYOBJECTUIVEXTPROC) load(userptr, "glGetQueryObjectuivEXT");
+ glad_glGetQueryivEXT = (PFNGLGETQUERYIVEXTPROC) load(userptr, "glGetQueryivEXT");
+ glad_glIsQueryEXT = (PFNGLISQUERYEXTPROC) load(userptr, "glIsQueryEXT");
+}
+static void glad_gl_load_GL_EXT_polygon_offset_clamp( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_polygon_offset_clamp) return;
+ glad_glPolygonOffsetClampEXT = (PFNGLPOLYGONOFFSETCLAMPEXTPROC) load(userptr, "glPolygonOffsetClampEXT");
+}
+static void glad_gl_load_GL_EXT_primitive_bounding_box( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_primitive_bounding_box) return;
+ glad_glPrimitiveBoundingBoxEXT = (PFNGLPRIMITIVEBOUNDINGBOXEXTPROC) load(userptr, "glPrimitiveBoundingBoxEXT");
+}
+static void glad_gl_load_GL_EXT_raster_multisample( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_raster_multisample) return;
+ glad_glRasterSamplesEXT = (PFNGLRASTERSAMPLESEXTPROC) load(userptr, "glRasterSamplesEXT");
+}
+static void glad_gl_load_GL_EXT_robustness( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_robustness) return;
+ glad_glGetGraphicsResetStatusEXT = (PFNGLGETGRAPHICSRESETSTATUSEXTPROC) load(userptr, "glGetGraphicsResetStatusEXT");
+ glad_glGetnUniformfvEXT = (PFNGLGETNUNIFORMFVEXTPROC) load(userptr, "glGetnUniformfvEXT");
+ glad_glGetnUniformivEXT = (PFNGLGETNUNIFORMIVEXTPROC) load(userptr, "glGetnUniformivEXT");
+ glad_glReadnPixelsEXT = (PFNGLREADNPIXELSEXTPROC) load(userptr, "glReadnPixelsEXT");
+}
+static void glad_gl_load_GL_EXT_semaphore( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_semaphore) return;
+ glad_glDeleteSemaphoresEXT = (PFNGLDELETESEMAPHORESEXTPROC) load(userptr, "glDeleteSemaphoresEXT");
+ glad_glGenSemaphoresEXT = (PFNGLGENSEMAPHORESEXTPROC) load(userptr, "glGenSemaphoresEXT");
+ glad_glGetSemaphoreParameterui64vEXT = (PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) load(userptr, "glGetSemaphoreParameterui64vEXT");
+ glad_glGetUnsignedBytei_vEXT = (PFNGLGETUNSIGNEDBYTEI_VEXTPROC) load(userptr, "glGetUnsignedBytei_vEXT");
+ glad_glGetUnsignedBytevEXT = (PFNGLGETUNSIGNEDBYTEVEXTPROC) load(userptr, "glGetUnsignedBytevEXT");
+ glad_glIsSemaphoreEXT = (PFNGLISSEMAPHOREEXTPROC) load(userptr, "glIsSemaphoreEXT");
+ glad_glSemaphoreParameterui64vEXT = (PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) load(userptr, "glSemaphoreParameterui64vEXT");
+ glad_glSignalSemaphoreEXT = (PFNGLSIGNALSEMAPHOREEXTPROC) load(userptr, "glSignalSemaphoreEXT");
+ glad_glWaitSemaphoreEXT = (PFNGLWAITSEMAPHOREEXTPROC) load(userptr, "glWaitSemaphoreEXT");
+}
+static void glad_gl_load_GL_EXT_semaphore_fd( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_semaphore_fd) return;
+ glad_glImportSemaphoreFdEXT = (PFNGLIMPORTSEMAPHOREFDEXTPROC) load(userptr, "glImportSemaphoreFdEXT");
+}
+static void glad_gl_load_GL_EXT_semaphore_win32( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_semaphore_win32) return;
+ glad_glImportSemaphoreWin32HandleEXT = (PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) load(userptr, "glImportSemaphoreWin32HandleEXT");
+ glad_glImportSemaphoreWin32NameEXT = (PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) load(userptr, "glImportSemaphoreWin32NameEXT");
+}
+static void glad_gl_load_GL_EXT_separate_shader_objects( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_separate_shader_objects) return;
+ glad_glActiveShaderProgramEXT = (PFNGLACTIVESHADERPROGRAMEXTPROC) load(userptr, "glActiveShaderProgramEXT");
+ glad_glBindProgramPipelineEXT = (PFNGLBINDPROGRAMPIPELINEEXTPROC) load(userptr, "glBindProgramPipelineEXT");
+ glad_glCreateShaderProgramvEXT = (PFNGLCREATESHADERPROGRAMVEXTPROC) load(userptr, "glCreateShaderProgramvEXT");
+ glad_glDeleteProgramPipelinesEXT = (PFNGLDELETEPROGRAMPIPELINESEXTPROC) load(userptr, "glDeleteProgramPipelinesEXT");
+ glad_glGenProgramPipelinesEXT = (PFNGLGENPROGRAMPIPELINESEXTPROC) load(userptr, "glGenProgramPipelinesEXT");
+ glad_glGetProgramPipelineInfoLogEXT = (PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) load(userptr, "glGetProgramPipelineInfoLogEXT");
+ glad_glGetProgramPipelineivEXT = (PFNGLGETPROGRAMPIPELINEIVEXTPROC) load(userptr, "glGetProgramPipelineivEXT");
+ glad_glIsProgramPipelineEXT = (PFNGLISPROGRAMPIPELINEEXTPROC) load(userptr, "glIsProgramPipelineEXT");
+ glad_glProgramParameteriEXT = (PFNGLPROGRAMPARAMETERIEXTPROC) load(userptr, "glProgramParameteriEXT");
+ glad_glProgramUniform1fEXT = (PFNGLPROGRAMUNIFORM1FEXTPROC) load(userptr, "glProgramUniform1fEXT");
+ glad_glProgramUniform1fvEXT = (PFNGLPROGRAMUNIFORM1FVEXTPROC) load(userptr, "glProgramUniform1fvEXT");
+ glad_glProgramUniform1iEXT = (PFNGLPROGRAMUNIFORM1IEXTPROC) load(userptr, "glProgramUniform1iEXT");
+ glad_glProgramUniform1ivEXT = (PFNGLPROGRAMUNIFORM1IVEXTPROC) load(userptr, "glProgramUniform1ivEXT");
+ glad_glProgramUniform1uiEXT = (PFNGLPROGRAMUNIFORM1UIEXTPROC) load(userptr, "glProgramUniform1uiEXT");
+ glad_glProgramUniform1uivEXT = (PFNGLPROGRAMUNIFORM1UIVEXTPROC) load(userptr, "glProgramUniform1uivEXT");
+ glad_glProgramUniform2fEXT = (PFNGLPROGRAMUNIFORM2FEXTPROC) load(userptr, "glProgramUniform2fEXT");
+ glad_glProgramUniform2fvEXT = (PFNGLPROGRAMUNIFORM2FVEXTPROC) load(userptr, "glProgramUniform2fvEXT");
+ glad_glProgramUniform2iEXT = (PFNGLPROGRAMUNIFORM2IEXTPROC) load(userptr, "glProgramUniform2iEXT");
+ glad_glProgramUniform2ivEXT = (PFNGLPROGRAMUNIFORM2IVEXTPROC) load(userptr, "glProgramUniform2ivEXT");
+ glad_glProgramUniform2uiEXT = (PFNGLPROGRAMUNIFORM2UIEXTPROC) load(userptr, "glProgramUniform2uiEXT");
+ glad_glProgramUniform2uivEXT = (PFNGLPROGRAMUNIFORM2UIVEXTPROC) load(userptr, "glProgramUniform2uivEXT");
+ glad_glProgramUniform3fEXT = (PFNGLPROGRAMUNIFORM3FEXTPROC) load(userptr, "glProgramUniform3fEXT");
+ glad_glProgramUniform3fvEXT = (PFNGLPROGRAMUNIFORM3FVEXTPROC) load(userptr, "glProgramUniform3fvEXT");
+ glad_glProgramUniform3iEXT = (PFNGLPROGRAMUNIFORM3IEXTPROC) load(userptr, "glProgramUniform3iEXT");
+ glad_glProgramUniform3ivEXT = (PFNGLPROGRAMUNIFORM3IVEXTPROC) load(userptr, "glProgramUniform3ivEXT");
+ glad_glProgramUniform3uiEXT = (PFNGLPROGRAMUNIFORM3UIEXTPROC) load(userptr, "glProgramUniform3uiEXT");
+ glad_glProgramUniform3uivEXT = (PFNGLPROGRAMUNIFORM3UIVEXTPROC) load(userptr, "glProgramUniform3uivEXT");
+ glad_glProgramUniform4fEXT = (PFNGLPROGRAMUNIFORM4FEXTPROC) load(userptr, "glProgramUniform4fEXT");
+ glad_glProgramUniform4fvEXT = (PFNGLPROGRAMUNIFORM4FVEXTPROC) load(userptr, "glProgramUniform4fvEXT");
+ glad_glProgramUniform4iEXT = (PFNGLPROGRAMUNIFORM4IEXTPROC) load(userptr, "glProgramUniform4iEXT");
+ glad_glProgramUniform4ivEXT = (PFNGLPROGRAMUNIFORM4IVEXTPROC) load(userptr, "glProgramUniform4ivEXT");
+ glad_glProgramUniform4uiEXT = (PFNGLPROGRAMUNIFORM4UIEXTPROC) load(userptr, "glProgramUniform4uiEXT");
+ glad_glProgramUniform4uivEXT = (PFNGLPROGRAMUNIFORM4UIVEXTPROC) load(userptr, "glProgramUniform4uivEXT");
+ glad_glProgramUniformMatrix2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) load(userptr, "glProgramUniformMatrix2fvEXT");
+ glad_glProgramUniformMatrix2x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) load(userptr, "glProgramUniformMatrix2x3fvEXT");
+ glad_glProgramUniformMatrix2x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) load(userptr, "glProgramUniformMatrix2x4fvEXT");
+ glad_glProgramUniformMatrix3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) load(userptr, "glProgramUniformMatrix3fvEXT");
+ glad_glProgramUniformMatrix3x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) load(userptr, "glProgramUniformMatrix3x2fvEXT");
+ glad_glProgramUniformMatrix3x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) load(userptr, "glProgramUniformMatrix3x4fvEXT");
+ glad_glProgramUniformMatrix4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) load(userptr, "glProgramUniformMatrix4fvEXT");
+ glad_glProgramUniformMatrix4x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) load(userptr, "glProgramUniformMatrix4x2fvEXT");
+ glad_glProgramUniformMatrix4x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) load(userptr, "glProgramUniformMatrix4x3fvEXT");
+ glad_glUseProgramStagesEXT = (PFNGLUSEPROGRAMSTAGESEXTPROC) load(userptr, "glUseProgramStagesEXT");
+ glad_glValidateProgramPipelineEXT = (PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) load(userptr, "glValidateProgramPipelineEXT");
+}
+static void glad_gl_load_GL_EXT_shader_framebuffer_fetch_non_coherent( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_shader_framebuffer_fetch_non_coherent) return;
+ glad_glFramebufferFetchBarrierEXT = (PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) load(userptr, "glFramebufferFetchBarrierEXT");
+}
+static void glad_gl_load_GL_EXT_shader_pixel_local_storage2( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_shader_pixel_local_storage2) return;
+ glad_glClearPixelLocalStorageuiEXT = (PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC) load(userptr, "glClearPixelLocalStorageuiEXT");
+ glad_glFramebufferPixelLocalStorageSizeEXT = (PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) load(userptr, "glFramebufferPixelLocalStorageSizeEXT");
+ glad_glGetFramebufferPixelLocalStorageSizeEXT = (PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) load(userptr, "glGetFramebufferPixelLocalStorageSizeEXT");
+}
+static void glad_gl_load_GL_EXT_sparse_texture( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_sparse_texture) return;
+ glad_glTexPageCommitmentEXT = (PFNGLTEXPAGECOMMITMENTEXTPROC) load(userptr, "glTexPageCommitmentEXT");
+}
+static void glad_gl_load_GL_EXT_tessellation_shader( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_tessellation_shader) return;
+ glad_glPatchParameteriEXT = (PFNGLPATCHPARAMETERIEXTPROC) load(userptr, "glPatchParameteriEXT");
+}
+static void glad_gl_load_GL_EXT_texture_border_clamp( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_texture_border_clamp) return;
+ glad_glGetSamplerParameterIivEXT = (PFNGLGETSAMPLERPARAMETERIIVEXTPROC) load(userptr, "glGetSamplerParameterIivEXT");
+ glad_glGetSamplerParameterIuivEXT = (PFNGLGETSAMPLERPARAMETERIUIVEXTPROC) load(userptr, "glGetSamplerParameterIuivEXT");
+ glad_glGetTexParameterIivEXT = (PFNGLGETTEXPARAMETERIIVEXTPROC) load(userptr, "glGetTexParameterIivEXT");
+ glad_glGetTexParameterIuivEXT = (PFNGLGETTEXPARAMETERIUIVEXTPROC) load(userptr, "glGetTexParameterIuivEXT");
+ glad_glSamplerParameterIivEXT = (PFNGLSAMPLERPARAMETERIIVEXTPROC) load(userptr, "glSamplerParameterIivEXT");
+ glad_glSamplerParameterIuivEXT = (PFNGLSAMPLERPARAMETERIUIVEXTPROC) load(userptr, "glSamplerParameterIuivEXT");
+ glad_glTexParameterIivEXT = (PFNGLTEXPARAMETERIIVEXTPROC) load(userptr, "glTexParameterIivEXT");
+ glad_glTexParameterIuivEXT = (PFNGLTEXPARAMETERIUIVEXTPROC) load(userptr, "glTexParameterIuivEXT");
+}
+static void glad_gl_load_GL_EXT_texture_buffer( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_texture_buffer) return;
+ glad_glTexBufferEXT = (PFNGLTEXBUFFEREXTPROC) load(userptr, "glTexBufferEXT");
+ glad_glTexBufferRangeEXT = (PFNGLTEXBUFFERRANGEEXTPROC) load(userptr, "glTexBufferRangeEXT");
+}
+static void glad_gl_load_GL_EXT_texture_storage( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_texture_storage) return;
+ glad_glTexStorage1DEXT = (PFNGLTEXSTORAGE1DEXTPROC) load(userptr, "glTexStorage1DEXT");
+ glad_glTexStorage2DEXT = (PFNGLTEXSTORAGE2DEXTPROC) load(userptr, "glTexStorage2DEXT");
+ glad_glTexStorage3DEXT = (PFNGLTEXSTORAGE3DEXTPROC) load(userptr, "glTexStorage3DEXT");
+ glad_glTextureStorage1DEXT = (PFNGLTEXTURESTORAGE1DEXTPROC) load(userptr, "glTextureStorage1DEXT");
+ glad_glTextureStorage2DEXT = (PFNGLTEXTURESTORAGE2DEXTPROC) load(userptr, "glTextureStorage2DEXT");
+ glad_glTextureStorage3DEXT = (PFNGLTEXTURESTORAGE3DEXTPROC) load(userptr, "glTextureStorage3DEXT");
+}
+static void glad_gl_load_GL_EXT_texture_storage_compression( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_texture_storage_compression) return;
+ glad_glTexStorageAttribs2DEXT = (PFNGLTEXSTORAGEATTRIBS2DEXTPROC) load(userptr, "glTexStorageAttribs2DEXT");
+ glad_glTexStorageAttribs3DEXT = (PFNGLTEXSTORAGEATTRIBS3DEXTPROC) load(userptr, "glTexStorageAttribs3DEXT");
+}
+static void glad_gl_load_GL_EXT_texture_view( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_texture_view) return;
+ glad_glTextureViewEXT = (PFNGLTEXTUREVIEWEXTPROC) load(userptr, "glTextureViewEXT");
+}
+static void glad_gl_load_GL_EXT_win32_keyed_mutex( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_win32_keyed_mutex) return;
+ glad_glAcquireKeyedMutexWin32EXT = (PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) load(userptr, "glAcquireKeyedMutexWin32EXT");
+ glad_glReleaseKeyedMutexWin32EXT = (PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) load(userptr, "glReleaseKeyedMutexWin32EXT");
+}
+static void glad_gl_load_GL_EXT_window_rectangles( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_EXT_window_rectangles) return;
+ glad_glWindowRectanglesEXT = (PFNGLWINDOWRECTANGLESEXTPROC) load(userptr, "glWindowRectanglesEXT");
+}
+static void glad_gl_load_GL_KHR_blend_equation_advanced( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_KHR_blend_equation_advanced) return;
+ glad_glBlendBarrierKHR = (PFNGLBLENDBARRIERKHRPROC) load(userptr, "glBlendBarrierKHR");
+}
+static void glad_gl_load_GL_KHR_debug( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_KHR_debug) return;
+ glad_glDebugMessageCallbackKHR = (PFNGLDEBUGMESSAGECALLBACKKHRPROC) load(userptr, "glDebugMessageCallbackKHR");
+ glad_glDebugMessageControlKHR = (PFNGLDEBUGMESSAGECONTROLKHRPROC) load(userptr, "glDebugMessageControlKHR");
+ glad_glDebugMessageInsertKHR = (PFNGLDEBUGMESSAGEINSERTKHRPROC) load(userptr, "glDebugMessageInsertKHR");
+ glad_glGetDebugMessageLogKHR = (PFNGLGETDEBUGMESSAGELOGKHRPROC) load(userptr, "glGetDebugMessageLogKHR");
+ glad_glGetObjectLabelKHR = (PFNGLGETOBJECTLABELKHRPROC) load(userptr, "glGetObjectLabelKHR");
+ glad_glGetObjectPtrLabelKHR = (PFNGLGETOBJECTPTRLABELKHRPROC) load(userptr, "glGetObjectPtrLabelKHR");
+ glad_glGetPointervKHR = (PFNGLGETPOINTERVKHRPROC) load(userptr, "glGetPointervKHR");
+ glad_glObjectLabelKHR = (PFNGLOBJECTLABELKHRPROC) load(userptr, "glObjectLabelKHR");
+ glad_glObjectPtrLabelKHR = (PFNGLOBJECTPTRLABELKHRPROC) load(userptr, "glObjectPtrLabelKHR");
+ glad_glPopDebugGroupKHR = (PFNGLPOPDEBUGGROUPKHRPROC) load(userptr, "glPopDebugGroupKHR");
+ glad_glPushDebugGroupKHR = (PFNGLPUSHDEBUGGROUPKHRPROC) load(userptr, "glPushDebugGroupKHR");
+}
+static void glad_gl_load_GL_KHR_parallel_shader_compile( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_KHR_parallel_shader_compile) return;
+ glad_glMaxShaderCompilerThreadsKHR = (PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) load(userptr, "glMaxShaderCompilerThreadsKHR");
+}
+static void glad_gl_load_GL_KHR_robustness( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_KHR_robustness) return;
+ glad_glGetGraphicsResetStatusKHR = (PFNGLGETGRAPHICSRESETSTATUSKHRPROC) load(userptr, "glGetGraphicsResetStatusKHR");
+ glad_glGetnUniformfvKHR = (PFNGLGETNUNIFORMFVKHRPROC) load(userptr, "glGetnUniformfvKHR");
+ glad_glGetnUniformivKHR = (PFNGLGETNUNIFORMIVKHRPROC) load(userptr, "glGetnUniformivKHR");
+ glad_glGetnUniformuivKHR = (PFNGLGETNUNIFORMUIVKHRPROC) load(userptr, "glGetnUniformuivKHR");
+ glad_glReadnPixelsKHR = (PFNGLREADNPIXELSKHRPROC) load(userptr, "glReadnPixelsKHR");
+}
+static void glad_gl_load_GL_OES_EGL_image( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_EGL_image) return;
+ glad_glEGLImageTargetRenderbufferStorageOES = (PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) load(userptr, "glEGLImageTargetRenderbufferStorageOES");
+ glad_glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) load(userptr, "glEGLImageTargetTexture2DOES");
+}
+static void glad_gl_load_GL_OES_copy_image( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_copy_image) return;
+ glad_glCopyImageSubDataOES = (PFNGLCOPYIMAGESUBDATAOESPROC) load(userptr, "glCopyImageSubDataOES");
+}
+static void glad_gl_load_GL_OES_draw_buffers_indexed( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_draw_buffers_indexed) return;
+ glad_glBlendEquationSeparateiOES = (PFNGLBLENDEQUATIONSEPARATEIOESPROC) load(userptr, "glBlendEquationSeparateiOES");
+ glad_glBlendEquationiOES = (PFNGLBLENDEQUATIONIOESPROC) load(userptr, "glBlendEquationiOES");
+ glad_glBlendFuncSeparateiOES = (PFNGLBLENDFUNCSEPARATEIOESPROC) load(userptr, "glBlendFuncSeparateiOES");
+ glad_glBlendFunciOES = (PFNGLBLENDFUNCIOESPROC) load(userptr, "glBlendFunciOES");
+ glad_glColorMaskiOES = (PFNGLCOLORMASKIOESPROC) load(userptr, "glColorMaskiOES");
+ glad_glDisableiOES = (PFNGLDISABLEIOESPROC) load(userptr, "glDisableiOES");
+ glad_glEnableiOES = (PFNGLENABLEIOESPROC) load(userptr, "glEnableiOES");
+ glad_glIsEnablediOES = (PFNGLISENABLEDIOESPROC) load(userptr, "glIsEnablediOES");
+}
+static void glad_gl_load_GL_OES_draw_elements_base_vertex( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_draw_elements_base_vertex) return;
+ glad_glDrawElementsBaseVertexOES = (PFNGLDRAWELEMENTSBASEVERTEXOESPROC) load(userptr, "glDrawElementsBaseVertexOES");
+ glad_glDrawElementsInstancedBaseVertexOES = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC) load(userptr, "glDrawElementsInstancedBaseVertexOES");
+ glad_glDrawRangeElementsBaseVertexOES = (PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC) load(userptr, "glDrawRangeElementsBaseVertexOES");
+ glad_glMultiDrawElementsBaseVertexEXT = (PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC) load(userptr, "glMultiDrawElementsBaseVertexEXT");
+}
+static void glad_gl_load_GL_OES_geometry_shader( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_geometry_shader) return;
+ glad_glFramebufferTextureOES = (PFNGLFRAMEBUFFERTEXTUREOESPROC) load(userptr, "glFramebufferTextureOES");
+}
+static void glad_gl_load_GL_OES_get_program_binary( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_get_program_binary) return;
+ glad_glGetProgramBinaryOES = (PFNGLGETPROGRAMBINARYOESPROC) load(userptr, "glGetProgramBinaryOES");
+ glad_glProgramBinaryOES = (PFNGLPROGRAMBINARYOESPROC) load(userptr, "glProgramBinaryOES");
+}
+static void glad_gl_load_GL_OES_mapbuffer( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_mapbuffer) return;
+ glad_glGetBufferPointervOES = (PFNGLGETBUFFERPOINTERVOESPROC) load(userptr, "glGetBufferPointervOES");
+ glad_glMapBufferOES = (PFNGLMAPBUFFEROESPROC) load(userptr, "glMapBufferOES");
+ glad_glUnmapBufferOES = (PFNGLUNMAPBUFFEROESPROC) load(userptr, "glUnmapBufferOES");
+}
+static void glad_gl_load_GL_OES_primitive_bounding_box( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_primitive_bounding_box) return;
+ glad_glPrimitiveBoundingBoxOES = (PFNGLPRIMITIVEBOUNDINGBOXOESPROC) load(userptr, "glPrimitiveBoundingBoxOES");
+}
+static void glad_gl_load_GL_OES_sample_shading( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_sample_shading) return;
+ glad_glMinSampleShadingOES = (PFNGLMINSAMPLESHADINGOESPROC) load(userptr, "glMinSampleShadingOES");
+}
+static void glad_gl_load_GL_OES_tessellation_shader( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_tessellation_shader) return;
+ glad_glPatchParameteriOES = (PFNGLPATCHPARAMETERIOESPROC) load(userptr, "glPatchParameteriOES");
+}
+static void glad_gl_load_GL_OES_texture_3D( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_texture_3D) return;
+ glad_glCompressedTexImage3DOES = (PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) load(userptr, "glCompressedTexImage3DOES");
+ glad_glCompressedTexSubImage3DOES = (PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) load(userptr, "glCompressedTexSubImage3DOES");
+ glad_glCopyTexSubImage3DOES = (PFNGLCOPYTEXSUBIMAGE3DOESPROC) load(userptr, "glCopyTexSubImage3DOES");
+ glad_glFramebufferTexture3DOES = (PFNGLFRAMEBUFFERTEXTURE3DOESPROC) load(userptr, "glFramebufferTexture3DOES");
+ glad_glTexImage3DOES = (PFNGLTEXIMAGE3DOESPROC) load(userptr, "glTexImage3DOES");
+ glad_glTexSubImage3DOES = (PFNGLTEXSUBIMAGE3DOESPROC) load(userptr, "glTexSubImage3DOES");
+}
+static void glad_gl_load_GL_OES_texture_border_clamp( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_texture_border_clamp) return;
+ glad_glGetSamplerParameterIivOES = (PFNGLGETSAMPLERPARAMETERIIVOESPROC) load(userptr, "glGetSamplerParameterIivOES");
+ glad_glGetSamplerParameterIuivOES = (PFNGLGETSAMPLERPARAMETERIUIVOESPROC) load(userptr, "glGetSamplerParameterIuivOES");
+ glad_glGetTexParameterIivOES = (PFNGLGETTEXPARAMETERIIVOESPROC) load(userptr, "glGetTexParameterIivOES");
+ glad_glGetTexParameterIuivOES = (PFNGLGETTEXPARAMETERIUIVOESPROC) load(userptr, "glGetTexParameterIuivOES");
+ glad_glSamplerParameterIivOES = (PFNGLSAMPLERPARAMETERIIVOESPROC) load(userptr, "glSamplerParameterIivOES");
+ glad_glSamplerParameterIuivOES = (PFNGLSAMPLERPARAMETERIUIVOESPROC) load(userptr, "glSamplerParameterIuivOES");
+ glad_glTexParameterIivOES = (PFNGLTEXPARAMETERIIVOESPROC) load(userptr, "glTexParameterIivOES");
+ glad_glTexParameterIuivOES = (PFNGLTEXPARAMETERIUIVOESPROC) load(userptr, "glTexParameterIuivOES");
+}
+static void glad_gl_load_GL_OES_texture_buffer( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_texture_buffer) return;
+ glad_glTexBufferOES = (PFNGLTEXBUFFEROESPROC) load(userptr, "glTexBufferOES");
+ glad_glTexBufferRangeOES = (PFNGLTEXBUFFERRANGEOESPROC) load(userptr, "glTexBufferRangeOES");
+}
+static void glad_gl_load_GL_OES_texture_storage_multisample_2d_array( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_texture_storage_multisample_2d_array) return;
+ glad_glTexStorage3DMultisampleOES = (PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC) load(userptr, "glTexStorage3DMultisampleOES");
+}
+static void glad_gl_load_GL_OES_texture_view( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_texture_view) return;
+ glad_glTextureViewOES = (PFNGLTEXTUREVIEWOESPROC) load(userptr, "glTextureViewOES");
+}
+static void glad_gl_load_GL_OES_vertex_array_object( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_vertex_array_object) return;
+ glad_glBindVertexArrayOES = (PFNGLBINDVERTEXARRAYOESPROC) load(userptr, "glBindVertexArrayOES");
+ glad_glDeleteVertexArraysOES = (PFNGLDELETEVERTEXARRAYSOESPROC) load(userptr, "glDeleteVertexArraysOES");
+ glad_glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC) load(userptr, "glGenVertexArraysOES");
+ glad_glIsVertexArrayOES = (PFNGLISVERTEXARRAYOESPROC) load(userptr, "glIsVertexArrayOES");
+}
+static void glad_gl_load_GL_OES_viewport_array( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_OES_viewport_array) return;
+ glad_glDepthRangeArrayfvOES = (PFNGLDEPTHRANGEARRAYFVOESPROC) load(userptr, "glDepthRangeArrayfvOES");
+ glad_glDepthRangeIndexedfOES = (PFNGLDEPTHRANGEINDEXEDFOESPROC) load(userptr, "glDepthRangeIndexedfOES");
+ glad_glDisableiOES = (PFNGLDISABLEIOESPROC) load(userptr, "glDisableiOES");
+ glad_glEnableiOES = (PFNGLENABLEIOESPROC) load(userptr, "glEnableiOES");
+ glad_glGetFloati_vOES = (PFNGLGETFLOATI_VOESPROC) load(userptr, "glGetFloati_vOES");
+ glad_glIsEnablediOES = (PFNGLISENABLEDIOESPROC) load(userptr, "glIsEnablediOES");
+ glad_glScissorArrayvOES = (PFNGLSCISSORARRAYVOESPROC) load(userptr, "glScissorArrayvOES");
+ glad_glScissorIndexedOES = (PFNGLSCISSORINDEXEDOESPROC) load(userptr, "glScissorIndexedOES");
+ glad_glScissorIndexedvOES = (PFNGLSCISSORINDEXEDVOESPROC) load(userptr, "glScissorIndexedvOES");
+ glad_glViewportArrayvOES = (PFNGLVIEWPORTARRAYVOESPROC) load(userptr, "glViewportArrayvOES");
+ glad_glViewportIndexedfOES = (PFNGLVIEWPORTINDEXEDFOESPROC) load(userptr, "glViewportIndexedfOES");
+ glad_glViewportIndexedfvOES = (PFNGLVIEWPORTINDEXEDFVOESPROC) load(userptr, "glViewportIndexedfvOES");
+}
+
+
+
+#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
+#define GLAD_GL_IS_SOME_NEW_VERSION 1
+#else
+#define GLAD_GL_IS_SOME_NEW_VERSION 0
+#endif
+
+static int glad_gl_get_extensions( int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) {
+#if GLAD_GL_IS_SOME_NEW_VERSION
+ if(GLAD_VERSION_MAJOR(version) < 3) {
+#else
+ GLAD_UNUSED(version);
+ GLAD_UNUSED(out_num_exts_i);
+ GLAD_UNUSED(out_exts_i);
+#endif
+ if (glad_glGetString == NULL) {
+ return 0;
+ }
+ *out_exts = (const char *)glad_glGetString(GL_EXTENSIONS);
+#if GLAD_GL_IS_SOME_NEW_VERSION
+ } else {
+ unsigned int index = 0;
+ unsigned int num_exts_i = 0;
+ char **exts_i = NULL;
+ if (glad_glGetStringi == NULL || glad_glGetIntegerv == NULL) {
+ return 0;
+ }
+ glad_glGetIntegerv(GL_NUM_EXTENSIONS, (int*) &num_exts_i);
+ if (num_exts_i > 0) {
+ exts_i = (char **) malloc(num_exts_i * (sizeof *exts_i));
+ }
+ if (exts_i == NULL) {
+ return 0;
+ }
+ for(index = 0; index < num_exts_i; index++) {
+ const char *gl_str_tmp = (const char*) glad_glGetStringi(GL_EXTENSIONS, index);
+ size_t len = strlen(gl_str_tmp) + 1;
+
+ char *local_str = (char*) malloc(len * sizeof(char));
+ if(local_str != NULL) {
+ memcpy(local_str, gl_str_tmp, len * sizeof(char));
+ }
+
+ exts_i[index] = local_str;
+ }
+
+ *out_num_exts_i = num_exts_i;
+ *out_exts_i = exts_i;
+ }
+#endif
+ return 1;
+}
+static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) {
+ if (exts_i != NULL) {
+ unsigned int index;
+ for(index = 0; index < num_exts_i; index++) {
+ free((void *) (exts_i[index]));
+ }
+ free((void *)exts_i);
+ exts_i = NULL;
+ }
+}
+static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) {
+ if(GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) {
+ const char *extensions;
+ const char *loc;
+ const char *terminator;
+ extensions = exts;
+ if(extensions == NULL || ext == NULL) {
+ return 0;
+ }
+ while(1) {
+ loc = strstr(extensions, ext);
+ if(loc == NULL) {
+ return 0;
+ }
+ terminator = loc + strlen(ext);
+ if((loc == extensions || *(loc - 1) == ' ') &&
+ (*terminator == ' ' || *terminator == '\0')) {
+ return 1;
+ }
+ extensions = terminator;
+ }
+ } else {
+ unsigned int index;
+ for(index = 0; index < num_exts_i; index++) {
+ const char *e = exts_i[index];
+ if(strcmp(e, ext) == 0) {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+static GLADapiproc glad_gl_get_proc_from_userptr(void *userptr, const char* name) {
+ return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
+}
+
+static int glad_gl_find_extensions_gles2( int version) {
+ const char *exts = NULL;
+ unsigned int num_exts_i = 0;
+ char **exts_i = NULL;
+ if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0;
+
+ GLAD_GL_EXT_EGL_image_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_EGL_image_array");
+ GLAD_GL_EXT_EGL_image_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_EGL_image_storage");
+ GLAD_GL_EXT_EGL_image_storage_compression = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_EGL_image_storage_compression");
+ GLAD_GL_EXT_YUV_target = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_YUV_target");
+ GLAD_GL_EXT_base_instance = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_base_instance");
+ GLAD_GL_EXT_blend_func_extended = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_blend_func_extended");
+ GLAD_GL_EXT_blend_minmax = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_blend_minmax");
+ GLAD_GL_EXT_buffer_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_buffer_storage");
+ GLAD_GL_EXT_clear_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_clear_texture");
+ GLAD_GL_EXT_clip_control = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_clip_control");
+ GLAD_GL_EXT_clip_cull_distance = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_clip_cull_distance");
+ GLAD_GL_EXT_color_buffer_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_color_buffer_float");
+ GLAD_GL_EXT_color_buffer_half_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_color_buffer_half_float");
+ GLAD_GL_EXT_conservative_depth = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_conservative_depth");
+ GLAD_GL_EXT_copy_image = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_copy_image");
+ GLAD_GL_EXT_debug_label = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_debug_label");
+ GLAD_GL_EXT_debug_marker = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_debug_marker");
+ GLAD_GL_EXT_depth_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_depth_clamp");
+ GLAD_GL_EXT_discard_framebuffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_discard_framebuffer");
+ GLAD_GL_EXT_disjoint_timer_query = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_disjoint_timer_query");
+ GLAD_GL_EXT_draw_buffers = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_buffers");
+ GLAD_GL_EXT_draw_buffers_indexed = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_buffers_indexed");
+ GLAD_GL_EXT_draw_elements_base_vertex = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_elements_base_vertex");
+ GLAD_GL_EXT_draw_instanced = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_instanced");
+ GLAD_GL_EXT_draw_transform_feedback = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_draw_transform_feedback");
+ GLAD_GL_EXT_external_buffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_external_buffer");
+ GLAD_GL_EXT_float_blend = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_float_blend");
+ GLAD_GL_EXT_fragment_shading_rate = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_fragment_shading_rate");
+ GLAD_GL_EXT_geometry_point_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_geometry_point_size");
+ GLAD_GL_EXT_geometry_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_geometry_shader");
+ GLAD_GL_EXT_gpu_shader5 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_gpu_shader5");
+ GLAD_GL_EXT_instanced_arrays = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_instanced_arrays");
+ GLAD_GL_EXT_map_buffer_range = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_map_buffer_range");
+ GLAD_GL_EXT_memory_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_memory_object");
+ GLAD_GL_EXT_memory_object_fd = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_memory_object_fd");
+ GLAD_GL_EXT_memory_object_win32 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_memory_object_win32");
+ GLAD_GL_EXT_multi_draw_arrays = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multi_draw_arrays");
+ GLAD_GL_EXT_multi_draw_indirect = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multi_draw_indirect");
+ GLAD_GL_EXT_multisampled_compatibility = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multisampled_compatibility");
+ GLAD_GL_EXT_multisampled_render_to_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multisampled_render_to_texture");
+ GLAD_GL_EXT_multisampled_render_to_texture2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multisampled_render_to_texture2");
+ GLAD_GL_EXT_multiview_draw_buffers = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multiview_draw_buffers");
+ GLAD_GL_EXT_multiview_tessellation_geometry_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multiview_tessellation_geometry_shader");
+ GLAD_GL_EXT_multiview_texture_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multiview_texture_multisample");
+ GLAD_GL_EXT_multiview_timer_query = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_multiview_timer_query");
+ GLAD_GL_EXT_occlusion_query_boolean = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_occlusion_query_boolean");
+ GLAD_GL_EXT_polygon_offset_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_polygon_offset_clamp");
+ GLAD_GL_EXT_post_depth_coverage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_post_depth_coverage");
+ GLAD_GL_EXT_primitive_bounding_box = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_primitive_bounding_box");
+ GLAD_GL_EXT_protected_textures = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_protected_textures");
+ GLAD_GL_EXT_pvrtc_sRGB = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_pvrtc_sRGB");
+ GLAD_GL_EXT_raster_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_raster_multisample");
+ GLAD_GL_EXT_read_format_bgra = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_read_format_bgra");
+ GLAD_GL_EXT_render_snorm = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_render_snorm");
+ GLAD_GL_EXT_robustness = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_robustness");
+ GLAD_GL_EXT_sRGB = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_sRGB");
+ GLAD_GL_EXT_sRGB_write_control = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_sRGB_write_control");
+ GLAD_GL_EXT_semaphore = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_semaphore");
+ GLAD_GL_EXT_semaphore_fd = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_semaphore_fd");
+ GLAD_GL_EXT_semaphore_win32 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_semaphore_win32");
+ GLAD_GL_EXT_separate_depth_stencil = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_separate_depth_stencil");
+ GLAD_GL_EXT_separate_shader_objects = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_separate_shader_objects");
+ GLAD_GL_EXT_shader_framebuffer_fetch = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_framebuffer_fetch");
+ GLAD_GL_EXT_shader_framebuffer_fetch_non_coherent = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_framebuffer_fetch_non_coherent");
+ GLAD_GL_EXT_shader_group_vote = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_group_vote");
+ GLAD_GL_EXT_shader_implicit_conversions = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_implicit_conversions");
+ GLAD_GL_EXT_shader_integer_mix = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_integer_mix");
+ GLAD_GL_EXT_shader_io_blocks = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_io_blocks");
+ GLAD_GL_EXT_shader_non_constant_global_initializers = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_non_constant_global_initializers");
+ GLAD_GL_EXT_shader_pixel_local_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_pixel_local_storage");
+ GLAD_GL_EXT_shader_pixel_local_storage2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_pixel_local_storage2");
+ GLAD_GL_EXT_shader_samples_identical = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_samples_identical");
+ GLAD_GL_EXT_shader_texture_lod = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shader_texture_lod");
+ GLAD_GL_EXT_shadow_samplers = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_shadow_samplers");
+ GLAD_GL_EXT_sparse_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_sparse_texture");
+ GLAD_GL_EXT_sparse_texture2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_sparse_texture2");
+ GLAD_GL_EXT_tessellation_point_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_tessellation_point_size");
+ GLAD_GL_EXT_tessellation_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_tessellation_shader");
+ GLAD_GL_EXT_texture_border_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_border_clamp");
+ GLAD_GL_EXT_texture_buffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_buffer");
+ GLAD_GL_EXT_texture_compression_astc_decode_mode = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_astc_decode_mode");
+ GLAD_GL_EXT_texture_compression_bptc = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_bptc");
+ GLAD_GL_EXT_texture_compression_dxt1 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_dxt1");
+ GLAD_GL_EXT_texture_compression_rgtc = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_rgtc");
+ GLAD_GL_EXT_texture_compression_s3tc = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_s3tc");
+ GLAD_GL_EXT_texture_compression_s3tc_srgb = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_compression_s3tc_srgb");
+ GLAD_GL_EXT_texture_cube_map_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_cube_map_array");
+ GLAD_GL_EXT_texture_filter_anisotropic = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_filter_anisotropic");
+ GLAD_GL_EXT_texture_filter_minmax = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_filter_minmax");
+ GLAD_GL_EXT_texture_format_BGRA8888 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_format_BGRA8888");
+ GLAD_GL_EXT_texture_format_sRGB_override = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_format_sRGB_override");
+ GLAD_GL_EXT_texture_mirror_clamp_to_edge = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_mirror_clamp_to_edge");
+ GLAD_GL_EXT_texture_norm16 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_norm16");
+ GLAD_GL_EXT_texture_query_lod = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_query_lod");
+ GLAD_GL_EXT_texture_rg = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_rg");
+ GLAD_GL_EXT_texture_sRGB_R8 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_sRGB_R8");
+ GLAD_GL_EXT_texture_sRGB_RG8 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_sRGB_RG8");
+ GLAD_GL_EXT_texture_sRGB_decode = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_sRGB_decode");
+ GLAD_GL_EXT_texture_shadow_lod = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_shadow_lod");
+ GLAD_GL_EXT_texture_storage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_storage");
+ GLAD_GL_EXT_texture_storage_compression = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_storage_compression");
+ GLAD_GL_EXT_texture_type_2_10_10_10_REV = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_type_2_10_10_10_REV");
+ GLAD_GL_EXT_texture_view = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_texture_view");
+ GLAD_GL_EXT_unpack_subimage = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_unpack_subimage");
+ GLAD_GL_EXT_win32_keyed_mutex = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_win32_keyed_mutex");
+ GLAD_GL_EXT_window_rectangles = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_EXT_window_rectangles");
+ GLAD_GL_KHR_blend_equation_advanced = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_blend_equation_advanced");
+ GLAD_GL_KHR_blend_equation_advanced_coherent = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_blend_equation_advanced_coherent");
+ GLAD_GL_KHR_context_flush_control = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_context_flush_control");
+ GLAD_GL_KHR_debug = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_debug");
+ GLAD_GL_KHR_no_error = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_no_error");
+ GLAD_GL_KHR_parallel_shader_compile = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_parallel_shader_compile");
+ GLAD_GL_KHR_robust_buffer_access_behavior = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_robust_buffer_access_behavior");
+ GLAD_GL_KHR_robustness = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_robustness");
+ GLAD_GL_KHR_shader_subgroup = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_shader_subgroup");
+ GLAD_GL_KHR_texture_compression_astc_hdr = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_texture_compression_astc_hdr");
+ GLAD_GL_KHR_texture_compression_astc_ldr = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_texture_compression_astc_ldr");
+ GLAD_GL_KHR_texture_compression_astc_sliced_3d = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_texture_compression_astc_sliced_3d");
+ GLAD_GL_OES_EGL_image = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_EGL_image");
+ GLAD_GL_OES_EGL_image_external = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_EGL_image_external");
+ GLAD_GL_OES_EGL_image_external_essl3 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_EGL_image_external_essl3");
+ GLAD_GL_OES_compressed_ETC1_RGB8_sub_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_compressed_ETC1_RGB8_sub_texture");
+ GLAD_GL_OES_compressed_ETC1_RGB8_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_compressed_ETC1_RGB8_texture");
+ GLAD_GL_OES_compressed_paletted_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_compressed_paletted_texture");
+ GLAD_GL_OES_copy_image = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_copy_image");
+ GLAD_GL_OES_depth24 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_depth24");
+ GLAD_GL_OES_depth32 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_depth32");
+ GLAD_GL_OES_depth_texture = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_depth_texture");
+ GLAD_GL_OES_draw_buffers_indexed = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_draw_buffers_indexed");
+ GLAD_GL_OES_draw_elements_base_vertex = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_draw_elements_base_vertex");
+ GLAD_GL_OES_element_index_uint = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_element_index_uint");
+ GLAD_GL_OES_fbo_render_mipmap = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_fbo_render_mipmap");
+ GLAD_GL_OES_fragment_precision_high = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_fragment_precision_high");
+ GLAD_GL_OES_geometry_point_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_geometry_point_size");
+ GLAD_GL_OES_geometry_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_geometry_shader");
+ GLAD_GL_OES_get_program_binary = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_get_program_binary");
+ GLAD_GL_OES_gpu_shader5 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_gpu_shader5");
+ GLAD_GL_OES_mapbuffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_mapbuffer");
+ GLAD_GL_OES_packed_depth_stencil = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_packed_depth_stencil");
+ GLAD_GL_OES_primitive_bounding_box = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_primitive_bounding_box");
+ GLAD_GL_OES_required_internalformat = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_required_internalformat");
+ GLAD_GL_OES_rgb8_rgba8 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_rgb8_rgba8");
+ GLAD_GL_OES_sample_shading = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_sample_shading");
+ GLAD_GL_OES_sample_variables = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_sample_variables");
+ GLAD_GL_OES_shader_image_atomic = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_shader_image_atomic");
+ GLAD_GL_OES_shader_io_blocks = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_shader_io_blocks");
+ GLAD_GL_OES_shader_multisample_interpolation = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_shader_multisample_interpolation");
+ GLAD_GL_OES_standard_derivatives = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_standard_derivatives");
+ GLAD_GL_OES_stencil1 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_stencil1");
+ GLAD_GL_OES_stencil4 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_stencil4");
+ GLAD_GL_OES_surfaceless_context = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_surfaceless_context");
+ GLAD_GL_OES_tessellation_point_size = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_tessellation_point_size");
+ GLAD_GL_OES_tessellation_shader = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_tessellation_shader");
+ GLAD_GL_OES_texture_3D = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_3D");
+ GLAD_GL_OES_texture_border_clamp = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_border_clamp");
+ GLAD_GL_OES_texture_buffer = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_buffer");
+ GLAD_GL_OES_texture_compression_astc = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_compression_astc");
+ GLAD_GL_OES_texture_cube_map_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_cube_map_array");
+ GLAD_GL_OES_texture_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_float");
+ GLAD_GL_OES_texture_float_linear = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_float_linear");
+ GLAD_GL_OES_texture_half_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_half_float");
+ GLAD_GL_OES_texture_half_float_linear = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_half_float_linear");
+ GLAD_GL_OES_texture_npot = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_npot");
+ GLAD_GL_OES_texture_stencil8 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_stencil8");
+ GLAD_GL_OES_texture_storage_multisample_2d_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_storage_multisample_2d_array");
+ GLAD_GL_OES_texture_view = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_texture_view");
+ GLAD_GL_OES_vertex_array_object = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_vertex_array_object");
+ GLAD_GL_OES_vertex_half_float = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_vertex_half_float");
+ GLAD_GL_OES_vertex_type_10_10_10_2 = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_vertex_type_10_10_10_2");
+ GLAD_GL_OES_viewport_array = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_OES_viewport_array");
+
+ glad_gl_free_extensions(exts_i, num_exts_i);
+
+ return 1;
+}
+
+static int glad_gl_find_core_gles2(void) {
+ int i;
+ const char* version;
+ const char* prefixes[] = {
+ "OpenGL ES-CM ",
+ "OpenGL ES-CL ",
+ "OpenGL ES ",
+ "OpenGL SC ",
+ NULL
+ };
+ int major = 0;
+ int minor = 0;
+ version = (const char*) glad_glGetString(GL_VERSION);
+ if (!version) return 0;
+ for (i = 0; prefixes[i]; i++) {
+ const size_t length = strlen(prefixes[i]);
+ if (strncmp(version, prefixes[i], length) == 0) {
+ version += length;
+ break;
+ }
+ }
+
+ GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor);
+
+ GLAD_GL_ES_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;
+
+ return GLAD_MAKE_VERSION(major, minor);
+}
+
+int gladLoadGLES2UserPtr( GLADuserptrloadfunc load, void *userptr) {
+ int version;
+
+ glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
+ if(glad_glGetString == NULL) return 0;
+ if(glad_glGetString(GL_VERSION) == NULL) return 0;
+ version = glad_gl_find_core_gles2();
+
+ glad_gl_load_GL_ES_VERSION_2_0(load, userptr);
+
+ if (!glad_gl_find_extensions_gles2(version)) return 0;
+ glad_gl_load_GL_EXT_EGL_image_storage(load, userptr);
+ glad_gl_load_GL_EXT_base_instance(load, userptr);
+ glad_gl_load_GL_EXT_blend_func_extended(load, userptr);
+ glad_gl_load_GL_EXT_buffer_storage(load, userptr);
+ glad_gl_load_GL_EXT_clear_texture(load, userptr);
+ glad_gl_load_GL_EXT_clip_control(load, userptr);
+ glad_gl_load_GL_EXT_copy_image(load, userptr);
+ glad_gl_load_GL_EXT_debug_label(load, userptr);
+ glad_gl_load_GL_EXT_debug_marker(load, userptr);
+ glad_gl_load_GL_EXT_discard_framebuffer(load, userptr);
+ glad_gl_load_GL_EXT_disjoint_timer_query(load, userptr);
+ glad_gl_load_GL_EXT_draw_buffers(load, userptr);
+ glad_gl_load_GL_EXT_draw_buffers_indexed(load, userptr);
+ glad_gl_load_GL_EXT_draw_elements_base_vertex(load, userptr);
+ glad_gl_load_GL_EXT_draw_instanced(load, userptr);
+ glad_gl_load_GL_EXT_draw_transform_feedback(load, userptr);
+ glad_gl_load_GL_EXT_external_buffer(load, userptr);
+ glad_gl_load_GL_EXT_fragment_shading_rate(load, userptr);
+ glad_gl_load_GL_EXT_geometry_shader(load, userptr);
+ glad_gl_load_GL_EXT_instanced_arrays(load, userptr);
+ glad_gl_load_GL_EXT_map_buffer_range(load, userptr);
+ glad_gl_load_GL_EXT_memory_object(load, userptr);
+ glad_gl_load_GL_EXT_memory_object_fd(load, userptr);
+ glad_gl_load_GL_EXT_memory_object_win32(load, userptr);
+ glad_gl_load_GL_EXT_multi_draw_arrays(load, userptr);
+ glad_gl_load_GL_EXT_multi_draw_indirect(load, userptr);
+ glad_gl_load_GL_EXT_multisampled_render_to_texture(load, userptr);
+ glad_gl_load_GL_EXT_multiview_draw_buffers(load, userptr);
+ glad_gl_load_GL_EXT_occlusion_query_boolean(load, userptr);
+ glad_gl_load_GL_EXT_polygon_offset_clamp(load, userptr);
+ glad_gl_load_GL_EXT_primitive_bounding_box(load, userptr);
+ glad_gl_load_GL_EXT_raster_multisample(load, userptr);
+ glad_gl_load_GL_EXT_robustness(load, userptr);
+ glad_gl_load_GL_EXT_semaphore(load, userptr);
+ glad_gl_load_GL_EXT_semaphore_fd(load, userptr);
+ glad_gl_load_GL_EXT_semaphore_win32(load, userptr);
+ glad_gl_load_GL_EXT_separate_shader_objects(load, userptr);
+ glad_gl_load_GL_EXT_shader_framebuffer_fetch_non_coherent(load, userptr);
+ glad_gl_load_GL_EXT_shader_pixel_local_storage2(load, userptr);
+ glad_gl_load_GL_EXT_sparse_texture(load, userptr);
+ glad_gl_load_GL_EXT_tessellation_shader(load, userptr);
+ glad_gl_load_GL_EXT_texture_border_clamp(load, userptr);
+ glad_gl_load_GL_EXT_texture_buffer(load, userptr);
+ glad_gl_load_GL_EXT_texture_storage(load, userptr);
+ glad_gl_load_GL_EXT_texture_storage_compression(load, userptr);
+ glad_gl_load_GL_EXT_texture_view(load, userptr);
+ glad_gl_load_GL_EXT_win32_keyed_mutex(load, userptr);
+ glad_gl_load_GL_EXT_window_rectangles(load, userptr);
+ glad_gl_load_GL_KHR_blend_equation_advanced(load, userptr);
+ glad_gl_load_GL_KHR_debug(load, userptr);
+ glad_gl_load_GL_KHR_parallel_shader_compile(load, userptr);
+ glad_gl_load_GL_KHR_robustness(load, userptr);
+ glad_gl_load_GL_OES_EGL_image(load, userptr);
+ glad_gl_load_GL_OES_copy_image(load, userptr);
+ glad_gl_load_GL_OES_draw_buffers_indexed(load, userptr);
+ glad_gl_load_GL_OES_draw_elements_base_vertex(load, userptr);
+ glad_gl_load_GL_OES_geometry_shader(load, userptr);
+ glad_gl_load_GL_OES_get_program_binary(load, userptr);
+ glad_gl_load_GL_OES_mapbuffer(load, userptr);
+ glad_gl_load_GL_OES_primitive_bounding_box(load, userptr);
+ glad_gl_load_GL_OES_sample_shading(load, userptr);
+ glad_gl_load_GL_OES_tessellation_shader(load, userptr);
+ glad_gl_load_GL_OES_texture_3D(load, userptr);
+ glad_gl_load_GL_OES_texture_border_clamp(load, userptr);
+ glad_gl_load_GL_OES_texture_buffer(load, userptr);
+ glad_gl_load_GL_OES_texture_storage_multisample_2d_array(load, userptr);
+ glad_gl_load_GL_OES_texture_view(load, userptr);
+ glad_gl_load_GL_OES_vertex_array_object(load, userptr);
+ glad_gl_load_GL_OES_viewport_array(load, userptr);
+
+
+
+ return version;
+}
+
+
+int gladLoadGLES2( GLADloadfunc load) {
+ return gladLoadGLES2UserPtr( glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
+}
+
+
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GLAD_GLES2_IMPLEMENTATION */
+
diff --git a/src/external/miniaudio.h b/src/external/miniaudio.h
index f774f0d5f..35eaafdcf 100644
--- a/src/external/miniaudio.h
+++ b/src/external/miniaudio.h
@@ -1,6 +1,6 @@
/*
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
-miniaudio - v0.11.9 - 2022-04-20
+miniaudio - v0.11.16 - 2023-05-15
David Reid - mackron@gmail.com
@@ -38,7 +38,7 @@ A config/init pattern is used throughout the entire library. The idea is that yo
object and pass that into the initialization routine. The advantage to this system is that the
config object can be initialized with logical defaults and new properties added to it without
breaking the API. The config object can be allocated on the stack and does not need to be
-maintained after initialization of the corresponding object.
+maintained after initialization of the corresponding object.
1.1. Low Level API
@@ -363,7 +363,7 @@ initialized. The easiest but least flexible way of playing a sound is like so:
This plays what miniaudio calls an "inline" sound. It plays the sound once, and then puts the
internal sound up for recycling. The last parameter is used to specify which sound group the sound
should be associated with which will be explained later. This particular way of playing a sound is
-simple, but lacks flexibility and features. A more flexible way of playing a sound is to first
+simple, but lacks flexibility and features. A more flexible way of playing a sound is to first
initialize a sound:
```c
@@ -386,7 +386,7 @@ Sounds should be uninitialized with `ma_sound_uninit()`.
Sounds are not started by default. Start a sound with `ma_sound_start()` and stop it with
`ma_sound_stop()`. When a sound is stopped, it is not rewound to the start. Use
-`ma_sound_seek_to_pcm_frames(&sound, 0)` to seek back to the start of a sound. By default, starting
+`ma_sound_seek_to_pcm_frame(&sound, 0)` to seek back to the start of a sound. By default, starting
and stopping sounds happens immediately, but sometimes it might be convenient to schedule the sound
the be started and/or stopped at a specific time. This can be done with the following functions:
@@ -398,13 +398,13 @@ the be started and/or stopped at a specific time. This can be done with the foll
```
The start/stop time needs to be specified based on the absolute timer which is controlled by the
-engine. The current global time time in PCM frames can be retrieved with `ma_engine_get_time()`.
-The engine's global time can be changed with `ma_engine_set_time()` for synchronization purposes if
-required. Note that scheduling a start time still requires an explicit call to `ma_sound_start()`
-before anything will play:
+engine. The current global time time in PCM frames can be retrieved with
+`ma_engine_get_time_in_pcm_frames()`. The engine's global time can be changed with
+`ma_engine_set_time_in_pcm_frames()` for synchronization purposes if required. Note that scheduling
+a start time still requires an explicit call to `ma_sound_start()` before anything will play:
```c
- ma_sound_set_start_time_in_pcm_frames(&sound, ma_engine_get_time(&engine) + (ma_engine_get_sample_rate(&engine) * 2);
+ ma_sound_set_start_time_in_pcm_frames(&sound, ma_engine_get_time_in_pcm_frames(&engine) + (ma_engine_get_sample_rate(&engine) * 2);
ma_sound_start(&sound);
```
@@ -460,6 +460,11 @@ is at the end, use `ma_sound_at_end()`. Looping of a sound can be controlled wit
miniaudio should work cleanly out of the box without the need to download or install any
dependencies. See below for platform-specific details.
+Note that GCC and Clang require `-msse2`, `-mavx2`, etc. for SIMD optimizations.
+
+If you get errors about undefined references to `__sync_val_compare_and_swap_8`, `__atomic_load_8`,
+etc. you need to link with `-latomic`.
+
2.1. Windows
------------
@@ -489,9 +494,10 @@ notarization process. To fix this there are two options. The first is to use the
#include "miniaudio.h"
```
-This will require linking with `-framework CoreFoundation -framework CoreAudio -framework AudioUnit`.
-Alternatively, if you would rather keep using runtime linking you can add the following to your
-entitlements.xcent file:
+This will require linking with `-framework CoreFoundation -framework CoreAudio -framework AudioToolbox`.
+If you get errors about AudioToolbox, try with `-framework AudioUnit` instead. You may get this when
+using older versions of iOS. Alternatively, if you would rather keep using runtime linking you can
+add the following to your entitlements.xcent file:
```
com.apple.security.cs.allow-dyld-environment-variables
@@ -627,10 +633,29 @@ You cannot use `-std=c*` compiler flags, nor `-ansi`.
| | and `ma_device` APIs. This is useful if you only want to use |
| | miniaudio's data conversion and/or decoding APIs. |
+----------------------------------+--------------------------------------------------------------------+
+ | MA_NO_RESOURCE_MANAGER | Disables the resource manager. When using the engine this will |
+ | | also disable the following functions: |
+ | | |
+ | | ``` |
+ | | ma_sound_init_from_file() |
+ | | ma_sound_init_from_file_w() |
+ | | ma_sound_init_copy() |
+ | | ma_engine_play_sound_ex() |
+ | | ma_engine_play_sound() |
+ | | ``` |
+ | | |
+ | | The only way to initialize a `ma_sound` object is to initialize it |
+ | | from a data source. |
+ +----------------------------------+--------------------------------------------------------------------+
+ | MA_NO_NODE_GRAPH | Disables the node graph API. This will also disable the engine API |
+ | | because it depends on the node graph. |
+ +----------------------------------+--------------------------------------------------------------------+
+ | MA_NO_ENGINE | Disables the engine API. |
+ +----------------------------------+--------------------------------------------------------------------+
| MA_NO_THREADING | Disables the `ma_thread`, `ma_mutex`, `ma_semaphore` and |
| | `ma_event` APIs. This option is useful if you only need to use |
| | miniaudio for data conversion, decoding and/or encoding. Some |
- | | families of APIsrequire threading which means the following |
+ | | families of APIs require threading which means the following |
| | options must also be set: |
| | |
| | ``` |
@@ -729,7 +754,7 @@ To read data from a data source:
ma_result result;
ma_uint64 framesRead;
- result = ma_data_source_read_pcm_frames(pDataSource, pFramesOut, frameCount, &framesRead, loop);
+ result = ma_data_source_read_pcm_frames(pDataSource, pFramesOut, frameCount, &framesRead);
if (result != MA_SUCCESS) {
return result; // Failed to read data from the data source.
}
@@ -749,7 +774,7 @@ you could plug in a decoder like so:
ma_uint64 framesRead;
ma_decoder decoder; // <-- This would be initialized with `ma_decoder_init_*()`.
- result = ma_data_source_read_pcm_frames(&decoder, pFramesOut, frameCount, &framesRead, loop);
+ result = ma_data_source_read_pcm_frames(&decoder, pFramesOut, frameCount, &framesRead);
if (result != MA_SUCCESS) {
return result; // Failed to read data from the decoder.
}
@@ -803,7 +828,7 @@ retrieved like so:
ma_uint32 channels;
ma_uint32 sampleRate;
ma_channel channelMap[MA_MAX_CHANNELS];
-
+
result = ma_data_source_get_data_format(pDataSource, &format, &channels, &sampleRate, channelMap, MA_MAX_CHANNELS);
if (result != MA_SUCCESS) {
return result; // Failed to retrieve data format.
@@ -823,7 +848,9 @@ read data within a certain range of the underlying data. To do this you can use
```
This is useful if you have a sound bank where many sounds are stored in the same file and you want
-the data source to only play one of those sub-sounds.
+the data source to only play one of those sub-sounds. Note that once the range is set, everything
+that takes a position, such as cursors and loop points, should always be relatvie to the start of
+the range. When the range is set, any previously defined loop point will be reset.
Custom loop points can also be used with data sources. By default, data sources will loop after
they reach the end of the data source, but if you need to loop at a specific location, you can do
@@ -852,19 +879,19 @@ To do this, you can use chaining:
return result; // Failed to set the next data source.
}
- result = ma_data_source_read_pcm_frames(&decoder1, pFramesOut, frameCount, pFramesRead, MA_FALSE);
+ result = ma_data_source_read_pcm_frames(&decoder1, pFramesOut, frameCount, pFramesRead);
if (result != MA_SUCCESS) {
return result; // Failed to read from the decoder.
}
```
In the example above we're using decoders. When reading from a chain, you always want to read from
-the top level data source in the chain. In the example above, `decoder1` is the top level data
+the top level data source in the chain. In the example above, `decoder1` is the top level data
source in the chain. When `decoder1` reaches the end, `decoder2` will start seamlessly without any
gaps.
-Note that the `loop` parameter is set to false in the example above. When this is set to true, only
-the current data source will be looped. You can loop the entire chain by linking in a loop like so:
+Note that when looping is enabled, only the current data source will be looped. You can loop the
+entire chain by linking in a loop like so:
```c
ma_data_source_set_next(&decoder1, &decoder2); // decoder1 -> decoder2
@@ -875,9 +902,9 @@ Note that setting up chaining is not thread safe, so care needs to be taken if y
changing links while the audio thread is in the middle of reading.
Do not use `ma_decoder_seek_to_pcm_frame()` as a means to reuse a data source to play multiple
-instances of the same sound simultaneously. Instead, initialize multiple data sources for each
-instance. This can be extremely inefficient depending on the data source and can result in
-glitching due to subtle changes to the state of internal filters.
+instances of the same sound simultaneously. This can be extremely inefficient depending on the type
+of data source and can result in glitching due to subtle changes to the state of internal filters.
+Instead, initialize multiple data sources for each instance.
4.1. Custom Data Sources
@@ -922,7 +949,7 @@ base object (`ma_data_source_base`):
// Retrieve the length in PCM frames here. Return MA_NOT_IMPLEMENTED and set *pLength to 0 if there is no notion of a length or if the length is unknown.
}
- static g_my_data_source_vtable =
+ static ma_data_source_vtable g_my_data_source_vtable =
{
my_data_source_read,
my_data_source_seek,
@@ -952,7 +979,7 @@ base object (`ma_data_source_base`):
void my_data_source_uninit(my_data_source* pMyDataSource)
{
// ... do the uninitialization of your custom data source here ...
-
+
// You must uninitialize the base data source.
ma_data_source_uninit(&pMyDataSource->base);
}
@@ -1001,7 +1028,7 @@ configure the engine with an engine config:
ma_engine_config engineConfig;
engineConfig = ma_engine_config_init();
- engineConfig.pPlaybackDevice = &myDevice;
+ engineConfig.pDevice = &myDevice;
result = ma_engine_init(&engineConfig, &engine);
if (result != MA_SUCCESS) {
@@ -1042,7 +1069,7 @@ Note that when you're not using a device, you must set the channel count and sam
config or else miniaudio won't know what to use (miniaudio will use the device to determine this
normally). When not using a device, you need to use `ma_engine_read_pcm_frames()` to process audio
data from the engine. This kind of setup is useful if you want to do something like offline
-processing.
+processing or want to use a different audio system for playback such as SDL.
When a sound is loaded it goes through a resource manager. By default the engine will initialize a
resource manager internally, but you can also specify a pre-initialized resource manager:
@@ -1207,7 +1234,7 @@ might be beneficial to pre-decode the sound. You can do this with the `MA_SOUND_
By default, sounds will be loaded synchronously, meaning `ma_sound_init_*()` will not return until
the sound has been fully loaded. If this is prohibitive you can instead load sounds asynchronously
-by specificying the `MA_SOUND_FLAG_ASYNC` flag:
+by specifying the `MA_SOUND_FLAG_ASYNC` flag:
```c
ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_DECODE | MA_SOUND_FLAG_ASYNC, pGroup, NULL, &sound);
@@ -1228,7 +1255,7 @@ counter hit's zero. You can specify a fence like so:
ma_sound sounds[4];
result = ma_fence_init(&fence);
- if (result != MA_SUCCES) {
+ if (result != MA_SUCCESS) {
return result;
}
@@ -1254,6 +1281,18 @@ When streaming sounds, 2 seconds worth of audio data is stored in memory. Althou
fine, it's inefficient to use streaming for short sounds. Streaming is useful for things like music
tracks in games.
+When loading a sound from a file path, the engine will reference count the file to prevent it from
+being loaded if it's already in memory. When you uninitialize a sound, the reference count will be
+decremented, and if it hits zero, the sound will be unloaded from memory. This reference counting
+system is not used for streams. The engine will use a 64-bit hash of the file name when comparing
+file paths which means there's a small chance you might encounter a name collision. If this is an
+issue, you'll need to use a different name for one of the colliding file paths, or just not load
+from files and instead load from a data source.
+
+You can use `ma_sound_init_copy()` to initialize a copy of another sound. Note, however, that this
+only works for sounds that were initialized with `ma_sound_init_from_file()` and without the
+`MA_SOUND_FLAG_STREAM` flag.
+
When you initialize a sound, if you specify a sound group the sound will be attached to that group
automatically. If you set it to NULL, it will be automatically attached to the engine's endpoint.
If you would instead rather leave the sound unattached by default, you can can specify the
@@ -1393,19 +1432,19 @@ can be useful to schedule a sound to start or stop:
```c
// Start the sound in 1 second from now.
- ma_sound_set_start_time_in_pcm_frames(&sound, ma_engine_get_time(&engine) + (ma_engine_get_sample_rate(&engine) * 1));
+ ma_sound_set_start_time_in_pcm_frames(&sound, ma_engine_get_time_in_pcm_frames(&engine) + (ma_engine_get_sample_rate(&engine) * 1));
// Stop the sound in 2 seconds from now.
- ma_sound_set_stop_time_in_pcm_frames(&sound, ma_engine_get_time(&engine) + (ma_engine_get_sample_rate(&engine) * 2));
+ ma_sound_set_stop_time_in_pcm_frames(&sound, ma_engine_get_time_in_pcm_frames(&engine) + (ma_engine_get_sample_rate(&engine) * 2));
```
Note that scheduling a start time still requires an explicit call to `ma_sound_start()` before
anything will play.
The time is specified in global time which is controlled by the engine. You can get the engine's
-current time with `ma_engine_get_time()`. The engine's global time is incremented automatically as
-audio data is read, but it can be reset with `ma_engine_set_time()` in case it needs to be
-resynchronized for some reason.
+current time with `ma_engine_get_time_in_pcm_frames()`. The engine's global time is incremented
+automatically as audio data is read, but it can be reset with `ma_engine_set_time_in_pcm_frames()`
+in case it needs to be resynchronized for some reason.
To determine whether or not a sound is currently playing, use `ma_sound_is_playing()`. This will
take the scheduled start and stop times into account.
@@ -1414,7 +1453,25 @@ Whether or not a sound should loop can be controlled with `ma_sound_set_looping(
be looping by default. Use `ma_sound_is_looping()` to determine whether or not a sound is looping.
Use `ma_sound_at_end()` to determine whether or not a sound is currently at the end. For a looping
-sound this should never return true.
+sound this should never return true. Alternatively, you can configure a callback that will be fired
+when the sound reaches the end. Note that the callback is fired from the audio thread which means
+you cannot be uninitializing sound from the callback. To set the callback you can use
+`ma_sound_set_end_callback()`. Alternatively, if you're using `ma_sound_init_ex()`, you can pass it
+into the config like so:
+
+ ```c
+ soundConfig.endCallback = my_end_callback;
+ soundConfig.pEndCallbackUserData = pMyEndCallbackUserData;
+ ```
+
+The end callback is declared like so:
+
+ ```c
+ void my_end_callback(void* pUserData, ma_sound* pSound)
+ {
+ ...
+ }
+ ```
Internally a sound wraps around a data source. Some APIs exist to control the underlying data
source, mainly for convenience:
@@ -1429,7 +1486,7 @@ source, mainly for convenience:
Sound groups have the same API as sounds, only they are called `ma_sound_group`, and since they do
not have any notion of a data source, anything relating to a data source is unavailable.
-Internally, sound data is loaded via the `ma_decoder` API which means by default in only supports
+Internally, sound data is loaded via the `ma_decoder` API which means by default it only supports
file formats that have built-in support in miniaudio. You can extend this to support any kind of
file format through the use of custom decoders. To do this you'll need to use a self-managed
resource manager and configure it appropriately. See the "Resource Management" section below for
@@ -1444,7 +1501,7 @@ streaming. This is supported by miniaudio via the `ma_resource_manager` API.
The resource manager is mainly responsible for the following:
* Loading of sound files into memory with reference counting.
- * Streaming of sound data
+ * Streaming of sound data.
When loading a sound file, the resource manager will give you back a `ma_data_source` compatible
object called `ma_resource_manager_data_source`. This object can be passed into any
@@ -1539,7 +1596,7 @@ need to retrieve a job using `ma_resource_manager_next_job()` and then process i
ma_job job;
ma_result result = ma_resource_manager_next_job(pMyResourceManager, &job);
if (result != MA_SUCCESS) {
- if (result == MA_NOT_DATA_AVAILABLE) {
+ if (result == MA_NO_DATA_AVAILABLE) {
// No jobs are available. Keep going. Will only get this if the resource manager was initialized
// with MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING.
continue;
@@ -1578,7 +1635,7 @@ default. This can be done by setting `pVFS` member of the resource manager's con
This is particularly useful in programs like games where you want to read straight from an archive
rather than the normal file system. If you do not specify a custom VFS, the resource manager will
-use the operating system's normal file operations. This is default.
+use the operating system's normal file operations.
To load a sound file and create a data source, call `ma_resource_manager_data_source_init()`. When
loading a sound you need to specify the file path and options for how the sounds should be loaded.
@@ -1851,9 +1908,11 @@ A binary search tree (BST) is used for storing data buffers as it has good balan
efficiency and simplicity. The key of the BST is a 64-bit hash of the file path that was passed
into `ma_resource_manager_data_source_init()`. The advantage of using a hash is that it saves
memory over storing the entire path, has faster comparisons, and results in a mostly balanced BST
-due to the random nature of the hash. The disadvantage is that file names are case-sensitive. If
-this is an issue, you should normalize your file names to upper- or lower-case before initializing
-your data sources.
+due to the random nature of the hash. The disadvantages are that file names are case-sensitive and
+there's a small chance of name collisions. If case-sensitivity is an issue, you should normalize
+your file names to upper- or lower-case before initializing your data sources. If name collisions
+become an issue, you'll need to change the name of one of the colliding names or just not use the
+resource manager.
When a sound file has not already been loaded and the `MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC`
flag is excluded, the file will be decoded synchronously by the calling thread. There are two
@@ -1933,7 +1992,7 @@ miniaudio's routing infrastructure follows a node graph paradigm. The idea is th
node whose outputs are attached to inputs of another node, thereby creating a graph. There are
different types of nodes, with each node in the graph processing input data to produce output,
which is then fed through the chain. Each node in the graph can apply their own custom effects. At
-the start of the graph will usually be one or more data source nodes which have no inputs, but
+the start of the graph will usually be one or more data source nodes which have no inputs and
instead pull their data from a data source. At the end of the graph is an endpoint which represents
the end of the chain and is where the final output is ultimately extracted from.
@@ -1959,7 +2018,7 @@ splitter node. It's at this point that the two data sources are mixed. After mix
performs it's processing routine and produces two outputs which is simply a duplication of the
input stream. One output is attached to a low pass filter, whereas the other output is attached to
a echo/delay. The outputs of the the low pass filter and the echo are attached to the endpoint, and
-since they're both connected to the same input but, they'll be mixed.
+since they're both connected to the same input bus, they'll be mixed.
Each input bus must be configured to accept the same number of channels, but the number of channels
used by input buses can be different to the number of channels for output buses in which case
@@ -1999,14 +2058,14 @@ data from the graph:
```
When you read audio data, miniaudio starts at the node graph's endpoint node which then pulls in
-data from it's input attachments, which in turn recusively pull in data from their inputs, and so
+data from it's input attachments, which in turn recursively pull in data from their inputs, and so
on. At the start of the graph there will be some kind of data source node which will have zero
inputs and will instead read directly from a data source. The base nodes don't literally need to
read from a `ma_data_source` object, but they will always have some kind of underlying object that
sources some kind of audio. The `ma_data_source_node` node can be used to read from a
`ma_data_source`. Data is always in floating-point format and in the number of channels you
specified when the graph was initialized. The sample rate is defined by the underlying data sources.
-It's up to you to ensure they use a consistent and appropraite sample rate.
+It's up to you to ensure they use a consistent and appropriate sample rate.
The `ma_node` API is designed to allow custom nodes to be implemented with relative ease, but
miniaudio includes a few stock nodes for common functionality. This is how you would initialize a
@@ -2047,7 +2106,7 @@ another, you do not need to detach first. You can just call `ma_node_attach_outp
deal with it for you.
Less frequently you may want to create a specialized node. This will be a node where you implement
-your own processing callback to apply a custom effect of some kind. This is similar to initalizing
+your own processing callback to apply a custom effect of some kind. This is similar to initializing
one of the stock node types, only this time you need to specify a pointer to a vtable containing a
pointer to the processing function and the number of input and output buses. Example:
@@ -2074,7 +2133,7 @@ pointer to the processing function and the number of input and output buses. Exa
static ma_node_vtable my_custom_node_vtable =
{
- my_custom_node_process_pcm_frames, // The function that will be called process your custom node. This is where you'd implement your effect processing.
+ my_custom_node_process_pcm_frames, // The function that will be called to process your custom node. This is where you'd implement your effect processing.
NULL, // Optional. A callback for calculating the number of input frames that are required to process a specified number of output frames.
2, // 2 input buses.
1, // 1 output bus.
@@ -2086,7 +2145,7 @@ pointer to the processing function and the number of input and output buses. Exa
// Each bus needs to have a channel count specified. To do this you need to specify the channel
// counts in an array and then pass that into the node config.
ma_uint32 inputChannels[2]; // Equal in size to the number of input channels specified in the vtable.
- ma_uint32 outputChannels[1]; // Equal in size to the number of output channels specicied in the vtable.
+ ma_uint32 outputChannels[1]; // Equal in size to the number of output channels specified in the vtable.
inputChannels[0] = channelsIn;
inputChannels[1] = channelsIn;
@@ -2170,10 +2229,19 @@ and include the following:
+-----------------------------------------+---------------------------------------------------+
| MA_NODE_FLAG_CONTINUOUS_PROCESSING | Causes the processing callback to be called even |
| | when no data is available to be read from input |
- | | attachments. This is useful for effects like |
+ | | attachments. When a node has at least one input |
+ | | bus, but there are no inputs attached or the |
+ | | inputs do not deliver any data, the node's |
+ | | processing callback will not get fired. This flag |
+ | | will make it so the callback is always fired |
+ | | regardless of whether or not any input data is |
+ | | received. This is useful for effects like |
| | echos where there will be a tail of audio data |
| | that still needs to be processed even when the |
- | | original data sources have reached their ends. |
+ | | original data sources have reached their ends. It |
+ | | may also be useful for nodes that must always |
+ | | have their processing callback fired when there |
+ | | are no inputs attached. |
+-----------------------------------------+---------------------------------------------------+
| MA_NODE_FLAG_ALLOW_NULL_INPUT | Used in conjunction with |
| | `MA_NODE_FLAG_CONTINUOUS_PROCESSING`. When this |
@@ -2204,7 +2272,7 @@ called `ma_splitter_node`. This takes has 1 input bus and splits the stream into
You can use it like this:
```c
- ma_splitter_node_config splitterNodeConfig = ma_splitter_node_config_init(channelsIn, channelsOut);
+ ma_splitter_node_config splitterNodeConfig = ma_splitter_node_config_init(channels);
ma_splitter_node splitterNode;
result = ma_splitter_node_init(&nodeGraph, &splitterNodeConfig, NULL, &splitterNode);
@@ -2364,7 +2432,7 @@ bus and input bus is locked. This locking is specifically for attaching and deta
different threads and does not affect `ma_node_graph_read_pcm_frames()` in any way. The locking and
unlocking is mostly self-explanatory, but a slightly less intuitive aspect comes into it when
considering that iterating over attachments must not break as a result of attaching or detaching a
-node while iteration is occuring.
+node while iteration is occurring.
Attaching and detaching are both quite simple. When an output bus of a node is attached to an input
bus of another node, it's added to a linked list. Basically, an input bus is a linked list, where
@@ -2430,7 +2498,7 @@ implementation:
#define MA_NO_FLAC
```
-Disabling built-in decoding libraries is useful if you use these libraries independantly of the
+Disabling built-in decoding libraries is useful if you use these libraries independently of the
`ma_decoder` API.
A decoder can be initialized from a file with `ma_decoder_init_file()`, a block of memory with
@@ -2532,7 +2600,7 @@ The `ma_decoding_backend_vtable` vtable has the following functions:
```
onInit
- onInitFile
+ onInitFile
onInitFileW
onInitMemory
onUninit
@@ -2544,11 +2612,11 @@ these are not specified, miniaudio will deal with it for you via a generic imple
When you initialize a custom data source (by implementing the `onInit` function in the vtable) you
will need to output a pointer to a `ma_data_source` which implements your custom decoder. See the
-section about data sources for details on how to implemen this. Alternatively, see the
+section about data sources for details on how to implement this. Alternatively, see the
"custom_decoders" example in the miniaudio repository.
The `onInit` function takes a pointer to some callbacks for the purpose of reading raw audio data
-from some abitrary source. You'll use these functions to read from the raw data and perform the
+from some arbitrary source. You'll use these functions to read from the raw data and perform the
decoding. When you call them, you will pass in the `pReadSeekTellUserData` pointer to the relevant
parameter.
@@ -2699,7 +2767,7 @@ To perform the conversion simply call `ma_channel_converter_process_pcm_frames()
}
```
-It is up to the caller to ensure the output buffer is large enough to accomodate the new PCM
+It is up to the caller to ensure the output buffer is large enough to accommodate the new PCM
frames.
Input and output PCM frames are always interleaved. Deinterleaved layouts are not supported.
@@ -3145,7 +3213,7 @@ you can chain first and second order filters together.
If you need to change the configuration of the filter, but need to maintain the state of internal
registers you can do so with `ma_lpf_reinit()`. This may be useful if you need to change the sample
-rate and/or cutoff frequency dynamically while maintaing smooth transitions. Note that changing the
+rate and/or cutoff frequency dynamically while maintaining smooth transitions. Note that changing the
format or channel count after initialization is invalid and will result in an error.
The `ma_lpf` object supports a configurable order, but if you only need a first order filter you
@@ -3318,8 +3386,8 @@ The noise API uses simple LCG random number generation. It supports a custom see
for things like automated testing requiring reproducibility. Setting the seed to zero will default
to `MA_DEFAULT_LCG_SEED`.
-The amplitude, seed, and type can be changed dynamically with `ma_noise_set_amplitude()`,
-`ma_noise_set_seed()`, and `ma_noise_set_type()` respectively.
+The amplitude and seed can be changed dynamically with `ma_noise_set_amplitude()` and
+`ma_noise_set_seed()` respectively.
By default, the noise API will use different values for different channels. So, for example, the
left side in a stereo stream will be different to the right side. To instead have each channel use
@@ -3467,7 +3535,7 @@ you will want to use. To initialize a ring buffer, do something like the followi
```
The `ma_pcm_rb_init()` function takes the sample format and channel count as parameters because
-it's the PCM varient of the ring buffer API. For the regular ring buffer that operates on bytes you
+it's the PCM variant of the ring buffer API. For the regular ring buffer that operates on bytes you
would call `ma_rb_init()` which leaves these out and just takes the size of the buffer in bytes
instead of frames. The fourth parameter is an optional pre-allocated buffer and the fifth parameter
is a pointer to a `ma_allocation_callbacks` structure for custom memory allocation routines.
@@ -3514,21 +3582,26 @@ producer thread.
15. Backends
============
-The following backends are supported by miniaudio.
+The following backends are supported by miniaudio. These are listed in order of default priority.
+When no backend is specified when initializing a context or device, miniaudio will attempt to use
+each of these backends in the order listed in the table below.
+
+Note that backends that are not usable by the build target will not be included in the build. For
+example, ALSA, which is specific to Linux, will not be included in the Windows build.
+-------------+-----------------------+--------------------------------------------------------+
| Name | Enum Name | Supported Operating Systems |
+-------------+-----------------------+--------------------------------------------------------+
| WASAPI | ma_backend_wasapi | Windows Vista+ |
| DirectSound | ma_backend_dsound | Windows XP+ |
- | WinMM | ma_backend_winmm | Windows XP+ (may work on older versions, but untested) |
+ | WinMM | ma_backend_winmm | Windows 95+ |
| Core Audio | ma_backend_coreaudio | macOS, iOS |
- | ALSA | ma_backend_alsa | Linux |
- | PulseAudio | ma_backend_pulseaudio | Cross Platform (disabled on Windows, BSD and Android) |
- | JACK | ma_backend_jack | Cross Platform (disabled on BSD and Android) |
| sndio | ma_backend_sndio | OpenBSD |
| audio(4) | ma_backend_audio4 | NetBSD, OpenBSD |
| OSS | ma_backend_oss | FreeBSD |
+ | PulseAudio | ma_backend_pulseaudio | Cross Platform (disabled on Windows, BSD and Android) |
+ | ALSA | ma_backend_alsa | Linux |
+ | JACK | ma_backend_jack | Cross Platform (disabled on BSD and Android) |
| AAudio | ma_backend_aaudio | Android 8+ |
| OpenSL ES | ma_backend_opensl | Android (API level 16+) |
| Web Audio | ma_backend_webaudio | Web (via Emscripten) |
@@ -3567,6 +3640,12 @@ Some backends have some nuance details you may want to be aware of.
miniaudio's built-in resampler is to take advantage of any potential device-specific
optimizations the driver may implement.
+BSD
+---
+- The sndio backend is currently only enabled on OpenBSD builds.
+- The audio(4) backend is supported on OpenBSD, but you may need to disable sndiod before you can
+ use it.
+
15.4. UWP
---------
- UWP only supports default playback and capture devices.
@@ -3597,14 +3676,28 @@ Some backends have some nuance details you may want to be aware of.
16. Optimization Tips
=====================
+See below for some tips on improving performance.
-16.1. High Level API
+16.1. Low Level API
+-------------------
+- In the data callback, if your data is already clipped prior to copying it into the output buffer,
+ set the `noClip` config option in the device config to true. This will disable miniaudio's built
+ in clipping function.
+- By default, miniaudio will pre-silence the data callback's output buffer. If you know that you
+ will always write valid data to the output buffer you can disable pre-silencing by setting the
+ `noPreSilence` config option in the device config to true.
+
+16.2. High Level API
--------------------
- If a sound does not require doppler or pitch shifting, consider disabling pitching by
initializing the sound with the `MA_SOUND_FLAG_NO_PITCH` flag.
-- If a sound does not require spatialization, disable it by initialzing the sound with the
- `MA_SOUND_FLAG_NO_SPATIALIZATION` flag. It can be renabled again post-initialization with
+- If a sound does not require spatialization, disable it by initializing the sound with the
+ `MA_SOUND_FLAG_NO_SPATIALIZATION` flag. It can be re-enabled again post-initialization with
`ma_sound_set_spatialization_enabled()`.
+- If you know all of your sounds will always be the same sample rate, set the engine's sample
+ rate to match that of the sounds. Likewise, if you're using a self-managed resource manager,
+ consider setting the decoded sample rate to match your sounds. By configuring everything to
+ use a consistent sample rate, sample rate conversion can be avoided.
@@ -3613,17 +3706,6 @@ Some backends have some nuance details you may want to be aware of.
- Automatic stream routing is enabled on a per-backend basis. Support is explicitly enabled for
WASAPI and Core Audio, however other backends such as PulseAudio may naturally support it, though
not all have been tested.
-- The contents of the output buffer passed into the data callback will always be pre-initialized to
- silence unless the `noPreSilencedOutputBuffer` config variable in `ma_device_config` is set to
- true, in which case it'll be undefined which will require you to write something to the entire
- buffer.
-- By default miniaudio will automatically clip samples. This only applies when the playback sample
- format is configured as `ma_format_f32`. If you are doing clipping yourself, you can disable this
- overhead by setting `noClip` to true in the device config.
-- Note that GCC and Clang requires `-msse2`, `-mavx2`, etc. for SIMD optimizations.
-- The sndio backend is currently only enabled on OpenBSD builds.
-- The audio(4) backend is supported on OpenBSD, but you may need to disable sndiod before you can
- use it.
- When compiling with VC6 and earlier, decoding is restricted to files less than 2GB in size. This
is due to 64-bit file APIs not being available.
*/
@@ -3640,7 +3722,7 @@ extern "C" {
#define MA_VERSION_MAJOR 0
#define MA_VERSION_MINOR 11
-#define MA_VERSION_REVISION 9
+#define MA_VERSION_REVISION 16
#define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION)
#if defined(_MSC_VER) && !defined(__clang__)
@@ -3655,7 +3737,7 @@ extern "C" {
#pragma GCC diagnostic ignored "-Wc11-extensions" /* anonymous unions are a C11 extension */
#endif
#endif
-
+
#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined(_M_IA64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__powerpc64__)
@@ -3714,9 +3796,24 @@ typedef ma_uint32 ma_bool32;
#define MA_TRUE 1
#define MA_FALSE 0
+/* These float types are not used universally by miniaudio. It's to simplify some macro expansion for atomic types. */
+typedef float ma_float;
+typedef double ma_double;
+
typedef void* ma_handle;
typedef void* ma_ptr;
-typedef void (* ma_proc)(void);
+
+/*
+ma_proc is annoying because when compiling with GCC we get pendantic warnings about converting
+between `void*` and `void (*)()`. We can't use `void (*)()` with MSVC however, because we'll get
+warning C4191 about "type cast between incompatible function types". To work around this I'm going
+to use a different data type depending on the compiler.
+*/
+#if defined(__GNUC__)
+typedef void (*ma_proc)(void);
+#else
+typedef void* ma_proc;
+#endif
#if defined(_MSC_VER) && !defined(_WCHAR_T_DEFINED)
typedef ma_uint16 wchar_t;
@@ -3735,16 +3832,17 @@ typedef ma_uint16 wchar_t;
/* Platform/backend detection. */
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__COSMOPOLITAN__)
#define MA_WIN32
- #if defined(WINAPI_FAMILY) && ((defined(WINAPI_FAMILY_PC_APP) && WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) || (defined(WINAPI_FAMILY_PHONE_APP) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP))
+ #if defined(MA_FORCE_UWP) || (defined(WINAPI_FAMILY) && ((defined(WINAPI_FAMILY_PC_APP) && WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) || (defined(WINAPI_FAMILY_PHONE_APP) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)))
#define MA_WIN32_UWP
#elif defined(WINAPI_FAMILY) && (defined(WINAPI_FAMILY_GAMES) && WINAPI_FAMILY == WINAPI_FAMILY_GAMES)
#define MA_WIN32_GDK
#else
#define MA_WIN32_DESKTOP
#endif
-#else
+#endif
+#if !defined(_WIN32) /* If it's not Win32, assume POSIX. */
#define MA_POSIX
/*
@@ -3765,26 +3863,54 @@ typedef ma_uint16 wchar_t;
typedef union ma_pthread_cond_t { char __data[48]; ma_uint64 __alignment; } ma_pthread_cond_t;
#endif
- #ifdef __unix__
+ #if defined(__unix__)
#define MA_UNIX
- #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
- #define MA_BSD
- #endif
#endif
- #ifdef __linux__
+ #if defined(__linux__)
#define MA_LINUX
#endif
- #ifdef __APPLE__
+ #if defined(__APPLE__)
#define MA_APPLE
#endif
- #ifdef __ANDROID__
+ #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+ #define MA_BSD
+ #endif
+ #if defined(__ANDROID__)
#define MA_ANDROID
#endif
- #ifdef __EMSCRIPTEN__
+ #if defined(__EMSCRIPTEN__)
#define MA_EMSCRIPTEN
#endif
+ #if defined(__ORBIS__)
+ #define MA_ORBIS
+ #endif
+ #if defined(__PROSPERO__)
+ #define MA_PROSPERO
+ #endif
+ #if defined(__NX__)
+ #define MA_NX
+ #endif
+ #if defined(__BEOS__) || defined(__HAIKU__)
+ #define MA_BEOS
+ #endif
+ #if defined(__HAIKU__)
+ #define MA_HAIKU
+ #endif
#endif
+#if defined(__has_c_attribute)
+ #if __has_c_attribute(fallthrough)
+ #define MA_FALLTHROUGH [[fallthrough]]
+ #endif
+#endif
+#if !defined(MA_FALLTHROUGH) && defined(__has_attribute) && (defined(__clang__) || defined(__GNUC__))
+ #if __has_attribute(fallthrough)
+ #define MA_FALLTHROUGH __attribute__((fallthrough))
+ #endif
+#endif
+#if !defined(MA_FALLTHROUGH)
+ #define MA_FALLTHROUGH ((void)0)
+#endif
#ifdef _MSC_VER
#define MA_INLINE __forceinline
@@ -3846,6 +3972,21 @@ typedef ma_uint16 wchar_t;
/* SIMD alignment in bytes. Currently set to 32 bytes in preparation for future AVX optimizations. */
#define MA_SIMD_ALIGNMENT 32
+/*
+Special wchar_t type to ensure any structures in the public sections that reference it have a
+consistent size across all platforms.
+
+On Windows, wchar_t is 2 bytes, whereas everywhere else it's 4 bytes. Since Windows likes to use
+wchar_t for it's IDs, we need a special explicitly sized wchar type that is always 2 bytes on all
+platforms.
+*/
+#if !defined(MA_POSIX) && defined(MA_WIN32)
+typedef wchar_t ma_wchar_win32;
+#else
+typedef ma_uint16 ma_wchar_win32;
+#endif
+
+
/*
Logging Levels
@@ -3890,9 +4031,9 @@ implications. Where supported by the compiler, alignment will be used, but other
architecture does not require it, it will simply leave it unaligned. This is the case with old
versions of Visual Studio, which I've confirmed with at least VC6.
*/
-#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
+#if !defined(_MSC_VER) && defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
#include
- #define MA_ATOMIC(alignment, type) alignas(alignment) type
+ #define MA_ATOMIC(alignment, type) _Alignas(alignment) type
#else
#if defined(__GNUC__)
/* GCC-style compilers. */
@@ -4034,6 +4175,7 @@ typedef enum
MA_API_NOT_FOUND = -105,
MA_INVALID_DEVICE_CONFIG = -106,
MA_LOOP = -107,
+ MA_BACKEND_NOT_ENABLED = -108,
/* State errors. */
MA_DEVICE_NOT_INITIALIZED = -200,
@@ -4050,7 +4192,7 @@ typedef enum
#define MA_MIN_CHANNELS 1
-#ifndef MA_MAX_CHANNELS
+#ifndef MA_MAX_CHANNELS
#define MA_MAX_CHANNELS 254
#endif
@@ -4123,7 +4265,7 @@ typedef enum
{
ma_channel_mix_mode_rectangular = 0, /* Simple averaging based on the plane(s) the channel is sitting on. */
ma_channel_mix_mode_simple, /* Drop excess channels; zeroed out extra channels. */
- ma_channel_mix_mode_custom_weights, /* Use custom weights specified in ma_channel_router_config. */
+ ma_channel_mix_mode_custom_weights, /* Use custom weights specified in ma_channel_converter_config. */
ma_channel_mix_mode_default = ma_channel_mix_mode_rectangular
} ma_channel_mix_mode;
@@ -4161,65 +4303,118 @@ typedef struct
} ma_lcg;
+/*
+Atomics.
+
+These are typesafe structures to prevent errors as a result of forgetting to reference variables atomically. It's too
+easy to introduce subtle bugs where you accidentally do a regular assignment instead of an atomic load/store, etc. By
+using a struct we can enforce the use of atomics at compile time.
+
+These types are declared in the header section because we need to reference them in structs below, but functions for
+using them are only exposed in the implementation section. I do not want these to be part of the public API.
+
+There's a few downsides to this system. The first is that you need to declare a new struct for each type. Below are
+some macros to help with the declarations. They will be named like so:
+
+ ma_atomic_uint32 - atomic ma_uint32
+ ma_atomic_int32 - atomic ma_int32
+ ma_atomic_uint64 - atomic ma_uint64
+ ma_atomic_float - atomic float
+ ma_atomic_bool32 - atomic ma_bool32
+
+The other downside is that atomic pointers are extremely messy. You need to declare a new struct for each specific
+type of pointer you need to make atomic. For example, an atomic ma_node* will look like this:
+
+ MA_ATOMIC_SAFE_TYPE_IMPL_PTR(node)
+
+Which will declare a type struct that's named like so:
+
+ ma_atomic_ptr_node
+
+Functions to use the atomic types are declared in the implementation section. All atomic functions are prefixed with
+the name of the struct. For example:
+
+ ma_atomic_uint32_set() - Atomic store of ma_uint32
+ ma_atomic_uint32_get() - Atomic load of ma_uint32
+ etc.
+
+For pointer types it's the same, which makes them a bit messy to use due to the length of each function name, but in
+return you get type safety and enforcement of atomic operations.
+*/
+#define MA_ATOMIC_SAFE_TYPE_DECL(c89TypeExtension, typeSize, type) \
+ typedef struct \
+ { \
+ MA_ATOMIC(typeSize, ma_##type) value; \
+ } ma_atomic_##type; \
+
+#define MA_ATOMIC_SAFE_TYPE_DECL_PTR(type) \
+ typedef struct \
+ { \
+ MA_ATOMIC(MA_SIZEOF_PTR, ma_##type*) value; \
+ } ma_atomic_ptr_##type; \
+
+MA_ATOMIC_SAFE_TYPE_DECL(32, 4, uint32)
+MA_ATOMIC_SAFE_TYPE_DECL(i32, 4, int32)
+MA_ATOMIC_SAFE_TYPE_DECL(64, 8, uint64)
+MA_ATOMIC_SAFE_TYPE_DECL(f32, 4, float)
+MA_ATOMIC_SAFE_TYPE_DECL(32, 4, bool32)
+
+
/* Spinlocks are 32-bit for compatibility reasons. */
typedef ma_uint32 ma_spinlock;
#ifndef MA_NO_THREADING
-/* Thread priorities should be ordered such that the default priority of the worker thread is 0. */
-typedef enum
-{
- ma_thread_priority_idle = -5,
- ma_thread_priority_lowest = -4,
- ma_thread_priority_low = -3,
- ma_thread_priority_normal = -2,
- ma_thread_priority_high = -1,
- ma_thread_priority_highest = 0,
- ma_thread_priority_realtime = 1,
- ma_thread_priority_default = 0
-} ma_thread_priority;
+ /* Thread priorities should be ordered such that the default priority of the worker thread is 0. */
+ typedef enum
+ {
+ ma_thread_priority_idle = -5,
+ ma_thread_priority_lowest = -4,
+ ma_thread_priority_low = -3,
+ ma_thread_priority_normal = -2,
+ ma_thread_priority_high = -1,
+ ma_thread_priority_highest = 0,
+ ma_thread_priority_realtime = 1,
+ ma_thread_priority_default = 0
+ } ma_thread_priority;
-#if defined(MA_WIN32)
-typedef ma_handle ma_thread;
-#endif
-#if defined(MA_POSIX)
-typedef ma_pthread_t ma_thread;
-#endif
+ #if defined(MA_POSIX)
+ typedef ma_pthread_t ma_thread;
+ #elif defined(MA_WIN32)
+ typedef ma_handle ma_thread;
+ #endif
-#if defined(MA_WIN32)
-typedef ma_handle ma_mutex;
-#endif
-#if defined(MA_POSIX)
-typedef ma_pthread_mutex_t ma_mutex;
-#endif
+ #if defined(MA_POSIX)
+ typedef ma_pthread_mutex_t ma_mutex;
+ #elif defined(MA_WIN32)
+ typedef ma_handle ma_mutex;
+ #endif
-#if defined(MA_WIN32)
-typedef ma_handle ma_event;
-#endif
-#if defined(MA_POSIX)
-typedef struct
-{
- ma_uint32 value;
- ma_pthread_mutex_t lock;
- ma_pthread_cond_t cond;
-} ma_event;
-#endif /* MA_POSIX */
+ #if defined(MA_POSIX)
+ typedef struct
+ {
+ ma_uint32 value;
+ ma_pthread_mutex_t lock;
+ ma_pthread_cond_t cond;
+ } ma_event;
+ #elif defined(MA_WIN32)
+ typedef ma_handle ma_event;
+ #endif
-#if defined(MA_WIN32)
-typedef ma_handle ma_semaphore;
-#endif
-#if defined(MA_POSIX)
-typedef struct
-{
- int value;
- ma_pthread_mutex_t lock;
- ma_pthread_cond_t cond;
-} ma_semaphore;
-#endif /* MA_POSIX */
+ #if defined(MA_POSIX)
+ typedef struct
+ {
+ int value;
+ ma_pthread_mutex_t lock;
+ ma_pthread_cond_t cond;
+ } ma_semaphore;
+ #elif defined(MA_WIN32)
+ typedef ma_handle ma_semaphore;
+ #endif
#else
-/* MA_NO_THREADING is set which means threading is disabled. Threading is required by some API families. If any of these are enabled we need to throw an error. */
-#ifndef MA_NO_DEVICE_IO
-#error "MA_NO_THREADING cannot be used without MA_NO_DEVICE_IO";
-#endif
+ /* MA_NO_THREADING is set which means threading is disabled. Threading is required by some API families. If any of these are enabled we need to throw an error. */
+ #ifndef MA_NO_DEVICE_IO
+ #error "MA_NO_THREADING cannot be used without MA_NO_DEVICE_IO";
+ #endif
#endif /* MA_NO_THREADING */
@@ -4247,7 +4442,7 @@ Logging
#endif
#endif
#ifndef MA_ATTRIBUTE_FORMAT
-#define MA_ATTRIBUTE_FORMAT(fmt,va)
+#define MA_ATTRIBUTE_FORMAT(fmt, va)
#endif
#ifndef MA_MAX_LOG_CALLBACKS
@@ -4278,11 +4473,6 @@ logLevel (in)
pMessage (in)
The log message.
-
-
-Remarks
--------
-Do not modify the state of the device from inside the callback.
*/
typedef void (* ma_log_callback_proc)(void* pUserData, ma_uint32 level, const char* pMessage);
@@ -4748,7 +4938,7 @@ typedef struct
{
ma_delay_config config;
ma_uint32 cursor; /* Feedback is written to this cursor. Always equal or in front of the read cursor. */
- ma_uint32 bufferSizeInFrames; /* The maximum of config.startDelayInFrames and config.feedbackDelayInFrames. */
+ ma_uint32 bufferSizeInFrames;
float* pBuffer;
} ma_delay;
@@ -4777,6 +4967,7 @@ typedef struct
{
ma_gainer_config config;
ma_uint32 t;
+ float masterVolume;
float* pOldGains;
float* pNewGains;
@@ -4792,6 +4983,8 @@ MA_API void ma_gainer_uninit(ma_gainer* pGainer, const ma_allocation_callbacks*
MA_API ma_result ma_gainer_process_pcm_frames(ma_gainer* pGainer, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
MA_API ma_result ma_gainer_set_gain(ma_gainer* pGainer, float newGain);
MA_API ma_result ma_gainer_set_gains(ma_gainer* pGainer, float* pNewGains);
+MA_API ma_result ma_gainer_set_master_volume(ma_gainer* pGainer, float volume);
+MA_API ma_result ma_gainer_get_master_volume(const ma_gainer* pGainer, float* pVolume);
@@ -4853,7 +5046,7 @@ MA_API ma_result ma_fader_init(const ma_fader_config* pConfig, ma_fader* pFader)
MA_API ma_result ma_fader_process_pcm_frames(ma_fader* pFader, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
MA_API void ma_fader_get_data_format(const ma_fader* pFader, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate);
MA_API void ma_fader_set_fade(ma_fader* pFader, float volumeBeg, float volumeEnd, ma_uint64 lengthInFrames);
-MA_API float ma_fader_get_current_volume(ma_fader* pFader);
+MA_API float ma_fader_get_current_volume(const ma_fader* pFader);
@@ -4865,6 +5058,12 @@ typedef struct
float z;
} ma_vec3f;
+typedef struct
+{
+ ma_vec3f v;
+ ma_spinlock lock;
+} ma_atomic_vec3f;
+
typedef enum
{
ma_attenuation_model_none, /* No distance attenuation and no spatialization. */
@@ -4904,9 +5103,9 @@ MA_API ma_spatializer_listener_config ma_spatializer_listener_config_init(ma_uin
typedef struct
{
ma_spatializer_listener_config config;
- ma_vec3f position; /* The absolute position of the listener. */
- ma_vec3f direction; /* The direction the listener is facing. The world up vector is config.worldUp. */
- ma_vec3f velocity;
+ ma_atomic_vec3f position; /* The absolute position of the listener. */
+ ma_atomic_vec3f direction; /* The direction the listener is facing. The world up vector is config.worldUp. */
+ ma_atomic_vec3f velocity;
ma_bool32 isEnabled;
/* Memory management. */
@@ -4953,6 +5152,7 @@ typedef struct
float coneOuterGain;
float dopplerFactor; /* Set to 0 to disable doppler effect. */
float directionalAttenuationFactor; /* Set to 0 to disable directional attenuation. */
+ float minSpatializationChannelGain; /* The minimal scaling factor to apply to channel gains when accounting for the direction of the sound relative to the listener. Must be in the range of 0..1. Smaller values means more aggressive directional panning, larger values means more subtle directional panning. */
ma_uint32 gainSmoothTimeInFrames; /* When the gain of a channel changes during spatialization, the transition will be linearly interpolated over this number of frames. */
} ma_spatializer_config;
@@ -4978,10 +5178,11 @@ typedef struct
float dopplerFactor; /* Set to 0 to disable doppler effect. */
float directionalAttenuationFactor; /* Set to 0 to disable directional attenuation. */
ma_uint32 gainSmoothTimeInFrames; /* When the gain of a channel changes during spatialization, the transition will be linearly interpolated over this number of frames. */
- ma_vec3f position;
- ma_vec3f direction;
- ma_vec3f velocity; /* For doppler effect. */
+ ma_atomic_vec3f position;
+ ma_atomic_vec3f direction;
+ ma_atomic_vec3f velocity; /* For doppler effect. */
float dopplerPitch; /* Will be updated by ma_spatializer_process_pcm_frames() and can be used by higher level functions to apply a pitch shift for doppler effect. */
+ float minSpatializationChannelGain;
ma_gainer gainer; /* For smooth gain transitions. */
float* pNewChannelGainsOut; /* An offset of _pHeap. Used by ma_spatializer_process_pcm_frames() to store new channel gains. The number of elements in this array is equal to config.channelsOut. */
@@ -4995,6 +5196,8 @@ MA_API ma_result ma_spatializer_init_preallocated(const ma_spatializer_config* p
MA_API ma_result ma_spatializer_init(const ma_spatializer_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_spatializer* pSpatializer);
MA_API void ma_spatializer_uninit(ma_spatializer* pSpatializer, const ma_allocation_callbacks* pAllocationCallbacks);
MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer, ma_spatializer_listener* pListener, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
+MA_API ma_result ma_spatializer_set_master_volume(ma_spatializer* pSpatializer, float volume);
+MA_API ma_result ma_spatializer_get_master_volume(const ma_spatializer* pSpatializer, float* pVolume);
MA_API ma_uint32 ma_spatializer_get_input_channels(const ma_spatializer* pSpatializer);
MA_API ma_uint32 ma_spatializer_get_output_channels(const ma_spatializer* pSpatializer);
MA_API void ma_spatializer_set_attenuation_model(ma_spatializer* pSpatializer, ma_attenuation_model attenuationModel);
@@ -5191,7 +5394,7 @@ MA_API ma_result ma_resampler_process_pcm_frames(ma_resampler* pResampler, const
/*
-Sets the input and output sample sample rate.
+Sets the input and output sample rate.
*/
MA_API ma_result ma_resampler_set_rate(ma_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut);
@@ -5264,6 +5467,7 @@ typedef struct
const ma_channel* pChannelMapIn;
const ma_channel* pChannelMapOut;
ma_channel_mix_mode mixingMode;
+ ma_bool32 calculateLFEFromSpatialChannels; /* When an output LFE channel is present, but no input LFE, set to true to set the output LFE to the average of all spatial channels (LR, FR, etc.). Ignored when an input LFE is present. */
float** ppWeights; /* [in][out]. Only used when mixingMode is set to ma_channel_mix_mode_custom_weights. */
} ma_channel_converter_config;
@@ -5316,6 +5520,7 @@ typedef struct
ma_channel* pChannelMapOut;
ma_dither_mode ditherMode;
ma_channel_mix_mode channelMixMode;
+ ma_bool32 calculateLFEFromSpatialChannels; /* When an output LFE channel is present, but no input LFE, set to true to set the output LFE to the average of all spatial channels (LR, FR, etc.). Ignored when an input LFE is present. */
float** ppChannelWeights; /* [in][out]. Only used when mixingMode is set to ma_channel_mix_mode_custom_weights. */
ma_bool32 allowDynamicSampleRate;
ma_resampler_config resampling;
@@ -5496,6 +5701,28 @@ The channel map buffer must have a capacity of at least `channels`.
*/
MA_API ma_bool32 ma_channel_map_contains_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition);
+/*
+Find a channel position in the given channel map. Returns MA_TRUE if the channel is found; MA_FALSE otherwise. The
+index of the channel is output to `pChannelIndex`.
+
+The channel map buffer must have a capacity of at least `channels`.
+*/
+MA_API ma_bool32 ma_channel_map_find_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition, ma_uint32* pChannelIndex);
+
+/*
+Generates a string representing the given channel map.
+
+This is for printing and debugging purposes, not serialization/deserialization.
+
+Returns the length of the string, not including the null terminator.
+*/
+MA_API size_t ma_channel_map_to_string(const ma_channel* pChannelMap, ma_uint32 channels, char* pBufferOut, size_t bufferCap);
+
+/*
+Retrieves a human readable version of a channel position.
+*/
+MA_API const char* ma_channel_position_to_string(ma_channel channel);
+
/************************************************************************************************************************************************************
@@ -5516,6 +5743,197 @@ MA_API ma_uint64 ma_convert_frames(void* pOut, ma_uint64 frameCountOut, ma_forma
MA_API ma_uint64 ma_convert_frames_ex(void* pOut, ma_uint64 frameCountOut, const void* pIn, ma_uint64 frameCountIn, const ma_data_converter_config* pConfig);
+/************************************************************************************************************************************************************
+
+Data Source
+
+************************************************************************************************************************************************************/
+typedef void ma_data_source;
+
+#define MA_DATA_SOURCE_SELF_MANAGED_RANGE_AND_LOOP_POINT 0x00000001
+
+typedef struct
+{
+ ma_result (* onRead)(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead);
+ ma_result (* onSeek)(ma_data_source* pDataSource, ma_uint64 frameIndex);
+ ma_result (* onGetDataFormat)(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap);
+ ma_result (* onGetCursor)(ma_data_source* pDataSource, ma_uint64* pCursor);
+ ma_result (* onGetLength)(ma_data_source* pDataSource, ma_uint64* pLength);
+ ma_result (* onSetLooping)(ma_data_source* pDataSource, ma_bool32 isLooping);
+ ma_uint32 flags;
+} ma_data_source_vtable;
+
+typedef ma_data_source* (* ma_data_source_get_next_proc)(ma_data_source* pDataSource);
+
+typedef struct
+{
+ const ma_data_source_vtable* vtable;
+} ma_data_source_config;
+
+MA_API ma_data_source_config ma_data_source_config_init(void);
+
+
+typedef struct
+{
+ const ma_data_source_vtable* vtable;
+ ma_uint64 rangeBegInFrames;
+ ma_uint64 rangeEndInFrames; /* Set to -1 for unranged (default). */
+ ma_uint64 loopBegInFrames; /* Relative to rangeBegInFrames. */
+ ma_uint64 loopEndInFrames; /* Relative to rangeBegInFrames. Set to -1 for the end of the range. */
+ ma_data_source* pCurrent; /* When non-NULL, the data source being initialized will act as a proxy and will route all operations to pCurrent. Used in conjunction with pNext/onGetNext for seamless chaining. */
+ ma_data_source* pNext; /* When set to NULL, onGetNext will be used. */
+ ma_data_source_get_next_proc onGetNext; /* Will be used when pNext is NULL. If both are NULL, no next will be used. */
+ MA_ATOMIC(4, ma_bool32) isLooping;
+} ma_data_source_base;
+
+MA_API ma_result ma_data_source_init(const ma_data_source_config* pConfig, ma_data_source* pDataSource);
+MA_API void ma_data_source_uninit(ma_data_source* pDataSource);
+MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); /* Must support pFramesOut = NULL in which case a forward seek should be performed. */
+MA_API ma_result ma_data_source_seek_pcm_frames(ma_data_source* pDataSource, ma_uint64 frameCount, ma_uint64* pFramesSeeked); /* Can only seek forward. Equivalent to ma_data_source_read_pcm_frames(pDataSource, NULL, frameCount, &framesRead); */
+MA_API ma_result ma_data_source_seek_to_pcm_frame(ma_data_source* pDataSource, ma_uint64 frameIndex);
+MA_API ma_result ma_data_source_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap);
+MA_API ma_result ma_data_source_get_cursor_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pCursor);
+MA_API ma_result ma_data_source_get_length_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pLength); /* Returns MA_NOT_IMPLEMENTED if the length is unknown or cannot be determined. Decoders can return this. */
+MA_API ma_result ma_data_source_get_cursor_in_seconds(ma_data_source* pDataSource, float* pCursor);
+MA_API ma_result ma_data_source_get_length_in_seconds(ma_data_source* pDataSource, float* pLength);
+MA_API ma_result ma_data_source_set_looping(ma_data_source* pDataSource, ma_bool32 isLooping);
+MA_API ma_bool32 ma_data_source_is_looping(const ma_data_source* pDataSource);
+MA_API ma_result ma_data_source_set_range_in_pcm_frames(ma_data_source* pDataSource, ma_uint64 rangeBegInFrames, ma_uint64 rangeEndInFrames);
+MA_API void ma_data_source_get_range_in_pcm_frames(const ma_data_source* pDataSource, ma_uint64* pRangeBegInFrames, ma_uint64* pRangeEndInFrames);
+MA_API ma_result ma_data_source_set_loop_point_in_pcm_frames(ma_data_source* pDataSource, ma_uint64 loopBegInFrames, ma_uint64 loopEndInFrames);
+MA_API void ma_data_source_get_loop_point_in_pcm_frames(const ma_data_source* pDataSource, ma_uint64* pLoopBegInFrames, ma_uint64* pLoopEndInFrames);
+MA_API ma_result ma_data_source_set_current(ma_data_source* pDataSource, ma_data_source* pCurrentDataSource);
+MA_API ma_data_source* ma_data_source_get_current(const ma_data_source* pDataSource);
+MA_API ma_result ma_data_source_set_next(ma_data_source* pDataSource, ma_data_source* pNextDataSource);
+MA_API ma_data_source* ma_data_source_get_next(const ma_data_source* pDataSource);
+MA_API ma_result ma_data_source_set_next_callback(ma_data_source* pDataSource, ma_data_source_get_next_proc onGetNext);
+MA_API ma_data_source_get_next_proc ma_data_source_get_next_callback(const ma_data_source* pDataSource);
+
+
+typedef struct
+{
+ ma_data_source_base ds;
+ ma_format format;
+ ma_uint32 channels;
+ ma_uint32 sampleRate;
+ ma_uint64 cursor;
+ ma_uint64 sizeInFrames;
+ const void* pData;
+} ma_audio_buffer_ref;
+
+MA_API ma_result ma_audio_buffer_ref_init(ma_format format, ma_uint32 channels, const void* pData, ma_uint64 sizeInFrames, ma_audio_buffer_ref* pAudioBufferRef);
+MA_API void ma_audio_buffer_ref_uninit(ma_audio_buffer_ref* pAudioBufferRef);
+MA_API ma_result ma_audio_buffer_ref_set_data(ma_audio_buffer_ref* pAudioBufferRef, const void* pData, ma_uint64 sizeInFrames);
+MA_API ma_uint64 ma_audio_buffer_ref_read_pcm_frames(ma_audio_buffer_ref* pAudioBufferRef, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop);
+MA_API ma_result ma_audio_buffer_ref_seek_to_pcm_frame(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameIndex);
+MA_API ma_result ma_audio_buffer_ref_map(ma_audio_buffer_ref* pAudioBufferRef, void** ppFramesOut, ma_uint64* pFrameCount);
+MA_API ma_result ma_audio_buffer_ref_unmap(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameCount); /* Returns MA_AT_END if the end has been reached. This should be considered successful. */
+MA_API ma_bool32 ma_audio_buffer_ref_at_end(const ma_audio_buffer_ref* pAudioBufferRef);
+MA_API ma_result ma_audio_buffer_ref_get_cursor_in_pcm_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pCursor);
+MA_API ma_result ma_audio_buffer_ref_get_length_in_pcm_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pLength);
+MA_API ma_result ma_audio_buffer_ref_get_available_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pAvailableFrames);
+
+
+
+typedef struct
+{
+ ma_format format;
+ ma_uint32 channels;
+ ma_uint32 sampleRate;
+ ma_uint64 sizeInFrames;
+ const void* pData; /* If set to NULL, will allocate a block of memory for you. */
+ ma_allocation_callbacks allocationCallbacks;
+} ma_audio_buffer_config;
+
+MA_API ma_audio_buffer_config ma_audio_buffer_config_init(ma_format format, ma_uint32 channels, ma_uint64 sizeInFrames, const void* pData, const ma_allocation_callbacks* pAllocationCallbacks);
+
+typedef struct
+{
+ ma_audio_buffer_ref ref;
+ ma_allocation_callbacks allocationCallbacks;
+ ma_bool32 ownsData; /* Used to control whether or not miniaudio owns the data buffer. If set to true, pData will be freed in ma_audio_buffer_uninit(). */
+ ma_uint8 _pExtraData[1]; /* For allocating a buffer with the memory located directly after the other memory of the structure. */
+} ma_audio_buffer;
+
+MA_API ma_result ma_audio_buffer_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer);
+MA_API ma_result ma_audio_buffer_init_copy(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer);
+MA_API ma_result ma_audio_buffer_alloc_and_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer** ppAudioBuffer); /* Always copies the data. Doesn't make sense to use this otherwise. Use ma_audio_buffer_uninit_and_free() to uninit. */
+MA_API void ma_audio_buffer_uninit(ma_audio_buffer* pAudioBuffer);
+MA_API void ma_audio_buffer_uninit_and_free(ma_audio_buffer* pAudioBuffer);
+MA_API ma_uint64 ma_audio_buffer_read_pcm_frames(ma_audio_buffer* pAudioBuffer, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop);
+MA_API ma_result ma_audio_buffer_seek_to_pcm_frame(ma_audio_buffer* pAudioBuffer, ma_uint64 frameIndex);
+MA_API ma_result ma_audio_buffer_map(ma_audio_buffer* pAudioBuffer, void** ppFramesOut, ma_uint64* pFrameCount);
+MA_API ma_result ma_audio_buffer_unmap(ma_audio_buffer* pAudioBuffer, ma_uint64 frameCount); /* Returns MA_AT_END if the end has been reached. This should be considered successful. */
+MA_API ma_bool32 ma_audio_buffer_at_end(const ma_audio_buffer* pAudioBuffer);
+MA_API ma_result ma_audio_buffer_get_cursor_in_pcm_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pCursor);
+MA_API ma_result ma_audio_buffer_get_length_in_pcm_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pLength);
+MA_API ma_result ma_audio_buffer_get_available_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pAvailableFrames);
+
+
+/*
+Paged Audio Buffer
+==================
+A paged audio buffer is made up of a linked list of pages. It's expandable, but not shrinkable. It
+can be used for cases where audio data is streamed in asynchronously while allowing data to be read
+at the same time.
+
+This is lock-free, but not 100% thread safe. You can append a page and read from the buffer across
+simultaneously across different threads, however only one thread at a time can append, and only one
+thread at a time can read and seek.
+*/
+typedef struct ma_paged_audio_buffer_page ma_paged_audio_buffer_page;
+struct ma_paged_audio_buffer_page
+{
+ MA_ATOMIC(MA_SIZEOF_PTR, ma_paged_audio_buffer_page*) pNext;
+ ma_uint64 sizeInFrames;
+ ma_uint8 pAudioData[1];
+};
+
+typedef struct
+{
+ ma_format format;
+ ma_uint32 channels;
+ ma_paged_audio_buffer_page head; /* Dummy head for the lock-free algorithm. Always has a size of 0. */
+ MA_ATOMIC(MA_SIZEOF_PTR, ma_paged_audio_buffer_page*) pTail; /* Never null. Initially set to &head. */
+} ma_paged_audio_buffer_data;
+
+MA_API ma_result ma_paged_audio_buffer_data_init(ma_format format, ma_uint32 channels, ma_paged_audio_buffer_data* pData);
+MA_API void ma_paged_audio_buffer_data_uninit(ma_paged_audio_buffer_data* pData, const ma_allocation_callbacks* pAllocationCallbacks);
+MA_API ma_paged_audio_buffer_page* ma_paged_audio_buffer_data_get_head(ma_paged_audio_buffer_data* pData);
+MA_API ma_paged_audio_buffer_page* ma_paged_audio_buffer_data_get_tail(ma_paged_audio_buffer_data* pData);
+MA_API ma_result ma_paged_audio_buffer_data_get_length_in_pcm_frames(ma_paged_audio_buffer_data* pData, ma_uint64* pLength);
+MA_API ma_result ma_paged_audio_buffer_data_allocate_page(ma_paged_audio_buffer_data* pData, ma_uint64 pageSizeInFrames, const void* pInitialData, const ma_allocation_callbacks* pAllocationCallbacks, ma_paged_audio_buffer_page** ppPage);
+MA_API ma_result ma_paged_audio_buffer_data_free_page(ma_paged_audio_buffer_data* pData, ma_paged_audio_buffer_page* pPage, const ma_allocation_callbacks* pAllocationCallbacks);
+MA_API ma_result ma_paged_audio_buffer_data_append_page(ma_paged_audio_buffer_data* pData, ma_paged_audio_buffer_page* pPage);
+MA_API ma_result ma_paged_audio_buffer_data_allocate_and_append_page(ma_paged_audio_buffer_data* pData, ma_uint32 pageSizeInFrames, const void* pInitialData, const ma_allocation_callbacks* pAllocationCallbacks);
+
+
+typedef struct
+{
+ ma_paged_audio_buffer_data* pData; /* Must not be null. */
+} ma_paged_audio_buffer_config;
+
+MA_API ma_paged_audio_buffer_config ma_paged_audio_buffer_config_init(ma_paged_audio_buffer_data* pData);
+
+
+typedef struct
+{
+ ma_data_source_base ds;
+ ma_paged_audio_buffer_data* pData; /* Audio data is read from here. Cannot be null. */
+ ma_paged_audio_buffer_page* pCurrent;
+ ma_uint64 relativeCursor; /* Relative to the current page. */
+ ma_uint64 absoluteCursor;
+} ma_paged_audio_buffer;
+
+MA_API ma_result ma_paged_audio_buffer_init(const ma_paged_audio_buffer_config* pConfig, ma_paged_audio_buffer* pPagedAudioBuffer);
+MA_API void ma_paged_audio_buffer_uninit(ma_paged_audio_buffer* pPagedAudioBuffer);
+MA_API ma_result ma_paged_audio_buffer_read_pcm_frames(ma_paged_audio_buffer* pPagedAudioBuffer, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); /* Returns MA_AT_END if no more pages available. */
+MA_API ma_result ma_paged_audio_buffer_seek_to_pcm_frame(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64 frameIndex);
+MA_API ma_result ma_paged_audio_buffer_get_cursor_in_pcm_frames(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64* pCursor);
+MA_API ma_result ma_paged_audio_buffer_get_length_in_pcm_frames(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64* pLength);
+
+
+
/************************************************************************************************************************************************************
Ring Buffer
@@ -5555,9 +5973,11 @@ MA_API void* ma_rb_get_subbuffer_ptr(ma_rb* pRB, size_t subbufferIndex, void* pB
typedef struct
{
+ ma_data_source_base ds;
ma_rb rb;
ma_format format;
ma_uint32 channels;
+ ma_uint32 sampleRate; /* Not required for the ring buffer itself, but useful for associating the data with some sample rate, particularly for data sources. */
} ma_pcm_rb;
MA_API ma_result ma_pcm_rb_init_ex(ma_format format, ma_uint32 channels, ma_uint32 subbufferSizeInFrames, ma_uint32 subbufferCount, ma_uint32 subbufferStrideInFrames, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_pcm_rb* pRB);
@@ -5577,6 +5997,10 @@ MA_API ma_uint32 ma_pcm_rb_get_subbuffer_size(ma_pcm_rb* pRB);
MA_API ma_uint32 ma_pcm_rb_get_subbuffer_stride(ma_pcm_rb* pRB);
MA_API ma_uint32 ma_pcm_rb_get_subbuffer_offset(ma_pcm_rb* pRB, ma_uint32 subbufferIndex);
MA_API void* ma_pcm_rb_get_subbuffer_ptr(ma_pcm_rb* pRB, ma_uint32 subbufferIndex, void* pBuffer);
+MA_API ma_format ma_pcm_rb_get_format(const ma_pcm_rb* pRB);
+MA_API ma_uint32 ma_pcm_rb_get_channels(const ma_pcm_rb* pRB);
+MA_API ma_uint32 ma_pcm_rb_get_sample_rate(const ma_pcm_rb* pRB);
+MA_API void ma_pcm_rb_set_sample_rate(ma_pcm_rb* pRB, ma_uint32 sampleRate);
/*
@@ -6087,15 +6511,20 @@ This section contains the APIs for device playback and capture. Here is where yo
/* Some backends are only supported on certain platforms. */
#if defined(MA_WIN32)
#define MA_SUPPORT_WASAPI
- #if defined(MA_WIN32_DESKTOP) /* DirectSound and WinMM backends are only supported on desktops. */
+
+ #if defined(MA_WIN32_DESKTOP) /* DirectSound and WinMM backends are only supported on desktops. */
#define MA_SUPPORT_DSOUND
#define MA_SUPPORT_WINMM
- #define MA_SUPPORT_JACK /* JACK is technically supported on Windows, but I don't know how many people use it in practice... */
+
+ /* Don't enable JACK here if compiling with Cosmopolitan. It'll be enabled in the Linux section below. */
+ #if !defined(__COSMOPOLITAN__)
+ #define MA_SUPPORT_JACK /* JACK is technically supported on Windows, but I don't know how many people use it in practice... */
+ #endif
#endif
#endif
-#if defined(MA_UNIX)
+#if defined(MA_UNIX) && !defined(MA_ORBIS) && !defined(MA_PROSPERO)
#if defined(MA_LINUX)
- #if !defined(MA_ANDROID) /* ALSA is not supported on Android. */
+ #if !defined(MA_ANDROID) && !defined(__COSMOPOLITAN__) /* ALSA is not supported on Android. */
#define MA_SUPPORT_ALSA
#endif
#endif
@@ -6103,10 +6532,6 @@ This section contains the APIs for device playback and capture. Here is where yo
#define MA_SUPPORT_PULSEAUDIO
#define MA_SUPPORT_JACK
#endif
- #if defined(MA_ANDROID)
- #define MA_SUPPORT_AAUDIO
- #define MA_SUPPORT_OPENSL
- #endif
#if defined(__OpenBSD__) /* <-- Change this to "#if defined(MA_BSD)" to enable sndio on all BSD flavors. */
#define MA_SUPPORT_SNDIO /* sndio is only supported on OpenBSD for now. May be expanded later if there's demand. */
#endif
@@ -6117,6 +6542,10 @@ This section contains the APIs for device playback and capture. Here is where yo
#define MA_SUPPORT_OSS /* Only support OSS on specific platforms with known support. */
#endif
#endif
+#if defined(MA_ANDROID)
+ #define MA_SUPPORT_AAUDIO
+ #define MA_SUPPORT_OPENSL
+#endif
#if defined(MA_APPLE)
#define MA_SUPPORT_COREAUDIO
#endif
@@ -6188,6 +6617,9 @@ typedef enum
ma_device_state_stopping = 4 /* Transitioning from a started state to stopped. */
} ma_device_state;
+MA_ATOMIC_SAFE_TYPE_DECL(i32, 4, device_state)
+
+
#ifdef MA_SUPPORT_WASAPI
/* We need a IMMNotificationClient object for WASAPI. */
typedef struct
@@ -6380,7 +6812,7 @@ DEPRECATED. Use ma_device_notification_proc instead.
The callback for when the device has been stopped.
This will be called when the device is stopped explicitly with `ma_device_stop()` and also called implicitly when the device is stopped through external forces
-such as being unplugged or an internal error occuring.
+such as being unplugged or an internal error occurring.
Parameters
@@ -6412,7 +6844,7 @@ typedef enum
/* iOS/tvOS/watchOS session categories. */
typedef enum
{
- ma_ios_session_category_default = 0, /* AVAudioSessionCategoryPlayAndRecord with AVAudioSessionCategoryOptionDefaultToSpeaker. */
+ ma_ios_session_category_default = 0, /* AVAudioSessionCategoryPlayAndRecord. */
ma_ios_session_category_none, /* Leave the session category unchanged. */
ma_ios_session_category_ambient, /* AVAudioSessionCategoryAmbient */
ma_ios_session_category_solo_ambient, /* AVAudioSessionCategorySoloAmbient */
@@ -6457,36 +6889,44 @@ typedef enum
ma_opensl_recording_preset_voice_unprocessed /* SL_ANDROID_RECORDING_PRESET_UNPROCESSED */
} ma_opensl_recording_preset;
+/* WASAPI audio thread priority characteristics. */
+typedef enum
+{
+ ma_wasapi_usage_default = 0,
+ ma_wasapi_usage_games,
+ ma_wasapi_usage_pro_audio,
+} ma_wasapi_usage;
+
/* AAudio usage types. */
typedef enum
{
ma_aaudio_usage_default = 0, /* Leaves the usage type unset. */
- ma_aaudio_usage_announcement, /* AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT */
- ma_aaudio_usage_emergency, /* AAUDIO_SYSTEM_USAGE_EMERGENCY */
- ma_aaudio_usage_safety, /* AAUDIO_SYSTEM_USAGE_SAFETY */
- ma_aaudio_usage_vehicle_status, /* AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS */
+ ma_aaudio_usage_media, /* AAUDIO_USAGE_MEDIA */
+ ma_aaudio_usage_voice_communication, /* AAUDIO_USAGE_VOICE_COMMUNICATION */
+ ma_aaudio_usage_voice_communication_signalling, /* AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING */
ma_aaudio_usage_alarm, /* AAUDIO_USAGE_ALARM */
+ ma_aaudio_usage_notification, /* AAUDIO_USAGE_NOTIFICATION */
+ ma_aaudio_usage_notification_ringtone, /* AAUDIO_USAGE_NOTIFICATION_RINGTONE */
+ ma_aaudio_usage_notification_event, /* AAUDIO_USAGE_NOTIFICATION_EVENT */
ma_aaudio_usage_assistance_accessibility, /* AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY */
ma_aaudio_usage_assistance_navigation_guidance, /* AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE */
ma_aaudio_usage_assistance_sonification, /* AAUDIO_USAGE_ASSISTANCE_SONIFICATION */
- ma_aaudio_usage_assitant, /* AAUDIO_USAGE_ASSISTANT */
ma_aaudio_usage_game, /* AAUDIO_USAGE_GAME */
- ma_aaudio_usage_media, /* AAUDIO_USAGE_MEDIA */
- ma_aaudio_usage_notification, /* AAUDIO_USAGE_NOTIFICATION */
- ma_aaudio_usage_notification_event, /* AAUDIO_USAGE_NOTIFICATION_EVENT */
- ma_aaudio_usage_notification_ringtone, /* AAUDIO_USAGE_NOTIFICATION_RINGTONE */
- ma_aaudio_usage_voice_communication, /* AAUDIO_USAGE_VOICE_COMMUNICATION */
- ma_aaudio_usage_voice_communication_signalling /* AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING */
+ ma_aaudio_usage_assitant, /* AAUDIO_USAGE_ASSISTANT */
+ ma_aaudio_usage_emergency, /* AAUDIO_SYSTEM_USAGE_EMERGENCY */
+ ma_aaudio_usage_safety, /* AAUDIO_SYSTEM_USAGE_SAFETY */
+ ma_aaudio_usage_vehicle_status, /* AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS */
+ ma_aaudio_usage_announcement /* AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT */
} ma_aaudio_usage;
/* AAudio content types. */
typedef enum
{
ma_aaudio_content_type_default = 0, /* Leaves the content type unset. */
- ma_aaudio_content_type_movie, /* AAUDIO_CONTENT_TYPE_MOVIE */
+ ma_aaudio_content_type_speech, /* AAUDIO_CONTENT_TYPE_SPEECH */
ma_aaudio_content_type_music, /* AAUDIO_CONTENT_TYPE_MUSIC */
- ma_aaudio_content_type_sonification, /* AAUDIO_CONTENT_TYPE_SONIFICATION */
- ma_aaudio_content_type_speech /* AAUDIO_CONTENT_TYPE_SPEECH */
+ ma_aaudio_content_type_movie, /* AAUDIO_CONTENT_TYPE_MOVIE */
+ ma_aaudio_content_type_sonification /* AAUDIO_CONTENT_TYPE_SONIFICATION */
} ma_aaudio_content_type;
/* AAudio input presets. */
@@ -6495,12 +6935,19 @@ typedef enum
ma_aaudio_input_preset_default = 0, /* Leaves the input preset unset. */
ma_aaudio_input_preset_generic, /* AAUDIO_INPUT_PRESET_GENERIC */
ma_aaudio_input_preset_camcorder, /* AAUDIO_INPUT_PRESET_CAMCORDER */
- ma_aaudio_input_preset_unprocessed, /* AAUDIO_INPUT_PRESET_UNPROCESSED */
ma_aaudio_input_preset_voice_recognition, /* AAUDIO_INPUT_PRESET_VOICE_RECOGNITION */
ma_aaudio_input_preset_voice_communication, /* AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION */
+ ma_aaudio_input_preset_unprocessed, /* AAUDIO_INPUT_PRESET_UNPROCESSED */
ma_aaudio_input_preset_voice_performance /* AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE */
} ma_aaudio_input_preset;
+typedef enum
+{
+ ma_aaudio_allow_capture_default = 0, /* Leaves the allowed capture policy unset. */
+ ma_aaudio_allow_capture_by_all, /* AAUDIO_ALLOW_CAPTURE_BY_ALL */
+ ma_aaudio_allow_capture_by_system, /* AAUDIO_ALLOW_CAPTURE_BY_SYSTEM */
+ ma_aaudio_allow_capture_by_none /* AAUDIO_ALLOW_CAPTURE_BY_NONE */
+} ma_aaudio_allowed_capture_policy;
typedef union
{
@@ -6510,7 +6957,7 @@ typedef union
typedef union
{
- wchar_t wasapi[64]; /* WASAPI uses a wchar_t string for identification. */
+ ma_wchar_win32 wasapi[64]; /* WASAPI uses a wchar_t string for identification. */
ma_uint8 dsound[16]; /* DirectSound uses a GUID for identification. */
/*UINT_PTR*/ ma_uint32 winmm; /* When creating a device, WinMM expects a Win32 UINT_PTR for device identification. In practice it's actually just a UINT. */
char alsa[256]; /* ALSA uses a name string for identification. */
@@ -6584,6 +7031,7 @@ struct ma_device_config
ma_uint32 channels;
ma_channel* pChannelMap;
ma_channel_mix_mode channelMixMode;
+ ma_bool32 calculateLFEFromSpatialChannels; /* When an output LFE channel is present, but no input LFE, set to true to set the output LFE to the average of all spatial channels (LR, FR, etc.). Ignored when an input LFE is present. */
ma_share_mode shareMode;
} playback;
struct
@@ -6593,15 +7041,19 @@ struct ma_device_config
ma_uint32 channels;
ma_channel* pChannelMap;
ma_channel_mix_mode channelMixMode;
+ ma_bool32 calculateLFEFromSpatialChannels; /* When an output LFE channel is present, but no input LFE, set to true to set the output LFE to the average of all spatial channels (LR, FR, etc.). Ignored when an input LFE is present. */
ma_share_mode shareMode;
} capture;
struct
{
- ma_bool8 noAutoConvertSRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */
- ma_bool8 noDefaultQualitySRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */
- ma_bool8 noAutoStreamRouting; /* Disables automatic stream routing. */
- ma_bool8 noHardwareOffloading; /* Disables WASAPI's hardware offloading feature. */
+ ma_wasapi_usage usage; /* When configured, uses Avrt APIs to set the thread characteristics. */
+ ma_bool8 noAutoConvertSRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */
+ ma_bool8 noDefaultQualitySRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */
+ ma_bool8 noAutoStreamRouting; /* Disables automatic stream routing. */
+ ma_bool8 noHardwareOffloading; /* Disables WASAPI's hardware offloading feature. */
+ ma_uint32 loopbackProcessID; /* The process ID to include or exclude for loopback mode. Set to 0 to capture audio from all processes. Ignored when an explicit device ID is specified. */
+ ma_bool8 loopbackProcessExclude; /* When set to true, excludes the process specified by loopbackProcessID. By default, the process will be included. */
} wasapi;
struct
{
@@ -6623,13 +7075,16 @@ struct ma_device_config
{
ma_opensl_stream_type streamType;
ma_opensl_recording_preset recordingPreset;
+ ma_bool32 enableCompatibilityWorkarounds;
} opensl;
struct
{
ma_aaudio_usage usage;
ma_aaudio_content_type contentType;
ma_aaudio_input_preset inputPreset;
+ ma_aaudio_allowed_capture_policy allowedCapturePolicy;
ma_bool32 noAutoStartAfterReroute;
+ ma_bool32 enableCompatibilityWorkarounds;
} aaudio;
};
@@ -6714,7 +7169,7 @@ sample rate. For the channel map, the default should be used when `ma_channel_ma
`MA_CHANNEL_NONE`). On input, the `periodSizeInFrames` or `periodSizeInMilliseconds` option should always be set. The backend should
inspect both of these variables. If `periodSizeInFrames` is set, it should take priority, otherwise it needs to be derived from the period
size in milliseconds (`periodSizeInMilliseconds`) and the sample rate, keeping in mind that the sample rate may be 0, in which case the
-sample rate will need to be determined before calculating the period size in frames. On output, all members of the `ma_device_data_format`
+sample rate will need to be determined before calculating the period size in frames. On output, all members of the `ma_device_descriptor`
object should be set to a valid value, except for `periodSizeInMilliseconds` which is optional (`periodSizeInFrames` *must* be set).
Starting and stopping of the device is done with `onDeviceStart()` and `onDeviceStop()` and should be self-explanatory. If the backend uses
@@ -6730,7 +7185,7 @@ If the backend requires absolute flexibility with it's data delivery, it can opt
which will allow it to implement the logic that will run on the audio thread. This is much more advanced and is completely optional.
The audio thread should run data delivery logic in a loop while `ma_device_get_state() == ma_device_state_started` and no errors have been
-encounted. Do not start or stop the device here. That will be handled from outside the `onDeviceDataLoop()` callback.
+encountered. Do not start or stop the device here. That will be handled from outside the `onDeviceDataLoop()` callback.
The invocation of the `onDeviceDataLoop()` callback will be handled by miniaudio. When you start the device, miniaudio will fire this
callback. When the device is stopped, the `ma_device_get_state() == ma_device_state_started` condition will fail and the loop will be terminated
@@ -6844,6 +7299,11 @@ struct ma_context
ma_uint32 commandIndex;
ma_uint32 commandCount;
ma_context_command__wasapi commands[4];
+ ma_handle hAvrt;
+ ma_proc AvSetMmThreadCharacteristicsA;
+ ma_proc AvRevertMmThreadcharacteristics;
+ ma_handle hMMDevapi;
+ ma_proc ActivateAudioInterfaceAsync;
} wasapi;
#endif
#ifdef MA_SUPPORT_DSOUND
@@ -7138,6 +7598,7 @@ struct ma_context
ma_proc AAudioStreamBuilder_setUsage;
ma_proc AAudioStreamBuilder_setContentType;
ma_proc AAudioStreamBuilder_setInputPreset;
+ ma_proc AAudioStreamBuilder_setAllowedCapturePolicy;
ma_proc AAudioStreamBuilder_openStream;
ma_proc AAudioStream_close;
ma_proc AAudioStream_getState;
@@ -7183,10 +7644,11 @@ struct ma_context
union
{
-#ifdef MA_WIN32
+#if defined(MA_WIN32)
struct
{
/*HMODULE*/ ma_handle hOle32DLL;
+ ma_proc CoInitialize;
ma_proc CoInitializeEx;
ma_proc CoUninitialize;
ma_proc CoCreateInstance;
@@ -7207,22 +7669,7 @@ struct ma_context
#ifdef MA_POSIX
struct
{
- ma_handle pthreadSO;
- ma_proc pthread_create;
- ma_proc pthread_join;
- ma_proc pthread_mutex_init;
- ma_proc pthread_mutex_destroy;
- ma_proc pthread_mutex_lock;
- ma_proc pthread_mutex_unlock;
- ma_proc pthread_cond_init;
- ma_proc pthread_cond_destroy;
- ma_proc pthread_cond_wait;
- ma_proc pthread_cond_signal;
- ma_proc pthread_attr_init;
- ma_proc pthread_attr_destroy;
- ma_proc pthread_attr_setschedpolicy;
- ma_proc pthread_attr_getschedparam;
- ma_proc pthread_attr_setschedparam;
+ int _unused;
} posix;
#endif
int _unused;
@@ -7234,7 +7681,7 @@ struct ma_device
ma_context* pContext;
ma_device_type type;
ma_uint32 sampleRate;
- MA_ATOMIC(4, ma_device_state) state; /* The state of the device is variable and can change at any time on any thread. Must be used atomically. */
+ ma_atomic_device_state state; /* The state of the device is variable and can change at any time on any thread. Must be used atomically. */
ma_device_data_proc onData; /* Set once at initialization time and should not be changed after. */
ma_device_notification_proc onNotification; /* Set once at initialization time and should not be changed after. */
ma_stop_proc onStop; /* DEPRECATED. Use the notification callback instead. Set once at initialization time and should not be changed after. */
@@ -7250,7 +7697,7 @@ struct ma_device
ma_bool8 noClip;
ma_bool8 noDisableDenormals;
ma_bool8 noFixedSizedCallback;
- MA_ATOMIC(4, float) masterVolumeFactor; /* Linear 0..1. Can be read and written simultaneously by different threads. Must be used atomically. */
+ ma_atomic_float masterVolumeFactor; /* Linear 0..1. Can be read and written simultaneously by different threads. Must be used atomically. */
ma_duplex_rb duplexRB; /* Intermediary buffer for duplex device on asynchronous backends. */
struct
{
@@ -7278,6 +7725,7 @@ struct ma_device
ma_uint32 internalPeriodSizeInFrames;
ma_uint32 internalPeriods;
ma_channel_mix_mode channelMixMode;
+ ma_bool32 calculateLFEFromSpatialChannels;
ma_data_converter converter;
void* pIntermediaryBuffer; /* For implementing fixed sized buffer callbacks. Will be null if using variable sized callbacks. */
ma_uint32 intermediaryBufferCap;
@@ -7303,6 +7751,7 @@ struct ma_device
ma_uint32 internalPeriodSizeInFrames;
ma_uint32 internalPeriods;
ma_channel_mix_mode channelMixMode;
+ ma_bool32 calculateLFEFromSpatialChannels;
ma_data_converter converter;
void* pIntermediaryBuffer; /* For implementing fixed sized buffer callbacks. Will be null if using variable sized callbacks. */
ma_uint32 intermediaryBufferCap;
@@ -7336,8 +7785,10 @@ struct ma_device
void* pMappedBufferPlayback;
ma_uint32 mappedBufferPlaybackCap;
ma_uint32 mappedBufferPlaybackLen;
- MA_ATOMIC(4, ma_bool32) isStartedCapture; /* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
- MA_ATOMIC(4, ma_bool32) isStartedPlayback; /* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
+ ma_atomic_bool32 isStartedCapture; /* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
+ ma_atomic_bool32 isStartedPlayback; /* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
+ ma_uint32 loopbackProcessID;
+ ma_bool8 loopbackProcessExclude;
ma_bool8 noAutoConvertSRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */
ma_bool8 noDefaultQualitySRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */
ma_bool8 noHardwareOffloading;
@@ -7345,6 +7796,9 @@ struct ma_device
ma_bool8 allowPlaybackAutoStreamRouting;
ma_bool8 isDetachedPlayback;
ma_bool8 isDetachedCapture;
+ ma_wasapi_usage usage;
+ void* hAvrtHandle;
+ ma_mutex rerouteLock;
} wasapi;
#endif
#ifdef MA_SUPPORT_DSOUND
@@ -7462,6 +7916,7 @@ struct ma_device
ma_aaudio_usage usage;
ma_aaudio_content_type contentType;
ma_aaudio_input_preset inputPreset;
+ ma_aaudio_allowed_capture_policy allowedCapturePolicy;
ma_bool32 noAutoStartAfterReroute;
} aaudio;
#endif
@@ -7487,6 +7942,20 @@ struct ma_device
#ifdef MA_SUPPORT_WEBAUDIO
struct
{
+ /* AudioWorklets path. */
+ /* EMSCRIPTEN_WEBAUDIO_T */ int audioContextPlayback;
+ /* EMSCRIPTEN_WEBAUDIO_T */ int audioContextCapture;
+ /* EMSCRIPTEN_AUDIO_WORKLET_NODE_T */ int workletNodePlayback;
+ /* EMSCRIPTEN_AUDIO_WORKLET_NODE_T */ int workletNodeCapture;
+ size_t intermediaryBufferSizeInFramesPlayback;
+ size_t intermediaryBufferSizeInFramesCapture;
+ float* pIntermediaryBufferPlayback;
+ float* pIntermediaryBufferCapture;
+ void* pStackBufferPlayback;
+ void* pStackBufferCapture;
+ ma_bool32 isInitialized;
+
+ /* ScriptProcessorNode path. */
int indexPlayback; /* We use a factory on the JavaScript side to manage devices and use an index for JS/C interop. */
int indexCapture;
} webaudio;
@@ -7506,7 +7975,7 @@ struct ma_device
ma_uint32 currentPeriodFramesRemainingCapture;
ma_uint64 lastProcessedFramePlayback;
ma_uint64 lastProcessedFrameCapture;
- MA_ATOMIC(4, ma_bool32) isStarted; /* Read and written by multiple threads. Must be used atomically, and must be 32-bit for compiler compatibility. */
+ ma_atomic_bool32 isStarted; /* Read and written by multiple threads. Must be used atomically, and must be 32-bit for compiler compatibility. */
} null_device;
#endif
};
@@ -8146,9 +8615,9 @@ then be set directly on the structure. Below are the members of the `ma_device_c
By default, miniaudio will disable denormals when the data callback is called. Setting this to true will prevent the disabling of denormals.
noFixedSizedCallback
- Allows miniaudio to fire the data callback with any frame count. When this is set to true, the data callback will be fired with a consistent frame
- count as specified by `periodSizeInFrames` or `periodSizeInMilliseconds`. When set to false, miniaudio will fire the callback with whatever the
- backend requests, which could be anything.
+ Allows miniaudio to fire the data callback with any frame count. When this is set to false (the default), the data callback will be fired with a
+ consistent frame count as specified by `periodSizeInFrames` or `periodSizeInMilliseconds`. When set to true, miniaudio will fire the callback with
+ whatever the backend requests, which could be anything.
dataCallback
The callback to fire whenever data is ready to be delivered to or from the device.
@@ -8170,7 +8639,7 @@ then be set directly on the structure. Below are the members of the `ma_device_c
A pointer that will passed to callbacks in pBackendVTable.
resampling.linear.lpfOrder
- The linear resampler applies a low-pass filter as part of it's procesing for anti-aliasing. This setting controls the order of the filter. The higher
+ The linear resampler applies a low-pass filter as part of it's processing for anti-aliasing. This setting controls the order of the filter. The higher
the value, the better the quality, in general. Setting this to 0 will disable low-pass filtering altogether. The maximum value is
`MA_MAX_FILTER_ORDER`. The default value is `min(4, MA_MAX_FILTER_ORDER)`.
@@ -9088,6 +9557,11 @@ Retrieves a friendly name for a backend.
*/
MA_API const char* ma_get_backend_name(ma_backend backend);
+/*
+Retrieves the backend enum from the given name.
+*/
+MA_API ma_result ma_get_backend_from_name(const char* pBackendName, ma_backend* pBackend);
+
/*
Determines whether or not the given backend is available by the compilation environment.
*/
@@ -9177,7 +9651,7 @@ MA_API ma_bool32 ma_is_loopback_supported(ma_backend backend);
/************************************************************************************************************************************************************
-Utiltities
+Utilities
************************************************************************************************************************************************************/
@@ -9279,196 +9753,13 @@ Helper for converting gain in decibels to a linear factor.
MA_API float ma_volume_db_to_linear(float gain);
-
-
-/**************************************************************************************************
-
-Data Source
-
-**************************************************************************************************/
-typedef void ma_data_source;
-
-#define MA_DATA_SOURCE_SELF_MANAGED_RANGE_AND_LOOP_POINT 0x00000001
-
-typedef struct
-{
- ma_result (* onRead)(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead);
- ma_result (* onSeek)(ma_data_source* pDataSource, ma_uint64 frameIndex);
- ma_result (* onGetDataFormat)(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap);
- ma_result (* onGetCursor)(ma_data_source* pDataSource, ma_uint64* pCursor);
- ma_result (* onGetLength)(ma_data_source* pDataSource, ma_uint64* pLength);
- ma_result (* onSetLooping)(ma_data_source* pDataSource, ma_bool32 isLooping);
- ma_uint32 flags;
-} ma_data_source_vtable;
-
-typedef ma_data_source* (* ma_data_source_get_next_proc)(ma_data_source* pDataSource);
-
-typedef struct
-{
- const ma_data_source_vtable* vtable;
-} ma_data_source_config;
-
-MA_API ma_data_source_config ma_data_source_config_init(void);
-
-
-typedef struct
-{
- const ma_data_source_vtable* vtable;
- ma_uint64 rangeBegInFrames;
- ma_uint64 rangeEndInFrames; /* Set to -1 for unranged (default). */
- ma_uint64 loopBegInFrames; /* Relative to rangeBegInFrames. */
- ma_uint64 loopEndInFrames; /* Relative to rangeBegInFrames. Set to -1 for the end of the range. */
- ma_data_source* pCurrent; /* When non-NULL, the data source being initialized will act as a proxy and will route all operations to pCurrent. Used in conjunction with pNext/onGetNext for seamless chaining. */
- ma_data_source* pNext; /* When set to NULL, onGetNext will be used. */
- ma_data_source_get_next_proc onGetNext; /* Will be used when pNext is NULL. If both are NULL, no next will be used. */
- MA_ATOMIC(4, ma_bool32) isLooping;
-} ma_data_source_base;
-
-MA_API ma_result ma_data_source_init(const ma_data_source_config* pConfig, ma_data_source* pDataSource);
-MA_API void ma_data_source_uninit(ma_data_source* pDataSource);
-MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); /* Must support pFramesOut = NULL in which case a forward seek should be performed. */
-MA_API ma_result ma_data_source_seek_pcm_frames(ma_data_source* pDataSource, ma_uint64 frameCount, ma_uint64* pFramesSeeked); /* Can only seek forward. Equivalent to ma_data_source_read_pcm_frames(pDataSource, NULL, frameCount, &framesRead); */
-MA_API ma_result ma_data_source_seek_to_pcm_frame(ma_data_source* pDataSource, ma_uint64 frameIndex);
-MA_API ma_result ma_data_source_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap);
-MA_API ma_result ma_data_source_get_cursor_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pCursor);
-MA_API ma_result ma_data_source_get_length_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pLength); /* Returns MA_NOT_IMPLEMENTED if the length is unknown or cannot be determined. Decoders can return this. */
-MA_API ma_result ma_data_source_get_cursor_in_seconds(ma_data_source* pDataSource, float* pCursor);
-MA_API ma_result ma_data_source_get_length_in_seconds(ma_data_source* pDataSource, float* pLength);
-MA_API ma_result ma_data_source_set_looping(ma_data_source* pDataSource, ma_bool32 isLooping);
-MA_API ma_bool32 ma_data_source_is_looping(const ma_data_source* pDataSource);
-MA_API ma_result ma_data_source_set_range_in_pcm_frames(ma_data_source* pDataSource, ma_uint64 rangeBegInFrames, ma_uint64 rangeEndInFrames);
-MA_API void ma_data_source_get_range_in_pcm_frames(const ma_data_source* pDataSource, ma_uint64* pRangeBegInFrames, ma_uint64* pRangeEndInFrames);
-MA_API ma_result ma_data_source_set_loop_point_in_pcm_frames(ma_data_source* pDataSource, ma_uint64 loopBegInFrames, ma_uint64 loopEndInFrames);
-MA_API void ma_data_source_get_loop_point_in_pcm_frames(const ma_data_source* pDataSource, ma_uint64* pLoopBegInFrames, ma_uint64* pLoopEndInFrames);
-MA_API ma_result ma_data_source_set_current(ma_data_source* pDataSource, ma_data_source* pCurrentDataSource);
-MA_API ma_data_source* ma_data_source_get_current(const ma_data_source* pDataSource);
-MA_API ma_result ma_data_source_set_next(ma_data_source* pDataSource, ma_data_source* pNextDataSource);
-MA_API ma_data_source* ma_data_source_get_next(const ma_data_source* pDataSource);
-MA_API ma_result ma_data_source_set_next_callback(ma_data_source* pDataSource, ma_data_source_get_next_proc onGetNext);
-MA_API ma_data_source_get_next_proc ma_data_source_get_next_callback(const ma_data_source* pDataSource);
-
-
-typedef struct
-{
- ma_data_source_base ds;
- ma_format format;
- ma_uint32 channels;
- ma_uint32 sampleRate;
- ma_uint64 cursor;
- ma_uint64 sizeInFrames;
- const void* pData;
-} ma_audio_buffer_ref;
-
-MA_API ma_result ma_audio_buffer_ref_init(ma_format format, ma_uint32 channels, const void* pData, ma_uint64 sizeInFrames, ma_audio_buffer_ref* pAudioBufferRef);
-MA_API void ma_audio_buffer_ref_uninit(ma_audio_buffer_ref* pAudioBufferRef);
-MA_API ma_result ma_audio_buffer_ref_set_data(ma_audio_buffer_ref* pAudioBufferRef, const void* pData, ma_uint64 sizeInFrames);
-MA_API ma_uint64 ma_audio_buffer_ref_read_pcm_frames(ma_audio_buffer_ref* pAudioBufferRef, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop);
-MA_API ma_result ma_audio_buffer_ref_seek_to_pcm_frame(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameIndex);
-MA_API ma_result ma_audio_buffer_ref_map(ma_audio_buffer_ref* pAudioBufferRef, void** ppFramesOut, ma_uint64* pFrameCount);
-MA_API ma_result ma_audio_buffer_ref_unmap(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameCount); /* Returns MA_AT_END if the end has been reached. This should be considered successful. */
-MA_API ma_bool32 ma_audio_buffer_ref_at_end(const ma_audio_buffer_ref* pAudioBufferRef);
-MA_API ma_result ma_audio_buffer_ref_get_cursor_in_pcm_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pCursor);
-MA_API ma_result ma_audio_buffer_ref_get_length_in_pcm_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pLength);
-MA_API ma_result ma_audio_buffer_ref_get_available_frames(const ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pAvailableFrames);
-
-
-
-typedef struct
-{
- ma_format format;
- ma_uint32 channels;
- ma_uint32 sampleRate;
- ma_uint64 sizeInFrames;
- const void* pData; /* If set to NULL, will allocate a block of memory for you. */
- ma_allocation_callbacks allocationCallbacks;
-} ma_audio_buffer_config;
-
-MA_API ma_audio_buffer_config ma_audio_buffer_config_init(ma_format format, ma_uint32 channels, ma_uint64 sizeInFrames, const void* pData, const ma_allocation_callbacks* pAllocationCallbacks);
-
-typedef struct
-{
- ma_audio_buffer_ref ref;
- ma_allocation_callbacks allocationCallbacks;
- ma_bool32 ownsData; /* Used to control whether or not miniaudio owns the data buffer. If set to true, pData will be freed in ma_audio_buffer_uninit(). */
- ma_uint8 _pExtraData[1]; /* For allocating a buffer with the memory located directly after the other memory of the structure. */
-} ma_audio_buffer;
-
-MA_API ma_result ma_audio_buffer_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer);
-MA_API ma_result ma_audio_buffer_init_copy(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer);
-MA_API ma_result ma_audio_buffer_alloc_and_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer** ppAudioBuffer); /* Always copies the data. Doesn't make sense to use this otherwise. Use ma_audio_buffer_uninit_and_free() to uninit. */
-MA_API void ma_audio_buffer_uninit(ma_audio_buffer* pAudioBuffer);
-MA_API void ma_audio_buffer_uninit_and_free(ma_audio_buffer* pAudioBuffer);
-MA_API ma_uint64 ma_audio_buffer_read_pcm_frames(ma_audio_buffer* pAudioBuffer, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop);
-MA_API ma_result ma_audio_buffer_seek_to_pcm_frame(ma_audio_buffer* pAudioBuffer, ma_uint64 frameIndex);
-MA_API ma_result ma_audio_buffer_map(ma_audio_buffer* pAudioBuffer, void** ppFramesOut, ma_uint64* pFrameCount);
-MA_API ma_result ma_audio_buffer_unmap(ma_audio_buffer* pAudioBuffer, ma_uint64 frameCount); /* Returns MA_AT_END if the end has been reached. This should be considered successful. */
-MA_API ma_bool32 ma_audio_buffer_at_end(const ma_audio_buffer* pAudioBuffer);
-MA_API ma_result ma_audio_buffer_get_cursor_in_pcm_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pCursor);
-MA_API ma_result ma_audio_buffer_get_length_in_pcm_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pLength);
-MA_API ma_result ma_audio_buffer_get_available_frames(const ma_audio_buffer* pAudioBuffer, ma_uint64* pAvailableFrames);
-
-
/*
-Paged Audio Buffer
-==================
-A paged audio buffer is made up of a linked list of pages. It's expandable, but not shrinkable. It
-can be used for cases where audio data is streamed in asynchronously while allowing data to be read
-at the same time.
+Mixes the specified number of frames in floating point format with a volume factor.
-This is lock-free, but not 100% thread safe. You can append a page and read from the buffer across
-simultaneously across different threads, however only one thread at a time can append, and only one
-thread at a time can read and seek.
+This will run on an optimized path when the volume is equal to 1.
*/
-typedef struct ma_paged_audio_buffer_page ma_paged_audio_buffer_page;
-struct ma_paged_audio_buffer_page
-{
- MA_ATOMIC(MA_SIZEOF_PTR, ma_paged_audio_buffer_page*) pNext;
- ma_uint64 sizeInFrames;
- ma_uint8 pAudioData[1];
-};
+MA_API ma_result ma_mix_pcm_frames_f32(float* pDst, const float* pSrc, ma_uint64 frameCount, ma_uint32 channels, float volume);
-typedef struct
-{
- ma_format format;
- ma_uint32 channels;
- ma_paged_audio_buffer_page head; /* Dummy head for the lock-free algorithm. Always has a size of 0. */
- MA_ATOMIC(MA_SIZEOF_PTR, ma_paged_audio_buffer_page*) pTail; /* Never null. Initially set to &head. */
-} ma_paged_audio_buffer_data;
-
-MA_API ma_result ma_paged_audio_buffer_data_init(ma_format format, ma_uint32 channels, ma_paged_audio_buffer_data* pData);
-MA_API void ma_paged_audio_buffer_data_uninit(ma_paged_audio_buffer_data* pData, const ma_allocation_callbacks* pAllocationCallbacks);
-MA_API ma_paged_audio_buffer_page* ma_paged_audio_buffer_data_get_head(ma_paged_audio_buffer_data* pData);
-MA_API ma_paged_audio_buffer_page* ma_paged_audio_buffer_data_get_tail(ma_paged_audio_buffer_data* pData);
-MA_API ma_result ma_paged_audio_buffer_data_get_length_in_pcm_frames(ma_paged_audio_buffer_data* pData, ma_uint64* pLength);
-MA_API ma_result ma_paged_audio_buffer_data_allocate_page(ma_paged_audio_buffer_data* pData, ma_uint64 pageSizeInFrames, const void* pInitialData, const ma_allocation_callbacks* pAllocationCallbacks, ma_paged_audio_buffer_page** ppPage);
-MA_API ma_result ma_paged_audio_buffer_data_free_page(ma_paged_audio_buffer_data* pData, ma_paged_audio_buffer_page* pPage, const ma_allocation_callbacks* pAllocationCallbacks);
-MA_API ma_result ma_paged_audio_buffer_data_append_page(ma_paged_audio_buffer_data* pData, ma_paged_audio_buffer_page* pPage);
-MA_API ma_result ma_paged_audio_buffer_data_allocate_and_append_page(ma_paged_audio_buffer_data* pData, ma_uint32 pageSizeInFrames, const void* pInitialData, const ma_allocation_callbacks* pAllocationCallbacks);
-
-
-typedef struct
-{
- ma_paged_audio_buffer_data* pData; /* Must not be null. */
-} ma_paged_audio_buffer_config;
-
-MA_API ma_paged_audio_buffer_config ma_paged_audio_buffer_config_init(ma_paged_audio_buffer_data* pData);
-
-
-typedef struct
-{
- ma_data_source_base ds;
- ma_paged_audio_buffer_data* pData; /* Audio data is read from here. Cannot be null. */
- ma_paged_audio_buffer_page* pCurrent;
- ma_uint64 relativeCursor; /* Relative to the current page. */
- ma_uint64 absoluteCursor;
-} ma_paged_audio_buffer;
-
-MA_API ma_result ma_paged_audio_buffer_init(const ma_paged_audio_buffer_config* pConfig, ma_paged_audio_buffer* pPagedAudioBuffer);
-MA_API void ma_paged_audio_buffer_uninit(ma_paged_audio_buffer* pPagedAudioBuffer);
-MA_API ma_result ma_paged_audio_buffer_read_pcm_frames(ma_paged_audio_buffer* pPagedAudioBuffer, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead); /* Returns MA_AT_END if no more pages available. */
-MA_API ma_result ma_paged_audio_buffer_seek_to_pcm_frame(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64 frameIndex);
-MA_API ma_result ma_paged_audio_buffer_get_cursor_in_pcm_frames(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64* pCursor);
-MA_API ma_result ma_paged_audio_buffer_get_length_in_pcm_frames(ma_paged_audio_buffer* pPagedAudioBuffer, ma_uint64* pLength);
@@ -10036,7 +10327,7 @@ struct ma_resource_manager_data_buffer
ma_bool32 seekToCursorOnNextRead; /* On the next read we need to seek to the frame cursor. */
MA_ATOMIC(4, ma_result) result; /* Keeps track of a result of decoding. Set to MA_BUSY while the buffer is still loading. Set to MA_SUCCESS when loading is finished successfully. Otherwise set to some other code. */
MA_ATOMIC(4, ma_bool32) isLooping; /* Can be read and written by different threads at the same time. Must be used atomically. */
- ma_bool32 isConnectorInitialized; /* Used for asynchronous loading to ensure we don't try to initialize the connector multiple times while waiting for the node to fully load. */
+ ma_atomic_bool32 isConnectorInitialized; /* Used for asynchronous loading to ensure we don't try to initialize the connector multiple times while waiting for the node to fully load. */
union
{
ma_decoder decoder; /* Supply type is ma_resource_manager_data_supply_type_encoded */
@@ -10094,6 +10385,7 @@ typedef struct
ma_uint32 decodedChannels; /* The decoded channel count to use. Set to 0 (default) to use the file's native channel count. */
ma_uint32 decodedSampleRate; /* the decoded sample rate to use. Set to 0 (default) to use the file's native sample rate. */
ma_uint32 jobThreadCount; /* Set to 0 if you want to self-manage your job threads. Defaults to 1. */
+ size_t jobThreadStackSize;
ma_uint32 jobQueueCapacity; /* The maximum number of jobs that can fit in the queue at a time. Defaults to MA_JOB_TYPE_RESOURCE_MANAGER_QUEUE_CAPACITY. Cannot be zero. */
ma_uint32 flags;
ma_vfs* pVFS; /* Can be NULL in which case defaults will be used. */
@@ -10302,7 +10594,7 @@ struct ma_node_output_bus
ma_uint8 channels; /* The number of channels in the audio stream for this bus. */
/* Mutable via multiple threads. Must be used atomically. The weird ordering here is for packing reasons. */
- MA_ATOMIC(1, ma_uint8) inputNodeInputBusIndex; /* The index of the input bus on the input. Required for detaching. */
+ ma_uint8 inputNodeInputBusIndex; /* The index of the input bus on the input. Required for detaching. Will only be used within the spinlock so does not need to be atomic. */
MA_ATOMIC(4, ma_uint32) flags; /* Some state flags for tracking the read state of the output buffer. A combination of MA_NODE_OUTPUT_BUS_FLAG_*. */
MA_ATOMIC(4, ma_uint32) refCount; /* Reference count for some thread-safety when detaching. */
MA_ATOMIC(4, ma_bool32) isAttached; /* This is used to prevent iteration of nodes that are in the middle of being detached. Used for thread safety. */
@@ -10326,7 +10618,7 @@ struct ma_node_input_bus
MA_ATOMIC(4, ma_spinlock) lock; /* Unfortunate lock, but significantly simplifies the implementation. Required for thread-safe attaching and detaching. */
/* Set once at startup. */
- ma_uint8 channels; /* The number of channels in the audio stream for this bus. */
+ ma_uint8 channels; /* The number of channels in the audio stream for this bus. */
};
@@ -10334,7 +10626,7 @@ typedef struct ma_node_base ma_node_base;
struct ma_node_base
{
/* These variables are set once at startup. */
- ma_node_graph* pNodeGraph; /* The graph this node belongs to. */
+ ma_node_graph* pNodeGraph; /* The graph this node belongs to. */
const ma_node_vtable* vtable;
float* pCachedData; /* Allocated on the heap. Fixed size. Needs to be stored on the heap because reading from output buses is done in separate function calls. */
ma_uint16 cachedDataCapInFramesPerBus; /* The capacity of the input data cache in frames, per bus. */
@@ -10436,11 +10728,12 @@ MA_API ma_result ma_data_source_node_set_looping(ma_data_source_node* pDataSourc
MA_API ma_bool32 ma_data_source_node_is_looping(ma_data_source_node* pDataSourceNode);
-/* Splitter Node. 1 input, 2 outputs. Used for splitting/copying a stream so it can be as input into two separate output nodes. */
+/* Splitter Node. 1 input, many outputs. Used for splitting/copying a stream so it can be as input into two separate output nodes. */
typedef struct
{
ma_node_config nodeConfig;
ma_uint32 channels;
+ ma_uint32 outputBusCount;
} ma_splitter_node_config;
MA_API ma_splitter_node_config ma_splitter_node_config_init(ma_uint32 channels);
@@ -10665,6 +10958,7 @@ MA_API float ma_delay_node_get_decay(const ma_delay_node* pDelayNode);
#endif /* MA_NO_NODE_GRAPH */
+/* SECTION: miniaudio_engine.h */
/************************************************************************************************************************************************************
Engine
@@ -10678,13 +10972,17 @@ typedef struct ma_sound ma_sound;
/* Sound flags. */
typedef enum
{
+ /* Resource manager flags. */
MA_SOUND_FLAG_STREAM = 0x00000001, /* MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM */
MA_SOUND_FLAG_DECODE = 0x00000002, /* MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE */
MA_SOUND_FLAG_ASYNC = 0x00000004, /* MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC */
MA_SOUND_FLAG_WAIT_INIT = 0x00000008, /* MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT */
- MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT = 0x00000010, /* Do not attach to the endpoint by default. Useful for when setting up nodes in a complex graph system. */
- MA_SOUND_FLAG_NO_PITCH = 0x00000020, /* Disable pitch shifting with ma_sound_set_pitch() and ma_sound_group_set_pitch(). This is an optimization. */
- MA_SOUND_FLAG_NO_SPATIALIZATION = 0x00000040 /* Disable spatialization. */
+ MA_SOUND_FLAG_UNKNOWN_LENGTH = 0x00000010, /* MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_UNKNOWN_LENGTH */
+
+ /* ma_sound specific flags. */
+ MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT = 0x00001000, /* Do not attach to the endpoint by default. Useful for when setting up nodes in a complex graph system. */
+ MA_SOUND_FLAG_NO_PITCH = 0x00002000, /* Disable pitch shifting with ma_sound_set_pitch() and ma_sound_group_set_pitch(). This is an optimization. */
+ MA_SOUND_FLAG_NO_SPATIALIZATION = 0x00004000 /* Disable spatialization. */
} ma_sound_flags;
#ifndef MA_ENGINE_MAX_LISTENERS
@@ -10706,7 +11004,9 @@ typedef struct
ma_uint32 channelsIn;
ma_uint32 channelsOut;
ma_uint32 sampleRate; /* Only used when the type is set to ma_engine_node_type_sound. */
- ma_bool8 isPitchDisabled; /* Pitching can be explicitly disable with MA_SOUND_FLAG_NO_PITCH to optimize processing. */
+ ma_uint32 volumeSmoothTimeInPCMFrames; /* The number of frames to smooth over volume changes. Defaults to 0 in which case no smoothing is used. */
+ ma_mono_expansion_mode monoExpansionMode;
+ ma_bool8 isPitchDisabled; /* Pitching can be explicitly disabled with MA_SOUND_FLAG_NO_PITCH to optimize processing. */
ma_bool8 isSpatializationDisabled; /* Spatialization can be explicitly disabled with MA_SOUND_FLAG_NO_SPATIALIZATION. */
ma_uint8 pinnedListenerIndex; /* The index of the listener this node should always use for spatialization. If set to MA_LISTENER_INDEX_CLOSEST the engine will use the closest listener. */
} ma_engine_node_config;
@@ -10720,10 +11020,14 @@ typedef struct
ma_node_base baseNode; /* Must be the first member for compatiblity with the ma_node API. */
ma_engine* pEngine; /* A pointer to the engine. Set based on the value from the config. */
ma_uint32 sampleRate; /* The sample rate of the input data. For sounds backed by a data source, this will be the data source's sample rate. Otherwise it'll be the engine's sample rate. */
+ ma_uint32 volumeSmoothTimeInPCMFrames;
+ ma_mono_expansion_mode monoExpansionMode;
ma_fader fader;
ma_linear_resampler resampler; /* For pitch shift. */
ma_spatializer spatializer;
ma_panner panner;
+ ma_gainer volumeGainer; /* This will only be used if volumeSmoothTimeInPCMFrames is > 0. */
+ ma_atomic_float volume; /* Defaults to 1. */
MA_ATOMIC(4, float) pitch;
float oldPitch; /* For determining whether or not the resampler needs to be updated to reflect the new pitch. The resampler will be updated on the mixing thread. */
float oldDopplerPitch; /* For determining whether or not the resampler needs to be updated to take a new doppler pitch into account. */
@@ -10744,6 +11048,9 @@ MA_API void ma_engine_node_uninit(ma_engine_node* pEngineNode, const ma_allocati
#define MA_SOUND_SOURCE_CHANNEL_COUNT 0xFFFFFFFF
+/* Callback for when a sound reaches the end. */
+typedef void (* ma_sound_end_proc)(void* pUserData, ma_sound* pSound);
+
typedef struct
{
const char* pFilePath; /* Set this to load from the resource manager. */
@@ -10753,17 +11060,25 @@ typedef struct
ma_uint32 initialAttachmentInputBusIndex; /* The index of the input bus of pInitialAttachment to attach the sound to. */
ma_uint32 channelsIn; /* Ignored if using a data source as input (the data source's channel count will be used always). Otherwise, setting to 0 will cause the engine's channel count to be used. */
ma_uint32 channelsOut; /* Set this to 0 (default) to use the engine's channel count. Set to MA_SOUND_SOURCE_CHANNEL_COUNT to use the data source's channel count (only used if using a data source as input). */
+ ma_mono_expansion_mode monoExpansionMode; /* Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. */
ma_uint32 flags; /* A combination of MA_SOUND_FLAG_* flags. */
+ ma_uint32 volumeSmoothTimeInPCMFrames; /* The number of frames to smooth over volume changes. Defaults to 0 in which case no smoothing is used. */
ma_uint64 initialSeekPointInPCMFrames; /* Initializes the sound such that it's seeked to this location by default. */
ma_uint64 rangeBegInPCMFrames;
ma_uint64 rangeEndInPCMFrames;
ma_uint64 loopPointBegInPCMFrames;
ma_uint64 loopPointEndInPCMFrames;
ma_bool32 isLooping;
- ma_fence* pDoneFence; /* Released when the resource manager has finished decoding the entire sound. Not used with streams. */
+ ma_sound_end_proc endCallback; /* Fired when the sound reaches the end. Will be fired from the audio thread. Do not restart, uninitialize or otherwise change the state of the sound from here. Instead fire an event or set a variable to indicate to a different thread to change the start of the sound. Will not be fired in response to a scheduled stop with ma_sound_set_stop_time_*(). */
+ void* pEndCallbackUserData;
+#ifndef MA_NO_RESOURCE_MANAGER
+ ma_resource_manager_pipeline_notifications initNotifications;
+#endif
+ ma_fence* pDoneFence; /* Deprecated. Use initNotifications instead. Released when the resource manager has finished decoding the entire sound. Not used with streams. */
} ma_sound_config;
-MA_API ma_sound_config ma_sound_config_init(void);
+MA_API ma_sound_config ma_sound_config_init(void); /* Deprecated. Will be removed in version 0.12. Use ma_sound_config_2() instead. */
+MA_API ma_sound_config ma_sound_config_init_2(ma_engine* pEngine); /* Will be renamed to ma_sound_config_init() in version 0.12. */
struct ma_sound
{
@@ -10771,6 +11086,8 @@ struct ma_sound
ma_data_source* pDataSource;
MA_ATOMIC(8, ma_uint64) seekTarget; /* The PCM frame index to seek to in the mixing thread. Set to (~(ma_uint64)0) to not perform any seeking. */
MA_ATOMIC(4, ma_bool32) atEnd;
+ ma_sound_end_proc endCallback;
+ void* pEndCallbackUserData;
ma_bool8 ownsDataSource;
/*
@@ -10795,32 +11112,34 @@ struct ma_sound_inlined
typedef ma_sound_config ma_sound_group_config;
typedef ma_sound ma_sound_group;
-MA_API ma_sound_group_config ma_sound_group_config_init(void);
-
+MA_API ma_sound_group_config ma_sound_group_config_init(void); /* Deprecated. Will be removed in version 0.12. Use ma_sound_config_2() instead. */
+MA_API ma_sound_group_config ma_sound_group_config_init_2(ma_engine* pEngine); /* Will be renamed to ma_sound_config_init() in version 0.12. */
typedef struct
{
#if !defined(MA_NO_RESOURCE_MANAGER)
- ma_resource_manager* pResourceManager; /* Can be null in which case a resource manager will be created for you. */
+ ma_resource_manager* pResourceManager; /* Can be null in which case a resource manager will be created for you. */
#endif
#if !defined(MA_NO_DEVICE_IO)
ma_context* pContext;
- ma_device* pDevice; /* If set, the caller is responsible for calling ma_engine_data_callback() in the device's data callback. */
- ma_device_id* pPlaybackDeviceID; /* The ID of the playback device to use with the default listener. */
+ ma_device* pDevice; /* If set, the caller is responsible for calling ma_engine_data_callback() in the device's data callback. */
+ ma_device_id* pPlaybackDeviceID; /* The ID of the playback device to use with the default listener. */
+ ma_device_notification_proc notificationCallback;
#endif
- ma_log* pLog; /* When set to NULL, will use the context's log. */
- ma_uint32 listenerCount; /* Must be between 1 and MA_ENGINE_MAX_LISTENERS. */
- ma_uint32 channels; /* The number of channels to use when mixing and spatializing. When set to 0, will use the native channel count of the device. */
- ma_uint32 sampleRate; /* The sample rate. When set to 0 will use the native channel count of the device. */
- ma_uint32 periodSizeInFrames; /* If set to something other than 0, updates will always be exactly this size. The underlying device may be a different size, but from the perspective of the mixer that won't matter.*/
- ma_uint32 periodSizeInMilliseconds; /* Used if periodSizeInFrames is unset. */
- ma_uint32 gainSmoothTimeInFrames; /* The number of frames to interpolate the gain of spatialized sounds across. If set to 0, will use gainSmoothTimeInMilliseconds. */
- ma_uint32 gainSmoothTimeInMilliseconds; /* When set to 0, gainSmoothTimeInFrames will be used. If both are set to 0, a default value will be used. */
+ ma_log* pLog; /* When set to NULL, will use the context's log. */
+ ma_uint32 listenerCount; /* Must be between 1 and MA_ENGINE_MAX_LISTENERS. */
+ ma_uint32 channels; /* The number of channels to use when mixing and spatializing. When set to 0, will use the native channel count of the device. */
+ ma_uint32 sampleRate; /* The sample rate. When set to 0 will use the native channel count of the device. */
+ ma_uint32 periodSizeInFrames; /* If set to something other than 0, updates will always be exactly this size. The underlying device may be a different size, but from the perspective of the mixer that won't matter.*/
+ ma_uint32 periodSizeInMilliseconds; /* Used if periodSizeInFrames is unset. */
+ ma_uint32 gainSmoothTimeInFrames; /* The number of frames to interpolate the gain of spatialized sounds across. If set to 0, will use gainSmoothTimeInMilliseconds. */
+ ma_uint32 gainSmoothTimeInMilliseconds; /* When set to 0, gainSmoothTimeInFrames will be used. If both are set to 0, a default value will be used. */
+ ma_uint32 defaultVolumeSmoothTimeInPCMFrames; /* Defaults to 0. Controls the default amount of smoothing to apply to volume changes to sounds. High values means more smoothing at the expense of high latency (will take longer to reach the new volume). */
ma_allocation_callbacks allocationCallbacks;
- ma_bool32 noAutoStart; /* When set to true, requires an explicit call to ma_engine_start(). This is false by default, meaning the engine will be started automatically in ma_engine_init(). */
- ma_bool32 noDevice; /* When set to true, don't create a default device. ma_engine_read_pcm_frames() can be called manually to read data. */
- ma_mono_expansion_mode monoExpansionMode; /* Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. */
- ma_vfs* pResourceManagerVFS; /* A pointer to a pre-allocated VFS object to use with the resource manager. This is ignored if pResourceManager is not NULL. */
+ ma_bool32 noAutoStart; /* When set to true, requires an explicit call to ma_engine_start(). This is false by default, meaning the engine will be started automatically in ma_engine_init(). */
+ ma_bool32 noDevice; /* When set to true, don't create a default device. ma_engine_read_pcm_frames() can be called manually to read data. */
+ ma_mono_expansion_mode monoExpansionMode; /* Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. */
+ ma_vfs* pResourceManagerVFS; /* A pointer to a pre-allocated VFS object to use with the resource manager. This is ignored if pResourceManager is not NULL. */
} ma_engine_config;
MA_API ma_engine_config ma_engine_config_init(void);
@@ -10846,6 +11165,7 @@ struct ma_engine
ma_sound_inlined* pInlinedSoundHead; /* The first inlined sound. Inlined sounds are tracked in a linked list. */
MA_ATOMIC(4, ma_uint32) inlinedSoundCount; /* The total number of allocated inlined sound objects. Used for debugging. */
ma_uint32 gainSmoothTimeInFrames; /* The number of frames to interpolate the gain of spatialized sounds across. */
+ ma_uint32 defaultVolumeSmoothTimeInPCMFrames;
ma_mono_expansion_mode monoExpansionMode;
};
@@ -10859,8 +11179,12 @@ MA_API ma_resource_manager* ma_engine_get_resource_manager(ma_engine* pEngine);
MA_API ma_device* ma_engine_get_device(ma_engine* pEngine);
MA_API ma_log* ma_engine_get_log(ma_engine* pEngine);
MA_API ma_node* ma_engine_get_endpoint(ma_engine* pEngine);
-MA_API ma_uint64 ma_engine_get_time(const ma_engine* pEngine);
-MA_API ma_result ma_engine_set_time(ma_engine* pEngine, ma_uint64 globalTime);
+MA_API ma_uint64 ma_engine_get_time_in_pcm_frames(const ma_engine* pEngine);
+MA_API ma_uint64 ma_engine_get_time_in_milliseconds(const ma_engine* pEngine);
+MA_API ma_result ma_engine_set_time_in_pcm_frames(ma_engine* pEngine, ma_uint64 globalTime);
+MA_API ma_result ma_engine_set_time_in_milliseconds(ma_engine* pEngine, ma_uint64 globalTime);
+MA_API ma_uint64 ma_engine_get_time(const ma_engine* pEngine); /* Deprecated. Use ma_engine_get_time_in_pcm_frames(). Will be removed in version 0.12. */
+MA_API ma_result ma_engine_set_time(ma_engine* pEngine, ma_uint64 globalTime); /* Deprecated. Use ma_engine_set_time_in_pcm_frames(). Will be removed in version 0.12. */
MA_API ma_uint32 ma_engine_get_channels(const ma_engine* pEngine);
MA_API ma_uint32 ma_engine_get_sample_rate(const ma_engine* pEngine);
@@ -10943,7 +11267,7 @@ MA_API void ma_sound_set_directional_attenuation_factor(ma_sound* pSound, float
MA_API float ma_sound_get_directional_attenuation_factor(const ma_sound* pSound);
MA_API void ma_sound_set_fade_in_pcm_frames(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInFrames);
MA_API void ma_sound_set_fade_in_milliseconds(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInMilliseconds);
-MA_API float ma_sound_get_current_fade_volume(ma_sound* pSound);
+MA_API float ma_sound_get_current_fade_volume(const ma_sound* pSound);
MA_API void ma_sound_set_start_time_in_pcm_frames(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInFrames);
MA_API void ma_sound_set_start_time_in_milliseconds(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInMilliseconds);
MA_API void ma_sound_set_stop_time_in_pcm_frames(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInFrames);
@@ -10959,6 +11283,7 @@ MA_API ma_result ma_sound_get_cursor_in_pcm_frames(ma_sound* pSound, ma_uint64*
MA_API ma_result ma_sound_get_length_in_pcm_frames(ma_sound* pSound, ma_uint64* pLength);
MA_API ma_result ma_sound_get_cursor_in_seconds(ma_sound* pSound, float* pCursor);
MA_API ma_result ma_sound_get_length_in_seconds(ma_sound* pSound, float* pLength);
+MA_API ma_result ma_sound_set_end_callback(ma_sound* pSound, ma_sound_end_proc callback, void* pUserData);
MA_API ma_result ma_sound_group_init(ma_engine* pEngine, ma_uint32 flags, ma_sound_group* pParentGroup, ma_sound_group* pGroup);
MA_API ma_result ma_sound_group_init_ex(ma_engine* pEngine, const ma_sound_group_config* pConfig, ma_sound_group* pGroup);
@@ -11016,6 +11341,7 @@ MA_API void ma_sound_group_set_stop_time_in_milliseconds(ma_sound_group* pGroup,
MA_API ma_bool32 ma_sound_group_is_playing(const ma_sound_group* pGroup);
MA_API ma_uint64 ma_sound_group_get_time_in_pcm_frames(const ma_sound_group* pGroup);
#endif /* MA_NO_ENGINE */
+/* END SECTION: miniaudio_engine.h */
#ifdef __cplusplus
}
@@ -11042,8 +11368,10 @@ IMPLEMENTATION
#define miniaudio_c
#include
-#include /* For INT_MAX */
-#include /* sin(), etc. */
+#include /* For INT_MAX */
+#include /* sin(), etc. */
+#include /* For malloc(), free(), wcstombs(). */
+#include /* For memset() */
#include
#include
@@ -11055,22 +11383,42 @@ IMPLEMENTATION
#include /* For _controlfp_s constants */
#endif
-#ifdef MA_WIN32
-#include
-#else
-#include /* For malloc(), free(), wcstombs(). */
-#include /* For memset() */
+#if defined(MA_WIN32)
+ #include
+
+ /*
+ There's a possibility that WIN32_LEAN_AND_MEAN has been defined which will exclude some symbols
+ such as STGM_READ and CLSCTL_ALL. We need to check these and define them ourselves if they're
+ unavailable.
+ */
+ #ifndef STGM_READ
+ #define STGM_READ 0x00000000L
+ #endif
+ #ifndef CLSCTX_ALL
+ #define CLSCTX_ALL 23
+ #endif
+
+ /* IUnknown is used by both the WASAPI and DirectSound backends. It easier to just declare our version here. */
+ typedef struct ma_IUnknown ma_IUnknown;
+#endif
+
+#if !defined(MA_WIN32)
#include
#include /* select() (used for ma_sleep()). */
#include
#endif
+#ifdef MA_NX
+#include /* For nanosleep() */
+#endif
+
#include /* For fstat(), etc. */
#ifdef MA_EMSCRIPTEN
#include
#endif
+
#if !defined(MA_64BIT) && !defined(MA_32BIT)
#ifdef _WIN32
#ifdef _WIN64
@@ -11110,7 +11458,7 @@ IMPLEMENTATION
#endif
/* Intrinsics Support */
-#if defined(MA_X64) || defined(MA_X86)
+#if (defined(MA_X64) || defined(MA_X86)) && !defined(__COSMOPOLITAN__)
#if defined(_MSC_VER) && !defined(__clang__)
/* MSVC. */
#if _MSC_VER >= 1400 && !defined(MA_NO_SSE2) /* 2005 */
@@ -11346,23 +11694,6 @@ static MA_INLINE ma_bool32 ma_has_neon(void)
#endif
}
-#define MA_SIMD_NONE 0
-#define MA_SIMD_SSE2 1
-#define MA_SIMD_AVX2 2
-#define MA_SIMD_NEON 3
-
-#ifndef MA_PREFERRED_SIMD
- # if defined(MA_SUPPORT_SSE2) && defined(MA_PREFER_SSE2)
- #define MA_PREFERRED_SIMD MA_SIMD_SSE2
- #elif defined(MA_SUPPORT_AVX2) && defined(MA_PREFER_AVX2)
- #define MA_PREFERRED_SIMD MA_SIMD_AVX2
- #elif defined(MA_SUPPORT_NEON) && defined(MA_PREFER_NEON)
- #define MA_PREFERRED_SIMD MA_SIMD_NEON
- #else
- #define MA_PREFERRED_SIMD MA_SIMD_NONE
- #endif
-#endif
-
#if defined(__has_builtin)
#define MA_COMPILER_HAS_BUILTIN(x) __has_builtin(x)
#else
@@ -11476,7 +11807,7 @@ static void ma_sleep__posix(ma_uint32 milliseconds)
(void)milliseconds;
MA_ASSERT(MA_FALSE); /* The Emscripten build should never sleep. */
#else
- #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L
+ #if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L) || defined(MA_NX)
struct timespec ts;
ts.tv_sec = milliseconds / 1000;
ts.tv_nsec = milliseconds % 1000 * 1000000;
@@ -11502,7 +11833,7 @@ static MA_INLINE void ma_sleep(ma_uint32 milliseconds)
}
#endif
-static MA_INLINE void ma_yield()
+static MA_INLINE void ma_yield(void)
{
#if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
/* x86/x64 */
@@ -11537,7 +11868,7 @@ static MA_INLINE void ma_yield()
#define MA_MM_DENORMALS_ZERO_MASK 0x0040
#define MA_MM_FLUSH_ZERO_MASK 0x8000
-static MA_INLINE unsigned int ma_disable_denormals()
+static MA_INLINE unsigned int ma_disable_denormals(void)
{
unsigned int prevState;
@@ -11564,7 +11895,7 @@ static MA_INLINE unsigned int ma_disable_denormals()
}
#elif defined(MA_X86) || defined(MA_X64)
{
- #if defined(__SSE2__) && !(defined(__TINYC__) || defined(__WATCOMC__)) /* <-- Add compilers that lack support for _mm_getcsr() and _mm_setcsr() to this list. */
+ #if defined(__SSE2__) && !(defined(__TINYC__) || defined(__WATCOMC__) || defined(__COSMOPOLITAN__)) /* <-- Add compilers that lack support for _mm_getcsr() and _mm_setcsr() to this list. */
{
prevState = _mm_getcsr();
_mm_setcsr(prevState | MA_MM_DENORMALS_ZERO_MASK | MA_MM_FLUSH_ZERO_MASK);
@@ -11604,7 +11935,7 @@ static MA_INLINE void ma_restore_denormals(unsigned int prevState)
}
#elif defined(MA_X86) || defined(MA_X64)
{
- #if defined(__SSE2__) && !(defined(__TINYC__) || defined(__WATCOMC__)) /* <-- Add compilers that lack support for _mm_getcsr() and _mm_setcsr() to this list. */
+ #if defined(__SSE2__) && !(defined(__TINYC__) || defined(__WATCOMC__) || defined(__COSMOPOLITAN__)) /* <-- Add compilers that lack support for _mm_getcsr() and _mm_setcsr() to this list. */
{
_mm_setcsr(prevState);
}
@@ -11624,6 +11955,20 @@ static MA_INLINE void ma_restore_denormals(unsigned int prevState)
}
+#ifdef MA_ANDROID
+#include
+
+int ma_android_sdk_version()
+{
+ char sdkVersion[PROP_VALUE_MAX + 1] = {0, };
+ if (__system_property_get("ro.build.version.sdk", sdkVersion)) {
+ return atoi(sdkVersion);
+ }
+
+ return 0;
+}
+#endif
+
#ifndef MA_COINIT_VALUE
#define MA_COINIT_VALUE 0 /* 0 = COINIT_MULTITHREADED */
@@ -11777,72 +12122,53 @@ MA_API const char* ma_version_string(void)
Standard Library Stuff
******************************************************************************/
+#ifndef MA_ASSERT
+#define MA_ASSERT(condition) assert(condition)
+#endif
+
#ifndef MA_MALLOC
-#ifdef MA_WIN32
-#define MA_MALLOC(sz) HeapAlloc(GetProcessHeap(), 0, (sz))
-#else
-#define MA_MALLOC(sz) malloc((sz))
+#define MA_MALLOC(sz) malloc((sz))
#endif
-#endif
-
#ifndef MA_REALLOC
-#ifdef MA_WIN32
-#define MA_REALLOC(p, sz) (((sz) > 0) ? ((p) ? HeapReAlloc(GetProcessHeap(), 0, (p), (sz)) : HeapAlloc(GetProcessHeap(), 0, (sz))) : ((VOID*)(size_t)(HeapFree(GetProcessHeap(), 0, (p)) & 0)))
-#else
-#define MA_REALLOC(p, sz) realloc((p), (sz))
+#define MA_REALLOC(p, sz) realloc((p), (sz))
#endif
+#ifndef MA_FREE
+#define MA_FREE(p) free((p))
#endif
-#ifndef MA_FREE
-#ifdef MA_WIN32
-#define MA_FREE(p) HeapFree(GetProcessHeap(), 0, (p))
-#else
-#define MA_FREE(p) free((p))
-#endif
-#endif
+static MA_INLINE void ma_zero_memory_default(void* p, size_t sz)
+{
+ if (p == NULL) {
+ MA_ASSERT(sz == 0); /* If this is triggered there's an error with the calling code. */
+ return;
+ }
+
+ if (sz > 0) {
+ memset(p, 0, sz);
+ }
+}
+
#ifndef MA_ZERO_MEMORY
-#ifdef MA_WIN32
-#define MA_ZERO_MEMORY(p, sz) ZeroMemory((p), (sz))
-#else
-#define MA_ZERO_MEMORY(p, sz) memset((p), 0, (sz))
+#define MA_ZERO_MEMORY(p, sz) ma_zero_memory_default((p), (sz))
#endif
-#endif
-
#ifndef MA_COPY_MEMORY
-#ifdef MA_WIN32
-#define MA_COPY_MEMORY(dst, src, sz) CopyMemory((dst), (src), (sz))
-#else
-#define MA_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
+#define MA_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
#endif
-#endif
-
#ifndef MA_MOVE_MEMORY
-#ifdef MA_WIN32
-#define MA_MOVE_MEMORY(dst, src, sz) MoveMemory((dst), (src), (sz))
-#else
-#define MA_MOVE_MEMORY(dst, src, sz) memmove((dst), (src), (sz))
-#endif
+#define MA_MOVE_MEMORY(dst, src, sz) memmove((dst), (src), (sz))
#endif
-#ifndef MA_ASSERT
-#ifdef MA_WIN32
-#define MA_ASSERT(condition) assert(condition)
-#else
-#define MA_ASSERT(condition) assert(condition)
-#endif
-#endif
+#define MA_ZERO_OBJECT(p) MA_ZERO_MEMORY((p), sizeof(*(p)))
-#define MA_ZERO_OBJECT(p) MA_ZERO_MEMORY((p), sizeof(*(p)))
-
-#define ma_countof(x) (sizeof(x) / sizeof(x[0]))
-#define ma_max(x, y) (((x) > (y)) ? (x) : (y))
-#define ma_min(x, y) (((x) < (y)) ? (x) : (y))
-#define ma_abs(x) (((x) > 0) ? (x) : -(x))
-#define ma_clamp(x, lo, hi) (ma_max(lo, ma_min(x, hi)))
-#define ma_offset_ptr(p, offset) (((ma_uint8*)(p)) + (offset))
-#define ma_align(x, a) ((x + (a-1)) & ~(a-1))
-#define ma_align_64(x) ma_align(x, 8)
+#define ma_countof(x) (sizeof(x) / sizeof(x[0]))
+#define ma_max(x, y) (((x) > (y)) ? (x) : (y))
+#define ma_min(x, y) (((x) < (y)) ? (x) : (y))
+#define ma_abs(x) (((x) > 0) ? (x) : -(x))
+#define ma_clamp(x, lo, hi) (ma_max(lo, ma_min(x, hi)))
+#define ma_offset_ptr(p, offset) (((ma_uint8*)(p)) + (offset))
+#define ma_align(x, a) ((x + (a-1)) & ~(a-1))
+#define ma_align_64(x) ma_align(x, 8)
#define ma_buffer_frame_capacity(buffer, channels, format) (sizeof(buffer) / ma_get_bytes_per_sample(format) / (channels))
@@ -11877,6 +12203,40 @@ static MA_INLINE double ma_sqrtd(double x)
}
+static MA_INLINE float ma_rsqrtf(float x)
+{
+ #if defined(MA_SUPPORT_SSE2) && !defined(MA_NO_SSE2) && (defined(MA_X64) || (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__))
+ {
+ /*
+ For SSE we can use RSQRTSS.
+
+ This Stack Overflow post suggests that compilers don't necessarily generate optimal code
+ when using intrinsics:
+
+ https://web.archive.org/web/20221211012522/https://stackoverflow.com/questions/32687079/getting-fewest-instructions-for-rsqrtss-wrapper
+
+ I'm going to do something similar here, but a bit simpler.
+ */
+ #if defined(__GNUC__) || defined(__clang__)
+ {
+ float result;
+ __asm__ __volatile__("rsqrtss %1, %0" : "=x"(result) : "x"(x));
+ return result;
+ }
+ #else
+ {
+ return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ps1(x)));
+ }
+ #endif
+ }
+ #else
+ {
+ return 1 / (float)ma_sqrtd(x);
+ }
+ #endif
+}
+
+
static MA_INLINE float ma_sinf(float x)
{
return (float)ma_sind((float)x);
@@ -12227,12 +12587,15 @@ MA_API int ma_strappend(char* dst, size_t dstSize, const char* srcA, const char*
MA_API char* ma_copy_string(const char* src, const ma_allocation_callbacks* pAllocationCallbacks)
{
+ size_t sz;
+ char* dst;
+
if (src == NULL) {
return NULL;
}
- size_t sz = strlen(src)+1;
- char* dst = (char*)ma_malloc(sz, pAllocationCallbacks);
+ sz = strlen(src)+1;
+ dst = (char*)ma_malloc(sz, pAllocationCallbacks);
if (dst == NULL) {
return NULL;
}
@@ -12256,406 +12619,408 @@ MA_API wchar_t* ma_copy_string_w(const wchar_t* src, const ma_allocation_callbac
}
+
#include
static ma_result ma_result_from_errno(int e)
{
- switch (e)
- {
- case 0: return MA_SUCCESS;
- #ifdef EPERM
- case EPERM: return MA_INVALID_OPERATION;
- #endif
- #ifdef ENOENT
- case ENOENT: return MA_DOES_NOT_EXIST;
- #endif
- #ifdef ESRCH
- case ESRCH: return MA_DOES_NOT_EXIST;
- #endif
- #ifdef EINTR
- case EINTR: return MA_INTERRUPT;
- #endif
- #ifdef EIO
- case EIO: return MA_IO_ERROR;
- #endif
- #ifdef ENXIO
- case ENXIO: return MA_DOES_NOT_EXIST;
- #endif
- #ifdef E2BIG
- case E2BIG: return MA_INVALID_ARGS;
- #endif
- #ifdef ENOEXEC
- case ENOEXEC: return MA_INVALID_FILE;
- #endif
- #ifdef EBADF
- case EBADF: return MA_INVALID_FILE;
- #endif
- #ifdef ECHILD
- case ECHILD: return MA_ERROR;
- #endif
- #ifdef EAGAIN
- case EAGAIN: return MA_UNAVAILABLE;
- #endif
- #ifdef ENOMEM
- case ENOMEM: return MA_OUT_OF_MEMORY;
- #endif
- #ifdef EACCES
- case EACCES: return MA_ACCESS_DENIED;
- #endif
- #ifdef EFAULT
- case EFAULT: return MA_BAD_ADDRESS;
- #endif
- #ifdef ENOTBLK
- case ENOTBLK: return MA_ERROR;
- #endif
- #ifdef EBUSY
- case EBUSY: return MA_BUSY;
- #endif
- #ifdef EEXIST
- case EEXIST: return MA_ALREADY_EXISTS;
- #endif
- #ifdef EXDEV
- case EXDEV: return MA_ERROR;
- #endif
- #ifdef ENODEV
- case ENODEV: return MA_DOES_NOT_EXIST;
- #endif
- #ifdef ENOTDIR
- case ENOTDIR: return MA_NOT_DIRECTORY;
- #endif
- #ifdef EISDIR
- case EISDIR: return MA_IS_DIRECTORY;
- #endif
- #ifdef EINVAL
- case EINVAL: return MA_INVALID_ARGS;
- #endif
- #ifdef ENFILE
- case ENFILE: return MA_TOO_MANY_OPEN_FILES;
- #endif
- #ifdef EMFILE
- case EMFILE: return MA_TOO_MANY_OPEN_FILES;
- #endif
- #ifdef ENOTTY
- case ENOTTY: return MA_INVALID_OPERATION;
- #endif
- #ifdef ETXTBSY
- case ETXTBSY: return MA_BUSY;
- #endif
- #ifdef EFBIG
- case EFBIG: return MA_TOO_BIG;
- #endif
- #ifdef ENOSPC
- case ENOSPC: return MA_NO_SPACE;
- #endif
- #ifdef ESPIPE
- case ESPIPE: return MA_BAD_SEEK;
- #endif
- #ifdef EROFS
- case EROFS: return MA_ACCESS_DENIED;
- #endif
- #ifdef EMLINK
- case EMLINK: return MA_TOO_MANY_LINKS;
- #endif
- #ifdef EPIPE
- case EPIPE: return MA_BAD_PIPE;
- #endif
- #ifdef EDOM
- case EDOM: return MA_OUT_OF_RANGE;
- #endif
- #ifdef ERANGE
- case ERANGE: return MA_OUT_OF_RANGE;
- #endif
- #ifdef EDEADLK
- case EDEADLK: return MA_DEADLOCK;
- #endif
- #ifdef ENAMETOOLONG
- case ENAMETOOLONG: return MA_PATH_TOO_LONG;
- #endif
- #ifdef ENOLCK
- case ENOLCK: return MA_ERROR;
- #endif
- #ifdef ENOSYS
- case ENOSYS: return MA_NOT_IMPLEMENTED;
- #endif
- #ifdef ENOTEMPTY
- case ENOTEMPTY: return MA_DIRECTORY_NOT_EMPTY;
- #endif
- #ifdef ELOOP
- case ELOOP: return MA_TOO_MANY_LINKS;
- #endif
- #ifdef ENOMSG
- case ENOMSG: return MA_NO_MESSAGE;
- #endif
- #ifdef EIDRM
- case EIDRM: return MA_ERROR;
- #endif
- #ifdef ECHRNG
- case ECHRNG: return MA_ERROR;
- #endif
- #ifdef EL2NSYNC
- case EL2NSYNC: return MA_ERROR;
- #endif
- #ifdef EL3HLT
- case EL3HLT: return MA_ERROR;
- #endif
- #ifdef EL3RST
- case EL3RST: return MA_ERROR;
- #endif
- #ifdef ELNRNG
- case ELNRNG: return MA_OUT_OF_RANGE;
- #endif
- #ifdef EUNATCH
- case EUNATCH: return MA_ERROR;
- #endif
- #ifdef ENOCSI
- case ENOCSI: return MA_ERROR;
- #endif
- #ifdef EL2HLT
- case EL2HLT: return MA_ERROR;
- #endif
- #ifdef EBADE
- case EBADE: return MA_ERROR;
- #endif
- #ifdef EBADR
- case EBADR: return MA_ERROR;
- #endif
- #ifdef EXFULL
- case EXFULL: return MA_ERROR;
- #endif
- #ifdef ENOANO
- case ENOANO: return MA_ERROR;
- #endif
- #ifdef EBADRQC
- case EBADRQC: return MA_ERROR;
- #endif
- #ifdef EBADSLT
- case EBADSLT: return MA_ERROR;
- #endif
- #ifdef EBFONT
- case EBFONT: return MA_INVALID_FILE;
- #endif
- #ifdef ENOSTR
- case ENOSTR: return MA_ERROR;
- #endif
- #ifdef ENODATA
- case ENODATA: return MA_NO_DATA_AVAILABLE;
- #endif
- #ifdef ETIME
- case ETIME: return MA_TIMEOUT;
- #endif
- #ifdef ENOSR
- case ENOSR: return MA_NO_DATA_AVAILABLE;
- #endif
- #ifdef ENONET
- case ENONET: return MA_NO_NETWORK;
- #endif
- #ifdef ENOPKG
- case ENOPKG: return MA_ERROR;
- #endif
- #ifdef EREMOTE
- case EREMOTE: return MA_ERROR;
- #endif
- #ifdef ENOLINK
- case ENOLINK: return MA_ERROR;
- #endif
- #ifdef EADV
- case EADV: return MA_ERROR;
- #endif
- #ifdef ESRMNT
- case ESRMNT: return MA_ERROR;
- #endif
- #ifdef ECOMM
- case ECOMM: return MA_ERROR;
- #endif
- #ifdef EPROTO
- case EPROTO: return MA_ERROR;
- #endif
- #ifdef EMULTIHOP
- case EMULTIHOP: return MA_ERROR;
- #endif
- #ifdef EDOTDOT
- case EDOTDOT: return MA_ERROR;
- #endif
- #ifdef EBADMSG
- case EBADMSG: return MA_BAD_MESSAGE;
- #endif
- #ifdef EOVERFLOW
- case EOVERFLOW: return MA_TOO_BIG;
- #endif
- #ifdef ENOTUNIQ
- case ENOTUNIQ: return MA_NOT_UNIQUE;
- #endif
- #ifdef EBADFD
- case EBADFD: return MA_ERROR;
- #endif
- #ifdef EREMCHG
- case EREMCHG: return MA_ERROR;
- #endif
- #ifdef ELIBACC
- case ELIBACC: return MA_ACCESS_DENIED;
- #endif
- #ifdef ELIBBAD
- case ELIBBAD: return MA_INVALID_FILE;
- #endif
- #ifdef ELIBSCN
- case ELIBSCN: return MA_INVALID_FILE;
- #endif
- #ifdef ELIBMAX
- case ELIBMAX: return MA_ERROR;
- #endif
- #ifdef ELIBEXEC
- case ELIBEXEC: return MA_ERROR;
- #endif
- #ifdef EILSEQ
- case EILSEQ: return MA_INVALID_DATA;
- #endif
- #ifdef ERESTART
- case ERESTART: return MA_ERROR;
- #endif
- #ifdef ESTRPIPE
- case ESTRPIPE: return MA_ERROR;
- #endif
- #ifdef EUSERS
- case EUSERS: return MA_ERROR;
- #endif
- #ifdef ENOTSOCK
- case ENOTSOCK: return MA_NOT_SOCKET;
- #endif
- #ifdef EDESTADDRREQ
- case EDESTADDRREQ: return MA_NO_ADDRESS;
- #endif
- #ifdef EMSGSIZE
- case EMSGSIZE: return MA_TOO_BIG;
- #endif
- #ifdef EPROTOTYPE
- case EPROTOTYPE: return MA_BAD_PROTOCOL;
- #endif
- #ifdef ENOPROTOOPT
- case ENOPROTOOPT: return MA_PROTOCOL_UNAVAILABLE;
- #endif
- #ifdef EPROTONOSUPPORT
- case EPROTONOSUPPORT: return MA_PROTOCOL_NOT_SUPPORTED;
- #endif
- #ifdef ESOCKTNOSUPPORT
- case ESOCKTNOSUPPORT: return MA_SOCKET_NOT_SUPPORTED;
- #endif
- #ifdef EOPNOTSUPP
- case EOPNOTSUPP: return MA_INVALID_OPERATION;
- #endif
- #ifdef EPFNOSUPPORT
- case EPFNOSUPPORT: return MA_PROTOCOL_FAMILY_NOT_SUPPORTED;
- #endif
- #ifdef EAFNOSUPPORT
- case EAFNOSUPPORT: return MA_ADDRESS_FAMILY_NOT_SUPPORTED;
- #endif
- #ifdef EADDRINUSE
- case EADDRINUSE: return MA_ALREADY_IN_USE;
- #endif
- #ifdef EADDRNOTAVAIL
- case EADDRNOTAVAIL: return MA_ERROR;
- #endif
- #ifdef ENETDOWN
- case ENETDOWN: return MA_NO_NETWORK;
- #endif
- #ifdef ENETUNREACH
- case ENETUNREACH: return MA_NO_NETWORK;
- #endif
- #ifdef ENETRESET
- case ENETRESET: return MA_NO_NETWORK;
- #endif
- #ifdef ECONNABORTED
- case ECONNABORTED: return MA_NO_NETWORK;
- #endif
- #ifdef ECONNRESET
- case ECONNRESET: return MA_CONNECTION_RESET;
- #endif
- #ifdef ENOBUFS
- case ENOBUFS: return MA_NO_SPACE;
- #endif
- #ifdef EISCONN
- case EISCONN: return MA_ALREADY_CONNECTED;
- #endif
- #ifdef ENOTCONN
- case ENOTCONN: return MA_NOT_CONNECTED;
- #endif
- #ifdef ESHUTDOWN
- case ESHUTDOWN: return MA_ERROR;
- #endif
- #ifdef ETOOMANYREFS
- case ETOOMANYREFS: return MA_ERROR;
- #endif
- #ifdef ETIMEDOUT
- case ETIMEDOUT: return MA_TIMEOUT;
- #endif
- #ifdef ECONNREFUSED
- case ECONNREFUSED: return MA_CONNECTION_REFUSED;
- #endif
- #ifdef EHOSTDOWN
- case EHOSTDOWN: return MA_NO_HOST;
- #endif
- #ifdef EHOSTUNREACH
- case EHOSTUNREACH: return MA_NO_HOST;
- #endif
- #ifdef EALREADY
- case EALREADY: return MA_IN_PROGRESS;
- #endif
- #ifdef EINPROGRESS
- case EINPROGRESS: return MA_IN_PROGRESS;
- #endif
- #ifdef ESTALE
- case ESTALE: return MA_INVALID_FILE;
- #endif
- #ifdef EUCLEAN
- case EUCLEAN: return MA_ERROR;
- #endif
- #ifdef ENOTNAM
- case ENOTNAM: return MA_ERROR;
- #endif
- #ifdef ENAVAIL
- case ENAVAIL: return MA_ERROR;
- #endif
- #ifdef EISNAM
- case EISNAM: return MA_ERROR;
- #endif
- #ifdef EREMOTEIO
- case EREMOTEIO: return MA_IO_ERROR;
- #endif
- #ifdef EDQUOT
- case EDQUOT: return MA_NO_SPACE;
- #endif
- #ifdef ENOMEDIUM
- case ENOMEDIUM: return MA_DOES_NOT_EXIST;
- #endif
- #ifdef EMEDIUMTYPE
- case EMEDIUMTYPE: return MA_ERROR;
- #endif
- #ifdef ECANCELED
- case ECANCELED: return MA_CANCELLED;
- #endif
- #ifdef ENOKEY
- case ENOKEY: return MA_ERROR;
- #endif
- #ifdef EKEYEXPIRED
- case EKEYEXPIRED: return MA_ERROR;
- #endif
- #ifdef EKEYREVOKED
- case EKEYREVOKED: return MA_ERROR;
- #endif
- #ifdef EKEYREJECTED
- case EKEYREJECTED: return MA_ERROR;
- #endif
- #ifdef EOWNERDEAD
- case EOWNERDEAD: return MA_ERROR;
- #endif
- #ifdef ENOTRECOVERABLE
- case ENOTRECOVERABLE: return MA_ERROR;
- #endif
- #ifdef ERFKILL
- case ERFKILL: return MA_ERROR;
- #endif
- #ifdef EHWPOISON
- case EHWPOISON: return MA_ERROR;
- #endif
- default: return MA_ERROR;
+ if (e == 0) {
+ return MA_SUCCESS;
+ }
+#ifdef EPERM
+ else if (e == EPERM) { return MA_INVALID_OPERATION; }
+#endif
+#ifdef ENOENT
+ else if (e == ENOENT) { return MA_DOES_NOT_EXIST; }
+#endif
+#ifdef ESRCH
+ else if (e == ESRCH) { return MA_DOES_NOT_EXIST; }
+#endif
+#ifdef EINTR
+ else if (e == EINTR) { return MA_INTERRUPT; }
+#endif
+#ifdef EIO
+ else if (e == EIO) { return MA_IO_ERROR; }
+#endif
+#ifdef ENXIO
+ else if (e == ENXIO) { return MA_DOES_NOT_EXIST; }
+#endif
+#ifdef E2BIG
+ else if (e == E2BIG) { return MA_INVALID_ARGS; }
+#endif
+#ifdef ENOEXEC
+ else if (e == ENOEXEC) { return MA_INVALID_FILE; }
+#endif
+#ifdef EBADF
+ else if (e == EBADF) { return MA_INVALID_FILE; }
+#endif
+#ifdef ECHILD
+ else if (e == ECHILD) { return MA_ERROR; }
+#endif
+#ifdef EAGAIN
+ else if (e == EAGAIN) { return MA_UNAVAILABLE; }
+#endif
+#ifdef ENOMEM
+ else if (e == ENOMEM) { return MA_OUT_OF_MEMORY; }
+#endif
+#ifdef EACCES
+ else if (e == EACCES) { return MA_ACCESS_DENIED; }
+#endif
+#ifdef EFAULT
+ else if (e == EFAULT) { return MA_BAD_ADDRESS; }
+#endif
+#ifdef ENOTBLK
+ else if (e == ENOTBLK) { return MA_ERROR; }
+#endif
+#ifdef EBUSY
+ else if (e == EBUSY) { return MA_BUSY; }
+#endif
+#ifdef EEXIST
+ else if (e == EEXIST) { return MA_ALREADY_EXISTS; }
+#endif
+#ifdef EXDEV
+ else if (e == EXDEV) { return MA_ERROR; }
+#endif
+#ifdef ENODEV
+ else if (e == ENODEV) { return MA_DOES_NOT_EXIST; }
+#endif
+#ifdef ENOTDIR
+ else if (e == ENOTDIR) { return MA_NOT_DIRECTORY; }
+#endif
+#ifdef EISDIR
+ else if (e == EISDIR) { return MA_IS_DIRECTORY; }
+#endif
+#ifdef EINVAL
+ else if (e == EINVAL) { return MA_INVALID_ARGS; }
+#endif
+#ifdef ENFILE
+ else if (e == ENFILE) { return MA_TOO_MANY_OPEN_FILES; }
+#endif
+#ifdef EMFILE
+ else if (e == EMFILE) { return MA_TOO_MANY_OPEN_FILES; }
+#endif
+#ifdef ENOTTY
+ else if (e == ENOTTY) { return MA_INVALID_OPERATION; }
+#endif
+#ifdef ETXTBSY
+ else if (e == ETXTBSY) { return MA_BUSY; }
+#endif
+#ifdef EFBIG
+ else if (e == EFBIG) { return MA_TOO_BIG; }
+#endif
+#ifdef ENOSPC
+ else if (e == ENOSPC) { return MA_NO_SPACE; }
+#endif
+#ifdef ESPIPE
+ else if (e == ESPIPE) { return MA_BAD_SEEK; }
+#endif
+#ifdef EROFS
+ else if (e == EROFS) { return MA_ACCESS_DENIED; }
+#endif
+#ifdef EMLINK
+ else if (e == EMLINK) { return MA_TOO_MANY_LINKS; }
+#endif
+#ifdef EPIPE
+ else if (e == EPIPE) { return MA_BAD_PIPE; }
+#endif
+#ifdef EDOM
+ else if (e == EDOM) { return MA_OUT_OF_RANGE; }
+#endif
+#ifdef ERANGE
+ else if (e == ERANGE) { return MA_OUT_OF_RANGE; }
+#endif
+#ifdef EDEADLK
+ else if (e == EDEADLK) { return MA_DEADLOCK; }
+#endif
+#ifdef ENAMETOOLONG
+ else if (e == ENAMETOOLONG) { return MA_PATH_TOO_LONG; }
+#endif
+#ifdef ENOLCK
+ else if (e == ENOLCK) { return MA_ERROR; }
+#endif
+#ifdef ENOSYS
+ else if (e == ENOSYS) { return MA_NOT_IMPLEMENTED; }
+#endif
+#ifdef ENOTEMPTY
+ else if (e == ENOTEMPTY) { return MA_DIRECTORY_NOT_EMPTY; }
+#endif
+#ifdef ELOOP
+ else if (e == ELOOP) { return MA_TOO_MANY_LINKS; }
+#endif
+#ifdef ENOMSG
+ else if (e == ENOMSG) { return MA_NO_MESSAGE; }
+#endif
+#ifdef EIDRM
+ else if (e == EIDRM) { return MA_ERROR; }
+#endif
+#ifdef ECHRNG
+ else if (e == ECHRNG) { return MA_ERROR; }
+#endif
+#ifdef EL2NSYNC
+ else if (e == EL2NSYNC) { return MA_ERROR; }
+#endif
+#ifdef EL3HLT
+ else if (e == EL3HLT) { return MA_ERROR; }
+#endif
+#ifdef EL3RST
+ else if (e == EL3RST) { return MA_ERROR; }
+#endif
+#ifdef ELNRNG
+ else if (e == ELNRNG) { return MA_OUT_OF_RANGE; }
+#endif
+#ifdef EUNATCH
+ else if (e == EUNATCH) { return MA_ERROR; }
+#endif
+#ifdef ENOCSI
+ else if (e == ENOCSI) { return MA_ERROR; }
+#endif
+#ifdef EL2HLT
+ else if (e == EL2HLT) { return MA_ERROR; }
+#endif
+#ifdef EBADE
+ else if (e == EBADE) { return MA_ERROR; }
+#endif
+#ifdef EBADR
+ else if (e == EBADR) { return MA_ERROR; }
+#endif
+#ifdef EXFULL
+ else if (e == EXFULL) { return MA_ERROR; }
+#endif
+#ifdef ENOANO
+ else if (e == ENOANO) { return MA_ERROR; }
+#endif
+#ifdef EBADRQC
+ else if (e == EBADRQC) { return MA_ERROR; }
+#endif
+#ifdef EBADSLT
+ else if (e == EBADSLT) { return MA_ERROR; }
+#endif
+#ifdef EBFONT
+ else if (e == EBFONT) { return MA_INVALID_FILE; }
+#endif
+#ifdef ENOSTR
+ else if (e == ENOSTR) { return MA_ERROR; }
+#endif
+#ifdef ENODATA
+ else if (e == ENODATA) { return MA_NO_DATA_AVAILABLE; }
+#endif
+#ifdef ETIME
+ else if (e == ETIME) { return MA_TIMEOUT; }
+#endif
+#ifdef ENOSR
+ else if (e == ENOSR) { return MA_NO_DATA_AVAILABLE; }
+#endif
+#ifdef ENONET
+ else if (e == ENONET) { return MA_NO_NETWORK; }
+#endif
+#ifdef ENOPKG
+ else if (e == ENOPKG) { return MA_ERROR; }
+#endif
+#ifdef EREMOTE
+ else if (e == EREMOTE) { return MA_ERROR; }
+#endif
+#ifdef ENOLINK
+ else if (e == ENOLINK) { return MA_ERROR; }
+#endif
+#ifdef EADV
+ else if (e == EADV) { return MA_ERROR; }
+#endif
+#ifdef ESRMNT
+ else if (e == ESRMNT) { return MA_ERROR; }
+#endif
+#ifdef ECOMM
+ else if (e == ECOMM) { return MA_ERROR; }
+#endif
+#ifdef EPROTO
+ else if (e == EPROTO) { return MA_ERROR; }
+#endif
+#ifdef EMULTIHOP
+ else if (e == EMULTIHOP) { return MA_ERROR; }
+#endif
+#ifdef EDOTDOT
+ else if (e == EDOTDOT) { return MA_ERROR; }
+#endif
+#ifdef EBADMSG
+ else if (e == EBADMSG) { return MA_BAD_MESSAGE; }
+#endif
+#ifdef EOVERFLOW
+ else if (e == EOVERFLOW) { return MA_TOO_BIG; }
+#endif
+#ifdef ENOTUNIQ
+ else if (e == ENOTUNIQ) { return MA_NOT_UNIQUE; }
+#endif
+#ifdef EBADFD
+ else if (e == EBADFD) { return MA_ERROR; }
+#endif
+#ifdef EREMCHG
+ else if (e == EREMCHG) { return MA_ERROR; }
+#endif
+#ifdef ELIBACC
+ else if (e == ELIBACC) { return MA_ACCESS_DENIED; }
+#endif
+#ifdef ELIBBAD
+ else if (e == ELIBBAD) { return MA_INVALID_FILE; }
+#endif
+#ifdef ELIBSCN
+ else if (e == ELIBSCN) { return MA_INVALID_FILE; }
+#endif
+#ifdef ELIBMAX
+ else if (e == ELIBMAX) { return MA_ERROR; }
+#endif
+#ifdef ELIBEXEC
+ else if (e == ELIBEXEC) { return MA_ERROR; }
+#endif
+#ifdef EILSEQ
+ else if (e == EILSEQ) { return MA_INVALID_DATA; }
+#endif
+#ifdef ERESTART
+ else if (e == ERESTART) { return MA_ERROR; }
+#endif
+#ifdef ESTRPIPE
+ else if (e == ESTRPIPE) { return MA_ERROR; }
+#endif
+#ifdef EUSERS
+ else if (e == EUSERS) { return MA_ERROR; }
+#endif
+#ifdef ENOTSOCK
+ else if (e == ENOTSOCK) { return MA_NOT_SOCKET; }
+#endif
+#ifdef EDESTADDRREQ
+ else if (e == EDESTADDRREQ) { return MA_NO_ADDRESS; }
+#endif
+#ifdef EMSGSIZE
+ else if (e == EMSGSIZE) { return MA_TOO_BIG; }
+#endif
+#ifdef EPROTOTYPE
+ else if (e == EPROTOTYPE) { return MA_BAD_PROTOCOL; }
+#endif
+#ifdef ENOPROTOOPT
+ else if (e == ENOPROTOOPT) { return MA_PROTOCOL_UNAVAILABLE; }
+#endif
+#ifdef EPROTONOSUPPORT
+ else if (e == EPROTONOSUPPORT) { return MA_PROTOCOL_NOT_SUPPORTED; }
+#endif
+#ifdef ESOCKTNOSUPPORT
+ else if (e == ESOCKTNOSUPPORT) { return MA_SOCKET_NOT_SUPPORTED; }
+#endif
+#ifdef EOPNOTSUPP
+ else if (e == EOPNOTSUPP) { return MA_INVALID_OPERATION; }
+#endif
+#ifdef EPFNOSUPPORT
+ else if (e == EPFNOSUPPORT) { return MA_PROTOCOL_FAMILY_NOT_SUPPORTED; }
+#endif
+#ifdef EAFNOSUPPORT
+ else if (e == EAFNOSUPPORT) { return MA_ADDRESS_FAMILY_NOT_SUPPORTED; }
+#endif
+#ifdef EADDRINUSE
+ else if (e == EADDRINUSE) { return MA_ALREADY_IN_USE; }
+#endif
+#ifdef EADDRNOTAVAIL
+ else if (e == EADDRNOTAVAIL) { return MA_ERROR; }
+#endif
+#ifdef ENETDOWN
+ else if (e == ENETDOWN) { return MA_NO_NETWORK; }
+#endif
+#ifdef ENETUNREACH
+ else if (e == ENETUNREACH) { return MA_NO_NETWORK; }
+#endif
+#ifdef ENETRESET
+ else if (e == ENETRESET) { return MA_NO_NETWORK; }
+#endif
+#ifdef ECONNABORTED
+ else if (e == ECONNABORTED) { return MA_NO_NETWORK; }
+#endif
+#ifdef ECONNRESET
+ else if (e == ECONNRESET) { return MA_CONNECTION_RESET; }
+#endif
+#ifdef ENOBUFS
+ else if (e == ENOBUFS) { return MA_NO_SPACE; }
+#endif
+#ifdef EISCONN
+ else if (e == EISCONN) { return MA_ALREADY_CONNECTED; }
+#endif
+#ifdef ENOTCONN
+ else if (e == ENOTCONN) { return MA_NOT_CONNECTED; }
+#endif
+#ifdef ESHUTDOWN
+ else if (e == ESHUTDOWN) { return MA_ERROR; }
+#endif
+#ifdef ETOOMANYREFS
+ else if (e == ETOOMANYREFS) { return MA_ERROR; }
+#endif
+#ifdef ETIMEDOUT
+ else if (e == ETIMEDOUT) { return MA_TIMEOUT; }
+#endif
+#ifdef ECONNREFUSED
+ else if (e == ECONNREFUSED) { return MA_CONNECTION_REFUSED; }
+#endif
+#ifdef EHOSTDOWN
+ else if (e == EHOSTDOWN) { return MA_NO_HOST; }
+#endif
+#ifdef EHOSTUNREACH
+ else if (e == EHOSTUNREACH) { return MA_NO_HOST; }
+#endif
+#ifdef EALREADY
+ else if (e == EALREADY) { return MA_IN_PROGRESS; }
+#endif
+#ifdef EINPROGRESS
+ else if (e == EINPROGRESS) { return MA_IN_PROGRESS; }
+#endif
+#ifdef ESTALE
+ else if (e == ESTALE) { return MA_INVALID_FILE; }
+#endif
+#ifdef EUCLEAN
+ else if (e == EUCLEAN) { return MA_ERROR; }
+#endif
+#ifdef ENOTNAM
+ else if (e == ENOTNAM) { return MA_ERROR; }
+#endif
+#ifdef ENAVAIL
+ else if (e == ENAVAIL) { return MA_ERROR; }
+#endif
+#ifdef EISNAM
+ else if (e == EISNAM) { return MA_ERROR; }
+#endif
+#ifdef EREMOTEIO
+ else if (e == EREMOTEIO) { return MA_IO_ERROR; }
+#endif
+#ifdef EDQUOT
+ else if (e == EDQUOT) { return MA_NO_SPACE; }
+#endif
+#ifdef ENOMEDIUM
+ else if (e == ENOMEDIUM) { return MA_DOES_NOT_EXIST; }
+#endif
+#ifdef EMEDIUMTYPE
+ else if (e == EMEDIUMTYPE) { return MA_ERROR; }
+#endif
+#ifdef ECANCELED
+ else if (e == ECANCELED) { return MA_CANCELLED; }
+#endif
+#ifdef ENOKEY
+ else if (e == ENOKEY) { return MA_ERROR; }
+#endif
+#ifdef EKEYEXPIRED
+ else if (e == EKEYEXPIRED) { return MA_ERROR; }
+#endif
+#ifdef EKEYREVOKED
+ else if (e == EKEYREVOKED) { return MA_ERROR; }
+#endif
+#ifdef EKEYREJECTED
+ else if (e == EKEYREJECTED) { return MA_ERROR; }
+#endif
+#ifdef EOWNERDEAD
+ else if (e == EOWNERDEAD) { return MA_ERROR; }
+#endif
+#ifdef ENOTRECOVERABLE
+ else if (e == ENOTRECOVERABLE) { return MA_ERROR; }
+#endif
+#ifdef ERFKILL
+ else if (e == ERFKILL) { return MA_ERROR; }
+#endif
+#ifdef EHWPOISON
+ else if (e == EHWPOISON) { return MA_ERROR; }
+#endif
+ else {
+ return MA_ERROR;
}
}
@@ -12969,6 +13334,9 @@ MA_API const char* ma_log_level_to_string(ma_uint32 logLevel)
}
#if defined(MA_DEBUG_OUTPUT)
+#if defined(MA_ANDROID)
+ #include
+#endif
/* Customize this to use a specific tag in __android_log_print() for debug output messages. */
#ifndef MA_ANDROID_LOG_TAG
@@ -13187,7 +13555,7 @@ MA_API ma_result ma_log_postv(ma_log* pLog, ma_uint32 level, const char* pFormat
return MA_INVALID_ARGS;
}
- #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || ((!defined(_MSC_VER) || _MSC_VER >= 1900) && !defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
+ #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || ((!defined(_MSC_VER) || _MSC_VER >= 1900) && !defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS)) || (defined(__cplusplus) && __cplusplus >= 201103L)
{
ma_result result;
int length;
@@ -13582,6 +13950,13 @@ Atomics
#if defined(__cplusplus)
extern "C" {
#endif
+#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wlong-long"
+ #if defined(__clang__)
+ #pragma GCC diagnostic ignored "-Wc++11-long-long"
+ #endif
+#endif
typedef signed char c89atomic_int8;
typedef unsigned char c89atomic_uint8;
typedef signed short c89atomic_int16;
@@ -13592,18 +13967,8 @@ typedef unsigned int c89atomic_uint32;
typedef signed __int64 c89atomic_int64;
typedef unsigned __int64 c89atomic_uint64;
#else
- #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wlong-long"
- #if defined(__clang__)
- #pragma GCC diagnostic ignored "-Wc++11-long-long"
- #endif
- #endif
typedef signed long long c89atomic_int64;
typedef unsigned long long c89atomic_uint64;
- #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
- #pragma GCC diagnostic pop
- #endif
#endif
typedef int c89atomic_memory_order;
typedef unsigned char c89atomic_bool;
@@ -13633,11 +13998,17 @@ typedef unsigned char c89atomic_bool;
#define C89ATOMIC_32BIT
#endif
#endif
+#if defined(__arm__) || defined(_M_ARM)
+#define C89ATOMIC_ARM32
+#endif
+#if defined(__arm64) || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
+#define C89ATOMIC_ARM64
+#endif
#if defined(__x86_64__) || defined(_M_X64)
#define C89ATOMIC_X64
#elif defined(__i386) || defined(_M_IX86)
#define C89ATOMIC_X86
-#elif defined(__arm__) || defined(_M_ARM) || defined(__arm64) || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
+#elif defined(C89ATOMIC_ARM32) || defined(C89ATOMIC_ARM64)
#define C89ATOMIC_ARM
#endif
#if defined(_MSC_VER)
@@ -13658,6 +14029,56 @@ typedef unsigned char c89atomic_bool;
#define C89ATOMIC_HAS_32
#define C89ATOMIC_HAS_64
#if (defined(_MSC_VER) ) || defined(__WATCOMC__) || defined(__DMC__)
+ #define C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, intrin, c89atomicType, msvcType) \
+ c89atomicType result; \
+ switch (order) \
+ { \
+ case c89atomic_memory_order_relaxed: \
+ { \
+ result = (c89atomicType)intrin##_nf((volatile msvcType*)dst, (msvcType)src); \
+ } break; \
+ case c89atomic_memory_order_consume: \
+ case c89atomic_memory_order_acquire: \
+ { \
+ result = (c89atomicType)intrin##_acq((volatile msvcType*)dst, (msvcType)src); \
+ } break; \
+ case c89atomic_memory_order_release: \
+ { \
+ result = (c89atomicType)intrin##_rel((volatile msvcType*)dst, (msvcType)src); \
+ } break; \
+ case c89atomic_memory_order_acq_rel: \
+ case c89atomic_memory_order_seq_cst: \
+ default: \
+ { \
+ result = (c89atomicType)intrin((volatile msvcType*)dst, (msvcType)src); \
+ } break; \
+ } \
+ return result;
+ #define C89ATOMIC_MSVC_ARM_INTRINSIC_COMPARE_EXCHANGE(ptr, expected, desired, order, intrin, c89atomicType, msvcType) \
+ c89atomicType result; \
+ switch (order) \
+ { \
+ case c89atomic_memory_order_relaxed: \
+ { \
+ result = (c89atomicType)intrin##_nf((volatile msvcType*)ptr, (msvcType)expected, (msvcType)desired); \
+ } break; \
+ case c89atomic_memory_order_consume: \
+ case c89atomic_memory_order_acquire: \
+ { \
+ result = (c89atomicType)intrin##_acq((volatile msvcType*)ptr, (msvcType)expected, (msvcType)desired); \
+ } break; \
+ case c89atomic_memory_order_release: \
+ { \
+ result = (c89atomicType)intrin##_rel((volatile msvcType*)ptr, (msvcType)expected, (msvcType)desired); \
+ } break; \
+ case c89atomic_memory_order_acq_rel: \
+ case c89atomic_memory_order_seq_cst: \
+ default: \
+ { \
+ result = (c89atomicType)intrin((volatile msvcType*)ptr, (msvcType)expected, (msvcType)desired); \
+ } break; \
+ } \
+ return result;
#define c89atomic_memory_order_relaxed 0
#define c89atomic_memory_order_consume 1
#define c89atomic_memory_order_acquire 2
@@ -13796,29 +14217,45 @@ typedef unsigned char c89atomic_bool;
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchange8, c89atomic_uint8, char);
+ #else
(void)order;
return (c89atomic_uint8)_InterlockedExchange8((volatile char*)dst, (char)src);
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchange16, c89atomic_uint16, short);
+ #else
(void)order;
return (c89atomic_uint16)_InterlockedExchange16((volatile short*)dst, (short)src);
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchange, c89atomic_uint32, long);
+ #else
(void)order;
return (c89atomic_uint32)_InterlockedExchange((volatile long*)dst, (long)src);
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_64) && defined(C89ATOMIC_64BIT)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchange64, c89atomic_uint64, long long);
+ #else
(void)order;
return (c89atomic_uint64)_InterlockedExchange64((volatile long long*)dst, (long long)src);
+ #endif
}
#else
#endif
@@ -13881,29 +14318,45 @@ typedef unsigned char c89atomic_bool;
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_add_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchangeAdd8, c89atomic_uint8, char);
+ #else
(void)order;
return (c89atomic_uint8)_InterlockedExchangeAdd8((volatile char*)dst, (char)src);
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_add_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchangeAdd16, c89atomic_uint16, short);
+ #else
(void)order;
return (c89atomic_uint16)_InterlockedExchangeAdd16((volatile short*)dst, (short)src);
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_add_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchangeAdd, c89atomic_uint32, long);
+ #else
(void)order;
return (c89atomic_uint32)_InterlockedExchangeAdd((volatile long*)dst, (long)src);
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_64) && defined(C89ATOMIC_64BIT)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedExchangeAdd64, c89atomic_uint64, long long);
+ #else
(void)order;
return (c89atomic_uint64)_InterlockedExchangeAdd64((volatile long long*)dst, (long long)src);
+ #endif
}
#else
#endif
@@ -13932,6 +14385,8 @@ typedef unsigned char c89atomic_bool;
#else
#if defined(C89ATOMIC_X64)
#define c89atomic_thread_fence(order) __faststorefence(), (void)order
+ #elif defined(C89ATOMIC_ARM64)
+ #define c89atomic_thread_fence(order) __dmb(_ARM64_BARRIER_ISH), (void)order
#else
static C89ATOMIC_INLINE void c89atomic_thread_fence(c89atomic_memory_order order)
{
@@ -13945,29 +14400,45 @@ typedef unsigned char c89atomic_bool;
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_load_explicit_8(volatile const c89atomic_uint8* ptr, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC_COMPARE_EXCHANGE(ptr, 0, 0, order, _InterlockedCompareExchange8, c89atomic_uint8, char);
+ #else
(void)order;
return c89atomic_compare_and_swap_8((volatile c89atomic_uint8*)ptr, 0, 0);
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_load_explicit_16(volatile const c89atomic_uint16* ptr, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC_COMPARE_EXCHANGE(ptr, 0, 0, order, _InterlockedCompareExchange16, c89atomic_uint16, short);
+ #else
(void)order;
return c89atomic_compare_and_swap_16((volatile c89atomic_uint16*)ptr, 0, 0);
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_load_explicit_32(volatile const c89atomic_uint32* ptr, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC_COMPARE_EXCHANGE(ptr, 0, 0, order, _InterlockedCompareExchange, c89atomic_uint32, long);
+ #else
(void)order;
return c89atomic_compare_and_swap_32((volatile c89atomic_uint32*)ptr, 0, 0);
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_64)
static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_load_explicit_64(volatile const c89atomic_uint64* ptr, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC_COMPARE_EXCHANGE(ptr, 0, 0, order, _InterlockedCompareExchange64, c89atomic_uint64, long long);
+ #else
(void)order;
return c89atomic_compare_and_swap_64((volatile c89atomic_uint64*)ptr, 0, 0);
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_8)
@@ -14037,6 +14508,9 @@ typedef unsigned char c89atomic_bool;
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_and_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedAnd8, c89atomic_uint8, char);
+ #else
c89atomic_uint8 oldValue;
c89atomic_uint8 newValue;
do {
@@ -14045,11 +14519,15 @@ typedef unsigned char c89atomic_bool;
} while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_and_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedAnd16, c89atomic_uint16, short);
+ #else
c89atomic_uint16 oldValue;
c89atomic_uint16 newValue;
do {
@@ -14058,11 +14536,15 @@ typedef unsigned char c89atomic_bool;
} while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_and_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedAnd, c89atomic_uint32, long);
+ #else
c89atomic_uint32 oldValue;
c89atomic_uint32 newValue;
do {
@@ -14071,11 +14553,15 @@ typedef unsigned char c89atomic_bool;
} while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_64)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_and_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedAnd64, c89atomic_uint64, long long);
+ #else
c89atomic_uint64 oldValue;
c89atomic_uint64 newValue;
do {
@@ -14084,11 +14570,15 @@ typedef unsigned char c89atomic_bool;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_xor_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedXor8, c89atomic_uint8, char);
+ #else
c89atomic_uint8 oldValue;
c89atomic_uint8 newValue;
do {
@@ -14097,11 +14587,15 @@ typedef unsigned char c89atomic_bool;
} while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_xor_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedXor16, c89atomic_uint16, short);
+ #else
c89atomic_uint16 oldValue;
c89atomic_uint16 newValue;
do {
@@ -14110,11 +14604,15 @@ typedef unsigned char c89atomic_bool;
} while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_xor_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedXor, c89atomic_uint32, long);
+ #else
c89atomic_uint32 oldValue;
c89atomic_uint32 newValue;
do {
@@ -14123,11 +14621,15 @@ typedef unsigned char c89atomic_bool;
} while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_64)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_xor_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedXor64, c89atomic_uint64, long long);
+ #else
c89atomic_uint64 oldValue;
c89atomic_uint64 newValue;
do {
@@ -14136,11 +14638,15 @@ typedef unsigned char c89atomic_bool;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_8)
static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_or_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedOr8, c89atomic_uint8, char);
+ #else
c89atomic_uint8 oldValue;
c89atomic_uint8 newValue;
do {
@@ -14149,11 +14655,15 @@ typedef unsigned char c89atomic_bool;
} while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_16)
static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_or_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedOr16, c89atomic_uint16, short);
+ #else
c89atomic_uint16 oldValue;
c89atomic_uint16 newValue;
do {
@@ -14162,11 +14672,15 @@ typedef unsigned char c89atomic_bool;
} while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_32)
static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_or_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedOr, c89atomic_uint32, long);
+ #else
c89atomic_uint32 oldValue;
c89atomic_uint32 newValue;
do {
@@ -14175,11 +14689,15 @@ typedef unsigned char c89atomic_bool;
} while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_64)
static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_or_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
{
+ #if defined(C89ATOMIC_ARM)
+ C89ATOMIC_MSVC_ARM_INTRINSIC(dst, src, order, _InterlockedOr64, c89atomic_uint64, long long);
+ #else
c89atomic_uint64 oldValue;
c89atomic_uint64 newValue;
do {
@@ -14188,6 +14706,7 @@ typedef unsigned char c89atomic_bool;
} while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
(void)order;
return oldValue;
+ #endif
}
#endif
#if defined(C89ATOMIC_HAS_8)
@@ -14289,10 +14808,26 @@ typedef unsigned char c89atomic_bool;
#define c89atomic_fetch_and_explicit_16(dst, src, order) __atomic_fetch_and(dst, src, order)
#define c89atomic_fetch_and_explicit_32(dst, src, order) __atomic_fetch_and(dst, src, order)
#define c89atomic_fetch_and_explicit_64(dst, src, order) __atomic_fetch_and(dst, src, order)
- #define c89atomic_compare_and_swap_8 (dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired)
- #define c89atomic_compare_and_swap_16(dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired)
- #define c89atomic_compare_and_swap_32(dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired)
- #define c89atomic_compare_and_swap_64(dst, expected, desired) __sync_val_compare_and_swap(dst, expected, desired)
+ static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_compare_and_swap_8(volatile c89atomic_uint8* dst, c89atomic_uint8 expected, c89atomic_uint8 desired)
+ {
+ __atomic_compare_exchange_n(dst, &expected, desired, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
+ return expected;
+ }
+ static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_compare_and_swap_16(volatile c89atomic_uint16* dst, c89atomic_uint16 expected, c89atomic_uint16 desired)
+ {
+ __atomic_compare_exchange_n(dst, &expected, desired, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
+ return expected;
+ }
+ static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_compare_and_swap_32(volatile c89atomic_uint32* dst, c89atomic_uint32 expected, c89atomic_uint32 desired)
+ {
+ __atomic_compare_exchange_n(dst, &expected, desired, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
+ return expected;
+ }
+ static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_compare_and_swap_64(volatile c89atomic_uint64* dst, c89atomic_uint64 expected, c89atomic_uint64 desired)
+ {
+ __atomic_compare_exchange_n(dst, &expected, desired, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
+ return expected;
+ }
typedef c89atomic_uint8 c89atomic_flag;
#define c89atomic_flag_test_and_set_explicit(dst, order) (c89atomic_bool)__atomic_test_and_set(dst, order)
#define c89atomic_flag_clear_explicit(dst, order) __atomic_clear(dst, order)
@@ -14814,7 +15349,7 @@ typedef unsigned char c89atomic_bool;
#endif
#if !defined(C89ATOMIC_HAS_NATIVE_COMPARE_EXCHANGE)
#if defined(C89ATOMIC_HAS_8)
- c89atomic_bool c89atomic_compare_exchange_strong_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8* expected, c89atomic_uint8 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
+ static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_strong_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8* expected, c89atomic_uint8 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
{
c89atomic_uint8 expectedValue;
c89atomic_uint8 result;
@@ -14831,7 +15366,7 @@ typedef unsigned char c89atomic_bool;
}
#endif
#if defined(C89ATOMIC_HAS_16)
- c89atomic_bool c89atomic_compare_exchange_strong_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16* expected, c89atomic_uint16 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
+ static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_strong_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16* expected, c89atomic_uint16 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
{
c89atomic_uint16 expectedValue;
c89atomic_uint16 result;
@@ -14848,7 +15383,7 @@ typedef unsigned char c89atomic_bool;
}
#endif
#if defined(C89ATOMIC_HAS_32)
- c89atomic_bool c89atomic_compare_exchange_strong_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32* expected, c89atomic_uint32 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
+ static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_strong_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32* expected, c89atomic_uint32 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
{
c89atomic_uint32 expectedValue;
c89atomic_uint32 result;
@@ -14865,7 +15400,7 @@ typedef unsigned char c89atomic_bool;
}
#endif
#if defined(C89ATOMIC_HAS_64)
- c89atomic_bool c89atomic_compare_exchange_strong_explicit_64(volatile c89atomic_uint64* dst, volatile c89atomic_uint64* expected, c89atomic_uint64 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
+ static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_strong_explicit_64(volatile c89atomic_uint64* dst, volatile c89atomic_uint64* expected, c89atomic_uint64 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
{
c89atomic_uint64 expectedValue;
c89atomic_uint64 result;
@@ -15040,10 +15575,10 @@ typedef unsigned char c89atomic_bool;
#define c89atomic_clear_explicit_i16(ptr, order) c89atomic_clear_explicit_16((c89atomic_uint16*)ptr, order)
#define c89atomic_clear_explicit_i32(ptr, order) c89atomic_clear_explicit_32((c89atomic_uint32*)ptr, order)
#define c89atomic_clear_explicit_i64(ptr, order) c89atomic_clear_explicit_64((c89atomic_uint64*)ptr, order)
-#define c89atomic_store_explicit_i8( dst, src, order) (c89atomic_int8 )c89atomic_store_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_store_explicit_i16(dst, src, order) (c89atomic_int16)c89atomic_store_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_store_explicit_i32(dst, src, order) (c89atomic_int32)c89atomic_store_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_store_explicit_i64(dst, src, order) (c89atomic_int64)c89atomic_store_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
+#define c89atomic_store_explicit_i8( dst, src, order) c89atomic_store_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
+#define c89atomic_store_explicit_i16(dst, src, order) c89atomic_store_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
+#define c89atomic_store_explicit_i32(dst, src, order) c89atomic_store_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
+#define c89atomic_store_explicit_i64(dst, src, order) c89atomic_store_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
#define c89atomic_load_explicit_i8( ptr, order) (c89atomic_int8 )c89atomic_load_explicit_8( (c89atomic_uint8* )ptr, order)
#define c89atomic_load_explicit_i16(ptr, order) (c89atomic_int16)c89atomic_load_explicit_16((c89atomic_uint16*)ptr, order)
#define c89atomic_load_explicit_i32(ptr, order) (c89atomic_int32)c89atomic_load_explicit_32((c89atomic_uint32*)ptr, order)
@@ -15184,6 +15719,110 @@ static C89ATOMIC_INLINE double c89atomic_exchange_explicit_f64(volatile double*
r.i = c89atomic_exchange_explicit_64((volatile c89atomic_uint64*)dst, x.i, order);
return r.f;
}
+static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_strong_explicit_f32(volatile float* dst, float* expected, float desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
+{
+ c89atomic_if32 d;
+ d.f = desired;
+ return c89atomic_compare_exchange_strong_explicit_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32*)expected, d.i, successOrder, failureOrder);
+}
+static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_strong_explicit_f64(volatile double* dst, double* expected, double desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
+{
+ c89atomic_if64 d;
+ d.f = desired;
+ return c89atomic_compare_exchange_strong_explicit_64((volatile c89atomic_uint64*)dst, (c89atomic_uint64*)expected, d.i, successOrder, failureOrder);
+}
+static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_weak_explicit_f32(volatile float* dst, float* expected, float desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
+{
+ c89atomic_if32 d;
+ d.f = desired;
+ return c89atomic_compare_exchange_weak_explicit_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32*)expected, d.i, successOrder, failureOrder);
+}
+static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_weak_explicit_f64(volatile double* dst, double* expected, double desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
+{
+ c89atomic_if64 d;
+ d.f = desired;
+ return c89atomic_compare_exchange_weak_explicit_64((volatile c89atomic_uint64*)dst, (c89atomic_uint64*)expected, d.i, successOrder, failureOrder);
+}
+static C89ATOMIC_INLINE float c89atomic_fetch_add_explicit_f32(volatile float* dst, float src, c89atomic_memory_order order)
+{
+ c89atomic_if32 r;
+ c89atomic_if32 x;
+ x.f = src;
+ r.i = c89atomic_fetch_add_explicit_32((volatile c89atomic_uint32*)dst, x.i, order);
+ return r.f;
+}
+static C89ATOMIC_INLINE double c89atomic_fetch_add_explicit_f64(volatile double* dst, double src, c89atomic_memory_order order)
+{
+ c89atomic_if64 r;
+ c89atomic_if64 x;
+ x.f = src;
+ r.i = c89atomic_fetch_add_explicit_64((volatile c89atomic_uint64*)dst, x.i, order);
+ return r.f;
+}
+static C89ATOMIC_INLINE float c89atomic_fetch_sub_explicit_f32(volatile float* dst, float src, c89atomic_memory_order order)
+{
+ c89atomic_if32 r;
+ c89atomic_if32 x;
+ x.f = src;
+ r.i = c89atomic_fetch_sub_explicit_32((volatile c89atomic_uint32*)dst, x.i, order);
+ return r.f;
+}
+static C89ATOMIC_INLINE double c89atomic_fetch_sub_explicit_f64(volatile double* dst, double src, c89atomic_memory_order order)
+{
+ c89atomic_if64 r;
+ c89atomic_if64 x;
+ x.f = src;
+ r.i = c89atomic_fetch_sub_explicit_64((volatile c89atomic_uint64*)dst, x.i, order);
+ return r.f;
+}
+static C89ATOMIC_INLINE float c89atomic_fetch_or_explicit_f32(volatile float* dst, float src, c89atomic_memory_order order)
+{
+ c89atomic_if32 r;
+ c89atomic_if32 x;
+ x.f = src;
+ r.i = c89atomic_fetch_or_explicit_32((volatile c89atomic_uint32*)dst, x.i, order);
+ return r.f;
+}
+static C89ATOMIC_INLINE double c89atomic_fetch_or_explicit_f64(volatile double* dst, double src, c89atomic_memory_order order)
+{
+ c89atomic_if64 r;
+ c89atomic_if64 x;
+ x.f = src;
+ r.i = c89atomic_fetch_or_explicit_64((volatile c89atomic_uint64*)dst, x.i, order);
+ return r.f;
+}
+static C89ATOMIC_INLINE float c89atomic_fetch_xor_explicit_f32(volatile float* dst, float src, c89atomic_memory_order order)
+{
+ c89atomic_if32 r;
+ c89atomic_if32 x;
+ x.f = src;
+ r.i = c89atomic_fetch_xor_explicit_32((volatile c89atomic_uint32*)dst, x.i, order);
+ return r.f;
+}
+static C89ATOMIC_INLINE double c89atomic_fetch_xor_explicit_f64(volatile double* dst, double src, c89atomic_memory_order order)
+{
+ c89atomic_if64 r;
+ c89atomic_if64 x;
+ x.f = src;
+ r.i = c89atomic_fetch_xor_explicit_64((volatile c89atomic_uint64*)dst, x.i, order);
+ return r.f;
+}
+static C89ATOMIC_INLINE float c89atomic_fetch_and_explicit_f32(volatile float* dst, float src, c89atomic_memory_order order)
+{
+ c89atomic_if32 r;
+ c89atomic_if32 x;
+ x.f = src;
+ r.i = c89atomic_fetch_and_explicit_32((volatile c89atomic_uint32*)dst, x.i, order);
+ return r.f;
+}
+static C89ATOMIC_INLINE double c89atomic_fetch_and_explicit_f64(volatile double* dst, double src, c89atomic_memory_order order)
+{
+ c89atomic_if64 r;
+ c89atomic_if64 x;
+ x.f = src;
+ r.i = c89atomic_fetch_and_explicit_64((volatile c89atomic_uint64*)dst, x.i, order);
+ return r.f;
+}
#define c89atomic_clear_f32(ptr) (float )c89atomic_clear_explicit_f32(ptr, c89atomic_memory_order_seq_cst)
#define c89atomic_clear_f64(ptr) (double)c89atomic_clear_explicit_f64(ptr, c89atomic_memory_order_seq_cst)
#define c89atomic_store_f32(dst, src) c89atomic_store_explicit_f32(dst, src, c89atomic_memory_order_seq_cst)
@@ -15192,6 +15831,38 @@ static C89ATOMIC_INLINE double c89atomic_exchange_explicit_f64(volatile double*
#define c89atomic_load_f64(ptr) (double)c89atomic_load_explicit_f64(ptr, c89atomic_memory_order_seq_cst)
#define c89atomic_exchange_f32(dst, src) (float )c89atomic_exchange_explicit_f32(dst, src, c89atomic_memory_order_seq_cst)
#define c89atomic_exchange_f64(dst, src) (double)c89atomic_exchange_explicit_f64(dst, src, c89atomic_memory_order_seq_cst)
+#define c89atomic_compare_exchange_strong_f32(dst, expected, desired) c89atomic_compare_exchange_strong_explicit_f32(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
+#define c89atomic_compare_exchange_strong_f64(dst, expected, desired) c89atomic_compare_exchange_strong_explicit_f64(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
+#define c89atomic_compare_exchange_weak_f32(dst, expected, desired) c89atomic_compare_exchange_weak_explicit_f32(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
+#define c89atomic_compare_exchange_weak_f64(dst, expected, desired) c89atomic_compare_exchange_weak_explicit_f64(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
+#define c89atomic_fetch_add_f32(dst, src) c89atomic_fetch_add_explicit_f32(dst, src, c89atomic_memory_order_seq_cst)
+#define c89atomic_fetch_add_f64(dst, src) c89atomic_fetch_add_explicit_f64(dst, src, c89atomic_memory_order_seq_cst)
+#define c89atomic_fetch_sub_f32(dst, src) c89atomic_fetch_sub_explicit_f32(dst, src, c89atomic_memory_order_seq_cst)
+#define c89atomic_fetch_sub_f64(dst, src) c89atomic_fetch_sub_explicit_f64(dst, src, c89atomic_memory_order_seq_cst)
+#define c89atomic_fetch_or_f32(dst, src) c89atomic_fetch_or_explicit_f32(dst, src, c89atomic_memory_order_seq_cst)
+#define c89atomic_fetch_or_f64(dst, src) c89atomic_fetch_or_explicit_f64(dst, src, c89atomic_memory_order_seq_cst)
+#define c89atomic_fetch_xor_f32(dst, src) c89atomic_fetch_xor_explicit_f32(dst, src, c89atomic_memory_order_seq_cst)
+#define c89atomic_fetch_xor_f64(dst, src) c89atomic_fetch_xor_explicit_f64(dst, src, c89atomic_memory_order_seq_cst)
+#define c89atomic_fetch_and_f32(dst, src) c89atomic_fetch_and_explicit_f32(dst, src, c89atomic_memory_order_seq_cst)
+#define c89atomic_fetch_and_f64(dst, src) c89atomic_fetch_and_explicit_f64(dst, src, c89atomic_memory_order_seq_cst)
+static C89ATOMIC_INLINE float c89atomic_compare_and_swap_f32(volatile float* dst, float expected, float desired)
+{
+ c89atomic_if32 r;
+ c89atomic_if32 e, d;
+ e.f = expected;
+ d.f = desired;
+ r.i = c89atomic_compare_and_swap_32((volatile c89atomic_uint32*)dst, e.i, d.i);
+ return r.f;
+}
+static C89ATOMIC_INLINE double c89atomic_compare_and_swap_f64(volatile double* dst, double expected, double desired)
+{
+ c89atomic_if64 r;
+ c89atomic_if64 e, d;
+ e.f = expected;
+ d.f = desired;
+ r.i = c89atomic_compare_and_swap_64((volatile c89atomic_uint64*)dst, e.i, d.i);
+ return r.f;
+}
typedef c89atomic_flag c89atomic_spinlock;
static C89ATOMIC_INLINE void c89atomic_spinlock_lock(volatile c89atomic_spinlock* pSpinlock)
{
@@ -15207,12 +15878,88 @@ static C89ATOMIC_INLINE void c89atomic_spinlock_unlock(volatile c89atomic_spinlo
{
c89atomic_flag_clear_explicit(pSpinlock, c89atomic_memory_order_release);
}
+#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
+ #pragma GCC diagnostic pop
+#endif
#if defined(__cplusplus)
}
#endif
#endif
/* c89atomic.h end */
+#define MA_ATOMIC_SAFE_TYPE_IMPL(c89TypeExtension, type) \
+ static MA_INLINE ma_##type ma_atomic_##type##_get(ma_atomic_##type* x) \
+ { \
+ return (ma_##type)c89atomic_load_##c89TypeExtension(&x->value); \
+ } \
+ static MA_INLINE void ma_atomic_##type##_set(ma_atomic_##type* x, ma_##type value) \
+ { \
+ c89atomic_store_##c89TypeExtension(&x->value, value); \
+ } \
+ static MA_INLINE ma_##type ma_atomic_##type##_exchange(ma_atomic_##type* x, ma_##type value) \
+ { \
+ return (ma_##type)c89atomic_exchange_##c89TypeExtension(&x->value, value); \
+ } \
+ static MA_INLINE ma_bool32 ma_atomic_##type##_compare_exchange(ma_atomic_##type* x, ma_##type* expected, ma_##type desired) \
+ { \
+ return c89atomic_compare_exchange_weak_##c89TypeExtension(&x->value, expected, desired); \
+ } \
+ static MA_INLINE ma_##type ma_atomic_##type##_fetch_add(ma_atomic_##type* x, ma_##type y) \
+ { \
+ return (ma_##type)c89atomic_fetch_add_##c89TypeExtension(&x->value, y); \
+ } \
+ static MA_INLINE ma_##type ma_atomic_##type##_fetch_sub(ma_atomic_##type* x, ma_##type y) \
+ { \
+ return (ma_##type)c89atomic_fetch_sub_##c89TypeExtension(&x->value, y); \
+ } \
+ static MA_INLINE ma_##type ma_atomic_##type##_fetch_or(ma_atomic_##type* x, ma_##type y) \
+ { \
+ return (ma_##type)c89atomic_fetch_or_##c89TypeExtension(&x->value, y); \
+ } \
+ static MA_INLINE ma_##type ma_atomic_##type##_fetch_xor(ma_atomic_##type* x, ma_##type y) \
+ { \
+ return (ma_##type)c89atomic_fetch_xor_##c89TypeExtension(&x->value, y); \
+ } \
+ static MA_INLINE ma_##type ma_atomic_##type##_fetch_and(ma_atomic_##type* x, ma_##type y) \
+ { \
+ return (ma_##type)c89atomic_fetch_and_##c89TypeExtension(&x->value, y); \
+ } \
+ static MA_INLINE ma_##type ma_atomic_##type##_compare_and_swap(ma_atomic_##type* x, ma_##type expected, ma_##type desired) \
+ { \
+ return (ma_##type)c89atomic_compare_and_swap_##c89TypeExtension(&x->value, expected, desired); \
+ } \
+
+#define MA_ATOMIC_SAFE_TYPE_IMPL_PTR(type) \
+ static MA_INLINE ma_##type* ma_atomic_ptr_##type##_get(ma_atomic_ptr_##type* x) \
+ { \
+ return c89atomic_load_ptr((void**)&x->value); \
+ } \
+ static MA_INLINE void ma_atomic_ptr_##type##_set(ma_atomic_ptr_##type* x, ma_##type* value) \
+ { \
+ c89atomic_store_ptr((void**)&x->value, (void*)value); \
+ } \
+ static MA_INLINE ma_##type* ma_atomic_ptr_##type##_exchange(ma_atomic_ptr_##type* x, ma_##type* value) \
+ { \
+ return c89atomic_exchange_ptr((void**)&x->value, (void*)value); \
+ } \
+ static MA_INLINE ma_bool32 ma_atomic_ptr_##type##_compare_exchange(ma_atomic_ptr_##type* x, ma_##type** expected, ma_##type* desired) \
+ { \
+ return c89atomic_compare_exchange_weak_ptr((void**)&x->value, (void*)expected, (void*)desired); \
+ } \
+ static MA_INLINE ma_##type* ma_atomic_ptr_##type##_compare_and_swap(ma_atomic_ptr_##type* x, ma_##type* expected, ma_##type* desired) \
+ { \
+ return (ma_##type*)c89atomic_compare_and_swap_ptr((void**)&x->value, (void*)expected, (void*)desired); \
+ } \
+
+MA_ATOMIC_SAFE_TYPE_IMPL(32, uint32)
+MA_ATOMIC_SAFE_TYPE_IMPL(i32, int32)
+MA_ATOMIC_SAFE_TYPE_IMPL(64, uint64)
+MA_ATOMIC_SAFE_TYPE_IMPL(f32, float)
+MA_ATOMIC_SAFE_TYPE_IMPL(32, bool32)
+
+#if !defined(MA_NO_DEVICE_IO)
+MA_ATOMIC_SAFE_TYPE_IMPL(i32, device_state)
+#endif
MA_API ma_uint64 ma_calculate_frame_count_after_resampling(ma_uint32 sampleRateOut, ma_uint32 sampleRateIn, ma_uint64 frameCountIn)
@@ -15320,156 +16067,16 @@ MA_API ma_result ma_spinlock_unlock(volatile ma_spinlock* pSpinlock)
#ifndef MA_NO_THREADING
-#ifdef MA_WIN32
- #define MA_THREADCALL WINAPI
- typedef unsigned long ma_thread_result;
-#else
+#if defined(MA_POSIX)
#define MA_THREADCALL
typedef void* ma_thread_result;
+#elif defined(MA_WIN32)
+ #define MA_THREADCALL WINAPI
+ typedef unsigned long ma_thread_result;
#endif
+
typedef ma_thread_result (MA_THREADCALL * ma_thread_entry_proc)(void* pData);
-#ifdef MA_WIN32
-static int ma_thread_priority_to_win32(ma_thread_priority priority)
-{
- switch (priority) {
- case ma_thread_priority_idle: return THREAD_PRIORITY_IDLE;
- case ma_thread_priority_lowest: return THREAD_PRIORITY_LOWEST;
- case ma_thread_priority_low: return THREAD_PRIORITY_BELOW_NORMAL;
- case ma_thread_priority_normal: return THREAD_PRIORITY_NORMAL;
- case ma_thread_priority_high: return THREAD_PRIORITY_ABOVE_NORMAL;
- case ma_thread_priority_highest: return THREAD_PRIORITY_HIGHEST;
- case ma_thread_priority_realtime: return THREAD_PRIORITY_TIME_CRITICAL;
- default: return THREAD_PRIORITY_NORMAL;
- }
-}
-
-static ma_result ma_thread_create__win32(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData)
-{
- *pThread = CreateThread(NULL, stackSize, entryProc, pData, 0, NULL);
- if (*pThread == NULL) {
- return ma_result_from_GetLastError(GetLastError());
- }
-
- SetThreadPriority((HANDLE)*pThread, ma_thread_priority_to_win32(priority));
-
- return MA_SUCCESS;
-}
-
-static void ma_thread_wait__win32(ma_thread* pThread)
-{
- WaitForSingleObject((HANDLE)*pThread, INFINITE);
- CloseHandle((HANDLE)*pThread);
-}
-
-
-static ma_result ma_mutex_init__win32(ma_mutex* pMutex)
-{
- *pMutex = CreateEventW(NULL, FALSE, TRUE, NULL);
- if (*pMutex == NULL) {
- return ma_result_from_GetLastError(GetLastError());
- }
-
- return MA_SUCCESS;
-}
-
-static void ma_mutex_uninit__win32(ma_mutex* pMutex)
-{
- CloseHandle((HANDLE)*pMutex);
-}
-
-static void ma_mutex_lock__win32(ma_mutex* pMutex)
-{
- WaitForSingleObject((HANDLE)*pMutex, INFINITE);
-}
-
-static void ma_mutex_unlock__win32(ma_mutex* pMutex)
-{
- SetEvent((HANDLE)*pMutex);
-}
-
-
-static ma_result ma_event_init__win32(ma_event* pEvent)
-{
- *pEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
- if (*pEvent == NULL) {
- return ma_result_from_GetLastError(GetLastError());
- }
-
- return MA_SUCCESS;
-}
-
-static void ma_event_uninit__win32(ma_event* pEvent)
-{
- CloseHandle((HANDLE)*pEvent);
-}
-
-static ma_result ma_event_wait__win32(ma_event* pEvent)
-{
- DWORD result = WaitForSingleObject((HANDLE)*pEvent, INFINITE);
- if (result == WAIT_OBJECT_0) {
- return MA_SUCCESS;
- }
-
- if (result == WAIT_TIMEOUT) {
- return MA_TIMEOUT;
- }
-
- return ma_result_from_GetLastError(GetLastError());
-}
-
-static ma_result ma_event_signal__win32(ma_event* pEvent)
-{
- BOOL result = SetEvent((HANDLE)*pEvent);
- if (result == 0) {
- return ma_result_from_GetLastError(GetLastError());
- }
-
- return MA_SUCCESS;
-}
-
-
-static ma_result ma_semaphore_init__win32(int initialValue, ma_semaphore* pSemaphore)
-{
- *pSemaphore = CreateSemaphoreW(NULL, (LONG)initialValue, LONG_MAX, NULL);
- if (*pSemaphore == NULL) {
- return ma_result_from_GetLastError(GetLastError());
- }
-
- return MA_SUCCESS;
-}
-
-static void ma_semaphore_uninit__win32(ma_semaphore* pSemaphore)
-{
- CloseHandle((HANDLE)*pSemaphore);
-}
-
-static ma_result ma_semaphore_wait__win32(ma_semaphore* pSemaphore)
-{
- DWORD result = WaitForSingleObject((HANDLE)*pSemaphore, INFINITE);
- if (result == WAIT_OBJECT_0) {
- return MA_SUCCESS;
- }
-
- if (result == WAIT_TIMEOUT) {
- return MA_TIMEOUT;
- }
-
- return ma_result_from_GetLastError(GetLastError());
-}
-
-static ma_result ma_semaphore_release__win32(ma_semaphore* pSemaphore)
-{
- BOOL result = ReleaseSemaphore((HANDLE)*pSemaphore, 1, NULL);
- if (result == 0) {
- return ma_result_from_GetLastError(GetLastError());
- }
-
- return MA_SUCCESS;
-}
-#endif
-
-
#ifdef MA_POSIX
static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData)
{
@@ -15481,23 +16088,32 @@ static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority
pthread_attr_t attr;
if (pthread_attr_init(&attr) == 0) {
int scheduler = -1;
- if (priority == ma_thread_priority_idle) {
-#ifdef SCHED_IDLE
- if (pthread_attr_setschedpolicy(&attr, SCHED_IDLE) == 0) {
- scheduler = SCHED_IDLE;
+
+ /* We successfully initialized our attributes object so we can assign the pointer so it's passed into pthread_create(). */
+ pAttr = &attr;
+
+ /* We need to set the scheduler policy. Only do this if the OS supports pthread_attr_setschedpolicy() */
+ #if !defined(MA_BEOS)
+ {
+ if (priority == ma_thread_priority_idle) {
+ #ifdef SCHED_IDLE
+ if (pthread_attr_setschedpolicy(&attr, SCHED_IDLE) == 0) {
+ scheduler = SCHED_IDLE;
+ }
+ #endif
+ } else if (priority == ma_thread_priority_realtime) {
+ #ifdef SCHED_FIFO
+ if (pthread_attr_setschedpolicy(&attr, SCHED_FIFO) == 0) {
+ scheduler = SCHED_FIFO;
+ }
+ #endif
+ #ifdef MA_LINUX
+ } else {
+ scheduler = sched_getscheduler(0);
+ #endif
}
-#endif
- } else if (priority == ma_thread_priority_realtime) {
-#ifdef SCHED_FIFO
- if (pthread_attr_setschedpolicy(&attr, SCHED_FIFO) == 0) {
- scheduler = SCHED_FIFO;
- }
-#endif
-#ifdef MA_LINUX
- } else {
- scheduler = sched_getscheduler(0);
-#endif
}
+ #endif
if (stackSize > 0) {
pthread_attr_setstacksize(&attr, stackSize);
@@ -15524,9 +16140,8 @@ static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority
}
}
- if (pthread_attr_setschedparam(&attr, &sched) == 0) {
- pAttr = &attr;
- }
+ /* I'm not treating a failure of setting the priority as a critical error so not checking the return value here. */
+ pthread_attr_setschedparam(&attr, &sched);
}
}
}
@@ -15703,6 +16318,146 @@ static ma_result ma_semaphore_release__posix(ma_semaphore* pSemaphore)
return MA_SUCCESS;
}
+#elif defined(MA_WIN32)
+static int ma_thread_priority_to_win32(ma_thread_priority priority)
+{
+ switch (priority) {
+ case ma_thread_priority_idle: return THREAD_PRIORITY_IDLE;
+ case ma_thread_priority_lowest: return THREAD_PRIORITY_LOWEST;
+ case ma_thread_priority_low: return THREAD_PRIORITY_BELOW_NORMAL;
+ case ma_thread_priority_normal: return THREAD_PRIORITY_NORMAL;
+ case ma_thread_priority_high: return THREAD_PRIORITY_ABOVE_NORMAL;
+ case ma_thread_priority_highest: return THREAD_PRIORITY_HIGHEST;
+ case ma_thread_priority_realtime: return THREAD_PRIORITY_TIME_CRITICAL;
+ default: return THREAD_PRIORITY_NORMAL;
+ }
+}
+
+static ma_result ma_thread_create__win32(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData)
+{
+ DWORD threadID; /* Not used. Only used for passing into CreateThread() so it doesn't fail on Windows 98. */
+
+ *pThread = CreateThread(NULL, stackSize, entryProc, pData, 0, &threadID);
+ if (*pThread == NULL) {
+ return ma_result_from_GetLastError(GetLastError());
+ }
+
+ SetThreadPriority((HANDLE)*pThread, ma_thread_priority_to_win32(priority));
+
+ return MA_SUCCESS;
+}
+
+static void ma_thread_wait__win32(ma_thread* pThread)
+{
+ WaitForSingleObject((HANDLE)*pThread, INFINITE);
+ CloseHandle((HANDLE)*pThread);
+}
+
+
+static ma_result ma_mutex_init__win32(ma_mutex* pMutex)
+{
+ *pMutex = CreateEventA(NULL, FALSE, TRUE, NULL);
+ if (*pMutex == NULL) {
+ return ma_result_from_GetLastError(GetLastError());
+ }
+
+ return MA_SUCCESS;
+}
+
+static void ma_mutex_uninit__win32(ma_mutex* pMutex)
+{
+ CloseHandle((HANDLE)*pMutex);
+}
+
+static void ma_mutex_lock__win32(ma_mutex* pMutex)
+{
+ WaitForSingleObject((HANDLE)*pMutex, INFINITE);
+}
+
+static void ma_mutex_unlock__win32(ma_mutex* pMutex)
+{
+ SetEvent((HANDLE)*pMutex);
+}
+
+
+static ma_result ma_event_init__win32(ma_event* pEvent)
+{
+ *pEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
+ if (*pEvent == NULL) {
+ return ma_result_from_GetLastError(GetLastError());
+ }
+
+ return MA_SUCCESS;
+}
+
+static void ma_event_uninit__win32(ma_event* pEvent)
+{
+ CloseHandle((HANDLE)*pEvent);
+}
+
+static ma_result ma_event_wait__win32(ma_event* pEvent)
+{
+ DWORD result = WaitForSingleObject((HANDLE)*pEvent, INFINITE);
+ if (result == WAIT_OBJECT_0) {
+ return MA_SUCCESS;
+ }
+
+ if (result == WAIT_TIMEOUT) {
+ return MA_TIMEOUT;
+ }
+
+ return ma_result_from_GetLastError(GetLastError());
+}
+
+static ma_result ma_event_signal__win32(ma_event* pEvent)
+{
+ BOOL result = SetEvent((HANDLE)*pEvent);
+ if (result == 0) {
+ return ma_result_from_GetLastError(GetLastError());
+ }
+
+ return MA_SUCCESS;
+}
+
+
+static ma_result ma_semaphore_init__win32(int initialValue, ma_semaphore* pSemaphore)
+{
+ *pSemaphore = CreateSemaphoreW(NULL, (LONG)initialValue, LONG_MAX, NULL);
+ if (*pSemaphore == NULL) {
+ return ma_result_from_GetLastError(GetLastError());
+ }
+
+ return MA_SUCCESS;
+}
+
+static void ma_semaphore_uninit__win32(ma_semaphore* pSemaphore)
+{
+ CloseHandle((HANDLE)*pSemaphore);
+}
+
+static ma_result ma_semaphore_wait__win32(ma_semaphore* pSemaphore)
+{
+ DWORD result = WaitForSingleObject((HANDLE)*pSemaphore, INFINITE);
+ if (result == WAIT_OBJECT_0) {
+ return MA_SUCCESS;
+ }
+
+ if (result == WAIT_TIMEOUT) {
+ return MA_TIMEOUT;
+ }
+
+ return ma_result_from_GetLastError(GetLastError());
+}
+
+static ma_result ma_semaphore_release__win32(ma_semaphore* pSemaphore)
+{
+ BOOL result = ReleaseSemaphore((HANDLE)*pSemaphore, 1, NULL);
+ if (result == 0) {
+ return ma_result_from_GetLastError(GetLastError());
+ }
+
+ return MA_SUCCESS;
+}
#endif
typedef struct
@@ -15752,15 +16507,20 @@ static ma_result ma_thread_create(ma_thread* pThread, ma_thread_priority priorit
return MA_OUT_OF_MEMORY;
}
+#if defined(MA_THREAD_DEFAULT_STACK_SIZE)
+ if (stackSize == 0) {
+ stackSize = MA_THREAD_DEFAULT_STACK_SIZE;
+ }
+#endif
+
pProxyData->entryProc = entryProc;
pProxyData->pData = pData;
ma_allocation_callbacks_init_copy(&pProxyData->allocationCallbacks, pAllocationCallbacks);
-#ifdef MA_WIN32
- result = ma_thread_create__win32(pThread, priority, stackSize, ma_thread_entry_proxy, pProxyData);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
result = ma_thread_create__posix(pThread, priority, stackSize, ma_thread_entry_proxy, pProxyData);
+#elif defined(MA_WIN32)
+ result = ma_thread_create__win32(pThread, priority, stackSize, ma_thread_entry_proxy, pProxyData);
#endif
if (result != MA_SUCCESS) {
@@ -15777,11 +16537,10 @@ static void ma_thread_wait(ma_thread* pThread)
return;
}
-#ifdef MA_WIN32
- ma_thread_wait__win32(pThread);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
ma_thread_wait__posix(pThread);
+#elif defined(MA_WIN32)
+ ma_thread_wait__win32(pThread);
#endif
}
@@ -15793,11 +16552,10 @@ MA_API ma_result ma_mutex_init(ma_mutex* pMutex)
return MA_INVALID_ARGS;
}
-#ifdef MA_WIN32
- return ma_mutex_init__win32(pMutex);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
return ma_mutex_init__posix(pMutex);
+#elif defined(MA_WIN32)
+ return ma_mutex_init__win32(pMutex);
#endif
}
@@ -15807,11 +16565,10 @@ MA_API void ma_mutex_uninit(ma_mutex* pMutex)
return;
}
-#ifdef MA_WIN32
- ma_mutex_uninit__win32(pMutex);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
ma_mutex_uninit__posix(pMutex);
+#elif defined(MA_WIN32)
+ ma_mutex_uninit__win32(pMutex);
#endif
}
@@ -15822,11 +16579,10 @@ MA_API void ma_mutex_lock(ma_mutex* pMutex)
return;
}
-#ifdef MA_WIN32
- ma_mutex_lock__win32(pMutex);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
ma_mutex_lock__posix(pMutex);
+#elif defined(MA_WIN32)
+ ma_mutex_lock__win32(pMutex);
#endif
}
@@ -15835,13 +16591,12 @@ MA_API void ma_mutex_unlock(ma_mutex* pMutex)
if (pMutex == NULL) {
MA_ASSERT(MA_FALSE); /* Fire an assert so the caller is aware of this bug. */
return;
-}
+ }
-#ifdef MA_WIN32
- ma_mutex_unlock__win32(pMutex);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
ma_mutex_unlock__posix(pMutex);
+#elif defined(MA_WIN32)
+ ma_mutex_unlock__win32(pMutex);
#endif
}
@@ -15853,11 +16608,10 @@ MA_API ma_result ma_event_init(ma_event* pEvent)
return MA_INVALID_ARGS;
}
-#ifdef MA_WIN32
- return ma_event_init__win32(pEvent);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
return ma_event_init__posix(pEvent);
+#elif defined(MA_WIN32)
+ return ma_event_init__win32(pEvent);
#endif
}
@@ -15895,11 +16649,10 @@ MA_API void ma_event_uninit(ma_event* pEvent)
return;
}
-#ifdef MA_WIN32
- ma_event_uninit__win32(pEvent);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
ma_event_uninit__posix(pEvent);
+#elif defined(MA_WIN32)
+ ma_event_uninit__win32(pEvent);
#endif
}
@@ -15922,11 +16675,10 @@ MA_API ma_result ma_event_wait(ma_event* pEvent)
return MA_INVALID_ARGS;
}
-#ifdef MA_WIN32
- return ma_event_wait__win32(pEvent);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
return ma_event_wait__posix(pEvent);
+#elif defined(MA_WIN32)
+ return ma_event_wait__win32(pEvent);
#endif
}
@@ -15937,11 +16689,10 @@ MA_API ma_result ma_event_signal(ma_event* pEvent)
return MA_INVALID_ARGS;
}
-#ifdef MA_WIN32
- return ma_event_signal__win32(pEvent);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
return ma_event_signal__posix(pEvent);
+#elif defined(MA_WIN32)
+ return ma_event_signal__win32(pEvent);
#endif
}
@@ -15953,11 +16704,10 @@ MA_API ma_result ma_semaphore_init(int initialValue, ma_semaphore* pSemaphore)
return MA_INVALID_ARGS;
}
-#ifdef MA_WIN32
- return ma_semaphore_init__win32(initialValue, pSemaphore);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
return ma_semaphore_init__posix(initialValue, pSemaphore);
+#elif defined(MA_WIN32)
+ return ma_semaphore_init__win32(initialValue, pSemaphore);
#endif
}
@@ -15968,11 +16718,10 @@ MA_API void ma_semaphore_uninit(ma_semaphore* pSemaphore)
return;
}
-#ifdef MA_WIN32
- ma_semaphore_uninit__win32(pSemaphore);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
ma_semaphore_uninit__posix(pSemaphore);
+#elif defined(MA_WIN32)
+ ma_semaphore_uninit__win32(pSemaphore);
#endif
}
@@ -15983,11 +16732,10 @@ MA_API ma_result ma_semaphore_wait(ma_semaphore* pSemaphore)
return MA_INVALID_ARGS;
}
-#ifdef MA_WIN32
- return ma_semaphore_wait__win32(pSemaphore);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
return ma_semaphore_wait__posix(pSemaphore);
+#elif defined(MA_WIN32)
+ return ma_semaphore_wait__win32(pSemaphore);
#endif
}
@@ -15998,11 +16746,10 @@ MA_API ma_result ma_semaphore_release(ma_semaphore* pSemaphore)
return MA_INVALID_ARGS;
}
-#ifdef MA_WIN32
- return ma_semaphore_release__win32(pSemaphore);
-#endif
-#ifdef MA_POSIX
+#if defined(MA_POSIX)
return ma_semaphore_release__posix(pSemaphore);
+#elif defined(MA_WIN32)
+ return ma_semaphore_release__win32(pSemaphore);
#endif
}
#else
@@ -16648,7 +17395,7 @@ MA_API ma_result ma_job_process(ma_job* pJob)
return MA_INVALID_ARGS;
}
- if (pJob->toc.breakup.code > MA_JOB_TYPE_COUNT) {
+ if (pJob->toc.breakup.code >= MA_JOB_TYPE_COUNT) {
return MA_INVALID_OPERATION;
}
@@ -17041,13 +17788,16 @@ DEVICE I/O
*************************************************************************************************************************************************************
************************************************************************************************************************************************************/
-#ifndef MA_NO_DEVICE_IO
-#ifdef MA_WIN32
- #include
- #include
- #include
+
+/* Disable run-time linking on certain backends and platforms. */
+#ifndef MA_NO_RUNTIME_LINKING
+ #if defined(MA_EMSCRIPTEN) || defined(MA_ORBIS) || defined(MA_PROSPERO)
+ #define MA_NO_RUNTIME_LINKING
+ #endif
#endif
+#ifndef MA_NO_DEVICE_IO
+
#if defined(MA_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200)
#include /* For mach_absolute_time() */
#endif
@@ -17055,26 +17805,15 @@ DEVICE I/O
#ifdef MA_POSIX
#include
#include
- #include
-#endif
-/*
-Unfortunately using runtime linking for pthreads causes problems. This has occurred for me when testing on FreeBSD. When
-using runtime linking, deadlocks can occur (for me it happens when loading data from fread()). It turns out that doing
-compile-time linking fixes this. I'm not sure why this happens, but the safest way I can think of to fix this is to simply
-disable runtime linking by default. To enable runtime linking, #define this before the implementation of this file. I am
-not officially supporting this, but I'm leaving it here in case it's useful for somebody, somewhere.
-*/
-/*#define MA_USE_RUNTIME_LINKING_FOR_PTHREAD*/
-
-/* Disable run-time linking on certain backends. */
-#ifndef MA_NO_RUNTIME_LINKING
- #if defined(MA_EMSCRIPTEN)
- #define MA_NO_RUNTIME_LINKING
+ /* No need for dlfcn.h if we're not using runtime linking. */
+ #ifndef MA_NO_RUNTIME_LINKING
+ #include
#endif
#endif
+
MA_API void ma_device_info_add_native_data_format(ma_device_info* pDeviceInfo, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 flags)
{
if (pDeviceInfo == NULL) {
@@ -17091,27 +17830,60 @@ MA_API void ma_device_info_add_native_data_format(ma_device_info* pDeviceInfo, m
}
+typedef struct
+{
+ ma_backend backend;
+ const char* pName;
+} ma_backend_info;
+
+static ma_backend_info gBackendInfo[] = /* Indexed by the backend enum. Must be in the order backends are declared in the ma_backend enum. */
+{
+ {ma_backend_wasapi, "WASAPI"},
+ {ma_backend_dsound, "DirectSound"},
+ {ma_backend_winmm, "WinMM"},
+ {ma_backend_coreaudio, "Core Audio"},
+ {ma_backend_sndio, "sndio"},
+ {ma_backend_audio4, "audio(4)"},
+ {ma_backend_oss, "OSS"},
+ {ma_backend_pulseaudio, "PulseAudio"},
+ {ma_backend_alsa, "ALSA"},
+ {ma_backend_jack, "JACK"},
+ {ma_backend_aaudio, "AAudio"},
+ {ma_backend_opensl, "OpenSL|ES"},
+ {ma_backend_webaudio, "Web Audio"},
+ {ma_backend_custom, "Custom"},
+ {ma_backend_null, "Null"}
+};
+
MA_API const char* ma_get_backend_name(ma_backend backend)
{
- switch (backend)
- {
- case ma_backend_wasapi: return "WASAPI";
- case ma_backend_dsound: return "DirectSound";
- case ma_backend_winmm: return "WinMM";
- case ma_backend_coreaudio: return "Core Audio";
- case ma_backend_sndio: return "sndio";
- case ma_backend_audio4: return "audio(4)";
- case ma_backend_oss: return "OSS";
- case ma_backend_pulseaudio: return "PulseAudio";
- case ma_backend_alsa: return "ALSA";
- case ma_backend_jack: return "JACK";
- case ma_backend_aaudio: return "AAudio";
- case ma_backend_opensl: return "OpenSL|ES";
- case ma_backend_webaudio: return "Web Audio";
- case ma_backend_custom: return "Custom";
- case ma_backend_null: return "Null";
- default: return "Unknown";
+ if (backend < 0 || backend >= (int)ma_countof(gBackendInfo)) {
+ return "Unknown";
}
+
+ return gBackendInfo[backend].pName;
+}
+
+MA_API ma_result ma_get_backend_from_name(const char* pBackendName, ma_backend* pBackend)
+{
+ size_t iBackend;
+
+ if (pBackendName == NULL) {
+ return MA_INVALID_ARGS;
+ }
+
+ for (iBackend = 0; iBackend < ma_countof(gBackendInfo); iBackend += 1) {
+ if (ma_strcmp(pBackendName, gBackendInfo[iBackend].pName) == 0) {
+ if (pBackend != NULL) {
+ *pBackend = gBackendInfo[iBackend].backend;
+ }
+
+ return MA_SUCCESS;
+ }
+ }
+
+ /* Getting here means the backend name is unknown. */
+ return MA_INVALID_ARGS;
}
MA_API ma_bool32 ma_is_backend_enabled(ma_backend backend)
@@ -17184,13 +17956,25 @@ MA_API ma_bool32 ma_is_backend_enabled(ma_backend backend)
#endif
case ma_backend_aaudio:
#if defined(MA_HAS_AAUDIO)
- return MA_TRUE;
+ #if defined(MA_ANDROID)
+ {
+ return ma_android_sdk_version() >= 26;
+ }
+ #else
+ return MA_FALSE;
+ #endif
#else
return MA_FALSE;
#endif
case ma_backend_opensl:
#if defined(MA_HAS_OPENSL)
- return MA_TRUE;
+ #if defined(MA_ANDROID)
+ {
+ return ma_android_sdk_version() >= 9;
+ }
+ #else
+ return MA_TRUE;
+ #endif
#else
return MA_FALSE;
#endif
@@ -17276,7 +18060,7 @@ MA_API ma_bool32 ma_is_loopback_supported(ma_backend backend)
-#ifdef MA_WIN32
+#if defined(MA_WIN32)
/* WASAPI error codes. */
#define MA_AUDCLNT_E_NOT_INITIALIZED ((HRESULT)0x88890001)
#define MA_AUDCLNT_E_ALREADY_INITIALIZED ((HRESULT)0x88890002)
@@ -17436,22 +18220,109 @@ static ma_result ma_result_from_HRESULT(HRESULT hr)
}
}
-typedef HRESULT (WINAPI * MA_PFN_CoInitializeEx)(LPVOID pvReserved, DWORD dwCoInit);
-typedef void (WINAPI * MA_PFN_CoUninitialize)(void);
-typedef HRESULT (WINAPI * MA_PFN_CoCreateInstance)(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID *ppv);
-typedef void (WINAPI * MA_PFN_CoTaskMemFree)(LPVOID pv);
-typedef HRESULT (WINAPI * MA_PFN_PropVariantClear)(PROPVARIANT *pvar);
-typedef int (WINAPI * MA_PFN_StringFromGUID2)(const GUID* const rguid, LPOLESTR lpsz, int cchMax);
+/* PROPVARIANT */
+#define MA_VT_LPWSTR 31
+#define MA_VT_BLOB 65
-typedef HWND (WINAPI * MA_PFN_GetForegroundWindow)(void);
-typedef HWND (WINAPI * MA_PFN_GetDesktopWindow)(void);
+#if defined(_MSC_VER) && !defined(__clang__)
+ #pragma warning(push)
+ #pragma warning(disable:4201) /* nonstandard extension used: nameless struct/union */
+#elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wpedantic" /* For ISO C99 doesn't support unnamed structs/unions [-Wpedantic] */
+ #if defined(__clang__)
+ #pragma GCC diagnostic ignored "-Wc11-extensions" /* anonymous unions are a C11 extension */
+ #endif
+#endif
+typedef struct
+{
+ WORD vt;
+ WORD wReserved1;
+ WORD wReserved2;
+ WORD wReserved3;
+ union
+ {
+ struct
+ {
+ ULONG cbSize;
+ BYTE* pBlobData;
+ } blob;
+ WCHAR* pwszVal;
+ char pad[16]; /* Just to ensure the size of the struct matches the official version. */
+ };
+} MA_PROPVARIANT;
+#if defined(_MSC_VER) && !defined(__clang__)
+ #pragma warning(pop)
+#elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
+ #pragma GCC diagnostic pop
+#endif
+
+typedef HRESULT (WINAPI * MA_PFN_CoInitialize)(void* pvReserved);
+typedef HRESULT (WINAPI * MA_PFN_CoInitializeEx)(void* pvReserved, DWORD dwCoInit);
+typedef void (WINAPI * MA_PFN_CoUninitialize)(void);
+typedef HRESULT (WINAPI * MA_PFN_CoCreateInstance)(const IID* rclsid, void* pUnkOuter, DWORD dwClsContext, const IID* riid, void* ppv);
+typedef void (WINAPI * MA_PFN_CoTaskMemFree)(void* pv);
+typedef HRESULT (WINAPI * MA_PFN_PropVariantClear)(MA_PROPVARIANT *pvar);
+typedef int (WINAPI * MA_PFN_StringFromGUID2)(const GUID* const rguid, WCHAR* lpsz, int cchMax);
+
+typedef HWND (WINAPI * MA_PFN_GetForegroundWindow)(void);
+typedef HWND (WINAPI * MA_PFN_GetDesktopWindow)(void);
#if defined(MA_WIN32_DESKTOP)
/* Microsoft documents these APIs as returning LSTATUS, but the Win32 API shipping with some compilers do not define it. It's just a LONG. */
-typedef LONG (WINAPI * MA_PFN_RegOpenKeyExA)(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
-typedef LONG (WINAPI * MA_PFN_RegCloseKey)(HKEY hKey);
-typedef LONG (WINAPI * MA_PFN_RegQueryValueExA)(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
+typedef LONG (WINAPI * MA_PFN_RegOpenKeyExA)(HKEY hKey, const char* lpSubKey, DWORD ulOptions, DWORD samDesired, HKEY* phkResult);
+typedef LONG (WINAPI * MA_PFN_RegCloseKey)(HKEY hKey);
+typedef LONG (WINAPI * MA_PFN_RegQueryValueExA)(HKEY hKey, const char* lpValueName, DWORD* lpReserved, DWORD* lpType, BYTE* lpData, DWORD* lpcbData);
#endif /* MA_WIN32_DESKTOP */
+
+
+MA_API size_t ma_strlen_WCHAR(const WCHAR* str)
+{
+ size_t len = 0;
+ while (str[len] != '\0') {
+ len += 1;
+ }
+
+ return len;
+}
+
+MA_API int ma_strcmp_WCHAR(const WCHAR *s1, const WCHAR *s2)
+{
+ while (*s1 != '\0' && *s1 == *s2) {
+ s1 += 1;
+ s2 += 1;
+ }
+
+ return *s1 - *s2;
+}
+
+MA_API int ma_strcpy_s_WCHAR(WCHAR* dst, size_t dstCap, const WCHAR* src)
+{
+ size_t i;
+
+ if (dst == 0) {
+ return 22;
+ }
+ if (dstCap == 0) {
+ return 34;
+ }
+ if (src == 0) {
+ dst[0] = '\0';
+ return 22;
+ }
+
+ for (i = 0; i < dstCap && src[i] != '\0'; ++i) {
+ dst[i] = src[i];
+ }
+
+ if (i < dstCap) {
+ dst[i] = '\0';
+ return 0;
+ }
+
+ dst[0] = '\0';
+ return 34;
+}
#endif /* MA_WIN32 */
@@ -17466,7 +18337,7 @@ typedef LONG (WINAPI * MA_PFN_RegQueryValueExA)(HKEY hKey, LPCSTR lpValueName, L
Timing
*******************************************************************************/
-#ifdef MA_WIN32
+#if defined(MA_WIN32) && !defined(MA_POSIX)
static LARGE_INTEGER g_ma_TimerFrequency; /* <-- Initialized to zero since it's static. */
void ma_timer_init(ma_timer* pTimer)
{
@@ -17579,25 +18450,27 @@ Dynamic Linking
*******************************************************************************/
MA_API ma_handle ma_dlopen(ma_context* pContext, const char* filename)
{
+#ifndef MA_NO_RUNTIME_LINKING
ma_handle handle;
ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "Loading library: %s\n", filename);
-#ifdef _WIN32
-#ifdef MA_WIN32_DESKTOP
- handle = (ma_handle)LoadLibraryA(filename);
-#else
- /* *sigh* It appears there is no ANSI version of LoadPackagedLibrary()... */
- WCHAR filenameW[4096];
- if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, sizeof(filenameW)) == 0) {
- handle = NULL;
- } else {
- handle = (ma_handle)LoadPackagedLibrary(filenameW, 0);
- }
-#endif
-#else
- handle = (ma_handle)dlopen(filename, RTLD_NOW);
-#endif
+ #ifdef MA_WIN32
+ /* From MSDN: Desktop applications cannot use LoadPackagedLibrary; if a desktop application calls this function it fails with APPMODEL_ERROR_NO_PACKAGE.*/
+ #if !defined(MA_WIN32_UWP)
+ handle = (ma_handle)LoadLibraryA(filename);
+ #else
+ /* *sigh* It appears there is no ANSI version of LoadPackagedLibrary()... */
+ WCHAR filenameW[4096];
+ if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, sizeof(filenameW)) == 0) {
+ handle = NULL;
+ } else {
+ handle = (ma_handle)LoadPackagedLibrary(filenameW, 0);
+ }
+ #endif
+ #else
+ handle = (ma_handle)dlopen(filename, RTLD_NOW);
+ #endif
/*
I'm not considering failure to load a library an error nor a warning because seamlessly falling through to a lower-priority
@@ -17609,21 +18482,34 @@ MA_API ma_handle ma_dlopen(ma_context* pContext, const char* filename)
(void)pContext; /* It's possible for pContext to be unused. */
return handle;
+#else
+ /* Runtime linking is disabled. */
+ (void)pContext;
+ (void)filename;
+ return NULL;
+#endif
}
MA_API void ma_dlclose(ma_context* pContext, ma_handle handle)
{
-#ifdef _WIN32
- FreeLibrary((HMODULE)handle);
-#else
- dlclose((void*)handle);
-#endif
+#ifndef MA_NO_RUNTIME_LINKING
+ #ifdef MA_WIN32
+ FreeLibrary((HMODULE)handle);
+ #else
+ dlclose((void*)handle);
+ #endif
(void)pContext;
+#else
+ /* Runtime linking is disabled. */
+ (void)pContext;
+ (void)handle;
+#endif
}
MA_API ma_proc ma_dlsym(ma_context* pContext, ma_handle handle, const char* symbol)
{
+#ifndef MA_NO_RUNTIME_LINKING
ma_proc proc;
ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "Loading symbol: %s\n", symbol);
@@ -17647,6 +18533,13 @@ MA_API ma_proc ma_dlsym(ma_context* pContext, ma_handle handle, const char* symb
(void)pContext; /* It's possible for pContext to be unused. */
return proc;
+#else
+ /* Runtime linking is disabled. */
+ (void)pContext;
+ (void)handle;
+ (void)symbol;
+ return NULL;
+#endif
}
@@ -17772,6 +18665,11 @@ static void ma_device__on_data(ma_device* pDevice, void* pFramesOut, const void*
{
MA_ASSERT(pDevice != NULL);
+ /* Don't read more data from the client if we're in the process of stopping. */
+ if (ma_device_get_state(pDevice) == ma_device_state_stopping) {
+ return;
+ }
+
if (pDevice->noFixedSizedCallback) {
/* Fast path. Not using a fixed sized callback. Process directly from the specified buffers. */
ma_device__on_data_inner(pDevice, pFramesOut, pFramesIn, frameCount);
@@ -17846,7 +18744,7 @@ static void ma_device__on_data(ma_device* pDevice, void* pFramesOut, const void*
/* The intermediary buffer has just been filled. */
pDevice->playback.intermediaryBufferLen = pDevice->playback.intermediaryBufferCap;
}
- }
+ }
}
/* If we're in duplex mode we might need to do a refill of the data. */
@@ -18059,6 +18957,9 @@ static void ma_device__send_frames_to_client(ma_device* pDevice, ma_uint32 frame
totalDeviceFramesProcessed += deviceFramesProcessedThisIteration;
totalClientFramesProcessed += clientFramesProcessedThisIteration;
+ /* This is just to silence a warning. I might want to use this variable later so leaving in place for now. */
+ (void)totalClientFramesProcessed;
+
if (deviceFramesProcessedThisIteration == 0 && clientFramesProcessedThisIteration == 0) {
break; /* We're done. */
}
@@ -18195,11 +19096,11 @@ static ma_result ma_device__handle_duplex_callback_playback(ma_device* pDevice,
/* A helper for changing the state of the device. */
static MA_INLINE void ma_device__set_state(ma_device* pDevice, ma_device_state newState)
{
- c89atomic_exchange_i32((ma_int32*)&pDevice->state, (ma_int32)newState);
+ ma_atomic_device_state_set(&pDevice->state, newState);
}
-#ifdef MA_WIN32
+#if defined(MA_WIN32)
GUID MA_GUID_KSDATAFORMAT_SUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
GUID MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
/*GUID MA_GUID_KSDATAFORMAT_SUBTYPE_ALAW = {0x00000006, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};*/
@@ -18706,7 +19607,7 @@ static ma_result ma_device_start__null(ma_device* pDevice)
ma_device_do_operation__null(pDevice, MA_DEVICE_OP_START__NULL);
- c89atomic_exchange_32(&pDevice->null_device.isStarted, MA_TRUE);
+ ma_atomic_bool32_set(&pDevice->null_device.isStarted, MA_TRUE);
return MA_SUCCESS;
}
@@ -18716,10 +19617,17 @@ static ma_result ma_device_stop__null(ma_device* pDevice)
ma_device_do_operation__null(pDevice, MA_DEVICE_OP_SUSPEND__NULL);
- c89atomic_exchange_32(&pDevice->null_device.isStarted, MA_FALSE);
+ ma_atomic_bool32_set(&pDevice->null_device.isStarted, MA_FALSE);
return MA_SUCCESS;
}
+static ma_bool32 ma_device_is_started__null(ma_device* pDevice)
+{
+ MA_ASSERT(pDevice != NULL);
+
+ return ma_atomic_bool32_get(&pDevice->null_device.isStarted);
+}
+
static ma_result ma_device_write__null(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
{
ma_result result = MA_SUCCESS;
@@ -18730,7 +19638,7 @@ static ma_result ma_device_write__null(ma_device* pDevice, const void* pPCMFrame
*pFramesWritten = 0;
}
- wasStartedOnEntry = c89atomic_load_32(&pDevice->null_device.isStarted);
+ wasStartedOnEntry = ma_device_is_started__null(pDevice);
/* Keep going until everything has been read. */
totalPCMFramesProcessed = 0;
@@ -18756,7 +19664,7 @@ static ma_result ma_device_write__null(ma_device* pDevice, const void* pPCMFrame
if (pDevice->null_device.currentPeriodFramesRemainingPlayback == 0) {
pDevice->null_device.currentPeriodFramesRemainingPlayback = 0;
- if (!c89atomic_load_32(&pDevice->null_device.isStarted) && !wasStartedOnEntry) {
+ if (!ma_device_is_started__null(pDevice) && !wasStartedOnEntry) {
result = ma_device_start__null(pDevice);
if (result != MA_SUCCESS) {
break;
@@ -18776,7 +19684,7 @@ static ma_result ma_device_write__null(ma_device* pDevice, const void* pPCMFrame
ma_uint64 currentFrame;
/* Stop waiting if the device has been stopped. */
- if (!c89atomic_load_32(&pDevice->null_device.isStarted)) {
+ if (!ma_device_is_started__null(pDevice)) {
break;
}
@@ -18847,7 +19755,7 @@ static ma_result ma_device_read__null(ma_device* pDevice, void* pPCMFrames, ma_u
ma_uint64 currentFrame;
/* Stop waiting if the device has been stopped. */
- if (!c89atomic_load_32(&pDevice->null_device.isStarted)) {
+ if (!ma_device_is_started__null(pDevice)) {
break;
}
@@ -18912,8 +19820,8 @@ WIN32 COMMON
*******************************************************************************/
#if defined(MA_WIN32)
-#if defined(MA_WIN32_DESKTOP)
- #define ma_CoInitializeEx(pContext, pvReserved, dwCoInit) ((MA_PFN_CoInitializeEx)pContext->win32.CoInitializeEx)(pvReserved, dwCoInit)
+#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)
+ #define ma_CoInitializeEx(pContext, pvReserved, dwCoInit) ((pContext->win32.CoInitializeEx) ? ((MA_PFN_CoInitializeEx)pContext->win32.CoInitializeEx)(pvReserved, dwCoInit) : ((MA_PFN_CoInitialize)pContext->win32.CoInitialize)(pvReserved))
#define ma_CoUninitialize(pContext) ((MA_PFN_CoUninitialize)pContext->win32.CoUninitialize)()
#define ma_CoCreateInstance(pContext, rclsid, pUnkOuter, dwClsContext, riid, ppv) ((MA_PFN_CoCreateInstance)pContext->win32.CoCreateInstance)(rclsid, pUnkOuter, dwClsContext, riid, ppv)
#define ma_CoTaskMemFree(pContext, pv) ((MA_PFN_CoTaskMemFree)pContext->win32.CoTaskMemFree)(pv)
@@ -18930,19 +19838,34 @@ WIN32 COMMON
typedef size_t DWORD_PTR;
#endif
+#if !defined(WAVE_FORMAT_1M08)
+#define WAVE_FORMAT_1M08 0x00000001
+#define WAVE_FORMAT_1S08 0x00000002
+#define WAVE_FORMAT_1M16 0x00000004
+#define WAVE_FORMAT_1S16 0x00000008
+#define WAVE_FORMAT_2M08 0x00000010
+#define WAVE_FORMAT_2S08 0x00000020
+#define WAVE_FORMAT_2M16 0x00000040
+#define WAVE_FORMAT_2S16 0x00000080
+#define WAVE_FORMAT_4M08 0x00000100
+#define WAVE_FORMAT_4S08 0x00000200
+#define WAVE_FORMAT_4M16 0x00000400
+#define WAVE_FORMAT_4S16 0x00000800
+#endif
+
#if !defined(WAVE_FORMAT_44M08)
-#define WAVE_FORMAT_44M08 0x00000100
-#define WAVE_FORMAT_44S08 0x00000200
-#define WAVE_FORMAT_44M16 0x00000400
-#define WAVE_FORMAT_44S16 0x00000800
-#define WAVE_FORMAT_48M08 0x00001000
-#define WAVE_FORMAT_48S08 0x00002000
-#define WAVE_FORMAT_48M16 0x00004000
-#define WAVE_FORMAT_48S16 0x00008000
-#define WAVE_FORMAT_96M08 0x00010000
-#define WAVE_FORMAT_96S08 0x00020000
-#define WAVE_FORMAT_96M16 0x00040000
-#define WAVE_FORMAT_96S16 0x00080000
+#define WAVE_FORMAT_44M08 0x00000100
+#define WAVE_FORMAT_44S08 0x00000200
+#define WAVE_FORMAT_44M16 0x00000400
+#define WAVE_FORMAT_44S16 0x00000800
+#define WAVE_FORMAT_48M08 0x00001000
+#define WAVE_FORMAT_48S08 0x00002000
+#define WAVE_FORMAT_48M16 0x00004000
+#define WAVE_FORMAT_48S16 0x00008000
+#define WAVE_FORMAT_96M08 0x00010000
+#define WAVE_FORMAT_96S08 0x00020000
+#define WAVE_FORMAT_96M16 0x00040000
+#define WAVE_FORMAT_96S16 0x00080000
#endif
#ifndef SPEAKER_FRONT_LEFT
@@ -18967,13 +19890,30 @@ typedef size_t DWORD_PTR;
#endif
/*
-The SDK that comes with old versions of MSVC (VC6, for example) does not appear to define WAVEFORMATEXTENSIBLE. We
-define our own implementation in this case.
+Implement our own version of MA_WAVEFORMATEXTENSIBLE so we can avoid a header. Be careful with this
+because MA_WAVEFORMATEX has an extra two bytes over standard WAVEFORMATEX due to padding. The
+standard version uses tight packing, but for compiler compatibility we're not doing that with ours.
*/
-#if (defined(_MSC_VER) && !defined(_WAVEFORMATEXTENSIBLE_)) || defined(__DMC__)
typedef struct
{
- WAVEFORMATEX Format;
+ WORD wFormatTag;
+ WORD nChannels;
+ DWORD nSamplesPerSec;
+ DWORD nAvgBytesPerSec;
+ WORD nBlockAlign;
+ WORD wBitsPerSample;
+ WORD cbSize;
+} MA_WAVEFORMATEX;
+
+typedef struct
+{
+ WORD wFormatTag;
+ WORD nChannels;
+ DWORD nSamplesPerSec;
+ DWORD nAvgBytesPerSec;
+ WORD nBlockAlign;
+ WORD wBitsPerSample;
+ WORD cbSize;
union
{
WORD wValidBitsPerSample;
@@ -18982,13 +19922,18 @@ typedef struct
} Samples;
DWORD dwChannelMask;
GUID SubFormat;
-} WAVEFORMATEXTENSIBLE;
-#endif
+} MA_WAVEFORMATEXTENSIBLE;
+
+
#ifndef WAVE_FORMAT_EXTENSIBLE
#define WAVE_FORMAT_EXTENSIBLE 0xFFFE
#endif
+#ifndef WAVE_FORMAT_PCM
+#define WAVE_FORMAT_PCM 1
+#endif
+
#ifndef WAVE_FORMAT_IEEE_FLOAT
#define WAVE_FORMAT_IEEE_FLOAT 0x0003
#endif
@@ -19064,11 +20009,9 @@ static DWORD ma_channel_map_to_channel_mask__win32(const ma_channel* pChannelMap
/* Converts a Win32-style channel mask to a miniaudio channel map. */
static void ma_channel_mask_to_channel_map__win32(DWORD dwChannelMask, ma_uint32 channels, ma_channel* pChannelMap)
{
- if (channels == 1 && dwChannelMask == 0) {
- pChannelMap[0] = MA_CHANNEL_MONO;
- } else if (channels == 2 && dwChannelMask == 0) {
- pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
- pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
+ /* If the channel mask is set to 0, just assume a default Win32 channel map. */
+ if (dwChannelMask == 0) {
+ ma_channel_map_init_standard(ma_standard_channel_map_microsoft, pChannelMap, channels, channels);
} else {
if (channels == 1 && (dwChannelMask & SPEAKER_FRONT_CENTER) != 0) {
pChannelMap[0] = MA_CHANNEL_MONO;
@@ -19104,21 +20047,21 @@ static MA_INLINE ma_bool32 ma_is_guid_null(const void* guid)
return ma_is_guid_equal(guid, &nullguid);
}
-static ma_format ma_format_from_WAVEFORMATEX(const WAVEFORMATEX* pWF)
+static ma_format ma_format_from_WAVEFORMATEX(const MA_WAVEFORMATEX* pWF)
{
MA_ASSERT(pWF != NULL);
if (pWF->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
- const WAVEFORMATEXTENSIBLE* pWFEX = (const WAVEFORMATEXTENSIBLE*)pWF;
+ const MA_WAVEFORMATEXTENSIBLE* pWFEX = (const MA_WAVEFORMATEXTENSIBLE*)pWF;
if (ma_is_guid_equal(&pWFEX->SubFormat, &MA_GUID_KSDATAFORMAT_SUBTYPE_PCM)) {
if (pWFEX->Samples.wValidBitsPerSample == 32) {
return ma_format_s32;
}
if (pWFEX->Samples.wValidBitsPerSample == 24) {
- if (pWFEX->Format.wBitsPerSample == 32) {
- /*return ma_format_s24_32;*/
+ if (pWFEX->wBitsPerSample == 32) {
+ return ma_format_s32;
}
- if (pWFEX->Format.wBitsPerSample == 24) {
+ if (pWFEX->wBitsPerSample == 24) {
return ma_format_s24;
}
}
@@ -19226,7 +20169,7 @@ typedef struct
#endif
/* Some compilers don't define PropVariantInit(). We just do this ourselves since it's just a memset(). */
-static MA_INLINE void ma_PropVariantInit(PROPVARIANT* pProp)
+static MA_INLINE void ma_PropVariantInit(MA_PROPVARIANT* pProp)
{
MA_ZERO_OBJECT(pProp);
}
@@ -19252,17 +20195,9 @@ static const IID MA_IID_DEVINTERFACE_AUDIO_CAPTURE = {0x2EEF81BE,
static const IID MA_IID_IActivateAudioInterfaceCompletionHandler = {0x41D949AB, 0x9862, 0x444A, {0x80, 0xF6, 0xC2, 0x61, 0x33, 0x4D, 0xA5, 0xEB}}; /* 41D949AB-9862-444A-80F6-C261334DA5EB */
#endif
-static const IID MA_CLSID_MMDeviceEnumerator_Instance = {0xBCDE0395, 0xE52F, 0x467C, {0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E}}; /* BCDE0395-E52F-467C-8E3D-C4579291692E = __uuidof(MMDeviceEnumerator) */
-static const IID MA_IID_IMMDeviceEnumerator_Instance = {0xA95664D2, 0x9614, 0x4F35, {0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6}}; /* A95664D2-9614-4F35-A746-DE8DB63617E6 = __uuidof(IMMDeviceEnumerator) */
-#ifdef __cplusplus
-#define MA_CLSID_MMDeviceEnumerator MA_CLSID_MMDeviceEnumerator_Instance
-#define MA_IID_IMMDeviceEnumerator MA_IID_IMMDeviceEnumerator_Instance
-#else
-#define MA_CLSID_MMDeviceEnumerator &MA_CLSID_MMDeviceEnumerator_Instance
-#define MA_IID_IMMDeviceEnumerator &MA_IID_IMMDeviceEnumerator_Instance
-#endif
+static const IID MA_CLSID_MMDeviceEnumerator = {0xBCDE0395, 0xE52F, 0x467C, {0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E}}; /* BCDE0395-E52F-467C-8E3D-C4579291692E = __uuidof(MMDeviceEnumerator) */
+static const IID MA_IID_IMMDeviceEnumerator = {0xA95664D2, 0x9614, 0x4F35, {0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6}}; /* A95664D2-9614-4F35-A746-DE8DB63617E6 = __uuidof(IMMDeviceEnumerator) */
-typedef struct ma_IUnknown ma_IUnknown;
#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)
#define MA_MM_DEVICE_STATE_ACTIVE 1
#define MA_MM_DEVICE_STATE_DISABLED 2
@@ -19359,11 +20294,11 @@ static MA_INLINE ULONG ma_IUnknown_Release(ma_IUnknown* pThis)
ULONG (STDMETHODCALLTYPE * Release) (ma_IMMNotificationClient* pThis);
/* IMMNotificationClient */
- HRESULT (STDMETHODCALLTYPE * OnDeviceStateChanged) (ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID, DWORD dwNewState);
- HRESULT (STDMETHODCALLTYPE * OnDeviceAdded) (ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID);
- HRESULT (STDMETHODCALLTYPE * OnDeviceRemoved) (ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID);
- HRESULT (STDMETHODCALLTYPE * OnDefaultDeviceChanged)(ma_IMMNotificationClient* pThis, ma_EDataFlow dataFlow, ma_ERole role, LPCWSTR pDefaultDeviceID);
- HRESULT (STDMETHODCALLTYPE * OnPropertyValueChanged)(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID, const PROPERTYKEY key);
+ HRESULT (STDMETHODCALLTYPE * OnDeviceStateChanged) (ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID, DWORD dwNewState);
+ HRESULT (STDMETHODCALLTYPE * OnDeviceAdded) (ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID);
+ HRESULT (STDMETHODCALLTYPE * OnDeviceRemoved) (ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID);
+ HRESULT (STDMETHODCALLTYPE * OnDefaultDeviceChanged)(ma_IMMNotificationClient* pThis, ma_EDataFlow dataFlow, ma_ERole role, const WCHAR* pDefaultDeviceID);
+ HRESULT (STDMETHODCALLTYPE * OnPropertyValueChanged)(ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID, const PROPERTYKEY key);
} ma_IMMNotificationClientVtbl;
/* IMMDeviceEnumerator */
@@ -19377,7 +20312,7 @@ static MA_INLINE ULONG ma_IUnknown_Release(ma_IUnknown* pThis)
/* IMMDeviceEnumerator */
HRESULT (STDMETHODCALLTYPE * EnumAudioEndpoints) (ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, DWORD dwStateMask, ma_IMMDeviceCollection** ppDevices);
HRESULT (STDMETHODCALLTYPE * GetDefaultAudioEndpoint) (ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, ma_ERole role, ma_IMMDevice** ppEndpoint);
- HRESULT (STDMETHODCALLTYPE * GetDevice) (ma_IMMDeviceEnumerator* pThis, LPCWSTR pID, ma_IMMDevice** ppDevice);
+ HRESULT (STDMETHODCALLTYPE * GetDevice) (ma_IMMDeviceEnumerator* pThis, const WCHAR* pID, ma_IMMDevice** ppDevice);
HRESULT (STDMETHODCALLTYPE * RegisterEndpointNotificationCallback) (ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient);
HRESULT (STDMETHODCALLTYPE * UnregisterEndpointNotificationCallback)(ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient);
} ma_IMMDeviceEnumeratorVtbl;
@@ -19390,7 +20325,7 @@ static MA_INLINE ULONG ma_IUnknown_Release(ma_IUnknown* pThis)
static MA_INLINE ULONG ma_IMMDeviceEnumerator_Release(ma_IMMDeviceEnumerator* pThis) { return pThis->lpVtbl->Release(pThis); }
static MA_INLINE HRESULT ma_IMMDeviceEnumerator_EnumAudioEndpoints(ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, DWORD dwStateMask, ma_IMMDeviceCollection** ppDevices) { return pThis->lpVtbl->EnumAudioEndpoints(pThis, dataFlow, dwStateMask, ppDevices); }
static MA_INLINE HRESULT ma_IMMDeviceEnumerator_GetDefaultAudioEndpoint(ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, ma_ERole role, ma_IMMDevice** ppEndpoint) { return pThis->lpVtbl->GetDefaultAudioEndpoint(pThis, dataFlow, role, ppEndpoint); }
- static MA_INLINE HRESULT ma_IMMDeviceEnumerator_GetDevice(ma_IMMDeviceEnumerator* pThis, LPCWSTR pID, ma_IMMDevice** ppDevice) { return pThis->lpVtbl->GetDevice(pThis, pID, ppDevice); }
+ static MA_INLINE HRESULT ma_IMMDeviceEnumerator_GetDevice(ma_IMMDeviceEnumerator* pThis, const WCHAR* pID, ma_IMMDevice** ppDevice) { return pThis->lpVtbl->GetDevice(pThis, pID, ppDevice); }
static MA_INLINE HRESULT ma_IMMDeviceEnumerator_RegisterEndpointNotificationCallback(ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient) { return pThis->lpVtbl->RegisterEndpointNotificationCallback(pThis, pClient); }
static MA_INLINE HRESULT ma_IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient) { return pThis->lpVtbl->UnregisterEndpointNotificationCallback(pThis, pClient); }
@@ -19427,9 +20362,9 @@ static MA_INLINE ULONG ma_IUnknown_Release(ma_IUnknown* pThis)
ULONG (STDMETHODCALLTYPE * Release) (ma_IMMDevice* pThis);
/* IMMDevice */
- HRESULT (STDMETHODCALLTYPE * Activate) (ma_IMMDevice* pThis, const IID* const iid, DWORD dwClsCtx, PROPVARIANT* pActivationParams, void** ppInterface);
+ HRESULT (STDMETHODCALLTYPE * Activate) (ma_IMMDevice* pThis, const IID* const iid, DWORD dwClsCtx, MA_PROPVARIANT* pActivationParams, void** ppInterface);
HRESULT (STDMETHODCALLTYPE * OpenPropertyStore)(ma_IMMDevice* pThis, DWORD stgmAccess, ma_IPropertyStore** ppProperties);
- HRESULT (STDMETHODCALLTYPE * GetId) (ma_IMMDevice* pThis, LPWSTR *pID);
+ HRESULT (STDMETHODCALLTYPE * GetId) (ma_IMMDevice* pThis, WCHAR** pID);
HRESULT (STDMETHODCALLTYPE * GetState) (ma_IMMDevice* pThis, DWORD *pState);
} ma_IMMDeviceVtbl;
struct ma_IMMDevice
@@ -19439,9 +20374,9 @@ static MA_INLINE ULONG ma_IUnknown_Release(ma_IUnknown* pThis)
static MA_INLINE HRESULT ma_IMMDevice_QueryInterface(ma_IMMDevice* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
static MA_INLINE ULONG ma_IMMDevice_AddRef(ma_IMMDevice* pThis) { return pThis->lpVtbl->AddRef(pThis); }
static MA_INLINE ULONG ma_IMMDevice_Release(ma_IMMDevice* pThis) { return pThis->lpVtbl->Release(pThis); }
- static MA_INLINE HRESULT ma_IMMDevice_Activate(ma_IMMDevice* pThis, const IID* const iid, DWORD dwClsCtx, PROPVARIANT* pActivationParams, void** ppInterface) { return pThis->lpVtbl->Activate(pThis, iid, dwClsCtx, pActivationParams, ppInterface); }
+ static MA_INLINE HRESULT ma_IMMDevice_Activate(ma_IMMDevice* pThis, const IID* const iid, DWORD dwClsCtx, MA_PROPVARIANT* pActivationParams, void** ppInterface) { return pThis->lpVtbl->Activate(pThis, iid, dwClsCtx, pActivationParams, ppInterface); }
static MA_INLINE HRESULT ma_IMMDevice_OpenPropertyStore(ma_IMMDevice* pThis, DWORD stgmAccess, ma_IPropertyStore** ppProperties) { return pThis->lpVtbl->OpenPropertyStore(pThis, stgmAccess, ppProperties); }
- static MA_INLINE HRESULT ma_IMMDevice_GetId(ma_IMMDevice* pThis, LPWSTR *pID) { return pThis->lpVtbl->GetId(pThis, pID); }
+ static MA_INLINE HRESULT ma_IMMDevice_GetId(ma_IMMDevice* pThis, WCHAR** pID) { return pThis->lpVtbl->GetId(pThis, pID); }
static MA_INLINE HRESULT ma_IMMDevice_GetState(ma_IMMDevice* pThis, DWORD *pState) { return pThis->lpVtbl->GetState(pThis, pState); }
#else
/* IActivateAudioInterfaceAsyncOperation */
@@ -19476,8 +20411,8 @@ typedef struct
/* IPropertyStore */
HRESULT (STDMETHODCALLTYPE * GetCount)(ma_IPropertyStore* pThis, DWORD* pPropCount);
HRESULT (STDMETHODCALLTYPE * GetAt) (ma_IPropertyStore* pThis, DWORD propIndex, PROPERTYKEY* pPropKey);
- HRESULT (STDMETHODCALLTYPE * GetValue)(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, PROPVARIANT* pPropVar);
- HRESULT (STDMETHODCALLTYPE * SetValue)(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, const PROPVARIANT* const pPropVar);
+ HRESULT (STDMETHODCALLTYPE * GetValue)(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, MA_PROPVARIANT* pPropVar);
+ HRESULT (STDMETHODCALLTYPE * SetValue)(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, const MA_PROPVARIANT* const pPropVar);
HRESULT (STDMETHODCALLTYPE * Commit) (ma_IPropertyStore* pThis);
} ma_IPropertyStoreVtbl;
struct ma_IPropertyStore
@@ -19489,8 +20424,8 @@ static MA_INLINE ULONG ma_IPropertyStore_AddRef(ma_IPropertyStore* pThis)
static MA_INLINE ULONG ma_IPropertyStore_Release(ma_IPropertyStore* pThis) { return pThis->lpVtbl->Release(pThis); }
static MA_INLINE HRESULT ma_IPropertyStore_GetCount(ma_IPropertyStore* pThis, DWORD* pPropCount) { return pThis->lpVtbl->GetCount(pThis, pPropCount); }
static MA_INLINE HRESULT ma_IPropertyStore_GetAt(ma_IPropertyStore* pThis, DWORD propIndex, PROPERTYKEY* pPropKey) { return pThis->lpVtbl->GetAt(pThis, propIndex, pPropKey); }
-static MA_INLINE HRESULT ma_IPropertyStore_GetValue(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, PROPVARIANT* pPropVar) { return pThis->lpVtbl->GetValue(pThis, pKey, pPropVar); }
-static MA_INLINE HRESULT ma_IPropertyStore_SetValue(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, const PROPVARIANT* const pPropVar) { return pThis->lpVtbl->SetValue(pThis, pKey, pPropVar); }
+static MA_INLINE HRESULT ma_IPropertyStore_GetValue(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, MA_PROPVARIANT* pPropVar) { return pThis->lpVtbl->GetValue(pThis, pKey, pPropVar); }
+static MA_INLINE HRESULT ma_IPropertyStore_SetValue(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, const MA_PROPVARIANT* const pPropVar) { return pThis->lpVtbl->SetValue(pThis, pKey, pPropVar); }
static MA_INLINE HRESULT ma_IPropertyStore_Commit(ma_IPropertyStore* pThis) { return pThis->lpVtbl->Commit(pThis); }
@@ -19503,12 +20438,12 @@ typedef struct
ULONG (STDMETHODCALLTYPE * Release) (ma_IAudioClient* pThis);
/* IAudioClient */
- HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
+ HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
HRESULT (STDMETHODCALLTYPE * GetBufferSize) (ma_IAudioClient* pThis, ma_uint32* pNumBufferFrames);
HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (ma_IAudioClient* pThis, MA_REFERENCE_TIME* pLatency);
HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(ma_IAudioClient* pThis, ma_uint32* pNumPaddingFrames);
- HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch);
- HRESULT (STDMETHODCALLTYPE * GetMixFormat) (ma_IAudioClient* pThis, WAVEFORMATEX** ppDeviceFormat);
+ HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, const MA_WAVEFORMATEX* pFormat, MA_WAVEFORMATEX** ppClosestMatch);
+ HRESULT (STDMETHODCALLTYPE * GetMixFormat) (ma_IAudioClient* pThis, MA_WAVEFORMATEX** ppDeviceFormat);
HRESULT (STDMETHODCALLTYPE * GetDevicePeriod) (ma_IAudioClient* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod);
HRESULT (STDMETHODCALLTYPE * Start) (ma_IAudioClient* pThis);
HRESULT (STDMETHODCALLTYPE * Stop) (ma_IAudioClient* pThis);
@@ -19523,12 +20458,12 @@ struct ma_IAudioClient
static MA_INLINE HRESULT ma_IAudioClient_QueryInterface(ma_IAudioClient* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
static MA_INLINE ULONG ma_IAudioClient_AddRef(ma_IAudioClient* pThis) { return pThis->lpVtbl->AddRef(pThis); }
static MA_INLINE ULONG ma_IAudioClient_Release(ma_IAudioClient* pThis) { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient_Initialize(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); }
+static MA_INLINE HRESULT ma_IAudioClient_Initialize(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); }
static MA_INLINE HRESULT ma_IAudioClient_GetBufferSize(ma_IAudioClient* pThis, ma_uint32* pNumBufferFrames) { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); }
static MA_INLINE HRESULT ma_IAudioClient_GetStreamLatency(ma_IAudioClient* pThis, MA_REFERENCE_TIME* pLatency) { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); }
static MA_INLINE HRESULT ma_IAudioClient_GetCurrentPadding(ma_IAudioClient* pThis, ma_uint32* pNumPaddingFrames) { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); }
-static MA_INLINE HRESULT ma_IAudioClient_IsFormatSupported(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); }
-static MA_INLINE HRESULT ma_IAudioClient_GetMixFormat(ma_IAudioClient* pThis, WAVEFORMATEX** ppDeviceFormat) { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); }
+static MA_INLINE HRESULT ma_IAudioClient_IsFormatSupported(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, const MA_WAVEFORMATEX* pFormat, MA_WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); }
+static MA_INLINE HRESULT ma_IAudioClient_GetMixFormat(ma_IAudioClient* pThis, MA_WAVEFORMATEX** ppDeviceFormat) { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); }
static MA_INLINE HRESULT ma_IAudioClient_GetDevicePeriod(ma_IAudioClient* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); }
static MA_INLINE HRESULT ma_IAudioClient_Start(ma_IAudioClient* pThis) { return pThis->lpVtbl->Start(pThis); }
static MA_INLINE HRESULT ma_IAudioClient_Stop(ma_IAudioClient* pThis) { return pThis->lpVtbl->Stop(pThis); }
@@ -19545,12 +20480,12 @@ typedef struct
ULONG (STDMETHODCALLTYPE * Release) (ma_IAudioClient2* pThis);
/* IAudioClient */
- HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
+ HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
HRESULT (STDMETHODCALLTYPE * GetBufferSize) (ma_IAudioClient2* pThis, ma_uint32* pNumBufferFrames);
HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pLatency);
HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(ma_IAudioClient2* pThis, ma_uint32* pNumPaddingFrames);
- HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch);
- HRESULT (STDMETHODCALLTYPE * GetMixFormat) (ma_IAudioClient2* pThis, WAVEFORMATEX** ppDeviceFormat);
+ HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, const MA_WAVEFORMATEX* pFormat, MA_WAVEFORMATEX** ppClosestMatch);
+ HRESULT (STDMETHODCALLTYPE * GetMixFormat) (ma_IAudioClient2* pThis, MA_WAVEFORMATEX** ppDeviceFormat);
HRESULT (STDMETHODCALLTYPE * GetDevicePeriod) (ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod);
HRESULT (STDMETHODCALLTYPE * Start) (ma_IAudioClient2* pThis);
HRESULT (STDMETHODCALLTYPE * Stop) (ma_IAudioClient2* pThis);
@@ -19561,7 +20496,7 @@ typedef struct
/* IAudioClient2 */
HRESULT (STDMETHODCALLTYPE * IsOffloadCapable) (ma_IAudioClient2* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable);
HRESULT (STDMETHODCALLTYPE * SetClientProperties)(ma_IAudioClient2* pThis, const ma_AudioClientProperties* pProperties);
- HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(ma_IAudioClient2* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration);
+ HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(ma_IAudioClient2* pThis, const MA_WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration);
} ma_IAudioClient2Vtbl;
struct ma_IAudioClient2
{
@@ -19570,12 +20505,12 @@ struct ma_IAudioClient2
static MA_INLINE HRESULT ma_IAudioClient2_QueryInterface(ma_IAudioClient2* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
static MA_INLINE ULONG ma_IAudioClient2_AddRef(ma_IAudioClient2* pThis) { return pThis->lpVtbl->AddRef(pThis); }
static MA_INLINE ULONG ma_IAudioClient2_Release(ma_IAudioClient2* pThis) { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient2_Initialize(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); }
+static MA_INLINE HRESULT ma_IAudioClient2_Initialize(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); }
static MA_INLINE HRESULT ma_IAudioClient2_GetBufferSize(ma_IAudioClient2* pThis, ma_uint32* pNumBufferFrames) { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); }
static MA_INLINE HRESULT ma_IAudioClient2_GetStreamLatency(ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pLatency) { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); }
static MA_INLINE HRESULT ma_IAudioClient2_GetCurrentPadding(ma_IAudioClient2* pThis, ma_uint32* pNumPaddingFrames) { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); }
-static MA_INLINE HRESULT ma_IAudioClient2_IsFormatSupported(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetMixFormat(ma_IAudioClient2* pThis, WAVEFORMATEX** ppDeviceFormat) { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); }
+static MA_INLINE HRESULT ma_IAudioClient2_IsFormatSupported(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, const MA_WAVEFORMATEX* pFormat, MA_WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); }
+static MA_INLINE HRESULT ma_IAudioClient2_GetMixFormat(ma_IAudioClient2* pThis, MA_WAVEFORMATEX** ppDeviceFormat) { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); }
static MA_INLINE HRESULT ma_IAudioClient2_GetDevicePeriod(ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); }
static MA_INLINE HRESULT ma_IAudioClient2_Start(ma_IAudioClient2* pThis) { return pThis->lpVtbl->Start(pThis); }
static MA_INLINE HRESULT ma_IAudioClient2_Stop(ma_IAudioClient2* pThis) { return pThis->lpVtbl->Stop(pThis); }
@@ -19584,7 +20519,7 @@ static MA_INLINE HRESULT ma_IAudioClient2_SetEventHandle(ma_IAudioClient2* pThis
static MA_INLINE HRESULT ma_IAudioClient2_GetService(ma_IAudioClient2* pThis, const IID* const riid, void** pp) { return pThis->lpVtbl->GetService(pThis, riid, pp); }
static MA_INLINE HRESULT ma_IAudioClient2_IsOffloadCapable(ma_IAudioClient2* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable) { return pThis->lpVtbl->IsOffloadCapable(pThis, category, pOffloadCapable); }
static MA_INLINE HRESULT ma_IAudioClient2_SetClientProperties(ma_IAudioClient2* pThis, const ma_AudioClientProperties* pProperties) { return pThis->lpVtbl->SetClientProperties(pThis, pProperties); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetBufferSizeLimits(ma_IAudioClient2* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); }
+static MA_INLINE HRESULT ma_IAudioClient2_GetBufferSizeLimits(ma_IAudioClient2* pThis, const MA_WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); }
/* IAudioClient3 */
@@ -19596,12 +20531,12 @@ typedef struct
ULONG (STDMETHODCALLTYPE * Release) (ma_IAudioClient3* pThis);
/* IAudioClient */
- HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
+ HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
HRESULT (STDMETHODCALLTYPE * GetBufferSize) (ma_IAudioClient3* pThis, ma_uint32* pNumBufferFrames);
HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pLatency);
HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(ma_IAudioClient3* pThis, ma_uint32* pNumPaddingFrames);
- HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch);
- HRESULT (STDMETHODCALLTYPE * GetMixFormat) (ma_IAudioClient3* pThis, WAVEFORMATEX** ppDeviceFormat);
+ HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, const MA_WAVEFORMATEX* pFormat, MA_WAVEFORMATEX** ppClosestMatch);
+ HRESULT (STDMETHODCALLTYPE * GetMixFormat) (ma_IAudioClient3* pThis, MA_WAVEFORMATEX** ppDeviceFormat);
HRESULT (STDMETHODCALLTYPE * GetDevicePeriod) (ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod);
HRESULT (STDMETHODCALLTYPE * Start) (ma_IAudioClient3* pThis);
HRESULT (STDMETHODCALLTYPE * Stop) (ma_IAudioClient3* pThis);
@@ -19612,12 +20547,12 @@ typedef struct
/* IAudioClient2 */
HRESULT (STDMETHODCALLTYPE * IsOffloadCapable) (ma_IAudioClient3* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable);
HRESULT (STDMETHODCALLTYPE * SetClientProperties)(ma_IAudioClient3* pThis, const ma_AudioClientProperties* pProperties);
- HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(ma_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration);
+ HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(ma_IAudioClient3* pThis, const MA_WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration);
/* IAudioClient3 */
- HRESULT (STDMETHODCALLTYPE * GetSharedModeEnginePeriod) (ma_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, ma_uint32* pDefaultPeriodInFrames, ma_uint32* pFundamentalPeriodInFrames, ma_uint32* pMinPeriodInFrames, ma_uint32* pMaxPeriodInFrames);
- HRESULT (STDMETHODCALLTYPE * GetCurrentSharedModeEnginePeriod)(ma_IAudioClient3* pThis, WAVEFORMATEX** ppFormat, ma_uint32* pCurrentPeriodInFrames);
- HRESULT (STDMETHODCALLTYPE * InitializeSharedAudioStream) (ma_IAudioClient3* pThis, DWORD streamFlags, ma_uint32 periodInFrames, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
+ HRESULT (STDMETHODCALLTYPE * GetSharedModeEnginePeriod) (ma_IAudioClient3* pThis, const MA_WAVEFORMATEX* pFormat, ma_uint32* pDefaultPeriodInFrames, ma_uint32* pFundamentalPeriodInFrames, ma_uint32* pMinPeriodInFrames, ma_uint32* pMaxPeriodInFrames);
+ HRESULT (STDMETHODCALLTYPE * GetCurrentSharedModeEnginePeriod)(ma_IAudioClient3* pThis, MA_WAVEFORMATEX** ppFormat, ma_uint32* pCurrentPeriodInFrames);
+ HRESULT (STDMETHODCALLTYPE * InitializeSharedAudioStream) (ma_IAudioClient3* pThis, DWORD streamFlags, ma_uint32 periodInFrames, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
} ma_IAudioClient3Vtbl;
struct ma_IAudioClient3
{
@@ -19626,12 +20561,12 @@ struct ma_IAudioClient3
static MA_INLINE HRESULT ma_IAudioClient3_QueryInterface(ma_IAudioClient3* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
static MA_INLINE ULONG ma_IAudioClient3_AddRef(ma_IAudioClient3* pThis) { return pThis->lpVtbl->AddRef(pThis); }
static MA_INLINE ULONG ma_IAudioClient3_Release(ma_IAudioClient3* pThis) { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient3_Initialize(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); }
+static MA_INLINE HRESULT ma_IAudioClient3_Initialize(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); }
static MA_INLINE HRESULT ma_IAudioClient3_GetBufferSize(ma_IAudioClient3* pThis, ma_uint32* pNumBufferFrames) { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); }
static MA_INLINE HRESULT ma_IAudioClient3_GetStreamLatency(ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pLatency) { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); }
static MA_INLINE HRESULT ma_IAudioClient3_GetCurrentPadding(ma_IAudioClient3* pThis, ma_uint32* pNumPaddingFrames) { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); }
-static MA_INLINE HRESULT ma_IAudioClient3_IsFormatSupported(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetMixFormat(ma_IAudioClient3* pThis, WAVEFORMATEX** ppDeviceFormat) { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); }
+static MA_INLINE HRESULT ma_IAudioClient3_IsFormatSupported(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, const MA_WAVEFORMATEX* pFormat, MA_WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); }
+static MA_INLINE HRESULT ma_IAudioClient3_GetMixFormat(ma_IAudioClient3* pThis, MA_WAVEFORMATEX** ppDeviceFormat) { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); }
static MA_INLINE HRESULT ma_IAudioClient3_GetDevicePeriod(ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); }
static MA_INLINE HRESULT ma_IAudioClient3_Start(ma_IAudioClient3* pThis) { return pThis->lpVtbl->Start(pThis); }
static MA_INLINE HRESULT ma_IAudioClient3_Stop(ma_IAudioClient3* pThis) { return pThis->lpVtbl->Stop(pThis); }
@@ -19640,10 +20575,10 @@ static MA_INLINE HRESULT ma_IAudioClient3_SetEventHandle(ma_IAudioClient3* pThis
static MA_INLINE HRESULT ma_IAudioClient3_GetService(ma_IAudioClient3* pThis, const IID* const riid, void** pp) { return pThis->lpVtbl->GetService(pThis, riid, pp); }
static MA_INLINE HRESULT ma_IAudioClient3_IsOffloadCapable(ma_IAudioClient3* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable) { return pThis->lpVtbl->IsOffloadCapable(pThis, category, pOffloadCapable); }
static MA_INLINE HRESULT ma_IAudioClient3_SetClientProperties(ma_IAudioClient3* pThis, const ma_AudioClientProperties* pProperties) { return pThis->lpVtbl->SetClientProperties(pThis, pProperties); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetBufferSizeLimits(ma_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetSharedModeEnginePeriod(ma_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, ma_uint32* pDefaultPeriodInFrames, ma_uint32* pFundamentalPeriodInFrames, ma_uint32* pMinPeriodInFrames, ma_uint32* pMaxPeriodInFrames) { return pThis->lpVtbl->GetSharedModeEnginePeriod(pThis, pFormat, pDefaultPeriodInFrames, pFundamentalPeriodInFrames, pMinPeriodInFrames, pMaxPeriodInFrames); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetCurrentSharedModeEnginePeriod(ma_IAudioClient3* pThis, WAVEFORMATEX** ppFormat, ma_uint32* pCurrentPeriodInFrames) { return pThis->lpVtbl->GetCurrentSharedModeEnginePeriod(pThis, ppFormat, pCurrentPeriodInFrames); }
-static MA_INLINE HRESULT ma_IAudioClient3_InitializeSharedAudioStream(ma_IAudioClient3* pThis, DWORD streamFlags, ma_uint32 periodInFrames, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGUID) { return pThis->lpVtbl->InitializeSharedAudioStream(pThis, streamFlags, periodInFrames, pFormat, pAudioSessionGUID); }
+static MA_INLINE HRESULT ma_IAudioClient3_GetBufferSizeLimits(ma_IAudioClient3* pThis, const MA_WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); }
+static MA_INLINE HRESULT ma_IAudioClient3_GetSharedModeEnginePeriod(ma_IAudioClient3* pThis, const MA_WAVEFORMATEX* pFormat, ma_uint32* pDefaultPeriodInFrames, ma_uint32* pFundamentalPeriodInFrames, ma_uint32* pMinPeriodInFrames, ma_uint32* pMaxPeriodInFrames) { return pThis->lpVtbl->GetSharedModeEnginePeriod(pThis, pFormat, pDefaultPeriodInFrames, pFundamentalPeriodInFrames, pMinPeriodInFrames, pMaxPeriodInFrames); }
+static MA_INLINE HRESULT ma_IAudioClient3_GetCurrentSharedModeEnginePeriod(ma_IAudioClient3* pThis, MA_WAVEFORMATEX** ppFormat, ma_uint32* pCurrentPeriodInFrames) { return pThis->lpVtbl->GetCurrentSharedModeEnginePeriod(pThis, ppFormat, pCurrentPeriodInFrames); }
+static MA_INLINE HRESULT ma_IAudioClient3_InitializeSharedAudioStream(ma_IAudioClient3* pThis, DWORD streamFlags, ma_uint32 periodInFrames, const MA_WAVEFORMATEX* pFormat, const GUID* pAudioSessionGUID) { return pThis->lpVtbl->InitializeSharedAudioStream(pThis, streamFlags, periodInFrames, pFormat, pAudioSessionGUID); }
/* IAudioRenderClient */
@@ -19693,8 +20628,16 @@ static MA_INLINE HRESULT ma_IAudioCaptureClient_GetBuffer(ma_IAudioCaptureClient
static MA_INLINE HRESULT ma_IAudioCaptureClient_ReleaseBuffer(ma_IAudioCaptureClient* pThis, ma_uint32 numFramesRead) { return pThis->lpVtbl->ReleaseBuffer(pThis, numFramesRead); }
static MA_INLINE HRESULT ma_IAudioCaptureClient_GetNextPacketSize(ma_IAudioCaptureClient* pThis, ma_uint32* pNumFramesInNextPacket) { return pThis->lpVtbl->GetNextPacketSize(pThis, pNumFramesInNextPacket); }
+#if defined(MA_WIN32_UWP)
+/* mmdevapi Functions */
+typedef HRESULT (WINAPI * MA_PFN_ActivateAudioInterfaceAsync)(const wchar_t* deviceInterfacePath, const IID* riid, MA_PROPVARIANT* activationParams, ma_IActivateAudioInterfaceCompletionHandler* completionHandler, ma_IActivateAudioInterfaceAsyncOperation** activationOperation);
+#endif
+
+/* Avrt Functions */
+typedef HANDLE (WINAPI * MA_PFN_AvSetMmThreadCharacteristicsA)(const char* TaskName, DWORD* TaskIndex);
+typedef BOOL (WINAPI * MA_PFN_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle);
+
#if !defined(MA_WIN32_DESKTOP) && !defined(MA_WIN32_GDK)
-#include
typedef struct ma_completion_handler_uwp ma_completion_handler_uwp;
typedef struct
@@ -19768,7 +20711,7 @@ static ma_result ma_completion_handler_uwp_init(ma_completion_handler_uwp* pHand
pHandler->lpVtbl = &g_maCompletionHandlerVtblInstance;
pHandler->counter = 1;
- pHandler->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+ pHandler->hEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
if (pHandler->hEvent == NULL) {
return ma_result_from_GetLastError(GetLastError());
}
@@ -19785,7 +20728,7 @@ static void ma_completion_handler_uwp_uninit(ma_completion_handler_uwp* pHandler
static void ma_completion_handler_uwp_wait(ma_completion_handler_uwp* pHandler)
{
- WaitForSingleObject(pHandler->hEvent, INFINITE);
+ WaitForSingleObject((HANDLE)pHandler->hEvent, INFINITE);
}
#endif /* !MA_WIN32_DESKTOP */
@@ -19823,7 +20766,7 @@ static ULONG STDMETHODCALLTYPE ma_IMMNotificationClient_Release(ma_IMMNotificati
return (ULONG)newRefCount;
}
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceStateChanged(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID, DWORD dwNewState)
+static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceStateChanged(ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID, DWORD dwNewState)
{
ma_bool32 isThisDevice = MA_FALSE;
ma_bool32 isCapture = MA_FALSE;
@@ -19839,14 +20782,14 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceStateChanged(m
*/
if (pThis->pDevice->wasapi.allowCaptureAutoStreamRouting && (pThis->pDevice->type == ma_device_type_capture || pThis->pDevice->type == ma_device_type_duplex || pThis->pDevice->type == ma_device_type_loopback)) {
isCapture = MA_TRUE;
- if (wcscmp(pThis->pDevice->capture.id.wasapi, pDeviceID) == 0) {
+ if (ma_strcmp_WCHAR(pThis->pDevice->capture.id.wasapi, pDeviceID) == 0) {
isThisDevice = MA_TRUE;
}
}
if (pThis->pDevice->wasapi.allowPlaybackAutoStreamRouting && (pThis->pDevice->type == ma_device_type_playback || pThis->pDevice->type == ma_device_type_duplex)) {
isPlayback = MA_TRUE;
- if (wcscmp(pThis->pDevice->playback.id.wasapi, pDeviceID) == 0) {
+ if (ma_strcmp_WCHAR(pThis->pDevice->playback.id.wasapi, pDeviceID) == 0) {
isThisDevice = MA_TRUE;
}
}
@@ -19907,7 +20850,7 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceStateChanged(m
return S_OK;
}
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceAdded(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID)
+static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceAdded(ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID)
{
#ifdef MA_DEBUG_OUTPUT
/*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDeviceAdded(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");*/
@@ -19919,7 +20862,7 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceAdded(ma_IMMNo
return S_OK;
}
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceRemoved(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID)
+static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceRemoved(ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID)
{
#ifdef MA_DEBUG_OUTPUT
/*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDeviceRemoved(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");*/
@@ -19931,23 +20874,25 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceRemoved(ma_IMM
return S_OK;
}
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged(ma_IMMNotificationClient* pThis, ma_EDataFlow dataFlow, ma_ERole role, LPCWSTR pDefaultDeviceID)
+static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged(ma_IMMNotificationClient* pThis, ma_EDataFlow dataFlow, ma_ERole role, const WCHAR* pDefaultDeviceID)
{
#ifdef MA_DEBUG_OUTPUT
/*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnDefaultDeviceChanged(dataFlow=%d, role=%d, pDefaultDeviceID=%S)\n", dataFlow, role, (pDefaultDeviceID != NULL) ? pDefaultDeviceID : L"(NULL)");*/
#endif
- /* We only ever use the eConsole role in miniaudio. */
- if (role != ma_eConsole) {
- ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Stream rerouting: role != eConsole\n");
+ (void)role;
+
+ /* We only care about devices with the same data flow as the current device. */
+ if ((pThis->pDevice->type == ma_device_type_playback && dataFlow != ma_eRender) ||
+ (pThis->pDevice->type == ma_device_type_capture && dataFlow != ma_eCapture) ||
+ (pThis->pDevice->type == ma_device_type_loopback && dataFlow != ma_eRender)) {
+ ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Stream rerouting abandoned because dataFlow does match device type.\n");
return S_OK;
}
- /* We only care about devices with the same data flow and role as the current device. */
- if ((pThis->pDevice->type == ma_device_type_playback && dataFlow != ma_eRender) ||
- (pThis->pDevice->type == ma_device_type_capture && dataFlow != ma_eCapture)) {
- ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Stream rerouting abandoned because dataFlow does match device type.\n");
- return S_OK;
+ /* We need to consider dataFlow as ma_eCapture if device is ma_device_type_loopback */
+ if (pThis->pDevice->type == ma_device_type_loopback) {
+ dataFlow = ma_eCapture;
}
/* Don't do automatic stream routing if we're not allowed. */
@@ -19970,7 +20915,6 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged
-
/*
Second attempt at device rerouting. We're going to retrieve the device's state at the time of
the route change. We're then going to stop the device, reinitialize the device, and then start
@@ -19980,37 +20924,49 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged
ma_uint32 previousState = ma_device_get_state(pThis->pDevice);
ma_bool8 restartDevice = MA_FALSE;
+ if (previousState == ma_device_state_uninitialized || previousState == ma_device_state_starting) {
+ ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Stream rerouting abandoned because the device is in the process of starting.\n");
+ return S_OK;
+ }
+
if (previousState == ma_device_state_started) {
ma_device_stop(pThis->pDevice);
restartDevice = MA_TRUE;
}
if (pDefaultDeviceID != NULL) { /* <-- The input device ID will be null if there's no other device available. */
- if (dataFlow == ma_eRender) {
- ma_device_reroute__wasapi(pThis->pDevice, ma_device_type_playback);
+ ma_mutex_lock(&pThis->pDevice->wasapi.rerouteLock);
+ {
+ if (dataFlow == ma_eRender) {
+ ma_device_reroute__wasapi(pThis->pDevice, ma_device_type_playback);
- if (pThis->pDevice->wasapi.isDetachedPlayback) {
- pThis->pDevice->wasapi.isDetachedPlayback = MA_FALSE;
+ if (pThis->pDevice->wasapi.isDetachedPlayback) {
+ pThis->pDevice->wasapi.isDetachedPlayback = MA_FALSE;
- if (pThis->pDevice->type == ma_device_type_duplex && pThis->pDevice->wasapi.isDetachedCapture) {
- restartDevice = MA_FALSE; /* It's a duplex device and the capture side is detached. We cannot be restarting the device just yet. */
- } else {
- restartDevice = MA_TRUE; /* It's not a duplex device, or the capture side is also attached so we can go ahead and restart the device. */
+ if (pThis->pDevice->type == ma_device_type_duplex && pThis->pDevice->wasapi.isDetachedCapture) {
+ restartDevice = MA_FALSE; /* It's a duplex device and the capture side is detached. We cannot be restarting the device just yet. */
+ }
+ else {
+ restartDevice = MA_TRUE; /* It's not a duplex device, or the capture side is also attached so we can go ahead and restart the device. */
+ }
}
}
- } else {
- ma_device_reroute__wasapi(pThis->pDevice, (pThis->pDevice->type == ma_device_type_loopback) ? ma_device_type_loopback : ma_device_type_capture);
+ else {
+ ma_device_reroute__wasapi(pThis->pDevice, (pThis->pDevice->type == ma_device_type_loopback) ? ma_device_type_loopback : ma_device_type_capture);
- if (pThis->pDevice->wasapi.isDetachedCapture) {
- pThis->pDevice->wasapi.isDetachedCapture = MA_FALSE;
+ if (pThis->pDevice->wasapi.isDetachedCapture) {
+ pThis->pDevice->wasapi.isDetachedCapture = MA_FALSE;
- if (pThis->pDevice->type == ma_device_type_duplex && pThis->pDevice->wasapi.isDetachedPlayback) {
- restartDevice = MA_FALSE; /* It's a duplex device and the playback side is detached. We cannot be restarting the device just yet. */
- } else {
- restartDevice = MA_TRUE; /* It's not a duplex device, or the playback side is also attached so we can go ahead and restart the device. */
+ if (pThis->pDevice->type == ma_device_type_duplex && pThis->pDevice->wasapi.isDetachedPlayback) {
+ restartDevice = MA_FALSE; /* It's a duplex device and the playback side is detached. We cannot be restarting the device just yet. */
+ }
+ else {
+ restartDevice = MA_TRUE; /* It's not a duplex device, or the playback side is also attached so we can go ahead and restart the device. */
+ }
}
}
}
+ ma_mutex_unlock(&pThis->pDevice->wasapi.rerouteLock);
if (restartDevice) {
ma_device_start(pThis->pDevice);
@@ -20021,7 +20977,7 @@ static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged
return S_OK;
}
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnPropertyValueChanged(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID, const PROPERTYKEY key)
+static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnPropertyValueChanged(ma_IMMNotificationClient* pThis, const WCHAR* pDeviceID, const PROPERTYKEY key)
{
#ifdef MA_DEBUG_OUTPUT
/*ma_log_postf(ma_device_get_log(pThis->pDevice), MA_LOG_LEVEL_DEBUG, "IMMNotificationClient_OnPropertyValueChanged(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");*/
@@ -20045,6 +21001,19 @@ static ma_IMMNotificationClientVtbl g_maNotificationCientVtbl = {
};
#endif /* MA_WIN32_DESKTOP */
+static const char* ma_to_usage_string__wasapi(ma_wasapi_usage usage)
+{
+ switch (usage)
+ {
+ case ma_wasapi_usage_default: return NULL;
+ case ma_wasapi_usage_games: return "Games";
+ case ma_wasapi_usage_pro_audio: return "Pro Audio";
+ default: break;
+ }
+
+ return NULL;
+}
+
#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)
typedef ma_IMMDevice ma_WASAPIDeviceInterface;
#else
@@ -20236,7 +21205,7 @@ static ma_result ma_device_release_IAudioClient_service__wasapi(ma_device* pDevi
#endif
-static void ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(const WAVEFORMATEX* pWF, ma_share_mode shareMode, ma_device_info* pInfo)
+static void ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(const MA_WAVEFORMATEX* pWF, ma_share_mode shareMode, ma_device_info* pInfo)
{
MA_ASSERT(pWF != NULL);
MA_ASSERT(pInfo != NULL);
@@ -20255,13 +21224,13 @@ static void ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(const WAV
static ma_result ma_context_get_device_info_from_IAudioClient__wasapi(ma_context* pContext, /*ma_IMMDevice**/void* pMMDevice, ma_IAudioClient* pAudioClient, ma_device_info* pInfo)
{
HRESULT hr;
- WAVEFORMATEX* pWF = NULL;
+ MA_WAVEFORMATEX* pWF = NULL;
MA_ASSERT(pAudioClient != NULL);
MA_ASSERT(pInfo != NULL);
/* Shared Mode. We use GetMixFormat() here. */
- hr = ma_IAudioClient_GetMixFormat((ma_IAudioClient*)pAudioClient, (WAVEFORMATEX**)&pWF);
+ hr = ma_IAudioClient_GetMixFormat((ma_IAudioClient*)pAudioClient, (MA_WAVEFORMATEX**)&pWF);
if (SUCCEEDED(hr)) {
ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(pWF, ma_share_mode_shared, pInfo);
} else {
@@ -20284,12 +21253,12 @@ static ma_result ma_context_get_device_info_from_IAudioClient__wasapi(ma_context
*/
hr = ma_IMMDevice_OpenPropertyStore((ma_IMMDevice*)pMMDevice, STGM_READ, &pProperties);
if (SUCCEEDED(hr)) {
- PROPVARIANT var;
+ MA_PROPVARIANT var;
ma_PropVariantInit(&var);
hr = ma_IPropertyStore_GetValue(pProperties, &MA_PKEY_AudioEngine_DeviceFormat, &var);
if (SUCCEEDED(hr)) {
- pWF = (WAVEFORMATEX*)var.blob.pBlobData;
+ pWF = (MA_WAVEFORMATEX*)var.blob.pBlobData;
/*
In my testing, the format returned by PKEY_AudioEngine_DeviceFormat is suitable for exclusive mode so we check this format
@@ -20306,7 +21275,7 @@ static ma_result ma_context_get_device_info_from_IAudioClient__wasapi(ma_context
*/
ma_uint32 channels = pWF->nChannels;
ma_channel defaultChannelMap[MA_MAX_CHANNELS];
- WAVEFORMATEXTENSIBLE wf;
+ MA_WAVEFORMATEXTENSIBLE wf;
ma_bool32 found;
ma_uint32 iFormat;
@@ -20318,9 +21287,9 @@ static ma_result ma_context_get_device_info_from_IAudioClient__wasapi(ma_context
ma_channel_map_init_standard(ma_standard_channel_map_microsoft, defaultChannelMap, ma_countof(defaultChannelMap), channels);
MA_ZERO_OBJECT(&wf);
- wf.Format.cbSize = sizeof(wf);
- wf.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wf.Format.nChannels = (WORD)channels;
+ wf.cbSize = sizeof(wf);
+ wf.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ wf.nChannels = (WORD)channels;
wf.dwChannelMask = ma_channel_map_to_channel_mask__win32(defaultChannelMap, channels);
found = MA_FALSE;
@@ -20328,10 +21297,10 @@ static ma_result ma_context_get_device_info_from_IAudioClient__wasapi(ma_context
ma_format format = g_maFormatPriorities[iFormat];
ma_uint32 iSampleRate;
- wf.Format.wBitsPerSample = (WORD)(ma_get_bytes_per_sample(format)*8);
- wf.Format.nBlockAlign = (WORD)(wf.Format.nChannels * wf.Format.wBitsPerSample / 8);
- wf.Format.nAvgBytesPerSec = wf.Format.nBlockAlign * wf.Format.nSamplesPerSec;
- wf.Samples.wValidBitsPerSample = /*(format == ma_format_s24_32) ? 24 :*/ wf.Format.wBitsPerSample;
+ wf.wBitsPerSample = (WORD)(ma_get_bytes_per_sample(format)*8);
+ wf.nBlockAlign = (WORD)(wf.nChannels * wf.wBitsPerSample / 8);
+ wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec;
+ wf.Samples.wValidBitsPerSample = /*(format == ma_format_s24_32) ? 24 :*/ wf.wBitsPerSample;
if (format == ma_format_f32) {
wf.SubFormat = MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
} else {
@@ -20339,11 +21308,11 @@ static ma_result ma_context_get_device_info_from_IAudioClient__wasapi(ma_context
}
for (iSampleRate = 0; iSampleRate < ma_countof(g_maStandardSampleRatePriorities); ++iSampleRate) {
- wf.Format.nSamplesPerSec = g_maStandardSampleRatePriorities[iSampleRate];
+ wf.nSamplesPerSec = g_maStandardSampleRatePriorities[iSampleRate];
- hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, (WAVEFORMATEX*)&wf, NULL);
+ hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, (MA_WAVEFORMATEX*)&wf, NULL);
if (SUCCEEDED(hr)) {
- ma_add_native_data_format_to_device_info_from_WAVEFORMATEX((WAVEFORMATEX*)&wf, ma_share_mode_exclusive, pInfo);
+ ma_add_native_data_format_to_device_info_from_WAVEFORMATEX((MA_WAVEFORMATEX*)&wf, ma_share_mode_exclusive, pInfo);
found = MA_TRUE;
break;
}
@@ -20369,6 +21338,10 @@ static ma_result ma_context_get_device_info_from_IAudioClient__wasapi(ma_context
ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_WARNING, "[WASAPI] Failed to open property store for device info retrieval.");
}
}
+ #else
+ {
+ (void)pMMDevice; /* Unused. */
+ }
#endif
return MA_SUCCESS;
@@ -20397,7 +21370,7 @@ static ma_result ma_context_create_IMMDeviceEnumerator__wasapi(ma_context* pCont
*ppDeviceEnumerator = NULL; /* Safety. */
- hr = ma_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
+ hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
if (FAILED(hr)) {
ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.");
return ma_result_from_HRESULT(hr);
@@ -20408,11 +21381,11 @@ static ma_result ma_context_create_IMMDeviceEnumerator__wasapi(ma_context* pCont
return MA_SUCCESS;
}
-static LPWSTR ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(ma_context* pContext, ma_IMMDeviceEnumerator* pDeviceEnumerator, ma_device_type deviceType)
+static WCHAR* ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(ma_context* pContext, ma_IMMDeviceEnumerator* pDeviceEnumerator, ma_device_type deviceType)
{
HRESULT hr;
ma_IMMDevice* pMMDefaultDevice = NULL;
- LPWSTR pDefaultDeviceID = NULL;
+ WCHAR* pDefaultDeviceID = NULL;
ma_EDataFlow dataFlow;
ma_ERole role;
@@ -20444,11 +21417,11 @@ static LPWSTR ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(
return pDefaultDeviceID;
}
-static LPWSTR ma_context_get_default_device_id__wasapi(ma_context* pContext, ma_device_type deviceType) /* Free the returned pointer with ma_CoTaskMemFree() */
+static WCHAR* ma_context_get_default_device_id__wasapi(ma_context* pContext, ma_device_type deviceType) /* Free the returned pointer with ma_CoTaskMemFree() */
{
ma_result result;
ma_IMMDeviceEnumerator* pDeviceEnumerator;
- LPWSTR pDefaultDeviceID = NULL;
+ WCHAR* pDefaultDeviceID = NULL;
MA_ASSERT(pContext != NULL);
@@ -20471,9 +21444,9 @@ static ma_result ma_context_get_MMDevice__wasapi(ma_context* pContext, ma_device
MA_ASSERT(pContext != NULL);
MA_ASSERT(ppMMDevice != NULL);
- hr = ma_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
+ hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
if (FAILED(hr)) {
- ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create IMMDeviceEnumerator.");
+ ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create IMMDeviceEnumerator.\n");
return ma_result_from_HRESULT(hr);
}
@@ -20485,7 +21458,7 @@ static ma_result ma_context_get_MMDevice__wasapi(ma_context* pContext, ma_device
ma_IMMDeviceEnumerator_Release(pDeviceEnumerator);
if (FAILED(hr)) {
- ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve IMMDevice.");
+ ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve IMMDevice.\n");
return ma_result_from_HRESULT(hr);
}
@@ -20494,14 +21467,14 @@ static ma_result ma_context_get_MMDevice__wasapi(ma_context* pContext, ma_device
static ma_result ma_context_get_device_id_from_MMDevice__wasapi(ma_context* pContext, ma_IMMDevice* pMMDevice, ma_device_id* pDeviceID)
{
- LPWSTR pDeviceIDString;
+ WCHAR* pDeviceIDString;
HRESULT hr;
MA_ASSERT(pDeviceID != NULL);
hr = ma_IMMDevice_GetId(pMMDevice, &pDeviceIDString);
if (SUCCEEDED(hr)) {
- size_t idlen = wcslen(pDeviceIDString);
+ size_t idlen = ma_strlen_WCHAR(pDeviceIDString);
if (idlen+1 > ma_countof(pDeviceID->wasapi)) {
ma_CoTaskMemFree(pContext, pDeviceIDString);
MA_ASSERT(MA_FALSE); /* NOTE: If this is triggered, please report it. It means the format of the ID must haved change and is too long to fit in our fixed sized buffer. */
@@ -20519,7 +21492,7 @@ static ma_result ma_context_get_device_id_from_MMDevice__wasapi(ma_context* pCon
return MA_ERROR;
}
-static ma_result ma_context_get_device_info_from_MMDevice__wasapi(ma_context* pContext, ma_IMMDevice* pMMDevice, LPWSTR pDefaultDeviceID, ma_bool32 onlySimpleInfo, ma_device_info* pInfo)
+static ma_result ma_context_get_device_info_from_MMDevice__wasapi(ma_context* pContext, ma_IMMDevice* pMMDevice, WCHAR* pDefaultDeviceID, ma_bool32 onlySimpleInfo, ma_device_info* pInfo)
{
ma_result result;
HRESULT hr;
@@ -20532,7 +21505,7 @@ static ma_result ma_context_get_device_info_from_MMDevice__wasapi(ma_context* pC
result = ma_context_get_device_id_from_MMDevice__wasapi(pContext, pMMDevice, &pInfo->id);
if (result == MA_SUCCESS) {
if (pDefaultDeviceID != NULL) {
- if (wcscmp(pInfo->id.wasapi, pDefaultDeviceID) == 0) {
+ if (ma_strcmp_WCHAR(pInfo->id.wasapi, pDefaultDeviceID) == 0) {
pInfo->isDefault = MA_TRUE;
}
}
@@ -20543,7 +21516,7 @@ static ma_result ma_context_get_device_info_from_MMDevice__wasapi(ma_context* pC
ma_IPropertyStore *pProperties;
hr = ma_IMMDevice_OpenPropertyStore(pMMDevice, STGM_READ, &pProperties);
if (SUCCEEDED(hr)) {
- PROPVARIANT var;
+ MA_PROPVARIANT var;
ma_PropVariantInit(&var);
hr = ma_IPropertyStore_GetValue(pProperties, &MA_PKEY_Device_FriendlyName, &var);
@@ -20580,7 +21553,7 @@ static ma_result ma_context_enumerate_devices_by_type__wasapi(ma_context* pConte
UINT deviceCount;
HRESULT hr;
ma_uint32 iDevice;
- LPWSTR pDefaultDeviceID = NULL;
+ WCHAR* pDefaultDeviceID = NULL;
ma_IMMDeviceCollection* pDeviceCollection = NULL;
MA_ASSERT(pContext != NULL);
@@ -20594,7 +21567,7 @@ static ma_result ma_context_enumerate_devices_by_type__wasapi(ma_context* pConte
if (SUCCEEDED(hr)) {
hr = ma_IMMDeviceCollection_GetCount(pDeviceCollection, &deviceCount);
if (FAILED(hr)) {
- ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to get device count.");
+ ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to get device count.\n");
result = ma_result_from_HRESULT(hr);
goto done;
}
@@ -20634,7 +21607,7 @@ done:
return result;
}
-static ma_result ma_context_get_IAudioClient_Desktop__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_IAudioClient** ppAudioClient, ma_IMMDevice** ppMMDevice)
+static ma_result ma_context_get_IAudioClient_Desktop__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, MA_PROPVARIANT* pActivationParams, ma_IAudioClient** ppAudioClient, ma_IMMDevice** ppMMDevice)
{
ma_result result;
HRESULT hr;
@@ -20648,7 +21621,7 @@ static ma_result ma_context_get_IAudioClient_Desktop__wasapi(ma_context* pContex
return result;
}
- hr = ma_IMMDevice_Activate(*ppMMDevice, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)ppAudioClient);
+ hr = ma_IMMDevice_Activate(*ppMMDevice, &MA_IID_IAudioClient, CLSCTX_ALL, pActivationParams, (void**)ppAudioClient);
if (FAILED(hr)) {
return ma_result_from_HRESULT(hr);
}
@@ -20656,12 +21629,12 @@ static ma_result ma_context_get_IAudioClient_Desktop__wasapi(ma_context* pContex
return MA_SUCCESS;
}
#else
-static ma_result ma_context_get_IAudioClient_UWP__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_IAudioClient** ppAudioClient, ma_IUnknown** ppActivatedInterface)
+static ma_result ma_context_get_IAudioClient_UWP__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, MA_PROPVARIANT* pActivationParams, ma_IAudioClient** ppAudioClient, ma_IUnknown** ppActivatedInterface)
{
ma_IActivateAudioInterfaceAsyncOperation *pAsyncOp = NULL;
ma_completion_handler_uwp completionHandler;
IID iid;
- LPOLESTR iidStr;
+ WCHAR* iidStr;
HRESULT hr;
ma_result result;
HRESULT activateResult;
@@ -20671,45 +21644,43 @@ static ma_result ma_context_get_IAudioClient_UWP__wasapi(ma_context* pContext, m
MA_ASSERT(ppAudioClient != NULL);
if (pDeviceID != NULL) {
- MA_COPY_MEMORY(&iid, pDeviceID->wasapi, sizeof(iid));
+ iidStr = (WCHAR*)pDeviceID->wasapi;
} else {
- if (deviceType == ma_device_type_playback) {
- iid = MA_IID_DEVINTERFACE_AUDIO_RENDER;
- } else {
+ if (deviceType == ma_device_type_capture) {
iid = MA_IID_DEVINTERFACE_AUDIO_CAPTURE;
+ } else {
+ iid = MA_IID_DEVINTERFACE_AUDIO_RENDER;
}
- }
-#if defined(__cplusplus)
- hr = StringFromIID(iid, &iidStr);
-#else
- hr = StringFromIID(&iid, &iidStr);
-#endif
- if (FAILED(hr)) {
- ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to convert device IID to string for ActivateAudioInterfaceAsync(). Out of memory.");
- return ma_result_from_HRESULT(hr);
+ #if defined(__cplusplus)
+ hr = StringFromIID(iid, &iidStr);
+ #else
+ hr = StringFromIID(&iid, &iidStr);
+ #endif
+ if (FAILED(hr)) {
+ ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to convert device IID to string for ActivateAudioInterfaceAsync(). Out of memory.\n");
+ return ma_result_from_HRESULT(hr);
+ }
}
result = ma_completion_handler_uwp_init(&completionHandler);
if (result != MA_SUCCESS) {
ma_CoTaskMemFree(pContext, iidStr);
- ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for waiting for ActivateAudioInterfaceAsync().");
+ ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for waiting for ActivateAudioInterfaceAsync().\n");
return result;
}
-#if defined(__cplusplus)
- hr = ActivateAudioInterfaceAsync(iidStr, MA_IID_IAudioClient, NULL, (IActivateAudioInterfaceCompletionHandler*)&completionHandler, (IActivateAudioInterfaceAsyncOperation**)&pAsyncOp);
-#else
- hr = ActivateAudioInterfaceAsync(iidStr, &MA_IID_IAudioClient, NULL, (IActivateAudioInterfaceCompletionHandler*)&completionHandler, (IActivateAudioInterfaceAsyncOperation**)&pAsyncOp);
-#endif
+ hr = ((MA_PFN_ActivateAudioInterfaceAsync)pContext->wasapi.ActivateAudioInterfaceAsync)(iidStr, &MA_IID_IAudioClient, pActivationParams, (ma_IActivateAudioInterfaceCompletionHandler*)&completionHandler, (ma_IActivateAudioInterfaceAsyncOperation**)&pAsyncOp);
if (FAILED(hr)) {
ma_completion_handler_uwp_uninit(&completionHandler);
ma_CoTaskMemFree(pContext, iidStr);
- ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] ActivateAudioInterfaceAsync() failed.");
+ ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] ActivateAudioInterfaceAsync() failed.\n");
return ma_result_from_HRESULT(hr);
}
- ma_CoTaskMemFree(pContext, iidStr);
+ if (pDeviceID == NULL) {
+ ma_CoTaskMemFree(pContext, iidStr);
+ }
/* Wait for the async operation for finish. */
ma_completion_handler_uwp_wait(&completionHandler);
@@ -20719,14 +21690,14 @@ static ma_result ma_context_get_IAudioClient_UWP__wasapi(ma_context* pContext, m
ma_IActivateAudioInterfaceAsyncOperation_Release(pAsyncOp);
if (FAILED(hr) || FAILED(activateResult)) {
- ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to activate device.");
+ ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to activate device.\n");
return FAILED(hr) ? ma_result_from_HRESULT(hr) : ma_result_from_HRESULT(activateResult);
}
/* Here is where we grab the IAudioClient interface. */
hr = ma_IUnknown_QueryInterface(pActivatedInterface, &MA_IID_IAudioClient, (void**)ppAudioClient);
if (FAILED(hr)) {
- ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to query IAudioClient interface.");
+ ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to query IAudioClient interface.\n");
return ma_result_from_HRESULT(hr);
}
@@ -20740,13 +21711,106 @@ static ma_result ma_context_get_IAudioClient_UWP__wasapi(ma_context* pContext, m
}
#endif
-static ma_result ma_context_get_IAudioClient__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_IAudioClient** ppAudioClient, ma_WASAPIDeviceInterface** ppDeviceInterface)
+
+/* https://docs.microsoft.com/en-us/windows/win32/api/audioclientactivationparams/ne-audioclientactivationparams-audioclient_activation_type */
+typedef enum
{
-#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)
- return ma_context_get_IAudioClient_Desktop__wasapi(pContext, deviceType, pDeviceID, ppAudioClient, ppDeviceInterface);
-#else
- return ma_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, ppAudioClient, ppDeviceInterface);
+ MA_AUDIOCLIENT_ACTIVATION_TYPE_DEFAULT,
+ MA_AUDIOCLIENT_ACTIVATION_TYPE_PROCESS_LOOPBACK
+} MA_AUDIOCLIENT_ACTIVATION_TYPE;
+
+/* https://docs.microsoft.com/en-us/windows/win32/api/audioclientactivationparams/ne-audioclientactivationparams-process_loopback_mode */
+typedef enum
+{
+ MA_PROCESS_LOOPBACK_MODE_INCLUDE_TARGET_PROCESS_TREE,
+ MA_PROCESS_LOOPBACK_MODE_EXCLUDE_TARGET_PROCESS_TREE
+} MA_PROCESS_LOOPBACK_MODE;
+
+/* https://docs.microsoft.com/en-us/windows/win32/api/audioclientactivationparams/ns-audioclientactivationparams-audioclient_process_loopback_params */
+typedef struct
+{
+ DWORD TargetProcessId;
+ MA_PROCESS_LOOPBACK_MODE ProcessLoopbackMode;
+} MA_AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS;
+
+#if defined(_MSC_VER) && !defined(__clang__)
+ #pragma warning(push)
+ #pragma warning(disable:4201) /* nonstandard extension used: nameless struct/union */
+#elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wpedantic" /* For ISO C99 doesn't support unnamed structs/unions [-Wpedantic] */
+ #if defined(__clang__)
+ #pragma GCC diagnostic ignored "-Wc11-extensions" /* anonymous unions are a C11 extension */
+ #endif
#endif
+/* https://docs.microsoft.com/en-us/windows/win32/api/audioclientactivationparams/ns-audioclientactivationparams-audioclient_activation_params */
+typedef struct
+{
+ MA_AUDIOCLIENT_ACTIVATION_TYPE ActivationType;
+ union
+ {
+ MA_AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS ProcessLoopbackParams;
+ };
+} MA_AUDIOCLIENT_ACTIVATION_PARAMS;
+#if defined(_MSC_VER) && !defined(__clang__)
+ #pragma warning(pop)
+#elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
+ #pragma GCC diagnostic pop
+#endif
+
+#define MA_VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK L"VAD\\Process_Loopback"
+
+static ma_result ma_context_get_IAudioClient__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_uint32 loopbackProcessID, ma_bool32 loopbackProcessExclude, ma_IAudioClient** ppAudioClient, ma_WASAPIDeviceInterface** ppDeviceInterface)
+{
+ ma_result result;
+ ma_bool32 usingProcessLoopback = MA_FALSE;
+ MA_AUDIOCLIENT_ACTIVATION_PARAMS audioclientActivationParams;
+ MA_PROPVARIANT activationParams;
+ MA_PROPVARIANT* pActivationParams = NULL;
+ ma_device_id virtualDeviceID;
+
+ /* Activation parameters specific to loopback mode. Note that process-specific loopback will only work when a default device ID is specified. */
+ if (deviceType == ma_device_type_loopback && loopbackProcessID != 0 && pDeviceID == NULL) {
+ usingProcessLoopback = MA_TRUE;
+ }
+
+ if (usingProcessLoopback) {
+ MA_ZERO_OBJECT(&audioclientActivationParams);
+ audioclientActivationParams.ActivationType = MA_AUDIOCLIENT_ACTIVATION_TYPE_PROCESS_LOOPBACK;
+ audioclientActivationParams.ProcessLoopbackParams.ProcessLoopbackMode = (loopbackProcessExclude) ? MA_PROCESS_LOOPBACK_MODE_EXCLUDE_TARGET_PROCESS_TREE : MA_PROCESS_LOOPBACK_MODE_INCLUDE_TARGET_PROCESS_TREE;
+ audioclientActivationParams.ProcessLoopbackParams.TargetProcessId = (DWORD)loopbackProcessID;
+
+ ma_PropVariantInit(&activationParams);
+ activationParams.vt = MA_VT_BLOB;
+ activationParams.blob.cbSize = sizeof(audioclientActivationParams);
+ activationParams.blob.pBlobData = (BYTE*)&audioclientActivationParams;
+ pActivationParams = &activationParams;
+
+ /* When requesting a specific device ID we need to use a special device ID. */
+ MA_COPY_MEMORY(virtualDeviceID.wasapi, MA_VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK, (wcslen(MA_VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK) + 1) * sizeof(wchar_t)); /* +1 for the null terminator. */
+ pDeviceID = &virtualDeviceID;
+ } else {
+ pActivationParams = NULL; /* No activation parameters required. */
+ }
+
+#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)
+ result = ma_context_get_IAudioClient_Desktop__wasapi(pContext, deviceType, pDeviceID, pActivationParams, ppAudioClient, ppDeviceInterface);
+#else
+ result = ma_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, pActivationParams, ppAudioClient, ppDeviceInterface);
+#endif
+
+ /*
+ If loopback mode was requested with a process ID and initialization failed, it could be because it's
+ trying to run on an older version of Windows where it's not supported. We need to let the caller
+ know about this with a log message.
+ */
+ if (result != MA_SUCCESS) {
+ if (usingProcessLoopback) {
+ ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Loopback mode requested to %s process ID %u, but initialization failed. Support for this feature begins with Windows 10 Build 20348. Confirm your version of Windows or consider not using process-specific loopback.\n", (loopbackProcessExclude) ? "exclude" : "include", loopbackProcessID);
+ }
+ }
+
+ return result;
}
@@ -20758,7 +21822,7 @@ static ma_result ma_context_enumerate_devices__wasapi(ma_context* pContext, ma_e
HRESULT hr;
ma_IMMDeviceEnumerator* pDeviceEnumerator;
- hr = ma_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
+ hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
if (FAILED(hr)) {
ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.");
return ma_result_from_HRESULT(hr);
@@ -20808,7 +21872,7 @@ static ma_result ma_context_get_device_info__wasapi(ma_context* pContext, ma_dev
#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)
ma_result result;
ma_IMMDevice* pMMDevice = NULL;
- LPWSTR pDefaultDeviceID = NULL;
+ WCHAR* pDefaultDeviceID = NULL;
result = ma_context_get_MMDevice__wasapi(pContext, deviceType, pDeviceID, &pMMDevice);
if (result != MA_SUCCESS) {
@@ -20839,7 +21903,7 @@ static ma_result ma_context_get_device_info__wasapi(ma_context* pContext, ma_dev
ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
}
- result = ma_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, &pAudioClient, NULL);
+ result = ma_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, NULL, &pAudioClient, NULL);
if (result != MA_SUCCESS) {
return result;
}
@@ -20893,10 +21957,10 @@ static ma_result ma_device_uninit__wasapi(ma_device* pDevice)
}
if (pDevice->wasapi.hEventPlayback) {
- CloseHandle(pDevice->wasapi.hEventPlayback);
+ CloseHandle((HANDLE)pDevice->wasapi.hEventPlayback);
}
if (pDevice->wasapi.hEventCapture) {
- CloseHandle(pDevice->wasapi.hEventCapture);
+ CloseHandle((HANDLE)pDevice->wasapi.hEventCapture);
}
return MA_SUCCESS;
@@ -20918,6 +21982,8 @@ typedef struct
ma_bool32 noAutoConvertSRC;
ma_bool32 noDefaultQualitySRC;
ma_bool32 noHardwareOffloading;
+ ma_uint32 loopbackProcessID;
+ ma_bool32 loopbackProcessExclude;
/* Output. */
ma_IAudioClient* pAudioClient;
@@ -20943,10 +22009,11 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
DWORD streamFlags = 0;
MA_REFERENCE_TIME periodDurationInMicroseconds;
ma_bool32 wasInitializedUsingIAudioClient3 = MA_FALSE;
- WAVEFORMATEXTENSIBLE wf;
+ MA_WAVEFORMATEXTENSIBLE wf;
ma_WASAPIDeviceInterface* pDeviceInterface = NULL;
ma_IAudioClient2* pAudioClient2;
ma_uint32 nativeSampleRate;
+ ma_bool32 usingProcessLoopback = MA_FALSE;
MA_ASSERT(pContext != NULL);
MA_ASSERT(pData != NULL);
@@ -20956,6 +22023,8 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
return MA_INVALID_ARGS;
}
+ usingProcessLoopback = deviceType == ma_device_type_loopback && pData->loopbackProcessID != 0 && pDeviceID == NULL;
+
pData->pAudioClient = NULL;
pData->pRenderClient = NULL;
pData->pCaptureClient = NULL;
@@ -20971,7 +22040,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
streamFlags |= MA_AUDCLNT_STREAMFLAGS_LOOPBACK;
}
- result = ma_context_get_IAudioClient__wasapi(pContext, deviceType, pDeviceID, &pData->pAudioClient, &pDeviceInterface);
+ result = ma_context_get_IAudioClient__wasapi(pContext, deviceType, pDeviceID, pData->loopbackProcessID, pData->loopbackProcessExclude, &pData->pAudioClient, &pDeviceInterface);
if (result != MA_SUCCESS) {
goto done;
}
@@ -21005,14 +22074,14 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
ma_IPropertyStore* pStore = NULL;
hr = ma_IMMDevice_OpenPropertyStore(pDeviceInterface, STGM_READ, &pStore);
if (SUCCEEDED(hr)) {
- PROPVARIANT prop;
+ MA_PROPVARIANT prop;
ma_PropVariantInit(&prop);
hr = ma_IPropertyStore_GetValue(pStore, &MA_PKEY_AudioEngine_DeviceFormat, &prop);
if (SUCCEEDED(hr)) {
- WAVEFORMATEX* pActualFormat = (WAVEFORMATEX*)prop.blob.pBlobData;
+ MA_WAVEFORMATEX* pActualFormat = (MA_WAVEFORMATEX*)prop.blob.pBlobData;
hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pData->pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, pActualFormat, NULL);
if (SUCCEEDED(hr)) {
- MA_COPY_MEMORY(&wf, pActualFormat, sizeof(WAVEFORMATEXTENSIBLE));
+ MA_COPY_MEMORY(&wf, pActualFormat, sizeof(MA_WAVEFORMATEXTENSIBLE));
}
ma_PropVariantClear(pContext, &prop);
@@ -21039,12 +22108,47 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
}
} else {
/* In shared mode we are always using the format reported by the operating system. */
- WAVEFORMATEXTENSIBLE* pNativeFormat = NULL;
- hr = ma_IAudioClient_GetMixFormat((ma_IAudioClient*)pData->pAudioClient, (WAVEFORMATEX**)&pNativeFormat);
+ MA_WAVEFORMATEXTENSIBLE* pNativeFormat = NULL;
+ hr = ma_IAudioClient_GetMixFormat((ma_IAudioClient*)pData->pAudioClient, (MA_WAVEFORMATEX**)&pNativeFormat);
if (hr != S_OK) {
- result = MA_FORMAT_NOT_SUPPORTED;
+ /* When using process-specific loopback, GetMixFormat() seems to always fail. */
+ if (usingProcessLoopback) {
+ wf.wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
+ wf.nChannels = 2;
+ wf.nSamplesPerSec = 44100;
+ wf.wBitsPerSample = 32;
+ wf.nBlockAlign = wf.nChannels * wf.wBitsPerSample / 8;
+ wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
+ wf.cbSize = sizeof(MA_WAVEFORMATEX);
+
+ result = MA_SUCCESS;
+ } else {
+ result = MA_FORMAT_NOT_SUPPORTED;
+ }
} else {
- MA_COPY_MEMORY(&wf, pNativeFormat, sizeof(wf));
+ /*
+ I've seen cases where cbSize will be set to sizeof(WAVEFORMATEX) even though the structure itself
+ is given the format tag of WAVE_FORMAT_EXTENSIBLE. If the format tag is WAVE_FORMAT_EXTENSIBLE
+ want to make sure we copy the whole WAVEFORMATEXTENSIBLE structure. Otherwise we'll have to be
+ safe and only copy the WAVEFORMATEX part.
+ */
+ if (pNativeFormat->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
+ MA_COPY_MEMORY(&wf, pNativeFormat, sizeof(MA_WAVEFORMATEXTENSIBLE));
+ } else {
+ /* I've seen a case where cbSize was set to 0. Assume sizeof(WAVEFORMATEX) in this case. */
+ size_t cbSize = pNativeFormat->cbSize;
+ if (cbSize == 0) {
+ cbSize = sizeof(MA_WAVEFORMATEX);
+ }
+
+ /* Make sure we don't copy more than the capacity of `wf`. */
+ if (cbSize > sizeof(wf)) {
+ cbSize = sizeof(wf);
+ }
+
+ MA_COPY_MEMORY(&wf, pNativeFormat, cbSize);
+ }
+
result = MA_SUCCESS;
}
@@ -21063,13 +22167,13 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
Override the native sample rate with the one requested by the caller, but only if we're not using the default sample rate. We'll use
WASAPI to perform the sample rate conversion.
*/
- nativeSampleRate = wf.Format.nSamplesPerSec;
+ nativeSampleRate = wf.nSamplesPerSec;
if (streamFlags & MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM) {
- wf.Format.nSamplesPerSec = (pData->sampleRateIn != 0) ? pData->sampleRateIn : MA_DEFAULT_SAMPLE_RATE;
- wf.Format.nAvgBytesPerSec = wf.Format.nSamplesPerSec * wf.Format.nBlockAlign;
+ wf.nSamplesPerSec = (pData->sampleRateIn != 0) ? pData->sampleRateIn : MA_DEFAULT_SAMPLE_RATE;
+ wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
}
- pData->formatOut = ma_format_from_WAVEFORMATEX((WAVEFORMATEX*)&wf);
+ pData->formatOut = ma_format_from_WAVEFORMATEX((MA_WAVEFORMATEX*)&wf);
if (pData->formatOut == ma_format_unknown) {
/*
The format isn't supported. This is almost certainly because the exclusive mode format isn't supported by miniaudio. We need to return MA_SHARE_MODE_NOT_SUPPORTED
@@ -21086,11 +22190,19 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
goto done;
}
- pData->channelsOut = wf.Format.nChannels;
- pData->sampleRateOut = wf.Format.nSamplesPerSec;
+ pData->channelsOut = wf.nChannels;
+ pData->sampleRateOut = wf.nSamplesPerSec;
- /* Get the internal channel map based on the channel mask. */
- ma_channel_mask_to_channel_map__win32(wf.dwChannelMask, pData->channelsOut, pData->channelMapOut);
+ /*
+ Get the internal channel map based on the channel mask. There is a possibility that GetMixFormat() returns
+ a WAVEFORMATEX instead of a WAVEFORMATEXTENSIBLE, in which case the channel mask will be undefined. In this
+ case we'll just use the default channel map.
+ */
+ if (wf.wFormatTag == WAVE_FORMAT_EXTENSIBLE || wf.cbSize >= sizeof(MA_WAVEFORMATEXTENSIBLE)) {
+ ma_channel_mask_to_channel_map__win32(wf.dwChannelMask, pData->channelsOut, pData->channelMapOut);
+ } else {
+ ma_channel_map_init_standard(ma_standard_channel_map_microsoft, pData->channelMapOut, ma_countof(pData->channelMapOut), pData->channelsOut);
+ }
/* Period size. */
pData->periodsOut = (pData->periodsIn != 0) ? pData->periodsIn : MA_DEFAULT_PERIODS;
@@ -21098,16 +22210,16 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
if (pData->periodSizeInFramesOut == 0) {
if (pData->periodSizeInMillisecondsIn == 0) {
if (pData->performanceProfile == ma_performance_profile_low_latency) {
- pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY, wf.Format.nSamplesPerSec);
+ pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY, wf.nSamplesPerSec);
} else {
- pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE, wf.Format.nSamplesPerSec);
+ pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE, wf.nSamplesPerSec);
}
} else {
- pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(pData->periodSizeInMillisecondsIn, wf.Format.nSamplesPerSec);
+ pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(pData->periodSizeInMillisecondsIn, wf.nSamplesPerSec);
}
}
- periodDurationInMicroseconds = ((ma_uint64)pData->periodSizeInFramesOut * 1000 * 1000) / wf.Format.nSamplesPerSec;
+ periodDurationInMicroseconds = ((ma_uint64)pData->periodSizeInFramesOut * 1000 * 1000) / wf.nSamplesPerSec;
/* Slightly different initialization for shared and exclusive modes. We try exclusive mode first, and if it fails, fall back to shared mode. */
@@ -21120,7 +22232,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
*/
hr = E_FAIL;
for (;;) {
- hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (WAVEFORMATEX*)&wf, NULL);
+ hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (MA_WAVEFORMATEX*)&wf, NULL);
if (hr == MA_AUDCLNT_E_INVALID_DEVICE_PERIOD) {
if (bufferDuration > 500*10000) {
break;
@@ -21141,7 +22253,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
ma_uint32 bufferSizeInFrames;
hr = ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pData->pAudioClient, &bufferSizeInFrames);
if (SUCCEEDED(hr)) {
- bufferDuration = (MA_REFERENCE_TIME)((10000.0 * 1000 / wf.Format.nSamplesPerSec * bufferSizeInFrames) + 0.5);
+ bufferDuration = (MA_REFERENCE_TIME)((10000.0 * 1000 / wf.nSamplesPerSec * bufferSizeInFrames) + 0.5);
/* Unfortunately we need to release and re-acquire the audio client according to MSDN. Seems silly - why not just call IAudioClient_Initialize() again?! */
ma_IAudioClient_Release((ma_IAudioClient*)pData->pAudioClient);
@@ -21153,7 +22265,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
#endif
if (SUCCEEDED(hr)) {
- hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (WAVEFORMATEX*)&wf, NULL);
+ hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (MA_WAVEFORMATEX*)&wf, NULL);
}
}
}
@@ -21184,7 +22296,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
*/
#ifndef MA_WASAPI_NO_LOW_LATENCY_SHARED_MODE
{
- if ((streamFlags & MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM) == 0 || nativeSampleRate == wf.Format.nSamplesPerSec) {
+ if ((streamFlags & MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM) == 0 || nativeSampleRate == wf.nSamplesPerSec) {
ma_IAudioClient3* pAudioClient3 = NULL;
hr = ma_IAudioClient_QueryInterface(pData->pAudioClient, &MA_IID_IAudioClient3, (void**)&pAudioClient3);
if (SUCCEEDED(hr)) {
@@ -21192,7 +22304,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
ma_uint32 fundamentalPeriodInFrames;
ma_uint32 minPeriodInFrames;
ma_uint32 maxPeriodInFrames;
- hr = ma_IAudioClient3_GetSharedModeEnginePeriod(pAudioClient3, (WAVEFORMATEX*)&wf, &defaultPeriodInFrames, &fundamentalPeriodInFrames, &minPeriodInFrames, &maxPeriodInFrames);
+ hr = ma_IAudioClient3_GetSharedModeEnginePeriod(pAudioClient3, (MA_WAVEFORMATEX*)&wf, &defaultPeriodInFrames, &fundamentalPeriodInFrames, &minPeriodInFrames, &maxPeriodInFrames);
if (SUCCEEDED(hr)) {
ma_uint32 desiredPeriodInFrames = pData->periodSizeInFramesOut;
ma_uint32 actualPeriodInFrames = desiredPeriodInFrames;
@@ -21216,7 +22328,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY must not be in the stream flags. If either of these are specified,
IAudioClient3_InitializeSharedAudioStream() will fail.
*/
- hr = ma_IAudioClient3_InitializeSharedAudioStream(pAudioClient3, streamFlags & ~(MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY), actualPeriodInFrames, (WAVEFORMATEX*)&wf, NULL);
+ hr = ma_IAudioClient3_InitializeSharedAudioStream(pAudioClient3, streamFlags & ~(MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY), actualPeriodInFrames, (MA_WAVEFORMATEX*)&wf, NULL);
if (SUCCEEDED(hr)) {
wasInitializedUsingIAudioClient3 = MA_TRUE;
pData->periodSizeInFramesOut = actualPeriodInFrames;
@@ -21247,7 +22359,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
/* If we don't have an IAudioClient3 then we need to use the normal initialization routine. */
if (!wasInitializedUsingIAudioClient3) {
MA_REFERENCE_TIME bufferDuration = periodDurationInMicroseconds * pData->periodsOut * 10; /* <-- Multiply by 10 for microseconds to 100-nanoseconds. */
- hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, 0, (WAVEFORMATEX*)&wf, NULL);
+ hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, 0, (const MA_WAVEFORMATEX*)&wf, NULL);
if (FAILED(hr)) {
if (hr == E_ACCESSDENIED) {
errorMsg = "[WASAPI] Failed to initialize device. Access denied.", result = MA_ACCESS_DENIED;
@@ -21263,13 +22375,22 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
}
if (!wasInitializedUsingIAudioClient3) {
- ma_uint32 bufferSizeInFrames;
+ ma_uint32 bufferSizeInFrames = 0;
hr = ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pData->pAudioClient, &bufferSizeInFrames);
if (FAILED(hr)) {
errorMsg = "[WASAPI] Failed to get audio client's actual buffer size.", result = ma_result_from_HRESULT(hr);
goto done;
}
+ /*
+ When using process loopback mode, retrieval of the buffer size seems to result in totally
+ incorrect values. In this case we'll just assume it's the same size as what we requested
+ when we initialized the client.
+ */
+ if (usingProcessLoopback) {
+ bufferSizeInFrames = (ma_uint32)((periodDurationInMicroseconds * pData->periodsOut) * pData->sampleRateOut / 1000000);
+ }
+
pData->periodSizeInFramesOut = bufferSizeInFrames / pData->periodsOut;
}
@@ -21295,7 +22416,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
ma_IPropertyStore *pProperties;
hr = ma_IMMDevice_OpenPropertyStore(pDeviceInterface, STGM_READ, &pProperties);
if (SUCCEEDED(hr)) {
- PROPVARIANT varName;
+ MA_PROPVARIANT varName;
ma_PropVariantInit(&varName);
hr = ma_IPropertyStore_GetValue(pProperties, &MA_PKEY_Device_FriendlyName, &varName);
if (SUCCEEDED(hr)) {
@@ -21352,7 +22473,7 @@ done:
}
if (errorMsg != NULL && errorMsg[0] != '\0') {
- ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "%s", errorMsg);
+ ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "%s\n", errorMsg);
}
return result;
@@ -21429,6 +22550,8 @@ static ma_result ma_device_reinit__wasapi(ma_device* pDevice, ma_device_type dev
data.noAutoConvertSRC = pDevice->wasapi.noAutoConvertSRC;
data.noDefaultQualitySRC = pDevice->wasapi.noDefaultQualitySRC;
data.noHardwareOffloading = pDevice->wasapi.noHardwareOffloading;
+ data.loopbackProcessID = pDevice->wasapi.loopbackProcessID;
+ data.loopbackProcessExclude = pDevice->wasapi.loopbackProcessExclude;
result = ma_device_init_internal__wasapi(pDevice->pContext, deviceType, NULL, &data);
if (result != MA_SUCCESS) {
return result;
@@ -21447,13 +22570,13 @@ static ma_result ma_device_reinit__wasapi(ma_device* pDevice, ma_device_type dev
pDevice->capture.internalPeriods = data.periodsOut;
ma_strcpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), data.deviceName);
- ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, pDevice->wasapi.hEventCapture);
+ ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, (HANDLE)pDevice->wasapi.hEventCapture);
pDevice->wasapi.periodSizeInFramesCapture = data.periodSizeInFramesOut;
ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &pDevice->wasapi.actualBufferSizeInFramesCapture);
/* We must always have a valid ID. */
- ma_wcscpy_s(pDevice->capture.id.wasapi, sizeof(pDevice->capture.id.wasapi), data.id.wasapi);
+ ma_strcpy_s_WCHAR(pDevice->capture.id.wasapi, sizeof(pDevice->capture.id.wasapi), data.id.wasapi);
}
if (deviceType == ma_device_type_playback) {
@@ -21468,13 +22591,13 @@ static ma_result ma_device_reinit__wasapi(ma_device* pDevice, ma_device_type dev
pDevice->playback.internalPeriods = data.periodsOut;
ma_strcpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), data.deviceName);
- ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, pDevice->wasapi.hEventPlayback);
+ ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, (HANDLE)pDevice->wasapi.hEventPlayback);
pDevice->wasapi.periodSizeInFramesPlayback = data.periodSizeInFramesOut;
ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &pDevice->wasapi.actualBufferSizeInFramesPlayback);
/* We must always have a valid ID because rerouting will look at it. */
- ma_wcscpy_s(pDevice->playback.id.wasapi, sizeof(pDevice->playback.id.wasapi), data.id.wasapi);
+ ma_strcpy_s_WCHAR(pDevice->playback.id.wasapi, sizeof(pDevice->playback.id.wasapi), data.id.wasapi);
}
return MA_SUCCESS;
@@ -21492,9 +22615,12 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf
MA_ASSERT(pDevice != NULL);
MA_ZERO_OBJECT(&pDevice->wasapi);
- pDevice->wasapi.noAutoConvertSRC = pConfig->wasapi.noAutoConvertSRC;
- pDevice->wasapi.noDefaultQualitySRC = pConfig->wasapi.noDefaultQualitySRC;
- pDevice->wasapi.noHardwareOffloading = pConfig->wasapi.noHardwareOffloading;
+ pDevice->wasapi.usage = pConfig->wasapi.usage;
+ pDevice->wasapi.noAutoConvertSRC = pConfig->wasapi.noAutoConvertSRC;
+ pDevice->wasapi.noDefaultQualitySRC = pConfig->wasapi.noDefaultQualitySRC;
+ pDevice->wasapi.noHardwareOffloading = pConfig->wasapi.noHardwareOffloading;
+ pDevice->wasapi.loopbackProcessID = pConfig->wasapi.loopbackProcessID;
+ pDevice->wasapi.loopbackProcessExclude = pConfig->wasapi.loopbackProcessExclude;
/* Exclusive mode is not allowed with loopback. */
if (pConfig->deviceType == ma_device_type_loopback && pConfig->playback.shareMode == ma_share_mode_exclusive) {
@@ -21515,6 +22641,8 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf
data.noAutoConvertSRC = pConfig->wasapi.noAutoConvertSRC;
data.noDefaultQualitySRC = pConfig->wasapi.noDefaultQualitySRC;
data.noHardwareOffloading = pConfig->wasapi.noHardwareOffloading;
+ data.loopbackProcessID = pConfig->wasapi.loopbackProcessID;
+ data.loopbackProcessExclude = pConfig->wasapi.loopbackProcessExclude;
result = ma_device_init_internal__wasapi(pDevice->pContext, (pConfig->deviceType == ma_device_type_loopback) ? ma_device_type_loopback : ma_device_type_capture, pDescriptorCapture->pDeviceID, &data);
if (result != MA_SUCCESS) {
@@ -21532,7 +22660,7 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf
The event for capture needs to be manual reset for the same reason as playback. We keep the initial state set to unsignaled,
however, because we want to block until we actually have something for the first call to ma_device_read().
*/
- pDevice->wasapi.hEventCapture = CreateEventW(NULL, FALSE, FALSE, NULL); /* Auto reset, unsignaled by default. */
+ pDevice->wasapi.hEventCapture = (ma_handle)CreateEventA(NULL, FALSE, FALSE, NULL); /* Auto reset, unsignaled by default. */
if (pDevice->wasapi.hEventCapture == NULL) {
result = ma_result_from_GetLastError(GetLastError());
@@ -21548,13 +22676,13 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for capture.");
return result;
}
- ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, pDevice->wasapi.hEventCapture);
+ ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, (HANDLE)pDevice->wasapi.hEventCapture);
pDevice->wasapi.periodSizeInFramesCapture = data.periodSizeInFramesOut;
ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &pDevice->wasapi.actualBufferSizeInFramesCapture);
/* We must always have a valid ID. */
- ma_wcscpy_s(pDevice->capture.id.wasapi, sizeof(pDevice->capture.id.wasapi), data.id.wasapi);
+ ma_strcpy_s_WCHAR(pDevice->capture.id.wasapi, sizeof(pDevice->capture.id.wasapi), data.id.wasapi);
/* The descriptor needs to be updated with actual values. */
pDescriptorCapture->format = data.formatOut;
@@ -21579,6 +22707,8 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf
data.noAutoConvertSRC = pConfig->wasapi.noAutoConvertSRC;
data.noDefaultQualitySRC = pConfig->wasapi.noDefaultQualitySRC;
data.noHardwareOffloading = pConfig->wasapi.noHardwareOffloading;
+ data.loopbackProcessID = pConfig->wasapi.loopbackProcessID;
+ data.loopbackProcessExclude = pConfig->wasapi.loopbackProcessExclude;
result = ma_device_init_internal__wasapi(pDevice->pContext, ma_device_type_playback, pDescriptorPlayback->pDeviceID, &data);
if (result != MA_SUCCESS) {
@@ -21592,7 +22722,7 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf
pDevice->wasapi.pAudioClientCapture = NULL;
}
- CloseHandle(pDevice->wasapi.hEventCapture);
+ CloseHandle((HANDLE)pDevice->wasapi.hEventCapture);
pDevice->wasapi.hEventCapture = NULL;
}
return result;
@@ -21612,7 +22742,7 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf
The playback event also needs to be initially set to a signaled state so that the first call to ma_device_write() is able
to get passed WaitForMultipleObjects().
*/
- pDevice->wasapi.hEventPlayback = CreateEventW(NULL, FALSE, TRUE, NULL); /* Auto reset, signaled by default. */
+ pDevice->wasapi.hEventPlayback = (ma_handle)CreateEventA(NULL, FALSE, TRUE, NULL); /* Auto reset, signaled by default. */
if (pDevice->wasapi.hEventPlayback == NULL) {
result = ma_result_from_GetLastError(GetLastError());
@@ -21626,7 +22756,7 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf
pDevice->wasapi.pAudioClientCapture = NULL;
}
- CloseHandle(pDevice->wasapi.hEventCapture);
+ CloseHandle((HANDLE)pDevice->wasapi.hEventCapture);
pDevice->wasapi.hEventCapture = NULL;
}
@@ -21642,13 +22772,13 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for playback.");
return result;
}
- ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, pDevice->wasapi.hEventPlayback);
+ ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, (HANDLE)pDevice->wasapi.hEventPlayback);
pDevice->wasapi.periodSizeInFramesPlayback = data.periodSizeInFramesOut;
ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &pDevice->wasapi.actualBufferSizeInFramesPlayback);
/* We must always have a valid ID because rerouting will look at it. */
- ma_wcscpy_s(pDevice->playback.id.wasapi, sizeof(pDevice->playback.id.wasapi), data.id.wasapi);
+ ma_strcpy_s_WCHAR(pDevice->playback.id.wasapi, sizeof(pDevice->playback.id.wasapi), data.id.wasapi);
/* The descriptor needs to be updated with actual values. */
pDescriptorPlayback->format = data.formatOut;
@@ -21666,7 +22796,7 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf
*/
#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)
if (pConfig->wasapi.noAutoStreamRouting == MA_FALSE) {
- if ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) && pConfig->capture.pDeviceID == NULL) {
+ if ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) && pConfig->capture.pDeviceID == NULL) {
pDevice->wasapi.allowCaptureAutoStreamRouting = MA_TRUE;
}
if ((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pConfig->playback.pDeviceID == NULL) {
@@ -21674,7 +22804,9 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf
}
}
- hr = ma_CoCreateInstance(pDevice->pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
+ ma_mutex_init(&pDevice->wasapi.rerouteLock);
+
+ hr = ma_CoCreateInstance(pDevice->pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
if (FAILED(hr)) {
ma_device_uninit__wasapi(pDevice);
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.");
@@ -21694,8 +22826,8 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf
}
#endif
- c89atomic_exchange_32(&pDevice->wasapi.isStartedCapture, MA_FALSE);
- c89atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_FALSE);
+ ma_atomic_bool32_set(&pDevice->wasapi.isStartedCapture, MA_FALSE);
+ ma_atomic_bool32_set(&pDevice->wasapi.isStartedPlayback, MA_FALSE);
return MA_SUCCESS;
}
@@ -21773,48 +22905,76 @@ static ma_result ma_device_reroute__wasapi(ma_device* pDevice, ma_device_type de
}
ma_device__post_init_setup(pDevice, deviceType);
-
ma_device__on_notification_rerouted(pDevice);
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "=== DEVICE CHANGED ===\n");
+
+ return MA_SUCCESS;
+}
+
+static ma_result ma_device_start__wasapi_nolock(ma_device* pDevice)
+{
+ HRESULT hr;
+
+ if (pDevice->pContext->wasapi.hAvrt) {
+ const char* pTaskName = ma_to_usage_string__wasapi(pDevice->wasapi.usage);
+ if (pTaskName) {
+ DWORD idx = 0;
+ pDevice->wasapi.hAvrtHandle = (ma_handle)((MA_PFN_AvSetMmThreadCharacteristicsA)pDevice->pContext->wasapi.AvSetMmThreadCharacteristicsA)(pTaskName, &idx);
+ }
+ }
+
+ if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
+ hr = ma_IAudioClient_Start((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
+ if (FAILED(hr)) {
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal capture device. HRESULT = %d.", (int)hr);
+ return ma_result_from_HRESULT(hr);
+ }
+
+ ma_atomic_bool32_set(&pDevice->wasapi.isStartedCapture, MA_TRUE);
+ }
+
+ if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
+ hr = ma_IAudioClient_Start((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
+ if (FAILED(hr)) {
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device. HRESULT = %d.", (int)hr);
+ return ma_result_from_HRESULT(hr);
+ }
+
+ ma_atomic_bool32_set(&pDevice->wasapi.isStartedPlayback, MA_TRUE);
+ }
+
return MA_SUCCESS;
}
static ma_result ma_device_start__wasapi(ma_device* pDevice)
{
- HRESULT hr;
+ ma_result result;
MA_ASSERT(pDevice != NULL);
- if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
- hr = ma_IAudioClient_Start((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
- if (FAILED(hr)) {
- ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal capture device.");
- return ma_result_from_HRESULT(hr);
- }
-
- c89atomic_exchange_32(&pDevice->wasapi.isStartedCapture, MA_TRUE);
+ /* Wait for any rerouting to finish before attempting to start the device. */
+ ma_mutex_lock(&pDevice->wasapi.rerouteLock);
+ {
+ result = ma_device_start__wasapi_nolock(pDevice);
}
+ ma_mutex_unlock(&pDevice->wasapi.rerouteLock);
- if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
- hr = ma_IAudioClient_Start((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
- if (FAILED(hr)) {
- ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device.");
- return ma_result_from_HRESULT(hr);
- }
-
- c89atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_TRUE);
- }
-
- return MA_SUCCESS;
+ return result;
}
-static ma_result ma_device_stop__wasapi(ma_device* pDevice)
+static ma_result ma_device_stop__wasapi_nolock(ma_device* pDevice)
{
ma_result result;
HRESULT hr;
MA_ASSERT(pDevice != NULL);
+ if (pDevice->wasapi.hAvrtHandle) {
+ ((MA_PFN_AvRevertMmThreadCharacteristics)pDevice->pContext->wasapi.AvRevertMmThreadcharacteristics)((HANDLE)pDevice->wasapi.hAvrtHandle);
+ pDevice->wasapi.hAvrtHandle = NULL;
+ }
+
if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
hr = ma_IAudioClient_Stop((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
if (FAILED(hr)) {
@@ -21832,12 +22992,12 @@ static ma_result ma_device_stop__wasapi(ma_device* pDevice)
/* If we have a mapped buffer we need to release it. */
if (pDevice->wasapi.pMappedBufferCapture != NULL) {
ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, pDevice->wasapi.mappedBufferCaptureCap);
- pDevice->wasapi.pMappedBufferCapture = NULL;
+ pDevice->wasapi.pMappedBufferCapture = NULL;
pDevice->wasapi.mappedBufferCaptureCap = 0;
pDevice->wasapi.mappedBufferCaptureLen = 0;
}
- c89atomic_exchange_32(&pDevice->wasapi.isStartedCapture, MA_FALSE);
+ ma_atomic_bool32_set(&pDevice->wasapi.isStartedCapture, MA_FALSE);
}
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
@@ -21845,13 +23005,14 @@ static ma_result ma_device_stop__wasapi(ma_device* pDevice)
The buffer needs to be drained before stopping the device. Not doing this will result in the last few frames not getting output to
the speakers. This is a problem for very short sounds because it'll result in a significant portion of it not getting played.
*/
- if (c89atomic_load_32(&pDevice->wasapi.isStartedPlayback)) {
+ if (ma_atomic_bool32_get(&pDevice->wasapi.isStartedPlayback)) {
/* We need to make sure we put a timeout here or else we'll risk getting stuck in a deadlock in some cases. */
DWORD waitTime = pDevice->wasapi.actualBufferSizeInFramesPlayback / pDevice->playback.internalSampleRate;
if (pDevice->playback.shareMode == ma_share_mode_exclusive) {
- WaitForSingleObject(pDevice->wasapi.hEventPlayback, waitTime);
- } else {
+ WaitForSingleObject((HANDLE)pDevice->wasapi.hEventPlayback, waitTime);
+ }
+ else {
ma_uint32 prevFramesAvaialablePlayback = (ma_uint32)-1;
ma_uint32 framesAvailablePlayback;
for (;;) {
@@ -21873,8 +23034,8 @@ static ma_result ma_device_stop__wasapi(ma_device* pDevice)
}
prevFramesAvaialablePlayback = framesAvailablePlayback;
- WaitForSingleObject(pDevice->wasapi.hEventPlayback, waitTime);
- ResetEvent(pDevice->wasapi.hEventPlayback); /* Manual reset. */
+ WaitForSingleObject((HANDLE)pDevice->wasapi.hEventPlayback, waitTime * 1000);
+ ResetEvent((HANDLE)pDevice->wasapi.hEventPlayback); /* Manual reset. */
}
}
}
@@ -21894,17 +23055,33 @@ static ma_result ma_device_stop__wasapi(ma_device* pDevice)
if (pDevice->wasapi.pMappedBufferPlayback != NULL) {
ma_IAudioRenderClient_ReleaseBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, pDevice->wasapi.mappedBufferPlaybackCap, 0);
- pDevice->wasapi.pMappedBufferPlayback = NULL;
+ pDevice->wasapi.pMappedBufferPlayback = NULL;
pDevice->wasapi.mappedBufferPlaybackCap = 0;
pDevice->wasapi.mappedBufferPlaybackLen = 0;
}
- c89atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_FALSE);
+ ma_atomic_bool32_set(&pDevice->wasapi.isStartedPlayback, MA_FALSE);
}
return MA_SUCCESS;
}
+static ma_result ma_device_stop__wasapi(ma_device* pDevice)
+{
+ ma_result result;
+
+ MA_ASSERT(pDevice != NULL);
+
+ /* Wait for any rerouting to finish before attempting to stop the device. */
+ ma_mutex_lock(&pDevice->wasapi.rerouteLock);
+ {
+ result = ma_device_stop__wasapi_nolock(pDevice);
+ }
+ ma_mutex_unlock(&pDevice->wasapi.rerouteLock);
+
+ return result;
+}
+
#ifndef MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS
#define MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS 5000
@@ -21953,50 +23130,100 @@ static ma_result ma_device_read__wasapi(ma_device* pDevice, void* pFrames, ma_ui
} else {
/* We don't have any cached data pointer, so grab another one. */
HRESULT hr;
- DWORD flags;
+ DWORD flags = 0;
/* First just ask WASAPI for a data buffer. If it's not available, we'll wait for more. */
hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pDevice->wasapi.pMappedBufferCapture, &pDevice->wasapi.mappedBufferCaptureCap, &flags, NULL, NULL);
if (hr == S_OK) {
/* We got a data buffer. Continue to the next loop iteration which will then read from the mapped pointer. */
+ pDevice->wasapi.mappedBufferCaptureLen = pDevice->wasapi.mappedBufferCaptureCap;
+
+ /*
+ There have been reports that indicate that at times the AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY is reported for every
+ call to IAudioCaptureClient_GetBuffer() above which results in spamming of the debug messages below. To partially
+ work around this, I'm only outputting these messages when MA_DEBUG_OUTPUT is explicitly defined. The better solution
+ would be to figure out why the flag is always getting reported.
+ */
+ #if defined(MA_DEBUG_OUTPUT)
+ {
+ if (flags != 0) {
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Capture Flags: %ld\n", flags);
+
+ if ((flags & MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) != 0) {
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Data discontinuity (possible overrun). Attempting recovery. mappedBufferCaptureCap=%d\n", pDevice->wasapi.mappedBufferCaptureCap);
+ }
+ }
+ }
+ #endif
/* Overrun detection. */
if ((flags & MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) != 0) {
/* Glitched. Probably due to an overrun. */
- ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Data discontinuity (possible overrun). Attempting recovery. mappedBufferCaptureCap=%d\n", pDevice->wasapi.mappedBufferCaptureCap);
/*
- If we got an overrun it probably means we're straddling the end of the buffer. In order to prevent
- a never-ending sequence of glitches we're going to recover by completely clearing out the capture
- buffer.
+ If we got an overrun it probably means we're straddling the end of the buffer. In normal capture
+ mode this is the fault of the client application because they're responsible for ensuring data is
+ processed fast enough. In duplex mode, however, the processing of audio is tied to the playback
+ device, so this can possibly be the result of a timing de-sync.
+
+ In capture mode we're not going to do any kind of recovery because the real fix is for the client
+ application to process faster. In duplex mode, we'll treat this as a desync and reset the buffers
+ to prevent a never-ending sequence of glitches due to straddling the end of the buffer.
*/
- {
- ma_uint32 iterationCount = 4; /* Safety to prevent an infinite loop. */
+ if (pDevice->type == ma_device_type_duplex) {
+ /*
+ Experiment:
+
+ If we empty out the *entire* buffer we may end up putting ourselves into an underrun position
+ which isn't really any better than the overrun we're probably in right now. Instead we'll just
+ empty out about half.
+ */
ma_uint32 i;
+ ma_uint32 periodCount = (pDevice->wasapi.actualBufferSizeInFramesCapture / pDevice->wasapi.periodSizeInFramesCapture);
+ ma_uint32 iterationCount = periodCount / 2;
+ if ((periodCount % 2) > 0) {
+ iterationCount += 1;
+ }
for (i = 0; i < iterationCount; i += 1) {
hr = ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, pDevice->wasapi.mappedBufferCaptureCap);
if (FAILED(hr)) {
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Data discontinuity recovery: IAudioCaptureClient_ReleaseBuffer() failed with %ld.\n", hr);
break;
}
+ flags = 0;
hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pDevice->wasapi.pMappedBufferCapture, &pDevice->wasapi.mappedBufferCaptureCap, &flags, NULL, NULL);
if (hr == MA_AUDCLNT_S_BUFFER_EMPTY || FAILED(hr)) {
+ /*
+ The buffer has been completely emptied or an error occurred. In this case we'll need
+ to reset the state of the mapped buffer which will trigger the next iteration to get
+ a fresh buffer from WASAPI.
+ */
+ pDevice->wasapi.pMappedBufferCapture = NULL;
+ pDevice->wasapi.mappedBufferCaptureCap = 0;
+ pDevice->wasapi.mappedBufferCaptureLen = 0;
+
+ if (hr == MA_AUDCLNT_S_BUFFER_EMPTY) {
+ if ((flags & MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) != 0) {
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Data discontinuity recovery: Buffer emptied, and data discontinuity still reported.\n");
+ } else {
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Data discontinuity recovery: Buffer emptied.\n");
+ }
+ }
+
+ if (FAILED(hr)) {
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Data discontinuity recovery: IAudioCaptureClient_GetBuffer() failed with %ld.\n", hr);
+ }
+
break;
}
}
- }
- /* We should not have a valid buffer at this point so make sure everything is empty. */
- pDevice->wasapi.pMappedBufferCapture = NULL;
- pDevice->wasapi.mappedBufferCaptureCap = 0;
- pDevice->wasapi.mappedBufferCaptureLen = 0;
- } else {
- /* The data is clean. */
- pDevice->wasapi.mappedBufferCaptureLen = pDevice->wasapi.mappedBufferCaptureCap;
-
- if (flags != 0) {
- ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[WASAPI] Capture Flags: %ld\n", flags);
+ /* If at this point we have a valid buffer mapped, make sure the buffer length is set appropriately. */
+ if (pDevice->wasapi.pMappedBufferCapture != NULL) {
+ pDevice->wasapi.mappedBufferCaptureLen = pDevice->wasapi.mappedBufferCaptureCap;
+ }
}
}
@@ -22009,9 +23236,16 @@ static ma_result ma_device_read__wasapi(ma_device* pDevice, void* pFrames, ma_ui
microphone isn't delivering data for whatever reason. In this case we'll just
abort the read and return whatever we were able to get. The other situations is
loopback mode, in which case a timeout probably just means the nothing is playing
- through the speakers.
+ through the speakers.
*/
- if (WaitForSingleObject(pDevice->wasapi.hEventCapture, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
+
+ /* Experiment: Use a shorter timeout for loopback mode. */
+ DWORD timeoutInMilliseconds = MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS;
+ if (pDevice->type == ma_device_type_loopback) {
+ timeoutInMilliseconds = 10;
+ }
+
+ if (WaitForSingleObject((HANDLE)pDevice->wasapi.hEventCapture, timeoutInMilliseconds) != WAIT_OBJECT_0) {
if (pDevice->type == ma_device_type_loopback) {
continue; /* Keep waiting in loopback mode. */
} else {
@@ -22096,7 +23330,7 @@ static ma_result ma_device_write__wasapi(ma_device* pDevice, const void* pFrames
whether or not we need to wait for more data.
*/
if (pDevice->playback.shareMode == ma_share_mode_exclusive) {
- if (WaitForSingleObject(pDevice->wasapi.hEventPlayback, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
+ if (WaitForSingleObject((HANDLE)pDevice->wasapi.hEventPlayback, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
result = MA_ERROR;
break; /* Wait failed. Probably timed out. */
}
@@ -22122,7 +23356,7 @@ static ma_result ma_device_write__wasapi(ma_device* pDevice, const void* pFrames
} else {
if (hr == MA_AUDCLNT_E_BUFFER_TOO_LARGE || hr == MA_AUDCLNT_E_BUFFER_ERROR) {
/* Not enough data available. We need to wait for more. */
- if (WaitForSingleObject(pDevice->wasapi.hEventPlayback, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
+ if (WaitForSingleObject((HANDLE)pDevice->wasapi.hEventPlayback, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
result = MA_ERROR;
break; /* Wait failed. Probably timed out. */
}
@@ -22161,19 +23395,32 @@ static ma_result ma_device_data_loop_wakeup__wasapi(ma_device* pDevice)
static ma_result ma_context_uninit__wasapi(ma_context* pContext)
{
+ ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_QUIT__WASAPI);
+
MA_ASSERT(pContext != NULL);
MA_ASSERT(pContext->backend == ma_backend_wasapi);
- if (pContext->wasapi.commandThread != NULL) {
- ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_QUIT__WASAPI);
- ma_context_post_command__wasapi(pContext, &cmd);
- ma_thread_wait(&pContext->wasapi.commandThread);
+ ma_context_post_command__wasapi(pContext, &cmd);
+ ma_thread_wait(&pContext->wasapi.commandThread);
- /* Only after the thread has been terminated can we uninitialize the sync objects for the command thread. */
- ma_semaphore_uninit(&pContext->wasapi.commandSem);
- ma_mutex_uninit(&pContext->wasapi.commandLock);
+ if (pContext->wasapi.hAvrt) {
+ ma_dlclose(pContext, pContext->wasapi.hAvrt);
+ pContext->wasapi.hAvrt = NULL;
}
+ #if defined(MA_WIN32_UWP)
+ {
+ if (pContext->wasapi.hMMDevapi) {
+ ma_dlclose(pContext, pContext->wasapi.hMMDevapi);
+ pContext->wasapi.hMMDevapi = NULL;
+ }
+ }
+ #endif
+
+ /* Only after the thread has been terminated can we uninitialize the sync objects for the command thread. */
+ ma_semaphore_uninit(&pContext->wasapi.commandSem);
+ ma_mutex_uninit(&pContext->wasapi.commandLock);
+
return MA_SUCCESS;
}
@@ -22274,6 +23521,41 @@ static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_
ma_mutex_uninit(&pContext->wasapi.commandLock);
return result;
}
+
+ #if defined(MA_WIN32_UWP)
+ {
+ /* Link to mmdevapi so we can get access to ActivateAudioInterfaceAsync(). */
+ pContext->wasapi.hMMDevapi = ma_dlopen(pContext, "mmdevapi.dll");
+ if (pContext->wasapi.hMMDevapi) {
+ pContext->wasapi.ActivateAudioInterfaceAsync = ma_dlsym(pContext, pContext->wasapi.hMMDevapi, "ActivateAudioInterfaceAsync");
+ if (pContext->wasapi.ActivateAudioInterfaceAsync == NULL) {
+ ma_semaphore_uninit(&pContext->wasapi.commandSem);
+ ma_mutex_uninit(&pContext->wasapi.commandLock);
+ ma_dlclose(pContext, pContext->wasapi.hMMDevapi);
+ return MA_NO_BACKEND; /* ActivateAudioInterfaceAsync() could not be loaded. */
+ }
+ } else {
+ ma_semaphore_uninit(&pContext->wasapi.commandSem);
+ ma_mutex_uninit(&pContext->wasapi.commandLock);
+ return MA_NO_BACKEND; /* Failed to load mmdevapi.dll which is required for ActivateAudioInterfaceAsync() */
+ }
+ }
+ #endif
+
+ /* Optionally use the Avrt API to specify the audio thread's latency sensitivity requirements */
+ pContext->wasapi.hAvrt = ma_dlopen(pContext, "avrt.dll");
+ if (pContext->wasapi.hAvrt) {
+ pContext->wasapi.AvSetMmThreadCharacteristicsA = ma_dlsym(pContext, pContext->wasapi.hAvrt, "AvSetMmThreadCharacteristicsA");
+ pContext->wasapi.AvRevertMmThreadcharacteristics = ma_dlsym(pContext, pContext->wasapi.hAvrt, "AvRevertMmThreadCharacteristics");
+
+ /* If either function could not be found, disable use of avrt entirely. */
+ if (!pContext->wasapi.AvSetMmThreadCharacteristicsA || !pContext->wasapi.AvRevertMmThreadcharacteristics) {
+ pContext->wasapi.AvSetMmThreadCharacteristicsA = NULL;
+ pContext->wasapi.AvRevertMmThreadcharacteristics = NULL;
+ ma_dlclose(pContext, pContext->wasapi.hAvrt);
+ pContext->wasapi.hAvrt = NULL;
+ }
+ }
}
@@ -22354,7 +23636,7 @@ typedef struct
DWORD dwFlags;
DWORD dwBufferBytes;
DWORD dwReserved;
- WAVEFORMATEX* lpwfxFormat;
+ MA_WAVEFORMATEX* lpwfxFormat;
GUID guid3DAlgorithm;
} MA_DSBUFFERDESC;
@@ -22364,7 +23646,7 @@ typedef struct
DWORD dwFlags;
DWORD dwBufferBytes;
DWORD dwReserved;
- WAVEFORMATEX* lpwfxFormat;
+ MA_WAVEFORMATEX* lpwfxFormat;
DWORD dwFXCount;
void* lpDSCFXDesc; /* <-- miniaudio doesn't use this, so set to void*. */
} MA_DSCBUFFERDESC;
@@ -22488,7 +23770,7 @@ typedef struct
/* IDirectSoundBuffer */
HRESULT (STDMETHODCALLTYPE * GetCaps) (ma_IDirectSoundBuffer* pThis, MA_DSBCAPS* pDSBufferCaps);
HRESULT (STDMETHODCALLTYPE * GetCurrentPosition)(ma_IDirectSoundBuffer* pThis, DWORD* pCurrentPlayCursor, DWORD* pCurrentWriteCursor);
- HRESULT (STDMETHODCALLTYPE * GetFormat) (ma_IDirectSoundBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten);
+ HRESULT (STDMETHODCALLTYPE * GetFormat) (ma_IDirectSoundBuffer* pThis, MA_WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten);
HRESULT (STDMETHODCALLTYPE * GetVolume) (ma_IDirectSoundBuffer* pThis, LONG* pVolume);
HRESULT (STDMETHODCALLTYPE * GetPan) (ma_IDirectSoundBuffer* pThis, LONG* pPan);
HRESULT (STDMETHODCALLTYPE * GetFrequency) (ma_IDirectSoundBuffer* pThis, DWORD* pFrequency);
@@ -22497,7 +23779,7 @@ typedef struct
HRESULT (STDMETHODCALLTYPE * Lock) (ma_IDirectSoundBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags);
HRESULT (STDMETHODCALLTYPE * Play) (ma_IDirectSoundBuffer* pThis, DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags);
HRESULT (STDMETHODCALLTYPE * SetCurrentPosition)(ma_IDirectSoundBuffer* pThis, DWORD dwNewPosition);
- HRESULT (STDMETHODCALLTYPE * SetFormat) (ma_IDirectSoundBuffer* pThis, const WAVEFORMATEX* pFormat);
+ HRESULT (STDMETHODCALLTYPE * SetFormat) (ma_IDirectSoundBuffer* pThis, const MA_WAVEFORMATEX* pFormat);
HRESULT (STDMETHODCALLTYPE * SetVolume) (ma_IDirectSoundBuffer* pThis, LONG volume);
HRESULT (STDMETHODCALLTYPE * SetPan) (ma_IDirectSoundBuffer* pThis, LONG pan);
HRESULT (STDMETHODCALLTYPE * SetFrequency) (ma_IDirectSoundBuffer* pThis, DWORD dwFrequency);
@@ -22514,7 +23796,7 @@ static MA_INLINE ULONG ma_IDirectSoundBuffer_AddRef(ma_IDirectSoundBuffer* pTh
static MA_INLINE ULONG ma_IDirectSoundBuffer_Release(ma_IDirectSoundBuffer* pThis) { return pThis->lpVtbl->Release(pThis); }
static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetCaps(ma_IDirectSoundBuffer* pThis, MA_DSBCAPS* pDSBufferCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSBufferCaps); }
static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetCurrentPosition(ma_IDirectSoundBuffer* pThis, DWORD* pCurrentPlayCursor, DWORD* pCurrentWriteCursor) { return pThis->lpVtbl->GetCurrentPosition(pThis, pCurrentPlayCursor, pCurrentWriteCursor); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetFormat(ma_IDirectSoundBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten) { return pThis->lpVtbl->GetFormat(pThis, pFormat, dwSizeAllocated, pSizeWritten); }
+static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetFormat(ma_IDirectSoundBuffer* pThis, MA_WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten) { return pThis->lpVtbl->GetFormat(pThis, pFormat, dwSizeAllocated, pSizeWritten); }
static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetVolume(ma_IDirectSoundBuffer* pThis, LONG* pVolume) { return pThis->lpVtbl->GetVolume(pThis, pVolume); }
static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetPan(ma_IDirectSoundBuffer* pThis, LONG* pPan) { return pThis->lpVtbl->GetPan(pThis, pPan); }
static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetFrequency(ma_IDirectSoundBuffer* pThis, DWORD* pFrequency) { return pThis->lpVtbl->GetFrequency(pThis, pFrequency); }
@@ -22523,7 +23805,7 @@ static MA_INLINE HRESULT ma_IDirectSoundBuffer_Initialize(ma_IDirectSoundBuffer*
static MA_INLINE HRESULT ma_IDirectSoundBuffer_Lock(ma_IDirectSoundBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags) { return pThis->lpVtbl->Lock(pThis, dwOffset, dwBytes, ppAudioPtr1, pAudioBytes1, ppAudioPtr2, pAudioBytes2, dwFlags); }
static MA_INLINE HRESULT ma_IDirectSoundBuffer_Play(ma_IDirectSoundBuffer* pThis, DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) { return pThis->lpVtbl->Play(pThis, dwReserved1, dwPriority, dwFlags); }
static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetCurrentPosition(ma_IDirectSoundBuffer* pThis, DWORD dwNewPosition) { return pThis->lpVtbl->SetCurrentPosition(pThis, dwNewPosition); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetFormat(ma_IDirectSoundBuffer* pThis, const WAVEFORMATEX* pFormat) { return pThis->lpVtbl->SetFormat(pThis, pFormat); }
+static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetFormat(ma_IDirectSoundBuffer* pThis, const MA_WAVEFORMATEX* pFormat) { return pThis->lpVtbl->SetFormat(pThis, pFormat); }
static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetVolume(ma_IDirectSoundBuffer* pThis, LONG volume) { return pThis->lpVtbl->SetVolume(pThis, volume); }
static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetPan(ma_IDirectSoundBuffer* pThis, LONG pan) { return pThis->lpVtbl->SetPan(pThis, pan); }
static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetFrequency(ma_IDirectSoundBuffer* pThis, DWORD dwFrequency) { return pThis->lpVtbl->SetFrequency(pThis, dwFrequency); }
@@ -22568,7 +23850,7 @@ typedef struct
/* IDirectSoundCaptureBuffer */
HRESULT (STDMETHODCALLTYPE * GetCaps) (ma_IDirectSoundCaptureBuffer* pThis, MA_DSCBCAPS* pDSCBCaps);
HRESULT (STDMETHODCALLTYPE * GetCurrentPosition)(ma_IDirectSoundCaptureBuffer* pThis, DWORD* pCapturePosition, DWORD* pReadPosition);
- HRESULT (STDMETHODCALLTYPE * GetFormat) (ma_IDirectSoundCaptureBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten);
+ HRESULT (STDMETHODCALLTYPE * GetFormat) (ma_IDirectSoundCaptureBuffer* pThis, MA_WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten);
HRESULT (STDMETHODCALLTYPE * GetStatus) (ma_IDirectSoundCaptureBuffer* pThis, DWORD* pStatus);
HRESULT (STDMETHODCALLTYPE * Initialize) (ma_IDirectSoundCaptureBuffer* pThis, ma_IDirectSoundCapture* pDirectSoundCapture, const MA_DSCBUFFERDESC* pDSCBufferDesc);
HRESULT (STDMETHODCALLTYPE * Lock) (ma_IDirectSoundCaptureBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags);
@@ -22585,7 +23867,7 @@ static MA_INLINE ULONG ma_IDirectSoundCaptureBuffer_AddRef(ma_IDirectSoundCapt
static MA_INLINE ULONG ma_IDirectSoundCaptureBuffer_Release(ma_IDirectSoundCaptureBuffer* pThis) { return pThis->lpVtbl->Release(pThis); }
static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetCaps(ma_IDirectSoundCaptureBuffer* pThis, MA_DSCBCAPS* pDSCBCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSCBCaps); }
static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetCurrentPosition(ma_IDirectSoundCaptureBuffer* pThis, DWORD* pCapturePosition, DWORD* pReadPosition) { return pThis->lpVtbl->GetCurrentPosition(pThis, pCapturePosition, pReadPosition); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetFormat(ma_IDirectSoundCaptureBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten) { return pThis->lpVtbl->GetFormat(pThis, pFormat, dwSizeAllocated, pSizeWritten); }
+static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetFormat(ma_IDirectSoundCaptureBuffer* pThis, MA_WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten) { return pThis->lpVtbl->GetFormat(pThis, pFormat, dwSizeAllocated, pSizeWritten); }
static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetStatus(ma_IDirectSoundCaptureBuffer* pThis, DWORD* pStatus) { return pThis->lpVtbl->GetStatus(pThis, pStatus); }
static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Initialize(ma_IDirectSoundCaptureBuffer* pThis, ma_IDirectSoundCapture* pDirectSoundCapture, const MA_DSCBUFFERDESC* pDSCBufferDesc) { return pThis->lpVtbl->Initialize(pThis, pDirectSoundCapture, pDSCBufferDesc); }
static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Lock(ma_IDirectSoundCaptureBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags) { return pThis->lpVtbl->Lock(pThis, dwOffset, dwBytes, ppAudioPtr1, pAudioBytes1, ppAudioPtr2, pAudioBytes2, dwFlags); }
@@ -22615,11 +23897,11 @@ static MA_INLINE ULONG ma_IDirectSoundNotify_Release(ma_IDirectSoundNotify* pT
static MA_INLINE HRESULT ma_IDirectSoundNotify_SetNotificationPositions(ma_IDirectSoundNotify* pThis, DWORD dwPositionNotifies, const MA_DSBPOSITIONNOTIFY* pPositionNotifies) { return pThis->lpVtbl->SetNotificationPositions(pThis, dwPositionNotifies, pPositionNotifies); }
-typedef BOOL (CALLBACK * ma_DSEnumCallbackAProc) (LPGUID pDeviceGUID, LPCSTR pDeviceDescription, LPCSTR pModule, LPVOID pContext);
-typedef HRESULT (WINAPI * ma_DirectSoundCreateProc) (const GUID* pcGuidDevice, ma_IDirectSound** ppDS8, LPUNKNOWN pUnkOuter);
-typedef HRESULT (WINAPI * ma_DirectSoundEnumerateAProc) (ma_DSEnumCallbackAProc pDSEnumCallback, LPVOID pContext);
-typedef HRESULT (WINAPI * ma_DirectSoundCaptureCreateProc) (const GUID* pcGuidDevice, ma_IDirectSoundCapture** ppDSC8, LPUNKNOWN pUnkOuter);
-typedef HRESULT (WINAPI * ma_DirectSoundCaptureEnumerateAProc)(ma_DSEnumCallbackAProc pDSEnumCallback, LPVOID pContext);
+typedef BOOL (CALLBACK * ma_DSEnumCallbackAProc) (GUID* pDeviceGUID, const char* pDeviceDescription, const char* pModule, void* pContext);
+typedef HRESULT (WINAPI * ma_DirectSoundCreateProc) (const GUID* pcGuidDevice, ma_IDirectSound** ppDS8, ma_IUnknown* pUnkOuter);
+typedef HRESULT (WINAPI * ma_DirectSoundEnumerateAProc) (ma_DSEnumCallbackAProc pDSEnumCallback, void* pContext);
+typedef HRESULT (WINAPI * ma_DirectSoundCaptureCreateProc) (const GUID* pcGuidDevice, ma_IDirectSoundCapture** ppDSC8, ma_IUnknown* pUnkOuter);
+typedef HRESULT (WINAPI * ma_DirectSoundCaptureEnumerateAProc)(ma_DSEnumCallbackAProc pDSEnumCallback, void* pContext);
static ma_uint32 ma_get_best_sample_rate_within_range(ma_uint32 sampleRateMin, ma_uint32 sampleRateMax)
{
@@ -22716,7 +23998,7 @@ static ma_result ma_context_create_IDirectSound__dsound(ma_context* pContext, ma
/* The cooperative level must be set before doing anything else. */
hWnd = ((MA_PFN_GetForegroundWindow)pContext->win32.GetForegroundWindow)();
- if (hWnd == NULL) {
+ if (hWnd == 0) {
hWnd = ((MA_PFN_GetDesktopWindow)pContext->win32.GetDesktopWindow)();
}
@@ -22868,7 +24150,7 @@ typedef struct
ma_bool32 terminated;
} ma_context_enumerate_devices_callback_data__dsound;
-static BOOL CALLBACK ma_context_enumerate_devices_callback__dsound(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext)
+static BOOL CALLBACK ma_context_enumerate_devices_callback__dsound(GUID* lpGuid, const char* lpcstrDescription, const char* lpcstrModule, void* lpContext)
{
ma_context_enumerate_devices_callback_data__dsound* pData = (ma_context_enumerate_devices_callback_data__dsound*)lpContext;
ma_device_info deviceInfo;
@@ -22934,7 +24216,7 @@ typedef struct
ma_bool32 found;
} ma_context_get_device_info_callback_data__dsound;
-static BOOL CALLBACK ma_context_get_device_info_callback__dsound(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext)
+static BOOL CALLBACK ma_context_get_device_info_callback__dsound(GUID* lpGuid, const char* lpcstrDescription, const char* lpcstrModule, void* lpContext)
{
ma_context_get_device_info_callback_data__dsound* pData = (ma_context_get_device_info_callback_data__dsound*)lpContext;
MA_ASSERT(pData != NULL);
@@ -23139,7 +24421,7 @@ static ma_result ma_device_uninit__dsound(ma_device* pDevice)
return MA_SUCCESS;
}
-static ma_result ma_config_to_WAVEFORMATEXTENSIBLE(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, const ma_channel* pChannelMap, WAVEFORMATEXTENSIBLE* pWF)
+static ma_result ma_config_to_WAVEFORMATEXTENSIBLE(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, const ma_channel* pChannelMap, MA_WAVEFORMATEXTENSIBLE* pWF)
{
GUID subformat;
@@ -23176,14 +24458,14 @@ static ma_result ma_config_to_WAVEFORMATEXTENSIBLE(ma_format format, ma_uint32 c
}
MA_ZERO_OBJECT(pWF);
- pWF->Format.cbSize = sizeof(*pWF);
- pWF->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- pWF->Format.nChannels = (WORD)channels;
- pWF->Format.nSamplesPerSec = (DWORD)sampleRate;
- pWF->Format.wBitsPerSample = (WORD)(ma_get_bytes_per_sample(format)*8);
- pWF->Format.nBlockAlign = (WORD)(pWF->Format.nChannels * pWF->Format.wBitsPerSample / 8);
- pWF->Format.nAvgBytesPerSec = pWF->Format.nBlockAlign * pWF->Format.nSamplesPerSec;
- pWF->Samples.wValidBitsPerSample = pWF->Format.wBitsPerSample;
+ pWF->cbSize = sizeof(*pWF);
+ pWF->wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ pWF->nChannels = (WORD)channels;
+ pWF->nSamplesPerSec = (DWORD)sampleRate;
+ pWF->wBitsPerSample = (WORD)(ma_get_bytes_per_sample(format)*8);
+ pWF->nBlockAlign = (WORD)(pWF->nChannels * pWF->wBitsPerSample / 8);
+ pWF->nAvgBytesPerSec = pWF->nBlockAlign * pWF->nSamplesPerSec;
+ pWF->Samples.wValidBitsPerSample = pWF->wBitsPerSample;
pWF->dwChannelMask = ma_channel_map_to_channel_mask__win32(pChannelMap, channels);
pWF->SubFormat = subformat;
@@ -23226,12 +24508,12 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf
full-duplex mode.
*/
if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
- WAVEFORMATEXTENSIBLE wf;
+ MA_WAVEFORMATEXTENSIBLE wf;
MA_DSCBUFFERDESC descDS;
ma_uint32 periodSizeInFrames;
ma_uint32 periodCount;
char rawdata[1024]; /* <-- Ugly hack to avoid a malloc() due to a crappy DirectSound API. */
- WAVEFORMATEXTENSIBLE* pActualFormat;
+ MA_WAVEFORMATEXTENSIBLE* pActualFormat;
result = ma_config_to_WAVEFORMATEXTENSIBLE(pDescriptorCapture->format, pDescriptorCapture->channels, pDescriptorCapture->sampleRate, pDescriptorCapture->channelMap, &wf);
if (result != MA_SUCCESS) {
@@ -23244,26 +24526,26 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf
return result;
}
- result = ma_context_get_format_info_for_IDirectSoundCapture__dsound(pDevice->pContext, (ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &wf.Format.nChannels, &wf.Format.wBitsPerSample, &wf.Format.nSamplesPerSec);
+ result = ma_context_get_format_info_for_IDirectSoundCapture__dsound(pDevice->pContext, (ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &wf.nChannels, &wf.wBitsPerSample, &wf.nSamplesPerSec);
if (result != MA_SUCCESS) {
ma_device_uninit__dsound(pDevice);
return result;
}
- wf.Format.nBlockAlign = (WORD)(wf.Format.nChannels * wf.Format.wBitsPerSample / 8);
- wf.Format.nAvgBytesPerSec = wf.Format.nBlockAlign * wf.Format.nSamplesPerSec;
- wf.Samples.wValidBitsPerSample = wf.Format.wBitsPerSample;
+ wf.nBlockAlign = (WORD)(wf.nChannels * wf.wBitsPerSample / 8);
+ wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec;
+ wf.Samples.wValidBitsPerSample = wf.wBitsPerSample;
wf.SubFormat = MA_GUID_KSDATAFORMAT_SUBTYPE_PCM;
/* The size of the buffer must be a clean multiple of the period count. */
- periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__dsound(pDescriptorCapture, wf.Format.nSamplesPerSec, pConfig->performanceProfile);
+ periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__dsound(pDescriptorCapture, wf.nSamplesPerSec, pConfig->performanceProfile);
periodCount = (pDescriptorCapture->periodCount > 0) ? pDescriptorCapture->periodCount : MA_DEFAULT_PERIODS;
MA_ZERO_OBJECT(&descDS);
descDS.dwSize = sizeof(descDS);
descDS.dwFlags = 0;
- descDS.dwBufferBytes = periodSizeInFrames * periodCount * wf.Format.nBlockAlign;
- descDS.lpwfxFormat = (WAVEFORMATEX*)&wf;
+ descDS.dwBufferBytes = periodSizeInFrames * periodCount * wf.nBlockAlign;
+ descDS.lpwfxFormat = (MA_WAVEFORMATEX*)&wf;
hr = ma_IDirectSoundCapture_CreateCaptureBuffer((ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &descDS, (ma_IDirectSoundCaptureBuffer**)&pDevice->dsound.pCaptureBuffer, NULL);
if (FAILED(hr)) {
ma_device_uninit__dsound(pDevice);
@@ -23272,8 +24554,8 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf
}
/* Get the _actual_ properties of the buffer. */
- pActualFormat = (WAVEFORMATEXTENSIBLE*)rawdata;
- hr = ma_IDirectSoundCaptureBuffer_GetFormat((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, (WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL);
+ pActualFormat = (MA_WAVEFORMATEXTENSIBLE*)rawdata;
+ hr = ma_IDirectSoundCaptureBuffer_GetFormat((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, (MA_WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL);
if (FAILED(hr)) {
ma_device_uninit__dsound(pDevice);
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the capture device's buffer.");
@@ -23281,12 +24563,12 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf
}
/* We can now start setting the output data formats. */
- pDescriptorCapture->format = ma_format_from_WAVEFORMATEX((WAVEFORMATEX*)pActualFormat);
- pDescriptorCapture->channels = pActualFormat->Format.nChannels;
- pDescriptorCapture->sampleRate = pActualFormat->Format.nSamplesPerSec;
+ pDescriptorCapture->format = ma_format_from_WAVEFORMATEX((MA_WAVEFORMATEX*)pActualFormat);
+ pDescriptorCapture->channels = pActualFormat->nChannels;
+ pDescriptorCapture->sampleRate = pActualFormat->nSamplesPerSec;
/* Get the native channel map based on the channel mask. */
- if (pActualFormat->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
+ if (pActualFormat->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
ma_channel_mask_to_channel_map__win32(pActualFormat->dwChannelMask, pDescriptorCapture->channels, pDescriptorCapture->channelMap);
} else {
ma_channel_mask_to_channel_map__win32(wf.dwChannelMask, pDescriptorCapture->channels, pDescriptorCapture->channelMap);
@@ -23314,14 +24596,16 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf
}
if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
- WAVEFORMATEXTENSIBLE wf;
+ MA_WAVEFORMATEXTENSIBLE wf;
MA_DSBUFFERDESC descDSPrimary;
MA_DSCAPS caps;
char rawdata[1024]; /* <-- Ugly hack to avoid a malloc() due to a crappy DirectSound API. */
- WAVEFORMATEXTENSIBLE* pActualFormat;
+ MA_WAVEFORMATEXTENSIBLE* pActualFormat;
ma_uint32 periodSizeInFrames;
ma_uint32 periodCount;
MA_DSBUFFERDESC descDS;
+ WORD nativeChannelCount;
+ DWORD nativeChannelMask = 0;
result = ma_config_to_WAVEFORMATEXTENSIBLE(pDescriptorPlayback->format, pDescriptorPlayback->channels, pDescriptorPlayback->sampleRate, pDescriptorPlayback->channelMap, &wf);
if (result != MA_SUCCESS) {
@@ -23355,34 +24639,38 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf
return ma_result_from_HRESULT(hr);
}
- if (pDescriptorPlayback->channels == 0) {
- if ((caps.dwFlags & MA_DSCAPS_PRIMARYSTEREO) != 0) {
- DWORD speakerConfig;
+ if ((caps.dwFlags & MA_DSCAPS_PRIMARYSTEREO) != 0) {
+ DWORD speakerConfig;
- /* It supports at least stereo, but could support more. */
- wf.Format.nChannels = 2;
+ /* It supports at least stereo, but could support more. */
+ nativeChannelCount = 2;
- /* Look at the speaker configuration to get a better idea on the channel count. */
- if (SUCCEEDED(ma_IDirectSound_GetSpeakerConfig((ma_IDirectSound*)pDevice->dsound.pPlayback, &speakerConfig))) {
- ma_get_channels_from_speaker_config__dsound(speakerConfig, &wf.Format.nChannels, &wf.dwChannelMask);
- }
- } else {
- /* It does not support stereo, which means we are stuck with mono. */
- wf.Format.nChannels = 1;
+ /* Look at the speaker configuration to get a better idea on the channel count. */
+ if (SUCCEEDED(ma_IDirectSound_GetSpeakerConfig((ma_IDirectSound*)pDevice->dsound.pPlayback, &speakerConfig))) {
+ ma_get_channels_from_speaker_config__dsound(speakerConfig, &nativeChannelCount, &nativeChannelMask);
}
+ } else {
+ /* It does not support stereo, which means we are stuck with mono. */
+ nativeChannelCount = 1;
+ nativeChannelMask = 0x00000001;
+ }
+
+ if (pDescriptorPlayback->channels == 0) {
+ wf.nChannels = nativeChannelCount;
+ wf.dwChannelMask = nativeChannelMask;
}
if (pDescriptorPlayback->sampleRate == 0) {
/* We base the sample rate on the values returned by GetCaps(). */
if ((caps.dwFlags & MA_DSCAPS_CONTINUOUSRATE) != 0) {
- wf.Format.nSamplesPerSec = ma_get_best_sample_rate_within_range(caps.dwMinSecondarySampleRate, caps.dwMaxSecondarySampleRate);
+ wf.nSamplesPerSec = ma_get_best_sample_rate_within_range(caps.dwMinSecondarySampleRate, caps.dwMaxSecondarySampleRate);
} else {
- wf.Format.nSamplesPerSec = caps.dwMaxSecondarySampleRate;
+ wf.nSamplesPerSec = caps.dwMaxSecondarySampleRate;
}
}
- wf.Format.nBlockAlign = (WORD)(wf.Format.nChannels * wf.Format.wBitsPerSample / 8);
- wf.Format.nAvgBytesPerSec = wf.Format.nBlockAlign * wf.Format.nSamplesPerSec;
+ wf.nBlockAlign = (WORD)(wf.nChannels * wf.wBitsPerSample / 8);
+ wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec;
/*
From MSDN:
@@ -23391,16 +24679,33 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf
supported format. To determine whether this has happened, an application can call the GetFormat method for the primary buffer
and compare the result with the format that was requested with the SetFormat method.
*/
- hr = ma_IDirectSoundBuffer_SetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (WAVEFORMATEX*)&wf);
+ hr = ma_IDirectSoundBuffer_SetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (MA_WAVEFORMATEX*)&wf);
if (FAILED(hr)) {
- ma_device_uninit__dsound(pDevice);
- ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to set format of playback device's primary buffer.");
- return ma_result_from_HRESULT(hr);
+ /*
+ If setting of the format failed we'll try again with some fallback settings. On Windows 98 I have
+ observed that IEEE_FLOAT does not work. We'll therefore enforce PCM. I also had issues where a
+ sample rate of 48000 did not work correctly. Not sure if it was a driver issue or not, but will
+ use 44100 for the sample rate.
+ */
+ wf.cbSize = 18; /* NOTE: Don't use sizeof(MA_WAVEFORMATEX) here because it's got an extra 2 bytes due to padding. */
+ wf.wFormatTag = WAVE_FORMAT_PCM;
+ wf.wBitsPerSample = 16;
+ wf.nChannels = nativeChannelCount;
+ wf.nSamplesPerSec = 44100;
+ wf.nBlockAlign = wf.nChannels * (wf.wBitsPerSample / 8);
+ wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
+
+ hr = ma_IDirectSoundBuffer_SetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (MA_WAVEFORMATEX*)&wf);
+ if (FAILED(hr)) {
+ ma_device_uninit__dsound(pDevice);
+ ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to set format of playback device's primary buffer.");
+ return ma_result_from_HRESULT(hr);
+ }
}
/* Get the _actual_ properties of the buffer. */
- pActualFormat = (WAVEFORMATEXTENSIBLE*)rawdata;
- hr = ma_IDirectSoundBuffer_GetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL);
+ pActualFormat = (MA_WAVEFORMATEXTENSIBLE*)rawdata;
+ hr = ma_IDirectSoundBuffer_GetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (MA_WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL);
if (FAILED(hr)) {
ma_device_uninit__dsound(pDevice);
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the playback device's primary buffer.");
@@ -23408,12 +24713,12 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf
}
/* We now have enough information to start setting some output properties. */
- pDescriptorPlayback->format = ma_format_from_WAVEFORMATEX((WAVEFORMATEX*)pActualFormat);
- pDescriptorPlayback->channels = pActualFormat->Format.nChannels;
- pDescriptorPlayback->sampleRate = pActualFormat->Format.nSamplesPerSec;
+ pDescriptorPlayback->format = ma_format_from_WAVEFORMATEX((MA_WAVEFORMATEX*)pActualFormat);
+ pDescriptorPlayback->channels = pActualFormat->nChannels;
+ pDescriptorPlayback->sampleRate = pActualFormat->nSamplesPerSec;
/* Get the internal channel map based on the channel mask. */
- if (pActualFormat->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
+ if (pActualFormat->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
ma_channel_mask_to_channel_map__win32(pActualFormat->dwChannelMask, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap);
} else {
ma_channel_mask_to_channel_map__win32(wf.dwChannelMask, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap);
@@ -23442,7 +24747,7 @@ static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_conf
descDS.dwSize = sizeof(descDS);
descDS.dwFlags = MA_DSBCAPS_CTRLPOSITIONNOTIFY | MA_DSBCAPS_GLOBALFOCUS | MA_DSBCAPS_GETCURRENTPOSITION2;
descDS.dwBufferBytes = periodSizeInFrames * periodCount * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels);
- descDS.lpwfxFormat = (WAVEFORMATEX*)&wf;
+ descDS.lpwfxFormat = (MA_WAVEFORMATEX*)pActualFormat;
hr = ma_IDirectSound_CreateSoundBuffer((ma_IDirectSound*)pDevice->dsound.pPlayback, &descDS, (ma_IDirectSoundBuffer**)&pDevice->dsound.pPlaybackBuffer, NULL);
if (FAILED(hr)) {
ma_device_uninit__dsound(pDevice);
@@ -23999,6 +25304,18 @@ static ma_result ma_context_init__dsound(ma_context* pContext, const ma_context_
pContext->dsound.DirectSoundCaptureCreate = ma_dlsym(pContext, pContext->dsound.hDSoundDLL, "DirectSoundCaptureCreate");
pContext->dsound.DirectSoundCaptureEnumerateA = ma_dlsym(pContext, pContext->dsound.hDSoundDLL, "DirectSoundCaptureEnumerateA");
+ /*
+ We need to support all functions or nothing. DirectSound with Windows 95 seems to not work too
+ well in my testing. For example, it's missing DirectSoundCaptureEnumerateA(). This is a convenient
+ place to just disable the DirectSound backend for Windows 95.
+ */
+ if (pContext->dsound.DirectSoundCreate == NULL ||
+ pContext->dsound.DirectSoundEnumerateA == NULL ||
+ pContext->dsound.DirectSoundCaptureCreate == NULL ||
+ pContext->dsound.DirectSoundCaptureEnumerateA == NULL) {
+ return MA_API_NOT_FOUND;
+ }
+
pCallbacks->onContextInit = ma_context_init__dsound;
pCallbacks->onContextUninit = ma_context_uninit__dsound;
pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__dsound;
@@ -24025,16 +25342,75 @@ WinMM Backend
#ifdef MA_HAS_WINMM
/*
-Some older compilers don't have WAVEOUTCAPS2A and WAVEINCAPS2A, so we'll need to write this ourselves. These structures
-are exactly the same as the older ones but they have a few GUIDs for manufacturer/product/name identification. I'm keeping
-the names the same as the Win32 library for consistency, but namespaced to avoid naming conflicts with the Win32 version.
+Some build configurations will exclude the WinMM API. An example is when WIN32_LEAN_AND_MEAN
+is defined. We need to define the types and functions we need manually.
*/
+#define MA_MMSYSERR_NOERROR 0
+#define MA_MMSYSERR_ERROR 1
+#define MA_MMSYSERR_BADDEVICEID 2
+#define MA_MMSYSERR_INVALHANDLE 5
+#define MA_MMSYSERR_NOMEM 7
+#define MA_MMSYSERR_INVALFLAG 10
+#define MA_MMSYSERR_INVALPARAM 11
+#define MA_MMSYSERR_HANDLEBUSY 12
+
+#define MA_CALLBACK_EVENT 0x00050000
+#define MA_WAVE_ALLOWSYNC 0x0002
+
+#define MA_WHDR_DONE 0x00000001
+#define MA_WHDR_PREPARED 0x00000002
+#define MA_WHDR_BEGINLOOP 0x00000004
+#define MA_WHDR_ENDLOOP 0x00000008
+#define MA_WHDR_INQUEUE 0x00000010
+
+#define MA_MAXPNAMELEN 32
+
+typedef void* MA_HWAVEIN;
+typedef void* MA_HWAVEOUT;
+typedef UINT MA_MMRESULT;
+typedef UINT MA_MMVERSION;
+
typedef struct
{
WORD wMid;
WORD wPid;
- MMVERSION vDriverVersion;
- CHAR szPname[MAXPNAMELEN];
+ MA_MMVERSION vDriverVersion;
+ CHAR szPname[MA_MAXPNAMELEN];
+ DWORD dwFormats;
+ WORD wChannels;
+ WORD wReserved1;
+} MA_WAVEINCAPSA;
+
+typedef struct
+{
+ WORD wMid;
+ WORD wPid;
+ MA_MMVERSION vDriverVersion;
+ CHAR szPname[MA_MAXPNAMELEN];
+ DWORD dwFormats;
+ WORD wChannels;
+ WORD wReserved1;
+ DWORD dwSupport;
+} MA_WAVEOUTCAPSA;
+
+typedef struct tagWAVEHDR
+{
+ char* lpData;
+ DWORD dwBufferLength;
+ DWORD dwBytesRecorded;
+ DWORD_PTR dwUser;
+ DWORD dwFlags;
+ DWORD dwLoops;
+ struct tagWAVEHDR* lpNext;
+ DWORD_PTR reserved;
+} MA_WAVEHDR;
+
+typedef struct
+{
+ WORD wMid;
+ WORD wPid;
+ MA_MMVERSION vDriverVersion;
+ CHAR szPname[MA_MAXPNAMELEN];
DWORD dwFormats;
WORD wChannels;
WORD wReserved1;
@@ -24043,12 +25419,13 @@ typedef struct
GUID ProductGuid;
GUID NameGuid;
} MA_WAVEOUTCAPS2A;
+
typedef struct
{
WORD wMid;
WORD wPid;
- MMVERSION vDriverVersion;
- CHAR szPname[MAXPNAMELEN];
+ MA_MMVERSION vDriverVersion;
+ CHAR szPname[MA_MAXPNAMELEN];
DWORD dwFormats;
WORD wChannels;
WORD wReserved1;
@@ -24057,36 +25434,37 @@ typedef struct
GUID NameGuid;
} MA_WAVEINCAPS2A;
-typedef UINT (WINAPI * MA_PFN_waveOutGetNumDevs)(void);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutGetDevCapsA)(ma_uintptr uDeviceID, LPWAVEOUTCAPSA pwoc, UINT cbwoc);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutOpen)(LPHWAVEOUT phwo, UINT uDeviceID, LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutClose)(HWAVEOUT hwo);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutPrepareHeader)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutUnprepareHeader)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutWrite)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutReset)(HWAVEOUT hwo);
-typedef UINT (WINAPI * MA_PFN_waveInGetNumDevs)(void);
-typedef MMRESULT (WINAPI * MA_PFN_waveInGetDevCapsA)(ma_uintptr uDeviceID, LPWAVEINCAPSA pwic, UINT cbwic);
-typedef MMRESULT (WINAPI * MA_PFN_waveInOpen)(LPHWAVEIN phwi, UINT uDeviceID, LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
-typedef MMRESULT (WINAPI * MA_PFN_waveInClose)(HWAVEIN hwi);
-typedef MMRESULT (WINAPI * MA_PFN_waveInPrepareHeader)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveInUnprepareHeader)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveInAddBuffer)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveInStart)(HWAVEIN hwi);
-typedef MMRESULT (WINAPI * MA_PFN_waveInReset)(HWAVEIN hwi);
+typedef UINT (WINAPI * MA_PFN_waveOutGetNumDevs)(void);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutGetDevCapsA)(ma_uintptr uDeviceID, MA_WAVEOUTCAPSA* pwoc, UINT cbwoc);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutOpen)(MA_HWAVEOUT* phwo, UINT uDeviceID, const MA_WAVEFORMATEX* pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutClose)(MA_HWAVEOUT hwo);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutPrepareHeader)(MA_HWAVEOUT hwo, MA_WAVEHDR* pwh, UINT cbwh);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutUnprepareHeader)(MA_HWAVEOUT hwo, MA_WAVEHDR* pwh, UINT cbwh);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutWrite)(MA_HWAVEOUT hwo, MA_WAVEHDR* pwh, UINT cbwh);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutReset)(MA_HWAVEOUT hwo);
+typedef UINT (WINAPI * MA_PFN_waveInGetNumDevs)(void);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveInGetDevCapsA)(ma_uintptr uDeviceID, MA_WAVEINCAPSA* pwic, UINT cbwic);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveInOpen)(MA_HWAVEIN* phwi, UINT uDeviceID, const MA_WAVEFORMATEX* pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveInClose)(MA_HWAVEIN hwi);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveInPrepareHeader)(MA_HWAVEIN hwi, MA_WAVEHDR* pwh, UINT cbwh);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveInUnprepareHeader)(MA_HWAVEIN hwi, MA_WAVEHDR* pwh, UINT cbwh);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveInAddBuffer)(MA_HWAVEIN hwi, MA_WAVEHDR* pwh, UINT cbwh);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveInStart)(MA_HWAVEIN hwi);
+typedef MA_MMRESULT (WINAPI * MA_PFN_waveInReset)(MA_HWAVEIN hwi);
-static ma_result ma_result_from_MMRESULT(MMRESULT resultMM)
+static ma_result ma_result_from_MMRESULT(MA_MMRESULT resultMM)
{
- switch (resultMM) {
- case MMSYSERR_NOERROR: return MA_SUCCESS;
- case MMSYSERR_BADDEVICEID: return MA_INVALID_ARGS;
- case MMSYSERR_INVALHANDLE: return MA_INVALID_ARGS;
- case MMSYSERR_NOMEM: return MA_OUT_OF_MEMORY;
- case MMSYSERR_INVALFLAG: return MA_INVALID_ARGS;
- case MMSYSERR_INVALPARAM: return MA_INVALID_ARGS;
- case MMSYSERR_HANDLEBUSY: return MA_BUSY;
- case MMSYSERR_ERROR: return MA_ERROR;
- default: return MA_ERROR;
+ switch (resultMM)
+ {
+ case MA_MMSYSERR_NOERROR: return MA_SUCCESS;
+ case MA_MMSYSERR_BADDEVICEID: return MA_INVALID_ARGS;
+ case MA_MMSYSERR_INVALHANDLE: return MA_INVALID_ARGS;
+ case MA_MMSYSERR_NOMEM: return MA_OUT_OF_MEMORY;
+ case MA_MMSYSERR_INVALFLAG: return MA_INVALID_ARGS;
+ case MA_MMSYSERR_INVALPARAM: return MA_INVALID_ARGS;
+ case MA_MMSYSERR_HANDLEBUSY: return MA_BUSY;
+ case MA_MMSYSERR_ERROR: return MA_ERROR;
+ default: return MA_ERROR;
}
}
@@ -24122,7 +25500,7 @@ we can do things generically and typesafely. Names are being kept the same for c
*/
typedef struct
{
- CHAR szPname[MAXPNAMELEN];
+ CHAR szPname[MA_MAXPNAMELEN];
DWORD dwFormats;
WORD wChannels;
GUID NameGuid;
@@ -24208,7 +25586,7 @@ static ma_result ma_get_best_info_from_formats_flags__winmm(DWORD dwFormats, WOR
return MA_SUCCESS;
}
-static ma_result ma_formats_flags_to_WAVEFORMATEX__winmm(DWORD dwFormats, WORD channels, WAVEFORMATEX* pWF)
+static ma_result ma_formats_flags_to_WAVEFORMATEX__winmm(DWORD dwFormats, WORD channels, MA_WAVEFORMATEX* pWF)
{
ma_result result;
@@ -24265,7 +25643,7 @@ static ma_result ma_context_get_device_info_from_WAVECAPS(ma_context* pContext,
name, and then concatenate the name from the registry.
*/
if (!ma_is_guid_null(&pCaps->NameGuid)) {
- wchar_t guidStrW[256];
+ WCHAR guidStrW[256];
if (((MA_PFN_StringFromGUID2)pContext->win32.StringFromGUID2)(&pCaps->NameGuid, guidStrW, ma_countof(guidStrW)) > 0) {
char guidStr[256];
char keyStr[1024];
@@ -24279,7 +25657,7 @@ static ma_result ma_context_get_device_info_from_WAVECAPS(ma_context* pContext,
if (((MA_PFN_RegOpenKeyExA)pContext->win32.RegOpenKeyExA)(HKEY_LOCAL_MACHINE, keyStr, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
BYTE nameFromReg[512];
DWORD nameFromRegSize = sizeof(nameFromReg);
- LONG resultWin32 = ((MA_PFN_RegQueryValueExA)pContext->win32.RegQueryValueExA)(hKey, "Name", 0, NULL, (LPBYTE)nameFromReg, (LPDWORD)&nameFromRegSize);
+ LONG resultWin32 = ((MA_PFN_RegQueryValueExA)pContext->win32.RegQueryValueExA)(hKey, "Name", 0, NULL, (BYTE*)nameFromReg, (DWORD*)&nameFromRegSize);
((MA_PFN_RegCloseKey)pContext->win32.RegCloseKey)(hKey);
if (resultWin32 == ERROR_SUCCESS) {
@@ -24373,13 +25751,13 @@ static ma_result ma_context_enumerate_devices__winmm(ma_context* pContext, ma_en
/* Playback. */
playbackDeviceCount = ((MA_PFN_waveOutGetNumDevs)pContext->winmm.waveOutGetNumDevs)();
for (iPlaybackDevice = 0; iPlaybackDevice < playbackDeviceCount; ++iPlaybackDevice) {
- MMRESULT result;
+ MA_MMRESULT result;
MA_WAVEOUTCAPS2A caps;
MA_ZERO_OBJECT(&caps);
- result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(iPlaybackDevice, (WAVEOUTCAPSA*)&caps, sizeof(caps));
- if (result == MMSYSERR_NOERROR) {
+ result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(iPlaybackDevice, (MA_WAVEOUTCAPSA*)&caps, sizeof(caps));
+ if (result == MA_MMSYSERR_NOERROR) {
ma_device_info deviceInfo;
MA_ZERO_OBJECT(&deviceInfo);
@@ -24402,13 +25780,13 @@ static ma_result ma_context_enumerate_devices__winmm(ma_context* pContext, ma_en
/* Capture. */
captureDeviceCount = ((MA_PFN_waveInGetNumDevs)pContext->winmm.waveInGetNumDevs)();
for (iCaptureDevice = 0; iCaptureDevice < captureDeviceCount; ++iCaptureDevice) {
- MMRESULT result;
+ MA_MMRESULT result;
MA_WAVEINCAPS2A caps;
MA_ZERO_OBJECT(&caps);
- result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(iCaptureDevice, (WAVEINCAPSA*)&caps, sizeof(caps));
- if (result == MMSYSERR_NOERROR) {
+ result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(iCaptureDevice, (MA_WAVEINCAPSA*)&caps, sizeof(caps));
+ if (result == MA_MMSYSERR_NOERROR) {
ma_device_info deviceInfo;
MA_ZERO_OBJECT(&deviceInfo);
@@ -24450,23 +25828,23 @@ static ma_result ma_context_get_device_info__winmm(ma_context* pContext, ma_devi
}
if (deviceType == ma_device_type_playback) {
- MMRESULT result;
+ MA_MMRESULT result;
MA_WAVEOUTCAPS2A caps;
MA_ZERO_OBJECT(&caps);
- result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(winMMDeviceID, (WAVEOUTCAPSA*)&caps, sizeof(caps));
- if (result == MMSYSERR_NOERROR) {
+ result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(winMMDeviceID, (MA_WAVEOUTCAPSA*)&caps, sizeof(caps));
+ if (result == MA_MMSYSERR_NOERROR) {
return ma_context_get_device_info_from_WAVEOUTCAPS2(pContext, &caps, pDeviceInfo);
}
} else {
- MMRESULT result;
+ MA_MMRESULT result;
MA_WAVEINCAPS2A caps;
MA_ZERO_OBJECT(&caps);
- result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(winMMDeviceID, (WAVEINCAPSA*)&caps, sizeof(caps));
- if (result == MMSYSERR_NOERROR) {
+ result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(winMMDeviceID, (MA_WAVEINCAPSA*)&caps, sizeof(caps));
+ if (result == MA_MMSYSERR_NOERROR) {
return ma_context_get_device_info_from_WAVEINCAPS2(pContext, &caps, pDeviceInfo);
}
}
@@ -24480,13 +25858,13 @@ static ma_result ma_device_uninit__winmm(ma_device* pDevice)
MA_ASSERT(pDevice != NULL);
if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
- ((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((HWAVEIN)pDevice->winmm.hDeviceCapture);
+ ((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture);
CloseHandle((HANDLE)pDevice->winmm.hEventCapture);
}
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
- ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
- ((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
+ ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback);
+ ((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback);
CloseHandle((HANDLE)pDevice->winmm.hEventPlayback);
}
@@ -24543,19 +25921,19 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
/* The capture device needs to be initialized first. */
if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
- WAVEINCAPSA caps;
- WAVEFORMATEX wf;
- MMRESULT resultMM;
+ MA_WAVEINCAPSA caps;
+ MA_WAVEFORMATEX wf;
+ MA_MMRESULT resultMM;
/* We use an event to know when a new fragment needs to be enqueued. */
- pDevice->winmm.hEventCapture = (ma_handle)CreateEventW(NULL, TRUE, TRUE, NULL);
+ pDevice->winmm.hEventCapture = (ma_handle)CreateEventA(NULL, TRUE, TRUE, NULL);
if (pDevice->winmm.hEventCapture == NULL) {
errorMsg = "[WinMM] Failed to create event for fragment enqueing for the capture device.", errorCode = ma_result_from_GetLastError(GetLastError());
goto on_error;
}
/* The format should be based on the device's actual format. */
- if (((MA_PFN_waveInGetDevCapsA)pDevice->pContext->winmm.waveInGetDevCapsA)(winMMDeviceIDCapture, &caps, sizeof(caps)) != MMSYSERR_NOERROR) {
+ if (((MA_PFN_waveInGetDevCapsA)pDevice->pContext->winmm.waveInGetDevCapsA)(winMMDeviceIDCapture, &caps, sizeof(caps)) != MA_MMSYSERR_NOERROR) {
errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MA_FORMAT_NOT_SUPPORTED;
goto on_error;
}
@@ -24566,8 +25944,8 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
goto on_error;
}
- resultMM = ((MA_PFN_waveInOpen)pDevice->pContext->winmm.waveInOpen)((LPHWAVEIN)&pDevice->winmm.hDeviceCapture, winMMDeviceIDCapture, &wf, (DWORD_PTR)pDevice->winmm.hEventCapture, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC);
- if (resultMM != MMSYSERR_NOERROR) {
+ resultMM = ((MA_PFN_waveInOpen)pDevice->pContext->winmm.waveInOpen)((MA_HWAVEIN*)&pDevice->winmm.hDeviceCapture, winMMDeviceIDCapture, &wf, (DWORD_PTR)pDevice->winmm.hEventCapture, (DWORD_PTR)pDevice, MA_CALLBACK_EVENT | MA_WAVE_ALLOWSYNC);
+ if (resultMM != MA_MMSYSERR_NOERROR) {
errorMsg = "[WinMM] Failed to open capture device.", errorCode = MA_FAILED_TO_OPEN_BACKEND_DEVICE;
goto on_error;
}
@@ -24581,19 +25959,19 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
}
if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
- WAVEOUTCAPSA caps;
- WAVEFORMATEX wf;
- MMRESULT resultMM;
+ MA_WAVEOUTCAPSA caps;
+ MA_WAVEFORMATEX wf;
+ MA_MMRESULT resultMM;
/* We use an event to know when a new fragment needs to be enqueued. */
- pDevice->winmm.hEventPlayback = (ma_handle)CreateEventW(NULL, TRUE, TRUE, NULL);
+ pDevice->winmm.hEventPlayback = (ma_handle)CreateEventA(NULL, TRUE, TRUE, NULL);
if (pDevice->winmm.hEventPlayback == NULL) {
errorMsg = "[WinMM] Failed to create event for fragment enqueing for the playback device.", errorCode = ma_result_from_GetLastError(GetLastError());
goto on_error;
}
/* The format should be based on the device's actual format. */
- if (((MA_PFN_waveOutGetDevCapsA)pDevice->pContext->winmm.waveOutGetDevCapsA)(winMMDeviceIDPlayback, &caps, sizeof(caps)) != MMSYSERR_NOERROR) {
+ if (((MA_PFN_waveOutGetDevCapsA)pDevice->pContext->winmm.waveOutGetDevCapsA)(winMMDeviceIDPlayback, &caps, sizeof(caps)) != MA_MMSYSERR_NOERROR) {
errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MA_FORMAT_NOT_SUPPORTED;
goto on_error;
}
@@ -24604,8 +25982,8 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
goto on_error;
}
- resultMM = ((MA_PFN_waveOutOpen)pDevice->pContext->winmm.waveOutOpen)((LPHWAVEOUT)&pDevice->winmm.hDevicePlayback, winMMDeviceIDPlayback, &wf, (DWORD_PTR)pDevice->winmm.hEventPlayback, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC);
- if (resultMM != MMSYSERR_NOERROR) {
+ resultMM = ((MA_PFN_waveOutOpen)pDevice->pContext->winmm.waveOutOpen)((MA_HWAVEOUT*)&pDevice->winmm.hDevicePlayback, winMMDeviceIDPlayback, &wf, (DWORD_PTR)pDevice->winmm.hEventPlayback, (DWORD_PTR)pDevice, MA_CALLBACK_EVENT | MA_WAVE_ALLOWSYNC);
+ if (resultMM != MA_MMSYSERR_NOERROR) {
errorMsg = "[WinMM] Failed to open playback device.", errorCode = MA_FAILED_TO_OPEN_BACKEND_DEVICE;
goto on_error;
}
@@ -24625,10 +26003,10 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
*/
heapSize = 0;
if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
- heapSize += sizeof(WAVEHDR)*pDescriptorCapture->periodCount + (pDescriptorCapture->periodSizeInFrames * pDescriptorCapture->periodCount * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels));
+ heapSize += sizeof(MA_WAVEHDR)*pDescriptorCapture->periodCount + (pDescriptorCapture->periodSizeInFrames * pDescriptorCapture->periodCount * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels));
}
if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
- heapSize += sizeof(WAVEHDR)*pDescriptorPlayback->periodCount + (pDescriptorPlayback->periodSizeInFrames * pDescriptorPlayback->periodCount * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels));
+ heapSize += sizeof(MA_WAVEHDR)*pDescriptorPlayback->periodCount + (pDescriptorPlayback->periodSizeInFrames * pDescriptorPlayback->periodCount * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels));
}
pDevice->winmm._pHeapData = (ma_uint8*)ma_calloc(heapSize, &pDevice->pContext->allocationCallbacks);
@@ -24644,27 +26022,27 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
if (pConfig->deviceType == ma_device_type_capture) {
pDevice->winmm.pWAVEHDRCapture = pDevice->winmm._pHeapData;
- pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount));
+ pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*(pDescriptorCapture->periodCount));
} else {
pDevice->winmm.pWAVEHDRCapture = pDevice->winmm._pHeapData;
- pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount));
+ pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount));
}
/* Prepare headers. */
for (iPeriod = 0; iPeriod < pDescriptorCapture->periodCount; ++iPeriod) {
ma_uint32 periodSizeInBytes = ma_get_period_size_in_bytes(pDescriptorCapture->periodSizeInFrames, pDescriptorCapture->format, pDescriptorCapture->channels);
- ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].lpData = (LPSTR)(pDevice->winmm.pIntermediaryBufferCapture + (periodSizeInBytes*iPeriod));
- ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwBufferLength = periodSizeInBytes;
- ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwFlags = 0L;
- ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwLoops = 0L;
- ((MA_PFN_waveInPrepareHeader)pDevice->pContext->winmm.waveInPrepareHeader)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR));
+ ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].lpData = (char*)(pDevice->winmm.pIntermediaryBufferCapture + (periodSizeInBytes*iPeriod));
+ ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwBufferLength = periodSizeInBytes;
+ ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwFlags = 0L;
+ ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwLoops = 0L;
+ ((MA_PFN_waveInPrepareHeader)pDevice->pContext->winmm.waveInPrepareHeader)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(MA_WAVEHDR));
/*
- The user data of the WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means
+ The user data of the MA_WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means
it's unlocked and available for writing. A value of 1 means it's locked.
*/
- ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwUser = 0;
+ ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwUser = 0;
}
}
@@ -24673,27 +26051,27 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
if (pConfig->deviceType == ma_device_type_playback) {
pDevice->winmm.pWAVEHDRPlayback = pDevice->winmm._pHeapData;
- pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*pDescriptorPlayback->periodCount);
+ pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*pDescriptorPlayback->periodCount);
} else {
- pDevice->winmm.pWAVEHDRPlayback = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount));
- pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount)) + (pDescriptorCapture->periodSizeInFrames*pDescriptorCapture->periodCount*ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels));
+ pDevice->winmm.pWAVEHDRPlayback = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*(pDescriptorCapture->periodCount));
+ pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount)) + (pDescriptorCapture->periodSizeInFrames*pDescriptorCapture->periodCount*ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels));
}
/* Prepare headers. */
for (iPeriod = 0; iPeriod < pDescriptorPlayback->periodCount; ++iPeriod) {
ma_uint32 periodSizeInBytes = ma_get_period_size_in_bytes(pDescriptorPlayback->periodSizeInFrames, pDescriptorPlayback->format, pDescriptorPlayback->channels);
- ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].lpData = (LPSTR)(pDevice->winmm.pIntermediaryBufferPlayback + (periodSizeInBytes*iPeriod));
- ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwBufferLength = periodSizeInBytes;
- ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwFlags = 0L;
- ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwLoops = 0L;
- ((MA_PFN_waveOutPrepareHeader)pDevice->pContext->winmm.waveOutPrepareHeader)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(WAVEHDR));
+ ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].lpData = (char*)(pDevice->winmm.pIntermediaryBufferPlayback + (periodSizeInBytes*iPeriod));
+ ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwBufferLength = periodSizeInBytes;
+ ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwFlags = 0L;
+ ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwLoops = 0L;
+ ((MA_PFN_waveOutPrepareHeader)pDevice->pContext->winmm.waveOutPrepareHeader)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(MA_WAVEHDR));
/*
- The user data of the WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means
+ The user data of the MA_WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means
it's unlocked and available for writing. A value of 1 means it's locked.
*/
- ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwUser = 0;
+ ((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwUser = 0;
}
}
@@ -24704,22 +26082,22 @@ on_error:
if (pDevice->winmm.pWAVEHDRCapture != NULL) {
ma_uint32 iPeriod;
for (iPeriod = 0; iPeriod < pDescriptorCapture->periodCount; ++iPeriod) {
- ((MA_PFN_waveInUnprepareHeader)pDevice->pContext->winmm.waveInUnprepareHeader)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR));
+ ((MA_PFN_waveInUnprepareHeader)pDevice->pContext->winmm.waveInUnprepareHeader)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(MA_WAVEHDR));
}
}
- ((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((HWAVEIN)pDevice->winmm.hDeviceCapture);
+ ((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture);
}
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
if (pDevice->winmm.pWAVEHDRCapture != NULL) {
ma_uint32 iPeriod;
for (iPeriod = 0; iPeriod < pDescriptorPlayback->periodCount; ++iPeriod) {
- ((MA_PFN_waveOutUnprepareHeader)pDevice->pContext->winmm.waveOutUnprepareHeader)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(WAVEHDR));
+ ((MA_PFN_waveOutUnprepareHeader)pDevice->pContext->winmm.waveOutUnprepareHeader)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(MA_WAVEHDR));
}
}
- ((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
+ ((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback);
}
ma_free(pDevice->winmm._pHeapData, &pDevice->pContext->allocationCallbacks);
@@ -24736,19 +26114,19 @@ static ma_result ma_device_start__winmm(ma_device* pDevice)
MA_ASSERT(pDevice != NULL);
if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
- MMRESULT resultMM;
- WAVEHDR* pWAVEHDR;
+ MA_MMRESULT resultMM;
+ MA_WAVEHDR* pWAVEHDR;
ma_uint32 iPeriod;
- pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRCapture;
+ pWAVEHDR = (MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture;
/* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */
ResetEvent((HANDLE)pDevice->winmm.hEventCapture);
/* To start the device we attach all of the buffers and then start it. As the buffers are filled with data we will get notifications. */
for (iPeriod = 0; iPeriod < pDevice->capture.internalPeriods; ++iPeriod) {
- resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((LPWAVEHDR)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR));
- if (resultMM != MMSYSERR_NOERROR) {
+ resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(MA_WAVEHDR));
+ if (resultMM != MA_MMSYSERR_NOERROR) {
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WinMM] Failed to attach input buffers to capture device in preparation for capture.");
return ma_result_from_MMRESULT(resultMM);
}
@@ -24758,8 +26136,8 @@ static ma_result ma_device_start__winmm(ma_device* pDevice)
}
/* Capture devices need to be explicitly started, unlike playback devices. */
- resultMM = ((MA_PFN_waveInStart)pDevice->pContext->winmm.waveInStart)((HWAVEIN)pDevice->winmm.hDeviceCapture);
- if (resultMM != MMSYSERR_NOERROR) {
+ resultMM = ((MA_PFN_waveInStart)pDevice->pContext->winmm.waveInStart)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture);
+ if (resultMM != MA_MMSYSERR_NOERROR) {
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WinMM] Failed to start backend device.");
return ma_result_from_MMRESULT(resultMM);
}
@@ -24774,7 +26152,7 @@ static ma_result ma_device_start__winmm(ma_device* pDevice)
static ma_result ma_device_stop__winmm(ma_device* pDevice)
{
- MMRESULT resultMM;
+ MA_MMRESULT resultMM;
MA_ASSERT(pDevice != NULL);
@@ -24783,22 +26161,22 @@ static ma_result ma_device_stop__winmm(ma_device* pDevice)
return MA_INVALID_ARGS;
}
- resultMM = ((MA_PFN_waveInReset)pDevice->pContext->winmm.waveInReset)((HWAVEIN)pDevice->winmm.hDeviceCapture);
- if (resultMM != MMSYSERR_NOERROR) {
+ resultMM = ((MA_PFN_waveInReset)pDevice->pContext->winmm.waveInReset)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture);
+ if (resultMM != MA_MMSYSERR_NOERROR) {
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[WinMM] WARNING: Failed to reset capture device.");
}
}
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
ma_uint32 iPeriod;
- WAVEHDR* pWAVEHDR;
+ MA_WAVEHDR* pWAVEHDR;
if (pDevice->winmm.hDevicePlayback == NULL) {
return MA_INVALID_ARGS;
}
/* We need to drain the device. To do this we just loop over each header and if it's locked just wait for the event. */
- pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback;
+ pWAVEHDR = (MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback;
for (iPeriod = 0; iPeriod < pDevice->playback.internalPeriods; iPeriod += 1) {
if (pWAVEHDR[iPeriod].dwUser == 1) { /* 1 = locked. */
if (WaitForSingleObject((HANDLE)pDevice->winmm.hEventPlayback, INFINITE) != WAIT_OBJECT_0) {
@@ -24809,8 +26187,8 @@ static ma_result ma_device_stop__winmm(ma_device* pDevice)
}
}
- resultMM = ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
- if (resultMM != MMSYSERR_NOERROR) {
+ resultMM = ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback);
+ if (resultMM != MA_MMSYSERR_NOERROR) {
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[WinMM] WARNING: Failed to reset playback device.");
}
}
@@ -24821,9 +26199,9 @@ static ma_result ma_device_stop__winmm(ma_device* pDevice)
static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
{
ma_result result = MA_SUCCESS;
- MMRESULT resultMM;
+ MA_MMRESULT resultMM;
ma_uint32 totalFramesWritten;
- WAVEHDR* pWAVEHDR;
+ MA_WAVEHDR* pWAVEHDR;
MA_ASSERT(pDevice != NULL);
MA_ASSERT(pPCMFrames != NULL);
@@ -24832,7 +26210,7 @@ static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFram
*pFramesWritten = 0;
}
- pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback;
+ pWAVEHDR = (MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback;
/* Keep processing as much data as possible. */
totalFramesWritten = 0;
@@ -24857,14 +26235,14 @@ static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFram
/* If we've consumed the buffer entirely we need to write it out to the device. */
if (pDevice->winmm.headerFramesConsumedPlayback == (pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwBufferLength/bpf)) {
pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwUser = 1; /* 1 = locked. */
- pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags &= ~WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */
+ pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags &= ~MA_WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */
/* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */
ResetEvent((HANDLE)pDevice->winmm.hEventPlayback);
/* The device will be started here. */
- resultMM = ((MA_PFN_waveOutWrite)pDevice->pContext->winmm.waveOutWrite)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &pWAVEHDR[pDevice->winmm.iNextHeaderPlayback], sizeof(WAVEHDR));
- if (resultMM != MMSYSERR_NOERROR) {
+ resultMM = ((MA_PFN_waveOutWrite)pDevice->pContext->winmm.waveOutWrite)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback, &pWAVEHDR[pDevice->winmm.iNextHeaderPlayback], sizeof(MA_WAVEHDR));
+ if (resultMM != MA_MMSYSERR_NOERROR) {
result = ma_result_from_MMRESULT(resultMM);
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WinMM] waveOutWrite() failed.");
break;
@@ -24892,7 +26270,7 @@ static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFram
}
/* Something happened. If the next buffer has been marked as done we need to reset a bit of state. */
- if ((pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags & WHDR_DONE) != 0) {
+ if ((pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags & MA_WHDR_DONE) != 0) {
pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwUser = 0; /* 0 = unlocked (make it available for writing). */
pDevice->winmm.headerFramesConsumedPlayback = 0;
}
@@ -24913,9 +26291,9 @@ static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFram
static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead)
{
ma_result result = MA_SUCCESS;
- MMRESULT resultMM;
+ MA_MMRESULT resultMM;
ma_uint32 totalFramesRead;
- WAVEHDR* pWAVEHDR;
+ MA_WAVEHDR* pWAVEHDR;
MA_ASSERT(pDevice != NULL);
MA_ASSERT(pPCMFrames != NULL);
@@ -24924,7 +26302,7 @@ static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_
*pFramesRead = 0;
}
- pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRCapture;
+ pWAVEHDR = (MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture;
/* Keep processing as much data as possible. */
totalFramesRead = 0;
@@ -24946,14 +26324,14 @@ static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_
/* If we've consumed the buffer entirely we need to add it back to the device. */
if (pDevice->winmm.headerFramesConsumedCapture == (pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwBufferLength/bpf)) {
pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwUser = 1; /* 1 = locked. */
- pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags &= ~WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */
+ pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags &= ~MA_WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */
/* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */
ResetEvent((HANDLE)pDevice->winmm.hEventCapture);
/* The device will be started here. */
- resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((LPWAVEHDR)pDevice->winmm.pWAVEHDRCapture)[pDevice->winmm.iNextHeaderCapture], sizeof(WAVEHDR));
- if (resultMM != MMSYSERR_NOERROR) {
+ resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[pDevice->winmm.iNextHeaderCapture], sizeof(MA_WAVEHDR));
+ if (resultMM != MA_MMSYSERR_NOERROR) {
result = ma_result_from_MMRESULT(resultMM);
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WinMM] waveInAddBuffer() failed.");
break;
@@ -24981,7 +26359,7 @@ static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_
}
/* Something happened. If the next buffer has been marked as done we need to reset a bit of state. */
- if ((pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags & WHDR_DONE) != 0) {
+ if ((pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags & MA_WHDR_DONE) != 0) {
pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwUser = 0; /* 0 = unlocked (make it available for reading). */
pDevice->winmm.headerFramesConsumedCapture = 0;
}
@@ -26231,7 +27609,7 @@ static ma_result ma_device_init_by_type__alsa(ma_device* pDevice, const ma_devic
isUsingMMap = MA_FALSE;
#if 0 /* NOTE: MMAP mode temporarily disabled. */
if (deviceType != ma_device_type_capture) { /* <-- Disabling MMAP mode for capture devices because I apparently do not have a device that supports it which means I can't test it... Contributions welcome. */
- if (!pConfig->alsa.noMMap && ma_device__is_async(pDevice)) {
+ if (!pConfig->alsa.noMMap) {
if (((ma_snd_pcm_hw_params_set_access_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_access)(pPCM, pHWParams, MA_SND_PCM_ACCESS_MMAP_INTERLEAVED) == 0) {
pDevice->alsa.isUsingMMap = MA_TRUE;
}
@@ -26462,7 +27840,11 @@ static ma_result ma_device_init_by_type__alsa(ma_device* pDevice, const ma_devic
/* Grab the internal channel map. For now we're not going to bother trying to change the channel map and instead just do it ourselves. */
{
- ma_snd_pcm_chmap_t* pChmap = ((ma_snd_pcm_get_chmap_proc)pDevice->pContext->alsa.snd_pcm_get_chmap)(pPCM);
+ ma_snd_pcm_chmap_t* pChmap = NULL;
+ if (pDevice->pContext->alsa.snd_pcm_get_chmap != NULL) {
+ pChmap = ((ma_snd_pcm_get_chmap_proc)pDevice->pContext->alsa.snd_pcm_get_chmap)(pPCM);
+ }
+
if (pChmap != NULL) {
ma_uint32 iChannel;
@@ -28169,6 +29551,14 @@ static void ma_device_sink_info_callback(ma_pa_context* pPulseContext, const ma_
return;
}
+ /*
+ There has been a report that indicates that pInfo can be null which results
+ in a null pointer dereference below. We'll check for this for safety.
+ */
+ if (pInfo == NULL) {
+ return;
+ }
+
pInfoOut = (ma_pa_sink_info*)pUserData;
MA_ASSERT(pInfoOut != NULL);
@@ -28185,6 +29575,14 @@ static void ma_device_source_info_callback(ma_pa_context* pPulseContext, const m
return;
}
+ /*
+ There has been a report that indicates that pInfo can be null which results
+ in a null pointer dereference below. We'll check for this for safety.
+ */
+ if (pInfo == NULL) {
+ return;
+ }
+
pInfoOut = (ma_pa_source_info*)pUserData;
MA_ASSERT(pInfoOut != NULL);
@@ -28856,7 +30254,6 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi
ma_pa_channel_map cmap;
ma_pa_buffer_attr attr;
const ma_pa_sample_spec* pActualSS = NULL;
- const ma_pa_channel_map* pActualCMap = NULL;
const ma_pa_buffer_attr* pActualAttr = NULL;
ma_uint32 iChannel;
ma_pa_stream_flags_t streamFlags;
@@ -28894,7 +30291,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi
sampleRate = pDescriptorCapture->sampleRate;
}
-
+
result = ma_init_pa_mainloop_and_pa_context__pulse(pDevice->pContext, pDevice->pContext->pulse.pApplicationName, pDevice->pContext->pulse.pServerName, MA_FALSE, &pDevice->pulse.pMainLoop, &pDevice->pulse.pPulseContext);
if (result != MA_SUCCESS) {
@@ -28912,6 +30309,19 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi
ss = sourceInfo.sample_spec;
cmap = sourceInfo.channel_map;
+ /* Use the requested channel count if we have one. */
+ if (pDescriptorCapture->channels != 0) {
+ ss.channels = pDescriptorCapture->channels;
+ }
+
+ /* Use a default channel map. */
+ ((ma_pa_channel_map_init_extend_proc)pDevice->pContext->pulse.pa_channel_map_init_extend)(&cmap, ss.channels, MA_PA_CHANNEL_MAP_DEFAULT);
+
+ /* Use the requested sample rate if one was specified. */
+ if (pDescriptorCapture->sampleRate != 0) {
+ ss.rate = pDescriptorCapture->sampleRate;
+ }
+
if (ma_format_from_pulse(ss.format) == ma_format_unknown) {
if (ma_is_little_endian()) {
ss.format = MA_PA_SAMPLE_FLOAT32LE;
@@ -29001,11 +30411,6 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi
fixed sooner than later. I might remove this hack later.
*/
if (pDescriptorCapture->channels > 2) {
- pActualCMap = ((ma_pa_stream_get_channel_map_proc)pDevice->pContext->pulse.pa_stream_get_channel_map)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
- if (pActualCMap != NULL) {
- cmap = *pActualCMap;
- }
-
for (iChannel = 0; iChannel < pDescriptorCapture->channels; ++iChannel) {
pDescriptorCapture->channelMap[iChannel] = ma_channel_position_from_pulse(cmap.map[iChannel]);
}
@@ -29048,6 +30453,20 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi
ss = sinkInfo.sample_spec;
cmap = sinkInfo.channel_map;
+ /* Use the requested channel count if we have one. */
+ if (pDescriptorPlayback->channels != 0) {
+ ss.channels = pDescriptorPlayback->channels;
+ }
+
+ /* Use a default channel map. */
+ ((ma_pa_channel_map_init_extend_proc)pDevice->pContext->pulse.pa_channel_map_init_extend)(&cmap, ss.channels, MA_PA_CHANNEL_MAP_DEFAULT);
+
+
+ /* Use the requested sample rate if one was specified. */
+ if (pDescriptorPlayback->sampleRate != 0) {
+ ss.rate = pDescriptorPlayback->sampleRate;
+ }
+
if (ma_format_from_pulse(ss.format) == ma_format_unknown) {
if (ma_is_little_endian()) {
ss.format = MA_PA_SAMPLE_FLOAT32LE;
@@ -29141,11 +30560,6 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi
fixed sooner than later. I might remove this hack later.
*/
if (pDescriptorPlayback->channels > 2) {
- pActualCMap = ((ma_pa_stream_get_channel_map_proc)pDevice->pContext->pulse.pa_stream_get_channel_map)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
- if (pActualCMap != NULL) {
- cmap = *pActualCMap;
- }
-
for (iChannel = 0; iChannel < pDescriptorPlayback->channels; ++iChannel) {
pDescriptorPlayback->channelMap[iChannel] = ma_channel_position_from_pulse(cmap.map[iChannel]);
}
@@ -30184,10 +31598,11 @@ static ma_result ma_context_init__jack(ma_context* pContext, const ma_context_co
{
#ifndef MA_NO_RUNTIME_LINKING
const char* libjackNames[] = {
-#ifdef MA_WIN32
+#if defined(MA_WIN32)
"libjack.dll",
"libjack64.dll"
-#else
+#endif
+#if defined(MA_UNIX)
"libjack.so",
"libjack.so.0"
#endif
@@ -30401,7 +31816,7 @@ structure with three variables and is used to identify which property you are ge
which is basically the specific property that you're wanting to retrieve or set. The second is the "scope", which is
typically set to kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyScopeInput for input-specific properties and
kAudioObjectPropertyScopeOutput for output-specific properties. The last is the "element" which is always set to
-kAudioObjectPropertyElementMaster in miniaudio's case. I don't know of any cases where this would be set to anything different.
+kAudioObjectPropertyElementMain in miniaudio's case. I don't know of any cases where this would be set to anything different.
Back to the earlier issue of device retrieval, you first use the AudioObjectGetPropertyDataSize() API to retrieve the size
of the raw data which is just a list of AudioDeviceID's. You use the kAudioObjectSystemObject AudioObjectID, and a property
@@ -30676,15 +32091,15 @@ static ma_result ma_get_channel_map_from_AudioChannelLayout(AudioChannelLayout*
{
pChannelMap[7] = MA_CHANNEL_SIDE_RIGHT;
pChannelMap[6] = MA_CHANNEL_SIDE_LEFT;
- } /* Intentional fallthrough. */
+ } MA_FALLTHROUGH; /* Intentional fallthrough. */
case kAudioChannelLayoutTag_Hexagonal:
{
pChannelMap[5] = MA_CHANNEL_BACK_CENTER;
- } /* Intentional fallthrough. */
+ } MA_FALLTHROUGH; /* Intentional fallthrough. */
case kAudioChannelLayoutTag_Pentagonal:
{
pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
- } /* Intentional fallghrough. */
+ } MA_FALLTHROUGH; /* Intentional fallthrough. */
case kAudioChannelLayoutTag_Quadraphonic:
{
pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
@@ -30705,6 +32120,14 @@ static ma_result ma_get_channel_map_from_AudioChannelLayout(AudioChannelLayout*
return MA_SUCCESS;
}
+#if (defined(MAC_OS_VERSION_12_0) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_12_0) || \
+ (defined(__IPHONE_15_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_15_0)
+#define AUDIO_OBJECT_PROPERTY_ELEMENT kAudioObjectPropertyElementMain
+#else
+/* kAudioObjectPropertyElementMaster is deprecated. */
+#define AUDIO_OBJECT_PROPERTY_ELEMENT kAudioObjectPropertyElementMaster
+#endif
+
static ma_result ma_get_device_object_ids__coreaudio(ma_context* pContext, UInt32* pDeviceCount, AudioObjectID** ppDeviceObjectIDs) /* NOTE: Free the returned buffer with ma_free(). */
{
AudioObjectPropertyAddress propAddressDevices;
@@ -30722,7 +32145,7 @@ static ma_result ma_get_device_object_ids__coreaudio(ma_context* pContext, UInt3
propAddressDevices.mSelector = kAudioHardwarePropertyDevices;
propAddressDevices.mScope = kAudioObjectPropertyScopeGlobal;
- propAddressDevices.mElement = kAudioObjectPropertyElementMaster;
+ propAddressDevices.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT;
status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(kAudioObjectSystemObject, &propAddressDevices, 0, NULL, &deviceObjectsDataSize);
if (status != noErr) {
@@ -30756,7 +32179,7 @@ static ma_result ma_get_AudioObject_uid_as_CFStringRef(ma_context* pContext, Aud
propAddress.mSelector = kAudioDevicePropertyDeviceUID;
propAddress.mScope = kAudioObjectPropertyScopeGlobal;
- propAddress.mElement = kAudioObjectPropertyElementMaster;
+ propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT;
dataSize = sizeof(*pUID);
status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(objectID, &propAddress, 0, NULL, &dataSize, pUID);
@@ -30798,7 +32221,7 @@ static ma_result ma_get_AudioObject_name(ma_context* pContext, AudioObjectID obj
propAddress.mSelector = kAudioDevicePropertyDeviceNameCFString;
propAddress.mScope = kAudioObjectPropertyScopeGlobal;
- propAddress.mElement = kAudioObjectPropertyElementMaster;
+ propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT;
dataSize = sizeof(deviceName);
status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(objectID, &propAddress, 0, NULL, &dataSize, &deviceName);
@@ -30827,7 +32250,7 @@ static ma_bool32 ma_does_AudioObject_support_scope(ma_context* pContext, AudioOb
/* To know whether or not a device is an input device we need ot look at the stream configuration. If it has an output channel it's a playback device. */
propAddress.mSelector = kAudioDevicePropertyStreamConfiguration;
propAddress.mScope = scope;
- propAddress.mElement = kAudioObjectPropertyElementMaster;
+ propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT;
status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize);
if (status != noErr) {
@@ -30882,7 +32305,7 @@ static ma_result ma_get_AudioObject_stream_descriptions(ma_context* pContext, Au
*/
propAddress.mSelector = kAudioStreamPropertyAvailableVirtualFormats; /*kAudioStreamPropertyAvailablePhysicalFormats;*/
propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
- propAddress.mElement = kAudioObjectPropertyElementMaster;
+ propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT;
status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize);
if (status != noErr) {
@@ -30920,7 +32343,7 @@ static ma_result ma_get_AudioObject_channel_layout(ma_context* pContext, AudioOb
propAddress.mSelector = kAudioDevicePropertyPreferredChannelLayout;
propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
- propAddress.mElement = kAudioObjectPropertyElementMaster;
+ propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT;
status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize);
if (status != noErr) {
@@ -31010,7 +32433,7 @@ static ma_result ma_get_AudioObject_sample_rates(ma_context* pContext, AudioObje
propAddress.mSelector = kAudioDevicePropertyAvailableNominalSampleRates;
propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
- propAddress.mElement = kAudioObjectPropertyElementMaster;
+ propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT;
status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize);
if (status != noErr) {
@@ -31132,7 +32555,7 @@ static ma_result ma_get_AudioObject_closest_buffer_size_in_frames(ma_context* pC
propAddress.mSelector = kAudioDevicePropertyBufferFrameSizeRange;
propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
- propAddress.mElement = kAudioObjectPropertyElementMaster;
+ propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT;
dataSize = sizeof(bufferSizeRange);
status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, &bufferSizeRange);
@@ -31170,7 +32593,7 @@ static ma_result ma_set_AudioObject_buffer_size_in_frames(ma_context* pContext,
/* Try setting the size of the buffer... If this fails we just use whatever is currently set. */
propAddress.mSelector = kAudioDevicePropertyBufferFrameSize;
propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
- propAddress.mElement = kAudioObjectPropertyElementMaster;
+ propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT;
((ma_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, NULL, sizeof(chosenBufferSizeInFrames), &chosenBufferSizeInFrames);
@@ -31199,7 +32622,7 @@ static ma_result ma_find_default_AudioObjectID(ma_context* pContext, ma_device_t
*pDeviceObjectID = 0;
propAddressDefaultDevice.mScope = kAudioObjectPropertyScopeGlobal;
- propAddressDefaultDevice.mElement = kAudioObjectPropertyElementMaster;
+ propAddressDefaultDevice.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT;
if (deviceType == ma_device_type_playback) {
propAddressDefaultDevice.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
} else {
@@ -32014,7 +33437,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "Failed to allocate AudioBufferList for capture.\n");
return noErr;
}
-
+
pRenderedBufferList = (AudioBufferList*)pDevice->coreaudio.pAudioBufferList;
MA_ASSERT(pRenderedBufferList);
@@ -32272,7 +33695,7 @@ static ma_result ma_context__init_device_tracking__coreaudio(ma_context* pContex
if (g_DeviceTrackingInitCounter_CoreAudio == 0) {
AudioObjectPropertyAddress propAddress;
propAddress.mScope = kAudioObjectPropertyScopeGlobal;
- propAddress.mElement = kAudioObjectPropertyElementMaster;
+ propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT;
ma_mutex_init(&g_DeviceTrackingMutex_CoreAudio);
@@ -32302,7 +33725,7 @@ static ma_result ma_context__uninit_device_tracking__coreaudio(ma_context* pCont
if (g_DeviceTrackingInitCounter_CoreAudio == 0) {
AudioObjectPropertyAddress propAddress;
propAddress.mScope = kAudioObjectPropertyScopeGlobal;
- propAddress.mElement = kAudioObjectPropertyElementMaster;
+ propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT;
propAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice;
((ma_AudioObjectRemovePropertyListener_proc)pContext->coreaudio.AudioObjectRemovePropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL);
@@ -32452,7 +33875,7 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice)
*/
ma_device__on_notification_interruption_began(m_pDevice);
} break;
-
+
case AVAudioSessionInterruptionTypeEnded:
{
ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_INFO, "[Core Audio] Interruption: AVAudioSessionInterruptionTypeEnded\n");
@@ -32506,7 +33929,7 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice)
}
ma_log_postf(ma_device_get_log(m_pDevice), MA_LOG_LEVEL_DEBUG, "[Core Audio] Changing Route. inputNumberChannels=%d; outputNumberOfChannels=%d\n", (int)pSession.inputNumberOfChannels, (int)pSession.outputNumberOfChannels);
-
+
/* Let the application know about the route change. */
ma_device__on_notification_rerouted(m_pDevice);
}
@@ -32753,7 +34176,7 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev
propAddress.mSelector = kAudioDevicePropertyNominalSampleRate;
propAddress.mScope = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
- propAddress.mElement = kAudioObjectPropertyElementMaster;
+ propAddress.mElement = AUDIO_OBJECT_PROPERTY_ELEMENT;
status = ((ma_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, NULL, sizeof(sampleRateRange), &sampleRateRange);
if (status != noErr) {
@@ -32879,7 +34302,7 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev
@autoreleasepool {
AVAudioSession* pAudioSession = [AVAudioSession sharedInstance];
MA_ASSERT(pAudioSession != NULL);
-
+
[pAudioSession setPreferredIOBufferDuration:((float)actualPeriodSizeInFrames / pAudioSession.sampleRate) error:nil];
actualPeriodSizeInFrames = ma_next_power_of_2((ma_uint32)(pAudioSession.IOBufferDuration * pAudioSession.sampleRate));
}
@@ -33120,7 +34543,7 @@ static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_c
#if defined(MA_APPLE_DESKTOP)
ma_get_AudioObject_uid(pDevice->pContext, pDevice->coreaudio.deviceObjectIDCapture, sizeof(pDevice->capture.id.coreaudio), pDevice->capture.id.coreaudio);
-
+
/*
If we are using the default device we'll need to listen for changes to the system's default device so we can seemlessly
switch the device in the background.
@@ -33184,7 +34607,7 @@ static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_c
#if defined(MA_APPLE_DESKTOP)
ma_get_AudioObject_uid(pDevice->pContext, pDevice->coreaudio.deviceObjectIDPlayback, sizeof(pDevice->playback.id.coreaudio), pDevice->playback.id.coreaudio);
-
+
/*
If we are using the default device we'll need to listen for changes to the system's default device so we can seemlessly
switch the device in the background.
@@ -34783,8 +36206,13 @@ static ma_result ma_device_init_fd__audio4(ma_device* pDevice, const ma_device_c
"/dev/audio",
"/dev/audio0"
};
+ const char* pDefaultDeviceCtlNames[] = {
+ "/dev/audioctl",
+ "/dev/audioctl0"
+ };
int fd;
int fdFlags = 0;
+ size_t iDefaultDevice = (size_t)-1;
ma_format internalFormat;
ma_uint32 internalChannels;
ma_uint32 internalSampleRate;
@@ -34803,11 +36231,11 @@ static ma_result ma_device_init_fd__audio4(ma_device* pDevice, const ma_device_c
}
/*fdFlags |= O_NONBLOCK;*/
+ /* Find the index of the default device as a start. We'll use this index later. Set it to (size_t)-1 otherwise. */
if (pDescriptor->pDeviceID == NULL) {
/* Default device. */
- size_t iDevice;
- for (iDevice = 0; iDevice < ma_countof(pDefaultDeviceNames); ++iDevice) {
- fd = open(pDefaultDeviceNames[iDevice], fdFlags, 0);
+ for (iDefaultDevice = 0; iDefaultDevice < ma_countof(pDefaultDeviceNames); ++iDefaultDevice) {
+ fd = open(pDefaultDeviceNames[iDefaultDevice], fdFlags, 0);
if (fd != -1) {
break;
}
@@ -34815,6 +36243,16 @@ static ma_result ma_device_init_fd__audio4(ma_device* pDevice, const ma_device_c
} else {
/* Specific device. */
fd = open(pDescriptor->pDeviceID->audio4, fdFlags, 0);
+
+ for (iDefaultDevice = 0; iDefaultDevice < ma_countof(pDefaultDeviceNames); iDefaultDevice += 1) {
+ if (ma_strcmp(pDefaultDeviceNames[iDefaultDevice], pDescriptor->pDeviceID->audio4) == 0) {
+ break;
+ }
+ }
+
+ if (iDefaultDevice == ma_countof(pDefaultDeviceNames)) {
+ iDefaultDevice = (size_t)-1;
+ }
}
if (fd == -1) {
@@ -34825,6 +36263,7 @@ static ma_result ma_device_init_fd__audio4(ma_device* pDevice, const ma_device_c
#if !defined(MA_AUDIO4_USE_NEW_API) /* Old API */
{
audio_info_t fdInfo;
+ int fdInfoResult = -1;
/*
The documentation is a little bit unclear to me as to how it handles formats. It says the
@@ -34844,6 +36283,28 @@ static ma_result ma_device_init_fd__audio4(ma_device* pDevice, const ma_device_c
*/
AUDIO_INITINFO(&fdInfo);
+ /*
+ Get the default format from the audioctl file if we're asking for a default device. If we
+ retrieve it from /dev/audio it'll default to mono 8000Hz.
+ */
+ if (iDefaultDevice != (size_t)-1) {
+ /* We're using a default device. Get the info from the /dev/audioctl file instead of /dev/audio. */
+ int fdctl = open(pDefaultDeviceCtlNames[iDefaultDevice], fdFlags, 0);
+ if (fdctl != -1) {
+ fdInfoResult = ioctl(fdctl, AUDIO_GETINFO, &fdInfo);
+ close(fdctl);
+ }
+ }
+
+ if (fdInfoResult == -1) {
+ /* We still don't have the default device info so just retrieve it from the main audio device. */
+ if (ioctl(fd, AUDIO_GETINFO, &fdInfo) < 0) {
+ close(fd);
+ ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[audio4] AUDIO_GETINFO failed.");
+ return ma_result_from_errno(errno);
+ }
+ }
+
/* We get the driver to do as much of the data conversion as possible. */
if (deviceType == ma_device_type_capture) {
fdInfo.mode = AUMODE_RECORD;
@@ -35831,6 +37292,9 @@ static ma_result ma_context_init__oss(ma_context* pContext, const ma_context_con
#endif /* OSS */
+
+
+
/******************************************************************************
AAudio Backend
@@ -35849,6 +37313,7 @@ typedef int32_t ma_aaudio_performance_mo
typedef int32_t ma_aaudio_usage_t;
typedef int32_t ma_aaudio_content_type_t;
typedef int32_t ma_aaudio_input_preset_t;
+typedef int32_t ma_aaudio_allowed_capture_policy_t;
typedef int32_t ma_aaudio_data_callback_result_t;
typedef struct ma_AAudioStreamBuilder_t* ma_AAudioStreamBuilder;
typedef struct ma_AAudioStream_t* ma_AAudioStream;
@@ -35923,6 +37388,11 @@ typedef struct ma_AAudioStream_t* ma_AAudioStream;
#define MA_AAUDIO_INPUT_PRESET_UNPROCESSED 9
#define MA_AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE 10
+/* Allowed Capture Policies */
+#define MA_AAUDIO_ALLOW_CAPTURE_BY_ALL 1
+#define MA_AAUDIO_ALLOW_CAPTURE_BY_SYSTEM 2
+#define MA_AAUDIO_ALLOW_CAPTURE_BY_NONE 3
+
/* Callback results. */
#define MA_AAUDIO_CALLBACK_RESULT_CONTINUE 0
#define MA_AAUDIO_CALLBACK_RESULT_STOP 1
@@ -35947,6 +37417,7 @@ typedef void (* MA_PFN_AAudioStreamBuilder_setPerformanceMod
typedef void (* MA_PFN_AAudioStreamBuilder_setUsage) (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_usage_t contentType);
typedef void (* MA_PFN_AAudioStreamBuilder_setContentType) (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_content_type_t contentType);
typedef void (* MA_PFN_AAudioStreamBuilder_setInputPreset) (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_input_preset_t inputPreset);
+typedef void (* MA_PFN_AAudioStreamBuilder_setAllowedCapturePolicy) (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_allowed_capture_policy_t policy);
typedef ma_aaudio_result_t (* MA_PFN_AAudioStreamBuilder_openStream) (ma_AAudioStreamBuilder* pBuilder, ma_AAudioStream** ppStream);
typedef ma_aaudio_result_t (* MA_PFN_AAudioStream_close) (ma_AAudioStream* pStream);
typedef ma_aaudio_stream_state_t (* MA_PFN_AAudioStream_getState) (ma_AAudioStream* pStream);
@@ -35974,22 +37445,22 @@ static ma_result ma_result_from_aaudio(ma_aaudio_result_t resultAA)
static ma_aaudio_usage_t ma_to_usage__aaudio(ma_aaudio_usage usage)
{
switch (usage) {
- case ma_aaudio_usage_announcement: return MA_AAUDIO_USAGE_MEDIA;
- case ma_aaudio_usage_emergency: return MA_AAUDIO_USAGE_VOICE_COMMUNICATION;
- case ma_aaudio_usage_safety: return MA_AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING;
- case ma_aaudio_usage_vehicle_status: return MA_AAUDIO_USAGE_ALARM;
- case ma_aaudio_usage_alarm: return MA_AAUDIO_USAGE_NOTIFICATION;
- case ma_aaudio_usage_assistance_accessibility: return MA_AAUDIO_USAGE_NOTIFICATION_RINGTONE;
- case ma_aaudio_usage_assistance_navigation_guidance: return MA_AAUDIO_USAGE_NOTIFICATION_EVENT;
- case ma_aaudio_usage_assistance_sonification: return MA_AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY;
- case ma_aaudio_usage_assitant: return MA_AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE;
- case ma_aaudio_usage_game: return MA_AAUDIO_USAGE_ASSISTANCE_SONIFICATION;
- case ma_aaudio_usage_media: return MA_AAUDIO_USAGE_GAME;
- case ma_aaudio_usage_notification: return MA_AAUDIO_USAGE_ASSISTANT;
- case ma_aaudio_usage_notification_event: return MA_AAUDIO_SYSTEM_USAGE_EMERGENCY;
- case ma_aaudio_usage_notification_ringtone: return MA_AAUDIO_SYSTEM_USAGE_SAFETY;
- case ma_aaudio_usage_voice_communication: return MA_AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS;
- case ma_aaudio_usage_voice_communication_signalling: return MA_AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT;
+ case ma_aaudio_usage_media: return MA_AAUDIO_USAGE_MEDIA;
+ case ma_aaudio_usage_voice_communication: return MA_AAUDIO_USAGE_VOICE_COMMUNICATION;
+ case ma_aaudio_usage_voice_communication_signalling: return MA_AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING;
+ case ma_aaudio_usage_alarm: return MA_AAUDIO_USAGE_ALARM;
+ case ma_aaudio_usage_notification: return MA_AAUDIO_USAGE_NOTIFICATION;
+ case ma_aaudio_usage_notification_ringtone: return MA_AAUDIO_USAGE_NOTIFICATION_RINGTONE;
+ case ma_aaudio_usage_notification_event: return MA_AAUDIO_USAGE_NOTIFICATION_EVENT;
+ case ma_aaudio_usage_assistance_accessibility: return MA_AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY;
+ case ma_aaudio_usage_assistance_navigation_guidance: return MA_AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE;
+ case ma_aaudio_usage_assistance_sonification: return MA_AAUDIO_USAGE_ASSISTANCE_SONIFICATION;
+ case ma_aaudio_usage_game: return MA_AAUDIO_USAGE_GAME;
+ case ma_aaudio_usage_assitant: return MA_AAUDIO_USAGE_ASSISTANT;
+ case ma_aaudio_usage_emergency: return MA_AAUDIO_SYSTEM_USAGE_EMERGENCY;
+ case ma_aaudio_usage_safety: return MA_AAUDIO_SYSTEM_USAGE_SAFETY;
+ case ma_aaudio_usage_vehicle_status: return MA_AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS;
+ case ma_aaudio_usage_announcement: return MA_AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT;
default: break;
}
@@ -35999,10 +37470,10 @@ static ma_aaudio_usage_t ma_to_usage__aaudio(ma_aaudio_usage usage)
static ma_aaudio_content_type_t ma_to_content_type__aaudio(ma_aaudio_content_type contentType)
{
switch (contentType) {
- case ma_aaudio_content_type_movie: return MA_AAUDIO_CONTENT_TYPE_MOVIE;
- case ma_aaudio_content_type_music: return MA_AAUDIO_CONTENT_TYPE_MUSIC;
- case ma_aaudio_content_type_sonification: return MA_AAUDIO_CONTENT_TYPE_SONIFICATION;
case ma_aaudio_content_type_speech: return MA_AAUDIO_CONTENT_TYPE_SPEECH;
+ case ma_aaudio_content_type_music: return MA_AAUDIO_CONTENT_TYPE_MUSIC;
+ case ma_aaudio_content_type_movie: return MA_AAUDIO_CONTENT_TYPE_MOVIE;
+ case ma_aaudio_content_type_sonification: return MA_AAUDIO_CONTENT_TYPE_SONIFICATION;
default: break;
}
@@ -36014,9 +37485,9 @@ static ma_aaudio_input_preset_t ma_to_input_preset__aaudio(ma_aaudio_input_prese
switch (inputPreset) {
case ma_aaudio_input_preset_generic: return MA_AAUDIO_INPUT_PRESET_GENERIC;
case ma_aaudio_input_preset_camcorder: return MA_AAUDIO_INPUT_PRESET_CAMCORDER;
- case ma_aaudio_input_preset_unprocessed: return MA_AAUDIO_INPUT_PRESET_UNPROCESSED;
case ma_aaudio_input_preset_voice_recognition: return MA_AAUDIO_INPUT_PRESET_VOICE_RECOGNITION;
case ma_aaudio_input_preset_voice_communication: return MA_AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION;
+ case ma_aaudio_input_preset_unprocessed: return MA_AAUDIO_INPUT_PRESET_UNPROCESSED;
case ma_aaudio_input_preset_voice_performance: return MA_AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE;
default: break;
}
@@ -36024,8 +37495,22 @@ static ma_aaudio_input_preset_t ma_to_input_preset__aaudio(ma_aaudio_input_prese
return MA_AAUDIO_INPUT_PRESET_GENERIC;
}
+static ma_aaudio_allowed_capture_policy_t ma_to_allowed_capture_policy__aaudio(ma_aaudio_allowed_capture_policy allowedCapturePolicy)
+{
+ switch (allowedCapturePolicy) {
+ case ma_aaudio_allow_capture_by_all: return MA_AAUDIO_ALLOW_CAPTURE_BY_ALL;
+ case ma_aaudio_allow_capture_by_system: return MA_AAUDIO_ALLOW_CAPTURE_BY_SYSTEM;
+ case ma_aaudio_allow_capture_by_none: return MA_AAUDIO_ALLOW_CAPTURE_BY_NONE;
+ default: break;
+ }
+
+ return MA_AAUDIO_ALLOW_CAPTURE_BY_ALL;
+}
+
static void ma_stream_error_callback__aaudio(ma_AAudioStream* pStream, void* pUserData, ma_aaudio_result_t error)
{
+ ma_result result;
+ ma_job job;
ma_device* pDevice = (ma_device*)pUserData;
MA_ASSERT(pDevice != NULL);
@@ -36034,26 +37519,24 @@ static void ma_stream_error_callback__aaudio(ma_AAudioStream* pStream, void* pUs
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[AAudio] ERROR CALLBACK: error=%d, AAudioStream_getState()=%d\n", error, ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream));
/*
- From the documentation for AAudio, when a device is disconnected all we can do is stop it. However, we cannot stop it from the callback - we need
- to do it from another thread. Therefore we are going to use an event thread for the AAudio backend to do this cleanly and safely.
+ When we get an error, we'll assume that the stream is in an erroneous state and needs to be restarted. From the documentation,
+ we cannot do this from the error callback. Therefore we are going to use an event thread for the AAudio backend to do this
+ cleanly and safely.
*/
- if (((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream) == MA_AAUDIO_STREAM_STATE_DISCONNECTED) {
- /* We need to post a job to the job thread for processing. This will reroute the device by reinitializing the stream. */
- ma_result result;
- ma_job job = ma_job_init(MA_JOB_TYPE_DEVICE_AAUDIO_REROUTE);
- job.data.device.aaudio.reroute.pDevice = pDevice;
+ job = ma_job_init(MA_JOB_TYPE_DEVICE_AAUDIO_REROUTE);
+ job.data.device.aaudio.reroute.pDevice = pDevice;
- if (pStream == pDevice->aaudio.pStreamCapture) {
- job.data.device.aaudio.reroute.deviceType = ma_device_type_capture;
- } else {
- job.data.device.aaudio.reroute.deviceType = ma_device_type_playback;
- }
+ if (pStream == pDevice->aaudio.pStreamCapture) {
+ job.data.device.aaudio.reroute.deviceType = ma_device_type_capture;
+ }
+ else {
+ job.data.device.aaudio.reroute.deviceType = ma_device_type_playback;
+ }
- result = ma_device_job_thread_post(&pDevice->pContext->aaudio.jobThread, &job);
- if (result != MA_SUCCESS) {
- ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[AAudio] Device Disconnected. Failed to post job for rerouting.\n");
- return;
- }
+ result = ma_device_job_thread_post(&pDevice->pContext->aaudio.jobThread, &job);
+ if (result != MA_SUCCESS) {
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[AAudio] Device Disconnected. Failed to post job for rerouting.\n");
+ return;
}
}
@@ -36083,7 +37566,6 @@ static ma_result ma_create_and_configure_AAudioStreamBuilder__aaudio(ma_context*
{
ma_AAudioStreamBuilder* pBuilder;
ma_aaudio_result_t resultAA;
- ma_uint32 bufferCapacityInFrames;
/* Safety. */
*ppBuilder = NULL;
@@ -36125,17 +37607,26 @@ static ma_result ma_create_and_configure_AAudioStreamBuilder__aaudio(ma_context*
}
}
+
/*
- AAudio is annoying when it comes to it's buffer calculation stuff because it doesn't let you
- retrieve the actual sample rate until after you've opened the stream. But you need to configure
- the buffer capacity before you open the stream... :/
-
- To solve, we're just going to assume MA_DEFAULT_SAMPLE_RATE (48000) and move on.
+ There have been reports where setting the frames per data callback results in an error
+ later on from Android. To address this, I'm experimenting with simply not setting it on
+ anything from Android 11 and earlier. Suggestions welcome on how we might be able to make
+ this more targetted.
*/
- bufferCapacityInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, pDescriptor->sampleRate, pConfig->performanceProfile) * pDescriptor->periodCount;
+ if (pConfig->aaudio.enableCompatibilityWorkarounds && ma_android_sdk_version() > 30) {
+ /*
+ AAudio is annoying when it comes to it's buffer calculation stuff because it doesn't let you
+ retrieve the actual sample rate until after you've opened the stream. But you need to configure
+ the buffer capacity before you open the stream... :/
- ((MA_PFN_AAudioStreamBuilder_setBufferCapacityInFrames)pContext->aaudio.AAudioStreamBuilder_setBufferCapacityInFrames)(pBuilder, bufferCapacityInFrames);
- ((MA_PFN_AAudioStreamBuilder_setFramesPerDataCallback)pContext->aaudio.AAudioStreamBuilder_setFramesPerDataCallback)(pBuilder, bufferCapacityInFrames / pDescriptor->periodCount);
+ To solve, we're just going to assume MA_DEFAULT_SAMPLE_RATE (48000) and move on.
+ */
+ ma_uint32 bufferCapacityInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, pDescriptor->sampleRate, pConfig->performanceProfile) * pDescriptor->periodCount;
+
+ ((MA_PFN_AAudioStreamBuilder_setBufferCapacityInFrames)pContext->aaudio.AAudioStreamBuilder_setBufferCapacityInFrames)(pBuilder, bufferCapacityInFrames);
+ ((MA_PFN_AAudioStreamBuilder_setFramesPerDataCallback)pContext->aaudio.AAudioStreamBuilder_setFramesPerDataCallback)(pBuilder, bufferCapacityInFrames / pDescriptor->periodCount);
+ }
if (deviceType == ma_device_type_capture) {
if (pConfig->aaudio.inputPreset != ma_aaudio_input_preset_default && pContext->aaudio.AAudioStreamBuilder_setInputPreset != NULL) {
@@ -36152,6 +37643,10 @@ static ma_result ma_create_and_configure_AAudioStreamBuilder__aaudio(ma_context*
((MA_PFN_AAudioStreamBuilder_setContentType)pContext->aaudio.AAudioStreamBuilder_setContentType)(pBuilder, ma_to_content_type__aaudio(pConfig->aaudio.contentType));
}
+ if (pConfig->aaudio.allowedCapturePolicy != ma_aaudio_allow_capture_default && pContext->aaudio.AAudioStreamBuilder_setAllowedCapturePolicy != NULL) {
+ ((MA_PFN_AAudioStreamBuilder_setAllowedCapturePolicy)pContext->aaudio.AAudioStreamBuilder_setAllowedCapturePolicy)(pBuilder, ma_to_allowed_capture_policy__aaudio(pConfig->aaudio.allowedCapturePolicy));
+ }
+
((MA_PFN_AAudioStreamBuilder_setDataCallback)pContext->aaudio.AAudioStreamBuilder_setDataCallback)(pBuilder, ma_stream_data_callback_playback__aaudio, (void*)pDevice);
}
@@ -36419,6 +37914,7 @@ static ma_result ma_device_init__aaudio(ma_device* pDevice, const ma_device_conf
pDevice->aaudio.usage = pConfig->aaudio.usage;
pDevice->aaudio.contentType = pConfig->aaudio.contentType;
pDevice->aaudio.inputPreset = pConfig->aaudio.inputPreset;
+ pDevice->aaudio.allowedCapturePolicy = pConfig->aaudio.allowedCapturePolicy;
pDevice->aaudio.noAutoStartAfterReroute = pConfig->aaudio.noAutoStartAfterReroute;
if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
@@ -36595,6 +38091,7 @@ static ma_result ma_device_reinit__aaudio(ma_device* pDevice, ma_device_type dev
deviceConfig.aaudio.usage = pDevice->aaudio.usage;
deviceConfig.aaudio.contentType = pDevice->aaudio.contentType;
deviceConfig.aaudio.inputPreset = pDevice->aaudio.inputPreset;
+ deviceConfig.aaudio.allowedCapturePolicy = pDevice->aaudio.allowedCapturePolicy;
deviceConfig.aaudio.noAutoStartAfterReroute = pDevice->aaudio.noAutoStartAfterReroute;
deviceConfig.periods = 1;
@@ -36730,6 +38227,7 @@ static ma_result ma_context_init__aaudio(ma_context* pContext, const ma_context_
pContext->aaudio.AAudioStreamBuilder_setUsage = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setUsage");
pContext->aaudio.AAudioStreamBuilder_setContentType = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setContentType");
pContext->aaudio.AAudioStreamBuilder_setInputPreset = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setInputPreset");
+ pContext->aaudio.AAudioStreamBuilder_setAllowedCapturePolicy = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setAllowedCapturePolicy");
pContext->aaudio.AAudioStreamBuilder_openStream = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_openStream");
pContext->aaudio.AAudioStream_close = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_close");
pContext->aaudio.AAudioStream_getState = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getState");
@@ -36772,7 +38270,7 @@ static ma_result ma_context_init__aaudio(ma_context* pContext, const ma_context_
return result;
}
}
-
+
(void)pConfig;
return MA_SUCCESS;
@@ -38071,6 +39569,29 @@ Web Audio Backend
#ifdef MA_HAS_WEBAUDIO
#include
+#if (__EMSCRIPTEN_major__ > 3) || (__EMSCRIPTEN_major__ == 3 && (__EMSCRIPTEN_minor__ > 1 || (__EMSCRIPTEN_minor__ == 1 && __EMSCRIPTEN_tiny__ >= 32)))
+ #include
+ #define MA_SUPPORT_AUDIO_WORKLETS
+#endif
+
+/*
+TODO: Version 0.12: Swap this logic around so that AudioWorklets are used by default. Add MA_NO_AUDIO_WORKLETS.
+*/
+#if defined(MA_ENABLE_AUDIO_WORKLETS) && defined(MA_SUPPORT_AUDIO_WORKLETS)
+ #define MA_USE_AUDIO_WORKLETS
+#endif
+
+/* The thread stack size must be a multiple of 16. */
+#ifndef MA_AUDIO_WORKLETS_THREAD_STACK_SIZE
+#define MA_AUDIO_WORKLETS_THREAD_STACK_SIZE 16384
+#endif
+
+#if defined(MA_USE_AUDIO_WORKLETS)
+#define MA_WEBAUDIO_LATENCY_HINT_BALANCED "balanced"
+#define MA_WEBAUDIO_LATENCY_HINT_INTERACTIVE "interactive"
+#define MA_WEBAUDIO_LATENCY_HINT_PLAYBACK "playback"
+#endif
+
static ma_bool32 ma_is_capture_supported__webaudio()
{
return EM_ASM_INT({
@@ -38081,6 +39602,16 @@ static ma_bool32 ma_is_capture_supported__webaudio()
#ifdef __cplusplus
extern "C" {
#endif
+void* EMSCRIPTEN_KEEPALIVE ma_malloc_emscripten(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks)
+{
+ return ma_malloc(sz, pAllocationCallbacks);
+}
+
+void EMSCRIPTEN_KEEPALIVE ma_free_emscripten(void* p, const ma_allocation_callbacks* pAllocationCallbacks)
+{
+ ma_free(p, pAllocationCallbacks);
+}
+
void EMSCRIPTEN_KEEPALIVE ma_device_process_pcm_frames_capture__webaudio(ma_device* pDevice, int frameCount, float* pFrames)
{
ma_device_handle_backend_data_callback(pDevice, NULL, pFrames, (ma_uint32)frameCount);
@@ -38171,13 +39702,14 @@ static ma_result ma_context_get_device_info__webaudio(ma_context* pContext, ma_d
return MA_SUCCESS;
}
-
+#if !defined(MA_USE_AUDIO_WORKLETS)
static void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_type deviceType, int deviceIndex)
{
MA_ASSERT(pDevice != NULL);
EM_ASM({
var device = miniaudio.get_device_by_index($0);
+ var pAllocationCallbacks = $3;
/* Make sure all nodes are disconnected and marked for collection. */
if (device.scriptNode !== undefined) {
@@ -38199,7 +39731,7 @@ static void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_ty
/* Can't forget to free the intermediary buffer. This is the buffer that's shared between JavaScript and C. */
if (device.intermediaryBuffer !== undefined) {
- Module._free(device.intermediaryBuffer);
+ _ma_free_emscripten(device.intermediaryBuffer, pAllocationCallbacks);
device.intermediaryBuffer = undefined;
device.intermediaryBufferView = undefined;
device.intermediaryBufferSizeInBytes = undefined;
@@ -38207,7 +39739,32 @@ static void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_ty
/* Make sure the device is untracked so the slot can be reused later. */
miniaudio.untrack_device_by_index($0);
- }, deviceIndex, deviceType);
+ }, deviceIndex, deviceType, &pDevice->pContext->allocationCallbacks);
+}
+#endif
+
+static void ma_device_uninit_by_type__webaudio(ma_device* pDevice, ma_device_type deviceType)
+{
+ MA_ASSERT(pDevice != NULL);
+ MA_ASSERT(deviceType == ma_device_type_capture || deviceType == ma_device_type_playback);
+
+#if defined(MA_USE_AUDIO_WORKLETS)
+ if (deviceType == ma_device_type_capture) {
+ ma_free(pDevice->webaudio.pIntermediaryBufferCapture, &pDevice->pContext->allocationCallbacks);
+ ma_free(pDevice->webaudio.pStackBufferCapture, &pDevice->pContext->allocationCallbacks);
+ emscripten_destroy_audio_context(pDevice->webaudio.audioContextCapture);
+ } else {
+ ma_free(pDevice->webaudio.pIntermediaryBufferPlayback, &pDevice->pContext->allocationCallbacks);
+ ma_free(pDevice->webaudio.pStackBufferPlayback, &pDevice->pContext->allocationCallbacks);
+ emscripten_destroy_audio_context(pDevice->webaudio.audioContextPlayback);
+ }
+#else
+ if (deviceType == ma_device_type_capture) {
+ ma_device_uninit_by_index__webaudio(pDevice, ma_device_type_capture, pDevice->webaudio.indexCapture);
+ } else {
+ ma_device_uninit_by_index__webaudio(pDevice, ma_device_type_playback, pDevice->webaudio.indexPlayback);
+ }
+#endif
}
static ma_result ma_device_uninit__webaudio(ma_device* pDevice)
@@ -38215,11 +39772,11 @@ static ma_result ma_device_uninit__webaudio(ma_device* pDevice)
MA_ASSERT(pDevice != NULL);
if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
- ma_device_uninit_by_index__webaudio(pDevice, ma_device_type_capture, pDevice->webaudio.indexCapture);
+ ma_device_uninit_by_type__webaudio(pDevice, ma_device_type_capture);
}
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
- ma_device_uninit_by_index__webaudio(pDevice, ma_device_type_playback, pDevice->webaudio.indexPlayback);
+ ma_device_uninit_by_type__webaudio(pDevice, ma_device_type_playback);
}
return MA_SUCCESS;
@@ -38227,10 +39784,16 @@ static ma_result ma_device_uninit__webaudio(ma_device* pDevice)
static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__webaudio(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile)
{
+#if defined(MA_USE_AUDIO_WORKLETS)
+ (void)pDescriptor;
+ (void)nativeSampleRate;
+ (void)performanceProfile;
+
+ return 256;
+#else
/*
- There have been reports of the default buffer size being too small on some browsers. There have been reports of the default buffer
- size being too small on some browsers. If we're using default buffer size, we'll make sure the period size is a big biffer than our
- standard defaults.
+ There have been reports of the default buffer size being too small on some browsers. If we're using
+ the default buffer size, we'll make sure the period size is bigger than our standard defaults.
*/
ma_uint32 periodSizeInFrames;
@@ -38258,11 +39821,177 @@ static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__webaudio(co
}
return periodSizeInFrames;
+#endif
}
+
+#if defined(MA_USE_AUDIO_WORKLETS)
+typedef struct
+{
+ ma_device* pDevice;
+ const ma_device_config* pConfig;
+ ma_device_descriptor* pDescriptor;
+ ma_device_type deviceType;
+ ma_uint32 channels;
+} ma_audio_worklet_thread_initialized_data;
+
+static EM_BOOL ma_audio_worklet_process_callback__webaudio(int inputCount, const AudioSampleFrame* pInputs, int outputCount, AudioSampleFrame* pOutputs, int paramCount, const AudioParamFrame* pParams, void* pUserData)
+{
+ ma_device* pDevice = (ma_device*)pUserData;
+ ma_uint32 frameCount;
+ ma_uint32 framesProcessed;
+
+ (void)paramCount;
+ (void)pParams;
+
+ /*
+ The Emscripten documentation says that it'll always be 128 frames being passed in. Hard coding it like that feels
+ like a very bad idea to me. Even if it's hard coded in the backend, the API and documentation should always refer
+ to variables instead of a hard coded number. In any case, will follow along for the time being.
+
+ Unfortunately the audio data is not interleaved so we'll need to convert it before we give the data to miniaudio
+ for further processing.
+ */
+ frameCount = 128;
+
+ /* Run the conversion logic in a loop for robustness. */
+ framesProcessed = 0;
+ while (framesProcessed < frameCount) {
+ ma_uint32 framesToProcessThisIteration = frameCount - framesProcessed;
+
+ if (inputCount > 0) {
+ if (framesToProcessThisIteration > pDevice->webaudio.intermediaryBufferSizeInFramesPlayback) {
+ framesToProcessThisIteration = pDevice->webaudio.intermediaryBufferSizeInFramesPlayback;
+ }
+
+ /* Input data needs to be interleaved before we hand it to the client. */
+ for (ma_uint32 iFrame = 0; iFrame < framesToProcessThisIteration; iFrame += 1) {
+ for (ma_uint32 iChannel = 0; iChannel < pDevice->capture.internalChannels; iChannel += 1) {
+ pDevice->webaudio.pIntermediaryBufferCapture[iFrame*pDevice->capture.internalChannels + iChannel] = pInputs[0].data[frameCount*iChannel + framesProcessed + iFrame];
+ }
+ }
+
+ ma_device_process_pcm_frames_capture__webaudio(pDevice, framesToProcessThisIteration, pDevice->webaudio.pIntermediaryBufferCapture);
+ }
+
+ if (outputCount > 0) {
+ ma_device_process_pcm_frames_playback__webaudio(pDevice, framesToProcessThisIteration, pDevice->webaudio.pIntermediaryBufferPlayback);
+
+ /* We've read the data from the client. Now we need to deinterleave the buffer and output to the output buffer. */
+ for (ma_uint32 iFrame = 0; iFrame < framesToProcessThisIteration; iFrame += 1) {
+ for (ma_uint32 iChannel = 0; iChannel < pDevice->playback.internalChannels; iChannel += 1) {
+ pOutputs[0].data[frameCount*iChannel + framesProcessed + iFrame] = pDevice->webaudio.pIntermediaryBufferPlayback[iFrame*pDevice->playback.internalChannels + iChannel];
+ }
+ }
+ }
+
+ framesProcessed += framesToProcessThisIteration;
+ }
+
+ return EM_TRUE;
+}
+
+
+static void ma_audio_worklet_processor_created__webaudio(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void* pUserData)
+{
+ ma_audio_worklet_thread_initialized_data* pParameters = (ma_audio_worklet_thread_initialized_data*)pUserData;
+ EmscriptenAudioWorkletNodeCreateOptions workletNodeOptions;
+ EMSCRIPTEN_AUDIO_WORKLET_NODE_T workletNode;
+ int outputChannelCount = 0;
+
+ if (success == EM_FALSE) {
+ pParameters->pDevice->webaudio.isInitialized = MA_TRUE;
+ return;
+ }
+
+ MA_ZERO_OBJECT(&workletNodeOptions);
+
+ if (pParameters->deviceType == ma_device_type_capture) {
+ workletNodeOptions.numberOfInputs = 1;
+ } else {
+ outputChannelCount = (int)pParameters->channels; /* Safe cast. */
+
+ workletNodeOptions.numberOfOutputs = 1;
+ workletNodeOptions.outputChannelCounts = &outputChannelCount;
+ }
+
+ /* Here is where we create the node that will do our processing. */
+ workletNode = emscripten_create_wasm_audio_worklet_node(audioContext, "miniaudio", &workletNodeOptions, &ma_audio_worklet_process_callback__webaudio, pParameters->pDevice);
+
+ if (pParameters->deviceType == ma_device_type_capture) {
+ pParameters->pDevice->webaudio.workletNodeCapture = workletNode;
+ } else {
+ pParameters->pDevice->webaudio.workletNodePlayback = workletNode;
+ }
+
+ /*
+ With the worklet node created we can now attach it to the graph. This is done differently depending on whether or not
+ it's capture or playback mode.
+ */
+ if (pParameters->deviceType == ma_device_type_capture) {
+ EM_ASM({
+ var workletNode = emscriptenGetAudioObject($0);
+ var audioContext = emscriptenGetAudioObject($1);
+
+ navigator.mediaDevices.getUserMedia({audio:true, video:false})
+ .then(function(stream) {
+ audioContext.streamNode = audioContext.createMediaStreamSource(stream);
+ audioContext.streamNode.connect(workletNode);
+
+ /*
+ Now that the worklet node has been connected, do we need to inspect workletNode.channelCount
+ to check the actual channel count, or is it safe to assume it's always 2?
+ */
+ })
+ .catch(function(error) {
+
+ });
+ }, workletNode, audioContext);
+ } else {
+ EM_ASM({
+ var workletNode = emscriptenGetAudioObject($0);
+ var audioContext = emscriptenGetAudioObject($1);
+ workletNode.connect(audioContext.destination);
+ }, workletNode, audioContext);
+ }
+
+ pParameters->pDevice->webaudio.isInitialized = MA_TRUE;
+
+ ma_log_postf(ma_device_get_log(pParameters->pDevice), MA_LOG_LEVEL_DEBUG, "AudioWorklets: Created worklet node: %d\n", workletNode);
+
+ /* Our parameter data is no longer needed. */
+ ma_free(pParameters, &pParameters->pDevice->pContext->allocationCallbacks);
+}
+
+
+
+static void ma_audio_worklet_thread_initialized__webaudio(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void* pUserData)
+{
+ ma_audio_worklet_thread_initialized_data* pParameters = (ma_audio_worklet_thread_initialized_data*)pUserData;
+ WebAudioWorkletProcessorCreateOptions workletProcessorOptions;
+
+ MA_ASSERT(pParameters != NULL);
+
+ if (success == EM_FALSE) {
+ pParameters->pDevice->webaudio.isInitialized = MA_TRUE;
+ return;
+ }
+
+ MA_ZERO_OBJECT(&workletProcessorOptions);
+ workletProcessorOptions.name = "miniaudio"; /* I'm not entirely sure what to call this. Does this need to be globally unique, or does it need only be unique for a given AudioContext? */
+
+ emscripten_create_wasm_audio_worklet_processor_async(audioContext, &workletProcessorOptions, ma_audio_worklet_processor_created__webaudio, pParameters);
+}
+#endif
+
static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType)
{
- int deviceIndex;
+#if defined(MA_USE_AUDIO_WORKLETS)
+ EMSCRIPTEN_WEBAUDIO_T audioContext;
+ void* pStackBuffer;
+ size_t intermediaryBufferSizeInFrames;
+ float* pIntermediaryBuffer;
+#endif
ma_uint32 channels;
ma_uint32 sampleRate;
ma_uint32 periodSizeInFrames;
@@ -38282,13 +40011,99 @@ static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_d
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "periodSizeInFrames = %d\n", (int)periodSizeInFrames);
+#if defined(MA_USE_AUDIO_WORKLETS)
+ {
+ ma_audio_worklet_thread_initialized_data* pInitParameters;
+ EmscriptenWebAudioCreateAttributes audioContextAttributes;
+
+ audioContextAttributes.latencyHint = MA_WEBAUDIO_LATENCY_HINT_INTERACTIVE;
+ audioContextAttributes.sampleRate = sampleRate;
+
+ /* It's not clear if this can return an error. None of the tests in the Emscripten repository check for this, so neither am I for now. */
+ audioContext = emscripten_create_audio_context(&audioContextAttributes);
+
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "TRACE: AUDIO CONTEXT CREATED\n");
+
+ /*
+ We now need to create a worker thread. This is a bit weird because we need to allocate our
+ own buffer for the thread's stack. The stack needs to be aligned to 16 bytes. I'm going to
+ allocate this on the heap to keep it simple.
+ */
+ pStackBuffer = ma_aligned_malloc(MA_AUDIO_WORKLETS_THREAD_STACK_SIZE, 16, &pDevice->pContext->allocationCallbacks);
+ if (pStackBuffer == NULL) {
+ emscripten_destroy_audio_context(audioContext);
+ return MA_OUT_OF_MEMORY;
+ }
+
+ /*
+ We need an intermediary buffer for data conversion. WebAudio reports data in uninterleaved
+ format whereas we require it to be interleaved. We'll do this in chunks of 128 frames.
+ */
+ intermediaryBufferSizeInFrames = 128;
+ pIntermediaryBuffer = ma_malloc(intermediaryBufferSizeInFrames * channels * sizeof(float), &pDevice->pContext->allocationCallbacks);
+ if (pIntermediaryBuffer == NULL) {
+ ma_free(pStackBuffer, &pDevice->pContext->allocationCallbacks);
+ emscripten_destroy_audio_context(audioContext);
+ return MA_OUT_OF_MEMORY;
+ }
+
+ pInitParameters = ma_malloc(sizeof(*pInitParameters), &pDevice->pContext->allocationCallbacks);
+ if (pInitParameters == NULL) {
+ ma_free(pIntermediaryBuffer, &pDevice->pContext->allocationCallbacks);
+ ma_free(pStackBuffer, &pDevice->pContext->allocationCallbacks);
+ emscripten_destroy_audio_context(audioContext);
+ return MA_OUT_OF_MEMORY;
+ }
+
+ pInitParameters->pDevice = pDevice;
+ pInitParameters->pConfig = pConfig;
+ pInitParameters->pDescriptor = pDescriptor;
+ pInitParameters->deviceType = deviceType;
+ pInitParameters->channels = channels;
+
+ /*
+ We need to flag the device as not yet initialized so we can wait on it later. Unfortunately all of
+ the Emscripten WebAudio stuff is asynchronous.
+ */
+ pDevice->webaudio.isInitialized = MA_FALSE;
+
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "TRACE: CREATING WORKLET\n");
+
+ emscripten_start_wasm_audio_worklet_thread_async(audioContext, pStackBuffer, MA_AUDIO_WORKLETS_THREAD_STACK_SIZE, ma_audio_worklet_thread_initialized__webaudio, pInitParameters);
+
+ /* We must wait for initialization to complete. We're just spinning here. The emscripten_sleep() call is why we need to build with `-sASYNCIFY`. */
+ while (pDevice->webaudio.isInitialized == MA_FALSE) {
+ emscripten_sleep(1);
+ }
+
+ /*
+ Now that initialization is finished we can go ahead and extract our channel count so that
+ miniaudio can set up a data converter at a higher level.
+ */
+ if (deviceType == ma_device_type_capture) {
+ /*
+ For capture we won't actually know what the channel count is. Everything I've seen seems
+ to indicate that the default channel count is 2, so I'm sticking with that.
+ */
+ channels = 2;
+ } else {
+ /* Get the channel count from the audio context. */
+ channels = (ma_uint32)EM_ASM_INT({
+ return emscriptenGetAudioObject($0).destination.channelCount;
+ }, audioContext);
+ }
+
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "TRACE: INITIALIZED. channels = %u\n", channels);
+ }
+#else
/* We create the device on the JavaScript side and reference it using an index. We use this to make it possible to reference the device between JavaScript and C. */
- deviceIndex = EM_ASM_INT({
- var channels = $0;
- var sampleRate = $1;
- var bufferSize = $2; /* In PCM frames. */
- var isCapture = $3;
- var pDevice = $4;
+ int deviceIndex = EM_ASM_INT({
+ var channels = $0;
+ var sampleRate = $1;
+ var bufferSize = $2; /* In PCM frames. */
+ var isCapture = $3;
+ var pDevice = $4;
+ var pAllocationCallbacks = $5;
if (typeof(window.miniaudio) === 'undefined') {
return -1; /* Context not initialized. */
@@ -38301,12 +40116,9 @@ static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_d
device.webaudio.suspend();
device.state = 1; /* ma_device_state_stopped */
- /*
- We need an intermediary buffer which we use for JavaScript and C interop. This buffer stores interleaved f32 PCM data. Because it's passed between
- JavaScript and C it needs to be allocated and freed using Module._malloc() and Module._free().
- */
+ /* We need an intermediary buffer which we use for JavaScript and C interop. This buffer stores interleaved f32 PCM data. */
device.intermediaryBufferSizeInBytes = channels * bufferSize * 4;
- device.intermediaryBuffer = Module._malloc(device.intermediaryBufferSizeInBytes);
+ device.intermediaryBuffer = _ma_malloc_emscripten(device.intermediaryBufferSizeInBytes, pAllocationCallbacks);
device.intermediaryBufferView = new Float32Array(Module.HEAPF32.buffer, device.intermediaryBuffer, device.intermediaryBufferSizeInBytes);
/*
@@ -38376,7 +40188,7 @@ static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_d
}
/* Send data to the client from our intermediary buffer. */
- ccall("ma_device_process_pcm_frames_capture__webaudio", "undefined", ["number", "number", "number"], [pDevice, framesToProcess, device.intermediaryBuffer]);
+ _ma_device_process_pcm_frames_capture__webaudio(pDevice, framesToProcess, device.intermediaryBuffer);
totalFramesProcessed += framesToProcess;
}
@@ -38422,7 +40234,7 @@ static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_d
}
/* Read data from the client into our intermediary buffer. */
- ccall("ma_device_process_pcm_frames_playback__webaudio", "undefined", ["number", "number", "number"], [pDevice, framesToProcess, device.intermediaryBuffer]);
+ _ma_device_process_pcm_frames_playback__webaudio(pDevice, framesToProcess, device.intermediaryBuffer);
/* At this point we'll have data in our intermediary buffer which we now need to deinterleave and copy over to the output buffers. */
if (outputSilence) {
@@ -38447,25 +40259,45 @@ static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_d
}
return miniaudio.track_device(device);
- }, channels, sampleRate, periodSizeInFrames, deviceType == ma_device_type_capture, pDevice);
+ }, channels, sampleRate, periodSizeInFrames, deviceType == ma_device_type_capture, pDevice, &pDevice->pContext->allocationCallbacks);
if (deviceIndex < 0) {
return MA_FAILED_TO_OPEN_BACKEND_DEVICE;
}
+#endif
+#if defined(MA_USE_AUDIO_WORKLETS)
+ if (deviceType == ma_device_type_capture) {
+ pDevice->webaudio.audioContextCapture = audioContext;
+ pDevice->webaudio.pStackBufferCapture = pStackBuffer;
+ pDevice->webaudio.intermediaryBufferSizeInFramesCapture = intermediaryBufferSizeInFrames;
+ pDevice->webaudio.pIntermediaryBufferCapture = pIntermediaryBuffer;
+ } else {
+ pDevice->webaudio.audioContextPlayback = audioContext;
+ pDevice->webaudio.pStackBufferPlayback = pStackBuffer;
+ pDevice->webaudio.intermediaryBufferSizeInFramesPlayback = intermediaryBufferSizeInFrames;
+ pDevice->webaudio.pIntermediaryBufferPlayback = pIntermediaryBuffer;
+ }
+#else
if (deviceType == ma_device_type_capture) {
pDevice->webaudio.indexCapture = deviceIndex;
} else {
pDevice->webaudio.indexPlayback = deviceIndex;
}
+#endif
pDescriptor->format = ma_format_f32;
pDescriptor->channels = channels;
ma_channel_map_init_standard(ma_standard_channel_map_webaudio, pDescriptor->channelMap, ma_countof(pDescriptor->channelMap), pDescriptor->channels);
- pDescriptor->sampleRate = EM_ASM_INT({ return miniaudio.get_device_by_index($0).webaudio.sampleRate; }, deviceIndex);
pDescriptor->periodSizeInFrames = periodSizeInFrames;
pDescriptor->periodCount = 1;
+#if defined(MA_USE_AUDIO_WORKLETS)
+ pDescriptor->sampleRate = sampleRate; /* Is this good enough to be used in the general case? */
+#else
+ pDescriptor->sampleRate = EM_ASM_INT({ return miniaudio.get_device_by_index($0).webaudio.sampleRate; }, deviceIndex);
+#endif
+
return MA_SUCCESS;
}
@@ -38494,7 +40326,7 @@ static ma_result ma_device_init__webaudio(ma_device* pDevice, const ma_device_co
result = ma_device_init_by_type__webaudio(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback);
if (result != MA_SUCCESS) {
if (pConfig->deviceType == ma_device_type_duplex) {
- ma_device_uninit_by_index__webaudio(pDevice, ma_device_type_capture, pDevice->webaudio.indexCapture);
+ ma_device_uninit_by_type__webaudio(pDevice, ma_device_type_capture);
}
return result;
}
@@ -38507,6 +40339,15 @@ static ma_result ma_device_start__webaudio(ma_device* pDevice)
{
MA_ASSERT(pDevice != NULL);
+#if defined(MA_USE_AUDIO_WORKLETS)
+ if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
+ emscripten_resume_audio_context_sync(pDevice->webaudio.audioContextCapture);
+ }
+
+ if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
+ emscripten_resume_audio_context_sync(pDevice->webaudio.audioContextPlayback);
+ }
+#else
if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
EM_ASM({
var device = miniaudio.get_device_by_index($0);
@@ -38522,6 +40363,7 @@ static ma_result ma_device_start__webaudio(ma_device* pDevice)
device.state = 2; /* ma_device_state_started */
}, pDevice->webaudio.indexPlayback);
}
+#endif
return MA_SUCCESS;
}
@@ -38540,6 +40382,20 @@ static ma_result ma_device_stop__webaudio(ma_device* pDevice)
do any kind of explicit draining.
*/
+#if defined(MA_USE_AUDIO_WORKLETS)
+ /* I can't seem to find a way to suspend an AudioContext via the C Emscripten API. Is this an oversight? */
+ if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
+ EM_ASM({
+ emscriptenGetAudioObject($0).suspend();
+ }, pDevice->webaudio.audioContextCapture);
+ }
+
+ if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
+ EM_ASM({
+ emscriptenGetAudioObject($0).suspend();
+ }, pDevice->webaudio.audioContextPlayback);
+ }
+#else
if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
EM_ASM({
var device = miniaudio.get_device_by_index($0);
@@ -38555,6 +40411,7 @@ static ma_result ma_device_stop__webaudio(ma_device* pDevice)
device.state = 1; /* ma_device_state_stopped */
}, pDevice->webaudio.indexPlayback);
}
+#endif
ma_device__on_notification_stopped(pDevice);
@@ -38566,8 +40423,17 @@ static ma_result ma_context_uninit__webaudio(ma_context* pContext)
MA_ASSERT(pContext != NULL);
MA_ASSERT(pContext->backend == ma_backend_webaudio);
- /* Nothing needs to be done here. */
- (void)pContext;
+ (void)pContext; /* Unused. */
+
+ /* Remove the global miniaudio object from window if there are no more references to it. */
+ EM_ASM({
+ if (typeof(window.miniaudio) !== 'undefined') {
+ window.miniaudio.referenceCount--;
+ if (window.miniaudio.referenceCount === 0) {
+ delete window.miniaudio;
+ }
+ }
+ });
return MA_SUCCESS;
}
@@ -38582,12 +40448,14 @@ static ma_result ma_context_init__webaudio(ma_context* pContext, const ma_contex
/* Here is where our global JavaScript object is initialized. */
resultFromJS = EM_ASM_INT({
- if ((window.AudioContext || window.webkitAudioContext) === undefined) {
+ if (typeof window === 'undefined' || (window.AudioContext || window.webkitAudioContext) === undefined) {
return 0; /* Web Audio not supported. */
}
if (typeof(window.miniaudio) === 'undefined') {
- window.miniaudio = {};
+ window.miniaudio = {
+ referenceCount: 0
+ };
miniaudio.devices = []; /* Device cache for mapping devices to indexes for JavaScript/C interop. */
miniaudio.track_device = function(device) {
@@ -38651,6 +40519,8 @@ static ma_result ma_context_init__webaudio(ma_context* pContext, const ma_contex
});
}
+ window.miniaudio.referenceCount++;
+
return 1;
}, 0); /* Must pass in a dummy argument for C99 compatibility. */
@@ -38701,6 +40571,22 @@ static ma_bool32 ma__is_channel_map_valid(const ma_channel* pChannelMap, ma_uint
}
+static ma_bool32 ma_context_is_backend_asynchronous(ma_context* pContext)
+{
+ MA_ASSERT(pContext != NULL);
+
+ if (pContext->callbacks.onDeviceRead == NULL && pContext->callbacks.onDeviceWrite == NULL) {
+ if (pContext->callbacks.onDeviceDataLoop == NULL) {
+ return MA_TRUE;
+ } else {
+ return MA_FALSE;
+ }
+ } else {
+ return MA_FALSE;
+ }
+}
+
+
static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type deviceType)
{
ma_result result;
@@ -38761,20 +40647,21 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d
if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex || deviceType == ma_device_type_loopback) {
/* Converting from internal device format to client format. */
ma_data_converter_config converterConfig = ma_data_converter_config_init_default();
- converterConfig.formatIn = pDevice->capture.internalFormat;
- converterConfig.channelsIn = pDevice->capture.internalChannels;
- converterConfig.sampleRateIn = pDevice->capture.internalSampleRate;
- converterConfig.pChannelMapIn = pDevice->capture.internalChannelMap;
- converterConfig.formatOut = pDevice->capture.format;
- converterConfig.channelsOut = pDevice->capture.channels;
- converterConfig.sampleRateOut = pDevice->sampleRate;
- converterConfig.pChannelMapOut = pDevice->capture.channelMap;
- converterConfig.channelMixMode = pDevice->capture.channelMixMode;
- converterConfig.allowDynamicSampleRate = MA_FALSE;
- converterConfig.resampling.algorithm = pDevice->resampling.algorithm;
- converterConfig.resampling.linear.lpfOrder = pDevice->resampling.linear.lpfOrder;
- converterConfig.resampling.pBackendVTable = pDevice->resampling.pBackendVTable;
- converterConfig.resampling.pBackendUserData = pDevice->resampling.pBackendUserData;
+ converterConfig.formatIn = pDevice->capture.internalFormat;
+ converterConfig.channelsIn = pDevice->capture.internalChannels;
+ converterConfig.sampleRateIn = pDevice->capture.internalSampleRate;
+ converterConfig.pChannelMapIn = pDevice->capture.internalChannelMap;
+ converterConfig.formatOut = pDevice->capture.format;
+ converterConfig.channelsOut = pDevice->capture.channels;
+ converterConfig.sampleRateOut = pDevice->sampleRate;
+ converterConfig.pChannelMapOut = pDevice->capture.channelMap;
+ converterConfig.channelMixMode = pDevice->capture.channelMixMode;
+ converterConfig.calculateLFEFromSpatialChannels = pDevice->capture.calculateLFEFromSpatialChannels;
+ converterConfig.allowDynamicSampleRate = MA_FALSE;
+ converterConfig.resampling.algorithm = pDevice->resampling.algorithm;
+ converterConfig.resampling.linear.lpfOrder = pDevice->resampling.linear.lpfOrder;
+ converterConfig.resampling.pBackendVTable = pDevice->resampling.pBackendVTable;
+ converterConfig.resampling.pBackendUserData = pDevice->resampling.pBackendUserData;
/* Make sure the old converter is uninitialized first. */
if (ma_device_get_state(pDevice) != ma_device_state_uninitialized) {
@@ -38790,20 +40677,21 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d
if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) {
/* Converting from client format to device format. */
ma_data_converter_config converterConfig = ma_data_converter_config_init_default();
- converterConfig.formatIn = pDevice->playback.format;
- converterConfig.channelsIn = pDevice->playback.channels;
- converterConfig.sampleRateIn = pDevice->sampleRate;
- converterConfig.pChannelMapIn = pDevice->playback.channelMap;
- converterConfig.formatOut = pDevice->playback.internalFormat;
- converterConfig.channelsOut = pDevice->playback.internalChannels;
- converterConfig.sampleRateOut = pDevice->playback.internalSampleRate;
- converterConfig.pChannelMapOut = pDevice->playback.internalChannelMap;
- converterConfig.channelMixMode = pDevice->playback.channelMixMode;
- converterConfig.allowDynamicSampleRate = MA_FALSE;
- converterConfig.resampling.algorithm = pDevice->resampling.algorithm;
- converterConfig.resampling.linear.lpfOrder = pDevice->resampling.linear.lpfOrder;
- converterConfig.resampling.pBackendVTable = pDevice->resampling.pBackendVTable;
- converterConfig.resampling.pBackendUserData = pDevice->resampling.pBackendUserData;
+ converterConfig.formatIn = pDevice->playback.format;
+ converterConfig.channelsIn = pDevice->playback.channels;
+ converterConfig.sampleRateIn = pDevice->sampleRate;
+ converterConfig.pChannelMapIn = pDevice->playback.channelMap;
+ converterConfig.formatOut = pDevice->playback.internalFormat;
+ converterConfig.channelsOut = pDevice->playback.internalChannels;
+ converterConfig.sampleRateOut = pDevice->playback.internalSampleRate;
+ converterConfig.pChannelMapOut = pDevice->playback.internalChannelMap;
+ converterConfig.channelMixMode = pDevice->playback.channelMixMode;
+ converterConfig.calculateLFEFromSpatialChannels = pDevice->playback.calculateLFEFromSpatialChannels;
+ converterConfig.allowDynamicSampleRate = MA_FALSE;
+ converterConfig.resampling.algorithm = pDevice->resampling.algorithm;
+ converterConfig.resampling.linear.lpfOrder = pDevice->resampling.linear.lpfOrder;
+ converterConfig.resampling.pBackendVTable = pDevice->resampling.pBackendVTable;
+ converterConfig.resampling.pBackendUserData = pDevice->resampling.pBackendUserData;
/* Make sure the old converter is uninitialized first. */
if (ma_device_get_state(pDevice) != ma_device_state_uninitialized) {
@@ -38818,8 +40706,23 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d
/*
- In playback mode, if the data converter does not support retrieval of the required number of
- input frames given a number of output frames, we need to fall back to a heap-allocated cache.
+ If the device is doing playback (ma_device_type_playback or ma_device_type_duplex), there's
+ a couple of situations where we'll need a heap allocated cache.
+
+ The first is a duplex device for backends that use a callback for data delivery. The reason
+ this is needed is that the input stage needs to have a buffer to place the input data while it
+ waits for the playback stage, after which the miniaudio data callback will get fired. This is
+ not needed for backends that use a blocking API because miniaudio manages temporary buffers on
+ the stack to achieve this.
+
+ The other situation is when the data converter does not have the ability to query the number
+ of input frames that are required in order to process a given number of output frames. When
+ performing data conversion, it's useful if miniaudio know exactly how many frames it needs
+ from the client in order to generate a given number of output frames. This way, only exactly
+ the number of frames are needed to be read from the client which means no cache is necessary.
+ On the other hand, if miniaudio doesn't know how many frames to read, it is forced to read
+ in fixed sized chunks and then cache any residual unused input frames, those of which will be
+ processed at a later stage.
*/
if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) {
ma_uint64 unused;
@@ -38827,7 +40730,9 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d
pDevice->playback.inputCacheConsumed = 0;
pDevice->playback.inputCacheRemaining = 0;
- if (deviceType == ma_device_type_duplex || ma_data_converter_get_required_input_frame_count(&pDevice->playback.converter, 1, &unused) != MA_SUCCESS) {
+ if (pDevice->type == ma_device_type_duplex || /* Duplex. backend may decide to use ma_device_handle_backend_data_callback() which will require this cache. */
+ ma_data_converter_get_required_input_frame_count(&pDevice->playback.converter, 1, &unused) != MA_SUCCESS) /* Data conversion required input frame calculation not supported. */
+ {
/* We need a heap allocated cache. We want to size this based on the period size. */
void* pNewInputCache;
ma_uint64 newInputCacheCap;
@@ -38843,7 +40748,7 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d
return MA_OUT_OF_MEMORY; /* Allocation too big. Should never hit this, but makes the cast below safer for 32-bit builds. */
}
- pNewInputCache = ma_realloc(pDevice->playback.pInputCache, (size_t)newInputCacheSizeInBytes, &pDevice->pContext->allocationCallbacks);
+ pNewInputCache = ma_realloc(pDevice->playback.pInputCache, (size_t)newInputCacheSizeInBytes, &pDevice->pContext->allocationCallbacks);
if (pNewInputCache == NULL) {
ma_free(pDevice->playback.pInputCache, &pDevice->pContext->allocationCallbacks);
pDevice->playback.pInputCache = NULL;
@@ -39063,11 +40968,15 @@ static ma_bool32 ma_device__is_initialized(ma_device* pDevice)
static ma_result ma_context_uninit_backend_apis__win32(ma_context* pContext)
{
/* For some reason UWP complains when CoUninitialize() is called. I'm just not going to call it on UWP. */
-#ifdef MA_WIN32_DESKTOP
+#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)
ma_CoUninitialize(pContext);
- ma_dlclose(pContext, pContext->win32.hUser32DLL);
+
+ #if defined(MA_WIN32_DESKTOP)
+ ma_dlclose(pContext, pContext->win32.hUser32DLL);
+ ma_dlclose(pContext, pContext->win32.hAdvapi32DLL);
+ #endif
+
ma_dlclose(pContext, pContext->win32.hOle32DLL);
- ma_dlclose(pContext, pContext->win32.hAdvapi32DLL);
#else
(void)pContext;
#endif
@@ -39077,40 +40986,44 @@ static ma_result ma_context_uninit_backend_apis__win32(ma_context* pContext)
static ma_result ma_context_init_backend_apis__win32(ma_context* pContext)
{
-#ifdef MA_WIN32_DESKTOP
+#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)
+ #if defined(MA_WIN32_DESKTOP)
+ /* User32.dll */
+ pContext->win32.hUser32DLL = ma_dlopen(pContext, "user32.dll");
+ if (pContext->win32.hUser32DLL == NULL) {
+ return MA_FAILED_TO_INIT_BACKEND;
+ }
+
+ pContext->win32.GetForegroundWindow = (ma_proc)ma_dlsym(pContext, pContext->win32.hUser32DLL, "GetForegroundWindow");
+ pContext->win32.GetDesktopWindow = (ma_proc)ma_dlsym(pContext, pContext->win32.hUser32DLL, "GetDesktopWindow");
+
+
+ /* Advapi32.dll */
+ pContext->win32.hAdvapi32DLL = ma_dlopen(pContext, "advapi32.dll");
+ if (pContext->win32.hAdvapi32DLL == NULL) {
+ return MA_FAILED_TO_INIT_BACKEND;
+ }
+
+ pContext->win32.RegOpenKeyExA = (ma_proc)ma_dlsym(pContext, pContext->win32.hAdvapi32DLL, "RegOpenKeyExA");
+ pContext->win32.RegCloseKey = (ma_proc)ma_dlsym(pContext, pContext->win32.hAdvapi32DLL, "RegCloseKey");
+ pContext->win32.RegQueryValueExA = (ma_proc)ma_dlsym(pContext, pContext->win32.hAdvapi32DLL, "RegQueryValueExA");
+ #endif
+
/* Ole32.dll */
pContext->win32.hOle32DLL = ma_dlopen(pContext, "ole32.dll");
if (pContext->win32.hOle32DLL == NULL) {
return MA_FAILED_TO_INIT_BACKEND;
}
+ pContext->win32.CoInitialize = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "CoInitialize");
pContext->win32.CoInitializeEx = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "CoInitializeEx");
pContext->win32.CoUninitialize = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "CoUninitialize");
pContext->win32.CoCreateInstance = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "CoCreateInstance");
pContext->win32.CoTaskMemFree = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "CoTaskMemFree");
pContext->win32.PropVariantClear = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "PropVariantClear");
pContext->win32.StringFromGUID2 = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "StringFromGUID2");
-
-
- /* User32.dll */
- pContext->win32.hUser32DLL = ma_dlopen(pContext, "user32.dll");
- if (pContext->win32.hUser32DLL == NULL) {
- return MA_FAILED_TO_INIT_BACKEND;
- }
-
- pContext->win32.GetForegroundWindow = (ma_proc)ma_dlsym(pContext, pContext->win32.hUser32DLL, "GetForegroundWindow");
- pContext->win32.GetDesktopWindow = (ma_proc)ma_dlsym(pContext, pContext->win32.hUser32DLL, "GetDesktopWindow");
-
-
- /* Advapi32.dll */
- pContext->win32.hAdvapi32DLL = ma_dlopen(pContext, "advapi32.dll");
- if (pContext->win32.hAdvapi32DLL == NULL) {
- return MA_FAILED_TO_INIT_BACKEND;
- }
-
- pContext->win32.RegOpenKeyExA = (ma_proc)ma_dlsym(pContext, pContext->win32.hAdvapi32DLL, "RegOpenKeyExA");
- pContext->win32.RegCloseKey = (ma_proc)ma_dlsym(pContext, pContext->win32.hAdvapi32DLL, "RegCloseKey");
- pContext->win32.RegQueryValueExA = (ma_proc)ma_dlsym(pContext, pContext->win32.hAdvapi32DLL, "RegQueryValueExA");
+#else
+ (void)pContext; /* Unused. */
#endif
ma_CoInitializeEx(pContext, NULL, MA_COINIT_VALUE);
@@ -39119,71 +41032,14 @@ static ma_result ma_context_init_backend_apis__win32(ma_context* pContext)
#else
static ma_result ma_context_uninit_backend_apis__nix(ma_context* pContext)
{
-#if defined(MA_USE_RUNTIME_LINKING_FOR_PTHREAD) && !defined(MA_NO_RUNTIME_LINKING)
- ma_dlclose(pContext, pContext->posix.pthreadSO);
-#else
(void)pContext;
-#endif
return MA_SUCCESS;
}
static ma_result ma_context_init_backend_apis__nix(ma_context* pContext)
{
- /* pthread */
-#if defined(MA_USE_RUNTIME_LINKING_FOR_PTHREAD) && !defined(MA_NO_RUNTIME_LINKING)
- const char* libpthreadFileNames[] = {
- "libpthread.so",
- "libpthread.so.0",
- "libpthread.dylib"
- };
- size_t i;
-
- for (i = 0; i < sizeof(libpthreadFileNames) / sizeof(libpthreadFileNames[0]); ++i) {
- pContext->posix.pthreadSO = ma_dlopen(pContext, libpthreadFileNames[i]);
- if (pContext->posix.pthreadSO != NULL) {
- break;
- }
- }
-
- if (pContext->posix.pthreadSO == NULL) {
- return MA_FAILED_TO_INIT_BACKEND;
- }
-
- pContext->posix.pthread_create = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_create");
- pContext->posix.pthread_join = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_join");
- pContext->posix.pthread_mutex_init = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_mutex_init");
- pContext->posix.pthread_mutex_destroy = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_mutex_destroy");
- pContext->posix.pthread_mutex_lock = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_mutex_lock");
- pContext->posix.pthread_mutex_unlock = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_mutex_unlock");
- pContext->posix.pthread_cond_init = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_cond_init");
- pContext->posix.pthread_cond_destroy = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_cond_destroy");
- pContext->posix.pthread_cond_wait = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_cond_wait");
- pContext->posix.pthread_cond_signal = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_cond_signal");
- pContext->posix.pthread_attr_init = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_init");
- pContext->posix.pthread_attr_destroy = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_destroy");
- pContext->posix.pthread_attr_setschedpolicy = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_setschedpolicy");
- pContext->posix.pthread_attr_getschedparam = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_getschedparam");
- pContext->posix.pthread_attr_setschedparam = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_setschedparam");
-#else
- pContext->posix.pthread_create = (ma_proc)pthread_create;
- pContext->posix.pthread_join = (ma_proc)pthread_join;
- pContext->posix.pthread_mutex_init = (ma_proc)pthread_mutex_init;
- pContext->posix.pthread_mutex_destroy = (ma_proc)pthread_mutex_destroy;
- pContext->posix.pthread_mutex_lock = (ma_proc)pthread_mutex_lock;
- pContext->posix.pthread_mutex_unlock = (ma_proc)pthread_mutex_unlock;
- pContext->posix.pthread_cond_init = (ma_proc)pthread_cond_init;
- pContext->posix.pthread_cond_destroy = (ma_proc)pthread_cond_destroy;
- pContext->posix.pthread_cond_wait = (ma_proc)pthread_cond_wait;
- pContext->posix.pthread_cond_signal = (ma_proc)pthread_cond_signal;
- pContext->posix.pthread_attr_init = (ma_proc)pthread_attr_init;
- pContext->posix.pthread_attr_destroy = (ma_proc)pthread_attr_destroy;
-#if !defined(__EMSCRIPTEN__)
- pContext->posix.pthread_attr_setschedpolicy = (ma_proc)pthread_attr_setschedpolicy;
- pContext->posix.pthread_attr_getschedparam = (ma_proc)pthread_attr_getschedparam;
- pContext->posix.pthread_attr_setschedparam = (ma_proc)pthread_attr_setschedparam;
-#endif
-#endif
+ (void)pContext;
return MA_SUCCESS;
}
@@ -39214,22 +41070,6 @@ static ma_result ma_context_uninit_backend_apis(ma_context* pContext)
}
-static ma_bool32 ma_context_is_backend_asynchronous(ma_context* pContext)
-{
- MA_ASSERT(pContext != NULL);
-
- if (pContext->callbacks.onDeviceRead == NULL && pContext->callbacks.onDeviceWrite == NULL) {
- if (pContext->callbacks.onDeviceDataLoop == NULL) {
- return MA_TRUE;
- } else {
- return MA_FALSE;
- }
- } else {
- return MA_FALSE;
- }
-}
-
-
/* The default capacity doesn't need to be too big. */
#ifndef MA_DEFAULT_DEVICE_JOB_QUEUE_CAPACITY
#define MA_DEFAULT_DEVICE_JOB_QUEUE_CAPACITY 32
@@ -39289,7 +41129,7 @@ MA_API ma_result ma_device_job_thread_init(const ma_device_job_thread_config* pC
/* Initialize the job queue before the thread to ensure it's in a valid state. */
- jobQueueConfig = ma_job_queue_config_init(pConfig->jobQueueFlags, pConfig->jobQueueCapacity);
+ jobQueueConfig = ma_job_queue_config_init(pConfig->jobQueueFlags, pConfig->jobQueueCapacity);
result = ma_job_queue_init(&jobQueueConfig, pAllocationCallbacks, &pJobThread->jobQueue);
if (result != MA_SUCCESS) {
@@ -39502,13 +41342,17 @@ MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendC
#ifdef MA_HAS_AAUDIO
case ma_backend_aaudio:
{
- pContext->callbacks.onContextInit = ma_context_init__aaudio;
+ if (ma_is_backend_enabled(backend)) {
+ pContext->callbacks.onContextInit = ma_context_init__aaudio;
+ }
} break;
#endif
#ifdef MA_HAS_OPENSL
case ma_backend_opensl:
{
- pContext->callbacks.onContextInit = ma_context_init__opensl;
+ if (ma_is_backend_enabled(backend)) {
+ pContext->callbacks.onContextInit = ma_context_init__opensl;
+ }
} break;
#endif
#ifdef MA_HAS_WEBAUDIO
@@ -39538,7 +41382,16 @@ MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendC
ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "Attempting to initialize %s backend...\n", ma_get_backend_name(backend));
result = pContext->callbacks.onContextInit(pContext, pConfig, &pContext->callbacks);
} else {
- result = MA_NO_BACKEND;
+ /* Getting here means the onContextInit callback is not set which means the backend is not enabled. Special case for the custom backend. */
+ if (backend != ma_backend_custom) {
+ result = MA_BACKEND_NOT_ENABLED;
+ } else {
+ #if !defined(MA_HAS_CUSTOM)
+ result = MA_BACKEND_NOT_ENABLED;
+ #else
+ result = MA_NO_BACKEND;
+ #endif
+ }
}
/* If this iteration was successful, return. */
@@ -39562,7 +41415,11 @@ MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendC
pContext->backend = backend;
return result;
} else {
- ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "Failed to initialize %s backend.\n", ma_get_backend_name(backend));
+ if (result == MA_BACKEND_NOT_ENABLED) {
+ ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "%s backend is disabled.\n", ma_get_backend_name(backend));
+ } else {
+ ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_DEBUG, "Failed to initialize %s backend.\n", ma_get_backend_name(backend));
+ }
}
}
@@ -39593,7 +41450,7 @@ MA_API ma_result ma_context_uninit(ma_context* pContext)
return MA_SUCCESS;
}
-MA_API size_t ma_context_sizeof()
+MA_API size_t ma_context_sizeof(void)
{
return sizeof(ma_context);
}
@@ -39717,7 +41574,12 @@ MA_API ma_result ma_context_get_devices(ma_context* pContext, ma_device_info** p
/* Capture devices. */
if (ppCaptureDeviceInfos != NULL) {
- *ppCaptureDeviceInfos = pContext->pDeviceInfos + pContext->playbackDeviceInfoCount; /* Capture devices come after playback devices. */
+ *ppCaptureDeviceInfos = pContext->pDeviceInfos;
+ /* Capture devices come after playback devices. */
+ if (pContext->playbackDeviceInfoCount > 0) {
+ /* Conditional, because NULL+0 is undefined behavior. */
+ *ppCaptureDeviceInfos += pContext->playbackDeviceInfoCount;
+ }
}
if (pCaptureDeviceCount != NULL) {
*pCaptureDeviceCount = pContext->captureDeviceInfoCount;
@@ -39853,7 +41715,7 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
pDevice->noClip = pConfig->noClip;
pDevice->noDisableDenormals = pConfig->noDisableDenormals;
pDevice->noFixedSizedCallback = pConfig->noFixedSizedCallback;
- pDevice->masterVolumeFactor = 1;
+ ma_atomic_float_set(&pDevice->masterVolumeFactor, 1);
pDevice->type = pConfig->deviceType;
pDevice->sampleRate = pConfig->sampleRate;
@@ -39867,13 +41729,14 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
pDevice->capture.channels = pConfig->capture.channels;
ma_channel_map_copy_or_default(pDevice->capture.channelMap, ma_countof(pDevice->capture.channelMap), pConfig->capture.pChannelMap, pConfig->capture.channels);
pDevice->capture.channelMixMode = pConfig->capture.channelMixMode;
+ pDevice->capture.calculateLFEFromSpatialChannels = pConfig->capture.calculateLFEFromSpatialChannels;
pDevice->playback.shareMode = pConfig->playback.shareMode;
pDevice->playback.format = pConfig->playback.format;
pDevice->playback.channels = pConfig->playback.channels;
ma_channel_map_copy_or_default(pDevice->playback.channelMap, ma_countof(pDevice->playback.channelMap), pConfig->playback.pChannelMap, pConfig->playback.channels);
pDevice->playback.channelMixMode = pConfig->playback.channelMixMode;
-
+ pDevice->playback.calculateLFEFromSpatialChannels = pConfig->playback.calculateLFEFromSpatialChannels;
result = ma_mutex_init(&pDevice->startStopLock);
if (result != MA_SUCCESS) {
@@ -40074,7 +41937,7 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
ma_uint64 intermediaryBufferSizeInBytes;
-
+
pDevice->playback.intermediaryBufferLen = 0;
if (pConfig->deviceType == ma_device_type_duplex) {
pDevice->playback.intermediaryBufferCap = pDevice->capture.intermediaryBufferCap; /* In duplex mode, make sure the intermediary buffer is always the same size as the capture side. */
@@ -40086,7 +41949,7 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
}
intermediaryBufferSizeInBytes = pDevice->playback.intermediaryBufferCap * ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
-
+
pDevice->playback.pIntermediaryBuffer = ma_malloc((size_t)intermediaryBufferSizeInBytes, &pContext->allocationCallbacks);
if (pDevice->playback.pIntermediaryBuffer == NULL) {
ma_device_uninit(pDevice);
@@ -40135,9 +41998,9 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
/* Log device information. */
{
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[%s]\n", ma_get_backend_name(pDevice->pContext->backend));
- if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
+ if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
char name[MA_MAX_DEVICE_NAME_LENGTH + 1];
- ma_device_get_name(pDevice, ma_device_type_capture, name, sizeof(name), NULL);
+ ma_device_get_name(pDevice, (pDevice->type == ma_device_type_loopback) ? ma_device_type_playback : ma_device_type_capture, name, sizeof(name), NULL);
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " %s (%s)\n", name, "Capture");
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Format: %s -> %s\n", ma_get_format_name(pDevice->capture.internalFormat), ma_get_format_name(pDevice->capture.format));
@@ -40150,6 +42013,14 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channel Routing: %s\n", pDevice->capture.converter.hasChannelConverter ? "YES" : "NO");
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Resampling: %s\n", pDevice->capture.converter.hasResampler ? "YES" : "NO");
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Passthrough: %s\n", pDevice->capture.converter.isPassthrough ? "YES" : "NO");
+ {
+ char channelMapStr[1024];
+ ma_channel_map_to_string(pDevice->capture.internalChannelMap, pDevice->capture.internalChannels, channelMapStr, sizeof(channelMapStr));
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channel Map In: {%s}\n", channelMapStr);
+
+ ma_channel_map_to_string(pDevice->capture.channelMap, pDevice->capture.channels, channelMapStr, sizeof(channelMapStr));
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channel Map Out: {%s}\n", channelMapStr);
+ }
}
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
char name[MA_MAX_DEVICE_NAME_LENGTH + 1];
@@ -40166,6 +42037,14 @@ MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pC
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channel Routing: %s\n", pDevice->playback.converter.hasChannelConverter ? "YES" : "NO");
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Resampling: %s\n", pDevice->playback.converter.hasResampler ? "YES" : "NO");
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Passthrough: %s\n", pDevice->playback.converter.isPassthrough ? "YES" : "NO");
+ {
+ char channelMapStr[1024];
+ ma_channel_map_to_string(pDevice->playback.channelMap, pDevice->playback.channels, channelMapStr, sizeof(channelMapStr));
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channel Map In: {%s}\n", channelMapStr);
+
+ ma_channel_map_to_string(pDevice->playback.internalChannelMap, pDevice->playback.internalChannels, channelMapStr, sizeof(channelMapStr));
+ ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, " Channel Map Out: {%s}\n", channelMapStr);
+ }
}
}
@@ -40196,7 +42075,6 @@ MA_API ma_result ma_device_init_ex(const ma_backend backends[], ma_uint32 backen
allocationCallbacks = ma_allocation_callbacks_init_default();
}
-
pContext = (ma_context*)ma_malloc(sizeof(*pContext), &allocationCallbacks);
if (pContext == NULL) {
return MA_OUT_OF_MEMORY;
@@ -40216,6 +42094,33 @@ MA_API ma_result ma_device_init_ex(const ma_backend backends[], ma_uint32 backen
result = MA_NO_BACKEND;
for (iBackend = 0; iBackend < backendsToIterateCount; ++iBackend) {
+ /*
+ This is a hack for iOS. If the context config is null, there's a good chance the
+ `ma_device_init(NULL, &deviceConfig, pDevice);` pattern is being used. In this
+ case, set the session category based on the device type.
+ */
+ #if defined(MA_APPLE_MOBILE)
+ ma_context_config contextConfig;
+
+ if (pContextConfig == NULL) {
+ contextConfig = ma_context_config_init();
+ switch (pConfig->deviceType) {
+ case ma_device_type_duplex: {
+ contextConfig.coreaudio.sessionCategory = ma_ios_session_category_play_and_record;
+ } break;
+ case ma_device_type_capture: {
+ contextConfig.coreaudio.sessionCategory = ma_ios_session_category_record;
+ } break;
+ case ma_device_type_playback:
+ default: {
+ contextConfig.coreaudio.sessionCategory = ma_ios_session_category_playback;
+ } break;
+ }
+
+ pContextConfig = &contextConfig;
+ }
+ #endif
+
result = ma_context_init(&pBackendsToIterate[iBackend], 1, pContextConfig, pContext);
if (result == MA_SUCCESS) {
result = ma_device_init(pContext, pConfig, pDevice);
@@ -40491,6 +42396,15 @@ MA_API ma_result ma_device_stop(ma_device* pDevice)
ma_event_wait(&pDevice->stopEvent);
result = MA_SUCCESS;
}
+
+ /*
+ This is a safety measure to ensure the internal buffer has been cleared so any leftover
+ does not get played the next time the device starts. Ideally this should be drained by
+ the backend first.
+ */
+ pDevice->playback.intermediaryBufferLen = 0;
+ pDevice->playback.inputCacheConsumed = 0;
+ pDevice->playback.inputCacheRemaining = 0;
}
ma_mutex_unlock(&pDevice->startStopLock);
@@ -40508,7 +42422,7 @@ MA_API ma_device_state ma_device_get_state(const ma_device* pDevice)
return ma_device_state_uninitialized;
}
- return (ma_device_state)c89atomic_load_i32((ma_int32*)&pDevice->state); /* Naughty cast to get rid of a const warning. */
+ return ma_atomic_device_state_get((ma_atomic_device_state*)&pDevice->state); /* Naughty cast to get rid of a const warning. */
}
MA_API ma_result ma_device_set_master_volume(ma_device* pDevice, float volume)
@@ -40521,7 +42435,7 @@ MA_API ma_result ma_device_set_master_volume(ma_device* pDevice, float volume)
return MA_INVALID_ARGS;
}
- c89atomic_exchange_f32(&pDevice->masterVolumeFactor, volume);
+ ma_atomic_float_set(&pDevice->masterVolumeFactor, volume);
return MA_SUCCESS;
}
@@ -40537,7 +42451,7 @@ MA_API ma_result ma_device_get_master_volume(ma_device* pDevice, float* pVolume)
return MA_INVALID_ARGS;
}
- *pVolume = c89atomic_load_f32(&pDevice->masterVolumeFactor);
+ *pVolume = ma_atomic_float_get(&pDevice->masterVolumeFactor);
return MA_SUCCESS;
}
@@ -41132,6 +43046,35 @@ MA_API float ma_volume_db_to_linear(float gain)
}
+MA_API ma_result ma_mix_pcm_frames_f32(float* pDst, const float* pSrc, ma_uint64 frameCount, ma_uint32 channels, float volume)
+{
+ ma_uint64 iSample;
+ ma_uint64 sampleCount;
+
+ if (pDst == NULL || pSrc == NULL || channels == 0) {
+ return MA_INVALID_ARGS;
+ }
+
+ if (volume == 0) {
+ return MA_SUCCESS; /* No changes if the volume is 0. */
+ }
+
+ sampleCount = frameCount * channels;
+
+ if (volume == 1) {
+ for (iSample = 0; iSample < sampleCount; iSample += 1) {
+ pDst[iSample] += pSrc[iSample];
+ }
+ } else {
+ for (iSample = 0; iSample < sampleCount; iSample += 1) {
+ pDst[iSample] += ma_apply_volume_unclipped_f32(pSrc[iSample], volume);
+ }
+ }
+
+ return MA_SUCCESS;
+}
+
+
/**************************************************************************************************************************************************************
@@ -41197,12 +43140,6 @@ static MA_INLINE void ma_pcm_u8_to_s16__sse2(void* dst, const void* src, ma_uint
ma_pcm_u8_to_s16__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_u8_to_s16__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_u8_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_u8_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -41215,15 +43152,11 @@ MA_API void ma_pcm_u8_to_s16(void* dst, const void* src, ma_uint64 count, ma_dit
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_u8_to_s16__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_u8_to_s16__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_u8_to_s16__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_u8_to_s16__neon(dst, src, count, ditherMode);
} else
@@ -41264,12 +43197,6 @@ static MA_INLINE void ma_pcm_u8_to_s24__sse2(void* dst, const void* src, ma_uint
ma_pcm_u8_to_s24__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_u8_to_s24__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_u8_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_u8_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -41282,15 +43209,11 @@ MA_API void ma_pcm_u8_to_s24(void* dst, const void* src, ma_uint64 count, ma_dit
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_u8_to_s24__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_u8_to_s24__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_u8_to_s24__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_u8_to_s24__neon(dst, src, count, ditherMode);
} else
@@ -41329,12 +43252,6 @@ static MA_INLINE void ma_pcm_u8_to_s32__sse2(void* dst, const void* src, ma_uint
ma_pcm_u8_to_s32__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_u8_to_s32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_u8_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_u8_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -41347,15 +43264,11 @@ MA_API void ma_pcm_u8_to_s32(void* dst, const void* src, ma_uint64 count, ma_dit
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_u8_to_s32__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_u8_to_s32__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_u8_to_s32__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_u8_to_s32__neon(dst, src, count, ditherMode);
} else
@@ -41395,12 +43308,6 @@ static MA_INLINE void ma_pcm_u8_to_f32__sse2(void* dst, const void* src, ma_uint
ma_pcm_u8_to_f32__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_u8_to_f32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_u8_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_u8_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -41413,15 +43320,11 @@ MA_API void ma_pcm_u8_to_f32(void* dst, const void* src, ma_uint64 count, ma_dit
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_u8_to_f32__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_u8_to_f32__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_u8_to_f32__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_u8_to_f32__neon(dst, src, count, ditherMode);
} else
@@ -41557,12 +43460,6 @@ static MA_INLINE void ma_pcm_s16_to_u8__sse2(void* dst, const void* src, ma_uint
ma_pcm_s16_to_u8__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s16_to_u8__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_s16_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_s16_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -41575,15 +43472,11 @@ MA_API void ma_pcm_s16_to_u8(void* dst, const void* src, ma_uint64 count, ma_dit
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_s16_to_u8__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_s16_to_u8__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_s16_to_u8__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_s16_to_u8__neon(dst, src, count, ditherMode);
} else
@@ -41628,12 +43521,6 @@ static MA_INLINE void ma_pcm_s16_to_s24__sse2(void* dst, const void* src, ma_uin
ma_pcm_s16_to_s24__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s16_to_s24__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_s16_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_s16_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -41646,15 +43533,11 @@ MA_API void ma_pcm_s16_to_s24(void* dst, const void* src, ma_uint64 count, ma_di
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_s16_to_s24__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_s16_to_s24__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_s16_to_s24__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_s16_to_s24__neon(dst, src, count, ditherMode);
} else
@@ -41690,12 +43573,6 @@ static MA_INLINE void ma_pcm_s16_to_s32__sse2(void* dst, const void* src, ma_uin
ma_pcm_s16_to_s32__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s16_to_s32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_s16_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_s16_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -41708,15 +43585,11 @@ MA_API void ma_pcm_s16_to_s32(void* dst, const void* src, ma_uint64 count, ma_di
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_s16_to_s32__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_s16_to_s32__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_s16_to_s32__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_s16_to_s32__neon(dst, src, count, ditherMode);
} else
@@ -41764,12 +43637,6 @@ static MA_INLINE void ma_pcm_s16_to_f32__sse2(void* dst, const void* src, ma_uin
ma_pcm_s16_to_f32__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s16_to_f32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_s16_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_s16_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -41782,15 +43649,11 @@ MA_API void ma_pcm_s16_to_f32(void* dst, const void* src, ma_uint64 count, ma_di
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_s16_to_f32__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_s16_to_f32__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_s16_to_f32__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_s16_to_f32__neon(dst, src, count, ditherMode);
} else
@@ -41902,12 +43765,6 @@ static MA_INLINE void ma_pcm_s24_to_u8__sse2(void* dst, const void* src, ma_uint
ma_pcm_s24_to_u8__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s24_to_u8__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_s24_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_s24_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -41920,15 +43777,11 @@ MA_API void ma_pcm_s24_to_u8(void* dst, const void* src, ma_uint64 count, ma_dit
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_s24_to_u8__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_s24_to_u8__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_s24_to_u8__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_s24_to_u8__neon(dst, src, count, ditherMode);
} else
@@ -41982,12 +43835,6 @@ static MA_INLINE void ma_pcm_s24_to_s16__sse2(void* dst, const void* src, ma_uin
ma_pcm_s24_to_s16__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s24_to_s16__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_s24_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_s24_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -42000,15 +43847,11 @@ MA_API void ma_pcm_s24_to_s16(void* dst, const void* src, ma_uint64 count, ma_di
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_s24_to_s16__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_s24_to_s16__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_s24_to_s16__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_s24_to_s16__neon(dst, src, count, ditherMode);
} else
@@ -42052,12 +43895,6 @@ static MA_INLINE void ma_pcm_s24_to_s32__sse2(void* dst, const void* src, ma_uin
ma_pcm_s24_to_s32__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s24_to_s32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_s24_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_s24_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -42070,15 +43907,11 @@ MA_API void ma_pcm_s24_to_s32(void* dst, const void* src, ma_uint64 count, ma_di
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_s24_to_s32__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_s24_to_s32__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_s24_to_s32__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_s24_to_s32__neon(dst, src, count, ditherMode);
} else
@@ -42126,12 +43959,6 @@ static MA_INLINE void ma_pcm_s24_to_f32__sse2(void* dst, const void* src, ma_uin
ma_pcm_s24_to_f32__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s24_to_f32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_s24_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_s24_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -42144,15 +43971,11 @@ MA_API void ma_pcm_s24_to_f32(void* dst, const void* src, ma_uint64 count, ma_di
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_s24_to_f32__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_s24_to_f32__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_s24_to_f32__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_s24_to_f32__neon(dst, src, count, ditherMode);
} else
@@ -42272,12 +44095,6 @@ static MA_INLINE void ma_pcm_s32_to_u8__sse2(void* dst, const void* src, ma_uint
ma_pcm_s32_to_u8__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s32_to_u8__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_s32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_s32_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -42290,15 +44107,11 @@ MA_API void ma_pcm_s32_to_u8(void* dst, const void* src, ma_uint64 count, ma_dit
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_s32_to_u8__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_s32_to_u8__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_s32_to_u8__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_s32_to_u8__neon(dst, src, count, ditherMode);
} else
@@ -42352,12 +44165,6 @@ static MA_INLINE void ma_pcm_s32_to_s16__sse2(void* dst, const void* src, ma_uin
ma_pcm_s32_to_s16__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s32_to_s16__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_s32_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_s32_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -42370,15 +44177,11 @@ MA_API void ma_pcm_s32_to_s16(void* dst, const void* src, ma_uint64 count, ma_di
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_s32_to_s16__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_s32_to_s16__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_s32_to_s16__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_s32_to_s16__neon(dst, src, count, ditherMode);
} else
@@ -42417,12 +44220,6 @@ static MA_INLINE void ma_pcm_s32_to_s24__sse2(void* dst, const void* src, ma_uin
ma_pcm_s32_to_s24__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s32_to_s24__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_s32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_s32_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -42435,15 +44232,11 @@ MA_API void ma_pcm_s32_to_s24(void* dst, const void* src, ma_uint64 count, ma_di
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_s32_to_s24__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_s32_to_s24__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_s32_to_s24__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_s32_to_s24__neon(dst, src, count, ditherMode);
} else
@@ -42497,12 +44290,6 @@ static MA_INLINE void ma_pcm_s32_to_f32__sse2(void* dst, const void* src, ma_uin
ma_pcm_s32_to_f32__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s32_to_f32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_s32_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_s32_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -42515,15 +44302,11 @@ MA_API void ma_pcm_s32_to_f32(void* dst, const void* src, ma_uint64 count, ma_di
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_s32_to_f32__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_s32_to_f32__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_s32_to_f32__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_s32_to_f32__neon(dst, src, count, ditherMode);
} else
@@ -42630,12 +44413,6 @@ static MA_INLINE void ma_pcm_f32_to_u8__sse2(void* dst, const void* src, ma_uint
ma_pcm_f32_to_u8__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_f32_to_u8__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_f32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_f32_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -42648,15 +44425,11 @@ MA_API void ma_pcm_f32_to_u8(void* dst, const void* src, ma_uint64 count, ma_dit
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_f32_to_u8__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_f32_to_u8__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_f32_to_u8__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_f32_to_u8__neon(dst, src, count, ditherMode);
} else
@@ -42860,129 +44633,6 @@ static MA_INLINE void ma_pcm_f32_to_s16__sse2(void* dst, const void* src, ma_uin
}
#endif /* SSE2 */
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_f32_to_s16__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_uint64 i;
- ma_uint64 i16;
- ma_uint64 count16;
- ma_int16* dst_s16;
- const float* src_f32;
- float ditherMin;
- float ditherMax;
-
- /* Both the input and output buffers need to be aligned to 32 bytes. */
- if ((((ma_uintptr)dst & 31) != 0) || (((ma_uintptr)src & 31) != 0)) {
- ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode);
- return;
- }
-
- dst_s16 = (ma_int16*)dst;
- src_f32 = (const float*)src;
-
- ditherMin = 0;
- ditherMax = 0;
- if (ditherMode != ma_dither_mode_none) {
- ditherMin = 1.0f / -32768;
- ditherMax = 1.0f / 32767;
- }
-
- i = 0;
-
- /* AVX2. AVX2 allows us to output 16 s16's at a time which means our loop is unrolled 16 times. */
- count16 = count >> 4;
- for (i16 = 0; i16 < count16; i16 += 1) {
- __m256 d0;
- __m256 d1;
- __m256 x0;
- __m256 x1;
- __m256i i0;
- __m256i i1;
- __m256i p0;
- __m256i p1;
- __m256i r;
-
- if (ditherMode == ma_dither_mode_none) {
- d0 = _mm256_set1_ps(0);
- d1 = _mm256_set1_ps(0);
- } else if (ditherMode == ma_dither_mode_rectangle) {
- d0 = _mm256_set_ps(
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax)
- );
- d1 = _mm256_set_ps(
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax),
- ma_dither_f32_rectangle(ditherMin, ditherMax)
- );
- } else {
- d0 = _mm256_set_ps(
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax)
- );
- d1 = _mm256_set_ps(
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax),
- ma_dither_f32_triangle(ditherMin, ditherMax)
- );
- }
-
- x0 = *((__m256*)(src_f32 + i) + 0);
- x1 = *((__m256*)(src_f32 + i) + 1);
-
- x0 = _mm256_add_ps(x0, d0);
- x1 = _mm256_add_ps(x1, d1);
-
- x0 = _mm256_mul_ps(x0, _mm256_set1_ps(32767.0f));
- x1 = _mm256_mul_ps(x1, _mm256_set1_ps(32767.0f));
-
- /* Computing the final result is a little more complicated for AVX2 than SSE2. */
- i0 = _mm256_cvttps_epi32(x0);
- i1 = _mm256_cvttps_epi32(x1);
- p0 = _mm256_permute2x128_si256(i0, i1, 0 | 32);
- p1 = _mm256_permute2x128_si256(i0, i1, 1 | 48);
- r = _mm256_packs_epi32(p0, p1);
-
- _mm256_stream_si256(((__m256i*)(dst_s16 + i)), r);
-
- i += 16;
- }
-
-
- /* Leftover. */
- for (; i < count; i += 1) {
- float x = src_f32[i];
- x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax);
- x = ((x < -1) ? -1 : ((x > 1) ? 1 : x)); /* clip */
- x = x * 32767.0f; /* -1..1 to -32767..32767 */
-
- dst_s16[i] = (ma_int16)x;
- }
-}
-#endif /* AVX2 */
-
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_f32_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -42995,7 +44645,8 @@ static MA_INLINE void ma_pcm_f32_to_s16__neon(void* dst, const void* src, ma_uin
float ditherMax;
if (!ma_has_neon()) {
- return ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode);
+ ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode);
+ return;
}
/* Both the input and output buffers need to be aligned to 16 bytes. */
@@ -43094,15 +44745,11 @@ MA_API void ma_pcm_f32_to_s16(void* dst, const void* src, ma_uint64 count, ma_di
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_f32_to_s16__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_f32_to_s16__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_f32_to_s16__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_f32_to_s16__neon(dst, src, count, ditherMode);
} else
@@ -43155,12 +44802,6 @@ static MA_INLINE void ma_pcm_f32_to_s24__sse2(void* dst, const void* src, ma_uin
ma_pcm_f32_to_s24__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_f32_to_s24__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_f32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_f32_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -43173,15 +44814,11 @@ MA_API void ma_pcm_f32_to_s24(void* dst, const void* src, ma_uint64 count, ma_di
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_f32_to_s24__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_f32_to_s24__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_f32_to_s24__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_f32_to_s24__neon(dst, src, count, ditherMode);
} else
@@ -43230,12 +44867,6 @@ static MA_INLINE void ma_pcm_f32_to_s32__sse2(void* dst, const void* src, ma_uin
ma_pcm_f32_to_s32__optimized(dst, src, count, ditherMode);
}
#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_f32_to_s32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
- ma_pcm_f32_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
#if defined(MA_SUPPORT_NEON)
static MA_INLINE void ma_pcm_f32_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
{
@@ -43248,15 +44879,11 @@ MA_API void ma_pcm_f32_to_s32(void* dst, const void* src, ma_uint64 count, ma_di
#ifdef MA_USE_REFERENCE_CONVERSION_APIS
ma_pcm_f32_to_s32__reference(dst, src, count, ditherMode);
#else
- # if MA_PREFERRED_SIMD == MA_SIMD_AVX2
- if (ma_has_avx2()) {
- ma_pcm_f32_to_s32__avx2(dst, src, count, ditherMode);
- } else
- #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
+ # if defined(MA_SUPPORT_SSE2)
if (ma_has_sse2()) {
ma_pcm_f32_to_s32__sse2(dst, src, count, ditherMode);
} else
- #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
+ #elif defined(MA_SUPPORT_NEON)
if (ma_has_neon()) {
ma_pcm_f32_to_s32__neon(dst, src, count, ditherMode);
} else
@@ -44631,7 +46258,7 @@ static MA_INLINE void ma_lpf_process_pcm_frame_f32(ma_lpf* pLPF, float* pY, cons
MA_ASSERT(pLPF->format == ma_format_f32);
- MA_COPY_MEMORY(pY, pX, ma_get_bytes_per_frame(pLPF->format, pLPF->channels));
+ MA_MOVE_MEMORY(pY, pX, ma_get_bytes_per_frame(pLPF->format, pLPF->channels));
for (ilpf1 = 0; ilpf1 < pLPF->lpf1Count; ilpf1 += 1) {
ma_lpf1_process_pcm_frame_f32(&pLPF->pLPF1[ilpf1], pY, pY);
@@ -44649,7 +46276,7 @@ static MA_INLINE void ma_lpf_process_pcm_frame_s16(ma_lpf* pLPF, ma_int16* pY, c
MA_ASSERT(pLPF->format == ma_format_s16);
- MA_COPY_MEMORY(pY, pX, ma_get_bytes_per_frame(pLPF->format, pLPF->channels));
+ MA_MOVE_MEMORY(pY, pX, ma_get_bytes_per_frame(pLPF->format, pLPF->channels));
for (ilpf1 = 0; ilpf1 < pLPF->lpf1Count; ilpf1 += 1) {
ma_lpf1_process_pcm_frame_s16(&pLPF->pLPF1[ilpf1], pY, pY);
@@ -46988,6 +48615,7 @@ MA_API ma_result ma_gainer_init_preallocated(const ma_gainer_config* pConfig, vo
pGainer->pOldGains = (float*)ma_offset_ptr(pHeap, heapLayout.oldGainsOffset);
pGainer->pNewGains = (float*)ma_offset_ptr(pHeap, heapLayout.newGainsOffset);
+ pGainer->masterVolume = 1;
pGainer->config = *pConfig;
pGainer->t = (ma_uint32)-1; /* No interpolation by default. */
@@ -47047,20 +48675,256 @@ static float ma_gainer_calculate_current_gain(const ma_gainer* pGainer, ma_uint3
return ma_mix_f32_fast(pGainer->pOldGains[channel], pGainer->pNewGains[channel], a);
}
-MA_API ma_result ma_gainer_process_pcm_frames(ma_gainer* pGainer, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
+static /*__attribute__((noinline))*/ ma_result ma_gainer_process_pcm_frames_internal(ma_gainer * pGainer, void* MA_RESTRICT pFramesOut, const void* MA_RESTRICT pFramesIn, ma_uint64 frameCount)
{
ma_uint64 iFrame;
ma_uint32 iChannel;
- float* pFramesOutF32 = (float*)pFramesOut;
- const float* pFramesInF32 = (const float*)pFramesIn;
+ ma_uint64 interpolatedFrameCount;
- if (pGainer == NULL) {
- return MA_INVALID_ARGS;
+ MA_ASSERT(pGainer != NULL);
+
+ /*
+ We don't necessarily need to apply a linear interpolation for the entire frameCount frames. When
+ linear interpolation is not needed we can do a simple volume adjustment which will be more
+ efficient than a lerp with an alpha value of 1.
+
+ To do this, all we need to do is determine how many frames need to have a lerp applied. Then we
+ just process that number of frames with linear interpolation. After that we run on an optimized
+ path which just applies the new gains without a lerp.
+ */
+ if (pGainer->t >= pGainer->config.smoothTimeInFrames) {
+ interpolatedFrameCount = 0;
+ } else {
+ interpolatedFrameCount = pGainer->t - pGainer->config.smoothTimeInFrames;
+ if (interpolatedFrameCount > frameCount) {
+ interpolatedFrameCount = frameCount;
+ }
}
+ /*
+ Start off with our interpolated frames. When we do this, we'll adjust frameCount and our pointers
+ so that the fast path can work naturally without consideration of the interpolated path.
+ */
+ if (interpolatedFrameCount > 0) {
+ /* We can allow the input and output buffers to be null in which case we'll just update the internal timer. */
+ if (pFramesOut != NULL && pFramesIn != NULL) {
+ /*
+ All we're really doing here is moving the old gains towards the new gains. We don't want to
+ be modifying the gains inside the ma_gainer object because that will break things. Instead
+ we can make a copy here on the stack. For extreme channel counts we can fall back to a slower
+ implementation which just uses a standard lerp.
+ */
+ float* pFramesOutF32 = (float*)pFramesOut;
+ const float* pFramesInF32 = (const float*)pFramesIn;
+ float a = (float)pGainer->t / pGainer->config.smoothTimeInFrames;
+ float d = 1.0f / pGainer->config.smoothTimeInFrames;
+
+ if (pGainer->config.channels <= 32) {
+ float pRunningGain[32];
+ float pRunningGainDelta[32]; /* Could this be heap-allocated as part of the ma_gainer object? */
+
+ /* Initialize the running gain. */
+ for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) {
+ float t = (pGainer->pNewGains[iChannel] - pGainer->pOldGains[iChannel]) * pGainer->masterVolume;
+ pRunningGainDelta[iChannel] = t * d;
+ pRunningGain[iChannel] = (pGainer->pOldGains[iChannel] * pGainer->masterVolume) + (t * a);
+ }
+
+ iFrame = 0;
+
+ /* Optimized paths for common channel counts. This is mostly just experimenting with some SIMD ideas. It's not necessarily final. */
+ if (pGainer->config.channels == 2) {
+ #if defined(MA_SUPPORT_SSE2)
+ if (ma_has_sse2()) {
+ ma_uint64 unrolledLoopCount = interpolatedFrameCount >> 1;
+
+ /* Expand some arrays so we can have a clean SIMD loop below. */
+ __m128 runningGainDelta0 = _mm_set_ps(pRunningGainDelta[1], pRunningGainDelta[0], pRunningGainDelta[1], pRunningGainDelta[0]);
+ __m128 runningGain0 = _mm_set_ps(pRunningGain[1] + pRunningGainDelta[1], pRunningGain[0] + pRunningGainDelta[0], pRunningGain[1], pRunningGain[0]);
+
+ for (; iFrame < unrolledLoopCount; iFrame += 1) {
+ _mm_storeu_ps(&pFramesOutF32[iFrame*4 + 0], _mm_mul_ps(_mm_loadu_ps(&pFramesInF32[iFrame*4 + 0]), runningGain0));
+ runningGain0 = _mm_add_ps(runningGain0, runningGainDelta0);
+ }
+
+ iFrame = unrolledLoopCount << 1;
+ } else
+ #endif
+ {
+ /*
+ Two different scalar implementations here. Clang (and I assume GCC) will vectorize
+ both of these, but the bottom version results in a nicer vectorization with less
+ instructions emitted. The problem, however, is that the bottom version runs slower
+ when compiled with MSVC. The top version will be partially vectorized by MSVC.
+ */
+ #if defined(_MSC_VER) && !defined(__clang__)
+ ma_uint64 unrolledLoopCount = interpolatedFrameCount >> 1;
+
+ /* Expand some arrays so we can have a clean 4x SIMD operation in the loop. */
+ pRunningGainDelta[2] = pRunningGainDelta[0];
+ pRunningGainDelta[3] = pRunningGainDelta[1];
+ pRunningGain[2] = pRunningGain[0] + pRunningGainDelta[0];
+ pRunningGain[3] = pRunningGain[1] + pRunningGainDelta[1];
+
+ for (; iFrame < unrolledLoopCount; iFrame += 1) {
+ pFramesOutF32[iFrame*4 + 0] = pFramesInF32[iFrame*4 + 0] * pRunningGain[0];
+ pFramesOutF32[iFrame*4 + 1] = pFramesInF32[iFrame*4 + 1] * pRunningGain[1];
+ pFramesOutF32[iFrame*4 + 2] = pFramesInF32[iFrame*4 + 2] * pRunningGain[2];
+ pFramesOutF32[iFrame*4 + 3] = pFramesInF32[iFrame*4 + 3] * pRunningGain[3];
+
+ /* Move the running gain forward towards the new gain. */
+ pRunningGain[0] += pRunningGainDelta[0];
+ pRunningGain[1] += pRunningGainDelta[1];
+ pRunningGain[2] += pRunningGainDelta[2];
+ pRunningGain[3] += pRunningGainDelta[3];
+ }
+
+ iFrame = unrolledLoopCount << 1;
+ #else
+ for (; iFrame < interpolatedFrameCount; iFrame += 1) {
+ for (iChannel = 0; iChannel < 2; iChannel += 1) {
+ pFramesOutF32[iFrame*2 + iChannel] = pFramesInF32[iFrame*2 + iChannel] * pRunningGain[iChannel];
+ }
+
+ for (iChannel = 0; iChannel < 2; iChannel += 1) {
+ pRunningGain[iChannel] += pRunningGainDelta[iChannel];
+ }
+ }
+ #endif
+ }
+ } else if (pGainer->config.channels == 6) {
+ #if defined(MA_SUPPORT_SSE2)
+ if (ma_has_sse2()) {
+ /*
+ For 6 channels things are a bit more complicated because 6 isn't cleanly divisible by 4. We need to do 2 frames
+ at a time, meaning we'll be doing 12 samples in a group. Like the stereo case we'll need to expand some arrays
+ so we can do clean 4x SIMD operations.
+ */
+ ma_uint64 unrolledLoopCount = interpolatedFrameCount >> 1;
+
+ /* Expand some arrays so we can have a clean SIMD loop below. */
+ __m128 runningGainDelta0 = _mm_set_ps(pRunningGainDelta[3], pRunningGainDelta[2], pRunningGainDelta[1], pRunningGainDelta[0]);
+ __m128 runningGainDelta1 = _mm_set_ps(pRunningGainDelta[1], pRunningGainDelta[0], pRunningGainDelta[5], pRunningGainDelta[4]);
+ __m128 runningGainDelta2 = _mm_set_ps(pRunningGainDelta[5], pRunningGainDelta[4], pRunningGainDelta[3], pRunningGainDelta[2]);
+
+ __m128 runningGain0 = _mm_set_ps(pRunningGain[3], pRunningGain[2], pRunningGain[1], pRunningGain[0]);
+ __m128 runningGain1 = _mm_set_ps(pRunningGain[1] + pRunningGainDelta[1], pRunningGain[0] + pRunningGainDelta[0], pRunningGain[5], pRunningGain[4]);
+ __m128 runningGain2 = _mm_set_ps(pRunningGain[5] + pRunningGainDelta[5], pRunningGain[4] + pRunningGainDelta[4], pRunningGain[3] + pRunningGainDelta[3], pRunningGain[2] + pRunningGainDelta[2]);
+
+ for (; iFrame < unrolledLoopCount; iFrame += 1) {
+ _mm_storeu_ps(&pFramesOutF32[iFrame*12 + 0], _mm_mul_ps(_mm_loadu_ps(&pFramesInF32[iFrame*12 + 0]), runningGain0));
+ _mm_storeu_ps(&pFramesOutF32[iFrame*12 + 4], _mm_mul_ps(_mm_loadu_ps(&pFramesInF32[iFrame*12 + 4]), runningGain1));
+ _mm_storeu_ps(&pFramesOutF32[iFrame*12 + 8], _mm_mul_ps(_mm_loadu_ps(&pFramesInF32[iFrame*12 + 8]), runningGain2));
+
+ runningGain0 = _mm_add_ps(runningGain0, runningGainDelta0);
+ runningGain1 = _mm_add_ps(runningGain1, runningGainDelta1);
+ runningGain2 = _mm_add_ps(runningGain2, runningGainDelta2);
+ }
+
+ iFrame = unrolledLoopCount << 1;
+ } else
+ #endif
+ {
+ for (; iFrame < interpolatedFrameCount; iFrame += 1) {
+ for (iChannel = 0; iChannel < 6; iChannel += 1) {
+ pFramesOutF32[iFrame*6 + iChannel] = pFramesInF32[iFrame*6 + iChannel] * pRunningGain[iChannel];
+ }
+
+ /* Move the running gain forward towards the new gain. */
+ for (iChannel = 0; iChannel < 6; iChannel += 1) {
+ pRunningGain[iChannel] += pRunningGainDelta[iChannel];
+ }
+ }
+ }
+ } else if (pGainer->config.channels == 8) {
+ /* For 8 channels we can just go over frame by frame and do all eight channels as 2 separate 4x SIMD operations. */
+ #if defined(MA_SUPPORT_SSE2)
+ if (ma_has_sse2()) {
+ __m128 runningGainDelta0 = _mm_loadu_ps(&pRunningGainDelta[0]);
+ __m128 runningGainDelta1 = _mm_loadu_ps(&pRunningGainDelta[4]);
+ __m128 runningGain0 = _mm_loadu_ps(&pRunningGain[0]);
+ __m128 runningGain1 = _mm_loadu_ps(&pRunningGain[4]);
+
+ for (; iFrame < interpolatedFrameCount; iFrame += 1) {
+ _mm_storeu_ps(&pFramesOutF32[iFrame*8 + 0], _mm_mul_ps(_mm_loadu_ps(&pFramesInF32[iFrame*8 + 0]), runningGain0));
+ _mm_storeu_ps(&pFramesOutF32[iFrame*8 + 4], _mm_mul_ps(_mm_loadu_ps(&pFramesInF32[iFrame*8 + 4]), runningGain1));
+
+ runningGain0 = _mm_add_ps(runningGain0, runningGainDelta0);
+ runningGain1 = _mm_add_ps(runningGain1, runningGainDelta1);
+ }
+ } else
+ #endif
+ {
+ /* This is crafted so that it auto-vectorizes when compiled with Clang. */
+ for (; iFrame < interpolatedFrameCount; iFrame += 1) {
+ for (iChannel = 0; iChannel < 8; iChannel += 1) {
+ pFramesOutF32[iFrame*8 + iChannel] = pFramesInF32[iFrame*8 + iChannel] * pRunningGain[iChannel];
+ }
+
+ /* Move the running gain forward towards the new gain. */
+ for (iChannel = 0; iChannel < 8; iChannel += 1) {
+ pRunningGain[iChannel] += pRunningGainDelta[iChannel];
+ }
+ }
+ }
+ }
+
+ for (; iFrame < interpolatedFrameCount; iFrame += 1) {
+ for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) {
+ pFramesOutF32[iFrame*pGainer->config.channels + iChannel] = pFramesInF32[iFrame*pGainer->config.channels + iChannel] * pRunningGain[iChannel];
+ pRunningGain[iChannel] += pRunningGainDelta[iChannel];
+ }
+ }
+ } else {
+ /* Slower path for extreme channel counts where we can't fit enough on the stack. We could also move this to the heap as part of the ma_gainer object which might even be better since it'll only be updated when the gains actually change. */
+ for (iFrame = 0; iFrame < interpolatedFrameCount; iFrame += 1) {
+ for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) {
+ pFramesOutF32[iFrame*pGainer->config.channels + iChannel] = pFramesInF32[iFrame*pGainer->config.channels + iChannel] * ma_mix_f32_fast(pGainer->pOldGains[iChannel], pGainer->pNewGains[iChannel], a) * pGainer->masterVolume;
+ }
+
+ a += d;
+ }
+ }
+ }
+
+ /* Make sure the timer is updated. */
+ pGainer->t = (ma_uint32)ma_min(pGainer->t + interpolatedFrameCount, pGainer->config.smoothTimeInFrames);
+
+ /* Adjust our arguments so the next part can work normally. */
+ frameCount -= interpolatedFrameCount;
+ pFramesOut = ma_offset_ptr(pFramesOut, interpolatedFrameCount * sizeof(float));
+ pFramesIn = ma_offset_ptr(pFramesIn, interpolatedFrameCount * sizeof(float));
+ }
+
+ /* All we need to do here is apply the new gains using an optimized path. */
+ if (pFramesOut != NULL && pFramesIn != NULL) {
+ if (pGainer->config.channels <= 32) {
+ float gains[32];
+ for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) {
+ gains[iChannel] = pGainer->pNewGains[iChannel] * pGainer->masterVolume;
+ }
+
+ ma_copy_and_apply_volume_factor_per_channel_f32((float*)pFramesOut, (const float*)pFramesIn, frameCount, pGainer->config.channels, gains);
+ } else {
+ /* Slow path. Too many channels to fit on the stack. Need to apply a master volume as a separate path. */
+ for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
+ for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) {
+ ((float*)pFramesOut)[iFrame*pGainer->config.channels + iChannel] = ((const float*)pFramesIn)[iFrame*pGainer->config.channels + iChannel] * pGainer->pNewGains[iChannel] * pGainer->masterVolume;
+ }
+ }
+ }
+ }
+
+ /* Now that some frames have been processed we need to make sure future changes to the gain are interpolated. */
+ if (pGainer->t == (ma_uint32)-1) {
+ pGainer->t = (ma_uint32)ma_min(pGainer->config.smoothTimeInFrames, frameCount);
+ }
+
+#if 0
if (pGainer->t >= pGainer->config.smoothTimeInFrames) {
/* Fast path. No gain calculation required. */
ma_copy_and_apply_volume_factor_per_channel_f32(pFramesOutF32, pFramesInF32, frameCount, pGainer->config.channels, pGainer->pNewGains);
+ ma_apply_volume_factor_f32(pFramesOutF32, frameCount * pGainer->config.channels, pGainer->masterVolume);
/* Now that some frames have been processed we need to make sure future changes to the gain are interpolated. */
if (pGainer->t == (ma_uint32)-1) {
@@ -47077,7 +48941,7 @@ MA_API ma_result ma_gainer_process_pcm_frames(ma_gainer* pGainer, void* pFramesO
for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
for (iChannel = 0; iChannel < channelCount; iChannel += 1) {
- pFramesOutF32[iChannel] = pFramesInF32[iChannel] * ma_mix_f32_fast(pGainer->pOldGains[iChannel], pGainer->pNewGains[iChannel], a);
+ pFramesOutF32[iChannel] = pFramesInF32[iChannel] * ma_mix_f32_fast(pGainer->pOldGains[iChannel], pGainer->pNewGains[iChannel], a) * pGainer->masterVolume;
}
pFramesOutF32 += channelCount;
@@ -47097,7 +48961,7 @@ MA_API ma_result ma_gainer_process_pcm_frames(ma_gainer* pGainer, void* pFramesO
/* We can allow the input and output buffers to be null in which case we'll just update the internal timer. */
if (pFramesOut != NULL && pFramesIn != NULL) {
for (iChannel = 0; iChannel < pGainer->config.channels; iChannel += 1) {
- pFramesOutF32[iFrame*pGainer->config.channels + iChannel] = pFramesInF32[iFrame*pGainer->config.channels + iChannel] * ma_gainer_calculate_current_gain(pGainer, iChannel);
+ pFramesOutF32[iFrame * pGainer->config.channels + iChannel] = pFramesInF32[iFrame * pGainer->config.channels + iChannel] * ma_gainer_calculate_current_gain(pGainer, iChannel) * pGainer->masterVolume;
}
}
@@ -47106,10 +48970,24 @@ MA_API ma_result ma_gainer_process_pcm_frames(ma_gainer* pGainer, void* pFramesO
}
#endif
}
+#endif
return MA_SUCCESS;
}
+MA_API ma_result ma_gainer_process_pcm_frames(ma_gainer* pGainer, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
+{
+ if (pGainer == NULL) {
+ return MA_INVALID_ARGS;
+ }
+
+ /*
+ ma_gainer_process_pcm_frames_internal() marks pFramesOut and pFramesIn with MA_RESTRICT which
+ helps with auto-vectorization.
+ */
+ return ma_gainer_process_pcm_frames_internal(pGainer, pFramesOut, pFramesIn, frameCount);
+}
+
static void ma_gainer_set_gain_by_index(ma_gainer* pGainer, float newGain, ma_uint32 iChannel)
{
pGainer->pOldGains[iChannel] = ma_gainer_calculate_current_gain(pGainer, iChannel);
@@ -47161,6 +49039,28 @@ MA_API ma_result ma_gainer_set_gains(ma_gainer* pGainer, float* pNewGains)
return MA_SUCCESS;
}
+MA_API ma_result ma_gainer_set_master_volume(ma_gainer* pGainer, float volume)
+{
+ if (pGainer == NULL) {
+ return MA_INVALID_ARGS;
+ }
+
+ pGainer->masterVolume = volume;
+
+ return MA_SUCCESS;
+}
+
+MA_API ma_result ma_gainer_get_master_volume(const ma_gainer* pGainer, float* pVolume)
+{
+ if (pGainer == NULL || pVolume == NULL) {
+ return MA_INVALID_ARGS;
+ }
+
+ *pVolume = pGainer->masterVolume;
+
+ return MA_SUCCESS;
+}
+
MA_API ma_panner_config ma_panner_config_init(ma_format format, ma_uint32 channels)
{
@@ -47510,7 +49410,7 @@ MA_API void ma_fader_set_fade(ma_fader* pFader, float volumeBeg, float volumeEnd
pFader->cursorInFrames = 0; /* Reset cursor. */
}
-MA_API float ma_fader_get_current_volume(ma_fader* pFader)
+MA_API float ma_fader_get_current_volume(const ma_fader* pFader)
{
if (pFader == NULL) {
return 0.0f;
@@ -47575,6 +49475,8 @@ MA_API float ma_vec3f_len(ma_vec3f v)
return (float)ma_sqrtd(ma_vec3f_len2(v));
}
+
+
MA_API float ma_vec3f_dist(ma_vec3f a, ma_vec3f b)
{
return ma_vec3f_len(ma_vec3f_sub(a, b));
@@ -47582,16 +49484,16 @@ MA_API float ma_vec3f_dist(ma_vec3f a, ma_vec3f b)
MA_API ma_vec3f ma_vec3f_normalize(ma_vec3f v)
{
- float f;
- float l = ma_vec3f_len(v);
- if (l == 0) {
+ float invLen;
+ float len2 = ma_vec3f_len2(v);
+ if (len2 == 0) {
return ma_vec3f_init_3f(0, 0, 0);
}
- f = 1 / l;
- v.x *= f;
- v.y *= f;
- v.z *= f;
+ invLen = ma_rsqrtf(len2);
+ v.x *= invLen;
+ v.y *= invLen;
+ v.z *= invLen;
return v;
}
@@ -47606,6 +49508,35 @@ MA_API ma_vec3f ma_vec3f_cross(ma_vec3f a, ma_vec3f b)
}
+MA_API void ma_atomic_vec3f_init(ma_atomic_vec3f* v, ma_vec3f value)
+{
+ v->v = value;
+ v->lock = 0; /* Important this is initialized to 0. */
+}
+
+MA_API void ma_atomic_vec3f_set(ma_atomic_vec3f* v, ma_vec3f value)
+{
+ ma_spinlock_lock(&v->lock);
+ {
+ v->v = value;
+ }
+ ma_spinlock_unlock(&v->lock);
+}
+
+MA_API ma_vec3f ma_atomic_vec3f_get(ma_atomic_vec3f* v)
+{
+ ma_vec3f r;
+
+ ma_spinlock_lock(&v->lock);
+ {
+ r = v->v;
+ }
+ ma_spinlock_unlock(&v->lock);
+
+ return r;
+}
+
+
static void ma_channel_map_apply_f32(float* pFramesOut, const ma_channel* pChannelMapOut, ma_uint32 channelsOut, const float* pFramesIn, const ma_channel* pChannelMapIn, ma_uint32 channelsIn, ma_uint64 frameCount, ma_channel_mix_mode mode, ma_mono_expansion_mode monoExpansionMode);
static ma_bool32 ma_is_spatial_channel_position(ma_channel channelPosition);
@@ -47856,14 +49787,15 @@ MA_API ma_result ma_spatializer_listener_init_preallocated(const ma_spatializer_
MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes);
pListener->config = *pConfig;
- pListener->position = ma_vec3f_init_3f(0, 0, 0);
- pListener->direction = ma_vec3f_init_3f(0, 0, -1);
- pListener->velocity = ma_vec3f_init_3f(0, 0, 0);
+ ma_atomic_vec3f_init(&pListener->position, ma_vec3f_init_3f(0, 0, 0));
+ ma_atomic_vec3f_init(&pListener->direction, ma_vec3f_init_3f(0, 0, -1));
+ ma_atomic_vec3f_init(&pListener->velocity, ma_vec3f_init_3f(0, 0, 0));
pListener->isEnabled = MA_TRUE;
/* Swap the forward direction if we're left handed (it was initialized based on right handed). */
if (pListener->config.handedness == ma_handedness_left) {
- pListener->direction = ma_vec3f_neg(pListener->direction);
+ ma_vec3f negDir = ma_vec3f_neg(ma_spatializer_listener_get_direction(pListener));
+ ma_spatializer_listener_set_direction(pListener, negDir.x, negDir.y, negDir.z);
}
@@ -47966,7 +49898,7 @@ MA_API void ma_spatializer_listener_set_position(ma_spatializer_listener* pListe
return;
}
- pListener->position = ma_vec3f_init_3f(x, y, z);
+ ma_atomic_vec3f_set(&pListener->position, ma_vec3f_init_3f(x, y, z));
}
MA_API ma_vec3f ma_spatializer_listener_get_position(const ma_spatializer_listener* pListener)
@@ -47975,7 +49907,7 @@ MA_API ma_vec3f ma_spatializer_listener_get_position(const ma_spatializer_listen
return ma_vec3f_init_3f(0, 0, 0);
}
- return pListener->position;
+ return ma_atomic_vec3f_get((ma_atomic_vec3f*)&pListener->position); /* Naughty const-cast. It's just for atomically loading the vec3 which should be safe. */
}
MA_API void ma_spatializer_listener_set_direction(ma_spatializer_listener* pListener, float x, float y, float z)
@@ -47984,7 +49916,7 @@ MA_API void ma_spatializer_listener_set_direction(ma_spatializer_listener* pList
return;
}
- pListener->direction = ma_vec3f_init_3f(x, y, z);
+ ma_atomic_vec3f_set(&pListener->direction, ma_vec3f_init_3f(x, y, z));
}
MA_API ma_vec3f ma_spatializer_listener_get_direction(const ma_spatializer_listener* pListener)
@@ -47993,7 +49925,7 @@ MA_API ma_vec3f ma_spatializer_listener_get_direction(const ma_spatializer_liste
return ma_vec3f_init_3f(0, 0, -1);
}
- return pListener->direction;
+ return ma_atomic_vec3f_get((ma_atomic_vec3f*)&pListener->direction); /* Naughty const-cast. It's just for atomically loading the vec3 which should be safe. */
}
MA_API void ma_spatializer_listener_set_velocity(ma_spatializer_listener* pListener, float x, float y, float z)
@@ -48002,7 +49934,7 @@ MA_API void ma_spatializer_listener_set_velocity(ma_spatializer_listener* pListe
return;
}
- pListener->velocity = ma_vec3f_init_3f(x, y, z);
+ ma_atomic_vec3f_set(&pListener->velocity, ma_vec3f_init_3f(x, y, z));
}
MA_API ma_vec3f ma_spatializer_listener_get_velocity(const ma_spatializer_listener* pListener)
@@ -48011,7 +49943,7 @@ MA_API ma_vec3f ma_spatializer_listener_get_velocity(const ma_spatializer_listen
return ma_vec3f_init_3f(0, 0, 0);
}
- return pListener->velocity;
+ return ma_atomic_vec3f_get((ma_atomic_vec3f*)&pListener->velocity); /* Naughty const-cast. It's just for atomically loading the vec3 which should be safe. */
}
MA_API void ma_spatializer_listener_set_speed_of_sound(ma_spatializer_listener* pListener, float speedOfSound)
@@ -48092,6 +50024,7 @@ MA_API ma_spatializer_config ma_spatializer_config_init(ma_uint32 channelsIn, ma
config.coneOuterGain = 0.0f;
config.dopplerFactor = 1;
config.directionalAttenuationFactor = 1;
+ config.minSpatializationChannelGain = 0.2f;
config.gainSmoothTimeInFrames = 360; /* 7.5ms @ 48K. */
return config;
@@ -48232,16 +50165,18 @@ MA_API ma_result ma_spatializer_init_preallocated(const ma_spatializer_config* p
pSpatializer->coneOuterAngleInRadians = pConfig->coneOuterAngleInRadians;
pSpatializer->coneOuterGain = pConfig->coneOuterGain;
pSpatializer->dopplerFactor = pConfig->dopplerFactor;
+ pSpatializer->minSpatializationChannelGain = pConfig->minSpatializationChannelGain;
pSpatializer->directionalAttenuationFactor = pConfig->directionalAttenuationFactor;
pSpatializer->gainSmoothTimeInFrames = pConfig->gainSmoothTimeInFrames;
- pSpatializer->position = ma_vec3f_init_3f(0, 0, 0);
- pSpatializer->direction = ma_vec3f_init_3f(0, 0, -1);
- pSpatializer->velocity = ma_vec3f_init_3f(0, 0, 0);
+ ma_atomic_vec3f_init(&pSpatializer->position, ma_vec3f_init_3f(0, 0, 0));
+ ma_atomic_vec3f_init(&pSpatializer->direction, ma_vec3f_init_3f(0, 0, -1));
+ ma_atomic_vec3f_init(&pSpatializer->velocity, ma_vec3f_init_3f(0, 0, 0));
pSpatializer->dopplerPitch = 1;
/* Swap the forward direction if we're left handed (it was initialized based on right handed). */
if (pSpatializer->handedness == ma_handedness_left) {
- pSpatializer->direction = ma_vec3f_neg(pSpatializer->direction);
+ ma_vec3f negDir = ma_vec3f_neg(ma_spatializer_get_direction(pSpatializer));
+ ma_spatializer_set_direction(pSpatializer, negDir.x, negDir.y, negDir.z);
}
/* Channel map. This will be on the heap. */
@@ -48406,7 +50341,7 @@ MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer,
defined by the listener, so we'll grab that here too.
*/
if (pListener != NULL) {
- listenerVel = pListener->velocity;
+ listenerVel = ma_spatializer_listener_get_velocity(pListener);
speedOfSound = pListener->config.speedOfSound;
} else {
listenerVel = ma_vec3f_init_3f(0, 0, 0);
@@ -48415,8 +50350,8 @@ MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer,
if (pListener == NULL || ma_spatializer_get_positioning(pSpatializer) == ma_positioning_relative) {
/* There's no listener or we're using relative positioning. */
- relativePos = pSpatializer->position;
- relativeDir = pSpatializer->direction;
+ relativePos = ma_spatializer_get_position(pSpatializer);
+ relativeDir = ma_spatializer_get_direction(pSpatializer);
} else {
/*
We've found a listener and we're using absolute positioning. We need to transform the
@@ -48512,6 +50447,26 @@ MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer,
/* Clamp the gain. */
gain = ma_clamp(gain, ma_spatializer_get_min_gain(pSpatializer), ma_spatializer_get_max_gain(pSpatializer));
+ /*
+ The gain needs to be applied per-channel here. The spatialization code below will be changing the per-channel
+ gains which will then eventually be passed into the gainer which will deal with smoothing the gain transitions
+ to avoid harsh changes in gain.
+ */
+ for (iChannel = 0; iChannel < channelsOut; iChannel += 1) {
+ pSpatializer->pNewChannelGainsOut[iChannel] = gain;
+ }
+
+ /*
+ Convert to our output channel count. If the listener is disabled we just output silence here. We cannot ignore
+ the whole section of code here because we need to update some internal spatialization state.
+ */
+ if (ma_spatializer_listener_is_enabled(pListener)) {
+ ma_channel_map_apply_f32((float*)pFramesOut, pChannelMapOut, channelsOut, (const float*)pFramesIn, pChannelMapIn, channelsIn, frameCount, ma_channel_mix_mode_rectangular, ma_mono_expansion_mode_default);
+ } else {
+ ma_silence_pcm_frames(pFramesOut, frameCount, ma_format_f32, pSpatializer->channelsOut);
+ }
+
+
/*
Panning. This is where we'll apply the gain and convert to the output channel count. We have an optimized path for
when we're converting to a mono stream. In that case we don't really need to do any panning - we just apply the
@@ -48533,19 +50488,6 @@ MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer,
be +1 on the X axis. A dot product is performed against the direction vector of the channel and the normalized
position of the sound.
*/
- for (iChannel = 0; iChannel < channelsOut; iChannel += 1) {
- pSpatializer->pNewChannelGainsOut[iChannel] = gain;
- }
-
- /*
- Convert to our output channel count. If the listener is disabled we just output silence here. We cannot ignore
- the whole section of code here because we need to update some internal spatialization state.
- */
- if (ma_spatializer_listener_is_enabled(pListener)) {
- ma_channel_map_apply_f32((float*)pFramesOut, pChannelMapOut, channelsOut, (const float*)pFramesIn, pChannelMapIn, channelsIn, frameCount, ma_channel_mix_mode_rectangular, ma_mono_expansion_mode_default);
- } else {
- ma_silence_pcm_frames(pFramesOut, frameCount, ma_format_f32, pSpatializer->channelsOut);
- }
/*
Calculate our per-channel gains. We do this based on the normalized relative position of the sound and it's
@@ -48576,13 +50518,13 @@ MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer,
0, panning will be most extreme and any sounds that are positioned on the opposite side of the
speaker will be completely silent from that speaker. Not only does this feel uncomfortable, it
doesn't even remotely represent the real world at all because sounds that come from your right side
- are still clearly audible from your left side. Setting "dMin" to 1 will result in no panning at
+ are still clearly audible from your left side. Setting "dMin" to 1 will result in no panning at
all, which is also not ideal. By setting it to something greater than 0, the spatialization effect
becomes much less dramatic and a lot more bearable.
Summary: 0 = more extreme panning; 1 = no panning.
*/
- dMin = 0.2f; /* TODO: Consider making this configurable. */
+ dMin = pSpatializer->minSpatializationChannelGain;
/*
At this point, "d" will be positive if the sound is on the same side as the channel and negative if
@@ -48645,7 +50587,7 @@ MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer,
source.
*/
if (dopplerFactor > 0) {
- pSpatializer->dopplerPitch = ma_doppler_pitch(ma_vec3f_sub(pListener->position, pSpatializer->position), pSpatializer->velocity, listenerVel, speedOfSound, dopplerFactor);
+ pSpatializer->dopplerPitch = ma_doppler_pitch(ma_vec3f_sub(ma_spatializer_listener_get_position(pListener), ma_spatializer_get_position(pSpatializer)), ma_spatializer_get_velocity(pSpatializer), listenerVel, speedOfSound, dopplerFactor);
} else {
pSpatializer->dopplerPitch = 1;
}
@@ -48654,6 +50596,24 @@ MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer,
return MA_SUCCESS;
}
+MA_API ma_result ma_spatializer_set_master_volume(ma_spatializer* pSpatializer, float volume)
+{
+ if (pSpatializer == NULL) {
+ return MA_INVALID_ARGS;
+ }
+
+ return ma_gainer_set_master_volume(&pSpatializer->gainer, volume);
+}
+
+MA_API ma_result ma_spatializer_get_master_volume(const ma_spatializer* pSpatializer, float* pVolume)
+{
+ if (pSpatializer == NULL) {
+ return MA_INVALID_ARGS;
+ }
+
+ return ma_gainer_get_master_volume(&pSpatializer->gainer, pVolume);
+}
+
MA_API ma_uint32 ma_spatializer_get_input_channels(const ma_spatializer* pSpatializer)
{
if (pSpatializer == NULL) {
@@ -48870,7 +50830,7 @@ MA_API void ma_spatializer_set_position(ma_spatializer* pSpatializer, float x, f
return;
}
- pSpatializer->position = ma_vec3f_init_3f(x, y, z);
+ ma_atomic_vec3f_set(&pSpatializer->position, ma_vec3f_init_3f(x, y, z));
}
MA_API ma_vec3f ma_spatializer_get_position(const ma_spatializer* pSpatializer)
@@ -48879,7 +50839,7 @@ MA_API ma_vec3f ma_spatializer_get_position(const ma_spatializer* pSpatializer)
return ma_vec3f_init_3f(0, 0, 0);
}
- return pSpatializer->position;
+ return ma_atomic_vec3f_get((ma_atomic_vec3f*)&pSpatializer->position); /* Naughty const-cast. It's just for atomically loading the vec3 which should be safe. */
}
MA_API void ma_spatializer_set_direction(ma_spatializer* pSpatializer, float x, float y, float z)
@@ -48888,7 +50848,7 @@ MA_API void ma_spatializer_set_direction(ma_spatializer* pSpatializer, float x,
return;
}
- pSpatializer->direction = ma_vec3f_init_3f(x, y, z);
+ ma_atomic_vec3f_set(&pSpatializer->direction, ma_vec3f_init_3f(x, y, z));
}
MA_API ma_vec3f ma_spatializer_get_direction(const ma_spatializer* pSpatializer)
@@ -48897,7 +50857,7 @@ MA_API ma_vec3f ma_spatializer_get_direction(const ma_spatializer* pSpatializer)
return ma_vec3f_init_3f(0, 0, -1);
}
- return pSpatializer->direction;
+ return ma_atomic_vec3f_get((ma_atomic_vec3f*)&pSpatializer->direction); /* Naughty const-cast. It's just for atomically loading the vec3 which should be safe. */
}
MA_API void ma_spatializer_set_velocity(ma_spatializer* pSpatializer, float x, float y, float z)
@@ -48906,7 +50866,7 @@ MA_API void ma_spatializer_set_velocity(ma_spatializer* pSpatializer, float x, f
return;
}
- pSpatializer->velocity = ma_vec3f_init_3f(x, y, z);
+ ma_atomic_vec3f_set(&pSpatializer->velocity, ma_vec3f_init_3f(x, y, z));
}
MA_API ma_vec3f ma_spatializer_get_velocity(const ma_spatializer* pSpatializer)
@@ -48915,7 +50875,7 @@ MA_API ma_vec3f ma_spatializer_get_velocity(const ma_spatializer* pSpatializer)
return ma_vec3f_init_3f(0, 0, 0);
}
- return pSpatializer->velocity;
+ return ma_atomic_vec3f_get((ma_atomic_vec3f*)&pSpatializer->velocity); /* Naughty const-cast. It's just for atomically loading the vec3 which should be safe. */
}
MA_API void ma_spatializer_get_relative_position_and_direction(const ma_spatializer* pSpatializer, const ma_spatializer_listener* pListener, ma_vec3f* pRelativePos, ma_vec3f* pRelativeDir)
@@ -48939,23 +50899,32 @@ MA_API void ma_spatializer_get_relative_position_and_direction(const ma_spatiali
if (pListener == NULL || ma_spatializer_get_positioning(pSpatializer) == ma_positioning_relative) {
/* There's no listener or we're using relative positioning. */
if (pRelativePos != NULL) {
- *pRelativePos = pSpatializer->position;
+ *pRelativePos = ma_spatializer_get_position(pSpatializer);
}
if (pRelativeDir != NULL) {
- *pRelativeDir = pSpatializer->direction;
+ *pRelativeDir = ma_spatializer_get_direction(pSpatializer);
}
} else {
+ ma_vec3f spatializerPosition;
+ ma_vec3f spatializerDirection;
+ ma_vec3f listenerPosition;
+ ma_vec3f listenerDirection;
ma_vec3f v;
ma_vec3f axisX;
ma_vec3f axisY;
ma_vec3f axisZ;
float m[4][4];
+ spatializerPosition = ma_spatializer_get_position(pSpatializer);
+ spatializerDirection = ma_spatializer_get_direction(pSpatializer);
+ listenerPosition = ma_spatializer_listener_get_position(pListener);
+ listenerDirection = ma_spatializer_listener_get_direction(pListener);
+
/*
We need to calcualte the right vector from our forward and up vectors. This is done with
a cross product.
*/
- axisZ = ma_vec3f_normalize(pListener->direction); /* Normalization required here because we can't trust the caller. */
+ axisZ = ma_vec3f_normalize(listenerDirection); /* Normalization required here because we can't trust the caller. */
axisX = ma_vec3f_normalize(ma_vec3f_cross(axisZ, pListener->config.worldUp)); /* Normalization required here because the world up vector may not be perpendicular with the forward vector. */
/*
@@ -48980,9 +50949,9 @@ MA_API void ma_spatializer_get_relative_position_and_direction(const ma_spatiali
}
/* Lookat. */
- m[0][0] = axisX.x; m[1][0] = axisX.y; m[2][0] = axisX.z; m[3][0] = -ma_vec3f_dot(axisX, pListener->position);
- m[0][1] = axisY.x; m[1][1] = axisY.y; m[2][1] = axisY.z; m[3][1] = -ma_vec3f_dot(axisY, pListener->position);
- m[0][2] = -axisZ.x; m[1][2] = -axisZ.y; m[2][2] = -axisZ.z; m[3][2] = -ma_vec3f_dot(ma_vec3f_neg(axisZ), pListener->position);
+ m[0][0] = axisX.x; m[1][0] = axisX.y; m[2][0] = axisX.z; m[3][0] = -ma_vec3f_dot(axisX, listenerPosition);
+ m[0][1] = axisY.x; m[1][1] = axisY.y; m[2][1] = axisY.z; m[3][1] = -ma_vec3f_dot(axisY, listenerPosition);
+ m[0][2] = -axisZ.x; m[1][2] = -axisZ.y; m[2][2] = -axisZ.z; m[3][2] = -ma_vec3f_dot(ma_vec3f_neg(axisZ), listenerPosition);
m[0][3] = 0; m[1][3] = 0; m[2][3] = 0; m[3][3] = 1;
/*
@@ -48991,7 +50960,7 @@ MA_API void ma_spatializer_get_relative_position_and_direction(const ma_spatiali
origin which makes things simpler.
*/
if (pRelativePos != NULL) {
- v = pSpatializer->position;
+ v = spatializerPosition;
pRelativePos->x = m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * 1;
pRelativePos->y = m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * 1;
pRelativePos->z = m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z + m[3][2] * 1;
@@ -49002,7 +50971,7 @@ MA_API void ma_spatializer_get_relative_position_and_direction(const ma_spatiali
rotation of the listener.
*/
if (pRelativeDir != NULL) {
- v = pSpatializer->direction;
+ v = spatializerDirection;
pRelativeDir->x = m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z;
pRelativeDir->y = m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z;
pRelativeDir->z = m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z;
@@ -49158,7 +51127,7 @@ static ma_result ma_linear_resampler_get_heap_layout(const ma_linear_resampler_c
}
/* LPF */
- pHeapLayout->lpfOffset = pHeapLayout->sizeInBytes;
+ pHeapLayout->lpfOffset = ma_align_64(pHeapLayout->sizeInBytes);
{
ma_result result;
size_t lpfHeapSizeInBytes;
@@ -50084,6 +52053,7 @@ MA_API ma_result ma_resampler_init(const ma_resampler_config* pConfig, const ma_
result = ma_resampler_init_preallocated(pConfig, pHeap, pResampler);
if (result != MA_SUCCESS) {
+ ma_free(pHeap, pAllocationCallbacks);
return result;
}
@@ -50388,6 +52358,23 @@ static ma_int32 ma_channel_converter_float_to_fixed(float x)
return (ma_int32)(x * (1< 0);
+
+ for (iChannel = 0; iChannel < channels; ++iChannel) {
+ if (ma_is_spatial_channel_position(ma_channel_map_get_channel(pChannelMap, channels, iChannel))) {
+ spatialChannelCount++;
+ }
+ }
+
+ return spatialChannelCount;
+}
+
static ma_bool32 ma_is_spatial_channel_position(ma_channel channelPosition)
{
int i;
@@ -50724,7 +52711,7 @@ static ma_result ma_channel_map_apply_mono_out_f32(float* pFramesOut, const floa
return MA_SUCCESS;
}
-static ma_result ma_channel_map_apply_mono_in_f32(float* pFramesOut, const ma_channel* pChannelMapOut, ma_uint32 channelsOut, const float* pFramesIn, ma_uint64 frameCount, ma_mono_expansion_mode monoExpansionMode)
+static ma_result ma_channel_map_apply_mono_in_f32(float* MA_RESTRICT pFramesOut, const ma_channel* pChannelMapOut, ma_uint32 channelsOut, const float* MA_RESTRICT pFramesIn, ma_uint64 frameCount, ma_mono_expansion_mode monoExpansionMode)
{
ma_uint64 iFrame;
ma_uint32 iChannelOut;
@@ -50829,16 +52816,123 @@ static ma_result ma_channel_map_apply_mono_in_f32(float* pFramesOut, const ma_ch
{
default_handler:
{
- for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
+ if (channelsOut <= MA_MAX_CHANNELS) {
+ ma_bool32 hasEmptyChannel = MA_FALSE;
+ ma_channel channelPositions[MA_MAX_CHANNELS];
for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) {
- ma_channel channelOut = ma_channel_map_get_channel(pChannelMapOut, channelsOut, iChannelOut);
- if (channelOut != MA_CHANNEL_NONE) {
- pFramesOut[iChannelOut] = pFramesIn[0];
+ channelPositions[iChannelOut] = ma_channel_map_get_channel(pChannelMapOut, channelsOut, iChannelOut);
+ if (channelPositions[iChannelOut] == MA_CHANNEL_NONE) {
+ hasEmptyChannel = MA_TRUE;
}
}
- pFramesOut += channelsOut;
- pFramesIn += 1;
+ if (hasEmptyChannel == MA_FALSE) {
+ /*
+ Faster path when there's no MA_CHANNEL_NONE channel positions. This should hopefully
+ help the compiler with auto-vectorization.m
+ */
+ if (channelsOut == 2) {
+ #if defined(MA_SUPPORT_SSE2)
+ if (ma_has_sse2()) {
+ /* We want to do two frames in each iteration. */
+ ma_uint64 unrolledFrameCount = frameCount >> 1;
+
+ for (iFrame = 0; iFrame < unrolledFrameCount; iFrame += 1) {
+ __m128 in0 = _mm_set1_ps(pFramesIn[iFrame*2 + 0]);
+ __m128 in1 = _mm_set1_ps(pFramesIn[iFrame*2 + 1]);
+ _mm_storeu_ps(&pFramesOut[iFrame*4 + 0], _mm_shuffle_ps(in1, in0, _MM_SHUFFLE(0, 0, 0, 0)));
+ }
+
+ /* Tail. */
+ iFrame = unrolledFrameCount << 1;
+ goto generic_on_fastpath;
+ } else
+ #endif
+ {
+ for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
+ for (iChannelOut = 0; iChannelOut < 2; iChannelOut += 1) {
+ pFramesOut[iFrame*2 + iChannelOut] = pFramesIn[iFrame];
+ }
+ }
+ }
+ } else if (channelsOut == 6) {
+ #if defined(MA_SUPPORT_SSE2)
+ if (ma_has_sse2()) {
+ /* We want to do two frames in each iteration so we can have a multiple of 4 samples. */
+ ma_uint64 unrolledFrameCount = frameCount >> 1;
+
+ for (iFrame = 0; iFrame < unrolledFrameCount; iFrame += 1) {
+ __m128 in0 = _mm_set1_ps(pFramesIn[iFrame*2 + 0]);
+ __m128 in1 = _mm_set1_ps(pFramesIn[iFrame*2 + 1]);
+
+ _mm_storeu_ps(&pFramesOut[iFrame*12 + 0], in0);
+ _mm_storeu_ps(&pFramesOut[iFrame*12 + 4], _mm_shuffle_ps(in1, in0, _MM_SHUFFLE(0, 0, 0, 0)));
+ _mm_storeu_ps(&pFramesOut[iFrame*12 + 8], in1);
+ }
+
+ /* Tail. */
+ iFrame = unrolledFrameCount << 1;
+ goto generic_on_fastpath;
+ } else
+ #endif
+ {
+ for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
+ for (iChannelOut = 0; iChannelOut < 6; iChannelOut += 1) {
+ pFramesOut[iFrame*6 + iChannelOut] = pFramesIn[iFrame];
+ }
+ }
+ }
+ } else if (channelsOut == 8) {
+ #if defined(MA_SUPPORT_SSE2)
+ if (ma_has_sse2()) {
+ for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
+ __m128 in = _mm_set1_ps(pFramesIn[iFrame]);
+ _mm_storeu_ps(&pFramesOut[iFrame*8 + 0], in);
+ _mm_storeu_ps(&pFramesOut[iFrame*8 + 4], in);
+ }
+ } else
+ #endif
+ {
+ for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
+ for (iChannelOut = 0; iChannelOut < 8; iChannelOut += 1) {
+ pFramesOut[iFrame*8 + iChannelOut] = pFramesIn[iFrame];
+ }
+ }
+ }
+ } else {
+ iFrame = 0;
+
+ #if defined(MA_SUPPORT_SSE2) /* For silencing a warning with non-x86 builds. */
+ generic_on_fastpath:
+ #endif
+ {
+ for (; iFrame < frameCount; iFrame += 1) {
+ for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) {
+ pFramesOut[iFrame*channelsOut + iChannelOut] = pFramesIn[iFrame];
+ }
+ }
+ }
+ }
+ } else {
+ /* Slow path. Need to handle MA_CHANNEL_NONE. */
+ for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
+ for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) {
+ if (channelPositions[iChannelOut] != MA_CHANNEL_NONE) {
+ pFramesOut[iFrame*channelsOut + iChannelOut] = pFramesIn[iFrame];
+ }
+ }
+ }
+ }
+ } else {
+ /* Slow path. Too many channels to store on the stack. */
+ for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
+ for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) {
+ ma_channel channelOut = ma_channel_map_get_channel(pChannelMapOut, channelsOut, iChannelOut);
+ if (channelOut != MA_CHANNEL_NONE) {
+ pFramesOut[iFrame*channelsOut + iChannelOut] = pFramesIn[iFrame];
+ }
+ }
+ }
}
}
} break;
@@ -50905,19 +52999,105 @@ static void ma_channel_map_apply_f32(float* pFramesOut, const ma_channel* pChann
}
}
- for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
+ iFrame = 0;
+
+ /* Experiment: Try an optimized unroll for some specific cases to see how it improves performance. RESULT: Good gains. */
+ if (channelsOut == 8) {
+ /* Experiment 2: Expand the inner loop to see what kind of different it makes. RESULT: Small, but worthwhile gain. */
+ if (channelsIn == 2) {
+ for (; iFrame < frameCount; iFrame += 1) {
+ float accumulation[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+
+ accumulation[0] += pFramesIn[iFrame*2 + 0] * weights[0][0];
+ accumulation[1] += pFramesIn[iFrame*2 + 0] * weights[1][0];
+ accumulation[2] += pFramesIn[iFrame*2 + 0] * weights[2][0];
+ accumulation[3] += pFramesIn[iFrame*2 + 0] * weights[3][0];
+ accumulation[4] += pFramesIn[iFrame*2 + 0] * weights[4][0];
+ accumulation[5] += pFramesIn[iFrame*2 + 0] * weights[5][0];
+ accumulation[6] += pFramesIn[iFrame*2 + 0] * weights[6][0];
+ accumulation[7] += pFramesIn[iFrame*2 + 0] * weights[7][0];
+
+ accumulation[0] += pFramesIn[iFrame*2 + 1] * weights[0][1];
+ accumulation[1] += pFramesIn[iFrame*2 + 1] * weights[1][1];
+ accumulation[2] += pFramesIn[iFrame*2 + 1] * weights[2][1];
+ accumulation[3] += pFramesIn[iFrame*2 + 1] * weights[3][1];
+ accumulation[4] += pFramesIn[iFrame*2 + 1] * weights[4][1];
+ accumulation[5] += pFramesIn[iFrame*2 + 1] * weights[5][1];
+ accumulation[6] += pFramesIn[iFrame*2 + 1] * weights[6][1];
+ accumulation[7] += pFramesIn[iFrame*2 + 1] * weights[7][1];
+
+ pFramesOut[iFrame*8 + 0] = accumulation[0];
+ pFramesOut[iFrame*8 + 1] = accumulation[1];
+ pFramesOut[iFrame*8 + 2] = accumulation[2];
+ pFramesOut[iFrame*8 + 3] = accumulation[3];
+ pFramesOut[iFrame*8 + 4] = accumulation[4];
+ pFramesOut[iFrame*8 + 5] = accumulation[5];
+ pFramesOut[iFrame*8 + 6] = accumulation[6];
+ pFramesOut[iFrame*8 + 7] = accumulation[7];
+ }
+ } else {
+ /* When outputting to 8 channels, we can do everything in groups of two 4x SIMD operations. */
+ for (; iFrame < frameCount; iFrame += 1) {
+ float accumulation[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+
+ for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) {
+ accumulation[0] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[0][iChannelIn];
+ accumulation[1] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[1][iChannelIn];
+ accumulation[2] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[2][iChannelIn];
+ accumulation[3] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[3][iChannelIn];
+ accumulation[4] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[4][iChannelIn];
+ accumulation[5] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[5][iChannelIn];
+ accumulation[6] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[6][iChannelIn];
+ accumulation[7] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[7][iChannelIn];
+ }
+
+ pFramesOut[iFrame*8 + 0] = accumulation[0];
+ pFramesOut[iFrame*8 + 1] = accumulation[1];
+ pFramesOut[iFrame*8 + 2] = accumulation[2];
+ pFramesOut[iFrame*8 + 3] = accumulation[3];
+ pFramesOut[iFrame*8 + 4] = accumulation[4];
+ pFramesOut[iFrame*8 + 5] = accumulation[5];
+ pFramesOut[iFrame*8 + 6] = accumulation[6];
+ pFramesOut[iFrame*8 + 7] = accumulation[7];
+ }
+ }
+ } else if (channelsOut == 6) {
+ /*
+ When outputting to 6 channels we unfortunately don't have a nice multiple of 4 to do 4x SIMD operations. Instead we'll
+ expand our weights and do two frames at a time.
+ */
+ for (; iFrame < frameCount; iFrame += 1) {
+ float accumulation[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+ for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) {
+ accumulation[0] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[0][iChannelIn];
+ accumulation[1] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[1][iChannelIn];
+ accumulation[2] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[2][iChannelIn];
+ accumulation[3] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[3][iChannelIn];
+ accumulation[4] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[4][iChannelIn];
+ accumulation[5] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[5][iChannelIn];
+ }
+
+ pFramesOut[iFrame*6 + 0] = accumulation[0];
+ pFramesOut[iFrame*6 + 1] = accumulation[1];
+ pFramesOut[iFrame*6 + 2] = accumulation[2];
+ pFramesOut[iFrame*6 + 3] = accumulation[3];
+ pFramesOut[iFrame*6 + 4] = accumulation[4];
+ pFramesOut[iFrame*6 + 5] = accumulation[5];
+ }
+ }
+
+ /* Leftover frames. */
+ for (; iFrame < frameCount; iFrame += 1) {
for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) {
float accumulation = 0;
for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) {
- accumulation += pFramesIn[iChannelIn] * weights[iChannelOut][iChannelIn];
+ accumulation += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[iChannelOut][iChannelIn];
}
- pFramesOut[iChannelOut] = accumulation;
+ pFramesOut[iFrame*channelsOut + iChannelOut] = accumulation;
}
-
- pFramesOut += channelsOut;
- pFramesIn += channelsIn;
}
} else {
/* Cannot pre-compute weights because not enough room in stack-allocated buffer. */
@@ -50928,14 +53108,11 @@ static void ma_channel_map_apply_f32(float* pFramesOut, const ma_channel* pChann
for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) {
ma_channel channelIn = ma_channel_map_get_channel(pChannelMapIn, channelsIn, iChannelIn);
- accumulation += pFramesIn[iChannelIn] * ma_calculate_channel_position_rectangular_weight(channelOut, channelIn);
+ accumulation += pFramesIn[iFrame*channelsIn + iChannelIn] * ma_calculate_channel_position_rectangular_weight(channelOut, channelIn);
}
- pFramesOut[iChannelOut] = accumulation;
+ pFramesOut[iFrame*channelsOut + iChannelOut] = accumulation;
}
-
- pFramesOut += channelsOut;
- pFramesIn += channelsIn;
}
}
}
@@ -51117,6 +53294,26 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert
/*
We now need to fill out our weights table. This is determined by the mixing mode.
*/
+
+ /* In all cases we need to make sure all channels that are present in both channel maps have a 1:1 mapping. */
+ for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
+ ma_channel channelPosIn = ma_channel_map_get_channel(pConverter->pChannelMapIn, pConverter->channelsIn, iChannelIn);
+
+ for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
+ ma_channel channelPosOut = ma_channel_map_get_channel(pConverter->pChannelMapOut, pConverter->channelsOut, iChannelOut);
+
+ if (channelPosIn == channelPosOut) {
+ float weight = 1;
+
+ if (pConverter->format == ma_format_f32) {
+ pConverter->weights.f32[iChannelIn][iChannelOut] = weight;
+ } else {
+ pConverter->weights.s16[iChannelIn][iChannelOut] = ma_channel_converter_float_to_fixed(weight);
+ }
+ }
+ }
+ }
+
switch (pConverter->mixingMode)
{
case ma_channel_mix_mode_custom_weights:
@@ -51140,19 +53337,10 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert
case ma_channel_mix_mode_simple:
{
- /* In simple mode, excess channels need to be silenced or dropped. */
- ma_uint32 iChannel;
- for (iChannel = 0; iChannel < ma_min(pConverter->channelsIn, pConverter->channelsOut); iChannel += 1) {
- if (pConverter->format == ma_format_f32) {
- if (pConverter->weights.f32[iChannel][iChannel] == 0) {
- pConverter->weights.f32[iChannel][iChannel] = 1;
- }
- } else {
- if (pConverter->weights.s16[iChannel][iChannel] == 0) {
- pConverter->weights.s16[iChannel][iChannel] = ma_channel_converter_float_to_fixed(1);
- }
- }
- }
+ /*
+ In simple mode, only set weights for channels that have exactly matching types, leave the rest at
+ zero. The 1:1 mappings have already been covered before this switch statement.
+ */
} break;
case ma_channel_mix_mode_rectangular:
@@ -51160,12 +53348,12 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert
{
/* Unmapped input channels. */
for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
- ma_channel channelPosIn = pConverter->pChannelMapIn[iChannelIn];
+ ma_channel channelPosIn = ma_channel_map_get_channel(pConverter->pChannelMapIn, pConverter->channelsIn, iChannelIn);
if (ma_is_spatial_channel_position(channelPosIn)) {
if (!ma_channel_map_contains_channel_position(pConverter->channelsOut, pConverter->pChannelMapOut, channelPosIn)) {
for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
- ma_channel channelPosOut = pConverter->pChannelMapOut[iChannelOut];
+ ma_channel channelPosOut = ma_channel_map_get_channel(pConverter->pChannelMapOut, pConverter->channelsOut, iChannelOut);
if (ma_is_spatial_channel_position(channelPosOut)) {
float weight = 0;
@@ -51191,12 +53379,12 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert
/* Unmapped output channels. */
for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
- ma_channel channelPosOut = pConverter->pChannelMapOut[iChannelOut];
+ ma_channel channelPosOut = ma_channel_map_get_channel(pConverter->pChannelMapOut, pConverter->channelsOut, iChannelOut);
if (ma_is_spatial_channel_position(channelPosOut)) {
if (!ma_channel_map_contains_channel_position(pConverter->channelsIn, pConverter->pChannelMapIn, channelPosOut)) {
for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
- ma_channel channelPosIn = pConverter->pChannelMapIn[iChannelIn];
+ ma_channel channelPosIn = ma_channel_map_get_channel(pConverter->pChannelMapIn, pConverter->channelsIn, iChannelIn);
if (ma_is_spatial_channel_position(channelPosIn)) {
float weight = 0;
@@ -51219,6 +53407,32 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert
}
}
}
+
+ /* If LFE is in the output channel map but was not present in the input channel map, configure its weight now */
+ if (pConfig->calculateLFEFromSpatialChannels) {
+ if (!ma_channel_map_contains_channel_position(pConverter->channelsIn, pConverter->pChannelMapIn, MA_CHANNEL_LFE)) {
+ ma_uint32 spatialChannelCount = ma_channel_map_get_spatial_channel_count(pConverter->pChannelMapIn, pConverter->channelsIn);
+ ma_uint32 iChannelOutLFE;
+
+ if (spatialChannelCount > 0 && ma_channel_map_find_channel_position(pConverter->channelsOut, pConverter->pChannelMapOut, MA_CHANNEL_LFE, &iChannelOutLFE)) {
+ const float weightForLFE = 1.0f / spatialChannelCount;
+ for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
+ const ma_channel channelPosIn = ma_channel_map_get_channel(pConverter->pChannelMapIn, pConverter->channelsIn, iChannelIn);
+ if (ma_is_spatial_channel_position(channelPosIn)) {
+ if (pConverter->format == ma_format_f32) {
+ if (pConverter->weights.f32[iChannelIn][iChannelOutLFE] == 0) {
+ pConverter->weights.f32[iChannelIn][iChannelOutLFE] = weightForLFE;
+ }
+ } else {
+ if (pConverter->weights.s16[iChannelIn][iChannelOutLFE] == 0) {
+ pConverter->weights.s16[iChannelIn][iChannelOutLFE] = ma_channel_converter_float_to_fixed(weightForLFE);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
} break;
}
}
@@ -51643,7 +53857,7 @@ MA_API ma_result ma_channel_converter_get_output_channel_map(const ma_channel_co
Data Conversion
**************************************************************************************************************************************************************/
-MA_API ma_data_converter_config ma_data_converter_config_init_default()
+MA_API ma_data_converter_config ma_data_converter_config_init_default(void)
{
ma_data_converter_config config;
MA_ZERO_OBJECT(&config);
@@ -51720,6 +53934,7 @@ static ma_channel_converter_config ma_channel_converter_config_init_from_data_co
channelConverterConfig = ma_channel_converter_config_init(ma_data_converter_config_get_mid_format(pConfig), pConfig->channelsIn, pConfig->pChannelMapIn, pConfig->channelsOut, pConfig->pChannelMapOut, pConfig->channelMixMode);
channelConverterConfig.ppWeights = pConfig->ppChannelWeights;
+ channelConverterConfig.calculateLFEFromSpatialChannels = pConfig->calculateLFEFromSpatialChannels;
return channelConverterConfig;
}
@@ -53643,18 +55858,128 @@ MA_API ma_bool32 ma_channel_map_is_blank(const ma_channel* pChannelMap, ma_uint3
}
MA_API ma_bool32 ma_channel_map_contains_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition)
+{
+ return ma_channel_map_find_channel_position(channels, pChannelMap, channelPosition, NULL);
+}
+
+MA_API ma_bool32 ma_channel_map_find_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition, ma_uint32* pChannelIndex)
{
ma_uint32 iChannel;
+ if (pChannelIndex != NULL) {
+ *pChannelIndex = (ma_uint32)-1;
+ }
+
for (iChannel = 0; iChannel < channels; ++iChannel) {
if (ma_channel_map_get_channel(pChannelMap, channels, iChannel) == channelPosition) {
+ if (pChannelIndex != NULL) {
+ *pChannelIndex = iChannel;
+ }
+
return MA_TRUE;
}
}
+ /* Getting here means the channel position was not found. */
return MA_FALSE;
}
+MA_API size_t ma_channel_map_to_string(const ma_channel* pChannelMap, ma_uint32 channels, char* pBufferOut, size_t bufferCap)
+{
+ size_t len;
+ ma_uint32 iChannel;
+
+ len = 0;
+
+ for (iChannel = 0; iChannel < channels; iChannel += 1) {
+ const char* pChannelStr = ma_channel_position_to_string(ma_channel_map_get_channel(pChannelMap, channels, iChannel));
+ size_t channelStrLen = strlen(pChannelStr);
+
+ /* Append the string if necessary. */
+ if (pBufferOut != NULL && bufferCap > len + channelStrLen) {
+ MA_COPY_MEMORY(pBufferOut + len, pChannelStr, channelStrLen);
+ }
+ len += channelStrLen;
+
+ /* Append a space if it's not the last item. */
+ if (iChannel+1 < channels) {
+ if (pBufferOut != NULL && bufferCap > len + 1) {
+ pBufferOut[len] = ' ';
+ }
+ len += 1;
+ }
+ }
+
+ /* Null terminate. Don't increment the length here. */
+ if (pBufferOut != NULL && bufferCap > len + 1) {
+ pBufferOut[len] = '\0';
+ }
+
+ return len;
+}
+
+MA_API const char* ma_channel_position_to_string(ma_channel channel)
+{
+ switch (channel)
+ {
+ case MA_CHANNEL_NONE : return "CHANNEL_NONE";
+ case MA_CHANNEL_MONO : return "CHANNEL_MONO";
+ case MA_CHANNEL_FRONT_LEFT : return "CHANNEL_FRONT_LEFT";
+ case MA_CHANNEL_FRONT_RIGHT : return "CHANNEL_FRONT_RIGHT";
+ case MA_CHANNEL_FRONT_CENTER : return "CHANNEL_FRONT_CENTER";
+ case MA_CHANNEL_LFE : return "CHANNEL_LFE";
+ case MA_CHANNEL_BACK_LEFT : return "CHANNEL_BACK_LEFT";
+ case MA_CHANNEL_BACK_RIGHT : return "CHANNEL_BACK_RIGHT";
+ case MA_CHANNEL_FRONT_LEFT_CENTER : return "CHANNEL_FRONT_LEFT_CENTER ";
+ case MA_CHANNEL_FRONT_RIGHT_CENTER: return "CHANNEL_FRONT_RIGHT_CENTER";
+ case MA_CHANNEL_BACK_CENTER : return "CHANNEL_BACK_CENTER";
+ case MA_CHANNEL_SIDE_LEFT : return "CHANNEL_SIDE_LEFT";
+ case MA_CHANNEL_SIDE_RIGHT : return "CHANNEL_SIDE_RIGHT";
+ case MA_CHANNEL_TOP_CENTER : return "CHANNEL_TOP_CENTER";
+ case MA_CHANNEL_TOP_FRONT_LEFT : return "CHANNEL_TOP_FRONT_LEFT";
+ case MA_CHANNEL_TOP_FRONT_CENTER : return "CHANNEL_TOP_FRONT_CENTER";
+ case MA_CHANNEL_TOP_FRONT_RIGHT : return "CHANNEL_TOP_FRONT_RIGHT";
+ case MA_CHANNEL_TOP_BACK_LEFT : return "CHANNEL_TOP_BACK_LEFT";
+ case MA_CHANNEL_TOP_BACK_CENTER : return "CHANNEL_TOP_BACK_CENTER";
+ case MA_CHANNEL_TOP_BACK_RIGHT : return "CHANNEL_TOP_BACK_RIGHT";
+ case MA_CHANNEL_AUX_0 : return "CHANNEL_AUX_0";
+ case MA_CHANNEL_AUX_1 : return "CHANNEL_AUX_1";
+ case MA_CHANNEL_AUX_2 : return "CHANNEL_AUX_2";
+ case MA_CHANNEL_AUX_3 : return "CHANNEL_AUX_3";
+ case MA_CHANNEL_AUX_4 : return "CHANNEL_AUX_4";
+ case MA_CHANNEL_AUX_5 : return "CHANNEL_AUX_5";
+ case MA_CHANNEL_AUX_6 : return "CHANNEL_AUX_6";
+ case MA_CHANNEL_AUX_7 : return "CHANNEL_AUX_7";
+ case MA_CHANNEL_AUX_8 : return "CHANNEL_AUX_8";
+ case MA_CHANNEL_AUX_9 : return "CHANNEL_AUX_9";
+ case MA_CHANNEL_AUX_10 : return "CHANNEL_AUX_10";
+ case MA_CHANNEL_AUX_11 : return "CHANNEL_AUX_11";
+ case MA_CHANNEL_AUX_12 : return "CHANNEL_AUX_12";
+ case MA_CHANNEL_AUX_13 : return "CHANNEL_AUX_13";
+ case MA_CHANNEL_AUX_14 : return "CHANNEL_AUX_14";
+ case MA_CHANNEL_AUX_15 : return "CHANNEL_AUX_15";
+ case MA_CHANNEL_AUX_16 : return "CHANNEL_AUX_16";
+ case MA_CHANNEL_AUX_17 : return "CHANNEL_AUX_17";
+ case MA_CHANNEL_AUX_18 : return "CHANNEL_AUX_18";
+ case MA_CHANNEL_AUX_19 : return "CHANNEL_AUX_19";
+ case MA_CHANNEL_AUX_20 : return "CHANNEL_AUX_20";
+ case MA_CHANNEL_AUX_21 : return "CHANNEL_AUX_21";
+ case MA_CHANNEL_AUX_22 : return "CHANNEL_AUX_22";
+ case MA_CHANNEL_AUX_23 : return "CHANNEL_AUX_23";
+ case MA_CHANNEL_AUX_24 : return "CHANNEL_AUX_24";
+ case MA_CHANNEL_AUX_25 : return "CHANNEL_AUX_25";
+ case MA_CHANNEL_AUX_26 : return "CHANNEL_AUX_26";
+ case MA_CHANNEL_AUX_27 : return "CHANNEL_AUX_27";
+ case MA_CHANNEL_AUX_28 : return "CHANNEL_AUX_28";
+ case MA_CHANNEL_AUX_29 : return "CHANNEL_AUX_29";
+ case MA_CHANNEL_AUX_30 : return "CHANNEL_AUX_30";
+ case MA_CHANNEL_AUX_31 : return "CHANNEL_AUX_31";
+ default: break;
+ }
+
+ return "UNKNOWN";
+}
+
/**************************************************************************************************************************************************************
@@ -54186,6 +56511,85 @@ MA_API void* ma_rb_get_subbuffer_ptr(ma_rb* pRB, size_t subbufferIndex, void* pB
+static ma_result ma_pcm_rb_data_source__on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead)
+{
+ /* Since there's no notion of an end, we don't ever want to return MA_AT_END here. But it is possible to return 0. */
+ ma_pcm_rb* pRB = (ma_pcm_rb*)pDataSource;
+ ma_result result;
+ ma_uint64 totalFramesRead;
+
+ MA_ASSERT(pRB != NULL);
+
+ /* We need to run this in a loop since the ring buffer itself may loop. */
+ totalFramesRead = 0;
+ while (totalFramesRead < frameCount) {
+ void* pMappedBuffer;
+ ma_uint32 mappedFrameCount;
+ ma_uint64 framesToRead = frameCount - totalFramesRead;
+ if (framesToRead > 0xFFFFFFFF) {
+ framesToRead = 0xFFFFFFFF;
+ }
+
+ mappedFrameCount = (ma_uint32)framesToRead;
+ result = ma_pcm_rb_acquire_read(pRB, &mappedFrameCount, &pMappedBuffer);
+ if (result != MA_SUCCESS) {
+ break;
+ }
+
+ if (mappedFrameCount == 0) {
+ break; /* <-- End of ring buffer. */
+ }
+
+ ma_copy_pcm_frames(ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, pRB->format, pRB->channels), pMappedBuffer, mappedFrameCount, pRB->format, pRB->channels);
+
+ result = ma_pcm_rb_commit_read(pRB, mappedFrameCount);
+ if (result != MA_SUCCESS) {
+ break;
+ }
+
+ totalFramesRead += mappedFrameCount;
+ }
+
+ *pFramesRead = totalFramesRead;
+ return MA_SUCCESS;
+}
+
+static ma_result ma_pcm_rb_data_source__on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap)
+{
+ ma_pcm_rb* pRB = (ma_pcm_rb*)pDataSource;
+ MA_ASSERT(pRB != NULL);
+
+ if (pFormat != NULL) {
+ *pFormat = pRB->format;
+ }
+
+ if (pChannels != NULL) {
+ *pChannels = pRB->channels;
+ }
+
+ if (pSampleRate != NULL) {
+ *pSampleRate = pRB->sampleRate;
+ }
+
+ /* Just assume the default channel map. */
+ if (pChannelMap != NULL) {
+ ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pRB->channels);
+ }
+
+ return MA_SUCCESS;
+}
+
+static ma_data_source_vtable ma_gRBDataSourceVTable =
+{
+ ma_pcm_rb_data_source__on_read,
+ NULL, /* onSeek */
+ ma_pcm_rb_data_source__on_get_data_format,
+ NULL, /* onGetCursor */
+ NULL, /* onGetLength */
+ NULL, /* onSetLooping */
+ 0
+};
+
static MA_INLINE ma_uint32 ma_pcm_rb_get_bpf(ma_pcm_rb* pRB)
{
MA_ASSERT(pRB != NULL);
@@ -54214,8 +56618,21 @@ MA_API ma_result ma_pcm_rb_init_ex(ma_format format, ma_uint32 channels, ma_uint
return result;
}
- pRB->format = format;
- pRB->channels = channels;
+ pRB->format = format;
+ pRB->channels = channels;
+ pRB->sampleRate = 0; /* The sample rate is not passed in as a parameter. */
+
+ /* The PCM ring buffer is a data source. We need to get that set up as well. */
+ {
+ ma_data_source_config dataSourceConfig = ma_data_source_config_init();
+ dataSourceConfig.vtable = &ma_gRBDataSourceVTable;
+
+ result = ma_data_source_init(&dataSourceConfig, &pRB->ds);
+ if (result != MA_SUCCESS) {
+ ma_rb_uninit(&pRB->rb);
+ return result;
+ }
+ }
return MA_SUCCESS;
}
@@ -54231,6 +56648,7 @@ MA_API void ma_pcm_rb_uninit(ma_pcm_rb* pRB)
return;
}
+ ma_data_source_uninit(&pRB->ds);
ma_rb_uninit(&pRB->rb);
}
@@ -54382,6 +56800,42 @@ MA_API void* ma_pcm_rb_get_subbuffer_ptr(ma_pcm_rb* pRB, ma_uint32 subbufferInde
return ma_rb_get_subbuffer_ptr(&pRB->rb, subbufferIndex, pBuffer);
}
+MA_API ma_format ma_pcm_rb_get_format(const ma_pcm_rb* pRB)
+{
+ if (pRB == NULL) {
+ return ma_format_unknown;
+ }
+
+ return pRB->format;
+}
+
+MA_API ma_uint32 ma_pcm_rb_get_channels(const ma_pcm_rb* pRB)
+{
+ if (pRB == NULL) {
+ return 0;
+ }
+
+ return pRB->channels;
+}
+
+MA_API ma_uint32 ma_pcm_rb_get_sample_rate(const ma_pcm_rb* pRB)
+{
+ if (pRB == NULL) {
+ return 0;
+ }
+
+ return pRB->sampleRate;
+}
+
+MA_API void ma_pcm_rb_set_sample_rate(ma_pcm_rb* pRB, ma_uint32 sampleRate)
+{
+ if (pRB == NULL) {
+ return;
+ }
+
+ pRB->sampleRate = sampleRate;
+}
+
MA_API ma_result ma_duplex_rb_init(ma_format captureFormat, ma_uint32 captureChannels, ma_uint32 sampleRate, ma_uint32 captureInternalSampleRate, ma_uint32 captureInternalPeriodSizeInFrames, const ma_allocation_callbacks* pAllocationCallbacks, ma_duplex_rb* pRB)
@@ -54615,6 +57069,11 @@ MA_API ma_uint32 ma_get_bytes_per_sample(ma_format format)
+#define MA_DATA_SOURCE_DEFAULT_RANGE_BEG 0
+#define MA_DATA_SOURCE_DEFAULT_RANGE_END ~((ma_uint64)0)
+#define MA_DATA_SOURCE_DEFAULT_LOOP_POINT_BEG 0
+#define MA_DATA_SOURCE_DEFAULT_LOOP_POINT_END ~((ma_uint64)0)
+
MA_API ma_data_source_config ma_data_source_config_init(void)
{
ma_data_source_config config;
@@ -54640,10 +57099,10 @@ MA_API ma_result ma_data_source_init(const ma_data_source_config* pConfig, ma_da
}
pDataSourceBase->vtable = pConfig->vtable;
- pDataSourceBase->rangeBegInFrames = 0;
- pDataSourceBase->rangeEndInFrames = ~((ma_uint64)0);
- pDataSourceBase->loopBegInFrames = 0;
- pDataSourceBase->loopEndInFrames = ~((ma_uint64)0);
+ pDataSourceBase->rangeBegInFrames = MA_DATA_SOURCE_DEFAULT_RANGE_BEG;
+ pDataSourceBase->rangeEndInFrames = MA_DATA_SOURCE_DEFAULT_RANGE_END;
+ pDataSourceBase->loopBegInFrames = MA_DATA_SOURCE_DEFAULT_LOOP_POINT_BEG;
+ pDataSourceBase->loopEndInFrames = MA_DATA_SOURCE_DEFAULT_LOOP_POINT_END;
pDataSourceBase->pCurrent = pDataSource; /* Always read from ourself by default. */
pDataSourceBase->pNext = NULL;
pDataSourceBase->onGetNext = NULL;
@@ -54709,18 +57168,23 @@ static ma_result ma_data_source_read_pcm_frames_within_range(ma_data_source* pDa
result = pDataSourceBase->vtable->onRead(pDataSourceBase, pFramesOut, frameCount, &framesRead);
} else {
/* Need to clamp to within the range. */
- ma_uint64 cursor;
+ ma_uint64 relativeCursor;
+ ma_uint64 absoluteCursor;
- result = ma_data_source_get_cursor_in_pcm_frames(pDataSourceBase, &cursor);
+ result = ma_data_source_get_cursor_in_pcm_frames(pDataSourceBase, &relativeCursor);
if (result != MA_SUCCESS) {
/* Failed to retrieve the cursor. Cannot read within a range or loop points. Just read like normal - this may happen for things like noise data sources where it doesn't really matter. */
result = pDataSourceBase->vtable->onRead(pDataSourceBase, pFramesOut, frameCount, &framesRead);
} else {
+ ma_uint64 rangeBeg;
ma_uint64 rangeEnd;
/* We have the cursor. We need to make sure we don't read beyond our range. */
+ rangeBeg = pDataSourceBase->rangeBegInFrames;
rangeEnd = pDataSourceBase->rangeEndInFrames;
+ absoluteCursor = rangeBeg + relativeCursor;
+
/* If looping, make sure we're within range. */
if (loop) {
if (pDataSourceBase->loopEndInFrames != ~((ma_uint64)0)) {
@@ -54728,8 +57192,8 @@ static ma_result ma_data_source_read_pcm_frames_within_range(ma_data_source* pDa
}
}
- if (frameCount > (rangeEnd - cursor) && rangeEnd != ~((ma_uint64)0)) {
- frameCount = (rangeEnd - cursor);
+ if (frameCount > (rangeEnd - absoluteCursor) && rangeEnd != ~((ma_uint64)0)) {
+ frameCount = (rangeEnd - absoluteCursor);
}
/*
@@ -55067,7 +57531,8 @@ MA_API ma_result ma_data_source_get_cursor_in_seconds(ma_data_source* pDataSourc
return result;
}
- *pCursor = cursorInPCMFrames / (float)sampleRate;
+ /* VC6 does not support division of unsigned 64-bit integers with floating point numbers. Need to use a signed number. This shouldn't effect anything in practice. */
+ *pCursor = (ma_int64)cursorInPCMFrames / (float)sampleRate;
return MA_SUCCESS;
}
@@ -55094,7 +57559,8 @@ MA_API ma_result ma_data_source_get_length_in_seconds(ma_data_source* pDataSourc
return result;
}
- *pLength = lengthInPCMFrames / (float)sampleRate;
+ /* VC6 does not support division of unsigned 64-bit integers with floating point numbers. Need to use a signed number. This shouldn't effect anything in practice. */
+ *pLength = (ma_int64)lengthInPCMFrames / (float)sampleRate;
return MA_SUCCESS;
}
@@ -55132,9 +57598,9 @@ MA_API ma_result ma_data_source_set_range_in_pcm_frames(ma_data_source* pDataSou
{
ma_data_source_base* pDataSourceBase = (ma_data_source_base*)pDataSource;
ma_result result;
- ma_uint64 cursor;
- ma_uint64 loopBegAbsolute;
- ma_uint64 loopEndAbsolute;
+ ma_uint64 relativeCursor;
+ ma_uint64 absoluteCursor;
+ ma_bool32 doSeekAdjustment = MA_FALSE;
if (pDataSource == NULL) {
return MA_INVALID_ARGS;
@@ -55145,51 +57611,51 @@ MA_API ma_result ma_data_source_set_range_in_pcm_frames(ma_data_source* pDataSou
}
/*
- The loop points need to be updated. We'll be storing the loop points relative to the range. We'll update
- these so that they maintain their absolute positioning. The loop points will then be clamped to the range.
+ We may need to adjust the position of the cursor to ensure it's clamped to the range. Grab it now
+ so we can calculate it's absolute position before we change the range.
*/
- loopBegAbsolute = pDataSourceBase->loopBegInFrames + pDataSourceBase->rangeBegInFrames;
- loopEndAbsolute = pDataSourceBase->loopEndInFrames + ((pDataSourceBase->loopEndInFrames != ~((ma_uint64)0)) ? pDataSourceBase->rangeBegInFrames : 0);
+ result = ma_data_source_get_cursor_in_pcm_frames(pDataSource, &relativeCursor);
+ if (result == MA_SUCCESS) {
+ doSeekAdjustment = MA_TRUE;
+ absoluteCursor = relativeCursor + pDataSourceBase->rangeBegInFrames;
+ } else {
+ /*
+ We couldn't get the position of the cursor. It probably means the data source has no notion
+ of a cursor. We'll just leave it at position 0. Don't treat this as an error.
+ */
+ doSeekAdjustment = MA_FALSE;
+ relativeCursor = 0;
+ absoluteCursor = 0;
+ }
pDataSourceBase->rangeBegInFrames = rangeBegInFrames;
pDataSourceBase->rangeEndInFrames = rangeEndInFrames;
- /* Make the loop points relative again, and make sure they're clamped to within the range. */
- if (loopBegAbsolute > pDataSourceBase->rangeBegInFrames) {
- pDataSourceBase->loopBegInFrames = loopBegAbsolute - pDataSourceBase->rangeBegInFrames;
- } else {
- pDataSourceBase->loopBegInFrames = 0;
- }
+ /*
+ The commented out logic below was intended to maintain loop points in response to a change in the
+ range. However, this is not useful because it results in the sound breaking when you move the range
+ outside of the old loop points. I'm simplifying this by simply resetting the loop points. The
+ caller is expected to update their loop points if they change the range.
- if (pDataSourceBase->loopBegInFrames > pDataSourceBase->rangeEndInFrames) {
- pDataSourceBase->loopBegInFrames = pDataSourceBase->rangeEndInFrames;
- }
+ In practice this should be mostly a non-issue because the majority of the time the range will be
+ set once right after initialization.
+ */
+ pDataSourceBase->loopBegInFrames = 0;
+ pDataSourceBase->loopEndInFrames = ~((ma_uint64)0);
- /* Only need to update the loop end point if it's not -1. */
- if (loopEndAbsolute != ~((ma_uint64)0)) {
- if (loopEndAbsolute > pDataSourceBase->rangeBegInFrames) {
- pDataSourceBase->loopEndInFrames = loopEndAbsolute - pDataSourceBase->rangeBegInFrames;
- } else {
- pDataSourceBase->loopEndInFrames = 0;
- }
-
- if (pDataSourceBase->loopEndInFrames > pDataSourceBase->rangeEndInFrames && pDataSourceBase->loopEndInFrames) {
- pDataSourceBase->loopEndInFrames = pDataSourceBase->rangeEndInFrames;
- }
- }
-
-
- /* If the new range is past the current cursor position we need to seek to it. */
- result = ma_data_source_get_cursor_in_pcm_frames(pDataSource, &cursor);
- if (result == MA_SUCCESS) {
- /* Seek to within range. Note that our seek positions here are relative to the new range. */
- if (cursor < rangeBegInFrames) {
+
+ /*
+ Seek to within range. Note that our seek positions here are relative to the new range. We don't want
+ do do this if we failed to retrieve the cursor earlier on because it probably means the data source
+ has no notion of a cursor. In practice the seek would probably fail (which we silently ignore), but
+ I'm just not even going to attempt it.
+ */
+ if (doSeekAdjustment) {
+ if (absoluteCursor < rangeBegInFrames) {
ma_data_source_seek_to_pcm_frame(pDataSource, 0);
- } else if (cursor > rangeEndInFrames) {
+ } else if (absoluteCursor > rangeEndInFrames) {
ma_data_source_seek_to_pcm_frame(pDataSource, rangeEndInFrames - rangeBegInFrames);
}
- } else {
- /* We failed to get the cursor position. Probably means the data source has no notion of a cursor such a noise data source. Just pretend the seeking worked. */
}
return MA_SUCCESS;
@@ -56317,7 +58783,7 @@ MA_API ma_result ma_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t
{
ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
ma_result result;
- size_t bytesRead;
+ size_t bytesRead = 0;
if (pBytesRead != NULL) {
*pBytesRead = 0;
@@ -56495,7 +58961,11 @@ MA_API ma_result ma_vfs_open_and_read_file_w(ma_vfs* pVFS, const wchar_t* pFileP
}
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP) && !defined(MA_NO_WIN32_FILEIO)
+#if !defined(MA_USE_WIN32_FILEIO) && (defined(MA_WIN32) && defined(MA_WIN32_DESKTOP) && !defined(MA_NO_WIN32_FILEIO) && !defined(MA_POSIX))
+ #define MA_USE_WIN32_FILEIO
+#endif
+
+#if defined(MA_USE_WIN32_FILEIO)
static void ma_default_vfs__get_open_settings_win32(ma_uint32 openMode, DWORD* pDesiredAccess, DWORD* pShareMode, DWORD* pCreationDisposition)
{
*pDesiredAccess = 0;
@@ -56964,7 +59434,7 @@ static ma_result ma_default_vfs_open(ma_vfs* pVFS, const char* pFilePath, ma_uin
return MA_INVALID_ARGS;
}
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP) && !defined(MA_NO_WIN32_FILEIO)
+#if defined(MA_USE_WIN32_FILEIO)
return ma_default_vfs_open__win32(pVFS, pFilePath, openMode, pFile);
#else
return ma_default_vfs_open__stdio(pVFS, pFilePath, openMode, pFile);
@@ -56983,7 +59453,7 @@ static ma_result ma_default_vfs_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, m
return MA_INVALID_ARGS;
}
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP) && !defined(MA_NO_WIN32_FILEIO)
+#if defined(MA_USE_WIN32_FILEIO)
return ma_default_vfs_open_w__win32(pVFS, pFilePath, openMode, pFile);
#else
return ma_default_vfs_open_w__stdio(pVFS, pFilePath, openMode, pFile);
@@ -56996,7 +59466,7 @@ static ma_result ma_default_vfs_close(ma_vfs* pVFS, ma_vfs_file file)
return MA_INVALID_ARGS;
}
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP) && !defined(MA_NO_WIN32_FILEIO)
+#if defined(MA_USE_WIN32_FILEIO)
return ma_default_vfs_close__win32(pVFS, file);
#else
return ma_default_vfs_close__stdio(pVFS, file);
@@ -57013,7 +59483,7 @@ static ma_result ma_default_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst,
return MA_INVALID_ARGS;
}
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP) && !defined(MA_NO_WIN32_FILEIO)
+#if defined(MA_USE_WIN32_FILEIO)
return ma_default_vfs_read__win32(pVFS, file, pDst, sizeInBytes, pBytesRead);
#else
return ma_default_vfs_read__stdio(pVFS, file, pDst, sizeInBytes, pBytesRead);
@@ -57030,7 +59500,7 @@ static ma_result ma_default_vfs_write(ma_vfs* pVFS, ma_vfs_file file, const void
return MA_INVALID_ARGS;
}
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP) && !defined(MA_NO_WIN32_FILEIO)
+#if defined(MA_USE_WIN32_FILEIO)
return ma_default_vfs_write__win32(pVFS, file, pSrc, sizeInBytes, pBytesWritten);
#else
return ma_default_vfs_write__stdio(pVFS, file, pSrc, sizeInBytes, pBytesWritten);
@@ -57043,7 +59513,7 @@ static ma_result ma_default_vfs_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 of
return MA_INVALID_ARGS;
}
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP) && !defined(MA_NO_WIN32_FILEIO)
+#if defined(MA_USE_WIN32_FILEIO)
return ma_default_vfs_seek__win32(pVFS, file, offset, origin);
#else
return ma_default_vfs_seek__stdio(pVFS, file, offset, origin);
@@ -57062,7 +59532,7 @@ static ma_result ma_default_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* p
return MA_INVALID_ARGS;
}
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP) && !defined(MA_NO_WIN32_FILEIO)
+#if defined(MA_USE_WIN32_FILEIO)
return ma_default_vfs_tell__win32(pVFS, file, pCursor);
#else
return ma_default_vfs_tell__stdio(pVFS, file, pCursor);
@@ -57081,7 +59551,7 @@ static ma_result ma_default_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_inf
return MA_INVALID_ARGS;
}
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP) && !defined(MA_NO_WIN32_FILEIO)
+#if defined(MA_USE_WIN32_FILEIO)
return ma_default_vfs_info__win32(pVFS, file, pInfo);
#else
return ma_default_vfs_info__stdio(pVFS, file, pInfo);
@@ -57199,7 +59669,7 @@ extern "C" {
#define DRWAV_XSTRINGIFY(x) DRWAV_STRINGIFY(x)
#define DRWAV_VERSION_MAJOR 0
#define DRWAV_VERSION_MINOR 13
-#define DRWAV_VERSION_REVISION 6
+#define DRWAV_VERSION_REVISION 8
#define DRWAV_VERSION_STRING DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION)
#include
typedef signed char drwav_int8;
@@ -57734,7 +60204,7 @@ extern "C" {
#define DRFLAC_XSTRINGIFY(x) DRFLAC_STRINGIFY(x)
#define DRFLAC_VERSION_MAJOR 0
#define DRFLAC_VERSION_MINOR 12
-#define DRFLAC_VERSION_REVISION 38
+#define DRFLAC_VERSION_REVISION 39
#define DRFLAC_VERSION_STRING DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MAJOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MINOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_REVISION)
#include
typedef signed char drflac_int8;
@@ -57863,14 +60333,12 @@ typedef enum
drflac_seek_origin_start,
drflac_seek_origin_current
} drflac_seek_origin;
-#pragma pack(2)
typedef struct
{
drflac_uint64 firstPCMFrame;
drflac_uint64 flacFrameOffset;
drflac_uint16 pcmFrameCount;
} drflac_seekpoint;
-#pragma pack()
typedef struct
{
drflac_uint16 minBlockSizeInPCMFrames;
@@ -58057,14 +60525,12 @@ typedef struct
drflac_uint32 countRemaining;
const char* pRunningData;
} drflac_cuesheet_track_iterator;
-#pragma pack(4)
typedef struct
{
drflac_uint64 offset;
drflac_uint8 index;
drflac_uint8 reserved[3];
} drflac_cuesheet_track_index;
-#pragma pack()
typedef struct
{
drflac_uint64 offset;
@@ -58095,7 +60561,7 @@ extern "C" {
#define DRMP3_XSTRINGIFY(x) DRMP3_STRINGIFY(x)
#define DRMP3_VERSION_MAJOR 0
#define DRMP3_VERSION_MINOR 6
-#define DRMP3_VERSION_REVISION 33
+#define DRMP3_VERSION_REVISION 34
#define DRMP3_VERSION_STRING DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION)
#include
typedef signed char drmp3_int8;
@@ -58277,7 +60743,6 @@ typedef struct
typedef struct
{
drmp3dec decoder;
- drmp3dec_frame_info frameInfo;
drmp3_uint32 channels;
drmp3_uint32 sampleRate;
drmp3_read_proc onRead;
@@ -60095,6 +62560,7 @@ static ma_result ma_mp3_generate_seek_table(ma_mp3* pMP3, const ma_decoding_back
mp3Result = drmp3_calculate_seek_points(&pMP3->dr, &seekPointCount, pSeekPoints);
if (mp3Result != MA_TRUE) {
+ ma_free(pSeekPoints, pAllocationCallbacks);
return MA_ERROR;
}
@@ -60625,6 +63091,7 @@ typedef struct
ma_uint8* pData;
size_t dataSize;
size_t dataCapacity;
+ size_t audioStartOffsetInBytes;
ma_uint32 framesConsumed; /* The number of frames consumed in ppPacketData. */
ma_uint32 framesRemaining; /* The number of frames remaining in ppPacketData. */
float** ppPacketData;
@@ -60719,6 +63186,81 @@ static ma_result ma_stbvorbis_post_init(ma_stbvorbis* pVorbis)
return MA_SUCCESS;
}
+
+static ma_result ma_stbvorbis_init_internal_decoder_push(ma_stbvorbis* pVorbis)
+{
+ ma_result result;
+ stb_vorbis* stb;
+ size_t dataSize = 0;
+ size_t dataCapacity = 0;
+ ma_uint8* pData = NULL; /* <-- Must be initialized to NULL. */
+
+ for (;;) {
+ int vorbisError;
+ int consumedDataSize; /* <-- Fill by stb_vorbis_open_pushdata(). */
+ size_t bytesRead;
+ ma_uint8* pNewData;
+
+ /* Allocate memory for the new chunk. */
+ dataCapacity += MA_VORBIS_DATA_CHUNK_SIZE;
+ pNewData = (ma_uint8*)ma_realloc(pData, dataCapacity, &pVorbis->allocationCallbacks);
+ if (pNewData == NULL) {
+ ma_free(pData, &pVorbis->allocationCallbacks);
+ return MA_OUT_OF_MEMORY;
+ }
+
+ pData = pNewData;
+
+ /* Read in the next chunk. */
+ result = pVorbis->onRead(pVorbis->pReadSeekTellUserData, ma_offset_ptr(pData, dataSize), (dataCapacity - dataSize), &bytesRead);
+ dataSize += bytesRead;
+
+ if (result != MA_SUCCESS) {
+ ma_free(pData, &pVorbis->allocationCallbacks);
+ return result;
+ }
+
+ /* We have a maximum of 31 bits with stb_vorbis. */
+ if (dataSize > INT_MAX) {
+ ma_free(pData, &pVorbis->allocationCallbacks);
+ return MA_TOO_BIG;
+ }
+
+ stb = stb_vorbis_open_pushdata(pData, (int)dataSize, &consumedDataSize, &vorbisError, NULL);
+ if (stb != NULL) {
+ /*
+ Successfully opened the Vorbis decoder. We might have some leftover unprocessed
+ data so we'll need to move that down to the front.
+ */
+ dataSize -= (size_t)consumedDataSize; /* Consume the data. */
+ MA_MOVE_MEMORY(pData, ma_offset_ptr(pData, consumedDataSize), dataSize);
+
+ /*
+ We need to track the start point so we can seek back to the start of the audio
+ data when seeking.
+ */
+ pVorbis->push.audioStartOffsetInBytes = consumedDataSize;
+
+ break;
+ } else {
+ /* Failed to open the decoder. */
+ if (vorbisError == VORBIS_need_more_data) {
+ continue;
+ } else {
+ ma_free(pData, &pVorbis->allocationCallbacks);
+ return MA_ERROR; /* Failed to open the stb_vorbis decoder. */
+ }
+ }
+ }
+
+ MA_ASSERT(stb != NULL);
+ pVorbis->stb = stb;
+ pVorbis->push.pData = pData;
+ pVorbis->push.dataSize = dataSize;
+ pVorbis->push.dataCapacity = dataCapacity;
+
+ return MA_SUCCESS;
+}
#endif
MA_API ma_result ma_stbvorbis_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_stbvorbis* pVorbis)
@@ -60747,74 +63289,17 @@ MA_API ma_result ma_stbvorbis_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_
pushing API. In order for us to be able to successfully initialize the decoder we need to
supply it with enough data. We need to keep loading data until we have enough.
*/
- stb_vorbis* stb;
- size_t dataSize = 0;
- size_t dataCapacity = 0;
- ma_uint8* pData = NULL; /* <-- Must be initialized to NULL. */
-
- for (;;) {
- int vorbisError;
- int consumedDataSize; /* <-- Fill by stb_vorbis_open_pushdata(). */
- size_t bytesRead;
- ma_uint8* pNewData;
-
- /* Allocate memory for the new chunk. */
- dataCapacity += MA_VORBIS_DATA_CHUNK_SIZE;
- pNewData = (ma_uint8*)ma_realloc(pData, dataCapacity, pAllocationCallbacks);
- if (pNewData == NULL) {
- ma_free(pData, pAllocationCallbacks);
- return MA_OUT_OF_MEMORY;
- }
-
- pData = pNewData;
-
- /* Read in the next chunk. */
- result = pVorbis->onRead(pVorbis->pReadSeekTellUserData, ma_offset_ptr(pData, dataSize), (dataCapacity - dataSize), &bytesRead);
- dataSize += bytesRead;
-
- if (result != MA_SUCCESS) {
- ma_free(pData, pAllocationCallbacks);
- return result;
- }
-
- /* We have a maximum of 31 bits with stb_vorbis. */
- if (dataSize > INT_MAX) {
- ma_free(pData, pAllocationCallbacks);
- return MA_TOO_BIG;
- }
-
- stb = stb_vorbis_open_pushdata(pData, (int)dataSize, &consumedDataSize, &vorbisError, NULL);
- if (stb != NULL) {
- /*
- Successfully opened the Vorbis decoder. We might have some leftover unprocessed
- data so we'll need to move that down to the front.
- */
- dataSize -= (size_t)consumedDataSize; /* Consume the data. */
- MA_MOVE_MEMORY(pData, ma_offset_ptr(pData, consumedDataSize), dataSize);
- break;
- } else {
- /* Failed to open the decoder. */
- if (vorbisError == VORBIS_need_more_data) {
- continue;
- } else {
- ma_free(pData, pAllocationCallbacks);
- return MA_ERROR; /* Failed to open the stb_vorbis decoder. */
- }
- }
+ result = ma_stbvorbis_init_internal_decoder_push(pVorbis);
+ if (result != MA_SUCCESS) {
+ return result;
}
- MA_ASSERT(stb != NULL);
- pVorbis->stb = stb;
- pVorbis->push.pData = pData;
- pVorbis->push.dataSize = dataSize;
- pVorbis->push.dataCapacity = dataCapacity;
-
pVorbis->usingPushMode = MA_TRUE;
result = ma_stbvorbis_post_init(pVorbis);
if (result != MA_SUCCESS) {
stb_vorbis_close(pVorbis->stb);
- ma_free(pData, pAllocationCallbacks);
+ ma_free(pVorbis->push.pData, pAllocationCallbacks);
return result;
}
@@ -61116,27 +63601,39 @@ MA_API ma_result ma_stbvorbis_seek_to_pcm_frame(ma_stbvorbis* pVorbis, ma_uint64
ma_result result;
float buffer[4096];
- /*
- This is terribly inefficient because stb_vorbis does not have a good seeking solution with it's push API. Currently this just performs
- a full decode right from the start of the stream. Later on I'll need to write a layer that goes through all of the Ogg pages until we
- find the one containing the sample we need. Then we know exactly where to seek for stb_vorbis.
+ /* If we're seeking backwards, we need to seek back to the start and then brute-force forward. */
+ if (frameIndex < pVorbis->cursor) {
+ if (frameIndex > 0x7FFFFFFF) {
+ return MA_INVALID_ARGS; /* Trying to seek beyond the 32-bit maximum of stb_vorbis. */
+ }
- TODO: Use seeking logic documented for stb_vorbis_flush_pushdata().
- */
+ /*
+ This is wildly inefficient due to me having trouble getting sample exact seeking working
+ robustly with stb_vorbis_flush_pushdata(). The only way I can think to make this work
+ perfectly is to reinitialize the decoder. Note that we only enter this path when seeking
+ backwards. This will hopefully be removed once we get our own Vorbis decoder implemented.
+ */
+ stb_vorbis_close(pVorbis->stb);
+ ma_free(pVorbis->push.pData, &pVorbis->allocationCallbacks);
- /* Seek to the start of the file to begin with. */
- result = pVorbis->onSeek(pVorbis->pReadSeekTellUserData, 0, ma_seek_origin_start);
- if (result != MA_SUCCESS) {
- return result;
+ MA_ZERO_OBJECT(&pVorbis->push);
+
+ /* Seek to the start of the file. */
+ result = pVorbis->onSeek(pVorbis->pReadSeekTellUserData, 0, ma_seek_origin_start);
+ if (result != MA_SUCCESS) {
+ return result;
+ }
+
+ result = ma_stbvorbis_init_internal_decoder_push(pVorbis);
+ if (result != MA_SUCCESS) {
+ return result;
+ }
+
+ /* At this point we should be sitting on the first frame. */
+ pVorbis->cursor = 0;
}
- stb_vorbis_flush_pushdata(pVorbis->stb);
- pVorbis->push.framesRemaining = 0;
- pVorbis->push.dataSize = 0;
-
- /* Move the cursor back to the start. We'll increment this in the loop below. */
- pVorbis->cursor = 0;
-
+ /* We're just brute-forcing this for now. */
while (pVorbis->cursor < frameIndex) {
ma_uint64 framesRead;
ma_uint64 framesToRead = ma_countof(buffer)/pVorbis->channels;
@@ -63693,8 +66190,15 @@ MA_API ma_result ma_noise_set_type(ma_noise* pNoise, ma_noise_type type)
return MA_INVALID_ARGS;
}
- pNoise->config.type = type;
- return MA_SUCCESS;
+ /*
+ This function should never have been implemented in the first place. Changing the type dynamically is not
+ supported. Instead you need to uninitialize and reinitiailize a fresh `ma_noise` object. This function
+ will be removed in version 0.12.
+ */
+ MA_ASSERT(MA_FALSE);
+ (void)type;
+
+ return MA_INVALID_OPERATION;
}
static MA_INLINE float ma_noise_f32_white(ma_noise* pNoise)
@@ -64078,10 +66582,15 @@ static MA_INLINE ma_uint32 ma_rotl32(ma_uint32 x, ma_int8 r)
static MA_INLINE ma_uint32 ma_hash_getblock(const ma_uint32* blocks, int i)
{
+ ma_uint32 block;
+
+ /* Try silencing a sanitization warning about unaligned access by doing a memcpy() instead of assignment. */
+ MA_COPY_MEMORY(&block, ma_offset_ptr(blocks, i * sizeof(block)), sizeof(block));
+
if (ma_is_little_endian()) {
- return blocks[i];
+ return block;
} else {
- return ma_swap_endian_uint32(blocks[i]);
+ return ma_swap_endian_uint32(block);
}
}
@@ -64796,7 +67305,7 @@ MA_API ma_result ma_resource_manager_init(const ma_resource_manager_config* pCon
/* Create the job threads last to ensure the threads has access to valid data. */
for (iJobThread = 0; iJobThread < pResourceManager->config.jobThreadCount; iJobThread += 1) {
- result = ma_thread_create(&pResourceManager->jobThreads[iJobThread], ma_thread_priority_normal, 0, ma_resource_manager_job_thread, pResourceManager, &pResourceManager->config.allocationCallbacks);
+ result = ma_thread_create(&pResourceManager->jobThreads[iJobThread], ma_thread_priority_normal, pResourceManager->config.jobThreadStackSize, ma_resource_manager_job_thread, pResourceManager, &pResourceManager->config.allocationCallbacks);
if (result != MA_SUCCESS) {
ma_mutex_uninit(&pResourceManager->dataBufferBSTLock);
ma_job_queue_uninit(&pResourceManager->jobQueue, &pResourceManager->config.allocationCallbacks);
@@ -64901,8 +67410,11 @@ MA_API ma_resource_manager_data_source_config ma_resource_manager_data_source_co
ma_resource_manager_data_source_config config;
MA_ZERO_OBJECT(&config);
- config.rangeEndInPCMFrames = ~((ma_uint64)0);
- config.loopPointEndInPCMFrames = ~((ma_uint64)0);
+ config.rangeBegInPCMFrames = MA_DATA_SOURCE_DEFAULT_RANGE_BEG;
+ config.rangeEndInPCMFrames = MA_DATA_SOURCE_DEFAULT_RANGE_END;
+ config.loopPointBegInPCMFrames = MA_DATA_SOURCE_DEFAULT_LOOP_POINT_BEG;
+ config.loopPointEndInPCMFrames = MA_DATA_SOURCE_DEFAULT_LOOP_POINT_END;
+ config.isLooping = MA_FALSE;
return config;
}
@@ -64951,8 +67463,17 @@ static ma_result ma_resource_manager__init_decoder(ma_resource_manager* pResourc
return MA_SUCCESS;
}
+static ma_bool32 ma_resource_manager_data_buffer_has_connector(ma_resource_manager_data_buffer* pDataBuffer)
+{
+ return ma_atomic_bool32_get(&pDataBuffer->isConnectorInitialized);
+}
+
static ma_data_source* ma_resource_manager_data_buffer_get_connector(ma_resource_manager_data_buffer* pDataBuffer)
{
+ if (ma_resource_manager_data_buffer_has_connector(pDataBuffer) == MA_FALSE) {
+ return NULL; /* Connector not yet initialized. */
+ }
+
switch (pDataBuffer->pNode->data.type)
{
case ma_resource_manager_data_supply_type_encoded: return &pDataBuffer->connector.decoder;
@@ -64974,7 +67495,7 @@ static ma_result ma_resource_manager_data_buffer_init_connector(ma_resource_mana
MA_ASSERT(pDataBuffer != NULL);
MA_ASSERT(pConfig != NULL);
- MA_ASSERT(pDataBuffer->isConnectorInitialized == MA_FALSE);
+ MA_ASSERT(ma_resource_manager_data_buffer_has_connector(pDataBuffer) == MA_FALSE);
/* The underlying data buffer must be initialized before we'll be able to know how to initialize the backend. */
result = ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode);
@@ -65024,14 +67545,30 @@ static ma_result ma_resource_manager_data_buffer_init_connector(ma_resource_mana
*/
if (result == MA_SUCCESS) {
/*
- Make sure the looping state is set before returning in order to handle the case where the
- loop state was set on the data buffer before the connector was initialized.
- */
- ma_data_source_set_range_in_pcm_frames(pDataBuffer, pConfig->rangeBegInPCMFrames, pConfig->rangeEndInPCMFrames);
- ma_data_source_set_loop_point_in_pcm_frames(pDataBuffer, pConfig->loopPointBegInPCMFrames, pConfig->loopPointEndInPCMFrames);
- ma_data_source_set_looping(pDataBuffer, pConfig->isLooping);
+ The resource manager supports the ability to set the range and loop settings via a config at
+ initialization time. This results in an case where the ranges could be set explicitly via
+ ma_data_source_set_*() before we get to this point here. If this happens, we'll end up
+ hitting a case where we just override those settings which results in what feels like a bug.
- pDataBuffer->isConnectorInitialized = MA_TRUE;
+ To address this we only change the relevant properties if they're not equal to defaults. If
+ they're equal to defaults there's no need to change them anyway. If they're *not* set to the
+ default values, we can assume the user has set the range and loop settings via the config. If
+ they're doing their own calls to ma_data_source_set_*() in addition to setting them via the
+ config, that's entirely on the caller and any synchronization issue becomes their problem.
+ */
+ if (pConfig->rangeBegInPCMFrames != MA_DATA_SOURCE_DEFAULT_RANGE_BEG || pConfig->rangeEndInPCMFrames != MA_DATA_SOURCE_DEFAULT_RANGE_END) {
+ ma_data_source_set_range_in_pcm_frames(pDataBuffer, pConfig->rangeBegInPCMFrames, pConfig->rangeEndInPCMFrames);
+ }
+
+ if (pConfig->loopPointBegInPCMFrames != MA_DATA_SOURCE_DEFAULT_LOOP_POINT_BEG || pConfig->loopPointEndInPCMFrames != MA_DATA_SOURCE_DEFAULT_LOOP_POINT_END) {
+ ma_data_source_set_loop_point_in_pcm_frames(pDataBuffer, pConfig->loopPointBegInPCMFrames, pConfig->loopPointEndInPCMFrames);
+ }
+
+ if (pConfig->isLooping != MA_FALSE) {
+ ma_data_source_set_looping(pDataBuffer, pConfig->isLooping);
+ }
+
+ ma_atomic_bool32_set(&pDataBuffer->isConnectorInitialized, MA_TRUE);
if (pInitNotification != NULL) {
ma_async_notification_signal(pInitNotification);
@@ -65051,6 +67588,8 @@ static ma_result ma_resource_manager_data_buffer_uninit_connector(ma_resource_ma
MA_ASSERT(pResourceManager != NULL);
MA_ASSERT(pDataBuffer != NULL);
+ (void)pResourceManager;
+
switch (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode))
{
case ma_resource_manager_data_supply_type_encoded: /* Connector is a decoder. */
@@ -65399,7 +67938,12 @@ static ma_result ma_resource_manager_data_buffer_node_acquire_critical_section(m
job.data.resourceManager.loadDataBufferNode.pInitFence = pInitFence;
job.data.resourceManager.loadDataBufferNode.pDoneFence = pDoneFence;
- result = ma_resource_manager_post_job(pResourceManager, &job);
+ if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) {
+ result = ma_job_process(&job);
+ } else {
+ result = ma_resource_manager_post_job(pResourceManager, &job);
+ }
+
if (result != MA_SUCCESS) {
/* Failed to post job. Probably ran out of memory. */
ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to post MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_BUFFER_NODE job. %s.\n", ma_result_description(result));
@@ -65412,12 +67956,13 @@ static ma_result ma_resource_manager_data_buffer_node_acquire_critical_section(m
if (pDoneFence != NULL) { ma_fence_release(pDoneFence); }
if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) {
- ma_resource_manager_inline_notification_init(pResourceManager, pInitNotification);
+ ma_resource_manager_inline_notification_uninit(pInitNotification);
+ } else {
+ /* These will have been freed by the job thread, but with WAIT_INIT they will already have happend sinced the job has already been handled. */
+ ma_free(pFilePathCopy, &pResourceManager->config.allocationCallbacks);
+ ma_free(pFilePathWCopy, &pResourceManager->config.allocationCallbacks);
}
- ma_free(pFilePathCopy, &pResourceManager->config.allocationCallbacks);
- ma_free(pFilePathWCopy, &pResourceManager->config.allocationCallbacks);
-
ma_resource_manager_data_buffer_node_remove(pResourceManager, pDataBufferNode);
ma_free(pDataBufferNode, &pResourceManager->config.allocationCallbacks);
@@ -65856,7 +68401,13 @@ static ma_result ma_resource_manager_data_buffer_init_ex_internal(ma_resource_ma
job.data.resourceManager.loadDataBuffer.loopPointEndInPCMFrames = pConfig->loopPointEndInPCMFrames;
job.data.resourceManager.loadDataBuffer.isLooping = pConfig->isLooping;
- result = ma_resource_manager_post_job(pResourceManager, &job);
+ /* If we need to wait for initialization to complete we can just process the job in place. */
+ if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) {
+ result = ma_job_process(&job);
+ } else {
+ result = ma_resource_manager_post_job(pResourceManager, &job);
+ }
+
if (result != MA_SUCCESS) {
/* We failed to post the job. Most likely there isn't enough room in the queue's buffer. */
ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to post MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_BUFFER job. %s.\n", ma_result_description(result));
@@ -66036,15 +68587,25 @@ MA_API ma_result ma_resource_manager_data_buffer_read_pcm_frames(ma_resource_man
MA_ASSERT(ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode) != MA_UNAVAILABLE);
/* If the node is not initialized we need to abort with a busy code. */
- if (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode) == ma_resource_manager_data_supply_type_unknown) {
+ if (ma_resource_manager_data_buffer_has_connector(pDataBuffer) == MA_FALSE) {
return MA_BUSY; /* Still loading. */
}
+ /*
+ If we've got a seek scheduled we'll want to do that before reading. However, for paged buffers, there's
+ a chance that the sound hasn't yet been decoded up to the seek point will result in the seek failing. If
+ this happens, we need to keep the seek scheduled and return MA_BUSY.
+ */
if (pDataBuffer->seekToCursorOnNextRead) {
pDataBuffer->seekToCursorOnNextRead = MA_FALSE;
result = ma_data_source_seek_to_pcm_frame(ma_resource_manager_data_buffer_get_connector(pDataBuffer), pDataBuffer->seekTargetInPCMFrames);
if (result != MA_SUCCESS) {
+ if (result == MA_BAD_SEEK && ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode) == ma_resource_manager_data_supply_type_decoded_paged) {
+ pDataBuffer->seekToCursorOnNextRead = MA_TRUE; /* Keep the seek scheduled. We just haven't loaded enough data yet to do the seek properly. */
+ return MA_BUSY;
+ }
+
return result;
}
}
@@ -66117,7 +68678,7 @@ MA_API ma_result ma_resource_manager_data_buffer_seek_to_pcm_frame(ma_resource_m
MA_ASSERT(ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode) != MA_UNAVAILABLE);
/* If we haven't yet got a connector we need to abort. */
- if (ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode) == ma_resource_manager_data_supply_type_unknown) {
+ if (ma_resource_manager_data_buffer_has_connector(pDataBuffer) == MA_FALSE) {
pDataBuffer->seekTargetInPCMFrames = frameIndex;
pDataBuffer->seekToCursorOnNextRead = MA_TRUE;
return MA_BUSY; /* Still loading. */
@@ -66451,7 +69012,7 @@ static ma_data_source_vtable g_ma_resource_manager_data_stream_vtable =
ma_resource_manager_data_stream_cb__get_cursor_in_pcm_frames,
ma_resource_manager_data_stream_cb__get_length_in_pcm_frames,
ma_resource_manager_data_stream_cb__set_looping,
- MA_DATA_SOURCE_SELF_MANAGED_RANGE_AND_LOOP_POINT
+ 0 /*MA_DATA_SOURCE_SELF_MANAGED_RANGE_AND_LOOP_POINT*/
};
static void ma_resource_manager_data_stream_set_absolute_cursor(ma_resource_manager_data_stream* pDataStream, ma_uint64 absoluteCursor)
@@ -66576,6 +69137,14 @@ MA_API ma_result ma_resource_manager_data_stream_init_ex(ma_resource_manager* pR
ma_async_notification_signal(notifications.init.pNotification);
}
+ /*
+ If there was an error during initialization make sure we return that result here. We don't want to do this
+ if we're not waiting because it will most likely be in a busy state.
+ */
+ if (pDataStream->result != MA_SUCCESS) {
+ return pDataStream->result;
+ }
+
/* NOTE: Do not release pInitFence here. That will be done by the job. */
}
@@ -66590,7 +69159,7 @@ MA_API ma_result ma_resource_manager_data_stream_init(ma_resource_manager* pReso
config.pFilePath = pFilePath;
config.flags = flags;
config.pNotifications = pNotifications;
-
+
return ma_resource_manager_data_stream_init_ex(pResourceManager, &config, pDataStream);
}
@@ -66602,7 +69171,7 @@ MA_API ma_result ma_resource_manager_data_stream_init_w(ma_resource_manager* pRe
config.pFilePathW = pFilePath;
config.flags = flags;
config.pNotifications = pNotifications;
-
+
return ma_resource_manager_data_stream_init_ex(pResourceManager, &config, pDataStream);
}
@@ -67537,6 +70106,12 @@ done:
/* Increment the node's execution pointer so that the next jobs can be processed. This is how we keep decoding of pages in-order. */
c89atomic_fetch_add_32(&pDataBufferNode->executionPointer, 1);
+
+ /* A busy result should be considered successful from the point of view of the job system. */
+ if (result == MA_BUSY) {
+ result = MA_SUCCESS;
+ }
+
return result;
}
@@ -67682,7 +70257,7 @@ static ma_result ma_job_process__resource_manager__load_data_buffer(ma_job* pJob
}
/* Try initializing the connector if we haven't already. */
- isConnectorInitialized = pDataBuffer->isConnectorInitialized;
+ isConnectorInitialized = ma_resource_manager_data_buffer_has_connector(pDataBuffer);
if (isConnectorInitialized == MA_FALSE) {
dataSupplyType = ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBuffer->pNode);
@@ -67715,7 +70290,7 @@ static ma_result ma_job_process__resource_manager__load_data_buffer(ma_job* pJob
There is a hole between here and the where the data connector is initialized where the data
buffer node may have finished initializing. We need to check for this by checking the result of
the data buffer node and whether or not we had an unknown data supply type at the time of
- trying to initialize the data connector.
+ trying to initialize the data connector.
*/
result = ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode);
if (result == MA_BUSY || (result == MA_SUCCESS && isConnectorInitialized == MA_FALSE && dataSupplyType == ma_resource_manager_data_supply_type_unknown)) {
@@ -67738,7 +70313,7 @@ done:
If at this point the data buffer has not had it's connector initialized, it means the
notification event was never signalled which means we need to signal it here.
*/
- if (pDataBuffer->isConnectorInitialized == MA_FALSE && result != MA_SUCCESS) {
+ if (ma_resource_manager_data_buffer_has_connector(pDataBuffer) == MA_FALSE && result != MA_SUCCESS) {
if (pJob->data.resourceManager.loadDataBuffer.pInitNotification != NULL) {
ma_async_notification_signal(pJob->data.resourceManager.loadDataBuffer.pInitNotification);
}
@@ -67818,7 +70393,7 @@ static ma_result ma_job_process__resource_manager__load_data_stream(ma_job* pJob
goto done;
}
- /* Retrieve the total length of the file before marking the decoder are loaded. */
+ /* Retrieve the total length of the file before marking the decoder as loaded. */
if ((pDataStream->flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_UNKNOWN_LENGTH) == 0) {
result = ma_decoder_get_length_in_pcm_frames(&pDataStream->decoder, &pDataStream->totalLengthInPCMFrames);
if (result != MA_SUCCESS) {
@@ -68064,35 +70639,6 @@ MA_API void ma_debug_fill_pcm_frames_with_sine_wave(float* pFramesOut, ma_uint32
-static ma_result ma_mix_pcm_frames_f32(float* pDst, const float* pSrc, ma_uint64 frameCount, ma_uint32 channels, float volume)
-{
- ma_uint64 iSample;
- ma_uint64 sampleCount;
-
- if (pDst == NULL || pSrc == NULL || channels == 0) {
- return MA_INVALID_ARGS;
- }
-
- if (volume == 0) {
- return MA_SUCCESS; /* No changes if the volume is 0. */
- }
-
- sampleCount = frameCount * channels;
-
- if (volume == 1) {
- for (iSample = 0; iSample < sampleCount; iSample += 1) {
- pDst[iSample] += pSrc[iSample];
- }
- } else {
- for (iSample = 0; iSample < sampleCount; iSample += 1) {
- pDst[iSample] += ma_apply_volume_unclipped_f32(pSrc[iSample], volume);
- }
- }
-
- return MA_SUCCESS;
-}
-
-
MA_API ma_node_graph_config ma_node_graph_config_init(ma_uint32 channels)
{
ma_node_graph_config config;
@@ -68425,11 +70971,15 @@ static ma_result ma_node_input_bus_init(ma_uint32 channels, ma_node_input_bus* p
static void ma_node_input_bus_lock(ma_node_input_bus* pInputBus)
{
+ MA_ASSERT(pInputBus != NULL);
+
ma_spinlock_lock(&pInputBus->lock);
}
static void ma_node_input_bus_unlock(ma_node_input_bus* pInputBus)
{
+ MA_ASSERT(pInputBus != NULL);
+
ma_spinlock_unlock(&pInputBus->lock);
}
@@ -68562,7 +71112,7 @@ static void ma_node_input_bus_attach(ma_node_input_bus* pInputBus, ma_node_outpu
old input bus has been updated so that pOutputBus will not get iterated again.
*/
pOutputBus->pInputNode = pNewInputNode; /* No need for an atomic assignment here because modification of this variable always happens within a lock. */
- pOutputBus->inputNodeInputBusIndex = (ma_uint8)inputNodeInputBusIndex; /* As above. */
+ pOutputBus->inputNodeInputBusIndex = (ma_uint8)inputNodeInputBusIndex;
/*
Now we need to attach the output bus to the linked list. This involves updating two pointers on
@@ -68660,6 +71210,8 @@ static ma_result ma_node_input_bus_read_pcm_frames(ma_node* pInputNode, ma_node_
ma_uint32 inputChannels;
ma_bool32 doesOutputBufferHaveContent = MA_FALSE;
+ (void)pInputNode; /* Not currently used. */
+
/*
This will be called from the audio thread which means we can't be doing any locking. Basically,
this function will not perfom any locking, whereas attaching and detaching will, but crafted in
@@ -68702,6 +71254,7 @@ static ma_result ma_node_input_bus_read_pcm_frames(ma_node* pInputNode, ma_node_
ma_bool32 isSilentOutput = MA_FALSE;
MA_ASSERT(pOutputBus->pNode != NULL);
+ MA_ASSERT(((ma_node_base*)pOutputBus->pNode)->vtable != NULL);
isSilentOutput = (((ma_node_base*)pOutputBus->pNode)->vtable->flags & MA_NODE_FLAG_SILENT_OUTPUT) != 0;
@@ -68884,8 +71437,8 @@ static ma_result ma_node_translate_bus_counts(const ma_node_config* pConfig, ma_
/* Some special rules for passthrough nodes. */
if ((pConfig->vtable->flags & MA_NODE_FLAG_PASSTHROUGH) != 0) {
- if (pConfig->vtable->inputBusCount != 1 || pConfig->vtable->outputBusCount != 1) {
- return MA_INVALID_ARGS; /* Passthrough nodes must have exactly 1 input bus and 1 output bus. */
+ if ((pConfig->vtable->inputBusCount != 0 && pConfig->vtable->inputBusCount != 1) || pConfig->vtable->outputBusCount != 1) {
+ return MA_INVALID_ARGS; /* Passthrough nodes must have exactly 1 output bus and either 0 or 1 input bus. */
}
if (pConfig->pInputChannels[0] != pConfig->pOutputChannels[0]) {
@@ -69574,6 +72127,15 @@ static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusInde
frameCountOut = frameCount; /* Just read as much as we can. The callback will return what was actually read. */
ppFramesOut[0] = pFramesOut;
+
+ /*
+ If it's a passthrough we won't be expecting the callback to output anything, so we'll
+ need to pre-silence the output buffer.
+ */
+ if ((pNodeBase->vtable->flags & MA_NODE_FLAG_PASSTHROUGH) != 0) {
+ ma_silence_pcm_frames(pFramesOut, frameCount, ma_format_f32, ma_node_get_output_channels(pNode, outputBusIndex));
+ }
+
ma_node_process_pcm_frames_internal(pNode, NULL, &frameCountIn, ppFramesOut, &frameCountOut);
totalFramesRead = frameCountOut;
} else {
@@ -69826,7 +72388,7 @@ static ma_result ma_node_read_pcm_frames(ma_node* pNode, ma_uint32 outputBusInde
ma_node_output_bus_set_has_read(&pNodeBase->pOutputBuses[outputBusIndex], MA_TRUE);
}
}
-
+
/* Apply volume, if necessary. */
ma_apply_volume_factor_f32(pFramesOut, totalFramesRead * ma_node_get_output_channels(pNodeBase, outputBusIndex), ma_node_output_bus_get_volume(&pNodeBase->pOutputBuses[outputBusIndex]));
@@ -69980,8 +72542,9 @@ MA_API ma_splitter_node_config ma_splitter_node_config_init(ma_uint32 channels)
ma_splitter_node_config config;
MA_ZERO_OBJECT(&config);
- config.nodeConfig = ma_node_config_init();
- config.channels = channels;
+ config.nodeConfig = ma_node_config_init();
+ config.channels = channels;
+ config.outputBusCount = 2;
return config;
}
@@ -69994,8 +72557,7 @@ static void ma_splitter_node_process_pcm_frames(ma_node* pNode, const float** pp
ma_uint32 channels;
MA_ASSERT(pNodeBase != NULL);
- MA_ASSERT(ma_node_get_input_bus_count(pNodeBase) == 1);
- MA_ASSERT(ma_node_get_output_bus_count(pNodeBase) >= 2);
+ MA_ASSERT(ma_node_get_input_bus_count(pNodeBase) == 1);
/* We don't need to consider the input frame count - it'll be the same as the output frame count and we process everything. */
(void)pFrameCountIn;
@@ -70012,9 +72574,9 @@ static void ma_splitter_node_process_pcm_frames(ma_node* pNode, const float** pp
static ma_node_vtable g_ma_splitter_node_vtable =
{
ma_splitter_node_process_pcm_frames,
- NULL, /* onGetRequiredInputFrameCount */
- 1, /* 1 input bus. */
- 2, /* 2 output buses. */
+ NULL, /* onGetRequiredInputFrameCount */
+ 1, /* 1 input bus. */
+ MA_NODE_BUS_COUNT_UNKNOWN, /* The output bus count is specified on a per-node basis. */
0
};
@@ -70023,7 +72585,8 @@ MA_API ma_result ma_splitter_node_init(ma_node_graph* pNodeGraph, const ma_split
ma_result result;
ma_node_config baseConfig;
ma_uint32 pInputChannels[1];
- ma_uint32 pOutputChannels[2];
+ ma_uint32 pOutputChannels[MA_MAX_NODE_BUS_COUNT];
+ ma_uint32 iOutputBus;
if (pSplitterNode == NULL) {
return MA_INVALID_ARGS;
@@ -70035,15 +72598,21 @@ MA_API ma_result ma_splitter_node_init(ma_node_graph* pNodeGraph, const ma_split
return MA_INVALID_ARGS;
}
+ if (pConfig->outputBusCount > MA_MAX_NODE_BUS_COUNT) {
+ return MA_INVALID_ARGS; /* Too many output buses. */
+ }
+
/* Splitters require the same number of channels between inputs and outputs. */
pInputChannels[0] = pConfig->channels;
- pOutputChannels[0] = pConfig->channels;
- pOutputChannels[1] = pConfig->channels;
+ for (iOutputBus = 0; iOutputBus < pConfig->outputBusCount; iOutputBus += 1) {
+ pOutputChannels[iOutputBus] = pConfig->channels;
+ }
baseConfig = pConfig->nodeConfig;
baseConfig.vtable = &g_ma_splitter_node_vtable;
baseConfig.pInputChannels = pInputChannels;
baseConfig.pOutputChannels = pOutputChannels;
+ baseConfig.outputBusCount = pConfig->outputBusCount;
result = ma_node_init(pNodeGraph, &baseConfig, pAllocationCallbacks, &pSplitterNode->base);
if (result != MA_SUCCESS) {
@@ -70938,6 +73507,7 @@ MA_API float ma_delay_node_get_decay(const ma_delay_node* pDelayNode)
#endif /* MA_NO_NODE_GRAPH */
+/* SECTION: miniaudio_engine.c */
#if !defined(MA_NO_ENGINE) && !defined(MA_NO_NODE_GRAPH)
/**************************************************************************************************************************************************************
@@ -70946,6 +73516,27 @@ Engine
**************************************************************************************************************************************************************/
#define MA_SEEK_TARGET_NONE (~(ma_uint64)0)
+
+static void ma_sound_set_at_end(ma_sound* pSound, ma_bool32 atEnd)
+{
+ MA_ASSERT(pSound != NULL);
+ c89atomic_exchange_32(&pSound->atEnd, atEnd);
+
+ /* Fire any callbacks or events. */
+ if (atEnd) {
+ if (pSound->endCallback != NULL) {
+ pSound->endCallback(pSound->pEndCallbackUserData, pSound);
+ }
+ }
+}
+
+static ma_bool32 ma_sound_get_at_end(const ma_sound* pSound)
+{
+ MA_ASSERT(pSound != NULL);
+ return c89atomic_load_32(&pSound->atEnd);
+}
+
+
MA_API ma_engine_node_config ma_engine_node_config_init(ma_engine* pEngine, ma_engine_node_type type, ma_uint32 flags)
{
ma_engine_node_config config;
@@ -70955,6 +73546,7 @@ MA_API ma_engine_node_config ma_engine_node_config_init(ma_engine* pEngine, ma_e
config.type = type;
config.isPitchDisabled = (flags & MA_SOUND_FLAG_NO_PITCH) != 0;
config.isSpatializationDisabled = (flags & MA_SOUND_FLAG_NO_SPATIALIZATION) != 0;
+ config.monoExpansionMode = pEngine->monoExpansionMode;
return config;
}
@@ -71016,6 +73608,44 @@ static ma_uint64 ma_engine_node_get_required_input_frame_count(const ma_engine_n
return inputFrameCount;
}
+static ma_result ma_engine_node_set_volume(ma_engine_node* pEngineNode, float volume)
+{
+ if (pEngineNode == NULL) {
+ return MA_INVALID_ARGS;
+ }
+
+ ma_atomic_float_set(&pEngineNode->volume, volume);
+
+ /* If we're not smoothing we should bypass the volume gainer entirely. */
+ if (pEngineNode->volumeSmoothTimeInPCMFrames == 0) {
+ /* We should always have an active spatializer because it can be enabled and disabled dynamically. We can just use that for hodling our volume. */
+ ma_spatializer_set_master_volume(&pEngineNode->spatializer, volume);
+ } else {
+ /* We're using volume smoothing, so apply the master volume to the gainer. */
+ ma_gainer_set_gain(&pEngineNode->volumeGainer, volume);
+ }
+
+ return MA_SUCCESS;
+}
+
+static ma_result ma_engine_node_get_volume(const ma_engine_node* pEngineNode, float* pVolume)
+{
+ if (pVolume == NULL) {
+ return MA_INVALID_ARGS;
+ }
+
+ *pVolume = 0.0f;
+
+ if (pEngineNode == NULL) {
+ return MA_INVALID_ARGS;
+ }
+
+ *pVolume = ma_atomic_float_get((ma_atomic_float*)&pEngineNode->volume);
+
+ return MA_SUCCESS;
+}
+
+
static void ma_engine_node_process_pcm_frames__general(ma_engine_node* pEngineNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut)
{
ma_uint32 frameCountIn;
@@ -71028,6 +73658,7 @@ static void ma_engine_node_process_pcm_frames__general(ma_engine_node* pEngineNo
ma_bool32 isFadingEnabled;
ma_bool32 isSpatializationEnabled;
ma_bool32 isPanningEnabled;
+ ma_bool32 isVolumeSmoothingEnabled;
frameCountIn = *pFrameCountIn;
frameCountOut = *pFrameCountOut;
@@ -71038,10 +73669,11 @@ static void ma_engine_node_process_pcm_frames__general(ma_engine_node* pEngineNo
totalFramesProcessedIn = 0;
totalFramesProcessedOut = 0;
- isPitchingEnabled = ma_engine_node_is_pitching_enabled(pEngineNode);
- isFadingEnabled = pEngineNode->fader.volumeBeg != 1 || pEngineNode->fader.volumeEnd != 1;
- isSpatializationEnabled = ma_engine_node_is_spatialization_enabled(pEngineNode);
- isPanningEnabled = pEngineNode->panner.pan != 0 && channelsOut != 1;
+ isPitchingEnabled = ma_engine_node_is_pitching_enabled(pEngineNode);
+ isFadingEnabled = pEngineNode->fader.volumeBeg != 1 || pEngineNode->fader.volumeEnd != 1;
+ isSpatializationEnabled = ma_engine_node_is_spatialization_enabled(pEngineNode);
+ isPanningEnabled = pEngineNode->panner.pan != 0 && channelsOut != 1;
+ isVolumeSmoothingEnabled = pEngineNode->volumeSmoothTimeInPCMFrames > 0;
/* Keep going while we've still got data available for processing. */
while (totalFramesProcessedOut < frameCountOut) {
@@ -71117,6 +73749,19 @@ static void ma_engine_node_process_pcm_frames__general(ma_engine_node* pEngineNo
}
}
+ /*
+ If we're using smoothing, we won't be applying volume via the spatializer, but instead from a ma_gainer. In this case
+ we'll want to apply our volume now.
+ */
+ if (isVolumeSmoothingEnabled) {
+ if (isWorkingBufferValid) {
+ ma_gainer_process_pcm_frames(&pEngineNode->volumeGainer, pWorkingBuffer, pWorkingBuffer, framesJustProcessedOut);
+ } else {
+ ma_gainer_process_pcm_frames(&pEngineNode->volumeGainer, pWorkingBuffer, pRunningFramesIn, framesJustProcessedOut);
+ isWorkingBufferValid = MA_TRUE;
+ }
+ }
+
/*
If at this point we still haven't actually done anything with the working buffer we need
to just read straight from the input buffer.
@@ -71136,18 +73781,33 @@ static void ma_engine_node_process_pcm_frames__general(ma_engine_node* pEngineNo
if (pEngineNode->pinnedListenerIndex != MA_LISTENER_INDEX_CLOSEST && pEngineNode->pinnedListenerIndex < ma_engine_get_listener_count(pEngineNode->pEngine)) {
iListener = pEngineNode->pinnedListenerIndex;
} else {
- iListener = ma_engine_find_closest_listener(pEngineNode->pEngine, pEngineNode->spatializer.position.x, pEngineNode->spatializer.position.y, pEngineNode->spatializer.position.z);
+ ma_vec3f spatializerPosition = ma_spatializer_get_position(&pEngineNode->spatializer);
+ iListener = ma_engine_find_closest_listener(pEngineNode->pEngine, spatializerPosition.x, spatializerPosition.y, spatializerPosition.z);
}
ma_spatializer_process_pcm_frames(&pEngineNode->spatializer, &pEngineNode->pEngine->listeners[iListener], pRunningFramesOut, pWorkingBuffer, framesJustProcessedOut);
} else {
- /* No spatialization, but we still need to do channel conversion. */
+ /* No spatialization, but we still need to do channel conversion and master volume. */
+ float volume;
+ ma_engine_node_get_volume(pEngineNode, &volume); /* Should never fail. */
+
if (channelsIn == channelsOut) {
/* No channel conversion required. Just copy straight to the output buffer. */
- ma_copy_pcm_frames(pRunningFramesOut, pWorkingBuffer, framesJustProcessedOut, ma_format_f32, channelsOut);
+ if (isVolumeSmoothingEnabled) {
+ /* Volume has already been applied. Just copy straight to the output buffer. */
+ ma_copy_pcm_frames(pRunningFramesOut, pWorkingBuffer, framesJustProcessedOut * channelsOut, ma_format_f32, channelsOut);
+ } else {
+ /* Volume has not been applied yet. Copy and apply volume in the same pass. */
+ ma_copy_and_apply_volume_factor_f32(pRunningFramesOut, pWorkingBuffer, framesJustProcessedOut * channelsOut, volume);
+ }
} else {
/* Channel conversion required. TODO: Add support for channel maps here. */
- ma_channel_map_apply_f32(pRunningFramesOut, NULL, channelsOut, pWorkingBuffer, NULL, channelsIn, framesJustProcessedOut, ma_channel_mix_mode_simple, pEngineNode->pEngine->monoExpansionMode);
+ ma_channel_map_apply_f32(pRunningFramesOut, NULL, channelsOut, pWorkingBuffer, NULL, channelsIn, framesJustProcessedOut, ma_channel_mix_mode_simple, pEngineNode->monoExpansionMode);
+
+ /* If we're using smoothing, the volume will have already been applied. */
+ if (!isVolumeSmoothingEnabled) {
+ ma_apply_volume_factor_f32(pRunningFramesOut, framesJustProcessedOut * channelsOut, volume);
+ }
}
}
@@ -71250,7 +73910,7 @@ static void ma_engine_node_process_pcm_frames__sound(ma_node* pNode, const float
/* If we reached the end of the sound we'll want to mark it as at the end and stop it. This should never be returned for looping sounds. */
if (result == MA_AT_END) {
- c89atomic_exchange_32(&pSound->atEnd, MA_TRUE); /* This will be set to false in ma_sound_start(). */
+ ma_sound_set_at_end(pSound, MA_TRUE); /* This will be set to false in ma_sound_start(). */
}
pRunningFramesOut = ma_offset_pcm_frames_ptr_f32(ppFramesOut[0], totalFramesRead, ma_engine_get_channels(ma_sound_get_engine(pSound)));
@@ -71371,6 +74031,7 @@ typedef struct
size_t baseNodeOffset;
size_t resamplerOffset;
size_t spatializerOffset;
+ size_t gainerOffset;
} ma_engine_node_heap_layout;
static ma_result ma_engine_node_get_heap_layout(const ma_engine_node_config* pConfig, ma_engine_node_heap_layout* pHeapLayout)
@@ -71380,8 +74041,10 @@ static ma_result ma_engine_node_get_heap_layout(const ma_engine_node_config* pCo
ma_node_config baseNodeConfig;
ma_linear_resampler_config resamplerConfig;
ma_spatializer_config spatializerConfig;
+ ma_gainer_config gainerConfig;
ma_uint32 channelsIn;
ma_uint32 channelsOut;
+ ma_channel defaultStereoChannelMap[2] = {MA_CHANNEL_SIDE_LEFT, MA_CHANNEL_SIDE_RIGHT}; /* <-- Consistent with the default channel map of a stereo listener. Means channel conversion can run on a fast path. */
MA_ASSERT(pHeapLayout);
@@ -71418,7 +74081,7 @@ static ma_result ma_engine_node_get_heap_layout(const ma_engine_node_config* pCo
/* Resmapler. */
resamplerConfig = ma_linear_resampler_config_init(ma_format_f32, channelsIn, 1, 1); /* Input and output sample rates don't affect the calculation of the heap size. */
resamplerConfig.lpfOrder = 0;
-
+
result = ma_linear_resampler_get_heap_size(&resamplerConfig, &tempHeapSize);
if (result != MA_SUCCESS) {
return result; /* Failed to retrieve the size of the heap for the resampler. */
@@ -71431,6 +74094,10 @@ static ma_result ma_engine_node_get_heap_layout(const ma_engine_node_config* pCo
/* Spatializer. */
spatializerConfig = ma_engine_node_spatializer_config_init(&baseNodeConfig);
+ if (spatializerConfig.channelsIn == 2) {
+ spatializerConfig.pChannelMapIn = defaultStereoChannelMap;
+ }
+
result = ma_spatializer_get_heap_size(&spatializerConfig, &tempHeapSize);
if (result != MA_SUCCESS) {
return result; /* Failed to retrieve the size of the heap for the spatializer. */
@@ -71440,6 +74107,20 @@ static ma_result ma_engine_node_get_heap_layout(const ma_engine_node_config* pCo
pHeapLayout->sizeInBytes += ma_align_64(tempHeapSize);
+ /* Gainer. Will not be used if we are not using smoothing. */
+ if (pConfig->volumeSmoothTimeInPCMFrames > 0) {
+ gainerConfig = ma_gainer_config_init(channelsIn, pConfig->volumeSmoothTimeInPCMFrames);
+
+ result = ma_gainer_get_heap_size(&gainerConfig, &tempHeapSize);
+ if (result != MA_SUCCESS) {
+ return result;
+ }
+
+ pHeapLayout->gainerOffset = pHeapLayout->sizeInBytes;
+ pHeapLayout->sizeInBytes += ma_align_64(tempHeapSize);
+ }
+
+
return MA_SUCCESS;
}
@@ -71473,8 +74154,10 @@ MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* p
ma_fader_config faderConfig;
ma_spatializer_config spatializerConfig;
ma_panner_config pannerConfig;
+ ma_gainer_config gainerConfig;
ma_uint32 channelsIn;
ma_uint32 channelsOut;
+ ma_channel defaultStereoChannelMap[2] = {MA_CHANNEL_SIDE_LEFT, MA_CHANNEL_SIDE_RIGHT}; /* <-- Consistent with the default channel map of a stereo listener. Means channel conversion can run on a fast path. */
if (pEngineNode == NULL) {
return MA_INVALID_ARGS;
@@ -71494,19 +74177,29 @@ MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* p
pEngineNode->_pHeap = pHeap;
MA_ZERO_MEMORY(pHeap, heapLayout.sizeInBytes);
- pEngineNode->pEngine = pConfig->pEngine;
- pEngineNode->sampleRate = (pConfig->sampleRate > 0) ? pConfig->sampleRate : ma_engine_get_sample_rate(pEngineNode->pEngine);
- pEngineNode->pitch = 1;
- pEngineNode->oldPitch = 1;
- pEngineNode->oldDopplerPitch = 1;
- pEngineNode->isPitchDisabled = pConfig->isPitchDisabled;
- pEngineNode->isSpatializationDisabled = pConfig->isSpatializationDisabled;
- pEngineNode->pinnedListenerIndex = pConfig->pinnedListenerIndex;
-
+ pEngineNode->pEngine = pConfig->pEngine;
+ pEngineNode->sampleRate = (pConfig->sampleRate > 0) ? pConfig->sampleRate : ma_engine_get_sample_rate(pEngineNode->pEngine);
+ pEngineNode->volumeSmoothTimeInPCMFrames = pConfig->volumeSmoothTimeInPCMFrames;
+ pEngineNode->monoExpansionMode = pConfig->monoExpansionMode;
+ ma_atomic_float_set(&pEngineNode->volume, 1);
+ pEngineNode->pitch = 1;
+ pEngineNode->oldPitch = 1;
+ pEngineNode->oldDopplerPitch = 1;
+ pEngineNode->isPitchDisabled = pConfig->isPitchDisabled;
+ pEngineNode->isSpatializationDisabled = pConfig->isSpatializationDisabled;
+ pEngineNode->pinnedListenerIndex = pConfig->pinnedListenerIndex;
channelsIn = (pConfig->channelsIn != 0) ? pConfig->channelsIn : ma_engine_get_channels(pConfig->pEngine);
channelsOut = (pConfig->channelsOut != 0) ? pConfig->channelsOut : ma_engine_get_channels(pConfig->pEngine);
+ /*
+ If the sample rate of the sound is different to the engine, make sure pitching is enabled so that the resampler
+ is activated. Not doing this will result in the sound not being resampled if MA_SOUND_FLAG_NO_PITCH is used.
+ */
+ if (pEngineNode->sampleRate != ma_engine_get_sample_rate(pEngineNode->pEngine)) {
+ pEngineNode->isPitchDisabled = MA_FALSE;
+ }
+
/* Base node. */
baseNodeConfig = ma_engine_node_base_node_config_init(pConfig);
@@ -71553,6 +74246,10 @@ MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* p
spatializerConfig = ma_engine_node_spatializer_config_init(&baseNodeConfig);
spatializerConfig.gainSmoothTimeInFrames = pEngineNode->pEngine->gainSmoothTimeInFrames;
+ if (spatializerConfig.channelsIn == 2) {
+ spatializerConfig.pChannelMapIn = defaultStereoChannelMap;
+ }
+
result = ma_spatializer_init_preallocated(&spatializerConfig, ma_offset_ptr(pHeap, heapLayout.spatializerOffset), &pEngineNode->spatializer);
if (result != MA_SUCCESS) {
goto error2;
@@ -71570,6 +74267,18 @@ MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* p
goto error3;
}
+
+ /* We'll need a gainer for smoothing out volume changes if we have a non-zero smooth time. We apply this before converting to the output channel count. */
+ if (pConfig->volumeSmoothTimeInPCMFrames > 0) {
+ gainerConfig = ma_gainer_config_init(channelsIn, pConfig->volumeSmoothTimeInPCMFrames);
+
+ result = ma_gainer_init_preallocated(&gainerConfig, ma_offset_ptr(pHeap, heapLayout.gainerOffset), &pEngineNode->volumeGainer);
+ if (result != MA_SUCCESS) {
+ goto error3;
+ }
+ }
+
+
return MA_SUCCESS;
/* No need for allocation callbacks here because we use a preallocated heap. */
@@ -71618,6 +74327,10 @@ MA_API void ma_engine_node_uninit(ma_engine_node* pEngineNode, const ma_allocati
ma_node_uninit(&pEngineNode->baseNode, pAllocationCallbacks);
/* Now that the node has been uninitialized we can safely uninitialize the rest. */
+ if (pEngineNode->volumeSmoothTimeInPCMFrames > 0) {
+ ma_gainer_uninit(&pEngineNode->volumeGainer, pAllocationCallbacks);
+ }
+
ma_spatializer_uninit(&pEngineNode->spatializer, pAllocationCallbacks);
ma_linear_resampler_uninit(&pEngineNode->resampler, pAllocationCallbacks);
@@ -71629,10 +74342,22 @@ MA_API void ma_engine_node_uninit(ma_engine_node* pEngineNode, const ma_allocati
MA_API ma_sound_config ma_sound_config_init(void)
+{
+ return ma_sound_config_init_2(NULL);
+}
+
+MA_API ma_sound_config ma_sound_config_init_2(ma_engine* pEngine)
{
ma_sound_config config;
MA_ZERO_OBJECT(&config);
+
+ if (pEngine != NULL) {
+ config.monoExpansionMode = pEngine->monoExpansionMode;
+ } else {
+ config.monoExpansionMode = ma_mono_expansion_mode_default;
+ }
+
config.rangeEndInPCMFrames = ~((ma_uint64)0);
config.loopPointEndInPCMFrames = ~((ma_uint64)0);
@@ -71640,11 +74365,22 @@ MA_API ma_sound_config ma_sound_config_init(void)
}
MA_API ma_sound_group_config ma_sound_group_config_init(void)
+{
+ return ma_sound_group_config_init_2(NULL);
+}
+
+MA_API ma_sound_group_config ma_sound_group_config_init_2(ma_engine* pEngine)
{
ma_sound_group_config config;
MA_ZERO_OBJECT(&config);
+ if (pEngine != NULL) {
+ config.monoExpansionMode = pEngine->monoExpansionMode;
+ } else {
+ config.monoExpansionMode = ma_mono_expansion_mode_default;
+ }
+
return config;
}
@@ -71718,6 +74454,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng
}
pEngine->monoExpansionMode = engineConfig.monoExpansionMode;
+ pEngine->defaultVolumeSmoothTimeInPCMFrames = engineConfig.defaultVolumeSmoothTimeInPCMFrames;
ma_allocation_callbacks_init_copy(&pEngine->allocationCallbacks, &engineConfig.allocationCallbacks);
#if !defined(MA_NO_RESOURCE_MANAGER)
@@ -71729,7 +74466,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng
#if !defined(MA_NO_DEVICE_IO)
{
pEngine->pDevice = engineConfig.pDevice;
-
+
/* If we don't have a device, we need one. */
if (pEngine->pDevice == NULL && engineConfig.noDevice == MA_FALSE) {
ma_device_config deviceConfig;
@@ -71746,6 +74483,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng
deviceConfig.sampleRate = engineConfig.sampleRate;
deviceConfig.dataCallback = ma_engine_data_callback_internal;
deviceConfig.pUserData = pEngine;
+ deviceConfig.notificationCallback = engineConfig.notificationCallback;
deviceConfig.periodSizeInFrames = engineConfig.periodSizeInFrames;
deviceConfig.periodSizeInMilliseconds = engineConfig.periodSizeInMilliseconds;
deviceConfig.noPreSilencedOutputBuffer = MA_TRUE; /* We'll always be outputting to every frame in the callback so there's no need for a pre-silenced buffer. */
@@ -71843,7 +74581,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng
Temporarily disabled. There is a subtle bug here where front-left and front-right
will be used by the device's channel map, but this is not what we want to use for
spatialization. Instead we want to use side-left and side-right. I need to figure
- out a better solution for this. For now, disabling the user of device channel maps.
+ out a better solution for this. For now, disabling the use of device channel maps.
*/
/*listenerConfig.pChannelMapOut = pEngine->pDevice->playback.channelMap;*/
}
@@ -72089,16 +74827,36 @@ MA_API ma_node* ma_engine_get_endpoint(ma_engine* pEngine)
return ma_node_graph_get_endpoint(&pEngine->nodeGraph);
}
-MA_API ma_uint64 ma_engine_get_time(const ma_engine* pEngine)
+MA_API ma_uint64 ma_engine_get_time_in_pcm_frames(const ma_engine* pEngine)
{
return ma_node_graph_get_time(&pEngine->nodeGraph);
}
-MA_API ma_result ma_engine_set_time(ma_engine* pEngine, ma_uint64 globalTime)
+MA_API ma_uint64 ma_engine_get_time_in_milliseconds(const ma_engine* pEngine)
+{
+ return ma_engine_get_time_in_pcm_frames(pEngine) * 1000 / ma_engine_get_sample_rate(pEngine);
+}
+
+MA_API ma_result ma_engine_set_time_in_pcm_frames(ma_engine* pEngine, ma_uint64 globalTime)
{
return ma_node_graph_set_time(&pEngine->nodeGraph, globalTime);
}
+MA_API ma_result ma_engine_set_time_in_milliseconds(ma_engine* pEngine, ma_uint64 globalTime)
+{
+ return ma_engine_set_time_in_pcm_frames(pEngine, globalTime * ma_engine_get_sample_rate(pEngine) / 1000);
+}
+
+MA_API ma_uint64 ma_engine_get_time(const ma_engine* pEngine)
+{
+ return ma_engine_get_time_in_pcm_frames(pEngine);
+}
+
+MA_API ma_result ma_engine_set_time(ma_engine* pEngine, ma_uint64 globalTime)
+{
+ return ma_engine_set_time_in_pcm_frames(pEngine, globalTime);
+}
+
MA_API ma_uint32 ma_engine_get_channels(const ma_engine* pEngine)
{
return ma_node_graph_get_channels(&pEngine->nodeGraph);
@@ -72213,7 +74971,7 @@ MA_API ma_uint32 ma_engine_find_closest_listener(const ma_engine* pEngine, float
iListenerClosest = 0;
for (iListener = 0; iListener < pEngine->listenerCount; iListener += 1) {
if (ma_engine_listener_is_enabled(pEngine, iListener)) {
- float len2 = ma_vec3f_len2(ma_vec3f_sub(pEngine->listeners[iListener].position, ma_vec3f_init_3f(absolutePosX, absolutePosY, absolutePosZ)));
+ float len2 = ma_vec3f_len2(ma_vec3f_sub(ma_spatializer_listener_get_position(&pEngine->listeners[iListener]), ma_vec3f_init_3f(absolutePosX, absolutePosY, absolutePosZ)));
if (closestLen2 > len2) {
closestLen2 = len2;
iListenerClosest = iListener;
@@ -72512,8 +75270,14 @@ static ma_result ma_sound_init_from_data_source_internal(ma_engine* pEngine, con
source that provides this information upfront.
*/
engineNodeConfig = ma_engine_node_config_init(pEngine, type, pConfig->flags);
- engineNodeConfig.channelsIn = pConfig->channelsIn;
- engineNodeConfig.channelsOut = pConfig->channelsOut;
+ engineNodeConfig.channelsIn = pConfig->channelsIn;
+ engineNodeConfig.channelsOut = pConfig->channelsOut;
+ engineNodeConfig.volumeSmoothTimeInPCMFrames = pConfig->volumeSmoothTimeInPCMFrames;
+ engineNodeConfig.monoExpansionMode = pConfig->monoExpansionMode;
+
+ if (engineNodeConfig.volumeSmoothTimeInPCMFrames == 0) {
+ engineNodeConfig.volumeSmoothTimeInPCMFrames = pEngine->defaultVolumeSmoothTimeInPCMFrames;
+ }
/* If we're loading from a data source the input channel count needs to be the data source's native channel count. */
if (pConfig->pDataSource != NULL) {
@@ -72540,7 +75304,7 @@ static ma_result ma_sound_init_from_data_source_internal(ma_engine* pEngine, con
/* If no attachment is specified, attach the sound straight to the endpoint. */
if (pConfig->pInitialAttachment == NULL) {
- /* No group. Attach straight to the endpoint by default, unless the caller has requested that do not. */
+ /* No group. Attach straight to the endpoint by default, unless the caller has requested that it not. */
if ((pConfig->flags & MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT) == 0) {
result = ma_node_attach_output_bus(pSound, 0, ma_node_graph_get_endpoint(&pEngine->nodeGraph), 0);
}
@@ -72594,8 +75358,11 @@ MA_API ma_result ma_sound_init_from_file_internal(ma_engine* pEngine, const ma_s
return MA_OUT_OF_MEMORY;
}
- notifications = ma_resource_manager_pipeline_notifications_init();
- notifications.done.pFence = pConfig->pDoneFence;
+ /* Removed in 0.12. Set pDoneFence on the notifications. */
+ notifications = pConfig->initNotifications;
+ if (pConfig->pDoneFence != NULL && notifications.done.pFence == NULL) {
+ notifications.done.pFence = pConfig->pDoneFence;
+ }
/*
We must wrap everything around the fence if one was specified. This ensures ma_fence_wait() does
@@ -72643,21 +75410,35 @@ done:
MA_API ma_result ma_sound_init_from_file(ma_engine* pEngine, const char* pFilePath, ma_uint32 flags, ma_sound_group* pGroup, ma_fence* pDoneFence, ma_sound* pSound)
{
- ma_sound_config config = ma_sound_config_init();
+ ma_sound_config config;
+
+ if (pFilePath == NULL) {
+ return MA_INVALID_ARGS;
+ }
+
+ config = ma_sound_config_init_2(pEngine);
config.pFilePath = pFilePath;
config.flags = flags;
config.pInitialAttachment = pGroup;
config.pDoneFence = pDoneFence;
+
return ma_sound_init_ex(pEngine, &config, pSound);
}
MA_API ma_result ma_sound_init_from_file_w(ma_engine* pEngine, const wchar_t* pFilePath, ma_uint32 flags, ma_sound_group* pGroup, ma_fence* pDoneFence, ma_sound* pSound)
{
- ma_sound_config config = ma_sound_config_init();
+ ma_sound_config config;
+
+ if (pFilePath == NULL) {
+ return MA_INVALID_ARGS;
+ }
+
+ config = ma_sound_config_init_2(pEngine);
config.pFilePathW = pFilePath;
config.flags = flags;
config.pInitialAttachment = pGroup;
config.pDoneFence = pDoneFence;
+
return ma_sound_init_ex(pEngine, &config, pSound);
}
@@ -72682,7 +75463,7 @@ MA_API ma_result ma_sound_init_copy(ma_engine* pEngine, const ma_sound* pExistin
/*
We need to make a clone of the data source. If the data source is not a data buffer (i.e. a stream)
- the this will fail.
+ this will fail.
*/
pSound->pResourceManagerDataSource = (ma_resource_manager_data_source*)ma_malloc(sizeof(*pSound->pResourceManagerDataSource), &pEngine->allocationCallbacks);
if (pSound->pResourceManagerDataSource == NULL) {
@@ -72695,10 +75476,12 @@ MA_API ma_result ma_sound_init_copy(ma_engine* pEngine, const ma_sound* pExistin
return result;
}
- config = ma_sound_config_init();
- config.pDataSource = pSound->pResourceManagerDataSource;
- config.flags = flags;
- config.pInitialAttachment = pGroup;
+ config = ma_sound_config_init_2(pEngine);
+ config.pDataSource = pSound->pResourceManagerDataSource;
+ config.flags = flags;
+ config.pInitialAttachment = pGroup;
+ config.monoExpansionMode = pExistingSound->engineNode.monoExpansionMode;
+ config.volumeSmoothTimeInPCMFrames = pExistingSound->engineNode.volumeSmoothTimeInPCMFrames;
result = ma_sound_init_from_data_source_internal(pEngine, &config, pSound);
if (result != MA_SUCCESS) {
@@ -72708,13 +75491,16 @@ MA_API ma_result ma_sound_init_copy(ma_engine* pEngine, const ma_sound* pExistin
return result;
}
+ /* Make sure the sound is marked as the owner of the data source or else it will never get uninitialized. */
+ pSound->ownsDataSource = MA_TRUE;
+
return MA_SUCCESS;
}
#endif
MA_API ma_result ma_sound_init_from_data_source(ma_engine* pEngine, ma_data_source* pDataSource, ma_uint32 flags, ma_sound_group* pGroup, ma_sound* pSound)
{
- ma_sound_config config = ma_sound_config_init();
+ ma_sound_config config = ma_sound_config_init_2(pEngine);
config.pDataSource = pDataSource;
config.flags = flags;
config.pInitialAttachment = pGroup;
@@ -72734,6 +75520,9 @@ MA_API ma_result ma_sound_init_ex(ma_engine* pEngine, const ma_sound_config* pCo
return MA_INVALID_ARGS;
}
+ pSound->endCallback = pConfig->endCallback;
+ pSound->pEndCallbackUserData = pConfig->pEndCallbackUserData;
+
/* We need to load the sound differently depending on whether or not we're loading from a file. */
#ifndef MA_NO_RESOURCE_MANAGER
if (pConfig->pFilePath != NULL || pConfig->pFilePathW != NULL) {
@@ -72839,17 +75628,20 @@ MA_API void ma_sound_set_volume(ma_sound* pSound, float volume)
return;
}
- /* The volume is controlled via the output bus. */
- ma_node_set_output_bus_volume(pSound, 0, volume);
+ ma_engine_node_set_volume(&pSound->engineNode, volume);
}
MA_API float ma_sound_get_volume(const ma_sound* pSound)
{
+ float volume = 0;
+
if (pSound == NULL) {
return 0;
}
- return ma_node_get_output_bus_volume(pSound, 0);
+ ma_engine_node_get_volume(&pSound->engineNode, &volume);
+
+ return volume;
}
MA_API void ma_sound_set_pan(ma_sound* pSound, float pan)
@@ -73243,7 +76035,7 @@ MA_API void ma_sound_set_fade_in_milliseconds(ma_sound* pSound, float volumeBeg,
ma_sound_set_fade_in_pcm_frames(pSound, volumeBeg, volumeEnd, (fadeLengthInMilliseconds * pSound->engineNode.fader.config.sampleRate) / 1000);
}
-MA_API float ma_sound_get_current_fade_volume(ma_sound* pSound)
+MA_API float ma_sound_get_current_fade_volume(const ma_sound* pSound)
{
if (pSound == NULL) {
return MA_INVALID_ARGS;
@@ -73294,7 +76086,7 @@ MA_API ma_bool32 ma_sound_is_playing(const ma_sound* pSound)
return MA_FALSE;
}
- return ma_node_get_state_by_time(pSound, ma_engine_get_time(ma_sound_get_engine(pSound))) == ma_node_state_started;
+ return ma_node_get_state_by_time(pSound, ma_engine_get_time_in_pcm_frames(ma_sound_get_engine(pSound))) == ma_node_state_started;
}
MA_API ma_uint64 ma_sound_get_time_in_pcm_frames(const ma_sound* pSound)
@@ -73346,7 +76138,7 @@ MA_API ma_bool32 ma_sound_at_end(const ma_sound* pSound)
return MA_FALSE;
}
- return c89atomic_load_32(&pSound->atEnd);
+ return ma_sound_get_at_end(pSound);
}
MA_API ma_result ma_sound_seek_to_pcm_frame(ma_sound* pSound, ma_uint64 frameIndex)
@@ -73455,10 +76247,27 @@ MA_API ma_result ma_sound_get_length_in_seconds(ma_sound* pSound, float* pLength
return ma_data_source_get_length_in_seconds(pSound->pDataSource, pLength);
}
+MA_API ma_result ma_sound_set_end_callback(ma_sound* pSound, ma_sound_end_proc callback, void* pUserData)
+{
+ if (pSound == NULL) {
+ return MA_INVALID_ARGS;
+ }
+
+ /* The notion of an end is only valid for sounds that are backed by a data source. */
+ if (pSound->pDataSource == NULL) {
+ return MA_INVALID_OPERATION;
+ }
+
+ pSound->endCallback = callback;
+ pSound->pEndCallbackUserData = pUserData;
+
+ return MA_SUCCESS;
+}
+
MA_API ma_result ma_sound_group_init(ma_engine* pEngine, ma_uint32 flags, ma_sound_group* pParentGroup, ma_sound_group* pGroup)
{
- ma_sound_group_config config = ma_sound_group_config_init();
+ ma_sound_group_config config = ma_sound_group_config_init_2(pEngine);
config.flags = flags;
config.pInitialAttachment = pParentGroup;
return ma_sound_group_init_ex(pEngine, &config, pGroup);
@@ -73760,6 +76569,7 @@ MA_API ma_uint64 ma_sound_group_get_time_in_pcm_frames(const ma_sound_group* pGr
return ma_sound_get_time_in_pcm_frames(pGroup);
}
#endif /* MA_NO_ENGINE */
+/* END SECTION: miniaudio_engine.c */
@@ -73778,13 +76588,18 @@ code below please report the bug to the respective repository for the relevant p
/* dr_wav_c begin */
#ifndef dr_wav_c
#define dr_wav_c
+#ifdef __MRC__
+#pragma options opt off
+#endif
#include
#include
#include
#ifndef DR_WAV_NO_STDIO
#include
+#ifndef DR_WAV_NO_WCHAR
#include
#endif
+#endif
#ifndef DRWAV_ASSERT
#include
#define DRWAV_ASSERT(expression) assert(expression)
@@ -74478,10 +77293,14 @@ DRWAV_PRIVATE drwav_uint64 drwav__read_smpl_to_metadata_obj(drwav__metadata_pars
{
drwav_uint8 smplHeaderData[DRWAV_SMPL_BYTES];
drwav_uint64 totalBytesRead = 0;
- size_t bytesJustRead = drwav__metadata_parser_read(pParser, smplHeaderData, sizeof(smplHeaderData), &totalBytesRead);
+ size_t bytesJustRead;
+ if (pMetadata == NULL) {
+ return 0;
+ }
+ bytesJustRead = drwav__metadata_parser_read(pParser, smplHeaderData, sizeof(smplHeaderData), &totalBytesRead);
DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read);
DRWAV_ASSERT(pChunkHeader != NULL);
- if (bytesJustRead == sizeof(smplHeaderData)) {
+ if (pMetadata != NULL && bytesJustRead == sizeof(smplHeaderData)) {
drwav_uint32 iSampleLoop;
pMetadata->type = drwav_metadata_type_smpl;
pMetadata->data.smpl.manufacturerId = drwav_bytes_to_u32(smplHeaderData + 0);
@@ -74522,7 +77341,11 @@ DRWAV_PRIVATE drwav_uint64 drwav__read_cue_to_metadata_obj(drwav__metadata_parse
{
drwav_uint8 cueHeaderSectionData[DRWAV_CUE_BYTES];
drwav_uint64 totalBytesRead = 0;
- size_t bytesJustRead = drwav__metadata_parser_read(pParser, cueHeaderSectionData, sizeof(cueHeaderSectionData), &totalBytesRead);
+ size_t bytesJustRead;
+ if (pMetadata == NULL) {
+ return 0;
+ }
+ bytesJustRead = drwav__metadata_parser_read(pParser, cueHeaderSectionData, sizeof(cueHeaderSectionData), &totalBytesRead);
DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read);
if (bytesJustRead == sizeof(cueHeaderSectionData)) {
pMetadata->type = drwav_metadata_type_cue;
@@ -74557,7 +77380,11 @@ DRWAV_PRIVATE drwav_uint64 drwav__read_cue_to_metadata_obj(drwav__metadata_parse
DRWAV_PRIVATE drwav_uint64 drwav__read_inst_to_metadata_obj(drwav__metadata_parser* pParser, drwav_metadata* pMetadata)
{
drwav_uint8 instData[DRWAV_INST_BYTES];
- drwav_uint64 bytesRead = drwav__metadata_parser_read(pParser, instData, sizeof(instData), NULL);
+ drwav_uint64 bytesRead;
+ if (pMetadata == NULL) {
+ return 0;
+ }
+ bytesRead = drwav__metadata_parser_read(pParser, instData, sizeof(instData), NULL);
DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read);
if (bytesRead == sizeof(instData)) {
pMetadata->type = drwav_metadata_type_inst;
@@ -74574,7 +77401,11 @@ DRWAV_PRIVATE drwav_uint64 drwav__read_inst_to_metadata_obj(drwav__metadata_pars
DRWAV_PRIVATE drwav_uint64 drwav__read_acid_to_metadata_obj(drwav__metadata_parser* pParser, drwav_metadata* pMetadata)
{
drwav_uint8 acidData[DRWAV_ACID_BYTES];
- drwav_uint64 bytesRead = drwav__metadata_parser_read(pParser, acidData, sizeof(acidData), NULL);
+ drwav_uint64 bytesRead;
+ if (pMetadata == NULL) {
+ return 0;
+ }
+ bytesRead = drwav__metadata_parser_read(pParser, acidData, sizeof(acidData), NULL);
DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read);
if (bytesRead == sizeof(acidData)) {
pMetadata->type = drwav_metadata_type_acid;
@@ -75599,7 +78430,7 @@ DRWAV_PRIVATE size_t drwav__write_or_count_metadata(drwav* pWav, drwav_metadata*
bytesWritten += drwav__write_or_count_u32ne_to_le(pWav, pMetadata->data.smpl.pLoops[iLoop].playCount);
}
if (pMetadata->data.smpl.samplerSpecificDataSizeInBytes > 0) {
- bytesWritten += drwav__write(pWav, pMetadata->data.smpl.pSamplerSpecificData, pMetadata->data.smpl.samplerSpecificDataSizeInBytes);
+ bytesWritten += drwav__write_or_count(pWav, pMetadata->data.smpl.pSamplerSpecificData, pMetadata->data.smpl.samplerSpecificDataSizeInBytes);
}
} break;
case drwav_metadata_type_inst:
@@ -76491,6 +79322,7 @@ DRWAV_PRIVATE drwav_result drwav_fopen(FILE** ppFile, const char* pFilePath, con
#define DRWAV_HAS_WFOPEN
#endif
#endif
+#ifndef DR_WAV_NO_WCHAR
DRWAV_PRIVATE drwav_result drwav_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drwav_allocation_callbacks* pAllocationCallbacks)
{
if (ppFile != NULL) {
@@ -76515,6 +79347,10 @@ DRWAV_PRIVATE drwav_result drwav_wfopen(FILE** ppFile, const wchar_t* pFilePath,
(void)pAllocationCallbacks;
}
#else
+ #if defined(__DJGPP__)
+ {
+ }
+ #else
{
mbstate_t mbs;
size_t lenMB;
@@ -76547,12 +79383,14 @@ DRWAV_PRIVATE drwav_result drwav_wfopen(FILE** ppFile, const wchar_t* pFilePath,
*ppFile = fopen(pFilePathMB, pOpenModeMB);
drwav__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
}
+ #endif
if (*ppFile == NULL) {
return DRWAV_ERROR;
}
#endif
return DRWAV_SUCCESS;
}
+#endif
DRWAV_PRIVATE size_t drwav__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead)
{
return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData);
@@ -76593,6 +79431,7 @@ DRWAV_API drwav_bool32 drwav_init_file_ex(drwav* pWav, const char* filename, drw
}
return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, drwav_metadata_type_none, pAllocationCallbacks);
}
+#ifndef DR_WAV_NO_WCHAR
DRWAV_API drwav_bool32 drwav_init_file_w(drwav* pWav, const wchar_t* filename, const drwav_allocation_callbacks* pAllocationCallbacks)
{
return drwav_init_file_ex_w(pWav, filename, NULL, NULL, 0, pAllocationCallbacks);
@@ -76605,6 +79444,7 @@ DRWAV_API drwav_bool32 drwav_init_file_ex_w(drwav* pWav, const wchar_t* filename
}
return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, drwav_metadata_type_none, pAllocationCallbacks);
}
+#endif
DRWAV_API drwav_bool32 drwav_init_file_with_metadata(drwav* pWav, const char* filename, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
{
FILE* pFile;
@@ -76613,6 +79453,7 @@ DRWAV_API drwav_bool32 drwav_init_file_with_metadata(drwav* pWav, const char* fi
}
return drwav_init_file__internal_FILE(pWav, pFile, NULL, NULL, flags, drwav_metadata_type_all_including_unknown, pAllocationCallbacks);
}
+#ifndef DR_WAV_NO_WCHAR
DRWAV_API drwav_bool32 drwav_init_file_with_metadata_w(drwav* pWav, const wchar_t* filename, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
{
FILE* pFile;
@@ -76621,6 +79462,7 @@ DRWAV_API drwav_bool32 drwav_init_file_with_metadata_w(drwav* pWav, const wchar_
}
return drwav_init_file__internal_FILE(pWav, pFile, NULL, NULL, flags, drwav_metadata_type_all_including_unknown, pAllocationCallbacks);
}
+#endif
DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal_FILE(drwav* pWav, FILE* pFile, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
{
drwav_bool32 result;
@@ -76644,6 +79486,7 @@ DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal(drwav* pWav, const ch
}
return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
}
+#ifndef DR_WAV_NO_WCHAR
DRWAV_PRIVATE drwav_bool32 drwav_init_file_write_w__internal(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
{
FILE* pFile;
@@ -76652,6 +79495,7 @@ DRWAV_PRIVATE drwav_bool32 drwav_init_file_write_w__internal(drwav* pWav, const
}
return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
}
+#endif
DRWAV_API drwav_bool32 drwav_init_file_write(drwav* pWav, const char* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
{
return drwav_init_file_write__internal(pWav, filename, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
@@ -76667,6 +79511,7 @@ DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames(drwav* pWav,
}
return drwav_init_file_write_sequential(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
}
+#ifndef DR_WAV_NO_WCHAR
DRWAV_API drwav_bool32 drwav_init_file_write_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
{
return drwav_init_file_write_w__internal(pWav, filename, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
@@ -76683,6 +79528,7 @@ DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames_w(drwav* pWav
return drwav_init_file_write_sequential_w(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
}
#endif
+#endif
DRWAV_PRIVATE size_t drwav__on_read_memory(void* pUserData, void* pBufferOut, size_t bytesToRead)
{
drwav* pWav = (drwav*)pUserData;
@@ -78701,6 +81547,7 @@ DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32(const char* filen
}
return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
}
+#ifndef DR_WAV_NO_WCHAR
DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
{
drwav wav;
@@ -78753,6 +81600,7 @@ DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32_w(const wchar_t*
return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
}
#endif
+#endif
DRWAV_API drwav_int16* drwav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
{
drwav wav;
@@ -78866,6 +81714,9 @@ DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b)
a[2] == b[2] &&
a[3] == b[3];
}
+#ifdef __MRC__
+#pragma options opt reset
+#endif
#endif
/* dr_wav_c end */
#endif /* DRWAV_IMPLEMENTATION */
@@ -79022,9 +81873,7 @@ static DRFLAC_INLINE drflac_bool32 drflac_has_sse41(void)
{
#if defined(DRFLAC_SUPPORT_SSE41)
#if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE41)
- #if defined(DRFLAC_X64)
- return DRFLAC_TRUE;
- #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE4_1__)
+ #if defined(__SSE4_1__) || defined(__AVX__)
return DRFLAC_TRUE;
#else
#if defined(DRFLAC_NO_CPUID)
@@ -79086,18 +81935,21 @@ static DRFLAC_INLINE drflac_bool32 drflac_has_sse41(void)
extern __inline drflac_uint64 _watcom_bswap64(drflac_uint64);
#pragma aux _watcom_bswap16 = \
"xchg al, ah" \
- parm [ax] \
- modify [ax];
+ parm [ax] \
+ value [ax] \
+ modify nomemory;
#pragma aux _watcom_bswap32 = \
- "bswap eax" \
- parm [eax] \
- modify [eax];
+ "bswap eax" \
+ parm [eax] \
+ value [eax] \
+ modify nomemory;
#pragma aux _watcom_bswap64 = \
"bswap eax" \
"bswap edx" \
"xchg eax,edx" \
parm [eax edx] \
- modify [eax edx];
+ value [eax edx] \
+ modify nomemory;
#endif
#ifndef DRFLAC_ASSERT
#include
@@ -79189,6 +82041,9 @@ typedef drflac_int32 drflac_result;
#define DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE 8
#define DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE 9
#define DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE 10
+#define DRFLAC_SEEKPOINT_SIZE_IN_BYTES 18
+#define DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES 36
+#define DRFLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES 12
#define drflac_align(x, a) ((((x) + (a) - 1) / (a)) * (a))
DRFLAC_API void drflac_version(drflac_uint32* pMajor, drflac_uint32* pMinor, drflac_uint32* pRevision)
{
@@ -79962,6 +82817,10 @@ static drflac_bool32 drflac__find_and_seek_to_next_sync_code(drflac_bs* bs)
#if defined(__WATCOMC__) && defined(__386__)
#define DRFLAC_IMPLEMENT_CLZ_WATCOM
#endif
+#ifdef __MRC__
+#include
+#define DRFLAC_IMPLEMENT_CLZ_MRC
+#endif
static DRFLAC_INLINE drflac_uint32 drflac__clz_software(drflac_cache_t x)
{
drflac_uint32 n;
@@ -79996,6 +82855,8 @@ static DRFLAC_INLINE drflac_bool32 drflac__is_lzcnt_supported(void)
{
#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
return DRFLAC_TRUE;
+#elif defined(__MRC__)
+ return DRFLAC_TRUE;
#else
#ifdef DRFLAC_HAS_LZCNT_INTRINSIC
return drflac__gIsLZCNTSupported;
@@ -80076,6 +82937,13 @@ static DRFLAC_INLINE drflac_uint32 drflac__clz_msvc(drflac_cache_t x)
#endif
#ifdef DRFLAC_IMPLEMENT_CLZ_WATCOM
static __inline drflac_uint32 drflac__clz_watcom (drflac_uint32);
+#ifdef DRFLAC_IMPLEMENT_CLZ_WATCOM_LZCNT
+#pragma aux drflac__clz_watcom_lzcnt = \
+ "db 0F3h, 0Fh, 0BDh, 0C0h" \
+ parm [eax] \
+ value [eax] \
+ modify nomemory;
+#else
#pragma aux drflac__clz_watcom = \
"bsr eax, eax" \
"xor eax, 31" \
@@ -80083,6 +82951,7 @@ static __inline drflac_uint32 drflac__clz_watcom (drflac_uint32);
value [eax] \
modify exact [eax] nomemory;
#endif
+#endif
static DRFLAC_INLINE drflac_uint32 drflac__clz(drflac_cache_t x)
{
#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
@@ -80093,8 +82962,12 @@ static DRFLAC_INLINE drflac_uint32 drflac__clz(drflac_cache_t x)
{
#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
return drflac__clz_msvc(x);
+#elif defined(DRFLAC_IMPLEMENT_CLZ_WATCOM_LZCNT)
+ return drflac__clz_watcom_lzcnt(x);
#elif defined(DRFLAC_IMPLEMENT_CLZ_WATCOM)
return (x == 0) ? sizeof(x)*8 : drflac__clz_watcom(x);
+#elif defined(__MRC__)
+ return __cntlzw(x);
#else
return drflac__clz_software(x);
#endif
@@ -81261,7 +84134,7 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_32(drflac_
int32x2_t shift64;
uint32x4_t one128;
const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
- riceParamMask = ~((~0UL) << riceParam);
+ riceParamMask = (drflac_uint32)~((~0UL) << riceParam);
riceParamMask128 = vdupq_n_u32(riceParamMask);
riceParam128 = vdupq_n_s32(riceParam);
shift64 = vdup_n_s32(-shift);
@@ -81401,8 +84274,11 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_
int32x4_t riceParam128;
int64x1_t shift64;
uint32x4_t one128;
+ int64x2_t prediction128 = { 0 };
+ uint32x4_t zeroCountPart128;
+ uint32x4_t riceParamPart128;
const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
- riceParamMask = ~((~0UL) << riceParam);
+ riceParamMask = (drflac_uint32)~((~0UL) << riceParam);
riceParamMask128 = vdupq_n_u32(riceParamMask);
riceParam128 = vdupq_n_s32(riceParam);
shift64 = vdup_n_s64(-shift);
@@ -81458,9 +84334,6 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_
coefficients128_8 = drflac__vrevq_s32(coefficients128_8);
}
while (pDecodedSamples < pDecodedSamplesEnd) {
- int64x2_t prediction128;
- uint32x4_t zeroCountPart128;
- uint32x4_t riceParamPart128;
if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
@@ -82751,7 +85624,7 @@ static void drflac__free_from_callbacks(void* p, const drflac_allocation_callbac
pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
}
}
-static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_uint64* pFirstFramePos, drflac_uint64* pSeektablePos, drflac_uint32* pSeektableSize, drflac_allocation_callbacks* pAllocationCallbacks)
+static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_uint64* pFirstFramePos, drflac_uint64* pSeektablePos, drflac_uint32* pSeekpointCount, drflac_allocation_callbacks* pAllocationCallbacks)
{
drflac_uint64 runningFilePos = 42;
drflac_uint64 seektablePos = 0;
@@ -82798,26 +85671,28 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
seektablePos = runningFilePos;
seektableSize = blockSize;
if (onMeta) {
+ drflac_uint32 seekpointCount;
drflac_uint32 iSeekpoint;
void* pRawData;
- pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
+ seekpointCount = blockSize/DRFLAC_SEEKPOINT_SIZE_IN_BYTES;
+ pRawData = drflac__malloc_from_callbacks(seekpointCount * sizeof(drflac_seekpoint), pAllocationCallbacks);
if (pRawData == NULL) {
return DRFLAC_FALSE;
}
- if (onRead(pUserData, pRawData, blockSize) != blockSize) {
- drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
- return DRFLAC_FALSE;
- }
- metadata.pRawData = pRawData;
- metadata.rawDataSize = blockSize;
- metadata.data.seektable.seekpointCount = blockSize/sizeof(drflac_seekpoint);
- metadata.data.seektable.pSeekpoints = (const drflac_seekpoint*)pRawData;
- for (iSeekpoint = 0; iSeekpoint < metadata.data.seektable.seekpointCount; ++iSeekpoint) {
+ for (iSeekpoint = 0; iSeekpoint < seekpointCount; ++iSeekpoint) {
drflac_seekpoint* pSeekpoint = (drflac_seekpoint*)pRawData + iSeekpoint;
+ if (onRead(pUserData, pSeekpoint, DRFLAC_SEEKPOINT_SIZE_IN_BYTES) != DRFLAC_SEEKPOINT_SIZE_IN_BYTES) {
+ drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
+ return DRFLAC_FALSE;
+ }
pSeekpoint->firstPCMFrame = drflac__be2host_64(pSeekpoint->firstPCMFrame);
pSeekpoint->flacFrameOffset = drflac__be2host_64(pSeekpoint->flacFrameOffset);
pSeekpoint->pcmFrameCount = drflac__be2host_16(pSeekpoint->pcmFrameCount);
}
+ metadata.pRawData = pRawData;
+ metadata.rawDataSize = blockSize;
+ metadata.data.seektable.seekpointCount = seekpointCount;
+ metadata.data.seektable.pSeekpoints = (const drflac_seekpoint*)pRawData;
onMeta(pUserDataMD, &metadata);
drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
}
@@ -82882,8 +85757,10 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
void* pRawData;
const char* pRunningData;
const char* pRunningDataEnd;
+ size_t bufferSize;
drflac_uint8 iTrack;
drflac_uint8 iIndex;
+ void* pTrackData;
pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
if (pRawData == NULL) {
return DRFLAC_FALSE;
@@ -82900,29 +85777,61 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
metadata.data.cuesheet.leadInSampleCount = drflac__be2host_64(*(const drflac_uint64*)pRunningData); pRunningData += 8;
metadata.data.cuesheet.isCD = (pRunningData[0] & 0x80) != 0; pRunningData += 259;
metadata.data.cuesheet.trackCount = pRunningData[0]; pRunningData += 1;
- metadata.data.cuesheet.pTrackData = pRunningData;
- for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) {
- drflac_uint8 indexCount;
- drflac_uint32 indexPointSize;
- if (pRunningDataEnd - pRunningData < 36) {
- drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
- return DRFLAC_FALSE;
- }
- pRunningData += 35;
- indexCount = pRunningData[0]; pRunningData += 1;
- indexPointSize = indexCount * sizeof(drflac_cuesheet_track_index);
- if (pRunningDataEnd - pRunningData < (drflac_int64)indexPointSize) {
- drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
- return DRFLAC_FALSE;
- }
- for (iIndex = 0; iIndex < indexCount; ++iIndex) {
- drflac_cuesheet_track_index* pTrack = (drflac_cuesheet_track_index*)pRunningData;
- pRunningData += sizeof(drflac_cuesheet_track_index);
- pTrack->offset = drflac__be2host_64(pTrack->offset);
+ metadata.data.cuesheet.pTrackData = NULL;
+ {
+ const char* pRunningDataSaved = pRunningData;
+ bufferSize = metadata.data.cuesheet.trackCount * DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES;
+ for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) {
+ drflac_uint8 indexCount;
+ drflac_uint32 indexPointSize;
+ if (pRunningDataEnd - pRunningData < DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES) {
+ drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
+ return DRFLAC_FALSE;
+ }
+ pRunningData += 35;
+ indexCount = pRunningData[0];
+ pRunningData += 1;
+ bufferSize += indexCount * sizeof(drflac_cuesheet_track_index);
+ indexPointSize = indexCount * DRFLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES;
+ if (pRunningDataEnd - pRunningData < (drflac_int64)indexPointSize) {
+ drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
+ return DRFLAC_FALSE;
+ }
+ pRunningData += indexPointSize;
}
+ pRunningData = pRunningDataSaved;
+ }
+ {
+ char* pRunningTrackData;
+ pTrackData = drflac__malloc_from_callbacks(bufferSize, pAllocationCallbacks);
+ if (pTrackData == NULL) {
+ drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
+ return DRFLAC_FALSE;
+ }
+ pRunningTrackData = (char*)pTrackData;
+ for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) {
+ drflac_uint8 indexCount;
+ DRFLAC_COPY_MEMORY(pRunningTrackData, pRunningData, DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES);
+ pRunningData += DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES-1;
+ pRunningTrackData += DRFLAC_CUESHEET_TRACK_SIZE_IN_BYTES-1;
+ indexCount = pRunningData[0];
+ pRunningData += 1;
+ pRunningTrackData += 1;
+ for (iIndex = 0; iIndex < indexCount; ++iIndex) {
+ drflac_cuesheet_track_index* pTrackIndex = (drflac_cuesheet_track_index*)pRunningTrackData;
+ DRFLAC_COPY_MEMORY(pRunningTrackData, pRunningData, DRFLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES);
+ pRunningData += DRFLAC_CUESHEET_TRACK_INDEX_SIZE_IN_BYTES;
+ pRunningTrackData += sizeof(drflac_cuesheet_track_index);
+ pTrackIndex->offset = drflac__be2host_64(pTrackIndex->offset);
+ }
+ }
+ metadata.data.cuesheet.pTrackData = pTrackData;
}
- onMeta(pUserDataMD, &metadata);
drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
+ pRawData = NULL;
+ onMeta(pUserDataMD, &metadata);
+ drflac__free_from_callbacks(pTrackData, pAllocationCallbacks);
+ pTrackData = NULL;
}
} break;
case DRFLAC_METADATA_BLOCK_TYPE_PICTURE:
@@ -82952,13 +85861,13 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
return DRFLAC_FALSE;
}
- metadata.data.picture.mime = pRunningData; pRunningData += metadata.data.picture.mimeLength;
+ metadata.data.picture.mime = pRunningData; pRunningData += metadata.data.picture.mimeLength;
metadata.data.picture.descriptionLength = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
if ((pRunningDataEnd - pRunningData) - 20 < (drflac_int64)metadata.data.picture.descriptionLength) {
drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
return DRFLAC_FALSE;
}
- metadata.data.picture.description = pRunningData; pRunningData += metadata.data.picture.descriptionLength;
+ metadata.data.picture.description = pRunningData; pRunningData += metadata.data.picture.descriptionLength;
metadata.data.picture.width = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
metadata.data.picture.height = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
metadata.data.picture.colorDepth = drflac__be2host_32_ptr_unaligned(pRunningData); pRunningData += 4;
@@ -83020,9 +85929,9 @@ static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, d
break;
}
}
- *pSeektablePos = seektablePos;
- *pSeektableSize = seektableSize;
- *pFirstFramePos = runningFilePos;
+ *pSeektablePos = seektablePos;
+ *pSeekpointCount = seektableSize / DRFLAC_SEEKPOINT_SIZE_IN_BYTES;
+ *pFirstFramePos = runningFilePos;
return DRFLAC_TRUE;
}
static drflac_bool32 drflac__init_private__native(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_bool32 relaxed)
@@ -83773,11 +86682,11 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
drflac_uint32 wholeSIMDVectorCountPerChannel;
drflac_uint32 decodedSamplesAllocationSize;
#ifndef DR_FLAC_NO_OGG
- drflac_oggbs oggbs;
+ drflac_oggbs* pOggbs = NULL;
#endif
drflac_uint64 firstFramePos;
drflac_uint64 seektablePos;
- drflac_uint32 seektableSize;
+ drflac_uint32 seekpointCount;
drflac_allocation_callbacks allocationCallbacks;
drflac* pFlac;
drflac__init_cpu_caps();
@@ -83807,22 +86716,24 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
#ifndef DR_FLAC_NO_OGG
if (init.container == drflac_container_ogg) {
allocationSize += sizeof(drflac_oggbs);
- }
- DRFLAC_ZERO_MEMORY(&oggbs, sizeof(oggbs));
- if (init.container == drflac_container_ogg) {
- oggbs.onRead = onRead;
- oggbs.onSeek = onSeek;
- oggbs.pUserData = pUserData;
- oggbs.currentBytePos = init.oggFirstBytePos;
- oggbs.firstBytePos = init.oggFirstBytePos;
- oggbs.serialNumber = init.oggSerial;
- oggbs.bosPageHeader = init.oggBosHeader;
- oggbs.bytesRemainingInPage = 0;
+ pOggbs = (drflac_oggbs*)drflac__malloc_from_callbacks(sizeof(*pOggbs), &allocationCallbacks);
+ if (pOggbs == NULL) {
+ return NULL;
+ }
+ DRFLAC_ZERO_MEMORY(pOggbs, sizeof(*pOggbs));
+ pOggbs->onRead = onRead;
+ pOggbs->onSeek = onSeek;
+ pOggbs->pUserData = pUserData;
+ pOggbs->currentBytePos = init.oggFirstBytePos;
+ pOggbs->firstBytePos = init.oggFirstBytePos;
+ pOggbs->serialNumber = init.oggSerial;
+ pOggbs->bosPageHeader = init.oggBosHeader;
+ pOggbs->bytesRemainingInPage = 0;
}
#endif
- firstFramePos = 42;
- seektablePos = 0;
- seektableSize = 0;
+ firstFramePos = 42;
+ seektablePos = 0;
+ seekpointCount = 0;
if (init.hasMetadataBlocks) {
drflac_read_proc onReadOverride = onRead;
drflac_seek_proc onSeekOverride = onSeek;
@@ -83831,16 +86742,22 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
if (init.container == drflac_container_ogg) {
onReadOverride = drflac__on_read_ogg;
onSeekOverride = drflac__on_seek_ogg;
- pUserDataOverride = (void*)&oggbs;
+ pUserDataOverride = (void*)pOggbs;
}
#endif
- if (!drflac__read_and_decode_metadata(onReadOverride, onSeekOverride, onMeta, pUserDataOverride, pUserDataMD, &firstFramePos, &seektablePos, &seektableSize, &allocationCallbacks)) {
+ if (!drflac__read_and_decode_metadata(onReadOverride, onSeekOverride, onMeta, pUserDataOverride, pUserDataMD, &firstFramePos, &seektablePos, &seekpointCount, &allocationCallbacks)) {
+ #ifndef DR_FLAC_NO_OGG
+ drflac__free_from_callbacks(pOggbs, &allocationCallbacks);
+ #endif
return NULL;
}
- allocationSize += seektableSize;
+ allocationSize += seekpointCount * sizeof(drflac_seekpoint);
}
pFlac = (drflac*)drflac__malloc_from_callbacks(allocationSize, &allocationCallbacks);
if (pFlac == NULL) {
+ #ifndef DR_FLAC_NO_OGG
+ drflac__free_from_callbacks(pOggbs, &allocationCallbacks);
+ #endif
return NULL;
}
drflac__init_from_info(pFlac, &init);
@@ -83848,8 +86765,10 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
pFlac->pDecodedSamples = (drflac_int32*)drflac_align((size_t)pFlac->pExtraData, DRFLAC_MAX_SIMD_VECTOR_SIZE);
#ifndef DR_FLAC_NO_OGG
if (init.container == drflac_container_ogg) {
- drflac_oggbs* pInternalOggbs = (drflac_oggbs*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize + seektableSize);
- DRFLAC_COPY_MEMORY(pInternalOggbs, &oggbs, sizeof(oggbs));
+ drflac_oggbs* pInternalOggbs = (drflac_oggbs*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize + (seekpointCount * sizeof(drflac_seekpoint)));
+ DRFLAC_COPY_MEMORY(pInternalOggbs, pOggbs, sizeof(*pOggbs));
+ drflac__free_from_callbacks(pOggbs, &allocationCallbacks);
+ pOggbs = NULL;
pFlac->bs.onRead = drflac__on_read_ogg;
pFlac->bs.onSeek = drflac__on_seek_ogg;
pFlac->bs.pUserData = (void*)pInternalOggbs;
@@ -83867,21 +86786,22 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
#endif
{
if (seektablePos != 0) {
- pFlac->seekpointCount = seektableSize / sizeof(*pFlac->pSeekpoints);
+ pFlac->seekpointCount = seekpointCount;
pFlac->pSeekpoints = (drflac_seekpoint*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize);
DRFLAC_ASSERT(pFlac->bs.onSeek != NULL);
DRFLAC_ASSERT(pFlac->bs.onRead != NULL);
if (pFlac->bs.onSeek(pFlac->bs.pUserData, (int)seektablePos, drflac_seek_origin_start)) {
- if (pFlac->bs.onRead(pFlac->bs.pUserData, pFlac->pSeekpoints, seektableSize) == seektableSize) {
- drflac_uint32 iSeekpoint;
- for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
+ drflac_uint32 iSeekpoint;
+ for (iSeekpoint = 0; iSeekpoint < seekpointCount; iSeekpoint += 1) {
+ if (pFlac->bs.onRead(pFlac->bs.pUserData, pFlac->pSeekpoints + iSeekpoint, DRFLAC_SEEKPOINT_SIZE_IN_BYTES) == DRFLAC_SEEKPOINT_SIZE_IN_BYTES) {
pFlac->pSeekpoints[iSeekpoint].firstPCMFrame = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].firstPCMFrame);
pFlac->pSeekpoints[iSeekpoint].flacFrameOffset = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].flacFrameOffset);
pFlac->pSeekpoints[iSeekpoint].pcmFrameCount = drflac__be2host_16(pFlac->pSeekpoints[iSeekpoint].pcmFrameCount);
+ } else {
+ pFlac->pSeekpoints = NULL;
+ pFlac->seekpointCount = 0;
+ break;
}
- } else {
- pFlac->pSeekpoints = NULL;
- pFlac->seekpointCount = 0;
}
if (!pFlac->bs.onSeek(pFlac->bs.pUserData, (int)pFlac->firstFLACFramePosInBytes, drflac_seek_origin_start)) {
drflac__free_from_callbacks(pFlac, &allocationCallbacks);
@@ -83917,7 +86837,9 @@ static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac
}
#ifndef DR_FLAC_NO_STDIO
#include
+#ifndef DR_FLAC_NO_WCHAR
#include
+#endif
#include
static drflac_result drflac_result_from_errno(int e)
{
@@ -84361,6 +87283,7 @@ static drflac_result drflac_fopen(FILE** ppFile, const char* pFilePath, const ch
#define DRFLAC_HAS_WFOPEN
#endif
#endif
+#ifndef DR_FLAC_NO_WCHAR
static drflac_result drflac_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drflac_allocation_callbacks* pAllocationCallbacks)
{
if (ppFile != NULL) {
@@ -84385,6 +87308,10 @@ static drflac_result drflac_wfopen(FILE** ppFile, const wchar_t* pFilePath, cons
(void)pAllocationCallbacks;
}
#else
+ #if defined(__DJGPP__)
+ {
+ }
+ #else
{
mbstate_t mbs;
size_t lenMB;
@@ -84417,12 +87344,14 @@ static drflac_result drflac_wfopen(FILE** ppFile, const wchar_t* pFilePath, cons
*ppFile = fopen(pFilePathMB, pOpenModeMB);
drflac__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
}
+ #endif
if (*ppFile == NULL) {
return DRFLAC_ERROR;
}
#endif
return DRFLAC_SUCCESS;
}
+#endif
static size_t drflac__on_read_stdio(void* pUserData, void* bufferOut, size_t bytesToRead)
{
return fread(bufferOut, 1, bytesToRead, (FILE*)pUserData);
@@ -84446,6 +87375,7 @@ DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocati
}
return pFlac;
}
+#ifndef DR_FLAC_NO_WCHAR
DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
{
drflac* pFlac;
@@ -84460,6 +87390,7 @@ DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_all
}
return pFlac;
}
+#endif
DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
{
drflac* pFlac;
@@ -84474,6 +87405,7 @@ DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_
}
return pFlac;
}
+#ifndef DR_FLAC_NO_WCHAR
DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
{
drflac* pFlac;
@@ -84489,6 +87421,7 @@ DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, dr
return pFlac;
}
#endif
+#endif
static size_t drflac__on_read_memory(void* pUserData, void* bufferOut, size_t bytesToRead)
{
drflac__memory_stream* memoryStream = (drflac__memory_stream*)pUserData;
@@ -87201,7 +90134,7 @@ DRMP3_API const char* drmp3_version_string(void)
#if !defined(DR_MP3_ONLY_SIMD) && (defined(_M_X64) || defined(__x86_64__) || defined(__aarch64__) || defined(_M_ARM64))
#define DR_MP3_ONLY_SIMD
#endif
-#if ((defined(_MSC_VER) && _MSC_VER >= 1400) && (defined(_M_IX86) || defined(_M_X64))) || ((defined(__i386__) || defined(__x86_64__)) && defined(__SSE2__))
+#if ((defined(_MSC_VER) && _MSC_VER >= 1400) && defined(_M_X64)) || ((defined(__i386) || defined(_M_IX86) || defined(__i386__) || defined(__x86_64__)) && ((defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__)))
#if defined(_MSC_VER)
#include
#endif
@@ -87847,7 +90780,7 @@ static void drmp3_L3_huffman(float *dst, drmp3_bs *bs, const drmp3_L3_gr_info *g
static const drmp3_uint8 tab33[] = { 252,236,220,204,188,172,156,140,124,108,92,76,60,44,28,12 };
static const drmp3_int16 tabindex[2*16] = { 0,32,64,98,0,132,180,218,292,364,426,538,648,746,0,1126,1460,1460,1460,1460,1460,1460,1460,1460,1842,1842,1842,1842,1842,1842,1842,1842 };
static const drmp3_uint8 g_linbits[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,6,8,10,13,4,5,6,7,8,9,11,13 };
-#define DRMP3_PEEK_BITS(n) (bs_cache >> (32 - n))
+#define DRMP3_PEEK_BITS(n) (bs_cache >> (32 - (n)))
#define DRMP3_FLUSH_BITS(n) { bs_cache <<= (n); bs_sh += (n); }
#define DRMP3_CHECK_BITS while (bs_sh >= 0) { bs_cache |= (drmp3_uint32)*bs_next_ptr++ << bs_sh; bs_sh -= 8; }
#define DRMP3_BSPOS ((bs_next_ptr - bs->buf)*8 - 24 + bs_sh)
@@ -88363,7 +91296,7 @@ static void drmp3d_DCT_II(float *grbuf, int n)
#if DRMP3_HAVE_SSE
#define DRMP3_VSAVE2(i, v) _mm_storel_pi((__m64 *)(void*)&y[i*18], v)
#else
-#define DRMP3_VSAVE2(i, v) vst1_f32((float32_t *)&y[i*18], vget_low_f32(v))
+#define DRMP3_VSAVE2(i, v) vst1_f32((float32_t *)&y[(i)*18], vget_low_f32(v))
#endif
for (i = 0; i < 7; i++, y += 4*18)
{
@@ -88379,7 +91312,7 @@ static void drmp3d_DCT_II(float *grbuf, int n)
DRMP3_VSAVE2(3, t[3][7]);
} else
{
-#define DRMP3_VSAVE4(i, v) DRMP3_VSTORE(&y[i*18], v)
+#define DRMP3_VSAVE4(i, v) DRMP3_VSTORE(&y[(i)*18], v)
for (i = 0; i < 7; i++, y += 4*18)
{
drmp3_f4 s = DRMP3_VADD(t[3][i], t[3][i + 1]);
@@ -88879,7 +91812,7 @@ DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num
#endif
#define DRMP3_MIN_DATA_CHUNK_SIZE 16384
#ifndef DRMP3_DATA_CHUNK_SIZE
-#define DRMP3_DATA_CHUNK_SIZE DRMP3_MIN_DATA_CHUNK_SIZE*4
+#define DRMP3_DATA_CHUNK_SIZE (DRMP3_MIN_DATA_CHUNK_SIZE*4)
#endif
#define DRMP3_COUNTOF(x) (sizeof(x) / sizeof(x[0]))
#define DRMP3_CLAMP(x, lo, hi) (DRMP3_MAX(lo, DRMP3_MIN(x, hi)))
@@ -89711,6 +92644,10 @@ static drmp3_result drmp3_wfopen(FILE** ppFile, const wchar_t* pFilePath, const
(void)pAllocationCallbacks;
}
#else
+ #if defined(__DJGPP__)
+ {
+ }
+ #else
{
mbstate_t mbs;
size_t lenMB;
@@ -89743,6 +92680,7 @@ static drmp3_result drmp3_wfopen(FILE** ppFile, const wchar_t* pFilePath, const
*ppFile = fopen(pFilePathMB, pOpenModeMB);
drmp3__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
}
+ #endif
if (*ppFile == NULL) {
return DRMP3_ERROR;
}
@@ -90444,7 +93382,7 @@ For more information, please refer to
===============================================================================
ALTERNATIVE 2 - MIT No Attribution
===============================================================================
-Copyright 2020 David Reid
+Copyright 2023 David Reid
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
diff --git a/src/external/qoa.h b/src/external/qoa.h
new file mode 100644
index 000000000..59d90aded
--- /dev/null
+++ b/src/external/qoa.h
@@ -0,0 +1,660 @@
+/*
+
+Copyright (c) 2023, Dominic Szablewski - https://phoboslab.org
+SPDX-License-Identifier: MIT
+
+QOA - The "Quite OK Audio" format for fast, lossy audio compression
+
+
+-- Data Format
+
+A QOA file has an 8 byte file header, followed by a number of frames. Each frame
+consists of an 8 byte frame header, the current 8 byte en-/decoder state per
+channel and 256 slices per channel. Each slice is 8 bytes wide and encodes 20
+samples of audio data.
+
+Note that the last frame of a file may contain less than 256 slices per channel.
+The last slice (per channel) in the last frame may contain less 20 samples, but
+the slice will still be 8 bytes wide, with the unused samples zeroed out.
+
+The samplerate and number of channels is only stated in the frame headers, but
+not in the file header. A decoder may peek into the first frame of the file to
+find these values.
+
+In a valid QOA file all frames have the same number of channels and the same
+samplerate. These restrictions may be relaxed for streaming. This remains to
+be decided.
+
+All values in a QOA file are BIG ENDIAN. Luckily, EVERYTHING in a QOA file,
+including the headers, is 64 bit aligned, so it's possible to read files with
+just a read_u64() that does the byte swapping if necessary.
+
+In pseudocode, the file layout is as follows:
+
+struct {
+ struct {
+ char magic[4]; // magic bytes 'qoaf'
+ uint32_t samples; // number of samples per channel in this file
+ } file_header; // = 64 bits
+
+ struct {
+ struct {
+ uint8_t num_channels; // number of channels
+ uint24_t samplerate; // samplerate in hz
+ uint16_t fsamples; // sample count per channel in this frame
+ uint16_t fsize; // frame size (including the frame header)
+ } frame_header; // = 64 bits
+
+ struct {
+ int16_t history[4]; // = 64 bits
+ int16_t weights[4]; // = 64 bits
+ } lms_state[num_channels];
+
+ qoa_slice_t slices[256][num_channels]; // = 64 bits each
+ } frames[samples * channels / qoa_max_framesize()];
+} qoa_file;
+
+Wheras the 64bit qoa_slice_t is defined as follows:
+
+.- QOA_SLICE -- 64 bits, 20 samples --------------------------/ /------------.
+| Byte[0] | Byte[1] | Byte[2] \ \ Byte[7] |
+| 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 | 7 6 5 / / 2 1 0 |
+|------------+--------+--------+--------+---------+---------+-\ \--+---------|
+| sf_index | r00 | r01 | r02 | r03 | r04 | / / | r19 |
+`-------------------------------------------------------------\ \------------`
+
+`sf_index` defines the scalefactor to use for this slice as an index into the
+qoa_scalefactor_tab[16]
+
+`r00`--`r19` are the residuals for the individual samples, divided by the
+scalefactor and quantized by the qoa_quant_tab[].
+
+In the decoder, a prediction of the next sample is computed by multiplying the
+state (the last four output samples) with the predictor. The residual from the
+slice is then dequantized using the qoa_dequant_tab[] and added to the
+prediction. The result is clamped to int16 to form the final output sample.
+
+*/
+
+
+
+/* -----------------------------------------------------------------------------
+ Header - Public functions */
+
+#ifndef QOA_H
+#define QOA_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define QOA_MIN_FILESIZE 16
+#define QOA_MAX_CHANNELS 8
+
+#define QOA_SLICE_LEN 20
+#define QOA_SLICES_PER_FRAME 256
+#define QOA_FRAME_LEN (QOA_SLICES_PER_FRAME * QOA_SLICE_LEN)
+#define QOA_LMS_LEN 4
+#define QOA_MAGIC 0x716f6166 /* 'qoaf' */
+
+#define QOA_FRAME_SIZE(channels, slices) \
+ (8 + QOA_LMS_LEN * 4 * channels + 8 * slices * channels)
+
+typedef struct {
+ int history[QOA_LMS_LEN];
+ int weights[QOA_LMS_LEN];
+} qoa_lms_t;
+
+typedef struct {
+ unsigned int channels;
+ unsigned int samplerate;
+ unsigned int samples;
+ qoa_lms_t lms[QOA_MAX_CHANNELS];
+ #ifdef QOA_RECORD_TOTAL_ERROR
+ double error;
+ #endif
+} qoa_desc;
+
+unsigned int qoa_encode_header(qoa_desc *qoa, unsigned char *bytes);
+unsigned int qoa_encode_frame(const short *sample_data, qoa_desc *qoa, unsigned int frame_len, unsigned char *bytes);
+void *qoa_encode(const short *sample_data, qoa_desc *qoa, unsigned int *out_len);
+
+unsigned int qoa_max_frame_size(qoa_desc *qoa);
+unsigned int qoa_decode_header(const unsigned char *bytes, int size, qoa_desc *qoa);
+unsigned int qoa_decode_frame(const unsigned char *bytes, unsigned int size, qoa_desc *qoa, short *sample_data, unsigned int *frame_len);
+short *qoa_decode(const unsigned char *bytes, int size, qoa_desc *file);
+
+#ifndef QOA_NO_STDIO
+
+int qoa_write(const char *filename, const short *sample_data, qoa_desc *qoa);
+void *qoa_read(const char *filename, qoa_desc *qoa);
+
+#endif /* QOA_NO_STDIO */
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* QOA_H */
+
+
+/* -----------------------------------------------------------------------------
+ Implementation */
+
+#ifdef QOA_IMPLEMENTATION
+#include
+
+#ifndef QOA_MALLOC
+ #define QOA_MALLOC(sz) malloc(sz)
+ #define QOA_FREE(p) free(p)
+#endif
+
+typedef unsigned long long qoa_uint64_t;
+
+
+/* The quant_tab provides an index into the dequant_tab for residuals in the
+range of -8 .. 8. It maps this range to just 3bits and becomes less accurate at
+the higher end. Note that the residual zero is identical to the lowest positive
+value. This is mostly fine, since the qoa_div() function always rounds away
+from zero. */
+
+static int qoa_quant_tab[17] = {
+ 7, 7, 7, 5, 5, 3, 3, 1, /* -8..-1 */
+ 0, /* 0 */
+ 0, 2, 2, 4, 4, 6, 6, 6 /* 1.. 8 */
+};
+
+
+/* We have 16 different scalefactors. Like the quantized residuals these become
+less accurate at the higher end. In theory, the highest scalefactor that we
+would need to encode the highest 16bit residual is (2**16)/8 = 8192. However we
+rely on the LMS filter to predict samples accurately enough that a maximum
+residual of one quarter of the 16 bit range is high sufficient. I.e. with the
+scalefactor 2048 times the quant range of 8 we can encode residuals up to 2**14.
+
+The scalefactor values are computed as:
+scalefactor_tab[s] <- round(pow(s + 1, 2.75)) */
+
+static int qoa_scalefactor_tab[16] = {
+ 1, 7, 21, 45, 84, 138, 211, 304, 421, 562, 731, 928, 1157, 1419, 1715, 2048
+};
+
+
+/* The reciprocal_tab maps each of the 16 scalefactors to their rounded
+reciprocals 1/scalefactor. This allows us to calculate the scaled residuals in
+the encoder with just one multiplication instead of an expensive division. We
+do this in .16 fixed point with integers, instead of floats.
+
+The reciprocal_tab is computed as:
+reciprocal_tab[s] <- ((1<<16) + scalefactor_tab[s] - 1) / scalefactor_tab[s] */
+
+static int qoa_reciprocal_tab[16] = {
+ 65536, 9363, 3121, 1457, 781, 475, 311, 216, 156, 117, 90, 71, 57, 47, 39, 32
+};
+
+
+/* The dequant_tab maps each of the scalefactors and quantized residuals to
+their unscaled & dequantized version.
+
+Since qoa_div rounds away from the zero, the smallest entries are mapped to 3/4
+instead of 1. The dequant_tab assumes the following dequantized values for each
+of the quant_tab indices and is computed as:
+float dqt[8] = {0.75, -0.75, 2.5, -2.5, 4.5, -4.5, 7, -7};
+dequant_tab[s][q] <- round(scalefactor_tab[s] * dqt[q]) */
+
+static int qoa_dequant_tab[16][8] = {
+ { 1, -1, 3, -3, 5, -5, 7, -7},
+ { 5, -5, 18, -18, 32, -32, 49, -49},
+ { 16, -16, 53, -53, 95, -95, 147, -147},
+ { 34, -34, 113, -113, 203, -203, 315, -315},
+ { 63, -63, 210, -210, 378, -378, 588, -588},
+ { 104, -104, 345, -345, 621, -621, 966, -966},
+ { 158, -158, 528, -528, 950, -950, 1477, -1477},
+ { 228, -228, 760, -760, 1368, -1368, 2128, -2128},
+ { 316, -316, 1053, -1053, 1895, -1895, 2947, -2947},
+ { 422, -422, 1405, -1405, 2529, -2529, 3934, -3934},
+ { 548, -548, 1828, -1828, 3290, -3290, 5117, -5117},
+ { 696, -696, 2320, -2320, 4176, -4176, 6496, -6496},
+ { 868, -868, 2893, -2893, 5207, -5207, 8099, -8099},
+ {1064, -1064, 3548, -3548, 6386, -6386, 9933, -9933},
+ {1286, -1286, 4288, -4288, 7718, -7718, 12005, -12005},
+ {1536, -1536, 5120, -5120, 9216, -9216, 14336, -14336},
+};
+
+
+/* The Least Mean Squares Filter is the heart of QOA. It predicts the next
+sample based on the previous 4 reconstructed samples. It does so by continuously
+adjusting 4 weights based on the residual of the previous prediction.
+
+The next sample is predicted as the sum of (weight[i] * history[i]).
+
+The adjustment of the weights is done with a "Sign-Sign-LMS" that adds or
+subtracts the residual to each weight, based on the corresponding sample from
+the history. This, surprisingly, is sufficient to get worthwhile predictions.
+
+This is all done with fixed point integers. Hence the right-shifts when updating
+the weights and calculating the prediction. */
+
+static int qoa_lms_predict(qoa_lms_t *lms) {
+ int prediction = 0;
+ for (int i = 0; i < QOA_LMS_LEN; i++) {
+ prediction += lms->weights[i] * lms->history[i];
+ }
+ return prediction >> 13;
+}
+
+static void qoa_lms_update(qoa_lms_t *lms, int sample, int residual) {
+ int delta = residual >> 4;
+ for (int i = 0; i < QOA_LMS_LEN; i++) {
+ lms->weights[i] += lms->history[i] < 0 ? -delta : delta;
+ }
+
+ for (int i = 0; i < QOA_LMS_LEN-1; i++) {
+ lms->history[i] = lms->history[i+1];
+ }
+ lms->history[QOA_LMS_LEN-1] = sample;
+}
+
+
+/* qoa_div() implements a rounding division, but avoids rounding to zero for
+small numbers. E.g. 0.1 will be rounded to 1. Note that 0 itself still
+returns as 0, which is handled in the qoa_quant_tab[].
+qoa_div() takes an index into the .16 fixed point qoa_reciprocal_tab as an
+argument, so it can do the division with a cheaper integer multiplication. */
+
+static inline int qoa_div(int v, int scalefactor) {
+ int reciprocal = qoa_reciprocal_tab[scalefactor];
+ int n = (v * reciprocal + (1 << 15)) >> 16;
+ n = n + ((v > 0) - (v < 0)) - ((n > 0) - (n < 0)); /* round away from 0 */
+ return n;
+}
+
+static inline int qoa_clamp(int v, int min, int max) {
+ return (v < min) ? min : (v > max) ? max : v;
+}
+
+static inline qoa_uint64_t qoa_read_u64(const unsigned char *bytes, unsigned int *p) {
+ bytes += *p;
+ *p += 8;
+ return
+ ((qoa_uint64_t)(bytes[0]) << 56) | ((qoa_uint64_t)(bytes[1]) << 48) |
+ ((qoa_uint64_t)(bytes[2]) << 40) | ((qoa_uint64_t)(bytes[3]) << 32) |
+ ((qoa_uint64_t)(bytes[4]) << 24) | ((qoa_uint64_t)(bytes[5]) << 16) |
+ ((qoa_uint64_t)(bytes[6]) << 8) | ((qoa_uint64_t)(bytes[7]) << 0);
+}
+
+static inline void qoa_write_u64(qoa_uint64_t v, unsigned char *bytes, unsigned int *p) {
+ bytes += *p;
+ *p += 8;
+ bytes[0] = (v >> 56) & 0xff;
+ bytes[1] = (v >> 48) & 0xff;
+ bytes[2] = (v >> 40) & 0xff;
+ bytes[3] = (v >> 32) & 0xff;
+ bytes[4] = (v >> 24) & 0xff;
+ bytes[5] = (v >> 16) & 0xff;
+ bytes[6] = (v >> 8) & 0xff;
+ bytes[7] = (v >> 0) & 0xff;
+}
+
+
+/* -----------------------------------------------------------------------------
+ Encoder */
+
+unsigned int qoa_encode_header(qoa_desc *qoa, unsigned char *bytes) {
+ unsigned int p = 0;
+ qoa_write_u64(((qoa_uint64_t)QOA_MAGIC << 32) | qoa->samples, bytes, &p);
+ return p;
+}
+
+unsigned int qoa_encode_frame(const short *sample_data, qoa_desc *qoa, unsigned int frame_len, unsigned char *bytes) {
+ unsigned int channels = qoa->channels;
+
+ unsigned int p = 0;
+ unsigned int slices = (frame_len + QOA_SLICE_LEN - 1) / QOA_SLICE_LEN;
+ unsigned int frame_size = QOA_FRAME_SIZE(channels, slices);
+
+ /* Write the frame header */
+ qoa_write_u64((
+ (qoa_uint64_t)qoa->channels << 56 |
+ (qoa_uint64_t)qoa->samplerate << 32 |
+ (qoa_uint64_t)frame_len << 16 |
+ (qoa_uint64_t)frame_size
+ ), bytes, &p);
+
+ /* Write the current LMS state */
+ for (int c = 0; c < channels; c++) {
+ qoa_uint64_t weights = 0;
+ qoa_uint64_t history = 0;
+ for (int i = 0; i < QOA_LMS_LEN; i++) {
+ history = (history << 16) | (qoa->lms[c].history[i] & 0xffff);
+ weights = (weights << 16) | (qoa->lms[c].weights[i] & 0xffff);
+ }
+ qoa_write_u64(history, bytes, &p);
+ qoa_write_u64(weights, bytes, &p);
+ }
+
+ /* We encode all samples with the channels interleaved on a slice level.
+ E.g. for stereo: (ch-0, slice 0), (ch 1, slice 0), (ch 0, slice 1), ...*/
+ for (int sample_index = 0; sample_index < frame_len; sample_index += QOA_SLICE_LEN) {
+
+ for (int c = 0; c < channels; c++) {
+ int slice_len = qoa_clamp(QOA_SLICE_LEN, 0, frame_len - sample_index);
+ int slice_start = sample_index * channels + c;
+ int slice_end = (sample_index + slice_len) * channels + c;
+
+ /* Brute for search for the best scalefactor. Just go through all
+ 16 scalefactors, encode all samples for the current slice and
+ meassure the total squared error. */
+ qoa_uint64_t best_error = -1;
+ qoa_uint64_t best_slice;
+ qoa_lms_t best_lms;
+
+ for (int scalefactor = 0; scalefactor < 16; scalefactor++) {
+
+ /* We have to reset the LMS state to the last known good one
+ before trying each scalefactor, as each pass updates the LMS
+ state when encoding. */
+ qoa_lms_t lms = qoa->lms[c];
+ qoa_uint64_t slice = scalefactor;
+ qoa_uint64_t current_error = 0;
+
+ for (int si = slice_start; si < slice_end; si += channels) {
+ int sample = sample_data[si];
+ int predicted = qoa_lms_predict(&lms);
+
+ int residual = sample - predicted;
+ int scaled = qoa_div(residual, scalefactor);
+ int clamped = qoa_clamp(scaled, -8, 8);
+ int quantized = qoa_quant_tab[clamped + 8];
+ int dequantized = qoa_dequant_tab[scalefactor][quantized];
+ int reconstructed = qoa_clamp(predicted + dequantized, -32768, 32767);
+
+ long long error = (sample - reconstructed);
+ current_error += error * error;
+ if (current_error > best_error) {
+ break;
+ }
+
+ qoa_lms_update(&lms, reconstructed, dequantized);
+ slice = (slice << 3) | quantized;
+ }
+
+ if (current_error < best_error) {
+ best_error = current_error;
+ best_slice = slice;
+ best_lms = lms;
+ }
+ }
+
+ qoa->lms[c] = best_lms;
+ #ifdef QOA_RECORD_TOTAL_ERROR
+ qoa->error += best_error;
+ #endif
+
+ /* If this slice was shorter than QOA_SLICE_LEN, we have to left-
+ shift all encoded data, to ensure the rightmost bits are the empty
+ ones. This should only happen in the last frame of a file as all
+ slices are completely filled otherwise. */
+ best_slice <<= (QOA_SLICE_LEN - slice_len) * 3;
+ qoa_write_u64(best_slice, bytes, &p);
+ }
+ }
+
+ return p;
+}
+
+void *qoa_encode(const short *sample_data, qoa_desc *qoa, unsigned int *out_len) {
+ if (
+ qoa->samples == 0 ||
+ qoa->samplerate == 0 || qoa->samplerate > 0xffffff ||
+ qoa->channels == 0 || qoa->channels > QOA_MAX_CHANNELS
+ ) {
+ return NULL;
+ }
+
+ /* Calculate the encoded size and allocate */
+ unsigned int num_frames = (qoa->samples + QOA_FRAME_LEN-1) / QOA_FRAME_LEN;
+ unsigned int num_slices = (qoa->samples + QOA_SLICE_LEN-1) / QOA_SLICE_LEN;
+ unsigned int encoded_size = 8 + /* 8 byte file header */
+ num_frames * 8 + /* 8 byte frame headers */
+ num_frames * QOA_LMS_LEN * 4 * qoa->channels + /* 4 * 4 bytes lms state per channel */
+ num_slices * 8 * qoa->channels; /* 8 byte slices */
+
+ unsigned char *bytes = QOA_MALLOC(encoded_size);
+
+ for (int c = 0; c < qoa->channels; c++) {
+ /* Set the initial LMS weights to {0, 0, -1, 2}. This helps with the
+ prediction of the first few ms of a file. */
+ qoa->lms[c].weights[0] = 0;
+ qoa->lms[c].weights[1] = 0;
+ qoa->lms[c].weights[2] = -(1<<13);
+ qoa->lms[c].weights[3] = (1<<14);
+
+ /* Explicitly set the history samples to 0, as we might have some
+ garbage in there. */
+ for (int i = 0; i < QOA_LMS_LEN; i++) {
+ qoa->lms[c].history[i] = 0;
+ }
+ }
+
+
+ /* Encode the header and go through all frames */
+ unsigned int p = qoa_encode_header(qoa, bytes);
+ #ifdef QOA_RECORD_TOTAL_ERROR
+ qoa->error = 0;
+ #endif
+
+ int frame_len = QOA_FRAME_LEN;
+ for (int sample_index = 0; sample_index < qoa->samples; sample_index += frame_len) {
+ frame_len = qoa_clamp(QOA_FRAME_LEN, 0, qoa->samples - sample_index);
+ const short *frame_samples = sample_data + sample_index * qoa->channels;
+ unsigned int frame_size = qoa_encode_frame(frame_samples, qoa, frame_len, bytes + p);
+ p += frame_size;
+ }
+
+ *out_len = p;
+ return bytes;
+}
+
+
+
+/* -----------------------------------------------------------------------------
+ Decoder */
+
+unsigned int qoa_max_frame_size(qoa_desc *qoa) {
+ return QOA_FRAME_SIZE(qoa->channels, QOA_SLICES_PER_FRAME);
+}
+
+unsigned int qoa_decode_header(const unsigned char *bytes, int size, qoa_desc *qoa) {
+ unsigned int p = 0;
+ if (size < QOA_MIN_FILESIZE) {
+ return 0;
+ }
+
+
+ /* Read the file header, verify the magic number ('qoaf') and read the
+ total number of samples. */
+ qoa_uint64_t file_header = qoa_read_u64(bytes, &p);
+
+ if ((file_header >> 32) != QOA_MAGIC) {
+ return 0;
+ }
+
+ qoa->samples = file_header & 0xffffffff;
+ if (!qoa->samples) {
+ return 0;
+ }
+
+ /* Peek into the first frame header to get the number of channels and
+ the samplerate. */
+ qoa_uint64_t frame_header = qoa_read_u64(bytes, &p);
+ qoa->channels = (frame_header >> 56) & 0x0000ff;
+ qoa->samplerate = (frame_header >> 32) & 0xffffff;
+
+ if (qoa->channels == 0 || qoa->samples == 0 || qoa->samplerate == 0) {
+ return 0;
+ }
+
+ return 8;
+}
+
+unsigned int qoa_decode_frame(const unsigned char *bytes, unsigned int size, qoa_desc *qoa, short *sample_data, unsigned int *frame_len) {
+ unsigned int p = 0;
+ *frame_len = 0;
+
+ if (size < 8 + QOA_LMS_LEN * 4 * qoa->channels) {
+ return 0;
+ }
+
+ /* Read and verify the frame header */
+ qoa_uint64_t frame_header = qoa_read_u64(bytes, &p);
+ int channels = (frame_header >> 56) & 0x0000ff;
+ int samplerate = (frame_header >> 32) & 0xffffff;
+ int samples = (frame_header >> 16) & 0x00ffff;
+ int frame_size = (frame_header ) & 0x00ffff;
+
+ int data_size = frame_size - 8 - QOA_LMS_LEN * 4 * channels;
+ int num_slices = data_size / 8;
+ int max_total_samples = num_slices * QOA_SLICE_LEN;
+
+ if (
+ channels != qoa->channels ||
+ samplerate != qoa->samplerate ||
+ frame_size > size ||
+ samples * channels > max_total_samples
+ ) {
+ return 0;
+ }
+
+
+ /* Read the LMS state: 4 x 2 bytes history, 4 x 2 bytes weights per channel */
+ for (int c = 0; c < channels; c++) {
+ qoa_uint64_t history = qoa_read_u64(bytes, &p);
+ qoa_uint64_t weights = qoa_read_u64(bytes, &p);
+ for (int i = 0; i < QOA_LMS_LEN; i++) {
+ qoa->lms[c].history[i] = ((signed short)(history >> 48));
+ history <<= 16;
+ qoa->lms[c].weights[i] = ((signed short)(weights >> 48));
+ weights <<= 16;
+ }
+ }
+
+
+ /* Decode all slices for all channels in this frame */
+ for (int sample_index = 0; sample_index < samples; sample_index += QOA_SLICE_LEN) {
+ for (int c = 0; c < channels; c++) {
+ qoa_uint64_t slice = qoa_read_u64(bytes, &p);
+
+ int scalefactor = (slice >> 60) & 0xf;
+ int slice_start = sample_index * channels + c;
+ int slice_end = qoa_clamp(sample_index + QOA_SLICE_LEN, 0, samples) * channels + c;
+
+ for (int si = slice_start; si < slice_end; si += channels) {
+ int predicted = qoa_lms_predict(&qoa->lms[c]);
+ int quantized = (slice >> 57) & 0x7;
+ int dequantized = qoa_dequant_tab[scalefactor][quantized];
+ int reconstructed = qoa_clamp(predicted + dequantized, -32768, 32767);
+
+ sample_data[si] = reconstructed;
+ slice <<= 3;
+
+ qoa_lms_update(&qoa->lms[c], reconstructed, dequantized);
+ }
+ }
+ }
+
+ *frame_len = samples;
+ return p;
+}
+
+short *qoa_decode(const unsigned char *bytes, int size, qoa_desc *qoa) {
+ unsigned int p = qoa_decode_header(bytes, size, qoa);
+ if (!p) {
+ return NULL;
+ }
+
+ /* Calculate the required size of the sample buffer and allocate */
+ int total_samples = qoa->samples * qoa->channels;
+ short *sample_data = QOA_MALLOC(total_samples * sizeof(short));
+
+ unsigned int sample_index = 0;
+ unsigned int frame_len;
+ unsigned int frame_size;
+
+ /* Decode all frames */
+ do {
+ short *sample_ptr = sample_data + sample_index * qoa->channels;
+ frame_size = qoa_decode_frame(bytes + p, size - p, qoa, sample_ptr, &frame_len);
+
+ p += frame_size;
+ sample_index += frame_len;
+ } while (frame_size && sample_index < qoa->samples);
+
+ qoa->samples = sample_index;
+ return sample_data;
+}
+
+
+
+/* -----------------------------------------------------------------------------
+ File read/write convenience functions */
+
+#ifndef QOA_NO_STDIO
+#include
+
+int qoa_write(const char *filename, const short *sample_data, qoa_desc *qoa) {
+ FILE *f = fopen(filename, "wb");
+ unsigned int size;
+ void *encoded;
+
+ if (!f) {
+ return 0;
+ }
+
+ encoded = qoa_encode(sample_data, qoa, &size);
+ if (!encoded) {
+ fclose(f);
+ return 0;
+ }
+
+ fwrite(encoded, 1, size, f);
+ fclose(f);
+
+ QOA_FREE(encoded);
+ return size;
+}
+
+void *qoa_read(const char *filename, qoa_desc *qoa) {
+ FILE *f = fopen(filename, "rb");
+ int size, bytes_read;
+ void *data;
+ short *sample_data;
+
+ if (!f) {
+ return NULL;
+ }
+
+ fseek(f, 0, SEEK_END);
+ size = ftell(f);
+ if (size <= 0) {
+ fclose(f);
+ return NULL;
+ }
+ fseek(f, 0, SEEK_SET);
+
+ data = QOA_MALLOC(size);
+ if (!data) {
+ fclose(f);
+ return NULL;
+ }
+
+ bytes_read = fread(data, 1, size, f);
+ fclose(f);
+
+ sample_data = qoa_decode(data, bytes_read, qoa);
+ QOA_FREE(data);
+ return sample_data;
+}
+
+#endif /* QOA_NO_STDIO */
+#endif /* QOA_IMPLEMENTATION */
diff --git a/src/external/qoaplay.c b/src/external/qoaplay.c
new file mode 100644
index 000000000..7f937f4fa
--- /dev/null
+++ b/src/external/qoaplay.c
@@ -0,0 +1,278 @@
+/*******************************************************************************************
+*
+* qoaplay - QOA stream playing helper functions
+*
+* qoaplay is a tiny abstraction to read and decode a QOA file "on the fly".
+* It reads and decodes one frame at a time with minimal memory requirements.
+* qoaplay also provides some functions to seek to a specific frame.
+*
+* LICENSE: MIT License
+*
+* Copyright (c) 2023 Dominic Szablewski (@phoboslab), reviewed by Ramon Santamaria (@raysan5)
+*
+* 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.
+*
+**********************************************************************************************/
+
+//----------------------------------------------------------------------------------
+// Types and Structures Definition
+//----------------------------------------------------------------------------------
+// QOA streaming data descriptor
+typedef struct {
+ qoa_desc info; // QOA descriptor data
+
+ FILE *file; // QOA file to read, if NULL, using memory buffer -> file_data
+ unsigned char *file_data; // QOA file data on memory
+ unsigned int file_data_size; // QOA file data on memory size
+ unsigned int file_data_offset; // QOA file data on memory offset for next read
+
+ unsigned int first_frame_pos; // First frame position (after QOA header, required for offset)
+ unsigned int sample_position; // Current streaming sample position
+
+ unsigned char *buffer; // Buffer used to read samples from file/memory (used on decoding)
+ unsigned int buffer_len; // Buffer length to read samples for streaming
+
+ short *sample_data; // Sample data decoded
+ unsigned int sample_data_len; // Sample data decoded length
+ unsigned int sample_data_pos; // Sample data decoded position
+
+} qoaplay_desc;
+
+//----------------------------------------------------------------------------------
+// Module Functions Declaration
+//----------------------------------------------------------------------------------
+
+#if defined(__cplusplus)
+extern "C" { // Prevents name mangling of functions
+#endif
+
+qoaplay_desc *qoaplay_open(const char *path);
+qoaplay_desc *qoaplay_open_memory(const unsigned char *data, int data_size);
+void qoaplay_close(qoaplay_desc *qoa_ctx);
+
+void qoaplay_rewind(qoaplay_desc *qoa_ctx);
+void qoaplay_seek_frame(qoaplay_desc *qoa_ctx, int frame);
+unsigned int qoaplay_decode(qoaplay_desc *qoa_ctx, float *sample_data, int num_samples);
+unsigned int qoaplay_decode_frame(qoaplay_desc *qoa_ctx);
+double qoaplay_get_duration(qoaplay_desc *qoa_ctx);
+double qoaplay_get_time(qoaplay_desc *qoa_ctx);
+int qoaplay_get_frame(qoaplay_desc *qoa_ctx);
+
+#if defined(__cplusplus)
+} // Prevents name mangling of functions
+#endif
+
+//----------------------------------------------------------------------------------
+// Module Functions Definition
+//----------------------------------------------------------------------------------
+
+// Open QOA file, keep FILE pointer to keep reading from file
+qoaplay_desc *qoaplay_open(const char *path)
+{
+ FILE *file = fopen(path, "rb");
+ if (!file) return NULL;
+
+ // Read and decode the file header
+ unsigned char header[QOA_MIN_FILESIZE];
+ int read = fread(header, QOA_MIN_FILESIZE, 1, file);
+ if (!read) return NULL;
+
+ qoa_desc qoa;
+ unsigned int first_frame_pos = qoa_decode_header(header, QOA_MIN_FILESIZE, &qoa);
+ if (!first_frame_pos) return NULL;
+
+ // Rewind the file back to beginning of the first frame
+ fseek(file, first_frame_pos, SEEK_SET);
+
+ // Allocate one chunk of memory for the qoaplay_desc struct
+ // + the sample data for one frame
+ // + a buffer to hold one frame of encoded data
+ unsigned int buffer_size = qoa_max_frame_size(&qoa);
+ unsigned int sample_data_size = qoa.channels*QOA_FRAME_LEN*sizeof(short)*2;
+ qoaplay_desc *qoa_ctx = QOA_MALLOC(sizeof(qoaplay_desc) + buffer_size + sample_data_size);
+ memset(qoa_ctx, 0, sizeof(qoaplay_desc));
+
+ qoa_ctx->file = file;
+ qoa_ctx->file_data = NULL;
+ qoa_ctx->file_data_size = 0;
+ qoa_ctx->file_data_offset = 0;
+ qoa_ctx->first_frame_pos = first_frame_pos;
+
+ // Setup data pointers to previously allocated data
+ qoa_ctx->buffer = ((unsigned char *)qoa_ctx) + sizeof(qoaplay_desc);
+ qoa_ctx->sample_data = (short *)(((unsigned char *)qoa_ctx) + sizeof(qoaplay_desc) + buffer_size);
+
+ qoa_ctx->info.channels = qoa.channels;
+ qoa_ctx->info.samplerate = qoa.samplerate;
+ qoa_ctx->info.samples = qoa.samples;
+
+ return qoa_ctx;
+}
+
+// Open QOA file from memory, no FILE pointer required
+qoaplay_desc *qoaplay_open_memory(const unsigned char *data, int data_size)
+{
+ // Read and decode the file header
+ unsigned char header[QOA_MIN_FILESIZE];
+ memcpy(header, data, QOA_MIN_FILESIZE);
+
+ qoa_desc qoa;
+ unsigned int first_frame_pos = qoa_decode_header(header, QOA_MIN_FILESIZE, &qoa);
+ if (!first_frame_pos) return NULL;
+
+ // Allocate one chunk of memory for the qoaplay_desc struct
+ // + the sample data for one frame
+ // + a buffer to hold one frame of encoded data
+ unsigned int buffer_size = qoa_max_frame_size(&qoa);
+ unsigned int sample_data_size = qoa.channels*QOA_FRAME_LEN*sizeof(short)*2;
+ qoaplay_desc *qoa_ctx = QOA_MALLOC(sizeof(qoaplay_desc) + buffer_size + sample_data_size);
+ memset(qoa_ctx, 0, sizeof(qoaplay_desc));
+
+ qoa_ctx->file = NULL;
+
+ // Keep a copy of file data provided to be managed internally
+ qoa_ctx->file_data = (unsigned char *)QOA_MALLOC(data_size);
+ memcpy(qoa_ctx->file_data, data, data_size);
+ qoa_ctx->file_data_size = data_size;
+ qoa_ctx->file_data_offset = 0;
+ qoa_ctx->first_frame_pos = first_frame_pos;
+
+ // Setup data pointers to previously allocated data
+ qoa_ctx->buffer = ((unsigned char *)qoa_ctx) + sizeof(qoaplay_desc);
+ qoa_ctx->sample_data = (short *)(((unsigned char *)qoa_ctx) + sizeof(qoaplay_desc) + buffer_size);
+
+ qoa_ctx->info.channels = qoa.channels;
+ qoa_ctx->info.samplerate = qoa.samplerate;
+ qoa_ctx->info.samples = qoa.samples;
+
+ return qoa_ctx;
+}
+
+// Close QOA file (if open) and free internal memory
+void qoaplay_close(qoaplay_desc *qoa_ctx)
+{
+ if (qoa_ctx->file) fclose(qoa_ctx->file);
+
+ if ((qoa_ctx->file_data) && (qoa_ctx->file_data_size > 0))
+ {
+ QOA_FREE(qoa_ctx->file_data);
+ qoa_ctx->file_data_size = 0;
+ }
+
+ QOA_FREE(qoa_ctx);
+}
+
+// Decode one frame from QOA data
+unsigned int qoaplay_decode_frame(qoaplay_desc *qoa_ctx)
+{
+ if (qoa_ctx->file) qoa_ctx->buffer_len = fread(qoa_ctx->buffer, 1, qoa_max_frame_size(&qoa_ctx->info), qoa_ctx->file);
+ else
+ {
+ qoa_ctx->buffer_len = qoa_max_frame_size(&qoa_ctx->info);
+ memcpy(qoa_ctx->buffer, qoa_ctx->file_data + qoa_ctx->file_data_offset, qoa_ctx->buffer_len);
+ qoa_ctx->file_data_offset += qoa_ctx->buffer_len;
+ }
+
+ unsigned int frame_len;
+ qoa_decode_frame(qoa_ctx->buffer, qoa_ctx->buffer_len, &qoa_ctx->info, qoa_ctx->sample_data, &frame_len);
+ qoa_ctx->sample_data_pos = 0;
+ qoa_ctx->sample_data_len = frame_len;
+
+ return frame_len;
+}
+
+// Rewind QOA file or memory pointer to beginning
+void qoaplay_rewind(qoaplay_desc *qoa_ctx)
+{
+ if (qoa_ctx->file) fseek(qoa_ctx->file, qoa_ctx->first_frame_pos, SEEK_SET);
+ else qoa_ctx->file_data_offset = 0;
+
+ qoa_ctx->sample_position = 0;
+ qoa_ctx->sample_data_len = 0;
+ qoa_ctx->sample_data_pos = 0;
+}
+
+// Decode required QOA frames
+unsigned int qoaplay_decode(qoaplay_desc *qoa_ctx, float *sample_data, int num_samples)
+{
+ int src_index = qoa_ctx->sample_data_pos*qoa_ctx->info.channels;
+ int dst_index = 0;
+
+ for (int i = 0; i < num_samples; i++)
+ {
+ // Do we have to decode more samples?
+ if (qoa_ctx->sample_data_len - qoa_ctx->sample_data_pos == 0)
+ {
+ if (!qoaplay_decode_frame(qoa_ctx))
+ {
+ // Loop to the beginning
+ qoaplay_rewind(qoa_ctx);
+ qoaplay_decode_frame(qoa_ctx);
+ }
+
+ src_index = 0;
+ }
+
+ // Normalize to -1..1 floats and write to dest
+ for (int c = 0; c < qoa_ctx->info.channels; c++)
+ {
+ sample_data[dst_index++] = qoa_ctx->sample_data[src_index++]/32768.0;
+ }
+
+ qoa_ctx->sample_data_pos++;
+ qoa_ctx->sample_position++;
+ }
+
+ return num_samples;
+}
+
+// Get QOA total time duration in seconds
+double qoaplay_get_duration(qoaplay_desc *qoa_ctx)
+{
+ return (double)qoa_ctx->info.samples/(double)qoa_ctx->info.samplerate;
+}
+
+// Get QOA current time position in seconds
+double qoaplay_get_time(qoaplay_desc *qoa_ctx)
+{
+ return (double)qoa_ctx->sample_position/(double)qoa_ctx->info.samplerate;
+}
+
+// Get QOA current audio frame
+int qoaplay_get_frame(qoaplay_desc *qoa_ctx)
+{
+ return qoa_ctx->sample_position/QOA_FRAME_LEN;
+}
+
+// Seek QOA audio frame
+void qoaplay_seek_frame(qoaplay_desc *qoa_ctx, int frame)
+{
+ if (frame < 0) frame = 0;
+
+ if (frame > qoa_ctx->info.samples/QOA_FRAME_LEN) frame = qoa_ctx->info.samples/QOA_FRAME_LEN;
+
+ qoa_ctx->sample_position = frame*QOA_FRAME_LEN;
+ qoa_ctx->sample_data_len = 0;
+ qoa_ctx->sample_data_pos = 0;
+
+ unsigned int offset = qoa_ctx->first_frame_pos + frame*qoa_max_frame_size(&qoa_ctx->info);
+
+ if (qoa_ctx->file) fseek(qoa_ctx->file, offset, SEEK_SET);
+ else qoa_ctx->file_data_offset = offset;
+}
diff --git a/src/external/qoi.h b/src/external/qoi.h
index 988f9edcb..6734ac46e 100644
--- a/src/external/qoi.h
+++ b/src/external/qoi.h
@@ -1,31 +1,11 @@
/*
+Copyright (c) 2021, Dominic Szablewski - https://phoboslab.org
+SPDX-License-Identifier: MIT
+
+
QOI - The "Quite OK Image" format for fast, lossless image compression
-Dominic Szablewski - https://phoboslab.org
-
-
--- LICENSE: The MIT License(MIT)
-
-Copyright(c) 2021 Dominic Szablewski
-
-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.
-
-
-- About
QOI encodes and decodes images in a lossless format. Compared to stb_image and
@@ -424,13 +404,12 @@ void *qoi_encode(const void *data, const qoi_desc *desc, int *out_len) {
channels = desc->channels;
for (px_pos = 0; px_pos < px_len; px_pos += channels) {
+ px.rgba.r = pixels[px_pos + 0];
+ px.rgba.g = pixels[px_pos + 1];
+ px.rgba.b = pixels[px_pos + 2];
+
if (channels == 4) {
- px = *(qoi_rgba_t *)(pixels + px_pos);
- }
- else {
- px.rgba.r = pixels[px_pos + 0];
- px.rgba.g = pixels[px_pos + 1];
- px.rgba.b = pixels[px_pos + 2];
+ px.rgba.a = pixels[px_pos + 3];
}
if (px.v == px_prev.v) {
@@ -598,13 +577,12 @@ void *qoi_decode(const void *data, int size, qoi_desc *desc, int channels) {
index[QOI_COLOR_HASH(px) % 64] = px;
}
+ pixels[px_pos + 0] = px.rgba.r;
+ pixels[px_pos + 1] = px.rgba.g;
+ pixels[px_pos + 2] = px.rgba.b;
+
if (channels == 4) {
- *(qoi_rgba_t*)(pixels + px_pos) = px;
- }
- else {
- pixels[px_pos + 0] = px.rgba.r;
- pixels[px_pos + 1] = px.rgba.g;
- pixels[px_pos + 2] = px.rgba.b;
+ pixels[px_pos + 3] = px.rgba.a;
}
}
diff --git a/src/external/rl_gputex.h b/src/external/rl_gputex.h
index 6d2e97b27..fa39fe29c 100644
--- a/src/external/rl_gputex.h
+++ b/src/external/rl_gputex.h
@@ -9,7 +9,7 @@
*
* Note that some file formats (DDS, PVR, KTX) also support uncompressed data storage.
* In those cases data is loaded uncompressed and format is returned.
-*
+*
* TODO:
* - Implement raylib function: rlGetGlTextureFormats(), required by rl_save_ktx_to_memory()
* - Review rl_load_ktx_from_memory() to support KTX v2.2 specs
@@ -477,10 +477,10 @@ int rl_save_ktx(const char *file_name, void *data, int width, int height, int fo
// Calculate file data_size required
int data_size = sizeof(ktx_header);
- for (int i = 0, width = width, height = height; i < mipmaps; i++)
+ for (int i = 0, w = width, h = height; i < mipmaps; i++)
{
- data_size += get_pixel_data_size(width, height, format);
- width /= 2; height /= 2;
+ data_size += get_pixel_data_size(w, h, format);
+ w /= 2; h /= 2;
}
unsigned char *file_data = RL_CALLOC(data_size, 1);
@@ -814,5 +814,4 @@ static int get_pixel_data_size(int width, int height, int format)
return data_size;
}
-
#endif // RL_GPUTEX_IMPLEMENTATION
diff --git a/src/external/sdefl.h b/src/external/sdefl.h
index 5db76763a..36015b95b 100644
--- a/src/external/sdefl.h
+++ b/src/external/sdefl.h
@@ -38,10 +38,10 @@ this file implementation in *one* C or C++ file to prevent collisions.
| zlib 1.2.11 -1 | 72 MB/s | 307 MB/s | 42298774 | 42.30 |
| zlib 1.2.11 -6 | 24 MB/s | 313 MB/s | 36548921 | 36.55 |
| zlib 1.2.11 -9 | 20 MB/s | 314 MB/s | 36475792 | 36.48 |
-| sdefl 1.0 -0 | 127 MB/s | 371 MB/s | 40004116 | 39.88 |
-| sdefl 1.0 -1 | 111 MB/s | 398 MB/s | 38940674 | 38.82 |
-| sdefl 1.0 -5 | 45 MB/s | 420 MB/s | 36577183 | 36.46 |
-| sdefl 1.0 -7 | 38 MB/s | 423 MB/s | 36523781 | 36.41 |
+| sdefl 1.0 -0 | 127 MB/s | 355 MB/s | 40004116 | 39.88 |
+| sdefl 1.0 -1 | 111 MB/s | 413 MB/s | 38940674 | 38.82 |
+| sdefl 1.0 -5 | 45 MB/s | 436 MB/s | 36577183 | 36.46 |
+| sdefl 1.0 -7 | 38 MB/s | 432 MB/s | 36523781 | 36.41 |
| libdeflate 1.3 -1 | 147 MB/s | 667 MB/s | 39597378 | 39.60 |
| libdeflate 1.3 -6 | 69 MB/s | 689 MB/s | 36648318 | 36.65 |
| libdeflate 1.3 -9 | 13 MB/s | 672 MB/s | 35197141 | 35.20 |
@@ -50,20 +50,20 @@ this file implementation in *one* C or C++ file to prevent collisions.
### Compression
Results on the [Silesia compression corpus](http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia):
-| File | Original | `sdefl 0` | `sdefl 5` | `sdefl 7` |
-| :------ | ---------: | -----------------: | ---------: | ----------: |
-| dickens | 10.192.446 | 4,260,187| 3,845,261| 3,833,657 |
-| mozilla | 51.220.480 | 20,774,706 | 19,607,009 | 19,565,867 |
-| mr | 9.970.564 | 3,860,531 | 3,673,460 | 3,665,627 |
-| nci | 33.553.445 | 4,030,283 | 3,094,526 | 3,006,075 |
-| ooffice | 6.152.192 | 3,320,063 | 3,186,373 | 3,183,815 |
-| osdb | 10.085.684 | 3,919,646 | 3,649,510 | 3,649,477 |
-| reymont | 6.627.202 | 2,263,378 | 1,857,588 | 1,827,237 |
-| samba | 21.606.400 | 6,121,797 | 5,462,670 | 5,450,762 |
-| sao | 7.251.944 | 5,612,421 | 5,485,380 | 5,481,765 |
-| webster | 41.458.703 | 13,972,648 | 12,059,432 | 11,991,421 |
-| xml | 5.345.280 | 886,620| 674,009 | 662,141 |
-| x-ray | 8.474.240 | 6,304,655 | 6,244,779 | 6,244,779 |
+| File | Original | `sdefl 0` | `sdefl 5` | `sdefl 7` |
+| --------| -----------| -------------| ---------- | ------------|
+| dickens | 10.192.446 | 4,260,187 | 3,845,261 | 3,833,657 |
+| mozilla | 51.220.480 | 20,774,706 | 19,607,009 | 19,565,867 |
+| mr | 9.970.564 | 3,860,531 | 3,673,460 | 3,665,627 |
+| nci | 33.553.445 | 4,030,283 | 3,094,526 | 3,006,075 |
+| ooffice | 6.152.192 | 3,320,063 | 3,186,373 | 3,183,815 |
+| osdb | 10.085.684 | 3,919,646 | 3,649,510 | 3,649,477 |
+| reymont | 6.627.202 | 2,263,378 | 1,857,588 | 1,827,237 |
+| samba | 21.606.400 | 6,121,797 | 5,462,670 | 5,450,762 |
+| sao | 7.251.944 | 5,612,421 | 5,485,380 | 5,481,765 |
+| webster | 41.458.703 | 13,972,648 | 12,059,432 | 11,991,421 |
+| xml | 5.345.280 | 886,620 | 674,009 | 662,141 |
+| x-ray | 8.474.240 | 6,304,655 | 6,244,779 | 6,244,779 |
## License
```
@@ -71,7 +71,7 @@ Results on the [Silesia compression corpus](http://sun.aei.polsl.pl/~sdeor/index
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
-Copyright (c) 2020 Micha Mettke
+Copyright (c) 2020-2023 Micha Mettke
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
@@ -125,7 +125,7 @@ extern "C" {
#define SDEFL_MIN_MATCH 4
#define SDEFL_BLK_MAX (256*1024)
-#define SDEFL_SEQ_SIZ ((SDEFL_BLK_MAX + SDEFL_MIN_MATCH)/SDEFL_MIN_MATCH)
+#define SDEFL_SEQ_SIZ ((SDEFL_BLK_MAX+2)/3)
#define SDEFL_SYM_MAX (288)
#define SDEFL_OFF_MAX (32)
@@ -185,6 +185,7 @@ extern int zsdeflate(struct sdefl *s, void *o, const void *i, int n, int lvl);
#define SDEFL_MAX_CODE_LEN (15)
#define SDEFL_SYM_BITS (10u)
#define SDEFL_SYM_MSK ((1u << SDEFL_SYM_BITS)-1u)
+#define SDEFL_RAW_BLK_SIZE (65535)
#define SDEFL_LIT_LEN_CODES (14)
#define SDEFL_OFF_CODES (15)
#define SDEFL_PRE_CODES (7)
@@ -192,6 +193,7 @@ extern int zsdeflate(struct sdefl *s, void *o, const void *i, int n, int lvl);
#define SDEFL_EOB (256)
#define sdefl_npow2(n) (1 << (sdefl_ilog2((n)-1) + 1))
+#define sdefl_div_round_up(n,d) (((n)+((d)-1))/(d))
static int
sdefl_ilog2(int n) {
@@ -438,12 +440,12 @@ sdefl_precode(struct sdefl_symcnt *cnt, unsigned *freqs, unsigned *items,
} while (run_start != total);
cnt->items = (int)(at - items);
}
-struct sdefl_match_codes {
+struct sdefl_match_codest {
int ls, lc;
int dc, dx;
};
static void
-sdefl_match_codes(struct sdefl_match_codes *cod, int dist, int len) {
+sdefl_match_codes(struct sdefl_match_codest *cod, int dist, int len) {
static const short dxmax[] = {0,6,12,24,48,96,192,384,768,1536,3072,6144,12288,24576};
static const unsigned char lslot[258+1] = {
0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12,
@@ -462,11 +464,53 @@ sdefl_match_codes(struct sdefl_match_codes *cod, int dist, int len) {
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 28
};
+ assert(len <= 258);
+ assert(dist <= 32768);
cod->ls = lslot[len];
cod->lc = 257 + cod->ls;
+ assert(cod->lc <= 285);
+
cod->dx = sdefl_ilog2(sdefl_npow2(dist) >> 2);
cod->dc = cod->dx ? ((cod->dx + 1) << 1) + (dist > dxmax[cod->dx]) : dist-1;
}
+enum sdefl_blk_type {
+ SDEFL_BLK_UCOMPR,
+ SDEFL_BLK_DYN
+};
+static enum sdefl_blk_type
+sdefl_blk_type(const struct sdefl *s, int blk_len, int pre_item_len,
+ const unsigned *pre_freq, const unsigned char *pre_len) {
+ static const unsigned char x_pre_bits[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
+ static const unsigned char x_len_bits[] = {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 const unsigned char x_off_bits[] = {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};
+
+ int dyn_cost = 0;
+ int fix_cost = 0;
+ int sym = 0;
+
+ dyn_cost += 5 + 5 + 4 + (3 * pre_item_len);
+ for (sym = 0; sym < SDEFL_PRE_MAX; sym++)
+ dyn_cost += pre_freq[sym] * (x_pre_bits[sym] + pre_len[sym]);
+ for (sym = 0; sym < 256; sym++)
+ dyn_cost += s->freq.lit[sym] * s->cod.len.lit[sym];
+ dyn_cost += s->cod.len.lit[SDEFL_EOB];
+ for (sym = 257; sym < 286; sym++)
+ dyn_cost += s->freq.lit[sym] * (x_len_bits[sym - 257] + s->cod.len.lit[sym]);
+ for (sym = 0; sym < 30; sym++)
+ dyn_cost += s->freq.off[sym] * (x_off_bits[sym] + s->cod.len.off[sym]);
+
+ fix_cost += 8*(5 * sdefl_div_round_up(blk_len, SDEFL_RAW_BLK_SIZE) + blk_len + 1 + 2);
+ return (dyn_cost < fix_cost) ? SDEFL_BLK_DYN : SDEFL_BLK_UCOMPR;
+}
+static void
+sdefl_put16(unsigned char **dst, unsigned short x) {
+ unsigned char *val = *dst;
+ val[0] = (unsigned char)(x & 0xff);
+ val[1] = (unsigned char)(x >> 8);
+ *dst = val + 2;
+}
static void
sdefl_match(unsigned char **dst, struct sdefl *s, int dist, int len) {
static const char lxn[] = {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};
@@ -475,7 +519,7 @@ sdefl_match(unsigned char **dst, struct sdefl *s, int dist, int len) {
static const short dmin[] = {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};
- struct sdefl_match_codes cod;
+ struct sdefl_match_codest cod;
sdefl_match_codes(&cod, dist, len);
sdefl_put(dst, s, (int)s->cod.word.lit[cod.lc], s->cod.len.lit[cod.lc]);
sdefl_put(dst, s, len - lmin[cod.ls], lxn[cod.ls]);
@@ -484,7 +528,8 @@ sdefl_match(unsigned char **dst, struct sdefl *s, int dist, int len) {
}
static void
sdefl_flush(unsigned char **dst, struct sdefl *s, int is_last,
- const unsigned char *in) {
+ const unsigned char *in, int blk_begin, int blk_end) {
+ int blk_len = blk_end - blk_begin;
int j, i = 0, item_cnt = 0;
struct sdefl_symcnt symcnt = {0};
unsigned codes[SDEFL_PRE_MAX];
@@ -494,41 +539,69 @@ sdefl_flush(unsigned char **dst, struct sdefl *s, int is_last,
static const unsigned char perm[SDEFL_PRE_MAX] = {16,17,18,0,8,7,9,6,10,5,11,
4,12,3,13,2,14,1,15};
- /* huffman codes */
+ /* calculate huffman codes */
s->freq.lit[SDEFL_EOB]++;
sdefl_huff(s->cod.len.lit, s->cod.word.lit, s->freq.lit, SDEFL_SYM_MAX, SDEFL_LIT_LEN_CODES);
sdefl_huff(s->cod.len.off, s->cod.word.off, s->freq.off, SDEFL_OFF_MAX, SDEFL_OFF_CODES);
sdefl_precode(&symcnt, freqs, items, s->cod.len.lit, s->cod.len.off);
sdefl_huff(lens, codes, freqs, SDEFL_PRE_MAX, SDEFL_PRE_CODES);
for (item_cnt = SDEFL_PRE_MAX; item_cnt > 4; item_cnt--) {
- if (lens[perm[item_cnt - 1]]) break;
+ if (lens[perm[item_cnt - 1]]){
+ break;
+ }
}
- /* block header */
- sdefl_put(dst, s, is_last ? 0x01 : 0x00, 1); /* block */
- sdefl_put(dst, s, 0x02, 2); /* dynamic huffman */
- sdefl_put(dst, s, symcnt.lit - 257, 5);
- sdefl_put(dst, s, symcnt.off - 1, 5);
- sdefl_put(dst, s, item_cnt - 4, 4);
- for (i = 0; i < item_cnt; ++i)
- sdefl_put(dst, s, lens[perm[i]], 3);
- for (i = 0; i < symcnt.items; ++i) {
- unsigned sym = items[i] & 0x1F;
- sdefl_put(dst, s, (int)codes[sym], lens[sym]);
- if (sym < 16) continue;
- if (sym == 16) sdefl_put(dst, s, items[i] >> 5, 2);
- else if(sym == 17) sdefl_put(dst, s, items[i] >> 5, 3);
- else sdefl_put(dst, s, items[i] >> 5, 7);
- }
- /* block sequences */
- for (i = 0; i < s->seq_cnt; ++i) {
- if (s->seq[i].off >= 0)
- for (j = 0; j < s->seq[i].len; ++j) {
- int c = in[s->seq[i].off + j];
- sdefl_put(dst, s, (int)s->cod.word.lit[c], s->cod.len.lit[c]);
+ /* write block */
+ switch (sdefl_blk_type(s, blk_len, item_cnt, freqs, lens)) {
+ case SDEFL_BLK_UCOMPR: {
+ /* uncompressed blocks */
+ int n = sdefl_div_round_up(blk_len, SDEFL_RAW_BLK_SIZE);
+ for (i = 0; i < n; ++i) {
+ int fin = is_last && (i + 1 == n);
+ int amount = blk_len < SDEFL_RAW_BLK_SIZE ? blk_len : SDEFL_RAW_BLK_SIZE;
+ sdefl_put(dst, s, !!fin, 1); /* block */
+ sdefl_put(dst, s, 0x00, 2); /* stored block */
+ if (s->bitcnt) {
+ sdefl_put(dst, s, 0x00, 8 - s->bitcnt);
}
- else sdefl_match(dst, s, -s->seq[i].off, s->seq[i].len);
- }
- sdefl_put(dst, s, (int)(s)->cod.word.lit[SDEFL_EOB], (s)->cod.len.lit[SDEFL_EOB]);
+ assert(s->bitcnt == 0);
+ sdefl_put16(dst, (unsigned short)amount);
+ sdefl_put16(dst, ~(unsigned short)amount);
+ memcpy(*dst, in + blk_begin + i * SDEFL_RAW_BLK_SIZE, amount);
+ *dst = *dst + amount;
+ blk_len -= amount;
+ }
+ } break;
+ case SDEFL_BLK_DYN: {
+ /* dynamic huffman block */
+ sdefl_put(dst, s, !!is_last, 1); /* block */
+ sdefl_put(dst, s, 0x02, 2); /* dynamic huffman */
+ sdefl_put(dst, s, symcnt.lit - 257, 5);
+ sdefl_put(dst, s, symcnt.off - 1, 5);
+ sdefl_put(dst, s, item_cnt - 4, 4);
+ for (i = 0; i < item_cnt; ++i) {
+ sdefl_put(dst, s, lens[perm[i]], 3);
+ }
+ for (i = 0; i < symcnt.items; ++i) {
+ unsigned sym = items[i] & 0x1F;
+ sdefl_put(dst, s, (int)codes[sym], lens[sym]);
+ if (sym < 16) continue;
+ if (sym == 16) sdefl_put(dst, s, items[i] >> 5, 2);
+ else if(sym == 17) sdefl_put(dst, s, items[i] >> 5, 3);
+ else sdefl_put(dst, s, items[i] >> 5, 7);
+ }
+ /* block sequences */
+ for (i = 0; i < s->seq_cnt; ++i) {
+ if (s->seq[i].off >= 0) {
+ for (j = 0; j < s->seq[i].len; ++j) {
+ int c = in[s->seq[i].off + j];
+ sdefl_put(dst, s, (int)s->cod.word.lit[c], s->cod.len.lit[c]);
+ }
+ } else {
+ sdefl_match(dst, s, -s->seq[i].off, s->seq[i].len);
+ }
+ }
+ sdefl_put(dst, s, (int)(s)->cod.word.lit[SDEFL_EOB], (s)->cod.len.lit[SDEFL_EOB]);
+ } break;}
memset(&s->freq, 0, sizeof(s->freq));
s->seq_cnt = 0;
}
@@ -541,8 +614,12 @@ sdefl_seq(struct sdefl *s, int off, int len) {
}
static void
sdefl_reg_match(struct sdefl *s, int off, int len) {
- struct sdefl_match_codes cod;
+ struct sdefl_match_codest cod;
sdefl_match_codes(&cod, off, len);
+
+ assert(cod.lc < SDEFL_SYM_MAX);
+ assert(cod.dc < SDEFL_OFF_MAX);
+
s->freq.lit[cod.lc]++;
s->freq.off[cod.dc]++;
}
@@ -551,22 +628,35 @@ struct sdefl_match {
int len;
};
static void
-sdefl_fnd(struct sdefl_match *m, const struct sdefl *s,
- int chain_len, int max_match, const unsigned char *in, int p) {
- int i = s->tbl[sdefl_hash32(&in[p])];
- int limit = ((p-SDEFL_WIN_SIZ)tbl[sdefl_hash32(in + p)];
+ int limit = ((p - SDEFL_WIN_SIZ) < SDEFL_NIL) ? SDEFL_NIL : (p-SDEFL_WIN_SIZ);
+
+ assert(p < e);
+ assert(p + max_match <= e);
while (i > limit) {
- if (in[i+m->len] == in[p+m->len] &&
- (sdefl_uload32(&in[i]) == sdefl_uload32(&in[p]))){
+ assert(i + m->len < e);
+ assert(p + m->len < e);
+ assert(i + SDEFL_MIN_MATCH < e);
+ assert(p + SDEFL_MIN_MATCH < e);
+
+ if (in[i + m->len] == in[p + m->len] &&
+ (sdefl_uload32(&in[i]) == sdefl_uload32(&in[p]))) {
int n = SDEFL_MIN_MATCH;
- while (n < max_match && in[i+n] == in[p+n]) n++;
+ while (n < max_match && in[i + n] == in[p + n]) {
+ assert(i + n < e);
+ assert(p + n < e);
+ n++;
+ }
if (n > m->len) {
m->len = n, m->off = p - i;
- if (n == max_match) break;
+ if (n == max_match)
+ break;
}
}
if (!(--chain_len)) break;
- i = s->prv[i&SDEFL_WIN_MSK];
+ i = s->prv[i & SDEFL_WIN_MSK];
}
}
static int
@@ -579,18 +669,20 @@ sdefl_compr(struct sdefl *s, unsigned char *out, const unsigned char *in,
for (n = 0; n < SDEFL_HASH_SIZ; ++n) {
s->tbl[n] = SDEFL_NIL;
}
- do {int blk_end = i + SDEFL_BLK_MAX < in_len ? i + SDEFL_BLK_MAX : in_len;
+ do {int blk_begin = i;
+ int blk_end = ((i + SDEFL_BLK_MAX) < in_len) ? (i + SDEFL_BLK_MAX) : in_len;
while (i < blk_end) {
struct sdefl_match m = {0};
- int max_match = ((in_len-i)>SDEFL_MAX_MATCH) ? SDEFL_MAX_MATCH:(in_len-i);
+ int left = blk_end - i;
+ int max_match = (left > SDEFL_MAX_MATCH) ? SDEFL_MAX_MATCH : left;
int nice_match = pref[lvl] < max_match ? pref[lvl] : max_match;
- int run = 1, inc = 1, run_inc;
+ int run = 1, inc = 1, run_inc = 0;
if (max_match > SDEFL_MIN_MATCH) {
- sdefl_fnd(&m, s, max_chain, max_match, in, i);
+ sdefl_fnd(&m, s, max_chain, max_match, in, i, in_len);
}
- if (lvl >= 5 && m.len >= SDEFL_MIN_MATCH && m.len < nice_match){
+ if (lvl >= 5 && m.len >= SDEFL_MIN_MATCH && m.len + 1 < nice_match){
struct sdefl_match m2 = {0};
- sdefl_fnd(&m2, s, max_chain, m.len+1, in, i+1);
+ sdefl_fnd(&m2, s, max_chain, m.len + 1, in, i + 1, in_len);
m.len = (m2.len > m.len) ? 0 : m.len;
}
if (m.len >= SDEFL_MIN_MATCH) {
@@ -615,20 +707,23 @@ sdefl_compr(struct sdefl *s, unsigned char *out, const unsigned char *in,
unsigned h = sdefl_hash32(&in[i]);
s->prv[i&SDEFL_WIN_MSK] = s->tbl[h];
s->tbl[h] = i, i += inc;
+ assert(i <= blk_end);
}
} else {
i += run_inc;
+ assert(i <= blk_end);
}
}
if (litlen) {
sdefl_seq(s, i - litlen, litlen);
litlen = 0;
}
- sdefl_flush(&q, s, blk_end == in_len, in);
+ sdefl_flush(&q, s, blk_end == in_len, in, blk_begin, blk_end);
} while (i < in_len);
-
- if (s->bitcnt)
+ if (s->bitcnt) {
sdefl_put(&q, s, 0x00, 8 - s->bitcnt);
+ }
+ assert(s->bitcnt == 0);
return (int)(q - out);
}
extern int
@@ -688,9 +783,8 @@ zsdeflate(struct sdefl *s, void *out, const void *in, int n, int lvl) {
}
extern int
sdefl_bound(int len) {
- int a = 128 + (len * 110) / 100;
- int b = 128 + len + ((len / (31 * 1024)) + 1) * 5;
- return (a > b) ? a : b;
+ int max_blocks = 1 + sdefl_div_round_up(len, SDEFL_RAW_BLK_SIZE);
+ int bound = 5 * max_blocks + len + 1 + 4 + 8;
+ return bound;
}
#endif /* SDEFL_IMPLEMENTATION */
-
diff --git a/src/external/sinfl.h b/src/external/sinfl.h
index 09f50d2bc..8979fcd7f 100644
--- a/src/external/sinfl.h
+++ b/src/external/sinfl.h
@@ -10,7 +10,7 @@ as needed to keep the implementation as concise as possible.
- Dual license with either MIT or public domain
- Small implementation
- Deflate: 525 LoC
- - Inflate: 320 LoC
+ - Inflate: 500 LoC
- Webassembly:
- Deflate ~3.7 KB (~2.2KB compressed)
- Inflate ~3.6 KB (~2.2KB compressed)
@@ -39,10 +39,10 @@ this file implementation in *one* C or C++ file to prevent collisions.
| zlib 1.2.11 -1 | 72 MB/s | 307 MB/s | 42298774 | 42.30 |
| zlib 1.2.11 -6 | 24 MB/s | 313 MB/s | 36548921 | 36.55 |
| zlib 1.2.11 -9 | 20 MB/s | 314 MB/s | 36475792 | 36.48 |
-| sdefl 1.0 -0 | 127 MB/s | 371 MB/s | 40004116 | 39.88 |
-| sdefl 1.0 -1 | 111 MB/s | 398 MB/s | 38940674 | 38.82 |
-| sdefl 1.0 -5 | 45 MB/s | 420 MB/s | 36577183 | 36.46 |
-| sdefl 1.0 -7 | 38 MB/s | 423 MB/s | 36523781 | 36.41 |
+| sdefl 1.0 -0 | 127 MB/s | 355 MB/s | 40004116 | 39.88 |
+| sdefl 1.0 -1 | 111 MB/s | 413 MB/s | 38940674 | 38.82 |
+| sdefl 1.0 -5 | 45 MB/s | 436 MB/s | 36577183 | 36.46 |
+| sdefl 1.0 -7 | 38 MB/s | 432 MB/s | 36523781 | 36.41 |
| libdeflate 1.3 -1 | 147 MB/s | 667 MB/s | 39597378 | 39.60 |
| libdeflate 1.3 -6 | 69 MB/s | 689 MB/s | 36648318 | 36.65 |
| libdeflate 1.3 -9 | 13 MB/s | 672 MB/s | 35197141 | 35.20 |
@@ -51,20 +51,20 @@ this file implementation in *one* C or C++ file to prevent collisions.
### Compression
Results on the [Silesia compression corpus](http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia):
-| File | Original | `sdefl 0` | `sdefl 5` | `sdefl 7` |
-| :------ | ---------: | -----------------: | ---------: | ----------: |
-| dickens | 10.192.446 | 4,260,187| 3,845,261| 3,833,657 |
-| mozilla | 51.220.480 | 20,774,706 | 19,607,009 | 19,565,867 |
-| mr | 9.970.564 | 3,860,531 | 3,673,460 | 3,665,627 |
-| nci | 33.553.445 | 4,030,283 | 3,094,526 | 3,006,075 |
-| ooffice | 6.152.192 | 3,320,063 | 3,186,373 | 3,183,815 |
-| osdb | 10.085.684 | 3,919,646 | 3,649,510 | 3,649,477 |
-| reymont | 6.627.202 | 2,263,378 | 1,857,588 | 1,827,237 |
-| samba | 21.606.400 | 6,121,797 | 5,462,670 | 5,450,762 |
-| sao | 7.251.944 | 5,612,421 | 5,485,380 | 5,481,765 |
-| webster | 41.458.703 | 13,972,648 | 12,059,432 | 11,991,421 |
-| xml | 5.345.280 | 886,620| 674,009 | 662,141 |
-| x-ray | 8.474.240 | 6,304,655 | 6,244,779 | 6,244,779 |
+| File | Original | `sdefl 0` | `sdefl 5` | `sdefl 7` |
+| --------| -----------| -------------| ---------- | ------------|
+| dickens | 10.192.446 | 4,260,187 | 3,845,261 | 3,833,657 |
+| mozilla | 51.220.480 | 20,774,706 | 19,607,009 | 19,565,867 |
+| mr | 9.970.564 | 3,860,531 | 3,673,460 | 3,665,627 |
+| nci | 33.553.445 | 4,030,283 | 3,094,526 | 3,006,075 |
+| ooffice | 6.152.192 | 3,320,063 | 3,186,373 | 3,183,815 |
+| osdb | 10.085.684 | 3,919,646 | 3,649,510 | 3,649,477 |
+| reymont | 6.627.202 | 2,263,378 | 1,857,588 | 1,827,237 |
+| samba | 21.606.400 | 6,121,797 | 5,462,670 | 5,450,762 |
+| sao | 7.251.944 | 5,612,421 | 5,485,380 | 5,481,765 |
+| webster | 41.458.703 | 13,972,648 | 12,059,432 | 11,991,421 |
+| xml | 5.345.280 | 886,620 | 674,009 | 662,141 |
+| x-ray | 8.474.240 | 6,304,655 | 6,244,779 | 6,244,779 |
## License
```
@@ -72,7 +72,7 @@ Results on the [Silesia compression corpus](http://sun.aei.polsl.pl/~sdeor/index
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
-Copyright (c) 2020 Micha Mettke
+Copyright (c) 2020-2023 Micha Mettke
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
@@ -151,7 +151,7 @@ extern int zsinflate(void *out, int cap, const void *in, int size);
#endif
#ifndef SINFL_NO_SIMD
-#if __x86_64__ || defined(_WIN32) || defined(_WIN64)
+#if defined(__x86_64__) || defined(_WIN32) || defined(_WIN64)
#include
#define sinfl_char16 __m128i
#define sinfl_char16_ld(p) _mm_loadu_si128((const __m128i *)(void*)(p))
@@ -183,6 +183,18 @@ sinfl_read64(const void *p) {
memcpy(&n, p, 8);
return n;
}
+static void
+sinfl_copy64(unsigned char **dst, unsigned char **src) {
+ unsigned long long n;
+ memcpy(&n, *src, 8);
+ memcpy(*dst, &n, 8);
+ *dst += 8, *src += 8;
+}
+static unsigned char*
+sinfl_write64(unsigned char *dst, unsigned long long w) {
+ memcpy(dst, &w, 8);
+ return dst + 8;
+}
#ifndef SINFL_NO_SIMD
static unsigned char*
sinfl_write128(unsigned char *dst, sinfl_char16 w) {
@@ -195,25 +207,12 @@ sinfl_copy128(unsigned char **dst, unsigned char **src) {
sinfl_char16_str(*dst, n);
*dst += 16, *src += 16;
}
-#else
-static unsigned char*
-sinfl_write64(unsigned char *dst, unsigned long long w) {
- memcpy(dst, &w, 8);
- return dst + 8;
-}
-static void
-sinfl_copy64(unsigned char **dst, unsigned char **src) {
- unsigned long long n;
- memcpy(&n, *src, 8);
- memcpy(*dst, &n, 8);
- *dst += 8, *src += 8;
-}
#endif
static void
sinfl_refill(struct sinfl *s) {
s->bitbuf |= sinfl_read64(s->bitptr) << s->bitcnt;
s->bitptr += (63 - s->bitcnt) >> 3;
- s->bitcnt |= 56; /* bitcount is in range [56,63] */
+ s->bitcnt |= 56; /* bitcount in range [56,63] */
}
static int
sinfl_peek(struct sinfl *s, int cnt) {
@@ -222,7 +221,7 @@ sinfl_peek(struct sinfl *s, int cnt) {
return s->bitbuf & ((1ull << cnt) - 1);
}
static void
-sinfl_consume(struct sinfl *s, int cnt) {
+sinfl_eat(struct sinfl *s, int cnt) {
assert(cnt <= s->bitcnt);
s->bitbuf >>= cnt;
s->bitcnt -= cnt;
@@ -230,7 +229,7 @@ sinfl_consume(struct sinfl *s, int cnt) {
static int
sinfl__get(struct sinfl *s, int cnt) {
int res = sinfl_peek(s, cnt);
- sinfl_consume(s, cnt);
+ sinfl_eat(s, cnt);
return res;
}
static int
@@ -285,7 +284,7 @@ sinfl_build_subtbl(struct sinfl_gen *gen, unsigned *tbl, int tbl_bits,
while (1) {
unsigned entry;
int bit, stride, i;
- /* start new subtable */
+ /* start new sub-table */
if ((gen->word & ((1 << tbl_bits)-1)) != sub_prefix) {
int used = 0;
sub_prefix = gen->word & ((1 << tbl_bits)-1);
@@ -299,7 +298,7 @@ sinfl_build_subtbl(struct sinfl_gen *gen, unsigned *tbl, int tbl_bits,
tbl_end = sub_start + (1 << sub_bits);
tbl[sub_prefix] = (sub_start << 16) | 0x10 | (sub_bits & 0xf);
}
- /* fill subtable */
+ /* fill sub-table */
entry = (*gen->sorted << 16) | ((gen->len - tbl_bits) & 0xf);
gen->sorted++;
i = sub_start + (gen->word >> tbl_bits);
@@ -353,18 +352,17 @@ sinfl_build(unsigned *tbl, unsigned char *lens, int tbl_bits, int maxlen,
}
static int
sinfl_decode(struct sinfl *s, const unsigned *tbl, int bit_len) {
- sinfl_refill(s);
- {int idx = sinfl_peek(s, bit_len);
+ int idx = sinfl_peek(s, bit_len);
unsigned key = tbl[idx];
if (key & 0x10) {
/* sub-table lookup */
int len = key & 0x0f;
- sinfl_consume(s, bit_len);
+ sinfl_eat(s, bit_len);
idx = sinfl_peek(s, len);
key = tbl[((key >> 16) & 0xffff) + (unsigned)idx];
}
- sinfl_consume(s, key & 0x0f);
- return (key >> 16) & 0x0fff;}
+ sinfl_eat(s, key & 0x0f);
+ return (key >> 16) & 0x0fff;
}
static int
sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size) {
@@ -402,17 +400,21 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size)
} break;
case stored: {
/* uncompressed block */
- int len;
- sinfl_refill(&s);
+ unsigned len, nlen;
sinfl__get(&s,s.bitcnt & 7);
- len = sinfl__get(&s,16);
- //int nlen = sinfl__get(&s,16); // @raysan5: Unused variable?
- in -= 2; s.bitcnt = 0;
+ len = (unsigned short)sinfl__get(&s,16);
+ nlen = (unsigned short)sinfl__get(&s,16);
+ s.bitptr -= s.bitcnt / 8;
+ s.bitbuf = s.bitcnt = 0;
- if (len > (e-in) || !len)
+ if ((unsigned short)len != (unsigned short)~nlen)
return (int)(out-o);
- memcpy(out, in, (size_t)len);
- in += len, out += len;
+ if (len > (e - s.bitptr) || !len)
+ return (int)(out-o);
+
+ memcpy(out, s.bitptr, (size_t)len);
+ s.bitptr += len, out += len;
+ if (last) return (int)(out-o);
state = hdr;
} break;
case fixed: {
@@ -430,40 +432,64 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size)
state = blk;
} break;
case dyn: {
- /* dynamic huffman codes */
- int n, i;
- unsigned hlens[SINFL_PRE_TBL_SIZE];
- unsigned char nlens[19] = {0}, lens[288+32];
+ /* dynamic huffman codes */
+ int n, i;
+ unsigned hlens[SINFL_PRE_TBL_SIZE];
+ unsigned char nlens[19] = {0}, lens[288+32];
+ sinfl_refill(&s);
+ {int nlit = 257 + sinfl__get(&s,5);
+ int ndist = 1 + sinfl__get(&s,5);
+ int nlen = 4 + sinfl__get(&s,4);
+ for (n = 0; n < nlen; n++)
+ nlens[order[n]] = (unsigned char)sinfl_get(&s,3);
+ sinfl_build(hlens, nlens, 7, 7, 19);
+
+ /* decode code lengths */
+ for (n = 0; n < nlit + ndist;) {
+ int sym = 0;
sinfl_refill(&s);
- {int nlit = 257 + sinfl__get(&s,5);
- int ndist = 1 + sinfl__get(&s,5);
- int nlen = 4 + sinfl__get(&s,4);
- for (n = 0; n < nlen; n++)
- nlens[order[n]] = (unsigned char)sinfl_get(&s,3);
- sinfl_build(hlens, nlens, 7, 7, 19);
-
- /* decode code lengths */
- for (n = 0; n < nlit + ndist;) {
- int sym = sinfl_decode(&s, hlens, 7);
- switch (sym) {default: lens[n++] = (unsigned char)sym; break;
- case 16: for (i=3+sinfl_get(&s,2);i;i--,n++) lens[n]=lens[n-1]; break;
- case 17: for (i=3+sinfl_get(&s,3);i;i--,n++) lens[n]=0; break;
- case 18: for (i=11+sinfl_get(&s,7);i;i--,n++) lens[n]=0; break;}
- }
- /* build lit/dist tables */
- sinfl_build(s.lits, lens, 10, 15, nlit);
- sinfl_build(s.dsts, lens + nlit, 8, 15, ndist);
- state = blk;}
+ sym = sinfl_decode(&s, hlens, 7);
+ switch (sym) {default: lens[n++] = (unsigned char)sym; break;
+ case 16: for (i=3+sinfl_get(&s,2);i;i--,n++) lens[n]=lens[n-1]; break;
+ case 17: for (i=3+sinfl_get(&s,3);i;i--,n++) lens[n]=0; break;
+ case 18: for (i=11+sinfl_get(&s,7);i;i--,n++) lens[n]=0; break;}
+ }
+ /* build lit/dist tables */
+ sinfl_build(s.lits, lens, 10, 15, nlit);
+ sinfl_build(s.dsts, lens + nlit, 8, 15, ndist);
+ state = blk;}
} break;
case blk: {
/* decompress block */
- int sym = sinfl_decode(&s, s.lits, 10);
- if (sym < 256) {
- /* literal */
- *out++ = (unsigned char)sym;
- } else if (sym > 256) {sym -= 257; /* match symbol */
+ while (1) {
+ int sym;
sinfl_refill(&s);
+ sym = sinfl_decode(&s, s.lits, 10);
+ if (sym < 256) {
+ /* literal */
+ if (sinfl_unlikely(out >= oe)) {
+ return (int)(out-o);
+ }
+ *out++ = (unsigned char)sym;
+ sym = sinfl_decode(&s, s.lits, 10);
+ if (sym < 256) {
+ *out++ = (unsigned char)sym;
+ continue;
+ }
+ }
+ if (sinfl_unlikely(sym == 256)) {
+ /* end of block */
+ if (last) return (int)(out-o);
+ state = hdr;
+ break;
+ }
+ /* match */
+ if (sym >= 286) {
+ /* length codes 286 and 287 must not appear in compressed data */
+ return (int)(out-o);
+ }
+ sym -= 257;
{int len = sinfl__get(&s, lbits[sym]) + lbase[sym];
int dsym = sinfl_decode(&s, s.dsts, 8);
int offs = sinfl__get(&s, dbits[dsym]) + dbase[dsym];
@@ -476,11 +502,17 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size)
#ifndef SINFL_NO_SIMD
if (sinfl_likely(oe - out >= 16 * 3)) {
if (offs >= 16) {
- /* copy match */
+ /* simd copy match */
sinfl_copy128(&dst, &src);
sinfl_copy128(&dst, &src);
do sinfl_copy128(&dst, &src);
while (dst < out);
+ } else if (offs >= 8) {
+ /* word copy match */
+ sinfl_copy64(&dst, &src);
+ sinfl_copy64(&dst, &src);
+ do sinfl_copy64(&dst, &src);
+ while (dst < out);
} else if (offs == 1) {
/* rle match copying */
sinfl_char16 w = sinfl_char16_char(src[0]);
@@ -489,6 +521,7 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size)
do dst = sinfl_write128(dst, w);
while (dst < out);
} else {
+ /* byte copy match */
*dst++ = *src++;
*dst++ = *src++;
do *dst++ = *src++;
@@ -498,7 +531,7 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size)
#else
if (sinfl_likely(oe - out >= 3 * 8 - 3)) {
if (offs >= 8) {
- /* copy match */
+ /* word copy match */
sinfl_copy64(&dst, &src);
sinfl_copy64(&dst, &src);
do sinfl_copy64(&dst, &src);
@@ -513,6 +546,7 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size)
do dst = sinfl_write64(dst, w);
while (dst < out);
} else {
+ /* byte copy match */
*dst++ = *src++;
*dst++ = *src++;
do *dst++ = *src++;
@@ -524,13 +558,8 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size)
*dst++ = *src++;
*dst++ = *src++;
do *dst++ = *src++;
- while (dst < out);}
- }
- } else {
- /* end of block */
- if (last) return (int)(out-o);
- state = hdr;
- break;
+ while (dst < out);
+ }}
}
} break;}
}
diff --git a/src/external/stb_image.h b/src/external/stb_image.h
index d60371b95..5e807a0a6 100644
--- a/src/external/stb_image.h
+++ b/src/external/stb_image.h
@@ -1,4 +1,4 @@
-/* stb_image - v2.27 - public domain image loader - http://nothings.org/stb
+/* stb_image - v2.28 - public domain image loader - http://nothings.org/stb
no warranty implied; use at your own risk
Do this:
@@ -48,6 +48,7 @@ LICENSE
RECENT REVISION HISTORY:
+ 2.28 (2023-01-29) many error fixes, security errors, just tons of stuff
2.27 (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes
2.26 (2020-07-13) many minor fixes
2.25 (2020-02-02) fix warnings
@@ -108,7 +109,7 @@ RECENT REVISION HISTORY:
Cass Everitt Ryamond Barbiero github:grim210
Paul Du Bois Engin Manap Aldo Culquicondor github:sammyhw
Philipp Wiesemann Dale Weiler Oriol Ferrer Mesia github:phprus
- Josh Tobin Matthew Gregan github:poppolopoppo
+ Josh Tobin Neil Bickford Matthew Gregan github:poppolopoppo
Julian Raschke Gregory Mullen Christian Floisand github:darealshinji
Baldur Karlsson Kevin Schmidt JR Smith github:Michaelangel007
Brad Weinberger Matvey Cherevko github:mosra
@@ -140,7 +141,7 @@ RECENT REVISION HISTORY:
// // ... 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)
+// stbi_image_free(data);
//
// Standard parameters:
// int *x -- outputs image width in pixels
@@ -635,7 +636,7 @@ STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const ch
#endif
#endif
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__SYMBIAN32__)
typedef unsigned short stbi__uint16;
typedef signed short stbi__int16;
typedef unsigned int stbi__uint32;
@@ -1063,6 +1064,23 @@ static void *stbi__malloc_mad4(int a, int b, int c, int d, int add)
}
#endif
+// returns 1 if the sum of two signed ints is valid (between -2^31 and 2^31-1 inclusive), 0 on overflow.
+static int stbi__addints_valid(int a, int b)
+{
+ if ((a >= 0) != (b >= 0)) return 1; // a and b have different signs, so no overflow
+ if (a < 0 && b < 0) return a >= INT_MIN - b; // same as a + b >= INT_MIN; INT_MIN - b cannot overflow since b < 0.
+ return a <= INT_MAX - b;
+}
+
+// returns 1 if the product of two signed shorts is valid, 0 on overflow.
+static int stbi__mul2shorts_valid(short a, short b)
+{
+ if (b == 0 || b == -1) return 1; // multiplication by 0 is always 0; check for -1 so SHRT_MIN/b doesn't overflow
+ if ((a >= 0) == (b >= 0)) return a <= SHRT_MAX/b; // product is positive, so similar to mul2sizes_valid
+ if (b < 0) return a <= SHRT_MIN / b; // same as a * b >= SHRT_MIN
+ return a >= SHRT_MIN / b;
+}
+
// stbi__err - error
// stbi__errpf - error returning pointer to float
// stbi__errpuc - error returning pointer to unsigned char
@@ -1985,9 +2003,12 @@ static int stbi__build_huffman(stbi__huffman *h, int *count)
int i,j,k=0;
unsigned int code;
// build size list for each symbol (from JPEG spec)
- for (i=0; i < 16; ++i)
- for (j=0; j < count[i]; ++j)
+ for (i=0; i < 16; ++i) {
+ for (j=0; j < count[i]; ++j) {
h->size[k++] = (stbi_uc) (i+1);
+ if(k >= 257) return stbi__err("bad size list","Corrupt JPEG");
+ }
+ }
h->size[k] = 0;
// compute actual symbols (from jpeg spec)
@@ -2112,6 +2133,8 @@ stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h)
// convert the huffman code to the symbol id
c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k];
+ if(c < 0 || c >= 256) // symbol id out of bounds!
+ return -1;
STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]);
// convert the id to a symbol
@@ -2130,6 +2153,7 @@ stbi_inline static int stbi__extend_receive(stbi__jpeg *j, int n)
unsigned int k;
int sgn;
if (j->code_bits < n) stbi__grow_buffer_unsafe(j);
+ if (j->code_bits < n) return 0; // ran out of bits from stream, return 0s intead of continuing
sgn = j->code_buffer >> 31; // sign bit always in MSB; 0 if MSB clear (positive), 1 if MSB set (negative)
k = stbi_lrot(j->code_buffer, n);
@@ -2144,6 +2168,7 @@ 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);
+ if (j->code_bits < n) return 0; // ran out of bits from stream, return 0s intead of continuing
k = stbi_lrot(j->code_buffer, n);
j->code_buffer = k & ~stbi__bmask[n];
k &= stbi__bmask[n];
@@ -2155,6 +2180,7 @@ stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j)
{
unsigned int k;
if (j->code_bits < 1) stbi__grow_buffer_unsafe(j);
+ if (j->code_bits < 1) return 0; // ran out of bits from stream, return 0s intead of continuing
k = j->code_buffer;
j->code_buffer <<= 1;
--j->code_bits;
@@ -2192,8 +2218,10 @@ static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman
memset(data,0,64*sizeof(data[0]));
diff = t ? stbi__extend_receive(j, t) : 0;
+ if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) return stbi__err("bad delta","Corrupt JPEG");
dc = j->img_comp[b].dc_pred + diff;
j->img_comp[b].dc_pred = dc;
+ if (!stbi__mul2shorts_valid(dc, dequant[0])) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
data[0] = (short) (dc * dequant[0]);
// decode AC components, see JPEG spec
@@ -2207,6 +2235,7 @@ static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman
if (r) { // fast-AC path
k += (r >> 4) & 15; // run
s = r & 15; // combined length
+ if (s > j->code_bits) return stbi__err("bad huffman code", "Combined length longer than code bits available");
j->code_buffer <<= s;
j->code_bits -= s;
// decode into unzigzag'd location
@@ -2246,8 +2275,10 @@ static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__
if (t < 0 || t > 15) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
diff = t ? stbi__extend_receive(j, t) : 0;
+ if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) return stbi__err("bad delta", "Corrupt JPEG");
dc = j->img_comp[b].dc_pred + diff;
j->img_comp[b].dc_pred = dc;
+ if (!stbi__mul2shorts_valid(dc, 1 << j->succ_low)) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
data[0] = (short) (dc * (1 << j->succ_low));
} else {
// refinement scan for DC coefficient
@@ -2282,6 +2313,7 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__
if (r) { // fast-AC path
k += (r >> 4) & 15; // run
s = r & 15; // combined length
+ if (s > j->code_bits) return stbi__err("bad huffman code", "Combined length longer than code bits available");
j->code_buffer <<= s;
j->code_bits -= s;
zig = stbi__jpeg_dezigzag[k++];
@@ -3102,6 +3134,7 @@ static int stbi__process_marker(stbi__jpeg *z, int m)
sizes[i] = stbi__get8(z->s);
n += sizes[i];
}
+ if(n > 256) return stbi__err("bad DHT header","Corrupt JPEG"); // Loop over i < n would write past end of values!
L -= 17;
if (tc == 0) {
if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0;
@@ -3351,6 +3384,28 @@ static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan)
return 1;
}
+static int stbi__skip_jpeg_junk_at_end(stbi__jpeg *j)
+{
+ // some JPEGs have junk at end, skip over it but if we find what looks
+ // like a valid marker, resume there
+ while (!stbi__at_eof(j->s)) {
+ int x = stbi__get8(j->s);
+ while (x == 255) { // might be a marker
+ if (stbi__at_eof(j->s)) return STBI__MARKER_none;
+ x = stbi__get8(j->s);
+ if (x != 0x00 && x != 0xff) {
+ // not a stuffed zero or lead-in to another marker, looks
+ // like an actual marker, return it
+ return x;
+ }
+ // stuffed zero has x=0 now which ends the loop, meaning we go
+ // back to regular scan loop.
+ // repeated 0xff keeps trying to read the next byte of the marker.
+ }
+ }
+ return STBI__MARKER_none;
+}
+
// decode image to YCbCr format
static int stbi__decode_jpeg_image(stbi__jpeg *j)
{
@@ -3367,25 +3422,22 @@ static int stbi__decode_jpeg_image(stbi__jpeg *j)
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;
- }
- }
+ j->marker = stbi__skip_jpeg_junk_at_end(j);
// if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0
}
+ m = stbi__get_marker(j);
+ if (STBI__RESTART(m))
+ m = stbi__get_marker(j);
} else if (stbi__DNL(m)) {
int Ld = stbi__get16be(j->s);
stbi__uint32 NL = stbi__get16be(j->s);
if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG");
if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG");
+ m = stbi__get_marker(j);
} else {
- if (!stbi__process_marker(j, m)) return 0;
+ if (!stbi__process_marker(j, m)) return 1;
+ m = stbi__get_marker(j);
}
- m = stbi__get_marker(j);
}
if (j->progressive)
stbi__jpeg_finish(j);
@@ -3976,6 +4028,7 @@ static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int re
unsigned char* result;
stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg));
if (!j) return stbi__errpuc("outofmem", "Out of memory");
+ memset(j, 0, sizeof(stbi__jpeg));
STBI_NOTUSED(ri);
j->s = s;
stbi__setup_jpeg(j);
@@ -3989,6 +4042,7 @@ static int stbi__jpeg_test(stbi__context *s)
int r;
stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg));
if (!j) return stbi__err("outofmem", "Out of memory");
+ memset(j, 0, sizeof(stbi__jpeg));
j->s = s;
stbi__setup_jpeg(j);
r = stbi__decode_jpeg_header(j, STBI__SCAN_type);
@@ -4014,6 +4068,7 @@ 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)));
if (!j) return stbi__err("outofmem", "Out of memory");
+ memset(j, 0, sizeof(stbi__jpeg));
j->s = s;
result = stbi__jpeg_info_raw(j, x, y, comp);
STBI_FREE(j);
@@ -4256,11 +4311,12 @@ static int stbi__parse_huffman_block(stbi__zbuf *a)
a->zout = zout;
return 1;
}
+ if (z >= 286) return stbi__err("bad huffman code","Corrupt PNG"); // per DEFLATE, length codes 286 and 287 must not appear in compressed data
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");
+ if (z < 0 || z >= 30) return stbi__err("bad huffman code","Corrupt PNG"); // per DEFLATE, distance codes 30 and 31 must not appear in compressed data
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");
@@ -4955,7 +5011,7 @@ STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert)
static STBI_THREAD_LOCAL int stbi__unpremultiply_on_load_local, stbi__unpremultiply_on_load_set;
static STBI_THREAD_LOCAL int stbi__de_iphone_flag_local, stbi__de_iphone_flag_set;
-STBIDEF void stbi__unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply)
+STBIDEF void stbi_set_unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply)
{
stbi__unpremultiply_on_load_local = flag_true_if_should_unpremultiply;
stbi__unpremultiply_on_load_set = 1;
@@ -5064,14 +5120,13 @@ static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
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
}
+ // even with SCAN_header, have to scan to see if we have a tRNS
break;
}
@@ -5103,6 +5158,8 @@ static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
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;
+ // non-paletted with tRNS = constant alpha. if header-scanning, we can stop now.
+ if (scan == STBI__SCAN_header) { ++s->img_n; return 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 {
@@ -5115,7 +5172,13 @@ static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
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 (scan == STBI__SCAN_header) {
+ // header scan definitely stops at first IDAT
+ if (pal_img_n)
+ s->img_n = pal_img_n;
+ return 1;
+ }
+ if (c.length > (1u << 30)) return stbi__err("IDAT size limit", "IDAT section larger than 2^30 bytes");
if ((int)(ioff + c.length) < (int)ioff) return 0;
if (ioff + c.length > idata_limit) {
stbi__uint32 idata_limit_old = idata_limit;
@@ -5498,8 +5561,22 @@ static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req
psize = (info.offset - info.extra_read - info.hsz) >> 2;
}
if (psize == 0) {
- if (info.offset != s->callback_already_read + (s->img_buffer - s->img_buffer_original)) {
- return stbi__errpuc("bad offset", "Corrupt BMP");
+ // accept some number of extra bytes after the header, but if the offset points either to before
+ // the header ends or implies a large amount of extra data, reject the file as malformed
+ int bytes_read_so_far = s->callback_already_read + (int)(s->img_buffer - s->img_buffer_original);
+ int header_limit = 1024; // max we actually read is below 256 bytes currently.
+ int extra_data_limit = 256*4; // what ordinarily goes here is a palette; 256 entries*4 bytes is its max size.
+ if (bytes_read_so_far <= 0 || bytes_read_so_far > header_limit) {
+ return stbi__errpuc("bad header", "Corrupt BMP");
+ }
+ // we established that bytes_read_so_far is positive and sensible.
+ // the first half of this test rejects offsets that are either too small positives, or
+ // negative, and guarantees that info.offset >= bytes_read_so_far > 0. this in turn
+ // ensures the number computed in the second half of the test can't overflow.
+ if (info.offset < bytes_read_so_far || info.offset - bytes_read_so_far > extra_data_limit) {
+ return stbi__errpuc("bad offset", "Corrupt BMP");
+ } else {
+ stbi__skip(s, info.offset - bytes_read_so_far);
}
}
@@ -7187,12 +7264,12 @@ static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int re
// 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"); }
+ if ((count == 0) || (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"); }
+ if ((count == 0) || (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);
}
@@ -7446,10 +7523,17 @@ static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req
out = (stbi_uc *) stbi__malloc_mad4(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0);
if (!out) return stbi__errpuc("outofmem", "Out of memory");
- stbi__getn(s, out, s->img_n * s->img_x * s->img_y * (ri->bits_per_channel / 8));
+ if (!stbi__getn(s, out, s->img_n * s->img_x * s->img_y * (ri->bits_per_channel / 8))) {
+ STBI_FREE(out);
+ return stbi__errpuc("bad PNM", "PNM file truncated");
+ }
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 (ri->bits_per_channel == 16) {
+ out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, s->img_n, req_comp, s->img_x, s->img_y);
+ } else {
+ 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;
@@ -7486,6 +7570,8 @@ static int stbi__pnm_getinteger(stbi__context *s, char *c)
while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) {
value = value*10 + (*c - '0');
*c = (char) stbi__get8(s);
+ if((value > 214748364) || (value == 214748364 && *c > '7'))
+ return stbi__err("integer parse overflow", "Parsing an integer in the PPM header overflowed a 32-bit int");
}
return value;
@@ -7516,9 +7602,13 @@ static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp)
stbi__pnm_skip_whitespace(s, &c);
*x = stbi__pnm_getinteger(s, &c); // read width
+ if(*x == 0)
+ return stbi__err("invalid width", "PPM image header had zero or overflowing width");
stbi__pnm_skip_whitespace(s, &c);
*y = stbi__pnm_getinteger(s, &c); // read height
+ if (*y == 0)
+ return stbi__err("invalid width", "PPM image header had zero or overflowing width");
stbi__pnm_skip_whitespace(s, &c);
maxv = stbi__pnm_getinteger(s, &c); // read max value
diff --git a/src/external/stb_vorbis.h b/src/external/stb_vorbis.c
similarity index 68%
rename from src/external/stb_vorbis.h
rename to src/external/stb_vorbis.c
index 2fcbc4afc..3e5c2504c 100644
--- a/src/external/stb_vorbis.h
+++ b/src/external/stb_vorbis.c
@@ -1,4 +1,4 @@
-// Ogg Vorbis audio decoder - v1.14 - public domain
+// Ogg Vorbis audio decoder - v1.22 - public domain
// http://nothings.org/stb_vorbis/
//
// Original version written by Sean Barrett in 2007.
@@ -26,18 +26,29 @@
// Terje Mathisen Niklas Frykholm Andy Hill
// Casey Muratori John Bolton Gargaj
// Laurent Gomila Marc LeBlanc Ronny Chevalier
-// Bernhard Wodo Evan Balster alxprd@github
+// Bernhard Wodo Evan Balster github:alxprd
// Tom Beaumont Ingo Leitgeb Nicolas Guillemot
// Phillip Bennefall Rohit Thiago Goulart
-// manxorist@github saga musix github:infatum
-// Timur Gagiev BareRose
+// github:manxorist Saga Musix github:infatum
+// Timur Gagiev Maxwell Koo Peter Waller
+// github:audinowho Dougall Johnson David Reid
+// github:Clownacy Pedro J. Estebanez Remi Verschelde
+// AnthoFoxo github:morlat Gabriel Ravier
//
// Partial history:
+// 1.22 - 2021-07-11 - various small fixes
+// 1.21 - 2021-07-02 - fix bug for files with no comments
+// 1.20 - 2020-07-11 - several small fixes
+// 1.19 - 2020-02-05 - warnings
+// 1.18 - 2020-02-02 - fix seek bugs; parse header comments; misc warnings etc.
+// 1.17 - 2019-07-08 - fix CVE-2019-13217..CVE-2019-13223 (by ForAllSecure)
+// 1.16 - 2019-03-04 - fix warnings
+// 1.15 - 2019-02-07 - explicit failure if Ogg Skeleton data is found
// 1.14 - 2018-02-11 - delete bogus dealloca usage
// 1.13 - 2018-01-29 - fix truncation of last frame (hopefully)
// 1.12 - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files
-// 1.11 - 2017-07-23 - fix MinGW compilation
-// 1.10 - 2017-03-03 - more robust seeking; fix negative stbv_ilog(); clear error in open_memory
+// 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
@@ -64,28 +75,17 @@
#define STB_VORBIS_INCLUDE_STB_VORBIS_H
#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO)
-#define STB_VORBIS_NO_STDIO
+#define STB_VORBIS_NO_STDIO 1
#endif
#ifndef STB_VORBIS_NO_STDIO
#include
#endif
-// NOTE: Added to work with raylib on Android
-#if defined(PLATFORM_ANDROID)
- #include "utils.h" // Android fopen function map
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
-#ifdef STB_VORBIS_STATIC
-#define STBVDEF static
-#else
-#define STBVDEF extern
-#endif
-
/////////// THREAD SAFETY
// Individual stb_vorbis* handles are not thread-safe; you cannot decode from
@@ -101,8 +101,8 @@ extern "C" {
// 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 (stbv_setup_malloc,
-// stbv_setup_temp_malloc, temp_malloc) to change this behavior, or you
+// 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
@@ -138,25 +138,36 @@ typedef struct
int max_frame_size;
} stb_vorbis_info;
+typedef struct
+{
+ char *vendor;
+
+ int comment_list_length;
+ char **comment_list;
+} stb_vorbis_comment;
+
// get general information about the file
-STBVDEF stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f);
+extern stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f);
+
+// get ogg comments
+extern stb_vorbis_comment stb_vorbis_get_comment(stb_vorbis *f);
// get the last error detected (clears it, too)
-STBVDEF int stb_vorbis_get_error(stb_vorbis *f);
+extern int stb_vorbis_get_error(stb_vorbis *f);
// close an ogg vorbis file and free all memory in use
-STBVDEF void stb_vorbis_close(stb_vorbis *f);
+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
-STBVDEF int stb_vorbis_get_sample_offset(stb_vorbis *f);
+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.
-STBVDEF unsigned int stb_vorbis_get_file_offset(stb_vorbis *f);
+extern unsigned int stb_vorbis_get_file_offset(stb_vorbis *f);
/////////// PUSHDATA API
@@ -169,7 +180,7 @@ STBVDEF unsigned int stb_vorbis_get_file_offset(stb_vorbis *f);
// need to give it the same data again PLUS more. Note that the Vorbis
// specification does not bound the size of an individual frame.
-STBVDEF stb_vorbis *stb_vorbis_open_pushdata(
+extern stb_vorbis *stb_vorbis_open_pushdata(
const unsigned char * datablock, int datablock_length_in_bytes,
int *datablock_memory_consumed_in_bytes,
int *error,
@@ -183,7 +194,7 @@ STBVDEF stb_vorbis *stb_vorbis_open_pushdata(
// 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
-STBVDEF int stb_vorbis_decode_frame_pushdata(
+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
@@ -212,8 +223,14 @@ STBVDEF int stb_vorbis_decode_frame_pushdata(
// 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.
+//
+// *output points into stb_vorbis's internal output buffer storage; these
+// buffers are owned by stb_vorbis and application code should not free
+// them or modify their contents. They are transient and will be overwritten
+// once you ask for more data to get decoded, so be sure to grab any data
+// you need before then.
-STBVDEF void stb_vorbis_flush_pushdata(stb_vorbis *f);
+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
@@ -238,38 +255,38 @@ STBVDEF void stb_vorbis_flush_pushdata(stb_vorbis *f);
// just want to go ahead and use pushdata.)
#if !defined(STB_VORBIS_NO_STDIO) && !defined(STB_VORBIS_NO_INTEGER_CONVERSION)
-STBVDEF int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output);
+extern int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output);
#endif
-#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
-STBVDEF int stb_vorbis_decode_memory(const unsigned char *mem, int len, int *channels, int *sample_rate, short **output);
+#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.
-STBVDEF stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len,
+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
-STBVDEF stb_vorbis * stb_vorbis_open_filename(const char *filename,
+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).
-STBVDEF stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close,
+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
+// calls to stb_vorbis, it will become confused. Moreover, 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.
-STBVDEF stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_close,
+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.
@@ -278,8 +295,8 @@ STBVDEF stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_c
// confused.
#endif
-STBVDEF int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number);
-STBVDEF int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number);
+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
@@ -287,14 +304,14 @@ STBVDEF int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number);
// do not need to seek to EXACTLY the target sample when using get_samples_*,
// you can also use seek_frame().
-STBVDEF int stb_vorbis_seek_start(stb_vorbis *f);
+extern int stb_vorbis_seek_start(stb_vorbis *f);
// this function is equivalent to stb_vorbis_seek(f,0)
-STBVDEF unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f);
-STBVDEF float stb_vorbis_stream_length_in_seconds(stb_vorbis *f);
+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
-STBVDEF int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output);
+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
@@ -305,8 +322,8 @@ STBVDEF int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***ou
// and stb_vorbis_get_samples_*(), since the latter calls the former.
#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
-STBVDEF int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts);
-STBVDEF int stb_vorbis_get_frame_short (stb_vorbis *f, int num_c, short **buffer, int num_samples);
+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
@@ -333,16 +350,16 @@ STBVDEF int stb_vorbis_get_frame_short (stb_vorbis *f, int num_c, sho
// Note that this is not _good_ surround etc. mixing at all! It's just so
// you get something useful.
-STBVDEF int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats);
-STBVDEF int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples);
+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
-STBVDEF int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts);
-STBVDEF int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int num_samples);
+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
@@ -385,7 +402,8 @@ enum STBVorbisError
VORBIS_invalid_first_page,
VORBIS_bad_packet_type,
VORBIS_cant_find_last_page,
- VORBIS_seek_failed
+ VORBIS_seek_failed,
+ VORBIS_ogg_skeleton_not_supported
};
@@ -399,7 +417,7 @@ enum STBVorbisError
//
//////////////////////////////////////////////////////////////////////////////
-#ifdef STB_VORBIS_IMPLEMENTATION
+#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
@@ -428,7 +446,7 @@ enum STBVorbisError
// 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
+//#define STB_VORBIS_NO_FAST_SCALED_FLOAT
// STB_VORBIS_MAX_CHANNELS [number]
@@ -570,7 +588,7 @@ enum STBVorbisError
#if defined(_MSC_VER) || defined(__MINGW32__)
#include
#endif
- #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) || defined(__APPLE__) || defined(__CYGWIN__)
+ #if defined(__linux__) || defined(__linux) || defined(__sun__) || defined(__EMSCRIPTEN__) || defined(__NEWLIB__)
#include
#endif
#else // STB_VORBIS_NO_CRT
@@ -593,7 +611,7 @@ enum STBVorbisError
#endif
#define __forceinline
#ifndef alloca
- #define alloca(s) __builtin_alloca(s)
+ #define alloca __builtin_alloca
#endif
#elif !defined(_MSC_VER)
#if __GNUC__
@@ -614,28 +632,34 @@ enum STBVorbisError
#if 0
#include
-#define STBV_CHECK(f) _CrtIsValidHeapPointer(f->channel_buffers[1])
+#define CHECK(f) _CrtIsValidHeapPointer(f->channel_buffers[1])
#else
-#define STBV_CHECK(f) ((void) 0)
+#define CHECK(f) ((void) 0)
#endif
-#define STBV_MAX_BLOCKSIZE_LOG 13 // from specification
-#define STBV_MAX_BLOCKSIZE (1 << STBV_MAX_BLOCKSIZE_LOG)
+#define MAX_BLOCKSIZE_LOG 13 // from specification
+#define MAX_BLOCKSIZE (1 << MAX_BLOCKSIZE_LOG)
-typedef unsigned char stbv_uint8;
-typedef signed char stbv_int8;
-typedef unsigned short stbv_uint16;
-typedef signed short stbv_int16;
-typedef unsigned int stbv_uint32;
-typedef signed int stbv_int32;
+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 stbv_codetype;
+typedef float codetype;
+
+#ifdef _MSC_VER
+#define STBV_NOTUSED(v) (void)(v)
+#else
+#define STBV_NOTUSED(v) (void)sizeof(v)
+#endif
// @NOTE
//
@@ -650,113 +674,113 @@ typedef float stbv_codetype;
// the sizes larger--nothing relies on silently truncating etc., nor the
// order of variables.
-#define STBV_FAST_HUFFMAN_TABLE_SIZE (1 << STB_VORBIS_FAST_HUFFMAN_LENGTH)
-#define STBV_FAST_HUFFMAN_TABLE_MASK (STBV_FAST_HUFFMAN_TABLE_SIZE - 1)
+#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;
- stbv_uint8 *codeword_lengths;
+ uint8 *codeword_lengths;
float minimum_value;
float delta_value;
- stbv_uint8 value_bits;
- stbv_uint8 lookup_type;
- stbv_uint8 sequence_p;
- stbv_uint8 sparse;
- stbv_uint32 lookup_values;
- stbv_codetype *multiplicands;
- stbv_uint32 *codewords;
+ uint8 value_bits;
+ uint8 lookup_type;
+ uint8 sequence_p;
+ uint8 sparse;
+ uint32 lookup_values;
+ codetype *multiplicands;
+ uint32 *codewords;
#ifdef STB_VORBIS_FAST_HUFFMAN_SHORT
- stbv_int16 fast_huffman[STBV_FAST_HUFFMAN_TABLE_SIZE];
+ int16 fast_huffman[FAST_HUFFMAN_TABLE_SIZE];
#else
- stbv_int32 fast_huffman[STBV_FAST_HUFFMAN_TABLE_SIZE];
+ int32 fast_huffman[FAST_HUFFMAN_TABLE_SIZE];
#endif
- stbv_uint32 *sorted_codewords;
+ uint32 *sorted_codewords;
int *sorted_values;
int sorted_entries;
-} StbvCodebook;
+} Codebook;
typedef struct
{
- stbv_uint8 order;
- stbv_uint16 rate;
- stbv_uint16 bark_map_size;
- stbv_uint8 amplitude_bits;
- stbv_uint8 amplitude_offset;
- stbv_uint8 number_of_books;
- stbv_uint8 book_list[16]; // varies
-} StbvFloor0;
+ 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
{
- stbv_uint8 partitions;
- stbv_uint8 partition_class_list[32]; // varies
- stbv_uint8 class_dimensions[16]; // varies
- stbv_uint8 class_subclasses[16]; // varies
- stbv_uint8 class_masterbooks[16]; // varies
- stbv_int16 subclass_books[16][8]; // varies
- stbv_uint16 Xlist[31*8+2]; // varies
- stbv_uint8 sorted_order[31*8+2];
- stbv_uint8 stbv_neighbors[31*8+2][2];
- stbv_uint8 floor1_multiplier;
- stbv_uint8 rangebits;
+ 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;
-} StbvFloor1;
+} Floor1;
typedef union
{
- StbvFloor0 floor0;
- StbvFloor1 floor1;
-} StbvFloor;
+ Floor0 floor0;
+ Floor1 floor1;
+} Floor;
typedef struct
{
- stbv_uint32 begin, end;
- stbv_uint32 part_size;
- stbv_uint8 classifications;
- stbv_uint8 classbook;
- stbv_uint8 **classdata;
- stbv_int16 (*residue_books)[8];
-} StbvResidue;
+ uint32 begin, end;
+ uint32 part_size;
+ uint8 classifications;
+ uint8 classbook;
+ uint8 **classdata;
+ int16 (*residue_books)[8];
+} Residue;
typedef struct
{
- stbv_uint8 magnitude;
- stbv_uint8 angle;
- stbv_uint8 mux;
-} StbvMappingChannel;
+ uint8 magnitude;
+ uint8 angle;
+ uint8 mux;
+} MappingChannel;
typedef struct
{
- stbv_uint16 coupling_steps;
- StbvMappingChannel *chan;
- stbv_uint8 submaps;
- stbv_uint8 submap_floor[15]; // varies
- stbv_uint8 submap_residue[15]; // varies
-} StbvMapping;
+ uint16 coupling_steps;
+ MappingChannel *chan;
+ uint8 submaps;
+ uint8 submap_floor[15]; // varies
+ uint8 submap_residue[15]; // varies
+} Mapping;
typedef struct
{
- stbv_uint8 blockflag;
- stbv_uint8 mapping;
- stbv_uint16 windowtype;
- stbv_uint16 transformtype;
-} StbvMode;
+ uint8 blockflag;
+ uint8 mapping;
+ uint16 windowtype;
+ uint16 transformtype;
+} Mode;
typedef struct
{
- stbv_uint32 goal_crc; // expected crc if match
+ uint32 goal_crc; // expected crc if match
int bytes_left; // bytes left in packet
- stbv_uint32 crc_so_far; // running crc
+ uint32 crc_so_far; // running crc
int bytes_done; // bytes processed in _current_ chunk
- stbv_uint32 sample_loc; // granule pos encoded in page
-} StbvCRCscan;
+ uint32 sample_loc; // granule pos encoded in page
+} CRCscan;
typedef struct
{
- stbv_uint32 page_start, page_end;
- stbv_uint32 last_decoded_sample;
-} StbvProbedPage;
+ uint32 page_start, page_end;
+ uint32 last_decoded_sample;
+} ProbedPage;
struct stb_vorbis
{
@@ -768,24 +792,31 @@ struct stb_vorbis
unsigned int temp_memory_required;
unsigned int setup_temp_memory_required;
+ char *vendor;
+ int comment_list_length;
+ char **comment_list;
+
// input config
#ifndef STB_VORBIS_NO_STDIO
FILE *f;
- stbv_uint32 f_start;
+ uint32 f_start;
int close_on_free;
#endif
- stbv_uint8 *stream;
- stbv_uint8 *stream_start;
- stbv_uint8 *stream_end;
+ uint8 *stream;
+ uint8 *stream_start;
+ uint8 *stream_end;
- stbv_uint32 stream_len;
+ uint32 stream_len;
- stbv_uint8 push_mode;
+ uint8 push_mode;
- stbv_uint32 first_audio_page_offset;
+ // the page to seek to when seeking to start, may be zero
+ uint32 first_audio_page_offset;
- StbvProbedPage p_first, p_last;
+ // p_first is the page on which the first audio packet ends
+ // (but not necessarily the page on which it starts)
+ ProbedPage p_first, p_last;
// memory management
stb_vorbis_alloc alloc;
@@ -802,19 +833,19 @@ struct stb_vorbis
int blocksize[2];
int blocksize_0, blocksize_1;
int codebook_count;
- StbvCodebook *codebooks;
+ Codebook *codebooks;
int floor_count;
- stbv_uint16 floor_types[64]; // varies
- StbvFloor *floor_config;
+ uint16 floor_types[64]; // varies
+ Floor *floor_config;
int residue_count;
- stbv_uint16 residue_types[64]; // varies
- StbvResidue *residue_config;
+ uint16 residue_types[64]; // varies
+ Residue *residue_config;
int mapping_count;
- StbvMapping *mapping;
+ Mapping *mapping;
int mode_count;
- StbvMode mode_config[64]; // varies
+ Mode mode_config[64]; // varies
- stbv_uint32 total_samples;
+ uint32 total_samples;
// decode buffer
float *channel_buffers[STB_VORBIS_MAX_CHANNELS];
@@ -824,44 +855,44 @@ struct stb_vorbis
int previous_length;
#ifndef STB_VORBIS_NO_DEFER_FLOOR
- stbv_int16 *finalY[STB_VORBIS_MAX_CHANNELS];
+ int16 *finalY[STB_VORBIS_MAX_CHANNELS];
#else
float *floor_buffers[STB_VORBIS_MAX_CHANNELS];
#endif
- stbv_uint32 current_loc; // sample location of next frame to decode
+ 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];
- stbv_uint16 *stbv_bit_reverse[2];
+ uint16 *bit_reverse[2];
// current page/packet/segment streaming info
- stbv_uint32 serial; // stream serial number for verification
+ uint32 serial; // stream serial number for verification
int last_page;
int segment_count;
- stbv_uint8 segments[255];
- stbv_uint8 page_flag;
- stbv_uint8 bytes_in_seg;
- stbv_uint8 first_decode;
+ 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?
- stbv_uint32 acc;
+ uint32 acc;
int valid_bits;
int packet_bytes;
int end_seg_with_known_loc;
- stbv_uint32 known_loc_for_packet;
+ uint32 known_loc_for_packet;
int discard_samples_deferred;
- stbv_uint32 samples_output;
+ 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
- StbvCRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT];
+ CRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT];
#endif
// sample-access
@@ -870,16 +901,16 @@ struct stb_vorbis
};
#if defined(STB_VORBIS_NO_PUSHDATA_API)
- #define STBV_IS_PUSH_MODE(f) FALSE
+ #define IS_PUSH_MODE(f) FALSE
#elif defined(STB_VORBIS_NO_PULLDATA_API)
- #define STBV_IS_PUSH_MODE(f) TRUE
+ #define IS_PUSH_MODE(f) TRUE
#else
- #define STBV_IS_PUSH_MODE(f) ((f)->push_mode)
+ #define IS_PUSH_MODE(f) ((f)->push_mode)
#endif
-typedef struct stb_vorbis stbv_vorb;
+typedef struct stb_vorbis vorb;
-static int stbv_error(stbv_vorb *f, enum STBVorbisError e)
+static int error(vorb *f, enum STBVorbisError e)
{
f->error = e;
if (!f->eof && e != VORBIS_need_more_data) {
@@ -894,17 +925,17 @@ static int stbv_error(stbv_vorb *f, enum STBVorbisError e)
// alloca(); otherwise, provide a temp buffer and it will
// allocate out of those.
-#define stbv_array_size_required(count,size) (count*(sizeof(void *)+(size)))
+#define array_size_required(count,size) (count*(sizeof(void *)+(size)))
-#define stbv_temp_alloc(f,size) (f->alloc.alloc_buffer ? stbv_setup_temp_malloc(f,size) : alloca(size))
-#define stbv_temp_free(f,p) 0
-#define stbv_temp_alloc_save(f) ((f)->temp_offset)
-#define stbv_temp_alloc_restore(f,p) ((f)->temp_offset = (p))
+#define temp_alloc(f,size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size))
+#define temp_free(f,p) (void)0
+#define temp_alloc_save(f) ((f)->temp_offset)
+#define temp_alloc_restore(f,p) ((f)->temp_offset = (p))
-#define stbv_temp_block_array(f,count,size) stbv_make_block_array(stbv_temp_alloc(f,stbv_array_size_required(count,size)), count, size)
+#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 *stbv_make_block_array(void *mem, int count, int size)
+static void *make_block_array(void *mem, int count, int size)
{
int i;
void ** p = (void **) mem;
@@ -916,9 +947,9 @@ static void *stbv_make_block_array(void *mem, int count, int size)
return p;
}
-static void *stbv_setup_malloc(stbv_vorb *f, int sz)
+static void *setup_malloc(vorb *f, int sz)
{
- sz = (sz+3) & ~3;
+ sz = (sz+7) & ~7; // round up to nearest 8 for alignment of future allocs.
f->setup_memory_required += sz;
if (f->alloc.alloc_buffer) {
void *p = (char *) f->alloc.alloc_buffer + f->setup_offset;
@@ -929,15 +960,15 @@ static void *stbv_setup_malloc(stbv_vorb *f, int sz)
return sz ? malloc(sz) : NULL;
}
-static void stbv_setup_free(stbv_vorb *f, void *p)
+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 *stbv_setup_temp_malloc(stbv_vorb *f, int sz)
+static void *setup_temp_malloc(vorb *f, int sz)
{
- sz = (sz+3) & ~3;
+ sz = (sz+7) & ~7; // round up to nearest 8 for alignment of future allocs.
if (f->alloc.alloc_buffer) {
if (f->temp_offset - sz < f->setup_offset) return NULL;
f->temp_offset -= sz;
@@ -946,37 +977,37 @@ static void *stbv_setup_temp_malloc(stbv_vorb *f, int sz)
return malloc(sz);
}
-static void stbv_setup_temp_free(stbv_vorb *f, void *p, int sz)
+static void setup_temp_free(vorb *f, void *p, int sz)
{
if (f->alloc.alloc_buffer) {
- f->temp_offset += (sz+3)&~3;
+ f->temp_offset += (sz+7)&~7;
return;
}
free(p);
}
-#define STBV_CRC32_POLY 0x04c11db7 // from spec
+#define CRC32_POLY 0x04c11db7 // from spec
-static stbv_uint32 stbv_crc_table[256];
-static void stbv_crc32_init(void)
+static uint32 crc_table[256];
+static void crc32_init(void)
{
int i,j;
- stbv_uint32 s;
+ uint32 s;
for(i=0; i < 256; i++) {
- for (s=(stbv_uint32) i << 24, j=0; j < 8; ++j)
- s = (s << 1) ^ (s >= (1U<<31) ? STBV_CRC32_POLY : 0);
- stbv_crc_table[i] = s;
+ 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 stbv_uint32 stbv_crc32_update(stbv_uint32 crc, stbv_uint8 byte)
+static __forceinline uint32 crc32_update(uint32 crc, uint8 byte)
{
- return (crc << 8) ^ stbv_crc_table[byte ^ (crc >> 24)];
+ return (crc << 8) ^ crc_table[byte ^ (crc >> 24)];
}
// used in setup, and for huffman that doesn't go fast path
-static unsigned int stbv_bit_reverse(unsigned int n)
+static unsigned int bit_reverse(unsigned int n)
{
n = ((n & 0xAAAAAAAA) >> 1) | ((n & 0x55555555) << 1);
n = ((n & 0xCCCCCCCC) >> 2) | ((n & 0x33333333) << 2);
@@ -985,7 +1016,7 @@ static unsigned int stbv_bit_reverse(unsigned int n)
return (n >> 16) | (n << 16);
}
-static float stbv_square(float x)
+static float square(float x)
{
return x*x;
}
@@ -993,7 +1024,7 @@ static float stbv_square(float 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 stbv_ilog(stbv_int32 n)
+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 };
@@ -1023,14 +1054,14 @@ static int stbv_ilog(stbv_int32 n)
// these functions are only called at setup, and only a few times
// per file
-static float stbv_float32_unpack(stbv_uint32 x)
+static float float32_unpack(uint32 x)
{
// from the specification
- stbv_uint32 mantissa = x & 0x1fffff;
- stbv_uint32 sign = x & 0x80000000;
- stbv_uint32 exp = (x & 0x7fe00000) >> 21;
+ 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);
+ return (float) ldexp((float)res, (int)exp-788);
}
@@ -1041,7 +1072,7 @@ static float stbv_float32_unpack(stbv_uint32 x)
// 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 stbv_add_entry(StbvCodebook *c, stbv_uint32 huff_code, int symbol, int count, int len, stbv_uint32 *values)
+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;
@@ -1052,17 +1083,18 @@ static void stbv_add_entry(StbvCodebook *c, stbv_uint32 huff_code, int symbol, i
}
}
-static int stbv_compute_codewords(StbvCodebook *c, stbv_uint8 *len, int n, stbv_uint32 *values)
+static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values)
{
int i,k,m=0;
- stbv_uint32 available[32];
+ 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; }
+ assert(len[k] < 32); // no error return required, code reading lens checks this
// add to the list
- stbv_add_entry(c, 0, k, m++, len[k], values);
+ 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);
@@ -1071,9 +1103,10 @@ static int stbv_compute_codewords(StbvCodebook *c, stbv_uint8 *len, int n, stbv_
// 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) {
- stbv_uint32 res;
+ uint32 res;
int z = len[i], y;
if (z == NO_CODE) continue;
+ assert(z < 32); // no error return required, code reading lens checks this
// 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
@@ -1083,12 +1116,10 @@ static int stbv_compute_codewords(StbvCodebook *c, stbv_uint8 *len, int n, stbv_
while (z > 0 && !available[z]) --z;
if (z == 0) { return FALSE; }
res = available[z];
- assert(z >= 0 && z < 32);
available[z] = 0;
- stbv_add_entry(c, stbv_bit_reverse(res), i, m++, len[i], values);
- // propogate availability up the tree
+ add_entry(c, bit_reverse(res), i, m++, len[i], values);
+ // propagate 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));
@@ -1100,10 +1131,10 @@ static int stbv_compute_codewords(StbvCodebook *c, stbv_uint8 *len, int n, stbv_
// accelerated huffman table allows fast O(1) match of all symbols
// of length <= STB_VORBIS_FAST_HUFFMAN_LENGTH
-static void stbv_compute_accelerated_huffman(StbvCodebook *c)
+static void compute_accelerated_huffman(Codebook *c)
{
int i, len;
- for (i=0; i < STBV_FAST_HUFFMAN_TABLE_SIZE; ++i)
+ for (i=0; i < FAST_HUFFMAN_TABLE_SIZE; ++i)
c->fast_huffman[i] = -1;
len = c->sparse ? c->sorted_entries : c->entries;
@@ -1112,9 +1143,9 @@ static void stbv_compute_accelerated_huffman(StbvCodebook *c)
#endif
for (i=0; i < len; ++i) {
if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) {
- stbv_uint32 z = c->sparse ? stbv_bit_reverse(c->sorted_codewords[i]) : c->codewords[i];
+ 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 < STBV_FAST_HUFFMAN_TABLE_SIZE) {
+ while (z < FAST_HUFFMAN_TABLE_SIZE) {
c->fast_huffman[z] = i;
z += 1 << c->codeword_lengths[i];
}
@@ -1128,14 +1159,14 @@ static void stbv_compute_accelerated_huffman(StbvCodebook *c)
#define STBV_CDECL
#endif
-static int STBV_CDECL stbv_uint32_compare(const void *p, const void *q)
+static int STBV_CDECL uint32_compare(const void *p, const void *q)
{
- stbv_uint32 x = * (stbv_uint32 *) p;
- stbv_uint32 y = * (stbv_uint32 *) q;
+ uint32 x = * (uint32 *) p;
+ uint32 y = * (uint32 *) q;
return x < y ? -1 : x > y;
}
-static int stbv_include_in_sort(StbvCodebook *c, stbv_uint8 len)
+static int include_in_sort(Codebook *c, uint8 len)
{
if (c->sparse) { assert(len != NO_CODE); return TRUE; }
if (len == NO_CODE) return FALSE;
@@ -1145,7 +1176,7 @@ static int stbv_include_in_sort(StbvCodebook *c, stbv_uint8 len)
// if the fast table above doesn't work, we want to binary
// search them... need to reverse the bits
-static void stbv_compute_sorted_huffman(StbvCodebook *c, stbv_uint8 *lengths, stbv_uint32 *values)
+static void compute_sorted_huffman(Codebook *c, uint8 *lengths, uint32 *values)
{
int i, len;
// build a list of all the entries
@@ -1155,15 +1186,15 @@ static void stbv_compute_sorted_huffman(StbvCodebook *c, stbv_uint8 *lengths, st
if (!c->sparse) {
int k = 0;
for (i=0; i < c->entries; ++i)
- if (stbv_include_in_sort(c, lengths[i]))
- c->sorted_codewords[k++] = stbv_bit_reverse(c->codewords[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] = stbv_bit_reverse(c->codewords[i]);
+ c->sorted_codewords[i] = bit_reverse(c->codewords[i]);
}
- qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]), stbv_uint32_compare);
+ 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;
@@ -1174,8 +1205,8 @@ static void stbv_compute_sorted_huffman(StbvCodebook *c, stbv_uint8 *lengths, st
// #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 (stbv_include_in_sort(c,huff_len)) {
- stbv_uint32 code = stbv_bit_reverse(c->codewords[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]
@@ -1199,26 +1230,28 @@ static void stbv_compute_sorted_huffman(StbvCodebook *c, stbv_uint8 *lengths, st
}
// only run while parsing the header (3 times)
-static int stbv_vorbis_validate(stbv_uint8 *data)
+static int vorbis_validate(uint8 *data)
{
- static stbv_uint8 vorbis[6] = { 'v', 'o', 'r', 'b', 'i', 's' };
+ 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 stbv_lookup1_values(int entries, int dim)
+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
+ if (pow((float) r+1, dim) <= entries)
+ return -1;
+ if ((int) floor(pow((float) r, dim)) > entries)
+ return -1;
return r;
}
// called twice per file
-static void stbv_compute_twiddle_factors(int n, float *A, float *B, float *C)
+static void compute_twiddle_factors(int n, float *A, float *B, float *C)
{
int n4 = n >> 2, n8 = n >> 3;
int k,k2;
@@ -1235,39 +1268,39 @@ static void stbv_compute_twiddle_factors(int n, float *A, float *B, float *C)
}
}
-static void stbv_compute_window(int n, float *window)
+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 * stbv_square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI)));
+ window[i] = (float) sin(0.5 * M_PI * square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI)));
}
-static void stbv_compute_bitreverse(int n, stbv_uint16 *rev)
+static void compute_bitreverse(int n, uint16 *rev)
{
- int ld = stbv_ilog(n) - 1; // stbv_ilog is off-by-one from normal definitions
+ 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] = (stbv_bit_reverse(i) >> (32-ld+3)) << 2;
+ rev[i] = (bit_reverse(i) >> (32-ld+3)) << 2;
}
-static int stbv_init_blocksize(stbv_vorb *f, int b, int n)
+static int init_blocksize(vorb *f, int b, int n)
{
int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3;
- f->A[b] = (float *) stbv_setup_malloc(f, sizeof(float) * n2);
- f->B[b] = (float *) stbv_setup_malloc(f, sizeof(float) * n2);
- f->C[b] = (float *) stbv_setup_malloc(f, sizeof(float) * n4);
- if (!f->A[b] || !f->B[b] || !f->C[b]) return stbv_error(f, VORBIS_outofmem);
- stbv_compute_twiddle_factors(n, f->A[b], f->B[b], f->C[b]);
- f->window[b] = (float *) stbv_setup_malloc(f, sizeof(float) * n2);
- if (!f->window[b]) return stbv_error(f, VORBIS_outofmem);
- stbv_compute_window(n, f->window[b]);
- f->stbv_bit_reverse[b] = (stbv_uint16 *) stbv_setup_malloc(f, sizeof(stbv_uint16) * n8);
- if (!f->stbv_bit_reverse[b]) return stbv_error(f, VORBIS_outofmem);
- stbv_compute_bitreverse(n, f->stbv_bit_reverse[b]);
+ 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 stbv_neighbors(stbv_uint16 *x, int n, int *plow, int *phigh)
+static void neighbors(uint16 *x, int n, int *plow, int *phigh)
{
int low = -1;
int high = 65536;
@@ -1281,13 +1314,13 @@ static void stbv_neighbors(stbv_uint16 *x, int n, int *plow, int *phigh)
// this has been repurposed so y is now the original index instead of y
typedef struct
{
- stbv_uint16 x,id;
-} stbv_floor_ordering;
+ uint16 x,id;
+} stbv__floor_ordering;
-static int STBV_CDECL stbv_point_compare(const void *p, const void *q)
+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;
+ 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;
}
@@ -1296,14 +1329,14 @@ static int STBV_CDECL stbv_point_compare(const void *p, const void *q)
#if defined(STB_VORBIS_NO_STDIO)
- #define STBV_USE_MEMORY(z) TRUE
+ #define USE_MEMORY(z) TRUE
#else
- #define STBV_USE_MEMORY(z) ((z)->stream)
+ #define USE_MEMORY(z) ((z)->stream)
#endif
-static stbv_uint8 stbv_get8(stbv_vorb *z)
+static uint8 get8(vorb *z)
{
- if (STBV_USE_MEMORY(z)) {
+ if (USE_MEMORY(z)) {
if (z->stream >= z->stream_end) { z->eof = TRUE; return 0; }
return *z->stream++;
}
@@ -1317,26 +1350,26 @@ static stbv_uint8 stbv_get8(stbv_vorb *z)
#endif
}
-static stbv_uint32 stbv_get32(stbv_vorb *f)
+static uint32 get32(vorb *f)
{
- stbv_uint32 x;
- x = stbv_get8(f);
- x += stbv_get8(f) << 8;
- x += stbv_get8(f) << 16;
- x += (stbv_uint32) stbv_get8(f) << 24;
+ uint32 x;
+ x = get8(f);
+ x += get8(f) << 8;
+ x += get8(f) << 16;
+ x += (uint32) get8(f) << 24;
return x;
}
-static int stbv_getn(stbv_vorb *z, stbv_uint8 *data, int n)
+static int getn(vorb *z, uint8 *data, int n)
{
- if (STBV_USE_MEMORY(z)) {
+ 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
+ #ifndef STB_VORBIS_NO_STDIO
if (fread(data, n, 1, z->f) == 1)
return 1;
else {
@@ -1346,9 +1379,9 @@ static int stbv_getn(stbv_vorb *z, stbv_uint8 *data, int n)
#endif
}
-static void stbv_skip(stbv_vorb *z, int n)
+static void skip(vorb *z, int n)
{
- if (STBV_USE_MEMORY(z)) {
+ if (USE_MEMORY(z)) {
z->stream += n;
if (z->stream >= z->stream_end) z->eof = 1;
return;
@@ -1361,13 +1394,13 @@ static void stbv_skip(stbv_vorb *z, int n)
#endif
}
-static int stbv_set_file_offset(stb_vorbis *f, unsigned int loc)
+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 (STBV_USE_MEMORY(f)) {
+ 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;
@@ -1393,44 +1426,47 @@ static int stbv_set_file_offset(stb_vorbis *f, unsigned int loc)
}
-static stbv_uint8 stbv_ogg_page_header[4] = { 0x4f, 0x67, 0x67, 0x53 };
+static uint8 ogg_page_header[4] = { 0x4f, 0x67, 0x67, 0x53 };
-static int stbv_capture_pattern(stbv_vorb *f)
+static int capture_pattern(vorb *f)
{
- if (0x4f != stbv_get8(f)) return FALSE;
- if (0x67 != stbv_get8(f)) return FALSE;
- if (0x67 != stbv_get8(f)) return FALSE;
- if (0x53 != stbv_get8(f)) return FALSE;
+ 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 STBV_PAGEFLAG_continued_packet 1
-#define STBV_PAGEFLAG_first_page 2
-#define STBV_PAGEFLAG_last_page 4
+#define PAGEFLAG_continued_packet 1
+#define PAGEFLAG_first_page 2
+#define PAGEFLAG_last_page 4
-static int stbv_start_page_no_capturepattern(stbv_vorb *f)
+static int start_page_no_capturepattern(vorb *f)
{
- stbv_uint32 loc0,loc1,n;
+ uint32 loc0,loc1,n;
+ if (f->first_decode && !IS_PUSH_MODE(f)) {
+ f->p_first.page_start = stb_vorbis_get_file_offset(f) - 4;
+ }
// stream structure version
- if (0 != stbv_get8(f)) return stbv_error(f, VORBIS_invalid_stream_structure_version);
+ if (0 != get8(f)) return error(f, VORBIS_invalid_stream_structure_version);
// header flag
- f->page_flag = stbv_get8(f);
+ f->page_flag = get8(f);
// absolute granule position
- loc0 = stbv_get32(f);
- loc1 = stbv_get32(f);
+ loc0 = get32(f);
+ loc1 = get32(f);
// @TODO: validate loc0,loc1 as valid positions?
// stream serial number -- vorbis doesn't interleave, so discard
- stbv_get32(f);
- //if (f->serial != stbv_get32(f)) return stbv_error(f, VORBIS_incorrect_stream_serial_number);
+ get32(f);
+ //if (f->serial != get32(f)) return error(f, VORBIS_incorrect_stream_serial_number);
// page sequence number
- n = stbv_get32(f);
+ n = get32(f);
f->last_page = n;
// CRC32
- stbv_get32(f);
+ get32(f);
// page_segments
- f->segment_count = stbv_get8(f);
- if (!stbv_getn(f, f->segments, f->segment_count))
- return stbv_error(f, VORBIS_unexpected_eof);
+ 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) {
@@ -1447,32 +1483,29 @@ static int stbv_start_page_no_capturepattern(stbv_vorb *f)
}
if (f->first_decode) {
int i,len;
- StbvProbedPage 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->p_first.page_end = f->p_first.page_start + len;
+ f->p_first.last_decoded_sample = loc0;
}
f->next_seg = 0;
return TRUE;
}
-static int stbv_start_page(stbv_vorb *f)
+static int start_page(vorb *f)
{
- if (!stbv_capture_pattern(f)) return stbv_error(f, VORBIS_missing_capture_pattern);
- return stbv_start_page_no_capturepattern(f);
+ if (!capture_pattern(f)) return error(f, VORBIS_missing_capture_pattern);
+ return start_page_no_capturepattern(f);
}
-static int stbv_start_packet(stbv_vorb *f)
+static int start_packet(vorb *f)
{
while (f->next_seg == -1) {
- if (!stbv_start_page(f)) return FALSE;
- if (f->page_flag & STBV_PAGEFLAG_continued_packet)
- return stbv_error(f, VORBIS_continued_packet_flag_invalid);
+ 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;
@@ -1482,35 +1515,35 @@ static int stbv_start_packet(stbv_vorb *f)
return TRUE;
}
-static int stbv_maybe_start_packet(stbv_vorb *f)
+static int maybe_start_packet(vorb *f)
{
if (f->next_seg == -1) {
- int x = stbv_get8(f);
+ int x = get8(f);
if (f->eof) return FALSE; // EOF at page boundary is not an error!
- if (0x4f != x ) return stbv_error(f, VORBIS_missing_capture_pattern);
- if (0x67 != stbv_get8(f)) return stbv_error(f, VORBIS_missing_capture_pattern);
- if (0x67 != stbv_get8(f)) return stbv_error(f, VORBIS_missing_capture_pattern);
- if (0x53 != stbv_get8(f)) return stbv_error(f, VORBIS_missing_capture_pattern);
- if (!stbv_start_page_no_capturepattern(f)) return FALSE;
- if (f->page_flag & STBV_PAGEFLAG_continued_packet) {
+ 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 stbv_error(f, VORBIS_continued_packet_flag_invalid);
+ return error(f, VORBIS_continued_packet_flag_invalid);
}
}
- return stbv_start_packet(f);
+ return start_packet(f);
}
-static int stbv_next_segment(stbv_vorb *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 stbv_start_page fails
- if (!stbv_start_page(f)) { f->last_seg = 1; return 0; }
- if (!(f->page_flag & STBV_PAGEFLAG_continued_packet)) return stbv_error(f, VORBIS_continued_packet_flag_invalid);
+ 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) {
@@ -1524,59 +1557,70 @@ static int stbv_next_segment(stbv_vorb *f)
return len;
}
-#define STBV_EOP (-1)
-#define STBV_INVALID_BITS (-1)
+#define EOP (-1)
+#define INVALID_BITS (-1)
-static int stbv_get8_packet_raw(stbv_vorb *f)
+static int get8_packet_raw(vorb *f)
{
if (!f->bytes_in_seg) { // CLANG!
- if (f->last_seg) return STBV_EOP;
- else if (!stbv_next_segment(f)) return STBV_EOP;
+ 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 stbv_get8(f);
+ return get8(f);
}
-static int stbv_get8_packet(stbv_vorb *f)
+static int get8_packet(vorb *f)
{
- int x = stbv_get8_packet_raw(f);
+ int x = get8_packet_raw(f);
f->valid_bits = 0;
return x;
}
-static void stbv_flush_packet(stbv_vorb *f)
+static int get32_packet(vorb *f)
{
- while (stbv_get8_packet_raw(f) != STBV_EOP);
+ uint32 x;
+ x = get8_packet(f);
+ x += get8_packet(f) << 8;
+ x += get8_packet(f) << 16;
+ x += (uint32) get8_packet(f) << 24;
+ 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 stbv_uint32 stbv_get_bits(stbv_vorb *f, int n)
+static uint32 get_bits(vorb *f, int n)
{
- stbv_uint32 z;
+ 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 = stbv_get_bits(f, 24);
- z += stbv_get_bits(f, n-24) << 24;
+ 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 = stbv_get8_packet_raw(f);
- if (z == STBV_EOP) {
- f->valid_bits = STBV_INVALID_BITS;
+ 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;
+
+ assert(f->valid_bits >= n);
z = f->acc & ((1 << n)-1);
f->acc >>= n;
f->valid_bits -= n;
@@ -1587,15 +1631,15 @@ static stbv_uint32 stbv_get_bits(stbv_vorb *f, int n)
// 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 stbv_prep_huffman(stbv_vorb *f)
+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 = stbv_get8_packet_raw(f);
- if (z == STBV_EOP) 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);
@@ -1604,15 +1648,15 @@ static __forceinline void stbv_prep_huffman(stbv_vorb *f)
enum
{
- STBV_VORBIS_packet_id = 1,
- STBV_VORBIS_packet_comment = 3,
- STBV_VORBIS_packet_setup = 5
+ VORBIS_packet_id = 1,
+ VORBIS_packet_comment = 3,
+ VORBIS_packet_setup = 5
};
-static int stbv_codebook_decode_scalar_raw(stbv_vorb *f, StbvCodebook *c)
+static int codebook_decode_scalar_raw(vorb *f, Codebook *c)
{
int i;
- stbv_prep_huffman(f);
+ prep_huffman(f);
if (c->codewords == NULL && c->sorted_codewords == NULL)
return -1;
@@ -1621,7 +1665,7 @@ static int stbv_codebook_decode_scalar_raw(stbv_vorb *f, StbvCodebook *c)
// sorted_codewords && c->entries > 8
if (c->entries > 8 ? c->sorted_codewords!=NULL : !c->codewords) {
// binary search
- stbv_uint32 code = stbv_bit_reverse(f->acc);
+ uint32 code = bit_reverse(f->acc);
int x=0, n=c->sorted_entries, len;
while (n > 1) {
@@ -1663,17 +1707,17 @@ static int stbv_codebook_decode_scalar_raw(stbv_vorb *f, StbvCodebook *c)
}
}
- stbv_error(f, VORBIS_invalid_stream);
+ error(f, VORBIS_invalid_stream);
f->valid_bits = 0;
return -1;
}
#ifndef STB_VORBIS_NO_INLINE_DECODE
-#define STBV_DECODE_RAW(var, f,c) \
+#define DECODE_RAW(var, f,c) \
if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) \
- stbv_prep_huffman(f); \
- var = f->acc & STBV_FAST_HUFFMAN_TABLE_MASK; \
+ prep_huffman(f); \
+ var = f->acc & FAST_HUFFMAN_TABLE_MASK; \
var = c->fast_huffman[var]; \
if (var >= 0) { \
int n = c->codeword_lengths[var]; \
@@ -1681,18 +1725,18 @@ static int stbv_codebook_decode_scalar_raw(stbv_vorb *f, StbvCodebook *c)
f->valid_bits -= n; \
if (f->valid_bits < 0) { f->valid_bits = 0; var = -1; } \
} else { \
- var = stbv_codebook_decode_scalar_raw(f,c); \
+ var = codebook_decode_scalar_raw(f,c); \
}
#else
-static int stbv_codebook_decode_scalar(stbv_vorb *f, StbvCodebook *c)
+static int codebook_decode_scalar(vorb *f, Codebook *c)
{
int i;
if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH)
- stbv_prep_huffman(f);
+ prep_huffman(f);
// fast huffman table lookup
- i = f->acc & STBV_FAST_HUFFMAN_TABLE_MASK;
+ i = f->acc & FAST_HUFFMAN_TABLE_MASK;
i = c->fast_huffman[i];
if (i >= 0) {
f->acc >>= c->codeword_lengths[i];
@@ -1700,21 +1744,21 @@ static int stbv_codebook_decode_scalar(stbv_vorb *f, StbvCodebook *c)
if (f->valid_bits < 0) { f->valid_bits = 0; return -1; }
return i;
}
- return stbv_codebook_decode_scalar_raw(f,c);
+ return codebook_decode_scalar_raw(f,c);
}
-#define STBV_DECODE_RAW(var,f,c) var = stbv_codebook_decode_scalar(f,c);
+#define DECODE_RAW(var,f,c) var = codebook_decode_scalar(f,c);
#endif
-#define STBV_DECODE(var,f,c) \
- STBV_DECODE_RAW(var,f,c) \
+#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) STBV_DECODE_RAW(var,f,c)
+ #define DECODE_VQ(var,f,c) DECODE_RAW(var,f,c)
#else
- #define DECODE_VQ(var,f,c) STBV_DECODE(var,f,c)
+ #define DECODE_VQ(var,f,c) DECODE(var,f,c)
#endif
@@ -1722,45 +1766,45 @@ static int stbv_codebook_decode_scalar(stbv_vorb *f, StbvCodebook *c)
-// STBV_CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case
+// CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case
// where we avoid one addition
-#define STBV_CODEBOOK_ELEMENT(c,off) (c->multiplicands[off])
-#define STBV_CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off])
-#define STBV_CODEBOOK_ELEMENT_BASE(c) (0)
+#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 stbv_codebook_decode_start(stbv_vorb *f, StbvCodebook *c)
+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)
- stbv_error(f, VORBIS_invalid_stream);
+ error(f, VORBIS_invalid_stream);
else {
DECODE_VQ(z,f,c);
if (c->sparse) assert(z < c->sorted_entries);
- if (z < 0) { // check for STBV_EOP
+ if (z < 0) { // check for EOP
if (!f->bytes_in_seg)
if (f->last_seg)
return z;
- stbv_error(f, VORBIS_invalid_stream);
+ error(f, VORBIS_invalid_stream);
}
}
return z;
}
-static int stbv_codebook_decode(stbv_vorb *f, StbvCodebook *c, float *output, int len)
+static int codebook_decode(vorb *f, Codebook *c, float *output, int len)
{
- int i,z = stbv_codebook_decode_start(f,c);
+ 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 = STBV_CODEBOOK_ELEMENT_BASE(c);
+ float last = CODEBOOK_ELEMENT_BASE(c);
int div = 1;
for (i=0; i < len; ++i) {
int off = (z / div) % c->lookup_values;
- float val = STBV_CODEBOOK_ELEMENT_FAST(c,off) + last;
+ float val = CODEBOOK_ELEMENT_FAST(c,off) + last;
output[i] += val;
if (c->sequence_p) last = val + c->minimum_value;
div *= c->lookup_values;
@@ -1771,26 +1815,26 @@ static int stbv_codebook_decode(stbv_vorb *f, StbvCodebook *c, float *output, in
z *= c->dimensions;
if (c->sequence_p) {
- float last = STBV_CODEBOOK_ELEMENT_BASE(c);
+ float last = CODEBOOK_ELEMENT_BASE(c);
for (i=0; i < len; ++i) {
- float val = STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
+ float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
output[i] += val;
last = val + c->minimum_value;
}
} else {
- float last = STBV_CODEBOOK_ELEMENT_BASE(c);
+ float last = CODEBOOK_ELEMENT_BASE(c);
for (i=0; i < len; ++i) {
- output[i] += STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
+ output[i] += CODEBOOK_ELEMENT_FAST(c,z+i) + last;
}
}
return TRUE;
}
-static int stbv_codebook_decode_step(stbv_vorb *f, StbvCodebook *c, float *output, int len, int step)
+static int codebook_decode_step(vorb *f, Codebook *c, float *output, int len, int step)
{
- int i,z = stbv_codebook_decode_start(f,c);
- float last = STBV_CODEBOOK_ELEMENT_BASE(c);
+ 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;
@@ -1799,7 +1843,7 @@ static int stbv_codebook_decode_step(stbv_vorb *f, StbvCodebook *c, float *outpu
int div = 1;
for (i=0; i < len; ++i) {
int off = (z / div) % c->lookup_values;
- float val = STBV_CODEBOOK_ELEMENT_FAST(c,off) + last;
+ float val = CODEBOOK_ELEMENT_FAST(c,off) + last;
output[i*step] += val;
if (c->sequence_p) last = val;
div *= c->lookup_values;
@@ -1810,7 +1854,7 @@ static int stbv_codebook_decode_step(stbv_vorb *f, StbvCodebook *c, float *outpu
z *= c->dimensions;
for (i=0; i < len; ++i) {
- float val = STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
+ float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
output[i*step] += val;
if (c->sequence_p) last = val;
}
@@ -1818,17 +1862,17 @@ static int stbv_codebook_decode_step(stbv_vorb *f, StbvCodebook *c, float *outpu
return TRUE;
}
-static int stbv_codebook_decode_deinterleave_repeat(stbv_vorb *f, StbvCodebook *c, float **outputs, int ch, int *c_inter_p, int *p_inter_p, int len, int total_decode)
+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 stbv_error(f, VORBIS_invalid_stream);
+ if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream);
while (total_decode > 0) {
- float last = STBV_CODEBOOK_ELEMENT_BASE(c);
+ float last = CODEBOOK_ELEMENT_BASE(c);
DECODE_VQ(z,f,c);
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
assert(!c->sparse || z < c->sorted_entries);
@@ -1836,7 +1880,7 @@ static int stbv_codebook_decode_deinterleave_repeat(stbv_vorb *f, StbvCodebook *
if (z < 0) {
if (!f->bytes_in_seg)
if (f->last_seg) return FALSE;
- return stbv_error(f, VORBIS_invalid_stream);
+ return error(f, VORBIS_invalid_stream);
}
// if this will take us off the end of the buffers, stop short!
@@ -1852,7 +1896,7 @@ static int stbv_codebook_decode_deinterleave_repeat(stbv_vorb *f, StbvCodebook *
int div = 1;
for (i=0; i < effective; ++i) {
int off = (z / div) % c->lookup_values;
- float val = STBV_CODEBOOK_ELEMENT_FAST(c,off) + last;
+ 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; }
@@ -1865,7 +1909,7 @@ static int stbv_codebook_decode_deinterleave_repeat(stbv_vorb *f, StbvCodebook *
z *= c->dimensions;
if (c->sequence_p) {
for (i=0; i < effective; ++i) {
- float val = STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
+ 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; }
@@ -1873,7 +1917,7 @@ static int stbv_codebook_decode_deinterleave_repeat(stbv_vorb *f, StbvCodebook *
}
} else {
for (i=0; i < effective; ++i) {
- float val = STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
+ 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; }
@@ -1888,7 +1932,7 @@ static int stbv_codebook_decode_deinterleave_repeat(stbv_vorb *f, StbvCodebook *
return TRUE;
}
-static int stbv_predict_point(int x, int x0, int x1, int y0, int y1)
+static int predict_point(int x, int x0, int x1, int y0, int y1)
{
int dy = y1 - y0;
int adx = x1 - x0;
@@ -1899,71 +1943,71 @@ static int stbv_predict_point(int x, int x0, int x1, int y0, int y1)
}
// the following table is block-copied from the specification
-static float stbv_inverse_db_table[256] =
+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,
+ 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
};
@@ -1976,18 +2020,18 @@ static float stbv_inverse_db_table[256] =
// ... 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 STBV_LINE_OP(a,b) a *= b
+#define LINE_OP(a,b) a *= b
#else
-#define STBV_LINE_OP(a,b) a = b
+#define LINE_OP(a,b) a = b
#endif
#ifdef STB_VORBIS_DIVIDE_TABLE
-#define STBV_DIVTAB_NUMER 32
-#define STBV_DIVTAB_DENOM 64
-stbv_int8 stbv_integer_divide_table[STBV_DIVTAB_NUMER][STBV_DIVTAB_DENOM]; // 2KB
+#define DIVTAB_NUMER 32
+#define DIVTAB_DENOM 64
+int8 integer_divide_table[DIVTAB_NUMER][DIVTAB_DENOM]; // 2KB
#endif
-static __forceinline void stbv_draw_line(float *output, int x0, int y0, int x1, int y1, int n)
+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;
@@ -1998,12 +2042,12 @@ static __forceinline void stbv_draw_line(float *output, int x0, int y0, int x1,
int sy;
#ifdef STB_VORBIS_DIVIDE_TABLE
- if (adx < STBV_DIVTAB_DENOM && ady < STBV_DIVTAB_NUMER) {
+ if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) {
if (dy < 0) {
- base = -stbv_integer_divide_table[ady][adx];
+ base = -integer_divide_table[ady][adx];
sy = base-1;
} else {
- base = stbv_integer_divide_table[ady][adx];
+ base = integer_divide_table[ady][adx];
sy = base+1;
}
} else {
@@ -2023,7 +2067,7 @@ static __forceinline void stbv_draw_line(float *output, int x0, int y0, int x1,
ady -= abs(base) * adx;
if (x1 > n) x1 = n;
if (x < x1) {
- STBV_LINE_OP(output[x], stbv_inverse_db_table[y]);
+ LINE_OP(output[x], inverse_db_table[y&255]);
for (++x; x < x1; ++x) {
err += ady;
if (err >= adx) {
@@ -2031,22 +2075,22 @@ static __forceinline void stbv_draw_line(float *output, int x0, int y0, int x1,
y += sy;
} else
y += base;
- STBV_LINE_OP(output[x], stbv_inverse_db_table[y]);
+ LINE_OP(output[x], inverse_db_table[y&255]);
}
}
}
-static int stbv_residue_decode(stbv_vorb *f, StbvCodebook *book, float *target, int offset, int n, int rtype)
+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 (!stbv_codebook_decode_step(f, book, target+offset+k, n-offset-k, step))
+ if (!codebook_decode_step(f, book, target+offset+k, n-offset-k, step))
return FALSE;
} else {
for (k=0; k < n; ) {
- if (!stbv_codebook_decode(f, book, target+offset, n-k))
+ if (!codebook_decode(f, book, target+offset, n-k))
return FALSE;
k += book->dimensions;
offset += book->dimensions;
@@ -2057,10 +2101,10 @@ static int stbv_residue_decode(stbv_vorb *f, StbvCodebook *book, float *target,
// n is 1/2 of the blocksize --
// specification: "Correct per-vector decode length is [n]/2"
-static void stbv_decode_residue(stbv_vorb *f, float *residue_buffers[], int ch, int n, int rn, stbv_uint8 *do_not_decode)
+static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int rn, uint8 *do_not_decode)
{
int i,j,pass;
- StbvResidue *r = f->residue_config + rn;
+ Residue *r = f->residue_config + rn;
int rtype = f->residue_types[rn];
int c = r->classbook;
int classwords = f->codebooks[c].dimensions;
@@ -2069,14 +2113,14 @@ static void stbv_decode_residue(stbv_vorb *f, float *residue_buffers[], int ch,
unsigned int limit_r_end = (r->end < actual_size ? r->end : actual_size);
int n_read = limit_r_end - limit_r_begin;
int part_read = n_read / r->part_size;
- int temp_alloc_point = stbv_temp_alloc_save(f);
+ int temp_alloc_point = temp_alloc_save(f);
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
- stbv_uint8 ***part_classdata = (stbv_uint8 ***) stbv_temp_block_array(f,f->channels, part_read * sizeof(**part_classdata));
+ uint8 ***part_classdata = (uint8 ***) temp_block_array(f,f->channels, part_read * sizeof(**part_classdata));
#else
- int **classifications = (int **) stbv_temp_block_array(f,f->channels, part_read * sizeof(**classifications));
+ int **classifications = (int **) temp_block_array(f,f->channels, part_read * sizeof(**classifications));
#endif
- STBV_CHECK(f);
+ CHECK(f);
for (i=0; i < ch; ++i)
if (!do_not_decode[i])
@@ -2096,10 +2140,10 @@ static void stbv_decode_residue(stbv_vorb *f, float *residue_buffers[], int ch,
int z = r->begin + pcount*r->part_size;
int c_inter = (z & 1), p_inter = z>>1;
if (pass == 0) {
- StbvCodebook *c = f->codebooks+r->classbook;
+ Codebook *c = f->codebooks+r->classbook;
int q;
- STBV_DECODE(q,f,c);
- if (q == STBV_EOP) goto done;
+ DECODE(q,f,c);
+ if (q == EOP) goto done;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
part_classdata[0][class_set] = r->classdata[q];
#else
@@ -2118,13 +2162,13 @@ static void stbv_decode_residue(stbv_vorb *f, float *residue_buffers[], int ch,
#endif
int b = r->residue_books[c][pass];
if (b >= 0) {
- StbvCodebook *book = f->codebooks + b;
+ Codebook *book = f->codebooks + b;
#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
- if (!stbv_codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
+ if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
goto done;
#else
// saves 1%
- if (!stbv_codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
+ if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
goto done;
#endif
} else {
@@ -2137,55 +2181,15 @@ static void stbv_decode_residue(stbv_vorb *f, float *residue_buffers[], int ch,
++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) {
- StbvCodebook *c = f->codebooks+r->classbook;
- int q;
- STBV_DECODE(q,f,c);
- if (q == STBV_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) {
- StbvCodebook *book = f->codebooks + b;
- if (!stbv_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 {
+ } else if (ch > 2) {
while (pcount < part_read) {
int z = r->begin + pcount*r->part_size;
int c_inter = z % ch, p_inter = z/ch;
if (pass == 0) {
- StbvCodebook *c = f->codebooks+r->classbook;
+ Codebook *c = f->codebooks+r->classbook;
int q;
- STBV_DECODE(q,f,c);
- if (q == STBV_EOP) goto done;
+ DECODE(q,f,c);
+ if (q == EOP) goto done;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
part_classdata[0][class_set] = r->classdata[q];
#else
@@ -2204,8 +2208,8 @@ static void stbv_decode_residue(stbv_vorb *f, float *residue_buffers[], int ch,
#endif
int b = r->residue_books[c][pass];
if (b >= 0) {
- StbvCodebook *book = f->codebooks + b;
- if (!stbv_codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
+ 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;
@@ -2221,7 +2225,7 @@ static void stbv_decode_residue(stbv_vorb *f, float *residue_buffers[], int ch,
}
goto done;
}
- STBV_CHECK(f);
+ CHECK(f);
for (pass=0; pass < 8; ++pass) {
int pcount = 0, class_set=0;
@@ -2229,10 +2233,10 @@ static void stbv_decode_residue(stbv_vorb *f, float *residue_buffers[], int ch,
if (pass == 0) {
for (j=0; j < ch; ++j) {
if (!do_not_decode[j]) {
- StbvCodebook *c = f->codebooks+r->classbook;
+ Codebook *c = f->codebooks+r->classbook;
int temp;
- STBV_DECODE(temp,f,c);
- if (temp == STBV_EOP) goto done;
+ DECODE(temp,f,c);
+ if (temp == EOP) goto done;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
part_classdata[j][class_set] = r->classdata[temp];
#else
@@ -2257,8 +2261,8 @@ static void stbv_decode_residue(stbv_vorb *f, float *residue_buffers[], int ch,
float *target = residue_buffers[j];
int offset = r->begin + pcount * r->part_size;
int n = r->part_size;
- StbvCodebook *book = f->codebooks + b;
- if (!stbv_residue_decode(f, book, target, offset, n, rtype))
+ Codebook *book = f->codebooks + b;
+ if (!residue_decode(f, book, target, offset, n, rtype))
goto done;
}
}
@@ -2270,13 +2274,13 @@ static void stbv_decode_residue(stbv_vorb *f, float *residue_buffers[], int ch,
}
}
done:
- STBV_CHECK(f);
+ CHECK(f);
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
- stbv_temp_free(f,part_classdata);
+ temp_free(f,part_classdata);
#else
- stbv_temp_free(f,classifications);
+ temp_free(f,classifications);
#endif
- stbv_temp_alloc_restore(f,temp_alloc_point);
+ temp_alloc_restore(f,temp_alloc_point);
}
@@ -2305,7 +2309,7 @@ void inverse_mdct_slow(float *buffer, int n)
}
#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, stbv_vorb *f, int blocktype)
+void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype)
{
float mcos[16384];
int i,j;
@@ -2343,7 +2347,7 @@ void dct_iv_slow(float *buffer, int n)
}
}
-void inverse_mdct_slow(float *buffer, int n, stbv_vorb *f, int blocktype)
+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];
@@ -2364,11 +2368,11 @@ void inverse_mdct_slow(float *buffer, int n, stbv_vorb *f, int blocktype)
#if LIBVORBIS_MDCT
// directly call the vorbis MDCT using an interface documented
// by Jeff Roberts... useful for performance comparison
-typedef struct
+typedef struct
{
int n;
int log2n;
-
+
float *trig;
int *bitrev;
@@ -2381,13 +2385,13 @@ extern void mdct_backward(mdct_lookup *init, float *in, float *out);
mdct_lookup M1,M2;
-void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
+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 {
+ else {
if (M2.n) __asm int 3;
mdct_init(&M2, n);
M = &M2;
@@ -2401,7 +2405,7 @@ void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
// 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 stbv_imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, float *A)
+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;
@@ -2446,7 +2450,7 @@ static void stbv_imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, f
}
}
-static void stbv_imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off, float *A, int k1)
+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;
@@ -2496,7 +2500,7 @@ static void stbv_imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off,
}
}
-static void stbv_imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off, float *A, int a_off, int k0)
+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];
@@ -2547,7 +2551,7 @@ static void stbv_imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off,
}
}
-static __forceinline void stbv_iter_54(float *z)
+static __forceinline void iter_54(float *z)
{
float k00,k11,k22,k33;
float y0,y1,y2,y3;
@@ -2579,7 +2583,7 @@ static __forceinline void stbv_iter_54(float *z)
z[-7] = k11 + k22; // z1 - z5 - z2 + z6
}
-static void stbv_imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n)
+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];
@@ -2588,48 +2592,47 @@ static void stbv_imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, floa
while (z > base) {
float k00,k11;
+ float l00,l11;
- 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[-0] - z[ -8];
+ k11 = z[-1] - z[ -9];
+ l00 = z[-2] - z[-10];
+ l11 = z[-3] - z[-11];
+ z[ -0] = z[-0] + z[ -8];
+ z[ -1] = z[-1] + z[ -9];
+ z[ -2] = z[-2] + z[-10];
+ z[ -3] = z[-3] + z[-11];
+ z[ -8] = k00;
+ z[ -9] = k11;
+ z[-10] = (l00+l11) * A2;
+ z[-11] = (l11-l00) * A2;
- 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
+ k00 = z[ -4] - z[-12];
k11 = z[ -5] - z[-13];
+ l00 = z[ -6] - z[-14];
+ l11 = z[ -7] - z[-15];
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;
+ z[-12] = k11;
+ z[-13] = -k00;
+ z[-14] = (l11-l00) * A2;
+ z[-15] = (l00+l11) * -A2;
- stbv_iter_54(z);
- stbv_iter_54(z-8);
+ iter_54(z);
+ iter_54(z-8);
z -= 16;
}
}
-static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
+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 = stbv_temp_alloc_save(f);
- float *buf2 = (float *) stbv_temp_alloc(f, n2 * sizeof(*buf2));
+ 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];
@@ -2650,7 +2653,7 @@ static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
// 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
+ // this propagates through linearly to the end, where the numbers
// are 1/2 too small, and need to be compensated for.
{
@@ -2724,7 +2727,7 @@ static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
}
// step 3
- ld = stbv_ilog(n) - 1; // stbv_ilog is off-by-one from normal definitions
+ ld = ilog(n) - 1; // ilog is off-by-one from normal definitions
// optimized step 3:
@@ -2734,14 +2737,14 @@ static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
// switch between them halfway.
// this is iteration 0 of step 3
- stbv_imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A);
- stbv_imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A);
+ 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
- stbv_imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16);
- stbv_imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16);
- stbv_imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16);
- stbv_imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16);
+ 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) {
@@ -2749,7 +2752,7 @@ static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
int lim = 1 << (l+1);
int i;
for (i=0; i < lim; ++i)
- stbv_imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3));
+ imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3));
}
for (; l < ld-6; ++l) {
@@ -2760,7 +2763,7 @@ static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
float *A0 = A;
i_off = n2-1;
for (r=rlim; r > 0; --r) {
- stbv_imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0);
+ imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0);
A0 += k1*4;
i_off -= 8;
}
@@ -2771,14 +2774,14 @@ static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
// 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
- stbv_imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n);
+ 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
{
- stbv_uint16 *bitrev = f->stbv_bit_reverse[blocktype];
+ 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
@@ -2800,7 +2803,7 @@ static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
d1[0] = u[k4+1];
d0[1] = u[k4+2];
d0[0] = u[k4+3];
-
+
d0 -= 4;
d1 -= 4;
bitrev += 2;
@@ -2881,7 +2884,7 @@ static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
float p0,p1,p2,p3;
p3 = e[6]*B[7] - e[7]*B[6];
- p2 = -e[6]*B[6] - e[7]*B[7];
+ p2 = -e[6]*B[6] - e[7]*B[7];
d0[0] = p3;
d1[3] = - p3;
@@ -2889,7 +2892,7 @@ static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
d3[3] = p2;
p1 = e[4]*B[5] - e[5]*B[4];
- p0 = -e[4]*B[4] - e[5]*B[5];
+ p0 = -e[4]*B[4] - e[5]*B[5];
d0[1] = p1;
d1[2] = - p1;
@@ -2897,7 +2900,7 @@ static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
d3[2] = p0;
p3 = e[2]*B[3] - e[3]*B[2];
- p2 = -e[2]*B[2] - e[3]*B[3];
+ p2 = -e[2]*B[2] - e[3]*B[3];
d0[2] = p3;
d1[1] = - p3;
@@ -2905,7 +2908,7 @@ static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
d3[1] = p2;
p1 = e[0]*B[1] - e[1]*B[0];
- p0 = -e[0]*B[0] - e[1]*B[1];
+ p0 = -e[0]*B[0] - e[1]*B[1];
d0[3] = p1;
d1[0] = - p1;
@@ -2921,8 +2924,8 @@ static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
}
}
- stbv_temp_free(f,buf2);
- stbv_temp_alloc_restore(f,save_point);
+ temp_free(f,buf2);
+ temp_alloc_restore(f,save_point);
}
#if 0
@@ -2973,7 +2976,7 @@ void inverse_mdct_naive(float *buffer, int n)
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 = stbv_ilog(n) - 1; // stbv_ilog is off-by-one from normal definitions
+ 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;
@@ -2996,7 +2999,7 @@ void inverse_mdct_naive(float *buffer, int n)
// step 4
for (i=0; i < n8; ++i) {
- int j = stbv_bit_reverse(i) >> (32-ld+3);
+ int j = bit_reverse(i) >> (32-ld+3);
assert(j < n8);
if (i == j) {
// paper bug: original code probably swapped in place; if copying,
@@ -3053,34 +3056,34 @@ void inverse_mdct_naive(float *buffer, int n)
}
#endif
-static float *stbv_get_window(stbv_vorb *f, int len)
+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 stbv_int16 STBV_YTYPE;
+typedef int16 YTYPE;
#else
-typedef int STBV_YTYPE;
+typedef int YTYPE;
#endif
-static int stbv_do_floor(stbv_vorb *f, StbvMapping *map, int i, int n, float *target, STBV_YTYPE *finalY, stbv_uint8 *step2_flag)
+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 stbv_error(f, VORBIS_invalid_stream);
+ return error(f, VORBIS_invalid_stream);
} else {
- StbvFloor1 *g = &f->floor_config[floor].floor1;
+ 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
+ STBV_NOTUSED(step2_flag);
if (finalY[j] >= 0)
#else
if (step2_flag[j])
@@ -3089,16 +3092,16 @@ static int stbv_do_floor(stbv_vorb *f, StbvMapping *map, int i, int n, float *ta
int hy = finalY[j] * g->floor1_multiplier;
int hx = g->Xlist[j];
if (lx != hx)
- stbv_draw_line(target, lx,ly, hx,hy, n2);
- STBV_CHECK(f);
+ draw_line(target, lx,ly, hx,hy, n2);
+ CHECK(f);
lx = hx, ly = hy;
}
}
if (lx < n2) {
- // optimization of: stbv_draw_line(target, lx,ly, n,ly, n2);
+ // optimization of: draw_line(target, lx,ly, n,ly, n2);
for (j=lx; j < n2; ++j)
- STBV_LINE_OP(target[j], stbv_inverse_db_table[ly]);
- STBV_CHECK(f);
+ LINE_OP(target[j], inverse_db_table[ly]);
+ CHECK(f);
}
}
return TRUE;
@@ -3118,36 +3121,36 @@ static int stbv_do_floor(stbv_vorb *f, StbvMapping *map, int i, int n, float *ta
// has to be the same as frame N+1's left_end-left_start (which they are by
// construction)
-static int stbv_vorbis_decode_initial(stbv_vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode)
+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)
{
- StbvMode *m;
+ 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 (!stbv_maybe_start_packet(f))
+ if (!maybe_start_packet(f))
return FALSE;
// check packet type
- if (stbv_get_bits(f,1) != 0) {
- if (STBV_IS_PUSH_MODE(f))
- return stbv_error(f,VORBIS_bad_packet_type);
- while (STBV_EOP != stbv_get8_packet(f));
+ 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 = stbv_get_bits(f, stbv_ilog(f->mode_count-1));
- if (i == STBV_EOP) return FALSE;
+ 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 = stbv_get_bits(f,1);
- next = stbv_get_bits(f,1);
+ prev = get_bits(f,1);
+ next = get_bits(f,1);
} else {
prev = next = 0;
n = f->blocksize_0;
@@ -3174,40 +3177,41 @@ static int stbv_vorbis_decode_initial(stbv_vorb *f, int *p_left_start, int *p_le
return TRUE;
}
-static int stbv_vorbis_decode_packet_rest(stbv_vorb *f, int *len, StbvMode *m, int left_start, int left_end, int right_start, int right_end, int *p_left)
+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)
{
- StbvMapping *map;
+ Mapping *map;
int i,j,k,n,n2;
int zero_channel[256];
int really_zero_channel[256];
// WINDOWING
+ STBV_NOTUSED(left_end);
n = f->blocksize[m->blockflag];
map = &f->mapping[m->mapping];
// FLOORS
n2 = n >> 1;
- STBV_CHECK(f);
+ 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 stbv_error(f, VORBIS_invalid_stream);
+ return error(f, VORBIS_invalid_stream);
} else {
- StbvFloor1 *g = &f->floor_config[floor].floor1;
- if (stbv_get_bits(f, 1)) {
+ Floor1 *g = &f->floor_config[floor].floor1;
+ if (get_bits(f, 1)) {
short *finalY;
- stbv_uint8 step2_flag[256];
+ 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] = stbv_get_bits(f, stbv_ilog(range)-1);
- finalY[1] = stbv_get_bits(f, stbv_ilog(range)-1);
+ 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];
@@ -3215,29 +3219,29 @@ static int stbv_vorbis_decode_packet_rest(stbv_vorb *f, int *len, StbvMode *m, i
int csub = (1 << cbits)-1;
int cval = 0;
if (cbits) {
- StbvCodebook *c = f->codebooks + g->class_masterbooks[pclass];
- STBV_DECODE(cval,f,c);
+ 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;
- StbvCodebook *c = f->codebooks + book;
- STBV_DECODE(temp,f,c);
+ Codebook *c = f->codebooks + book;
+ DECODE(temp,f,c);
finalY[offset++] = temp;
} else
finalY[offset++] = 0;
}
}
- if (f->valid_bits == STBV_INVALID_BITS) goto error; // behavior according to spec
+ 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->stbv_neighbors[j][0];
- high = g->stbv_neighbors[j][1];
- //stbv_neighbors(g->Xlist, j, &low, &high);
- pred = stbv_predict_point(g->Xlist[j], g->Xlist[low], g->Xlist[high], finalY[low], finalY[high]);
+ 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;
@@ -3265,7 +3269,7 @@ static int stbv_vorbis_decode_packet_rest(stbv_vorb *f, int *len, StbvMode *m, i
}
#ifdef STB_VORBIS_NO_DEFER_FLOOR
- stbv_do_floor(f, map, i, n, f->floor_buffers[i], finalY, step2_flag);
+ 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) {
@@ -3282,7 +3286,7 @@ static int stbv_vorbis_decode_packet_rest(stbv_vorb *f, int *len, StbvMode *m, i
// at this point we've decoded the floor into buffer
}
}
- STBV_CHECK(f);
+ CHECK(f);
// at this point we've decoded all floors
if (f->alloc.alloc_buffer)
@@ -3295,12 +3299,12 @@ static int stbv_vorbis_decode_packet_rest(stbv_vorb *f, int *len, StbvMode *m, i
zero_channel[map->chan[i].magnitude] = zero_channel[map->chan[i].angle] = FALSE;
}
- STBV_CHECK(f);
-// RESIDUE STBV_DECODE
+ CHECK(f);
+// RESIDUE DECODE
for (i=0; i < map->submaps; ++i) {
float *residue_buffers[STB_VORBIS_MAX_CHANNELS];
int r;
- stbv_uint8 do_not_decode[256];
+ uint8 do_not_decode[256];
int ch = 0;
for (j=0; j < f->channels; ++j) {
if (map->chan[j].mux == i) {
@@ -3315,12 +3319,12 @@ static int stbv_vorbis_decode_packet_rest(stbv_vorb *f, int *len, StbvMode *m, i
}
}
r = map->submap_residue[i];
- stbv_decode_residue(f, residue_buffers, ch, n2, r, do_not_decode);
+ 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);
- STBV_CHECK(f);
+ CHECK(f);
// INVERSE COUPLING
for (i = map->coupling_steps-1; i >= 0; --i) {
@@ -3343,7 +3347,7 @@ static int stbv_vorbis_decode_packet_rest(stbv_vorb *f, int *len, StbvMode *m, i
a[j] = a2;
}
}
- STBV_CHECK(f);
+ CHECK(f);
// finish decoding the floors
#ifndef STB_VORBIS_NO_DEFER_FLOOR
@@ -3351,7 +3355,7 @@ static int stbv_vorbis_decode_packet_rest(stbv_vorb *f, int *len, StbvMode *m, i
if (really_zero_channel[i]) {
memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2);
} else {
- stbv_do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL);
+ do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL);
}
}
#else
@@ -3366,21 +3370,21 @@ static int stbv_vorbis_decode_packet_rest(stbv_vorb *f, int *len, StbvMode *m, i
#endif
// INVERSE MDCT
- STBV_CHECK(f);
+ CHECK(f);
for (i=0; i < f->channels; ++i)
- stbv_inverse_mdct(f->channel_buffers[i], n, f, m->blockflag);
- STBV_CHECK(f);
+ 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
- stbv_flush_packet(f);
+ 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
+ f->current_loc = 0u - n2; // start of first frame is positioned for discard (NB this is an intentional unsigned overflow/wrap-around)
// 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;
@@ -3408,8 +3412,8 @@ static int stbv_vorbis_decode_packet_rest(stbv_vorb *f, int *len, StbvMode *m, i
// 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 & STBV_PAGEFLAG_last_page)) {
- stbv_uint32 current_end = f->known_loc_for_packet;
+ if (f->current_loc_valid && (f->page_flag & PAGEFLAG_last_page)) {
+ uint32 current_end = f->known_loc_for_packet;
// 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) {
@@ -3437,19 +3441,19 @@ static int stbv_vorbis_decode_packet_rest(stbv_vorb *f, int *len, StbvMode *m, i
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
- STBV_CHECK(f);
+ CHECK(f);
return TRUE;
}
-static int stbv_vorbis_decode_packet(stbv_vorb *f, int *len, int *p_left, int *p_right)
+static int vorbis_decode_packet(vorb *f, int *len, int *p_left, int *p_right)
{
int mode, left_end, right_end;
- if (!stbv_vorbis_decode_initial(f, p_left, &left_end, p_right, &right_end, &mode)) return 0;
- return stbv_vorbis_decode_packet_rest(f, len, f->mode_config + mode, *p_left, left_end, *p_right, right_end, p_left);
+ 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 stbv_vorbis_finish_frame(stb_vorbis *f, int len, int left, int right)
+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)
@@ -3463,7 +3467,8 @@ static int stbv_vorbis_finish_frame(stb_vorbis *f, int len, int left, int right)
// mixin from previous window
if (f->previous_length) {
int i,j, n = f->previous_length;
- float *w = stbv_get_window(f, n);
+ float *w = get_window(f, n);
+ if (w == NULL) return 0;
for (i=0; i < f->channels; ++i) {
for (j=0; j < n; ++j)
f->channel_buffers[i][left+j] =
@@ -3501,28 +3506,28 @@ static int stbv_vorbis_finish_frame(stb_vorbis *f, int len, int left, int right)
return right - left;
}
-static int stbv_vorbis_pump_first_frame(stb_vorbis *f)
+static int vorbis_pump_first_frame(stb_vorbis *f)
{
int len, right, left, res;
- res = stbv_vorbis_decode_packet(f, &len, &left, &right);
+ res = vorbis_decode_packet(f, &len, &left, &right);
if (res)
- stbv_vorbis_finish_frame(f, len, left, right);
+ vorbis_finish_frame(f, len, left, right);
return res;
}
#ifndef STB_VORBIS_NO_PUSHDATA_API
-static int stbv_is_whole_packet_present(stb_vorbis *f, int end_page)
+static int is_whole_packet_present(stb_vorbis *f)
{
// 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 stbv_get8() until end-of-packet, check f->eof, then
+ // 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;
- stbv_uint8 *p = f->stream;
+ 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) {
@@ -3531,112 +3536,166 @@ static int stbv_is_whole_packet_present(stb_vorbis *f, int end_page)
break;
}
// either this continues, or it ends it...
- if (end_page)
- if (s < f->segment_count-1) return stbv_error(f, VORBIS_invalid_stream);
if (s == f->segment_count)
s = -1; // set 'crosses page' flag
- if (p > f->stream_end) return stbv_error(f, VORBIS_need_more_data);
+ if (p > f->stream_end) return error(f, VORBIS_need_more_data);
first = FALSE;
}
for (; s == -1;) {
- stbv_uint8 *q;
+ uint8 *q;
int n;
// check that we have the page header ready
- if (p + 26 >= f->stream_end) return stbv_error(f, VORBIS_need_more_data);
+ if (p + 26 >= f->stream_end) return error(f, VORBIS_need_more_data);
// validate the page
- if (memcmp(p, stbv_ogg_page_header, 4)) return stbv_error(f, VORBIS_invalid_stream);
- if (p[4] != 0) return stbv_error(f, VORBIS_invalid_stream);
+ 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] & STBV_PAGEFLAG_continued_packet)) return stbv_error(f, VORBIS_invalid_stream);
+ 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] & STBV_PAGEFLAG_continued_packet)) return stbv_error(f, VORBIS_invalid_stream);
+ 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 stbv_error(f, VORBIS_need_more_data);
+ 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 stbv_error(f, VORBIS_invalid_stream);
if (s == n)
s = -1; // set 'crosses page' flag
- if (p > f->stream_end) return stbv_error(f, VORBIS_need_more_data);
+ if (p > f->stream_end) return error(f, VORBIS_need_more_data);
first = FALSE;
}
return TRUE;
}
#endif // !STB_VORBIS_NO_PUSHDATA_API
-static int stbv_start_decoder(stbv_vorb *f)
+static int start_decoder(vorb *f)
{
- stbv_uint8 header[6], x,y;
+ uint8 header[6], x,y;
int len,i,j,k, max_submaps = 0;
int longest_floorlist=0;
// first page, first packet
+ f->first_decode = TRUE;
- if (!stbv_start_page(f)) return FALSE;
+ if (!start_page(f)) return FALSE;
// validate page flag
- if (!(f->page_flag & STBV_PAGEFLAG_first_page)) return stbv_error(f, VORBIS_invalid_first_page);
- if (f->page_flag & STBV_PAGEFLAG_last_page) return stbv_error(f, VORBIS_invalid_first_page);
- if (f->page_flag & STBV_PAGEFLAG_continued_packet) return stbv_error(f, VORBIS_invalid_first_page);
+ 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 stbv_error(f, VORBIS_invalid_first_page);
- if (f->segments[0] != 30) return stbv_error(f, VORBIS_invalid_first_page);
+ if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page);
+ if (f->segments[0] != 30) {
+ // check for the Ogg skeleton fishead identifying header to refine our error
+ if (f->segments[0] == 64 &&
+ getn(f, header, 6) &&
+ header[0] == 'f' &&
+ header[1] == 'i' &&
+ header[2] == 's' &&
+ header[3] == 'h' &&
+ header[4] == 'e' &&
+ header[5] == 'a' &&
+ get8(f) == 'd' &&
+ get8(f) == '\0') return error(f, VORBIS_ogg_skeleton_not_supported);
+ else
+ return error(f, VORBIS_invalid_first_page);
+ }
+
// read packet
// check packet header
- if (stbv_get8(f) != STBV_VORBIS_packet_id) return stbv_error(f, VORBIS_invalid_first_page);
- if (!stbv_getn(f, header, 6)) return stbv_error(f, VORBIS_unexpected_eof);
- if (!stbv_vorbis_validate(header)) return stbv_error(f, VORBIS_invalid_first_page);
+ 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 (stbv_get32(f) != 0) return stbv_error(f, VORBIS_invalid_first_page);
- f->channels = stbv_get8(f); if (!f->channels) return stbv_error(f, VORBIS_invalid_first_page);
- if (f->channels > STB_VORBIS_MAX_CHANNELS) return stbv_error(f, VORBIS_too_many_channels);
- f->sample_rate = stbv_get32(f); if (!f->sample_rate) return stbv_error(f, VORBIS_invalid_first_page);
- stbv_get32(f); // bitrate_maximum
- stbv_get32(f); // bitrate_nominal
- stbv_get32(f); // bitrate_minimum
- x = stbv_get8(f);
+ 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 stbv_error(f, VORBIS_invalid_setup);
- if (log1 < 6 || log1 > 13) return stbv_error(f, VORBIS_invalid_setup);
- if (log0 > log1) return stbv_error(f, VORBIS_invalid_setup);
+ 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 = stbv_get8(f);
- if (!(x & 1)) return stbv_error(f, VORBIS_invalid_first_page);
+ x = get8(f);
+ if (!(x & 1)) return error(f, VORBIS_invalid_first_page);
// second packet!
- if (!stbv_start_page(f)) return FALSE;
+ if (!start_page(f)) return FALSE;
+
+ if (!start_packet(f)) return FALSE;
+
+ if (!next_segment(f)) return FALSE;
+
+ if (get8_packet(f) != VORBIS_packet_comment) 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);
+ //file vendor
+ len = get32_packet(f);
+ f->vendor = (char*)setup_malloc(f, sizeof(char) * (len+1));
+ if (f->vendor == NULL) return error(f, VORBIS_outofmem);
+ for(i=0; i < len; ++i) {
+ f->vendor[i] = get8_packet(f);
+ }
+ f->vendor[len] = (char)'\0';
+ //user comments
+ f->comment_list_length = get32_packet(f);
+ f->comment_list = NULL;
+ if (f->comment_list_length > 0)
+ {
+ f->comment_list = (char**) setup_malloc(f, sizeof(char*) * (f->comment_list_length));
+ if (f->comment_list == NULL) return error(f, VORBIS_outofmem);
+ }
+
+ for(i=0; i < f->comment_list_length; ++i) {
+ len = get32_packet(f);
+ f->comment_list[i] = (char*)setup_malloc(f, sizeof(char) * (len+1));
+ if (f->comment_list[i] == NULL) return error(f, VORBIS_outofmem);
+
+ for(j=0; j < len; ++j) {
+ f->comment_list[i][j] = get8_packet(f);
+ }
+ f->comment_list[i][len] = (char)'\0';
+ }
+
+ // framing_flag
+ x = get8_packet(f);
+ if (!(x & 1)) return error(f, VORBIS_invalid_setup);
+
+
+ skip(f, f->bytes_in_seg);
+ f->bytes_in_seg = 0;
- if (!stbv_start_packet(f)) return FALSE;
do {
- len = stbv_next_segment(f);
- stbv_skip(f, len);
+ len = next_segment(f);
+ skip(f, len);
f->bytes_in_seg = 0;
} while (len);
// third packet!
- if (!stbv_start_packet(f)) return FALSE;
+ if (!start_packet(f)) return FALSE;
#ifndef STB_VORBIS_NO_PUSHDATA_API
- if (STBV_IS_PUSH_MODE(f)) {
- if (!stbv_is_whole_packet_present(f, TRUE)) {
+ if (IS_PUSH_MODE(f)) {
+ if (!is_whole_packet_present(f)) {
// convert error in ogg header to write type
if (f->error == VORBIS_invalid_stream)
f->error = VORBIS_invalid_setup;
@@ -3645,64 +3704,65 @@ static int stbv_start_decoder(stbv_vorb *f)
}
#endif
- stbv_crc32_init(); // always init it, to avoid multithread race conditions
+ crc32_init(); // always init it, to avoid multithread race conditions
- if (stbv_get8_packet(f) != STBV_VORBIS_packet_setup) return stbv_error(f, VORBIS_invalid_setup);
- for (i=0; i < 6; ++i) header[i] = stbv_get8_packet(f);
- if (!stbv_vorbis_validate(header)) return stbv_error(f, VORBIS_invalid_setup);
+ 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 = stbv_get_bits(f,8) + 1;
- f->codebooks = (StbvCodebook *) stbv_setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count);
- if (f->codebooks == NULL) return stbv_error(f, VORBIS_outofmem);
+ 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) {
- stbv_uint32 *values;
+ uint32 *values;
int ordered, sorted_count;
int total=0;
- stbv_uint8 *lengths;
- StbvCodebook *c = f->codebooks+i;
- STBV_CHECK(f);
- x = stbv_get_bits(f, 8); if (x != 0x42) return stbv_error(f, VORBIS_invalid_setup);
- x = stbv_get_bits(f, 8); if (x != 0x43) return stbv_error(f, VORBIS_invalid_setup);
- x = stbv_get_bits(f, 8); if (x != 0x56) return stbv_error(f, VORBIS_invalid_setup);
- x = stbv_get_bits(f, 8);
- c->dimensions = (stbv_get_bits(f, 8)<<8) + x;
- x = stbv_get_bits(f, 8);
- y = stbv_get_bits(f, 8);
- c->entries = (stbv_get_bits(f, 8)<<16) + (y<<8) + x;
- ordered = stbv_get_bits(f,1);
- c->sparse = ordered ? 0 : stbv_get_bits(f,1);
+ 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 stbv_error(f, VORBIS_invalid_setup);
+ if (c->dimensions == 0 && c->entries != 0) return error(f, VORBIS_invalid_setup);
if (c->sparse)
- lengths = (stbv_uint8 *) stbv_setup_temp_malloc(f, c->entries);
+ lengths = (uint8 *) setup_temp_malloc(f, c->entries);
else
- lengths = c->codeword_lengths = (stbv_uint8 *) stbv_setup_malloc(f, c->entries);
+ lengths = c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries);
- if (!lengths) return stbv_error(f, VORBIS_outofmem);
+ if (!lengths) return error(f, VORBIS_outofmem);
if (ordered) {
int current_entry = 0;
- int current_length = stbv_get_bits(f,5) + 1;
+ int current_length = get_bits(f,5) + 1;
while (current_entry < c->entries) {
int limit = c->entries - current_entry;
- int n = stbv_get_bits(f, stbv_ilog(limit));
- if (current_entry + n > (int) c->entries) { return stbv_error(f, VORBIS_invalid_setup); }
+ int n = get_bits(f, ilog(limit));
+ if (current_length >= 32) return error(f, VORBIS_invalid_setup);
+ 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 ? stbv_get_bits(f,1) : 1;
+ int present = c->sparse ? get_bits(f,1) : 1;
if (present) {
- lengths[j] = stbv_get_bits(f, 5) + 1;
+ lengths[j] = get_bits(f, 5) + 1;
++total;
if (lengths[j] == 32)
- return stbv_error(f, VORBIS_invalid_setup);
+ return error(f, VORBIS_invalid_setup);
} else {
lengths[j] = NO_CODE;
}
@@ -3714,10 +3774,10 @@ static int stbv_start_decoder(stbv_vorb *f)
if (c->entries > (int) f->setup_temp_memory_required)
f->setup_temp_memory_required = c->entries;
- c->codeword_lengths = (stbv_uint8 *) stbv_setup_malloc(f, c->entries);
- if (c->codeword_lengths == NULL) return stbv_error(f, VORBIS_outofmem);
+ 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);
- stbv_setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs!
+ 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;
}
@@ -3737,72 +3797,74 @@ static int stbv_start_decoder(stbv_vorb *f)
c->sorted_entries = sorted_count;
values = NULL;
- STBV_CHECK(f);
+ CHECK(f);
if (!c->sparse) {
- c->codewords = (stbv_uint32 *) stbv_setup_malloc(f, sizeof(c->codewords[0]) * c->entries);
- if (!c->codewords) return stbv_error(f, VORBIS_outofmem);
+ 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 = (stbv_uint8 *) stbv_setup_malloc(f, c->sorted_entries);
- if (!c->codeword_lengths) return stbv_error(f, VORBIS_outofmem);
- c->codewords = (stbv_uint32 *) stbv_setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries);
- if (!c->codewords) return stbv_error(f, VORBIS_outofmem);
- values = (stbv_uint32 *) stbv_setup_temp_malloc(f, sizeof(*values) * c->sorted_entries);
- if (!values) return stbv_error(f, VORBIS_outofmem);
+ 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 (!stbv_compute_codewords(c, lengths, c->entries, values)) {
- if (c->sparse) stbv_setup_temp_free(f, values, 0);
- return stbv_error(f, VORBIS_invalid_setup);
+ 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 = (stbv_uint32 *) stbv_setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1));
- if (c->sorted_codewords == NULL) return stbv_error(f, VORBIS_outofmem);
+ 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 *) stbv_setup_malloc(f, sizeof(*c->sorted_values ) * (c->sorted_entries+1));
- if (c->sorted_values == NULL) return stbv_error(f, VORBIS_outofmem);
+ 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;
- stbv_compute_sorted_huffman(c, lengths, values);
+ compute_sorted_huffman(c, lengths, values);
}
if (c->sparse) {
- stbv_setup_temp_free(f, values, sizeof(*values)*c->sorted_entries);
- stbv_setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries);
- stbv_setup_temp_free(f, lengths, c->entries);
+ 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;
}
- stbv_compute_accelerated_huffman(c);
+ compute_accelerated_huffman(c);
- STBV_CHECK(f);
- c->lookup_type = stbv_get_bits(f, 4);
- if (c->lookup_type > 2) return stbv_error(f, VORBIS_invalid_setup);
+ 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) {
- stbv_uint16 *mults;
- c->minimum_value = stbv_float32_unpack(stbv_get_bits(f, 32));
- c->delta_value = stbv_float32_unpack(stbv_get_bits(f, 32));
- c->value_bits = stbv_get_bits(f, 4)+1;
- c->sequence_p = stbv_get_bits(f,1);
+ 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 = stbv_lookup1_values(c->entries, c->dimensions);
+ int values = lookup1_values(c->entries, c->dimensions);
+ if (values < 0) return error(f, VORBIS_invalid_setup);
+ c->lookup_values = (uint32) values;
} else {
c->lookup_values = c->entries * c->dimensions;
}
- if (c->lookup_values == 0) return stbv_error(f, VORBIS_invalid_setup);
- mults = (stbv_uint16 *) stbv_setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values);
- if (mults == NULL) return stbv_error(f, VORBIS_outofmem);
+ 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 = stbv_get_bits(f, c->value_bits);
- if (q == STBV_EOP) { stbv_setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return stbv_error(f, VORBIS_invalid_setup); }
+ 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;
}
@@ -3812,26 +3874,25 @@ static int stbv_start_decoder(stbv_vorb *f)
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 stbv_skip;
- c->multiplicands = (stbv_codetype *) stbv_setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions);
+ 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 = (stbv_codetype *) stbv_setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions);
- if (c->multiplicands == NULL) { stbv_setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return stbv_error(f, VORBIS_outofmem); }
+ 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;
+ float 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) {
- stbv_setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values);
- return stbv_error(f, VORBIS_invalid_setup);
+ setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values);
+ return error(f, VORBIS_invalid_setup);
}
div *= c->lookup_values;
}
@@ -3843,9 +3904,9 @@ static int stbv_start_decoder(stbv_vorb *f)
#endif
{
float last=0;
- STBV_CHECK(f);
- c->multiplicands = (stbv_codetype *) stbv_setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values);
- if (c->multiplicands == NULL) { stbv_setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return stbv_error(f, VORBIS_outofmem); }
+ 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;
@@ -3854,72 +3915,72 @@ static int stbv_start_decoder(stbv_vorb *f)
}
}
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
- stbv_skip:;
+ skip:;
#endif
- stbv_setup_temp_free(f, mults, sizeof(mults[0])*c->lookup_values);
+ setup_temp_free(f, mults, sizeof(mults[0])*c->lookup_values);
- STBV_CHECK(f);
+ CHECK(f);
}
- STBV_CHECK(f);
+ CHECK(f);
}
// time domain transfers (notused)
- x = stbv_get_bits(f, 6) + 1;
+ x = get_bits(f, 6) + 1;
for (i=0; i < x; ++i) {
- stbv_uint32 z = stbv_get_bits(f, 16);
- if (z != 0) return stbv_error(f, VORBIS_invalid_setup);
+ uint32 z = get_bits(f, 16);
+ if (z != 0) return error(f, VORBIS_invalid_setup);
}
// Floors
- f->floor_count = stbv_get_bits(f, 6)+1;
- f->floor_config = (StbvFloor *) stbv_setup_malloc(f, f->floor_count * sizeof(*f->floor_config));
- if (f->floor_config == NULL) return stbv_error(f, VORBIS_outofmem);
+ 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] = stbv_get_bits(f, 16);
- if (f->floor_types[i] > 1) return stbv_error(f, VORBIS_invalid_setup);
+ 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) {
- StbvFloor0 *g = &f->floor_config[i].floor0;
- g->order = stbv_get_bits(f,8);
- g->rate = stbv_get_bits(f,16);
- g->bark_map_size = stbv_get_bits(f,16);
- g->amplitude_bits = stbv_get_bits(f,6);
- g->amplitude_offset = stbv_get_bits(f,8);
- g->number_of_books = stbv_get_bits(f,4) + 1;
+ 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] = stbv_get_bits(f,8);
- return stbv_error(f, VORBIS_feature_not_supported);
+ g->book_list[j] = get_bits(f,8);
+ return error(f, VORBIS_feature_not_supported);
} else {
- stbv_floor_ordering p[31*8+2];
- StbvFloor1 *g = &f->floor_config[i].floor1;
- int max_class = -1;
- g->partitions = stbv_get_bits(f, 5);
+ 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] = stbv_get_bits(f, 4);
+ 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] = stbv_get_bits(f, 3)+1;
- g->class_subclasses[j] = stbv_get_bits(f, 2);
+ 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] = stbv_get_bits(f, 8);
- if (g->class_masterbooks[j] >= f->codebook_count) return stbv_error(f, VORBIS_invalid_setup);
+ 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] = stbv_get_bits(f,8)-1;
- if (g->subclass_books[j][k] >= f->codebook_count) return stbv_error(f, VORBIS_invalid_setup);
+ g->subclass_books[j][k] = (int16)get_bits(f,8)-1;
+ if (g->subclass_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup);
}
}
- g->floor1_multiplier = stbv_get_bits(f,2)+1;
- g->rangebits = stbv_get_bits(f,4);
+ 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] = stbv_get_bits(f, g->rangebits);
+ g->Xlist[g->values] = get_bits(f, g->rangebits);
++g->values;
}
}
@@ -3928,15 +3989,18 @@ static int stbv_start_decoder(stbv_vorb *f)
p[j].x = g->Xlist[j];
p[j].id = j;
}
- qsort(p, g->values, sizeof(p[0]), stbv_point_compare);
+ qsort(p, g->values, sizeof(p[0]), point_compare);
+ for (j=0; j < g->values-1; ++j)
+ if (p[j].x == p[j+1].x)
+ return error(f, VORBIS_invalid_setup);
for (j=0; j < g->values; ++j)
- g->sorted_order[j] = (stbv_uint8) p[j].id;
- // precompute the stbv_neighbors
+ g->sorted_order[j] = (uint8) p[j].id;
+ // precompute the neighbors
for (j=2; j < g->values; ++j) {
- int low,hi;
- stbv_neighbors(g->Xlist, j, &low,&hi);
- g->stbv_neighbors[j][0] = low;
- g->stbv_neighbors[j][1] = hi;
+ int low = 0,hi = 0;
+ neighbors(g->Xlist, j, &low,&hi);
+ g->neighbors[j][0] = low;
+ g->neighbors[j][1] = hi;
}
if (g->values > longest_floorlist)
@@ -3944,37 +4008,37 @@ static int stbv_start_decoder(stbv_vorb *f)
}
}
- // StbvResidue
- f->residue_count = stbv_get_bits(f, 6)+1;
- f->residue_config = (StbvResidue *) stbv_setup_malloc(f, f->residue_count * sizeof(f->residue_config[0]));
- if (f->residue_config == NULL) return stbv_error(f, VORBIS_outofmem);
+ // 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) {
- stbv_uint8 residue_cascade[64];
- StbvResidue *r = f->residue_config+i;
- f->residue_types[i] = stbv_get_bits(f, 16);
- if (f->residue_types[i] > 2) return stbv_error(f, VORBIS_invalid_setup);
- r->begin = stbv_get_bits(f, 24);
- r->end = stbv_get_bits(f, 24);
- if (r->end < r->begin) return stbv_error(f, VORBIS_invalid_setup);
- r->part_size = stbv_get_bits(f,24)+1;
- r->classifications = stbv_get_bits(f,6)+1;
- r->classbook = stbv_get_bits(f,8);
- if (r->classbook >= f->codebook_count) return stbv_error(f, VORBIS_invalid_setup);
+ 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) {
- stbv_uint8 high_bits=0;
- stbv_uint8 low_bits=stbv_get_bits(f,3);
- if (stbv_get_bits(f,1))
- high_bits = stbv_get_bits(f,5);
+ 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]) stbv_setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications);
- if (r->residue_books == NULL) return stbv_error(f, VORBIS_outofmem);
+ 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] = stbv_get_bits(f, 8);
- if (r->residue_books[j][k] >= f->codebook_count) return stbv_error(f, VORBIS_invalid_setup);
+ 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;
}
@@ -3982,14 +4046,14 @@ static int stbv_start_decoder(stbv_vorb *f)
}
// precompute the classifications[] array to avoid inner-loop mod/divide
// call it 'classdata' since we already have r->classifications
- r->classdata = (stbv_uint8 **) stbv_setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries);
- if (!r->classdata) return stbv_error(f, VORBIS_outofmem);
+ 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] = (stbv_uint8 *) stbv_setup_malloc(f, sizeof(r->classdata[j][0]) * classwords);
- if (r->classdata[j] == NULL) return stbv_error(f, VORBIS_outofmem);
+ 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;
@@ -3997,40 +4061,41 @@ static int stbv_start_decoder(stbv_vorb *f)
}
}
- f->mapping_count = stbv_get_bits(f,6)+1;
- f->mapping = (StbvMapping *) stbv_setup_malloc(f, f->mapping_count * sizeof(*f->mapping));
- if (f->mapping == NULL) return stbv_error(f, VORBIS_outofmem);
+ 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) {
- StbvMapping *m = f->mapping + i;
- int mapping_type = stbv_get_bits(f,16);
- if (mapping_type != 0) return stbv_error(f, VORBIS_invalid_setup);
- m->chan = (StbvMappingChannel *) stbv_setup_malloc(f, f->channels * sizeof(*m->chan));
- if (m->chan == NULL) return stbv_error(f, VORBIS_outofmem);
- if (stbv_get_bits(f,1))
- m->submaps = stbv_get_bits(f,4)+1;
+ 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 (stbv_get_bits(f,1)) {
- m->coupling_steps = stbv_get_bits(f,8)+1;
+ if (get_bits(f,1)) {
+ m->coupling_steps = get_bits(f,8)+1;
+ if (m->coupling_steps > f->channels) return error(f, VORBIS_invalid_setup);
for (k=0; k < m->coupling_steps; ++k) {
- m->chan[k].magnitude = stbv_get_bits(f, stbv_ilog(f->channels-1));
- m->chan[k].angle = stbv_get_bits(f, stbv_ilog(f->channels-1));
- if (m->chan[k].magnitude >= f->channels) return stbv_error(f, VORBIS_invalid_setup);
- if (m->chan[k].angle >= f->channels) return stbv_error(f, VORBIS_invalid_setup);
- if (m->chan[k].magnitude == m->chan[k].angle) return stbv_error(f, VORBIS_invalid_setup);
+ 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 (stbv_get_bits(f,2)) return stbv_error(f, VORBIS_invalid_setup);
+ 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 = stbv_get_bits(f, 4);
- if (m->chan[j].mux >= m->submaps) return stbv_error(f, VORBIS_invalid_setup);
+ 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
@@ -4038,64 +4103,64 @@ static int stbv_start_decoder(stbv_vorb *f)
m->chan[j].mux = 0;
for (j=0; j < m->submaps; ++j) {
- stbv_get_bits(f,8); // discard
- m->submap_floor[j] = stbv_get_bits(f,8);
- m->submap_residue[j] = stbv_get_bits(f,8);
- if (m->submap_floor[j] >= f->floor_count) return stbv_error(f, VORBIS_invalid_setup);
- if (m->submap_residue[j] >= f->residue_count) return stbv_error(f, VORBIS_invalid_setup);
+ 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 = stbv_get_bits(f, 6)+1;
+ f->mode_count = get_bits(f, 6)+1;
for (i=0; i < f->mode_count; ++i) {
- StbvMode *m = f->mode_config+i;
- m->blockflag = stbv_get_bits(f,1);
- m->windowtype = stbv_get_bits(f,16);
- m->transformtype = stbv_get_bits(f,16);
- m->mapping = stbv_get_bits(f,8);
- if (m->windowtype != 0) return stbv_error(f, VORBIS_invalid_setup);
- if (m->transformtype != 0) return stbv_error(f, VORBIS_invalid_setup);
- if (m->mapping >= f->mapping_count) return stbv_error(f, VORBIS_invalid_setup);
+ 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);
}
- stbv_flush_packet(f);
+ flush_packet(f);
f->previous_length = 0;
for (i=0; i < f->channels; ++i) {
- f->channel_buffers[i] = (float *) stbv_setup_malloc(f, sizeof(float) * f->blocksize_1);
- f->previous_window[i] = (float *) stbv_setup_malloc(f, sizeof(float) * f->blocksize_1/2);
- f->finalY[i] = (stbv_int16 *) stbv_setup_malloc(f, sizeof(stbv_int16) * longest_floorlist);
- if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) return stbv_error(f, VORBIS_outofmem);
+ 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);
memset(f->channel_buffers[i], 0, sizeof(float) * f->blocksize_1);
#ifdef STB_VORBIS_NO_DEFER_FLOOR
- f->floor_buffers[i] = (float *) stbv_setup_malloc(f, sizeof(float) * f->blocksize_1/2);
- if (f->floor_buffers[i] == NULL) return stbv_error(f, VORBIS_outofmem);
+ 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 (!stbv_init_blocksize(f, 0, f->blocksize_0)) return FALSE;
- if (!stbv_init_blocksize(f, 1, f->blocksize_1)) return FALSE;
+ 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 (stbv_integer_divide_table[1][1]==0)
- for (i=0; i < STBV_DIVTAB_NUMER; ++i)
- for (j=1; j < STBV_DIVTAB_DENOM; ++j)
- stbv_integer_divide_table[i][j] = i / j;
+ 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.
{
- stbv_uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1);
- stbv_uint32 classify_mem;
+ 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) {
- StbvResidue *r = f->residue_config + i;
+ Residue *r = f->residue_config + i;
unsigned int actual_size = f->blocksize_1 / 2;
unsigned int limit_r_begin = r->begin < actual_size ? r->begin : actual_size;
unsigned int limit_r_end = r->end < actual_size ? r->end : actual_size;
@@ -4105,7 +4170,7 @@ static int stbv_start_decoder(stbv_vorb *f)
max_part_read = part_read;
}
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
- classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(stbv_uint8 *));
+ classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(uint8 *));
#else
classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *));
#endif
@@ -4117,89 +4182,105 @@ static int stbv_start_decoder(stbv_vorb *f)
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 stbv_error(f, VORBIS_outofmem);
+ return error(f, VORBIS_outofmem);
}
- f->first_audio_page_offset = stb_vorbis_get_file_offset(f);
+ // @TODO: stb_vorbis_seek_start expects first_audio_page_offset to point to a page
+ // without PAGEFLAG_continued_packet, so this either points to the first page, or
+ // the page after the end of the headers. It might be cleaner to point to a page
+ // in the middle of the headers, when that's the page where the first audio packet
+ // starts, but we'd have to also correctly skip the end of any continued packet in
+ // stb_vorbis_seek_start.
+ if (f->next_seg == -1) {
+ f->first_audio_page_offset = stb_vorbis_get_file_offset(f);
+ } else {
+ f->first_audio_page_offset = 0;
+ }
return TRUE;
}
-static void stbv_vorbis_deinit(stb_vorbis *p)
+static void vorbis_deinit(stb_vorbis *p)
{
int i,j;
+
+ setup_free(p, p->vendor);
+ for (i=0; i < p->comment_list_length; ++i) {
+ setup_free(p, p->comment_list[i]);
+ }
+ setup_free(p, p->comment_list);
+
if (p->residue_config) {
for (i=0; i < p->residue_count; ++i) {
- StbvResidue *r = p->residue_config+i;
+ Residue *r = p->residue_config+i;
if (r->classdata) {
for (j=0; j < p->codebooks[r->classbook].entries; ++j)
- stbv_setup_free(p, r->classdata[j]);
- stbv_setup_free(p, r->classdata);
+ setup_free(p, r->classdata[j]);
+ setup_free(p, r->classdata);
}
- stbv_setup_free(p, r->residue_books);
+ setup_free(p, r->residue_books);
}
}
if (p->codebooks) {
- STBV_CHECK(p);
+ CHECK(p);
for (i=0; i < p->codebook_count; ++i) {
- StbvCodebook *c = p->codebooks + i;
- stbv_setup_free(p, c->codeword_lengths);
- stbv_setup_free(p, c->multiplicands);
- stbv_setup_free(p, c->codewords);
- stbv_setup_free(p, c->sorted_codewords);
+ 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
- stbv_setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL);
+ setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL);
}
- stbv_setup_free(p, p->codebooks);
+ setup_free(p, p->codebooks);
}
- stbv_setup_free(p, p->floor_config);
- stbv_setup_free(p, p->residue_config);
+ setup_free(p, p->floor_config);
+ setup_free(p, p->residue_config);
if (p->mapping) {
for (i=0; i < p->mapping_count; ++i)
- stbv_setup_free(p, p->mapping[i].chan);
- stbv_setup_free(p, p->mapping);
+ setup_free(p, p->mapping[i].chan);
+ setup_free(p, p->mapping);
}
- STBV_CHECK(p);
+ CHECK(p);
for (i=0; i < p->channels && i < STB_VORBIS_MAX_CHANNELS; ++i) {
- stbv_setup_free(p, p->channel_buffers[i]);
- stbv_setup_free(p, p->previous_window[i]);
+ setup_free(p, p->channel_buffers[i]);
+ setup_free(p, p->previous_window[i]);
#ifdef STB_VORBIS_NO_DEFER_FLOOR
- stbv_setup_free(p, p->floor_buffers[i]);
+ setup_free(p, p->floor_buffers[i]);
#endif
- stbv_setup_free(p, p->finalY[i]);
+ setup_free(p, p->finalY[i]);
}
for (i=0; i < 2; ++i) {
- stbv_setup_free(p, p->A[i]);
- stbv_setup_free(p, p->B[i]);
- stbv_setup_free(p, p->C[i]);
- stbv_setup_free(p, p->window[i]);
- stbv_setup_free(p, p->stbv_bit_reverse[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
}
-STBVDEF void stb_vorbis_close(stb_vorbis *p)
+void stb_vorbis_close(stb_vorbis *p)
{
if (p == NULL) return;
- stbv_vorbis_deinit(p);
- stbv_setup_free(p,p);
+ vorbis_deinit(p);
+ setup_free(p,p);
}
-static void stbv_vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z)
+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->alloc.alloc_buffer_length_in_bytes &= ~7;
p->temp_offset = p->alloc.alloc_buffer_length_in_bytes;
}
p->eof = 0;
@@ -4213,7 +4294,7 @@ static void stbv_vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z)
#endif
}
-STBVDEF int stb_vorbis_get_sample_offset(stb_vorbis *f)
+int stb_vorbis_get_sample_offset(stb_vorbis *f)
{
if (f->current_loc_valid)
return f->current_loc;
@@ -4221,7 +4302,7 @@ STBVDEF int stb_vorbis_get_sample_offset(stb_vorbis *f)
return -1;
}
-STBVDEF stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f)
+stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f)
{
stb_vorbis_info d;
d.channels = f->channels;
@@ -4233,22 +4314,31 @@ STBVDEF stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f)
return d;
}
-STBVDEF int stb_vorbis_get_error(stb_vorbis *f)
+stb_vorbis_comment stb_vorbis_get_comment(stb_vorbis *f)
+{
+ stb_vorbis_comment d;
+ d.vendor = f->vendor;
+ d.comment_list_length = f->comment_list_length;
+ d.comment_list = f->comment_list;
+ return d;
+}
+
+int stb_vorbis_get_error(stb_vorbis *f)
{
int e = f->error;
f->error = VORBIS__no_error;
return e;
}
-static stb_vorbis * stbv_vorbis_alloc(stb_vorbis *f)
+static stb_vorbis * vorbis_alloc(stb_vorbis *f)
{
- stb_vorbis *p = (stb_vorbis *) stbv_setup_malloc(f, sizeof(*p));
+ stb_vorbis *p = (stb_vorbis *) setup_malloc(f, sizeof(*p));
return p;
}
#ifndef STB_VORBIS_NO_PUSHDATA_API
-STBVDEF void stb_vorbis_flush_pushdata(stb_vorbis *f)
+void stb_vorbis_flush_pushdata(stb_vorbis *f)
{
f->previous_length = 0;
f->page_crc_tests = 0;
@@ -4260,7 +4350,7 @@ STBVDEF void stb_vorbis_flush_pushdata(stb_vorbis *f)
f->channel_buffer_end = 0;
}
-static int stbv_vorbis_search_for_page_pushdata(stbv_vorb *f, stbv_uint8 *data, int data_len)
+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)
@@ -4274,9 +4364,9 @@ static int stbv_vorbis_search_for_page_pushdata(stbv_vorb *f, stbv_uint8 *data,
// one that straddles a boundary
for (i=0; i < data_len; ++i) {
if (data[i] == 0x4f) {
- if (0==memcmp(data+i, stbv_ogg_page_header, 4)) {
+ if (0==memcmp(data+i, ogg_page_header, 4)) {
int j,len;
- stbv_uint32 crc;
+ 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
@@ -4291,10 +4381,10 @@ static int stbv_vorbis_search_for_page_pushdata(stbv_vorb *f, stbv_uint8 *data,
// scan everything up to the embedded crc (which we must 0)
crc = 0;
for (j=0; j < 22; ++j)
- crc = stbv_crc32_update(crc, data[i+j]);
+ crc = crc32_update(crc, data[i+j]);
// now process 4 0-bytes
for ( ; j < 26; ++j)
- crc = stbv_crc32_update(crc, 0);
+ 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;
@@ -4316,7 +4406,7 @@ static int stbv_vorbis_search_for_page_pushdata(stbv_vorb *f, stbv_uint8 *data,
}
for (i=0; i < f->page_crc_tests;) {
- stbv_uint32 crc;
+ uint32 crc;
int j;
int n = f->scan[i].bytes_done;
int m = f->scan[i].bytes_left;
@@ -4324,7 +4414,7 @@ static int stbv_vorbis_search_for_page_pushdata(stbv_vorb *f, stbv_uint8 *data,
// m is the bytes to scan in the current chunk
crc = f->scan[i].crc_so_far;
for (j=0; j < m; ++j)
- crc = stbv_crc32_update(crc, data[n+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) {
@@ -4351,9 +4441,9 @@ static int stbv_vorbis_search_for_page_pushdata(stbv_vorb *f, stbv_uint8 *data,
}
// return value: number of bytes we used
-STBVDEF int stb_vorbis_decode_frame_pushdata(
+int stb_vorbis_decode_frame_pushdata(
stb_vorbis *f, // the file we're decoding
- const stbv_uint8 *data, int data_len, // the memory available for 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
@@ -4362,30 +4452,30 @@ STBVDEF int stb_vorbis_decode_frame_pushdata(
int i;
int len,right,left;
- if (!STBV_IS_PUSH_MODE(f)) return stbv_error(f, VORBIS_invalid_api_mixing);
+ if (!IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
if (f->page_crc_tests >= 0) {
*samples = 0;
- return stbv_vorbis_search_for_page_pushdata(f, (stbv_uint8 *) data, data_len);
+ return vorbis_search_for_page_pushdata(f, (uint8 *) data, data_len);
}
- f->stream = (stbv_uint8 *) data;
- f->stream_end = (stbv_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 (!stbv_is_whole_packet_present(f, FALSE)) {
+ if (!is_whole_packet_present(f)) {
*samples = 0;
return 0;
}
- if (!stbv_vorbis_decode_packet(f, &len, &left, &right)) {
+ 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 (stbv_get8_packet(f) != STBV_EOP)
+ while (get8_packet(f) != EOP)
if (f->eof) break;
*samples = 0;
return (int) (f->stream - data);
@@ -4395,7 +4485,7 @@ STBVDEF int stb_vorbis_decode_frame_pushdata(
// 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 (stbv_get8_packet(f) != STBV_EOP)
+ while (get8_packet(f) != EOP)
if (f->eof) break;
*samples = 0;
return (int) (f->stream - data);
@@ -4411,7 +4501,7 @@ STBVDEF int stb_vorbis_decode_frame_pushdata(
}
// success!
- len = stbv_vorbis_finish_frame(f, len, left, right);
+ len = vorbis_finish_frame(f, len, left, right);
for (i=0; i < f->channels; ++i)
f->outputs[i] = f->channel_buffers[i] + left;
@@ -4421,42 +4511,43 @@ STBVDEF int stb_vorbis_decode_frame_pushdata(
return (int) (f->stream - data);
}
-STBVDEF stb_vorbis *stb_vorbis_open_pushdata(
+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;
- stbv_vorbis_init(&p, alloc);
- p.stream = (stbv_uint8 *) data;
- p.stream_end = (stbv_uint8 *) data + data_len;
+ vorbis_init(&p, alloc);
+ p.stream = (uint8 *) data;
+ p.stream_end = (uint8 *) data + data_len;
p.push_mode = TRUE;
- if (!stbv_start_decoder(&p)) {
+ if (!start_decoder(&p)) {
if (p.eof)
*error = VORBIS_need_more_data;
else
*error = p.error;
+ vorbis_deinit(&p);
return NULL;
}
- f = stbv_vorbis_alloc(&p);
+ f = vorbis_alloc(&p);
if (f) {
*f = p;
*data_used = (int) (f->stream - data);
*error = 0;
return f;
} else {
- stbv_vorbis_deinit(&p);
+ vorbis_deinit(&p);
return NULL;
}
}
#endif // STB_VORBIS_NO_PUSHDATA_API
-STBVDEF unsigned int stb_vorbis_get_file_offset(stb_vorbis *f)
+unsigned int stb_vorbis_get_file_offset(stb_vorbis *f)
{
#ifndef STB_VORBIS_NO_PUSHDATA_API
if (f->push_mode) return 0;
#endif
- if (STBV_USE_MEMORY(f)) return (unsigned int) (f->stream - f->stream_start);
+ 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
@@ -4467,12 +4558,12 @@ STBVDEF unsigned int stb_vorbis_get_file_offset(stb_vorbis *f)
// DATA-PULLING API
//
-static stbv_uint32 stbv_vorbis_find_page(stb_vorbis *f, stbv_uint32 *end, stbv_uint32 *last)
+static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last)
{
for(;;) {
int n;
if (f->eof) return 0;
- n = stbv_get8(f);
+ n = get8(f);
if (n == 0x4f) { // page header candidate
unsigned int retry_loc = stb_vorbis_get_file_offset(f);
int i;
@@ -4481,33 +4572,33 @@ static stbv_uint32 stbv_vorbis_find_page(stb_vorbis *f, stbv_uint32 *end, stbv_u
return 0;
// check the rest of the header
for (i=1; i < 4; ++i)
- if (stbv_get8(f) != stbv_ogg_page_header[i])
+ if (get8(f) != ogg_page_header[i])
break;
if (f->eof) return 0;
if (i == 4) {
- stbv_uint8 header[27];
- stbv_uint32 i, crc, goal, len;
+ uint8 header[27];
+ uint32 i, crc, goal, len;
for (i=0; i < 4; ++i)
- header[i] = stbv_ogg_page_header[i];
+ header[i] = ogg_page_header[i];
for (; i < 27; ++i)
- header[i] = stbv_get8(f);
+ 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);
+ goal = header[22] + (header[23] << 8) + (header[24]<<16) + ((uint32)header[25]<<24);
for (i=22; i < 26; ++i)
header[i] = 0;
crc = 0;
for (i=0; i < 27; ++i)
- crc = stbv_crc32_update(crc, header[i]);
+ crc = crc32_update(crc, header[i]);
len = 0;
for (i=0; i < header[26]; ++i) {
- int s = stbv_get8(f);
- crc = stbv_crc32_update(crc, s);
+ int s = get8(f);
+ crc = crc32_update(crc, s);
len += s;
}
if (len && f->eof) return 0;
for (i=0; i < len; ++i)
- crc = stbv_crc32_update(crc, stbv_get8(f));
+ crc = crc32_update(crc, get8(f));
// finished parsing probable page
if (crc == goal) {
// we could now check that it's either got the last
@@ -4526,19 +4617,19 @@ static stbv_uint32 stbv_vorbis_find_page(stb_vorbis *f, stbv_uint32 *end, stbv_u
else
*last = 0;
}
- stbv_set_file_offset(f, retry_loc-1);
+ set_file_offset(f, retry_loc-1);
return 1;
}
}
invalid:
// not a valid page, so rewind and look for next one
- stbv_set_file_offset(f, retry_loc);
+ set_file_offset(f, retry_loc);
}
}
}
-#define STBV_SAMPLE_unknown 0xffffffff
+#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
@@ -4549,19 +4640,19 @@ static stbv_uint32 stbv_vorbis_find_page(stb_vorbis *f, stbv_uint32 *end, stbv_u
// to try to bound either side of the binary search sensibly, while still
// working in O(log n) time if they fail.
-static int stbv_get_seek_page_info(stb_vorbis *f, StbvProbedPage *z)
+static int get_seek_page_info(stb_vorbis *f, ProbedPage *z)
{
- stbv_uint8 header[27], lacing[255];
+ 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
- stbv_getn(f, header, 27);
+ getn(f, header, 27);
if (header[0] != 'O' || header[1] != 'g' || header[2] != 'g' || header[3] != 'S')
return 0;
- stbv_getn(f, lacing, header[26]);
+ getn(f, lacing, header[26]);
// determine the length of the payload
len = 0;
@@ -4575,13 +4666,13 @@ static int stbv_get_seek_page_info(stb_vorbis *f, StbvProbedPage *z)
z->last_decoded_sample = header[6] + (header[7] << 8) + (header[8] << 16) + (header[9] << 24);
// restore file state to where we were
- stbv_set_file_offset(f, z->page_start);
+ set_file_offset(f, z->page_start);
return 1;
}
-// rarely used function to seek back to the preceeding page while finding the
+// rarely used function to seek back to the preceding page while finding the
// start of a packet
-static int stbv_go_to_page_before(stb_vorbis *f, unsigned int limit_offset)
+static int go_to_page_before(stb_vorbis *f, unsigned int limit_offset)
{
unsigned int previous_safe, end;
@@ -4591,12 +4682,12 @@ static int stbv_go_to_page_before(stb_vorbis *f, unsigned int limit_offset)
else
previous_safe = f->first_audio_page_offset;
- stbv_set_file_offset(f, previous_safe);
+ set_file_offset(f, previous_safe);
- while (stbv_vorbis_find_page(f, &end, NULL)) {
+ while (vorbis_find_page(f, &end, NULL)) {
if (end >= limit_offset && stb_vorbis_get_file_offset(f) < limit_offset)
return 1;
- stbv_set_file_offset(f, end);
+ set_file_offset(f, end);
}
return 0;
@@ -4606,42 +4697,45 @@ static int stbv_go_to_page_before(stb_vorbis *f, unsigned int limit_offset)
// 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 stbv_seek_to_sample_coarse(stb_vorbis *f, stbv_uint32 sample_number)
+static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number)
{
- StbvProbedPage left, right, mid;
+ ProbedPage left, right, mid;
int i, start_seg_with_known_loc, end_pos, page_start;
- stbv_uint32 delta, stream_length, padding;
- double offset, bytes_per_sample;
+ uint32 delta, stream_length, padding, last_sample_limit;
+ double offset = 0.0, bytes_per_sample = 0.0;
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 stbv_error(f, VORBIS_seek_without_length);
- if (sample_number > stream_length) return stbv_error(f, VORBIS_seek_invalid);
+ 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;
+ last_sample_limit = 0;
else
- sample_number -= padding;
+ last_sample_limit = sample_number - padding;
left = f->p_first;
while (left.last_decoded_sample == ~0U) {
// (untested) the first page does not have a 'last_decoded_sample'
- stbv_set_file_offset(f, left.page_end);
- if (!stbv_get_seek_page_info(f, &left)) goto error;
+ 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))
+ if (last_sample_limit <= left.last_decoded_sample) {
+ if (stb_vorbis_seek_start(f)) {
+ if (f->current_loc > sample_number)
+ return error(f, VORBIS_seek_failed);
return 1;
+ }
return 0;
}
@@ -4651,17 +4745,17 @@ static int stbv_seek_to_sample_coarse(stb_vorbis *f, stbv_uint32 sample_number)
delta = right.page_start - left.page_end;
if (delta <= 65536) {
// there's only 64K left to search - handle it linearly
- stbv_set_file_offset(f, left.page_end);
+ 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);
+ offset = left.page_start + bytes_per_sample * (last_sample_limit - 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;
+ double error = ((double) last_sample_limit - mid.last_decoded_sample) * bytes_per_sample;
if (error >= 0 && error < 8000) error = 8000;
if (error < 0 && error > -8000) error = -8000;
offset += error * 2;
@@ -4673,41 +4767,43 @@ static int stbv_seek_to_sample_coarse(stb_vorbis *f, stbv_uint32 sample_number)
if (offset > right.page_start - 65536)
offset = right.page_start - 65536;
- stbv_set_file_offset(f, (unsigned int) offset);
+ 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)
- stbv_set_file_offset(f, left.page_end + (delta / 2) - 32768);
+ set_file_offset(f, left.page_end + (delta / 2) - 32768);
}
- if (!stbv_vorbis_find_page(f, NULL, NULL)) goto error;
+ if (!vorbis_find_page(f, NULL, NULL)) goto error;
}
for (;;) {
- if (!stbv_get_seek_page_info(f, &mid)) goto error;
+ if (!get_seek_page_info(f, &mid)) goto error;
if (mid.last_decoded_sample != ~0U) break;
// (untested) no frames end on this page
- stbv_set_file_offset(f, mid.page_end);
+ 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;
+ // and we're close enough (if it wasn't an interpolation probe).
+ if (mid.page_start == right.page_start) {
+ if (probe >= 2 || delta <= 65536)
+ break;
+ } else {
+ if (last_sample_limit < mid.last_decoded_sample)
+ right = mid;
+ else
+ left = mid;
+ }
++probe;
}
// seek back to start of the last packet
page_start = left.page_start;
- stbv_set_file_offset(f, page_start);
- if (!stbv_start_page(f)) return stbv_error(f, VORBIS_seek_failed);
+ 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);
@@ -4718,15 +4814,15 @@ static int stbv_seek_to_sample_coarse(stb_vorbis *f, stbv_uint32 sample_number)
start_seg_with_known_loc = i;
- if (start_seg_with_known_loc > 0 || !(f->page_flag & STBV_PAGEFLAG_continued_packet))
+ if (start_seg_with_known_loc > 0 || !(f->page_flag & PAGEFLAG_continued_packet))
break;
// (untested) the final packet begins on an earlier page
- if (!stbv_go_to_page_before(f, page_start))
+ if (!go_to_page_before(f, page_start))
goto error;
page_start = stb_vorbis_get_file_offset(f);
- if (!stbv_start_page(f)) goto error;
+ if (!start_page(f)) goto error;
end_pos = f->segment_count - 1;
}
@@ -4740,38 +4836,38 @@ static int stbv_seek_to_sample_coarse(stb_vorbis *f, stbv_uint32 sample_number)
f->next_seg = start_seg_with_known_loc;
for (i = 0; i < start_seg_with_known_loc; i++)
- stbv_skip(f, f->segments[i]);
+ skip(f, f->segments[i]);
// start decoding (optimizable - this frame is generally discarded)
- if (!stbv_vorbis_pump_first_frame(f))
+ if (!vorbis_pump_first_frame(f))
return 0;
if (f->current_loc > sample_number)
- return stbv_error(f, VORBIS_seek_failed);
+ return error(f, VORBIS_seek_failed);
return 1;
error:
// try to restore the file to a valid state
stb_vorbis_seek_start(f);
- return stbv_error(f, VORBIS_seek_failed);
+ return error(f, VORBIS_seek_failed);
}
-// the same as stbv_vorbis_decode_initial, but without advancing
-static int stbv_peek_decode_initial(stbv_vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode)
+// 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 (!stbv_vorbis_decode_initial(f, p_left_start, p_left_end, p_right_start, p_right_end, mode))
+ 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 + stbv_ilog(f->mode_count-1);
+ 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;
- stbv_skip(f, -bytes_read);
+ skip(f, -bytes_read);
if (f->next_seg == -1)
f->next_seg = f->segment_count - 1;
else
@@ -4781,14 +4877,14 @@ static int stbv_peek_decode_initial(stbv_vorb *f, int *p_left_start, int *p_left
return 1;
}
-STBVDEF int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number)
+int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number)
{
- stbv_uint32 max_frame_samples;
+ uint32 max_frame_samples;
- if (STBV_IS_PUSH_MODE(f)) return stbv_error(f, VORBIS_invalid_api_mixing);
+ if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
// fast page-level search
- if (!stbv_seek_to_sample_coarse(f, sample_number))
+ if (!seek_to_sample_coarse(f, sample_number))
return 0;
assert(f->current_loc_valid);
@@ -4798,36 +4894,36 @@ STBVDEF int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number)
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 (!stbv_peek_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode))
- return stbv_error(f, VORBIS_seek_failed);
+ 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
- stbv_vorbis_pump_first_frame(f);
+ vorbis_pump_first_frame(f);
} else {
// this frame is too early to be relevant
f->current_loc += frame_samples;
f->previous_length = 0;
- stbv_maybe_start_packet(f);
- stbv_flush_packet(f);
+ maybe_start_packet(f);
+ flush_packet(f);
}
}
- // the next frame will start with the sample
- assert(f->current_loc == sample_number);
+ // the next frame should start with the sample
+ if (f->current_loc != sample_number) return error(f, VORBIS_seek_failed);
return 1;
}
-STBVDEF int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number)
+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;
- stbv_uint32 frame_start = f->current_loc;
+ 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);
@@ -4837,25 +4933,25 @@ STBVDEF int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number)
return 1;
}
-STBVDEF int stb_vorbis_seek_start(stb_vorbis *f)
+int stb_vorbis_seek_start(stb_vorbis *f)
{
- if (STBV_IS_PUSH_MODE(f)) { return stbv_error(f, VORBIS_invalid_api_mixing); }
- stbv_set_file_offset(f, f->first_audio_page_offset);
+ 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 stbv_vorbis_pump_first_frame(f);
+ return vorbis_pump_first_frame(f);
}
-STBVDEF unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *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 (STBV_IS_PUSH_MODE(f)) return stbv_error(f, VORBIS_invalid_api_mixing);
+ if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
if (!f->total_samples) {
unsigned int last;
- stbv_uint32 lo,hi;
+ uint32 lo,hi;
char header[6];
// first, store the current decode position so we can restore it
@@ -4868,11 +4964,11 @@ STBVDEF unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f)
else
previous_safe = f->first_audio_page_offset;
- stbv_set_file_offset(f, previous_safe);
+ 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 (!stbv_vorbis_find_page(f, &end, &last)) {
+ 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;
@@ -4886,26 +4982,26 @@ STBVDEF unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f)
// this allows us to stop short of a 'file_section' end without
// explicitly checking the length of the section
while (!last) {
- stbv_set_file_offset(f, end);
- if (!stbv_vorbis_find_page(f, &end, &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;
+ //previous_safe = last_page_loc+1; // NOTE: not used after this point, but note for debugging
last_page_loc = stb_vorbis_get_file_offset(f);
}
- stbv_set_file_offset(f, last_page_loc);
+ set_file_offset(f, last_page_loc);
// parse the header
- stbv_getn(f, (unsigned char *)header, 6);
+ getn(f, (unsigned char *)header, 6);
// extract the absolute granule position
- lo = stbv_get32(f);
- hi = stbv_get32(f);
+ lo = get32(f);
+ hi = get32(f);
if (lo == 0xffffffff && hi == 0xffffffff) {
f->error = VORBIS_cant_find_last_page;
- f->total_samples = STBV_SAMPLE_unknown;
+ f->total_samples = SAMPLE_unknown;
goto done;
}
if (hi)
@@ -4917,29 +5013,29 @@ STBVDEF unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f)
f->p_last.last_decoded_sample = lo;
done:
- stbv_set_file_offset(f, restore_offset);
+ set_file_offset(f, restore_offset);
}
- return f->total_samples == STBV_SAMPLE_unknown ? 0 : f->total_samples;
+ return f->total_samples == SAMPLE_unknown ? 0 : f->total_samples;
}
-STBVDEF float stb_vorbis_stream_length_in_seconds(stb_vorbis *f)
+float stb_vorbis_stream_length_in_seconds(stb_vorbis *f)
{
return stb_vorbis_stream_length_in_samples(f) / (float) f->sample_rate;
}
-STBVDEF int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output)
+int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output)
{
int len, right,left,i;
- if (STBV_IS_PUSH_MODE(f)) return stbv_error(f, VORBIS_invalid_api_mixing);
+ if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
- if (!stbv_vorbis_decode_packet(f, &len, &left, &right)) {
+ if (!vorbis_decode_packet(f, &len, &left, &right)) {
f->channel_buffer_start = f->channel_buffer_end = 0;
return 0;
}
- len = stbv_vorbis_finish_frame(f, len, left, right);
+ len = vorbis_finish_frame(f, len, left, right);
for (i=0; i < f->channels; ++i)
f->outputs[i] = f->channel_buffers[i] + left;
@@ -4953,28 +5049,28 @@ STBVDEF int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***ou
#ifndef STB_VORBIS_NO_STDIO
-STBVDEF 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 * 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;
- stbv_vorbis_init(&p, alloc);
+ vorbis_init(&p, alloc);
p.f = file;
- p.f_start = (stbv_uint32) ftell(file);
+ p.f_start = (uint32) ftell(file);
p.stream_len = length;
p.close_on_free = close_on_free;
- if (stbv_start_decoder(&p)) {
- f = stbv_vorbis_alloc(&p);
+ if (start_decoder(&p)) {
+ f = vorbis_alloc(&p);
if (f) {
*f = p;
- stbv_vorbis_pump_first_frame(f);
+ vorbis_pump_first_frame(f);
return f;
}
}
if (error) *error = p.error;
- stbv_vorbis_deinit(&p);
+ vorbis_deinit(&p);
return NULL;
}
-STBVDEF stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc)
+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);
@@ -4984,58 +5080,67 @@ STBVDEF stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *er
return stb_vorbis_open_file_section(file, close_on_free, error, alloc, len);
}
-STBVDEF stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc)
+stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc)
{
- FILE *f = fopen(filename, "rb");
- if (f)
+ FILE *f;
+#if defined(_WIN32) && defined(__STDC_WANT_SECURE_LIB__)
+ if (0 != fopen_s(&f, filename, "rb"))
+ f = NULL;
+#else
+ f = fopen(filename, "rb");
+#endif
+ 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
-STBVDEF stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc)
+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;
- stbv_vorbis_init(&p, alloc);
- p.stream = (stbv_uint8 *) data;
- p.stream_end = (stbv_uint8 *) data + len;
- p.stream_start = (stbv_uint8 *) p.stream;
+ if (!data) {
+ if (error) *error = VORBIS_unexpected_eof;
+ 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 (stbv_start_decoder(&p)) {
- f = stbv_vorbis_alloc(&p);
+ if (start_decoder(&p)) {
+ f = vorbis_alloc(&p);
if (f) {
*f = p;
- stbv_vorbis_pump_first_frame(f);
+ vorbis_pump_first_frame(f);
if (error) *error = VORBIS__no_error;
return f;
}
}
if (error) *error = p.error;
- stbv_vorbis_deinit(&p);
+ vorbis_deinit(&p);
return NULL;
}
#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
-#define STBV_PLAYBACK_MONO 1
-#define STBV_PLAYBACK_LEFT 2
-#define STBV_PLAYBACK_RIGHT 4
+#define PLAYBACK_MONO 1
+#define PLAYBACK_LEFT 2
+#define PLAYBACK_RIGHT 4
-#define STBV_L (STBV_PLAYBACK_LEFT | STBV_PLAYBACK_MONO)
-#define STBV_C (STBV_PLAYBACK_LEFT | STBV_PLAYBACK_RIGHT | STBV_PLAYBACK_MONO)
-#define STBV_R (STBV_PLAYBACK_RIGHT | STBV_PLAYBACK_MONO)
+#define L (PLAYBACK_LEFT | PLAYBACK_MONO)
+#define C (PLAYBACK_LEFT | PLAYBACK_RIGHT | PLAYBACK_MONO)
+#define R (PLAYBACK_RIGHT | PLAYBACK_MONO)
-static stbv_int8 stbv_channel_position[7][6] =
+static int8 channel_position[7][6] =
{
{ 0 },
- { STBV_C },
- { STBV_L, STBV_R },
- { STBV_L, STBV_C, STBV_R },
- { STBV_L, STBV_R, STBV_L, STBV_R },
- { STBV_L, STBV_C, STBV_R, STBV_L, STBV_R },
- { STBV_L, STBV_C, STBV_R, STBV_L, STBV_R, STBV_C },
+ { C },
+ { L, R },
+ { L, C, R },
+ { L, R, L, R },
+ { L, C, R, L, R },
+ { L, C, R, L, R, C },
};
@@ -5043,139 +5148,141 @@ static stbv_int8 stbv_channel_position[7][6] =
typedef union {
float f;
int i;
- } stbv_float_conv;
+ } float_conv;
typedef char stb_vorbis_float_size_test[sizeof(float)==4 && sizeof(int) == 4];
- #define STBV_FASTDEF(x) stbv_float_conv x
+ #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 STBV_MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT))
- #define STBV_ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22))
- #define STBV_FAST_SCALED_FLOAT_TO_INT(temp,x,s) (temp.f = (x) + STBV_MAGIC(s), temp.i - STBV_ADDEND(s))
- #define stbv_check_endianness()
+ #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 STBV_FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s))))
- #define stbv_check_endianness()
- #define STBV_FASTDEF(x)
+ #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s))))
+ #define check_endianness()
+ #define FASTDEF(x)
#endif
-static void stbv_copy_samples(short *dest, float *src, int len)
+static void copy_samples(short *dest, float *src, int len)
{
int i;
- stbv_check_endianness();
+ check_endianness();
for (i=0; i < len; ++i) {
- STBV_FASTDEF(temp);
- int v = STBV_FAST_SCALED_FLOAT_TO_INT(temp, src[i],15);
+ 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 stbv_compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len)
+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;
- stbv_check_endianness();
- for (o = 0; o < len; o += BUFFER_SIZE) {
+ #define STB_BUFFER_SIZE 32
+ float buffer[STB_BUFFER_SIZE];
+ int i,j,o,n = STB_BUFFER_SIZE;
+ check_endianness();
+ for (o = 0; o < len; o += STB_BUFFER_SIZE) {
memset(buffer, 0, sizeof(buffer));
if (o + n > len) n = len - o;
for (j=0; j < num_c; ++j) {
- if (stbv_channel_position[num_c][j] & mask) {
+ 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) {
- STBV_FASTDEF(temp);
- int v = STBV_FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15);
+ 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;
}
}
+ #undef STB_BUFFER_SIZE
}
-static void stbv_compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len)
+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;
+ #define STB_BUFFER_SIZE 32
+ float buffer[STB_BUFFER_SIZE];
+ int i,j,o,n = STB_BUFFER_SIZE >> 1;
// o is the offset in the source data
- stbv_check_endianness();
- for (o = 0; o < len; o += BUFFER_SIZE >> 1) {
+ check_endianness();
+ for (o = 0; o < len; o += STB_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 = stbv_channel_position[num_c][j] & (STBV_PLAYBACK_LEFT | STBV_PLAYBACK_RIGHT);
- if (m == (STBV_PLAYBACK_LEFT | STBV_PLAYBACK_RIGHT)) {
+ 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 == STBV_PLAYBACK_LEFT) {
+ } else if (m == PLAYBACK_LEFT) {
for (i=0; i < n; ++i) {
buffer[i*2+0] += data[j][d_offset+o+i];
}
- } else if (m == STBV_PLAYBACK_RIGHT) {
+ } 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) {
- STBV_FASTDEF(temp);
- int v = STBV_FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15);
+ 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;
}
}
+ #undef STB_BUFFER_SIZE
}
-static void stbv_convert_samples_short(int buf_c, short **buffer, int b_offset, int data_c, float **data, int d_offset, int samples)
+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}, {STBV_PLAYBACK_MONO}, {STBV_PLAYBACK_LEFT, STBV_PLAYBACK_RIGHT} };
+ static int channel_selector[3][2] = { {0}, {PLAYBACK_MONO}, {PLAYBACK_LEFT, PLAYBACK_RIGHT} };
for (i=0; i < buf_c; ++i)
- stbv_compute_samples(channel_selector[buf_c][i], buffer[i]+b_offset, data_c, data, d_offset, samples);
+ 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)
- stbv_copy_samples(buffer[i]+b_offset, data[i]+d_offset, samples);
+ 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);
}
}
-STBVDEF int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples)
+int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples)
{
- float **output;
+ float **output = NULL;
int len = stb_vorbis_get_frame_float(f, NULL, &output);
if (len > num_samples) len = num_samples;
if (len)
- stbv_convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len);
+ convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len);
return len;
}
-static void stbv_convert_channels_short_interleaved(int buf_c, short *buffer, int data_c, float **data, int d_offset, int len)
+static void convert_channels_short_interleaved(int buf_c, short *buffer, int data_c, float **data, int d_offset, int len)
{
int i;
- stbv_check_endianness();
+ check_endianness();
if (buf_c != data_c && buf_c <= 2 && data_c <= 6) {
assert(buf_c == 2);
for (i=0; i < buf_c; ++i)
- stbv_compute_stereo_samples(buffer, data_c, data, d_offset, len);
+ 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) {
- STBV_FASTDEF(temp);
+ FASTDEF(temp);
float f = data[i][d_offset+j];
- int v = STBV_FAST_SCALED_FLOAT_TO_INT(temp, f,15);//data[i][d_offset+j],15);
+ 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;
@@ -5186,7 +5293,7 @@ static void stbv_convert_channels_short_interleaved(int buf_c, short *buffer, in
}
}
-STBVDEF int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts)
+int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts)
{
float **output;
int len;
@@ -5194,23 +5301,21 @@ STBVDEF int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, sho
len = stb_vorbis_get_frame_float(f, NULL, &output);
if (len) {
if (len*num_c > num_shorts) len = num_shorts / num_c;
- stbv_convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len);
+ convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len);
}
return len;
}
-STBVDEF int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts)
+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)
- stbv_convert_channels_short_interleaved(channels, buffer, f->channels, f->channel_buffers, f->channel_buffer_start, 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;
@@ -5220,17 +5325,15 @@ STBVDEF int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels
return n;
}
-STBVDEF int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int len)
+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)
- stbv_convert_samples_short(channels, buffer, n, f->channels, f->channel_buffers, f->channel_buffer_start, 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;
@@ -5240,7 +5343,7 @@ STBVDEF int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **bu
}
#ifndef STB_VORBIS_NO_STDIO
-STBVDEF int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output)
+int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output)
{
int data_len, offset, total, limit, error;
short *data;
@@ -5280,7 +5383,7 @@ STBVDEF int stb_vorbis_decode_filename(const char *filename, int *channels, int
}
#endif // NO_STDIO
-STBVDEF int stb_vorbis_decode_memory(const stbv_uint8 *mem, int len, int *channels, int *sample_rate, short **output)
+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;
@@ -5320,7 +5423,7 @@ STBVDEF int stb_vorbis_decode_memory(const stbv_uint8 *mem, int len, int *channe
}
#endif // STB_VORBIS_NO_INTEGER_CONVERSION
-STBVDEF int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats)
+int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats)
{
float **outputs;
int len = num_floats / channels;
@@ -5347,7 +5450,7 @@ STBVDEF int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels
return n;
}
-STBVDEF int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples)
+int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples)
{
float **outputs;
int n=0;
@@ -5375,14 +5478,20 @@ STBVDEF int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **bu
#endif // STB_VORBIS_NO_PULLDATA_API
/* Version history
+ 1.17 - 2019-07-08 - fix CVE-2019-13217, -13218, -13219, -13220, -13221, -13222, -13223
+ found with Mayhem by ForAllSecure
+ 1.16 - 2019-03-04 - fix warnings
+ 1.15 - 2019-02-07 - explicit failure if Ogg Skeleton data is found
+ 1.14 - 2018-02-11 - delete bogus dealloca usage
+ 1.13 - 2018-01-29 - fix truncation of last frame (hopefully)
1.12 - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files
- 1.11 - 2017-07-23 - fix MinGW compilation
- 1.10 - 2017-03-03 - more robust seeking; fix negative stbv_ilog(); clear error in open_memory
+ 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 '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
+ 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
@@ -5429,7 +5538,7 @@ STBVDEF int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **bu
0.90 - first public release
*/
-#endif // STB_VORBIS_IMPLEMENTATION
+#endif // STB_VORBIS_HEADER_ONLY
/*
@@ -5438,38 +5547,38 @@ 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
+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
+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
+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,
+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
+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
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------------------
*/
diff --git a/src/external/tinyobj_loader_c.h b/src/external/tinyobj_loader_c.h
index 6d34d25f7..502a55a7e 100644
--- a/src/external/tinyobj_loader_c.h
+++ b/src/external/tinyobj_loader_c.h
@@ -746,7 +746,7 @@ static int tinyobj_parse_and_index_mtl_file(tinyobj_material_t **materials_out,
(*materials_out) = NULL;
(*num_materials_out) = 0;
- fp = fopen(filename, "r");
+ fp = fopen(filename, "rt");
if (!fp) {
fprintf(stderr, "TINYOBJ: Error reading file '%s': %s (%d)\n", filename, strerror(errno), errno);
return TINYOBJ_ERROR_FILE_OPERATION;
diff --git a/src/external/vox_loader.h b/src/external/vox_loader.h
index a7a161c7f..6df10b518 100644
--- a/src/external/vox_loader.h
+++ b/src/external/vox_loader.h
@@ -67,7 +67,7 @@ revision history:
#define VOX_SUCCESS (0)
#define VOX_ERROR_FILE_NOT_FOUND (-1)
#define VOX_ERROR_INVALID_FORMAT (-2)
-#define VOX_ERROR_FILE_VERSION_TOO_OLD (-3)
+#define VOX_ERROR_FILE_VERSION_NOT_MATCH (-3)
// VoxColor, 4 components, R8G8B8A8 (32bit)
typedef struct {
@@ -538,31 +538,26 @@ int Vox_LoadFromMemory(unsigned char* pvoxData, unsigned int voxDataSize, VoxArr
// @raysan5: Reviewed (unsigned long) -> (unsigned int), possible issue with Ubuntu 18.04 64bit
// @raysan5: reviewed signature loading
- unsigned char signature[4] = { 0 };
unsigned char* fileData = pvoxData;
unsigned char* fileDataPtr = fileData;
unsigned char* endfileDataPtr = fileData + voxDataSize;
- signature[0] = fileDataPtr[0];
- signature[1] = fileDataPtr[1];
- signature[2] = fileDataPtr[2];
- signature[3] = fileDataPtr[3];
- fileDataPtr += 4;
-
- if ((signature[0] != 'V') && (signature[0] != 'O') && (signature[0] != 'X') && (signature[0] != ' '))
+ if (strncmp((char*)fileDataPtr, "VOX ", 4) != 0)
{
return VOX_ERROR_INVALID_FORMAT; //"Not an MagicaVoxel File format"
}
+ fileDataPtr += 4;
+
// @raysan5: reviewed version loading
unsigned int version = 0;
version = ((unsigned int*)fileDataPtr)[0];
fileDataPtr += 4;
- if (version < 150)
+ if (version != 150 && version != 200)
{
- return VOX_ERROR_FILE_VERSION_TOO_OLD; //"MagicaVoxel version too old"
+ return VOX_ERROR_FILE_VERSION_NOT_MATCH; //"MagicaVoxel version doesn't match"
}
diff --git a/src/minshell.html b/src/minshell.html
index 4f0d6ade0..2aa75578f 100644
--- a/src/minshell.html
+++ b/src/minshell.html
@@ -1,5 +1,5 @@
-
+
diff --git a/src/raudio.c b/src/raudio.c
index d1b47f64a..9d1683a1f 100644
--- a/src/raudio.c
+++ b/src/raudio.c
@@ -11,22 +11,22 @@
* - Play/Stop/Pause/Resume loaded audio
*
* CONFIGURATION:
+* #define SUPPORT_MODULE_RAUDIO
+* raudio module is included in the build
*
-* #define SUPPORT_MODULE_RAUDIO
-* raudio module is included in the build
+* #define RAUDIO_STANDALONE
+* Define to use the module as standalone library (independently of raylib).
+* Required types and functions are defined in the same module.
*
-* #define RAUDIO_STANDALONE
-* Define to use the module as standalone library (independently of raylib).
-* Required types and functions are defined in the same module.
-*
-* #define SUPPORT_FILEFORMAT_WAV
-* #define SUPPORT_FILEFORMAT_OGG
-* #define SUPPORT_FILEFORMAT_XM
-* #define SUPPORT_FILEFORMAT_MOD
-* #define SUPPORT_FILEFORMAT_FLAC
-* #define SUPPORT_FILEFORMAT_MP3
-* Selected desired fileformats to be supported for loading. Some of those formats are
-* supported by default, to remove support, just comment unrequired #define in this module
+* #define SUPPORT_FILEFORMAT_WAV
+* #define SUPPORT_FILEFORMAT_OGG
+* #define SUPPORT_FILEFORMAT_MP3
+* #define SUPPORT_FILEFORMAT_QOA
+* #define SUPPORT_FILEFORMAT_FLAC
+* #define SUPPORT_FILEFORMAT_XM
+* #define SUPPORT_FILEFORMAT_MOD
+* Selected desired fileformats to be supported for loading. Some of those formats are
+* supported by default, to remove support, just comment unrequired #define in this module
*
* DEPENDENCIES:
* miniaudio.h - Audio device management lib (https://github.com/mackron/miniaudio)
@@ -41,7 +41,7 @@
* David Reid (github: @mackron) (Nov. 2017):
* - Complete port to miniaudio library
*
-* Joshua Reisenauer (github: @kd7tck) (2015)
+* Joshua Reisenauer (github: @kd7tck) (2015):
* - XM audio module support (jar_xm)
* - MOD audio module support (jar_mod)
* - Mixing channels support
@@ -50,7 +50,7 @@
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -167,6 +167,10 @@ typedef struct tagBITMAPINFOHEADER {
#define MA_NO_WAV
#define MA_NO_FLAC
#define MA_NO_MP3
+
+// Threading model: Default: [0] COINIT_MULTITHREADED: COM calls objects on any thread (free threading)
+#define MA_COINIT_VALUE 2 // [2] COINIT_APARTMENTTHREADED: Each object has its own thread (apartment model)
+
#define MINIAUDIO_IMPLEMENTATION
//#define MA_DEBUG_OUTPUT
#include "external/miniaudio.h" // Audio device initialization and management
@@ -196,29 +200,6 @@ typedef struct tagBITMAPINFOHEADER {
#endif
#endif
-#if defined(SUPPORT_FILEFORMAT_OGG)
- // TODO: Remap stb_vorbis malloc()/free() calls to RL_MALLOC/RL_FREE
-
- #define STB_VORBIS_IMPLEMENTATION
- #include "external/stb_vorbis.h" // OGG loading functions
-#endif
-
-#if defined(SUPPORT_FILEFORMAT_XM)
- #define JARXM_MALLOC RL_MALLOC
- #define JARXM_FREE RL_FREE
-
- #define JAR_XM_IMPLEMENTATION
- #include "external/jar_xm.h" // XM loading functions
-#endif
-
-#if defined(SUPPORT_FILEFORMAT_MOD)
- #define JARMOD_MALLOC RL_MALLOC
- #define JARMOD_FREE RL_FREE
-
- #define JAR_MOD_IMPLEMENTATION
- #include "external/jar_mod.h" // MOD loading functions
-#endif
-
#if defined(SUPPORT_FILEFORMAT_WAV)
#define DRWAV_MALLOC RL_MALLOC
#define DRWAV_REALLOC RL_REALLOC
@@ -228,6 +209,11 @@ typedef struct tagBITMAPINFOHEADER {
#include "external/dr_wav.h" // WAV loading functions
#endif
+#if defined(SUPPORT_FILEFORMAT_OGG)
+ // TODO: Remap stb_vorbis malloc()/free() calls to RL_MALLOC/RL_FREE
+ #include "external/stb_vorbis.c" // OGG loading functions
+#endif
+
#if defined(SUPPORT_FILEFORMAT_MP3)
#define DRMP3_MALLOC RL_MALLOC
#define DRMP3_REALLOC RL_REALLOC
@@ -237,6 +223,26 @@ typedef struct tagBITMAPINFOHEADER {
#include "external/dr_mp3.h" // MP3 loading functions
#endif
+#if defined(SUPPORT_FILEFORMAT_QOA)
+ #define QOA_MALLOC RL_MALLOC
+ #define QOA_FREE RL_FREE
+
+ #if defined(_MSC_VER) // Disable some MSVC warning
+ #pragma warning(push)
+ #pragma warning(disable : 4018)
+ #pragma warning(disable : 4267)
+ #pragma warning(disable : 4244)
+ #endif
+
+ #define QOA_IMPLEMENTATION
+ #include "external/qoa.h" // QOA loading and saving functions
+ #include "external/qoaplay.c" // QOA stream playing helper functions
+
+ #if defined(_MSC_VER)
+ #pragma warning(pop) // Disable MSVC warning suppression
+ #endif
+#endif
+
#if defined(SUPPORT_FILEFORMAT_FLAC)
#define DRFLAC_MALLOC RL_MALLOC
#define DRFLAC_REALLOC RL_REALLOC
@@ -247,6 +253,31 @@ typedef struct tagBITMAPINFOHEADER {
#include "external/dr_flac.h" // FLAC loading functions
#endif
+#if defined(SUPPORT_FILEFORMAT_XM)
+ #define JARXM_MALLOC RL_MALLOC
+ #define JARXM_FREE RL_FREE
+
+ #if defined(_MSC_VER) // Disable some MSVC warning
+ #pragma warning(push)
+ #pragma warning(disable : 4244)
+ #endif
+
+ #define JAR_XM_IMPLEMENTATION
+ #include "external/jar_xm.h" // XM loading functions
+
+ #if defined(_MSC_VER)
+ #pragma warning(pop) // Disable MSVC warning suppression
+ #endif
+#endif
+
+#if defined(SUPPORT_FILEFORMAT_MOD)
+ #define JARMOD_MALLOC RL_MALLOC
+ #define JARMOD_FREE RL_FREE
+
+ #define JAR_MOD_IMPLEMENTATION
+ #include "external/jar_mod.h" // MOD loading functions
+#endif
+
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
@@ -267,20 +298,6 @@ typedef struct tagBITMAPINFOHEADER {
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
-
-// Music context type
-// NOTE: Depends on data structure provided by the library
-// in charge of reading the different file types
-typedef enum {
- MUSIC_AUDIO_NONE = 0, // No audio context loaded
- MUSIC_AUDIO_WAV, // WAV audio context
- MUSIC_AUDIO_OGG, // OGG audio context
- MUSIC_AUDIO_FLAC, // FLAC audio context
- MUSIC_AUDIO_MP3, // MP3 audio context
- MUSIC_MODULE_XM, // XM module audio context
- MUSIC_MODULE_MOD // MOD module audio context
-} MusicContextType;
-
#if defined(RAUDIO_STANDALONE)
// Trace log level
// NOTE: Organized by priority level
@@ -296,8 +313,22 @@ typedef enum {
} TraceLogLevel;
#endif
+// Music context type
+// NOTE: Depends on data structure provided by the library
+// in charge of reading the different file types
+typedef enum {
+ MUSIC_AUDIO_NONE = 0, // No audio context loaded
+ MUSIC_AUDIO_WAV, // WAV audio context
+ MUSIC_AUDIO_OGG, // OGG audio context
+ MUSIC_AUDIO_FLAC, // FLAC audio context
+ MUSIC_AUDIO_MP3, // MP3 audio context
+ MUSIC_AUDIO_QOA, // QOA audio context
+ MUSIC_MODULE_XM, // XM module audio context
+ MUSIC_MODULE_MOD // MOD module audio context
+} MusicContextType;
+
// NOTE: Different logic is used when feeding data to the playback device
-// depending on whether or not data is streamed (Music vs Sound)
+// depending on whether data is streamed (Music vs Sound)
typedef enum {
AUDIO_BUFFER_USAGE_STATIC = 0,
AUDIO_BUFFER_USAGE_STREAM
@@ -355,11 +386,7 @@ typedef struct AudioData {
AudioBuffer *last; // Pointer to last AudioBuffer in the list
int defaultSize; // Default audio buffer size for audio streams
} Buffer;
- struct {
- unsigned int poolCounter; // AudioBuffer pointers pool counter
- AudioBuffer *pool[MAX_AUDIO_BUFFER_POOL_CHANNELS]; // Multichannel AudioBuffer pointers pool
- unsigned int channels[MAX_AUDIO_BUFFER_POOL_CHANNELS]; // AudioBuffer pool channels
- } MultiChannel;
+ rAudioProcessor *mixedProcessor;
} AudioData;
//----------------------------------------------------------------------------------
@@ -371,7 +398,8 @@ static AudioData AUDIO = { // Global AUDIO context
// After some math, considering a sampleRate of 48000, a buffer refill rate of 1/60 seconds and a
// standard double-buffering system, a 4096 samples buffer has been chosen, it should be enough
// In case of music-stalls, just increase this number
- .Buffer.defaultSize = 0
+ .Buffer.defaultSize = 0,
+ .mixedProcessor = NULL
};
//----------------------------------------------------------------------------------
@@ -457,7 +485,7 @@ void InitAudioDevice(void)
return;
}
- // Mixing happens on a seperate thread which means we need to synchronize. I'm using a mutex here to make things simple, but may
+ // Mixing happens on a separate thread which means we need to synchronize. I'm using a mutex here to make things simple, but may
// want to look at something a bit smarter later on to keep everything real-time, if that's necessary.
if (ma_mutex_init(&AUDIO.System.lock) != MA_SUCCESS)
{
@@ -467,13 +495,6 @@ void InitAudioDevice(void)
return;
}
- // Init dummy audio buffers pool for multichannel sound playing
- for (int i = 0; i < MAX_AUDIO_BUFFER_POOL_CHANNELS; i++)
- {
- // WARNING: An empty audio buffer is created (data = 0) and added to list, AudioBuffer data is filled on PlaySoundMulti()
- AUDIO.MultiChannel.pool[i] = LoadAudioBuffer(AUDIO_DEVICE_FORMAT, AUDIO_DEVICE_CHANNELS, AUDIO.System.device.sampleRate, 0, AUDIO_BUFFER_USAGE_STATIC);
- }
-
TRACELOG(LOG_INFO, "AUDIO: Device initialized successfully");
TRACELOG(LOG_INFO, " > Backend: miniaudio / %s", ma_get_backend_name(AUDIO.System.context.backend));
TRACELOG(LOG_INFO, " > Format: %s -> %s", ma_get_format_name(AUDIO.System.device.playback.format), ma_get_format_name(AUDIO.System.device.playback.internalFormat));
@@ -489,20 +510,6 @@ void CloseAudioDevice(void)
{
if (AUDIO.System.isReady)
{
- // Unload dummy audio buffers pool
- // WARNING: They can be pointing to already unloaded data
- for (int i = 0; i < MAX_AUDIO_BUFFER_POOL_CHANNELS; i++)
- {
- //UnloadAudioBuffer(AUDIO.MultiChannel.pool[i]);
- if (AUDIO.MultiChannel.pool[i] != NULL)
- {
- ma_data_converter_uninit(&AUDIO.MultiChannel.pool[i]->converter, NULL);
- UntrackAudioBuffer(AUDIO.MultiChannel.pool[i]);
- //RL_FREE(buffer->data); // Already unloaded by UnloadSound()
- RL_FREE(AUDIO.MultiChannel.pool[i]);
- }
- }
-
ma_mutex_uninit(&AUDIO.System.lock);
ma_device_uninit(&AUDIO.System.device);
ma_context_uninit(&AUDIO.System.context);
@@ -511,7 +518,7 @@ void CloseAudioDevice(void)
RL_FREE(AUDIO.System.pcmBuffer);
AUDIO.System.pcmBuffer = NULL;
AUDIO.System.pcmBufferSize = 0;
-
+
TRACELOG(LOG_INFO, "AUDIO: Device closed successfully");
}
else TRACELOG(LOG_WARNING, "AUDIO: Device could not be closed, not currently initialized");
@@ -744,7 +751,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
if (false) { }
#if defined(SUPPORT_FILEFORMAT_WAV)
- else if (strcmp(fileType, ".wav") == 0)
+ else if ((strcmp(fileType, ".wav") == 0) || (strcmp(fileType, ".WAV") == 0))
{
drwav wav = { 0 };
bool success = drwav_init_memory(&wav, fileData, dataSize, NULL);
@@ -766,7 +773,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
}
#endif
#if defined(SUPPORT_FILEFORMAT_OGG)
- else if (strcmp(fileType, ".ogg") == 0)
+ else if ((strcmp(fileType, ".ogg") == 0) || (strcmp(fileType, ".OGG") == 0))
{
stb_vorbis *oggData = stb_vorbis_open_memory((unsigned char *)fileData, dataSize, NULL, NULL);
@@ -787,21 +794,8 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
else TRACELOG(LOG_WARNING, "WAVE: Failed to load OGG data");
}
#endif
-#if defined(SUPPORT_FILEFORMAT_FLAC)
- else if (strcmp(fileType, ".flac") == 0)
- {
- unsigned long long int totalFrameCount = 0;
-
- // NOTE: We are forcing conversion to 16bit sample size on reading
- wave.data = drflac_open_memory_and_read_pcm_frames_s16(fileData, dataSize, &wave.channels, &wave.sampleRate, &totalFrameCount, NULL);
- wave.sampleSize = 16;
-
- if (wave.data != NULL) wave.frameCount = (unsigned int)totalFrameCount;
- else TRACELOG(LOG_WARNING, "WAVE: Failed to load FLAC data");
- }
-#endif
#if defined(SUPPORT_FILEFORMAT_MP3)
- else if (strcmp(fileType, ".mp3") == 0)
+ else if ((strcmp(fileType, ".mp3") == 0) || (strcmp(fileType, ".MP3") == 0))
{
drmp3_config config = { 0 };
unsigned long long int totalFrameCount = 0;
@@ -819,6 +813,38 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
else TRACELOG(LOG_WARNING, "WAVE: Failed to load MP3 data");
}
+#endif
+#if defined(SUPPORT_FILEFORMAT_QOA)
+ else if ((strcmp(fileType, ".qoa") == 0) || (strcmp(fileType, ".QOA") == 0))
+ {
+ qoa_desc qoa = { 0 };
+
+ // NOTE: Returned sample data is always 16 bit?
+ wave.data = qoa_decode(fileData, dataSize, &qoa);
+ wave.sampleSize = 16;
+
+ if (wave.data != NULL)
+ {
+ wave.channels = qoa.channels;
+ wave.sampleRate = qoa.samplerate;
+ wave.frameCount = qoa.samples;
+ }
+ else TRACELOG(LOG_WARNING, "WAVE: Failed to load QOA data");
+
+ }
+#endif
+#if defined(SUPPORT_FILEFORMAT_FLAC)
+ else if ((strcmp(fileType, ".flac") == 0) || (strcmp(fileType, ".FLAC") == 0))
+ {
+ unsigned long long int totalFrameCount = 0;
+
+ // NOTE: We are forcing conversion to 16bit sample size on reading
+ wave.data = drflac_open_memory_and_read_pcm_frames_s16(fileData, dataSize, &wave.channels, &wave.sampleRate, &totalFrameCount, NULL);
+ wave.sampleSize = 16;
+
+ if (wave.data != NULL) wave.frameCount = (unsigned int)totalFrameCount;
+ else TRACELOG(LOG_WARNING, "WAVE: Failed to load FLAC data");
+ }
#endif
else TRACELOG(LOG_WARNING, "WAVE: Data format not supported");
@@ -827,6 +853,16 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
return wave;
}
+// Checks if wave data is ready
+bool IsWaveReady(Wave wave)
+{
+ return ((wave.data != NULL) && // Validate wave data available
+ (wave.frameCount > 0) && // Validate frame count
+ (wave.sampleRate > 0) && // Validate sample rate is supported
+ (wave.sampleSize > 0) && // Validate sample size is supported
+ (wave.channels > 0)); // Validate number of channels supported
+}
+
// Load sound from file
// NOTE: The entire file is loaded to memory to be played (no-streaming)
Sound LoadSound(const char *fileName)
@@ -883,6 +919,42 @@ Sound LoadSoundFromWave(Wave wave)
return sound;
}
+// Clone sound from existing sound data, clone does not own wave data
+// Wave data must
+// NOTE: Wave data must be unallocated manually and will be shared across all clones
+Sound LoadSoundAlias(Sound source)
+{
+ Sound sound = { 0 };
+
+ if (source.stream.buffer->data != NULL)
+ {
+ AudioBuffer* audioBuffer = LoadAudioBuffer(AUDIO_DEVICE_FORMAT, AUDIO_DEVICE_CHANNELS, AUDIO.System.device.sampleRate, source.frameCount, AUDIO_BUFFER_USAGE_STATIC);
+ if (audioBuffer == NULL)
+ {
+ TRACELOG(LOG_WARNING, "SOUND: Failed to create buffer");
+ return sound; // early return to avoid dereferencing the audioBuffer null pointer
+ }
+ audioBuffer->data = source.stream.buffer->data;
+ sound.frameCount = source.frameCount;
+ sound.stream.sampleRate = AUDIO.System.device.sampleRate;
+ sound.stream.sampleSize = 32;
+ sound.stream.channels = AUDIO_DEVICE_CHANNELS;
+ sound.stream.buffer = audioBuffer;
+ }
+
+ return sound;
+}
+
+// Checks if a sound is ready
+bool IsSoundReady(Sound sound)
+{
+ return ((sound.frameCount > 0) && // Validate frame count
+ (sound.stream.buffer != NULL) && // Validate stream buffer
+ (sound.stream.sampleRate > 0) && // Validate sample rate is supported
+ (sound.stream.sampleSize > 0) && // Validate sample size is supported
+ (sound.stream.channels > 0)); // Validate number of channels supported
+}
+
// Unload wave data
void UnloadWave(Wave wave)
{
@@ -897,6 +969,17 @@ void UnloadSound(Sound sound)
//TRACELOG(LOG_INFO, "SOUND: Unloaded sound data from RAM");
}
+void UnloadSoundAlias(Sound alias)
+{
+ // untrack and unload just the sound buffer, not the sample data, it is shared with the source for the alias
+ if (alias.stream.buffer != NULL)
+ {
+ ma_data_converter_uninit(&alias.stream.buffer->converter, NULL);
+ UntrackAudioBuffer(alias.stream.buffer);
+ RL_FREE(alias.stream.buffer);
+ }
+}
+
// Update sound buffer with new data
void UpdateSound(Sound sound, const void *data, int sampleCount)
{
@@ -937,6 +1020,22 @@ bool ExportWave(Wave wave, const char *fileName)
drwav_free(fileData, NULL);
}
+#endif
+#if defined(SUPPORT_FILEFORMAT_QOA)
+ else if (IsFileExtension(fileName, ".qoa"))
+ {
+ if (wave.sampleSize == 16)
+ {
+ qoa_desc qoa = { 0 };
+ qoa.channels = wave.channels;
+ qoa.samplerate = wave.sampleRate;
+ qoa.samples = wave.frameCount;
+
+ int bytesWritten = qoa_write(fileName, wave.data, &qoa);
+ if (bytesWritten > 0) success = true;
+ }
+ else TRACELOG(LOG_WARNING, "AUDIO: Wave data must be 16 bit per sample for QOA format export");
+ }
#endif
else if (IsFileExtension(fileName, ".raw"))
{
@@ -974,33 +1073,34 @@ bool ExportWaveAsCode(Wave wave, const char *fileName)
byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n");
byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n");
byteCount += sprintf(txtData + byteCount, "// //\n");
- byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2022 Ramon Santamaria (@raysan5) //\n");
+ byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2023 Ramon Santamaria (@raysan5) //\n");
byteCount += sprintf(txtData + byteCount, "// //\n");
byteCount += sprintf(txtData + byteCount, "//////////////////////////////////////////////////////////////////////////////////\n\n");
- char fileNameLower[256] = { 0 };
- char fileNameUpper[256] = { 0 };
- for (int i = 0; fileName[i] != '.'; i++) { fileNameLower[i] = fileName[i]; } // Get filename without extension
- for (int i = 0; fileNameLower[i] != '\0'; i++) if (fileNameLower[i] >= 'a' && fileNameLower[i] <= 'z') { fileNameUpper[i] = fileNameLower[i] - 32; }
+ // Get file name from path and convert variable name to uppercase
+ char varFileName[256] = { 0 };
+ strcpy(varFileName, GetFileNameWithoutExt(fileName));
+ for (int i = 0; varFileName[i] != '\0'; i++) if (varFileName[i] >= 'a' && varFileName[i] <= 'z') { varFileName[i] = varFileName[i] - 32; }
+ //Add wave information
byteCount += sprintf(txtData + byteCount, "// Wave data information\n");
- byteCount += sprintf(txtData + byteCount, "#define %s_FRAME_COUNT %u\n", fileNameUpper, wave.frameCount);
- byteCount += sprintf(txtData + byteCount, "#define %s_SAMPLE_RATE %u\n", fileNameUpper, wave.sampleRate);
- byteCount += sprintf(txtData + byteCount, "#define %s_SAMPLE_SIZE %u\n", fileNameUpper, wave.sampleSize);
- byteCount += sprintf(txtData + byteCount, "#define %s_CHANNELS %u\n\n", fileNameUpper, wave.channels);
+ byteCount += sprintf(txtData + byteCount, "#define %s_FRAME_COUNT %u\n", varFileName, wave.frameCount);
+ byteCount += sprintf(txtData + byteCount, "#define %s_SAMPLE_RATE %u\n", varFileName, wave.sampleRate);
+ byteCount += sprintf(txtData + byteCount, "#define %s_SAMPLE_SIZE %u\n", varFileName, wave.sampleSize);
+ byteCount += sprintf(txtData + byteCount, "#define %s_CHANNELS %u\n\n", varFileName, wave.channels);
// Write wave data as an array of values
// Wave data is exported as byte array for 8/16bit and float array for 32bit float data
// NOTE: Frame data exported is channel-interlaced: frame01[sampleChannel1, sampleChannel2, ...], frame02[], frame03[]
if (wave.sampleSize == 32)
{
- byteCount += sprintf(txtData + byteCount, "static float %sData[%i] = {\n", fileNameLower, waveDataSize/4);
+ byteCount += sprintf(txtData + byteCount, "static float %s_DATA[%i] = {\n", varFileName, waveDataSize/4);
for (int i = 1; i < waveDataSize/4; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "%.4ff,\n " : "%.4ff, "), ((float *)wave.data)[i - 1]);
byteCount += sprintf(txtData + byteCount, "%.4ff };\n", ((float *)wave.data)[waveDataSize/4 - 1]);
}
else
{
- byteCount += sprintf(txtData + byteCount, "static unsigned char %sData[%i] = { ", fileNameLower, waveDataSize);
+ byteCount += sprintf(txtData + byteCount, "static unsigned char %s_DATA[%i] = { ", varFileName, waveDataSize);
for (int i = 1; i < waveDataSize; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%x,\n " : "0x%x, "), ((unsigned char *)wave.data)[i - 1]);
byteCount += sprintf(txtData + byteCount, "0x%x };\n", ((unsigned char *)wave.data)[waveDataSize - 1]);
}
@@ -1022,88 +1122,6 @@ void PlaySound(Sound sound)
PlayAudioBuffer(sound.stream.buffer);
}
-// Play a sound in the multichannel buffer pool
-void PlaySoundMulti(Sound sound)
-{
- int index = -1;
- unsigned int oldAge = 0;
- int oldIndex = -1;
-
- // find the first non playing pool entry
- for (int i = 0; i < MAX_AUDIO_BUFFER_POOL_CHANNELS; i++)
- {
- if (AUDIO.MultiChannel.channels[i] > oldAge)
- {
- oldAge = AUDIO.MultiChannel.channels[i];
- oldIndex = i;
- }
-
- if (!IsAudioBufferPlaying(AUDIO.MultiChannel.pool[i]))
- {
- index = i;
- break;
- }
- }
-
- // If no none playing pool members can be index choose the oldest
- if (index == -1)
- {
- TRACELOG(LOG_WARNING, "SOUND: Buffer pool is already full, count: %i", AUDIO.MultiChannel.poolCounter);
-
- if (oldIndex == -1)
- {
- // Shouldn't be able to get here... but just in case something odd happens!
- TRACELOG(LOG_WARNING, "SOUND: Buffer pool could not determine oldest buffer not playing sound");
- return;
- }
-
- index = oldIndex;
-
- // Just in case...
- StopAudioBuffer(AUDIO.MultiChannel.pool[index]);
- }
-
- // Experimentally mutex lock doesn't seem to be needed this makes sense
- // as pool[index] isn't playing and the only stuff we're copying
- // shouldn't be changing...
-
- AUDIO.MultiChannel.channels[index] = AUDIO.MultiChannel.poolCounter;
- AUDIO.MultiChannel.poolCounter++;
-
- SetAudioBufferVolume(AUDIO.MultiChannel.pool[index], sound.stream.buffer->volume);
- SetAudioBufferPitch(AUDIO.MultiChannel.pool[index], sound.stream.buffer->pitch);
- SetAudioBufferPan(AUDIO.MultiChannel.pool[index], sound.stream.buffer->pan);
-
- AUDIO.MultiChannel.pool[index]->looping = sound.stream.buffer->looping;
- AUDIO.MultiChannel.pool[index]->usage = sound.stream.buffer->usage;
- AUDIO.MultiChannel.pool[index]->isSubBufferProcessed[0] = false;
- AUDIO.MultiChannel.pool[index]->isSubBufferProcessed[1] = false;
- AUDIO.MultiChannel.pool[index]->sizeInFrames = sound.stream.buffer->sizeInFrames;
-
- AUDIO.MultiChannel.pool[index]->data = sound.stream.buffer->data; // Fill dummy track with data for playing
-
- PlayAudioBuffer(AUDIO.MultiChannel.pool[index]);
-}
-
-// Stop any sound played with PlaySoundMulti()
-void StopSoundMulti(void)
-{
- for (int i = 0; i < MAX_AUDIO_BUFFER_POOL_CHANNELS; i++) StopAudioBuffer(AUDIO.MultiChannel.pool[i]);
-}
-
-// Get number of sounds playing in the multichannel buffer pool
-int GetSoundsPlaying(void)
-{
- int counter = 0;
-
- for (int i = 0; i < MAX_AUDIO_BUFFER_POOL_CHANNELS; i++)
- {
- if (IsAudioBufferPlaying(AUDIO.MultiChannel.pool[i])) counter++;
- }
-
- return counter;
-}
-
// Pause a sound
void PauseSound(Sound sound)
{
@@ -1244,7 +1262,7 @@ void UnloadWaveSamples(float *samples)
}
//----------------------------------------------------------------------------------
-// Module Functions Definition - Music loading and stream playing (.OGG)
+// Module Functions Definition - Music loading and stream playing
//----------------------------------------------------------------------------------
// Load music stream from file
@@ -1296,23 +1314,6 @@ Music LoadMusicStream(const char *fileName)
}
}
#endif
-#if defined(SUPPORT_FILEFORMAT_FLAC)
- else if (IsFileExtension(fileName, ".flac"))
- {
- music.ctxType = MUSIC_AUDIO_FLAC;
- music.ctxData = drflac_open_file(fileName, NULL);
-
- if (music.ctxData != NULL)
- {
- drflac *ctxFlac = (drflac *)music.ctxData;
-
- music.stream = LoadAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels);
- music.frameCount = (unsigned int)ctxFlac->totalPCMFrameCount;
- music.looping = true; // Looping enabled by default
- musicLoaded = true;
- }
- }
-#endif
#if defined(SUPPORT_FILEFORMAT_MP3)
else if (IsFileExtension(fileName, ".mp3"))
{
@@ -1331,6 +1332,41 @@ Music LoadMusicStream(const char *fileName)
}
}
#endif
+#if defined(SUPPORT_FILEFORMAT_QOA)
+ else if (IsFileExtension(fileName, ".qoa"))
+ {
+ qoaplay_desc *ctxQoa = qoaplay_open(fileName);
+ music.ctxType = MUSIC_AUDIO_QOA;
+ music.ctxData = ctxQoa;
+
+ if (ctxQoa->file != NULL)
+ {
+ // NOTE: We are loading samples are 32bit float normalized data, so,
+ // we configure the output audio stream to also use float 32bit
+ music.stream = LoadAudioStream(ctxQoa->info.samplerate, 32, ctxQoa->info.channels);
+ music.frameCount = ctxQoa->info.samples;
+ music.looping = true; // Looping enabled by default
+ musicLoaded = true;
+ }
+ }
+#endif
+#if defined(SUPPORT_FILEFORMAT_FLAC)
+ else if (IsFileExtension(fileName, ".flac"))
+ {
+ music.ctxType = MUSIC_AUDIO_FLAC;
+ music.ctxData = drflac_open_file(fileName, NULL);
+
+ if (music.ctxData != NULL)
+ {
+ drflac *ctxFlac = (drflac *)music.ctxData;
+
+ music.stream = LoadAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels);
+ music.frameCount = (unsigned int)ctxFlac->totalPCMFrameCount;
+ music.looping = true; // Looping enabled by default
+ musicLoaded = true;
+ }
+ }
+#endif
#if defined(SUPPORT_FILEFORMAT_XM)
else if (IsFileExtension(fileName, ".xm"))
{
@@ -1388,12 +1424,15 @@ Music LoadMusicStream(const char *fileName)
#if defined(SUPPORT_FILEFORMAT_OGG)
else if (music.ctxType == MUSIC_AUDIO_OGG) stb_vorbis_close((stb_vorbis *)music.ctxData);
#endif
- #if defined(SUPPORT_FILEFORMAT_FLAC)
- else if (music.ctxType == MUSIC_AUDIO_FLAC) drflac_free((drflac *)music.ctxData, NULL);
- #endif
#if defined(SUPPORT_FILEFORMAT_MP3)
else if (music.ctxType == MUSIC_AUDIO_MP3) { drmp3_uninit((drmp3 *)music.ctxData); RL_FREE(music.ctxData); }
#endif
+ #if defined(SUPPORT_FILEFORMAT_QOA)
+ else if (music.ctxType == MUSIC_AUDIO_QOA) qoaplay_close((qoaplay_desc *)music.ctxData);
+ #endif
+ #if defined(SUPPORT_FILEFORMAT_FLAC)
+ else if (music.ctxType == MUSIC_AUDIO_FLAC) drflac_free((drflac *)music.ctxData, NULL);
+ #endif
#if defined(SUPPORT_FILEFORMAT_XM)
else if (music.ctxType == MUSIC_MODULE_XM) jar_xm_free_context((jar_xm_context_t *)music.ctxData);
#endif
@@ -1426,7 +1465,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
if (false) { }
#if defined(SUPPORT_FILEFORMAT_WAV)
- else if (strcmp(fileType, ".wav") == 0)
+ else if ((strcmp(fileType, ".wav") == 0) || (strcmp(fileType, ".WAV") == 0))
{
drwav *ctxWav = RL_CALLOC(1, sizeof(drwav));
@@ -1447,43 +1486,8 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
}
}
#endif
-#if defined(SUPPORT_FILEFORMAT_FLAC)
- else if (strcmp(fileType, ".flac") == 0)
- {
- music.ctxType = MUSIC_AUDIO_FLAC;
- music.ctxData = drflac_open_memory((const void*)data, dataSize, NULL);
-
- if (music.ctxData != NULL)
- {
- drflac *ctxFlac = (drflac *)music.ctxData;
-
- music.stream = LoadAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels);
- music.frameCount = (unsigned int)ctxFlac->totalPCMFrameCount;
- music.looping = true; // Looping enabled by default
- musicLoaded = true;
- }
- }
-#endif
-#if defined(SUPPORT_FILEFORMAT_MP3)
- else if (strcmp(fileType, ".mp3") == 0)
- {
- drmp3 *ctxMp3 = RL_CALLOC(1, sizeof(drmp3));
- int success = drmp3_init_memory(ctxMp3, (const void*)data, dataSize, NULL);
-
- music.ctxType = MUSIC_AUDIO_MP3;
- music.ctxData = ctxMp3;
-
- if (success)
- {
- music.stream = LoadAudioStream(ctxMp3->sampleRate, 32, ctxMp3->channels);
- music.frameCount = (unsigned int)drmp3_get_pcm_frame_count(ctxMp3);
- music.looping = true; // Looping enabled by default
- musicLoaded = true;
- }
- }
-#endif
#if defined(SUPPORT_FILEFORMAT_OGG)
- else if (strcmp(fileType, ".ogg") == 0)
+ else if ((strcmp(fileType, ".ogg") == 0) || (strcmp(fileType, ".OGG") == 0))
{
// Open ogg audio stream
music.ctxType = MUSIC_AUDIO_OGG;
@@ -1504,8 +1508,61 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
}
}
#endif
+#if defined(SUPPORT_FILEFORMAT_MP3)
+ else if ((strcmp(fileType, ".mp3") == 0) || (strcmp(fileType, ".MP3") == 0))
+ {
+ drmp3 *ctxMp3 = RL_CALLOC(1, sizeof(drmp3));
+ int success = drmp3_init_memory(ctxMp3, (const void*)data, dataSize, NULL);
+
+ music.ctxType = MUSIC_AUDIO_MP3;
+ music.ctxData = ctxMp3;
+
+ if (success)
+ {
+ music.stream = LoadAudioStream(ctxMp3->sampleRate, 32, ctxMp3->channels);
+ music.frameCount = (unsigned int)drmp3_get_pcm_frame_count(ctxMp3);
+ music.looping = true; // Looping enabled by default
+ musicLoaded = true;
+ }
+ }
+#endif
+#if defined(SUPPORT_FILEFORMAT_QOA)
+ else if ((strcmp(fileType, ".qoa") == 0) || (strcmp(fileType, ".QOA") == 0))
+ {
+ qoaplay_desc *ctxQoa = qoaplay_open_memory(data, dataSize);
+ music.ctxType = MUSIC_AUDIO_QOA;
+ music.ctxData = ctxQoa;
+
+ if ((ctxQoa->file_data != NULL) && (ctxQoa->file_data_size != 0))
+ {
+ // NOTE: We are loading samples are 32bit float normalized data, so,
+ // we configure the output audio stream to also use float 32bit
+ music.stream = LoadAudioStream(ctxQoa->info.samplerate, 32, ctxQoa->info.channels);
+ music.frameCount = ctxQoa->info.samples;
+ music.looping = true; // Looping enabled by default
+ musicLoaded = true;
+ }
+ }
+#endif
+#if defined(SUPPORT_FILEFORMAT_FLAC)
+ else if ((strcmp(fileType, ".flac") == 0) || (strcmp(fileType, ".FLAC") == 0))
+ {
+ music.ctxType = MUSIC_AUDIO_FLAC;
+ music.ctxData = drflac_open_memory((const void*)data, dataSize, NULL);
+
+ if (music.ctxData != NULL)
+ {
+ drflac *ctxFlac = (drflac *)music.ctxData;
+
+ music.stream = LoadAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels);
+ music.frameCount = (unsigned int)ctxFlac->totalPCMFrameCount;
+ music.looping = true; // Looping enabled by default
+ musicLoaded = true;
+ }
+ }
+#endif
#if defined(SUPPORT_FILEFORMAT_XM)
- else if (strcmp(fileType, ".xm") == 0)
+ else if ((strcmp(fileType, ".xm") == 0) || (strcmp(fileType, ".XM") == 0))
{
jar_xm_context_t *ctxXm = NULL;
int result = jar_xm_create_context_safe(&ctxXm, (const char *)data, dataSize, AUDIO.System.device.sampleRate);
@@ -1530,7 +1587,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
}
#endif
#if defined(SUPPORT_FILEFORMAT_MOD)
- else if (strcmp(fileType, ".mod") == 0)
+ else if ((strcmp(fileType, ".mod") == 0) || (strcmp(fileType, ".MOD") == 0))
{
jar_mod_context_t *ctxMod = (jar_mod_context_t *)RL_MALLOC(sizeof(jar_mod_context_t));
int result = 0;
@@ -1570,24 +1627,27 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
if (!musicLoaded)
{
if (false) { }
- #if defined(SUPPORT_FILEFORMAT_WAV)
+#if defined(SUPPORT_FILEFORMAT_WAV)
else if (music.ctxType == MUSIC_AUDIO_WAV) drwav_uninit((drwav *)music.ctxData);
- #endif
- #if defined(SUPPORT_FILEFORMAT_FLAC)
- else if (music.ctxType == MUSIC_AUDIO_FLAC) drflac_free((drflac *)music.ctxData, NULL);
- #endif
- #if defined(SUPPORT_FILEFORMAT_MP3)
- else if (music.ctxType == MUSIC_AUDIO_MP3) { drmp3_uninit((drmp3 *)music.ctxData); RL_FREE(music.ctxData); }
- #endif
- #if defined(SUPPORT_FILEFORMAT_OGG)
+#endif
+#if defined(SUPPORT_FILEFORMAT_OGG)
else if (music.ctxType == MUSIC_AUDIO_OGG) stb_vorbis_close((stb_vorbis *)music.ctxData);
- #endif
- #if defined(SUPPORT_FILEFORMAT_XM)
+#endif
+#if defined(SUPPORT_FILEFORMAT_MP3)
+ else if (music.ctxType == MUSIC_AUDIO_MP3) { drmp3_uninit((drmp3 *)music.ctxData); RL_FREE(music.ctxData); }
+#endif
+#if defined(SUPPORT_FILEFORMAT_QOA)
+ else if (music.ctxType == MUSIC_AUDIO_QOA) qoaplay_close((qoaplay_desc *)music.ctxData);
+#endif
+#if defined(SUPPORT_FILEFORMAT_FLAC)
+ else if (music.ctxType == MUSIC_AUDIO_FLAC) drflac_free((drflac *)music.ctxData, NULL);
+#endif
+#if defined(SUPPORT_FILEFORMAT_XM)
else if (music.ctxType == MUSIC_MODULE_XM) jar_xm_free_context((jar_xm_context_t *)music.ctxData);
- #endif
- #if defined(SUPPORT_FILEFORMAT_MOD)
+#endif
+#if defined(SUPPORT_FILEFORMAT_MOD)
else if (music.ctxType == MUSIC_MODULE_MOD) { jar_mod_unload((jar_mod_context_t *)music.ctxData); RL_FREE(music.ctxData); }
- #endif
+#endif
music.ctxData = NULL;
TRACELOG(LOG_WARNING, "FILEIO: Music data could not be loaded");
@@ -1605,6 +1665,16 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
return music;
}
+// Checks if a music stream is ready
+bool IsMusicReady(Music music)
+{
+ return ((music.ctxData != NULL) && // Validate context loaded
+ (music.frameCount > 0) && // Validate audio frame count
+ (music.stream.sampleRate > 0) && // Validate sample rate is supported
+ (music.stream.sampleSize > 0) && // Validate sample size is supported
+ (music.stream.channels > 0)); // Validate number of channels supported
+}
+
// Unload music stream
void UnloadMusicStream(Music music)
{
@@ -1619,12 +1689,15 @@ void UnloadMusicStream(Music music)
#if defined(SUPPORT_FILEFORMAT_OGG)
else if (music.ctxType == MUSIC_AUDIO_OGG) stb_vorbis_close((stb_vorbis *)music.ctxData);
#endif
-#if defined(SUPPORT_FILEFORMAT_FLAC)
- else if (music.ctxType == MUSIC_AUDIO_FLAC) drflac_free((drflac *)music.ctxData, NULL);
-#endif
#if defined(SUPPORT_FILEFORMAT_MP3)
else if (music.ctxType == MUSIC_AUDIO_MP3) { drmp3_uninit((drmp3 *)music.ctxData); RL_FREE(music.ctxData); }
#endif
+#if defined(SUPPORT_FILEFORMAT_QOA)
+ else if (music.ctxType == MUSIC_AUDIO_QOA) qoaplay_close((qoaplay_desc *)music.ctxData);
+#endif
+#if defined(SUPPORT_FILEFORMAT_FLAC)
+ else if (music.ctxType == MUSIC_AUDIO_FLAC) drflac_free((drflac *)music.ctxData, NULL);
+#endif
#if defined(SUPPORT_FILEFORMAT_XM)
else if (music.ctxType == MUSIC_MODULE_XM) jar_xm_free_context((jar_xm_context_t *)music.ctxData);
#endif
@@ -1674,12 +1747,15 @@ void StopMusicStream(Music music)
#if defined(SUPPORT_FILEFORMAT_OGG)
case MUSIC_AUDIO_OGG: stb_vorbis_seek_start((stb_vorbis *)music.ctxData); break;
#endif
-#if defined(SUPPORT_FILEFORMAT_FLAC)
- case MUSIC_AUDIO_FLAC: drflac__seek_to_first_frame((drflac *)music.ctxData); break;
-#endif
#if defined(SUPPORT_FILEFORMAT_MP3)
case MUSIC_AUDIO_MP3: drmp3_seek_to_start_of_stream((drmp3 *)music.ctxData); break;
#endif
+#if defined(SUPPORT_FILEFORMAT_QOA)
+ case MUSIC_AUDIO_QOA: qoaplay_rewind((qoaplay_desc *)music.ctxData); break;
+#endif
+#if defined(SUPPORT_FILEFORMAT_FLAC)
+ case MUSIC_AUDIO_FLAC: drflac__seek_to_first_frame((drflac *)music.ctxData); break;
+#endif
#if defined(SUPPORT_FILEFORMAT_XM)
case MUSIC_MODULE_XM: jar_xm_reset((jar_xm_context_t *)music.ctxData); break;
#endif
@@ -1706,11 +1782,14 @@ void SeekMusicStream(Music music, float position)
#if defined(SUPPORT_FILEFORMAT_OGG)
case MUSIC_AUDIO_OGG: stb_vorbis_seek_frame((stb_vorbis *)music.ctxData, positionInFrames); break;
#endif
-#if defined(SUPPORT_FILEFORMAT_FLAC)
- case MUSIC_AUDIO_FLAC: drflac_seek_to_pcm_frame((drflac *)music.ctxData, positionInFrames); break;
-#endif
#if defined(SUPPORT_FILEFORMAT_MP3)
case MUSIC_AUDIO_MP3: drmp3_seek_to_pcm_frame((drmp3 *)music.ctxData, positionInFrames); break;
+#endif
+#if defined(SUPPORT_FILEFORMAT_QOA)
+ case MUSIC_AUDIO_QOA: qoaplay_seek_frame((qoaplay_desc *)music.ctxData, positionInFrames); break;
+#endif
+#if defined(SUPPORT_FILEFORMAT_FLAC)
+ case MUSIC_AUDIO_FLAC: drflac_seek_to_pcm_frame((drflac *)music.ctxData, positionInFrames); break;
#endif
default: break;
}
@@ -1728,6 +1807,7 @@ void UpdateMusicStream(Music music)
// On first call of this function we lazily pre-allocated a temp buffer to read audio files/memory data in
int frameSize = music.stream.channels*music.stream.sampleSize/8;
unsigned int pcmSize = subBufferSizeInFrames*frameSize;
+
if (AUDIO.System.pcmBufferSize < pcmSize)
{
RL_FREE(AUDIO.System.pcmBuffer);
@@ -1742,11 +1822,13 @@ void UpdateMusicStream(Music music)
unsigned int framesLeft = music.frameCount - music.stream.buffer->framesProcessed; // Frames left to be processed
unsigned int framesToStream = 0; // Total frames to be streamed
+
if ((framesLeft >= subBufferSizeInFrames) || music.looping) framesToStream = subBufferSizeInFrames;
else framesToStream = framesLeft;
int frameCountStillNeeded = framesToStream;
- int frameCountRedTotal = 0;
+ int frameCountReadTotal = 0;
+
switch (music.ctxType)
{
#if defined(SUPPORT_FILEFORMAT_WAV)
@@ -1756,9 +1838,9 @@ void UpdateMusicStream(Music music)
{
while (true)
{
- int frameCountRed = drwav_read_pcm_frames_s16((drwav *)music.ctxData, frameCountStillNeeded, (short *)((char *)AUDIO.System.pcmBuffer + frameCountRedTotal*frameSize));
- frameCountRedTotal += frameCountRed;
- frameCountStillNeeded -= frameCountRed;
+ int frameCountRead = (int)drwav_read_pcm_frames_s16((drwav *)music.ctxData, frameCountStillNeeded, (short *)((char *)AUDIO.System.pcmBuffer + frameCountReadTotal*frameSize));
+ frameCountReadTotal += frameCountRead;
+ frameCountStillNeeded -= frameCountRead;
if (frameCountStillNeeded == 0) break;
else drwav_seek_to_first_pcm_frame((drwav *)music.ctxData);
}
@@ -1767,9 +1849,9 @@ void UpdateMusicStream(Music music)
{
while (true)
{
- int frameCountRed = drwav_read_pcm_frames_f32((drwav *)music.ctxData, frameCountStillNeeded, (float *)((char *)AUDIO.System.pcmBuffer + frameCountRedTotal*frameSize));
- frameCountRedTotal += frameCountRed;
- frameCountStillNeeded -= frameCountRed;
+ int frameCountRead = (int)drwav_read_pcm_frames_f32((drwav *)music.ctxData, frameCountStillNeeded, (float *)((char *)AUDIO.System.pcmBuffer + frameCountReadTotal*frameSize));
+ frameCountReadTotal += frameCountRead;
+ frameCountStillNeeded -= frameCountRead;
if (frameCountStillNeeded == 0) break;
else drwav_seek_to_first_pcm_frame((drwav *)music.ctxData);
}
@@ -1781,40 +1863,57 @@ void UpdateMusicStream(Music music)
{
while (true)
{
- int frameCountRed = stb_vorbis_get_samples_short_interleaved((stb_vorbis *)music.ctxData, music.stream.channels, (short *)((char *)AUDIO.System.pcmBuffer + frameCountRedTotal*frameSize), frameCountStillNeeded*music.stream.channels);
- frameCountRedTotal += frameCountRed;
- frameCountStillNeeded -= frameCountRed;
+ int frameCountRead = stb_vorbis_get_samples_short_interleaved((stb_vorbis *)music.ctxData, music.stream.channels, (short *)((char *)AUDIO.System.pcmBuffer + frameCountReadTotal*frameSize), frameCountStillNeeded*music.stream.channels);
+ frameCountReadTotal += frameCountRead;
+ frameCountStillNeeded -= frameCountRead;
if (frameCountStillNeeded == 0) break;
else stb_vorbis_seek_start((stb_vorbis *)music.ctxData);
}
} break;
#endif
- #if defined(SUPPORT_FILEFORMAT_FLAC)
- case MUSIC_AUDIO_FLAC:
- {
- while (true)
- {
- int frameCountRed = drflac_read_pcm_frames_s16((drflac *)music.ctxData, frameCountStillNeeded, (short *)((char *)AUDIO.System.pcmBuffer + frameCountRedTotal*frameSize));
- frameCountRedTotal += frameCountRed;
- frameCountStillNeeded -= frameCountRed;
- if (frameCountStillNeeded == 0) break;
- else drflac__seek_to_first_frame((drflac *)music.ctxData);
- }
- } break;
- #endif
#if defined(SUPPORT_FILEFORMAT_MP3)
case MUSIC_AUDIO_MP3:
{
while (true)
{
- int frameCountRed = drmp3_read_pcm_frames_f32((drmp3 *)music.ctxData, frameCountStillNeeded, (float *)((char *)AUDIO.System.pcmBuffer + frameCountRedTotal*frameSize));
- frameCountRedTotal += frameCountRed;
- frameCountStillNeeded -= frameCountRed;
+ int frameCountRead = (int)drmp3_read_pcm_frames_f32((drmp3 *)music.ctxData, frameCountStillNeeded, (float *)((char *)AUDIO.System.pcmBuffer + frameCountReadTotal*frameSize));
+ frameCountReadTotal += frameCountRead;
+ frameCountStillNeeded -= frameCountRead;
if (frameCountStillNeeded == 0) break;
else drmp3_seek_to_start_of_stream((drmp3 *)music.ctxData);
}
} break;
#endif
+ #if defined(SUPPORT_FILEFORMAT_QOA)
+ case MUSIC_AUDIO_QOA:
+ {
+ unsigned int frameCountRead = qoaplay_decode((qoaplay_desc *)music.ctxData, (float *)AUDIO.System.pcmBuffer, framesToStream);
+ frameCountReadTotal += frameCountRead;
+ /*
+ while (true)
+ {
+ int frameCountRead = (int)qoaplay_decode((qoaplay_desc *)music.ctxData, (float *)((char *)AUDIO.System.pcmBuffer + frameCountReadTotal*frameSize), frameCountStillNeeded);
+ frameCountReadTotal += frameCountRead;
+ frameCountStillNeeded -= frameCountRead;
+ if (frameCountStillNeeded == 0) break;
+ else qoaplay_rewind((qoaplay_desc *)music.ctxData);
+ }
+ */
+ } break;
+ #endif
+ #if defined(SUPPORT_FILEFORMAT_FLAC)
+ case MUSIC_AUDIO_FLAC:
+ {
+ while (true)
+ {
+ int frameCountRead = drflac_read_pcm_frames_s16((drflac *)music.ctxData, frameCountStillNeeded, (short *)((char *)AUDIO.System.pcmBuffer + frameCountReadTotal*frameSize));
+ frameCountReadTotal += frameCountRead;
+ frameCountStillNeeded -= frameCountRead;
+ if (frameCountStillNeeded == 0) break;
+ else drflac__seek_to_first_frame((drflac *)music.ctxData);
+ }
+ } break;
+ #endif
#if defined(SUPPORT_FILEFORMAT_XM)
case MUSIC_MODULE_XM:
{
@@ -1822,7 +1921,6 @@ void UpdateMusicStream(Music music)
if (AUDIO_DEVICE_FORMAT == ma_format_f32) jar_xm_generate_samples((jar_xm_context_t *)music.ctxData, (float *)AUDIO.System.pcmBuffer, framesToStream);
else if (AUDIO_DEVICE_FORMAT == ma_format_s16) jar_xm_generate_samples_16bit((jar_xm_context_t *)music.ctxData, (short *)AUDIO.System.pcmBuffer, framesToStream);
else if (AUDIO_DEVICE_FORMAT == ma_format_u8) jar_xm_generate_samples_8bit((jar_xm_context_t *)music.ctxData, (char *)AUDIO.System.pcmBuffer, framesToStream);
-
//jar_xm_reset((jar_xm_context_t *)music.ctxData);
} break;
@@ -1832,7 +1930,6 @@ void UpdateMusicStream(Music music)
{
// NOTE: 3rd parameter (nbsample) specify the number of stereo 16bits samples you want, so sampleCount/2
jar_mod_fillbuffer((jar_mod_context_t *)music.ctxData, (short *)AUDIO.System.pcmBuffer, framesToStream, 0);
-
//jar_mod_seek_start((jar_mod_context_t *)music.ctxData);
} break;
@@ -1900,7 +1997,7 @@ float GetMusicTimePlayed(Music music)
float secondsPlayed = 0.0f;
if (music.stream.buffer != NULL)
{
- #if defined(SUPPORT_FILEFORMAT_XM)
+#if defined(SUPPORT_FILEFORMAT_XM)
if (music.ctxType == MUSIC_MODULE_XM)
{
uint64_t framesPlayed = 0;
@@ -1909,7 +2006,7 @@ float GetMusicTimePlayed(Music music)
secondsPlayed = (float)framesPlayed/music.stream.sampleRate;
}
else
- #endif
+#endif
{
//ma_uint32 frameSizeInBytes = ma_get_bytes_per_sample(music.stream.buffer->dsp.formatConverterIn.config.formatIn)*music.stream.buffer->dsp.formatConverterIn.config.channels;
int framesProcessed = (int)music.stream.buffer->framesProcessed;
@@ -1958,6 +2055,15 @@ AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
return stream;
}
+// Checks if an audio stream is ready
+bool IsAudioStreamReady(AudioStream stream)
+{
+ return ((stream.buffer != NULL) && // Validate stream buffer
+ (stream.sampleRate > 0) && // Validate sample rate is supported
+ (stream.sampleSize > 0) && // Validate sample size is supported
+ (stream.channels > 0)); // Validate number of channels supported
+}
+
// Unload audio stream and free memory
void UnloadAudioStream(AudioStream stream)
{
@@ -1967,8 +2073,8 @@ void UnloadAudioStream(AudioStream stream)
}
// Update audio stream buffers with data
-// NOTE 1: Only updates one buffer of the stream source: unqueue -> update -> queue
-// NOTE 2: To unqueue a buffer it needs to be processed: IsAudioStreamProcessed()
+// NOTE 1: Only updates one buffer of the stream source: dequeue -> update -> queue
+// NOTE 2: To dequeue a buffer it needs to be processed: IsAudioStreamProcessed()
void UpdateAudioStream(AudioStream stream, const void *data, int frameCount)
{
if (stream.buffer != NULL)
@@ -2112,6 +2218,7 @@ void AttachAudioStreamProcessor(AudioStream stream, AudioCallback process)
ma_mutex_unlock(&AUDIO.System.lock);
}
+// Remove processor from audio stream
void DetachAudioStreamProcessor(AudioStream stream, AudioCallback process)
{
ma_mutex_lock(&AUDIO.System.lock);
@@ -2138,6 +2245,60 @@ void DetachAudioStreamProcessor(AudioStream stream, AudioCallback process)
ma_mutex_unlock(&AUDIO.System.lock);
}
+// Add processor to audio pipeline. Order of processors is important
+// Works the same way as {Attach,Detach}AudioStreamProcessor() functions, except
+// these two work on the already mixed output just before sending it to the sound hardware
+void AttachAudioMixedProcessor(AudioCallback process)
+{
+ ma_mutex_lock(&AUDIO.System.lock);
+
+ rAudioProcessor *processor = (rAudioProcessor *)RL_CALLOC(1, sizeof(rAudioProcessor));
+ processor->process = process;
+
+ rAudioProcessor *last = AUDIO.mixedProcessor;
+
+ while (last && last->next)
+ {
+ last = last->next;
+ }
+ if (last)
+ {
+ processor->prev = last;
+ last->next = processor;
+ }
+ else AUDIO.mixedProcessor = processor;
+
+ ma_mutex_unlock(&AUDIO.System.lock);
+}
+
+// Remove processor from audio pipeline
+void DetachAudioMixedProcessor(AudioCallback process)
+{
+ ma_mutex_lock(&AUDIO.System.lock);
+
+ rAudioProcessor *processor = AUDIO.mixedProcessor;
+
+ while (processor)
+ {
+ rAudioProcessor *next = processor->next;
+ rAudioProcessor *prev = processor->prev;
+
+ if (processor->process == process)
+ {
+ if (AUDIO.mixedProcessor == processor) AUDIO.mixedProcessor = next;
+ if (prev) prev->next = next;
+ if (next) next->prev = prev;
+
+ RL_FREE(processor);
+ }
+
+ processor = next;
+ }
+
+ ma_mutex_unlock(&AUDIO.System.lock);
+}
+
+
//----------------------------------------------------------------------------------
// Module specific Functions Definition
//----------------------------------------------------------------------------------
@@ -2165,7 +2326,7 @@ static ma_uint32 ReadAudioBufferFramesInInternalFormat(AudioBuffer *audioBuffer,
if (currentSubBufferIndex > 1) return 0;
- // Another thread can update the processed state of buffers so
+ // Another thread can update the processed state of buffers, so
// we just take a copy here to try and avoid potential synchronization problems
bool isSubBufferProcessed[2] = { 0 };
isSubBufferProcessed[0] = audioBuffer->isSubBufferProcessed[0];
@@ -2179,7 +2340,7 @@ static ma_uint32 ReadAudioBufferFramesInInternalFormat(AudioBuffer *audioBuffer,
{
// We break from this loop differently depending on the buffer's usage
// - For static buffers, we simply fill as much data as we can
- // - For streaming buffers we only fill the halves of the buffer that are processed
+ // - For streaming buffers we only fill half of the buffer that are processed
// Unprocessed halves must keep their audio data in-tact
if (audioBuffer->usage == AUDIO_BUFFER_USAGE_STATIC)
{
@@ -2236,7 +2397,7 @@ static ma_uint32 ReadAudioBufferFramesInInternalFormat(AudioBuffer *audioBuffer,
// For static buffers we can fill the remaining frames with silence for safety, but we don't want
// to report those frames as "read". The reason for this is that the caller uses the return value
- // to know whether or not a non-looping sound has finished playback.
+ // to know whether a non-looping sound has finished playback.
if (audioBuffer->usage != AUDIO_BUFFER_USAGE_STATIC) framesRead += totalFramesRemaining;
}
@@ -2289,7 +2450,6 @@ static ma_uint32 ReadAudioBufferFramesInMixingFormat(AudioBuffer *audioBuffer, f
return totalOutputFramesProcessed;
}
-
// Sending audio data to device callback function
// This function will be called when miniaudio needs more data
// NOTE: All the mixing takes place here
@@ -2379,6 +2539,13 @@ static void OnSendAudioDataToDevice(ma_device *pDevice, void *pFramesOut, const
}
}
+ rAudioProcessor *processor = AUDIO.mixedProcessor;
+ while (processor)
+ {
+ processor->process(pFramesOut, frameCount);
+ processor = processor->next;
+ }
+
ma_mutex_unlock(&AUDIO.System.lock);
}
diff --git a/src/raylib.dll.rc b/src/raylib.dll.rc
index 4380d9784..c2a42dca2 100644
--- a/src/raylib.dll.rc
+++ b/src/raylib.dll.rc
@@ -1,8 +1,8 @@
GLFW_ICON ICON "raylib.ico"
1 VERSIONINFO
-FILEVERSION 4,2,0,0
-PRODUCTVERSION 4,2,0,0
+FILEVERSION 4,5,0,0
+PRODUCTVERSION 4,5,0,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
@@ -11,12 +11,12 @@ BEGIN
BEGIN
//VALUE "CompanyName", "raylib technologies"
VALUE "FileDescription", "raylib dynamic library (www.raylib.com)"
- VALUE "FileVersion", "4.2.0"
+ VALUE "FileVersion", "4.5.0"
VALUE "InternalName", "raylib.dll"
- VALUE "LegalCopyright", "(c) 2022 Ramon Santamaria (@raysan5)"
+ VALUE "LegalCopyright", "(c) 2023 Ramon Santamaria (@raysan5)"
VALUE "OriginalFilename", "raylib.dll"
VALUE "ProductName", "raylib"
- VALUE "ProductVersion", "4.2.0"
+ VALUE "ProductVersion", "4.5.0"
END
END
BLOCK "VarFileInfo"
diff --git a/src/raylib.dll.rc.data b/src/raylib.dll.rc.data
index 729c45ddf..7403bd020 100644
Binary files a/src/raylib.dll.rc.data and b/src/raylib.dll.rc.data differ
diff --git a/src/raylib.h b/src/raylib.h
index 9bbb8874b..60b204122 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -1,6 +1,6 @@
/**********************************************************************************************
*
-* raylib v4.2 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
+* raylib v4.6-dev - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
*
* FEATURES:
* - NO external dependencies, all required libraries included with raylib
@@ -57,7 +57,7 @@
* raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software:
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -81,7 +81,10 @@
#include // Required for: va_list - Only used by TraceLogCallback
-#define RAYLIB_VERSION "4.2"
+#define RAYLIB_VERSION_MAJOR 4
+#define RAYLIB_VERSION_MINOR 6
+#define RAYLIB_VERSION_PATCH 0
+#define RAYLIB_VERSION "4.6-dev"
// Function specifiers in case library is build/used as a shared library (Windows)
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
@@ -130,12 +133,20 @@
// NOTE: MSVC C++ compiler does not support compound literals (C99 feature)
// Plain structures in C++ (without constructors) can be initialized with { }
+// This is called aggregate initialization (C++11 feature)
#if defined(__cplusplus)
#define CLITERAL(type) type
#else
#define CLITERAL(type) (type)
#endif
+// Some compilers (mostly macos clang) default to C++98,
+// where aggregate initialization can't be used
+// So, give a more clear error stating how to fix this
+#if !defined(_MSC_VER) && (defined(__cplusplus) && __cplusplus < 201103L)
+ #error "C++11 or later is required. Add -std=c++11"
+#endif
+
// NOTE: We set some defines with some data types declared by raylib
// Other modules (raymath, rlgl) also require some of those types, so,
// to be able to use those other modules as standalone (not depending on raylib)
@@ -213,7 +224,7 @@ typedef struct Vector4 {
// Quaternion, 4 components (Vector4 alias)
typedef Vector4 Quaternion;
-// Matrix, 4x4 components, column major, OpenGL style, right handed
+// Matrix, 4x4 components, column major, OpenGL style, right-handed
typedef struct Matrix {
float m0, m4, m8, m12; // Matrix first row (4 components)
float m1, m5, m9, m13; // Matrix second row (4 components)
@@ -364,7 +375,7 @@ typedef struct Material {
float params[4]; // Material generic parameters (if required)
} Material;
-// Transform, vectex transformation data
+// Transform, vertex transformation data
typedef struct Transform {
Vector3 translation; // Translation
Quaternion rotation; // Rotation
@@ -399,6 +410,7 @@ typedef struct ModelAnimation {
int frameCount; // Number of animation frames
BoneInfo *bones; // Bones information (skeleton)
Transform **framePoses; // Poses array by frame
+ char name[32]; // Animation name
} ModelAnimation;
// Ray, ray for raycasting
@@ -410,8 +422,8 @@ typedef struct Ray {
// RayCollision, ray hit information
typedef struct RayCollision {
bool hit; // Did the ray hit something?
- float distance; // Distance to nearest hit
- Vector3 point; // Point of nearest hit
+ float distance; // Distance to the nearest hit
+ Vector3 point; // Point of the nearest hit
Vector3 normal; // Surface normal of hit
} RayCollision;
@@ -514,6 +526,7 @@ typedef enum {
FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer
FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI
FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000, // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED
+ FLAG_BORDERLESS_WINDOWED_MODE = 0x00008000, // Set to run program in borderless windowed mode
FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X
FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D)
} ConfigFlags;
@@ -678,7 +691,7 @@ typedef enum {
MOUSE_CURSOR_RESIZE_NS = 6, // Vertical resize/move arrow shape
MOUSE_CURSOR_RESIZE_NWSE = 7, // Top-left to bottom-right diagonal resize/move arrow shape
MOUSE_CURSOR_RESIZE_NESW = 8, // The top-right to bottom-left diagonal resize/move arrow shape
- MOUSE_CURSOR_RESIZE_ALL = 9, // The omni-directional resize/move cursor shape
+ MOUSE_CURSOR_RESIZE_ALL = 9, // The omnidirectional resize/move cursor shape
MOUSE_CURSOR_NOT_ALLOWED = 10 // The operation-not-allowed shape
} MouseCursor;
@@ -716,7 +729,7 @@ typedef enum {
// Material map index
typedef enum {
- MATERIAL_MAP_ALBEDO = 0, // Albedo material (same as: MATERIAL_MAP_DIFFUSE)
+ MATERIAL_MAP_ALBEDO = 0, // Albedo material (same as: MATERIAL_MAP_DIFFUSE)
MATERIAL_MAP_METALNESS, // Metalness material (same as: MATERIAL_MAP_SPECULAR)
MATERIAL_MAP_NORMAL, // Normal material
MATERIAL_MAP_ROUGHNESS, // Roughness material
@@ -799,6 +812,9 @@ typedef enum {
PIXELFORMAT_UNCOMPRESSED_R32, // 32 bpp (1 channel - float)
PIXELFORMAT_UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float)
PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float)
+ PIXELFORMAT_UNCOMPRESSED_R16, // 16 bpp (1 channel - half float)
+ PIXELFORMAT_UNCOMPRESSED_R16G16B16, // 16*3 bpp (3 channels - half float)
+ PIXELFORMAT_UNCOMPRESSED_R16G16B16A16, // 16*4 bpp (4 channels - half float)
PIXELFORMAT_COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
PIXELFORMAT_COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
PIXELFORMAT_COMPRESSED_DXT3_RGBA, // 8 bpp
@@ -836,10 +852,10 @@ typedef enum {
typedef enum {
CUBEMAP_LAYOUT_AUTO_DETECT = 0, // Automatically detect layout type
CUBEMAP_LAYOUT_LINE_VERTICAL, // Layout is defined by a vertical line with faces
- CUBEMAP_LAYOUT_LINE_HORIZONTAL, // Layout is defined by an horizontal line with faces
+ CUBEMAP_LAYOUT_LINE_HORIZONTAL, // Layout is defined by a horizontal line with faces
CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces
- CUBEMAP_LAYOUT_PANORAMA // Layout is defined by a panorama image (equirectangular map)
+ CUBEMAP_LAYOUT_PANORAMA // Layout is defined by a panorama image (equirrectangular map)
} CubemapLayout;
// Font type, defines generation method
@@ -857,11 +873,12 @@ typedef enum {
BLEND_ADD_COLORS, // Blend textures adding colors (alternative)
BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative)
BLEND_ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha
- BLEND_CUSTOM // Blend textures using custom src/dst factors (use rlSetBlendMode())
+ BLEND_CUSTOM, // Blend textures using custom src/dst factors (use rlSetBlendFactors())
+ BLEND_CUSTOM_SEPARATE // Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate())
} BlendMode;
// Gesture
-// NOTE: It could be used as flags to enable only some gestures
+// NOTE: Provided as bit-wise flags to enable only desired gestures
typedef enum {
GESTURE_NONE = 0, // No gesture
GESTURE_TAP = 1, // Tap gesture
@@ -899,7 +916,7 @@ typedef enum {
} NPatchLayout;
// Callbacks to hook some internal functions
-// WARNING: This callbacks are intended for advance users
+// WARNING: These callbacks are intended for advance users
typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args); // Logging: Redirect trace log messages
typedef unsigned char *(*LoadFileDataCallback)(const char *fileName, unsigned int *bytesRead); // FileIO: Load binary data
typedef bool (*SaveFileDataCallback)(const char *fileName, void *data, unsigned int bytesToWrite); // FileIO: Save binary data
@@ -934,16 +951,19 @@ RLAPI bool IsWindowState(unsigned int flag); // Check if on
RLAPI void SetWindowState(unsigned int flags); // Set window configuration state using flags (only PLATFORM_DESKTOP)
RLAPI void ClearWindowState(unsigned int flags); // Clear window configuration state flags
RLAPI void ToggleFullscreen(void); // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP)
+RLAPI void ToggleBorderlessWindowed(void); // Toggle window state: borderless windowed (only PLATFORM_DESKTOP)
RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
-RLAPI void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP)
-RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP)
+RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)
+RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
+RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
-RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode)
+RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window
RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
RLAPI void SetWindowSize(int width, int height); // Set window dimensions
RLAPI void SetWindowOpacity(float opacity); // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
+RLAPI void SetWindowFocused(void); // Set window focused (only PLATFORM_DESKTOP)
RLAPI void *GetWindowHandle(void); // Get native window handle
RLAPI int GetScreenWidth(void); // Get current screen width
RLAPI int GetScreenHeight(void); // Get current screen height
@@ -959,7 +979,7 @@ RLAPI int GetMonitorPhysicalHeight(int monitor); // Get specifi
RLAPI int GetMonitorRefreshRate(int monitor); // Get specified monitor refresh rate
RLAPI Vector2 GetWindowPosition(void); // Get window position XY on monitor
RLAPI Vector2 GetWindowScaleDPI(void); // Get window scale DPI factor
-RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor
+RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the specified monitor
RLAPI void SetClipboardText(const char *text); // Set clipboard text content
RLAPI const char *GetClipboardText(void); // Get clipboard text content
RLAPI void EnableEventWaiting(void); // Enable waiting for events on EndDrawing(), no automatic event polling
@@ -1008,6 +1028,7 @@ RLAPI void UnloadVrStereoConfig(VrStereoConfig config); // Unload VR s
// NOTE: Shader functionality is not available on OpenGL 1.1
RLAPI Shader LoadShader(const char *vsFileName, const char *fsFileName); // Load shader from files and bind default locations
RLAPI Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode); // Load shader from code strings and bind default locations
+RLAPI bool IsShaderReady(Shader shader); // Check if a shader is ready
RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
RLAPI int GetShaderLocationAttrib(Shader shader, const char *attribName); // Get shader attribute location
RLAPI void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType); // Set shader uniform value
@@ -1057,7 +1078,7 @@ RLAPI void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom
RLAPI unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read)
RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData()
RLAPI bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write), returns true on success
-RLAPI bool ExportDataAsCode(const char *data, unsigned int size, const char *fileName); // Export data to code (.h), returns true on success
+RLAPI bool ExportDataAsCode(const unsigned char *data, unsigned int size, const char *fileName); // Export data to code (.h), returns true on success
RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string
RLAPI void UnloadFileText(char *text); // Unload file text data allocated by LoadFileText()
RLAPI bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success
@@ -1094,6 +1115,7 @@ RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize
// Input-related functions: keyboard
RLAPI bool IsKeyPressed(int key); // Check if a key has been pressed once
+RLAPI bool IsKeyPressedRepeat(int key); // Check if a key has been pressed again (Only PLATFORM_DESKTOP)
RLAPI bool IsKeyDown(int key); // Check if a key is being pressed
RLAPI bool IsKeyReleased(int key); // Check if a key has been released once
RLAPI bool IsKeyUp(int key); // Check if a key is NOT being pressed
@@ -1151,13 +1173,8 @@ RLAPI float GetGesturePinchAngle(void); // Get gesture pinch ang
//------------------------------------------------------------------------------------
// Camera System Functions (Module: rcamera)
//------------------------------------------------------------------------------------
-RLAPI void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available)
-RLAPI void UpdateCamera(Camera *camera); // Update camera position for selected mode
-
-RLAPI void SetCameraPanControl(int keyPan); // Set camera pan key to combine with mouse movement (free camera)
-RLAPI void SetCameraAltControl(int keyAlt); // Set camera alt key to combine with mouse movement (free camera)
-RLAPI void SetCameraSmoothZoomControl(int keySmoothZoom); // Set camera smooth zoom key to combine with mouse (free camera)
-RLAPI void SetCameraMoveControls(int keyFront, int keyBack, int keyRight, int keyLeft, int keyUp, int keyDown); // Set camera move controls (1st person and 3rd person cameras)
+RLAPI void UpdateCamera(Camera *camera, int mode); // Update camera position for selected mode
+RLAPI void UpdateCameraPro(Camera *camera, Vector3 movement, Vector3 rotation, float zoom); // Update camera movement/rotation
//------------------------------------------------------------------------------------
// Basic Shapes Drawing Functions (Module: shapes)
@@ -1176,6 +1193,8 @@ RLAPI void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color
RLAPI void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line using cubic-bezier curves in-out
RLAPI void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thick, Color color); // Draw line using quadratic bezier curves with a control point
RLAPI void DrawLineBezierCubic(Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thick, Color color); // Draw line using cubic bezier curves with 2 control points
+RLAPI void DrawLineBSpline(Vector2 *points, int pointCount, float thick, Color color); // Draw a B-Spline line, minimum 4 points
+RLAPI void DrawLineCatmullRom(Vector2 *points, int pointCount, float thick, Color color); // Draw a Catmull Rom spline line, minimum 4 points
RLAPI void DrawLineStrip(Vector2 *points, int pointCount, Color color); // Draw lines sequence
RLAPI void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle
RLAPI void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); // Draw a piece of a circle
@@ -1223,7 +1242,7 @@ RLAPI Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2);
//------------------------------------------------------------------------------------
// Image loading functions
-// NOTE: This functions do not require GPU access
+// NOTE: These functions do not require GPU access
RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)
RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data
RLAPI Image LoadImageSvg(const char *fileName, int width, int height); // Load image from SVG file data with specified size
@@ -1232,19 +1251,22 @@ RLAPI Image LoadImageAnim(const char *fileName, int *frames);
RLAPI Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load image from memory buffer, fileType refers to extension: i.e. '.png'
RLAPI Image LoadImageFromTexture(Texture2D texture); // Load image from GPU texture data
RLAPI Image LoadImageFromScreen(void); // Load image from screen buffer and (screenshot)
+RLAPI bool IsImageReady(Image image); // Check if an image is ready
RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM)
RLAPI bool ExportImage(Image image, const char *fileName); // Export image data to file, returns true on success
+RLAPI unsigned char *ExportImageToMemory(Image image, const char *fileType, int *fileSize); // Export image to memory buffer
RLAPI bool ExportImageAsCode(Image image, const char *fileName); // Export image as code file defining an array of bytes, returns true on success
// Image generation functions
RLAPI Image GenImageColor(int width, int height, Color color); // Generate image: plain color
-RLAPI Image GenImageGradientV(int width, int height, Color top, Color bottom); // Generate image: vertical gradient
-RLAPI Image GenImageGradientH(int width, int height, Color left, Color right); // Generate image: horizontal gradient
+RLAPI Image GenImageGradientLinear(int width, int height, int direction, Color start, Color end); // Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient
RLAPI Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); // Generate image: radial gradient
+RLAPI Image GenImageGradientSquare(int width, int height, float density, Color inner, Color outer); // Generate image: square gradient
RLAPI Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2); // Generate image: checked
RLAPI Image GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise
RLAPI Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); // Generate image: perlin noise
RLAPI Image GenImageCellular(int width, int height, int tileSize); // Generate image: cellular algorithm, bigger tileSize means bigger cells
+RLAPI Image GenImageText(int width, int height, const char *text); // Generate image: grayscale image from text data
// Image manipulation functions
RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)
@@ -1258,6 +1280,7 @@ RLAPI void ImageAlphaCrop(Image *image, float threshold);
RLAPI void ImageAlphaClear(Image *image, Color color, float threshold); // Clear alpha channel to desired color
RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
RLAPI void ImageAlphaPremultiply(Image *image); // Premultiply alpha channel
+RLAPI void ImageBlurGaussian(Image *image, int blurSize); // Apply Gaussian blur using a box blur approximation
RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize image (Bicubic scaling algorithm)
RLAPI void ImageResizeNN(Image *image, int newWidth,int newHeight); // Resize image (Nearest-Neighbor scaling algorithm)
RLAPI void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill); // Resize canvas and fill with color
@@ -1265,6 +1288,7 @@ RLAPI void ImageMipmaps(Image *image);
RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
RLAPI void ImageFlipVertical(Image *image); // Flip image vertically
RLAPI void ImageFlipHorizontal(Image *image); // Flip image horizontally
+RLAPI void ImageRotate(Image *image, int degrees); // Rotate image by input angle in degrees (-359 to 359)
RLAPI void ImageRotateCW(Image *image); // Rotate image clockwise 90deg
RLAPI void ImageRotateCCW(Image *image); // Rotate image counter-clockwise 90deg
RLAPI void ImageColorTint(Image *image, Color color); // Modify image color: tint
@@ -1305,7 +1329,9 @@ RLAPI Texture2D LoadTexture(const char *fileName);
RLAPI Texture2D LoadTextureFromImage(Image image); // Load texture from image data
RLAPI TextureCubemap LoadTextureCubemap(Image image, int layout); // Load cubemap from image, multiple image cubemap layouts supported
RLAPI RenderTexture2D LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer)
+RLAPI bool IsTextureReady(Texture2D texture); // Check if a texture is ready
RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)
+RLAPI bool IsRenderTextureReady(RenderTexture2D target); // Check if a render texture is ready
RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM)
RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data
RLAPI void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels); // Update GPU texture rectangle with new data
@@ -1320,11 +1346,8 @@ RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint);
RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters
RLAPI void DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle
-RLAPI void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint); // Draw texture quad with tiling and offset parameters
-RLAPI void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint); // Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.
-RLAPI void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draw a part of a texture defined by a rectangle with 'pro' parameters
-RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely
-RLAPI void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint); // Draw a textured polygon
+RLAPI void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draw a part of a texture defined by a rectangle with 'pro' parameters
+RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely
// Color/pixel related functions
RLAPI Color Fade(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f
@@ -1333,6 +1356,9 @@ RLAPI Vector4 ColorNormalize(Color color); // G
RLAPI Color ColorFromNormalized(Vector4 normalized); // Get Color from normalized values [0..1]
RLAPI Vector3 ColorToHSV(Color color); // Get HSV values for a Color, hue [0..360], saturation/value [0..1]
RLAPI Color ColorFromHSV(float hue, float saturation, float value); // Get a Color from HSV values, hue [0..360], saturation/value [0..1]
+RLAPI Color ColorTint(Color color, Color tint); // Get color multiplied with another color
+RLAPI Color ColorBrightness(Color color, float factor); // Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
+RLAPI Color ColorContrast(Color color, float contrast); // Get color with contrast correction, contrast values between -1.0f and 1.0f
RLAPI Color ColorAlpha(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f
RLAPI Color ColorAlphaBlend(Color dst, Color src, Color tint); // Get src alpha-blended into dst color with tint
RLAPI Color GetColor(unsigned int hexValue); // Get Color structure from hexadecimal value
@@ -1350,6 +1376,7 @@ RLAPI Font LoadFont(const char *fileName);
RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int glyphCount); // Load font from file with extended parameters, use NULL for fontChars and 0 for glyphCount to load the default character set
RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)
RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
+RLAPI bool IsFontReady(Font font); // Check if a font is ready
RLAPI GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount, int type); // Load font data for further use
RLAPI Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **recs, int glyphCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info
RLAPI void UnloadFontData(GlyphInfo *chars, int glyphCount); // Unload font chars info data (RAM)
@@ -1365,6 +1392,7 @@ RLAPI void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float f
RLAPI void DrawTextCodepoints(Font font, const int *codepoints, int count, Vector2 position, float fontSize, float spacing, Color tint); // Draw multiple character (codepoint)
// Text font info functions
+RLAPI void SetTextLineSpacing(int spacing); // Set vertical line spacing when drawing with line-breaks
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
RLAPI Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // Measure string size for Font
RLAPI int GetGlyphIndex(Font font, int codepoint); // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found
@@ -1414,8 +1442,6 @@ RLAPI void DrawCube(Vector3 position, float width, float height, float length, C
RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version)
RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires
RLAPI void DrawCubeWiresV(Vector3 position, Vector3 size, Color color); // Draw cube wires (Vector version)
-RLAPI void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured
-RLAPI void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color); // Draw cube with a region of a texture
RLAPI void DrawSphere(Vector3 centerPos, float radius, Color color); // Draw sphere
RLAPI void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere with extended parameters
RLAPI void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires
@@ -1423,6 +1449,8 @@ RLAPI void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, f
RLAPI void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder with base at startPos and top at endPos
RLAPI void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires
RLAPI void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder wires with base at startPos and top at endPos
+RLAPI void DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color); // Draw a capsule with the center of its sphere caps at startPos and endPos
+RLAPI void DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color); // Draw capsule wireframe with the center of its sphere caps at startPos and endPos
RLAPI void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ
RLAPI void DrawRay(Ray ray, Color color); // Draw a ray line
RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0))
@@ -1434,16 +1462,16 @@ RLAPI void DrawGrid(int slices, float spacing);
// Model management functions
RLAPI Model LoadModel(const char *fileName); // Load model from files (meshes and materials)
RLAPI Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh (default material)
+RLAPI bool IsModelReady(Model model); // Check if a model is ready
RLAPI void UnloadModel(Model model); // Unload model (including meshes) from memory (RAM and/or VRAM)
-RLAPI void UnloadModelKeepMeshes(Model model); // Unload model (but not meshes) from memory (RAM and/or VRAM)
RLAPI BoundingBox GetModelBoundingBox(Model model); // Compute model bounding box limits (considers all meshes)
// Model drawing functions
-RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
+RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters
-RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set)
+RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set)
RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters
-RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
+RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 position, float size, Color tint); // Draw a billboard texture
RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint); // Draw a billboard texture defined by source
RLAPI void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint); // Draw a billboard texture defined by source and rotation
@@ -1474,6 +1502,7 @@ RLAPI Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize);
// Material loading/unloading functions
RLAPI Material *LoadMaterials(const char *fileName, int *materialCount); // Load materials from model file
RLAPI Material LoadMaterialDefault(void); // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)
+RLAPI bool IsMaterialReady(Material material); // Check if a material is ready
RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)
RLAPI void SetMaterialTexture(Material *material, int mapType, Texture2D texture); // Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...)
RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh
@@ -1509,11 +1538,15 @@ RLAPI void SetMasterVolume(float volume); // Set mas
// Wave/Sound loading/unloading functions
RLAPI Wave LoadWave(const char *fileName); // Load wave data from file
RLAPI Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load wave from memory buffer, fileType refers to extension: i.e. '.wav'
+RLAPI bool IsWaveReady(Wave wave); // Checks if wave data is ready
RLAPI Sound LoadSound(const char *fileName); // Load sound from file
RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data
+RLAPI Sound LoadSoundAlias(Sound source); // Create a new sound that shares the same sample data as the source sound, does not own the sound data
+RLAPI bool IsSoundReady(Sound sound); // Checks if a sound is ready
RLAPI void UpdateSound(Sound sound, const void *data, int sampleCount); // Update sound buffer with new data
RLAPI void UnloadWave(Wave wave); // Unload wave data
RLAPI void UnloadSound(Sound sound); // Unload sound
+RLAPI void UnloadSoundAlias(Sound alias); // Unload a sound alias (does not deallocate sample data)
RLAPI bool ExportWave(Wave wave, const char *fileName); // Export wave data to file, returns true on success
RLAPI bool ExportWaveAsCode(Wave wave, const char *fileName); // Export wave sample data to code (.h), returns true on success
@@ -1522,9 +1555,6 @@ RLAPI void PlaySound(Sound sound); // Play a
RLAPI void StopSound(Sound sound); // Stop playing a sound
RLAPI void PauseSound(Sound sound); // Pause a sound
RLAPI void ResumeSound(Sound sound); // Resume a paused sound
-RLAPI void PlaySoundMulti(Sound sound); // Play a sound (using multichannel buffer pool)
-RLAPI void StopSoundMulti(void); // Stop any sound playing (using multichannel buffer pool)
-RLAPI int GetSoundsPlaying(void); // Get number of sounds playing in the multichannel
RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)
RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
@@ -1538,6 +1568,7 @@ RLAPI void UnloadWaveSamples(float *samples); // Unload
// Music management functions
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
RLAPI Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, int dataSize); // Load music stream from data
+RLAPI bool IsMusicReady(Music music); // Checks if a music stream is ready
RLAPI void UnloadMusicStream(Music music); // Unload music stream
RLAPI void PlayMusicStream(Music music); // Start music playing
RLAPI bool IsMusicStreamPlaying(Music music); // Check if music is playing
@@ -1554,6 +1585,7 @@ RLAPI float GetMusicTimePlayed(Music music); // Get cur
// AudioStream management functions
RLAPI AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Load audio stream (to stream raw audio pcm data)
+RLAPI bool IsAudioStreamReady(AudioStream stream); // Checks if an audio stream is ready
RLAPI void UnloadAudioStream(AudioStream stream); // Unload audio stream and free memory
RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int frameCount); // Update audio stream buffers with data
RLAPI bool IsAudioStreamProcessed(AudioStream stream); // Check if any audio stream buffers requires refill
@@ -1568,9 +1600,12 @@ RLAPI void SetAudioStreamPan(AudioStream stream, float pan); // Set pan
RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams
RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data
-RLAPI void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream
+RLAPI void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream, receives the samples as s
RLAPI void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Detach audio stream processor from stream
+RLAPI void AttachAudioMixedProcessor(AudioCallback processor); // Attach audio stream processor to the entire audio pipeline, receives the samples as s
+RLAPI void DetachAudioMixedProcessor(AudioCallback processor); // Detach audio stream processor from the entire audio pipeline
+
#if defined(__cplusplus)
}
#endif
diff --git a/src/raylib.rc b/src/raylib.rc
index 984017055..6a9546537 100644
--- a/src/raylib.rc
+++ b/src/raylib.rc
@@ -1,8 +1,8 @@
GLFW_ICON ICON "raylib.ico"
1 VERSIONINFO
-FILEVERSION 4,2,0,0
-PRODUCTVERSION 4,2,0,0
+FILEVERSION 4,5,0,0
+PRODUCTVERSION 4,5,0,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
@@ -11,12 +11,12 @@ BEGIN
BEGIN
//VALUE "CompanyName", "raylib technologies"
VALUE "FileDescription", "raylib application (www.raylib.com)"
- VALUE "FileVersion", "4.2.0"
+ VALUE "FileVersion", "4.5.0"
VALUE "InternalName", "raylib app"
- VALUE "LegalCopyright", "(c) 2022 Ramon Santamaria (@raysan5)"
+ VALUE "LegalCopyright", "(c) 2023 Ramon Santamaria (@raysan5)"
//VALUE "OriginalFilename", "raylib_app.exe"
VALUE "ProductName", "raylib app"
- VALUE "ProductVersion", "4.2.0"
+ VALUE "ProductVersion", "4.5.0"
END
END
BLOCK "VarFileInfo"
diff --git a/src/raylib.rc.data b/src/raylib.rc.data
index e44f566d4..1485d3aa4 100644
Binary files a/src/raylib.rc.data and b/src/raylib.rc.data differ
diff --git a/src/raymath.h b/src/raymath.h
index fbe4ceadc..1fab43aad 100644
--- a/src/raymath.h
+++ b/src/raymath.h
@@ -2,30 +2,35 @@
*
* raymath v1.5 - Math functions to work with Vector2, Vector3, Matrix and Quaternions
*
-* CONFIGURATION:
-*
-* #define RAYMATH_IMPLEMENTATION
-* Generates the implementation of the library into the included file.
-* If not defined, the library is in header only mode and can be included in other headers
-* or source files without problems. But only ONE file should hold the implementation.
-*
-* #define RAYMATH_STATIC_INLINE
-* Define static inline functions code, so #include header suffices for use.
-* This may use up lots of memory.
-*
* CONVENTIONS:
-*
+* - Matrix structure is defined as row-major (memory layout) but parameters naming AND all
+* math operations performed by the library consider the structure as it was column-major
+* It is like transposed versions of the matrices are used for all the maths
+* It benefits some functions making them cache-friendly and also avoids matrix
+* transpositions sometimes required by OpenGL
+* Example: In memory order, row0 is [m0 m4 m8 m12] but in semantic math row0 is [m0 m1 m2 m3]
* - Functions are always self-contained, no function use another raymath function inside,
* required code is directly re-implemented inside
* - Functions input parameters are always received by value (2 unavoidable exceptions)
* - Functions use always a "result" variable for return
* - Functions are always defined inline
* - Angles are always in radians (DEG2RAD/RAD2DEG macros provided for convenience)
+* - No compound literals used to make sure libray is compatible with C++
+*
+* CONFIGURATION:
+* #define RAYMATH_IMPLEMENTATION
+* Generates the implementation of the library into the included file.
+* If not defined, the library is in header only mode and can be included in other headers
+* or source files without problems. But only ONE file should hold the implementation.
+*
+* #define RAYMATH_STATIC_INLINE
+* Define static inline functions code, so #include header suffices for use.
+* This may use up lots of memory.
*
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -306,10 +311,27 @@ RMAPI float Vector2DistanceSqr(Vector2 v1, Vector2 v2)
return result;
}
-// Calculate angle from two vectors
+// Calculate angle between two vectors
+// NOTE: Angle is calculated from origin point (0, 0)
RMAPI float Vector2Angle(Vector2 v1, Vector2 v2)
{
- float result = atan2f(v2.y, v2.x) - atan2f(v1.y, v1.x);
+ float result = 0.0f;
+
+ float dot = v1.x*v2.x + v1.y*v2.y;
+ float det = v1.x*v2.y - v1.y*v2.x;
+ result = -atan2f(det, dot);
+
+ return result;
+}
+
+// Calculate angle defined by a two vectors line
+// NOTE: Parameters need to be normalized
+// Current implementation should be aligned with glm::angle
+RMAPI float Vector2LineAngle(Vector2 start, Vector2 end)
+{
+ float result = 0.0f;
+
+ result = atan2f(end.y - start.y, end.x - start.x);
return result;
}
@@ -680,12 +702,48 @@ RMAPI Vector3 Vector3Normalize(Vector3 v)
Vector3 result = v;
float length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);
- if (length == 0.0f) length = 1.0f;
- float ilength = 1.0f/length;
+ if (length != 0.0f)
+ {
+ float ilength = 1.0f/length;
- result.x *= ilength;
- result.y *= ilength;
- result.z *= ilength;
+ result.x *= ilength;
+ result.y *= ilength;
+ result.z *= ilength;
+ }
+
+ return result;
+}
+
+//Calculate the projection of the vector v1 on to v2
+RMAPI Vector3 Vector3Project(Vector3 v1, Vector3 v2)
+{
+ Vector3 result = { 0 };
+
+ float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
+ float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z);
+
+ float mag = v1dv2/v2dv2;
+
+ result.x = v2.x*mag;
+ result.y = v2.y*mag;
+ result.z = v2.z*mag;
+
+ return result;
+}
+
+//Calculate the rejection of the vector v1 on to v2
+RMAPI Vector3 Vector3Reject(Vector3 v1, Vector3 v2)
+{
+ Vector3 result = { 0 };
+
+ float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
+ float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z);
+
+ float mag = v1dv2/v2dv2;
+
+ result.x = v1.x - (v2.x*mag);
+ result.y = v1.y - (v2.y*mag);
+ result.z = v1.z - (v2.z*mag);
return result;
}
@@ -889,7 +947,7 @@ RMAPI Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view)
{
Vector3 result = { 0 };
- // Calculate unproject matrix (multiply view patrix by projection matrix) and invert it
+ // Calculate unprojected matrix (multiply view matrix by projection matrix) and invert it
Matrix matViewProj = { // MatrixMultiply(view, projection);
view.m0*projection.m0 + view.m1*projection.m4 + view.m2*projection.m8 + view.m3*projection.m12,
view.m0*projection.m1 + view.m1*projection.m5 + view.m2*projection.m9 + view.m3*projection.m13,
@@ -952,7 +1010,7 @@ RMAPI Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view)
// Create quaternion from source point
Quaternion quat = { source.x, source.y, source.z, 1.0f };
- // Multiply quat point by unproject matrix
+ // Multiply quat point by unprojecte matrix
Quaternion qtransformed = { // QuaternionTransform(quat, matViewProjInv)
matViewProjInv.m0*quat.x + matViewProjInv.m4*quat.y + matViewProjInv.m8*quat.z + matViewProjInv.m12*quat.w,
matViewProjInv.m1*quat.x + matViewProjInv.m5*quat.y + matViewProjInv.m9*quat.z + matViewProjInv.m13*quat.w,
@@ -1486,11 +1544,11 @@ RMAPI Matrix MatrixFrustum(double left, double right, double bottom, double top,
// Get perspective projection matrix
// NOTE: Fovy angle must be provided in radians
-RMAPI Matrix MatrixPerspective(double fovy, double aspect, double near, double far)
+RMAPI Matrix MatrixPerspective(double fovY, double aspect, double nearPlane, double farPlane)
{
Matrix result = { 0 };
- double top = near*tan(fovy*0.5);
+ double top = nearPlane*tan(fovY*0.5);
double bottom = -top;
double right = top*aspect;
double left = -right;
@@ -1498,27 +1556,27 @@ RMAPI Matrix MatrixPerspective(double fovy, double aspect, double near, double f
// MatrixFrustum(-right, right, -top, top, near, far);
float rl = (float)(right - left);
float tb = (float)(top - bottom);
- float fn = (float)(far - near);
+ float fn = (float)(farPlane - nearPlane);
- result.m0 = ((float)near*2.0f)/rl;
- result.m5 = ((float)near*2.0f)/tb;
+ result.m0 = ((float)nearPlane*2.0f)/rl;
+ result.m5 = ((float)nearPlane*2.0f)/tb;
result.m8 = ((float)right + (float)left)/rl;
result.m9 = ((float)top + (float)bottom)/tb;
- result.m10 = -((float)far + (float)near)/fn;
+ result.m10 = -((float)farPlane + (float)nearPlane)/fn;
result.m11 = -1.0f;
- result.m14 = -((float)far*(float)near*2.0f)/fn;
+ result.m14 = -((float)farPlane*(float)nearPlane*2.0f)/fn;
return result;
}
// Get orthographic projection matrix
-RMAPI Matrix MatrixOrtho(double left, double right, double bottom, double top, double near, double far)
+RMAPI Matrix MatrixOrtho(double left, double right, double bottom, double top, double nearPlane, double farPlane)
{
Matrix result = { 0 };
float rl = (float)(right - left);
float tb = (float)(top - bottom);
- float fn = (float)(far - near);
+ float fn = (float)(farPlane - nearPlane);
result.m0 = 2.0f/rl;
result.m1 = 0.0f;
@@ -1534,7 +1592,7 @@ RMAPI Matrix MatrixOrtho(double left, double right, double bottom, double top, d
result.m11 = 0.0f;
result.m12 = -((float)left + (float)right)/rl;
result.m13 = -((float)top + (float)bottom)/tb;
- result.m14 = -((float)far + (float)near)/fn;
+ result.m14 = -((float)farPlane + (float)nearPlane)/fn;
result.m15 = 1.0f;
return result;
diff --git a/src/rcamera.h b/src/rcamera.h
index 37ea13a67..de169fc39 100644
--- a/src/rcamera.h
+++ b/src/rcamera.h
@@ -1,28 +1,26 @@
/*******************************************************************************************
*
-* rcamera - Basic camera system for multiple camera modes
-*
-* NOTE: Memory footprint of this library is aproximately 52 bytes (global variables)
+* rcamera - Basic camera system with support for multiple camera modes
*
* CONFIGURATION:
+* #define RCAMERA_IMPLEMENTATION
+* Generates the implementation of the library into the included file.
+* If not defined, the library is in header only mode and can be included in other headers
+* or source files without problems. But only ONE file should hold the implementation.
*
-* #define CAMERA_IMPLEMENTATION
-* Generates the implementation of the library into the included file.
-* If not defined, the library is in header only mode and can be included in other headers
-* or source files without problems. But only ONE file should hold the implementation.
-*
-* #define CAMERA_STANDALONE
-* If defined, the library can be used as standalone as a camera system but some
-* functions must be redefined to manage inputs accordingly.
+* #define RCAMERA_STANDALONE
+* If defined, the library can be used as standalone as a camera system but some
+* functions must be redefined to manage inputs accordingly.
*
* CONTRIBUTORS:
* Ramon Santamaria: Supervision, review, update and maintenance
+* Christoph Wagner: Complete redesign, using raymath (2022)
* Marc Palau: Initial implementation (2014)
*
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2022-2023 Christoph Wagner (@Crydsch) & Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -47,51 +45,70 @@
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
-//...
+// Function specifiers definition
+#ifndef RLAPI
+ #define RLAPI // Functions defined as 'extern' by default (implicit specifiers)
+#endif
+
+#if defined(RCAMERA_STANDALONE)
+ #define CAMERA_CULL_DISTANCE_NEAR 0.01
+ #define CAMERA_CULL_DISTANCE_FAR 1000.0
+#else
+ #define CAMERA_CULL_DISTANCE_NEAR RL_CULL_DISTANCE_NEAR
+ #define CAMERA_CULL_DISTANCE_FAR RL_CULL_DISTANCE_FAR
+#endif
//----------------------------------------------------------------------------------
// Types and Structures Definition
-// NOTE: Below types are required for CAMERA_STANDALONE usage
+// NOTE: Below types are required for standalone usage
//----------------------------------------------------------------------------------
-#if defined(CAMERA_STANDALONE)
- // Vector2 type
+#if defined(RCAMERA_STANDALONE)
+ // Vector2, 2 components
typedef struct Vector2 {
- float x;
- float y;
+ float x; // Vector x component
+ float y; // Vector y component
} Vector2;
- // Vector3 type
+ // Vector3, 3 components
typedef struct Vector3 {
- float x;
- float y;
- float z;
+ float x; // Vector x component
+ float y; // Vector y component
+ float z; // Vector z component
} Vector3;
+ // Matrix, 4x4 components, column major, OpenGL style, right-handed
+ typedef struct Matrix {
+ float m0, m4, m8, m12; // Matrix first row (4 components)
+ float m1, m5, m9, m13; // Matrix second row (4 components)
+ float m2, m6, m10, m14; // Matrix third row (4 components)
+ float m3, m7, m11, m15; // Matrix fourth row (4 components)
+ } Matrix;
+
// Camera type, defines a camera position/orientation in 3d space
typedef struct Camera3D {
Vector3 position; // Camera position
Vector3 target; // Camera target it looks-at
Vector3 up; // Camera up vector (rotation over its axis)
float fovy; // Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic
- int type; // Camera type, defines projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
+ int projection; // Camera projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
} Camera3D;
typedef Camera3D Camera; // Camera type fallback, defaults to Camera3D
+ // Camera projection
+ typedef enum {
+ CAMERA_PERSPECTIVE = 0, // Perspective projection
+ CAMERA_ORTHOGRAPHIC // Orthographic projection
+ } CameraProjection;
+
// Camera system modes
typedef enum {
- CAMERA_CUSTOM = 0,
- CAMERA_FREE,
- CAMERA_ORBITAL,
- CAMERA_FIRST_PERSON,
- CAMERA_THIRD_PERSON
+ CAMERA_CUSTOM = 0, // Camera custom, controlled by user (UpdateCamera() does nothing)
+ CAMERA_FREE, // Camera free mode
+ CAMERA_ORBITAL, // Camera orbital, around target, zoom supported
+ CAMERA_FIRST_PERSON, // Camera first person
+ CAMERA_THIRD_PERSON // Camera third person
} CameraMode;
-
- // Camera projection modes
- typedef enum {
- CAMERA_PERSPECTIVE = 0,
- CAMERA_ORTHOGRAPHIC
- } CameraProjection;
#endif
//----------------------------------------------------------------------------------
@@ -107,23 +124,29 @@
extern "C" { // Prevents name mangling of functions
#endif
-#if defined(CAMERA_STANDALONE)
-void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available)
-void UpdateCamera(Camera *camera); // Update camera position for selected mode
+RLAPI Vector3 GetCameraForward(Camera *camera);
+RLAPI Vector3 GetCameraUp(Camera *camera);
+RLAPI Vector3 GetCameraRight(Camera *camera);
-void SetCameraPanControl(int keyPan); // Set camera pan key to combine with mouse movement (free camera)
-void SetCameraAltControl(int keyAlt); // Set camera alt key to combine with mouse movement (free camera)
-void SetCameraSmoothZoomControl(int szoomKey); // Set camera smooth zoom key to combine with mouse (free camera)
-void SetCameraMoveControls(int keyFront, int keyBack,
- int keyRight, int keyLeft,
- int keyUp, int keyDown); // Set camera move controls (1st person and 3rd person cameras)
-#endif
+// Camera movement
+RLAPI void CameraMoveForward(Camera *camera, float distance, bool moveInWorldPlane);
+RLAPI void CameraMoveUp(Camera *camera, float distance);
+RLAPI void CameraMoveRight(Camera *camera, float distance, bool moveInWorldPlane);
+RLAPI void CameraMoveToTarget(Camera *camera, float delta);
+
+// Camera rotation
+RLAPI void CameraYaw(Camera *camera, float angle, bool rotateAroundTarget);
+RLAPI void CameraPitch(Camera *camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp);
+RLAPI void CameraRoll(Camera *camera, float angle);
+
+RLAPI Matrix GetCameraViewMatrix(Camera *camera);
+RLAPI Matrix GetCameraProjectionMatrix(Camera* camera, float aspect);
#if defined(__cplusplus)
}
#endif
-#endif // CAMERA_H
+#endif // RCAMERA_H
/***********************************************************************************
@@ -132,427 +155,390 @@ void SetCameraMoveControls(int keyFront, int keyBack,
*
************************************************************************************/
-#if defined(CAMERA_IMPLEMENTATION)
+#if defined(RCAMERA_IMPLEMENTATION)
-#include // Required for: sinf(), cosf(), sqrtf()
+#include "raymath.h" // Required for vector maths:
+ // Vector3Add()
+ // Vector3Subtract()
+ // Vector3Scale()
+ // Vector3Normalize()
+ // Vector3Distance()
+ // Vector3CrossProduct()
+ // Vector3RotateByAxisAngle()
+ // Vector3Angle()
+ // Vector3Negate()
+ // MatrixLookAt()
+ // MatrixPerspective()
+ // MatrixOrtho()
+ // MatrixIdentity()
+
+// raylib required functionality:
+ // GetMouseDelta()
+ // GetMouseWheelMove()
+ // IsKeyDown()
+ // IsKeyPressed()
+ // GetFrameTime()
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
-#ifndef PI
- #define PI 3.14159265358979323846
-#endif
-#ifndef DEG2RAD
- #define DEG2RAD (PI/180.0f)
-#endif
-#ifndef RAD2DEG
- #define RAD2DEG (180.0f/PI)
-#endif
+#define CAMERA_MOVE_SPEED 0.09f
+#define CAMERA_ROTATION_SPEED 0.03f
+#define CAMERA_PAN_SPEED 0.2f
// Camera mouse movement sensitivity
-#define CAMERA_MOUSE_MOVE_SENSITIVITY 0.5f // TODO: it should be independant of framerate
+#define CAMERA_MOUSE_MOVE_SENSITIVITY 0.003f // TODO: it should be independant of framerate
#define CAMERA_MOUSE_SCROLL_SENSITIVITY 1.5f
-// FREE_CAMERA
-#define CAMERA_FREE_MOUSE_SENSITIVITY 0.01f
-#define CAMERA_FREE_DISTANCE_MIN_CLAMP 0.3f
-#define CAMERA_FREE_DISTANCE_MAX_CLAMP 120.0f
-#define CAMERA_FREE_MIN_CLAMP 85.0f
-#define CAMERA_FREE_MAX_CLAMP -85.0f
-#define CAMERA_FREE_SMOOTH_ZOOM_SENSITIVITY 0.05f
-#define CAMERA_FREE_PANNING_DIVIDER 5.1f
-
-// ORBITAL_CAMERA
#define CAMERA_ORBITAL_SPEED 0.5f // Radians per second
-// FIRST_PERSON
-//#define CAMERA_FIRST_PERSON_MOUSE_SENSITIVITY 0.003f
-#define CAMERA_FIRST_PERSON_FOCUS_DISTANCE 25.0f
-#define CAMERA_FIRST_PERSON_MIN_CLAMP 89.0f
-#define CAMERA_FIRST_PERSON_MAX_CLAMP -89.0f
-// When walking, y-position of the player moves up-down at step frequency (swinging) but
-// also the body slightly tilts left-right on every step, when all the body weight is left over one foot (tilting)
-#define CAMERA_FIRST_PERSON_STEP_FREQUENCY 1.8f // Step frequency when walking (steps per second)
-#define CAMERA_FIRST_PERSON_SWINGING_DELTA 0.03f // Maximum up-down swinging distance when walking
-#define CAMERA_FIRST_PERSON_TILTING_DELTA 0.005f // Maximum left-right tilting distance when walking
-
-// THIRD_PERSON
-//#define CAMERA_THIRD_PERSON_MOUSE_SENSITIVITY 0.003f
-#define CAMERA_THIRD_PERSON_DISTANCE_CLAMP 1.2f
-#define CAMERA_THIRD_PERSON_MIN_CLAMP 5.0f
-#define CAMERA_THIRD_PERSON_MAX_CLAMP -85.0f
-#define CAMERA_THIRD_PERSON_OFFSET (Vector3){ 0.4f, 0.0f, 0.0f }
+#define CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER 8.0f
+#define CAMERA_FIRST_PERSON_STEP_DIVIDER 30.0f
+#define CAMERA_FIRST_PERSON_WAVING_DIVIDER 200.0f
// PLAYER (used by camera)
-#define PLAYER_MOVEMENT_SENSITIVITY 2.0f
+#define PLAYER_MOVEMENT_SENSITIVITY 20.0f
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
-// Camera move modes (first person and third person cameras)
-typedef enum {
- MOVE_FRONT = 0,
- MOVE_BACK,
- MOVE_RIGHT,
- MOVE_LEFT,
- MOVE_UP,
- MOVE_DOWN
-} CameraMove;
-
-// Camera global state context data [56 bytes]
-typedef struct {
- unsigned int mode; // Current camera mode
- float targetDistance; // Camera distance from position to target
- float playerEyesPosition; // Player eyes position from ground (in meters)
- Vector2 angle; // Camera angle in plane XZ
-
- // Camera movement control keys
- int moveControl[6]; // Move controls (CAMERA_FIRST_PERSON)
- int smoothZoomControl; // Smooth zoom control key
- int altControl; // Alternative control key
- int panControl; // Pan view control key
-} CameraData;
+//...
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
-static CameraData CAMERA = { // Global CAMERA state context
- .mode = 0,
- .targetDistance = 0,
- .playerEyesPosition = 1.85f,
- .angle = { 0 },
- .moveControl = { 'W', 'S', 'D', 'A', 'E', 'Q' },
- .smoothZoomControl = 341, // raylib: KEY_LEFT_CONTROL
- .altControl = 342, // raylib: KEY_LEFT_ALT
- .panControl = 2 // raylib: MOUSE_BUTTON_MIDDLE
-};
+//...
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
//----------------------------------------------------------------------------------
-#if defined(CAMERA_STANDALONE)
-// NOTE: Camera controls depend on some raylib input functions
-static void EnableCursor() {} // Unlock cursor
-static void DisableCursor() {} // Lock cursor
-
-static int IsKeyDown(int key) { return 0; }
-
-static int IsMouseButtonDown(int button) { return 0;}
-static float GetMouseWheelMove() { return 0.0f; }
-static Vector2 GetMousePosition() { return (Vector2){ 0.0f, 0.0f }; }
-#endif
+//...
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
-
-// Select camera mode (multiple camera modes available)
-void SetCameraMode(Camera camera, int mode)
+// Returns the cameras forward vector (normalized)
+Vector3 GetCameraForward(Camera *camera)
{
- Vector3 v1 = camera.position;
- Vector3 v2 = camera.target;
-
- float dx = v2.x - v1.x;
- float dy = v2.y - v1.y;
- float dz = v2.z - v1.z;
-
- CAMERA.targetDistance = sqrtf(dx*dx + dy*dy + dz*dz); // Distance to target
-
- // Camera angle calculation
- CAMERA.angle.x = atan2f(dx, dz); // Camera angle in plane XZ (0 aligned with Z, move positive CCW)
- CAMERA.angle.y = atan2f(dy, sqrtf(dx*dx + dz*dz)); // Camera angle in plane XY (0 aligned with X, move positive CW)
-
- CAMERA.playerEyesPosition = camera.position.y; // Init player eyes position to camera Y position
-
- // Lock cursor for first person and third person cameras
- if ((mode == CAMERA_FIRST_PERSON) || (mode == CAMERA_THIRD_PERSON)) DisableCursor();
- else EnableCursor();
-
- CAMERA.mode = mode;
+ return Vector3Normalize(Vector3Subtract(camera->target, camera->position));
}
-// Update camera depending on selected mode
-// NOTE: Camera controls depend on some raylib functions:
-// System: EnableCursor(), DisableCursor()
-// Mouse: IsMouseButtonDown(), GetMousePosition(), GetMouseWheelMove()
-// Keys: IsKeyDown()
-void UpdateCamera(Camera *camera)
+// Returns the cameras up vector (normalized)
+// Note: The up vector might not be perpendicular to the forward vector
+Vector3 GetCameraUp(Camera *camera)
{
- static float swingCounter = 0.0f; // Used for 1st person swinging movement
+ return Vector3Normalize(camera->up);
+}
- // TODO: Compute CAMERA.targetDistance and CAMERA.angle here (?)
+// Returns the cameras right vector (normalized)
+Vector3 GetCameraRight(Camera *camera)
+{
+ Vector3 forward = GetCameraForward(camera);
+ Vector3 up = GetCameraUp(camera);
- // Mouse movement detection
- Vector2 mousePositionDelta = GetMouseDelta();
- float mouseWheelMove = GetMouseWheelMove();
+ return Vector3CrossProduct(forward, up);
+}
- // Keys input detection
- // TODO: Input detection is raylib-dependant, it could be moved outside the module
- bool keyPan = IsMouseButtonDown(CAMERA.panControl);
- bool keyAlt = IsKeyDown(CAMERA.altControl);
- bool szoomKey = IsKeyDown(CAMERA.smoothZoomControl);
- bool direction[6] = { IsKeyDown(CAMERA.moveControl[MOVE_FRONT]),
- IsKeyDown(CAMERA.moveControl[MOVE_BACK]),
- IsKeyDown(CAMERA.moveControl[MOVE_RIGHT]),
- IsKeyDown(CAMERA.moveControl[MOVE_LEFT]),
- IsKeyDown(CAMERA.moveControl[MOVE_UP]),
- IsKeyDown(CAMERA.moveControl[MOVE_DOWN]) };
+// Moves the camera in its forward direction
+void CameraMoveForward(Camera *camera, float distance, bool moveInWorldPlane)
+{
+ Vector3 forward = GetCameraForward(camera);
- // Support for multiple automatic camera modes
- // NOTE: In case of CAMERA_CUSTOM nothing happens here, user must update it manually
- switch (CAMERA.mode)
+ if (moveInWorldPlane)
{
- case CAMERA_FREE: // Camera free controls, using standard 3d-content-creation scheme
- {
- // Camera zoom
- if ((CAMERA.targetDistance < CAMERA_FREE_DISTANCE_MAX_CLAMP) && (mouseWheelMove < 0))
- {
- CAMERA.targetDistance -= (mouseWheelMove*CAMERA_MOUSE_SCROLL_SENSITIVITY);
- if (CAMERA.targetDistance > CAMERA_FREE_DISTANCE_MAX_CLAMP) CAMERA.targetDistance = CAMERA_FREE_DISTANCE_MAX_CLAMP;
- }
+ // Project vector onto world plane
+ forward.y = 0;
+ forward = Vector3Normalize(forward);
+ }
- // Camera looking down
- else if ((camera->position.y > camera->target.y) && (CAMERA.targetDistance == CAMERA_FREE_DISTANCE_MAX_CLAMP) && (mouseWheelMove < 0))
- {
- camera->target.x += mouseWheelMove*(camera->target.x - camera->position.x)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
- camera->target.y += mouseWheelMove*(camera->target.y - camera->position.y)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
- camera->target.z += mouseWheelMove*(camera->target.z - camera->position.z)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
- }
- else if ((camera->position.y > camera->target.y) && (camera->target.y >= 0))
- {
- camera->target.x += mouseWheelMove*(camera->target.x - camera->position.x)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
- camera->target.y += mouseWheelMove*(camera->target.y - camera->position.y)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
- camera->target.z += mouseWheelMove*(camera->target.z - camera->position.z)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
+ // Scale by distance
+ forward = Vector3Scale(forward, distance);
- // if (camera->target.y < 0) camera->target.y = -0.001;
- }
- else if ((camera->position.y > camera->target.y) && (camera->target.y < 0) && (mouseWheelMove > 0))
- {
- CAMERA.targetDistance -= (mouseWheelMove*CAMERA_MOUSE_SCROLL_SENSITIVITY);
- if (CAMERA.targetDistance < CAMERA_FREE_DISTANCE_MIN_CLAMP) CAMERA.targetDistance = CAMERA_FREE_DISTANCE_MIN_CLAMP;
- }
- // Camera looking up
- else if ((camera->position.y < camera->target.y) && (CAMERA.targetDistance == CAMERA_FREE_DISTANCE_MAX_CLAMP) && (mouseWheelMove < 0))
- {
- camera->target.x += mouseWheelMove*(camera->target.x - camera->position.x)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
- camera->target.y += mouseWheelMove*(camera->target.y - camera->position.y)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
- camera->target.z += mouseWheelMove*(camera->target.z - camera->position.z)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
- }
- else if ((camera->position.y < camera->target.y) && (camera->target.y <= 0))
- {
- camera->target.x += mouseWheelMove*(camera->target.x - camera->position.x)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
- camera->target.y += mouseWheelMove*(camera->target.y - camera->position.y)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
- camera->target.z += mouseWheelMove*(camera->target.z - camera->position.z)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
+ // Move position and target
+ camera->position = Vector3Add(camera->position, forward);
+ camera->target = Vector3Add(camera->target, forward);
+}
- // if (camera->target.y > 0) camera->target.y = 0.001;
- }
- else if ((camera->position.y < camera->target.y) && (camera->target.y > 0) && (mouseWheelMove > 0))
- {
- CAMERA.targetDistance -= (mouseWheelMove*CAMERA_MOUSE_SCROLL_SENSITIVITY);
- if (CAMERA.targetDistance < CAMERA_FREE_DISTANCE_MIN_CLAMP) CAMERA.targetDistance = CAMERA_FREE_DISTANCE_MIN_CLAMP;
- }
+// Moves the camera in its up direction
+void CameraMoveUp(Camera *camera, float distance)
+{
+ Vector3 up = GetCameraUp(camera);
- // Input keys checks
- if (keyPan)
- {
- if (keyAlt) // Alternative key behaviour
- {
- if (szoomKey)
- {
- // Camera smooth zoom
- CAMERA.targetDistance += (mousePositionDelta.y*CAMERA_FREE_SMOOTH_ZOOM_SENSITIVITY);
- }
- else
- {
- // Camera rotation
- CAMERA.angle.x += mousePositionDelta.x*-CAMERA_FREE_MOUSE_SENSITIVITY;
- CAMERA.angle.y += mousePositionDelta.y*-CAMERA_FREE_MOUSE_SENSITIVITY;
+ // Scale by distance
+ up = Vector3Scale(up, distance);
- // Angle clamp
- if (CAMERA.angle.y > CAMERA_FREE_MIN_CLAMP*DEG2RAD) CAMERA.angle.y = CAMERA_FREE_MIN_CLAMP*DEG2RAD;
- else if (CAMERA.angle.y < CAMERA_FREE_MAX_CLAMP*DEG2RAD) CAMERA.angle.y = CAMERA_FREE_MAX_CLAMP*DEG2RAD;
- }
- }
- else
- {
- // Camera panning
- camera->target.x += ((mousePositionDelta.x*CAMERA_FREE_MOUSE_SENSITIVITY)*cosf(CAMERA.angle.x) + (mousePositionDelta.y*-CAMERA_FREE_MOUSE_SENSITIVITY)*sinf(CAMERA.angle.x)*sinf(CAMERA.angle.y))*(CAMERA.targetDistance/CAMERA_FREE_PANNING_DIVIDER);
- camera->target.y += ((mousePositionDelta.y*CAMERA_FREE_MOUSE_SENSITIVITY)*cosf(CAMERA.angle.y))*(CAMERA.targetDistance/CAMERA_FREE_PANNING_DIVIDER);
- camera->target.z += ((mousePositionDelta.x*-CAMERA_FREE_MOUSE_SENSITIVITY)*sinf(CAMERA.angle.x) + (mousePositionDelta.y*-CAMERA_FREE_MOUSE_SENSITIVITY)*cosf(CAMERA.angle.x)*sinf(CAMERA.angle.y))*(CAMERA.targetDistance/CAMERA_FREE_PANNING_DIVIDER);
- }
- }
+ // Move position and target
+ camera->position = Vector3Add(camera->position, up);
+ camera->target = Vector3Add(camera->target, up);
+}
- // Update camera position with changes
- camera->position.x = -sinf(CAMERA.angle.x)*CAMERA.targetDistance*cosf(CAMERA.angle.y) + camera->target.x;
- camera->position.y = -sinf(CAMERA.angle.y)*CAMERA.targetDistance + camera->target.y;
- camera->position.z = -cosf(CAMERA.angle.x)*CAMERA.targetDistance*cosf(CAMERA.angle.y) + camera->target.z;
+// Moves the camera target in its current right direction
+void CameraMoveRight(Camera *camera, float distance, bool moveInWorldPlane)
+{
+ Vector3 right = GetCameraRight(camera);
- } break;
- case CAMERA_ORBITAL: // Camera just orbits around target, only zoom allowed
- {
- CAMERA.angle.x += CAMERA_ORBITAL_SPEED*GetFrameTime(); // Camera orbit angle
- CAMERA.targetDistance -= (mouseWheelMove*CAMERA_MOUSE_SCROLL_SENSITIVITY); // Camera zoom
+ if (moveInWorldPlane)
+ {
+ // Project vector onto world plane
+ right.y = 0;
+ right = Vector3Normalize(right);
+ }
- // Camera distance clamp
- if (CAMERA.targetDistance < CAMERA_THIRD_PERSON_DISTANCE_CLAMP) CAMERA.targetDistance = CAMERA_THIRD_PERSON_DISTANCE_CLAMP;
+ // Scale by distance
+ right = Vector3Scale(right, distance);
- // Update camera position with changes
- camera->position.x = sinf(CAMERA.angle.x)*CAMERA.targetDistance*cosf(CAMERA.angle.y) + camera->target.x;
- camera->position.y = ((CAMERA.angle.y <= 0.0f)? 1 : -1)*sinf(CAMERA.angle.y)*CAMERA.targetDistance*sinf(CAMERA.angle.y) + camera->target.y;
- camera->position.z = cosf(CAMERA.angle.x)*CAMERA.targetDistance*cosf(CAMERA.angle.y) + camera->target.z;
+ // Move position and target
+ camera->position = Vector3Add(camera->position, right);
+ camera->target = Vector3Add(camera->target, right);
+}
- } break;
- case CAMERA_FIRST_PERSON: // Camera moves as in a first-person game, controls are configurable
- {
- camera->position.x += (sinf(CAMERA.angle.x)*direction[MOVE_BACK] -
- sinf(CAMERA.angle.x)*direction[MOVE_FRONT] -
- cosf(CAMERA.angle.x)*direction[MOVE_LEFT] +
- cosf(CAMERA.angle.x)*direction[MOVE_RIGHT])*PLAYER_MOVEMENT_SENSITIVITY*GetFrameTime();
+// Moves the camera position closer/farther to/from the camera target
+void CameraMoveToTarget(Camera *camera, float delta)
+{
+ float distance = Vector3Distance(camera->position, camera->target);
- camera->position.y += (sinf(CAMERA.angle.y)*direction[MOVE_FRONT] -
- sinf(CAMERA.angle.y)*direction[MOVE_BACK] +
- 1.0f*direction[MOVE_UP] - 1.0f*direction[MOVE_DOWN])*PLAYER_MOVEMENT_SENSITIVITY*GetFrameTime();
+ // Apply delta
+ distance += delta;
- camera->position.z += (cosf(CAMERA.angle.x)*direction[MOVE_BACK] -
- cosf(CAMERA.angle.x)*direction[MOVE_FRONT] +
- sinf(CAMERA.angle.x)*direction[MOVE_LEFT] -
- sinf(CAMERA.angle.x)*direction[MOVE_RIGHT])*PLAYER_MOVEMENT_SENSITIVITY*GetFrameTime();
+ // Distance must be greater than 0
+ if (distance <= 0) distance = 0.001f;
- // Camera orientation calculation
- CAMERA.angle.x -= mousePositionDelta.x*CAMERA_MOUSE_MOVE_SENSITIVITY*GetFrameTime();
- CAMERA.angle.y -= mousePositionDelta.y*CAMERA_MOUSE_MOVE_SENSITIVITY*GetFrameTime();
+ // Set new distance by moving the position along the forward vector
+ Vector3 forward = GetCameraForward(camera);
+ camera->position = Vector3Add(camera->target, Vector3Scale(forward, -distance));
+}
- // Angle clamp
- if (CAMERA.angle.y > CAMERA_FIRST_PERSON_MIN_CLAMP*DEG2RAD) CAMERA.angle.y = CAMERA_FIRST_PERSON_MIN_CLAMP*DEG2RAD;
- else if (CAMERA.angle.y < CAMERA_FIRST_PERSON_MAX_CLAMP*DEG2RAD) CAMERA.angle.y = CAMERA_FIRST_PERSON_MAX_CLAMP*DEG2RAD;
+// Rotates the camera around its up vector
+// Yaw is "looking left and right"
+// If rotateAroundTarget is false, the camera rotates around its position
+// Note: angle must be provided in radians
+void CameraYaw(Camera *camera, float angle, bool rotateAroundTarget)
+{
+ // Rotation axis
+ Vector3 up = GetCameraUp(camera);
- // Calculate translation matrix
- Matrix matTranslation = { 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, (CAMERA.targetDistance/CAMERA_FREE_PANNING_DIVIDER),
- 0.0f, 0.0f, 0.0f, 1.0f };
+ // View vector
+ Vector3 targetPosition = Vector3Subtract(camera->target, camera->position);
- // Calculate rotation matrix
- Matrix matRotation = { 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f };
+ // Rotate view vector around up axis
+ targetPosition = Vector3RotateByAxisAngle(targetPosition, up, angle);
- float cosz = cosf(0.0f);
- float sinz = sinf(0.0f);
- float cosy = cosf(-(PI*2 - CAMERA.angle.x));
- float siny = sinf(-(PI*2 - CAMERA.angle.x));
- float cosx = cosf(-(PI*2 - CAMERA.angle.y));
- float sinx = sinf(-(PI*2 - CAMERA.angle.y));
-
- matRotation.m0 = cosz*cosy;
- matRotation.m4 = (cosz*siny*sinx) - (sinz*cosx);
- matRotation.m8 = (cosz*siny*cosx) + (sinz*sinx);
- matRotation.m1 = sinz*cosy;
- matRotation.m5 = (sinz*siny*sinx) + (cosz*cosx);
- matRotation.m9 = (sinz*siny*cosx) - (cosz*sinx);
- matRotation.m2 = -siny;
- matRotation.m6 = cosy*sinx;
- matRotation.m10= cosy*cosx;
-
- // Multiply translation and rotation matrices
- Matrix matTransform = { 0 };
- matTransform.m0 = matTranslation.m0*matRotation.m0 + matTranslation.m1*matRotation.m4 + matTranslation.m2*matRotation.m8 + matTranslation.m3*matRotation.m12;
- matTransform.m1 = matTranslation.m0*matRotation.m1 + matTranslation.m1*matRotation.m5 + matTranslation.m2*matRotation.m9 + matTranslation.m3*matRotation.m13;
- matTransform.m2 = matTranslation.m0*matRotation.m2 + matTranslation.m1*matRotation.m6 + matTranslation.m2*matRotation.m10 + matTranslation.m3*matRotation.m14;
- matTransform.m3 = matTranslation.m0*matRotation.m3 + matTranslation.m1*matRotation.m7 + matTranslation.m2*matRotation.m11 + matTranslation.m3*matRotation.m15;
- matTransform.m4 = matTranslation.m4*matRotation.m0 + matTranslation.m5*matRotation.m4 + matTranslation.m6*matRotation.m8 + matTranslation.m7*matRotation.m12;
- matTransform.m5 = matTranslation.m4*matRotation.m1 + matTranslation.m5*matRotation.m5 + matTranslation.m6*matRotation.m9 + matTranslation.m7*matRotation.m13;
- matTransform.m6 = matTranslation.m4*matRotation.m2 + matTranslation.m5*matRotation.m6 + matTranslation.m6*matRotation.m10 + matTranslation.m7*matRotation.m14;
- matTransform.m7 = matTranslation.m4*matRotation.m3 + matTranslation.m5*matRotation.m7 + matTranslation.m6*matRotation.m11 + matTranslation.m7*matRotation.m15;
- matTransform.m8 = matTranslation.m8*matRotation.m0 + matTranslation.m9*matRotation.m4 + matTranslation.m10*matRotation.m8 + matTranslation.m11*matRotation.m12;
- matTransform.m9 = matTranslation.m8*matRotation.m1 + matTranslation.m9*matRotation.m5 + matTranslation.m10*matRotation.m9 + matTranslation.m11*matRotation.m13;
- matTransform.m10 = matTranslation.m8*matRotation.m2 + matTranslation.m9*matRotation.m6 + matTranslation.m10*matRotation.m10 + matTranslation.m11*matRotation.m14;
- matTransform.m11 = matTranslation.m8*matRotation.m3 + matTranslation.m9*matRotation.m7 + matTranslation.m10*matRotation.m11 + matTranslation.m11*matRotation.m15;
- matTransform.m12 = matTranslation.m12*matRotation.m0 + matTranslation.m13*matRotation.m4 + matTranslation.m14*matRotation.m8 + matTranslation.m15*matRotation.m12;
- matTransform.m13 = matTranslation.m12*matRotation.m1 + matTranslation.m13*matRotation.m5 + matTranslation.m14*matRotation.m9 + matTranslation.m15*matRotation.m13;
- matTransform.m14 = matTranslation.m12*matRotation.m2 + matTranslation.m13*matRotation.m6 + matTranslation.m14*matRotation.m10 + matTranslation.m15*matRotation.m14;
- matTransform.m15 = matTranslation.m12*matRotation.m3 + matTranslation.m13*matRotation.m7 + matTranslation.m14*matRotation.m11 + matTranslation.m15*matRotation.m15;
-
- camera->target.x = camera->position.x - matTransform.m12;
- camera->target.y = camera->position.y - matTransform.m13;
- camera->target.z = camera->position.z - matTransform.m14;
-
- // Camera position update
- // NOTE: On CAMERA_FIRST_PERSON player Y-movement is limited to player 'eyes position'
- camera->position.y = CAMERA.playerEyesPosition;
-
- // Camera swinging (y-movement), only when walking (some key pressed)
- for (int i = 0; i < 6; i++) if (direction[i]) { swingCounter += GetFrameTime(); break; }
- camera->position.y -= sinf(2*PI*CAMERA_FIRST_PERSON_STEP_FREQUENCY*swingCounter)*CAMERA_FIRST_PERSON_SWINGING_DELTA;
-
- // Camera waiving (xz-movement), only when walking (some key pressed)
- camera->up.x = sinf(2*PI*CAMERA_FIRST_PERSON_STEP_FREQUENCY*swingCounter)*CAMERA_FIRST_PERSON_TILTING_DELTA;
- camera->up.z = -sinf(2*PI*CAMERA_FIRST_PERSON_STEP_FREQUENCY*swingCounter)*CAMERA_FIRST_PERSON_TILTING_DELTA;
-
- } break;
- case CAMERA_THIRD_PERSON: // Camera moves as in a third-person game, following target at a distance, controls are configurable
- {
- camera->position.x += (sinf(CAMERA.angle.x)*direction[MOVE_BACK] -
- sinf(CAMERA.angle.x)*direction[MOVE_FRONT] -
- cosf(CAMERA.angle.x)*direction[MOVE_LEFT] +
- cosf(CAMERA.angle.x)*direction[MOVE_RIGHT])*PLAYER_MOVEMENT_SENSITIVITY*GetFrameTime();
-
- camera->position.y += (sinf(CAMERA.angle.y)*direction[MOVE_FRONT] -
- sinf(CAMERA.angle.y)*direction[MOVE_BACK] +
- 1.0f*direction[MOVE_UP] - 1.0f*direction[MOVE_DOWN])*PLAYER_MOVEMENT_SENSITIVITY*GetFrameTime();
-
- camera->position.z += (cosf(CAMERA.angle.x)*direction[MOVE_BACK] -
- cosf(CAMERA.angle.x)*direction[MOVE_FRONT] +
- sinf(CAMERA.angle.x)*direction[MOVE_LEFT] -
- sinf(CAMERA.angle.x)*direction[MOVE_RIGHT])*PLAYER_MOVEMENT_SENSITIVITY*GetFrameTime();
-
- // Camera orientation calculation
- CAMERA.angle.x += (mousePositionDelta.x*-CAMERA_MOUSE_MOVE_SENSITIVITY);
- CAMERA.angle.y += (mousePositionDelta.y*-CAMERA_MOUSE_MOVE_SENSITIVITY);
-
- // Angle clamp
- if (CAMERA.angle.y > CAMERA_THIRD_PERSON_MIN_CLAMP*DEG2RAD) CAMERA.angle.y = CAMERA_THIRD_PERSON_MIN_CLAMP*DEG2RAD;
- else if (CAMERA.angle.y < CAMERA_THIRD_PERSON_MAX_CLAMP*DEG2RAD) CAMERA.angle.y = CAMERA_THIRD_PERSON_MAX_CLAMP*DEG2RAD;
-
- // Camera zoom
- CAMERA.targetDistance -= (mouseWheelMove*CAMERA_MOUSE_SCROLL_SENSITIVITY);
-
- // Camera distance clamp
- if (CAMERA.targetDistance < CAMERA_THIRD_PERSON_DISTANCE_CLAMP) CAMERA.targetDistance = CAMERA_THIRD_PERSON_DISTANCE_CLAMP;
-
- camera->position.x = sinf(CAMERA.angle.x)*CAMERA.targetDistance*cosf(CAMERA.angle.y) + camera->target.x;
-
- if (CAMERA.angle.y <= 0.0f) camera->position.y = sinf(CAMERA.angle.y)*CAMERA.targetDistance*sinf(CAMERA.angle.y) + camera->target.y;
- else camera->position.y = -sinf(CAMERA.angle.y)*CAMERA.targetDistance*sinf(CAMERA.angle.y) + camera->target.y;
-
- camera->position.z = cosf(CAMERA.angle.x)*CAMERA.targetDistance*cosf(CAMERA.angle.y) + camera->target.z;
-
- } break;
- case CAMERA_CUSTOM: break;
- default: break;
+ if (rotateAroundTarget)
+ {
+ // Move position relative to target
+ camera->position = Vector3Subtract(camera->target, targetPosition);
+ }
+ else // rotate around camera.position
+ {
+ // Move target relative to position
+ camera->target = Vector3Add(camera->position, targetPosition);
}
}
-// Set camera pan key to combine with mouse movement (free camera)
-void SetCameraPanControl(int keyPan) { CAMERA.panControl = keyPan; }
-
-// Set camera alt key to combine with mouse movement (free camera)
-void SetCameraAltControl(int keyAlt) { CAMERA.altControl = keyAlt; }
-
-// Set camera smooth zoom key to combine with mouse (free camera)
-void SetCameraSmoothZoomControl(int szoomKey) { CAMERA.smoothZoomControl = szoomKey; }
-
-// Set camera move controls (1st person and 3rd person cameras)
-void SetCameraMoveControls(int keyFront, int keyBack, int keyRight, int keyLeft, int keyUp, int keyDown)
+// Rotates the camera around its right vector, pitch is "looking up and down"
+// - lockView prevents camera overrotation (aka "somersaults")
+// - rotateAroundTarget defines if rotation is around target or around its position
+// - rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE)
+// NOTE: angle must be provided in radians
+void CameraPitch(Camera *camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp)
{
- CAMERA.moveControl[MOVE_FRONT] = keyFront;
- CAMERA.moveControl[MOVE_BACK] = keyBack;
- CAMERA.moveControl[MOVE_RIGHT] = keyRight;
- CAMERA.moveControl[MOVE_LEFT] = keyLeft;
- CAMERA.moveControl[MOVE_UP] = keyUp;
- CAMERA.moveControl[MOVE_DOWN] = keyDown;
+ // Up direction
+ Vector3 up = GetCameraUp(camera);
+
+ // View vector
+ Vector3 targetPosition = Vector3Subtract(camera->target, camera->position);
+
+ if (lockView)
+ {
+ // In these camera modes we clamp the Pitch angle
+ // to allow only viewing straight up or down.
+
+ // Clamp view up
+ float maxAngleUp = Vector3Angle(up, targetPosition);
+ maxAngleUp -= 0.001f; // avoid numerical errors
+ if (angle > maxAngleUp) angle = maxAngleUp;
+
+ // Clamp view down
+ float maxAngleDown = Vector3Angle(Vector3Negate(up), targetPosition);
+ maxAngleDown *= -1.0f; // downwards angle is negative
+ maxAngleDown += 0.001f; // avoid numerical errors
+ if (angle < maxAngleDown) angle = maxAngleDown;
+ }
+
+ // Rotation axis
+ Vector3 right = GetCameraRight(camera);
+
+ // Rotate view vector around right axis
+ targetPosition = Vector3RotateByAxisAngle(targetPosition, right, angle);
+
+ if (rotateAroundTarget)
+ {
+ // Move position relative to target
+ camera->position = Vector3Subtract(camera->target, targetPosition);
+ }
+ else // rotate around camera.position
+ {
+ // Move target relative to position
+ camera->target = Vector3Add(camera->position, targetPosition);
+ }
+
+ if (rotateUp)
+ {
+ // Rotate up direction around right axis
+ camera->up = Vector3RotateByAxisAngle(camera->up, right, angle);
+ }
}
-#endif // CAMERA_IMPLEMENTATION
+// Rotates the camera around its forward vector
+// Roll is "turning your head sideways to the left or right"
+// Note: angle must be provided in radians
+void CameraRoll(Camera *camera, float angle)
+{
+ // Rotation axis
+ Vector3 forward = GetCameraForward(camera);
+
+ // Rotate up direction around forward axis
+ camera->up = Vector3RotateByAxisAngle(camera->up, forward, angle);
+}
+
+// Returns the camera view matrix
+Matrix GetCameraViewMatrix(Camera *camera)
+{
+ return MatrixLookAt(camera->position, camera->target, camera->up);
+}
+
+// Returns the camera projection matrix
+Matrix GetCameraProjectionMatrix(Camera *camera, float aspect)
+{
+ if (camera->projection == CAMERA_PERSPECTIVE)
+ {
+ return MatrixPerspective(camera->fovy*DEG2RAD, aspect, CAMERA_CULL_DISTANCE_NEAR, CAMERA_CULL_DISTANCE_FAR);
+ }
+ else if (camera->projection == CAMERA_ORTHOGRAPHIC)
+ {
+ double top = camera->fovy/2.0;
+ double right = top*aspect;
+
+ return MatrixOrtho(-right, right, -top, top, CAMERA_CULL_DISTANCE_NEAR, CAMERA_CULL_DISTANCE_FAR);
+ }
+
+ return MatrixIdentity();
+}
+
+#if !defined(RCAMERA_STANDALONE)
+// Update camera position for selected mode
+// Camera mode: CAMERA_FREE, CAMERA_FIRST_PERSON, CAMERA_THIRD_PERSON, CAMERA_ORBITAL or CUSTOM
+void UpdateCamera(Camera *camera, int mode)
+{
+ Vector2 mousePositionDelta = GetMouseDelta();
+
+ bool moveInWorldPlane = ((mode == CAMERA_FIRST_PERSON) || (mode == CAMERA_THIRD_PERSON));
+ bool rotateAroundTarget = ((mode == CAMERA_THIRD_PERSON) || (mode == CAMERA_ORBITAL));
+ bool lockView = ((mode == CAMERA_FIRST_PERSON) || (mode == CAMERA_THIRD_PERSON) || (mode == CAMERA_ORBITAL));
+ bool rotateUp = false;
+
+ if (mode == CAMERA_ORBITAL)
+ {
+ // Orbital can just orbit
+ Matrix rotation = MatrixRotate(GetCameraUp(camera), CAMERA_ORBITAL_SPEED*GetFrameTime());
+ Vector3 view = Vector3Subtract(camera->position, camera->target);
+ view = Vector3Transform(view, rotation);
+ camera->position = Vector3Add(camera->target, view);
+ }
+ else
+ {
+ // Camera rotation
+ if (IsKeyDown(KEY_DOWN)) CameraPitch(camera, -CAMERA_ROTATION_SPEED, lockView, rotateAroundTarget, rotateUp);
+ if (IsKeyDown(KEY_UP)) CameraPitch(camera, CAMERA_ROTATION_SPEED, lockView, rotateAroundTarget, rotateUp);
+ if (IsKeyDown(KEY_RIGHT)) CameraYaw(camera, -CAMERA_ROTATION_SPEED, rotateAroundTarget);
+ if (IsKeyDown(KEY_LEFT)) CameraYaw(camera, CAMERA_ROTATION_SPEED, rotateAroundTarget);
+ if (IsKeyDown(KEY_Q)) CameraRoll(camera, -CAMERA_ROTATION_SPEED);
+ if (IsKeyDown(KEY_E)) CameraRoll(camera, CAMERA_ROTATION_SPEED);
+
+ // Camera movement
+ if (!IsGamepadAvailable(0))
+ {
+ // Camera pan (for CAMERA_FREE)
+ if ((mode == CAMERA_FREE) && (IsMouseButtonDown(MOUSE_BUTTON_MIDDLE)))
+ {
+ const Vector2 mouseDelta = GetMouseDelta();
+ if (mouseDelta.x > 0.0f) CameraMoveRight(camera, CAMERA_PAN_SPEED, moveInWorldPlane);
+ if (mouseDelta.x < 0.0f) CameraMoveRight(camera, -CAMERA_PAN_SPEED, moveInWorldPlane);
+ if (mouseDelta.y > 0.0f) CameraMoveUp(camera, -CAMERA_PAN_SPEED);
+ if (mouseDelta.y < 0.0f) CameraMoveUp(camera, CAMERA_PAN_SPEED);
+ }
+ else
+ {
+ // Mouse support
+ CameraYaw(camera, -mousePositionDelta.x*CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget);
+ CameraPitch(camera, -mousePositionDelta.y*CAMERA_MOUSE_MOVE_SENSITIVITY, lockView, rotateAroundTarget, rotateUp);
+ }
+
+ // Keyboard support
+ if (IsKeyDown(KEY_W)) CameraMoveForward(camera, CAMERA_MOVE_SPEED, moveInWorldPlane);
+ if (IsKeyDown(KEY_A)) CameraMoveRight(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane);
+ if (IsKeyDown(KEY_S)) CameraMoveForward(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane);
+ if (IsKeyDown(KEY_D)) CameraMoveRight(camera, CAMERA_MOVE_SPEED, moveInWorldPlane);
+ }
+ else
+ {
+ // Gamepad controller support
+ CameraYaw(camera, -(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X) * 2)*CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget);
+ CameraPitch(camera, -(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y) * 2)*CAMERA_MOUSE_MOVE_SENSITIVITY, lockView, rotateAroundTarget, rotateUp);
+
+ if (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y) <= -0.25f) CameraMoveForward(camera, CAMERA_MOVE_SPEED, moveInWorldPlane);
+ if (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X) <= -0.25f) CameraMoveRight(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane);
+ if (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y) >= 0.25f) CameraMoveForward(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane);
+ if (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X) >= 0.25f) CameraMoveRight(camera, CAMERA_MOVE_SPEED, moveInWorldPlane);
+ }
+
+ if (mode == CAMERA_FREE)
+ {
+ if (IsKeyDown(KEY_SPACE)) CameraMoveUp(camera, CAMERA_MOVE_SPEED);
+ if (IsKeyDown(KEY_LEFT_CONTROL)) CameraMoveUp(camera, -CAMERA_MOVE_SPEED);
+ }
+ }
+
+ if ((mode == CAMERA_THIRD_PERSON) || (mode == CAMERA_ORBITAL) || (mode == CAMERA_FREE))
+ {
+ // Zoom target distance
+ CameraMoveToTarget(camera, -GetMouseWheelMove());
+ if (IsKeyPressed(KEY_KP_SUBTRACT)) CameraMoveToTarget(camera, 2.0f);
+ if (IsKeyPressed(KEY_KP_ADD)) CameraMoveToTarget(camera, -2.0f);
+ }
+}
+#endif // !RCAMERA_STANDALONE
+
+// Update camera movement, movement/rotation values should be provided by user
+void UpdateCameraPro(Camera *camera, Vector3 movement, Vector3 rotation, float zoom)
+{
+ // Required values
+ // movement.x - Move forward/backward
+ // movement.y - Move right/left
+ // movement.z - Move up/down
+ // rotation.x - yaw
+ // rotation.y - pitch
+ // rotation.z - roll
+ // zoom - Move towards target
+
+ bool lockView = true;
+ bool rotateAroundTarget = false;
+ bool rotateUp = false;
+ bool moveInWorldPlane = true;
+
+ // Camera rotation
+ CameraPitch(camera, -rotation.y*DEG2RAD, lockView, rotateAroundTarget, rotateUp);
+ CameraYaw(camera, -rotation.x*DEG2RAD, rotateAroundTarget);
+ CameraRoll(camera, rotation.z*DEG2RAD);
+
+ // Camera movement
+ CameraMoveForward(camera, movement.x, moveInWorldPlane);
+ CameraMoveRight(camera, movement.y, moveInWorldPlane);
+ CameraMoveUp(camera, movement.z);
+
+ // Zoom target distance
+ CameraMoveToTarget(camera, zoom);
+}
+
+#endif // RCAMERA_IMPLEMENTATION
diff --git a/src/rcore.c b/src/rcore.c
index d5823ad0b..2c53eb5e6 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -13,75 +13,75 @@
* - PLATFORM_WEB: HTML5 with WebAssembly
*
* CONFIGURATION:
+* #define PLATFORM_DESKTOP
+* Windowing and input system configured for desktop platforms:
+* Windows, Linux, OSX, FreeBSD, OpenBSD, NetBSD, DragonFly
*
-* #define PLATFORM_DESKTOP
-* Windowing and input system configured for desktop platforms: Windows, Linux, OSX, FreeBSD, OpenBSD, NetBSD, DragonFly
-* NOTE: Oculus Rift CV1 requires PLATFORM_DESKTOP for mirror rendering - View [rlgl] module to enable it
+* #define PLATFORM_ANDROID
+* Windowing and input system configured for Android device, app activity managed internally in this module.
+* NOTE: OpenGL ES 2.0 is required and graphic device is managed by EGL
*
-* #define PLATFORM_ANDROID
-* Windowing and input system configured for Android device, app activity managed internally in this module.
-* NOTE: OpenGL ES 2.0 is required and graphic device is managed by EGL
+* #define PLATFORM_RPI (deprecated - RPI OS Buster only)
+* Windowing and input system configured for Raspberry Pi in native mode (no XWindow required),
+* graphic device is managed by EGL and inputs are processed is raw mode, reading from /dev/input/
+* WARNING: This platform is deprecated, since RPI OS Bullseye, the old Dispmanx libraries are not
+* supported and you must be using PLATFORM_DRM
*
-* #define PLATFORM_RPI (deprecated - RPI OS Buster only)
-* Windowing and input system configured for Raspberry Pi in native mode (no XWindow required),
-* graphic device is managed by EGL and inputs are processed is raw mode, reading from /dev/input/
-* WARNING: This platform is deprecated, since RPI OS Bullseye, the old Dispmanx libraries are not
-* supported and you must be using PLATFORM_DRM
+* #define PLATFORM_DRM
+* Windowing and input system configured for DRM native mode (RPI4 and other devices)
+* graphic device is managed by EGL and inputs are processed is raw mode, reading from /dev/input/
*
-* #define PLATFORM_DRM
-* Windowing and input system configured for DRM native mode (RPI4 and other devices)
-* graphic device is managed by EGL and inputs are processed is raw mode, reading from /dev/input/
+* #define PLATFORM_WEB
+* Windowing and input system configured for HTML5 (run on browser), code converted from C to asm.js
+* using emscripten compiler. OpenGL ES 2.0 required for direct translation to WebGL equivalent code.
*
-* #define PLATFORM_WEB
-* Windowing and input system configured for HTML5 (run on browser), code converted from C to asm.js
-* using emscripten compiler. OpenGL ES 2.0 required for direct translation to WebGL equivalent code.
+* #define SUPPORT_DEFAULT_FONT (default)
+* Default font is loaded on window initialization to be available for the user to render simple text.
+* NOTE: If enabled, uses external module functions to load default raylib font (module: text)
*
-* #define SUPPORT_DEFAULT_FONT (default)
-* Default font is loaded on window initialization to be available for the user to render simple text.
-* NOTE: If enabled, uses external module functions to load default raylib font (module: text)
+* #define SUPPORT_CAMERA_SYSTEM
+* Camera module is included (rcamera.h) and multiple predefined cameras are available:
+* free, 1st/3rd person, orbital, custom
*
-* #define SUPPORT_CAMERA_SYSTEM
-* Camera module is included (rcamera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital
+* #define SUPPORT_GESTURES_SYSTEM
+* Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag
*
-* #define SUPPORT_GESTURES_SYSTEM
-* Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag
+* #define SUPPORT_MOUSE_GESTURES
+* Mouse gestures are directly mapped like touches and processed by gestures system.
*
-* #define SUPPORT_MOUSE_GESTURES
-* Mouse gestures are directly mapped like touches and processed by gestures system.
+* #define SUPPORT_TOUCH_AS_MOUSE
+* Touch input and mouse input are shared. Mouse functions also return touch information.
*
-* #define SUPPORT_TOUCH_AS_MOUSE
-* Touch input and mouse input are shared. Mouse functions also return touch information.
+* #define SUPPORT_SSH_KEYBOARD_RPI (Raspberry Pi only)
+* Reconfigure standard input to receive key inputs, works with SSH connection.
+* WARNING: Reconfiguring standard input could lead to undesired effects, like breaking other
+* running processes orblocking the device if not restored properly. Use with care.
*
-* #define SUPPORT_SSH_KEYBOARD_RPI (Raspberry Pi only)
-* Reconfigure standard input to receive key inputs, works with SSH connection.
-* WARNING: Reconfiguring standard input could lead to undesired effects, like breaking other running processes or
-* blocking the device if not restored properly. Use with care.
+* #define SUPPORT_BUSY_WAIT_LOOP
+* Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used
*
-* #define SUPPORT_BUSY_WAIT_LOOP
-* Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used
+* #define SUPPORT_PARTIALBUSY_WAIT_LOOP
+* Use a partial-busy wait loop, in this case frame sleeps for most of the time and runs a busy-wait-loop at the end
*
-* #define SUPPORT_PARTIALBUSY_WAIT_LOOP
-* Use a partial-busy wait loop, in this case frame sleeps for most of the time and runs a busy-wait-loop at the end
+* #define SUPPORT_EVENTS_WAITING
+* Wait for events passively (sleeping while no events) instead of polling them actively every frame
*
-* #define SUPPORT_EVENTS_WAITING
-* Wait for events passively (sleeping while no events) instead of polling them actively every frame
+* #define SUPPORT_SCREEN_CAPTURE
+* Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
*
-* #define SUPPORT_SCREEN_CAPTURE
-* Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
+* #define SUPPORT_GIF_RECORDING
+* Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
*
-* #define SUPPORT_GIF_RECORDING
-* Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
+* #define SUPPORT_COMPRESSION_API
+* Support CompressData() and DecompressData() functions, those functions use zlib implementation
+* provided by stb_image and stb_image_write libraries, so, those libraries must be enabled on textures module
+* for linkage
*
-* #define SUPPORT_COMPRESSION_API
-* Support CompressData() and DecompressData() functions, those functions use zlib implementation
-* provided by stb_image and stb_image_write libraries, so, those libraries must be enabled on textures module
-* for linkage
-*
-* #define SUPPORT_EVENTS_AUTOMATION
-* Support automatic generated events, loading and recording of those events when required
+* #define SUPPORT_EVENTS_AUTOMATION
+* Support automatic generated events, loading and recording of those events when required
*
* DEPENDENCIES:
-* rglfw - Manage graphic device, OpenGL context and inputs on PLATFORM_DESKTOP (Windows, Linux, OSX. FreeBSD, OpenBSD, NetBSD, DragonFly)
+* rglfw - Manage graphic device, OpenGL context and inputs on PLATFORM_DESKTOP (Windows, Linux, OSX, FreeBSD...)
* raymath - 3D math functionality (Vector2, Vector3, Matrix, Quaternion)
* camera - Multiple 3D camera modes (free, orbital, 1st person, 3rd person)
* gestures - Gestures system for touch-ready devices (or simulated from mouse inputs)
@@ -89,7 +89,7 @@
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -124,12 +124,12 @@
#include "raymath.h" // Vector3, Quaternion and Matrix functionality
#if defined(SUPPORT_GESTURES_SYSTEM)
- #define GESTURES_IMPLEMENTATION
+ #define RGESTURES_IMPLEMENTATION
#include "rgestures.h" // Gestures detection functionality
#endif
#if defined(SUPPORT_CAMERA_SYSTEM)
- #define CAMERA_IMPLEMENTATION
+ #define RCAMERA_IMPLEMENTATION
#include "rcamera.h" // Camera system functionality
#endif
@@ -151,10 +151,13 @@
#include "external/sdefl.h" // Deflate (RFC 1951) compressor
#endif
-#if (defined(__linux__) || defined(PLATFORM_WEB)) && _POSIX_C_SOURCE < 199309L
+#if (defined(__linux__) || defined(PLATFORM_WEB)) && (_POSIX_C_SOURCE < 199309L)
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext.
#endif
+#if defined(__linux__) && !defined(_GNU_SOURCE)
+ #define _GNU_SOURCE
+#endif
// Platform specific defines to handle GetApplicationDirectory()
#if defined (PLATFORM_DESKTOP)
@@ -239,6 +242,7 @@
#include // Required for: usleep()
//#define GLFW_EXPOSE_NATIVE_COCOA // WARNING: Fails due to type redefinition
+ void *glfwGetCocoaWindow(GLFWwindow* handle);
#include "GLFW/glfw3native.h" // Required for: glfwGetCocoaWindow()
#endif
@@ -287,6 +291,7 @@
#if defined(PLATFORM_WEB)
#define GLFW_INCLUDE_ES2 // GLFW3: Enable OpenGL ES 2.0 (translated to WebGL)
+ //#define GLFW_INCLUDE_ES3 // GLFW3: Enable OpenGL ES 3.0 (transalted to WebGL2?)
#include "GLFW/glfw3.h" // GLFW3: Windows, OpenGL context and Input management
#include // Required for: timespec, nanosleep(), select() - POSIX
@@ -407,6 +412,8 @@ typedef struct CoreData {
Size render; // Framebuffer width and height (render area, including black bars if required)
Point renderOffset; // Offset from render area (must be divided by 2)
Matrix screenScale; // Matrix to scale screen (framebuffer rendering)
+ Point previousPosition; // Previous screen position (required on borderless windowed toggle)
+ Size previousScreen; // Previous screen size (required on borderless windowed toggle)
char **dropFilepaths; // Store dropped files paths pointers (provided by GLFW)
unsigned int dropFileCount; // Count dropped files strings
@@ -431,6 +438,8 @@ typedef struct CoreData {
int exitKey; // Default exit key
char currentKeyState[MAX_KEYBOARD_KEYS]; // Registers current frame key state
char previousKeyState[MAX_KEYBOARD_KEYS]; // Registers previous frame key state
+ // NOTE: Since key press logic involves comparing prev vs cur key state, we need to handle key repeats specially
+ char keyRepeatInFrame[MAX_KEYBOARD_KEYS]; // Registers key repeats for current frame.
int keyPressedQueue[MAX_KEY_PRESSED_QUEUE]; // Input keys queue
int keyPressedQueueCount; // Input keys queue count
@@ -463,6 +472,7 @@ typedef struct CoreData {
Vector2 currentWheelMove; // Registers current mouse wheel variation
Vector2 previousWheelMove; // Registers previous mouse wheel variation
#if defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
+ Vector2 eventWheelMove; // Registers the event mouse wheel variation
// NOTE: currentButtonState[] can't be written directly due to multithreading, app could miss the update
char currentButtonStateEvdev[MAX_MOUSE_BUTTONS]; // Holds the new mouse state for the next polling event to grab
#endif
@@ -496,7 +506,7 @@ typedef struct CoreData {
double frame; // Time measure for one frame
double target; // Desired time for one frame, if 0 not applied
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
- unsigned long long base; // Base time measure for hi-res timer
+ unsigned long long int base; // Base time measure for hi-res timer
#endif
unsigned int frameCounter; // Frame counter
} Time;
@@ -591,14 +601,14 @@ static const char *autoEventTypeName[] = {
"ACTION_SETTARGETFPS"
};
-// Automation Event (20 bytes)
+// Automation Event (24 bytes)
typedef struct AutomationEvent {
unsigned int frame; // Event frame
- unsigned int type; // Event type (AutoEventType)
- int params[3]; // Event parameters (if required)
+ unsigned int type; // Event type (AutomationEventType)
+ int params[4]; // Event parameters (if required)
} AutomationEvent;
-static AutomationEvent *events = NULL; // Events array
+static AutomationEvent *events = NULL; // Events array
static unsigned int eventCount = 0; // Events count
static bool eventsPlaying = false; // Play events
static bool eventsRecording = false; // Record events
@@ -712,8 +722,24 @@ void android_main(struct android_app *app)
char arg0[] = "raylib"; // NOTE: argv[] are mutable
CORE.Android.app = app;
- // NOTE: Return codes != 0 are skipped
+ // NOTE: Return from main is ignored
(void)main(1, (char *[]) { arg0, NULL });
+
+ // Request to end the native activity
+ ANativeActivity_finish(app->activity);
+
+ // Android ALooper_pollAll() variables
+ int pollResult = 0;
+ int pollEvents = 0;
+
+ // Waiting for application events before complete finishing
+ while (!app->destroyRequested)
+ {
+ while ((pollResult = ALooper_pollAll(0, NULL, &pollEvents, (void **)&CORE.Android.source)) >= 0)
+ {
+ if (CORE.Android.source != NULL) CORE.Android.source->process(app, CORE.Android.source);
+ }
+ }
}
// NOTE: Add this to header (if apps really need it)
@@ -765,7 +791,7 @@ void InitWindow(int width, int height, const char *title)
CORE.Input.Keyboard.exitKey = KEY_ESCAPE;
CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f };
CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW;
- CORE.Input.Gamepad.lastButtonPressed = -1;
+ CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN
#if defined(SUPPORT_EVENTS_WAITING)
CORE.Window.eventWaiting = true;
#endif
@@ -845,6 +871,7 @@ void InitWindow(int width, int height, const char *title)
TRACELOG(LOG_FATAL, "Failed to initialize Graphic Device");
return;
}
+ else SetWindowPosition(GetMonitorWidth(GetCurrentMonitor())/2 - CORE.Window.screen.width/2, GetMonitorHeight(GetCurrentMonitor())/2 - CORE.Window.screen.height/2);
// Initialize hi-res timer
InitTimer();
@@ -861,7 +888,7 @@ void InitWindow(int width, int height, const char *title)
LoadFontDefault();
#if defined(SUPPORT_MODULE_RSHAPES)
Rectangle rec = GetFontDefault().recs[95];
- // NOTE: We setup a 1px padding on char rectangle to avoid pixel bleeding on MSAA filtering
+ // NOTE: We set up a 1px padding on char rectangle to avoid pixel bleeding on MSAA filtering
SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 1, rec.y + 1, rec.width - 2, rec.height - 2 }); // WARNING: Module required: rshapes
#endif
#else
@@ -890,7 +917,7 @@ void InitWindow(int width, int height, const char *title)
#endif
#if defined(PLATFORM_WEB)
- // Setup callback funtions for the DOM events
+ // Setup callback functions for the DOM events
emscripten_set_fullscreenchange_callback("#canvas", NULL, 1, EmscriptenFullscreenChangeCallback);
// WARNING: Below resize code was breaking fullscreen mode for sample games and examples, it needs review
@@ -919,11 +946,8 @@ void InitWindow(int width, int height, const char *title)
emscripten_set_gamepaddisconnected_callback(NULL, 1, EmscriptenGamepadCallback);
#endif
- CORE.Input.Mouse.currentPosition.x = (float)CORE.Window.screen.width/2.0f;
- CORE.Input.Mouse.currentPosition.y = (float)CORE.Window.screen.height/2.0f;
-
#if defined(SUPPORT_EVENTS_AUTOMATION)
- events = (AutomationEvent *)malloc(MAX_CODE_AUTOMATION_EVENTS*sizeof(AutomationEvent));
+ events = (AutomationEvent *)RL_CALLOC(MAX_CODE_AUTOMATION_EVENTS, sizeof(AutomationEvent));
CORE.Time.frameCounter = 0;
#endif
@@ -1071,7 +1095,7 @@ void CloseWindow(void)
#endif
#if defined(SUPPORT_EVENTS_AUTOMATION)
- free(events);
+ RL_FREE(events);
#endif
CORE.Window.ready = false;
@@ -1139,9 +1163,8 @@ bool IsWindowMinimized(void)
{
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
return ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0);
-#else
- return false;
#endif
+ return false;
}
// Check if window has been maximized (only PLATFORM_DESKTOP)
@@ -1149,9 +1172,8 @@ bool IsWindowMaximized(void)
{
#if defined(PLATFORM_DESKTOP)
return ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0);
-#else
- return false;
#endif
+ return false;
}
// Check if window has the focus
@@ -1159,9 +1181,11 @@ bool IsWindowFocused(void)
{
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
return ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) == 0);
-#else
- return true;
#endif
+#if defined(PLATFORM_ANDROID)
+ return CORE.Android.appEnabled;
+#endif
+ return true;
}
// Check if window has been resizedLastFrame
@@ -1298,6 +1322,82 @@ void ToggleFullscreen(void)
#endif
}
+// Toggle borderless windowed mode (only PLATFORM_DESKTOP)
+void ToggleBorderlessWindowed(void)
+{
+#if defined(PLATFORM_DESKTOP)
+ // Leave fullscreen before attempting to set borderless windowed mode and get screen position from it
+ bool wasOnFullscreen = false;
+ if (CORE.Window.fullscreen)
+ {
+ CORE.Window.previousPosition = CORE.Window.position;
+ ToggleFullscreen();
+ wasOnFullscreen = true;
+ }
+
+ const int monitor = GetCurrentMonitor();
+ int monitorCount;
+ GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
+ if ((monitor >= 0) && (monitor < monitorCount))
+ {
+ const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
+ if (mode)
+ {
+ if (!IsWindowState(FLAG_BORDERLESS_WINDOWED_MODE))
+ {
+ // Store screen position and size
+ // NOTE: If it was on fullscreen, screen position was already stored, so skip setting it here
+ if (!wasOnFullscreen) glfwGetWindowPos(CORE.Window.handle, &CORE.Window.previousPosition.x, &CORE.Window.previousPosition.y);
+ CORE.Window.previousScreen = CORE.Window.screen;
+
+ // Set undecorated and topmost modes and flags
+ glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_FALSE);
+ CORE.Window.flags |= FLAG_WINDOW_UNDECORATED;
+ glfwSetWindowAttrib(CORE.Window.handle, GLFW_FLOATING, GLFW_TRUE);
+ CORE.Window.flags |= FLAG_WINDOW_TOPMOST;
+
+ // Get monitor position and size
+ int monitorPosX = 0;
+ int monitorPosY = 0;
+ glfwGetMonitorPos(monitors[monitor], &monitorPosX, &monitorPosY);
+ const int monitorWidth = mode->width;
+ const int monitorHeight = mode->height;
+ glfwSetWindowSize(CORE.Window.handle, monitorWidth, monitorHeight);
+
+ // Set screen position and size
+ glfwSetWindowPos(CORE.Window.handle, monitorPosX, monitorPosY);
+ glfwSetWindowSize(CORE.Window.handle, monitorWidth, monitorHeight);
+
+ // Refocus window
+ glfwFocusWindow(CORE.Window.handle);
+
+ CORE.Window.flags |= FLAG_BORDERLESS_WINDOWED_MODE;
+ }
+ else
+ {
+ // Remove topmost and undecorated modes and flags
+ glfwSetWindowAttrib(CORE.Window.handle, GLFW_FLOATING, GLFW_FALSE);
+ CORE.Window.flags &= ~FLAG_WINDOW_TOPMOST;
+ glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_TRUE);
+ CORE.Window.flags &= ~FLAG_WINDOW_UNDECORATED;
+
+ // Return previous screen size and position
+ // NOTE: The order matters here, it must set size first, then set position, otherwise the screen will be positioned incorrectly
+ glfwSetWindowSize(CORE.Window.handle, CORE.Window.previousScreen.width, CORE.Window.previousScreen.height);
+ glfwSetWindowPos(CORE.Window.handle, CORE.Window.previousPosition.x, CORE.Window.previousPosition.y);
+
+ // Refocus window
+ glfwFocusWindow(CORE.Window.handle);
+
+ CORE.Window.flags &= ~FLAG_BORDERLESS_WINDOWED_MODE;
+ }
+ }
+ else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
+ }
+ else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
+#endif
+}
+
// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
void MaximizeWindow(void)
{
@@ -1314,7 +1414,7 @@ void MaximizeWindow(void)
void MinimizeWindow(void)
{
#if defined(PLATFORM_DESKTOP)
- // NOTE: Following function launches callback that sets appropiate flag!
+ // NOTE: Following function launches callback that sets appropriate flag!
glfwIconifyWindow(CORE.Window.handle);
#endif
}
@@ -1347,6 +1447,13 @@ void SetWindowState(unsigned int flags)
CORE.Window.flags |= FLAG_VSYNC_HINT;
}
+ // State change: FLAG_BORDERLESS_WINDOWED_MODE
+ // NOTE: This must be handled before FLAG_FULLSCREEN_MODE because ToggleBorderlessWindowed() needs to get some fullscreen values if fullscreen is running
+ if (((CORE.Window.flags & FLAG_BORDERLESS_WINDOWED_MODE) != (flags & FLAG_BORDERLESS_WINDOWED_MODE)) && ((flags & FLAG_BORDERLESS_WINDOWED_MODE) > 0))
+ {
+ ToggleBorderlessWindowed(); // NOTE: Window state flag updated inside function
+ }
+
// State change: FLAG_FULLSCREEN_MODE
if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) != (flags & FLAG_FULLSCREEN_MODE))
{
@@ -1413,13 +1520,13 @@ void SetWindowState(unsigned int flags)
// State change: FLAG_WINDOW_TRANSPARENT
if (((CORE.Window.flags & FLAG_WINDOW_TRANSPARENT) != (flags & FLAG_WINDOW_TRANSPARENT)) && ((flags & FLAG_WINDOW_TRANSPARENT) > 0))
{
- TRACELOG(LOG_WARNING, "WINDOW: Framebuffer transparency can only by configured before window initialization");
+ TRACELOG(LOG_WARNING, "WINDOW: Framebuffer transparency can only be configured before window initialization");
}
// State change: FLAG_WINDOW_HIGHDPI
if (((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) != (flags & FLAG_WINDOW_HIGHDPI)) && ((flags & FLAG_WINDOW_HIGHDPI) > 0))
{
- TRACELOG(LOG_WARNING, "WINDOW: High DPI can only by configured before window initialization");
+ TRACELOG(LOG_WARNING, "WINDOW: High DPI can only be configured before window initialization");
}
// State change: FLAG_WINDOW_MOUSE_PASSTHROUGH
@@ -1432,13 +1539,13 @@ void SetWindowState(unsigned int flags)
// State change: FLAG_MSAA_4X_HINT
if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) != (flags & FLAG_MSAA_4X_HINT)) && ((flags & FLAG_MSAA_4X_HINT) > 0))
{
- TRACELOG(LOG_WARNING, "WINDOW: MSAA can only by configured before window initialization");
+ TRACELOG(LOG_WARNING, "WINDOW: MSAA can only be configured before window initialization");
}
// State change: FLAG_INTERLACED_HINT
if (((CORE.Window.flags & FLAG_INTERLACED_HINT) != (flags & FLAG_INTERLACED_HINT)) && ((flags & FLAG_INTERLACED_HINT) > 0))
{
- TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only by configured before window initialization");
+ TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only be configured before window initialization");
}
#endif
}
@@ -1457,6 +1564,13 @@ void ClearWindowState(unsigned int flags)
CORE.Window.flags &= ~FLAG_VSYNC_HINT;
}
+ // State change: FLAG_BORDERLESS_WINDOWED_MODE
+ // NOTE: This must be handled before FLAG_FULLSCREEN_MODE because ToggleBorderlessWindowed() needs to get some fullscreen values if fullscreen is running
+ if (((CORE.Window.flags & FLAG_BORDERLESS_WINDOWED_MODE) > 0) && ((flags & FLAG_BORDERLESS_WINDOWED_MODE) > 0))
+ {
+ ToggleBorderlessWindowed(); // NOTE: Window state flag updated inside function
+ }
+
// State change: FLAG_FULLSCREEN_MODE
if (((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0) && ((flags & FLAG_FULLSCREEN_MODE) > 0))
{
@@ -1470,13 +1584,6 @@ void ClearWindowState(unsigned int flags)
CORE.Window.flags &= ~FLAG_WINDOW_RESIZABLE;
}
- // State change: FLAG_WINDOW_UNDECORATED
- if (((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) > 0) && ((flags & FLAG_WINDOW_UNDECORATED) > 0))
- {
- glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_TRUE);
- CORE.Window.flags &= ~FLAG_WINDOW_UNDECORATED;
- }
-
// State change: FLAG_WINDOW_HIDDEN
if (((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0) && ((flags & FLAG_WINDOW_HIDDEN) > 0))
{
@@ -1496,6 +1603,13 @@ void ClearWindowState(unsigned int flags)
RestoreWindow(); // NOTE: Window state flag updated inside function
}
+ // State change: FLAG_WINDOW_UNDECORATED
+ if (((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) > 0) && ((flags & FLAG_WINDOW_UNDECORATED) > 0))
+ {
+ glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_TRUE);
+ CORE.Window.flags &= ~FLAG_WINDOW_UNDECORATED;
+ }
+
// State change: FLAG_WINDOW_UNFOCUSED
if (((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) > 0) && ((flags & FLAG_WINDOW_UNFOCUSED) > 0))
{
@@ -1521,13 +1635,13 @@ void ClearWindowState(unsigned int flags)
// State change: FLAG_WINDOW_TRANSPARENT
if (((CORE.Window.flags & FLAG_WINDOW_TRANSPARENT) > 0) && ((flags & FLAG_WINDOW_TRANSPARENT) > 0))
{
- TRACELOG(LOG_WARNING, "WINDOW: Framebuffer transparency can only by configured before window initialization");
+ TRACELOG(LOG_WARNING, "WINDOW: Framebuffer transparency can only be configured before window initialization");
}
// State change: FLAG_WINDOW_HIGHDPI
if (((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0) && ((flags & FLAG_WINDOW_HIGHDPI) > 0))
{
- TRACELOG(LOG_WARNING, "WINDOW: High DPI can only by configured before window initialization");
+ TRACELOG(LOG_WARNING, "WINDOW: High DPI can only be configured before window initialization");
}
// State change: FLAG_WINDOW_MOUSE_PASSTHROUGH
@@ -1540,45 +1654,94 @@ void ClearWindowState(unsigned int flags)
// State change: FLAG_MSAA_4X_HINT
if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) > 0) && ((flags & FLAG_MSAA_4X_HINT) > 0))
{
- TRACELOG(LOG_WARNING, "WINDOW: MSAA can only by configured before window initialization");
+ TRACELOG(LOG_WARNING, "WINDOW: MSAA can only be configured before window initialization");
}
// State change: FLAG_INTERLACED_HINT
if (((CORE.Window.flags & FLAG_INTERLACED_HINT) > 0) && ((flags & FLAG_INTERLACED_HINT) > 0))
{
- TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only by configured before window initialization");
+ TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only be configured before window initialization");
}
#endif
}
// Set icon for window (only PLATFORM_DESKTOP)
-// NOTE: Image must be in RGBA format, 8bit per channel
+// NOTE 1: Image must be in RGBA format, 8bit per channel
+// NOTE 2: Image is scaled by the OS for all required sizes
void SetWindowIcon(Image image)
{
#if defined(PLATFORM_DESKTOP)
- if (image.format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
+ if (image.data == NULL)
{
- GLFWimage icon[1] = { 0 };
+ // Revert to the default window icon, pass in an empty image array
+ glfwSetWindowIcon(CORE.Window.handle, 0, NULL);
+ }
+ else
+ {
+ if (image.format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
+ {
+ GLFWimage icon[1] = { 0 };
- icon[0].width = image.width;
- icon[0].height = image.height;
- icon[0].pixels = (unsigned char *)image.data;
+ icon[0].width = image.width;
+ icon[0].height = image.height;
+ icon[0].pixels = (unsigned char *)image.data;
- // NOTE 1: We only support one image icon
- // NOTE 2: The specified image data is copied before this function returns
- glfwSetWindowIcon(CORE.Window.handle, 1, icon);
+ // NOTE 1: We only support one image icon
+ // NOTE 2: The specified image data is copied before this function returns
+ glfwSetWindowIcon(CORE.Window.handle, 1, icon);
+ }
+ else TRACELOG(LOG_WARNING, "GLFW: Window icon image must be in R8G8B8A8 pixel format");
}
- else TRACELOG(LOG_WARNING, "GLFW: Window icon image must be in R8G8B8A8 pixel format");
#endif
}
-// Set title for window (only PLATFORM_DESKTOP)
+// Set icon for window (multiple images, only PLATFORM_DESKTOP)
+// NOTE 1: Images must be in RGBA format, 8bit per channel
+// NOTE 2: The multiple images are used depending on provided sizes
+// Standard Windows icon sizes: 256, 128, 96, 64, 48, 32, 24, 16
+void SetWindowIcons(Image *images, int count)
+{
+#if defined(PLATFORM_DESKTOP)
+ if ((images == NULL) || (count <= 0))
+ {
+ // Revert to the default window icon, pass in an empty image array
+ glfwSetWindowIcon(CORE.Window.handle, 0, NULL);
+ }
+ else
+ {
+ int valid = 0;
+ GLFWimage *icons = RL_CALLOC(count, sizeof(GLFWimage));
+
+ for (int i = 0; i < count; i++)
+ {
+ if (images[i].format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
+ {
+ icons[valid].width = images[i].width;
+ icons[valid].height = images[i].height;
+ icons[valid].pixels = (unsigned char *)images[i].data;
+
+ valid++;
+ }
+ else TRACELOG(LOG_WARNING, "GLFW: Window icon image must be in R8G8B8A8 pixel format");
+ }
+ // NOTE: Images data is copied internally before this function returns
+ glfwSetWindowIcon(CORE.Window.handle, valid, icons);
+
+ RL_FREE(icons);
+ }
+#endif
+}
+
+// Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
void SetWindowTitle(const char *title)
{
CORE.Window.title = title;
#if defined(PLATFORM_DESKTOP)
glfwSetWindowTitle(CORE.Window.handle, title);
#endif
+#if defined(PLATFORM_WEB)
+ emscripten_set_window_title(title);
+#endif
}
// Set window position on screen (windowed mode)
@@ -1589,7 +1752,7 @@ void SetWindowPosition(int x, int y)
#endif
}
-// Set monitor for the current window (fullscreen mode)
+// Set monitor for the current window
void SetWindowMonitor(int monitor)
{
#if defined(PLATFORM_DESKTOP)
@@ -1598,10 +1761,34 @@ void SetWindowMonitor(int monitor)
if ((monitor >= 0) && (monitor < monitorCount))
{
- TRACELOG(LOG_INFO, "GLFW: Selected fullscreen monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
+ if (CORE.Window.fullscreen)
+ {
+ TRACELOG(LOG_INFO, "GLFW: Selected fullscreen monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
- const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
- glfwSetWindowMonitor(CORE.Window.handle, monitors[monitor], 0, 0, mode->width, mode->height, mode->refreshRate);
+ const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
+ glfwSetWindowMonitor(CORE.Window.handle, monitors[monitor], 0, 0, mode->width, mode->height, mode->refreshRate);
+ }
+ else
+ {
+ TRACELOG(LOG_INFO, "GLFW: Selected monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
+
+ const int screenWidth = CORE.Window.screen.width;
+ const int screenHeight = CORE.Window.screen.height;
+ int monitorWorkareaX = 0;
+ int monitorWorkareaY = 0;
+ int monitorWorkareaWidth = 0;
+ int monitorWorkareaHeight = 0;
+ glfwGetMonitorWorkarea(monitors[monitor], &monitorWorkareaX, &monitorWorkareaY, &monitorWorkareaWidth, &monitorWorkareaHeight);
+
+ // If the screen size is larger than the monitor workarea, anchor it on the top left corner, otherwise, center it
+ if ((screenWidth >= monitorWorkareaWidth) || (screenHeight >= monitorWorkareaHeight)) glfwSetWindowPos(CORE.Window.handle, monitorWorkareaX, monitorWorkareaY);
+ else
+ {
+ const int x = monitorWorkareaX + (monitorWorkareaWidth/2) - (screenWidth/2);
+ const int y = monitorWorkareaY + (monitorWorkareaHeight/2) - (screenHeight/2);
+ glfwSetWindowPos(CORE.Window.handle, x, y);
+ }
+ }
}
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
#endif
@@ -1634,6 +1821,14 @@ void SetWindowOpacity(float opacity)
#endif
}
+// Set window focused
+void SetWindowFocused(void)
+{
+#if defined(PLATFORM_DESKTOP)
+ glfwFocusWindow(CORE.Window.handle);
+#endif
+}
+
// Get current screen width
int GetScreenWidth(void)
{
@@ -1665,16 +1860,17 @@ void *GetWindowHandle(void)
// NOTE: Returned handle is: void *HWND (windows.h)
return glfwGetWin32Window(CORE.Window.handle);
#endif
-#if defined(__linux__)
+#if defined(PLATFORM_DESKTOP) && defined(__linux__)
// NOTE: Returned handle is: unsigned long Window (X.h)
// typedef unsigned long XID;
// typedef XID Window;
- //unsigned long id = (unsigned long)glfwGetX11Window(window);
- return NULL; // TODO: Find a way to return value... cast to void *?
+ //unsigned long id = (unsigned long)glfwGetX11Window(CORE.Window.handle);
+ //return NULL; // TODO: Find a way to return value... cast to void *?
+ return (void *)CORE.Window.handle;
#endif
#if defined(__APPLE__)
// NOTE: Returned handle is: (objc_object *)
- return NULL; // TODO: return (void *)glfwGetCocoaWindow(window);
+ return (void *)glfwGetCocoaWindow(CORE.Window.handle);
#endif
return NULL;
@@ -1730,17 +1926,24 @@ int GetCurrentMonitor(void)
int mx = 0;
int my = 0;
- int width = 0;
- int height = 0;
-
monitor = monitors[i];
- glfwGetMonitorWorkarea(monitor, &mx, &my, &width, &height);
-
- if (x >= mx && x <= (mx + width) && y >= my && y <= (my + height))
+ glfwGetMonitorPos(monitor, &mx, &my);
+ const GLFWvidmode *mode = glfwGetVideoMode(monitor);
+ if (mode)
{
- index = i;
- break;
+ const int width = mode->width;
+ const int height = mode->height;
+
+ if ((x >= mx) &&
+ (x < (mx + width)) &&
+ (y >= my) &&
+ (y < (my + height)))
+ {
+ index = i;
+ break;
+ }
}
+ else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
}
}
}
@@ -1783,6 +1986,12 @@ int GetMonitorWidth(int monitor)
else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
}
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
+#endif
+#if defined(PLATFORM_ANDROID)
+ if (CORE.Android.app->window != NULL)
+ {
+ return ANativeWindow_getWidth(CORE.Android.app->window);
+ }
#endif
return 0;
}
@@ -1802,6 +2011,12 @@ int GetMonitorHeight(int monitor)
else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
}
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
+#endif
+#if defined(PLATFORM_ANDROID)
+ if (CORE.Android.app->window != NULL)
+ {
+ return ANativeWindow_getHeight(CORE.Android.app->window);
+ }
#endif
return 0;
}
@@ -1933,10 +2148,40 @@ void SetClipboardText(const char *text)
glfwSetClipboardString(CORE.Window.handle, text);
#endif
#if defined(PLATFORM_WEB)
- emscripten_run_script(TextFormat("navigator.clipboard.writeText('%s')", text));
+ // Security check to (partially) avoid malicious code
+ if (strchr(text, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided Clipboard could be potentially malicious, avoid [\'] character");
+ else EM_ASM( { navigator.clipboard.writeText(UTF8ToString($0)); }, text);
#endif
}
+// Get clipboard text content
+// NOTE: returned string is allocated and freed by GLFW
+const char *GetClipboardText(void)
+{
+#if defined(PLATFORM_DESKTOP)
+ return glfwGetClipboardString(CORE.Window.handle);
+#endif
+#if defined(PLATFORM_WEB)
+/*
+ // Accessing clipboard data from browser is tricky due to security reasons
+ // The method to use is navigator.clipboard.readText() but this is an asynchronous method
+ // that will return at some moment after the function is called with the required data
+ emscripten_run_script_string("navigator.clipboard.readText() \
+ .then(text => { document.getElementById('clipboard').innerText = text; console.log('Pasted content: ', text); }) \
+ .catch(err => { console.error('Failed to read clipboard contents: ', err); });"
+ );
+
+ // The main issue is getting that data, one approach could be using ASYNCIFY and wait
+ // for the data but it requires adding Asyncify emscripten library on compilation
+
+ // Another approach could be just copy the data in a HTML text field and try to retrieve it
+ // later on if available... and clean it for future accesses
+*/
+ return NULL;
+#endif
+ return NULL;
+}
+
// Enable waiting for events on EndDrawing(), no automatic event polling
void EnableEventWaiting(void)
{
@@ -1949,19 +2194,6 @@ void DisableEventWaiting(void)
CORE.Window.eventWaiting = false;
}
-// Get clipboard text content
-// NOTE: returned string is allocated and freed by GLFW
-const char *GetClipboardText(void)
-{
-#if defined(PLATFORM_DESKTOP)
- return glfwGetClipboardString(CORE.Window.handle);
-#endif
-#if defined(PLATFORM_WEB)
- return emscripten_run_script_string("navigator.clipboard.readText()");
-#endif
- return NULL;
-}
-
// Show mouse cursor
void ShowCursor(void)
{
@@ -1997,6 +2229,8 @@ void EnableCursor(void)
#if defined(PLATFORM_WEB)
emscripten_exit_pointerlock();
#endif
+ // Set cursor position in the middle
+ SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2);
CORE.Input.Mouse.cursorHidden = false;
}
@@ -2010,6 +2244,8 @@ void DisableCursor(void)
#if defined(PLATFORM_WEB)
emscripten_request_pointerlock("#canvas", 1);
#endif
+ // Set cursor position in the middle
+ SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2);
CORE.Input.Mouse.cursorHidden = true;
}
@@ -2171,7 +2407,7 @@ void EndMode2D(void)
}
// Initializes 3D mode with custom camera (3D)
-void BeginMode3D(Camera3D camera)
+void BeginMode3D(Camera camera)
{
rlDrawRenderBatchActive(); // Update and draw internal render batch
@@ -2347,7 +2583,7 @@ VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device)
{
VrStereoConfig config = { 0 };
- if ((rlGetVersion() == RL_OPENGL_33) || (rlGetVersion() == RL_OPENGL_ES_20))
+ if ((rlGetVersion() == RL_OPENGL_33) || (rlGetVersion() >= RL_OPENGL_ES_20))
{
// Compute aspect ratio
float aspect = ((float)device.hResolution*0.5f)/(float)device.vResolution;
@@ -2446,10 +2682,6 @@ Shader LoadShader(const char *vsFileName, const char *fsFileName)
Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode)
{
Shader shader = { 0 };
- shader.locs = (int *)RL_CALLOC(RL_MAX_SHADER_LOCATIONS, sizeof(int));
-
- // NOTE: All locations must be reseted to -1 (no location)
- for (int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++) shader.locs[i] = -1;
shader.id = rlLoadShaderCode(vsCode, fsCode);
@@ -2466,7 +2698,12 @@ Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode)
// NOTE: If any location is not found, loc point becomes -1
- // Get handles to GLSL input attibute locations
+ shader.locs = (int *)RL_CALLOC(RL_MAX_SHADER_LOCATIONS, sizeof(int));
+
+ // All locations reset to -1 (no location)
+ for (int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++) shader.locs[i] = -1;
+
+ // Get handles to GLSL input attribute locations
shader.locs[SHADER_LOC_VERTEX_POSITION] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION);
shader.locs[SHADER_LOC_VERTEX_TEXCOORD01] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD);
shader.locs[SHADER_LOC_VERTEX_TEXCOORD02] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2);
@@ -2491,12 +2728,46 @@ Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode)
return shader;
}
+// Check if a shader is ready
+bool IsShaderReady(Shader shader)
+{
+ return ((shader.id > 0) && // Validate shader id (loaded successfully)
+ (shader.locs != NULL)); // Validate memory has been allocated for default shader locations
+
+ // The following locations are tried to be set automatically (locs[i] >= 0),
+ // any of them can be checked for validation but the only mandatory one is, afaik, SHADER_LOC_VERTEX_POSITION
+ // NOTE: Users can also setup manually their own attributes/uniforms and do not used the default raylib ones
+
+ // Vertex shader attribute locations (default)
+ // shader.locs[SHADER_LOC_VERTEX_POSITION] // Set by default internal shader
+ // shader.locs[SHADER_LOC_VERTEX_TEXCOORD01] // Set by default internal shader
+ // shader.locs[SHADER_LOC_VERTEX_TEXCOORD02]
+ // shader.locs[SHADER_LOC_VERTEX_NORMAL]
+ // shader.locs[SHADER_LOC_VERTEX_TANGENT]
+ // shader.locs[SHADER_LOC_VERTEX_COLOR] // Set by default internal shader
+
+ // Vertex shader uniform locations (default)
+ // shader.locs[SHADER_LOC_MATRIX_MVP] // Set by default internal shader
+ // shader.locs[SHADER_LOC_MATRIX_VIEW]
+ // shader.locs[SHADER_LOC_MATRIX_PROJECTION]
+ // shader.locs[SHADER_LOC_MATRIX_MODEL]
+ // shader.locs[SHADER_LOC_MATRIX_NORMAL]
+
+ // Fragment shader uniform locations (default)
+ // shader.locs[SHADER_LOC_COLOR_DIFFUSE] // Set by default internal shader
+ // shader.locs[SHADER_LOC_MAP_DIFFUSE] // Set by default internal shader
+ // shader.locs[SHADER_LOC_MAP_SPECULAR]
+ // shader.locs[SHADER_LOC_MAP_NORMAL]
+}
+
// Unload shader from GPU memory (VRAM)
void UnloadShader(Shader shader)
{
if (shader.id != rlGetShaderIdDefault())
{
rlUnloadShaderProgram(shader.id);
+
+ // NOTE: If shader loading failed, it should be 0
RL_FREE(shader.locs);
}
}
@@ -2522,25 +2793,34 @@ void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformT
// Set shader uniform value vector
void SetShaderValueV(Shader shader, int locIndex, const void *value, int uniformType, int count)
{
- rlEnableShader(shader.id);
- rlSetUniform(locIndex, value, uniformType, count);
- //rlDisableShader(); // Avoid reseting current shader program, in case other uniforms are set
+ if (locIndex > -1)
+ {
+ rlEnableShader(shader.id);
+ rlSetUniform(locIndex, value, uniformType, count);
+ //rlDisableShader(); // Avoid resetting current shader program, in case other uniforms are set
+ }
}
// Set shader uniform value (matrix 4x4)
void SetShaderValueMatrix(Shader shader, int locIndex, Matrix mat)
{
- rlEnableShader(shader.id);
- rlSetUniformMatrix(locIndex, mat);
- //rlDisableShader();
+ if (locIndex > -1)
+ {
+ rlEnableShader(shader.id);
+ rlSetUniformMatrix(locIndex, mat);
+ //rlDisableShader();
+ }
}
// Set shader uniform value for texture
void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture)
{
- rlEnableShader(shader.id);
- rlSetUniformSampler(locIndex, texture.id);
- //rlDisableShader();
+ if (locIndex > -1)
+ {
+ rlEnableShader(shader.id);
+ rlSetUniformSampler(locIndex, texture.id);
+ //rlDisableShader();
+ }
}
// Get a ray trace from mouse position
@@ -2582,7 +2862,7 @@ Ray GetMouseRay(Vector2 mouse, Camera camera)
Vector3 farPoint = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, 1.0f }, matProj, matView);
// Unproject the mouse cursor in the near plane.
- // We need this as the source position because orthographic projects, compared to perspect doesn't have a
+ // We need this as the source position because orthographic projects, compared to perspective doesn't have a
// convergence point, meaning that the "eye" of the camera is more like a plane than a point.
Vector3 cameraPlanePointerPos = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, -1.0f }, matProj, matView);
@@ -2719,7 +2999,7 @@ int GetFPS(void)
#if !defined(SUPPORT_CUSTOM_FRAME_CONTROL)
#define FPS_CAPTURE_FRAMES_COUNT 30 // 30 captures
- #define FPS_AVERAGE_TIME_SECONDS 0.5f // 500 millisecondes
+ #define FPS_AVERAGE_TIME_SECONDS 0.5f // 500 milliseconds
#define FPS_STEP (FPS_AVERAGE_TIME_SECONDS/FPS_CAPTURE_FRAMES_COUNT)
static int index = 0;
@@ -2755,22 +3035,24 @@ float GetFrameTime(void)
// NOTE: On PLATFORM_DESKTOP, timer is initialized on glfwInit()
double GetTime(void)
{
+ double time = 0.0;
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
- return glfwGetTime(); // Elapsed time since glfwInit()
+ time = glfwGetTime(); // Elapsed time since glfwInit()
#endif
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
struct timespec ts = { 0 };
clock_gettime(CLOCK_MONOTONIC, &ts);
- unsigned long long int time = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
+ unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
- return (double)(time - CORE.Time.base)*1e-9; // Elapsed time since InitTimer()
+ time = (double)(nanoSeconds - CORE.Time.base)*1e-9; // Elapsed time since InitTimer()
#endif
+ return time;
}
// Setup window configuration flags (view FLAGS)
// NOTE: This function is expected to be called before window creation,
-// because it setups some flags for the window creation process.
+// because it sets up some flags for the window creation process.
// To configure window states after creation, just use SetWindowState()
void SetConfigFlags(unsigned int flags)
{
@@ -2785,6 +3067,9 @@ void SetConfigFlags(unsigned int flags)
void TakeScreenshot(const char *fileName)
{
#if defined(SUPPORT_MODULE_RTEXTURES)
+ // Security check to (partially) avoid malicious code on PLATFORM_WEB
+ if (strchr(fileName, '\'') != NULL) { TRACELOG(LOG_WARNING, "SYSTEM: Provided fileName could be potentially malicious, avoid [\'] character"); return; }
+
Vector2 scale = GetWindowScaleDPI();
unsigned char *imgData = rlReadScreenPixels((int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y));
Image image = { imgData, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y), 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
@@ -2808,6 +3093,9 @@ void TakeScreenshot(const char *fileName)
}
// Get a random value between min and max (both included)
+// WARNING: Ranges higher than RAND_MAX will return invalid results
+// More specifically, if (max - min) > INT_MAX there will be an overflow,
+// and otherwise if (max - min) > RAND_MAX the random value will incorrectly never exceed a certain threshold
int GetRandomValue(int min, int max)
{
if (min > max)
@@ -2817,6 +3105,11 @@ int GetRandomValue(int min, int max)
min = tmp;
}
+ if ((unsigned int)(max - min) > (unsigned int)RAND_MAX)
+ {
+ TRACELOG(LOG_WARNING, "Invalid GetRandomValue() arguments, range should not be higher than %i", RAND_MAX);
+ }
+
return (rand()%(abs(max - min) + 1) + min);
}
@@ -2861,7 +3154,7 @@ bool IsFileExtension(const char *fileName, const char *ext)
const char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext
char fileExtLower[MAX_FILE_EXTENSION_SIZE + 1] = { 0 };
- strncpy(fileExtLower, TextToLower(fileExt),MAX_FILE_EXTENSION_SIZE); // WARNING: Module required: rtext
+ strncpy(fileExtLower, TextToLower(fileExt), MAX_FILE_EXTENSION_SIZE); // WARNING: Module required: rtext
for (int i = 0; i < extCount; i++)
{
@@ -2899,13 +3192,24 @@ bool DirectoryExists(const char *dirPath)
int GetFileLength(const char *fileName)
{
int size = 0;
+
+ // NOTE: On Unix-like systems, it can by used the POSIX system call: stat(),
+ // but depending on the platform that call could not be available
+ //struct stat result = { 0 };
+ //stat(fileName, &result);
+ //return result.st_size;
FILE *file = fopen(fileName, "rb");
if (file != NULL)
{
fseek(file, 0L, SEEK_END);
- size = (int)ftell(file);
+ long int fileSize = ftell(file);
+
+ // Check for size overflow (INT_MAX)
+ if (fileSize > 2147483647) TRACELOG(LOG_WARNING, "[%s] File size overflows expected limit, do not use GetFileLength()", fileName);
+ else size = (int)fileSize;
+
fclose(file);
}
@@ -2987,7 +3291,7 @@ const char *GetDirectoryPath(const char *filePath)
if (filePath[1] != ':' && filePath[0] != '\\' && filePath[0] != '/')
{
// For security, we set starting path to current directory,
- // obtained path will be concated to this
+ // obtained path will be concatenated to this
dirPath[0] = '.';
dirPath[1] = '/';
}
@@ -3054,7 +3358,7 @@ const char *GetApplicationDirectory(void)
#if defined(_WIN32)
int len = 0;
-#if defined (UNICODE)
+#if defined(UNICODE)
unsigned short widePath[MAX_PATH];
len = GetModuleFileNameW(NULL, widePath, MAX_PATH);
len = WideCharToMultiByte(0, 0, widePath, len, appDir, MAX_PATH, NULL, NULL);
@@ -3181,14 +3485,12 @@ FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool
}
// Unload directory filepaths
+// WARNING: files.count is not reseted to 0 after unloading
void UnloadDirectoryFiles(FilePathList files)
{
- if (files.capacity > 0)
- {
- for (unsigned int i = 0; i < files.capacity; i++) RL_FREE(files.paths[i]);
+ for (unsigned int i = 0; i < files.capacity; i++) RL_FREE(files.paths[i]);
- RL_FREE(files.paths);
- }
+ RL_FREE(files.paths);
}
// Change working directory, returns true on success
@@ -3204,10 +3506,10 @@ bool ChangeDirectory(const char *dir)
// Check if a given path point to a file
bool IsPathFile(const char *path)
{
- struct stat pathStat = { 0 };
- stat(path, &pathStat);
+ struct stat result = { 0 };
+ stat(path, &result);
- return S_ISREG(pathStat.st_mode);
+ return S_ISREG(result.st_mode);
}
// Check if a file has been dropped into window
@@ -3271,9 +3573,9 @@ unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDa
struct sdefl sdefl = { 0 };
int bounds = sdefl_bound(dataSize);
compData = (unsigned char *)RL_CALLOC(bounds, 1);
- *compDataSize = sdeflate(&sdefl, compData, data, dataSize, COMPRESSION_QUALITY_DEFLATE); // Compression level 8, same as stbwi
+ *compDataSize = sdeflate(&sdefl, compData, data, dataSize, COMPRESSION_QUALITY_DEFLATE); // Compression level 8, same as stbiw
- TraceLog(LOG_INFO, "SYSTEM: Compress data: Original size: %i -> Comp. size: %i", dataSize, *compDataSize);
+ TRACELOG(LOG_INFO, "SYSTEM: Compress data: Original size: %i -> Comp. size: %i", dataSize, *compDataSize);
#endif
return compData;
@@ -3286,16 +3588,19 @@ unsigned char *DecompressData(const unsigned char *compData, int compDataSize, i
#if defined(SUPPORT_COMPRESSION_API)
// Decompress data from a valid DEFLATE stream
- data = RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1);
+ data = (unsigned char *)RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1);
int length = sinflate(data, MAX_DECOMPRESSION_SIZE*1024*1024, compData, compDataSize);
- unsigned char *temp = RL_REALLOC(data, length);
+
+ // WARNING: RL_REALLOC can make (and leave) data copies in memory, be careful with sensitive compressed data!
+ // TODO: Use a different approach, create another buffer, copy data manually to it and wipe original buffer memory
+ unsigned char *temp = (unsigned char *)RL_REALLOC(data, length);
if (temp != NULL) data = temp;
else TRACELOG(LOG_WARNING, "SYSTEM: Failed to re-allocate required decompression memory");
*dataSize = length;
- TraceLog(LOG_INFO, "SYSTEM: Decompress data: Comp. size: %i -> Original size: %i", compDataSize, *dataSize);
+ TRACELOG(LOG_INFO, "SYSTEM: Decompress data: Comp. size: %i -> Original size: %i", compDataSize, *dataSize);
#endif
return data;
@@ -3314,7 +3619,7 @@ char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize)
*outputSize = 4*((dataSize + 2)/3);
- char *encodedData = RL_MALLOC(*outputSize);
+ char *encodedData = (char *)RL_MALLOC(*outputSize);
if (encodedData == NULL) return NULL;
@@ -3402,16 +3707,12 @@ unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize)
// Ref: https://github.com/raysan5/raylib/issues/686
void OpenURL(const char *url)
{
- // Small security check trying to avoid (partially) malicious code...
- // sorry for the inconvenience when you hit this point...
- if (strchr(url, '\'') != NULL)
- {
- TRACELOG(LOG_WARNING, "SYSTEM: Provided URL is not valid");
- }
+ // Security check to (partially) avoid malicious code on PLATFORM_WEB
+ if (strchr(url, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character");
else
{
#if defined(PLATFORM_DESKTOP)
- char *cmd = (char *)RL_CALLOC(strlen(url) + 10, sizeof(char));
+ char *cmd = (char *)RL_CALLOC(strlen(url) + 32, sizeof(char));
#if defined(_WIN32)
sprintf(cmd, "explorer \"%s\"", url);
#endif
@@ -3460,6 +3761,7 @@ void OpenURL(const char *url)
// Check if a key has been pressed once
bool IsKeyPressed(int key)
{
+ if ((key < 0) || (key >= MAX_KEYBOARD_KEYS)) return false;
bool pressed = false;
if ((CORE.Input.Keyboard.previousKeyState[key] == 0) && (CORE.Input.Keyboard.currentKeyState[key] == 1)) pressed = true;
@@ -3467,9 +3769,18 @@ bool IsKeyPressed(int key)
return pressed;
}
+// Check if a key has been pressed again (only PLATFORM_DESKTOP)
+bool IsKeyPressedRepeat(int key)
+{
+ if ((key < 0) || (key >= MAX_KEYBOARD_KEYS)) return false;
+ if (CORE.Input.Keyboard.keyRepeatInFrame[key] == 1) return true;
+ else return false;
+}
+
// Check if a key is being pressed (key held down)
bool IsKeyDown(int key)
{
+ if ((key < 0) || (key >= MAX_KEYBOARD_KEYS)) return false;
if (CORE.Input.Keyboard.currentKeyState[key] == 1) return true;
else return false;
}
@@ -3477,6 +3788,7 @@ bool IsKeyDown(int key)
// Check if a key has been released once
bool IsKeyReleased(int key)
{
+ if ((key < 0) || (key >= MAX_KEYBOARD_KEYS)) return false;
bool released = false;
if ((CORE.Input.Keyboard.previousKeyState[key] == 1) && (CORE.Input.Keyboard.currentKeyState[key] == 0)) released = true;
@@ -3487,6 +3799,7 @@ bool IsKeyReleased(int key)
// Check if a key is NOT being pressed (key not held down)
bool IsKeyUp(int key)
{
+ if ((key < 0) || (key >= MAX_KEYBOARD_KEYS)) return false;
if (CORE.Input.Keyboard.currentKeyState[key] == 0) return true;
else return false;
}
@@ -3506,7 +3819,7 @@ int GetKeyPressed(void)
CORE.Input.Keyboard.keyPressedQueue[i] = CORE.Input.Keyboard.keyPressedQueue[i + 1];
// Reset last character in the queue
- CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = 0;
+ CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount - 1] = 0;
CORE.Input.Keyboard.keyPressedQueueCount--;
}
@@ -3528,7 +3841,7 @@ int GetCharPressed(void)
CORE.Input.Keyboard.charPressedQueue[i] = CORE.Input.Keyboard.charPressedQueue[i + 1];
// Reset last character in the queue
- CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = 0;
+ CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount - 1] = 0;
CORE.Input.Keyboard.charPressedQueueCount--;
}
@@ -3741,7 +4054,7 @@ Vector2 GetMousePosition(void)
// Get mouse delta between frames
Vector2 GetMouseDelta(void)
{
- Vector2 delta = {0};
+ Vector2 delta = { 0 };
delta.x = CORE.Input.Mouse.currentPosition.x - CORE.Input.Mouse.previousPosition.x;
delta.y = CORE.Input.Mouse.currentPosition.y - CORE.Input.Mouse.previousPosition.y;
@@ -3753,6 +4066,8 @@ Vector2 GetMouseDelta(void)
void SetMousePosition(int x, int y)
{
CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y };
+ CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
+
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
// NOTE: emscripten not implemented
glfwSetCursorPos(CORE.Window.handle, CORE.Input.Mouse.currentPosition.x, CORE.Input.Mouse.currentPosition.y);
@@ -3882,7 +4197,7 @@ static bool InitGraphicsDevice(int width, int height)
CORE.Window.screenScale = MatrixIdentity(); // No draw scaling required by default
// NOTE: Framebuffer (render area - CORE.Window.render.width, CORE.Window.render.height) could include black bars...
- // ...in top-down or left-right to match display aspect ratio (no weird scalings)
+ // ...in top-down or left-right to match display aspect ratio (no weird scaling)
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
glfwSetErrorCallback(ErrorCallback);
@@ -3987,9 +4302,9 @@ static bool InitGraphicsDevice(int width, int height)
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // Profiles Hint: Only 3.3 and above!
// Values: GLFW_OPENGL_CORE_PROFILE, GLFW_OPENGL_ANY_PROFILE, GLFW_OPENGL_COMPAT_PROFILE
#if defined(__APPLE__)
- glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE); // OSX Requires fordward compatibility
+ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE); // OSX Requires forward compatibility
#else
- glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE); // Fordward Compatibility Hint: Only 3.3 and above!
+ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE); // Forward Compatibility Hint: Only 3.3 and above!
#endif
//glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Request OpenGL DEBUG context
}
@@ -4003,7 +4318,7 @@ static bool InitGraphicsDevice(int width, int height)
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Enable OpenGL Debug Context
#endif
}
- else if (rlGetVersion() == RL_OPENGL_ES_20) // Request OpenGL ES 2.0 context
+ else if (rlGetVersion() == RL_OPENGL_ES_20) // Request OpenGL ES 2.0 context
{
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
@@ -4012,6 +4327,17 @@ static bool InitGraphicsDevice(int width, int height)
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
#else
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
+#endif
+ }
+ else if (rlGetVersion() == RL_OPENGL_ES_30) // Request OpenGL ES 3.0 context
+ {
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
+ glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
+#if defined(PLATFORM_DESKTOP)
+ glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
+#else
+ glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
#endif
}
@@ -4051,8 +4377,18 @@ static bool InitGraphicsDevice(int width, int height)
if (CORE.Window.fullscreen)
{
// remember center for switchinging from fullscreen to window
- CORE.Window.position.x = CORE.Window.display.width/2 - CORE.Window.screen.width/2;
- CORE.Window.position.y = CORE.Window.display.height/2 - CORE.Window.screen.height/2;
+ if ((CORE.Window.screen.height == CORE.Window.display.height) && (CORE.Window.screen.width == CORE.Window.display.width))
+ {
+ // If screen width/height equal to the display, we can't calculate the window pos for toggling full-screened/windowed.
+ // Toggling full-screened/windowed with pos(0, 0) can cause problems in some platforms, such as X11.
+ CORE.Window.position.x = CORE.Window.display.width/4;
+ CORE.Window.position.y = CORE.Window.display.height/4;
+ }
+ else
+ {
+ CORE.Window.position.x = CORE.Window.display.width/2 - CORE.Window.screen.width/2;
+ CORE.Window.position.y = CORE.Window.display.height/2 - CORE.Window.screen.height/2;
+ }
if (CORE.Window.position.x < 0) CORE.Window.position.x = 0;
if (CORE.Window.position.y < 0) CORE.Window.position.y = 0;
@@ -4081,7 +4417,7 @@ static bool InitGraphicsDevice(int width, int height)
// framebuffer is rendered correctly but once displayed on a 16:9 monitor, it gets stretched
// by the sides to fit all monitor space...
- // Try to setup the most appropiate fullscreen framebuffer for the requested screenWidth/screenHeight
+ // Try to setup the most appropriate fullscreen framebuffer for the requested screenWidth/screenHeight
// It considers device display resolution mode and setups a framebuffer with black bars if required (render size/offset)
// Modified global variables: CORE.Window.screen.width/CORE.Window.screen.height - CORE.Window.render.width/CORE.Window.render.height - CORE.Window.renderOffset.x/CORE.Window.renderOffset.y - CORE.Window.screenScale
// TODO: It is a quite cumbersome solution to display size vs requested size, it should be reviewed or removed...
@@ -4119,6 +4455,11 @@ static bool InitGraphicsDevice(int width, int height)
return false;
}
+// glfwCreateWindow title doesn't work with emscripten.
+#if defined(PLATFORM_WEB)
+ emscripten_set_window_title((CORE.Window.title != 0)? CORE.Window.title : " ");
+#endif
+
// Set window callback events
glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback); // NOTE: Resizing not allowed by default!
#if !defined(PLATFORM_WEB)
@@ -4145,13 +4486,16 @@ static bool InitGraphicsDevice(int width, int height)
#endif
// Try to enable GPU V-Sync, so frames are limited to screen refresh rate (60Hz -> 60 FPS)
- // NOTE: V-Sync can be enabled by graphic driver configuration
+ // NOTE: V-Sync can be enabled by graphic driver configuration, it doesn't need
+ // to be activated on web platforms since VSync is enforced there.
+#if !defined(PLATFORM_WEB)
if (CORE.Window.flags & FLAG_VSYNC_HINT)
{
- // WARNING: It seems to hits a critical render path in Intel HD Graphics
+ // WARNING: It seems to hit a critical render path in Intel HD Graphics
glfwSwapInterval(1);
TRACELOG(LOG_INFO, "DISPLAY: Trying to enable VSYNC");
}
+#endif
int fbWidth = CORE.Window.screen.width;
int fbHeight = CORE.Window.screen.height;
@@ -4159,12 +4503,12 @@ static bool InitGraphicsDevice(int width, int height)
#if defined(PLATFORM_DESKTOP)
if ((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0)
{
- // NOTE: On APPLE platforms system should manage window/input scaling and also framebuffer scaling
+ // NOTE: On APPLE platforms system should manage window/input scaling and also framebuffer scaling.
// Framebuffer scaling should be activated with: glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE);
#if !defined(__APPLE__)
glfwGetFramebufferSize(CORE.Window.handle, &fbWidth, &fbHeight);
- // Screen scaling matrix is required in case desired screen area is different than display area
+ // Screen scaling matrix is required in case desired screen area is different from display area
CORE.Window.screenScale = MatrixScale((float)fbWidth/CORE.Window.screen.width, (float)fbHeight/CORE.Window.screen.height, 1.0f);
// Mouse input scaling for the new screen size
@@ -4373,7 +4717,7 @@ static bool InitGraphicsDevice(int width, int height)
const EGLint framebufferAttribs[] =
{
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // Type of context support -> Required on RPI?
+ EGL_RENDERABLE_TYPE, (rlGetVersion() == RL_OPENGL_ES_30)? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, // Type of context support
#if defined(PLATFORM_DRM)
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, // Don't use it on Android!
#endif
@@ -4762,7 +5106,7 @@ static void InitTimer(void)
// NOTE: Sleep() granularity could be around 10 ms, it means, Sleep() could
// take longer than expected... for that reason we use the busy wait loop
// Ref: http://stackoverflow.com/questions/43057578/c-programming-win32-games-sleep-taking-longer-than-expected
-// Ref: http://www.geisswerks.com/ryan/FAQS/timing.html --> All about timming on Win32!
+// Ref: http://www.geisswerks.com/ryan/FAQS/timing.html --> All about timing on Win32!
void WaitTime(double seconds)
{
#if defined(SUPPORT_BUSY_WAIT_LOOP) || defined(SUPPORT_PARTIALBUSY_WAIT_LOOP)
@@ -4854,22 +5198,29 @@ void PollInputEvents(void)
// Reset keys/chars pressed registered
CORE.Input.Keyboard.keyPressedQueueCount = 0;
CORE.Input.Keyboard.charPressedQueueCount = 0;
+ // Reset key repeats
+ for (int i = 0; i < MAX_KEYBOARD_KEYS; i++) CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
#if !(defined(PLATFORM_RPI) || defined(PLATFORM_DRM))
// Reset last gamepad button/axis registered state
- CORE.Input.Gamepad.lastButtonPressed = -1;
+ CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN
CORE.Input.Gamepad.axisCount = 0;
#endif
#if defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
// Register previous keys states
- for (int i = 0; i < MAX_KEYBOARD_KEYS; i++) CORE.Input.Keyboard.previousKeyState[i] = CORE.Input.Keyboard.currentKeyState[i];
+ for (int i = 0; i < MAX_KEYBOARD_KEYS; i++)
+ {
+ CORE.Input.Keyboard.previousKeyState[i] = CORE.Input.Keyboard.currentKeyState[i];
+ CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
+ }
PollKeyboardEvents();
// Register previous mouse states
CORE.Input.Mouse.previousWheelMove = CORE.Input.Mouse.currentWheelMove;
- CORE.Input.Mouse.currentWheelMove = (Vector2){ 0.0f, 0.0f };
+ CORE.Input.Mouse.currentWheelMove = CORE.Input.Mouse.eventWheelMove;
+ CORE.Input.Mouse.eventWheelMove = (Vector2){ 0.0f, 0.0f };
for (int i = 0; i < MAX_MOUSE_BUTTONS; i++)
{
CORE.Input.Mouse.previousButtonState[i] = CORE.Input.Mouse.currentButtonState[i];
@@ -4891,7 +5242,11 @@ void PollInputEvents(void)
// Keyboard/Mouse input polling (automatically managed by GLFW3 through callback)
// Register previous keys states
- for (int i = 0; i < MAX_KEYBOARD_KEYS; i++) CORE.Input.Keyboard.previousKeyState[i] = CORE.Input.Keyboard.currentKeyState[i];
+ for (int i = 0; i < MAX_KEYBOARD_KEYS; i++)
+ {
+ CORE.Input.Keyboard.previousKeyState[i] = CORE.Input.Keyboard.currentKeyState[i];
+ CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
+ }
// Register previous mouse states
for (int i = 0; i < MAX_MOUSE_BUTTONS; i++) CORE.Input.Mouse.previousButtonState[i] = CORE.Input.Mouse.currentButtonState[i];
@@ -4931,7 +5286,6 @@ void PollInputEvents(void)
// Get current gamepad state
// NOTE: There is no callback available, so we get it manually
- // Get remapped buttons
GLFWgamepadstate state = { 0 };
glfwGetGamepadState(i, &state); // This remapps all gamepads so they have their buttons mapped like an xbox controller
@@ -4939,7 +5293,7 @@ void PollInputEvents(void)
for (int k = 0; (buttons != NULL) && (k < GLFW_GAMEPAD_BUTTON_DPAD_LEFT + 1) && (k < MAX_GAMEPAD_BUTTONS); k++)
{
- GamepadButton button = -1;
+ int button = -1; // GamepadButton enum values assigned
switch (k)
{
@@ -5074,7 +5428,11 @@ void PollInputEvents(void)
#if defined(PLATFORM_ANDROID)
// Register previous keys states
// NOTE: Android supports up to 260 keys
- for (int i = 0; i < 260; i++) CORE.Input.Keyboard.previousKeyState[i] = CORE.Input.Keyboard.currentKeyState[i];
+ for (int i = 0; i < 260; i++)
+ {
+ CORE.Input.Keyboard.previousKeyState[i] = CORE.Input.Keyboard.currentKeyState[i];
+ CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
+ }
// Android ALooper_pollAll() variables
int pollResult = 0;
@@ -5270,7 +5628,8 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
// WARNING: GLFW could return GLFW_REPEAT, we need to consider it as 1
// to work properly with our implementation (IsKeyDown/IsKeyUp checks)
if (action == GLFW_RELEASE) CORE.Input.Keyboard.currentKeyState[key] = 0;
- else CORE.Input.Keyboard.currentKeyState[key] = 1;
+ else if(action == GLFW_PRESS) CORE.Input.Keyboard.currentKeyState[key] = 1;
+ else if(action == GLFW_REPEAT) CORE.Input.Keyboard.keyRepeatInFrame[key] = 1;
#if !defined(PLATFORM_WEB)
// WARNING: Check if CAPS/NUM key modifiers are enabled and force down state for those keys
@@ -5293,7 +5652,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
if ((key == GLFW_KEY_F12) && (action == GLFW_PRESS))
{
#if defined(SUPPORT_GIF_RECORDING)
- if (mods == GLFW_MOD_CONTROL)
+ if (mods & GLFW_MOD_CONTROL)
{
if (gifRecording)
{
@@ -5357,12 +5716,12 @@ static void CharCallback(GLFWwindow *window, unsigned int key)
//TRACELOG(LOG_DEBUG, "Char Callback: KEY:%i(%c)", key, key);
// NOTE: Registers any key down considering OS keyboard layout but
- // do not detects action events, those should be managed by user...
+ // does not detect action events, those should be managed by user...
// Ref: https://github.com/glfw/glfw/issues/668#issuecomment-166794907
// Ref: https://www.glfw.org/docs/latest/input_guide.html#input_char
// Check if there is space available in the queue
- if (CORE.Input.Keyboard.charPressedQueueCount < MAX_KEY_PRESSED_QUEUE)
+ if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
{
// Add character to the queue
CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = key;
@@ -5400,9 +5759,15 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
- // Gesture data is sent to gestures system for processing
+ // Gesture data is sent to gestures-system for processing
+#if defined(PLATFORM_WEB)
+ // Prevent calling ProcessGestureEvent() when Emscripten is present and there's a touch gesture, so EmscriptenTouchCallback() can handle it itself
+ if (GetMouseX() != 0 || GetMouseY() != 0) ProcessGestureEvent(gestureEvent);
+#else
ProcessGestureEvent(gestureEvent);
#endif
+
+#endif
}
// GLFW3 Cursor Position Callback, runs on mouse move
@@ -5431,7 +5796,7 @@ static void MouseCursorPosCallback(GLFWwindow *window, double x, double y)
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
- // Gesture data is sent to gestures system for processing
+ // Gesture data is sent to gestures-system for processing
ProcessGestureEvent(gestureEvent);
#endif
}
@@ -5452,25 +5817,28 @@ static void CursorEnterCallback(GLFWwindow *window, int enter)
// GLFW3 Window Drop Callback, runs when drop files into window
static void WindowDropCallback(GLFWwindow *window, int count, const char **paths)
{
- // In case previous dropped filepaths have not been freed, we free them
- if (CORE.Window.dropFileCount > 0)
+ if (count > 0)
{
- for (unsigned int i = 0; i < CORE.Window.dropFileCount; i++) RL_FREE(CORE.Window.dropFilepaths[i]);
+ // In case previous dropped filepaths have not been freed, we free them
+ if (CORE.Window.dropFileCount > 0)
+ {
+ for (unsigned int i = 0; i < CORE.Window.dropFileCount; i++) RL_FREE(CORE.Window.dropFilepaths[i]);
- RL_FREE(CORE.Window.dropFilepaths);
+ RL_FREE(CORE.Window.dropFilepaths);
- CORE.Window.dropFileCount = 0;
- CORE.Window.dropFilepaths = NULL;
- }
+ CORE.Window.dropFileCount = 0;
+ CORE.Window.dropFilepaths = NULL;
+ }
- // WARNING: Paths are freed by GLFW when the callback returns, we must keep an internal copy
- CORE.Window.dropFileCount = count;
- CORE.Window.dropFilepaths = (char **)RL_CALLOC(CORE.Window.dropFileCount, sizeof(char *));
+ // WARNING: Paths are freed by GLFW when the callback returns, we must keep an internal copy
+ CORE.Window.dropFileCount = count;
+ CORE.Window.dropFilepaths = (char **)RL_CALLOC(CORE.Window.dropFileCount, sizeof(char *));
- for (unsigned int i = 0; i < CORE.Window.dropFileCount; i++)
- {
- CORE.Window.dropFilepaths[i] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char));
- strcpy(CORE.Window.dropFilepaths[i], paths[i]);
+ for (unsigned int i = 0; i < CORE.Window.dropFileCount; i++)
+ {
+ CORE.Window.dropFilepaths[i] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char));
+ strcpy(CORE.Window.dropFilepaths[i], paths[i]);
+ }
}
}
#endif
@@ -5565,21 +5933,29 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
} break;
case APP_CMD_TERM_WINDOW:
{
- // Dettach OpenGL context and destroy display surface
- // NOTE 1: Detaching context before destroying display surface avoids losing our resources (textures, shaders, VBOs...)
- // NOTE 2: In some cases (too many context loaded), OS could unload context automatically... :(
- eglMakeCurrent(CORE.Window.device, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- eglDestroySurface(CORE.Window.device, CORE.Window.surface);
+ // Detach OpenGL context and destroy display surface
+ // NOTE 1: This case is used when the user exits the app without closing it. We detach the context to ensure everything is recoverable upon resuming.
+ // NOTE 2: Detaching context before destroying display surface avoids losing our resources (textures, shaders, VBOs...)
+ // NOTE 3: In some cases (too many context loaded), OS could unload context automatically... :(
+ if (CORE.Window.device != EGL_NO_DISPLAY)
+ {
+ eglMakeCurrent(CORE.Window.device, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+
+ if (CORE.Window.surface != EGL_NO_SURFACE)
+ {
+ eglDestroySurface(CORE.Window.device, CORE.Window.surface);
+ CORE.Window.surface = EGL_NO_SURFACE;
+ }
+
+ CORE.Android.contextRebindRequired = true;
+ }
+ // If 'CORE.Window.device' is already set to 'EGL_NO_DISPLAY'
+ // this means that the user has already called 'CloseWindow()'
- CORE.Android.contextRebindRequired = true;
} break;
case APP_CMD_SAVE_STATE: break;
case APP_CMD_STOP: break;
- case APP_CMD_DESTROY:
- {
- // TODO: Finish activity?
- //ANativeActivity_finish(CORE.Android.app->activity);
- } break;
+ case APP_CMD_DESTROY: break;
case APP_CMD_CONFIG_CHANGED:
{
//AConfiguration_fromAssetManager(CORE.Android.app->config, CORE.Android.app->activity->assetManager);
@@ -5700,14 +6076,15 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
CORE.Input.Gamepad.ready[0] = true;
GamepadButton button = AndroidTranslateGamepadButton(keycode);
- if (button == GAMEPAD_BUTTON_UNKNOWN)
- return 1;
+
+ if (button == GAMEPAD_BUTTON_UNKNOWN) return 1;
if (AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_DOWN)
{
CORE.Input.Gamepad.currentButtonState[0][button] = 1;
}
else CORE.Input.Gamepad.currentButtonState[0][button] = 0; // Key up
+
return 1; // Handled gamepad button
}
@@ -5720,6 +6097,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = keycode;
CORE.Input.Keyboard.keyPressedQueueCount++;
}
+ else if (AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_MULTIPLE) CORE.Input.Keyboard.keyRepeatInFrame[keycode] = 1;
else CORE.Input.Keyboard.currentKeyState[keycode] = 0; // Key up
if (keycode == AKEYCODE_POWER)
@@ -5792,11 +6170,12 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
if (flags == AMOTION_EVENT_ACTION_POINTER_UP || flags == AMOTION_EVENT_ACTION_UP)
{
// One of the touchpoints is released, remove it from touch point arrays
- for (int i = pointerIndex; (i < CORE.Input.Touch.pointCount-1) && (i < MAX_TOUCH_POINTS); i++)
+ for (int i = pointerIndex; (i < CORE.Input.Touch.pointCount - 1) && (i < MAX_TOUCH_POINTS); i++)
{
CORE.Input.Touch.pointId[i] = CORE.Input.Touch.pointId[i+1];
CORE.Input.Touch.position[i] = CORE.Input.Touch.position[i+1];
}
+
CORE.Input.Touch.pointCount--;
}
@@ -5933,10 +6312,17 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
{
gestureEvent.pointId[i] = CORE.Input.Touch.pointId[i];
gestureEvent.position[i] = CORE.Input.Touch.position[i];
+
+ // Normalize gestureEvent.position[i]
+ gestureEvent.position[i].x /= (float)GetScreenWidth();
+ gestureEvent.position[i].y /= (float)GetScreenHeight();
}
// Gesture data is sent to gestures system for processing
ProcessGestureEvent(gestureEvent);
+
+ // Reset the pointCount for web, if it was the last Touch End event
+ if (eventType == EMSCRIPTEN_EVENT_TOUCHEND && CORE.Input.Touch.pointCount == 1) CORE.Input.Touch.pointCount = 0;
#endif
return 1; // The event was consumed by the callback handler
@@ -6015,7 +6401,11 @@ static void ProcessKeyboard(void)
bufferByteCount = read(STDIN_FILENO, keysBuffer, MAX_KEYBUFFER_SIZE); // POSIX system call
// Reset pressed keys array (it will be filled below)
- for (int i = 0; i < MAX_KEYBOARD_KEYS; i++) CORE.Input.Keyboard.currentKeyState[i] = 0;
+ for (int i = 0; i < MAX_KEYBOARD_KEYS; i++)
+ {
+ CORE.Input.Keyboard.currentKeyState[i] = 0;
+ CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
+ }
// Fill all read bytes (looking for keys)
for (int i = 0; i < bufferByteCount; i++)
@@ -6131,7 +6521,11 @@ static void InitEvdevInput(void)
}
// Reset keyboard key state
- for (int i = 0; i < MAX_KEYBOARD_KEYS; i++) CORE.Input.Keyboard.currentKeyState[i] = 0;
+ for (int i = 0; i < MAX_KEYBOARD_KEYS; i++)
+ {
+ CORE.Input.Keyboard.currentKeyState[i] = 0;
+ CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
+ }
// Open the linux directory of "/dev/input"
directory = opendir(DEFAULT_EVDEV_PATH);
@@ -6233,7 +6627,7 @@ static void ConfigureEvdevDevice(char *device)
{
ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absBits)), absBits);
- // Check for absolute movement support (usualy touchscreens, but also joysticks)
+ // Check for absolute movement support (usually touchscreens, but also joysticks)
if (TEST_BIT(absBits, ABS_X) && TEST_BIT(absBits, ABS_Y))
{
hasAbs = true;
@@ -6247,7 +6641,7 @@ static void ConfigureEvdevDevice(char *device)
worker->absRange.height = absinfo.maximum - absinfo.minimum;
}
- // Check for multiple absolute movement support (usualy multitouch touchscreens)
+ // Check for multiple absolute movement support (usually multitouch touchscreens)
if (TEST_BIT(absBits, ABS_MT_POSITION_X) && TEST_BIT(absBits, ABS_MT_POSITION_Y))
{
hasAbsMulti = true;
@@ -6262,7 +6656,7 @@ static void ConfigureEvdevDevice(char *device)
}
}
- // Check for relative movement support (usualy mouse)
+ // Check for relative movement support (usually mouse)
if (TEST_BIT(evBits, EV_REL))
{
ioctl(fd, EVIOCGBIT(EV_REL, sizeof(relBits)), relBits);
@@ -6270,7 +6664,7 @@ static void ConfigureEvdevDevice(char *device)
if (TEST_BIT(relBits, REL_X) && TEST_BIT(relBits, REL_Y)) hasRel = true;
}
- // Check for button support to determine the device type(usualy on all input devices)
+ // Check for button support to determine the device type(usually on all input devices)
if (TEST_BIT(evBits, EV_KEY))
{
ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keyBits)), keyBits);
@@ -6398,7 +6792,7 @@ static void PollKeyboardEvents(void)
// Keyboard button parsing
if ((event.code >= 1) && (event.code <= 255)) //Keyboard keys appear for codes 1 to 255
{
- keycode = keymapUS[event.code & 0xFF]; // The code we get is a scancode so we look up the apropriate keycode
+ keycode = keymapUS[event.code & 0xFF]; // The code we get is a scancode so we look up the appropriate keycode
// Make sure we got a valid keycode
if ((keycode > 0) && (keycode < sizeof(CORE.Input.Keyboard.currentKeyState)))
@@ -6466,7 +6860,7 @@ static void *EventThread(void *arg)
gestureUpdate = true;
}
- if (event.code == REL_WHEEL) CORE.Input.Mouse.currentWheelMove.y += event.value;
+ if (event.code == REL_WHEEL) CORE.Input.Mouse.eventWheelMove.y += event.value;
}
// Absolute movement parsing
@@ -6475,8 +6869,8 @@ static void *EventThread(void *arg)
// Basic movement
if (event.code == ABS_X)
{
- CORE.Input.Mouse.currentPosition.x = (event.value - worker->absRange.x)*CORE.Window.screen.width/worker->absRange.width; // Scale acording to absRange
- CORE.Input.Touch.position[0].x = (event.value - worker->absRange.x)*CORE.Window.screen.width/worker->absRange.width; // Scale acording to absRange
+ CORE.Input.Mouse.currentPosition.x = (event.value - worker->absRange.x)*CORE.Window.screen.width/worker->absRange.width; // Scale according to absRange
+ CORE.Input.Touch.position[0].x = (event.value - worker->absRange.x)*CORE.Window.screen.width/worker->absRange.width; // Scale according to absRange
touchAction = 2; // TOUCH_ACTION_MOVE
gestureUpdate = true;
@@ -6484,8 +6878,8 @@ static void *EventThread(void *arg)
if (event.code == ABS_Y)
{
- CORE.Input.Mouse.currentPosition.y = (event.value - worker->absRange.y)*CORE.Window.screen.height/worker->absRange.height; // Scale acording to absRange
- CORE.Input.Touch.position[0].y = (event.value - worker->absRange.y)*CORE.Window.screen.height/worker->absRange.height; // Scale acording to absRange
+ CORE.Input.Mouse.currentPosition.y = (event.value - worker->absRange.y)*CORE.Window.screen.height/worker->absRange.height; // Scale according to absRange
+ CORE.Input.Touch.position[0].y = (event.value - worker->absRange.y)*CORE.Window.screen.height/worker->absRange.height; // Scale according to absRange
touchAction = 2; // TOUCH_ACTION_MOVE
gestureUpdate = true;
@@ -6496,12 +6890,12 @@ static void *EventThread(void *arg)
if (event.code == ABS_MT_POSITION_X)
{
- if (worker->touchSlot < MAX_TOUCH_POINTS) CORE.Input.Touch.position[worker->touchSlot].x = (event.value - worker->absRange.x)*CORE.Window.screen.width/worker->absRange.width; // Scale acording to absRange
+ if (worker->touchSlot < MAX_TOUCH_POINTS) CORE.Input.Touch.position[worker->touchSlot].x = (event.value - worker->absRange.x)*CORE.Window.screen.width/worker->absRange.width; // Scale according to absRange
}
if (event.code == ABS_MT_POSITION_Y)
{
- if (worker->touchSlot < MAX_TOUCH_POINTS) CORE.Input.Touch.position[worker->touchSlot].y = (event.value - worker->absRange.y)*CORE.Window.screen.height/worker->absRange.height; // Scale acording to absRange
+ if (worker->touchSlot < MAX_TOUCH_POINTS) CORE.Input.Touch.position[worker->touchSlot].y = (event.value - worker->absRange.y)*CORE.Window.screen.height/worker->absRange.height; // Scale according to absRange
}
if (event.code == ABS_MT_TRACKING_ID)
@@ -6569,18 +6963,20 @@ static void *EventThread(void *arg)
if (CORE.Input.Mouse.currentPosition.y > CORE.Window.screen.height/CORE.Input.Mouse.scale.y) CORE.Input.Mouse.currentPosition.y = CORE.Window.screen.height/CORE.Input.Mouse.scale.y;
}
+ // Update touch point count
+ CORE.Input.Touch.pointCount = 0;
+ if (CORE.Input.Touch.position[0].x >= 0) CORE.Input.Touch.pointCount++;
+ if (CORE.Input.Touch.position[1].x >= 0) CORE.Input.Touch.pointCount++;
+ if (CORE.Input.Touch.position[2].x >= 0) CORE.Input.Touch.pointCount++;
+ if (CORE.Input.Touch.position[3].x >= 0) CORE.Input.Touch.pointCount++;
+
#if defined(SUPPORT_GESTURES_SYSTEM) // PLATFORM_RPI, PLATFORM_DRM
if (gestureUpdate)
{
GestureEvent gestureEvent = { 0 };
- gestureEvent.pointCount = 0;
gestureEvent.touchAction = touchAction;
-
- if (CORE.Input.Touch.position[0].x >= 0) gestureEvent.pointCount++;
- if (CORE.Input.Touch.position[1].x >= 0) gestureEvent.pointCount++;
- if (CORE.Input.Touch.position[2].x >= 0) gestureEvent.pointCount++;
- if (CORE.Input.Touch.position[3].x >= 0) gestureEvent.pointCount++;
+ gestureEvent.pointCount = CORE.Input.Touch.pointCount;
gestureEvent.pointId[0] = 0;
gestureEvent.pointId[1] = 1;
@@ -6671,7 +7067,7 @@ static void *GamepadThread(void *arg)
CORE.Input.Gamepad.currentButtonState[i][gamepadEvent.number] = (int)gamepadEvent.value;
if ((int)gamepadEvent.value == 1) CORE.Input.Gamepad.lastButtonPressed = gamepadEvent.number;
- else CORE.Input.Gamepad.lastButtonPressed = -1;
+ else CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN
}
}
else if (gamepadEvent.type == JS_EVENT_AXIS)
@@ -6793,24 +7189,24 @@ static int FindNearestConnectorMode(const drmModeConnector *connector, uint widt
// TODO: This system should probably be redesigned
static void LoadAutomationEvents(const char *fileName)
{
- //unsigned char fileId[4] = { 0 };
-
- // Load binary
+ // Load events file (binary)
/*
FILE *repFile = fopen(fileName, "rb");
- fread(fileId, 4, 1, repFile);
+ unsigned char fileId[4] = { 0 };
+
+ fread(fileId, 1, 4, repFile);
if ((fileId[0] == 'r') && (fileId[1] == 'E') && (fileId[2] == 'P') && (fileId[1] == ' '))
{
fread(&eventCount, sizeof(int), 1, repFile);
- TraceLog(LOG_WARNING, "Events loaded: %i\n", eventCount);
+ TRACELOG(LOG_WARNING, "Events loaded: %i\n", eventCount);
fread(events, sizeof(AutomationEvent), eventCount, repFile);
}
fclose(repFile);
*/
- // Load events (text file)
+ // Load events file (text)
FILE *repFile = fopen(fileName, "rt");
if (repFile != NULL)
@@ -6850,7 +7246,7 @@ static void ExportAutomationEvents(const char *fileName)
// Save as binary
/*
FILE *repFile = fopen(fileName, "wb");
- fwrite(fileId, 4, 1, repFile);
+ fwrite(fileId, sizeof(unsigned char), 4, repFile);
fwrite(&eventCount, sizeof(int), 1, repFile);
fwrite(events, sizeof(AutomationEvent), eventCount, repFile);
fclose(repFile);
diff --git a/src/rgestures.h b/src/rgestures.h
index 1703dbd0d..779dbed56 100644
--- a/src/rgestures.h
+++ b/src/rgestures.h
@@ -2,18 +2,15 @@
*
* rgestures - Gestures system, gestures processing based on input events (touch/mouse)
*
-* NOTE: Memory footprint of this library is aproximately 128 bytes (global variables)
-*
* CONFIGURATION:
+* #define RGESTURES_IMPLEMENTATION
+* Generates the implementation of the library into the included file.
+* If not defined, the library is in header only mode and can be included in other headers
+* or source files without problems. But only ONE file should hold the implementation.
*
-* #define GESTURES_IMPLEMENTATION
-* Generates the implementation of the library into the included file.
-* If not defined, the library is in header only mode and can be included in other headers
-* or source files without problems. But only ONE file should hold the implementation.
-*
-* #define GESTURES_STANDALONE
-* If defined, the library can be used as standalone to process gesture events with
-* no external dependencies.
+* #define RGESTURES_STANDALONE
+* If defined, the library can be used as standalone to process gesture events with
+* no external dependencies.
*
* CONTRIBUTORS:
* Marc Palau: Initial implementation (2014)
@@ -24,7 +21,7 @@
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -59,7 +56,7 @@
//----------------------------------------------------------------------------------
// Types and Structures Definition
-// NOTE: Below types are required for GESTURES_STANDALONE usage
+// NOTE: Below types are required for standalone usage
//----------------------------------------------------------------------------------
// Boolean type
#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
@@ -76,7 +73,7 @@ typedef struct Vector2 {
} Vector2;
#endif
-#if defined(GESTURES_STANDALONE)
+#if defined(RGESTURES_STANDALONE)
// Gestures type
// NOTE: It could be used as flags to enable only some gestures
typedef enum {
@@ -125,12 +122,12 @@ extern "C" { // Prevents name mangling of functions
void ProcessGestureEvent(GestureEvent event); // Process gesture event and translate it into gestures
void UpdateGestures(void); // Update gestures detected (must be called every frame)
-#if defined(GESTURES_STANDALONE)
+#if defined(RGESTURES_STANDALONE)
void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags
bool IsGestureDetected(int gesture); // Check if a gesture have been detected
int GetGestureDetected(void); // Get latest detected gesture
-float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds
+float GetGestureHoldDuration(void); // Get gesture hold time in seconds
Vector2 GetGestureDragVector(void); // Get gesture drag vector
float GetGestureDragAngle(void); // Get gesture drag angle
Vector2 GetGesturePinchVector(void); // Get gesture pinch delta
@@ -141,17 +138,17 @@ float GetGesturePinchAngle(void); // Get gesture pinch ang
}
#endif
-#endif // GESTURES_H
+#endif // RGESTURES_H
/***********************************************************************************
*
-* GESTURES IMPLEMENTATION
+* RGESTURES IMPLEMENTATION
*
************************************************************************************/
-#if defined(GESTURES_IMPLEMENTATION)
+#if defined(RGESTURES_IMPLEMENTATION)
-#if defined(GESTURES_STANDALONE)
+#if defined(RGESTURES_STANDALONE)
#if defined(_WIN32)
#if defined(__cplusplus)
extern "C" { // Prevents name mangling of functions
@@ -181,11 +178,12 @@ float GetGesturePinchAngle(void); // Get gesture pinch ang
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
-#define FORCE_TO_SWIPE 0.0005f // Swipe force, measured in normalized screen units/time
+#define FORCE_TO_SWIPE 0.2f // Swipe force, measured in normalized screen units/time
#define MINIMUM_DRAG 0.015f // Drag minimum force, measured in normalized screen units (0.0f to 1.0f)
+#define DRAG_TIMEOUT 0.3f // Drag minimum time for web, measured in seconds
#define MINIMUM_PINCH 0.005f // Pinch minimum force, measured in normalized screen units (0.0f to 1.0f)
-#define TAP_TIMEOUT 300 // Tap minimum time, measured in milliseconds
-#define PINCH_TIMEOUT 300 // Pinch minimum time, measured in milliseconds
+#define TAP_TIMEOUT 0.3f // Tap minimum time, measured in seconds
+#define PINCH_TIMEOUT 0.3f // Pinch minimum time, measured in seconds
#define DOUBLETAP_RANGE 0.03f // DoubleTap range, measured in normalized screen units (0.0f to 1.0f)
//----------------------------------------------------------------------------------
@@ -206,11 +204,13 @@ typedef struct {
Vector2 downDragPosition; // Touch drag position
Vector2 moveDownPositionA; // First touch down position on move
Vector2 moveDownPositionB; // Second touch down position on move
+ Vector2 previousPositionA; // Previous position A to compare for pinch gestures
+ Vector2 previousPositionB; // Previous position B to compare for pinch gestures
int tapCounter; // TAP counter (one tap implies TOUCH_ACTION_DOWN and TOUCH_ACTION_UP actions)
} Touch;
struct {
bool resetRequired; // HOLD reset to get first touch point again
- double timeDuration; // HOLD duration in milliseconds
+ double timeDuration; // HOLD duration in seconds
} Hold;
struct {
Vector2 vector; // DRAG vector (between initial and current position)
@@ -219,8 +219,7 @@ typedef struct {
float intensity; // DRAG intensity, how far why did the DRAG (pixels per frame)
} Drag;
struct {
- bool start; // SWIPE used to define when start measuring GESTURES.Swipe.timeDuration
- double timeDuration; // SWIPE time to calculate drag intensity
+ double startTime; // SWIPE start time to calculate drag intensity
} Swipe;
struct {
Vector2 vector; // PINCH vector (between first and second touch points)
@@ -249,7 +248,7 @@ static double rgGetCurrentTime(void);
// Module Functions Definition
//----------------------------------------------------------------------------------
-// Enable only desired getures to be detected
+// Enable only desired gestures to be detected
void SetGesturesEnabled(unsigned int flags)
{
GESTURES.enabledFlags = flags;
@@ -292,30 +291,29 @@ void ProcessGestureEvent(GestureEvent event)
GESTURES.Touch.upPosition = GESTURES.Touch.downPositionA;
GESTURES.Touch.eventTime = rgGetCurrentTime();
- GESTURES.Touch.firstId = event.pointId[0];
+ GESTURES.Swipe.startTime = rgGetCurrentTime();
GESTURES.Drag.vector = (Vector2){ 0.0f, 0.0f };
}
else if (event.touchAction == TOUCH_ACTION_UP)
{
- if (GESTURES.current == GESTURE_DRAG) GESTURES.Touch.upPosition = event.position[0];
+ // A swipe can happen while the current gesture is drag, but (specially for web) also hold, so set upPosition for both cases
+ if (GESTURES.current == GESTURE_DRAG || GESTURES.current == GESTURE_HOLD) GESTURES.Touch.upPosition = event.position[0];
- // NOTE: GESTURES.Drag.intensity dependend on the resolution of the screen
+ // NOTE: GESTURES.Drag.intensity dependent on the resolution of the screen
GESTURES.Drag.distance = rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition);
- GESTURES.Drag.intensity = GESTURES.Drag.distance/(float)((rgGetCurrentTime() - GESTURES.Swipe.timeDuration));
-
- GESTURES.Swipe.start = false;
+ GESTURES.Drag.intensity = GESTURES.Drag.distance/(float)((rgGetCurrentTime() - GESTURES.Swipe.startTime));
// Detect GESTURE_SWIPE
- if ((GESTURES.Drag.intensity > FORCE_TO_SWIPE) && (GESTURES.Touch.firstId == event.pointId[0]))
+ if ((GESTURES.Drag.intensity > FORCE_TO_SWIPE) && (GESTURES.current != GESTURE_DRAG))
{
// NOTE: Angle should be inverted in Y
GESTURES.Drag.angle = 360.0f - rgVector2Angle(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition);
- if ((GESTURES.Drag.angle < 30) || (GESTURES.Drag.angle > 330)) GESTURES.current = GESTURE_SWIPE_RIGHT; // Right
- else if ((GESTURES.Drag.angle > 30) && (GESTURES.Drag.angle < 120)) GESTURES.current = GESTURE_SWIPE_UP; // Up
- else if ((GESTURES.Drag.angle > 120) && (GESTURES.Drag.angle < 210)) GESTURES.current = GESTURE_SWIPE_LEFT; // Left
- else if ((GESTURES.Drag.angle > 210) && (GESTURES.Drag.angle < 300)) GESTURES.current = GESTURE_SWIPE_DOWN; // Down
+ if ((GESTURES.Drag.angle < 30) || (GESTURES.Drag.angle > 330)) GESTURES.current = GESTURE_SWIPE_RIGHT; // Right
+ else if ((GESTURES.Drag.angle >= 30) && (GESTURES.Drag.angle <= 150)) GESTURES.current = GESTURE_SWIPE_UP; // Up
+ else if ((GESTURES.Drag.angle > 150) && (GESTURES.Drag.angle < 210)) GESTURES.current = GESTURE_SWIPE_LEFT; // Left
+ else if ((GESTURES.Drag.angle >= 210) && (GESTURES.Drag.angle <= 330)) GESTURES.current = GESTURE_SWIPE_DOWN; // Down
else GESTURES.current = GESTURE_NONE;
}
else
@@ -332,14 +330,6 @@ void ProcessGestureEvent(GestureEvent event)
}
else if (event.touchAction == TOUCH_ACTION_MOVE)
{
- if (GESTURES.current == GESTURE_DRAG) GESTURES.Touch.eventTime = rgGetCurrentTime();
-
- if (!GESTURES.Swipe.start)
- {
- GESTURES.Swipe.timeDuration = rgGetCurrentTime();
- GESTURES.Swipe.start = true;
- }
-
GESTURES.Touch.moveDownPositionA = event.position[0];
if (GESTURES.current == GESTURE_HOLD)
@@ -349,7 +339,7 @@ void ProcessGestureEvent(GestureEvent event)
GESTURES.Hold.resetRequired = false;
// Detect GESTURE_DRAG
- if (rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.moveDownPositionA) >= MINIMUM_DRAG)
+ if ((rgGetCurrentTime() - GESTURES.Touch.eventTime) > DRAG_TIMEOUT)
{
GESTURES.Touch.eventTime = rgGetCurrentTime();
GESTURES.current = GESTURE_DRAG;
@@ -367,6 +357,9 @@ void ProcessGestureEvent(GestureEvent event)
GESTURES.Touch.downPositionA = event.position[0];
GESTURES.Touch.downPositionB = event.position[1];
+ GESTURES.Touch.previousPositionA = GESTURES.Touch.downPositionA;
+ GESTURES.Touch.previousPositionB = GESTURES.Touch.downPositionB;
+
//GESTURES.Pinch.distance = rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.downPositionB);
GESTURES.Pinch.vector.x = GESTURES.Touch.downPositionB.x - GESTURES.Touch.downPositionA.x;
@@ -379,18 +372,15 @@ void ProcessGestureEvent(GestureEvent event)
{
GESTURES.Pinch.distance = rgVector2Distance(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB);
- GESTURES.Touch.downPositionA = GESTURES.Touch.moveDownPositionA;
- GESTURES.Touch.downPositionB = GESTURES.Touch.moveDownPositionB;
-
GESTURES.Touch.moveDownPositionA = event.position[0];
GESTURES.Touch.moveDownPositionB = event.position[1];
GESTURES.Pinch.vector.x = GESTURES.Touch.moveDownPositionB.x - GESTURES.Touch.moveDownPositionA.x;
GESTURES.Pinch.vector.y = GESTURES.Touch.moveDownPositionB.y - GESTURES.Touch.moveDownPositionA.y;
- if ((rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.moveDownPositionA) >= MINIMUM_PINCH) || (rgVector2Distance(GESTURES.Touch.downPositionB, GESTURES.Touch.moveDownPositionB) >= MINIMUM_PINCH))
+ if ((rgVector2Distance(GESTURES.Touch.previousPositionA, GESTURES.Touch.moveDownPositionA) >= MINIMUM_PINCH) || (rgVector2Distance(GESTURES.Touch.previousPositionB, GESTURES.Touch.moveDownPositionB) >= MINIMUM_PINCH))
{
- if ((rgVector2Distance(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB) - GESTURES.Pinch.distance) < 0) GESTURES.current = GESTURE_PINCH_IN;
+ if ( rgVector2Distance(GESTURES.Touch.previousPositionA, GESTURES.Touch.previousPositionB) > rgVector2Distance(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB) ) GESTURES.current = GESTURE_PINCH_IN;
else GESTURES.current = GESTURE_PINCH_OUT;
}
else
@@ -430,13 +420,6 @@ void UpdateGestures(void)
GESTURES.Hold.timeDuration = rgGetCurrentTime();
}
- if (((rgGetCurrentTime() - GESTURES.Touch.eventTime) > TAP_TIMEOUT) && (GESTURES.current == GESTURE_DRAG) && (GESTURES.Touch.pointCount < 2))
- {
- GESTURES.current = GESTURE_HOLD;
- GESTURES.Hold.timeDuration = rgGetCurrentTime();
- GESTURES.Hold.resetRequired = true;
- }
-
// Detect GESTURE_NONE
if ((GESTURES.current == GESTURE_SWIPE_RIGHT) || (GESTURES.current == GESTURE_SWIPE_UP) || (GESTURES.current == GESTURE_SWIPE_LEFT) || (GESTURES.current == GESTURE_SWIPE_DOWN))
{
@@ -472,7 +455,7 @@ Vector2 GetGestureDragVector(void)
}
// Get drag angle
-// NOTE: Angle in degrees, horizontal-right is 0, counterclock-wise
+// NOTE: Angle in degrees, horizontal-right is 0, counterclockwise
float GetGestureDragAngle(void)
{
// NOTE: drag angle is calculated on one touch points TOUCH_ACTION_UP
@@ -488,8 +471,8 @@ Vector2 GetGesturePinchVector(void)
return GESTURES.Pinch.vector;
}
-// Get angle beween two pinch points
-// NOTE: Angle in degrees, horizontal-right is 0, counterclock-wise
+// Get angle between two pinch points
+// NOTE: Angle in degrees, horizontal-right is 0, counterclockwise
float GetGesturePinchAngle(void)
{
// NOTE: pinch angle is calculated on two touch points TOUCH_ACTION_MOVE
@@ -523,12 +506,12 @@ static float rgVector2Distance(Vector2 v1, Vector2 v2)
return result;
}
-// Time measure returned are milliseconds
+// Time measure returned are seconds
static double rgGetCurrentTime(void)
{
double time = 0;
-#if !defined(GESTURES_STANDALONE)
+#if !defined(RGESTURES_STANDALONE)
time = GetTime();
#else
#if defined(_WIN32)
@@ -537,7 +520,7 @@ static double rgGetCurrentTime(void)
QueryPerformanceFrequency(&clockFrequency); // BE CAREFUL: Costly operation!
QueryPerformanceCounter(¤tTime);
- time = (double)currentTime/clockFrequency*1000.0f; // Time in miliseconds
+ time = (double)currentTime/clockFrequency; // Time in seconds
#endif
#if defined(__linux__)
@@ -546,7 +529,7 @@ static double rgGetCurrentTime(void)
clock_gettime(CLOCK_MONOTONIC, &now);
unsigned long long int nowTime = (unsigned long long int)now.tv_sec*1000000000LLU + (unsigned long long int)now.tv_nsec; // Time in nanoseconds
- time = ((double)nowTime/1000000.0); // Time in miliseconds
+ time = ((double)nowTime*1e-9); // Time in seconds
#endif
#if defined(__APPLE__)
@@ -562,11 +545,11 @@ static double rgGetCurrentTime(void)
mach_port_deallocate(mach_task_self(), cclock);
unsigned long long int nowTime = (unsigned long long int)now.tv_sec*1000000000LLU + (unsigned long long int)now.tv_nsec; // Time in nanoseconds
- time = ((double)nowTime/1000000.0); // Time in miliseconds
+ time = ((double)nowTime*1e-9); // Time in seconds
#endif
#endif
return time;
}
-#endif // GESTURES_IMPLEMENTATION
+#endif // RGESTURES_IMPLEMENTATION
diff --git a/src/rglfw.c b/src/rglfw.c
index 61922604c..59f5ad2f8 100644
--- a/src/rglfw.c
+++ b/src/rglfw.c
@@ -7,7 +7,7 @@
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2017-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2017-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -75,7 +75,7 @@
#include "external/glfw/src/win32_time.c"
#include "external/glfw/src/win32_thread.c"
#include "external/glfw/src/wgl_context.c"
-
+
#include "external/glfw/src/egl_context.c"
#include "external/glfw/src/osmesa_context.c"
#endif
@@ -87,10 +87,10 @@
#include "external/glfw/src/posix_poll.c"
#include "external/glfw/src/linux_joystick.c"
#include "external/glfw/src/xkb_unicode.c"
-
+
#include "external/glfw/src/egl_context.c"
#include "external/glfw/src/osmesa_context.c"
-
+
#if defined(_GLFW_WAYLAND)
#include "external/glfw/src/wl_init.c"
#include "external/glfw/src/wl_monitor.c"
@@ -108,9 +108,10 @@
#include "external/glfw/src/posix_module.c"
#include "external/glfw/src/posix_thread.c"
#include "external/glfw/src/posix_time.c"
+ #include "external/glfw/src/posix_poll.c"
#include "external/glfw/src/null_joystick.c"
#include "external/glfw/src/xkb_unicode.c"
-
+
#include "external/glfw/src/x11_init.c"
#include "external/glfw/src/x11_monitor.c"
#include "external/glfw/src/x11_window.c"
@@ -129,7 +130,7 @@
#include "external/glfw/src/cocoa_window.m"
#include "external/glfw/src/cocoa_time.c"
#include "external/glfw/src/nsgl_context.m"
-
+
#include "external/glfw/src/egl_context.c"
#include "external/glfw/src/osmesa_context.c"
#endif
diff --git a/src/rlgl.h b/src/rlgl.h
index ee3c3d91a..f274931e2 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -1,91 +1,90 @@
/**********************************************************************************************
*
-* rlgl v4.2 - A multi-OpenGL abstraction layer with an immediate-mode style API
+* rlgl v4.5 - A multi-OpenGL abstraction layer with an immediate-mode style API
*
-* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0)
-* that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...)
+* DESCRIPTION:
+* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0)
+* that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...)
*
-* When chosing an OpenGL backend different than OpenGL 1.1, some internal buffer are
-* initialized on rlglInit() to accumulate vertex data.
+* ADDITIONAL NOTES:
+* When choosing an OpenGL backend different than OpenGL 1.1, some internal buffer are
+* initialized on rlglInit() to accumulate vertex data.
*
-* When an internal state change is required all the stored vertex data is renderer in batch,
-* additioanlly, rlDrawRenderBatchActive() could be called to force flushing of the batch.
+* When an internal state change is required all the stored vertex data is renderer in batch,
+* additionally, rlDrawRenderBatchActive() could be called to force flushing of the batch.
*
-* Some additional resources are also loaded for convenience, here the complete list:
-* - Default batch (RLGL.defaultBatch): RenderBatch system to accumulate vertex data
-* - Default texture (RLGL.defaultTextureId): 1x1 white pixel R8G8B8A8
-* - Default shader (RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs)
-*
-* Internal buffer (and additional resources) must be manually unloaded calling rlglClose().
+* Some resources are also loaded for convenience, here the complete list:
+* - Default batch (RLGL.defaultBatch): RenderBatch system to accumulate vertex data
+* - Default texture (RLGL.defaultTextureId): 1x1 white pixel R8G8B8A8
+* - Default shader (RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs)
*
+* Internal buffer (and resources) must be manually unloaded calling rlglClose().
*
* CONFIGURATION:
+* #define GRAPHICS_API_OPENGL_11
+* #define GRAPHICS_API_OPENGL_21
+* #define GRAPHICS_API_OPENGL_33
+* #define GRAPHICS_API_OPENGL_43
+* #define GRAPHICS_API_OPENGL_ES2
+* #define GRAPHICS_API_OPENGL_ES3
+* Use selected OpenGL graphics backend, should be supported by platform
+* Those preprocessor defines are only used on rlgl module, if OpenGL version is
+* required by any other module, use rlGetVersion() to check it
*
-* #define GRAPHICS_API_OPENGL_11
-* #define GRAPHICS_API_OPENGL_21
-* #define GRAPHICS_API_OPENGL_33
-* #define GRAPHICS_API_OPENGL_43
-* #define GRAPHICS_API_OPENGL_ES2
-* Use selected OpenGL graphics backend, should be supported by platform
-* Those preprocessor defines are only used on rlgl module, if OpenGL version is
-* required by any other module, use rlGetVersion() to check it
+* #define RLGL_IMPLEMENTATION
+* Generates the implementation of the library into the included file.
+* If not defined, the library is in header only mode and can be included in other headers
+* or source files without problems. But only ONE file should hold the implementation.
*
-* #define RLGL_IMPLEMENTATION
-* Generates the implementation of the library into the included file.
-* If not defined, the library is in header only mode and can be included in other headers
-* or source files without problems. But only ONE file should hold the implementation.
+* #define RLGL_RENDER_TEXTURES_HINT
+* Enable framebuffer objects (fbo) support (enabled by default)
+* Some GPUs could not support them despite the OpenGL version
*
-* #define RLGL_RENDER_TEXTURES_HINT
-* Enable framebuffer objects (fbo) support (enabled by default)
-* Some GPUs could not support them despite the OpenGL version
+* #define RLGL_SHOW_GL_DETAILS_INFO
+* Show OpenGL extensions and capabilities detailed logs on init
*
-* #define RLGL_SHOW_GL_DETAILS_INFO
-* Show OpenGL extensions and capabilities detailed logs on init
+* #define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
+* Enable debug context (only available on OpenGL 4.3)
*
-* #define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
-* Enable debug context (only available on OpenGL 4.3)
+* rlgl capabilities could be customized just defining some internal
+* values before library inclusion (default values listed):
*
-* rlgl capabilities could be customized just defining some internal
-* values before library inclusion (default values listed):
+* #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192 // Default internal render batch elements limits
+* #define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
+* #define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
+* #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
*
-* #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192 // Default internal render batch elements limits
-* #define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
-* #define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
-* #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
+* #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
+* #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
+* #define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance
+* #define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance
*
-* #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
-* #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
-* #define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance
-* #define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance
+* When loading a shader, the following vertex attribute and uniform
+* location names are tried to be set automatically:
*
-* When loading a shader, the following vertex attribute and uniform
-* location names are tried to be set automatically:
-*
-* #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Binded by default to shader location: 0
-* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Binded by default to shader location: 1
-* #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Binded by default to shader location: 2
-* #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Binded by default to shader location: 3
-* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Binded by default to shader location: 4
-* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Binded by default to shader location: 5
-* #define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix
-* #define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix
-* #define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix
-* #define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix
-* #define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView))
-* #define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color)
-* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0)
-* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1)
-* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2)
+* #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: 0
+* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: 1
+* #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: 2
+* #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: 3
+* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: 4
+* #define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix
+* #define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix
+* #define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix
+* #define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix
+* #define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView))
+* #define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color)
+* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0)
+* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1)
+* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2)
*
* DEPENDENCIES:
-*
* - OpenGL libraries (depending on platform and OpenGL version selected)
* - GLAD OpenGL extensions loading library (only for OpenGL 3.3 Core, 4.3 Core)
*
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -107,7 +106,7 @@
#ifndef RLGL_H
#define RLGL_H
-#define RLGL_VERSION "4.2"
+#define RLGL_VERSION "4.5"
// Function specifiers in case library is build/used as a shared library (Windows)
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
@@ -149,7 +148,8 @@
!defined(GRAPHICS_API_OPENGL_21) && \
!defined(GRAPHICS_API_OPENGL_33) && \
!defined(GRAPHICS_API_OPENGL_43) && \
- !defined(GRAPHICS_API_OPENGL_ES2)
+ !defined(GRAPHICS_API_OPENGL_ES2) && \
+ !defined(GRAPHICS_API_OPENGL_ES3)
#define GRAPHICS_API_OPENGL_33
#endif
@@ -180,6 +180,11 @@
#define GRAPHICS_API_OPENGL_33
#endif
+// OpenGL ES 3.0 uses OpenGL ES 2.0 functionality (and more)
+#if defined(GRAPHICS_API_OPENGL_ES3)
+ #define GRAPHICS_API_OPENGL_ES2
+#endif
+
// Support framebuffer objects by default
// NOTE: Some driver implementation do not support it, despite they should
#define RLGL_RENDER_TEXTURES_HINT
@@ -264,7 +269,7 @@
#define RL_UNSIGNED_BYTE 0x1401 // GL_UNSIGNED_BYTE
#define RL_FLOAT 0x1406 // GL_FLOAT
-// Buffer usage hint
+// GL buffer usage hint
#define RL_STREAM_DRAW 0x88E0 // GL_STREAM_DRAW
#define RL_STREAM_READ 0x88E1 // GL_STREAM_READ
#define RL_STREAM_COPY 0x88E2 // GL_STREAM_COPY
@@ -280,6 +285,39 @@
#define RL_VERTEX_SHADER 0x8B31 // GL_VERTEX_SHADER
#define RL_COMPUTE_SHADER 0x91B9 // GL_COMPUTE_SHADER
+// GL blending factors
+#define RL_ZERO 0 // GL_ZERO
+#define RL_ONE 1 // GL_ONE
+#define RL_SRC_COLOR 0x0300 // GL_SRC_COLOR
+#define RL_ONE_MINUS_SRC_COLOR 0x0301 // GL_ONE_MINUS_SRC_COLOR
+#define RL_SRC_ALPHA 0x0302 // GL_SRC_ALPHA
+#define RL_ONE_MINUS_SRC_ALPHA 0x0303 // GL_ONE_MINUS_SRC_ALPHA
+#define RL_DST_ALPHA 0x0304 // GL_DST_ALPHA
+#define RL_ONE_MINUS_DST_ALPHA 0x0305 // GL_ONE_MINUS_DST_ALPHA
+#define RL_DST_COLOR 0x0306 // GL_DST_COLOR
+#define RL_ONE_MINUS_DST_COLOR 0x0307 // GL_ONE_MINUS_DST_COLOR
+#define RL_SRC_ALPHA_SATURATE 0x0308 // GL_SRC_ALPHA_SATURATE
+#define RL_CONSTANT_COLOR 0x8001 // GL_CONSTANT_COLOR
+#define RL_ONE_MINUS_CONSTANT_COLOR 0x8002 // GL_ONE_MINUS_CONSTANT_COLOR
+#define RL_CONSTANT_ALPHA 0x8003 // GL_CONSTANT_ALPHA
+#define RL_ONE_MINUS_CONSTANT_ALPHA 0x8004 // GL_ONE_MINUS_CONSTANT_ALPHA
+
+// GL blending functions/equations
+#define RL_FUNC_ADD 0x8006 // GL_FUNC_ADD
+#define RL_MIN 0x8007 // GL_MIN
+#define RL_MAX 0x8008 // GL_MAX
+#define RL_FUNC_SUBTRACT 0x800A // GL_FUNC_SUBTRACT
+#define RL_FUNC_REVERSE_SUBTRACT 0x800B // GL_FUNC_REVERSE_SUBTRACT
+#define RL_BLEND_EQUATION 0x8009 // GL_BLEND_EQUATION
+#define RL_BLEND_EQUATION_RGB 0x8009 // GL_BLEND_EQUATION_RGB // (Same as BLEND_EQUATION)
+#define RL_BLEND_EQUATION_ALPHA 0x883D // GL_BLEND_EQUATION_ALPHA
+#define RL_BLEND_DST_RGB 0x80C8 // GL_BLEND_DST_RGB
+#define RL_BLEND_SRC_RGB 0x80C9 // GL_BLEND_SRC_RGB
+#define RL_BLEND_DST_ALPHA 0x80CA // GL_BLEND_DST_ALPHA
+#define RL_BLEND_SRC_ALPHA 0x80CB // GL_BLEND_SRC_ALPHA
+#define RL_BLEND_COLOR 0x8005 // GL_BLEND_COLOR
+
+
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
@@ -351,7 +389,8 @@ typedef enum {
RL_OPENGL_21, // OpenGL 2.1 (GLSL 120)
RL_OPENGL_33, // OpenGL 3.3 (GLSL 330)
RL_OPENGL_43, // OpenGL 4.3 (using GLSL 330)
- RL_OPENGL_ES_20 // OpenGL ES 2.0 (GLSL 100)
+ RL_OPENGL_ES_20, // OpenGL ES 2.0 (GLSL 100)
+ RL_OPENGL_ES_30 // OpenGL ES 3.0 (GLSL 300 es)
} rlGlVersion;
// Trace log level
@@ -380,6 +419,9 @@ typedef enum {
RL_PIXELFORMAT_UNCOMPRESSED_R32, // 32 bpp (1 channel - float)
RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float)
RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float)
+ RL_PIXELFORMAT_UNCOMPRESSED_R16, // 16 bpp (1 channel - half float)
+ RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16, // 16*3 bpp (3 channels - half float)
+ RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16, // 16*4 bpp (4 channels - half float)
RL_PIXELFORMAT_COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA, // 8 bpp
@@ -413,7 +455,8 @@ typedef enum {
RL_BLEND_ADD_COLORS, // Blend textures adding colors (alternative)
RL_BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative)
RL_BLEND_ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha
- RL_BLEND_CUSTOM // Blend textures using custom src/dst factors (use rlSetBlendFactors())
+ RL_BLEND_CUSTOM, // Blend textures using custom src/dst factors (use rlSetBlendFactors())
+ RL_BLEND_CUSTOM_SEPARATE // Blend textures using custom src/dst factors (use rlSetBlendFactorsSeparate())
} rlBlendMode;
// Shader location point type
@@ -449,7 +492,7 @@ typedef enum {
#define RL_SHADER_LOC_MAP_DIFFUSE RL_SHADER_LOC_MAP_ALBEDO
#define RL_SHADER_LOC_MAP_SPECULAR RL_SHADER_LOC_MAP_METALNESS
-// Shader uniform data type
+// Shader uniform data type
typedef enum {
RL_SHADER_UNIFORM_FLOAT = 0, // Shader uniform type: float
RL_SHADER_UNIFORM_VEC2, // Shader uniform type: vec2 (2 float)
@@ -471,18 +514,18 @@ typedef enum {
} rlShaderAttributeDataType;
// Framebuffer attachment type
-// NOTE: By default up to 8 color channels defined but it can be more
+// NOTE: By default up to 8 color channels defined, but it can be more
typedef enum {
- RL_ATTACHMENT_COLOR_CHANNEL0 = 0, // Framebuffer attachmment type: color 0
- RL_ATTACHMENT_COLOR_CHANNEL1, // Framebuffer attachmment type: color 1
- RL_ATTACHMENT_COLOR_CHANNEL2, // Framebuffer attachmment type: color 2
- RL_ATTACHMENT_COLOR_CHANNEL3, // Framebuffer attachmment type: color 3
- RL_ATTACHMENT_COLOR_CHANNEL4, // Framebuffer attachmment type: color 4
- RL_ATTACHMENT_COLOR_CHANNEL5, // Framebuffer attachmment type: color 5
- RL_ATTACHMENT_COLOR_CHANNEL6, // Framebuffer attachmment type: color 6
- RL_ATTACHMENT_COLOR_CHANNEL7, // Framebuffer attachmment type: color 7
- RL_ATTACHMENT_DEPTH = 100, // Framebuffer attachmment type: depth
- RL_ATTACHMENT_STENCIL = 200, // Framebuffer attachmment type: stencil
+ RL_ATTACHMENT_COLOR_CHANNEL0 = 0, // Framebuffer attachment type: color 0
+ RL_ATTACHMENT_COLOR_CHANNEL1, // Framebuffer attachment type: color 1
+ RL_ATTACHMENT_COLOR_CHANNEL2, // Framebuffer attachment type: color 2
+ RL_ATTACHMENT_COLOR_CHANNEL3, // Framebuffer attachment type: color 3
+ RL_ATTACHMENT_COLOR_CHANNEL4, // Framebuffer attachment type: color 4
+ RL_ATTACHMENT_COLOR_CHANNEL5, // Framebuffer attachment type: color 5
+ RL_ATTACHMENT_COLOR_CHANNEL6, // Framebuffer attachment type: color 6
+ RL_ATTACHMENT_COLOR_CHANNEL7, // Framebuffer attachment type: color 7
+ RL_ATTACHMENT_DEPTH = 100, // Framebuffer attachment type: depth
+ RL_ATTACHMENT_STENCIL = 200, // Framebuffer attachment type: stencil
} rlFramebufferAttachType;
// Framebuffer texture attachment type
@@ -497,6 +540,12 @@ typedef enum {
RL_ATTACHMENT_RENDERBUFFER = 200, // Framebuffer texture attachment type: renderbuffer
} rlFramebufferAttachTextureType;
+// Face culling mode
+typedef enum {
+ RL_CULL_FACE_FRONT = 0,
+ RL_CULL_FACE_BACK
+} rlCullMode;
+
//------------------------------------------------------------------------------------
// Functions Declaration - Matrix operations
//------------------------------------------------------------------------------------
@@ -507,12 +556,12 @@ extern "C" { // Prevents name mangling of functions
RLAPI void rlMatrixMode(int mode); // Choose the current matrix to be transformed
RLAPI void rlPushMatrix(void); // Push the current matrix to stack
-RLAPI void rlPopMatrix(void); // Pop lattest inserted matrix from stack
+RLAPI void rlPopMatrix(void); // Pop latest inserted matrix from stack
RLAPI void rlLoadIdentity(void); // Reset current matrix to identity matrix
RLAPI void rlTranslatef(float x, float y, float z); // Multiply the current matrix by a translation matrix
RLAPI void rlRotatef(float angle, float x, float y, float z); // Multiply the current matrix by a rotation matrix
RLAPI void rlScalef(float x, float y, float z); // Multiply the current matrix by a scaling matrix
-RLAPI void rlMultMatrixf(float *matf); // Multiply the current matrix by another matrix
+RLAPI void rlMultMatrixf(const float *matf); // Multiply the current matrix by another matrix
RLAPI void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar);
RLAPI void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar);
RLAPI void rlViewport(int x, int y, int width, int height); // Set the viewport area
@@ -558,6 +607,7 @@ RLAPI void rlDisableTexture(void); // Disable texture
RLAPI void rlEnableTextureCubemap(unsigned int id); // Enable texture cubemap
RLAPI void rlDisableTextureCubemap(void); // Disable texture cubemap
RLAPI void rlTextureParameters(unsigned int id, int param, int value); // Set texture parameters (filter, wrap)
+RLAPI void rlCubemapParameters(unsigned int id, int param, int value); // Set cubemap parameters (filter, wrap)
// Shader state
RLAPI void rlEnableShader(unsigned int id); // Enable shader program
@@ -577,6 +627,7 @@ RLAPI void rlEnableDepthMask(void); // Enable depth write
RLAPI void rlDisableDepthMask(void); // Disable depth write
RLAPI void rlEnableBackfaceCulling(void); // Enable backface culling
RLAPI void rlDisableBackfaceCulling(void); // Disable backface culling
+RLAPI void rlSetCullFace(int mode); // Set face culling mode
RLAPI void rlEnableScissorTest(void); // Enable scissor test
RLAPI void rlDisableScissorTest(void); // Disable scissor test
RLAPI void rlScissor(int x, int y, int width, int height); // Scissor test
@@ -595,13 +646,14 @@ RLAPI void rlClearScreenBuffers(void); // Clear used screen buf
RLAPI void rlCheckErrors(void); // Check and log OpenGL error codes
RLAPI void rlSetBlendMode(int mode); // Set blending mode
RLAPI void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation); // Set blending mode factor and equation (using OpenGL factors)
+RLAPI void rlSetBlendFactorsSeparate(int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha); // Set blending mode factors and equations separately (using OpenGL factors)
//------------------------------------------------------------------------------------
// Functions Declaration - rlgl functionality
//------------------------------------------------------------------------------------
// rlgl initialization functions
RLAPI void rlglInit(int width, int height); // Initialize rlgl (buffers, shaders, textures, states)
-RLAPI void rlglClose(void); // De-inititialize rlgl (buffers, shaders, textures)
+RLAPI void rlglClose(void); // De-initialize rlgl (buffers, shaders, textures)
RLAPI void rlLoadExtensions(void *loader); // Load OpenGL extensions (loader function required)
RLAPI int rlGetVersion(void); // Get current OpenGL version
RLAPI void rlSetFramebufferWidth(int width); // Set current framebuffer width
@@ -675,7 +727,7 @@ RLAPI void rlSetShader(unsigned int id, int *locs);
// Compute shader management
RLAPI unsigned int rlLoadComputeShaderProgram(unsigned int shaderId); // Load compute shader program
-RLAPI void rlComputeShaderDispatch(unsigned int groupX, unsigned int groupY, unsigned int groupZ); // Dispatch compute shader (equivalent to *draw* for graphics pilepine)
+RLAPI void rlComputeShaderDispatch(unsigned int groupX, unsigned int groupY, unsigned int groupZ); // Dispatch compute shader (equivalent to *draw* for graphics pipeline)
// Shader buffer storage object management (ssbo)
RLAPI unsigned int rlLoadShaderBuffer(unsigned int size, const void *data, int usageHint); // Load shader storage buffer object (SSBO)
@@ -687,7 +739,7 @@ RLAPI void rlCopyShaderBuffer(unsigned int destId, unsigned int srcId, unsigned
RLAPI unsigned int rlGetShaderBufferSize(unsigned int id); // Get SSBO buffer size
// Buffer management
-RLAPI void rlBindImageTexture(unsigned int id, unsigned int index, unsigned int format, int readonly); // Bind image texture
+RLAPI void rlBindImageTexture(unsigned int id, unsigned int index, int format, bool readonly); // Bind image texture
// Matrix state management
RLAPI Matrix rlGetMatrixModelview(void); // Get internal modelview matrix
@@ -749,10 +801,17 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad
#endif
#if defined(GRAPHICS_API_OPENGL_ES2)
- #define GL_GLEXT_PROTOTYPES
- //#include // EGL library -> not required, platform layer
- #include // OpenGL ES 2.0 library
- #include // OpenGL ES 2.0 extensions library
+ // NOTE: OpenGL ES 2.0 can be enabled on PLATFORM_DESKTOP,
+ // in that case, functions are loaded from a custom glad for OpenGL ES 2.0
+ #if defined(PLATFORM_DESKTOP)
+ #define GLAD_GLES2_IMPLEMENTATION
+ #include "external/glad_gles2.h"
+ #else
+ #define GL_GLEXT_PROTOTYPES
+ //#include // EGL library -> not required, platform layer
+ #include // OpenGL ES 2.0 library
+ #include // OpenGL ES 2.0 extensions library
+ #endif
// It seems OpenGL ES 2.0 instancing entry points are not defined on Raspberry Pi
// provided headers (despite being defined in official Khronos GLES2 headers)
@@ -844,22 +903,22 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad
// Default shader vertex attribute names to set location points
#ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION
- #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Binded by default to shader location: 0
+ #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: 0
#endif
#ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD
- #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Binded by default to shader location: 1
+ #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: 1
#endif
#ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL
- #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Binded by default to shader location: 2
+ #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: 2
#endif
#ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR
- #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Binded by default to shader location: 3
+ #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: 3
#endif
#ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT
- #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Binded by default to shader location: 4
+ #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: 4
#endif
#ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2
- #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Binded by default to shader location: 5
+ #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: 5
#endif
#ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_MVP
@@ -926,10 +985,18 @@ typedef struct rlglData {
Matrix projectionStereo[2]; // VR stereo rendering eyes projection matrices
Matrix viewOffsetStereo[2]; // VR stereo rendering eyes view offset matrices
+ // Blending variables
int currentBlendMode; // Blending mode active
int glBlendSrcFactor; // Blending source factor
int glBlendDstFactor; // Blending destination factor
int glBlendEquation; // Blending equation
+ int glBlendSrcFactorRGB; // Blending source RGB factor
+ int glBlendDestFactorRGB; // Blending destination RGB factor
+ int glBlendSrcFactorAlpha; // Blending source alpha factor
+ int glBlendDestFactorAlpha; // Blending destination alpha factor
+ int glBlendEquationRGB; // Blending equation for RGB
+ int glBlendEquationAlpha; // Blending equation for alpha
+ bool glCustomBlendModeModified; // Custom blending factor and equation modification status
int framebufferWidth; // Current framebuffer width
int framebufferHeight; // Current framebuffer height
@@ -939,8 +1006,10 @@ typedef struct rlglData {
bool vao; // VAO support (OpenGL ES2 could not support VAO extension) (GL_ARB_vertex_array_object)
bool instancing; // Instancing supported (GL_ANGLE_instanced_arrays, GL_EXT_draw_instanced + GL_EXT_instanced_arrays)
bool texNPOT; // NPOT textures full support (GL_ARB_texture_non_power_of_two, GL_OES_texture_npot)
- bool texDepth; // Depth textures supported (GL_ARB_depth_texture, GL_WEBGL_depth_texture, GL_OES_depth_texture)
+ bool texDepth; // Depth textures supported (GL_ARB_depth_texture, GL_OES_depth_texture)
+ bool texDepthWebGL; // Depth textures supported WebGL specific (GL_WEBGL_depth_texture)
bool texFloat32; // float textures support (32 bit per channel) (GL_OES_texture_float)
+ bool texFloat16; // half float textures support (16 bit per channel) (GL_OES_texture_half_float)
bool texCompDXT; // DDS texture compression support (GL_EXT_texture_compression_s3tc, GL_WEBGL_compressed_texture_s3tc, GL_WEBKIT_WEBGL_compressed_texture_s3tc)
bool texCompETC1; // ETC1 texture compression support (GL_OES_compressed_ETC1_RGB8_texture, GL_WEBGL_compressed_texture_etc1)
bool texCompETC2; // ETC2/EAC texture compression support (GL_ARB_ES3_compatibility)
@@ -1031,7 +1100,7 @@ void rlLoadIdentity(void) { glLoadIdentity(); }
void rlTranslatef(float x, float y, float z) { glTranslatef(x, y, z); }
void rlRotatef(float angle, float x, float y, float z) { glRotatef(angle, x, y, z); }
void rlScalef(float x, float y, float z) { glScalef(x, y, z); }
-void rlMultMatrixf(float *matf) { glMultMatrixf(matf); }
+void rlMultMatrixf(const float *matf) { glMultMatrixf(matf); }
#endif
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
// Choose the current matrix to be transformed
@@ -1156,7 +1225,7 @@ void rlScalef(float x, float y, float z)
}
// Multiply the current matrix by another matrix
-void rlMultMatrixf(float *matf)
+void rlMultMatrixf(const float *matf)
{
// Matrix creation from array
Matrix mat = { matf[0], matf[4], matf[8], matf[12],
@@ -1358,8 +1427,7 @@ void rlVertex3f(float x, float y, float z)
RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].texcoords[2*RLGL.State.vertexCounter] = RLGL.State.texcoordx;
RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].texcoords[2*RLGL.State.vertexCounter + 1] = RLGL.State.texcoordy;
- // TODO: Add current normal
- // By default rlVertexBuffer type does not store normals
+ // WARNING: By default rlVertexBuffer struct does not store normals
// Add current color
RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].colors[4*RLGL.State.vertexCounter] = RLGL.State.colorr;
@@ -1568,6 +1636,50 @@ void rlTextureParameters(unsigned int id, int param, int value)
glBindTexture(GL_TEXTURE_2D, 0);
}
+// Set cubemap parameters (wrap mode/filter mode)
+void rlCubemapParameters(unsigned int id, int param, int value)
+{
+#if !defined(GRAPHICS_API_OPENGL_11)
+ glBindTexture(GL_TEXTURE_CUBE_MAP, id);
+
+ // Reset anisotropy filter, in case it was set
+ glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
+
+ switch (param)
+ {
+ case RL_TEXTURE_WRAP_S:
+ case RL_TEXTURE_WRAP_T:
+ {
+ if (value == RL_TEXTURE_WRAP_MIRROR_CLAMP)
+ {
+ if (RLGL.ExtSupported.texMirrorClamp) glTexParameteri(GL_TEXTURE_CUBE_MAP, param, value);
+ else TRACELOG(RL_LOG_WARNING, "GL: Clamp mirror wrap mode not supported (GL_MIRROR_CLAMP_EXT)");
+ }
+ else glTexParameteri(GL_TEXTURE_CUBE_MAP, param, value);
+
+ } break;
+ case RL_TEXTURE_MAG_FILTER:
+ case RL_TEXTURE_MIN_FILTER: glTexParameteri(GL_TEXTURE_CUBE_MAP, param, value); break;
+ case RL_TEXTURE_FILTER_ANISOTROPIC:
+ {
+ if (value <= RLGL.ExtSupported.maxAnisotropyLevel) glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value);
+ else if (RLGL.ExtSupported.maxAnisotropyLevel > 0.0f)
+ {
+ TRACELOG(RL_LOG_WARNING, "GL: Maximum anisotropic filter level supported is %iX", id, (int)RLGL.ExtSupported.maxAnisotropyLevel);
+ glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value);
+ }
+ else TRACELOG(RL_LOG_WARNING, "GL: Anisotropic filtering not supported");
+ } break;
+#if defined(GRAPHICS_API_OPENGL_33)
+ case RL_TEXTURE_MIPMAP_BIAS_RATIO: glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_LOD_BIAS, value/100.0f);
+#endif
+ default: break;
+ }
+
+ glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
+#endif
+}
+
// Enable shader program
void rlEnableShader(unsigned int id)
{
@@ -1604,7 +1716,7 @@ void rlDisableFramebuffer(void)
// NOTE: One color buffer is always active by default
void rlActiveDrawBuffers(int count)
{
-#if (defined(GRAPHICS_API_OPENGL_33) && defined(RLGL_RENDER_TEXTURES_HINT))
+#if ((defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3)) && defined(RLGL_RENDER_TEXTURES_HINT))
// NOTE: Maximum number of draw buffers supported is implementation dependant,
// it can be queried with glGet*() but it must be at least 8
//GLint maxDrawBuffers = 0;
@@ -1616,6 +1728,16 @@ void rlActiveDrawBuffers(int count)
else
{
unsigned int buffers[8] = {
+#if defined(GRAPHICS_API_OPENGL_ES3)
+ GL_COLOR_ATTACHMENT0_EXT,
+ GL_COLOR_ATTACHMENT1_EXT,
+ GL_COLOR_ATTACHMENT2_EXT,
+ GL_COLOR_ATTACHMENT3_EXT,
+ GL_COLOR_ATTACHMENT4_EXT,
+ GL_COLOR_ATTACHMENT5_EXT,
+ GL_COLOR_ATTACHMENT6_EXT,
+ GL_COLOR_ATTACHMENT7_EXT,
+#else
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2,
@@ -1624,9 +1746,14 @@ void rlActiveDrawBuffers(int count)
GL_COLOR_ATTACHMENT5,
GL_COLOR_ATTACHMENT6,
GL_COLOR_ATTACHMENT7,
+#endif
};
+#if defined(GRAPHICS_API_OPENGL_ES3)
+ glDrawBuffersEXT(count, buffers);
+#else
glDrawBuffers(count, buffers);
+#endif
}
}
else TRACELOG(LOG_WARNING, "GL: One color buffer active by default");
@@ -1661,6 +1788,17 @@ void rlEnableBackfaceCulling(void) { glEnable(GL_CULL_FACE); }
// Disable backface culling
void rlDisableBackfaceCulling(void) { glDisable(GL_CULL_FACE); }
+// Set face culling mode
+void rlSetCullFace(int mode)
+{
+ switch (mode)
+ {
+ case RL_CULL_FACE_BACK: glCullFace(GL_BACK); break;
+ case RL_CULL_FACE_FRONT: glCullFace(GL_FRONT); break;
+ default: break;
+ }
+}
+
// Enable scissor test
void rlEnableScissorTest(void) { glEnable(GL_SCISSOR_TEST); }
@@ -1788,7 +1926,7 @@ void rlCheckErrors()
void rlSetBlendMode(int mode)
{
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
- if (RLGL.State.currentBlendMode != mode)
+ if ((RLGL.State.currentBlendMode != mode) || ((mode == RL_BLEND_CUSTOM || mode == RL_BLEND_CUSTOM_SEPARATE) && RLGL.State.glCustomBlendModeModified))
{
rlDrawRenderBatch(RLGL.currentBatch);
@@ -1804,11 +1942,20 @@ void rlSetBlendMode(int mode)
{
// NOTE: Using GL blend src/dst factors and GL equation configured with rlSetBlendFactors()
glBlendFunc(RLGL.State.glBlendSrcFactor, RLGL.State.glBlendDstFactor); glBlendEquation(RLGL.State.glBlendEquation);
+
+ } break;
+ case RL_BLEND_CUSTOM_SEPARATE:
+ {
+ // NOTE: Using GL blend src/dst factors and GL equation configured with rlSetBlendFactorsSeparate()
+ glBlendFuncSeparate(RLGL.State.glBlendSrcFactorRGB, RLGL.State.glBlendDestFactorRGB, RLGL.State.glBlendSrcFactorAlpha, RLGL.State.glBlendDestFactorAlpha);
+ glBlendEquationSeparate(RLGL.State.glBlendEquationRGB, RLGL.State.glBlendEquationAlpha);
+
} break;
default: break;
}
RLGL.State.currentBlendMode = mode;
+ RLGL.State.glCustomBlendModeModified = false;
}
#endif
}
@@ -1817,9 +1964,39 @@ void rlSetBlendMode(int mode)
void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation)
{
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
- RLGL.State.glBlendSrcFactor = glSrcFactor;
- RLGL.State.glBlendDstFactor = glDstFactor;
- RLGL.State.glBlendEquation = glEquation;
+ if ((RLGL.State.glBlendSrcFactor != glSrcFactor) ||
+ (RLGL.State.glBlendDstFactor != glDstFactor) ||
+ (RLGL.State.glBlendEquation != glEquation))
+ {
+ RLGL.State.glBlendSrcFactor = glSrcFactor;
+ RLGL.State.glBlendDstFactor = glDstFactor;
+ RLGL.State.glBlendEquation = glEquation;
+
+ RLGL.State.glCustomBlendModeModified = true;
+ }
+#endif
+}
+
+// Set blending mode factor and equation separately for RGB and alpha
+void rlSetBlendFactorsSeparate(int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha)
+{
+#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
+ if ((RLGL.State.glBlendSrcFactorRGB != glSrcRGB) ||
+ (RLGL.State.glBlendDestFactorRGB != glDstRGB) ||
+ (RLGL.State.glBlendSrcFactorAlpha != glSrcAlpha) ||
+ (RLGL.State.glBlendDestFactorAlpha != glDstAlpha) ||
+ (RLGL.State.glBlendEquationRGB != glEqRGB) ||
+ (RLGL.State.glBlendEquationAlpha != glEqAlpha))
+ {
+ RLGL.State.glBlendSrcFactorRGB = glSrcRGB;
+ RLGL.State.glBlendDestFactorRGB = glDstRGB;
+ RLGL.State.glBlendSrcFactorAlpha = glSrcAlpha;
+ RLGL.State.glBlendDestFactorAlpha = glDstAlpha;
+ RLGL.State.glBlendEquationRGB = glEqRGB;
+ RLGL.State.glBlendEquationAlpha = glEqAlpha;
+
+ RLGL.State.glCustomBlendModeModified = true;
+ }
#endif
}
@@ -1895,7 +2072,7 @@ void rlglInit(int width, int height)
if ((glDebugMessageCallback != NULL) && (glDebugMessageControl != NULL))
{
glDebugMessageCallback(rlDebugMessageCallback, 0);
- // glDebugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, GL_DEBUG_SEVERITY_HIGH, 0, 0, GL_TRUE); // TODO: Filter message
+ // glDebugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, GL_DEBUG_SEVERITY_HIGH, 0, 0, GL_TRUE);
// Debug context options:
// - GL_DEBUG_OUTPUT - Faster version but not useful for breakpoints
@@ -2016,6 +2193,7 @@ void rlLoadExtensions(void *loader)
RLGL.ExtSupported.instancing = (GLAD_GL_EXT_draw_instanced && GLAD_GL_ARB_instanced_arrays);
RLGL.ExtSupported.texNPOT = GLAD_GL_ARB_texture_non_power_of_two;
RLGL.ExtSupported.texFloat32 = GLAD_GL_ARB_texture_float;
+ RLGL.ExtSupported.texFloat16 = GLAD_GL_ARB_texture_float;
RLGL.ExtSupported.texDepth = GLAD_GL_ARB_depth_texture;
RLGL.ExtSupported.maxDepthBits = 32;
RLGL.ExtSupported.texAnisoFilter = GLAD_GL_EXT_texture_filter_anisotropic;
@@ -2027,6 +2205,7 @@ void rlLoadExtensions(void *loader)
RLGL.ExtSupported.instancing = true;
RLGL.ExtSupported.texNPOT = true;
RLGL.ExtSupported.texFloat32 = true;
+ RLGL.ExtSupported.texFloat16 = true;
RLGL.ExtSupported.texDepth = true;
RLGL.ExtSupported.maxDepthBits = 32;
RLGL.ExtSupported.texAnisoFilter = true;
@@ -2044,7 +2223,37 @@ void rlLoadExtensions(void *loader)
#endif // GRAPHICS_API_OPENGL_33
-#if defined(GRAPHICS_API_OPENGL_ES2)
+#if defined(GRAPHICS_API_OPENGL_ES3)
+ // Register supported extensions flags
+ // OpenGL ES 3.0 extensions supported by default
+ RLGL.ExtSupported.vao = true;
+ RLGL.ExtSupported.instancing = true;
+ RLGL.ExtSupported.texNPOT = true;
+ RLGL.ExtSupported.texFloat32 = true;
+ RLGL.ExtSupported.texFloat16 = true;
+ RLGL.ExtSupported.texDepth = true;
+ RLGL.ExtSupported.texDepthWebGL = true;
+ RLGL.ExtSupported.maxDepthBits = 24;
+ RLGL.ExtSupported.texAnisoFilter = true;
+ RLGL.ExtSupported.texMirrorClamp = true;
+ // TODO: Make sure that the ones above are actually present by default
+ // TODO: Check for these...
+ // RLGL.ExtSupported.texCompDXT
+ // RLGL.ExtSupported.texCompETC1
+ // RLGL.ExtSupported.texCompETC2
+ // RLGL.ExtSupported.texCompPVRT
+ // RLGL.ExtSupported.texCompASTC
+ // RLGL.ExtSupported.computeShader
+ // RLGL.ExtSupported.ssbo
+ // RLGL.ExtSupported.maxAnisotropyLevel
+#elif defined(GRAPHICS_API_OPENGL_ES2)
+
+ #if defined(PLATFORM_DESKTOP)
+ // TODO: Support OpenGL ES 3.0
+ if (gladLoadGLES2((GLADloadfunc)loader) == 0) TRACELOG(RL_LOG_WARNING, "GLAD: Cannot load OpenGL ES2.0 functions");
+ else TRACELOG(RL_LOG_INFO, "GLAD: OpenGL ES 2.0 loaded successfully");
+ #endif
+
// Get supported extensions list
GLint numExt = 0;
const char **extList = RL_MALLOC(512*sizeof(const char *)); // Allocate 512 strings pointers (2 KB)
@@ -2118,13 +2327,15 @@ void rlLoadExtensions(void *loader)
// Check texture float support
if (strcmp(extList[i], (const char *)"GL_OES_texture_float") == 0) RLGL.ExtSupported.texFloat32 = true;
+ if (strcmp(extList[i], (const char *)"GL_OES_texture_half_float") == 0) RLGL.ExtSupported.texFloat16 = true;
// Check depth texture support
- if ((strcmp(extList[i], (const char *)"GL_OES_depth_texture") == 0) ||
- (strcmp(extList[i], (const char *)"GL_WEBGL_depth_texture") == 0)) RLGL.ExtSupported.texDepth = true;
+ if (strcmp(extList[i], (const char *)"GL_OES_depth_texture") == 0) RLGL.ExtSupported.texDepth = true;
+ if (strcmp(extList[i], (const char *)"GL_WEBGL_depth_texture") == 0) RLGL.ExtSupported.texDepthWebGL = true; // WebGL requires unsized internal format
+ if (RLGL.ExtSupported.texDepthWebGL) RLGL.ExtSupported.texDepth = true;
- if (strcmp(extList[i], (const char *)"GL_OES_depth24") == 0) RLGL.ExtSupported.maxDepthBits = 24;
- if (strcmp(extList[i], (const char *)"GL_OES_depth32") == 0) RLGL.ExtSupported.maxDepthBits = 32;
+ if (strcmp(extList[i], (const char *)"GL_OES_depth24") == 0) RLGL.ExtSupported.maxDepthBits = 24; // Not available on WebGL
+ if (strcmp(extList[i], (const char *)"GL_OES_depth32") == 0) RLGL.ExtSupported.maxDepthBits = 32; // Not available on WebGL
// Check texture compression support: DXT
if ((strcmp(extList[i], (const char *)"GL_EXT_texture_compression_s3tc") == 0) ||
@@ -2232,15 +2443,17 @@ int rlGetVersion(void)
#endif
#if defined(GRAPHICS_API_OPENGL_21)
glVersion = RL_OPENGL_21;
+#elif defined(GRAPHICS_API_OPENGL_43)
+ glVersion = RL_OPENGL_43;
#elif defined(GRAPHICS_API_OPENGL_33)
glVersion = RL_OPENGL_33;
#endif
-#if defined(GRAPHICS_API_OPENGL_43)
- glVersion = RL_OPENGL_43;
-#endif
-#if defined(GRAPHICS_API_OPENGL_ES2)
+#if defined(GRAPHICS_API_OPENGL_ES3)
+ glVersion = RL_OPENGL_ES_30;
+#elif defined(GRAPHICS_API_OPENGL_ES2)
glVersion = RL_OPENGL_ES_20;
#endif
+
return glVersion;
}
@@ -2489,7 +2702,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
// Update batch vertex buffers
//------------------------------------------------------------------------------------------------------------
// NOTE: If there is not vertex data, buffers doesn't need to be updated (vertexCount > 0)
- // TODO: If no data changed on the CPU arrays --> No need to re-update GPU arrays (change flag required)
+ // TODO: If no data changed on the CPU arrays --> No need to re-update GPU arrays (use a change detector flag?)
if (RLGL.State.vertexCounter > 0)
{
// Activate elements VAO
@@ -2609,7 +2822,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
for (int i = 0, vertexOffset = 0; i < batch->drawCounter; i++)
{
- // Bind current draw call texture, activated as GL_TEXTURE0 and binded to sampler2D texture0 by default
+ // Bind current draw call texture, activated as GL_TEXTURE0 and Bound to sampler2D texture0 by default
glBindTexture(GL_TEXTURE_2D, batch->draws[i].textureId);
if ((batch->draws[i].mode == RL_LINES) || (batch->draws[i].mode == RL_TRIANGLES)) glDrawArrays(batch->draws[i].mode, vertexOffset, batch->draws[i].vertexCount);
@@ -2877,7 +3090,7 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
}
// Load depth texture/renderbuffer (to be attached to fbo)
-// WARNING: OpenGL ES 2.0 requires GL_OES_depth_texture/WEBGL_depth_texture extensions
+// WARNING: OpenGL ES 2.0 requires GL_OES_depth_texture and WebGL requires WEBGL_depth_texture extensions
unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer)
{
unsigned int id = 0;
@@ -2890,10 +3103,15 @@ unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer)
// Possible formats: GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT32 and GL_DEPTH_COMPONENT32F
unsigned int glInternalFormat = GL_DEPTH_COMPONENT;
-#if defined(GRAPHICS_API_OPENGL_ES2)
- if (RLGL.ExtSupported.maxDepthBits == 32) glInternalFormat = GL_DEPTH_COMPONENT32_OES;
- else if (RLGL.ExtSupported.maxDepthBits == 24) glInternalFormat = GL_DEPTH_COMPONENT24_OES;
- else glInternalFormat = GL_DEPTH_COMPONENT16;
+#if (defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_ES3))
+ // WARNING: WebGL platform requires unsized internal format definition (GL_DEPTH_COMPONENT)
+ // while other platforms using OpenGL ES 2.0 require/support sized internal formats depending on the GPU capabilities
+ if (!RLGL.ExtSupported.texDepthWebGL || useRenderBuffer)
+ {
+ if (RLGL.ExtSupported.maxDepthBits == 32) glInternalFormat = GL_DEPTH_COMPONENT32_OES;
+ else if (RLGL.ExtSupported.maxDepthBits == 24) glInternalFormat = GL_DEPTH_COMPONENT24_OES;
+ else glInternalFormat = GL_DEPTH_COMPONENT16;
+ }
#endif
if (!useRenderBuffer && RLGL.ExtSupported.texDepth)
@@ -2953,13 +3171,9 @@ unsigned int rlLoadTextureCubemap(const void *data, int size, int format)
{
if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB)
{
- if (format == RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32)
- {
- // Instead of using a sized internal texture format (GL_RGB16F, GL_RGB32F), we let the driver to choose the better format for us (GL_RGB)
- if (RLGL.ExtSupported.texFloat32) glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, size, size, 0, GL_RGB, GL_FLOAT, NULL);
- else TRACELOG(RL_LOG_WARNING, "TEXTURES: Cubemap requested format not supported");
- }
- else if ((format == RL_PIXELFORMAT_UNCOMPRESSED_R32) || (format == RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32)) TRACELOG(RL_LOG_WARNING, "TEXTURES: Cubemap requested format not supported");
+ if ((format == RL_PIXELFORMAT_UNCOMPRESSED_R32) || (format == RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32)
+ || (format == RL_PIXELFORMAT_UNCOMPRESSED_R16) || (format == RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16))
+ TRACELOG(RL_LOG_WARNING, "TEXTURES: Cubemap requested format not supported");
else glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, size, size, 0, glFormat, glType, NULL);
}
else TRACELOG(RL_LOG_WARNING, "TEXTURES: Empty cubemap creation does not support compressed format");
@@ -3042,9 +3256,27 @@ void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned
case RL_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_SHORT_4_4_4_4; break;
case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_BYTE; break;
#if !defined(GRAPHICS_API_OPENGL_11)
- case RL_PIXELFORMAT_UNCOMPRESSED_R32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_LUMINANCE; *glFormat = GL_LUMINANCE; *glType = GL_FLOAT; break; // NOTE: Requires extension OES_texture_float
- case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_FLOAT; break; // NOTE: Requires extension OES_texture_float
- case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_FLOAT; break; // NOTE: Requires extension OES_texture_float
+ #if defined(GRAPHICS_API_OPENGL_ES3)
+ case RL_PIXELFORMAT_UNCOMPRESSED_R32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_R32F_EXT; *glFormat = GL_RED_EXT; *glType = GL_FLOAT; break;
+ case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGB32F_EXT; *glFormat = GL_RGB; *glType = GL_FLOAT; break;
+ case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGBA32F_EXT; *glFormat = GL_RGBA; *glType = GL_FLOAT; break;
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_R16F_EXT; *glFormat = GL_RED_EXT; *glType = GL_HALF_FLOAT; break;
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGB16F_EXT; *glFormat = GL_RGB; *glType = GL_HALF_FLOAT; break;
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGBA16F_EXT; *glFormat = GL_RGBA; *glType = GL_HALF_FLOAT; break;
+ #else
+ case RL_PIXELFORMAT_UNCOMPRESSED_R32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_LUMINANCE; *glFormat = GL_LUMINANCE; *glType = GL_FLOAT; break; // NOTE: Requires extension OES_texture_float
+ case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_FLOAT; break; // NOTE: Requires extension OES_texture_float
+ case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_FLOAT; break; // NOTE: Requires extension OES_texture_float
+ #if defined(GRAPHICS_API_OPENGL_21)
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_LUMINANCE; *glFormat = GL_LUMINANCE; *glType = GL_HALF_FLOAT_ARB; break;
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_HALF_FLOAT_ARB; break;
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_HALF_FLOAT_ARB; break;
+ #else // defined(GRAPHICS_API_OPENGL_ES2)
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_LUMINANCE; *glFormat = GL_LUMINANCE; *glType = GL_HALF_FLOAT_OES; break; // NOTE: Requires extension OES_texture_half_float
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_HALF_FLOAT_OES; break; // NOTE: Requires extension OES_texture_half_float
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_HALF_FLOAT_OES; break; // NOTE: Requires extension OES_texture_half_float
+ #endif
+ #endif
#endif
#elif defined(GRAPHICS_API_OPENGL_33)
case RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: *glInternalFormat = GL_R8; *glFormat = GL_RED; *glType = GL_UNSIGNED_BYTE; break;
@@ -3057,6 +3289,9 @@ void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned
case RL_PIXELFORMAT_UNCOMPRESSED_R32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_R32F; *glFormat = GL_RED; *glType = GL_FLOAT; break;
case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGB32F; *glFormat = GL_RGB; *glType = GL_FLOAT; break;
case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGBA32F; *glFormat = GL_RGBA; *glType = GL_FLOAT; break;
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_R16F; *glFormat = GL_RED; *glType = GL_HALF_FLOAT; break;
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGB16F; *glFormat = GL_RGB; *glType = GL_HALF_FLOAT; break;
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGBA16F; *glFormat = GL_RGBA; *glType = GL_HALF_FLOAT; break;
#endif
#if !defined(GRAPHICS_API_OPENGL_11)
case RL_PIXELFORMAT_COMPRESSED_DXT1_RGB: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; break;
@@ -3085,6 +3320,7 @@ void rlUnloadTexture(unsigned int id)
// NOTE: Only supports GPU mipmap generation
void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int *mipmaps)
{
+#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
glBindTexture(GL_TEXTURE_2D, id);
// Check if texture is power-of-two (POT)
@@ -3093,7 +3329,6 @@ void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int
if (((width > 0) && ((width & (width - 1)) == 0)) &&
((height > 0) && ((height & (height - 1)) == 0))) texIsPOT = true;
-#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
if ((texIsPOT) || (RLGL.ExtSupported.texNPOT))
{
//glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorithm: GL_FASTEST, GL_NICEST, GL_DONT_CARE
@@ -3105,10 +3340,12 @@ void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int
*mipmaps = 1 + (int)floor(log(MAX(width, height))/log(2));
TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Mipmaps generated automatically, total: %i", id, *mipmaps);
}
-#endif
else TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] Failed to generate mipmaps", id);
glBindTexture(GL_TEXTURE_2D, 0);
+#else
+ TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] GPU mipmap generation not supported", id);
+#endif
}
@@ -3309,7 +3546,7 @@ void rlUnloadFramebuffer(unsigned int id)
unsigned int depthIdU = (unsigned int)depthId;
if (depthType == GL_RENDERBUFFER) glDeleteRenderbuffers(1, &depthIdU);
- else if (depthType == GL_RENDERBUFFER) glDeleteTextures(1, &depthIdU);
+ else if (depthType == GL_TEXTURE) glDeleteTextures(1, &depthIdU);
// NOTE: If a texture object is deleted while its image is attached to the *currently bound* framebuffer,
// the texture image is automatically detached from the currently bound framebuffer.
@@ -3576,12 +3813,14 @@ unsigned int rlLoadShaderCode(const char *vsCode, const char *fsCode)
// NOTE: We detach shader before deletion to make sure memory is freed
if (vertexShaderId != RLGL.State.defaultVShaderId)
{
- glDetachShader(id, vertexShaderId);
+ // WARNING: Shader program linkage could fail and returned id is 0
+ if (id > 0) glDetachShader(id, vertexShaderId);
glDeleteShader(vertexShaderId);
}
if (fragmentShaderId != RLGL.State.defaultFShaderId)
{
- glDetachShader(id, fragmentShaderId);
+ // WARNING: Shader program linkage could fail and returned id is 0
+ if (id > 0) glDetachShader(id, fragmentShaderId);
glDeleteShader(fragmentShaderId);
}
@@ -3689,7 +3928,7 @@ unsigned int rlLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId)
glAttachShader(program, vShaderId);
glAttachShader(program, fShaderId);
- // NOTE: Default attribute shader locations must be binded before linking
+ // NOTE: Default attribute shader locations must be Bound before linking
glBindAttribLocation(program, 0, RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION);
glBindAttribLocation(program, 1, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD);
glBindAttribLocation(program, 2, RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL);
@@ -3755,8 +3994,8 @@ int rlGetLocationUniform(unsigned int shaderId, const char *uniformName)
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
location = glGetUniformLocation(shaderId, uniformName);
- if (location == -1) TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to find shader uniform: %s", shaderId, uniformName);
- else TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Shader uniform (%s) set at location: %i", shaderId, uniformName, location);
+ //if (location == -1) TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to find shader uniform: %s", shaderId, uniformName);
+ //else TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Shader uniform (%s) set at location: %i", shaderId, uniformName, location);
#endif
return location;
}
@@ -3768,8 +4007,8 @@ int rlGetLocationAttrib(unsigned int shaderId, const char *attribName)
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
location = glGetAttribLocation(shaderId, attribName);
- if (location == -1) TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to find shader attribute: %s", shaderId, attribName);
- else TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Shader attribute (%s) set at location: %i", shaderId, attribName, location);
+ //if (location == -1) TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to find shader attribute: %s", shaderId, attribName);
+ //else TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Shader attribute (%s) set at location: %i", shaderId, attribName, location);
#endif
return location;
}
@@ -3923,7 +4162,7 @@ unsigned int rlLoadShaderBuffer(unsigned int size, const void *data, int usageHi
glGenBuffers(1, &ssbo);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo);
glBufferData(GL_SHADER_STORAGE_BUFFER, size, data, usageHint? usageHint : RL_STREAM_COPY);
- glClearBufferData(GL_SHADER_STORAGE_BUFFER, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, 0);
+ if (data == NULL) glClearBufferData(GL_SHADER_STORAGE_BUFFER, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, NULL); // Clear buffer data to 0
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
#endif
@@ -3988,7 +4227,7 @@ void rlCopyShaderBuffer(unsigned int destId, unsigned int srcId, unsigned int de
}
// Bind image texture
-void rlBindImageTexture(unsigned int id, unsigned int index, unsigned int format, int readonly)
+void rlBindImageTexture(unsigned int id, unsigned int index, int format, bool readonly)
{
#if defined(GRAPHICS_API_OPENGL_43)
unsigned int glInternalFormat = 0, glFormat = 0, glType = 0;
@@ -4260,6 +4499,9 @@ const char *rlGetPixelFormatName(unsigned int format)
case RL_PIXELFORMAT_UNCOMPRESSED_R32: return "R32"; break; // 32 bpp (1 channel - float)
case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: return "R32G32B32"; break; // 32*3 bpp (3 channels - float)
case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: return "R32G32B32A32"; break; // 32*4 bpp (4 channels - float)
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16: return "R16"; break; // 16 bpp (1 channel - half float)
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: return "R16G16B16"; break; // 16*3 bpp (3 channels - half float)
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: return "R16G16B16A16"; break; // 16*4 bpp (4 channels - half float)
case RL_PIXELFORMAT_COMPRESSED_DXT1_RGB: return "DXT1_RGB"; break; // 4 bpp (no alpha)
case RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA: return "DXT1_RGBA"; break; // 4 bpp (1 bit alpha)
case RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA: return "DXT3_RGBA"; break; // 8 bpp
@@ -4308,6 +4550,7 @@ static void rlLoadShaderDefault(void)
#endif
#if defined(GRAPHICS_API_OPENGL_ES2)
"#version 100 \n"
+ "precision mediump float; \n" // Precision required for OpenGL ES2 (WebGL) (on some browsers)
"attribute vec3 vertexPosition; \n"
"attribute vec2 vertexTexCoord; \n"
"attribute vec4 vertexColor; \n"
@@ -4501,6 +4744,9 @@ static int rlGetPixelDataSize(int width, int height, int format)
case RL_PIXELFORMAT_UNCOMPRESSED_R32: bpp = 32; break;
case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: bpp = 32*3; break;
case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: bpp = 32*4; break;
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16: bpp = 16; break;
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: bpp = 16*3; break;
+ case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: bpp = 16*4; break;
case RL_PIXELFORMAT_COMPRESSED_DXT1_RGB:
case RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA:
case RL_PIXELFORMAT_COMPRESSED_ETC1_RGB:
diff --git a/src/rmodels.c b/src/rmodels.c
index 342ba33b6..ebb454e4a 100644
--- a/src/rmodels.c
+++ b/src/rmodels.c
@@ -3,26 +3,25 @@
* rmodels - Basic functions to draw 3d shapes and load and draw 3d models
*
* CONFIGURATION:
+* #define SUPPORT_MODULE_RMODELS
+* rmodels module is included in the build
*
-* #define SUPPORT_MODULE_RMODELS
-* rmodels module is included in the build
+* #define SUPPORT_FILEFORMAT_OBJ
+* #define SUPPORT_FILEFORMAT_MTL
+* #define SUPPORT_FILEFORMAT_IQM
+* #define SUPPORT_FILEFORMAT_GLTF
+* #define SUPPORT_FILEFORMAT_VOX
+* #define SUPPORT_FILEFORMAT_M3D
+* Selected desired fileformats to be supported for model data loading.
*
-* #define SUPPORT_FILEFORMAT_OBJ
-* #define SUPPORT_FILEFORMAT_MTL
-* #define SUPPORT_FILEFORMAT_IQM
-* #define SUPPORT_FILEFORMAT_GLTF
-* #define SUPPORT_FILEFORMAT_VOX
-* #define SUPPORT_FILEFORMAT_M3D
-* Selected desired fileformats to be supported for model data loading.
-*
-* #define SUPPORT_MESH_GENERATION
-* Support procedural mesh generation functions, uses external par_shapes.h library
-* NOTE: Some generated meshes DO NOT include generated texture coordinates
+* #define SUPPORT_MESH_GENERATION
+* Support procedural mesh generation functions, uses external par_shapes.h library
+* NOTE: Some generated meshes DO NOT include generated texture coordinates
*
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -102,8 +101,18 @@
#define PAR_REALLOC(T, BUF, N) ((T*)RL_REALLOC(BUF, sizeof(T)*(N)))
#define PAR_FREE RL_FREE
+ #if defined(_MSC_VER) // Disable some MSVC warning
+ #pragma warning(push)
+ #pragma warning(disable : 4244)
+ #pragma warning(disable : 4305)
+ #endif
+
#define PAR_SHAPES_IMPLEMENTATION
#include "external/par_shapes.h" // Shapes 3d parametric generation
+
+ #if defined(_MSC_VER)
+ #pragma warning(pop) // Disable MSVC warning suppression
+ #endif
#endif
#if defined(_WIN32)
@@ -142,18 +151,21 @@ static Model LoadOBJ(const char *fileName); // Load OBJ mesh data
#endif
#if defined(SUPPORT_FILEFORMAT_IQM)
static Model LoadIQM(const char *fileName); // Load IQM mesh data
-static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, unsigned int *animCount); // Load IQM animation data
+static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, unsigned int *animCount); // Load IQM animation data
#endif
#if defined(SUPPORT_FILEFORMAT_GLTF)
static Model LoadGLTF(const char *fileName); // Load GLTF mesh data
-//static ModelAnimation *LoadModelAnimationGLTF(const char *fileName, unsigned int *animCount); // Load GLTF animation data
+static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, unsigned int *animCount); // Load GLTF animation data
#endif
#if defined(SUPPORT_FILEFORMAT_VOX)
static Model LoadVOX(const char *filename); // Load VOX mesh data
#endif
#if defined(SUPPORT_FILEFORMAT_M3D)
static Model LoadM3D(const char *filename); // Load M3D mesh data
-static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, unsigned int *animCount); // Load M3D animation data
+static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, unsigned int *animCount); // Load M3D animation data
+#endif
+#if defined(SUPPORT_FILEFORMAT_OBJ) || defined(SUPPORT_FILEFORMAT_MTL)
+static void ProcessMaterialsOBJ(Material *rayMaterials, tinyobj_material_t *materials, int materialCount); // Process obj materials
#endif
//----------------------------------------------------------------------------------
@@ -397,151 +409,6 @@ void DrawCubeWiresV(Vector3 position, Vector3 size, Color color)
DrawCubeWires(position, size.x, size.y, size.z, color);
}
-// Draw cube
-// NOTE: Cube position is the center position
-void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color)
-{
- float x = position.x;
- float y = position.y;
- float z = position.z;
-
- rlSetTexture(texture.id);
-
- //rlPushMatrix();
- // NOTE: Transformation is applied in inverse order (scale -> rotate -> translate)
- //rlTranslatef(2.0f, 0.0f, 0.0f);
- //rlRotatef(45, 0, 1, 0);
- //rlScalef(2.0f, 2.0f, 2.0f);
-
- rlBegin(RL_QUADS);
- rlColor4ub(color.r, color.g, color.b, color.a);
- // Front Face
- rlNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
- rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
- rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom Right Of The Texture and Quad
- rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z + length/2); // Top Right Of The Texture and Quad
- rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z + length/2); // Top Left Of The Texture and Quad
- // Back Face
- rlNormal3f(0.0f, 0.0f, - 1.0f); // Normal Pointing Away From Viewer
- rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z - length/2); // Bottom Right Of The Texture and Quad
- rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z - length/2); // Top Right Of The Texture and Quad
- rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z - length/2); // Top Left Of The Texture and Quad
- rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z - length/2); // Bottom Left Of The Texture and Quad
- // Top Face
- rlNormal3f(0.0f, 1.0f, 0.0f); // Normal Pointing Up
- rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z - length/2); // Top Left Of The Texture and Quad
- rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y + height/2, z + length/2); // Bottom Left Of The Texture and Quad
- rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x + width/2, y + height/2, z + length/2); // Bottom Right Of The Texture and Quad
- rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z - length/2); // Top Right Of The Texture and Quad
- // Bottom Face
- rlNormal3f(0.0f, - 1.0f, 0.0f); // Normal Pointing Down
- rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x - width/2, y - height/2, z - length/2); // Top Right Of The Texture and Quad
- rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x + width/2, y - height/2, z - length/2); // Top Left Of The Texture and Quad
- rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
- rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Right Of The Texture and Quad
- // Right face
- rlNormal3f(1.0f, 0.0f, 0.0f); // Normal Pointing Right
- rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z - length/2); // Bottom Right Of The Texture and Quad
- rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z - length/2); // Top Right Of The Texture and Quad
- rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z + length/2); // Top Left Of The Texture and Quad
- rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
- // Left Face
- rlNormal3f( - 1.0f, 0.0f, 0.0f); // Normal Pointing Left
- rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z - length/2); // Bottom Left Of The Texture and Quad
- rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Right Of The Texture and Quad
- rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z + length/2); // Top Right Of The Texture and Quad
- rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z - length/2); // Top Left Of The Texture and Quad
- rlEnd();
- //rlPopMatrix();
-
- rlSetTexture(0);
-}
-
-// Draw cube with texture piece applied to all faces
-void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color)
-{
- float x = position.x;
- float y = position.y;
- float z = position.z;
- float texWidth = (float)texture.width;
- float texHeight = (float)texture.height;
-
- rlSetTexture(texture.id);
-
- rlBegin(RL_QUADS);
- rlColor4ub(color.r, color.g, color.b, color.a);
-
- // Front face
- rlNormal3f(0.0f, 0.0f, 1.0f);
- rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
- rlVertex3f(x - width/2, y - height/2, z + length/2);
- rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
- rlVertex3f(x + width/2, y - height/2, z + length/2);
- rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
- rlVertex3f(x + width/2, y + height/2, z + length/2);
- rlTexCoord2f(source.x/texWidth, source.y/texHeight);
- rlVertex3f(x - width/2, y + height/2, z + length/2);
-
- // Back face
- rlNormal3f(0.0f, 0.0f, - 1.0f);
- rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
- rlVertex3f(x - width/2, y - height/2, z - length/2);
- rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
- rlVertex3f(x - width/2, y + height/2, z - length/2);
- rlTexCoord2f(source.x/texWidth, source.y/texHeight);
- rlVertex3f(x + width/2, y + height/2, z - length/2);
- rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
- rlVertex3f(x + width/2, y - height/2, z - length/2);
-
- // Top face
- rlNormal3f(0.0f, 1.0f, 0.0f);
- rlTexCoord2f(source.x/texWidth, source.y/texHeight);
- rlVertex3f(x - width/2, y + height/2, z - length/2);
- rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
- rlVertex3f(x - width/2, y + height/2, z + length/2);
- rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
- rlVertex3f(x + width/2, y + height/2, z + length/2);
- rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
- rlVertex3f(x + width/2, y + height/2, z - length/2);
-
- // Bottom face
- rlNormal3f(0.0f, - 1.0f, 0.0f);
- rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
- rlVertex3f(x - width/2, y - height/2, z - length/2);
- rlTexCoord2f(source.x/texWidth, source.y/texHeight);
- rlVertex3f(x + width/2, y - height/2, z - length/2);
- rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
- rlVertex3f(x + width/2, y - height/2, z + length/2);
- rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
- rlVertex3f(x - width/2, y - height/2, z + length/2);
-
- // Right face
- rlNormal3f(1.0f, 0.0f, 0.0f);
- rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
- rlVertex3f(x + width/2, y - height/2, z - length/2);
- rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
- rlVertex3f(x + width/2, y + height/2, z - length/2);
- rlTexCoord2f(source.x/texWidth, source.y/texHeight);
- rlVertex3f(x + width/2, y + height/2, z + length/2);
- rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
- rlVertex3f(x + width/2, y - height/2, z + length/2);
-
- // Left face
- rlNormal3f( - 1.0f, 0.0f, 0.0f);
- rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
- rlVertex3f(x - width/2, y - height/2, z - length/2);
- rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
- rlVertex3f(x - width/2, y - height/2, z + length/2);
- rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
- rlVertex3f(x - width/2, y + height/2, z + length/2);
- rlTexCoord2f(source.x/texWidth, source.y/texHeight);
- rlVertex3f(x - width/2, y + height/2, z - length/2);
-
- rlEnd();
-
- rlSetTexture(0);
-}
-
// Draw sphere
void DrawSphere(Vector3 centerPos, float radius, Color color)
{
@@ -817,6 +684,284 @@ void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, fl
rlEnd();
}
+// Draw a capsule with the center of its sphere caps at startPos and endPos
+void DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color)
+{
+ if (slices < 3) slices = 3;
+
+ Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
+
+ // draw a sphere if start and end points are the same
+ bool sphereCase = (direction.x == 0) && (direction.y == 0) && (direction.z == 0);
+ if (sphereCase) direction = (Vector3){0.0f, 1.0f, 0.0f};
+
+ // Construct a basis of the base and the caps:
+ Vector3 b0 = Vector3Normalize(direction);
+ Vector3 b1 = Vector3Normalize(Vector3Perpendicular(direction));
+ Vector3 b2 = Vector3Normalize(Vector3CrossProduct(b1, direction));
+ Vector3 capCenter = endPos;
+
+ float baseSliceAngle = (2.0f*PI)/slices;
+ float baseRingAngle = PI * 0.5f / rings;
+
+ rlBegin(RL_TRIANGLES);
+ rlColor4ub(color.r, color.g, color.b, color.a);
+
+ // render both caps
+ for (int c = 0; c < 2; c++)
+ {
+ for (int i = 0; i < rings; i++)
+ {
+ for (int j = 0; j < slices; j++)
+ {
+
+ // we build up the rings from capCenter in the direction of the 'direction' vector we computed earlier
+
+ // as we iterate through the rings they must be placed higher above the center, the height we need is sin(angle(i))
+ // as we iterate through the rings they must get smaller by the cos(angle(i))
+
+ // compute the four vertices
+ float ringSin1 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 ));
+ float ringCos1 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 ));
+ Vector3 w1 = (Vector3){
+ capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin1*b1.x + ringCos1*b2.x) * radius,
+ capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin1*b1.y + ringCos1*b2.y) * radius,
+ capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin1*b1.z + ringCos1*b2.z) * radius
+ };
+ float ringSin2 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 ));
+ float ringCos2 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 ));
+ Vector3 w2 = (Vector3){
+ capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin2*b1.x + ringCos2*b2.x) * radius,
+ capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin2*b1.y + ringCos2*b2.y) * radius,
+ capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin2*b1.z + ringCos2*b2.z) * radius
+ };
+
+ float ringSin3 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 ));
+ float ringCos3 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 ));
+ Vector3 w3 = (Vector3){
+ capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin3*b1.x + ringCos3*b2.x) * radius,
+ capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin3*b1.y + ringCos3*b2.y) * radius,
+ capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin3*b1.z + ringCos3*b2.z) * radius
+ };
+ float ringSin4 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 ));
+ float ringCos4 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 ));
+ Vector3 w4 = (Vector3){
+ capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin4*b1.x + ringCos4*b2.x) * radius,
+ capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin4*b1.y + ringCos4*b2.y) * radius,
+ capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin4*b1.z + ringCos4*b2.z) * radius
+ };
+
+ // make sure cap triangle normals are facing outwards
+ if(c == 0)
+ {
+ rlVertex3f(w1.x, w1.y, w1.z);
+ rlVertex3f(w2.x, w2.y, w2.z);
+ rlVertex3f(w3.x, w3.y, w3.z);
+
+ rlVertex3f(w2.x, w2.y, w2.z);
+ rlVertex3f(w4.x, w4.y, w4.z);
+ rlVertex3f(w3.x, w3.y, w3.z);
+ }
+ else
+ {
+ rlVertex3f(w1.x, w1.y, w1.z);
+ rlVertex3f(w3.x, w3.y, w3.z);
+ rlVertex3f(w2.x, w2.y, w2.z);
+
+ rlVertex3f(w2.x, w2.y, w2.z);
+ rlVertex3f(w3.x, w3.y, w3.z);
+ rlVertex3f(w4.x, w4.y, w4.z);
+ }
+ }
+ }
+ capCenter = startPos;
+ b0 = Vector3Scale(b0, -1.0f);
+ }
+ // render middle
+ if (!sphereCase)
+ {
+ for (int j = 0; j < slices; j++)
+ {
+ // compute the four vertices
+ float ringSin1 = sinf(baseSliceAngle*(j + 0))*radius;
+ float ringCos1 = cosf(baseSliceAngle*(j + 0))*radius;
+ Vector3 w1 = {
+ startPos.x + ringSin1*b1.x + ringCos1*b2.x,
+ startPos.y + ringSin1*b1.y + ringCos1*b2.y,
+ startPos.z + ringSin1*b1.z + ringCos1*b2.z
+ };
+ float ringSin2 = sinf(baseSliceAngle*(j + 1))*radius;
+ float ringCos2 = cosf(baseSliceAngle*(j + 1))*radius;
+ Vector3 w2 = {
+ startPos.x + ringSin2*b1.x + ringCos2*b2.x,
+ startPos.y + ringSin2*b1.y + ringCos2*b2.y,
+ startPos.z + ringSin2*b1.z + ringCos2*b2.z
+ };
+
+ float ringSin3 = sinf(baseSliceAngle*(j + 0))*radius;
+ float ringCos3 = cosf(baseSliceAngle*(j + 0))*radius;
+ Vector3 w3 = {
+ endPos.x + ringSin3*b1.x + ringCos3*b2.x,
+ endPos.y + ringSin3*b1.y + ringCos3*b2.y,
+ endPos.z + ringSin3*b1.z + ringCos3*b2.z
+ };
+ float ringSin4 = sinf(baseSliceAngle*(j + 1))*radius;
+ float ringCos4 = cosf(baseSliceAngle*(j + 1))*radius;
+ Vector3 w4 = {
+ endPos.x + ringSin4*b1.x + ringCos4*b2.x,
+ endPos.y + ringSin4*b1.y + ringCos4*b2.y,
+ endPos.z + ringSin4*b1.z + ringCos4*b2.z
+ };
+ // w2 x.-----------x startPos
+ rlVertex3f(w1.x, w1.y, w1.z); // | |\'. T0 /
+ rlVertex3f(w2.x, w2.y, w2.z); // T1 | \ '. /
+ rlVertex3f(w3.x, w3.y, w3.z); // | |T \ '. /
+ // | 2 \ T 'x w1
+ rlVertex3f(w2.x, w2.y, w2.z); // | w4 x.---\-1-|---x endPos
+ rlVertex3f(w4.x, w4.y, w4.z); // T2 '. \ |T3/
+ rlVertex3f(w3.x, w3.y, w3.z); // | '. \ | /
+ // '.\|/
+ // 'x w3
+ }
+ }
+ rlEnd();
+}
+
+// Draw capsule wires with the center of its sphere caps at startPos and endPos
+void DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color)
+{
+ if (slices < 3) slices = 3;
+
+ Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
+
+ // draw a sphere if start and end points are the same
+ bool sphereCase = (direction.x == 0) && (direction.y == 0) && (direction.z == 0);
+ if (sphereCase) direction = (Vector3){0.0f, 1.0f, 0.0f};
+
+ // Construct a basis of the base and the caps:
+ Vector3 b0 = Vector3Normalize(direction);
+ Vector3 b1 = Vector3Normalize(Vector3Perpendicular(direction));
+ Vector3 b2 = Vector3Normalize(Vector3CrossProduct(b1, direction));
+ Vector3 capCenter = endPos;
+
+ float baseSliceAngle = (2.0f*PI)/slices;
+ float baseRingAngle = PI * 0.5f / rings;
+
+ rlBegin(RL_LINES);
+ rlColor4ub(color.r, color.g, color.b, color.a);
+
+ // render both caps
+ for (int c = 0; c < 2; c++)
+ {
+ for (int i = 0; i < rings; i++)
+ {
+ for (int j = 0; j < slices; j++)
+ {
+
+ // we build up the rings from capCenter in the direction of the 'direction' vector we computed earlier
+
+ // as we iterate through the rings they must be placed higher above the center, the height we need is sin(angle(i))
+ // as we iterate through the rings they must get smaller by the cos(angle(i))
+
+ // compute the four vertices
+ float ringSin1 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 ));
+ float ringCos1 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 0 ));
+ Vector3 w1 = (Vector3){
+ capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin1*b1.x + ringCos1*b2.x) * radius,
+ capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin1*b1.y + ringCos1*b2.y) * radius,
+ capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin1*b1.z + ringCos1*b2.z) * radius
+ };
+ float ringSin2 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 ));
+ float ringCos2 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 0 ));
+ Vector3 w2 = (Vector3){
+ capCenter.x + (sinf(baseRingAngle * ( i + 0 ))*b0.x + ringSin2*b1.x + ringCos2*b2.x) * radius,
+ capCenter.y + (sinf(baseRingAngle * ( i + 0 ))*b0.y + ringSin2*b1.y + ringCos2*b2.y) * radius,
+ capCenter.z + (sinf(baseRingAngle * ( i + 0 ))*b0.z + ringSin2*b1.z + ringCos2*b2.z) * radius
+ };
+
+ float ringSin3 = sinf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 ));
+ float ringCos3 = cosf(baseSliceAngle*(j + 0))*cosf(baseRingAngle * ( i + 1 ));
+ Vector3 w3 = (Vector3){
+ capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin3*b1.x + ringCos3*b2.x) * radius,
+ capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin3*b1.y + ringCos3*b2.y) * radius,
+ capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin3*b1.z + ringCos3*b2.z) * radius
+ };
+ float ringSin4 = sinf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 ));
+ float ringCos4 = cosf(baseSliceAngle*(j + 1))*cosf(baseRingAngle * ( i + 1 ));
+ Vector3 w4 = (Vector3){
+ capCenter.x + (sinf(baseRingAngle * ( i + 1 ))*b0.x + ringSin4*b1.x + ringCos4*b2.x) * radius,
+ capCenter.y + (sinf(baseRingAngle * ( i + 1 ))*b0.y + ringSin4*b1.y + ringCos4*b2.y) * radius,
+ capCenter.z + (sinf(baseRingAngle * ( i + 1 ))*b0.z + ringSin4*b1.z + ringCos4*b2.z) * radius
+ };
+
+ rlVertex3f(w1.x, w1.y, w1.z);
+ rlVertex3f(w2.x, w2.y, w2.z);
+
+ rlVertex3f(w2.x, w2.y, w2.z);
+ rlVertex3f(w3.x, w3.y, w3.z);
+
+ rlVertex3f(w1.x, w1.y, w1.z);
+ rlVertex3f(w3.x, w3.y, w3.z);
+
+ rlVertex3f(w2.x, w2.y, w2.z);
+ rlVertex3f(w4.x, w4.y, w4.z);
+
+ rlVertex3f(w3.x, w3.y, w3.z);
+ rlVertex3f(w4.x, w4.y, w4.z);
+ }
+ }
+ capCenter = startPos;
+ b0 = Vector3Scale(b0, -1.0f);
+ }
+ // render middle
+ if (!sphereCase)
+ {
+ for (int j = 0; j < slices; j++)
+ {
+ // compute the four vertices
+ float ringSin1 = sinf(baseSliceAngle*(j + 0))*radius;
+ float ringCos1 = cosf(baseSliceAngle*(j + 0))*radius;
+ Vector3 w1 = {
+ startPos.x + ringSin1*b1.x + ringCos1*b2.x,
+ startPos.y + ringSin1*b1.y + ringCos1*b2.y,
+ startPos.z + ringSin1*b1.z + ringCos1*b2.z
+ };
+ float ringSin2 = sinf(baseSliceAngle*(j + 1))*radius;
+ float ringCos2 = cosf(baseSliceAngle*(j + 1))*radius;
+ Vector3 w2 = {
+ startPos.x + ringSin2*b1.x + ringCos2*b2.x,
+ startPos.y + ringSin2*b1.y + ringCos2*b2.y,
+ startPos.z + ringSin2*b1.z + ringCos2*b2.z
+ };
+
+ float ringSin3 = sinf(baseSliceAngle*(j + 0))*radius;
+ float ringCos3 = cosf(baseSliceAngle*(j + 0))*radius;
+ Vector3 w3 = {
+ endPos.x + ringSin3*b1.x + ringCos3*b2.x,
+ endPos.y + ringSin3*b1.y + ringCos3*b2.y,
+ endPos.z + ringSin3*b1.z + ringCos3*b2.z
+ };
+ float ringSin4 = sinf(baseSliceAngle*(j + 1))*radius;
+ float ringCos4 = cosf(baseSliceAngle*(j + 1))*radius;
+ Vector3 w4 = {
+ endPos.x + ringSin4*b1.x + ringCos4*b2.x,
+ endPos.y + ringSin4*b1.y + ringCos4*b2.y,
+ endPos.z + ringSin4*b1.z + ringCos4*b2.z
+ };
+
+ rlVertex3f(w1.x, w1.y, w1.z);
+ rlVertex3f(w3.x, w3.y, w3.z);
+
+ rlVertex3f(w2.x, w2.y, w2.z);
+ rlVertex3f(w4.x, w4.y, w4.z);
+
+ rlVertex3f(w2.x, w2.y, w2.z);
+ rlVertex3f(w3.x, w3.y, w3.z);
+ }
+ }
+ rlEnd();
+}
+
// Draw a plane
void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
{
@@ -962,6 +1107,18 @@ Model LoadModelFromMesh(Mesh mesh)
return model;
}
+// Check if a model is ready
+bool IsModelReady(Model model)
+{
+ return ((model.meshes != NULL) && // Validate model contains some mesh
+ (model.materials != NULL) && // Validate model contains some material (at least default one)
+ (model.meshMaterial != NULL) && // Validate mesh-material linkage
+ (model.meshCount > 0) && // Validate mesh count
+ (model.materialCount > 0)); // Validate material count
+
+ // NOTE: This is a very general model validation, many elements could be validated from a model...
+}
+
// Unload model (meshes/materials) from memory (RAM and/or VRAM)
// NOTE: This function takes care of all model elements, for a detailed control
// over them, use UnloadMesh() and UnloadMaterial()
@@ -972,7 +1129,7 @@ void UnloadModel(Model model)
// Unload materials maps
// NOTE: As the user could be sharing shaders and textures between models,
- // we don't unload the material but just free it's maps,
+ // we don't unload the material but just free its maps,
// the user is responsible for freeing models shaders and textures
for (int i = 0; i < model.materialCount; i++) RL_FREE(model.materials[i].maps);
@@ -988,27 +1145,6 @@ void UnloadModel(Model model)
TRACELOG(LOG_INFO, "MODEL: Unloaded model (and meshes) from RAM and VRAM");
}
-// Unload model (but not meshes) from memory (RAM and/or VRAM)
-void UnloadModelKeepMeshes(Model model)
-{
- // Unload materials maps
- // NOTE: As the user could be sharing shaders and textures between models,
- // we don't unload the material but just free it's maps,
- // the user is responsible for freeing models shaders and textures
- for (int i = 0; i < model.materialCount; i++) RL_FREE(model.materials[i].maps);
-
- // Unload arrays
- RL_FREE(model.meshes);
- RL_FREE(model.materials);
- RL_FREE(model.meshMaterial);
-
- // Unload animation data
- RL_FREE(model.bones);
- RL_FREE(model.bindPose);
-
- TRACELOG(LOG_INFO, "MODEL: Unloaded model (but not meshes) from RAM and VRAM");
-}
-
// Compute model bounding box limits (considers all meshes)
BoundingBox GetModelBoundingBox(Model model)
{
@@ -1077,7 +1213,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
rlEnableVertexAttribute(1);
// WARNING: When setting default vertex attribute values, the values for each generic vertex attribute
- // is part of current state and it is maintained even if a different program object is used
+ // is part of current state, and it is maintained even if a different program object is used
if (mesh->normals != NULL)
{
@@ -1230,7 +1366,7 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
}
// Get a copy of current matrices to work with,
- // just in case stereo render is required and we need to modify them
+ // just in case stereo render is required, and we need to modify them
// NOTE: At this point the modelview matrix just contains the view matrix (camera)
// That's because BeginMode3D() sets it and there is no model-drawing function
// that modifies it, all use rlPushMatrix() and rlPopMatrix()
@@ -1243,7 +1379,7 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
if (material.shader.locs[SHADER_LOC_MATRIX_VIEW] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_VIEW], matView);
if (material.shader.locs[SHADER_LOC_MATRIX_PROJECTION] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_PROJECTION], matProjection);
- // Model transformation matrix is send to shader uniform location: SHADER_LOC_MATRIX_MODEL
+ // Model transformation matrix is sent to shader uniform location: SHADER_LOC_MATRIX_MODEL
if (material.shader.locs[SHADER_LOC_MATRIX_MODEL] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_MODEL], transform);
// Accumulate several model transformations:
@@ -1364,7 +1500,7 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
else rlDrawVertexArray(0, mesh.vertexCount);
}
- // Unbind all binded texture maps
+ // Unbind all bound texture maps
for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
{
if (material.maps[i].texture.id > 0)
@@ -1434,7 +1570,7 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
}
// Get a copy of current matrices to work with,
- // just in case stereo render is required and we need to modify them
+ // just in case stereo render is required, and we need to modify them
// NOTE: At this point the modelview matrix just contains the view matrix (camera)
// That's because BeginMode3D() sets it and there is no model-drawing function
// that modifies it, all use rlPushMatrix() and rlPopMatrix()
@@ -1585,7 +1721,7 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
else rlDrawVertexArrayInstanced(0, mesh.vertexCount, instances);
}
- // Unbind all binded texture maps
+ // Unbind all bound texture maps
for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
{
if (material.maps[i].texture.id > 0)
@@ -1662,7 +1798,7 @@ bool ExportMesh(Mesh mesh, const char *fileName)
byteCount += sprintf(txtData + byteCount, "# // more info and bugs-report: github.com/raysan5/raylib //\n");
byteCount += sprintf(txtData + byteCount, "# // feedback and support: ray[at]raylib.com //\n");
byteCount += sprintf(txtData + byteCount, "# // //\n");
- byteCount += sprintf(txtData + byteCount, "# // Copyright (c) 2018-2022 Ramon Santamaria (@raysan5) //\n");
+ byteCount += sprintf(txtData + byteCount, "# // Copyright (c) 2018-2023 Ramon Santamaria (@raysan5) //\n");
byteCount += sprintf(txtData + byteCount, "# // //\n");
byteCount += sprintf(txtData + byteCount, "# //////////////////////////////////////////////////////////////////////////////////\n\n");
byteCount += sprintf(txtData + byteCount, "# Vertex Count: %i\n", mesh.vertexCount);
@@ -1718,6 +1854,40 @@ bool ExportMesh(Mesh mesh, const char *fileName)
return success;
}
+#if defined(SUPPORT_FILEFORMAT_OBJ) || defined(SUPPORT_FILEFORMAT_MTL)
+// Process obj materials
+static void ProcessMaterialsOBJ(Material *materials, tinyobj_material_t *mats, int materialCount)
+{
+ // Init model mats
+ for (int m = 0; m < materialCount; m++)
+ {
+ // Init material to default
+ // NOTE: Uses default shader, which only supports MATERIAL_MAP_DIFFUSE
+ materials[m] = LoadMaterialDefault();
+
+ // Get default texture, in case no texture is defined
+ // NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8
+ materials[m].maps[MATERIAL_MAP_DIFFUSE].texture = (Texture2D){ rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
+
+ if (mats[m].diffuse_texname != NULL) materials[m].maps[MATERIAL_MAP_DIFFUSE].texture = LoadTexture(mats[m].diffuse_texname); //char *diffuse_texname; // map_Kd
+ else materials[m].maps[MATERIAL_MAP_DIFFUSE].color = (Color){ (unsigned char)(mats[m].diffuse[0]*255.0f), (unsigned char)(mats[m].diffuse[1]*255.0f), (unsigned char)(mats[m].diffuse[2] * 255.0f), 255 }; //float diffuse[3];
+ materials[m].maps[MATERIAL_MAP_DIFFUSE].value = 0.0f;
+
+ if (mats[m].specular_texname != NULL) materials[m].maps[MATERIAL_MAP_SPECULAR].texture = LoadTexture(mats[m].specular_texname); //char *specular_texname; // map_Ks
+ materials[m].maps[MATERIAL_MAP_SPECULAR].color = (Color){ (unsigned char)(mats[m].specular[0]*255.0f), (unsigned char)(mats[m].specular[1]*255.0f), (unsigned char)(mats[m].specular[2] * 255.0f), 255 }; //float specular[3];
+ materials[m].maps[MATERIAL_MAP_SPECULAR].value = 0.0f;
+
+ if (mats[m].bump_texname != NULL) materials[m].maps[MATERIAL_MAP_NORMAL].texture = LoadTexture(mats[m].bump_texname); //char *bump_texname; // map_bump, bump
+ materials[m].maps[MATERIAL_MAP_NORMAL].color = WHITE;
+ materials[m].maps[MATERIAL_MAP_NORMAL].value = mats[m].shininess;
+
+ materials[m].maps[MATERIAL_MAP_EMISSION].color = (Color){ (unsigned char)(mats[m].emission[0]*255.0f), (unsigned char)(mats[m].emission[1]*255.0f), (unsigned char)(mats[m].emission[2] * 255.0f), 255 }; //float emission[3];
+
+ if (mats[m].displacement_texname != NULL) materials[m].maps[MATERIAL_MAP_HEIGHT].texture = LoadTexture(mats[m].displacement_texname); //char *displacement_texname; // disp
+ }
+}
+#endif
+
// Load materials from model file
Material *LoadMaterials(const char *fileName, int *materialCount)
{
@@ -1734,7 +1904,8 @@ Material *LoadMaterials(const char *fileName, int *materialCount)
int result = tinyobj_parse_mtl_file(&mats, &count, fileName);
if (result != TINYOBJ_SUCCESS) TRACELOG(LOG_WARNING, "MATERIAL: [%s] Failed to parse materials file", fileName);
- // TODO: Process materials to return
+ materials = MemAlloc(count*sizeof(Material));
+ ProcessMaterialsOBJ(materials, mats, count);
tinyobj_materials_free(mats, count);
}
@@ -1742,16 +1913,6 @@ Material *LoadMaterials(const char *fileName, int *materialCount)
TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to load material file", fileName);
#endif
- // Set materials shader to default (DIFFUSE, SPECULAR, NORMAL)
- if (materials != NULL)
- {
- for (unsigned int i = 0; i < count; i++)
- {
- materials[i].shader.id = rlGetShaderIdDefault();
- materials[i].shader.locs = rlGetShaderLocsDefault();
- }
- }
-
*materialCount = count;
return materials;
}
@@ -1777,6 +1938,13 @@ Material LoadMaterialDefault(void)
return material;
}
+// Check if a material is ready
+bool IsMaterialReady(Material material)
+{
+ return ((material.maps != NULL) && // Validate material contain some map
+ (material.shader.id > 0)); // Validate material shader is valid
+}
+
// Unload material from memory
void UnloadMaterial(Material material)
{
@@ -1822,7 +1990,7 @@ ModelAnimation *LoadModelAnimations(const char *fileName, unsigned int *animCoun
if (IsFileExtension(fileName, ".m3d")) animations = LoadModelAnimationsM3D(fileName, animCount);
#endif
#if defined(SUPPORT_FILEFORMAT_GLTF)
- //if (IsFileExtension(fileName, ".gltf;.glb")) animations = LoadModelAnimationGLTF(fileName, animCount);
+ if (IsFileExtension(fileName, ".gltf;.glb")) animations = LoadModelAnimationsGLTF(fileName, animCount);
#endif
return animations;
@@ -1839,13 +2007,14 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
for (int m = 0; m < model.meshCount; m++)
{
Mesh mesh = model.meshes[m];
+
if (mesh.boneIds == NULL || mesh.boneWeights == NULL)
{
- TRACELOG(LOG_WARNING, "MODEL: UpdateModelAnimation Mesh %i has no connection to bones",m);
+ TRACELOG(LOG_WARNING, "MODEL: UpdateModelAnimation(): Mesh %i has no connection to bones", m);
continue;
}
- bool updated = false; // set to true when anim vertex information is updated
+ bool updated = false; // Flag to check when anim vertex information is updated
Vector3 animVertex = { 0 };
Vector3 animNormal = { 0 };
@@ -1862,13 +2031,13 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
float boneWeight = 0.0;
const int vValues = mesh.vertexCount*3;
- for (int vCounter = 0; vCounter < vValues; vCounter+=3)
+ for (int vCounter = 0; vCounter < vValues; vCounter += 3)
{
mesh.animVertices[vCounter] = 0;
mesh.animVertices[vCounter + 1] = 0;
mesh.animVertices[vCounter + 2] = 0;
- if (mesh.animNormals!=NULL)
+ if (mesh.animNormals != NULL)
{
mesh.animNormals[vCounter] = 0;
mesh.animNormals[vCounter + 1] = 0;
@@ -1879,16 +2048,15 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
for (int j = 0; j < 4; j++, boneCounter++)
{
boneWeight = mesh.boneWeights[boneCounter];
- // early stop when no transformation will be applied
- if (boneWeight == 0.0f)
- {
- continue;
- }
+
+ // Early stop when no transformation will be applied
+ if (boneWeight == 0.0f) continue;
+
boneId = mesh.boneIds[boneCounter];
//int boneIdParent = model.bones[boneId].parent;
inTranslation = model.bindPose[boneId].translation;
inRotation = model.bindPose[boneId].rotation;
- // inScale = model.bindPose[boneId].scale;
+ //inScale = model.bindPose[boneId].scale;
outTranslation = anim.framePoses[frame][boneId].translation;
outRotation = anim.framePoses[frame][boneId].rotation;
outScale = anim.framePoses[frame][boneId].scale;
@@ -1896,11 +2064,11 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
// Vertices processing
// NOTE: We use meshes.vertices (default vertex position) to calculate meshes.animVertices (animated vertex position)
animVertex = (Vector3){ mesh.vertices[vCounter], mesh.vertices[vCounter + 1], mesh.vertices[vCounter + 2] };
- animVertex = Vector3Multiply(animVertex, outScale);
animVertex = Vector3Subtract(animVertex, inTranslation);
+ animVertex = Vector3Multiply(animVertex, outScale);
animVertex = Vector3RotateByQuaternion(animVertex, QuaternionMultiply(outRotation, QuaternionInvert(inRotation)));
animVertex = Vector3Add(animVertex, outTranslation);
-// animVertex = Vector3Transform(animVertex, model.transform);
+ //animVertex = Vector3Transform(animVertex, model.transform);
mesh.animVertices[vCounter] += animVertex.x*boneWeight;
mesh.animVertices[vCounter + 1] += animVertex.y*boneWeight;
mesh.animVertices[vCounter + 2] += animVertex.z*boneWeight;
@@ -1920,10 +2088,11 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
}
// Upload new vertex data to GPU for model drawing
- // Only update data when values changed.
- if (updated){
- rlUpdateVertexBuffer(mesh.vboId[0], mesh.animVertices, mesh.vertexCount*3*sizeof(float), 0); // Update vertex position
- rlUpdateVertexBuffer(mesh.vboId[2], mesh.animNormals, mesh.vertexCount*3*sizeof(float), 0); // Update vertex normals
+ // NOTE: Only update data when values changed
+ if (updated)
+ {
+ rlUpdateVertexBuffer(mesh.vboId[0], mesh.animVertices, mesh.vertexCount*3*sizeof(float), 0); // Update vertex position
+ rlUpdateVertexBuffer(mesh.vboId[2], mesh.animNormals, mesh.vertexCount*3*sizeof(float), 0); // Update vertex normals
}
}
}
@@ -2288,7 +2457,7 @@ Mesh GenMeshCube(float width, float height, float length)
// Platonic solids:
par_shapes_mesh* par_shapes_create_tetrahedron(); // 4 sides polyhedron (pyramid)
par_shapes_mesh* par_shapes_create_cube(); // 6 sides polyhedron (cube)
-par_shapes_mesh* par_shapes_create_octahedron(); // 8 sides polyhedron (dyamond)
+par_shapes_mesh* par_shapes_create_octahedron(); // 8 sides polyhedron (diamond)
par_shapes_mesh* par_shapes_create_dodecahedron(); // 12 sides polyhedron
par_shapes_mesh* par_shapes_create_icosahedron(); // 20 sides polyhedron
*/
@@ -2373,7 +2542,7 @@ Mesh GenMeshSphere(float radius, int rings, int slices)
return mesh;
}
-// Generate hemi-sphere mesh (half sphere, no bottom cap)
+// Generate hemisphere mesh (half sphere, no bottom cap)
Mesh GenMeshHemiSphere(float radius, int rings, int slices)
{
Mesh mesh = { 0 };
@@ -2768,11 +2937,8 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
Color *pixels = LoadImageColors(cubicmap);
- int mapWidth = cubicmap.width;
- int mapHeight = cubicmap.height;
-
// NOTE: Max possible number of triangles numCubes*(12 triangles by cube)
- int maxTriangles = cubicmap.width*cubicmap.height*12;
+ int maxTriangles = cubicmap.width * cubicmap.height * 12;
int vCounter = 0; // Used to count vertices
int tcCounter = 0; // Used to count texcoords
@@ -2809,9 +2975,9 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
RectangleF topTexUV = { 0.0f, 0.5f, 0.5f, 0.5f };
RectangleF bottomTexUV = { 0.5f, 0.5f, 0.5f, 0.5f };
- for (int z = 0; z < mapHeight; ++z)
+ for (int z = 0; z < cubicmap.height; ++z)
{
- for (int x = 0; x < mapWidth; ++x)
+ for (int x = 0; x < cubicmap.width; ++x)
{
// Define the 8 vertex of the cube, we will combine them accordingly later...
Vector3 v1 = { w*(x - 0.5f), h2, h*(z - 0.5f) };
@@ -3056,7 +3222,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
}
}
- // Move data from mapVertices temp arays to vertices float array
+ // Move data from mapVertices temp arrays to vertices float array
mesh.vertexCount = vCounter;
mesh.triangleCount = vCounter/3;
@@ -3140,9 +3306,15 @@ BoundingBox GetMeshBoundingBox(Mesh mesh)
// Compute mesh tangents
// NOTE: To calculate mesh tangents and binormals we need mesh vertex positions and texture coordinates
-// Implementation base don: https://answers.unity.com/questions/7789/calculating-tangents-vector4.html
+// Implementation based on: https://answers.unity.com/questions/7789/calculating-tangents-vector4.html
void GenMeshTangents(Mesh *mesh)
{
+ if ((mesh->vertices == NULL) || (mesh->texcoords == NULL))
+ {
+ TRACELOG(LOG_WARNING, "MESH: Tangents generation requires texcoord vertex attribute data");
+ return;
+ }
+
if (mesh->tangents == NULL) mesh->tangents = (float *)RL_MALLOC(mesh->vertexCount*4*sizeof(float));
else
{
@@ -3222,7 +3394,7 @@ void GenMeshTangents(Mesh *mesh)
{
if (mesh->vboId[SHADER_LOC_VERTEX_TANGENT] != 0)
{
- // Upate existing vertex buffer
+ // Update existing vertex buffer
rlUpdateVertexBuffer(mesh->vboId[SHADER_LOC_VERTEX_TANGENT], mesh->tangents, mesh->vertexCount*4*sizeof(float), 0);
}
else
@@ -3319,7 +3491,7 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector
void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint)
{
// NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width
- Vector2 sizeRatio = { size.x*(float)source.width/source.height, size.y };
+ Vector2 sizeRatio = { size.x*fabsf((float)source.width/source.height), size.y };
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
@@ -3385,21 +3557,40 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
rlBegin(RL_QUADS);
rlColor4ub(tint.r, tint.g, tint.b, tint.a);
- // Bottom-left corner for texture and quad
- rlTexCoord2f((float)source.x/texture.width, (float)source.y/texture.height);
- rlVertex3f(topLeft.x, topLeft.y, topLeft.z);
+ if (sizeRatio.x * sizeRatio.y >= 0.0f)
+ {
+ // Bottom-left corner for texture and quad
+ rlTexCoord2f((float)source.x/texture.width, (float)source.y/texture.height);
+ rlVertex3f(topLeft.x, topLeft.y, topLeft.z);
- // Top-left corner for texture and quad
- rlTexCoord2f((float)source.x/texture.width, (float)(source.y + source.height)/texture.height);
- rlVertex3f(bottomLeft.x, bottomLeft.y, bottomLeft.z);
+ // Top-left corner for texture and quad
+ rlTexCoord2f((float)source.x/texture.width, (float)(source.y + source.height)/texture.height);
+ rlVertex3f(bottomLeft.x, bottomLeft.y, bottomLeft.z);
- // Top-right corner for texture and quad
- rlTexCoord2f((float)(source.x + source.width)/texture.width, (float)(source.y + source.height)/texture.height);
- rlVertex3f(bottomRight.x, bottomRight.y, bottomRight.z);
+ // Top-right corner for texture and quad
+ rlTexCoord2f((float)(source.x + source.width)/texture.width, (float)(source.y + source.height)/texture.height);
+ rlVertex3f(bottomRight.x, bottomRight.y, bottomRight.z);
+
+ // Bottom-right corner for texture and quad
+ rlTexCoord2f((float)(source.x + source.width)/texture.width, (float)source.y/texture.height);
+ rlVertex3f(topRight.x, topRight.y, topRight.z);
+ }
+ else
+ {
+ // Reverse vertex order if the size has only one negative dimension
+ rlTexCoord2f((float)(source.x + source.width)/texture.width, (float)source.y/texture.height);
+ rlVertex3f(topRight.x, topRight.y, topRight.z);
+
+ rlTexCoord2f((float)(source.x + source.width)/texture.width, (float)(source.y + source.height)/texture.height);
+ rlVertex3f(bottomRight.x, bottomRight.y, bottomRight.z);
+
+ rlTexCoord2f((float)source.x/texture.width, (float)(source.y + source.height)/texture.height);
+ rlVertex3f(bottomLeft.x, bottomLeft.y, bottomLeft.z);
+
+ rlTexCoord2f((float)source.x/texture.width, (float)source.y/texture.height);
+ rlVertex3f(topLeft.x, topLeft.y, topLeft.z);
+ }
- // Bottom-right corner for texture and quad
- rlTexCoord2f((float)(source.x + source.width)/texture.width, (float)source.y/texture.height);
- rlVertex3f(topRight.x, topRight.y, topRight.z);
rlEnd();
rlSetTexture(0);
@@ -3556,7 +3747,7 @@ RayCollision GetRayCollisionBox(Ray ray, BoundingBox box)
// NOTE: We use an additional .01 to fix numerical errors
collision.normal = Vector3Scale(collision.normal, 2.01f);
collision.normal = Vector3Divide(collision.normal, Vector3Subtract(box.max, box.min));
- // The relevant elemets of the vector are now slightly larger than 1.0f (or smaller than -1.0f)
+ // The relevant elements of the vector are now slightly larger than 1.0f (or smaller than -1.0f)
// and the others are somewhere between -1.0 and 1.0 casting to int is exactly our wanted normal!
collision.normal.x = (float)((int)collision.normal.x);
collision.normal.y = (float)((int)collision.normal.y);
@@ -3656,7 +3847,7 @@ RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3
// Calculate u parameter and test bound
u = Vector3DotProduct(tv, p)*invDet;
- // The intersection lies outside of the triangle
+ // The intersection lies outside the triangle
if ((u < 0.0f) || (u > 1.0f)) return collision;
// Prepare to test v parameter
@@ -3665,7 +3856,7 @@ RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3
// Calculate V parameter and test bound
v = Vector3DotProduct(ray.direction, q)*invDet;
- // The intersection lies outside of the triangle
+ // The intersection lies outside the triangle
if ((v < 0.0f) || ((u + v) > 1.0f)) return collision;
t = Vector3DotProduct(edge2, q)*invDet;
@@ -3698,6 +3889,29 @@ RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Ve
//----------------------------------------------------------------------------------
// Module specific Functions Definition
//----------------------------------------------------------------------------------
+#if defined(SUPPORT_FILEFORMAT_IQM) || defined(SUPPORT_FILEFORMAT_GLTF)
+// Build pose from parent joints
+// NOTE: Required for animations loading (required by IQM and GLTF)
+static void BuildPoseFromParentJoints(BoneInfo *bones, int boneCount, Transform *transforms)
+{
+ for (int i = 0; i < boneCount; i++)
+ {
+ if (bones[i].parent >= 0)
+ {
+ if (bones[i].parent > i)
+ {
+ TRACELOG(LOG_WARNING, "Assumes bones are toplogically sorted, but bone %d has parent %d. Skipping.", i, bones[i].parent);
+ continue;
+ }
+ transforms[i].rotation = QuaternionMultiply(transforms[bones[i].parent].rotation, transforms[i].rotation);
+ transforms[i].translation = Vector3RotateByQuaternion(transforms[i].translation, transforms[bones[i].parent].rotation);
+ transforms[i].translation = Vector3Add(transforms[i].translation, transforms[bones[i].parent].translation);
+ transforms[i].scale = Vector3Multiply(transforms[i].scale, transforms[bones[i].parent].scale);
+ }
+ }
+}
+#endif
+
#if defined(SUPPORT_FILEFORMAT_OBJ)
// Load OBJ mesh data
//
@@ -3742,12 +3956,12 @@ static Model LoadOBJ(const char *fileName)
{
model.materialCount = materialCount;
model.materials = (Material *)RL_CALLOC(model.materialCount, sizeof(Material));
- TraceLog(LOG_INFO, "MODEL: model has %i material meshes", materialCount);
+ TRACELOG(LOG_INFO, "MODEL: model has %i material meshes", materialCount);
}
else
{
model.meshCount = 1;
- TraceLog(LOG_INFO, "MODEL: No materials, putting all meshes in a default material");
+ TRACELOG(LOG_INFO, "MODEL: No materials, putting all meshes in a default material");
}
model.meshes = (Mesh *)RL_CALLOC(model.meshCount, sizeof(Mesh));
@@ -3756,7 +3970,7 @@ static Model LoadOBJ(const char *fileName)
// Count the faces for each material
int *matFaces = RL_CALLOC(model.meshCount, sizeof(int));
- // iff no materials are present use all faces on one mesh
+ // if no materials are present use all faces on one mesh
if (materialCount > 0)
{
for (unsigned int fi = 0; fi < attrib.num_faces; fi++)
@@ -3832,33 +4046,7 @@ static Model LoadOBJ(const char *fileName)
}
// Init model materials
- for (unsigned int m = 0; m < materialCount; m++)
- {
- // Init material to default
- // NOTE: Uses default shader, which only supports MATERIAL_MAP_DIFFUSE
- model.materials[m] = LoadMaterialDefault();
-
- // Get default texture, in case no texture is defined
- // NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8
- model.materials[m].maps[MATERIAL_MAP_DIFFUSE].texture = (Texture2D){ rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
-
- if (materials[m].diffuse_texname != NULL) model.materials[m].maps[MATERIAL_MAP_DIFFUSE].texture = LoadTexture(materials[m].diffuse_texname); //char *diffuse_texname; // map_Kd
-
- model.materials[m].maps[MATERIAL_MAP_DIFFUSE].color = (Color){ (unsigned char)(materials[m].diffuse[0]*255.0f), (unsigned char)(materials[m].diffuse[1]*255.0f), (unsigned char)(materials[m].diffuse[2]*255.0f), 255 }; //float diffuse[3];
- model.materials[m].maps[MATERIAL_MAP_DIFFUSE].value = 0.0f;
-
- if (materials[m].specular_texname != NULL) model.materials[m].maps[MATERIAL_MAP_SPECULAR].texture = LoadTexture(materials[m].specular_texname); //char *specular_texname; // map_Ks
- model.materials[m].maps[MATERIAL_MAP_SPECULAR].color = (Color){ (unsigned char)(materials[m].specular[0]*255.0f), (unsigned char)(materials[m].specular[1]*255.0f), (unsigned char)(materials[m].specular[2]*255.0f), 255 }; //float specular[3];
- model.materials[m].maps[MATERIAL_MAP_SPECULAR].value = 0.0f;
-
- if (materials[m].bump_texname != NULL) model.materials[m].maps[MATERIAL_MAP_NORMAL].texture = LoadTexture(materials[m].bump_texname); //char *bump_texname; // map_bump, bump
- model.materials[m].maps[MATERIAL_MAP_NORMAL].color = WHITE;
- model.materials[m].maps[MATERIAL_MAP_NORMAL].value = materials[m].shininess;
-
- model.materials[m].maps[MATERIAL_MAP_EMISSION].color = (Color){ (unsigned char)(materials[m].emission[0]*255.0f), (unsigned char)(materials[m].emission[1]*255.0f), (unsigned char)(materials[m].emission[2]*255.0f), 255 }; //float emission[3];
-
- if (materials[m].displacement_texname != NULL) model.materials[m].maps[MATERIAL_MAP_HEIGHT].texture = LoadTexture(materials[m].displacement_texname); //char *displacement_texname; // disp
- }
+ ProcessMaterialsOBJ(model.materials, materials, materialCount);
tinyobj_attrib_free(&attrib);
tinyobj_shapes_free(meshes, meshCount);
@@ -4033,11 +4221,11 @@ static Model LoadIQM(const char *fileName)
for (int i = 0; i < model.meshCount; i++)
{
//fseek(iqmFile, iqmHeader->ofs_text + imesh[i].name, SEEK_SET);
- //fread(name, sizeof(char)*MESH_NAME_LENGTH, 1, iqmFile);
+ //fread(name, sizeof(char), MESH_NAME_LENGTH, iqmFile);
memcpy(name, fileDataPtr + iqmHeader->ofs_text + imesh[i].name, MESH_NAME_LENGTH*sizeof(char));
//fseek(iqmFile, iqmHeader->ofs_text + imesh[i].material, SEEK_SET);
- //fread(material, sizeof(char)*MATERIAL_NAME_LENGTH, 1, iqmFile);
+ //fread(material, sizeof(char), MATERIAL_NAME_LENGTH, iqmFile);
memcpy(material, fileDataPtr + iqmHeader->ofs_text + imesh[i].material, MATERIAL_NAME_LENGTH*sizeof(char));
model.materials[i] = LoadMaterialDefault();
@@ -4056,7 +4244,7 @@ static Model LoadIQM(const char *fileName)
model.meshes[i].triangleCount = imesh[i].num_triangles;
model.meshes[i].indices = RL_CALLOC(model.meshes[i].triangleCount*3, sizeof(unsigned short));
- // Animated verted data, what we actually process for rendering
+ // Animated vertex data, what we actually process for rendering
// NOTE: Animated vertex should be re-uploaded to GPU (if not using GPU skinning)
model.meshes[i].animVertices = RL_CALLOC(model.meshes[i].vertexCount*3, sizeof(float));
model.meshes[i].animNormals = RL_CALLOC(model.meshes[i].vertexCount*3, sizeof(float));
@@ -4065,7 +4253,7 @@ static Model LoadIQM(const char *fileName)
// Triangles data processing
tri = RL_MALLOC(iqmHeader->num_triangles*sizeof(IQMTriangle));
//fseek(iqmFile, iqmHeader->ofs_triangles, SEEK_SET);
- //fread(tri, iqmHeader->num_triangles*sizeof(IQMTriangle), 1, iqmFile);
+ //fread(tri, sizeof(IQMTriangle), iqmHeader->num_triangles, iqmFile);
memcpy(tri, fileDataPtr + iqmHeader->ofs_triangles, iqmHeader->num_triangles*sizeof(IQMTriangle));
for (int m = 0; m < model.meshCount; m++)
@@ -4087,7 +4275,7 @@ static Model LoadIQM(const char *fileName)
// Vertex arrays data processing
va = RL_MALLOC(iqmHeader->num_vertexarrays*sizeof(IQMVertexArray));
//fseek(iqmFile, iqmHeader->ofs_vertexarrays, SEEK_SET);
- //fread(va, iqmHeader->num_vertexarrays*sizeof(IQMVertexArray), 1, iqmFile);
+ //fread(va, sizeof(IQMVertexArray), iqmHeader->num_vertexarrays, iqmFile);
memcpy(va, fileDataPtr + iqmHeader->ofs_vertexarrays, iqmHeader->num_vertexarrays*sizeof(IQMVertexArray));
for (unsigned int i = 0; i < iqmHeader->num_vertexarrays; i++)
@@ -4206,7 +4394,7 @@ static Model LoadIQM(const char *fileName)
// Bones (joints) data processing
ijoint = RL_MALLOC(iqmHeader->num_joints*sizeof(IQMJoint));
//fseek(iqmFile, iqmHeader->ofs_joints, SEEK_SET);
- //fread(ijoint, iqmHeader->num_joints*sizeof(IQMJoint), 1, iqmFile);
+ //fread(ijoint, sizeof(IQMJoint), iqmHeader->num_joints, iqmFile);
memcpy(ijoint, fileDataPtr + iqmHeader->ofs_joints, iqmHeader->num_joints*sizeof(IQMJoint));
model.boneCount = iqmHeader->num_joints;
@@ -4218,7 +4406,7 @@ static Model LoadIQM(const char *fileName)
// Bones
model.bones[i].parent = ijoint[i].parent;
//fseek(iqmFile, iqmHeader->ofs_text + ijoint[i].name, SEEK_SET);
- //fread(model.bones[i].name, BONE_NAME_LENGTH*sizeof(char), 1, iqmFile);
+ //fread(model.bones[i].name, sizeof(char), BONE_NAME_LENGTH, iqmFile);
memcpy(model.bones[i].name, fileDataPtr + iqmHeader->ofs_text + ijoint[i].name, BONE_NAME_LENGTH*sizeof(char));
// Bind pose (base pose)
@@ -4236,17 +4424,7 @@ static Model LoadIQM(const char *fileName)
model.bindPose[i].scale.z = ijoint[i].scale[2];
}
- // Build bind pose from parent joints
- for (int i = 0; i < model.boneCount; i++)
- {
- if (model.bones[i].parent >= 0)
- {
- model.bindPose[i].rotation = QuaternionMultiply(model.bindPose[model.bones[i].parent].rotation, model.bindPose[i].rotation);
- model.bindPose[i].translation = Vector3RotateByQuaternion(model.bindPose[i].translation, model.bindPose[model.bones[i].parent].rotation);
- model.bindPose[i].translation = Vector3Add(model.bindPose[i].translation, model.bindPose[model.bones[i].parent].translation);
- model.bindPose[i].scale = Vector3Multiply(model.bindPose[i].scale, model.bindPose[model.bones[i].parent].scale);
- }
- }
+ BuildPoseFromParentJoints(model.bones, model.boneCount, model.bindPose);
RL_FREE(fileData);
@@ -4291,6 +4469,12 @@ static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, unsigned int
unsigned int num_extensions, ofs_extensions;
} IQMHeader;
+ typedef struct IQMJoint {
+ unsigned int name;
+ int parent;
+ float translate[3], rotate[4], scale[3];
+ } IQMJoint;
+
typedef struct IQMPose {
int parent;
unsigned int mask;
@@ -4326,14 +4510,14 @@ static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, unsigned int
// Get bones data
IQMPose *poses = RL_MALLOC(iqmHeader->num_poses*sizeof(IQMPose));
//fseek(iqmFile, iqmHeader->ofs_poses, SEEK_SET);
- //fread(poses, iqmHeader->num_poses*sizeof(IQMPose), 1, iqmFile);
+ //fread(poses, sizeof(IQMPose), iqmHeader->num_poses, iqmFile);
memcpy(poses, fileDataPtr + iqmHeader->ofs_poses, iqmHeader->num_poses*sizeof(IQMPose));
// Get animations data
*animCount = iqmHeader->num_anims;
IQMAnim *anim = RL_MALLOC(iqmHeader->num_anims*sizeof(IQMAnim));
//fseek(iqmFile, iqmHeader->ofs_anims, SEEK_SET);
- //fread(anim, iqmHeader->num_anims*sizeof(IQMAnim), 1, iqmFile);
+ //fread(anim, sizeof(IQMAnim), iqmHeader->num_anims, iqmFile);
memcpy(anim, fileDataPtr + iqmHeader->ofs_anims, iqmHeader->num_anims*sizeof(IQMAnim));
ModelAnimation *animations = RL_MALLOC(iqmHeader->num_anims*sizeof(ModelAnimation));
@@ -4341,20 +4525,28 @@ static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, unsigned int
// frameposes
unsigned short *framedata = RL_MALLOC(iqmHeader->num_frames*iqmHeader->num_framechannels*sizeof(unsigned short));
//fseek(iqmFile, iqmHeader->ofs_frames, SEEK_SET);
- //fread(framedata, iqmHeader->num_frames*iqmHeader->num_framechannels*sizeof(unsigned short), 1, iqmFile);
+ //fread(framedata, sizeof(unsigned short), iqmHeader->num_frames*iqmHeader->num_framechannels, iqmFile);
memcpy(framedata, fileDataPtr + iqmHeader->ofs_frames, iqmHeader->num_frames*iqmHeader->num_framechannels*sizeof(unsigned short));
+ // joints
+ IQMJoint *joints = RL_MALLOC(iqmHeader->num_joints*sizeof(IQMJoint));
+ memcpy(joints, fileDataPtr + iqmHeader->ofs_joints, iqmHeader->num_joints*sizeof(IQMJoint));
+
for (unsigned int a = 0; a < iqmHeader->num_anims; a++)
{
animations[a].frameCount = anim[a].num_frames;
animations[a].boneCount = iqmHeader->num_poses;
animations[a].bones = RL_MALLOC(iqmHeader->num_poses*sizeof(BoneInfo));
animations[a].framePoses = RL_MALLOC(anim[a].num_frames*sizeof(Transform *));
- // animations[a].framerate = anim.framerate; // TODO: Use framerate?
+ // animations[a].framerate = anim.framerate; // TODO: Use animation framerate data?
for (unsigned int j = 0; j < iqmHeader->num_poses; j++)
{
- strcpy(animations[a].bones[j].name, "ANIMJOINTNAME");
+ // If animations and skeleton are in the same file, copy bone names to anim
+ if (iqmHeader->num_joints > 0)
+ memcpy(animations[a].bones[j].name, fileDataPtr + iqmHeader->ofs_text + joints[j].name, BONE_NAME_LENGTH*sizeof(char));
+ else
+ strcpy(animations[a].bones[j].name, "ANIMJOINTNAME"); // default bone name otherwise
animations[a].bones[j].parent = poses[j].parent;
}
@@ -4468,6 +4660,7 @@ static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, unsigned int
RL_FREE(fileData);
+ RL_FREE(joints);
RL_FREE(framedata);
RL_FREE(poses);
RL_FREE(anim);
@@ -4483,7 +4676,7 @@ static Image LoadImageFromCgltfImage(cgltf_image *cgltfImage, const char *texPat
{
Image image = { 0 };
- if (cgltfImage->uri != NULL) // Check if image data is provided as a uri (base64 or path)
+ if (cgltfImage->uri != NULL) // Check if image data is provided as an uri (base64 or path)
{
if ((strlen(cgltfImage->uri) > 5) &&
(cgltfImage->uri[0] == 'd') &&
@@ -4511,7 +4704,7 @@ static Image LoadImageFromCgltfImage(cgltf_image *cgltfImage, const char *texPat
if (result == cgltf_result_success)
{
image = LoadImageFromMemory(".png", (unsigned char *)data, outSize);
- cgltf_free((cgltf_data*)data);
+ MemFree(data);
}
}
}
@@ -4547,6 +4740,35 @@ static Image LoadImageFromCgltfImage(cgltf_image *cgltfImage, const char *texPat
return image;
}
+// Load bone info from GLTF skin data
+static BoneInfo *LoadBoneInfoGLTF(cgltf_skin skin, int *boneCount)
+{
+ *boneCount = (int)skin.joints_count;
+ BoneInfo *bones = RL_MALLOC(skin.joints_count*sizeof(BoneInfo));
+
+ for (unsigned int i = 0; i < skin.joints_count; i++)
+ {
+ cgltf_node node = *skin.joints[i];
+ strncpy(bones[i].name, node.name, sizeof(bones[i].name));
+
+ // Find parent bone index
+ unsigned int parentIndex = -1;
+
+ for (unsigned int j = 0; j < skin.joints_count; j++)
+ {
+ if (skin.joints[j] == node.parent)
+ {
+ parentIndex = j;
+ break;
+ }
+ }
+
+ bones[i].parent = parentIndex;
+ }
+
+ return bones;
+}
+
// Load glTF file into model struct, .gltf and .glb supported
static Model LoadGLTF(const char *fileName)
{
@@ -4561,10 +4783,11 @@ static Model LoadGLTF(const char *fileName)
- Supports PBR metallic/roughness flow, loads material textures, values and colors
PBR specular/glossiness flow and extended texture flows not supported
- Supports multiple meshes per model (every primitives is loaded as a separate mesh)
+ - Supports basic animations
RESTRICTIONS:
- Only triangle meshes supported
- - Vertex attibute types and formats supported:
+ - Vertex attribute types and formats supported:
> Vertices (position): vec3: float
> Normals: vec3: float
> Texcoords: vec2: float
@@ -4615,7 +4838,7 @@ static Model LoadGLTF(const char *fileName)
TRACELOG(LOG_DEBUG, " > Textures count: %i", data->textures_count);
// Force reading data buffers (fills buffer_view->buffer->data)
- // NOTE: If an uri is defined to base64 data or external path, it's automatically loaded -> TODO: Verify this assumption
+ // NOTE: If an uri is defined to base64 data or external path, it's automatically loaded
result = cgltf_load_buffers(&options, data, fileName);
if (result != cgltf_result_success) TRACELOG(LOG_INFO, "MODEL: [%s] Failed to load mesh/material buffers", fileName);
@@ -4741,7 +4964,7 @@ static Model LoadGLTF(const char *fileName)
for (unsigned int j = 0; j < data->meshes[i].primitives[p].attributes_count; j++)
{
- // Check the different attributes for every pimitive
+ // Check the different attributes for every primitive
if (data->meshes[i].primitives[p].attributes[j].type == cgltf_attribute_type_position) // POSITION
{
cgltf_accessor *attribute = data->meshes[i].primitives[p].attributes[j].data;
@@ -4892,7 +5115,7 @@ static Model LoadGLTF(const char *fileName)
{
// The primitive actually keeps the pointer to the corresponding material,
// raylib instead assigns to the mesh the by its index, as loaded in model.materials array
- // To get the index, we check if material pointers match and we assign the corresponding index,
+ // To get the index, we check if material pointers match, and we assign the corresponding index,
// skipping index 0, the default material
if (&data->materials[m] == data->meshes[i].primitives[p].material)
{
@@ -4905,11 +5128,45 @@ static Model LoadGLTF(const char *fileName)
}
}
-/*
- // TODO: Load glTF meshes animation data
+ // Load glTF meshes animation data
// REF: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#skins
// REF: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#skinned-mesh-attributes
+ //
+ // LIMITATIONS:
+ // - Only supports 1 armature per file, and skips loading it if there are multiple armatures
+ // - Only supports linear interpolation (default method in Blender when checked "Always Sample Animations" when exporting a GLTF file)
+ // - Only supports translation/rotation/scale animation channel.path, weights not considered (i.e. morph targets)
//----------------------------------------------------------------------------------------------------
+ if (data->skins_count == 1)
+ {
+ cgltf_skin skin = data->skins[0];
+ model.bones = LoadBoneInfoGLTF(skin, &model.boneCount);
+ model.bindPose = RL_MALLOC(model.boneCount*sizeof(Transform));
+
+ for (int i = 0; i < model.boneCount; i++)
+ {
+ cgltf_node node = *skin.joints[i];
+ model.bindPose[i].translation.x = node.translation[0];
+ model.bindPose[i].translation.y = node.translation[1];
+ model.bindPose[i].translation.z = node.translation[2];
+
+ model.bindPose[i].rotation.x = node.rotation[0];
+ model.bindPose[i].rotation.y = node.rotation[1];
+ model.bindPose[i].rotation.z = node.rotation[2];
+ model.bindPose[i].rotation.w = node.rotation[3];
+
+ model.bindPose[i].scale.x = node.scale[0];
+ model.bindPose[i].scale.y = node.scale[1];
+ model.bindPose[i].scale.z = node.scale[2];
+ }
+
+ BuildPoseFromParentJoints(model.bones, model.boneCount, model.bindPose);
+ }
+ else if (data->skins_count > 1)
+ {
+ TRACELOG(LOG_ERROR, "MODEL: [%s] can only load one skin (armature) per model, but gltf skins_count == %i", fileName, data->skins_count);
+ }
+
for (unsigned int i = 0, meshIndex = 0; i < data->meshes_count; i++)
{
for (unsigned int p = 0; p < data->meshes[i].primitives_count; p++)
@@ -4931,7 +5188,6 @@ static Model LoadGLTF(const char *fileName)
model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount*4, sizeof(unsigned char));
// Load 4 components of unsigned char data type into mesh.boneIds
- // TODO: It seems LOAD_ATTRIBUTE() macro does not work as expected in some cases,
// for cgltf_attribute_type_joints we have:
// - data.meshes[0] (256 vertices)
// - 256 values, provided as cgltf_type_vec4 of bytes (4 byte per joint, stride 4)
@@ -4958,10 +5214,19 @@ static Model LoadGLTF(const char *fileName)
}
}
+ // Animated vertex data
+ model.meshes[meshIndex].animVertices = RL_CALLOC(model.meshes[meshIndex].vertexCount*3, sizeof(float));
+ memcpy(model.meshes[meshIndex].animVertices, model.meshes[meshIndex].vertices, model.meshes[meshIndex].vertexCount*3*sizeof(float));
+ model.meshes[meshIndex].animNormals = RL_CALLOC(model.meshes[meshIndex].vertexCount*3, sizeof(float));
+ if (model.meshes[meshIndex].normals != NULL) {
+ memcpy(model.meshes[meshIndex].animNormals, model.meshes[meshIndex].normals, model.meshes[meshIndex].vertexCount*3*sizeof(float));
+ }
+
meshIndex++; // Move to next mesh
}
+
}
-*/
+
// Free all cgltf loaded data
cgltf_free(data);
}
@@ -4972,6 +5237,225 @@ static Model LoadGLTF(const char *fileName)
return model;
}
+
+// Get interpolated pose for bone sampler at a specific time. Returns true on success.
+static bool GetPoseAtTimeGLTF(cgltf_accessor *input, cgltf_accessor *output, float time, void *data)
+{
+ // Input and output should have the same count
+ float tstart = 0.0f;
+ float tend = 0.0f;
+ int keyframe = 0; // Defaults to first pose
+
+ for (int i = 0; i < input->count - 1; i++)
+ {
+ cgltf_bool r1 = cgltf_accessor_read_float(input, i, &tstart, 1);
+ if (!r1) return false;
+
+ cgltf_bool r2 = cgltf_accessor_read_float(input, i + 1, &tend, 1);
+ if (!r2) return false;
+
+ if ((tstart <= time) && (time < tend))
+ {
+ keyframe = i;
+ break;
+ }
+ }
+
+ float t = (time - tstart)/(tend - tstart);
+ t = (t < 0.0f)? 0.0f : t;
+ t = (t > 1.0f)? 1.0f : t;
+
+ if (output->component_type != cgltf_component_type_r_32f) return false;
+
+ if (output->type == cgltf_type_vec3)
+ {
+ float tmp[3] = { 0.0f };
+ cgltf_accessor_read_float(output, keyframe, tmp, 3);
+ Vector3 v1 = {tmp[0], tmp[1], tmp[2]};
+ cgltf_accessor_read_float(output, keyframe+1, tmp, 3);
+ Vector3 v2 = {tmp[0], tmp[1], tmp[2]};
+ Vector3 *r = data;
+ *r = Vector3Lerp(v1, v2, t);
+ }
+ else if (output->type == cgltf_type_vec4)
+ {
+ float tmp[4] = { 0.0f };
+ cgltf_accessor_read_float(output, keyframe, tmp, 4);
+ Vector4 v1 = {tmp[0], tmp[1], tmp[2], tmp[3]};
+ cgltf_accessor_read_float(output, keyframe+1, tmp, 4);
+ Vector4 v2 = {tmp[0], tmp[1], tmp[2], tmp[3]};
+ Vector4 *r = data;
+
+ // Only v4 is for rotations, so we know it's a quaternion
+ *r = QuaternionSlerp(v1, v2, t);
+ }
+
+ return true;
+}
+
+#define GLTF_ANIMDELAY 17 // Animation frames delay, (~1000 ms/60 FPS = 16.666666* ms)
+
+static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, unsigned int *animCount)
+{
+ // glTF file loading
+ unsigned int dataSize = 0;
+ unsigned char *fileData = LoadFileData(fileName, &dataSize);
+
+ ModelAnimation *animations = NULL;
+
+ // glTF data loading
+ cgltf_options options = { 0 };
+ cgltf_data *data = NULL;
+ cgltf_result result = cgltf_parse(&options, fileData, dataSize, &data);
+
+ if (result != cgltf_result_success)
+ {
+ TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load glTF data", fileName);
+ *animCount = 0;
+ return NULL;
+ }
+
+ result = cgltf_load_buffers(&options, data, fileName);
+ if (result != cgltf_result_success) TRACELOG(LOG_INFO, "MODEL: [%s] Failed to load animation buffers", fileName);
+
+ if (result == cgltf_result_success)
+ {
+ if (data->skins_count == 1)
+ {
+ cgltf_skin skin = data->skins[0];
+ *animCount = (int)data->animations_count;
+ animations = RL_MALLOC(data->animations_count*sizeof(ModelAnimation));
+
+ for (unsigned int i = 0; i < data->animations_count; i++)
+ {
+ animations[i].bones = LoadBoneInfoGLTF(skin, &animations[i].boneCount);
+
+ cgltf_animation animData = data->animations[i];
+
+ struct Channels {
+ cgltf_animation_channel *translate;
+ cgltf_animation_channel *rotate;
+ cgltf_animation_channel *scale;
+ };
+
+ struct Channels *boneChannels = RL_CALLOC(animations[i].boneCount, sizeof(struct Channels));
+ float animDuration = 0.0f;
+
+ for (unsigned int j = 0; j < animData.channels_count; j++)
+ {
+ cgltf_animation_channel channel = animData.channels[j];
+ int boneIndex = -1;
+
+ for (unsigned int k = 0; k < skin.joints_count; k++)
+ {
+ if (animData.channels[j].target_node == skin.joints[k])
+ {
+ boneIndex = k;
+ break;
+ }
+ }
+
+ if (boneIndex == -1)
+ {
+ // Animation channel for a node not in the armature
+ continue;
+ }
+
+ if (animData.channels[j].sampler->interpolation == cgltf_interpolation_type_linear)
+ {
+ if (channel.target_path == cgltf_animation_path_type_translation)
+ {
+ boneChannels[boneIndex].translate = &animData.channels[j];
+ }
+ else if (channel.target_path == cgltf_animation_path_type_rotation)
+ {
+ boneChannels[boneIndex].rotate = &animData.channels[j];
+ }
+ else if (channel.target_path == cgltf_animation_path_type_scale)
+ {
+ boneChannels[boneIndex].scale = &animData.channels[j];
+ }
+ else
+ {
+ TRACELOG(LOG_WARNING, "MODEL: [%s] Unsupported target_path on channel %d's sampler for animation %d. Skipping.", fileName, j, i);
+ }
+ }
+ else TRACELOG(LOG_WARNING, "MODEL: [%s] Only linear interpolation curves are supported for GLTF animation.", fileName);
+
+ float t = 0.0f;
+ cgltf_bool r = cgltf_accessor_read_float(channel.sampler->input, channel.sampler->input->count - 1, &t, 1);
+
+ if (!r)
+ {
+ TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load input time", fileName);
+ continue;
+ }
+
+ animDuration = (t > animDuration)? t : animDuration;
+ }
+
+ strncpy(animations[i].name, animData.name, sizeof(animations[i].name));
+ animations[i].name[sizeof(animations[i].name) - 1] = '\0';
+
+ animations[i].frameCount = (int)(animDuration*1000.0f/GLTF_ANIMDELAY);
+ animations[i].framePoses = RL_MALLOC(animations[i].frameCount*sizeof(Transform *));
+
+ for (int j = 0; j < animations[i].frameCount; j++)
+ {
+ animations[i].framePoses[j] = RL_MALLOC(animations[i].boneCount*sizeof(Transform));
+ float time = ((float) j*GLTF_ANIMDELAY)/1000.0f;
+
+ for (int k = 0; k < animations[i].boneCount; k++)
+ {
+ Vector3 translation = {0, 0, 0};
+ Quaternion rotation = {0, 0, 0, 1};
+ Vector3 scale = {1, 1, 1};
+
+ if (boneChannels[k].translate)
+ {
+ if (!GetPoseAtTimeGLTF(boneChannels[k].translate->sampler->input, boneChannels[k].translate->sampler->output, time, &translation))
+ {
+ TRACELOG(LOG_INFO, "MODEL: [%s] Failed to load translate pose data for bone %s", fileName, animations[i].bones[k].name);
+ }
+ }
+
+ if (boneChannels[k].rotate)
+ {
+ if (!GetPoseAtTimeGLTF(boneChannels[k].rotate->sampler->input, boneChannels[k].rotate->sampler->output, time, &rotation))
+ {
+ TRACELOG(LOG_INFO, "MODEL: [%s] Failed to load rotate pose data for bone %s", fileName, animations[i].bones[k].name);
+ }
+ }
+
+ if (boneChannels[k].scale)
+ {
+ if (!GetPoseAtTimeGLTF(boneChannels[k].scale->sampler->input, boneChannels[k].scale->sampler->output, time, &scale))
+ {
+ TRACELOG(LOG_INFO, "MODEL: [%s] Failed to load scale pose data for bone %s", fileName, animations[i].bones[k].name);
+ }
+ }
+
+ animations[i].framePoses[j][k] = (Transform){
+ .translation = translation,
+ .rotation = rotation,
+ .scale = scale
+ };
+ }
+
+ BuildPoseFromParentJoints(animations[i].bones, animations[i].boneCount, animations[i].framePoses[j]);
+ }
+
+ TRACELOG(LOG_INFO, "MODEL: [%s] Loaded animation: %s (%d frames, %fs)", fileName, animData.name, animations[i].frameCount, animDuration);
+ RL_FREE(boneChannels);
+ }
+ }
+ else TRACELOG(LOG_ERROR, "MODEL: [%s] expected exactly one skin to load animation data from, but found %i", fileName, data->skins_count);
+
+ cgltf_free(data);
+ }
+ UnloadFileData(fileData);
+ return animations;
+}
#endif
#if defined(SUPPORT_FILEFORMAT_VOX)
@@ -5051,7 +5535,6 @@ static Model LoadVOX(const char *fileName)
memcpy(pmesh->vertices, pvertices, size);
// Copy indices
- // TODO: Compute globals indices array
size = voxarray.indices.used*sizeof(unsigned short);
pmesh->indices = RL_MALLOC(size);
memcpy(pmesh->indices, pindices, size);
@@ -5093,7 +5576,7 @@ static Model LoadM3D(const char *fileName)
m3dp_t *prop = NULL;
unsigned int bytesRead = 0;
unsigned char *fileData = LoadFileData(fileName, &bytesRead);
- int i, j, k, l, n, mi = -2;
+ int i, j, k, l, n, mi = -2, vcolor = 0;
if (fileData != NULL)
{
@@ -5123,10 +5606,13 @@ static Model LoadM3D(const char *fileName)
}
else
{
- model.meshCount = model.materialCount = 1;
+ model.meshCount = 1; model.materialCount = 0;
TRACELOG(LOG_INFO, "MODEL: No materials, putting all meshes in a default material");
}
+ // We always need a default material, so we add +1
+ model.materialCount++;
+
model.meshes = (Mesh *)RL_CALLOC(model.meshCount, sizeof(Mesh));
model.meshMaterial = (int *)RL_CALLOC(model.meshCount, sizeof(int));
model.materials = (Material *)RL_CALLOC(model.materialCount + 1, sizeof(Material));
@@ -5134,12 +5620,12 @@ static Model LoadM3D(const char *fileName)
// Map no material to index 0 with default shader, everything else materialid + 1
model.materials[0] = LoadMaterialDefault();
- for (i = l = 0, k = -1; i < m3d->numface; i++, l++)
+ for (i = l = 0, k = -1; i < (int)m3d->numface; i++, l++)
{
// Materials are grouped together
if (mi != m3d->face[i].materialid)
{
- // there should be only one material switch per material kind, but be bulletproof for unoptimal model files
+ // there should be only one material switch per material kind, but be bulletproof for non-optimal model files
if (k + 1 >= model.meshCount)
{
model.meshCount++;
@@ -5151,19 +5637,25 @@ static Model LoadM3D(const char *fileName)
k++;
mi = m3d->face[i].materialid;
- for (j = i, l = 0; (j < m3d->numface) && (mi == m3d->face[j].materialid); j++, l++);
+ // Only allocate colors VertexBuffer if there's a color vertex in the model for this material batch
+ // if all colors are fully transparent black for all verteces of this materal, then we assume no vertex colors
+ for (j = i, l = vcolor = 0; (j < (int)m3d->numface) && (mi == m3d->face[j].materialid); j++, l++)
+ {
+ if (!m3d->vertex[m3d->face[j].vertex[0]].color ||
+ !m3d->vertex[m3d->face[j].vertex[1]].color ||
+ !m3d->vertex[m3d->face[j].vertex[2]].color) vcolor = 1;
+ }
model.meshes[k].vertexCount = l*3;
model.meshes[k].triangleCount = l;
model.meshes[k].vertices = (float *)RL_CALLOC(model.meshes[k].vertexCount*3, sizeof(float));
model.meshes[k].texcoords = (float *)RL_CALLOC(model.meshes[k].vertexCount*2, sizeof(float));
model.meshes[k].normals = (float *)RL_CALLOC(model.meshes[k].vertexCount*3, sizeof(float));
- // without material, we rely on vertex colors
- if (mi == M3D_UNDEF && model.meshes[k].colors == NULL)
- {
- model.meshes[k].colors = RL_CALLOC(model.meshes[k].vertexCount*4, sizeof(unsigned char));
- for (j = 0; j < model.meshes[k].vertexCount*4; j += 4) memcpy(&model.meshes[k].colors[j], &WHITE, 4);
- }
+
+ // If no map is provided, or we have colors defined, we allocate storage for vertex colors
+ // M3D specs only consider vertex colors if no material is provided, however raylib uses both and mixes the colors
+ if ((mi == M3D_UNDEF) || vcolor) model.meshes[k].colors = RL_CALLOC(model.meshes[k].vertexCount*4, sizeof(unsigned char));
+
if (m3d->numbone && m3d->numskin)
{
model.meshes[k].boneIds = (unsigned char *)RL_CALLOC(model.meshes[k].vertexCount*4, sizeof(unsigned char));
@@ -5171,53 +5663,54 @@ static Model LoadM3D(const char *fileName)
model.meshes[k].animVertices = (float *)RL_CALLOC(model.meshes[k].vertexCount*3, sizeof(float));
model.meshes[k].animNormals = (float *)RL_CALLOC(model.meshes[k].vertexCount*3, sizeof(float));
}
+
model.meshMaterial[k] = mi + 1;
l = 0;
}
// Process meshes per material, add triangles
- model.meshes[k].vertices[l * 9 + 0] = m3d->vertex[m3d->face[i].vertex[0]].x*m3d->scale;
- model.meshes[k].vertices[l * 9 + 1] = m3d->vertex[m3d->face[i].vertex[0]].y*m3d->scale;
- model.meshes[k].vertices[l * 9 + 2] = m3d->vertex[m3d->face[i].vertex[0]].z*m3d->scale;
- model.meshes[k].vertices[l * 9 + 3] = m3d->vertex[m3d->face[i].vertex[1]].x*m3d->scale;
- model.meshes[k].vertices[l * 9 + 4] = m3d->vertex[m3d->face[i].vertex[1]].y*m3d->scale;
- model.meshes[k].vertices[l * 9 + 5] = m3d->vertex[m3d->face[i].vertex[1]].z*m3d->scale;
- model.meshes[k].vertices[l * 9 + 6] = m3d->vertex[m3d->face[i].vertex[2]].x*m3d->scale;
- model.meshes[k].vertices[l * 9 + 7] = m3d->vertex[m3d->face[i].vertex[2]].y*m3d->scale;
- model.meshes[k].vertices[l * 9 + 8] = m3d->vertex[m3d->face[i].vertex[2]].z*m3d->scale;
+ model.meshes[k].vertices[l*9 + 0] = m3d->vertex[m3d->face[i].vertex[0]].x*m3d->scale;
+ model.meshes[k].vertices[l*9 + 1] = m3d->vertex[m3d->face[i].vertex[0]].y*m3d->scale;
+ model.meshes[k].vertices[l*9 + 2] = m3d->vertex[m3d->face[i].vertex[0]].z*m3d->scale;
+ model.meshes[k].vertices[l*9 + 3] = m3d->vertex[m3d->face[i].vertex[1]].x*m3d->scale;
+ model.meshes[k].vertices[l*9 + 4] = m3d->vertex[m3d->face[i].vertex[1]].y*m3d->scale;
+ model.meshes[k].vertices[l*9 + 5] = m3d->vertex[m3d->face[i].vertex[1]].z*m3d->scale;
+ model.meshes[k].vertices[l*9 + 6] = m3d->vertex[m3d->face[i].vertex[2]].x*m3d->scale;
+ model.meshes[k].vertices[l*9 + 7] = m3d->vertex[m3d->face[i].vertex[2]].y*m3d->scale;
+ model.meshes[k].vertices[l*9 + 8] = m3d->vertex[m3d->face[i].vertex[2]].z*m3d->scale;
- if (mi == M3D_UNDEF)
+ // without vertex color (full transparency), we use the default color
+ if (model.meshes[k].colors != NULL)
{
- // without vertex color (full transparency), we use the default color
if (m3d->vertex[m3d->face[i].vertex[0]].color & 0xFF000000)
- memcpy(&model.meshes[k].colors[l * 12 + 0], &m3d->vertex[m3d->face[i].vertex[0]].color, 4);
+ memcpy(&model.meshes[k].colors[l*12 + 0], &m3d->vertex[m3d->face[i].vertex[0]].color, 4);
if (m3d->vertex[m3d->face[i].vertex[1]].color & 0xFF000000)
- memcpy(&model.meshes[k].colors[l * 12 + 4], &m3d->vertex[m3d->face[i].vertex[1]].color, 4);
+ memcpy(&model.meshes[k].colors[l*12 + 4], &m3d->vertex[m3d->face[i].vertex[1]].color, 4);
if (m3d->vertex[m3d->face[i].vertex[2]].color & 0xFF000000)
- memcpy(&model.meshes[k].colors[l * 12 + 8], &m3d->vertex[m3d->face[i].vertex[2]].color, 4);
+ memcpy(&model.meshes[k].colors[l*12 + 8], &m3d->vertex[m3d->face[i].vertex[2]].color, 4);
}
if (m3d->face[i].texcoord[0] != M3D_UNDEF)
{
- model.meshes[k].texcoords[l * 6 + 0] = m3d->tmap[m3d->face[i].texcoord[0]].u;
- model.meshes[k].texcoords[l * 6 + 1] = 1.0 - m3d->tmap[m3d->face[i].texcoord[0]].v;
- model.meshes[k].texcoords[l * 6 + 2] = m3d->tmap[m3d->face[i].texcoord[1]].u;
- model.meshes[k].texcoords[l * 6 + 3] = 1.0 - m3d->tmap[m3d->face[i].texcoord[1]].v;
- model.meshes[k].texcoords[l * 6 + 4] = m3d->tmap[m3d->face[i].texcoord[2]].u;
- model.meshes[k].texcoords[l * 6 + 5] = 1.0 - m3d->tmap[m3d->face[i].texcoord[2]].v;
+ model.meshes[k].texcoords[l*6 + 0] = m3d->tmap[m3d->face[i].texcoord[0]].u;
+ model.meshes[k].texcoords[l*6 + 1] = 1.0f - m3d->tmap[m3d->face[i].texcoord[0]].v;
+ model.meshes[k].texcoords[l*6 + 2] = m3d->tmap[m3d->face[i].texcoord[1]].u;
+ model.meshes[k].texcoords[l*6 + 3] = 1.0f - m3d->tmap[m3d->face[i].texcoord[1]].v;
+ model.meshes[k].texcoords[l*6 + 4] = m3d->tmap[m3d->face[i].texcoord[2]].u;
+ model.meshes[k].texcoords[l*6 + 5] = 1.0f - m3d->tmap[m3d->face[i].texcoord[2]].v;
}
if (m3d->face[i].normal[0] != M3D_UNDEF)
{
- model.meshes[k].normals[l * 9 + 0] = m3d->vertex[m3d->face[i].normal[0]].x;
- model.meshes[k].normals[l * 9 + 1] = m3d->vertex[m3d->face[i].normal[0]].y;
- model.meshes[k].normals[l * 9 + 2] = m3d->vertex[m3d->face[i].normal[0]].z;
- model.meshes[k].normals[l * 9 + 3] = m3d->vertex[m3d->face[i].normal[1]].x;
- model.meshes[k].normals[l * 9 + 4] = m3d->vertex[m3d->face[i].normal[1]].y;
- model.meshes[k].normals[l * 9 + 5] = m3d->vertex[m3d->face[i].normal[1]].z;
- model.meshes[k].normals[l * 9 + 6] = m3d->vertex[m3d->face[i].normal[2]].x;
- model.meshes[k].normals[l * 9 + 7] = m3d->vertex[m3d->face[i].normal[2]].y;
- model.meshes[k].normals[l * 9 + 8] = m3d->vertex[m3d->face[i].normal[2]].z;
+ model.meshes[k].normals[l*9 + 0] = m3d->vertex[m3d->face[i].normal[0]].x;
+ model.meshes[k].normals[l*9 + 1] = m3d->vertex[m3d->face[i].normal[0]].y;
+ model.meshes[k].normals[l*9 + 2] = m3d->vertex[m3d->face[i].normal[0]].z;
+ model.meshes[k].normals[l*9 + 3] = m3d->vertex[m3d->face[i].normal[1]].x;
+ model.meshes[k].normals[l*9 + 4] = m3d->vertex[m3d->face[i].normal[1]].y;
+ model.meshes[k].normals[l*9 + 5] = m3d->vertex[m3d->face[i].normal[1]].z;
+ model.meshes[k].normals[l*9 + 6] = m3d->vertex[m3d->face[i].normal[2]].x;
+ model.meshes[k].normals[l*9 + 7] = m3d->vertex[m3d->face[i].normal[2]].y;
+ model.meshes[k].normals[l*9 + 8] = m3d->vertex[m3d->face[i].normal[2]].z;
}
// Add skin (vertex / bone weight pairs)
@@ -5228,7 +5721,7 @@ static Model LoadM3D(const char *fileName)
int skinid = m3d->vertex[m3d->face[i].vertex[n]].skinid;
// Check if there is a skin for this mesh, should be, just failsafe
- if (skinid != M3D_UNDEF && skinid < m3d->numskin)
+ if (skinid != M3D_UNDEF && skinid < (int)m3d->numskin)
{
for (j = 0; j < 4; j++)
{
@@ -5240,15 +5733,15 @@ static Model LoadM3D(const char *fileName)
{
// raylib does not handle boneless meshes with skeletal animations, so
// we put all vertices without a bone into a special "no bone" bone
- model.meshes[k].boneIds[l * 12 + n * 4] = m3d->numbone;
- model.meshes[k].boneWeights[l * 12 + n * 4] = 1.0f;
+ model.meshes[k].boneIds[l*12 + n*4] = m3d->numbone;
+ model.meshes[k].boneWeights[l*12 + n*4] = 1.0f;
}
}
}
}
// Load materials
- for (i = 0; i < m3d->nummaterial; i++)
+ for (i = 0; i < (int)m3d->nummaterial; i++)
{
model.materials[i + 1] = LoadMaterialDefault();
@@ -5325,7 +5818,7 @@ static Model LoadM3D(const char *fileName)
model.bones = RL_CALLOC(model.boneCount, sizeof(BoneInfo));
model.bindPose = RL_CALLOC(model.boneCount, sizeof(Transform));
- for (i = 0; i < m3d->numbone; i++)
+ for (i = 0; i < (int)m3d->numbone; i++)
{
model.bones[i].parent = m3d->bone[i].parent;
strncpy(model.bones[i].name, m3d->bone[i].name, sizeof(model.bones[i].name));
@@ -5336,7 +5829,8 @@ static Model LoadM3D(const char *fileName)
model.bindPose[i].rotation.y = m3d->vertex[m3d->bone[i].ori].y;
model.bindPose[i].rotation.z = m3d->vertex[m3d->bone[i].ori].z;
model.bindPose[i].rotation.w = m3d->vertex[m3d->bone[i].ori].w;
- // TODO: if the orientation quaternion not normalized, then that's encoding scaling
+
+ // TODO: If the orientation quaternion is not normalized, then that's encoding scaling
model.bindPose[i].rotation = QuaternionNormalize(model.bindPose[i].rotation);
model.bindPose[i].scale.x = model.bindPose[i].scale.y = model.bindPose[i].scale.z = 1.0f;
@@ -5364,7 +5858,7 @@ static Model LoadM3D(const char *fileName)
}
// Load bone-pose default mesh into animation vertices. These will be updated when UpdateModelAnimation gets
- // called, but not before, however DrawMesh uses these if they exists (so not good if they are left empty).
+ // called, but not before, however DrawMesh uses these if they exist (so not good if they are left empty).
if (m3d->numbone && m3d->numskin)
{
for(i = 0; i < model.meshCount; i++)
@@ -5381,15 +5875,16 @@ static Model LoadM3D(const char *fileName)
return model;
}
+#define M3D_ANIMDELAY 17 // Animation frames delay, (~1000 ms/60 FPS = 16.666666* ms)
+
// Load M3D animation data
-#define M3D_ANIMDELAY 17 // that's roughly ~1000 msec / 60 FPS (16.666666* msec)
static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, unsigned int *animCount)
{
m3d_t *m3d = NULL;
unsigned int bytesRead = 0;
unsigned char *fileData = LoadFileData(fileName, &bytesRead);
ModelAnimation *animations = NULL;
- int i, j;
+ int i = 0, j = 0;
*animCount = 0;
@@ -5406,7 +5901,7 @@ static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, unsigned int
else TRACELOG(LOG_INFO, "MODEL: [%s] M3D data loaded successfully: %i animations, %i bones, %i skins", fileName,
m3d->numaction, m3d->numbone, m3d->numskin);
- // no animation or bone+skin?
+ // No animation or bone+skin?
if (!m3d->numaction || !m3d->numbone || !m3d->numskin)
{
m3d_free(m3d);
@@ -5426,7 +5921,7 @@ static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, unsigned int
// strncpy(animations[a].name, m3d->action[a].name, sizeof(animations[a].name));
TRACELOG(LOG_INFO, "MODEL: [%s] animation #%i: %i msec, %i frames", fileName, a, m3d->action[a].durationmsec, animations[a].frameCount);
- for (i = 0; i < m3d->numbone; i++)
+ for (i = 0; i < (int)m3d->numbone; i++)
{
animations[a].bones[i].parent = m3d->bone[i].parent;
strncpy(animations[a].bones[i].name, m3d->bone[i].name, sizeof(animations[a].bones[i].name));
@@ -5442,10 +5937,11 @@ static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, unsigned int
{
animations[a].framePoses[i] = RL_MALLOC((m3d->numbone + 1)*sizeof(Transform));
- m3db_t *pose = m3d_pose(m3d, a, i * M3D_ANIMDELAY);
+ m3db_t *pose = m3d_pose(m3d, a, i*M3D_ANIMDELAY);
+
if (pose != NULL)
{
- for (j = 0; j < m3d->numbone; j++)
+ for (j = 0; j < (int)m3d->numbone; j++)
{
animations[a].framePoses[i][j].translation.x = m3d->vertex[pose[j].pos].x*m3d->scale;
animations[a].framePoses[i][j].translation.y = m3d->vertex[pose[j].pos].y*m3d->scale;
diff --git a/src/rshapes.c b/src/rshapes.c
index f8d9db71f..f3061f8b3 100644
--- a/src/rshapes.c
+++ b/src/rshapes.c
@@ -2,31 +2,30 @@
*
* rshapes - Basic functions to draw 2d shapes and check collisions
*
-* NOTES:
-* Shapes can be draw using 3 types of primitives: LINES, TRIANGLES and QUADS.
-* Some functions implement two drawing options: TRIANGLES and QUADS, by default TRIANGLES
-* are used but QUADS implementation can be selected with SUPPORT_QUADS_DRAW_MODE define
+* ADDITIONAL NOTES:
+* Shapes can be draw using 3 types of primitives: LINES, TRIANGLES and QUADS.
+* Some functions implement two drawing options: TRIANGLES and QUADS, by default TRIANGLES
+* are used but QUADS implementation can be selected with SUPPORT_QUADS_DRAW_MODE define
*
-* Some functions define texture coordinates (rlTexCoord2f()) for the shapes and use a
-* user-provided texture with SetShapesTexture(), the pourpouse of this implementation
-* is allowing to reduce draw calls when combined with a texture-atlas.
+* Some functions define texture coordinates (rlTexCoord2f()) for the shapes and use a
+* user-provided texture with SetShapesTexture(), the pourpouse of this implementation
+* is allowing to reduce draw calls when combined with a texture-atlas.
*
-* By default, raylib sets the default texture and rectangle at InitWindow()[rcore] to one
-* white character of default font [rtext], this way, raylib text and shapes can be draw with
-* a single draw call and it also allows users to configure it the same way with their own fonts.
+* By default, raylib sets the default texture and rectangle at InitWindow()[rcore] to one
+* white character of default font [rtext], this way, raylib text and shapes can be draw with
+* a single draw call and it also allows users to configure it the same way with their own fonts.
*
* CONFIGURATION:
+* #define SUPPORT_MODULE_RSHAPES
+* rshapes module is included in the build
*
-* #define SUPPORT_MODULE_RSHAPES
-* rshapes module is included in the build
-*
-* #define SUPPORT_QUADS_DRAW_MODE
-* Use QUADS instead of TRIANGLES for drawing when possible. Lines-based shapes still use LINES
+* #define SUPPORT_QUADS_DRAW_MODE
+* Use QUADS instead of TRIANGLES for drawing when possible. Lines-based shapes still use LINES
*
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -58,6 +57,7 @@
#include // Required for: sinf(), asinf(), cosf(), acosf(), sqrtf(), fabsf()
#include // Required for: FLT_EPSILON
+#include // Required for: RL_FREE
//----------------------------------------------------------------------------------
// Defines and Macros
@@ -67,8 +67,8 @@
#ifndef SMOOTH_CIRCLE_ERROR_RATE
#define SMOOTH_CIRCLE_ERROR_RATE 0.5f // Circle error rate
#endif
-#ifndef BEZIER_LINE_DIVISIONS
- #define BEZIER_LINE_DIVISIONS 24 // Bezier line divisions
+#ifndef SPLINE_LINE_DIVISIONS
+ #define SPLINE_LINE_DIVISIONS 24 // Spline lines segment divisions
#endif
@@ -80,7 +80,7 @@
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
-Texture2D texShapes = { 1, 1, 1, 1, 7 }; // Texture used on shapes drawing (usually a white pixel)
+Texture2D texShapes = { 1, 1, 1, 1, 7 }; // Texture used on shapes drawing (white pixel loaded by rlgl)
Rectangle texShapesRec = { 0.0f, 0.0f, 1.0f, 1.0f }; // Texture source rectangle used on shapes drawing
//----------------------------------------------------------------------------------
@@ -97,28 +97,68 @@ static float EaseCubicInOut(float t, float b, float c, float d); // Cubic eas
// defining a font char white rectangle would allow drawing everything in a single draw call
void SetShapesTexture(Texture2D texture, Rectangle source)
{
- texShapes = texture;
- texShapesRec = source;
+ // Reset texture to default pixel if required
+ // WARNING: Shapes texture should be probably better validated,
+ // it can break the rendering of all shapes if misused
+ if ((texture.id == 0) || (source.width == 0) || (source.height == 0))
+ {
+ texShapes = (Texture2D){ 1, 1, 1, 1, 7 };
+ texShapesRec = (Rectangle){ 0.0f, 0.0f, 1.0f, 1.0f };
+ }
+ else
+ {
+ texShapes = texture;
+ texShapesRec = source;
+ }
}
// Draw a pixel
void DrawPixel(int posX, int posY, Color color)
{
- rlBegin(RL_LINES);
- rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2f(posX, posY);
- rlVertex2f(posX + 1, posY + 1);
- rlEnd();
+ DrawPixelV((Vector2){ (float)posX, (float)posY }, color);
}
// Draw a pixel (Vector version)
void DrawPixelV(Vector2 position, Color color)
{
- rlBegin(RL_LINES);
+#if defined(SUPPORT_QUADS_DRAW_MODE)
+ rlSetTexture(texShapes.id);
+
+ rlBegin(RL_QUADS);
+
+ rlNormal3f(0.0f, 0.0f, 1.0f);
rlColor4ub(color.r, color.g, color.b, color.a);
+
+ rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
rlVertex2f(position.x, position.y);
- rlVertex2f(position.x + 1.0f, position.y + 1.0f);
+
+ rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
+ rlVertex2f(position.x, position.y + 1);
+
+ rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
+ rlVertex2f(position.x + 1, position.y + 1);
+
+ rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
+ rlVertex2f(position.x + 1, position.y);
+
rlEnd();
+
+ rlSetTexture(0);
+#else
+ rlBegin(RL_TRIANGLES);
+
+ rlColor4ub(color.r, color.g, color.b, color.a);
+
+ rlVertex2f(position.x, position.y);
+ rlVertex2f(position.x, position.y + 1);
+ rlVertex2f(position.x + 1, position.y);
+
+ rlVertex2f(position.x + 1, position.y);
+ rlVertex2f(position.x, position.y + 1);
+ rlVertex2f(position.x + 1, position.y + 1);
+
+ rlEnd();
+#endif
}
// Draw a line
@@ -126,8 +166,8 @@ void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color colo
{
rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2f(startPosX, startPosY);
- rlVertex2f(endPosX, endPosY);
+ rlVertex2f((float)startPosX, (float)startPosY);
+ rlVertex2f((float)endPosX, (float)endPosY);
rlEnd();
}
@@ -150,6 +190,7 @@ void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color)
if ((length > 0) && (thick > 0))
{
float scale = thick/(2*length);
+
Vector2 radius = { -scale*delta.y, scale*delta.x };
Vector2 strip[4] = {
{ startPos.x - radius.x, startPos.y - radius.y },
@@ -168,75 +209,270 @@ void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color)
Vector2 previous = startPos;
Vector2 current = { 0 };
- for (int i = 1; i <= BEZIER_LINE_DIVISIONS; i++)
+ Vector2 points[2*SPLINE_LINE_DIVISIONS + 2] = { 0 };
+
+ for (int i = 1; i <= SPLINE_LINE_DIVISIONS; i++)
{
// Cubic easing in-out
// NOTE: Easing is calculated only for y position value
- current.y = EaseCubicInOut((float)i, startPos.y, endPos.y - startPos.y, (float)BEZIER_LINE_DIVISIONS);
- current.x = previous.x + (endPos.x - startPos.x)/ (float)BEZIER_LINE_DIVISIONS;
+ current.y = EaseCubicInOut((float)i, startPos.y, endPos.y - startPos.y, (float)SPLINE_LINE_DIVISIONS);
+ current.x = previous.x + (endPos.x - startPos.x)/(float)SPLINE_LINE_DIVISIONS;
- // TODO: Avoid drawing the line by pieces, it generates gaps for big thicks,
- // Custom "triangle-strip" implementation should be used, check DrawTriangleStrip() for reference
- DrawLineEx(previous, current, thick, color);
+ float dy = current.y - previous.y;
+ float dx = current.x - previous.x;
+ float size = 0.5f*thick/sqrtf(dx*dx+dy*dy);
+
+ if (i == 1)
+ {
+ points[0].x = previous.x + dy*size;
+ points[0].y = previous.y - dx*size;
+ points[1].x = previous.x - dy*size;
+ points[1].y = previous.y + dx*size;
+ }
+
+ points[2*i + 1].x = current.x - dy*size;
+ points[2*i + 1].y = current.y + dx*size;
+ points[2*i].x = current.x + dy*size;
+ points[2*i].y = current.y - dx*size;
previous = current;
}
+
+ DrawTriangleStrip(points, 2*SPLINE_LINE_DIVISIONS + 2, color);
}
// Draw line using quadratic bezier curves with a control point
void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thick, Color color)
{
- const float step = 1.0f/BEZIER_LINE_DIVISIONS;
+ const float step = 1.0f/SPLINE_LINE_DIVISIONS;
Vector2 previous = startPos;
Vector2 current = { 0 };
float t = 0.0f;
- for (int i = 0; i <= BEZIER_LINE_DIVISIONS; i++)
+ Vector2 points[2*SPLINE_LINE_DIVISIONS + 2] = { 0 };
+
+ for (int i = 1; i <= SPLINE_LINE_DIVISIONS; i++)
{
t = step*i;
- float a = powf(1 - t, 2);
- float b = 2*(1 - t)*t;
+
+ float a = powf(1.0f - t, 2);
+ float b = 2.0f*(1.0f - t)*t;
float c = powf(t, 2);
// NOTE: The easing functions aren't suitable here because they don't take a control point
current.y = a*startPos.y + b*controlPos.y + c*endPos.y;
current.x = a*startPos.x + b*controlPos.x + c*endPos.x;
- // TODO: Avoid drawing the line by pieces, it generates gaps for big thicks,
- // Custom "triangle-strip" implementation should be used, check DrawTriangleStrip() for reference
- DrawLineEx(previous, current, thick, color);
+ float dy = current.y - previous.y;
+ float dx = current.x - previous.x;
+ float size = 0.5f*thick/sqrtf(dx*dx+dy*dy);
+
+ if (i == 1)
+ {
+ points[0].x = previous.x + dy*size;
+ points[0].y = previous.y - dx*size;
+ points[1].x = previous.x - dy*size;
+ points[1].y = previous.y + dx*size;
+ }
+
+ points[2*i + 1].x = current.x - dy*size;
+ points[2*i + 1].y = current.y + dx*size;
+ points[2*i].x = current.x + dy*size;
+ points[2*i].y = current.y - dx*size;
previous = current;
}
+
+ DrawTriangleStrip(points, 2*SPLINE_LINE_DIVISIONS + 2, color);
}
// Draw line using cubic bezier curves with 2 control points
void DrawLineBezierCubic(Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thick, Color color)
{
- const float step = 1.0f/BEZIER_LINE_DIVISIONS;
+ const float step = 1.0f/SPLINE_LINE_DIVISIONS;
Vector2 previous = startPos;
Vector2 current = { 0 };
float t = 0.0f;
- for (int i = 0; i <= BEZIER_LINE_DIVISIONS; i++)
+ Vector2 points[2*SPLINE_LINE_DIVISIONS + 2] = { 0 };
+
+ for (int i = 1; i <= SPLINE_LINE_DIVISIONS; i++)
{
t = step*i;
- float a = powf(1 - t, 3);
- float b = 3*powf(1 - t, 2)*t;
- float c = 3*(1-t)*powf(t, 2);
+
+ float a = powf(1.0f - t, 3);
+ float b = 3.0f*powf(1.0f - t, 2)*t;
+ float c = 3.0f*(1.0f - t)*powf(t, 2);
float d = powf(t, 3);
current.y = a*startPos.y + b*startControlPos.y + c*endControlPos.y + d*endPos.y;
current.x = a*startPos.x + b*startControlPos.x + c*endControlPos.x + d*endPos.x;
- // TODO: Avoid drawing the line by pieces, it generates gaps for big thicks,
- // Custom "triangle-strip" implementation should be used, check DrawTriangleStrip() for reference
- DrawLineEx(previous, current, thick, color);
+ float dy = current.y - previous.y;
+ float dx = current.x - previous.x;
+ float size = 0.5f*thick/sqrtf(dx*dx+dy*dy);
+
+ if (i == 1)
+ {
+ points[0].x = previous.x + dy*size;
+ points[0].y = previous.y - dx*size;
+ points[1].x = previous.x - dy*size;
+ points[1].y = previous.y + dx*size;
+ }
+
+ points[2*i + 1].x = current.x - dy*size;
+ points[2*i + 1].y = current.y + dx*size;
+ points[2*i].x = current.x + dy*size;
+ points[2*i].y = current.y - dx*size;
previous = current;
}
+
+ DrawTriangleStrip(points, 2*SPLINE_LINE_DIVISIONS + 2, color);
+}
+
+// Draw a B-Spline line, minimum 4 points
+void DrawLineBSpline(Vector2 *points, int pointCount, float thick, Color color)
+{
+ if (pointCount < 4) return;
+
+ float a[4] = { 0 };
+ float b[4] = { 0 };
+ float dy = 0.0f;
+ float dx = 0.0f;
+ float size = 0.0f;
+
+ Vector2 currentPoint = { 0 };
+ Vector2 nextPoint = { 0 };
+ Vector2 vertices[2*SPLINE_LINE_DIVISIONS + 2] = { 0 };
+
+ for (int i = 0; i < (pointCount - 3); i++)
+ {
+ float t = 0.0f;
+ Vector2 p1 = points[i], p2 = points[i + 1], p3 = points[i + 2], p4 = points[i + 3];
+
+ a[0] = (-p1.x + 3.0f*p2.x - 3.0f*p3.x + p4.x)/6.0f;
+ a[1] = (3.0f*p1.x - 6.0f*p2.x + 3.0f*p3.x)/6.0f;
+ a[2] = (-3.0f*p1.x + 3.0f*p3.x)/6.0f;
+ a[3] = (p1.x + 4.0f*p2.x + p3.x)/6.0f;
+
+ b[0] = (-p1.y + 3.0f*p2.y - 3.0f*p3.y + p4.y)/6.0f;
+ b[1] = (3.0f*p1.y - 6.0f*p2.y + 3.0f*p3.y)/6.0f;
+ b[2] = (-3.0f*p1.y + 3.0f*p3.y)/6.0f;
+ b[3] = (p1.y + 4.0f*p2.y + p3.y)/6.0f;
+
+ currentPoint.x = a[3];
+ currentPoint.y = b[3];
+
+ if (i == 0) DrawCircleV(currentPoint, thick/2.0f, color); // Draw init line circle-cap
+
+ if (i > 0)
+ {
+ vertices[0].x = currentPoint.x + dy*size;
+ vertices[0].y = currentPoint.y - dx*size;
+ vertices[1].x = currentPoint.x - dy*size;
+ vertices[1].y = currentPoint.y + dx*size;
+ }
+
+ for (int j = 1; j <= SPLINE_LINE_DIVISIONS; j++)
+ {
+ t = ((float)j)/((float)SPLINE_LINE_DIVISIONS);
+
+ nextPoint.x = a[3] + t*(a[2] + t*(a[1] + t*a[0]));
+ nextPoint.y = b[3] + t*(b[2] + t*(b[1] + t*b[0]));
+
+ dy = nextPoint.y - currentPoint.y;
+ dx = nextPoint.x - currentPoint.x;
+ size = 0.5f*thick/sqrtf(dx*dx+dy*dy);
+
+ if ((i == 0) && (j == 1))
+ {
+ vertices[0].x = currentPoint.x + dy*size;
+ vertices[0].y = currentPoint.y - dx*size;
+ vertices[1].x = currentPoint.x - dy*size;
+ vertices[1].y = currentPoint.y + dx*size;
+ }
+
+ vertices[2*j + 1].x = nextPoint.x - dy*size;
+ vertices[2*j + 1].y = nextPoint.y + dx*size;
+ vertices[2*j].x = nextPoint.x + dy*size;
+ vertices[2*j].y = nextPoint.y - dx*size;
+
+ currentPoint = nextPoint;
+ }
+
+ DrawTriangleStrip(vertices, 2*SPLINE_LINE_DIVISIONS + 2, color);
+ }
+
+ DrawCircleV(currentPoint, thick/2.0f, color); // Draw end line circle-cap
+}
+
+// Draw a Catmull Rom spline line, minimum 4 points
+void DrawLineCatmullRom(Vector2 *points, int pointCount, float thick, Color color)
+{
+ if (pointCount < 4) return;
+
+ float dy = 0.0f;
+ float dx = 0.0f;
+ float size = 0.0f;
+
+ Vector2 currentPoint = points[1];
+ Vector2 nextPoint = { 0 };
+ Vector2 vertices[2*SPLINE_LINE_DIVISIONS + 2] = { 0 };
+
+ DrawCircleV(currentPoint, thick/2.0f, color); // Draw init line circle-cap
+
+ for (int i = 0; i < (pointCount - 3); i++)
+ {
+ float t = 0.0f;
+ Vector2 p1 = points[i], p2 = points[i + 1], p3 = points[i + 2], p4 = points[i + 3];
+
+ if (i > 0)
+ {
+ vertices[0].x = currentPoint.x + dy*size;
+ vertices[0].y = currentPoint.y - dx*size;
+ vertices[1].x = currentPoint.x - dy*size;
+ vertices[1].y = currentPoint.y + dx*size;
+ }
+
+ for (int j = 1; j <= SPLINE_LINE_DIVISIONS; j++)
+ {
+ t = ((float)j)/((float)SPLINE_LINE_DIVISIONS);
+
+ float q0 = (-1.0f*t*t*t) + (2.0f*t*t) + (-1.0f*t);
+ float q1 = (3.0f*t*t*t) + (-5.0f*t*t) + 2.0f;
+ float q2 = (-3.0f*t*t*t) + (4.0f*t*t) + t;
+ float q3 = t*t*t - t*t;
+
+ nextPoint.x = 0.5f*((p1.x*q0) + (p2.x*q1) + (p3.x*q2) + (p4.x*q3));
+ nextPoint.y = 0.5f*((p1.y*q0) + (p2.y*q1) + (p3.y*q2) + (p4.y*q3));
+
+ dy = nextPoint.y - currentPoint.y;
+ dx = nextPoint.x - currentPoint.x;
+ size = (0.5f*thick)/sqrtf(dx*dx + dy*dy);
+
+ if ((i == 0) && (j == 1))
+ {
+ vertices[0].x = currentPoint.x + dy*size;
+ vertices[0].y = currentPoint.y - dx*size;
+ vertices[1].x = currentPoint.x - dy*size;
+ vertices[1].y = currentPoint.y + dx*size;
+ }
+
+ vertices[2*j + 1].x = nextPoint.x - dy*size;
+ vertices[2*j + 1].y = nextPoint.y + dx*size;
+ vertices[2*j].x = nextPoint.x + dy*size;
+ vertices[2*j].y = nextPoint.y - dx*size;
+
+ currentPoint = nextPoint;
+ }
+
+ DrawTriangleStrip(vertices, 2*SPLINE_LINE_DIVISIONS + 2, color);
+ }
+
+ DrawCircleV(currentPoint, thick/2.0f, color); // Draw end line circle-cap
}
// Draw lines sequence
@@ -262,6 +498,13 @@ void DrawCircle(int centerX, int centerY, float radius, Color color)
DrawCircleV((Vector2){ (float)centerX, (float)centerY }, radius, color);
}
+// Draw a color-filled circle (Vector version)
+// NOTE: On OpenGL 3.3 and ES2 we use QUADS to avoid drawing order issues
+void DrawCircleV(Vector2 center, float radius, Color color)
+{
+ DrawCircleSector(center, radius, 0, 360, 36, color);
+}
+
// Draw a piece of a circle
void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
{
@@ -294,6 +537,7 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
rlSetTexture(texShapes.id);
rlBegin(RL_QUADS);
+
// NOTE: Every QUAD actually represents two segments
for (int i = 0; i < segments/2; i++)
{
@@ -302,35 +546,36 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
rlVertex2f(center.x, center.y);
- rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
+ rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength*2.0f))*radius, center.y + sinf(DEG2RAD*(angle + stepLength*2.0f))*radius);
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*radius, center.y + cosf(DEG2RAD*(angle + stepLength))*radius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*radius, center.y + sinf(DEG2RAD*(angle + stepLength))*radius);
- rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength*2))*radius, center.y + cosf(DEG2RAD*(angle + stepLength*2))*radius);
+ rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*radius, center.y + sinf(DEG2RAD*angle)*radius);
- angle += (stepLength*2);
+ angle += (stepLength*2.0f);
}
// NOTE: In case number of segments is odd, we add one last piece to the cake
- if (segments%2)
+ if ((segments%2) == 1)
{
rlColor4ub(color.r, color.g, color.b, color.a);
rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
rlVertex2f(center.x, center.y);
- rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
-
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*radius, center.y + cosf(DEG2RAD*(angle + stepLength))*radius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*radius, center.y + sinf(DEG2RAD*(angle + stepLength))*radius);
+
+ rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*radius, center.y + sinf(DEG2RAD*angle)*radius);
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
rlVertex2f(center.x, center.y);
}
+
rlEnd();
rlSetTexture(0);
@@ -341,8 +586,8 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(center.x, center.y);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*radius, center.y + cosf(DEG2RAD*(angle + stepLength))*radius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*radius, center.y + sinf(DEG2RAD*(angle + stepLength))*radius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*radius, center.y + sinf(DEG2RAD*angle)*radius);
angle += stepLength;
}
@@ -384,15 +629,15 @@ void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float
{
rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(center.x, center.y);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*radius, center.y + sinf(DEG2RAD*angle)*radius);
}
for (int i = 0; i < segments; i++)
{
rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*radius, center.y + cosf(DEG2RAD*(angle + stepLength))*radius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*radius, center.y + sinf(DEG2RAD*angle)*radius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*radius, center.y + sinf(DEG2RAD*(angle + stepLength))*radius);
angle += stepLength;
}
@@ -401,7 +646,7 @@ void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float
{
rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(center.x, center.y);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*radius, center.y + sinf(DEG2RAD*angle)*radius);
}
rlEnd();
}
@@ -416,20 +661,13 @@ void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Co
rlColor4ub(color1.r, color1.g, color1.b, color1.a);
rlVertex2f((float)centerX, (float)centerY);
rlColor4ub(color2.r, color2.g, color2.b, color2.a);
- rlVertex2f((float)centerX + sinf(DEG2RAD*i)*radius, (float)centerY + cosf(DEG2RAD*i)*radius);
+ rlVertex2f((float)centerX + cosf(DEG2RAD*(i + 10))*radius, (float)centerY + sinf(DEG2RAD*(i + 10))*radius);
rlColor4ub(color2.r, color2.g, color2.b, color2.a);
- rlVertex2f((float)centerX + sinf(DEG2RAD*(i + 10))*radius, (float)centerY + cosf(DEG2RAD*(i + 10))*radius);
+ rlVertex2f((float)centerX + cosf(DEG2RAD*i)*radius, (float)centerY + sinf(DEG2RAD*i)*radius);
}
rlEnd();
}
-// Draw a color-filled circle (Vector version)
-// NOTE: On OpenGL 3.3 and ES2 we use QUADS to avoid drawing order issues
-void DrawCircleV(Vector2 center, float radius, Color color)
-{
- DrawCircleSector(center, radius, 0, 360, 36, color);
-}
-
// Draw circle outline
void DrawCircleLines(int centerX, int centerY, float radius, Color color)
{
@@ -439,8 +677,8 @@ void DrawCircleLines(int centerX, int centerY, float radius, Color color)
// NOTE: Circle outline is drawn pixel by pixel every degree (0 to 360)
for (int i = 0; i < 360; i += 10)
{
- rlVertex2f(centerX + sinf(DEG2RAD*i)*radius, centerY + cosf(DEG2RAD*i)*radius);
- rlVertex2f(centerX + sinf(DEG2RAD*(i + 10))*radius, centerY + cosf(DEG2RAD*(i + 10))*radius);
+ rlVertex2f(centerX + cosf(DEG2RAD*i)*radius, centerY + sinf(DEG2RAD*i)*radius);
+ rlVertex2f(centerX + cosf(DEG2RAD*(i + 10))*radius, centerY + sinf(DEG2RAD*(i + 10))*radius);
}
rlEnd();
}
@@ -453,8 +691,8 @@ void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color c
{
rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f((float)centerX, (float)centerY);
- rlVertex2f((float)centerX + sinf(DEG2RAD*i)*radiusH, (float)centerY + cosf(DEG2RAD*i)*radiusV);
- rlVertex2f((float)centerX + sinf(DEG2RAD*(i + 10))*radiusH, (float)centerY + cosf(DEG2RAD*(i + 10))*radiusV);
+ rlVertex2f((float)centerX + cosf(DEG2RAD*(i + 10))*radiusH, (float)centerY + sinf(DEG2RAD*(i + 10))*radiusV);
+ rlVertex2f((float)centerX + cosf(DEG2RAD*i)*radiusH, (float)centerY + sinf(DEG2RAD*i)*radiusV);
}
rlEnd();
}
@@ -466,8 +704,8 @@ void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Co
for (int i = 0; i < 360; i += 10)
{
rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2f(centerX + sinf(DEG2RAD*i)*radiusH, centerY + cosf(DEG2RAD*i)*radiusV);
- rlVertex2f(centerX + sinf(DEG2RAD*(i + 10))*radiusH, centerY + cosf(DEG2RAD*(i + 10))*radiusV);
+ rlVertex2f(centerX + cosf(DEG2RAD*(i + 10))*radiusH, centerY + sinf(DEG2RAD*(i + 10))*radiusV);
+ rlVertex2f(centerX + cosf(DEG2RAD*i)*radiusH, centerY + sinf(DEG2RAD*i)*radiusV);
}
rlEnd();
}
@@ -525,17 +763,17 @@ void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startA
{
rlColor4ub(color.r, color.g, color.b, color.a);
- rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
-
rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*outerRadius, center.y + sinf(DEG2RAD*angle)*outerRadius);
- rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*outerRadius);
+ rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*innerRadius, center.y + sinf(DEG2RAD*angle)*innerRadius);
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*innerRadius);
+
+ rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*outerRadius);
angle += stepLength;
}
@@ -548,13 +786,13 @@ void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startA
{
rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*innerRadius, center.y + sinf(DEG2RAD*angle)*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*outerRadius, center.y + sinf(DEG2RAD*angle)*outerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*innerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*outerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*outerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*outerRadius, center.y + sinf(DEG2RAD*angle)*outerRadius);
angle += stepLength;
}
@@ -611,19 +849,19 @@ void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float s
if (showCapLines)
{
rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*outerRadius, center.y + sinf(DEG2RAD*angle)*outerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*innerRadius, center.y + sinf(DEG2RAD*angle)*innerRadius);
}
for (int i = 0; i < segments; i++)
{
rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*outerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*outerRadius, center.y + sinf(DEG2RAD*angle)*outerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*outerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*innerRadius, center.y + sinf(DEG2RAD*angle)*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*innerRadius);
angle += stepLength;
}
@@ -631,8 +869,8 @@ void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float s
if (showCapLines)
{
rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*outerRadius, center.y + sinf(DEG2RAD*angle)*outerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*innerRadius, center.y + sinf(DEG2RAD*angle)*innerRadius);
}
rlEnd();
}
@@ -891,13 +1129,13 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
};
const Vector2 centers[4] = { point[8], point[9], point[10], point[11] };
- const float angles[4] = { 180.0f, 90.0f, 0.0f, 270.0f };
+ const float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f };
#if defined(SUPPORT_QUADS_DRAW_MODE)
rlSetTexture(texShapes.id);
rlBegin(RL_QUADS);
- // Draw all of the 4 corners: [1] Upper Left Corner, [3] Upper Right Corner, [5] Lower Right Corner, [7] Lower Left Corner
+ // Draw all the 4 corners: [1] Upper Left Corner, [3] Upper Right Corner, [5] Lower Right Corner, [7] Lower Left Corner
for (int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop
{
float angle = angles[k];
@@ -909,12 +1147,16 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
rlColor4ub(color.r, color.g, color.b, color.a);
rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
rlVertex2f(center.x, center.y);
- rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
- rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*radius, center.y + cosf(DEG2RAD*(angle + stepLength))*radius);
+
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength*2))*radius, center.y + cosf(DEG2RAD*(angle + stepLength*2))*radius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength*2))*radius, center.y + sinf(DEG2RAD*(angle + stepLength*2))*radius);
+
+ rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*radius, center.y + sinf(DEG2RAD*(angle + stepLength))*radius);
+
+ rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*radius, center.y + sinf(DEG2RAD*angle)*radius);
+
angle += (stepLength*2);
}
@@ -924,10 +1166,13 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
rlColor4ub(color.r, color.g, color.b, color.a);
rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
rlVertex2f(center.x, center.y);
- rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
+
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*radius, center.y + cosf(DEG2RAD*(angle + stepLength))*radius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*radius, center.y + sinf(DEG2RAD*(angle + stepLength))*radius);
+
+ rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*radius, center.y + sinf(DEG2RAD*angle)*radius);
+
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
rlVertex2f(center.x, center.y);
}
@@ -1002,8 +1247,8 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
{
rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(center.x, center.y);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*radius, center.y + cosf(DEG2RAD*angle)*radius);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*radius, center.y + cosf(DEG2RAD*(angle + stepLength))*radius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*radius, center.y + sinf(DEG2RAD*(angle + stepLength))*radius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*radius, center.y + sinf(DEG2RAD*angle)*radius);
angle += stepLength;
}
}
@@ -1117,7 +1362,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, flo
{(float)(rec.x + rec.width) - innerRadius, (float)(rec.y + rec.height) - innerRadius}, {(float)rec.x + innerRadius, (float)(rec.y + rec.height) - innerRadius} // P18, P19
};
- const float angles[4] = { 180.0f, 90.0f, 0.0f, 270.0f };
+ const float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f };
if (lineThick > 1)
{
@@ -1126,7 +1371,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, flo
rlBegin(RL_QUADS);
- // Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
+ // Draw all the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
for (int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop
{
float angle = angles[k];
@@ -1134,14 +1379,18 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, flo
for (int i = 0; i < segments; i++)
{
rlColor4ub(color.r, color.g, color.b, color.a);
+
rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
- rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
- rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*outerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*innerRadius, center.y + sinf(DEG2RAD*angle)*innerRadius);
+
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*innerRadius);
+
+ rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*outerRadius);
+
+ rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*outerRadius, center.y + sinf(DEG2RAD*angle)*outerRadius);
angle += stepLength;
}
@@ -1206,13 +1455,13 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, flo
{
rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*innerRadius, center.y + cosf(DEG2RAD*angle)*innerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*innerRadius, center.y + sinf(DEG2RAD*angle)*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*outerRadius, center.y + sinf(DEG2RAD*angle)*outerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*innerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*outerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*innerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*innerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*outerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*outerRadius, center.y + sinf(DEG2RAD*angle)*outerRadius);
angle += stepLength;
}
@@ -1261,7 +1510,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, flo
// Use LINES to draw the outline
rlBegin(RL_LINES);
- // Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
+ // Draw all the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
for (int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop
{
float angle = angles[k];
@@ -1270,8 +1519,8 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, flo
for (int i = 0; i < segments; i++)
{
rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2f(center.x + sinf(DEG2RAD*angle)*outerRadius, center.y + cosf(DEG2RAD*angle)*outerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + cosf(DEG2RAD*(angle + stepLength))*outerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*angle)*outerRadius, center.y + sinf(DEG2RAD*angle)*outerRadius);
+ rlVertex2f(center.x + cosf(DEG2RAD*(angle + stepLength))*outerRadius, center.y + sinf(DEG2RAD*(angle + stepLength))*outerRadius);
angle += stepLength;
}
}
@@ -1401,7 +1650,8 @@ void DrawTriangleStrip(Vector2 *points, int pointCount, Color color)
void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color)
{
if (sides < 3) sides = 3;
- float centralAngle = rotation;
+ float centralAngle = rotation*DEG2RAD;
+ float angleStep = 360.0f/(float)sides*DEG2RAD;
#if defined(SUPPORT_QUADS_DRAW_MODE)
rlSetTexture(texShapes.id);
@@ -1410,19 +1660,21 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
for (int i = 0; i < sides; i++)
{
rlColor4ub(color.r, color.g, color.b, color.a);
+ float nextAngle = centralAngle + angleStep;
rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
rlVertex2f(center.x, center.y);
rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
+ rlVertex2f(center.x + cosf(centralAngle)*radius, center.y + sinf(centralAngle)*radius);
+
+ rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
+ rlVertex2f(center.x + cosf(nextAngle)*radius, center.y + sinf(nextAngle)*radius);
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
+ rlVertex2f(center.x + cosf(centralAngle)*radius, center.y + sinf(centralAngle)*radius);
- centralAngle += 360.0f/(float)sides;
- rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
+ centralAngle = nextAngle;
}
rlEnd();
rlSetTexture(0);
@@ -1433,10 +1685,10 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(center.x, center.y);
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
+ rlVertex2f(center.x + cosf(centralAngle + angleStep)*radius, center.y + sinf(centralAngle + angleStep)*radius);
+ rlVertex2f(center.x + cosf(centralAngle)*radius, center.y + sinf(centralAngle)*radius);
- centralAngle += 360.0f/(float)sides;
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
+ centralAngle += angleStep;
}
rlEnd();
#endif
@@ -1446,16 +1698,18 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color)
{
if (sides < 3) sides = 3;
- float centralAngle = rotation;
+ float centralAngle = rotation*DEG2RAD;
+ float angleStep = 360.0f/(float)sides*DEG2RAD;
rlBegin(RL_LINES);
for (int i = 0; i < sides; i++)
{
rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
- centralAngle += 360.0f/(float)sides;
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
+ rlVertex2f(center.x + cosf(centralAngle)*radius, center.y + sinf(centralAngle)*radius);
+ rlVertex2f(center.x + cosf(centralAngle + angleStep)*radius, center.y + sinf(centralAngle + angleStep)*radius);
+
+ centralAngle += angleStep;
}
rlEnd();
}
@@ -1463,8 +1717,8 @@ void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Colo
void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float lineThick, Color color)
{
if (sides < 3) sides = 3;
- float centralAngle = rotation;
- float exteriorAngle = 360.0f/(float)sides;
+ float centralAngle = rotation*DEG2RAD;
+ float exteriorAngle = 360.0f/(float)sides*DEG2RAD;
float innerRadius = radius - (lineThick*cosf(DEG2RAD*exteriorAngle/2.0f));
#if defined(SUPPORT_QUADS_DRAW_MODE)
@@ -1474,19 +1728,21 @@ void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, fl
for (int i = 0; i < sides; i++)
{
rlColor4ub(color.r, color.g, color.b, color.a);
-
- rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*innerRadius, center.y + cosf(DEG2RAD*centralAngle)*innerRadius);
+ float nextAngle = centralAngle + exteriorAngle;
rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
+ rlVertex2f(center.x + cosf(centralAngle)*radius, center.y + sinf(centralAngle)*radius);
- centralAngle += exteriorAngle;
- rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
+ rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
+ rlVertex2f(center.x + cosf(centralAngle)*innerRadius, center.y + sinf(centralAngle)*innerRadius);
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*innerRadius, center.y + cosf(DEG2RAD*centralAngle)*innerRadius);
+ rlVertex2f(center.x + cosf(nextAngle)*innerRadius, center.y + sinf(nextAngle)*innerRadius);
+
+ rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
+ rlVertex2f(center.x + cosf(nextAngle)*radius, center.y + sinf(nextAngle)*radius);
+
+ centralAngle = nextAngle;
}
rlEnd();
rlSetTexture(0);
@@ -1497,13 +1753,13 @@ void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, fl
rlColor4ub(color.r, color.g, color.b, color.a);
float nextAngle = centralAngle + exteriorAngle;
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*innerRadius, center.y + cosf(DEG2RAD*centralAngle)*innerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*nextAngle)*radius, center.y + cosf(DEG2RAD*nextAngle)*radius);
+ rlVertex2f(center.x + cosf(nextAngle)*radius, center.y + sinf(nextAngle)*radius);
+ rlVertex2f(center.x + cosf(centralAngle)*radius, center.y + sinf(centralAngle)*radius);
+ rlVertex2f(center.x + cosf(centralAngle)*innerRadius, center.y + sinf(centralAngle)*innerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*innerRadius, center.y + cosf(DEG2RAD*centralAngle)*innerRadius);
- rlVertex2f(center.x + sinf(DEG2RAD*nextAngle)*radius, center.y + cosf(DEG2RAD*nextAngle)*radius);
- rlVertex2f(center.x + sinf(DEG2RAD*nextAngle)*innerRadius, center.y + cosf(DEG2RAD*nextAngle)*innerRadius);
+ rlVertex2f(center.x + cosf(centralAngle)*innerRadius, center.y + sinf(centralAngle)*innerRadius);
+ rlVertex2f(center.x + cosf(nextAngle)*innerRadius, center.y + sinf(nextAngle)*innerRadius);
+ rlVertex2f(center.x + cosf(nextAngle)*radius, center.y + sinf(nextAngle)*radius);
centralAngle = nextAngle;
}
@@ -1520,7 +1776,7 @@ bool CheckCollisionPointRec(Vector2 point, Rectangle rec)
{
bool collision = false;
- if ((point.x >= rec.x) && (point.x <= (rec.x + rec.width)) && (point.y >= rec.y) && (point.y <= (rec.y + rec.height))) collision = true;
+ if ((point.x >= rec.x) && (point.x < (rec.x + rec.width)) && (point.y >= rec.y) && (point.y < (rec.y + rec.height))) collision = true;
return collision;
}
@@ -1558,19 +1814,19 @@ bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2
bool CheckCollisionPointPoly(Vector2 point, Vector2 *points, int pointCount)
{
bool collision = false;
-
+
if (pointCount > 2)
{
for (int i = 0; i < pointCount - 1; i++)
{
Vector2 vc = points[i];
Vector2 vn = points[i + 1];
-
+
if ((((vc.y >= point.y) && (vn.y < point.y)) || ((vc.y < point.y) && (vn.y >= point.y))) &&
(point.x < ((vn.x - vc.x)*(point.y - vc.y)/(vn.y - vc.y) + vc.x))) collision = !collision;
}
}
-
+
return collision;
}
@@ -1678,68 +1934,26 @@ bool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshol
// Get collision rectangle for two rectangles collision
Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
{
- Rectangle rec = { 0, 0, 0, 0 };
+ Rectangle overlap = { 0 };
- if (CheckCollisionRecs(rec1, rec2))
+ float left = (rec1.x > rec2.x)? rec1.x : rec2.x;
+ float right1 = rec1.x + rec1.width;
+ float right2 = rec2.x + rec2.width;
+ float right = (right1 < right2)? right1 : right2;
+ float top = (rec1.y > rec2.y)? rec1.y : rec2.y;
+ float bottom1 = rec1.y + rec1.height;
+ float bottom2 = rec2.y + rec2.height;
+ float bottom = (bottom1 < bottom2)? bottom1 : bottom2;
+
+ if ((left < right) && (top < bottom))
{
- float dxx = fabsf(rec1.x - rec2.x);
- float dyy = fabsf(rec1.y - rec2.y);
-
- if (rec1.x <= rec2.x)
- {
- if (rec1.y <= rec2.y)
- {
- rec.x = rec2.x;
- rec.y = rec2.y;
- rec.width = rec1.width - dxx;
- rec.height = rec1.height - dyy;
- }
- else
- {
- rec.x = rec2.x;
- rec.y = rec1.y;
- rec.width = rec1.width - dxx;
- rec.height = rec2.height - dyy;
- }
- }
- else
- {
- if (rec1.y <= rec2.y)
- {
- rec.x = rec1.x;
- rec.y = rec2.y;
- rec.width = rec2.width - dxx;
- rec.height = rec1.height - dyy;
- }
- else
- {
- rec.x = rec1.x;
- rec.y = rec1.y;
- rec.width = rec2.width - dxx;
- rec.height = rec2.height - dyy;
- }
- }
-
- if (rec1.width > rec2.width)
- {
- if (rec.width >= rec2.width) rec.width = rec2.width;
- }
- else
- {
- if (rec.width >= rec1.width) rec.width = rec1.width;
- }
-
- if (rec1.height > rec2.height)
- {
- if (rec.height >= rec2.height) rec.height = rec2.height;
- }
- else
- {
- if (rec.height >= rec1.height) rec.height = rec1.height;
- }
+ overlap.x = left;
+ overlap.y = top;
+ overlap.width = right - left;
+ overlap.height = bottom - top;
}
- return rec;
+ return overlap;
}
//----------------------------------------------------------------------------------
diff --git a/src/rtext.c b/src/rtext.c
index 324ebe95a..3fb2b8861 100644
--- a/src/rtext.c
+++ b/src/rtext.c
@@ -3,25 +3,28 @@
* rtext - Basic functions to load fonts and draw text
*
* CONFIGURATION:
+* #define SUPPORT_MODULE_RTEXT
+* rtext module is included in the build
*
-* #define SUPPORT_MODULE_RTEXT
-* rtext module is included in the build
+* #define SUPPORT_DEFAULT_FONT
+* Load default raylib font on initialization to be used by DrawText() and MeasureText().
+* If no default font loaded, DrawTextEx() and MeasureTextEx() are required.
*
-* #define SUPPORT_FILEFORMAT_FNT
-* #define SUPPORT_FILEFORMAT_TTF
-* Selected desired fileformats to be supported for loading. Some of those formats are
-* supported by default, to remove support, just comment unrequired #define in this module
+* #define SUPPORT_FILEFORMAT_FNT
+* #define SUPPORT_FILEFORMAT_TTF
+* Selected desired fileformats to be supported for loading. Some of those formats are
+* supported by default, to remove support, just comment unrequired #define in this module
*
-* #define SUPPORT_DEFAULT_FONT
-* Load default raylib font on initialization to be used by DrawText() and MeasureText().
-* If no default font loaded, DrawTextEx() and MeasureTextEx() are required.
+* #define SUPPORT_FONT_ATLAS_WHITE_REC
+* On font atlas image generation [GenImageFontAtlas()], add a 3x3 pixels white rectangle
+* at the bottom-right corner of the atlas. It can be useful to for shapes drawing, to allow
+* drawing text and shapes with a single draw call [SetShapesTexture()].
*
-* #define TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH
-* TextSplit() function static buffer max size
-*
-* #define MAX_TEXTSPLIT_COUNT
-* TextSplit() function static substrings pointers array (pointing to static buffer)
+* #define TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH
+* TextSplit() function static buffer max size
*
+* #define MAX_TEXTSPLIT_COUNT
+* TextSplit() function static substrings pointers array (pointing to static buffer)
*
* DEPENDENCIES:
* stb_truetype - Load TTF file and rasterize characters data
@@ -30,7 +33,7 @@
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -58,22 +61,31 @@
#if defined(SUPPORT_MODULE_RTEXT)
-#include "utils.h" // Required for: LoadFileText()
+#include "utils.h" // Required for: LoadFile*()
#include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2 -> Only DrawTextPro()
#include // Required for: malloc(), free()
#include // Required for: vsprintf()
#include // Required for: strcmp(), strstr(), strcpy(), strncpy() [Used in TextReplace()], sscanf() [Used in LoadBMFont()]
#include // Required for: va_list, va_start(), vsprintf(), va_end() [Used in TextFormat()]
-#include // Requried for: toupper(), tolower() [Used in TextToUpper(), TextToLower()]
+#include // Required for: toupper(), tolower() [Used in TextToUpper(), TextToLower()]
#if defined(SUPPORT_FILEFORMAT_TTF)
+ #if defined(__GNUC__) // GCC and Clang
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wunused-function"
+ #endif
+
#define STB_RECT_PACK_IMPLEMENTATION
#include "external/stb_rect_pack.h" // Required for: ttf font rectangles packaging
#define STBTT_STATIC
#define STB_TRUETYPE_IMPLEMENTATION
#include "external/stb_truetype.h" // Required for: ttf font data reading
+
+ #if defined(__GNUC__) // GCC and Clang
+ #pragma GCC diagnostic pop
+ #endif
#endif
//----------------------------------------------------------------------------------
@@ -113,8 +125,9 @@ static Font defaultFont = { 0 };
// Module specific Functions Declaration
//----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_FNT)
-static Font LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file)
+static Font LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file)
#endif
+static int textLineSpacing = 15; // Text vertical line spacing in pixels
#if defined(SUPPORT_DEFAULT_FONT)
extern void LoadFontDefault(void);
@@ -125,7 +138,6 @@ extern void UnloadFontDefault(void);
// Module Functions Definition
//----------------------------------------------------------------------------------
#if defined(SUPPORT_DEFAULT_FONT)
-
// Load raylib default font
extern void LoadFontDefault(void)
{
@@ -199,11 +211,11 @@ extern void LoadFontDefault(void)
// Re-construct image from defaultFontData and generate OpenGL texture
//----------------------------------------------------------------------
Image imFont = {
- .data = calloc(128*128, 2), // 2 bytes per pixel (gray + alpha)
+ .data = RL_CALLOC(128*128, 2), // 2 bytes per pixel (gray + alpha)
.width = 128,
.height = 128,
- .format = PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA,
- .mipmaps = 1
+ .mipmaps = 1,
+ .format = PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA
};
// Fill image.data with defaultFontData (convert from bit to pixel!)
@@ -336,7 +348,7 @@ Font LoadFont(const char *fileName)
}
else
{
- SetTextureFilter(font.texture, TEXTURE_FILTER_POINT); // By default we set point filter (best performance)
+ SetTextureFilter(font.texture, TEXTURE_FILTER_POINT); // By default, we set point filter (the best performance)
TRACELOG(LOG_INFO, "FONT: Data loaded successfully (%i pixel size | %i glyphs)", FONT_TTF_DEFAULT_SIZE, FONT_TTF_DEFAULT_NUMCHARS);
}
@@ -359,7 +371,7 @@ Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int glyphCou
// Loading font from memory data
font = LoadFontFromMemory(GetFileExtension(fileName), fileData, fileSize, fontSize, fontChars, glyphCount);
- RL_FREE(fileData);
+ UnloadFileData(fileData);
}
else font = GetFontDefault();
@@ -454,8 +466,8 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
.data = pixels,
.width = image.width,
.height = image.height,
- .format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
- .mipmaps = 1
+ .mipmaps = 1,
+ .format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
};
// Set font with all data parsed from image
@@ -535,6 +547,19 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
return font;
}
+// Check if a font is ready
+bool IsFontReady(Font font)
+{
+ return ((font.texture.id > 0) && // Validate OpenGL id fot font texture atlas
+ (font.baseSize > 0) && // Validate font size
+ (font.glyphCount > 0) && // Validate font contains some glyph
+ (font.recs != NULL) && // Validate font recs defining glyphs on texture atlas
+ (font.glyphs != NULL)); // Validate glyph data is loaded
+
+ // NOTE: Further validations could be done to verify if recs count and glyphs count
+ // match glyphCount and to verify that data contained is valid (glyphs values, metrics...)
+}
+
// Load font data for further use
// NOTE: Requires TTF font memory data and can generate SDF data
GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount, int type)
@@ -578,7 +603,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz
glyphCount = (glyphCount > 0)? glyphCount : 95;
// Fill fontChars in case not provided externally
- // NOTE: By default we fill glyphCount consecutevely, starting at 32 (Space)
+ // NOTE: By default we fill glyphCount consecutively, starting at 32 (Space)
if (fontChars == NULL)
{
@@ -620,11 +645,11 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz
if (ch == 32)
{
Image imSpace = {
- .data = calloc(chars[i].advanceX*fontSize, 2),
+ .data = RL_CALLOC(chars[i].advanceX*fontSize, 2),
.width = chars[i].advanceX,
.height = fontSize,
- .format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE,
- .mipmaps = 1
+ .mipmaps = 1,
+ .format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE
};
chars[i].image = imSpace;
@@ -641,7 +666,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz
}
}
- // Get bounding box for character (may be offset to account for chars that dip above or below the line)
+ // Get bounding box for character (maybe offset to account for chars that dip above or below the line)
/*
int chX1, chY1, chX2, chY2;
stbtt_GetCodepointBitmapBox(&fontInfo, ch, scaleFactor, scaleFactor, &chX1, &chY1, &chX2, &chY2);
@@ -669,7 +694,7 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
if (chars == NULL)
{
- TraceLog(LOG_WARNING, "FONT: Provided chars info not valid, returning empty image atlas");
+ TRACELOG(LOG_WARNING, "FONT: Provided chars info not valid, returning empty image atlas");
return atlas;
}
@@ -681,17 +706,48 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
// NOTE: Rectangles memory is loaded here!
Rectangle *recs = (Rectangle *)RL_MALLOC(glyphCount*sizeof(Rectangle));
- // Calculate image size based on required pixel area
- // NOTE 1: Image is forced to be squared and POT... very conservative!
- // NOTE 2: SDF font characters already contain an internal padding,
- // so image size would result bigger than default font type
- float requiredArea = 0;
- for (int i = 0; i < glyphCount; i++) requiredArea += ((chars[i].image.width + 2*padding)*(fontSize + 2*padding));
- float guessSize = sqrtf(requiredArea)*1.4f;
- int imageSize = (int)powf(2, ceilf(logf((float)guessSize)/logf(2))); // Calculate next POT
+ // Calculate image size based on total glyph width and glyph row count
+ int totalWidth = 0;
+ int maxGlyphWidth = 0;
+
+ for (int i = 0; i < glyphCount; i++)
+ {
+ if (chars[i].image.width > maxGlyphWidth) maxGlyphWidth = chars[i].image.width;
+ totalWidth += chars[i].image.width + 4*padding;
+ }
+
+//#define SUPPORT_FONT_ATLAS_SIZE_CONSERVATIVE
+#if defined(SUPPORT_FONT_ATLAS_SIZE_CONSERVATIVE)
+ int rowCount = 0;
+ int imageSize = 64; // Define minimum starting value to avoid unnecessary calculation steps for very small images
+
+ // NOTE: maxGlyphWidth is maximum possible space left at the end of row
+ while (totalWidth > (imageSize - maxGlyphWidth)*rowCount)
+ {
+ imageSize *= 2; // Double the size of image (to keep POT)
+ rowCount = imageSize/(fontSize + 2*padding); // Calculate new row count for the new image size
+ }
atlas.width = imageSize; // Atlas bitmap width
atlas.height = imageSize; // Atlas bitmap height
+#else
+ // No need for a so-conservative atlas generation
+ float totalArea = totalWidth*fontSize*1.2f;
+ float imageMinSize = sqrtf(totalArea);
+ int imageSize = (int)powf(2, ceilf(logf(imageMinSize)/logf(2)));
+
+ if (totalArea < ((imageSize*imageSize)/2))
+ {
+ atlas.width = imageSize; // Atlas bitmap width
+ atlas.height = imageSize/2; // Atlas bitmap height
+ }
+ else
+ {
+ atlas.width = imageSize; // Atlas bitmap width
+ atlas.height = imageSize; // Atlas bitmap height
+ }
+#endif
+
atlas.data = (unsigned char *)RL_CALLOC(1, atlas.width*atlas.height); // Create a bitmap to store characters (8 bpp)
atlas.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE;
atlas.mipmaps = 1;
@@ -707,24 +763,7 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
// NOTE: Using simple packaging, one char after another
for (int i = 0; i < glyphCount; i++)
{
- // Copy pixel data from fc.data to atlas
- for (int y = 0; y < chars[i].image.height; y++)
- {
- for (int x = 0; x < chars[i].image.width; x++)
- {
- ((unsigned char *)atlas.data)[(offsetY + y)*atlas.width + (offsetX + x)] = ((unsigned char *)chars[i].image.data)[y*chars[i].image.width + x];
- }
- }
-
- // Fill chars rectangles in atlas info
- recs[i].x = (float)offsetX;
- recs[i].y = (float)offsetY;
- recs[i].width = (float)chars[i].image.width;
- recs[i].height = (float)chars[i].image.height;
-
- // Move atlas position X for next character drawing
- offsetX += (chars[i].image.width + 2*padding);
-
+ // Check remaining space for glyph
if (offsetX >= (atlas.width - chars[i].image.width - 2*padding))
{
offsetX = padding;
@@ -748,6 +787,24 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
break;
}
}
+
+ // Copy pixel data from fc.data to atlas
+ for (int y = 0; y < chars[i].image.height; y++)
+ {
+ for (int x = 0; x < chars[i].image.width; x++)
+ {
+ ((unsigned char *)atlas.data)[(offsetY + y)*atlas.width + (offsetX + x)] = ((unsigned char *)chars[i].image.data)[y*chars[i].image.width + x];
+ }
+ }
+
+ // Fill chars rectangles in atlas info
+ recs[i].x = (float)offsetX;
+ recs[i].y = (float)offsetY;
+ recs[i].width = (float)chars[i].image.width;
+ recs[i].height = (float)chars[i].image.height;
+
+ // Move atlas position X for next character drawing
+ offsetX += (chars[i].image.width + 2*padding);
}
}
else if (packMethod == 1) // Use Skyline rect packing algorithm (stb_pack_rect)
@@ -771,7 +828,7 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
for (int i = 0; i < glyphCount; i++)
{
- // It return char rectangles in atlas
+ // It returns char rectangles in atlas
recs[i].x = rects[i].x + (float)padding;
recs[i].y = rects[i].y + (float)padding;
recs[i].width = (float)chars[i].image.width;
@@ -796,6 +853,19 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
RL_FREE(context);
}
+#if defined(SUPPORT_FONT_ATLAS_WHITE_REC)
+ // Add a 3x3 white rectangle at the bottom-right corner of the generated atlas,
+ // useful to use as the white texture to draw shapes with raylib, using this rectangle
+ // shapes and text can be backed into a single draw call: SetShapesTexture()
+ for (int i = 0, k = atlas.width*atlas.height - 1; i < 3; i++)
+ {
+ ((unsigned char *)atlas.data)[k - 0] = 255;
+ ((unsigned char *)atlas.data)[k - 1] = 255;
+ ((unsigned char *)atlas.data)[k - 2] = 255;
+ k -= atlas.width;
+ }
+#endif
+
// Convert image data from GRAYSCALE to GRAY_ALPHA
unsigned char *dataGrayAlpha = (unsigned char *)RL_MALLOC(atlas.width*atlas.height*sizeof(unsigned char)*2); // Two channels
@@ -867,7 +937,7 @@ bool ExportFontAsCode(Font font, const char *fileName)
byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n");
byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n");
byteCount += sprintf(txtData + byteCount, "// //\n");
- byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2022 Ramon Santamaria (@raysan5) //\n");
+ byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2023 Ramon Santamaria (@raysan5) //\n");
byteCount += sprintf(txtData + byteCount, "// //\n");
byteCount += sprintf(txtData + byteCount, "// ---------------------------------------------------------------------------------- //\n");
byteCount += sprintf(txtData + byteCount, "// //\n");
@@ -896,7 +966,7 @@ bool ExportFontAsCode(Font font, const char *fileName)
// Compress font image data
int compDataSize = 0;
- unsigned char *compData = CompressData(image.data, imageDataSize, &compDataSize);
+ unsigned char *compData = CompressData((const unsigned char *)image.data, imageDataSize, &compDataSize);
// Save font image data (compressed)
byteCount += sprintf(txtData + byteCount, "#define COMPRESSED_DATA_SIZE_FONT_%s %i\n\n", TextToUpper(fileNamePascal), compDataSize);
@@ -1034,7 +1104,7 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f
int size = TextLength(text); // Total size in bytes of the text, scanned by codepoints in loop
- int textOffsetY = 0; // Offset between lines (on line break '\n')
+ int textOffsetY = 0; // Offset between lines (on linebreak '\n')
float textOffsetX = 0.0f; // Offset X to next character to draw
float scaleFactor = fontSize/font.baseSize; // Character quad scaling factor
@@ -1046,15 +1116,10 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f
int codepoint = GetCodepointNext(&text[i], &codepointByteCount);
int index = GetGlyphIndex(font, codepoint);
- // NOTE: Normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
- // but we need to draw all of the bad bytes using the '?' symbol moving one byte
- if (codepoint == 0x3f) codepointByteCount = 1;
-
if (codepoint == '\n')
{
- // NOTE: Fixed line spacing of 1.5 line-height
- // TODO: Support custom line spacing defined by user
- textOffsetY += (int)((font.baseSize + font.baseSize/2.0f)*scaleFactor);
+ // NOTE: Line spacing is a global variable, use SetTextLineSpacing() to setup
+ textOffsetY += textLineSpacing;
textOffsetX = 0.0f;
}
else
@@ -1113,7 +1178,7 @@ void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSiz
// Draw multiple character (codepoints)
void DrawTextCodepoints(Font font, const int *codepoints, int count, Vector2 position, float fontSize, float spacing, Color tint)
{
- int textOffsetY = 0; // Offset between lines (on line break '\n')
+ int textOffsetY = 0; // Offset between lines (on linebreak '\n')
float textOffsetX = 0.0f; // Offset X to next character to draw
float scaleFactor = fontSize/font.baseSize; // Character quad scaling factor
@@ -1124,9 +1189,8 @@ void DrawTextCodepoints(Font font, const int *codepoints, int count, Vector2 pos
if (codepoints[i] == '\n')
{
- // NOTE: Fixed line spacing of 1.5 line-height
- // TODO: Support custom line spacing defined by user
- textOffsetY += (int)((font.baseSize + font.baseSize/2.0f)*scaleFactor);
+ // NOTE: Line spacing is a global variable, use SetTextLineSpacing() to setup
+ textOffsetY += textLineSpacing;
textOffsetX = 0.0f;
}
else
@@ -1142,6 +1206,12 @@ void DrawTextCodepoints(Font font, const int *codepoints, int count, Vector2 pos
}
}
+// Set vertical line spacing when drawing with line-breaks
+void SetTextLineSpacing(int spacing)
+{
+ textLineSpacing = spacing;
+}
+
// Measure string width for default font
int MeasureText(const char *text, int fontSize)
{
@@ -1180,7 +1250,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
int letter = 0; // Current character
int index = 0; // Index position in sprite font
- for (int i = 0; i < size; i++)
+ for (int i = 0; i < size;)
{
byteCounter++;
@@ -1188,10 +1258,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
letter = GetCodepointNext(&text[i], &next);
index = GetGlyphIndex(font, letter);
- // NOTE: normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
- // but we need to draw all of the bad bytes using the '?' symbol so to not skip any we set next = 1
- if (letter == 0x3f) next = 1;
- i += next - 1;
+ i += next;
if (letter != '\n')
{
@@ -1203,7 +1270,9 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
if (tempTextWidth < textWidth) tempTextWidth = textWidth;
byteCounter = 0;
textWidth = 0;
- textHeight += ((float)font.baseSize*1.5f); // NOTE: Fixed line spacing of 1.5 lines
+
+ // NOTE: Line spacing is a global variable, use SetTextLineSpacing() to setup
+ textHeight += (float)textLineSpacing;
}
if (tempByteCounter < byteCounter) tempByteCounter = byteCounter;
@@ -1211,7 +1280,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
if (tempTextWidth < textWidth) tempTextWidth = textWidth;
- textSize.x = tempTextWidth*scaleFactor + (float)((tempByteCounter - 1)*spacing); // Adds chars spacing to measure
+ textSize.x = tempTextWidth*scaleFactor + (float)((tempByteCounter - 1)*spacing);
textSize.y = textHeight*scaleFactor;
return textSize;
@@ -1221,17 +1290,17 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
// NOTE: If codepoint is not found in the font it fallbacks to '?'
int GetGlyphIndex(Font font, int codepoint)
{
-#ifndef GLYPH_NOTFOUND_CHAR_FALLBACK
- #define GLYPH_NOTFOUND_CHAR_FALLBACK 63 // Character used if requested codepoint is not found: '?'
-#endif
+ int index = 0;
-// Support charsets with any characters order
#define SUPPORT_UNORDERED_CHARSET
#if defined(SUPPORT_UNORDERED_CHARSET)
- int index = GLYPH_NOTFOUND_CHAR_FALLBACK;
+ int fallbackIndex = 0; // Get index of fallback glyph '?'
+ // Look for character index in the unordered charset
for (int i = 0; i < font.glyphCount; i++)
{
+ if (font.glyphs[i].value == 63) fallbackIndex = i;
+
if (font.glyphs[i].value == codepoint)
{
index = i;
@@ -1239,10 +1308,12 @@ int GetGlyphIndex(Font font, int codepoint)
}
}
- return index;
+ if ((index == 0) && (font.glyphs[0].value != codepoint)) index = fallbackIndex;
#else
- return (codepoint - 32);
+ index = codepoint - 32;
#endif
+
+ return index;
}
// Get glyph font info data for a codepoint (unicode character)
@@ -1322,7 +1393,7 @@ int TextToInteger(const char *text)
text++;
}
- for (int i = 0; ((text[i] >= '0') && (text[i] <= '9')); ++i) value = value*10 + (int)(text[i] - '0');
+ for (int i = 0; ((text[i] >= '0') && (text[i] <= '9')); i++) value = value*10 + (int)(text[i] - '0');
return value*sign;
}
@@ -1333,7 +1404,7 @@ int TextCopy(char *dst, const char *src)
{
int bytes = 0;
- if (dst != NULL)
+ if ((src != NULL) && (dst != NULL))
{
while (*src != '\0')
{
@@ -1404,7 +1475,7 @@ char *TextReplace(char *text, const char *replace, const char *by)
char *insertPoint = NULL; // Next insert point
char *temp = NULL; // Temp pointer
int replaceLen = 0; // Replace string length of (the string to remove)
- int byLen = 0; // Replacement length (the string to replace replace by)
+ int byLen = 0; // Replacement length (the string to replace by)
int lastReplacePos = 0; // Distance between replace and end of last replace
int count = 0; // Number of replacements
@@ -1556,69 +1627,66 @@ int TextFindIndex(const char *text, const char *find)
}
// Get upper case version of provided string
-// REQUIRES: toupper()
+// WARNING: Limited functionality, only basic characters set
+// TODO: Support UTF-8 diacritics to upper-case, check codepoints
const char *TextToUpper(const char *text)
{
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
- for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++)
+ if (text != NULL)
{
- if (text[i] != '\0')
+ for (int i = 0; (i < MAX_TEXT_BUFFER_LENGTH - 1) && (text[i] != '\0'); i++)
{
- buffer[i] = (char)toupper(text[i]);
- //if ((text[i] >= 'a') && (text[i] <= 'z')) buffer[i] = text[i] - 32;
-
- // TODO: Support UTF-8 diacritics to upper-case
- //if ((text[i] >= 'à') && (text[i] <= 'ý')) buffer[i] = text[i] - 32;
+ if ((text[i] >= 'a') && (text[i] <= 'z')) buffer[i] = text[i] - 32;
+ else buffer[i] = text[i];
}
- else { buffer[i] = '\0'; break; }
}
return buffer;
}
// Get lower case version of provided string
-// REQUIRES: tolower()
+// WARNING: Limited functionality, only basic characters set
const char *TextToLower(const char *text)
{
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
- for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++)
+ if (text != NULL)
{
- if (text[i] != '\0')
+ for (int i = 0; (i < MAX_TEXT_BUFFER_LENGTH - 1) && (text[i] != '\0'); i++)
{
- buffer[i] = (char)tolower(text[i]);
- //if ((text[i] >= 'A') && (text[i] <= 'Z')) buffer[i] = text[i] + 32;
+ if ((text[i] >= 'A') && (text[i] <= 'Z')) buffer[i] = text[i] + 32;
+ else buffer[i] = text[i];
}
- else { buffer[i] = '\0'; break; }
}
return buffer;
}
// Get Pascal case notation version of provided string
-// REQUIRES: toupper()
+// WARNING: Limited functionality, only basic characters set
const char *TextToPascal(const char *text)
{
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
- buffer[0] = (char)toupper(text[0]);
-
- for (int i = 1, j = 1; i < MAX_TEXT_BUFFER_LENGTH; i++, j++)
+ if (text != NULL)
{
- if (text[j] != '\0')
+ // Upper case first character
+ if ((text[0] >= 'a') && (text[0] <= 'z')) buffer[0] = text[0] - 32;
+
+ // Check for next separator to upper case another character
+ for (int i = 1, j = 1; (i < MAX_TEXT_BUFFER_LENGTH - 1) && (text[j] != '\0'); i++, j++)
{
if (text[j] != '_') buffer[i] = text[j];
else
{
j++;
- buffer[i] = (char)toupper(text[j]);
+ if ((text[j] >= 'a') && (text[j] <= 'z')) buffer[i] = text[j] - 32;
}
}
- else { buffer[i] = '\0'; break; }
}
return buffer;
@@ -1629,7 +1697,7 @@ const char *TextToPascal(const char *text)
// WARNING: Allocated memory must be manually freed
char *LoadUTF8(const int *codepoints, int length)
{
- // We allocate enough memory fo fit all possible codepoints
+ // We allocate enough memory to fit all possible codepoints
// NOTE: 5 bytes for every codepoint should be enough
char *text = (char *)RL_CALLOC(length*5, 1);
const char *utf8 = NULL;
@@ -1665,7 +1733,7 @@ int *LoadCodepoints(const char *text, int *count)
int codepointCount = 0;
// Allocate a big enough buffer to store as many codepoints as text bytes
- int *codepoints = RL_CALLOC(textLength, sizeof(int));
+ int *codepoints = (int *)RL_CALLOC(textLength, sizeof(int));
for (int i = 0; i < textLength; codepointCount++)
{
@@ -1674,7 +1742,7 @@ int *LoadCodepoints(const char *text, int *count)
}
// Re-allocate buffer to the actual number of codepoints loaded
- void *temp = RL_REALLOC(codepoints, codepointCount*sizeof(int));
+ int *temp = (int *)RL_REALLOC(codepoints, codepointCount*sizeof(int));
if (temp != NULL) codepoints = temp;
*count = codepointCount;
@@ -1698,10 +1766,9 @@ int GetCodepointCount(const char *text)
while (*ptr != '\0')
{
int next = 0;
- int letter = GetCodepointNext(ptr, &next);
+ GetCodepointNext(ptr, &next);
- if (letter == 0x3f) ptr += 1;
- else ptr += next;
+ ptr += next;
length++;
}
@@ -1750,7 +1817,7 @@ const char *CodepointToUTF8(int codepoint, int *utf8Size)
#endif // SUPPORT_TEXT_MANIPULATION
// Get next codepoint in a UTF-8 encoded text, scanning until '\0' is found
-// When a invalid UTF-8 byte is encountered we exit as soon as possible and a '?'(0x3f) codepoint is returned
+// When an invalid UTF-8 byte is encountered we exit as soon as possible and a '?'(0x3f) codepoint is returned
// Total number of bytes processed are returned as a parameter
// NOTE: The standard says U+FFFD should be returned in case of errors
// but that character is not supported by the default font in raylib
@@ -1862,34 +1929,37 @@ int GetCodepointNext(const char *text, int *codepointSize)
{
const char *ptr = text;
int codepoint = 0x3f; // Codepoint (defaults to '?')
- *codepointSize = 0;
-
+ *codepointSize = 1;
+
// Get current codepoint and bytes processed
if (0xf0 == (0xf8 & ptr[0]))
{
// 4 byte UTF-8 codepoint
+ if(((ptr[1] & 0xC0) ^ 0x80) || ((ptr[2] & 0xC0) ^ 0x80) || ((ptr[3] & 0xC0) ^ 0x80)) { return codepoint; } //10xxxxxx checks
codepoint = ((0x07 & ptr[0]) << 18) | ((0x3f & ptr[1]) << 12) | ((0x3f & ptr[2]) << 6) | (0x3f & ptr[3]);
*codepointSize = 4;
}
else if (0xe0 == (0xf0 & ptr[0]))
{
// 3 byte UTF-8 codepoint */
+ if(((ptr[1] & 0xC0) ^ 0x80) || ((ptr[2] & 0xC0) ^ 0x80)) { return codepoint; } //10xxxxxx checks
codepoint = ((0x0f & ptr[0]) << 12) | ((0x3f & ptr[1]) << 6) | (0x3f & ptr[2]);
*codepointSize = 3;
- }
+ }
else if (0xc0 == (0xe0 & ptr[0]))
{
// 2 byte UTF-8 codepoint
+ if((ptr[1] & 0xC0) ^ 0x80) { return codepoint; } //10xxxxxx checks
codepoint = ((0x1f & ptr[0]) << 6) | (0x3f & ptr[1]);
*codepointSize = 2;
- }
- else
+ }
+ else if (0x00 == (0x80 & ptr[0]))
{
// 1 byte UTF-8 codepoint
codepoint = ptr[0];
*codepointSize = 1;
}
-
+
return codepoint;
}
@@ -1904,7 +1974,7 @@ int GetCodepointPrevious(const char *text, int *codepointSize)
// Move to previous codepoint
do ptr--;
while (((0x80 & ptr[0]) != 0) && ((0xc0 & ptr[0]) == 0x80));
-
+
codepoint = GetCodepointNext(ptr, &cpSize);
if (codepoint != 0) *codepointSize = cpSize;
@@ -1992,7 +2062,7 @@ static Font LoadBMFont(const char *fileName)
if (lastSlash != NULL)
{
// NOTE: We need some extra space to avoid memory corruption on next allocations!
- imPath = RL_CALLOC(TextLength(fileName) - TextLength(lastSlash) + TextLength(imFileName) + 4, 1);
+ imPath = (char *)RL_CALLOC(TextLength(fileName) - TextLength(lastSlash) + TextLength(imFileName) + 4, 1);
memcpy(imPath, fileName, TextLength(fileName) - TextLength(lastSlash) + 1);
memcpy(imPath + TextLength(fileName) - TextLength(lastSlash) + 1, imFileName, TextLength(imFileName));
}
@@ -2006,11 +2076,11 @@ static Font LoadBMFont(const char *fileName)
{
// Convert image to GRAYSCALE + ALPHA, using the mask as the alpha channel
Image imFontAlpha = {
- .data = calloc(imFont.width*imFont.height, 2),
+ .data = RL_CALLOC(imFont.width*imFont.height, 2),
.width = imFont.width,
.height = imFont.height,
- .format = PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA,
- .mipmaps = 1
+ .mipmaps = 1,
+ .format = PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA
};
for (int p = 0, i = 0; p < (imFont.width*imFont.height*2); p += 2, i++)
diff --git a/src/rtextures.c b/src/rtextures.c
index b481af62b..99056be5a 100644
--- a/src/rtextures.c
+++ b/src/rtextures.c
@@ -3,36 +3,36 @@
* rtextures - Basic functions to load and draw textures
*
* CONFIGURATION:
+* #define SUPPORT_MODULE_RTEXTURES
+* rtextures module is included in the build
*
-* #define SUPPORT_MODULE_RTEXTURES
-* rtextures module is included in the build
+* #define SUPPORT_FILEFORMAT_BMP
+* #define SUPPORT_FILEFORMAT_PNG
+* #define SUPPORT_FILEFORMAT_TGA
+* #define SUPPORT_FILEFORMAT_JPG
+* #define SUPPORT_FILEFORMAT_GIF
+* #define SUPPORT_FILEFORMAT_QOI
+* #define SUPPORT_FILEFORMAT_PSD
+* #define SUPPORT_FILEFORMAT_HDR
+* #define SUPPORT_FILEFORMAT_PIC
+* #define SUPPORT_FILEFORMAT_PNM
+* #define SUPPORT_FILEFORMAT_DDS
+* #define SUPPORT_FILEFORMAT_PKM
+* #define SUPPORT_FILEFORMAT_KTX
+* #define SUPPORT_FILEFORMAT_PVR
+* #define SUPPORT_FILEFORMAT_ASTC
+* Select desired fileformats to be supported for image data loading. Some of those formats are
+* supported by default, to remove support, just comment unrequired #define in this module
*
-* #define SUPPORT_FILEFORMAT_BMP
-* #define SUPPORT_FILEFORMAT_PNG
-* #define SUPPORT_FILEFORMAT_TGA
-* #define SUPPORT_FILEFORMAT_JPG
-* #define SUPPORT_FILEFORMAT_GIF
-* #define SUPPORT_FILEFORMAT_QOI
-* #define SUPPORT_FILEFORMAT_PSD
-* #define SUPPORT_FILEFORMAT_PIC
-* #define SUPPORT_FILEFORMAT_HDR
-* #define SUPPORT_FILEFORMAT_DDS
-* #define SUPPORT_FILEFORMAT_PKM
-* #define SUPPORT_FILEFORMAT_KTX
-* #define SUPPORT_FILEFORMAT_PVR
-* #define SUPPORT_FILEFORMAT_ASTC
-* Select desired fileformats to be supported for image data loading. Some of those formats are
-* supported by default, to remove support, just comment unrequired #define in this module
+* #define SUPPORT_IMAGE_EXPORT
+* Support image export in multiple file formats
*
-* #define SUPPORT_IMAGE_EXPORT
-* Support image export in multiple file formats
+* #define SUPPORT_IMAGE_MANIPULATION
+* Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop...
+* If not defined only some image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageResize*()
*
-* #define SUPPORT_IMAGE_MANIPULATION
-* Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop...
-* If not defined only three image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageToPOT()
-*
-* #define SUPPORT_IMAGE_GENERATION
-* Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)
+* #define SUPPORT_IMAGE_GENERATION
+* Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)
*
* DEPENDENCIES:
* stb_image - Multiple image formats loading (JPEG, PNG, BMP, TGA, PSD, GIF, PIC)
@@ -42,7 +42,7 @@
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -103,6 +103,9 @@
#if !defined(SUPPORT_FILEFORMAT_HDR)
#define STBI_NO_HDR
#endif
+#if !defined(SUPPORT_FILEFORMAT_PNM)
+ #define STBI_NO_PNM
+#endif
#if defined(SUPPORT_FILEFORMAT_DDS)
#define RL_GPUTEX_SUPPORT_DDS
@@ -121,9 +124,6 @@
#endif
// Image fileformats not supported by default
-#define STBI_NO_PIC
-#define STBI_NO_PNM // Image format .ppm and .pgm
-
#if defined(__TINYC__)
#define STBI_NO_SIMD
#endif
@@ -134,8 +134,14 @@
defined(SUPPORT_FILEFORMAT_JPG) || \
defined(SUPPORT_FILEFORMAT_PSD) || \
defined(SUPPORT_FILEFORMAT_GIF) || \
+ defined(SUPPORT_FILEFORMAT_HDR) || \
defined(SUPPORT_FILEFORMAT_PIC) || \
- defined(SUPPORT_FILEFORMAT_HDR))
+ defined(SUPPORT_FILEFORMAT_PNM))
+
+ #if defined(__GNUC__) // GCC and Clang
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wunused-function"
+ #endif
#define STBI_MALLOC RL_MALLOC
#define STBI_FREE RL_FREE
@@ -144,6 +150,10 @@
#define STB_IMAGE_IMPLEMENTATION
#include "external/stb_image.h" // Required for: stbi_load_from_file()
// NOTE: Used to read image data (multiple formats support)
+
+ #if defined(__GNUC__) // GCC and Clang
+ #pragma GCC diagnostic pop
+ #endif
#endif
#if (defined(SUPPORT_FILEFORMAT_DDS) || \
@@ -152,17 +162,36 @@
defined(SUPPORT_FILEFORMAT_PVR) || \
defined(SUPPORT_FILEFORMAT_ASTC))
+ #if defined(__GNUC__) // GCC and Clang
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wunused-function"
+ #endif
+
#define RL_GPUTEX_IMPLEMENTATION
#include "external/rl_gputex.h" // Required for: rl_load_xxx_from_memory()
// NOTE: Used to read compressed textures data (multiple formats support)
+
+ #if defined(__GNUC__) // GCC and Clang
+ #pragma GCC diagnostic pop
+ #endif
#endif
#if defined(SUPPORT_FILEFORMAT_QOI)
#define QOI_MALLOC RL_MALLOC
#define QOI_FREE RL_FREE
+ #if defined(_MSC_VER) // Disable some MSVC warning
+ #pragma warning(push)
+ #pragma warning(disable : 4267)
+ #endif
+
#define QOI_IMPLEMENTATION
#include "external/qoi.h"
+
+ #if defined(_MSC_VER)
+ #pragma warning(pop) // Disable MSVC warning suppression
+ #endif
+
#endif
#if defined(SUPPORT_IMAGE_EXPORT)
@@ -179,13 +208,10 @@
#include "external/stb_perlin.h" // Required for: stb_perlin_fbm_noise3
#endif
-#if defined(SUPPORT_IMAGE_MANIPULATION)
- #define STBIR_MALLOC(size,c) ((void)(c), RL_MALLOC(size))
- #define STBIR_FREE(ptr,c) ((void)(c), RL_FREE(ptr))
-
- #define STB_IMAGE_RESIZE_IMPLEMENTATION
- #include "external/stb_image_resize.h" // Required for: stbir_resize_uint8() [ImageResize()]
-#endif
+#define STBIR_MALLOC(size,c) ((void)(c), RL_MALLOC(size))
+#define STBIR_FREE(ptr,c) ((void)(c), RL_FREE(ptr))
+#define STB_IMAGE_RESIZE_IMPLEMENTATION
+#include "external/stb_image_resize.h" // Required for: stbir_resize_uint8() [ImageResize()]
#if defined(SUPPORT_FILEFORMAT_SVG)
#define NANOSVG_IMPLEMENTATION // Expands implementation
@@ -202,6 +228,10 @@
#define PIXELFORMAT_UNCOMPRESSED_R5G5B5A1_ALPHA_THRESHOLD 50 // Threshold over 255 to set alpha as 0
#endif
+#ifndef GAUSSIAN_BLUR_ITERATIONS
+ #define GAUSSIAN_BLUR_ITERATIONS 4 // Number of box blur iterations to approximate gaussian blur
+#endif
+
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
@@ -215,11 +245,13 @@
//----------------------------------------------------------------------------------
// Other Modules Functions Declaration (required by text)
//----------------------------------------------------------------------------------
-// ...
+extern void LoadFontDefault(void); // [Module: text] Loads default font, required by ImageDrawText()
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
//----------------------------------------------------------------------------------
+static float HalfToFloat(unsigned short x);
+static unsigned short FloatToHalf(float x);
static Vector4 *LoadImageDataNormalized(Image image); // Load pixel data from image as Vector4 array (float normalized)
//----------------------------------------------------------------------------------
@@ -238,6 +270,7 @@ Image LoadImage(const char *fileName)
defined(SUPPORT_FILEFORMAT_GIF) || \
defined(SUPPORT_FILEFORMAT_PIC) || \
defined(SUPPORT_FILEFORMAT_HDR) || \
+ defined(SUPPORT_FILEFORMAT_PNM) || \
defined(SUPPORT_FILEFORMAT_PSD)
#define STBI_REQUIRED
@@ -357,7 +390,7 @@ Image LoadImageSvgFromString(const char *string, int width, int height)
Image LoadImageAnim(const char *fileName, int *frames)
{
Image image = { 0 };
- int frameCount = 1;
+ int frameCount = 0;
#if defined(SUPPORT_FILEFORMAT_GIF)
if (IsFileExtension(fileName, ".gif"))
@@ -381,9 +414,11 @@ Image LoadImageAnim(const char *fileName, int *frames)
#else
if (false) { }
#endif
- else image = LoadImage(fileName);
-
- // TODO: Support APNG animated images
+ else
+ {
+ image = LoadImage(fileName);
+ frameCount = 1;
+ }
*frames = frameCount;
return image;
@@ -397,25 +432,30 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
if ((false)
#if defined(SUPPORT_FILEFORMAT_PNG)
- || (strcmp(fileType, ".png") == 0)
+ || (strcmp(fileType, ".png") == 0) || (strcmp(fileType, ".PNG") == 0)
#endif
#if defined(SUPPORT_FILEFORMAT_BMP)
- || (strcmp(fileType, ".bmp") == 0)
+ || (strcmp(fileType, ".bmp") == 0) || (strcmp(fileType, ".BMP") == 0)
#endif
#if defined(SUPPORT_FILEFORMAT_TGA)
- || (strcmp(fileType, ".tga") == 0)
+ || (strcmp(fileType, ".tga") == 0) || (strcmp(fileType, ".TGA") == 0)
#endif
#if defined(SUPPORT_FILEFORMAT_JPG)
- || ((strcmp(fileType, ".jpg") == 0) || (strcmp(fileType, ".jpeg") == 0))
+ || (strcmp(fileType, ".jpg") == 0) || (strcmp(fileType, ".jpeg") == 0)
+ || (strcmp(fileType, ".JPG") == 0) || (strcmp(fileType, ".JPEG") == 0)
#endif
#if defined(SUPPORT_FILEFORMAT_GIF)
- || (strcmp(fileType, ".gif") == 0)
+ || (strcmp(fileType, ".gif") == 0) || (strcmp(fileType, ".GIF") == 0)
#endif
#if defined(SUPPORT_FILEFORMAT_PIC)
- || (strcmp(fileType, ".pic") == 0)
+ || (strcmp(fileType, ".pic") == 0) || (strcmp(fileType, ".PIC") == 0)
+#endif
+#if defined(SUPPORT_FILEFORMAT_PNM)
+ || (strcmp(fileType, ".ppm") == 0) || (strcmp(fileType, ".pgm") == 0)
+ || (strcmp(fileType, ".PPM") == 0) || (strcmp(fileType, ".PGM") == 0)
#endif
#if defined(SUPPORT_FILEFORMAT_PSD)
- || (strcmp(fileType, ".psd") == 0)
+ || (strcmp(fileType, ".psd") == 0) || (strcmp(fileType, ".PSD") == 0)
#endif
)
{
@@ -440,7 +480,7 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
#endif
}
#if defined(SUPPORT_FILEFORMAT_HDR)
- else if (strcmp(fileType, ".hdr") == 0)
+ else if ((strcmp(fileType, ".hdr") == 0) || (strcmp(fileType, ".HDR") == 0))
{
#if defined(STBI_REQUIRED)
if (fileData != NULL)
@@ -463,7 +503,7 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
}
#endif
#if defined(SUPPORT_FILEFORMAT_QOI)
- else if (strcmp(fileType, ".qoi") == 0)
+ else if ((strcmp(fileType, ".qoi") == 0) || (strcmp(fileType, ".QOI") == 0))
{
qoi_desc desc = { 0 };
image.data = qoi_decode(fileData, dataSize, &desc, 4);
@@ -474,31 +514,31 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
}
#endif
#if defined(SUPPORT_FILEFORMAT_DDS)
- else if (strcmp(fileType, ".dds") == 0)
+ else if ((strcmp(fileType, ".dds") == 0) || (strcmp(fileType, ".DDS") == 0))
{
image.data = rl_load_dds_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
}
#endif
#if defined(SUPPORT_FILEFORMAT_PKM)
- else if (strcmp(fileType, ".pkm") == 0)
+ else if ((strcmp(fileType, ".pkm") == 0) || (strcmp(fileType, ".PKM") == 0))
{
image.data = rl_load_pkm_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
}
#endif
#if defined(SUPPORT_FILEFORMAT_KTX)
- else if (strcmp(fileType, ".ktx") == 0)
+ else if ((strcmp(fileType, ".ktx") == 0) || (strcmp(fileType, ".KTX") == 0))
{
image.data = rl_load_ktx_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
}
#endif
#if defined(SUPPORT_FILEFORMAT_PVR)
- else if (strcmp(fileType, ".pvr") == 0)
+ else if ((strcmp(fileType, ".pvr") == 0) || (strcmp(fileType, ".PVR") == 0))
{
image.data = rl_load_pvr_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
}
#endif
#if defined(SUPPORT_FILEFORMAT_ASTC)
- else if (strcmp(fileType, ".astc") == 0)
+ else if ((strcmp(fileType, ".astc") == 0) || (strcmp(fileType, ".ASTC") == 0))
{
image.data = rl_load_astc_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
}
@@ -578,6 +618,16 @@ Image LoadImageFromScreen(void)
return image;
}
+// Check if an image is ready
+bool IsImageReady(Image image)
+{
+ return ((image.data != NULL) && // Validate pixel data available
+ (image.width > 0) &&
+ (image.height > 0) && // Validate image size
+ (image.format > 0) && // Validate image format
+ (image.mipmaps > 0)); // Validate image mipmaps (at least 1 for basic mipmap level)
+}
+
// Unload image from CPU memory (RAM)
void UnloadImage(Image image)
{
@@ -590,6 +640,8 @@ bool ExportImage(Image image, const char *fileName)
{
int success = 0;
+ if ((image.width == 0) || (image.height == 0) || (image.data == NULL)) return success;
+
#if defined(SUPPORT_IMAGE_EXPORT)
int channels = 4;
bool allocatedData = false;
@@ -669,6 +721,34 @@ bool ExportImage(Image image, const char *fileName)
return success;
}
+// Export image to memory buffer
+unsigned char *ExportImageToMemory(Image image, const char *fileType, int *dataSize)
+{
+ unsigned char *fileData = NULL;
+ *dataSize = 0;
+
+ if ((image.width == 0) || (image.height == 0) || (image.data == NULL)) return NULL;
+
+#if defined(SUPPORT_IMAGE_EXPORT)
+ int channels = 4;
+
+ if (image.format == PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) channels = 1;
+ else if (image.format == PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) channels = 2;
+ else if (image.format == PIXELFORMAT_UNCOMPRESSED_R8G8B8) channels = 3;
+ else if (image.format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8) channels = 4;
+
+#if defined(SUPPORT_FILEFORMAT_PNG)
+ if ((strcmp(fileType, ".png") == 0) || (strcmp(fileType, ".PNG") == 0))
+ {
+ fileData = stbi_write_png_to_mem((const unsigned char *)image.data, image.width*channels, image.width, image.height, channels, dataSize);
+ }
+#endif
+
+#endif
+
+ return fileData;
+}
+
// Export image as code file (.h) defining an array of bytes
bool ExportImageAsCode(Image image, const char *fileName)
{
@@ -694,7 +774,7 @@ bool ExportImageAsCode(Image image, const char *fileName)
byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n");
byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n");
byteCount += sprintf(txtData + byteCount, "// //\n");
- byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2022 Ramon Santamaria (@raysan5) //\n");
+ byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2023 Ramon Santamaria (@raysan5) //\n");
byteCount += sprintf(txtData + byteCount, "// //\n");
byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n\n");
@@ -748,48 +828,34 @@ Image GenImageColor(int width, int height, Color color)
}
#if defined(SUPPORT_IMAGE_GENERATION)
-// Generate image: vertical gradient
-Image GenImageGradientV(int width, int height, Color top, Color bottom)
+// Generate image: linear gradient
+// The direction value specifies the direction of the gradient (in degrees)
+// with 0 being vertical (from top to bottom), 90 being horizontal (from left to right).
+// The gradient effectively rotates counter-clockwise by the specified amount.
+Image GenImageGradientLinear(int width, int height, int direction, Color start, Color end)
{
Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color));
- for (int j = 0; j < height; j++)
- {
- float factor = (float)j/(float)height;
- for (int i = 0; i < width; i++)
- {
- pixels[j*width + i].r = (int)((float)bottom.r*factor + (float)top.r*(1.f - factor));
- pixels[j*width + i].g = (int)((float)bottom.g*factor + (float)top.g*(1.f - factor));
- pixels[j*width + i].b = (int)((float)bottom.b*factor + (float)top.b*(1.f - factor));
- pixels[j*width + i].a = (int)((float)bottom.a*factor + (float)top.a*(1.f - factor));
- }
- }
-
- Image image = {
- .data = pixels,
- .width = width,
- .height = height,
- .format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
- .mipmaps = 1
- };
-
- return image;
-}
-
-// Generate image: horizontal gradient
-Image GenImageGradientH(int width, int height, Color left, Color right)
-{
- Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color));
+ float radianDirection = (float)(90 - direction)/180.f*3.14159f;
+ float cosDir = cosf(radianDirection);
+ float sinDir = sinf(radianDirection);
for (int i = 0; i < width; i++)
{
- float factor = (float)i/(float)width;
for (int j = 0; j < height; j++)
{
- pixels[j*width + i].r = (int)((float)right.r*factor + (float)left.r*(1.f - factor));
- pixels[j*width + i].g = (int)((float)right.g*factor + (float)left.g*(1.f - factor));
- pixels[j*width + i].b = (int)((float)right.b*factor + (float)left.b*(1.f - factor));
- pixels[j*width + i].a = (int)((float)right.a*factor + (float)left.a*(1.f - factor));
+ // Calculate the relative position of the pixel along the gradient direction
+ float pos = (i*cosDir + j*sinDir)/(width*cosDir + height*sinDir);
+
+ float factor = pos;
+ factor = (factor > 1.0f)? 1.0f : factor; // Clamp to [0,1]
+ factor = (factor < 0.0f)? 0.0f : factor; // Clamp to [0,1]
+
+ // Generate the color for this pixel
+ pixels[j*width + i].r = (int)((float)end.r*factor + (float)start.r*(1.0f - factor));
+ pixels[j*width + i].g = (int)((float)end.g*factor + (float)start.g*(1.0f - factor));
+ pixels[j*width + i].b = (int)((float)end.b*factor + (float)start.b*(1.0f - factor));
+ pixels[j*width + i].a = (int)((float)end.a*factor + (float)start.a*(1.0f - factor));
}
}
@@ -821,7 +887,7 @@ Image GenImageGradientRadial(int width, int height, float density, Color inner,
float factor = (dist - radius*density)/(radius*(1.0f - density));
factor = (float)fmax(factor, 0.0f);
- factor = (float)fmin(factor, 1.f); // dist can be bigger than radius so we have to check
+ factor = (float)fmin(factor, 1.f); // dist can be bigger than radius, so we have to check
pixels[y*width + x].r = (int)((float)outer.r*factor + (float)inner.r*(1.0f - factor));
pixels[y*width + x].g = (int)((float)outer.g*factor + (float)inner.g*(1.0f - factor));
@@ -841,6 +907,55 @@ Image GenImageGradientRadial(int width, int height, float density, Color inner,
return image;
}
+// Generate image: square gradient
+Image GenImageGradientSquare(int width, int height, float density, Color inner, Color outer)
+{
+ Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color));
+
+ float centerX = (float)width/2.0f;
+ float centerY = (float)height/2.0f;
+
+ for (int y = 0; y < height; y++)
+ {
+ for (int x = 0; x < width; x++)
+ {
+ // Calculate the Manhattan distance from the center
+ float distX = fabsf(x - centerX);
+ float distY = fabsf(y - centerY);
+
+ // Normalize the distances by the dimensions of the gradient rectangle
+ float normalizedDistX = distX / centerX;
+ float normalizedDistY = distY / centerY;
+
+ // Calculate the total normalized Manhattan distance
+ float manhattanDist = fmaxf(normalizedDistX, normalizedDistY);
+
+ // Subtract the density from the manhattanDist, then divide by (1 - density)
+ // This makes the gradient start from the center when density is 0, and from the edge when density is 1
+ float factor = (manhattanDist - density)/(1.0f - density);
+
+ // Clamp the factor between 0 and 1
+ factor = fminf(fmaxf(factor, 0.0f), 1.0f);
+
+ // Blend the colors based on the calculated factor
+ pixels[y*width + x].r = (int)((float)outer.r*factor + (float)inner.r*(1.0f - factor));
+ pixels[y*width + x].g = (int)((float)outer.g*factor + (float)inner.g*(1.0f - factor));
+ pixels[y*width + x].b = (int)((float)outer.b*factor + (float)inner.b*(1.0f - factor));
+ pixels[y*width + x].a = (int)((float)outer.a*factor + (float)inner.a*(1.0f - factor));
+ }
+ }
+
+ Image image = {
+ .data = pixels,
+ .width = width,
+ .height = height,
+ .format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
+ .mipmaps = 1
+ };
+
+ return image;
+}
+
// Generate image: checked
Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2)
{
@@ -897,18 +1012,27 @@ Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float
{
for (int x = 0; x < width; x++)
{
- float nx = (float)(x + offsetX)*scale/(float)width;
- float ny = (float)(y + offsetY)*scale/(float)height;
+ float nx = (float)(x + offsetX)*(scale/(float)width);
+ float ny = (float)(y + offsetY)*(scale/(float)height);
+ // Basic perlin noise implementation (not used)
+ //float p = (stb_perlin_noise3(nx, ny, 0.0f, 0, 0, 0);
+
+ // Calculate a better perlin noise using fbm (fractal brownian motion)
// Typical values to start playing with:
// lacunarity = ~2.0 -- spacing between successive octaves (use exactly 2.0 for wrapping output)
// gain = 0.5 -- relative weighting applied to each successive octave
// octaves = 6 -- number of "octaves" of noise3() to sum
+ float p = stb_perlin_fbm_noise3(nx, ny, 1.0f, 2.0f, 0.5f, 6);
- // NOTE: We need to translate the data from [-1..1] to [0..1]
- float p = (stb_perlin_fbm_noise3(nx, ny, 1.0f, 2.0f, 0.5f, 6) + 1.0f)/2.0f;
+ // Clamp between -1.0f and 1.0f
+ if (p < -1.0f) p = -1.0f;
+ if (p > 1.0f) p = 1.0f;
- int intensity = (int)(p*255.0f);
+ // We need to normalize the data from [-1..1] to [0..1]
+ float np = (p + 1.0f)/2.0f;
+
+ int intensity = (int)(np*255.0f);
pixels[y*width + x] = (Color){ intensity, intensity, intensity, 255 };
}
}
@@ -968,7 +1092,7 @@ Image GenImageCellular(int width, int height, int tileSize)
}
}
- // I made this up but it seems to give good results at all tile sizes
+ // I made this up, but it seems to give good results at all tile sizes
int intensity = (int)(minDistance*256.0f/tileSize);
if (intensity > 255) intensity = 255;
@@ -988,6 +1112,25 @@ Image GenImageCellular(int width, int height, int tileSize)
return image;
}
+
+// Generate image: grayscale image from text data
+Image GenImageText(int width, int height, const char *text)
+{
+ Image image = { 0 };
+
+ int textLength = TextLength(text);
+ int imageViewSize = width*height;
+
+ image.width = width;
+ image.height = height;
+ image.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE;
+ image.data = RL_CALLOC(imageViewSize, 1);
+ image.mipmaps = 1;
+
+ memcpy(image.data, text, (textLength > imageViewSize)? imageViewSize : textLength);
+
+ return image;
+}
#endif // SUPPORT_IMAGE_GENERATION
//------------------------------------------------------------------------------------
@@ -1014,7 +1157,7 @@ Image ImageCopy(Image image)
if (height < 1) height = 1;
}
- newImage.data = RL_MALLOC(size);
+ newImage.data = RL_CALLOC(size, 1);
if (newImage.data != NULL)
{
@@ -1227,7 +1370,7 @@ void ImageFormat(Image *image, int newFormat)
} break;
case PIXELFORMAT_UNCOMPRESSED_R32:
{
- // WARNING: Image is converted to GRAYSCALE eqeuivalent 32bit
+ // WARNING: Image is converted to GRAYSCALE equivalent 32bit
image->data = (float *)RL_MALLOC(image->width*image->height*sizeof(float));
@@ -1259,13 +1402,47 @@ void ImageFormat(Image *image, int newFormat)
((float *)image->data)[i + 3] = pixels[k].w;
}
} break;
+ case PIXELFORMAT_UNCOMPRESSED_R16:
+ {
+ // WARNING: Image is converted to GRAYSCALE equivalent 16bit
+
+ image->data = (unsigned short *)RL_MALLOC(image->width*image->height*sizeof(unsigned short));
+
+ for (int i = 0; i < image->width*image->height; i++)
+ {
+ ((unsigned short *)image->data)[i] = FloatToHalf((float)(pixels[i].x*0.299f + pixels[i].y*0.587f + pixels[i].z*0.114f));
+ }
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16:
+ {
+ image->data = (unsigned short *)RL_MALLOC(image->width*image->height*3*sizeof(unsigned short));
+
+ for (int i = 0, k = 0; i < image->width*image->height*3; i += 3, k++)
+ {
+ ((unsigned short *)image->data)[i] = FloatToHalf(pixels[k].x);
+ ((unsigned short *)image->data)[i + 1] = FloatToHalf(pixels[k].y);
+ ((unsigned short *)image->data)[i + 2] = FloatToHalf(pixels[k].z);
+ }
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
+ {
+ image->data = (unsigned short *)RL_MALLOC(image->width*image->height*4*sizeof(unsigned short));
+
+ for (int i = 0, k = 0; i < image->width*image->height*4; i += 4, k++)
+ {
+ ((unsigned short *)image->data)[i] = FloatToHalf(pixels[k].x);
+ ((unsigned short *)image->data)[i + 1] = FloatToHalf(pixels[k].y);
+ ((unsigned short *)image->data)[i + 2] = FloatToHalf(pixels[k].z);
+ ((unsigned short *)image->data)[i + 3] = FloatToHalf(pixels[k].w);
+ }
+ } break;
default: break;
}
RL_FREE(pixels);
pixels = NULL;
- // In case original image had mipmaps, generate mipmaps for formated image
+ // In case original image had mipmaps, generate mipmaps for formatted image
// NOTE: Original mipmaps are replaced by new ones, if custom mipmaps were used, they are lost
if (image->mipmaps > 1)
{
@@ -1279,23 +1456,6 @@ void ImageFormat(Image *image, int newFormat)
}
}
-// Convert image to POT (power-of-two)
-// NOTE: It could be useful on OpenGL ES 2.0 (RPI, HTML5)
-void ImageToPOT(Image *image, Color fill)
-{
- // Security check to avoid program crash
- if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
-
- // Calculate next power-of-two values
- // NOTE: Just add the required amount of pixels at the right and bottom sides of image...
- int potWidth = (int)powf(2, ceilf(logf((float)image->width)/logf(2)));
- int potHeight = (int)powf(2, ceilf(logf((float)image->height)/logf(2)));
-
- // Check if POT texture generation is required (if texture is not already POT)
- if ((potWidth != image->width) || (potHeight != image->height)) ImageResizeCanvas(image, potWidth, potHeight, 0, 0, fill);
-}
-
-#if defined(SUPPORT_IMAGE_MANIPULATION)
// Create an image from text (default font)
Image ImageText(const char *text, int fontSize, Color color)
{
@@ -1313,6 +1473,7 @@ Image ImageText(const char *text, int fontSize, Color color)
}
// Create an image from text (custom sprite font)
+// WARNING: Module required: rtext
Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint)
{
Image imText = { 0 };
@@ -1320,25 +1481,22 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
int size = (int)strlen(text); // Get size in bytes of text
int textOffsetX = 0; // Image drawing position X
- int textOffsetY = 0; // Offset between lines (on line break '\n')
+ int textOffsetY = 0; // Offset between lines (on linebreak '\n')
// NOTE: Text image is generated at font base size, later scaled to desired font size
Vector2 imSize = MeasureTextEx(font, text, (float)font.baseSize, spacing); // WARNING: Module required: rtext
+ Vector2 textSize = MeasureTextEx(font, text, fontSize, spacing);
// Create image to store text
imText = GenImageColor((int)imSize.x, (int)imSize.y, BLANK);
- for (int i = 0; i < size; i++)
+ for (int i = 0; i < size;)
{
// Get next codepoint from byte string and glyph index in font
int codepointByteCount = 0;
int codepoint = GetCodepointNext(&text[i], &codepointByteCount); // WARNING: Module required: rtext
int index = GetGlyphIndex(font, codepoint); // WARNING: Module required: rtext
- // NOTE: Normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
- // but we need to draw all of the bad bytes using the '?' symbol moving one byte
- if (codepoint == 0x3f) codepointByteCount = 1;
-
if (codepoint == '\n')
{
// NOTE: Fixed line spacing of 1.5 line-height
@@ -1358,17 +1516,17 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
else textOffsetX += font.glyphs[index].advanceX + (int)spacing;
}
- i += (codepointByteCount - 1); // Move text bytes counter to next codepoint
+ i += codepointByteCount; // Move text bytes counter to next codepoint
}
// Scale image depending on text size
- if (fontSize > imSize.y)
+ if (textSize.y != imSize.y)
{
- float scaleFactor = fontSize/imSize.y;
+ float scaleFactor = textSize.y / imSize.y;
TRACELOG(LOG_INFO, "IMAGE: Text scaled by factor: %f", scaleFactor);
// Using nearest-neighbor scaling algorithm for default font
- // WARNING: Module required: rtext
+ // TODO: Allow defining the preferred scaling mechanism externally
if (font.texture.id == GetFontDefault().texture.id) ImageResizeNN(&imText, (int)(imSize.x*scaleFactor), (int)(imSize.y*scaleFactor));
else ImageResize(&imText, (int)(imSize.x*scaleFactor), (int)(imSize.y*scaleFactor));
}
@@ -1379,8 +1537,174 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
return imText;
}
+// Resize and image to new size using Nearest-Neighbor scaling algorithm
+void ImageResizeNN(Image *image,int newWidth,int newHeight)
+{
+ // Security check to avoid program crash
+ if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
+
+ Color *pixels = LoadImageColors(*image);
+ Color *output = (Color *)RL_MALLOC(newWidth*newHeight*sizeof(Color));
+
+ // EDIT: added +1 to account for an early rounding problem
+ int xRatio = (int)((image->width << 16)/newWidth) + 1;
+ int yRatio = (int)((image->height << 16)/newHeight) + 1;
+
+ int x2, y2;
+ for (int y = 0; y < newHeight; y++)
+ {
+ for (int x = 0; x < newWidth; x++)
+ {
+ x2 = ((x*xRatio) >> 16);
+ y2 = ((y*yRatio) >> 16);
+
+ output[(y*newWidth) + x] = pixels[(y2*image->width) + x2] ;
+ }
+ }
+
+ int format = image->format;
+
+ RL_FREE(image->data);
+
+ image->data = output;
+ image->width = newWidth;
+ image->height = newHeight;
+ image->format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
+
+ ImageFormat(image, format); // Reformat 32bit RGBA image to original format
+
+ UnloadImageColors(pixels);
+}
+
+
+// Resize and image to new size
+// NOTE: Uses stb default scaling filters (both bicubic):
+// STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_CATMULLROM
+// STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_MITCHELL (high-quality Catmull-Rom)
+void ImageResize(Image *image, int newWidth, int newHeight)
+{
+ // Security check to avoid program crash
+ if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
+
+ // Check if we can use a fast path on image scaling
+ // It can be for 8 bit per channel images with 1 to 4 channels per pixel
+ if ((image->format == PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) ||
+ (image->format == PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) ||
+ (image->format == PIXELFORMAT_UNCOMPRESSED_R8G8B8) ||
+ (image->format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8))
+ {
+ int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
+ unsigned char *output = (unsigned char *)RL_MALLOC(newWidth*newHeight*bytesPerPixel);
+
+ switch (image->format)
+ {
+ case PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: stbir_resize_uint8((unsigned char *)image->data, image->width, image->height, 0, output, newWidth, newHeight, 0, 1); break;
+ case PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: stbir_resize_uint8((unsigned char *)image->data, image->width, image->height, 0, output, newWidth, newHeight, 0, 2); break;
+ case PIXELFORMAT_UNCOMPRESSED_R8G8B8: stbir_resize_uint8((unsigned char *)image->data, image->width, image->height, 0, output, newWidth, newHeight, 0, 3); break;
+ case PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: stbir_resize_uint8((unsigned char *)image->data, image->width, image->height, 0, output, newWidth, newHeight, 0, 4); break;
+ default: break;
+ }
+
+ RL_FREE(image->data);
+ image->data = output;
+ image->width = newWidth;
+ image->height = newHeight;
+ }
+ else
+ {
+ // Get data as Color pixels array to work with it
+ Color *pixels = LoadImageColors(*image);
+ Color *output = (Color *)RL_MALLOC(newWidth*newHeight*sizeof(Color));
+
+ // NOTE: Color data is cast to (unsigned char *), there shouldn't been any problem...
+ stbir_resize_uint8((unsigned char *)pixels, image->width, image->height, 0, (unsigned char *)output, newWidth, newHeight, 0, 4);
+
+ int format = image->format;
+
+ UnloadImageColors(pixels);
+ RL_FREE(image->data);
+
+ image->data = output;
+ image->width = newWidth;
+ image->height = newHeight;
+ image->format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
+
+ ImageFormat(image, format); // Reformat 32bit RGBA image to original format
+ }
+}
+
+// Resize canvas and fill with color
+// NOTE: Resize offset is relative to the top-left corner of the original image
+void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill)
+{
+ // Security check to avoid program crash
+ if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
+
+ if (image->mipmaps > 1) TRACELOG(LOG_WARNING, "Image manipulation only applied to base mipmap level");
+ if (image->format >= PIXELFORMAT_COMPRESSED_DXT1_RGB) TRACELOG(LOG_WARNING, "Image manipulation not supported for compressed formats");
+ else if ((newWidth != image->width) || (newHeight != image->height))
+ {
+ Rectangle srcRec = { 0, 0, (float)image->width, (float)image->height };
+ Vector2 dstPos = { (float)offsetX, (float)offsetY };
+
+ if (offsetX < 0)
+ {
+ srcRec.x = (float)-offsetX;
+ srcRec.width += (float)offsetX;
+ dstPos.x = 0;
+ }
+ else if ((offsetX + image->width) > newWidth) srcRec.width = (float)(newWidth - offsetX);
+
+ if (offsetY < 0)
+ {
+ srcRec.y = (float)-offsetY;
+ srcRec.height += (float)offsetY;
+ dstPos.y = 0;
+ }
+ else if ((offsetY + image->height) > newHeight) srcRec.height = (float)(newHeight - offsetY);
+
+ if (newWidth < srcRec.width) srcRec.width = (float)newWidth;
+ if (newHeight < srcRec.height) srcRec.height = (float)newHeight;
+
+ int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
+ unsigned char *resizedData = (unsigned char *)RL_CALLOC(newWidth*newHeight*bytesPerPixel, 1);
+
+ // TODO: Fill resized canvas with fill color (must be formatted to image->format)
+
+ int dstOffsetSize = ((int)dstPos.y*newWidth + (int)dstPos.x)*bytesPerPixel;
+
+ for (int y = 0; y < (int)srcRec.height; y++)
+ {
+ memcpy(resizedData + dstOffsetSize, ((unsigned char *)image->data) + ((y + (int)srcRec.y)*image->width + (int)srcRec.x)*bytesPerPixel, (int)srcRec.width*bytesPerPixel);
+ dstOffsetSize += (newWidth*bytesPerPixel);
+ }
+
+ RL_FREE(image->data);
+ image->data = resizedData;
+ image->width = newWidth;
+ image->height = newHeight;
+ }
+}
+
+#if defined(SUPPORT_IMAGE_MANIPULATION)
+// Convert image to POT (power-of-two)
+// NOTE: It could be useful on OpenGL ES 2.0 (RPI, HTML5)
+void ImageToPOT(Image *image, Color fill)
+{
+ // Security check to avoid program crash
+ if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
+
+ // Calculate next power-of-two values
+ // NOTE: Just add the required amount of pixels at the right and bottom sides of image...
+ int potWidth = (int)powf(2, ceilf(logf((float)image->width)/logf(2)));
+ int potHeight = (int)powf(2, ceilf(logf((float)image->height)/logf(2)));
+
+ // Check if POT texture generation is required (if texture is not already POT)
+ if ((potWidth != image->width) || (potHeight != image->height)) ImageResizeCanvas(image, potWidth, potHeight, 0, 0, fill);
+}
+
// Crop image depending on alpha value
-// NOTE: Threshold is defined as a percentatge: 0.0f -> 1.0f
+// NOTE: Threshold is defined as a percentage: 0.0f -> 1.0f
void ImageAlphaCrop(Image *image, float threshold)
{
// Security check to avoid program crash
@@ -1478,6 +1802,19 @@ void ImageAlphaClear(Image *image, Color color, float threshold)
}
}
} break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
+ {
+ for (int i = 3; i < image->width*image->height*4; i += 4)
+ {
+ if (HalfToFloat(((unsigned short *)image->data)[i]) <= threshold)
+ {
+ ((unsigned short *)image->data)[i - 3] = FloatToHalf((float)color.r/255.0f);
+ ((unsigned short *)image->data)[i - 2] = FloatToHalf((float)color.g/255.0f);
+ ((unsigned short *)image->data)[i - 1] = FloatToHalf((float)color.b/255.0f);
+ ((unsigned short *)image->data)[i] = FloatToHalf((float)color.a/255.0f);
+ }
+ }
+ } break;
default: break;
}
}
@@ -1569,152 +1906,156 @@ void ImageAlphaPremultiply(Image *image)
ImageFormat(image, format);
}
-// Resize and image to new size
-// NOTE: Uses stb default scaling filters (both bicubic):
-// STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_CATMULLROM
-// STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_MITCHELL (high-quality Catmull-Rom)
-void ImageResize(Image *image, int newWidth, int newHeight)
-{
+// Apply box blur
+void ImageBlurGaussian(Image *image, int blurSize) {
// Security check to avoid program crash
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
- // Check if we can use a fast path on image scaling
- // It can be for 8 bit per channel images with 1 to 4 channels per pixel
- if ((image->format == PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) ||
- (image->format == PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) ||
- (image->format == PIXELFORMAT_UNCOMPRESSED_R8G8B8) ||
- (image->format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8))
- {
- int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
- unsigned char *output = (unsigned char *)RL_MALLOC(newWidth*newHeight*bytesPerPixel);
-
- switch (image->format)
- {
- case PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: stbir_resize_uint8((unsigned char *)image->data, image->width, image->height, 0, output, newWidth, newHeight, 0, 1); break;
- case PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: stbir_resize_uint8((unsigned char *)image->data, image->width, image->height, 0, output, newWidth, newHeight, 0, 2); break;
- case PIXELFORMAT_UNCOMPRESSED_R8G8B8: stbir_resize_uint8((unsigned char *)image->data, image->width, image->height, 0, output, newWidth, newHeight, 0, 3); break;
- case PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: stbir_resize_uint8((unsigned char *)image->data, image->width, image->height, 0, output, newWidth, newHeight, 0, 4); break;
- default: break;
- }
-
- RL_FREE(image->data);
- image->data = output;
- image->width = newWidth;
- image->height = newHeight;
- }
- else
- {
- // Get data as Color pixels array to work with it
- Color *pixels = LoadImageColors(*image);
- Color *output = (Color *)RL_MALLOC(newWidth*newHeight*sizeof(Color));
-
- // NOTE: Color data is casted to (unsigned char *), there shouldn't been any problem...
- stbir_resize_uint8((unsigned char *)pixels, image->width, image->height, 0, (unsigned char *)output, newWidth, newHeight, 0, 4);
-
- int format = image->format;
-
- UnloadImageColors(pixels);
- RL_FREE(image->data);
-
- image->data = output;
- image->width = newWidth;
- image->height = newHeight;
- image->format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
-
- ImageFormat(image, format); // Reformat 32bit RGBA image to original format
- }
-}
-
-// Resize and image to new size using Nearest-Neighbor scaling algorithm
-void ImageResizeNN(Image *image,int newWidth,int newHeight)
-{
- // Security check to avoid program crash
- if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
+ ImageAlphaPremultiply(image);
Color *pixels = LoadImageColors(*image);
- Color *output = (Color *)RL_MALLOC(newWidth*newHeight*sizeof(Color));
- // EDIT: added +1 to account for an early rounding problem
- int xRatio = (int)((image->width << 16)/newWidth) + 1;
- int yRatio = (int)((image->height << 16)/newHeight) + 1;
+ // Loop switches between pixelsCopy1 and pixelsCopy2
+ Vector4 *pixelsCopy1 = RL_MALLOC((image->height)*(image->width)*sizeof(Vector4));
+ Vector4 *pixelsCopy2 = RL_MALLOC((image->height)*(image->width)*sizeof(Vector4));
- int x2, y2;
- for (int y = 0; y < newHeight; y++)
- {
- for (int x = 0; x < newWidth; x++)
+ for (int i = 0; i < (image->height)*(image->width); i++) {
+ pixelsCopy1[i].x = pixels[i].r;
+ pixelsCopy1[i].y = pixels[i].g;
+ pixelsCopy1[i].z = pixels[i].b;
+ pixelsCopy1[i].w = pixels[i].a;
+ }
+
+ // Repeated convolution of rectangular window signal by itself converges to a gaussian distribution
+ for (int j = 0; j < GAUSSIAN_BLUR_ITERATIONS; j++) {
+ // Horizontal motion blur
+ for (int row = 0; row < image->height; row++)
{
- x2 = ((x*xRatio) >> 16);
- y2 = ((y*yRatio) >> 16);
+ float avgR = 0.0f;
+ float avgG = 0.0f;
+ float avgB = 0.0f;
+ float avgAlpha = 0.0f;
+ int convolutionSize = blurSize+1;
- output[(y*newWidth) + x] = pixels[(y2*image->width) + x2] ;
+ for (int i = 0; i < blurSize+1; i++)
+ {
+ avgR += pixelsCopy1[row*image->width + i].x;
+ avgG += pixelsCopy1[row*image->width + i].y;
+ avgB += pixelsCopy1[row*image->width + i].z;
+ avgAlpha += pixelsCopy1[row*image->width + i].w;
+ }
+
+ pixelsCopy2[row*image->width].x = avgR/convolutionSize;
+ pixelsCopy2[row*image->width].y = avgG/convolutionSize;
+ pixelsCopy2[row*image->width].z = avgB/convolutionSize;
+ pixelsCopy2[row*image->width].w = avgAlpha/convolutionSize;
+
+ for (int x = 1; x < image->width; x++)
+ {
+ if (x-blurSize >= 0)
+ {
+ avgR -= pixelsCopy1[row*image->width + x-blurSize].x;
+ avgG -= pixelsCopy1[row*image->width + x-blurSize].y;
+ avgB -= pixelsCopy1[row*image->width + x-blurSize].z;
+ avgAlpha -= pixelsCopy1[row*image->width + x-blurSize].w;
+ convolutionSize--;
+ }
+
+ if (x+blurSize < image->width)
+ {
+ avgR += pixelsCopy1[row*image->width + x+blurSize].x;
+ avgG += pixelsCopy1[row*image->width + x+blurSize].y;
+ avgB += pixelsCopy1[row*image->width + x+blurSize].z;
+ avgAlpha += pixelsCopy1[row*image->width + x+blurSize].w;
+ convolutionSize++;
+ }
+
+ pixelsCopy2[row*image->width + x].x = avgR/convolutionSize;
+ pixelsCopy2[row*image->width + x].y = avgG/convolutionSize;
+ pixelsCopy2[row*image->width + x].z = avgB/convolutionSize;
+ pixelsCopy2[row*image->width + x].w = avgAlpha/convolutionSize;
+ }
+ }
+
+ // Vertical motion blur
+ for (int col = 0; col < image->width; col++)
+ {
+ float avgR = 0.0f;
+ float avgG = 0.0f;
+ float avgB = 0.0f;
+ float avgAlpha = 0.0f;
+ int convolutionSize = blurSize+1;
+
+ for (int i = 0; i < blurSize+1; i++)
+ {
+ avgR += pixelsCopy2[i*image->width + col].x;
+ avgG += pixelsCopy2[i*image->width + col].y;
+ avgB += pixelsCopy2[i*image->width + col].z;
+ avgAlpha += pixelsCopy2[i*image->width + col].w;
+ }
+
+ pixelsCopy1[col].x = (unsigned char) (avgR/convolutionSize);
+ pixelsCopy1[col].y = (unsigned char) (avgG/convolutionSize);
+ pixelsCopy1[col].z = (unsigned char) (avgB/convolutionSize);
+ pixelsCopy1[col].w = (unsigned char) (avgAlpha/convolutionSize);
+
+ for (int y = 1; y < image->height; y++)
+ {
+ if (y-blurSize >= 0)
+ {
+ avgR -= pixelsCopy2[(y-blurSize)*image->width + col].x;
+ avgG -= pixelsCopy2[(y-blurSize)*image->width + col].y;
+ avgB -= pixelsCopy2[(y-blurSize)*image->width + col].z;
+ avgAlpha -= pixelsCopy2[(y-blurSize)*image->width + col].w;
+ convolutionSize--;
+ }
+ if (y+blurSize < image->height)
+ {
+ avgR += pixelsCopy2[(y+blurSize)*image->width + col].x;
+ avgG += pixelsCopy2[(y+blurSize)*image->width + col].y;
+ avgB += pixelsCopy2[(y+blurSize)*image->width + col].z;
+ avgAlpha += pixelsCopy2[(y+blurSize)*image->width + col].w;
+ convolutionSize++;
+ }
+
+ pixelsCopy1[y*image->width + col].x = (unsigned char) (avgR/convolutionSize);
+ pixelsCopy1[y*image->width + col].y = (unsigned char) (avgG/convolutionSize);
+ pixelsCopy1[y*image->width + col].z = (unsigned char) (avgB/convolutionSize);
+ pixelsCopy1[y*image->width + col].w = (unsigned char) (avgAlpha/convolutionSize);
+ }
+ }
+ }
+
+
+ // Reverse premultiply
+ for (int i = 0; i < (image->width)*(image->height); i++)
+ {
+ if (pixelsCopy1[i].w == 0.0f)
+ {
+ pixels[i].r = 0;
+ pixels[i].g = 0;
+ pixels[i].b = 0;
+ pixels[i].a = 0;
+ }
+ else if (pixelsCopy1[i].w <= 255.0f)
+ {
+ float alpha = (float)pixelsCopy1[i].w/255.0f;
+ pixels[i].r = (unsigned char)((float)pixelsCopy1[i].x/alpha);
+ pixels[i].g = (unsigned char)((float)pixelsCopy1[i].y/alpha);
+ pixels[i].b = (unsigned char)((float)pixelsCopy1[i].z/alpha);
+ pixels[i].a = (unsigned char) pixelsCopy1[i].w;
}
}
int format = image->format;
-
RL_FREE(image->data);
+ RL_FREE(pixelsCopy1);
+ RL_FREE(pixelsCopy2);
- image->data = output;
- image->width = newWidth;
- image->height = newHeight;
+ image->data = pixels;
image->format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
- ImageFormat(image, format); // Reformat 32bit RGBA image to original format
-
- UnloadImageColors(pixels);
-}
-
-// Resize canvas and fill with color
-// NOTE: Resize offset is relative to the top-left corner of the original image
-void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill)
-{
- // Security check to avoid program crash
- if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
-
- if (image->mipmaps > 1) TRACELOG(LOG_WARNING, "Image manipulation only applied to base mipmap level");
- if (image->format >= PIXELFORMAT_COMPRESSED_DXT1_RGB) TRACELOG(LOG_WARNING, "Image manipulation not supported for compressed formats");
- else if ((newWidth != image->width) || (newHeight != image->height))
- {
- Rectangle srcRec = { 0, 0, (float)image->width, (float)image->height };
- Vector2 dstPos = { (float)offsetX, (float)offsetY };
-
- if (offsetX < 0)
- {
- srcRec.x = (float)-offsetX;
- srcRec.width += (float)offsetX;
- dstPos.x = 0;
- }
- else if ((offsetX + image->width) > newWidth) srcRec.width = (float)(newWidth - offsetX);
-
- if (offsetY < 0)
- {
- srcRec.y = (float)-offsetY;
- srcRec.height += (float)offsetY;
- dstPos.y = 0;
- }
- else if ((offsetY + image->height) > newHeight) srcRec.height = (float)(newHeight - offsetY);
-
- if (newWidth < srcRec.width) srcRec.width = (float)newWidth;
- if (newHeight < srcRec.height) srcRec.height = (float)newHeight;
-
- int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
- unsigned char *resizedData = (unsigned char *)RL_CALLOC(newWidth*newHeight*bytesPerPixel, 1);
-
- // TODO: Fill resized canvas with fill color (must be formatted to image->format)
-
- int dstOffsetSize = ((int)dstPos.y*newWidth + (int)dstPos.x)*bytesPerPixel;
-
- for (int y = 0; y < (int)srcRec.height; y++)
- {
- memcpy(resizedData + dstOffsetSize, ((unsigned char *)image->data) + ((y + (int)srcRec.y)*image->width + (int)srcRec.x)*bytesPerPixel, (int)srcRec.width*bytesPerPixel);
- dstOffsetSize += (newWidth*bytesPerPixel);
- }
-
- RL_FREE(image->data);
- image->data = resizedData;
- image->width = newWidth;
- image->height = newHeight;
- }
+ ImageFormat(image, format);
}
// Generate all mipmap levels for a provided image
@@ -1788,7 +2129,7 @@ void ImageMipmaps(Image *image)
}
// Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
-// NOTE: In case selected bpp do not represent an known 16bit format,
+// NOTE: In case selected bpp do not represent a known 16bit format,
// dithered data is stored in the LSB part of the unsigned short
void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
{
@@ -1940,7 +2281,7 @@ void ImageFlipHorizontal(Image *image)
{
for (int x = 0; x < image->width; x++)
{
- // OPTION 1: Move pixels with memcopy()
+ // OPTION 1: Move pixels with memcpy()
//memcpy(flippedData + (y*image->width + x)*bytesPerPixel, ((unsigned char *)image->data) + (y*image->width + (image->width - 1 - x))*bytesPerPixel, bytesPerPixel);
// OPTION 2: Just copy data pixel by pixel
@@ -1968,6 +2309,65 @@ void ImageFlipHorizontal(Image *image)
}
}
+// Rotate image in degrees
+void ImageRotate(Image *image, int degrees)
+{
+ // Security check to avoid program crash
+ if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
+
+ if (image->mipmaps > 1) TRACELOG(LOG_WARNING, "Image manipulation only applied to base mipmap level");
+ if (image->format >= PIXELFORMAT_COMPRESSED_DXT1_RGB) TRACELOG(LOG_WARNING, "Image manipulation not supported for compressed formats");
+ else
+ {
+ float rad = degrees*PI/180.0f;
+ float sinRadius = sinf(rad);
+ float cosRadius = cosf(rad);
+
+ int width = (int)(fabsf(image->width*cosRadius) + fabsf(image->height*sinRadius));
+ int height = (int)(fabsf(image->height*cosRadius) + fabsf(image->width*sinRadius));
+
+ int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
+ unsigned char *rotatedData = (unsigned char *)RL_CALLOC(width*height, bytesPerPixel);
+
+ for (int y = 0; y < height; y++)
+ {
+ for (int x = 0; x < width; x++)
+ {
+ float oldX = ((x - width/2.0f)*cosRadius + (y - height/2.0f)*sinRadius) + image->width/2.0f;
+ float oldY = ((y - height/2.0f)*cosRadius - (x - width/2.0f)*sinRadius) + image->height/2.0f;
+
+ if ((oldX >= 0) && (oldX < image->width) && (oldY >= 0) && (oldY < image->height))
+ {
+ int x1 = (int)floorf(oldX);
+ int y1 = (int)floorf(oldY);
+ int x2 = MIN(x1 + 1, image->width - 1);
+ int y2 = MIN(y1 + 1, image->height - 1);
+
+ float px = oldX - x1;
+ float py = oldY - y1;
+
+ for (int i = 0; i < bytesPerPixel; i++)
+ {
+ float f1 = ((unsigned char *)image->data)[(y1*image->width + x1)*bytesPerPixel + i];
+ float f2 = ((unsigned char *)image->data)[(y1*image->width + x2)*bytesPerPixel + i];
+ float f3 = ((unsigned char *)image->data)[(y2*image->width + x1)*bytesPerPixel + i];
+ float f4 = ((unsigned char *)image->data)[(y2*image->width + x2)*bytesPerPixel + i];
+
+ float val = f1*(1 - px)*(1 - py) + f2*px*(1 - py) + f3*(1 - px)*py + f4*px*py;
+
+ rotatedData[(y*width + x)*bytesPerPixel + i] = (unsigned char)val;
+ }
+ }
+ }
+ }
+
+ RL_FREE(image->data);
+ image->data = rotatedData;
+ image->width = width;
+ image->height = height;
+ }
+}
+
// Rotate image clockwise 90deg
void ImageRotateCW(Image *image)
{
@@ -2256,6 +2656,10 @@ Color *LoadImageColors(Image image)
(image.format == PIXELFORMAT_UNCOMPRESSED_R32G32B32) ||
(image.format == PIXELFORMAT_UNCOMPRESSED_R32G32B32A32)) TRACELOG(LOG_WARNING, "IMAGE: Pixel format converted from 32bit to 8bit per channel");
+ if ((image.format == PIXELFORMAT_UNCOMPRESSED_R16) ||
+ (image.format == PIXELFORMAT_UNCOMPRESSED_R16G16B16) ||
+ (image.format == PIXELFORMAT_UNCOMPRESSED_R16G16B16A16)) TRACELOG(LOG_WARNING, "IMAGE: Pixel format converted from 16bit to 8bit per channel");
+
for (int i = 0, k = 0; i < image.width*image.height; i++)
{
switch (image.format)
@@ -2351,6 +2755,32 @@ Color *LoadImageColors(Image image)
k += 4;
} break;
+ case PIXELFORMAT_UNCOMPRESSED_R16:
+ {
+ pixels[i].r = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[k])*255.0f);
+ pixels[i].g = 0;
+ pixels[i].b = 0;
+ pixels[i].a = 255;
+
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16:
+ {
+ pixels[i].r = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[k])*255.0f);
+ pixels[i].g = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[k + 1])*255.0f);
+ pixels[i].b = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[k + 2])*255.0f);
+ pixels[i].a = 255;
+
+ k += 3;
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
+ {
+ pixels[i].r = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[k])*255.0f);
+ pixels[i].g = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[k])*255.0f);
+ pixels[i].b = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[k])*255.0f);
+ pixels[i].a = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[k])*255.0f);
+
+ k += 4;
+ } break;
default: break;
}
}
@@ -2428,7 +2858,7 @@ void UnloadImagePalette(Color *colors)
}
// Get image alpha border rectangle
-// NOTE: Threshold is defined as a percentatge: 0.0f -> 1.0f
+// NOTE: Threshold is defined as a percentage: 0.0f -> 1.0f
Rectangle GetImageAlphaBorder(Image image, float threshold)
{
Rectangle crop = { 0 };
@@ -2562,6 +2992,30 @@ Color GetImageColor(Image image, int x, int y)
color.b = (unsigned char)(((float *)image.data)[(y*image.width + x)*4]*255.0f);
color.a = (unsigned char)(((float *)image.data)[(y*image.width + x)*4]*255.0f);
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16:
+ {
+ color.r = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[y*image.width + x])*255.0f);
+ color.g = 0;
+ color.b = 0;
+ color.a = 255;
+
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16:
+ {
+ color.r = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[(y*image.width + x)*3])*255.0f);
+ color.g = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[(y*image.width + x)*3 + 1])*255.0f);
+ color.b = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[(y*image.width + x)*3 + 2])*255.0f);
+ color.a = 255;
+
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
+ {
+ color.r = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[(y*image.width + x)*4])*255.0f);
+ color.g = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[(y*image.width + x)*4])*255.0f);
+ color.b = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[(y*image.width + x)*4])*255.0f);
+ color.a = (unsigned char)(HalfToFloat(((unsigned short *)image.data)[(y*image.width + x)*4])*255.0f);
+
} break;
default: TRACELOG(LOG_WARNING, "Compressed image format does not support color reading"); break;
}
@@ -2587,9 +3041,9 @@ void ImageClearBackground(Image *dst, Color color)
int bytesPerPixel = GetPixelDataSize(1, 1, dst->format);
// Repeat the first pixel data throughout the image
- for (int i = 1; i < dst->width * dst->height; i++)
+ for (int i = 1; i < dst->width*dst->height; i++)
{
- memcpy(pSrcPixel + i * bytesPerPixel, pSrcPixel, bytesPerPixel);
+ memcpy(pSrcPixel + i*bytesPerPixel, pSrcPixel, bytesPerPixel);
}
}
@@ -2701,6 +3155,34 @@ void ImageDrawPixel(Image *dst, int x, int y, Color color)
((float *)dst->data)[(y*dst->width + x)*4 + 2] = coln.z;
((float *)dst->data)[(y*dst->width + x)*4 + 3] = coln.w;
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16:
+ {
+ // NOTE: Calculate grayscale equivalent color (normalized to 32bit)
+ Vector3 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f };
+
+ ((unsigned short*)dst->data)[y*dst->width + x] = FloatToHalf(coln.x*0.299f + coln.y*0.587f + coln.z*0.114f);
+
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16:
+ {
+ // NOTE: Calculate R32G32B32 equivalent color (normalized to 32bit)
+ Vector3 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f };
+
+ ((unsigned short *)dst->data)[(y*dst->width + x)*3] = FloatToHalf(coln.x);
+ ((unsigned short *)dst->data)[(y*dst->width + x)*3 + 1] = FloatToHalf(coln.y);
+ ((unsigned short *)dst->data)[(y*dst->width + x)*3 + 2] = FloatToHalf(coln.z);
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
+ {
+ // NOTE: Calculate R32G32B32A32 equivalent color (normalized to 32bit)
+ Vector4 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f, (float)color.a/255.0f };
+
+ ((unsigned short *)dst->data)[(y*dst->width + x)*4] = FloatToHalf(coln.x);
+ ((unsigned short *)dst->data)[(y*dst->width + x)*4 + 1] = FloatToHalf(coln.y);
+ ((unsigned short *)dst->data)[(y*dst->width + x)*4 + 2] = FloatToHalf(coln.z);
+ ((unsigned short *)dst->data)[(y*dst->width + x)*4 + 3] = FloatToHalf(coln.w);
+
} break;
default: break;
}
@@ -2828,7 +3310,7 @@ void ImageDrawCircle(Image* dst, int centerX, int centerY, int radius, Color col
{
y--;
decesionParameter = decesionParameter + 4*(x - y) + 10;
- }
+ }
else decesionParameter = decesionParameter + 4*x + 6;
}
}
@@ -2891,26 +3373,42 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
// Security check to avoid program crash
if ((dst->data == NULL) || (dst->width == 0) || (dst->height == 0)) return;
- int sy = (int)rec.y;
- int ey = sy + (int)rec.height;
+ // Security check to avoid drawing out of bounds in case of bad user data
+ if (rec.x < 0) { rec.width -= rec.x; rec.x = 0; }
+ if (rec.y < 0) { rec.height -= rec.y; rec.y = 0; }
+ if (rec.width < 0) rec.width = 0;
+ if (rec.height < 0) rec.height = 0;
+ // Clamp the size the the image bounds
+ if ((rec.x + rec.width) >= dst->width) rec.width = dst->width - rec.x;
+ if ((rec.y + rec.height) >= dst->height) rec.height = dst->height - rec.y;
+
+ // Check if the rect is even inside the image
+ if ((rec.x > dst->width) || (rec.y > dst->height)) return;
+ if (((rec.x + rec.width) < 0) || (rec.y + rec.height < 0)) return;
+
+ int sy = (int)rec.y;
int sx = (int)rec.x;
int bytesPerPixel = GetPixelDataSize(1, 1, dst->format);
- for (int y = sy; y < ey; y++)
+ // Fill in the first pixel of the first row based on image format
+ ImageDrawPixel(dst, sx, sy, color);
+
+ int bytesOffset = ((sy*dst->width) + sx)*bytesPerPixel;
+ unsigned char *pSrcPixel = (unsigned char *)dst->data + bytesOffset;
+
+ // Repeat the first pixel data throughout the row
+ for (int x = 1; x < (int)rec.width; x++)
{
- // Fill in the first pixel of the row based on image format
- ImageDrawPixel(dst, sx, y, color);
+ memcpy(pSrcPixel + x*bytesPerPixel, pSrcPixel, bytesPerPixel);
+ }
- int bytesOffset = ((y * dst->width) + sx) * bytesPerPixel;
- unsigned char *pSrcPixel = (unsigned char *)dst->data + bytesOffset;
-
- // Repeat the first pixel data throughout the row
- for (int x = 1; x < (int)rec.width; x++)
- {
- memcpy(pSrcPixel + x * bytesPerPixel, pSrcPixel, bytesPerPixel);
- }
+ // Repeat the first row data for all other rows
+ int bytesPerRow = bytesPerPixel * (int)rec.width;
+ for (int y = 1; y < (int)rec.height; y++)
+ {
+ memcpy(pSrcPixel + (y*dst->width)*bytesPerPixel, pSrcPixel, bytesPerRow);
}
}
@@ -2946,7 +3444,7 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
if ((srcRec.y + srcRec.height) > src.height) srcRec.height = src.height - srcRec.y;
// Check if source rectangle needs to be resized to destination rectangle
- // In that case, we make a copy of source and we apply all required transform
+ // In that case, we make a copy of source, and we apply all required transform
if (((int)srcRec.width != (int)dstRec.width) || ((int)srcRec.height != (int)dstRec.height))
{
srcMod = ImageFromImage(src, srcRec); // Create image from another image
@@ -2989,7 +3487,7 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
// [-] GetPixelColor(): Get Vector4 instead of Color, easier for ColorAlphaBlend()
// [ ] Support f32bit channels drawing
- // TODO: Support PIXELFORMAT_UNCOMPRESSED_R32, PIXELFORMAT_UNCOMPRESSED_R32G32B32, PIXELFORMAT_UNCOMPRESSED_R32G32B32A32
+ // TODO: Support PIXELFORMAT_UNCOMPRESSED_R32, PIXELFORMAT_UNCOMPRESSED_R32G32B32, PIXELFORMAT_UNCOMPRESSED_R32G32B32A32 and 16-bit equivalents
Color colSrc, colDst, blend;
bool blendRequired = true;
@@ -3043,9 +3541,11 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color)
{
#if defined(SUPPORT_MODULE_RTEXT)
+ // Make sure default font is loaded to be used on image text drawing
+ if (GetFontDefault().texture.id == 0) LoadFontDefault();
+
Vector2 position = { (float)posX, (float)posY };
- // NOTE: For default font, spacing is set to desired font size / default font size (10)
- ImageDrawTextEx(dst, GetFontDefault(), text, position, (float)fontSize, (float)fontSize/10, color); // WARNING: Module required: rtext
+ ImageDrawTextEx(dst, GetFontDefault(), text, position, (float)fontSize, 1.0f, color); // WARNING: Module required: rtext
#else
TRACELOG(LOG_WARNING, "IMAGE: ImageDrawText() requires module: rtext");
#endif
@@ -3122,10 +3622,16 @@ TextureCubemap LoadTextureCubemap(Image image, int layout)
if ((image.height/6) == image.width) { layout = CUBEMAP_LAYOUT_LINE_VERTICAL; cubemap.width = image.height/6; }
else if ((image.width/3) == (image.height/4)) { layout = CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR; cubemap.width = image.width/3; }
}
-
- cubemap.height = cubemap.width;
+ } else {
+ if (layout == CUBEMAP_LAYOUT_LINE_VERTICAL) cubemap.width = image.height/6;
+ if (layout == CUBEMAP_LAYOUT_LINE_HORIZONTAL) cubemap.width = image.width/6;
+ if (layout == CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR) cubemap.width = image.width/3;
+ if (layout == CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE) cubemap.width = image.width/4;
+ if (layout == CUBEMAP_LAYOUT_PANORAMA) cubemap.width = image.width/4;
}
+ cubemap.height = cubemap.width;
+
// Layout provided or already auto-detected
if (layout != CUBEMAP_LAYOUT_AUTO_DETECT)
{
@@ -3170,7 +3676,7 @@ TextureCubemap LoadTextureCubemap(Image image, int layout)
faces = GenImageColor(size, size*6, MAGENTA);
ImageFormat(&faces, image.format);
- // NOTE: Image formating does not work with compressed textures
+ // NOTE: Image formatting does not work with compressed textures
for (int i = 0; i < 6; i++) ImageDraw(&faces, image, faceRecs[i], (Rectangle){ 0, (float)size*i, (float)size, (float)size }, WHITE);
}
@@ -3227,6 +3733,18 @@ RenderTexture2D LoadRenderTexture(int width, int height)
return target;
}
+// Check if a texture is ready
+bool IsTextureReady(Texture2D texture)
+{
+ // TODO: Validate maximum texture size supported by GPU?
+
+ return ((texture.id > 0) && // Validate OpenGL id
+ (texture.width > 0) &&
+ (texture.height > 0) && // Validate texture size
+ (texture.format > 0) && // Validate texture pixel format
+ (texture.mipmaps > 0)); // Validate texture mipmaps (at least 1 for basic mipmap level)
+}
+
// Unload texture from GPU memory (VRAM)
void UnloadTexture(Texture2D texture)
{
@@ -3238,6 +3756,14 @@ void UnloadTexture(Texture2D texture)
}
}
+// Check if a render texture is ready
+bool IsRenderTextureReady(RenderTexture2D target)
+{
+ return ((target.id > 0) && // Validate OpenGL id
+ IsTextureReady(target.depth) && // Validate FBO depth texture/renderbuffer
+ IsTextureReady(target.texture)); // Validate FBO texture
+}
+
// Unload render texture from GPU memory (VRAM)
void UnloadRenderTexture(RenderTexture2D target)
{
@@ -3491,7 +4017,7 @@ void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2
// NOTE: Vertex position can be transformed using matrices
// but the process is way more costly than just calculating
// the vertex positions manually, like done above.
- // I leave here the old implementation for educational pourposes,
+ // I leave here the old implementation for educational purposes,
// just in case someone wants to do some performance test
/*
rlSetTexture(texture.id);
@@ -3530,104 +4056,6 @@ void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2
}
}
-// Draw texture quad with tiling and offset parameters
-// NOTE: Tiling and offset should be provided considering normalized texture values [0..1]
-// i.e tiling = { 1.0f, 1.0f } refers to all texture, offset = { 0.5f, 0.5f } moves texture origin to center
-void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint)
-{
- // WARNING: This solution only works if TEXTURE_WRAP_REPEAT is supported,
- // NPOT textures supported is required and OpenGL ES 2.0 could not support it
- Rectangle source = { offset.x*texture.width, offset.y*texture.height, tiling.x*texture.width, tiling.y*texture.height };
- Vector2 origin = { 0.0f, 0.0f };
-
- DrawTexturePro(texture, source, quad, origin, 0.0f, tint);
-}
-
-// Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.
-// NOTE: For tilling a whole texture DrawTextureQuad() is better
-void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint)
-{
- if ((texture.id <= 0) || (scale <= 0.0f)) return; // Wanna see a infinite loop?!...just delete this line!
- if ((source.width == 0) || (source.height == 0)) return;
-
- int tileWidth = (int)(source.width*scale), tileHeight = (int)(source.height*scale);
- if ((dest.width < tileWidth) && (dest.height < tileHeight))
- {
- // Can fit only one tile
- DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)dest.width/tileWidth)*source.width, ((float)dest.height/tileHeight)*source.height},
- (Rectangle){dest.x, dest.y, dest.width, dest.height}, origin, rotation, tint);
- }
- else if (dest.width <= tileWidth)
- {
- // Tiled vertically (one column)
- int dy = 0;
- for (;dy+tileHeight < dest.height; dy += tileHeight)
- {
- DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)dest.width/tileWidth)*source.width, source.height}, (Rectangle){dest.x, dest.y + dy, dest.width, (float)tileHeight}, origin, rotation, tint);
- }
-
- // Fit last tile
- if (dy < dest.height)
- {
- DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)dest.width/tileWidth)*source.width, ((float)(dest.height - dy)/tileHeight)*source.height},
- (Rectangle){dest.x, dest.y + dy, dest.width, dest.height - dy}, origin, rotation, tint);
- }
- }
- else if (dest.height <= tileHeight)
- {
- // Tiled horizontally (one row)
- int dx = 0;
- for (;dx+tileWidth < dest.width; dx += tileWidth)
- {
- DrawTexturePro(texture, (Rectangle){source.x, source.y, source.width, ((float)dest.height/tileHeight)*source.height}, (Rectangle){dest.x + dx, dest.y, (float)tileWidth, dest.height}, origin, rotation, tint);
- }
-
- // Fit last tile
- if (dx < dest.width)
- {
- DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)(dest.width - dx)/tileWidth)*source.width, ((float)dest.height/tileHeight)*source.height},
- (Rectangle){dest.x + dx, dest.y, dest.width - dx, dest.height}, origin, rotation, tint);
- }
- }
- else
- {
- // Tiled both horizontally and vertically (rows and columns)
- int dx = 0;
- for (;dx+tileWidth < dest.width; dx += tileWidth)
- {
- int dy = 0;
- for (;dy+tileHeight < dest.height; dy += tileHeight)
- {
- DrawTexturePro(texture, source, (Rectangle){dest.x + dx, dest.y + dy, (float)tileWidth, (float)tileHeight}, origin, rotation, tint);
- }
-
- if (dy < dest.height)
- {
- DrawTexturePro(texture, (Rectangle){source.x, source.y, source.width, ((float)(dest.height - dy)/tileHeight)*source.height},
- (Rectangle){dest.x + dx, dest.y + dy, (float)tileWidth, dest.height - dy}, origin, rotation, tint);
- }
- }
-
- // Fit last column of tiles
- if (dx < dest.width)
- {
- int dy = 0;
- for (;dy+tileHeight < dest.height; dy += tileHeight)
- {
- DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)(dest.width - dx)/tileWidth)*source.width, source.height},
- (Rectangle){dest.x + dx, dest.y + dy, dest.width - dx, (float)tileHeight}, origin, rotation, tint);
- }
-
- // Draw final tile in the bottom right corner
- if (dy < dest.height)
- {
- DrawTexturePro(texture, (Rectangle){source.x, source.y, ((float)(dest.width - dx)/tileWidth)*source.width, ((float)(dest.height - dy)/tileHeight)*source.height},
- (Rectangle){dest.x + dx, dest.y + dy, dest.width - dx, dest.height - dy}, origin, rotation, tint);
- }
- }
- }
-}
-
// Draws a texture (or part of it) that stretches or shrinks nicely using n-patch info
void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint)
{
@@ -3825,44 +4253,13 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest,
}
}
-// Draw textured polygon, defined by vertex and texturecoordinates
-// NOTE: Polygon center must have straight line path to all points
-// without crossing perimeter, points must be in anticlockwise order
-void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint)
-{
- rlSetTexture(texture.id);
-
- // Texturing is only supported on RL_QUADS
- rlBegin(RL_QUADS);
-
- rlColor4ub(tint.r, tint.g, tint.b, tint.a);
-
- for (int i = 0; i < pointCount - 1; i++)
- {
- rlTexCoord2f(0.5f, 0.5f);
- rlVertex2f(center.x, center.y);
-
- rlTexCoord2f(texcoords[i].x, texcoords[i].y);
- rlVertex2f(points[i].x + center.x, points[i].y + center.y);
-
- rlTexCoord2f(texcoords[i + 1].x, texcoords[i + 1].y);
- rlVertex2f(points[i + 1].x + center.x, points[i + 1].y + center.y);
-
- rlTexCoord2f(texcoords[i + 1].x, texcoords[i + 1].y);
- rlVertex2f(points[i + 1].x + center.x, points[i + 1].y + center.y);
- }
- rlEnd();
-
- rlSetTexture(0);
-}
-
// Get color with alpha applied, alpha goes from 0.0f to 1.0f
Color Fade(Color color, float alpha)
{
if (alpha < 0.0f) alpha = 0.0f;
else if (alpha > 1.0f) alpha = 1.0f;
- return (Color){color.r, color.g, color.b, (unsigned char)(255.0f*alpha)};
+ return (Color){ color.r, color.g, color.b, (unsigned char)(255.0f*alpha) };
}
// Get hexadecimal value for a Color
@@ -3985,6 +4382,105 @@ Color ColorFromHSV(float hue, float saturation, float value)
return color;
}
+// Get color multiplied with another color
+Color ColorTint(Color color, Color tint)
+{
+ Color result = color;
+
+ float cR = (float)tint.r/255;
+ float cG = (float)tint.g/255;
+ float cB = (float)tint.b/255;
+ float cA = (float)tint.a/255;
+
+ unsigned char r = (unsigned char)(((float)color.r/255*cR)*255.0f);
+ unsigned char g = (unsigned char)(((float)color.g/255*cG)*255.0f);
+ unsigned char b = (unsigned char)(((float)color.b/255*cB)*255.0f);
+ unsigned char a = (unsigned char)(((float)color.a/255*cA)*255.0f);
+
+ result.r = r;
+ result.g = g;
+ result.b = b;
+ result.a = a;
+
+ return result;
+}
+
+// Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
+Color ColorBrightness(Color color, float factor)
+{
+ Color result = color;
+
+ if (factor > 1.0f) factor = 1.0f;
+ else if (factor < -1.0f) factor = -1.0f;
+
+ float red = (float)color.r;
+ float green = (float)color.g;
+ float blue = (float)color.b;
+
+ if (factor < 0.0f)
+ {
+ factor = 1.0f + factor;
+ red *= factor;
+ green *= factor;
+ blue *= factor;
+ }
+ else
+ {
+ red = (255 - red)*factor + red;
+ green = (255 - green)*factor + green;
+ blue = (255 - blue)*factor + blue;
+ }
+
+ result.r = (unsigned char)red;
+ result.g = (unsigned char)green;
+ result.b = (unsigned char)blue;
+
+ return result;
+}
+
+// Get color with contrast correction
+// NOTE: Contrast values between -1.0f and 1.0f
+Color ColorContrast(Color color, float contrast)
+{
+ Color result = color;
+
+ if (contrast < -1.0f) contrast = -1.0f;
+ else if (contrast > 1.0f) contrast = 1.0f;
+
+ contrast = (1.0f + contrast);
+ contrast *= contrast;
+
+ float pR = (float)color.r/255.0f;
+ pR -= 0.5f;
+ pR *= contrast;
+ pR += 0.5f;
+ pR *= 255;
+ if (pR < 0) pR = 0;
+ else if (pR > 255) pR = 255;
+
+ float pG = (float)color.g/255.0f;
+ pG -= 0.5f;
+ pG *= contrast;
+ pG += 0.5f;
+ pG *= 255;
+ if (pG < 0) pG = 0;
+ else if (pG > 255) pG = 255;
+
+ float pB = (float)color.b/255.0f;
+ pB -= 0.5f;
+ pB *= contrast;
+ pB += 0.5f;
+ pB *= 255;
+ if (pB < 0) pB = 0;
+ else if (pB > 255) pB = 255;
+
+ result.r = (unsigned char)pR;
+ result.g = (unsigned char)pG;
+ result.b = (unsigned char)pB;
+
+ return result;
+}
+
// Get color with alpha applied, alpha goes from 0.0f to 1.0f
Color ColorAlpha(Color color, float alpha)
{
@@ -4123,6 +4619,33 @@ Color GetPixelColor(void *srcPtr, int format)
color.b = (unsigned char)(((float *)srcPtr)[2]*255.0f);
color.a = (unsigned char)(((float *)srcPtr)[3]*255.0f);
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16:
+ {
+ // NOTE: Pixel normalized float value is converted to [0..255]
+ color.r = (unsigned char)(HalfToFloat(((unsigned short *)srcPtr)[0])*255.0f);
+ color.g = (unsigned char)(HalfToFloat(((unsigned short *)srcPtr)[0])*255.0f);
+ color.b = (unsigned char)(HalfToFloat(((unsigned short *)srcPtr)[0])*255.0f);
+ color.a = 255;
+
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16:
+ {
+ // NOTE: Pixel normalized float value is converted to [0..255]
+ color.r = (unsigned char)(HalfToFloat(((unsigned short *)srcPtr)[0])*255.0f);
+ color.g = (unsigned char)(HalfToFloat(((unsigned short *)srcPtr)[1])*255.0f);
+ color.b = (unsigned char)(HalfToFloat(((unsigned short *)srcPtr)[2])*255.0f);
+ color.a = 255;
+
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
+ {
+ // NOTE: Pixel normalized float value is converted to [0..255]
+ color.r = (unsigned char)(HalfToFloat(((unsigned short *)srcPtr)[0])*255.0f);
+ color.g = (unsigned char)(HalfToFloat(((unsigned short *)srcPtr)[1])*255.0f);
+ color.b = (unsigned char)(HalfToFloat(((unsigned short *)srcPtr)[2])*255.0f);
+ color.a = (unsigned char)(HalfToFloat(((unsigned short *)srcPtr)[3])*255.0f);
+
} break;
default: break;
}
@@ -4230,6 +4753,9 @@ int GetPixelDataSize(int width, int height, int format)
case PIXELFORMAT_UNCOMPRESSED_R32: bpp = 32; break;
case PIXELFORMAT_UNCOMPRESSED_R32G32B32: bpp = 32*3; break;
case PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: bpp = 32*4; break;
+ case PIXELFORMAT_UNCOMPRESSED_R16: bpp = 16; break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16: bpp = 16*3; break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: bpp = 16*4; break;
case PIXELFORMAT_COMPRESSED_DXT1_RGB:
case PIXELFORMAT_COMPRESSED_DXT1_RGBA:
case PIXELFORMAT_COMPRESSED_ETC1_RGB:
@@ -4260,6 +4786,24 @@ int GetPixelDataSize(int width, int height, int format)
//----------------------------------------------------------------------------------
// Module specific Functions Definition
//----------------------------------------------------------------------------------
+// From https://stackoverflow.com/questions/1659440/32-bit-to-16-bit-floating-point-conversion/60047308#60047308
+
+static float HalfToFloat(unsigned short x) {
+ const unsigned int e = (x&0x7C00)>>10; // exponent
+ const unsigned int m = (x&0x03FF)<<13; // mantissa
+ const float fm = (float)m;
+ const unsigned int v = (*(unsigned int*)&fm)>>23; // evil log2 bit hack to count leading zeros in denormalized format
+ const unsigned int r = (x&0x8000)<<16 | (e!=0)*((e+112)<<23|m) | ((e==0)&(m!=0))*((v-37)<<23|((m<<(150-v))&0x007FE000)); // sign : normalized : denormalized
+ return *(float*)&r;
+}
+
+static unsigned short FloatToHalf(float x) {
+ const unsigned int b = (*(unsigned int*)&x)+0x00001000; // round-to-nearest-even: add last bit after truncated mantissa
+ const unsigned int e = (b&0x7F800000)>>23; // exponent
+ const unsigned int m = b&0x007FFFFF; // mantissa; in line below: 0x007FF000 = 0x00800000-0x00001000 = decimal indicator flag - initial rounding
+ return (b&0x80000000)>>16 | (e>112)*((((e-112)<<10)&0x7C00)|m>>13) | ((e<113)&(e>101))*((((0x007FF000+m)>>(125-e))+1)>>1) | (e>143)*0x7FFF; // sign : normalized : denormalized : saturate
+}
+
// Get pixel data from image as Vector4 array (float normalized)
static Vector4 *LoadImageDataNormalized(Image image)
{
@@ -4362,7 +4906,32 @@ static Vector4 *LoadImageDataNormalized(Image image)
pixels[i].w = ((float *)image.data)[k + 3];
k += 4;
- }
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16:
+ {
+ pixels[i].x = HalfToFloat(((unsigned short *)image.data)[k]);
+ pixels[i].y = 0.0f;
+ pixels[i].z = 0.0f;
+ pixels[i].w = 1.0f;
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16:
+ {
+ pixels[i].x = HalfToFloat(((unsigned short *)image.data)[k]);
+ pixels[i].y = HalfToFloat(((unsigned short *)image.data)[k + 1]);
+ pixels[i].z = HalfToFloat(((unsigned short *)image.data)[k + 2]);
+ pixels[i].w = 1.0f;
+
+ k += 3;
+ } break;
+ case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
+ {
+ pixels[i].x = HalfToFloat(((unsigned short *)image.data)[k]);
+ pixels[i].y = HalfToFloat(((unsigned short *)image.data)[k + 1]);
+ pixels[i].z = HalfToFloat(((unsigned short *)image.data)[k + 2]);
+ pixels[i].w = HalfToFloat(((unsigned short *)image.data)[k + 3]);
+
+ k += 4;
+ } break;
default: break;
}
}
diff --git a/src/shell.html b/src/shell.html
index 3ab8c3a30..b373394bb 100644
--- a/src/shell.html
+++ b/src/shell.html
@@ -1,5 +1,5 @@
-
+
diff --git a/src/utils.c b/src/utils.c
index 208a483a7..ac57a2157 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -3,15 +3,14 @@
* raylib.utils - Some common utility functions
*
* CONFIGURATION:
-*
-* #define SUPPORT_TRACELOG
-* Show TraceLog() output messages
-* NOTE: By default LOG_DEBUG traces not shown
+* #define SUPPORT_TRACELOG
+* Show TraceLog() output messages
+* NOTE: By default LOG_DEBUG traces not shown
*
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@@ -54,7 +53,7 @@
// Defines and Macros
//----------------------------------------------------------------------------------
#ifndef MAX_TRACELOG_MSG_LENGTH
- #define MAX_TRACELOG_MSG_LENGTH 128 // Max length of one trace-log message
+ #define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message
#endif
//----------------------------------------------------------------------------------
@@ -63,10 +62,10 @@
static int logTypeLevel = LOG_INFO; // Minimum log type level
static TraceLogCallback traceLog = NULL; // TraceLog callback function pointer
-static LoadFileDataCallback loadFileData = NULL; // LoadFileData callback funtion pointer
-static SaveFileDataCallback saveFileData = NULL; // SaveFileText callback funtion pointer
-static LoadFileTextCallback loadFileText = NULL; // LoadFileText callback funtion pointer
-static SaveFileTextCallback saveFileText = NULL; // SaveFileText callback funtion pointer
+static LoadFileDataCallback loadFileData = NULL; // LoadFileData callback function pointer
+static SaveFileDataCallback saveFileData = NULL; // SaveFileText callback function pointer
+static LoadFileTextCallback loadFileText = NULL; // LoadFileText callback function pointer
+static SaveFileTextCallback saveFileText = NULL; // SaveFileText callback function pointer
//----------------------------------------------------------------------------------
// Functions to set internal callbacks
@@ -145,7 +144,8 @@ void TraceLog(int logType, const char *text, ...)
default: break;
}
- strcat(buffer, text);
+ unsigned int textSize = (unsigned int)strlen(text);
+ memcpy(buffer + strlen(buffer), text, (textSize < (MAX_TRACELOG_MSG_LENGTH - 12))? textSize : (MAX_TRACELOG_MSG_LENGTH - 12));
strcat(buffer, "\n");
vprintf(buffer, args);
fflush(stdout);
@@ -207,12 +207,16 @@ unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead)
{
data = (unsigned char *)RL_MALLOC(size*sizeof(unsigned char));
- // NOTE: fread() returns number of read elements instead of bytes, so we read [1 byte, size elements]
- unsigned int count = (unsigned int)fread(data, sizeof(unsigned char), size, file);
- *bytesRead = count;
+ if (data != NULL)
+ {
+ // NOTE: fread() returns number of read elements instead of bytes, so we read [1 byte, size elements]
+ unsigned int count = (unsigned int)fread(data, sizeof(unsigned char), size, file);
+ *bytesRead = count;
- if (count != size) TRACELOG(LOG_WARNING, "FILEIO: [%s] File partially loaded", fileName);
- else TRACELOG(LOG_INFO, "FILEIO: [%s] File loaded successfully", fileName);
+ if (count != size) TRACELOG(LOG_WARNING, "FILEIO: [%s] File partially loaded", fileName);
+ else TRACELOG(LOG_INFO, "FILEIO: [%s] File loaded successfully", fileName);
+ }
+ else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to allocated memory for file reading", fileName);
}
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to read file", fileName);
@@ -270,7 +274,7 @@ bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite)
}
// Export data to code (.h), returns true on success
-bool ExportDataAsCode(const char *data, unsigned int size, const char *fileName)
+bool ExportDataAsCode(const unsigned char *data, unsigned int size, const char *fileName)
{
bool success = false;
@@ -290,7 +294,7 @@ bool ExportDataAsCode(const char *data, unsigned int size, const char *fileName)
byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n");
byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n");
byteCount += sprintf(txtData + byteCount, "// //\n");
- byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2022 Ramon Santamaria (@raysan5) //\n");
+ byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2022-2023 Ramon Santamaria (@raysan5) //\n");
byteCount += sprintf(txtData + byteCount, "// //\n");
byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n\n");
@@ -299,7 +303,9 @@ bool ExportDataAsCode(const char *data, unsigned int size, const char *fileName)
strcpy(varFileName, GetFileNameWithoutExt(fileName));
for (int i = 0; varFileName[i] != '\0'; i++) if ((varFileName[i] >= 'a') && (varFileName[i] <= 'z')) { varFileName[i] = varFileName[i] - 32; }
- byteCount += sprintf(txtData + byteCount, "static unsigned char %s_DATA[%i] = { ", varFileName, size);
+ byteCount += sprintf(txtData + byteCount, "#define %s_DATA_SIZE %i\n\n", varFileName, size);
+
+ byteCount += sprintf(txtData + byteCount, "static unsigned char %s_DATA[%s_DATA_SIZE] = { ", varFileName, varFileName);
for (unsigned int i = 0; i < size - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), data[i]);
byteCount += sprintf(txtData + byteCount, "0x%x };\n", data[size - 1]);
@@ -342,16 +348,21 @@ char *LoadFileText(const char *fileName)
if (size > 0)
{
text = (char *)RL_MALLOC((size + 1)*sizeof(char));
- unsigned int count = (unsigned int)fread(text, sizeof(char), size, file);
- // WARNING: \r\n is converted to \n on reading, so,
- // read bytes count gets reduced by the number of lines
- if (count < size) text = RL_REALLOC(text, count + 1);
+ if (text != NULL)
+ {
+ unsigned int count = (unsigned int)fread(text, sizeof(char), size, file);
- // Zero-terminate the string
- text[count] = '\0';
+ // WARNING: \r\n is converted to \n on reading, so,
+ // read bytes count gets reduced by the number of lines
+ if (count < size) text = RL_REALLOC(text, count + 1);
- TRACELOG(LOG_INFO, "FILEIO: [%s] Text file loaded successfully", fileName);
+ // Zero-terminate the string
+ text[count] = '\0';
+
+ TRACELOG(LOG_INFO, "FILEIO: [%s] Text file loaded successfully", fileName);
+ }
+ else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to allocated memory for file reading", fileName);
}
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to read text file", fileName);
diff --git a/src/utils.h b/src/utils.h
index a2b3e03c5..ff8246a7b 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -5,7 +5,7 @@
*
* LICENSE: zlib/libpng
*
-* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
+* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.