Merge remote-tracking branch 'upstream/master'
13
.github/workflows/android.yml
vendored
|
|
@ -1,8 +1,18 @@
|
||||||
name: Android
|
name: Android
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
|
workflow_dispatch:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/android.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/android.yml'
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
|
|
@ -50,6 +60,9 @@ jobs:
|
||||||
- name: Generate Artifacts
|
- name: Generate Artifacts
|
||||||
run: |
|
run: |
|
||||||
cp -v ./src/raylib.h ./build/${{ env.RELEASE_NAME }}/include
|
cp -v ./src/raylib.h ./build/${{ env.RELEASE_NAME }}/include
|
||||||
|
cp -v ./src/raymath.h ./build/${{ env.RELEASE_NAME }}/include
|
||||||
|
cp -v ./src/rlgl.h ./build/${{ env.RELEASE_NAME }}/include
|
||||||
|
cp -v ./src/extras/raygui.h ./build/${{ env.RELEASE_NAME }}/include
|
||||||
cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md
|
cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md
|
||||||
cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE
|
cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE
|
||||||
cd build
|
cd build
|
||||||
|
|
|
||||||
15
.github/workflows/cmake.yml
vendored
|
|
@ -1,8 +1,23 @@
|
||||||
name: CMakeBuilds
|
name: CMakeBuilds
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/cmake.yml'
|
||||||
|
- 'CMakeList.txt'
|
||||||
|
- 'CMakeOptions.txt'
|
||||||
|
- 'cmake/**'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/cmake.yml'
|
||||||
|
- 'CMakeList.txt'
|
||||||
|
- 'CMakeOptions.txt'
|
||||||
|
- 'cmake/**'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||||
|
|
|
||||||
18
.github/workflows/linux.yml
vendored
|
|
@ -1,8 +1,17 @@
|
||||||
name: Linux
|
name: Linux
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/linux.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/linux.yml'
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
|
|
@ -51,11 +60,11 @@ jobs:
|
||||||
cd ../../../raylib
|
cd ../../../raylib
|
||||||
# ${{ matrix.ARCH }}-linux-gnu-gcc -v
|
# ${{ matrix.ARCH }}-linux-gnu-gcc -v
|
||||||
|
|
||||||
# TODO: Support 32bit (i386) shared library building
|
# TODO: Support 32bit (i386) static/shared library building
|
||||||
- name: Build Library
|
- name: Build Library
|
||||||
run: |
|
run: |
|
||||||
cd src
|
cd src
|
||||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CFLAGS="-m32"
|
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CUSTOM_CFLAGS="-m32" -B
|
||||||
# make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
# make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
||||||
cd ..
|
cd ..
|
||||||
if: matrix.bits == 32
|
if: matrix.bits == 32
|
||||||
|
|
@ -63,7 +72,7 @@ jobs:
|
||||||
- name: Build Library
|
- name: Build Library
|
||||||
run: |
|
run: |
|
||||||
cd src
|
cd src
|
||||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib"
|
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
||||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
||||||
cd ..
|
cd ..
|
||||||
if: matrix.bits == 64
|
if: matrix.bits == 64
|
||||||
|
|
@ -71,6 +80,9 @@ jobs:
|
||||||
- name: Generate Artifacts
|
- name: Generate Artifacts
|
||||||
run: |
|
run: |
|
||||||
cp -v ./src/raylib.h ./build/${{ env.RELEASE_NAME }}/include
|
cp -v ./src/raylib.h ./build/${{ env.RELEASE_NAME }}/include
|
||||||
|
cp -v ./src/raymath.h ./build/${{ env.RELEASE_NAME }}/include
|
||||||
|
cp -v ./src/rlgl.h ./build/${{ env.RELEASE_NAME }}/include
|
||||||
|
cp -v ./src/extras/raygui.h ./build/${{ env.RELEASE_NAME }}/include
|
||||||
cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md
|
cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md
|
||||||
cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE
|
cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE
|
||||||
cd build
|
cd build
|
||||||
|
|
|
||||||
7
.github/workflows/linux_examples.yml
vendored
|
|
@ -1,11 +1,18 @@
|
||||||
name: Linux Examples
|
name: Linux Examples
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/linux_examples.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
paths:
|
paths:
|
||||||
|
- 'src/**'
|
||||||
- 'examples/**'
|
- 'examples/**'
|
||||||
|
- '.github/workflows/linux_examples.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
|
||||||
24
.github/workflows/macos.yml
vendored
|
|
@ -1,8 +1,17 @@
|
||||||
name: macOS
|
name: macOS
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/macos.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/macos.yml'
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
|
|
@ -40,14 +49,14 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
cd src
|
cd src
|
||||||
clang --version
|
clang --version
|
||||||
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION"
|
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CUSTOM_CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION" -B
|
||||||
# make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC RAYLIB_LIB_NAME=raylib_x86_64 CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION"
|
# make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC RAYLIB_LIB_NAME=raylib_x86_64 CUSTOM_CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION"
|
||||||
# make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC RAYLIB_LIB_NAME=raylib_arm64 CFLAGS="-target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION" -B
|
# make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC RAYLIB_LIB_NAME=raylib_arm64 CUSTOM_CFLAGS="-target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION" -B
|
||||||
# lipo -create -output ../build/${{ env.RELEASE_NAME }}/lib/libraylib.a libraylib_x86_64.a libraylib_arm64.a
|
# lipo -create -output ../build/${{ env.RELEASE_NAME }}/lib/libraylib.a libraylib_x86_64.a libraylib_arm64.a
|
||||||
make clean
|
make clean
|
||||||
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION"
|
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CUSTOM_CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION" -B
|
||||||
# make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED RAYLIB_LIB_NAME=raylib_x86_64 CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION" -B
|
# make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED RAYLIB_LIB_NAME=raylib_x86_64 CUSTOM_CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION" -B
|
||||||
# make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED RAYLIB_LIB_NAME=raylib_arm64 CFLAGS="-target i686-apple-macos -DGL_SILENCE_DEPRECATION" -B
|
# make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED RAYLIB_LIB_NAME=raylib_arm64 CUSTOM_CFLAGS="-target i686-apple-macos -DGL_SILENCE_DEPRECATION" -B
|
||||||
# lipo -create -output ../build/${{ env.RELEASE_NAME }}/lib/libraylib.3.1.0.dylib libraylib_x86_64.3.1.0.dylib libraylib_arm64.3.1.0.dylib
|
# lipo -create -output ../build/${{ env.RELEASE_NAME }}/lib/libraylib.3.1.0.dylib libraylib_x86_64.3.1.0.dylib libraylib_arm64.3.1.0.dylib
|
||||||
# cp -v ./libraylib_arm64.dylib ../build/${{ env.RELEASE_NAME }}/lib/libraylib.dylib
|
# cp -v ./libraylib_arm64.dylib ../build/${{ env.RELEASE_NAME }}/lib/libraylib.dylib
|
||||||
# cp -v ./libraylib_arm64.310.dylib ../build/${{ env.RELEASE_NAME }}/lib/libraylib.310.dylib
|
# cp -v ./libraylib_arm64.310.dylib ../build/${{ env.RELEASE_NAME }}/lib/libraylib.310.dylib
|
||||||
|
|
@ -56,6 +65,9 @@ jobs:
|
||||||
- name: Generate Artifacts
|
- name: Generate Artifacts
|
||||||
run: |
|
run: |
|
||||||
cp -v ./src/raylib.h ./build/${{ env.RELEASE_NAME }}/include
|
cp -v ./src/raylib.h ./build/${{ env.RELEASE_NAME }}/include
|
||||||
|
cp -v ./src/raymath.h ./build/${{ env.RELEASE_NAME }}/include
|
||||||
|
cp -v ./src/rlgl.h ./build/${{ env.RELEASE_NAME }}/include
|
||||||
|
cp -v ./src/extras/raygui.h ./build/${{ env.RELEASE_NAME }}/include
|
||||||
cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md
|
cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md
|
||||||
cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE
|
cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE
|
||||||
cd build
|
cd build
|
||||||
|
|
|
||||||
18
.github/workflows/webassembly.yml
vendored
|
|
@ -1,8 +1,17 @@
|
||||||
name: WebAssembly
|
name: WebAssembly
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/webassembly.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/webassembly.yml'
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
|
|
@ -18,9 +27,9 @@ jobs:
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@master
|
||||||
|
|
||||||
- name: Setup emsdk
|
- name: Setup emsdk
|
||||||
uses: mymindstorm/setup-emsdk@v7
|
uses: mymindstorm/setup-emsdk@v11
|
||||||
with:
|
with:
|
||||||
version: 2.0.0
|
version: 3.0.0
|
||||||
actions-cache-folder: 'emsdk-cache'
|
actions-cache-folder: 'emsdk-cache'
|
||||||
|
|
||||||
- name: Setup Release Version
|
- name: Setup Release Version
|
||||||
|
|
@ -43,12 +52,15 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
cd src
|
cd src
|
||||||
emcc -v
|
emcc -v
|
||||||
make PLATFORM=PLATFORM_WEB EMSDK_PATH="D:/a/raylib/raylib/emsdk-cache/emsdk-master" RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib"
|
make PLATFORM=PLATFORM_WEB EMSDK_PATH="D:/a/raylib/raylib/emsdk-cache/emsdk-main" RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Generate Artifacts
|
- name: Generate Artifacts
|
||||||
run: |
|
run: |
|
||||||
copy /Y .\src\raylib.h .\build\${{ env.RELEASE_NAME }}\include\raylib.h
|
copy /Y .\src\raylib.h .\build\${{ env.RELEASE_NAME }}\include\raylib.h
|
||||||
|
copy /Y .\src\raymath.h .\build\${{ env.RELEASE_NAME }}\include\raymath.h
|
||||||
|
copy /Y .\src\rlgl.h .\build\${{ env.RELEASE_NAME }}\include\rlgl.h
|
||||||
|
copy /Y .\src\extras\raygui.h .\build\${{ env.RELEASE_NAME }}\include\raygui.h
|
||||||
copy /Y .\README.md .\build\${{ env.RELEASE_NAME }}\README.md
|
copy /Y .\README.md .\build\${{ env.RELEASE_NAME }}\README.md
|
||||||
copy /Y .\LICENSE .\build\${{ env.RELEASE_NAME }}\LICENSE
|
copy /Y .\LICENSE .\build\${{ env.RELEASE_NAME }}\LICENSE
|
||||||
cd build
|
cd build
|
||||||
|
|
|
||||||
12
.github/workflows/windows.yml
vendored
|
|
@ -1,8 +1,17 @@
|
||||||
name: Windows
|
name: Windows
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/windows.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/windows.yml'
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
|
|
@ -93,6 +102,9 @@ jobs:
|
||||||
- name: Generate Artifacts
|
- name: Generate Artifacts
|
||||||
run: |
|
run: |
|
||||||
copy /Y .\src\raylib.h .\build\${{ env.RELEASE_NAME }}\include\raylib.h
|
copy /Y .\src\raylib.h .\build\${{ env.RELEASE_NAME }}\include\raylib.h
|
||||||
|
copy /Y .\src\raymath.h .\build\${{ env.RELEASE_NAME }}\include\raymath.h
|
||||||
|
copy /Y .\src\rlgl.h .\build\${{ env.RELEASE_NAME }}\include\rlgl.h
|
||||||
|
copy /Y .\src\extras\raygui.h .\build\${{ env.RELEASE_NAME }}\include\raygui.h
|
||||||
copy /Y .\README.md .\build\${{ env.RELEASE_NAME }}\README.md
|
copy /Y .\README.md .\build\${{ env.RELEASE_NAME }}\README.md
|
||||||
copy /Y .\LICENSE .\build\${{ env.RELEASE_NAME }}\LICENSE
|
copy /Y .\LICENSE .\build\${{ env.RELEASE_NAME }}\LICENSE
|
||||||
cd build
|
cd build
|
||||||
|
|
|
||||||
7
.github/workflows/windows_examples.yml
vendored
|
|
@ -1,11 +1,18 @@
|
||||||
name: Windows Examples
|
name: Windows Examples
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'examples/**'
|
||||||
|
- '.github/workflows/windows_examples.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
paths:
|
paths:
|
||||||
|
- 'src/**'
|
||||||
- 'examples/**'
|
- 'examples/**'
|
||||||
|
- '.github/workflows/windows_examples.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
|
||||||
11
.gitignore
vendored
|
|
@ -45,6 +45,7 @@ ipch/
|
||||||
*.db
|
*.db
|
||||||
*.opendb
|
*.opendb
|
||||||
packages/
|
packages/
|
||||||
|
!examples/models/resources/models/obj/
|
||||||
|
|
||||||
# Ignore compiled binaries
|
# Ignore compiled binaries
|
||||||
*.o
|
*.o
|
||||||
|
|
@ -101,3 +102,13 @@ build
|
||||||
GPATH
|
GPATH
|
||||||
GRTAGS
|
GRTAGS
|
||||||
GTAGS
|
GTAGS
|
||||||
|
|
||||||
|
# Zig programming language
|
||||||
|
zig-cache/
|
||||||
|
zig-out/
|
||||||
|
build/
|
||||||
|
build-*/
|
||||||
|
docgen_tmp/
|
||||||
|
|
||||||
|
# Parser stuff
|
||||||
|
parser/raylib_parser
|
||||||
|
|
|
||||||
111
BINDINGS.md
|
|
@ -1,111 +1,128 @@
|
||||||
# raylib bindings and wrappers
|
# raylib bindings and wrappers
|
||||||
|
|
||||||
Some people ported raylib to other languages in form of bindings or wrappers to the library. Here it is alist with all the ports available. Feel free to send a PR if you know of any binding/wrapper not in this list.
|
Some people ported raylib to other languages in form of bindings or wrappers to the library. Here is a list with all the ports available. Feel free to send a PR if you know of any binding/wrapper not in this list.
|
||||||
|
|
||||||
### Language Bindings
|
### Language Bindings
|
||||||
|
|
||||||
|
| name | raylib version | language | license | repo |
|
||||||
|
|:------------------:|:---------------:|:---------:|:----------:|-----------------------------------------------------------|
|
||||||
|
| raylib | **4.0** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib | https://github.com/raysan5/raylib |
|
||||||
|
| Raylib-cs | **4.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib | https://github.com/ChrisDill/Raylib-cs |
|
||||||
|
| Raylib-CsLo | **4.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | https://github.com/NotNotTech/Raylib-CsLo |
|
||||||
|
| raylib-boo | 3.7 | [Boo](http://boo-language.github.io/)| MIT | https://github.com/Rabios/raylib-boo |
|
||||||
|
| bindbc-raylib3 | **4.0** | [D](https://dlang.org/) | BSL-1.0 | https://github.com/o3o/bindbc-raylib3 |
|
||||||
|
| dray | **4.0** | [D](https://dlang.org/) | Apache-2.0 | https://github.com/xdrie/dray |
|
||||||
|
| raylib-d | **4.0** | [D](https://dlang.org/) | Zlib | https://github.com/schveiguy/raylib-d |
|
||||||
|
| raylib-go | **4.0** | [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-rs | 3.5 | [Rust](https://www.rust-lang.org/) | Zlib | https://github.com/deltaphc/raylib-rs |
|
||||||
|
| raylib-lua | **4.0** | [Lua](http://www.lua.org/) | ISC | https://github.com/TSnake41/raylib-lua |
|
||||||
|
| raylua | **4.0** | [Lua](http://www.lua.org/) | MIT | https://github.com/Rabios/raylua |
|
||||||
|
| nelua-raylib | 4.0 | [nelua](https://nelua.io/) | MIT | https://github.com/AKDev21/nelua-raylib |
|
||||||
|
| NimraylibNow! | 4.0 | [Nim](https://nim-lang.org/) | MIT | https://github.com/greenfork/nimraylib_now |
|
||||||
|
| raylib-Forever | auto | [Nim](https://nim-lang.org/) | ? | https://github.com/Guevara-chan/Raylib-Forever |
|
||||||
|
| Ray4Laz | **4.0** | [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language))| Zlib | https://github.com/GuvaCode/Ray4Laz |
|
||||||
|
| pyraylib | 3.7 | [Python](https://www.python.org/) | Zlib | https://github.com/Ho011/pyraylib |
|
||||||
|
| raylib-python-cffi | **4.0** | [Python](https://www.python.org/) | EPL-2.0 | https://github.com/electronstudio/raylib-python-cffi |
|
||||||
|
| jaylib | **4.0** | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | GPLv3 | 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 |
|
||||||
|
| node-raylib | 3.5 | [Node.js](https://nodejs.org/en/) | Zlib | https://github.com/RobLoach/node-raylib |
|
||||||
|
| raylib-php | 3.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-factor | 3.5 | [Factor](https://factorcode.org/) | MIT | https://github.com/ArnautDaniel/raylib-factor |
|
||||||
|
| gforth-raylib | 3.5 | [Gforth](https://gforth.org/) | MIT | https://github.com/ArnautDaniel/gforth-raylib |
|
||||||
|
| hxRaylib | 4.0 | [Haxe](https://haxe.org/) | Zlib | https://github.com/ForeignSasquatch/hxRaylib |
|
||||||
|
| raylib-wren | **4.0** | [Wren](http://wren.io/) | ISC | https://github.com/TSnake41/raylib-wren |
|
||||||
|
| raylib_odin_bindings | 4.0-dev | [Odin](https://odin-lang.org/) | MIT | https://github.com/Deathbat2190/raylib_odin_bindings |
|
||||||
|
| raylib-odin | **4.0** | [Odin](https://odin-lang.org/) | BSD-3Clause | https://github.com/odin-lang/Odin/tree/master/vendor/raylib |
|
||||||
|
| raylib.v | **4.0** | [V](https://vlang.io/) | Zlib | https://github.com/irishgreencitrus/raylib.v |
|
||||||
|
| raylib-ocaml | **4.0** | [OCaml](https://ocaml.org/) | MIT | https://github.com/tjammer/raylib-ocaml |
|
||||||
|
| raylib-swift | **4.0** | [Swift](https://swift.org/) | MIT | https://github.com/STREGAsGate/Raylib |
|
||||||
|
| hb-raylib | 3.5 | [Harbour](https://harbour.github.io) | MIT | https://github.com/MarcosLeonardoMendezGerencir/hb-raylib |
|
||||||
|
| Relib | 3.5 | [ReCT](https://github.com/RedCubeDev-ByteSpace/ReCT) | ? | https://github.com/RedCubeDev-ByteSpace/Relib |
|
||||||
|
| rayex | 3.7 | [elixir](https://elixir-lang.org/) | Apache-2.0 | https://github.com/shiryel/rayex |
|
||||||
|
| kaylib | 3.7 | [Kotlin/native](https://kotlinlang.org) | ? | https://github.com/electronstudio/kaylib |
|
||||||
|
| dlang_raylib | 3.7 | [D](https://dlang.org) | ? |https://github.com/rc-05/dlang_raylib |
|
||||||
|
| raylib-freebasic | **4.0** | [FreeBASIC](https://www.freebasic.net/) | MIT | https://github.com/WIITD/raylib-freebasic |
|
||||||
|
| raylib-cr | **4.0** | [Crystal](https://crystal-lang.org/) | Apache-2.0 | https://github.com/sol-vin/raylib-cr |
|
||||||
|
| dart-raylib | **4.0** | [Dart](https://dart.dev/) | MIT | https://gitlab.com/wolfenrain/dart-raylib |
|
||||||
|
| raylib-scopes | auto | [Scopes](http://scopes.rocks) | MIT | https://github.com/salotz/raylib-scopes |
|
||||||
|
| raylib-smallBasic | 4.1-dev | [SmallBASIC](https://github.com/smallbasic/SmallBASIC) | GPLv3 | https://github.com/smallbasic/smallbasic.plugins/tree/master/raylib |
|
||||||
|
|
||||||
|
### Utility Wrapers
|
||||||
|
These are utility wrappers for specific languages, they are not required to use raylib in the language but may adapt the raylib API to be more inline with the language's pardigm.
|
||||||
|
| name | raylib version | language | license | repo |
|
||||||
|
|:------------------:|:-------------: | :--------:|:-------:|:-------------------------------------------------------------|
|
||||||
|
| raylib-cpp | **4.0** | [C++](https://en.wikipedia.org/wiki/C%2B%2B) | Zlib | https://github.com/robloach/raylib-cpp |
|
||||||
|
|
||||||
|
### Older or Unmaintained Language Bindings
|
||||||
|
These are older raylib bindings that are more than 2 versions old or have not been maintained.
|
||||||
| name | raylib version | language | repo |
|
| name | raylib version | language | repo |
|
||||||
|:------------------:|:-------------: | :--------:|----------------------------------------------------------------------|
|
|:------------------:|:-------------: | :--------:|----------------------------------------------------------------------|
|
||||||
| raylib | **3.7** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | https://github.com/raysan5/raylib |
|
|
||||||
| Raylib-cs | 3.7 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | https://github.com/ChrisDill/Raylib-cs |
|
|
||||||
| raylib-cppsharp | 2.5 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | https://github.com/phxvyper/raylib-cppsharp |
|
| raylib-cppsharp | 2.5 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | https://github.com/phxvyper/raylib-cppsharp |
|
||||||
| raylib-boo | 3.7 | [Boo](http://boo-language.github.io/) | https://github.com/Rabios/raylib-boo |
|
|
||||||
| RaylibFS | 2.5 | [F#](https://fsharp.org/) | https://github.com/dallinbeutler/RaylibFS |
|
| RaylibFS | 2.5 | [F#](https://fsharp.org/) | https://github.com/dallinbeutler/RaylibFS |
|
||||||
| raylib_d | 2.5 | [D](https://dlang.org/) | https://github.com/Sepheus/raylib_d |
|
| raylib_d | 2.5 | [D](https://dlang.org/) | https://github.com/Sepheus/raylib_d |
|
||||||
| raylib-d | 3.0 | [D](https://dlang.org/) | https://github.com/onroundit/raylib-d |
|
|
||||||
| bindbc-raylib | 3.0 | [D](https://dlang.org/) | https://github.com/o3o/bindbc-raylib |
|
| bindbc-raylib | 3.0 | [D](https://dlang.org/) | https://github.com/o3o/bindbc-raylib |
|
||||||
| dray | 3.5 | [D](https://dlang.org/) | https://github.com/xdrie/dray |
|
| go-raylib | 3.5 | [Go](https://golang.org/) | https://github.com/chunqian/go-raylib |
|
||||||
| raylib-go | 3.8-dev | [Go](https://golang.org/) | https://github.com/gen2brain/raylib-go |
|
|
||||||
| raylib-goplus | 2.6-dev | [Go](https://golang.org/) | https://github.com/Lachee/raylib-goplus |
|
| raylib-goplus | 2.6-dev | [Go](https://golang.org/) | https://github.com/Lachee/raylib-goplus |
|
||||||
| ray-go | 2.6-dev | [Go](https://golang.org/) | https://github.com/hecate-tech/ray-go |
|
| ray-go | 2.6-dev | [Go](https://golang.org/) | https://github.com/hecate-tech/ray-go |
|
||||||
| go-raylib | 3.5 | [Go](https://golang.org/) | https://github.com/chunqian/go-raylib |
|
|
||||||
| raylib-rs | 3.5 | [Rust](https://www.rust-lang.org/) | https://github.com/deltaphc/raylib-rs |
|
|
||||||
| raylib-lua | 1.7 | [Lua](http://www.lua.org/) | https://github.com/raysan5/raylib-lua |
|
|
||||||
| raylib-lua-ffi | 2.0 | [Lua](http://www.lua.org/) | https://github.com/raysan5/raylib/issues/693 |
|
|
||||||
| raylib-lua-sol | 2.5 | [Lua](http://www.lua.org/) | https://github.com/RobLoach/raylib-lua-sol |
|
|
||||||
| raylib-lua | 3.7 | [Lua](http://www.lua.org/) | https://github.com/TSnake41/raylib-lua |
|
|
||||||
| raylib-luamore | 3.0 | [Lua](http://www.lua.org/) | https://github.com/HDPLocust/raylib-luamore |
|
| raylib-luamore | 3.0 | [Lua](http://www.lua.org/) | https://github.com/HDPLocust/raylib-luamore |
|
||||||
| raylua | 3.7 | [Lua](http://www.lua.org/) | https://github.com/Rabios/raylua |
|
|
||||||
| LuaJIT-Raylib | 2.6 | [Lua](http://www.lua.org/) | https://github.com/Bambofy/LuaJIT-Raylib |
|
| LuaJIT-Raylib | 2.6 | [Lua](http://www.lua.org/) | https://github.com/Bambofy/LuaJIT-Raylib |
|
||||||
| raylib-nelua | 3.7 | [nelua](https://nelua.io/) | https://github.com/edubart/nelua-decl/tree/main/libs/raylib |
|
| raylib-lua-sol | 2.5 | [Lua](http://www.lua.org/) | https://github.com/RobLoach/raylib-lua-sol |
|
||||||
|
| raylib-lua-ffi | 2.0 | [Lua](http://www.lua.org/) | https://github.com/raysan5/raylib/issues/693 |
|
||||||
|
| raylib-lua | 1.7 | [Lua](http://www.lua.org/) | https://github.com/raysan5/raylib-lua |
|
||||||
| raylib-nelua | 3.0 | [Nelua](https://nelua.io/) | https://github.com/Andre-LA/raylib-nelua |
|
| raylib-nelua | 3.0 | [Nelua](https://nelua.io/) | https://github.com/Andre-LA/raylib-nelua |
|
||||||
| raylib-Nim | 1.7 | [Nim](https://nim-lang.org/) | https://gitlab.com/define-private-public/raylib-Nim |
|
|
||||||
| raylib-nim | 2.0 | [Nim](https://nim-lang.org/) | https://github.com/Skrylar/raylib-nim |
|
| raylib-nim | 2.0 | [Nim](https://nim-lang.org/) | https://github.com/Skrylar/raylib-nim |
|
||||||
| raylib-Forever | 3.1-dev | [Nim](https://nim-lang.org/) | https://github.com/Guevara-chan/Raylib-Forever |
|
| raylib-Nim | 1.7 | [Nim](https://nim-lang.org/) | https://gitlab.com/define-private-public/raylib-Nim |
|
||||||
| nim-raylib | 3.1-dev | [Nim](https://nim-lang.org/) | https://github.com/tomc1998/nim-raylib |
|
| nim-raylib | 3.1-dev | [Nim](https://nim-lang.org/) | https://github.com/tomc1998/nim-raylib |
|
||||||
| NimraylibNow! | 3.7 | [Nim](https://nim-lang.org/) | https://github.com/greenfork/nimraylib_now |
|
|
||||||
| raylib-haskell | 2.0 | [Haskell](https://www.haskell.org/) | https://github.com/DevJac/raylib-haskell |
|
| raylib-haskell | 2.0 | [Haskell](https://www.haskell.org/) | https://github.com/DevJac/raylib-haskell |
|
||||||
| raylib-cr | 2.5-dev | [Crystal](https://crystal-lang.org/) | https://github.com/AregevDev/raylib-cr |
|
| raylib-cr | 2.5-dev | [Crystal](https://crystal-lang.org/) | https://github.com/AregevDev/raylib-cr |
|
||||||
| cray | 1.8 | [Crystal](https://crystal-lang.org/) | https://gitlab.com/Zatherz/cray |
|
|
||||||
| raylib.cr | 2.0 | [Crystal](https://crystal-lang.org/) | https://github.com/sam0x17/raylib.cr |
|
| raylib.cr | 2.0 | [Crystal](https://crystal-lang.org/) | https://github.com/sam0x17/raylib.cr |
|
||||||
| raylib-pascal | 2.0 | [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)) | https://github.com/drezgames/raylib-pascal |
|
| cray | 1.8 | [Crystal](https://crystal-lang.org/) | https://gitlab.com/Zatherz/cray |
|
||||||
| raylib-pas | 3.0 | [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)) | https://github.com/tazdij/raylib-pas |
|
| raylib-pas | 3.0 | [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)) | https://github.com/tazdij/raylib-pas |
|
||||||
| Ray4Laz | 3.7 | [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)) | https://github.com/GuvaCode/Ray4Laz |
|
| raylib-pascal | 2.0 | [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)) | https://github.com/drezgames/raylib-pascal |
|
||||||
| Graphics-Raylib | 1.4 | [Perl](https://www.perl.org/) | https://github.com/athreef/Graphics-Raylib |
|
| Graphics-Raylib | 1.4 | [Perl](https://www.perl.org/) | https://github.com/athreef/Graphics-Raylib |
|
||||||
| raylib-ruby-ffi | 2.0 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/D3nX/raylib-ruby-ffi |
|
|
||||||
| raylib-ruby | 2.6 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/a0/raylib-ruby |
|
| raylib-ruby | 2.6 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/a0/raylib-ruby |
|
||||||
|
| raylib-ruby-ffi | 2.0 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/D3nX/raylib-ruby-ffi |
|
||||||
| raylib-mruby | 2.5-dev | [mruby](https://github.com/mruby/mruby) | https://github.com/lihaochen910/raylib-mruby |
|
| raylib-mruby | 2.5-dev | [mruby](https://github.com/mruby/mruby) | https://github.com/lihaochen910/raylib-mruby |
|
||||||
| pyraylib | 3.7 | [Python](https://www.python.org/) | https://github.com/Ho011/pyraylib |
|
|
||||||
| raylib-py | 2.0 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py |
|
|
||||||
| raylib-python-cffi | 3.7 | [Python](https://www.python.org/) | https://github.com/electronstudio/raylib-python-cffi |
|
|
||||||
| raylib-py-ctbg | 2.6 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py-ctbg |
|
| raylib-py-ctbg | 2.6 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py-ctbg |
|
||||||
| jaylib | 3.7 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/electronstudio/jaylib/ |
|
| raylib-py | 2.0 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py |
|
||||||
| raylib-java | 2.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/XoanaIO/raylib-java |
|
| raylib-java | 2.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/XoanaIO/raylib-java |
|
||||||
| raylib-j | 3.5 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/CreedVI/Raylib-J |
|
|
||||||
| clj-raylib | 3.0 | [Clojure](https://clojure.org/) | https://github.com/lsevero/clj-raylib |
|
| clj-raylib | 3.0 | [Clojure](https://clojure.org/) | https://github.com/lsevero/clj-raylib |
|
||||||
| node-raylib | 3.5 | [Node.js](https://nodejs.org/en/) | https://github.com/RobLoach/node-raylib |
|
|
||||||
| QuickJS-raylib | 3.0 | [QuickJS](https://bellard.org/quickjs/) | https://github.com/sntg-p/QuickJS-raylib |
|
| QuickJS-raylib | 3.0 | [QuickJS](https://bellard.org/quickjs/) | https://github.com/sntg-p/QuickJS-raylib |
|
||||||
| raylib-duktape | 2.6 | [JavaScript (Duktape)](https://en.wikipedia.org/wiki/JavaScript) | https://github.com/RobLoach/raylib-duktape |
|
| raylib-duktape | 2.6 | [JavaScript (Duktape)](https://en.wikipedia.org/wiki/JavaScript) | https://github.com/RobLoach/raylib-duktape |
|
||||||
| raylib-v7 | 3.5 | [JavaScript (v7)](https://en.wikipedia.org/wiki/JavaScript) | https://github.com/Rabios/raylib-v7 |
|
| raylib-v7 | 3.5 | [JavaScript (v7)](https://en.wikipedia.org/wiki/JavaScript) | https://github.com/Rabios/raylib-v7 |
|
||||||
| raylib-chaiscript | 2.6 | [ChaiScript](http://chaiscript.com/) | https://github.com/RobLoach/raylib-chaiscript |
|
| raylib-chaiscript | 2.6 | [ChaiScript](http://chaiscript.com/) | https://github.com/RobLoach/raylib-chaiscript |
|
||||||
| raylib-squirrel | 2.5 | [Squirrel](http://www.squirrel-lang.org/) | https://github.com/RobLoach/raylib-squirrel |
|
| raylib-squirrel | 2.5 | [Squirrel](http://www.squirrel-lang.org/) | https://github.com/RobLoach/raylib-squirrel |
|
||||||
| racket-raylib-2d | 2.5 | [Racket](https://racket-lang.org/) | https://github.com/arvyy/racket-raylib-2d |
|
| racket-raylib-2d | 2.5 | [Racket](https://racket-lang.org/) | https://github.com/arvyy/racket-raylib-2d |
|
||||||
| raylib-php | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | https://github.com/joseph-montanez/raylib-php |
|
|
||||||
| raylib-php-ffi | 2.4-dev | [PHP](https://en.wikipedia.org/wiki/PHP) | https://github.com/oraoto/raylib-php-ffi |
|
| raylib-php-ffi | 2.4-dev | [PHP](https://en.wikipedia.org/wiki/PHP) | https://github.com/oraoto/raylib-php-ffi |
|
||||||
| raylib-phpcpp | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | https://github.com/oraoto/raylib-phpcpp |
|
|
||||||
| raylib-factor | 3.5 | [Factor](https://factorcode.org/) | https://github.com/ArnautDaniel/raylib-factor |
|
|
||||||
| gforth-raylib | 3.5 | [Gforth](https://gforth.org/) | https://github.com/ArnautDaniel/gforth-raylib |
|
|
||||||
| raylib-haxe | 2.4 | [Haxe](https://haxe.org/) | https://github.com/ibilon/raylib-haxe |
|
| raylib-haxe | 2.4 | [Haxe](https://haxe.org/) | https://github.com/ibilon/raylib-haxe |
|
||||||
| hxRaylib | 3.7 | [Haxe](https://haxe.org/) | https://github.com/ForeignSasquatch/hxRaylib |
|
|
||||||
| ringraylib | 2.6 | [Ring](http://ring-lang.sourceforge.net/) | https://github.com/ringpackages/ringraylib |
|
| ringraylib | 2.6 | [Ring](http://ring-lang.sourceforge.net/) | https://github.com/ringpackages/ringraylib |
|
||||||
| cl-raylib | 3.0 | [Common Lisp](https://common-lisp.net/) | https://github.com/longlene/cl-raylib |
|
| cl-raylib | 3.0 | [Common Lisp](https://common-lisp.net/) | https://github.com/longlene/cl-raylib |
|
||||||
| raylib-scm | 2.5 | [Chicken Scheme](https://www.call-cc.org/) | https://github.com/yashrk/raylib-scm |
|
| raylib-scm | 2.5 | [Chicken Scheme](https://www.call-cc.org/) | https://github.com/yashrk/raylib-scm |
|
||||||
| raylib-chibi | 2.5 | [Chibi-Scheme](https://github.com/ashinn/chibi-scheme) | https://github.com/VincentToups/raylib-chibi |
|
| raylib-chibi | 2.5 | [Chibi-Scheme](https://github.com/ashinn/chibi-scheme) | https://github.com/VincentToups/raylib-chibi |
|
||||||
| raylib-gambit-scheme | 3.1-dev | [Gambit Scheme](https://github.com/gambit/gambit) | https://github.com/georgjz/raylib-gambit-scheme |
|
| raylib-gambit-scheme | 3.1-dev | [Gambit Scheme](https://github.com/gambit/gambit) | https://github.com/georgjz/raylib-gambit-scheme |
|
||||||
| Euraylib | 3.0 | [Euphoria](https://openeuphoria.org/) | https://github.com/gAndy50/Euraylib |
|
| Euraylib | 3.0 | [Euphoria](https://openeuphoria.org/) | https://github.com/gAndy50/Euraylib |
|
||||||
| raylib-wren | 3.7 | [Wren](http://wren.io/) | https://github.com/TSnake41/raylib-wren |
|
|
||||||
| raylib-odin | 3.0 | [Odin](https://odin-lang.org/) | https://github.com/kevinw/raylib-odin |
|
| raylib-odin | 3.0 | [Odin](https://odin-lang.org/) | https://github.com/kevinw/raylib-odin |
|
||||||
| raylib_odin_bindings | 3.8+ | [Odin](https://odin-lang.org/) | https://github.com/Deathbat2190/raylib_odin_bindings |
|
| vraylib | 3.5 | [V](https://vlang.io/) | https://github.com/waotzi/vraylib |
|
||||||
| raylib-zig | 3.0 | [Zig](https://ziglang.org/) | https://github.com/Not-Nik/raylib-zig |
|
| raylib-zig | 3.0 | [Zig](https://ziglang.org/) | https://github.com/Not-Nik/raylib-zig |
|
||||||
| raylib-jai | 3.1-dev | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | https://github.com/kevinw/raylib-jai |
|
| raylib-jai | 3.1-dev | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | https://github.com/kevinw/raylib-jai |
|
||||||
| ray.zig | 2.5 | [Zig](https://ziglang.org/) | https://github.com/BitPuffin/zig-raylib-experiments |
|
| ray.zig | 2.5 | [Zig](https://ziglang.org/) | https://github.com/BitPuffin/zig-raylib-experiments |
|
||||||
| raylib-Ada | 3.0 | [Ada](https://www.adacore.com/about-ada) | https://github.com/mimo/raylib-Ada |
|
| raylib-Ada | 3.0 | [Ada](https://www.adacore.com/about-ada) | https://github.com/mimo/raylib-Ada |
|
||||||
| jaylib | 3.0 | [Janet](https://janet-lang.org/) | https://github.com/janet-lang/jaylib |
|
| jaylib | 3.0 | [Janet](https://janet-lang.org/) | https://github.com/janet-lang/jaylib |
|
||||||
| raykit | ? | [Kit](https://www.kitlang.org/) | https://github.com/Gamerfiend/raykit |
|
| raykit | ? | [Kit](https://www.kitlang.org/) | https://github.com/Gamerfiend/raykit |
|
||||||
| vraylib | 3.5 | [V](https://vlang.io/) | https://github.com/waotzi/vraylib |
|
|
||||||
| raylib.v | 3.7 | [V](https://vlang.io/) | https://github.com/irishgreencitrus/raylib.v |
|
|
||||||
| ray.mod | 3.0 | [BlitzMax](https://blitzmax.org/) | https://github.com/bmx-ng/ray.mod |
|
| ray.mod | 3.0 | [BlitzMax](https://blitzmax.org/) | https://github.com/bmx-ng/ray.mod |
|
||||||
| raylib-ocaml | 3.7 | [OCaml](https://ocaml.org/) | https://github.com/tjammer/raylib-ocaml |
|
|
||||||
| raylib-mosaic | 3.0 | [Mosaic](https://github.com/sal55/langs/tree/master/Mosaic) | https://github.com/pluckyporcupine/raylib-mosaic |
|
| raylib-mosaic | 3.0 | [Mosaic](https://github.com/sal55/langs/tree/master/Mosaic) | https://github.com/pluckyporcupine/raylib-mosaic |
|
||||||
| raylib-xdpw | 2.6 | [XD Pascal](https://github.com/vtereshkov/xdpw) | https://github.com/vtereshkov/raylib-xdpw |
|
| raylib-xdpw | 2.6 | [XD Pascal](https://github.com/vtereshkov/xdpw) | https://github.com/vtereshkov/raylib-xdpw |
|
||||||
| raylib-carp | 3.0 | [Carp](https://github.com/carp-lang/Carp) | https://github.com/pluckyporcupine/raylib-carp |
|
| raylib-carp | 3.0 | [Carp](https://github.com/carp-lang/Carp) | https://github.com/pluckyporcupine/raylib-carp |
|
||||||
| raylib-fb | 3.0 | [FreeBasic](https://www.freebasic.net/) | https://github.com/IchMagBier/raylib-fb |
|
| raylib-fb | 3.0 | [FreeBasic](https://www.freebasic.net/) | https://github.com/IchMagBier/raylib-fb |
|
||||||
| raylib-purebasic | 3.0 | [PureBasic](https://www.purebasic.com/) | https://github.com/D-a-n-i-l-o/raylib-purebasic |
|
| raylib-purebasic | 3.0 | [PureBasic](https://www.purebasic.com/) | https://github.com/D-a-n-i-l-o/raylib-purebasic |
|
||||||
| raylib-smallBasic | 3.1-dev | [SmallBASIC](https://github.com/smallbasic/SmallBASIC) | https://github.com/smallbasic/smallbasic.plugins/tree/master/raylib |
|
|
||||||
| raylib-ats2 | 3.0 | [ATS2](http://www.ats-lang.org/) | https://github.com/mephistopheles-8/raylib-ats2 |
|
| raylib-ats2 | 3.0 | [ATS2](http://www.ats-lang.org/) | https://github.com/mephistopheles-8/raylib-ats2 |
|
||||||
| raylib-beef | 3.0 | [Beef](https://www.beeflang.org/) | https://github.com/M0n7y5/raylib-beef |
|
| raylib-beef | 3.0 | [Beef](https://www.beeflang.org/) | https://github.com/M0n7y5/raylib-beef |
|
||||||
| raylib-swift | 3.5 | [Swift](https://swift.org/) | https://github.com/conifer-dev/raylib-swift |
|
|
||||||
| raylib-never | 3.0 | [Never](https://github.com/never-lang/never) | https://github.com/never-lang/raylib-never |
|
| raylib-never | 3.0 | [Never](https://github.com/never-lang/never) | https://github.com/never-lang/raylib-never |
|
||||||
| hb-raylib | 3.5 | [Harbour](https://harbour.github.io) | https://github.com/MarcosLeonardoMendezGerencir/hb-raylib |
|
|
||||||
| Relib | 3.5 | [ReCT](https://github.com/RedCubeDev-ByteSpace/ReCT) | https://github.com/RedCubeDev-ByteSpace/Relib |
|
|
||||||
| rayex | 3.7 | [elixir](https://elixir-lang.org/) | https://github.com/shiryel/rayex |
|
|
||||||
| raylib.cbl | 2.0 | [COBOL](https://en.wikipedia.org/wiki/COBOL) | *[code examples](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)* |
|
| raylib.cbl | 2.0 | [COBOL](https://en.wikipedia.org/wiki/COBOL) | *[code examples](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)* |
|
||||||
|
|
||||||
### Utility Wrapers
|
|
||||||
|
|
||||||
| name | raylib version | language | repo |
|
|
||||||
|:------------------:|:-------------: | :--------:|----------------------------------------------------------------------|
|
|
||||||
| raylib-cpp | 3.7 | [C++](https://en.wikipedia.org/wiki/C%2B%2B) | https://github.com/robloach/raylib-cpp |
|
|
||||||
|
|
||||||
Missing some language or wrapper? Feel free to create a new one! :)
|
Missing some language or wrapper? Feel free to create a new one! :)
|
||||||
|
|
||||||
|
|
|
||||||
145
CHANGELOG
|
|
@ -1,18 +1,151 @@
|
||||||
changelog
|
changelog
|
||||||
---------
|
---------
|
||||||
|
|
||||||
Current Release: raylib 3.7.0 (26 April 2021)
|
Current Release: raylib 4.0.0 (05 November 2021)
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
Release: raylib 4.0 (November? 2021)
|
Release: raylib 4.0 - 8th Anniversary Edition (05 November 2021)
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
KEY CHANGES:
|
KEY CHANGES:
|
||||||
-
|
- Naming consistency and coherency: Complete review of the library: sintax, naming, comments, decriptions, logs...
|
||||||
-
|
- Event Automation System: Support for input events recording and automatic re-playing, useful for automated testing and more!
|
||||||
-
|
- Custom game-loop control: Intended for advance users that want to control the events polling and the timming mechanisms
|
||||||
|
- rlgl 4.0: Completely decoupling from platform layer and raylib, intended for standalone usage as single-file header-only
|
||||||
|
- raymath 1.5: Complete review following new conventions, to make it more portable and self-contained
|
||||||
|
- raygui 3.0: Complete review and official new release, more portable and self-contained, intended for tools development
|
||||||
|
- raylib_parser: New tool to parse raylib.h and extract all required info into custom output formats (TXT, XML, JSON...)
|
||||||
|
- Zig and Odin official support
|
||||||
|
|
||||||
Detailed changes:
|
Detailed changes:
|
||||||
|
[core] ADDED: Support canvas resizing on web (#1840) by @skylersaleh
|
||||||
|
[core] ADDED: GetMouseDelta() (#1832) by @adricoin2010
|
||||||
|
[core] ADDED: Support additional mouse buttons (#1753) by @lambertwang
|
||||||
|
[core] ADDED: SetRandomSeed() (#1994) by @TommiSinivuo
|
||||||
|
[core] ADDED: GetTouchPointId() #1972
|
||||||
|
[core] ADDED: EncodeDataBase64() and DecodeDataBase64()
|
||||||
|
[core] REMOVED: PLATFORM_UWP, difficult to maintain
|
||||||
|
[core] REMOVED: IsGamepadName()
|
||||||
|
[core] RENAMED: SwapBuffers() to SwapScreenBuffer()
|
||||||
|
[core] RENAMED: Wait() to WaitTime()
|
||||||
|
[core] RENAMED: RayHitInfo to RayCollision (#1781)
|
||||||
|
[core] RENAMED: GetRayCollisionGround() to GetRayCollisionQuad() (#1781)
|
||||||
|
[core] REVIEWED: Support mouse wheel on x-axis (#1948)
|
||||||
|
[core] REVIEWED: DisableCursor() on web by registering an empty mouse click event function in emscripten (#1900) by @grenappels
|
||||||
|
[core] REVIEWED: LoadShader() and default locations and descriptions
|
||||||
|
[core] REVIEWED: LoadShaderFromMemory() (#1851) by @Ruminant
|
||||||
|
[core] REVIEWED: WaitTime(), avoid global variables dependency to make the function is self-contained (#1841)
|
||||||
|
[core] REVIEWED: SetWindowSize() to work on web (#1847) by @nikki93
|
||||||
|
[core] REVIEWED: Raspberry RPI/DRM keyboard blocking render loop (#1879) @luizpestana
|
||||||
|
[core] REVIEWED: Android multi-touch (#1869) by @humbe
|
||||||
|
[core] REVIEWED: Implemented GetGamepadName() for emscripten by @nbarkhina
|
||||||
|
[core] REVIEWED: HighDPI support (#1987) by @ArnaudValensi
|
||||||
|
[core] REVIEWED: KeyCallback(), register keys independently of the actions
|
||||||
|
[rlgl] ADDED: GRAPHIC_API_OPENGL_43
|
||||||
|
[rlgl] ADDED: rlUpdateVertexBufferElements() (#1915)
|
||||||
|
[rlgl] ADDED: rlActiveDrawBuffers() (#1911)
|
||||||
|
[rlgl] ADDED: rlEnableColorBlend()/rlDisableColorBlend()
|
||||||
|
[rlgl] ADDED: rlGetPixelFormatName()
|
||||||
|
[rlgl] REVIEWED: rlUpdateVertexBuffer (#1914) by @630Studios
|
||||||
|
[rlgl] REVIEWED: rlDrawVertexArrayElements() (#1891)
|
||||||
|
[rlgl] REVIEWED: Wrong normal matrix calculation (#1870)
|
||||||
|
[raymath] ADDED: Vector3Angle()
|
||||||
|
[raymath] REVIEWED: QuaternionFromAxisAngle() (#1892)
|
||||||
|
[raymath] REVIEWED: QuaternionToMatrix() returning transposed result. (#1793) by @object71
|
||||||
|
[shapes] ADDED: RenderPolyLinesEx() (#1758) by @lambertwang
|
||||||
|
[shapes] ADDED: DrawLineBezierCubic() (#2021) by @SAOMDVN
|
||||||
|
[textures] ADDED: GetImageColor() #2024
|
||||||
|
[textures] REMOVED: GenImagePerlinNoise()
|
||||||
|
[textures] RENAMED: GetTextureData() to LoadImageFromTexture()
|
||||||
|
[textures] RENAMED: GetScreenData() to LoadImageFromScreen()
|
||||||
|
[textures] REVIEWED: ExportImage() to use SaveFileData() (#1779)
|
||||||
|
[textures] REVIEWED: LoadImageAnim() #2005
|
||||||
|
[text] ADDED: Security check in case of not valid font
|
||||||
|
[text] ADDED: `GetGlyphInfo()` to get glyph info for a specific codepoint
|
||||||
|
[text] ADDED: `GetGlyphAtlasRec()` to get glyph rectangle within the generated font atlas
|
||||||
|
[text] ADDED: DrawTextPro() with text rotation support, WARNING: DrawTextPro() requires including `rlgl.h`, before it was only dependant on `textures` module.
|
||||||
|
[text] ADDED: UnloadCodepoints() to safely free loaded codepoints
|
||||||
|
[text] REMOVED: DrawTextRec() and DrawTextRecEx(), moved to example, those functions could be very specific depending on user needs so it's better to give the user the full source in case of special requirements instead of allowing a function with +10 input parameters.
|
||||||
|
[text] RENAMED: struct `CharInfo` to `GlyphInfo`, actually that's the correct naming for the data contained. It contains the character glyph metrics and the glyph image; in the past it also contained rectangle within the font atlas but that data has been moved to `Font` struct directly, so, `GlyphInfo` is a more correct name.
|
||||||
|
[text] RENAMED: `CodepointToUtf8()` to `CodepointToUTF8()`, capitalization of UTF-8 is the correct form, it would also require de hyphen but it can be omitted in this case.
|
||||||
|
[text] RENAMED: `TextToUtf8()` to `TextCodepointsToUTF8` for consistency and more detail on the functionality.
|
||||||
|
[text] RENAMED: GetCodepoints() to LoadCodepoints(), now codepoint array data is loaded dynamically instead of reusing a limited static buffer.
|
||||||
|
[text] RENAMED: GetNextCodepoint() to GetCodepoint()
|
||||||
|
[models] ADDED: MagikaVoxel VOX models loading
|
||||||
|
[models] ADDED: GenMeshCone() (#1903)
|
||||||
|
[models] ADDED: GetModelBoundingBox()
|
||||||
|
[models] ADDED: DrawBillboardPro() (#1759) by @nobytesgiven
|
||||||
|
[models] ADDED: DrawCubeTextureRec() (#2001) by @tdgroot
|
||||||
|
[models] ADDED: DrawCylinderEx() and DrawCylinderWiresEx() (#2049) by @Horrowind
|
||||||
|
[models] REMOVED: DrawBillboardEx()
|
||||||
|
[models] RENAMED: MeshBoundingBox() to GetMeshBoundingBox()
|
||||||
|
[models] RENAMED: MeshTangents() to GenMeshTangents()
|
||||||
|
[models] RENAMED: MeshBinormals() to GenMeshBinormals()
|
||||||
|
[models] REVIEWED: GenMeshTangents() (#1877) by @630Studios
|
||||||
|
[models] REVIEWED: CheckCollisionBoxSphere() by @Crydsch
|
||||||
|
[models] REVIEWED: GetRayCollisionQuad() by @Crydsch
|
||||||
|
[models] REVIEWED: LoadGLTF(), fixed missing transformations and nonroot skinning by @MrDiver
|
||||||
|
[models] REVIEWED: LoadGLTF(), rewriten from scratch, removed animations support (broken)
|
||||||
|
[models] REVIEWED: Decouple DrawMesh() and DrawMeshInstanced() (#1958)
|
||||||
|
[models] REVIEWED: Support vertex color attribute for GLTF and IQM (#1790) by @object71
|
||||||
|
[models] REVIEWED: DrawBillboardPro() (#1941) by @GithubPrankster
|
||||||
|
[models] REDESIGNED: Major review of glTF loading functionality (#1849) by @object71
|
||||||
|
[audio] ADDED: SeekMusicStream() (#2006) by @GithubPrankster
|
||||||
|
[audio] REMOVED: GetAudioStreamBufferSizeDefault()
|
||||||
|
[audio] RENAMED: InitAudioStream() to LoadAudioStream()
|
||||||
|
[audio] RENAMED: CloseAudioStream() to UnloadAudioStream()
|
||||||
|
[audio] RENAMED: IsMusicPlaying() to IsMusicStreamPlaying()
|
||||||
|
[audio] REVIEWED: ExportWaveAsCode()
|
||||||
|
[audio] REDESIGNED: Use frameCount on audio instead of sampleCount
|
||||||
|
[utils] REVIEWED: exit() on LOG_FATAL instead of LOG_ERROR (#1796)
|
||||||
|
[examples] ADDED: core_custom_frame_control
|
||||||
|
[examples] ADDED: core_basic_screen_manager
|
||||||
|
[examples] ADDED: core_split_screen (#1806) by @JeffM2501
|
||||||
|
[examples] ADDED: core_smooth_pixelperfect (#1771) by @NotManyIdeasDev
|
||||||
|
[examples] ADDED: shaders_texture_outline (#1883) by @GoldenThumbs
|
||||||
|
[examples] ADDED: models_loading_vox (#1940) by @procfxgen
|
||||||
|
[examples] ADDED: rlgl_compute_shader by @TSnake41 (#2088)
|
||||||
|
[examples] REMOVED: models_material_pbr
|
||||||
|
[examples] REMOVED: models_gltf_animation
|
||||||
|
[examples] REVIEWED: core_3d_picking
|
||||||
|
[examples] REVIEWED: core_input_mouse
|
||||||
|
[examples] REVIEWED: core_vr_simulator, RenderTexture usage
|
||||||
|
[examples] REVIEWED: core_window_letterbox, RenderTexture usage
|
||||||
|
[examples] REVIEWED: shapes_basic_shapes
|
||||||
|
[examples] REVIEWED: shapes_logo_raylib_anim
|
||||||
|
[examples] REVIEWED: textures_to_image
|
||||||
|
[examples] REVIEWED: text_rectangle_bounds
|
||||||
|
[examples] REVIEWED: text_unicode
|
||||||
|
[examples] REVIEWED: text_draw_3d
|
||||||
|
[examples] REVIEWED: models_loading
|
||||||
|
[examples] REVIEWED: models_skybox (#1792) (#1778)
|
||||||
|
[examples] REVIEWED: models_mesh_picking
|
||||||
|
[examples] REVIEWED: models_yaw_pitch_roll
|
||||||
|
[examples] REVIEWED: models_rlgl_solar_system
|
||||||
|
[examples] REVIEWED: shaders_custom_uniform, RenderTexture usage
|
||||||
|
[examples] REVIEWED: shaders_eratosthenes, RenderTexture usage
|
||||||
|
[examples] REVIEWED: shaders_julia_set, RenderTexture usage
|
||||||
|
[examples] REVIEWED: shaders_postprocessing, RenderTexture usage
|
||||||
|
[examples] REVIEWED: shaders_basic_lighting, simplified (#1865)
|
||||||
|
[examples] REVIEWED: audio_raw_stream.c
|
||||||
|
[examples] REVIEWED: raudio_standalone
|
||||||
|
[examples] REVIEWED: raylib_opengl_interop
|
||||||
|
[examples] REVIEWED: rlgl_standalone.c
|
||||||
|
[examples] REVIEWED: Resources licenses
|
||||||
|
[examples] REVIEWED: models resources reorganization
|
||||||
|
[templates] REMOVED: Moved to a separate repo: https://github.com/raysan5/raylib-game-template
|
||||||
|
[build] ADDED: Zig build file (#2014) by @TommiSinivuo
|
||||||
|
[build] ADDED: Android VS2019 solution (#2013) by @Kronka
|
||||||
|
[build] REMOVED: VS2017 project, outdated
|
||||||
|
[build] RENAMED: All raylib modules prefixed with 'r' (core -> rcore)
|
||||||
|
[build] RENAMED: SUPPORT_MOUSE_CURSOR_NATIVE to SUPPORT_MOUSE_CURSOR_POINT
|
||||||
|
[build] REVIEWED: examples/examples_template.c
|
||||||
|
[build] REVIEWED: Makefile to latest Emscripten SDK r23
|
||||||
|
[build] REVIEWED: Makefile for latest Android NDK r32 LTS
|
||||||
|
[build] REVIEWED: raylib resource files
|
||||||
|
[build] Moved some extra raylib libraries to /extras/ directory
|
||||||
|
[*] UPDATED: Multiple bindings to latest version
|
||||||
|
[*] UPDATED: Most external libraries to latest versions (except GLFW)
|
||||||
|
[*] Multiple code improvements and fixes by multiple contributors!
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
Release: raylib 3.7 (26 April 2021)
|
Release: raylib 3.7 (26 April 2021)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ include(EnumOption)
|
||||||
|
|
||||||
enum_option(PLATFORM "Desktop;Web;Android;Raspberry Pi;DRM" "Platform to build for.")
|
enum_option(PLATFORM "Desktop;Web;Android;Raspberry Pi;DRM" "Platform to build for.")
|
||||||
|
|
||||||
enum_option(OPENGL_VERSION "OFF;3.3;2.1;1.1;ES 2.0" "Force a specific OpenGL Version?")
|
enum_option(OPENGL_VERSION "OFF;4.3;3.3;2.1;1.1;ES 2.0" "Force a specific OpenGL Version?")
|
||||||
|
|
||||||
# Configuration options
|
# Configuration options
|
||||||
option(BUILD_EXAMPLES "Build the examples." ${RAYLIB_IS_MAIN})
|
option(BUILD_EXAMPLES "Build the examples." ${RAYLIB_IS_MAIN})
|
||||||
|
|
@ -27,9 +27,16 @@ endif()
|
||||||
option(INCLUDE_EVERYTHING "Include everything disabled by default (for CI usage" OFF)
|
option(INCLUDE_EVERYTHING "Include everything disabled by default (for CI usage" OFF)
|
||||||
set(OFF ${INCLUDE_EVERYTHING} CACHE INTERNAL "Replace any OFF by default with \${OFF} to have it covered by this option")
|
set(OFF ${INCLUDE_EVERYTHING} CACHE INTERNAL "Replace any OFF by default with \${OFF} to have it covered by this option")
|
||||||
|
|
||||||
# core.c
|
# raylib modules included
|
||||||
cmake_dependent_option(SUPPORT_CAMERA_SYSTEM "Provide camera module (camera.h) with multiple predefined cameras: free, 1st/3rd person, orbital" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_MODULE_RSHAPES "Include module: rshapes" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_GESTURES_SYSTEM "Gestures module is included (gestures.h) to support gestures detection: tap, hold, swipe, drag" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_MODULE_RTEXTURES "Include module: rtextures" ON CUSTOMIZE_BUILD ON)
|
||||||
|
cmake_dependent_option(SUPPORT_MODULE_RTEXT "Include module: rtext" ON CUSTOMIZE_BUILD ON)
|
||||||
|
cmake_dependent_option(SUPPORT_MODULE_RMODELS "Include module: rmodels" ON CUSTOMIZE_BUILD ON)
|
||||||
|
cmake_dependent_option(SUPPORT_MODULE_RAUDIO "Include module: raudio" ON CUSTOMIZE_BUILD ON)
|
||||||
|
|
||||||
|
# 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_GESTURES_SYSTEM "Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_MOUSE_GESTURES "Mouse gestures are directly mapped like touches and processed by gestures system" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_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" OFF CUSTOMIZE_BUILD OFF)
|
||||||
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)
|
||||||
|
|
@ -41,10 +48,10 @@ cmake_dependent_option(SUPPORT_WINMM_HIGHRES_TIMER "Setting a higher resolution
|
||||||
cmake_dependent_option(SUPPORT_DATA_STORAGE "Support for persistent data storage" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_DATA_STORAGE "Support for persistent data storage" 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)
|
||||||
|
|
||||||
# shapes.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)
|
||||||
|
|
||||||
# textures.c
|
# rtextures.c
|
||||||
cmake_dependent_option(SUPPORT_IMAGE_EXPORT "Support image exporting to file" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_IMAGE_EXPORT "Support image exporting to file" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_IMAGE_GENERATION "Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_IMAGE_GENERATION "Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_IMAGE_MANIPULATION "Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop... If not defined only three image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageToPOT()" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_IMAGE_MANIPULATION "Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop... If not defined only three image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageToPOT()" ON CUSTOMIZE_BUILD ON)
|
||||||
|
|
@ -57,21 +64,23 @@ cmake_dependent_option(SUPPORT_FILEFORMAT_BMP "Support loading BMP as textures"
|
||||||
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" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||||
|
cmake_dependent_option(SUPPORT_FILEFORMAT_QOI "Support loading QOI 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_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)
|
||||||
|
|
||||||
# text.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)
|
||||||
|
|
||||||
# models.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)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_OBJ "Support loading OBJ file format" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_OBJ "Support loading OBJ file format" ON CUSTOMIZE_BUILD ON)
|
||||||
cmake_dependent_option(SUPPORT_FILEFORMAT_MTL "Support loading MTL file format" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_FILEFORMAT_MTL "Support loading MTL 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_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)
|
||||||
|
|
||||||
# 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)
|
||||||
|
|
|
||||||
54
HISTORY.md
|
|
@ -33,7 +33,7 @@ Lots of code changes and lot of testing have concluded in this amazing new rayli
|
||||||
notes on raylib 1.2
|
notes on raylib 1.2
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
On September 2014, after 5 month of raylib 1.1 release, it comes raylib 1.2. Again, this version presents a complete internal redesign of [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module to support two new platforms: [Android](http://www.android.com/) and [Raspberry Pi](http://www.raspberrypi.org/).
|
On September 2014, after 5 month of raylib 1.1 release, it comes raylib 1.2. Again, this version presents a complete internal redesign of [core](https://github.com/raysan5/raylib/blob/master/src/rcore.c) module to support two new platforms: [Android](http://www.android.com/) and [Raspberry Pi](http://www.raspberrypi.org/).
|
||||||
|
|
||||||
It's been some month of really hard work to accomodate raylib to those new platforms while keeping it easy for the users. On Android, raylib manages internally the activity cicle, as well as the inputs; on Raspberry Pi, a complete raw input system has been written from scratch.
|
It's been some month of really hard work to accomodate raylib to those new platforms while keeping it easy for the users. On Android, raylib manages internally the activity cicle, as well as the inputs; on Raspberry Pi, a complete raw input system has been written from scratch.
|
||||||
|
|
||||||
|
|
@ -54,9 +54,9 @@ On September 2015, after 1 year of raylib 1.2 release, arrives raylib 1.3. This
|
||||||
|
|
||||||
- Textures module has grown to support most of the internal texture formats available in OpenGL (RGB565, RGB888, RGBA5551, RGBA4444, etc.), including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT); raylib 1.3 can load .dds, .pkm, .ktx, .astc and .pvr files.
|
- Textures module has grown to support most of the internal texture formats available in OpenGL (RGB565, RGB888, RGBA5551, RGBA4444, etc.), including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT); raylib 1.3 can load .dds, .pkm, .ktx, .astc and .pvr files.
|
||||||
|
|
||||||
- A brand new [camera](https://github.com/raysan5/raylib/blob/master/src/camera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person). Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_first_person.c).
|
- A brand new [camera](https://github.com/raysan5/raylib/blob/master/src/rcamera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person). Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_first_person.c).
|
||||||
|
|
||||||
- New [gestures](https://github.com/raysan5/raylib/blob/master/src/gestures.h) module simplifies gestures detection on Android and HTML5 programs.
|
- New [gestures](https://github.com/raysan5/raylib/blob/master/src/rgestures.h) module simplifies gestures detection on Android and HTML5 programs.
|
||||||
|
|
||||||
- [raygui](https://github.com/raysan5/raylib/blob/master/src/raygui.h), the new immediate-mode GUI module offers a set of functions to create simple user interfaces, primary intended for tools development. It's still in experimental state but already fully functional.
|
- [raygui](https://github.com/raysan5/raylib/blob/master/src/raygui.h), the new immediate-mode GUI module offers a set of functions to create simple user interfaces, primary intended for tools development. It's still in experimental state but already fully functional.
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ On February 2016, after 4 months of raylib 1.3 release, it comes raylib 1.4. For
|
||||||
|
|
||||||
- [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline.
|
- [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline.
|
||||||
|
|
||||||
- [gestures](https://github.com/raysan5/raylib/blob/master/src/gestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse. This way, gestures system can be used on any platform providing an unified way to work with inputs and allowing the user to create multiplatform games with only one source code.
|
- [gestures](https://github.com/raysan5/raylib/blob/master/src/rgestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse. This way, gestures system can be used on any platform providing an unified way to work with inputs and allowing the user to create multiplatform games with only one source code.
|
||||||
|
|
||||||
- Raspberry Pi input system has been redesigned to better read raw inputs using generic Linux event handlers (keyboard:`stdin`, mouse:`/dev/input/mouse0`, gamepad:`/dev/input/js0`). Gamepad support has also been added (experimental).
|
- Raspberry Pi input system has been redesigned to better read raw inputs using generic Linux event handlers (keyboard:`stdin`, mouse:`/dev/input/mouse0`, gamepad:`/dev/input/js0`). Gamepad support has also been added (experimental).
|
||||||
|
|
||||||
|
|
@ -106,7 +106,7 @@ On July 2016, after 5 months of raylib 1.4 release, arrives raylib 1.5. This new
|
||||||
|
|
||||||
- Audio chiptunese support and mixing channels: Added support for module audio music (.xm, .mod) loading and playing. Multiple mixing channels are now also supported. All this features thanks to the amazing work of @kd7tck.
|
- Audio chiptunese support and mixing channels: Added support for module audio music (.xm, .mod) loading and playing. Multiple mixing channels are now also supported. All this features thanks to the amazing work of @kd7tck.
|
||||||
|
|
||||||
Other additions include a [2D camera system](https://github.com/raysan5/raylib/blob/master/examples/core_2d_camera.c), render textures for offline render (and most comprehensive [postprocessing](https://github.com/raysan5/raylib/blob/master/examples/shaders_postprocessing.c)) or support for legacy OpenGL 2.1 on desktop platforms.
|
Other additions include a [2D camera system](https://github.com/raysan5/raylib/blob/master/examples/core_2d_rcamera.c), render textures for offline render (and most comprehensive [postprocessing](https://github.com/raysan5/raylib/blob/master/examples/shaders_postprocessing.c)) or support for legacy OpenGL 2.1 on desktop platforms.
|
||||||
|
|
||||||
This new version is so massive that is difficult to list all the improvements, most of raylib modules have been reviewed and [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) module has been completely redesigned to accomodate to new material-lighting systems and stereo rendering. You can check [CHANGELOG](https://github.com/raysan5/raylib/blob/master/CHANGELOG) file for a more detailed list of changes.
|
This new version is so massive that is difficult to list all the improvements, most of raylib modules have been reviewed and [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) module has been completely redesigned to accomodate to new material-lighting systems and stereo rendering. You can check [CHANGELOG](https://github.com/raysan5/raylib/blob/master/CHANGELOG) file for a more detailed list of changes.
|
||||||
|
|
||||||
|
|
@ -255,8 +255,8 @@ It has been **10 months of improvements** to create the best raylib ever.
|
||||||
|
|
||||||
Welcome to **raylib 3.0**.
|
Welcome to **raylib 3.0**.
|
||||||
|
|
||||||
notes on raylib 3.5
|
notes on raylib 3.5 - 7th Anniversary Edition
|
||||||
-------------------
|
---------------------------------------------
|
||||||
|
|
||||||
It's December 25th... this crazy 2020 is about to finish and finally the holidays gave me some time to put a new version of raylib. It's been **9 months since last release** and last November raylib become 7 years old... I was not able to release this new version back then but here it is. Many changes and improvements have happened in those months and, even, last August, raylib was awarded with an [Epic Megagrant](https://www.unrealengine.com/en-US/blog/epic-megagrants-fall-2020-update)! Bindings list kept growing to [+50 programming languages](BINDINGS.md) and some new platforms have been supported. Let's see this new version details:
|
It's December 25th... this crazy 2020 is about to finish and finally the holidays gave me some time to put a new version of raylib. It's been **9 months since last release** and last November raylib become 7 years old... I was not able to release this new version back then but here it is. Many changes and improvements have happened in those months and, even, last August, raylib was awarded with an [Epic Megagrant](https://www.unrealengine.com/en-US/blog/epic-megagrants-fall-2020-update)! Bindings list kept growing to [+50 programming languages](BINDINGS.md) and some new platforms have been supported. Let's see this new version details:
|
||||||
|
|
||||||
|
|
@ -322,3 +322,43 @@ Highlights for `raylib 3.7`:
|
||||||
Beside those key changes, many functions have been reviewed with improvements and bug fixes, many of them contributed by the community! Thanks! And again, this release sets a **new milestone for raylib library**. Make sure to check [CHANGELOG](CHANGELOG) for detailed list of changes! Hope you enjoy this new raylib installment!
|
Beside those key changes, many functions have been reviewed with improvements and bug fixes, many of them contributed by the community! Thanks! And again, this release sets a **new milestone for raylib library**. Make sure to check [CHANGELOG](CHANGELOG) for detailed list of changes! Hope you enjoy this new raylib installment!
|
||||||
|
|
||||||
Happy **gamedev/tools/graphics** programming! :)
|
Happy **gamedev/tools/graphics** programming! :)
|
||||||
|
|
||||||
|
notes on raylib 4.0 - 8th Anniversary Edition
|
||||||
|
---------------------------------------------
|
||||||
|
|
||||||
|
It's been about 6 months since last raylib release and it's been **8 years since I started with this project**, what an adventure! It's time for a new release: `raylib 4.0`, **the biggest release ever** and an inflexion point for the library. Many hours have been put in this release to make it special, **many library details have been polished**: syntax, naming conventions, code comments, functions descriptions, log outputs... Almost all the issues have been closed (only 3 remain open at the moment of this writing) and some amazing new features have been added. I expect this **`raylib 4.0`** to be a long term version (LTS), stable and complete enough for any new graphic/game/tool application development.
|
||||||
|
|
||||||
|
Let's start with some numbers:
|
||||||
|
|
||||||
|
- **+130** closed issues (for a TOTAL of **+1030**!)
|
||||||
|
- **+550** commits since previous RELEASE
|
||||||
|
- **+20** functions ADDED to raylib API
|
||||||
|
- **+60** functions ADDED to rlgl API
|
||||||
|
- **+40** functions RENAMED/REVIEWED/REDESIGNED
|
||||||
|
- **+60** new contributors (for a TOTAL of **+275**!)
|
||||||
|
|
||||||
|
Highlights for `raylib 4.0`:
|
||||||
|
|
||||||
|
- **Naming consistency and coherency**: `raylib` API has been completely reviewed to be consistent on naming conventions for data structures and functions, comments and descriptions have been reviewed, also the syntax of many symbols for consistency; some functions and structs have been renamed (i.e. `struct CharInfo` to `struct GlyphInfo`). Output log messages have been also improved to show more info to the users. Several articles have been writen in this process: [raylib_syntax analysis](https://github.com/raysan5/raylib/wiki/raylib-syntax-analysis) and [raylib API usage analysis](https://gist.github.com/raysan5/7c0c9fff1b6c19af24bb4a51b7383f1e). In general, a big polishment of the library to make it more consistent and coherent.
|
||||||
|
|
||||||
|
- **Event Automation System**: This new _experimental_ feature has been added for future usage, it allows to **record input events and re-play them automatically**. This feature could be very useful to automatize examples testing but also for tutorials with assited game playing, in-game cinematics, speedruns, AI playing and more! Note this feature is still experimental.
|
||||||
|
|
||||||
|
- **Custom game-loop control**: As requested by some advance users, **the game-loop control can be exposed** compiling raylib with the config flag: `SUPPORT_CUSTOM_FRAME_CONTROL`. It's intended for advance users that want to control the events polling and also the timming mechanisms of their games.
|
||||||
|
|
||||||
|
- [**`rlgl 4.0`**](https://github.com/raysan5/raylib/blob/master/src/rlgl.h): This module has been completely **decoupled from platform layer** and raylib, now `rlgl` single-file header-only library only depends on the multiple OpenGL backends supported, even the dependency on `raymath` has been removed. Additionally, **support for OpenGL 4.3** has been added, supporting compute shaders and Shader Storage Buffer Objects (SSBO). Now `rlgl` can be used as a complete standalone portable library to wrap several OpenGL version and providing **a simple and easy-to-use pseudo-OpenGL immediate-mode API**.
|
||||||
|
|
||||||
|
- [**`raymath 1.5`**](https://github.com/raysan5/raylib/blob/master/src/raymath.h): This module has been reviewed and some new conventions have been adopted to make it **more portable and self-contained**:
|
||||||
|
- Functions are self-contained, no function use other raymath function inside, required code is directly re-implemented
|
||||||
|
- Functions input parameters are always received by value
|
||||||
|
- Functions use always a "result" variable for return
|
||||||
|
- Angles are always in radians (`DEG2RAD`/`RAD2DEG` macros provided for convenience)
|
||||||
|
|
||||||
|
- [**`raygui 3.0`**](https://github.com/raysan5/raygui): The **official raylib immediate-mode gui library** (included in `raylib/src/extras`) has been updated to a new version, embedding the icons collection and adding mulstiple improvements. It has been simplified and constrained for a better focus on its task: provide a simple and easy-to-use immediate-mode-gui library for small tools development.
|
||||||
|
|
||||||
|
- [**`raylib_parser`**](https://github.com/raysan5/raylib/tree/master/parser): Added **new tool to parse `raylib.h`** and tokenize its enums, structs and functions, extracting all required info (name, params, descriptions...) into custom output formats (TXT, XML, JSON...) for further processing. This tool is specially useful to **automatize bindings generation**. Hopefully, this tool will make life easier to binding creators to update their bindings for raylib 4.0 or adding new ones!
|
||||||
|
|
||||||
|
- **Zig and Odin official support for raylib**: Those two new amazing programming languages are officially supporting raylib, `Zig` lists raylib as an [official example for C interoperatibility](https://ziglang.org/learn/samples/#c-interoperability) and Odin [officially supports raylib as a vendor library](https://github.com/odin-lang/Odin/tree/master/vendor/raylib). Both languages also have several bingings to raylib. Additionally, Zig build system supported has been added to compile raylib library and examples.
|
||||||
|
|
||||||
|
Those are some of the key features for this new release but actually there is way more! **Support for `VOX` ([MagikaVoxel](https://ephtracy.github.io/)) 3d model format** has been added, **new [raylib_game_template](https://github.com/raysan5/raylib-game-template)** repo shared, **new `EncodeDataBase64()` and `DecodeDataBase64()` functions** added, **improved HiDPI support**, new `DrawTextPro()` with support for text rotations, completely **reviewed `glTF` models loading**, added **`SeekMusicStream()` for music seeking**, many new examples and +20 examples reviewed... **hundreds of improvements and bug fixes**! Make sure to check [CHANGELOG](CHANGELOG) for a detailed list of changes!
|
||||||
|
|
||||||
|
Undoubtely, **this is the best raylib ever**. Enjoy gamedev/tools/graphics programming! :)
|
||||||
|
|
|
||||||
2
LICENSE
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2013-2021 Ramon Santamaria (@raysan5)
|
Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
|
||||||
|
|
||||||
This software is provided "as-is", without any express or implied warranty. In no event
|
This software is provided "as-is", without any express or implied warranty. In no event
|
||||||
will the authors be held liable for any damages arising from the use of this software.
|
will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
|
|
||||||
48
README.md
|
|
@ -14,9 +14,9 @@ Please, follow the wiki page in order to install and use it:
|
||||||
|
|
||||||
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 specially 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 auto-debugging... 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.*
|
||||||
|
|
||||||
Ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html)
|
Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
@ -24,7 +24,8 @@ Ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html)
|
||||||
|
|
||||||
[](https://github.com/raysan5/raylib/graphs/contributors)
|
[](https://github.com/raysan5/raylib/graphs/contributors)
|
||||||
[](https://github.com/raysan5/raylib/releases)
|
[](https://github.com/raysan5/raylib/releases)
|
||||||
[](https://github.com/raysan5/raylib/commits/master)
|
[](https://repology.org/project/raylib/versions)
|
||||||
|
[](https://github.com/raysan5/raylib/commits/master)
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
|
|
||||||
[](https://discord.gg/raylib)
|
[](https://discord.gg/raylib)
|
||||||
|
|
@ -47,13 +48,13 @@ features
|
||||||
- **NO external dependencies**, all required libraries are [bundled into raylib](https://github.com/raysan5/raylib/tree/master/src/external)
|
- **NO external dependencies**, all required libraries are [bundled into raylib](https://github.com/raysan5/raylib/tree/master/src/external)
|
||||||
- Multiple platforms supported: **Windows, Linux, MacOS, RPI, Android, HTML5... and more!**
|
- Multiple platforms supported: **Windows, Linux, MacOS, RPI, Android, HTML5... and more!**
|
||||||
- Written in plain C code (C99) in PascalCase/camelCase notation
|
- Written in plain C code (C99) in PascalCase/camelCase notation
|
||||||
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3 or ES 2.0**)
|
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3, 4.3 or ES 2.0**)
|
||||||
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
|
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
|
||||||
- Multiple **Fonts** formats supported (TTF, XNA fonts, AngelCode fonts)
|
- Multiple **Fonts** formats supported (TTF, XNA fonts, AngelCode fonts)
|
||||||
- Multiple texture formats supported, including **compressed formats** (DXT, ETC, ASTC)
|
- Multiple texture formats supported, including **compressed formats** (DXT, ETC, ASTC)
|
||||||
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
||||||
- Flexible Materials system, supporting classic maps and **PBR maps**
|
- Flexible Materials system, supporting classic maps and **PBR maps**
|
||||||
- **Animated 3D models** supported (skeletal bones animation) (IQM, glTF)
|
- **Animated 3D models** supported (skeletal bones animation) (IQM)
|
||||||
- Shaders support, including model and **postprocessing** shaders.
|
- Shaders support, including model and **postprocessing** shaders.
|
||||||
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
||||||
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
|
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
|
||||||
|
|
@ -62,11 +63,9 @@ features
|
||||||
- Bindings to [+50 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
- Bindings to [+50 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
||||||
- **Free and open source**.
|
- **Free and open source**.
|
||||||
|
|
||||||
raylib uses internally some libraries for window/graphics/inputs management and also to support different fileformats loading, all those libraries are embedded with raylib and are available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib dependencies](https://github.com/raysan5/raylib/wiki/raylib-dependencies) on [raylib Wiki](https://github.com/raysan5/raylib/wiki) for a detailed list.
|
|
||||||
|
|
||||||
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/web/core/loader.html?name=core_basic_window).
|
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).
|
||||||
```c
|
```c
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
|
@ -91,30 +90,10 @@ int main(void)
|
||||||
build and installation
|
build and installation
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
raylib binary releases for Windows, Linux and macOS are available at the [Github Releases page](https://github.com/raysan5/raylib/releases).
|
raylib binary releases for Windows, Linux, macOS, Android and HTML5 are available at the [Github Releases page](https://github.com/raysan5/raylib/releases).
|
||||||
|
|
||||||
raylib is also available via multiple [package managers](https://github.com/raysan5/raylib/issues/613) on multiple OS distributions.
|
raylib is also available via multiple [package managers](https://github.com/raysan5/raylib/issues/613) on multiple OS distributions.
|
||||||
|
|
||||||
#### Installing and building raylib via vcpkg
|
|
||||||
|
|
||||||
You can download and install raylib using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
|
|
||||||
|
|
||||||
git clone https://github.com/Microsoft/vcpkg.git
|
|
||||||
cd vcpkg
|
|
||||||
./bootstrap-vcpkg.sh
|
|
||||||
./vcpkg integrate install
|
|
||||||
vcpkg install raylib
|
|
||||||
|
|
||||||
*The raylib port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.*
|
|
||||||
|
|
||||||
#### Installing and building raylib via conan
|
|
||||||
|
|
||||||
You can download and install raylib using the [conan](https://conan.io) dependency manager:
|
|
||||||
|
|
||||||
https://docs.conan.io/en/latest/getting_started.html
|
|
||||||
|
|
||||||
*The raylib recipe in conan is kept up to date by conan team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/conan-io/conan-center-index) on the conan-center-index repository.*
|
|
||||||
|
|
||||||
#### Installing and building raylib on multiple platforms
|
#### Installing and building raylib on multiple platforms
|
||||||
|
|
||||||
[raylib Wiki](https://github.com/raysan5/raylib/wiki#development-platforms) contains detailed instructions on building and usage on multiple platforms.
|
[raylib Wiki](https://github.com/raysan5/raylib/wiki#development-platforms) contains detailed instructions on building and usage on multiple platforms.
|
||||||
|
|
@ -122,6 +101,7 @@ You can download and install raylib using the [conan](https://conan.io) dependen
|
||||||
- [Working on Windows](https://github.com/raysan5/raylib/wiki/Working-on-Windows)
|
- [Working on Windows](https://github.com/raysan5/raylib/wiki/Working-on-Windows)
|
||||||
- [Working on macOS](https://github.com/raysan5/raylib/wiki/Working-on-macOS)
|
- [Working on macOS](https://github.com/raysan5/raylib/wiki/Working-on-macOS)
|
||||||
- [Working on GNU Linux](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux)
|
- [Working on GNU Linux](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux)
|
||||||
|
- [Working on Chrome OS](https://github.com/raysan5/raylib/wiki/Working-on-Chrome-OS)
|
||||||
- [Working on FreeBSD](https://github.com/raysan5/raylib/wiki/Working-on-FreeBSD)
|
- [Working on FreeBSD](https://github.com/raysan5/raylib/wiki/Working-on-FreeBSD)
|
||||||
- [Working on Raspberry Pi](https://github.com/raysan5/raylib/wiki/Working-on-Raspberry-Pi)
|
- [Working on Raspberry Pi](https://github.com/raysan5/raylib/wiki/Working-on-Raspberry-Pi)
|
||||||
- [Working for Android](https://github.com/raysan5/raylib/wiki/Working-for-Android)
|
- [Working for Android](https://github.com/raysan5/raylib/wiki/Working-for-Android)
|
||||||
|
|
@ -132,7 +112,7 @@ You can download and install raylib using the [conan](https://conan.io) dependen
|
||||||
|
|
||||||
#### Setup raylib with multiple IDEs
|
#### Setup raylib with multiple IDEs
|
||||||
|
|
||||||
raylib has been developed on Windows platform using [Notepad++](https://notepad-plus-plus.org/) and [MinGW GCC](http://mingw-w64.org/doku.php) compiler but it can be used with other IDEs on multiple platforms.
|
raylib has been developed on Windows platform using [Notepad++](https://notepad-plus-plus.org/) and [MinGW GCC](https://www.mingw-w64.org/) compiler but it can be used with other IDEs on multiple platforms.
|
||||||
|
|
||||||
[Projects directory](https://github.com/raysan5/raylib/tree/master/projects) contains several ready-to-use **project templates** to build raylib and code examples with multiple IDEs.
|
[Projects directory](https://github.com/raysan5/raylib/tree/master/projects) contains several ready-to-use **project templates** to build raylib and code examples with multiple IDEs.
|
||||||
|
|
||||||
|
|
@ -157,10 +137,10 @@ contact and networks
|
||||||
|
|
||||||
raylib is present in several networks and raylib community is growing everyday. If you are using raylib and enjoying it, feel free to join us in any of these networks. The most active network is our [Discord server](https://discord.gg/raylib)! :)
|
raylib is present in several networks and raylib community is growing everyday. If you are using raylib and enjoying it, feel free to join us in any of these networks. The most active network is our [Discord server](https://discord.gg/raylib)! :)
|
||||||
|
|
||||||
- Webpage: [http://www.raylib.com](http://www.raylib.com)
|
- Webpage: [https://www.raylib.com](https://www.raylib.com)
|
||||||
- Discord: [https://discord.gg/raylib](https://discord.gg/raylib)
|
- Discord: [https://discord.gg/raylib](https://discord.gg/raylib)
|
||||||
- Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
|
- Twitter: [https://www.twitter.com/raysan5](https://www.twitter.com/raysan5)
|
||||||
- Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
|
- Twitch: [https://www.twitch.tv/raysan5](https://www.twitch.tv/raysan5)
|
||||||
- Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
- Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||||
- Patreon: [https://www.patreon.com/raylib](https://www.patreon.com/raylib)
|
- Patreon: [https://www.patreon.com/raylib](https://www.patreon.com/raylib)
|
||||||
- YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/c/raylib)
|
- YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/c/raylib)
|
||||||
|
|
@ -169,3 +149,5 @@ license
|
||||||
-------
|
-------
|
||||||
|
|
||||||
raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.
|
raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.
|
||||||
|
|
||||||
|
raylib uses internally some libraries for window/graphics/inputs management and also to support different fileformats loading, all those libraries are embedded with and are available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib dependencies LICENSES](https://github.com/raysan5/raylib/wiki/raylib-dependencies) on raylib Wiki for details.
|
||||||
|
|
|
||||||
28
ROADMAP.md
|
|
@ -1,19 +1,27 @@
|
||||||
roadmap
|
# raylib roadmap
|
||||||
-------
|
|
||||||
|
|
||||||
Here it is a wish-list with features and ideas to improve the library. Note that features listed here are usually long term additions for the library. Current version of raylib is complete and functional but there is a lot of room for improvement.
|
Here it is a wish-list with features and ideas to improve the library. Note that features listed here are usually long term improvements or just describe a route to follow for the library. There are also some additional places to look for raylib improvements of ideas:
|
||||||
|
|
||||||
Also note that [raylib source code](https://github.com/raysan5/raylib/tree/master/src) has multiple *TODO* comments around code with pending things to review or improve. Check also [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
- [GitHub Issues](https://github.com/raysan5/raylib/issues) has several open issues for possible improvements or bugs to fix.
|
||||||
|
- [raylib source code](https://github.com/raysan5/raylib/tree/master/src) has multiple *TODO* comments around code with pending things to review or improve.
|
||||||
|
- [raylib wishlist](https://github.com/raysan5/raylib/discussions/1502) is open to everyone to ask for improvements, feel free to check and comment.
|
||||||
|
|
||||||
There is also a [Discussions Wishlist](https://github.com/raysan5/raylib/discussions/1502) open to everyone, feel free to check and comment.
|
_Current version of raylib is complete and functional but, as always, there is lot of room for improvement._
|
||||||
|
|
||||||
|
**raylib 4.x**
|
||||||
|
- [ ] Redesign camera module (more flexible) ([#1143](https://github.com/raysan5/raylib/issues/1143))
|
||||||
|
- [ ] Redesign gestures system, improve touch inputs management
|
||||||
|
- [ ] Better documentation and improved examples
|
||||||
|
- [ ] Focus on HTML5 and embedded platforms
|
||||||
|
- [ ] Additional support libraries: [raygui](https://github.com/raysan5/raygui), [rres](https://github.com/raysan5/rres)...
|
||||||
|
|
||||||
**raylib 4.0**
|
**raylib 4.0**
|
||||||
- [ ] Network module (UDP): `rnet` ([#753](https://github.com/raysan5/raylib/issues/753))
|
- [x] Improved consistency and coherency in raylib API
|
||||||
- [ ] Custom raylib resource packer: `rres` ([link](https://github.com/raysan5/rres))
|
|
||||||
- [ ] Basic CPU/GPU stats system (memory, draws, time...) ([#1295](https://github.com/raysan5/raylib/issues/1295))
|
|
||||||
- [ ] Software rendering backend (avoiding OpenGL) ([#1370](https://github.com/raysan5/raylib/issues/1370))
|
|
||||||
- [ ] Redesigned camera module (more flexible) ([#1143](https://github.com/raysan5/raylib/issues/1143))
|
|
||||||
- [x] Continuous Deployment using GitHub Actions
|
- [x] Continuous Deployment using GitHub Actions
|
||||||
|
- [x] rlgl improvements for standalone usage (avoid raylib coupling)
|
||||||
|
- Basic CPU/GPU stats system (memory, draws, time...) ([#1295](https://github.com/raysan5/raylib/issues/1295)) - _DISCARDED_
|
||||||
|
- Software rendering backend (avoiding OpenGL) ([#1370](https://github.com/raysan5/raylib/issues/1370)) - _DISCARDED_
|
||||||
|
- Network module (UDP): `rnet` ([#753](https://github.com/raysan5/raylib/issues/753)) - _DISCARDED_ - Use [nbnet](https://github.com/nathhB/nbnet).
|
||||||
|
|
||||||
**raylib 3.0**
|
**raylib 3.0**
|
||||||
- [x] Custom memory allocators support
|
- [x] Custom memory allocators support
|
||||||
|
|
|
||||||
41
SPONSORS.md
|
|
@ -1,21 +1,14 @@
|
||||||
## raylib GitHub Sponsors
|
## raylib GitHub Sponsors
|
||||||
|
|
||||||
### Current raylib GitHub Sponsors
|
### Current raylib GitHub Sponsors (raylib 4.0 release)
|
||||||
|
|
||||||
The following people is currently [**sponsoring raylib**](https://github.com/sponsors/raysan5) with a generous donation to allow improving and growing the project!
|
The following people are currently [**sponsoring raylib**](https://github.com/sponsors/raysan5) with a generous donation to allow improving and growing the project!
|
||||||
|
|
||||||
Note that Sponsors donations vary between sponsors, I just decided not to make any distinction while listing them.
|
|
||||||
|
|
||||||
- Eric J. ([@ProfJski](https://github.com/ProfJski))
|
- Eric J. ([@ProfJski](https://github.com/ProfJski))
|
||||||
- devdad ([@devdad](https://github.com/devdad))
|
|
||||||
- Zach Geis ([@zacgeis](https://github.com/zacgeis))
|
- Zach Geis ([@zacgeis](https://github.com/zacgeis))
|
||||||
- minirop ([@minirop](https://github.com/minirop))
|
- minirop ([@minirop](https://github.com/minirop))
|
||||||
- Daniel Gómez ([@Koocachookies](https://github.com/Koocachookies))
|
- Daniel Gómez ([@Koocachookies](https://github.com/Koocachookies))
|
||||||
- Sergio ([@anidealgift](https://github.com/anidealgift))
|
|
||||||
- Marc Agüera ([@maguera93](https://github.com/maguera93))
|
- Marc Agüera ([@maguera93](https://github.com/maguera93))
|
||||||
- Pau Fernández ([@pauek](https://github.com/pauek))
|
|
||||||
- Snowminx ([@Gamerfiend](https://github.com/Gamerfiend))
|
|
||||||
- NimbusFox ([@NimbusFox](https://github.com/NimbusFox))
|
|
||||||
- Robin Mattheussen ([@romatthe](https://github.com/romatthe))
|
- Robin Mattheussen ([@romatthe](https://github.com/romatthe))
|
||||||
- Grant Haywood ([@cinterloper](https://github.com/cinterloper))
|
- Grant Haywood ([@cinterloper](https://github.com/cinterloper))
|
||||||
- Terry Nguyen ([@terrehbyte](https://github.com/terrehbyte))
|
- Terry Nguyen ([@terrehbyte](https://github.com/terrehbyte))
|
||||||
|
|
@ -25,10 +18,18 @@ Note that Sponsors donations vary between sponsors, I just decided not to make a
|
||||||
- cob ([@majorcob](https://github.com/majorcob))
|
- cob ([@majorcob](https://github.com/majorcob))
|
||||||
- Samuel Batista ([@gamedevsam](https://github.com/gamedevsam))
|
- Samuel Batista ([@gamedevsam](https://github.com/gamedevsam))
|
||||||
- Merlyn Morgan-Graham ([@kavika13](https://github.com/kavika13))
|
- Merlyn Morgan-Graham ([@kavika13](https://github.com/kavika13))
|
||||||
- Toby4213 ([@Toby4213](https://github.com/Toby4213))
|
|
||||||
- linus ([@hochbaum](https://github.com/hochbaum))
|
- linus ([@hochbaum](https://github.com/hochbaum))
|
||||||
- Nawarian ([@nawarian](https://github.com/nawarian) - [thephp.website](https://thephp.website/))
|
- Níckolas Daniel da Silva ([@nawarian](https://github.com/nawarian) - [thephp.website](https://thephp.website/))
|
||||||
|
- kenzie ([@sme-ek](https://github.com/sme-ek))
|
||||||
|
- Allan Regush ([@AllanRegush](https://github.com/AllanRegush))
|
||||||
|
- Jeffery Myers ([@JeffM2501](https://github.com/JeffM2501))
|
||||||
|
- Ryan Roden-Corrent ([@rcorre](https://github.com/rcorre))
|
||||||
|
- michaelfiber ([@michaelfiber](https://github.com/michaelfiber))
|
||||||
|
- Nikhilesh S ([@nikki93](https://github.com/nikki93))
|
||||||
|
- kevinabraun ([@kevinabraun](https://github.com/kevinabraun))
|
||||||
|
- Matthew Owens ([@MatthewOwens](https://github.com/MatthewOwens))
|
||||||
|
- Tim Eilers ([@eilerstim](https://github.com/eilerstim))
|
||||||
|
- Laurentino Luna ([@catmanl](https://github.com/catmanl))
|
||||||
|
|
||||||
### Past raylib GitHub Sponsors
|
### Past raylib GitHub Sponsors
|
||||||
|
|
||||||
|
|
@ -49,10 +50,20 @@ The following people has **sponsored raylib** in the past, allowing the project
|
||||||
- James Ghawaly ([@jghawaly](https://github.com/jghawaly))
|
- James Ghawaly ([@jghawaly](https://github.com/jghawaly))
|
||||||
- jack ([@Jack-Ji](https://github.com/Jack-Ji))
|
- jack ([@Jack-Ji](https://github.com/Jack-Ji))
|
||||||
- Guido Offermans ([@jghawaly](https://github.com/GuidoOffermans))
|
- Guido Offermans ([@jghawaly](https://github.com/GuidoOffermans))
|
||||||
|
- devdad ([@devdad](https://github.com/devdad))
|
||||||
|
- Pau Fernández ([@pauek](https://github.com/pauek))
|
||||||
|
- Sergio ([@anidealgift](https://github.com/anidealgift))
|
||||||
|
- Snowminx ([@Gamerfiend](https://github.com/Gamerfiend))
|
||||||
|
- NimbusFox ([@NimbusFox](https://github.com/NimbusFox))
|
||||||
|
- Shylie ([@Shylie](https://github.com/Shylie))
|
||||||
|
- Livio Dal Maso ([@Humeur](https://github.com/Humeur))
|
||||||
|
- Diego Vaccher ([@denny0754](https://github.com/denny0754))
|
||||||
|
- Ricardo Alcantara ([@ricardoalcantara](https://github.com/ricardoalcantara))
|
||||||
|
- Toby4213 ([@Toby4213](https://github.com/Toby4213))
|
||||||
|
|
||||||
### Notes for Current/Past raylib Sponsor
|
### Notes for Current/Past raylib Sponsor
|
||||||
|
|
||||||
- **If you are not on the list, feel free to send a PR to add you if desired.**
|
- If you are not on the list, feel free to send a PR to be added (if desired).
|
||||||
- **If you want your personal webpage listed along your GitHub account, feel free to send a PR to add it.**
|
- If you want your personal webpage or project listed, feel free to send a PR to be added.
|
||||||
- **If you prefer not to listed in this list, feel free to send a PR to remove it.**
|
- If you prefer not to be in this list, feel free to send a PR to be remove.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,26 +4,35 @@ target_compile_definitions("raylib" PUBLIC "${GRAPHICS}")
|
||||||
|
|
||||||
function(define_if target variable)
|
function(define_if target variable)
|
||||||
if (${${variable}})
|
if (${${variable}})
|
||||||
|
message(STATUS "${variable}=${${variable}}")
|
||||||
target_compile_definitions(${target} PUBLIC "${variable}")
|
target_compile_definitions(${target} PUBLIC "${variable}")
|
||||||
endif ()
|
endif ()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
if (${CUSTOMIZE_BUILD})
|
if (${CUSTOMIZE_BUILD})
|
||||||
target_compile_definitions("raylib" PUBLIC EXTERNAL_CONFIG_FLAGS)
|
target_compile_definitions("raylib" PUBLIC EXTERNAL_CONFIG_FLAGS)
|
||||||
|
define_if("raylib" USE_AUDIO)
|
||||||
|
define_if("raylib" SUPPORT_MODULE_RSHAPES)
|
||||||
|
define_if("raylib" SUPPORT_MODULE_RTEXTURES)
|
||||||
|
define_if("raylib" SUPPORT_MODULE_RTEXT)
|
||||||
|
define_if("raylib" SUPPORT_MODULE_RMODELS)
|
||||||
|
define_if("raylib" SUPPORT_MODULE_RAUDIO)
|
||||||
define_if("raylib" SUPPORT_CAMERA_SYSTEM)
|
define_if("raylib" SUPPORT_CAMERA_SYSTEM)
|
||||||
define_if("raylib" SUPPORT_GESTURES_SYSTEM)
|
define_if("raylib" SUPPORT_GESTURES_SYSTEM)
|
||||||
define_if("raylib" SUPPORT_MOUSE_GESTURES)
|
define_if("raylib" SUPPORT_MOUSE_GESTURES)
|
||||||
define_if("raylib" SUPPORT_SSH_KEYBOARD_RPI)
|
define_if("raylib" SUPPORT_SSH_KEYBOARD_RPI)
|
||||||
define_if("raylib" SUPPORT_BUSY_WAIT_LOOP)
|
define_if("raylib" SUPPORT_DEFAULT_FONT)
|
||||||
define_if("raylib" SUPPORT_EVENTS_WAITING)
|
|
||||||
define_if("raylib" SUPPORT_SCREEN_CAPTURE)
|
define_if("raylib" SUPPORT_SCREEN_CAPTURE)
|
||||||
define_if("raylib" SUPPORT_GIF_RECORDING)
|
define_if("raylib" SUPPORT_GIF_RECORDING)
|
||||||
define_if("raylib" SUPPORT_HIGH_DPI)
|
define_if("raylib" SUPPORT_BUSY_WAIT_LOOP)
|
||||||
define_if("raylib" SUPPORT_COMPRESSION_API)
|
define_if("raylib" SUPPORT_EVENTS_WAITING)
|
||||||
|
define_if("raylib" SUPPORT_WINMM_HIGHRES_TIMER)
|
||||||
define_if("raylib" SUPPORT_DATA_STORAGE)
|
define_if("raylib" SUPPORT_DATA_STORAGE)
|
||||||
define_if("raylib" SUPPORT_VR_SIMULATOR)
|
define_if("raylib" SUPPORT_COMPRESSION_API)
|
||||||
define_if("raylib" SUPPORT_FONT_TEXTURE)
|
|
||||||
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_GENERATION)
|
||||||
|
define_if("raylib" SUPPORT_IMAGE_MANIPULATION)
|
||||||
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)
|
||||||
|
|
@ -33,31 +42,27 @@ if (${CUSTOMIZE_BUILD})
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_TGA)
|
define_if("raylib" SUPPORT_FILEFORMAT_TGA)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_JPG)
|
define_if("raylib" SUPPORT_FILEFORMAT_JPG)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_GIF)
|
define_if("raylib" SUPPORT_FILEFORMAT_GIF)
|
||||||
|
define_if("raylib" SUPPORT_FILEFORMAT_QOI)
|
||||||
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" ORT_IMAGE_EXPORT)
|
|
||||||
define_if("raylib" SUPPORT_IMAGE_MANIPULATION)
|
|
||||||
define_if("raylib" SUPPORT_IMAGE_GENERATION)
|
|
||||||
define_if("raylib" SUPPORT_DEFAULT_FONT)
|
|
||||||
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)
|
||||||
|
define_if("raylib" SUPPORT_MESH_GENERATION)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_OBJ)
|
define_if("raylib" SUPPORT_FILEFORMAT_OBJ)
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_MTL)
|
define_if("raylib" SUPPORT_FILEFORMAT_MTL)
|
||||||
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_MESH_GENERATION)
|
define_if("raylib" SUPPORT_FILEFORMAT_VOX)
|
||||||
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_FLAC)
|
|
||||||
define_if("raylib" SUPPORT_FILEFORMAT_MP3)
|
define_if("raylib" SUPPORT_FILEFORMAT_MP3)
|
||||||
|
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)
|
||||||
define_if("raylib" SUPPORT_COMPRESSION_API)
|
|
||||||
|
|
||||||
|
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
target_compile_definitions("raylib" PUBLIC "MAX_FILEPATH_LENGTH=4096")
|
target_compile_definitions("raylib" PUBLIC "MAX_FILEPATH_LENGTH=4096")
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@ if (${PLATFORM} MATCHES "Desktop")
|
||||||
endif ()
|
endif ()
|
||||||
elseif (WIN32)
|
elseif (WIN32)
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} winmm)
|
find_package(OpenGL QUIET)
|
||||||
|
set(LIBS_PRIVATE ${OPENGL_LIBRARIES} winmm)
|
||||||
else ()
|
else ()
|
||||||
find_library(pthread NAMES pthread)
|
find_library(pthread NAMES pthread)
|
||||||
find_package(OpenGL QUIET)
|
find_package(OpenGL QUIET)
|
||||||
|
|
@ -27,6 +28,10 @@ if (${PLATFORM} MATCHES "Desktop")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
|
set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
|
||||||
|
|
||||||
|
if (USE_AUDIO)
|
||||||
|
set(LIBS_PRIVATE ${LIBS_PRIVATE} dl)
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
elseif (${PLATFORM} MATCHES "Web")
|
elseif (${PLATFORM} MATCHES "Web")
|
||||||
|
|
@ -39,10 +44,10 @@ elseif (${PLATFORM} MATCHES "Android")
|
||||||
set(PLATFORM_CPP "PLATFORM_ANDROID")
|
set(PLATFORM_CPP "PLATFORM_ANDROID")
|
||||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
set(raylib_sources "${raylib_sources} ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c")
|
||||||
add_definitions(-DANDROID -D__ANDROID_API__=21)
|
add_definitions(-DANDROID -D__ANDROID_API__=21)
|
||||||
include_directories(external/android/native_app_glue)
|
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -uANativeActivity_onCreate")
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -u ANativeActivity_onCreate -Wl,-undefined,dynamic_lookup")
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ string (REPLACE ";" " " raylib_LDFLAGS "${raylib_LDFLAGS}")
|
||||||
set_target_properties(raylib
|
set_target_properties(raylib
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
IMPORTED_LOCATION "${raylib_LIBRARIES}"
|
IMPORTED_LOCATION "${raylib_LIBRARIES}"
|
||||||
|
IMPORTED_IMPLIB "${raylib_LIBRARIES}"
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${raylib_INCLUDE_DIRS}"
|
INTERFACE_INCLUDE_DIRECTORIES "${raylib_INCLUDE_DIRS}"
|
||||||
INTERFACE_LINK_LIBRARIES "${raylib_LDFLAGS}"
|
INTERFACE_LINK_LIBRARIES "${raylib_LDFLAGS}"
|
||||||
INTERFACE_COMPILE_OPTIONS "${raylib_DEFINITIONS}"
|
INTERFACE_COMPILE_OPTIONS "${raylib_DEFINITIONS}"
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,6 @@ if (${PLATFORM} MATCHES "Android")
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_world_screen.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_world_screen.c)
|
||||||
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_material_pbr.c)
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_cubicmap.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_cubicmap.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_skybox.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_skybox.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
|
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013-2021 Ramon Santamaria (@raysan5)
|
# Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
|
||||||
#
|
#
|
||||||
# This software is provided "as-is", without any express or implied warranty. In no event
|
# This software is provided "as-is", without any express or implied warranty. In no event
|
||||||
# will the authors be held liable for any damages arising from the use of this software.
|
# will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
|
@ -23,44 +23,43 @@
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
||||||
# Define required raylib variables
|
# Define required environment variables
|
||||||
PROJECT_NAME ?= raylib_examples
|
#------------------------------------------------------------------------------------------------
|
||||||
RAYLIB_VERSION ?= 3.8.0
|
# Define target platform: PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB, PLATFORM_NX
|
||||||
RAYLIB_PATH ?= ..
|
|
||||||
|
|
||||||
# Define default options
|
|
||||||
|
|
||||||
# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB, PLATFORM_NX
|
|
||||||
PLATFORM ?= PLATFORM_DESKTOP
|
PLATFORM ?= PLATFORM_DESKTOP
|
||||||
|
|
||||||
# Locations of your newly installed library and associated headers. See ../src/Makefile
|
# Define required raylib variables
|
||||||
# On Linux, if you have installed raylib but cannot compile the examples, check that
|
PROJECT_NAME ?= raylib_examples
|
||||||
# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations.
|
RAYLIB_VERSION ?= 4.0.0
|
||||||
# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED.
|
RAYLIB_PATH ?= ..
|
||||||
# To enable compile-time linking to a special version of libraylib.so, change these variables here.
|
|
||||||
# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below.
|
|
||||||
# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime,
|
|
||||||
# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH.
|
|
||||||
# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths.
|
|
||||||
DESTDIR ?= /usr/local
|
|
||||||
RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib
|
|
||||||
# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files.
|
|
||||||
RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include
|
|
||||||
|
|
||||||
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
|
# Locations of raylib.h and libraylib.a/libraylib.so
|
||||||
|
# NOTE: Those variables are only used for PLATFORM_OS: LINUX, BSD
|
||||||
|
RAYLIB_INCLUDE_PATH ?= /usr/local/include
|
||||||
|
RAYLIB_LIB_PATH ?= /usr/local/lib
|
||||||
|
|
||||||
|
# Library type compilation: STATIC (.a) or SHARED (.so/.dll)
|
||||||
RAYLIB_LIBTYPE ?= STATIC
|
RAYLIB_LIBTYPE ?= STATIC
|
||||||
|
|
||||||
# Build mode for project: DEBUG or RELEASE
|
# Build mode for project: DEBUG or RELEASE
|
||||||
BUILD_MODE ?= RELEASE
|
BUILD_MODE ?= RELEASE
|
||||||
|
|
||||||
# Use external GLFW library instead of rglfw module
|
# Use external GLFW library instead of rglfw module
|
||||||
# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3
|
|
||||||
USE_EXTERNAL_GLFW ?= FALSE
|
USE_EXTERNAL_GLFW ?= FALSE
|
||||||
|
|
||||||
# Use Wayland display server protocol on Linux desktop
|
# Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system)
|
||||||
# by default it uses X11 windowing system
|
# 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 selected
|
# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
|
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
|
||||||
|
|
@ -110,18 +109,16 @@ ifeq ($(PLATFORM),PLATFORM_NX)
|
||||||
USE_EXTERNAL_GLFW = TRUE
|
USE_EXTERNAL_GLFW = TRUE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# RAYLIB_PATH adjustment for different platforms.
|
# RAYLIB_PATH adjustment for LINUX platform
|
||||||
# If using GNU make, we can get the full path to the top of the tree. Windows? BSD?
|
# TODO: Do we really need this?
|
||||||
# Required for ldconfig or other tools that do not perform path expansion.
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
RAYLIB_PREFIX ?= ..
|
RAYLIB_PREFIX ?= ..
|
||||||
RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX))
|
RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX))
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
# Default path for raylib on Raspberry Pi, if installed in different path, update it!
|
|
||||||
# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki.
|
# Default path for raylib on Raspberry Pi
|
||||||
# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX.
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
RAYLIB_PATH ?= /home/pi/raylib
|
RAYLIB_PATH ?= /home/pi/raylib
|
||||||
endif
|
endif
|
||||||
|
|
@ -129,6 +126,9 @@ ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
RAYLIB_PATH ?= /home/pi/raylib
|
RAYLIB_PATH ?= /home/pi/raylib
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Define raylib release directory for compiled library
|
||||||
|
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# Emscripten required variables
|
# Emscripten required variables
|
||||||
EMSDK_PATH ?= C:/emsdk
|
EMSDK_PATH ?= C:/emsdk
|
||||||
|
|
@ -136,7 +136,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
CLANG_PATH = $(EMSDK_PATH)/upstream/bin
|
CLANG_PATH = $(EMSDK_PATH)/upstream/bin
|
||||||
PYTHON_PATH = $(EMSDK_PATH)/python/3.9.2-1_64bit
|
PYTHON_PATH = $(EMSDK_PATH)/python/3.9.2-1_64bit
|
||||||
NODE_PATH = $(EMSDK_PATH)/node/14.15.5_64bit/bin
|
NODE_PATH = $(EMSDK_PATH)/node/14.15.5_64bit/bin
|
||||||
export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH)
|
export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH):$$(PATH)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_NX)
|
ifeq ($(PLATFORM),PLATFORM_NX)
|
||||||
|
|
@ -144,26 +144,8 @@ ifeq ($(PLATFORM),PLATFORM_NX)
|
||||||
RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX))
|
RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define raylib release directory for compiled library.
|
# Define default C compiler: CC
|
||||||
# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version
|
#------------------------------------------------------------------------------------------------
|
||||||
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
|
|
||||||
|
|
||||||
# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries
|
|
||||||
# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH
|
|
||||||
# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux
|
|
||||||
# without formal installation from ../src/Makefile. It aids portability and is useful if you have
|
|
||||||
# multiple versions of raylib, have raylib installed to a non-standard location, or want to
|
|
||||||
# bundle libraylib.so with your game. Change it to your liking.
|
|
||||||
# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH,
|
|
||||||
# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH,
|
|
||||||
# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH)
|
|
||||||
# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute.
|
|
||||||
# To see which libraries a built example is linking to, ldd core/core_basic_window;
|
|
||||||
# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing.
|
|
||||||
EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH)
|
|
||||||
|
|
||||||
# Define default C compiler: gcc
|
|
||||||
# NOTE: define g++ compiler if using C++
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
|
|
@ -196,16 +178,24 @@ ifeq ($(PLATFORM),PLATFORM_NX)
|
||||||
include $(DEVKITPRO)/libnx/switch_rules
|
include $(DEVKITPRO)/libnx/switch_rules
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define default make program
|
# Define default make program: MAKE
|
||||||
MAKE = make
|
#------------------------------------------------------------------------------------------------
|
||||||
|
MAKE ?= make
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
MAKE = mingw32-make
|
MAKE = mingw32-make
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
||||||
|
MAKE = mingw32-make
|
||||||
|
endif
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
MAKE = mingw32-make
|
||||||
|
endif
|
||||||
|
|
||||||
# Define compiler flags:
|
# Define compiler flags: CFLAGS
|
||||||
|
#------------------------------------------------------------------------------------------------
|
||||||
# -O1 defines optimization level
|
# -O1 defines optimization level
|
||||||
# -g include debug information on compilation
|
# -g include debug information on compilation
|
||||||
# -s strip unnecessary data from build
|
# -s strip unnecessary data from build
|
||||||
|
|
@ -213,11 +203,12 @@ endif
|
||||||
# -std=c99 defines C language mode (standard C from 1999 revision)
|
# -std=c99 defines C language mode (standard C from 1999 revision)
|
||||||
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
||||||
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
|
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
|
||||||
|
# -Wno-unused-value ignore unused return values of some functions (i.e. fread())
|
||||||
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
|
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
|
||||||
CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result
|
CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result
|
||||||
|
|
||||||
ifeq ($(BUILD_MODE),DEBUG)
|
ifeq ($(BUILD_MODE),DEBUG)
|
||||||
CFLAGS += -g
|
CFLAGS += -g -D_DEBUG
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
CFLAGS += -s ASSERTIONS=1 --profiling
|
CFLAGS += -s ASSERTIONS=1 --profiling
|
||||||
endif
|
endif
|
||||||
|
|
@ -232,6 +223,10 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Additional flags for compiler (if desired)
|
# Additional flags for compiler (if desired)
|
||||||
|
# -Wextra enables some extra warning flags that are not enabled by -Wall
|
||||||
|
# -Wmissing-prototypes warn if a global function is defined without a previous prototype declaration
|
||||||
|
# -Wstrict-prototypes warn if a function is declared or defined without specifying the argument types
|
||||||
|
# -Werror=implicit-function-declaration catch function calls without prior declaration
|
||||||
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
|
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
|
|
@ -240,7 +235,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
endif
|
endif
|
||||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
||||||
# Explicitly enable runtime link to libraylib.so
|
# Explicitly enable runtime link to libraylib.so
|
||||||
CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH)
|
CFLAGS += -Wl,-rpath,$(RAYLIB_RELEASE_PATH)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
@ -250,12 +245,61 @@ endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
CFLAGS += -std=gnu99 -DEGL_NO_X11
|
CFLAGS += -std=gnu99 -DEGL_NO_X11
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Define include paths for required headers: INCLUDE_PATHS
|
||||||
|
# NOTE: Some external/extras libraries could be required (stb, physac, easings...)
|
||||||
|
#------------------------------------------------------------------------------------------------
|
||||||
|
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external -I$(RAYLIB_PATH)/src/extras
|
||||||
|
|
||||||
|
# Define additional directories containing required header files
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_NX)
|
||||||
|
LIBDIRS := $(PORTLIBS) $(LIBNX)
|
||||||
|
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
|
||||||
|
CFLAGS += -ffunction-sections $(ARCH) $(foreach dir,$(LIBDIRS),-I$(dir)/include) -D__SWITCH__
|
||||||
|
endif
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
|
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
|
||||||
|
endif
|
||||||
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
|
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
|
||||||
|
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)
|
||||||
|
INCLUDE_PATHS += -I/usr/include/libdrm
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Define library paths containing required libs: LDFLAGS
|
||||||
|
#------------------------------------------------------------------------------------------------
|
||||||
|
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
|
||||||
|
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
|
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
|
||||||
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
|
LDFLAGS += -L$(RAYLIB_LIB_PATH)
|
||||||
|
endif
|
||||||
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
|
LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH)
|
||||||
|
endif
|
||||||
|
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
|
||||||
# -s USE_GLFW=3 # Use glfw3 library (context/input management)
|
# -s USE_GLFW=3 # Use glfw3 library (context/input management)
|
||||||
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
||||||
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
|
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB)
|
||||||
# -s USE_PTHREADS=1 # multithreading support
|
# -s USE_PTHREADS=1 # multithreading support
|
||||||
# -s WASM=0 # disable Web Assembly, emitted by default
|
# -s WASM=0 # disable Web Assembly, emitted by default
|
||||||
# -s ASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
|
# -s ASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
|
||||||
|
|
@ -265,7 +309,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --preload-file resources # specify a resources folder for data compilation
|
||||||
# --source-map-base # allow debugging in browser with source map
|
# --source-map-base # allow debugging in browser with source map
|
||||||
CFLAGS += -s USE_GLFW=3 -s ASYNCIFY -s TOTAL_MEMORY=67108864 -s FORCE_FILESYSTEM=1 --preload-file $(dir $<)resources@resources
|
LDFLAGS += -s USE_GLFW=3 -s ASYNCIFY -s TOTAL_MEMORY=67108864 -s FORCE_FILESYSTEM=1 --preload-file $(dir $<)resources@resources
|
||||||
|
|
||||||
# NOTE: Simple raylib examples are compiled to be interpreter with asyncify, that way,
|
# NOTE: Simple raylib examples are compiled to be interpreter with asyncify, that way,
|
||||||
# we can compile same code for ALL platforms with no change required, but, working on bigger
|
# we can compile same code for ALL platforms with no change required, but, working on bigger
|
||||||
|
|
@ -273,74 +317,20 @@ 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.
|
||||||
|
|
||||||
# Define a custom shell .html and output extension
|
# Define a custom shell .html and output extension
|
||||||
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
LDFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
||||||
EXT = .html
|
EXT = .html
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define include paths for required headers
|
|
||||||
# NOTE: Some external/extras libraries could be required (stb, physac, easings...)
|
|
||||||
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external -I$(RAYLIB_PATH)/src/extras
|
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_NX)
|
|
||||||
LIBDIRS := $(PORTLIBS) $(LIBNX)
|
|
||||||
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
|
|
||||||
CFLAGS += -ffunction-sections $(ARCH) $(foreach dir,$(LIBDIRS),-I$(dir)/include) -D__SWITCH__
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define additional directories containing required header files
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
# RPI required libraries
|
LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib
|
||||||
INCLUDE_PATHS += -I/opt/vc/include
|
|
||||||
INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux
|
|
||||||
INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
|
||||||
# DRM required libraries
|
|
||||||
INCLUDE_PATHS += -I/usr/include/libdrm
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
|
||||||
# Consider -L$(RAYLIB_H_INSTALL_PATH)
|
|
||||||
INCLUDE_PATHS += -I/usr/local/include
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
|
||||||
INCLUDE_PATHS += -I$(RAYLIB_H_INSTALL_PATH)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define library paths containing required libs.
|
|
||||||
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
|
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
# resource 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
|
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
|
||||||
# Consider -L$(RAYLIB_INSTALL_PATH)
|
|
||||||
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
|
||||||
# Reset everything.
|
|
||||||
# Precedence: immediately local, installed version, raysan5 provided libs
|
|
||||||
LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
LDFLAGS += -L/opt/vc/lib
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_NX)
|
ifeq ($(PLATFORM),PLATFORM_NX)
|
||||||
LDFLAGS += -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$*.map $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
LDFLAGS += -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$*.map $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define any libraries required on linking
|
# Define libraries required on linking: LDLIBS
|
||||||
# if you want to link libraries (libname.so or libname.a), use the -lname
|
# NOTE: To link libraries (lib<name>.so or lib<name>.a), use -l<name>
|
||||||
|
#------------------------------------------------------------------------------------------------
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
# Libraries for Windows desktop compilation
|
# Libraries for Windows desktop compilation
|
||||||
|
|
@ -390,6 +380,9 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
# Libraries for Raspberry Pi compiling
|
# Libraries for Raspberry Pi compiling
|
||||||
# NOTE: Required packages: libasound2-dev (ALSA)
|
# NOTE: Required packages: libasound2-dev (ALSA)
|
||||||
LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
|
LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
|
||||||
|
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
|
||||||
|
LDLIBS += -lvchiq_arm -lvcos
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||||
# Libraries for DRM compiling
|
# Libraries for DRM compiling
|
||||||
|
|
@ -405,9 +398,11 @@ ifeq ($(PLATFORM),PLATFORM_NX)
|
||||||
LDLIBS += `$(PREFIX)pkg-config --libs sdl2`
|
LDLIBS += `$(PREFIX)pkg-config --libs sdl2`
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define all object files required
|
# Define source code object files required
|
||||||
|
#------------------------------------------------------------------------------------------------
|
||||||
CORE = \
|
CORE = \
|
||||||
core/core_basic_window \
|
core/core_basic_window \
|
||||||
|
core/core_basic_screen_manager \
|
||||||
core/core_input_keys \
|
core/core_input_keys \
|
||||||
core/core_input_mouse \
|
core/core_input_mouse \
|
||||||
core/core_input_mouse_wheel \
|
core/core_input_mouse_wheel \
|
||||||
|
|
@ -431,7 +426,9 @@ CORE = \
|
||||||
core/core_loading_thread \
|
core/core_loading_thread \
|
||||||
core/core_quat_conversion \
|
core/core_quat_conversion \
|
||||||
core/core_window_flags \
|
core/core_window_flags \
|
||||||
core/core_split_screen
|
core/core_split_screen \
|
||||||
|
core/core_smooth_pixelperfect \
|
||||||
|
core/core_custom_frame_control
|
||||||
|
|
||||||
SHAPES = \
|
SHAPES = \
|
||||||
shapes/shapes_basic_shapes \
|
shapes/shapes_basic_shapes \
|
||||||
|
|
@ -448,7 +445,7 @@ SHAPES = \
|
||||||
shapes/shapes_easings_rectangle_array \
|
shapes/shapes_easings_rectangle_array \
|
||||||
shapes/shapes_draw_ring \
|
shapes/shapes_draw_ring \
|
||||||
shapes/shapes_draw_circle_sector \
|
shapes/shapes_draw_circle_sector \
|
||||||
shapes/shapes_draw_rectangle_rounded
|
shapes/shapes_top_down_lights
|
||||||
|
|
||||||
TEXTURES = \
|
TEXTURES = \
|
||||||
textures/textures_logo_raylib \
|
textures/textures_logo_raylib \
|
||||||
|
|
@ -470,7 +467,7 @@ TEXTURES = \
|
||||||
textures/textures_bunnymark \
|
textures/textures_bunnymark \
|
||||||
textures/textures_blend_modes \
|
textures/textures_blend_modes \
|
||||||
textures/textures_draw_tiled \
|
textures/textures_draw_tiled \
|
||||||
textures/textures_poly
|
textures/textures_polygon
|
||||||
|
|
||||||
TEXT = \
|
TEXT = \
|
||||||
text/text_raylib_fonts \
|
text/text_raylib_fonts \
|
||||||
|
|
@ -492,17 +489,17 @@ MODELS = \
|
||||||
models/models_cubicmap \
|
models/models_cubicmap \
|
||||||
models/models_first_person_maze \
|
models/models_first_person_maze \
|
||||||
models/models_geometric_shapes \
|
models/models_geometric_shapes \
|
||||||
models/models_material_pbr \
|
|
||||||
models/models_mesh_generation \
|
models/models_mesh_generation \
|
||||||
models/models_mesh_picking \
|
models/models_mesh_picking \
|
||||||
models/models_loading \
|
models/models_loading \
|
||||||
|
models/models_loading_vox \
|
||||||
|
models/models_loading_gltf \
|
||||||
models/models_orthographic_projection \
|
models/models_orthographic_projection \
|
||||||
models/models_rlgl_solar_system \
|
models/models_rlgl_solar_system \
|
||||||
models/models_skybox \
|
models/models_skybox \
|
||||||
models/models_yaw_pitch_roll \
|
models/models_yaw_pitch_roll \
|
||||||
models/models_heightmap \
|
models/models_heightmap \
|
||||||
models/models_waving_cubes \
|
models/models_waving_cubes
|
||||||
models/models_magicavoxel_loading
|
|
||||||
|
|
||||||
SHADERS = \
|
SHADERS = \
|
||||||
shaders/shaders_model_shader \
|
shaders/shaders_model_shader \
|
||||||
|
|
@ -513,6 +510,7 @@ SHADERS = \
|
||||||
shaders/shaders_raymarching \
|
shaders/shaders_raymarching \
|
||||||
shaders/shaders_texture_drawing \
|
shaders/shaders_texture_drawing \
|
||||||
shaders/shaders_texture_waves \
|
shaders/shaders_texture_waves \
|
||||||
|
shaders/shaders_texture_outline \
|
||||||
shaders/shaders_julia_set \
|
shaders/shaders_julia_set \
|
||||||
shaders/shaders_eratosthenes \
|
shaders/shaders_eratosthenes \
|
||||||
shaders/shaders_basic_lighting \
|
shaders/shaders_basic_lighting \
|
||||||
|
|
@ -540,6 +538,8 @@ PHYSICS = \
|
||||||
|
|
||||||
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
||||||
|
|
||||||
|
# Define processes to execute
|
||||||
|
#------------------------------------------------------------------------------------------------
|
||||||
# Default target entry
|
# Default target entry
|
||||||
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) $(PHYSICS)
|
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) $(PHYSICS)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# raylib makefile for Android project (APK building)
|
# raylib makefile for Android project (APK building)
|
||||||
#
|
#
|
||||||
# Copyright (c) 2017-2021 Ramon Santamaria (@raysan5)
|
# Copyright (c) 2017-2022 Ramon Santamaria (@raysan5)
|
||||||
#
|
#
|
||||||
# This software is provided "as-is", without any express or implied warranty. In no event
|
# This software is provided "as-is", without any express or implied warranty. In no event
|
||||||
# will the authors be held liable for any damages arising from the use of this software.
|
# will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
|
|
||||||
1054
examples/Makefile.Web
Normal file
|
|
@ -1,3 +1,21 @@
|
||||||
|
## Building the Examples
|
||||||
|
|
||||||
|
The examples assume you have already built the `raylib` library in `../src`.
|
||||||
|
|
||||||
|
### With GNU make
|
||||||
|
|
||||||
|
- `make` builds all examples
|
||||||
|
- `make [module]` builds all examples for a particular module (e.g `make core`)
|
||||||
|
|
||||||
|
### With Zig
|
||||||
|
|
||||||
|
The [Zig](https://ziglang.org/) toolchain can compile `C` and `C++` in addition to `Zig`.
|
||||||
|
You may find it easier to use than other toolchains, especially when it comes to cross-compiling.
|
||||||
|
|
||||||
|
- `zig build` to compile all examples
|
||||||
|
- `zig build [module]` to compile all examples for a module (e.g. `zig build core`)
|
||||||
|
- `zig build [example]` to compile _and run_ a particular example (e.g. `zig build core_basic_window`)
|
||||||
|
|
||||||
## EXAMPLES LIST
|
## EXAMPLES LIST
|
||||||
|
|
||||||
### category: core
|
### category: core
|
||||||
|
|
@ -110,7 +128,7 @@ Examples using raylib models functionality, including models loading/generation
|
||||||
| 72 | [models_cubicmap](models/models_cubicmap.c) | <img src="models/models_cubicmap.png" alt="models_cubicmap" width="200"> | ray | |
|
| 72 | [models_cubicmap](models/models_cubicmap.c) | <img src="models/models_cubicmap.png" alt="models_cubicmap" width="200"> | ray | |
|
||||||
| 73 | [models_first_person_maze](models/models_first_person_maze.c) | <img src="models/models_first_person_maze.png" alt="models_first_person_maze" width="200"> | ray | |
|
| 73 | [models_first_person_maze](models/models_first_person_maze.c) | <img src="models/models_first_person_maze.png" alt="models_first_person_maze" width="200"> | ray | |
|
||||||
| 74 | [models_geometric_shapes](models/models_geometric_shapes.c) | <img src="models/models_geometric_shapes.png" alt="models_geometric_shapes" width="200"> | ray | |
|
| 74 | [models_geometric_shapes](models/models_geometric_shapes.c) | <img src="models/models_geometric_shapes.png" alt="models_geometric_shapes" width="200"> | ray | |
|
||||||
| 75 | [models_material_pbr](models/models_material_pbr.c) | <img src="models/models_material_pbr.png" alt="models_material_pbr" width="200"> | ray | |
|
| 75 | [...]() | | ray | |
|
||||||
| 76 | [models_mesh_generation](models/models_mesh_generation.c) | <img src="models/models_mesh_generation.png" alt="models_mesh_generation" width="200"> | ray | |
|
| 76 | [models_mesh_generation](models/models_mesh_generation.c) | <img src="models/models_mesh_generation.png" alt="models_mesh_generation" width="200"> | ray | |
|
||||||
| 77 | [models_mesh_picking](models/models_mesh_picking.c) | <img src="models/models_mesh_picking.png" alt="models_mesh_picking" width="200"> | [Joel Davis](https://github.com/joeld42) | |
|
| 77 | [models_mesh_picking](models/models_mesh_picking.c) | <img src="models/models_mesh_picking.png" alt="models_mesh_picking" width="200"> | [Joel Davis](https://github.com/joeld42) | |
|
||||||
| 78 | [models_loading](models/models_loading.c) | <img src="models/models_loading.png" alt="models_loading" width="200"> | ray | |
|
| 78 | [models_loading](models/models_loading.c) | <img src="models/models_loading.png" alt="models_loading" width="200"> | ray | |
|
||||||
|
|
@ -170,22 +188,6 @@ Examples showing physics functionality with raylib. This functionality is provid
|
||||||
| 110 | [physics_restitution](physics/physics_restitution.c) | <img src="physics/physics_restitution.png" alt="physics_restitution" width="200"> | [Victor Fisac](https://github.com/victorfisac) | |
|
| 110 | [physics_restitution](physics/physics_restitution.c) | <img src="physics/physics_restitution.png" alt="physics_restitution" width="200"> | [Victor Fisac](https://github.com/victorfisac) | |
|
||||||
| 111 | [physics_shatter](physics/physics_shatter.c) | <img src="physics/physics_shatter.png" alt="physics_shatter" width="200"> | [Victor Fisac](https://github.com/victorfisac) | |
|
| 111 | [physics_shatter](physics/physics_shatter.c) | <img src="physics/physics_shatter.png" alt="physics_shatter" width="200"> | [Victor Fisac](https://github.com/victorfisac) | |
|
||||||
|
|
||||||
### category: network
|
|
||||||
|
|
||||||
Examples showing raylib network functionality. This functionality is provided by [rnet](../src/rnet.h) module.
|
|
||||||
|
|
||||||
**Note that rnet module is under development and not ready yet.**
|
|
||||||
|
|
||||||
| ## | example | image | developer | new |
|
|
||||||
|----|----------|--------|:----------:|:---:|
|
|
||||||
| 112 | [network_ping_pong](network/network_ping_pong.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
|
||||||
| 113 | [network_resolve_host](network/network_resolve_host.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
|
||||||
| 114 | [network_tcp_client](network/network_tcp_client.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
|
||||||
| 115 | [network_tcp_server](network/network_tcp_server.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
|
||||||
| 116 | [network_test](network/network_test.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
|
||||||
| 117 | [network_udp_client](network/network_udp_client.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
|
||||||
| 118 | [network_udp_server](network/network_udp_server.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
|
||||||
|
|
||||||
### category: others
|
### category: others
|
||||||
|
|
||||||
Examples showing raylib misc functionality that does not fit in other categories, like standalone modules usage or examples integrating external libraries.
|
Examples showing raylib misc functionality that does not fit in other categories, like standalone modules usage or examples integrating external libraries.
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,9 @@ int main(void)
|
||||||
{
|
{
|
||||||
float fp = (float)(mousePosition.y);
|
float fp = (float)(mousePosition.y);
|
||||||
frequency = 40.0f + (float)(fp);
|
frequency = 40.0f + (float)(fp);
|
||||||
|
|
||||||
|
float pan = (float)(mousePosition.x) / (float)screenWidth;
|
||||||
|
SetAudioStreamPan(stream, pan);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rewrite the sine wave.
|
// Rewrite the sine wave.
|
||||||
|
|
@ -137,7 +140,7 @@ int main(void)
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawText(TextFormat("sine frequency: %i",(int)frequency), GetScreenWidth() - 220, 10, 20, RED);
|
DrawText(TextFormat("sine frequency: %i",(int)frequency), GetScreenWidth() - 220, 10, 20, RED);
|
||||||
DrawText("click mouse button to change frequency", 10, 10, 20, DARKGRAY);
|
DrawText("click mouse button to change frequency or pan", 10, 10, 20, DARKGRAY);
|
||||||
|
|
||||||
// Draw the current buffer state proportionate to the screen
|
// Draw the current buffer state proportionate to the screen
|
||||||
for (int i = 0; i < screenWidth; i++)
|
for (int i = 0; i < screenWidth; i++)
|
||||||
|
|
|
||||||
101
examples/build.zig
Normal file
|
|
@ -0,0 +1,101 @@
|
||||||
|
const std = @import("std");
|
||||||
|
const builtin = @import("builtin");
|
||||||
|
|
||||||
|
fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zig.CrossTarget) !*std.build.Step {
|
||||||
|
// Standard release options allow the person running `zig build` to select
|
||||||
|
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
||||||
|
const mode = b.standardReleaseOptions();
|
||||||
|
|
||||||
|
const all = b.step(module, "All " ++ module ++ " examples");
|
||||||
|
const dir = try std.fs.cwd().openDir(
|
||||||
|
module,
|
||||||
|
.{ .iterate = true },
|
||||||
|
);
|
||||||
|
var iter = dir.iterate();
|
||||||
|
while (try iter.next()) |entry| {
|
||||||
|
if (entry.kind != .File) continue;
|
||||||
|
const extension_idx = std.mem.lastIndexOf(u8, entry.name, ".c") orelse continue;
|
||||||
|
const name = entry.name[0..extension_idx];
|
||||||
|
const path = try std.fs.path.join(b.allocator, &.{ module, entry.name });
|
||||||
|
|
||||||
|
// zig's mingw headers do not include pthread.h
|
||||||
|
if (std.mem.eql(u8, "core_loading_thread", name) and target.getOsTag() == .windows) continue;
|
||||||
|
|
||||||
|
const exe = b.addExecutable(name, null);
|
||||||
|
exe.addCSourceFile(path, switch (target.getOsTag()) {
|
||||||
|
.windows => &[_][]const u8{},
|
||||||
|
.linux => &[_][]const u8{},
|
||||||
|
.macos => &[_][]const u8{"-DPLATFORM_DESKTOP"},
|
||||||
|
else => @panic("Unsupported OS"),
|
||||||
|
});
|
||||||
|
exe.setTarget(target);
|
||||||
|
exe.setBuildMode(mode);
|
||||||
|
exe.linkLibC();
|
||||||
|
exe.addObjectFile(switch (target.getOsTag()) {
|
||||||
|
.windows => "../src/raylib.lib",
|
||||||
|
.linux => "../src/libraylib.a",
|
||||||
|
.macos => "../src/libraylib.a",
|
||||||
|
else => @panic("Unsupported OS"),
|
||||||
|
});
|
||||||
|
|
||||||
|
exe.addIncludeDir("../src");
|
||||||
|
exe.addIncludeDir("../src/external");
|
||||||
|
exe.addIncludeDir("../src/external/glfw/include");
|
||||||
|
|
||||||
|
switch (exe.target.toTarget().os.tag) {
|
||||||
|
.windows => {
|
||||||
|
exe.linkSystemLibrary("winmm");
|
||||||
|
exe.linkSystemLibrary("gdi32");
|
||||||
|
exe.linkSystemLibrary("opengl32");
|
||||||
|
exe.addIncludeDir("external/glfw/deps/mingw");
|
||||||
|
},
|
||||||
|
.linux => {
|
||||||
|
exe.linkSystemLibrary("GL");
|
||||||
|
exe.linkSystemLibrary("rt");
|
||||||
|
exe.linkSystemLibrary("dl");
|
||||||
|
exe.linkSystemLibrary("m");
|
||||||
|
exe.linkSystemLibrary("X11");
|
||||||
|
},
|
||||||
|
.macos => {
|
||||||
|
exe.linkFramework("Foundation");
|
||||||
|
exe.linkFramework("Cocoa");
|
||||||
|
exe.linkFramework("OpenGL");
|
||||||
|
exe.linkFramework("CoreAudio");
|
||||||
|
exe.linkFramework("CoreVideo");
|
||||||
|
exe.linkFramework("IOKit");
|
||||||
|
},
|
||||||
|
else => {
|
||||||
|
@panic("Unsupported OS");
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
exe.setOutputDir(module);
|
||||||
|
|
||||||
|
var run = exe.run();
|
||||||
|
run.step.dependOn(&b.addInstallArtifact(exe).step);
|
||||||
|
run.cwd = module;
|
||||||
|
b.step(name, name).dependOn(&run.step);
|
||||||
|
all.dependOn(&exe.step);
|
||||||
|
}
|
||||||
|
return all;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn build(b: *std.build.Builder) !void {
|
||||||
|
// Standard target options allows the person running `zig build` to choose
|
||||||
|
// what target to build for. Here we do not override the defaults, which
|
||||||
|
// means any target is allowed, and the default is native. Other options
|
||||||
|
// for restricting supported target set are available.
|
||||||
|
const target = b.standardTargetOptions(.{});
|
||||||
|
|
||||||
|
const all = b.getInstallStep();
|
||||||
|
|
||||||
|
all.dependOn(try add_module("audio", b, target));
|
||||||
|
all.dependOn(try add_module("core", b, target));
|
||||||
|
all.dependOn(try add_module("models", b, target));
|
||||||
|
all.dependOn(try add_module("others", b, target));
|
||||||
|
all.dependOn(try add_module("physics", b, target));
|
||||||
|
all.dependOn(try add_module("shaders", b, target));
|
||||||
|
all.dependOn(try add_module("shapes", b, target));
|
||||||
|
all.dependOn(try add_module("text", b, target));
|
||||||
|
all.dependOn(try add_module("textures", b, target));
|
||||||
|
}
|
||||||
|
|
@ -62,7 +62,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
DrawText(TextFormat("GP1: %s", GetGamepadName(0)), 10, 10, 10, BLACK);
|
DrawText(TextFormat("GP1: %s", GetGamepadName(0)), 10, 10, 10, BLACK);
|
||||||
|
|
||||||
if (IsGamepadName(0, XBOX360_NAME_ID) || IsGamepadName(0, XBOX360_LEGACY_NAME_ID))
|
if (TextIsEqual(GetGamepadName(0), XBOX360_NAME_ID) || TextIsEqual(GetGamepadName(0), XBOX360_LEGACY_NAME_ID))
|
||||||
{
|
{
|
||||||
DrawTexture(texXboxPad, 0, 0, DARKGRAY);
|
DrawTexture(texXboxPad, 0, 0, DARKGRAY);
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ int main(void)
|
||||||
//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(0, GAMEPAD_AXIS_LEFT_TRIGGER)), 10, 40, 10, BLACK);
|
||||||
//DrawText(TextFormat("Xbox axis RT: %02.02f", GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER)), 10, 60, 10, BLACK);
|
//DrawText(TextFormat("Xbox axis RT: %02.02f", GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER)), 10, 60, 10, BLACK);
|
||||||
}
|
}
|
||||||
else if (IsGamepadName(0, PS3_NAME_ID))
|
else if (TextIsEqual(GetGamepadName(0), PS3_NAME_ID))
|
||||||
{
|
{
|
||||||
DrawTexture(texPs3Pad, 0, 0, DARKGRAY);
|
DrawTexture(texPs3Pad, 0, 0, DARKGRAY);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,7 @@ int main(void)
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - input multitouch");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - input multitouch");
|
||||||
|
|
||||||
Vector2 ballPosition = { -100.0f, -100.0f };
|
Vector2 touchPositions[MAX_TOUCH_POINTS] = { 0 };
|
||||||
Color ballColor = BEIGE;
|
|
||||||
|
|
||||||
int touchCounter = 0;
|
|
||||||
Vector2 touchPosition = { 0 };
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
@ -38,19 +34,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
ballPosition = GetMousePosition();
|
// Get multiple touchpoints
|
||||||
|
for (int i = 0; i < MAX_TOUCH_POINTS; ++i) touchPositions[i] = GetTouchPosition(i);
|
||||||
ballColor = BEIGE;
|
|
||||||
|
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) ballColor = MAROON;
|
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_MIDDLE)) ballColor = LIME;
|
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) ballColor = DARKBLUE;
|
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) touchCounter = 10;
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_MIDDLE)) touchCounter = 10;
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) touchCounter = 10;
|
|
||||||
|
|
||||||
if (touchCounter > 0) touchCounter--;
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
@ -59,24 +44,18 @@ int main(void)
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
// Multitouch
|
|
||||||
for (int i = 0; i < MAX_TOUCH_POINTS; ++i)
|
for (int i = 0; i < MAX_TOUCH_POINTS; ++i)
|
||||||
{
|
{
|
||||||
touchPosition = GetTouchPosition(i); // Get the touch point
|
// Make sure point is not (0, 0) as this means there is no touch for it
|
||||||
|
if ((touchPositions[i].x > 0) && (touchPositions[i].y > 0))
|
||||||
if ((touchPosition.x >= 0) && (touchPosition.y >= 0)) // Make sure point is not (-1,-1) as this means there is no touch for it
|
|
||||||
{
|
{
|
||||||
// Draw circle and touch index number
|
// Draw circle and touch index number
|
||||||
DrawCircleV(touchPosition, 34, ORANGE);
|
DrawCircleV(touchPositions[i], 34, ORANGE);
|
||||||
DrawText(TextFormat("%d", i), (int)touchPosition.x - 10, (int)touchPosition.y - 70, 40, BLACK);
|
DrawText(TextFormat("%d", i), (int)touchPositions[i].x - 10, (int)touchPositions[i].y - 70, 40, BLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the normal mouse location
|
DrawText("touch the screen at multiple locations to get multiple balls", 10, 10, 20, DARKGRAY);
|
||||||
DrawCircleV(ballPosition, 30 + (touchCounter*3.0f), ballColor);
|
|
||||||
|
|
||||||
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY);
|
|
||||||
DrawText("touch the screen at multiple locations to get multiple balls", 10, 30, 20, DARKGRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
*
|
*
|
||||||
* Example contributed by Chris Camacho (@chriscamacho) and reviewed by Ramon Santamaria (@raysan5)
|
* Example contributed by Chris Camacho (@chriscamacho) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2020 Chris Camacho (@chriscamacho) and Ramon Santamaria (@raysan5)
|
* Copyright (c) 2020-2021 Chris Camacho (@chriscamacho) and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
@ -34,13 +34,21 @@ int main(void)
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
Mesh mesh = GenMeshCylinder(0.2f, 1.0f, 32);
|
// Load a cylinder model for testing
|
||||||
Model model = LoadModelFromMesh(mesh);
|
Model model = LoadModelFromMesh(GenMeshCylinder(0.2f, 1.0f, 32));
|
||||||
|
|
||||||
// Some required variables
|
// Generic quaternion for operations
|
||||||
Quaternion q1 = { 0 };
|
Quaternion q1 = { 0 };
|
||||||
Matrix m1 = { 0 }, m2 = { 0 }, m3 = { 0 }, m4 = { 0 };
|
|
||||||
Vector3 v1 = { 0 }, v2 = { 0 };
|
// Transform matrices required to draw 4 cylinders
|
||||||
|
Matrix m1 = { 0 };
|
||||||
|
Matrix m2 = { 0 };
|
||||||
|
Matrix m3 = { 0 };
|
||||||
|
Matrix m4 = { 0 };
|
||||||
|
|
||||||
|
// Generic vectors for rotations
|
||||||
|
Vector3 v1 = { 0 };
|
||||||
|
Vector3 v2 = { 0 };
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -50,6 +58,10 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
if (v2.x < 0) v2.x += PI*2;
|
||||||
|
if (v2.y < 0) v2.y += PI*2;
|
||||||
|
if (v2.z < 0) v2.z += PI*2;
|
||||||
|
|
||||||
if (!IsKeyDown(KEY_SPACE))
|
if (!IsKeyDown(KEY_SPACE))
|
||||||
{
|
{
|
||||||
v1.x += 0.01f;
|
v1.x += 0.01f;
|
||||||
|
|
@ -68,10 +80,7 @@ int main(void)
|
||||||
q1 = QuaternionFromMatrix(m1);
|
q1 = QuaternionFromMatrix(m1);
|
||||||
m3 = QuaternionToMatrix(q1);
|
m3 = QuaternionToMatrix(q1);
|
||||||
|
|
||||||
v2 = QuaternionToEuler(q1);
|
v2 = QuaternionToEuler(q1); // Angles returned in radians
|
||||||
v2.x *= DEG2RAD;
|
|
||||||
v2.y *= DEG2RAD;
|
|
||||||
v2.z *= DEG2RAD;
|
|
||||||
|
|
||||||
m4 = MatrixRotateZYX(v2);
|
m4 = MatrixRotateZYX(v2);
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -86,10 +95,13 @@ int main(void)
|
||||||
|
|
||||||
model.transform = m1;
|
model.transform = m1;
|
||||||
DrawModel(model, (Vector3){ -1, 0, 0 }, 1.0f, RED);
|
DrawModel(model, (Vector3){ -1, 0, 0 }, 1.0f, RED);
|
||||||
|
|
||||||
model.transform = m2;
|
model.transform = m2;
|
||||||
DrawModel(model, (Vector3){ 1, 0, 0 }, 1.0f, RED);
|
DrawModel(model, (Vector3){ 1, 0, 0 }, 1.0f, RED);
|
||||||
|
|
||||||
model.transform = m3;
|
model.transform = m3;
|
||||||
DrawModel(model, (Vector3){ 0, 0, 0 }, 1.0f, RED);
|
DrawModel(model, (Vector3){ 0, 0, 0 }, 1.0f, RED);
|
||||||
|
|
||||||
model.transform = m4;
|
model.transform = m4;
|
||||||
DrawModel(model, (Vector3){ 0, 0, -1 }, 1.0f, RED);
|
DrawModel(model, (Vector3){ 0, 0, -1 }, 1.0f, RED);
|
||||||
|
|
||||||
|
|
@ -97,23 +109,13 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
if (v2.x < 0) v2.x += PI*2;
|
DrawText(TextFormat("%2.3f", v1.x), 20, 20, 20, (v1.x == v2.x)? GREEN: BLACK);
|
||||||
if (v2.y < 0) v2.y += PI*2;
|
DrawText(TextFormat("%2.3f", v1.y), 20, 40, 20, (v1.y == v2.y)? GREEN: BLACK);
|
||||||
if (v2.z < 0) v2.z += PI*2;
|
DrawText(TextFormat("%2.3f", v1.z), 20, 60, 20, (v1.z == v2.z)? GREEN: BLACK);
|
||||||
|
|
||||||
Color cx,cy,cz;
|
DrawText(TextFormat("%2.3f", v2.x), 200, 20, 20, (v1.x == v2.x)? GREEN: BLACK);
|
||||||
cx = cy = cz = BLACK;
|
DrawText(TextFormat("%2.3f", v2.y), 200, 40, 20, (v1.y == v2.y)? GREEN: BLACK);
|
||||||
if (v1.x == v2.x) cx = GREEN;
|
DrawText(TextFormat("%2.3f", v2.z), 200, 60, 20, (v1.z == v2.z)? GREEN: BLACK);
|
||||||
if (v1.y == v2.y) cy = GREEN;
|
|
||||||
if (v1.z == v2.z) cz = GREEN;
|
|
||||||
|
|
||||||
DrawText(TextFormat("%2.3f", v1.x), 20, 20, 20, cx);
|
|
||||||
DrawText(TextFormat("%2.3f", v1.y), 20, 40, 20, cy);
|
|
||||||
DrawText(TextFormat("%2.3f", v1.z), 20, 60, 20, cz);
|
|
||||||
|
|
||||||
DrawText(TextFormat("%2.3f", v2.x), 200, 20, 20, cx);
|
|
||||||
DrawText(TextFormat("%2.3f", v2.y), 200, 40, 20, cy);
|
|
||||||
DrawText(TextFormat("%2.3f", v2.z), 200, 60, 20, cz);
|
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,12 @@ int main(void)
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values");
|
||||||
|
|
||||||
int framesCounter = 0; // Variable used to count frames
|
// SetRandomSeed(0xaabbccff); // Set a custom random seed if desired, by default: "time(NULL)"
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,6 @@ int main(void)
|
||||||
worldSpaceCamera.target.y = (int)screenSpaceCamera.target.y;
|
worldSpaceCamera.target.y = (int)screenSpaceCamera.target.y;
|
||||||
screenSpaceCamera.target.y -= worldSpaceCamera.target.y;
|
screenSpaceCamera.target.y -= worldSpaceCamera.target.y;
|
||||||
screenSpaceCamera.target.y *= virtualRatio;
|
screenSpaceCamera.target.y *= virtualRatio;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
BIN
examples/core/core_smooth_pixelperfect.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
|
|
@ -122,7 +122,7 @@ int main(void)
|
||||||
BeginMode3D(cameraPlayer1);
|
BeginMode3D(cameraPlayer1);
|
||||||
DrawScene();
|
DrawScene();
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
DrawText("PLAYER1 W/S to move", 0, 0, 20, RED);
|
DrawText("PLAYER1 W/S to move", 10, 10, 20, RED);
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
// Draw Player2 view to the render texture
|
// Draw Player2 view to the render texture
|
||||||
|
|
@ -131,7 +131,7 @@ int main(void)
|
||||||
BeginMode3D(cameraPlayer2);
|
BeginMode3D(cameraPlayer2);
|
||||||
DrawScene();
|
DrawScene();
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
DrawText("PLAYER2 UP/DOWN to move", 0, 0, 20, BLUE);
|
DrawText("PLAYER2 UP/DOWN to move", 10, 10, 20, BLUE);
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
// Draw both views render textures to the screen side by side
|
// Draw both views render textures to the screen side by side
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 21 KiB |
|
|
@ -17,7 +17,7 @@ uniform vec2 leftScreenCenter;
|
||||||
uniform vec2 rightScreenCenter;
|
uniform vec2 rightScreenCenter;
|
||||||
uniform vec2 scale;
|
uniform vec2 scale;
|
||||||
uniform vec2 scaleIn;
|
uniform vec2 scaleIn;
|
||||||
uniform vec4 hmdWarpParam;
|
uniform vec4 deviceWarpParam;
|
||||||
uniform vec4 chromaAbParam;
|
uniform vec4 chromaAbParam;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
|
@ -27,7 +27,7 @@ void main()
|
||||||
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
|
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
|
||||||
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
|
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
|
||||||
float rSq = theta.x*theta.x + theta.y*theta.y;
|
float rSq = theta.x*theta.x + theta.y*theta.y;
|
||||||
vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq);
|
vec2 theta1 = theta*(deviceWarpParam.x + deviceWarpParam.y*rSq + deviceWarpParam.z*rSq*rSq + deviceWarpParam.w*rSq*rSq*rSq);
|
||||||
vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq);
|
vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq);
|
||||||
vec2 tcBlue = lensCenter + scale*thetaBlue;
|
vec2 tcBlue = lensCenter + scale*thetaBlue;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ uniform vec2 leftScreenCenter = vec2(0.25, 0.5);
|
||||||
uniform vec2 rightScreenCenter = vec2(0.75, 0.5);
|
uniform vec2 rightScreenCenter = vec2(0.75, 0.5);
|
||||||
uniform vec2 scale = vec2(0.25, 0.45);
|
uniform vec2 scale = vec2(0.25, 0.45);
|
||||||
uniform vec2 scaleIn = vec2(4, 2.2222);
|
uniform vec2 scaleIn = vec2(4, 2.2222);
|
||||||
uniform vec4 hmdWarpParam = vec4(1, 0.22, 0.24, 0);
|
uniform vec4 deviceWarpParam = vec4(1, 0.22, 0.24, 0);
|
||||||
uniform vec4 chromaAbParam = vec4(0.996, -0.004, 1.014, 0.0);
|
uniform vec4 chromaAbParam = vec4(0.996, -0.004, 1.014, 0.0);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
|
@ -28,7 +28,7 @@ void main()
|
||||||
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
|
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
|
||||||
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
|
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
|
||||||
float rSq = theta.x*theta.x + theta.y*theta.y;
|
float rSq = theta.x*theta.x + theta.y*theta.y;
|
||||||
vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq);
|
vec2 theta1 = theta*(deviceWarpParam.x + deviceWarpParam.y*rSq + deviceWarpParam.z*rSq*rSq + deviceWarpParam.w*rSq*rSq*rSq);
|
||||||
vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq);
|
vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq);
|
||||||
vec2 tcBlue = lensCenter + scale*thetaBlue;
|
vec2 tcBlue = lensCenter + scale*thetaBlue;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,15 +39,15 @@ int main(void)
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
Model model = LoadModel("resources/guy/guy.iqm"); // Load the animated model mesh and basic data
|
Model model = LoadModel("resources/models/iqm/guy.iqm"); // Load the animated model mesh and basic data
|
||||||
Texture2D texture = LoadTexture("resources/guy/guytex.png"); // Load model texture and set material
|
Texture2D texture = LoadTexture("resources/models/iqm/guytex.png"); // Load model texture and set material
|
||||||
SetMaterialTexture(&model.materials[0], MATERIAL_MAP_DIFFUSE, texture); // Set model material map texture
|
SetMaterialTexture(&model.materials[0], MATERIAL_MAP_DIFFUSE, texture); // Set model material map texture
|
||||||
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
|
||||||
// Load animation data
|
// Load animation data
|
||||||
int animsCount = 0;
|
unsigned int animsCount = 0;
|
||||||
ModelAnimation *anims = LoadModelAnimations("resources/guy/guyanim.iqm", &animsCount);
|
ModelAnimation *anims = LoadModelAnimations("resources/models/iqm/guyanim.iqm", &animsCount);
|
||||||
int animFrameCounter = 0;
|
int animFrameCounter = 0;
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
|
SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
|
||||||
|
|
@ -102,7 +102,7 @@ int main(void)
|
||||||
UnloadTexture(texture); // Unload texture
|
UnloadTexture(texture); // Unload texture
|
||||||
|
|
||||||
// Unload model animations data
|
// Unload model animations data
|
||||||
for (int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
|
for (unsigned int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
|
||||||
RL_FREE(anims);
|
RL_FREE(anims);
|
||||||
|
|
||||||
UnloadModel(model); // Unload model
|
UnloadModel(model); // Unload model
|
||||||
|
|
|
||||||
|
|
@ -1,122 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [models] example - Load 3d gltf model with animations and play them
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 3.5 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
*
|
|
||||||
* Example contributed by Hristo Stamenov (@object71) and reviewed by Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2021 Hristo Stamenov (@object71) and Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************
|
|
||||||
*
|
|
||||||
* To export a model from blender, make sure it is not posed, the vertices need to be in the
|
|
||||||
* same position as they would be in edit mode.
|
|
||||||
* and that the scale of your models is set to 0. Scaling can be done from the export menu.
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - model animation");
|
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
|
||||||
Camera camera = { 0 };
|
|
||||||
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
|
|
||||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
|
||||||
|
|
||||||
Model model = LoadModel("resources/gltf/rigged_figure.glb"); // Load the animated model mesh and
|
|
||||||
// basic data
|
|
||||||
// Texture2D texture = LoadTexture("resources/guy/guytex.png"); // Load model texture and set material
|
|
||||||
// SetMaterialTexture(&model.materials[0], MAP_DIFFUSE, texture); // Set model material map texture
|
|
||||||
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
|
||||||
|
|
||||||
// Load animation data
|
|
||||||
int animsCount = 0;
|
|
||||||
ModelAnimation *anims = LoadModelAnimations("resources/gltf/rigged_figure.glb", &animsCount);
|
|
||||||
int animFrameCounter = 0;
|
|
||||||
int animationDirection = 1;
|
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
|
|
||||||
|
|
||||||
SetTargetFPS(30); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
UpdateCamera(&camera);
|
|
||||||
|
|
||||||
// Play animation when spacebar is held down
|
|
||||||
if (IsKeyDown(KEY_SPACE))
|
|
||||||
{
|
|
||||||
animFrameCounter += animationDirection;
|
|
||||||
|
|
||||||
if (animFrameCounter >= anims[0].frameCount || animFrameCounter <= 0)
|
|
||||||
{
|
|
||||||
animationDirection *= -1;
|
|
||||||
animFrameCounter += animationDirection;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateModelAnimation(model, anims[0], animFrameCounter);
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode3D(camera);
|
|
||||||
|
|
||||||
DrawModelEx(model, position, (Vector3){ 1.0f, 0.0f, 0.0f }, -90.0f, (Vector3){ 1.0f, 1.0f, 1.0f }, WHITE);
|
|
||||||
|
|
||||||
for (int i = 0; i < model.boneCount; i++)
|
|
||||||
{
|
|
||||||
DrawSphere(anims[0].framePoses[animFrameCounter][i].translation, 0.01f, RED);
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawGrid(10, 1.0f); // Draw a grid
|
|
||||||
|
|
||||||
EndMode3D();
|
|
||||||
|
|
||||||
DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, 10, 20, MAROON);
|
|
||||||
DrawText("(cc4) Rigged Figure by @Cesium", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
// UnloadTexture(texture); // Unload texture
|
|
||||||
|
|
||||||
// Unload model animations data
|
|
||||||
for (int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
|
|
||||||
RL_FREE(anims);
|
|
||||||
|
|
||||||
UnloadModel(model); // Unload model
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -4,17 +4,19 @@
|
||||||
*
|
*
|
||||||
* raylib supports multiple models file formats:
|
* raylib supports multiple models file formats:
|
||||||
*
|
*
|
||||||
* - OBJ > Text file, must include vertex position-texcoords-normals information,
|
* - OBJ > Text file format. Must include vertex position-texcoords-normals information,
|
||||||
* if files references some .mtl materials file, it will be loaded (or try to)
|
* if files references some .mtl materials file, it will be loaded (or try to).
|
||||||
* - GLTF > Modern text/binary file format, includes lot of information and it could
|
* - GLTF > Text/binary file format. Includes lot of information and it could
|
||||||
* also reference external files, raylib will try loading mesh and materials data
|
* also reference external files, raylib will try loading mesh and materials data.
|
||||||
* - IQM > Binary file format including mesh vertex data but also animation data,
|
* - IQM > Binary file format. Includes mesh vertex data but also animation data,
|
||||||
* raylib can load .iqm animations.
|
* raylib can load .iqm animations.
|
||||||
|
* - VOX > Binary file format. MagikaVoxel mesh format:
|
||||||
|
* https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox.txt
|
||||||
*
|
*
|
||||||
* This example has been created using raylib 2.6 (www.raylib.com)
|
* This example has been created using raylib 4.0 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
|
* Copyright (c) 2014-2021 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
@ -37,8 +39,8 @@ int main(void)
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
Model model = LoadModel("resources/models/castle.obj"); // Load model
|
Model model = LoadModel("resources/models/obj/castle.obj"); // Load model
|
||||||
Texture2D texture = LoadTexture("resources/models/castle_diffuse.png"); // Load model texture
|
Texture2D texture = LoadTexture("resources/models/obj/castle_diffuse.png"); // Load model texture
|
||||||
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||||
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
|
@ -72,6 +74,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
if (IsFileExtension(droppedFiles[0], ".obj") ||
|
if (IsFileExtension(droppedFiles[0], ".obj") ||
|
||||||
IsFileExtension(droppedFiles[0], ".gltf") ||
|
IsFileExtension(droppedFiles[0], ".gltf") ||
|
||||||
|
IsFileExtension(droppedFiles[0], ".glb") ||
|
||||||
|
IsFileExtension(droppedFiles[0], ".vox") ||
|
||||||
IsFileExtension(droppedFiles[0], ".iqm")) // Model file formats supported
|
IsFileExtension(droppedFiles[0], ".iqm")) // Model file formats supported
|
||||||
{
|
{
|
||||||
UnloadModel(model); // Unload previous model
|
UnloadModel(model); // Unload previous model
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,24 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [models] example - Load 3d gltf model
|
* raylib [models] example - Load models gltf
|
||||||
*
|
*
|
||||||
* This example has been created using raylib 3.5 (www.raylib.com)
|
* This example has been created using raylib 3.5 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
|
* NOTE: To export a model from Blender, make sure it is not posed, the vertices need to be
|
||||||
|
* in the same position as they would be in edit mode.
|
||||||
|
* Also make sure the scale parameter of your models is set to 0.0,
|
||||||
|
* scaling can be applied from the export menu.
|
||||||
|
*
|
||||||
* Example contributed by Hristo Stamenov (@object71) and reviewed by Ramon Santamaria (@raysan5)
|
* Example contributed by Hristo Stamenov (@object71) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2021 Hristo Stamenov (@object71) and Ramon Santamaria (@raysan5)
|
* Copyright (c) 2021 Hristo Stamenov (@object71) and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************
|
|
||||||
*
|
|
||||||
* To export a model from blender, make sure it is not posed, the vertices need to be in the
|
|
||||||
* same position as they would be in edit mode.
|
|
||||||
* and that the scale of your models is set to 0. Scaling can be done from the export menu.
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#define MAX_GLTF_MODELS 8
|
||||||
|
|
||||||
#define MAX_MODELS 8
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
|
@ -40,16 +37,16 @@ int main(void)
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
Model model[MAX_MODELS] = { 0 };
|
// Load some models
|
||||||
|
Model model[MAX_GLTF_MODELS] = { 0 };
|
||||||
model[0] = LoadModel("resources/gltf/raylib_32x32.glb");
|
model[0] = LoadModel("resources/models/gltf/raylib_32x32.glb");
|
||||||
model[1] = LoadModel("resources/gltf/rigged_figure.glb");
|
model[1] = LoadModel("resources/models/gltf/rigged_figure.glb");
|
||||||
model[2] = LoadModel("resources/gltf/GearboxAssy.glb");
|
model[2] = LoadModel("resources/models/gltf/GearboxAssy.glb");
|
||||||
model[3] = LoadModel("resources/gltf/BoxAnimated.glb");
|
model[3] = LoadModel("resources/models/gltf/BoxAnimated.glb");
|
||||||
model[4] = LoadModel("resources/gltf/AnimatedTriangle.gltf");
|
model[4] = LoadModel("resources/models/gltf/AnimatedTriangle.gltf");
|
||||||
model[5] = LoadModel("resources/gltf/AnimatedMorphCube.glb");
|
model[5] = LoadModel("resources/models/gltf/AnimatedMorphCube.glb");
|
||||||
model[6] = LoadModel("resources/gltf/vertex_colored_object.glb");
|
model[6] = LoadModel("resources/models/gltf/vertex_colored_object.glb");
|
||||||
model[7] = LoadModel("resources/gltf/girl.glb");
|
model[7] = LoadModel("resources/models/gltf/girl.glb");
|
||||||
|
|
||||||
int currentModel = 0;
|
int currentModel = 0;
|
||||||
|
|
||||||
|
|
@ -65,19 +62,20 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateCamera(&camera);
|
UpdateCamera(&camera); // Update our camera with inputs
|
||||||
|
|
||||||
if (IsKeyReleased(KEY_RIGHT))
|
if (IsKeyReleased(KEY_RIGHT))
|
||||||
{
|
{
|
||||||
currentModel++;
|
currentModel++;
|
||||||
if (currentModel == MAX_MODELS) currentModel = 0;
|
if (currentModel == MAX_GLTF_MODELS) currentModel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyReleased(KEY_LEFT))
|
if (IsKeyReleased(KEY_LEFT))
|
||||||
{
|
{
|
||||||
currentModel--;
|
currentModel--;
|
||||||
if (currentModel < 0) currentModel = MAX_MODELS - 1;
|
if (currentModel < 0) currentModel = MAX_GLTF_MODELS - 1;
|
||||||
}
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
@ -87,8 +85,7 @@ int main(void)
|
||||||
|
|
||||||
BeginMode3D(camera);
|
BeginMode3D(camera);
|
||||||
|
|
||||||
DrawModelEx(model[currentModel], position, (Vector3){ 0.0f, 1.0f, 0.0f }, 180.0f, (Vector3){ 2.0f, 2.0f, 2.0f }, WHITE);
|
DrawModel(model[currentModel], position, 1.0f, WHITE);
|
||||||
|
|
||||||
DrawGrid(10, 1.0f); // Draw a grid
|
DrawGrid(10, 1.0f); // Draw a grid
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
@ -99,7 +96,7 @@ int main(void)
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
for (int i = 0; i < MAX_MODELS; i++) UnloadModel(model[i]); // Unload models
|
for (int i = 0; i < MAX_GLTF_MODELS; i++) UnloadModel(model[i]); // Unload models
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
130
examples/models/models_loading_vox.c
Normal file
|
|
@ -0,0 +1,130 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [models] example - Load models vox (MagicaVoxel)
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 4.0 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Example contributed by Johann Nadalutti (@procfxgen) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 Johann Nadalutti (@procfxgen) and Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#include "raymath.h" // Required for: MatrixTranslate()
|
||||||
|
|
||||||
|
#define MAX_VOX_FILES 3
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
const char *voxFileNames[] = {
|
||||||
|
"resources/models/vox/chr_knight.vox",
|
||||||
|
"resources/models/vox/chr_sword.vox",
|
||||||
|
"resources/models/vox/monu9.vox"
|
||||||
|
};
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - magicavoxel loading");
|
||||||
|
|
||||||
|
// Define the camera to look into our 3d world
|
||||||
|
Camera camera = { 0 };
|
||||||
|
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
|
||||||
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||||
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
|
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
|
// Load MagicaVoxel files
|
||||||
|
Model models[MAX_VOX_FILES] = { 0 };
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_VOX_FILES; i++)
|
||||||
|
{
|
||||||
|
// Load VOX file and measure time
|
||||||
|
double t0 = GetTime()*1000.0;
|
||||||
|
models[i] = LoadModel(voxFileNames[i]);
|
||||||
|
double t1 = GetTime()*1000.0;
|
||||||
|
|
||||||
|
TraceLog(LOG_WARNING, TextFormat("[%s] File loaded in %.3f ms", voxFileNames[i], t1 - t0));
|
||||||
|
|
||||||
|
// Compute model translation matrix to center model on draw position (0, 0 , 0)
|
||||||
|
BoundingBox bb = GetModelBoundingBox(models[i]);
|
||||||
|
Vector3 center = { 0 };
|
||||||
|
center.x = bb.min.x + (((bb.max.x - bb.min.x)/2));
|
||||||
|
center.z = bb.min.z + (((bb.max.z - bb.min.z)/2));
|
||||||
|
|
||||||
|
Matrix matTranslate = MatrixTranslate(-center.x, 0, -center.z);
|
||||||
|
models[i].transform = matTranslate;
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentModel = 0;
|
||||||
|
|
||||||
|
SetCameraMode(camera, CAMERA_ORBITAL); // Set a orbital camera mode
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
UpdateCamera(&camera); // Update our camera to orbit
|
||||||
|
|
||||||
|
// Cycle between models on mouse click
|
||||||
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) currentModel = (currentModel + 1)%MAX_VOX_FILES;
|
||||||
|
|
||||||
|
// Cycle between models on key pressed
|
||||||
|
if (IsKeyPressed(KEY_RIGHT))
|
||||||
|
{
|
||||||
|
currentModel++;
|
||||||
|
if (currentModel >= MAX_VOX_FILES) currentModel = 0;
|
||||||
|
}
|
||||||
|
else if (IsKeyPressed(KEY_LEFT))
|
||||||
|
{
|
||||||
|
currentModel--;
|
||||||
|
if (currentModel < 0) currentModel = MAX_VOX_FILES - 1;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
// Draw 3D model
|
||||||
|
BeginMode3D(camera);
|
||||||
|
|
||||||
|
DrawModel(models[currentModel], (Vector3){ 0, 0, 0 }, 1.0f, WHITE);
|
||||||
|
DrawGrid(10, 1.0);
|
||||||
|
|
||||||
|
EndMode3D();
|
||||||
|
|
||||||
|
// Display info
|
||||||
|
DrawRectangle(10, 400, 310, 30, Fade(SKYBLUE, 0.5f));
|
||||||
|
DrawRectangleLines(10, 400, 310, 30, Fade(DARKBLUE, 0.5f));
|
||||||
|
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, 410, 10, BLUE);
|
||||||
|
DrawText(TextFormat("File: %s", GetFileName(voxFileNames[currentModel])), 10, 10, 20, GRAY);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Unload models data (GPU VRAM)
|
||||||
|
for (int i = 0; i < MAX_VOX_FILES; i++) UnloadModel(models[i]);
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BIN
examples/models/models_loading_vox.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
|
|
@ -1,153 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [models] example - magicavoxel loader and viewer
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 3.8 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
*
|
|
||||||
* Example contributed by Johann Nadalutti
|
|
||||||
*
|
|
||||||
* Copyright (c) 2021 Johann Nadalutti
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
#include "raymath.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
// VOX Files to load and view
|
|
||||||
|
|
||||||
#define NUM_VOX_FILES 3
|
|
||||||
|
|
||||||
const char* szVoxFiles[] = {
|
|
||||||
"resources/vox/chr_knight.vox",
|
|
||||||
"resources/vox/chr_sword.vox",
|
|
||||||
"resources/vox/monu9.vox"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - magicavoxel loading");
|
|
||||||
|
|
||||||
// Load MagicaVoxel files
|
|
||||||
Model models[NUM_VOX_FILES] = { 0 };
|
|
||||||
|
|
||||||
for (int i = 0; i < NUM_VOX_FILES; i++)
|
|
||||||
{
|
|
||||||
// Load MagicaVoxel File and build model
|
|
||||||
double t0, t1;
|
|
||||||
t0 = GetTime() * 1000.0;
|
|
||||||
|
|
||||||
models[i] = LoadModel(szVoxFiles[i]);
|
|
||||||
|
|
||||||
t1 = GetTime() * 1000.0;
|
|
||||||
TraceLog(LOG_INFO, TextFormat("Vox <%s> loaded in %f ms", GetFileName(szVoxFiles[i]), t1 - t0));
|
|
||||||
|
|
||||||
//Compute model matrix
|
|
||||||
BoundingBox bb = GetModelBoundingBox(models[i]);
|
|
||||||
Vector3 center;
|
|
||||||
center.x = -(((bb.max.x - bb.min.x) / 2));
|
|
||||||
center.y = -(((bb.max.y - bb.min.y) / 2));
|
|
||||||
center.z = -(((bb.max.z - bb.min.z) / 2));
|
|
||||||
|
|
||||||
Matrix matP = MatrixTranslate(center.x, center.z, 0);
|
|
||||||
Matrix matR = MatrixRotateX(90 * DEG2RAD);
|
|
||||||
models[i].transform = MatrixMultiply(matP, matR);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
|
||||||
Camera camera = { { 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
|
||||||
|
|
||||||
// Model drawing position
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f };
|
|
||||||
|
|
||||||
int currentModel = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set a orbital camera mode
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
// Main game loop
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
UpdateCamera(&camera); // Update internal camera and our camera
|
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
|
||||||
{
|
|
||||||
currentModel = (currentModel + 1) % NUM_VOX_FILES; // Cycle between models
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_RIGHT))
|
|
||||||
{
|
|
||||||
currentModel++;
|
|
||||||
if (currentModel >= NUM_VOX_FILES) currentModel = 0;
|
|
||||||
}
|
|
||||||
else if (IsKeyPressed(KEY_LEFT))
|
|
||||||
{
|
|
||||||
currentModel--;
|
|
||||||
if (currentModel < 0) currentModel = NUM_VOX_FILES - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
//Display model
|
|
||||||
BeginMode3D(camera);
|
|
||||||
|
|
||||||
Vector3 rotAxis = { 1,0,0 };
|
|
||||||
Vector3 scale = { 1,1,1 };
|
|
||||||
|
|
||||||
|
|
||||||
DrawModelEx(models[currentModel], position, rotAxis, 0, scale, WHITE);
|
|
||||||
//DrawModelWiresEx(models[currentModel], position, rotAxis, -90.0f, scale, BLACK);
|
|
||||||
|
|
||||||
DrawGrid(10, 1.0);
|
|
||||||
|
|
||||||
EndMode3D();
|
|
||||||
|
|
||||||
//Display debug infos
|
|
||||||
DrawRectangle(30, 400, 310, 30, Fade(SKYBLUE, 0.5f));
|
|
||||||
DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f));
|
|
||||||
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, 410, 10, BLUE);
|
|
||||||
|
|
||||||
DrawText(GetFileName(szVoxFiles[currentModel]), 100, 10, 20, DARKBLUE);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Unload models data (GPU VRAM)
|
|
||||||
for (int i = 0; i < NUM_VOX_FILES; i++) UnloadModel(models[i]);
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,543 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [models] example - PBR material
|
|
||||||
*
|
|
||||||
* NOTE: This example requires raylib OpenGL 3.3 for shaders support and only #version 330
|
|
||||||
* is currently supported. OpenGL ES 2.0 platforms are not supported at the moment.
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 1.8 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
#include "raymath.h"
|
|
||||||
#include "rlgl.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define RLIGHTS_IMPLEMENTATION
|
|
||||||
#include "rlights.h"
|
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
|
||||||
#define GLSL_VERSION 330
|
|
||||||
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
|
||||||
#define GLSL_VERSION 100
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CUBEMAP_SIZE 1024 // Cubemap texture size
|
|
||||||
#define IRRADIANCE_SIZE 32 // Irradiance texture size
|
|
||||||
#define PREFILTERED_SIZE 256 // Prefiltered HDR environment texture size
|
|
||||||
#define BRDF_SIZE 512 // BRDF LUT texture size
|
|
||||||
#define LIGHT_DISTANCE 1000.0f
|
|
||||||
#define LIGHT_HEIGHT 1.0f
|
|
||||||
|
|
||||||
// PBR texture maps generation
|
|
||||||
static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int size, int format); // Generate cubemap (6 faces) from equirectangular (panorama) texture
|
|
||||||
static TextureCubemap GenTextureIrradiance(Shader shader, TextureCubemap cubemap, int size); // Generate irradiance cubemap using cubemap texture
|
|
||||||
static TextureCubemap GenTexturePrefilter(Shader shader, TextureCubemap cubemap, int size); // Generate prefilter cubemap using cubemap texture
|
|
||||||
static Texture2D GenTextureBRDF(Shader shader, int size); // Generate a generic BRDF texture
|
|
||||||
|
|
||||||
// PBR material loading
|
|
||||||
static Material LoadMaterialPBR(Color albedo, float metalness, float roughness);
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material");
|
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
|
||||||
Camera camera = { 0 };
|
|
||||||
camera.position = (Vector3){ 4.0f, 4.0f, 4.0f }; // Camera position
|
|
||||||
camera.target = (Vector3){ 0.0f, 0.5f, 0.0f }; // Camera looking at point
|
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
|
||||||
|
|
||||||
// Load model and PBR material
|
|
||||||
Model model = LoadModel("resources/pbr/trooper.obj");
|
|
||||||
|
|
||||||
// Mesh tangents are generated... and uploaded to GPU
|
|
||||||
// NOTE: New VBO for tangents is generated at default location and also binded to mesh VAO
|
|
||||||
//MeshTangents(&model.meshes[0]);
|
|
||||||
|
|
||||||
model.materials[0] = LoadMaterialPBR((Color){ 255, 255, 255, 255 }, 1.0f, 1.0f);
|
|
||||||
|
|
||||||
// Create lights
|
|
||||||
// NOTE: Lights are added to an internal lights pool automatically
|
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 0, 255 }, model.materials[0].shader);
|
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 255, 0, 255 }, model.materials[0].shader);
|
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 0, 255, 255 }, model.materials[0].shader);
|
|
||||||
CreateLight(LIGHT_DIRECTIONAL, (Vector3){ 0.0f, LIGHT_HEIGHT*2.0f, -LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 255, 255 }, model.materials[0].shader);
|
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
UpdateCamera(&camera); // Update camera
|
|
||||||
|
|
||||||
// Send to material PBR shader camera view position
|
|
||||||
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
|
|
||||||
SetShaderValue(model.materials[0].shader, model.materials[0].shader.locs[SHADER_LOC_VECTOR_VIEW], cameraPos, SHADER_UNIFORM_VEC3);
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode3D(camera);
|
|
||||||
|
|
||||||
DrawModel(model, Vector3Zero(), 1.0f, WHITE);
|
|
||||||
|
|
||||||
DrawGrid(10, 1.0f);
|
|
||||||
|
|
||||||
EndMode3D();
|
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadMaterial(model.materials[0]); // Unload material: shader and textures
|
|
||||||
|
|
||||||
UnloadModel(model); // Unload model
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load PBR material (Supports: ALBEDO, NORMAL, METALNESS, ROUGHNESS, AO, EMMISIVE, HEIGHT maps)
|
|
||||||
// NOTE: PBR shader is loaded inside this function
|
|
||||||
static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
|
||||||
{
|
|
||||||
Material mat = LoadMaterialDefault(); // Initialize material to default
|
|
||||||
|
|
||||||
// Load PBR shader (requires several maps)
|
|
||||||
mat.shader = LoadShader(TextFormat("resources/shaders/glsl%i/pbr.vs", GLSL_VERSION),
|
|
||||||
TextFormat("resources/shaders/glsl%i/pbr.fs", GLSL_VERSION));
|
|
||||||
|
|
||||||
// Get required locations points for PBR material
|
|
||||||
// NOTE: Those location names must be available and used in the shader code
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_ALBEDO] = GetShaderLocation(mat.shader, "albedo.sampler");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_METALNESS] = GetShaderLocation(mat.shader, "metalness.sampler");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_NORMAL] = GetShaderLocation(mat.shader, "normals.sampler");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_ROUGHNESS] = GetShaderLocation(mat.shader, "roughness.sampler");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_OCCLUSION] = GetShaderLocation(mat.shader, "occlusion.sampler");
|
|
||||||
//mat.shader.locs[SHADER_LOC_MAP_EMISSION] = GetShaderLocation(mat.shader, "emission.sampler");
|
|
||||||
//mat.shader.locs[SHADER_LOC_MAP_HEIGHT] = GetShaderLocation(mat.shader, "height.sampler");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_IRRADIANCE] = GetShaderLocation(mat.shader, "irradianceMap");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_PREFILTER] = GetShaderLocation(mat.shader, "prefilterMap");
|
|
||||||
mat.shader.locs[SHADER_LOC_MAP_BRDF] = GetShaderLocation(mat.shader, "brdfLUT");
|
|
||||||
|
|
||||||
// Set view matrix location
|
|
||||||
mat.shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "matModel");
|
|
||||||
//mat.shader.locs[SHADER_LOC_MATRIX_VIEW] = GetShaderLocation(mat.shader, "view");
|
|
||||||
mat.shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(mat.shader, "viewPos");
|
|
||||||
|
|
||||||
// Set PBR standard maps
|
|
||||||
mat.maps[MATERIAL_MAP_ALBEDO].texture = LoadTexture("resources/pbr/trooper_albedo.png");
|
|
||||||
mat.maps[MATERIAL_MAP_NORMAL].texture = LoadTexture("resources/pbr/trooper_normals.png");
|
|
||||||
mat.maps[MATERIAL_MAP_METALNESS].texture = LoadTexture("resources/pbr/trooper_metalness.png");
|
|
||||||
mat.maps[MATERIAL_MAP_ROUGHNESS].texture = LoadTexture("resources/pbr/trooper_roughness.png");
|
|
||||||
mat.maps[MATERIAL_MAP_OCCLUSION].texture = LoadTexture("resources/pbr/trooper_ao.png");
|
|
||||||
|
|
||||||
// Set textures filtering for better quality
|
|
||||||
SetTextureFilter(mat.maps[MATERIAL_MAP_ALBEDO].texture, TEXTURE_FILTER_BILINEAR);
|
|
||||||
SetTextureFilter(mat.maps[MATERIAL_MAP_NORMAL].texture, TEXTURE_FILTER_BILINEAR);
|
|
||||||
SetTextureFilter(mat.maps[MATERIAL_MAP_METALNESS].texture, TEXTURE_FILTER_BILINEAR);
|
|
||||||
SetTextureFilter(mat.maps[MATERIAL_MAP_ROUGHNESS].texture, TEXTURE_FILTER_BILINEAR);
|
|
||||||
SetTextureFilter(mat.maps[MATERIAL_MAP_OCCLUSION].texture, TEXTURE_FILTER_BILINEAR);
|
|
||||||
|
|
||||||
// Enable sample usage in shader for assigned textures
|
|
||||||
SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "albedo.useSampler"), (int[1]){ 1 }, SHADER_UNIFORM_INT);
|
|
||||||
SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "normals.useSampler"), (int[1]){ 1 }, SHADER_UNIFORM_INT);
|
|
||||||
SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "metalness.useSampler"), (int[1]){ 1 }, SHADER_UNIFORM_INT);
|
|
||||||
SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "roughness.useSampler"), (int[1]){ 1 }, SHADER_UNIFORM_INT);
|
|
||||||
SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "occlusion.useSampler"), (int[1]){ 1 }, SHADER_UNIFORM_INT);
|
|
||||||
|
|
||||||
int renderModeLoc = GetShaderLocation(mat.shader, "renderMode");
|
|
||||||
SetShaderValue(mat.shader, renderModeLoc, (int[1]){ 0 }, SHADER_UNIFORM_INT);
|
|
||||||
|
|
||||||
// Set up material properties color
|
|
||||||
mat.maps[MATERIAL_MAP_ALBEDO].color = albedo;
|
|
||||||
mat.maps[MATERIAL_MAP_NORMAL].color = (Color){ 128, 128, 255, 255 };
|
|
||||||
mat.maps[MATERIAL_MAP_METALNESS].value = metalness;
|
|
||||||
mat.maps[MATERIAL_MAP_ROUGHNESS].value = roughness;
|
|
||||||
mat.maps[MATERIAL_MAP_OCCLUSION].value = 1.0f;
|
|
||||||
mat.maps[MATERIAL_MAP_EMISSION].value = 0.5f;
|
|
||||||
mat.maps[MATERIAL_MAP_HEIGHT].value = 0.5f;
|
|
||||||
|
|
||||||
// Generate cubemap from panorama texture
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
Texture2D panorama = LoadTexture("resources/dresden_square_2k.hdr");
|
|
||||||
|
|
||||||
// Load equirectangular to cubemap shader
|
|
||||||
Shader shdrCubemap = LoadShader(TextFormat("resources/shaders/glsl%i/pbr.vs", GLSL_VERSION),
|
|
||||||
TextFormat("resources/shaders/glsl%i/pbr.fs", GLSL_VERSION));
|
|
||||||
|
|
||||||
SetShaderValue(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, SHADER_UNIFORM_INT);
|
|
||||||
TextureCubemap cubemap = GenTextureCubemap(shdrCubemap, panorama, CUBEMAP_SIZE, PIXELFORMAT_UNCOMPRESSED_R32G32B32);
|
|
||||||
UnloadTexture(panorama);
|
|
||||||
UnloadShader(shdrCubemap);
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Generate irradiance map from cubemap texture
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
// Load irradiance (GI) calculation shader
|
|
||||||
Shader shdrIrradiance = LoadShader(TextFormat("resources/shaders/glsl%i/skybox.vs", GLSL_VERSION),
|
|
||||||
TextFormat("resources/shaders/glsl%i/irradiance.fs", GLSL_VERSION));
|
|
||||||
|
|
||||||
SetShaderValue(shdrIrradiance, GetShaderLocation(shdrIrradiance, "environmentMap"), (int[1]){ 0 }, SHADER_UNIFORM_INT);
|
|
||||||
mat.maps[MATERIAL_MAP_IRRADIANCE].texture = GenTextureIrradiance(shdrIrradiance, cubemap, IRRADIANCE_SIZE);
|
|
||||||
UnloadShader(shdrIrradiance);
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Generate prefilter map from cubemap texture
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
// Load reflection prefilter calculation shader
|
|
||||||
Shader shdrPrefilter = LoadShader(TextFormat("resources/shaders/glsl%i/skybox.vs", GLSL_VERSION),
|
|
||||||
TextFormat("resources/shaders/glsl%i/prefilter.fs", GLSL_VERSION));
|
|
||||||
|
|
||||||
SetShaderValue(shdrPrefilter, GetShaderLocation(shdrPrefilter, "environmentMap"), (int[1]){ 0 }, SHADER_UNIFORM_INT);
|
|
||||||
mat.maps[MATERIAL_MAP_PREFILTER].texture = GenTexturePrefilter(shdrPrefilter, cubemap, PREFILTERED_SIZE);
|
|
||||||
UnloadTexture(cubemap);
|
|
||||||
UnloadShader(shdrPrefilter);
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Generate BRDF (bidirectional reflectance distribution function) texture (using shader)
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
Shader shdrBRDF = LoadShader(TextFormat("resources/shaders/glsl%i/brdf.vs", GLSL_VERSION),
|
|
||||||
TextFormat("resources/shaders/glsl%i/brdf.fs", GLSL_VERSION));
|
|
||||||
|
|
||||||
mat.maps[MATERIAL_MAP_BRDG].texture = GenTextureBRDF(shdrBRDF, BRDF_SIZE);
|
|
||||||
UnloadShader(shdrBRDF);
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return mat;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Texture maps generation (PBR)
|
|
||||||
//-------------------------------------------------------------------------------------------
|
|
||||||
// Generate cubemap texture from HDR texture
|
|
||||||
static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int size, int format)
|
|
||||||
{
|
|
||||||
TextureCubemap cubemap = { 0 };
|
|
||||||
|
|
||||||
rlDisableBackfaceCulling(); // Disable backface culling to render inside the cube
|
|
||||||
|
|
||||||
// STEP 1: Setup framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
unsigned int rbo = rlLoadTextureDepth(size, size, true);
|
|
||||||
cubemap.id = rlLoadTextureCubemap(NULL, size, format);
|
|
||||||
|
|
||||||
unsigned int fbo = rlLoadFramebuffer(size, size);
|
|
||||||
rlFramebufferAttach(fbo, rbo, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
|
||||||
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X, 0);
|
|
||||||
|
|
||||||
// Check if framebuffer is complete with attachments (valid)
|
|
||||||
if (rlFramebufferComplete(fbo)) TraceLog(LOG_INFO, "FBO: [ID %i] Framebuffer object created successfully", fbo);
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 2: Draw to framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
// NOTE: Shader is used to convert HDR equirectangular environment map to cubemap equivalent (6 faces)
|
|
||||||
rlEnableShader(shader.id);
|
|
||||||
|
|
||||||
// Define projection matrix and send it to shader
|
|
||||||
Matrix matFboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
|
|
||||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_PROJECTION], matFboProjection);
|
|
||||||
|
|
||||||
// Define view matrix for every side of the cubemap
|
|
||||||
Matrix fboViews[6] = {
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ -1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 1.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, 1.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, -1.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, 1.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, -1.0f }, (Vector3){ 0.0f, -1.0f, 0.0f })
|
|
||||||
};
|
|
||||||
|
|
||||||
rlViewport(0, 0, size, size); // Set viewport to current fbo dimensions
|
|
||||||
|
|
||||||
// Activate and enable texture for drawing to cubemap faces
|
|
||||||
rlActiveTextureSlot(0);
|
|
||||||
rlEnableTexture(panorama.id);
|
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
// Set the view matrix for the current cube face
|
|
||||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_VIEW], fboViews[i]);
|
|
||||||
|
|
||||||
// Select the current cubemap face attachment for the fbo
|
|
||||||
// WARNING: This function by default enables->attach->disables fbo!!!
|
|
||||||
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X + i, 0);
|
|
||||||
rlEnableFramebuffer(fbo);
|
|
||||||
|
|
||||||
// Load and draw a cube, it uses the current enabled texture
|
|
||||||
rlClearScreenBuffers();
|
|
||||||
rlLoadDrawCube();
|
|
||||||
|
|
||||||
// ALTERNATIVE: Try to use internal batch system to draw the cube instead of rlLoadDrawCube
|
|
||||||
// for some reason this method does not work, maybe due to cube triangles definition? normals pointing out?
|
|
||||||
// TODO: Investigate this issue...
|
|
||||||
//rlSetTexture(panorama.id); // WARNING: It must be called after enabling current framebuffer if using internal batch system!
|
|
||||||
//rlClearScreenBuffers();
|
|
||||||
//DrawCubeV(Vector3Zero(), Vector3One(), WHITE);
|
|
||||||
//rlDrawRenderBatchActive();
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 3: Unload framebuffer and reset state
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
rlDisableShader(); // Unbind shader
|
|
||||||
rlDisableTexture(); // Unbind texture
|
|
||||||
rlDisableFramebuffer(); // Unbind framebuffer
|
|
||||||
rlUnloadFramebuffer(fbo); // Unload framebuffer (and automatically attached depth texture/renderbuffer)
|
|
||||||
|
|
||||||
// Reset viewport dimensions to default
|
|
||||||
rlViewport(0, 0, rlGetFramebufferWidth(), rlGetFramebufferHeight());
|
|
||||||
rlEnableBackfaceCulling();
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
cubemap.width = size;
|
|
||||||
cubemap.height = size;
|
|
||||||
cubemap.mipmaps = 1;
|
|
||||||
cubemap.format = PIXELFORMAT_UNCOMPRESSED_R32G32B32;
|
|
||||||
|
|
||||||
return cubemap;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate irradiance texture using cubemap data
|
|
||||||
static TextureCubemap GenTextureIrradiance(Shader shader, TextureCubemap cubemap, int size)
|
|
||||||
{
|
|
||||||
TextureCubemap irradiance = { 0 };
|
|
||||||
|
|
||||||
rlDisableBackfaceCulling(); // Disable backface culling to render inside the cube
|
|
||||||
|
|
||||||
// STEP 1: Setup framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
unsigned int rbo = rlLoadTextureDepth(size, size, true);
|
|
||||||
irradiance.id = rlLoadTextureCubemap(NULL, size, PIXELFORMAT_UNCOMPRESSED_R32G32B32);
|
|
||||||
|
|
||||||
unsigned int fbo = rlLoadFramebuffer(size, size);
|
|
||||||
rlFramebufferAttach(fbo, rbo, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
|
||||||
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X, 0);
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 2: Draw to framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
// NOTE: Shader is used to solve diffuse integral by convolution to create an irradiance cubemap
|
|
||||||
rlEnableShader(shader.id);
|
|
||||||
|
|
||||||
// Define projection matrix and send it to shader
|
|
||||||
Matrix matFboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
|
|
||||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_PROJECTION], matFboProjection);
|
|
||||||
|
|
||||||
// Define view matrix for every side of the cubemap
|
|
||||||
Matrix fboViews[6] = {
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ -1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 1.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, 1.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, -1.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, 1.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, -1.0f }, (Vector3){ 0.0f, -1.0f, 0.0f })
|
|
||||||
};
|
|
||||||
|
|
||||||
rlActiveTextureSlot(0);
|
|
||||||
rlEnableTextureCubemap(cubemap.id);
|
|
||||||
|
|
||||||
rlViewport(0, 0, size, size); // Set viewport to current fbo dimensions
|
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_VIEW], fboViews[i]);
|
|
||||||
rlFramebufferAttach(fbo, irradiance.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X + i, 0);
|
|
||||||
|
|
||||||
rlEnableFramebuffer(fbo);
|
|
||||||
rlClearScreenBuffers();
|
|
||||||
rlLoadDrawCube();
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 3: Unload framebuffer and reset state
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
rlDisableShader(); // Unbind shader
|
|
||||||
rlDisableTexture(); // Unbind texture
|
|
||||||
rlDisableFramebuffer(); // Unbind framebuffer
|
|
||||||
rlUnloadFramebuffer(fbo); // Unload framebuffer (and automatically attached depth texture/renderbuffer)
|
|
||||||
|
|
||||||
// Reset viewport dimensions to default
|
|
||||||
rlViewport(0, 0, rlGetFramebufferWidth(), rlGetFramebufferHeight());
|
|
||||||
rlEnableBackfaceCulling();
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
irradiance.width = size;
|
|
||||||
irradiance.height = size;
|
|
||||||
irradiance.mipmaps = 1;
|
|
||||||
irradiance.format = PIXELFORMAT_UNCOMPRESSED_R32G32B32;
|
|
||||||
|
|
||||||
return irradiance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate prefilter texture using cubemap data
|
|
||||||
static TextureCubemap GenTexturePrefilter(Shader shader, TextureCubemap cubemap, int size)
|
|
||||||
{
|
|
||||||
TextureCubemap prefilter = { 0 };
|
|
||||||
|
|
||||||
rlDisableBackfaceCulling(); // Disable backface culling to render inside the cube
|
|
||||||
|
|
||||||
// STEP 1: Setup framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
unsigned int rbo = rlLoadTextureDepth(size, size, true);
|
|
||||||
prefilter.id = rlLoadTextureCubemap(NULL, size, PIXELFORMAT_UNCOMPRESSED_R32G32B32);
|
|
||||||
rlTextureParameters(prefilter.id, RL_TEXTURE_MIN_FILTER, RL_TEXTURE_FILTER_MIP_LINEAR);
|
|
||||||
|
|
||||||
unsigned int fbo = rlLoadFramebuffer(size, size);
|
|
||||||
rlFramebufferAttach(fbo, rbo, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
|
||||||
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X, 0);
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Generate mipmaps for the prefiltered HDR texture
|
|
||||||
//glGenerateMipmap(GL_TEXTURE_CUBE_MAP); // TODO!
|
|
||||||
|
|
||||||
// STEP 2: Draw to framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
// NOTE: Shader is used to prefilter HDR and store data into mipmap levels
|
|
||||||
|
|
||||||
// Define projection matrix and send it to shader
|
|
||||||
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
|
|
||||||
rlEnableShader(shader.id);
|
|
||||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_PROJECTION], fboProjection);
|
|
||||||
|
|
||||||
// Define view matrix for every side of the cubemap
|
|
||||||
Matrix fboViews[6] = {
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ -1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 1.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, 1.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, -1.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, 1.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
|
||||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, 0.0f, -1.0f }, (Vector3){ 0.0f, -1.0f, 0.0f })
|
|
||||||
};
|
|
||||||
|
|
||||||
rlActiveTextureSlot(0);
|
|
||||||
rlEnableTextureCubemap(cubemap.id);
|
|
||||||
|
|
||||||
// TODO: Locations should be taken out of this function... too shader dependant...
|
|
||||||
int roughnessLoc = rlGetLocationUniform(shader.id, "roughness");
|
|
||||||
|
|
||||||
rlEnableFramebuffer(fbo);
|
|
||||||
|
|
||||||
#define MAX_MIPMAP_LEVELS 5 // Max number of prefilter texture mipmaps
|
|
||||||
|
|
||||||
for (int mip = 0; mip < MAX_MIPMAP_LEVELS; mip++)
|
|
||||||
{
|
|
||||||
// Resize framebuffer according to mip-level size.
|
|
||||||
unsigned int mipWidth = size*(int)powf(0.5f, (float)mip);
|
|
||||||
unsigned int mipHeight = size*(int)powf(0.5f, (float)mip);
|
|
||||||
|
|
||||||
rlViewport(0, 0, mipWidth, mipHeight);
|
|
||||||
|
|
||||||
//glBindRenderbuffer(GL_RENDERBUFFER, rbo);
|
|
||||||
//glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, mipWidth, mipHeight);
|
|
||||||
|
|
||||||
float roughness = (float)mip/(float)(MAX_MIPMAP_LEVELS - 1);
|
|
||||||
rlSetUniform(roughnessLoc, &roughness, SHADER_UNIFORM_FLOAT, 1);
|
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_VIEW], fboViews[i]);
|
|
||||||
rlFramebufferAttach(fbo, prefilter.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X + i, mip);
|
|
||||||
|
|
||||||
rlClearScreenBuffers();
|
|
||||||
rlLoadDrawCube();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 3: Unload framebuffer and reset state
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
rlDisableShader(); // Unbind shader
|
|
||||||
rlDisableTexture(); // Unbind texture
|
|
||||||
rlDisableFramebuffer(); // Unbind framebuffer
|
|
||||||
rlUnloadFramebuffer(fbo); // Unload framebuffer (and automatically attached depth texture/renderbuffer)
|
|
||||||
|
|
||||||
// Reset viewport dimensions to default
|
|
||||||
rlViewport(0, 0, rlGetFramebufferWidth(), rlGetFramebufferHeight());
|
|
||||||
rlEnableBackfaceCulling();
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
prefilter.width = size;
|
|
||||||
prefilter.height = size;
|
|
||||||
prefilter.mipmaps = MAX_MIPMAP_LEVELS;
|
|
||||||
prefilter.format = PIXELFORMAT_UNCOMPRESSED_R32G32B32;
|
|
||||||
|
|
||||||
return prefilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate BRDF texture using cubemap data
|
|
||||||
// TODO: Review implementation: https://github.com/HectorMF/BRDFGenerator
|
|
||||||
static Texture2D GenTextureBRDF(Shader shader, int size)
|
|
||||||
{
|
|
||||||
Texture2D brdf = { 0 };
|
|
||||||
|
|
||||||
// STEP 1: Setup framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
unsigned int rbo = rlLoadTextureDepth(size, size, true);
|
|
||||||
brdf.id = rlLoadTexture(NULL, size, size, PIXELFORMAT_UNCOMPRESSED_R32G32B32, 1);
|
|
||||||
|
|
||||||
unsigned int fbo = rlLoadFramebuffer(size, size);
|
|
||||||
rlFramebufferAttach(fbo, rbo, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
|
||||||
rlFramebufferAttach(fbo, brdf.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_TEXTURE2D, 0);
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 2: Draw to framebuffer
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
// NOTE: Render BRDF LUT into a quad using FBO
|
|
||||||
rlEnableShader(shader.id);
|
|
||||||
|
|
||||||
rlViewport(0, 0, size, size);
|
|
||||||
|
|
||||||
rlEnableFramebuffer(fbo);
|
|
||||||
rlClearScreenBuffers();
|
|
||||||
|
|
||||||
rlLoadDrawQuad();
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// STEP 3: Unload framebuffer and reset state
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
rlDisableShader(); // Unbind shader
|
|
||||||
rlDisableTexture(); // Unbind texture
|
|
||||||
rlDisableFramebuffer(); // Unbind framebuffer
|
|
||||||
rlUnloadFramebuffer(fbo); // Unload framebuffer (and automatically attached depth texture/renderbuffer)
|
|
||||||
|
|
||||||
// Reset viewport dimensions to default
|
|
||||||
rlViewport(0, 0, rlGetFramebufferWidth(), rlGetFramebufferHeight());
|
|
||||||
//------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
brdf.width = size;
|
|
||||||
brdf.height = size;
|
|
||||||
brdf.mipmaps = 1;
|
|
||||||
brdf.format = PIXELFORMAT_UNCOMPRESSED_R32G32B32;
|
|
||||||
|
|
||||||
return brdf;
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 317 KiB |
|
|
@ -5,7 +5,7 @@
|
||||||
* This example has been created using raylib 1.8 (www.raylib.com)
|
* This example has been created using raylib 1.8 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2017 Ramon Santamaria (Ray San)
|
* Copyright (c) 2017-2021 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
@ -13,56 +13,7 @@
|
||||||
|
|
||||||
#define NUM_MODELS 9 // Parametric 3d shapes to generate
|
#define NUM_MODELS 9 // Parametric 3d shapes to generate
|
||||||
|
|
||||||
void AllocateMeshData(Mesh* mesh, int triangleCount)
|
static Mesh GenMeshCustom(void); // Generate a simple triangle mesh from code
|
||||||
{
|
|
||||||
mesh->vertexCount = triangleCount * 3;
|
|
||||||
mesh->triangleCount = triangleCount;
|
|
||||||
|
|
||||||
mesh->vertices = (float*)MemAlloc(mesh->vertexCount * 3 * sizeof(float));
|
|
||||||
mesh->texcoords = (float*)MemAlloc(mesh->vertexCount * 2 * sizeof(float));
|
|
||||||
mesh->normals = (float*)MemAlloc(mesh->vertexCount * 3 * sizeof(float));
|
|
||||||
}
|
|
||||||
|
|
||||||
// generate a simple triangle mesh from code
|
|
||||||
Mesh MakeMesh()
|
|
||||||
{
|
|
||||||
Mesh mesh = { 0 };
|
|
||||||
AllocateMeshData(&mesh, 1);
|
|
||||||
|
|
||||||
// vertex at the origin
|
|
||||||
mesh.vertices[0] = 0;
|
|
||||||
mesh.vertices[1] = 0;
|
|
||||||
mesh.vertices[2] = 0;
|
|
||||||
mesh.normals[0] = 0;
|
|
||||||
mesh.normals[1] = 1;
|
|
||||||
mesh.normals[2] = 0;
|
|
||||||
mesh.texcoords[0] = 0;
|
|
||||||
mesh.texcoords[1] = 0;
|
|
||||||
|
|
||||||
// vertex at 1,0,2
|
|
||||||
mesh.vertices[3] = 1;
|
|
||||||
mesh.vertices[4] = 0;
|
|
||||||
mesh.vertices[5] = 2;
|
|
||||||
mesh.normals[3] = 0;
|
|
||||||
mesh.normals[4] = 1;
|
|
||||||
mesh.normals[5] = 0;
|
|
||||||
mesh.texcoords[2] = 0.5f;
|
|
||||||
mesh.texcoords[3] = 1.0f;
|
|
||||||
|
|
||||||
// vertex at 2,0,0
|
|
||||||
mesh.vertices[6] = 2;
|
|
||||||
mesh.vertices[7] = 0;
|
|
||||||
mesh.vertices[8] = 0;
|
|
||||||
mesh.normals[6] = 0;
|
|
||||||
mesh.normals[7] = 1;
|
|
||||||
mesh.normals[8] = 0;
|
|
||||||
mesh.texcoords[4] = 1;
|
|
||||||
mesh.texcoords[5] =0;
|
|
||||||
|
|
||||||
UploadMesh(&mesh, false);
|
|
||||||
|
|
||||||
return mesh;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
|
@ -88,7 +39,18 @@ int main(void)
|
||||||
models[5] = LoadModelFromMesh(GenMeshTorus(0.25f, 4.0f, 16, 32));
|
models[5] = LoadModelFromMesh(GenMeshTorus(0.25f, 4.0f, 16, 32));
|
||||||
models[6] = LoadModelFromMesh(GenMeshKnot(1.0f, 2.0f, 16, 128));
|
models[6] = LoadModelFromMesh(GenMeshKnot(1.0f, 2.0f, 16, 128));
|
||||||
models[7] = LoadModelFromMesh(GenMeshPoly(5, 2.0f));
|
models[7] = LoadModelFromMesh(GenMeshPoly(5, 2.0f));
|
||||||
models[8] = LoadModelFromMesh(MakeMesh());
|
models[8] = LoadModelFromMesh(GenMeshCustom());
|
||||||
|
|
||||||
|
// Generated meshes could be exported as .obj files
|
||||||
|
//ExportMesh(models[0].meshes[0], "plane.obj");
|
||||||
|
//ExportMesh(models[1].meshes[0], "cube.obj");
|
||||||
|
//ExportMesh(models[2].meshes[0], "sphere.obj");
|
||||||
|
//ExportMesh(models[3].meshes[0], "hemisphere.obj");
|
||||||
|
//ExportMesh(models[4].meshes[0], "cylinder.obj");
|
||||||
|
//ExportMesh(models[5].meshes[0], "torus.obj");
|
||||||
|
//ExportMesh(models[6].meshes[0], "knot.obj");
|
||||||
|
//ExportMesh(models[7].meshes[0], "poly.obj");
|
||||||
|
//ExportMesh(models[8].meshes[0], "custom.obj");
|
||||||
|
|
||||||
// Set checked texture as default diffuse component for all models material
|
// Set checked texture as default diffuse component for all models material
|
||||||
for (int i = 0; i < NUM_MODELS; i++) models[i].materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
|
for (int i = 0; i < NUM_MODELS; i++) models[i].materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
|
||||||
|
|
@ -157,7 +119,7 @@ int main(void)
|
||||||
case 5: DrawText("TORUS", 680, 10, 20, DARKBLUE); break;
|
case 5: DrawText("TORUS", 680, 10, 20, DARKBLUE); break;
|
||||||
case 6: DrawText("KNOT", 680, 10, 20, DARKBLUE); break;
|
case 6: DrawText("KNOT", 680, 10, 20, DARKBLUE); break;
|
||||||
case 7: DrawText("POLY", 680, 10, 20, DARKBLUE); break;
|
case 7: DrawText("POLY", 680, 10, 20, DARKBLUE); break;
|
||||||
case 8: DrawText("Parametric(custom)", 580, 10, 20, DARKBLUE); break;
|
case 8: DrawText("Custom (triangle)", 580, 10, 20, DARKBLUE); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -177,3 +139,49 @@ int main(void)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate a simple triangle mesh from code
|
||||||
|
static Mesh GenMeshCustom(void)
|
||||||
|
{
|
||||||
|
Mesh mesh = { 0 };
|
||||||
|
mesh.triangleCount = 1;
|
||||||
|
mesh.vertexCount = mesh.triangleCount*3;
|
||||||
|
mesh.vertices = (float *)MemAlloc(mesh.vertexCount*3*sizeof(float)); // 3 vertices, 3 coordinates each (x, y, z)
|
||||||
|
mesh.texcoords = (float *)MemAlloc(mesh.vertexCount*2*sizeof(float)); // 3 vertices, 2 coordinates each (x, y)
|
||||||
|
mesh.normals = (float *)MemAlloc(mesh.vertexCount*3*sizeof(float)); // 3 vertices, 3 coordinates each (x, y, z)
|
||||||
|
|
||||||
|
// Vertex at (0, 0, 0)
|
||||||
|
mesh.vertices[0] = 0;
|
||||||
|
mesh.vertices[1] = 0;
|
||||||
|
mesh.vertices[2] = 0;
|
||||||
|
mesh.normals[0] = 0;
|
||||||
|
mesh.normals[1] = 1;
|
||||||
|
mesh.normals[2] = 0;
|
||||||
|
mesh.texcoords[0] = 0;
|
||||||
|
mesh.texcoords[1] = 0;
|
||||||
|
|
||||||
|
// Vertex at (1, 0, 2)
|
||||||
|
mesh.vertices[3] = 1;
|
||||||
|
mesh.vertices[4] = 0;
|
||||||
|
mesh.vertices[5] = 2;
|
||||||
|
mesh.normals[3] = 0;
|
||||||
|
mesh.normals[4] = 1;
|
||||||
|
mesh.normals[5] = 0;
|
||||||
|
mesh.texcoords[2] = 0.5f;
|
||||||
|
mesh.texcoords[3] = 1.0f;
|
||||||
|
|
||||||
|
// Vertex at (2, 0, 0)
|
||||||
|
mesh.vertices[6] = 2;
|
||||||
|
mesh.vertices[7] = 0;
|
||||||
|
mesh.vertices[8] = 0;
|
||||||
|
mesh.normals[6] = 0;
|
||||||
|
mesh.normals[7] = 1;
|
||||||
|
mesh.normals[8] = 0;
|
||||||
|
mesh.texcoords[4] = 1;
|
||||||
|
mesh.texcoords[5] =0;
|
||||||
|
|
||||||
|
// Upload mesh data from CPU (RAM) to GPU (VRAM) memory
|
||||||
|
UploadMesh(&mesh, false);
|
||||||
|
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ int main(void)
|
||||||
|
|
||||||
Ray ray = { 0 }; // Picking ray
|
Ray ray = { 0 }; // Picking ray
|
||||||
|
|
||||||
Model tower = LoadModel("resources/models/turret.obj"); // Load OBJ model
|
Model tower = LoadModel("resources/models/obj/turret.obj"); // Load OBJ model
|
||||||
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load model texture
|
Texture2D texture = LoadTexture("resources/models/obj/turret_diffuse.png"); // Load model texture
|
||||||
tower.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture
|
tower.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture
|
||||||
|
|
||||||
Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position
|
Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,6 @@ int main(void)
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlRotatef(earthOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Earth orbit around Sun
|
rlRotatef(earthOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Earth orbit around Sun
|
||||||
rlTranslatef(earthOrbitRadius, 0.0f, 0.0f); // Translation for Earth orbit
|
rlTranslatef(earthOrbitRadius, 0.0f, 0.0f); // Translation for Earth orbit
|
||||||
rlRotatef(-earthOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Earth orbit around Sun inverted
|
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlRotatef(earthRotation, 0.25, 1.0, 0.0); // Rotation for Earth itself
|
rlRotatef(earthRotation, 0.25, 1.0, 0.0); // Rotation for Earth itself
|
||||||
|
|
@ -99,7 +98,6 @@ int main(void)
|
||||||
|
|
||||||
rlRotatef(moonOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Moon orbit around Earth
|
rlRotatef(moonOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Moon orbit around Earth
|
||||||
rlTranslatef(moonOrbitRadius, 0.0f, 0.0f); // Translation for Moon orbit
|
rlTranslatef(moonOrbitRadius, 0.0f, 0.0f); // Translation for Moon orbit
|
||||||
rlRotatef(-moonOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Moon orbit around Earth inverted
|
|
||||||
rlRotatef(moonRotation, 0.0f, 1.0f, 0.0f); // Rotation for Moon itself
|
rlRotatef(moonRotation, 0.0f, 1.0f, 0.0f); // Rotation for Moon itself
|
||||||
rlScalef(moonRadius, moonRadius, moonRadius); // Scale Moon
|
rlScalef(moonRadius, moonRadius, moonRadius); // Scale Moon
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,9 @@
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#include "rlgl.h"
|
#include "rlgl.h"
|
||||||
#include "raymath.h"
|
#include "raymath.h" // Required for: MatrixPerspective(), MatrixLookAt()
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,13 @@
|
||||||
*
|
*
|
||||||
* Example contributed by Berni (@Berni8k) and reviewed by Ramon Santamaria (@raysan5)
|
* Example contributed by Berni (@Berni8k) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2017 Berni (@Berni8k) and Ramon Santamaria (@raysan5)
|
* Copyright (c) 2017-2021 Berni (@Berni8k) and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "raymath.h"
|
|
||||||
|
#include "raymath.h" // Required for: MatrixRotateXYZ()
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
|
@ -31,9 +32,9 @@ int main(void)
|
||||||
camera.fovy = 30.0f; // Camera field-of-view Y
|
camera.fovy = 30.0f; // Camera field-of-view Y
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera type
|
camera.projection = CAMERA_PERSPECTIVE; // Camera type
|
||||||
|
|
||||||
// Model loading
|
Model model = LoadModel("resources/models/obj/plane.obj"); // Load model
|
||||||
// NOTE: Diffuse map loaded automatically
|
Texture2D texture = LoadTexture("resources/models/obj/plane_diffuse.png"); // Load model texture
|
||||||
Model model = LoadModel("resources/plane/plane.gltf");
|
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||||
|
|
||||||
float pitch = 0.0f;
|
float pitch = 0.0f;
|
||||||
float roll = 0.0f;
|
float roll = 0.0f;
|
||||||
|
|
@ -78,7 +79,6 @@ int main(void)
|
||||||
model.transform = MatrixRotateXYZ((Vector3){ DEG2RAD*pitch, DEG2RAD*yaw, DEG2RAD*roll });
|
model.transform = MatrixRotateXYZ((Vector3){ DEG2RAD*pitch, DEG2RAD*yaw, DEG2RAD*roll });
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
@ -88,7 +88,7 @@ int main(void)
|
||||||
// Draw 3D model (recomended to draw 3D always before 2D)
|
// Draw 3D model (recomended to draw 3D always before 2D)
|
||||||
BeginMode3D(camera);
|
BeginMode3D(camera);
|
||||||
|
|
||||||
DrawModel(model, (Vector3){ 0.0f, 0.0f, 15.0f }, 0.25f, WHITE); // Draw 3d model with texture
|
DrawModel(model, (Vector3){ 0.0f, -8.0f, 0.0f }, 1.0f, WHITE); // Draw 3d model with texture
|
||||||
DrawGrid(10, 10.0f);
|
DrawGrid(10, 10.0f);
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,19 @@
|
||||||
| resource | author | licence | notes |
|
| resource | author | licence | notes |
|
||||||
| :------------------- | :---------: | :------ | :---- |
|
| :------------------- | :---------: | :------ | :---- |
|
||||||
| models/castle.obj,<br> models/castle_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
| models/obj/castle.obj,<br>models/castle_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
||||||
| models/bridge.obj,<br> models/bridge_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
| models/obj/bridge.obj,<br>models/bridge_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
||||||
| models/house.obj,<br> models/house_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
| models/obj/house.obj,<br>models/house_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
||||||
| models/market.obj,<br> models/market_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
| models/obj/market.obj,<br>models/market_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
||||||
| models/turret.obj,<br> models/turret_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
| models/obj/turret.obj,<br>models/turret_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
||||||
| models/well.obj,<br> models/well_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
| models/obj/well.obj,<br>models/well_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
||||||
| models/cube.obj,<br> models/cube_diffuse.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
| models/obj/cube.obj,<br>models/cube_diffuse.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||||
| models/vertex_colored_object.iqm | ❔ | ❔ | - |
|
| models/obj/plane.gltf,<br>models/gltf/plane/plane.bin,<br>models/gltf/plane/plane_diffuse.png | [GiaHanLam](https://sketchfab.com/GiaHanLam) | [CC-BY](https://creativecommons.org/licenses/by/4.0/) | Used by: [`models_yaw_pitch_roll.c`](https://github.com/raysan5/raylib/blob/master/examples/models/models_yaw_pitch_roll.c)
|
||||||
|
| models/iqm/guy.iqm,<br>models/iqm/guyanim.iqm,<br>models/iqm/guytex.png,<br>models/iqm/guy.blend | [@culacant](https://github.com/culacant) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||||
|
| models/iqm/vertex_colored_object.iqm | ❔ | ❔ | - |
|
||||||
|
| models/gltf/... | _various_ | Check [LICENSE](https://github.com/raysan5/raylib/blob/master/examples/models/resources/models/gltf/LICENSE) | - |
|
||||||
|
| models/vox/chr_knight.vox | ❔ | ❔ | - |
|
||||||
|
| models/vox/chr_sword.vox | ❔ | ❔ | - |
|
||||||
|
| models/vox/monu9.vox | ❔ | ❔ | - |
|
||||||
| billboard.png | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
| billboard.png | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||||
| cubicmap.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
| cubicmap.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||||
| cubicmap_atlas.png | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
| cubicmap_atlas.png | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||||
|
|
@ -15,6 +21,3 @@
|
||||||
| dresden_square_1k.hdr | [HDRIHaven](https://hdrihaven.com/hdri/?h=dresden_square) | [CC0](https://hdrihaven.com/p/license.php) | - |
|
| dresden_square_1k.hdr | [HDRIHaven](https://hdrihaven.com/hdri/?h=dresden_square) | [CC0](https://hdrihaven.com/p/license.php) | - |
|
||||||
| dresden_square_2k.hdr | [HDRIHaven](https://hdrihaven.com/hdri/?h=dresden_square) | [CC0](https://hdrihaven.com/p/license.php) | - |
|
| dresden_square_2k.hdr | [HDRIHaven](https://hdrihaven.com/hdri/?h=dresden_square) | [CC0](https://hdrihaven.com/p/license.php) | - |
|
||||||
| skybox.png | ❔ | ❔ | - |
|
| skybox.png | ❔ | ❔ | - |
|
||||||
| **guy/...** | [@culacant](https://github.com/culacant) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
|
||||||
| **plane/...** | [GiaHanLam](https://sketchfab.com/GiaHanLam) | [CC-BY](https://creativecommons.org/licenses/by/4.0/) | Used by: [`models_yaw_pitch_roll.c`](https://github.com/raysan5/raylib/blob/master/examples/models/models_yaw_pitch_roll.c)
|
|
||||||
| **gltf/...** | _various_ | [LICENSE](https://github.com/raysan5/raylib/blob/master/examples/models/resources/gltf/LICENSE) | - |
|
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 295 KiB After Width: | Height: | Size: 295 KiB |
|
Before Width: | Height: | Size: 311 KiB After Width: | Height: | Size: 311 KiB |
|
Before Width: | Height: | Size: 434 KiB After Width: | Height: | Size: 434 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 383 KiB After Width: | Height: | Size: 383 KiB |
|
Before Width: | Height: | Size: 380 KiB After Width: | Height: | Size: 380 KiB |
10858
examples/models/resources/models/obj/plane.obj
Normal file
|
Before Width: | Height: | Size: 804 KiB After Width: | Height: | Size: 804 KiB |
|
Before Width: | Height: | Size: 371 KiB After Width: | Height: | Size: 371 KiB |
|
Before Width: | Height: | Size: 334 KiB After Width: | Height: | Size: 334 KiB |
9
examples/models/resources/models/vox/LICENSE
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
The following models are provided by the official github repo of voxel-model format by MagikaVoxel developer @ephtracy
|
||||||
|
|
||||||
|
GitHub official repo: https://github.com/ephtracy/voxel-model
|
||||||
|
|
||||||
|
- chr_knight.vox - https://github.com/ephtracy/voxel-model/blob/master/vox/character/chr_knight.vox
|
||||||
|
- chr_sword.vox - https://github.com/ephtracy/voxel-model/blob/master/vox/character/chr_sword.vox
|
||||||
|
- monu9.vox - https://github.com/ephtracy/voxel-model/blob/master/vox/monument/monu9.vox
|
||||||
|
|
||||||
|
Worth mentioning there is no license specified for the models yet: https://github.com/ephtracy/voxel-model/issues/22
|
||||||
|
Before Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 547 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 717 KiB |
|
|
@ -1,9 +0,0 @@
|
||||||
WWI Plane Model created by GiaHanLam (https://sketchfab.com/GiaHanLam)
|
|
||||||
This model is free to use, licensed as Creative Commons Attribution (CC-BY 4.0)
|
|
||||||
|
|
||||||
License details: https://creativecommons.org/licenses/by/4.0/
|
|
||||||
|
|
||||||
As per the license, author must be credited and commercial use is allowed.
|
|
||||||
|
|
||||||
This model was donwload from author Sketchfab account: https://sketchfab.com/3d-models/wwi-plane-model-f0d39a6daacd4925a8922db193886715
|
|
||||||
|
|
||||||
|
|
@ -1,327 +0,0 @@
|
||||||
{
|
|
||||||
"accessors": [
|
|
||||||
{
|
|
||||||
"bufferView": 2,
|
|
||||||
"componentType": 5126,
|
|
||||||
"count": 3446,
|
|
||||||
"max": [
|
|
||||||
143.99604797363281,
|
|
||||||
168.74668884277344,
|
|
||||||
75.31597900390625
|
|
||||||
],
|
|
||||||
"min": [
|
|
||||||
-143.99604797363281,
|
|
||||||
-43.94732666015625,
|
|
||||||
-49.556678771972656
|
|
||||||
],
|
|
||||||
"type": "VEC3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView": 2,
|
|
||||||
"byteOffset": 41352,
|
|
||||||
"componentType": 5126,
|
|
||||||
"count": 3446,
|
|
||||||
"max": [
|
|
||||||
1,
|
|
||||||
0.99916732311248779,
|
|
||||||
0.99978786706924438
|
|
||||||
],
|
|
||||||
"min": [
|
|
||||||
-1,
|
|
||||||
-0.99928808212280273,
|
|
||||||
-0.99977350234985352
|
|
||||||
],
|
|
||||||
"type": "VEC3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView": 3,
|
|
||||||
"componentType": 5126,
|
|
||||||
"count": 3446,
|
|
||||||
"max": [
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"min": [
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"type": "VEC4"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView": 1,
|
|
||||||
"componentType": 5126,
|
|
||||||
"count": 3446,
|
|
||||||
"max": [
|
|
||||||
4.8965663909912109,
|
|
||||||
0.99786919355392456
|
|
||||||
],
|
|
||||||
"min": [
|
|
||||||
0.0036561768501996994,
|
|
||||||
0.0083234198391437531
|
|
||||||
],
|
|
||||||
"type": "VEC2"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView": 0,
|
|
||||||
"componentType": 5125,
|
|
||||||
"count": 7692,
|
|
||||||
"max": [
|
|
||||||
3445
|
|
||||||
],
|
|
||||||
"min": [
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"type": "SCALAR"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"asset": {
|
|
||||||
"extras": {
|
|
||||||
"author": "GiaHanLam (https://sketchfab.com/GiaHanLam)",
|
|
||||||
"license": "CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)",
|
|
||||||
"source": "https://sketchfab.com/3d-models/wwi-plane-model-f0d39a6daacd4925a8922db193886715",
|
|
||||||
"title": "WWI Plane Model"
|
|
||||||
},
|
|
||||||
"generator": "Sketchfab-8.25.0",
|
|
||||||
"version": "2.0"
|
|
||||||
},
|
|
||||||
"bufferViews": [
|
|
||||||
{
|
|
||||||
"buffer": 0,
|
|
||||||
"byteLength": 30768,
|
|
||||||
"byteOffset": 0,
|
|
||||||
"name": "floatBufferViews",
|
|
||||||
"target": 34963
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"buffer": 0,
|
|
||||||
"byteLength": 27568,
|
|
||||||
"byteOffset": 30768,
|
|
||||||
"byteStride": 8,
|
|
||||||
"name": "floatBufferViews",
|
|
||||||
"target": 34962
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"buffer": 0,
|
|
||||||
"byteLength": 82704,
|
|
||||||
"byteOffset": 58336,
|
|
||||||
"byteStride": 12,
|
|
||||||
"name": "floatBufferViews",
|
|
||||||
"target": 34962
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"buffer": 0,
|
|
||||||
"byteLength": 55136,
|
|
||||||
"byteOffset": 141040,
|
|
||||||
"byteStride": 16,
|
|
||||||
"name": "floatBufferViews",
|
|
||||||
"target": 34962
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"buffers": [
|
|
||||||
{
|
|
||||||
"byteLength": 196176,
|
|
||||||
"uri": "plane.bin"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"images": [
|
|
||||||
{
|
|
||||||
"uri": "plane_diffuse.png"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"materials": [
|
|
||||||
{
|
|
||||||
"doubleSided": true,
|
|
||||||
"name": "Material_24",
|
|
||||||
"pbrMetallicRoughness": {
|
|
||||||
"baseColorFactor": [
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"baseColorTexture": {
|
|
||||||
"index": 0,
|
|
||||||
"texCoord": 0
|
|
||||||
},
|
|
||||||
"metallicFactor": 0,
|
|
||||||
"roughnessFactor": 0.59999999999999998
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"meshes": [
|
|
||||||
{
|
|
||||||
"name": "BODY_Material #24_0",
|
|
||||||
"primitives": [
|
|
||||||
{
|
|
||||||
"attributes": {
|
|
||||||
"COLOR_0": 2,
|
|
||||||
"NORMAL": 1,
|
|
||||||
"POSITION": 0,
|
|
||||||
"TEXCOORD_0": 3
|
|
||||||
},
|
|
||||||
"indices": 4,
|
|
||||||
"material": 0,
|
|
||||||
"mode": 4
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"children": [
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"name": "RootNode (gltf orientation matrix)",
|
|
||||||
"rotation": [
|
|
||||||
-0.70710678118654746,
|
|
||||||
-0,
|
|
||||||
-0,
|
|
||||||
0.70710678118654757
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"children": [
|
|
||||||
2
|
|
||||||
],
|
|
||||||
"name": "RootNode (model correction matrix)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"children": [
|
|
||||||
3
|
|
||||||
],
|
|
||||||
"matrix": [
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
-1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"name": "base"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"children": [
|
|
||||||
4,
|
|
||||||
6
|
|
||||||
],
|
|
||||||
"name": "RootNode"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"children": [
|
|
||||||
5
|
|
||||||
],
|
|
||||||
"matrix": [
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
2.2204460492503131e-16,
|
|
||||||
-1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
2.2204460492503131e-16,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"name": "BODY"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mesh": 0,
|
|
||||||
"name": "BODY_Material #24_0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"children": [
|
|
||||||
7
|
|
||||||
],
|
|
||||||
"matrix": [
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
-680,
|
|
||||||
0,
|
|
||||||
90,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"name": "Sky001"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"children": [
|
|
||||||
8
|
|
||||||
],
|
|
||||||
"matrix": [
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
2.2204460492503131e-16,
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
-1,
|
|
||||||
2.2204460492503131e-16,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1
|
|
||||||
],
|
|
||||||
"name": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": ""
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"samplers": [
|
|
||||||
{
|
|
||||||
"magFilter": 9729,
|
|
||||||
"minFilter": 9987,
|
|
||||||
"wrapS": 10497,
|
|
||||||
"wrapT": 10497
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"scene": 0,
|
|
||||||
"scenes": [
|
|
||||||
{
|
|
||||||
"name": "OSG_Scene",
|
|
||||||
"nodes": [
|
|
||||||
0
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"textures": [
|
|
||||||
{
|
|
||||||
"sampler": 0,
|
|
||||||
"source": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,124 +0,0 @@
|
||||||
#version 330
|
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
|
||||||
in vec2 fragTexCoord;
|
|
||||||
|
|
||||||
// Constant values
|
|
||||||
const float PI = 3.14159265359;
|
|
||||||
const uint MAX_SAMPLES = 1024u;
|
|
||||||
|
|
||||||
// Output fragment color
|
|
||||||
out vec4 finalColor;
|
|
||||||
|
|
||||||
vec2 Hammersley(uint i, uint N);
|
|
||||||
float RadicalInverseVdC(uint bits);
|
|
||||||
float GeometrySchlickGGX(float NdotV, float roughness);
|
|
||||||
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness);
|
|
||||||
vec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness);
|
|
||||||
vec2 IntegrateBRDF(float NdotV, float roughness);
|
|
||||||
|
|
||||||
float RadicalInverseVdC(uint bits)
|
|
||||||
{
|
|
||||||
bits = (bits << 16u) | (bits >> 16u);
|
|
||||||
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
|
|
||||||
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
|
|
||||||
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
|
|
||||||
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
|
|
||||||
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute Hammersley coordinates
|
|
||||||
vec2 Hammersley(uint i, uint N)
|
|
||||||
{
|
|
||||||
return vec2(float(i)/float(N), RadicalInverseVdC(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Integrate number of importance samples for (roughness and NoV)
|
|
||||||
vec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness)
|
|
||||||
{
|
|
||||||
float a = roughness*roughness;
|
|
||||||
float phi = 2.0 * PI * Xi.x;
|
|
||||||
float cosTheta = sqrt((1.0 - Xi.y)/(1.0 + (a*a - 1.0)*Xi.y));
|
|
||||||
float sinTheta = sqrt(1.0 - cosTheta*cosTheta);
|
|
||||||
|
|
||||||
// Transform from spherical coordinates to cartesian coordinates (halfway vector)
|
|
||||||
vec3 H = vec3(cos(phi)*sinTheta, sin(phi)*sinTheta, cosTheta);
|
|
||||||
|
|
||||||
// Transform from tangent space H vector to world space sample vector
|
|
||||||
vec3 up = ((abs(N.z) < 0.999) ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0));
|
|
||||||
vec3 tangent = normalize(cross(up, N));
|
|
||||||
vec3 bitangent = cross(N, tangent);
|
|
||||||
vec3 sampleVec = tangent*H.x + bitangent*H.y + N*H.z;
|
|
||||||
|
|
||||||
return normalize(sampleVec);
|
|
||||||
}
|
|
||||||
|
|
||||||
float GeometrySchlickGGX(float NdotV, float roughness)
|
|
||||||
{
|
|
||||||
// For IBL k is calculated different
|
|
||||||
float k = (roughness*roughness)/2.0;
|
|
||||||
|
|
||||||
float nom = NdotV;
|
|
||||||
float denom = NdotV*(1.0 - k) + k;
|
|
||||||
|
|
||||||
return nom/denom;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute the geometry term for the BRDF given roughness squared, NoV, NoL
|
|
||||||
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness)
|
|
||||||
{
|
|
||||||
float NdotV = max(dot(N, V), 0.0);
|
|
||||||
float NdotL = max(dot(N, L), 0.0);
|
|
||||||
float ggx2 = GeometrySchlickGGX(NdotV, roughness);
|
|
||||||
float ggx1 = GeometrySchlickGGX(NdotL, roughness);
|
|
||||||
|
|
||||||
return ggx1*ggx2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bidirectional reflectance distribution function
|
|
||||||
// Ref: https://github.com/HectorMF/BRDFGenerator
|
|
||||||
vec2 IntegrateBRDF(float NdotV, float roughness)
|
|
||||||
{
|
|
||||||
float A = 0.0;
|
|
||||||
float B = 0.0;
|
|
||||||
vec3 V = vec3(sqrt(1.0 - NdotV*NdotV), 0.0, NdotV);
|
|
||||||
vec3 N = vec3(0.0, 0.0, 1.0);
|
|
||||||
|
|
||||||
for (uint i = 0u; i < MAX_SAMPLES; i++)
|
|
||||||
{
|
|
||||||
// Generate a sample vector that's biased towards the preferred alignment direction (importance sampling)
|
|
||||||
|
|
||||||
vec2 Xi = Hammersley(i, MAX_SAMPLES); // Compute a Hammersely coordinate
|
|
||||||
vec3 H = ImportanceSampleGGX(Xi, N, roughness); // Integrate number of importance samples for (roughness and NoV)
|
|
||||||
vec3 L = normalize(2.0*dot(V, H)*H - V); // Compute reflection vector L
|
|
||||||
|
|
||||||
float NdotL = max(L.z, 0.0); // Compute normal dot light
|
|
||||||
float NdotH = max(H.z, 0.0); // Compute normal dot half
|
|
||||||
float VdotH = max(dot(V, H), 0.0); // Compute view dot half
|
|
||||||
|
|
||||||
if (NdotL > 0.0)
|
|
||||||
{
|
|
||||||
float G = GeometrySmith(N, V, L, roughness); // Compute the geometry term for the BRDF given roughness squared, NoV, NoL
|
|
||||||
float GVis = (G*VdotH)/(NdotH*NdotV); // Compute the visibility term given G, VoH, NoH, NoV, NoL
|
|
||||||
float Fc = pow(1.0 - VdotH, 5.0); // Compute the fresnel term given VoH
|
|
||||||
|
|
||||||
A += (1.0 - Fc)*GVis; // Sum the result given fresnel, geometry, visibility
|
|
||||||
B += Fc*GVis;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate brdf average sample
|
|
||||||
A /= float(MAX_SAMPLES);
|
|
||||||
B /= float(MAX_SAMPLES);
|
|
||||||
|
|
||||||
return vec2(A, B);
|
|
||||||
}
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
// Calculate brdf based on texture coordinates
|
|
||||||
vec2 brdf = IntegrateBRDF(fragTexCoord.x, fragTexCoord.y);
|
|
||||||
|
|
||||||
// Calculate final fragment color
|
|
||||||
finalColor = vec4(brdf.r, brdf.g, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
#version 330
|
|
||||||
|
|
||||||
// Input vertex attributes
|
|
||||||
in vec3 vertexPosition;
|
|
||||||
in vec2 vertexTexCoord;
|
|
||||||
|
|
||||||
// Output vertex attributes (to fragment shader)
|
|
||||||
out vec2 fragTexCoord;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
// Calculate fragment position based on model transformations
|
|
||||||
fragTexCoord = vertexTexCoord;
|
|
||||||
|
|
||||||
// Calculate final vertex position
|
|
||||||
gl_Position = vec4(vertexPosition, 1.0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
#version 330
|
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
|
||||||
in vec3 fragPosition;
|
|
||||||
|
|
||||||
// Input uniform values
|
|
||||||
uniform samplerCube environmentMap;
|
|
||||||
|
|
||||||
// Constant values
|
|
||||||
const float PI = 3.14159265359;
|
|
||||||
|
|
||||||
// Output fragment color
|
|
||||||
out vec4 finalColor;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
// The sample direction equals the hemisphere's orientation
|
|
||||||
vec3 normal = normalize(fragPosition);
|
|
||||||
|
|
||||||
vec3 irradiance = vec3(0.0);
|
|
||||||
|
|
||||||
vec3 up = vec3(0.0, 1.0, 0.0);
|
|
||||||
vec3 right = cross(up, normal);
|
|
||||||
up = cross(normal, right);
|
|
||||||
|
|
||||||
float sampleDelta = 0.025;
|
|
||||||
float nrSamples = 0.0;
|
|
||||||
|
|
||||||
for (float phi = 0.0; phi < 2.0*PI; phi += sampleDelta)
|
|
||||||
{
|
|
||||||
for (float theta = 0.0; theta < 0.5*PI; theta += sampleDelta)
|
|
||||||
{
|
|
||||||
// Spherical to cartesian (in tangent space)
|
|
||||||
vec3 tangentSample = vec3(sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta));
|
|
||||||
|
|
||||||
// tangent space to world
|
|
||||||
vec3 sampleVec = tangentSample.x*right + tangentSample.y*up + tangentSample.z*normal;
|
|
||||||
|
|
||||||
// Fetch color from environment cubemap
|
|
||||||
irradiance += texture(environmentMap, sampleVec).rgb*cos(theta)*sin(theta);
|
|
||||||
nrSamples++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate irradiance average value from samples
|
|
||||||
irradiance = PI*irradiance*(1.0/float(nrSamples));
|
|
||||||
|
|
||||||
// Calculate final fragment color
|
|
||||||
finalColor = vec4(irradiance, 1.0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,292 +0,0 @@
|
||||||
#version 330
|
|
||||||
|
|
||||||
#define MAX_REFLECTION_LOD 4.0
|
|
||||||
#define MAX_DEPTH_LAYER 20
|
|
||||||
#define MIN_DEPTH_LAYER 10
|
|
||||||
|
|
||||||
#define MAX_LIGHTS 4
|
|
||||||
#define LIGHT_DIRECTIONAL 0
|
|
||||||
#define LIGHT_POINT 1
|
|
||||||
|
|
||||||
struct MaterialProperty {
|
|
||||||
vec3 color;
|
|
||||||
int useSampler;
|
|
||||||
sampler2D sampler;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Light {
|
|
||||||
int enabled;
|
|
||||||
int type;
|
|
||||||
vec3 position;
|
|
||||||
vec3 target;
|
|
||||||
vec4 color;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
|
||||||
in vec3 fragPosition;
|
|
||||||
in vec2 fragTexCoord;
|
|
||||||
in vec3 fragNormal;
|
|
||||||
in vec3 fragTangent;
|
|
||||||
in vec3 fragBinormal;
|
|
||||||
|
|
||||||
// Input material values
|
|
||||||
uniform MaterialProperty albedo;
|
|
||||||
uniform MaterialProperty normals;
|
|
||||||
uniform MaterialProperty metalness;
|
|
||||||
uniform MaterialProperty roughness;
|
|
||||||
uniform MaterialProperty occlusion;
|
|
||||||
uniform MaterialProperty emission;
|
|
||||||
uniform MaterialProperty height;
|
|
||||||
|
|
||||||
// Input uniform values
|
|
||||||
uniform samplerCube irradianceMap;
|
|
||||||
uniform samplerCube prefilterMap;
|
|
||||||
uniform sampler2D brdfLUT;
|
|
||||||
|
|
||||||
// Input lighting values
|
|
||||||
uniform Light lights[MAX_LIGHTS];
|
|
||||||
|
|
||||||
// Other uniform values
|
|
||||||
uniform int renderMode;
|
|
||||||
uniform vec3 viewPos;
|
|
||||||
vec2 texCoord;
|
|
||||||
|
|
||||||
// Constant values
|
|
||||||
const float PI = 3.14159265359;
|
|
||||||
|
|
||||||
// Output fragment color
|
|
||||||
out vec4 finalColor;
|
|
||||||
|
|
||||||
vec3 ComputeMaterialProperty(MaterialProperty property);
|
|
||||||
float DistributionGGX(vec3 N, vec3 H, float roughness);
|
|
||||||
float GeometrySchlickGGX(float NdotV, float roughness);
|
|
||||||
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness);
|
|
||||||
vec3 fresnelSchlick(float cosTheta, vec3 F0);
|
|
||||||
vec3 fresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness);
|
|
||||||
vec2 ParallaxMapping(vec2 texCoords, vec3 viewDir);
|
|
||||||
|
|
||||||
// WARNING: There is some weird behaviour with this function, always returns black!
|
|
||||||
// Yes, I even tried: return texture(property.sampler, texCoord).rgb;
|
|
||||||
vec3 ComputeMaterialProperty(MaterialProperty property)
|
|
||||||
{
|
|
||||||
vec3 result = vec3(0.0, 0.0, 0.0);
|
|
||||||
|
|
||||||
if (property.useSampler == 1) result = texture(property.sampler, texCoord).rgb;
|
|
||||||
else result = property.color;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
float DistributionGGX(vec3 N, vec3 H, float roughness)
|
|
||||||
{
|
|
||||||
float a = roughness*roughness;
|
|
||||||
float a2 = a*a;
|
|
||||||
float NdotH = max(dot(N, H), 0.0);
|
|
||||||
float NdotH2 = NdotH*NdotH;
|
|
||||||
|
|
||||||
float nom = a2;
|
|
||||||
float denom = (NdotH2*(a2 - 1.0) + 1.0);
|
|
||||||
denom = PI*denom*denom;
|
|
||||||
|
|
||||||
return nom/denom;
|
|
||||||
}
|
|
||||||
|
|
||||||
float GeometrySchlickGGX(float NdotV, float roughness)
|
|
||||||
{
|
|
||||||
float r = (roughness + 1.0);
|
|
||||||
float k = r*r/8.0;
|
|
||||||
|
|
||||||
float nom = NdotV;
|
|
||||||
float denom = NdotV*(1.0 - k) + k;
|
|
||||||
|
|
||||||
return nom/denom;
|
|
||||||
}
|
|
||||||
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness)
|
|
||||||
{
|
|
||||||
float NdotV = max(dot(N, V), 0.0);
|
|
||||||
float NdotL = max(dot(N, L), 0.0);
|
|
||||||
float ggx2 = GeometrySchlickGGX(NdotV, roughness);
|
|
||||||
float ggx1 = GeometrySchlickGGX(NdotL, roughness);
|
|
||||||
|
|
||||||
return ggx1*ggx2;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 fresnelSchlick(float cosTheta, vec3 F0)
|
|
||||||
{
|
|
||||||
return F0 + (1.0 - F0)*pow(1.0 - cosTheta, 5.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 fresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness)
|
|
||||||
{
|
|
||||||
return F0 + (max(vec3(1.0 - roughness), F0) - F0)*pow(1.0 - cosTheta, 5.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec2 ParallaxMapping(vec2 texCoords, vec3 viewDir)
|
|
||||||
{
|
|
||||||
// Calculate the number of depth layers and calculate the size of each layer
|
|
||||||
float numLayers = mix(MAX_DEPTH_LAYER, MIN_DEPTH_LAYER, abs(dot(vec3(0.0, 0.0, 1.0), viewDir)));
|
|
||||||
float layerDepth = 1.0/numLayers;
|
|
||||||
|
|
||||||
// Calculate depth of current layer
|
|
||||||
float currentLayerDepth = 0.0;
|
|
||||||
|
|
||||||
// Calculate the amount to shift the texture coordinates per layer (from vector P)
|
|
||||||
// Note: height amount is stored in height material attribute color R channel (sampler use is independent)
|
|
||||||
vec2 P = viewDir.xy*height.color.r;
|
|
||||||
vec2 deltaTexCoords = P/numLayers;
|
|
||||||
|
|
||||||
// Store initial texture coordinates and depth values
|
|
||||||
vec2 currentTexCoords = texCoords;
|
|
||||||
float currentDepthMapValue = texture(height.sampler, currentTexCoords).r;
|
|
||||||
|
|
||||||
while (currentLayerDepth < currentDepthMapValue)
|
|
||||||
{
|
|
||||||
// Shift texture coordinates along direction of P
|
|
||||||
currentTexCoords -= deltaTexCoords;
|
|
||||||
|
|
||||||
// Get depth map value at current texture coordinates
|
|
||||||
currentDepthMapValue = texture(height.sampler, currentTexCoords).r;
|
|
||||||
|
|
||||||
// Get depth of next layer
|
|
||||||
currentLayerDepth += layerDepth;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get texture coordinates before collision (reverse operations)
|
|
||||||
vec2 prevTexCoords = currentTexCoords + deltaTexCoords;
|
|
||||||
|
|
||||||
// Get depth after and before collision for linear interpolation
|
|
||||||
float afterDepth = currentDepthMapValue - currentLayerDepth;
|
|
||||||
float beforeDepth = texture(height.sampler, prevTexCoords).r - currentLayerDepth + layerDepth;
|
|
||||||
|
|
||||||
// Interpolation of texture coordinates
|
|
||||||
float weight = afterDepth/(afterDepth - beforeDepth);
|
|
||||||
vec2 finalTexCoords = prevTexCoords*weight + currentTexCoords*(1.0 - weight);
|
|
||||||
|
|
||||||
return finalTexCoords;
|
|
||||||
}
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
// Calculate TBN and RM matrices
|
|
||||||
mat3 TBN = transpose(mat3(fragTangent, fragBinormal, fragNormal));
|
|
||||||
|
|
||||||
// Calculate lighting required attributes
|
|
||||||
vec3 normal = normalize(fragNormal);
|
|
||||||
vec3 view = normalize(viewPos - fragPosition);
|
|
||||||
vec3 refl = reflect(-view, normal);
|
|
||||||
|
|
||||||
// Check if parallax mapping is enabled and calculate texture coordinates to use based on height map
|
|
||||||
// NOTE: remember that 'texCoord' variable must be assigned before calling any ComputeMaterialProperty() function
|
|
||||||
if (height.useSampler == 1) texCoord = ParallaxMapping(fragTexCoord, view);
|
|
||||||
else texCoord = fragTexCoord; // Use default texture coordinates
|
|
||||||
|
|
||||||
// Fetch material values from texture sampler or color attributes
|
|
||||||
vec3 color = texture(albedo.sampler, texCoord).rgb; //ComputeMaterialProperty(albedo);
|
|
||||||
vec3 metal = texture(metalness.sampler, texCoord).rgb; //ComputeMaterialProperty(metalness);
|
|
||||||
vec3 rough = texture(roughness.sampler, texCoord).rgb; //ComputeMaterialProperty(roughness);
|
|
||||||
vec3 emiss = texture(emission.sampler, texCoord).rgb; //ComputeMaterialProperty(emission);
|
|
||||||
vec3 ao = texture(occlusion.sampler, texCoord).rgb; //ComputeMaterialProperty(occlusion);
|
|
||||||
|
|
||||||
// Check if normal mapping is enabled
|
|
||||||
if (normals.useSampler == 1)
|
|
||||||
{
|
|
||||||
// Fetch normal map color and transform lighting values to tangent space
|
|
||||||
normal = texture(normals.sampler, texCoord).rgb; //ComputeMaterialProperty(normals);
|
|
||||||
normal = normalize(normal*2.0 - 1.0);
|
|
||||||
normal = normalize(normal*TBN);
|
|
||||||
|
|
||||||
// Convert tangent space normal to world space due to cubemap reflection calculations
|
|
||||||
refl = normalize(reflect(-view, normal));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate reflectance at normal incidence
|
|
||||||
vec3 F0 = vec3(0.04);
|
|
||||||
F0 = mix(F0, color, metal.r);
|
|
||||||
|
|
||||||
// Calculate lighting for all lights
|
|
||||||
vec3 Lo = vec3(0.0);
|
|
||||||
vec3 lightDot = vec3(0.0);
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_LIGHTS; i++)
|
|
||||||
{
|
|
||||||
if (lights[i].enabled == 1)
|
|
||||||
{
|
|
||||||
// Calculate per-light radiance
|
|
||||||
vec3 light = vec3(0.0);
|
|
||||||
vec3 radiance = lights[i].color.rgb;
|
|
||||||
if (lights[i].type == LIGHT_DIRECTIONAL) light = -normalize(lights[i].target - lights[i].position);
|
|
||||||
else if (lights[i].type == LIGHT_POINT)
|
|
||||||
{
|
|
||||||
light = normalize(lights[i].position - fragPosition);
|
|
||||||
float distance = length(lights[i].position - fragPosition);
|
|
||||||
float attenuation = 1.0/(distance*distance);
|
|
||||||
radiance *= attenuation;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cook-torrance BRDF
|
|
||||||
vec3 high = normalize(view + light);
|
|
||||||
float NDF = DistributionGGX(normal, high, rough.r);
|
|
||||||
float G = GeometrySmith(normal, view, light, rough.r);
|
|
||||||
vec3 F = fresnelSchlick(max(dot(high, view), 0.0), F0);
|
|
||||||
vec3 nominator = NDF*G*F;
|
|
||||||
float denominator = 4*max(dot(normal, view), 0.0)*max(dot(normal, light), 0.0) + 0.001;
|
|
||||||
vec3 brdf = nominator/denominator;
|
|
||||||
|
|
||||||
// Store to kS the fresnel value and calculate energy conservation
|
|
||||||
vec3 kS = F;
|
|
||||||
vec3 kD = vec3(1.0) - kS;
|
|
||||||
|
|
||||||
// Multiply kD by the inverse metalness such that only non-metals have diffuse lighting
|
|
||||||
kD *= 1.0 - metal.r;
|
|
||||||
|
|
||||||
// Scale light by dot product between normal and light direction
|
|
||||||
float NdotL = max(dot(normal, light), 0.0);
|
|
||||||
|
|
||||||
// Add to outgoing radiance Lo
|
|
||||||
// Note: BRDF is already multiplied by the Fresnel so it doesn't need to be multiplied again
|
|
||||||
Lo += (kD*color/PI + brdf)*radiance*NdotL*lights[i].color.a;
|
|
||||||
lightDot += radiance*NdotL + brdf*lights[i].color.a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate ambient lighting using IBL
|
|
||||||
vec3 F = fresnelSchlickRoughness(max(dot(normal, view), 0.0), F0, rough.r);
|
|
||||||
vec3 kS = F;
|
|
||||||
vec3 kD = 1.0 - kS;
|
|
||||||
kD *= 1.0 - metal.r;
|
|
||||||
|
|
||||||
// Calculate indirect diffuse
|
|
||||||
vec3 irradiance = texture(irradianceMap, fragNormal).rgb;
|
|
||||||
vec3 diffuse = color*irradiance;
|
|
||||||
|
|
||||||
// Sample both the prefilter map and the BRDF lut and combine them together as per the Split-Sum approximation
|
|
||||||
vec3 prefilterColor = textureLod(prefilterMap, refl, rough.r*MAX_REFLECTION_LOD).rgb;
|
|
||||||
vec2 brdf = texture(brdfLUT, vec2(max(dot(normal, view), 0.0), rough.r)).rg;
|
|
||||||
vec3 reflection = prefilterColor*(F*brdf.x + brdf.y);
|
|
||||||
|
|
||||||
// Calculate final lighting
|
|
||||||
vec3 ambient = (kD*diffuse + reflection)*ao;
|
|
||||||
|
|
||||||
// Calculate fragment color based on render mode
|
|
||||||
vec3 fragmentColor = ambient + Lo + emiss; // Physically Based Rendering
|
|
||||||
|
|
||||||
if (renderMode == 1) fragmentColor = color; // Albedo
|
|
||||||
else if (renderMode == 2) fragmentColor = normal; // Normals
|
|
||||||
else if (renderMode == 3) fragmentColor = metal; // Metalness
|
|
||||||
else if (renderMode == 4) fragmentColor = rough; // Roughness
|
|
||||||
else if (renderMode == 5) fragmentColor = ao; // Ambient Occlusion
|
|
||||||
else if (renderMode == 6) fragmentColor = emiss; // Emission
|
|
||||||
else if (renderMode == 7) fragmentColor = lightDot; // Lighting
|
|
||||||
else if (renderMode == 8) fragmentColor = kS; // Fresnel
|
|
||||||
else if (renderMode == 9) fragmentColor = irradiance; // Irradiance
|
|
||||||
else if (renderMode == 10) fragmentColor = reflection; // Reflection
|
|
||||||
|
|
||||||
// Apply HDR tonemapping
|
|
||||||
fragmentColor = fragmentColor/(fragmentColor + vec3(1.0));
|
|
||||||
|
|
||||||
// Apply gamma correction
|
|
||||||
fragmentColor = pow(fragmentColor, vec3(1.0/2.2));
|
|
||||||
|
|
||||||
// Calculate final fragment color
|
|
||||||
finalColor = vec4(fragmentColor, 1.0);
|
|
||||||
}
|
|
||||||