From 1b084ff9f256bea3406255322fce4618e0b250f0 Mon Sep 17 00:00:00 2001
From: Thomas Anderson <5776225+CrackedPixel@users.noreply.github.com>
Date: Sun, 22 Mar 2026 03:06:03 -0500
Subject: [PATCH 01/12] fixed error in readme, found by discord user the.enemy
(#5680)
---
examples/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/README.md b/examples/README.md
index 43e2dcc63..d48641528 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -223,7 +223,7 @@ Examples using raylib models functionality, including models loading/generation
### category: shaders [35]
-Examples using raylib shaders functionality, including shaders loading, parameters configuration and drawing using them (model shaders and postprocessing shaders). This functionality is directly provided by raylib [rlgl](../src/rlgl.c) module.
+Examples using raylib shaders functionality, including shaders loading, parameters configuration and drawing using them (model shaders and postprocessing shaders). This functionality is directly provided by raylib [rlgl](../src/rlgl.h) module.
| example | image | difficulty
level | version
created | last version
updated | original
developer |
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
From 22cc2554b121453a9414d5390ab695ff2d6a97d2 Mon Sep 17 00:00:00 2001
From: Jopestpe <47086979+Jopestpe@users.noreply.github.com>
Date: Mon, 23 Mar 2026 07:28:28 -0300
Subject: [PATCH 02/12] Fix Memory out of bounds in [shapes] example - ball
physics (#5683)
Update screenshot to shapes_bouncing_ball.png
---
examples/shapes/shapes_ball_physics.c | 6 ++++--
examples/shapes/shapes_bouncing_ball.png | Bin 15523 -> 9564 bytes
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/examples/shapes/shapes_ball_physics.c b/examples/shapes/shapes_ball_physics.c
index f01a7c8e1..9aba0cf57 100644
--- a/examples/shapes/shapes_ball_physics.c
+++ b/examples/shapes/shapes_ball_physics.c
@@ -45,7 +45,8 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - ball physics");
- Ball balls[MAX_BALLS] = {{
+ Ball *balls = (Ball*)malloc(sizeof(Ball)*MAX_BALLS);
+ balls[0] = (Ball){
.pos = { GetScreenWidth()/2.0f, GetScreenHeight()/2.0f },
.vel = { 200, 200 },
.ppos = { 0 },
@@ -54,7 +55,7 @@ int main(void)
.elasticity = 0.9f,
.color = BLUE,
.grabbed = false
- }};
+ };
int ballCount = 1;
Ball *grabbedBall = NULL; // A pointer to the current ball that is grabbed
@@ -214,6 +215,7 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
+ free(balls);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
diff --git a/examples/shapes/shapes_bouncing_ball.png b/examples/shapes/shapes_bouncing_ball.png
index 9d98e3a889d13b73e276354be935e906f5f63143..a9555b5c7f0df8cb569c7c5ad612b883d4aee3ca 100644
GIT binary patch
literal 9564
zcmeHNdsvd$)(4^!S}A7P%?V1)Q<^rJQ|9eWoy^g+>|#QSnUhmimPTF>gvpt7nzWfY
zsWmAxq1mWtY07v(Z1ha}SyEo0QbD_slHvs%PKrR8o}Vlwfg->6{0ByG&za)rdmEKOOCHP
zC07X=D9ku&>zi$r)uo*mn5MJ4-LmaP=Z(r0{<8|=Z68rlF%*wSHLX&g#z6(kdWEl4
zDT<4BRSLviJn09^fkN+U=%&~jhE5qqHXX5ubs$wYf(M>OZa>n(VP7Fgfe*u$zLPKQlm{%sxJ1nmgNhtw4
zcc{<0&O*;{Fx-lCda+NT13N4biHvBwchKzPNf>zJzAi~IL}WG15xTFrqb(Ape+PlLul~)9#^{p-kg4gD1bvdAP1ygt
zBq5$yO@R~fUL=Z19e=uZzq>}>F3T-fI*^0|!IM&jrSNHaB}I6mqIFM^W7Ii&5PQ=9
z-iv;jy0`qOt}d9j1Pd8$+uE{rHpxHjg(ThE_PnF`DuU6D`JNV1ASpUPafvk^eoP)O
zKKyN@NUaLyt3o`%Tg?y@9_#&rGjxT=S`#d^c6rK|x+3!ys44elm#s3G9r9a)r~7Tf
zwCL)Z-P<9=ZyUdKT{JtC?NuLr?^*;lb2}Z{#mE&OcU)h7-@#k>C{}ZgEK;8gV)46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fb2f4d404ee87be7998adbfa7842 Mon Sep 17 00:00:00 2001
From: Levent Kaya <42411502+lvntky@users.noreply.github.com>
Date: Mon, 23 Mar 2026 13:30:28 +0300
Subject: [PATCH 03/12] [rcore] refactor possible data loss on FileMove()
(#5682)
---
src/rcore.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/rcore.c b/src/rcore.c
index 5cdc8aca1..c83a1c4ae 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -2274,14 +2274,16 @@ int FileCopy(const char *srcPath, const char *dstPath)
// NOTE: If dst directories do not exists they are created
int FileMove(const char *srcPath, const char *dstPath)
{
- int result = 0;
+ int result = -1;
if (FileExists(srcPath))
{
- FileCopy(srcPath, dstPath);
- FileRemove(srcPath);
+ if (FileCopy(srcPath, dstPath) == 0)
+ result = FileRemove(srcPath);
+ else
+ TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to copy file to [%s]", srcPath, dstPath);
}
- else result = -1;
+ else TRACELOG(LOG_WARNING, "FILEIO: [%s] Source file does not exist", srcPath);
return result;
}
From 1e74aba7c37095a337d4ba3881459ae3609db530 Mon Sep 17 00:00:00 2001
From: Krzysztof Szenk
Date: Mon, 23 Mar 2026 11:31:06 +0100
Subject: [PATCH 04/12] WebRGFW: remapping mouse/touch position to canvas pixel
coordinates (#5679)
* RGFW also requires RGBA8 images as window icons, as raylib already reports in raylib.h
* LibraryConfigurations.cmake: exchanged MATCHES -> STREQUAL in platform choosing if-statements
* WebRGFW: remapping mouse/touch position to canvas pixel coordinates
* fix 'typo'
* has to be done like that because of += in case of captured mouse
---
src/platforms/rcore_desktop_rgfw.c | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c
index 87ad7d7c4..7817c7874 100755
--- a/src/platforms/rcore_desktop_rgfw.c
+++ b/src/platforms/rcore_desktop_rgfw.c
@@ -1447,15 +1447,37 @@ void PollInputEvents(void)
} break;
case RGFW_mousePosChanged:
{
+ float event_x = 0.0f, event_y = 0.0f;
if (RGFW_window_isCaptured(platform.window))
{
- CORE.Input.Mouse.currentPosition.x += (float)rgfw_event.mouse.vecX;
- CORE.Input.Mouse.currentPosition.y += (float)rgfw_event.mouse.vecY;
+ event_x = (float)rgfw_event.mouse.vecX;
+ event_y = (float)rgfw_event.mouse.vecY;
}
else
{
- CORE.Input.Mouse.currentPosition.x = (float)rgfw_event.mouse.x;
- CORE.Input.Mouse.currentPosition.y = (float)rgfw_event.mouse.y;
+ event_x = (float)rgfw_event.mouse.x;
+ event_y = (float)rgfw_event.mouse.y;
+ }
+
+#if defined(__EMSCRIPTEN__)
+ {
+ double canvasWidth = 0.0;
+ double canvasHeight = 0.0;
+ emscripten_get_element_css_size("#canvas", &canvasWidth, &canvasHeight);
+ event_x *= ((float)GetScreenWidth() / (float)canvasWidth);
+ event_y *= ((float)GetScreenHeight() / (float)canvasHeight);
+ }
+#endif
+
+ if (RGFW_window_isCaptured(platform.window))
+ {
+ CORE.Input.Mouse.currentPosition.x += event_x;
+ CORE.Input.Mouse.currentPosition.y += event_y;
+ }
+ else
+ {
+ CORE.Input.Mouse.currentPosition.x = event_x;
+ CORE.Input.Mouse.currentPosition.y = event_y;
}
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
From 644e4adbe2026aa38bbf85e760d351806385d883 Mon Sep 17 00:00:00 2001
From: Ray
Date: Mon, 23 Mar 2026 11:51:37 +0100
Subject: [PATCH 05/12] Update rcore.c
---
src/rcore.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/rcore.c b/src/rcore.c
index c83a1c4ae..894e00832 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -2278,10 +2278,8 @@ int FileMove(const char *srcPath, const char *dstPath)
if (FileExists(srcPath))
{
- if (FileCopy(srcPath, dstPath) == 0)
- result = FileRemove(srcPath);
- else
- TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to copy file to [%s]", srcPath, dstPath);
+ if (FileCopy(srcPath, dstPath) == 0) result = FileRemove(srcPath);
+ else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to copy file to [%s]", srcPath, dstPath);
}
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Source file does not exist", srcPath);
From c1dbfc87f315e5525cb853afb87b301e9bf34743 Mon Sep 17 00:00:00 2001
From: Ray
Date: Mon, 23 Mar 2026 11:52:01 +0100
Subject: [PATCH 06/12] REVIEWED: PR #5679
---
src/platforms/rcore_desktop_rgfw.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c
index 7817c7874..fb1fc6cf6 100755
--- a/src/platforms/rcore_desktop_rgfw.c
+++ b/src/platforms/rcore_desktop_rgfw.c
@@ -1447,28 +1447,26 @@ void PollInputEvents(void)
} break;
case RGFW_mousePosChanged:
{
- float event_x = 0.0f, event_y = 0.0f;
+ float mouseX = 0.0f;
+ float mouseY = 0.0f;
if (RGFW_window_isCaptured(platform.window))
{
- event_x = (float)rgfw_event.mouse.vecX;
- event_y = (float)rgfw_event.mouse.vecY;
+ mouseX = (float)rgfw_event.mouse.vecX;
+ mouseY = (float)rgfw_event.mouse.vecY;
}
else
{
- event_x = (float)rgfw_event.mouse.x;
- event_y = (float)rgfw_event.mouse.y;
+ mouseX = (float)rgfw_event.mouse.x;
+ mouseY = (float)rgfw_event.mouse.y;
}
#if defined(__EMSCRIPTEN__)
- {
- double canvasWidth = 0.0;
- double canvasHeight = 0.0;
- emscripten_get_element_css_size("#canvas", &canvasWidth, &canvasHeight);
- event_x *= ((float)GetScreenWidth() / (float)canvasWidth);
- event_y *= ((float)GetScreenHeight() / (float)canvasHeight);
- }
+ double canvasWidth = 0.0;
+ double canvasHeight = 0.0;
+ emscripten_get_element_css_size("#canvas", &canvasWidth, &canvasHeight);
+ mouseX *= ((float)GetScreenWidth()/(float)canvasWidth);
+ mouseY *= ((float)GetScreenHeight()/(float)canvasHeight);
#endif
-
if (RGFW_window_isCaptured(platform.window))
{
CORE.Input.Mouse.currentPosition.x += event_x;
From 7e8aca00b69ce416e29dfd0de8b8204811473f00 Mon Sep 17 00:00:00 2001
From: Ray
Date: Mon, 23 Mar 2026 11:53:31 +0100
Subject: [PATCH 07/12] Update textures_raw_data.c
---
examples/textures/textures_raw_data.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/examples/textures/textures_raw_data.c b/examples/textures/textures_raw_data.c
index c38983b53..49efc890e 100644
--- a/examples/textures/textures_raw_data.c
+++ b/examples/textures/textures_raw_data.c
@@ -17,8 +17,6 @@
#include "raylib.h"
-#include // Required for: malloc() and free()
-
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
@@ -39,26 +37,31 @@ int main(void)
UnloadImage(fudesumiRaw); // Unload CPU (RAM) image data
// Generate a checked texture by code
- int width = 960;
- int height = 480;
+ int imWidth = 960;
+ int imHeight = 480;
// Dynamic memory allocation to store pixels data (Color type)
- Color *pixels = (Color *)malloc(width*height*sizeof(Color));
+ // WARNING: Using raylib provided MemAlloc() that uses default raylib
+ // internal memory allocator, so this data can be freed using UnloadImage()
+ // that also uses raylib internal memory de-allocator
+ Color *pixels = (Color *)MemAlloc(imWidth*imHeight*sizeof(Color));
- for (int y = 0; y < height; y++)
+ for (int y = 0; y < imHeight; y++)
{
- for (int x = 0; x < width; x++)
+ for (int x = 0; x < imWidth; x++)
{
- if (((x/32+y/32)/1)%2 == 0) pixels[y*width + x] = ORANGE;
- else pixels[y*width + x] = GOLD;
+ if (((x/32+y/32)/1)%2 == 0) pixels[y*imWidth + x] = ORANGE;
+ else pixels[y*imWidth + x] = GOLD;
}
}
// Load pixels data into an image structure and create texture
+ // NOTE: We can assign pixels directly to data because Color is R8G8B8A8
+ // data structure defining that pixelformat, format must be set properly
Image checkedIm = {
- .data = pixels, // We can assign pixels directly to data
- .width = width,
- .height = height,
+ .data = pixels,
+ .width = imWidth,
+ .height = imHeight,
.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
.mipmaps = 1
};
From ca1baca7c2847e6f19fa774f02cf3fec6a0b4211 Mon Sep 17 00:00:00 2001
From: Ray
Date: Mon, 23 Mar 2026 11:53:57 +0100
Subject: [PATCH 08/12] REVIEWED: examples memory allocators, using raylib
provided macros
---
examples/core/core_random_sequence.c | 2 +-
examples/shapes/shapes_ball_physics.c | 94 +++++++++++++------------
examples/text/text_codepoints_loading.c | 4 +-
examples/textures/textures_bunnymark.c | 4 +-
examples/textures/textures_fog_of_war.c | 8 +--
5 files changed, 59 insertions(+), 53 deletions(-)
diff --git a/examples/core/core_random_sequence.c b/examples/core/core_random_sequence.c
index 19d44461e..32ec3001b 100644
--- a/examples/core/core_random_sequence.c
+++ b/examples/core/core_random_sequence.c
@@ -111,7 +111,7 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
- free(rectangles);
+ RL_FREE(rectangles);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
diff --git a/examples/shapes/shapes_ball_physics.c b/examples/shapes/shapes_ball_physics.c
index 9aba0cf57..9c18ab66e 100644
--- a/examples/shapes/shapes_ball_physics.c
+++ b/examples/shapes/shapes_ball_physics.c
@@ -17,15 +17,19 @@
#include "raylib.h"
-#include
-#include
+#include // Required for: malloc(), free()
+#include // Required for: hypot()
-#define MAX_BALLS 5000 // Maximum quantity of balls
+#define MAX_BALLS 5000 // Maximum quantity of balls
+//----------------------------------------------------------------------------------
+// Types and Structures Definition
+//----------------------------------------------------------------------------------
+// Ball data type
typedef struct Ball {
- Vector2 pos; // Position
- Vector2 vel; // Velocity
- Vector2 ppos; // Previous position
+ Vector2 position;
+ Vector2 speed;
+ Vector2 prevPosition;
float radius;
float friction;
float elasticity;
@@ -45,11 +49,13 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - ball physics");
- Ball *balls = (Ball*)malloc(sizeof(Ball)*MAX_BALLS);
+ Ball *balls = (Ball*)RL_MALLOC(sizeof(Ball)*MAX_BALLS);
+
+ // Init first ball in the array
balls[0] = (Ball){
- .pos = { GetScreenWidth()/2.0f, GetScreenHeight()/2.0f },
- .vel = { 200, 200 },
- .ppos = { 0 },
+ .position = { GetScreenWidth()/2.0f, GetScreenHeight()/2.0f },
+ .speed = { 200, 200 },
+ .prevPosition = { 0 },
.radius = 40,
.friction = 0.99f,
.elasticity = 0.9f,
@@ -58,12 +64,12 @@ int main(void)
};
int ballCount = 1;
- Ball *grabbedBall = NULL; // A pointer to the current ball that is grabbed
- Vector2 pressOffset = { 0 }; // Mouse press offset relative to the ball that grabbedd
+ Ball *grabbedBall = NULL; // A pointer to the current ball that is grabbed
+ Vector2 pressOffset = { 0 }; // Mouse press offset relative to the ball that grabbedd
- float gravity = 100; // World gravity
+ float gravity = 100; // World gravity
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//---------------------------------------------------------------------------------------
// Main game loop
@@ -80,8 +86,8 @@ int main(void)
for (int i = ballCount - 1; i >= 0; i--)
{
Ball *ball = &balls[i];
- pressOffset.x = mousePos.x - ball->pos.x;
- pressOffset.y = mousePos.y - ball->pos.y;
+ pressOffset.x = mousePos.x - ball->position.x;
+ pressOffset.y = mousePos.y - ball->position.y;
// If the distance between the ball position and the mouse press position
// is less than or equal to the ball radius, the event occurred inside the ball
@@ -110,9 +116,9 @@ int main(void)
if (ballCount < MAX_BALLS)
{
balls[ballCount++] = (Ball){
- .pos = mousePos,
- .vel = { (float)GetRandomValue(-300, 300), (float)GetRandomValue(-300, 300) },
- .ppos = { 0 },
+ .position = mousePos,
+ .speed = { (float)GetRandomValue(-300, 300), (float)GetRandomValue(-300, 300) },
+ .prevPosition = { 0 },
.radius = 20.0f + (float)GetRandomValue(0, 30),
.friction = 0.99f,
.elasticity = 0.9f,
@@ -127,7 +133,7 @@ int main(void)
{
for (int i = 0; i < ballCount; i++)
{
- if (!balls[i].grabbed) balls[i].vel = (Vector2){ (float)GetRandomValue(-2000, 2000), (float)GetRandomValue(-2000, 2000) };
+ if (!balls[i].grabbed) balls[i].speed = (Vector2){ (float)GetRandomValue(-2000, 2000), (float)GetRandomValue(-2000, 2000) };
}
}
@@ -143,49 +149,49 @@ int main(void)
if (!ball->grabbed)
{
// Ball repositioning using the velocity
- ball->pos.x += ball->vel.x * delta;
- ball->pos.y += ball->vel.y * delta;
+ ball->position.x += ball->speed.x * delta;
+ ball->position.y += ball->speed.y * delta;
// Does the ball hit the screen right boundary?
- if ((ball->pos.x + ball->radius) >= screenWidth)
+ if ((ball->position.x + ball->radius) >= screenWidth)
{
- ball->pos.x = screenWidth - ball->radius; // Ball repositioning
- ball->vel.x = -ball->vel.x*ball->elasticity; // Elasticity makes the ball lose 10% of its velocity on hit
+ ball->position.x = screenWidth - ball->radius; // Ball repositioning
+ ball->speed.x = -ball->speed.x*ball->elasticity; // Elasticity makes the ball lose 10% of its velocity on hit
}
// Does the ball hit the screen left boundary?
- else if ((ball->pos.x - ball->radius) <= 0)
+ else if ((ball->position.x - ball->radius) <= 0)
{
- ball->pos.x = ball->radius;
- ball->vel.x = -ball->vel.x*ball->elasticity;
+ ball->position.x = ball->radius;
+ ball->speed.x = -ball->speed.x*ball->elasticity;
}
// The same for y axis
- if ((ball->pos.y + ball->radius) >= screenHeight)
+ if ((ball->position.y + ball->radius) >= screenHeight)
{
- ball->pos.y = screenHeight - ball->radius;
- ball->vel.y = -ball->vel.y*ball->elasticity;
+ ball->position.y = screenHeight - ball->radius;
+ ball->speed.y = -ball->speed.y*ball->elasticity;
}
- else if ((ball->pos.y - ball->radius) <= 0)
+ else if ((ball->position.y - ball->radius) <= 0)
{
- ball->pos.y = ball->radius;
- ball->vel.y = -ball->vel.y*ball->elasticity;
+ ball->position.y = ball->radius;
+ ball->speed.y = -ball->speed.y*ball->elasticity;
}
// Friction makes the ball lose 1% of its velocity each frame
- ball->vel.x = ball->vel.x*ball->friction;
+ ball->speed.x = ball->speed.x*ball->friction;
// Gravity affects only the y axis
- ball->vel.y = ball->vel.y*ball->friction + gravity;
+ ball->speed.y = ball->speed.y*ball->friction + gravity;
}
else
{
// Ball repositioning using the mouse position
- ball->pos.x = mousePos.x - pressOffset.x;
- ball->pos.y = mousePos.y - pressOffset.y;
+ ball->position.x = mousePos.x - pressOffset.x;
+ ball->position.y = mousePos.y - pressOffset.y;
// While the ball is grabbed, recalculates its velocity
- ball->vel.x = (ball->pos.x - ball->ppos.x)/delta;
- ball->vel.y = (ball->pos.y - ball->ppos.y)/delta;
- ball->ppos = ball->pos;
+ ball->speed.x = (ball->position.x - ball->prevPosition.x)/delta;
+ ball->speed.y = (ball->position.y - ball->prevPosition.y)/delta;
+ ball->prevPosition = ball->position;
}
}
//----------------------------------------------------------------------------------
@@ -198,8 +204,8 @@ int main(void)
for (int i = 0; i < ballCount; i++)
{
- DrawCircleV(balls[i].pos, balls[i].radius, balls[i].color);
- DrawCircleLinesV(balls[i].pos, balls[i].radius, BLACK);
+ DrawCircleV(balls[i].position, balls[i].radius, balls[i].color);
+ DrawCircleLinesV(balls[i].position, balls[i].radius, BLACK);
}
DrawText("grab a ball by pressing with the mouse and throw it by releasing", 10, 10, 10, DARKGRAY);
@@ -215,7 +221,7 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
- free(balls);
+ RL_FREE(balls);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
diff --git a/examples/text/text_codepoints_loading.c b/examples/text/text_codepoints_loading.c
index 1cd82d60e..1da8cf93f 100644
--- a/examples/text/text_codepoints_loading.c
+++ b/examples/text/text_codepoints_loading.c
@@ -61,7 +61,7 @@ int main(void)
SetTextLineSpacing(20); // Set line spacing for multiline text (when line breaks are included '\n')
// Free codepoints, atlas has already been generated
- free(codepointsNoDups);
+ RL_FREE(codepointsNoDups);
bool showFontAtlas = false;
@@ -139,7 +139,7 @@ int main(void)
static int *CodepointRemoveDuplicates(int *codepoints, int codepointCount, int *codepointsResultCount)
{
int codepointsNoDupsCount = codepointCount;
- int *codepointsNoDups = (int *)calloc(codepointCount, sizeof(int));
+ int *codepointsNoDups = (int *)RL_CALLOC(codepointCount, sizeof(int));
memcpy(codepointsNoDups, codepoints, codepointCount*sizeof(int));
// Remove duplicates
diff --git a/examples/textures/textures_bunnymark.c b/examples/textures/textures_bunnymark.c
index a04741227..64e55db43 100644
--- a/examples/textures/textures_bunnymark.c
+++ b/examples/textures/textures_bunnymark.c
@@ -47,7 +47,7 @@ int main(void)
// Load bunny texture
Texture2D texBunny = LoadTexture("resources/raybunny.png");
- Bunny *bunnies = (Bunny *)malloc(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array
+ Bunny *bunnies = (Bunny *)RL_MALLOC(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array
int bunniesCount = 0; // Bunnies counter
@@ -126,7 +126,7 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
- free(bunnies); // Unload bunnies data array
+ RL_FREE(bunnies); // Unload bunnies data array
UnloadTexture(texBunny); // Unload bunny texture
diff --git a/examples/textures/textures_fog_of_war.c b/examples/textures/textures_fog_of_war.c
index 1354d7124..e4ed2b60a 100644
--- a/examples/textures/textures_fog_of_war.c
+++ b/examples/textures/textures_fog_of_war.c
@@ -51,8 +51,8 @@ int main(void)
// NOTE: We can have up to 256 values for tile ids and for tile fog state,
// probably we don't need that many values for fog state, it can be optimized
// to use only 2 bits per fog state (reducing size by 4) but logic will be a bit more complex
- map.tileIds = (unsigned char *)calloc(map.tilesX*map.tilesY, sizeof(unsigned char));
- map.tileFog = (unsigned char *)calloc(map.tilesX*map.tilesY, sizeof(unsigned char));
+ map.tileIds = (unsigned char *)RL_CALLOC(map.tilesX*map.tilesY, sizeof(unsigned char));
+ map.tileFog = (unsigned char *)RL_CALLOC(map.tilesX*map.tilesY, sizeof(unsigned char));
// Load map tiles (generating 2 random tile ids for testing)
// NOTE: Map tile ids should be probably loaded from an external map file
@@ -149,8 +149,8 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
- free(map.tileIds); // Free allocated map tile ids
- free(map.tileFog); // Free allocated map tile fog state
+ RL_FREE(map.tileIds); // Free allocated map tile ids
+ RL_FREE(map.tileFog); // Free allocated map tile fog state
UnloadRenderTexture(fogOfWar); // Unload render texture
From e71633a0be295c91ff8a039e67deee6fef590237 Mon Sep 17 00:00:00 2001
From: Maicon Santana
Date: Mon, 23 Mar 2026 13:05:23 +0000
Subject: [PATCH 09/12] Set textureWrapRepeat to avoid issue on web version
(#5684)
---
examples/models/models_yaw_pitch_roll.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/examples/models/models_yaw_pitch_roll.c b/examples/models/models_yaw_pitch_roll.c
index c19aafdcd..af0f06daf 100644
--- a/examples/models/models_yaw_pitch_roll.c
+++ b/examples/models/models_yaw_pitch_roll.c
@@ -41,6 +41,9 @@ int main(void)
Model model = LoadModel("resources/models/obj/plane.obj"); // Load model
Texture2D texture = LoadTexture("resources/models/obj/plane_diffuse.png"); // Load model texture
+
+ SetTextureWrap(texture, TEXTURE_WRAP_REPEAT); // Force Repeat to avoid issue on Web version
+
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
float pitch = 0.0f;
From 6cf71f565ca987ce465adfd7c01d3fa94250f3b3 Mon Sep 17 00:00:00 2001
From: Charlie Tonneslan
Date: Mon, 23 Mar 2026 12:17:50 -0400
Subject: [PATCH 10/12] Fix typo: dependant -> dependent in rlgl.h and rexm.c
(#5685)
5 instances in src/rlgl.h comments and 1 in tools/rexm/rexm.c.
Skipped vendored raygui.h files in examples/.
---
src/rlgl.h | 10 +++++-----
tools/rexm/rexm.c | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/rlgl.h b/src/rlgl.h
index 13c037132..ce10b2f64 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -880,7 +880,7 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad
#elif defined(GRAPHICS_API_OPENGL_ES2)
// NOTE: OpenGL ES 2.0 can be enabled on Desktop platforms,
// in that case, functions are loaded from a custom glad for OpenGL ES 2.0
- // TODO: OpenGL ES 2.0 support shouldn't be platform-dependant, neither require GLAD
+ // TODO: OpenGL ES 2.0 support shouldn't be platform-dependent, neither require GLAD
#if defined(PLATFORM_DESKTOP_GLFW) || defined(PLATFORM_DESKTOP_SDL)
#define GLAD_GLES2_IMPLEMENTATION
#include "external/glad_gles2.h"
@@ -893,7 +893,7 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad
// It seems OpenGL ES 2.0 instancing entry points are not defined on Raspberry Pi
// provided headers (despite being defined in official Khronos GLES2 headers)
- // TODO: Avoid raylib platform-dependant code on rlgl, it should be a completely portable library
+ // TODO: Avoid raylib platform-dependent code on rlgl, it should be a completely portable library
#if defined(PLATFORM_DRM)
typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
@@ -1392,7 +1392,7 @@ void rlFrustum(double left, double right, double bottom, double top, double znea
void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar)
{
// NOTE: If left-right and top-botton values are equal it could create a division by zero,
- // response to it is platform/compiler dependant
+ // response to it is platform/compiler dependent
Matrix matOrtho = { 0 };
float rl = (float)(right - left);
@@ -1509,7 +1509,7 @@ void rlBegin(int mode)
// Finish vertex providing
void rlEnd(void)
{
- // NOTE: Depth increment is dependant on rlOrtho(): z-near and z-far values,
+ // NOTE: Depth increment is dependent on rlOrtho(): z-near and z-far values,
// as well as depth buffer bit-depth (16bit or 24bit or 32bit)
// Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits)
RLGL.currentBatch->currentDepth += (1.0f/20000.0f);
@@ -1902,7 +1902,7 @@ void rlBindFramebuffer(unsigned int target, unsigned int framebuffer)
void rlActiveDrawBuffers(int count)
{
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3))
- // NOTE: Maximum number of draw buffers supported is implementation dependant,
+ // NOTE: Maximum number of draw buffers supported is implementation dependent,
// it can be queried with glGet*() but it must be at least 8
//GLint maxDrawBuffers = 0;
//glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
diff --git a/tools/rexm/rexm.c b/tools/rexm/rexm.c
index 49d4dce9a..e4881b633 100644
--- a/tools/rexm/rexm.c
+++ b/tools/rexm/rexm.c
@@ -1669,7 +1669,7 @@ int main(int argc, char *argv[])
FileRemove(TextFormat("%s/%s/%s.original.c", exBasePath, exCategory, exName));
// STEP 3: Run example with required arguments
- // NOTE: Not easy to retrieve process return value from system(), it's platform dependant
+ // NOTE: Not easy to retrieve process return value from system(), it's platform dependent
ChangeDirectory(TextFormat("%s/%s", exBasePath, exCategory));
#if defined(_WIN32)
From 0f1e14a600df058d807ed5e26cddf2529674073d Mon Sep 17 00:00:00 2001
From: Charlie Tonneslan
Date: Mon, 23 Mar 2026 12:58:45 -0400
Subject: [PATCH 11/12] Fix typo: dependant -> dependent in rlgl.h and rexm.c
(#5685)
5 instances in src/rlgl.h comments and 1 in tools/rexm/rexm.c.
Skipped vendored raygui.h files in examples/.
From 52d2158f498dabee0f866a62bee88efd2d9fb77d Mon Sep 17 00:00:00 2001
From: Ray
Date: Mon, 23 Mar 2026 18:28:09 +0100
Subject: [PATCH 12/12] Update ROADMAP.md
---
ROADMAP.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/ROADMAP.md b/ROADMAP.md
index 10754e52b..91d2299c3 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -23,6 +23,7 @@ _Current version of raylib is complete and functional but there is always room f
- [ ] `rlsw`: Software renderer optimizations: mipmaps, platform-specific SIMD
- [ ] `rtextures`: Consider moving N-patch system to separate example
- [ ] `rtextures`: Review blending modes system, provide more options or better samples
+ - [ ] `rtext`: Investigate the recently opened [`Slug`](https://sluglibrary.com/) font rendering algorithm
- [ ] `raudio`: Support microphone input, basic API to read microphone
- [ ] `rltexgpu`: Improve compressed textures support, loading and saving, improve KTX 2.0
- [ ] `rlobj`: Create OBJ loader, supporting material file separately (low priority)