Compare commits

...

6 Commits

Author SHA1 Message Date
Ray
49868b356f Update examples_testing_linux.md 2025-11-19 19:41:43 +01:00
Ray
8fcd99c8dd Update textures_sprite_stacking.c 2025-11-19 19:41:39 +01:00
Ray
646e814baf Update Makefile 2025-11-19 19:41:35 +01:00
Ray
5aee9f9d50 Create examples_testing_linux.md 2025-11-19 19:31:17 +01:00
Ray
282c4b0eab Minor teaks to run on Linux 2025-11-19 19:30:25 +01:00
Ray
1f7f9ab22b Ignore examples binaries on Linux (and automated logs) 2025-11-19 19:30:07 +01:00
5 changed files with 57 additions and 37 deletions

4
.gitignore vendored
View File

@ -62,10 +62,14 @@ packages/
emsdk
# Ignore wasm data in examples/
examples/**/*
examples/**/*.wasm
examples/**/*.data
examples/**/*.js
examples/**/*.html
!examples/**/*.*
!examples/**/*/
examples/**/logs/*
# Ignore files build by xcode
*.mode*v*

View File

@ -231,7 +231,7 @@ endif
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -Wno-unused-value ignore unused return values of some functions (i.e. fread())
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result
CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wno-unused-result
ifeq ($(BUILD_MODE),DEBUG)
CFLAGS += -g -D_DEBUG

View File

@ -17,7 +17,8 @@
********************************************************************************************/
#include "raylib.h"
#include "raymath.h"
#include "raymath.h" // Required for: Clamp()
//------------------------------------------------------------------------------------
// Program main entry point
@ -33,18 +34,14 @@ int main(void)
Texture2D booth = LoadTexture("resources/booth.png");
// The overall scale of the stacked sprite
float stackScale = 3.0f;
// The vertical spacing between each layer
float stackSpacing = 2.0f;
// The number of layers. Used for calculating the size of a single slice
unsigned int stackCount = 122;
// The speed to rotate the stacked sprite
float rotationSpeed = 30.0f;
// The current rotation of the stacked sprite
float rotation = 0.0f;
// The amount that speed will change by when the user presses A/D
const float speedChange = 0.25f;
float stackScale = 3.0f; // Overall scale of the stacked sprite
float stackSpacing = 2.0f; // Vertical spacing between each layer
unsigned int stackCount = 122; // Number of layers, used for calculating the size of a single slice
float rotationSpeed = 30.0f; // Stacked sprites rotation speed
float rotation = 0.0f; // Current rotation of the stacked sprite
const float speedChange = 0.25f; // Amount speed will change by when the user presses A/D
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
@ -57,15 +54,8 @@ int main(void)
stackSpacing = Clamp(stackSpacing, 0.0f, 5.0f);
// Add a positive/negative offset to spin right/left at different speeds
if (IsKeyDown(KEY_LEFT) || IsKeyDown(KEY_A))
{
rotationSpeed -= speedChange;
}
if (IsKeyDown(KEY_RIGHT) || IsKeyDown(KEY_D))
{
rotationSpeed += speedChange;
}
if (IsKeyDown(KEY_LEFT) || IsKeyDown(KEY_A)) rotationSpeed -= speedChange;
if (IsKeyDown(KEY_RIGHT) || IsKeyDown(KEY_D)) rotationSpeed += speedChange;
rotation += rotationSpeed*GetFrameTime();
//----------------------------------------------------------------------------------
@ -73,6 +63,7 @@ int main(void)
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// Get the size of a single slice
@ -86,20 +77,19 @@ int main(void)
// Draw the stacked sprite, rotated to the correct angle, with an vertical offset applied based on its y location
for (int i = stackCount - 1; i >= 0; i--)
{
Rectangle source = { 0.0f, (float)i*frameHeight, frameWidth, frameHeight };
// Center vertically
Rectangle source = { 0.0f, (float)i*frameHeight, frameWidth, frameHeight };
Rectangle dest = { screenWidth/2.0f, (screenHeight/2.0f) + (i*stackSpacing) - (stackSpacing*stackCount/2.0f), scaledWidth, scaledHeight };
Vector2 origin = { scaledWidth/2.0f, scaledHeight/2.0f };
DrawTexturePro(booth, source, dest, origin, rotation, WHITE);
}
DrawText("a/d to spin\nmouse wheel to change separation (aka 'angle')", 10, 10, 20, DARKGRAY);
const char *spacingText = TextFormat("current spacing: %.01f", stackSpacing);
DrawText(spacingText, 10, 50, 20, DARKGRAY);
const char *speedText = TextFormat("current speed: %.02f", rotationSpeed);
DrawText(speedText, 10, 70, 20, DARKGRAY);
DrawText("A/D to spin\nmouse wheel to change separation (aka 'angle')", 10, 10, 20, DARKGRAY);
DrawText(TextFormat("current spacing: %.01f", stackSpacing), 10, 50, 20, DARKGRAY);
DrawText(TextFormat("current speed: %.02f", rotationSpeed), 10, 70, 20, DARKGRAY);
DrawText("redbooth model (c) kluchek under cc 4.0", 10, 420, 20, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}

View File

@ -0,0 +1,22 @@
# EXAMPLES COLLECTION - TESTING REPORT
## Tested Platform: Linux
```
Example automated testing elements validated:
- [CWARN] : Compilation WARNING messages
- [LWARN] : Log WARNING messages count
- [INIT] : Initialization
- [CLOSE] : Closing
- [ASSETS] : Assets loading
- [RLGL] : OpenGL-wrapped initialization
- [PLAT] : Platform initialization
- [FONT] : Font default initialization
- [TIMER] : Timer initialization
```
| **EXAMPLE NAME** | [CWARN] | [LWARN] | [INIT] | [CLOSE] | [ASSETS] | [RLGL] | [PLAT] | [FONT] | [TIMER] |
|:---------------------------------|:-------:|:-------:|:------:|:-------:|:--------:|:------:|:------:|:------:|:-------:|
| text_font_loading | 0 | 10 | âś” | âś” | âś” | âś” | âś” | âś” | âś” |
| text_codepoints_loading | 0 | 1 | âś” | âś” | âś” | âś” | âś” | âś” | âś” |
| models_animation_playing | 0 | 1 | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ |

View File

@ -51,9 +51,9 @@
#include "raylib.h"
#include <stdlib.h> // Required for: NULL, calloc(), free()
#include <stdio.h> // Required for: rename(), remove()
#include <string.h> // Required for: strcmp(), strcpy()
#include <stdlib.h> // Required for: NULL, calloc(), free()
#define SUPPORT_LOG_INFO
#if defined(SUPPORT_LOG_INFO) //&& defined(_DEBUG)
@ -1517,7 +1517,7 @@ int main(int argc, char *argv[])
TextFormat("%s/%s/%s.original.c", exBasePath, exCategory, exName));
char *srcText = LoadFileText(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName));
#define BUILD_TESTING_WEB
//#define BUILD_TESTING_WEB
#if defined(BUILD_TESTING_WEB)
static const char *mainReplaceText =
"#include <stdio.h>\n"
@ -1620,7 +1620,8 @@ int main(int argc, char *argv[])
exBasePath, exCategory, exName, exBasePath, exCategory, exName));
#else
LOG("INFO: [%s] Building example for PLATFORM_DESKTOP (Host: POSIX)\n", exName);
system(TextFormat("make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B", exBasePath, exCategory, exName));
system(TextFormat("make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B > %s/%s/logs/%s.build.log 2>&1",
exBasePath, exCategory, exName, exBasePath, exCategory, exName));
#endif
// Restore original source code before continue
FileCopy(TextFormat("%s/%s/%s.original.c", exBasePath, exCategory, exName),
@ -1630,7 +1631,7 @@ int main(int argc, char *argv[])
// STEP 3: Run example with required arguments
// NOTE: Not easy to retrieve process return value from system(), it's platform dependant
ChangeDirectory(TextFormat("%s/%s", exBasePath, exCategory));
system(TextFormat("%s --frames 2 > logs/%s.log", exName, exName));
system(TextFormat("./%s --frames 2 > logs/%s.log", exName, exName));
#endif
}
} break;
@ -1712,7 +1713,9 @@ int main(int argc, char *argv[])
char **exTestLogLines = LoadTextLines(exTestLog, &exTestLogLinesCount);
for (int k = 0; k < exTestLogLinesCount; k++)
{
if (TextFindIndex(exTestLogLines[k], "WARNING: GL: NPOT") >= 0) continue; // Ignore warning
#if defined(BUILD_TESTING_WEB)
if (TextFindIndex(exTestLogLines[k], "WARNING: GL: NPOT") >= 0) continue; // Ignore web-specific warning
#endif
if (TextFindIndex(exTestLogLines[k], "WARNING") >= 0) testing[i].warnings++;
}
UnloadTextLines(exTestLogLines, exTestLogLinesCount);
@ -1842,6 +1845,7 @@ int main(int argc, char *argv[])
printf(" rename <old_examples_name> <new_example_name> : Rename an existing example\n");
printf(" remove <example_name> : Remove an existing example\n");
printf(" build <example_name> : Build example for Desktop and Web platforms\n");
printf(" test <example_name> : Build and Test example for Desktop and Web platforms\n");
printf(" validate : Validate examples collection, generates report\n");
printf(" update : Validate and update examples collection, generates report\n\n");
printf("OPTIONS:\n\n");