Merge branch 'master' into compute-shaders
This commit is contained in:
commit
1648fc67bf
105 changed files with 4911 additions and 51898 deletions
96
BINDINGS.md
96
BINDINGS.md
|
|
@ -8,84 +8,101 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
||||||
|:------------------:|:-------------: | :--------:|----------------------------------------------------------------------|
|
|:------------------:|:-------------: | :--------:|----------------------------------------------------------------------|
|
||||||
| raylib | **3.7** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | https://github.com/raysan5/raylib |
|
| raylib | **3.7** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | https://github.com/raysan5/raylib |
|
||||||
| Raylib-cs | 3.7 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | https://github.com/ChrisDill/Raylib-cs |
|
| Raylib-cs | 3.7 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | https://github.com/ChrisDill/Raylib-cs |
|
||||||
| raylib-cppsharp | 2.5 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | https://github.com/phxvyper/raylib-cppsharp |
|
|
||||||
| raylib-boo | 3.7 | [Boo](http://boo-language.github.io/) | https://github.com/Rabios/raylib-boo |
|
| raylib-boo | 3.7 | [Boo](http://boo-language.github.io/) | https://github.com/Rabios/raylib-boo |
|
||||||
|
| dray | 3.5 | [D](https://dlang.org/) | https://github.com/xdrie/dray |
|
||||||
|
| raylib-go | 4.0-dev | [Go](https://golang.org/) | https://github.com/gen2brain/raylib-go |
|
||||||
|
| raylib-rs | 3.5 | [Rust](https://www.rust-lang.org/) | https://github.com/deltaphc/raylib-rs |
|
||||||
|
| raylib-lua | 3.7 | [Lua](http://www.lua.org/) | https://github.com/TSnake41/raylib-lua |
|
||||||
|
| raylua | 3.7 | [Lua](http://www.lua.org/) | https://github.com/Rabios/raylua |
|
||||||
|
| nelua-raylib | 3.7 | [nelua](https://nelua.io/) | https://github.com/AKDev21/nelua-raylib |
|
||||||
|
| NimraylibNow! | 3.7 | [Nim](https://nim-lang.org/) | https://github.com/greenfork/nimraylib_now |
|
||||||
|
| raylib-Forever | auto | [Nim](https://nim-lang.org/) | https://github.com/Guevara-chan/Raylib-Forever |
|
||||||
|
| Ray4Laz | 3.7 | [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)) | https://github.com/GuvaCode/Ray4Laz |
|
||||||
|
| pyraylib | 3.7 | [Python](https://www.python.org/) | https://github.com/Ho011/pyraylib |
|
||||||
|
| raylib-python-cffi | 3.7 | [Python](https://www.python.org/) | https://github.com/electronstudio/raylib-python-cffi |
|
||||||
|
| jaylib | 3.7 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/electronstudio/jaylib/ |
|
||||||
|
| node-raylib | 3.5 | [Node.js](https://nodejs.org/en/) | https://github.com/RobLoach/node-raylib |
|
||||||
|
| raylib-v7 | 3.5 | [JavaScript (v7)](https://en.wikipedia.org/wiki/JavaScript) | https://github.com/Rabios/raylib-v7 |
|
||||||
|
| raylib-php | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | https://github.com/joseph-montanez/raylib-php |
|
||||||
|
| raylib-phpcpp | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | https://github.com/oraoto/raylib-phpcpp |
|
||||||
|
| raylib-factor | 3.5 | [Factor](https://factorcode.org/) | https://github.com/ArnautDaniel/raylib-factor |
|
||||||
|
| gforth-raylib | 3.5 | [Gforth](https://gforth.org/) | https://github.com/ArnautDaniel/gforth-raylib |
|
||||||
|
| hxRaylib | 3.7 | [Haxe](https://haxe.org/) | https://github.com/ForeignSasquatch/hxRaylib |
|
||||||
|
| raylib-wren | 3.7 | [Wren](http://wren.io/) | https://github.com/TSnake41/raylib-wren |
|
||||||
|
| raylib_odin_bindings | 4.0-dev | [Odin](https://odin-lang.org/) | https://github.com/Deathbat2190/raylib_odin_bindings |
|
||||||
|
| raylib.v | 3.7 | [V](https://vlang.io/) | https://github.com/irishgreencitrus/raylib.v |
|
||||||
|
| raylib-ocaml | 3.7 | [OCaml](https://ocaml.org/) | https://github.com/tjammer/raylib-ocaml |
|
||||||
|
| raylib-swift | 3.7 | [Swift](https://swift.org/) | https://github.com/STREGAsGate/Raylib |
|
||||||
|
| hb-raylib | 3.5 | [Harbour](https://harbour.github.io) | https://github.com/MarcosLeonardoMendezGerencir/hb-raylib |
|
||||||
|
| Relib | 3.5 | [ReCT](https://github.com/RedCubeDev-ByteSpace/ReCT) | https://github.com/RedCubeDev-ByteSpace/Relib |
|
||||||
|
| rayex | 3.7 | [elixir](https://elixir-lang.org/) | https://github.com/shiryel/rayex |
|
||||||
|
| kaylib | 3.7 | [Kotlin/native](https://kotlinlang.org) | https://github.com/electronstudio/kaylib |
|
||||||
|
| s48-raylib | 3.7 | [Scheme48](https://s48.org) | https://github.com/rc-05/s48-raylib |
|
||||||
|
|
||||||
|
### 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 | repo |
|
||||||
|
|:------------------:|:-------------: | :--------:|----------------------------------------------------------------------|
|
||||||
|
| raylib-cpp | 3.7 | [C++](https://en.wikipedia.org/wiki/C%2B%2B) | https://github.com/robloach/raylib-cpp |
|
||||||
|
|
||||||
|
### Older or Unmaintained Language Bindings
|
||||||
|
These are older raylib bindings that are more than 2 versions old or have not been maintained.
|
||||||
|
| name | raylib version | language | repo |
|
||||||
|
|:------------------:|:-------------: | :--------:|----------------------------------------------------------------------|
|
||||||
|
| raylib-cppsharp | 2.5 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | https://github.com/phxvyper/raylib-cppsharp |
|
||||||
| RaylibFS | 2.5 | [F#](https://fsharp.org/) | https://github.com/dallinbeutler/RaylibFS |
|
| RaylibFS | 2.5 | [F#](https://fsharp.org/) | https://github.com/dallinbeutler/RaylibFS |
|
||||||
| raylib_d | 2.5 | [D](https://dlang.org/) | https://github.com/Sepheus/raylib_d |
|
| raylib_d | 2.5 | [D](https://dlang.org/) | https://github.com/Sepheus/raylib_d |
|
||||||
| raylib-d | 3.0 | [D](https://dlang.org/) | https://github.com/onroundit/raylib-d |
|
| raylib-d | 3.0 | [D](https://dlang.org/) | https://github.com/onroundit/raylib-d |
|
||||||
| bindbc-raylib | 3.0 | [D](https://dlang.org/) | https://github.com/o3o/bindbc-raylib |
|
| bindbc-raylib | 3.0 | [D](https://dlang.org/) | https://github.com/o3o/bindbc-raylib |
|
||||||
| dray | 3.5 | [D](https://dlang.org/) | https://github.com/xdrie/dray |
|
| go-raylib | 3.5 | [Go](https://golang.org/) | https://github.com/chunqian/go-raylib |
|
||||||
| raylib-go | 3.8-dev | [Go](https://golang.org/) | https://github.com/gen2brain/raylib-go |
|
|
||||||
| raylib-goplus | 2.6-dev | [Go](https://golang.org/) | https://github.com/Lachee/raylib-goplus |
|
| raylib-goplus | 2.6-dev | [Go](https://golang.org/) | https://github.com/Lachee/raylib-goplus |
|
||||||
| ray-go | 2.6-dev | [Go](https://golang.org/) | https://github.com/hecate-tech/ray-go |
|
| ray-go | 2.6-dev | [Go](https://golang.org/) | https://github.com/hecate-tech/ray-go |
|
||||||
| go-raylib | 3.5 | [Go](https://golang.org/) | https://github.com/chunqian/go-raylib |
|
|
||||||
| raylib-rs | 3.5 | [Rust](https://www.rust-lang.org/) | https://github.com/deltaphc/raylib-rs |
|
|
||||||
| raylib-lua | 1.7 | [Lua](http://www.lua.org/) | https://github.com/raysan5/raylib-lua |
|
|
||||||
| raylib-lua-ffi | 2.0 | [Lua](http://www.lua.org/) | https://github.com/raysan5/raylib/issues/693 |
|
|
||||||
| raylib-lua-sol | 2.5 | [Lua](http://www.lua.org/) | https://github.com/RobLoach/raylib-lua-sol |
|
|
||||||
| raylib-lua | 3.7 | [Lua](http://www.lua.org/) | https://github.com/TSnake41/raylib-lua |
|
|
||||||
| raylib-luamore | 3.0 | [Lua](http://www.lua.org/) | https://github.com/HDPLocust/raylib-luamore |
|
| raylib-luamore | 3.0 | [Lua](http://www.lua.org/) | https://github.com/HDPLocust/raylib-luamore |
|
||||||
| raylua | 3.7 | [Lua](http://www.lua.org/) | https://github.com/Rabios/raylua |
|
|
||||||
| LuaJIT-Raylib | 2.6 | [Lua](http://www.lua.org/) | https://github.com/Bambofy/LuaJIT-Raylib |
|
| LuaJIT-Raylib | 2.6 | [Lua](http://www.lua.org/) | https://github.com/Bambofy/LuaJIT-Raylib |
|
||||||
| raylib-nelua | 3.7 | [nelua](https://nelua.io/) | https://github.com/edubart/nelua-decl/tree/main/libs/raylib |
|
| raylib-lua-sol | 2.5 | [Lua](http://www.lua.org/) | https://github.com/RobLoach/raylib-lua-sol |
|
||||||
|
| raylib-lua-ffi | 2.0 | [Lua](http://www.lua.org/) | https://github.com/raysan5/raylib/issues/693 |
|
||||||
|
| raylib-lua | 1.7 | [Lua](http://www.lua.org/) | https://github.com/raysan5/raylib-lua |
|
||||||
| raylib-nelua | 3.0 | [Nelua](https://nelua.io/) | https://github.com/Andre-LA/raylib-nelua |
|
| raylib-nelua | 3.0 | [Nelua](https://nelua.io/) | https://github.com/Andre-LA/raylib-nelua |
|
||||||
| raylib-Nim | 1.7 | [Nim](https://nim-lang.org/) | https://gitlab.com/define-private-public/raylib-Nim |
|
|
||||||
| raylib-nim | 2.0 | [Nim](https://nim-lang.org/) | https://github.com/Skrylar/raylib-nim |
|
| raylib-nim | 2.0 | [Nim](https://nim-lang.org/) | https://github.com/Skrylar/raylib-nim |
|
||||||
| raylib-Forever | 3.1-dev | [Nim](https://nim-lang.org/) | https://github.com/Guevara-chan/Raylib-Forever |
|
| raylib-Nim | 1.7 | [Nim](https://nim-lang.org/) | https://gitlab.com/define-private-public/raylib-Nim |
|
||||||
| nim-raylib | 3.1-dev | [Nim](https://nim-lang.org/) | https://github.com/tomc1998/nim-raylib |
|
| nim-raylib | 3.1-dev | [Nim](https://nim-lang.org/) | https://github.com/tomc1998/nim-raylib |
|
||||||
| NimraylibNow! | 3.7 | [Nim](https://nim-lang.org/) | https://github.com/greenfork/nimraylib_now |
|
|
||||||
| raylib-haskell | 2.0 | [Haskell](https://www.haskell.org/) | https://github.com/DevJac/raylib-haskell |
|
| raylib-haskell | 2.0 | [Haskell](https://www.haskell.org/) | https://github.com/DevJac/raylib-haskell |
|
||||||
| raylib-cr | 2.5-dev | [Crystal](https://crystal-lang.org/) | https://github.com/AregevDev/raylib-cr |
|
| raylib-cr | 2.5-dev | [Crystal](https://crystal-lang.org/) | https://github.com/AregevDev/raylib-cr |
|
||||||
| cray | 1.8 | [Crystal](https://crystal-lang.org/) | https://gitlab.com/Zatherz/cray |
|
|
||||||
| raylib.cr | 2.0 | [Crystal](https://crystal-lang.org/) | https://github.com/sam0x17/raylib.cr |
|
| raylib.cr | 2.0 | [Crystal](https://crystal-lang.org/) | https://github.com/sam0x17/raylib.cr |
|
||||||
| raylib-pascal | 2.0 | [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)) | https://github.com/drezgames/raylib-pascal |
|
| cray | 1.8 | [Crystal](https://crystal-lang.org/) | https://gitlab.com/Zatherz/cray |
|
||||||
| raylib-pas | 3.0 | [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)) | https://github.com/tazdij/raylib-pas |
|
| raylib-pas | 3.0 | [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)) | https://github.com/tazdij/raylib-pas |
|
||||||
| Ray4Laz | 3.7 | [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)) | https://github.com/GuvaCode/Ray4Laz |
|
| raylib-pascal | 2.0 | [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)) | https://github.com/drezgames/raylib-pascal |
|
||||||
| Graphics-Raylib | 1.4 | [Perl](https://www.perl.org/) | https://github.com/athreef/Graphics-Raylib |
|
| Graphics-Raylib | 1.4 | [Perl](https://www.perl.org/) | https://github.com/athreef/Graphics-Raylib |
|
||||||
| raylib-ruby-ffi | 2.0 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/D3nX/raylib-ruby-ffi |
|
|
||||||
| raylib-ruby | 2.6 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/a0/raylib-ruby |
|
| 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-mruby | 2.5-dev | [mruby](https://github.com/mruby/mruby) | https://github.com/lihaochen910/raylib-mruby |
|
||||||
| pyraylib | 3.7 | [Python](https://www.python.org/) | https://github.com/Ho011/pyraylib |
|
|
||||||
| raylib-py | 2.0 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py |
|
|
||||||
| raylib-python-cffi | 3.7 | [Python](https://www.python.org/) | https://github.com/electronstudio/raylib-python-cffi |
|
|
||||||
| raylib-py-ctbg | 2.6 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py-ctbg |
|
| raylib-py-ctbg | 2.6 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py-ctbg |
|
||||||
| jaylib | 3.7 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/electronstudio/jaylib/ |
|
| 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 |
|
| raylib-java | 2.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/XoanaIO/raylib-java |
|
||||||
| raylib-j | 3.5 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/CreedVI/Raylib-J |
|
| raylib-j | 3.5 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/CreedVI/Raylib-J |
|
||||||
| clj-raylib | 3.0 | [Clojure](https://clojure.org/) | https://github.com/lsevero/clj-raylib |
|
| clj-raylib | 3.0 | [Clojure](https://clojure.org/) | https://github.com/lsevero/clj-raylib |
|
||||||
| node-raylib | 3.5 | [Node.js](https://nodejs.org/en/) | https://github.com/RobLoach/node-raylib |
|
|
||||||
| QuickJS-raylib | 3.0 | [QuickJS](https://bellard.org/quickjs/) | https://github.com/sntg-p/QuickJS-raylib |
|
| QuickJS-raylib | 3.0 | [QuickJS](https://bellard.org/quickjs/) | https://github.com/sntg-p/QuickJS-raylib |
|
||||||
| raylib-duktape | 2.6 | [JavaScript (Duktape)](https://en.wikipedia.org/wiki/JavaScript) | https://github.com/RobLoach/raylib-duktape |
|
| raylib-duktape | 2.6 | [JavaScript (Duktape)](https://en.wikipedia.org/wiki/JavaScript) | https://github.com/RobLoach/raylib-duktape |
|
||||||
| raylib-v7 | 3.5 | [JavaScript (v7)](https://en.wikipedia.org/wiki/JavaScript) | https://github.com/Rabios/raylib-v7 |
|
|
||||||
| raylib-chaiscript | 2.6 | [ChaiScript](http://chaiscript.com/) | https://github.com/RobLoach/raylib-chaiscript |
|
| raylib-chaiscript | 2.6 | [ChaiScript](http://chaiscript.com/) | https://github.com/RobLoach/raylib-chaiscript |
|
||||||
| raylib-squirrel | 2.5 | [Squirrel](http://www.squirrel-lang.org/) | https://github.com/RobLoach/raylib-squirrel |
|
| raylib-squirrel | 2.5 | [Squirrel](http://www.squirrel-lang.org/) | https://github.com/RobLoach/raylib-squirrel |
|
||||||
| racket-raylib-2d | 2.5 | [Racket](https://racket-lang.org/) | https://github.com/arvyy/racket-raylib-2d |
|
| racket-raylib-2d | 2.5 | [Racket](https://racket-lang.org/) | https://github.com/arvyy/racket-raylib-2d |
|
||||||
| raylib-php | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | https://github.com/joseph-montanez/raylib-php |
|
|
||||||
| raylib-php-ffi | 2.4-dev | [PHP](https://en.wikipedia.org/wiki/PHP) | https://github.com/oraoto/raylib-php-ffi |
|
| raylib-php-ffi | 2.4-dev | [PHP](https://en.wikipedia.org/wiki/PHP) | https://github.com/oraoto/raylib-php-ffi |
|
||||||
| raylib-phpcpp | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | https://github.com/oraoto/raylib-phpcpp |
|
|
||||||
| raylib-factor | 3.5 | [Factor](https://factorcode.org/) | https://github.com/ArnautDaniel/raylib-factor |
|
|
||||||
| gforth-raylib | 3.5 | [Gforth](https://gforth.org/) | https://github.com/ArnautDaniel/gforth-raylib |
|
|
||||||
| raylib-haxe | 2.4 | [Haxe](https://haxe.org/) | https://github.com/ibilon/raylib-haxe |
|
| raylib-haxe | 2.4 | [Haxe](https://haxe.org/) | https://github.com/ibilon/raylib-haxe |
|
||||||
| hxRaylib | 3.7 | [Haxe](https://haxe.org/) | https://github.com/ForeignSasquatch/hxRaylib |
|
|
||||||
| ringraylib | 2.6 | [Ring](http://ring-lang.sourceforge.net/) | https://github.com/ringpackages/ringraylib |
|
| ringraylib | 2.6 | [Ring](http://ring-lang.sourceforge.net/) | https://github.com/ringpackages/ringraylib |
|
||||||
| cl-raylib | 3.0 | [Common Lisp](https://common-lisp.net/) | https://github.com/longlene/cl-raylib |
|
| cl-raylib | 3.0 | [Common Lisp](https://common-lisp.net/) | https://github.com/longlene/cl-raylib |
|
||||||
| raylib-scm | 2.5 | [Chicken Scheme](https://www.call-cc.org/) | https://github.com/yashrk/raylib-scm |
|
| raylib-scm | 2.5 | [Chicken Scheme](https://www.call-cc.org/) | https://github.com/yashrk/raylib-scm |
|
||||||
| raylib-chibi | 2.5 | [Chibi-Scheme](https://github.com/ashinn/chibi-scheme) | https://github.com/VincentToups/raylib-chibi |
|
| raylib-chibi | 2.5 | [Chibi-Scheme](https://github.com/ashinn/chibi-scheme) | https://github.com/VincentToups/raylib-chibi |
|
||||||
| raylib-gambit-scheme | 3.1-dev | [Gambit Scheme](https://github.com/gambit/gambit) | https://github.com/georgjz/raylib-gambit-scheme |
|
| raylib-gambit-scheme | 3.1-dev | [Gambit Scheme](https://github.com/gambit/gambit) | https://github.com/georgjz/raylib-gambit-scheme |
|
||||||
| Euraylib | 3.0 | [Euphoria](https://openeuphoria.org/) | https://github.com/gAndy50/Euraylib |
|
| Euraylib | 3.0 | [Euphoria](https://openeuphoria.org/) | https://github.com/gAndy50/Euraylib |
|
||||||
| raylib-wren | 3.7 | [Wren](http://wren.io/) | https://github.com/TSnake41/raylib-wren |
|
|
||||||
| raylib-odin | 3.0 | [Odin](https://odin-lang.org/) | https://github.com/kevinw/raylib-odin |
|
| raylib-odin | 3.0 | [Odin](https://odin-lang.org/) | https://github.com/kevinw/raylib-odin |
|
||||||
| raylib_odin_bindings | 3.8+ | [Odin](https://odin-lang.org/) | https://github.com/Deathbat2190/raylib_odin_bindings |
|
| vraylib | 3.5 | [V](https://vlang.io/) | https://github.com/waotzi/vraylib |
|
||||||
| raylib-zig | 3.0 | [Zig](https://ziglang.org/) | https://github.com/Not-Nik/raylib-zig |
|
| raylib-zig | 3.0 | [Zig](https://ziglang.org/) | https://github.com/Not-Nik/raylib-zig |
|
||||||
| raylib-jai | 3.1-dev | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | https://github.com/kevinw/raylib-jai |
|
| raylib-jai | 3.1-dev | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | https://github.com/kevinw/raylib-jai |
|
||||||
| ray.zig | 2.5 | [Zig](https://ziglang.org/) | https://github.com/BitPuffin/zig-raylib-experiments |
|
| 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 |
|
| 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 |
|
| 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 |
|
| raykit | ? | [Kit](https://www.kitlang.org/) | https://github.com/Gamerfiend/raykit |
|
||||||
| vraylib | 3.5 | [V](https://vlang.io/) | https://github.com/waotzi/vraylib |
|
|
||||||
| raylib.v | 3.7 | [V](https://vlang.io/) | https://github.com/irishgreencitrus/raylib.v |
|
|
||||||
| ray.mod | 3.0 | [BlitzMax](https://blitzmax.org/) | https://github.com/bmx-ng/ray.mod |
|
| ray.mod | 3.0 | [BlitzMax](https://blitzmax.org/) | https://github.com/bmx-ng/ray.mod |
|
||||||
| raylib-ocaml | 3.7 | [OCaml](https://ocaml.org/) | https://github.com/tjammer/raylib-ocaml |
|
|
||||||
| raylib-mosaic | 3.0 | [Mosaic](https://github.com/sal55/langs/tree/master/Mosaic) | https://github.com/pluckyporcupine/raylib-mosaic |
|
| raylib-mosaic | 3.0 | [Mosaic](https://github.com/sal55/langs/tree/master/Mosaic) | https://github.com/pluckyporcupine/raylib-mosaic |
|
||||||
| raylib-xdpw | 2.6 | [XD Pascal](https://github.com/vtereshkov/xdpw) | https://github.com/vtereshkov/raylib-xdpw |
|
| raylib-xdpw | 2.6 | [XD Pascal](https://github.com/vtereshkov/xdpw) | https://github.com/vtereshkov/raylib-xdpw |
|
||||||
| raylib-carp | 3.0 | [Carp](https://github.com/carp-lang/Carp) | https://github.com/pluckyporcupine/raylib-carp |
|
| raylib-carp | 3.0 | [Carp](https://github.com/carp-lang/Carp) | https://github.com/pluckyporcupine/raylib-carp |
|
||||||
|
|
@ -94,20 +111,11 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
||||||
| raylib-smallBasic | 3.1-dev | [SmallBASIC](https://github.com/smallbasic/SmallBASIC) | https://github.com/smallbasic/smallbasic.plugins/tree/master/raylib |
|
| raylib-smallBasic | 3.1-dev | [SmallBASIC](https://github.com/smallbasic/SmallBASIC) | https://github.com/smallbasic/smallbasic.plugins/tree/master/raylib |
|
||||||
| raylib-ats2 | 3.0 | [ATS2](http://www.ats-lang.org/) | https://github.com/mephistopheles-8/raylib-ats2 |
|
| raylib-ats2 | 3.0 | [ATS2](http://www.ats-lang.org/) | https://github.com/mephistopheles-8/raylib-ats2 |
|
||||||
| raylib-beef | 3.0 | [Beef](https://www.beeflang.org/) | https://github.com/M0n7y5/raylib-beef |
|
| raylib-beef | 3.0 | [Beef](https://www.beeflang.org/) | https://github.com/M0n7y5/raylib-beef |
|
||||||
| raylib-swift | 3.7 | [Swift](https://swift.org/) | https://github.com/STREGAsGate/Raylib |
|
|
||||||
| raylib-never | 3.0 | [Never](https://github.com/never-lang/never) | https://github.com/never-lang/raylib-never |
|
| raylib-never | 3.0 | [Never](https://github.com/never-lang/never) | https://github.com/never-lang/raylib-never |
|
||||||
| hb-raylib | 3.5 | [Harbour](https://harbour.github.io) | https://github.com/MarcosLeonardoMendezGerencir/hb-raylib |
|
|
||||||
| Relib | 3.5 | [ReCT](https://github.com/RedCubeDev-ByteSpace/ReCT) | https://github.com/RedCubeDev-ByteSpace/Relib |
|
|
||||||
| rayex | 3.7 | [elixir](https://elixir-lang.org/) | https://github.com/shiryel/rayex |
|
|
||||||
| raylib.cbl | 2.0 | [COBOL](https://en.wikipedia.org/wiki/COBOL) | *[code examples](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)* |
|
| raylib.cbl | 2.0 | [COBOL](https://en.wikipedia.org/wiki/COBOL) | *[code examples](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)* |
|
||||||
| kaylib | 3.7 | [Kotlin/native](https://kotlinlang.org) | https://github.com/electronstudio/kaylib |
|
|
||||||
|
|
||||||
### Utility Wrapers
|
|
||||||
|
|
||||||
| name | raylib version | language | repo |
|
|
||||||
|:------------------:|:-------------: | :--------:|----------------------------------------------------------------------|
|
|
||||||
| raylib-cpp | 3.7 | [C++](https://en.wikipedia.org/wiki/C%2B%2B) | https://github.com/robloach/raylib-cpp |
|
|
||||||
|
|
||||||
Missing some language or wrapper? Feel free to create a new one! :)
|
Missing some language or wrapper? Feel free to create a new one! :)
|
||||||
|
|
||||||
Usually, raylib bindings follow the convention: `raylib-{language}`
|
Usually, raylib bindings follow the convention: `raylib-{language}`
|
||||||
|
|
|
||||||
122
CHANGELOG
122
CHANGELOG
|
|
@ -12,7 +12,127 @@ KEY CHANGES:
|
||||||
-
|
-
|
||||||
|
|
||||||
Detailed changes:
|
Detailed changes:
|
||||||
|
[core] ADDED: Support canvas resizing on web (#1840) by @skylersaleh
|
||||||
|
[core] ADDED: GetMouseDelta() (#1832) by @adricoin2010
|
||||||
|
[core] ADDED: Support additional mouse buttons (#1753) by @lambertwang
|
||||||
|
[core] ADDED: SetRandomSeed() (#1994) by @TommiSinivuo
|
||||||
|
[core] ADDED: GetTouchPointId() #1972
|
||||||
|
[core] RENAMED: SwapBuffers() to SwapScreenBuffer()
|
||||||
|
[core] RENAMED: Wait() to WaitTime()
|
||||||
|
[core] RENAMED: RayHitInfo to RayCollision (#1781)
|
||||||
|
[core] RENAMED: GetRayCollisionGround() to GetRayCollisionQuad() (#1781)
|
||||||
|
[core] REVIEWED: Support mouse wheel on x-axis (#1948)
|
||||||
|
[core] REVIEWED: DisableCursor() on web by registering an empty mouse click event function in emscripten (#1900) by @grenappels
|
||||||
|
[core] REVIEWED: LoadShader() and default locations and descriptions
|
||||||
|
[core] REVIEWED: LoadShaderFromMemory() (#1851) by @Ruminant
|
||||||
|
[core] REVIEWED: WaitTime(), avoid global variables dependency to make the function is self-contained (#1841)
|
||||||
|
[core] REVIEWED: SetWindowSize() to work on web (#1847) by @nikki93
|
||||||
|
[core] REVIEWED: Raspberry RPI/DRM keyboard blocking render loop (#1879) @luizpestana
|
||||||
|
[core] REVIEWED: Android multi-touch (#1869) by @humbe
|
||||||
|
[core] REVIEWED: Implemented GetGamepadName() for emscripten by @nbarkhina
|
||||||
|
[core] REVIEWED: HighDPI support (#1987) by @ArnaudValensi
|
||||||
|
[rlgl] ADDED: rlUpdateVertexBufferElements() (#1915)
|
||||||
|
[rlgl] ADDED: rlActiveDrawBuffers() (#1911)
|
||||||
|
[rlgl] ADDED: rlEnableColorBlend()/rlDisableColorBlend()
|
||||||
|
[rlgl] ADDED: rlGetPixelFormatName()
|
||||||
|
[rlgl] REVIEWED: rlUpdateVertexBuffer (#1914) by @630Studios
|
||||||
|
[rlgl] REVIEWED: rlDrawVertexArrayElements() (#1891)
|
||||||
|
[rlgl] REVIEWED: Wrong normal matrix calculation (#1870)
|
||||||
|
[raymath] ADDED: Vector3Angle()
|
||||||
|
[raymath] REVIEWED: QuaternionFromAxisAngle() (#1892)
|
||||||
|
[raymath] REVIEWED: QuaternionToMatrix() returning transposed result. (#1793) by @object71
|
||||||
|
[shapes] ADDED: RenderPolyLinesEx() (#1758) by @lambertwang
|
||||||
|
[shapes] ADDED: DrawLineBezierCubic() (#2021) by @SAOMDVN
|
||||||
|
[textures] ADDED: GetImageColor() #2024
|
||||||
|
[textures] REMOVED: GenImagePerlinNoise()
|
||||||
|
[textures] RENAMED: GetTextureData() to LoadImageFromTexture()
|
||||||
|
[textures] RENAMED: GetScreenData() to LoadImageFromScreen()
|
||||||
|
[textures] REVIEWED: ExportImage() to use SaveFileData() (#1779)
|
||||||
|
[textures] REVIEWED: LoadImageAnim() #2005
|
||||||
|
[text] ADDED: Security check in case of not valid font
|
||||||
|
[text] ADDED: `GetGlyphInfo()` to get glyph info for a specific codepoint
|
||||||
|
[text] ADDED: `GetGlyphAtlasRec()` to get glyph rectangle within the generated font atlas
|
||||||
|
[text] ADDED: DrawTextPro() with text rotation support, WARNING: DrawTextPro() requires including `rlgl.h`, before it was only dependant on `textures` module.
|
||||||
|
[text] ADDED: UnloadCodepoints() to safely free loaded codepoints
|
||||||
|
[text] REMOVED: DrawTextRec() and DrawTextRecEx(), moved to example, those functions could be very specific depending on user needs so it's better to give the user the full source in case of special requirements instead of allowing a function with +10 input parameters.
|
||||||
|
[text] RENAMED: struct `CharInfo` to `GlyphInfo`, actually that's the correct naming for the data contained. It contains the character glyph metrics and the glyph image; in the past it also contained rectangle within the font atlas but that data has been moved to `Font` struct directly, so, `GlyphInfo` is a more correct name.
|
||||||
|
[text] RENAMED: `CodepointToUtf8()` to `CodepointToUTF8()`, capitalization of UTF-8 is the correct form, it would also require de hyphen but it can be omitted in this case.
|
||||||
|
[text] RENAMED: `TextToUtf8()` to `TextCodepointsToUTF8` for consistency and more detail on the functionality.
|
||||||
|
[text] RENAMED: GetCodepoints() to LoadCodepoints(), now codepoint array data is loaded dynamically instead of reusing a limited static buffer.
|
||||||
|
[text] RENAMED: GetNextCodepoint() to GetCodepoint()
|
||||||
|
[models] ADDED: MagikaVoxel VOX models loading
|
||||||
|
[models] ADDED: GenMeshCone() (#1903)
|
||||||
|
[models] ADDED: GetModelBoundingBox()
|
||||||
|
[models] ADDED: DrawBillboardPro() (#1759) by @nobytesgiven
|
||||||
|
[models] ADDED: DrawCubeTextureRec() (#2001) by @tdgroot
|
||||||
|
[models] ADDED: DrawCylinderEx() and DrawCylinderWiresEx() (#2049) by @Horrowind
|
||||||
|
[models] REMOVED: DrawBillboardEx()
|
||||||
|
[models] RENAMED: MeshBoundingBox() to GetMeshBoundingBox()
|
||||||
|
[models] RENAMED: MeshTangents() to GenMeshTangents()
|
||||||
|
[models] RENAMED: MeshBinormals() to GenMeshBinormals()
|
||||||
|
[models] REVIEWED: GenMeshTangents() (#1877) by @630Studios
|
||||||
|
[models] REVIEWED: CheckCollisionBoxSphere() by @Crydsch
|
||||||
|
[models] REVIEWED: GetRayCollisionQuad() by @Crydsch
|
||||||
|
[models] REVIEWED: LoadGLTF(), fixed missing transformations and nonroot skinning by @MrDiver
|
||||||
|
[models] REVIEWED: Decouple DrawMesh() and DrawMeshInstanced() (#1958)
|
||||||
|
[models] REVIEWED: Support vertex color attribute for GLTF and IQM (#1790) by @object71
|
||||||
|
[models] REVIEWED: DrawBillboardPro() (#1941) by @GithubPrankster
|
||||||
|
[models] REDESIGNED: Major review of glTF loading functionality (#1849) by @object71
|
||||||
|
[audio] ADDED: SeekMusicStream() (#2006) by @GithubPrankster
|
||||||
|
[audio] REMOVED: GetAudioStreamBufferSizeDefault()
|
||||||
|
[audio] RENAMED: InitAudioStream() to LoadAudioStream()
|
||||||
|
[audio] RENAMED: CloseAudioStream() to UnloadAudioStream()
|
||||||
|
[audio] RENAMED: IsMusicPlaying() to IsMusicStreamPlaying()
|
||||||
|
[audio] REVIEWED: ExportWaveAsCode()
|
||||||
|
[audio] REDESIGNED: Use frameCount on audio instead of sampleCount
|
||||||
|
[utils] REVIEWED: exit() on LOG_FATAL instead of LOG_ERROR (#1796)
|
||||||
|
[examples] ADDED: core_custom_frame_control
|
||||||
|
[examples] ADDED: core_basic_screen_manager
|
||||||
|
[examples] ADDED: core_split_screen (#1806) by @JeffM2501
|
||||||
|
[examples] ADDED: core_2d_camera_smooth_pixelperfect (#1771) by @NotManyIdeasDev
|
||||||
|
[examples] ADDED: shaders_texture_outline (#1883) by @GoldenThumbs
|
||||||
|
[examples] ADDED: models_loading_vox (#1940) by @procfxgen
|
||||||
|
[examples] REMOVED: models_material_pbr
|
||||||
|
[examples] REMOVED: models_gltf_animation
|
||||||
|
[examples] REVIEWED: core_3d_picking
|
||||||
|
[examples] REVIEWED: core_input_mouse
|
||||||
|
[examples] REVIEWED: core_vr_simulator, RenderTexture usage
|
||||||
|
[examples] REVIEWED: core_window_letterbox, RenderTexture usage
|
||||||
|
[examples] REVIEWED: shapes_basic_shapes
|
||||||
|
[examples] REVIEWED: shapes_logo_raylib_anim
|
||||||
|
[examples] REVIEWED: textures_to_image
|
||||||
|
[examples] REVIEWED: text_rectangle_bounds
|
||||||
|
[examples] REVIEWED: text_unicode
|
||||||
|
[examples] REVIEWED: text_draw_3d
|
||||||
|
[examples] REVIEWED: models_loading
|
||||||
|
[examples] REVIEWED: models_skybox (#1792) (#1778)
|
||||||
|
[examples] REVIEWED: models_mesh_picking
|
||||||
|
[examples] REVIEWED: models_material_pbr
|
||||||
|
[examples] REVIEWED: models_rlgl_solar_system
|
||||||
|
[examples] REVIEWED: shaders_custom_uniform, RenderTexture usage
|
||||||
|
[examples] REVIEWED: shaders_eratosthenes, RenderTexture usage
|
||||||
|
[examples] REVIEWED: shaders_julia_set, RenderTexture usage
|
||||||
|
[examples] REVIEWED: shaders_postprocessing, RenderTexture usage
|
||||||
|
[examples] REVIEWED: shaders_basic_lighting, simplified (#1865)
|
||||||
|
[examples] REVIEWED: audio_raw_stream.c
|
||||||
|
[examples] REVIEWED: raudio_standalone
|
||||||
|
[examples] REVIEWED: raylib_opengl_interop
|
||||||
|
[examples] REVIEWED: rlgl_standalone.c
|
||||||
|
[examples] REVIEWED: Resources licenses
|
||||||
|
[examples] REVIEWED: models resources reorganization
|
||||||
|
[build] ADDED: Zig build file (#2014) by @TommiSinivuo
|
||||||
|
[build] ADDED: Android VS2019 solution (#2013) by @Kronka
|
||||||
|
[build] REMOVED: VS2017 project, outdated
|
||||||
|
[build] RENAMED: All raylib modules prefixed with 'r' (core -> rcore)
|
||||||
|
[build] RENAMED: SUPPORT_MOUSE_CURSOR_NATIVE to SUPPORT_MOUSE_CURSOR_POINT
|
||||||
|
[build] REVIEWED: examples/examples_template.c
|
||||||
|
[build] REVIEWED: Makefile to latest Emscripten SDK r23
|
||||||
|
[build] REVIEWED: Makefile for latest Android NDK r32 LTS
|
||||||
|
[build] REVIEWED: raylib resource files
|
||||||
|
[build] Moved some extra raylib libraries to /extras/ directory
|
||||||
|
[*] UPDATED: Multiple bindings to latest version
|
||||||
|
[*] UPDATED: All external libraries to latest versions
|
||||||
|
[*] Multiple code improvements and fixes by multiple contributors!
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
Release: raylib 3.7 (26 April 2021)
|
Release: raylib 3.7 (26 April 2021)
|
||||||
|
|
|
||||||
34
SPONSORS.md
34
SPONSORS.md
|
|
@ -4,18 +4,11 @@
|
||||||
|
|
||||||
The following people is currently [**sponsoring raylib**](https://github.com/sponsors/raysan5) with a generous donation to allow improving and growing the project!
|
The following people is currently [**sponsoring raylib**](https://github.com/sponsors/raysan5) with a generous donation to allow improving and growing the project!
|
||||||
|
|
||||||
Note that Sponsors donations vary between sponsors, I just decided not to make any distinction while listing them.
|
|
||||||
|
|
||||||
- Eric J. ([@ProfJski](https://github.com/ProfJski))
|
- Eric J. ([@ProfJski](https://github.com/ProfJski))
|
||||||
- devdad ([@devdad](https://github.com/devdad))
|
|
||||||
- Zach Geis ([@zacgeis](https://github.com/zacgeis))
|
- Zach Geis ([@zacgeis](https://github.com/zacgeis))
|
||||||
- minirop ([@minirop](https://github.com/minirop))
|
- minirop ([@minirop](https://github.com/minirop))
|
||||||
- Daniel Gómez ([@Koocachookies](https://github.com/Koocachookies))
|
- Daniel Gómez ([@Koocachookies](https://github.com/Koocachookies))
|
||||||
- Sergio ([@anidealgift](https://github.com/anidealgift))
|
|
||||||
- Marc Agüera ([@maguera93](https://github.com/maguera93))
|
- Marc Agüera ([@maguera93](https://github.com/maguera93))
|
||||||
- Pau Fernández ([@pauek](https://github.com/pauek))
|
|
||||||
- Snowminx ([@Gamerfiend](https://github.com/Gamerfiend))
|
|
||||||
- NimbusFox ([@NimbusFox](https://github.com/NimbusFox))
|
|
||||||
- Robin Mattheussen ([@romatthe](https://github.com/romatthe))
|
- Robin Mattheussen ([@romatthe](https://github.com/romatthe))
|
||||||
- Grant Haywood ([@cinterloper](https://github.com/cinterloper))
|
- Grant Haywood ([@cinterloper](https://github.com/cinterloper))
|
||||||
- Terry Nguyen ([@terrehbyte](https://github.com/terrehbyte))
|
- Terry Nguyen ([@terrehbyte](https://github.com/terrehbyte))
|
||||||
|
|
@ -25,10 +18,17 @@ Note that Sponsors donations vary between sponsors, I just decided not to make a
|
||||||
- cob ([@majorcob](https://github.com/majorcob))
|
- cob ([@majorcob](https://github.com/majorcob))
|
||||||
- Samuel Batista ([@gamedevsam](https://github.com/gamedevsam))
|
- Samuel Batista ([@gamedevsam](https://github.com/gamedevsam))
|
||||||
- Merlyn Morgan-Graham ([@kavika13](https://github.com/kavika13))
|
- Merlyn Morgan-Graham ([@kavika13](https://github.com/kavika13))
|
||||||
- Toby4213 ([@Toby4213](https://github.com/Toby4213))
|
|
||||||
- linus ([@hochbaum](https://github.com/hochbaum))
|
- linus ([@hochbaum](https://github.com/hochbaum))
|
||||||
- Nawarian ([@nawarian](https://github.com/nawarian) - [thephp.website](https://thephp.website/))
|
- Nawarian ([@nawarian](https://github.com/nawarian) - [thephp.website](https://thephp.website/))
|
||||||
|
- kenzie ([@sme-ek](https://github.com/sme-ek))
|
||||||
|
- Allan Regush ([@AllanRegush](https://github.com/AllanRegush))
|
||||||
|
- Jeffery Myers ([@JeffM2501](https://github.com/ProfJski))
|
||||||
|
- Ryan Roden-Corrent ([@rcorre](https://github.com/ProfJski))
|
||||||
|
- michaelfiber ([@michaelfiber](https://github.com/ProfJski))
|
||||||
|
- Nikhilesh S ([@nikki93](https://github.com/ProfJski))
|
||||||
|
- kevinabraun ([@kevinabraun](https://github.com/ProfJski))
|
||||||
|
- Matthew Owens ([@MatthewOwens](https://github.com/ProfJski))
|
||||||
|
- Tim Eilers ([@eilerstim](https://github.com/ProfJski))
|
||||||
|
|
||||||
### Past raylib GitHub Sponsors
|
### Past raylib GitHub Sponsors
|
||||||
|
|
||||||
|
|
@ -49,10 +49,20 @@ The following people has **sponsored raylib** in the past, allowing the project
|
||||||
- James Ghawaly ([@jghawaly](https://github.com/jghawaly))
|
- James Ghawaly ([@jghawaly](https://github.com/jghawaly))
|
||||||
- jack ([@Jack-Ji](https://github.com/Jack-Ji))
|
- jack ([@Jack-Ji](https://github.com/Jack-Ji))
|
||||||
- Guido Offermans ([@jghawaly](https://github.com/GuidoOffermans))
|
- Guido Offermans ([@jghawaly](https://github.com/GuidoOffermans))
|
||||||
|
- devdad ([@devdad](https://github.com/devdad))
|
||||||
|
- Pau Fernández ([@pauek](https://github.com/pauek))
|
||||||
|
- Sergio ([@anidealgift](https://github.com/anidealgift))
|
||||||
|
- Snowminx ([@Gamerfiend](https://github.com/Gamerfiend))
|
||||||
|
- NimbusFox ([@NimbusFox](https://github.com/NimbusFox))
|
||||||
|
- Shylie ([@Shylie](https://github.com/Shylie))
|
||||||
|
- Livio Dal Maso ([@Humeur](https://github.com/Humeur))
|
||||||
|
- Diego Vaccher ([@denny0754](https://github.com/denny0754))
|
||||||
|
- Ricardo Alcantara ([@ricardoalcantara](https://github.com/ricardoalcantara))
|
||||||
|
- Toby4213 ([@Toby4213](https://github.com/Toby4213))
|
||||||
|
|
||||||
### Notes for Current/Past raylib Sponsor
|
### Notes for Current/Past raylib Sponsor
|
||||||
|
|
||||||
- **If you are not on the list, feel free to send a PR to add you if desired.**
|
- If you are not on the list, feel free to send a PR to be added (if desired).
|
||||||
- **If you want your personal webpage listed along your GitHub account, feel free to send a PR to add it.**
|
- If you want your personal webpage or project listed, feel free to send a PR to be added.
|
||||||
- **If you prefer not to listed in this list, feel free to send a PR to remove it.**
|
- If you prefer not to be in this list, feel free to send a PR to be remove.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,6 @@ if (${PLATFORM} MATCHES "Android")
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_world_screen.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_world_screen.c)
|
||||||
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_material_pbr.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_cubicmap.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_cubicmap.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_skybox.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_skybox.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
||||||
|
|
|
||||||
|
|
@ -462,7 +462,6 @@ MODELS = \
|
||||||
models/models_cubicmap \
|
models/models_cubicmap \
|
||||||
models/models_first_person_maze \
|
models/models_first_person_maze \
|
||||||
models/models_geometric_shapes \
|
models/models_geometric_shapes \
|
||||||
models/models_material_pbr \
|
|
||||||
models/models_mesh_generation \
|
models/models_mesh_generation \
|
||||||
models/models_mesh_picking \
|
models/models_mesh_picking \
|
||||||
models/models_loading \
|
models/models_loading \
|
||||||
|
|
@ -471,8 +470,7 @@ MODELS = \
|
||||||
models/models_skybox \
|
models/models_skybox \
|
||||||
models/models_yaw_pitch_roll \
|
models/models_yaw_pitch_roll \
|
||||||
models/models_heightmap \
|
models/models_heightmap \
|
||||||
models/models_waving_cubes \
|
models/models_waving_cubes
|
||||||
models/models_magicavoxel_loading
|
|
||||||
|
|
||||||
SHADERS = \
|
SHADERS = \
|
||||||
shaders/shaders_model_shader \
|
shaders/shaders_model_shader \
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,21 @@
|
||||||
|
## Building the Examples
|
||||||
|
|
||||||
|
The examples assume you have already built the `raylib` library in `../src`.
|
||||||
|
|
||||||
|
### With GNU make
|
||||||
|
|
||||||
|
- `make` builds all examples
|
||||||
|
- `make [module]` builds all examples for a particular module (e.g `make core`)
|
||||||
|
|
||||||
|
### With Zig
|
||||||
|
|
||||||
|
The [Zig](https://ziglang.org/) toolchain can compile `C` and `C++` in addition to `Zig`.
|
||||||
|
You may find it easier to use than other toolchains, especially when it comes to cross-compiling.
|
||||||
|
|
||||||
|
- `zig build` to compile all examples
|
||||||
|
- `zig build [module]` to compile all examples for a module (e.g. `zig build core`)
|
||||||
|
- `zig build [example]` to compile _and run_ a particular example (e.g. `zig build core_basic_window`)
|
||||||
|
|
||||||
## EXAMPLES LIST
|
## EXAMPLES LIST
|
||||||
|
|
||||||
### category: core
|
### category: core
|
||||||
|
|
@ -110,7 +128,7 @@ Examples using raylib models functionality, including models loading/generation
|
||||||
| 72 | [models_cubicmap](models/models_cubicmap.c) | <img src="models/models_cubicmap.png" alt="models_cubicmap" width="200"> | ray | |
|
| 72 | [models_cubicmap](models/models_cubicmap.c) | <img src="models/models_cubicmap.png" alt="models_cubicmap" width="200"> | ray | |
|
||||||
| 73 | [models_first_person_maze](models/models_first_person_maze.c) | <img src="models/models_first_person_maze.png" alt="models_first_person_maze" width="200"> | ray | |
|
| 73 | [models_first_person_maze](models/models_first_person_maze.c) | <img src="models/models_first_person_maze.png" alt="models_first_person_maze" width="200"> | ray | |
|
||||||
| 74 | [models_geometric_shapes](models/models_geometric_shapes.c) | <img src="models/models_geometric_shapes.png" alt="models_geometric_shapes" width="200"> | ray | |
|
| 74 | [models_geometric_shapes](models/models_geometric_shapes.c) | <img src="models/models_geometric_shapes.png" alt="models_geometric_shapes" width="200"> | ray | |
|
||||||
| 75 | [models_material_pbr](models/models_material_pbr.c) | <img src="models/models_material_pbr.png" alt="models_material_pbr" width="200"> | ray | |
|
| 75 | [...]() | | ray | |
|
||||||
| 76 | [models_mesh_generation](models/models_mesh_generation.c) | <img src="models/models_mesh_generation.png" alt="models_mesh_generation" width="200"> | ray | |
|
| 76 | [models_mesh_generation](models/models_mesh_generation.c) | <img src="models/models_mesh_generation.png" alt="models_mesh_generation" width="200"> | ray | |
|
||||||
| 77 | [models_mesh_picking](models/models_mesh_picking.c) | <img src="models/models_mesh_picking.png" alt="models_mesh_picking" width="200"> | [Joel Davis](https://github.com/joeld42) | |
|
| 77 | [models_mesh_picking](models/models_mesh_picking.c) | <img src="models/models_mesh_picking.png" alt="models_mesh_picking" width="200"> | [Joel Davis](https://github.com/joeld42) | |
|
||||||
| 78 | [models_loading](models/models_loading.c) | <img src="models/models_loading.png" alt="models_loading" width="200"> | ray | |
|
| 78 | [models_loading](models/models_loading.c) | <img src="models/models_loading.png" alt="models_loading" width="200"> | ray | |
|
||||||
|
|
|
||||||
86
examples/build.zig
Normal file
86
examples/build.zig
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
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();
|
||||||
|
|
||||||
|
const all = b.step(module, "All " ++ module ++ " examples");
|
||||||
|
const dir = try std.fs.cwd().openDir(
|
||||||
|
module,
|
||||||
|
.{ .iterate = true },
|
||||||
|
);
|
||||||
|
var iter = dir.iterate();
|
||||||
|
while (try iter.next()) |entry| {
|
||||||
|
if (entry.kind != .File) continue;
|
||||||
|
const extension_idx = std.mem.lastIndexOf(u8, entry.name, ".c") orelse continue;
|
||||||
|
const name = entry.name[0..extension_idx];
|
||||||
|
const path = try std.fs.path.join(b.allocator, &.{ module, entry.name });
|
||||||
|
|
||||||
|
// 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, path);
|
||||||
|
exe.setTarget(target);
|
||||||
|
exe.setBuildMode(mode);
|
||||||
|
exe.linkLibC();
|
||||||
|
exe.addObjectFile(switch (target.getOsTag()) {
|
||||||
|
.windows => "../src/raylib.lib",
|
||||||
|
.linux => "../src/libraylib.a",
|
||||||
|
else => @panic("Unsupported OS"),
|
||||||
|
});
|
||||||
|
|
||||||
|
exe.addIncludeDir("../src");
|
||||||
|
exe.addIncludeDir("../src/external");
|
||||||
|
exe.addIncludeDir("../src/external/glfw/include");
|
||||||
|
|
||||||
|
switch (exe.target.toTarget().os.tag) {
|
||||||
|
.windows => {
|
||||||
|
exe.linkSystemLibrary("winmm");
|
||||||
|
exe.linkSystemLibrary("gdi32");
|
||||||
|
exe.linkSystemLibrary("opengl32");
|
||||||
|
exe.addIncludeDir("external/glfw/deps/mingw");
|
||||||
|
},
|
||||||
|
.linux => {
|
||||||
|
exe.linkSystemLibrary("GL");
|
||||||
|
exe.linkSystemLibrary("rt");
|
||||||
|
exe.linkSystemLibrary("dl");
|
||||||
|
exe.linkSystemLibrary("m");
|
||||||
|
exe.linkSystemLibrary("X11");
|
||||||
|
},
|
||||||
|
else => {
|
||||||
|
@panic("Unsupported OS");
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
exe.setOutputDir(module);
|
||||||
|
|
||||||
|
var run = exe.run();
|
||||||
|
run.step.dependOn(&b.addInstallArtifact(exe).step);
|
||||||
|
run.cwd = module;
|
||||||
|
b.step(name, name).dependOn(&run.step);
|
||||||
|
all.dependOn(&exe.step);
|
||||||
|
}
|
||||||
|
return all;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn build(b: *std.build.Builder) !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(.{});
|
||||||
|
|
||||||
|
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("physics", 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));
|
||||||
|
}
|
||||||
|
|
@ -37,17 +37,17 @@ int main(void)
|
||||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
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.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
Model model = LoadModel("resources/guy/guy.iqm"); // Load the animated model mesh and basic data
|
Model model = LoadModel("resources/models/iqm/guy.iqm"); // Load the animated model mesh and basic data
|
||||||
Texture2D texture = LoadTexture("resources/guy/guytex.png"); // Load model texture and set material
|
Texture2D texture = LoadTexture("resources/models/iqm/guytex.png"); // Load model texture and set material
|
||||||
SetMaterialTexture(&model.materials[0], MATERIAL_MAP_DIFFUSE, texture); // Set model material map texture
|
SetMaterialTexture(&model.materials[0], MATERIAL_MAP_DIFFUSE, texture); // Set model material map texture
|
||||||
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
|
||||||
// Load animation data
|
// Load animation data
|
||||||
int animsCount = 0;
|
int animsCount = 0;
|
||||||
ModelAnimation *anims = LoadModelAnimations("resources/guy/guyanim.iqm", &animsCount);
|
ModelAnimation *anims = LoadModelAnimations("resources/models/iqm/guyanim.iqm", &animsCount);
|
||||||
int animFrameCounter = 0;
|
int animFrameCounter = 0;
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
|
SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
|
||||||
|
|
|
||||||
|
|
@ -1,122 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [models] example - Load 3d gltf model with animations and play them
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 3.5 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
*
|
|
||||||
* Example contributed by Hristo Stamenov (@object71) and reviewed by Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2021 Hristo Stamenov (@object71) and Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************
|
|
||||||
*
|
|
||||||
* To export a model from blender, make sure it is not posed, the vertices need to be in the
|
|
||||||
* same position as they would be in edit mode.
|
|
||||||
* and that the scale of your models is set to 0. Scaling can be done from the export menu.
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - model animation");
|
|
||||||
|
|
||||||
// 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.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
|
|
||||||
|
|
||||||
Model model = LoadModel("resources/gltf/rigged_figure.glb"); // Load the animated model mesh and
|
|
||||||
// basic data
|
|
||||||
// Texture2D texture = LoadTexture("resources/guy/guytex.png"); // Load model texture and set material
|
|
||||||
// SetMaterialTexture(&model.materials[0], MAP_DIFFUSE, texture); // Set model material map texture
|
|
||||||
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
|
||||||
|
|
||||||
// Load animation data
|
|
||||||
int animsCount = 0;
|
|
||||||
ModelAnimation *anims = LoadModelAnimations("resources/gltf/rigged_figure.glb", &animsCount);
|
|
||||||
int animFrameCounter = 0;
|
|
||||||
int animationDirection = 1;
|
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
|
|
||||||
|
|
||||||
SetTargetFPS(30); // 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);
|
|
||||||
|
|
||||||
// Play animation when spacebar is held down
|
|
||||||
if (IsKeyDown(KEY_SPACE))
|
|
||||||
{
|
|
||||||
animFrameCounter += animationDirection;
|
|
||||||
|
|
||||||
if (animFrameCounter >= anims[0].frameCount || animFrameCounter <= 0)
|
|
||||||
{
|
|
||||||
animationDirection *= -1;
|
|
||||||
animFrameCounter += animationDirection;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateModelAnimation(model, anims[0], animFrameCounter);
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode3D(camera);
|
|
||||||
|
|
||||||
DrawModelEx(model, position, (Vector3){ 1.0f, 0.0f, 0.0f }, -90.0f, (Vector3){ 1.0f, 1.0f, 1.0f }, WHITE);
|
|
||||||
|
|
||||||
for (int i = 0; i < model.boneCount; i++)
|
|
||||||
{
|
|
||||||
DrawSphere(anims[0].framePoses[animFrameCounter][i].translation, 0.01f, RED);
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawGrid(10, 1.0f); // Draw a grid
|
|
||||||
|
|
||||||
EndMode3D();
|
|
||||||
|
|
||||||
DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, 10, 20, MAROON);
|
|
||||||
DrawText("(cc4) Rigged Figure by @Cesium", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
// UnloadTexture(texture); // Unload texture
|
|
||||||
|
|
||||||
// Unload model animations data
|
|
||||||
for (int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
|
|
||||||
RL_FREE(anims);
|
|
||||||
|
|
||||||
UnloadModel(model); // Unload model
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -4,17 +4,19 @@
|
||||||
*
|
*
|
||||||
* raylib supports multiple models file formats:
|
* raylib supports multiple models file formats:
|
||||||
*
|
*
|
||||||
* - OBJ > Text file, must include vertex position-texcoords-normals information,
|
* - OBJ > Text file format. Must include vertex position-texcoords-normals information,
|
||||||
* if files references some .mtl materials file, it will be loaded (or try to)
|
* if files references some .mtl materials file, it will be loaded (or try to).
|
||||||
* - GLTF > Modern text/binary file format, includes lot of information and it could
|
* - GLTF > Text/binary file format. Includes lot of information and it could
|
||||||
* also reference external files, raylib will try loading mesh and materials data
|
* also reference external files, raylib will try loading mesh and materials data.
|
||||||
* - IQM > Binary file format including mesh vertex data but also animation data,
|
* - IQM > Binary file format. Includes mesh vertex data but also animation data,
|
||||||
* raylib can load .iqm animations.
|
* raylib can load .iqm animations.
|
||||||
|
* - VOX > Binary file format. MagikaVoxel mesh format:
|
||||||
|
* https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox.txt
|
||||||
*
|
*
|
||||||
* This example has been created using raylib 2.6 (www.raylib.com)
|
* This example has been created using raylib 4.0 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
|
* Copyright (c) 2014-2021 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
105
examples/models/models_loading_gltf.c
Normal file
105
examples/models/models_loading_gltf.c
Normal file
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [models] example - Load models gltf
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 3.5 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* NOTE: To export a model from Blender, make sure it is not posed, the vertices need to be
|
||||||
|
* in the same position as they would be in edit mode.
|
||||||
|
* Also make sure the scale parameter of your models is set to 0.0,
|
||||||
|
* scaling can be applied from the export menu.
|
||||||
|
*
|
||||||
|
* Example contributed by Hristo Stamenov (@object71) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 Hristo Stamenov (@object71) and Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#define MAX_GLTF_MODELS 8
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - model");
|
||||||
|
|
||||||
|
// 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.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
|
||||||
|
|
||||||
|
// Load some models
|
||||||
|
Model model[MAX_GLTF_MODELS] = { 0 };
|
||||||
|
model[0] = LoadModel("resources/models/gltf/raylib_32x32.glb");
|
||||||
|
model[1] = LoadModel("resources/models/gltf/rigged_figure.glb");
|
||||||
|
model[2] = LoadModel("resources/models/gltf/GearboxAssy.glb");
|
||||||
|
model[3] = LoadModel("resources/models/gltf/BoxAnimated.glb");
|
||||||
|
model[4] = LoadModel("resources/models/gltf/AnimatedTriangle.gltf");
|
||||||
|
model[5] = LoadModel("resources/models/gltf/AnimatedMorphCube.glb");
|
||||||
|
model[6] = LoadModel("resources/models/gltf/vertex_colored_object.glb");
|
||||||
|
model[7] = LoadModel("resources/models/gltf/girl.glb");
|
||||||
|
|
||||||
|
int currentModel = 0;
|
||||||
|
|
||||||
|
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
|
||||||
|
SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
|
||||||
|
|
||||||
|
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); // Update our camera with inputs
|
||||||
|
|
||||||
|
if (IsKeyReleased(KEY_RIGHT))
|
||||||
|
{
|
||||||
|
currentModel++;
|
||||||
|
if (currentModel == MAX_GLTF_MODELS) currentModel = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyReleased(KEY_LEFT))
|
||||||
|
{
|
||||||
|
currentModel--;
|
||||||
|
if (currentModel < 0) currentModel = MAX_GLTF_MODELS - 1;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(SKYBLUE);
|
||||||
|
|
||||||
|
BeginMode3D(camera);
|
||||||
|
|
||||||
|
DrawModel(model[currentModel], position, 1.0f, WHITE);
|
||||||
|
DrawGrid(10, 1.0f); // Draw a grid
|
||||||
|
|
||||||
|
EndMode3D();
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
for (int i = 0; i < MAX_GLTF_MODELS; i++) UnloadModel(model[i]); // Unload models
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
examples/models/models_loading_gltf.png
Normal file
BIN
examples/models/models_loading_gltf.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
130
examples/models/models_loading_vox.c
Normal file
130
examples/models/models_loading_vox.c
Normal file
|
|
@ -0,0 +1,130 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [models] example - Load models vox (MagicaVoxel)
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 4.0 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Example contributed by Johann Nadalutti (@procfxgen) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 Johann Nadalutti (@procfxgen) and Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#include "raymath.h" // Required for: MatrixTranslate()
|
||||||
|
|
||||||
|
#define MAX_VOX_FILES 3
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
const char *voxFileNames[] = {
|
||||||
|
"resources/models/vox/chr_knight.vox",
|
||||||
|
"resources/models/vox/chr_sword.vox",
|
||||||
|
"resources/models/vox/monu9.vox"
|
||||||
|
};
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - magicavoxel loading");
|
||||||
|
|
||||||
|
// 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.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
|
||||||
|
|
||||||
|
// Load MagicaVoxel files
|
||||||
|
Model models[MAX_VOX_FILES] = { 0 };
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_VOX_FILES; i++)
|
||||||
|
{
|
||||||
|
// Load VOX file and measure time
|
||||||
|
double t0 = GetTime()*1000.0;
|
||||||
|
models[i] = LoadModel(voxFileNames[i]);
|
||||||
|
double t1 = GetTime()*1000.0;
|
||||||
|
|
||||||
|
TraceLog(LOG_WARNING, TextFormat("[%s] File loaded in %.3f ms", voxFileNames[i], t1 - t0));
|
||||||
|
|
||||||
|
// Compute model translation matrix to center model on draw position (0, 0 , 0)
|
||||||
|
BoundingBox bb = GetModelBoundingBox(models[i]);
|
||||||
|
Vector3 center = { 0 };
|
||||||
|
center.x = bb.min.x + (((bb.max.x - bb.min.x)/2));
|
||||||
|
center.z = bb.min.z + (((bb.max.z - bb.min.z)/2));
|
||||||
|
|
||||||
|
Matrix matTranslate = MatrixTranslate(-center.x, 0, -center.z);
|
||||||
|
models[i].transform = matTranslate;
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentModel = 0;
|
||||||
|
|
||||||
|
SetCameraMode(camera, CAMERA_ORBITAL); // Set a orbital camera mode
|
||||||
|
|
||||||
|
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); // Update our camera to orbit
|
||||||
|
|
||||||
|
// Cycle between models on mouse click
|
||||||
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) currentModel = (currentModel + 1)%MAX_VOX_FILES;
|
||||||
|
|
||||||
|
// Cycle between models on key pressed
|
||||||
|
if (IsKeyPressed(KEY_RIGHT))
|
||||||
|
{
|
||||||
|
currentModel++;
|
||||||
|
if (currentModel >= MAX_VOX_FILES) currentModel = 0;
|
||||||
|
}
|
||||||
|
else if (IsKeyPressed(KEY_LEFT))
|
||||||
|
{
|
||||||
|
currentModel--;
|
||||||
|
if (currentModel < 0) currentModel = MAX_VOX_FILES - 1;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
// Draw 3D model
|
||||||
|
BeginMode3D(camera);
|
||||||
|
|
||||||
|
DrawModel(models[currentModel], (Vector3){ 0, 0, 0 }, 1.0f, WHITE);
|
||||||
|
DrawGrid(10, 1.0);
|
||||||
|
|
||||||
|
EndMode3D();
|
||||||
|
|
||||||
|
// Display info
|
||||||
|
DrawRectangle(10, 400, 310, 30, Fade(SKYBLUE, 0.5f));
|
||||||
|
DrawRectangleLines(10, 400, 310, 30, Fade(DARKBLUE, 0.5f));
|
||||||
|
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, 410, 10, BLUE);
|
||||||
|
DrawText(TextFormat("File: %s", GetFileName(voxFileNames[currentModel])), 10, 10, 20, GRAY);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Unload models data (GPU VRAM)
|
||||||
|
for (int i = 0; i < MAX_VOX_FILES; i++) UnloadModel(models[i]);
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,151 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [models] example - magicavoxel loader and viewer
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 3.8 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
*
|
|
||||||
* Example contributed by Johann Nadalutti
|
|
||||||
*
|
|
||||||
* Copyright (c) 2021 Johann Nadalutti
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
#include "raymath.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
// VOX Files to load and view
|
|
||||||
|
|
||||||
#define NUM_VOX_FILES 3
|
|
||||||
|
|
||||||
const char* szVoxFiles[] = {
|
|
||||||
"resources/vox/chr_knight.vox",
|
|
||||||
"resources/vox/chr_sword.vox",
|
|
||||||
"resources/vox/monu9.vox"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - magicavoxel loading");
|
|
||||||
|
|
||||||
// Load MagicaVoxel files
|
|
||||||
Model models[NUM_VOX_FILES] = { 0 };
|
|
||||||
|
|
||||||
for (int i = 0; i < NUM_VOX_FILES; i++)
|
|
||||||
{
|
|
||||||
// Load MagicaVoxel File and build model
|
|
||||||
double t0, t1;
|
|
||||||
t0 = GetTime() * 1000.0;
|
|
||||||
|
|
||||||
models[i] = LoadModel(szVoxFiles[i]);
|
|
||||||
|
|
||||||
t1 = GetTime() * 1000.0;
|
|
||||||
TraceLog(LOG_INFO, TextFormat("Vox <%s> loaded in %f ms", GetFileName(szVoxFiles[i]), t1 - t0));
|
|
||||||
|
|
||||||
//Compute model's center matrix
|
|
||||||
BoundingBox bb = GetModelBoundingBox(models[i]);
|
|
||||||
Vector3 center;
|
|
||||||
center.x = bb.min.x + (((bb.max.x - bb.min.x) / 2));
|
|
||||||
center.z = bb.min.z + (((bb.max.z - bb.min.z) / 2));
|
|
||||||
|
|
||||||
Matrix matP = MatrixTranslate(-center.x, 0, -center.z);
|
|
||||||
models[i].transform = matP;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
|
||||||
Camera camera = { { 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
|
||||||
|
|
||||||
// Model drawing position
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f };
|
|
||||||
|
|
||||||
int currentModel = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set a orbital camera mode
|
|
||||||
|
|
||||||
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); // Update internal camera and our camera
|
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
|
||||||
{
|
|
||||||
currentModel = (currentModel + 1) % NUM_VOX_FILES; // Cycle between models
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_RIGHT))
|
|
||||||
{
|
|
||||||
currentModel++;
|
|
||||||
if (currentModel >= NUM_VOX_FILES) currentModel = 0;
|
|
||||||
}
|
|
||||||
else if (IsKeyPressed(KEY_LEFT))
|
|
||||||
{
|
|
||||||
currentModel--;
|
|
||||||
if (currentModel < 0) currentModel = NUM_VOX_FILES - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
//Display model
|
|
||||||
BeginMode3D(camera);
|
|
||||||
|
|
||||||
Vector3 rotAxis = { 1,0,0 };
|
|
||||||
Vector3 scale = { 1,1,1 };
|
|
||||||
|
|
||||||
|
|
||||||
DrawModelEx(models[currentModel], position, rotAxis, 0, scale, WHITE);
|
|
||||||
//DrawModelWiresEx(models[currentModel], position, rotAxis, -90.0f, scale, BLACK);
|
|
||||||
|
|
||||||
DrawGrid(10, 1.0);
|
|
||||||
|
|
||||||
EndMode3D();
|
|
||||||
|
|
||||||
//Display debug infos
|
|
||||||
DrawRectangle(30, 400, 310, 30, Fade(SKYBLUE, 0.5f));
|
|
||||||
DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f));
|
|
||||||
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, 410, 10, BLUE);
|
|
||||||
|
|
||||||
DrawText(GetFileName(szVoxFiles[currentModel]), 100, 10, 20, DARKBLUE);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Unload models data (GPU VRAM)
|
|
||||||
for (int i = 0; i < NUM_VOX_FILES; i++) UnloadModel(models[i]);
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,543 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [models] example - PBR material
|
|
||||||
*
|
|
||||||
* NOTE: This example requires raylib OpenGL 3.3 for shaders support and only #version 330
|
|
||||||
* is currently supported. OpenGL ES 2.0 platforms are not supported at the moment.
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 1.8 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
#include "raymath.h"
|
|
||||||
#include "rlgl.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define RLIGHTS_IMPLEMENTATION
|
|
||||||
#include "rlights.h"
|
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
|
||||||
#define GLSL_VERSION 330
|
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
|
||||||
#define GLSL_VERSION 100
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CUBEMAP_SIZE 1024 // Cubemap texture size
|
|
||||||
#define IRRADIANCE_SIZE 32 // Irradiance texture size
|
|
||||||
#define PREFILTERED_SIZE 256 // Prefiltered HDR environment texture size
|
|
||||||
#define BRDF_SIZE 512 // BRDF LUT texture size
|
|
||||||
#define LIGHT_DISTANCE 1000.0f
|
|
||||||
#define LIGHT_HEIGHT 1.0f
|
|
||||||
|
|
||||||
// PBR texture maps generation
|
|
||||||
static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int size, int format); // Generate cubemap (6 faces) from equirectangular (panorama) texture
|
|
||||||
static TextureCubemap GenTextureIrradiance(Shader shader, TextureCubemap cubemap, int size); // Generate irradiance cubemap using cubemap texture
|
|
||||||
static TextureCubemap GenTexturePrefilter(Shader shader, TextureCubemap cubemap, int size); // Generate prefilter cubemap using cubemap texture
|
|
||||||
static Texture2D GenTextureBRDF(Shader shader, int size); // Generate a generic BRDF texture
|
|
||||||
|
|
||||||
// PBR material loading
|
|
||||||
static Material LoadMaterialPBR(Color albedo, float metalness, float roughness);
|
|
||||||
|
|
||||||
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 [models] example - pbr material");
|
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
|
||||||
Camera camera = { 0 };
|
|
||||||
camera.position = (Vector3){ 4.0f, 4.0f, 4.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 mode type
|
|
||||||
|
|
||||||
// Load model and PBR material
|
|
||||||
Model model = LoadModel("resources/pbr/trooper.obj");
|
|
||||||
|
|
||||||
// Mesh tangents are generated... and uploaded to GPU
|
|
||||||
// NOTE: New VBO for tangents is generated at default location and also binded to mesh VAO
|
|
||||||
//MeshTangents(&model.meshes[0]);
|
|
||||||
|
|
||||||
model.materials[0] = LoadMaterialPBR((Color){ 255, 255, 255, 255 }, 1.0f, 1.0f);
|
|
||||||
|
|
||||||
// Create lights
|
|
||||||
// NOTE: Lights are added to an internal lights pool automatically
|
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 0, 255 }, model.materials[0].shader);
|
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 255, 0, 255 }, model.materials[0].shader);
|
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 0, 255, 255 }, model.materials[0].shader);
|
|
||||||
CreateLight(LIGHT_DIRECTIONAL, (Vector3){ 0.0f, LIGHT_HEIGHT*2.0f, -LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 255, 255 }, model.materials[0].shader);
|
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
|
||||||
|
|
||||||
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); // Update camera
|
|
||||||
|
|
||||||
// Send to material PBR shader camera view position
|
|
||||||
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
|
|
||||||
SetShaderValue(model.materials[0].shader, model.materials[0].shader.locs[SHADER_LOC_VECTOR_VIEW], cameraPos, SHADER_UNIFORM_VEC3);
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode3D(camera);
|
|
||||||
|
|
||||||
DrawModel(model, Vector3Zero(), 1.0f, WHITE);
|
|
||||||
|
|
||||||
DrawGrid(10, 1.0f);
|
|
||||||
|
|
||||||
EndMode3D();
|
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadMaterial(model.materials[0]); // Unload material: shader and textures
|
|
||||||
|
|
||||||
UnloadModel(model); // Unload model
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load PBR material (Supports: ALBEDO, NORMAL, METALNESS, ROUGHNESS, AO, EMMISIVE, HEIGHT maps)
|
|
||||||
// NOTE: PBR shader is loaded inside this function
|
|
||||||
static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
|
||||||
{
|
|
||||||
Material mat = LoadMaterialDefault(); // Initialize material to default
|
|
||||||
|
|
||||||
// Load PBR shader (requires several maps)
|
|
||||||
mat.shader = LoadShader(TextFormat("resources/shaders/glsl%i/pbr.vs", GLSL_VERSION),
|
|
||||||
TextFormat("resources/shaders/glsl%i/pbr.fs", GLSL_VERSION));
|
|
||||||
|
|
||||||
// Get required locations points for PBR material
|
|
||||||
// NOTE: Those location names must be available and used in the shader code
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_ALBEDO] = GetShaderLocation(mat.shader, "albedo.sampler");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_METALNESS] = GetShaderLocation(mat.shader, "metalness.sampler");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_NORMAL] = GetShaderLocation(mat.shader, "normals.sampler");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_ROUGHNESS] = GetShaderLocation(mat.shader, "roughness.sampler");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_OCCLUSION] = GetShaderLocation(mat.shader, "occlusion.sampler");
|
|
||||||
//mat.shader.locs[SHADER_LOC_MAP_EMISSION] = GetShaderLocation(mat.shader, "emission.sampler");
|
|
||||||
//mat.shader.locs[SHADER_LOC_MAP_HEIGHT] = GetShaderLocation(mat.shader, "height.sampler");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_IRRADIANCE] = GetShaderLocation(mat.shader, "irradianceMap");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_PREFILTER] = GetShaderLocation(mat.shader, "prefilterMap");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_BRDF] = GetShaderLocation(mat.shader, "brdfLUT");
|
|
||||||
|
|
||||||
// Set view matrix location
|
|
||||||
mat.shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "matModel");
|
|
||||||
//mat.shader.locs[SHADER_LOC_MATRIX_VIEW] = GetShaderLocation(mat.shader, "view");
|
|
||||||
mat.shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(mat.shader, "viewPos");
|
|
||||||
|
|
||||||
// Set PBR standard maps
|
|
||||||
mat.maps[MATERIAL_MAP_ALBEDO].texture = LoadTexture("resources/pbr/trooper_albedo.png");
|
|
||||||
mat.maps[MATERIAL_MAP_NORMAL].texture = LoadTexture("resources/pbr/trooper_normals.png");
|
|
||||||
mat.maps[MATERIAL_MAP_METALNESS].texture = LoadTexture("resources/pbr/trooper_metalness.png");
|
|
||||||
mat.maps[MATERIAL_MAP_ROUGHNESS].texture = LoadTexture("resources/pbr/trooper_roughness.png");
|
|
||||||
mat.maps[MATERIAL_MAP_OCCLUSION].texture = LoadTexture("resources/pbr/trooper_ao.png");
|
|
||||||
|
|
||||||
// Set textures filtering for better quality
|
|
||||||
SetTextureFilter(mat.maps[MATERIAL_MAP_ALBEDO].texture, TEXTURE_FILTER_BILINEAR);
|
|
||||||
SetTextureFilter(mat.maps[MATERIAL_MAP_NORMAL].texture, TEXTURE_FILTER_BILINEAR);
|
|
||||||
SetTextureFilter(mat.maps[MATERIAL_MAP_METALNESS].texture, TEXTURE_FILTER_BILINEAR);
|
|
||||||
SetTextureFilter(mat.maps[MATERIAL_MAP_ROUGHNESS].texture, TEXTURE_FILTER_BILINEAR);
|
|
||||||
SetTextureFilter(mat.maps[MATERIAL_MAP_OCCLUSION].texture, TEXTURE_FILTER_BILINEAR);
|
|
||||||
|
|
||||||
// Enable sample usage in shader for assigned textures
|
|
||||||
SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "albedo.useSampler"), (int[1]){ 1 }, SHADER_UNIFORM_INT);
|
|
||||||
SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "normals.useSampler"), (int[1]){ 1 }, SHADER_UNIFORM_INT);
|
|
||||||
SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "metalness.useSampler"), (int[1]){ 1 }, SHADER_UNIFORM_INT);
|
|
||||||
SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "roughness.useSampler"), (int[1]){ 1 }, SHADER_UNIFORM_INT);
|
|
||||||
SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "occlusion.useSampler"), (int[1]){ 1 }, SHADER_UNIFORM_INT);
|
|
||||||
|
|
||||||
int renderModeLoc = GetShaderLocation(mat.shader, "renderMode");
|
|
||||||
SetShaderValue(mat.shader, renderModeLoc, (int[1]){ 0 }, SHADER_UNIFORM_INT);
|
|
||||||
|
|
||||||
// Set up material properties color
|
|
||||||
mat.maps[MATERIAL_MAP_ALBEDO].color = albedo;
|
|
||||||
mat.maps[MATERIAL_MAP_NORMAL].color = (Color){ 128, 128, 255, 255 };
|
|
||||||
mat.maps[MATERIAL_MAP_METALNESS].value = metalness;
|
|
||||||
mat.maps[MATERIAL_MAP_ROUGHNESS].value = roughness;
|
|
||||||
mat.maps[MATERIAL_MAP_OCCLUSION].value = 1.0f;
|
|
||||||
mat.maps[MATERIAL_MAP_EMISSION].value = 0.5f;
|
|
||||||
mat.maps[MATERIAL_MAP_HEIGHT].value = 0.5f;
|
|
||||||
|
|
||||||
// Generate cubemap from panorama texture
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
Texture2D panorama = LoadTexture("resources/dresden_square_2k.hdr");
|
|
||||||
|
|
||||||
// Load equirectangular to cubemap shader
|
|
||||||
Shader shdrCubemap = LoadShader(TextFormat("resources/shaders/glsl%i/pbr.vs", GLSL_VERSION),
|
|
||||||
TextFormat("resources/shaders/glsl%i/pbr.fs", GLSL_VERSION));
|
|
||||||
|
|
||||||
SetShaderValue(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, SHADER_UNIFORM_INT);
|
|
||||||
TextureCubemap cubemap = GenTextureCubemap(shdrCubemap, panorama, CUBEMAP_SIZE, PIXELFORMAT_UNCOMPRESSED_R32G32B32);
|
|
||||||
UnloadTexture(panorama);
|
|
||||||
UnloadShader(shdrCubemap);
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Generate irradiance map from cubemap texture
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
// Load irradiance (GI) calculation shader
|
|
||||||
Shader shdrIrradiance = LoadShader(TextFormat("resources/shaders/glsl%i/skybox.vs", GLSL_VERSION),
|
|
||||||
TextFormat("resources/shaders/glsl%i/irradiance.fs", GLSL_VERSION));
|
|
||||||
|
|
||||||
SetShaderValue(shdrIrradiance, GetShaderLocation(shdrIrradiance, "environmentMap"), (int[1]){ 0 }, SHADER_UNIFORM_INT);
|
|
||||||
mat.maps[MATERIAL_MAP_IRRADIANCE].texture = GenTextureIrradiance(shdrIrradiance, cubemap, IRRADIANCE_SIZE);
|
|
||||||
UnloadShader(shdrIrradiance);
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Generate prefilter map from cubemap texture
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
// Load reflection prefilter calculation shader
|
|
||||||
Shader shdrPrefilter = LoadShader(TextFormat("resources/shaders/glsl%i/skybox.vs", GLSL_VERSION),
|
|
||||||
TextFormat("resources/shaders/glsl%i/prefilter.fs", GLSL_VERSION));
|
|
||||||
|
|
||||||
SetShaderValue(shdrPrefilter, GetShaderLocation(shdrPrefilter, "environmentMap"), (int[1]){ 0 }, SHADER_UNIFORM_INT);
|
|
||||||
mat.maps[MATERIAL_MAP_PREFILTER].texture = GenTexturePrefilter(shdrPrefilter, cubemap, PREFILTERED_SIZE);
|
|
||||||
UnloadTexture(cubemap);
|
|
||||||
UnloadShader(shdrPrefilter);
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Generate BRDF (bidirectional reflectance distribution function) texture (using shader)
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
Shader shdrBRDF = LoadShader(TextFormat("resources/shaders/glsl%i/brdf.vs", GLSL_VERSION),
|
|
||||||
TextFormat("resources/shaders/glsl%i/brdf.fs", GLSL_VERSION));
|
|
||||||
|
|
||||||
mat.maps[MATERIAL_MAP_BRDF].texture = GenTextureBRDF(shdrBRDF, BRDF_SIZE);
|
|
||||||
UnloadShader(shdrBRDF);
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return mat;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Texture maps generation (PBR)
|
|
||||||
//-------------------------------------------------------------------------------------------
|
|
||||||
// Generate cubemap texture from HDR texture
|
|
||||||
static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int size, int format)
|
|
||||||
{
|
|
||||||
TextureCubemap cubemap = { 0 };
|
|
||||||
|
|
||||||
rlDisableBackfaceCulling(); // Disable backface culling to render inside the cube
|
|
||||||
|
|
||||||
// STEP 1: Setup framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
unsigned int rbo = rlLoadTextureDepth(size, size, true);
|
|
||||||
cubemap.id = rlLoadTextureCubemap(NULL, size, format);
|
|
||||||
|
|
||||||
unsigned int fbo = rlLoadFramebuffer(size, size);
|
|
||||||
rlFramebufferAttach(fbo, rbo, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
|
||||||
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X, 0);
|
|
||||||
|
|
||||||
// Check if framebuffer is complete with attachments (valid)
|
|
||||||
if (rlFramebufferComplete(fbo)) TraceLog(LOG_INFO, "FBO: [ID %i] Framebuffer object created successfully", fbo);
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 2: Draw to framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
// NOTE: Shader is used to convert HDR equirectangular environment map to cubemap equivalent (6 faces)
|
|
||||||
rlEnableShader(shader.id);
|
|
||||||
|
|
||||||
// Define projection matrix and send it to shader
|
|
||||||
Matrix matFboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
|
|
||||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_PROJECTION], matFboProjection);
|
|
||||||
|
|
||||||
// Define view matrix for every side of the cubemap
|
|
||||||
Matrix fboViews[6] = {
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ -1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 1.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, 1.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, -1.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, 1.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, -1.0f }, (Vector3){ 0.0f, -1.0f, 0.0f })
|
|
||||||
};
|
|
||||||
|
|
||||||
rlViewport(0, 0, size, size); // Set viewport to current fbo dimensions
|
|
||||||
|
|
||||||
// Activate and enable texture for drawing to cubemap faces
|
|
||||||
rlActiveTextureSlot(0);
|
|
||||||
rlEnableTexture(panorama.id);
|
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
// Set the view matrix for the current cube face
|
|
||||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_VIEW], fboViews[i]);
|
|
||||||
|
|
||||||
// Select the current cubemap face attachment for the fbo
|
|
||||||
// WARNING: This function by default enables->attach->disables fbo!!!
|
|
||||||
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X + i, 0);
|
|
||||||
rlEnableFramebuffer(fbo);
|
|
||||||
|
|
||||||
// Load and draw a cube, it uses the current enabled texture
|
|
||||||
rlClearScreenBuffers();
|
|
||||||
rlLoadDrawCube();
|
|
||||||
|
|
||||||
// ALTERNATIVE: Try to use internal batch system to draw the cube instead of rlLoadDrawCube
|
|
||||||
// for some reason this method does not work, maybe due to cube triangles definition? normals pointing out?
|
|
||||||
// TODO: Investigate this issue...
|
|
||||||
//rlSetTexture(panorama.id); // WARNING: It must be called after enabling current framebuffer if using internal batch system!
|
|
||||||
//rlClearScreenBuffers();
|
|
||||||
//DrawCubeV(Vector3Zero(), Vector3One(), WHITE);
|
|
||||||
//rlDrawRenderBatchActive();
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 3: Unload framebuffer and reset state
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
rlDisableShader(); // Unbind shader
|
|
||||||
rlDisableTexture(); // Unbind texture
|
|
||||||
rlDisableFramebuffer(); // Unbind framebuffer
|
|
||||||
rlUnloadFramebuffer(fbo); // Unload framebuffer (and automatically attached depth texture/renderbuffer)
|
|
||||||
|
|
||||||
// Reset viewport dimensions to default
|
|
||||||
rlViewport(0, 0, rlGetFramebufferWidth(), rlGetFramebufferHeight());
|
|
||||||
rlEnableBackfaceCulling();
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
cubemap.width = size;
|
|
||||||
cubemap.height = size;
|
|
||||||
cubemap.mipmaps = 1;
|
|
||||||
cubemap.format = PIXELFORMAT_UNCOMPRESSED_R32G32B32;
|
|
||||||
|
|
||||||
return cubemap;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate irradiance texture using cubemap data
|
|
||||||
static TextureCubemap GenTextureIrradiance(Shader shader, TextureCubemap cubemap, int size)
|
|
||||||
{
|
|
||||||
TextureCubemap irradiance = { 0 };
|
|
||||||
|
|
||||||
rlDisableBackfaceCulling(); // Disable backface culling to render inside the cube
|
|
||||||
|
|
||||||
// STEP 1: Setup framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
unsigned int rbo = rlLoadTextureDepth(size, size, true);
|
|
||||||
irradiance.id = rlLoadTextureCubemap(NULL, size, PIXELFORMAT_UNCOMPRESSED_R32G32B32);
|
|
||||||
|
|
||||||
unsigned int fbo = rlLoadFramebuffer(size, size);
|
|
||||||
rlFramebufferAttach(fbo, rbo, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
|
||||||
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X, 0);
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 2: Draw to framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
// NOTE: Shader is used to solve diffuse integral by convolution to create an irradiance cubemap
|
|
||||||
rlEnableShader(shader.id);
|
|
||||||
|
|
||||||
// Define projection matrix and send it to shader
|
|
||||||
Matrix matFboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
|
|
||||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_PROJECTION], matFboProjection);
|
|
||||||
|
|
||||||
// Define view matrix for every side of the cubemap
|
|
||||||
Matrix fboViews[6] = {
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ -1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 1.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, 1.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, -1.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, 1.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, -1.0f }, (Vector3){ 0.0f, -1.0f, 0.0f })
|
|
||||||
};
|
|
||||||
|
|
||||||
rlActiveTextureSlot(0);
|
|
||||||
rlEnableTextureCubemap(cubemap.id);
|
|
||||||
|
|
||||||
rlViewport(0, 0, size, size); // Set viewport to current fbo dimensions
|
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_VIEW], fboViews[i]);
|
|
||||||
rlFramebufferAttach(fbo, irradiance.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X + i, 0);
|
|
||||||
|
|
||||||
rlEnableFramebuffer(fbo);
|
|
||||||
rlClearScreenBuffers();
|
|
||||||
rlLoadDrawCube();
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 3: Unload framebuffer and reset state
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
rlDisableShader(); // Unbind shader
|
|
||||||
rlDisableTexture(); // Unbind texture
|
|
||||||
rlDisableFramebuffer(); // Unbind framebuffer
|
|
||||||
rlUnloadFramebuffer(fbo); // Unload framebuffer (and automatically attached depth texture/renderbuffer)
|
|
||||||
|
|
||||||
// Reset viewport dimensions to default
|
|
||||||
rlViewport(0, 0, rlGetFramebufferWidth(), rlGetFramebufferHeight());
|
|
||||||
rlEnableBackfaceCulling();
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
irradiance.width = size;
|
|
||||||
irradiance.height = size;
|
|
||||||
irradiance.mipmaps = 1;
|
|
||||||
irradiance.format = PIXELFORMAT_UNCOMPRESSED_R32G32B32;
|
|
||||||
|
|
||||||
return irradiance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate prefilter texture using cubemap data
|
|
||||||
static TextureCubemap GenTexturePrefilter(Shader shader, TextureCubemap cubemap, int size)
|
|
||||||
{
|
|
||||||
TextureCubemap prefilter = { 0 };
|
|
||||||
|
|
||||||
rlDisableBackfaceCulling(); // Disable backface culling to render inside the cube
|
|
||||||
|
|
||||||
// STEP 1: Setup framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
unsigned int rbo = rlLoadTextureDepth(size, size, true);
|
|
||||||
prefilter.id = rlLoadTextureCubemap(NULL, size, PIXELFORMAT_UNCOMPRESSED_R32G32B32);
|
|
||||||
rlTextureParameters(prefilter.id, RL_TEXTURE_MIN_FILTER, RL_TEXTURE_FILTER_MIP_LINEAR);
|
|
||||||
|
|
||||||
unsigned int fbo = rlLoadFramebuffer(size, size);
|
|
||||||
rlFramebufferAttach(fbo, rbo, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
|
||||||
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X, 0);
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Generate mipmaps for the prefiltered HDR texture
|
|
||||||
//glGenerateMipmap(GL_TEXTURE_CUBE_MAP); // TODO!
|
|
||||||
|
|
||||||
// STEP 2: Draw to framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
// NOTE: Shader is used to prefilter HDR and store data into mipmap levels
|
|
||||||
|
|
||||||
// Define projection matrix and send it to shader
|
|
||||||
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
|
|
||||||
rlEnableShader(shader.id);
|
|
||||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_PROJECTION], fboProjection);
|
|
||||||
|
|
||||||
// Define view matrix for every side of the cubemap
|
|
||||||
Matrix fboViews[6] = {
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ -1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 1.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, 1.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, -1.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, 1.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, -1.0f }, (Vector3){ 0.0f, -1.0f, 0.0f })
|
|
||||||
};
|
|
||||||
|
|
||||||
rlActiveTextureSlot(0);
|
|
||||||
rlEnableTextureCubemap(cubemap.id);
|
|
||||||
|
|
||||||
// TODO: Locations should be taken out of this function... too shader dependant...
|
|
||||||
int roughnessLoc = rlGetLocationUniform(shader.id, "roughness");
|
|
||||||
|
|
||||||
rlEnableFramebuffer(fbo);
|
|
||||||
|
|
||||||
#define MAX_MIPMAP_LEVELS 5 // Max number of prefilter texture mipmaps
|
|
||||||
|
|
||||||
for (int mip = 0; mip < MAX_MIPMAP_LEVELS; mip++)
|
|
||||||
{
|
|
||||||
// Resize framebuffer according to mip-level size.
|
|
||||||
unsigned int mipWidth = size*(int)powf(0.5f, (float)mip);
|
|
||||||
unsigned int mipHeight = size*(int)powf(0.5f, (float)mip);
|
|
||||||
|
|
||||||
rlViewport(0, 0, mipWidth, mipHeight);
|
|
||||||
|
|
||||||
//glBindRenderbuffer(GL_RENDERBUFFER, rbo);
|
|
||||||
//glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, mipWidth, mipHeight);
|
|
||||||
|
|
||||||
float roughness = (float)mip/(float)(MAX_MIPMAP_LEVELS - 1);
|
|
||||||
rlSetUniform(roughnessLoc, &roughness, SHADER_UNIFORM_FLOAT, 1);
|
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_VIEW], fboViews[i]);
|
|
||||||
rlFramebufferAttach(fbo, prefilter.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X + i, mip);
|
|
||||||
|
|
||||||
rlClearScreenBuffers();
|
|
||||||
rlLoadDrawCube();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 3: Unload framebuffer and reset state
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
rlDisableShader(); // Unbind shader
|
|
||||||
rlDisableTexture(); // Unbind texture
|
|
||||||
rlDisableFramebuffer(); // Unbind framebuffer
|
|
||||||
rlUnloadFramebuffer(fbo); // Unload framebuffer (and automatically attached depth texture/renderbuffer)
|
|
||||||
|
|
||||||
// Reset viewport dimensions to default
|
|
||||||
rlViewport(0, 0, rlGetFramebufferWidth(), rlGetFramebufferHeight());
|
|
||||||
rlEnableBackfaceCulling();
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
prefilter.width = size;
|
|
||||||
prefilter.height = size;
|
|
||||||
prefilter.mipmaps = MAX_MIPMAP_LEVELS;
|
|
||||||
prefilter.format = PIXELFORMAT_UNCOMPRESSED_R32G32B32;
|
|
||||||
|
|
||||||
return prefilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate BRDF texture using cubemap data
|
|
||||||
// TODO: Review implementation: https://github.com/HectorMF/BRDFGenerator
|
|
||||||
static Texture2D GenTextureBRDF(Shader shader, int size)
|
|
||||||
{
|
|
||||||
Texture2D brdf = { 0 };
|
|
||||||
|
|
||||||
// STEP 1: Setup framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
unsigned int rbo = rlLoadTextureDepth(size, size, true);
|
|
||||||
brdf.id = rlLoadTexture(NULL, size, size, PIXELFORMAT_UNCOMPRESSED_R32G32B32, 1);
|
|
||||||
|
|
||||||
unsigned int fbo = rlLoadFramebuffer(size, size);
|
|
||||||
rlFramebufferAttach(fbo, rbo, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
|
||||||
rlFramebufferAttach(fbo, brdf.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_TEXTURE2D, 0);
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 2: Draw to framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
// NOTE: Render BRDF LUT into a quad using FBO
|
|
||||||
rlEnableShader(shader.id);
|
|
||||||
|
|
||||||
rlViewport(0, 0, size, size);
|
|
||||||
|
|
||||||
rlEnableFramebuffer(fbo);
|
|
||||||
rlClearScreenBuffers();
|
|
||||||
|
|
||||||
rlLoadDrawQuad();
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 3: Unload framebuffer and reset state
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
rlDisableShader(); // Unbind shader
|
|
||||||
rlDisableTexture(); // Unbind texture
|
|
||||||
rlDisableFramebuffer(); // Unbind framebuffer
|
|
||||||
rlUnloadFramebuffer(fbo); // Unload framebuffer (and automatically attached depth texture/renderbuffer)
|
|
||||||
|
|
||||||
// Reset viewport dimensions to default
|
|
||||||
rlViewport(0, 0, rlGetFramebufferWidth(), rlGetFramebufferHeight());
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
brdf.width = size;
|
|
||||||
brdf.height = size;
|
|
||||||
brdf.mipmaps = 1;
|
|
||||||
brdf.format = PIXELFORMAT_UNCOMPRESSED_R32G32B32;
|
|
||||||
|
|
||||||
return brdf;
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 317 KiB |
|
|
@ -31,16 +31,16 @@ int main(void)
|
||||||
camera.target = (Vector3){ 0.0f, 8.0f, 0.0f }; // Camera looking at point
|
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.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
Ray ray = { 0 }; // Picking ray
|
Ray ray = { 0 }; // Picking ray
|
||||||
|
|
||||||
Model tower = LoadModel("resources/models/turret.obj"); // Load OBJ model
|
Model tower = LoadModel("resources/models/obj/turret.obj"); // Load OBJ model
|
||||||
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load model texture
|
Texture2D texture = LoadTexture("resources/models/obj/turret_diffuse.png"); // Load model texture
|
||||||
tower.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture
|
tower.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture
|
||||||
|
|
||||||
Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position
|
Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
BoundingBox towerBBox = GetMeshBoundingBox(tower.meshes[0]); // Get mesh bounding box
|
BoundingBox towerBBox = GetMeshBoundingBox(tower.meshes[0]); // Get mesh bounding box
|
||||||
|
|
||||||
// Ground quad
|
// Ground quad
|
||||||
Vector3 g0 = (Vector3){ -50.0f, 0.0f, -50.0f };
|
Vector3 g0 = (Vector3){ -50.0f, 0.0f, -50.0f };
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,6 @@ int main(void)
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlRotatef(earthOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Earth orbit around Sun
|
rlRotatef(earthOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Earth orbit around Sun
|
||||||
rlTranslatef(earthOrbitRadius, 0.0f, 0.0f); // Translation for Earth orbit
|
rlTranslatef(earthOrbitRadius, 0.0f, 0.0f); // Translation for Earth orbit
|
||||||
rlRotatef(-earthOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Earth orbit around Sun inverted
|
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlRotatef(earthRotation, 0.25, 1.0, 0.0); // Rotation for Earth itself
|
rlRotatef(earthRotation, 0.25, 1.0, 0.0); // Rotation for Earth itself
|
||||||
|
|
@ -99,7 +98,6 @@ int main(void)
|
||||||
|
|
||||||
rlRotatef(moonOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Moon orbit around Earth
|
rlRotatef(moonOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Moon orbit around Earth
|
||||||
rlTranslatef(moonOrbitRadius, 0.0f, 0.0f); // Translation for Moon orbit
|
rlTranslatef(moonOrbitRadius, 0.0f, 0.0f); // Translation for Moon orbit
|
||||||
rlRotatef(-moonOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Moon orbit around Earth inverted
|
|
||||||
rlRotatef(moonRotation, 0.0f, 1.0f, 0.0f); // Rotation for Moon itself
|
rlRotatef(moonRotation, 0.0f, 1.0f, 0.0f); // Rotation for Moon itself
|
||||||
rlScalef(moonRadius, moonRadius, moonRadius); // Scale Moon
|
rlScalef(moonRadius, moonRadius, moonRadius); // Scale Moon
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,9 @@
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#include "rlgl.h"
|
#include "rlgl.h"
|
||||||
#include "raymath.h"
|
#include "raymath.h" // Required for: MatrixPerspective(), MatrixLookAt()
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,13 @@
|
||||||
*
|
*
|
||||||
* Example contributed by Berni (@Berni8k) and reviewed by Ramon Santamaria (@raysan5)
|
* Example contributed by Berni (@Berni8k) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2017 Berni (@Berni8k) and Ramon Santamaria (@raysan5)
|
* Copyright (c) 2017-2021 Berni (@Berni8k) and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "raymath.h"
|
|
||||||
|
#include "raymath.h" // Required for: MatrixRotateXYZ()
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
|
@ -33,7 +34,7 @@ int main(void)
|
||||||
|
|
||||||
// Model loading
|
// Model loading
|
||||||
// NOTE: Diffuse map loaded automatically
|
// NOTE: Diffuse map loaded automatically
|
||||||
Model model = LoadModel("resources/plane/plane.gltf");
|
Model model = LoadModel("resources/models/gltf/plane/plane.gltf");
|
||||||
|
|
||||||
float pitch = 0.0f;
|
float pitch = 0.0f;
|
||||||
float roll = 0.0f;
|
float roll = 0.0f;
|
||||||
|
|
@ -78,7 +79,6 @@ int main(void)
|
||||||
model.transform = MatrixRotateXYZ((Vector3){ DEG2RAD*pitch, DEG2RAD*yaw, DEG2RAD*roll });
|
model.transform = MatrixRotateXYZ((Vector3){ DEG2RAD*pitch, DEG2RAD*yaw, DEG2RAD*roll });
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue