From c579eef4b777224af06e67d3e9fc7f101ac08f00 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 3 Sep 2025 10:40:31 +0200 Subject: [PATCH] REVIEWED: Examples section comments, for better organization and consistency --- examples/core/core_automation_events.c | 4 +- examples/core/core_random_sequence.c | 4 +- examples/core/core_storage_values.c | 7 +- examples/models/models_mesh_generation.c | 6 + examples/models/models_point_rendering.c | 10 +- examples/models/models_skybox.c | 6 + examples/others/raylib_opengl_interop.c | 3 + examples/others/rlgl_compute_shader.c | 3 + examples/shaders/shaders_deferred_render.c | 3 + examples/shaders/shaders_palette_switch.c | 3 + examples/shaders/shaders_postprocessing.c | 3 + examples/shapes/shapes_splines_drawing.c | 3 + examples/shapes/shapes_top_down_lights.c | 344 ++++++++++-------- examples/text/text_codepoints_loading.c | 6 + examples/text/text_unicode.c | 5 +- examples/text/text_unicode_ranges.c | 2 +- examples/textures/textures_bunnymark.c | 3 + examples/textures/textures_fog_of_war.c | 3 + .../textures/textures_particles_blending.c | 5 +- 19 files changed, 253 insertions(+), 170 deletions(-) diff --git a/examples/core/core_automation_events.c b/examples/core/core_automation_events.c index 6ae0a4336..b98b37c69 100644 --- a/examples/core/core_automation_events.c +++ b/examples/core/core_automation_events.c @@ -24,6 +24,9 @@ #define MAX_ENVIRONMENT_ELEMENTS 5 +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- typedef struct Player { Vector2 position; float speed; @@ -36,7 +39,6 @@ typedef struct EnvElement { Color color; } EnvElement; - //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ diff --git a/examples/core/core_random_sequence.c b/examples/core/core_random_sequence.c index 67990df32..e3b54976a 100644 --- a/examples/core/core_random_sequence.c +++ b/examples/core/core_random_sequence.c @@ -31,7 +31,7 @@ typedef struct ColorRect { //------------------------------------------------------------------------------------ // Module Functions Declaration //------------------------------------------------------------------------------------ -static Color GenerateRandomColor(); +static Color GenerateRandomColor(void); static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight); static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount); @@ -122,7 +122,7 @@ int main(void) //------------------------------------------------------------------------------------ // Module Functions Definition //------------------------------------------------------------------------------------ -static Color GenerateRandomColor() +static Color GenerateRandomColor(void) { Color color = { GetRandomValue(0, 255), diff --git a/examples/core/core_storage_values.c b/examples/core/core_storage_values.c index c74c7ce93..b4645bf72 100644 --- a/examples/core/core_storage_values.c +++ b/examples/core/core_storage_values.c @@ -25,7 +25,9 @@ typedef enum { STORAGE_POSITION_HISCORE = 1 } StorageData; -// Persistent storage functions +//------------------------------------------------------------------------------------ +// Module Functions Declaration +//------------------------------------------------------------------------------------ static bool SaveStorageValue(unsigned int position, int value); static int LoadStorageValue(unsigned int position); @@ -101,6 +103,9 @@ int main(void) return 0; } +//------------------------------------------------------------------------------------ +// Module Functions Declaration +//------------------------------------------------------------------------------------ // Save integer value to storage file (to defined position) // NOTE: Storage positions is directly related to file memory layout (4 bytes each integer) bool SaveStorageValue(unsigned int position, int value) diff --git a/examples/models/models_mesh_generation.c b/examples/models/models_mesh_generation.c index 36112e73b..c500e3cbc 100644 --- a/examples/models/models_mesh_generation.c +++ b/examples/models/models_mesh_generation.c @@ -17,6 +17,9 @@ #define NUM_MODELS 9 // Parametric 3d shapes to generate +//------------------------------------------------------------------------------------ +// Module Functions Declaration +//------------------------------------------------------------------------------------ static Mesh GenMeshCustom(void); // Generate a simple triangle mesh from code //------------------------------------------------------------------------------------ @@ -136,6 +139,9 @@ int main(void) return 0; } +//------------------------------------------------------------------------------------ +// Module Functions Definition +//------------------------------------------------------------------------------------ // Generate a simple triangle mesh from code static Mesh GenMeshCustom(void) { diff --git a/examples/models/models_point_rendering.c b/examples/models/models_point_rendering.c index 5408002f5..3a93fc8d9 100644 --- a/examples/models/models_point_rendering.c +++ b/examples/models/models_point_rendering.c @@ -18,11 +18,14 @@ #include "raylib.h" #include // Required for: rand() -#include // Required for: cos(), sin() +#include // Required for: cosf(), sinf() #define MAX_POINTS 10000000 // 10 million #define MIN_POINTS 1000 // 1 thousand +//------------------------------------------------------------------------------------ +// Module Functions Declaration +//------------------------------------------------------------------------------------ // Generate mesh using points static Mesh GenMeshPoints(int numPoints); @@ -148,6 +151,9 @@ int main() return 0; } +//------------------------------------------------------------------------------------ +// Module Functions Definition +//------------------------------------------------------------------------------------ // Generate a spherical point cloud static Mesh GenMeshPoints(int numPoints) { @@ -158,7 +164,7 @@ static Mesh GenMeshPoints(int numPoints) .colors = (unsigned char*)MemAlloc(numPoints*4*sizeof(unsigned char)), }; - // https://en.wikipedia.org/wiki/Spherical_coordinate_system + // REF: https://en.wikipedia.org/wiki/Spherical_coordinate_system for (int i = 0; i < numPoints; i++) { float theta = ((float)PI*rand())/((float)RAND_MAX); diff --git a/examples/models/models_skybox.c b/examples/models/models_skybox.c index 6cd0259f7..ddce6a28f 100644 --- a/examples/models/models_skybox.c +++ b/examples/models/models_skybox.c @@ -24,6 +24,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Module Functions Declaration +//------------------------------------------------------------------------------------ // Generate cubemap (6 faces) from equirectangular (panorama) texture static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int size, int format); @@ -183,6 +186,9 @@ int main(void) return 0; } +//------------------------------------------------------------------------------------ +// Module Functions Definition +//------------------------------------------------------------------------------------ // Generate cubemap texture from HDR texture static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int size, int format) { diff --git a/examples/others/raylib_opengl_interop.c b/examples/others/raylib_opengl_interop.c index 7ca4c28b6..02aedc533 100644 --- a/examples/others/raylib_opengl_interop.c +++ b/examples/others/raylib_opengl_interop.c @@ -54,6 +54,9 @@ #define MAX_PARTICLES 1000 +//------------------------------------------------------------------------------------ +// Module Functions Declaration +//------------------------------------------------------------------------------------ // Particle type typedef struct Particle { float x; diff --git a/examples/others/rlgl_compute_shader.c b/examples/others/rlgl_compute_shader.c index 81b2e7db9..2b17b5eaa 100644 --- a/examples/others/rlgl_compute_shader.c +++ b/examples/others/rlgl_compute_shader.c @@ -30,6 +30,9 @@ // Maximum amount of queued draw commands (squares draw from mouse down events) #define MAX_BUFFERED_TRANSFERTS 48 +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- // Game Of Life Update Command typedef struct GolUpdateCmd { unsigned int x; // x coordinate of the gol command diff --git a/examples/shaders/shaders_deferred_render.c b/examples/shaders/shaders_deferred_render.c index c0bdd9f98..c5801bbeb 100644 --- a/examples/shaders/shaders_deferred_render.c +++ b/examples/shaders/shaders_deferred_render.c @@ -35,6 +35,9 @@ #define MAX_CUBES 30 +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- // GBuffer data typedef struct GBuffer { unsigned int framebuffer; diff --git a/examples/shaders/shaders_palette_switch.c b/examples/shaders/shaders_palette_switch.c index 1384c7332..346bc171c 100644 --- a/examples/shaders/shaders_palette_switch.c +++ b/examples/shaders/shaders_palette_switch.c @@ -34,6 +34,9 @@ #define COLORS_PER_PALETTE 8 #define VALUES_PER_COLOR 3 +//------------------------------------------------------------------------------------ +// Global Variables Definition +//------------------------------------------------------------------------------------ static const int palettes[MAX_PALETTES][COLORS_PER_PALETTE*VALUES_PER_COLOR] = { { // 3-BIT RGB 0, 0, 0, diff --git a/examples/shaders/shaders_postprocessing.c b/examples/shaders/shaders_postprocessing.c index abfa92fe3..117fa3886 100644 --- a/examples/shaders/shaders_postprocessing.c +++ b/examples/shaders/shaders_postprocessing.c @@ -46,6 +46,9 @@ typedef enum { //FX_FXAA } PostproShader; +//------------------------------------------------------------------------------------ +// Global Variables Definition +//------------------------------------------------------------------------------------ static const char *postproShaderText[] = { "GRAYSCALE", "POSTERIZATION", diff --git a/examples/shapes/shapes_splines_drawing.c b/examples/shapes/shapes_splines_drawing.c index 88cfe688b..98d8c481f 100644 --- a/examples/shapes/shapes_splines_drawing.c +++ b/examples/shapes/shapes_splines_drawing.c @@ -22,6 +22,9 @@ #define MAX_SPLINE_POINTS 32 +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- // Cubic Bezier spline control points // NOTE: Every segment has two control points typedef struct { diff --git a/examples/shapes/shapes_top_down_lights.c b/examples/shapes/shapes_top_down_lights.c index 2371d1e29..4a2ea0dcd 100644 --- a/examples/shapes/shapes_top_down_lights.c +++ b/examples/shapes/shapes_top_down_lights.c @@ -20,14 +20,17 @@ #include "rlgl.h" // Custom Blend Modes -#define RLGL_SRC_ALPHA 0x0302 -#define RLGL_MIN 0x8007 -#define RLGL_MAX 0x8008 +#define RLGL_SRC_ALPHA 0x0302 +#define RLGL_MIN 0x8007 +#define RLGL_MAX 0x8008 -#define MAX_BOXES 20 -#define MAX_SHADOWS MAX_BOXES*3 // MAX_BOXES *3. Each box can cast up to two shadow volumes for the edges it is away from, and one for the box itself -#define MAX_LIGHTS 16 +#define MAX_BOXES 20 +#define MAX_SHADOWS MAX_BOXES*3 // MAX_BOXES*3 - Each box can cast up to two shadow volumes for the edges it is away from, and one for the box itself +#define MAX_LIGHTS 16 +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- // Shadow geometry type typedef struct ShadowGeometry { Vector2 vertices[4]; @@ -48,167 +51,26 @@ typedef struct LightInfo { int shadowCount; } LightInfo; +//------------------------------------------------------------------------------------ +// Global Variables Definition +//------------------------------------------------------------------------------------ +static LightInfo lights[MAX_LIGHTS] = { 0 }; -LightInfo lights[MAX_LIGHTS] = { 0 }; - +//------------------------------------------------------------------------------------ +// Module Functions Declaration +//------------------------------------------------------------------------------------ // Move a light and mark it as dirty so that we update it's mask next frame -void MoveLight(int slot, float x, float y) -{ - lights[slot].dirty = true; - lights[slot].position.x = x; - lights[slot].position.y = y; - - // update the cached bounds - lights[slot].bounds.x = x - lights[slot].outerRadius; - lights[slot].bounds.y = y - lights[slot].outerRadius; -} - +static void MoveLight(int slot, float x, float y); // Compute a shadow volume for the edge -// It takes the edge and projects it back by the light radius and turns it into a quad -void ComputeShadowVolumeForEdge(int slot, Vector2 sp, Vector2 ep) -{ - if (lights[slot].shadowCount >= MAX_SHADOWS) return; - - float extension = lights[slot].outerRadius*2; - - Vector2 spVector = Vector2Normalize(Vector2Subtract(sp, lights[slot].position)); - Vector2 spProjection = Vector2Add(sp, Vector2Scale(spVector, extension)); - - Vector2 epVector = Vector2Normalize(Vector2Subtract(ep, lights[slot].position)); - Vector2 epProjection = Vector2Add(ep, Vector2Scale(epVector, extension)); - - lights[slot].shadows[lights[slot].shadowCount].vertices[0] = sp; - lights[slot].shadows[lights[slot].shadowCount].vertices[1] = ep; - lights[slot].shadows[lights[slot].shadowCount].vertices[2] = epProjection; - lights[slot].shadows[lights[slot].shadowCount].vertices[3] = spProjection; - - lights[slot].shadowCount++; -} - +static void ComputeShadowVolumeForEdge(int slot, Vector2 sp, Vector2 ep); // Draw the light and shadows to the mask for a light -void DrawLightMask(int slot) -{ - // Use the light mask - BeginTextureMode(lights[slot].mask); - - ClearBackground(WHITE); - - // Force the blend mode to only set the alpha of the destination - rlSetBlendFactors(RLGL_SRC_ALPHA, RLGL_SRC_ALPHA, RLGL_MIN); - rlSetBlendMode(BLEND_CUSTOM); - - // If we are valid, then draw the light radius to the alpha mask - if (lights[slot].valid) DrawCircleGradient((int)lights[slot].position.x, (int)lights[slot].position.y, lights[slot].outerRadius, ColorAlpha(WHITE, 0), WHITE); - - rlDrawRenderBatchActive(); - - // Cut out the shadows from the light radius by forcing the alpha to maximum - rlSetBlendMode(BLEND_ALPHA); - rlSetBlendFactors(RLGL_SRC_ALPHA, RLGL_SRC_ALPHA, RLGL_MAX); - rlSetBlendMode(BLEND_CUSTOM); - - // Draw the shadows to the alpha mask - for (int i = 0; i < lights[slot].shadowCount; i++) - { - DrawTriangleFan(lights[slot].shadows[i].vertices, 4, WHITE); - } - - rlDrawRenderBatchActive(); - - // Go back to normal blend mode - rlSetBlendMode(BLEND_ALPHA); - - EndTextureMode(); -} - +static void DrawLightMask(int slot); // Setup a light -void SetupLight(int slot, float x, float y, float radius) -{ - lights[slot].active = true; - lights[slot].valid = false; // The light must prove it is valid - lights[slot].mask = LoadRenderTexture(GetScreenWidth(), GetScreenHeight()); - lights[slot].outerRadius = radius; - - lights[slot].bounds.width = radius*2; - lights[slot].bounds.height = radius*2; - - MoveLight(slot, x, y); - - // Force the render texture to have something in it - DrawLightMask(slot); -} - +static void SetupLight(int slot, float x, float y, float radius); // See if a light needs to update it's mask -bool UpdateLight(int slot, Rectangle* boxes, int count) -{ - if (!lights[slot].active || !lights[slot].dirty) return false; - - lights[slot].dirty = false; - lights[slot].shadowCount = 0; - lights[slot].valid = false; - - for (int i = 0; i < count; i++) - { - // Are we in a box? if so we are not valid - if (CheckCollisionPointRec(lights[slot].position, boxes[i])) return false; - - // If this box is outside our bounds, we can skip it - if (!CheckCollisionRecs(lights[slot].bounds, boxes[i])) continue; - - // Check the edges that are on the same side we are, and cast shadow volumes out from them - - // Top - Vector2 sp = (Vector2){ boxes[i].x, boxes[i].y }; - Vector2 ep = (Vector2){ boxes[i].x + boxes[i].width, boxes[i].y }; - - if (lights[slot].position.y > ep.y) ComputeShadowVolumeForEdge(slot, sp, ep); - - // Right - sp = ep; - ep.y += boxes[i].height; - if (lights[slot].position.x < ep.x) ComputeShadowVolumeForEdge(slot, sp, ep); - - // Bottom - sp = ep; - ep.x -= boxes[i].width; - if (lights[slot].position.y < ep.y) ComputeShadowVolumeForEdge(slot, sp, ep); - - // Left - sp = ep; - ep.y -= boxes[i].height; - if (lights[slot].position.x > ep.x) ComputeShadowVolumeForEdge(slot, sp, ep); - - // The box itself - lights[slot].shadows[lights[slot].shadowCount].vertices[0] = (Vector2){ boxes[i].x, boxes[i].y }; - lights[slot].shadows[lights[slot].shadowCount].vertices[1] = (Vector2){ boxes[i].x, boxes[i].y + boxes[i].height }; - lights[slot].shadows[lights[slot].shadowCount].vertices[2] = (Vector2){ boxes[i].x + boxes[i].width, boxes[i].y + boxes[i].height }; - lights[slot].shadows[lights[slot].shadowCount].vertices[3] = (Vector2){ boxes[i].x + boxes[i].width, boxes[i].y }; - lights[slot].shadowCount++; - } - - lights[slot].valid = true; - - DrawLightMask(slot); - - return true; -} - +static bool UpdateLight(int slot, Rectangle* boxes, int count); // Set up some boxes -void SetupBoxes(Rectangle *boxes, int *count) -{ - boxes[0] = (Rectangle){ 150,80, 40, 40 }; - boxes[1] = (Rectangle){ 1200, 700, 40, 40 }; - boxes[2] = (Rectangle){ 200, 600, 40, 40 }; - boxes[3] = (Rectangle){ 1000, 50, 40, 40 }; - boxes[4] = (Rectangle){ 500, 350, 40, 40 }; - - for (int i = 5; i < MAX_BOXES; i++) - { - boxes[i] = (Rectangle){(float)GetRandomValue(0,GetScreenWidth()), (float)GetRandomValue(0,GetScreenHeight()), (float)GetRandomValue(10,100), (float)GetRandomValue(10,100) }; - } - - *count = MAX_BOXES; -} +static void SetupBoxes(Rectangle *boxes, int *count); //------------------------------------------------------------------------------------ // Program main entry point @@ -356,3 +218,165 @@ int main(void) return 0; } + +//------------------------------------------------------------------------------------ +// Module Functions Definition +//------------------------------------------------------------------------------------ +// Move a light and mark it as dirty so that we update it's mask next frame +static void MoveLight(int slot, float x, float y) +{ + lights[slot].dirty = true; + lights[slot].position.x = x; + lights[slot].position.y = y; + + // update the cached bounds + lights[slot].bounds.x = x - lights[slot].outerRadius; + lights[slot].bounds.y = y - lights[slot].outerRadius; +} + +// Compute a shadow volume for the edge +// It takes the edge and projects it back by the light radius and turns it into a quad +static void ComputeShadowVolumeForEdge(int slot, Vector2 sp, Vector2 ep) +{ + if (lights[slot].shadowCount >= MAX_SHADOWS) return; + + float extension = lights[slot].outerRadius*2; + + Vector2 spVector = Vector2Normalize(Vector2Subtract(sp, lights[slot].position)); + Vector2 spProjection = Vector2Add(sp, Vector2Scale(spVector, extension)); + + Vector2 epVector = Vector2Normalize(Vector2Subtract(ep, lights[slot].position)); + Vector2 epProjection = Vector2Add(ep, Vector2Scale(epVector, extension)); + + lights[slot].shadows[lights[slot].shadowCount].vertices[0] = sp; + lights[slot].shadows[lights[slot].shadowCount].vertices[1] = ep; + lights[slot].shadows[lights[slot].shadowCount].vertices[2] = epProjection; + lights[slot].shadows[lights[slot].shadowCount].vertices[3] = spProjection; + + lights[slot].shadowCount++; +} + +// Setup a light +static void SetupLight(int slot, float x, float y, float radius) +{ + lights[slot].active = true; + lights[slot].valid = false; // The light must prove it is valid + lights[slot].mask = LoadRenderTexture(GetScreenWidth(), GetScreenHeight()); + lights[slot].outerRadius = radius; + + lights[slot].bounds.width = radius*2; + lights[slot].bounds.height = radius*2; + + MoveLight(slot, x, y); + + // Force the render texture to have something in it + DrawLightMask(slot); +} + +// See if a light needs to update it's mask +static bool UpdateLight(int slot, Rectangle* boxes, int count) +{ + if (!lights[slot].active || !lights[slot].dirty) return false; + + lights[slot].dirty = false; + lights[slot].shadowCount = 0; + lights[slot].valid = false; + + for (int i = 0; i < count; i++) + { + // Are we in a box? if so we are not valid + if (CheckCollisionPointRec(lights[slot].position, boxes[i])) return false; + + // If this box is outside our bounds, we can skip it + if (!CheckCollisionRecs(lights[slot].bounds, boxes[i])) continue; + + // Check the edges that are on the same side we are, and cast shadow volumes out from them + + // Top + Vector2 sp = (Vector2){ boxes[i].x, boxes[i].y }; + Vector2 ep = (Vector2){ boxes[i].x + boxes[i].width, boxes[i].y }; + + if (lights[slot].position.y > ep.y) ComputeShadowVolumeForEdge(slot, sp, ep); + + // Right + sp = ep; + ep.y += boxes[i].height; + if (lights[slot].position.x < ep.x) ComputeShadowVolumeForEdge(slot, sp, ep); + + // Bottom + sp = ep; + ep.x -= boxes[i].width; + if (lights[slot].position.y < ep.y) ComputeShadowVolumeForEdge(slot, sp, ep); + + // Left + sp = ep; + ep.y -= boxes[i].height; + if (lights[slot].position.x > ep.x) ComputeShadowVolumeForEdge(slot, sp, ep); + + // The box itself + lights[slot].shadows[lights[slot].shadowCount].vertices[0] = (Vector2){ boxes[i].x, boxes[i].y }; + lights[slot].shadows[lights[slot].shadowCount].vertices[1] = (Vector2){ boxes[i].x, boxes[i].y + boxes[i].height }; + lights[slot].shadows[lights[slot].shadowCount].vertices[2] = (Vector2){ boxes[i].x + boxes[i].width, boxes[i].y + boxes[i].height }; + lights[slot].shadows[lights[slot].shadowCount].vertices[3] = (Vector2){ boxes[i].x + boxes[i].width, boxes[i].y }; + lights[slot].shadowCount++; + } + + lights[slot].valid = true; + + DrawLightMask(slot); + + return true; +} + +// Draw the light and shadows to the mask for a light +static void DrawLightMask(int slot) +{ + // Use the light mask + BeginTextureMode(lights[slot].mask); + + ClearBackground(WHITE); + + // Force the blend mode to only set the alpha of the destination + rlSetBlendFactors(RLGL_SRC_ALPHA, RLGL_SRC_ALPHA, RLGL_MIN); + rlSetBlendMode(BLEND_CUSTOM); + + // If we are valid, then draw the light radius to the alpha mask + if (lights[slot].valid) DrawCircleGradient((int)lights[slot].position.x, (int)lights[slot].position.y, lights[slot].outerRadius, ColorAlpha(WHITE, 0), WHITE); + + rlDrawRenderBatchActive(); + + // Cut out the shadows from the light radius by forcing the alpha to maximum + rlSetBlendMode(BLEND_ALPHA); + rlSetBlendFactors(RLGL_SRC_ALPHA, RLGL_SRC_ALPHA, RLGL_MAX); + rlSetBlendMode(BLEND_CUSTOM); + + // Draw the shadows to the alpha mask + for (int i = 0; i < lights[slot].shadowCount; i++) + { + DrawTriangleFan(lights[slot].shadows[i].vertices, 4, WHITE); + } + + rlDrawRenderBatchActive(); + + // Go back to normal blend mode + rlSetBlendMode(BLEND_ALPHA); + + EndTextureMode(); +} + +// Set up some boxes +static void SetupBoxes(Rectangle *boxes, int *count) +{ + boxes[0] = (Rectangle){ 150,80, 40, 40 }; + boxes[1] = (Rectangle){ 1200, 700, 40, 40 }; + boxes[2] = (Rectangle){ 200, 600, 40, 40 }; + boxes[3] = (Rectangle){ 1000, 50, 40, 40 }; + boxes[4] = (Rectangle){ 500, 350, 40, 40 }; + + for (int i = 5; i < MAX_BOXES; i++) + { + boxes[i] = (Rectangle){(float)GetRandomValue(0,GetScreenWidth()), (float)GetRandomValue(0,GetScreenHeight()), (float)GetRandomValue(10,100), (float)GetRandomValue(10,100) }; + } + + *count = MAX_BOXES; +} diff --git a/examples/text/text_codepoints_loading.c b/examples/text/text_codepoints_loading.c index 2c33a8da5..7f8b1ef3a 100644 --- a/examples/text/text_codepoints_loading.c +++ b/examples/text/text_codepoints_loading.c @@ -23,6 +23,9 @@ // this text will be scanned to get all the required codepoints static char *text = "いろはにほへと ちりぬるを\nわかよたれそ つねならむ\nうゐのおくやま けふこえて\nあさきゆめみし ゑひもせす"; +//------------------------------------------------------------------------------------ +// Module Functions Declaration +//------------------------------------------------------------------------------------ // Remove codepoint duplicates if requested static int *CodepointRemoveDuplicates(int *codepoints, int codepointCount, int *codepointResultCount); @@ -128,6 +131,9 @@ int main(void) return 0; } +//------------------------------------------------------------------------------------ +// Module Functions Definition +//------------------------------------------------------------------------------------ // Remove codepoint duplicates if requested // WARNING: This process could be a bit slow if there text to process is very long static int *CodepointRemoveDuplicates(int *codepoints, int codepointCount, int *codepointsResultCount) diff --git a/examples/text/text_unicode.c b/examples/text/text_unicode.c index aa8527fa9..6847ad754 100644 --- a/examples/text/text_unicode.c +++ b/examples/text/text_unicode.c @@ -25,7 +25,7 @@ #define EMOJI_PER_HEIGHT 4 //-------------------------------------------------------------------------------------- -// Global variables +// Global Variables Definition //-------------------------------------------------------------------------------------- // Arrays that holds the random emojis struct { @@ -34,7 +34,8 @@ struct { Color color; // Emoji color } emoji[EMOJI_PER_WIDTH*EMOJI_PER_HEIGHT] = { 0 }; -static int hovered = -1, selected = -1; +static int hovered = -1; +static int selected = -1; // String containing 180 emoji codepoints separated by a '\0' char const char *const emojiCodepoints = "\xF0\x9F\x8C\x80\x00\xF0\x9F\x98\x80\x00\xF0\x9F\x98\x82\x00\xF0\x9F\xA4\xA3\x00\xF0\x9F\x98\x83\x00\xF0\x9F\x98\x86\x00\xF0\x9F\x98\x89\x00" diff --git a/examples/text/text_unicode_ranges.c b/examples/text/text_unicode_ranges.c index 76d20ba40..4c887f3f8 100644 --- a/examples/text/text_unicode_ranges.c +++ b/examples/text/text_unicode_ranges.c @@ -149,7 +149,7 @@ int main(void) (Rectangle){ 400, 16, font.texture.width*atlasScale, font.texture.height*atlasScale }, (Vector2){ 0, 0 }, 0.0f, WHITE); DrawRectangleLines(400, 16, 380, 380, RED); - DrawText(TextFormat("ATLAS SIZE: %ix%i px (x%02.1f)", font.texture.width, font.texture.height, atlasScale), 20, 380, 20, BLUE); + DrawText(TextFormat("ATLAS SIZE: %ix%i px (x%02.2f)", font.texture.width, font.texture.height, atlasScale), 20, 380, 20, BLUE); // Display font attribution DrawText("Font: Noto Sans TC. License: SIL Open Font License 1.1", screenWidth - 300, screenHeight - 20, 10, GRAY); diff --git a/examples/textures/textures_bunnymark.c b/examples/textures/textures_bunnymark.c index a26f175ca..7789602b5 100644 --- a/examples/textures/textures_bunnymark.c +++ b/examples/textures/textures_bunnymark.c @@ -23,6 +23,9 @@ // NOTE: This value is defined in [rlgl] module and can be changed there #define MAX_BATCH_ELEMENTS 8192 +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- typedef struct Bunny { Vector2 position; Vector2 speed; diff --git a/examples/textures/textures_fog_of_war.c b/examples/textures/textures_fog_of_war.c index 41a332272..4733caeb4 100644 --- a/examples/textures/textures_fog_of_war.c +++ b/examples/textures/textures_fog_of_war.c @@ -21,6 +21,9 @@ #define PLAYER_SIZE 16 // Player size #define PLAYER_TILE_VISIBILITY 2 // Player can see 2 tiles around its position +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- // Map data type typedef struct Map { unsigned int tilesX; // Number of tiles in X axis diff --git a/examples/textures/textures_particles_blending.c b/examples/textures/textures_particles_blending.c index 537d7f312..35ae67d3a 100644 --- a/examples/textures/textures_particles_blending.c +++ b/examples/textures/textures_particles_blending.c @@ -17,7 +17,10 @@ #define MAX_PARTICLES 200 -// Particle structure with basic data +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- +// Particle structure typedef struct { Vector2 position; Color color;