10 Commits

Author SHA1 Message Date
Ray
dbc56a87da Update HISTORY.md 2026-04-23 00:18:40 +02:00
Ray
932558ca7a Update HISTORY.md 2026-04-22 13:41:27 +02:00
Ray
7495a77a79 Update CHANGELOG 2026-04-22 13:41:15 +02:00
Ray
a4680fc677 Update HISTORY.md 2026-04-19 20:03:35 +02:00
Ray
d6445b55d6 Update core_basic_window.c 2026-04-19 20:03:31 +02:00
Ray
d87bf55607 Update CHANGELOG 2026-04-19 20:03:29 +02:00
a32b53f4d6 [build.zig] Refactor (#5764)
* Add better structure for build.zig

Temporarily disabled the tests

* Cleanup build.zig a bit

* Fixed zemscripten and cleanup other platforms

* Make opengl_version selection more restritive

* Add traslateC to build; Renable examples

* Add raygui build to build.zig

* Deny glfw from android target

* Fix android platform includes

* Add Zig project example

* Add Zig project mention to README

* Set right name for web build in zig example

* Cleanup last parts of build.zig

* Add linking method for build.zig

* Fix lshcore link for glfw and rgfw build.zig

* Fix weird sdl linkage build.zig

* Add zig example to zig project

* Fix win32, mac build bugs in build.zig

* Rename argument lshcore to shcore build.zig
2026-04-19 13:57:58 +02:00
Ray
cc752037b9 Update rmodels.c 2026-04-19 13:54:39 +02:00
90e9145978 Making it similar to CheckCollisionSpheres to remove pow function (#5776) 2026-04-19 13:51:52 +02:00
9060ac7c95 Mouse delta calculation with scaling (#5779)
Added scaling from SetMouseScale to mouse GetMouseDelta
2026-04-19 13:50:15 +02:00
13 changed files with 880 additions and 381 deletions

View File

@ -17,7 +17,7 @@ KEY CHANGES:
- New File System API
- New Text Management API
- New tool: [rexm] raylib examples manager
- Added +50 new examples to learn from
- Added +70 new examples to learn from
Detailed changes:
@ -115,6 +115,7 @@ Detailed changes:
[rcore][GLFW] REVIEWED: `GetGamepadButtonPressed()`, return GAMEPAD_BUTTON_*_TRIGGER_2 if pressed (#4742) by @whaleymar
[rcore][GLFW] REVIEWED: Update `mappings.h` using `GenerateMappings.cmake` by @sleeptightAnsiC
[rcore][RGFW] ADDED: New backend option: `PLATFORM_WEB_RGFW` and update RGFW (#4480) by @colleagueRiley
[rcore][RGFW] ADDED: Support for software rendering (#5773) by @CrackedPixel
[rcore][RGFW] REVIEWED: Added missing Right Control key by @M374LX
[rcore][RGFW] REVIEWED: Changed `RGFW_window_eventWait` timeout to -1 by @doggymangc
[rcore][RGFW] REVIEWED: Duplicate entries removed from `keyMappingRGFW` (#5242) by @iamahuman1395
@ -326,6 +327,7 @@ Detailed changes:
[rmodels] REVIEWED: `DrawSphereEx()`, normals support (#4926) by @karl-zylinski
[rmodels] REVIEWED: `ExportMesh()`, improve OBJ vertex data precision and lower memory usage (#4496) by @mikeemm
[rmodels] REVIEWED: `CheckCollisionSpheres()`, simplified using `Vector3DistanceSqr()` (#5695) by @Bigfoot71
[rmodels] REVIEWED: `CheckCollisionBoxSphere()`, improved performance and consistency (#5776) by @maiconpintoabreu
[raudio] REVIEWED: Fix a glitch at the end of a sound (#5578) by @mackron
[raudio] REVIEWED: Improvements to device configuration (#5577) by @mackron
[raudio] REVIEWED: Initialize sound alias properties as if it was a new sound (#5123) by @JeffM2501
@ -410,11 +412,12 @@ Detailed changes:
[build][CMake] REVIEWED: Set `libm` as public so it can be linked by consumer (#5193) by @brccabral
[build][Cmake] REVIEWED: Expose PLATFORM_WEB_RGFW (#5579) by @crisserpl2
[build][Zig] ADDED: Android target to build by @lumenkeyes
[build][Zig] REDESIGNED: Complete refactor of build.zig to support Zig 0.16.0 (#5764) by @HaxSam
[build][Zig] REVIEWED: Link EGL for Android by @lumenkeyes
[build][Zig] REVIEWED: Approach to build for web with zig-build (#5157) by @haxsam
[build][Zig] REVIEWED: Fix build accessing env vars (#5490) by @iisakki
[build][Zig] REVIEWED: Fix emscripten building by @johnnymarler
[build][Zig] REVIWED: Move examples/build.zig into main build.zig by @johnnymarler
[build][Zig] REVIEWED: Move examples/build.zig into main build.zig by @johnnymarler
[build][Zig] REVIEWED: Fix raygui inclusion in windows crosscompilation (#4489) by @kimierik
[build][Zig] REVIEWED: Issue on emscripten run if the user has not installed emsdk by @emilhakimov415
[build][Zig] REVIEWED: Make X11 the default display backend instead of choosing at runtime (#5168) by @Not-Nik
@ -462,6 +465,7 @@ Detailed changes:
[examples] ADDED: `shapes_rlgl_triangle` example (#5353) by @robinsaviary
[examples] ADDED: `shapes_starfield` (#5255) by @themushroompirates
[examples] ADDED: `shapes_triangle_strip` (#5240) by @Jopestpe
[examples] ADDED: `shapes_collision_ellipses` (#5722) by @Monjaris
[examples] ADDED: `text_inline_styling` by @raysan5
[examples] ADDED: `text_strings_management` (#5379) by @davidbuzatto
[examples] ADDED: `text_words_alignment` (#5254) by @themushroompirates

View File

@ -530,10 +530,10 @@ A new `raylib` release is finally ready and, again, this is the **biggest `rayli
Some astonishing numbers for this release:
- **+320** closed issues (for a TOTAL of **+2140**!)
- **+1950** commits since previous RELEASE (for a TOTAL of **+9700**!)
- **+330** closed issues (for a TOTAL of **+2150**!)
- **+2000** commits since previous RELEASE (for a TOTAL of **+9760**!)
- **+20** new functions ADDED to raylib API (for a TOTAL of **600**!)
- **+50** new examples to learn from (for a TOTAL of **+210**!)
- **+70** new examples to learn from (for a TOTAL of **+215**!)
- **+210** new contributors (for a TOTAL of **+850**!)
Highlights for `raylib 6.0`:
@ -591,14 +591,14 @@ COMMANDS:
update : Validate and update examples collection, generates report
```
- **`NEW` +50 new examples**: Thanks to `rexm` and the simplification on examples management, this new raylib release includes +50 new examples to leearn from, most of them contributed by community.
- **`NEW` +70 new examples**: Thanks to `rexm` and the simplification on examples management, this new raylib release includes +70 new examples to learn from, most of them contributed by community. Multiple examples have also been renamed for consistency and all examples header and structure have been reviewed and unified.
Make sure to check raylib [CHANGELOG](https://github.com/raysan5/raylib/blob/master/CHANGELOG) for a detailed list of changes!
I want to **thank all the contributors (+850!**) that along the years have **greatly improved raylib** and pushed it further and better day after day. And **many thanks to raylib community and all raylib users** for supporting the library along those many years.
Finally, I want to thank [puffer.ai](https://puffer.ai/) and [comma.ai](https://comma.ai/) for **supporting and sponsoring the project** as platinum sponsors, along many others individuals that have been sponsoring raylib along the years. Thanks to all of you for allowing me to keep working on this library!
Finally, I want to thank [puffer.ai](https://puffer.ai/) and [comma.ai](https://comma.ai/) for **using raylib and supporting the project** as platinum sponsors, along many others individuals that have been sponsoring raylib along the years. Thanks to all of you for allowing me to keep working on this library!
**After +12 years of development, `raylib 6.0` is today one of the bests libraries to enjoy games/tools/graphic programming!**
**After +12 years of development, `raylib 6.0` is today one of the bests libraries to enjoy games/tools/graphics programming!**
**Enjoy graphics programming with raylib!** :)

860
build.zig

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,11 @@
.hash = "N-V-__8AALShqgXkvqYU6f__FrA22SMWmi2TXCJjNTO1m8XJ",
.lazy = true,
},
.raygui = .{
.url = "git+https://github.com/raysan5/raygui#3b2855842ab578a034f827c38cf8f62c042fc983",
.hash = "N-V-__8AAHvybwBw1kyBGn0BW_s1RqIpycNjLf_XbE-fpLUF",
.lazy = true,
},
.emsdk = .{
.url = "git+https://github.com/emscripten-core/emsdk#4.0.9",
.hash = "N-V-__8AAJl1DwBezhYo_VE6f53mPVm00R-Fk28NPW7P14EQ",

View File

@ -22,7 +22,7 @@
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5)
* Copyright (c) 2013-2026 Ramon Santamaria (@raysan5)
*
********************************************************************************************/

View File

@ -13,6 +13,7 @@ IDE | Platform(s) | Source | Example(s)
[SublimeText](https://www.sublimetext.com/) | Windows, Linux, macOS | ✔️ | ✔️
[VS2019](https://www.visualstudio.com) | Windows | ✔️ | ✔️
[VSCode](https://code.visualstudio.com/) | Windows, macOS | ❌ | ✔️
[Zig](https://ziglang.org) | Windows, Linux, macOS, Web | ✔️ | ✔️
scripts | Windows, Linux, macOS | ✔️ | ✔️
*New IDEs config files are welcome!*

84
projects/Zig/README.md Normal file
View File

@ -0,0 +1,84 @@
# Starting your raylib project with Zig (0.16.0)
## How to compile and run it
To compile the project:
```sh
zig build
```
To run the project:
```sh
zig build run
```
## Compile with different optimization
To change from debug to release build you can do it with the `-Doptimze=` flag.
```
Debug
ReleaseSafe
ReleaseFast
ReleaseSmall
```
## Choose a different platform
To compile with a different platform you can use the `-Dplatform=` flag.
Here all the options:
```
glfw
rgfw
sdl
sdl2
sdl3
memory
win32
drm
android
```
In this example the platform `sdl` and `sdl2` are not supported
Important for the android platform you also have to compile for the right target
## Compile for a different target
To compile for a different [target](https://ziglang.org/download/0.16.0/release-notes.html#Support-Table) you can use the `-Dtarget=` flag.
Not all targets are supported
## Example: Compile for web and run it
To compile for the web we use emscripten and you run it like that:
```sh
zig build -Dtarget=wasm32-emscripten
```
To run it we do:
```sh
zig build run -Dtarget=wasm32-emscripten
```
And to make a relase build we do:
```sh
zig build -Dtarget=wasm32-emscripten -Doptimize=ReleaseFast
```
If we want to use rgfw for the web build we could do:
```sh
zig build -Dplatform=rgfw -Dtarget=wasm32-emscripten -Doptimize=ReleaseFast
```
## Compiling the Zig code? Just add `-Dzig` and try out zig ;)
## More Resources
See [Zig Build System](https://ziglang.org/learn/build-system/)

87
projects/Zig/build.zig Normal file
View File

@ -0,0 +1,87 @@
const std = @import("std");
const rl = @import("raylib");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const platform = b.option(rl.PlatformBackend, "platform", "select the platform") orelse rl.PlatformBackend.glfw;
const zig = b.option(bool, "zig", "compile zig code") orelse false;
const raylib_dep = b.dependency("raylib", .{
.target = target,
.optimize = optimize,
.platform = platform,
});
const raylib_artifact = raylib_dep.artifact("raylib");
if (platform == .sdl3) {
if (b.lazyDependency("sdl3", .{ .optimize = optimize, .target = target })) |dep| {
raylib_artifact.root_module.linkLibrary(dep.artifact("SDL3"));
}
}
var exe_mod: *std.Build.Module = undefined;
if (zig) {
exe_mod = b.createModule(.{
.root_source_file = b.path("src/core_basic_window.zig"),
.target = target,
.optimize = optimize,
});
exe_mod.addImport("raylib", raylib_dep.module("raylib"));
} else {
exe_mod = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
});
exe_mod.addCSourceFile(.{ .file = b.path("src/core_basic_window.c") });
exe_mod.linkLibrary(raylib_artifact);
}
const run_step = b.step("run", "Run the app");
// web exports are completely separate
if (target.query.os_tag == .emscripten) {
const emsdk = rl.emsdk;
const wasm = b.addLibrary(.{
.name = "core_basic_window_web",
.root_module = exe_mod,
});
const install_dir: std.Build.InstallDir = .{ .custom = "web" };
const emcc_flags = emsdk.emccDefaultFlags(b.allocator, .{ .optimize = optimize });
const emcc_settings = emsdk.emccDefaultSettings(b.allocator, .{ .optimize = optimize });
const emcc_step = emsdk.emccStep(b, raylib_artifact, wasm, .{
.optimize = optimize,
.flags = emcc_flags,
.settings = emcc_settings,
.shell_file_path = emsdk.shell(raylib_dep),
.install_dir = install_dir,
});
b.getInstallStep().dependOn(emcc_step);
const html_filename = try std.fmt.allocPrint(b.allocator, "{s}.html", .{wasm.name});
const emrun_step = emsdk.emrunStep(
b,
b.getInstallPath(install_dir, html_filename),
&.{},
);
emrun_step.dependOn(emcc_step);
run_step.dependOn(emrun_step);
} else {
const exe = b.addExecutable(.{
.name = "core_basic_window",
.root_module = exe_mod,
.use_lld = target.result.os.tag == .windows,
});
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
run_step.dependOn(&run_cmd.step);
}
}

View File

@ -0,0 +1,23 @@
.{
.name = .example,
.version = "0.0.1",
.minimum_zig_version = "0.16.0",
.paths = .{""},
.dependencies = .{
.raylib = .{
.path = "../../",
},
.emsdk = .{
.url = "git+https://github.com/emscripten-core/emsdk?ref=4.0.9#3bcf1dcd01f040f370e10fe673a092d9ed79ebb5",
.hash = "N-V-__8AAJl1DwBezhYo_VE6f53mPVm00R-Fk28NPW7P14EQ",
},
.sdl3 = .{
.url = "git+https://codeberg.org/7Games/zig-sdl3?ref=master#6d418ef3ddae99098414a96a88bf5e5fdb41785e",
.hash = "sdl3-0.1.9-NmT1QwiEJwByePqkmArtppCHQn8Y7kiSWcncT_Mop8ie",
.lazy = true,
},
},
.fingerprint = 0x6eec9b9f1a9d7aca,
}

View File

@ -0,0 +1,83 @@
/*******************************************************************************************
*
* raylib [core] example - Basic window (adapted for HTML5 platform)
*
* This example is prepared to compile for PLATFORM_WEB and PLATFORM_DESKTOP
* As you will notice, code structure is slightly different to the other examples...
* To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning
*
* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
//----------------------------------------------------------------------------------
// Module Functions Declaration
//----------------------------------------------------------------------------------
void UpdateDrawFrame(void); // Update and Draw one frame
//----------------------------------------------------------------------------------
// Program main entry point
//----------------------------------------------------------------------------------
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic 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
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
void UpdateDrawFrame(void)
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}

View File

@ -0,0 +1,73 @@
//*******************************************************************************************
//*
//* raylib [core] example - Basic window (adapted for HTML5 platform)
//*
//* This example is prepared to compile for PLATFORM_WEB and PLATFORM_DESKTOP
//* As you will notice, code structure is slightly different to the other examples...
//* To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning
//*
//* This example has been created using raylib 6.0 (www.raylib.com)
//* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
//*
//* Copyright (c) 2015 Ramon Santamaria (@raysan5)
//* Rewrite in Zig by HaxSam (@haxsam)
//*
//*******************************************************************************************
const rl = @import("raylib");
const std = @import("std");
const builtin = @import("builtin");
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
const screenWidth: c_int = 800;
const screenHeight: c_int = 450;
//----------------------------------------------------------------------------------
// Program main entry point
//----------------------------------------------------------------------------------
pub fn main() void {
// Initialization
//--------------------------------------------------------------------------------------
rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
if (builtin.os.tag == .emscripten) {
std.os.emscripten.emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
} else {
rl.SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!rl.WindowShouldClose()) // Detect window close button or ESC key
{
UpdateDrawFrame();
}
}
// De-Initialization
//--------------------------------------------------------------------------------------
rl.CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
}
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
fn UpdateDrawFrame() callconv(.c) void {
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
rl.BeginDrawing();
rl.ClearBackground(rl.RAYWHITE);
rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY);
rl.EndDrawing();
//----------------------------------------------------------------------------------
}

View File

@ -4125,8 +4125,8 @@ Vector2 GetMouseDelta(void)
{
Vector2 delta = { 0 };
delta.x = CORE.Input.Mouse.currentPosition.x - CORE.Input.Mouse.previousPosition.x;
delta.y = CORE.Input.Mouse.currentPosition.y - CORE.Input.Mouse.previousPosition.y;
delta.x = (CORE.Input.Mouse.currentPosition.x - CORE.Input.Mouse.previousPosition.x)*CORE.Input.Mouse.scale.x;
delta.y = (CORE.Input.Mouse.currentPosition.y - CORE.Input.Mouse.previousPosition.y)*CORE.Input.Mouse.scale.y;
return delta;
}

View File

@ -4105,7 +4105,7 @@ bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, floa
// Check for distances squared to avoid sqrtf()
float radSum = radius1 + radius2;
if (Vector3DistanceSqr(center1, center2) <= radSum*radSum) collision = true;
if (Vector3DistanceSqr(center1, center2) <= (radSum*radSum)) collision = true;
return collision;
}
@ -4131,18 +4131,13 @@ bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius)
{
bool collision = false;
float dmin = 0;
Vector3 closestPoint = {
Clamp(center.x, box.min.x, box.max.x),
Clamp(center.y, box.min.y, box.max.y),
Clamp(center.z, box.min.z, box.max.z)
};
if (center.x < box.min.x) dmin += powf(center.x - box.min.x, 2);
else if (center.x > box.max.x) dmin += powf(center.x - box.max.x, 2);
if (center.y < box.min.y) dmin += powf(center.y - box.min.y, 2);
else if (center.y > box.max.y) dmin += powf(center.y - box.max.y, 2);
if (center.z < box.min.z) dmin += powf(center.z - box.min.z, 2);
else if (center.z > box.max.z) dmin += powf(center.z - box.max.z, 2);
if (dmin <= (radius*radius)) collision = true;
if (Vector3DistanceSqr(center, closestPoint) <= (radius*radius)) collision = true;
return collision;
}