5 Commits

6 changed files with 166 additions and 60 deletions

View File

@ -104,7 +104,7 @@ USE_WAYLAND_DISPLAY ?= FALSE
BUILD_WEB_ASYNCIFY ?= TRUE
BUILD_WEB_SHELL ?= $(RAYLIB_PATH)/src/shell.html
BUILD_WEB_HEAP_SIZE ?= 134217728
BUILD_WEB_RESOURCES ?= TRUE
BUILD_WEB_RESOURCES ?= FALSE
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
# Use WebGL2 backend (OpenGL 3.0)
# WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3
@ -920,8 +920,7 @@ textures/textures_logo_raylib: textures/textures_logo_raylib.c
--preload-file textures/resources/raylib_logo.png@resources/raylib_logo.png
textures/textures_mouse_painting: textures/textures_mouse_painting.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/my_amazing_texture_painting.png@my_amazing_texture_painting.png
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
textures/textures_npatch_drawing: textures/textures_npatch_drawing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \

View File

@ -2,26 +2,29 @@
:: .
:: Compile your examples for web using: build_example_web.bat <example_category>/<example_name>
:: .
set "INPUT_FILE=%1"
SET "INPUT_FILE=%1"
:: Change delimiter for the FOR loop
for /f "tokens=1-10 delims=/" %%a in ("%INPUT_FILE%") do (
set CATEGORY=%%a
set FILENAME=%%b
FOR /f "tokens=1-10 delims=/" %%a IN ("%INPUT_FILE%") DO (
SET CATEGORY=%%a
SET FILENAME=%%b
)
:: > Setup required Environment
:: > SETup required Environment
:: -------------------------------------
set RAYLIB_PATH=C:\GitHub\raylib
set EMSDK_PATH=C:\raylib\emsdk
SET RAYLIB_PATH=C:\GitHub\raylib
SET EMSDK_PATH=C:\raylib\emsdk
SET COMPILER_PATH=C:\raylib\w64devkit\bin
ENV_SET PATH=%COMPILER_PATH%
SET MAKE=mingw32-make
echo
:: Set required web compilation options
:: SET required web compilation options
:: -------------------------------------
set CC=%EMSDK_PATH%\upstream\emscripten\emcc
set CFLAGS=-Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -O3 -I. -Iexternal -I%RAYLIB_PATH%\src -I%RAYLIB_PATH%\external -DPLATFORM_WEB
set LDFLAGS=-L. -L$(RAYLIB_PATH)\src -sUSE_GLFW=3 -sEXPORTED_RUNTIME_METHODS=ccall -sASYNCIFY --shell-file %RAYLIB_PATH%\src\shell.html
set LDLIBS=%RAYLIB_PATH%\src\libraylib.web.a
:: TODO: If using some resources/assets, set the directory path as shown in the commented line!
set RESOURCES=
::set RESOURCES=--preload-file $(RESOURCES_PATH)
SET CC=%EMSDK_PATH%\upstream\emscripten\emcc
SET CFLAGS=-Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -O3 -I. -Iexternal -I%RAYLIB_PATH%\src -I%RAYLIB_PATH%\external -DPLATFORM_WEB
SET LDFLAGS=-L. -L$(RAYLIB_PATH)\src -sUSE_GLFW=3 -sEXPORTED_RUNTIME_METHODS=ccall -sASYNCIFY --shell-file %RAYLIB_PATH%\src\shell.html
SET LDLIBS=%RAYLIB_PATH%\src\libraylib.web.a
:: TODO: If using some resources/asSETs, SET the directory path as shown in the commented line!
::SET RESOURCES=
::SET RESOURCES=--preload-file $(RESOURCES_PATH)
cd %RAYLIB_PATH%\examples\%CATEGORY%
echo
:: Clean latest build
@ -31,13 +34,15 @@ cmd /c if exist %FILENAME%.wasm del /F %FILENAME%.wasm
cmd /c if exist %FILENAME%.js del /F %FILENAME%.js
cmd /c if exist %FILENAME%.data del /F %FILENAME%.data
echo
:: Setup emsdk environment
:: SETup emsdk environment
:: --------------------------
call %EMSDK_PATH%\emsdk_env.bat
echo on
:: Compile program
:: -----------------------
C:
%CC% -o %FILENAME%.html %FILENAME%.c %CFLAGS% %LDFLAGS% %LDLIBS% %RESOURCES%
cd %RAYLIB_PATH%\examples
%MAKE% -f Makefile.Web %CATEGORY%/%FILENAME% PLATFORM=PLATFORM_WEB -B
::%CC% -o %FILENAME%.html %FILENAME%.c %CFLAGS% %LDFLAGS% %LDLIBS% %RESOURCES%
cd ..
echo

View File

@ -48,7 +48,9 @@
*
**********************************************************************************************/
#ifdef USING_SDL3_PACKAGE
#define USING_SDL3_PROJECT
#endif
#ifndef SDL_ENABLE_OLD_NAMES
#define SDL_ENABLE_OLD_NAMES // Just in case we're on SDL3, we need some in-between compatibily
#endif
@ -1620,7 +1622,7 @@ void PollInputEvents(void)
// Add character (codepoint) to the queue
#if defined(PLATFORM_DESKTOP_SDL3)
unsigned int textLen = strlen(event.text.text);
unsigned int codepoint = (unsigned int)SDL_StepUTF8(&event.text.text, textLen);
unsigned int codepoint = (unsigned int)SDL_StepUTF8(&event.text.text, &textLen);
#else
int codepointSize = 0;
int codepoint = GetCodepointNextSDL(event.text.text, &codepointSize);

View File

@ -92,7 +92,7 @@ Example elements validated:
| textures_sprite_button | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| textures_sprite_explosion | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| textures_bunnymark | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| textures_mouse_painting | ✔ | ✔ | ✔ | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| textures_mouse_painting | ✔ | ✔ | ✔ | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| textures_blend_modes | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| textures_draw_tiled | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| textures_polygon | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
@ -174,9 +174,9 @@ Example elements validated:
| audio_stream_effects | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| audio_sound_multi | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| audio_sound_positioning | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| rlgl_standalone | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | |
| rlgl_compute_shader | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | |
| easings_testbed | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | |
| raylib_opengl_interop | ✔ | ❌ | ❌ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | |
| embedded_files_loading | ✔ | ❌ | ❌ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | |
| raymath_vector_angle | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | |
| rlgl_standalone | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | |
| rlgl_compute_shader | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | |
| easings_testbed | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | |
| raylib_opengl_interop | ✔ | ❌ | ❌ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | |
| embedded_files_loading | ✔ | ❌ | ❌ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | |
| raymath_vector_angle | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | |

View File

@ -0,0 +1,39 @@
# EXAMPLES COLLECTION - VALIDATION REPORT
```
Example elements validated:
- [C] : Missing .c source file
- [CAT] : Not a recognized category
- [INFO] : Inconsistent example header info (stars, author...)
- [PNG] : Missing screenshot .png
- [WPNG] : Invalid png screenshot (using default one)
- [RES] : Missing resources listed in the code
- [MK] : Not listed in Makefile
- [MKWEB] : Not listed in Makefile.Web
- [VCX] : Missing Visual Studio project file
- [SOL] : Project not included in solution file
- [RDME] : Not listed in README.md
- [JS] : Not listed in Web (examples.js)
- [WOUT] : Missing Web build (.html/.data/.wasm/.js)
```
| **EXAMPLE NAME** | [C] | [CAT]| [INFO]|[PNG]|[WPNG]| [RES]| [MK] |[MKWEB]| [VCX]| [SOL]|[RDME]|[JS] | [WOUT]|
|:---------------------------------|:---:|:----:|:-----:|:---:|:----:|:----:|:----:|:-----:|:----:|:----:|:----:|:---:|:-----:|
| core_input_virtual_controls | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| core_basic_window_web | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ❌ |
| core_input_gestures_web | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ |
| core_high_dpi | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shapes_digital_clock | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_font_sdf | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_draw_3d | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_codepoints_loading | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_loading_vox | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_loading_m3d | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_texture_outline | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| audio_music_stream | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| rlgl_standalone | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| rlgl_compute_shader | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| easings_testbed | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| raylib_opengl_interop | ✔ | ❌ | ❌ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ |
| embedded_files_loading | ✔ | ❌ | ❌ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| raymath_vector_angle | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ |

View File

@ -842,6 +842,7 @@ int main(int argc, char *argv[])
// Validate: raylib/examples/<category>/resources/.. -> Example resources available?
// Scan resources used in example to check for missing resource files
// WARNING: Some paths could be for files to save, not files to load, verify it
char **resPaths = ScanExampleResources(TextFormat("%s/%s/%s.c", exBasePath, exInfo->category, exInfo->name), &exInfo->resCount);
if (exInfo->resCount > 0)
{
@ -881,11 +882,14 @@ int main(int argc, char *argv[])
// Validate: raylib.com/examples/<category>/<category>_example_name.data -> File exists?
// Validate: raylib.com/examples/<category>/<category>_example_name.wasm -> File exists?
// Validate: raylib.com/examples/<category>/<category>_example_name.js -> File exists?
if (!FileExists(TextFormat("%s/%s/%s.html", exWebPath, exInfo->category, exInfo->name)) ||
!FileExists(TextFormat("%s/%s/%s.wasm", exWebPath, exInfo->category, exInfo->name)) ||
!FileExists(TextFormat("%s/%s/%s.js", exWebPath, exInfo->category, exInfo->name)) ||
((exInfo->resCount > 0) && !FileExists(TextFormat("%s/%s/%s.data", exWebPath, exInfo->category, exInfo->name))))
if (!TextIsEqual(exInfo->category, "others") &&
(!FileExists(TextFormat("%s/%s/%s.html", exWebPath, exInfo->category, exInfo->name)) ||
!FileExists(TextFormat("%s/%s/%s.wasm", exWebPath, exInfo->category, exInfo->name)) ||
!FileExists(TextFormat("%s/%s/%s.js", exWebPath, exInfo->category, exInfo->name)) ||
((exInfo->resCount > 0) && !FileExists(TextFormat("%s/%s/%s.data", exWebPath, exInfo->category, exInfo->name)))))
{
exInfo->status |= VALID_MISSING_WEB_OUTPUT;
}
// NOTE: Additional validation elements
// Validate: Example naming conventions: <category>/<category>_example_name, valid category
@ -998,6 +1002,7 @@ int main(int argc, char *argv[])
}
// Generate validation report/table with results (.md)
//-----------------------------------------------------------------------------------------------------
/*
Columns:
[C] VALID_MISSING_C // Missing .c source file
@ -1021,8 +1026,6 @@ int main(int argc, char *argv[])
| text_format_text | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✔ | ✘ | ✔ | ✔ | ✔ |
*/
// TODO: Generate a report with only the examples missing some elements
char *report = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1);
int repIndex = 0;
@ -1067,6 +1070,58 @@ int main(int argc, char *argv[])
SaveFileText(TextFormat("%s/../tools/rexm/%s", exBasePath, "examples_report.md"), report);
RL_FREE(report);
//-----------------------------------------------------------------------------------------------------
// Generate a report with only the examples missing some elements
//-----------------------------------------------------------------------------------------------------
char *reportIssues = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1);
repIndex = 0;
repIndex += sprintf(reportIssues + repIndex, "# EXAMPLES COLLECTION - VALIDATION REPORT\n\n");
repIndex += sprintf(reportIssues + repIndex, "```\nExample elements validated:\n\n");
repIndex += sprintf(reportIssues + repIndex, " - [C] : Missing .c source file\n");
repIndex += sprintf(reportIssues + repIndex, " - [CAT] : Not a recognized category\n");
repIndex += sprintf(reportIssues + repIndex, " - [INFO] : Inconsistent example header info (stars, author...)\n");
repIndex += sprintf(reportIssues + repIndex, " - [PNG] : Missing screenshot .png\n");
repIndex += sprintf(reportIssues + repIndex, " - [WPNG] : Invalid png screenshot (using default one)\n");
repIndex += sprintf(reportIssues + repIndex, " - [RES] : Missing resources listed in the code\n");
repIndex += sprintf(reportIssues + repIndex, " - [MK] : Not listed in Makefile\n");
repIndex += sprintf(reportIssues + repIndex, " - [MKWEB] : Not listed in Makefile.Web\n");
repIndex += sprintf(reportIssues + repIndex, " - [VCX] : Missing Visual Studio project file\n");
repIndex += sprintf(reportIssues + repIndex, " - [SOL] : Project not included in solution file\n");
repIndex += sprintf(reportIssues + repIndex, " - [RDME] : Not listed in README.md\n");
repIndex += sprintf(reportIssues + repIndex, " - [JS] : Not listed in Web (examples.js)\n");
repIndex += sprintf(reportIssues + repIndex, " - [WOUT] : Missing Web build (.html/.data/.wasm/.js)\n```\n");
repIndex += sprintf(reportIssues + repIndex, "| **EXAMPLE NAME** | [C] | [CAT]| [INFO]|[PNG]|[WPNG]| [RES]| [MK] |[MKWEB]| [VCX]| [SOL]|[RDME]|[JS] | [WOUT]|\n");
repIndex += sprintf(reportIssues + repIndex, "|:---------------------------------|:---:|:----:|:-----:|:---:|:----:|:----:|:----:|:-----:|:----:|:----:|:----:|:---:|:-----:|\n");
for (int i = 0; i < exCollectionCount; i++)
{
if (exCollection[i].status > 0)
{
repIndex += sprintf(reportIssues + repIndex, "| %-32s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s |\n",
exCollection[i].name,
(exCollection[i].status & VALID_MISSING_C)? "" : "",
(exCollection[i].status & VALID_INVALID_CATEGORY)? "" : "",
(exCollection[i].status & VALID_INCONSISTENT_INFO)? "" : "",
(exCollection[i].status & VALID_MISSING_PNG)? "" : "",
(exCollection[i].status & VALID_INVALID_PNG)? "" : "",
(exCollection[i].status & VALID_MISSING_RESOURCES)? "" : "",
(exCollection[i].status & VALID_NOT_IN_MAKEFILE)? "" : "",
(exCollection[i].status & VALID_NOT_IN_MAKEFILE_WEB)? "" : "",
(exCollection[i].status & VALID_MISSING_VCXPROJ)? "" : "",
(exCollection[i].status & VALID_NOT_IN_VCXSOL)? "" : "",
(exCollection[i].status & VALID_NOT_IN_README)? "" : "",
(exCollection[i].status & VALID_NOT_IN_JS)? "" : "",
(exCollection[i].status & VALID_MISSING_WEB_OUTPUT)? "" : "");
}
}
SaveFileText(TextFormat("%s/../tools/rexm/%s", exBasePath, "examples_report_issues.md"), reportIssues);
RL_FREE(reportIssues);
//-----------------------------------------------------------------------------------------------------
UnloadExamplesData(exCollection);
//------------------------------------------------------------------------------------------------
@ -1798,37 +1853,43 @@ static char **ScanExampleResources(const char *filePath, int *resPathCount)
char *end = strchr(start, '"');
if (!end) break;
int len = (int)(end - start);
if ((len > 0) && (len < REXM_MAX_RESOURCE_PATH_LEN))
// TODO: WARNING: Some paths could be for files to save, not files to load, verify it
// HACK: Just check previous position from pointer for function name including the string...
// This is a horrible solution, the good one would be getting the data loading function names...
if (TextFindIndex(ptr - 40, "ExportImage") == -1)
{
char buffer[REXM_MAX_RESOURCE_PATH_LEN] = { 0 };
strncpy(buffer, start, len);
buffer[len] = '\0';
// TODO: Make sure buffer is a path (and not a Tracelog() text)
// Check for known extensions
for (int i = 0; i < extCount; i++)
int len = (int)(end - start);
if ((len > 0) && (len < REXM_MAX_RESOURCE_PATH_LEN))
{
// TODO: WARNING: IsFileExtension() expects a NULL terminated fileName,
// but in this case buffer can contain any kind of string,
// including not paths strings, for example TraceLog() string
if (IsFileExtension(buffer, exts[i]))
char buffer[REXM_MAX_RESOURCE_PATH_LEN] = { 0 };
strncpy(buffer, start, len);
buffer[len] = '\0';
// TODO: Make sure buffer is a path (and not a Tracelog() text)
// Check for known extensions
for (int i = 0; i < extCount; i++)
{
// Avoid duplicates
bool found = false;
for (int j = 0; j < resCounter; j++)
// TODO: WARNING: IsFileExtension() expects a NULL terminated fileName,
// but in this case buffer can contain any kind of string,
// including not paths strings, for example TraceLog() string
if (IsFileExtension(buffer, exts[i]))
{
if (strcmp(paths[j], buffer) == 0) { found = true; break; }
}
// Avoid duplicates
bool found = false;
for (int j = 0; j < resCounter; j++)
{
if (strcmp(paths[j], buffer) == 0) { found = true; break; }
}
if (!found && (resCounter < REXM_MAX_RESOURCE_PATHS))
{
strcpy(paths[resCounter], buffer);
resCounter++;
}
if (!found && (resCounter < REXM_MAX_RESOURCE_PATHS))
{
strcpy(paths[resCounter], buffer);
resCounter++;
}
break;
break;
}
}
}
}