4 Commits

Author SHA1 Message Date
Ray
aa475b1046 REVIEWED: Code sections description for consistency 2025-09-02 12:34:04 +02:00
Ray
8b3c68f8b5 Update core_random_sequence.c 2025-09-02 12:18:19 +02:00
Ray
8f32c502a7 REVIEWED: Code sections definition 2025-09-02 12:10:40 +02:00
Ray
b6ae380260 REVIEWED: Examples comments, consistent code sections 2025-09-02 12:10:16 +02:00
44 changed files with 192 additions and 173 deletions

View File

@ -19,7 +19,9 @@
#include "raymath.h"
// Sound positioning function
//------------------------------------------------------------------------------------
// Module Functions Declaration
//------------------------------------------------------------------------------------
static void SetSoundPosition(Camera listener, Sound sound, Vector3 position, float maxDist);
//------------------------------------------------------------------------------------
@ -94,7 +96,10 @@ int main(void)
//--------------------------------------------------------------------------------------
}
// Sound positioning function
//------------------------------------------------------------------------------------
// Module Functions Definition
//------------------------------------------------------------------------------------
// Set sound 3d position
static void SetSoundPosition(Camera listener, Sound sound, Vector3 position, float maxDist)
{
// Calculate direction vector and distance between listener and sound source

View File

@ -17,7 +17,9 @@
#include <stdlib.h> // Required for: NULL
// Required delay effect variables
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
static float *delayBuffer = NULL;
static unsigned int delayBufferSize = 0;
static unsigned int delayReadIndex = 2;

View File

@ -22,6 +22,9 @@
#define PLAYER_JUMP_SPD 350.0f
#define PLAYER_HOR_SPD 200.0f
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef struct Player {
Vector2 position;
float speed;
@ -35,7 +38,7 @@ typedef struct EnvItem {
} EnvItem;
//----------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//----------------------------------------------------------------------------------
void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float delta);
void UpdateCameraCenter(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);

View File

@ -64,7 +64,7 @@ static float headLerp = STAND_HEIGHT;
static Vector2 lean = { 0 };
//----------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//----------------------------------------------------------------------------------
static void DrawLevel(void);
static void UpdateCameraFPS(Camera *camera);
@ -172,9 +172,10 @@ int main(void)
}
//----------------------------------------------------------------------------------
// Module functions definition
// Module Functions Definition
//----------------------------------------------------------------------------------
void UpdateBody(Body* body, float rot, char side, char forward, bool jumpPressed, bool crouchHold)
// Update body considering current world state
void UpdateBody(Body *body, float rot, char side, char forward, bool jumpPressed, bool crouchHold)
{
Vector2 input = (Vector2){ (float)side, (float)-forward };
@ -236,7 +237,7 @@ void UpdateBody(Body* body, float rot, char side, char forward, bool jumpPressed
}
}
// Update camera
// Update camera for FPS behaviour
static void UpdateCameraFPS(Camera *camera)
{
const Vector3 up = (Vector3){ 0.0f, 1.0f, 0.0f };

View File

@ -32,7 +32,7 @@ const int screenWidth = 800;
const int screenHeight = 450;
//----------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//----------------------------------------------------------------------------------
void UpdateDrawFrame(void); // Update and Draw one frame

View File

@ -14,7 +14,7 @@
#include "raylib.h"
//------------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//------------------------------------------------------------------------------------
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color);
@ -120,7 +120,7 @@ int main(void)
}
//------------------------------------------------------------------------------------
// Module functions definition
// Module Functions Definition
//------------------------------------------------------------------------------------
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color)
{

View File

@ -20,16 +20,18 @@
// WARNING: This example does not build on Windows with MSVC compiler
#include "pthread.h" // POSIX style threads management
#include <stdatomic.h> // C11 atomic data types
#include <stdatomic.h> // Required for: C11 atomic data types
#include <time.h> // Required for: clock()
// Using C11 atomics for synchronization
// NOTE: A plain bool (or any plain data type for that matter) can't be used for inter-thread synchronization
static atomic_bool dataLoaded = false; // Data Loaded completion indicator
static void *LoadDataThread(void *arg); // Loading data thread function declaration
static atomic_bool dataLoaded = false; // Data Loaded completion indicator
static atomic_int dataProgress = 0; // Data progress accumulator
static atomic_int dataProgress = 0; // Data progress accumulator
//------------------------------------------------------------------------------------
// Module Functions Declaration
//------------------------------------------------------------------------------------
static void *LoadDataThread(void *arg); // Loading data thread function declaration
//------------------------------------------------------------------------------------
// Program main entry point
@ -134,6 +136,9 @@ int main(void)
return 0;
}
//------------------------------------------------------------------------------------
// Module Functions Definition
//------------------------------------------------------------------------------------
// Loading data thread function definition
static void *LoadDataThread(void *arg)
{

View File

@ -18,20 +18,22 @@
#include "raylib.h"
#include "raymath.h"
#include <stdlib.h> // Required for: malloc() and free()
#include <stdlib.h> // Required for: malloc(), free()
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef struct ColorRect {
Color c;
Rectangle r;
Color color;
Rectangle rect;
} ColorRect;
//------------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//------------------------------------------------------------------------------------
static Color GenerateRandomColor();
static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight);
static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount);
static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, int posY, int fontSize, Color color);
//------------------------------------------------------------------------------------
// Program main entry point
@ -63,7 +65,9 @@ int main(void)
{
rectCount++;
rectSize = (float)screenWidth/rectCount;
free(rectangles);
RL_FREE(rectangles);
// Re-generate random sequence with new count
rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f*screenHeight);
}
@ -73,7 +77,9 @@ int main(void)
{
rectCount--;
rectSize = (float)screenWidth/rectCount;
free(rectangles);
RL_FREE(rectangles);
// Re-generate random sequence with new count
rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f*screenHeight);
}
}
@ -85,20 +91,20 @@ int main(void)
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);
DrawRectangleRec(rectangles[i].rect, rectangles[i].color);
DrawText("Press SPACE to shuffle the sequence", 10, screenHeight - 96, 20, BLACK);
DrawText("Press SPACE to shuffle the current sequence", 10, screenHeight - 96, 20, BLACK);
DrawText("Press UP to add a rectangle and generate a new sequence", 10, screenHeight - 64, 20, BLACK);
DrawText("Press DOWN to remove a rectangle and generate a new sequence", 10, screenHeight - 32, 20, BLACK);
}
const char *rectCountText = TextFormat("%d rectangles", rectCount);
int rectCountTextSize = MeasureText(rectCountText, fontSize);
DrawText(rectCountText, screenWidth - rectCountTextSize - 10, 10, fontSize, BLACK);
DrawText(TextFormat("Count: %d rectangles", rectCount), 10, 10, 20, MAROON);
DrawFPS(10, 10);
DrawFPS(screenWidth - 80, 10);
EndDrawing();
//----------------------------------------------------------------------------------
@ -114,7 +120,7 @@ int main(void)
}
//------------------------------------------------------------------------------------
// Module functions definition
// Module Functions Definition
//------------------------------------------------------------------------------------
static Color GenerateRandomColor()
{
@ -130,7 +136,8 @@ static Color GenerateRandomColor()
static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight)
{
ColorRect *rectangles = (ColorRect *)malloc((int)rectCount*sizeof(ColorRect));
ColorRect *rectangles = (ColorRect *)RL_CALLOC((int)rectCount, sizeof(ColorRect));
int *seq = LoadRandomSequence((unsigned int)rectCount, 0, (unsigned int)rectCount - 1);
float rectSeqWidth = rectCount*rectWidth;
float startX = (screenWidth - rectSeqWidth)*0.5f;
@ -139,8 +146,8 @@ static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWid
{
int rectHeight = (int)Remap((float)seq[i], 0, rectCount - 1, 0, screenHeight);
rectangles[i].c = GenerateRandomColor();
rectangles[i].r = CLITERAL(Rectangle){ startX + i*rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight };
rectangles[i].color = GenerateRandomColor();
rectangles[i].rect = CLITERAL(Rectangle){ startX + i*rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight };
}
UnloadRandomSequence(seq);
@ -159,28 +166,13 @@ static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount)
// Swap only the color and height
ColorRect tmp = *r1;
r1->c = r2->c;
r1->r.height = r2->r.height;
r1->r.y = r2->r.y;
r2->c = tmp.c;
r2->r.height = tmp.r.height;
r2->r.y = tmp.r.y;
r1->color = r2->color;
r1->rect.height = r2->rect.height;
r1->rect.y = r2->rect.y;
r2->color = tmp.color;
r2->rect.height = tmp.rect.height;
r2->rect.y = tmp.rect.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 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);
}

View File

@ -128,9 +128,8 @@ int main(void)
}
//--------------------------------------------------------------------------------------------
// Module Functions Definitions (local)
// Module Functions Definition
//--------------------------------------------------------------------------------------------
// Draw sphere without any matrix transformation
// NOTE: Sphere is drawn in world position ( 0, 0, 0 ) with radius 1.0f
void DrawSphereBasic(Color color)

View File

@ -109,7 +109,7 @@ void UpdateLightValues(Shader shader, Light light); // Send light proper
static int lightsCount = 0; // Current amount of created lights
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
// ...

View File

@ -77,7 +77,7 @@
#define DARKGRAY (Color){ 80, 80, 80, 255 } // Dark Gray
//----------------------------------------------------------------------------------
// Structures Definition
// Types and Structures Definition
//----------------------------------------------------------------------------------
// Color, 4 components, R8G8B8A8 (32bit)
typedef struct Color {
@ -97,7 +97,7 @@ typedef struct Camera {
} Camera;
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Functions Declaration
//----------------------------------------------------------------------------------
static void ErrorCallback(int error, const char *description);
static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods);
@ -260,7 +260,7 @@ int main(void)
}
//----------------------------------------------------------------------------------
// Module specific Functions Definitions
// Module Functions Definitions
//----------------------------------------------------------------------------------
// GLFW3: Error callback

View File

@ -109,7 +109,7 @@ void UpdateLightValues(Shader shader, Light light); // Send light proper
static int lightsCount = 0; // Current amount of created lights
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
// ...

View File

@ -34,7 +34,6 @@
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
// Light type
typedef enum {
LIGHT_DIRECTIONAL = 0,
@ -66,7 +65,7 @@ typedef struct {
static int lightCount = 0; // Current number of dynamic lights that have been created
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Functions Declaration
//----------------------------------------------------------------------------------
// Create a light and get shader locations
static Light CreateLight(int type, Vector3 position, Vector3 target, Color color, float intensity, Shader shader);
@ -76,7 +75,7 @@ static Light CreateLight(int type, Vector3 position, Vector3 target, Color color
static void UpdateLight(Shader shader, Light light);
//----------------------------------------------------------------------------------
// Main Entry Point
// Program main entry point
//----------------------------------------------------------------------------------
int main()
{
@ -231,9 +230,9 @@ int main()
Vector4 floorEmissiveColor = ColorNormalize(floor.materials[0].maps[MATERIAL_MAP_EMISSION].color);
SetShaderValue(shader, emissiveColorLoc, &floorEmissiveColor, SHADER_UNIFORM_VEC4);
// Set floor metallic and roughness values
SetShaderValue(shader, metallicValueLoc, &floor.materials[0].maps[MATERIAL_MAP_METALNESS].value, SHADER_UNIFORM_FLOAT);
SetShaderValue(shader, roughnessValueLoc, &floor.materials[0].maps[MATERIAL_MAP_ROUGHNESS].value, SHADER_UNIFORM_FLOAT);
// Set floor metallic and roughness values
SetShaderValue(shader, metallicValueLoc, &floor.materials[0].maps[MATERIAL_MAP_METALNESS].value, SHADER_UNIFORM_FLOAT);
SetShaderValue(shader, roughnessValueLoc, &floor.materials[0].maps[MATERIAL_MAP_ROUGHNESS].value, SHADER_UNIFORM_FLOAT);
DrawModel(floor, (Vector3){ 0.0f, 0.0f, 0.0f }, 5.0f, WHITE); // Draw floor model
@ -244,9 +243,9 @@ int main()
float emissiveIntensity = 0.01f;
SetShaderValue(shader, emissiveIntensityLoc, &emissiveIntensity, SHADER_UNIFORM_FLOAT);
// Set old car metallic and roughness values
SetShaderValue(shader, metallicValueLoc, &car.materials[0].maps[MATERIAL_MAP_METALNESS].value, SHADER_UNIFORM_FLOAT);
SetShaderValue(shader, roughnessValueLoc, &car.materials[0].maps[MATERIAL_MAP_ROUGHNESS].value, SHADER_UNIFORM_FLOAT);
// Set old car metallic and roughness values
SetShaderValue(shader, metallicValueLoc, &car.materials[0].maps[MATERIAL_MAP_METALNESS].value, SHADER_UNIFORM_FLOAT);
SetShaderValue(shader, roughnessValueLoc, &car.materials[0].maps[MATERIAL_MAP_ROUGHNESS].value, SHADER_UNIFORM_FLOAT);
DrawModel(car, (Vector3){ 0.0f, 0.0f, 0.0f }, 0.25f, WHITE); // Draw car model
@ -293,6 +292,9 @@ int main()
return 0;
}
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
// Create light with provided data
// NOTE: It updated the global lightCount and it's limited to MAX_LIGHTS
static Light CreateLight(int type, Vector3 position, Vector3 target, Color color, float intensity, Shader shader)

View File

@ -16,32 +16,35 @@
********************************************************************************************/
#include "raylib.h"
#include "rlgl.h"
#include "math.h" // Used for tan()
#include "raymath.h" // Used to calculate camera Direction
#include "raymath.h"
#include <math.h> // Required for: tanf()
#if defined(PLATFORM_DESKTOP)
#define GLSL_VERSION 330
#define GLSL_VERSION 330
#else // PLATFORM_ANDROID, PLATFORM_WEB
#define GLSL_VERSION 100
#define GLSL_VERSION 100
#endif
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef struct {
unsigned int camPos;
unsigned int camDir;
unsigned int screenCenter;
} RayLocs;
//------------------------------------------------------------------------------------
// Declare custom functions required for the example
// Module Functions Declaration
//------------------------------------------------------------------------------------
// Load custom render texture, create a writable depth texture buffer
static RenderTexture2D LoadRenderTextureDepthTex(int width, int height);
// Unload render texture from GPU memory (VRAM)
static void UnloadRenderTextureDepthTex(RenderTexture2D target);
//------------------------------------------------------------------------------------
// Declare custom Structs
//------------------------------------------------------------------------------------
typedef struct {
unsigned int camPos, camDir, screenCenter;
}RayLocs ;
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
@ -153,10 +156,10 @@ int main(void)
}
//------------------------------------------------------------------------------------
// Define custom functions required for the example
// Module Functions Definition
//------------------------------------------------------------------------------------
// Load custom render texture, create a writable depth texture buffer
RenderTexture2D LoadRenderTextureDepthTex(int width, int height)
static RenderTexture2D LoadRenderTextureDepthTex(int width, int height)
{
RenderTexture2D target = { 0 };
@ -195,7 +198,7 @@ RenderTexture2D LoadRenderTextureDepthTex(int width, int height)
}
// Unload render texture from GPU memory (VRAM)
void UnloadRenderTextureDepthTex(RenderTexture2D target)
static void UnloadRenderTextureDepthTex(RenderTexture2D target)
{
if (target.id > 0)
{

View File

@ -23,9 +23,9 @@
#define GLSL_VERSION 100
#endif
//------------------------------------------------------------------------------------
// Structs definition
//------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
// Rounded rectangle data
typedef struct {
Vector4 cornerRadius; // Individual corner radius (top-left, top-right, bottom-left, bottom-right)

View File

@ -43,6 +43,9 @@
#define MAX_SPOTS 3 // NOTE: It must be the same as define in shader
#define MAX_STARS 400
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
// Spot data
typedef struct Spot {
Vector2 position;
@ -62,6 +65,9 @@ typedef struct Star {
Vector2 speed;
} Star;
//--------------------------------------------------------------------------------------
// Module Functions Declaration
//--------------------------------------------------------------------------------------
static void UpdateStar(Star *s);
static void ResetStar(Star *s);

View File

@ -25,9 +25,9 @@
#define GLSL_VERSION 100
#endif
//------------------------------------------------------------------------------------
// Declare custom functions required for the example
//------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
// Module Functions Declaration
//--------------------------------------------------------------------------------------
// Load custom render texture, create a writable depth texture buffer
static RenderTexture2D LoadRenderTextureDepthTex(int width, int height);
@ -109,9 +109,10 @@ int main(void)
return 0;
}
//------------------------------------------------------------------------------------
// Define custom functions required for the example
//------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
// Module Functions Definition
//--------------------------------------------------------------------------------------
// Load custom render texture, create a writable depth texture buffer
RenderTexture2D LoadRenderTextureDepthTex(int width, int height)
{

View File

@ -1480,7 +1480,7 @@ static void DrawRectangleGradientV(int posX, int posY, int width, int height, Co
#endif // RAYGUI_STANDALONE
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize); // Load style from memory (binary only)
@ -4479,7 +4479,7 @@ void GuiSetIconScale(int scale)
#endif // !RAYGUI_NO_ICONS
//----------------------------------------------------------------------------------
// Module specific Functions Definition
// Module Internal Functions Definition
//----------------------------------------------------------------------------------
// Load style from memory

View File

@ -128,7 +128,6 @@ int main(void)
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
// Update clock time
static void UpdateClock(Clock *clock)
{

View File

@ -19,9 +19,6 @@
#include <math.h> // Required for: sin(), cos(), PI
//----------------------------------------------------------------------------------
// Macro Helpers
//----------------------------------------------------------------------------------
// Constant for Simulation
#define SIMULATION_STEPS 30
#define G 9.81
@ -156,13 +153,16 @@ int main(void)
return 0;
}
// Calculate Pendulum End Point
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
// Calculate pendulum end point
static Vector2 CalculatePendulumEndPoint(float l, float theta)
{
return (Vector2){ 10*l*sin(theta), 10*l*cos(theta) };
}
// Calculate Double Pendulum End Point
// Calculate double pendulum end point
static Vector2 CalculateDoublePendulumEndPoint(float l1, float theta1, float l2, float theta2)
{
Vector2 endpoint1 = CalculatePendulumEndPoint(l1, theta1);

View File

@ -21,6 +21,9 @@
#include <math.h>
//--------------------------------------------------------------------------------------
// Module Functions Declaration
//--------------------------------------------------------------------------------------
// Draw rectangle with rounded edges and horizontal gradient, with options to choose side of roundness
static void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float roundnessRight, int segments, Color left, Color right);
@ -83,6 +86,9 @@ int main(void)
return 0;
}
//--------------------------------------------------------------------------------------
// Module Functions Definition
//--------------------------------------------------------------------------------------
// 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)

View File

@ -41,7 +41,7 @@
#endif
//--------------------------------------------------------------------------------------
// Globals
// Global variables
//--------------------------------------------------------------------------------------
#define LETTER_BOUNDRY_SIZE 0.25f
#define TEXT_MAX_LAYERS 32
@ -51,7 +51,7 @@ bool SHOW_LETTER_BOUNDRY = false;
bool SHOW_TEXT_BOUNDRY = false;
//--------------------------------------------------------------------------------------
// Data Types definition
// Types and Structures Definition
//--------------------------------------------------------------------------------------
// Configuration structure for waving the text
typedef struct WaveTextConfig {

View File

@ -18,7 +18,7 @@
#include "raylib.h"
//----------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//----------------------------------------------------------------------------------
// Draw text using font inside rectangle limits
static void DrawTextBoxed(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint);
@ -135,7 +135,7 @@ tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet ris
}
//--------------------------------------------------------------------------------------
// Module functions definition
// Module Functions Definition
//--------------------------------------------------------------------------------------
// Draw text using font inside rectangle limits

View File

@ -24,6 +24,18 @@
#define EMOJI_PER_WIDTH 8
#define EMOJI_PER_HEIGHT 4
//--------------------------------------------------------------------------------------
// Global variables
//--------------------------------------------------------------------------------------
// Arrays that holds the random emojis
struct {
int index; // Index inside `emojiCodepoints`
int message; // Message index
Color color; // Emoji color
} emoji[EMOJI_PER_WIDTH*EMOJI_PER_HEIGHT] = { 0 };
static int hovered = -1, selected = -1;
// String containing 180 emoji codepoints separated by a '\0' char
const char *const emojiCodepoints = "\xF0\x9F\x8C\x80\x00\xF0\x9F\x98\x80\x00\xF0\x9F\x98\x82\x00\xF0\x9F\xA4\xA3\x00\xF0\x9F\x98\x83\x00\xF0\x9F\x98\x86\x00\xF0\x9F\x98\x89\x00"
"\xF0\x9F\x98\x8B\x00\xF0\x9F\x98\x8E\x00\xF0\x9F\x98\x8D\x00\xF0\x9F\x98\x98\x00\xF0\x9F\x98\x97\x00\xF0\x9F\x98\x99\x00\xF0\x9F\x98\x9A\x00\xF0\x9F\x99\x82\x00"
@ -133,25 +145,13 @@ struct {
};
//--------------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//--------------------------------------------------------------------------------------
static void RandomizeEmoji(void); // Fills the emoji array with random emojis
static void DrawTextBoxed(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits
static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint); // Draw text using font inside rectangle limits with support for text selection
//--------------------------------------------------------------------------------------
// Global variables
//--------------------------------------------------------------------------------------
// Arrays that holds the random emojis
struct {
int index; // Index inside `emojiCodepoints`
int message; // Message index
Color color; // Emoji color
} emoji[EMOJI_PER_WIDTH*EMOJI_PER_HEIGHT] = { 0 };
static int hovered = -1, selected = -1;
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
@ -329,7 +329,7 @@ static void RandomizeEmoji(void)
}
//--------------------------------------------------------------------------------------
// Module functions definition
// Module Functions Definition
//--------------------------------------------------------------------------------------
// Draw text using font inside rectangle limits

View File

@ -19,17 +19,20 @@
#include <stdlib.h>
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef struct {
int* data;
int *data;
int count;
int capacity;
} CodepointsArray;
//--------------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//--------------------------------------------------------------------------------------
static void AddRange(CodepointsArray* array, int start, int stop);
static Font LoadUnicodeFont(const char* fileName, int fontSize);
static void AddCodepointRange(CodepointsArray* array, int start, int stop);
//static Font LoadUnicodeFont(const char* fileName, int fontSize);
//------------------------------------------------------------------------------------
// Program main entry point
@ -95,7 +98,7 @@ int main(void)
}
//--------------------------------------------------------------------------------------
// Module functions definition
// Module Functions Definition
//--------------------------------------------------------------------------------------
static void AddRange(CodepointsArray* array, int start, int stop)
{

View File

@ -20,7 +20,7 @@
#include "raylib.h"
//------------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//------------------------------------------------------------------------------------
static void NormalizeKernel(float *kernel, int size);
@ -131,7 +131,7 @@ int main(void)
}
//------------------------------------------------------------------------------------
// Module functions definition
// Module Functions Definition
//------------------------------------------------------------------------------------
static void NormalizeKernel(float *kernel, int size)
{

View File

@ -155,7 +155,6 @@ int main()
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
// Draw textured curve using Spline Cubic Bezier
static void DrawTexturedCurve(void)
{

View File

@ -31,7 +31,7 @@ int screenHeight = 450;
void UpdateDrawFrame(void); // Update and Draw one frame
//----------------------------------------------------------------------------------
// Main Entry Point
// Program main entry point
//----------------------------------------------------------------------------------
int main()
{

View File

@ -26,18 +26,18 @@
#endif
//----------------------------------------------------------------------------------
// Local Variables Definition (local to this module)
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
Camera camera = { 0 };
Vector3 cubePosition = { 0 };
//----------------------------------------------------------------------------------
// Local Functions Declaration
// Module Functions Declaration
//----------------------------------------------------------------------------------
static void UpdateDrawFrame(void); // Update and draw one frame
//----------------------------------------------------------------------------------
// Main entry point
// Program main entry point
//----------------------------------------------------------------------------------
int main()
{

View File

@ -156,13 +156,13 @@ static uint32_t rprand_state[4] = { // Xoshiro128** state, initializ
};
//----------------------------------------------------------------------------------
// Module internal functions declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
static uint32_t rprand_xoshiro(void); // Xoshiro128** generator (uses global rprand_state)
static uint64_t rprand_splitmix64(void); // SplitMix64 generator (uses seed to generate rprand_state)
//----------------------------------------------------------------------------------
// Module functions definition
// Module Functions Definition
//----------------------------------------------------------------------------------
// Set rprand_state for Xoshiro128**
// NOTE: We use a custom generation algorithm using SplitMix64
@ -236,7 +236,7 @@ void rprand_unload_sequence(int *sequence)
}
//----------------------------------------------------------------------------------
// Module internal functions definition
// Module Internal Functions Definition
//----------------------------------------------------------------------------------
static inline uint32_t rprand_rotate_left(const uint32_t x, int k)
{

View File

@ -111,7 +111,7 @@ extern CoreData CORE; // Global CORE state context
static PlatformData platform = { 0 }; // Platform specific data
//----------------------------------------------------------------------------------
// Local Variables Definition
// Global Variables Definition
//----------------------------------------------------------------------------------
#define SCANCODE_MAPPED_NUM 232
static const KeyboardKey mapScancodeToKey[SCANCODE_MAPPED_NUM] = {

View File

@ -156,7 +156,7 @@ extern CoreData CORE; // Global CORE state context
static PlatformData platform = { 0 }; // Platform specific data
//----------------------------------------------------------------------------------
// Local Variables Definition
// Global Variables Definition
//----------------------------------------------------------------------------------
// NOTE: The complete evdev EV_KEY list can be found at /usr/include/linux/input-event-codes.h

View File

@ -86,7 +86,7 @@ extern CoreData CORE; // Global CORE state context
static PlatformData platform = { 0 }; // Platform specific data
//----------------------------------------------------------------------------------
// Local Variables Definition
// Global Variables Definition
//----------------------------------------------------------------------------------
static const char cursorLUT[11][12] = {
"default", // 0 MOUSE_CURSOR_DEFAULT

View File

@ -407,7 +407,7 @@ static AudioData AUDIO = { // Global AUDIO context
};
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
static void OnLog(void *pUserData, ma_uint32 level, const char *pMessage);
@ -2352,9 +2352,8 @@ void DetachAudioMixedProcessor(AudioCallback process)
}
//----------------------------------------------------------------------------------
// Module specific Functions Definition
// Module Internal Functions Definition
//----------------------------------------------------------------------------------
// Log callback function
static void OnLog(void *pUserData, ma_uint32 level, const char *pMessage)
{

View File

@ -115,7 +115,7 @@
#endif
//----------------------------------------------------------------------------------
// Some basic Defines
// Defines and Macros
//----------------------------------------------------------------------------------
#ifndef PI
#define PI 3.14159265358979323846f
@ -201,7 +201,7 @@
#define RAYWHITE CLITERAL(Color){ 245, 245, 245, 255 } // My own White (raylib logo)
//----------------------------------------------------------------------------------
// Structures Definition
// Types and Structures Definition
//----------------------------------------------------------------------------------
// Boolean type
#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800)

View File

@ -216,7 +216,7 @@ RLAPI Matrix GetCameraProjectionMatrix(Camera *camera, float aspect);
//...
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
//...

View File

@ -238,7 +238,7 @@ static GesturesData GESTURES = {
};
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
static float rgVector2Angle(Vector2 initialPosition, Vector2 finalPosition);
static float rgVector2Distance(Vector2 v1, Vector2 v2);
@ -481,7 +481,7 @@ float GetGesturePinchAngle(void)
}
//----------------------------------------------------------------------------------
// Module specific Functions Definition
// Module Internal Functions Definition
//----------------------------------------------------------------------------------
// Get angle from two-points vector with X-axis
static float rgVector2Angle(Vector2 v1, Vector2 v2)

View File

@ -1039,7 +1039,7 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad
#endif
//----------------------------------------------------------------------------------
// Types and Structures Definition
// Module Types and Structures Definition
//----------------------------------------------------------------------------------
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
@ -1145,7 +1145,7 @@ static PFNGLVERTEXATTRIBDIVISOREXTPROC glVertexAttribDivisor = NULL;
#endif
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Functions Declaration
//----------------------------------------------------------------------------------
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
static void rlLoadShaderDefault(void); // Load default shader
@ -4864,7 +4864,7 @@ const char *rlGetPixelFormatName(unsigned int format)
}
//----------------------------------------------------------------------------------
// Module specific Functions Definition
// Module Functions Definition
//----------------------------------------------------------------------------------
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
// Load default shader (just vertex positioning and texture coloring)

View File

@ -144,7 +144,7 @@
// ...
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_OBJ)
static Model LoadOBJ(const char *fileName); // Load OBJ mesh data
@ -171,7 +171,6 @@ static void ProcessMaterialsOBJ(Material *rayMaterials, tinyobj_material_t *mate
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
// Draw a line in 3D world space
void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
{
@ -4244,7 +4243,7 @@ RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Ve
}
//----------------------------------------------------------------------------------
// Module specific Functions Definition
// Module Internal Functions Definition
//----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_IQM) || defined(SUPPORT_FILEFORMAT_GLTF)
// Build pose from parent joints

View File

@ -83,14 +83,13 @@ static Texture2D texShapes = { 1, 1, 1, 1, 7 }; // Texture used o
static Rectangle texShapesRec = { 0.0f, 0.0f, 1.0f, 1.0f }; // Texture source rectangle used on shapes drawing
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
static float EaseCubicInOut(float t, float b, float c, float d); // Cubic easing
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
// Set texture and rectangle to be used on shapes drawing
// NOTE: It can be useful when using basic shapes and one single font,
// defining a font char white rectangle would allow drawing everything in a single draw call
@ -2371,7 +2370,7 @@ bool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshol
}
// Check if circle collides with a line created between two points [p1] and [p2]
RLAPI bool CheckCollisionCircleLine(Vector2 center, float radius, Vector2 p1, Vector2 p2)
bool CheckCollisionCircleLine(Vector2 center, float radius, Vector2 p1, Vector2 p2)
{
float dx = p1.x - p2.x;
float dy = p1.y - p2.y;
@ -2420,7 +2419,7 @@ Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
}
//----------------------------------------------------------------------------------
// Module specific Functions Definition
// Module Internal Functions Definition
//----------------------------------------------------------------------------------
// Cubic easing in-out

View File

@ -141,7 +141,7 @@ static int textLineSpacing = 2; // Text vertical line spacing in
//...
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_FNT)
static Font LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file)
@ -2197,7 +2197,7 @@ int GetCodepointPrevious(const char *text, int *codepointSize)
}
//----------------------------------------------------------------------------------
// Module specific Functions Definition
// Module Internal Functions Definition
//----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_FNT) || defined(SUPPORT_FILEFORMAT_BDF)
// Read a line from memory
@ -2380,11 +2380,9 @@ static Font LoadBMFont(const char *fileName)
return font;
}
#endif
#if defined(SUPPORT_FILEFORMAT_BDF)
// Convert hexadecimal to decimal (single digit)
static unsigned char HexToInt(char hex)
{

View File

@ -258,7 +258,7 @@
extern void LoadFontDefault(void); // [Module: text] Loads default font, required by ImageDrawText()
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
static float HalfToFloat(unsigned short x);
static unsigned short FloatToHalf(float x);
@ -267,7 +267,6 @@ static Vector4 *LoadImageDataNormalized(Image image); // Load pixel data f
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
// Load image from file into CPU memory (RAM)
Image LoadImage(const char *fileName)
{
@ -5406,7 +5405,7 @@ int GetPixelDataSize(int width, int height, int format)
}
//----------------------------------------------------------------------------------
// Module specific Functions Definition
// Module Internal Functions Definition
//----------------------------------------------------------------------------------
// Convert half-float (stored as unsigned short) to float
// REF: https://stackoverflow.com/questions/1659440/32-bit-to-16-bit-floating-point-conversion/60047308#60047308

View File

@ -82,7 +82,7 @@ static const char *internalDataPath = NULL; // Android internal data pat
#endif
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
FILE *funopen(const void *cookie, int (*readfn)(void *, char *, int), int (*writefn)(void *, const char *, int),
@ -482,7 +482,7 @@ FILE *android_fopen(const char *fileName, const char *mode)
#endif // PLATFORM_ANDROID
//----------------------------------------------------------------------------------
// Module specific Functions Definition
// Module Internal Functions Definition
//----------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
static int android_read(void *cookie, char *data, int dataSize)

View File

@ -129,7 +129,7 @@ static const char *exCollectionFilePath = NULL; // Env: REXM_EXAMPLES_COLLECTION
static const char *exVSProjectSolutionFile = NULL; // Env REXM_EXAMPLES_VS2022_SLN_FILE
//----------------------------------------------------------------------------------
// Module specific functions declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
static int FileTextFind(const char *fileName, const char *find);
static int FileTextReplace(const char *fileName, const char *find, const char *replace);
@ -1283,9 +1283,8 @@ int main(int argc, char *argv[])
}
//----------------------------------------------------------------------------------
// Module specific functions definition
// Module Internal Functions Definition
//----------------------------------------------------------------------------------
// Update required files from examples collection
static int UpdateRequiredFiles(void)
{
@ -1772,7 +1771,7 @@ static int FileMove(const char *srcPath, const char *dstPath)
// Get example info from example file header
// NOTE: Expecting the example to follow raylib_example_template.c
rlExampleInfo *LoadExampleInfo(const char *exFileName)
static rlExampleInfo *LoadExampleInfo(const char *exFileName)
{
rlExampleInfo *exInfo = (rlExampleInfo *)RL_CALLOC(1, sizeof(rlExampleInfo));