11 Commits

27 changed files with 262 additions and 127 deletions

View File

@ -58,7 +58,7 @@ Examples using raylib[core](../src/rcore.c) platform functionality like window c
| [core_smooth_pixelperfect](core/core_smooth_pixelperfect.c) | <img src="core/core_smooth_pixelperfect.png" alt="core_smooth_pixelperfect" width="80"> | ⭐⭐⭐☆ | 3.7 | 4.0 | [Giancamillo Alessandroni](https://github.com/NotManyIdeasDev) |
| [core_random_sequence](core/core_random_sequence.c) | <img src="core/core_random_sequence.png" alt="core_random_sequence" width="80"> | ⭐☆☆☆ | 5.0 | 5.0 | [Dalton Overmyer](https://github.com/REDl3east) |
| [core_automation_events](core/core_automation_events.c) | <img src="core/core_automation_events.png" alt="core_automation_events" width="80"> | ⭐⭐⭐☆ | 5.0 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_high_dpi](core/core_high_dpi.c) | <img src="core/core_high_dpi.png" alt="core_high_dpi" width="80"> | ⭐☆☆ | 5.0 | 5.0 | [Jonathan Marler](https://github.com/marler8997) |
| [core_high_dpi](core/core_high_dpi.c) | <img src="core/core_high_dpi.png" alt="core_high_dpi" width="80"> | ⭐☆☆ | 5.0 | 5.5 | [Jonathan Marler](https://github.com/marler8997) |
### category: shapes [20]
@ -84,7 +84,7 @@ Examples using raylib shapes drawing functionality, provided by raylib [shapes](
| [shapes_top_down_lights](shapes/shapes_top_down_lights.c) | <img src="shapes/shapes_top_down_lights.png" alt="shapes_top_down_lights" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 4.2 | [Jeffery Myers](https://github.com/JeffM2501) |
| [shapes_rectangle_advanced](shapes/shapes_rectangle_advanced.c) | <img src="shapes/shapes_rectangle_advanced.png" alt="shapes_rectangle_advanced" width="80"> | ⭐⭐⭐⭐️ | 5.5 | 5.5 | [Everton Jr.](https://github.com/evertonse) |
| [shapes_splines_drawing](shapes/shapes_splines_drawing.c) | <img src="shapes/shapes_splines_drawing.png" alt="shapes_splines_drawing" width="80"> | ⭐⭐⭐☆ | 5.0 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_digital_clock](shapes/shapes_digital_clock.c) | <img src="shapes/shapes_digital_clock.png" alt="shapes_digital_clock" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [Hamza RAHAL](https://github.com/rhmz-rhl) |
| [shapes_digital_clock](shapes/shapes_digital_clock.c) | <img src="shapes/shapes_digital_clock.png" alt="shapes_digital_clock" width="80"> | ⭐⭐☆☆ | 5.5 | 5.6 | [Hamza RAHAL](https://github.com/hmz-rhl) |
| [shapes_double_pendulum](shapes/shapes_double_pendulum.c) | <img src="shapes/shapes_double_pendulum.png" alt="shapes_double_pendulum" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [JoeCheong](https://github.com/Joecheong2006) |
### category: textures [26]
@ -157,7 +157,7 @@ Examples using raylib models functionality, including models loading/generation
| [models_loading](models/models_loading.c) | <img src="models/models_loading.png" alt="models_loading" width="80"> | ⭐☆☆☆ | 2.0 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_loading_gltf](models/models_loading_gltf.c) | <img src="models/models_loading_gltf.png" alt="models_loading_gltf" width="80"> | ⭐☆☆☆ | 3.7 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_loading_vox](models/models_loading_vox.c) | <img src="models/models_loading_vox.png" alt="models_loading_vox" width="80"> | ⭐☆☆☆ | 4.0 | 4.0 | [Johann Nadalutti](https://github.com/procfxgen) |
| [models_loading_m3d](models/models_loading_m3d.c) | <img src="models/models_loading_m3d.png" alt="models_loading_m3d" width="80"> | ⭐⭐☆☆ | 4.5 | 4.5 | [bzt](https://github.com/model3d) |
| [models_loading_m3d](models/models_loading_m3d.c) | <img src="models/models_loading_m3d.png" alt="models_loading_m3d" width="80"> | ⭐⭐☆☆ | 4.5 | 4.5 | [bzt](https://github.com/bztsrc) |
| [models_orthographic_projection](models/models_orthographic_projection.c) | <img src="models/models_orthographic_projection.png" alt="models_orthographic_projection" width="80"> | ⭐☆☆☆ | 2.0 | 3.7 | [Max Danielsson](https://github.com/autious) |
| [models_point_rendering](models/models_point_rendering.c) | <img src="models/models_point_rendering.png" alt="models_point_rendering" width="80"> | ⭐⭐⭐☆ | 5.0 | 5.0 | [Reese Gallagher](https://github.com/satchelfrost) |
| [models_rlgl_solar_system](models/models_rlgl_solar_system.c) | <img src="models/models_rlgl_solar_system.png" alt="models_rlgl_solar_system" width="80"> | ⭐⭐⭐⭐️ | 2.5 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
@ -184,7 +184,7 @@ Examples using raylib shaders functionality, including shaders loading, paramete
| [shaders_palette_switch](shaders/shaders_palette_switch.c) | <img src="shaders/shaders_palette_switch.png" alt="shaders_palette_switch" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.7 | [Marco Lizza](https://github.com/MarcoLizza) |
| [shaders_raymarching](shaders/shaders_raymarching.c) | <img src="shaders/shaders_raymarching.png" alt="shaders_raymarching" width="80"> | ⭐⭐⭐⭐️ | 2.0 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [shaders_texture_rendering](shaders/shaders_texture_rendering.c) | <img src="shaders/shaders_texture_rendering.png" alt="shaders_texture_rendering" width="80"> | ⭐⭐☆☆ | 2.0 | 3.7 | [Michał Ciesielski](https://github.com/ciessielski) |
| [shaders_texture_outline](shaders/shaders_texture_outline.c) | <img src="shaders/shaders_texture_outline.png" alt="shaders_texture_outline" width="80"> | ⭐⭐⭐☆ | 4.0 | 4.0 | [Samuel Skiff](https://github.com/GoldenThumbs) |
| [shaders_texture_outline](shaders/shaders_texture_outline.c) | <img src="shaders/shaders_texture_outline.png" alt="shaders_texture_outline" width="80"> | ⭐⭐⭐☆ | 4.0 | 4.0 | [Serenity Skiff](https://github.com/GoldenThumbs) |
| [shaders_texture_waves](shaders/shaders_texture_waves.c) | <img src="shaders/shaders_texture_waves.png" alt="shaders_texture_waves" width="80"> | ⭐⭐☆☆ | 2.5 | 3.7 | [Anata](https://github.com/anatagawa) |
| [shaders_julia_set](shaders/shaders_julia_set.c) | <img src="shaders/shaders_julia_set.png" alt="shaders_julia_set" width="80"> | ⭐⭐⭐☆ | 2.5 | 4.0 | [Josh Colclough](https://github.com/joshcol9232) |
| [shaders_eratosthenes](shaders/shaders_eratosthenes.c) | <img src="shaders/shaders_eratosthenes.png" alt="shaders_eratosthenes" width="80"> | ⭐⭐⭐☆ | 2.5 | 4.0 | [ProfJski](https://github.com/ProfJski) |

View File

@ -1,10 +1,10 @@
/*******************************************************************************************
*
* raylib [audio] example - music playing (streaming)
* raylib [audio] example - music streaming
*
* Example complexity rating: [★☆☆☆] 1/4
*
* Example originally created with raylib 1.3, last time updated with raylib 4.0
* Example originally created with raylib 1.3, last time updated with raylib 4.2
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
@ -25,7 +25,7 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)");
InitWindow(screenWidth, screenHeight, "raylib [audio] example - music streaming");
InitAudioDevice(); // Initialize audio device

View File

@ -2,12 +2,16 @@
*
* raylib [core] example - high dpi
*
* Example complexity rating: [★☆☆] e/4
* Example complexity rating: [★☆☆] 2/4
*
* Example originally created with raylib 5.0, last time updated with raylib 5.5
*
* Example contributed by Jonathan Marler (@marler8997) and reviewed by Ramon Santamaria (@raysan5)
*
* 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) 2013-2025 Ramon Santamaria (@raysan5)
* Copyright (c) 2025 Jonathan Marler (@marler8997)
*
********************************************************************************************/

View File

@ -2,14 +2,12 @@
*
* raylib [core] example - input virtual controls
*
* Example complexity rating: [★★☆] 3/4
* Example complexity rating: [★★☆] 3/4
*
* Example originally created with raylib 5.0, last time updated with raylib 5.0
*
* Example create by GreenSnakeLinux (@GreenSnakeLinux),
* lighter by oblerion (@oblerion) and
* reviewed by Ramon Santamaria (@raysan5) and
* improved by danilwhale (@danilwhale)
* Example contributed by GreenSnakeLinux (@GreenSnakeLinux),
* reviewed by Ramon Santamaria (@raysan5), oblerion (@oblerion) and danilwhale (@danilwhale)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
@ -19,6 +17,7 @@
********************************************************************************************/
#include "raylib.h"
#include <math.h>
typedef enum {
@ -45,24 +44,21 @@ int main(void)
Vector2 padPosition = { 100, 350 };
float buttonRadius = 30;
Vector2 buttonPositions[BUTTON_MAX] =
{
Vector2 buttonPositions[BUTTON_MAX] = {
{ padPosition.x,padPosition.y - buttonRadius*1.5f }, // Up
{ padPosition.x - buttonRadius*1.5f, padPosition.y }, // Left
{ padPosition.x + buttonRadius*1.5f, padPosition.y }, // Right
{ padPosition.x, padPosition.y + buttonRadius*1.5f } // Down
};
const char *buttonLabels[BUTTON_MAX] =
{
const char *buttonLabels[BUTTON_MAX] = {
"Y", // Up
"X", // Left
"B", // Right
"A" // Down
};
Color buttonLabelColors[BUTTON_MAX] =
{
Color buttonLabelColors[BUTTON_MAX] = {
YELLOW, // Up
BLUE, // Left
RED, // Right
@ -83,22 +79,15 @@ int main(void)
{
// Update
//--------------------------------------------------------------------------
if ((GetTouchPointCount() > 0))
{
// Use touch position
inputPosition = GetTouchPosition(0);
}
else
{
// Use mouse position
inputPosition = GetMousePosition();
}
if ((GetTouchPointCount() > 0)) inputPosition = GetTouchPosition(0); // Use touch position
else inputPosition = GetMousePosition(); // Use mouse position
// Reset pressed button to none
pressedButton = BUTTON_NONE;
// Make sure user is pressing left mouse button if they're from desktop
if ((GetTouchPointCount() > 0) || ((GetTouchPointCount() == 0) && IsMouseButtonDown(MOUSE_BUTTON_LEFT)))
if ((GetTouchPointCount() > 0) ||
((GetTouchPointCount() == 0) && IsMouseButtonDown(MOUSE_BUTTON_LEFT)))
{
// Find nearest D-Pad button to the input position
for (int i = 0; i < BUTTON_MAX; i++)
@ -123,8 +112,8 @@ int main(void)
case BUTTON_DOWN: playerPosition.y += playerSpeed*GetFrameTime(); break;
default: break;
};
//--------------------------------------------------------------------------
// Draw
//--------------------------------------------------------------------------
BeginDrawing();
@ -157,4 +146,3 @@ int main(void)
return 0;
}

View File

@ -41,7 +41,7 @@ core;core_custom_frame_control;⭐️⭐️⭐️⭐️;4.0;4.0;"Ramon Santamari
core;core_smooth_pixelperfect;⭐️⭐️⭐️☆;3.7;4.0;"Giancamillo Alessandroni";@NotManyIdeasDev
core;core_random_sequence;⭐️☆☆☆;5.0;5.0;"Dalton Overmyer";@REDl3east
core;core_automation_events;⭐️⭐️⭐️☆;5.0;5.0;"Ramon Santamaria";@raysan5
core;core_high_dpi;⭐️☆☆;5.0;5.0;"Jonathan Marler";@marler8997
core;core_high_dpi;⭐️⭐️☆☆;5.0;5.5;"Jonathan Marler";@marler8997
shapes;shapes_basic_shapes;⭐️☆☆☆;1.0;4.2;"Ramon Santamaria";@raysan5
shapes;shapes_bouncing_ball;⭐️☆☆☆;2.5;2.5;"Ramon Santamaria";@raysan5
shapes;shapes_colors_palette;⭐️⭐️☆☆;1.0;2.5;"Ramon Santamaria";@raysan5
@ -60,7 +60,7 @@ shapes;shapes_draw_rectangle_rounded;⭐️⭐️⭐️☆;2.5;2.5;"Vlad Adrian"
shapes;shapes_top_down_lights;⭐️⭐️⭐️⭐️;4.2;4.2;"Jeffery Myers";@JeffM2501
shapes;shapes_rectangle_advanced;⭐️⭐️⭐️⭐️;5.5;5.5;"Everton Jr.";@evertonse
shapes;shapes_splines_drawing;⭐️⭐️⭐️☆;5.0;5.0;"Ramon Santamaria";@raysan5
shapes;shapes_digital_clock;⭐️⭐️☆☆;5.5;5.5;"Hamza RAHAL";@rhmz-rhl
shapes;shapes_digital_clock;⭐️⭐️☆☆;5.5;5.6;"Hamza RAHAL";@hmz-rhl
shapes;shapes_double_pendulum;⭐️⭐️☆☆;5.5;5.5;"JoeCheong";@Joecheong2006
textures;textures_logo_raylib;⭐️☆☆☆;1.0;1.0;"Ramon Santamaria";@raysan5
textures;textures_srcrec_dstrec;⭐️⭐️⭐️☆;1.3;1.3;"Ramon Santamaria";@raysan5
@ -112,7 +112,7 @@ models;models_mesh_picking;⭐️⭐️⭐️☆;1.7;4.0;"Joel Davis";@joeld42
models;models_loading;⭐️☆☆☆;2.0;4.2;"Ramon Santamaria";@raysan5
models;models_loading_gltf;⭐️☆☆☆;3.7;4.2;"Ramon Santamaria";@raysan5
models;models_loading_vox;⭐️☆☆☆;4.0;4.0;"Johann Nadalutti";@procfxgen
models;models_loading_m3d;⭐️⭐️☆☆;4.5;4.5;"bzt";@model3d
models;models_loading_m3d;⭐️⭐️☆☆;4.5;4.5;"bzt";@bztsrc
models;models_orthographic_projection;⭐️☆☆☆;2.0;3.7;"Max Danielsson";@autious
models;models_point_rendering;⭐️⭐️⭐️☆;5.0;5.0;"Reese Gallagher";@satchelfrost
models;models_rlgl_solar_system;⭐️⭐️⭐️⭐️;2.5;4.0;"Ramon Santamaria";@raysan5
@ -132,7 +132,7 @@ shaders;shaders_postprocessing;⭐️⭐️⭐️☆;1.3;4.0;"Ramon Santamaria";
shaders;shaders_palette_switch;⭐️⭐️⭐️☆;2.5;3.7;"Marco Lizza";@MarcoLizza
shaders;shaders_raymarching;⭐️⭐️⭐️⭐️;2.0;4.2;"Ramon Santamaria";@raysan5
shaders;shaders_texture_rendering;⭐️⭐️☆☆;2.0;3.7;"Michał Ciesielski";@ciessielski
shaders;shaders_texture_outline;⭐️⭐️⭐️☆;4.0;4.0;"Samuel Skiff";@GoldenThumbs
shaders;shaders_texture_outline;⭐️⭐️⭐️☆;4.0;4.0;"Serenity Skiff";@GoldenThumbs
shaders;shaders_texture_waves;⭐️⭐️☆☆;2.5;3.7;"Anata";@anatagawa
shaders;shaders_julia_set;⭐️⭐️⭐️☆;2.5;4.0;"Josh Colclough";@joshcol9232
shaders;shaders_eratosthenes;⭐️⭐️⭐️☆;2.5;4.0;"ProfJski";@ProfJski

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [models] example - model loading m3d
* raylib [models] example - models loading m3d
*
* Example complexity rating: [★★☆☆] 2/4
*
@ -31,7 +31,7 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - model loading m3d");
InitWindow(screenWidth, screenHeight, "raylib [models] example - models loading m3d");
// Define the camera to look into our 3d world
Camera camera = { 0 };

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [easings] example - easings testbed
* raylib [others] example - easings testbed
*
* Example originally created with raylib 2.5, last time updated with raylib 2.5
*
@ -108,7 +108,7 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [easings] example - easings testbed");
InitWindow(screenWidth, screenHeight, "raylib [others] example - easings testbed");
Vector2 ballPosition = { 100.0f, 100.0f };

View File

@ -4,7 +4,7 @@
*
* Example complexity rating: [★★★★] 4/4
*
* Example originally created with raylib 3.8, last time updated with raylib 2.5
* Example originally created with raylib 3.8, last time updated with raylib 4.0
*
* Example contributed by Stephan Soller (@arkanis) and reviewed by Ramon Santamaria (@raysan5)
*

View File

@ -0,0 +1,14 @@
#version 120
// Input uniform values
uniform vec4 color;
// NOTE: Add your custom variables here
void main()
{
// Each point is drawn as a screen space square of gl_PointSize size. gl_PointCoord contains where we are inside of
// it. (0, 0) is the top left, (1, 1) the bottom right corner
// Draw each point as a colored circle with alpha 1.0 in the center and 0.0 at the outer edges
gl_FragColor = vec4(color.rgb, color.a*(1.0 - length(gl_PointCoord.xy - vec2(0.5))*2.0));
}

View File

@ -0,0 +1,24 @@
#version 120
// Input vertex attributes
attribute vec3 vertexPosition;
// Input uniform values
uniform mat4 mvp;
uniform float currentTime;
// NOTE: Add your custom variables here
void main()
{
// Unpack data from vertexPosition
vec2 pos = vertexPosition.xy;
float period = vertexPosition.z;
// Calculate final vertex position (jiggle it around a bit horizontally)
pos += vec2(100.0, 0.0)*sin(period*currentTime);
gl_Position = mvp*vec4(pos.x, pos.y, 0.0, 1.0);
// Calculate the screen space size of this particle (also vary it over time)
gl_PointSize = 10.0 - 5.0*abs(sin(period*currentTime));
}

View File

@ -1,13 +1,13 @@
/*******************************************************************************************
*
* raylib [rlgl] example - compute shader - game of life
* raylib [others] example - compute shader - game of life
*
* NOTE: This example requires raylib OpenGL 4.3 versions for compute shaders support,
* shaders used in this example are #version 430 (OpenGL 4.3)
*
* Example complexity rating: [★★★★] 4/4
*
* Example originally created with raylib 4.0, last time updated with raylib 2.5
* Example originally created with raylib 4.0, last time updated with raylib 4.0
*
* Example contributed by Teddy Astie (@tsnake41) and reviewed by Ramon Santamaria (@raysan5)
*
@ -57,7 +57,7 @@ int main(void)
const int screenWidth = GOL_WIDTH;
const int screenHeight = GOL_WIDTH;
InitWindow(screenWidth, screenHeight, "raylib [rlgl] example - compute shader - game of life");
InitWindow(screenWidth, screenHeight, "raylib [others] example - compute shader - game of life");
const Vector2 resolution = { screenWidth, screenHeight };
unsigned int brushSize = 8;

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [rlgl] example - Using rlgl module as standalone module
* raylib [others] example - Using rlgl module as standalone module
*
* rlgl library is an abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, ES 2.0)
* that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...)
@ -147,7 +147,7 @@ int main(void)
glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE );
#endif
GLFWwindow *window = glfwCreateWindow(screenWidth, screenHeight, "rlgl standalone", NULL, NULL);
GLFWwindow *window = glfwCreateWindow(screenWidth, screenHeight, "raylib [others] example - rlgl standalone", NULL, NULL);
if (!window)
{

View File

@ -9,12 +9,12 @@
*
* Example originally created with raylib 4.0, last time updated with raylib 4.0
*
* Example contributed by Samuel Skiff (@GoldenThumbs) and reviewed by Ramon Santamaria (@raysan5)
* Example contributed by Serenity Skiff (@GoldenThumbs) and reviewed by Ramon Santamaria (@raysan5)
*
* 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) 2021-2025 Samuel SKiff (@GoldenThumbs) and Ramon Santamaria (@raysan5)
* Copyright (c) 2021-2025 Serenity Skiff (@GoldenThumbs) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/

View File

@ -4,7 +4,7 @@
*
* Example complexity rating: [★★☆☆] 2/4
*
* Example originally created with raylib 5.5, last time updated with raylib 5.5
* Example originally created with raylib 5.5, last time updated with raylib 5.6-dev
*
* Example contributed by Hamza RAHAL (@hmz-rhl) and reviewed by Ramon Santamaria (@raysan5)
*

View File

@ -0,0 +1,18 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
void main()
{
vec4 texelColor = texture2D(texture0, fragTexCoord);
if (texelColor.a == 0.0) discard;
gl_FragColor = texelColor*fragColor*colDiffuse;
}

View File

@ -0,0 +1,23 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add your custom variables here
const float smoothing = 1.0/16.0;
void main()
{
// Texel color fetching from texture sampler
// NOTE: Calculate alpha using signed distance field (SDF)
float distance = texture2D(texture0, fragTexCoord).a;
float alpha = smoothstep(0.5 - smoothing, 0.5 + smoothing, distance);
// Calculate final fragment color
gl_FragColor = vec4(fragColor.rgb, fragColor.a*alpha);
}

View File

@ -4,7 +4,7 @@
*
* Example complexity rating: [★★★☆] 3/4
*
* Example originally created with raylib 4.2, last time updated with raylib 2.5
* Example originally created with raylib 4.2, last time updated with raylib 4.2
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software

View File

@ -4,7 +4,7 @@
*
* Example complexity rating: [★★★★] 4/4
*
* Example originally created with raylib 2.5, last time updated with raylib 4.0
* Example originally created with raylib 5.5, last time updated with raylib 5.6
*
* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5)
*
@ -17,7 +17,7 @@
#include "raylib.h"
#include <stdlib.h>
#include <stdlib.h> // Required for: calloc(), free()
//--------------------------------------------------------------------------------------
// Module Functions Declaration
@ -199,5 +199,6 @@ static void AddCodepointRange(Font *font, const char *fontPath, int start, int s
UnloadFont(*font);
*font = LoadFontEx(fontPath, 32, updatedCodepoints, updatedCodepointCount);
RL_FREE(updatedCodepoints);
}

View File

@ -1507,7 +1507,7 @@ RLAPI const char *CodepointToUTF8(int codepoint, int *utf8Size);
// WARNING 1: Most of these functions use internal static buffers, it's recommended to store returned data on user-side for re-use
// WARNING 2: Some strings allocate memory internally for the returned strings, those strings must be free by user using MemFree()
RLAPI char **LoadTextLines(const char *text, int *count); // Load text as separate lines ('\n')
RLAPI void UnloadTextLines(char **text); // Unload text lines
RLAPI void UnloadTextLines(char **text, int lineCount); // Unload text lines
RLAPI int TextCopy(char *dst, const char *src); // Copy one string to another, returns bytes copied
RLAPI bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal
RLAPI unsigned int TextLength(const char *text); // Get text length, checks for '\0' ending

View File

@ -1448,36 +1448,39 @@ Rectangle GetGlyphAtlasRec(Font font, int codepoint)
// Text strings management functions
//----------------------------------------------------------------------------------
// Load text as separate lines ('\n')
// WARNING: There is a limit set for number of lines and line-size
// NOTE: Returned lines end with null terminator '\0'
char **LoadTextLines(const char *text, int *count)
{
#define MAX_TEXTLINES_COUNT 512
#define MAX_TEXTLINES_LINE_LEN 512
int lineCount = 1;
int textSize = strlen(text);
char **lines = (char **)RL_CALLOC(MAX_TEXTLINES_COUNT, sizeof(char *));
for (int i = 0; i < MAX_TEXTLINES_COUNT; i++) lines[i] = (char *)RL_CALLOC(MAX_TEXTLINES_LINE_LEN, 1);
int textSize = (int)strlen(text);
int k = 0;
for (int i = 0, len = 0; (i < textSize) && (k < MAX_TEXTLINES_COUNT); i++)
// Text pass to get required line count
for (int i = 0; i < textSize; i++)
{
if ((text[i] == '\n') || (len == (MAX_TEXTLINES_LINE_LEN - 1)))
{
strncpy(lines[k], &text[i - len], len);
len = 0;
k++;
}
else len++;
if (text[i] == '\n') lineCount++;
}
*count += k;
char **lines = (char **)RL_CALLOC(lineCount, sizeof(char *));
for (int i = 0, l = 0, lineLen = 0; i <= textSize; i++)
{
if ((text[i] == '\n') || (text[i] == '\0'))
{
lines[l] = (char *)RL_CALLOC(lineLen + 1, 1);
strncpy(lines[l], &text[i - lineLen], lineLen);
lineLen = 0;
l++;
}
else lineLen++;
}
*count = lineCount;
return lines;
}
// Unload text lines
void UnloadTextLines(char **lines)
void UnloadTextLines(char **lines, int lineCount)
{
for (int i = 0; i < MAX_TEXTLINES_COUNT; i++) RL_FREE(lines[i]);
for (int i = 0; i < lineCount; i++) RL_FREE(lines[i]);
RL_FREE(lines);
}

View File

@ -9632,6 +9632,10 @@
{
"type": "char **",
"name": "text"
},
{
"type": "int",
"name": "lineCount"
}
]
},

View File

@ -6860,7 +6860,8 @@ return {
description = "Unload text lines",
returnType = "void",
params = {
{type = "char **", name = "text"}
{type = "char **", name = "text"},
{type = "int", name = "lineCount"}
}
},
{

View File

@ -3681,11 +3681,12 @@ Function 425: LoadTextLines() (2 input parameters)
Description: Load text as separate lines ('\n')
Param[1]: text (type: const char *)
Param[2]: count (type: int *)
Function 426: UnloadTextLines() (1 input parameters)
Function 426: UnloadTextLines() (2 input parameters)
Name: UnloadTextLines
Return type: void
Description: Unload text lines
Param[1]: text (type: char **)
Param[2]: lineCount (type: int)
Function 427: TextCopy() (2 input parameters)
Name: TextCopy
Return type: int

View File

@ -2440,8 +2440,9 @@
<Param type="const char *" name="text" desc="" />
<Param type="int *" name="count" desc="" />
</Function>
<Function name="UnloadTextLines" retType="void" paramCount="1" desc="Unload text lines">
<Function name="UnloadTextLines" retType="void" paramCount="2" desc="Unload text lines">
<Param type="char **" name="text" desc="" />
<Param type="int" name="lineCount" desc="" />
</Function>
<Function name="TextCopy" retType="int" paramCount="2" desc="Copy one string to another, returns bytes copied">
<Param type="char *" name="dst" desc="" />

View File

@ -28,7 +28,7 @@ Example elements validated:
| core_input_multitouch | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| core_input_gestures | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| core_input_gestures_testbed | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| core_input_virtual_controls | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| core_input_virtual_controls | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| core_2d_camera | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| core_2d_camera_mouse_zoom | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| core_2d_camera_platformer | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
@ -54,7 +54,7 @@ Example elements validated:
| core_smooth_pixelperfect | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| core_random_sequence | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| core_automation_events | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| core_high_dpi | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| core_high_dpi | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shapes_basic_shapes | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shapes_bouncing_ball | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shapes_colors_palette | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
@ -73,7 +73,7 @@ Example elements validated:
| shapes_top_down_lights | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shapes_rectangle_advanced | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shapes_splines_drawing | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shapes_digital_clock | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shapes_digital_clock | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shapes_double_pendulum | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| textures_logo_raylib | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| textures_srcrec_dstrec | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
@ -105,15 +105,15 @@ Example elements validated:
| text_font_spritefont | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_font_filters | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_font_loading | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_font_sdf | ✔ | ✔ | ✔ | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_font_sdf | ✔ | ✔ | ✔ | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_format_text | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_input_box | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_writing_anim | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_rectangle_bounds | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_unicode_emojis | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_unicode_ranges | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_3d_drawing | ✔ | ✔ | ✔ | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_codepoints_loading | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_unicode_ranges | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_3d_drawing | ✔ | ✔ | ✔ | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_codepoints_loading | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_animation | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_billboard_rendering | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_box_collisions | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
@ -125,7 +125,7 @@ Example elements validated:
| models_loading | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_loading_gltf | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_loading_vox | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_loading_m3d | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_loading_m3d | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_orthographic_projection | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_point_rendering | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_rlgl_solar_system | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
@ -145,7 +145,7 @@ Example elements validated:
| shaders_palette_switch | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_raymarching | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_texture_rendering | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_texture_outline | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_texture_outline | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_texture_waves | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_julia_set | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_eratosthenes | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
@ -167,7 +167,7 @@ Example elements validated:
| shaders_rounded_rectangle | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_view_depth | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| audio_module_playing | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| audio_music_stream | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| audio_music_stream | ✔ | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| audio_raw_stream | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| audio_sound_loading | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| audio_mixed_processor | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
@ -177,6 +177,6 @@ Example elements validated:
| rlgl_standalone | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| rlgl_compute_shader | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| easings_testbed | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| raylib_opengl_interop | ✔ | ❌ | ❌ | ✔ | ✔ | | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ |
| raylib_opengl_interop | ✔ | ❌ | ❌ | ✔ | ✔ | | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ |
| embedded_files_loading | ✔ | ❌ | ❌ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| raymath_vector_angle | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ |

View File

@ -20,19 +20,9 @@ Example elements validated:
```
| **EXAMPLE NAME** | [C] | [CAT]| [INFO]|[PNG]|[WPNG]| [RES]| [MK] |[MKWEB]| [VCX]| [SOL]|[RDME]|[JS] | [WOUT]|[WMETA]|
|:---------------------------------|:---:|:----:|:-----:|:---:|:----:|:----:|:----:|:-----:|:----:|:----:|:----:|:---:|:-----:|:-----:|
| core_input_virtual_controls | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| core_high_dpi | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shapes_digital_clock | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_font_sdf | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_unicode_ranges | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_3d_drawing | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_codepoints_loading | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_loading_m3d | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| shaders_texture_outline | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| audio_music_stream | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| rlgl_standalone | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| rlgl_compute_shader | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| easings_testbed | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| raylib_opengl_interop | ✔ | ❌ | ❌ | ✔ | ✔ | | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ |
| raylib_opengl_interop | ✔ | ❌ | ❌ | ✔ | ✔ | | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ |
| embedded_files_loading | ✔ | ❌ | ❌ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| raymath_vector_angle | ✔ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ |

View File

@ -167,8 +167,8 @@ static char **ScanExampleResources(const char *filePath, int *resPathCount);
static void ClearExampleResources(char **resPaths);
// Add/remove VS project (.vcxproj) tofrom existing VS solution (.sln)
static int AddVSProjectToSolution(const char *projFile, const char *slnFile, const char *category);
//static int RemoveVSProjectFromSolution(const char *projFile, const char *slnFile, const char *category);
static int AddVSProjectToSolution(const char *slnFile, const char *projFile, const char *category);
static int RemoveVSProjectFromSolution(const char *slnFile, const char *exName);
// Generate unique UUID v4 string
// Output format: {9A2F48CC-0DA8-47C0-884E-02E37F9BE6C1}
@ -563,8 +563,8 @@ int main(int argc, char *argv[])
// Edit: raylib/projects/VS2022/raylib.sln --> Add new example project
// WARNING: This function uses TextFormat() extensively inside,
// we must store provided file paths because pointers will be overwriten
AddVSProjectToSolution(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName),
exVSProjectSolutionFile, exCategory);
AddVSProjectToSolution(exVSProjectSolutionFile,
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName), exCategory);
//------------------------------------------------------------------------------------------------
// Recompile example (on raylib side)
@ -639,7 +639,7 @@ int main(int argc, char *argv[])
FileTextReplace(exCollectionFilePath, TextFormat("%s;%s", exCategory, exName),
TextFormat("%s;%s", exRecategory, exRename));
// TODO: Move example resources from <src_category>/resources to <dst_category>/resources
// TODO: Move example resources from <exCategory>/resources to <exRecategory>/resources
// WARNING: Resources can be shared with other examples in the category
// Edit: Rename example code file (copy and remove)
@ -684,7 +684,8 @@ int main(int argc, char *argv[])
FileCopy(TextFormat("%s/%s/%s.js", exBasePath, exRecategory, exRename),
TextFormat("%s/%s/%s.js", exWebPath, exRecategory, exRename));
// Create commit with changes (local)
/*
// Create GitHub commit with changes (local)
putenv("PATH=%PATH%;C:\\Program Files\\Git\\bin");
ChangeDirectory("C:\\GitHub\\raylib");
system("git --version");
@ -696,9 +697,9 @@ int main(int argc, char *argv[])
system("git add -A");
result = system(TextFormat("git commit -m \"REXM: RENAME: example: `%s` --> `%s`\"", exName, exRename)); // Commit changes (only tracked files)
if (result != 0) LOG("WARNING: Error committing changes\n");
//result = system("git push"); // Push to the remote (origin, current branch)
//if (result != 0) LOG("WARNING: Error pushing changes\n");
*/
} break;
case OP_REMOVE: // Remove
@ -770,11 +771,7 @@ int main(int argc, char *argv[])
FileRemove(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName));
// Edit: raylib/projects/VS2022/raylib.sln --> Remove example project
//---------------------------------------------------------------------------
// TODO: Remove project from solution
//RemoveVSProjectFromSolution(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName),
// TextFormat("%s/../projects/VS2022/raylib.sln", exBasePath));
//---------------------------------------------------------------------------
RemoveVSProjectFromSolution(TextFormat("%s/../projects/VS2022/raylib.sln", exBasePath), exName);
// Remove: raylib.com/examples/<category>/<category>_example_name.html
// Remove: raylib.com/examples/<category>/<category>_example_name.data
@ -819,6 +816,22 @@ int main(int argc, char *argv[])
int exListLen = (int)strlen(exList);
strcpy(exListUpdated, exList);
// Copy examples list into an update list
// NOTE: Checking and removing duplicate entries
int lineCount = 0;
char **exListLines = LoadTextLines(exList, &lineCount);
int exListUpdatedOffset = 0;
exListUpdatedOffset = sprintf(exListUpdated, "%s\n", exListLines[0]);
for (int i = 1; i < lineCount; i++)
{
if ((TextFindIndex(exListUpdated, exListLines[i]) == -1) || (exListLines[i][0] == '#'))
exListUpdatedOffset += sprintf(exListUpdated + exListUpdatedOffset, "%s\n", exListLines[i]);
else listUpdated = true;
}
UnloadTextLines(exListLines, lineCount);
for (unsigned int i = 0; i < list.count; i++)
{
if ((strcmp("examples_template", GetFileNameWithoutExt(list.paths[i])) != 0) && // HACK: Skip "examples_template"
@ -859,8 +872,6 @@ int main(int argc, char *argv[])
int exCollectionCount = 0;
rlExampleInfo *exCollection = LoadExamplesData(exCollectionFilePath, "ALL", false, &exCollectionCount);
// TODO: Validate: Check duplicate entries in collection list?
// Set status information for all examples, using "status" field in the struct
for (int i = 0; i < exCollectionCount; i++)
{
@ -984,7 +995,10 @@ int main(int argc, char *argv[])
(strcmp(exInfo->authorGitHub, exInfoHeader->authorGitHub) != 0) ||
(exInfo->stars != exInfoHeader->stars) ||
(exInfo->verCreated != exInfoHeader->verCreated) ||
(exInfo->verUpdated != exInfoHeader->verUpdated)) exInfo->status |= VALID_INCONSISTENT_INFO;
(exInfo->verUpdated != exInfoHeader->verUpdated))
{
exInfo->status |= VALID_INCONSISTENT_INFO;
}
UnloadExampleInfo(exInfoHeader);
}
@ -1033,8 +1047,8 @@ int main(int argc, char *argv[])
// Add project (.vcxproj) to raylib solution (.sln)
if (exInfo->status & VALID_NOT_IN_VCXSOL)
{
AddVSProjectToSolution(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exInfo->name),
exVSProjectSolutionFile, exInfo->category);
AddVSProjectToSolution(exVSProjectSolutionFile,
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exInfo->name), exInfo->category);
exInfo->status &= ~VALID_NOT_IN_VCXSOL;
}
@ -1677,7 +1691,7 @@ static rlExampleInfo *LoadExamplesData(const char *fileName, const char *categor
}
}
UnloadTextLines(lines);
UnloadTextLines(lines, lineCount);
UnloadFileText(text);
}
@ -1961,7 +1975,8 @@ static char **ScanExampleResources(const char *filePath, int *resPathCount)
if (code != NULL)
{
// Resources extensions to check
const char *exts[] = { ".png", ".bmp", ".jpg", ".qoi", ".gif", ".raw", ".hdr", ".ttf", ".fnt", ".wav", ".ogg", ".mp3", ".flac", ".mod", ".qoa", ".qoa", ".obj", ".iqm", ".glb", ".m3d", ".vox", ".vs", ".fs", ".txt" };
const char *exts[] = { ".png", ".bmp", ".jpg", ".qoi", ".gif", ".raw", ".hdr", ".ttf", ".fnt",
".wav", ".ogg", ".mp3", ".flac", ".mod", ".qoa", ".qoa", ".obj", ".iqm", ".glb", ".m3d", ".vox", ".vs", ".fs", ".txt" };
const int extCount = sizeof(exts)/sizeof(char *);
char *ptr = code;
@ -1974,7 +1989,8 @@ static char **ScanExampleResources(const char *filePath, int *resPathCount)
// 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...
// This is a dirty solution, the good one would be getting the data loading function names...
if (TextFindIndex(ptr - 40, "ExportImage") == -1)
if ((TextFindIndex(ptr - 40, "ExportImage") == -1) &&
(TextFindIndex(ptr - 10, "TraceLog") == -1)) // Avoid TraceLog() strings processing
{
int len = (int)(end - start);
if ((len > 0) && (len < REXM_MAX_RESOURCE_PATH_LEN))
@ -1983,14 +1999,11 @@ static char **ScanExampleResources(const char *filePath, int *resPathCount)
strncpy(buffer, start, len);
buffer[len] = '\0';
// TODO: Make sure buffer is a path (and not a TraceLog() string)
// Check for known extensions
for (int i = 0; i < extCount; i++)
{
// 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
// NOTE: IsFileExtension() expects a NULL terminated fileName string,
// it looks for the last '.' and checks "extension" after that
if (IsFileExtension(buffer, exts[i]))
{
// Avoid duplicates
@ -2035,7 +2048,7 @@ static void ClearExampleResources(char **resPaths)
// - "dotnet" tool (C# projects only)
// - "devenv" tool (no adding support, only building)
// It must be done manually editing the .sln file
static int AddVSProjectToSolution(const char *projFile, const char *slnFile, const char *category)
static int AddVSProjectToSolution(const char *slnFile, const char *projFile, const char *category)
{
int result = 0;
@ -2149,6 +2162,55 @@ static int AddVSProjectToSolution(const char *projFile, const char *slnFile, con
return result;
}
// Remove VS project (.vcxproj) to existing VS solution (.sln)
static int RemoveVSProjectFromSolution(const char *slnFile, const char *exName)
{
int result = 0;
// Lines to be removed from solution file:
//Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_random_values", "examples\core_random_values.vcxproj", "{B332DCA8-3599-4A99-917A-82261BDC27AC}"
//EndProject
// All lines starting with:
//"\t\t{B332DCA8-3599-4A99-917A-82261BDC27AC}."
char *slnText = LoadFileText(slnFile);
char *slnTextUpdated = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1);
int lineCount = 0;
char **lines = LoadTextLines(slnText, &lineCount); // WARNING: Max 512 lines, we need +4000!
char uuid[38] = { 0 };
strcpy(uuid, "ABCDEF00-0123-4567-89AB-000000000012"); // Temp value
int textUpdatedOfsset = 0;
int exNameLen = strlen(exName);
for (int i = 0, index = 0; i < lineCount; i++)
{
index = TextFindIndex(lines[i], exName);
if (index > 0)
{
// Found line with project --> get UUID
strncpy(uuid, lines[i] + index + exNameLen*2 + 26, 36);
// Skip copying line and also next one
i++;
}
else
{
if (TextFindIndex(lines[i], uuid) == -1)
textUpdatedOfsset += sprintf(slnTextUpdated + textUpdatedOfsset, "%s\n", lines[i]);
}
}
SaveFileText(slnFile, slnTextUpdated);
UnloadTextLines(lines, lineCount);
UnloadFileText(slnText);
RL_FREE(slnTextUpdated);
return result;
}
// Generate unique UUID v4 string
// Output format: {9A2F48CC-0DA8-47C0-884E-02E37F9BE6C1}
static const char *GenerateUUIDv4(void)
@ -2188,6 +2250,8 @@ static void UpdateSourceMetadata(const char *exSrcPath, const rlExampleInfo *inf
char exDescription[256] = { 0 }; // Example description: example text line #3
char exTitle[64] = { 0 }; // Example title: fileName without extension, replacing underscores by spaces
// TODO: Update source code metadata
// Update example header title (line #3 - ALWAYS)
// String: "* raylib [shaders] example - texture drawing"
@ -2277,7 +2341,7 @@ static void UpdateWebMetadata(const char *exHtmlPath, const char *exFilePath)
char **lines = LoadTextLines(exText, &lineCount);
int lineLength = (int)strlen(lines[2]);
strncpy(exDescription, lines[2] + 4, lineLength - 4);
UnloadTextLines(lines);
UnloadTextLines(lines, lineCount);
UnloadFileText(exText);
// Update example.html required text
@ -2305,12 +2369,11 @@ static void UpdateWebMetadata(const char *exHtmlPath, const char *exFilePath)
}
}
// Get text between two strings
// NOTE: Using static string to return result, MAX: 1024 bytes
static char *GetTextBetween(const char *text, const char *begin, const char *end)
{
#define MAX_TEXT_BETWEEN_SIZE 1024
#define MAX_TEXT_BETWEEN_SIZE 1024
static char between[MAX_TEXT_BETWEEN_SIZE] = { 0 };
memset(between, 0, MAX_TEXT_BETWEEN_SIZE);