REVIEWED: Code/Web-Makefile formatting
This commit is contained in:
parent
43db59d1aa
commit
a1896c7a90
9 changed files with 302 additions and 269 deletions
|
@ -330,20 +330,20 @@ endif
|
||||||
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
||||||
# -Os # size optimization
|
# -Os # size optimization
|
||||||
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
||||||
# -sUSE_GLFW=3 # Use glfw3 library (context/input management)
|
# -sUSE_GLFW=3 # Use glfw3 library (context/input management)
|
||||||
# -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
# -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)
|
# -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB)
|
||||||
# -sUSE_PTHREADS=1 # multithreading support
|
# -sUSE_PTHREADS=1 # multithreading support
|
||||||
# -sWASM=0 # disable Web Assembly, emitted by default
|
# -sWASM=0 # disable Web Assembly, emitted by default
|
||||||
# -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
|
# -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
|
||||||
# -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data
|
# -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)
|
# -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
|
# -sMINIFY_HTML=0 # minify generated html from shell.html
|
||||||
# --profiling # include information for code profiling
|
# --profiling # include information for code profiling
|
||||||
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --preload-file resources # specify a resources folder for data compilation
|
||||||
# --source-map-base # allow debugging in browser with source map
|
# --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)
|
ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
|
||||||
LDFLAGS += -sUSE_GLFW=3
|
LDFLAGS += -sUSE_GLFW=3
|
||||||
endif
|
endif
|
||||||
|
@ -547,10 +547,11 @@ SHAPES = \
|
||||||
shapes/shapes_lines_bezier \
|
shapes/shapes_lines_bezier \
|
||||||
shapes/shapes_logo_raylib \
|
shapes/shapes_logo_raylib \
|
||||||
shapes/shapes_logo_raylib_anim \
|
shapes/shapes_logo_raylib_anim \
|
||||||
|
shapes/shapes_rectangle_advanced \
|
||||||
shapes/shapes_rectangle_scaling \
|
shapes/shapes_rectangle_scaling \
|
||||||
shapes/shapes_splines_drawing \
|
shapes/shapes_splines_drawing \
|
||||||
shapes/shapes_top_down_lights \
|
shapes/shapes_top_down_lights
|
||||||
shapes/shapes_rectangle_advanced
|
|
||||||
|
|
||||||
TEXTURES = \
|
TEXTURES = \
|
||||||
textures/textures_background_scrolling \
|
textures/textures_background_scrolling \
|
||||||
|
@ -603,6 +604,7 @@ MODELS = \
|
||||||
models/models_draw_cube_texture \
|
models/models_draw_cube_texture \
|
||||||
models/models_first_person_maze \
|
models/models_first_person_maze \
|
||||||
models/models_geometric_shapes \
|
models/models_geometric_shapes \
|
||||||
|
models/models_gpu_skinning \
|
||||||
models/models_heightmap \
|
models/models_heightmap \
|
||||||
models/models_loading \
|
models/models_loading \
|
||||||
models/models_loading_gltf \
|
models/models_loading_gltf \
|
||||||
|
@ -614,9 +616,9 @@ MODELS = \
|
||||||
models/models_point_rendering \
|
models/models_point_rendering \
|
||||||
models/models_rlgl_solar_system \
|
models/models_rlgl_solar_system \
|
||||||
models/models_skybox \
|
models/models_skybox \
|
||||||
|
models/models_tesseract_view \
|
||||||
models/models_waving_cubes \
|
models/models_waving_cubes \
|
||||||
models/models_yaw_pitch_roll \
|
models/models_yaw_pitch_roll
|
||||||
models/models_gpu_skinning
|
|
||||||
|
|
||||||
SHADERS = \
|
SHADERS = \
|
||||||
shaders/shaders_basic_lighting \
|
shaders/shaders_basic_lighting \
|
||||||
|
|
|
@ -266,25 +266,25 @@ endif
|
||||||
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
||||||
# -Os # size optimization
|
# -Os # size optimization
|
||||||
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
||||||
# -sUSE_GLFW=3 # Use glfw3 library (context/input management)
|
# -sUSE_GLFW=3 # Use glfw3 library (context/input management)
|
||||||
# -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
# -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)
|
# -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB)
|
||||||
# -sUSE_PTHREADS=1 # multithreading support
|
# -sUSE_PTHREADS=1 # multithreading support
|
||||||
# -sWASM=0 # disable Web Assembly, emitted by default
|
# -sWASM=0 # disable Web Assembly, emitted by default
|
||||||
# -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
|
# -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
|
||||||
# -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data
|
# -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)
|
# -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
|
# -sMINIFY_HTML=0 # minify generated html from shell.html
|
||||||
# --profiling # include information for code profiling
|
# --profiling # include information for code profiling
|
||||||
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --preload-file resources # specify a resources folder for data compilation
|
||||||
# --source-map-base # allow debugging in browser with source map
|
# --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)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
LDFLAGS += -sUSE_GLFW=3
|
LDFLAGS += -sUSE_GLFW=3
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LDFLAGS += -sEXPORTED_RUNTIME_METHODS=ccall
|
LDFLAGS += -sEXPORTED_RUNTIME_METHODS=ccall -s
|
||||||
|
|
||||||
# Build using asyncify
|
# Build using asyncify
|
||||||
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
|
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
|
||||||
|
@ -428,10 +428,10 @@ SHAPES = \
|
||||||
shapes/shapes_lines_bezier \
|
shapes/shapes_lines_bezier \
|
||||||
shapes/shapes_logo_raylib \
|
shapes/shapes_logo_raylib \
|
||||||
shapes/shapes_logo_raylib_anim \
|
shapes/shapes_logo_raylib_anim \
|
||||||
|
shapes/shapes_rectangle_advanced \
|
||||||
shapes/shapes_rectangle_scaling \
|
shapes/shapes_rectangle_scaling \
|
||||||
shapes/shapes_splines_drawing \
|
shapes/shapes_splines_drawing \
|
||||||
shapes/shapes_top_down_lights \
|
shapes/shapes_top_down_lights
|
||||||
shapes/shapes_rectangle_advanced
|
|
||||||
|
|
||||||
TEXTURES = \
|
TEXTURES = \
|
||||||
textures/textures_background_scrolling \
|
textures/textures_background_scrolling \
|
||||||
|
@ -477,7 +477,6 @@ TEXT = \
|
||||||
|
|
||||||
MODELS = \
|
MODELS = \
|
||||||
models/models_animation \
|
models/models_animation \
|
||||||
models/models_gpu_skinning \
|
|
||||||
models/models_billboard \
|
models/models_billboard \
|
||||||
models/models_bone_socket \
|
models/models_bone_socket \
|
||||||
models/models_box_collisions \
|
models/models_box_collisions \
|
||||||
|
@ -485,6 +484,7 @@ MODELS = \
|
||||||
models/models_draw_cube_texture \
|
models/models_draw_cube_texture \
|
||||||
models/models_first_person_maze \
|
models/models_first_person_maze \
|
||||||
models/models_geometric_shapes \
|
models/models_geometric_shapes \
|
||||||
|
models/models_gpu_skinning \
|
||||||
models/models_heightmap \
|
models/models_heightmap \
|
||||||
models/models_loading \
|
models/models_loading \
|
||||||
models/models_loading_gltf \
|
models/models_loading_gltf \
|
||||||
|
@ -496,6 +496,7 @@ MODELS = \
|
||||||
models/models_point_rendering \
|
models/models_point_rendering \
|
||||||
models/models_rlgl_solar_system \
|
models/models_rlgl_solar_system \
|
||||||
models/models_skybox \
|
models/models_skybox \
|
||||||
|
models/models_tesseract_view \
|
||||||
models/models_waving_cubes \
|
models/models_waving_cubes \
|
||||||
models/models_yaw_pitch_roll
|
models/models_yaw_pitch_roll
|
||||||
|
|
||||||
|
@ -524,8 +525,8 @@ SHADERS = \
|
||||||
shaders/shaders_texture_outline \
|
shaders/shaders_texture_outline \
|
||||||
shaders/shaders_texture_tiling \
|
shaders/shaders_texture_tiling \
|
||||||
shaders/shaders_texture_waves \
|
shaders/shaders_texture_waves \
|
||||||
shaders/shaders_write_depth \
|
shaders/shaders_vertex_displacement \
|
||||||
shaders/shaders_vertex_displacement
|
shaders/shaders_write_depth
|
||||||
|
|
||||||
AUDIO = \
|
AUDIO = \
|
||||||
audio/audio_mixed_processor \
|
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
|
core/core_input_virtual_controls: core/core_input_virtual_controls.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(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: 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)
|
# 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
|
# 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.vs@resources/shaders/glsl100/cubemap.vs \
|
||||||
--preload-file models/resources/shaders/glsl100/cubemap.fs@resources/shaders/glsl100/cubemap.fs
|
--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
|
models/models_waving_cubes: models/models_waving_cubes.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
|
|
|
@ -18,159 +18,169 @@
|
||||||
|
|
||||||
#include <stdlib.h> // Required for: malloc() and free()
|
#include <stdlib.h> // Required for: malloc() and free()
|
||||||
|
|
||||||
typedef struct ColorRect{
|
typedef struct ColorRect {
|
||||||
Color c;
|
Color c;
|
||||||
Rectangle r;
|
Rectangle r;
|
||||||
} ColorRect;
|
} ColorRect;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Module functions declaration
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
static Color GenerateRandomColor();
|
static Color GenerateRandomColor();
|
||||||
static ColorRect* GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight);
|
static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight);
|
||||||
static void ShuffleColorRectSequence(ColorRect* rectangles, int rectCount);
|
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 void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, int posY, int fontSize, Color color);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
int main(void) {
|
int main(void)
|
||||||
// Initialization
|
{
|
||||||
//--------------------------------------------------------------------------------------
|
// Initialization
|
||||||
const int screenWidth = 800;
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenHeight = 450;
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - Generates a random sequence");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - Generates a random sequence");
|
||||||
|
|
||||||
int rectCount = 20;
|
int rectCount = 20;
|
||||||
float rectSize = (float)screenWidth/rectCount;
|
float rectSize = (float)screenWidth/rectCount;
|
||||||
ColorRect* rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight);
|
ColorRect *rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f*screenHeight);
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
if(IsKeyPressed(KEY_SPACE))
|
|
||||||
{
|
{
|
||||||
ShuffleColorRectSequence(rectangles, rectCount);
|
// 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();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IsKeyPressed(KEY_UP))
|
// De-Initialization
|
||||||
{
|
//--------------------------------------------------------------------------------------
|
||||||
rectCount++;
|
free(rectangles);
|
||||||
rectSize = (float)screenWidth/rectCount;
|
CloseWindow(); // Close window and OpenGL context
|
||||||
free(rectangles);
|
//--------------------------------------------------------------------------------------
|
||||||
rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(IsKeyPressed(KEY_DOWN))
|
return 0;
|
||||||
{
|
|
||||||
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 x=0;x<rectCount;x++)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Module functions definition
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
static Color GenerateRandomColor()
|
static Color GenerateRandomColor()
|
||||||
{
|
{
|
||||||
return CLITERAL(Color){
|
Color color = {
|
||||||
GetRandomValue(0, 255),
|
GetRandomValue(0, 255),
|
||||||
GetRandomValue(0, 255),
|
GetRandomValue(0, 255),
|
||||||
GetRandomValue(0, 255),
|
GetRandomValue(0, 255),
|
||||||
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));
|
|
||||||
|
|
||||||
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 color;
|
||||||
return rectangles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShuffleColorRectSequence(ColorRect* rectangles, int rectCount)
|
static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight)
|
||||||
{
|
{
|
||||||
int *seq = LoadRandomSequence(rectCount, 0, rectCount-1);
|
ColorRect *rectangles = (ColorRect *)malloc((int)rectCount*sizeof(ColorRect));
|
||||||
for(int i1=0;i1<rectCount;i1++){
|
int *seq = LoadRandomSequence((unsigned int)rectCount, 0, (unsigned int)rectCount - 1);
|
||||||
ColorRect* r1 = &rectangles[i1];
|
float rectSeqWidth = rectCount*rectWidth;
|
||||||
ColorRect* r2 = &rectangles[seq[i1]];
|
float startX = (screenWidth - rectSeqWidth)*0.5f;
|
||||||
|
|
||||||
// swap only the color and height
|
for (int i = 0; i < rectCount; i++)
|
||||||
ColorRect tmp = *r1;
|
{
|
||||||
r1->c = r2->c;
|
int rectHeight = (int)Remap((float)seq[i], 0, rectCount - 1, 0, screenHeight);
|
||||||
r1->r.height = r2->r.height;
|
|
||||||
r1->r.y = r2->r.y;
|
rectangles[i].c = GenerateRandomColor();
|
||||||
r2->c = tmp.c;
|
rectangles[i].r = CLITERAL(Rectangle){ startX + i*rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight };
|
||||||
r2->r.height = tmp.r.height;
|
}
|
||||||
r2->r.y = tmp.r.y;
|
|
||||||
|
UnloadRandomSequence(seq);
|
||||||
}
|
|
||||||
UnloadRandomSequence(seq);
|
return rectangles;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawTextCenterKeyHelp(const char* key, const char* text, int posX, int posY, int fontSize, Color color)
|
static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount)
|
||||||
{
|
{
|
||||||
int spaceSize = MeasureText(" ", fontSize);
|
int *seq = LoadRandomSequence(rectCount, 0, rectCount - 1);
|
||||||
int pressSize = MeasureText("Press", fontSize);
|
|
||||||
int keySize = MeasureText(key, fontSize);
|
for (int i1 = 0; i1 < rectCount; i1++)
|
||||||
int textSize = MeasureText(text, fontSize);
|
{
|
||||||
int totalSize = pressSize + 2 * spaceSize + keySize + 2 * spaceSize + textSize;
|
ColorRect *r1 = &rectangles[i1];
|
||||||
int textSizeCurrent = 0;
|
ColorRect *r2 = &rectangles[seq[i1]];
|
||||||
|
|
||||||
DrawText("Press", posX, posY, fontSize, color);
|
// Swap only the color and height
|
||||||
textSizeCurrent += pressSize + 2 * spaceSize;
|
ColorRect tmp = *r1;
|
||||||
DrawText(key, posX + textSizeCurrent, posY, fontSize, RED);
|
r1->c = r2->c;
|
||||||
DrawRectangle(posX + textSizeCurrent, posY + fontSize, keySize, 3, RED);
|
r1->r.height = r2->r.height;
|
||||||
textSizeCurrent += keySize + 2 * spaceSize;
|
r1->r.y = r2->r.y;
|
||||||
DrawText(text, posX + textSizeCurrent, posY, fontSize, color);
|
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)
|
||||||
|
{
|
||||||
|
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);
|
||||||
}
|
}
|
|
@ -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 "raylib.h"
|
||||||
|
|
||||||
#include "rlgl.h"
|
#include "rlgl.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
// Draw rectangle with rounded edges and horizontal gradient, with options to choose side of roundness
|
// Draw rectangle with rounded edges and horizontal gradient, with options to choose side of roundness
|
||||||
// Adapted from both `DrawRectangleRounded` and `DrawRectangleGradientH`
|
static void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float roundnessRight, int segments, Color left, Color right);
|
||||||
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
|
// Neither side is rounded
|
||||||
if ((roundnessLeft <= 0.0f && roundnessRight <= 0.0f) || (rec.width < 1) || (rec.height < 1 ))
|
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;
|
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
|
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
|
// 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
|
// [2] Upper Rectangle
|
||||||
rlColor4ub(left.r, left.g, left.b, left.a);
|
rlColor4ub(left.r, left.g, left.b, left.a);
|
||||||
|
@ -187,27 +261,25 @@ void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float rou
|
||||||
rlSetTexture(0);
|
rlSetTexture(0);
|
||||||
#else
|
#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
|
// By choosing the color correctly associated with a pointe the gradient effect
|
||||||
// will naturally come from OpenGL interpolation.
|
// will naturally come from OpenGL interpolation.
|
||||||
// But this time instead of Quad, we think in triangles.
|
// But this time instead of Quad, we think in triangles.
|
||||||
//
|
|
||||||
|
|
||||||
rlBegin(RL_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
|
// 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)
|
for (int k = 0; k < 4; ++k)
|
||||||
{
|
{
|
||||||
Color color;
|
Color color = { 0 };
|
||||||
float radius;
|
float radius = 0.0f;
|
||||||
if (k == 0) color = left, radius = radiusLeft; // [1] Upper Left Corner
|
if (k == 0) color = left, radius = radiusLeft; // [1] Upper Left Corner
|
||||||
if (k == 1) color = right, radius = radiusRight; // [3] Upper Right 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 == 2) color = right, radius = radiusRight; // [5] Lower Right Corner
|
||||||
if (k == 3) color = left, radius = radiusLeft; // [7] Lower Left Corner
|
if (k == 3) color = left, radius = radiusLeft; // [7] Lower Left Corner
|
||||||
|
|
||||||
float angle = angles[k];
|
float angle = angles[k];
|
||||||
const Vector2 center = centers[k];
|
const Vector2 center = centers[k];
|
||||||
|
|
||||||
for (int i = 0; i < segments; i++)
|
for (int i = 0; i < segments; i++)
|
||||||
{
|
{
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
|
@ -274,57 +346,3 @@ void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float rou
|
||||||
rlEnd();
|
rlEnd();
|
||||||
#endif
|
#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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -219,21 +219,23 @@ endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# -Os # size optimization
|
# -Os # size optimization
|
||||||
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
||||||
# -s USE_GLFW=3 # Use glfw3 library (context/input management)
|
# -sUSE_GLFW=3 # Use glfw3 library (context/input management)
|
||||||
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
# -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
||||||
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
|
# -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB)
|
||||||
# -s USE_PTHREADS=1 # multithreading support
|
# -sUSE_PTHREADS=1 # multithreading support
|
||||||
# -s WASM=0 # disable Web Assembly, emitted by default
|
# -sWASM=0 # disable Web Assembly, emitted by default
|
||||||
# -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow)
|
# -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
|
||||||
# -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter
|
# -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data
|
||||||
# -s FORCE_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)
|
||||||
# -s ASSERTIONS=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
|
# --profiling # include information for code profiling
|
||||||
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --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)
|
ifeq ($(BUILD_MODE), DEBUG)
|
||||||
CFLAGS += -s ASSERTIONS=1 --profiling
|
CFLAGS += -sASSERTIONS=1 --profiling
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define a custom shell .html and output extension
|
# Define a custom shell .html and output extension
|
||||||
|
|
|
@ -225,21 +225,23 @@ endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# -Os # size optimization
|
# -Os # size optimization
|
||||||
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
||||||
# -s USE_GLFW=3 # Use glfw3 library (context/input management)
|
# -sUSE_GLFW=3 # Use glfw3 library (context/input management)
|
||||||
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
# -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
||||||
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
|
# -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB)
|
||||||
# -s USE_PTHREADS=1 # multithreading support
|
# -sUSE_PTHREADS=1 # multithreading support
|
||||||
# -s WASM=0 # disable Web Assembly, emitted by default
|
# -sWASM=0 # disable Web Assembly, emitted by default
|
||||||
# -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow)
|
# -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
|
||||||
# -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter
|
# -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data
|
||||||
# -s FORCE_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)
|
||||||
# -s ASSERTIONS=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
|
# --profiling # include information for code profiling
|
||||||
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --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)
|
ifeq ($(BUILD_MODE), DEBUG)
|
||||||
CFLAGS += -s ASSERTIONS=1 --profiling
|
CFLAGS += -sASSERTIONS=1 --profiling
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define a custom shell .html and output extension
|
# Define a custom shell .html and output extension
|
||||||
|
|
19
src/Makefile
19
src/Makefile
|
@ -369,20 +369,23 @@ endif
|
||||||
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
||||||
# -Os # size optimization
|
# -Os # size optimization
|
||||||
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
||||||
# -sUSE_GLFW=3 # Use glfw3 library (context/input management) -> Only for linker!
|
# -sUSE_GLFW=3 # Use glfw3 library (context/input management)
|
||||||
# -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
# -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
||||||
# -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
|
# -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB)
|
||||||
# -sUSE_PTHREADS=1 # multithreading support
|
# -sUSE_PTHREADS=1 # multithreading support
|
||||||
# -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data
|
# -sWASM=0 # disable Web Assembly, emitted by default
|
||||||
# -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off)
|
# -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
|
||||||
# -sGL_ENABLE_GET_PROC_ADDRESS # enable using the *glGetProcAddress() family of functions, required for extensions loading
|
# -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
|
# --profiling # include information for code profiling
|
||||||
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --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)
|
ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
|
||||||
CFLAGS += -sASSERTIONS=1 --profiling
|
CFLAGS += -sASSERTIONS=1 --profiling
|
||||||
endif
|
endif
|
||||||
#CFLAGS += -sGL_ENABLE_GET_PROC_ADDRESS
|
|
||||||
endif
|
endif
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
|
ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
|
||||||
# Compiler flags for arquitecture
|
# Compiler flags for arquitecture
|
||||||
|
|
|
@ -34,12 +34,8 @@
|
||||||
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
|
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
body { margin: 0px; overflow: hidden; background-color: black; }
|
||||||
margin: 0px;
|
canvas.emscripten { border: 0px none; background-color: black; }
|
||||||
overflow: hidden;
|
|
||||||
background-color: black;
|
|
||||||
}
|
|
||||||
canvas.emscripten { border: 0px none; background-color: black;}
|
|
||||||
</style>
|
</style>
|
||||||
<script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
|
<script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
<meta property="og:title" content="raylib web game">
|
<meta property="og:title" content="raylib web game">
|
||||||
<meta property="og:image:type" content="image/png">
|
<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" 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:site_name" content="raylib - example">
|
||||||
<meta property="og:url" content="https://www.raylib.com/games.html">
|
<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">
|
<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">
|
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
body { font-family: arial; margin: 0; padding: none; }
|
||||||
font-family: arial;
|
|
||||||
margin: 0;
|
|
||||||
padding: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#header {
|
#header {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue