From 3f92c396a009ecb51a5efab378802851f805cd76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20=E2=9D=A4=EF=B8=8F?= Date: Wed, 19 Nov 2025 02:56:32 -0500 Subject: [PATCH 1/2] Fixed typo (#5364) --- src/rlgl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rlgl.h b/src/rlgl.h index 99e9037d5..6cdf8a317 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -1252,7 +1252,7 @@ void rlPushMatrix(void) RLGL.State.stackCounter++; } -// Pop lattest inserted matrix from RLGL.State.stack +// Pop latest inserted matrix from RLGL.State.stack void rlPopMatrix(void) { if (RLGL.State.stackCounter > 0) From e2233acdb0d51d5f11f63d1b8550a766a962aac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adi=20=C4=8Cau=C5=A1evi=C4=87?= <31798801+ChocolateChipKookie@users.noreply.github.com> Date: Wed, 19 Nov 2025 08:58:43 +0100 Subject: [PATCH 2/2] feat: Optimize ImageClearBackground and ImageDrawRectangleRec with doubling strategy (#5363) --- src/rtextures.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/rtextures.c b/src/rtextures.c index ddaee2939..00554e418 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -3341,11 +3341,14 @@ void ImageClearBackground(Image *dst, Color color) unsigned char *pSrcPixel = (unsigned char *)dst->data; int bytesPerPixel = GetPixelDataSize(1, 1, dst->format); + int totalPixels = dst->width * dst->height; - // Repeat the first pixel data throughout the image - for (int i = 1; i < dst->width*dst->height; i++) + // Repeat the first pixel data throughout the image, + // doubling the pixels copied on each iteration + for (int i = 1; i < totalPixels; i *= 2) { - memcpy(pSrcPixel + i*bytesPerPixel, pSrcPixel, bytesPerPixel); + int pixelsToCopy = MIN(i, totalPixels - i); + memcpy(pSrcPixel + i * bytesPerPixel, pSrcPixel, pixelsToCopy * bytesPerPixel); } } @@ -3724,9 +3727,10 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color) unsigned char *pSrcPixel = (unsigned char *)dst->data + bytesOffset; // Repeat the first pixel data throughout the row - for (int x = 1; x < (int)rec.width; x++) + for (int x = 1; x < (int)rec.width; x *= 2) { - memcpy(pSrcPixel + x*bytesPerPixel, pSrcPixel, bytesPerPixel); + int pixelsToCopy = MIN(x, (int)rec.width - x); + memcpy(pSrcPixel + x*bytesPerPixel, pSrcPixel, pixelsToCopy * bytesPerPixel); } // Repeat the first row data for all other rows