Merge branch 'raysan5:master' into master
1
.github/ISSUE_TEMPLATE/new-issue-template.md
vendored
|
|
@ -21,6 +21,7 @@ Please, before submitting a new issue verify and check:
|
||||||
|
|
||||||
- [ ] I tested it on latest raylib version from master branch
|
- [ ] I tested it on latest raylib version from master branch
|
||||||
- [ ] I checked there is no similar issue already reported
|
- [ ] I checked there is no similar issue already reported
|
||||||
|
- [ ] I checked the documentation on the [wiki](https://github.com/raysan5/raylib/wiki)
|
||||||
- [ ] My code has no errors or misuse of raylib
|
- [ ] My code has no errors or misuse of raylib
|
||||||
|
|
||||||
### Issue description
|
### Issue description
|
||||||
|
|
|
||||||
2
.github/workflows/linux.yml
vendored
|
|
@ -22,7 +22,7 @@ jobs:
|
||||||
build:
|
build:
|
||||||
permissions:
|
permissions:
|
||||||
contents: write # for actions/upload-release-asset to upload release asset
|
contents: write # for actions/upload-release-asset to upload release asset
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-20.04
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
max-parallel: 1
|
max-parallel: 1
|
||||||
|
|
|
||||||
2
.github/workflows/webassembly.yml
vendored
|
|
@ -27,7 +27,7 @@ jobs:
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@master
|
||||||
|
|
||||||
- name: Setup emsdk
|
- name: Setup emsdk
|
||||||
uses: mymindstorm/setup-emsdk@v11
|
uses: mymindstorm/setup-emsdk@v12
|
||||||
with:
|
with:
|
||||||
version: 3.1.30
|
version: 3.1.30
|
||||||
actions-cache-folder: 'emsdk-cache'
|
actions-cache-folder: 'emsdk-cache'
|
||||||
|
|
|
||||||
3
.gitignore
vendored
|
|
@ -75,6 +75,9 @@ xcschememanagement.plist
|
||||||
xcuserdata/
|
xcuserdata/
|
||||||
DerivedData/
|
DerivedData/
|
||||||
|
|
||||||
|
# VSCode project
|
||||||
|
.vscode
|
||||||
|
|
||||||
# Jetbrains project
|
# Jetbrains project
|
||||||
.idea/
|
.idea/
|
||||||
cmake-build-*/
|
cmake-build-*/
|
||||||
|
|
|
||||||
42
BINDINGS.md
|
|
@ -8,56 +8,63 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
||||||
|:------------------:|:---------------:|:---------:|:----------:|-----------------------------------------------------------|
|
|:------------------:|:---------------:|:---------:|:----------:|-----------------------------------------------------------|
|
||||||
| raylib | **4.5** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib | https://github.com/raysan5/raylib |
|
| raylib | **4.5** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib | https://github.com/raysan5/raylib |
|
||||||
| raylib-boo | 3.7 | [Boo](http://boo-language.github.io/)| MIT | https://github.com/Rabios/raylib-boo |
|
| raylib-boo | 3.7 | [Boo](http://boo-language.github.io/)| MIT | https://github.com/Rabios/raylib-boo |
|
||||||
| Raylib-cs | 4.2 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib | https://github.com/ChrisDill/Raylib-cs |
|
| Raylib-cs | **4.5** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib | https://github.com/ChrisDill/Raylib-cs |
|
||||||
| Raylib-CsLo | 4.2 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | https://github.com/NotNotTech/Raylib-CsLo |
|
| Raylib-CsLo | 4.2 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | https://github.com/NotNotTech/Raylib-CsLo |
|
||||||
| cl-raylib | 4.0 | [Common Lisp](https://common-lisp.net/) | MIT | https://github.com/longlene/cl-raylib |
|
| cl-raylib | 4.0 | [Common Lisp](https://common-lisp.net/) | MIT | https://github.com/longlene/cl-raylib |
|
||||||
| claylib/wrap | 4.2 | [Common Lisp](https://common-lisp.net/) | Zlib | https://github.com/defun-games/claylib |
|
| claylib/wrap | **4.5** | [Common Lisp](https://common-lisp.net/) | Zlib | https://github.com/defun-games/claylib |
|
||||||
|
| claw-raylib | **auto** | [Common Lisp](https://common-lisp.net/) | Apache-2.0 | https://github.com/bohonghuang/claw-raylib |
|
||||||
| chez-raylib | **auto** | [Chez Scheme](https://cisco.github.io/ChezScheme/) | GPLv3 | https://github.com/Yunoinsky/chez-raylib |
|
| chez-raylib | **auto** | [Chez Scheme](https://cisco.github.io/ChezScheme/) | GPLv3 | https://github.com/Yunoinsky/chez-raylib |
|
||||||
| raylib-cr | **4.5-dev (7e7939e)** | [Crystal](https://crystal-lang.org/) | Apache-2.0 | https://github.com/sol-vin/raylib-cr |
|
| raylib-cr | **4.6-dev (5e1a81)** | [Crystal](https://crystal-lang.org/) | Apache-2.0 | https://github.com/sol-vin/raylib-cr |
|
||||||
| ray-cyber | 4.5 | [Cyber](https://cyberscript.dev) | MIT | https://github.com/fubark/ray-cyber |
|
| ray-cyber | 4.5 | [Cyber](https://cyberscript.dev) | MIT | https://github.com/fubark/ray-cyber |
|
||||||
| raylib-c3 | **4.5-dev** | [C3](https://c3-lang.org/) | MIT | https://github.com/Its-Kenta/Raylib-C3 |
|
| raylib-c3 | **4.5** | [C3](https://c3-lang.org/) | Zlib | https://github.com/Its-Kenta/Raylib-C3 |
|
||||||
| dart-raylib | 4.0 | [Dart](https://dart.dev/) | MIT | https://gitlab.com/wolfenrain/dart-raylib |
|
| dart-raylib | 4.0 | [Dart](https://dart.dev/) | MIT | https://gitlab.com/wolfenrain/dart-raylib |
|
||||||
| bindbc-raylib3 | 4.0 | [D](https://dlang.org/) | BSL-1.0 | https://github.com/o3o/bindbc-raylib3 |
|
| bindbc-raylib3 | **4.5** | [D](https://dlang.org/) | BSL-1.0 | https://github.com/o3o/bindbc-raylib3 |
|
||||||
| dray | 4.2 | [D](https://dlang.org/) | Apache-2.0 | https://github.com/redthing1/dray |
|
| dray | 4.2 | [D](https://dlang.org/) | Apache-2.0 | https://github.com/redthing1/dray |
|
||||||
| raylib-d | **4.5** | [D](https://dlang.org/) | Zlib | https://github.com/schveiguy/raylib-d |
|
| raylib-d | **4.5** | [D](https://dlang.org/) | Zlib | https://github.com/schveiguy/raylib-d |
|
||||||
| dlang_raylib | 4.0 | [D](https://dlang.org) | MPL-2.0 |https://github.com/rc-05/dlang_raylib |
|
| dlang_raylib | 4.0 | [D](https://dlang.org) | MPL-2.0 |https://github.com/rc-05/dlang_raylib |
|
||||||
| rayex | 3.7 | [elixir](https://elixir-lang.org/) | Apache-2.0 | https://github.com/shiryel/rayex |
|
| rayex | 3.7 | [elixir](https://elixir-lang.org/) | Apache-2.0 | https://github.com/shiryel/rayex |
|
||||||
| raylib-factor | 4.0 | [Factor](https://factorcode.org/) | BSD | https://github.com/factor/factor/blob/master/extra/raylib/raylib.factor |
|
| raylib-factor | **4.5** | [Factor](https://factorcode.org/) | BSD | https://github.com/factor/factor/blob/master/extra/raylib/raylib.factor |
|
||||||
| raylib-freebasic | **4.5** | [FreeBASIC](https://www.freebasic.net/) | MIT | https://github.com/WIITD/raylib-freebasic |
|
| raylib-freebasic | **4.5** | [FreeBASIC](https://www.freebasic.net/) | MIT | https://github.com/WIITD/raylib-freebasic |
|
||||||
|
| fortran-raylib | **4.5** | [Fortran](https://fortran-lang.org/) | ISC | https://github.com/interkosmos/fortran-raylib |
|
||||||
| raylib for Pascal | **4.5** | [Object Pascal](https://en.wikipedia.org/wiki/Object_Pascal) | Modified Zlib | https://github.com/tinyBigGAMES/raylib |
|
| raylib for Pascal | **4.5** | [Object Pascal](https://en.wikipedia.org/wiki/Object_Pascal) | Modified Zlib | https://github.com/tinyBigGAMES/raylib |
|
||||||
| raylib-go | 4.2 | [Go](https://golang.org/) | Zlib | https://github.com/gen2brain/raylib-go |
|
| raylib-go | 4.5 | [Go](https://golang.org/) | Zlib | https://github.com/gen2brain/raylib-go |
|
||||||
| raylib-guile | **auto** | [Guile](https://www.gnu.org/software/guile/) | Zlib | https://github.com/petelliott/raylib-guile |
|
| raylib-guile | **auto** | [Guile](https://www.gnu.org/software/guile/) | Zlib | https://github.com/petelliott/raylib-guile |
|
||||||
| gforth-raylib | 3.5 | [Gforth](https://gforth.org/) | MIT | https://github.com/ArnautDaniel/gforth-raylib |
|
| gforth-raylib | 3.5 | [Gforth](https://gforth.org/) | MIT | https://github.com/ArnautDaniel/gforth-raylib |
|
||||||
| h-raylib | **4.5** | [Haskell](https://haskell.org/) | Apache-2.0 | https://github.com/Anut-py/h-raylib |
|
| h-raylib | **4.6-dev** | [Haskell](https://haskell.org/) | Apache-2.0 | https://github.com/Anut-py/h-raylib |
|
||||||
| raylib-hx | 4.2 | [Haxe](https://haxe.org/) | Zlib | https://github.com/foreignsasquatch/raylib-hx |
|
| raylib-hx | 4.2 | [Haxe](https://haxe.org/) | Zlib | https://github.com/foreignsasquatch/raylib-hx |
|
||||||
| hb-raylib | 3.5 | [Harbour](https://harbour.github.io) | MIT | https://github.com/MarcosLeonardoMendezGerencir/hb-raylib |
|
| hb-raylib | 3.5 | [Harbour](https://harbour.github.io) | MIT | https://github.com/MarcosLeonardoMendezGerencir/hb-raylib |
|
||||||
|
| jaylib | 4.5 | [Janet](https://janet-lang.org/) | MIT | https://github.com/janet-lang/jaylib |
|
||||||
| jaylib | 4.2 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | GPLv3+CE | https://github.com/electronstudio/jaylib/ |
|
| jaylib | 4.2 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | GPLv3+CE | https://github.com/electronstudio/jaylib/ |
|
||||||
| raylib-j | 4.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | Zlib | https://github.com/CreedVI/Raylib-J |
|
| raylib-j | 4.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | Zlib | https://github.com/CreedVI/Raylib-J |
|
||||||
| raylib.jl | 4.2 | [Julia](https://julialang.org/) | Zlib | https://github.com/irishgreencitrus/raylib.jl |
|
| raylib.jl | 4.2 | [Julia](https://julialang.org/) | Zlib | https://github.com/irishgreencitrus/raylib.jl |
|
||||||
| kaylib | 3.7 | [Kotlin/native](https://kotlinlang.org) | ? | https://github.com/electronstudio/kaylib |
|
| kaylib | 3.7 | [Kotlin/native](https://kotlinlang.org) | ? | https://github.com/electronstudio/kaylib |
|
||||||
| kaylib | **4.5**| [Kotlin/native](https://kotlinlang.org) | Zlib | https://codeberg.org/Soutaisei/Kaylib |
|
| KaylibKit | **4.5**| [Kotlin/native](https://kotlinlang.org) | Zlib | https://codeberg.org/Kenta/KaylibKit |
|
||||||
| raylib-lua | **4.5** | [Lua](http://www.lua.org/) | ISC | https://github.com/TSnake41/raylib-lua |
|
| raylib-lua | **4.5** | [Lua](http://www.lua.org/) | ISC | https://github.com/TSnake41/raylib-lua |
|
||||||
| raylua | 4.0 | [Lua](http://www.lua.org/) | MIT | https://github.com/Rabios/raylua |
|
| raylua | 4.0 | [Lua](http://www.lua.org/) | MIT | https://github.com/Rabios/raylua |
|
||||||
|
| raylib-matte | 4.6-dev | [Matte](https://github.com/jcorks/matte/) | MIT | https://github.com/jcorks/raylib-matte |
|
||||||
| nelua-raylib | 4.0 | [nelua](https://nelua.io/) | MIT | https://github.com/AKDev21/nelua-raylib |
|
| nelua-raylib | 4.0 | [nelua](https://nelua.io/) | MIT | https://github.com/AKDev21/nelua-raylib |
|
||||||
| Raylib-Nelua | **4.5-dev** | [nelua](https://nelua.io/) | MIT | https://github.com/Its-Kenta/Raylib-Nelua |
|
| Raylib.nelua | **4.5** | [nelua](https://nelua.io/) | Zlib | https://github.com/Its-Kenta/Raylib-Nelua |
|
||||||
| NimraylibNow! | 4.2 | [Nim](https://nim-lang.org/) | MIT | https://github.com/greenfork/nimraylib_now |
|
| NimraylibNow! | 4.2 | [Nim](https://nim-lang.org/) | MIT | https://github.com/greenfork/nimraylib_now |
|
||||||
|
| raylib-bindings | **4.5** | [Ruby](https://www.ruby-lang.org/en/) | Zlib | https://github.com/vaiorabbit/raylib-bindings |
|
||||||
| raylib-Forever | auto | [Nim](https://nim-lang.org/) | ? | https://github.com/Guevara-chan/Raylib-Forever |
|
| raylib-Forever | auto | [Nim](https://nim-lang.org/) | ? | https://github.com/Guevara-chan/Raylib-Forever |
|
||||||
| naylib | auto | [Nim](https://nim-lang.org/) | MIT | https://github.com/planetis-m/naylib |
|
| naylib | auto | [Nim](https://nim-lang.org/) | MIT | https://github.com/planetis-m/naylib |
|
||||||
| node-raylib | **4.5** | [Node.js](https://nodejs.org/en/) | Zlib | https://github.com/RobLoach/node-raylib |
|
| node-raylib | **4.5** | [Node.js](https://nodejs.org/en/) | Zlib | https://github.com/RobLoach/node-raylib |
|
||||||
| raylib-odin | **4.5** | [Odin](https://odin-lang.org/) | BSD-3Clause | https://github.com/odin-lang/Odin/tree/master/vendor/raylib |
|
| raylib-odin | **4.5** | [Odin](https://odin-lang.org/) | BSD-3Clause | https://github.com/odin-lang/Odin/tree/master/vendor/raylib |
|
||||||
| raylib_odin_bindings | 4.0-dev | [Odin](https://odin-lang.org/) | MIT | https://github.com/Deathbat2190/raylib_odin_bindings |
|
| raylib_odin_bindings | 4.0-dev | [Odin](https://odin-lang.org/) | MIT | https://github.com/Deathbat2190/raylib_odin_bindings |
|
||||||
| raylib-ocaml | 4.2 | [OCaml](https://ocaml.org/) | MIT | https://github.com/tjammer/raylib-ocaml |
|
| raylib-ocaml | **4.5** | [OCaml](https://ocaml.org/) | MIT | https://github.com/tjammer/raylib-ocaml |
|
||||||
| TurboRaylib | 4.2 | [Object Pascal](https://en.wikipedia.org/wiki/Object_Pascal) | MIT | https://github.com/turborium/TurboRaylib |
|
| TurboRaylib | **4.5** | [Object Pascal](https://en.wikipedia.org/wiki/Object_Pascal) | MIT | https://github.com/turborium/TurboRaylib |
|
||||||
| Ray4Laz | **4.5** | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal)| Zlib | https://github.com/GuvaCode/Ray4Laz |
|
| Ray4Laz | **4.5** | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal)| Zlib | https://github.com/GuvaCode/Ray4Laz |
|
||||||
| Raylib.4.0.Pascal | 4.0 | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal)| Zlib | https://github.com/sysrpl/Raylib.4.0.Pascal |
|
| Raylib.4.0.Pascal | 4.0 | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal)| Zlib | https://github.com/sysrpl/Raylib.4.0.Pascal |
|
||||||
| pyraylib | 3.7 | [Python](https://www.python.org/) | Zlib | https://github.com/Ho011/pyraylib |
|
| pyraylib | 3.7 | [Python](https://www.python.org/) | Zlib | https://github.com/Ho011/pyraylib |
|
||||||
| raylib-python-cffi | 4.2 | [Python](https://www.python.org/) | EPL-2.0 | https://github.com/electronstudio/raylib-python-cffi |
|
| raylib-python-cffi | 4.2 | [Python](https://www.python.org/) | EPL-2.0 | https://github.com/electronstudio/raylib-python-cffi |
|
||||||
| raylibpyctbg | **4.5** | [Python](https://www.python.org/) | MIT | https://github.com/overdev/raylibpyctbg |
|
| raylibpyctbg | **4.5** | [Python](https://www.python.org/) | MIT | https://github.com/overdev/raylibpyctbg |
|
||||||
| raylib-py | **4.5** | [Python](https://www.python.org/) | MIT | https://github.com/overdev/raylib-py |
|
| raylib-py | **4.5** | [Python](https://www.python.org/) | MIT | https://github.com/overdev/raylib-py |
|
||||||
| raylib-python-ctypes | 4.2 | [Python](https://www.python.org/) | MIT | https://github.com/sDos280/raylib-python-ctypes |
|
| raylib-python-ctypes | 4.6-dev | [Python](https://www.python.org/) | MIT | https://github.com/sDos280/raylib-python-ctypes |
|
||||||
| raylib-php | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib | https://github.com/joseph-montanez/raylib-php |
|
| raylib-pkpy-bindings | 4.6-dev | [pocketpy](https://pocketpy.dev/) | MIT | https://github.com/blueloveTH/pkpy-bindings |
|
||||||
|
| raylib-php | **4.5** | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib | https://github.com/joseph-montanez/raylib-php |
|
||||||
| raylib-phpcpp | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib | https://github.com/oraoto/raylib-phpcpp |
|
| raylib-phpcpp | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib | https://github.com/oraoto/raylib-phpcpp |
|
||||||
| raylibr | 4.0 | [R](https://www.r-project.org) | MIT | https://github.com/jeroenjanssens/raylibr |
|
| raylibr | 4.0 | [R](https://www.r-project.org) | MIT | https://github.com/jeroenjanssens/raylibr |
|
||||||
|
| raylib-ffi | 4.5 | [Rust](https://www.rust-lang.org/) | GPLv3 | https://github.com/ewpratten/raylib-ffi |
|
||||||
| raylib-rs | 3.5 | [Rust](https://www.rust-lang.org/) | Zlib | https://github.com/deltaphc/raylib-rs |
|
| raylib-rs | 3.5 | [Rust](https://www.rust-lang.org/) | Zlib | https://github.com/deltaphc/raylib-rs |
|
||||||
| Relib | 3.5 | [ReCT](https://github.com/RedCubeDev-ByteSpace/ReCT) | ? | https://github.com/RedCubeDev-ByteSpace/Relib |
|
| Relib | 3.5 | [ReCT](https://github.com/RedCubeDev-ByteSpace/ReCT) | ? | https://github.com/RedCubeDev-ByteSpace/Relib |
|
||||||
| racket-raylib | 4.0 | [Racket](https://racket-lang.org/) | MIT/Apache-2.0 | https://github.com/eutro/racket-raylib |
|
| racket-raylib | 4.0 | [Racket](https://racket-lang.org/) | MIT/Apache-2.0 | https://github.com/eutro/racket-raylib |
|
||||||
|
|
@ -73,14 +80,16 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
||||||
| hare-raylib | **auto** | [Hare](https://harelang.org/) | Zlib | https://git.sr.ht/~evantj/hare-raylib |
|
| hare-raylib | **auto** | [Hare](https://harelang.org/) | Zlib | https://git.sr.ht/~evantj/hare-raylib |
|
||||||
| raylib-sunder | **auto** | [Sunder](https://github.com/ashn-dot-dev/sunder) | 0BSD | https://github.com/ashn-dot-dev/raylib-sunder |
|
| raylib-sunder | **auto** | [Sunder](https://github.com/ashn-dot-dev/sunder) | 0BSD | https://github.com/ashn-dot-dev/raylib-sunder |
|
||||||
| rayed-bqn | **auto** | [BQN](https://mlochbaum.github.io/BQN/) | MIT | https://github.com/Brian-ED/rayed-bqn |
|
| rayed-bqn | **auto** | [BQN](https://mlochbaum.github.io/BQN/) | MIT | https://github.com/Brian-ED/rayed-bqn |
|
||||||
|
| rayjs | 4.6-dev | [QuickJS](https://bellard.org/quickjs/) | MIT | https://github.com/mode777/rayjs |
|
||||||
|
| raylib-raku | **auto** | [Raku](https://www.raku.org/) | Artistic License 2.0 | https://github.com/vushu/raylib-raku |
|
||||||
|
| Raylib.lean | 4.5 | [Lean4](https://lean-lang.org/) | BSD-3-Clause | https://github.com/KislyjKisel/Raylib.lean |
|
||||||
|
|
||||||
### Utility Wrapers
|
### 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.
|
These are utility wrappers for specific languages, they are not required to use raylib in the language but may adapt the raylib API to be more inline with the language's pardigm.
|
||||||
| name | raylib version | language | license | repo |
|
| name | raylib version | language | license | repo |
|
||||||
|:------------------:|:-------------: | :--------:|:-------:|:-------------------------------------------------------------|
|
|:------------------:|:-------------: | :--------:|:-------:|:-------------------------------------------------------------|
|
||||||
| raylib-cpp | **4.5** | [C++](https://en.wikipedia.org/wiki/C%2B%2B) | Zlib | https://github.com/robloach/raylib-cpp |
|
| raylib-cpp | **4.5** | [C++](https://en.wikipedia.org/wiki/C%2B%2B) | Zlib | https://github.com/robloach/raylib-cpp |
|
||||||
| claylib | **4.2** | [Common Lisp](https://common-lisp.net/) | Zlib | https://github.com/defun-games/claylib |
|
| claylib | **4.5** | [Common Lisp](https://common-lisp.net/) | Zlib | https://github.com/defun-games/claylib |
|
||||||
|
|
||||||
### Older or Unmaintained Language Bindings
|
### Older or Unmaintained Language Bindings
|
||||||
These are older raylib bindings that are more than 2 versions old or have not been maintained.
|
These are older raylib bindings that are more than 2 versions old or have not been maintained.
|
||||||
|
|
@ -133,7 +142,6 @@ These are older raylib bindings that are more than 2 versions old or have not be
|
||||||
| raylib-jai | 3.1-dev | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | https://github.com/kujukuju/raylib-jai |
|
| raylib-jai | 3.1-dev | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | https://github.com/kujukuju/raylib-jai |
|
||||||
| ray.zig | 2.5 | [Zig](https://ziglang.org/) | https://github.com/BitPuffin/zig-raylib-experiments |
|
| 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 |
|
|
||||||
| raykit | ? | [Kit](https://www.kitlang.org/) | https://github.com/Gamerfiend/raykit |
|
| raykit | ? | [Kit](https://www.kitlang.org/) | https://github.com/Gamerfiend/raykit |
|
||||||
| ray.mod | 3.0 | [BlitzMax](https://blitzmax.org/) | https://github.com/bmx-ng/ray.mod |
|
| ray.mod | 3.0 | [BlitzMax](https://blitzmax.org/) | https://github.com/bmx-ng/ray.mod |
|
||||||
| raylib-mosaic | 3.0 | [Mosaic](https://github.com/sal55/langs/tree/master/Mosaic) | https://github.com/pluckyporcupine/raylib-mosaic |
|
| raylib-mosaic | 3.0 | [Mosaic](https://github.com/sal55/langs/tree/master/Mosaic) | https://github.com/pluckyporcupine/raylib-mosaic |
|
||||||
|
|
|
||||||
210
CHANGELOG
|
|
@ -3,6 +3,212 @@ changelog
|
||||||
|
|
||||||
Current Release: raylib 4.5.0 (18 March 2023)
|
Current Release: raylib 4.5.0 (18 March 2023)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
Release: raylib 5.0 (xx November 2023) -WIP-
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
KEY CHANGES:
|
||||||
|
- REDESIGNED: rcore module split per-platform, by @ubkp, @michaelfiber, @Bigfoot71, @raysan5
|
||||||
|
- REMOVED: Deprecated platform: PLATFORM_RPI, use PLATFORM_DRM instead
|
||||||
|
- ADDED: New platform backend supported: SDL
|
||||||
|
- ADDED: New platform backend supported: Nintendo Switch (closed source)
|
||||||
|
- REDESIGNED: Automation Events System (exposed API)
|
||||||
|
|
||||||
|
Detailed changes:
|
||||||
|
[rcore] ADDED: RAYLIB_VERSION_* values to raylib.h (#2856) by @RobLoach
|
||||||
|
[rcore] ADDED: IsKeyPressedRepeat() on PLATFORM_DESKTOP (#3245) by @actondev
|
||||||
|
[rcore] ADDED: SetWindowTitle() for PLATFORM_WEB (#3222) by @VitusVeit
|
||||||
|
[rcore] ADDED: FLAG_WINDOW_RESIZABLE for web (#3305) by @Peter0x44
|
||||||
|
[rcore] ADDED: SetWindowMaxSize() for desktop and web (#3309) by @ubkp
|
||||||
|
[rcore] ADDED: SetMouseCursor() for PLATFORM_WEB (#3414) by @BeardedBread
|
||||||
|
[rcore] REMOVED: PLATFORM_RPI (#3232) by @michaelfiber
|
||||||
|
[rcore] REVIEWED: GetFileLength(), added comment (#3262) by @raysan5
|
||||||
|
[rcore] REVIEWED: Default shaders precission issue on PLATFORM_WEB (#3261) by @branc116
|
||||||
|
[rcore] REVIEWED: IsKey*() key validation checks (#3256) by @n77y
|
||||||
|
[rcore] REVIEWED: SetClipboardText() for PLATFORM_WEB (#3257) by @ubkp
|
||||||
|
[rcore] REVIEWED: Check if Ctrl modifier is among the currently set modifiers (#3230) by @mohad12211
|
||||||
|
[rcore] REVIEWED: Android app black screen when reopening by @Bigfoot71
|
||||||
|
[rcore] REVIEWED: Warnings when casting int to floats (#3218) by @JeffM2501
|
||||||
|
[rcore] REVIEWED: GetCurrentMonitor() detection inconsistency issue (#3215) by @ubkp
|
||||||
|
[rcore] REVIEWED: SetWindowMonitor() to no longer force fullscreen (#3209) by @ubkp
|
||||||
|
[rcore] REVIEWED: Fix mouse wheel not working in PLATFORM_RPI or PLATFORM_DRM (#3193) by @ubkp
|
||||||
|
[rcore] REVIEWED: GetMonitorName() description (#3184) (#3189) by @danilwhale
|
||||||
|
[rcore] REVIEWED: Window flags order (#3114) by @lesleyrs
|
||||||
|
[rcore] REVIEWED: Full movement for right analog stick (#3095) by @PixelPhobicGames
|
||||||
|
[rcore] REVIEWED: Fix Android app freeze after calling CloseWindow() (#3067) by @Bigfoot71
|
||||||
|
[rcore] REVIEWED: Lazy loading of default font used on image drawing (no InitWindow) by @raysan5
|
||||||
|
[rcore] REVIEWED: Minor tweaks to raylib events automation system @raysan5
|
||||||
|
[rcore] REVIEWED: GetCurrentMonitor() bugfix (#3058) by @hamyyy
|
||||||
|
[rcore] REVIEWED: Update CORE.Input.Touch.pointCount (#3024) by @raysan5
|
||||||
|
[rcore] REVIEWED: Mouse offset and scaling must be considered also on web!
|
||||||
|
[rcore] REVIEWED: CompressData(), possible stack overflow
|
||||||
|
[rcore] REVIEWED: GetWorldToScreenEx() (#3351) by @Brian-ED
|
||||||
|
[rcore] REVIEWED: Fix GetMouseDelta() issue for Android (#3404) by @Bigfoot71
|
||||||
|
[rlgl] ADDED: Experimental support for OpenGL ES 3.0 by @raysan5
|
||||||
|
[rlgl] ADDED: Support 16-Bit HDR textures (#3220) by @Not-Nik
|
||||||
|
[rlgl] REVIEWED: Improved support for ES3/WebGL2 (#3107) by @chemaguerra
|
||||||
|
[rlgl] REVIEWED: OpenGL 2.1 half floats support as part of an extension by @Not-Nik
|
||||||
|
[rlgl] REVIEWED: Avoid shader attribute not found log by @raysan5
|
||||||
|
[rlgl] REVIEWED: Avoid tracelog about not found uniforms (#3003) by @raysan5
|
||||||
|
[rlgl] REVIEWED: rLoadTexture() UBSAN complaints #1891 (#3321) by @Codom
|
||||||
|
[rlgl] REVIEWED: glInternalFormat as unsigned int
|
||||||
|
[rshapes] ADDED: Spline drawing functions by @raysan5
|
||||||
|
[rshapes] REVIEWED: DrawLineCatmullRom() by @raysan5
|
||||||
|
[rshapes] REVIEWED: Minor fix in DrawLineBezier* (#3006) by @eternalStudent
|
||||||
|
[rshapes] REVIEWED: GetCollisionRec(), more performant (#3052) by @manuel5975p
|
||||||
|
[rshapes] REVIEWED: Fix off-by-one error in CheckCollisionPointRec() (#3022) by @dbechrd
|
||||||
|
[rtextures] ADDED: Basic SVG loading support (#2738) by @bXi
|
||||||
|
[rtextures] ADDED: Support 16-Bit HDR textures (#3220) by @Not-Nik
|
||||||
|
[rtextures] ADDED: ExportImageToMemory() by @raysan5
|
||||||
|
[rtextures] ADDED: ImageRotate() (#3078) by @danemadsen
|
||||||
|
[rtextures] ADDED: GenImageGradientSquare() (#3077) by @danemadsen
|
||||||
|
[rtextures] ADDED: GenImageLinearGradient() by @danemadsen
|
||||||
|
[rtextures] REMOVED: GenImageGradientH() and GenImageGradientV() by @danemadsen
|
||||||
|
[rtextures] REVIEWED: LoadImageSvg() by @raysan5
|
||||||
|
[rtextures] REVIEWED: Uninitialized thread-locals in stbi (#3282) (#3283) by @jbarthelmes
|
||||||
|
[rtextures] REVIEWED: ImageDrawRectangleRec(), validate drawing inside bounds by @JeffM2501
|
||||||
|
[rtextures] REVIEWED: LoadTextureCubemap() for manual layouts (#3204) by @Not-Nik
|
||||||
|
[rtextures] REVIEWED: Optimization of ImageDrawRectangleRec() (#3185) by @smalltimewizard
|
||||||
|
[rtextures] REVIEWED: ImageRotate() formatting by @raysan5
|
||||||
|
[rtextures] REVIEWED: GenImagePerlinNoise(), clamp values (#3071) by @raysan5
|
||||||
|
[rtextures] REVIEWED: Packing logic error in GenImageFontAtlas() (#2979) by @hanaxar
|
||||||
|
[rtextures] REVIEWED: Calculate exact image size in GenImageFontAtlas() (#2963) by @hanaxar
|
||||||
|
[rtextures] REVIEWED: ImageDrawRectangleRec() (#3027) by @raysan5
|
||||||
|
[rtextures] REVIEWED: ImageDraw() source clipping when drawing beyond top left (#3306) by @RobLoach
|
||||||
|
[rtextures] REVIEWED: UnloadRenderTexture(), additional checks
|
||||||
|
[rtext] ADDED: Font altas white rectangle and flag SUPPORT_FONT_ATLAS_WHITE_REC by @raysan5
|
||||||
|
[rtext] ADDED: SetTextLineSpacing() to define line breaks text drawing spacing by @raysan5
|
||||||
|
[rtext] RENAMED: LoadFont*() parameter names for consistency and coherence by @raysan5
|
||||||
|
[rtext] REVIEWED: GetCodepointCount(), ignore unused return value of GetCodepointNext by @ashn-dot-dev
|
||||||
|
[rtext] REVIEWED: TextFormat() warn user if buffer overflow occured (#3399) by @Murlocohol
|
||||||
|
[rtext] REVIEWED: TextFormat(), added "..." for truncation (#3366) by @raysan5
|
||||||
|
[rtext] REVIEWED: GetGlyphIndex() (#3000) by @raysan5
|
||||||
|
[rtext] REVIEWED: GetCodepointNext() to return default value on invalid inp… by @chocolate42
|
||||||
|
[rtext] REVIEWED: TextToPascal() issue when first char is uppercase
|
||||||
|
[rmodels] ADDED: ModelAnimation.name field, initially with GLTF animation names loaded (… by @alfredbaudisch
|
||||||
|
[rmodels] REVIEWED: Support .vox model files version 200 (#3097) by @Bigfoot71
|
||||||
|
[rmodels] REVIEWED: Materials loading (#3126) @raysan5
|
||||||
|
[rmodels] REVIEWED: DrawBillboardPro() to allow source of negative size (#3197) by @bohonghuang
|
||||||
|
[rmodels] REVIEWED: glTF loading segfault in animNormals memcpy by @charles-l
|
||||||
|
[rmodels] REVIEWED: LoadModelAnimationsGLTF(), free fileData after use (#3065) by @crynux
|
||||||
|
[rmodels] REVIEWED: GenMeshCubicmap(), correction of values (#3032) by @Bigfoot71
|
||||||
|
[rmodels] REVIEWED: DrawMesh() to avoid UBSAN complaining (#1891)
|
||||||
|
[rmodels] REVIEWED: GenMeshPlane() when resX != resZ (#3425) by @neyrox, @s-yablonskiy
|
||||||
|
[raudio] ADDED: LoadSoundAlias() by @JeffM2501
|
||||||
|
[raudio] ADDED: Missing structure on standalone mode (#3160) by @raysan5
|
||||||
|
[raudio] ADDED: GetMasterVolume() (#3434) by @rexim
|
||||||
|
[raudio] REVIEWED: Comments about sample format to AttachAudioStreamProcessor() (#3188) by @AlbertoGP
|
||||||
|
[raudio] REVIEWED: Documented buffer format for audio processors (#3186) by @AlbertoGP
|
||||||
|
[raudio] REVIEWED: ExportWaveAsCode() file saving by @RadsammyT
|
||||||
|
[raudio] REVIEWED: Fix warning on discarded const qualifier (#2967) by @RobLoach
|
||||||
|
[raudio] REVIEWED: Move mutex initialization before ma_device_start() (#3325) by @Bigfoot71
|
||||||
|
[raudio] REVIEWED: Fix UpdateSound() parameter name (#3405) by @KislyjKisel
|
||||||
|
[rcamera] REVIEWED: File-macros for consistency (#3161) by @raysan5
|
||||||
|
[rcamera] REVIEWED: Support analog stick camera controls (#3066) by @PixelPhobicGames
|
||||||
|
[rcamera] REVIEWED: CameraMoveToTarget(), ensure distance is greater than 0 (#3031) by @kolunmi
|
||||||
|
[rcamera] REVIEWED: Exposing rcamera functions to the dll (#3355) by @JeffM2501
|
||||||
|
[raymath] ADDED: Vector3Projection() and Vector3Rejection() (#3263) by @Dial0
|
||||||
|
[raymath] ADDED: EPSILON macro to each function requiring it (#3330) by @Brian-ED
|
||||||
|
[raymath] REVIEWED: Usage of 'sinf()' and 'cosf()' to be correct (#3181) by @RokasPuzonas
|
||||||
|
[raymath] REVIEWED: Slightly optimized Vector3Normalize() (#2982) by @RicoP
|
||||||
|
[raymath] REVIEWED: Comment to clarify raymath semantics by @raysan5
|
||||||
|
[raymath] REVIEWED: Comment about Matrix conventions by @raysan5
|
||||||
|
[raymath] REVIEWED: Vector2Angle() and Vector2LineAngle() (#3396) by @Murlocohol
|
||||||
|
[rgestures] REVIEWED: Optimize and simplify the gesture system (#3190) by @ubkp
|
||||||
|
[rgestures] REVIEWED: GESTURE_DRAG and GESTURE_SWIPE_* issues (mostly) for web (#3183) by @ubkp
|
||||||
|
[rgestures] REVIEWED: Touch pointCount for web (#3163) by @ubkp
|
||||||
|
[rgestures] REVIEWED: IsGestureDetected() parameter type
|
||||||
|
[utils] ADDED: Security checks to file reading (memory allocations) by @raysan5
|
||||||
|
[utils] REVIEWED: LoadFileData() potential issues with dataSize
|
||||||
|
[examples] ADDED: shaders_lightmap (#3043) by @nullstare
|
||||||
|
[examples] ADDED: core_2d_camera_split_screen (#3298) by @gabrielssanches
|
||||||
|
[examples] ADDED: LoadSoundAlias() usage example (#3223) by @JeffM2501
|
||||||
|
[examples] ADDED: textures_tiling (#3353) by @luis605
|
||||||
|
[examples] RENAMED: 2d_camera examples for consistency
|
||||||
|
[examples] REVIEWED: Text examples SetTextLineSpacing() to multiline examples by @raysan5
|
||||||
|
[examples] REVIEWED: examples/shapes/shapes_collision_area.c help instructions (#3279) by @asdqwe
|
||||||
|
[examples] REVIEWED: examples/shaders/shaders_texture_outline.c help instructions (#3278) by @asdqwe
|
||||||
|
[examples] REVIEWED: examples/others/easings_testbed.c help instructions and small twe… by @asdqwe
|
||||||
|
[examples] REVIEWED: example/audio/audio_module_player.c help instructions and small b… by @asdqwe
|
||||||
|
[examples] REVIEWED: example/models/models_loading_m3d.c controls (#3269) by @asdqwe
|
||||||
|
[examples] REVIEWED: example/models/models_loading_gltf.c controls (#3268) by @asdqwe
|
||||||
|
[examples] REVIEWED: text_unicode.c example crashing (#3250) by @ubkp
|
||||||
|
[examples] REVIEWED: rlgl_standalone.c compilation issue (#3242) by @ubkp
|
||||||
|
[examples] REVIEWED: core_input_gestures for Web (#3172) by @ubkp
|
||||||
|
[examples] REVIEWED: core_input_gamepad (#3110) by @iacore
|
||||||
|
[examples] REVIEWED: examples using raygui to raygui 4.0 by @raysan5
|
||||||
|
[build] ADDED: CMake option for SUPPORT_CUSTOM_FRAME_CONTROL (#3221) by @ubkp
|
||||||
|
[build] ADDED: New BORDERLESS_WINDOWED_MODE for PLATFORM_DESKTOP (#3216) by @ubkp
|
||||||
|
[build] REVIEWED: Fix CMake extraneous -lglfw (#3266) by @iacore
|
||||||
|
[build] REVIEWED: Add missing cmake options (#3267) by @asdqwe
|
||||||
|
[build] REVIEWED: Match CMakeOptions.txt options default values (#3258) by @asdqwe
|
||||||
|
[build] REVIEWED: Add build.zig options for individual modules (#3254) by @actondev
|
||||||
|
[build] REVIEWED: build.zig to work with cross-compiling (#3225) by @yujiri8
|
||||||
|
[build] REVIEWED: Makefile build on PLATFORM_ANDROID, soname (#3211) by @ndytts
|
||||||
|
[build] REVIEWED: src/Makefile, fix misleading indentation (#3202) by @ashn-dot-dev
|
||||||
|
[build] REVIEWED: build.zig: Support for building with PLAFORM_DRM (#3191) by @jakubvf
|
||||||
|
[build] REVIEWED: Update CMakeOptions.txt by @raysan5
|
||||||
|
[build] REVIEWED: fix: cmake option "OPENGL_VERSION" doesn't work (#3170) by @royqh1979
|
||||||
|
[build] REVIEWED: Add error if raylib.h is included in a C++98 program (#3093) by @Peter0x44
|
||||||
|
[build] REVIEWED: Cross compilation for PLATFORM_DRM (#3091) by @TheLastBilly
|
||||||
|
[build] REVIEWED: build.zigm fixed cross-compiling from Linux (#3090)by @yujiri8
|
||||||
|
[build] REVIEWED: Enhanced cmake part for OpenBSD (#3086) by @rayit
|
||||||
|
[build] REVIEWED: Fixed compile on OpenBSD (#3085)by @rayit
|
||||||
|
[build] REVIEWED: CMake project example: fix a couple of typos (#3014) by @benjamin-thomas
|
||||||
|
[build] REVIEWED: Fix warnings in raylib for MSVC (#3004) by @JeffM2501
|
||||||
|
[build] REVIEWED: Update cmake example project (#3062) by @lesleyrs
|
||||||
|
[build] REVIEWED: Update build.zig be be able to build with current zig master (#3064) by @ryupold
|
||||||
|
[build] REVIEWED: VSCode project template (#3048) by @Shoozza
|
||||||
|
[build] REVIEWED: Fixed broken build.zig files. Now works with latest stable compiler (… by @Gamer-Kold
|
||||||
|
[build] REVIEWED: Fix missing symbol when rglfw.c on BSD platforms (#2968) by @Koromix
|
||||||
|
[build] REVIEWED: Update Makefile comment to indicate arm64 as a supported Linux deskto… @ashn-dot-dev
|
||||||
|
[build] REVIEWED: Update Makefile : clean raygui.c & physac.c (#3296) by @SuperUserNameMan
|
||||||
|
[build] REVIEWED: Update webassembly.yml and linux.yml
|
||||||
|
[build] REVIEWED: Update zig build system to zig version 0.11.0 (#3393) by @purple4pur
|
||||||
|
[build] REVIEWED: Fix for latest zig master (#3037) by @star-tek-mb
|
||||||
|
[build] REVIEWED: Examples Makefile to use Makefile.Web when building for web (#3449) by @keithstellyes
|
||||||
|
[bindings] ADDED: fortran-raylib
|
||||||
|
[bindings] ADDED: raylib-raku to bindings (#3299) by @vushu
|
||||||
|
[bindings] ADDED: claw-raylib to BINDINGS.md (#3310) by @bohonghuang
|
||||||
|
[bindings] ADDED: vaiorabbit/raylib-bindings (#3318) by @wilsonsilva
|
||||||
|
[bindings] ADDED: TurboRaylib (#3317) by @turborium
|
||||||
|
[bindings] ADDED: raylib-ffi to bindings list (#3164) by @ewpratten
|
||||||
|
[bindings] ADDED: raylib-pkpy-bindings (#3361) by @blueloveTH
|
||||||
|
[bindings] ADDED: Raylib.lean to BINDINGS.md (#3409) by @KislyjKisel
|
||||||
|
[bindings] UPDATED: BINDINGS.md (#3217) by @joseph-montanez
|
||||||
|
[bindings] UPDATED: BINDINGS.md to include rayjs (#3212) by @mode777
|
||||||
|
[bindings] UPDATED: latest h-raylib version (#3166) by @Anut-py
|
||||||
|
[bindings] UPDATED: bindbd-raylib3 to raylib 4.5 (#3157) by @o3o
|
||||||
|
[bindings] UPDATED: Janet bindings supported version update (#3083)by @archydragon
|
||||||
|
[bindings] UPDATED: BINDINGS.md (raylib-py -> 4.5) (#2992) by @overdev
|
||||||
|
[bindings] UPDATED: BINDINGS.md (raylib-lua -> 4.5) (#2989) by @TSnake41
|
||||||
|
[bindings] UPDATED: raylib-d binding version to 4.5 (#2988) by @schveiguy
|
||||||
|
[bindings] UPDATED: raylib-freebasic to 4.5 (#2986) by @WIITD
|
||||||
|
[bindings] UPDATED: BINDINGS.md (#2983) by @jarroddavis68
|
||||||
|
[bindings] UPDATED: BINDINGS.md for raylib Odin 4.5 (#2981) by @gingerBill
|
||||||
|
[bindings] UPDATED: BINDINGS.md (#2980) by @GuvaCode
|
||||||
|
[bindings] UPDATED: BINDINGS.md (#3002) by @fubark
|
||||||
|
[bindings] UPDATED: BINDINGS.md (#3053) by @JupiterRider
|
||||||
|
[bindings] UPDATED: BINDINGS.md (#3050) by @Its-Kenta
|
||||||
|
[bindings] UPDATED: CL bindings version (#3049) by @shelvick
|
||||||
|
[bindings] UPDATED: BINDINGS.md (#3026) by @ChrisDill
|
||||||
|
[bindings] UPDATED: BINDINGS.md (#3023) by @sDos280
|
||||||
|
[bindings] UPDATED: BINDINGS.md (#3017) by @Soutaisei
|
||||||
|
[bindings] UPDATED: Various versions to 4.5 (#2974) by @RobLoach
|
||||||
|
[bindings] UPDATED: raylib.zig version to 4.5 (#2971) by @ryupold
|
||||||
|
[bindings] UPDATED: h-raylib version (#2970) by @Anut-py
|
||||||
|
[bindings] UPDATED: Factor's raylib binding to v4.5 (#3350) by @WraithGlade
|
||||||
|
[bindings] UPDATED: raylib-ocaml bindings to 4.5 version (#3322) by @tjammer
|
||||||
|
[external] UPDATED: sdefl and sinfl DEFLATE compression libraries by @raysan5
|
||||||
|
[external] UPDATED: miniaudio v0.11.12 --> v0.11.18 by @raysan5
|
||||||
|
[external] UPDATED: rl_gputex.h compressed images loading library by @raysan5
|
||||||
|
[external] UPDATED: Replaced stb_image_resize.c by stb_image_resize2.h (#3403) by @BabakSamimi
|
||||||
|
[external] REVIEWED: msf_gif.h, some warnings
|
||||||
|
[misc] ADDED: New task point to issue template about checking the wiki (#3169) by @ubkp
|
||||||
|
[misc] REVIEWED: Update FAQ.md by @raysan5
|
||||||
|
[misc] REVIEWED: Fix a link in the FAQ (#3082)by @jasonliang-dev
|
||||||
|
[misc] REVIEWED: New file formats to FAQ (#3079) by @Luramoth
|
||||||
|
[misc] REVIEWED: Make assets loading extension case insensitive #3008 by @raysan5
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
Release: raylib 4.5 (18 March 2023)
|
Release: raylib 4.5 (18 March 2023)
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
|
|
@ -1665,9 +1871,9 @@ other changes:
|
||||||
[models] Added function DrawCubeTexture()
|
[models] Added function DrawCubeTexture()
|
||||||
[models] Added function DrawQuad()
|
[models] Added function DrawQuad()
|
||||||
[models] Added function DrawRay()
|
[models] Added function DrawRay()
|
||||||
[models] Simplified funtion DrawPlane()
|
[models] Simplified function DrawPlane()
|
||||||
[models] Removed function DrawPlaneEx()
|
[models] Removed function DrawPlaneEx()
|
||||||
[models] Simplified funtion DrawGizmo()
|
[models] Simplified function DrawGizmo()
|
||||||
[models] Removed function DrawGizmoEx()
|
[models] Removed function DrawGizmoEx()
|
||||||
[models] Added function LoadModelEx()
|
[models] Added function LoadModelEx()
|
||||||
[models] Review of function LoadCubicMap()
|
[models] Review of function LoadCubicMap()
|
||||||
|
|
|
||||||
|
|
@ -37,15 +37,18 @@ cmake_dependent_option(SUPPORT_MODULE_RAUDIO "Include module: raudio" ON CUSTOMI
|
||||||
# rcore.c
|
# rcore.c
|
||||||
cmake_dependent_option(SUPPORT_CAMERA_SYSTEM "Provide camera module (rcamera.h) with multiple predefined cameras: free, 1st/3rd person, orbital" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_CAMERA_SYSTEM "Provide camera module (rcamera.h) with multiple predefined cameras: free, 1st/3rd person, orbital" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_GESTURES_SYSTEM "Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_GESTURES_SYSTEM "Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag" ON CUSTOMIZE_BUILD ON)
|
||||||
|
cmake_dependent_option(SUPPORT_RPRAND_GENERATOR "Include pseudo-random numbers generator (rprand.h), based on Xoshiro128** and SplitMix64" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_MOUSE_GESTURES "Mouse gestures are directly mapped like touches and processed by gestures system" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_MOUSE_GESTURES "Mouse gestures are directly mapped like touches and processed by gestures system" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_SSH_KEYBOARD_RPI "Reconfigure standard input to receive key inputs, works with SSH connection" OFF CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_SSH_KEYBOARD_RPI "Reconfigure standard input to receive key inputs, works with SSH connection" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_DEFAULT_FONT "Default font is loaded on window initialization to be available for the user to render simple text. If enabled, uses external module functions to load default raylib font (module: text)" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_DEFAULT_FONT "Default font is loaded on window initialization to be available for the user to render simple text. If enabled, uses external module functions to load default raylib font (module: text)" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_SCREEN_CAPTURE "Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_SCREEN_CAPTURE "Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_GIF_RECORDING "Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_GIF_RECORDING "Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_BUSY_WAIT_LOOP "Use busy wait loop for timing sync instead of a high-resolution timer" OFF CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_BUSY_WAIT_LOOP "Use busy wait loop for timing sync instead of a high-resolution timer" OFF CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_EVENTS_WAITING "Wait for events passively (sleeping while no events) instead of polling them actively every frame" OFF CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_EVENTS_WAITING "Wait for events passively (sleeping while no events) instead of polling them actively every frame" OFF CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_WINMM_HIGHRES_TIMER "Setting a higher resolution can improve the accuracy of time-out intervals in wait functions" OFF CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_WINMM_HIGHRES_TIMER "Setting a higher resolution can improve the accuracy of time-out intervals in wait functions" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_COMPRESSION_API "Support for compression API" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_COMPRESSION_API "Support for compression API" ON CUSTOMIZE_BUILD ON)
|
||||||
|
cmake_dependent_option(SUPPORT_EVENTS_AUTOMATION "Support automatic generated events, loading and recording of those events when required" OFF CUSTOMIZE_BUILD OFF)
|
||||||
|
cmake_dependent_option(SUPPORT_CUSTOM_FRAME_CONTROL "Enabling this flag allows manual control of the frame processes, use at your own risk" OFF CUSTOMIZE_BUILD OFF)
|
||||||
|
|
||||||
# rshapes.c
|
# rshapes.c
|
||||||
cmake_dependent_option(SUPPORT_QUADS_DRAW_MODE "Use QUADS instead of TRIANGLES for drawing when possible. Some lines-based shapes could still use lines" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_QUADS_DRAW_MODE "Use QUADS instead of TRIANGLES for drawing when possible. Some lines-based shapes could still use lines" ON CUSTOMIZE_BUILD ON)
|
||||||
|
|
@ -57,22 +60,25 @@ cmake_dependent_option(SUPPORT_IMAGE_MANIPULATION "Support multiple image editin
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_PNG "Support loading PNG as textures" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_PNG "Support loading PNG as textures" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_DDS "Support loading DDS as textures" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_DDS "Support loading DDS as textures" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_HDR "Support loading HDR as textures" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_HDR "Support loading HDR as textures" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_PNM "Support loading PNM as textures" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_PIC "Support loading PIC as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_KTX "Support loading KTX as textures" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_PNM "Support loading PNM as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_ASTC "Support loading ASTC as textures" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_KTX "Support loading KTX as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||||
|
cmake_dependent_option(SUPPORT_FILEFORMAT_ASTC "Support loading ASTC as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_BMP "Support loading BMP as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_BMP "Support loading BMP as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_TGA "Support loading TGA as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_TGA "Support loading TGA as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_JPG "Support loading JPG as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_JPG "Support loading JPG as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_GIF "Support loading GIF as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_GIF "Support loading GIF as textures" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_QOI "Support loading QOI as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_QOI "Support loading QOI as textures" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_PSD "Support loading PSD as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_PSD "Support loading PSD as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_PKM "Support loading PKM as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_PKM "Support loading PKM as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_PVR "Support loading PVR as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_PVR "Support loading PVR as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||||
|
cmake_dependent_option(SUPPORT_FILEFORMAT_SVG "Support loading SVG as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||||
|
|
||||||
# rtext.c
|
# rtext.c
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_FNT "Support loading fonts in FNT format" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_FNT "Support loading fonts in FNT format" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_TTF "Support loading font in TTF/OTF format" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_TTF "Support loading font in TTF/OTF format" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_TEXT_MANIPULATION "Support text manipulation functions" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_TEXT_MANIPULATION "Support text manipulation functions" ON CUSTOMIZE_BUILD ON)
|
||||||
|
cmake_dependent_option(SUPPORT_FONT_ATLAS_WHITE_REC "Support white rec on font atlas bottom-right corner" ON CUSTOMIZE_BUILD ON)
|
||||||
|
|
||||||
# rmodels.c
|
# rmodels.c
|
||||||
cmake_dependent_option(SUPPORT_MESH_GENERATION "Support procedural mesh generation functions, uses external par_shapes.h library. NOTE: Some generated meshes DO NOT include generated texture coordinates" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_MESH_GENERATION "Support procedural mesh generation functions, uses external par_shapes.h library. NOTE: Some generated meshes DO NOT include generated texture coordinates" ON CUSTOMIZE_BUILD ON)
|
||||||
|
|
@ -81,6 +87,7 @@ cmake_dependent_option(SUPPORT_FILEFORMAT_MTL "Support loading MTL file format"
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_IQM "Support loading IQM file format" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_IQM "Support loading IQM file format" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_GLTF "Support loading GLTF file format" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_GLTF "Support loading GLTF file format" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_VOX "Support loading VOX file format" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_VOX "Support loading VOX file format" ON CUSTOMIZE_BUILD ON)
|
||||||
|
cmake_dependent_option(SUPPORT_FILEFORMAT_M3D "Support loading M3D file format" ON CUSTOMIZE_BUILD ON)
|
||||||
|
|
||||||
# raudio.c
|
# raudio.c
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_WAV "Support loading WAV for sound" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_WAV "Support loading WAV for sound" ON CUSTOMIZE_BUILD ON)
|
||||||
|
|
@ -88,6 +95,7 @@ cmake_dependent_option(SUPPORT_FILEFORMAT_OGG "Support loading OGG for sound" O
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_XM "Support loading XM for sound" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_XM "Support loading XM for sound" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_MOD "Support loading MOD for sound" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_MOD "Support loading MOD for sound" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_MP3 "Support loading MP3 for sound" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_MP3 "Support loading MP3 for sound" ON CUSTOMIZE_BUILD ON)
|
||||||
|
cmake_dependent_option(SUPPORT_FILEFORMAT_QOA "Support loading QOA for sound" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_FLAC "Support loading FLAC for sound" ${OFF} CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_FLAC "Support loading FLAC for sound" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||||
|
|
||||||
# utils.c
|
# utils.c
|
||||||
|
|
|
||||||
7
FAQ.md
|
|
@ -14,12 +14,13 @@
|
||||||
- [What does raylib provide that other engines or libraries don't?](#what-does-raylib-provide-that-other-engines-or-libraries-dont)
|
- [What does raylib provide that other engines or libraries don't?](#what-does-raylib-provide-that-other-engines-or-libraries-dont)
|
||||||
- [How does raylib compare to Unity/Unreal/Godot?](#how-does-raylib-compare-to-unityunrealgodot)
|
- [How does raylib compare to Unity/Unreal/Godot?](#how-does-raylib-compare-to-unityunrealgodot)
|
||||||
- [What development tools are required for raylib?](#what-development-tools-are-required-for-raylib)
|
- [What development tools are required for raylib?](#what-development-tools-are-required-for-raylib)
|
||||||
- [Which are raylib external dependencies?](#which-are-raylib-external-dependencies)
|
- [What are raylib's external dependencies?](#what-are-raylibs-external-dependencies)
|
||||||
- [Can I use raylib with other technologies or libraries?](#can-i-use-raylib-with-other-technologies-or-libraries)
|
- [Can I use raylib with other technologies or libraries?](#can-i-use-raylib-with-other-technologies-or-libraries)
|
||||||
- [What file formats are supported by raylib?](#what-file-formats-are-supported-by-raylib)
|
- [What file formats are supported by raylib?](#what-file-formats-are-supported-by-raylib)
|
||||||
- [Does raylib support the Vulkan API?](#does-raylib-support-the-vulkan-api)
|
- [Does raylib support the Vulkan API?](#does-raylib-support-the-vulkan-api)
|
||||||
- [What could I expect to see in raylib in the future?](#what-could-i-expect-to-see-in-raylib-in-the-future)
|
- [What could I expect to see in raylib in the future?](#what-could-i-expect-to-see-in-raylib-in-the-future)
|
||||||
- [Who are the raylib developers?](#who-are-the-raylib-developers)
|
- [Who are the raylib developers?](#who-are-the-raylib-developers)
|
||||||
|
- [MORE QUESTIONS...](https://github.com/raysan5/raylib/wiki/Frequently-Asked-Questions)
|
||||||
|
|
||||||
### What is raylib?
|
### What is raylib?
|
||||||
|
|
||||||
|
|
@ -119,8 +120,8 @@ raylib can load data from multiple standard file formats:
|
||||||
|
|
||||||
- Image/Textures: PNG, BMP, TGA, JPG, GIF, QOI, PSD, DDS, HDR, KTX, ASTC, PKM, PVR
|
- Image/Textures: PNG, BMP, TGA, JPG, GIF, QOI, PSD, DDS, HDR, KTX, ASTC, PKM, PVR
|
||||||
- Fonts: FNT (sprite font), TTF, OTF
|
- Fonts: FNT (sprite font), TTF, OTF
|
||||||
- Models/Meshes: OBJ, IQM, GLTF, VOX
|
- Models/Meshes: OBJ, IQM, GLTF, VOX, M3D
|
||||||
- Audio: WAV, OGG, MP3, FLAC, XM, MOD
|
- Audio: WAV, OGG, MP3, FLAC, XM, MOD, QOA
|
||||||
|
|
||||||
### Does raylib support the Vulkan API?
|
### Does raylib support the Vulkan API?
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ introduction
|
||||||
|
|
||||||
I started developing videogames in 2006 and some years later I started teaching videogames development to young people with artistic profile, most of students had never written a single line of code.
|
I started developing videogames in 2006 and some years later I started teaching videogames development to young people with artistic profile, most of students had never written a single line of code.
|
||||||
|
|
||||||
I decided to start with C language basis and, after searching for the most simple and easy-to-use library to teach videogames programming, I found [WinBGI](http://www.codecutter.net/tools/winbgim/); it was great and it worked very well with students, in just a couple of weeks, those students that had never written a single line of code were able to program (and understand) a simple PONG game, some of them even a BREAKOUT!
|
I decided to start with C language basis and, after searching for the most simple and easy-to-use library to teach videogames programming, I found [WinBGI](https://winbgim.codecutter.org/); it was great and it worked very well with students, in just a couple of weeks, those students that had never written a single line of code were able to program (and understand) a simple PONG game, some of them even a BREAKOUT!
|
||||||
|
|
||||||
But WinBGI was not the clearer and most organized library for my taste. There were lots of things I found confusing and some function names were not clear enough for most of the students; not to mention the lack of transparencies support and no hardware acceleration.
|
But WinBGI was not the clearer and most organized library for my taste. There were lots of things I found confusing and some function names were not clear enough for most of the students; not to mention the lack of transparencies support and no hardware acceleration.
|
||||||
|
|
||||||
|
|
@ -140,7 +140,7 @@ notes on raylib 1.7
|
||||||
|
|
||||||
On May 2017, around 6 month after raylib 1.6, comes another raylib instalment, raylib 1.7. This time library has been improved a lot in terms of consistency and cleanness. As stated in [this patreon article](https://www.patreon.com/posts/raylib-future-7501034), this new raylib version has focused efforts in becoming more simple and easy-to-use to learn videogames programming. Some highlights of this new version are:
|
On May 2017, around 6 month after raylib 1.6, comes another raylib instalment, raylib 1.7. This time library has been improved a lot in terms of consistency and cleanness. As stated in [this patreon article](https://www.patreon.com/posts/raylib-future-7501034), this new raylib version has focused efforts in becoming more simple and easy-to-use to learn videogames programming. Some highlights of this new version are:
|
||||||
|
|
||||||
- More than 30 new functions added to the library, functions to control Window, utils to work with filenames and extensions, functions to draw lines with custom thick, mesh loading, functions for 3d ray collisions detailed detection, funtions for VR simulation and much more... Just check [CHANGELOG](CHANGELOG) for a detailed list of additions!
|
- More than 30 new functions added to the library, functions to control Window, utils to work with filenames and extensions, functions to draw lines with custom thick, mesh loading, functions for 3d ray collisions detailed detection, functions for VR simulation and much more... Just check [CHANGELOG](CHANGELOG) for a detailed list of additions!
|
||||||
|
|
||||||
- Support of [configuration flags](https://github.com/raysan5/raylib/issues/200) on every raylib module. Advance users can customize raylib just choosing desired features, defining some configuration flags on modules compilation. That way users can control library size and available functionality.
|
- Support of [configuration flags](https://github.com/raysan5/raylib/issues/200) on every raylib module. Advance users can customize raylib just choosing desired features, defining some configuration flags on modules compilation. That way users can control library size and available functionality.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<img align="left" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_logo_animation.gif" width="288px">
|
<img align="left" style="width:260px" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_logo_animation.gif" width="288px">
|
||||||
|
|
||||||
**raylib is a simple and easy-to-use library to enjoy videogames programming.**
|
**raylib is a simple and easy-to-use library to enjoy videogames programming.**
|
||||||
|
|
||||||
raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's specially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's especially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
||||||
|
|
||||||
*NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no debug button... just coding in the most pure spartan-programmers way.*
|
*NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no debug button... just coding in the most pure spartan-programmers way.*
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ features
|
||||||
|
|
||||||
basic example
|
basic example
|
||||||
--------------
|
--------------
|
||||||
This is a basic raylib example, it creates a window and it draws the text `"Congrats! You created your first window!"` in the middle of the screen. Check this example [running live on web here](https://www.raylib.com/examples/core/loader.html?name=core_basic_window).
|
This is a basic raylib example, it creates a window and draws the text `"Congrats! You created your first window!"` in the middle of the screen. Check this example [running live on web here](https://www.raylib.com/examples/core/loader.html?name=core_basic_window).
|
||||||
```c
|
```c
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
|
|
||||||
15
build.zig
|
|
@ -1,18 +1,7 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const raylib = @import("src/build.zig");
|
const raylib = @import("src/build.zig");
|
||||||
|
|
||||||
|
// This has been tested to work with zig 0.11.0
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
// Standard target options allows the person running `zig build` to choose
|
raylib.build(b);
|
||||||
// what target to build for. Here we do not override the defaults, which
|
|
||||||
// means any target is allowed, and the default is native. Other options
|
|
||||||
// for restricting supported target set are available.
|
|
||||||
const target = b.standardTargetOptions(.{});
|
|
||||||
// Standard optimization options allow the person running `zig build` to select
|
|
||||||
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
|
|
||||||
// set a preferred release mode, allowing the user to decide how to optimize.
|
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
|
||||||
|
|
||||||
const lib = raylib.addRaylib(b, target, optimize);
|
|
||||||
lib.installHeader("src/raylib.h", "raylib.h");
|
|
||||||
lib.install();
|
|
||||||
}
|
}
|
||||||
|
|
@ -28,6 +28,8 @@ if (${CUSTOMIZE_BUILD})
|
||||||
define_if("raylib" SUPPORT_EVENTS_WAITING)
|
define_if("raylib" SUPPORT_EVENTS_WAITING)
|
||||||
define_if("raylib" SUPPORT_WINMM_HIGHRES_TIMER)
|
define_if("raylib" SUPPORT_WINMM_HIGHRES_TIMER)
|
||||||
define_if("raylib" SUPPORT_COMPRESSION_API)
|
define_if("raylib" SUPPORT_COMPRESSION_API)
|
||||||
|
define_if("raylib" SUPPORT_EVENTS_AUTOMATION)
|
||||||
|
define_if("raylib" SUPPORT_CUSTOM_FRAME_CONTROL)
|
||||||
define_if("raylib" SUPPORT_QUADS_DRAW_MODE)
|
define_if("raylib" SUPPORT_QUADS_DRAW_MODE)
|
||||||
define_if("raylib" SUPPORT_IMAGE_EXPORT)
|
define_if("raylib" SUPPORT_IMAGE_EXPORT)
|
||||||
define_if("raylib" SUPPORT_IMAGE_GENERATION)
|
define_if("raylib" SUPPORT_IMAGE_GENERATION)
|
||||||
|
|
@ -35,6 +37,7 @@ if (${CUSTOMIZE_BUILD})
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_PNG)
|
define_if("raylib" SUPPORT_FILEFORMAT_PNG)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_DDS)
|
define_if("raylib" SUPPORT_FILEFORMAT_DDS)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_HDR)
|
define_if("raylib" SUPPORT_FILEFORMAT_HDR)
|
||||||
|
define_if("raylib" SUPPORT_FILEFORMAT_PIC)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_PNM)
|
define_if("raylib" SUPPORT_FILEFORMAT_PNM)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_KTX)
|
define_if("raylib" SUPPORT_FILEFORMAT_KTX)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_ASTC)
|
define_if("raylib" SUPPORT_FILEFORMAT_ASTC)
|
||||||
|
|
@ -46,6 +49,7 @@ if (${CUSTOMIZE_BUILD})
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_PSD)
|
define_if("raylib" SUPPORT_FILEFORMAT_PSD)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_PKM)
|
define_if("raylib" SUPPORT_FILEFORMAT_PKM)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_PVR)
|
define_if("raylib" SUPPORT_FILEFORMAT_PVR)
|
||||||
|
define_if("raylib" SUPPORT_FILEFORMAT_SVG)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_FNT)
|
define_if("raylib" SUPPORT_FILEFORMAT_FNT)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_TTF)
|
define_if("raylib" SUPPORT_FILEFORMAT_TTF)
|
||||||
define_if("raylib" SUPPORT_TEXT_MANIPULATION)
|
define_if("raylib" SUPPORT_TEXT_MANIPULATION)
|
||||||
|
|
@ -55,11 +59,13 @@ if (${CUSTOMIZE_BUILD})
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_IQM)
|
define_if("raylib" SUPPORT_FILEFORMAT_IQM)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_GLTF)
|
define_if("raylib" SUPPORT_FILEFORMAT_GLTF)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_VOX)
|
define_if("raylib" SUPPORT_FILEFORMAT_VOX)
|
||||||
|
define_if("raylib" SUPPORT_FILEFORMAT_M3D)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_WAV)
|
define_if("raylib" SUPPORT_FILEFORMAT_WAV)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_OGG)
|
define_if("raylib" SUPPORT_FILEFORMAT_OGG)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_XM)
|
define_if("raylib" SUPPORT_FILEFORMAT_XM)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_MOD)
|
define_if("raylib" SUPPORT_FILEFORMAT_MOD)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_MP3)
|
define_if("raylib" SUPPORT_FILEFORMAT_MP3)
|
||||||
|
define_if("raylib" SUPPORT_FILEFORMAT_QOA)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_FLAC)
|
define_if("raylib" SUPPORT_FILEFORMAT_FLAC)
|
||||||
define_if("raylib" SUPPORT_STANDARD_FILEIO)
|
define_if("raylib" SUPPORT_STANDARD_FILEIO)
|
||||||
define_if("raylib" SUPPORT_TRACELOG)
|
define_if("raylib" SUPPORT_TRACELOG)
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,7 @@ install(
|
||||||
# PKG_CONFIG_LIBS_PRIVATE is used in raylib.pc.in
|
# PKG_CONFIG_LIBS_PRIVATE is used in raylib.pc.in
|
||||||
if (NOT BUILD_SHARED_LIBS)
|
if (NOT BUILD_SHARED_LIBS)
|
||||||
include(LibraryPathToLinkerFlags)
|
include(LibraryPathToLinkerFlags)
|
||||||
library_path_to_linker_flags(__PKG_CONFIG_LIBS_PRIVATE "${LIBS_PRIVATE}")
|
set(PKG_CONFIG_LIBS_PRIVATE ${GLFW_PKG_LIBS})
|
||||||
set(PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE} ${GLFW_PKG_LIBS})
|
|
||||||
string(REPLACE ";" " " PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE}")
|
string(REPLACE ";" " " PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE}")
|
||||||
elseif (BUILD_SHARED_LIBS)
|
elseif (BUILD_SHARED_LIBS)
|
||||||
set(PKG_CONFIG_LIBS_EXTRA "")
|
set(PKG_CONFIG_LIBS_EXTRA "")
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ if (${PLATFORM} MATCHES "Desktop")
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
find_package(OpenGL QUIET)
|
find_package(OpenGL QUIET)
|
||||||
set(LIBS_PRIVATE ${OPENGL_LIBRARIES} winmm)
|
set(LIBS_PRIVATE ${OPENGL_LIBRARIES} winmm)
|
||||||
else ()
|
elseif (UNIX)
|
||||||
find_library(pthread NAMES pthread)
|
find_library(pthread NAMES pthread)
|
||||||
find_package(OpenGL QUIET)
|
find_package(OpenGL QUIET)
|
||||||
if ("${OPENGL_LIBRARIES}" STREQUAL "")
|
if ("${OPENGL_LIBRARIES}" STREQUAL "")
|
||||||
|
|
@ -36,9 +36,22 @@ if (${PLATFORM} MATCHES "Desktop")
|
||||||
find_library(OSS_LIBRARY ossaudio)
|
find_library(OSS_LIBRARY ossaudio)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
|
||||||
|
else ()
|
||||||
|
find_library(pthread NAMES pthread)
|
||||||
|
find_package(OpenGL QUIET)
|
||||||
|
if ("${OPENGL_LIBRARIES}" STREQUAL "")
|
||||||
|
set(OPENGL_LIBRARIES "GL")
|
||||||
|
endif ()
|
||||||
|
|
||||||
set(LIBS_PRIVATE m atomic pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
|
set(LIBS_PRIVATE m atomic pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
|
||||||
|
|
||||||
if (USE_AUDIO)
|
if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
|
||||||
|
find_library(OSS_LIBRARY ossaudio)
|
||||||
|
set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (NOT "${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD" AND USE_AUDIO)
|
||||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} dl)
|
set(LIBS_PRIVATE ${LIBS_PRIVATE} dl)
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
@ -60,19 +73,6 @@ elseif (${PLATFORM} MATCHES "Android")
|
||||||
find_library(OPENGL_LIBRARY OpenGL)
|
find_library(OPENGL_LIBRARY OpenGL)
|
||||||
set(LIBS_PRIVATE m log android EGL GLESv2 OpenSLES atomic c)
|
set(LIBS_PRIVATE m log android EGL GLESv2 OpenSLES atomic c)
|
||||||
|
|
||||||
elseif (${PLATFORM} MATCHES "Raspberry Pi")
|
|
||||||
set(PLATFORM_CPP "PLATFORM_RPI")
|
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
||||||
|
|
||||||
add_definitions(-D_DEFAULT_SOURCE)
|
|
||||||
|
|
||||||
find_library(GLESV2 brcmGLESv2 HINTS /opt/vc/lib)
|
|
||||||
find_library(EGL brcmEGL HINTS /opt/vc/lib)
|
|
||||||
find_library(BCMHOST bcm_host HINTS /opt/vc/lib)
|
|
||||||
include_directories(/opt/vc/include /opt/vc/include/interface/vmcs_host/linux /opt/vc/include/interface/vcos/pthreads)
|
|
||||||
link_directories(/opt/vc/lib)
|
|
||||||
set(LIBS_PRIVATE ${GLESV2} ${EGL} ${BCMHOST} pthread rt m dl)
|
|
||||||
|
|
||||||
elseif ("${PLATFORM}" MATCHES "DRM")
|
elseif ("${PLATFORM}" MATCHES "DRM")
|
||||||
set(PLATFORM_CPP "PLATFORM_DRM")
|
set(PLATFORM_CPP "PLATFORM_DRM")
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
||||||
|
|
@ -93,7 +93,7 @@ elseif ("${PLATFORM}" MATCHES "DRM")
|
||||||
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (NOT ${OPENGL_VERSION})
|
if (NOT ${OPENGL_VERSION} MATCHES "OFF")
|
||||||
set(${SUGGESTED_GRAPHICS} "${GRAPHICS}")
|
set(${SUGGESTED_GRAPHICS} "${GRAPHICS}")
|
||||||
if (${OPENGL_VERSION} MATCHES "4.3")
|
if (${OPENGL_VERSION} MATCHES "4.3")
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_43")
|
set(GRAPHICS "GRAPHICS_API_OPENGL_43")
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,25 @@
|
||||||
#**************************************************************************************************
|
#**************************************************************************************************
|
||||||
#
|
#
|
||||||
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
|
# raylib makefile for multiple platforms
|
||||||
|
#
|
||||||
|
# This file supports building raylib examples for the following platforms:
|
||||||
|
#
|
||||||
|
# > PLATFORM_DESKTOP (GLFW backend):
|
||||||
|
# - Windows (Win32, Win64)
|
||||||
|
# - Linux (X11/Wayland desktop mode)
|
||||||
|
# - macOS/OSX (x64, arm64)
|
||||||
|
# - FreeBSD, OpenBSD, NetBSD, DragonFly (X11 desktop)
|
||||||
|
# > PLATFORM_DESKTOP_SDL (SDL backend):
|
||||||
|
# - Windows (Win32, Win64)
|
||||||
|
# - Linux (X11/Wayland desktop mode)
|
||||||
|
# - Others (not tested)
|
||||||
|
# > PLATFORM_WEB:
|
||||||
|
# - HTML5 (WebAssembly)
|
||||||
|
# > PLATFORM_DRM:
|
||||||
|
# - Raspberry Pi 0-5 (DRM/KMS)
|
||||||
|
# - Linux DRM subsystem (KMS mode)
|
||||||
|
# > PLATFORM_ANDROID:
|
||||||
|
# - Android (ARM, ARM64)
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
|
# Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
|
||||||
#
|
#
|
||||||
|
|
@ -25,14 +44,17 @@
|
||||||
|
|
||||||
# Define required environment variables
|
# Define required environment variables
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
# Define target platform: PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB
|
# Define target platform: PLATFORM_DESKTOP, PLATFORM_DESKTOP_SDL, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
PLATFORM ?= PLATFORM_DESKTOP
|
PLATFORM ?= PLATFORM_DESKTOP
|
||||||
|
|
||||||
# Define required raylib variables
|
# Define required raylib variables
|
||||||
PROJECT_NAME ?= raylib_examples
|
PROJECT_NAME ?= raylib_examples
|
||||||
RAYLIB_VERSION ?= 4.5.0
|
RAYLIB_VERSION ?= 5.0.0
|
||||||
RAYLIB_PATH ?= ..
|
RAYLIB_PATH ?= ..
|
||||||
|
|
||||||
|
# Define raylib source code path
|
||||||
|
RAYLIB_SRC_PATH ?= ../src
|
||||||
|
|
||||||
# Locations of raylib.h and libraylib.a/libraylib.so
|
# Locations of raylib.h and libraylib.a/libraylib.so
|
||||||
# NOTE: Those variables are only used for PLATFORM_OS: LINUX, BSD
|
# NOTE: Those variables are only used for PLATFORM_OS: LINUX, BSD
|
||||||
RAYLIB_INCLUDE_PATH ?= /usr/local/include
|
RAYLIB_INCLUDE_PATH ?= /usr/local/include
|
||||||
|
|
@ -47,6 +69,11 @@ BUILD_MODE ?= RELEASE
|
||||||
# Use external GLFW library instead of rglfw module
|
# Use external GLFW library instead of rglfw module
|
||||||
USE_EXTERNAL_GLFW ?= FALSE
|
USE_EXTERNAL_GLFW ?= FALSE
|
||||||
|
|
||||||
|
# PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally
|
||||||
|
# WARNING: Library is not included in raylib, it MUST be configured by users
|
||||||
|
SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2-2.28.4/include
|
||||||
|
SDL_LIBRARY_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2-2.28.4/lib/x64
|
||||||
|
|
||||||
# Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system)
|
# Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system)
|
||||||
# NOTE: This variable is only used for PLATFORM_OS: LINUX
|
# NOTE: This variable is only used for PLATFORM_OS: LINUX
|
||||||
USE_WAYLAND_DISPLAY ?= FALSE
|
USE_WAYLAND_DISPLAY ?= FALSE
|
||||||
|
|
@ -58,17 +85,8 @@ BUILD_WEB_HEAP_SIZE ?= 134217728
|
||||||
BUILD_WEB_RESOURCES ?= TRUE
|
BUILD_WEB_RESOURCES ?= TRUE
|
||||||
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
|
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
|
||||||
|
|
||||||
# Use cross-compiler for PLATFORM_RPI
|
# Determine PLATFORM_OS when required
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_DESKTOP_SDL PLATFORM_WEB))
|
||||||
USE_RPI_CROSS_COMPILER ?= FALSE
|
|
||||||
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
|
|
||||||
RPI_TOOLCHAIN ?= C:/SysGCC/Raspberry
|
|
||||||
RPI_TOOLCHAIN_SYSROOT ?= $(RPI_TOOLCHAIN)/arm-linux-gnueabihf/sysroot
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Determine PLATFORM_OS in case PLATFORM_DESKTOP or PLATFORM_WEB selected
|
|
||||||
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB))
|
|
||||||
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
|
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
|
||||||
# ifeq ($(UNAME),Msys) -> Windows
|
# ifeq ($(UNAME),Msys) -> Windows
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
|
|
@ -95,12 +113,6 @@ ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB))
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
UNAMEOS = $(shell uname)
|
|
||||||
ifeq ($(UNAMEOS),Linux)
|
|
||||||
PLATFORM_OS = LINUX
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
UNAMEOS = $(shell uname)
|
UNAMEOS = $(shell uname)
|
||||||
ifeq ($(UNAMEOS),Linux)
|
ifeq ($(UNAMEOS),Linux)
|
||||||
|
|
@ -118,9 +130,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Default path for raylib on Raspberry Pi
|
# Default path for raylib on Raspberry Pi
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
RAYLIB_PATH ?= /home/pi/raylib
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
RAYLIB_PATH ?= /home/pi/raylib
|
RAYLIB_PATH ?= /home/pi/raylib
|
||||||
endif
|
endif
|
||||||
|
|
@ -154,13 +163,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
CC = clang
|
CC = clang
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
|
|
||||||
# Define RPI cross-compiler
|
|
||||||
#CC = armv6j-hardfloat-linux-gnueabi-gcc
|
|
||||||
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# HTML5 emscripten compiler
|
# HTML5 emscripten compiler
|
||||||
# WARNING: To compile to HTML5, code must be redesigned
|
# WARNING: To compile to HTML5, code must be redesigned
|
||||||
|
|
@ -181,7 +183,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
||||||
MAKE = mingw32-make
|
MAKE = mingw32-make
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
MAKE = mingw32-make
|
MAKE = emmake make
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define compiler flags: CFLAGS
|
# Define compiler flags: CFLAGS
|
||||||
|
|
@ -231,9 +233,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
CFLAGS += -std=gnu99
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
CFLAGS += -std=gnu99 -DEGL_NO_X11
|
CFLAGS += -std=gnu99 -DEGL_NO_X11
|
||||||
endif
|
endif
|
||||||
|
|
@ -252,15 +251,19 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
|
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP_SDL)
|
||||||
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include
|
INCLUDE_PATHS += -I$(SDL_INCLUDE_PATH)
|
||||||
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vmcs_host/linux
|
|
||||||
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vcos/pthreads
|
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
|
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
|
||||||
INCLUDE_PATHS += -I/usr/include/libdrm
|
INCLUDE_PATHS += -I/usr/include/libdrm
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Include GLFW required for examples/others/rlgl_standalone.c
|
||||||
|
ifeq ($(USE_EXTERNAL_GLFW),FALSE)
|
||||||
|
all others: INCLUDE_PATHS += -I$(RAYLIB_PATH)/src/external/glfw/include
|
||||||
|
endif
|
||||||
|
|
||||||
# Define library paths containing required libs: LDFLAGS
|
# Define library paths containing required libs: LDFLAGS
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
|
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
|
||||||
|
|
@ -281,6 +284,17 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH)
|
LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP_SDL)
|
||||||
|
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
|
# NOTE: The resource .rc file contains windows executable icon and properties
|
||||||
|
LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
|
||||||
|
# -Wl,--subsystem,windows hides the console window
|
||||||
|
ifeq ($(BUILD_MODE), RELEASE)
|
||||||
|
LDFLAGS += -Wl,--subsystem,windows
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
LDFLAGS += -L$(SDL_LIBRARY_PATH)
|
||||||
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# -Os # size optimization
|
# -Os # size optimization
|
||||||
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
||||||
|
|
@ -323,9 +337,6 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# logic to a self contained function: UpdateDrawFrame(), check core_basic_window_web.c for reference.
|
# logic to a self contained function: UpdateDrawFrame(), check core_basic_window_web.c for reference.
|
||||||
|
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define libraries required on linking: LDLIBS
|
# Define libraries required on linking: LDLIBS
|
||||||
# NOTE: To link libraries (lib<name>.so or lib<name>.a), use -l<name>
|
# NOTE: To link libraries (lib<name>.so or lib<name>.a), use -l<name>
|
||||||
|
|
@ -376,12 +387,32 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
LDLIBS += -lglfw
|
LDLIBS += -lglfw
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP_SDL)
|
||||||
# Libraries for Raspberry Pi compiling
|
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
# NOTE: Required packages: libasound2-dev (ALSA)
|
# Libraries for Windows desktop compilation
|
||||||
LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -latomic
|
LDLIBS = -lraylib -lSDL2 -lSDL2main -lopengl32 -lgdi32
|
||||||
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
|
endif
|
||||||
LDLIBS += -lvchiq_arm -lvcos
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
|
# Libraries for Debian GNU/Linux desktop compiling
|
||||||
|
# NOTE: Required packages: libegl1-mesa-dev
|
||||||
|
LDLIBS = -lraylib -lSDL2 -lSDL2main -lGL -lm -lpthread -ldl -lrt
|
||||||
|
|
||||||
|
# On X11 requires also below libraries
|
||||||
|
LDLIBS += -lX11
|
||||||
|
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
|
||||||
|
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
|
||||||
|
|
||||||
|
# On Wayland windowing system, additional libraries requires
|
||||||
|
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
|
||||||
|
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
|
||||||
|
endif
|
||||||
|
# Explicit link to libc
|
||||||
|
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
||||||
|
LDLIBS += -lc
|
||||||
|
endif
|
||||||
|
|
||||||
|
# NOTE: On ARM 32bit arch, miniaudio requires atomics library
|
||||||
|
LDLIBS += -latomic
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
|
|
@ -403,14 +434,18 @@ CORE = \
|
||||||
core/core_input_mouse \
|
core/core_input_mouse \
|
||||||
core/core_input_mouse_wheel \
|
core/core_input_mouse_wheel \
|
||||||
core/core_input_gamepad \
|
core/core_input_gamepad \
|
||||||
|
core/core_input_gamepad_info \
|
||||||
core/core_input_multitouch \
|
core/core_input_multitouch \
|
||||||
core/core_input_gestures \
|
core/core_input_gestures \
|
||||||
|
core/core_input_gestures_web \
|
||||||
core/core_2d_camera \
|
core/core_2d_camera \
|
||||||
core/core_2d_camera_platformer \
|
core/core_2d_camera_platformer \
|
||||||
core/core_2d_camera_mouse_zoom \
|
core/core_2d_camera_mouse_zoom \
|
||||||
|
core/core_2d_camera_split_screen \
|
||||||
core/core_3d_camera_mode \
|
core/core_3d_camera_mode \
|
||||||
core/core_3d_camera_free \
|
core/core_3d_camera_free \
|
||||||
core/core_3d_camera_first_person \
|
core/core_3d_camera_first_person \
|
||||||
|
core/core_3d_camera_split_screen \
|
||||||
core/core_3d_picking \
|
core/core_3d_picking \
|
||||||
core/core_world_screen \
|
core/core_world_screen \
|
||||||
core/core_custom_logging \
|
core/core_custom_logging \
|
||||||
|
|
@ -423,7 +458,6 @@ CORE = \
|
||||||
core/core_window_flags \
|
core/core_window_flags \
|
||||||
core/core_window_letterbox \
|
core/core_window_letterbox \
|
||||||
core/core_window_should_close \
|
core/core_window_should_close \
|
||||||
core/core_split_screen \
|
|
||||||
core/core_smooth_pixelperfect \
|
core/core_smooth_pixelperfect \
|
||||||
core/core_custom_frame_control
|
core/core_custom_frame_control
|
||||||
|
|
||||||
|
|
@ -453,6 +487,7 @@ TEXTURES = \
|
||||||
textures/textures_image_generation \
|
textures/textures_image_generation \
|
||||||
textures/textures_image_loading \
|
textures/textures_image_loading \
|
||||||
textures/textures_image_processing \
|
textures/textures_image_processing \
|
||||||
|
textures/textures_image_rotate \
|
||||||
textures/textures_image_text \
|
textures/textures_image_text \
|
||||||
textures/textures_to_image \
|
textures/textures_to_image \
|
||||||
textures/textures_raw_data \
|
textures/textures_raw_data \
|
||||||
|
|
@ -468,7 +503,8 @@ TEXTURES = \
|
||||||
textures/textures_draw_tiled \
|
textures/textures_draw_tiled \
|
||||||
textures/textures_polygon \
|
textures/textures_polygon \
|
||||||
textures/textures_gif_player \
|
textures/textures_gif_player \
|
||||||
textures/textures_fog_of_war
|
textures/textures_fog_of_war \
|
||||||
|
textures/textures_svg_loading
|
||||||
|
|
||||||
TEXT = \
|
TEXT = \
|
||||||
text/text_raylib_fonts \
|
text/text_raylib_fonts \
|
||||||
|
|
@ -522,25 +558,36 @@ SHADERS = \
|
||||||
shaders/shaders_simple_mask \
|
shaders/shaders_simple_mask \
|
||||||
shaders/shaders_spotlight \
|
shaders/shaders_spotlight \
|
||||||
shaders/shaders_hot_reloading \
|
shaders/shaders_hot_reloading \
|
||||||
|
shaders/shaders_lightmap \
|
||||||
shaders/shaders_mesh_instancing \
|
shaders/shaders_mesh_instancing \
|
||||||
shaders/shaders_multi_sample2d \
|
shaders/shaders_multi_sample2d \
|
||||||
shaders/shaders_write_depth \
|
shaders/shaders_write_depth \
|
||||||
shaders/shaders_hybrid_render
|
shaders/shaders_hybrid_render \
|
||||||
|
shaders/shaders_deferred_render
|
||||||
|
|
||||||
AUDIO = \
|
AUDIO = \
|
||||||
audio/audio_module_playing \
|
audio/audio_module_playing \
|
||||||
audio/audio_music_stream \
|
audio/audio_music_stream \
|
||||||
audio/audio_raw_stream \
|
audio/audio_raw_stream \
|
||||||
audio/audio_sound_loading \
|
audio/audio_sound_loading \
|
||||||
|
audio/audio_sound_multi \
|
||||||
audio/audio_stream_effects \
|
audio/audio_stream_effects \
|
||||||
audio/audio_mixed_processor
|
audio/audio_mixed_processor
|
||||||
|
|
||||||
|
OTHERS = \
|
||||||
|
others/easings_testbed \
|
||||||
|
others/embedded_files_loading \
|
||||||
|
others/raylib_opengl_interop \
|
||||||
|
others/raymath_vector_angle \
|
||||||
|
others/rlgl_compute_shader \
|
||||||
|
others/rlgl_standalone
|
||||||
|
|
||||||
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
||||||
|
|
||||||
# Define processes to execute
|
# Define processes to execute
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
# Default target entry
|
# Default target entry
|
||||||
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO)
|
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) $(OTHERS)
|
||||||
|
|
||||||
core: $(CORE)
|
core: $(CORE)
|
||||||
shapes: $(SHAPES)
|
shapes: $(SHAPES)
|
||||||
|
|
@ -549,12 +596,15 @@ text: $(TEXT)
|
||||||
models: $(MODELS)
|
models: $(MODELS)
|
||||||
shaders: $(SHADERS)
|
shaders: $(SHADERS)
|
||||||
audio: $(AUDIO)
|
audio: $(AUDIO)
|
||||||
|
others: $(OTHERS)
|
||||||
|
|
||||||
# Generic compilation pattern
|
# Generic compilation pattern
|
||||||
# NOTE: Examples must be ready for Android compilation!
|
# NOTE: Examples must be ready for Android compilation!
|
||||||
%: %.c
|
%: %.c
|
||||||
ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
||||||
$(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$<
|
$(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$<
|
||||||
|
else ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
$(MAKE) -f Makefile.Web $@
|
||||||
else
|
else
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
endif
|
endif
|
||||||
|
|
@ -574,10 +624,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
rm -f *.o
|
rm -f *.o
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
find . -type f -executable -delete
|
|
||||||
rm -fv *.o
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
find . -type f -executable -delete
|
find . -type f -executable -delete
|
||||||
rm -fv *.o
|
rm -fv *.o
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,12 @@
|
||||||
|
|
||||||
# Define required environment variables
|
# Define required environment variables
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
# Define target platform: PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB
|
# Define target platform: PLATFORM_DESKTOP, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
PLATFORM ?= PLATFORM_WEB
|
PLATFORM ?= PLATFORM_WEB
|
||||||
|
|
||||||
# Define required raylib variables
|
# Define required raylib variables
|
||||||
PROJECT_NAME ?= raylib_examples
|
PROJECT_NAME ?= raylib_examples
|
||||||
RAYLIB_VERSION ?= 4.5.0
|
RAYLIB_VERSION ?= 5.0.0
|
||||||
RAYLIB_PATH ?= ..
|
RAYLIB_PATH ?= ..
|
||||||
|
|
||||||
# Locations of raylib.h and libraylib.a/libraylib.so
|
# Locations of raylib.h and libraylib.a/libraylib.so
|
||||||
|
|
@ -51,15 +51,6 @@ USE_EXTERNAL_GLFW ?= FALSE
|
||||||
# NOTE: This variable is only used for PLATFORM_OS: LINUX
|
# NOTE: This variable is only used for PLATFORM_OS: LINUX
|
||||||
USE_WAYLAND_DISPLAY ?= FALSE
|
USE_WAYLAND_DISPLAY ?= FALSE
|
||||||
|
|
||||||
# Use cross-compiler for PLATFORM_RPI
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
USE_RPI_CROSS_COMPILER ?= FALSE
|
|
||||||
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
|
|
||||||
RPI_TOOLCHAIN ?= C:/SysGCC/Raspberry
|
|
||||||
RPI_TOOLCHAIN_SYSROOT ?= $(RPI_TOOLCHAIN)/arm-linux-gnueabihf/sysroot
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Determine PLATFORM_OS in case PLATFORM_DESKTOP or PLATFORM_WEB selected
|
# Determine PLATFORM_OS in case PLATFORM_DESKTOP or PLATFORM_WEB selected
|
||||||
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB))
|
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB))
|
||||||
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
|
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
|
||||||
|
|
@ -88,12 +79,6 @@ ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB))
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
UNAMEOS = $(shell uname)
|
|
||||||
ifeq ($(UNAMEOS),Linux)
|
|
||||||
PLATFORM_OS = LINUX
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
UNAMEOS = $(shell uname)
|
UNAMEOS = $(shell uname)
|
||||||
ifeq ($(UNAMEOS),Linux)
|
ifeq ($(UNAMEOS),Linux)
|
||||||
|
|
@ -111,9 +96,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Default path for raylib on Raspberry Pi
|
# Default path for raylib on Raspberry Pi
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
RAYLIB_PATH ?= /home/pi/raylib
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
RAYLIB_PATH ?= /home/pi/raylib
|
RAYLIB_PATH ?= /home/pi/raylib
|
||||||
endif
|
endif
|
||||||
|
|
@ -147,13 +129,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
CC = clang
|
CC = clang
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
|
|
||||||
# Define RPI cross-compiler
|
|
||||||
#CC = armv6j-hardfloat-linux-gnueabi-gcc
|
|
||||||
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# HTML5 emscripten compiler
|
# HTML5 emscripten compiler
|
||||||
# WARNING: To compile to HTML5, code must be redesigned
|
# WARNING: To compile to HTML5, code must be redesigned
|
||||||
|
|
@ -163,7 +138,7 @@ endif
|
||||||
|
|
||||||
# Define default make program: MAKE
|
# Define default make program: MAKE
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
MAKE ?= make
|
MAKE ?= emmake make
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
|
|
@ -174,7 +149,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
||||||
MAKE = mingw32-make
|
MAKE = mingw32-make
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
MAKE = mingw32-make
|
MAKE = emmake make
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define compiler flags: CFLAGS
|
# Define compiler flags: CFLAGS
|
||||||
|
|
@ -224,9 +199,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
CFLAGS += -std=gnu99
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
CFLAGS += -std=gnu99 -DEGL_NO_X11
|
CFLAGS += -std=gnu99 -DEGL_NO_X11
|
||||||
endif
|
endif
|
||||||
|
|
@ -245,11 +217,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
|
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include
|
|
||||||
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vmcs_host/linux
|
|
||||||
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vcos/pthreads
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
INCLUDE_PATHS += -I/usr/include/libdrm
|
INCLUDE_PATHS += -I/usr/include/libdrm
|
||||||
endif
|
endif
|
||||||
|
|
@ -301,12 +268,9 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# are specified per-example for optimization
|
# are specified per-example for optimization
|
||||||
|
|
||||||
# Define a custom shell .html and output extension
|
# Define a custom shell .html and output extension
|
||||||
LDFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
LDFLAGS += --shell-file $(RAYLIB_PATH)/src/minshell.html
|
||||||
EXT = .html
|
EXT = .html
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define libraries required on linking: LDLIBS
|
# Define libraries required on linking: LDLIBS
|
||||||
# NOTE: To link libraries (lib<name>.so or lib<name>.a), use -l<name>
|
# NOTE: To link libraries (lib<name>.so or lib<name>.a), use -l<name>
|
||||||
|
|
@ -357,14 +321,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
LDLIBS += -lglfw
|
LDLIBS += -lglfw
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
# Libraries for Raspberry Pi compiling
|
|
||||||
# NOTE: Required packages: libasound2-dev (ALSA)
|
|
||||||
LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -latomic
|
|
||||||
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
|
|
||||||
LDLIBS += -lvchiq_arm -lvcos
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
# Libraries for DRM compiling
|
# Libraries for DRM compiling
|
||||||
# NOTE: Required packages: libasound2-dev (ALSA)
|
# NOTE: Required packages: libasound2-dev (ALSA)
|
||||||
|
|
@ -384,14 +340,18 @@ CORE = \
|
||||||
core/core_input_mouse \
|
core/core_input_mouse \
|
||||||
core/core_input_mouse_wheel \
|
core/core_input_mouse_wheel \
|
||||||
core/core_input_gamepad \
|
core/core_input_gamepad \
|
||||||
|
core/core_input_gamepad_info \
|
||||||
core/core_input_multitouch \
|
core/core_input_multitouch \
|
||||||
core/core_input_gestures \
|
core/core_input_gestures \
|
||||||
|
core/core_input_gestures_web \
|
||||||
core/core_2d_camera \
|
core/core_2d_camera \
|
||||||
core/core_2d_camera_platformer \
|
core/core_2d_camera_platformer \
|
||||||
core/core_2d_camera_mouse_zoom \
|
core/core_2d_camera_mouse_zoom \
|
||||||
|
core/core_2d_camera_split_screen \
|
||||||
core/core_3d_camera_mode \
|
core/core_3d_camera_mode \
|
||||||
core/core_3d_camera_free \
|
core/core_3d_camera_free \
|
||||||
core/core_3d_camera_first_person \
|
core/core_3d_camera_first_person \
|
||||||
|
core/core_3d_camera_split_screen \
|
||||||
core/core_3d_picking \
|
core/core_3d_picking \
|
||||||
core/core_world_screen \
|
core/core_world_screen \
|
||||||
core/core_custom_logging \
|
core/core_custom_logging \
|
||||||
|
|
@ -403,7 +363,6 @@ CORE = \
|
||||||
core/core_window_flags \
|
core/core_window_flags \
|
||||||
core/core_window_letterbox \
|
core/core_window_letterbox \
|
||||||
core/core_window_should_close \
|
core/core_window_should_close \
|
||||||
core/core_split_screen \
|
|
||||||
core/core_smooth_pixelperfect \
|
core/core_smooth_pixelperfect \
|
||||||
core/core_custom_frame_control \
|
core/core_custom_frame_control \
|
||||||
core/core_loading_thread
|
core/core_loading_thread
|
||||||
|
|
@ -434,6 +393,7 @@ TEXTURES = \
|
||||||
textures/textures_image_generation \
|
textures/textures_image_generation \
|
||||||
textures/textures_image_loading \
|
textures/textures_image_loading \
|
||||||
textures/textures_image_processing \
|
textures/textures_image_processing \
|
||||||
|
textures/textures_image_rotate \
|
||||||
textures/textures_image_text \
|
textures/textures_image_text \
|
||||||
textures/textures_to_image \
|
textures/textures_to_image \
|
||||||
textures/textures_raw_data \
|
textures/textures_raw_data \
|
||||||
|
|
@ -449,7 +409,8 @@ TEXTURES = \
|
||||||
textures/textures_draw_tiled \
|
textures/textures_draw_tiled \
|
||||||
textures/textures_polygon \
|
textures/textures_polygon \
|
||||||
textures/textures_gif_player \
|
textures/textures_gif_player \
|
||||||
textures/textures_fog_of_war
|
textures/textures_fog_of_war \
|
||||||
|
textures/textures_svg_loading
|
||||||
|
|
||||||
TEXT = \
|
TEXT = \
|
||||||
text/text_raylib_fonts \
|
text/text_raylib_fonts \
|
||||||
|
|
@ -503,19 +464,30 @@ SHADERS = \
|
||||||
shaders/shaders_simple_mask \
|
shaders/shaders_simple_mask \
|
||||||
shaders/shaders_spotlight \
|
shaders/shaders_spotlight \
|
||||||
shaders/shaders_hot_reloading \
|
shaders/shaders_hot_reloading \
|
||||||
|
shaders/shaders_lightmap \
|
||||||
shaders/shaders_mesh_instancing \
|
shaders/shaders_mesh_instancing \
|
||||||
shaders/shaders_multi_sample2d \
|
shaders/shaders_multi_sample2d \
|
||||||
shaders/shaders_write_depth \
|
shaders/shaders_write_depth \
|
||||||
shaders/shaders_hybrid_render
|
shaders/shaders_hybrid_render \
|
||||||
|
shaders/shaders_deferred_render
|
||||||
|
|
||||||
AUDIO = \
|
AUDIO = \
|
||||||
audio/audio_module_playing \
|
audio/audio_module_playing \
|
||||||
audio/audio_music_stream \
|
audio/audio_music_stream \
|
||||||
audio/audio_raw_stream \
|
audio/audio_raw_stream \
|
||||||
audio/audio_sound_loading \
|
audio/audio_sound_loading \
|
||||||
|
audio/audio_sound_multi \
|
||||||
audio/audio_stream_effects \
|
audio/audio_stream_effects \
|
||||||
audio/audio_mixed_processor
|
audio/audio_mixed_processor
|
||||||
|
|
||||||
|
OTHERS = \
|
||||||
|
others/easings_testbed \
|
||||||
|
others/embedded_files_loading \
|
||||||
|
others/raylib_opengl_interop \
|
||||||
|
others/raymath_vector_angle \
|
||||||
|
others/rlgl_compute_shader \
|
||||||
|
others/rlgl_standalone
|
||||||
|
|
||||||
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
||||||
|
|
||||||
# Define processes to execute
|
# Define processes to execute
|
||||||
|
|
@ -552,12 +524,18 @@ core/core_input_gamepad: core/core_input_gamepad.c
|
||||||
--preload-file core/resources/ps3.png@resources/ps3.png \
|
--preload-file core/resources/ps3.png@resources/ps3.png \
|
||||||
--preload-file core/resources/xbox.png@resources/xbox.png
|
--preload-file core/resources/xbox.png@resources/xbox.png
|
||||||
|
|
||||||
|
core/core_input_gamepad_info: core/core_input_gamepad.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
core/core_input_multitouch: core/core_input_multitouch.c
|
core/core_input_multitouch: core/core_input_multitouch.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
core/core_input_gestures: core/core_input_gestures.c
|
core/core_input_gestures: core/core_input_gestures.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
|
core/core_input_gestures_web: core/core_input_gestures_web.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
core/core_2d_camera: core/core_2d_camera.c
|
core/core_2d_camera: core/core_2d_camera.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
|
|
@ -567,6 +545,9 @@ core/core_2d_camera_platformer: core/core_2d_camera_platformer.c
|
||||||
core/core_2d_camera_mouse_zoom: core/core_2d_camera_mouse_zoom.c
|
core/core_2d_camera_mouse_zoom: core/core_2d_camera_mouse_zoom.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
|
core/core_2d_camera_split_screen: core/core_2d_camera_split_screen.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
core/core_3d_camera_mode: core/core_3d_camera_mode.c
|
core/core_3d_camera_mode: core/core_3d_camera_mode.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
|
|
@ -576,6 +557,9 @@ core/core_3d_camera_free: core/core_3d_camera_free.c
|
||||||
core/core_3d_camera_first_person: core/core_3d_camera_first_person.c
|
core/core_3d_camera_first_person: core/core_3d_camera_first_person.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
|
core/core_3d_camera_split_screen: core/core_3d_camera_split_screen.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
core/core_3d_picking: core/core_3d_picking.c
|
core/core_3d_picking: core/core_3d_picking.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
|
|
@ -607,9 +591,6 @@ core/core_vr_simulator: core/core_vr_simulator.c
|
||||||
core/core_window_flags: core/core_window_flags.c
|
core/core_window_flags: core/core_window_flags.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
core/core_split_screen: core/core_split_screen.c
|
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
|
||||||
|
|
||||||
core/core_smooth_pixelperfect: core/core_smooth_pixelperfect.c
|
core/core_smooth_pixelperfect: core/core_smooth_pixelperfect.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
|
|
@ -709,6 +690,10 @@ textures/textures_image_processing: textures/textures_image_processing.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||||
--preload-file textures/resources/parrots.png@resources/parrots.png
|
--preload-file textures/resources/parrots.png@resources/parrots.png
|
||||||
|
|
||||||
|
textures/textures_image_rotate: textures/textures_image_rotate.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||||
|
--preload-file textures/resources/raylib_logo.png
|
||||||
|
|
||||||
textures/textures_image_text: textures/textures_image_text.c
|
textures/textures_image_text: textures/textures_image_text.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
|
||||||
--preload-file textures/resources/parrots.png@resources/parrots.png \
|
--preload-file textures/resources/parrots.png@resources/parrots.png \
|
||||||
|
|
@ -774,6 +759,10 @@ textures/textures_gif_player: textures/textures_gif_player.c
|
||||||
textures/textures_fog_of_war: textures/textures_fog_of_war.c
|
textures/textures_fog_of_war: textures/textures_fog_of_war.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
|
textures/textures_svg_loading: textures/textures_svg_loading.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||||
|
--preload-file textures/resources/test.svg
|
||||||
|
|
||||||
# Compile TEXT examples
|
# Compile TEXT examples
|
||||||
text/text_raylib_fonts: text/text_raylib_fonts.c
|
text/text_raylib_fonts: text/text_raylib_fonts.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||||
|
|
@ -997,6 +986,13 @@ shaders/shaders_hot_reloading: shaders/shaders_hot_reloading.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s FORCE_FILESYSTEM=1 \
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s FORCE_FILESYSTEM=1 \
|
||||||
--preload-file shaders/resources/shaders/glsl100/reload.fs@resources/shaders/glsl100/reload.fs
|
--preload-file shaders/resources/shaders/glsl100/reload.fs@resources/shaders/glsl100/reload.fs
|
||||||
|
|
||||||
|
shaders/shaders_lightmap: shaders/shaders_lightmap.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s FORCE_FILESYSTEM=1 \
|
||||||
|
--preload-file shaders/resources/shaders/glsl330/lightmap.vs \
|
||||||
|
--preload-file shaders/resources/shaders/glsl330/lightmap.fs \
|
||||||
|
--preload-file shaders/resources/cubicmap_atlas.png \
|
||||||
|
--preload-file shaders/resources/spark_flame.png
|
||||||
|
|
||||||
shaders/shaders_mesh_instancing: shaders/shaders_mesh_instancing.c
|
shaders/shaders_mesh_instancing: shaders/shaders_mesh_instancing.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||||
--preload-file shaders/resources/shaders/glsl100/lighting_instancing.vs@resources/shaders/glsl100/lighting_instancing.vs \
|
--preload-file shaders/resources/shaders/glsl100/lighting_instancing.vs@resources/shaders/glsl100/lighting_instancing.vs \
|
||||||
|
|
@ -1037,6 +1033,10 @@ audio/audio_sound_loading: audio/audio_sound_loading.c
|
||||||
--preload-file audio/resources/sound.wav@resources/sound.wav \
|
--preload-file audio/resources/sound.wav@resources/sound.wav \
|
||||||
--preload-file audio/resources/target.ogg@resources/target.ogg
|
--preload-file audio/resources/target.ogg@resources/target.ogg
|
||||||
|
|
||||||
|
audio/audio_sound_multi: audio/audio_sound_multi.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||||
|
--preload-file audio/resources/sound.wav@resources/sound.wav
|
||||||
|
|
||||||
audio/audio_stream_effects: audio/audio_stream_effects.c
|
audio/audio_stream_effects: audio/audio_stream_effects.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
|
||||||
--preload-file audio/resources/country.mp3@resources/country.mp3
|
--preload-file audio/resources/country.mp3@resources/country.mp3
|
||||||
|
|
@ -1046,6 +1046,25 @@ audio/audio_mixed_processor: audio/audio_mixed_processor.c
|
||||||
--preload-file audio/resources/country.mp3@resources/country.mp3 \
|
--preload-file audio/resources/country.mp3@resources/country.mp3 \
|
||||||
--preload-file audio/resources/coin.wav@resources/coin.wav
|
--preload-file audio/resources/coin.wav@resources/coin.wav
|
||||||
|
|
||||||
|
# Compile OTHERS examples
|
||||||
|
others/easings_testbed: others/easings_testbed.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
|
others/embedded_files_loading: others/embedded_files_loading.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
|
others/raylib_opengl_interop:
|
||||||
|
$(info Skipping_others_raylib_opengl_interop)
|
||||||
|
|
||||||
|
others/raymath_vector_angle: others/raymath_vector_angle.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
|
others/rlgl_compute_shader:
|
||||||
|
$(info Skipping_others_rlgl_compute_shader)
|
||||||
|
|
||||||
|
others/rlgl_standalone:
|
||||||
|
$(info Skipping_others_rlgl_standalone)
|
||||||
|
|
||||||
# Clean everything
|
# Clean everything
|
||||||
clean:
|
clean:
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
|
|
@ -1061,10 +1080,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
rm -f *.o
|
rm -f *.o
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
find . -type f -executable -delete
|
|
||||||
rm -fv *.o
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
find . -type f -executable -delete
|
find . -type f -executable -delete
|
||||||
rm -fv *.o
|
rm -fv *.o
|
||||||
|
|
|
||||||
|
|
@ -34,26 +34,27 @@ Examples using raylib core platform functionality like window creation, inputs,
|
||||||
| 08 | [core_2d_camera](core/core_2d_camera.c) | <img src="core/core_2d_camera.png" alt="core_2d_camera" width="80"> | ⭐️⭐️☆☆ | 1.5 | 3.0 | [Ray](https://github.com/raysan5) |
|
| 08 | [core_2d_camera](core/core_2d_camera.c) | <img src="core/core_2d_camera.png" alt="core_2d_camera" width="80"> | ⭐️⭐️☆☆ | 1.5 | 3.0 | [Ray](https://github.com/raysan5) |
|
||||||
| 09 | [core_2d_camera_mouse_zoom](core/core_2d_camera_mouse_zoom.c) | <img src="core/core_2d_camera_mouse_zoom.png" alt="core_2d_camera_mouse_zoom" width="80"> | ⭐️⭐️☆☆ | **4.2** | **4.2** | [Jeffery Myers](https://github.com/JeffM2501) |
|
| 09 | [core_2d_camera_mouse_zoom](core/core_2d_camera_mouse_zoom.c) | <img src="core/core_2d_camera_mouse_zoom.png" alt="core_2d_camera_mouse_zoom" width="80"> | ⭐️⭐️☆☆ | **4.2** | **4.2** | [Jeffery Myers](https://github.com/JeffM2501) |
|
||||||
| 10 | [core_2d_camera_platformer](core/core_2d_camera_platformer.c) | <img src="core/core_2d_camera_platformer.png" alt="core_2d_camera_platformer" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.0 | [avyy](https://github.com/avyy) |
|
| 10 | [core_2d_camera_platformer](core/core_2d_camera_platformer.c) | <img src="core/core_2d_camera_platformer.png" alt="core_2d_camera_platformer" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.0 | [avyy](https://github.com/avyy) |
|
||||||
| 11 | [core_3d_camera_mode](core/core_3d_camera_mode.c) | <img src="core/core_3d_camera_mode.png" alt="core_3d_camera_mode" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
|
| 11 | [core_2d_camera_split_screen](core/core_2d_camera_split_screen.c) | <img src="core/core_2d_camera_split_screen.png" alt="core_2d_camera_split_screen" width="80"> | ⭐️⭐️⭐️⭐️ | **4.5** | **4.5** | [Gabriel dos Santos Sanches](https://github.com/gabrielssanches) |
|
||||||
| 12 | [core_3d_camera_free](core/core_3d_camera_free.c) | <img src="core/core_3d_camera_free.png" alt="core_3d_camera_free" width="80"> | ⭐️☆☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) |
|
| 12 | [core_3d_camera_mode](core/core_3d_camera_mode.c) | <img src="core/core_3d_camera_mode.png" alt="core_3d_camera_mode" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
|
||||||
| 13 | [core_3d_camera_first_person](core/core_3d_camera_first_person.c) | <img src="core/core_3d_camera_first_person.png" alt="core_3d_camera_first_person" width="80"> | ⭐️⭐️☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) |
|
| 13 | [core_3d_camera_free](core/core_3d_camera_free.c) | <img src="core/core_3d_camera_free.png" alt="core_3d_camera_free" width="80"> | ⭐️☆☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) |
|
||||||
| 14 | [core_3d_picking](core/core_3d_picking.c) | <img src="core/core_3d_picking.png" alt="core_3d_picking" width="80"> | ⭐️⭐️☆☆ | 1.3 | **4.0** | [Ray](https://github.com/raysan5) |
|
| 14 | [core_3d_camera_first_person](core/core_3d_camera_first_person.c) | <img src="core/core_3d_camera_first_person.png" alt="core_3d_camera_first_person" width="80"> | ⭐️⭐️☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) |
|
||||||
| 15 | [core_world_screen](core/core_world_screen.c) | <img src="core/core_world_screen.png" alt="core_world_screen" width="80"> | ⭐️⭐️☆☆ | 1.3 | 1.4 | [Ray](https://github.com/raysan5) |
|
| 15 | [core_3d_camera:split_screen](core/core_3d_camera_split_screen.c) | <img src="core/core_3d_camera_split_screen.png" alt="core_3d_camera_split_screen" width="80"> | ⭐️⭐️⭐️⭐️ | 3.7 | **4.0** | [Jeffery Myers](https://github.com/JeffM2501) |
|
||||||
| 16 | [core_custom_logging](core/core_custom_logging.c) | <img src="core/core_custom_logging.png" alt="core_custom_logging" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 2.5 | [Pablo Marcos Oltra](https://github.com/pamarcos) |
|
| 16 | [core_3d_picking](core/core_3d_picking.c) | <img src="core/core_3d_picking.png" alt="core_3d_picking" width="80"> | ⭐️⭐️☆☆ | 1.3 | **4.0** | [Ray](https://github.com/raysan5) |
|
||||||
| 17 | [core_window_flags](core/core_window_flags.c) | <img src="core/core_window_flags.png" alt="core_window_flags" width="80"> | ⭐️⭐️⭐️☆ | 3.5 | 3.5 | [Ray](https://github.com/raysan5) |
|
| 17 | [core_world_screen](core/core_world_screen.c) | <img src="core/core_world_screen.png" alt="core_world_screen" width="80"> | ⭐️⭐️☆☆ | 1.3 | 1.4 | [Ray](https://github.com/raysan5) |
|
||||||
| 18 | [core_window_letterbox](core/core_window_letterbox.c) | <img src="core/core_window_letterbox.png" alt="core_window_letterbox" width="80"> | ⭐️⭐️☆☆ | 2.5 | **4.0** | [Anata](https://github.com/anatagawa) |
|
| 18 | [core_custom_logging](core/core_custom_logging.c) | <img src="core/core_custom_logging.png" alt="core_custom_logging" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 2.5 | [Pablo Marcos Oltra](https://github.com/pamarcos) |
|
||||||
| 19 | [core_window_should_close](core/core_window_should_close.c) | <img src="core/core_window_should_close.png" alt="core_window_should_close" width="80"> | ⭐️☆☆☆ | **4.2** | **4.2** | [Ray](https://github.com/raysan5) |
|
| 19 | [core_window_flags](core/core_window_flags.c) | <img src="core/core_window_flags.png" alt="core_window_flags" width="80"> | ⭐️⭐️⭐️☆ | 3.5 | 3.5 | [Ray](https://github.com/raysan5) |
|
||||||
| 20 | [core_drop_files](core/core_drop_files.c) | <img src="core/core_drop_files.png" alt="core_drop_files" width="80"> | ⭐️⭐️☆☆ | 1.3 | **4.2** | [Ray](https://github.com/raysan5) |
|
| 20 | [core_window_letterbox](core/core_window_letterbox.c) | <img src="core/core_window_letterbox.png" alt="core_window_letterbox" width="80"> | ⭐️⭐️☆☆ | 2.5 | **4.0** | [Anata](https://github.com/anatagawa) |
|
||||||
| 21 | [core_random_values](core/core_random_values.c) | <img src="core/core_random_values.png" alt="core_random_values" width="80"> | ⭐️☆☆☆ | 1.1 | 1.1 | [Ray](https://github.com/raysan5) |
|
| 21 | [core_window_should_close](core/core_window_should_close.c) | <img src="core/core_window_should_close.png" alt="core_window_should_close" width="80"> | ⭐️☆☆☆ | **4.2** | **4.2** | [Ray](https://github.com/raysan5) |
|
||||||
| 22 | [core_storage_values](core/core_storage_values.c) | <img src="core/core_storage_values.png" alt="core_storage_values" width="80"> | ⭐️⭐️☆☆ | 1.4 | **4.2** | [Ray](https://github.com/raysan5) |
|
| 22 | [core_drop_files](core/core_drop_files.c) | <img src="core/core_drop_files.png" alt="core_drop_files" width="80"> | ⭐️⭐️☆☆ | 1.3 | **4.2** | [Ray](https://github.com/raysan5) |
|
||||||
| 23 | [core_vr_simulator](core/core_vr_simulator.c) | <img src="core/core_vr_simulator.png" alt="core_vr_simulator" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | **4.0** | [Ray](https://github.com/raysan5) |
|
| 23 | [core_random_values](core/core_random_values.c) | <img src="core/core_random_values.png" alt="core_random_values" width="80"> | ⭐️☆☆☆ | 1.1 | 1.1 | [Ray](https://github.com/raysan5) |
|
||||||
| 24 | [core_loading_thread](core/core_loading_thread.c) | <img src="core/core_loading_thread.png" alt="core_loading_thread" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.0 | [Ray](https://github.com/raysan5) |
|
| 24 | [core_storage_values](core/core_storage_values.c) | <img src="core/core_storage_values.png" alt="core_storage_values" width="80"> | ⭐️⭐️☆☆ | 1.4 | **4.2** | [Ray](https://github.com/raysan5) |
|
||||||
| 25 | [core_scissor_test](core/core_scissor_test.c) | <img src="core/core_scissor_test.png" alt="core_scissor_test" width="80"> | ⭐️☆☆☆ | 2.5 | 3.0 | [Chris Dill](https://github.com/MysteriousSpace) |
|
| 25 | [core_vr_simulator](core/core_vr_simulator.c) | <img src="core/core_vr_simulator.png" alt="core_vr_simulator" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | **4.0** | [Ray](https://github.com/raysan5) |
|
||||||
| 26 | [core_basic_screen_manager](core/core_basic_screen_manager.c) | <img src="core/core_basic_screen_manager.png" alt="core_basic_screen_manager" width="80"> | ⭐️☆☆☆ | **4.0** | **4.0** | [Ray](https://github.com/raysan5) |
|
| 26 | [core_loading_thread](core/core_loading_thread.c) | <img src="core/core_loading_thread.png" alt="core_loading_thread" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.0 | [Ray](https://github.com/raysan5) |
|
||||||
| 27 | [core_custom_frame_control](core/core_custom_frame_control.c) | <img src="core/core_custom_frame_control.png" alt="core_custom_frame_control" width="80"> | ⭐️⭐️⭐️⭐️ | **4.0** | **4.0** | [Ray](https://github.com/raysan5) |
|
| 27 | [core_scissor_test](core/core_scissor_test.c) | <img src="core/core_scissor_test.png" alt="core_scissor_test" width="80"> | ⭐️☆☆☆ | 2.5 | 3.0 | [Chris Dill](https://github.com/MysteriousSpace) |
|
||||||
| 28 | [core_smooth_pixelperfect](core/core_smooth_pixelperfect.c) | <img src="core/core_smooth_pixelperfect.png" alt="core_smooth_pixelperfect" width="80"> | ⭐️⭐️⭐️☆ | 3.7 | **4.0** | [Giancamillo Alessandroni](https://github.com/NotManyIdeasDev) |
|
| 28 | [core_basic_screen_manager](core/core_basic_screen_manager.c) | <img src="core/core_basic_screen_manager.png" alt="core_basic_screen_manager" width="80"> | ⭐️☆☆☆ | **4.0** | **4.0** | [Ray](https://github.com/raysan5) |
|
||||||
| 29 | [core_split_screen](core/core_split_screen.c) | <img src="core/core_split_screen.png" alt="core_split_screen" width="80"> | ⭐️⭐️⭐️⭐️ | 3.7 | **4.0** | [Jeffery Myers](https://github.com/JeffM2501) |
|
| 29 | [core_custom_frame_control](core/core_custom_frame_control.c) | <img src="core/core_custom_frame_control.png" alt="core_custom_frame_control" width="80"> | ⭐️⭐️⭐️⭐️ | **4.0** | **4.0** | [Ray](https://github.com/raysan5) |
|
||||||
| 30 | [core_window_should_close](core/core_window_should_close.c) | <img src="core/core_window_should_close.png" alt="core_window_should_close" width="80"> | ⭐️⭐️☆☆ | **4.2** | **4.2** | [Ray](https://github.com/raysan5) |
|
| 30 | [core_smooth_pixelperfect](core/core_smooth_pixelperfect.c) | <img src="core/core_smooth_pixelperfect.png" alt="core_smooth_pixelperfect" width="80"> | ⭐️⭐️⭐️☆ | 3.7 | **4.0** | [Giancamillo Alessandroni](https://github.com/NotManyIdeasDev) |
|
||||||
|
| 31 | [core_window_should_close](core/core_window_should_close.c) | <img src="core/core_window_should_close.png" alt="core_window_should_close" width="80"> | ⭐️⭐️☆☆ | **4.2** | **4.2** | [Ray](https://github.com/raysan5) |
|
||||||
|
|
||||||
### category: shapes
|
### category: shapes
|
||||||
|
|
||||||
|
|
@ -175,6 +176,7 @@ Examples using raylib shaders functionality, including shaders loading, paramete
|
||||||
| 114 | [shaders_mesh_instancing](shaders/shaders_mesh_instancing.c) | <img src="shaders/shaders_mesh_instancing.png" alt="shaders_mesh_instancing" width="80"> | ⭐️⭐️⭐️⭐️ | 3.7 | **4.2** | [seanpringle](https://github.com/seanpringle) |
|
| 114 | [shaders_mesh_instancing](shaders/shaders_mesh_instancing.c) | <img src="shaders/shaders_mesh_instancing.png" alt="shaders_mesh_instancing" width="80"> | ⭐️⭐️⭐️⭐️ | 3.7 | **4.2** | [seanpringle](https://github.com/seanpringle) |
|
||||||
| 115 | [shaders_multi_sample2d](shaders/shaders_multi_sample2d.c) | <img src="shaders/shaders_multi_sample2d.png" alt="shaders_multi_sample2d" width="80"> | ⭐️⭐️☆☆ | 3.5 | 3.5 | [Ray](https://github.com/raysan5) |
|
| 115 | [shaders_multi_sample2d](shaders/shaders_multi_sample2d.c) | <img src="shaders/shaders_multi_sample2d.png" alt="shaders_multi_sample2d" width="80"> | ⭐️⭐️☆☆ | 3.5 | 3.5 | [Ray](https://github.com/raysan5) |
|
||||||
| 116 | [shaders_spotlight](shaders/shaders_spotlight.c) | <img src="shaders/shaders_spotlight.png" alt="shaders_spotlight" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/codifies) |
|
| 116 | [shaders_spotlight](shaders/shaders_spotlight.c) | <img src="shaders/shaders_spotlight.png" alt="shaders_spotlight" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/codifies) |
|
||||||
|
| 117 | [shaders_deferred_render](shaders/shaders_deferred_render.c) | <img src="shaders/shaders_deferred_render.png" alt="shaders_deferred_render" width="80"> | ⭐️⭐️⭐️⭐️ | 4.5 | 4.5 | [Justin Andreas Lacoste](https://github.com/27justin) |
|
||||||
|
|
||||||
### category: audio
|
### category: audio
|
||||||
|
|
||||||
|
|
@ -182,10 +184,10 @@ Examples using raylib audio functionality, including sound/music loading and pla
|
||||||
|
|
||||||
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
||||||
|----|----------|--------|:-------------------:|:------------------:|:------------------:|:----------|
|
|----|----------|--------|:-------------------:|:------------------:|:------------------:|:----------|
|
||||||
| 117 | [audio_module_playing](audio/audio_module_playing.c) | <img src="audio/audio_module_playing.png" alt="audio_module_playing" width="80"> | ⭐️☆☆☆ | 1.5 | 3.5 | [Ray](https://github.com/raysan5) |
|
| 118 | [audio_module_playing](audio/audio_module_playing.c) | <img src="audio/audio_module_playing.png" alt="audio_module_playing" width="80"> | ⭐️☆☆☆ | 1.5 | 3.5 | [Ray](https://github.com/raysan5) |
|
||||||
| 118 | [audio_music_stream](audio/audio_music_stream.c) | <img src="audio/audio_music_stream.png" alt="audio_music_stream" width="80"> | ⭐️☆☆☆ | 1.3 | **4.2** | [Ray](https://github.com/raysan5) |
|
| 119 | [audio_music_stream](audio/audio_music_stream.c) | <img src="audio/audio_music_stream.png" alt="audio_music_stream" width="80"> | ⭐️☆☆☆ | 1.3 | **4.2** | [Ray](https://github.com/raysan5) |
|
||||||
| 119 | [audio_raw_stream](audio/audio_raw_stream.c) | <img src="audio/audio_raw_stream.png" alt="audio_raw_stream" width="80"> | ⭐️⭐️⭐️☆ | 1.6 | **4.2** | [Ray](https://github.com/raysan5) |
|
| 120 | [audio_raw_stream](audio/audio_raw_stream.c) | <img src="audio/audio_raw_stream.png" alt="audio_raw_stream" width="80"> | ⭐️⭐️⭐️☆ | 1.6 | **4.2** | [Ray](https://github.com/raysan5) |
|
||||||
| 120 | [audio_sound_loading](audio/audio_sound_loading.c) | <img src="audio/audio_sound_loading.png" alt="audio_sound_loading" width="80"> | ⭐️☆☆☆ | 1.1 | 3.5 | [Ray](https://github.com/raysan5) |
|
| 121 | [audio_sound_loading](audio/audio_sound_loading.c) | <img src="audio/audio_sound_loading.png" alt="audio_sound_loading" width="80"> | ⭐️☆☆☆ | 1.1 | 3.5 | [Ray](https://github.com/raysan5) |
|
||||||
|
|
||||||
### category: others
|
### category: others
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
StopMusicStream(music);
|
StopMusicStream(music);
|
||||||
PlayMusicStream(music);
|
PlayMusicStream(music);
|
||||||
|
pause = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pause/Resume music playing
|
// Pause/Resume music playing
|
||||||
|
|
@ -134,6 +135,14 @@ int main(void)
|
||||||
DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, MAROON);
|
DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, MAROON);
|
||||||
DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, GRAY);
|
DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, GRAY);
|
||||||
|
|
||||||
|
// Draw help instructions
|
||||||
|
DrawRectangle(20, 20, 425, 145, WHITE);
|
||||||
|
DrawRectangleLines(20, 20, 425, 145, GRAY);
|
||||||
|
DrawText("PRESS SPACE TO RESTART MUSIC", 40, 40, 20, BLACK);
|
||||||
|
DrawText("PRESS P TO PAUSE/RESUME", 40, 70, 20, BLACK);
|
||||||
|
DrawText("PRESS UP/DOWN TO CHANGE SPEED", 40, 100, 20, BLACK);
|
||||||
|
DrawText(TextFormat("SPEED: %f", pitch), 40, 130, 20, MAROON);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 44 KiB |
87
examples/audio/audio_sound_multi.c
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [audio] example - Playing sound multiple times
|
||||||
|
*
|
||||||
|
* Example originally created with raylib 4.6
|
||||||
|
*
|
||||||
|
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||||
|
* BSD-like license that allows static linking with closed source software
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Jeffery Myers (@JeffM2501)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#define MAX_SOUNDS 10
|
||||||
|
Sound soundArray[MAX_SOUNDS] = { 0 };
|
||||||
|
int currentSound;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [audio] example - playing sound multiple times");
|
||||||
|
|
||||||
|
InitAudioDevice(); // Initialize audio device
|
||||||
|
|
||||||
|
// load the sound list
|
||||||
|
soundArray[0] = LoadSound("resources/sound.wav"); // Load WAV audio file into the first slot as the 'source' sound
|
||||||
|
// this sound owns the sample data
|
||||||
|
for (int i = 1; i < MAX_SOUNDS; i++)
|
||||||
|
{
|
||||||
|
soundArray[i] = LoadSoundAlias(soundArray[0]); // Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
|
||||||
|
}
|
||||||
|
currentSound = 0; // set the sound list to the start
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsKeyPressed(KEY_SPACE))
|
||||||
|
{
|
||||||
|
PlaySound(soundArray[currentSound]); // play the next open sound slot
|
||||||
|
currentSound++; // increment the sound slot
|
||||||
|
if (currentSound >= MAX_SOUNDS) // if the sound slot is out of bounds, go back to 0
|
||||||
|
currentSound = 0;
|
||||||
|
|
||||||
|
// Note: a better way would be to look at the list for the first sound that is not playing and use that slot
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
DrawText("Press SPACE to PLAY a WAV sound!", 200, 180, 20, LIGHTGRAY);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
for (int i = 1; i < MAX_SOUNDS; i++)
|
||||||
|
UnloadSoundAlias(soundArray[i]); // Unload sound aliases
|
||||||
|
UnloadSound(soundArray[0]); // Unload source sound data
|
||||||
|
|
||||||
|
CloseAudioDevice(); // Close audio device
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
examples/audio/audio_sound_multi.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
|
|
@ -1,6 +1,7 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
|
|
||||||
|
// This has been tested to work with zig 0.11.0 (67709b6, Aug 4 2023)
|
||||||
fn add_module(comptime module: []const u8, b: *std.Build, target: std.zig.CrossTarget, optimize: std.builtin.OptimizeMode) !*std.Build.Step {
|
fn add_module(comptime module: []const u8, b: *std.Build, target: std.zig.CrossTarget, optimize: std.builtin.OptimizeMode) !*std.Build.Step {
|
||||||
if (target.getOsTag() == .emscripten) {
|
if (target.getOsTag() == .emscripten) {
|
||||||
@panic("Emscripten building via Zig unsupported");
|
@panic("Emscripten building via Zig unsupported");
|
||||||
|
|
@ -10,7 +11,7 @@ fn add_module(comptime module: []const u8, b: *std.Build, target: std.zig.CrossT
|
||||||
const dir = try std.fs.cwd().openIterableDir(module, .{});
|
const dir = try std.fs.cwd().openIterableDir(module, .{});
|
||||||
var iter = dir.iterate();
|
var iter = dir.iterate();
|
||||||
while (try iter.next()) |entry| {
|
while (try iter.next()) |entry| {
|
||||||
if (entry.kind != .File) continue;
|
if (entry.kind != .file) continue;
|
||||||
const extension_idx = std.mem.lastIndexOf(u8, entry.name, ".c") orelse continue;
|
const extension_idx = std.mem.lastIndexOf(u8, entry.name, ".c") orelse continue;
|
||||||
const name = entry.name[0..extension_idx];
|
const name = entry.name[0..extension_idx];
|
||||||
const path = try std.fs.path.join(b.allocator, &.{ module, entry.name });
|
const path = try std.fs.path.join(b.allocator, &.{ module, entry.name });
|
||||||
|
|
@ -23,26 +24,26 @@ fn add_module(comptime module: []const u8, b: *std.Build, target: std.zig.CrossT
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
exe.addCSourceFile(path, &[_][]const u8{});
|
exe.addCSourceFile(.{ .file = .{ .path = path }, .flags = &.{} });
|
||||||
exe.linkLibC();
|
exe.linkLibC();
|
||||||
exe.addObjectFile(switch (target.getOsTag()) {
|
exe.addObjectFile(switch (target.getOsTag()) {
|
||||||
.windows => "../src/raylib.lib",
|
.windows => .{ .path = "../zig-out/lib/raylib.lib" },
|
||||||
.linux => "../src/libraylib.a",
|
.linux => .{ .path = "../zig-out/lib/libraylib.a" },
|
||||||
.macos => "../src/libraylib.a",
|
.macos => .{ .path = "../zig-out/lib/libraylib.a" },
|
||||||
.emscripten => "../src/libraylib.a",
|
.emscripten => .{ .path = "../zig-out/lib/libraylib.a" },
|
||||||
else => @panic("Unsupported OS"),
|
else => @panic("Unsupported OS"),
|
||||||
});
|
});
|
||||||
|
|
||||||
exe.addIncludePath("../src");
|
exe.addIncludePath(.{ .path = "../src" });
|
||||||
exe.addIncludePath("../src/external");
|
exe.addIncludePath(.{ .path = "../src/external" });
|
||||||
exe.addIncludePath("../src/external/glfw/include");
|
exe.addIncludePath(.{ .path = "../src/external/glfw/include" });
|
||||||
|
|
||||||
switch (target.getOsTag()) {
|
switch (target.getOsTag()) {
|
||||||
.windows => {
|
.windows => {
|
||||||
exe.linkSystemLibrary("winmm");
|
exe.linkSystemLibrary("winmm");
|
||||||
exe.linkSystemLibrary("gdi32");
|
exe.linkSystemLibrary("gdi32");
|
||||||
exe.linkSystemLibrary("opengl32");
|
exe.linkSystemLibrary("opengl32");
|
||||||
exe.addIncludePath("external/glfw/deps/mingw");
|
exe.addIncludePath(.{ .path = "external/glfw/deps/mingw" });
|
||||||
|
|
||||||
exe.defineCMacro("PLATFORM_DESKTOP", null);
|
exe.defineCMacro("PLATFORM_DESKTOP", null);
|
||||||
},
|
},
|
||||||
|
|
@ -70,13 +71,15 @@ fn add_module(comptime module: []const u8, b: *std.Build, target: std.zig.CrossT
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
exe.setOutputDir(module);
|
const install_cmd = b.addInstallArtifact(exe, .{});
|
||||||
|
|
||||||
var run = exe.run();
|
const run_cmd = b.addRunArtifact(exe);
|
||||||
run.step.dependOn(&b.addInstallArtifact(exe).step);
|
run_cmd.step.dependOn(&install_cmd.step);
|
||||||
run.cwd = module;
|
|
||||||
b.step(name, name).dependOn(&run.step);
|
const run_step = b.step(name, name);
|
||||||
all.dependOn(&exe.step);
|
run_step.dependOn(&run_cmd.step);
|
||||||
|
|
||||||
|
all.dependOn(&install_cmd.step);
|
||||||
}
|
}
|
||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 16 KiB |
167
examples/core/core_2d_camera_split_screen.c
Normal file
|
|
@ -0,0 +1,167 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [core] example - 2d camera split screen
|
||||||
|
*
|
||||||
|
* Addapted from the core_3d_camera_split_screen example:
|
||||||
|
* https://github.com/raysan5/raylib/blob/master/examples/core/core_3d_camera_split_screen.c
|
||||||
|
*
|
||||||
|
* Example originally created with raylib 4.5, last time updated with raylib 4.5
|
||||||
|
*
|
||||||
|
* Example contributed by Gabriel dos Santos Sanches (@gabrielssanches) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||||
|
* BSD-like license that allows static linking with closed source software
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Gabriel dos Santos Sanches (@gabrielssanches)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#define PLAYER_SIZE 40
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 440;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera split screen");
|
||||||
|
|
||||||
|
Rectangle player1 = { 200, 200, PLAYER_SIZE, PLAYER_SIZE };
|
||||||
|
Rectangle player2 = { 250, 200, PLAYER_SIZE, PLAYER_SIZE };
|
||||||
|
|
||||||
|
Camera2D camera1 = { 0 };
|
||||||
|
camera1.target = (Vector2){ player1.x, player1.y };
|
||||||
|
camera1.offset = (Vector2){ 200.0f, 200.0f };
|
||||||
|
camera1.rotation = 0.0f;
|
||||||
|
camera1.zoom = 1.0f;
|
||||||
|
|
||||||
|
Camera2D camera2 = { 0 };
|
||||||
|
camera2.target = (Vector2){ player2.x, player2.y };
|
||||||
|
camera2.offset = (Vector2){ 200.0f, 200.0f };
|
||||||
|
camera2.rotation = 0.0f;
|
||||||
|
camera2.zoom = 1.0f;
|
||||||
|
|
||||||
|
RenderTexture screenCamera1 = LoadRenderTexture(screenWidth/2, screenHeight);
|
||||||
|
RenderTexture screenCamera2 = LoadRenderTexture(screenWidth/2, screenHeight);
|
||||||
|
|
||||||
|
// Build a flipped rectangle the size of the split view to use for drawing later
|
||||||
|
Rectangle splitScreenRect = { 0.0f, 0.0f, (float)screenCamera1.texture.width, (float)-screenCamera1.texture.height };
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsKeyDown(KEY_S)) player1.y += 3.0f;
|
||||||
|
else if (IsKeyDown(KEY_W)) player1.y -= 3.0f;
|
||||||
|
if (IsKeyDown(KEY_D)) player1.x += 3.0f;
|
||||||
|
else if (IsKeyDown(KEY_A)) player1.x -= 3.0f;
|
||||||
|
|
||||||
|
if (IsKeyDown(KEY_UP)) player2.y -= 3.0f;
|
||||||
|
else if (IsKeyDown(KEY_DOWN)) player2.y += 3.0f;
|
||||||
|
if (IsKeyDown(KEY_RIGHT)) player2.x += 3.0f;
|
||||||
|
else if (IsKeyDown(KEY_LEFT)) player2.x -= 3.0f;
|
||||||
|
|
||||||
|
camera1.target = (Vector2){ player1.x, player1.y };
|
||||||
|
camera2.target = (Vector2){ player2.x, player2.y };
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginTextureMode(screenCamera1);
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
BeginMode2D(camera1);
|
||||||
|
|
||||||
|
// Draw full scene with first camera
|
||||||
|
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
|
||||||
|
{
|
||||||
|
DrawLineV((Vector2){PLAYER_SIZE*i, 0}, (Vector2){PLAYER_SIZE*i, screenHeight}, LIGHTGRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < screenHeight/PLAYER_SIZE + 1; i++)
|
||||||
|
{
|
||||||
|
DrawLineV((Vector2){0, PLAYER_SIZE*i}, (Vector2){screenWidth, PLAYER_SIZE*i}, LIGHTGRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < screenWidth/PLAYER_SIZE; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < screenHeight/PLAYER_SIZE; j++)
|
||||||
|
{
|
||||||
|
DrawText(TextFormat("[%i,%i]", i, j), 10 + PLAYER_SIZE*i, 15 + PLAYER_SIZE*j, 10, LIGHTGRAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawRectangleRec(player1, RED);
|
||||||
|
DrawRectangleRec(player2, BLUE);
|
||||||
|
EndMode2D();
|
||||||
|
|
||||||
|
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
|
||||||
|
DrawText("PLAYER1: W/S/A/D to move", 10, 10, 10, MAROON);
|
||||||
|
|
||||||
|
EndTextureMode();
|
||||||
|
|
||||||
|
BeginTextureMode(screenCamera2);
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
BeginMode2D(camera2);
|
||||||
|
|
||||||
|
// Draw full scene with second camera
|
||||||
|
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
|
||||||
|
{
|
||||||
|
DrawLineV((Vector2){PLAYER_SIZE*i, 0}, (Vector2){PLAYER_SIZE*i, screenHeight}, LIGHTGRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < screenHeight/PLAYER_SIZE + 1; i++)
|
||||||
|
{
|
||||||
|
DrawLineV((Vector2){0, PLAYER_SIZE*i}, (Vector2){screenWidth, PLAYER_SIZE*i}, LIGHTGRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < screenWidth/PLAYER_SIZE; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < screenHeight/PLAYER_SIZE; j++)
|
||||||
|
{
|
||||||
|
DrawText(TextFormat("[%i,%i]", i, j), 10 + PLAYER_SIZE*i, 15 + PLAYER_SIZE*j, 10, LIGHTGRAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawRectangleRec(player1, RED);
|
||||||
|
DrawRectangleRec(player2, BLUE);
|
||||||
|
|
||||||
|
EndMode2D();
|
||||||
|
|
||||||
|
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
|
||||||
|
DrawText("PLAYER2: UP/DOWN/LEFT/RIGHT to move", 10, 10, 10, DARKBLUE);
|
||||||
|
|
||||||
|
EndTextureMode();
|
||||||
|
|
||||||
|
// Draw both views render textures to the screen side by side
|
||||||
|
BeginDrawing();
|
||||||
|
ClearBackground(BLACK);
|
||||||
|
|
||||||
|
DrawTextureRec(screenCamera1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
|
||||||
|
DrawTextureRec(screenCamera2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
|
||||||
|
|
||||||
|
DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY);
|
||||||
|
EndDrawing();
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
UnloadRenderTexture(screenCamera1); // Unload render texture
|
||||||
|
UnloadRenderTexture(screenCamera2); // Unload render texture
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
examples/core/core_2d_camera_split_screen.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
|
|
@ -65,15 +65,13 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawRectangle( 10, 10, 320, 133, Fade(SKYBLUE, 0.5f));
|
DrawRectangle( 10, 10, 320, 93, Fade(SKYBLUE, 0.5f));
|
||||||
DrawRectangleLines( 10, 10, 320, 133, BLUE);
|
DrawRectangleLines( 10, 10, 320, 93, BLUE);
|
||||||
|
|
||||||
DrawText("Free camera default controls:", 20, 20, 10, BLACK);
|
DrawText("Free camera default controls:", 20, 20, 10, BLACK);
|
||||||
DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, DARKGRAY);
|
DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, DARKGRAY);
|
||||||
DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, DARKGRAY);
|
DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, DARKGRAY);
|
||||||
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, DARKGRAY);
|
DrawText("- Z to zoom to (0, 0, 0)", 40, 80, 10, DARKGRAY);
|
||||||
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, DARKGRAY);
|
|
||||||
DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, DARKGRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [core] example - split screen
|
* raylib [core] example - 3d cmaera split screen
|
||||||
*
|
*
|
||||||
* Example originally created with raylib 3.7, last time updated with raylib 4.0
|
* Example originally created with raylib 3.7, last time updated with raylib 4.0
|
||||||
*
|
*
|
||||||
|
|
@ -15,32 +15,6 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
Camera cameraPlayer1 = { 0 };
|
|
||||||
Camera cameraPlayer2 = { 0 };
|
|
||||||
|
|
||||||
// Scene drawing
|
|
||||||
void DrawScene(void)
|
|
||||||
{
|
|
||||||
int count = 5;
|
|
||||||
float spacing = 4;
|
|
||||||
|
|
||||||
// Grid of cube trees on a plane to make a "world"
|
|
||||||
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 50, 50 }, BEIGE); // Simple world plane
|
|
||||||
|
|
||||||
for (float x = -count*spacing; x <= count*spacing; x += spacing)
|
|
||||||
{
|
|
||||||
for (float z = -count*spacing; z <= count*spacing; z += spacing)
|
|
||||||
{
|
|
||||||
DrawCube((Vector3) { x, 1.5f, z }, 1, 1, 1, LIME);
|
|
||||||
DrawCube((Vector3) { x, 0.5f, z }, 0.25f, 1, 0.25f, BROWN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a cube at each player's position
|
|
||||||
DrawCube(cameraPlayer1.position, 1, 1, 1, RED);
|
|
||||||
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
@ -51,9 +25,10 @@ int main(void)
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - split screen");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera split screen");
|
||||||
|
|
||||||
// Setup player 1 camera and screen
|
// Setup player 1 camera and screen
|
||||||
|
Camera cameraPlayer1 = { 0 };
|
||||||
cameraPlayer1.fovy = 45.0f;
|
cameraPlayer1.fovy = 45.0f;
|
||||||
cameraPlayer1.up.y = 1.0f;
|
cameraPlayer1.up.y = 1.0f;
|
||||||
cameraPlayer1.target.y = 1.0f;
|
cameraPlayer1.target.y = 1.0f;
|
||||||
|
|
@ -63,6 +38,7 @@ int main(void)
|
||||||
RenderTexture screenPlayer1 = LoadRenderTexture(screenWidth/2, screenHeight);
|
RenderTexture screenPlayer1 = LoadRenderTexture(screenWidth/2, screenHeight);
|
||||||
|
|
||||||
// Setup player two camera and screen
|
// Setup player two camera and screen
|
||||||
|
Camera cameraPlayer2 = { 0 };
|
||||||
cameraPlayer2.fovy = 45.0f;
|
cameraPlayer2.fovy = 45.0f;
|
||||||
cameraPlayer2.up.y = 1.0f;
|
cameraPlayer2.up.y = 1.0f;
|
||||||
cameraPlayer2.target.y = 3.0f;
|
cameraPlayer2.target.y = 3.0f;
|
||||||
|
|
@ -74,6 +50,10 @@ int main(void)
|
||||||
// Build a flipped rectangle the size of the split view to use for drawing later
|
// Build a flipped rectangle the size of the split view to use for drawing later
|
||||||
Rectangle splitScreenRect = { 0.0f, 0.0f, (float)screenPlayer1.texture.width, (float)-screenPlayer1.texture.height };
|
Rectangle splitScreenRect = { 0.0f, 0.0f, (float)screenPlayer1.texture.width, (float)-screenPlayer1.texture.height };
|
||||||
|
|
||||||
|
// Grid data
|
||||||
|
int count = 5;
|
||||||
|
float spacing = 4;
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -116,26 +96,69 @@ int main(void)
|
||||||
// Draw Player1 view to the render texture
|
// Draw Player1 view to the render texture
|
||||||
BeginTextureMode(screenPlayer1);
|
BeginTextureMode(screenPlayer1);
|
||||||
ClearBackground(SKYBLUE);
|
ClearBackground(SKYBLUE);
|
||||||
|
|
||||||
BeginMode3D(cameraPlayer1);
|
BeginMode3D(cameraPlayer1);
|
||||||
DrawScene();
|
|
||||||
|
// Draw scene: grid of cube trees on a plane to make a "world"
|
||||||
|
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 50, 50 }, BEIGE); // Simple world plane
|
||||||
|
|
||||||
|
for (float x = -count*spacing; x <= count*spacing; x += spacing)
|
||||||
|
{
|
||||||
|
for (float z = -count*spacing; z <= count*spacing; z += spacing)
|
||||||
|
{
|
||||||
|
DrawCube((Vector3) { x, 1.5f, z }, 1, 1, 1, LIME);
|
||||||
|
DrawCube((Vector3) { x, 0.5f, z }, 0.25f, 1, 0.25f, BROWN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw a cube at each player's position
|
||||||
|
DrawCube(cameraPlayer1.position, 1, 1, 1, RED);
|
||||||
|
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
DrawText("PLAYER1 W/S to move", 10, 10, 20, RED);
|
|
||||||
|
DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f));
|
||||||
|
DrawText("PLAYER1: W/S to move", 10, 10, 20, MAROON);
|
||||||
|
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
// Draw Player2 view to the render texture
|
// Draw Player2 view to the render texture
|
||||||
BeginTextureMode(screenPlayer2);
|
BeginTextureMode(screenPlayer2);
|
||||||
ClearBackground(SKYBLUE);
|
ClearBackground(SKYBLUE);
|
||||||
|
|
||||||
BeginMode3D(cameraPlayer2);
|
BeginMode3D(cameraPlayer2);
|
||||||
DrawScene();
|
|
||||||
|
// Draw scene: grid of cube trees on a plane to make a "world"
|
||||||
|
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 50, 50 }, BEIGE); // Simple world plane
|
||||||
|
|
||||||
|
for (float x = -count*spacing; x <= count*spacing; x += spacing)
|
||||||
|
{
|
||||||
|
for (float z = -count*spacing; z <= count*spacing; z += spacing)
|
||||||
|
{
|
||||||
|
DrawCube((Vector3) { x, 1.5f, z }, 1, 1, 1, LIME);
|
||||||
|
DrawCube((Vector3) { x, 0.5f, z }, 0.25f, 1, 0.25f, BROWN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw a cube at each player's position
|
||||||
|
DrawCube(cameraPlayer1.position, 1, 1, 1, RED);
|
||||||
|
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
DrawText("PLAYER2 UP/DOWN to move", 10, 10, 20, BLUE);
|
|
||||||
|
DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f));
|
||||||
|
DrawText("PLAYER2: UP/DOWN to move", 10, 10, 20, DARKBLUE);
|
||||||
|
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
// Draw both views render textures to the screen side by side
|
// Draw both views render textures to the screen side by side
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(BLACK);
|
ClearBackground(BLACK);
|
||||||
|
|
||||||
DrawTextureRec(screenPlayer1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
|
DrawTextureRec(screenPlayer1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
|
||||||
DrawTextureRec(screenPlayer2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
|
DrawTextureRec(screenPlayer2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
|
||||||
|
|
||||||
|
DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
||||||
BIN
examples/core/core_3d_camera_split_screen.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
326
examples/core/core_automation_events.c
Normal file
|
|
@ -0,0 +1,326 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [core] example - automation events
|
||||||
|
*
|
||||||
|
* Example originally created with raylib 5.0, last time updated with raylib 5.0
|
||||||
|
*
|
||||||
|
* Example based on 2d_camera_platformer example by arvyy (@arvyy)
|
||||||
|
*
|
||||||
|
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||||
|
* BSD-like license that allows static linking with closed source software
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "raymath.h"
|
||||||
|
|
||||||
|
#define GRAVITY 400
|
||||||
|
#define PLAYER_JUMP_SPD 350.0f
|
||||||
|
#define PLAYER_HOR_SPD 200.0f
|
||||||
|
|
||||||
|
#define MAX_ENVIRONMENT_ELEMENTS 5
|
||||||
|
|
||||||
|
typedef struct Player {
|
||||||
|
Vector2 position;
|
||||||
|
float speed;
|
||||||
|
bool canJump;
|
||||||
|
} Player;
|
||||||
|
|
||||||
|
typedef struct EnvElement {
|
||||||
|
Rectangle rect;
|
||||||
|
int blocking;
|
||||||
|
Color color;
|
||||||
|
} EnvElement;
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - automation events");
|
||||||
|
|
||||||
|
// Define player
|
||||||
|
Player player = { 0 };
|
||||||
|
player.position = (Vector2){ 400, 280 };
|
||||||
|
player.speed = 0;
|
||||||
|
player.canJump = false;
|
||||||
|
|
||||||
|
// Define environment elements (platforms)
|
||||||
|
EnvElement envElements[MAX_ENVIRONMENT_ELEMENTS] = {
|
||||||
|
{{ 0, 0, 1000, 400 }, 0, LIGHTGRAY },
|
||||||
|
{{ 0, 400, 1000, 200 }, 1, GRAY },
|
||||||
|
{{ 300, 200, 400, 10 }, 1, GRAY },
|
||||||
|
{{ 250, 300, 100, 10 }, 1, GRAY },
|
||||||
|
{{ 650, 300, 100, 10 }, 1, GRAY }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Define camera
|
||||||
|
Camera2D camera = { 0 };
|
||||||
|
camera.target = player.position;
|
||||||
|
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
||||||
|
camera.rotation = 0.0f;
|
||||||
|
camera.zoom = 1.0f;
|
||||||
|
|
||||||
|
// Automation events
|
||||||
|
AutomationEventList aelist = LoadAutomationEventList(0); // Initialize list of automation events to record new events
|
||||||
|
SetAutomationEventList(&aelist);
|
||||||
|
bool eventRecording = false;
|
||||||
|
bool eventPlaying = false;
|
||||||
|
|
||||||
|
unsigned int frameCounter = 0;
|
||||||
|
unsigned int playFrameCounter = 0;
|
||||||
|
unsigned int currentPlayFrame = 0;
|
||||||
|
|
||||||
|
SetTargetFPS(60);
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose())
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
float deltaTime = 0.015f;//GetFrameTime();
|
||||||
|
|
||||||
|
// Dropped files logic
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsFileDropped())
|
||||||
|
{
|
||||||
|
FilePathList droppedFiles = LoadDroppedFiles();
|
||||||
|
|
||||||
|
// Supports loading .rgs style files (text or binary) and .png style palette images
|
||||||
|
if (IsFileExtension(droppedFiles.paths[0], ".txt;.rae"))
|
||||||
|
{
|
||||||
|
UnloadAutomationEventList(&aelist);
|
||||||
|
aelist = LoadAutomationEventList(droppedFiles.paths[0]);
|
||||||
|
|
||||||
|
eventRecording = false;
|
||||||
|
|
||||||
|
// Reset scene state to play
|
||||||
|
eventPlaying = true;
|
||||||
|
playFrameCounter = 0;
|
||||||
|
currentPlayFrame = 0;
|
||||||
|
|
||||||
|
player.position = (Vector2){ 400, 280 };
|
||||||
|
player.speed = 0;
|
||||||
|
player.canJump = false;
|
||||||
|
|
||||||
|
camera.target = player.position;
|
||||||
|
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
||||||
|
camera.rotation = 0.0f;
|
||||||
|
camera.zoom = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnloadDroppedFiles(droppedFiles); // Unload filepaths from memory
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Update player
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsKeyDown(KEY_LEFT)) player.position.x -= PLAYER_HOR_SPD*deltaTime;
|
||||||
|
if (IsKeyDown(KEY_RIGHT)) player.position.x += PLAYER_HOR_SPD*deltaTime;
|
||||||
|
if (IsKeyDown(KEY_SPACE) && player.canJump)
|
||||||
|
{
|
||||||
|
player.speed = -PLAYER_JUMP_SPD;
|
||||||
|
player.canJump = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hitObstacle = 0;
|
||||||
|
for (int i = 0; i < MAX_ENVIRONMENT_ELEMENTS; i++)
|
||||||
|
{
|
||||||
|
EnvElement *element = &envElements[i];
|
||||||
|
Vector2 *p = &(player.position);
|
||||||
|
if (element->blocking &&
|
||||||
|
element->rect.x <= p->x &&
|
||||||
|
element->rect.x + element->rect.width >= p->x &&
|
||||||
|
element->rect.y >= p->y &&
|
||||||
|
element->rect.y <= p->y + player.speed*deltaTime)
|
||||||
|
{
|
||||||
|
hitObstacle = 1;
|
||||||
|
player.speed = 0.0f;
|
||||||
|
p->y = element->rect.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hitObstacle)
|
||||||
|
{
|
||||||
|
player.position.y += player.speed*deltaTime;
|
||||||
|
player.speed += GRAVITY*deltaTime;
|
||||||
|
player.canJump = false;
|
||||||
|
}
|
||||||
|
else player.canJump = true;
|
||||||
|
|
||||||
|
camera.zoom += ((float)GetMouseWheelMove()*0.05f);
|
||||||
|
|
||||||
|
if (camera.zoom > 3.0f) camera.zoom = 3.0f;
|
||||||
|
else if (camera.zoom < 0.25f) camera.zoom = 0.25f;
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_R))
|
||||||
|
{
|
||||||
|
// Reset game state
|
||||||
|
player.position = (Vector2){ 400, 280 };
|
||||||
|
player.speed = 0;
|
||||||
|
player.canJump = false;
|
||||||
|
|
||||||
|
camera.target = player.position;
|
||||||
|
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
||||||
|
camera.rotation = 0.0f;
|
||||||
|
camera.zoom = 1.0f;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Update camera
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
camera.target = player.position;
|
||||||
|
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
||||||
|
float minX = 1000, minY = 1000, maxX = -1000, maxY = -1000;
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_ENVIRONMENT_ELEMENTS; i++)
|
||||||
|
{
|
||||||
|
EnvElement *element = &envElements[i];
|
||||||
|
minX = fminf(element->rect.x, minX);
|
||||||
|
maxX = fmaxf(element->rect.x + element->rect.width, maxX);
|
||||||
|
minY = fminf(element->rect.y, minY);
|
||||||
|
maxY = fmaxf(element->rect.y + element->rect.height, maxY);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2 max = GetWorldToScreen2D((Vector2){ maxX, maxY }, camera);
|
||||||
|
Vector2 min = GetWorldToScreen2D((Vector2){ minX, minY }, camera);
|
||||||
|
|
||||||
|
if (max.x < screenWidth) camera.offset.x = screenWidth - (max.x - screenWidth/2);
|
||||||
|
if (max.y < screenHeight) camera.offset.y = screenHeight - (max.y - screenHeight/2);
|
||||||
|
if (min.x > 0) camera.offset.x = screenWidth/2 - min.x;
|
||||||
|
if (min.y > 0) camera.offset.y = screenHeight/2 - min.y;
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Toggle events recording
|
||||||
|
if (IsKeyPressed(KEY_F2))
|
||||||
|
{
|
||||||
|
if (!eventPlaying)
|
||||||
|
{
|
||||||
|
if (eventRecording)
|
||||||
|
{
|
||||||
|
StopAutomationEventRecording();
|
||||||
|
eventRecording = false;
|
||||||
|
|
||||||
|
ExportAutomationEventList(aelist, "automation.rae");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetAutomationEventBaseFrame(180);
|
||||||
|
StartAutomationEventRecording();
|
||||||
|
eventRecording = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (IsKeyPressed(KEY_F3))
|
||||||
|
{
|
||||||
|
if (!eventRecording && (aelist.count > 0))
|
||||||
|
{
|
||||||
|
// Reset scene state to play
|
||||||
|
eventPlaying = true;
|
||||||
|
playFrameCounter = 0;
|
||||||
|
currentPlayFrame = 0;
|
||||||
|
|
||||||
|
player.position = (Vector2){ 400, 280 };
|
||||||
|
player.speed = 0;
|
||||||
|
player.canJump = false;
|
||||||
|
|
||||||
|
camera.target = player.position;
|
||||||
|
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
||||||
|
camera.rotation = 0.0f;
|
||||||
|
camera.zoom = 1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eventPlaying)
|
||||||
|
{
|
||||||
|
// NOTE: Multiple events could be executed in a single frame
|
||||||
|
while (playFrameCounter == aelist.events[currentPlayFrame].frame)
|
||||||
|
{
|
||||||
|
PlayAutomationEvent(aelist.events[currentPlayFrame]);
|
||||||
|
currentPlayFrame++;
|
||||||
|
|
||||||
|
if (currentPlayFrame == aelist.count)
|
||||||
|
{
|
||||||
|
eventPlaying = false;
|
||||||
|
currentPlayFrame = 0;
|
||||||
|
playFrameCounter = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
playFrameCounter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eventRecording || eventPlaying) frameCounter++;
|
||||||
|
else frameCounter = 0;
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(LIGHTGRAY);
|
||||||
|
|
||||||
|
BeginMode2D(camera);
|
||||||
|
|
||||||
|
// Draw environment elements
|
||||||
|
for (int i = 0; i < MAX_ENVIRONMENT_ELEMENTS; i++)
|
||||||
|
{
|
||||||
|
DrawRectangleRec(envElements[i].rect, envElements[i].color);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw player rectangle
|
||||||
|
DrawRectangleRec((Rectangle){ player.position.x - 20, player.position.y - 40, 40, 40 }, RED);
|
||||||
|
|
||||||
|
EndMode2D();
|
||||||
|
|
||||||
|
// Draw game controls
|
||||||
|
DrawRectangle(10, 10, 290, 145, Fade(SKYBLUE, 0.5f));
|
||||||
|
DrawRectangleLines(10, 10, 290, 145, Fade(BLUE, 0.8f));
|
||||||
|
|
||||||
|
DrawText("Controls:", 20, 20, 10, BLACK);
|
||||||
|
DrawText("- RIGHT | LEFT: Player movement", 30, 40, 10, DARKGRAY);
|
||||||
|
DrawText("- SPACE: Player jump", 30, 60, 10, DARKGRAY);
|
||||||
|
DrawText("- R: Reset game state", 30, 80, 10, DARKGRAY);
|
||||||
|
|
||||||
|
DrawText("- F2: START/STOP RECORDING INPUT EVENTS", 30, 110, 10, BLACK);
|
||||||
|
DrawText("- F3: REPLAY LAST RECORDED INPUT EVENTS", 30, 130, 10, BLACK);
|
||||||
|
|
||||||
|
// Draw automation events recording indicator
|
||||||
|
if (eventRecording)
|
||||||
|
{
|
||||||
|
DrawRectangle(10, 160, 290, 30, Fade(RED, 0.3f));
|
||||||
|
DrawRectangleLines(10, 160, 290, 30, Fade(MAROON, 0.8f));
|
||||||
|
DrawCircle(30, 175, 10, MAROON);
|
||||||
|
|
||||||
|
if (((frameCounter/15)%2) == 1) DrawText(TextFormat("RECORDING EVENTS... [%i]", aelist.count), 50, 170, 10, MAROON);
|
||||||
|
}
|
||||||
|
else if (eventPlaying)
|
||||||
|
{
|
||||||
|
DrawRectangle(10, 160, 290, 30, Fade(LIME, 0.3f));
|
||||||
|
DrawRectangleLines(10, 160, 290, 30, Fade(DARKGREEN, 0.8f));
|
||||||
|
DrawTriangle((Vector2){ 20, 155 + 10 }, (Vector2){ 20, 155 + 30 }, (Vector2){ 40, 155 + 20 }, DARKGREEN);
|
||||||
|
|
||||||
|
if (((frameCounter/15)%2) == 1) DrawText(TextFormat("PLAYING RECORDED EVENTS... [%i]", currentPlayFrame), 50, 170, 10, DARKGREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* raylib [core] example - Basic window (adapted for HTML5 platform)
|
* raylib [core] example - Basic window (adapted for HTML5 platform)
|
||||||
*
|
*
|
||||||
* NOTE: This example is prepared to compile for PLATFORM_WEB, PLATFORM_DESKTOP and PLATFORM_RPI
|
* NOTE: This example is prepared to compile for PLATFORM_WEB, and PLATFORM_DESKTOP
|
||||||
* As you will notice, code structure is slightly diferent to the other examples...
|
* As you will notice, code structure is slightly diferent to the other examples...
|
||||||
* To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning
|
* To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,8 @@
|
||||||
|
|
||||||
// NOTE: Gamepad name ID depends on drivers and OS
|
// NOTE: Gamepad name ID depends on drivers and OS
|
||||||
#define XBOX360_LEGACY_NAME_ID "Xbox Controller"
|
#define XBOX360_LEGACY_NAME_ID "Xbox Controller"
|
||||||
#if defined(PLATFORM_RPI)
|
#define XBOX360_NAME_ID "Xbox 360 Controller"
|
||||||
#define XBOX360_NAME_ID "Microsoft X-Box 360 pad"
|
#define PS3_NAME_ID "PLAYSTATION(R)3 Controller"
|
||||||
#define PS3_NAME_ID "PLAYSTATION(R)3 Controller"
|
|
||||||
#else
|
|
||||||
#define XBOX360_NAME_ID "Xbox 360 Controller"
|
|
||||||
#define PS3_NAME_ID "PLAYSTATION(R)3 Controller"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
|
|
@ -49,6 +44,8 @@ int main(void)
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int gamepad = 0; // which gamepad to display
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
|
|
@ -63,102 +60,114 @@ int main(void)
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
if (IsGamepadAvailable(0))
|
if (IsKeyPressed(KEY_LEFT) && gamepad > 0) gamepad--;
|
||||||
{
|
if (IsKeyPressed(KEY_RIGHT)) gamepad++;
|
||||||
DrawText(TextFormat("GP1: %s", GetGamepadName(0)), 10, 10, 10, BLACK);
|
|
||||||
|
|
||||||
if (TextIsEqual(GetGamepadName(0), XBOX360_NAME_ID) || TextIsEqual(GetGamepadName(0), XBOX360_LEGACY_NAME_ID))
|
if (IsGamepadAvailable(gamepad))
|
||||||
|
{
|
||||||
|
DrawText(TextFormat("GP%d: %s", gamepad, GetGamepadName(gamepad)), 10, 10, 10, BLACK);
|
||||||
|
|
||||||
|
if (true)
|
||||||
{
|
{
|
||||||
DrawTexture(texXboxPad, 0, 0, DARKGRAY);
|
DrawTexture(texXboxPad, 0, 0, DARKGRAY);
|
||||||
|
|
||||||
// Draw buttons: xbox home
|
// Draw buttons: xbox home
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE)) DrawCircle(394, 89, 19, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE)) DrawCircle(394, 89, 19, RED);
|
||||||
|
|
||||||
// Draw buttons: basic
|
// Draw buttons: basic
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawCircle(436, 150, 9, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawCircle(436, 150, 9, RED);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawCircle(352, 150, 9, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawCircle(352, 150, 9, RED);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) DrawCircle(501, 151, 15, BLUE);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) DrawCircle(501, 151, 15, BLUE);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(536, 187, 15, LIME);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(536, 187, 15, LIME);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(572, 151, 15, MAROON);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(572, 151, 15, MAROON);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_UP)) DrawCircle(536, 115, 15, GOLD);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_UP)) DrawCircle(536, 115, 15, GOLD);
|
||||||
|
|
||||||
// Draw buttons: d-pad
|
// Draw buttons: d-pad
|
||||||
DrawRectangle(317, 202, 19, 71, BLACK);
|
DrawRectangle(317, 202, 19, 71, BLACK);
|
||||||
DrawRectangle(293, 228, 69, 19, BLACK);
|
DrawRectangle(293, 228, 69, 19, BLACK);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_UP)) DrawRectangle(317, 202, 19, 26, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_UP)) DrawRectangle(317, 202, 19, 26, RED);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(317, 202 + 45, 19, 26, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(317, 202 + 45, 19, 26, RED);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(292, 228, 25, 19, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(292, 228, 25, 19, RED);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(292 + 44, 228, 26, 19, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(292 + 44, 228, 26, 19, RED);
|
||||||
|
|
||||||
// Draw buttons: left-right back
|
// Draw buttons: left-right back
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawCircle(259, 61, 20, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawCircle(259, 61, 20, RED);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(536, 61, 20, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(536, 61, 20, RED);
|
||||||
|
|
||||||
// Draw axis: left joystick
|
// Draw axis: left joystick
|
||||||
|
|
||||||
|
Color leftGamepadColor = BLACK;
|
||||||
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_THUMB)) leftGamepadColor = RED;
|
||||||
DrawCircle(259, 152, 39, BLACK);
|
DrawCircle(259, 152, 39, BLACK);
|
||||||
DrawCircle(259, 152, 34, LIGHTGRAY);
|
DrawCircle(259, 152, 34, LIGHTGRAY);
|
||||||
DrawCircle(259 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X)*20),
|
DrawCircle(259 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_X)*20),
|
||||||
152 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y)*20), 25, BLACK);
|
152 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_Y)*20), 25, leftGamepadColor);
|
||||||
|
|
||||||
// Draw axis: right joystick
|
// Draw axis: right joystick
|
||||||
|
Color rightGamepadColor = BLACK;
|
||||||
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_THUMB)) rightGamepadColor = RED;
|
||||||
DrawCircle(461, 237, 38, BLACK);
|
DrawCircle(461, 237, 38, BLACK);
|
||||||
DrawCircle(461, 237, 33, LIGHTGRAY);
|
DrawCircle(461, 237, 33, LIGHTGRAY);
|
||||||
DrawCircle(461 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X)*20),
|
DrawCircle(461 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_X)*20),
|
||||||
237 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y)*20), 25, BLACK);
|
237 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_Y)*20), 25, rightGamepadColor);
|
||||||
|
|
||||||
// Draw axis: left-right triggers
|
// Draw axis: left-right triggers
|
||||||
DrawRectangle(170, 30, 15, 70, GRAY);
|
DrawRectangle(170, 30, 15, 70, GRAY);
|
||||||
DrawRectangle(604, 30, 15, 70, GRAY);
|
DrawRectangle(604, 30, 15, 70, GRAY);
|
||||||
DrawRectangle(170, 30, 15, (int)(((1 + GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER))/2)*70), RED);
|
DrawRectangle(170, 30, 15, (int)(((1 + GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_TRIGGER))/2)*70), RED);
|
||||||
DrawRectangle(604, 30, 15, (int)(((1 + GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER))/2)*70), RED);
|
DrawRectangle(604, 30, 15, (int)(((1 + GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_TRIGGER))/2)*70), RED);
|
||||||
|
|
||||||
//DrawText(TextFormat("Xbox axis LT: %02.02f", GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER)), 10, 40, 10, BLACK);
|
//DrawText(TextFormat("Xbox axis LT: %02.02f", GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_TRIGGER)), 10, 40, 10, BLACK);
|
||||||
//DrawText(TextFormat("Xbox axis RT: %02.02f", GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER)), 10, 60, 10, BLACK);
|
//DrawText(TextFormat("Xbox axis RT: %02.02f", GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_TRIGGER)), 10, 60, 10, BLACK);
|
||||||
}
|
}
|
||||||
else if (TextIsEqual(GetGamepadName(0), PS3_NAME_ID))
|
else if (TextIsEqual(GetGamepadName(gamepad), PS3_NAME_ID))
|
||||||
{
|
{
|
||||||
DrawTexture(texPs3Pad, 0, 0, DARKGRAY);
|
DrawTexture(texPs3Pad, 0, 0, DARKGRAY);
|
||||||
|
|
||||||
// Draw buttons: ps
|
// Draw buttons: ps
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE)) DrawCircle(396, 222, 13, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE)) DrawCircle(396, 222, 13, RED);
|
||||||
|
|
||||||
// Draw buttons: basic
|
// Draw buttons: basic
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawRectangle(328, 170, 32, 13, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawRectangle(328, 170, 32, 13, RED);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawTriangle((Vector2){ 436, 168 }, (Vector2){ 436, 185 }, (Vector2){ 464, 177 }, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawTriangle((Vector2){ 436, 168 }, (Vector2){ 436, 185 }, (Vector2){ 464, 177 }, RED);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_UP)) DrawCircle(557, 144, 13, LIME);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_UP)) DrawCircle(557, 144, 13, LIME);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(586, 173, 13, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(586, 173, 13, RED);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(557, 203, 13, VIOLET);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(557, 203, 13, VIOLET);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) DrawCircle(527, 173, 13, PINK);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) DrawCircle(527, 173, 13, PINK);
|
||||||
|
|
||||||
// Draw buttons: d-pad
|
// Draw buttons: d-pad
|
||||||
DrawRectangle(225, 132, 24, 84, BLACK);
|
DrawRectangle(225, 132, 24, 84, BLACK);
|
||||||
DrawRectangle(195, 161, 84, 25, BLACK);
|
DrawRectangle(195, 161, 84, 25, BLACK);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_UP)) DrawRectangle(225, 132, 24, 29, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_UP)) DrawRectangle(225, 132, 24, 29, RED);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(225, 132 + 54, 24, 30, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(225, 132 + 54, 24, 30, RED);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(195, 161, 30, 25, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(195, 161, 30, 25, RED);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(195 + 54, 161, 30, 25, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(195 + 54, 161, 30, 25, RED);
|
||||||
|
|
||||||
// Draw buttons: left-right back buttons
|
// Draw buttons: left-right back buttons
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawCircle(239, 82, 20, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawCircle(239, 82, 20, RED);
|
||||||
if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(557, 82, 20, RED);
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(557, 82, 20, RED);
|
||||||
|
|
||||||
// Draw axis: left joystick
|
// Draw axis: left joystick
|
||||||
DrawCircle(319, 255, 35, BLACK);
|
Color leftGamepadColor = BLACK;
|
||||||
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_THUMB)) leftGamepadColor = RED;
|
||||||
|
DrawCircle(319, 255, 35, leftGamepadColor);
|
||||||
DrawCircle(319, 255, 31, LIGHTGRAY);
|
DrawCircle(319, 255, 31, LIGHTGRAY);
|
||||||
DrawCircle(319 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X) * 20),
|
DrawCircle(319 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_X) * 20),
|
||||||
255 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y) * 20), 25, BLACK);
|
255 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_Y) * 20), 25, leftGamepadColor);
|
||||||
|
|
||||||
// Draw axis: right joystick
|
// Draw axis: right joystick
|
||||||
|
Color rightGamepadColor = BLACK;
|
||||||
|
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_THUMB)) rightGamepadColor = RED;
|
||||||
DrawCircle(475, 255, 35, BLACK);
|
DrawCircle(475, 255, 35, BLACK);
|
||||||
DrawCircle(475, 255, 31, LIGHTGRAY);
|
DrawCircle(475, 255, 31, LIGHTGRAY);
|
||||||
DrawCircle(475 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X) * 20),
|
DrawCircle(475 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_X) * 20),
|
||||||
255 + (int)(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y) * 20), 25, BLACK);
|
255 + (int)(GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_Y) * 20), 25, rightGamepadColor);
|
||||||
|
|
||||||
// Draw axis: left-right triggers
|
// Draw axis: left-right triggers
|
||||||
DrawRectangle(169, 48, 15, 70, GRAY);
|
DrawRectangle(169, 48, 15, 70, GRAY);
|
||||||
DrawRectangle(611, 48, 15, 70, GRAY);
|
DrawRectangle(611, 48, 15, 70, GRAY);
|
||||||
DrawRectangle(169, 48, 15, (int)(((1 - GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER)) / 2) * 70), RED);
|
DrawRectangle(169, 48, 15, (int)(((1 - GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_LEFT_TRIGGER)) / 2) * 70), RED);
|
||||||
DrawRectangle(611, 48, 15, (int)(((1 - GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER)) / 2) * 70), RED);
|
DrawRectangle(611, 48, 15, (int)(((1 - GetGamepadAxisMovement(gamepad, GAMEPAD_AXIS_RIGHT_TRIGGER)) / 2) * 70), RED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -179,7 +188,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawText("GP1: NOT DETECTED", 10, 10, 10, GRAY);
|
DrawText(TextFormat("GP%d: NOT DETECTED", gamepad), 10, 10, 10, GRAY);
|
||||||
|
|
||||||
DrawTexture(texXboxPad, 0, 0, LIGHTGRAY);
|
DrawTexture(texXboxPad, 0, 0, LIGHTGRAY);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
74
examples/core/core_input_gamepad_info.c
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [core] example - Gamepad information
|
||||||
|
*
|
||||||
|
* NOTE: This example requires a Gamepad connected to the system
|
||||||
|
* Check raylib.h for buttons configuration
|
||||||
|
*
|
||||||
|
* Example originally created with raylib 4.6, last time updated with raylib 4.6
|
||||||
|
*
|
||||||
|
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||||
|
* BSD-like license that allows static linking with closed source software
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad information");
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
int y = 10;
|
||||||
|
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++) // by default rcore.h has a MAX_GAMEPADS of 4 so mimmic that here.
|
||||||
|
{
|
||||||
|
if (IsGamepadAvailable(i))
|
||||||
|
{
|
||||||
|
DrawText(TextFormat("Gamepad name: %s", GetGamepadName(i)), 10, y, 20, BLACK);
|
||||||
|
y += 30;
|
||||||
|
DrawText(TextFormat("\tAxis count: %d", GetGamepadAxisCount(i)), 10, y, 20, BLACK);
|
||||||
|
y += 30;
|
||||||
|
for (int axis = 0; axis < GetGamepadAxisCount(i); axis++)
|
||||||
|
{
|
||||||
|
DrawText(TextFormat("\tAxis %d = %f", axis, GetGamepadAxisMovement(i, axis)), 10, y, 20, BLACK);
|
||||||
|
y += 30;
|
||||||
|
}
|
||||||
|
for (int button = 0; button < 32; button++)
|
||||||
|
{
|
||||||
|
DrawText(TextFormat("\tButton %d = %d", button, IsGamepadButtonDown(i, button)), 10, y, 20, BLACK);
|
||||||
|
y += 30;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawFPS(GetScreenWidth() - 100, 100);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
330
examples/core/core_input_gestures_web.c
Normal file
|
|
@ -0,0 +1,330 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [core] example - Input Gestures for Web
|
||||||
|
*
|
||||||
|
* Example originally created with raylib 4.6-dev, last time updated with raylib 4.6-dev
|
||||||
|
*
|
||||||
|
* Example contributed by ubkp (@ubkp) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||||
|
* BSD-like license that allows static linking with closed source software
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 ubkp (@ubkp)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#include "math.h" // Required for the protractor angle graphic drawing
|
||||||
|
|
||||||
|
#if defined(PLATFORM_WEB)
|
||||||
|
#include <emscripten/emscripten.h> // Required for the Web/HTML5
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Global definitions and declarations
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Common variables definitions
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
int screenWidth = 800; // Update depending on web canvas
|
||||||
|
const int screenHeight = 450;
|
||||||
|
Vector2 messagePosition = { 160, 7 };
|
||||||
|
|
||||||
|
// Last gesture variables definitions
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
int lastGesture = 0;
|
||||||
|
Vector2 lastGesturePosition = { 165, 130 };
|
||||||
|
|
||||||
|
// Gesture log variables definitions and functions declarations
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
#define GESTURE_LOG_SIZE 20
|
||||||
|
char gestureLog[GESTURE_LOG_SIZE][12] = { "" }; // The gesture log uses an array (as an inverted circular queue) to store the performed gestures
|
||||||
|
int gestureLogIndex = GESTURE_LOG_SIZE; // The index for the inverted circular queue (moving from last to first direction, then looping around)
|
||||||
|
int previousGesture = 0;
|
||||||
|
|
||||||
|
char const *GetGestureName(int i)
|
||||||
|
{
|
||||||
|
switch (i) {
|
||||||
|
case 0: return "None"; break;
|
||||||
|
case 1: return "Tap"; break;
|
||||||
|
case 2: return "Double Tap"; break;
|
||||||
|
case 4: return "Hold"; break;
|
||||||
|
case 8: return "Drag"; break;
|
||||||
|
case 16: return "Swipe Right"; break;
|
||||||
|
case 32: return "Swipe Left"; break;
|
||||||
|
case 64: return "Swipe Up"; break;
|
||||||
|
case 128: return "Swipe Down"; break;
|
||||||
|
case 256: return "Pinch In"; break;
|
||||||
|
case 512: return "Pinch Out"; break;
|
||||||
|
default: return "Unknown"; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Color GetGestureColor(int i)
|
||||||
|
{
|
||||||
|
switch (i) {
|
||||||
|
case 0: return BLACK; break;
|
||||||
|
case 1: return BLUE; break;
|
||||||
|
case 2: return SKYBLUE; break;
|
||||||
|
case 4: return BLACK; break;
|
||||||
|
case 8: return LIME; break;
|
||||||
|
case 16: return RED; break;
|
||||||
|
case 32: return RED; break;
|
||||||
|
case 64: return RED; break;
|
||||||
|
case 128: return RED; break;
|
||||||
|
case 256: return VIOLET; break;
|
||||||
|
case 512: return ORANGE; break;
|
||||||
|
default: return BLACK; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int logMode = 1; // Log mode values: 0 shows repeated events; 1 hides repeated events; 2 shows repeated events but hide hold events; 3 hides repeated events and hide hold events
|
||||||
|
|
||||||
|
Color gestureColor = { 0, 0, 0, 255 };
|
||||||
|
Rectangle logButton1 = { 53, 7, 48, 26 };
|
||||||
|
Rectangle logButton2 = { 108, 7, 36, 26 };
|
||||||
|
Vector2 gestureLogPosition = { 10, 10 };
|
||||||
|
|
||||||
|
// Protractor variables definitions
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
float angleLength = 90.0f;
|
||||||
|
float currentAngleDegrees = 0.0f;
|
||||||
|
Vector2 finalVector = { 0.0f, 0.0f };
|
||||||
|
char currentAngleStr[7] = "";
|
||||||
|
Vector2 protractorPosition = { 266.0f, 315.0f };
|
||||||
|
|
||||||
|
// Update
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
void Update(void)
|
||||||
|
{
|
||||||
|
// Handle common
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
int i, ii; // Iterators that will be reused by all for loops
|
||||||
|
const int currentGesture = GetGestureDetected();
|
||||||
|
const float currentDragDegrees = GetGestureDragAngle();
|
||||||
|
const float currentPitchDegrees = GetGesturePinchAngle();
|
||||||
|
const int touchCount = GetTouchPointCount();
|
||||||
|
|
||||||
|
// Handle last gesture
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
if ((currentGesture != 0) && (currentGesture != 4) && (currentGesture != previousGesture)) lastGesture = currentGesture; // Filter the meaningful gestures (1, 2, 8 to 512) for the display
|
||||||
|
|
||||||
|
// Handle gesture log
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
|
||||||
|
{
|
||||||
|
if (CheckCollisionPointRec(GetMousePosition(), logButton1))
|
||||||
|
{
|
||||||
|
switch (logMode)
|
||||||
|
{
|
||||||
|
case 3: logMode=2; break;
|
||||||
|
case 2: logMode=3; break;
|
||||||
|
case 1: logMode=0; break;
|
||||||
|
default: logMode=1; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (CheckCollisionPointRec(GetMousePosition(), logButton2))
|
||||||
|
{
|
||||||
|
switch (logMode)
|
||||||
|
{
|
||||||
|
case 3: logMode=1; break;
|
||||||
|
case 2: logMode=0; break;
|
||||||
|
case 1: logMode=3; break;
|
||||||
|
default: logMode=2; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int fillLog = 0; // Gate variable to be used to allow or not the gesture log to be filled
|
||||||
|
if (currentGesture !=0)
|
||||||
|
{
|
||||||
|
if (logMode == 3) // 3 hides repeated events and hide hold events
|
||||||
|
{
|
||||||
|
if (((currentGesture != 4) && (currentGesture != previousGesture)) || (currentGesture < 3)) fillLog = 1;
|
||||||
|
}
|
||||||
|
else if (logMode == 2) // 2 shows repeated events but hide hold events
|
||||||
|
{
|
||||||
|
if (currentGesture != 4) fillLog = 1;
|
||||||
|
}
|
||||||
|
else if (logMode == 1) // 1 hides repeated events
|
||||||
|
{
|
||||||
|
if (currentGesture != previousGesture) fillLog = 1;
|
||||||
|
}
|
||||||
|
else // 0 shows repeated events
|
||||||
|
{
|
||||||
|
fillLog = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fillLog) // If one of the conditions from logMode was met, fill the gesture log
|
||||||
|
{
|
||||||
|
previousGesture = currentGesture;
|
||||||
|
gestureColor = GetGestureColor(currentGesture);
|
||||||
|
if (gestureLogIndex <= 0) gestureLogIndex = GESTURE_LOG_SIZE;
|
||||||
|
gestureLogIndex--;
|
||||||
|
|
||||||
|
// Copy the gesture respective name to the gesture log array
|
||||||
|
TextCopy(gestureLog[gestureLogIndex], GetGestureName(currentGesture));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle protractor
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
if (currentGesture > 255) // aka Pinch In and Pinch Out
|
||||||
|
{
|
||||||
|
currentAngleDegrees = currentPitchDegrees;
|
||||||
|
}
|
||||||
|
else if (currentGesture > 15) // aka Swipe Right, Swipe Left, Swipe Up and Swipe Down
|
||||||
|
{
|
||||||
|
currentAngleDegrees = currentDragDegrees;
|
||||||
|
}
|
||||||
|
else if (currentGesture > 0) // aka Tap, Doubletap, Hold and Grab
|
||||||
|
{
|
||||||
|
currentAngleDegrees = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float currentAngleRadians = ((currentAngleDegrees +90.0f)*PI/180); // Convert the current angle to Radians
|
||||||
|
finalVector = (Vector2){ (angleLength*sinf(currentAngleRadians)) + protractorPosition.x, (angleLength*cosf(currentAngleRadians)) + protractorPosition.y }; // Calculate the final vector for display
|
||||||
|
|
||||||
|
// Handle touch and mouse pointer points
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
#define MAX_TOUCH_COUNT 32
|
||||||
|
|
||||||
|
Vector2 touchPosition[MAX_TOUCH_COUNT] = { 0 };
|
||||||
|
Vector2 mousePosition = {0, 0};
|
||||||
|
if (currentGesture != GESTURE_NONE)
|
||||||
|
{
|
||||||
|
if (touchCount != 0)
|
||||||
|
{
|
||||||
|
for (i = 0; i < touchCount; i++) touchPosition[i] = GetTouchPosition(i); // Fill the touch positions
|
||||||
|
}
|
||||||
|
else mousePosition = GetMousePosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
// Draw common
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
DrawText("*", messagePosition.x + 5, messagePosition.y + 5, 10, BLACK);
|
||||||
|
DrawText("Example optimized for Web/HTML5\non Smartphones with Touch Screen.", messagePosition.x + 15, messagePosition.y + 5, 10, BLACK);
|
||||||
|
DrawText("*", messagePosition.x + 5, messagePosition.y + 35, 10, BLACK);
|
||||||
|
DrawText("While running on Desktop Web Browsers,\ninspect and turn on Touch Emulation.", messagePosition.x + 15, messagePosition.y + 35, 10, BLACK);
|
||||||
|
|
||||||
|
// Draw last gesture
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
DrawText("Last gesture", lastGesturePosition.x + 33, lastGesturePosition.y - 47, 20, BLACK);
|
||||||
|
DrawText("Swipe Tap Pinch Touch", lastGesturePosition.x + 17, lastGesturePosition.y - 18, 10, BLACK);
|
||||||
|
DrawRectangle(lastGesturePosition.x + 20, lastGesturePosition.y, 20, 20, lastGesture == GESTURE_SWIPE_UP ? RED : LIGHTGRAY);
|
||||||
|
DrawRectangle(lastGesturePosition.x, lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_LEFT ? RED : LIGHTGRAY);
|
||||||
|
DrawRectangle(lastGesturePosition.x + 40, lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_RIGHT ? RED : LIGHTGRAY);
|
||||||
|
DrawRectangle(lastGesturePosition.x + 20, lastGesturePosition.y + 40, 20, 20, lastGesture == GESTURE_SWIPE_DOWN ? RED : LIGHTGRAY);
|
||||||
|
DrawCircle(lastGesturePosition.x + 80, lastGesturePosition.y + 16, 10, lastGesture == GESTURE_TAP ? BLUE : LIGHTGRAY);
|
||||||
|
DrawRing( (Vector2){lastGesturePosition.x + 103, lastGesturePosition.y + 16}, 6.0f, 11.0f, 0.0f, 360.0f, 0, lastGesture == GESTURE_DRAG ? LIME : LIGHTGRAY);
|
||||||
|
DrawCircle(lastGesturePosition.x + 80, lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
|
||||||
|
DrawCircle(lastGesturePosition.x + 103, lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
|
||||||
|
DrawTriangle((Vector2){ lastGesturePosition.x + 122, lastGesturePosition.y + 16 }, (Vector2){ lastGesturePosition.x + 137, lastGesturePosition.y + 26 }, (Vector2){ lastGesturePosition.x + 137, lastGesturePosition.y + 6 }, lastGesture == GESTURE_PINCH_OUT? ORANGE : LIGHTGRAY);
|
||||||
|
DrawTriangle((Vector2){ lastGesturePosition.x + 147, lastGesturePosition.y + 6 }, (Vector2){ lastGesturePosition.x + 147, lastGesturePosition.y + 26 }, (Vector2){ lastGesturePosition.x + 162, lastGesturePosition.y + 16 }, lastGesture == GESTURE_PINCH_OUT? ORANGE : LIGHTGRAY);
|
||||||
|
DrawTriangle((Vector2){ lastGesturePosition.x + 125, lastGesturePosition.y + 33 }, (Vector2){ lastGesturePosition.x + 125, lastGesturePosition.y + 53 }, (Vector2){ lastGesturePosition.x + 140, lastGesturePosition.y + 43 }, lastGesture == GESTURE_PINCH_IN? VIOLET : LIGHTGRAY);
|
||||||
|
DrawTriangle((Vector2){ lastGesturePosition.x + 144, lastGesturePosition.y + 43 }, (Vector2){ lastGesturePosition.x + 159, lastGesturePosition.y + 53 }, (Vector2){ lastGesturePosition.x + 159, lastGesturePosition.y + 33 }, lastGesture == GESTURE_PINCH_IN? VIOLET : LIGHTGRAY);
|
||||||
|
for (i = 0; i < 4; i++) DrawCircle(lastGesturePosition.x + 180, lastGesturePosition.y + 7 + i*15, 5, touchCount <= i? LIGHTGRAY : gestureColor);
|
||||||
|
|
||||||
|
// Draw gesture log
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
DrawText("Log", gestureLogPosition.x, gestureLogPosition.y, 20, BLACK);
|
||||||
|
|
||||||
|
// Loop in both directions to print the gesture log array in the inverted order (and looping around if the index started somewhere in the middle)
|
||||||
|
for (i = 0, ii = gestureLogIndex; i < GESTURE_LOG_SIZE; i++, ii = (ii + 1) % GESTURE_LOG_SIZE) DrawText(gestureLog[ii], gestureLogPosition.x, gestureLogPosition.y + 410 - i*20, 20, (i == 0 ? gestureColor : LIGHTGRAY));
|
||||||
|
Color logButton1Color, logButton2Color;
|
||||||
|
switch (logMode)
|
||||||
|
{
|
||||||
|
case 3: logButton1Color=MAROON; logButton2Color=MAROON; break;
|
||||||
|
case 2: logButton1Color=GRAY; logButton2Color=MAROON; break;
|
||||||
|
case 1: logButton1Color=MAROON; logButton2Color=GRAY; break;
|
||||||
|
default: logButton1Color=GRAY; logButton2Color=GRAY; break;
|
||||||
|
}
|
||||||
|
DrawRectangleRec(logButton1, logButton1Color);
|
||||||
|
DrawText("Hide", logButton1.x + 7, logButton1.y + 3, 10, WHITE);
|
||||||
|
DrawText("Repeat", logButton1.x + 7, logButton1.y + 13, 10, WHITE);
|
||||||
|
DrawRectangleRec(logButton2, logButton2Color);
|
||||||
|
DrawText("Hide", logButton1.x + 62, logButton1.y + 3, 10, WHITE);
|
||||||
|
DrawText("Hold", logButton1.x + 62, logButton1.y + 13, 10, WHITE);
|
||||||
|
|
||||||
|
// Draw protractor
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
DrawText("Angle", protractorPosition.x + 55, protractorPosition.y + 76, 10, BLACK);
|
||||||
|
const char *angleString = TextFormat("%f", currentAngleDegrees);
|
||||||
|
const int angleStringDot = TextFindIndex(angleString, ".");
|
||||||
|
const char *angleStringTrim = TextSubtext(angleString, 0, angleStringDot + 3);
|
||||||
|
DrawText( angleStringTrim, protractorPosition.x + 55, protractorPosition.y + 92, 20, gestureColor);
|
||||||
|
DrawCircle(protractorPosition.x, protractorPosition.y, 80.0f, WHITE);
|
||||||
|
DrawLineEx((Vector2){ protractorPosition.x - 90, protractorPosition.y }, (Vector2){ protractorPosition.x + 90, protractorPosition.y }, 3.0f, LIGHTGRAY);
|
||||||
|
DrawLineEx((Vector2){ protractorPosition.x, protractorPosition.y - 90 }, (Vector2){ protractorPosition.x, protractorPosition.y + 90 }, 3.0f, LIGHTGRAY);
|
||||||
|
DrawLineEx((Vector2){ protractorPosition.x - 80, protractorPosition.y - 45 }, (Vector2){ protractorPosition.x + 80, protractorPosition.y + 45 }, 3.0f, GREEN);
|
||||||
|
DrawLineEx((Vector2){ protractorPosition.x - 80, protractorPosition.y + 45 }, (Vector2){ protractorPosition.x + 80, protractorPosition.y - 45 }, 3.0f, GREEN);
|
||||||
|
DrawText("0", protractorPosition.x + 96, protractorPosition.y - 9, 20, BLACK);
|
||||||
|
DrawText("30", protractorPosition.x + 74, protractorPosition.y - 68, 20, BLACK);
|
||||||
|
DrawText("90", protractorPosition.x - 11, protractorPosition.y - 110, 20, BLACK);
|
||||||
|
DrawText("150", protractorPosition.x - 100, protractorPosition.y - 68, 20, BLACK);
|
||||||
|
DrawText("180", protractorPosition.x - 124, protractorPosition.y - 9, 20, BLACK);
|
||||||
|
DrawText("210", protractorPosition.x - 100, protractorPosition.y + 50, 20, BLACK);
|
||||||
|
DrawText("270", protractorPosition.x - 18, protractorPosition.y + 92, 20, BLACK);
|
||||||
|
DrawText("330", protractorPosition.x + 72, protractorPosition.y + 50, 20, BLACK);
|
||||||
|
if (currentAngleDegrees != 0.0f) DrawLineEx(protractorPosition, finalVector, 3.0f, gestureColor);
|
||||||
|
|
||||||
|
// Draw touch and mouse pointer points
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
if (currentGesture != GESTURE_NONE)
|
||||||
|
{
|
||||||
|
if ( touchCount != 0 )
|
||||||
|
{
|
||||||
|
for (i = 0; i < touchCount; i++)
|
||||||
|
{
|
||||||
|
DrawCircleV(touchPosition[i], 50.0f, Fade(gestureColor, 0.5f));
|
||||||
|
DrawCircleV(touchPosition[i], 5.0f, gestureColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (touchCount == 2) DrawLineEx(touchPosition[0], touchPosition[1], ((currentGesture == 512)? 8 : 12), gestureColor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DrawCircleV(mousePosition, 35.0f, Fade(gestureColor, 0.5f));
|
||||||
|
DrawCircleV(mousePosition, 5.0f, gestureColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures web");
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
#if defined(PLATFORM_WEB)
|
||||||
|
emscripten_set_main_loop(Update, 0, 1);
|
||||||
|
#else
|
||||||
|
SetTargetFPS(60);
|
||||||
|
while (!WindowShouldClose()) Update(); // Detect window close button or ESC key
|
||||||
|
#endif
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
examples/core/core_input_gestures_web.png
Normal file
|
After Width: | Height: | Size: 8.7 KiB |
|
|
@ -41,7 +41,7 @@ int main(void)
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - loading thread");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - loading thread");
|
||||||
|
|
||||||
pthread_t threadId; // Loading data thread id
|
pthread_t threadId = { 0 }; // Loading data thread id
|
||||||
|
|
||||||
enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING;
|
enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING;
|
||||||
int framesCounter = 0;
|
int framesCounter = 0;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ int main(void)
|
||||||
|
|
||||||
int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included)
|
int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included)
|
||||||
|
|
||||||
int framesCounter = 0; // Variable used to count frames
|
unsigned int framesCounter = 0; // Variable used to count frames
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 21 KiB |
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,13 +35,30 @@
|
||||||
9. In case of additional information is required, just come to raylib Discord channel: example-contributions
|
9. In case of additional information is required, just come to raylib Discord channel: example-contributions
|
||||||
|
|
||||||
10. Have fun!
|
10. Have fun!
|
||||||
|
|
||||||
|
The following files should be updated when adding a new example, it's planned to create some
|
||||||
|
script to automatize this process but not available yet.
|
||||||
|
|
||||||
|
- raylib/examples/<category>/<category>_example_name.c
|
||||||
|
- raylib/examples/<category>/<category>_example_name.png
|
||||||
|
- raylib/examples/<category>/resources/*.*
|
||||||
|
- raylib/examples/Makefile
|
||||||
|
- raylib/examples/Makefile.Web
|
||||||
|
- raylib/examples/README.md
|
||||||
|
- raylib/projects/VS2022/examples/<category>_example_name.vcxproj
|
||||||
|
- raylib/projects/VS2022/raylib.sln
|
||||||
|
- raylib.com/common/examples.js
|
||||||
|
- raylib.com/examples/<category>/<category>_example_name.html
|
||||||
|
- raylib.com/examples/<category>/<category>_example_name.data
|
||||||
|
- raylib.com/examples/<category>/<category>_example_name.wasm
|
||||||
|
- raylib.com/examples/<category>/<category>_example_name.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [core] example - Basic window
|
* raylib [core] example - Basic window
|
||||||
*
|
*
|
||||||
* Example originally created with raylib 4.2, last time updated with raylib 4.2
|
* Example originally created with raylib 4.5, last time updated with raylib 4.5
|
||||||
*
|
*
|
||||||
* Example contributed by <user_name> (@<user_github>) and reviewed by Ramon Santamaria (@raysan5)
|
* Example contributed by <user_name> (@<user_github>) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,8 @@ int main(void)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateCamera(&camera, CAMERA_THIRD_PERSON);
|
UpdateCamera(&camera, CAMERA_THIRD_PERSON);
|
||||||
// Select current animation
|
// Select current animation
|
||||||
if (IsKeyPressed(KEY_UP)) animIndex = (animIndex + 1)%animsCount;
|
if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) animIndex = (animIndex + 1)%animsCount;
|
||||||
else if (IsKeyPressed(KEY_DOWN)) animIndex = (animIndex + animsCount - 1)%animsCount;
|
else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) animIndex = (animIndex + animsCount - 1)%animsCount;
|
||||||
|
|
||||||
// Update model animation
|
// Update model animation
|
||||||
ModelAnimation anim = modelAnimations[animIndex];
|
ModelAnimation anim = modelAnimations[animIndex];
|
||||||
|
|
@ -85,7 +85,8 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("Use the UP/DOWN arrow keys to switch animation", 10, 10, 20, GRAY);
|
DrawText("Use the LEFT/RIGHT mouse buttons to switch animation", 10, 10, 20, GRAY);
|
||||||
|
DrawText(TextFormat("Animation: %s", anim.name), 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 26 KiB |
|
|
@ -79,8 +79,8 @@ int main(void)
|
||||||
animPlaying = true;
|
animPlaying = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select animation by pressing A
|
// Select animation by pressing C
|
||||||
if (IsKeyPressed(KEY_A))
|
if (IsKeyPressed(KEY_C))
|
||||||
{
|
{
|
||||||
animFrameCounter = 0;
|
animFrameCounter = 0;
|
||||||
animId++;
|
animId++;
|
||||||
|
|
@ -92,7 +92,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle skeleton drawing
|
// Toggle skeleton drawing
|
||||||
if (IsKeyPressed(KEY_S)) drawSkeleton ^= 1;
|
if (IsKeyPressed(KEY_B)) drawSkeleton ^= 1;
|
||||||
|
|
||||||
// Toggle mesh drawing
|
// Toggle mesh drawing
|
||||||
if (IsKeyPressed(KEY_M)) drawMesh ^= 1;
|
if (IsKeyPressed(KEY_M)) drawMesh ^= 1;
|
||||||
|
|
@ -149,9 +149,10 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, GetScreenHeight() - 60, 10, MAROON);
|
DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, GetScreenHeight() - 80, 10, MAROON);
|
||||||
DrawText("PRESS A to CYCLE THROUGH ANIMATIONS", 10, GetScreenHeight() - 40, 10, DARKGRAY);
|
DrawText("PRESS N to STEP ONE ANIMATION FRAME", 10, GetScreenHeight() - 60, 10, DARKGRAY);
|
||||||
DrawText("PRESS M to toggle MESH, S to toggle SKELETON DRAWING", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
DrawText("PRESS C to CYCLE THROUGH ANIMATIONS", 10, GetScreenHeight() - 40, 10, DARKGRAY);
|
||||||
|
DrawText("PRESS M to toggle MESH, B to toggle SKELETON DRAWING", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
||||||
DrawText("(c) CesiumMan model by KhronosGroup", GetScreenWidth() - 210, GetScreenHeight() - 20, 10, GRAY);
|
DrawText("(c) CesiumMan model by KhronosGroup", GetScreenWidth() - 210, GetScreenHeight() - 20, 10, GRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 25 KiB |
|
|
@ -36,7 +36,7 @@ int main(void)
|
||||||
|
|
||||||
Model models[NUM_MODELS] = { 0 };
|
Model models[NUM_MODELS] = { 0 };
|
||||||
|
|
||||||
models[0] = LoadModelFromMesh(GenMeshPlane(2, 2, 5, 5));
|
models[0] = LoadModelFromMesh(GenMeshPlane(2, 2, 4, 3));
|
||||||
models[1] = LoadModelFromMesh(GenMeshCube(2.0f, 1.0f, 2.0f));
|
models[1] = LoadModelFromMesh(GenMeshCube(2.0f, 1.0f, 2.0f));
|
||||||
models[2] = LoadModelFromMesh(GenMeshSphere(2, 32, 32));
|
models[2] = LoadModelFromMesh(GenMeshSphere(2, 32, 32));
|
||||||
models[3] = LoadModelFromMesh(GenMeshHemiSphere(2, 16, 16));
|
models[3] = LoadModelFromMesh(GenMeshHemiSphere(2, 16, 16));
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -68,14 +68,12 @@ int main(void)
|
||||||
|
|
||||||
char skyboxFileName[256] = { 0 };
|
char skyboxFileName[256] = { 0 };
|
||||||
|
|
||||||
Texture2D panorama;
|
|
||||||
|
|
||||||
if (useHDR)
|
if (useHDR)
|
||||||
{
|
{
|
||||||
TextCopy(skyboxFileName, "resources/dresden_square_2k.hdr");
|
TextCopy(skyboxFileName, "resources/dresden_square_2k.hdr");
|
||||||
|
|
||||||
// Load HDR panorama (sphere) texture
|
// Load HDR panorama (sphere) texture
|
||||||
panorama = LoadTexture(skyboxFileName);
|
Texture2D panorama = LoadTexture(skyboxFileName);
|
||||||
|
|
||||||
// Generate cubemap (texture with 6 quads-cube-mapping) from panorama HDR texture
|
// Generate cubemap (texture with 6 quads-cube-mapping) from panorama HDR texture
|
||||||
// NOTE 1: New texture is generated rendering to texture, shader calculates the sphere->cube coordinates mapping
|
// NOTE 1: New texture is generated rendering to texture, shader calculates the sphere->cube coordinates mapping
|
||||||
|
|
@ -83,7 +81,7 @@ int main(void)
|
||||||
// despite texture can be successfully created.. so using PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 instead of PIXELFORMAT_UNCOMPRESSED_R32G32B32A32
|
// despite texture can be successfully created.. so using PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 instead of PIXELFORMAT_UNCOMPRESSED_R32G32B32A32
|
||||||
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
|
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
|
||||||
|
|
||||||
//UnloadTexture(panorama); // Texture not required anymore, cubemap already generated
|
UnloadTexture(panorama); // Texture not required anymore, cubemap already generated
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -113,15 +111,18 @@ int main(void)
|
||||||
{
|
{
|
||||||
if (IsFileExtension(droppedFiles.paths[0], ".png;.jpg;.hdr;.bmp;.tga"))
|
if (IsFileExtension(droppedFiles.paths[0], ".png;.jpg;.hdr;.bmp;.tga"))
|
||||||
{
|
{
|
||||||
// Unload current cubemap texture and load new one
|
// Unload current cubemap texture to load new one
|
||||||
UnloadTexture(skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture);
|
UnloadTexture(skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture);
|
||||||
|
|
||||||
if (useHDR)
|
if (useHDR)
|
||||||
{
|
{
|
||||||
|
// Load HDR panorama (sphere) texture
|
||||||
Texture2D panorama = LoadTexture(droppedFiles.paths[0]);
|
Texture2D panorama = LoadTexture(droppedFiles.paths[0]);
|
||||||
|
|
||||||
// Generate cubemap from panorama texture
|
// Generate cubemap from panorama texture
|
||||||
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
|
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
|
||||||
UnloadTexture(panorama);
|
|
||||||
|
UnloadTexture(panorama); // Texture not required anymore, cubemap already generated
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ int main(void)
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [easings] example - easings testbed");
|
InitWindow(screenWidth, screenHeight, "raylib [easings] example - easings testbed");
|
||||||
|
|
||||||
Vector2 ballPosition = { 100.0f, 200.0f };
|
Vector2 ballPosition = { 100.0f, 100.0f };
|
||||||
|
|
||||||
float t = 0.0f; // Current time (in any unit measure, but same unit as duration)
|
float t = 0.0f; // Current time (in any unit measure, but same unit as duration)
|
||||||
float d = 300.0f; // Total time it should take to complete (duration)
|
float d = 300.0f; // Total time it should take to complete (duration)
|
||||||
|
|
@ -180,8 +180,8 @@ int main(void)
|
||||||
// Movement computation
|
// Movement computation
|
||||||
if (!paused && ((boundedT && t < d) || !boundedT))
|
if (!paused && ((boundedT && t < d) || !boundedT))
|
||||||
{
|
{
|
||||||
ballPosition.x = Easings[easingX].func(t, 100.0f, 700.0f - 100.0f, d);
|
ballPosition.x = Easings[easingX].func(t, 100.0f, 700.0f - 170.0f, d);
|
||||||
ballPosition.y = Easings[easingY].func(t, 100.0f, 400.0f - 100.0f, d);
|
ballPosition.y = Easings[easingY].func(t, 100.0f, 400.0f - 170.0f, d);
|
||||||
t += 1.0f;
|
t += 1.0f;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
@ -193,15 +193,15 @@ int main(void)
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
// Draw information text
|
// Draw information text
|
||||||
DrawText(TextFormat("Easing x: %s", Easings[easingX].name), 0, FONT_SIZE*2, FONT_SIZE, LIGHTGRAY);
|
DrawText(TextFormat("Easing x: %s", Easings[easingX].name), 20, FONT_SIZE, FONT_SIZE, LIGHTGRAY);
|
||||||
DrawText(TextFormat("Easing y: %s", Easings[easingY].name), 0, FONT_SIZE*3, FONT_SIZE, LIGHTGRAY);
|
DrawText(TextFormat("Easing y: %s", Easings[easingY].name), 20, FONT_SIZE*2, FONT_SIZE, LIGHTGRAY);
|
||||||
DrawText(TextFormat("t (%c) = %.2f d = %.2f", (boundedT == true)? 'b' : 'u', t, d), 0, FONT_SIZE*4, FONT_SIZE, LIGHTGRAY);
|
DrawText(TextFormat("t (%c) = %.2f d = %.2f", (boundedT == true)? 'b' : 'u', t, d), 20, FONT_SIZE*3, FONT_SIZE, LIGHTGRAY);
|
||||||
|
|
||||||
// Draw instructions text
|
// Draw instructions text
|
||||||
DrawText("Use ENTER to play or pause movement, use SPACE to restart", 0, GetScreenHeight() - FONT_SIZE*2, FONT_SIZE, LIGHTGRAY);
|
DrawText("Use ENTER to play or pause movement, use SPACE to restart", 20, GetScreenHeight() - FONT_SIZE*2, FONT_SIZE, LIGHTGRAY);
|
||||||
DrawText("Use D and W or A and S keys to change duration", 0, GetScreenHeight() - FONT_SIZE*3, FONT_SIZE, LIGHTGRAY);
|
DrawText("Use Q and W or A and S keys to change duration", 20, GetScreenHeight() - FONT_SIZE*3, FONT_SIZE, LIGHTGRAY);
|
||||||
DrawText("Use LEFT or RIGHT keys to choose easing for the x axis", 0, GetScreenHeight() - FONT_SIZE*4, FONT_SIZE, LIGHTGRAY);
|
DrawText("Use LEFT or RIGHT keys to choose easing for the x axis", 20, GetScreenHeight() - FONT_SIZE*4, FONT_SIZE, LIGHTGRAY);
|
||||||
DrawText("Use UP or DOWN keys to choose easing for the y axis", 0, GetScreenHeight() - FONT_SIZE*5, FONT_SIZE, LIGHTGRAY);
|
DrawText("Use UP or DOWN keys to choose easing for the y axis", 20, GetScreenHeight() - FONT_SIZE*5, FONT_SIZE, LIGHTGRAY);
|
||||||
|
|
||||||
// Draw ball
|
// Draw ball
|
||||||
DrawCircleV(ballPosition, 16.0f, MAROON);
|
DrawCircleV(ballPosition, 16.0f, MAROON);
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
|
@ -42,7 +42,7 @@
|
||||||
#endif
|
#endif
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#endif
|
#endif
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
122
examples/others/raymath_vector_angle.c
Normal file
|
|
@ -0,0 +1,122 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [shapes] example - Vector Angle
|
||||||
|
*
|
||||||
|
* Example originally created with raylib 1.0, last time updated with raylib 4.6
|
||||||
|
*
|
||||||
|
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||||
|
* BSD-like license that allows static linking with closed source software
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#include "raymath.h"
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [math] example - vector angle");
|
||||||
|
|
||||||
|
Vector2 v0 = { screenWidth/2, screenHeight/2 };
|
||||||
|
Vector2 v1 = Vector2Add(v0, (Vector2){ 100.0f, 80.0f });
|
||||||
|
Vector2 v2 = { 0 }; // Updated with mouse position
|
||||||
|
|
||||||
|
float angle = 0.0f; // Angle in degrees
|
||||||
|
int angleMode = 0; // 0-Vector2Angle(), 1-Vector2LineAngle()
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
float startangle = 0.0f;
|
||||||
|
|
||||||
|
if (angleMode == 0) startangle = -Vector2LineAngle(v0, v1)*RAD2DEG;
|
||||||
|
if (angleMode == 1) startangle = 0.0f;
|
||||||
|
|
||||||
|
v2 = GetMousePosition();
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_SPACE)) angleMode = !angleMode;
|
||||||
|
|
||||||
|
if(angleMode == 0 && IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) v1 = GetMousePosition();
|
||||||
|
|
||||||
|
if (angleMode == 0)
|
||||||
|
{
|
||||||
|
// Calculate angle between two vectors, considering a common origin (v0)
|
||||||
|
Vector2 v1Normal = Vector2Normalize(Vector2Subtract(v1, v0));
|
||||||
|
Vector2 v2Normal = Vector2Normalize(Vector2Subtract(v2, v0));
|
||||||
|
|
||||||
|
angle = Vector2Angle(v1Normal, v2Normal)*RAD2DEG;
|
||||||
|
}
|
||||||
|
else if (angleMode == 1)
|
||||||
|
{
|
||||||
|
// Calculate angle defined by a two vectors line, in reference to horizontal line
|
||||||
|
angle = Vector2LineAngle(v0, v2)*RAD2DEG;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
if (angleMode == 0)
|
||||||
|
{
|
||||||
|
DrawText("MODE 0: Angle between V1 and V2", 10, 10, 20, BLACK);
|
||||||
|
DrawText("Right Click to Move V2", 10, 30, 20, DARKGRAY);
|
||||||
|
|
||||||
|
DrawLineEx(v0, v1, 2.0f, BLACK);
|
||||||
|
DrawLineEx(v0, v2, 2.0f, RED);
|
||||||
|
|
||||||
|
DrawCircleSector(v0, 40.0f, startangle, startangle + angle, 32, Fade(GREEN, 0.6f));
|
||||||
|
}
|
||||||
|
else if (angleMode == 1)
|
||||||
|
{
|
||||||
|
DrawText("MODE 1: Angle formed by line V1 to V2", 10, 10, 20, BLACK);
|
||||||
|
|
||||||
|
DrawLine(0, screenHeight/2, screenWidth, screenHeight/2, LIGHTGRAY);
|
||||||
|
DrawLineEx(v0, v2, 2.0f, RED);
|
||||||
|
|
||||||
|
DrawCircleSector(v0, 40.0f, startangle, startangle - angle, 32, Fade(GREEN, 0.6f));
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawText("v0", v0.x, v0.y, 10, DARKGRAY);
|
||||||
|
|
||||||
|
// If the line from v0 to v1 would overlap the text, move it's position up 10
|
||||||
|
if (angleMode == 0 && Vector2Subtract(v0, v1).y > 0.0f) DrawText("v1", v1.x, v1.y-10.0f, 10, DARKGRAY);
|
||||||
|
if (angleMode == 0 && Vector2Subtract(v0, v1).y < 0.0f) DrawText("v1", v1.x, v1.y, 10, DARKGRAY);
|
||||||
|
|
||||||
|
// If angle mode 1, use v1 to emphasize the horizontal line
|
||||||
|
if (angleMode == 1) DrawText("v1", v0.x + 40.0f, v0.y, 10, DARKGRAY);
|
||||||
|
|
||||||
|
// position adjusted by -10 so it isn't hidden by cursor
|
||||||
|
DrawText("v2", v2.x-10.0f, v2.y-10.0f, 10, DARKGRAY);
|
||||||
|
|
||||||
|
DrawText("Press SPACE to change MODE", 460, 10, 20, DARKGRAY);
|
||||||
|
DrawText(TextFormat("ANGLE: %2.2f", angle), 10, 70, 20, LIME);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
examples/others/raymath_vector_angle.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
|
@ -9,3 +9,5 @@
|
||||||
| raysan.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
| raysan.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||||
| space.png | ❔ | ❔ | - |
|
| space.png | ❔ | ❔ | - |
|
||||||
| texel_checker.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [UV Checker Map Maker](http://uvchecker.byvalle.com/) |
|
| texel_checker.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [UV Checker Map Maker](http://uvchecker.byvalle.com/) |
|
||||||
|
| cubicmap.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||||
|
| spark_flame.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [EffectTextureMaker](https://mebiusbox.github.io/contents/EffectTextureMaker/) |
|
||||||
BIN
examples/shaders/resources/cubicmap_atlas.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
|
|
@ -6,30 +6,30 @@ precision mediump float;
|
||||||
varying vec2 fragTexCoord;
|
varying vec2 fragTexCoord;
|
||||||
varying vec4 fragColor;
|
varying vec4 fragColor;
|
||||||
|
|
||||||
uniform vec2 screenDims; // Dimensions of the screen
|
|
||||||
uniform vec2 c; // c.x = real, c.y = imaginary component. Equation done is z^2 + c
|
uniform vec2 c; // c.x = real, c.y = imaginary component. Equation done is z^2 + c
|
||||||
uniform vec2 offset; // Offset of the scale.
|
uniform vec2 offset; // Offset of the scale.
|
||||||
uniform float zoom; // Zoom of the scale.
|
uniform float zoom; // Zoom of the scale.
|
||||||
|
|
||||||
// NOTE: Maximum number of shader for-loop iterations depend on GPU,
|
// NOTE: Maximum number of shader for-loop iterations depend on GPU,
|
||||||
// for example, on RasperryPi for this examply only supports up to 60
|
// for example, on RasperryPi for this examply only supports up to 60
|
||||||
const int MAX_ITERATIONS = 48; // Max iterations to do
|
const int maxIterations = 48; // Max iterations to do.
|
||||||
|
const float colorCycles = 1.0f; // Number of times the color palette repeats.
|
||||||
|
|
||||||
// Square a complex number
|
// Square a complex number
|
||||||
vec2 ComplexSquare(vec2 z)
|
vec2 ComplexSquare(vec2 z)
|
||||||
{
|
{
|
||||||
return vec2(
|
return vec2(
|
||||||
z.x * z.x - z.y * z.y,
|
z.x*z.x - z.y*z.y,
|
||||||
z.x * z.y * 2.0
|
z.x*z.y*2.0f
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert Hue Saturation Value (HSV) color into RGB
|
// Convert Hue Saturation Value (HSV) color into RGB
|
||||||
vec3 Hsv2rgb(vec3 c)
|
vec3 Hsv2rgb(vec3 c)
|
||||||
{
|
{
|
||||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
vec4 K = vec4(1.0f, 2.0f/3.0f, 1.0f/3.0f, 3.0f);
|
||||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
vec3 p = abs(fract(c.xxx + K.xyz)*6.0f - K.www);
|
||||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
return c.z*mix(K.xxx, clamp(p - K.xxx, 0.0f, 1.0f), c.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
|
@ -45,8 +45,8 @@ void main()
|
||||||
|
|
||||||
If the number is below 2, we keep iterating.
|
If the number is below 2, we keep iterating.
|
||||||
But when do we stop iterating if the number is always below 2 (it converges)?
|
But when do we stop iterating if the number is always below 2 (it converges)?
|
||||||
That is what MAX_ITERATIONS is for.
|
That is what maxIterations is for.
|
||||||
Then we can divide the iterations by the MAX_ITERATIONS value to get a normalized value that we can
|
Then we can divide the iterations by the maxIterations value to get a normalized value that we can
|
||||||
then map to a color.
|
then map to a color.
|
||||||
|
|
||||||
We use dot product (z.x * z.x + z.y * z.y) to determine the magnitude (length) squared.
|
We use dot product (z.x * z.x + z.y * z.y) to determine the magnitude (length) squared.
|
||||||
|
|
@ -55,13 +55,15 @@ void main()
|
||||||
|
|
||||||
// The pixel coordinates are scaled so they are on the mandelbrot scale
|
// The pixel coordinates are scaled so they are on the mandelbrot scale
|
||||||
// NOTE: fragTexCoord already comes as normalized screen coordinates but offset must be normalized before scaling and zoom
|
// NOTE: fragTexCoord already comes as normalized screen coordinates but offset must be normalized before scaling and zoom
|
||||||
vec2 z = vec2((fragTexCoord.x + offset.x/screenDims.x)*2.5/zoom, (fragTexCoord.y + offset.y/screenDims.y)*1.5/zoom);
|
vec2 z = vec2((fragTexCoord.x - 0.5f)*2.5f, (fragTexCoord.y - 0.5f)*1.5f)/zoom;
|
||||||
|
z.x += offset.x;
|
||||||
|
z.y += offset.y;
|
||||||
|
|
||||||
int iter = 0;
|
int iter = 0;
|
||||||
for (int iterations = 0; iterations < 60; iterations++)
|
for (int iterations = 0; iterations < 60; iterations++)
|
||||||
{
|
{
|
||||||
z = ComplexSquare(z) + c; // Iterate function
|
z = ComplexSquare(z) + c; // Iterate function
|
||||||
if (dot(z, z) > 4.0) break;
|
if (dot(z, z) > 4.0f) break;
|
||||||
|
|
||||||
iter = iterations;
|
iter = iterations;
|
||||||
}
|
}
|
||||||
|
|
@ -72,12 +74,12 @@ void main()
|
||||||
z = ComplexSquare(z) + c;
|
z = ComplexSquare(z) + c;
|
||||||
|
|
||||||
// This last part smooths the color (again see link above).
|
// This last part smooths the color (again see link above).
|
||||||
float smoothVal = float(iter) + 1.0 - (log(log(length(z)))/log(2.0));
|
float smoothVal = float(iter) + 1.0f - (log(log(length(z)))/log(2.0f));
|
||||||
|
|
||||||
// Normalize the value so it is between 0 and 1.
|
// Normalize the value so it is between 0 and 1.
|
||||||
float norm = smoothVal/float(MAX_ITERATIONS);
|
float norm = smoothVal/float(maxIterations);
|
||||||
|
|
||||||
// If in set, color black. 0.999 allows for some float accuracy error.
|
// If in set, color black. 0.999 allows for some float accuracy error.
|
||||||
if (norm > 0.999) gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
if (norm > 0.999f) gl_FragColor = vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
else gl_FragColor = vec4(Hsv2rgb(vec3(norm, 1.0, 1.0)), 1.0);
|
else gl_FragColor = vec4(Hsv2rgb(vec3(norm*colorCycles, 1.0f, 1.0f)), 1.0f);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,6 @@ uniform vec4 colDiffuse;
|
||||||
#define LIGHT_DIRECTIONAL 0
|
#define LIGHT_DIRECTIONAL 0
|
||||||
#define LIGHT_POINT 1
|
#define LIGHT_POINT 1
|
||||||
|
|
||||||
struct MaterialProperty {
|
|
||||||
vec3 color;
|
|
||||||
int useSampler;
|
|
||||||
sampler2D sampler;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Light {
|
struct Light {
|
||||||
int enabled;
|
int enabled;
|
||||||
int type;
|
int type;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ varying vec4 fragColor;
|
||||||
uniform sampler2D texture0;
|
uniform sampler2D texture0;
|
||||||
uniform vec4 colDiffuse;
|
uniform vec4 colDiffuse;
|
||||||
|
|
||||||
uniform float secondes;
|
uniform float seconds;
|
||||||
|
|
||||||
uniform vec2 size;
|
uniform vec2 size;
|
||||||
|
|
||||||
|
|
@ -29,8 +29,8 @@ void main() {
|
||||||
float boxTop = 0.0;
|
float boxTop = 0.0;
|
||||||
|
|
||||||
vec2 p = fragTexCoord;
|
vec2 p = fragTexCoord;
|
||||||
p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth;
|
p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (seconds * speedX)) * ampX * pixelWidth;
|
||||||
p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight;
|
p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (seconds * speedY)) * ampY * pixelHeight;
|
||||||
|
|
||||||
gl_FragColor = texture2D(texture0, p)*colDiffuse*fragColor;
|
gl_FragColor = texture2D(texture0, p)*colDiffuse*fragColor;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,6 @@ uniform vec4 colDiffuse;
|
||||||
#define LIGHT_DIRECTIONAL 0
|
#define LIGHT_DIRECTIONAL 0
|
||||||
#define LIGHT_POINT 1
|
#define LIGHT_POINT 1
|
||||||
|
|
||||||
struct MaterialProperty {
|
|
||||||
vec3 color;
|
|
||||||
int useSampler;
|
|
||||||
sampler2D sampler;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Light {
|
struct Light {
|
||||||
int enabled;
|
int enabled;
|
||||||
int type;
|
int type;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
#version 330 core
|
||||||
|
out vec4 finalColor;
|
||||||
|
|
||||||
|
in vec2 texCoord;
|
||||||
|
in vec2 texCoord2;
|
||||||
|
|
||||||
|
uniform sampler2D gPosition;
|
||||||
|
uniform sampler2D gNormal;
|
||||||
|
uniform sampler2D gAlbedoSpec;
|
||||||
|
|
||||||
|
struct Light {
|
||||||
|
int enabled;
|
||||||
|
int type; // Unused in this demo.
|
||||||
|
vec3 position;
|
||||||
|
vec3 target; // Unused in this demo.
|
||||||
|
vec4 color;
|
||||||
|
};
|
||||||
|
|
||||||
|
const int NR_LIGHTS = 4;
|
||||||
|
uniform Light lights[NR_LIGHTS];
|
||||||
|
uniform vec3 viewPosition;
|
||||||
|
|
||||||
|
const float QUADRATIC = 0.032;
|
||||||
|
const float LINEAR = 0.09;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec3 fragPosition = texture(gPosition, texCoord).rgb;
|
||||||
|
vec3 normal = texture(gNormal, texCoord).rgb;
|
||||||
|
vec3 albedo = texture(gAlbedoSpec, texCoord).rgb;
|
||||||
|
float specular = texture(gAlbedoSpec, texCoord).a;
|
||||||
|
|
||||||
|
vec3 ambient = albedo * vec3(0.1f);
|
||||||
|
vec3 viewDirection = normalize(viewPosition - fragPosition);
|
||||||
|
|
||||||
|
for(int i = 0; i < NR_LIGHTS; ++i)
|
||||||
|
{
|
||||||
|
if(lights[i].enabled == 0) continue;
|
||||||
|
vec3 lightDirection = lights[i].position - fragPosition;
|
||||||
|
vec3 diffuse = max(dot(normal, lightDirection), 0.0) * albedo * lights[i].color.xyz;
|
||||||
|
|
||||||
|
vec3 halfwayDirection = normalize(lightDirection + viewDirection);
|
||||||
|
float spec = pow(max(dot(normal, halfwayDirection), 0.0), 32.0);
|
||||||
|
vec3 specular = specular * spec * lights[i].color.xyz;
|
||||||
|
|
||||||
|
// Attenuation
|
||||||
|
float distance = length(lights[i].position - fragPosition);
|
||||||
|
float attenuation = 1.0 / (1.0 + LINEAR * distance + QUADRATIC * distance * distance);
|
||||||
|
diffuse *= attenuation;
|
||||||
|
specular *= attenuation;
|
||||||
|
ambient += diffuse + specular;
|
||||||
|
}
|
||||||
|
|
||||||
|
finalColor = vec4(ambient, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
layout (location = 0) in vec3 vertexPosition;
|
||||||
|
layout (location = 1) in vec2 vertexTexCoord;
|
||||||
|
|
||||||
|
out vec2 texCoord;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = vec4(vertexPosition, 1.0);
|
||||||
|
texCoord = vertexTexCoord;
|
||||||
|
}
|
||||||
22
examples/shaders/resources/shaders/glsl330/gbuffer.fs
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#version 330 core
|
||||||
|
layout (location = 0) out vec3 gPosition;
|
||||||
|
layout (location = 1) out vec3 gNormal;
|
||||||
|
layout (location = 2) out vec4 gAlbedoSpec;
|
||||||
|
|
||||||
|
in vec3 fragPosition;
|
||||||
|
in vec2 fragTexCoord;
|
||||||
|
in vec3 fragNormal;
|
||||||
|
|
||||||
|
uniform sampler2D diffuseTexture;
|
||||||
|
uniform sampler2D specularTexture;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
// store the fragment position vector in the first gbuffer texture
|
||||||
|
gPosition = fragPosition;
|
||||||
|
// also store the per-fragment normals into the gbuffer
|
||||||
|
gNormal = normalize(fragNormal);
|
||||||
|
// and the diffuse per-fragment color
|
||||||
|
gAlbedoSpec.rgb = texture(diffuseTexture, fragTexCoord).rgb;
|
||||||
|
// store specular intensity in gAlbedoSpec's alpha component
|
||||||
|
gAlbedoSpec.a = texture(specularTexture, fragTexCoord).r;
|
||||||
|
}
|
||||||
24
examples/shaders/resources/shaders/glsl330/gbuffer.vs
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#version 330 core
|
||||||
|
layout (location = 0) in vec3 vertexPosition;
|
||||||
|
layout (location = 1) in vec2 vertexTexCoord;
|
||||||
|
layout (location = 2) in vec3 vertexNormal;
|
||||||
|
|
||||||
|
out vec3 fragPosition;
|
||||||
|
out vec2 fragTexCoord;
|
||||||
|
out vec3 fragNormal;
|
||||||
|
|
||||||
|
uniform mat4 matModel;
|
||||||
|
uniform mat4 matView;
|
||||||
|
uniform mat4 matProjection;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 worldPos = matModel * vec4(vertexPosition, 1.0);
|
||||||
|
fragPosition = worldPos.xyz;
|
||||||
|
fragTexCoord = vertexTexCoord;
|
||||||
|
|
||||||
|
mat3 normalMatrix = transpose(inverse(mat3(matModel)));
|
||||||
|
fragNormal = normalMatrix * vertexNormal;
|
||||||
|
|
||||||
|
gl_Position = matProjection * matView * worldPos;
|
||||||
|
}
|
||||||
|
|
@ -7,28 +7,28 @@ in vec4 fragColor;
|
||||||
// Output fragment color
|
// Output fragment color
|
||||||
out vec4 finalColor;
|
out vec4 finalColor;
|
||||||
|
|
||||||
uniform vec2 screenDims; // Dimensions of the screen
|
|
||||||
uniform vec2 c; // c.x = real, c.y = imaginary component. Equation done is z^2 + c
|
uniform vec2 c; // c.x = real, c.y = imaginary component. Equation done is z^2 + c
|
||||||
uniform vec2 offset; // Offset of the scale.
|
uniform vec2 offset; // Offset of the scale.
|
||||||
uniform float zoom; // Zoom of the scale.
|
uniform float zoom; // Zoom of the scale.
|
||||||
|
|
||||||
const int MAX_ITERATIONS = 255; // Max iterations to do.
|
const int maxIterations = 255; // Max iterations to do.
|
||||||
|
const float colorCycles = 2.0f; // Number of times the color palette repeats. Can show higher detail for higher iteration numbers.
|
||||||
|
|
||||||
// Square a complex number
|
// Square a complex number
|
||||||
vec2 ComplexSquare(vec2 z)
|
vec2 ComplexSquare(vec2 z)
|
||||||
{
|
{
|
||||||
return vec2(
|
return vec2(
|
||||||
z.x * z.x - z.y * z.y,
|
z.x*z.x - z.y*z.y,
|
||||||
z.x * z.y * 2.0
|
z.x*z.y*2.0f
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert Hue Saturation Value (HSV) color into RGB
|
// Convert Hue Saturation Value (HSV) color into RGB
|
||||||
vec3 Hsv2rgb(vec3 c)
|
vec3 Hsv2rgb(vec3 c)
|
||||||
{
|
{
|
||||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
vec4 K = vec4(1.0f, 2.0f/3.0f, 1.0f/3.0f, 3.0f);
|
||||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
vec3 p = abs(fract(c.xxx + K.xyz)*6.0f - K.www);
|
||||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
return c.z*mix(K.xxx, clamp(p - K.xxx, 0.0f, 1.0f), c.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
|
@ -44,8 +44,8 @@ void main()
|
||||||
|
|
||||||
If the number is below 2, we keep iterating.
|
If the number is below 2, we keep iterating.
|
||||||
But when do we stop iterating if the number is always below 2 (it converges)?
|
But when do we stop iterating if the number is always below 2 (it converges)?
|
||||||
That is what MAX_ITERATIONS is for.
|
That is what maxIterations is for.
|
||||||
Then we can divide the iterations by the MAX_ITERATIONS value to get a normalized value that we can
|
Then we can divide the iterations by the maxIterations value to get a normalized value that we can
|
||||||
then map to a color.
|
then map to a color.
|
||||||
|
|
||||||
We use dot product (z.x * z.x + z.y * z.y) to determine the magnitude (length) squared.
|
We use dot product (z.x * z.x + z.y * z.y) to determine the magnitude (length) squared.
|
||||||
|
|
@ -54,14 +54,16 @@ void main()
|
||||||
|
|
||||||
// The pixel coordinates are scaled so they are on the mandelbrot scale
|
// The pixel coordinates are scaled so they are on the mandelbrot scale
|
||||||
// NOTE: fragTexCoord already comes as normalized screen coordinates but offset must be normalized before scaling and zoom
|
// NOTE: fragTexCoord already comes as normalized screen coordinates but offset must be normalized before scaling and zoom
|
||||||
vec2 z = vec2((fragTexCoord.x + offset.x/screenDims.x)*2.5/zoom, (fragTexCoord.y + offset.y/screenDims.y)*1.5/zoom);
|
vec2 z = vec2((fragTexCoord.x - 0.5f)*2.5f, (fragTexCoord.y - 0.5f)*1.5f)/zoom;
|
||||||
|
z.x += offset.x;
|
||||||
|
z.y += offset.y;
|
||||||
|
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
for (iterations = 0; iterations < MAX_ITERATIONS; iterations++)
|
for (iterations = 0; iterations < maxIterations; iterations++)
|
||||||
{
|
{
|
||||||
z = ComplexSquare(z) + c; // Iterate function
|
z = ComplexSquare(z) + c; // Iterate function
|
||||||
|
|
||||||
if (dot(z, z) > 4.0) break;
|
if (dot(z, z) > 4.0f) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Another few iterations decreases errors in the smoothing calculation.
|
// Another few iterations decreases errors in the smoothing calculation.
|
||||||
|
|
@ -70,12 +72,12 @@ void main()
|
||||||
z = ComplexSquare(z) + c;
|
z = ComplexSquare(z) + c;
|
||||||
|
|
||||||
// This last part smooths the color (again see link above).
|
// This last part smooths the color (again see link above).
|
||||||
float smoothVal = float(iterations) + 1.0 - (log(log(length(z)))/log(2.0));
|
float smoothVal = float(iterations) + 1.0f - (log(log(length(z)))/log(2.0f));
|
||||||
|
|
||||||
// Normalize the value so it is between 0 and 1.
|
// Normalize the value so it is between 0 and 1.
|
||||||
float norm = smoothVal/float(MAX_ITERATIONS);
|
float norm = smoothVal/float(maxIterations);
|
||||||
|
|
||||||
// If in set, color black. 0.999 allows for some float accuracy error.
|
// If in set, color black. 0.999 allows for some float accuracy error.
|
||||||
if (norm > 0.999) finalColor = vec4(0.0, 0.0, 0.0, 1.0);
|
if (norm > 0.999f) finalColor = vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
else finalColor = vec4(Hsv2rgb(vec3(norm, 1.0, 1.0)), 1.0);
|
else finalColor = vec4(Hsv2rgb(vec3(norm*colorCycles, 1.0f, 1.0f)), 1.0f);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,6 @@ out vec4 finalColor;
|
||||||
#define LIGHT_DIRECTIONAL 0
|
#define LIGHT_DIRECTIONAL 0
|
||||||
#define LIGHT_POINT 1
|
#define LIGHT_POINT 1
|
||||||
|
|
||||||
struct MaterialProperty {
|
|
||||||
vec3 color;
|
|
||||||
int useSampler;
|
|
||||||
sampler2D sampler;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Light {
|
struct Light {
|
||||||
int enabled;
|
int enabled;
|
||||||
int type;
|
int type;
|
||||||
|
|
|
||||||
23
examples/shaders/resources/shaders/glsl330/lightmap.fs
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#version 330
|
||||||
|
|
||||||
|
// Input vertex attributes (from vertex shader)
|
||||||
|
in vec2 fragTexCoord;
|
||||||
|
in vec2 fragTexCoord2;
|
||||||
|
in vec3 fragPosition;
|
||||||
|
in vec4 fragColor;
|
||||||
|
|
||||||
|
// Input uniform values
|
||||||
|
uniform sampler2D texture0;
|
||||||
|
uniform sampler2D texture1;
|
||||||
|
|
||||||
|
// Output fragment color
|
||||||
|
out vec4 finalColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// Texel color fetching from texture sampler
|
||||||
|
vec4 texelColor = texture(texture0, fragTexCoord);
|
||||||
|
vec4 texelColor2 = texture(texture1, fragTexCoord2);
|
||||||
|
|
||||||
|
finalColor = texelColor * texelColor2;
|
||||||
|
}
|
||||||
29
examples/shaders/resources/shaders/glsl330/lightmap.vs
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#version 330
|
||||||
|
|
||||||
|
// Input vertex attributes
|
||||||
|
in vec3 vertexPosition;
|
||||||
|
in vec2 vertexTexCoord;
|
||||||
|
in vec2 vertexTexCoord2;
|
||||||
|
in vec4 vertexColor;
|
||||||
|
|
||||||
|
// Input uniform values
|
||||||
|
uniform mat4 mvp;
|
||||||
|
uniform mat4 matModel;
|
||||||
|
|
||||||
|
// Output vertex attributes (to fragment shader)
|
||||||
|
out vec3 fragPosition;
|
||||||
|
out vec2 fragTexCoord;
|
||||||
|
out vec2 fragTexCoord2;
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// Send vertex attributes to fragment shader
|
||||||
|
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
|
||||||
|
fragTexCoord = vertexTexCoord;
|
||||||
|
fragTexCoord2 = vertexTexCoord2;
|
||||||
|
fragColor = vertexColor;
|
||||||
|
|
||||||
|
// Calculate final vertex position
|
||||||
|
gl_Position = mvp*vec4(vertexPosition, 1.0);
|
||||||
|
}
|
||||||
14
examples/shaders/resources/shaders/glsl330/tiling.fs
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
uniform sampler2D diffuseMap;
|
||||||
|
uniform vec2 tiling;
|
||||||
|
|
||||||
|
in vec2 fragTexCoord;
|
||||||
|
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec2 texCoord = fragTexCoord * tiling;
|
||||||
|
fragColor = texture(diffuseMap, texCoord);
|
||||||
|
}
|
||||||
|
|
@ -11,7 +11,7 @@ uniform vec4 colDiffuse;
|
||||||
// Output fragment color
|
// Output fragment color
|
||||||
out vec4 finalColor;
|
out vec4 finalColor;
|
||||||
|
|
||||||
uniform float secondes;
|
uniform float seconds;
|
||||||
|
|
||||||
uniform vec2 size;
|
uniform vec2 size;
|
||||||
|
|
||||||
|
|
@ -30,8 +30,8 @@ void main() {
|
||||||
float boxTop = 0.0;
|
float boxTop = 0.0;
|
||||||
|
|
||||||
vec2 p = fragTexCoord;
|
vec2 p = fragTexCoord;
|
||||||
p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth;
|
p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (seconds * speedX)) * ampX * pixelWidth;
|
||||||
p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight;
|
p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (seconds * speedY)) * ampY * pixelHeight;
|
||||||
|
|
||||||
finalColor = texture(texture0, p)*colDiffuse*fragColor;
|
finalColor = texture(texture0, p)*colDiffuse*fragColor;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
examples/shaders/resources/spark_flame.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
94
examples/shaders/shader_texture_tiling.c
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [textures] example - Texture Tiling
|
||||||
|
*
|
||||||
|
* Example demonstrates how to tile a texture on a 3D model using raylib.
|
||||||
|
*
|
||||||
|
* Example contributed by Luís Almeida (https://github.com/luis605)
|
||||||
|
*
|
||||||
|
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||||
|
* BSD-like license that allows static linking with closed source software
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Luís Almeida (https://github.com/luis605)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 600;
|
||||||
|
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
InitWindow(screenWidth, screenHeight, "Raylib Texture Tiling");
|
||||||
|
|
||||||
|
SetTargetFPS(60);
|
||||||
|
|
||||||
|
// Load a texture
|
||||||
|
Texture2D texture = LoadTexture("resources/raylib_logo.png");
|
||||||
|
|
||||||
|
// Create a cube mesh
|
||||||
|
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
// Load the texture onto the GPU
|
||||||
|
Model model = LoadModelFromMesh(cube);
|
||||||
|
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
|
||||||
|
|
||||||
|
// Set the tiling of the texture
|
||||||
|
float tiling[2] = {3.0f, 3.0f};
|
||||||
|
Shader shader = LoadShader(0, "resources/shaders/glsl330/tiling.fs"); // Create a custom shader in a .glsl file
|
||||||
|
SetShaderValue(shader, GetShaderLocation(shader, "tiling"), tiling, SHADER_UNIFORM_VEC2);
|
||||||
|
model.materials[0].shader = shader;
|
||||||
|
|
||||||
|
// Camera setup
|
||||||
|
Camera camera = { 0 };
|
||||||
|
camera.position = (Vector3){ 3.0f, 3.0f, 3.0f };
|
||||||
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||||
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||||
|
camera.fovy = 45.0f;
|
||||||
|
camera.projection = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose())
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BeginDrawing();
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
UpdateCamera(&camera, CAMERA_FREE);
|
||||||
|
|
||||||
|
// Draw the model
|
||||||
|
{
|
||||||
|
BeginMode3D(camera);
|
||||||
|
BeginShaderMode(shader);
|
||||||
|
|
||||||
|
DrawModel(model, (Vector3){ 0.0f, 0.0f, 0.0f }, 5.0f, WHITE);
|
||||||
|
|
||||||
|
EndShaderMode();
|
||||||
|
EndMode3D();
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawText("Use mouse to rotate the camera", 10, 10, 20, DARKGRAY);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
UnloadTexture(texture); // Unload texture
|
||||||
|
UnloadModel(model); // Unload model
|
||||||
|
UnloadShader(shader); // Unload shader
|
||||||
|
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
336
examples/shaders/shaders_deferred_render.c
Normal file
|
|
@ -0,0 +1,336 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [shaders] example - deferred rendering
|
||||||
|
*
|
||||||
|
* NOTE: This example requires raylib OpenGL 3.3 or OpenGL ES 3.0
|
||||||
|
*
|
||||||
|
* Example originally created with raylib 4.5, last time updated with raylib 4.5
|
||||||
|
*
|
||||||
|
* Example contributed by Justin Andreas Lacoste (@27justin) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||||
|
* BSD-like license that allows static linking with closed source software
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Justin Andreas Lacoste (@27justin)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#include "rlgl.h"
|
||||||
|
#include "raymath.h"
|
||||||
|
|
||||||
|
#define RLIGHTS_IMPLEMENTATION
|
||||||
|
#include "rlights.h"
|
||||||
|
|
||||||
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
#define GLSL_VERSION 330
|
||||||
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
|
#define GLSL_VERSION 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h> // Required for: NULL
|
||||||
|
|
||||||
|
#define MAX_CUBES 30
|
||||||
|
|
||||||
|
typedef struct GBuffer {
|
||||||
|
unsigned int framebuffer;
|
||||||
|
|
||||||
|
unsigned int positionTexture;
|
||||||
|
unsigned int normalTexture;
|
||||||
|
unsigned int albedoSpecTexture;
|
||||||
|
|
||||||
|
unsigned int depthRenderbuffer;
|
||||||
|
} GBuffer;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
DEFERRED_POSITION,
|
||||||
|
DEFERRED_NORMAL,
|
||||||
|
DEFERRED_ALBEDO,
|
||||||
|
DEFERRED_SHADING
|
||||||
|
} DeferredMode;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
// -------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - deferred render");
|
||||||
|
|
||||||
|
Camera camera = { 0 };
|
||||||
|
camera.position = (Vector3){ 5.0f, 4.0f, 5.0f }; // Camera position
|
||||||
|
camera.target = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera looking at point
|
||||||
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
camera.fovy = 60.0f; // Camera field-of-view Y
|
||||||
|
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||||
|
|
||||||
|
// Load plane model from a generated mesh
|
||||||
|
Model model = LoadModelFromMesh(GenMeshPlane(10.0f, 10.0f, 3, 3));
|
||||||
|
Model cube = LoadModelFromMesh(GenMeshCube(2.0f, 2.0f, 2.0f));
|
||||||
|
|
||||||
|
// Load geometry buffer (G-buffer) shader and deferred shader
|
||||||
|
Shader gbufferShader = LoadShader("resources/shaders/glsl330/gbuffer.vs",
|
||||||
|
"resources/shaders/glsl330/gbuffer.fs");
|
||||||
|
|
||||||
|
Shader deferredShader = LoadShader("resources/shaders/glsl330/deferred_shading.vs",
|
||||||
|
"resources/shaders/glsl330/deferred_shading.fs");
|
||||||
|
deferredShader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(deferredShader, "viewPosition");
|
||||||
|
|
||||||
|
// Initialize the G-buffer
|
||||||
|
GBuffer gBuffer = { 0 };
|
||||||
|
gBuffer.framebuffer = rlLoadFramebuffer(screenWidth, screenHeight);
|
||||||
|
|
||||||
|
if (!gBuffer.framebuffer)
|
||||||
|
{
|
||||||
|
TraceLog(LOG_WARNING, "Failed to create framebuffer");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
rlEnableFramebuffer(gBuffer.framebuffer);
|
||||||
|
|
||||||
|
// Since we are storing position and normal data in these textures,
|
||||||
|
// we need to use a floating point format.
|
||||||
|
gBuffer.positionTexture = rlLoadTexture(NULL, screenWidth, screenHeight, RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32, 1);
|
||||||
|
|
||||||
|
gBuffer.normalTexture = rlLoadTexture(NULL, screenWidth, screenHeight, RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32, 1);
|
||||||
|
// Albedo (diffuse color) and specular strength can be combined into one texture.
|
||||||
|
// The color in RGB, and the specular strength in the alpha channel.
|
||||||
|
gBuffer.albedoSpecTexture = rlLoadTexture(NULL, screenWidth, screenHeight, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1);
|
||||||
|
|
||||||
|
// Activate the draw buffers for our framebuffer
|
||||||
|
rlActiveDrawBuffers(3);
|
||||||
|
|
||||||
|
// Now we attach our textures to the framebuffer.
|
||||||
|
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.positionTexture, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_TEXTURE2D, 0);
|
||||||
|
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.normalTexture, RL_ATTACHMENT_COLOR_CHANNEL1, RL_ATTACHMENT_TEXTURE2D, 0);
|
||||||
|
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.albedoSpecTexture, RL_ATTACHMENT_COLOR_CHANNEL2, RL_ATTACHMENT_TEXTURE2D, 0);
|
||||||
|
|
||||||
|
// Finally we attach the depth buffer.
|
||||||
|
gBuffer.depthRenderbuffer = rlLoadTextureDepth(screenWidth, screenHeight, true);
|
||||||
|
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.depthRenderbuffer, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
||||||
|
|
||||||
|
// Make sure our framebuffer is complete.
|
||||||
|
// NOTE: rlFramebufferComplete() automatically unbinds the framebuffer, so we don't have
|
||||||
|
// to rlDisableFramebuffer() here.
|
||||||
|
if (!rlFramebufferComplete(gBuffer.framebuffer))
|
||||||
|
{
|
||||||
|
TraceLog(LOG_WARNING, "Framebuffer is not complete");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now we initialize the sampler2D uniform's in the deferred shader.
|
||||||
|
// We do this by setting the uniform's value to the color channel slot we earlier
|
||||||
|
// bound our textures to.
|
||||||
|
rlEnableShader(deferredShader.id);
|
||||||
|
|
||||||
|
rlSetUniformSampler(rlGetLocationUniform(deferredShader.id, "gPosition"), 0);
|
||||||
|
rlSetUniformSampler(rlGetLocationUniform(deferredShader.id, "gNormal"), 1);
|
||||||
|
rlSetUniformSampler(rlGetLocationUniform(deferredShader.id, "gAlbedoSpec"), 2);
|
||||||
|
|
||||||
|
rlDisableShader();
|
||||||
|
|
||||||
|
// Assign out lighting shader to model
|
||||||
|
model.materials[0].shader = gbufferShader;
|
||||||
|
cube.materials[0].shader = gbufferShader;
|
||||||
|
|
||||||
|
// Create lights
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
Light lights[MAX_LIGHTS] = { 0 };
|
||||||
|
lights[0] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, -2 }, Vector3Zero(), YELLOW, deferredShader);
|
||||||
|
lights[1] = CreateLight(LIGHT_POINT, (Vector3){ 2, 1, 2 }, Vector3Zero(), RED, deferredShader);
|
||||||
|
lights[2] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, 2 }, Vector3Zero(), GREEN, deferredShader);
|
||||||
|
lights[3] = CreateLight(LIGHT_POINT, (Vector3){ 2, 1, -2 }, Vector3Zero(), BLUE, deferredShader);
|
||||||
|
|
||||||
|
const float CUBE_SCALE = 0.25;
|
||||||
|
Vector3 cubePositions[MAX_CUBES] = { 0 };
|
||||||
|
float cubeRotations[MAX_CUBES] = { 0 };
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_CUBES; i++)
|
||||||
|
{
|
||||||
|
cubePositions[i] = (Vector3){
|
||||||
|
.x = (float)(rand()%10) - 5,
|
||||||
|
.y = (float)(rand()%5),
|
||||||
|
.z = (float)(rand()%10) - 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
cubeRotations[i] = (float)(rand()%360);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeferredMode mode = DEFERRED_SHADING;
|
||||||
|
|
||||||
|
rlEnableDepthTest();
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose())
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||||
|
|
||||||
|
// Update the shader with the camera view vector (points towards { 0.0f, 0.0f, 0.0f })
|
||||||
|
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
|
||||||
|
SetShaderValue(deferredShader, deferredShader.locs[SHADER_LOC_VECTOR_VIEW], cameraPos, SHADER_UNIFORM_VEC3);
|
||||||
|
|
||||||
|
// Check key inputs to enable/disable lights
|
||||||
|
if (IsKeyPressed(KEY_Y)) { lights[0].enabled = !lights[0].enabled; }
|
||||||
|
if (IsKeyPressed(KEY_R)) { lights[1].enabled = !lights[1].enabled; }
|
||||||
|
if (IsKeyPressed(KEY_G)) { lights[2].enabled = !lights[2].enabled; }
|
||||||
|
if (IsKeyPressed(KEY_B)) { lights[3].enabled = !lights[3].enabled; }
|
||||||
|
|
||||||
|
// Check key inputs to switch between G-buffer textures
|
||||||
|
if (IsKeyPressed(KEY_ONE)) mode = DEFERRED_POSITION;
|
||||||
|
if (IsKeyPressed(KEY_TWO)) mode = DEFERRED_NORMAL;
|
||||||
|
if (IsKeyPressed(KEY_THREE)) mode = DEFERRED_ALBEDO;
|
||||||
|
if (IsKeyPressed(KEY_FOUR)) mode = DEFERRED_SHADING;
|
||||||
|
|
||||||
|
// Update light values (actually, only enable/disable them)
|
||||||
|
for (int i = 0; i < MAX_LIGHTS; i++) UpdateLightValues(deferredShader, lights[i]);
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
// ---------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
// Draw to the geometry buffer by first activating it
|
||||||
|
rlEnableFramebuffer(gBuffer.framebuffer);
|
||||||
|
rlClearScreenBuffers(); // Clear color and depth buffer
|
||||||
|
|
||||||
|
rlDisableColorBlend();
|
||||||
|
BeginMode3D(camera);
|
||||||
|
// NOTE: We have to use rlEnableShader here. `BeginShaderMode` or thus `rlSetShader`
|
||||||
|
// will not work, as they won't immediately load the shader program.
|
||||||
|
rlEnableShader(gbufferShader.id);
|
||||||
|
// When drawing a model here, make sure that the material's shaders
|
||||||
|
// are set to the gbuffer shader!
|
||||||
|
DrawModel(model, Vector3Zero(), 1.0f, WHITE);
|
||||||
|
DrawModel(cube, (Vector3) { 0.0, 1.0f, 0.0 }, 1.0f, WHITE);
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_CUBES; i++)
|
||||||
|
{
|
||||||
|
Vector3 position = cubePositions[i];
|
||||||
|
DrawModelEx(cube, position, (Vector3) { 1, 1, 1 }, cubeRotations[i], (Vector3) { CUBE_SCALE, CUBE_SCALE, CUBE_SCALE }, WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
rlDisableShader();
|
||||||
|
EndMode3D();
|
||||||
|
rlEnableColorBlend();
|
||||||
|
|
||||||
|
// Go back to the default framebuffer (0) and draw our deferred shading.
|
||||||
|
rlDisableFramebuffer();
|
||||||
|
rlClearScreenBuffers(); // Clear color & depth buffer
|
||||||
|
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case DEFERRED_SHADING:
|
||||||
|
{
|
||||||
|
BeginMode3D(camera);
|
||||||
|
rlDisableColorBlend();
|
||||||
|
rlEnableShader(deferredShader.id);
|
||||||
|
// Activate our g-buffer textures
|
||||||
|
// These will now be bound to the sampler2D uniforms `gPosition`, `gNormal`,
|
||||||
|
// and `gAlbedoSpec`
|
||||||
|
rlActiveTextureSlot(0);
|
||||||
|
rlEnableTexture(gBuffer.positionTexture);
|
||||||
|
rlActiveTextureSlot(1);
|
||||||
|
rlEnableTexture(gBuffer.normalTexture);
|
||||||
|
rlActiveTextureSlot(2);
|
||||||
|
rlEnableTexture(gBuffer.albedoSpecTexture);
|
||||||
|
|
||||||
|
// Finally, we draw a fullscreen quad to our default framebuffer
|
||||||
|
// This will now be shaded using our deferred shader
|
||||||
|
rlLoadDrawQuad();
|
||||||
|
rlDisableShader();
|
||||||
|
rlEnableColorBlend();
|
||||||
|
EndMode3D();
|
||||||
|
|
||||||
|
// As a last step, we now copy over the depth buffer from our g-buffer to the default framebuffer.
|
||||||
|
rlEnableFramebuffer(gBuffer.framebuffer); //glBindFramebuffer(GL_READ_FRAMEBUFFER, gBuffer.framebuffer);
|
||||||
|
rlEnableFramebuffer(0); //glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
|
rlBlitFramebuffer(0, 0, screenWidth, screenHeight, 0, 0, screenWidth, screenHeight, 0x00000100); // GL_DEPTH_BUFFER_BIT
|
||||||
|
rlDisableFramebuffer();
|
||||||
|
|
||||||
|
// Since our shader is now done and disabled, we can draw our lights in default
|
||||||
|
// forward rendering
|
||||||
|
BeginMode3D(camera);
|
||||||
|
rlEnableShader(rlGetShaderIdDefault());
|
||||||
|
for(int i = 0; i < MAX_LIGHTS; i++)
|
||||||
|
{
|
||||||
|
if (lights[i].enabled) DrawSphereEx(lights[i].position, 0.2f, 8, 8, lights[i].color);
|
||||||
|
else DrawSphereWires(lights[i].position, 0.2f, 8, 8, ColorAlpha(lights[i].color, 0.3f));
|
||||||
|
}
|
||||||
|
rlDisableShader();
|
||||||
|
EndMode3D();
|
||||||
|
DrawText("FINAL RESULT", 10, screenHeight - 30, 20, DARKGREEN);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case DEFERRED_POSITION:
|
||||||
|
{
|
||||||
|
DrawTextureRec((Texture2D){
|
||||||
|
.id = gBuffer.positionTexture,
|
||||||
|
.width = screenWidth,
|
||||||
|
.height = screenHeight,
|
||||||
|
}, (Rectangle) { 0, 0, screenWidth, -screenHeight }, Vector2Zero(), RAYWHITE);
|
||||||
|
DrawText("POSITION TEXTURE", 10, screenHeight - 30, 20, DARKGREEN);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case DEFERRED_NORMAL:
|
||||||
|
{
|
||||||
|
DrawTextureRec((Texture2D){
|
||||||
|
.id = gBuffer.normalTexture,
|
||||||
|
.width = screenWidth,
|
||||||
|
.height = screenHeight,
|
||||||
|
}, (Rectangle) { 0, 0, screenWidth, -screenHeight }, Vector2Zero(), RAYWHITE);
|
||||||
|
DrawText("NORMAL TEXTURE", 10, screenHeight - 30, 20, DARKGREEN);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case DEFERRED_ALBEDO:
|
||||||
|
{
|
||||||
|
DrawTextureRec((Texture2D){
|
||||||
|
.id = gBuffer.albedoSpecTexture,
|
||||||
|
.width = screenWidth,
|
||||||
|
.height = screenHeight,
|
||||||
|
}, (Rectangle) { 0, 0, screenWidth, -screenHeight }, Vector2Zero(), RAYWHITE);
|
||||||
|
DrawText("ALBEDO TEXTURE", 10, screenHeight - 30, 20, DARKGREEN);
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawText("Toggle lights keys: [Y][R][G][B]", 10, 40, 20, DARKGRAY);
|
||||||
|
DrawText("Switch G-buffer textures: [1][2][3][4]", 10, 70, 20, DARKGRAY);
|
||||||
|
|
||||||
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
UnloadModel(model); // Unload the models
|
||||||
|
UnloadModel(cube);
|
||||||
|
|
||||||
|
UnloadShader(deferredShader); // Unload shaders
|
||||||
|
UnloadShader(gbufferShader);
|
||||||
|
|
||||||
|
// Unload geometry buffer and all attached textures
|
||||||
|
rlUnloadFramebuffer(gBuffer.framebuffer);
|
||||||
|
rlUnloadTexture(gBuffer.positionTexture);
|
||||||
|
rlUnloadTexture(gBuffer.normalTexture);
|
||||||
|
rlUnloadTexture(gBuffer.albedoSpecTexture);
|
||||||
|
rlUnloadTexture(gBuffer.depthRenderbuffer);
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
BIN
examples/shaders/shaders_deferred_render.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@
|
||||||
*
|
*
|
||||||
* Example originally created with raylib 2.5, last time updated with raylib 4.0
|
* Example originally created with raylib 2.5, last time updated with raylib 4.0
|
||||||
*
|
*
|
||||||
* Example contributed by eggmund (@eggmund) and reviewed by Ramon Santamaria (@raysan5)
|
* Example contributed by Josh Colclough (@joshcol9232) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||||
* BSD-like license that allows static linking with closed source software
|
* BSD-like license that allows static linking with closed source software
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019-2023 eggmund (@eggmund) and Ramon Santamaria (@raysan5)
|
* Copyright (c) 2019-2023 Josh Colclough (@joshcol9232) and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -37,6 +37,13 @@ const float pointsOfInterest[6][2] =
|
||||||
{ -0.70176f, -0.3842f },
|
{ -0.70176f, -0.3842f },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
const float zoomSpeed = 1.01f;
|
||||||
|
const float offsetSpeedMul = 2.0f;
|
||||||
|
|
||||||
|
const float startingZoom = 0.75f;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
@ -44,10 +51,6 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
//SetConfigFlags(FLAG_WINDOW_HIGHDPI);
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - julia sets");
|
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - julia sets");
|
||||||
|
|
||||||
// Load julia set shader
|
// Load julia set shader
|
||||||
|
|
@ -61,10 +64,8 @@ int main(void)
|
||||||
float c[2] = { pointsOfInterest[0][0], pointsOfInterest[0][1] };
|
float c[2] = { pointsOfInterest[0][0], pointsOfInterest[0][1] };
|
||||||
|
|
||||||
// Offset and zoom to draw the julia set at. (centered on screen and default size)
|
// Offset and zoom to draw the julia set at. (centered on screen and default size)
|
||||||
float offset[2] = { -(float)GetScreenWidth()/2, -(float)GetScreenHeight()/2 };
|
float offset[2] = { 0.0f, 0.0f };
|
||||||
float zoom = 1.0f;
|
float zoom = startingZoom;
|
||||||
|
|
||||||
Vector2 offsetSpeed = { 0.0f, 0.0f };
|
|
||||||
|
|
||||||
// Get variable (uniform) locations on the shader to connect with the program
|
// Get variable (uniform) locations on the shader to connect with the program
|
||||||
// NOTE: If uniform variable could not be found in the shader, function returns -1
|
// NOTE: If uniform variable could not be found in the shader, function returns -1
|
||||||
|
|
@ -72,17 +73,13 @@ int main(void)
|
||||||
int zoomLoc = GetShaderLocation(shader, "zoom");
|
int zoomLoc = GetShaderLocation(shader, "zoom");
|
||||||
int offsetLoc = GetShaderLocation(shader, "offset");
|
int offsetLoc = GetShaderLocation(shader, "offset");
|
||||||
|
|
||||||
// Tell the shader what the screen dimensions, zoom, offset and c are
|
// Upload the shader uniform values!
|
||||||
float screenDims[2] = { (float)GetScreenWidth(), (float)GetScreenHeight() };
|
|
||||||
SetShaderValue(shader, GetShaderLocation(shader, "screenDims"), screenDims, SHADER_UNIFORM_VEC2);
|
|
||||||
|
|
||||||
SetShaderValue(shader, cLoc, c, SHADER_UNIFORM_VEC2);
|
SetShaderValue(shader, cLoc, c, SHADER_UNIFORM_VEC2);
|
||||||
SetShaderValue(shader, zoomLoc, &zoom, SHADER_UNIFORM_FLOAT);
|
SetShaderValue(shader, zoomLoc, &zoom, SHADER_UNIFORM_FLOAT);
|
||||||
SetShaderValue(shader, offsetLoc, offset, SHADER_UNIFORM_VEC2);
|
SetShaderValue(shader, offsetLoc, offset, SHADER_UNIFORM_VEC2);
|
||||||
|
|
||||||
int incrementSpeed = 0; // Multiplier of speed to change c value
|
int incrementSpeed = 0; // Multiplier of speed to change c value
|
||||||
bool showControls = true; // Show controls
|
bool showControls = true; // Show controls
|
||||||
bool pause = false; // Pause animation
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -110,42 +107,50 @@ int main(void)
|
||||||
SetShaderValue(shader, cLoc, c, SHADER_UNIFORM_VEC2);
|
SetShaderValue(shader, cLoc, c, SHADER_UNIFORM_VEC2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_SPACE)) pause = !pause; // Pause animation (c change)
|
// If "R" is pressed, reset zoom and offset.
|
||||||
|
if (IsKeyPressed(KEY_R))
|
||||||
|
{
|
||||||
|
zoom = startingZoom;
|
||||||
|
offset[0] = 0.0f;
|
||||||
|
offset[1] = 0.0f;
|
||||||
|
SetShaderValue(shader, zoomLoc, &zoom, SHADER_UNIFORM_FLOAT);
|
||||||
|
SetShaderValue(shader, offsetLoc, offset, SHADER_UNIFORM_VEC2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_SPACE)) incrementSpeed = 0; // Pause animation (c change)
|
||||||
if (IsKeyPressed(KEY_F1)) showControls = !showControls; // Toggle whether or not to show controls
|
if (IsKeyPressed(KEY_F1)) showControls = !showControls; // Toggle whether or not to show controls
|
||||||
|
|
||||||
if (!pause)
|
|
||||||
{
|
|
||||||
if (IsKeyPressed(KEY_RIGHT)) incrementSpeed++;
|
if (IsKeyPressed(KEY_RIGHT)) incrementSpeed++;
|
||||||
else if (IsKeyPressed(KEY_LEFT)) incrementSpeed--;
|
else if (IsKeyPressed(KEY_LEFT)) incrementSpeed--;
|
||||||
|
|
||||||
// TODO: The idea is to zoom and move around with mouse
|
// If either left or right button is pressed, zoom in/out.
|
||||||
// Probably offset movement should be proportional to zoom level
|
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT) || IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT) || IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
|
||||||
{
|
{
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) zoom += zoom*0.003f;
|
// Change zoom. If Mouse left -> zoom in. Mouse right -> zoom out.
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) zoom -= zoom*0.003f;
|
zoom *= IsMouseButtonDown(MOUSE_BUTTON_LEFT)? zoomSpeed : 1.0f/zoomSpeed;
|
||||||
|
|
||||||
Vector2 mousePos = GetMousePosition();
|
const Vector2 mousePos = GetMousePosition();
|
||||||
|
Vector2 offsetVelocity;
|
||||||
|
// Find the velocity at which to change the camera. Take the distance of the mouse
|
||||||
|
// from the center of the screen as the direction, and adjust magnitude based on
|
||||||
|
// the current zoom.
|
||||||
|
offsetVelocity.x = (mousePos.x/(float)screenWidth - 0.5f)*offsetSpeedMul/zoom;
|
||||||
|
offsetVelocity.y = (mousePos.y/(float)screenHeight - 0.5f)*offsetSpeedMul/zoom;
|
||||||
|
|
||||||
offsetSpeed.x = mousePos.x -(float)screenWidth/2;
|
// Apply move velocity to camera
|
||||||
offsetSpeed.y = mousePos.y -(float)screenHeight/2;
|
offset[0] += GetFrameTime()*offsetVelocity.x;
|
||||||
|
offset[1] += GetFrameTime()*offsetVelocity.y;
|
||||||
// Slowly move camera to targetOffset
|
|
||||||
offset[0] += GetFrameTime()*offsetSpeed.x*0.8f;
|
|
||||||
offset[1] += GetFrameTime()*offsetSpeed.y*0.8f;
|
|
||||||
}
|
|
||||||
else offsetSpeed = (Vector2){ 0.0f, 0.0f };
|
|
||||||
|
|
||||||
|
// Update the shader uniform values!
|
||||||
SetShaderValue(shader, zoomLoc, &zoom, SHADER_UNIFORM_FLOAT);
|
SetShaderValue(shader, zoomLoc, &zoom, SHADER_UNIFORM_FLOAT);
|
||||||
SetShaderValue(shader, offsetLoc, offset, SHADER_UNIFORM_VEC2);
|
SetShaderValue(shader, offsetLoc, offset, SHADER_UNIFORM_VEC2);
|
||||||
|
}
|
||||||
|
|
||||||
// Increment c value with time
|
// Increment c value with time
|
||||||
float amount = GetFrameTime()*incrementSpeed*0.0005f;
|
const float dc = GetFrameTime()*(float)incrementSpeed*0.0005f;
|
||||||
c[0] += amount;
|
c[0] += dc;
|
||||||
c[1] += amount;
|
c[1] += dc;
|
||||||
|
|
||||||
SetShaderValue(shader, cLoc, c, SHADER_UNIFORM_VEC2);
|
SetShaderValue(shader, cLoc, c, SHADER_UNIFORM_VEC2);
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
@ -178,7 +183,8 @@ int main(void)
|
||||||
DrawText("Press KEY_F1 to toggle these controls", 10, 30, 10, RAYWHITE);
|
DrawText("Press KEY_F1 to toggle these controls", 10, 30, 10, RAYWHITE);
|
||||||
DrawText("Press KEYS [1 - 6] to change point of interest", 10, 45, 10, RAYWHITE);
|
DrawText("Press KEYS [1 - 6] to change point of interest", 10, 45, 10, RAYWHITE);
|
||||||
DrawText("Press KEY_LEFT | KEY_RIGHT to change speed", 10, 60, 10, RAYWHITE);
|
DrawText("Press KEY_LEFT | KEY_RIGHT to change speed", 10, 60, 10, RAYWHITE);
|
||||||
DrawText("Press KEY_SPACE to pause movement animation", 10, 75, 10, RAYWHITE);
|
DrawText("Press KEY_SPACE to stop movement animation", 10, 75, 10, RAYWHITE);
|
||||||
|
DrawText("Press KEY_R to recenter the camera", 10, 90, 10, RAYWHITE);
|
||||||
}
|
}
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
173
examples/shaders/shaders_lightmap.c
Normal file
|
|
@ -0,0 +1,173 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [shaders] example - lightmap
|
||||||
|
*
|
||||||
|
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||||
|
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||||
|
*
|
||||||
|
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3).
|
||||||
|
*
|
||||||
|
* Example contributed by Jussi Viitala (@nullstare) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||||
|
* BSD-like license that allows static linking with closed source software
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019-2023 Jussi Viitala (@nullstare) and Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "raymath.h"
|
||||||
|
#include "rlgl.h"
|
||||||
|
|
||||||
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
#define GLSL_VERSION 330
|
||||||
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
|
#define GLSL_VERSION 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MAP_SIZE 10
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - lightmap");
|
||||||
|
|
||||||
|
// Define the camera to look into our 3d world
|
||||||
|
Camera camera = { 0 };
|
||||||
|
camera.position = (Vector3){ 4.0f, 6.0f, 8.0f }; // Camera position
|
||||||
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||||
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
|
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||||
|
|
||||||
|
Mesh mesh = GenMeshPlane((float)MAP_SIZE, (float)MAP_SIZE, 1, 1);
|
||||||
|
|
||||||
|
// GenMeshPlane doesn't generate texcoords2 so we will upload them separately
|
||||||
|
mesh.texcoords2 = (float *)RL_MALLOC(mesh.vertexCount*2*sizeof(float));
|
||||||
|
|
||||||
|
// X // Y
|
||||||
|
mesh.texcoords2[0] = 0.0f; mesh.texcoords2[1] = 0.0f;
|
||||||
|
mesh.texcoords2[2] = 1.0f; mesh.texcoords2[3] = 0.0f;
|
||||||
|
mesh.texcoords2[4] = 0.0f; mesh.texcoords2[5] = 1.0f;
|
||||||
|
mesh.texcoords2[6] = 1.0f; mesh.texcoords2[7] = 1.0f;
|
||||||
|
|
||||||
|
// Load a new texcoords2 attributes buffer
|
||||||
|
mesh.vboId[SHADER_LOC_VERTEX_TEXCOORD02] = rlLoadVertexBuffer(mesh.texcoords2, mesh.vertexCount*2*sizeof(float), false);
|
||||||
|
rlEnableVertexArray(mesh.vaoId);
|
||||||
|
|
||||||
|
// Index 5 is for texcoords2
|
||||||
|
rlSetVertexAttribute(5, 2, RL_FLOAT, 0, 0, 0);
|
||||||
|
rlEnableVertexAttribute(5);
|
||||||
|
rlDisableVertexArray();
|
||||||
|
|
||||||
|
// Load lightmap shader
|
||||||
|
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/lightmap.vs", GLSL_VERSION),
|
||||||
|
TextFormat("resources/shaders/glsl%i/lightmap.fs", GLSL_VERSION));
|
||||||
|
|
||||||
|
Texture texture = LoadTexture("resources/cubicmap_atlas.png");
|
||||||
|
Texture light = LoadTexture("resources/spark_flame.png");
|
||||||
|
|
||||||
|
GenTextureMipmaps(&texture);
|
||||||
|
SetTextureFilter(texture, TEXTURE_FILTER_TRILINEAR);
|
||||||
|
|
||||||
|
RenderTexture lightmap = LoadRenderTexture(MAP_SIZE, MAP_SIZE);
|
||||||
|
|
||||||
|
SetTextureFilter(lightmap.texture, TEXTURE_FILTER_TRILINEAR);
|
||||||
|
|
||||||
|
Material material = LoadMaterialDefault();
|
||||||
|
material.shader = shader;
|
||||||
|
material.maps[MATERIAL_MAP_ALBEDO].texture = texture;
|
||||||
|
material.maps[MATERIAL_MAP_METALNESS].texture = lightmap.texture;
|
||||||
|
|
||||||
|
// Drawing to lightmap
|
||||||
|
BeginTextureMode(lightmap);
|
||||||
|
ClearBackground(BLACK);
|
||||||
|
|
||||||
|
BeginBlendMode(BLEND_ADDITIVE);
|
||||||
|
DrawTexturePro(
|
||||||
|
light,
|
||||||
|
(Rectangle){ 0, 0, light.width, light.height },
|
||||||
|
(Rectangle){ 0, 0, 20, 20 },
|
||||||
|
(Vector2){ 10.0, 10.0 },
|
||||||
|
0.0,
|
||||||
|
RED
|
||||||
|
);
|
||||||
|
DrawTexturePro(
|
||||||
|
light,
|
||||||
|
(Rectangle){ 0, 0, light.width, light.height },
|
||||||
|
(Rectangle){ 8, 4, 20, 20 },
|
||||||
|
(Vector2){ 10.0, 10.0 },
|
||||||
|
0.0,
|
||||||
|
BLUE
|
||||||
|
);
|
||||||
|
DrawTexturePro(
|
||||||
|
light,
|
||||||
|
(Rectangle){ 0, 0, light.width, light.height },
|
||||||
|
(Rectangle){ 8, 8, 10, 10 },
|
||||||
|
(Vector2){ 5.0, 5.0 },
|
||||||
|
0.0,
|
||||||
|
GREEN
|
||||||
|
);
|
||||||
|
BeginBlendMode(BLEND_ALPHA);
|
||||||
|
EndTextureMode();
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
BeginMode3D(camera);
|
||||||
|
DrawMesh(mesh, material, MatrixIdentity());
|
||||||
|
EndMode3D();
|
||||||
|
|
||||||
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
DrawTexturePro(
|
||||||
|
lightmap.texture,
|
||||||
|
(Rectangle){ 0, 0, -MAP_SIZE, -MAP_SIZE },
|
||||||
|
(Rectangle){ GetRenderWidth() - MAP_SIZE*8 - 10, 10, MAP_SIZE*8, MAP_SIZE*8 },
|
||||||
|
(Vector2){ 0.0, 0.0 },
|
||||||
|
0.0,
|
||||||
|
WHITE);
|
||||||
|
|
||||||
|
DrawText("lightmap", GetRenderWidth() - 66, 16 + MAP_SIZE*8, 10, GRAY);
|
||||||
|
DrawText("10x10 pixels", GetRenderWidth() - 76, 30 + MAP_SIZE*8, 10, GRAY);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
UnloadMesh(mesh); // Unload the mesh
|
||||||
|
UnloadShader(shader); // Unload shader
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
BIN
examples/shaders/shaders_lightmap.png
Normal file
|
After Width: | Height: | Size: 205 KiB |
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -> Not supported at this moment
|
#else // PLATFORM_ANDROID, PLATFORM_WEB -> Not supported at this moment
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -82,7 +82,8 @@ int main(void)
|
||||||
// Check if screen is resized
|
// Check if screen is resized
|
||||||
if (IsWindowResized())
|
if (IsWindowResized())
|
||||||
{
|
{
|
||||||
float resolution[2] = { (float)GetScreenWidth(), (float)GetScreenHeight() };
|
resolution[0] = (float)GetScreenWidth();
|
||||||
|
resolution[1] = (float)GetScreenHeight();
|
||||||
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
|
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ int main(void)
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
DrawText("Shader-based\ntexture\noutline", 10, 10, 20, GRAY);
|
DrawText("Shader-based\ntexture\noutline", 10, 10, 20, GRAY);
|
||||||
|
DrawText("Scroll mouse wheel to\nchange outline size", 10, 72, 20, GRAY);
|
||||||
DrawText(TextFormat("Outline size: %i px", (int)outlineSize), 10, 120, 20, MAROON);
|
DrawText(TextFormat("Outline size: %i px", (int)outlineSize), 10, 120, 20, MAROON);
|
||||||
|
|
||||||
DrawFPS(710, 10);
|
DrawFPS(710, 10);
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 258 KiB After Width: | Height: | Size: 258 KiB |
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ int main(void)
|
||||||
// Load shader and setup location points and values
|
// Load shader and setup location points and values
|
||||||
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/wave.fs", GLSL_VERSION));
|
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/wave.fs", GLSL_VERSION));
|
||||||
|
|
||||||
int secondsLoc = GetShaderLocation(shader, "secondes");
|
int secondsLoc = GetShaderLocation(shader, "seconds");
|
||||||
int freqXLoc = GetShaderLocation(shader, "freqX");
|
int freqXLoc = GetShaderLocation(shader, "freqX");
|
||||||
int freqYLoc = GetShaderLocation(shader, "freqY");
|
int freqYLoc = GetShaderLocation(shader, "freqY");
|
||||||
int ampXLoc = GetShaderLocation(shader, "ampX");
|
int ampXLoc = GetShaderLocation(shader, "ampX");
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ int main(void)
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - bouncing ball");
|
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - bouncing ball");
|
||||||
|
|
||||||
Vector2 ballPosition = { GetScreenWidth()/2.0f, GetScreenHeight()/2.0f };
|
Vector2 ballPosition = { GetScreenWidth()/2.0f, GetScreenHeight()/2.0f };
|
||||||
|
|
@ -61,11 +62,14 @@ int main(void)
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawCircleV(ballPosition, (float)ballRadius, MAROON);
|
DrawCircleV(ballPosition, (float)ballRadius, MAROON);
|
||||||
DrawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, GetScreenHeight() - 25, 20, LIGHTGRAY);
|
//DrawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, GetScreenHeight() - 25, 20, LIGHTGRAY);
|
||||||
|
|
||||||
// On pause, we draw a blinking message
|
// On pause, we draw a blinking message
|
||||||
if (pause && ((framesCounter/30)%2)) DrawText("PAUSED", 350, 200, 30, GRAY);
|
if (pause && ((framesCounter/30)%2)) DrawText("PAUSED", 350, 200, 30, GRAY);
|
||||||
|
|
||||||
|
DrawCircle(400.5, 300.5, 50, BLACK);
|
||||||
|
DrawCircle(528.0, 172.0, 26, BLACK);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,9 @@ int main(void)
|
||||||
DrawText(TextFormat("Collision Area: %i", (int)boxCollision.width*(int)boxCollision.height), GetScreenWidth()/2 - 100, screenUpperLimit + 10, 20, BLACK);
|
DrawText(TextFormat("Collision Area: %i", (int)boxCollision.width*(int)boxCollision.height), GetScreenWidth()/2 - 100, screenUpperLimit + 10, 20, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw help instructions
|
||||||
|
DrawText("Press SPACE to PAUSE/RESUME", 20, screenHeight - 35, 20, LIGHTGRAY);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
|
@ -35,8 +35,8 @@ int main(void)
|
||||||
float outerRadius = 180.0f;
|
float outerRadius = 180.0f;
|
||||||
float startAngle = 0.0f;
|
float startAngle = 0.0f;
|
||||||
float endAngle = 180.0f;
|
float endAngle = 180.0f;
|
||||||
int segments = 0;
|
float segments = 10.0f;
|
||||||
int minSegments = 4;
|
float minSegments = 4;
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -58,16 +58,16 @@ int main(void)
|
||||||
DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
|
DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
|
||||||
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
|
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
|
||||||
|
|
||||||
DrawCircleSector(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3f));
|
DrawCircleSector(center, outerRadius, startAngle, endAngle, (int)segments, Fade(MAROON, 0.3f));
|
||||||
DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.6f));
|
DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, (int)segments, Fade(MAROON, 0.6f));
|
||||||
|
|
||||||
// Draw GUI controls
|
// Draw GUI controls
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
startAngle = GuiSliderBar((Rectangle){ 600, 40, 120, 20}, "StartAngle", NULL, startAngle, 0, 720);
|
GuiSliderBar((Rectangle){ 600, 40, 120, 20}, "StartAngle", NULL, &startAngle, 0, 720);
|
||||||
endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", NULL, endAngle, 0, 720);
|
GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", NULL, &endAngle, 0, 720);
|
||||||
|
|
||||||
outerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20}, "Radius", NULL, outerRadius, 0, 200);
|
GuiSliderBar((Rectangle){ 600, 140, 120, 20}, "Radius", NULL, &outerRadius, 0, 200);
|
||||||
segments = (int)GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", NULL, (float)segments, 0, 100);
|
GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", NULL, &segments, 0, 100);
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
minSegments = (int)ceilf((endAngle - startAngle) / 90);
|
minSegments = (int)ceilf((endAngle - startAngle) / 90);
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@ int main(void)
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw rectangle rounded");
|
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw rectangle rounded");
|
||||||
|
|
||||||
float roundness = 0.2f;
|
float roundness = 0.2f;
|
||||||
int width = 200;
|
float width = 200.0f;
|
||||||
int height = 100;
|
float height = 100.0f;
|
||||||
int segments = 0;
|
float segments = 0.0f;
|
||||||
int lineThick = 1;
|
float lineThick = 1.0f;
|
||||||
|
|
||||||
bool drawRect = false;
|
bool drawRect = false;
|
||||||
bool drawRoundedRect = true;
|
bool drawRoundedRect = true;
|
||||||
|
|
@ -61,20 +61,20 @@ int main(void)
|
||||||
DrawRectangle(560, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
|
DrawRectangle(560, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
|
||||||
|
|
||||||
if (drawRect) DrawRectangleRec(rec, Fade(GOLD, 0.6f));
|
if (drawRect) DrawRectangleRec(rec, Fade(GOLD, 0.6f));
|
||||||
if (drawRoundedRect) DrawRectangleRounded(rec, roundness, segments, Fade(MAROON, 0.2f));
|
if (drawRoundedRect) DrawRectangleRounded(rec, roundness, (int)segments, Fade(MAROON, 0.2f));
|
||||||
if (drawRoundedLines) DrawRectangleRoundedLines(rec,roundness, segments, (float)lineThick, Fade(MAROON, 0.4f));
|
if (drawRoundedLines) DrawRectangleRoundedLines(rec, roundness, (int)segments, lineThick, Fade(MAROON, 0.4f));
|
||||||
|
|
||||||
// Draw GUI controls
|
// Draw GUI controls
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
width = (int)GuiSliderBar((Rectangle){ 640, 40, 105, 20 }, "Width", NULL, (float)width, 0, (float)GetScreenWidth() - 300);
|
GuiSliderBar((Rectangle){ 640, 40, 105, 20 }, "Width", NULL, &width, 0, (float)GetScreenWidth() - 300);
|
||||||
height = (int)GuiSliderBar((Rectangle){ 640, 70, 105, 20 }, "Height", NULL, (float)height, 0, (float)GetScreenHeight() - 50);
|
GuiSliderBar((Rectangle){ 640, 70, 105, 20 }, "Height", NULL, &height, 0, (float)GetScreenHeight() - 50);
|
||||||
roundness = GuiSliderBar((Rectangle){ 640, 140, 105, 20 }, "Roundness", NULL, roundness, 0.0f, 1.0f);
|
GuiSliderBar((Rectangle){ 640, 140, 105, 20 }, "Roundness", NULL, &roundness, 0.0f, 1.0f);
|
||||||
lineThick = (int)GuiSliderBar((Rectangle){ 640, 170, 105, 20 }, "Thickness", NULL, (float)lineThick, 0, 20);
|
GuiSliderBar((Rectangle){ 640, 170, 105, 20 }, "Thickness", NULL, &lineThick, 0, 20);
|
||||||
segments = (int)GuiSliderBar((Rectangle){ 640, 240, 105, 20}, "Segments", NULL, (float)segments, 0, 60);
|
GuiSliderBar((Rectangle){ 640, 240, 105, 20}, "Segments", NULL, &segments, 0, 60);
|
||||||
|
|
||||||
drawRoundedRect = GuiCheckBox((Rectangle){ 640, 320, 20, 20 }, "DrawRoundedRect", drawRoundedRect);
|
GuiCheckBox((Rectangle){ 640, 320, 20, 20 }, "DrawRoundedRect", &drawRoundedRect);
|
||||||
drawRoundedLines = GuiCheckBox((Rectangle){ 640, 350, 20, 20 }, "DrawRoundedLines", drawRoundedLines);
|
GuiCheckBox((Rectangle){ 640, 350, 20, 20 }, "DrawRoundedLines", &drawRoundedLines);
|
||||||
drawRect = GuiCheckBox((Rectangle){ 640, 380, 20, 20}, "DrawRect", drawRect);
|
GuiCheckBox((Rectangle){ 640, 380, 20, 20}, "DrawRect", &drawRect);
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
DrawText(TextFormat("MODE: %s", (segments >= 4)? "MANUAL" : "AUTO"), 640, 280, 10, (segments >= 4)? MAROON : DARKGRAY);
|
DrawText(TextFormat("MODE: %s", (segments >= 4)? "MANUAL" : "AUTO"), 640, 280, 10, (segments >= 4)? MAROON : DARKGRAY);
|
||||||
|
|
|
||||||