mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-06 19:38:15 +00:00
Merge branch 'master' into master
This commit is contained in:
34
.github/workflows/linux.yml
vendored
34
.github/workflows/linux.yml
vendored
@@ -22,22 +22,28 @@ jobs:
|
||||
build:
|
||||
permissions:
|
||||
contents: write # for actions/upload-release-asset to upload release asset
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 1
|
||||
matrix:
|
||||
bits: [32, 64]
|
||||
include:
|
||||
- bits: 32
|
||||
ARCH: "i386"
|
||||
ARCH_NAME: "i386"
|
||||
COMPILER_PATH: "/user/bin"
|
||||
COMPILER_PATH: "/usr/bin"
|
||||
runner: "ubuntu-latest"
|
||||
- bits: 64
|
||||
ARCH: "x86_64"
|
||||
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:
|
||||
RELEASE_NAME: raylib-dev_linux_${{ matrix.ARCH_NAME }}
|
||||
|
||||
@@ -54,7 +60,6 @@ jobs:
|
||||
- name: Setup Environment
|
||||
run: |
|
||||
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
|
||||
mkdir build
|
||||
cd build
|
||||
@@ -64,9 +69,14 @@ jobs:
|
||||
mkdir lib
|
||||
cd ../../../raylib
|
||||
# ${{ 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
|
||||
- name: Build Library
|
||||
- name: Build Library (32-bit)
|
||||
run: |
|
||||
cd src
|
||||
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 ..
|
||||
if: matrix.bits == 32
|
||||
|
||||
- name: Build Library
|
||||
- name: Build Library (64-bit x86)
|
||||
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
|
||||
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
|
||||
run: |
|
||||
|
7
.github/workflows/parse.yml
vendored
7
.github/workflows/parse.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Parse raylib_api
|
||||
name: Parse raylib API
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@@ -14,7 +14,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Update parse files
|
||||
working-directory: parser
|
||||
working-directory: tools/parser
|
||||
run: |
|
||||
make raylib_api
|
||||
mv raylib_api.* output
|
||||
@@ -32,6 +32,7 @@ jobs:
|
||||
set -x
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config user.name "github-actions[bot]"
|
||||
git add parser
|
||||
git add tools/parser
|
||||
git commit -m "Update raylib_api.* by CI"
|
||||
git push
|
||||
|
||||
|
1
.github/workflows/windows.yml
vendored
1
.github/workflows/windows.yml
vendored
@@ -54,7 +54,6 @@ jobs:
|
||||
- compiler: mingw-w64
|
||||
ziptarget: winarm64 # We don't build arm64 with mingw-w64 yet
|
||||
|
||||
|
||||
env:
|
||||
RELEASE_NAME: raylib-dev_${{ matrix.ziptarget }}_${{ matrix.compiler }}
|
||||
GNUTARGET: default
|
||||
|
6
.gitignore
vendored
6
.gitignore
vendored
@@ -111,5 +111,7 @@ build/
|
||||
build-*/
|
||||
docgen_tmp/
|
||||
|
||||
# Parser stuff
|
||||
parser/raylib_parser
|
||||
# Tools stuff
|
||||
tools/parser/raylib_parser
|
||||
tools/rexm/VS2022
|
||||
tools/rexm/rexm
|
||||
|
@@ -14,9 +14,11 @@ Some people ported raylib to other languages in the form of bindings or wrappers
|
||||
| [Raylib-CsLo](https://github.com/NotNotTech/Raylib-CsLo) | 4.2 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 |
|
||||
| [Raylib-CSharp-Vinculum](https://github.com/ZeroElectric/Raylib-CSharp-Vinculum) | **5.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 |
|
||||
| [Raylib-CSharp](https://github.com/MrScautHD/Raylib-CSharp) | **5.5** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MIT |
|
||||
| [Raylib-cs.BleedingEdge](https://github.com/danilwhale/Raylib-cs.BleedingEdge) | **5.6-dev** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib |
|
||||
| [cl-raylib](https://github.com/longlene/cl-raylib) | 4.0 | [Common Lisp](https://common-lisp.net) | MIT |
|
||||
| [claylib/wrap](https://github.com/defun-games/claylib) | 4.5 | [Common Lisp](https://common-lisp.net) | Zlib |
|
||||
| [claw-raylib](https://github.com/bohonghuang/claw-raylib) | **auto** | [Common Lisp](https://common-lisp.net) | Apache-2.0 |
|
||||
| [raylib](https://github.com/fosskers/raylib) | 5.5 | [Common Lisp](https://common-lisp.net) | MPL-2.0 |
|
||||
| [chez-raylib](https://github.com/Yunoinsky/chez-raylib) | **auto** | [Chez Scheme](https://cisco.github.io/ChezScheme) | GPLv3 |
|
||||
| [CLIPSraylib](https://github.com/mrryanjohnston/CLIPSraylib) | **auto** | [CLIPS](https://www.clipsrules.net/) | MIT |
|
||||
| [raylib-cr](https://github.com/sol-vin/raylib-cr) | 4.6-dev (5e1a81) | [Crystal](https://crystal-lang.org) | Apache-2.0 |
|
||||
@@ -49,7 +51,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
|
||||
| [raylib-luajit-generated](https://github.com/james2doyle/raylib-luajit-generated) | 5.5 | [Lua](http://www.lua.org) | MIT |
|
||||
| [raylib-matte](https://github.com/jcorks/raylib-matte) | 4.6-dev | [Matte](https://github.com/jcorks/matte) | **???** |
|
||||
| [Raylib.nelua](https://github.com/AuzFox/Raylib.nelua) | **5.5** | [nelua](https://nelua.io) | Zlib |
|
||||
| [raylib-bindings](https://github.com/vaiorabbit/raylib-bindings) | 5.6-dev | [Ruby](https://www.ruby-lang.org/en) | Zlib |
|
||||
| [raylib-bindings](https://github.com/vaiorabbit/raylib-bindings) | 5.6-dev | [Ruby](https://www.ruby-lang.org/en) | Zlib |
|
||||
| [naylib](https://github.com/planetis-m/naylib) | **5.6-dev** | [Nim](https://nim-lang.org) | MIT |
|
||||
| [node-raylib](https://github.com/RobLoach/node-raylib) | 4.5 | [Node.js](https://nodejs.org/en) | Zlib |
|
||||
| [raylib-odin](https://github.com/odin-lang/Odin/tree/master/vendor/raylib) | **5.5** | [Odin](https://odin-lang.org) | BSD-3Clause |
|
||||
@@ -80,7 +82,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-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-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-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 |
|
||||
@@ -93,6 +95,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
|
||||
| [raylib-apl](https://github.com/Brian-ED/raylib-apl) | **5.0** | [Dyalog APL](https://www.dyalog.com/) | MIT |
|
||||
| [raylib-jai](https://github.com/ahmedqarmout2/raylib-jai) | **5.5** | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | MIT |
|
||||
| [fnl-raylib](https://github.com/0riginaln0/fnl-raylib) | **5.5** | [Fennel](https://fennel-lang.org/) | MIT |
|
||||
| [Rayua](https://github.com/uiua-lang/rayua) | **5.5** | [Uiua](https://www.uiua.org/) | **???** |
|
||||
|
||||
### Utility Wrapers
|
||||
|
||||
@@ -103,6 +106,7 @@ These are utility wrappers for specific languages, they are not required to use
|
||||
| [claylib](https://github.com/defun-games/claylib) | 4.5 | [Common Lisp](https://common-lisp.net) | Zlib |
|
||||
| [rayed-bqn](https://github.com/Brian-ED/rayed-bqn) | **5.0** | [BQN](https://mlochbaum.github.io/BQN) | MIT |
|
||||
| [DOOR](https://github.com/RealDoigt/DOOR) | 4.0 | [D](https://dlang.org) | MIT |
|
||||
| [Iris](https://github.com/Marcos-cat/iris) | **5.5** | [Uiua](https://www.uiua.org/) | MIT |
|
||||
|
||||
### Older or Unmaintained Language Bindings
|
||||
|
||||
@@ -141,7 +145,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) |
|
||||
| [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-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-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) |
|
||||
|
@@ -28,6 +28,10 @@ Some other conventions to follow:
|
||||
- **ALWAYS** initialize all defined variables.
|
||||
- **Do not use TABS**, use 4 spaces instead.
|
||||
- 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**:
|
||||
```c
|
||||
if (condition) value = 0;
|
||||
|
261
build.zig
261
build.zig
@@ -4,6 +4,9 @@ const builtin = @import("builtin");
|
||||
/// Minimum supported version of Zig
|
||||
const min_ver = "0.13.0";
|
||||
|
||||
const emccOutputDir = "zig-out" ++ std.fs.path.sep_str ++ "htmlout" ++ std.fs.path.sep_str;
|
||||
const emccOutputFile = "index.html";
|
||||
|
||||
comptime {
|
||||
const order = std.SemanticVersion.order;
|
||||
const parse = std.SemanticVersion.parse;
|
||||
@@ -45,6 +48,26 @@ fn emSdkSetupStep(b: *std.Build, emsdk: *std.Build.Dependency) !?*std.Build.Step
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
const config_h_flags = outer: {
|
||||
// Set this value higher if compile errors happen as `src/config.h` gets larger
|
||||
@@ -130,18 +153,14 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
|
||||
try raylib_flags_arr.appendSlice(&config_h_flags);
|
||||
}
|
||||
|
||||
const raylib = if (options.shared)
|
||||
b.addSharedLibrary(.{
|
||||
.name = "raylib",
|
||||
const raylib = b.addLibrary(.{
|
||||
.name = "raylib",
|
||||
.linkage = if (options.shared) .dynamic else .static,
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
})
|
||||
else
|
||||
b.addStaticLibrary(.{
|
||||
.name = "raylib",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
}),
|
||||
});
|
||||
raylib.linkLibC();
|
||||
|
||||
// No GLFW required on PLATFORM_DRM
|
||||
@@ -339,7 +358,6 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
|
||||
setDesktopPlatform(raylib, options.platform);
|
||||
},
|
||||
.emscripten => {
|
||||
// Include emscripten for cross compilation
|
||||
if (b.lazyDependency("emsdk", .{})) |dep| {
|
||||
if (try emSdkSetupStep(b, dep)) |emSdkStep| {
|
||||
raylib.step.dependOn(&emSdkStep.step);
|
||||
@@ -366,8 +384,8 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
|
||||
return raylib;
|
||||
}
|
||||
|
||||
pub fn addRaygui(b: *std.Build, raylib: *std.Build.Step.Compile, raygui_dep: *std.Build.Dependency) void {
|
||||
const raylib_dep = b.dependencyFromBuildZig(@This(), .{});
|
||||
pub fn addRaygui(b: *std.Build, raylib: *std.Build.Step.Compile, raygui_dep: *std.Build.Dependency, options: Options) void {
|
||||
const raylib_dep = b.dependencyFromBuildZig(@This(), options);
|
||||
var gen_step = b.addWriteFiles();
|
||||
raylib.step.dependOn(&gen_step.step);
|
||||
|
||||
@@ -511,12 +529,9 @@ fn addExamples(
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
raylib: *std.Build.Step.Compile,
|
||||
) !*std.Build.Step {
|
||||
if (target.result.os.tag == .emscripten) {
|
||||
return &b.addFail("Emscripten building via Zig unsupported").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();
|
||||
|
||||
@@ -530,71 +545,159 @@ fn addExamples(
|
||||
// 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 = b.addExecutable(.{
|
||||
.name = name,
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
exe.addCSourceFile(.{ .file = b.path(path), .flags = &.{} });
|
||||
exe.linkLibC();
|
||||
if (target.result.os.tag == .emscripten) {
|
||||
const exe_lib = b.addLibrary(.{
|
||||
.name = name,
|
||||
.linkage = .static,
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
}),
|
||||
});
|
||||
exe_lib.addCSourceFile(.{
|
||||
.file = b.path(path),
|
||||
.flags = &.{},
|
||||
});
|
||||
exe_lib.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, "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,
|
||||
.root_module = b.createModule(.{
|
||||
.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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@@ -12,8 +12,8 @@
|
||||
.lazy = true,
|
||||
},
|
||||
.emsdk = .{
|
||||
.url = "git+https://github.com/emscripten-core/emsdk#3.1.50",
|
||||
.hash = "N-V-__8AALRTBQDo_pUJ8IQ-XiIyYwDKQVwnr7-7o5kvPDGE",
|
||||
.url = "git+https://github.com/emscripten-core/emsdk#4.0.9",
|
||||
.hash = "N-V-__8AAJl1DwBezhYo_VE6f53mPVm00R-Fk28NPW7P14EQ",
|
||||
.lazy = true,
|
||||
},
|
||||
},
|
||||
@@ -23,5 +23,6 @@
|
||||
"build.zig.zon",
|
||||
"src",
|
||||
"examples",
|
||||
"LICENSE",
|
||||
},
|
||||
}
|
||||
|
@@ -101,10 +101,37 @@ elseif ("${PLATFORM}" MATCHES "DRM")
|
||||
set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} atomic pthread m dl)
|
||||
|
||||
elseif ("${PLATFORM}" MATCHES "SDL")
|
||||
find_package(SDL2 REQUIRED)
|
||||
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
|
||||
set(LIBS_PRIVATE SDL2::SDL2)
|
||||
# First, check if SDL is included as a subdirectory
|
||||
if(TARGET SDL3::SDL3)
|
||||
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 ()
|
||||
|
||||
if (NOT ${OPENGL_VERSION} MATCHES "OFF")
|
||||
|
@@ -106,6 +106,9 @@ BUILD_WEB_SHELL ?= $(RAYLIB_PATH)/src/minshell.html
|
||||
BUILD_WEB_HEAP_SIZE ?= 134217728
|
||||
BUILD_WEB_RESOURCES ?= TRUE
|
||||
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
|
||||
# Use WebGL2 backend (OpenGL 3.0)
|
||||
# WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3
|
||||
BUILD_WEB_WEBGL2 ?= FALSE
|
||||
|
||||
# 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))
|
||||
@@ -186,7 +189,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
||||
endif
|
||||
endif
|
||||
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
|
||||
# to use emscripten.h and emscripten_set_main_loop()
|
||||
CC = emcc
|
||||
@@ -269,8 +272,8 @@ endif
|
||||
# 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)
|
||||
# Define additional directories containing required header files
|
||||
|
||||
# Define additional directories containing required header files
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
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
|
||||
endif
|
||||
|
||||
# Include GLFW required for examples/others/rlgl_standalone.c
|
||||
ifeq ($(USE_EXTERNAL_GLFW),FALSE)
|
||||
all others: INCLUDE_PATHS += -I$(RAYLIB_PATH)/src/external/glfw/include
|
||||
endif
|
||||
|
||||
# Define library paths containing required libs: LDFLAGS
|
||||
#------------------------------------------------------------------------------------------------
|
||||
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
|
||||
@@ -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
|
||||
# --source-map-base # allow debugging in browser with source map
|
||||
# --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)
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
|
||||
LDFLAGS += -sUSE_GLFW=3
|
||||
endif
|
||||
|
||||
# Build using asyncify
|
||||
# Build using asyncify
|
||||
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
|
||||
LDFLAGS += -sASYNCIFY
|
||||
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
|
||||
ifeq ($(BUILD_WEB_RESOURCES),TRUE)
|
||||
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
|
||||
endif
|
||||
|
||||
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
||||
|
||||
# Define source code object files required
|
||||
#------------------------------------------------------------------------------------------------
|
||||
#EXAMPLES_LIST_START
|
||||
CORE = \
|
||||
core/core_2d_camera \
|
||||
core/core_2d_camera_mouse_zoom \
|
||||
@@ -500,6 +507,7 @@ CORE = \
|
||||
core/core_3d_camera_free \
|
||||
core/core_3d_camera_mode \
|
||||
core/core_3d_camera_split_screen \
|
||||
core/core_3d_fps_controller \
|
||||
core/core_3d_picking \
|
||||
core/core_automation_events \
|
||||
core/core_basic_screen_manager \
|
||||
@@ -534,6 +542,8 @@ SHAPES = \
|
||||
shapes/shapes_bouncing_ball \
|
||||
shapes/shapes_collision_area \
|
||||
shapes/shapes_colors_palette \
|
||||
shapes/shapes_digital_clock \
|
||||
shapes/shapes_double_pendulum \
|
||||
shapes/shapes_draw_circle_sector \
|
||||
shapes/shapes_draw_rectangle_rounded \
|
||||
shapes/shapes_draw_ring \
|
||||
@@ -630,6 +640,7 @@ SHADERS = \
|
||||
shaders/shaders_mesh_instancing \
|
||||
shaders/shaders_model_shader \
|
||||
shaders/shaders_multi_sample2d \
|
||||
shaders/shaders_normalmap \
|
||||
shaders/shaders_palette_switch \
|
||||
shaders/shaders_postprocessing \
|
||||
shaders/shaders_raymarching \
|
||||
@@ -642,9 +653,9 @@ SHADERS = \
|
||||
shaders/shaders_texture_outline \
|
||||
shaders/shaders_texture_tiling \
|
||||
shaders/shaders_texture_waves \
|
||||
shaders/shaders_vertex_displacement \
|
||||
shaders/shaders_view_depth \
|
||||
shaders/shaders_write_depth \
|
||||
shaders/shaders_vertex_displacement
|
||||
shaders/shaders_write_depth
|
||||
|
||||
AUDIO = \
|
||||
audio/audio_mixed_processor \
|
||||
@@ -661,18 +672,14 @@ OTHERS = \
|
||||
others/embedded_files_loading \
|
||||
others/raylib_opengl_interop \
|
||||
others/raymath_vector_angle \
|
||||
others/rlgl_compute_shader
|
||||
|
||||
ifeq ($(TARGET_PLATFORM), PLATFORM_DESKTOP_GFLW)
|
||||
OTHERS += others/rlgl_standalone
|
||||
endif
|
||||
|
||||
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
||||
others/rlgl_compute_shader \
|
||||
others/rlgl_standalone
|
||||
#EXAMPLES_LIST_END
|
||||
|
||||
# Define processes to execute
|
||||
#------------------------------------------------------------------------------------------------
|
||||
# Default target entry
|
||||
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) $(OTHERS)
|
||||
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO)
|
||||
|
||||
core: $(CORE)
|
||||
shapes: $(SHAPES)
|
||||
@@ -681,7 +688,6 @@ text: $(TEXT)
|
||||
models: $(MODELS)
|
||||
shaders: $(SHADERS)
|
||||
audio: $(AUDIO)
|
||||
others: $(OTHERS)
|
||||
|
||||
# Generic compilation pattern
|
||||
# NOTE: Examples must be ready for Android compilation!
|
||||
|
@@ -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)
|
||||
#
|
||||
@@ -25,9 +53,20 @@
|
||||
|
||||
# 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
|
||||
|
||||
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
|
||||
PROJECT_NAME ?= raylib_examples
|
||||
RAYLIB_VERSION ?= 5.5.0
|
||||
@@ -51,6 +90,12 @@ BUILD_MODE ?= RELEASE
|
||||
# Use external GLFW library instead of rglfw module
|
||||
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)
|
||||
# NOTE: This variable is only used for PLATFORM_OS: LINUX
|
||||
USE_WAYLAND_DISPLAY ?= FALSE
|
||||
@@ -59,13 +104,14 @@ USE_WAYLAND_DISPLAY ?= FALSE
|
||||
BUILD_WEB_ASYNCIFY ?= TRUE
|
||||
BUILD_WEB_SHELL ?= $(RAYLIB_PATH)/src/shell.html
|
||||
BUILD_WEB_HEAP_SIZE ?= 134217728
|
||||
|
||||
BUILD_WEB_RESOURCES ?= TRUE
|
||||
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
|
||||
# Use WebGL2 backend (OpenGL 3.0)
|
||||
# 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
|
||||
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB PLATFORM_WEB_RGFW))
|
||||
# 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))
|
||||
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
|
||||
# ifeq ($(UNAME),Msys) -> Windows
|
||||
ifeq ($(OS),Windows_NT)
|
||||
@@ -92,7 +138,7 @@ ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB PLATFORM_WE
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
||||
UNAMEOS = $(shell uname)
|
||||
ifeq ($(UNAMEOS),Linux)
|
||||
PLATFORM_OS = LINUX
|
||||
@@ -101,7 +147,7 @@ endif
|
||||
|
||||
# RAYLIB_PATH adjustment for LINUX platform
|
||||
# TODO: Do we really need this?
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
||||
ifeq ($(PLATFORM_OS),LINUX)
|
||||
RAYLIB_PREFIX ?= ..
|
||||
RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX))
|
||||
@@ -109,14 +155,14 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
endif
|
||||
|
||||
# Default path for raylib on Raspberry Pi
|
||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
||||
RAYLIB_PATH ?= /home/pi/raylib
|
||||
endif
|
||||
|
||||
# Define raylib release directory for compiled library
|
||||
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)
|
||||
# Emscripten required variables
|
||||
EMSDK_PATH ?= C:/raylib/emsdk
|
||||
@@ -132,7 +178,7 @@ endif
|
||||
#------------------------------------------------------------------------------------------------
|
||||
CC = gcc
|
||||
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
# OSX default compiler
|
||||
CC = clang
|
||||
@@ -142,7 +188,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
CC = clang
|
||||
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
|
||||
# WARNING: To compile to HTML5, code must be redesigned
|
||||
# to use emscripten.h and emscripten_set_main_loop()
|
||||
@@ -153,15 +199,15 @@ endif
|
||||
#------------------------------------------------------------------------------------------------
|
||||
MAKE ?= make
|
||||
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||
MAKE = mingw32-make
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
|
||||
MAKE = mingw32-make
|
||||
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)
|
||||
MAKE = mingw32-make
|
||||
else
|
||||
@@ -190,14 +236,14 @@ CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result
|
||||
ifeq ($(BUILD_MODE),DEBUG)
|
||||
CFLAGS += -g -D_DEBUG
|
||||
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)
|
||||
CFLAGS += -O3
|
||||
else
|
||||
CFLAGS += -Os
|
||||
endif
|
||||
else
|
||||
CFLAGS += -s -O2
|
||||
CFLAGS += -O2
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -207,7 +253,7 @@ endif
|
||||
# -Wstrict-prototypes warn if a function is declared or defined without specifying the argument types
|
||||
# -Werror=implicit-function-declaration catch function calls without prior declaration
|
||||
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
||||
ifeq ($(PLATFORM_OS),LINUX)
|
||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
||||
CFLAGS += -D_DEFAULT_SOURCE
|
||||
@@ -218,25 +264,29 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
||||
CFLAGS += -std=gnu99 -DEGL_NO_X11
|
||||
endif
|
||||
|
||||
# Define include paths for required headers: INCLUDE_PATHS
|
||||
# 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
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
||||
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
|
||||
ifeq ($(PLATFORM_OS),LINUX)
|
||||
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
|
||||
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
|
||||
endif
|
||||
|
||||
@@ -244,7 +294,7 @@ endif
|
||||
#------------------------------------------------------------------------------------------------
|
||||
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
|
||||
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||
# NOTE: The resource .rc file contains windows executable icon and properties
|
||||
LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
|
||||
@@ -260,7 +310,18 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH)
|
||||
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
|
||||
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
||||
# -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
|
||||
# --source-map-base # allow debugging in browser with source map
|
||||
# --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)
|
||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
|
||||
LDFLAGS += -sUSE_GLFW=3
|
||||
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)
|
||||
# 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
|
||||
endif
|
||||
|
||||
# Add resources building if required
|
||||
ifeq ($(BUILD_WEB_RESOURCES),TRUE)
|
||||
LDFLAGS += --preload-file $(BUILD_WEB_RESOURCES_PATH)
|
||||
endif
|
||||
|
||||
# Add debug mode flags if required
|
||||
ifeq ($(BUILD_MODE),DEBUG)
|
||||
@@ -314,7 +380,7 @@ endif
|
||||
# Define libraries required on linking: LDLIBS
|
||||
# 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)
|
||||
# Libraries for Windows desktop compilation
|
||||
# NOTE: WinMM library required to set high-res timer resolution
|
||||
@@ -361,18 +427,77 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
LDLIBS += -lglfw
|
||||
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
|
||||
# NOTE: Required packages: libasound2-dev (ALSA)
|
||||
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic
|
||||
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
|
||||
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a
|
||||
endif
|
||||
|
||||
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
||||
|
||||
# Define source code object files required
|
||||
#------------------------------------------------------------------------------------------------
|
||||
#EXAMPLES_LIST_START
|
||||
CORE = \
|
||||
core/core_2d_camera \
|
||||
core/core_2d_camera_mouse_zoom \
|
||||
@@ -382,6 +507,7 @@ CORE = \
|
||||
core/core_3d_camera_free \
|
||||
core/core_3d_camera_mode \
|
||||
core/core_3d_camera_split_screen \
|
||||
core/core_3d_fps_controller \
|
||||
core/core_3d_picking \
|
||||
core/core_automation_events \
|
||||
core/core_basic_screen_manager \
|
||||
@@ -416,6 +542,8 @@ SHAPES = \
|
||||
shapes/shapes_bouncing_ball \
|
||||
shapes/shapes_collision_area \
|
||||
shapes/shapes_colors_palette \
|
||||
shapes/shapes_digital_clock \
|
||||
shapes/shapes_double_pendulum \
|
||||
shapes/shapes_draw_circle_sector \
|
||||
shapes/shapes_draw_rectangle_rounded \
|
||||
shapes/shapes_draw_ring \
|
||||
@@ -512,6 +640,7 @@ SHADERS = \
|
||||
shaders/shaders_mesh_instancing \
|
||||
shaders/shaders_model_shader \
|
||||
shaders/shaders_multi_sample2d \
|
||||
shaders/shaders_normalmap \
|
||||
shaders/shaders_palette_switch \
|
||||
shaders/shaders_postprocessing \
|
||||
shaders/shaders_raymarching \
|
||||
@@ -538,18 +667,6 @@ AUDIO = \
|
||||
audio/audio_sound_positioning \
|
||||
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
|
||||
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO)
|
||||
|
||||
@@ -586,10 +703,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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
core/core_3d_fps_controller: core/core_3d_fps_controller.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
core/core_3d_picking: core/core_3d_picking.c
|
||||
$(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)
|
||||
|
||||
core/core_basic_window: core/core_basic_window.c
|
||||
@@ -598,9 +721,6 @@ core/core_basic_window: core/core_basic_window.c
|
||||
core/core_basic_window_web: core/core_basic_window_web.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)
|
||||
|
||||
core/core_custom_frame_control: core/core_custom_frame_control.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
@@ -608,7 +728,10 @@ core/core_custom_logging: core/core_custom_logging.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
@@ -636,12 +759,8 @@ core/core_input_multitouch: core/core_input_multitouch.c
|
||||
core/core_input_virtual_controls: core/core_input_virtual_controls.c
|
||||
$(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
|
||||
$(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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
@@ -656,11 +775,11 @@ core/core_smooth_pixelperfect: core/core_smooth_pixelperfect.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
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
|
||||
$(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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
@@ -674,7 +793,6 @@ core/core_window_should_close: core/core_window_should_close.c
|
||||
core/core_world_screen: core/core_world_screen.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
|
||||
# Compile SHAPES examples
|
||||
shapes/shapes_basic_shapes: shapes/shapes_basic_shapes.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
@@ -688,6 +806,12 @@ shapes/shapes_collision_area: shapes/shapes_collision_area.c
|
||||
shapes/shapes_colors_palette: shapes/shapes_colors_palette.c
|
||||
$(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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
@@ -718,6 +842,9 @@ shapes/shapes_logo_raylib: shapes/shapes_logo_raylib.c
|
||||
shapes/shapes_logo_raylib_anim: shapes/shapes_logo_raylib_anim.c
|
||||
$(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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
@@ -727,10 +854,6 @@ shapes/shapes_splines_drawing: shapes/shapes_splines_drawing.c
|
||||
shapes/shapes_top_down_lights: shapes/shapes_top_down_lights.c
|
||||
$(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
|
||||
textures/textures_background_scrolling: textures/textures_background_scrolling.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
@@ -764,16 +887,16 @@ textures/textures_image_channel: textures/textures_image_channel.c
|
||||
|
||||
textures/textures_image_drawing: textures/textures_image_drawing.c
|
||||
$(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/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
|
||||
$(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
|
||||
$(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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
@@ -785,10 +908,10 @@ textures/textures_image_processing: textures/textures_image_processing.c
|
||||
|
||||
textures/textures_image_rotate: textures/textures_image_rotate.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file textures/resources/raylib_logo.png
|
||||
--preload-file textures/resources/raylib_logo.png@resources/raylib_logo.png
|
||||
|
||||
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/KAISG.ttf@resources/KAISG.ttf
|
||||
|
||||
@@ -797,7 +920,8 @@ textures/textures_logo_raylib: textures/textures_logo_raylib.c
|
||||
--preload-file textures/resources/raylib_logo.png@resources/raylib_logo.png
|
||||
|
||||
textures/textures_mouse_painting: textures/textures_mouse_painting.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file textures/my_amazing_texture_painting.png@my_amazing_texture_painting.png
|
||||
|
||||
textures/textures_npatch_drawing: textures/textures_npatch_drawing.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
@@ -821,13 +945,13 @@ textures/textures_sprite_anim: textures/textures_sprite_anim.c
|
||||
|
||||
textures/textures_sprite_button: textures/textures_sprite_button.c
|
||||
$(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
|
||||
$(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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
@@ -841,7 +965,6 @@ textures/textures_to_image: textures/textures_to_image.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file textures/resources/raylib_logo.png@resources/raylib_logo.png
|
||||
|
||||
|
||||
# Compile TEXT examples
|
||||
text/text_codepoints_loading: text/text_codepoints_loading.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
@@ -852,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
|
||||
|
||||
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
|
||||
|
||||
text/text_font_loading: text/text_font_loading.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \
|
||||
--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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
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/shaders/glsl100/sdf.fs@resources/shaders/glsl100/sdf.fs
|
||||
|
||||
@@ -893,31 +1013,21 @@ text/text_rectangle_bounds: text/text_rectangle_bounds.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
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.png@resources/dejavu.png \
|
||||
--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.png@resources/symbola.png
|
||||
--preload-file text/resources/symbola.fnt@resources/symbola.fnt
|
||||
|
||||
text/text_writing_anim: text/text_writing_anim.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
|
||||
# Compile MODELS examples
|
||||
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/guytex.png@resources/models/iqm/guytex.png \
|
||||
--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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file models/resources/billboard.png@resources/billboard.png
|
||||
@@ -949,28 +1059,37 @@ models/models_first_person_maze: models/models_first_person_maze.c
|
||||
models/models_geometric_shapes: models/models_geometric_shapes.c
|
||||
$(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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file models/resources/heightmap.png@resources/heightmap.png
|
||||
|
||||
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_diffuse.png@resources/models/obj/castle_diffuse.png
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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_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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
@@ -990,13 +1109,13 @@ models/models_rlgl_solar_system: models/models_rlgl_solar_system.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
models/models_skybox: models/models_skybox.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 -sFORCE_FILESYSTEM=1 \
|
||||
--preload-file models/resources/dresden_square_2k.hdr@resources/dresden_square_2k.hdr \
|
||||
--preload-file models/resources/skybox.png@resources/skybox.png \
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--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/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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
@@ -1005,26 +1124,20 @@ models/models_waving_cubes: models/models_waving_cubes.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
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_diffuse.png@resources/models/obj/plane_diffuse.png
|
||||
|
||||
|
||||
# Compile SHADER examples
|
||||
# Compile SHADERS examples
|
||||
shaders/shaders_basic_lighting: shaders/shaders_basic_lighting.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file shaders/resources/texel_checker.png@resources/texel_checker.png \
|
||||
--preload-file shaders/resources/shaders/glsl100/lighting.fs@resources/shaders/glsl100/lighting.fs \
|
||||
--preload-file shaders/resources/shaders/glsl100/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/lighting.fs@resources/shaders/glsl100/lighting.fs
|
||||
|
||||
shaders/shaders_basic_pbr: shaders/shaders_basic_pbr.c
|
||||
$(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/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/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/old_car_d.png@resources/old_car_d.png \
|
||||
--preload-file shaders/resources/old_car_mra.png@resources/old_car_mra.png \
|
||||
@@ -1036,14 +1149,13 @@ shaders/shaders_basic_pbr: shaders/shaders_basic_pbr.c
|
||||
--preload-file shaders/resources/road_n.png@resources/road_n.png
|
||||
|
||||
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_diffuse.png@resources/models/barracks_diffuse.png \
|
||||
--preload-file shaders/resources/shaders/glsl100/swirl.fs@resources/shaders/glsl100/swirl.fs
|
||||
|
||||
shaders/shaders_deferred_render: shaders/shaders_deferred_render.c
|
||||
$(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.fs@resources/shaders/glsl100/gbuffer.fs \
|
||||
--preload-file shaders/resources/shaders/glsl100/deferred_shading.vs@resources/shaders/glsl100/deferred_shading.vs \
|
||||
@@ -1056,11 +1168,11 @@ shaders/shaders_eratosthenes: shaders/shaders_eratosthenes.c
|
||||
shaders/shaders_fog: shaders/shaders_fog.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file shaders/resources/texel_checker.png@resources/texel_checker.png \
|
||||
--preload-file shaders/resources/shaders/glsl100/fog.fs@resources/shaders/glsl100/fog.fs \
|
||||
--preload-file shaders/resources/shaders/glsl100/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
|
||||
$(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
|
||||
|
||||
shaders/shaders_hybrid_render: shaders/shaders_hybrid_render.c
|
||||
@@ -1073,7 +1185,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
|
||||
|
||||
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.fs@resources/shaders/glsl100/lightmap.fs \
|
||||
--preload-file shaders/resources/cubicmap_atlas.png@resources/cubicmap_atlas.png \
|
||||
@@ -1085,7 +1197,7 @@ shaders/shaders_mesh_instancing: shaders/shaders_mesh_instancing.c
|
||||
--preload-file shaders/resources/shaders/glsl100/lighting.fs@resources/shaders/glsl100/lighting.fs
|
||||
|
||||
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_diffuse.png@resources/models/watermill_diffuse.png \
|
||||
--preload-file shaders/resources/shaders/glsl100/grayscale.fs@resources/shaders/glsl100/grayscale.fs
|
||||
@@ -1094,39 +1206,61 @@ shaders/shaders_multi_sample2d: shaders/shaders_multi_sample2d.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file shaders/resources/shaders/glsl100/color_mix.fs@resources/shaders/glsl100/color_mix.fs
|
||||
|
||||
shaders/shaders_normalmap: shaders/shaders_normalmap.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
|
||||
$(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
|
||||
|
||||
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_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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--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
|
||||
$(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/glsl330/shadowmap.vs@resources/shaders/glsl330/shadowmap.vs \
|
||||
--preload-file shaders/resources/shaders/glsl120/shadowmap.fs@resources/shaders/glsl120/shadowmap.fs \
|
||||
--preload-file shaders/resources/shaders/glsl330/shadowmap.fs@resources/shaders/glsl330/shadowmap.fs \
|
||||
--preload-file shaders/resources/models/robot.glb@resources/models/robot.glb
|
||||
--preload-file shaders/resources/shaders/glsl100/shadowmap.vs@resources/shaders/glsl100/shadowmap.vs \
|
||||
--preload-file shaders/resources/shaders/glsl100/shadowmap.fs@resources/shaders/glsl100/shadowmap.fs \
|
||||
--preload-file shaders/resources/models/robot.glb@resources/models/robot.glb \
|
||||
--preload-file shaders/shaders_shadowmap.png@shaders_shadowmap.png
|
||||
|
||||
shaders/shaders_shapes_textures: shaders/shaders_shapes_textures.c
|
||||
$(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/base.vs@resources/shaders/glsl100/base.vs \
|
||||
--preload-file shaders/resources/shaders/glsl100/grayscale.fs@resources/shaders/glsl100/grayscale.fs
|
||||
|
||||
shaders/shaders_simple_mask: shaders/shaders_simple_mask.c
|
||||
$(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/mask.png@resources/mask.png \
|
||||
--preload-file shaders/resources/shaders/glsl100/mask.fs@resources/shaders/glsl100/mask.fs
|
||||
--preload-file shaders/resources/mask.png@resources/mask.png
|
||||
|
||||
shaders/shaders_spotlight: shaders/shaders_spotlight.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
@@ -1139,51 +1273,47 @@ shaders/shaders_texture_drawing: shaders/shaders_texture_drawing.c
|
||||
|
||||
shaders/shaders_texture_outline: shaders/shaders_texture_outline.c
|
||||
$(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
|
||||
$(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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file shaders/resources/space.png@resources/space.png \
|
||||
--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
|
||||
$(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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file shaders/resources/shaders/glsl100/write_depth.fs@resources/shaders/glsl100/write_depth.fs
|
||||
|
||||
shaders/shaders_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
|
||||
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/coin.wav@resources/coin.wav
|
||||
|
||||
audio/audio_module_playing: audio/audio_module_playing.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file audio/resources/mini1111.xm@resources/mini1111.xm
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
@@ -1194,29 +1324,14 @@ audio/audio_sound_multi: audio/audio_sound_multi.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file audio/resources/sound.wav@resources/sound.wav
|
||||
|
||||
audio/audio_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
|
||||
$(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
|
||||
|
||||
|
||||
# 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)
|
||||
#EXAMPLES_LIST_END
|
||||
|
||||
# Clean everything
|
||||
clean:
|
||||
|
@@ -16,219 +16,223 @@ 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 [example]` to compile _and run_ a particular example (e.g. `zig build core_basic_window`)
|
||||
|
||||
## EXAMPLES LIST
|
||||
## EXAMPLES COLLECTION [TOTAL: 160]
|
||||
|
||||
### category: core
|
||||
### category: core [36]
|
||||
|
||||
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 |
|
||||
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
||||
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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_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) |
|
||||
| [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_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) |
|
||||
| [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_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_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_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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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_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) |
|
||||
| [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) |
|
||||
| [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_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) |
|
||||
| [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_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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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_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) |
|
||||
| [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) |
|
||||
| [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_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_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) |
|
||||
| [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) |
|
||||
| [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 |
|
||||
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| 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) |
|
||||
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
||||
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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_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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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_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_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_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_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_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) |
|
||||
| [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_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) |
|
||||
|
||||
### category: textures
|
||||
### category: textures [26]
|
||||
|
||||
Examples using raylib textures functionality, including image/textures loading/generation and drawing, provided by raylib [textures](../src/textures.c) modul
|
||||
Examples using raylib textures functionality, including image/textures loading/generation and drawing, provided by raylib [textures](../src/rtextures.c) module.
|
||||
|
||||
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
||||
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| 54 | [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) |
|
||||
| 55 | [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) |
|
||||
| 56 | [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) |
|
||||
| 57 | [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) |
|
||||
| 58 | [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) |
|
||||
| 59 | [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) |
|
||||
| 60 | [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) |
|
||||
| 61 | [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) |
|
||||
| 62 | [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) |
|
||||
| 63 | [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) |
|
||||
| 64 | [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) |
|
||||
| 65 | [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) |
|
||||
| 66 | [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) |
|
||||
| 67 | [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) |
|
||||
| 68 | [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) |
|
||||
| 69 | [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) |
|
||||
| 70 | [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) |
|
||||
| 71 | [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) |
|
||||
| 72 | [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) |
|
||||
| 73 | [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) |
|
||||
| 74 | [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) |
|
||||
| 75 | [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) |
|
||||
| 76 | [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) |
|
||||
| 77 | [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) |
|
||||
| 78 | [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) |
|
||||
| 79 | [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) |
|
||||
| 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) |
|
||||
|
||||
### category: text
|
||||
### category: text [12]
|
||||
|
||||
Examples using raylib text functionality, including sprite fonts loading/generation and text drawing, provided by raylib [text](../src/text.c) module.
|
||||
Examples using raylib text functionality, including sprite fonts loading/generation and text drawing, provided by raylib [text](../src/rtext.c) module.
|
||||
|
||||
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
||||
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| 80 | [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) |
|
||||
| 81 | [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) |
|
||||
| 82 | [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) |
|
||||
| 83 | [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) |
|
||||
| 84 | [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) |
|
||||
| 85 | [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) |
|
||||
| 86 | [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) |
|
||||
| 87 | [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) |
|
||||
| 88 | [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) |
|
||||
| 89 | [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) |
|
||||
| 90 | [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) |
|
||||
| 91 | [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) |
|
||||
| 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) |
|
||||
|
||||
### category: models
|
||||
### category: models [23]
|
||||
|
||||
Examples using raylib models functionality, including models loading/generation and drawing, provided by raylib [models](../src/models.c) module.
|
||||
Examples using raylib models functionality, including models loading/generation and drawing, provided by raylib [models](../src/rmodels.c) module.
|
||||
|
||||
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
||||
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| 92 | [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) |
|
||||
| 93 | [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) |
|
||||
| 94 | [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) |
|
||||
| 95 | [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) |
|
||||
| 96 | [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) |
|
||||
| 97 | [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) |
|
||||
| 98 | [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) |
|
||||
| 99 | [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) |
|
||||
| 100 | [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) |
|
||||
| 101 | [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) |
|
||||
| 102 | [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) |
|
||||
| 103 | [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) |
|
||||
| 104 | [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) |
|
||||
| 105 | [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) |
|
||||
| 106 | [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) |
|
||||
| 107 | [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) |
|
||||
| 108 | [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) |
|
||||
| 109 | [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) |
|
||||
| 110 | [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) |
|
||||
| 111 | [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) |
|
||||
| 112 | [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) |
|
||||
| 113 | [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) |
|
||||
| 114 | [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) |
|
||||
| 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
|
||||
### 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.
|
||||
|
||||
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
||||
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| 115 | [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) |
|
||||
| 116 | [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) |
|
||||
| 117 | [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) |
|
||||
| 118 | [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) |
|
||||
| 119 | [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) |
|
||||
| 120 | [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) |
|
||||
| 121 | [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) |
|
||||
| 122 | [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) |
|
||||
| 123 | [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) |
|
||||
| 124 | [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) |
|
||||
| 125 | [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) |
|
||||
| 126 | [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) |
|
||||
| 127 | [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) |
|
||||
| 128 | [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) |
|
||||
| 129 | [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) |
|
||||
| 130 | [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) |
|
||||
| 131 | [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) |
|
||||
| 132 | [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) |
|
||||
| 133 | [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) |
|
||||
| 134 | [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) |
|
||||
| 135 | [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) |
|
||||
| 136 | [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) |
|
||||
| 137 | [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) |
|
||||
| 138 | [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) |
|
||||
| 139 | [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) |
|
||||
| 140 | [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) |
|
||||
| 141 | [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) |
|
||||
| 142 | [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) |
|
||||
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
||||
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| [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_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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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_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) |
|
||||
| [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_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_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_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_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_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_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_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) |
|
||||
| [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_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) |
|
||||
| [shaders_normalmap](shaders/shaders_normalmap.c) | <img src="shaders/shaders_normalmap.png" alt="shaders_normalmap" width="80"> | ⭐⭐⭐⭐️ | 5.6 | 5.6 | [Jeremy Montgomery](https://github.com/Sir_Irk) |
|
||||
| [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_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_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_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_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_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_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_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) |
|
||||
| [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_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 |
|
||||
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| 142 | [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) |
|
||||
| 143 | [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) |
|
||||
| 144 | [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) |
|
||||
| 145 | [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) |
|
||||
| 146 | [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) |
|
||||
| 147 | [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) |
|
||||
| 148 | [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) |
|
||||
| 149 | [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) |
|
||||
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
||||
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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_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) |
|
||||
| [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_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]
|
||||
|
||||
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 |
|
||||
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| 150 | [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) |
|
||||
| 151 | [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) |
|
||||
| 152 | [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) |
|
||||
| 153 | [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) |
|
||||
| 154 | [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) |
|
||||
| 155 | [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) |
|
||||
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|
||||
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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) |
|
||||
| [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!
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [audio] example - Mixed audio processing
|
||||
* raylib [audio] example - mixed audio processing
|
||||
*
|
||||
* Example complexity rating: [★★★★] 4/4
|
||||
*
|
||||
|
@@ -45,7 +45,7 @@ int main(void)
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateMusicStream(music); // Update music buffer with new stream data
|
||||
|
||||
|
||||
// Restart music playing (stop and play)
|
||||
if (IsKeyPressed(KEY_SPACE))
|
||||
{
|
||||
|
@@ -108,8 +108,6 @@ int main(void)
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Sample mouse input.
|
||||
mousePosition = GetMousePosition();
|
||||
|
||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
||||
@@ -125,7 +123,7 @@ int main(void)
|
||||
// Compute two cycles to allow the buffer padding, simplifying any modulation, resampling, etc.
|
||||
if (frequency != oldFrequency)
|
||||
{
|
||||
// Compute wavelength. Limit size in both directions.
|
||||
// Compute wavelength. Limit size in both directions
|
||||
//int oldWavelength = waveLength;
|
||||
waveLength = (int)(22050/frequency);
|
||||
if (waveLength > MAX_SAMPLES/2) waveLength = MAX_SAMPLES/2;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [audio] example - Playing sound multiple times
|
||||
* raylib [audio] example - sound alias
|
||||
*
|
||||
* Example complexity rating: [★★☆☆] 2/4
|
||||
*
|
||||
@@ -31,18 +31,18 @@ int main(void)
|
||||
const int screenWidth = 800;
|
||||
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
|
||||
|
||||
// load the sound list
|
||||
soundArray[0] = LoadSound("resources/sound.wav"); // Load WAV audio file into the first slot as the 'source' sound
|
||||
// this sound owns the sample data
|
||||
for (int i = 1; i < MAX_SOUNDS; i++)
|
||||
{
|
||||
soundArray[i] = LoadSoundAlias(soundArray[0]); // Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
|
||||
}
|
||||
currentSound = 0; // set the sound list to the start
|
||||
// Load audio file into the first slot as the 'source' sound,
|
||||
// this sound owns the sample data
|
||||
soundArray[0] = LoadSound("resources/sound.wav");
|
||||
|
||||
// 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
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -54,14 +54,15 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed(KEY_SPACE))
|
||||
{
|
||||
PlaySound(soundArray[currentSound]); // play the next open sound slot
|
||||
currentSound++; // increment the sound slot
|
||||
if (currentSound >= MAX_SOUNDS) // if the sound slot is out of bounds, go back to 0
|
||||
currentSound = 0;
|
||||
PlaySound(soundArray[currentSound]); // Play the next open sound slot
|
||||
currentSound++; // Increment the sound slot
|
||||
|
||||
// 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
|
||||
@@ -78,9 +79,8 @@ int main(void)
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
for (int i = 1; i < MAX_SOUNDS; i++)
|
||||
UnloadSoundAlias(soundArray[i]); // Unload sound aliases
|
||||
UnloadSound(soundArray[0]); // Unload source sound data
|
||||
for (int i = 1; i < MAX_SOUNDS; i++) UnloadSoundAlias(soundArray[i]); // Unload sound aliases
|
||||
UnloadSound(soundArray[0]); // Unload source sound data
|
||||
|
||||
CloseAudioDevice(); // Close audio device
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [audio] example - Playing spatialized 3D sound
|
||||
* raylib [audio] example - spatialized 3D sound
|
||||
*
|
||||
* Example complexity rating: [★★☆☆] 2/4
|
||||
*
|
||||
@@ -31,9 +31,9 @@ int main(void)
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - Playing spatialized 3D sound");
|
||||
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - spatialized 3D sound");
|
||||
|
||||
InitAudioDevice();
|
||||
|
||||
Sound sound = LoadSound("resources/coin.wav");
|
||||
@@ -45,9 +45,9 @@ int main(void)
|
||||
.fovy = 60,
|
||||
.projection = CAMERA_PERSPECTIVE
|
||||
};
|
||||
|
||||
|
||||
DisableCursor();
|
||||
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@@ -89,7 +89,7 @@ int main(void)
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadSound(sound);
|
||||
CloseAudioDevice(); // Close audio device
|
||||
|
||||
|
||||
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
|
||||
Vector3 direction = Vector3Subtract(position, listener.position);
|
||||
float distance = Vector3Length(direction);
|
||||
|
||||
|
||||
// Apply logarithmic distance attenuation and clamp between 0-1
|
||||
float attenuation = 1.0f/(1.0f + (distance/maxDist));
|
||||
attenuation = Clamp(attenuation, 0.0f, 1.0f);
|
||||
|
||||
|
||||
// Calculate normalized vectors for spatial positioning
|
||||
Vector3 normalizedDirection = Vector3Normalize(direction);
|
||||
Vector3 forward = Vector3Normalize(Vector3Subtract(listener.target, listener.position));
|
||||
Vector3 right = Vector3Normalize(Vector3CrossProduct(listener.up, forward));
|
||||
|
||||
|
||||
// Reduce volume for sounds behind the listener
|
||||
float dotProduct = Vector3DotProduct(forward, normalizedDirection);
|
||||
if (dotProduct < 0.0f) attenuation *= (1.0f + dotProduct*0.5f);
|
||||
|
||||
|
||||
// Set stereo panning based on sound position relative to listener
|
||||
float pan = 0.5f + 0.5f*Vector3DotProduct(normalizedDirection, right);
|
||||
|
||||
|
||||
// Apply final sound properties
|
||||
SetSoundVolume(sound, attenuation);
|
||||
SetSoundPan(sound, pan);
|
||||
|
@@ -53,7 +53,7 @@ int main(void)
|
||||
|
||||
float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f]
|
||||
bool pause = false; // Music playing paused
|
||||
|
||||
|
||||
bool enableEffectLPF = false; // Enable effect low-pass-filter
|
||||
bool enableEffectDelay = false; // Enable effect delay (1 second)
|
||||
|
||||
@@ -98,7 +98,7 @@ int main(void)
|
||||
if (enableEffectDelay) AttachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
|
||||
else DetachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
|
||||
}
|
||||
|
||||
|
||||
// Get normalized time played for current music stream
|
||||
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music);
|
||||
|
||||
@@ -119,7 +119,7 @@ int main(void)
|
||||
|
||||
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 230, 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 D TO TOGGLE DELAY EFFECT: %s", enableEffectDelay? "ON" : "OFF"), 180, 350, 20, GRAY);
|
||||
|
||||
|
43
examples/build_example_web.bat
Normal file
43
examples/build_example_web.bat
Normal file
@@ -0,0 +1,43 @@
|
||||
::@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
|
||||
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
|
||||
:: TODO: If using some resources/assets, set the directory path as shown in the commented line!
|
||||
set RESOURCES=
|
||||
::set RESOURCES=--preload-file $(RESOURCES_PATH)
|
||||
cd %RAYLIB_PATH%\examples\%CATEGORY%
|
||||
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:
|
||||
%CC% -o %FILENAME%.html %FILENAME%.c %CFLAGS% %LDFLAGS% %LDLIBS% %RESOURCES%
|
||||
cd ..
|
||||
echo
|
@@ -47,7 +47,7 @@ int main ()
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed(KEY_ONE)) zoomMode = 0;
|
||||
else if (IsKeyPressed(KEY_TWO)) zoomMode = 1;
|
||||
|
||||
|
||||
// Translate based on mouse right click
|
||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
||||
{
|
||||
@@ -68,7 +68,7 @@ int main ()
|
||||
// Set the offset to where the mouse is
|
||||
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
|
||||
camera.target = mouseWorldPos;
|
||||
|
||||
@@ -89,7 +89,7 @@ int main ()
|
||||
// Set the offset to where the mouse is
|
||||
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
|
||||
camera.target = mouseWorldPos;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ int main ()
|
||||
|
||||
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
|
||||
rlPushMatrix();
|
||||
rlTranslatef(0, 25*50, 0);
|
||||
@@ -121,19 +121,19 @@ int main ()
|
||||
|
||||
// Draw a reference circle
|
||||
DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, 50, MAROON);
|
||||
|
||||
|
||||
EndMode2D();
|
||||
|
||||
|
||||
// Draw mouse reference
|
||||
//Vector2 mousePos = GetWorldToScreen2D(GetMousePosition(), camera)
|
||||
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);
|
||||
|
||||
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);
|
||||
else DrawText("Mouse left button drag to move, mouse press and move to zoom", 20, 50, 20, DARKGRAY);
|
||||
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
@@ -137,7 +137,7 @@ int main(void)
|
||||
|
||||
Rectangle playerRect = { player.position.x - 20, player.position.y - 40, 40.0f, 40.0f };
|
||||
DrawRectangleRec(playerRect, RED);
|
||||
|
||||
|
||||
DrawCircleV(player.position, 5.0f, GOLD);
|
||||
|
||||
EndMode2D();
|
||||
|
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Example originally created with raylib 4.5, last time updated with raylib 4.5
|
||||
@@ -81,9 +81,9 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginTextureMode(screenCamera1);
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
|
||||
BeginMode2D(camera1);
|
||||
|
||||
|
||||
// Draw full scene with first camera
|
||||
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
|
||||
{
|
||||
@@ -106,17 +106,17 @@ int main(void)
|
||||
DrawRectangleRec(player1, RED);
|
||||
DrawRectangleRec(player2, BLUE);
|
||||
EndMode2D();
|
||||
|
||||
|
||||
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
|
||||
DrawText("PLAYER1: W/S/A/D to move", 10, 10, 10, MAROON);
|
||||
|
||||
|
||||
EndTextureMode();
|
||||
|
||||
BeginTextureMode(screenCamera2);
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
|
||||
BeginMode2D(camera2);
|
||||
|
||||
|
||||
// Draw full scene with second camera
|
||||
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
|
||||
{
|
||||
@@ -138,21 +138,21 @@ int main(void)
|
||||
|
||||
DrawRectangleRec(player1, RED);
|
||||
DrawRectangleRec(player2, BLUE);
|
||||
|
||||
|
||||
EndMode2D();
|
||||
|
||||
|
||||
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
|
||||
DrawText("PLAYER2: UP/DOWN/LEFT/RIGHT to move", 10, 10, 10, DARKBLUE);
|
||||
|
||||
|
||||
EndTextureMode();
|
||||
|
||||
// Draw both views render textures to the screen side by side
|
||||
BeginDrawing();
|
||||
ClearBackground(BLACK);
|
||||
|
||||
|
||||
DrawTextureRec(screenCamera1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
|
||||
DrawTextureRec(screenCamera2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
|
||||
|
||||
|
||||
DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY);
|
||||
EndDrawing();
|
||||
}
|
||||
|
@@ -127,7 +127,7 @@ int main(void)
|
||||
UpdateCameraPro(&camera,
|
||||
(Vector3){
|
||||
(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_A) || IsKeyDown(KEY_LEFT))*0.1f,
|
||||
0.0f // Move up-down
|
||||
|
@@ -51,7 +51,7 @@ int main(void)
|
||||
|
||||
// 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 };
|
||||
|
||||
|
||||
// Grid data
|
||||
int count = 5;
|
||||
float spacing = 4;
|
||||
@@ -98,9 +98,9 @@ int main(void)
|
||||
// Draw Player1 view to the render texture
|
||||
BeginTextureMode(screenPlayer1);
|
||||
ClearBackground(SKYBLUE);
|
||||
|
||||
|
||||
BeginMode3D(cameraPlayer1);
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
@@ -116,20 +116,20 @@ int main(void)
|
||||
// Draw a cube at each player's position
|
||||
DrawCube(cameraPlayer1.position, 1, 1, 1, RED);
|
||||
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
|
||||
|
||||
|
||||
EndMode3D();
|
||||
|
||||
|
||||
DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f));
|
||||
DrawText("PLAYER1: W/S to move", 10, 10, 20, MAROON);
|
||||
|
||||
|
||||
EndTextureMode();
|
||||
|
||||
// Draw Player2 view to the render texture
|
||||
BeginTextureMode(screenPlayer2);
|
||||
ClearBackground(SKYBLUE);
|
||||
|
||||
|
||||
BeginMode3D(cameraPlayer2);
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
@@ -145,21 +145,21 @@ int main(void)
|
||||
// Draw a cube at each player's position
|
||||
DrawCube(cameraPlayer1.position, 1, 1, 1, RED);
|
||||
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
|
||||
|
||||
|
||||
EndMode3D();
|
||||
|
||||
|
||||
DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f));
|
||||
DrawText("PLAYER2: UP/DOWN to move", 10, 10, 20, DARKBLUE);
|
||||
|
||||
|
||||
EndTextureMode();
|
||||
|
||||
// Draw both views render textures to the screen side by side
|
||||
BeginDrawing();
|
||||
ClearBackground(BLACK);
|
||||
|
||||
|
||||
DrawTextureRec(screenPlayer1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
|
||||
DrawTextureRec(screenPlayer2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
|
||||
|
||||
|
||||
DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY);
|
||||
EndDrawing();
|
||||
}
|
||||
|
360
examples/core/core_3d_fps_controller.c
Normal file
360
examples/core/core_3d_fps_controller.c
Normal file
@@ -0,0 +1,360 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - Input Gestures for Web
|
||||
*
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* Example originally created 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"
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
#define GLSL_VERSION 330
|
||||
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||
#define GLSL_VERSION 100
|
||||
#endif
|
||||
|
||||
|
||||
/* Movement constants */
|
||||
#define GRAVITY 32.f
|
||||
#define MAX_SPEED 20.f
|
||||
#define CROUCH_SPEED 5.f
|
||||
#define JUMP_FORCE 12.f
|
||||
#define MAX_ACCEL 150.f
|
||||
/* 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.f
|
||||
#define CROUCH_HEIGHT 0.f
|
||||
#define STAND_HEIGHT 1.f
|
||||
#define BOTTOM_HEIGHT 0.5f
|
||||
|
||||
#define NORMALIZE_INPUT 0
|
||||
|
||||
typedef struct {
|
||||
Vector3 position;
|
||||
Vector3 velocity;
|
||||
Vector3 dir;
|
||||
bool isGrounded;
|
||||
Sound soundJump;
|
||||
}Body;
|
||||
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
Vector2 sensitivity = { 0.001f, 0.001f };
|
||||
|
||||
Body player;
|
||||
Camera camera;
|
||||
Vector2 lookRotation = { 0 };
|
||||
float headTimer;
|
||||
float walkLerp;
|
||||
float headLerp;
|
||||
Vector2 lean;
|
||||
|
||||
void UpdateDrawFrame(void); // Update and Draw one frame
|
||||
|
||||
void DrawLevel();
|
||||
|
||||
void UpdateCameraAngle();
|
||||
|
||||
void UpdateBody(Body* body, float rot, char side, char forward, bool jumpPressed, bool crouchHold);
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
InitWindow(screenWidth, screenHeight, "Raylib Quake-like controller");
|
||||
InitAudioDevice();
|
||||
|
||||
player = (Body){ Vector3Zero(), Vector3Zero(), Vector3Zero(), false, LoadSound("resources/huh_jump.wav")};
|
||||
camera = (Camera){ 0 };
|
||||
camera.fovy = 60.f; // Camera field-of-view Y
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||
|
||||
lookRotation = Vector2Zero();
|
||||
headTimer = 0.f;
|
||||
walkLerp = 0.f;
|
||||
headLerp = STAND_HEIGHT;
|
||||
lean = Vector2Zero();
|
||||
|
||||
camera.position = (Vector3){
|
||||
player.position.x,
|
||||
player.position.y + (BOTTOM_HEIGHT + headLerp),
|
||||
player.position.z,
|
||||
};
|
||||
UpdateCameraAngle();
|
||||
|
||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||
#else
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
UpdateDrawFrame();
|
||||
}
|
||||
#endif
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadSound(player.soundJump);
|
||||
CloseAudioDevice();
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UpdateDrawFrame(void)
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
Vector2 mouse_delta = GetMouseDelta();
|
||||
lookRotation.x -= mouse_delta.x * sensitivity.x;
|
||||
lookRotation.y += mouse_delta.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.f * 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.f;
|
||||
walkLerp = Lerp(walkLerp, 1.f, 10.f * delta);
|
||||
camera.fovy = Lerp(camera.fovy, 55.f, 5.f * delta);
|
||||
}
|
||||
else {
|
||||
walkLerp = Lerp(walkLerp, 0.f, 10.f * delta);
|
||||
camera.fovy = Lerp(camera.fovy, 60.f, 5.f * delta);
|
||||
}
|
||||
|
||||
lean.x = Lerp(lean.x, sideway * 0.02f, 10.f * delta);
|
||||
lean.y = Lerp(lean.y, forward * 0.015f, 10.f * delta);
|
||||
|
||||
UpdateCameraAngle();
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawLevel();
|
||||
|
||||
EndMode3D();
|
||||
|
||||
// Draw info box
|
||||
DrawRectangle(5, 5, 330, 100, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines(5, 5, 330, 100, 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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
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;
|
||||
SetSoundPitch(body->soundJump, 1.f + (GetRandomValue(-100, 100) * 0.001));
|
||||
PlaySound(body->soundJump);
|
||||
}
|
||||
|
||||
Vector3 front_vec = (Vector3){ sin(rot), 0.f, cos(rot) };
|
||||
Vector3 right_vec = (Vector3){ cos(-rot), 0.f, sin(-rot) };
|
||||
|
||||
Vector3 desired_dir = (Vector3){
|
||||
input.x * right_vec.x + input.y * front_vec.x,
|
||||
0.f,
|
||||
input.x * right_vec.z + input.y * front_vec.z,
|
||||
};
|
||||
|
||||
body->dir = Vector3Lerp(body->dir, desired_dir, CONTROL * delta);
|
||||
|
||||
float decel = body->isGrounded ? FRICTION : AIR_DRAG;
|
||||
Vector3 hvel = (Vector3){
|
||||
body->velocity.x * decel,
|
||||
0.f,
|
||||
body->velocity.z * decel
|
||||
};
|
||||
|
||||
float hvel_length = Vector3Length(hvel); // a.k.a. magnitude
|
||||
if (hvel_length < 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 max_speed = crouchHold ? CROUCH_SPEED : MAX_SPEED;
|
||||
float accel = Clamp(max_speed - 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.f)
|
||||
{
|
||||
body->position.y = 0.f;
|
||||
body->velocity.y = 0.f;
|
||||
body->isGrounded = true; // <= enables jumping
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateCameraAngle()
|
||||
{
|
||||
const Vector3 up = (Vector3){ 0.f, 1.f, 0.f };
|
||||
const Vector3 targetOffset = (Vector3){ 0.f, 0.f, -1.f };
|
||||
|
||||
/* Left & 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 & Down */
|
||||
Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up));
|
||||
|
||||
// Rotate view vector around right axis
|
||||
Vector3 pitch = Vector3RotateByAxisAngle(yaw, right, -lookRotation.y - lean.y);
|
||||
|
||||
// Head animation
|
||||
// Rotate up direction around forward axis
|
||||
float _sin = sin(headTimer * PI);
|
||||
float _cos = cos(headTimer * PI);
|
||||
const float stepRotation = 0.01f;
|
||||
camera.up = Vector3RotateByAxisAngle(up, pitch, _sin * stepRotation + lean.x);
|
||||
|
||||
/* BOB */
|
||||
const float bobSide = 0.1f;
|
||||
const float bobUp = 0.15f;
|
||||
Vector3 bobbing = Vector3Scale(right, _sin * bobSide);
|
||||
bobbing.y = fabsf(_cos * bobUp);
|
||||
camera.position = Vector3Add(camera.position, Vector3Scale(bobbing, walkLerp));
|
||||
|
||||
camera.target = Vector3Add(camera.position, pitch);
|
||||
}
|
||||
|
||||
|
||||
void DrawLevel()
|
||||
{
|
||||
const int floorExtent = 25;
|
||||
const float tileSize = 5.f;
|
||||
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.f, y * tileSize},
|
||||
(Vector2) {tileSize, tileSize}, tileColor1);
|
||||
}
|
||||
else if(!(y & 1) && !(x & 1))
|
||||
{
|
||||
DrawPlane((Vector3) { x * tileSize, 0.f, y * tileSize},
|
||||
(Vector2) {tileSize, tileSize}, LIGHTGRAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const Vector3 towerSize = (Vector3){ 16.f, 32.f, 16.f };
|
||||
const Color towerColor = (Color){ 150, 200, 200, 255 };
|
||||
|
||||
Vector3 towerPos = (Vector3){ 16.f, 16.f, 16.f };
|
||||
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.f, 300.f, 0.f }, 100.f, (Color) { 255, 0, 0, 255 });
|
||||
}
|
BIN
examples/core/core_3d_fps_controller.png
Normal file
BIN
examples/core/core_3d_fps_controller.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.9 KiB |
@@ -54,7 +54,7 @@ int main(void)
|
||||
player.position = (Vector2){ 400, 280 };
|
||||
player.speed = 0;
|
||||
player.canJump = false;
|
||||
|
||||
|
||||
// Define environment elements (platforms)
|
||||
EnvElement envElements[MAX_ENVIRONMENT_ELEMENTS] = {
|
||||
{{ 0, 0, 1000, 400 }, 0, LIGHTGRAY },
|
||||
@@ -70,13 +70,13 @@ int main(void)
|
||||
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
||||
camera.rotation = 0.0f;
|
||||
camera.zoom = 1.0f;
|
||||
|
||||
|
||||
// Automation events
|
||||
AutomationEventList aelist = LoadAutomationEventList(0); // Initialize list of automation events to record new events
|
||||
SetAutomationEventList(&aelist);
|
||||
bool eventRecording = false;
|
||||
bool eventPlaying = false;
|
||||
|
||||
|
||||
unsigned int frameCounter = 0;
|
||||
unsigned int playFrameCounter = 0;
|
||||
unsigned int currentPlayFrame = 0;
|
||||
@@ -90,7 +90,7 @@ int main(void)
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
float deltaTime = 0.015f;//GetFrameTime();
|
||||
|
||||
|
||||
// Dropped files logic
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsFileDropped())
|
||||
@@ -102,14 +102,14 @@ int main(void)
|
||||
{
|
||||
UnloadAutomationEventList(aelist);
|
||||
aelist = LoadAutomationEventList(droppedFiles.paths[0]);
|
||||
|
||||
|
||||
eventRecording = false;
|
||||
|
||||
|
||||
// Reset scene state to play
|
||||
eventPlaying = true;
|
||||
playFrameCounter = 0;
|
||||
currentPlayFrame = 0;
|
||||
|
||||
|
||||
player.position = (Vector2){ 400, 280 };
|
||||
player.speed = 0;
|
||||
player.canJump = false;
|
||||
@@ -174,7 +174,7 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// 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
|
||||
//----------------------------------------------------------------------------------
|
||||
if (eventPlaying)
|
||||
@@ -228,7 +228,7 @@ int main(void)
|
||||
if (min.x > 0) camera.offset.x = screenWidth/2 - min.x;
|
||||
if (min.y > 0) camera.offset.y = screenHeight/2 - min.y;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Events management
|
||||
if (IsKeyPressed(KEY_S)) // Toggle events recording
|
||||
{
|
||||
@@ -238,12 +238,12 @@ int main(void)
|
||||
{
|
||||
StopAutomationEventRecording();
|
||||
eventRecording = false;
|
||||
|
||||
|
||||
ExportAutomationEventList(aelist, "automation.rae");
|
||||
|
||||
|
||||
TraceLog(LOG_INFO, "RECORDED FRAMES: %i", aelist.count);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
SetAutomationEventBaseFrame(180);
|
||||
StartAutomationEventRecording();
|
||||
@@ -293,7 +293,7 @@ int main(void)
|
||||
DrawRectangleRec((Rectangle){ player.position.x - 20, player.position.y - 40, 40, 40 }, RED);
|
||||
|
||||
EndMode2D();
|
||||
|
||||
|
||||
// Draw game controls
|
||||
DrawRectangle(10, 10, 290, 145, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines(10, 10, 290, 145, Fade(BLUE, 0.8f));
|
||||
@@ -323,7 +323,7 @@ int main(void)
|
||||
|
||||
if (((frameCounter/15)%2) == 1) DrawText(TextFormat("PLAYING RECORDED EVENTS... [%i]", currentPlayFrame), 50, 170, 10, DARKGREEN);
|
||||
}
|
||||
|
||||
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
BIN
examples/core/core_basic_window_web.png
Normal file
BIN
examples/core/core_basic_window_web.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
@@ -12,7 +12,7 @@
|
||||
* 4. PollInputEvents()
|
||||
*
|
||||
* 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:
|
||||
* - GetFrameTime()
|
||||
@@ -39,7 +39,7 @@ int main(void)
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - custom frame control");
|
||||
|
||||
// Custom timming variables
|
||||
@@ -48,11 +48,11 @@ int main(void)
|
||||
double updateDrawTime = 0.0; // Update + Draw time
|
||||
double waitTime = 0.0; // Wait time (if target fps required)
|
||||
float deltaTime = 0.0f; // Frame time (Update + Draw + Wait time)
|
||||
|
||||
|
||||
float timeCounter = 0.0f; // Accumulative time counter (seconds)
|
||||
float position = 0.0f; // Circle position
|
||||
bool pause = false; // Pause control flag
|
||||
|
||||
|
||||
int targetFPS = 60; // Our initial target fps
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@@ -61,13 +61,15 @@ int main(void)
|
||||
{
|
||||
// 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_UP)) targetFPS += 20;
|
||||
else if (IsKeyPressed(KEY_DOWN)) targetFPS -= 20;
|
||||
|
||||
|
||||
if (targetFPS < 0) targetFPS = 0;
|
||||
|
||||
if (!pause)
|
||||
@@ -76,6 +78,10 @@ int main(void)
|
||||
if (position >= GetScreenWidth()) position = 0;
|
||||
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
|
||||
@@ -85,12 +91,12 @@ int main(void)
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
for (int i = 0; i < GetScreenWidth()/200; i++) DrawRectangle(200*i, 0, 1, GetScreenHeight(), SKYBLUE);
|
||||
|
||||
|
||||
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("PosX: %03.0f", position), (int)position - 50, GetScreenHeight()/2 + 40, 20, BLACK);
|
||||
|
||||
|
||||
DrawText("Circle is moving at a constant 200 pixels/sec,\nindependently of the frame rate.", 10, 10, 20, DARKGRAY);
|
||||
DrawText("PRESS SPACE to PAUSE MOVEMENT", 10, GetScreenHeight() - 60, 20, GRAY);
|
||||
DrawText("PRESS UP | DOWN to CHANGE TARGET FPS", 10, GetScreenHeight() - 30, 20, GRAY);
|
||||
@@ -102,18 +108,18 @@ int main(void)
|
||||
|
||||
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
|
||||
|
||||
SwapScreenBuffer(); // Flip the back buffer to screen (front buffer)
|
||||
|
||||
|
||||
currentTime = GetTime();
|
||||
updateDrawTime = currentTime - previousTime;
|
||||
|
||||
|
||||
if (targetFPS > 0) // We want a fixed frame rate
|
||||
{
|
||||
waitTime = (1.0f/(float)targetFPS) - updateDrawTime;
|
||||
if (waitTime > 0.0)
|
||||
if (waitTime > 0.0)
|
||||
{
|
||||
WaitTime((float)waitTime);
|
||||
currentTime = GetTime();
|
||||
|
@@ -13,12 +13,10 @@
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
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);
|
||||
}
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module functions declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color);
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
@@ -31,10 +29,20 @@ int main(void)
|
||||
const int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_RESIZABLE);
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi");
|
||||
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
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@@ -44,67 +52,60 @@ int main(void)
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
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();
|
||||
Vector2 dpiScale = GetWindowScaleDPI();
|
||||
cellSizePx = ((float)cellSize)/dpiScale.x;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
Vector2 dpiScale = GetWindowScaleDPI();
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
int windowCenter = GetScreenWidth() / 2;
|
||||
int windowCenter = GetScreenWidth()/2;
|
||||
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);
|
||||
|
||||
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("Monitor: %d/%d ([N] next monitor)", currentMonitor+1, monitorCount), windowCenter, 70, 20, LIGHTGRAY);
|
||||
DrawTextCenter(TextFormat("Window is %d \"logical points\" wide", GetScreenWidth()), windowCenter, logicalGridDescY, 20, ORANGE);
|
||||
|
||||
bool odd = true;
|
||||
for (int i = cellSize; i < GetScreenWidth(); i += cellSize, odd = !odd) {
|
||||
if (odd) {
|
||||
DrawRectangle(i, logicalGridTop, cellSize, logicalGridBottom-logicalGridTop, ORANGE);
|
||||
}
|
||||
DrawTextCenter(TextFormat("%d", i), i, logicalGridLabelY, 12, LIGHTGRAY);
|
||||
for (int i = cellSize; i < GetScreenWidth(); i += cellSize, odd = !odd)
|
||||
{
|
||||
if (odd) DrawRectangle(i, logicalGridTop, cellSize, logicalGridBottom-logicalGridTop, ORANGE);
|
||||
|
||||
DrawTextCenter(TextFormat("%d", i), i, logicalGridLabelY, 10, LIGHTGRAY);
|
||||
DrawLine(i, logicalGridLabelY + 10, i, logicalGridBottom, GRAY);
|
||||
}
|
||||
|
||||
odd = true;
|
||||
const int minTextSpace = 30;
|
||||
int last_text_x = -minTextSpace;
|
||||
for (int i = cellSize; i < GetRenderWidth(); i += cellSize, odd = !odd) {
|
||||
int x = (int)(((float)i) / dpiScale.x);
|
||||
if (odd) {
|
||||
DrawRectangle(x, pixelGridTop, (int)cellSizePx, pixelGridBottom-pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 });
|
||||
}
|
||||
int lastTextX = -minTextSpace;
|
||||
for (int i = cellSize; i < GetRenderWidth(); i += cellSize, odd = !odd)
|
||||
{
|
||||
int x = (int)(((float)i)/dpiScale.x);
|
||||
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);
|
||||
if (x - last_text_x >= minTextSpace) {
|
||||
DrawTextCenter(TextFormat("%d", i), x, pixelGridLabelY, 12, LIGHTGRAY);
|
||||
last_text_x = x;
|
||||
|
||||
if ((x - lastTextX) >= minTextSpace)
|
||||
{
|
||||
DrawTextCenter(TextFormat("%d", i), x, pixelGridLabelY, 10, LIGHTGRAY);
|
||||
lastTextX = x;
|
||||
}
|
||||
}
|
||||
|
||||
DrawTextCenter(TextFormat("Window is %d \"physical pixels\" wide", GetRenderWidth()), windowCenter, pixelGridDescY, 20, BLUE);
|
||||
|
||||
{
|
||||
const char *text = "Can you see this?";
|
||||
Vector2 size = MeasureTextEx(GetFontDefault(), text, 16, 3);
|
||||
Vector2 pos = (Vector2){GetScreenWidth() - size.x - 5, GetScreenHeight() - size.y - 5};
|
||||
DrawTextEx(GetFontDefault(), text, pos, 16, 3, LIGHTGRAY);
|
||||
}
|
||||
const char *text = "Can you see this?";
|
||||
Vector2 size = MeasureTextEx(GetFontDefault(), text, 20, 3);
|
||||
Vector2 pos = (Vector2){ GetScreenWidth() - size.x - 5, GetScreenHeight() - size.y - 5 };
|
||||
DrawTextEx(GetFontDefault(), text, pos, 20, 3, LIGHTGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
@@ -117,3 +118,13 @@ int main(void)
|
||||
|
||||
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);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -52,7 +52,7 @@ int main(void)
|
||||
isCursorHidden = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ballPosition = GetMousePosition();
|
||||
|
||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) ballColor = MAROON;
|
||||
|
@@ -54,7 +54,7 @@ int main(void)
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
|
||||
for (int i = 0; i < tCount; ++i)
|
||||
{
|
||||
// Make sure point is not (0, 0) as this means there is no touch for it
|
||||
|
@@ -7,7 +7,7 @@
|
||||
* Example originally created with raylib 5.0, last time updated with raylib 5.0
|
||||
*
|
||||
* Example create by GreenSnakeLinux (@GreenSnakeLinux),
|
||||
* lighter by oblerion (@oblerion) and
|
||||
* lighter by oblerion (@oblerion) and
|
||||
* reviewed by Ramon Santamaria (@raysan5) and
|
||||
* improved by danilwhale (@danilwhale)
|
||||
*
|
||||
|
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Example originally created with raylib 2.5, last time updated with raylib 3.0
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - Generates a random sequence
|
||||
* raylib [core] example - generate random sequence
|
||||
*
|
||||
* Example complexity rating: [★☆☆☆] 1/4
|
||||
*
|
||||
@@ -43,7 +43,7 @@ int main(void)
|
||||
const int screenWidth = 800;
|
||||
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;
|
||||
float rectSize = (float)screenWidth/rectCount;
|
||||
@@ -118,8 +118,8 @@ int main(void)
|
||||
//------------------------------------------------------------------------------------
|
||||
static Color GenerateRandomColor()
|
||||
{
|
||||
Color color = {
|
||||
GetRandomValue(0, 255),
|
||||
Color color = {
|
||||
GetRandomValue(0, 255),
|
||||
GetRandomValue(0, 255),
|
||||
GetRandomValue(0, 255),
|
||||
255
|
||||
@@ -138,20 +138,20 @@ static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWid
|
||||
for (int i = 0; i < rectCount; i++)
|
||||
{
|
||||
int rectHeight = (int)Remap((float)seq[i], 0, rectCount - 1, 0, screenHeight);
|
||||
|
||||
|
||||
rectangles[i].c = GenerateRandomColor();
|
||||
rectangles[i].r = CLITERAL(Rectangle){ startX + i*rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight };
|
||||
}
|
||||
|
||||
|
||||
UnloadRandomSequence(seq);
|
||||
|
||||
|
||||
return rectangles;
|
||||
}
|
||||
|
||||
static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount)
|
||||
{
|
||||
int *seq = LoadRandomSequence(rectCount, 0, rectCount - 1);
|
||||
|
||||
|
||||
for (int i1 = 0; i1 < rectCount; i1++)
|
||||
{
|
||||
ColorRect *r1 = &rectangles[i1];
|
||||
@@ -166,16 +166,16 @@ static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount)
|
||||
r2->r.height = tmp.r.height;
|
||||
r2->r.y = tmp.r.y;
|
||||
}
|
||||
|
||||
|
||||
UnloadRandomSequence(seq);
|
||||
}
|
||||
|
||||
static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, int posY, int fontSize, Color color)
|
||||
{
|
||||
int spaceSize = MeasureText(" ", fontSize);
|
||||
int pressSize = MeasureText("Press", fontSize);
|
||||
int keySize = MeasureText(key, fontSize);
|
||||
int textSize = MeasureText(text, fontSize);
|
||||
int spaceSize = MeasureText(" ", fontSize);
|
||||
int pressSize = MeasureText("Press", fontSize);
|
||||
int keySize = MeasureText(key, fontSize);
|
||||
int textSize = MeasureText(text, fontSize);
|
||||
int textSizeCurrent = 0;
|
||||
|
||||
DrawText("Press", posX, posY, fontSize, color);
|
||||
|
@@ -30,9 +30,9 @@ int main(void)
|
||||
// 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)
|
||||
|
||||
|
||||
unsigned int framesCounter = 0; // Variable used to count frames
|
||||
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* Example originally created with raylib 3.7, last time updated with raylib 4.0
|
||||
*
|
||||
*
|
||||
* Example contributed by Giancamillo Alessandroni (@NotManyIdeasDev) and
|
||||
* reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
@@ -43,7 +43,8 @@ int main(void)
|
||||
Camera2D screenSpaceCamera = { 0 }; // Smoothing camera
|
||||
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 rec02 = { 90.0f, 55.0f, 30.0f, 10.0f };
|
||||
|
@@ -61,7 +61,7 @@ int main(void)
|
||||
VrStereoConfig config = LoadVrStereoConfig(device);
|
||||
|
||||
// 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
|
||||
SetShaderValue(distortion, GetShaderLocation(distortion, "leftLensCenter"),
|
||||
@@ -127,7 +127,7 @@ int main(void)
|
||||
EndMode3D();
|
||||
EndVrStereoMode();
|
||||
EndTextureMode();
|
||||
|
||||
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
BeginShaderMode(distortion);
|
||||
|
@@ -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("Virtual Mouse: [%i , %i]", (int)virtualMouse.x, (int)virtualMouse.y), 350, 55, 20, YELLOW);
|
||||
EndTextureMode();
|
||||
|
||||
|
||||
BeginDrawing();
|
||||
ClearBackground(BLACK); // Clear screen background
|
||||
|
||||
|
@@ -26,9 +26,9 @@ int main()
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - window should close");
|
||||
|
||||
|
||||
SetExitKey(KEY_NULL); // Disable KEY_ESCAPE to close window, X-button still works
|
||||
|
||||
|
||||
bool exitWindowRequested = false; // Flag to request 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
|
||||
if (WindowShouldClose() || IsKeyPressed(KEY_ESCAPE)) exitWindowRequested = true;
|
||||
|
||||
|
||||
if (exitWindowRequested)
|
||||
{
|
||||
// A request for close window has been issued, we can save data before closing
|
||||
// or just show a message asking for confirmation
|
||||
|
||||
|
||||
if (IsKeyPressed(KEY_Y)) exitWindow = true;
|
||||
else if (IsKeyPressed(KEY_N)) exitWindowRequested = false;
|
||||
}
|
||||
|
@@ -70,7 +70,7 @@ int main(void)
|
||||
EndMode3D();
|
||||
|
||||
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("Text 2d should be always on top of the cube", 10, 40, 20, GRAY);
|
||||
|
||||
|
BIN
examples/core/resources/huh_jump.wav
Normal file
BIN
examples/core/resources/huh_jump.wav
Normal file
Binary file not shown.
50
examples/core/resources/shaders/glsl120/distortion.fs
Normal file
50
examples/core/resources/shaders/glsl120/distortion.fs
Normal 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);
|
||||
}
|
||||
}
|
169
examples/examples_list.txt
Normal file
169
examples/examples_list.txt
Normal file
@@ -0,0 +1,169 @@
|
||||
#
|
||||
# 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_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_normalmap;⭐️⭐️⭐️⭐️;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
|
@@ -6,30 +6,30 @@
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
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.
|
||||
Short description should also be used on the title of the window.
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
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.
|
||||
Don't abuse with comments, try to be clear and impersonal on the comments.
|
||||
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
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
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!
|
||||
|
||||
9. In case of additional information is required, just come to raylib Discord channel: example-contributions
|
||||
@@ -37,11 +37,11 @@
|
||||
10. Have fun!
|
||||
|
||||
The following files should be updated when adding a new example, it's planned to create some
|
||||
script to automatize this process but not available yet.
|
||||
script to automatize this process but not available yet
|
||||
|
||||
- raylib/examples/<category>/<category>_example_name.c
|
||||
- raylib/examples/<category>/<category>_example_name.png
|
||||
- raylib/examples/<category>/resources/*.*
|
||||
- raylib/examples/<category>/resources/..
|
||||
- raylib/examples/Makefile
|
||||
- raylib/examples/Makefile.Web
|
||||
- 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,
|
||||
* 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);
|
||||
|
||||
// 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();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
BIN
examples/examples_template.png
Normal file
BIN
examples/examples_template.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
@@ -15,9 +15,9 @@
|
||||
*
|
||||
********************************************************************************************
|
||||
*
|
||||
* 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
|
||||
* set to 0. Scaling can be done from the export menu.
|
||||
* 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
|
||||
* set to 0. Scaling can be done from the export menu
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
@@ -40,7 +40,7 @@ int main(void)
|
||||
Vector3 billPositionStatic = { 0.0f, 2.0f, 0.0f }; // Position of static 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 };
|
||||
|
||||
// NOTE: Billboard locked on axis-Y
|
||||
@@ -54,7 +54,7 @@ int main(void)
|
||||
Vector2 origin = Vector2Scale(size, 0.5f);
|
||||
|
||||
// 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 distanceRotating;
|
||||
float rotation = 0.0f;
|
||||
@@ -85,17 +85,17 @@ int main(void)
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
// Draw order matters!
|
||||
if (distanceStatic > distanceRotating)
|
||||
if (distanceStatic > distanceRotating)
|
||||
{
|
||||
DrawBillboard(camera, bill, billPositionStatic, 2.0f, WHITE);
|
||||
DrawBillboardPro(camera, bill, source, billPositionRotating, billUp, size, origin, rotation, WHITE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawBillboardPro(camera, bill, source, billPositionRotating, billUp, size, origin, rotation, WHITE);
|
||||
DrawBillboard(camera, bill, billPositionStatic, 2.0f, WHITE);
|
||||
}
|
||||
|
||||
|
||||
EndMode3D();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
* raylib [core] example - Using bones as socket for calculating the positioning of something
|
||||
*
|
||||
* Example complexity rating: [★★★★] 4/4
|
||||
*
|
||||
*
|
||||
* 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)
|
||||
@@ -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_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
|
||||
|
||||
// Load gltf model animations
|
||||
@@ -63,7 +63,7 @@ int main(void)
|
||||
// indices of bones for sockets
|
||||
int boneSocketIndex[BONE_SOCKETS] = { -1, -1, -1 };
|
||||
|
||||
// search bones for sockets
|
||||
// search bones for sockets
|
||||
for (int i = 0; i < characterModel.boneCount; i++)
|
||||
{
|
||||
if (TextIsEqual(characterModel.bones[i].name, "socket_hat"))
|
||||
@@ -71,13 +71,13 @@ int main(void)
|
||||
boneSocketIndex[BONE_SOCKET_HAT] = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (TextIsEqual(characterModel.bones[i].name, "socket_hand_R"))
|
||||
{
|
||||
boneSocketIndex[BONE_SOCKET_HAND_R] = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (TextIsEqual(characterModel.bones[i].name, "socket_hand_L"))
|
||||
{
|
||||
boneSocketIndex[BONE_SOCKET_HAND_L] = i;
|
||||
@@ -99,7 +99,7 @@ int main(void)
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera, CAMERA_THIRD_PERSON);
|
||||
|
||||
|
||||
// Rotate character
|
||||
if (IsKeyDown(KEY_F)) angle = (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_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];
|
||||
|
||||
|
||||
// Update model animation
|
||||
ModelAnimation anim = modelAnimations[animIndex];
|
||||
animCurrentFrame = (animCurrentFrame + 1)%anim.frameCount;
|
||||
@@ -140,7 +140,7 @@ int main(void)
|
||||
Transform *transform = &anim.framePoses[animCurrentFrame][boneSocketIndex[i]];
|
||||
Quaternion inRotation = characterModel.bindPose[boneSocketIndex[i]].rotation;
|
||||
Quaternion outRotation = transform->rotation;
|
||||
|
||||
|
||||
// Calculate socket rotation (angle between bone in initial pose and same bone in current animation frame)
|
||||
Quaternion rotate = QuaternionMultiply(outRotation, QuaternionInvert(inRotation));
|
||||
Matrix matrixTransform = QuaternionToMatrix(rotate);
|
||||
@@ -148,7 +148,7 @@ int main(void)
|
||||
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)
|
||||
matrixTransform = MatrixMultiply(matrixTransform, characterModel.transform);
|
||||
|
||||
|
||||
// Draw mesh at socket position with socket angle rotation
|
||||
DrawMesh(equipModel[i].meshes[0], equipModel[i].materials[1], matrixTransform);
|
||||
}
|
||||
@@ -168,7 +168,7 @@ int main(void)
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadModelAnimations(modelAnimations, animsCount);
|
||||
UnloadModel(characterModel); // Unload character model and meshes/material
|
||||
|
||||
|
||||
// Unload equipment model and meshes/material
|
||||
for (int i = 0; i < BONE_SOCKETS; i++) UnloadModel(equipModel[i]);
|
||||
|
||||
|
@@ -42,7 +42,7 @@ int main(void)
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 45.0f;
|
||||
camera.projection = CAMERA_PERSPECTIVE;
|
||||
|
||||
|
||||
// Load texture to be applied to the cubes sides
|
||||
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png");
|
||||
|
||||
@@ -69,7 +69,7 @@ int main(void)
|
||||
DrawCubeTexture(texture, (Vector3){ -2.0f, 2.0f, 0.0f }, 2.0f, 4.0f, 2.0f, WHITE);
|
||||
|
||||
// Draw cube with an applied texture, but only a defined rectangle piece of the texture
|
||||
DrawCubeTextureRec(texture, (Rectangle){ 0.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);
|
||||
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
@@ -85,7 +85,7 @@ int main(void)
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Unload texture
|
||||
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@@ -171,7 +171,7 @@ void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, f
|
||||
rlSetTexture(texture.id);
|
||||
|
||||
// We calculate the normalized texture coordinates for the desired texture-source-rectangle
|
||||
// It means converting from (tex.width, tex.height) coordinates to [0.0f, 1.0f] equivalent
|
||||
// It means converting from (tex.width, tex.height) coordinates to [0.0f, 1.0f] equivalent
|
||||
rlBegin(RL_QUADS);
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
* raylib [core] example - Doing skinning on the gpu using a vertex shader
|
||||
*
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
*
|
||||
* 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)
|
||||
@@ -12,7 +12,7 @@
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2024-2025 Daniel Holden (@orangeduck)
|
||||
*
|
||||
*
|
||||
* Note: Due to limitations in the Apple OpenGL driver, this feature does not work on MacOS
|
||||
*
|
||||
********************************************************************************************/
|
||||
@@ -49,13 +49,13 @@ int main(void)
|
||||
|
||||
// Load gltf model
|
||||
Model characterModel = LoadModel("resources/models/gltf/greenman.glb"); // Load character model
|
||||
|
||||
|
||||
// Load skinning shader
|
||||
Shader skinningShader = LoadShader(TextFormat("resources/shaders/glsl%i/skinning.vs", GLSL_VERSION),
|
||||
TextFormat("resources/shaders/glsl%i/skinning.fs", GLSL_VERSION));
|
||||
|
||||
|
||||
characterModel.materials[1].shader = skinningShader;
|
||||
|
||||
|
||||
// Load gltf model animations
|
||||
int animsCount = 0;
|
||||
unsigned int animIndex = 0;
|
||||
@@ -75,7 +75,7 @@ int main(void)
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera, CAMERA_THIRD_PERSON);
|
||||
|
||||
|
||||
// Select current animation
|
||||
if (IsKeyPressed(KEY_T)) animIndex = (animIndex + 1)%animsCount;
|
||||
else if (IsKeyPressed(KEY_G)) animIndex = (animIndex + animsCount - 1)%animsCount;
|
||||
@@ -94,12 +94,12 @@ int main(void)
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginMode3D(camera);
|
||||
|
||||
|
||||
// Draw character mesh, pose calculation is done in shader (GPU skinning)
|
||||
DrawMesh(characterModel.meshes[0], characterModel.materials[1], characterModel.transform);
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
|
||||
EndMode3D();
|
||||
|
||||
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
|
||||
UnloadModel(characterModel); // Unload model and meshes/material
|
||||
UnloadShader(skinningShader); // Unload GPU skinning shader
|
||||
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
@@ -7,11 +7,11 @@
|
||||
* NOTE: raylib supports multiple models file formats:
|
||||
*
|
||||
* - 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
|
||||
* 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,
|
||||
* raylib can load .iqm animations.
|
||||
* raylib can load .iqm animations
|
||||
* - VOX > Binary file format. MagikaVoxel mesh format:
|
||||
* https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox.txt
|
||||
* - M3D > Binary file format. Model 3D format:
|
||||
|
@@ -45,7 +45,7 @@ int main(void)
|
||||
// Load gltf model
|
||||
Model model = LoadModel("resources/models/gltf/robot.glb");
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
|
||||
// Load gltf model animations
|
||||
int animsCount = 0;
|
||||
unsigned int animIndex = 0;
|
||||
|
@@ -119,7 +119,7 @@ int main(void)
|
||||
// without a -1, we would always draw a cube at the origin
|
||||
for (int i = 0; i < model.boneCount - 1; i++)
|
||||
{
|
||||
// By default the model is loaded in bind-pose by LoadModel().
|
||||
// By default the model is loaded in bind-pose by LoadModel()
|
||||
// But if UpdateModelAnimation() has been called at least once
|
||||
// then the model is already in animation pose, so we need the animated skeleton
|
||||
if (!animPlaying || !animsCount)
|
||||
|
@@ -40,7 +40,7 @@ int main(void)
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
const char* voxFileNames[] = {
|
||||
const char *voxFileNames[] = {
|
||||
"resources/models/vox/chr_knight.vox",
|
||||
"resources/models/vox/chr_sword.vox",
|
||||
"resources/models/vox/monu9.vox",
|
||||
@@ -57,24 +57,23 @@ int main(void)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Load MagicaVoxel files
|
||||
Model models[MAX_VOX_FILES] = { 0 };
|
||||
|
||||
for (int i = 0; i < MAX_VOX_FILES; i++)
|
||||
{
|
||||
// Load VOX file and measure time
|
||||
double t0 = GetTime() * 1000.0;
|
||||
double t0 = GetTime()*1000.0;
|
||||
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));
|
||||
|
||||
// Compute model translation matrix to center model on draw position (0, 0 , 0)
|
||||
BoundingBox bb = GetModelBoundingBox(models[i]);
|
||||
Vector3 center = { 0 };
|
||||
center.x = bb.min.x + (((bb.max.x - bb.min.x) / 2));
|
||||
center.z = bb.min.z + (((bb.max.z - bb.min.z) / 2));
|
||||
center.x = bb.min.x + (((bb.max.x - bb.min.x)/2));
|
||||
center.z = bb.min.z + (((bb.max.z - bb.min.z)/2));
|
||||
|
||||
Matrix matTranslate = MatrixTranslate(-center.x, 0, -center.z);
|
||||
models[i].transform = matTranslate;
|
||||
@@ -82,14 +81,13 @@ int main(void)
|
||||
|
||||
int currentModel = 0;
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Load voxel shader
|
||||
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/voxel_lighting.vs", GLSL_VERSION),
|
||||
TextFormat("resources/shaders/glsl%i/voxel_lighting.fs", GLSL_VERSION));
|
||||
|
||||
// Get some required shader locations
|
||||
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
|
||||
//shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel");
|
||||
|
||||
|
@@ -47,17 +47,8 @@ int main(void)
|
||||
models[6] = LoadModelFromMesh(GenMeshKnot(1.0f, 2.0f, 16, 128));
|
||||
models[7] = LoadModelFromMesh(GenMeshPoly(5, 2.0f));
|
||||
models[8] = LoadModelFromMesh(GenMeshCustom());
|
||||
|
||||
// Generated meshes could be exported as .obj files
|
||||
//ExportMesh(models[0].meshes[0], "plane.obj");
|
||||
//ExportMesh(models[1].meshes[0], "cube.obj");
|
||||
//ExportMesh(models[2].meshes[0], "sphere.obj");
|
||||
//ExportMesh(models[3].meshes[0], "hemisphere.obj");
|
||||
//ExportMesh(models[4].meshes[0], "cylinder.obj");
|
||||
//ExportMesh(models[5].meshes[0], "torus.obj");
|
||||
//ExportMesh(models[6].meshes[0], "knot.obj");
|
||||
//ExportMesh(models[7].meshes[0], "poly.obj");
|
||||
//ExportMesh(models[8].meshes[0], "custom.obj");
|
||||
|
||||
// NOTE: Generated meshes could be exported using ExportMesh()
|
||||
|
||||
// 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;
|
||||
|
@@ -137,7 +137,7 @@ int main(void)
|
||||
RayCollision meshHitInfo = { 0 };
|
||||
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
|
||||
// model drawn multiple times with multiple transforms
|
||||
meshHitInfo = GetRayCollisionMesh(ray, tower.meshes[m], tower.transform);
|
||||
@@ -145,7 +145,7 @@ int main(void)
|
||||
{
|
||||
// Save the closest hit mesh
|
||||
if ((!collision.hit) || (collision.distance > meshHitInfo.distance)) collision = meshHitInfo;
|
||||
|
||||
|
||||
break; // Stop once one mesh collision is detected, the colliding mesh is m
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ int main()
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - point rendering");
|
||||
|
||||
Camera camera = {
|
||||
@@ -50,10 +50,10 @@ int main()
|
||||
bool useDrawModelPoints = true;
|
||||
bool numPointsChanged = false;
|
||||
int numPoints = 1000;
|
||||
|
||||
|
||||
Mesh mesh = GenMeshPoints(numPoints);
|
||||
Model model = LoadModelFromMesh(mesh);
|
||||
|
||||
|
||||
//SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@@ -114,14 +114,14 @@ int main()
|
||||
.b = mesh.colors[i*4 + 2],
|
||||
.a = mesh.colors[i*4 + 3],
|
||||
};
|
||||
|
||||
|
||||
DrawPoint3D(pos, color);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw a unit sphere for reference
|
||||
DrawSphereWires(position, 1.0f, 10, 10, YELLOW);
|
||||
|
||||
|
||||
EndMode3D();
|
||||
|
||||
// Draw UI text
|
||||
@@ -129,12 +129,12 @@ int main()
|
||||
DrawText("Up - increase points", 20, 70, 20, WHITE);
|
||||
DrawText("Down - decrease points", 20, 100, 20, WHITE);
|
||||
DrawText("Space - drawing function", 20, 130, 20, WHITE);
|
||||
|
||||
|
||||
if (useDrawModelPoints) DrawText("Using: DrawModelPoints()", 20, 160, 20, GREEN);
|
||||
else DrawText("Using: DrawPoint3D()", 20, 160, 20, RED);
|
||||
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
@@ -151,7 +151,7 @@ int main()
|
||||
// Generate a spherical point cloud
|
||||
static Mesh GenMeshPoints(int numPoints)
|
||||
{
|
||||
Mesh mesh = {
|
||||
Mesh mesh = {
|
||||
.triangleCount = 1,
|
||||
.vertexCount = numPoints,
|
||||
.vertices = (float *)MemAlloc(numPoints*3*sizeof(float)),
|
||||
@@ -164,13 +164,13 @@ static Mesh GenMeshPoints(int numPoints)
|
||||
float theta = ((float)PI*rand())/RAND_MAX;
|
||||
float phi = (2.0f*PI*rand())/RAND_MAX;
|
||||
float r = (10.0f*rand())/RAND_MAX;
|
||||
|
||||
|
||||
mesh.vertices[i*3 + 0] = r*sinf(theta)*cosf(phi);
|
||||
mesh.vertices[i*3 + 1] = r*sinf(theta)*sinf(phi);
|
||||
mesh.vertices[i*3 + 2] = r*cosf(theta);
|
||||
|
||||
|
||||
Color color = ColorFromHSV(r*360.0f, 1.0f, 1.0f);
|
||||
|
||||
|
||||
mesh.colors[i*4 + 0] = color.r;
|
||||
mesh.colors[i*4 + 1] = color.g;
|
||||
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
|
||||
UploadMesh(&mesh, false);
|
||||
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
@@ -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
|
||||
*
|
||||
@@ -41,7 +41,7 @@ int main(void)
|
||||
const float moonRadius = 0.16f;
|
||||
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
|
||||
Camera camera = { 0 };
|
||||
|
@@ -70,7 +70,7 @@ int main(void)
|
||||
SetShaderValue(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, SHADER_UNIFORM_INT);
|
||||
|
||||
char skyboxFileName[256] = { 0 };
|
||||
|
||||
|
||||
if (useHDR)
|
||||
{
|
||||
TextCopy(skyboxFileName, "resources/dresden_square_2k.hdr");
|
||||
@@ -116,7 +116,7 @@ int main(void)
|
||||
{
|
||||
// Unload current cubemap texture to load new one
|
||||
UnloadTexture(skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture);
|
||||
|
||||
|
||||
if (useHDR)
|
||||
{
|
||||
// Load HDR panorama (sphere) texture
|
||||
@@ -124,7 +124,7 @@ int main(void)
|
||||
|
||||
// Generate cubemap from panorama texture
|
||||
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
|
||||
|
||||
|
||||
UnloadTexture(panorama); // Texture not required anymore, cubemap already generated
|
||||
}
|
||||
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
|
||||
|
||||
|
||||
// Activate and enable texture for drawing to cubemap faces
|
||||
rlActiveTextureSlot(0);
|
||||
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
|
||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_VIEW], fboViews[i]);
|
||||
|
||||
|
||||
// Select the current cubemap face attachment for the fbo
|
||||
// WARNING: This function by default enables->attach->disables fbo!!!
|
||||
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X + i, 0);
|
||||
|
@@ -32,7 +32,7 @@ int main(void)
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - tesseract view");
|
||||
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { 0 };
|
||||
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
|
||||
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 },
|
||||
};
|
||||
|
||||
|
||||
float rotation = 0.0f;
|
||||
Vector3 transformed[16] = { 0 };
|
||||
float wValues[16] = { 0 };
|
||||
@@ -66,7 +66,7 @@ int main(void)
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
rotation = DEG2RAD*45.0f*GetTime();
|
||||
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
Vector4 p = tesseract[i];
|
||||
@@ -92,9 +92,9 @@ int main(void)
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
|
||||
BeginMode3D(camera);
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
@@ -114,7 +114,7 @@ int main(void)
|
||||
}
|
||||
}
|
||||
EndMode3D();
|
||||
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
@@ -91,7 +91,7 @@ int main()
|
||||
};
|
||||
|
||||
// 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
|
||||
Color cubeColor = ColorFromHSV((float)(((x + y + z)*18)%360), 0.75f, 0.9f);
|
||||
|
||||
|
27
examples/models/resources/shaders/glsl120/cubemap.fs
Normal file
27
examples/models/resources/shaders/glsl120/cubemap.fs
Normal 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);
|
||||
}
|
20
examples/models/resources/shaders/glsl120/cubemap.vs
Normal file
20
examples/models/resources/shaders/glsl120/cubemap.vs
Normal file
@@ -0,0 +1,20 @@
|
||||
#version 120
|
||||
|
||||
// Input vertex attributes
|
||||
attribute vec3 vertexPosition;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 matProjection;
|
||||
uniform mat4 matView;
|
||||
|
||||
// Output vertex attributes (to fragment shader)
|
||||
varying vec3 fragPosition;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Calculate fragment position based on model transformations
|
||||
fragPosition = vertexPosition;
|
||||
|
||||
// Calculate final vertex position
|
||||
gl_Position = matProjection*matView*vec4(vertexPosition, 1.0);
|
||||
}
|
18
examples/models/resources/shaders/glsl120/skinning.fs
Normal file
18
examples/models/resources/shaders/glsl120/skinning.fs
Normal file
@@ -0,0 +1,18 @@
|
||||
#version 120
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Fetch color from texture sampler
|
||||
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
||||
|
||||
// Calculate final fragment color
|
||||
gl_FragColor = texelColor*colDiffuse*fragColor;
|
||||
}
|
59
examples/models/resources/shaders/glsl120/skinning.vs
Normal file
59
examples/models/resources/shaders/glsl120/skinning.vs
Normal file
@@ -0,0 +1,59 @@
|
||||
#version 120
|
||||
|
||||
#define MAX_BONE_NUM 64
|
||||
|
||||
// Input vertex attributes
|
||||
attribute vec3 vertexPosition;
|
||||
attribute vec2 vertexTexCoord;
|
||||
attribute vec4 vertexColor;
|
||||
attribute vec4 vertexBoneIds;
|
||||
attribute vec4 vertexBoneWeights;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 mvp;
|
||||
uniform mat4 boneMatrices[MAX_BONE_NUM];
|
||||
|
||||
// Output vertex attributes (to fragment shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
int boneIndex0 = int(vertexBoneIds.x);
|
||||
int boneIndex1 = int(vertexBoneIds.y);
|
||||
int boneIndex2 = int(vertexBoneIds.z);
|
||||
int boneIndex3 = int(vertexBoneIds.w);
|
||||
|
||||
// WARNING: OpenGL ES 2.0 does not support automatic matrix transposing, neither transpose() function
|
||||
mat4 boneMatrixTransposed0 = mat4(
|
||||
vec4(boneMatrices[boneIndex0][0].x, boneMatrices[boneIndex0][1].x, boneMatrices[boneIndex0][2].x, boneMatrices[boneIndex0][3].x),
|
||||
vec4(boneMatrices[boneIndex0][0].y, boneMatrices[boneIndex0][1].y, boneMatrices[boneIndex0][2].y, boneMatrices[boneIndex0][3].y),
|
||||
vec4(boneMatrices[boneIndex0][0].z, boneMatrices[boneIndex0][1].z, boneMatrices[boneIndex0][2].z, boneMatrices[boneIndex0][3].z),
|
||||
vec4(boneMatrices[boneIndex0][0].w, boneMatrices[boneIndex0][1].w, boneMatrices[boneIndex0][2].w, boneMatrices[boneIndex0][3].w));
|
||||
mat4 boneMatrixTransposed1 = mat4(
|
||||
vec4(boneMatrices[boneIndex1][0].x, boneMatrices[boneIndex1][1].x, boneMatrices[boneIndex1][2].x, boneMatrices[boneIndex1][3].x),
|
||||
vec4(boneMatrices[boneIndex1][0].y, boneMatrices[boneIndex1][1].y, boneMatrices[boneIndex1][2].y, boneMatrices[boneIndex1][3].y),
|
||||
vec4(boneMatrices[boneIndex1][0].z, boneMatrices[boneIndex1][1].z, boneMatrices[boneIndex1][2].z, boneMatrices[boneIndex1][3].z),
|
||||
vec4(boneMatrices[boneIndex1][0].w, boneMatrices[boneIndex1][1].w, boneMatrices[boneIndex1][2].w, boneMatrices[boneIndex1][3].w));
|
||||
mat4 boneMatrixTransposed2 = mat4(
|
||||
vec4(boneMatrices[boneIndex2][0].x, boneMatrices[boneIndex2][1].x, boneMatrices[boneIndex2][2].x, boneMatrices[boneIndex2][3].x),
|
||||
vec4(boneMatrices[boneIndex2][0].y, boneMatrices[boneIndex2][1].y, boneMatrices[boneIndex2][2].y, boneMatrices[boneIndex2][3].y),
|
||||
vec4(boneMatrices[boneIndex2][0].z, boneMatrices[boneIndex2][1].z, boneMatrices[boneIndex2][2].z, boneMatrices[boneIndex2][3].z),
|
||||
vec4(boneMatrices[boneIndex2][0].w, boneMatrices[boneIndex2][1].w, boneMatrices[boneIndex2][2].w, boneMatrices[boneIndex2][3].w));
|
||||
mat4 boneMatrixTransposed3 = mat4(
|
||||
vec4(boneMatrices[boneIndex3][0].x, boneMatrices[boneIndex3][1].x, boneMatrices[boneIndex3][2].x, boneMatrices[boneIndex3][3].x),
|
||||
vec4(boneMatrices[boneIndex3][0].y, boneMatrices[boneIndex3][1].y, boneMatrices[boneIndex3][2].y, boneMatrices[boneIndex3][3].y),
|
||||
vec4(boneMatrices[boneIndex3][0].z, boneMatrices[boneIndex3][1].z, boneMatrices[boneIndex3][2].z, boneMatrices[boneIndex3][3].z),
|
||||
vec4(boneMatrices[boneIndex3][0].w, boneMatrices[boneIndex3][1].w, boneMatrices[boneIndex3][2].w, boneMatrices[boneIndex3][3].w));
|
||||
|
||||
vec4 skinnedPosition =
|
||||
vertexBoneWeights.x*(boneMatrixTransposed0*vec4(vertexPosition, 1.0)) +
|
||||
vertexBoneWeights.y*(boneMatrixTransposed1*vec4(vertexPosition, 1.0)) +
|
||||
vertexBoneWeights.z*(boneMatrixTransposed2*vec4(vertexPosition, 1.0)) +
|
||||
vertexBoneWeights.w*(boneMatrixTransposed3*vec4(vertexPosition, 1.0));
|
||||
|
||||
fragTexCoord = vertexTexCoord;
|
||||
fragColor = vertexColor;
|
||||
|
||||
gl_Position = mvp*skinnedPosition;
|
||||
}
|
29
examples/models/resources/shaders/glsl120/skybox.fs
Normal file
29
examples/models/resources/shaders/glsl120/skybox.fs
Normal file
@@ -0,0 +1,29 @@
|
||||
#version 120
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec3 fragPosition;
|
||||
|
||||
// Input uniform values
|
||||
uniform samplerCube environmentMap;
|
||||
uniform bool vflipped;
|
||||
uniform bool doGamma;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Fetch color from texture map
|
||||
vec4 texelColor = vec4(0.0);
|
||||
|
||||
if (vflipped) texelColor = textureCube(environmentMap, vec3(fragPosition.x, -fragPosition.y, fragPosition.z));
|
||||
else texelColor = textureCube(environmentMap, fragPosition);
|
||||
|
||||
vec3 color = vec3(texelColor.x, texelColor.y, texelColor.z);
|
||||
|
||||
if (doGamma) // Apply gamma correction
|
||||
{
|
||||
color = color/(color + vec3(1.0));
|
||||
color = pow(color, vec3(1.0/2.2));
|
||||
}
|
||||
|
||||
// Calculate final fragment color
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
}
|
24
examples/models/resources/shaders/glsl120/skybox.vs
Normal file
24
examples/models/resources/shaders/glsl120/skybox.vs
Normal file
@@ -0,0 +1,24 @@
|
||||
#version 120
|
||||
|
||||
// Input vertex attributes
|
||||
attribute vec3 vertexPosition;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 matProjection;
|
||||
uniform mat4 matView;
|
||||
|
||||
// Output vertex attributes (to fragment shader)
|
||||
varying vec3 fragPosition;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Calculate fragment position based on model transformations
|
||||
fragPosition = vertexPosition;
|
||||
|
||||
// Remove translation from the view matrix
|
||||
mat4 rotView = mat4(mat3(matView));
|
||||
vec4 clipPos = matProjection*rotView*vec4(vertexPosition, 1.0);
|
||||
|
||||
// Calculate final vertex position
|
||||
gl_Position = clipPos;
|
||||
}
|
@@ -221,10 +221,12 @@ int main(void)
|
||||
}
|
||||
|
||||
|
||||
// NoEase function, used when "no easing" is selected for any axis. It just ignores all parameters besides b.
|
||||
// NoEase function, used when "no easing" is selected for any axis
|
||||
// It just ignores all parameters besides b
|
||||
static float NoEase(float t, float b, float c, float d)
|
||||
{
|
||||
float burn = t + b + c + d; // Hack to avoid compiler warning (about unused variables)
|
||||
// Hack to avoid compiler warning (about unused variables)
|
||||
float burn = t + b + c + d;
|
||||
d += burn;
|
||||
|
||||
return b;
|
||||
|
@@ -16,13 +16,13 @@
|
||||
********************************************************************************************
|
||||
*
|
||||
* Mixes raylib and plain OpenGL code to draw a GL_POINTS based particle system. The
|
||||
* primary point is to demonstrate raylib and OpenGL interop.
|
||||
* primary point is to demonstrate raylib and OpenGL interop
|
||||
*
|
||||
* rlgl batched draw operations internally so we have to flush the current batch before
|
||||
* doing our own OpenGL work (rlDrawRenderBatchActive()).
|
||||
* doing our own OpenGL work (rlDrawRenderBatchActive())
|
||||
*
|
||||
* The example also demonstrates how to get the current model view projection matrix of
|
||||
* raylib. That way raylib cameras and so on work as expected.
|
||||
* raylib. That way raylib cameras and so on work as expected
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
@@ -30,18 +30,18 @@
|
||||
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_DESKTOP_SDL)
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
#include "glad_gles2.h" // Required for: OpenGL functionality
|
||||
#include "glad_gles2.h" // Required for: OpenGL functionality
|
||||
#define glGenVertexArrays glGenVertexArraysOES
|
||||
#define glBindVertexArray glBindVertexArrayOES
|
||||
#define glDeleteVertexArrays glDeleteVertexArraysOES
|
||||
#define GLSL_VERSION 100
|
||||
#else
|
||||
#if defined(__APPLE__)
|
||||
#define GL_SILENCE_DEPRECATION // Silence Opengl API deprecation warnings
|
||||
#define GL_SILENCE_DEPRECATION // Silence Opengl API deprecation warnings
|
||||
#include <OpenGL/gl3.h> // OpenGL 3 library for OSX
|
||||
#include <OpenGL/gl3ext.h> // OpenGL 3 extensions library for OSX
|
||||
#else
|
||||
#include "glad.h" // Required for: OpenGL functionality
|
||||
#include "glad.h" // Required for: OpenGL functionality
|
||||
#endif
|
||||
#define GLSL_VERSION 330
|
||||
#endif
|
||||
@@ -71,7 +71,7 @@ int main(void)
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib - point particles");
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - point particles");
|
||||
|
||||
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/point_particle.vs", GLSL_VERSION),
|
||||
TextFormat("resources/shaders/glsl%i/point_particle.fs", GLSL_VERSION));
|
||||
@@ -86,14 +86,14 @@ int main(void)
|
||||
{
|
||||
particles[i].x = (float)GetRandomValue(20, screenWidth - 20);
|
||||
particles[i].y = (float)GetRandomValue(50, screenHeight - 20);
|
||||
|
||||
// Give each particle a slightly different period. But don't spread it to much.
|
||||
// This way the particles line up every so often and you get a glimps of what is going on.
|
||||
|
||||
// Give each particle a slightly different period. But don't spread it to much
|
||||
// This way the particles line up every so often and you get a glimps of what is going on
|
||||
particles[i].period = (float)GetRandomValue(10, 30)/10.0f;
|
||||
}
|
||||
|
||||
// Create a plain OpenGL vertex buffer with the data and an vertex array object
|
||||
// that feeds the data from the buffer into the vertexPosition shader attribute.
|
||||
// Create a plain OpenGL vertex buffer with the data and an vertex array object
|
||||
// that feeds the data from the buffer into the vertexPosition shader attribute
|
||||
GLuint vao = 0;
|
||||
GLuint vbo = 0;
|
||||
glGenVertexArrays(1, &vao);
|
||||
@@ -125,13 +125,13 @@ int main(void)
|
||||
|
||||
DrawRectangle(10, 10, 210, 30, MAROON);
|
||||
DrawText(TextFormat("%zu particles in one vertex buffer", MAX_PARTICLES), 20, 20, 10, RAYWHITE);
|
||||
|
||||
|
||||
rlDrawRenderBatchActive(); // Draw iternal buffers data (previous draw calls)
|
||||
|
||||
// Switch to plain OpenGL
|
||||
//------------------------------------------------------------------------------
|
||||
glUseProgram(shader.id);
|
||||
|
||||
|
||||
glUniform1f(currentTimeLoc, GetTime());
|
||||
|
||||
Vector4 color = ColorNormalize((Color){ 255, 0, 0, 128 });
|
||||
@@ -139,18 +139,18 @@ int main(void)
|
||||
|
||||
// Get the current modelview and projection matrix so the particle system is displayed and transformed
|
||||
Matrix modelViewProjection = MatrixMultiply(rlGetMatrixModelview(), rlGetMatrixProjection());
|
||||
|
||||
|
||||
glUniformMatrix4fv(shader.locs[SHADER_LOC_MATRIX_MVP], 1, false, MatrixToFloat(modelViewProjection));
|
||||
|
||||
glBindVertexArray(vao);
|
||||
glDrawArrays(GL_POINTS, 0, MAX_PARTICLES);
|
||||
glBindVertexArray(0);
|
||||
|
||||
|
||||
glUseProgram(0);
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
DrawFPS(screenWidth - 100, 10);
|
||||
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@
|
||||
* Copyright (c) 2023-2025 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include "raymath.h"
|
||||
@@ -32,7 +32,7 @@ int main(void)
|
||||
Vector2 v0 = { screenWidth/2, screenHeight/2 };
|
||||
Vector2 v1 = Vector2Add(v0, (Vector2){ 100.0f, 80.0f });
|
||||
Vector2 v2 = { 0 }; // Updated with mouse position
|
||||
|
||||
|
||||
float angle = 0.0f; // Angle in degrees
|
||||
int angleMode = 0; // 0-Vector2Angle(), 1-Vector2LineAngle()
|
||||
|
||||
@@ -47,12 +47,12 @@ int main(void)
|
||||
float startangle = 0.0f;
|
||||
|
||||
if (angleMode == 0) startangle = -Vector2LineAngle(v0, v1)*RAD2DEG;
|
||||
if (angleMode == 1) startangle = 0.0f;
|
||||
if (angleMode == 1) startangle = 0.0f;
|
||||
|
||||
v2 = GetMousePosition();
|
||||
|
||||
if (IsKeyPressed(KEY_SPACE)) angleMode = !angleMode;
|
||||
|
||||
|
||||
if ((angleMode == 0) && IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) v1 = GetMousePosition();
|
||||
|
||||
if (angleMode == 0)
|
||||
@@ -75,12 +75,12 @@ int main(void)
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
|
||||
if (angleMode == 0)
|
||||
{
|
||||
DrawText("MODE 0: Angle between V1 and V2", 10, 10, 20, BLACK);
|
||||
DrawText("Right Click to Move V2", 10, 30, 20, DARKGRAY);
|
||||
|
||||
|
||||
DrawLineEx(v0, v1, 2.0f, BLACK);
|
||||
DrawLineEx(v0, v2, 2.0f, RED);
|
||||
|
||||
@@ -89,13 +89,13 @@ int main(void)
|
||||
else if (angleMode == 1)
|
||||
{
|
||||
DrawText("MODE 1: Angle formed by line V1 to V2", 10, 10, 20, BLACK);
|
||||
|
||||
|
||||
DrawLine(0, screenHeight/2, screenWidth, screenHeight/2, LIGHTGRAY);
|
||||
DrawLineEx(v0, v2, 2.0f, RED);
|
||||
|
||||
DrawCircleSector(v0, 40.0f, startangle, startangle - angle, 32, Fade(GREEN, 0.6f));
|
||||
}
|
||||
|
||||
|
||||
DrawText("v0", v0.x, v0.y, 10, DARKGRAY);
|
||||
|
||||
// If the line from v0 to v1 would overlap the text, move it's position up 10
|
||||
@@ -110,7 +110,7 @@ int main(void)
|
||||
|
||||
DrawText("Press SPACE to change MODE", 460, 10, 20, DARKGRAY);
|
||||
DrawText(TextFormat("ANGLE: %2.2f", angle), 10, 70, 20, LIME);
|
||||
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ uniform vec4 color;
|
||||
void main()
|
||||
{
|
||||
// Each point is drawn as a screen space square of gl_PointSize size. gl_PointCoord contains where we are inside of
|
||||
// it. (0, 0) is the top left, (1, 1) the bottom right corner.
|
||||
// Draw each point as a colored circle with alpha 1.0 in the center and 0.0 at the outer edges.
|
||||
gl_FragColor = vec4(color.rgb, color.a * (1.0 - length(gl_PointCoord.xy - vec2(0.5))*2.0));
|
||||
// it. (0, 0) is the top left, (1, 1) the bottom right corner
|
||||
// Draw each point as a colored circle with alpha 1.0 in the center and 0.0 at the outer edges
|
||||
gl_FragColor = vec4(color.rgb, color.a*(1.0 - length(gl_PointCoord.xy - vec2(0.5))*2.0));
|
||||
}
|
@@ -16,9 +16,9 @@ void main()
|
||||
float period = vertexPosition.z;
|
||||
|
||||
// Calculate final vertex position (jiggle it around a bit horizontally)
|
||||
pos += vec2(100.0, 0.0) * sin(period * currentTime);
|
||||
gl_Position = mvp * vec4(pos.x, pos.y, 0.0, 1.0);
|
||||
pos += vec2(100.0, 0.0)*sin(period*currentTime);
|
||||
gl_Position = mvp*vec4(pos.x, pos.y, 0.0, 1.0);
|
||||
|
||||
// Calculate the screen space size of this particle (also vary it over time)
|
||||
gl_PointSize = 10.0 - 5.0 * abs(sin(period * currentTime));
|
||||
gl_PointSize = 10.0 - 5.0*abs(sin(period*currentTime));
|
||||
}
|
@@ -11,7 +11,7 @@ out vec4 finalColor;
|
||||
void main()
|
||||
{
|
||||
// Each point is drawn as a screen space square of gl_PointSize size. gl_PointCoord contains where we are inside of
|
||||
// it. (0, 0) is the top left, (1, 1) the bottom right corner.
|
||||
// Draw each point as a colored circle with alpha 1.0 in the center and 0.0 at the outer edges.
|
||||
finalColor = vec4(color.rgb, color.a * (1 - length(gl_PointCoord.xy - vec2(0.5))*2));
|
||||
// it. (0, 0) is the top left, (1, 1) the bottom right corner
|
||||
// Draw each point as a colored circle with alpha 1.0 in the center and 0.0 at the outer edges
|
||||
finalColor = vec4(color.rgb, color.a*(1 - length(gl_PointCoord.xy - vec2(0.5))*2));
|
||||
}
|
@@ -16,9 +16,9 @@ void main()
|
||||
float period = vertexPosition.z;
|
||||
|
||||
// Calculate final vertex position (jiggle it around a bit horizontally)
|
||||
pos += vec2(100, 0) * sin(period * currentTime);
|
||||
gl_Position = mvp * vec4(pos, 0.0, 1.0);
|
||||
pos += vec2(100, 0)*sin(period*currentTime);
|
||||
gl_Position = mvp*vec4(pos, 0.0, 1.0);
|
||||
|
||||
// Calculate the screen space size of this particle (also vary it over time)
|
||||
gl_PointSize = 10 - 5 * abs(sin(period * currentTime));
|
||||
gl_PointSize = 10 - 5*abs(sin(period*currentTime));
|
||||
}
|
@@ -23,11 +23,11 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// IMPORTANT: This must match gol*.glsl GOL_WIDTH constant.
|
||||
// This must be a multiple of 16 (check golLogic compute dispatch).
|
||||
// IMPORTANT: This must match gol*.glsl GOL_WIDTH constant
|
||||
// This must be a multiple of 16 (check golLogic compute dispatch)
|
||||
#define GOL_WIDTH 768
|
||||
|
||||
// Maximum amount of queued draw commands (squares draw from mouse down events).
|
||||
// Maximum amount of queued draw commands (squares draw from mouse down events)
|
||||
#define MAX_BUFFERED_TRANSFERTS 48
|
||||
|
||||
// Game Of Life Update Command
|
||||
@@ -51,9 +51,12 @@ int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
InitWindow(GOL_WIDTH, GOL_WIDTH, "raylib [rlgl] example - compute shader - game of life");
|
||||
const int screenWidth = GOL_WIDTH;
|
||||
const int screenHeight = GOL_WIDTH;
|
||||
|
||||
const Vector2 resolution = { GOL_WIDTH, GOL_WIDTH };
|
||||
InitWindow(screenWidth, screenHeight, "raylib [rlgl] example - compute shader - game of life");
|
||||
|
||||
const Vector2 resolution = { screenWidth, screenHeight };
|
||||
unsigned int brushSize = 8;
|
||||
|
||||
// Game of Life logic compute shader
|
||||
@@ -157,7 +160,7 @@ int main(void)
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Unload shader buffers objects.
|
||||
// Unload shader buffers objects
|
||||
rlUnloadShaderBuffer(ssboA);
|
||||
rlUnloadShaderBuffer(ssboB);
|
||||
rlUnloadShaderBuffer(ssboTransfert);
|
||||
|
@@ -9,7 +9,7 @@
|
||||
*
|
||||
* Example originally created with raylib 1.6, last time updated with raylib 4.0
|
||||
*
|
||||
* WARNING: This example is intended only for PLATFORM_DESKTOP and OpenGL 3.3 Core profile.
|
||||
* WARNING: This example is intended only for PLATFORM_DESKTOP and OpenGL 3.3 Core profile
|
||||
* It could work on other platforms if redesigned for those platforms (out-of-scope)
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
@@ -48,7 +48,7 @@
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
* 3. This notice may not be removed or altered from any source distribution
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
@@ -137,7 +137,7 @@ int main(void)
|
||||
|
||||
glfwWindowHint(GLFW_SAMPLES, 4);
|
||||
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
||||
|
||||
|
||||
// WARNING: OpenGL 3.3 Core profile only
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
|
@@ -12,9 +12,9 @@ uniform vec4 colDiffuse;
|
||||
|
||||
// NOTE: Add your custom variables here
|
||||
|
||||
const vec2 size = vec2(800, 450); // render size
|
||||
const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance
|
||||
const float quality = 2.5; // lower = smaller glow, better quality
|
||||
const vec2 size = vec2(800, 450); // Framebuffer size
|
||||
const float samples = 5.0; // Pixels per axis; higher = bigger glow, worse performance
|
||||
const float quality = 2.5; // Defines size factor: Lower = smaller glow, better quality
|
||||
|
||||
void main()
|
||||
{
|
||||
|
@@ -23,8 +23,8 @@ vec4 PostFX(sampler2D tex, vec2 uv)
|
||||
{
|
||||
vec4 c = vec4(0.0);
|
||||
float size = stitchingSize;
|
||||
vec2 cPos = uv * vec2(renderWidth, renderHeight);
|
||||
vec2 tlPos = floor(cPos / vec2(size, size));
|
||||
vec2 cPos = uv*vec2(renderWidth, renderHeight);
|
||||
vec2 tlPos = floor(cPos/vec2(size, size));
|
||||
tlPos *= size;
|
||||
|
||||
int remX = int(mod(cPos.x, size));
|
||||
@@ -38,11 +38,11 @@ vec4 PostFX(sampler2D tex, vec2 uv)
|
||||
if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
|
||||
{
|
||||
if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0);
|
||||
else c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
|
||||
else c = texture2D(tex, tlPos*vec2(1.0/renderWidth, 1.0/renderHeight))*1.4;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (invert == 1) c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
|
||||
if (invert == 1) c = texture2D(tex, tlPos*vec2(1.0/renderWidth, 1.0/renderHeight))*1.4;
|
||||
else c = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ float angle = 0.0;
|
||||
vec2 VectorRotateTime(vec2 v, float speed)
|
||||
{
|
||||
float time = uTime*speed;
|
||||
float localTime = fract(time); // The time domain this works on is 1 sec.
|
||||
float localTime = fract(time); // The time domain this works on is 1 sec
|
||||
|
||||
if ((localTime >= 0.0) && (localTime < 0.25)) angle = 0.0;
|
||||
else if ((localTime >= 0.25) && (localTime < 0.50)) angle = PI/4.0*sin(2.0*PI*localTime - PI/2.0);
|
||||
|
@@ -13,9 +13,9 @@ uniform sampler2D gAlbedoSpec;
|
||||
|
||||
struct Light {
|
||||
int enabled;
|
||||
int type; // Unused in this demo.
|
||||
int type; // Unused in this demo
|
||||
vec3 position;
|
||||
vec3 target; // Unused in this demo.
|
||||
vec3 target; // Unused in this demo
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ void main()
|
||||
|
||||
for (int i = 0; i < NR_LIGHTS; ++i)
|
||||
{
|
||||
if(lights[i].enabled == 0) continue;
|
||||
if (lights[i].enabled == 0) continue;
|
||||
vec3 lightDirection = lights[i].position - fragPosition;
|
||||
vec3 diffuse = max(dot(normal, lightDirection), 0.0)*albedo*lights[i].color.xyz;
|
||||
|
||||
@@ -48,7 +48,7 @@ void main()
|
||||
|
||||
// Attenuation
|
||||
float distance = length(lights[i].position - fragPosition);
|
||||
float attenuation = 1.0/(1.0 + LINEAR * distance + QUADRATIC*distance*distance);
|
||||
float attenuation = 1.0/(1.0 + LINEAR*distance + QUADRATIC*distance*distance);
|
||||
diffuse *= attenuation;
|
||||
specular *= attenuation;
|
||||
ambient += diffuse + specular;
|
||||
|
@@ -7,12 +7,12 @@ precision mediump float;
|
||||
The Sieve of Eratosthenes -- a simple shader by ProfJski
|
||||
An early prime number sieve: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
|
||||
|
||||
The screen is divided into a square grid of boxes, each representing an integer value.
|
||||
Each integer is tested to see if it is a prime number. Primes are colored white.
|
||||
Non-primes are colored with a color that indicates the smallest factor which evenly divdes our integer.
|
||||
The screen is divided into a square grid of boxes, each representing an integer value
|
||||
Each integer is tested to see if it is a prime number. Primes are colored white
|
||||
Non-primes are colored with a color that indicates the smallest factor which evenly divdes our integer
|
||||
|
||||
You can change the scale variable to make a larger or smaller grid.
|
||||
Total number of integers displayed = scale squared, so scale = 100 tests the first 10,000 integers.
|
||||
You can change the scale variable to make a larger or smaller grid
|
||||
Total number of integers displayed = scale squared, so scale = 100 tests the first 10,000 integers
|
||||
|
||||
WARNING: If you make scale too large, your GPU may bog down!
|
||||
|
||||
@@ -38,7 +38,7 @@ vec4 Colorizer(float counter, float maxSize)
|
||||
void main()
|
||||
{
|
||||
vec4 color = vec4(1.0);
|
||||
float scale = 1000.0; // Makes 100x100 square grid. Change this variable to make a smaller or larger grid.
|
||||
float scale = 1000.0; // Makes 100x100 square grid. Change this variable to make a smaller or larger grid
|
||||
float value = scale*floor(fragTexCoord.y*scale) + floor(fragTexCoord.x*scale); // Group pixels into boxes representing integer values
|
||||
int valuei = int(value);
|
||||
|
||||
|
@@ -17,22 +17,22 @@ const float PI = 3.1415926535;
|
||||
void main()
|
||||
{
|
||||
float aperture = 178.0;
|
||||
float apertureHalf = 0.5 * aperture * (PI / 180.0);
|
||||
float apertureHalf = 0.5*aperture*(PI/180.0);
|
||||
float maxFactor = sin(apertureHalf);
|
||||
|
||||
vec2 uv = vec2(0.0);
|
||||
vec2 xy = 2.0 * fragTexCoord.xy - 1.0;
|
||||
vec2 xy = 2.0*fragTexCoord.xy - 1.0;
|
||||
float d = length(xy);
|
||||
|
||||
if (d < (2.0 - maxFactor))
|
||||
{
|
||||
d = length(xy * maxFactor);
|
||||
float z = sqrt(1.0 - d * d);
|
||||
float r = atan(d, z) / PI;
|
||||
d = length(xy*maxFactor);
|
||||
float z = sqrt(1.0 - d*d);
|
||||
float r = atan(d, z)/PI;
|
||||
float phi = atan(xy.y, xy.x);
|
||||
|
||||
uv.x = r * cos(phi) + 0.5;
|
||||
uv.y = r * sin(phi) + 0.5;
|
||||
uv.x = r*cos(phi) + 0.5;
|
||||
uv.y = r*sin(phi) + 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#version 100
|
||||
#version 100
|
||||
|
||||
#extension GL_EXT_frag_depth : enable // Extension required for writing depth
|
||||
precision mediump float; // Precision required for OpenGL ES2 (WebGL)
|
||||
|
||||
@@ -11,6 +12,7 @@ uniform vec4 colDiffuse;
|
||||
void main()
|
||||
{
|
||||
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
||||
|
||||
gl_FragColor = texelColor*colDiffuse*fragColor;
|
||||
gl_FragDepthEXT = gl_FragCoord.z;
|
||||
gl_FragDepthEXT = gl_FragCoord.z;
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
#version 100
|
||||
#version 100
|
||||
|
||||
#extension GL_EXT_frag_depth : enable //Extension required for writing depth
|
||||
#extension GL_OES_standard_derivatives : enable //Extension used for fwidth()
|
||||
precision mediump float; // Precision required for OpenGL ES2 (WebGL)
|
||||
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
@@ -19,21 +19,22 @@ uniform vec2 screenCenter;
|
||||
|
||||
#define ZERO 0
|
||||
|
||||
// https://learnopengl.com/Advanced-OpenGL/Depth-testing
|
||||
float CalcDepth(in vec3 rd, in float Idist){
|
||||
// SRC: https://learnopengl.com/Advanced-OpenGL/Depth-testing
|
||||
float CalcDepth(in vec3 rd, in float Idist)
|
||||
{
|
||||
float local_z = dot(normalize(camDir),rd)*Idist;
|
||||
return (1.0/(local_z) - 1.0/0.01)/(1.0/1000.0 -1.0/0.01);
|
||||
}
|
||||
|
||||
// https://iquilezles.org/articles/distfunctions/
|
||||
float sdHorseshoe( in vec3 p, in vec2 c, in float r, in float le, vec2 w )
|
||||
// SRC: https://iquilezles.org/articles/distfunctions/
|
||||
float sdHorseshoe(in vec3 p, in vec2 c, in float r, in float le, vec2 w)
|
||||
{
|
||||
p.x = abs(p.x);
|
||||
float l = length(p.xy);
|
||||
p.xy = mat2(-c.x, c.y,
|
||||
c.y, c.x)*p.xy;
|
||||
p.xy = vec2((p.y>0.0 || p.x>0.0)?p.x:l*sign(-c.x),
|
||||
(p.x>0.0)?p.y:l );
|
||||
(p.x>0.0)?p.y:l);
|
||||
p.xy = vec2(p.x,abs(p.y-r))-vec2(le,0.0);
|
||||
|
||||
vec2 q = vec2(length(max(p.xy,0.0)) + min(0.0,max(p.x,p.y)),p.z);
|
||||
@@ -44,67 +45,70 @@ float sdHorseshoe( in vec3 p, in vec2 c, in float r, in float le, vec2 w )
|
||||
// r = sphere's radius
|
||||
// h = cutting's plane's position
|
||||
// t = thickness
|
||||
float sdSixWayCutHollowSphere( vec3 p, float r, float h, float t )
|
||||
float sdSixWayCutHollowSphere(vec3 p, float r, float h, float t)
|
||||
{
|
||||
// Six way symetry Transformation
|
||||
vec3 ap = abs(p);
|
||||
if(ap.x < max(ap.y, ap.z)){
|
||||
if(ap.y < ap.z) ap.xz = ap.zx;
|
||||
if (ap.x < max(ap.y, ap.z)){
|
||||
if (ap.y < ap.z) ap.xz = ap.zx;
|
||||
else ap.xy = ap.yx;
|
||||
}
|
||||
|
||||
vec2 q = vec2( length(ap.yz), ap.x );
|
||||
vec2 q = vec2(length(ap.yz), ap.x);
|
||||
|
||||
float w = sqrt(r*r-h*h);
|
||||
|
||||
return ((h*q.x<w*q.y) ? length(q-vec2(w,h)) :
|
||||
abs(length(q)-r) ) - t;
|
||||
return ((h*q.x<w*q.y) ? length(q-vec2(w,h)) : abs(length(q)-r)) - t;
|
||||
}
|
||||
|
||||
// https://iquilezles.org/articles/boxfunctions
|
||||
vec2 iBox( in vec3 ro, in vec3 rd, in vec3 rad )
|
||||
// SRC: https://iquilezles.org/articles/boxfunctions
|
||||
vec2 iBox(in vec3 ro, in vec3 rd, in vec3 rad)
|
||||
{
|
||||
vec3 m = 1.0/rd;
|
||||
vec3 n = m*ro;
|
||||
vec3 k = abs(m)*rad;
|
||||
vec3 t1 = -n - k;
|
||||
vec3 t2 = -n + k;
|
||||
return vec2( max( max( t1.x, t1.y ), t1.z ),
|
||||
min( min( t2.x, t2.y ), t2.z ) );
|
||||
|
||||
return vec2(max(max(t1.x, t1.y), t1.z),
|
||||
min(min(t2.x, t2.y), t2.z));
|
||||
}
|
||||
|
||||
vec2 opU( vec2 d1, vec2 d2 )
|
||||
vec2 opU(vec2 d1, vec2 d2)
|
||||
{
|
||||
return (d1.x<d2.x) ? d1 : d2;
|
||||
return (d1.x<d2.x) ? d1 : d2;
|
||||
}
|
||||
|
||||
vec2 map( in vec3 pos ){
|
||||
vec2 res = vec2( sdHorseshoe( pos-vec3(-1.0,0.08, 1.0), vec2(cos(1.3),sin(1.3)), 0.2, 0.3, vec2(0.03,0.5) ), 11.5 ) ;
|
||||
res = opU(res, vec2( sdSixWayCutHollowSphere( pos-vec3(0.0, 1.0, 0.0), 4.0, 3.5, 0.5 ), 4.5 )) ;
|
||||
vec2 map(in vec3 pos)
|
||||
{
|
||||
vec2 res = vec2(sdHorseshoe(pos-vec3(-1.0,0.08, 1.0), vec2(cos(1.3),sin(1.3)), 0.2, 0.3, vec2(0.03,0.5)), 11.5) ;
|
||||
res = opU(res, vec2(sdSixWayCutHollowSphere(pos-vec3(0.0, 1.0, 0.0), 4.0, 3.5, 0.5), 4.5)) ;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// https://www.shadertoy.com/view/Xds3zN
|
||||
vec2 raycast( in vec3 ro, in vec3 rd ){
|
||||
// SRC: https://www.shadertoy.com/view/Xds3zN
|
||||
vec2 raycast(in vec3 ro, in vec3 rd)
|
||||
{
|
||||
vec2 res = vec2(-1.0,-1.0);
|
||||
|
||||
float tmin = 1.0;
|
||||
float tmax = 20.0;
|
||||
|
||||
// raytrace floor plane
|
||||
// Raytrace floor plane
|
||||
float tp1 = (-ro.y)/rd.y;
|
||||
if( tp1>0.0 )
|
||||
if (tp1>0.0)
|
||||
{
|
||||
tmax = min( tmax, tp1 );
|
||||
res = vec2( tp1, 1.0 );
|
||||
tmax = min(tmax, tp1);
|
||||
res = vec2(tp1, 1.0);
|
||||
}
|
||||
|
||||
float t = tmin;
|
||||
for( int i=0; i<70 ; i++ )
|
||||
for (int i=0; i<70 ; i++)
|
||||
{
|
||||
if(t>tmax) break;
|
||||
vec2 h = map( ro+rd*t );
|
||||
if( abs(h.x)<(0.0001*t) )
|
||||
if (t>tmax) break;
|
||||
vec2 h = map(ro+rd*t);
|
||||
if (abs(h.x) < (0.0001*t))
|
||||
{
|
||||
res = vec2(t,h.y);
|
||||
break;
|
||||
@@ -117,54 +121,54 @@ vec2 raycast( in vec3 ro, in vec3 rd ){
|
||||
|
||||
|
||||
// https://iquilezles.org/articles/rmshadows
|
||||
float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax )
|
||||
float calcSoftshadow(in vec3 ro, in vec3 rd, in float mint, in float tmax)
|
||||
{
|
||||
// bounding volume
|
||||
float tp = (0.8-ro.y)/rd.y; if( tp>0.0 ) tmax = min( tmax, tp );
|
||||
float tp = (0.8-ro.y)/rd.y; if (tp>0.0) tmax = min(tmax, tp);
|
||||
|
||||
float res = 1.0;
|
||||
float t = mint;
|
||||
for( int i=ZERO; i<24; i++ )
|
||||
for (int i=ZERO; i<24; i++)
|
||||
{
|
||||
float h = map( ro + rd*t ).x;
|
||||
float h = map(ro + rd*t).x;
|
||||
float s = clamp(8.0*h/t,0.0,1.0);
|
||||
res = min( res, s );
|
||||
t += clamp( h, 0.01, 0.2 );
|
||||
if( res<0.004 || t>tmax ) break;
|
||||
res = min(res, s);
|
||||
t += clamp(h, 0.01, 0.2);
|
||||
if (res<0.004 || t>tmax) break;
|
||||
}
|
||||
res = clamp( res, 0.0, 1.0 );
|
||||
res = clamp(res, 0.0, 1.0);
|
||||
return res*res*(3.0-2.0*res);
|
||||
}
|
||||
|
||||
|
||||
// https://iquilezles.org/articles/normalsSDF
|
||||
vec3 calcNormal( in vec3 pos )
|
||||
vec3 calcNormal(in vec3 pos)
|
||||
{
|
||||
vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
|
||||
return normalize( e.xyy*map( pos + e.xyy ).x +
|
||||
e.yyx*map( pos + e.yyx ).x +
|
||||
e.yxy*map( pos + e.yxy ).x +
|
||||
e.xxx*map( pos + e.xxx ).x );
|
||||
return normalize(e.xyy*map(pos + e.xyy).x +
|
||||
e.yyx*map(pos + e.yyx).x +
|
||||
e.yxy*map(pos + e.yxy).x +
|
||||
e.xxx*map(pos + e.xxx).x);
|
||||
}
|
||||
|
||||
// https://iquilezles.org/articles/nvscene2008/rwwtt.pdf
|
||||
float calcAO( in vec3 pos, in vec3 nor )
|
||||
float calcAO(in vec3 pos, in vec3 nor)
|
||||
{
|
||||
float occ = 0.0;
|
||||
float occ = 0.0;
|
||||
float sca = 1.0;
|
||||
for( int i=ZERO; i<5; i++ )
|
||||
for (int i=ZERO; i<5; i++)
|
||||
{
|
||||
float h = 0.01 + 0.12*float(i)/4.0;
|
||||
float d = map( pos + h*nor ).x;
|
||||
float d = map(pos + h*nor).x;
|
||||
occ += (h-d)*sca;
|
||||
sca *= 0.95;
|
||||
if( occ>0.35 ) break;
|
||||
if (occ>0.35) break;
|
||||
}
|
||||
return clamp( 1.0 - 3.0*occ, 0.0, 1.0 ) * (0.5+0.5*nor.y);
|
||||
return clamp(1.0 - 3.0*occ, 0.0, 1.0)*(0.5+0.5*nor.y);
|
||||
}
|
||||
|
||||
// https://iquilezles.org/articles/checkerfiltering
|
||||
float checkersGradBox( in vec2 p )
|
||||
float checkersGradBox(in vec2 p)
|
||||
{
|
||||
// filter kernel
|
||||
vec2 w = fwidth(p) + 0.001;
|
||||
@@ -175,7 +179,7 @@ float checkersGradBox( in vec2 p )
|
||||
}
|
||||
|
||||
// https://www.shadertoy.com/view/tdS3DG
|
||||
vec4 render( in vec3 ro, in vec3 rd)
|
||||
vec4 render(in vec3 ro, in vec3 rd)
|
||||
{
|
||||
// background
|
||||
vec3 col = vec3(0.7, 0.7, 0.9) - max(rd.y,0.0)*0.3;
|
||||
@@ -183,37 +187,37 @@ vec4 render( in vec3 ro, in vec3 rd)
|
||||
// raycast scene
|
||||
vec2 res = raycast(ro,rd);
|
||||
float t = res.x;
|
||||
float m = res.y;
|
||||
if( m>-0.5 )
|
||||
float m = res.y;
|
||||
if (m>-0.5)
|
||||
{
|
||||
vec3 pos = ro + t*rd;
|
||||
vec3 nor = (m<1.5) ? vec3(0.0,1.0,0.0) : calcNormal( pos );
|
||||
vec3 ref = reflect( rd, nor );
|
||||
vec3 nor = (m<1.5) ? vec3(0.0,1.0,0.0) : calcNormal(pos);
|
||||
vec3 ref = reflect(rd, nor);
|
||||
|
||||
// material
|
||||
col = 0.2 + 0.2*sin( m*2.0 + vec3(0.0,1.0,2.0) );
|
||||
col = 0.2 + 0.2*sin(m*2.0 + vec3(0.0,1.0,2.0));
|
||||
float ks = 1.0;
|
||||
|
||||
if( m<1.5 )
|
||||
if (m<1.5)
|
||||
{
|
||||
float f = checkersGradBox( 3.0*pos.xz);
|
||||
float f = checkersGradBox(3.0*pos.xz);
|
||||
col = 0.15 + f*vec3(0.05);
|
||||
ks = 0.4;
|
||||
}
|
||||
|
||||
// lighting
|
||||
float occ = calcAO( pos, nor );
|
||||
float occ = calcAO(pos, nor);
|
||||
|
||||
vec3 lin = vec3(0.0);
|
||||
vec3 lin = vec3(0.0);
|
||||
|
||||
// sun
|
||||
{
|
||||
vec3 lig = normalize( vec3(-0.5, 0.4, -0.6) );
|
||||
vec3 hal = normalize( lig-rd );
|
||||
float dif = clamp( dot( nor, lig ), 0.0, 1.0 );
|
||||
//if( dif>0.0001 )
|
||||
dif *= calcSoftshadow( pos, lig, 0.02, 2.5 );
|
||||
float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0);
|
||||
vec3 lig = normalize(vec3(-0.5, 0.4, -0.6));
|
||||
vec3 hal = normalize(lig-rd);
|
||||
float dif = clamp(dot(nor, lig), 0.0, 1.0);
|
||||
//if (dif>0.0001)
|
||||
dif *= calcSoftshadow(pos, lig, 0.02, 2.5);
|
||||
float spe = pow(clamp(dot(nor, hal), 0.0, 1.0),16.0);
|
||||
spe *= dif;
|
||||
spe *= 0.04+0.96*pow(clamp(1.0-dot(hal,lig),0.0,1.0),5.0);
|
||||
//spe *= 0.04+0.96*pow(clamp(1.0-sqrt(0.5*(1.0-dot(rd,lig))),0.0,1.0),5.0);
|
||||
@@ -222,35 +226,35 @@ vec4 render( in vec3 ro, in vec3 rd)
|
||||
}
|
||||
// sky
|
||||
{
|
||||
float dif = sqrt(clamp( 0.5+0.5*nor.y, 0.0, 1.0 ));
|
||||
float dif = sqrt(clamp(0.5+0.5*nor.y, 0.0, 1.0));
|
||||
dif *= occ;
|
||||
float spe = smoothstep( -0.2, 0.2, ref.y );
|
||||
float spe = smoothstep(-0.2, 0.2, ref.y);
|
||||
spe *= dif;
|
||||
spe *= 0.04+0.96*pow(clamp(1.0+dot(nor,rd),0.0,1.0), 5.0 );
|
||||
//if( spe>0.001 )
|
||||
spe *= calcSoftshadow( pos, ref, 0.02, 2.5 );
|
||||
spe *= 0.04+0.96*pow(clamp(1.0+dot(nor,rd),0.0,1.0), 5.0);
|
||||
//if (spe>0.001)
|
||||
spe *= calcSoftshadow(pos, ref, 0.02, 2.5);
|
||||
lin += col*0.60*dif*vec3(0.40,0.60,1.15);
|
||||
lin += 2.00*spe*vec3(0.40,0.60,1.30)*ks;
|
||||
}
|
||||
// back
|
||||
{
|
||||
float dif = clamp( dot( nor, normalize(vec3(0.5,0.0,0.6))), 0.0, 1.0 )*clamp( 1.0-pos.y,0.0,1.0);
|
||||
float dif = clamp(dot(nor, normalize(vec3(0.5,0.0,0.6))), 0.0, 1.0)*clamp(1.0-pos.y,0.0,1.0);
|
||||
dif *= occ;
|
||||
lin += col*0.55*dif*vec3(0.25,0.25,0.25);
|
||||
lin += col*0.55*dif*vec3(0.25,0.25,0.25);
|
||||
}
|
||||
// sss
|
||||
{
|
||||
float dif = pow(clamp(1.0+dot(nor,rd),0.0,1.0),2.0);
|
||||
dif *= occ;
|
||||
lin += col*0.25*dif*vec3(1.00,1.00,1.00);
|
||||
lin += col*0.25*dif*vec3(1.00,1.00,1.00);
|
||||
}
|
||||
|
||||
col = lin;
|
||||
col = lin;
|
||||
|
||||
col = mix( col, vec3(0.7,0.7,0.9), 1.0-exp( -0.0001*t*t*t ) );
|
||||
col = mix(col, vec3(0.7,0.7,0.9), 1.0-exp(-0.0001*t*t*t));
|
||||
}
|
||||
|
||||
return vec4(vec3( clamp(col,0.0,1.0) ),t);
|
||||
return vec4(vec3(clamp(col,0.0,1.0)),t);
|
||||
}
|
||||
|
||||
vec3 CalcRayDir(vec2 nCoord){
|
||||
@@ -261,11 +265,11 @@ vec3 CalcRayDir(vec2 nCoord){
|
||||
|
||||
mat3 setCamera()
|
||||
{
|
||||
vec3 cw = normalize(camDir);
|
||||
vec3 cp = vec3(0.0, 1.0 ,0.0);
|
||||
vec3 cu = normalize( cross(cw,cp) );
|
||||
vec3 cv = ( cross(cu,cw) );
|
||||
return mat3( cu, cv, cw );
|
||||
vec3 cw = normalize(camDir);
|
||||
vec3 cp = vec3(0.0, 1.0 ,0.0);
|
||||
vec3 cu = normalize(cross(cw,cp));
|
||||
vec3 cv = (cross(cu,cw));
|
||||
return mat3(cu, cv, cw);
|
||||
}
|
||||
|
||||
void main()
|
||||
@@ -275,14 +279,14 @@ void main()
|
||||
|
||||
// focal length
|
||||
float fl = length(camDir);
|
||||
vec3 rd = ca * normalize( vec3(nCoord,fl) );
|
||||
vec3 rd = ca*normalize(vec3(nCoord,fl));
|
||||
vec3 color = vec3(nCoord/2.0 + 0.5, 0.0);
|
||||
float depth = gl_FragCoord.z;
|
||||
{
|
||||
vec4 res = render( camPos - vec3(0.0, 0.0, 0.0) , rd );
|
||||
vec4 res = render(camPos - vec3(0.0, 0.0, 0.0) , rd);
|
||||
color = res.xyz;
|
||||
depth = CalcDepth(rd,res.w);
|
||||
}
|
||||
gl_FragColor = vec4(color , 1.0);
|
||||
gl_FragDepthEXT = depth;
|
||||
gl_FragDepthEXT = depth;
|
||||
}
|
@@ -1,19 +1,17 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
#version 120
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
uniform vec2 c; // c.x = real, c.y = imaginary component. Equation done is z^2 + c
|
||||
uniform vec2 offset; // Offset of the scale.
|
||||
uniform float zoom; // Zoom of the scale.
|
||||
uniform vec2 offset; // Offset of the scale
|
||||
uniform float zoom; // Zoom of the scale
|
||||
|
||||
// NOTE: Maximum number of shader for-loop iterations depend on GPU,
|
||||
// for example, on RasperryPi for this examply only supports up to 60
|
||||
const int maxIterations = 48; // Max iterations to do.
|
||||
const float colorCycles = 1.0; // Number of times the color palette repeats.
|
||||
const int maxIterations = 255; // Max iterations to do.
|
||||
const float colorCycles = 1.0; // Number of times the color palette repeats.
|
||||
|
||||
// Square a complex number
|
||||
vec2 ComplexSquare(vec2 z)
|
||||
@@ -32,22 +30,22 @@ vec3 Hsv2rgb(vec3 c)
|
||||
void main()
|
||||
{
|
||||
/**********************************************************************************************
|
||||
Julia sets use a function z^2 + c, where c is a constant.
|
||||
This function is iterated until the nature of the point is determined.
|
||||
Julia sets use a function z^2 + c, where c is a constant
|
||||
This function is iterated until the nature of the point is determined
|
||||
|
||||
If the magnitude of the number becomes greater than 2, then from that point onward
|
||||
the number will get bigger and bigger, and will never get smaller (tends towards infinity).
|
||||
2^2 = 4, 4^2 = 8 and so on.
|
||||
So at 2 we stop iterating.
|
||||
the number will get bigger and bigger, and will never get smaller (tends towards infinity)
|
||||
2^2 = 4, 4^2 = 8 and so on
|
||||
So at 2 we stop iterating
|
||||
|
||||
If the number is below 2, we keep iterating.
|
||||
If the number is below 2, we keep iterating
|
||||
But when do we stop iterating if the number is always below 2 (it converges)?
|
||||
That is what maxIterations is for.
|
||||
Then we can divide the iterations by the maxIterations value to get a normalized value that we can
|
||||
then map to a color.
|
||||
That is what maxIterations is for
|
||||
Then we can divide the iterations by the maxIterations value to get a normalized value
|
||||
that we can then map to a color
|
||||
|
||||
We use dot product (z.x * z.x + z.y * z.y) to determine the magnitude (length) squared.
|
||||
And once the magnitude squared is > 4, then magnitude > 2 is also true (saves computational power).
|
||||
We use dot product (z.x*z.x + z.y*z.y) to determine the magnitude (length) squared
|
||||
And once the magnitude squared is > 4, then magnitude > 2 is also true (saves computational power)
|
||||
*************************************************************************************************/
|
||||
|
||||
// The pixel coordinates are scaled so they are on the mandelbrot scale
|
||||
@@ -57,7 +55,7 @@ void main()
|
||||
z.y += offset.y;
|
||||
|
||||
int iter = 0;
|
||||
for (int iterations = 0; iterations < 60; iterations++)
|
||||
for (int iterations = 0; iterations < maxIterations; iterations++)
|
||||
{
|
||||
z = ComplexSquare(z) + c; // Iterate function
|
||||
if (dot(z, z) > 4.0) break;
|
||||
@@ -65,18 +63,18 @@ void main()
|
||||
iter = iterations;
|
||||
}
|
||||
|
||||
// Another few iterations decreases errors in the smoothing calculation.
|
||||
// See http://linas.org/art-gallery/escape/escape.html for more information.
|
||||
// Another few iterations decreases errors in the smoothing calculation
|
||||
// See http://linas.org/art-gallery/escape/escape.html for more information
|
||||
z = ComplexSquare(z) + c;
|
||||
z = ComplexSquare(z) + c;
|
||||
|
||||
// This last part smooths the color (again see link above).
|
||||
// This last part smooths the color (again see link above)
|
||||
float smoothVal = float(iter) + 1.0 - (log(log(length(z)))/log(2.0));
|
||||
|
||||
// Normalize the value so it is between 0 and 1.
|
||||
// Normalize the value so it is between 0 and 1
|
||||
float norm = smoothVal/float(maxIterations);
|
||||
|
||||
// If in set, color black. 0.999 allows for some float accuracy error.
|
||||
// If in set, color black. 0.999 allows for some float accuracy error
|
||||
if (norm > 0.999) gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
else gl_FragColor = vec4(Hsv2rgb(vec3(norm*colorCycles, 1.0, 1.0)), 1.0);
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ void main()
|
||||
vec3 viewD = normalize(viewPos - fragPosition);
|
||||
vec3 specular = vec3(0.0);
|
||||
|
||||
vec4 tint = colDiffuse * fragColor;
|
||||
vec4 tint = colDiffuse*fragColor;
|
||||
|
||||
// NOTE: Implement here your fragment shader code
|
||||
|
||||
|
@@ -18,5 +18,5 @@ void main()
|
||||
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
||||
vec4 texelColor2 = texture2D(texture1, fragTexCoord2);
|
||||
|
||||
gl_FragColor = texelColor * texelColor2;
|
||||
gl_FragColor = texelColor*texelColor2;
|
||||
}
|
||||
|
@@ -1,6 +1,4 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
#version 120
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
|
64
examples/shaders/resources/shaders/glsl100/normalmap.fs
Normal file
64
examples/shaders/resources/shaders/glsl100/normalmap.fs
Normal file
@@ -0,0 +1,64 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec3 fragPosition;
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec3 fragNormal; //used for when normal mapping is toggled off
|
||||
varying vec4 fragColor;
|
||||
varying mat3 TBN;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform sampler2D normalMap;
|
||||
uniform vec4 colDiffuse;
|
||||
uniform vec3 viewPos;
|
||||
|
||||
// NOTE: Add your custom variables here
|
||||
|
||||
uniform vec3 lightPos;
|
||||
uniform bool useNormalMap;
|
||||
uniform float specularExponent;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texelColor = texture(texture0, vec2(fragTexCoord.x, fragTexCoord.y));
|
||||
vec3 specular = vec3(0.0);
|
||||
vec3 viewDir = normalize(viewPos - fragPosition);
|
||||
vec3 lightDir = normalize(lightPos - fragPosition);
|
||||
|
||||
vec3 normal;
|
||||
if (useNormalMap)
|
||||
{
|
||||
normal = texture(normalMap, vec2(fragTexCoord.x, fragTexCoord.y)).rgb;
|
||||
|
||||
//Transform normal values to the range -1.0 ... 1.0
|
||||
normal = normalize(normal*2.0 - 1.0);
|
||||
|
||||
//Transform the normal from tangent-space to world-space for lighting calculation
|
||||
normal = normalize(normal*TBN);
|
||||
}
|
||||
else
|
||||
{
|
||||
normal = normalize(fragNormal);
|
||||
}
|
||||
|
||||
vec4 tint = colDiffuse*fragColor;
|
||||
|
||||
vec3 lightColor = vec3(1.0, 1.0, 1.0);
|
||||
float NdotL = max(dot(normal, lightDir), 0.0);
|
||||
vec3 lightDot = lightColor*NdotL;
|
||||
|
||||
float specCo = 0.0;
|
||||
|
||||
if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewDir, reflect(-lightDir, normal))), specularExponent); // 16 refers to shine
|
||||
|
||||
specular += specCo;
|
||||
|
||||
finalColor = (texelColor*((tint + vec4(specular, 1.0))*vec4(lightDot, 1.0)));
|
||||
finalColor += texelColor*(vec4(1.0, 1.0, 1.0, 1.0)/40.0)*tint;
|
||||
|
||||
// Gamma correction
|
||||
gl_FragColor = pow(finalColor, vec4(1.0/2.2));
|
||||
}
|
76
examples/shaders/resources/shaders/glsl100/normalmap.vs
Normal file
76
examples/shaders/resources/shaders/glsl100/normalmap.vs
Normal file
@@ -0,0 +1,76 @@
|
||||
#version 100
|
||||
|
||||
// Input vertex attributes
|
||||
attribute vec3 vertexPosition;
|
||||
attribute vec2 vertexTexCoord;
|
||||
attribute vec3 vertexNormal;
|
||||
attribute vec4 vertexTangent;
|
||||
attribute vec4 vertexColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 mvp;
|
||||
uniform mat4 matModel;
|
||||
|
||||
// Output vertex attributes (to fragment shader)
|
||||
varying vec3 fragPosition;
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec3 fragNormal; //used for when normal mapping is toggled off
|
||||
varying vec4 fragColor;
|
||||
varying mat3 TBN;
|
||||
|
||||
// NOTE: Add your custom variables here
|
||||
|
||||
// https://github.com/glslify/glsl-inverse
|
||||
mat3 inverse(mat3 m)
|
||||
{
|
||||
float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];
|
||||
float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
|
||||
float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];
|
||||
|
||||
float b01 = a22*a11 - a12*a21;
|
||||
float b11 = -a22*a10 + a12*a20;
|
||||
float b21 = a21*a10 - a11*a20;
|
||||
|
||||
float det = a00*b01 + a01*b11 + a02*b21;
|
||||
|
||||
return mat3(b01, (-a22*a01 + a02*a21), (a12*a01 - a02*a11),
|
||||
b11, (a22*a00 - a02*a20), (-a12*a00 + a02*a10),
|
||||
b21, (-a21*a00 + a01*a20), (a11*a00 - a01*a10))/det;
|
||||
}
|
||||
|
||||
// https://github.com/glslify/glsl-transpose
|
||||
mat3 transpose(mat3 m)
|
||||
{
|
||||
return mat3(m[0][0], m[1][0], m[2][0],
|
||||
m[0][1], m[1][1], m[2][1],
|
||||
m[0][2], m[1][2], m[2][2]);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// Compute binormal from vertex normal and tangent. W component is the tangent handedness
|
||||
vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz)*vertexTangent.w;
|
||||
|
||||
// Compute fragment normal based on normal transformations
|
||||
mat3 normalMatrix = transpose(inverse(mat3(matModel)));
|
||||
|
||||
// Compute fragment position based on model transformations
|
||||
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
|
||||
|
||||
//Create TBN matrix for transforming the normal map values from tangent-space to world-space
|
||||
fragNormal = normalize(normalMatrix*vertexNormal);
|
||||
|
||||
vec3 fragTangent = normalize(normalMatrix*vertexTangent.xyz);
|
||||
fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal)*fragNormal);
|
||||
|
||||
vec3 fragBinormal = normalize(normalMatrix*vertexBinormal);
|
||||
fragBinormal = cross(fragNormal, fragTangent);
|
||||
|
||||
TBN = transpose(mat3(fragTangent, fragBinormal, fragNormal));
|
||||
|
||||
fragColor = vertexColor;
|
||||
|
||||
fragTexCoord = vertexTexCoord;
|
||||
|
||||
gl_Position = mvp*vec4(vertexPosition, 1.0);
|
||||
}
|
@@ -4,7 +4,7 @@
|
||||
attribute vec3 vertexPosition;
|
||||
attribute vec2 vertexTexCoord;
|
||||
attribute vec3 vertexNormal;
|
||||
attribute vec3 vertexTangent;
|
||||
attribute vec4 vertexTangent;
|
||||
attribute vec4 vertexColor;
|
||||
|
||||
// Input uniform values
|
||||
@@ -52,7 +52,7 @@ mat3 transpose(mat3 m)
|
||||
void main()
|
||||
{
|
||||
// Compute binormal from vertex normal and tangent
|
||||
vec3 vertexBinormal = cross(vertexNormal, vertexTangent);
|
||||
vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz)*vertexTangent.w;
|
||||
|
||||
// Compute fragment normal based on normal transformations
|
||||
mat3 normalMatrix = transpose(inverse(mat3(matModel)));
|
||||
@@ -62,7 +62,7 @@ void main()
|
||||
|
||||
fragTexCoord = vertexTexCoord*2.0;
|
||||
fragNormal = normalize(normalMatrix*vertexNormal);
|
||||
vec3 fragTangent = normalize(normalMatrix*vertexTangent);
|
||||
vec3 fragTangent = normalize(normalMatrix*vertexTangent.xyz);
|
||||
fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal)*fragNormal);
|
||||
vec3 fragBinormal = normalize(normalMatrix*vertexBinormal);
|
||||
fragBinormal = cross(fragNormal, fragTangent);
|
||||
|
@@ -34,7 +34,7 @@ uniform vec2 resolution;
|
||||
// SOFTWARE.
|
||||
|
||||
// A list of useful distance function to simple primitives, and an example on how to
|
||||
// do some interesting boolean operations, repetition and displacement.
|
||||
// do some interesting boolean operations, repetition and displacement
|
||||
//
|
||||
// More info here: http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
|
||||
|
||||
@@ -42,38 +42,38 @@ uniform vec2 resolution;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
||||
float sdPlane( vec3 p )
|
||||
float sdPlane(vec3 p)
|
||||
{
|
||||
return p.y;
|
||||
}
|
||||
|
||||
float sdSphere( vec3 p, float s )
|
||||
float sdSphere(vec3 p, float s)
|
||||
{
|
||||
return length(p)-s;
|
||||
}
|
||||
|
||||
float sdBox( vec3 p, vec3 b )
|
||||
float sdBox(vec3 p, vec3 b)
|
||||
{
|
||||
vec3 d = abs(p) - b;
|
||||
return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0));
|
||||
}
|
||||
|
||||
float sdEllipsoid( in vec3 p, in vec3 r )
|
||||
float sdEllipsoid(in vec3 p, in vec3 r)
|
||||
{
|
||||
return (length( p/r ) - 1.0) * min(min(r.x,r.y),r.z);
|
||||
return (length(p/r) - 1.0)*min(min(r.x,r.y),r.z);
|
||||
}
|
||||
|
||||
float udRoundBox( vec3 p, vec3 b, float r )
|
||||
float udRoundBox(vec3 p, vec3 b, float r)
|
||||
{
|
||||
return length(max(abs(p)-b,0.0))-r;
|
||||
}
|
||||
|
||||
float sdTorus( vec3 p, vec2 t )
|
||||
float sdTorus(vec3 p, vec2 t)
|
||||
{
|
||||
return length( vec2(length(p.xz)-t.x,p.y) )-t.y;
|
||||
return length(vec2(length(p.xz)-t.x,p.y))-t.y;
|
||||
}
|
||||
|
||||
float sdHexPrism( vec3 p, vec2 h )
|
||||
float sdHexPrism(vec3 p, vec2 h)
|
||||
{
|
||||
vec3 q = abs(p);
|
||||
#if 0
|
||||
@@ -85,24 +85,24 @@ float sdHexPrism( vec3 p, vec2 h )
|
||||
#endif
|
||||
}
|
||||
|
||||
float sdCapsule( vec3 p, vec3 a, vec3 b, float r )
|
||||
float sdCapsule(vec3 p, vec3 a, vec3 b, float r)
|
||||
{
|
||||
vec3 pa = p-a, ba = b-a;
|
||||
float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
|
||||
return length( pa - ba*h ) - r;
|
||||
float h = clamp(dot(pa,ba)/dot(ba,ba), 0.0, 1.0);
|
||||
return length(pa - ba*h) - r;
|
||||
}
|
||||
|
||||
float sdEquilateralTriangle( in vec2 p )
|
||||
float sdEquilateralTriangle( in vec2 p)
|
||||
{
|
||||
const float k = sqrt(3.0);
|
||||
p.x = abs(p.x) - 1.0;
|
||||
p.y = p.y + 1.0/k;
|
||||
if( p.x + k*p.y > 0.0 ) p = vec2( p.x - k*p.y, -k*p.x - p.y )/2.0;
|
||||
p.x += 2.0 - 2.0*clamp( (p.x+2.0)/2.0, 0.0, 1.0 );
|
||||
if (p.x + k*p.y > 0.0) p = vec2(p.x - k*p.y, -k*p.x - p.y)/2.0;
|
||||
p.x += 2.0 - 2.0*clamp((p.x+2.0)/2.0, 0.0, 1.0);
|
||||
return -length(p)*sign(p.y);
|
||||
}
|
||||
|
||||
float sdTriPrism( vec3 p, vec2 h )
|
||||
float sdTriPrism(vec3 p, vec2 h)
|
||||
{
|
||||
vec3 q = abs(p);
|
||||
float d1 = q.z-h.y;
|
||||
@@ -117,95 +117,95 @@ float sdTriPrism( vec3 p, vec2 h )
|
||||
return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
|
||||
}
|
||||
|
||||
float sdCylinder( vec3 p, vec2 h )
|
||||
float sdCylinder(vec3 p, vec2 h)
|
||||
{
|
||||
vec2 d = abs(vec2(length(p.xz),p.y)) - h;
|
||||
return min(max(d.x,d.y),0.0) + length(max(d,0.0));
|
||||
}
|
||||
|
||||
float sdCone( in vec3 p, in vec3 c )
|
||||
float sdCone(in vec3 p, in vec3 c)
|
||||
{
|
||||
vec2 q = vec2( length(p.xz), p.y );
|
||||
vec2 q = vec2(length(p.xz), p.y);
|
||||
float d1 = -q.y-c.z;
|
||||
float d2 = max( dot(q,c.xy), q.y);
|
||||
float d2 = max(dot(q,c.xy), q.y);
|
||||
return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
|
||||
}
|
||||
|
||||
float sdConeSection( in vec3 p, in float h, in float r1, in float r2 )
|
||||
float sdConeSection(in vec3 p, in float h, in float r1, in float r2)
|
||||
{
|
||||
float d1 = -p.y - h;
|
||||
float q = p.y - h;
|
||||
float si = 0.5*(r1-r2)/h;
|
||||
float d2 = max( sqrt( dot(p.xz,p.xz)*(1.0-si*si)) + q*si - r2, q );
|
||||
float d2 = max(sqrt(dot(p.xz,p.xz)*(1.0-si*si)) + q*si - r2, q);
|
||||
return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.);
|
||||
}
|
||||
|
||||
float sdPryamid4(vec3 p, vec3 h ) // h = { cos a, sin a, height }
|
||||
float sdPryamid4(vec3 p, vec3 h) // h = { cos a, sin a, height }
|
||||
{
|
||||
// Tetrahedron = Octahedron - Cube
|
||||
float box = sdBox( p - vec3(0,-2.0*h.z,0), vec3(2.0*h.z) );
|
||||
float box = sdBox(p - vec3(0,-2.0*h.z,0), vec3(2.0*h.z));
|
||||
|
||||
float d = 0.0;
|
||||
d = max( d, abs( dot(p, vec3( -h.x, h.y, 0 )) ));
|
||||
d = max( d, abs( dot(p, vec3( h.x, h.y, 0 )) ));
|
||||
d = max( d, abs( dot(p, vec3( 0, h.y, h.x )) ));
|
||||
d = max( d, abs( dot(p, vec3( 0, h.y,-h.x )) ));
|
||||
d = max(d, abs(dot(p, vec3(-h.x, h.y, 0))));
|
||||
d = max(d, abs(dot(p, vec3( h.x, h.y, 0))));
|
||||
d = max(d, abs(dot(p, vec3( 0, h.y, h.x))));
|
||||
d = max(d, abs(dot(p, vec3( 0, h.y,-h.x))));
|
||||
float octa = d - h.z;
|
||||
return max(-box,octa); // Subtraction
|
||||
}
|
||||
|
||||
float length2( vec2 p )
|
||||
float length2(vec2 p)
|
||||
{
|
||||
return sqrt( p.x*p.x + p.y*p.y );
|
||||
return sqrt(p.x*p.x + p.y*p.y);
|
||||
}
|
||||
|
||||
float length6( vec2 p )
|
||||
float length6(vec2 p)
|
||||
{
|
||||
p = p*p*p; p = p*p;
|
||||
return pow( p.x + p.y, 1.0/6.0 );
|
||||
return pow(p.x + p.y, 1.0/6.0);
|
||||
}
|
||||
|
||||
float length8( vec2 p )
|
||||
float length8(vec2 p)
|
||||
{
|
||||
p = p*p; p = p*p; p = p*p;
|
||||
return pow( p.x + p.y, 1.0/8.0 );
|
||||
return pow(p.x + p.y, 1.0/8.0);
|
||||
}
|
||||
|
||||
float sdTorus82( vec3 p, vec2 t )
|
||||
float sdTorus82(vec3 p, vec2 t)
|
||||
{
|
||||
vec2 q = vec2(length2(p.xz)-t.x,p.y);
|
||||
return length8(q)-t.y;
|
||||
}
|
||||
|
||||
float sdTorus88( vec3 p, vec2 t )
|
||||
float sdTorus88(vec3 p, vec2 t)
|
||||
{
|
||||
vec2 q = vec2(length8(p.xz)-t.x,p.y);
|
||||
return length8(q)-t.y;
|
||||
}
|
||||
|
||||
float sdCylinder6( vec3 p, vec2 h )
|
||||
float sdCylinder6(vec3 p, vec2 h)
|
||||
{
|
||||
return max( length6(p.xz)-h.x, abs(p.y)-h.y );
|
||||
return max(length6(p.xz)-h.x, abs(p.y)-h.y);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
||||
float opS( float d1, float d2 )
|
||||
float opS(float d1, float d2)
|
||||
{
|
||||
return max(-d2,d1);
|
||||
}
|
||||
|
||||
vec2 opU( vec2 d1, vec2 d2 )
|
||||
vec2 opU(vec2 d1, vec2 d2)
|
||||
{
|
||||
return (d1.x<d2.x) ? d1 : d2;
|
||||
}
|
||||
|
||||
vec3 opRep( vec3 p, vec3 c )
|
||||
vec3 opRep(vec3 p, vec3 c)
|
||||
{
|
||||
return mod(p,c)-0.5*c;
|
||||
}
|
||||
|
||||
vec3 opTwist( vec3 p )
|
||||
vec3 opTwist(vec3 p)
|
||||
{
|
||||
float c = cos(10.0*p.y+10.0);
|
||||
float s = sin(10.0*p.y+10.0);
|
||||
@@ -215,110 +215,110 @@ vec3 opTwist( vec3 p )
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
||||
vec2 map( in vec3 pos )
|
||||
vec2 map(in vec3 pos)
|
||||
{
|
||||
vec2 res = opU( vec2( sdPlane( pos), 1.0 ),
|
||||
vec2( sdSphere( pos-vec3( 0.0,0.25, 0.0), 0.25 ), 46.9 ) );
|
||||
res = opU( res, vec2( sdBox( pos-vec3( 1.0,0.25, 0.0), vec3(0.25) ), 3.0 ) );
|
||||
res = opU( res, vec2( udRoundBox( pos-vec3( 1.0,0.25, 1.0), vec3(0.15), 0.1 ), 41.0 ) );
|
||||
res = opU( res, vec2( sdTorus( pos-vec3( 0.0,0.25, 1.0), vec2(0.20,0.05) ), 25.0 ) );
|
||||
res = opU( res, vec2( sdCapsule( pos,vec3(-1.3,0.10,-0.1), vec3(-0.8,0.50,0.2), 0.1 ), 31.9 ) );
|
||||
res = opU( res, vec2( sdTriPrism( pos-vec3(-1.0,0.25,-1.0), vec2(0.25,0.05) ),43.5 ) );
|
||||
res = opU( res, vec2( sdCylinder( pos-vec3( 1.0,0.30,-1.0), vec2(0.1,0.2) ), 8.0 ) );
|
||||
res = opU( res, vec2( sdCone( pos-vec3( 0.0,0.50,-1.0), vec3(0.8,0.6,0.3) ), 55.0 ) );
|
||||
res = opU( res, vec2( sdTorus82( pos-vec3( 0.0,0.25, 2.0), vec2(0.20,0.05) ),50.0 ) );
|
||||
res = opU( res, vec2( sdTorus88( pos-vec3(-1.0,0.25, 2.0), vec2(0.20,0.05) ),43.0 ) );
|
||||
res = opU( res, vec2( sdCylinder6( pos-vec3( 1.0,0.30, 2.0), vec2(0.1,0.2) ), 12.0 ) );
|
||||
res = opU( res, vec2( sdHexPrism( pos-vec3(-1.0,0.20, 1.0), vec2(0.25,0.05) ),17.0 ) );
|
||||
res = opU( res, vec2( sdPryamid4( pos-vec3(-1.0,0.15,-2.0), vec3(0.8,0.6,0.25) ),37.0 ) );
|
||||
res = opU( res, vec2( opS( udRoundBox( pos-vec3(-2.0,0.2, 1.0), vec3(0.15),0.05),
|
||||
sdSphere( pos-vec3(-2.0,0.2, 1.0), 0.25)), 13.0 ) );
|
||||
res = opU( res, vec2( opS( sdTorus82( pos-vec3(-2.0,0.2, 0.0), vec2(0.20,0.1)),
|
||||
sdCylinder( opRep( vec3(atan(pos.x+2.0,pos.z)/6.2831, pos.y, 0.02+0.5*length(pos-vec3(-2.0,0.2, 0.0))), vec3(0.05,1.0,0.05)), vec2(0.02,0.6))), 51.0 ) );
|
||||
res = opU( res, vec2( 0.5*sdSphere( pos-vec3(-2.0,0.25,-1.0), 0.2 ) + 0.03*sin(50.0*pos.x)*sin(50.0*pos.y)*sin(50.0*pos.z), 65.0 ) );
|
||||
res = opU( res, vec2( 0.5*sdTorus( opTwist(pos-vec3(-2.0,0.25, 2.0)),vec2(0.20,0.05)), 46.7 ) );
|
||||
res = opU( res, vec2( sdConeSection( pos-vec3( 0.0,0.35,-2.0), 0.15, 0.2, 0.1 ), 13.67 ) );
|
||||
res = opU( res, vec2( sdEllipsoid( pos-vec3( 1.0,0.35,-2.0), vec3(0.15, 0.2, 0.05) ), 43.17 ) );
|
||||
vec2 res = opU(vec2(sdPlane( pos), 1.0),
|
||||
vec2(sdSphere( pos-vec3(0.0,0.25, 0.0), 0.25), 46.9));
|
||||
res = opU(res, vec2(sdBox( pos-vec3(1.0,0.25, 0.0), vec3(0.25)), 3.0));
|
||||
res = opU(res, vec2(udRoundBox( pos-vec3(1.0,0.25, 1.0), vec3(0.15), 0.1), 41.0));
|
||||
res = opU(res, vec2(sdTorus( pos-vec3(0.0,0.25, 1.0), vec2(0.20,0.05)), 25.0));
|
||||
res = opU(res, vec2(sdCapsule( pos,vec3(-1.3,0.10,-0.1), vec3(-0.8,0.50,0.2), 0.1 ), 31.9));
|
||||
res = opU(res, vec2(sdTriPrism( pos-vec3(-1.0,0.25,-1.0), vec2(0.25,0.05)),43.5));
|
||||
res = opU(res, vec2(sdCylinder( pos-vec3(1.0,0.30,-1.0), vec2(0.1,0.2)), 8.0));
|
||||
res = opU(res, vec2(sdCone( pos-vec3(0.0,0.50,-1.0), vec3(0.8,0.6,0.3)), 55.0));
|
||||
res = opU(res, vec2(sdTorus82( pos-vec3(0.0,0.25, 2.0), vec2(0.20,0.05)),50.0));
|
||||
res = opU(res, vec2(sdTorus88( pos-vec3(-1.0,0.25, 2.0), vec2(0.20,0.05)),43.0));
|
||||
res = opU(res, vec2(sdCylinder6(pos-vec3(1.0,0.30, 2.0), vec2(0.1,0.2)), 12.0));
|
||||
res = opU(res, vec2(sdHexPrism( pos-vec3(-1.0,0.20, 1.0), vec2(0.25,0.05)),17.0));
|
||||
res = opU(res, vec2(sdPryamid4( pos-vec3(-1.0,0.15,-2.0), vec3(0.8,0.6,0.25)),37.0));
|
||||
res = opU(res, vec2(opS(udRoundBox( pos-vec3(-2.0,0.2, 1.0), vec3(0.15),0.05),
|
||||
sdSphere( pos-vec3(-2.0,0.2, 1.0), 0.25)), 13.0));
|
||||
res = opU(res, vec2(opS(sdTorus82( pos-vec3(-2.0,0.2, 0.0), vec2(0.20,0.1)),
|
||||
sdCylinder( opRep(vec3(atan(pos.x+2.0,pos.z)/6.2831, pos.y, 0.02+0.5*length(pos-vec3(-2.0,0.2, 0.0))), vec3(0.05,1.0,0.05)), vec2(0.02,0.6))), 51.0));
|
||||
res = opU(res, vec2(0.5*sdSphere( pos-vec3(-2.0,0.25,-1.0), 0.2) + 0.03*sin(50.0*pos.x)*sin(50.0*pos.y)*sin(50.0*pos.z), 65.0));
|
||||
res = opU(res, vec2(0.5*sdTorus(opTwist(pos-vec3(-2.0,0.25, 2.0)),vec2(0.20,0.05)), 46.7));
|
||||
res = opU(res, vec2(sdConeSection(pos-vec3(0.0,0.35,-2.0), 0.15, 0.2, 0.1), 13.67));
|
||||
res = opU(res, vec2(sdEllipsoid(pos-vec3(1.0,0.35,-2.0), vec3(0.15, 0.2, 0.05)), 43.17));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
vec2 castRay( in vec3 ro, in vec3 rd )
|
||||
vec2 castRay(in vec3 ro, in vec3 rd)
|
||||
{
|
||||
float tmin = 0.2;
|
||||
float tmax = 30.0;
|
||||
|
||||
#if 1
|
||||
// bounding volume
|
||||
float tp1 = (0.0-ro.y)/rd.y; if( tp1>0.0 ) tmax = min( tmax, tp1 );
|
||||
float tp2 = (1.6-ro.y)/rd.y; if( tp2>0.0 ) { if( ro.y>1.6 ) tmin = max( tmin, tp2 );
|
||||
else tmax = min( tmax, tp2 ); }
|
||||
float tp1 = (0.0-ro.y)/rd.y; if (tp1>0.0) tmax = min(tmax, tp1);
|
||||
float tp2 = (1.6-ro.y)/rd.y; if (tp2>0.0) { if (ro.y>1.6) tmin = max(tmin, tp2);
|
||||
else tmax = min(tmax, tp2); }
|
||||
#endif
|
||||
|
||||
float t = tmin;
|
||||
float m = -1.0;
|
||||
for( int i=0; i<64; i++ )
|
||||
for (int i=0; i<64; i++)
|
||||
{
|
||||
float precis = 0.0005*t;
|
||||
vec2 res = map( ro+rd*t );
|
||||
if( res.x<precis || t>tmax ) break;
|
||||
vec2 res = map(ro+rd*t);
|
||||
if (res.x<precis || t>tmax) break;
|
||||
t += res.x;
|
||||
m = res.y;
|
||||
}
|
||||
|
||||
if( t>tmax ) m=-1.0;
|
||||
return vec2( t, m );
|
||||
if (t>tmax) m=-1.0;
|
||||
return vec2(t, m);
|
||||
}
|
||||
|
||||
|
||||
float calcSoftshadow( in vec3 ro, in vec3 rd, in float mint, in float tmax )
|
||||
float calcSoftshadow(in vec3 ro, in vec3 rd, in float mint, in float tmax)
|
||||
{
|
||||
float res = 1.0;
|
||||
float t = mint;
|
||||
for( int i=0; i<16; i++ )
|
||||
for (int i=0; i<16; i++)
|
||||
{
|
||||
float h = map( ro + rd*t ).x;
|
||||
res = min( res, 8.0*h/t );
|
||||
t += clamp( h, 0.02, 0.10 );
|
||||
if( h<0.001 || t>tmax ) break;
|
||||
float h = map(ro + rd*t).x;
|
||||
res = min(res, 8.0*h/t);
|
||||
t += clamp(h, 0.02, 0.10);
|
||||
if (h<0.001 || t>tmax) break;
|
||||
}
|
||||
return clamp( res, 0.0, 1.0 );
|
||||
return clamp(res, 0.0, 1.0);
|
||||
}
|
||||
|
||||
vec3 calcNormal( in vec3 pos )
|
||||
vec3 calcNormal(in vec3 pos)
|
||||
{
|
||||
vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
|
||||
return normalize( e.xyy*map( pos + e.xyy ).x +
|
||||
e.yyx*map( pos + e.yyx ).x +
|
||||
e.yxy*map( pos + e.yxy ).x +
|
||||
e.xxx*map( pos + e.xxx ).x );
|
||||
return normalize(e.xyy*map(pos + e.xyy).x +
|
||||
e.yyx*map(pos + e.yyx).x +
|
||||
e.yxy*map(pos + e.yxy).x +
|
||||
e.xxx*map(pos + e.xxx).x);
|
||||
/*
|
||||
vec3 eps = vec3( 0.0005, 0.0, 0.0 );
|
||||
vec3 eps = vec3(0.0005, 0.0, 0.0);
|
||||
vec3 nor = vec3(
|
||||
map(pos+eps.xyy).x - map(pos-eps.xyy).x,
|
||||
map(pos+eps.yxy).x - map(pos-eps.yxy).x,
|
||||
map(pos+eps.yyx).x - map(pos-eps.yyx).x );
|
||||
map(pos+eps.yyx).x - map(pos-eps.yyx).x);
|
||||
return normalize(nor);
|
||||
*/
|
||||
}
|
||||
|
||||
float calcAO( in vec3 pos, in vec3 nor )
|
||||
float calcAO(in vec3 pos, in vec3 nor)
|
||||
{
|
||||
float occ = 0.0;
|
||||
float sca = 1.0;
|
||||
for( int i=0; i<5; i++ )
|
||||
for (int i=0; i<5; i++)
|
||||
{
|
||||
float hr = 0.01 + 0.12*float(i)/4.0;
|
||||
vec3 aopos = nor * hr + pos;
|
||||
float dd = map( aopos ).x;
|
||||
vec3 aopos = nor*hr + pos;
|
||||
float dd = map(aopos).x;
|
||||
occ += -(dd-hr)*sca;
|
||||
sca *= 0.95;
|
||||
}
|
||||
return clamp( 1.0 - 3.0*occ, 0.0, 1.0 );
|
||||
return clamp(1.0 - 3.0*occ, 0.0, 1.0);
|
||||
}
|
||||
|
||||
// http://iquilezles.org/www/articles/checkerfiltering/checkerfiltering.htm
|
||||
float checkersGradBox( in vec2 p )
|
||||
float checkersGradBox(in vec2 p)
|
||||
{
|
||||
// filter kernel
|
||||
vec2 w = fwidth(p) + 0.001;
|
||||
@@ -328,43 +328,43 @@ float checkersGradBox( in vec2 p )
|
||||
return 0.5 - 0.5*i.x*i.y;
|
||||
}
|
||||
|
||||
vec3 render( in vec3 ro, in vec3 rd )
|
||||
vec3 render(in vec3 ro, in vec3 rd)
|
||||
{
|
||||
vec3 col = vec3(0.7, 0.9, 1.0) +rd.y*0.8;
|
||||
vec2 res = castRay(ro,rd);
|
||||
float t = res.x;
|
||||
float m = res.y;
|
||||
if( m>-0.5 )
|
||||
if (m>-0.5)
|
||||
{
|
||||
vec3 pos = ro + t*rd;
|
||||
vec3 nor = calcNormal( pos );
|
||||
vec3 ref = reflect( rd, nor );
|
||||
vec3 nor = calcNormal(pos);
|
||||
vec3 ref = reflect(rd, nor);
|
||||
|
||||
// material
|
||||
col = 0.45 + 0.35*sin( vec3(0.05,0.08,0.10)*(m-1.0) );
|
||||
if( m<1.5 )
|
||||
col = 0.45 + 0.35*sin(vec3(0.05,0.08,0.10)*(m-1.0));
|
||||
if (m<1.5)
|
||||
{
|
||||
|
||||
float f = checkersGradBox( 5.0*pos.xz );
|
||||
float f = checkersGradBox(5.0*pos.xz);
|
||||
col = 0.3 + f*vec3(0.1);
|
||||
}
|
||||
|
||||
// lighting
|
||||
float occ = calcAO( pos, nor );
|
||||
vec3 lig = normalize( vec3(cos(-0.4 * runTime), sin(0.7 * runTime), -0.6) );
|
||||
vec3 hal = normalize( lig-rd );
|
||||
float amb = clamp( 0.5+0.5*nor.y, 0.0, 1.0 );
|
||||
float dif = clamp( dot( nor, lig ), 0.0, 1.0 );
|
||||
float bac = clamp( dot( nor, normalize(vec3(-lig.x,0.0,-lig.z))), 0.0, 1.0 )*clamp( 1.0-pos.y,0.0,1.0);
|
||||
float dom = smoothstep( -0.1, 0.1, ref.y );
|
||||
float fre = pow( clamp(1.0+dot(nor,rd),0.0,1.0), 2.0 );
|
||||
float occ = calcAO(pos, nor);
|
||||
vec3 lig = normalize(vec3(cos(-0.4*runTime), sin(0.7*runTime), -0.6));
|
||||
vec3 hal = normalize(lig-rd);
|
||||
float amb = clamp(0.5+0.5*nor.y, 0.0, 1.0);
|
||||
float dif = clamp(dot(nor, lig), 0.0, 1.0);
|
||||
float bac = clamp(dot(nor, normalize(vec3(-lig.x,0.0,-lig.z))), 0.0, 1.0)*clamp(1.0-pos.y,0.0,1.0);
|
||||
float dom = smoothstep(-0.1, 0.1, ref.y);
|
||||
float fre = pow(clamp(1.0+dot(nor,rd),0.0,1.0), 2.0);
|
||||
|
||||
dif *= calcSoftshadow( pos, lig, 0.02, 2.5 );
|
||||
dom *= calcSoftshadow( pos, ref, 0.02, 2.5 );
|
||||
dif *= calcSoftshadow(pos, lig, 0.02, 2.5);
|
||||
dom *= calcSoftshadow(pos, ref, 0.02, 2.5);
|
||||
|
||||
float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0)*
|
||||
float spe = pow(clamp(dot(nor, hal), 0.0, 1.0),16.0)*
|
||||
dif *
|
||||
(0.04 + 0.96*pow( clamp(1.0+dot(hal,rd),0.0,1.0), 5.0 ));
|
||||
(0.04 + 0.96*pow(clamp(1.0+dot(hal,rd),0.0,1.0), 5.0));
|
||||
|
||||
vec3 lin = vec3(0.0);
|
||||
lin += 1.30*dif*vec3(1.00,0.80,0.55);
|
||||
@@ -375,51 +375,51 @@ vec3 render( in vec3 ro, in vec3 rd )
|
||||
col = col*lin;
|
||||
col += 10.00*spe*vec3(1.00,0.90,0.70);
|
||||
|
||||
col = mix( col, vec3(0.8,0.9,1.0), 1.0-exp( -0.0002*t*t*t ) );
|
||||
col = mix(col, vec3(0.8,0.9,1.0), 1.0-exp(-0.0002*t*t*t));
|
||||
}
|
||||
|
||||
return vec3( clamp(col,0.0,1.0) );
|
||||
return vec3(clamp(col,0.0,1.0));
|
||||
}
|
||||
|
||||
mat3 setCamera( in vec3 ro, in vec3 ta, float cr )
|
||||
mat3 setCamera(in vec3 ro, in vec3 ta, float cr)
|
||||
{
|
||||
vec3 cw = normalize(ta-ro);
|
||||
vec3 cp = vec3(sin(cr), cos(cr),0.0);
|
||||
vec3 cu = normalize( cross(cw,cp) );
|
||||
vec3 cv = normalize( cross(cu,cw) );
|
||||
return mat3( cu, cv, cw );
|
||||
vec3 cu = normalize(cross(cw,cp));
|
||||
vec3 cv = normalize(cross(cu,cw));
|
||||
return mat3(cu, cv, cw);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 tot = vec3(0.0);
|
||||
#if AA>1
|
||||
for( int m=0; m<AA; m++ )
|
||||
for( int n=0; n<AA; n++ )
|
||||
for (int m=0; m<AA; m++)
|
||||
for (int n=0; n<AA; n++)
|
||||
{
|
||||
// pixel coordinates
|
||||
vec2 o = vec2(float(m),float(n)) / float(AA) - 0.5;
|
||||
vec2 o = vec2(float(m),float(n))/float(AA) - 0.5;
|
||||
vec2 p = (-resolution.xy + 2.0*(gl_FragCoord.xy+o))/resolution.y;
|
||||
#else
|
||||
vec2 p = (-resolution.xy + 2.0*gl_FragCoord.xy)/resolution.y;
|
||||
#endif
|
||||
|
||||
// RAY: Camera is provided from raylib
|
||||
//vec3 ro = vec3( -0.5+3.5*cos(0.1*time + 6.0*mo.x), 1.0 + 2.0*mo.y, 0.5 + 4.0*sin(0.1*time + 6.0*mo.x) );
|
||||
//vec3 ro = vec3(-0.5+3.5*cos(0.1*time + 6.0*mo.x), 1.0 + 2.0*mo.y, 0.5 + 4.0*sin(0.1*time + 6.0*mo.x));
|
||||
|
||||
vec3 ro = viewEye;
|
||||
vec3 ta = viewCenter;
|
||||
|
||||
// camera-to-world transformation
|
||||
mat3 ca = setCamera( ro, ta, 0.0 );
|
||||
mat3 ca = setCamera(ro, ta, 0.0);
|
||||
// ray direction
|
||||
vec3 rd = ca * normalize( vec3(p.xy,2.0) );
|
||||
vec3 rd = ca*normalize(vec3(p.xy,2.0));
|
||||
|
||||
// render
|
||||
vec3 col = render( ro, rd );
|
||||
vec3 col = render(ro, rd);
|
||||
|
||||
// gamma
|
||||
col = pow( col, vec3(0.4545) );
|
||||
col = pow(col, vec3(0.4545));
|
||||
|
||||
tot += col;
|
||||
#if AA>1
|
||||
@@ -427,5 +427,5 @@ void main()
|
||||
tot /= float(AA*AA);
|
||||
#endif
|
||||
|
||||
gl_FragColor = vec4( tot, 1.0 );
|
||||
gl_FragColor = vec4(tot, 1.0);
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
// Note: SDF by Iñigo Quilez is licensed under MIT License
|
||||
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// NOTE: SDF by Iñigo Quilez, licensed under MIT License
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
@@ -35,7 +35,7 @@ void main()
|
||||
fragColor = color;
|
||||
*/
|
||||
// Scanlines method 2
|
||||
float globalPos = (fragTexCoord.y + offset) * frequency;
|
||||
float globalPos = (fragTexCoord.y + offset)*frequency;
|
||||
float wavePos = cos((fract(globalPos) - 0.5)*3.14);
|
||||
|
||||
vec4 color = texture2D(texture0, fragTexCoord);
|
||||
|
86
examples/shaders/resources/shaders/glsl100/shadowmap.fs
Normal file
86
examples/shaders/resources/shaders/glsl100/shadowmap.fs
Normal file
@@ -0,0 +1,86 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// This shader is based on the basic lighting shader
|
||||
// This only supports one light, which is directional, and it (of course) supports shadows
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec3 fragPosition;
|
||||
varying vec2 fragTexCoord;
|
||||
//varying in vec4 fragColor;
|
||||
varying vec3 fragNormal;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// Input lighting values
|
||||
uniform vec3 lightDir;
|
||||
uniform vec4 lightColor;
|
||||
uniform vec4 ambient;
|
||||
uniform vec3 viewPos;
|
||||
|
||||
// Input shadowmapping values
|
||||
uniform mat4 lightVP; // Light source view-projection matrix
|
||||
uniform sampler2D shadowMap;
|
||||
|
||||
uniform int shadowMapResolution;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Texel color fetching from texture sampler
|
||||
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
||||
vec3 lightDot = vec3(0.0);
|
||||
vec3 normal = normalize(fragNormal);
|
||||
vec3 viewD = normalize(viewPos - fragPosition);
|
||||
vec3 specular = vec3(0.0);
|
||||
|
||||
vec3 l = -lightDir;
|
||||
|
||||
float NdotL = max(dot(normal, l), 0.0);
|
||||
lightDot += lightColor.rgb*NdotL;
|
||||
|
||||
float specCo = 0.0;
|
||||
if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewD, reflect(-(l), normal))), 16.0); // 16 refers to shine
|
||||
specular += specCo;
|
||||
|
||||
vec4 finalColor = (texelColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0)));
|
||||
|
||||
// Shadow calculations
|
||||
vec4 fragPosLightSpace = lightVP*vec4(fragPosition, 1);
|
||||
fragPosLightSpace.xyz /= fragPosLightSpace.w; // Perform the perspective division
|
||||
fragPosLightSpace.xyz = (fragPosLightSpace.xyz + 1.0)/2.0; // Transform from [-1, 1] range to [0, 1] range
|
||||
vec2 sampleCoords = fragPosLightSpace.xy;
|
||||
float curDepth = fragPosLightSpace.z;
|
||||
|
||||
// Slope-scale depth bias: depth biasing reduces "shadow acne" artifacts, where dark stripes appear all over the scene
|
||||
// The solution is adding a small bias to the depth
|
||||
// In this case, the bias is proportional to the slope of the surface, relative to the light
|
||||
float bias = max(0.0008*(1.0 - dot(normal, l)), 0.00008);
|
||||
int shadowCounter = 0;
|
||||
const int numSamples = 9;
|
||||
|
||||
// PCF (percentage-closer filtering) algorithm:
|
||||
// Instead of testing if just one point is closer to the current point,
|
||||
// we test the surrounding points as well
|
||||
// This blurs shadow edges, hiding aliasing artifacts
|
||||
vec2 texelSize = vec2(1.0/float(shadowMapResolution));
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int y = -1; y <= 1; y++)
|
||||
{
|
||||
float sampleDepth = texture2D(shadowMap, sampleCoords + texelSize*vec2(x, y)).r;
|
||||
if (curDepth - bias > sampleDepth) shadowCounter++;
|
||||
}
|
||||
}
|
||||
|
||||
finalColor = mix(finalColor, vec4(0, 0, 0, 1), float(shadowCounter)/float(numSamples));
|
||||
|
||||
// Add ambient lighting whether in shadow or not
|
||||
finalColor += texelColor*(ambient/10.0)*colDiffuse;
|
||||
|
||||
// Gamma correction
|
||||
finalColor = pow(finalColor, vec4(1.0/2.2));
|
||||
gl_FragColor = finalColor;
|
||||
}
|
32
examples/shaders/resources/shaders/glsl100/shadowmap.vs
Normal file
32
examples/shaders/resources/shaders/glsl100/shadowmap.vs
Normal file
@@ -0,0 +1,32 @@
|
||||
#version 100
|
||||
|
||||
// Input vertex attributes
|
||||
attribute vec3 vertexPosition;
|
||||
attribute vec2 vertexTexCoord;
|
||||
attribute vec3 vertexNormal;
|
||||
attribute vec4 vertexColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 mvp;
|
||||
uniform mat4 matModel;
|
||||
uniform mat4 matNormal;
|
||||
|
||||
// Output vertex attributes (to fragment shader)
|
||||
varying vec3 fragPosition;
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
varying vec3 fragNormal;
|
||||
|
||||
// NOTE: Add your custom variables here
|
||||
|
||||
void main()
|
||||
{
|
||||
// Send vertex attributes to fragment shader
|
||||
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
|
||||
fragTexCoord = vertexTexCoord;
|
||||
fragColor = vertexColor;
|
||||
fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
|
||||
|
||||
// Calculate final vertex position
|
||||
gl_Position = mvp*vec4(vertexPosition, 1.0);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user