Browse Source

REVIEWED: Code/Web-Makefile formatting

pull/4683/head
Ray 1 month ago
parent
commit
a1896c7a90
9 changed files with 302 additions and 269 deletions
  1. +16
    -14
      examples/Makefile
  2. +21
    -17
      examples/Makefile.Web
  3. +137
    -127
      examples/core/core_random_sequence.c
  4. +87
    -69
      examples/shapes/shapes_rectangle_advanced.c
  5. +13
    -11
      projects/4coder/Makefile
  6. +13
    -11
      projects/VSCode/Makefile
  7. +11
    -8
      src/Makefile
  8. +2
    -6
      src/minshell.html
  9. +2
    -6
      src/shell.html

+ 16
- 14
examples/Makefile View File

@ -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 \

+ 21
- 17
examples/Makefile.Web View File

@ -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)

+ 137
- 127
examples/core/core_random_sequence.c View File

@ -18,159 +18,169 @@
#include <stdlib.h> // 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<rectCount;x++)
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
DrawRectangleRec(rectangles[x].r, rectangles[x].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);
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_SPACE)) ShuffleColorRectSequence(rectangles, rectCount);
if (IsKeyPressed(KEY_UP))
{
rectCount++;
rectSize = (float)screenWidth/rectCount;
free(rectangles);
rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f*screenHeight);
}
if (IsKeyPressed(KEY_DOWN))
{
if (rectCount >= 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;x<rectCount;x++){
int rectHeight = (int)Remap((float)seq[x], 0, rectCount-1, 0, screenHeight);
rectangles[x].c = GenerateRandomColor();
rectangles[x].r = CLITERAL(Rectangle){
startX + x * rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight
};
}
UnloadRandomSequence(seq);
return rectangles;
for (int i = 0; i < rectCount; i++)
{
int rectHeight = (int)Remap((float)seq[i], 0, rectCount - 1, 0, screenHeight);
rectangles[i].c = GenerateRandomColor();
rectangles[i].r = CLITERAL(Rectangle){ startX + i*rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight };
}
UnloadRandomSequence(seq);
return rectangles;
}
static void ShuffleColorRectSequence(ColorRect* rectangles, int rectCount)
static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount)
{
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);
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);
}

+ 87
- 69
examples/shapes/shapes_rectangle_advanced.c View File

@ -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 <math.h>
// 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;
}

+ 13
- 11
projects/4coder/Makefile View File

@ -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

+ 13
- 11
projects/VSCode/Makefile View File

@ -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

+ 11
- 8
src/Makefile View File

@ -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

+ 2
- 6
src/minshell.html View File

@ -34,12 +34,8 @@
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
<style>
body {
margin: 0px;
overflow: hidden;
background-color: black;
}
canvas.emscripten { border: 0px none; background-color: black;}
body { margin: 0px; overflow: hidden; background-color: black; }
canvas.emscripten { border: 0px none; background-color: black; }
</style>
<script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
<script type='text/javascript'>

+ 2
- 6
src/shell.html View File

@ -15,8 +15,8 @@
<meta property="og:type" content="website" />
<meta property="og:title" content="raylib web game">
<meta property="og:image:type" content="image/png">
<meta property="og:image:alt" content="New raylib web videogame, developed using raylib videogames library" />
<meta property="og:image" content="https://www.raylib.com/common/raylib_logo.png">
<meta property="og:image:alt" content="New raylib web videogame, developed using raylib videogames library" />
<meta property="og:site_name" content="raylib - example">
<meta property="og:url" content="https://www.raylib.com/games.html">
<meta property="og:description" content="New raylib web videogame, developed using raylib videogames library">
@ -34,11 +34,7 @@
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
<style>
body {
font-family: arial;
margin: 0;
padding: none;
}
body { font-family: arial; margin: 0; padding: none; }
#header {
width: 100%;

Loading…
Cancel
Save