5 Commits

Author SHA1 Message Date
Ray
f6ae596a1d Update rexm.c 2025-09-09 00:47:12 +02:00
Ray
0da5bc1e17 REXM: REVIEWED: TextReplaceBetween() 2025-09-09 00:26:38 +02:00
Ray
4447868c60 REXM: Updated examples, resources checking 2025-09-09 00:16:47 +02:00
Ray
adb078128b Update rexm.c 2025-09-09 00:15:30 +02:00
Ray
28c5d16000 Update shaders_shadowmap_rendering.c 2025-09-09 00:15:26 +02:00
5 changed files with 48 additions and 37 deletions

View File

@ -1248,8 +1248,7 @@ shaders/shaders_shadowmap_rendering: shaders/shaders_shadowmap_rendering.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/shadowmap.vs@resources/shaders/glsl100/shadowmap.vs \
--preload-file shaders/resources/shaders/glsl100/shadowmap.fs@resources/shaders/glsl100/shadowmap.fs \
--preload-file shaders/resources/models/robot.glb@resources/models/robot.glb \
--preload-file shaders/shaders_shadowmap.png@shaders_shadowmap.png
--preload-file shaders/resources/models/robot.glb@resources/models/robot.glb
shaders/shaders_shapes_textures: shaders/shaders_shapes_textures.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \

View File

@ -42,10 +42,11 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT);
// Shadows are a HUGE topic, and this example shows an extremely simple implementation of the shadowmapping algorithm,
// which is the industry standard for shadows. This algorithm can be extended in a ridiculous number of ways to improve
// realism and also adapt it for different scenes. This is pretty much the simplest possible implementation
SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shadowmap rendering");
Camera3D camera = (Camera3D){ 0 };
@ -143,8 +144,8 @@ int main(void)
// Draw
//----------------------------------------------------------------------------------
// First, render all objects into the shadowmap
// The idea is, we record all the objects' depths (as rendered from the light source's point of view) in a buffer
// PASS 01: Render all objects into the shadowmap render texture
// We record all the objects' depths (as rendered from the light source's point of view) in a buffer
// Anything that is "visible" to the light is in light, anything that isn't is in shadow
// We can later use the depth buffer when rendering everything from the player's point of view
// to determine whether a given point is "visible" to the light
@ -160,7 +161,7 @@ int main(void)
EndTextureMode();
lightViewProj = MatrixMultiply(lightView, lightProj);
// Draw the scene using the generated shadowmap
// PASS 02: Draw the scene into main framebuffer, using the generated shadowmap
BeginDrawing();
ClearBackground(RAYWHITE);
@ -199,7 +200,7 @@ int main(void)
}
// Load render texture for shadowmap projection
// NOTE: Load frmaebuffer with only a texture depth attachment,
// NOTE: Load framebuffer with only a texture depth attachment,
// no color attachment required for shadowmap
static RenderTexture2D LoadShadowmapRenderTexture(int width, int height)
{
@ -214,11 +215,11 @@ static RenderTexture2D LoadShadowmapRenderTexture(int width, int height)
rlEnableFramebuffer(target.id);
// Create depth texture
// We don't need a color texture for the shadowmap
// NOTE: No need a color texture attachment for the shadowmap
target.depth.id = rlLoadTextureDepth(width, height, false);
target.depth.width = width;
target.depth.height = height;
target.depth.format = 19; //DEPTH_COMPONENT_24BIT?
target.depth.format = 19; // DEPTH_COMPONENT_24BIT?
target.depth.mipmaps = 1;
// Attach depth texture to FBO
@ -245,8 +246,8 @@ static void UnloadShadowmapRenderTexture(RenderTexture2D target)
}
}
// Draw scene
// NOTE: Required several calls to generate shadowmap
// Draw full scene projecting shadows
// NOTE: Required to be called several time to generate shadowmap
static void DrawScene(Model cube, Model robot)
{
DrawModelEx(cube, Vector3Zero(), (Vector3) { 0.0f, 1.0f, 0.0f }, 0.0f, (Vector3) { 10.0f, 1.0f, 10.0f }, BLUE);

View File

@ -159,7 +159,7 @@ Example elements validated:
| shaders_deferred_rendering | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_hybrid_rendering | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_texture_tiling | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_shadowmap_rendering | ✔ | ✔ | ✔ | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_shadowmap_rendering | ✔ | ✔ | ✔ | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_vertex_displacement | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_write_depth | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_basic_pbr | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |

View File

@ -20,7 +20,6 @@ Example elements validated:
```
| **EXAMPLE NAME** | [C] | [CAT]| [INFO]|[PNG]|[WPNG]| [RES]| [MK] |[MKWEB]| [VCX]| [SOL]|[RDME]|[JS] | [WOUT]|[WMETA]|
|:---------------------------------|:---:|:----:|:-----:|:---:|:----:|:----:|:----:|:-----:|:----:|:----:|:----:|:---:|:-----:|:-----:|
| shaders_shadowmap_rendering | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| rlgl_standalone | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| rlgl_compute_shader | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| easings_testbed | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |

View File

@ -187,7 +187,7 @@ static void UpdateWebMetadata(const char *exHtmlPath, const char *exFilePath);
// Get text between two strings
static char *GetTextBetween(const char *text, const char *begin, const char *end);
// Replace text between two specific strings
static char *TextReplaceBetween(const char *text, const char *replace, const char *begin, const char *end);
static char *TextReplaceBetween(const char *text, const char *begin, const char *end, const char *replace);
//------------------------------------------------------------------------------------
// Program main entry point
@ -639,9 +639,15 @@ int main(int argc, char *argv[])
FileRename(TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName),
TextFormat("%s/%s/%s.png", exBasePath, exCategory, exRename));
// TODO: Edit: Update example source code metadata
//rlExampleInfo *info = LoadExamplesData(exCollectionFilePath, exRename, false, NULL); // TODO: Load one example from collection
//UpdateSourceMetadata(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exRename), info);
// Edit: Update example source code metadata
int exListCount = 0;
rlExampleInfo *exList = LoadExamplesData(exCollectionFilePath, exCategory, false, &exListCount);
for (int i = 0; i < exListCount; i++)
{
if (strcmp(exList[i].name, exRename) == 0)
UpdateSourceMetadata(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exRename), &exList[i]);
}
UnloadExamplesData(exList);
// NOTE: Example resource files do not need to be changed...
// unless the example is moved from one caegory to another
@ -860,7 +866,8 @@ int main(int argc, char *argv[])
for (unsigned int i = 0; i < list.count; i++)
{
if ((strcmp("examples_template", GetFileNameWithoutExt(list.paths[i])) != 0) && // HACK: Skip "examples_template"
// NOTE: Skipping "examples_template" from checks
if ((strcmp("examples_template", GetFileNameWithoutExt(list.paths[i])) != 0) &&
(TextFindIndex(exList, GetFileNameWithoutExt(list.paths[i])) == -1))
{
// Add example to the examples collection list
@ -2043,11 +2050,16 @@ static char **ScanExampleResources(const char *filePath, int *resPathCount)
if (!end) break;
// WARNING: Some paths could be for saving files, not loading, those "resource" files must be omitted
// HACK: Just check previous position from pointer for function name including the string...
// HACK: Just check previous position from pointer for function name including the string and the index "distance"
// This is a quick solution, the good one would be getting the data loading function names...
//if ((TextFindIndex(ptr - 40, "ExportImage") == -1) &&
// (TextFindIndex(ptr - 10, "TraceLog") == -1)) // Avoid TraceLog() strings processing
if (TextFindIndex(ptr - 40, "ExportImage") == -1)
int functionIndex01 = TextFindIndex(ptr - 40, "ExportImage"); // Check ExportImage()
int functionIndex02 = TextFindIndex(ptr - 10, "TraceLog"); // Check TraceLog()
int functionIndex03 = TextFindIndex(ptr - 40, "TakeScreenshot"); // Check TakeScreenshot()
if (!((functionIndex01 != -1) && (functionIndex01 < 40)) && // Not found ExportImage() before ""
!((functionIndex02 != -1) && (functionIndex02 < 10)) && // Not found TraceLog() before ""
!((functionIndex03 != -1) && (functionIndex03 < 40))) // Not found TakeScreenshot() before ""
{
int len = (int)(end - start);
if ((len > 0) && (len < REXM_MAX_RESOURCE_PATH_LEN))
@ -2315,8 +2327,8 @@ static void UpdateSourceMetadata(const char *exSrcPath, const rlExampleInfo *inf
// Update example header title (line #3 - ALWAYS)
// String: "* raylib [shaders] example - texture drawing"
exTextUpdated[0] = TextReplaceBetween(exTextUpdatedPtr,
TextFormat("%s] example - %s", info->category, exNameFormated), "* raylib [", "\n");
exTextUpdated[0] = TextReplaceBetween(exTextUpdatedPtr, "* raylib [", "\n",
TextFormat("%s] example - %s", info->category, exNameFormated));
if (exTextUpdated[0] != NULL) exTextUpdatedPtr = exTextUpdated[0];
// Update example complexity rating
@ -2329,42 +2341,42 @@ static void UpdateSourceMetadata(const char *exSrcPath, const rlExampleInfo *inf
if (i < info->stars) strcpy(starsText + 3*i, "");
else strcpy(starsText + 3*i, "");
}
exTextUpdated[1] = TextReplaceBetween(exTextUpdatedPtr,
TextFormat("%s] %i", starsText, info->stars), "* Example complexity rating: [", "/4\n");
exTextUpdated[1] = TextReplaceBetween(exTextUpdatedPtr, "* Example complexity rating: [", "/4\n",
TextFormat("%s] %i", starsText, info->stars));
if (exTextUpdated[1] != NULL) exTextUpdatedPtr = exTextUpdated[1];
// Update example creation/update raylib versions
// String: "* Example originally created with raylib 2.0, last time updated with raylib 3.7
exTextUpdated[2] = TextReplaceBetween(exTextUpdatedPtr,
TextFormat("%s, last time updated with raylib %s", info->verCreated, info->verUpdated), "* Example originally created with raylib ", "\n");
exTextUpdated[2] = TextReplaceBetween(exTextUpdatedPtr, "* Example originally created with raylib ", "\n",
TextFormat("%s, last time updated with raylib %s", info->verCreated, info->verUpdated));
if (exTextUpdated[2] != NULL) exTextUpdatedPtr = exTextUpdated[2];
// Update copyright message
// String: "* Copyright (c) 2019-2025 Contributor Name (@github_user) and Ramon Santamaria (@raysan5)"
if (info->yearCreated == info->yearReviewed)
{
exTextUpdated[3] = TextReplaceBetween(exTextUpdatedPtr,
TextFormat("%i %s (@%s", info->yearCreated, info->author, info->authorGitHub), "Copyright (c) ", ")");
exTextUpdated[3] = TextReplaceBetween(exTextUpdatedPtr, "Copyright (c) ", ")",
TextFormat("%i %s (@%s", info->yearCreated, info->author, info->authorGitHub));
if (exTextUpdated[3] != NULL) exTextUpdatedPtr = exTextUpdated[3];
}
else
{
exTextUpdated[3] = TextReplaceBetween(exTextUpdatedPtr,
TextFormat("%i-%i %s (@%s", info->yearCreated, info->yearReviewed, info->author, info->authorGitHub), "Copyright (c) ", ")");
exTextUpdated[3] = TextReplaceBetween(exTextUpdatedPtr, "Copyright (c) ", ")",
TextFormat("%i-%i %s (@%s", info->yearCreated, info->yearReviewed, info->author, info->authorGitHub));
if (exTextUpdated[3] != NULL) exTextUpdatedPtr = exTextUpdated[3];
}
// Update window title
// String: "InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing");"
exTextUpdated[4] = TextReplaceBetween(exTextUpdated[3],
TextFormat("raylib [%s] example - %s", info->category, exNameFormated), "InitWindow(screenWidth, screenHeight, \"", "\");");
exTextUpdated[4] = TextReplaceBetween(exTextUpdated[3], "InitWindow(screenWidth, screenHeight, \"", "\");",
TextFormat("raylib [%s] example - %s", info->category, exNameFormated));
if (exTextUpdated[4] != NULL) exTextUpdatedPtr = exTextUpdated[4];
// Update contributors names
// String: "* Example contributed by Contributor Name (@github_user) and reviewed by Ramon Santamaria (@raysan5)"
// WARNING: Not all examples are contributed by someone, so the result of this replace can be NULL (string not found)
exTextUpdated[5] = TextReplaceBetween(exTextUpdatedPtr,
TextFormat("%s (@%s", info->author, info->authorGitHub), "* Example contributed by ", ")");
exTextUpdated[5] = TextReplaceBetween(exTextUpdatedPtr, "* Example contributed by ", ")",
TextFormat("%s (@%s", info->author, info->authorGitHub));
if (exTextUpdated[5] != NULL) exTextUpdatedPtr = exTextUpdated[5];
if (exTextUpdatedPtr != NULL) SaveFileText(exSourcePath, exTextUpdatedPtr);
@ -2464,7 +2476,7 @@ static char *GetTextBetween(const char *text, const char *begin, const char *end
// Replace text between two specific strings
// WARNING: Returned string must be freed by user
static char *TextReplaceBetween(const char *text, const char *replace, const char *begin, const char *end)
static char *TextReplaceBetween(const char *text, const char *begin, const char *end, const char *replace)
{
char *result = NULL;
int beginIndex = TextFindIndex(text, begin);