From a1896c7a90f241336a216e6fb1bc26dee4603912 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 12 Jan 2025 16:19:10 +0100 Subject: [PATCH 1/8] REVIEWED: Code/Web-Makefile formatting --- examples/Makefile | 30 +-- examples/Makefile.Web | 38 +-- examples/core/core_random_sequence.c | 264 ++++++++++---------- examples/shapes/shapes_rectangle_advanced.c | 156 +++++++----- projects/4coder/Makefile | 24 +- projects/VSCode/Makefile | 24 +- src/Makefile | 19 +- src/minshell.html | 8 +- src/shell.html | 8 +- 9 files changed, 302 insertions(+), 269 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 12d798b50680..f8c26f340490 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -330,20 +330,20 @@ endif ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # -Os # size optimization # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -sUSE_GLFW=3 # Use glfw3 library (context/input management) - # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) - # -sUSE_PTHREADS=1 # multithreading support - # -sWASM=0 # disable Web Assembly, emitted by default - # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS - # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # -sGL_ENABLE_GET_PROC_ADDRESS # enable using the *glGetProcAddress() family of functions, required for extensions loading + # -sUSE_GLFW=3 # Use glfw3 library (context/input management) + # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! + # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) + # -sUSE_PTHREADS=1 # multithreading support + # -sWASM=0 # disable Web Assembly, emitted by default + # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS + # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data + # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sMINIFY_HTML=0 # minify generated html from shell.html # --profiling # include information for code profiling # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation # --source-map-base # allow debugging in browser with source map - + # --shell-file shell.html # define a custom shell .html and output extension ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) LDFLAGS += -sUSE_GLFW=3 endif @@ -547,10 +547,11 @@ SHAPES = \ shapes/shapes_lines_bezier \ shapes/shapes_logo_raylib \ shapes/shapes_logo_raylib_anim \ + shapes/shapes_rectangle_advanced \ shapes/shapes_rectangle_scaling \ shapes/shapes_splines_drawing \ - shapes/shapes_top_down_lights \ - shapes/shapes_rectangle_advanced + shapes/shapes_top_down_lights + TEXTURES = \ textures/textures_background_scrolling \ @@ -603,6 +604,7 @@ MODELS = \ models/models_draw_cube_texture \ models/models_first_person_maze \ models/models_geometric_shapes \ + models/models_gpu_skinning \ models/models_heightmap \ models/models_loading \ models/models_loading_gltf \ @@ -614,9 +616,9 @@ MODELS = \ models/models_point_rendering \ models/models_rlgl_solar_system \ models/models_skybox \ + models/models_tesseract_view \ models/models_waving_cubes \ - models/models_yaw_pitch_roll \ - models/models_gpu_skinning + models/models_yaw_pitch_roll SHADERS = \ shaders/shaders_basic_lighting \ diff --git a/examples/Makefile.Web b/examples/Makefile.Web index 90345f97d802..d44b99dde2cf 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -266,25 +266,25 @@ endif ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # -Os # size optimization # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -sUSE_GLFW=3 # Use glfw3 library (context/input management) - # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) - # -sUSE_PTHREADS=1 # multithreading support - # -sWASM=0 # disable Web Assembly, emitted by default - # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS - # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # -sGL_ENABLE_GET_PROC_ADDRESS # enable using the *glGetProcAddress() family of functions, required for extensions loading + # -sUSE_GLFW=3 # Use glfw3 library (context/input management) + # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! + # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) + # -sUSE_PTHREADS=1 # multithreading support + # -sWASM=0 # disable Web Assembly, emitted by default + # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS + # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data + # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sMINIFY_HTML=0 # minify generated html from shell.html # --profiling # include information for code profiling # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation # --source-map-base # allow debugging in browser with source map - + # --shell-file shell.html # define a custom shell .html and output extension ifeq ($(PLATFORM),PLATFORM_WEB) LDFLAGS += -sUSE_GLFW=3 endif - LDFLAGS += -sEXPORTED_RUNTIME_METHODS=ccall + LDFLAGS += -sEXPORTED_RUNTIME_METHODS=ccall -s # Build using asyncify ifeq ($(BUILD_WEB_ASYNCIFY),TRUE) @@ -428,10 +428,10 @@ SHAPES = \ shapes/shapes_lines_bezier \ shapes/shapes_logo_raylib \ shapes/shapes_logo_raylib_anim \ + shapes/shapes_rectangle_advanced \ shapes/shapes_rectangle_scaling \ shapes/shapes_splines_drawing \ - shapes/shapes_top_down_lights \ - shapes/shapes_rectangle_advanced + shapes/shapes_top_down_lights TEXTURES = \ textures/textures_background_scrolling \ @@ -477,7 +477,6 @@ TEXT = \ MODELS = \ models/models_animation \ - models/models_gpu_skinning \ models/models_billboard \ models/models_bone_socket \ models/models_box_collisions \ @@ -485,6 +484,7 @@ MODELS = \ models/models_draw_cube_texture \ models/models_first_person_maze \ models/models_geometric_shapes \ + models/models_gpu_skinning \ models/models_heightmap \ models/models_loading \ models/models_loading_gltf \ @@ -496,6 +496,7 @@ MODELS = \ models/models_point_rendering \ models/models_rlgl_solar_system \ models/models_skybox \ + models/models_tesseract_view \ models/models_waving_cubes \ models/models_yaw_pitch_roll @@ -524,8 +525,8 @@ SHADERS = \ shaders/shaders_texture_outline \ shaders/shaders_texture_tiling \ shaders/shaders_texture_waves \ - shaders/shaders_write_depth \ - shaders/shaders_vertex_displacement + shaders/shaders_vertex_displacement \ + shaders/shaders_write_depth AUDIO = \ audio/audio_mixed_processor \ @@ -637,7 +638,7 @@ core/core_input_multitouch: core/core_input_multitouch.c core/core_input_virtual_controls: core/core_input_virtual_controls.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -# NOTE: To use multi-threading raylib must be compiled with multi-theading support (-s USE_PTHREADS=1) +# NOTE: To use multi-threading raylib must be compiled with multi-theading support (-sUSE_PTHREADS=1) # WARNING: For security reasons multi-threading is not supported on browsers, it requires cross-origin isolation (Oct.2021) # WARNING: It requires raylib to be compiled using -pthread, so atomic operations and thread-local data (if any) # in its source were transformed to non-atomic operations and non-thread-local data @@ -998,6 +999,9 @@ models/models_skybox: models/models_skybox.c --preload-file models/resources/shaders/glsl100/cubemap.vs@resources/shaders/glsl100/cubemap.vs \ --preload-file models/resources/shaders/glsl100/cubemap.fs@resources/shaders/glsl100/cubemap.fs +models/models_tesseract_view: models/models_tesseract_view.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) + models/models_waving_cubes: models/models_waving_cubes.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) diff --git a/examples/core/core_random_sequence.c b/examples/core/core_random_sequence.c index 2f7c3be95832..417440449fc7 100644 --- a/examples/core/core_random_sequence.c +++ b/examples/core/core_random_sequence.c @@ -18,159 +18,169 @@ #include // Required for: malloc() and free() -typedef struct ColorRect{ - Color c; - Rectangle r; +typedef struct ColorRect { + Color c; + Rectangle r; } ColorRect; +//------------------------------------------------------------------------------------ +// Module functions declaration +//------------------------------------------------------------------------------------ static Color GenerateRandomColor(); -static ColorRect* GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight); -static void ShuffleColorRectSequence(ColorRect* rectangles, int rectCount); -static void DrawTextCenterKeyHelp(const char* key, const char* text, int posX, int posY, int fontSize, Color color); +static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight); +static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount); +static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, int posY, int fontSize, Color color); //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ -int main(void) { - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - Generates a random sequence"); - - int rectCount = 20; - float rectSize = (float)screenWidth/rectCount; - ColorRect* rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight); - - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - - if(IsKeyPressed(KEY_SPACE)) - { - ShuffleColorRectSequence(rectangles, rectCount); - } +int main(void) +{ + // Initialization + //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; - if(IsKeyPressed(KEY_UP)) - { - rectCount++; - rectSize = (float)screenWidth/rectCount; - free(rectangles); - rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight); - } + InitWindow(screenWidth, screenHeight, "raylib [core] example - Generates a random sequence"); - if(IsKeyPressed(KEY_DOWN)) - { - if(rectCount >= 4){ - rectCount--; - rectSize = (float)screenWidth/rectCount; - free(rectangles); - rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight); - } - } + int rectCount = 20; + float rectSize = (float)screenWidth/rectCount; + ColorRect *rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f*screenHeight); - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- - ClearBackground(RAYWHITE); - - int fontSize = 20; - for(int x=0;x= 4) + { + rectCount--; + rectSize = (float)screenWidth/rectCount; + free(rectangles); + rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f*screenHeight); + } + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + int fontSize = 20; + for (int i = 0; i < rectCount; i++) + { + DrawRectangleRec(rectangles[i].r, rectangles[i].c); + DrawTextCenterKeyHelp("SPACE", "to shuffle the sequence.", 10, screenHeight - 96, fontSize, BLACK); + DrawTextCenterKeyHelp("UP", "to add a rectangle and generate a new sequence.", 10, screenHeight - 64, fontSize, BLACK); + DrawTextCenterKeyHelp("DOWN", "to remove a rectangle and generate a new sequence.", 10, screenHeight - 32, fontSize, BLACK); + } + + const char *rectCountText = TextFormat("%d rectangles", rectCount); + int rectCountTextSize = MeasureText(rectCountText, fontSize); + DrawText(rectCountText, screenWidth - rectCountTextSize - 10, 10, fontSize, BLACK); + + DrawFPS(10, 10); + + EndDrawing(); + //---------------------------------------------------------------------------------- } - const char* rectCountText = TextFormat("%d rectangles", rectCount); - int rectCountTextSize = MeasureText(rectCountText, fontSize); - DrawText(rectCountText, screenWidth - rectCountTextSize - 10, 10, fontSize, BLACK); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } + // De-Initialization + //-------------------------------------------------------------------------------------- + free(rectangles); + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- - // De-Initialization - //-------------------------------------------------------------------------------------- - - free(rectangles); - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; + return 0; } +//------------------------------------------------------------------------------------ +// Module functions definition +//------------------------------------------------------------------------------------ static Color GenerateRandomColor() { - return CLITERAL(Color){ - GetRandomValue(0, 255), - GetRandomValue(0, 255), - GetRandomValue(0, 255), - 255, - }; -} + Color color = { + GetRandomValue(0, 255), + GetRandomValue(0, 255), + GetRandomValue(0, 255), + 255 + }; -static ColorRect* GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight){ - int *seq = LoadRandomSequence((unsigned int)rectCount, 0, (unsigned int)rectCount-1); - ColorRect* rectangles = (ColorRect *)malloc((int)rectCount*sizeof(ColorRect)); + return color; +} - float rectSeqWidth = rectCount * rectWidth; - float startX = (screenWidth - rectSeqWidth) * 0.5f; +static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight) +{ + ColorRect *rectangles = (ColorRect *)malloc((int)rectCount*sizeof(ColorRect)); + int *seq = LoadRandomSequence((unsigned int)rectCount, 0, (unsigned int)rectCount - 1); + float rectSeqWidth = rectCount*rectWidth; + float startX = (screenWidth - rectSeqWidth)*0.5f; - for(int x=0;xc = r2->c; - r1->r.height = r2->r.height; - r1->r.y = r2->r.y; - r2->c = tmp.c; - r2->r.height = tmp.r.height; - r2->r.y = tmp.r.y; - - } - UnloadRandomSequence(seq); + int *seq = LoadRandomSequence(rectCount, 0, rectCount - 1); + + for (int i1 = 0; i1 < rectCount; i1++) + { + ColorRect *r1 = &rectangles[i1]; + ColorRect *r2 = &rectangles[seq[i1]]; + + // Swap only the color and height + ColorRect tmp = *r1; + r1->c = r2->c; + r1->r.height = r2->r.height; + r1->r.y = r2->r.y; + r2->c = tmp.c; + r2->r.height = tmp.r.height; + r2->r.y = tmp.r.y; + } + + UnloadRandomSequence(seq); } -static void DrawTextCenterKeyHelp(const char* key, const char* text, int posX, int posY, int fontSize, Color color) +static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, int posY, int fontSize, Color color) { - int spaceSize = MeasureText(" ", fontSize); - int pressSize = MeasureText("Press", fontSize); - int keySize = MeasureText(key, fontSize); - int textSize = MeasureText(text, fontSize); - int totalSize = pressSize + 2 * spaceSize + keySize + 2 * spaceSize + textSize; - int textSizeCurrent = 0; - - DrawText("Press", posX, posY, fontSize, color); - textSizeCurrent += pressSize + 2 * spaceSize; - DrawText(key, posX + textSizeCurrent, posY, fontSize, RED); - DrawRectangle(posX + textSizeCurrent, posY + fontSize, keySize, 3, RED); - textSizeCurrent += keySize + 2 * spaceSize; - DrawText(text, posX + textSizeCurrent, posY, fontSize, color); + int spaceSize = MeasureText(" ", fontSize); + int pressSize = MeasureText("Press", fontSize); + int keySize = MeasureText(key, fontSize); + int textSize = MeasureText(text, fontSize); + int totalSize = pressSize + 2*spaceSize + keySize + 2*spaceSize + textSize; + int textSizeCurrent = 0; + + DrawText("Press", posX, posY, fontSize, color); + textSizeCurrent += pressSize + 2*spaceSize; + DrawText(key, posX + textSizeCurrent, posY, fontSize, RED); + DrawRectangle(posX + textSizeCurrent, posY + fontSize, keySize, 3, RED); + textSizeCurrent += keySize + 2*spaceSize; + DrawText(text, posX + textSizeCurrent, posY, fontSize, color); } \ No newline at end of file diff --git a/examples/shapes/shapes_rectangle_advanced.c b/examples/shapes/shapes_rectangle_advanced.c index e885a10ee05a..6dd7d2e7e8df 100644 --- a/examples/shapes/shapes_rectangle_advanced.c +++ b/examples/shapes/shapes_rectangle_advanced.c @@ -1,10 +1,87 @@ +/******************************************************************************************* +* +* raylib [shapes] example - Rectangle advanced +* +* Example originally created with raylib 5.5, last time updated with raylib 5.5 +* +* 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) 2024-2025 raylib contributors and Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + #include "raylib.h" + #include "rlgl.h" + #include // Draw rectangle with rounded edges and horizontal gradient, with options to choose side of roundness -// Adapted from both `DrawRectangleRounded` and `DrawRectangleGradientH` -void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float roundnessRight, int segments, Color left, Color right) +static void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float roundnessRight, int segments, Color left, Color right); + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main(void) +{ + // Initialization + //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [shapes] example - rectangle avanced"); + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update rectangle bounds + //---------------------------------------------------------------------------------- + float width = GetScreenWidth()/2.0f, height = GetScreenHeight()/6.0f; + Rectangle rec = { + GetScreenWidth() / 2.0f - width/2, + GetScreenHeight() / 2.0f - 5*(height/2), + width, height + }; + //-------------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + ClearBackground(RAYWHITE); + + // Draw All Rectangles with different roundess for each side and different gradients + DrawRectangleRoundedGradientH(rec, 0.8f, 0.8f, 36, BLUE, RED); + + rec.y += rec.height + 1; + DrawRectangleRoundedGradientH(rec, 0.5f, 1.0f, 36, RED, PINK); + + rec.y += rec.height + 1; + DrawRectangleRoundedGradientH(rec, 1.0f, 0.5f, 36, RED, BLUE); + + rec.y += rec.height + 1; + DrawRectangleRoundedGradientH(rec, 0.0f, 1.0f, 36, BLUE, BLACK); + + rec.y += rec.height + 1; + DrawRectangleRoundedGradientH(rec, 1.0f, 0.0f, 36, BLUE, PINK); + EndDrawing(); + //-------------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} + +// Draw rectangle with rounded edges and horizontal gradient, with options to choose side of roundness +// NOTE: Adapted from both 'DrawRectangleRounded()' and 'DrawRectangleGradientH()' raylib [rshapes] implementations +static void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float roundnessRight, int segments, Color left, Color right) { // Neither side is rounded if ((roundnessLeft <= 0.0f && roundnessRight <= 0.0f) || (rec.width < 1) || (rec.height < 1 )) @@ -29,7 +106,7 @@ void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float rou float stepLength = 90.0f/(float)segments; /* - Diagram Copied here for reference, original at `DrawRectangleRounded` source code + Diagram Copied here for reference, original at 'DrawRectangleRounded()' source code P0____________________P1 /| |\ @@ -113,12 +190,9 @@ void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float rou } } - // - // Here we use the `Diagram` to guide ourselves to which point receives what color. - // + // Here we use the 'Diagram' to guide ourselves to which point receives what color // By choosing the color correctly associated with a pointe the gradient effect - // will naturally come from OpenGL interpolation. - // + // will naturally come from OpenGL interpolation // [2] Upper Rectangle rlColor4ub(left.r, left.g, left.b, left.a); @@ -187,27 +261,25 @@ void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float rou rlSetTexture(0); #else - // - // Here we use the `Diagram` to guide ourselves to which point receives what color. - // + // Here we use the 'Diagram' to guide ourselves to which point receives what color. // By choosing the color correctly associated with a pointe the gradient effect // will naturally come from OpenGL interpolation. // But this time instead of Quad, we think in triangles. - // rlBegin(RL_TRIANGLES); - // Draw all of the 4 corners: [1] Upper Left Corner, [3] Upper Right Corner, [5] Lower Right Corner, [7] Lower Left Corner for (int k = 0; k < 4; ++k) { - Color color; - float radius; + Color color = { 0 }; + float radius = 0.0f; if (k == 0) color = left, radius = radiusLeft; // [1] Upper Left Corner if (k == 1) color = right, radius = radiusRight; // [3] Upper Right Corner if (k == 2) color = right, radius = radiusRight; // [5] Lower Right Corner if (k == 3) color = left, radius = radiusLeft; // [7] Lower Left Corner + float angle = angles[k]; const Vector2 center = centers[k]; + for (int i = 0; i < segments; i++) { rlColor4ub(color.r, color.g, color.b, color.a); @@ -274,57 +346,3 @@ void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float rou rlEnd(); #endif } - -int main(int argc, char *argv[]) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - rectangle avanced"); - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update rectangle bounds - //---------------------------------------------------------------------------------- - float width = GetScreenWidth()/2.0f, height = GetScreenHeight()/6.0f; - Rectangle rec = { - GetScreenWidth() / 2.0f - width/2, - GetScreenHeight() / 2.0f - (5)*(height/2), - width, height - }; - //-------------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - ClearBackground(RAYWHITE); - - // Draw All Rectangles with different roundess for each side and different gradients - DrawRectangleRoundedGradientH(rec, 0.8f, 0.8f, 36, BLUE, RED); - - rec.y += rec.height + 1; - DrawRectangleRoundedGradientH(rec, 0.5f, 1.0f, 36, RED, PINK); - - rec.y += rec.height + 1; - DrawRectangleRoundedGradientH(rec, 1.0f, 0.5f, 36, RED, BLUE); - - rec.y += rec.height + 1; - DrawRectangleRoundedGradientH(rec, 0.0f, 1.0f, 36, BLUE, BLACK); - - rec.y += rec.height + 1; - DrawRectangleRoundedGradientH(rec, 1.0f, 0.0f, 36, BLUE, PINK); - EndDrawing(); - //-------------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - return 0; -} - diff --git a/projects/4coder/Makefile b/projects/4coder/Makefile index 641731291a43..1b598eed5f20 100644 --- a/projects/4coder/Makefile +++ b/projects/4coder/Makefile @@ -219,21 +219,23 @@ endif ifeq ($(PLATFORM),PLATFORM_WEB) # -Os # size optimization # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sUSE_GLFW=3 # Use glfw3 library (context/input management) + # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! + # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) + # -sUSE_PTHREADS=1 # multithreading support + # -sWASM=0 # disable Web Assembly, emitted by default + # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS + # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data + # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sMINIFY_HTML=0 # minify generated html from shell.html # --profiling # include information for code profiling # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -Os -s USE_GLFW=3 -s TOTAL_MEMORY=16777216 --preload-file resources + # --source-map-base # allow debugging in browser with source map + # --shell-file shell.html # define a custom shell .html and output extension + CFLAGS += -Os -sUSE_GLFW=3 -sTOTAL_MEMORY=16777216 --preload-file resources -sMINIFY_HTML=0 ifeq ($(BUILD_MODE), DEBUG) - CFLAGS += -s ASSERTIONS=1 --profiling + CFLAGS += -sASSERTIONS=1 --profiling endif # Define a custom shell .html and output extension diff --git a/projects/VSCode/Makefile b/projects/VSCode/Makefile index 72b850d9b705..389a12cf972a 100644 --- a/projects/VSCode/Makefile +++ b/projects/VSCode/Makefile @@ -225,21 +225,23 @@ endif ifeq ($(PLATFORM),PLATFORM_WEB) # -Os # size optimization # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sUSE_GLFW=3 # Use glfw3 library (context/input management) + # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! + # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) + # -sUSE_PTHREADS=1 # multithreading support + # -sWASM=0 # disable Web Assembly, emitted by default + # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS + # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data + # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sMINIFY_HTML=0 # minify generated html from shell.html # --profiling # include information for code profiling # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -Os -s USE_GLFW=3 -s TOTAL_MEMORY=16777216 --preload-file resources + # --source-map-base # allow debugging in browser with source map + # --shell-file shell.html # define a custom shell .html and output extension + CFLAGS += -Os -sUSE_GLFW=3 -sTOTAL_MEMORY=16777216 --preload-file resources -sMINIFY_HTML=0 ifeq ($(BUILD_MODE), DEBUG) - CFLAGS += -s ASSERTIONS=1 --profiling + CFLAGS += -sASSERTIONS=1 --profiling endif # Define a custom shell .html and output extension diff --git a/src/Makefile b/src/Makefile index 37554b2a0a93..a626db52ed82 100644 --- a/src/Makefile +++ b/src/Makefile @@ -369,20 +369,23 @@ endif ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # -Os # size optimization # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -sUSE_GLFW=3 # Use glfw3 library (context/input management) -> Only for linker! - # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -sUSE_PTHREADS=1 # multithreading support - # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # -sGL_ENABLE_GET_PROC_ADDRESS # enable using the *glGetProcAddress() family of functions, required for extensions loading + # -sUSE_GLFW=3 # Use glfw3 library (context/input management) + # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! + # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) + # -sUSE_PTHREADS=1 # multithreading support + # -sWASM=0 # disable Web Assembly, emitted by default + # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS + # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data + # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sMINIFY_HTML=0 # minify generated html from shell.html # --profiling # include information for code profiling # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation + # --source-map-base # allow debugging in browser with source map + # --shell-file shell.html # define a custom shell .html and output extension ifeq ($(RAYLIB_BUILD_MODE),DEBUG) CFLAGS += -sASSERTIONS=1 --profiling endif - #CFLAGS += -sGL_ENABLE_GET_PROC_ADDRESS endif ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) # Compiler flags for arquitecture diff --git a/src/minshell.html b/src/minshell.html index 4068ca36c750..ec71588419e3 100644 --- a/src/minshell.html +++ b/src/minshell.html @@ -34,12 +34,8 @@