Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/raysan5/raylib
Browse files Browse the repository at this point in the history
  • Loading branch information
raysan5 committed Oct 15, 2021
2 parents 84edd22 + 2a6bd97 commit 226c0e3
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 109 deletions.
34 changes: 22 additions & 12 deletions SPONSORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@

The following people is currently [**sponsoring raylib**](https://github.com/sponsors/raysan5) with a generous donation to allow improving and growing the project!

Note that Sponsors donations vary between sponsors, I just decided not to make any distinction while listing them.

- Eric J. ([@ProfJski](https://github.com/ProfJski))
- devdad ([@devdad](https://github.com/devdad))
- Zach Geis ([@zacgeis](https://github.com/zacgeis))
- minirop ([@minirop](https://github.com/minirop))
- Daniel Gómez ([@Koocachookies](https://github.com/Koocachookies))
- Sergio ([@anidealgift](https://github.com/anidealgift))
- Marc Agüera ([@maguera93](https://github.com/maguera93))
- Pau Fernández ([@pauek](https://github.com/pauek))
- Snowminx ([@Gamerfiend](https://github.com/Gamerfiend))
- NimbusFox ([@NimbusFox](https://github.com/NimbusFox))
- Robin Mattheussen ([@romatthe](https://github.com/romatthe))
- Grant Haywood ([@cinterloper](https://github.com/cinterloper))
- Terry Nguyen ([@terrehbyte](https://github.com/terrehbyte))
Expand All @@ -25,10 +18,17 @@ Note that Sponsors donations vary between sponsors, I just decided not to make a
- cob ([@majorcob](https://github.com/majorcob))
- Samuel Batista ([@gamedevsam](https://github.com/gamedevsam))
- Merlyn Morgan-Graham ([@kavika13](https://github.com/kavika13))
- Toby4213 ([@Toby4213](https://github.com/Toby4213))
- linus ([@hochbaum](https://github.com/hochbaum))
- Nawarian ([@nawarian](https://github.com/nawarian) - [thephp.website](https://thephp.website/))

- kenzie ([@sme-ek](https://github.com/sme-ek))
- Allan Regush ([@AllanRegush](https://github.com/AllanRegush))
- Jeffery Myers ([@JeffM2501](https://github.com/ProfJski))
- Ryan Roden-Corrent ([@rcorre](https://github.com/ProfJski))
- michaelfiber ([@michaelfiber](https://github.com/ProfJski))
- Nikhilesh S ([@nikki93](https://github.com/ProfJski))
- kevinabraun ([@kevinabraun](https://github.com/ProfJski))
- Matthew Owens ([@MatthewOwens](https://github.com/ProfJski))
- Tim Eilers ([@eilerstim](https://github.com/ProfJski))

### Past raylib GitHub Sponsors

Expand All @@ -49,10 +49,20 @@ The following people has **sponsored raylib** in the past, allowing the project
- James Ghawaly ([@jghawaly](https://github.com/jghawaly))
- jack ([@Jack-Ji](https://github.com/Jack-Ji))
- Guido Offermans ([@jghawaly](https://github.com/GuidoOffermans))
- devdad ([@devdad](https://github.com/devdad))
- Pau Fernández ([@pauek](https://github.com/pauek))
- Sergio ([@anidealgift](https://github.com/anidealgift))
- Snowminx ([@Gamerfiend](https://github.com/Gamerfiend))
- NimbusFox ([@NimbusFox](https://github.com/NimbusFox))
- Shylie ([@Shylie](https://github.com/Shylie))
- Livio Dal Maso ([@Humeur](https://github.com/Humeur))
- Diego Vaccher ([@denny0754](https://github.com/denny0754))
- Ricardo Alcantara ([@ricardoalcantara](https://github.com/ricardoalcantara))
- Toby4213 ([@Toby4213](https://github.com/Toby4213))

### Notes for Current/Past raylib Sponsor

- **If you are not on the list, feel free to send a PR to add you if desired.**
- **If you want your personal webpage listed along your GitHub account, feel free to send a PR to add it.**
- **If you prefer not to listed in this list, feel free to send a PR to remove it.**
- If you are not on the list, feel free to send a PR to be added (if desired).
- If you want your personal webpage or project listed, feel free to send a PR to be added.
- If you prefer not to be in this list, feel free to send a PR to be remove.

18 changes: 18 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## Building the Examples

The examples assume you have already built the `raylib` library in `../src`.

### With GNU make

- `make` builds all examples
- `make [module]` builds all examples for a particular module (e.g `make core`)

### With Zig

The [Zig](https://ziglang.org/) toolchain can compile `C` and `C++` in addition to `Zig`.
You may find it easier to use than other toolchains, especially when it comes to cross-compiling.

- `zig build` to compile all examples
- `zig build [module]` to compile all examples for a module (e.g. `zig build core`)
- `zig build [example]` to compile _and run_ a particular example (e.g. `zig build core_basic_window`)

## EXAMPLES LIST

### category: core
Expand Down
86 changes: 86 additions & 0 deletions examples/build.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
const std = @import("std");
const builtin = @import("builtin");

fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zig.CrossTarget) !*std.build.Step {
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();

const all = b.step(module, "All " ++ module ++ " examples");
const dir = try std.fs.cwd().openDir(
module,
.{ .iterate = true },
);
var iter = dir.iterate();
while (try iter.next()) |entry| {
if (entry.kind != .File) continue;
const extension_idx = std.mem.lastIndexOf(u8, entry.name, ".c") orelse continue;
const name = entry.name[0..extension_idx];
const path = try std.fs.path.join(b.allocator, &.{ module, entry.name });

// zig's mingw headers do not include pthread.h
if (std.mem.eql(u8, "core_loading_thread", name) and target.getOsTag() == .windows) continue;

const exe = b.addExecutable(name, path);
exe.setTarget(target);
exe.setBuildMode(mode);
exe.linkLibC();
exe.addObjectFile(switch (target.getOsTag()) {
.windows => "../src/raylib.lib",
.linux => "../src/libraylib.a",
else => @panic("Unsupported OS"),
});

exe.addIncludeDir("../src");
exe.addIncludeDir("../src/external");
exe.addIncludeDir("../src/external/glfw/include");

switch (exe.target.toTarget().os.tag) {
.windows => {
exe.linkSystemLibrary("winmm");
exe.linkSystemLibrary("gdi32");
exe.linkSystemLibrary("opengl32");
exe.addIncludeDir("external/glfw/deps/mingw");
},
.linux => {
exe.linkSystemLibrary("GL");
exe.linkSystemLibrary("rt");
exe.linkSystemLibrary("dl");
exe.linkSystemLibrary("m");
exe.linkSystemLibrary("X11");
},
else => {
@panic("Unsupported OS");
},
}

exe.setOutputDir(module);

var run = exe.run();
run.step.dependOn(&b.addInstallArtifact(exe).step);
run.cwd = module;
b.step(name, name).dependOn(&run.step);
all.dependOn(&exe.step);
}
return all;
}

pub fn build(b: *std.build.Builder) !void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});

const all = b.getInstallStep();

all.dependOn(try add_module("audio", b, target));
all.dependOn(try add_module("core", b, target));
all.dependOn(try add_module("models", b, target));
all.dependOn(try add_module("others", b, target));
all.dependOn(try add_module("physics", b, target));
all.dependOn(try add_module("shaders", b, target));
all.dependOn(try add_module("shapes", b, target));
all.dependOn(try add_module("text", b, target));
all.dependOn(try add_module("textures", b, target));
}
33 changes: 15 additions & 18 deletions examples/models/models_loading_gltf.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
/*******************************************************************************************
*
* raylib [models] example - Load 3d gltf model
* raylib [models] example - Load models gltf
*
* This example has been created using raylib 3.5 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* NOTE: To export a model from Blender, make sure it is not posed, the vertices need to be
* in the same position as they would be in edit mode.
* Also make sure the scale parameter of your models is set to 0.0,
* scaling can be applied from the export menu.
*
* Example contributed by Hristo Stamenov (@object71) and reviewed by Ramon Santamaria (@raysan5)
*
* Copyright (c) 2021 Hristo Stamenov (@object71) and Ramon Santamaria (@raysan5)
*
********************************************************************************************
*
* To export a model from blender, make sure it is not posed, the vertices need to be in the
* same position as they would be in edit mode.
* and that the scale of your models is set to 0. Scaling can be done from the export menu.
*
********************************************************************************************/

#include "raylib.h"

#include <stdlib.h>

#define MAX_MODELS 8
#define MAX_GLTF_MODELS 8

int main(void)
{
Expand All @@ -40,8 +37,8 @@ int main(void)
camera.fovy = 45.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type

Model model[MAX_MODELS] = { 0 };

// Load some models
Model model[MAX_GLTF_MODELS] = { 0 };
model[0] = LoadModel("resources/models/gltf/raylib_32x32.glb");
model[1] = LoadModel("resources/models/gltf/rigged_figure.glb");
model[2] = LoadModel("resources/models/gltf/GearboxAssy.glb");
Expand All @@ -65,19 +62,20 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(&camera);
UpdateCamera(&camera); // Update our camera with inputs

if (IsKeyReleased(KEY_RIGHT))
{
currentModel++;
if (currentModel == MAX_MODELS) currentModel = 0;
if (currentModel == MAX_GLTF_MODELS) currentModel = 0;
}

if (IsKeyReleased(KEY_LEFT))
{
currentModel--;
if (currentModel < 0) currentModel = MAX_MODELS - 1;
if (currentModel < 0) currentModel = MAX_GLTF_MODELS - 1;
}
//----------------------------------------------------------------------------------

// Draw
//----------------------------------------------------------------------------------
Expand All @@ -87,8 +85,7 @@ int main(void)

BeginMode3D(camera);

DrawModelEx(model[currentModel], position, (Vector3){ 0.0f, 1.0f, 0.0f }, 180.0f, (Vector3){ 2.0f, 2.0f, 2.0f }, WHITE);

DrawModel(model[currentModel], position, 1.0f, WHITE);
DrawGrid(10, 1.0f); // Draw a grid

EndMode3D();
Expand All @@ -99,7 +96,7 @@ int main(void)

// De-Initialization
//--------------------------------------------------------------------------------------
for (int i = 0; i < MAX_MODELS; i++) UnloadModel(model[i]); // Unload models
for (int i = 0; i < MAX_GLTF_MODELS; i++) UnloadModel(model[i]); // Unload models

CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 226c0e3

Please sign in to comment.