From d4f09984acb427f5ab67ee49235546b01ad09199 Mon Sep 17 00:00:00 2001 From: Amy Wilder Date: Mon, 7 Jul 2025 21:51:27 -0400 Subject: [PATCH 1/2] Add safety notes to 'Update_' functions --- src/raudio.c | 2 ++ src/raylib.h | 6 +++--- src/rtextures.c | 7 +++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/raudio.c b/src/raudio.c index 2b6628a24..8929c9ef9 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -1033,6 +1033,8 @@ void UnloadSoundAlias(Sound alias) } // Update sound buffer with new data +// NOTE 1: data format must match sound.stream.sampleSize +// NOTE 2: frameCount must not exceed sound.frameCount void UpdateSound(Sound sound, const void *data, int frameCount) { if (sound.stream.buffer != NULL) diff --git a/src/raylib.h b/src/raylib.h index 7919db775..38b703e98 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1422,8 +1422,8 @@ RLAPI bool IsTextureValid(Texture2D texture); RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM) RLAPI bool IsRenderTextureValid(RenderTexture2D target); // Check if a render texture is valid (loaded in GPU) RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM) -RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data -RLAPI void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels); // Update GPU texture rectangle with new data +RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data (pixels should be able to fill texture) +RLAPI void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels); // Update GPU texture rectangle with new data (pixels and rec should fit in texture) // Texture configuration functions RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture @@ -1644,7 +1644,7 @@ RLAPI Sound LoadSound(const char *fileName); // Load so RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data RLAPI Sound LoadSoundAlias(Sound source); // Create a new sound that shares the same sample data as the source sound, does not own the sound data RLAPI bool IsSoundValid(Sound sound); // Checks if a sound is valid (data loaded and buffers initialized) -RLAPI void UpdateSound(Sound sound, const void *data, int sampleCount); // Update sound buffer with new data +RLAPI void UpdateSound(Sound sound, const void *data, int sampleCount); // Update sound buffer with new data (data and frame count should fit in sound) RLAPI void UnloadWave(Wave wave); // Unload wave data RLAPI void UnloadSound(Sound sound); // Unload sound RLAPI void UnloadSoundAlias(Sound alias); // Unload a sound alias (does not deallocate sample data) diff --git a/src/rtextures.c b/src/rtextures.c index ee116b0e5..337d01b1d 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -4337,14 +4337,17 @@ void UnloadRenderTexture(RenderTexture2D target) } // Update GPU texture with new data -// NOTE: pixels data must match texture.format +// NOTE 1: pixels data must match texture.format +// NOTE 2: pixels data must contain at least as many pixels as texture void UpdateTexture(Texture2D texture, const void *pixels) { rlUpdateTexture(texture.id, 0, 0, texture.width, texture.height, texture.format, pixels); } // Update GPU texture rectangle with new data -// NOTE: pixels data must match texture.format +// NOTE 1: pixels data must match texture.format +// NOTE 2: pixels data must contain as many pixels as rec contains +// NOTE 3: rec must fit completely within texture's width and height void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels) { rlUpdateTexture(texture.id, (int)rec.x, (int)rec.y, (int)rec.width, (int)rec.height, texture.format, pixels); From 9f6d37ecb4774a5f1f00c53fd85dfc15db69467b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 8 Jul 2025 01:51:52 +0000 Subject: [PATCH 2/2] Update raylib_api.* by CI --- parser/output/raylib_api.json | 6 +++--- parser/output/raylib_api.lua | 6 +++--- parser/output/raylib_api.txt | 6 +++--- parser/output/raylib_api.xml | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index f5872ec8a..2fddc75e7 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -8483,7 +8483,7 @@ }, { "name": "UpdateTexture", - "description": "Update GPU texture with new data", + "description": "Update GPU texture with new data (pixels should be able to fill texture)", "returnType": "void", "params": [ { @@ -8498,7 +8498,7 @@ }, { "name": "UpdateTextureRec", - "description": "Update GPU texture rectangle with new data", + "description": "Update GPU texture rectangle with new data (pixels and rec should fit in texture)", "returnType": "void", "params": [ { @@ -11465,7 +11465,7 @@ }, { "name": "UpdateSound", - "description": "Update sound buffer with new data", + "description": "Update sound buffer with new data (data and frame count should fit in sound)", "returnType": "void", "params": [ { diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index 81dd7f932..49e2e1f47 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -6242,7 +6242,7 @@ return { }, { name = "UpdateTexture", - description = "Update GPU texture with new data", + description = "Update GPU texture with new data (pixels should be able to fill texture)", returnType = "void", params = { {type = "Texture2D", name = "texture"}, @@ -6251,7 +6251,7 @@ return { }, { name = "UpdateTextureRec", - description = "Update GPU texture rectangle with new data", + description = "Update GPU texture rectangle with new data (pixels and rec should fit in texture)", returnType = "void", params = { {type = "Texture2D", name = "texture"}, @@ -7850,7 +7850,7 @@ return { }, { name = "UpdateSound", - description = "Update sound buffer with new data", + description = "Update sound buffer with new data (data and frame count should fit in sound)", returnType = "void", params = { {type = "Sound", name = "sound"}, diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index c74a79a5f..a92a96de3 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -3255,13 +3255,13 @@ Function 362: UnloadRenderTexture() (1 input parameters) Function 363: UpdateTexture() (2 input parameters) Name: UpdateTexture Return type: void - Description: Update GPU texture with new data + Description: Update GPU texture with new data (pixels should be able to fill texture) Param[1]: texture (type: Texture2D) Param[2]: pixels (type: const void *) Function 364: UpdateTextureRec() (3 input parameters) Name: UpdateTextureRec Return type: void - Description: Update GPU texture rectangle with new data + Description: Update GPU texture rectangle with new data (pixels and rec should fit in texture) Param[1]: texture (type: Texture2D) Param[2]: rec (type: Rectangle) Param[3]: pixels (type: const void *) @@ -4383,7 +4383,7 @@ Function 528: IsSoundValid() (1 input parameters) Function 529: UpdateSound() (3 input parameters) Name: UpdateSound Return type: void - Description: Update sound buffer with new data + Description: Update sound buffer with new data (data and frame count should fit in sound) Param[1]: sound (type: Sound) Param[2]: data (type: const void *) Param[3]: sampleCount (type: int) diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index b7af0c41a..e9c83ad9c 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -2138,11 +2138,11 @@ - + - + @@ -2928,7 +2928,7 @@ - +