Merge branch 'master' into rlsw

This commit is contained in:
Ray 2025-08-31 12:27:48 +02:00 committed by GitHub
commit c32a4b6586
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
356 changed files with 27215 additions and 4602 deletions

View File

@ -3,7 +3,7 @@
# #
# You may wish to alter this file to override the set of languages analyzed, # You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic. # or to provide custom queries or build logic.
name: "CodeQL" name: Analyze raylib with CodeQL
on: on:
workflow_dispatch: workflow_dispatch:

View File

@ -1,4 +1,4 @@
name: Android name: Build raylib - Android
on: on:
workflow_dispatch: workflow_dispatch:

View File

@ -1,4 +1,4 @@
name: CMakeBuilds name: Build raylib CMake - Windows+Linux
on: on:
workflow_dispatch: workflow_dispatch:

View File

@ -1,4 +1,4 @@
name: Linux Examples name: Build raylib examples - Linux
on: on:
workflow_dispatch: workflow_dispatch:

View File

@ -1,4 +1,4 @@
name: Windows Examples name: Build raylib examples - Windows
on: on:
workflow_dispatch: workflow_dispatch:

View File

@ -1,4 +1,4 @@
name: Linux name: Build raylib - Linux
on: on:
workflow_dispatch: workflow_dispatch:
@ -22,22 +22,28 @@ jobs:
build: build:
permissions: permissions:
contents: write # for actions/upload-release-asset to upload release asset contents: write # for actions/upload-release-asset to upload release asset
runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
max-parallel: 1 max-parallel: 1
matrix: matrix:
bits: [32, 64]
include: include:
- bits: 32 - bits: 32
ARCH: "i386" ARCH: "i386"
ARCH_NAME: "i386" ARCH_NAME: "i386"
COMPILER_PATH: "/user/bin" COMPILER_PATH: "/usr/bin"
runner: "ubuntu-latest"
- bits: 64 - bits: 64
ARCH: "x86_64" ARCH: "x86_64"
ARCH_NAME: "amd64" ARCH_NAME: "amd64"
COMPILER_PATH: "/user/bin" COMPILER_PATH: "/usr/bin"
runner: "ubuntu-latest"
- bits: 64
ARCH: "aarch64"
ARCH_NAME: "arm64"
COMPILER_PATH: "/usr/bin"
runner: "ubuntu-24.04-arm"
runs-on: ${{ matrix.runner }}
env: env:
RELEASE_NAME: raylib-dev_linux_${{ matrix.ARCH_NAME }} RELEASE_NAME: raylib-dev_linux_${{ matrix.ARCH_NAME }}
@ -54,7 +60,6 @@ jobs:
- name: Setup Environment - name: Setup Environment
run: | run: |
sudo apt-get update -qq sudo apt-get update -qq
sudo apt-get install gcc-multilib
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libxkbcommon-dev sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libxkbcommon-dev
mkdir build mkdir build
cd build cd build
@ -64,9 +69,14 @@ jobs:
mkdir lib mkdir lib
cd ../../../raylib cd ../../../raylib
# ${{ matrix.ARCH }}-linux-gnu-gcc -v # ${{ matrix.ARCH }}-linux-gnu-gcc -v
- name: Setup Environment (x86)
run : |
sudo apt-get install gcc-multilib
if: matrix.bits == 32 && matrix.ARCH == 'i386'
# TODO: Support 32bit (i386) static/shared library building # TODO: Support 32bit (i386) static/shared library building
- name: Build Library - name: Build Library (32-bit)
run: | run: |
cd src cd src
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=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CUSTOM_CFLAGS="-m32" -B
@ -74,13 +84,21 @@ jobs:
cd .. cd ..
if: matrix.bits == 32 if: matrix.bits == 32
- name: Build Library - name: Build Library (64-bit x86)
run: | run: |
cd src cd src
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=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 && matrix.ARCH == 'x86_64'
- name: Build Library (64-bit ARM)
run: |
cd src
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
cd ..
if: matrix.bits == 64 && matrix.ARCH == 'aarch64'
- name: Generate Artifacts - name: Generate Artifacts
run: | run: |

View File

@ -1,4 +1,4 @@
name: macOS name: Build raylib - macOS
on: on:
workflow_dispatch: workflow_dispatch:

View File

@ -1,4 +1,4 @@
name: WebAssembly name: Build raylib - WebAssembly
on: on:
workflow_dispatch: workflow_dispatch:

View File

@ -1,4 +1,4 @@
name: Windows name: Build raylib - Windows
on: on:
workflow_dispatch: workflow_dispatch:
@ -54,7 +54,6 @@ jobs:
- compiler: mingw-w64 - compiler: mingw-w64
ziptarget: winarm64 # We don't build arm64 with mingw-w64 yet ziptarget: winarm64 # We don't build arm64 with mingw-w64 yet
env: env:
RELEASE_NAME: raylib-dev_${{ matrix.ziptarget }}_${{ matrix.compiler }} RELEASE_NAME: raylib-dev_${{ matrix.ziptarget }}_${{ matrix.compiler }}
GNUTARGET: default GNUTARGET: default

View File

@ -1,37 +1,37 @@
name: Parse raylib_api name: Parse raylib API
on: on:
workflow_dispatch: workflow_dispatch:
push: push:
paths: paths:
- "src/raylib.h" - "src/raylib.h"
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Update parse files - name: Update parse files
working-directory: parser working-directory: tools/parser
run: | run: |
make raylib_api make raylib_api
mv raylib_api.* output mv raylib_api.* output
- name: Diff parse files - name: Diff parse files
id: diff id: diff
run: | run: |
git add -N parser git add -N parser
git diff --name-only --exit-code git diff --name-only --exit-code
continue-on-error: true continue-on-error: true
- name: Commit parse files - name: Commit parse files
if: steps.diff.outcome == 'failure' if: steps.diff.outcome == 'failure'
run: | run: |
set -x set -x
git config user.email "github-actions[bot]@users.noreply.github.com" git config user.name "github-actions[bot]"
git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add parser git add tools/parser
git commit -m "Update raylib_api.* by CI" git commit -m "Update raylib_api.* by CI"
git push git push

72
.github/workflows/update_examples.yml vendored Normal file
View File

@ -0,0 +1,72 @@
name: Update examples collection
on:
workflow_dispatch:
push:
paths:
- 'examples/**'
pull_request:
paths:
- 'examples/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v14
with:
version: 'latest'
actions-cache-folder: 'emsdk-cache'
- name: Clone raylib.com repo to update files
run: |
git clone https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/raysan5/raylib.com.git
shell: bash
- name: Build and run rexm tool (requires GNU Makefile)
# "rexm update" validates and updates all required examples in raylib and even raylib.com repos,
# note that it calls examples/Makefile.Web internally, so it requires [make] tool available
run: |
sudo apt-get update && sudo apt-get install -y libopengl0 libglu1-mesa libx11-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libgl1-mesa-dev libglu1-mesa-dev
cd "${{ github.workspace }}/src"
make PLATFORM=PLATFORM_DESKTOP
sudo make install
make clean
make PLATFORM=PLATFORM_WEB
cd ../tools/rexm/
make
export REXM_EXAMPLES_BASE_PATH="${{ github.workspace }}/examples"
export REXM_EXAMPLES_WEB_PATH="${{ github.workspace }}/raylib.com/examples"
export REXM_EXAMPLES_TEMPLATE_FILE_PATH="${{ github.workspace }}/examples/examples_template.c"
export REXM_EXAMPLES_TEMPLATE_SCREENSHOT_PATH="${{ github.workspace }}/examples/examples_template.png"
export REXM_EXAMPLES_COLLECTION_FILE_PATH="${{ github.workspace }}/examples/examples_list.txt"
export REXM_EXAMPLES_VS2022_SLN_FILE="${{ github.workspace }}/projects/VS2022/raylib.sln"
export EMSDK_PATH="${{ github.workspace }}/emsdk-cache/emsdk-main"
./rexm update
shell: bash
- name: Commit changes to raylib repo (DISABLED)
if: github.event_name == 'push' && false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Update examples collection" || echo "git exited with code 1, nothing changed"
git push
shell: bash
- name: Push changes to raylib.com repo (DISABLED)
if: github.event_name == 'push' && false
run: |
cd raylib.com
git add -A
git commit -m "Update web examples" || echo "git exited with code 1, nothing changed"
git push origin
shell: bash

10
.gitignore vendored
View File

@ -111,5 +111,11 @@ build/
build-*/ build-*/
docgen_tmp/ docgen_tmp/
# Parser stuff # Tools stuff
parser/raylib_parser tools/parser/raylib_parser
tools/rexm/rexm.exe
tools/rexm/rexm
# CI
emsdk-cache/
raylib.com/

View File

@ -7,6 +7,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
| Name | raylib Version | Language | License | | Name | raylib Version | Language | License |
| :--------------------------------------------------------------------------------------- | :--------------: | :------------------------------------------------------------------: | :------------------: | | :--------------------------------------------------------------------------------------- | :--------------: | :------------------------------------------------------------------: | :------------------: |
| [raylib](https://github.com/raysan5/raylib) | **5.5** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib | | [raylib](https://github.com/raysan5/raylib) | **5.5** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib |
| [raylib-ada](https://github.com/Fabien-Chouteau/raylib-ada) | **5.5** | [Ada](https://en.wikipedia.org/wiki/Ada_(programming_language)) | MIT |
| [raylib-beef](https://github.com/Starpelly/raylib-beef) | **5.5** | [Beef](https://www.beeflang.org) | MIT | | [raylib-beef](https://github.com/Starpelly/raylib-beef) | **5.5** | [Beef](https://www.beeflang.org) | MIT |
| [raybit](https://github.com/Alex-Velez/raybit) | **5.0** | [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) | MIT | | [raybit](https://github.com/Alex-Velez/raybit) | **5.0** | [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) | MIT |
| [raylib-c3](https://github.com/c3lang/vendor/tree/main/libraries/raylib55.c3l) | **5.5** | [C3](https://c3-lang.org) | MIT | | [raylib-c3](https://github.com/c3lang/vendor/tree/main/libraries/raylib55.c3l) | **5.5** | [C3](https://c3-lang.org) | MIT |
@ -82,7 +83,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
| [raylib.v](https://github.com/irishgreencitrus/raylib.v) | 4.2 | [V](https://vlang.io) | Zlib | | [raylib.v](https://github.com/irishgreencitrus/raylib.v) | 4.2 | [V](https://vlang.io) | Zlib |
| [raylib-vapi](https://github.com/lxmcf/raylib-vapi) | **5.0** | [Vala](https://vala.dev) | Zlib | | [raylib-vapi](https://github.com/lxmcf/raylib-vapi) | **5.0** | [Vala](https://vala.dev) | Zlib |
| [raylib-wren](https://github.com/TSnake41/raylib-wren) | 4.5 | [Wren](http://wren.io) | ISC | | [raylib-wren](https://github.com/TSnake41/raylib-wren) | 4.5 | [Wren](http://wren.io) | ISC |
| [raylib-zig](https://github.com/Not-Nik/raylib-zig) | **5.5** | [Zig](https://ziglang.org) | MIT | | [raylib-zig](https://github.com/raylib-zig/raylib-zig) | **5.6-dev** | [Zig](https://ziglang.org) | MIT |
| [raylib.zig](https://github.com/ryupold/raylib.zig) | **5.1-dev** | [Zig](https://ziglang.org) | MIT | | [raylib.zig](https://github.com/ryupold/raylib.zig) | **5.1-dev** | [Zig](https://ziglang.org) | MIT |
| [raylib-zig-bindings](https://github.com/L-Briand/raylib-zig-bindings) | **5.0** | [Zig](https://ziglang.org) | Zlib | | [raylib-zig-bindings](https://github.com/L-Briand/raylib-zig-bindings) | **5.0** | [Zig](https://ziglang.org) | Zlib |
| [hare-raylib](https://git.sr.ht/~evantj/hare-raylib) | **auto** | [Hare](https://harelang.org) | Zlib | | [hare-raylib](https://git.sr.ht/~evantj/hare-raylib) | **auto** | [Hare](https://harelang.org) | Zlib |
@ -145,7 +146,6 @@ These are older raylib bindings that are more than 2 versions old or have not be
| [clj-raylib](https://github.com/lsevero/clj-raylib) | 3.0 | [Clojure](https://clojure.org) | | [clj-raylib](https://github.com/lsevero/clj-raylib) | 3.0 | [Clojure](https://clojure.org) |
| [QuickJS-raylib](https://github.com/sntg-p/QuickJS-raylib) | 3.0 | [QuickJS](https://bellard.org/quickjs) | | [QuickJS-raylib](https://github.com/sntg-p/QuickJS-raylib) | 3.0 | [QuickJS](https://bellard.org/quickjs) |
| [raylib-duktape](https://github.com/RobLoach/raylib-duktape) | 2.6 | [JavaScript (Duktape)](https://en.wikipedia.org/wiki/JavaScript) | | [raylib-duktape](https://github.com/RobLoach/raylib-duktape) | 2.6 | [JavaScript (Duktape)](https://en.wikipedia.org/wiki/JavaScript) |
| [raylib-v7](https://github.com/Rabios/raylib-v7) | 3.5 | [JavaScript (v7)](https://en.wikipedia.org/wiki/JavaScript) |
| [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) | 2.6 | [ChaiScript](http://chaiscript.com) | | [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) | 2.6 | [ChaiScript](http://chaiscript.com) |
| [raylib-squirrel](https://github.com/RobLoach/raylib-squirrel) | 2.5 | [Squirrel](http://www.squirrel-lang.org) | | [raylib-squirrel](https://github.com/RobLoach/raylib-squirrel) | 2.5 | [Squirrel](http://www.squirrel-lang.org) |
| [racket-raylib-2d](https://github.com/arvyy/racket-raylib-2d) | 2.5 | [Racket](https://racket-lang.org) | | [racket-raylib-2d](https://github.com/arvyy/racket-raylib-2d) | 2.5 | [Racket](https://racket-lang.org) |

View File

@ -11,7 +11,7 @@ Local variables | lowerCase | `Vector2 playerPosition = { 0 };`
Global variables | lowerCase | `bool windowReady = false;` Global variables | lowerCase | `bool windowReady = false;`
Constants | lowerCase | `const int maxValue = 8;` Constants | lowerCase | `const int maxValue = 8;`
Pointers | MyType *pointer | `Texture2D *array = NULL;` Pointers | MyType *pointer | `Texture2D *array = NULL;`
float values | always x.xf | `float gravity = 10.0f` float values | always x.xf | `float gravity = 10.0f` (avoid `10.f`)
Operators | value1*value2 | `int product = value*6;` Operators | value1*value2 | `int product = value*6;`
Operators | value1/value2 | `int division = value/4;` Operators | value1/value2 | `int division = value/4;`
Operators | value1 + value2 | `int sum = value + 10;` Operators | value1 + value2 | `int sum = value + 10;`
@ -28,6 +28,10 @@ Some other conventions to follow:
- **ALWAYS** initialize all defined variables. - **ALWAYS** initialize all defined variables.
- **Do not use TABS**, use 4 spaces instead. - **Do not use TABS**, use 4 spaces instead.
- Avoid trailing spaces, please, avoid them - Avoid trailing spaces, please, avoid them
- Comments always start with space + capital letter and never end with a '.', place them **before** the line(s) they refer to
```c
// This is a comment in raylib or raylib examples
```
- Control flow statements always are followed **by a space**: - Control flow statements always are followed **by a space**:
```c ```c
if (condition) value = 0; if (condition) value = 0;
@ -68,19 +72,19 @@ void SomeFunction()
**If proposing new functions, please try to use a clear naming for function-name and functions-parameters, in case of doubt, open an issue for discussion.** **If proposing new functions, please try to use a clear naming for function-name and functions-parameters, in case of doubt, open an issue for discussion.**
## Files and Directories Naming Conventions ## Files and Directories Naming Conventions
- Directories will be named using `snake_case`: `resources/models`, `resources/fonts` - Directories will be named using `snake_case`: `resources/models`, `resources/fonts`
- Files will be named using `snake_case`: `main_title.png`, `cubicmap.png`, `sound.wav` - Files will be named using `snake_case`: `main_title.png`, `cubicmap.png`, `sound.wav`
_NOTE: Avoid any space or special character in the files/dir naming!_ _NOTE: Avoid any space or special character in the files/dir naming!_
## Games/Examples Directories Organization Conventions ## Games/Examples Directories Organization Conventions
- Data files should be organized by context and usage in the game, think about the loading requirements for data and put all the resources that need to be loaded at the same time together. - Data files should be organized by context and usage in the game, think about the loading requirements for data and put all the resources that need to be loaded at the same time together.
- Use descriptive names for the files, it would be perfect if just reading the name of the file, it was possible to know what is that file and where fits in the game. - Use descriptive names for the files, it would be perfect if just reading the name of the file, it was possible to know what is that file and where fits in the game.
- Here is an example, note that some resources require to be loaded all at once while other require to be loaded only at initialization (gui, font). - Here is an example, note that some resources require to be loaded all at once while other require to be loaded only at initialization (gui, font).
``` ```
resources/audio/fx/long_jump.wav resources/audio/fx/long_jump.wav
resources/audio/music/main_theme.ogg resources/audio/music/main_theme.ogg

View File

@ -24,14 +24,14 @@ Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
[![Youtube Subscribers](https://img.shields.io/youtube/channel/subscribers/UC8WIBkhYb5sBNqXO1mZ7WSQ?style=flat&label=Youtube&logo=youtube)](https://www.youtube.com/c/raylib) [![Youtube Subscribers](https://img.shields.io/youtube/channel/subscribers/UC8WIBkhYb5sBNqXO1mZ7WSQ?style=flat&label=Youtube&logo=youtube)](https://www.youtube.com/c/raylib)
[![Twitch Status](https://img.shields.io/twitch/status/raysan5?style=flat&label=Twitch&logo=twitch)](https://www.twitch.tv/raysan5) [![Twitch Status](https://img.shields.io/twitch/status/raysan5?style=flat&label=Twitch&logo=twitch)](https://www.twitch.tv/raysan5)
[![Windows](https://github.com/raysan5/raylib/workflows/Windows/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AWindows) [![Build Windows](https://github.com/raysan5/raylib/actions/workflows/build_windows.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_windows.yml)
[![Linux](https://github.com/raysan5/raylib/workflows/Linux/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3ALinux) [![Build Linux](https://github.com/raysan5/raylib/actions/workflows/build_linux.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_linux.yml)
[![macOS](https://github.com/raysan5/raylib/workflows/macOS/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AmacOS) [![Build macOS](https://github.com/raysan5/raylib/actions/workflows/build_macos.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_macos.yml)
[![WebAssembly](https://github.com/raysan5/raylib/workflows/WebAssembly/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AWebAssembly) [![Build WebAssembly](https://github.com/raysan5/raylib/actions/workflows/build_webassembly.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_webassembly.yml)
[![CMakeBuilds](https://github.com/raysan5/raylib/workflows/CMakeBuilds/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3ACMakeBuilds) [![Build CMake](https://github.com/raysan5/raylib/actions/workflows/build_cmake.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_cmake.yml)
[![Windows Examples](https://github.com/raysan5/raylib/actions/workflows/windows_examples.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/windows_examples.yml) [![Build examples Windows](https://github.com/raysan5/raylib/actions/workflows/build_examples_windows.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_examples_windows.yml)
[![Linux Examples](https://github.com/raysan5/raylib/actions/workflows/linux_examples.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/linux_examples.yml) [![Build examples Linux](https://github.com/raysan5/raylib/actions/workflows/build_examples_linux.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_examples_linux.yml)
features features
-------- --------

641
build.zig
View File

@ -2,7 +2,7 @@ const std = @import("std");
const builtin = @import("builtin"); const builtin = @import("builtin");
/// Minimum supported version of Zig /// Minimum supported version of Zig
const min_ver = "0.13.0"; const min_ver = "0.15.1";
const emccOutputDir = "zig-out" ++ std.fs.path.sep_str ++ "htmlout" ++ std.fs.path.sep_str; const emccOutputDir = "zig-out" ++ std.fs.path.sep_str ++ "htmlout" ++ std.fs.path.sep_str;
const emccOutputFile = "index.html"; const emccOutputFile = "index.html";
@ -14,6 +14,72 @@ comptime {
@compileError("Raylib requires zig version " ++ min_ver); @compileError("Raylib requires zig version " ++ min_ver);
} }
pub const emsdk = struct {
const zemscripten = @import("zemscripten");
pub fn shell(b: *std.Build) std.Build.LazyPath {
return b.dependency("raylib", .{}).path("src/shell.html");
}
pub const FlagsOptions = struct {
optimize: std.builtin.OptimizeMode,
asyncify: bool = true,
};
pub fn emccDefaultFlags(allocator: std.mem.Allocator, options: FlagsOptions) zemscripten.EmccFlags {
var emcc_flags = zemscripten.emccDefaultFlags(allocator, .{
.optimize = options.optimize,
.fsanitize = true,
});
if (options.asyncify)
emcc_flags.put("-sASYNCIFY", {}) catch unreachable;
return emcc_flags;
}
pub const SettingsOptions = struct {
optimize: std.builtin.OptimizeMode,
es3: bool = true,
emsdk_allocator: zemscripten.EmsdkAllocator = .emmalloc,
};
pub fn emccDefaultSettings(allocator: std.mem.Allocator, options: SettingsOptions) zemscripten.EmccSettings {
var emcc_settings = zemscripten.emccDefaultSettings(allocator, .{
.optimize = options.optimize,
.emsdk_allocator = options.emsdk_allocator,
});
if (options.es3)
emcc_settings.put("FULL_ES3", "1") catch unreachable;
emcc_settings.put("USE_GLFW", "3") catch unreachable;
emcc_settings.put("EXPORTED_RUNTIME_METHODS", "['requestFullscreen']") catch unreachable;
return emcc_settings;
}
pub fn emccStep(b: *std.Build, raylib: *std.Build.Step.Compile, wasm: *std.Build.Step.Compile, options: zemscripten.StepOptions) *std.Build.Step {
const activate_emsdk_step = zemscripten.activateEmsdkStep(b);
const emsdk_dep = b.dependency("emsdk", .{});
raylib.root_module.addIncludePath(emsdk_dep.path("upstream/emscripten/cache/sysroot/include"));
wasm.root_module.addIncludePath(emsdk_dep.path("upstream/emscripten/cache/sysroot/include"));
const emcc_step = zemscripten.emccStep(b, wasm, options);
emcc_step.dependOn(activate_emsdk_step);
return emcc_step;
}
pub fn emrunStep(
b: *std.Build,
html_path: []const u8,
extra_args: []const []const u8,
) *std.Build.Step {
return zemscripten.emrunStep(b, html_path, extra_args);
}
};
fn setDesktopPlatform(raylib: *std.Build.Step.Compile, platform: PlatformBackend) void { fn setDesktopPlatform(raylib: *std.Build.Step.Compile, platform: PlatformBackend) void {
switch (platform) { switch (platform) {
.glfw => raylib.root_module.addCMacro("PLATFORM_DESKTOP_GLFW", ""), .glfw => raylib.root_module.addCMacro("PLATFORM_DESKTOP_GLFW", ""),
@ -24,50 +90,6 @@ fn setDesktopPlatform(raylib: *std.Build.Step.Compile, platform: PlatformBackend
} }
} }
fn createEmsdkStep(b: *std.Build, emsdk: *std.Build.Dependency) *std.Build.Step.Run {
if (builtin.os.tag == .windows) {
return b.addSystemCommand(&.{emsdk.path("emsdk.bat").getPath(b)});
} else {
return b.addSystemCommand(&.{emsdk.path("emsdk").getPath(b)});
}
}
fn emSdkSetupStep(b: *std.Build, emsdk: *std.Build.Dependency) !?*std.Build.Step.Run {
const dot_emsc_path = emsdk.path(".emscripten").getPath(b);
const dot_emsc_exists = !std.meta.isError(std.fs.accessAbsolute(dot_emsc_path, .{}));
if (!dot_emsc_exists) {
const emsdk_install = createEmsdkStep(b, emsdk);
emsdk_install.addArgs(&.{ "install", "latest" });
const emsdk_activate = createEmsdkStep(b, emsdk);
emsdk_activate.addArgs(&.{ "activate", "latest" });
emsdk_activate.step.dependOn(&emsdk_install.step);
return emsdk_activate;
} else {
return null;
}
}
// Adapted from Not-Nik/raylib-zig
fn emscriptenRunStep(b: *std.Build, emsdk: *std.Build.Dependency, examplePath: []const u8) !*std.Build.Step.Run {
const dot_emsc_path = emsdk.path("upstream/emscripten/cache/sysroot/include").getPath(b);
// If compiling on windows , use emrun.bat.
const emrunExe = switch (builtin.os.tag) {
.windows => "emrun.bat",
else => "emrun",
};
var emrun_run_arg = try b.allocator.alloc(u8, dot_emsc_path.len + emrunExe.len + 1);
defer b.allocator.free(emrun_run_arg);
if (b.sysroot == null) {
emrun_run_arg = try std.fmt.bufPrint(emrun_run_arg, "{s}" ++ std.fs.path.sep_str ++ "{s}", .{ emsdk.path("upstream/emscripten").getPath(b), emrunExe });
} else {
emrun_run_arg = try std.fmt.bufPrint(emrun_run_arg, "{s}" ++ std.fs.path.sep_str ++ "{s}", .{ dot_emsc_path, emrunExe });
}
const run_cmd = b.addSystemCommand(&.{ emrun_run_arg, examplePath });
return run_cmd;
}
/// A list of all flags from `src/config.h` that one may override /// A list of all flags from `src/config.h` that one may override
const config_h_flags = outer: { const config_h_flags = outer: {
// Set this value higher if compile errors happen as `src/config.h` gets larger // Set this value higher if compile errors happen as `src/config.h` gets larger
@ -100,25 +122,41 @@ const config_h_flags = outer: {
}; };
fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, options: Options) !*std.Build.Step.Compile { fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, options: Options) !*std.Build.Step.Compile {
var raylib_flags_arr = std.ArrayList([]const u8).init(b.allocator); var raylib_flags_arr: std.ArrayList([]const u8) = .empty;
defer raylib_flags_arr.deinit(); defer raylib_flags_arr.deinit(b.allocator);
try raylib_flags_arr.appendSlice(&[_][]const u8{ const raylib = b.addLibrary(.{
"-std=gnu99", .name = "raylib",
"-D_GNU_SOURCE", .linkage = options.linkage,
"-DGL_SILENCE_DEPRECATION=199309L", .root_module = b.createModule(.{
"-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/3674 .optimize = optimize,
.target = target,
.link_libc = true,
}),
}); });
if (options.shared) { try raylib_flags_arr.appendSlice(
try raylib_flags_arr.appendSlice(&[_][]const u8{ b.allocator,
"-fPIC", &[_][]const u8{
"-DBUILD_LIBTYPE_SHARED", "-std=gnu99",
}); "-D_GNU_SOURCE",
"-DGL_SILENCE_DEPRECATION=199309L",
"-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/3674
},
);
if (options.linkage == .dynamic) {
try raylib_flags_arr.appendSlice(
b.allocator,
&[_][]const u8{
"-fPIC",
"-DBUILD_LIBTYPE_SHARED",
},
);
} }
// Sets a flag indiciating the use of a custom `config.h` // Sets a flag indiciating the use of a custom `config.h`
try raylib_flags_arr.append("-DEXTERNAL_CONFIG_FLAGS"); try raylib_flags_arr.append(b.allocator, "-DEXTERNAL_CONFIG_FLAGS");
if (options.config.len > 0) { if (options.config.len > 0) {
// Splits a space-separated list of config flags into multiple flags // Splits a space-separated list of config flags into multiple flags
// //
@ -128,7 +166,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
// Apply config flags supplied by the user // Apply config flags supplied by the user
while (config_iter.next()) |config_flag| while (config_iter.next()) |config_flag|
try raylib_flags_arr.append(config_flag); try raylib_flags_arr.append(b.allocator, config_flag);
// Apply all relevant configs from `src/config.h` *except* the user-specified ones // Apply all relevant configs from `src/config.h` *except* the user-specified ones
// //
@ -146,54 +184,40 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
} }
// Otherwise, append default value from config.h to compile flags // Otherwise, append default value from config.h to compile flags
try raylib_flags_arr.append(flag); try raylib_flags_arr.append(b.allocator, flag);
} }
} else { } else {
// Set default config if no custome config got set // Set default config if no custome config got set
try raylib_flags_arr.appendSlice(&config_h_flags); try raylib_flags_arr.appendSlice(b.allocator, &config_h_flags);
} }
const raylib = if (options.shared)
b.addSharedLibrary(.{
.name = "raylib",
.target = target,
.optimize = optimize,
})
else
b.addStaticLibrary(.{
.name = "raylib",
.target = target,
.optimize = optimize,
});
raylib.linkLibC();
// No GLFW required on PLATFORM_DRM // No GLFW required on PLATFORM_DRM
if (options.platform != .drm) { if (options.platform != .drm) {
raylib.addIncludePath(b.path("src/external/glfw/include")); raylib.addIncludePath(b.path("src/external/glfw/include"));
} }
var c_source_files = try std.ArrayList([]const u8).initCapacity(b.allocator, 2); var c_source_files: std.ArrayList([]const u8) = try .initCapacity(b.allocator, 2);
c_source_files.appendSliceAssumeCapacity(&.{ "src/rcore.c", "src/utils.c" }); c_source_files.appendSliceAssumeCapacity(&.{ "src/rcore.c", "src/utils.c" });
if (options.rshapes) { if (options.rshapes) {
try c_source_files.append("src/rshapes.c"); try c_source_files.append(b.allocator, "src/rshapes.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RSHAPES"); try raylib_flags_arr.append(b.allocator, "-DSUPPORT_MODULE_RSHAPES");
} }
if (options.rtextures) { if (options.rtextures) {
try c_source_files.append("src/rtextures.c"); try c_source_files.append(b.allocator, "src/rtextures.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RTEXTURES"); try raylib_flags_arr.append(b.allocator, "-DSUPPORT_MODULE_RTEXTURES");
} }
if (options.rtext) { if (options.rtext) {
try c_source_files.append("src/rtext.c"); try c_source_files.append(b.allocator, "src/rtext.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RTEXT"); try raylib_flags_arr.append(b.allocator, "-DSUPPORT_MODULE_RTEXT");
} }
if (options.rmodels) { if (options.rmodels) {
try c_source_files.append("src/rmodels.c"); try c_source_files.append(b.allocator, "src/rmodels.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RMODELS"); try raylib_flags_arr.append(b.allocator, "-DSUPPORT_MODULE_RMODELS");
} }
if (options.raudio) { if (options.raudio) {
try c_source_files.append("src/raudio.c"); try c_source_files.append(b.allocator, "src/raudio.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RAUDIO"); try raylib_flags_arr.append(b.allocator, "-DSUPPORT_MODULE_RAUDIO");
} }
if (options.opengl_version != .auto) { if (options.opengl_version != .auto) {
@ -204,26 +228,26 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
switch (target.result.os.tag) { switch (target.result.os.tag) {
.windows => { .windows => {
switch (options.platform) { switch (options.platform) {
.glfw => try c_source_files.append("src/rglfw.c"), .glfw => try c_source_files.append(b.allocator, "src/rglfw.c"),
.rgfw, .sdl, .drm, .android => {}, .rgfw, .sdl, .drm, .android => {},
} }
raylib.linkSystemLibrary("winmm"); raylib.root_module.linkSystemLibrary("winmm", .{});
raylib.linkSystemLibrary("gdi32"); raylib.root_module.linkSystemLibrary("gdi32", .{});
raylib.linkSystemLibrary("opengl32"); raylib.root_module.linkSystemLibrary("opengl32", .{});
setDesktopPlatform(raylib, options.platform); setDesktopPlatform(raylib, options.platform);
}, },
.linux => { .linux => {
if (options.platform == .drm) { if (options.platform == .drm) {
if (options.opengl_version == .auto) { if (options.opengl_version == .auto) {
raylib.linkSystemLibrary("GLESv2"); raylib.root_module.linkSystemLibrary("GLESv2", .{});
raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES2", ""); raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES2", "");
} }
raylib.linkSystemLibrary("EGL"); raylib.root_module.linkSystemLibrary("EGL", .{});
raylib.linkSystemLibrary("gbm"); raylib.root_module.linkSystemLibrary("gbm", .{});
raylib.linkSystemLibrary2("libdrm", .{ .use_pkg_config = .force }); raylib.root_module.linkSystemLibrary("libdrm", .{ .use_pkg_config = .force });
raylib.root_module.addCMacro("PLATFORM_DRM", ""); raylib.root_module.addCMacro("PLATFORM_DRM", "");
raylib.root_module.addCMacro("EGL_NO_X11", ""); raylib.root_module.addCMacro("EGL_NO_X11", "");
@ -258,21 +282,21 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
const androidAsmPath = try std.fs.path.join(b.allocator, &.{ androidIncludePath, "/asm-generic" }); const androidAsmPath = try std.fs.path.join(b.allocator, &.{ androidIncludePath, "/asm-generic" });
const androidGluePath = try std.fs.path.join(b.allocator, &.{ androidNdkPathString, "/sources/android/native_app_glue/" }); const androidGluePath = try std.fs.path.join(b.allocator, &.{ androidNdkPathString, "/sources/android/native_app_glue/" });
raylib.addLibraryPath(.{ .cwd_relative = androidLibPath }); raylib.root_module.addLibraryPath(.{ .cwd_relative = androidLibPath });
raylib.root_module.addLibraryPath(.{ .cwd_relative = androidApiSpecificPath }); raylib.root_module.addLibraryPath(.{ .cwd_relative = androidApiSpecificPath });
raylib.addSystemIncludePath(.{ .cwd_relative = androidIncludePath }); raylib.root_module.addSystemIncludePath(.{ .cwd_relative = androidIncludePath });
raylib.addSystemIncludePath(.{ .cwd_relative = androidArchIncludePath }); raylib.root_module.addSystemIncludePath(.{ .cwd_relative = androidArchIncludePath });
raylib.addSystemIncludePath(.{ .cwd_relative = androidAsmPath }); raylib.root_module.addSystemIncludePath(.{ .cwd_relative = androidAsmPath });
raylib.addSystemIncludePath(.{ .cwd_relative = androidGluePath }); raylib.root_module.addSystemIncludePath(.{ .cwd_relative = androidGluePath });
var libcData = std.ArrayList(u8).init(b.allocator); var libcData: std.ArrayList(u8) = .empty;
const writer = libcData.writer(); var aw: std.Io.Writer.Allocating = .fromArrayList(b.allocator, &libcData);
try (std.zig.LibCInstallation{ try (std.zig.LibCInstallation{
.include_dir = androidIncludePath, .include_dir = androidIncludePath,
.sys_include_dir = androidIncludePath, .sys_include_dir = androidIncludePath,
.crt_dir = androidApiSpecificPath, .crt_dir = androidApiSpecificPath,
}).render(writer); }).render(&aw.writer);
const libcFile = b.addWriteFiles().add("android-libc.txt", try libcData.toOwnedSlice()); const libcFile = b.addWriteFiles().add("android-libc.txt", try libcData.toOwnedSlice(b.allocator));
raylib.setLibCFile(libcFile); raylib.setLibCFile(libcFile);
if (options.opengl_version == .auto) { if (options.opengl_version == .auto) {
@ -283,19 +307,19 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
setDesktopPlatform(raylib, .android); setDesktopPlatform(raylib, .android);
} else { } else {
try c_source_files.append("src/rglfw.c"); try c_source_files.append(b.allocator, "src/rglfw.c");
if (options.linux_display_backend == .X11 or options.linux_display_backend == .Both) { if (options.linux_display_backend == .X11 or options.linux_display_backend == .Both) {
raylib.root_module.addCMacro("_GLFW_X11", ""); raylib.root_module.addCMacro("_GLFW_X11", "");
raylib.linkSystemLibrary("GLX"); raylib.root_module.linkSystemLibrary("GLX", .{});
raylib.linkSystemLibrary("X11"); raylib.root_module.linkSystemLibrary("X11", .{});
raylib.linkSystemLibrary("Xcursor"); raylib.root_module.linkSystemLibrary("Xcursor", .{});
raylib.linkSystemLibrary("Xext"); raylib.root_module.linkSystemLibrary("Xext", .{});
raylib.linkSystemLibrary("Xfixes"); raylib.root_module.linkSystemLibrary("Xfixes", .{});
raylib.linkSystemLibrary("Xi"); raylib.root_module.linkSystemLibrary("Xi", .{});
raylib.linkSystemLibrary("Xinerama"); raylib.root_module.linkSystemLibrary("Xinerama", .{});
raylib.linkSystemLibrary("Xrandr"); raylib.root_module.linkSystemLibrary("Xrandr", .{});
raylib.linkSystemLibrary("Xrender"); raylib.root_module.linkSystemLibrary("Xrender", .{});
} }
if (options.linux_display_backend == .Wayland or options.linux_display_backend == .Both) { if (options.linux_display_backend == .Wayland or options.linux_display_backend == .Both) {
@ -307,9 +331,9 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
@panic("`wayland-scanner` not found"); @panic("`wayland-scanner` not found");
}; };
raylib.root_module.addCMacro("_GLFW_WAYLAND", ""); raylib.root_module.addCMacro("_GLFW_WAYLAND", "");
raylib.linkSystemLibrary("EGL"); raylib.root_module.linkSystemLibrary("EGL", .{});
raylib.linkSystemLibrary("wayland-client"); raylib.root_module.linkSystemLibrary("wayland-client", .{});
raylib.linkSystemLibrary("xkbcommon"); raylib.root_module.linkSystemLibrary("xkbcommon", .{});
waylandGenerate(b, raylib, "wayland.xml", "wayland-client-protocol"); waylandGenerate(b, raylib, "wayland.xml", "wayland-client-protocol");
waylandGenerate(b, raylib, "xdg-shell.xml", "xdg-shell-client-protocol"); waylandGenerate(b, raylib, "xdg-shell.xml", "xdg-shell-client-protocol");
waylandGenerate(b, raylib, "xdg-decoration-unstable-v1.xml", "xdg-decoration-unstable-v1-client-protocol"); waylandGenerate(b, raylib, "xdg-decoration-unstable-v1.xml", "xdg-decoration-unstable-v1-client-protocol");
@ -324,55 +348,47 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
} }
}, },
.freebsd, .openbsd, .netbsd, .dragonfly => { .freebsd, .openbsd, .netbsd, .dragonfly => {
try c_source_files.append("rglfw.c"); try c_source_files.append(b.allocator, "rglfw.c");
raylib.linkSystemLibrary("GL"); raylib.root_module.linkSystemLibrary("GL", .{});
raylib.linkSystemLibrary("rt"); raylib.root_module.linkSystemLibrary("rt", .{});
raylib.linkSystemLibrary("dl"); raylib.root_module.linkSystemLibrary("dl", .{});
raylib.linkSystemLibrary("m"); raylib.root_module.linkSystemLibrary("m", .{});
raylib.linkSystemLibrary("X11"); raylib.root_module.linkSystemLibrary("X11", .{});
raylib.linkSystemLibrary("Xrandr"); raylib.root_module.linkSystemLibrary("Xrandr", .{});
raylib.linkSystemLibrary("Xinerama"); raylib.root_module.linkSystemLibrary("Xinerama", .{});
raylib.linkSystemLibrary("Xi"); raylib.root_module.linkSystemLibrary("Xi", .{});
raylib.linkSystemLibrary("Xxf86vm"); raylib.root_module.linkSystemLibrary("Xxf86vm", .{});
raylib.linkSystemLibrary("Xcursor"); raylib.root_module.linkSystemLibrary("Xcursor", .{});
setDesktopPlatform(raylib, options.platform); setDesktopPlatform(raylib, options.platform);
}, },
.macos => { .macos => {
// Include xcode_frameworks for cross compilation // Include xcode_frameworks for cross compilation
if (b.lazyDependency("xcode_frameworks", .{})) |dep| { if (b.lazyDependency("xcode_frameworks", .{})) |dep| {
raylib.addSystemFrameworkPath(dep.path("Frameworks")); raylib.root_module.addSystemFrameworkPath(dep.path("Frameworks"));
raylib.addSystemIncludePath(dep.path("include")); raylib.root_module.addSystemIncludePath(dep.path("include"));
raylib.addLibraryPath(dep.path("lib")); raylib.root_module.addLibraryPath(dep.path("lib"));
} }
// On macos rglfw.c include Objective-C files. // On macos rglfw.c include Objective-C files.
try raylib_flags_arr.append("-ObjC"); try raylib_flags_arr.append(b.allocator, "-ObjC");
raylib.root_module.addCSourceFile(.{ raylib.root_module.addCSourceFile(.{
.file = b.path("src/rglfw.c"), .file = b.path("src/rglfw.c"),
.flags = raylib_flags_arr.items, .flags = raylib_flags_arr.items,
}); });
_ = raylib_flags_arr.pop(); _ = raylib_flags_arr.pop();
raylib.linkFramework("Foundation"); raylib.root_module.linkFramework("Foundation", .{});
raylib.linkFramework("CoreServices"); raylib.root_module.linkFramework("CoreServices", .{});
raylib.linkFramework("CoreGraphics"); raylib.root_module.linkFramework("CoreGraphics", .{});
raylib.linkFramework("AppKit"); raylib.root_module.linkFramework("AppKit", .{});
raylib.linkFramework("IOKit"); raylib.root_module.linkFramework("IOKit", .{});
setDesktopPlatform(raylib, options.platform); setDesktopPlatform(raylib, options.platform);
}, },
.emscripten => { .emscripten => {
if (b.lazyDependency("emsdk", .{})) |dep| {
if (try emSdkSetupStep(b, dep)) |emSdkStep| {
raylib.step.dependOn(&emSdkStep.step);
}
raylib.addIncludePath(dep.path("upstream/emscripten/cache/sysroot/include"));
}
raylib.root_module.addCMacro("PLATFORM_WEB", ""); raylib.root_module.addCMacro("PLATFORM_WEB", "");
if (options.opengl_version == .auto) { if (options.opengl_version == .auto) {
raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES2", ""); raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES3", "");
} }
}, },
else => { else => {
@ -394,9 +410,9 @@ pub fn addRaygui(b: *std.Build, raylib: *std.Build.Step.Compile, raygui_dep: *st
raylib.step.dependOn(&gen_step.step); raylib.step.dependOn(&gen_step.step);
const raygui_c_path = gen_step.add("raygui.c", "#define RAYGUI_IMPLEMENTATION\n#include \"raygui.h\"\n"); const raygui_c_path = gen_step.add("raygui.c", "#define RAYGUI_IMPLEMENTATION\n#include \"raygui.h\"\n");
raylib.addCSourceFile(.{ .file = raygui_c_path }); raylib.root_module.addCSourceFile(.{ .file = raygui_c_path });
raylib.addIncludePath(raygui_dep.path("src")); raylib.root_module.addIncludePath(raygui_dep.path("src"));
raylib.addIncludePath(raylib_dep.path("src")); raylib.root_module.addIncludePath(raylib_dep.path("src"));
raylib.installHeader(raygui_dep.path("src/raygui.h"), "raygui.h"); raylib.installHeader(raygui_dep.path("src/raygui.h"), "raygui.h");
} }
@ -408,7 +424,7 @@ pub const Options = struct {
rtext: bool = true, rtext: bool = true,
rtextures: bool = true, rtextures: bool = true,
platform: PlatformBackend = .glfw, platform: PlatformBackend = .glfw,
shared: bool = false, linkage: std.builtin.LinkMode = .static,
linux_display_backend: LinuxDisplayBackend = .Both, linux_display_backend: LinuxDisplayBackend = .Both,
opengl_version: OpenglVersion = .auto, opengl_version: OpenglVersion = .auto,
android_ndk: []const u8 = "", android_ndk: []const u8 = "",
@ -426,7 +442,7 @@ pub const Options = struct {
.rtext = b.option(bool, "rtext", "Compile with text support") orelse defaults.rtext, .rtext = b.option(bool, "rtext", "Compile with text support") orelse defaults.rtext,
.rtextures = b.option(bool, "rtextures", "Compile with textures support") orelse defaults.rtextures, .rtextures = b.option(bool, "rtextures", "Compile with textures support") orelse defaults.rtextures,
.rshapes = b.option(bool, "rshapes", "Compile with shapes support") orelse defaults.rshapes, .rshapes = b.option(bool, "rshapes", "Compile with shapes support") orelse defaults.rshapes,
.shared = b.option(bool, "shared", "Compile as shared library") orelse defaults.shared, .linkage = b.option(std.builtin.LinkMode, "linkage", "Compile as shared or static library") orelse defaults.linkage,
.linux_display_backend = b.option(LinuxDisplayBackend, "linux_display_backend", "Linux display backend to use") orelse defaults.linux_display_backend, .linux_display_backend = b.option(LinuxDisplayBackend, "linux_display_backend", "Linux display backend to use") orelse defaults.linux_display_backend,
.opengl_version = b.option(OpenglVersion, "opengl_version", "OpenGL version to use") orelse defaults.opengl_version, .opengl_version = b.option(OpenglVersion, "opengl_version", "OpenGL version to use") orelse defaults.opengl_version,
.config = b.option([]const u8, "config", "Compile with custom define macros overriding config.h") orelse &.{}, .config = b.option([]const u8, "config", "Compile with custom define macros overriding config.h") orelse &.{},
@ -473,14 +489,7 @@ pub const PlatformBackend = enum {
}; };
pub fn build(b: *std.Build) !void { pub fn build(b: *std.Build) !void {
// Standard target options allows the person running `zig build` to choose
// 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 target = b.standardTargetOptions(.{});
// Standard optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const lib = try compileRaylib(b, target, optimize, Options.getOptions(b)); const lib = try compileRaylib(b, target, optimize, Options.getOptions(b));
@ -503,6 +512,145 @@ pub fn build(b: *std.Build) !void {
examples.dependOn(try addExamples("textures", b, target, optimize, lib)); examples.dependOn(try addExamples("textures", b, target, optimize, lib));
} }
fn addExamples(
comptime module: []const u8,
b: *std.Build,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
raylib: *std.Build.Step.Compile,
) !*std.Build.Step {
const all = b.step(module, "All " ++ module ++ " examples");
const module_subpath = b.pathJoin(&.{ "examples", module });
var dir = try std.fs.cwd().openDir(b.pathFromRoot(module_subpath), .{ .iterate = true });
defer dir.close();
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 = b.pathJoin(&.{ module_subpath, entry.name });
// zig's mingw headers do not include pthread.h
if (std.mem.eql(u8, "core_loading_thread", name) and target.result.os.tag == .windows) continue;
const exe_mod = b.createModule(.{
.target = target,
.optimize = optimize,
});
exe_mod.addCSourceFile(.{ .file = b.path(path), .flags = &.{} });
exe_mod.linkLibrary(raylib);
const run_step = b.step(name, name);
if (target.result.os.tag == .emscripten) {
const wasm = b.addLibrary(.{
.name = name,
.linkage = .static,
.root_module = exe_mod,
});
if (std.mem.eql(u8, name, "rlgl_standalone")) {
//TODO: Make rlgl_standalone example work
continue;
}
if (std.mem.eql(u8, name, "raylib_opengl_interop")) {
//TODO: Make raylib_opengl_interop example work
continue;
}
const emcc_flags = emsdk.emccDefaultFlags(b.allocator, .{ .optimize = optimize });
const emcc_settings = emsdk.emccDefaultSettings(b.allocator, .{ .optimize = optimize });
const install_dir: std.Build.InstallDir = .{ .custom = "htmlout" };
const emcc_step = emsdk.emccStep(b, raylib, wasm, .{
.optimize = optimize,
.flags = emcc_flags,
.settings = emcc_settings,
.shell_file_path = b.path("src/shell.html"),
.embed_paths = &.{
.{
.src_path = b.pathJoin(&.{ module_subpath, "resources" }),
.virtual_path = "resources",
},
},
.install_dir = install_dir,
});
const html_filename = try std.fmt.allocPrint(b.allocator, "{s}.html", .{wasm.name});
const emrun_step = emsdk.emrunStep(
b,
b.getInstallPath(install_dir, html_filename),
&.{"--no_browser"},
);
emrun_step.dependOn(emcc_step);
run_step.dependOn(emrun_step);
all.dependOn(emcc_step);
} else {
// special examples that test using these external dependencies directly
// alongside raylib
if (std.mem.eql(u8, name, "rlgl_standalone")) {
exe_mod.addIncludePath(b.path("src"));
exe_mod.addIncludePath(b.path("src/external/glfw/include"));
if (!hasCSource(raylib.root_module, "rglfw.c")) {
exe_mod.addCSourceFile(.{ .file = b.path("src/rglfw.c"), .flags = &.{} });
}
}
if (std.mem.eql(u8, name, "raylib_opengl_interop")) {
exe_mod.addIncludePath(b.path("src/external"));
}
switch (target.result.os.tag) {
.windows => {
exe_mod.linkSystemLibrary("winmm", .{});
exe_mod.linkSystemLibrary("gdi32", .{});
exe_mod.linkSystemLibrary("opengl32", .{});
exe_mod.addCMacro("PLATFORM_DESKTOP", "");
},
.linux => {
exe_mod.linkSystemLibrary("GL", .{});
exe_mod.linkSystemLibrary("rt", .{});
exe_mod.linkSystemLibrary("dl", .{});
exe_mod.linkSystemLibrary("m", .{});
exe_mod.linkSystemLibrary("X11", .{});
exe_mod.addCMacro("PLATFORM_DESKTOP", "");
},
.macos => {
exe_mod.linkFramework("Foundation", .{});
exe_mod.linkFramework("Cocoa", .{});
exe_mod.linkFramework("OpenGL", .{});
exe_mod.linkFramework("CoreAudio", .{});
exe_mod.linkFramework("CoreVideo", .{});
exe_mod.linkFramework("IOKit", .{});
exe_mod.addCMacro("PLATFORM_DESKTOP", "");
},
else => {
@panic("Unsupported OS");
},
}
const exe = b.addExecutable(.{
.name = name,
.root_module = exe_mod,
});
const install_cmd = b.addInstallArtifact(exe, .{});
const run_cmd = b.addRunArtifact(exe);
run_cmd.cwd = b.path(module_subpath);
run_cmd.step.dependOn(&install_cmd.step);
run_step.dependOn(&run_cmd.step);
all.dependOn(&install_cmd.step);
}
}
return all;
}
fn waylandGenerate( fn waylandGenerate(
b: *std.Build, b: *std.Build,
raylib: *std.Build.Step.Compile, raylib: *std.Build.Step.Compile,
@ -516,191 +664,16 @@ fn waylandGenerate(
const client_step = b.addSystemCommand(&.{ "wayland-scanner", "client-header" }); const client_step = b.addSystemCommand(&.{ "wayland-scanner", "client-header" });
client_step.addFileArg(b.path(protocolDir)); client_step.addFileArg(b.path(protocolDir));
raylib.addIncludePath(client_step.addOutputFileArg(clientHeader).dirname()); raylib.root_module.addIncludePath(client_step.addOutputFileArg(clientHeader).dirname());
const private_step = b.addSystemCommand(&.{ "wayland-scanner", "private-code" }); const private_step = b.addSystemCommand(&.{ "wayland-scanner", "private-code" });
private_step.addFileArg(b.path(protocolDir)); private_step.addFileArg(b.path(protocolDir));
raylib.addIncludePath(private_step.addOutputFileArg(privateCode).dirname()); raylib.root_module.addIncludePath(private_step.addOutputFileArg(privateCode).dirname());
raylib.step.dependOn(&client_step.step); raylib.step.dependOn(&client_step.step);
raylib.step.dependOn(&private_step.step); raylib.step.dependOn(&private_step.step);
} }
fn addExamples(
comptime module: []const u8,
b: *std.Build,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
raylib: *std.Build.Step.Compile,
) !*std.Build.Step {
const all = b.step(module, "All " ++ module ++ " examples");
const module_subpath = b.pathJoin(&.{ "examples", module });
const module_resources = b.pathJoin(&.{ module_subpath, "resources@resources" });
var dir = try std.fs.cwd().openDir(b.pathFromRoot(module_subpath), .{ .iterate = true });
defer if (comptime builtin.zig_version.minor >= 12) dir.close();
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 = b.pathJoin(&.{ module_subpath, entry.name });
// zig's mingw headers do not include pthread.h
if (std.mem.eql(u8, "core_loading_thread", name) and target.result.os.tag == .windows) continue;
if (target.result.os.tag == .emscripten) {
const exe_lib = b.addStaticLibrary(.{
.name = name,
.target = target,
.optimize = optimize,
});
exe_lib.addCSourceFile(.{
.file = b.path(path),
.flags = &.{},
});
exe_lib.linkLibC();
if (std.mem.eql(u8, name, "rlgl_standalone")) {
//TODO: Make rlgl_standalone example work
continue;
}
if (std.mem.eql(u8, name, "raylib_opengl_interop")) {
//TODO: Make raylib_opengl_interop example work
continue;
}
exe_lib.linkLibrary(raylib);
// Include emscripten for cross compilation
if (b.lazyDependency("emsdk", .{})) |emsdk_dep| {
if (try emSdkSetupStep(b, emsdk_dep)) |emSdkStep| {
exe_lib.step.dependOn(&emSdkStep.step);
}
exe_lib.addIncludePath(emsdk_dep.path("upstream/emscripten/cache/sysroot/include"));
// Create the output directory because emcc can't do it.
const emccOutputDirExample = b.pathJoin(&.{ emccOutputDir, name, std.fs.path.sep_str });
const mkdir_command = switch (builtin.os.tag) {
.windows => b.addSystemCommand(&.{ "cmd.exe", "/c", "if", "not", "exist", emccOutputDirExample, "mkdir", emccOutputDirExample }),
else => b.addSystemCommand(&.{ "mkdir", "-p", emccOutputDirExample }),
};
const emcc_exe = switch (builtin.os.tag) {
.windows => "emcc.bat",
else => "emcc",
};
const emcc_exe_path = b.pathJoin(&.{ emsdk_dep.path("upstream/emscripten").getPath(b), emcc_exe });
const emcc_command = b.addSystemCommand(&[_][]const u8{emcc_exe_path});
emcc_command.step.dependOn(&mkdir_command.step);
const emccOutputDirExampleWithFile = b.pathJoin(&.{ emccOutputDir, name, std.fs.path.sep_str, emccOutputFile });
emcc_command.addArgs(&[_][]const u8{
"-o",
emccOutputDirExampleWithFile,
"-sFULL-ES3=1",
"-sUSE_GLFW=3",
"-sSTACK_OVERFLOW_CHECK=1",
"-sEXPORTED_RUNTIME_METHODS=['requestFullscreen']",
"-sASYNCIFY",
"-O0",
"--emrun",
"--preload-file",
module_resources,
"--shell-file",
b.path("src/shell.html").getPath(b),
});
const link_items: []const *std.Build.Step.Compile = &.{
raylib,
exe_lib,
};
for (link_items) |item| {
emcc_command.addFileArg(item.getEmittedBin());
emcc_command.step.dependOn(&item.step);
}
const run_step = try emscriptenRunStep(b, emsdk_dep, emccOutputDirExampleWithFile);
run_step.step.dependOn(&emcc_command.step);
run_step.addArg("--no_browser");
const run_option = b.step(name, name);
run_option.dependOn(&run_step.step);
all.dependOn(&emcc_command.step);
}
} else {
const exe = b.addExecutable(.{
.name = name,
.target = target,
.optimize = optimize,
});
exe.addCSourceFile(.{ .file = b.path(path), .flags = &.{} });
exe.linkLibC();
// special examples that test using these external dependencies directly
// alongside raylib
if (std.mem.eql(u8, name, "rlgl_standalone")) {
exe.addIncludePath(b.path("src"));
exe.addIncludePath(b.path("src/external/glfw/include"));
if (!hasCSource(raylib.root_module, "rglfw.c")) {
exe.addCSourceFile(.{ .file = b.path("src/rglfw.c"), .flags = &.{} });
}
}
if (std.mem.eql(u8, name, "raylib_opengl_interop")) {
exe.addIncludePath(b.path("src/external"));
}
exe.linkLibrary(raylib);
switch (target.result.os.tag) {
.windows => {
exe.linkSystemLibrary("winmm");
exe.linkSystemLibrary("gdi32");
exe.linkSystemLibrary("opengl32");
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
},
.linux => {
exe.linkSystemLibrary("GL");
exe.linkSystemLibrary("rt");
exe.linkSystemLibrary("dl");
exe.linkSystemLibrary("m");
exe.linkSystemLibrary("X11");
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
},
.macos => {
exe.linkFramework("Foundation");
exe.linkFramework("Cocoa");
exe.linkFramework("OpenGL");
exe.linkFramework("CoreAudio");
exe.linkFramework("CoreVideo");
exe.linkFramework("IOKit");
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
},
else => {
@panic("Unsupported OS");
},
}
const install_cmd = b.addInstallArtifact(exe, .{});
const run_cmd = b.addRunArtifact(exe);
run_cmd.cwd = b.path(module_subpath);
run_cmd.step.dependOn(&install_cmd.step);
const run_step = b.step(name, name);
run_step.dependOn(&run_cmd.step);
all.dependOn(&install_cmd.step);
}
}
return all;
}
fn hasCSource(module: *std.Build.Module, name: []const u8) bool { fn hasCSource(module: *std.Build.Module, name: []const u8) bool {
for (module.link_objects.items) |o| switch (o) { for (module.link_objects.items) |o| switch (o) {
.c_source_file => |c| if (switch (c.file) { .c_source_file => |c| if (switch (c.file) {

View File

@ -1,7 +1,7 @@
.{ .{
.name = .raylib, .name = .raylib,
.version = "5.5.0", .version = "5.6.0-dev",
.minimum_zig_version = "0.14.0", .minimum_zig_version = "0.15.1",
.fingerprint = 0x13035e5cb8bc1ac2, // Changing this has security and trust implications. .fingerprint = 0x13035e5cb8bc1ac2, // Changing this has security and trust implications.
@ -14,7 +14,10 @@
.emsdk = .{ .emsdk = .{
.url = "git+https://github.com/emscripten-core/emsdk#4.0.9", .url = "git+https://github.com/emscripten-core/emsdk#4.0.9",
.hash = "N-V-__8AAJl1DwBezhYo_VE6f53mPVm00R-Fk28NPW7P14EQ", .hash = "N-V-__8AAJl1DwBezhYo_VE6f53mPVm00R-Fk28NPW7P14EQ",
.lazy = true, },
.zemscripten = .{
.url = "git+https://github.com/zig-gamedev/zemscripten#3fa4b778852226c7346bdcc3c1486e875a9a6d02",
.hash = "zemscripten-0.2.0-dev-sRlDqApRAACspTbAZnuNKWIzfWzSYgYkb2nWAXZ-tqqt",
}, },
}, },

View File

@ -101,10 +101,37 @@ elseif ("${PLATFORM}" MATCHES "DRM")
set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} atomic pthread m dl) set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} atomic pthread m dl)
elseif ("${PLATFORM}" MATCHES "SDL") elseif ("${PLATFORM}" MATCHES "SDL")
find_package(SDL2 REQUIRED) # First, check if SDL is included as a subdirectory
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL") if(TARGET SDL3::SDL3)
set(LIBS_PRIVATE SDL2::SDL2) message(STATUS "Using SDL3 from subdirectory")
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
set(LIBS_PRIVATE SDL3::SDL3)
add_compile_definitions(USING_SDL3_PROJECT)
elseif(TARGET SDL2::SDL2)
message(STATUS "Using SDL2 from subdirectory")
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
set(LIBS_PRIVATE SDL2::SDL2)
add_compile_definitions(USING_SDL2_PROJECT)
else()
# No SDL added via add_subdirectory(), try find_package()
message(STATUS "No SDL target from subdirectory, searching via find_package()...")
# First try SDL3
find_package(SDL3 QUIET)
if(SDL3_FOUND)
message(STATUS "Found SDL3 via find_package()")
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
set(LIBS_PRIVATE SDL3::SDL3)
add_compile_definitions(USING_SDL3_PACKAGE)
else()
# Fallback to SDL2
find_package(SDL2 REQUIRED)
message(STATUS "Found SDL2 via find_package()")
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
set(LIBS_PRIVATE SDL2::SDL2)
add_compile_definitions(USING_SDL2_PACKAGE)
endif()
endif()
endif () endif ()
if (NOT ${OPENGL_VERSION} MATCHES "OFF") if (NOT ${OPENGL_VERSION} MATCHES "OFF")

View File

@ -106,6 +106,9 @@ BUILD_WEB_SHELL ?= $(RAYLIB_PATH)/src/minshell.html
BUILD_WEB_HEAP_SIZE ?= 134217728 BUILD_WEB_HEAP_SIZE ?= 134217728
BUILD_WEB_RESOURCES ?= TRUE BUILD_WEB_RESOURCES ?= TRUE
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
# Use WebGL2 backend (OpenGL 3.0)
# WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3
BUILD_WEB_WEBGL2 ?= FALSE
# Determine PLATFORM_OS when required # Determine PLATFORM_OS when required
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB PLATFORM_WEB_RGFW))
@ -186,7 +189,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
endif endif
endif endif
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# HTML5 emscripten compiler # HTML5 emscripten compiler
# WARNING: To compile to HTML5, code must be redesigned # WARNING: To compile to HTML5, code must be redesigned
# to use emscripten.h and emscripten_set_main_loop() # to use emscripten.h and emscripten_set_main_loop()
CC = emcc CC = emcc
@ -269,8 +272,8 @@ endif
# NOTE: Some external/extras libraries could be required (stb, easings...) # NOTE: Some external/extras libraries could be required (stb, easings...)
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external $(EXTRA_INCLUDE_PATHS) INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external $(EXTRA_INCLUDE_PATHS)
# Define additional directories containing required header files
# Define additional directories containing required header files
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
ifeq ($(PLATFORM_OS),BSD) ifeq ($(PLATFORM_OS),BSD)
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH) -I/usr/pkg/include -I/usr/X11R7/include INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH) -I/usr/pkg/include -I/usr/X11R7/include
@ -287,11 +290,6 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
INCLUDE_PATHS += -I/usr/include/libdrm INCLUDE_PATHS += -I/usr/include/libdrm
endif endif
# Include GLFW required for examples/others/rlgl_standalone.c
ifeq ($(USE_EXTERNAL_GLFW),FALSE)
all others: INCLUDE_PATHS += -I$(RAYLIB_PATH)/src/external/glfw/include
endif
# Define library paths containing required libs: LDFLAGS # Define library paths containing required libs: LDFLAGS
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
@ -340,18 +338,24 @@ ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_R
# --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
# --shell-file shell.html # define a custom shell .html and output extension # --shell-file shell.html # define a custom shell .html and output extension
LDFLAGS += -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1 -sMINIFY_HTML=0 LDFLAGS += -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1 -sEXPORTED_RUNTIME_METHODS=ccall -sMINIFY_HTML=0
# Using GLFW3 library (instead of RGFW) # Using GLFW3 library (instead of RGFW)
ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
LDFLAGS += -sUSE_GLFW=3 LDFLAGS += -sUSE_GLFW=3
endif endif
# Build using asyncify # Build using asyncify
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE) ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
LDFLAGS += -sASYNCIFY LDFLAGS += -sASYNCIFY
endif endif
# NOTE: Flags required for WebGL 2.0 (OpenGL ES 3.0)
# WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3
ifeq ($(BUILD_WEB_WEBGL2),TRUE)
LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2
endif
# Add resources building if required # Add resources building if required
ifeq ($(BUILD_WEB_RESOURCES),TRUE) ifeq ($(BUILD_WEB_RESOURCES),TRUE)
LDFLAGS += --preload-file $(BUILD_WEB_RESOURCES_PATH) LDFLAGS += --preload-file $(BUILD_WEB_RESOURCES_PATH)
@ -489,8 +493,11 @@ ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_R
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a
endif endif
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
# Define source code object files required # Define source code object files required
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
#EXAMPLES_LIST_START
CORE = \ CORE = \
core/core_2d_camera \ core/core_2d_camera \
core/core_2d_camera_mouse_zoom \ core/core_2d_camera_mouse_zoom \
@ -500,6 +507,7 @@ CORE = \
core/core_3d_camera_free \ core/core_3d_camera_free \
core/core_3d_camera_mode \ core/core_3d_camera_mode \
core/core_3d_camera_split_screen \ core/core_3d_camera_split_screen \
core/core_3d_camera_fps \
core/core_3d_picking \ core/core_3d_picking \
core/core_automation_events \ core/core_automation_events \
core/core_basic_screen_manager \ core/core_basic_screen_manager \
@ -534,6 +542,8 @@ SHAPES = \
shapes/shapes_bouncing_ball \ shapes/shapes_bouncing_ball \
shapes/shapes_collision_area \ shapes/shapes_collision_area \
shapes/shapes_colors_palette \ shapes/shapes_colors_palette \
shapes/shapes_digital_clock \
shapes/shapes_double_pendulum \
shapes/shapes_draw_circle_sector \ shapes/shapes_draw_circle_sector \
shapes/shapes_draw_rectangle_rounded \ shapes/shapes_draw_rectangle_rounded \
shapes/shapes_draw_ring \ shapes/shapes_draw_ring \
@ -547,8 +557,7 @@ SHAPES = \
shapes/shapes_rectangle_advanced \ shapes/shapes_rectangle_advanced \
shapes/shapes_rectangle_scaling \ shapes/shapes_rectangle_scaling \
shapes/shapes_splines_drawing \ shapes/shapes_splines_drawing \
shapes/shapes_top_down_lights \ shapes/shapes_top_down_lights
shapes/shapes_digital_clock
TEXTURES = \ TEXTURES = \
textures/textures_background_scrolling \ textures/textures_background_scrolling \
@ -590,6 +599,7 @@ TEXT = \
text/text_raylib_fonts \ text/text_raylib_fonts \
text/text_rectangle_bounds \ text/text_rectangle_bounds \
text/text_unicode \ text/text_unicode \
text/text_unicode_ranges \
text/text_writing_anim text/text_writing_anim
MODELS = \ MODELS = \
@ -631,6 +641,7 @@ SHADERS = \
shaders/shaders_mesh_instancing \ shaders/shaders_mesh_instancing \
shaders/shaders_model_shader \ shaders/shaders_model_shader \
shaders/shaders_multi_sample2d \ shaders/shaders_multi_sample2d \
shaders/shaders_normal_map \
shaders/shaders_palette_switch \ shaders/shaders_palette_switch \
shaders/shaders_postprocessing \ shaders/shaders_postprocessing \
shaders/shaders_raymarching \ shaders/shaders_raymarching \
@ -643,9 +654,9 @@ SHADERS = \
shaders/shaders_texture_outline \ shaders/shaders_texture_outline \
shaders/shaders_texture_tiling \ shaders/shaders_texture_tiling \
shaders/shaders_texture_waves \ shaders/shaders_texture_waves \
shaders/shaders_vertex_displacement \
shaders/shaders_view_depth \ shaders/shaders_view_depth \
shaders/shaders_write_depth \ shaders/shaders_write_depth
shaders/shaders_vertex_displacement
AUDIO = \ AUDIO = \
audio/audio_mixed_processor \ audio/audio_mixed_processor \
@ -662,18 +673,14 @@ OTHERS = \
others/embedded_files_loading \ others/embedded_files_loading \
others/raylib_opengl_interop \ others/raylib_opengl_interop \
others/raymath_vector_angle \ others/raymath_vector_angle \
others/rlgl_compute_shader others/rlgl_compute_shader \
others/rlgl_standalone
ifeq ($(TARGET_PLATFORM), PLATFORM_DESKTOP_GFLW) #EXAMPLES_LIST_END
OTHERS += others/rlgl_standalone
endif
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
# Define processes to execute # Define processes to execute
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
# Default target entry # Default target entry
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) $(OTHERS) all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO)
core: $(CORE) core: $(CORE)
shapes: $(SHAPES) shapes: $(SHAPES)
@ -682,7 +689,6 @@ text: $(TEXT)
models: $(MODELS) models: $(MODELS)
shaders: $(SHADERS) shaders: $(SHADERS)
audio: $(AUDIO) audio: $(AUDIO)
others: $(OTHERS)
# Generic compilation pattern # Generic compilation pattern
# NOTE: Examples must be ready for Android compilation! # NOTE: Examples must be ready for Android compilation!

View File

@ -1,6 +1,34 @@
#************************************************************************************************** #**************************************************************************************************
# #
# raylib makefile for Web platform # raylib makefile for multiple platforms
#
# This file supports building raylib examples for the following platforms:
#
# > PLATFORM_DESKTOP
# - Defaults to PLATFORM_DESKTOP_GLFW
# > PLATFORM_DESKTOP_GFLW (GLFW backend):
# - Windows (Win32, Win64)
# - Linux (X11/Wayland desktop mode)
# - macOS/OSX (x64, arm64)
# - FreeBSD, OpenBSD, NetBSD, DragonFly (X11 desktop)
# > PLATFORM_DESKTOP_SDL (SDL backend):
# - Windows (Win32, Win64)
# - Linux (X11/Wayland desktop mode)
# - Others (not tested)
# > PLATFORM_DESKTOP_RGFW (RGFW backend):
# - Windows (Win32, Win64)
# - Linux (X11 desktop mode)
# - macOS/OSX (x64, arm64 (not tested))
# - Others (not tested)
# > PLATFORM_WEB_RGFW:
# - HTML5 (WebAssembly)
# > PLATFORM_WEB:
# - HTML5 (WebAssembly)
# > PLATFORM_DRM:
# - Raspberry Pi 0-5 (DRM/KMS)
# - Linux DRM subsystem (KMS mode)
# > PLATFORM_ANDROID:
# - Android (ARM, ARM64)
# #
# Copyright (c) 2013-2025 Ramon Santamaria (@raysan5) # Copyright (c) 2013-2025 Ramon Santamaria (@raysan5)
# #
@ -25,9 +53,20 @@
# Define required environment variables # Define required environment variables
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
# Define target platform: PLATFORM_DESKTOP, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB # Define target platform: PLATFORM_DESKTOP, PLATFORM_DESKTOP_SDL, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB, PLATFORM_WEB_RGFW
PLATFORM ?= PLATFORM_WEB PLATFORM ?= PLATFORM_WEB
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW))
TARGET_PLATFORM := $(PLATFORM)
override PLATFORM = PLATFORM_DESKTOP
else
ifeq ($(PLATFORM), PLATFORM_DESKTOP)
TARGET_PLATFORM = PLATFORM_DESKTOP_GLFW
else
TARGET_PLATFORM = $(PLATFORM)
endif
endif
# Define required raylib variables # Define required raylib variables
PROJECT_NAME ?= raylib_examples PROJECT_NAME ?= raylib_examples
RAYLIB_VERSION ?= 5.5.0 RAYLIB_VERSION ?= 5.5.0
@ -51,6 +90,12 @@ BUILD_MODE ?= RELEASE
# Use external GLFW library instead of rglfw module # Use external GLFW library instead of rglfw module
USE_EXTERNAL_GLFW ?= FALSE USE_EXTERNAL_GLFW ?= FALSE
# PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally
# WARNING: Library is not included in raylib, it MUST be configured by users
SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
SDL_LIBRARY_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/lib
SDL_LIBRARIES ?= -lSDL2 -lSDL2main
# Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system) # Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system)
# NOTE: This variable is only used for PLATFORM_OS: LINUX # NOTE: This variable is only used for PLATFORM_OS: LINUX
USE_WAYLAND_DISPLAY ?= FALSE USE_WAYLAND_DISPLAY ?= FALSE
@ -59,13 +104,14 @@ USE_WAYLAND_DISPLAY ?= FALSE
BUILD_WEB_ASYNCIFY ?= TRUE BUILD_WEB_ASYNCIFY ?= TRUE
BUILD_WEB_SHELL ?= $(RAYLIB_PATH)/src/shell.html BUILD_WEB_SHELL ?= $(RAYLIB_PATH)/src/shell.html
BUILD_WEB_HEAP_SIZE ?= 134217728 BUILD_WEB_HEAP_SIZE ?= 134217728
BUILD_WEB_RESOURCES ?= FALSE
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
# Use WebGL2 backend (OpenGL 3.0) # Use WebGL2 backend (OpenGL 3.0)
# WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3 # WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3
USE_WEBGL2 ?= FALSE BUILD_WEB_WEBGL2 ?= FALSE
# Determine PLATFORM_OS in case PLATFORM_DESKTOP or PLATFORM_WEB selected # Determine PLATFORM_OS when required
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB PLATFORM_WEB_RGFW))
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! # No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows # ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
@ -92,7 +138,7 @@ ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB PLATFORM_WE
endif endif
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_DRM) ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
UNAMEOS = $(shell uname) UNAMEOS = $(shell uname)
ifeq ($(UNAMEOS),Linux) ifeq ($(UNAMEOS),Linux)
PLATFORM_OS = LINUX PLATFORM_OS = LINUX
@ -101,7 +147,7 @@ endif
# RAYLIB_PATH adjustment for LINUX platform # RAYLIB_PATH adjustment for LINUX platform
# TODO: Do we really need this? # TODO: Do we really need this?
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_PREFIX ?= .. RAYLIB_PREFIX ?= ..
RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX))
@ -109,14 +155,14 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif endif
# Default path for raylib on Raspberry Pi # Default path for raylib on Raspberry Pi
ifeq ($(PLATFORM),PLATFORM_DRM) ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
RAYLIB_PATH ?= /home/pi/raylib RAYLIB_PATH ?= /home/pi/raylib
endif endif
# Define raylib release directory for compiled library # Define raylib release directory for compiled library
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# Emscripten required variables # Emscripten required variables
EMSDK_PATH ?= C:/raylib/emsdk EMSDK_PATH ?= C:/raylib/emsdk
@ -132,7 +178,7 @@ endif
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
CC = gcc CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
ifeq ($(PLATFORM_OS),OSX) ifeq ($(PLATFORM_OS),OSX)
# OSX default compiler # OSX default compiler
CC = clang CC = clang
@ -142,7 +188,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
CC = clang CC = clang
endif endif
endif endif
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# HTML5 emscripten compiler # HTML5 emscripten compiler
# WARNING: To compile to HTML5, code must be redesigned # WARNING: To compile to HTML5, code must be redesigned
# to use emscripten.h and emscripten_set_main_loop() # to use emscripten.h and emscripten_set_main_loop()
@ -153,15 +199,15 @@ endif
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
MAKE ?= make MAKE ?= make
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
MAKE = mingw32-make MAKE = mingw32-make
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
MAKE = mingw32-make MAKE = mingw32-make
endif endif
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
MAKE = mingw32-make MAKE = mingw32-make
else else
@ -190,14 +236,14 @@ CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result
ifeq ($(BUILD_MODE),DEBUG) ifeq ($(BUILD_MODE),DEBUG)
CFLAGS += -g -D_DEBUG CFLAGS += -g -D_DEBUG
else else
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE) ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
CFLAGS += -O3 CFLAGS += -O3
else else
CFLAGS += -Os CFLAGS += -Os
endif endif
else else
CFLAGS += -s -O2 CFLAGS += -O2
endif endif
endif endif
@ -207,7 +253,7 @@ endif
# -Wstrict-prototypes warn if a function is declared or defined without specifying the argument types # -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 # -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 ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
ifeq ($(RAYLIB_LIBTYPE),STATIC) ifeq ($(RAYLIB_LIBTYPE),STATIC)
CFLAGS += -D_DEFAULT_SOURCE CFLAGS += -D_DEFAULT_SOURCE
@ -218,25 +264,29 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif endif
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_DRM) ifeq ($(TARGET_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 # Define include paths for required headers: INCLUDE_PATHS
# NOTE: Some external/extras libraries could be required (stb, easings...) # NOTE: Some external/extras libraries could be required (stb, easings...)
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external $(EXTRA_INCLUDE_PATHS)
# Define additional directories containing required header files # Define additional directories containing required header files
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
ifeq ($(PLATFORM_OS),BSD) ifeq ($(PLATFORM_OS),BSD)
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH) INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH) -I/usr/pkg/include -I/usr/X11R7/include
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH) INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_DRM) ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
INCLUDE_PATHS += -I$(SDL_INCLUDE_PATH)
endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
INCLUDE_PATHS += -I/usr/include/libdrm INCLUDE_PATHS += -I/usr/include/libdrm
endif endif
@ -244,7 +294,7 @@ endif
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# NOTE: The resource .rc file contains windows executable icon and properties # NOTE: The resource .rc file contains windows executable icon and properties
LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
@ -260,7 +310,18 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH) LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH)
endif endif
endif endif
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
ifeq ($(PLATFORM_OS),WINDOWS)
# NOTE: The resource .rc file contains windows executable icon and properties
LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
# -Wl,--subsystem,windows hides the console window
ifeq ($(BUILD_MODE), RELEASE)
LDFLAGS += -Wl,--subsystem,windows
endif
endif
LDFLAGS += -L$(SDL_LIBRARY_PATH)
endif
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# -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
# -sUSE_GLFW=3 # Use glfw3 library (context/input management) # -sUSE_GLFW=3 # Use glfw3 library (context/input management)
@ -277,10 +338,10 @@ ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# --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
# --shell-file shell.html # define a custom shell .html and output extension # --shell-file shell.html # define a custom shell .html and output extension
LDFLAGS += -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1 -sEXPORTED_RUNTIME_METHODS=ccall -sMINIFY_HTML=0 LDFLAGS += -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1 -sEXPORTED_RUNTIME_METHODS=ccall -sMINIFY_HTML=0
# Using GLFW3 library (instead of RGFW) # Using GLFW3 library (instead of RGFW)
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
LDFLAGS += -sUSE_GLFW=3 LDFLAGS += -sUSE_GLFW=3
endif endif
@ -291,9 +352,14 @@ ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# NOTE: Flags required for WebGL 2.0 (OpenGL ES 3.0) # NOTE: Flags required for WebGL 2.0 (OpenGL ES 3.0)
# WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3 # WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3
ifeq ($(USE_WEBGL2),TRUE) ifeq ($(BUILD_WEB_WEBGL2),TRUE)
LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2
endif endif
# Add resources building if required
ifeq ($(BUILD_WEB_RESOURCES),TRUE)
LDFLAGS += --preload-file $(BUILD_WEB_RESOURCES_PATH)
endif
# Add debug mode flags if required # Add debug mode flags if required
ifeq ($(BUILD_MODE),DEBUG) ifeq ($(BUILD_MODE),DEBUG)
@ -314,7 +380,7 @@ endif
# Define libraries required on linking: LDLIBS # Define libraries required on linking: LDLIBS
# NOTE: To link libraries (lib<name>.so or lib<name>.a), use -l<name> # NOTE: To link libraries (lib<name>.so or lib<name>.a), use -l<name>
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compilation # Libraries for Windows desktop compilation
# NOTE: WinMM library required to set high-res timer resolution # NOTE: WinMM library required to set high-res timer resolution
@ -361,18 +427,77 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
LDLIBS += -lglfw LDLIBS += -lglfw
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_DRM) ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compilation
LDLIBS = -lraylib $(SDL_LIBRARIES) -lopengl32 -lgdi32
endif
ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib $(SDL_LIBRARIES) -lGL -lm -lpthread -ldl -lrt
# On X11 requires also below libraries
LDLIBS += -lX11
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On Wayland windowing system, additional libraries requires
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
endif
# Explicit link to libc
ifeq ($(RAYLIB_LIBTYPE),SHARED)
LDLIBS += -lc
endif
# NOTE: On ARM 32bit arch, miniaudio requires atomics library
LDLIBS += -latomic
endif
endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compilation
LDFLAGS += -L..\src
LDLIBS = -lraylib -lgdi32 -lwinmm -lopengl32
endif
ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compipling
# NOTE: Required packages: libegl1-mesa-dev
LDFLAGS += -L../src
LDLIBS = -lraylib -lGL -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lm -lpthread -ldl -lrt
# Explicit link to libc
ifeq ($(RAYLIB_LIBTYPE),SHARED)
LDLIBS += -lc
endif
# NOTE: On ARM 32bit arch, miniaudio requires atomics library
LDLIBS += -latomic
endif
ifeq ($(PLATFORM_OS),OSX)
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libegl1-mesa-dev
LDFLAGS += -L../src
LDLIBS = -lraylib -lm
LDLIBS += -framework Foundation -framework AppKit -framework IOKit -framework OpenGL -framework CoreVideo
endif
endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
# Libraries for DRM compiling # Libraries for DRM compiling
# NOTE: Required packages: libasound2-dev (ALSA) # NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic
endif endif
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# Libraries for web (HTML5) compiling # Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a
endif endif
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
# Define source code object files required # Define source code object files required
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
#EXAMPLES_LIST_START
CORE = \ CORE = \
core/core_2d_camera \ core/core_2d_camera \
core/core_2d_camera_mouse_zoom \ core/core_2d_camera_mouse_zoom \
@ -382,6 +507,7 @@ CORE = \
core/core_3d_camera_free \ core/core_3d_camera_free \
core/core_3d_camera_mode \ core/core_3d_camera_mode \
core/core_3d_camera_split_screen \ core/core_3d_camera_split_screen \
core/core_3d_camera_fps \
core/core_3d_picking \ core/core_3d_picking \
core/core_automation_events \ core/core_automation_events \
core/core_basic_screen_manager \ core/core_basic_screen_manager \
@ -416,6 +542,8 @@ SHAPES = \
shapes/shapes_bouncing_ball \ shapes/shapes_bouncing_ball \
shapes/shapes_collision_area \ shapes/shapes_collision_area \
shapes/shapes_colors_palette \ shapes/shapes_colors_palette \
shapes/shapes_digital_clock \
shapes/shapes_double_pendulum \
shapes/shapes_draw_circle_sector \ shapes/shapes_draw_circle_sector \
shapes/shapes_draw_rectangle_rounded \ shapes/shapes_draw_rectangle_rounded \
shapes/shapes_draw_ring \ shapes/shapes_draw_ring \
@ -429,8 +557,7 @@ SHAPES = \
shapes/shapes_rectangle_advanced \ shapes/shapes_rectangle_advanced \
shapes/shapes_rectangle_scaling \ shapes/shapes_rectangle_scaling \
shapes/shapes_splines_drawing \ shapes/shapes_splines_drawing \
shapes/shapes_top_down_lights \ shapes/shapes_top_down_lights
shapes/shapes_digital_clock
TEXTURES = \ TEXTURES = \
textures/textures_background_scrolling \ textures/textures_background_scrolling \
@ -472,6 +599,7 @@ TEXT = \
text/text_raylib_fonts \ text/text_raylib_fonts \
text/text_rectangle_bounds \ text/text_rectangle_bounds \
text/text_unicode \ text/text_unicode \
text/text_unicode_ranges \
text/text_writing_anim text/text_writing_anim
MODELS = \ MODELS = \
@ -513,6 +641,7 @@ SHADERS = \
shaders/shaders_mesh_instancing \ shaders/shaders_mesh_instancing \
shaders/shaders_model_shader \ shaders/shaders_model_shader \
shaders/shaders_multi_sample2d \ shaders/shaders_multi_sample2d \
shaders/shaders_normal_map \
shaders/shaders_palette_switch \ shaders/shaders_palette_switch \
shaders/shaders_postprocessing \ shaders/shaders_postprocessing \
shaders/shaders_raymarching \ shaders/shaders_raymarching \
@ -539,18 +668,6 @@ AUDIO = \
audio/audio_sound_positioning \ audio/audio_sound_positioning \
audio/audio_stream_effects audio/audio_stream_effects
OTHERS = \
others/easings_testbed \
others/embedded_files_loading \
others/raylib_opengl_interop \
others/raymath_vector_angle \
others/rlgl_compute_shader \
others/rlgl_standalone
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
# Define processes to execute
#------------------------------------------------------------------------------------------------
# Default target entry # Default target entry
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO)
@ -587,10 +704,16 @@ core/core_3d_camera_mode: core/core_3d_camera_mode.c
core/core_3d_camera_split_screen: core/core_3d_camera_split_screen.c core/core_3d_camera_split_screen: core/core_3d_camera_split_screen.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_3d_camera_fps: core/core_3d_camera_fps.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_3d_picking: core/core_3d_picking.c core/core_3d_picking: core/core_3d_picking.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_automation_events : core/core_automation_events.c core/core_automation_events: core/core_automation_events.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_basic_screen_manager: core/core_basic_screen_manager.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_basic_window: core/core_basic_window.c core/core_basic_window: core/core_basic_window.c
@ -599,9 +722,6 @@ core/core_basic_window: core/core_basic_window.c
core/core_basic_window_web: core/core_basic_window_web.c core/core_basic_window_web: core/core_basic_window_web.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_basic_screen_manager: core/core_basic_screen_manager.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_custom_frame_control: core/core_custom_frame_control.c core/core_custom_frame_control: core/core_custom_frame_control.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@ -609,7 +729,10 @@ core/core_custom_logging: core/core_custom_logging.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_drop_files: core/core_drop_files.c core/core_drop_files: core/core_drop_files.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 -sFORCE_FILESYSTEM=1 $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_high_dpi: core/core_high_dpi.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_input_gamepad: core/core_input_gamepad.c core/core_input_gamepad: core/core_input_gamepad.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
@ -637,12 +760,8 @@ core/core_input_multitouch: core/core_input_multitouch.c
core/core_input_virtual_controls: core/core_input_virtual_controls.c core/core_input_virtual_controls: core/core_input_virtual_controls.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
# NOTE: To use multi-threading raylib must be compiled with multi-theading support (-sUSE_PTHREADS=1)
# WARNING: For security reasons multi-threading is not supported on browsers, it requires cross-origin isolation (Oct.2021)
# WARNING: It requires raylib to be compiled using -pthread, so atomic operations and thread-local data (if any)
# in its source were transformed to non-atomic operations and non-thread-local data
core/core_loading_thread: core/core_loading_thread.c core/core_loading_thread: core/core_loading_thread.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sUSE_PTHREADS=1 $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_random_sequence: core/core_random_sequence.c core/core_random_sequence: core/core_random_sequence.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@ -657,11 +776,11 @@ core/core_smooth_pixelperfect: core/core_smooth_pixelperfect.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_storage_values: core/core_storage_values.c core/core_storage_values: core/core_storage_values.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sFORCE_FILESYSTEM=1 $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_vr_simulator: core/core_vr_simulator.c core/core_vr_simulator: core/core_vr_simulator.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file core/resources/distortion100.fs@resources/distortion100.fs --preload-file core/resources/shaders/glsl100/distortion.fs@resources/shaders/glsl100/distortion.fs
core/core_window_flags: core/core_window_flags.c core/core_window_flags: core/core_window_flags.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@ -675,7 +794,6 @@ core/core_window_should_close: core/core_window_should_close.c
core/core_world_screen: core/core_world_screen.c core/core_world_screen: core/core_world_screen.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
# Compile SHAPES examples # Compile SHAPES examples
shapes/shapes_basic_shapes: shapes/shapes_basic_shapes.c shapes/shapes_basic_shapes: shapes/shapes_basic_shapes.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@ -689,6 +807,12 @@ shapes/shapes_collision_area: shapes/shapes_collision_area.c
shapes/shapes_colors_palette: shapes/shapes_colors_palette.c shapes/shapes_colors_palette: shapes/shapes_colors_palette.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
shapes/shapes_digital_clock: shapes/shapes_digital_clock.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
shapes/shapes_double_pendulum: shapes/shapes_double_pendulum.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
shapes/shapes_draw_circle_sector: shapes/shapes_draw_circle_sector.c shapes/shapes_draw_circle_sector: shapes/shapes_draw_circle_sector.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@ -719,6 +843,9 @@ shapes/shapes_logo_raylib: shapes/shapes_logo_raylib.c
shapes/shapes_logo_raylib_anim: shapes/shapes_logo_raylib_anim.c shapes/shapes_logo_raylib_anim: shapes/shapes_logo_raylib_anim.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
shapes/shapes_rectangle_advanced: shapes/shapes_rectangle_advanced.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
shapes/shapes_rectangle_scaling: shapes/shapes_rectangle_scaling.c shapes/shapes_rectangle_scaling: shapes/shapes_rectangle_scaling.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@ -728,10 +855,6 @@ shapes/shapes_splines_drawing: shapes/shapes_splines_drawing.c
shapes/shapes_top_down_lights: shapes/shapes_top_down_lights.c shapes/shapes_top_down_lights: shapes/shapes_top_down_lights.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
shapes/shapes_rectangle_advanced: shapes/shapes_rectangle_advanced.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
# Compile TEXTURES examples # Compile TEXTURES examples
textures/textures_background_scrolling: textures/textures_background_scrolling.c textures/textures_background_scrolling: textures/textures_background_scrolling.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
@ -765,16 +888,16 @@ textures/textures_image_channel: textures/textures_image_channel.c
textures/textures_image_drawing: textures/textures_image_drawing.c textures/textures_image_drawing: textures/textures_image_drawing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/resources/custom_jupiter_crash.png@resources/custom_jupiter_crash.png \ --preload-file textures/resources/cat.png@resources/cat.png \
--preload-file textures/resources/parrots.png@resources/parrots.png \ --preload-file textures/resources/parrots.png@resources/parrots.png \
--preload-file textures/resources/cat.png@resources/cat.png --preload-file textures/resources/custom_jupiter_crash.png@resources/custom_jupiter_crash.png
textures/textures_image_generation: textures/textures_image_generation.c textures/textures_image_generation: textures/textures_image_generation.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
textures/textures_image_kernel: textures/textures_image_kernel.c textures/textures_image_kernel: textures/textures_image_kernel.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/resources/cat.png@resources/cat.png --preload-file textures/resources/cat.png@resources/cat.png
textures/textures_image_loading: textures/textures_image_loading.c textures/textures_image_loading: textures/textures_image_loading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
@ -786,10 +909,10 @@ textures/textures_image_processing: textures/textures_image_processing.c
textures/textures_image_rotate: textures/textures_image_rotate.c textures/textures_image_rotate: textures/textures_image_rotate.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/resources/raylib_logo.png --preload-file textures/resources/raylib_logo.png@resources/raylib_logo.png
textures/textures_image_text: textures/textures_image_text.c textures/textures_image_text: textures/textures_image_text.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/resources/parrots.png@resources/parrots.png \ --preload-file textures/resources/parrots.png@resources/parrots.png \
--preload-file textures/resources/KAISG.ttf@resources/KAISG.ttf --preload-file textures/resources/KAISG.ttf@resources/KAISG.ttf
@ -822,13 +945,13 @@ textures/textures_sprite_anim: textures/textures_sprite_anim.c
textures/textures_sprite_button: textures/textures_sprite_button.c textures/textures_sprite_button: textures/textures_sprite_button.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/resources/button.png@resources/button.png \ --preload-file textures/resources/buttonfx.wav@resources/buttonfx.wav \
--preload-file textures/resources/buttonfx.wav@resources/buttonfx.wav --preload-file textures/resources/button.png@resources/button.png
textures/textures_sprite_explosion: textures/textures_sprite_explosion.c textures/textures_sprite_explosion: textures/textures_sprite_explosion.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/resources/explosion.png@resources/explosion.png \ --preload-file textures/resources/boom.wav@resources/boom.wav \
--preload-file textures/resources/boom.wav@resources/boom.wav --preload-file textures/resources/explosion.png@resources/explosion.png
textures/textures_srcrec_dstrec: textures/textures_srcrec_dstrec.c textures/textures_srcrec_dstrec: textures/textures_srcrec_dstrec.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
@ -842,7 +965,6 @@ textures/textures_to_image: textures/textures_to_image.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/resources/raylib_logo.png@resources/raylib_logo.png --preload-file textures/resources/raylib_logo.png@resources/raylib_logo.png
# Compile TEXT examples # Compile TEXT examples
text/text_codepoints_loading: text/text_codepoints_loading.c text/text_codepoints_loading: text/text_codepoints_loading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
@ -853,17 +975,14 @@ text/text_draw_3d: text/text_draw_3d.c
--preload-file text/resources/shaders/glsl100/alpha_discard.fs@resources/shaders/glsl100/alpha_discard.fs --preload-file text/resources/shaders/glsl100/alpha_discard.fs@resources/shaders/glsl100/alpha_discard.fs
text/text_font_filters: text/text_font_filters.c text/text_font_filters: text/text_font_filters.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file text/resources/KAISG.ttf@resources/KAISG.ttf --preload-file text/resources/KAISG.ttf@resources/KAISG.ttf
text/text_font_loading: text/text_font_loading.c text/text_font_loading: text/text_font_loading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
--preload-file text/resources/pixantiqua.fnt@resources/pixantiqua.fnt \
--preload-file text/resources/pixantiqua.png@resources/pixantiqua.png \
--preload-file text/resources/pixantiqua.ttf@resources/pixantiqua.ttf
text/text_font_sdf: text/text_font_sdf.c text/text_font_sdf: text/text_font_sdf.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file text/resources/anonymous_pro_bold.ttf@resources/anonymous_pro_bold.ttf \ --preload-file text/resources/anonymous_pro_bold.ttf@resources/anonymous_pro_bold.ttf \
--preload-file text/resources/shaders/glsl100/sdf.fs@resources/shaders/glsl100/sdf.fs --preload-file text/resources/shaders/glsl100/sdf.fs@resources/shaders/glsl100/sdf.fs
@ -881,44 +1000,38 @@ text/text_input_box: text/text_input_box.c
text/text_raylib_fonts: text/text_raylib_fonts.c text/text_raylib_fonts: text/text_raylib_fonts.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file text/resources/fonts/alagard.png@resources/fonts/alagard.png \ --preload-file text/resources/sprite_fonts/alagard.png@resources/sprite_fonts/alagard.png \
--preload-file text/resources/fonts/pixelplay.png@resources/fonts/pixelplay.png \ --preload-file text/resources/sprite_fonts/pixelplay.png@resources/sprite_fonts/pixelplay.png \
--preload-file text/resources/fonts/mecha.png@resources/fonts/mecha.png \ --preload-file text/resources/sprite_fonts/mecha.png@resources/sprite_fonts/mecha.png \
--preload-file text/resources/fonts/setback.png@resources/fonts/setback.png \ --preload-file text/resources/sprite_fonts/setback.png@resources/sprite_fonts/setback.png \
--preload-file text/resources/fonts/romulus.png@resources/fonts/romulus.png \ --preload-file text/resources/sprite_fonts/romulus.png@resources/sprite_fonts/romulus.png \
--preload-file text/resources/fonts/pixantiqua.png@resources/fonts/pixantiqua.png \ --preload-file text/resources/sprite_fonts/pixantiqua.png@resources/sprite_fonts/pixantiqua.png \
--preload-file text/resources/fonts/alpha_beta.png@resources/fonts/alpha_beta.png \ --preload-file text/resources/sprite_fonts/alpha_beta.png@resources/sprite_fonts/alpha_beta.png \
--preload-file text/resources/fonts/jupiter_crash.png@resources/fonts/jupiter_crash.png --preload-file text/resources/sprite_fonts/jupiter_crash.png@resources/sprite_fonts/jupiter_crash.png
text/text_rectangle_bounds: text/text_rectangle_bounds.c text/text_rectangle_bounds: text/text_rectangle_bounds.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
text/text_unicode: text/text_unicode.c text/text_unicode: text/text_unicode.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file text/resources/dejavu.fnt@resources/dejavu.fnt \ --preload-file text/resources/dejavu.fnt@resources/dejavu.fnt \
--preload-file text/resources/dejavu.png@resources/dejavu.png \
--preload-file text/resources/noto_cjk.fnt@resources/noto_cjk.fnt \ --preload-file text/resources/noto_cjk.fnt@resources/noto_cjk.fnt \
--preload-file text/resources/noto_cjk.png@resources/noto_cjk.png \ --preload-file text/resources/symbola.fnt@resources/symbola.fnt
--preload-file text/resources/symbola.fnt@resources/symbola.fnt \
--preload-file text/resources/symbola.png@resources/symbola.png text/text_unicode_ranges: text/text_unicode_ranges.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file text/resources/NotoSansTC-Regular.ttf@resources/NotoSansTC-Regular.ttf
text/text_writing_anim: text/text_writing_anim.c text/text_writing_anim: text/text_writing_anim.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
# Compile MODELS examples # Compile MODELS examples
models/models_animation: models/models_animation.c models/models_animation: models/models_animation.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file models/resources/models/iqm/guy.iqm@resources/models/iqm/guy.iqm \ --preload-file models/resources/models/iqm/guy.iqm@resources/models/iqm/guy.iqm \
--preload-file models/resources/models/iqm/guytex.png@resources/models/iqm/guytex.png \ --preload-file models/resources/models/iqm/guytex.png@resources/models/iqm/guytex.png \
--preload-file models/resources/models/iqm/guyanim.iqm@resources/models/iqm/guyanim.iqm --preload-file models/resources/models/iqm/guyanim.iqm@resources/models/iqm/guyanim.iqm
models/models_gpu_skinning: models/models_gpu_skinning.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \
--preload-file models/resources/models/gltf/greenman.glb@resources/models/gltf/greenman.glb \
--preload-file models/resources/shaders/glsl100/skinning.vs@resources/shaders/glsl100/skinning.vs \
--preload-file models/resources/shaders/glsl100/skinning.fs@resources/shaders/glsl100/skinning.fs
models/models_billboard: models/models_billboard.c models/models_billboard: models/models_billboard.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file models/resources/billboard.png@resources/billboard.png --preload-file models/resources/billboard.png@resources/billboard.png
@ -950,28 +1063,37 @@ models/models_first_person_maze: models/models_first_person_maze.c
models/models_geometric_shapes: models/models_geometric_shapes.c models/models_geometric_shapes: models/models_geometric_shapes.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
models/models_gpu_skinning: models/models_gpu_skinning.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file models/resources/models/gltf/greenman.glb@resources/models/gltf/greenman.glb \
--preload-file models/resources/shaders/glsl100/skinning.vs@resources/shaders/glsl100/skinning.vs \
--preload-file models/resources/shaders/glsl100/skinning.fs@resources/shaders/glsl100/skinning.fs
models/models_heightmap: models/models_heightmap.c models/models_heightmap: models/models_heightmap.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file models/resources/heightmap.png@resources/heightmap.png --preload-file models/resources/heightmap.png@resources/heightmap.png
models/models_loading: models/models_loading.c models/models_loading: models/models_loading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file models/resources/models/obj/castle.obj@resources/models/obj/castle.obj \ --preload-file models/resources/models/obj/castle.obj@resources/models/obj/castle.obj \
--preload-file models/resources/models/obj/castle_diffuse.png@resources/models/obj/castle_diffuse.png --preload-file models/resources/models/obj/castle_diffuse.png@resources/models/obj/castle_diffuse.png
models/models_loading_gltf: models/models_loading_gltf.c models/models_loading_gltf: models/models_loading_gltf.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file models/resources/models/gltf/robot.glb@resources/models/gltf/robot.glb --preload-file models/resources/models/gltf/robot.glb@resources/models/gltf/robot.glb
models/models_loading_m3d: models/models_loading_m3d.c models/models_loading_m3d: models/models_loading_m3d.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file models/resources/models/m3d/cesium_man.m3d@resources/models/m3d/cesium_man.m3d --preload-file models/resources/models/m3d/cesium_man.m3d@resources/models/m3d/cesium_man.m3d
models/models_loading_vox: models/models_loading_vox.c models/models_loading_vox: models/models_loading_vox.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file models/resources/models/vox/chr_knight.vox@resources/models/vox/chr_knight.vox \ --preload-file models/resources/models/vox/chr_knight.vox@resources/models/vox/chr_knight.vox \
--preload-file models/resources/models/vox/chr_sword.vox@resources/models/vox/chr_sword.vox \ --preload-file models/resources/models/vox/chr_sword.vox@resources/models/vox/chr_sword.vox \
--preload-file models/resources/models/vox/monu9.vox@resources/models/vox/monu9.vox --preload-file models/resources/models/vox/monu9.vox@resources/models/vox/monu9.vox \
--preload-file models/resources/models/vox/fez.vox@resources/models/vox/fez.vox \
--preload-file models/resources/shaders/glsl100/voxel_lighting.vs@resources/shaders/glsl100/voxel_lighting.vs \
--preload-file models/resources/shaders/glsl100/voxel_lighting.fs@resources/shaders/glsl100/voxel_lighting.fs
models/models_mesh_generation: models/models_mesh_generation.c models/models_mesh_generation: models/models_mesh_generation.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@ -991,13 +1113,13 @@ models/models_rlgl_solar_system: models/models_rlgl_solar_system.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
models/models_skybox: models/models_skybox.c models/models_skybox: models/models_skybox.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 -sFORCE_FILESYSTEM=1 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file models/resources/dresden_square_2k.hdr@resources/dresden_square_2k.hdr \
--preload-file models/resources/skybox.png@resources/skybox.png \
--preload-file models/resources/shaders/glsl100/skybox.vs@resources/shaders/glsl100/skybox.vs \ --preload-file models/resources/shaders/glsl100/skybox.vs@resources/shaders/glsl100/skybox.vs \
--preload-file models/resources/shaders/glsl100/skybox.fs@resources/shaders/glsl100/skybox.fs \ --preload-file models/resources/shaders/glsl100/skybox.fs@resources/shaders/glsl100/skybox.fs \
--preload-file models/resources/shaders/glsl100/cubemap.vs@resources/shaders/glsl100/cubemap.vs \ --preload-file models/resources/shaders/glsl100/cubemap.vs@resources/shaders/glsl100/cubemap.vs \
--preload-file models/resources/shaders/glsl100/cubemap.fs@resources/shaders/glsl100/cubemap.fs --preload-file models/resources/shaders/glsl100/cubemap.fs@resources/shaders/glsl100/cubemap.fs \
--preload-file models/resources/dresden_square_2k.hdr@resources/dresden_square_2k.hdr \
--preload-file models/resources/skybox.png@resources/skybox.png
models/models_tesseract_view: models/models_tesseract_view.c models/models_tesseract_view: models/models_tesseract_view.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@ -1006,26 +1128,20 @@ models/models_waving_cubes: models/models_waving_cubes.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
models/models_yaw_pitch_roll: models/models_yaw_pitch_roll.c models/models_yaw_pitch_roll: models/models_yaw_pitch_roll.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file models/resources/models/obj/plane.obj@resources/models/obj/plane.obj \ --preload-file models/resources/models/obj/plane.obj@resources/models/obj/plane.obj \
--preload-file models/resources/models/obj/plane_diffuse.png@resources/models/obj/plane_diffuse.png --preload-file models/resources/models/obj/plane_diffuse.png@resources/models/obj/plane_diffuse.png
# Compile SHADERS examples
# Compile SHADER examples
shaders/shaders_basic_lighting: shaders/shaders_basic_lighting.c shaders/shaders_basic_lighting: shaders/shaders_basic_lighting.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/texel_checker.png@resources/texel_checker.png \ --preload-file shaders/resources/shaders/glsl100/lighting.vs@resources/shaders/glsl100/lighting.vs \
--preload-file shaders/resources/shaders/glsl100/lighting.fs@resources/shaders/glsl100/lighting.fs \ --preload-file shaders/resources/shaders/glsl100/lighting.fs@resources/shaders/glsl100/lighting.fs
--preload-file shaders/resources/shaders/glsl100/lighting.vs@resources/shaders/glsl100/lighting.vs
shaders/shaders_basic_pbr: shaders/shaders_basic_pbr.c shaders/shaders_basic_pbr: shaders/shaders_basic_pbr.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/pbr.vs@resources/shaders/glsl100/pbr.vs \ --preload-file shaders/resources/shaders/glsl100/pbr.vs@resources/shaders/glsl100/pbr.vs \
--preload-file shaders/resources/shaders/glsl120/pbr.vs@resources/shaders/glsl120/pbr.vs \
--preload-file shaders/resources/shaders/glsl330/pbr.vs@resources/shaders/glsl330/pbr.vs \
--preload-file shaders/resources/shaders/glsl100/pbr.fs@resources/shaders/glsl100/pbr.fs \ --preload-file shaders/resources/shaders/glsl100/pbr.fs@resources/shaders/glsl100/pbr.fs \
--preload-file shaders/resources/shaders/glsl120/pbr.fs@resources/shaders/glsl120/pbr.fs \
--preload-file shaders/resources/shaders/glsl330/pbr.fs@resources/shaders/glsl330/pbr.fs \
--preload-file shaders/resources/models/old_car_new.glb@resources/models/old_car_new.glb \ --preload-file shaders/resources/models/old_car_new.glb@resources/models/old_car_new.glb \
--preload-file shaders/resources/old_car_d.png@resources/old_car_d.png \ --preload-file shaders/resources/old_car_d.png@resources/old_car_d.png \
--preload-file shaders/resources/old_car_mra.png@resources/old_car_mra.png \ --preload-file shaders/resources/old_car_mra.png@resources/old_car_mra.png \
@ -1037,14 +1153,13 @@ shaders/shaders_basic_pbr: shaders/shaders_basic_pbr.c
--preload-file shaders/resources/road_n.png@resources/road_n.png --preload-file shaders/resources/road_n.png@resources/road_n.png
shaders/shaders_custom_uniform: shaders/shaders_custom_uniform.c shaders/shaders_custom_uniform: shaders/shaders_custom_uniform.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/models/barracks.obj@resources/models/barracks.obj \ --preload-file shaders/resources/models/barracks.obj@resources/models/barracks.obj \
--preload-file shaders/resources/models/barracks_diffuse.png@resources/models/barracks_diffuse.png \ --preload-file shaders/resources/models/barracks_diffuse.png@resources/models/barracks_diffuse.png \
--preload-file shaders/resources/shaders/glsl100/swirl.fs@resources/shaders/glsl100/swirl.fs --preload-file shaders/resources/shaders/glsl100/swirl.fs@resources/shaders/glsl100/swirl.fs
shaders/shaders_deferred_render: shaders/shaders_deferred_render.c shaders/shaders_deferred_render: shaders/shaders_deferred_render.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/fudesumi.png@resources/fudesumi.png \
--preload-file shaders/resources/shaders/glsl100/gbuffer.vs@resources/shaders/glsl100/gbuffer.vs \ --preload-file shaders/resources/shaders/glsl100/gbuffer.vs@resources/shaders/glsl100/gbuffer.vs \
--preload-file shaders/resources/shaders/glsl100/gbuffer.fs@resources/shaders/glsl100/gbuffer.fs \ --preload-file shaders/resources/shaders/glsl100/gbuffer.fs@resources/shaders/glsl100/gbuffer.fs \
--preload-file shaders/resources/shaders/glsl100/deferred_shading.vs@resources/shaders/glsl100/deferred_shading.vs \ --preload-file shaders/resources/shaders/glsl100/deferred_shading.vs@resources/shaders/glsl100/deferred_shading.vs \
@ -1057,11 +1172,11 @@ shaders/shaders_eratosthenes: shaders/shaders_eratosthenes.c
shaders/shaders_fog: shaders/shaders_fog.c shaders/shaders_fog: shaders/shaders_fog.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/texel_checker.png@resources/texel_checker.png \ --preload-file shaders/resources/texel_checker.png@resources/texel_checker.png \
--preload-file shaders/resources/shaders/glsl100/fog.fs@resources/shaders/glsl100/fog.fs \ --preload-file shaders/resources/shaders/glsl100/lighting.vs@resources/shaders/glsl100/lighting.vs \
--preload-file shaders/resources/shaders/glsl100/lighting.vs@resources/shaders/glsl100/lighting.vs --preload-file shaders/resources/shaders/glsl100/fog.fs@resources/shaders/glsl100/fog.fs
shaders/shaders_hot_reloading: shaders/shaders_hot_reloading.c shaders/shaders_hot_reloading: shaders/shaders_hot_reloading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sFORCE_FILESYSTEM=1 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/reload.fs@resources/shaders/glsl100/reload.fs --preload-file shaders/resources/shaders/glsl100/reload.fs@resources/shaders/glsl100/reload.fs
shaders/shaders_hybrid_render: shaders/shaders_hybrid_render.c shaders/shaders_hybrid_render: shaders/shaders_hybrid_render.c
@ -1074,7 +1189,7 @@ shaders/shaders_julia_set: shaders/shaders_julia_set.c
--preload-file shaders/resources/shaders/glsl100/julia_set.fs@resources/shaders/glsl100/julia_set.fs --preload-file shaders/resources/shaders/glsl100/julia_set.fs@resources/shaders/glsl100/julia_set.fs
shaders/shaders_lightmap: shaders/shaders_lightmap.c shaders/shaders_lightmap: shaders/shaders_lightmap.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sFORCE_FILESYSTEM=1 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/lightmap.vs@resources/shaders/glsl100/lightmap.vs \ --preload-file shaders/resources/shaders/glsl100/lightmap.vs@resources/shaders/glsl100/lightmap.vs \
--preload-file shaders/resources/shaders/glsl100/lightmap.fs@resources/shaders/glsl100/lightmap.fs \ --preload-file shaders/resources/shaders/glsl100/lightmap.fs@resources/shaders/glsl100/lightmap.fs \
--preload-file shaders/resources/cubicmap_atlas.png@resources/cubicmap_atlas.png \ --preload-file shaders/resources/cubicmap_atlas.png@resources/cubicmap_atlas.png \
@ -1086,7 +1201,7 @@ shaders/shaders_mesh_instancing: shaders/shaders_mesh_instancing.c
--preload-file shaders/resources/shaders/glsl100/lighting.fs@resources/shaders/glsl100/lighting.fs --preload-file shaders/resources/shaders/glsl100/lighting.fs@resources/shaders/glsl100/lighting.fs
shaders/shaders_model_shader: shaders/shaders_model_shader.c shaders/shaders_model_shader: shaders/shaders_model_shader.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/models/watermill.obj@resources/models/watermill.obj \ --preload-file shaders/resources/models/watermill.obj@resources/models/watermill.obj \
--preload-file shaders/resources/models/watermill_diffuse.png@resources/models/watermill_diffuse.png \ --preload-file shaders/resources/models/watermill_diffuse.png@resources/models/watermill_diffuse.png \
--preload-file shaders/resources/shaders/glsl100/grayscale.fs@resources/shaders/glsl100/grayscale.fs --preload-file shaders/resources/shaders/glsl100/grayscale.fs@resources/shaders/glsl100/grayscale.fs
@ -1095,39 +1210,61 @@ shaders/shaders_multi_sample2d: shaders/shaders_multi_sample2d.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/color_mix.fs@resources/shaders/glsl100/color_mix.fs --preload-file shaders/resources/shaders/glsl100/color_mix.fs@resources/shaders/glsl100/color_mix.fs
shaders/shaders_normal_map: shaders/shaders_normal_map.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/normalmap.vs@resources/shaders/glsl100/normalmap.vs \
--preload-file shaders/resources/shaders/glsl100/normalmap.fs@resources/shaders/glsl100/normalmap.fs \
--preload-file shaders/resources/models/plane.glb@resources/models/plane.glb \
--preload-file shaders/resources/tiles_diffuse.png@resources/tiles_diffuse.png \
--preload-file shaders/resources/tiles_normal.png@resources/tiles_normal.png
shaders/shaders_palette_switch: shaders/shaders_palette_switch.c shaders/shaders_palette_switch: shaders/shaders_palette_switch.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/palette_switch.fs@resources/shaders/glsl100/palette_switch.fs --preload-file shaders/resources/shaders/glsl100/palette_switch.fs@resources/shaders/glsl100/palette_switch.fs
shaders/shaders_postprocessing: shaders/shaders_postprocessing.c shaders/shaders_postprocessing: shaders/shaders_postprocessing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/models/church.obj@resources/models/church.obj \ --preload-file shaders/resources/models/church.obj@resources/models/church.obj \
--preload-file shaders/resources/models/church_diffuse.png@resources/models/church_diffuse.png \ --preload-file shaders/resources/models/church_diffuse.png@resources/models/church_diffuse.png \
--preload-file shaders/resources/shaders/glsl100@resources/shaders/glsl100 --preload-file shaders/resources/shaders/glsl100/grayscale.fs@resources/shaders/glsl100/grayscale.fs \
--preload-file shaders/resources/shaders/glsl100/posterization.fs@resources/shaders/glsl100/posterization.fs \
--preload-file shaders/resources/shaders/glsl100/dream_vision.fs@resources/shaders/glsl100/dream_vision.fs \
--preload-file shaders/resources/shaders/glsl100/pixelizer.fs@resources/shaders/glsl100/pixelizer.fs \
--preload-file shaders/resources/shaders/glsl100/cross_hatching.fs@resources/shaders/glsl100/cross_hatching.fs \
--preload-file shaders/resources/shaders/glsl100/cross_stitching.fs@resources/shaders/glsl100/cross_stitching.fs \
--preload-file shaders/resources/shaders/glsl100/predator.fs@resources/shaders/glsl100/predator.fs \
--preload-file shaders/resources/shaders/glsl100/scanlines.fs@resources/shaders/glsl100/scanlines.fs \
--preload-file shaders/resources/shaders/glsl100/fisheye.fs@resources/shaders/glsl100/fisheye.fs \
--preload-file shaders/resources/shaders/glsl100/sobel.fs@resources/shaders/glsl100/sobel.fs \
--preload-file shaders/resources/shaders/glsl100/bloom.fs@resources/shaders/glsl100/bloom.fs \
--preload-file shaders/resources/shaders/glsl100/blur.fs@resources/shaders/glsl100/blur.fs
shaders/shaders_raymarching: shaders/shaders_raymarching.c shaders/shaders_raymarching: shaders/shaders_raymarching.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/raymarching.fs@resources/shaders/glsl100/raymarching.fs --preload-file shaders/resources/shaders/glsl100/raymarching.fs@resources/shaders/glsl100/raymarching.fs
shaders/shaders_rounded_rectangle: shaders/shaders_rounded_rectangle.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/base.vs@resources/shaders/glsl100/base.vs \
--preload-file shaders/resources/shaders/glsl100/rounded_rectangle.fs@resources/shaders/glsl100/rounded_rectangle.fs
shaders/shaders_shadowmap: shaders/shaders_shadowmap.c shaders/shaders_shadowmap: shaders/shaders_shadowmap.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl120/shadowmap.vs@resources/shaders/glsl120/shadowmap.vs \ --preload-file shaders/resources/shaders/glsl100/shadowmap.vs@resources/shaders/glsl100/shadowmap.vs \
--preload-file shaders/resources/shaders/glsl330/shadowmap.vs@resources/shaders/glsl330/shadowmap.vs \ --preload-file shaders/resources/shaders/glsl100/shadowmap.fs@resources/shaders/glsl100/shadowmap.fs \
--preload-file shaders/resources/shaders/glsl120/shadowmap.fs@resources/shaders/glsl120/shadowmap.fs \ --preload-file shaders/resources/models/robot.glb@resources/models/robot.glb \
--preload-file shaders/resources/shaders/glsl330/shadowmap.fs@resources/shaders/glsl330/shadowmap.fs \ --preload-file shaders/shaders_shadowmap.png@shaders_shadowmap.png
--preload-file shaders/resources/models/robot.glb@resources/models/robot.glb
shaders/shaders_shapes_textures: shaders/shaders_shapes_textures.c shaders/shaders_shapes_textures: shaders/shaders_shapes_textures.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/fudesumi.png@resources/fudesumi.png \ --preload-file shaders/resources/fudesumi.png@resources/fudesumi.png \
--preload-file shaders/resources/shaders/glsl100/base.vs@resources/shaders/glsl100/base.vs \
--preload-file shaders/resources/shaders/glsl100/grayscale.fs@resources/shaders/glsl100/grayscale.fs --preload-file shaders/resources/shaders/glsl100/grayscale.fs@resources/shaders/glsl100/grayscale.fs
shaders/shaders_simple_mask: shaders/shaders_simple_mask.c shaders/shaders_simple_mask: shaders/shaders_simple_mask.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/mask.fs@resources/shaders/glsl100/mask.fs \
--preload-file shaders/resources/plasma.png@resources/plasma.png \ --preload-file shaders/resources/plasma.png@resources/plasma.png \
--preload-file shaders/resources/mask.png@resources/mask.png \ --preload-file shaders/resources/mask.png@resources/mask.png
--preload-file shaders/resources/shaders/glsl100/mask.fs@resources/shaders/glsl100/mask.fs
shaders/shaders_spotlight: shaders/shaders_spotlight.c shaders/shaders_spotlight: shaders/shaders_spotlight.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
@ -1140,51 +1277,47 @@ shaders/shaders_texture_drawing: shaders/shaders_texture_drawing.c
shaders/shaders_texture_outline: shaders/shaders_texture_outline.c shaders/shaders_texture_outline: shaders/shaders_texture_outline.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/outline.fs@resources/shaders/glsl100/outline.fs \ --preload-file shaders/resources/fudesumi.png@resources/fudesumi.png \
--preload-file shaders/resources/fudesumi.png@resources/fudesumi.png --preload-file shaders/resources/shaders/glsl100/outline.fs@resources/shaders/glsl100/outline.fs
shaders/shaders_texture_tiling: shaders/shaders_texture_tiling.c shaders/shaders_texture_tiling: shaders/shaders_texture_tiling.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/tiling.fs@resources/shaders/glsl100/tiling.fs \ --preload-file shaders/resources/cubicmap_atlas.png@resources/cubicmap_atlas.png \
--preload-file shaders/resources/cubicmap_atlas.png@resources/cubicmap_atlas.png --preload-file shaders/resources/shaders/glsl100/tiling.fs@resources/shaders/glsl100/tiling.fs
shaders/shaders_texture_waves: shaders/shaders_texture_waves.c shaders/shaders_texture_waves: shaders/shaders_texture_waves.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/space.png@resources/space.png \ --preload-file shaders/resources/space.png@resources/space.png \
--preload-file shaders/resources/shaders/glsl100/wave.fs@resources/shaders/glsl100/wave.fs --preload-file shaders/resources/shaders/glsl100/wave.fs@resources/shaders/glsl100/wave.fs
shaders/shaders_vertex_displacement: shaders/shaders_vertex_displacement.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/vertex_displacement.vs@resources/shaders/glsl100/vertex_displacement.vs \
--preload-file shaders/resources/shaders/glsl100/vertex_displacement.fs@resources/shaders/glsl100/vertex_displacement.fs
shaders/shaders_view_depth: shaders/shaders_view_depth.c shaders/shaders_view_depth: shaders/shaders_view_depth.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/write_depth.fs@resources/shaders/glsl100/write_depth.fs --preload-file shaders/resources/shaders/glsl100/depth.fs@resources/shaders/glsl100/depth.fs
shaders/shaders_write_depth: shaders/shaders_write_depth.c shaders/shaders_write_depth: shaders/shaders_write_depth.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/write_depth.fs@resources/shaders/glsl100/write_depth.fs --preload-file shaders/resources/shaders/glsl100/write_depth.fs@resources/shaders/glsl100/write_depth.fs
shaders/shaders_vertex_displacement: shaders/shaders_vertex_displacement.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/vertex_displacement.vs@resources/shaders/glsl100/vertex_displacement.vs \
--preload-file shaders/resources/shaders/glsl330/vertex_displacement.vs@resources/shaders/glsl330/vertex_displacement.vs \
--preload-file shaders/resources/shaders/glsl100/vertex_displacement.fs@resources/shaders/glsl100/vertex_displacement.fs \
--preload-file shaders/resources/shaders/glsl330/vertex_displacement.fs@resources/shaders/glsl330/vertex_displacement.fs
# Compile AUDIO examples # Compile AUDIO examples
audio/audio_mixed_processor: audio/audio_mixed_processor.c audio/audio_mixed_processor: audio/audio_mixed_processor.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file audio/resources/country.mp3@resources/country.mp3 \ --preload-file audio/resources/country.mp3@resources/country.mp3 \
--preload-file audio/resources/coin.wav@resources/coin.wav --preload-file audio/resources/coin.wav@resources/coin.wav
audio/audio_module_playing: audio/audio_module_playing.c audio/audio_module_playing: audio/audio_module_playing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
--preload-file audio/resources/mini1111.xm@resources/mini1111.xm
audio/audio_music_stream: audio/audio_music_stream.c audio/audio_music_stream: audio/audio_music_stream.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file audio/resources/country.mp3@resources/country.mp3 --preload-file audio/resources/country.mp3@resources/country.mp3
audio/audio_raw_stream: audio/audio_raw_stream.c audio/audio_raw_stream: audio/audio_raw_stream.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
audio/audio_sound_loading: audio/audio_sound_loading.c audio/audio_sound_loading: audio/audio_sound_loading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
@ -1195,29 +1328,14 @@ audio/audio_sound_multi: audio/audio_sound_multi.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file audio/resources/sound.wav@resources/sound.wav --preload-file audio/resources/sound.wav@resources/sound.wav
audio/audio_sound_positioning: audio/audio_sound_positioning.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file audio/resources/coin.wav@resources/coin.wav
audio/audio_stream_effects: audio/audio_stream_effects.c audio/audio_stream_effects: audio/audio_stream_effects.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file audio/resources/country.mp3@resources/country.mp3 --preload-file audio/resources/country.mp3@resources/country.mp3
#EXAMPLES_LIST_END
# Compile OTHERS examples
others/easings_testbed: others/easings_testbed.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
others/embedded_files_loading: others/embedded_files_loading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
others/raylib_opengl_interop:
$(info Skipping_others_raylib_opengl_interop)
others/raymath_vector_angle: others/raymath_vector_angle.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
others/rlgl_compute_shader:
$(info Skipping_others_rlgl_compute_shader)
others/rlgl_standalone:
$(info Skipping_others_rlgl_standalone)
# Clean everything # Clean everything
clean: clean:

View File

@ -16,219 +16,225 @@ You may find it easier to use than other toolchains, especially when it comes to
- `zig build [module]` to compile all examples for a module (e.g. `zig build core`) - `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`) - `zig build [example]` to compile _and run_ a particular example (e.g. `zig build core_basic_window`)
## EXAMPLES LIST ## EXAMPLES COLLECTION [TOTAL: 162]
### category: core ### category: core [37]
Examples using raylib core platform functionality like window creation, inputs, drawing modes and system functionality. Examples using raylib[core](../src/rcore.c) platform functionality like window creation, inputs, drawing modes and system functionality.
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer | | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------| |-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 01 | [core_basic_window](core/core_basic_window.c) | <img src="core/core_basic_window.png" alt="core_basic_window" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) | | [core_basic_window](core/core_basic_window.c) | <img src="core/core_basic_window.png" alt="core_basic_window" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 02 | [core_input_keys](core/core_input_keys.c) | <img src="core/core_input_keys.png" alt="core_input_keys" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) | | [core_input_keys](core/core_input_keys.c) | <img src="core/core_input_keys.png" alt="core_input_keys" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 03 | [core_input_mouse](core/core_input_mouse.c) | <img src="core/core_input_mouse.png" alt="core_input_mouse" width="80"> | ⭐️☆☆☆ | 1.0 | 5.5 | [Ray](https://github.com/raysan5) | | [core_input_mouse](core/core_input_mouse.c) | <img src="core/core_input_mouse.png" alt="core_input_mouse" width="80"> | ⭐☆☆☆ | 1.0 | 5.5 | [Ramon Santamaria](https://github.com/raysan5) |
| 04 | [core_input_mouse_wheel](core/core_input_mouse_wheel.c) | <img src="core/core_input_mouse_wheel.png" alt="core_input_mouse_wheel" width="80"> | ⭐️☆☆☆ | 1.1 | 1.3 | [Ray](https://github.com/raysan5) | | [core_input_mouse_wheel](core/core_input_mouse_wheel.c) | <img src="core/core_input_mouse_wheel.png" alt="core_input_mouse_wheel" width="80"> | ⭐☆☆☆ | 1.1 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
| 05 | [core_input_gamepad](core/core_input_gamepad.c) | <img src="core/core_input_gamepad.png" alt="core_input_gamepad" width="80"> | ⭐️☆☆☆ | 1.1 | 4.2 | [Ray](https://github.com/raysan5) | | [core_input_gamepad](core/core_input_gamepad.c) | <img src="core/core_input_gamepad.png" alt="core_input_gamepad" width="80"> | ⭐☆☆☆ | 1.1 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| 06 | [core_input_multitouch](core/core_input_multitouch.c) | <img src="core/core_input_multitouch.png" alt="core_input_multitouch" width="80"> | ⭐️☆☆☆ | 2.1 | 2.5 | [Berni](https://github.com/Berni8k) | | [core_input_multitouch](core/core_input_multitouch.c) | <img src="core/core_input_multitouch.png" alt="core_input_multitouch" width="80"> | ⭐☆☆☆ | 2.1 | 2.5 | [Berni](https://github.com/Berni8k) |
| 07 | [core_input_gestures](core/core_input_gestures.c) | <img src="core/core_input_gestures.png" alt="core_input_gestures" width="80"> | ⭐️⭐️☆☆ | 1.4 | 4.2 | [Ray](https://github.com/raysan5) | | [core_input_gestures](core/core_input_gestures.c) | <img src="core/core_input_gestures.png" alt="core_input_gestures" width="80"> | ⭐⭐☆☆ | 1.4 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| 08 | [core_input_virtual_controls](core/core_input_virtual_controls.c) | <img src="core/core_input_virtual_controls.png" alt="core_input_virtual_controls" width="80"> | ⭐️⭐️☆☆ | 5.0 | 5.0 | [oblerion](https://github.com/oblerion) | | [core_input_virtual_controls](core/core_input_virtual_controls.c) | <img src="core/core_input_virtual_controls.png" alt="core_input_virtual_controls" width="80"> | ⭐⭐☆☆ | 5.0 | 5.0 | [oblerion](https://github.com/oblerion) |
| 09 | [core_2d_camera](core/core_2d_camera.c) | <img src="core/core_2d_camera.png" alt="core_2d_camera" width="80"> | ⭐️⭐️☆☆ | 1.5 | 3.0 | [Ray](https://github.com/raysan5) | | [core_2d_camera](core/core_2d_camera.c) | <img src="core/core_2d_camera.png" alt="core_2d_camera" width="80"> | ⭐⭐☆☆ | 1.5 | 3.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 10 | [core_2d_camera_mouse_zoom](core/core_2d_camera_mouse_zoom.c) | <img src="core/core_2d_camera_mouse_zoom.png" alt="core_2d_camera_mouse_zoom" width="80"> | ⭐️⭐️☆☆ | 4.2 | 4.2 | [Jeffery Myers](https://github.com/JeffM2501) | | [core_2d_camera_mouse_zoom](core/core_2d_camera_mouse_zoom.c) | <img src="core/core_2d_camera_mouse_zoom.png" alt="core_2d_camera_mouse_zoom" width="80"> | ⭐⭐☆☆ | 4.2 | 4.2 | [Jeffery Myers](https://github.com/JeffM2501) |
| 11 | [core_2d_camera_platformer](core/core_2d_camera_platformer.c) | <img src="core/core_2d_camera_platformer.png" alt="core_2d_camera_platformer" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.0 | [arvyy](https://github.com/arvyy) | | [core_2d_camera_platformer](core/core_2d_camera_platformer.c) | <img src="core/core_2d_camera_platformer.png" alt="core_2d_camera_platformer" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.0 | [arvyy](https://github.com/arvyy) |
| 12 | [core_2d_camera_split_screen](core/core_2d_camera_split_screen.c) | <img src="core/core_2d_camera_split_screen.png" alt="core_2d_camera_split_screen" width="80"> | ⭐️⭐️⭐️⭐️ | 4.5 | 4.5 | [Gabriel dos Santos Sanches](https://github.com/gabrielssanches) | | [core_2d_camera_split_screen](core/core_2d_camera_split_screen.c) | <img src="core/core_2d_camera_split_screen.png" alt="core_2d_camera_split_screen" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [Gabriel dos Santos Sanches](https://github.com/gabrielssanches) |
| 13 | [core_3d_camera_mode](core/core_3d_camera_mode.c) | <img src="core/core_3d_camera_mode.png" alt="core_3d_camera_mode" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) | | [core_3d_camera_mode](core/core_3d_camera_mode.c) | <img src="core/core_3d_camera_mode.png" alt="core_3d_camera_mode" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 14 | [core_3d_camera_free](core/core_3d_camera_free.c) | <img src="core/core_3d_camera_free.png" alt="core_3d_camera_free" width="80"> | ⭐️☆☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) | | [core_3d_camera_free](core/core_3d_camera_free.c) | <img src="core/core_3d_camera_free.png" alt="core_3d_camera_free" width="80"> | ⭐☆☆☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
| 15 | [core_3d_camera_first_person](core/core_3d_camera_first_person.c) | <img src="core/core_3d_camera_first_person.png" alt="core_3d_camera_first_person" width="80"> | ⭐️⭐️☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) | | [core_3d_camera_first_person](core/core_3d_camera_first_person.c) | <img src="core/core_3d_camera_first_person.png" alt="core_3d_camera_first_person" width="80"> | ⭐⭐☆☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
| 16 | [core_3d_camera_split_screen](core/core_3d_camera_split_screen.c) | <img src="core/core_3d_camera_split_screen.png" alt="core_3d_camera_split_screen" width="80"> | ⭐️⭐️⭐️☆ | 3.7 | 4.0 | [Jeffery Myers](https://github.com/JeffM2501) | | [core_3d_camera_split_screen](core/core_3d_camera_split_screen.c) | <img src="core/core_3d_camera_split_screen.png" alt="core_3d_camera_split_screen" width="80"> | ⭐⭐⭐☆ | 3.7 | 4.0 | [Jeffery Myers](https://github.com/JeffM2501) |
| 17 | [core_3d_picking](core/core_3d_picking.c) | <img src="core/core_3d_picking.png" alt="core_3d_picking" width="80"> | ⭐️⭐️☆☆ | 1.3 | 4.0 | [Ray](https://github.com/raysan5) | | [core_3d_camera_fps](core/core_3d_camera_fps.c) | <img src="core/core_3d_camera_fps.png" alt="core_3d_camera_fps" width="80"> | ⭐⭐⭐☆ | 5.5 | 5.5 | [Agnis Aldins](https://github.com/nezvers) |
| 18 | [core_world_screen](core/core_world_screen.c) | <img src="core/core_world_screen.png" alt="core_world_screen" width="80"> | ⭐️⭐️☆☆ | 1.3 | 1.4 | [Ray](https://github.com/raysan5) | | [core_3d_picking](core/core_3d_picking.c) | <img src="core/core_3d_picking.png" alt="core_3d_picking" width="80"> | ⭐⭐☆☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 19 | [core_custom_logging](core/core_custom_logging.c) | <img src="core/core_custom_logging.png" alt="core_custom_logging" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 2.5 | [Pablo Marcos Oltra](https://github.com/pamarcos) | | [core_world_screen](core/core_world_screen.c) | <img src="core/core_world_screen.png" alt="core_world_screen" width="80"> | ⭐⭐☆☆ | 1.3 | 1.4 | [Ramon Santamaria](https://github.com/raysan5) |
| 20 | [core_window_flags](core/core_window_flags.c) | <img src="core/core_window_flags.png" alt="core_window_flags" width="80"> | ⭐️⭐️⭐️☆ | 3.5 | 3.5 | [Ray](https://github.com/raysan5) | | [core_custom_logging](core/core_custom_logging.c) | <img src="core/core_custom_logging.png" alt="core_custom_logging" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Pablo Marcos Oltra](https://github.com/pamarcos) |
| 21 | [core_window_letterbox](core/core_window_letterbox.c) | <img src="core/core_window_letterbox.png" alt="core_window_letterbox" width="80"> | ⭐️⭐️☆☆ | 2.5 | 4.0 | [Anata](https://github.com/anatagawa) | | [core_window_flags](core/core_window_flags.c) | <img src="core/core_window_flags.png" alt="core_window_flags" width="80"> | ⭐⭐⭐☆ | 3.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| 22 | [core_window_should_close](core/core_window_should_close.c) | <img src="core/core_window_should_close.png" alt="core_window_should_close" width="80"> | ⭐️☆☆☆ | 4.2 | 4.2 | [Ray](https://github.com/raysan5) | | [core_window_letterbox](core/core_window_letterbox.c) | <img src="core/core_window_letterbox.png" alt="core_window_letterbox" width="80"> | ⭐⭐☆☆ | 2.5 | 4.0 | [Anata](https://github.com/anatagawa) |
| 23 | [core_drop_files](core/core_drop_files.c) | <img src="core/core_drop_files.png" alt="core_drop_files" width="80"> | ⭐️⭐️☆☆ | 1.3 | 4.2 | [Ray](https://github.com/raysan5) | | [core_window_should_close](core/core_window_should_close.c) | <img src="core/core_window_should_close.png" alt="core_window_should_close" width="80"> | ⭐☆☆☆ | 4.2 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| 24 | [core_random_values](core/core_random_values.c) | <img src="core/core_random_values.png" alt="core_random_values" width="80"> | ⭐️☆☆☆ | 1.1 | 1.1 | [Ray](https://github.com/raysan5) | | [core_drop_files](core/core_drop_files.c) | <img src="core/core_drop_files.png" alt="core_drop_files" width="80"> | ⭐⭐☆☆ | 1.3 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| 25 | [core_storage_values](core/core_storage_values.c) | <img src="core/core_storage_values.png" alt="core_storage_values" width="80"> | ⭐️⭐️☆☆ | 1.4 | 4.2 | [Ray](https://github.com/raysan5) | | [core_random_values](core/core_random_values.c) | <img src="core/core_random_values.png" alt="core_random_values" width="80"> | ⭐☆☆☆ | 1.1 | 1.1 | [Ramon Santamaria](https://github.com/raysan5) |
| 26 | [core_vr_simulator](core/core_vr_simulator.c) | <img src="core/core_vr_simulator.png" alt="core_vr_simulator" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 4.0 | [Ray](https://github.com/raysan5) | | [core_storage_values](core/core_storage_values.c) | <img src="core/core_storage_values.png" alt="core_storage_values" width="80"> | ⭐⭐☆☆ | 1.4 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| 27 | [core_loading_thread](core/core_loading_thread.c) | <img src="core/core_loading_thread.png" alt="core_loading_thread" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.0 | [Ray](https://github.com/raysan5) | | [core_vr_simulator](core/core_vr_simulator.c) | <img src="core/core_vr_simulator.png" alt="core_vr_simulator" width="80"> | ⭐⭐⭐☆ | 2.5 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 28 | [core_scissor_test](core/core_scissor_test.c) | <img src="core/core_scissor_test.png" alt="core_scissor_test" width="80"> | ⭐️☆☆☆ | 2.5 | 3.0 | [Chris Dill](https://github.com/MysteriousSpace) | | [core_loading_thread](core/core_loading_thread.c) | <img src="core/core_loading_thread.png" alt="core_loading_thread" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 29 | [core_basic_screen_manager](core/core_basic_screen_manager.c) | <img src="core/core_basic_screen_manager.png" alt="core_basic_screen_manager" width="80"> | ⭐️☆☆☆ | 4.0 | 4.0 | [Ray](https://github.com/raysan5) | | [core_scissor_test](core/core_scissor_test.c) | <img src="core/core_scissor_test.png" alt="core_scissor_test" width="80"> | ⭐☆☆☆ | 2.5 | 3.0 | [Chris Dill](https://github.com/MysteriousSpace) |
| 30 | [core_custom_frame_control](core/core_custom_frame_control.c) | <img src="core/core_custom_frame_control.png" alt="core_custom_frame_control" width="80"> | ⭐️⭐️⭐️⭐️ | 4.0 | 4.0 | [Ray](https://github.com/raysan5) | | [core_basic_screen_manager](core/core_basic_screen_manager.c) | <img src="core/core_basic_screen_manager.png" alt="core_basic_screen_manager" width="80"> | ⭐☆☆☆ | 4.0 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 31 | [core_smooth_pixelperfect](core/core_smooth_pixelperfect.c) | <img src="core/core_smooth_pixelperfect.png" alt="core_smooth_pixelperfect" width="80"> | ⭐️⭐️⭐️☆ | 3.7 | 4.0 | [Giancamillo Alessandroni](https://github.com/NotManyIdeasDev) | | [core_custom_frame_control](core/core_custom_frame_control.c) | <img src="core/core_custom_frame_control.png" alt="core_custom_frame_control" width="80"> | ⭐⭐⭐⭐️ | 4.0 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 32 | [core_random_sequence](core/core_random_sequence.c) | <img src="core/core_random_sequence.png" alt="core_random_sequence" width="80"> | ⭐️☆☆☆ | 5.0 | 5.0 | [Dalton Overmyer](https://github.com/REDl3east) | | [core_smooth_pixelperfect](core/core_smooth_pixelperfect.c) | <img src="core/core_smooth_pixelperfect.png" alt="core_smooth_pixelperfect" width="80"> | ⭐⭐⭐☆ | 3.7 | 4.0 | [Giancamillo Alessandroni](https://github.com/NotManyIdeasDev) |
| 33 | [core_basic_window_web](core/core_basic_window_web.c) | <img src="core/core_basic_window_web.png" alt="core_basic_window_web" width="80"> | ⭐️☆☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) | | [core_random_sequence](core/core_random_sequence.c) | <img src="core/core_random_sequence.png" alt="core_random_sequence" width="80"> | ⭐☆☆☆ | 5.0 | 5.0 | [Dalton Overmyer](https://github.com/REDl3east) |
| 34 | [core_input_gestures_web](core/core_input_gestures_web.c) | <img src="core/core_input_gestures_web.png" alt="core_input_gestures_web" width="80"> | ⭐️⭐️☆☆ | 4.6-dev | 4.6-dev | [ubkp](https://github.com/ubkp) | | [core_basic_window_web](core/core_basic_window_web.c) | <img src="core/core_basic_window_web.png" alt="core_basic_window_web" width="80"> | ⭐☆☆☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
| 35 | [core_automation_events](core/core_automation_events.c) | <img src="core/core_automation_events.png" alt="core_automation_events" width="80"> | ⭐️⭐️⭐️☆ | 5.0 | 5.0 | [Ray](https://github.com/raysan5) | | [core_input_gestures_web](core/core_input_gestures_web.c) | <img src="core/core_input_gestures_web.png" alt="core_input_gestures_web" width="80"> | ⭐⭐☆☆ | 4.6 | 4.6 | [ubkp](https://github.com/ubkp) |
| 36 | [core_high_dpi](core/core_high_dpi.c) | <img src="core/core_high_dpi.png" alt="core_high_dpi" width="80"> | ⭐️☆☆☆ | 5.0 | 5.0 | [Jonathan Marler](https://github.com/marler8997) | | [core_automation_events](core/core_automation_events.c) | <img src="core/core_automation_events.png" alt="core_automation_events" width="80"> | ⭐⭐⭐☆ | 5.0 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_high_dpi](core/core_high_dpi.c) | <img src="core/core_high_dpi.png" alt="core_high_dpi" width="80"> | ⭐☆☆☆ | 5.0 | 5.0 | [Jonathan Marler](https://github.com/marler8997) |
### category: shapes ### category: shapes [20]
Examples using raylib shapes drawing functionality, provided by raylib [shapes](../src/shapes.c) module. Examples using raylib shapes drawing functionality, provided by raylib [shapes](../src/rshapes.c) module.
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer | | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------| |-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 36 | [shapes_basic_shapes](shapes/shapes_basic_shapes.c) | <img src="shapes/shapes_basic_shapes.png" alt="shapes_basic_shapes" width="80"> | ⭐️☆☆☆ | 1.0 | 4.2 | [Ray](https://github.com/raysan5) | | [shapes_basic_shapes](shapes/shapes_basic_shapes.c) | <img src="shapes/shapes_basic_shapes.png" alt="shapes_basic_shapes" width="80"> | ⭐☆☆☆ | 1.0 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| 37 | [shapes_bouncing_ball](shapes/shapes_bouncing_ball.c) | <img src="shapes/shapes_bouncing_ball.png" alt="shapes_bouncing_ball" width="80"> | ⭐️☆☆☆ | 2.5 | 2.5 | [Ray](https://github.com/raysan5) | | [shapes_bouncing_ball](shapes/shapes_bouncing_ball.c) | <img src="shapes/shapes_bouncing_ball.png" alt="shapes_bouncing_ball" width="80"> | ⭐☆☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| 38 | [shapes_colors_palette](shapes/shapes_colors_palette.c) | <img src="shapes/shapes_colors_palette.png" alt="shapes_colors_palette" width="80"> | ⭐️⭐️☆☆ | 1.0 | 2.5 | [Ray](https://github.com/raysan5) | | [shapes_colors_palette](shapes/shapes_colors_palette.c) | <img src="shapes/shapes_colors_palette.png" alt="shapes_colors_palette" width="80"> | ⭐⭐☆☆ | 1.0 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| 39 | [shapes_logo_raylib](shapes/shapes_logo_raylib.c) | <img src="shapes/shapes_logo_raylib.png" alt="shapes_logo_raylib" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) | | [shapes_logo_raylib](shapes/shapes_logo_raylib.c) | <img src="shapes/shapes_logo_raylib.png" alt="shapes_logo_raylib" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 40 | [shapes_logo_raylib_anim](shapes/shapes_logo_raylib_anim.c) | <img src="shapes/shapes_logo_raylib_anim.png" alt="shapes_logo_raylib_anim" width="80"> | ⭐️⭐️☆☆ | 2.5 | 4.0 | [Ray](https://github.com/raysan5) | | [shapes_logo_raylib_anim](shapes/shapes_logo_raylib_anim.c) | <img src="shapes/shapes_logo_raylib_anim.png" alt="shapes_logo_raylib_anim" width="80"> | ⭐⭐☆☆ | 2.5 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 41 | [shapes_rectangle_scaling](shapes/shapes_rectangle_scaling.c) | <img src="shapes/shapes_rectangle_scaling.png" alt="shapes_rectangle_scaling" width="80"> | ⭐☆☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) | | [shapes_rectangle_scaling](shapes/shapes_rectangle_scaling.c) | <img src="shapes/shapes_rectangle_scaling.png" alt="shapes_rectangle_scaling" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
| 42 | [shapes_lines_bezier](shapes/shapes_lines_bezier.c) | <img src="shapes/shapes_lines_bezier.png" alt="shapes_lines_bezier" width="80"> | ⭐️☆☆☆ | 1.7 | 1.7 | [Ray](https://github.com/raysan5) | | [shapes_lines_bezier](shapes/shapes_lines_bezier.c) | <img src="shapes/shapes_lines_bezier.png" alt="shapes_lines_bezier" width="80"> | ⭐☆☆☆ | 1.7 | 1.7 | [Ramon Santamaria](https://github.com/raysan5) |
| 43 | [shapes_collision_area](shapes/shapes_collision_area.c) | <img src="shapes/shapes_collision_area.png" alt="shapes_collision_area" width="80"> | ⭐️⭐️☆☆ | 2.5 | 2.5 | [Ray](https://github.com/raysan5) | | [shapes_collision_area](shapes/shapes_collision_area.c) | <img src="shapes/shapes_collision_area.png" alt="shapes_collision_area" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| 44 | [shapes_following_eyes](shapes/shapes_following_eyes.c) | <img src="shapes/shapes_following_eyes.png" alt="shapes_following_eyes" width="80"> | ⭐️⭐️☆☆ | 2.5 | 2.5 | [Ray](https://github.com/raysan5) | | [shapes_following_eyes](shapes/shapes_following_eyes.c) | <img src="shapes/shapes_following_eyes.png" alt="shapes_following_eyes" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| 45 | [shapes_easings_ball_anim](shapes/shapes_easings_ball_anim.c) | <img src="shapes/shapes_easings_ball_anim.png" alt="shapes_easings_ball_anim" width="80"> | ⭐️⭐️☆☆ | 2.5 | 2.5 | [Ray](https://github.com/raysan5) | | [shapes_easings_ball_anim](shapes/shapes_easings_ball_anim.c) | <img src="shapes/shapes_easings_ball_anim.png" alt="shapes_easings_ball_anim" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| 46 | [shapes_easings_box_anim](shapes/shapes_easings_box_anim.c) | <img src="shapes/shapes_easings_box_anim.png" alt="shapes_easings_box_anim" width="80"> | ⭐️⭐️☆☆ | 2.5 | 2.5 | [Ray](https://github.com/raysan5) | | [shapes_easings_box_anim](shapes/shapes_easings_box_anim.c) | <img src="shapes/shapes_easings_box_anim.png" alt="shapes_easings_box_anim" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| 47 | [shapes_easings_rectangle_array](shapes/shapes_easings_rectangle_array.c) | <img src="shapes/shapes_easings_rectangle_array.png" alt="shapes_easings_rectangle_array" width="80"> | ⭐️⭐️⭐️☆ | 2.0 | 2.5 | [Ray](https://github.com/raysan5) | | [shapes_easings_rectangle_array](shapes/shapes_easings_rectangle_array.c) | <img src="shapes/shapes_easings_rectangle_array.png" alt="shapes_easings_rectangle_array" width="80"> | ⭐⭐⭐☆ | 2.0 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| 48 | [shapes_draw_ring](shapes/shapes_draw_ring.c) | <img src="shapes/shapes_draw_ring.png" alt="shapes_draw_ring" width="80"> | ⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) | | [shapes_draw_ring](shapes/shapes_draw_ring.c) | <img src="shapes/shapes_draw_ring.png" alt="shapes_draw_ring" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
| 49 | [shapes_draw_circle_sector](shapes/shapes_draw_circle_sector.c) | <img src="shapes/shapes_draw_circle_sector.png" alt="shapes_draw_circle_sector" width="80"> | ⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) | | [shapes_draw_circle_sector](shapes/shapes_draw_circle_sector.c) | <img src="shapes/shapes_draw_circle_sector.png" alt="shapes_draw_circle_sector" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
| 50 | [shapes_draw_rectangle_rounded](shapes/shapes_draw_rectangle_rounded.c) | <img src="shapes/shapes_draw_rectangle_rounded.png" alt="shapes_draw_rectangle_rounded" width="80"> | ⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) | | [shapes_draw_rectangle_rounded](shapes/shapes_draw_rectangle_rounded.c) | <img src="shapes/shapes_draw_rectangle_rounded.png" alt="shapes_draw_rectangle_rounded" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
| 51 | [shapes_top_down_lights](shapes/shapes_top_down_lights.c) | <img src="shapes/shapes_top_down_lights.png" alt="shapes_top_down_lights" width="80"> | ⭐⭐️ | 4.2 | 4.2 | [Jeffery Myers](https://github.com/JeffM2501) | | [shapes_top_down_lights](shapes/shapes_top_down_lights.c) | <img src="shapes/shapes_top_down_lights.png" alt="shapes_top_down_lights" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 4.2 | [Jeffery Myers](https://github.com/JeffM2501) |
| 52 | [shapes_rectangle_advanced](shapes/shapes_rectangle_advanced.c) | <img src="shapes/shapes_rectangle_advanced.png" alt="shapes_rectangle_advanced" width="80"> | ⭐⭐️ | 5.5 | 5.5 | [Everton Jr.](https://github.com/evertonse) | | [shapes_rectangle_advanced](shapes/shapes_rectangle_advanced.c) | <img src="shapes/shapes_rectangle_advanced.png" alt="shapes_rectangle_advanced" width="80"> | ⭐⭐⭐⭐️ | 5.5 | 5.5 | [Everton Jr.](https://github.com/evertonse) |
| 53 | [shapes_splines_drawing](shapes/shapes_splines_drawing.c) | <img src="shapes/shapes_splines_drawing.png" alt="shapes_splines_drawing" width="80"> | ⭐️⭐️⭐️☆ | 5.0 | 5.0 | [Ray](https://github.com/raysan5) | | [shapes_splines_drawing](shapes/shapes_splines_drawing.c) | <img src="shapes/shapes_splines_drawing.png" alt="shapes_splines_drawing" width="80"> | ⭐⭐⭐☆ | 5.0 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 54 | [shapes_digital_clock](shapes/shapes_digital_clock.c) | <img src="shapes/shapes_digital_clock.png" alt="shapes_digital_clock" width="80"> | ⭐☆☆ | 5.5 | 5.5 | [Hamza RAHAL](https://github.com/rhmz-rhl) | | [shapes_digital_clock](shapes/shapes_digital_clock.c) | <img src="shapes/shapes_digital_clock.png" alt="shapes_digital_clock" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [Hamza RAHAL](https://github.com/rhmz-rhl) |
### category: textures | [shapes_double_pendulum](shapes/shapes_double_pendulum.c) | <img src="shapes/shapes_double_pendulum.png" alt="shapes_double_pendulum" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [JoeCheong](https://github.com/Joecheong2006) |
Examples using raylib textures functionality, including image/textures loading/generation and drawing, provided by raylib [textures](../src/textures.c) modul ### category: textures [26]
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer | Examples using raylib textures functionality, including image/textures loading/generation and drawing, provided by raylib [textures](../src/rtextures.c) module.
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 55 | [textures_logo_raylib](textures/textures_logo_raylib.c) | <img src="textures/textures_logo_raylib.png" alt="textures_logo_raylib" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
| 56 | [textures_srcrec_dstrec](textures/textures_srcrec_dstrec.c) | <img src="textures/textures_srcrec_dstrec.png" alt="textures_srcrec_dstrec" width="80"> | ⭐️⭐️⭐️☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) |
| 57 | [textures_image_drawing](textures/textures_image_drawing.c) | <img src="textures/textures_image_drawing.png" alt="textures_image_drawing" width="80"> | ⭐️⭐️☆☆ | 1.4 | 1.4 | [Ray](https://github.com/raysan5) |
| 58 | [textures_image_generation](textures/textures_image_generation.c) | <img src="textures/textures_image_generation.png" alt="textures_image_generation" width="80"> | ⭐️⭐️☆☆ | 1.8 | 1.8 | [Wilhem Barbier](https://github.com/nounoursheureux) |
| 59 | [textures_image_loading](textures/textures_image_loading.c) | <img src="textures/textures_image_loading.png" alt="textures_image_loading" width="80"> | ⭐️☆☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) |
| 60 | [textures_image_processing](textures/textures_image_processing.c) | <img src="textures/textures_image_processing.png" alt="textures_image_processing" width="80"> | ⭐️⭐️⭐️☆ | 1.4 | 3.5 | [Ray](https://github.com/raysan5) |
| 61 | [textures_image_text](textures/textures_image_text.c) | <img src="textures/textures_image_text.png" alt="textures_image_text" width="80"> | ⭐️⭐️☆☆ | 1.8 | 4.0 | [Ray](https://github.com/raysan5) |
| 62 | [textures_to_image](textures/textures_to_image.c) | <img src="textures/textures_to_image.png" alt="textures_to_image" width="80"> | ⭐️☆☆☆ | 1.3 | 4.0 | [Ray](https://github.com/raysan5) |
| 63 | [textures_raw_data](textures/textures_raw_data.c) | <img src="textures/textures_raw_data.png" alt="textures_raw_data" width="80"> | ⭐️⭐️⭐️☆ | 1.3 | 3.5 | [Ray](https://github.com/raysan5) |
| 64 | [textures_particles_blending](textures/textures_particles_blending.c) | <img src="textures/textures_particles_blending.png" alt="textures_particles_blending" width="80"> | ⭐️☆☆☆ | 1.7 | 3.5 | [Ray](https://github.com/raysan5) |
| 65 | [textures_npatch_drawing](textures/textures_npatch_drawing.c) | <img src="textures/textures_npatch_drawing.png" alt="textures_npatch_drawing" width="80"> | ⭐️⭐️⭐️☆ | 2.0 | 2.5 | [Jorge A. Gomes](https://github.com/overdev) |
| 66 | [textures_background_scrolling](textures/textures_background_scrolling.c) | <img src="textures/textures_background_scrolling.png" alt="textures_background_scrolling" width="80"> | ⭐️☆☆☆ | 2.0 | 2.5 | [Ray](https://github.com/raysan5) |
| 67 | [textures_sprite_anim](textures/textures_sprite_anim.c) | <img src="textures/textures_sprite_anim.png" alt="textures_sprite_anim" width="80"> | ⭐️⭐️☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) |
| 68 | [textures_sprite_button](textures/textures_sprite_button.c) | <img src="textures/textures_sprite_button.png" alt="textures_sprite_button" width="80"> | ⭐️⭐️☆☆ | 2.5 | 2.5 | [Ray](https://github.com/raysan5) |
| 69 | [textures_sprite_explosion](textures/textures_sprite_explosion.c) | <img src="textures/textures_sprite_explosion.png" alt="textures_sprite_explosion" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.5 | [Ray](https://github.com/raysan5) |
| 70 | [textures_bunnymark](textures/textures_bunnymark.c) | <img src="textures/textures_bunnymark.png" alt="textures_bunnymark" width="80"> | ⭐️⭐️⭐️☆ | 1.6 | 2.5 | [Ray](https://github.com/raysan5) |
| 71 | [textures_mouse_painting](textures/textures_mouse_painting.c) | <img src="textures/textures_mouse_painting.png" alt="textures_mouse_painting" width="80"> | ⭐️⭐️⭐️☆ | 3.0 | 3.0 | [Chris Dill](https://github.com/MysteriousSpace) |
| 72 | [textures_blend_modes](textures/textures_blend_modes.c) | <img src="textures/textures_blend_modes.png" alt="textures_blend_modes" width="80"> | ⭐️☆☆☆ | 3.5 | 3.5 | [Karlo Licudine](https://github.com/accidentalrebel) |
| 73 | [textures_draw_tiled](textures/textures_draw_tiled.c) | <img src="textures/textures_draw_tiled.png" alt="textures_draw_tiled" width="80"> | ⭐️⭐️⭐️☆ | 3.0 | 4.2 | [Vlad Adrian](https://github.com/demizdor) |
| 74 | [textures_polygon](textures/textures_polygon.c) | <img src="textures/textures_polygon.png" alt="textures_polygon" width="80"> | ⭐️☆☆☆ | 3.7 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| 75 | [textures_fog_of_war](textures/textures_fog_of_war.c) | <img src="textures/textures_fog_of_war.png" alt="textures_fog_of_war" width="80"> | ⭐️⭐️⭐️☆ | 4.2 | 4.2 | [Ray](https://github.com/raysan5) |
| 76 | [textures_gif_player](textures/textures_gif_player.c) | <img src="textures/textures_gif_player.png" alt="textures_gif_player" width="80"> | ⭐️⭐️⭐️☆ | 4.2 | 4.2 | [Ray](https://github.com/raysan5) |
| 77 | [textures_image_kernel](textures/textures_image_kernel.c) | <img src="textures/textures_image_kernel.png" alt="textures_image_kernel" width="80"> | ⭐️⭐️⭐️⭐️ | 1.3 | 1.3 | [Karim Salem](https://github.com/kimo-s) |
| 78 | [textures_image_channel](textures/textures_image_channel.c) | <img src="textures/textures_image_channel.png" alt="textures_image_channel" width="80"> | ⭐️⭐️☆☆ | 5.1-dev | 5.1-dev | [Bruno Cabral](https://github.com/brccabral) |
| 79 | [textures_image_rotate](textures/textures_image_rotate.c) | <img src="textures/textures_image_rotate.png" alt="textures_image_rotate" width="80"> | ⭐️⭐️☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
| 80 | [textures_textured_curve](textures/textures_textured_curve.c) | <img src="textures/textures_textured_curve.png" alt="textures_textured_curve" width="80"> | ⭐️⭐️⭐️☆ | 4.5 | 4.5 | [Jeffery Myers](https://github.com/JeffM2501) |
### category: text | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| [textures_logo_raylib](textures/textures_logo_raylib.c) | <img src="textures/textures_logo_raylib.png" alt="textures_logo_raylib" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_srcrec_dstrec](textures/textures_srcrec_dstrec.c) | <img src="textures/textures_srcrec_dstrec.png" alt="textures_srcrec_dstrec" width="80"> | ⭐⭐⭐☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_image_drawing](textures/textures_image_drawing.c) | <img src="textures/textures_image_drawing.png" alt="textures_image_drawing" width="80"> | ⭐⭐☆☆ | 1.4 | 1.4 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_image_generation](textures/textures_image_generation.c) | <img src="textures/textures_image_generation.png" alt="textures_image_generation" width="80"> | ⭐⭐☆☆ | 1.8 | 1.8 | [Wilhem Barbier](https://github.com/nounoursheureux) |
| [textures_image_loading](textures/textures_image_loading.c) | <img src="textures/textures_image_loading.png" alt="textures_image_loading" width="80"> | ⭐☆☆☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_image_processing](textures/textures_image_processing.c) | <img src="textures/textures_image_processing.png" alt="textures_image_processing" width="80"> | ⭐⭐⭐☆ | 1.4 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_image_text](textures/textures_image_text.c) | <img src="textures/textures_image_text.png" alt="textures_image_text" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_to_image](textures/textures_to_image.c) | <img src="textures/textures_to_image.png" alt="textures_to_image" width="80"> | ⭐☆☆☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_raw_data](textures/textures_raw_data.c) | <img src="textures/textures_raw_data.png" alt="textures_raw_data" width="80"> | ⭐⭐⭐☆ | 1.3 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_particles_blending](textures/textures_particles_blending.c) | <img src="textures/textures_particles_blending.png" alt="textures_particles_blending" width="80"> | ⭐☆☆☆ | 1.7 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_npatch_drawing](textures/textures_npatch_drawing.c) | <img src="textures/textures_npatch_drawing.png" alt="textures_npatch_drawing" width="80"> | ⭐⭐⭐☆ | 2.0 | 2.5 | [Jorge A. Gomes](https://github.com/overdev) |
| [textures_background_scrolling](textures/textures_background_scrolling.c) | <img src="textures/textures_background_scrolling.png" alt="textures_background_scrolling" width="80"> | ⭐☆☆☆ | 2.0 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_sprite_anim](textures/textures_sprite_anim.c) | <img src="textures/textures_sprite_anim.png" alt="textures_sprite_anim" width="80"> | ⭐⭐☆☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_sprite_button](textures/textures_sprite_button.c) | <img src="textures/textures_sprite_button.png" alt="textures_sprite_button" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_sprite_explosion](textures/textures_sprite_explosion.c) | <img src="textures/textures_sprite_explosion.png" alt="textures_sprite_explosion" width="80"> | ⭐⭐☆☆ | 2.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_bunnymark](textures/textures_bunnymark.c) | <img src="textures/textures_bunnymark.png" alt="textures_bunnymark" width="80"> | ⭐⭐⭐☆ | 1.6 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_mouse_painting](textures/textures_mouse_painting.c) | <img src="textures/textures_mouse_painting.png" alt="textures_mouse_painting" width="80"> | ⭐⭐⭐☆ | 3.0 | 3.0 | [Chris Dill](https://github.com/MysteriousSpace) |
| [textures_blend_modes](textures/textures_blend_modes.c) | <img src="textures/textures_blend_modes.png" alt="textures_blend_modes" width="80"> | ⭐☆☆☆ | 3.5 | 3.5 | [Karlo Licudine](https://github.com/accidentalrebel) |
| [textures_draw_tiled](textures/textures_draw_tiled.c) | <img src="textures/textures_draw_tiled.png" alt="textures_draw_tiled" width="80"> | ⭐⭐⭐☆ | 3.0 | 4.2 | [Vlad Adrian](https://github.com/demizdor) |
| [textures_polygon](textures/textures_polygon.c) | <img src="textures/textures_polygon.png" alt="textures_polygon" width="80"> | ⭐☆☆☆ | 3.7 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| [textures_fog_of_war](textures/textures_fog_of_war.c) | <img src="textures/textures_fog_of_war.png" alt="textures_fog_of_war" width="80"> | ⭐⭐⭐☆ | 4.2 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_gif_player](textures/textures_gif_player.c) | <img src="textures/textures_gif_player.png" alt="textures_gif_player" width="80"> | ⭐⭐⭐☆ | 4.2 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_image_kernel](textures/textures_image_kernel.c) | <img src="textures/textures_image_kernel.png" alt="textures_image_kernel" width="80"> | ⭐⭐⭐⭐️ | 1.3 | 1.3 | [Karim Salem](https://github.com/kimo-s) |
| [textures_image_channel](textures/textures_image_channel.c) | <img src="textures/textures_image_channel.png" alt="textures_image_channel" width="80"> | ⭐⭐☆☆ | 5.1 | 5.1 | [Bruno Cabral](https://github.com/brccabral) |
| [textures_image_rotate](textures/textures_image_rotate.c) | <img src="textures/textures_image_rotate.png" alt="textures_image_rotate" width="80"> | ⭐⭐☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_textured_curve](textures/textures_textured_curve.c) | <img src="textures/textures_textured_curve.png" alt="textures_textured_curve" width="80"> | ⭐⭐⭐☆ | 4.5 | 4.5 | [Jeffery Myers](https://github.com/JeffM2501) |
Examples using raylib text functionality, including sprite fonts loading/generation and text drawing, provided by raylib [text](../src/text.c) module. ### category: text [13]
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer | Examples using raylib text functionality, including sprite fonts loading/generation and text drawing, provided by raylib [text](../src/rtext.c) module.
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 81 | [text_raylib_fonts](text/text_raylib_fonts.c) | <img src="text/text_raylib_fonts.png" alt="text_raylib_fonts" width="80"> | ⭐️☆☆☆ | 1.7 | 3.7 | [Ray](https://github.com/raysan5) |
| 82 | [text_font_spritefont](text/text_font_spritefont.c) | <img src="text/text_font_spritefont.png" alt="text_font_spritefont" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
| 83 | [text_font_filters](text/text_font_filters.c) | <img src="text/text_font_filters.png" alt="text_font_filters" width="80"> | ⭐️⭐️☆☆ | 1.3 | 4.2 | [Ray](https://github.com/raysan5) |
| 84 | [text_font_loading](text/text_font_loading.c) | <img src="text/text_font_loading.png" alt="text_font_loading" width="80"> | ⭐️☆☆☆ | 1.4 | 3.0 | [Ray](https://github.com/raysan5) |
| 85 | [text_font_sdf](text/text_font_sdf.c) | <img src="text/text_font_sdf.png" alt="text_font_sdf" width="80"> | ⭐️⭐️⭐️☆ | 1.3 | 4.0 | [Ray](https://github.com/raysan5) |
| 86 | [text_format_text](text/text_format_text.c) | <img src="text/text_format_text.png" alt="text_format_text" width="80"> | ⭐️☆☆☆ | 1.1 | 3.0 | [Ray](https://github.com/raysan5) |
| 87 | [text_input_box](text/text_input_box.c) | <img src="text/text_input_box.png" alt="text_input_box" width="80"> | ⭐️⭐️☆☆ | 1.7 | 3.5 | [Ray](https://github.com/raysan5) |
| 88 | [text_writing_anim](text/text_writing_anim.c) | <img src="text/text_writing_anim.png" alt="text_writing_anim" width="80"> | ⭐️⭐️☆☆ | 1.4 | 1.4 | [Ray](https://github.com/raysan5) |
| 89 | [text_rectangle_bounds](text/text_rectangle_bounds.c) | <img src="text/text_rectangle_bounds.png" alt="text_rectangle_bounds" width="80"> | ⭐️⭐️⭐️⭐️ | 2.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
| 90 | [text_unicode](text/text_unicode.c) | <img src="text/text_unicode.png" alt="text_unicode" width="80"> | ⭐️⭐️⭐️⭐️ | 2.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
| 91 | [text_draw_3d](text/text_draw_3d.c) | <img src="text/text_draw_3d.png" alt="text_draw_3d" width="80"> | ⭐️⭐️⭐️⭐️ | 3.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
| 92 | [text_codepoints_loading](text/text_codepoints_loading.c) | <img src="text/text_codepoints_loading.png" alt="text_codepoints_loading" width="80"> | ⭐️⭐️⭐️☆ | 4.2 | 4.2 | [Ray](https://github.com/raysan5) |
### category: models | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| [text_raylib_fonts](text/text_raylib_fonts.c) | <img src="text/text_raylib_fonts.png" alt="text_raylib_fonts" width="80"> | ⭐☆☆☆ | 1.7 | 3.7 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_font_spritefont](text/text_font_spritefont.c) | <img src="text/text_font_spritefont.png" alt="text_font_spritefont" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_font_filters](text/text_font_filters.c) | <img src="text/text_font_filters.png" alt="text_font_filters" width="80"> | ⭐⭐☆☆ | 1.3 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_font_loading](text/text_font_loading.c) | <img src="text/text_font_loading.png" alt="text_font_loading" width="80"> | ⭐☆☆☆ | 1.4 | 3.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_font_sdf](text/text_font_sdf.c) | <img src="text/text_font_sdf.png" alt="text_font_sdf" width="80"> | ⭐⭐⭐☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_format_text](text/text_format_text.c) | <img src="text/text_format_text.png" alt="text_format_text" width="80"> | ⭐☆☆☆ | 1.1 | 3.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_input_box](text/text_input_box.c) | <img src="text/text_input_box.png" alt="text_input_box" width="80"> | ⭐⭐☆☆ | 1.7 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_writing_anim](text/text_writing_anim.c) | <img src="text/text_writing_anim.png" alt="text_writing_anim" width="80"> | ⭐⭐☆☆ | 1.4 | 1.4 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_rectangle_bounds](text/text_rectangle_bounds.c) | <img src="text/text_rectangle_bounds.png" alt="text_rectangle_bounds" width="80"> | ⭐⭐⭐⭐️ | 2.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
| [text_unicode](text/text_unicode.c) | <img src="text/text_unicode.png" alt="text_unicode" width="80"> | ⭐⭐⭐⭐️ | 2.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
| [text_draw_3d](text/text_draw_3d.c) | <img src="text/text_draw_3d.png" alt="text_draw_3d" width="80"> | ⭐⭐⭐⭐️ | 3.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
| [text_codepoints_loading](text/text_codepoints_loading.c) | <img src="text/text_codepoints_loading.png" alt="text_codepoints_loading" width="80"> | ⭐⭐⭐☆ | 4.2 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_unicode_ranges](text/text_unicode_ranges.c) | <img src="text/text_unicode_ranges.png" alt="text_unicode_ranges" width="80"> | ⭐⭐⭐⭐️ | 2.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
Examples using raylib models functionality, including models loading/generation and drawing, provided by raylib [models](../src/models.c) module. ### category: models [23]
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer | Examples using raylib models functionality, including models loading/generation and drawing, provided by raylib [models](../src/rmodels.c) module.
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 93 | [models_animation](models/models_animation.c) | <img src="models/models_animation.png" alt="models_animation" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.5 | [Culacant](https://github.com/culacant) |
| 94 | [models_billboard](models/models_billboard.c) | <img src="models/models_billboard.png" alt="models_billboard" width="80"> | ⭐️⭐️⭐️☆ | 1.3 | 3.5 | [Ray](https://github.com/raysan5) |
| 95 | [models_box_collisions](models/models_box_collisions.c) | <img src="models/models_box_collisions.png" alt="models_box_collisions" width="80"> | ⭐️☆☆☆ | 1.3 | 3.5 | [Ray](https://github.com/raysan5) |
| 96 | [models_cubicmap](models/models_cubicmap.c) | <img src="models/models_cubicmap.png" alt="models_cubicmap" width="80"> | ⭐️⭐️☆☆ | 1.8 | 3.5 | [Ray](https://github.com/raysan5) |
| 97 | [models_first_person_maze](models/models_first_person_maze.c) | <img src="models/models_first_person_maze.png" alt="models_first_person_maze" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.5 | [Ray](https://github.com/raysan5) |
| 98 | [models_geometric_shapes](models/models_geometric_shapes.c) | <img src="models/models_geometric_shapes.png" alt="models_geometric_shapes" width="80"> | ⭐️☆☆☆ | 1.0 | 3.5 | [Ray](https://github.com/raysan5) |
| 99 | [models_mesh_generation](models/models_mesh_generation.c) | <img src="models/models_mesh_generation.png" alt="models_mesh_generation" width="80"> | ⭐️⭐️☆☆ | 1.8 | 4.0 | [Ray](https://github.com/raysan5) |
| 100 | [models_mesh_picking](models/models_mesh_picking.c) | <img src="models/models_mesh_picking.png" alt="models_mesh_picking" width="80"> | ⭐️⭐️⭐️☆ | 1.7 | 4.0 | [Joel Davis](https://github.com/joeld42) |
| 101 | [models_loading](models/models_loading.c) | <img src="models/models_loading.png" alt="models_loading" width="80"> | ⭐️☆☆☆ | 2.0 | 4.2 | [Ray](https://github.com/raysan5) |
| 102 | [models_loading_gltf](models/models_loading_gltf.c) | <img src="models/models_loading_gltf.png" alt="models_loading_gltf" width="80"> | ⭐️☆☆☆ | 3.7 | 4.2 | [Ray](https://github.com/raysan5) |
| 103 | [models_loading_vox](models/models_loading_vox.c) | <img src="models/models_loading_vox.png" alt="models_loading_vox" width="80"> | ⭐️☆☆☆ | 4.0 | 4.0 | [Johann Nadalutti](https://github.com/procfxgen) |
| 104 | [models_loading_m3d](models/models_loading_m3d.c) | <img src="models/models_loading_m3d.png" alt="models_loading_m3d" width="80"> | ⭐️⭐️☆☆ | 4.5 | 4.5 | [bzt](https://bztsrc.gitlab.io/model3d) |
| 105 | [models_orthographic_projection](models/models_orthographic_projection.c) | <img src="models/models_orthographic_projection.png" alt="models_orthographic_projection" width="80"> | ⭐️☆☆☆ | 2.0 | 3.7 | [Max Danielsson](https://github.com/autious) |
| 106 | [models_point_rendering](models/models_point_rendering.c) | <img src="models/models_point_rendering.png" alt="models_point_rendering" width="80"> | ⭐️⭐️⭐️☆ | 5.0 | 5.0 | [Reese Gallagher](https://github.com/satchelfrost) |
| 107 | [models_rlgl_solar_system](models/models_rlgl_solar_system.c) | <img src="models/models_rlgl_solar_system.png" alt="models_rlgl_solar_system" width="80"> | ⭐️⭐️⭐️⭐️ | 2.5 | 4.0 | [Ray](https://github.com/raysan5) |
| 108 | [models_yaw_pitch_roll](models/models_yaw_pitch_roll.c) | <img src="models/models_yaw_pitch_roll.png" alt="models_yaw_pitch_roll" width="80"> | ⭐️⭐️☆☆ | 1.8 | 4.0 | [Berni](https://github.com/Berni8k) |
| 109 | [models_waving_cubes](models/models_waving_cubes.c) | <img src="models/models_waving_cubes.png" alt="models_waving_cubes" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.7 | [Codecat](https://github.com/codecat) |
| 110 | [models_heightmap](models/models_heightmap.c) | <img src="models/models_heightmap.png" alt="models_heightmap" width="80"> | ⭐️☆☆☆ | 1.8 | 3.5 | [Ray](https://github.com/raysan5) |
| 111 | [models_skybox](models/models_skybox.c) | <img src="models/models_skybox.png" alt="models_skybox" width="80"> | ⭐️⭐️☆☆ | 1.8 | 4.0 | [Ray](https://github.com/raysan5) |
| 112 | [models_draw_cube_texture](models/models_draw_cube_texture.c) | <img src="models/models_draw_cube_texture.png" alt="models_draw_cube_texture" width="80"> | ⭐️⭐️☆☆ | 4.5 | 4.5 | [Ray](https://github.com/raysan5) |
| 113 | [models_gpu_skinning](models/models_gpu_skinning.c) | <img src="models/models_gpu_skinning.png" alt="models_gpu_skinning" width="80"> | ⭐️⭐️⭐️☆ | 4.5 | 4.5 | [Daniel Holden](https://github.com/orangeduck) |
| 114 | [models_bone_socket](models/models_bone_socket.c) | <img src="models/models_bone_socket.png" alt="models_bone_socket" width="80"> | ⭐️⭐️⭐️⭐️ | 4.5 | 4.5 | [iP](https://github.com/ipzaur) |
| 115 | [models_tesseract_view](models/models_tesseract_view.c) | <img src="models/models_tesseract_view.png" alt="models_tesseract_view" width="80"> | ⭐️⭐️☆☆ | 5.6-dev | 5.6-dev | [Timothy van der Valk](https://github.com/arceryz) |
### category: shaders | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| [models_animation](models/models_animation.c) | <img src="models/models_animation.png" alt="models_animation" width="80"> | ⭐⭐☆☆ | 2.5 | 3.5 | [Culacant](https://github.com/culacant) |
| [models_billboard](models/models_billboard.c) | <img src="models/models_billboard.png" alt="models_billboard" width="80"> | ⭐⭐⭐☆ | 1.3 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_box_collisions](models/models_box_collisions.c) | <img src="models/models_box_collisions.png" alt="models_box_collisions" width="80"> | ⭐☆☆☆ | 1.3 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_cubicmap](models/models_cubicmap.c) | <img src="models/models_cubicmap.png" alt="models_cubicmap" width="80"> | ⭐⭐☆☆ | 1.8 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_first_person_maze](models/models_first_person_maze.c) | <img src="models/models_first_person_maze.png" alt="models_first_person_maze" width="80"> | ⭐⭐☆☆ | 2.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_geometric_shapes](models/models_geometric_shapes.c) | <img src="models/models_geometric_shapes.png" alt="models_geometric_shapes" width="80"> | ⭐☆☆☆ | 1.0 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_mesh_generation](models/models_mesh_generation.c) | <img src="models/models_mesh_generation.png" alt="models_mesh_generation" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_mesh_picking](models/models_mesh_picking.c) | <img src="models/models_mesh_picking.png" alt="models_mesh_picking" width="80"> | ⭐⭐⭐☆ | 1.7 | 4.0 | [Joel Davis](https://github.com/joeld42) |
| [models_loading](models/models_loading.c) | <img src="models/models_loading.png" alt="models_loading" width="80"> | ⭐☆☆☆ | 2.0 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_loading_gltf](models/models_loading_gltf.c) | <img src="models/models_loading_gltf.png" alt="models_loading_gltf" width="80"> | ⭐☆☆☆ | 3.7 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_loading_vox](models/models_loading_vox.c) | <img src="models/models_loading_vox.png" alt="models_loading_vox" width="80"> | ⭐☆☆☆ | 4.0 | 4.0 | [Johann Nadalutti](https://github.com/procfxgen) |
| [models_loading_m3d](models/models_loading_m3d.c) | <img src="models/models_loading_m3d.png" alt="models_loading_m3d" width="80"> | ⭐⭐☆☆ | 4.5 | 4.5 | [bzt](https://github.com/model3d) |
| [models_orthographic_projection](models/models_orthographic_projection.c) | <img src="models/models_orthographic_projection.png" alt="models_orthographic_projection" width="80"> | ⭐☆☆☆ | 2.0 | 3.7 | [Max Danielsson](https://github.com/autious) |
| [models_point_rendering](models/models_point_rendering.c) | <img src="models/models_point_rendering.png" alt="models_point_rendering" width="80"> | ⭐⭐⭐☆ | 5.0 | 5.0 | [Reese Gallagher](https://github.com/satchelfrost) |
| [models_rlgl_solar_system](models/models_rlgl_solar_system.c) | <img src="models/models_rlgl_solar_system.png" alt="models_rlgl_solar_system" width="80"> | ⭐⭐⭐⭐️ | 2.5 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_yaw_pitch_roll](models/models_yaw_pitch_roll.c) | <img src="models/models_yaw_pitch_roll.png" alt="models_yaw_pitch_roll" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Berni](https://github.com/Berni8k) |
| [models_waving_cubes](models/models_waving_cubes.c) | <img src="models/models_waving_cubes.png" alt="models_waving_cubes" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.7 | [Codecat](https://github.com/codecat) |
| [models_heightmap](models/models_heightmap.c) | <img src="models/models_heightmap.png" alt="models_heightmap" width="80"> | ⭐☆☆☆ | 1.8 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_skybox](models/models_skybox.c) | <img src="models/models_skybox.png" alt="models_skybox" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_draw_cube_texture](models/models_draw_cube_texture.c) | <img src="models/models_draw_cube_texture.png" alt="models_draw_cube_texture" width="80"> | ⭐⭐☆☆ | 4.5 | 4.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_gpu_skinning](models/models_gpu_skinning.c) | <img src="models/models_gpu_skinning.png" alt="models_gpu_skinning" width="80"> | ⭐⭐⭐☆ | 4.5 | 4.5 | [Daniel Holden](https://github.com/orangeduck) |
| [models_bone_socket](models/models_bone_socket.c) | <img src="models/models_bone_socket.png" alt="models_bone_socket" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [iP](https://github.com/ipzaur) |
| [models_tesseract_view](models/models_tesseract_view.c) | <img src="models/models_tesseract_view.png" alt="models_tesseract_view" width="80"> | ⭐⭐☆☆ | 5.6 | 5.6 | [Timothy van der Valk](https://github.com/arceryz) |
### category: shaders [29]
Examples using raylib shaders functionality, including shaders loading, parameters configuration and drawing using them (model shaders and postprocessing shaders). This functionality is directly provided by raylib [rlgl](../src/rlgl.c) module. Examples using raylib shaders functionality, including shaders loading, parameters configuration and drawing using them (model shaders and postprocessing shaders). This functionality is directly provided by raylib [rlgl](../src/rlgl.c) module.
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer | | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------| |-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 116 | [shaders_basic_lighting](shaders/shaders_basic_lighting.c) | <img src="shaders/shaders_basic_lighting.png" alt="shaders_basic_lighting" width="80"> | ⭐️⭐️⭐️⭐️ | 3.0 | 4.2 | [Chris Camacho](https://github.com/chriscamacho) | | [shaders_basic_lighting](shaders/shaders_basic_lighting.c) | <img src="shaders/shaders_basic_lighting.png" alt="shaders_basic_lighting" width="80"> | ⭐⭐⭐⭐️ | 3.0 | 4.2 | [Chris Camacho](https://github.com/chriscamacho) |
| 117 | [shaders_model_shader](shaders/shaders_model_shader.c) | <img src="shaders/shaders_model_shader.png" alt="shaders_model_shader" width="80"> | ⭐️⭐️☆☆ | 1.3 | 3.7 | [Ray](https://github.com/raysan5) | | [shaders_model_shader](shaders/shaders_model_shader.c) | <img src="shaders/shaders_model_shader.png" alt="shaders_model_shader" width="80"> | ⭐⭐☆☆ | 1.3 | 3.7 | [Ramon Santamaria](https://github.com/raysan5) |
| 118 | [shaders_shapes_textures](shaders/shaders_shapes_textures.c) | <img src="shaders/shaders_shapes_textures.png" alt="shaders_shapes_textures" width="80"> | ⭐️⭐️☆☆ | 1.7 | 3.7 | [Ray](https://github.com/raysan5) | | [shaders_shapes_textures](shaders/shaders_shapes_textures.c) | <img src="shaders/shaders_shapes_textures.png" alt="shaders_shapes_textures" width="80"> | ⭐⭐☆☆ | 1.7 | 3.7 | [Ramon Santamaria](https://github.com/raysan5) |
| 119 | [shaders_custom_uniform](shaders/shaders_custom_uniform.c) | <img src="shaders/shaders_custom_uniform.png" alt="shaders_custom_uniform" width="80"> | ⭐️⭐️☆☆ | 1.3 | 4.0 | [Ray](https://github.com/raysan5) | | [shaders_custom_uniform](shaders/shaders_custom_uniform.c) | <img src="shaders/shaders_custom_uniform.png" alt="shaders_custom_uniform" width="80"> | ⭐⭐☆☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 120 | [shaders_postprocessing](shaders/shaders_postprocessing.c) | <img src="shaders/shaders_postprocessing.png" alt="shaders_postprocessing" width="80"> | ⭐️⭐️⭐️☆ | 1.3 | 4.0 | [Ray](https://github.com/raysan5) | | [shaders_postprocessing](shaders/shaders_postprocessing.c) | <img src="shaders/shaders_postprocessing.png" alt="shaders_postprocessing" width="80"> | ⭐⭐⭐☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 121 | [shaders_palette_switch](shaders/shaders_palette_switch.c) | <img src="shaders/shaders_palette_switch.png" alt="shaders_palette_switch" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.7 | [Marco Lizza](https://github.com/MarcoLizza) | | [shaders_palette_switch](shaders/shaders_palette_switch.c) | <img src="shaders/shaders_palette_switch.png" alt="shaders_palette_switch" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.7 | [Marco Lizza](https://github.com/MarcoLizza) |
| 122 | [shaders_raymarching](shaders/shaders_raymarching.c) | <img src="shaders/shaders_raymarching.png" alt="shaders_raymarching" width="80"> | ⭐️⭐️⭐️⭐️ | 2.0 | 4.2 | [Ray](https://github.com/raysan5) | | [shaders_raymarching](shaders/shaders_raymarching.c) | <img src="shaders/shaders_raymarching.png" alt="shaders_raymarching" width="80"> | ⭐⭐⭐⭐️ | 2.0 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| 123 | [shaders_texture_drawing](shaders/shaders_texture_drawing.c) | <img src="shaders/shaders_texture_drawing.png" alt="shaders_texture_drawing" width="80"> | ⭐️⭐️☆☆ | 2.0 | 3.7 | [Michał Ciesielski](https://github.com/ciessielski) | | [shaders_texture_drawing](shaders/shaders_texture_drawing.c) | <img src="shaders/shaders_texture_drawing.png" alt="shaders_texture_drawing" width="80"> | ⭐⭐☆☆ | 2.0 | 3.7 | [Michał Ciesielski](https://github.com/ciessielski) |
| 124 | [shaders_texture_outline](shaders/shaders_texture_outline.c) | <img src="shaders/shaders_texture_outline.png" alt="shaders_texture_outline" width="80"> | ⭐️⭐️⭐️☆ | 4.0 | 4.0 | [Samuel Skiff](https://github.com/GoldenThumbs) | | [shaders_texture_outline](shaders/shaders_texture_outline.c) | <img src="shaders/shaders_texture_outline.png" alt="shaders_texture_outline" width="80"> | ⭐⭐⭐☆ | 4.0 | 4.0 | [Samuel Skiff](https://github.com/GoldenThumbs) |
| 125 | [shaders_texture_waves](shaders/shaders_texture_waves.c) | <img src="shaders/shaders_texture_waves.png" alt="shaders_texture_waves" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.7 | [Anata](https://github.com/anatagawa) | | [shaders_texture_waves](shaders/shaders_texture_waves.c) | <img src="shaders/shaders_texture_waves.png" alt="shaders_texture_waves" width="80"> | ⭐⭐☆☆ | 2.5 | 3.7 | [Anata](https://github.com/anatagawa) |
| 126 | [shaders_julia_set](shaders/shaders_julia_set.c) | <img src="shaders/shaders_julia_set.png" alt="shaders_julia_set" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 4.0 | [Josh Colclough](https://github.com/joshcol9232) | | [shaders_julia_set](shaders/shaders_julia_set.c) | <img src="shaders/shaders_julia_set.png" alt="shaders_julia_set" width="80"> | ⭐⭐⭐☆ | 2.5 | 4.0 | [Josh Colclough](https://github.com/joshcol9232) |
| 127 | [shaders_eratosthenes](shaders/shaders_eratosthenes.c) | <img src="shaders/shaders_eratosthenes.png" alt="shaders_eratosthenes" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 4.0 | [ProfJski](https://github.com/ProfJski) | | [shaders_eratosthenes](shaders/shaders_eratosthenes.c) | <img src="shaders/shaders_eratosthenes.png" alt="shaders_eratosthenes" width="80"> | ⭐⭐⭐☆ | 2.5 | 4.0 | [ProfJski](https://github.com/ProfJski) |
| 128 | [shaders_fog](shaders/shaders_fog.c) | <img src="shaders/shaders_fog.png" alt="shaders_fog" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) | | [shaders_fog](shaders/shaders_fog.c) | <img src="shaders/shaders_fog.png" alt="shaders_fog" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| 129 | [shaders_simple_mask](shaders/shaders_simple_mask.c) | <img src="shaders/shaders_simple_mask.png" alt="shaders_simple_mask" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) | | [shaders_simple_mask](shaders/shaders_simple_mask.c) | <img src="shaders/shaders_simple_mask.png" alt="shaders_simple_mask" width="80"> | ⭐⭐☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| 130 | [shaders_hot_reloading](shaders/shaders_hot_reloading.c) | <img src="shaders/shaders_hot_reloading.png" alt="shaders_hot_reloading" width="80"> | ⭐️⭐️⭐️☆ | 3.0 | 3.5 | [Ray](https://github.com/raysan5) | | [shaders_hot_reloading](shaders/shaders_hot_reloading.c) | <img src="shaders/shaders_hot_reloading.png" alt="shaders_hot_reloading" width="80"> | ⭐⭐⭐☆ | 3.0 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| 131 | [shaders_mesh_instancing](shaders/shaders_mesh_instancing.c) | <img src="shaders/shaders_mesh_instancing.png" alt="shaders_mesh_instancing" width="80"> | ⭐️⭐️⭐️⭐️ | 3.7 | 4.2 | [seanpringle](https://github.com/seanpringle) | | [shaders_mesh_instancing](shaders/shaders_mesh_instancing.c) | <img src="shaders/shaders_mesh_instancing.png" alt="shaders_mesh_instancing" width="80"> | ⭐⭐⭐⭐️ | 3.7 | 4.2 | [seanpringle](https://github.com/seanpringle) |
| 132 | [shaders_multi_sample2d](shaders/shaders_multi_sample2d.c) | <img src="shaders/shaders_multi_sample2d.png" alt="shaders_multi_sample2d" width="80"> | ⭐️⭐️☆☆ | 3.5 | 3.5 | [Ray](https://github.com/raysan5) | | [shaders_multi_sample2d](shaders/shaders_multi_sample2d.c) | <img src="shaders/shaders_multi_sample2d.png" alt="shaders_multi_sample2d" width="80"> | ⭐⭐☆☆ | 3.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| 133 | [shaders_spotlight](shaders/shaders_spotlight.c) | <img src="shaders/shaders_spotlight.png" alt="shaders_spotlight" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) | | [shaders_normal_map](shaders/shaders_normal_map.c) | <img src="shaders/shaders_normal_map.png" alt="shaders_normal_map" width="80"> | ⭐⭐⭐⭐️ | 5.6 | 5.6 | [Jeremy Montgomery](https://github.com/Sir_Irk) |
| 134 | [shaders_deferred_render](shaders/shaders_deferred_render.c) | <img src="shaders/shaders_deferred_render.png" alt="shaders_deferred_render" width="80"> | ⭐️⭐️⭐️⭐️ | 4.5 | 4.5 | [Justin Andreas Lacoste](https://github.com/27justin) | | [shaders_spotlight](shaders/shaders_spotlight.c) | <img src="shaders/shaders_spotlight.png" alt="shaders_spotlight" width="80"> | ⭐⭐☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| 135 | [shaders_hybrid_render](shaders/shaders_hybrid_render.c) | <img src="shaders/shaders_hybrid_render.png" alt="shaders_hybrid_render" width="80"> | ⭐️⭐️⭐️⭐️ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) | | [shaders_deferred_render](shaders/shaders_deferred_render.c) | <img src="shaders/shaders_deferred_render.png" alt="shaders_deferred_render" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [Justin Andreas Lacoste](https://github.com/27justin) |
| 136 | [shaders_texture_tiling](shaders/shaders_texture_tiling.c) | <img src="shaders/shaders_texture_tiling.png" alt="shaders_texture_tiling" width="80"> | ⭐️⭐️☆☆ | 4.5 | 4.5 | [Luis Almeida](https://github.com/luis605) | | [shaders_hybrid_render](shaders/shaders_hybrid_render.c) | <img src="shaders/shaders_hybrid_render.png" alt="shaders_hybrid_render" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) |
| 137 | [shaders_shadowmap](shaders/shaders_shadowmap.c) | <img src="shaders/shaders_shadowmap.png" alt="shaders_shadowmap" width="80"> | ⭐️⭐️⭐️⭐️ | 5.0 | 5.0 | [TheManTheMythTheGameDev](https://github.com/TheManTheMythTheGameDev) | | [shaders_texture_tiling](shaders/shaders_texture_tiling.c) | <img src="shaders/shaders_texture_tiling.png" alt="shaders_texture_tiling" width="80"> | ⭐⭐☆☆ | 4.5 | 4.5 | [Luis Almeida](https://github.com/luis605) |
| 138 | [shaders_vertex_displacement](shaders/shaders_vertex_displacement.c) | <img src="shaders/shaders_vertex_displacement.png" alt="shaders_vertex_displacement" width="80"> | ⭐️⭐️⭐️☆ | 5.0 | 4.5 | [Alex ZH](https://github.com/ZzzhHe) | | [shaders_shadowmap](shaders/shaders_shadowmap.c) | <img src="shaders/shaders_shadowmap.png" alt="shaders_shadowmap" width="80"> | ⭐⭐⭐⭐️ | 5.0 | 5.0 | [TheManTheMythTheGameDev](https://github.com/TheManTheMythTheGameDev) |
| 139 | [shaders_write_depth](shaders/shaders_write_depth.c) | <img src="shaders/shaders_write_depth.png" alt="shaders_write_depth" width="80"> | ⭐️⭐️☆☆ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) | | [shaders_vertex_displacement](shaders/shaders_vertex_displacement.c) | <img src="shaders/shaders_vertex_displacement.png" alt="shaders_vertex_displacement" width="80"> | ⭐⭐⭐☆ | 5.0 | 4.5 | [Alex ZH](https://github.com/ZzzhHe) |
| 140 | [shaders_basic_pbr](shaders/shaders_basic_pbr.c) | <img src="shaders/shaders_basic_pbr.png" alt="shaders_basic_pbr" width="80"> | ⭐️⭐️⭐️⭐️ | 5.0 | 5.1-dev | [Afan OLOVCIC](https://github.com/_DevDad) | | [shaders_write_depth](shaders/shaders_write_depth.c) | <img src="shaders/shaders_write_depth.png" alt="shaders_write_depth" width="80"> | ⭐⭐☆☆ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) |
| 141 | [shaders_lightmap](shaders/shaders_lightmap.c) | <img src="shaders/shaders_lightmap.png" alt="shaders_lightmap" width="80"> | ⭐️⭐️⭐️☆ | 4.5 | 4.5 | [Jussi Viitala](https://github.com/nullstare) | | [shaders_basic_pbr](shaders/shaders_basic_pbr.c) | <img src="shaders/shaders_basic_pbr.png" alt="shaders_basic_pbr" width="80"> | ⭐⭐⭐⭐️ | 5.0 | 5.1 | [Afan OLOVCIC](https://github.com/_DevDad) |
| 142 | [shaders_rounded_rectangle](shaders/shaders_rounded_rectangle.c) | <img src="shaders/shaders_rounded_rectangle.png" alt="shaders_rounded_rectangle" width=80> | ⭐️⭐️⭐️☆ | 5.5 | 5.5 | [Anstro Pleuton](https://github.com/anstropleuton) | | [shaders_lightmap](shaders/shaders_lightmap.c) | <img src="shaders/shaders_lightmap.png" alt="shaders_lightmap" width="80"> | ⭐⭐⭐☆ | 4.5 | 4.5 | [Jussi Viitala](https://github.com/nullstare) |
| 143 | [shaders_view_depth](shaders/shaders_view_depth.c) | <img src="shaders/shaders_view_depth.png" alt="shaders_view_depth" width="80"> | ⭐️⭐️⭐️☆ | 5.6-dev | 5.6-dev | [Luís Almeida](https://github.com/luis605) | | [shaders_rounded_rectangle](shaders/shaders_rounded_rectangle.c) | <img src="shaders/shaders_rounded_rectangle.png" alt="shaders_rounded_rectangle" width="80"> | ⭐⭐⭐☆ | 5.5 | 5.5 | [Anstro Pleuton](https://github.com/anstropleuton) |
| [shaders_view_depth](shaders/shaders_view_depth.c) | <img src="shaders/shaders_view_depth.png" alt="shaders_view_depth" width="80"> | ⭐⭐⭐☆ | 5.6 | 5.6 | [Luís Almeida](https://github.com/luis605) |
### category: audio ### category: audio [8]
Examples using raylib audio functionality, including sound/music loading and playing. This functionality is provided by raylib [raudio](../src/raudio.c) module. Note this module can be used standalone independently of raylib, check [raudio_standalone](others/raudio_standalone.c) example. Examples using raylib audio functionality, including sound/music loading and playing. This functionality is provided by raylib [raudio](../src/raudio.c) module. Note this module can be used standalone independently of raylib.
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer | | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------| |-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 144 | [audio_module_playing](audio/audio_module_playing.c) | <img src="audio/audio_module_playing.png" alt="audio_module_playing" width="80"> | ⭐️☆☆☆ | 1.5 | 3.5 | [Ray](https://github.com/raysan5) | | [audio_module_playing](audio/audio_module_playing.c) | <img src="audio/audio_module_playing.png" alt="audio_module_playing" width="80"> | ⭐☆☆☆ | 1.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| 145 | [audio_music_stream](audio/audio_music_stream.c) | <img src="audio/audio_music_stream.png" alt="audio_music_stream" width="80"> | ⭐️☆☆☆ | 1.3 | 4.2 | [Ray](https://github.com/raysan5) | | [audio_music_stream](audio/audio_music_stream.c) | <img src="audio/audio_music_stream.png" alt="audio_music_stream" width="80"> | ⭐☆☆☆ | 1.3 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| 146 | [audio_raw_stream](audio/audio_raw_stream.c) | <img src="audio/audio_raw_stream.png" alt="audio_raw_stream" width="80"> | ⭐️⭐️⭐️☆ | 1.6 | 4.2 | [Ray](https://github.com/raysan5) | | [audio_raw_stream](audio/audio_raw_stream.c) | <img src="audio/audio_raw_stream.png" alt="audio_raw_stream" width="80"> | ⭐⭐⭐☆ | 1.6 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| 147 | [audio_sound_loading](audio/audio_sound_loading.c) | <img src="audio/audio_sound_loading.png" alt="audio_sound_loading" width="80"> | ⭐️☆☆☆ | 1.1 | 3.5 | [Ray](https://github.com/raysan5) | | [audio_sound_loading](audio/audio_sound_loading.c) | <img src="audio/audio_sound_loading.png" alt="audio_sound_loading" width="80"> | ⭐☆☆☆ | 1.1 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| 148 | [audio_mixed_processor](audio/audio_mixed_processor.c) | <img src="audio/audio_mixed_processor.png" alt="audio_mixed_processor" width="80"> | ⭐⭐️ | 4.2 | 4.2 | [hkc](https://github.com/hatkidchan) | | [audio_mixed_processor](audio/audio_mixed_processor.c) | <img src="audio/audio_mixed_processor.png" alt="audio_mixed_processor" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 4.2 | [hkc](https://github.com/hatkidchan) |
| 149 | [audio_stream_effects](audio/audio_stream_effects.c) | <img src="audio/audio_stream_effects.png" alt="audio_stream_effects" width="80"> | ⭐️⭐️⭐️⭐️ | 4.2 | 5.0 | [Ray](https://github.com/raysan5) | | [audio_stream_effects](audio/audio_stream_effects.c) | <img src="audio/audio_stream_effects.png" alt="audio_stream_effects" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 150 [audio_sound_multi](audio/audio_sound_multi.c) | <img src="audio/audio_sound_multi.png" alt="audio_sound_multi" width="80"> | ⭐☆☆ | 4.6 | 4.6 | [Jeffery Myers](https://github.com/JeffM2501) | | [audio_sound_multi](audio/audio_sound_multi.c) | <img src="audio/audio_sound_multi.png" alt="audio_sound_multi" width="80"> | ⭐⭐☆☆ | 4.6 | 4.6 | [Jeffery Myers](https://github.com/JeffM2501) |
| 151 | [audio_sound_positioning](audio/audio_sound_positioning.c) | <img src="audio/audio_sound_positioning.png" alt="audio_sound_positioning" width="80"> | ⭐☆☆ | 5.5 | 5.5 | [Le Juez Victor](https://github.com/Bigfoot71) | | [audio_sound_positioning](audio/audio_sound_positioning.c) | <img src="audio/audio_sound_positioning.png" alt="audio_sound_positioning" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [Le Juez Victor](https://github.com/Bigfoot71) |
### category: others ### category: others [6]
Ex150amples 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.
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer | | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------| |-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 152 | [rlgl_standalone](others/rlgl_standalone.c) | <img src="others/rlgl_standalone.png" alt="rlgl_standalone" width="80"> | ⭐️⭐️⭐️⭐️ | 1.6 | 4.0 | [Ray](https://github.com/raysan5) | | [rlgl_standalone](others/rlgl_standalone.c) | <img src="others/rlgl_standalone.png" alt="rlgl_standalone" width="80"> | ⭐⭐⭐⭐️ | 1.6 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| 153 | [rlgl_compute_shader](others/rlgl_compute_shader.c) | <img src="others/rlgl_compute_shader.png" alt="rlgl_compute_shader" width="80"> | ⭐⭐️ | 4.0 | 4.0 | [Teddy Astie](https://github.com/tsnake41) | | [rlgl_compute_shader](others/rlgl_compute_shader.c) | <img src="others/rlgl_compute_shader.png" alt="rlgl_compute_shader" width="80"> | ⭐⭐⭐⭐️ | 4.0 | 4.0 | [Teddy Astie](https://github.com/tsnake41) |
| 154 | [easings_testbed](others/easings_testbed.c) | <img src="others/easings_testbed.png" alt="easings_testbed" width="80"> | ⭐☆ | 2.5 | 3.0 | [Juan Miguel López](https://github.com/flashback-fx) | | [easings_testbed](others/easings_testbed.c) | <img src="others/easings_testbed.png" alt="easings_testbed" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.0 | [Juan Miguel López](https://github.com/flashback-fx) |
| 155 | [raylib_opengl_interop](others/raylib_opengl_interop.c) | <img src="others/raylib_opengl_interop.png" alt="raylib_opengl_interop" width="80"> | ⭐⭐️ | 3.8 | 4.0 | [Stephan Soller](https://github.com/arkanis) | | [raylib_opengl_interop](others/raylib_opengl_interop.c) | <img src="others/raylib_opengl_interop.png" alt="raylib_opengl_interop" width="80"> | ⭐⭐⭐⭐️ | 3.8 | 4.0 | [Stephan Soller](https://github.com/arkanis) |
| 156 | [embedded_files_loading](others/embedded_files_loading.c) | <img src="others/embedded_files_loading.png" alt="embedded_files_loading" width="80"> | ⭐☆☆ | 3.0 | 3.5 | [Kristian Holmgren](https://github.com/defutura) | | [embedded_files_loading](others/embedded_files_loading.c) | <img src="others/embedded_files_loading.png" alt="embedded_files_loading" width="80"> | ⭐⭐☆☆ | 3.0 | 3.5 | [Kristian Holmgren](https://github.com/defutura) |
| 157 | [raymath_vector_angle](others/raymath_vector_angle.c) | <img src="others/raymath_vector_angle.png" alt="raymath_vector_angle" width="80"> | ⭐️⭐️☆☆ | 1.0 | 4.6 | [Ray](https://github.com/raysan5) | | [raymath_vector_angle](others/raymath_vector_angle.c) | <img src="others/raymath_vector_angle.png" alt="raymath_vector_angle" width="80"> | ⭐⭐☆☆ | 1.0 | 4.6 | [Ramon Santamaria](https://github.com/raysan5) |
As always contributions are welcome, feel free to send new examples! Here is an [examples template](examples_template.c) to start with! Some example missing? As always, contributions are welcome, feel free to send new examples!
Here is an[examples template](examples_template.c) with instructions to start with!

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [audio] example - Mixed audio processing * raylib [audio] example - mixed audio processing
* *
* Example complexity rating: [] 4/4 * Example complexity rating: [] 4/4
* *
@ -30,13 +30,13 @@ void ProcessAudio(void *buffer, unsigned int frames)
for (unsigned int frame = 0; frame < frames; frame++) for (unsigned int frame = 0; frame < frames; frame++)
{ {
float *left = &samples[frame * 2 + 0], *right = &samples[frame * 2 + 1]; float *left = &samples[frame*2 + 0], *right = &samples[frame*2 + 1];
*left = powf(fabsf(*left), exponent) * ( (*left < 0.0f)? -1.0f : 1.0f ); *left = powf(fabsf(*left), exponent)*( (*left < 0.0f)? -1.0f : 1.0f );
*right = powf(fabsf(*right), exponent) * ( (*right < 0.0f)? -1.0f : 1.0f ); *right = powf(fabsf(*right), exponent)*( (*right < 0.0f)? -1.0f : 1.0f );
average += fabsf(*left) / frames; // accumulating average volume average += fabsf(*left)/frames; // accumulating average volume
average += fabsf(*right) / frames; average += fabsf(*right)/frames;
} }
// Moving history to the left // Moving history to the left
@ -55,7 +55,7 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - processing mixed output"); InitWindow(screenWidth, screenHeight, "raylib [audio] example - mixed audio processing");
InitAudioDevice(); // Initialize audio device InitAudioDevice(); // Initialize audio device
@ -99,7 +99,7 @@ int main(void)
DrawRectangle(199, 199, 402, 34, LIGHTGRAY); DrawRectangle(199, 199, 402, 34, LIGHTGRAY);
for (int i = 0; i < 400; i++) for (int i = 0; i < 400; i++)
{ {
DrawLine(201 + i, 232 - (int)(averageVolume[i] * 32), 201 + i, 232, MAROON); DrawLine(201 + i, 232 - (int)(averageVolume[i]*32), 201 + i, 232, MAROON);
} }
DrawRectangleLines(199, 199, 402, 34, GRAY); DrawRectangleLines(199, 199, 402, 34, GRAY);

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [audio] example - Module playing (streaming) * raylib [audio] example - module playing (streaming)
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [audio] example - Music playing (streaming) * raylib [audio] example - music playing (streaming)
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *
@ -45,7 +45,7 @@ int main(void)
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateMusicStream(music); // Update music buffer with new stream data UpdateMusicStream(music); // Update music buffer with new stream data
// Restart music playing (stop and play) // Restart music playing (stop and play)
if (IsKeyPressed(KEY_SPACE)) if (IsKeyPressed(KEY_SPACE))
{ {

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [audio] example - Raw audio streaming * raylib [audio] example - raw audio streaming
* *
* Example complexity rating: [] 3/4 * Example complexity rating: [] 3/4
* *
@ -108,8 +108,6 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Sample mouse input.
mousePosition = GetMousePosition(); mousePosition = GetMousePosition();
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
@ -117,7 +115,7 @@ 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; float pan = (float)(mousePosition.x)/(float)screenWidth;
SetAudioStreamPan(stream, pan); SetAudioStreamPan(stream, pan);
} }
@ -125,7 +123,7 @@ int main(void)
// Compute two cycles to allow the buffer padding, simplifying any modulation, resampling, etc. // Compute two cycles to allow the buffer padding, simplifying any modulation, resampling, etc.
if (frequency != oldFrequency) if (frequency != oldFrequency)
{ {
// Compute wavelength. Limit size in both directions. // Compute wavelength. Limit size in both directions
//int oldWavelength = waveLength; //int oldWavelength = waveLength;
waveLength = (int)(22050/frequency); waveLength = (int)(22050/frequency);
if (waveLength > MAX_SAMPLES/2) waveLength = MAX_SAMPLES/2; if (waveLength > MAX_SAMPLES/2) waveLength = MAX_SAMPLES/2;
@ -143,7 +141,7 @@ int main(void)
} }
// Scale read cursor's position to minimize transition artifacts // Scale read cursor's position to minimize transition artifacts
//readCursor = (int)(readCursor * ((float)waveLength / (float)oldWavelength)); //readCursor = (int)(readCursor*((float)waveLength/(float)oldWavelength));
oldFrequency = frequency; oldFrequency = frequency;
} }

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [audio] example - Sound loading and playing * raylib [audio] example - sound loading and playing
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [audio] example - Playing sound multiple times * raylib [audio] example - sound alias
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *
@ -31,18 +31,18 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - playing sound multiple times"); InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound alias");
InitAudioDevice(); // Initialize audio device InitAudioDevice(); // Initialize audio device
// load the sound list // Load audio file into the first slot as the 'source' sound,
soundArray[0] = LoadSound("resources/sound.wav"); // Load WAV audio file into the first slot as the 'source' sound // this sound owns the sample data
// this sound owns the sample data soundArray[0] = LoadSound("resources/sound.wav");
for (int i = 1; i < MAX_SOUNDS; i++)
{ // Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
soundArray[i] = LoadSoundAlias(soundArray[0]); // Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played for (int i = 1; i < MAX_SOUNDS; i++) soundArray[i] = LoadSoundAlias(soundArray[0]);
}
currentSound = 0; // set the sound list to the start currentSound = 0; // Set the sound list to the start
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -54,14 +54,15 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_SPACE)) if (IsKeyPressed(KEY_SPACE))
{ {
PlaySound(soundArray[currentSound]); // play the next open sound slot PlaySound(soundArray[currentSound]); // Play the next open sound slot
currentSound++; // increment the sound slot currentSound++; // Increment the sound slot
if (currentSound >= MAX_SOUNDS) // if the sound slot is out of bounds, go back to 0
currentSound = 0;
// Note: a better way would be to look at the list for the first sound that is not playing and use that slot // If the sound slot is out of bounds, go back to 0
if (currentSound >= MAX_SOUNDS) currentSound = 0;
// NOTE: Another approach would be to look at the list for the first sound
// that is not playing and use that slot
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -78,9 +79,8 @@ int main(void)
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
for (int i = 1; i < MAX_SOUNDS; i++) for (int i = 1; i < MAX_SOUNDS; i++) UnloadSoundAlias(soundArray[i]); // Unload sound aliases
UnloadSoundAlias(soundArray[i]); // Unload sound aliases UnloadSound(soundArray[0]); // Unload source sound data
UnloadSound(soundArray[0]); // Unload source sound data
CloseAudioDevice(); // Close audio device CloseAudioDevice(); // Close audio device

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [audio] example - Playing spatialized 3D sound * raylib [audio] example - 3d sound positioning
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *
@ -31,9 +31,9 @@ int main(void)
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - Playing spatialized 3D sound"); InitWindow(screenWidth, screenHeight, "raylib [audio] example - 3d sound positioning");
InitAudioDevice(); InitAudioDevice();
Sound sound = LoadSound("resources/coin.wav"); Sound sound = LoadSound("resources/coin.wav");
@ -45,9 +45,9 @@ int main(void)
.fovy = 60, .fovy = 60,
.projection = CAMERA_PERSPECTIVE .projection = CAMERA_PERSPECTIVE
}; };
DisableCursor(); DisableCursor();
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -89,7 +89,7 @@ int main(void)
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadSound(sound); UnloadSound(sound);
CloseAudioDevice(); // Close audio device CloseAudioDevice(); // Close audio device
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
} }
@ -100,23 +100,23 @@ static void SetSoundPosition(Camera listener, Sound sound, Vector3 position, flo
// Calculate direction vector and distance between listener and sound source // Calculate direction vector and distance between listener and sound source
Vector3 direction = Vector3Subtract(position, listener.position); Vector3 direction = Vector3Subtract(position, listener.position);
float distance = Vector3Length(direction); float distance = Vector3Length(direction);
// Apply logarithmic distance attenuation and clamp between 0-1 // Apply logarithmic distance attenuation and clamp between 0-1
float attenuation = 1.0f/(1.0f + (distance/maxDist)); float attenuation = 1.0f/(1.0f + (distance/maxDist));
attenuation = Clamp(attenuation, 0.0f, 1.0f); attenuation = Clamp(attenuation, 0.0f, 1.0f);
// Calculate normalized vectors for spatial positioning // Calculate normalized vectors for spatial positioning
Vector3 normalizedDirection = Vector3Normalize(direction); Vector3 normalizedDirection = Vector3Normalize(direction);
Vector3 forward = Vector3Normalize(Vector3Subtract(listener.target, listener.position)); Vector3 forward = Vector3Normalize(Vector3Subtract(listener.target, listener.position));
Vector3 right = Vector3Normalize(Vector3CrossProduct(listener.up, forward)); Vector3 right = Vector3Normalize(Vector3CrossProduct(listener.up, forward));
// Reduce volume for sounds behind the listener // Reduce volume for sounds behind the listener
float dotProduct = Vector3DotProduct(forward, normalizedDirection); float dotProduct = Vector3DotProduct(forward, normalizedDirection);
if (dotProduct < 0.0f) attenuation *= (1.0f + dotProduct*0.5f); if (dotProduct < 0.0f) attenuation *= (1.0f + dotProduct*0.5f);
// Set stereo panning based on sound position relative to listener // Set stereo panning based on sound position relative to listener
float pan = 0.5f + 0.5f*Vector3DotProduct(normalizedDirection, right); float pan = 0.5f + 0.5f*Vector3DotProduct(normalizedDirection, right);
// Apply final sound properties // Apply final sound properties
SetSoundVolume(sound, attenuation); SetSoundVolume(sound, attenuation);
SetSoundPan(sound, pan); SetSoundPan(sound, pan);

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [audio] example - Music stream processing effects * raylib [audio] example - stream effects
* *
* Example complexity rating: [] 4/4 * Example complexity rating: [] 4/4
* *
@ -53,7 +53,7 @@ int main(void)
float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f] float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f]
bool pause = false; // Music playing paused bool pause = false; // Music playing paused
bool enableEffectLPF = false; // Enable effect low-pass-filter bool enableEffectLPF = false; // Enable effect low-pass-filter
bool enableEffectDelay = false; // Enable effect delay (1 second) bool enableEffectDelay = false; // Enable effect delay (1 second)
@ -98,7 +98,7 @@ int main(void)
if (enableEffectDelay) AttachAudioStreamProcessor(music.stream, AudioProcessEffectDelay); if (enableEffectDelay) AttachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
else DetachAudioStreamProcessor(music.stream, AudioProcessEffectDelay); else DetachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
} }
// Get normalized time played for current music stream // Get normalized time played for current music stream
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music); timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music);
@ -119,7 +119,7 @@ int main(void)
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 230, 20, LIGHTGRAY); DrawText("PRESS SPACE TO RESTART MUSIC", 215, 230, 20, LIGHTGRAY);
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 260, 20, LIGHTGRAY); DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 260, 20, LIGHTGRAY);
DrawText(TextFormat("PRESS F TO TOGGLE LPF EFFECT: %s", enableEffectLPF? "ON" : "OFF"), 200, 320, 20, GRAY); DrawText(TextFormat("PRESS F TO TOGGLE LPF EFFECT: %s", enableEffectLPF? "ON" : "OFF"), 200, 320, 20, GRAY);
DrawText(TextFormat("PRESS D TO TOGGLE DELAY EFFECT: %s", enableEffectDelay? "ON" : "OFF"), 180, 350, 20, GRAY); DrawText(TextFormat("PRESS D TO TOGGLE DELAY EFFECT: %s", enableEffectDelay? "ON" : "OFF"), 180, 350, 20, GRAY);
@ -148,8 +148,8 @@ int main(void)
static void AudioProcessEffectLPF(void *buffer, unsigned int frames) static void AudioProcessEffectLPF(void *buffer, unsigned int frames)
{ {
static float low[2] = { 0.0f, 0.0f }; static float low[2] = { 0.0f, 0.0f };
static const float cutoff = 70.0f / 44100.0f; // 70 Hz lowpass filter static const float cutoff = 70.0f/44100.0f; // 70 Hz lowpass filter
const float k = cutoff / (cutoff + 0.1591549431f); // RC filter formula const float k = cutoff/(cutoff + 0.1591549431f); // RC filter formula
// Converts the buffer data before using it // Converts the buffer data before using it
float *bufferData = (float *)buffer; float *bufferData = (float *)buffer;
@ -158,8 +158,8 @@ static void AudioProcessEffectLPF(void *buffer, unsigned int frames)
const float l = bufferData[i]; const float l = bufferData[i];
const float r = bufferData[i + 1]; const float r = bufferData[i + 1];
low[0] += k * (l - low[0]); low[0] += k*(l - low[0]);
low[1] += k * (r - low[1]); low[1] += k*(r - low[1]);
bufferData[i] = low[0]; bufferData[i] = low[0];
bufferData[i + 1] = low[1]; bufferData[i + 1] = low[1];
} }

View File

@ -0,0 +1,44 @@
::@echo off
:: .
:: Compile your examples for web using: build_example_web.bat <example_category>/<example_name>
:: .
SET "INPUT_FILE=%1"
:: Change delimiter for the FOR loop
FOR /f "tokens=1-10 delims=/" %%a IN ("%INPUT_FILE%") DO (
SET CATEGORY=%%a
SET FILENAME=%%b
)
:: > SETup required Environment
:: -------------------------------------
SET RAYLIB_PATH=C:\GitHub\raylib
SET EMSDK_PATH=C:\raylib\emsdk
SET COMPILER_PATH=C:\raylib\w64devkit\bin
ENV_SET PATH=%COMPILER_PATH%
SET MAKE=mingw32-make
echo
:: Set required web compilation options
:: -------------------------------------
::SET CC=%EMSDK_PATH%\upstream\emscripten\emcc
::SET CFLAGS=-Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -O3 -I. -Iexternal -I%RAYLIB_PATH%\src -I%RAYLIB_PATH%\external -DPLATFORM_WEB
::SET LDFLAGS=-L. -L$(RAYLIB_PATH)\src -sUSE_GLFW=3 -sEXPORTED_RUNTIME_METHODS=ccall -sASYNCIFY --shell-file %RAYLIB_PATH%\src\shell.html
::SET LDLIBS=%RAYLIB_PATH%\src\libraylib.web.a
echo
:: Clean latest build
:: ------------------------
cmd /c if exist %FILENAME%.html del /F %FILENAME%.html
cmd /c if exist %FILENAME%.wasm del /F %FILENAME%.wasm
cmd /c if exist %FILENAME%.js del /F %FILENAME%.js
cmd /c if exist %FILENAME%.data del /F %FILENAME%.data
echo
:: Setup emsdk environment
:: --------------------------
call %EMSDK_PATH%\emsdk_env.bat
echo on
:: Compile program
:: -----------------------
C:
cd %RAYLIB_PATH%\examples
%MAKE% -f Makefile.Web %CATEGORY%/%FILENAME% PLATFORM=PLATFORM_WEB -B
::%CC% -o %FILENAME%.html %FILENAME%.c %CFLAGS% %LDFLAGS% %LDLIBS% %RESOURCES%
cd ..
echo

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - 2D Camera system * raylib [core] example - 2d camera
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *

View File

@ -47,7 +47,7 @@ int main ()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_ONE)) zoomMode = 0; if (IsKeyPressed(KEY_ONE)) zoomMode = 0;
else if (IsKeyPressed(KEY_TWO)) zoomMode = 1; else if (IsKeyPressed(KEY_TWO)) zoomMode = 1;
// Translate based on mouse right click // Translate based on mouse right click
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
{ {
@ -68,7 +68,7 @@ int main ()
// Set the offset to where the mouse is // Set the offset to where the mouse is
camera.offset = GetMousePosition(); camera.offset = GetMousePosition();
// Set the target to match, so that the camera maps the world space point // Set the target to match, so that the camera maps the world space point
// under the cursor to the screen space point under the cursor at any zoom // under the cursor to the screen space point under the cursor at any zoom
camera.target = mouseWorldPos; camera.target = mouseWorldPos;
@ -89,7 +89,7 @@ int main ()
// Set the offset to where the mouse is // Set the offset to where the mouse is
camera.offset = GetMousePosition(); camera.offset = GetMousePosition();
// Set the target to match, so that the camera maps the world space point // Set the target to match, so that the camera maps the world space point
// under the cursor to the screen space point under the cursor at any zoom // under the cursor to the screen space point under the cursor at any zoom
camera.target = mouseWorldPos; camera.target = mouseWorldPos;
} }
@ -111,7 +111,7 @@ int main ()
BeginMode2D(camera); BeginMode2D(camera);
// Draw the 3d grid, rotated 90 degrees and centered around 0,0 // Draw the 3d grid, rotated 90 degrees and centered around 0,0
// just so we have something in the XY plane // just so we have something in the XY plane
rlPushMatrix(); rlPushMatrix();
rlTranslatef(0, 25*50, 0); rlTranslatef(0, 25*50, 0);
@ -121,19 +121,19 @@ int main ()
// Draw a reference circle // Draw a reference circle
DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, 50, MAROON); DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, 50, MAROON);
EndMode2D(); EndMode2D();
// Draw mouse reference // Draw mouse reference
//Vector2 mousePos = GetWorldToScreen2D(GetMousePosition(), camera) //Vector2 mousePos = GetWorldToScreen2D(GetMousePosition(), camera)
DrawCircleV(GetMousePosition(), 4, DARKGRAY); DrawCircleV(GetMousePosition(), 4, DARKGRAY);
DrawTextEx(GetFontDefault(), TextFormat("[%i, %i]", GetMouseX(), GetMouseY()), DrawTextEx(GetFontDefault(), TextFormat("[%i, %i]", GetMouseX(), GetMouseY()),
Vector2Add(GetMousePosition(), (Vector2){ -44, -24 }), 20, 2, BLACK); Vector2Add(GetMousePosition(), (Vector2){ -44, -24 }), 20, 2, BLACK);
DrawText("[1][2] Select mouse zoom mode (Wheel or Move)", 20, 20, 20, DARKGRAY); DrawText("[1][2] Select mouse zoom mode (Wheel or Move)", 20, 20, 20, DARKGRAY);
if (zoomMode == 0) DrawText("Mouse left button drag to move, mouse wheel to zoom", 20, 50, 20, DARKGRAY); if (zoomMode == 0) DrawText("Mouse left button drag to move, mouse wheel to zoom", 20, 50, 20, DARKGRAY);
else DrawText("Mouse left button drag to move, mouse press and move to zoom", 20, 50, 20, DARKGRAY); else DrawText("Mouse left button drag to move, mouse press and move to zoom", 20, 50, 20, DARKGRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - 2D Camera platformer * raylib [core] example - 2d camera platformer
* *
* Example complexity rating: [] 3/4 * Example complexity rating: [] 3/4
* *
@ -54,7 +54,7 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera platformer");
Player player = { 0 }; Player player = { 0 };
player.position = (Vector2){ 400, 280 }; player.position = (Vector2){ 400, 280 };
@ -137,7 +137,7 @@ int main(void)
Rectangle playerRect = { player.position.x - 20, player.position.y - 40, 40.0f, 40.0f }; Rectangle playerRect = { player.position.x - 20, player.position.y - 40, 40.0f, 40.0f };
DrawRectangleRec(playerRect, RED); DrawRectangleRec(playerRect, RED);
DrawCircleV(player.position, 5.0f, GOLD); DrawCircleV(player.position, 5.0f, GOLD);
EndMode2D(); EndMode2D();
@ -294,7 +294,7 @@ void UpdateCameraPlayerBoundsPush(Camera2D *camera, Player *player, EnvItem *env
Vector2 bboxWorldMin = GetScreenToWorld2D((Vector2){ (1 - bbox.x)*0.5f*width, (1 - bbox.y)*0.5f*height }, *camera); Vector2 bboxWorldMin = GetScreenToWorld2D((Vector2){ (1 - bbox.x)*0.5f*width, (1 - bbox.y)*0.5f*height }, *camera);
Vector2 bboxWorldMax = GetScreenToWorld2D((Vector2){ (1 + bbox.x)*0.5f*width, (1 + bbox.y)*0.5f*height }, *camera); Vector2 bboxWorldMax = GetScreenToWorld2D((Vector2){ (1 + bbox.x)*0.5f*width, (1 + bbox.y)*0.5f*height }, *camera);
camera->offset = (Vector2){ (1 - bbox.x)*0.5f * width, (1 - bbox.y)*0.5f*height }; camera->offset = (Vector2){ (1 - bbox.x)*0.5f*width, (1 - bbox.y)*0.5f*height };
if (player->position.x < bboxWorldMin.x) camera->target.x = player->position.x; if (player->position.x < bboxWorldMin.x) camera->target.x = player->position.x;
if (player->position.y < bboxWorldMin.y) camera->target.y = player->position.y; if (player->position.y < bboxWorldMin.y) camera->target.y = player->position.y;

View File

@ -4,7 +4,7 @@
* *
* Example complexity rating: [] 4/4 * Example complexity rating: [] 4/4
* *
* Addapted from the core_3d_camera_split_screen example: * Addapted from the core_3d_camera_split_screen example:
* https://github.com/raysan5/raylib/blob/master/examples/core/core_3d_camera_split_screen.c * https://github.com/raysan5/raylib/blob/master/examples/core/core_3d_camera_split_screen.c
* *
* Example originally created with raylib 4.5, last time updated with raylib 4.5 * Example originally created with raylib 4.5, last time updated with raylib 4.5
@ -81,9 +81,9 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginTextureMode(screenCamera1); BeginTextureMode(screenCamera1);
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
BeginMode2D(camera1); BeginMode2D(camera1);
// Draw full scene with first camera // Draw full scene with first camera
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++) for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
{ {
@ -106,17 +106,17 @@ int main(void)
DrawRectangleRec(player1, RED); DrawRectangleRec(player1, RED);
DrawRectangleRec(player2, BLUE); DrawRectangleRec(player2, BLUE);
EndMode2D(); EndMode2D();
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f)); DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
DrawText("PLAYER1: W/S/A/D to move", 10, 10, 10, MAROON); DrawText("PLAYER1: W/S/A/D to move", 10, 10, 10, MAROON);
EndTextureMode(); EndTextureMode();
BeginTextureMode(screenCamera2); BeginTextureMode(screenCamera2);
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
BeginMode2D(camera2); BeginMode2D(camera2);
// Draw full scene with second camera // Draw full scene with second camera
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++) for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
{ {
@ -138,21 +138,21 @@ int main(void)
DrawRectangleRec(player1, RED); DrawRectangleRec(player1, RED);
DrawRectangleRec(player2, BLUE); DrawRectangleRec(player2, BLUE);
EndMode2D(); EndMode2D();
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f)); DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
DrawText("PLAYER2: UP/DOWN/LEFT/RIGHT to move", 10, 10, 10, DARKBLUE); DrawText("PLAYER2: UP/DOWN/LEFT/RIGHT to move", 10, 10, 10, DARKBLUE);
EndTextureMode(); EndTextureMode();
// Draw both views render textures to the screen side by side // Draw both views render textures to the screen side by side
BeginDrawing(); BeginDrawing();
ClearBackground(BLACK); ClearBackground(BLACK);
DrawTextureRec(screenCamera1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE); DrawTextureRec(screenCamera1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
DrawTextureRec(screenCamera2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE); DrawTextureRec(screenCamera2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY); DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY);
EndDrawing(); EndDrawing();
} }

View File

@ -100,8 +100,8 @@ int main(void)
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.projection = CAMERA_ORTHOGRAPHIC; camera.projection = CAMERA_ORTHOGRAPHIC;
camera.fovy = 20.0f; // near plane width in CAMERA_ORTHOGRAPHIC camera.fovy = 20.0f; // near plane width in CAMERA_ORTHOGRAPHIC
CameraYaw(&camera, -135 * DEG2RAD, true); CameraYaw(&camera, -135*DEG2RAD, true);
CameraPitch(&camera, -45 * DEG2RAD, true, true, false); CameraPitch(&camera, -45*DEG2RAD, true, true, false);
} }
else if (camera.projection == CAMERA_ORTHOGRAPHIC) else if (camera.projection == CAMERA_ORTHOGRAPHIC)
{ {
@ -127,7 +127,7 @@ int main(void)
UpdateCameraPro(&camera, UpdateCameraPro(&camera,
(Vector3){ (Vector3){
(IsKeyDown(KEY_W) || IsKeyDown(KEY_UP))*0.1f - // Move forward-backward (IsKeyDown(KEY_W) || IsKeyDown(KEY_UP))*0.1f - // Move forward-backward
(IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN))*0.1f, (IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN))*0.1f,
(IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT))*0.1f - // Move right-left (IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT))*0.1f - // Move right-left
(IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT))*0.1f, (IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT))*0.1f,
0.0f // Move up-down 0.0f // Move up-down

View File

@ -0,0 +1,330 @@
/*******************************************************************************************
*
* raylib [core] example - 3d first-person camera controller
*
* Example complexity rating: [] 3/4
*
* Example originally created with raylib 5.5, last time updated with raylib 5.5
*
* Example contributed by Agnis Aldins (@nezvers) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2025-2025 Agnis Aldins (@nezvers)
*
********************************************************************************************/
#include "raylib.h"
#include "raymath.h"
#include "rcamera.h"
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
// Movement constants
#define GRAVITY 32.0f
#define MAX_SPEED 20.0f
#define CROUCH_SPEED 5.0f
#define JUMP_FORCE 12.0f
#define MAX_ACCEL 150.0f
// Grounded drag
#define FRICTION 0.86f
// Increasing air drag, increases strafing speed
#define AIR_DRAG 0.98f
// Responsiveness for turning movement direction to looked direction
#define CONTROL 15.0f
#define CROUCH_HEIGHT 0.0f
#define STAND_HEIGHT 1.0f
#define BOTTOM_HEIGHT 0.5f
#define NORMALIZE_INPUT 0
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
// Body structure
typedef struct {
Vector3 position;
Vector3 velocity;
Vector3 dir;
bool isGrounded;
} Body;
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
static Vector2 sensitivity = { 0.001f, 0.001f };
static Body player = { 0 };
static Vector2 lookRotation = { 0 };
static float headTimer = 0.0f;
static float walkLerp = 0.0f;
static float headLerp = STAND_HEIGHT;
static Vector2 lean = { 0 };
//----------------------------------------------------------------------------------
// Module functions declaration
//----------------------------------------------------------------------------------
static void DrawLevel(void);
static void UpdateCameraAngle(Camera *camera);
static void UpdateBody(Body *body, float rot, char side, char forward, bool jumpPressed, bool crouchHold);
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d first-person camera controller");
// Initialize camera variables
// NOTE: UpdateCameraAngle() takes care of the rest
Camera camera = { 0 };
camera.fovy = 60.0f;
camera.projection = CAMERA_PERSPECTIVE;
camera.position = (Vector3){
player.position.x,
player.position.y + (BOTTOM_HEIGHT + headLerp),
player.position.z,
};
UpdateCameraAngle(&camera); // Update camera parameters
DisableCursor(); // Limit cursor to relative movement inside the window
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
Vector2 mouseDelta = GetMouseDelta();
lookRotation.x -= mouseDelta.x*sensitivity.x;
lookRotation.y += mouseDelta.y*sensitivity.y;
char sideway = (IsKeyDown(KEY_D) - IsKeyDown(KEY_A));
char forward = (IsKeyDown(KEY_W) - IsKeyDown(KEY_S));
bool crouching = IsKeyDown(KEY_LEFT_CONTROL);
UpdateBody(&player, lookRotation.x, sideway, forward, IsKeyPressed(KEY_SPACE), crouching);
float delta = GetFrameTime();
headLerp = Lerp(headLerp, (crouching ? CROUCH_HEIGHT : STAND_HEIGHT), 20.0f*delta);
camera.position = (Vector3){
player.position.x,
player.position.y + (BOTTOM_HEIGHT + headLerp),
player.position.z,
};
if (player.isGrounded && ((forward != 0) || (sideway != 0)))
{
headTimer += delta*3.0f;
walkLerp = Lerp(walkLerp, 1.0f, 10.0f*delta);
camera.fovy = Lerp(camera.fovy, 55.0f, 5.0f*delta);
}
else
{
walkLerp = Lerp(walkLerp, 0.0f, 10.0f*delta);
camera.fovy = Lerp(camera.fovy, 60.0f, 5.0f*delta);
}
lean.x = Lerp(lean.x, sideway*0.02f, 10.0f*delta);
lean.y = Lerp(lean.y, forward*0.015f, 10.0f*delta);
UpdateCameraAngle(&camera);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode3D(camera);
DrawLevel();
EndMode3D();
// Draw info box
DrawRectangle(5, 5, 330, 75, Fade(SKYBLUE, 0.5f));
DrawRectangleLines(5, 5, 330, 75, BLUE);
DrawText("Camera controls:", 15, 15, 10, BLACK);
DrawText("- Move keys: W, A, S, D, Space, Left-Ctrl", 15, 30, 10, BLACK);
DrawText("- Look around: arrow keys or mouse", 15, 45, 10, BLACK);
DrawText(TextFormat("- Velocity Len: (%06.3f)", Vector2Length((Vector2){ player.velocity.x, player.velocity.z })), 15, 60, 10, BLACK);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
//----------------------------------------------------------------------------------
// Module functions definition
//----------------------------------------------------------------------------------
void UpdateBody(Body* body, float rot, char side, char forward, bool jumpPressed, bool crouchHold)
{
Vector2 input = (Vector2){ (float)side, (float)-forward };
#if defined(NORMALIZE_INPUT)
// Slow down diagonal movement
if ((side != 0) && (forward != 0)) input = Vector2Normalize(input);
#endif
float delta = GetFrameTime();
if (!body->isGrounded) body->velocity.y -= GRAVITY*delta;
if (body->isGrounded && jumpPressed)
{
body->velocity.y = JUMP_FORCE;
body->isGrounded = false;
// Sound can be played at this moment
//SetSoundPitch(fxJump, 1.0f + (GetRandomValue(-100, 100)*0.001));
//PlaySound(fxJump);
}
Vector3 front = (Vector3){ sin(rot), 0.f, cos(rot) };
Vector3 right = (Vector3){ cos(-rot), 0.f, sin(-rot) };
Vector3 desiredDir = (Vector3){ input.x*right.x + input.y*front.x, 0.0f, input.x*right.z + input.y*front.z, };
body->dir = Vector3Lerp(body->dir, desiredDir, CONTROL*delta);
float decel = (body->isGrounded ? FRICTION : AIR_DRAG);
Vector3 hvel = (Vector3){ body->velocity.x*decel, 0.0f, body->velocity.z*decel };
float hvelLength = Vector3Length(hvel); // Magnitude
if (hvelLength < (MAX_SPEED*0.01f)) hvel = (Vector3){ 0 };
// This is what creates strafing
float speed = Vector3DotProduct(hvel, body->dir);
// Whenever the amount of acceleration to add is clamped by the maximum acceleration constant,
// a Player can make the speed faster by bringing the direction closer to horizontal velocity angle
// More info here: https://youtu.be/v3zT3Z5apaM?t=165
float maxSpeed = (crouchHold? CROUCH_SPEED : MAX_SPEED);
float accel = Clamp(maxSpeed - speed, 0.f, MAX_ACCEL*delta);
hvel.x += body->dir.x*accel;
hvel.z += body->dir.z*accel;
body->velocity.x = hvel.x;
body->velocity.z = hvel.z;
body->position.x += body->velocity.x*delta;
body->position.y += body->velocity.y*delta;
body->position.z += body->velocity.z*delta;
// Fancy collision system against the floor
if (body->position.y <= 0.0f)
{
body->position.y = 0.0f;
body->velocity.y = 0.0f;
body->isGrounded = true; // Enable jumping
}
}
// Update camera
static void UpdateCameraAngle(Camera *camera)
{
const Vector3 up = (Vector3){ 0.0f, 1.0f, 0.0f };
const Vector3 targetOffset = (Vector3){ 0.0f, 0.0f, -1.0f };
// Left and right
Vector3 yaw = Vector3RotateByAxisAngle(targetOffset, up, lookRotation.x);
// Clamp view up
float maxAngleUp = Vector3Angle(up, yaw);
maxAngleUp -= 0.001f; // Avoid numerical errors
if ( -(lookRotation.y) > maxAngleUp) { lookRotation.y = -maxAngleUp; }
// Clamp view down
float maxAngleDown = Vector3Angle(Vector3Negate(up), yaw);
maxAngleDown *= -1.0f; // Downwards angle is negative
maxAngleDown += 0.001f; // Avoid numerical errors
if ( -(lookRotation.y) < maxAngleDown) { lookRotation.y = -maxAngleDown; }
// Up and down
Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up));
// Rotate view vector around right axis
float pitchAngle = -lookRotation.y -
lean.y;
pitchAngle = Clamp(pitchAngle, -PI/2 + 0.0001f, PI/2 - 0.0001f); // Clamp angle so it doesn't go past straight up or straight down
Vector3 pitch = Vector3RotateByAxisAngle(yaw, right, pitchAngle);
// Head animation
// Rotate up direction around forward axis
float headSin = sin(headTimer*PI);
float headCos = cos(headTimer*PI);
const float stepRotation = 0.01f;
camera->up = Vector3RotateByAxisAngle(up, pitch, headSin*stepRotation + lean.x);
// Camera BOB
const float bobSide = 0.1f;
const float bobUp = 0.15f;
Vector3 bobbing = Vector3Scale(right, headSin*bobSide);
bobbing.y = fabsf(headCos*bobUp);
camera->position = Vector3Add(camera->position, Vector3Scale(bobbing, walkLerp));
camera->target = Vector3Add(camera->position, pitch);
}
// Draw game level
static void DrawLevel(void)
{
const int floorExtent = 25;
const float tileSize = 5.0f;
const Color tileColor1 = (Color){ 150, 200, 200, 255 };
// Floor tiles
for (int y = -floorExtent; y < floorExtent; y++)
{
for (int x = -floorExtent; x < floorExtent; x++)
{
if ((y & 1) && (x & 1))
{
DrawPlane((Vector3){ x*tileSize, 0.0f, y*tileSize}, (Vector2){ tileSize, tileSize }, tileColor1);
}
else if (!(y & 1) && !(x & 1))
{
DrawPlane((Vector3){ x*tileSize, 0.0f, y*tileSize}, (Vector2){ tileSize, tileSize }, LIGHTGRAY);
}
}
}
const Vector3 towerSize = (Vector3){ 16.0f, 32.0f, 16.0f };
const Color towerColor = (Color){ 150, 200, 200, 255 };
Vector3 towerPos = (Vector3){ 16.0f, 16.0f, 16.0f };
DrawCubeV(towerPos, towerSize, towerColor);
DrawCubeWiresV(towerPos, towerSize, DARKBLUE);
towerPos.x *= -1;
DrawCubeV(towerPos, towerSize, towerColor);
DrawCubeWiresV(towerPos, towerSize, DARKBLUE);
towerPos.z *= -1;
DrawCubeV(towerPos, towerSize, towerColor);
DrawCubeWiresV(towerPos, towerSize, DARKBLUE);
towerPos.x *= -1;
DrawCubeV(towerPos, towerSize, towerColor);
DrawCubeWiresV(towerPos, towerSize, DARKBLUE);
// Red sun
DrawSphere((Vector3){ 300.0f, 300.0f, 0.0f }, 100.0f, (Color){ 255, 0, 0, 255 });
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Initialize 3d camera free * raylib [core] example - 3d camera free
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Initialize 3d camera mode * raylib [core] example - 3d camera mode
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - 3d cmaera split screen * raylib [core] example - 3d camera split screen
* *
* Example complexity rating: [] 3/4 * Example complexity rating: [] 3/4
* *
@ -47,11 +47,11 @@ int main(void)
cameraPlayer2.position.x = -3.0f; cameraPlayer2.position.x = -3.0f;
cameraPlayer2.position.y = 3.0f; cameraPlayer2.position.y = 3.0f;
RenderTexture screenPlayer2 = LoadRenderTexture(screenWidth / 2, screenHeight); RenderTexture screenPlayer2 = LoadRenderTexture(screenWidth/2, screenHeight);
// Build a flipped rectangle the size of the split view to use for drawing later // Build a flipped rectangle the size of the split view to use for drawing later
Rectangle splitScreenRect = { 0.0f, 0.0f, (float)screenPlayer1.texture.width, (float)-screenPlayer1.texture.height }; Rectangle splitScreenRect = { 0.0f, 0.0f, (float)screenPlayer1.texture.width, (float)-screenPlayer1.texture.height };
// Grid data // Grid data
int count = 5; int count = 5;
float spacing = 4; float spacing = 4;
@ -98,9 +98,9 @@ int main(void)
// Draw Player1 view to the render texture // Draw Player1 view to the render texture
BeginTextureMode(screenPlayer1); BeginTextureMode(screenPlayer1);
ClearBackground(SKYBLUE); ClearBackground(SKYBLUE);
BeginMode3D(cameraPlayer1); BeginMode3D(cameraPlayer1);
// Draw scene: grid of cube trees on a plane to make a "world" // Draw scene: grid of cube trees on a plane to make a "world"
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 50, 50 }, BEIGE); // Simple world plane DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 50, 50 }, BEIGE); // Simple world plane
@ -116,20 +116,20 @@ int main(void)
// Draw a cube at each player's position // Draw a cube at each player's position
DrawCube(cameraPlayer1.position, 1, 1, 1, RED); DrawCube(cameraPlayer1.position, 1, 1, 1, RED);
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE); DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
EndMode3D(); EndMode3D();
DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f)); DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f));
DrawText("PLAYER1: W/S to move", 10, 10, 20, MAROON); DrawText("PLAYER1: W/S to move", 10, 10, 20, MAROON);
EndTextureMode(); EndTextureMode();
// Draw Player2 view to the render texture // Draw Player2 view to the render texture
BeginTextureMode(screenPlayer2); BeginTextureMode(screenPlayer2);
ClearBackground(SKYBLUE); ClearBackground(SKYBLUE);
BeginMode3D(cameraPlayer2); BeginMode3D(cameraPlayer2);
// Draw scene: grid of cube trees on a plane to make a "world" // Draw scene: grid of cube trees on a plane to make a "world"
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 50, 50 }, BEIGE); // Simple world plane DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 50, 50 }, BEIGE); // Simple world plane
@ -145,21 +145,21 @@ int main(void)
// Draw a cube at each player's position // Draw a cube at each player's position
DrawCube(cameraPlayer1.position, 1, 1, 1, RED); DrawCube(cameraPlayer1.position, 1, 1, 1, RED);
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE); DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
EndMode3D(); EndMode3D();
DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f)); DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f));
DrawText("PLAYER2: UP/DOWN to move", 10, 10, 20, DARKBLUE); DrawText("PLAYER2: UP/DOWN to move", 10, 10, 20, DARKBLUE);
EndTextureMode(); EndTextureMode();
// Draw both views render textures to the screen side by side // Draw both views render textures to the screen side by side
BeginDrawing(); BeginDrawing();
ClearBackground(BLACK); ClearBackground(BLACK);
DrawTextureRec(screenPlayer1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE); DrawTextureRec(screenPlayer1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
DrawTextureRec(screenPlayer2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE); DrawTextureRec(screenPlayer2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY); DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY);
EndDrawing(); EndDrawing();
} }

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Picking in 3d mode * raylib [core] example - 3d picking
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *
@ -101,7 +101,7 @@ int main(void)
DrawText("Try clicking on the box with your mouse!", 240, 10, 20, DARKGRAY); DrawText("Try clicking on the box with your mouse!", 240, 10, 20, DARKGRAY);
if (collision.hit) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, (int)(screenHeight * 0.1f), 30, GREEN); if (collision.hit) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30))/2, (int)(screenHeight*0.1f), 30, GREEN);
DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY); DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY);

View File

@ -54,7 +54,7 @@ int main(void)
player.position = (Vector2){ 400, 280 }; player.position = (Vector2){ 400, 280 };
player.speed = 0; player.speed = 0;
player.canJump = false; player.canJump = false;
// Define environment elements (platforms) // Define environment elements (platforms)
EnvElement envElements[MAX_ENVIRONMENT_ELEMENTS] = { EnvElement envElements[MAX_ENVIRONMENT_ELEMENTS] = {
{{ 0, 0, 1000, 400 }, 0, LIGHTGRAY }, {{ 0, 0, 1000, 400 }, 0, LIGHTGRAY },
@ -70,13 +70,13 @@ int main(void)
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f }; camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
camera.rotation = 0.0f; camera.rotation = 0.0f;
camera.zoom = 1.0f; camera.zoom = 1.0f;
// Automation events // Automation events
AutomationEventList aelist = LoadAutomationEventList(0); // Initialize list of automation events to record new events AutomationEventList aelist = LoadAutomationEventList(0); // Initialize list of automation events to record new events
SetAutomationEventList(&aelist); SetAutomationEventList(&aelist);
bool eventRecording = false; bool eventRecording = false;
bool eventPlaying = false; bool eventPlaying = false;
unsigned int frameCounter = 0; unsigned int frameCounter = 0;
unsigned int playFrameCounter = 0; unsigned int playFrameCounter = 0;
unsigned int currentPlayFrame = 0; unsigned int currentPlayFrame = 0;
@ -90,7 +90,7 @@ int main(void)
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
float deltaTime = 0.015f;//GetFrameTime(); float deltaTime = 0.015f;//GetFrameTime();
// Dropped files logic // Dropped files logic
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsFileDropped()) if (IsFileDropped())
@ -102,14 +102,14 @@ int main(void)
{ {
UnloadAutomationEventList(aelist); UnloadAutomationEventList(aelist);
aelist = LoadAutomationEventList(droppedFiles.paths[0]); aelist = LoadAutomationEventList(droppedFiles.paths[0]);
eventRecording = false; eventRecording = false;
// Reset scene state to play // Reset scene state to play
eventPlaying = true; eventPlaying = true;
playFrameCounter = 0; playFrameCounter = 0;
currentPlayFrame = 0; currentPlayFrame = 0;
player.position = (Vector2){ 400, 280 }; player.position = (Vector2){ 400, 280 };
player.speed = 0; player.speed = 0;
player.canJump = false; player.canJump = false;
@ -174,7 +174,7 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Events playing // Events playing
// NOTE: Logic must be before Camera update because it depends on mouse-wheel value, // NOTE: Logic must be before Camera update because it depends on mouse-wheel value,
// that can be set by the played event... but some other inputs could be affected // that can be set by the played event... but some other inputs could be affected
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (eventPlaying) if (eventPlaying)
@ -228,7 +228,7 @@ int main(void)
if (min.x > 0) camera.offset.x = screenWidth/2 - min.x; if (min.x > 0) camera.offset.x = screenWidth/2 - min.x;
if (min.y > 0) camera.offset.y = screenHeight/2 - min.y; if (min.y > 0) camera.offset.y = screenHeight/2 - min.y;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Events management // Events management
if (IsKeyPressed(KEY_S)) // Toggle events recording if (IsKeyPressed(KEY_S)) // Toggle events recording
{ {
@ -238,12 +238,12 @@ int main(void)
{ {
StopAutomationEventRecording(); StopAutomationEventRecording();
eventRecording = false; eventRecording = false;
ExportAutomationEventList(aelist, "automation.rae"); ExportAutomationEventList(aelist, "automation.rae");
TraceLog(LOG_INFO, "RECORDED FRAMES: %i", aelist.count); TraceLog(LOG_INFO, "RECORDED FRAMES: %i", aelist.count);
} }
else else
{ {
SetAutomationEventBaseFrame(180); SetAutomationEventBaseFrame(180);
StartAutomationEventRecording(); StartAutomationEventRecording();
@ -293,7 +293,7 @@ int main(void)
DrawRectangleRec((Rectangle){ player.position.x - 20, player.position.y - 40, 40, 40 }, RED); DrawRectangleRec((Rectangle){ player.position.x - 20, player.position.y - 40, 40, 40 }, RED);
EndMode2D(); EndMode2D();
// Draw game controls // Draw game controls
DrawRectangle(10, 10, 290, 145, Fade(SKYBLUE, 0.5f)); DrawRectangle(10, 10, 290, 145, Fade(SKYBLUE, 0.5f));
DrawRectangleLines(10, 10, 290, 145, Fade(BLUE, 0.8f)); DrawRectangleLines(10, 10, 290, 145, Fade(BLUE, 0.8f));
@ -323,7 +323,7 @@ int main(void)
if (((frameCounter/15)%2) == 1) DrawText(TextFormat("PLAYING RECORDED EVENTS... [%i]", currentPlayFrame), 50, 170, 10, DARKGREEN); if (((frameCounter/15)%2) == 1) DrawText(TextFormat("PLAYING RECORDED EVENTS... [%i]", currentPlayFrame), 50, 170, 10, DARKGREEN);
} }
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] examples - basic screen manager * raylib [core] example - basic screen manager
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Basic window * raylib [core] example - basic window
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Basic window (adapted for HTML5 platform) * raylib [core] example - basic window
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -12,7 +12,7 @@
* 4. PollInputEvents() * 4. PollInputEvents()
* *
* To avoid steps 2, 3 and 4, flag SUPPORT_CUSTOM_FRAME_CONTROL can be enabled in * To avoid steps 2, 3 and 4, flag SUPPORT_CUSTOM_FRAME_CONTROL can be enabled in
* config.h (it requires recompiling raylib). This way those steps are up to the user. * config.h (it requires recompiling raylib). This way those steps are up to the user
* *
* Note that enabling this flag invalidates some functions: * Note that enabling this flag invalidates some functions:
* - GetFrameTime() * - GetFrameTime()
@ -39,7 +39,7 @@ int main(void)
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - custom frame control"); InitWindow(screenWidth, screenHeight, "raylib [core] example - custom frame control");
// Custom timming variables // Custom timming variables
@ -48,11 +48,11 @@ int main(void)
double updateDrawTime = 0.0; // Update + Draw time double updateDrawTime = 0.0; // Update + Draw time
double waitTime = 0.0; // Wait time (if target fps required) double waitTime = 0.0; // Wait time (if target fps required)
float deltaTime = 0.0f; // Frame time (Update + Draw + Wait time) float deltaTime = 0.0f; // Frame time (Update + Draw + Wait time)
float timeCounter = 0.0f; // Accumulative time counter (seconds) float timeCounter = 0.0f; // Accumulative time counter (seconds)
float position = 0.0f; // Circle position float position = 0.0f; // Circle position
bool pause = false; // Pause control flag bool pause = false; // Pause control flag
int targetFPS = 60; // Our initial target fps int targetFPS = 60; // Our initial target fps
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -61,13 +61,15 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
PollInputEvents(); // Poll input events (SUPPORT_CUSTOM_FRAME_CONTROL) #ifndef PLATFORM_WEB // NOTE: On non web platforms the PollInputEvents just works before the inputs checks
PollInputEvents(); // Poll input events (SUPPORT_CUSTOM_FRAME_CONTROL)
#endif
if (IsKeyPressed(KEY_SPACE)) pause = !pause; if (IsKeyPressed(KEY_SPACE)) pause = !pause;
if (IsKeyPressed(KEY_UP)) targetFPS += 20; if (IsKeyPressed(KEY_UP)) targetFPS += 20;
else if (IsKeyPressed(KEY_DOWN)) targetFPS -= 20; else if (IsKeyPressed(KEY_DOWN)) targetFPS -= 20;
if (targetFPS < 0) targetFPS = 0; if (targetFPS < 0) targetFPS = 0;
if (!pause) if (!pause)
@ -76,6 +78,10 @@ int main(void)
if (position >= GetScreenWidth()) position = 0; if (position >= GetScreenWidth()) position = 0;
timeCounter += deltaTime; // We count time (seconds) timeCounter += deltaTime; // We count time (seconds)
} }
#ifdef PLATFORM_WEB // NOTE: On web platform for some reason the PollInputEvents only works after the inputs check, so just call it after check all your inputs (on web)
PollInputEvents(); // Poll input events (SUPPORT_CUSTOM_FRAME_CONTROL)
#endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -85,12 +91,12 @@ int main(void)
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
for (int i = 0; i < GetScreenWidth()/200; i++) DrawRectangle(200*i, 0, 1, GetScreenHeight(), SKYBLUE); for (int i = 0; i < GetScreenWidth()/200; i++) DrawRectangle(200*i, 0, 1, GetScreenHeight(), SKYBLUE);
DrawCircle((int)position, GetScreenHeight()/2 - 25, 50, RED); DrawCircle((int)position, GetScreenHeight()/2 - 25, 50, RED);
DrawText(TextFormat("%03.0f ms", timeCounter*1000.0f), (int)position - 40, GetScreenHeight()/2 - 100, 20, MAROON); DrawText(TextFormat("%03.0f ms", timeCounter*1000.0f), (int)position - 40, GetScreenHeight()/2 - 100, 20, MAROON);
DrawText(TextFormat("PosX: %03.0f", position), (int)position - 50, GetScreenHeight()/2 + 40, 20, BLACK); DrawText(TextFormat("PosX: %03.0f", position), (int)position - 50, GetScreenHeight()/2 + 40, 20, BLACK);
DrawText("Circle is moving at a constant 200 pixels/sec,\nindependently of the frame rate.", 10, 10, 20, DARKGRAY); DrawText("Circle is moving at a constant 200 pixels/sec,\nindependently of the frame rate.", 10, 10, 20, DARKGRAY);
DrawText("PRESS SPACE to PAUSE MOVEMENT", 10, GetScreenHeight() - 60, 20, GRAY); DrawText("PRESS SPACE to PAUSE MOVEMENT", 10, GetScreenHeight() - 60, 20, GRAY);
DrawText("PRESS UP | DOWN to CHANGE TARGET FPS", 10, GetScreenHeight() - 30, 20, GRAY); DrawText("PRESS UP | DOWN to CHANGE TARGET FPS", 10, GetScreenHeight() - 30, 20, GRAY);
@ -102,18 +108,18 @@ int main(void)
EndDrawing(); EndDrawing();
// NOTE: In case raylib is configured to SUPPORT_CUSTOM_FRAME_CONTROL, // NOTE: In case raylib is configured to SUPPORT_CUSTOM_FRAME_CONTROL,
// Events polling, screen buffer swap and frame time control must be managed by the user // Events polling, screen buffer swap and frame time control must be managed by the user
SwapScreenBuffer(); // Flip the back buffer to screen (front buffer) SwapScreenBuffer(); // Flip the back buffer to screen (front buffer)
currentTime = GetTime(); currentTime = GetTime();
updateDrawTime = currentTime - previousTime; updateDrawTime = currentTime - previousTime;
if (targetFPS > 0) // We want a fixed frame rate if (targetFPS > 0) // We want a fixed frame rate
{ {
waitTime = (1.0f/(float)targetFPS) - updateDrawTime; waitTime = (1.0f/(float)targetFPS) - updateDrawTime;
if (waitTime > 0.0) if (waitTime > 0.0)
{ {
WaitTime((float)waitTime); WaitTime((float)waitTime);
currentTime = GetTime(); currentTime = GetTime();

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Custom logging * raylib [core] example - custom logging
* *
* Example complexity rating: [] 3/4 * Example complexity rating: [] 3/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Windows drop files * raylib [core] example - drop files
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - HighDPI * raylib [core] example - high dpi
* *
* Example complexity rating: [] e/4 * Example complexity rating: [] e/4
* *
@ -13,12 +13,10 @@
#include "raylib.h" #include "raylib.h"
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color) //------------------------------------------------------------------------------------
{ // Module functions declaration
Vector2 size = MeasureTextEx(GetFontDefault(), text, (float)fontSize, 3); //------------------------------------------------------------------------------------
Vector2 pos = (Vector2){x - size.x/2, y - size.y/2 }; static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color);
DrawTextEx(GetFontDefault(), text, pos, (float)fontSize, 3, color);
}
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
@ -31,10 +29,20 @@ int main(void)
const int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_RESIZABLE); SetConfigFlags(FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_RESIZABLE);
InitWindow(screenWidth, screenHeight, "raylib [core] example - high dpi");
InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi");
SetWindowMinSize(450, 450); SetWindowMinSize(450, 450);
int logicalGridDescY = 120;
int logicalGridLabelY = logicalGridDescY + 30;
int logicalGridTop = logicalGridLabelY + 30;
int logicalGridBottom = logicalGridTop + 80;
int pixelGridTop = logicalGridBottom - 20;
int pixelGridBottom = pixelGridTop + 80;
int pixelGridLabelY = pixelGridBottom + 30;
int pixelGridDescY = pixelGridLabelY + 30;
int cellSize = 50;
float cellSizePx = (float)cellSize;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -44,67 +52,60 @@ int main(void)
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
int monitorCount = GetMonitorCount(); int monitorCount = GetMonitorCount();
if (monitorCount > 1 && IsKeyPressed(KEY_N)) {
SetWindowMonitor((GetCurrentMonitor() + 1) % monitorCount); if ((monitorCount > 1) && IsKeyPressed(KEY_N))
{
SetWindowMonitor((GetCurrentMonitor() + 1)%monitorCount);
} }
int currentMonitor = GetCurrentMonitor(); int currentMonitor = GetCurrentMonitor();
Vector2 dpiScale = GetWindowScaleDPI();
cellSizePx = ((float)cellSize)/dpiScale.x;
//----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
Vector2 dpiScale = GetWindowScaleDPI();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
int windowCenter = GetScreenWidth() / 2; int windowCenter = GetScreenWidth()/2;
DrawTextCenter(TextFormat("Dpi Scale: %f", dpiScale.x), windowCenter, 30, 40, DARKGRAY); DrawTextCenter(TextFormat("Dpi Scale: %f", dpiScale.x), windowCenter, 30, 40, DARKGRAY);
DrawTextCenter(TextFormat("Monitor: %d/%d ([N] next monitor)", currentMonitor+1, monitorCount), windowCenter, 70, 16, LIGHTGRAY); DrawTextCenter(TextFormat("Monitor: %d/%d ([N] next monitor)", currentMonitor+1, monitorCount), windowCenter, 70, 20, LIGHTGRAY);
const int logicalGridDescY = 120;
const int logicalGridLabelY = logicalGridDescY + 30;
const int logicalGridTop = logicalGridLabelY + 30;
const int logicalGridBottom = logicalGridTop + 80;
const int pixelGridTop = logicalGridBottom - 20;
const int pixelGridBottom = pixelGridTop + 80;
const int pixelGridLabelY = pixelGridBottom + 30;
const int pixelGridDescY = pixelGridLabelY + 30;
const int cellSize = 50;
const float cellSizePx = ((float)cellSize) / dpiScale.x;
DrawTextCenter(TextFormat("Window is %d \"logical points\" wide", GetScreenWidth()), windowCenter, logicalGridDescY, 20, ORANGE); DrawTextCenter(TextFormat("Window is %d \"logical points\" wide", GetScreenWidth()), windowCenter, logicalGridDescY, 20, ORANGE);
bool odd = true; bool odd = true;
for (int i = cellSize; i < GetScreenWidth(); i += cellSize, odd = !odd) { for (int i = cellSize; i < GetScreenWidth(); i += cellSize, odd = !odd)
if (odd) { {
DrawRectangle(i, logicalGridTop, cellSize, logicalGridBottom-logicalGridTop, ORANGE); if (odd) DrawRectangle(i, logicalGridTop, cellSize, logicalGridBottom-logicalGridTop, ORANGE);
}
DrawTextCenter(TextFormat("%d", i), i, logicalGridLabelY, 12, LIGHTGRAY); DrawTextCenter(TextFormat("%d", i), i, logicalGridLabelY, 10, LIGHTGRAY);
DrawLine(i, logicalGridLabelY + 10, i, logicalGridBottom, GRAY); DrawLine(i, logicalGridLabelY + 10, i, logicalGridBottom, GRAY);
} }
odd = true; odd = true;
const int minTextSpace = 30; const int minTextSpace = 30;
int last_text_x = -minTextSpace; int lastTextX = -minTextSpace;
for (int i = cellSize; i < GetRenderWidth(); i += cellSize, odd = !odd) { for (int i = cellSize; i < GetRenderWidth(); i += cellSize, odd = !odd)
int x = (int)(((float)i) / dpiScale.x); {
if (odd) { int x = (int)(((float)i)/dpiScale.x);
DrawRectangle(x, pixelGridTop, (int)cellSizePx, pixelGridBottom-pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 }); if (odd) DrawRectangle(x, pixelGridTop, (int)cellSizePx, pixelGridBottom - pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 });
}
DrawLine(x, pixelGridTop, (int)(((float)i) / dpiScale.x), pixelGridLabelY - 10, GRAY); DrawLine(x, pixelGridTop, (int)(((float)i)/dpiScale.x), pixelGridLabelY - 10, GRAY);
if (x - last_text_x >= minTextSpace) {
DrawTextCenter(TextFormat("%d", i), x, pixelGridLabelY, 12, LIGHTGRAY); if ((x - lastTextX) >= minTextSpace)
last_text_x = x; {
DrawTextCenter(TextFormat("%d", i), x, pixelGridLabelY, 10, LIGHTGRAY);
lastTextX = x;
} }
} }
DrawTextCenter(TextFormat("Window is %d \"physical pixels\" wide", GetRenderWidth()), windowCenter, pixelGridDescY, 20, BLUE); DrawTextCenter(TextFormat("Window is %d \"physical pixels\" wide", GetRenderWidth()), windowCenter, pixelGridDescY, 20, BLUE);
{ const char *text = "Can you see this?";
const char *text = "Can you see this?"; Vector2 size = MeasureTextEx(GetFontDefault(), text, 20, 3);
Vector2 size = MeasureTextEx(GetFontDefault(), text, 16, 3); Vector2 pos = (Vector2){ GetScreenWidth() - size.x - 5, GetScreenHeight() - size.y - 5 };
Vector2 pos = (Vector2){GetScreenWidth() - size.x - 5, GetScreenHeight() - size.y - 5}; DrawTextEx(GetFontDefault(), text, pos, 20, 3, LIGHTGRAY);
DrawTextEx(GetFontDefault(), text, pos, 16, 3, LIGHTGRAY);
}
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -117,3 +118,13 @@ int main(void)
return 0; return 0;
} }
//------------------------------------------------------------------------------------
// Module functions definition
//------------------------------------------------------------------------------------
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color)
{
Vector2 size = MeasureTextEx(GetFontDefault(), text, (float)fontSize, 3);
Vector2 pos = (Vector2){ x - size.x/2, y - size.y/2 };
DrawTextEx(GetFontDefault(), text, pos, (float)fontSize, 3, color);
}

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Gamepad input * raylib [core] example - gamepad input
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *
@ -256,11 +256,11 @@ int main(void)
} }
DrawText(TextFormat("DETECTED AXIS [%i]:", GetGamepadAxisCount(0)), 10, 50, 10, MAROON); DrawText(TextFormat("DETECTED AXIS [%i]:", GetGamepadAxisCount(gamepad)), 10, 50, 10, MAROON);
for (int i = 0; i < GetGamepadAxisCount(0); i++) for (int i = 0; i < GetGamepadAxisCount(gamepad); i++)
{ {
DrawText(TextFormat("AXIS %i: %.02f", i, GetGamepadAxisMovement(0, i)), 20, 70 + 20*i, 10, DARKGRAY); DrawText(TextFormat("AXIS %i: %.02f", i, GetGamepadAxisMovement(gamepad, i)), 20, 70 + 20*i, 10, DARKGRAY);
} }
if (GetGamepadButtonPressed() != GAMEPAD_BUTTON_UNKNOWN) DrawText(TextFormat("DETECTED BUTTON: %i", GetGamepadButtonPressed()), 10, 430, 10, RED); if (GetGamepadButtonPressed() != GAMEPAD_BUTTON_UNKNOWN) DrawText(TextFormat("DETECTED BUTTON: %i", GetGamepadButtonPressed()), 10, 430, 10, RED);

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Input Gestures Detection * raylib [core] example - input gestures
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Input Gestures for Web * raylib [core] example - input gestures web
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Keyboard input * raylib [core] example - keyboard input
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Mouse input * raylib [core] example - mouse input
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *
@ -29,7 +29,6 @@ int main(void)
Vector2 ballPosition = { -100.0f, -100.0f }; Vector2 ballPosition = { -100.0f, -100.0f };
Color ballColor = DARKBLUE; Color ballColor = DARKBLUE;
int isCursorHidden = 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
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
@ -41,18 +40,16 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_H)) if (IsKeyPressed(KEY_H))
{ {
if (isCursorHidden == 0) if (IsCursorHidden())
{ {
HideCursor(); ShowCursor();
isCursorHidden = 1;
} }
else else
{ {
ShowCursor(); HideCursor();
isCursorHidden = 0;
} }
} }
ballPosition = GetMousePosition(); ballPosition = GetMousePosition();
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) ballColor = MAROON; if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) ballColor = MAROON;
@ -75,7 +72,7 @@ int main(void)
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY); DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY);
DrawText("Press 'H' to toggle cursor visibility", 10, 30, 20, DARKGRAY); DrawText("Press 'H' to toggle cursor visibility", 10, 30, 20, DARKGRAY);
if (isCursorHidden == 1) DrawText("CURSOR HIDDEN", 20, 60, 20, RED); if (!IsCursorHidden()) DrawText("CURSOR HIDDEN", 20, 60, 20, RED);
else DrawText("CURSOR VISIBLE", 20, 60, 20, LIME); else DrawText("CURSOR VISIBLE", 20, 60, 20, LIME);
EndDrawing(); EndDrawing();

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] examples - Mouse wheel input * raylib [core] example - input mouse wheel
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Input multitouch * raylib [core] example - input multitouch
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *
@ -54,7 +54,7 @@ int main(void)
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
for (int i = 0; i < tCount; ++i) for (int i = 0; i < tCount; ++i)
{ {
// Make sure point is not (0, 0) as this means there is no touch for it // Make sure point is not (0, 0) as this means there is no touch for it

View File

@ -7,7 +7,7 @@
* Example originally created with raylib 5.0, last time updated with raylib 5.0 * Example originally created with raylib 5.0, last time updated with raylib 5.0
* *
* Example create by GreenSnakeLinux (@GreenSnakeLinux), * Example create by GreenSnakeLinux (@GreenSnakeLinux),
* lighter by oblerion (@oblerion) and * lighter by oblerion (@oblerion) and
* reviewed by Ramon Santamaria (@raysan5) and * reviewed by Ramon Santamaria (@raysan5) and
* improved by danilwhale (@danilwhale) * improved by danilwhale (@danilwhale)
* *

View File

@ -4,7 +4,7 @@
* *
* Example complexity rating: [] 3/4 * Example complexity rating: [] 3/4
* *
* NOTE: This example requires linking with pthreads library on MinGW, * NOTE: This example requires linking with pthreads library on MinGW,
* it can be accomplished passing -static parameter to compiler * it can be accomplished passing -static parameter to compiler
* *
* Example originally created with raylib 2.5, last time updated with raylib 3.0 * Example originally created with raylib 2.5, last time updated with raylib 3.0

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Generates a random sequence * raylib [core] example - generate random sequence
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *
@ -43,7 +43,7 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - Generates a random sequence"); InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random sequence");
int rectCount = 20; int rectCount = 20;
float rectSize = (float)screenWidth/rectCount; float rectSize = (float)screenWidth/rectCount;
@ -118,8 +118,8 @@ int main(void)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static Color GenerateRandomColor() static Color GenerateRandomColor()
{ {
Color color = { Color color = {
GetRandomValue(0, 255), GetRandomValue(0, 255),
GetRandomValue(0, 255), GetRandomValue(0, 255),
GetRandomValue(0, 255), GetRandomValue(0, 255),
255 255
@ -138,20 +138,20 @@ static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWid
for (int i = 0; i < rectCount; i++) for (int i = 0; i < rectCount; i++)
{ {
int rectHeight = (int)Remap((float)seq[i], 0, rectCount - 1, 0, screenHeight); int rectHeight = (int)Remap((float)seq[i], 0, rectCount - 1, 0, screenHeight);
rectangles[i].c = GenerateRandomColor(); rectangles[i].c = GenerateRandomColor();
rectangles[i].r = CLITERAL(Rectangle){ startX + i*rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight }; rectangles[i].r = CLITERAL(Rectangle){ startX + i*rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight };
} }
UnloadRandomSequence(seq); UnloadRandomSequence(seq);
return rectangles; return rectangles;
} }
static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount) static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount)
{ {
int *seq = LoadRandomSequence(rectCount, 0, rectCount - 1); int *seq = LoadRandomSequence(rectCount, 0, rectCount - 1);
for (int i1 = 0; i1 < rectCount; i1++) for (int i1 = 0; i1 < rectCount; i1++)
{ {
ColorRect *r1 = &rectangles[i1]; ColorRect *r1 = &rectangles[i1];
@ -166,16 +166,15 @@ static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount)
r2->r.height = tmp.r.height; r2->r.height = tmp.r.height;
r2->r.y = tmp.r.y; r2->r.y = tmp.r.y;
} }
UnloadRandomSequence(seq); UnloadRandomSequence(seq);
} }
static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, int posY, int fontSize, Color color) static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, int posY, int fontSize, Color color)
{ {
int spaceSize = MeasureText(" ", fontSize); int spaceSize = MeasureText(" ", fontSize);
int pressSize = MeasureText("Press", fontSize); int pressSize = MeasureText("Press", fontSize);
int keySize = MeasureText(key, fontSize); int keySize = MeasureText(key, fontSize);
int textSize = MeasureText(text, fontSize);
int textSizeCurrent = 0; int textSizeCurrent = 0;
DrawText("Press", posX, posY, fontSize, color); DrawText("Press", posX, posY, fontSize, color);
@ -184,4 +183,4 @@ static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, i
DrawRectangle(posX + textSizeCurrent, posY + fontSize, keySize, 3, RED); DrawRectangle(posX + textSizeCurrent, posY + fontSize, keySize, 3, RED);
textSizeCurrent += keySize + 2*spaceSize; textSizeCurrent += keySize + 2*spaceSize;
DrawText(text, posX + textSizeCurrent, posY, fontSize, color); DrawText(text, posX + textSizeCurrent, posY, fontSize, color);
} }

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Generate random values * raylib [core] example - generate random values
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *
@ -30,9 +30,9 @@ int main(void)
// SetRandomSeed(0xaabbccff); // Set a custom random seed if desired, by default: "time(NULL)" // 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)
unsigned int framesCounter = 0; // Variable used to count frames unsigned int framesCounter = 0; // Variable used to count frames
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Scissor test * raylib [core] example - scissor test
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *

View File

@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Smooth Pixel-perfect camera * raylib [core] example - smooth pixel-perfect camera
* *
* Example complexity rating: [] 3/4 * Example complexity rating: [] 3/4
* *
* Example originally created with raylib 3.7, last time updated with raylib 4.0 * Example originally created with raylib 3.7, last time updated with raylib 4.0
* *
* Example contributed by Giancamillo Alessandroni (@NotManyIdeasDev) and * Example contributed by Giancamillo Alessandroni (@NotManyIdeasDev) and
* reviewed by Ramon Santamaria (@raysan5) * reviewed by Ramon Santamaria (@raysan5)
* *
@ -43,7 +43,8 @@ int main(void)
Camera2D screenSpaceCamera = { 0 }; // Smoothing camera Camera2D screenSpaceCamera = { 0 }; // Smoothing camera
screenSpaceCamera.zoom = 1.0f; screenSpaceCamera.zoom = 1.0f;
RenderTexture2D target = LoadRenderTexture(virtualScreenWidth, virtualScreenHeight); // This is where we'll draw all our objects. // Load render texture to draw all our objects
RenderTexture2D target = LoadRenderTexture(virtualScreenWidth, virtualScreenHeight);
Rectangle rec01 = { 70.0f, 35.0f, 20.0f, 20.0f }; Rectangle rec01 = { 70.0f, 35.0f, 20.0f, 20.0f };
Rectangle rec02 = { 90.0f, 55.0f, 30.0f, 10.0f }; Rectangle rec02 = { 90.0f, 55.0f, 30.0f, 10.0f };

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Storage save/load values * raylib [core] example - storage save/load values
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - VR Simulator (Oculus Rift CV1 parameters) * raylib [core] example - vr simulator
* *
* Example complexity rating: [] 3/4 * Example complexity rating: [] 3/4
* *
@ -61,7 +61,7 @@ int main(void)
VrStereoConfig config = LoadVrStereoConfig(device); VrStereoConfig config = LoadVrStereoConfig(device);
// Distortion shader (uses device lens distortion and chroma) // Distortion shader (uses device lens distortion and chroma)
Shader distortion = LoadShader(0, TextFormat("resources/distortion%i.fs", GLSL_VERSION)); Shader distortion = LoadShader(0, TextFormat("resources/shaders/glsl%i/distortion.fs", GLSL_VERSION));
// Update distortion shader with lens and distortion-scale parameters // Update distortion shader with lens and distortion-scale parameters
SetShaderValue(distortion, GetShaderLocation(distortion, "leftLensCenter"), SetShaderValue(distortion, GetShaderLocation(distortion, "leftLensCenter"),
@ -127,7 +127,7 @@ int main(void)
EndMode3D(); EndMode3D();
EndVrStereoMode(); EndVrStereoMode();
EndTextureMode(); EndTextureMode();
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
BeginShaderMode(distortion); BeginShaderMode(distortion);

View File

@ -46,7 +46,7 @@ int main(void)
//SetConfigFlags(FLAG_VSYNC_HINT | FLAG_MSAA_4X_HINT | FLAG_WINDOW_HIGHDPI); //SetConfigFlags(FLAG_VSYNC_HINT | FLAG_MSAA_4X_HINT | FLAG_WINDOW_HIGHDPI);
InitWindow(screenWidth, screenHeight, "raylib [core] example - window flags"); InitWindow(screenWidth, screenHeight, "raylib [core] example - window flags");
Vector2 ballPosition = { GetScreenWidth() / 2.0f, GetScreenHeight() / 2.0f }; Vector2 ballPosition = { GetScreenWidth()/2.0f, GetScreenHeight()/2.0f };
Vector2 ballSpeed = { 5.0f, 4.0f }; Vector2 ballSpeed = { 5.0f, 4.0f };
float ballRadius = 20; float ballRadius = 20;

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - window scale letterbox (and virtual mouse) * raylib [core] example - window scale letterbox
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *
@ -27,12 +27,12 @@
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
int main(void) int main(void)
{ {
const int windowWidth = 800; const int screenWidth = 800;
const int windowHeight = 450; const int screenHeight = 450;
// Enable config flags for resizable window and vertical synchro // Enable config flags for resizable window and vertical synchro
SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT); SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT);
InitWindow(windowWidth, windowHeight, "raylib [core] example - window scale letterbox"); InitWindow(screenWidth, screenHeight, "raylib [core] example - window scale letterbox");
SetWindowMinSize(320, 240); SetWindowMinSize(320, 240);
int gameScreenWidth = 640; int gameScreenWidth = 640;
@ -86,7 +86,7 @@ int main(void)
DrawText(TextFormat("Default Mouse: [%i , %i]", (int)mouse.x, (int)mouse.y), 350, 25, 20, GREEN); DrawText(TextFormat("Default Mouse: [%i , %i]", (int)mouse.x, (int)mouse.y), 350, 25, 20, GREEN);
DrawText(TextFormat("Virtual Mouse: [%i , %i]", (int)virtualMouse.x, (int)virtualMouse.y), 350, 55, 20, YELLOW); DrawText(TextFormat("Virtual Mouse: [%i , %i]", (int)virtualMouse.x, (int)virtualMouse.y), 350, 55, 20, YELLOW);
EndTextureMode(); EndTextureMode();
BeginDrawing(); BeginDrawing();
ClearBackground(BLACK); // Clear screen background ClearBackground(BLACK); // Clear screen background

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Window should close * raylib [core] example - window should close
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *
@ -26,9 +26,9 @@ int main()
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - window should close"); InitWindow(screenWidth, screenHeight, "raylib [core] example - window should close");
SetExitKey(KEY_NULL); // Disable KEY_ESCAPE to close window, X-button still works SetExitKey(KEY_NULL); // Disable KEY_ESCAPE to close window, X-button still works
bool exitWindowRequested = false; // Flag to request window to exit bool exitWindowRequested = false; // Flag to request window to exit
bool exitWindow = false; // Flag to set window to exit bool exitWindow = false; // Flag to set window to exit
@ -42,12 +42,12 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Detect if X-button or KEY_ESCAPE have been pressed to close window // Detect if X-button or KEY_ESCAPE have been pressed to close window
if (WindowShouldClose() || IsKeyPressed(KEY_ESCAPE)) exitWindowRequested = true; if (WindowShouldClose() || IsKeyPressed(KEY_ESCAPE)) exitWindowRequested = true;
if (exitWindowRequested) if (exitWindowRequested)
{ {
// A request for close window has been issued, we can save data before closing // A request for close window has been issued, we can save data before closing
// or just show a message asking for confirmation // or just show a message asking for confirmation
if (IsKeyPressed(KEY_Y)) exitWindow = true; if (IsKeyPressed(KEY_Y)) exitWindow = true;
else if (IsKeyPressed(KEY_N)) exitWindowRequested = false; else if (IsKeyPressed(KEY_N)) exitWindowRequested = false;
} }

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - World to screen * raylib [core] example - core world screen
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *
@ -69,8 +69,8 @@ int main(void)
EndMode3D(); EndMode3D();
DrawText("Enemy: 100 / 100", (int)cubeScreenPosition.x - MeasureText("Enemy: 100/100", 20)/2, (int)cubeScreenPosition.y, 20, BLACK); DrawText("Enemy: 100/100", (int)cubeScreenPosition.x - MeasureText("Enemy: 100/100", 20)/2, (int)cubeScreenPosition.y, 20, BLACK);
DrawText(TextFormat("Cube position in screen space coordinates: [%i, %i]", (int)cubeScreenPosition.x, (int)cubeScreenPosition.y), 10, 10, 20, LIME); DrawText(TextFormat("Cube position in screen space coordinates: [%i, %i]", (int)cubeScreenPosition.x, (int)cubeScreenPosition.y), 10, 10, 20, LIME);
DrawText("Text 2d should be always on top of the cube", 10, 40, 20, GRAY); DrawText("Text 2d should be always on top of the cube", 10, 40, 20, GRAY);
@ -84,4 +84,4 @@ int main(void)
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

@ -0,0 +1,50 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add your custom variables here
uniform vec2 leftLensCenter;
uniform vec2 rightLensCenter;
uniform vec2 leftScreenCenter;
uniform vec2 rightScreenCenter;
uniform vec2 scale;
uniform vec2 scaleIn;
uniform vec4 deviceWarpParam;
uniform vec4 chromaAbParam;
void main()
{
// Compute lens distortion
vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter;
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
float rSq = theta.x*theta.x + theta.y*theta.y;
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 tcBlue = lensCenter + scale*thetaBlue;
if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue)))
{
// Set black fragment for everything outside the lens border
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
}
else
{
// Compute color chroma aberration
float blue = texture2D(texture0, tcBlue).b;
vec2 tcGreen = lensCenter + scale*theta1;
float green = texture2D(texture0, tcGreen).g;
vec2 thetaRed = theta1*(chromaAbParam.x + chromaAbParam.y*rSq);
vec2 tcRed = lensCenter + scale*thetaRed;
float red = texture2D(texture0, tcRed).r;
gl_FragColor = vec4(red, green, blue, 1.0);
}
}

171
examples/examples_list.txt Normal file
View File

@ -0,0 +1,171 @@
#
# raylib examples list used to generate/update collection
# examples must be provided as: <example_category>;<example_name>;<example_stars>;<raylib_created_version>;<raylib_last_update_version>;"<example_author_name>";<author_github_user>
#
# This list is used as the main reference by [rexm] tool for examples collection validation and management
# New examples must be added to this list and any possible rename must be made on this list first
#
# WARNING: List is not ordered by example name but by the display order on web
#
core;core_basic_window;⭐️☆☆☆;1.0;1.0;"Ramon Santamaria";@raysan5
core;core_input_keys;⭐️☆☆☆;1.0;1.0;"Ramon Santamaria";@raysan5
core;core_input_mouse;⭐️☆☆☆;1.0;5.5;"Ramon Santamaria";@raysan5
core;core_input_mouse_wheel;⭐️☆☆☆;1.1;1.3;"Ramon Santamaria";@raysan5
core;core_input_gamepad;⭐️☆☆☆;1.1;4.2;"Ramon Santamaria";@raysan5
core;core_input_multitouch;⭐️☆☆☆;2.1;2.5;"Berni";@Berni8k
core;core_input_gestures;⭐️⭐️☆☆;1.4;4.2;"Ramon Santamaria";@raysan5
core;core_input_virtual_controls;⭐️⭐️☆☆;5.0;5.0;"oblerion";@oblerion
core;core_2d_camera;⭐️⭐️☆☆;1.5;3.0;"Ramon Santamaria";@raysan5
core;core_2d_camera_mouse_zoom;⭐️⭐️☆☆;4.2;4.2;"Jeffery Myers";@JeffM2501
core;core_2d_camera_platformer;⭐️⭐️⭐️☆;2.5;3.0;"arvyy";@arvyy
core;core_2d_camera_split_screen;⭐️⭐️⭐️⭐️;4.5;4.5;"Gabriel dos Santos Sanches";@gabrielssanches
core;core_3d_camera_mode;⭐️☆☆☆;1.0;1.0;"Ramon Santamaria";@raysan5
core;core_3d_camera_free;⭐️☆☆☆;1.3;1.3;"Ramon Santamaria";@raysan5
core;core_3d_camera_first_person;⭐️⭐️☆☆;1.3;1.3;"Ramon Santamaria";@raysan5
core;core_3d_camera_split_screen;⭐️⭐️⭐️☆;3.7;4.0;"Jeffery Myers";@JeffM2501
core;core_3d_camera_fps;⭐️⭐️⭐️☆;5.5;5.5;"Agnis Aldins";@nezvers
core;core_3d_picking;⭐️⭐️☆☆;1.3;4.0;"Ramon Santamaria";@raysan5
core;core_world_screen;⭐️⭐️☆☆;1.3;1.4;"Ramon Santamaria";@raysan5
core;core_custom_logging;⭐️⭐️⭐️☆;2.5;2.5;"Pablo Marcos Oltra";@pamarcos
core;core_window_flags;⭐️⭐️⭐️☆;3.5;3.5;"Ramon Santamaria";@raysan5
core;core_window_letterbox;⭐️⭐️☆☆;2.5;4.0;"Anata";@anatagawa
core;core_window_should_close;⭐️☆☆☆;4.2;4.2;"Ramon Santamaria";@raysan5
core;core_drop_files;⭐️⭐️☆☆;1.3;4.2;"Ramon Santamaria";@raysan5
core;core_random_values;⭐️☆☆☆;1.1;1.1;"Ramon Santamaria";@raysan5
core;core_storage_values;⭐️⭐️☆☆;1.4;4.2;"Ramon Santamaria";@raysan5
core;core_vr_simulator;⭐️⭐️⭐️☆;2.5;4.0;"Ramon Santamaria";@raysan5
core;core_loading_thread;⭐️⭐️⭐️☆;2.5;3.0;"Ramon Santamaria";@raysan5
core;core_scissor_test;⭐️☆☆☆;2.5;3.0;"Chris Dill";@MysteriousSpace
core;core_basic_screen_manager;⭐️☆☆☆;4.0;4.0;"Ramon Santamaria";@raysan5
core;core_custom_frame_control;⭐️⭐️⭐️⭐️;4.0;4.0;"Ramon Santamaria";@raysan5
core;core_smooth_pixelperfect;⭐️⭐️⭐️☆;3.7;4.0;"Giancamillo Alessandroni";@NotManyIdeasDev
core;core_random_sequence;⭐️☆☆☆;5.0;5.0;"Dalton Overmyer";@REDl3east
core;core_basic_window_web;⭐️☆☆☆;1.3;1.3;"Ramon Santamaria";@raysan5
core;core_input_gestures_web;⭐️⭐️☆☆;4.6-dev;4.6-dev;"ubkp";@ubkp
core;core_automation_events;⭐️⭐️⭐️☆;5.0;5.0;"Ramon Santamaria";@raysan5
core;core_high_dpi;⭐️☆☆☆;5.0;5.0;"Jonathan Marler";@marler8997
shapes;shapes_basic_shapes;⭐️☆☆☆;1.0;4.2;"Ramon Santamaria";@raysan5
shapes;shapes_bouncing_ball;⭐️☆☆☆;2.5;2.5;"Ramon Santamaria";@raysan5
shapes;shapes_colors_palette;⭐️⭐️☆☆;1.0;2.5;"Ramon Santamaria";@raysan5
shapes;shapes_logo_raylib;⭐️☆☆☆;1.0;1.0;"Ramon Santamaria";@raysan5
shapes;shapes_logo_raylib_anim;⭐️⭐️☆☆;2.5;4.0;"Ramon Santamaria";@raysan5
shapes;shapes_rectangle_scaling;⭐️⭐️☆☆;2.5;2.5;"Vlad Adrian";@demizdor
shapes;shapes_lines_bezier;⭐️☆☆☆;1.7;1.7;"Ramon Santamaria";@raysan5
shapes;shapes_collision_area;⭐️⭐️☆☆;2.5;2.5;"Ramon Santamaria";@raysan5
shapes;shapes_following_eyes;⭐️⭐️☆☆;2.5;2.5;"Ramon Santamaria";@raysan5
shapes;shapes_easings_ball_anim;⭐️⭐️☆☆;2.5;2.5;"Ramon Santamaria";@raysan5
shapes;shapes_easings_box_anim;⭐️⭐️☆☆;2.5;2.5;"Ramon Santamaria";@raysan5
shapes;shapes_easings_rectangle_array;⭐️⭐️⭐️☆;2.0;2.5;"Ramon Santamaria";@raysan5
shapes;shapes_draw_ring;⭐️⭐️⭐️☆;2.5;2.5;"Vlad Adrian";@demizdor
shapes;shapes_draw_circle_sector;⭐️⭐️⭐️☆;2.5;2.5;"Vlad Adrian";@demizdor
shapes;shapes_draw_rectangle_rounded;⭐️⭐️⭐️☆;2.5;2.5;"Vlad Adrian";@demizdor
shapes;shapes_top_down_lights;⭐️⭐️⭐️⭐️;4.2;4.2;"Jeffery Myers";@JeffM2501
shapes;shapes_rectangle_advanced;⭐️⭐️⭐️⭐️;5.5;5.5;"Everton Jr.";@evertonse
shapes;shapes_splines_drawing;⭐️⭐️⭐️☆;5.0;5.0;"Ramon Santamaria";@raysan5
shapes;shapes_digital_clock;⭐️⭐️☆☆;5.5;5.5;"Hamza RAHAL";@rhmz-rhl
shapes;shapes_double_pendulum;⭐️⭐️☆☆;5.5;5.5;"JoeCheong";@Joecheong2006
textures;textures_logo_raylib;⭐️☆☆☆;1.0;1.0;"Ramon Santamaria";@raysan5
textures;textures_srcrec_dstrec;⭐️⭐️⭐️☆;1.3;1.3;"Ramon Santamaria";@raysan5
textures;textures_image_drawing;⭐️⭐️☆☆;1.4;1.4;"Ramon Santamaria";@raysan5
textures;textures_image_generation;⭐️⭐️☆☆;1.8;1.8;"Wilhem Barbier";@nounoursheureux
textures;textures_image_loading;⭐️☆☆☆;1.3;1.3;"Ramon Santamaria";@raysan5
textures;textures_image_processing;⭐️⭐️⭐️☆;1.4;3.5;"Ramon Santamaria";@raysan5
textures;textures_image_text;⭐️⭐️☆☆;1.8;4.0;"Ramon Santamaria";@raysan5
textures;textures_to_image;⭐️☆☆☆;1.3;4.0;"Ramon Santamaria";@raysan5
textures;textures_raw_data;⭐️⭐️⭐️☆;1.3;3.5;"Ramon Santamaria";@raysan5
textures;textures_particles_blending;⭐️☆☆☆;1.7;3.5;"Ramon Santamaria";@raysan5
textures;textures_npatch_drawing;⭐️⭐️⭐️☆;2.0;2.5;"Jorge A. Gomes";@overdev
textures;textures_background_scrolling;⭐️☆☆☆;2.0;2.5;"Ramon Santamaria";@raysan5
textures;textures_sprite_anim;⭐️⭐️☆☆;1.3;1.3;"Ramon Santamaria";@raysan5
textures;textures_sprite_button;⭐️⭐️☆☆;2.5;2.5;"Ramon Santamaria";@raysan5
textures;textures_sprite_explosion;⭐️⭐️☆☆;2.5;3.5;"Ramon Santamaria";@raysan5
textures;textures_bunnymark;⭐️⭐️⭐️☆;1.6;2.5;"Ramon Santamaria";@raysan5
textures;textures_mouse_painting;⭐️⭐️⭐️☆;3.0;3.0;"Chris Dill";@MysteriousSpace
textures;textures_blend_modes;⭐️☆☆☆;3.5;3.5;"Karlo Licudine";@accidentalrebel
textures;textures_draw_tiled;⭐️⭐️⭐️☆;3.0;4.2;"Vlad Adrian";@demizdor
textures;textures_polygon;⭐️☆☆☆;3.7;3.7;"Chris Camacho";@chriscamacho
textures;textures_fog_of_war;⭐️⭐️⭐️☆;4.2;4.2;"Ramon Santamaria";@raysan5
textures;textures_gif_player;⭐️⭐️⭐️☆;4.2;4.2;"Ramon Santamaria";@raysan5
textures;textures_image_kernel;⭐️⭐️⭐️⭐️;1.3;1.3;"Karim Salem";@kimo-s
textures;textures_image_channel;⭐️⭐️☆☆;5.1-dev;5.1-dev;"Bruno Cabral";@brccabral
textures;textures_image_rotate;⭐️⭐️☆☆;1.0;1.0;"Ramon Santamaria";@raysan5
textures;textures_textured_curve;⭐️⭐️⭐️☆;4.5;4.5;"Jeffery Myers";@JeffM2501
text;text_raylib_fonts;⭐️☆☆☆;1.7;3.7;"Ramon Santamaria";@raysan5
text;text_font_spritefont;⭐️☆☆☆;1.0;1.0;"Ramon Santamaria";@raysan5
text;text_font_filters;⭐️⭐️☆☆;1.3;4.2;"Ramon Santamaria";@raysan5
text;text_font_loading;⭐️☆☆☆;1.4;3.0;"Ramon Santamaria";@raysan5
text;text_font_sdf;⭐️⭐️⭐️☆;1.3;4.0;"Ramon Santamaria";@raysan5
text;text_format_text;⭐️☆☆☆;1.1;3.0;"Ramon Santamaria";@raysan5
text;text_input_box;⭐️⭐️☆☆;1.7;3.5;"Ramon Santamaria";@raysan5
text;text_writing_anim;⭐️⭐️☆☆;1.4;1.4;"Ramon Santamaria";@raysan5
text;text_rectangle_bounds;⭐️⭐️⭐️⭐️;2.5;4.0;"Vlad Adrian";@demizdor
text;text_unicode;⭐️⭐️⭐️⭐️;2.5;4.0;"Vlad Adrian";@demizdor
text;text_draw_3d;⭐️⭐️⭐️⭐️;3.5;4.0;"Vlad Adrian";@demizdor
text;text_codepoints_loading;⭐️⭐️⭐️☆;4.2;4.2;"Ramon Santamaria";@raysan5
models;models_animation;⭐️⭐️☆☆;2.5;3.5;"Culacant";@culacant
models;models_billboard;⭐️⭐️⭐️☆;1.3;3.5;"Ramon Santamaria";@raysan5
models;models_box_collisions;⭐️☆☆☆;1.3;3.5;"Ramon Santamaria";@raysan5
models;models_cubicmap;⭐️⭐️☆☆;1.8;3.5;"Ramon Santamaria";@raysan5
models;models_first_person_maze;⭐️⭐️☆☆;2.5;3.5;"Ramon Santamaria";@raysan5
models;models_geometric_shapes;⭐️☆☆☆;1.0;3.5;"Ramon Santamaria";@raysan5
models;models_mesh_generation;⭐️⭐️☆☆;1.8;4.0;"Ramon Santamaria";@raysan5
models;models_mesh_picking;⭐️⭐️⭐️☆;1.7;4.0;"Joel Davis";@joeld42
models;models_loading;⭐️☆☆☆;2.0;4.2;"Ramon Santamaria";@raysan5
models;models_loading_gltf;⭐️☆☆☆;3.7;4.2;"Ramon Santamaria";@raysan5
models;models_loading_vox;⭐️☆☆☆;4.0;4.0;"Johann Nadalutti";@procfxgen
models;models_loading_m3d;⭐️⭐️☆☆;4.5;4.5;"bzt";@model3d
models;models_orthographic_projection;⭐️☆☆☆;2.0;3.7;"Max Danielsson";@autious
models;models_point_rendering;⭐️⭐️⭐️☆;5.0;5.0;"Reese Gallagher";@satchelfrost
models;models_rlgl_solar_system;⭐️⭐️⭐️⭐️;2.5;4.0;"Ramon Santamaria";@raysan5
models;models_yaw_pitch_roll;⭐️⭐️☆☆;1.8;4.0;"Berni";@Berni8k
models;models_waving_cubes;⭐️⭐️⭐️☆;2.5;3.7;"Codecat";@codecat
models;models_heightmap;⭐️☆☆☆;1.8;3.5;"Ramon Santamaria";@raysan5
models;models_skybox;⭐️⭐️☆☆;1.8;4.0;"Ramon Santamaria";@raysan5
models;models_draw_cube_texture;⭐️⭐️☆☆;4.5;4.5;"Ramon Santamaria";@raysan5
models;models_gpu_skinning;⭐️⭐️⭐️☆;4.5;4.5;"Daniel Holden";@orangeduck
models;models_bone_socket;⭐️⭐️⭐️⭐️;4.5;4.5;"iP";@ipzaur
models;models_tesseract_view;⭐️⭐️☆☆;5.6-dev;5.6-dev;"Timothy van der Valk";@arceryz
shaders;shaders_basic_lighting;⭐️⭐️⭐️⭐️;3.0;4.2;"Chris Camacho";@chriscamacho
shaders;shaders_model_shader;⭐️⭐️☆☆;1.3;3.7;"Ramon Santamaria";@raysan5
shaders;shaders_shapes_textures;⭐️⭐️☆☆;1.7;3.7;"Ramon Santamaria";@raysan5
shaders;shaders_custom_uniform;⭐️⭐️☆☆;1.3;4.0;"Ramon Santamaria";@raysan5
shaders;shaders_postprocessing;⭐️⭐️⭐️☆;1.3;4.0;"Ramon Santamaria";@raysan5
shaders;shaders_palette_switch;⭐️⭐️⭐️☆;2.5;3.7;"Marco Lizza";@MarcoLizza
shaders;shaders_raymarching;⭐️⭐️⭐️⭐️;2.0;4.2;"Ramon Santamaria";@raysan5
shaders;shaders_texture_drawing;⭐️⭐️☆☆;2.0;3.7;"Michał Ciesielski";@ciessielski
shaders;shaders_texture_outline;⭐️⭐️⭐️☆;4.0;4.0;"Samuel Skiff";@GoldenThumbs
shaders;shaders_texture_waves;⭐️⭐️☆☆;2.5;3.7;"Anata";@anatagawa
shaders;shaders_julia_set;⭐️⭐️⭐️☆;2.5;4.0;"Josh Colclough";@joshcol9232
shaders;shaders_eratosthenes;⭐️⭐️⭐️☆;2.5;4.0;"ProfJski";@ProfJski
shaders;shaders_fog;⭐️⭐️⭐️☆;2.5;3.7;"Chris Camacho";@chriscamacho
shaders;shaders_simple_mask;⭐️⭐️☆☆;2.5;3.7;"Chris Camacho";@chriscamacho
shaders;shaders_hot_reloading;⭐️⭐️⭐️☆;3.0;3.5;"Ramon Santamaria";@raysan5
shaders;shaders_mesh_instancing;⭐️⭐️⭐️⭐️;3.7;4.2;"seanpringle";@seanpringle
shaders;shaders_multi_sample2d;⭐️⭐️☆☆;3.5;3.5;"Ramon Santamaria";@raysan5
shaders;shaders_normal_map;⭐️⭐️⭐️⭐️;5.6;5.6;"Jeremy Montgomery";@Sir_Irk
shaders;shaders_spotlight;⭐️⭐️☆☆;2.5;3.7;"Chris Camacho";@chriscamacho
shaders;shaders_deferred_render;⭐️⭐️⭐️⭐️;4.5;4.5;"Justin Andreas Lacoste";@27justin
shaders;shaders_hybrid_render;⭐️⭐️⭐️⭐️;4.2;4.2;"Buğra Alptekin Sarı";@BugraAlptekinSari
shaders;shaders_texture_tiling;⭐️⭐️☆☆;4.5;4.5;"Luis Almeida";@luis605
shaders;shaders_shadowmap;⭐️⭐️⭐️⭐️;5.0;5.0;"TheManTheMythTheGameDev";@TheManTheMythTheGameDev
shaders;shaders_vertex_displacement;⭐️⭐️⭐️☆;5.0;4.5;"Alex ZH";@ZzzhHe
shaders;shaders_write_depth;⭐️⭐️☆☆;4.2;4.2;"Buğra Alptekin Sarı";@BugraAlptekinSari
shaders;shaders_basic_pbr;⭐️⭐️⭐️⭐️;5.0;5.1-dev;"Afan OLOVCIC";@_DevDad
shaders;shaders_lightmap;⭐️⭐️⭐️☆;4.5;4.5;"Jussi Viitala";@nullstare
shaders;shaders_rounded_rectangle;⭐️⭐️⭐️☆;5.5;5.5;"Anstro Pleuton";@anstropleuton
shaders;shaders_view_depth;⭐️⭐️⭐️☆;5.6-dev;5.6-dev;"Luís Almeida";@luis605
audio;audio_module_playing;⭐️☆☆☆;1.5;3.5;"Ramon Santamaria";@raysan5
audio;audio_music_stream;⭐️☆☆☆;1.3;4.2;"Ramon Santamaria";@raysan5
audio;audio_raw_stream;⭐️⭐️⭐️☆;1.6;4.2;"Ramon Santamaria";@raysan5
audio;audio_sound_loading;⭐️☆☆☆;1.1;3.5;"Ramon Santamaria";@raysan5
audio;audio_mixed_processor;⭐️⭐️⭐️⭐️;4.2;4.2;"hkc";@hatkidchan
audio;audio_stream_effects;⭐️⭐️⭐️⭐️;4.2;5.0;"Ramon Santamaria";@raysan5
audio;audio_sound_multi;⭐️⭐️☆☆;4.6;4.6;"Jeffery Myers";@JeffM2501
audio;audio_sound_positioning;⭐️⭐️☆☆;5.5;5.5;"Le Juez Victor";@Bigfoot71
others;rlgl_standalone;⭐️⭐️⭐️⭐️;1.6;4.0;"Ramon Santamaria";@raysan5
others;rlgl_compute_shader;⭐️⭐️⭐️⭐️;4.0;4.0;"Teddy Astie";@tsnake41
others;easings_testbed;⭐️⭐️⭐️☆;2.5;3.0;"Juan Miguel López";@flashback-fx
others;raylib_opengl_interop;⭐️⭐️⭐️⭐️;3.8;4.0;"Stephan Soller";@arkanis
others;embedded_files_loading;⭐️⭐️☆☆;3.0;3.5;"Kristian Holmgren";@defutura
others;raymath_vector_angle;⭐️⭐️☆☆;1.0;4.6;"Ramon Santamaria";@raysan5
text;text_unicode_ranges;⭐⭐⭐⭐️;2.5;4.0;"Vlad Adrian";@demizdor

View File

@ -6,30 +6,30 @@
1. File naming: <module>_<description> - Lower case filename, words separated by underscore, 1. File naming: <module>_<description> - Lower case filename, words separated by underscore,
no more than 3-4 words in total to describe the example. <module> referes to the primary no more than 3-4 words in total to describe the example. <module> referes to the primary
raylib module the example is more related with (code, shapes, textures, models, shaders, raudio). raylib module the example is more related with (code, shapes, textures, models, shaders, raudio)
i.e: core_input_multitouch, shapes_lines_bezier, shaders_palette_switch i.e: core_input_multitouch, shapes_lines_bezier, shaders_palette_switch
2. Follow below template structure, example info should list the module, the short description 2. Follow below template structure, example info should list the module, the short description
and the author of the example, twitter or github info could be also provided for the author. and the author of the example, twitter or github info could be also provided for the author
Short description should also be used on the title of the window. Short description should also be used on the title of the window
3. Code should be organized by sections:[Initialization]- [Update] - [Draw] - [De-Initialization] 3. Code should be organized by sections:[Initialization]- [Update] - [Draw] - [De-Initialization]
Place your code between the dotted lines for every section, please don't mix update logic with drawing Place your code between the dotted lines for every section, please don't mix update logic with drawing
and remember to unload all loaded resources. and remember to unload all loaded resources
4. Code should follow raylib conventions: https://github.com/raysan5/raylib/wiki/raylib-coding-conventions 4. Code should follow raylib conventions: https://github.com/raysan5/raylib/wiki/raylib-coding-conventions
Try to be very organized, using line-breaks appropiately. Try to be very organized, using line-breaks appropiately
5. Add comments to the specific parts of code the example is focus on. 5. Add comments to the specific parts of code the example is focus on
Don't abuse with comments, try to be clear and impersonal on the comments. Don't abuse with comments, try to be clear and impersonal on the comments
6. Try to keep the example simple, under 300 code lines if possible. Try to avoid external dependencies. 6. Try to keep the example simple, under 300 code lines if possible. Try to avoid external dependencies
Try to avoid defining functions outside the main(). Example should be as self-contained as possible. Try to avoid defining functions outside the main(). Example should be as self-contained as possible
7. About external resources, they should be placed in a [resources] folder and those resources 7. About external resources, they should be placed in a [resources] folder and those resources
should be open and free for use and distribution. Avoid propietary content. should be open and free for use and distribution. Avoid propietary content
8. Try to keep the example simple but with a creative touch. 8. Try to keep the example simple but with a creative touch
Simple but beautiful examples are more appealing to users! Simple but beautiful examples are more appealing to users!
9. In case of additional information is required, just come to raylib Discord channel: example-contributions 9. In case of additional information is required, just come to raylib Discord channel: example-contributions
@ -37,11 +37,11 @@
10. Have fun! 10. Have fun!
The following files should be updated when adding a new example, it's planned to create some The following files should be updated when adding a new example, it's planned to create some
script to automatize this process but not available yet. script to automatize this process but not available yet
- raylib/examples/<category>/<category>_example_name.c - raylib/examples/<category>/<category>_example_name.c
- raylib/examples/<category>/<category>_example_name.png - raylib/examples/<category>/<category>_example_name.png
- raylib/examples/<category>/resources/*.* - raylib/examples/<category>/resources/..
- raylib/examples/Makefile - raylib/examples/Makefile
- raylib/examples/Makefile.Web - raylib/examples/Makefile.Web
- raylib/examples/README.md - raylib/examples/README.md
@ -56,18 +56,18 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [<module>] example - <name> * raylib [<module>] example - <name/short description>
* *
* Example complexity rating: [??] ?/4 * Example complexity rating: [] 1/4
* *
* Example originally created with raylib 5.5, last time updated with raylib 5.5 * Example originally created with raylib 5.5, last time updated with raylib 5.6
* *
* Example contributed by <user_name> (@<user_github>) and reviewed by Ramon Santamaria (@raysan5) * Example contributed by <author_name> (@<user_github>) and reviewed by Ramon Santamaria (@raysan5)
* *
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software * BSD-like license that allows static linking with closed source software
* *
* Copyright (c) <year_created>-<year_updated> <user_name> (@<user_github>) * Copyright (c) <year_created>-<year_updated> <author_name> (@<user_github>)
* *
********************************************************************************************/ ********************************************************************************************/
@ -104,9 +104,11 @@ int main(void)
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
// TODO: Draw everything that requires to be drawn at this point: // TODO: Draw everything that requires to be drawn at this point
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); // Example DrawLineEx((Vector2){ 0, 0 }, (Vector2){ screenWidth, screenHeight }, 2.0f, RED);
DrawLineEx((Vector2){ 0, screenHeight }, (Vector2){ screenWidth, 0 }, 2.0f, RED);
DrawText("example base code template", 260, 400, 20, LIGHTGRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Load 3d model with animations and play them * raylib [models] example - model animation
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *
@ -15,9 +15,9 @@
* *
******************************************************************************************** ********************************************************************************************
* *
* NOTE: To export a model from blender, make sure it is not posed, the vertices need to be * 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 and the scale of your models is * in the same position as they would be in edit mode and the scale of your models is
* set to 0. Scaling can be done from the export menu. * set to 0. Scaling can be done from the export menu
* *
********************************************************************************************/ ********************************************************************************************/

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Drawing billboards * raylib [models] example - billboard render
* *
* Example complexity rating: [] 3/4 * Example complexity rating: [] 3/4
* *
@ -26,7 +26,7 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards"); InitWindow(screenWidth, screenHeight, "raylib [models] example - billboard render");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = { 0 }; Camera camera = { 0 };
@ -40,7 +40,7 @@ int main(void)
Vector3 billPositionStatic = { 0.0f, 2.0f, 0.0f }; // Position of static billboard Vector3 billPositionStatic = { 0.0f, 2.0f, 0.0f }; // Position of static billboard
Vector3 billPositionRotating = { 1.0f, 2.0f, 1.0f }; // Position of rotating billboard Vector3 billPositionRotating = { 1.0f, 2.0f, 1.0f }; // Position of rotating billboard
// Entire billboard texture, source is used to take a segment from a larger texture. // Entire billboard texture, source is used to take a segment from a larger texture
Rectangle source = { 0.0f, 0.0f, (float)bill.width, (float)bill.height }; Rectangle source = { 0.0f, 0.0f, (float)bill.width, (float)bill.height };
// NOTE: Billboard locked on axis-Y // NOTE: Billboard locked on axis-Y
@ -54,7 +54,7 @@ int main(void)
Vector2 origin = Vector2Scale(size, 0.5f); Vector2 origin = Vector2Scale(size, 0.5f);
// Distance is needed for the correct billboard draw order // Distance is needed for the correct billboard draw order
// Larger distance (further away from the camera) should be drawn prior to smaller distance. // Larger distance (further away from the camera) should be drawn prior to smaller distance
float distanceStatic; float distanceStatic;
float distanceRotating; float distanceRotating;
float rotation = 0.0f; float rotation = 0.0f;
@ -85,17 +85,17 @@ int main(void)
DrawGrid(10, 1.0f); // Draw a grid DrawGrid(10, 1.0f); // Draw a grid
// Draw order matters! // Draw order matters!
if (distanceStatic > distanceRotating) if (distanceStatic > distanceRotating)
{ {
DrawBillboard(camera, bill, billPositionStatic, 2.0f, WHITE); DrawBillboard(camera, bill, billPositionStatic, 2.0f, WHITE);
DrawBillboardPro(camera, bill, source, billPositionRotating, billUp, size, origin, rotation, WHITE); DrawBillboardPro(camera, bill, source, billPositionRotating, billUp, size, origin, rotation, WHITE);
} }
else else
{ {
DrawBillboardPro(camera, bill, source, billPositionRotating, billUp, size, origin, rotation, WHITE); DrawBillboardPro(camera, bill, source, billPositionRotating, billUp, size, origin, rotation, WHITE);
DrawBillboard(camera, bill, billPositionStatic, 2.0f, WHITE); DrawBillboard(camera, bill, billPositionStatic, 2.0f, WHITE);
} }
EndMode3D(); EndMode3D();
DrawFPS(10, 10); DrawFPS(10, 10);

View File

@ -1,9 +1,9 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Using bones as socket for calculating the positioning of something * raylib [models] example - bone socket
* *
* Example complexity rating: [] 4/4 * Example complexity rating: [] 4/4
* *
* Example originally created with raylib 4.5, last time updated with raylib 4.5 * Example originally created with raylib 4.5, last time updated with raylib 4.5
* *
* Example contributed by iP (@ipzaur) and reviewed by Ramon Santamaria (@raysan5) * Example contributed by iP (@ipzaur) and reviewed by Ramon Santamaria (@raysan5)
@ -51,7 +51,7 @@ int main(void)
LoadModel("resources/models/gltf/greenman_sword.glb"), // Index for the sword model is the same as BONE_SOCKET_HAND_R LoadModel("resources/models/gltf/greenman_sword.glb"), // Index for the sword model is the same as BONE_SOCKET_HAND_R
LoadModel("resources/models/gltf/greenman_shield.glb") // Index for the shield model is the same as BONE_SOCKET_HAND_L LoadModel("resources/models/gltf/greenman_shield.glb") // Index for the shield model is the same as BONE_SOCKET_HAND_L
}; };
bool showEquip[3] = { true, true, true }; // Toggle on/off equip bool showEquip[3] = { true, true, true }; // Toggle on/off equip
// Load gltf model animations // Load gltf model animations
@ -63,7 +63,7 @@ int main(void)
// indices of bones for sockets // indices of bones for sockets
int boneSocketIndex[BONE_SOCKETS] = { -1, -1, -1 }; int boneSocketIndex[BONE_SOCKETS] = { -1, -1, -1 };
// search bones for sockets // search bones for sockets
for (int i = 0; i < characterModel.boneCount; i++) for (int i = 0; i < characterModel.boneCount; i++)
{ {
if (TextIsEqual(characterModel.bones[i].name, "socket_hat")) if (TextIsEqual(characterModel.bones[i].name, "socket_hat"))
@ -71,13 +71,13 @@ int main(void)
boneSocketIndex[BONE_SOCKET_HAT] = i; boneSocketIndex[BONE_SOCKET_HAT] = i;
continue; continue;
} }
if (TextIsEqual(characterModel.bones[i].name, "socket_hand_R")) if (TextIsEqual(characterModel.bones[i].name, "socket_hand_R"))
{ {
boneSocketIndex[BONE_SOCKET_HAND_R] = i; boneSocketIndex[BONE_SOCKET_HAND_R] = i;
continue; continue;
} }
if (TextIsEqual(characterModel.bones[i].name, "socket_hand_L")) if (TextIsEqual(characterModel.bones[i].name, "socket_hand_L"))
{ {
boneSocketIndex[BONE_SOCKET_HAND_L] = i; boneSocketIndex[BONE_SOCKET_HAND_L] = i;
@ -99,7 +99,7 @@ int main(void)
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera, CAMERA_THIRD_PERSON); UpdateCamera(&camera, CAMERA_THIRD_PERSON);
// Rotate character // Rotate character
if (IsKeyDown(KEY_F)) angle = (angle + 1)%360; if (IsKeyDown(KEY_F)) angle = (angle + 1)%360;
else if (IsKeyDown(KEY_H)) angle = (360 + angle - 1)%360; else if (IsKeyDown(KEY_H)) angle = (360 + angle - 1)%360;
@ -112,7 +112,7 @@ int main(void)
if (IsKeyPressed(KEY_ONE)) showEquip[BONE_SOCKET_HAT] = !showEquip[BONE_SOCKET_HAT]; if (IsKeyPressed(KEY_ONE)) showEquip[BONE_SOCKET_HAT] = !showEquip[BONE_SOCKET_HAT];
if (IsKeyPressed(KEY_TWO)) showEquip[BONE_SOCKET_HAND_R] = !showEquip[BONE_SOCKET_HAND_R]; if (IsKeyPressed(KEY_TWO)) showEquip[BONE_SOCKET_HAND_R] = !showEquip[BONE_SOCKET_HAND_R];
if (IsKeyPressed(KEY_THREE)) showEquip[BONE_SOCKET_HAND_L] = !showEquip[BONE_SOCKET_HAND_L]; if (IsKeyPressed(KEY_THREE)) showEquip[BONE_SOCKET_HAND_L] = !showEquip[BONE_SOCKET_HAND_L];
// Update model animation // Update model animation
ModelAnimation anim = modelAnimations[animIndex]; ModelAnimation anim = modelAnimations[animIndex];
animCurrentFrame = (animCurrentFrame + 1)%anim.frameCount; animCurrentFrame = (animCurrentFrame + 1)%anim.frameCount;
@ -140,7 +140,7 @@ int main(void)
Transform *transform = &anim.framePoses[animCurrentFrame][boneSocketIndex[i]]; Transform *transform = &anim.framePoses[animCurrentFrame][boneSocketIndex[i]];
Quaternion inRotation = characterModel.bindPose[boneSocketIndex[i]].rotation; Quaternion inRotation = characterModel.bindPose[boneSocketIndex[i]].rotation;
Quaternion outRotation = transform->rotation; Quaternion outRotation = transform->rotation;
// Calculate socket rotation (angle between bone in initial pose and same bone in current animation frame) // Calculate socket rotation (angle between bone in initial pose and same bone in current animation frame)
Quaternion rotate = QuaternionMultiply(outRotation, QuaternionInvert(inRotation)); Quaternion rotate = QuaternionMultiply(outRotation, QuaternionInvert(inRotation));
Matrix matrixTransform = QuaternionToMatrix(rotate); Matrix matrixTransform = QuaternionToMatrix(rotate);
@ -148,7 +148,7 @@ int main(void)
matrixTransform = MatrixMultiply(matrixTransform, MatrixTranslate(transform->translation.x, transform->translation.y, transform->translation.z)); matrixTransform = MatrixMultiply(matrixTransform, MatrixTranslate(transform->translation.x, transform->translation.y, transform->translation.z));
// Transform the socket using the transform of the character (angle and translate) // Transform the socket using the transform of the character (angle and translate)
matrixTransform = MatrixMultiply(matrixTransform, characterModel.transform); matrixTransform = MatrixMultiply(matrixTransform, characterModel.transform);
// Draw mesh at socket position with socket angle rotation // Draw mesh at socket position with socket angle rotation
DrawMesh(equipModel[i].meshes[0], equipModel[i].materials[1], matrixTransform); DrawMesh(equipModel[i].meshes[0], equipModel[i].materials[1], matrixTransform);
} }
@ -168,7 +168,7 @@ int main(void)
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadModelAnimations(modelAnimations, animsCount); UnloadModelAnimations(modelAnimations, animsCount);
UnloadModel(characterModel); // Unload character model and meshes/material UnloadModel(characterModel); // Unload character model and meshes/material
// Unload equipment model and meshes/material // Unload equipment model and meshes/material
for (int i = 0; i < BONE_SOCKETS; i++) UnloadModel(equipModel[i]); for (int i = 0; i < BONE_SOCKETS; i++) UnloadModel(equipModel[i]);

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Detect basic 3d collisions (box vs sphere vs box) * raylib [models] example - box collisions
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Cubicmap loading and drawing * raylib [models] example - cubicmap loading and drawing
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *
@ -25,7 +25,7 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing"); InitWindow(screenWidth, screenHeight, "raylib [models] example - cubicmap loading and drawing");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = { 0 }; Camera camera = { 0 };

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Draw textured cube * raylib [models] example - draw cube texture
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *
@ -42,7 +42,7 @@ int main(void)
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.fovy = 45.0f; camera.fovy = 45.0f;
camera.projection = CAMERA_PERSPECTIVE; camera.projection = CAMERA_PERSPECTIVE;
// Load texture to be applied to the cubes sides // Load texture to be applied to the cubes sides
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); Texture2D texture = LoadTexture("resources/cubicmap_atlas.png");
@ -69,7 +69,7 @@ int main(void)
DrawCubeTexture(texture, (Vector3){ -2.0f, 2.0f, 0.0f }, 2.0f, 4.0f, 2.0f, WHITE); DrawCubeTexture(texture, (Vector3){ -2.0f, 2.0f, 0.0f }, 2.0f, 4.0f, 2.0f, WHITE);
// Draw cube with an applied texture, but only a defined rectangle piece of the texture // Draw cube with an applied texture, but only a defined rectangle piece of the texture
DrawCubeTextureRec(texture, (Rectangle){ 0.0f, texture.height/2.0f, texture.width/2.0f, texture.height/2.0f }, DrawCubeTextureRec(texture, (Rectangle){ 0.0f, texture.height/2.0f, texture.width/2.0f, texture.height/2.0f },
(Vector3){ 2.0f, 1.0f, 0.0f }, 2.0f, 2.0f, 2.0f, WHITE); (Vector3){ 2.0f, 1.0f, 0.0f }, 2.0f, 2.0f, 2.0f, WHITE);
DrawGrid(10, 1.0f); // Draw a grid DrawGrid(10, 1.0f); // Draw a grid
@ -85,7 +85,7 @@ int main(void)
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(texture); // Unload texture UnloadTexture(texture); // Unload texture
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -171,7 +171,7 @@ void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, f
rlSetTexture(texture.id); rlSetTexture(texture.id);
// We calculate the normalized texture coordinates for the desired texture-source-rectangle // We calculate the normalized texture coordinates for the desired texture-source-rectangle
// It means converting from (tex.width, tex.height) coordinates to [0.0f, 1.0f] equivalent // It means converting from (tex.width, tex.height) coordinates to [0.0f, 1.0f] equivalent
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Draw some basic geometric shapes (cube, sphere, cylinder...) * raylib [models] example - geometric shapes
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *

View File

@ -1,9 +1,9 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Doing skinning on the gpu using a vertex shader * raylib [models] example - gpu skinning
* *
* Example complexity rating: [] 3/4 * Example complexity rating: [] 3/4
* *
* Example originally created with raylib 4.5, last time updated with raylib 4.5 * Example originally created with raylib 4.5, last time updated with raylib 4.5
* *
* Example contributed by Daniel Holden (@orangeduck) and reviewed by Ramon Santamaria (@raysan5) * Example contributed by Daniel Holden (@orangeduck) and reviewed by Ramon Santamaria (@raysan5)
@ -12,7 +12,7 @@
* BSD-like license that allows static linking with closed source software * BSD-like license that allows static linking with closed source software
* *
* Copyright (c) 2024-2025 Daniel Holden (@orangeduck) * Copyright (c) 2024-2025 Daniel Holden (@orangeduck)
* *
* Note: Due to limitations in the Apple OpenGL driver, this feature does not work on MacOS * Note: Due to limitations in the Apple OpenGL driver, this feature does not work on MacOS
* *
********************************************************************************************/ ********************************************************************************************/
@ -37,7 +37,7 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - GPU skinning"); InitWindow(screenWidth, screenHeight, "raylib [models] example - gpu skinning");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = { 0 }; Camera camera = { 0 };
@ -49,13 +49,13 @@ int main(void)
// Load gltf model // Load gltf model
Model characterModel = LoadModel("resources/models/gltf/greenman.glb"); // Load character model Model characterModel = LoadModel("resources/models/gltf/greenman.glb"); // Load character model
// Load skinning shader // Load skinning shader
Shader skinningShader = LoadShader(TextFormat("resources/shaders/glsl%i/skinning.vs", GLSL_VERSION), Shader skinningShader = LoadShader(TextFormat("resources/shaders/glsl%i/skinning.vs", GLSL_VERSION),
TextFormat("resources/shaders/glsl%i/skinning.fs", GLSL_VERSION)); TextFormat("resources/shaders/glsl%i/skinning.fs", GLSL_VERSION));
characterModel.materials[1].shader = skinningShader; characterModel.materials[1].shader = skinningShader;
// Load gltf model animations // Load gltf model animations
int animsCount = 0; int animsCount = 0;
unsigned int animIndex = 0; unsigned int animIndex = 0;
@ -75,7 +75,7 @@ int main(void)
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera, CAMERA_THIRD_PERSON); UpdateCamera(&camera, CAMERA_THIRD_PERSON);
// Select current animation // Select current animation
if (IsKeyPressed(KEY_T)) animIndex = (animIndex + 1)%animsCount; if (IsKeyPressed(KEY_T)) animIndex = (animIndex + 1)%animsCount;
else if (IsKeyPressed(KEY_G)) animIndex = (animIndex + animsCount - 1)%animsCount; else if (IsKeyPressed(KEY_G)) animIndex = (animIndex + animsCount - 1)%animsCount;
@ -94,12 +94,12 @@ int main(void)
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
BeginMode3D(camera); BeginMode3D(camera);
// Draw character mesh, pose calculation is done in shader (GPU skinning) // Draw character mesh, pose calculation is done in shader (GPU skinning)
DrawMesh(characterModel.meshes[0], characterModel.materials[1], characterModel.transform); DrawMesh(characterModel.meshes[0], characterModel.materials[1], characterModel.transform);
DrawGrid(10, 1.0f); DrawGrid(10, 1.0f);
EndMode3D(); EndMode3D();
DrawText("Use the T/G to switch animation", 10, 10, 20, GRAY); DrawText("Use the T/G to switch animation", 10, 10, 20, GRAY);
@ -113,7 +113,7 @@ int main(void)
UnloadModelAnimations(modelAnimations, animsCount); // Unload model animation UnloadModelAnimations(modelAnimations, animsCount); // Unload model animation
UnloadModel(characterModel); // Unload model and meshes/material UnloadModel(characterModel); // Unload model and meshes/material
UnloadShader(skinningShader); // Unload GPU skinning shader UnloadShader(skinningShader); // Unload GPU skinning shader
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Heightmap loading and drawing * raylib [models] example - heightmap terrain
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *
@ -25,7 +25,7 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing"); InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap terrain");
// Define our custom camera to look into our 3d world // Define our custom camera to look into our 3d world
Camera camera = { 0 }; Camera camera = { 0 };

View File

@ -1,17 +1,17 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Models loading * raylib [models] example - models loading
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *
* NOTE: raylib supports multiple models file formats: * NOTE: raylib supports multiple models file formats:
* *
* - OBJ > Text file format. 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 > 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. Includes 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: * - VOX > Binary file format. MagikaVoxel mesh format:
* https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox.txt * https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox.txt
* - M3D > Binary file format. Model 3D format: * - M3D > Binary file format. Model 3D format:

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - loading gltf with animations * raylib [models] example - loading gltf animations
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *
@ -45,7 +45,7 @@ int main(void)
// Load gltf model // Load gltf model
Model model = LoadModel("resources/models/gltf/robot.glb"); Model model = LoadModel("resources/models/gltf/robot.glb");
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
// Load gltf model animations // Load gltf model animations
int animsCount = 0; int animsCount = 0;
unsigned int animIndex = 0; unsigned int animIndex = 0;

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Load models M3D * raylib [models] example - model loading m3d
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *
@ -31,7 +31,7 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - M3D model loading"); InitWindow(screenWidth, screenHeight, "raylib [models] example - model loading m3d");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = { 0 }; Camera camera = { 0 };
@ -119,7 +119,7 @@ int main(void)
// without a -1, we would always draw a cube at the origin // without a -1, we would always draw a cube at the origin
for (int i = 0; i < model.boneCount - 1; i++) for (int i = 0; i < model.boneCount - 1; i++)
{ {
// By default the model is loaded in bind-pose by LoadModel(). // By default the model is loaded in bind-pose by LoadModel()
// But if UpdateModelAnimation() has been called at least once // But if UpdateModelAnimation() has been called at least once
// then the model is already in animation pose, so we need the animated skeleton // then the model is already in animation pose, so we need the animated skeleton
if (!animPlaying || !animsCount) if (!animPlaying || !animsCount)

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Load models vox (MagicaVoxel) * raylib [models] example - magicavoxel loading
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *
@ -40,7 +40,7 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
const char* voxFileNames[] = { const char *voxFileNames[] = {
"resources/models/vox/chr_knight.vox", "resources/models/vox/chr_knight.vox",
"resources/models/vox/chr_sword.vox", "resources/models/vox/chr_sword.vox",
"resources/models/vox/monu9.vox", "resources/models/vox/monu9.vox",
@ -57,24 +57,23 @@ 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 projection type camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
//--------------------------------------------------------------------------------------
// Load MagicaVoxel files // Load MagicaVoxel files
Model models[MAX_VOX_FILES] = { 0 }; Model models[MAX_VOX_FILES] = { 0 };
for (int i = 0; i < MAX_VOX_FILES; i++) for (int i = 0; i < MAX_VOX_FILES; i++)
{ {
// Load VOX file and measure time // Load VOX file and measure time
double t0 = GetTime() * 1000.0; double t0 = GetTime()*1000.0;
models[i] = LoadModel(voxFileNames[i]); models[i] = LoadModel(voxFileNames[i]);
double t1 = GetTime() * 1000.0; double t1 = GetTime()*1000.0;
TraceLog(LOG_WARNING, TextFormat("[%s] File loaded in %.3f ms", voxFileNames[i], t1 - t0)); 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) // Compute model translation matrix to center model on draw position (0, 0 , 0)
BoundingBox bb = GetModelBoundingBox(models[i]); BoundingBox bb = GetModelBoundingBox(models[i]);
Vector3 center = { 0 }; Vector3 center = { 0 };
center.x = bb.min.x + (((bb.max.x - bb.min.x) / 2)); center.x = bb.min.x + (((bb.max.x - bb.min.x)/2));
center.z = bb.min.z + (((bb.max.z - bb.min.z) / 2)); center.z = bb.min.z + (((bb.max.z - bb.min.z)/2));
Matrix matTranslate = MatrixTranslate(-center.x, 0, -center.z); Matrix matTranslate = MatrixTranslate(-center.x, 0, -center.z);
models[i].transform = matTranslate; models[i].transform = matTranslate;
@ -82,14 +81,13 @@ int main(void)
int currentModel = 0; int currentModel = 0;
//--------------------------------------------------------------------------------------
// Load voxel shader // Load voxel shader
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/voxel_lighting.vs", GLSL_VERSION), Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/voxel_lighting.vs", GLSL_VERSION),
TextFormat("resources/shaders/glsl%i/voxel_lighting.fs", GLSL_VERSION)); TextFormat("resources/shaders/glsl%i/voxel_lighting.fs", GLSL_VERSION));
// Get some required shader locations // Get some required shader locations
shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos"); shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
// NOTE: "matModel" location name is automatically assigned on shader loading, // NOTE: "matModel" location name is automatically assigned on shader loading,
// no need to get the location again if using that uniform name // no need to get the location again if using that uniform name
//shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel"); //shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel");
@ -129,8 +127,8 @@ int main(void)
if (IsMouseButtonDown(MOUSE_BUTTON_MIDDLE)) if (IsMouseButtonDown(MOUSE_BUTTON_MIDDLE))
{ {
const Vector2 mouseDelta = GetMouseDelta(); const Vector2 mouseDelta = GetMouseDelta();
camerarot.x = mouseDelta.x * 0.05f; camerarot.x = mouseDelta.x*0.05f;
camerarot.y = mouseDelta.y * 0.05f; camerarot.y = mouseDelta.y*0.05f;
} }
else else
{ {
@ -140,14 +138,14 @@ int main(void)
UpdateCameraPro(&camera, UpdateCameraPro(&camera,
(Vector3) { (Vector3) {
(IsKeyDown(KEY_W) || IsKeyDown(KEY_UP)) * 0.1f - // Move forward-backward (IsKeyDown(KEY_W) || IsKeyDown(KEY_UP))*0.1f - // Move forward-backward
(IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN)) * 0.1f, (IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN))*0.1f,
(IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT)) * 0.1f - // Move right-left (IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT))*0.1f - // Move right-left
(IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT)) * 0.1f, (IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT))*0.1f,
0.0f // Move up-down 0.0f // Move up-down
}, },
camerarot, camerarot,
GetMouseWheelMove() * -2.0f); // Move to target (zoom) GetMouseWheelMove()*-2.0f); // Move to target (zoom)
// Cycle between models on mouse click // Cycle between models on mouse click
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) currentModel = (currentModel + 1) % MAX_VOX_FILES; if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) currentModel = (currentModel + 1) % MAX_VOX_FILES;

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - procedural mesh generation * raylib [models] example - mesh generation
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *
@ -47,17 +47,8 @@ int main(void)
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(GenMeshCustom()); models[8] = LoadModelFromMesh(GenMeshCustom());
// Generated meshes could be exported as .obj files // NOTE: Generated meshes could be exported using ExportMesh()
//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;

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Mesh picking in 3d mode, ground plane, triangle, mesh * raylib [models] example - mesh picking
* *
* Example complexity rating: [] 3/4 * Example complexity rating: [] 3/4
* *
@ -18,6 +18,7 @@
#include "raylib.h" #include "raylib.h"
#include "raymath.h" #include "raymath.h"
#undef FLT_MAX
#define FLT_MAX 340282346638528859811704183484516925440.0f // Maximum value of a float, from bit pattern 01111111011111111111111111111111 #define FLT_MAX 340282346638528859811704183484516925440.0f // Maximum value of a float, from bit pattern 01111111011111111111111111111111
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
@ -84,7 +85,7 @@ int main(void)
// Display information about closest hit // Display information about closest hit
RayCollision collision = { 0 }; RayCollision collision = { 0 };
char *hitObjectName = "None"; const char *hitObjectName = "None";
collision.distance = FLT_MAX; collision.distance = FLT_MAX;
collision.hit = false; collision.hit = false;
Color cursorColor = WHITE; Color cursorColor = WHITE;
@ -137,7 +138,7 @@ int main(void)
RayCollision meshHitInfo = { 0 }; RayCollision meshHitInfo = { 0 };
for (int m = 0; m < tower.meshCount; m++) for (int m = 0; m < tower.meshCount; m++)
{ {
// NOTE: We consider the model.transform for the collision check but // NOTE: We consider the model.transform for the collision check but
// it can be checked against any transform Matrix, used when checking against same // it can be checked against any transform Matrix, used when checking against same
// model drawn multiple times with multiple transforms // model drawn multiple times with multiple transforms
meshHitInfo = GetRayCollisionMesh(ray, tower.meshes[m], tower.transform); meshHitInfo = GetRayCollisionMesh(ray, tower.meshes[m], tower.transform);
@ -145,7 +146,7 @@ int main(void)
{ {
// Save the closest hit mesh // Save the closest hit mesh
if ((!collision.hit) || (collision.distance > meshHitInfo.distance)) collision = meshHitInfo; if ((!collision.hit) || (collision.distance > meshHitInfo.distance)) collision = meshHitInfo;
break; // Stop once one mesh collision is detected, the colliding mesh is m break; // Stop once one mesh collision is detected, the colliding mesh is m
} }
} }
@ -245,4 +246,4 @@ int main(void)
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Show the difference between perspective and orthographic projection * raylib [models] example - orthographic projection
* *
* Example complexity rating: [] 1/4 * Example complexity rating: [] 1/4
* *
@ -30,7 +30,7 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); InitWindow(screenWidth, screenHeight, "raylib [models] example - orthographic projection");
// Define the camera to look into our 3d world // 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 }, FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE }; Camera camera = { { 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE };

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example - point rendering * raylib [models] example - point rendering
* *
* Example complexity rating: [] 3/4 * Example complexity rating: [] 3/4
* *
@ -35,7 +35,7 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - point rendering"); InitWindow(screenWidth, screenHeight, "raylib [models] example - point rendering");
Camera camera = { Camera camera = {
@ -50,10 +50,10 @@ int main()
bool useDrawModelPoints = true; bool useDrawModelPoints = true;
bool numPointsChanged = false; bool numPointsChanged = false;
int numPoints = 1000; int numPoints = 1000;
Mesh mesh = GenMeshPoints(numPoints); Mesh mesh = GenMeshPoints(numPoints);
Model model = LoadModelFromMesh(mesh); Model model = LoadModelFromMesh(mesh);
//SetTargetFPS(60); //SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -114,14 +114,14 @@ int main()
.b = mesh.colors[i*4 + 2], .b = mesh.colors[i*4 + 2],
.a = mesh.colors[i*4 + 3], .a = mesh.colors[i*4 + 3],
}; };
DrawPoint3D(pos, color); DrawPoint3D(pos, color);
} }
} }
// Draw a unit sphere for reference // Draw a unit sphere for reference
DrawSphereWires(position, 1.0f, 10, 10, YELLOW); DrawSphereWires(position, 1.0f, 10, 10, YELLOW);
EndMode3D(); EndMode3D();
// Draw UI text // Draw UI text
@ -129,12 +129,12 @@ int main()
DrawText("Up - increase points", 20, 70, 20, WHITE); DrawText("Up - increase points", 20, 70, 20, WHITE);
DrawText("Down - decrease points", 20, 100, 20, WHITE); DrawText("Down - decrease points", 20, 100, 20, WHITE);
DrawText("Space - drawing function", 20, 130, 20, WHITE); DrawText("Space - drawing function", 20, 130, 20, WHITE);
if (useDrawModelPoints) DrawText("Using: DrawModelPoints()", 20, 160, 20, GREEN); if (useDrawModelPoints) DrawText("Using: DrawModelPoints()", 20, 160, 20, GREEN);
else DrawText("Using: DrawPoint3D()", 20, 160, 20, RED); else DrawText("Using: DrawPoint3D()", 20, 160, 20, RED);
DrawFPS(10, 10); DrawFPS(10, 10);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@ -151,7 +151,7 @@ int main()
// Generate a spherical point cloud // Generate a spherical point cloud
static Mesh GenMeshPoints(int numPoints) static Mesh GenMeshPoints(int numPoints)
{ {
Mesh mesh = { Mesh mesh = {
.triangleCount = 1, .triangleCount = 1,
.vertexCount = numPoints, .vertexCount = numPoints,
.vertices = (float *)MemAlloc(numPoints*3*sizeof(float)), .vertices = (float *)MemAlloc(numPoints*3*sizeof(float)),
@ -161,16 +161,16 @@ static Mesh GenMeshPoints(int numPoints)
// https://en.wikipedia.org/wiki/Spherical_coordinate_system // https://en.wikipedia.org/wiki/Spherical_coordinate_system
for (int i = 0; i < numPoints; i++) for (int i = 0; i < numPoints; i++)
{ {
float theta = ((float)PI*rand())/RAND_MAX; float theta = ((float)PI*rand())/((float)RAND_MAX);
float phi = (2.0f*PI*rand())/RAND_MAX; float phi = (2.0f*PI*rand())/((float)RAND_MAX);
float r = (10.0f*rand())/RAND_MAX; float r = (10.0f*rand())/((float)RAND_MAX);
mesh.vertices[i*3 + 0] = r*sinf(theta)*cosf(phi); mesh.vertices[i*3 + 0] = r*sinf(theta)*cosf(phi);
mesh.vertices[i*3 + 1] = r*sinf(theta)*sinf(phi); mesh.vertices[i*3 + 1] = r*sinf(theta)*sinf(phi);
mesh.vertices[i*3 + 2] = r*cosf(theta); mesh.vertices[i*3 + 2] = r*cosf(theta);
Color color = ColorFromHSV(r*360.0f, 1.0f, 1.0f); Color color = ColorFromHSV(r*360.0f, 1.0f, 1.0f);
mesh.colors[i*4 + 0] = color.r; mesh.colors[i*4 + 0] = color.r;
mesh.colors[i*4 + 1] = color.g; mesh.colors[i*4 + 1] = color.g;
mesh.colors[i*4 + 2] = color.b; mesh.colors[i*4 + 2] = color.b;
@ -179,6 +179,6 @@ static Mesh GenMeshPoints(int numPoints)
// Upload mesh data from CPU (RAM) to GPU (VRAM) memory // Upload mesh data from CPU (RAM) to GPU (VRAM) memory
UploadMesh(&mesh, false); UploadMesh(&mesh, false);
return mesh; return mesh;
} }

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - rlgl module usage with push/pop matrix transformations * raylib [models] example - rlgl solar system
* *
* Example complexity rating: [] 4/4 * Example complexity rating: [] 4/4
* *
@ -41,7 +41,7 @@ int main(void)
const float moonRadius = 0.16f; const float moonRadius = 0.16f;
const float moonOrbitRadius = 1.5f; const float moonOrbitRadius = 1.5f;
InitWindow(screenWidth, screenHeight, "raylib [models] example - rlgl module usage with push/pop matrix transformations"); InitWindow(screenWidth, screenHeight, "raylib [models] example - rlgl solar system");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = { 0 }; Camera camera = { 0 };

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Skybox loading and drawing * raylib [models] example - skybox rendering
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *
@ -37,7 +37,7 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing"); InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox rendering");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = { 0 }; Camera camera = { 0 };
@ -70,7 +70,7 @@ int main(void)
SetShaderValue(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, SHADER_UNIFORM_INT); SetShaderValue(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, SHADER_UNIFORM_INT);
char skyboxFileName[256] = { 0 }; char skyboxFileName[256] = { 0 };
if (useHDR) if (useHDR)
{ {
TextCopy(skyboxFileName, "resources/dresden_square_2k.hdr"); TextCopy(skyboxFileName, "resources/dresden_square_2k.hdr");
@ -116,7 +116,7 @@ int main(void)
{ {
// Unload current cubemap texture to load new one // Unload current cubemap texture to load new one
UnloadTexture(skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture); UnloadTexture(skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture);
if (useHDR) if (useHDR)
{ {
// Load HDR panorama (sphere) texture // Load HDR panorama (sphere) texture
@ -124,7 +124,7 @@ int main(void)
// Generate cubemap from panorama texture // Generate cubemap from panorama texture
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8); skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
UnloadTexture(panorama); // Texture not required anymore, cubemap already generated UnloadTexture(panorama); // Texture not required anymore, cubemap already generated
} }
else else
@ -223,7 +223,7 @@ static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int s
}; };
rlViewport(0, 0, size, size); // Set viewport to current fbo dimensions rlViewport(0, 0, size, size); // Set viewport to current fbo dimensions
// Activate and enable texture for drawing to cubemap faces // Activate and enable texture for drawing to cubemap faces
rlActiveTextureSlot(0); rlActiveTextureSlot(0);
rlEnableTexture(panorama.id); rlEnableTexture(panorama.id);
@ -232,7 +232,7 @@ static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int s
{ {
// Set the view matrix for the current cube face // Set the view matrix for the current cube face
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_VIEW], fboViews[i]); rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_VIEW], fboViews[i]);
// Select the current cubemap face attachment for the fbo // Select the current cubemap face attachment for the fbo
// WARNING: This function by default enables->attach->disables 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); rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X + i, 0);

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Tesseract view * raylib [models] example - tesseract view
* *
* NOTE: This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?) * NOTE: This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?)
* *
@ -32,7 +32,7 @@ int main(void)
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - tesseract view"); InitWindow(screenWidth, screenHeight, "raylib [models] example - tesseract view");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = { 0 }; Camera camera = { 0 };
camera.position = (Vector3){ 4.0f, 4.0f, 4.0f }; // Camera position camera.position = (Vector3){ 4.0f, 4.0f, 4.0f }; // Camera position
@ -43,16 +43,16 @@ int main(void)
// Find the coordinates by setting XYZW to +-1 // Find the coordinates by setting XYZW to +-1
Vector4 tesseract[16] = { Vector4 tesseract[16] = {
{ 1, 1, 1, 1 }, { 1, 1, 1, -1 }, { 1, 1, 1, 1 }, { 1, 1, 1, -1 },
{ 1, 1, -1, 1 }, { 1, 1, -1, -1 }, { 1, 1, -1, 1 }, { 1, 1, -1, -1 },
{ 1, -1, 1, 1 }, { 1, -1, 1, -1 }, { 1, -1, 1, 1 }, { 1, -1, 1, -1 },
{ 1, -1, -1, 1 }, { 1, -1, -1, -1 }, { 1, -1, -1, 1 }, { 1, -1, -1, -1 },
{ -1, 1, 1, 1 }, { -1, 1, 1, -1 }, { -1, 1, 1, 1 }, { -1, 1, 1, -1 },
{ -1, 1, -1, 1 }, { -1, 1, -1, -1 }, { -1, 1, -1, 1 }, { -1, 1, -1, -1 },
{ -1, -1, 1, 1 }, { -1, -1, 1, -1 }, { -1, -1, 1, 1 }, { -1, -1, 1, -1 },
{ -1, -1, -1, 1 }, { -1, -1, -1, -1 }, { -1, -1, -1, 1 }, { -1, -1, -1, -1 },
}; };
float rotation = 0.0f; float rotation = 0.0f;
Vector3 transformed[16] = { 0 }; Vector3 transformed[16] = { 0 };
float wValues[16] = { 0 }; float wValues[16] = { 0 };
@ -66,7 +66,7 @@ int main(void)
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
rotation = DEG2RAD*45.0f*GetTime(); rotation = DEG2RAD*45.0f*GetTime();
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
{ {
Vector4 p = tesseract[i]; Vector4 p = tesseract[i];
@ -79,9 +79,9 @@ int main(void)
// Projection from XYZW to XYZ from perspective point (0, 0, 0, 3) // Projection from XYZW to XYZ from perspective point (0, 0, 0, 3)
// NOTE: Trace a ray from (0, 0, 0, 3) > p and continue until W = 0 // NOTE: Trace a ray from (0, 0, 0, 3) > p and continue until W = 0
float c = 3.0f/(3.0f - p.w); float c = 3.0f/(3.0f - p.w);
p.x = c * p.x; p.x = c*p.x;
p.y = c * p.y; p.y = c*p.y;
p.z = c * p.z; p.z = c*p.z;
// Split XYZ coordinate and W values later for drawing // Split XYZ coordinate and W values later for drawing
transformed[i] = (Vector3){ p.x, p.y, p.z }; transformed[i] = (Vector3){ p.x, p.y, p.z };
@ -92,9 +92,9 @@ int main(void)
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
BeginMode3D(camera); BeginMode3D(camera);
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
{ {
@ -114,7 +114,7 @@ int main(void)
} }
} }
EndMode3D(); EndMode3D();
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@ -125,4 +125,4 @@ int main(void)
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Waving cubes * raylib [models] example - waving cubes
* *
* Example complexity rating: [] 3/4 * Example complexity rating: [] 3/4
* *
@ -91,7 +91,7 @@ int main()
}; };
// Pick a color with a hue depending on cube position for the rainbow color effect // Pick a color with a hue depending on cube position for the rainbow color effect
// NOTE: This function is quite costly to be done per cube and frame, // NOTE: This function is quite costly to be done per cube and frame,
// pre-catching the results into a separate array could improve performance // pre-catching the results into a separate array could improve performance
Color cubeColor = ColorFromHSV((float)(((x + y + z)*18)%360), 0.75f, 0.9f); Color cubeColor = ColorFromHSV((float)(((x + y + z)*18)%360), 0.75f, 0.9f);

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [models] example - Plane rotations (yaw, pitch, roll) * raylib [models] example - plane rotations (yaw, pitch, roll)
* *
* Example complexity rating: [] 2/4 * Example complexity rating: [] 2/4
* *

View File

@ -0,0 +1,65 @@
#version 100
precision mediump float;
// Input from vertex shader
varying vec3 fragPosition;
varying vec4 fragColor;
varying vec3 fragNormal;
// Uniforms
uniform vec4 colDiffuse;
uniform vec4 ambient;
uniform vec3 viewPos;
#define MAX_LIGHTS 4
#define LIGHT_DIRECTIONAL 0
#define LIGHT_POINT 1
struct Light {
int enabled;
int type;
vec3 position;
vec3 target;
vec4 color;
};
uniform Light lights[MAX_LIGHTS];
void main()
{
vec3 lightDot = vec3(0.0);
vec3 normal = normalize(fragNormal);
vec3 viewD = normalize(viewPos - fragPosition);
vec3 specular = vec3(0.0);
for (int i = 0; i < MAX_LIGHTS; i++)
{
if (lights[i].enabled == 1)
{
vec3 light = vec3(0.0);
if (lights[i].type == LIGHT_DIRECTIONAL)
light = -normalize(lights[i].target - lights[i].position);
if (lights[i].type == LIGHT_POINT)
light = normalize(lights[i].position - fragPosition);
float NdotL = max(dot(normal, light), 0.0);
lightDot += lights[i].color.rgb*NdotL;
if (NdotL > 0.0)
{
float specCo = pow(max(0.0, dot(viewD, reflect(-light, normal))), 16.0);
specular += specCo;
}
}
}
vec4 finalColor = (fragColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0)));
finalColor += fragColor*(ambient/10.0)*colDiffuse;
finalColor = pow(finalColor, vec4(1.0/2.2)); // gamma correction
gl_FragColor = finalColor;
}

View File

@ -0,0 +1,28 @@
#version 100
precision mediump float;
// Input vertex attributes
attribute vec3 vertexPosition;
attribute vec3 vertexNormal;
attribute vec4 vertexColor;
// attribute vec2 vertexTexCoord;
// Input uniform values
uniform mat4 mvp;
uniform mat4 matModel;
uniform mat4 matNormal;
// Output to fragment shader
varying vec3 fragPosition;
varying vec4 fragColor;
varying vec3 fragNormal;
void main()
{
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
fragColor = vertexColor;
fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
gl_Position = mvp*vec4(vertexPosition, 1.0);
}

View File

@ -0,0 +1,27 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec3 fragPosition;
// Input uniform values
uniform sampler2D equirectangularMap;
vec2 SampleSphericalMap(vec3 v)
{
vec2 uv = vec2(atan(v.z, v.x), asin(v.y));
uv *= vec2(0.1591, 0.3183);
uv += 0.5;
return uv;
}
void main()
{
// Normalize local position
vec2 uv = SampleSphericalMap(normalize(fragPosition));
// Fetch color from texture map
vec3 color = texture2D(equirectangularMap, uv).rgb;
// Calculate final fragment color
gl_FragColor = vec4(color, 1.0);
}

Some files were not shown because too many files have changed in this diff Show More