Merge branch 'master' into master

This commit is contained in:
Jon Daniel 2025-09-02 23:41:37 +02:00 • committed by GitHub
commit 6ed6b19abd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
59 changed files with 525 additions and 432 deletions

View file

@ -504,10 +504,10 @@ CORE = \
core/core_2d_camera_platformer \ core/core_2d_camera_platformer \
core/core_2d_camera_split_screen \ core/core_2d_camera_split_screen \
core/core_3d_camera_first_person \ core/core_3d_camera_first_person \
core/core_3d_camera_fps \
core/core_3d_camera_free \ core/core_3d_camera_free \
core/core_3d_camera_mode \ core/core_3d_camera_mode \
core/core_3d_camera_split_screen \ core/core_3d_camera_split_screen \
core/core_3d_camera_fps \
core/core_3d_picking \ core/core_3d_picking \
core/core_automation_events \ core/core_automation_events \
core/core_basic_screen_manager \ core/core_basic_screen_manager \

View file

@ -504,10 +504,10 @@ CORE = \
core/core_2d_camera_platformer \ core/core_2d_camera_platformer \
core/core_2d_camera_split_screen \ core/core_2d_camera_split_screen \
core/core_3d_camera_first_person \ core/core_3d_camera_first_person \
core/core_3d_camera_fps \
core/core_3d_camera_free \ core/core_3d_camera_free \
core/core_3d_camera_mode \ core/core_3d_camera_mode \
core/core_3d_camera_split_screen \ core/core_3d_camera_split_screen \
core/core_3d_camera_fps \
core/core_3d_picking \ core/core_3d_picking \
core/core_automation_events \ core/core_automation_events \
core/core_basic_screen_manager \ core/core_basic_screen_manager \
@ -695,6 +695,9 @@ core/core_2d_camera_split_screen: core/core_2d_camera_split_screen.c
core/core_3d_camera_first_person: core/core_3d_camera_first_person.c core/core_3d_camera_first_person: core/core_3d_camera_first_person.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_3d_camera_fps: core/core_3d_camera_fps.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_3d_camera_free: core/core_3d_camera_free.c core/core_3d_camera_free: core/core_3d_camera_free.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@ -704,9 +707,6 @@ core/core_3d_camera_mode: core/core_3d_camera_mode.c
core/core_3d_camera_split_screen: core/core_3d_camera_split_screen.c core/core_3d_camera_split_screen: core/core_3d_camera_split_screen.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_3d_camera_fps: core/core_3d_camera_fps.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_3d_picking: core/core_3d_picking.c core/core_3d_picking: core/core_3d_picking.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)

View file

@ -19,7 +19,9 @@
#include "raymath.h" #include "raymath.h"
// Sound positioning function //------------------------------------------------------------------------------------
// Module Functions Declaration
//------------------------------------------------------------------------------------
static void SetSoundPosition(Camera listener, Sound sound, Vector3 position, float maxDist); 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) static void SetSoundPosition(Camera listener, Sound sound, Vector3 position, float maxDist)
{ {
// Calculate direction vector and distance between listener and sound source // Calculate direction vector and distance between listener and sound source

View file

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

View file

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

View file

@ -18,7 +18,6 @@
#include "raylib.h" #include "raylib.h"
#include "raymath.h" #include "raymath.h"
#include "rcamera.h"
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Defines and Macros // Defines and Macros
@ -65,10 +64,10 @@ static float headLerp = STAND_HEIGHT;
static Vector2 lean = { 0 }; static Vector2 lean = { 0 };
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module functions declaration // Module Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
static void DrawLevel(void); static void DrawLevel(void);
static void UpdateCameraAngle(Camera *camera); static void UpdateCameraFPS(Camera *camera);
static void UpdateBody(Body *body, float rot, char side, char forward, bool jumpPressed, bool crouchHold); static void UpdateBody(Body *body, float rot, char side, char forward, bool jumpPressed, bool crouchHold);
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
@ -84,7 +83,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d first-person camera controller"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d first-person camera controller");
// Initialize camera variables // Initialize camera variables
// NOTE: UpdateCameraAngle() takes care of the rest // NOTE: UpdateCameraFPS() takes care of the rest
Camera camera = { 0 }; Camera camera = { 0 };
camera.fovy = 60.0f; camera.fovy = 60.0f;
camera.projection = CAMERA_PERSPECTIVE; camera.projection = CAMERA_PERSPECTIVE;
@ -94,7 +93,7 @@ int main(void)
player.position.z, player.position.z,
}; };
UpdateCameraAngle(&camera); // Update camera parameters UpdateCameraFPS(&camera); // Update camera parameters
DisableCursor(); // Limit cursor to relative movement inside the window DisableCursor(); // Limit cursor to relative movement inside the window
@ -138,7 +137,7 @@ int main(void)
lean.x = Lerp(lean.x, sideway*0.02f, 10.0f*delta); lean.x = Lerp(lean.x, sideway*0.02f, 10.0f*delta);
lean.y = Lerp(lean.y, forward*0.015f, 10.0f*delta); lean.y = Lerp(lean.y, forward*0.015f, 10.0f*delta);
UpdateCameraAngle(&camera); UpdateCameraFPS(&camera);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -173,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 }; Vector2 input = (Vector2){ (float)side, (float)-forward };
@ -237,8 +237,8 @@ void UpdateBody(Body* body, float rot, char side, char forward, bool jumpPressed
} }
} }
// Update camera // Update camera for FPS behaviour
static void UpdateCameraAngle(Camera *camera) static void UpdateCameraFPS(Camera *camera)
{ {
const Vector3 up = (Vector3){ 0.0f, 1.0f, 0.0f }; const Vector3 up = (Vector3){ 0.0f, 1.0f, 0.0f };
const Vector3 targetOffset = (Vector3){ 0.0f, 0.0f, -1.0f }; const Vector3 targetOffset = (Vector3){ 0.0f, 0.0f, -1.0f };

View file

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

View file

@ -14,7 +14,7 @@
#include "raylib.h" #include "raylib.h"
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module functions declaration // Module Functions Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color); 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) 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 // WARNING: This example does not build on Windows with MSVC compiler
#include "pthread.h" // POSIX style threads management #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() #include <time.h> // Required for: clock()
// Using C11 atomics for synchronization // 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 // 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 atomic_bool dataLoaded = false; // Data Loaded completion indicator
static void *LoadDataThread(void *arg); // Loading data thread function declaration 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 // Program main entry point
@ -134,6 +136,9 @@ int main(void)
return 0; return 0;
} }
//------------------------------------------------------------------------------------
// Module Functions Definition
//------------------------------------------------------------------------------------
// Loading data thread function definition // Loading data thread function definition
static void *LoadDataThread(void *arg) static void *LoadDataThread(void *arg)
{ {

View file

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

@ -100,6 +100,7 @@ text;text_input_box;⭐️⭐️☆☆;1.7;3.5;"Ramon Santamaria";@raysan5
text;text_writing_anim;⭐️⭐️☆☆;1.4;1.4;"Ramon Santamaria";@raysan5 text;text_writing_anim;⭐️⭐️☆☆;1.4;1.4;"Ramon Santamaria";@raysan5
text;text_rectangle_bounds;⭐️⭐️⭐️⭐️;2.5;4.0;"Vlad Adrian";@demizdor text;text_rectangle_bounds;⭐️⭐️⭐️⭐️;2.5;4.0;"Vlad Adrian";@demizdor
text;text_unicode;⭐️⭐️⭐️⭐️;2.5;4.0;"Vlad Adrian";@demizdor text;text_unicode;⭐️⭐️⭐️⭐️;2.5;4.0;"Vlad Adrian";@demizdor
text;text_unicode_ranges;⭐️⭐️⭐️⭐️;5.5;5.6;"Vlad Adrian";@demizdor
text;text_draw_3d;⭐️⭐️⭐️⭐️;3.5;4.0;"Vlad Adrian";@demizdor text;text_draw_3d;⭐️⭐️⭐️⭐️;3.5;4.0;"Vlad Adrian";@demizdor
text;text_codepoints_loading;⭐️⭐️⭐️☆;4.2;4.2;"Ramon Santamaria";@raysan5 text;text_codepoints_loading;⭐️⭐️⭐️☆;4.2;4.2;"Ramon Santamaria";@raysan5
models;models_animation;⭐️⭐️☆☆;2.5;3.5;"Culacant";@culacant models;models_animation;⭐️⭐️☆☆;2.5;3.5;"Culacant";@culacant
@ -168,4 +169,3 @@ others;easings_testbed;⭐️⭐️⭐️☆;2.5;3.0;"Juan Miguel López";@flash
others;raylib_opengl_interop;⭐️⭐️⭐️⭐️;3.8;4.0;"Stephan Soller";@arkanis others;raylib_opengl_interop;⭐️⭐️⭐️⭐️;3.8;4.0;"Stephan Soller";@arkanis
others;embedded_files_loading;⭐️⭐️☆☆;3.0;3.5;"Kristian Holmgren";@defutura others;embedded_files_loading;⭐️⭐️☆☆;3.0;3.5;"Kristian Holmgren";@defutura
others;raymath_vector_angle;⭐️⭐️☆☆;1.0;4.6;"Ramon Santamaria";@raysan5 others;raymath_vector_angle;⭐️⭐️☆☆;1.0;4.6;"Ramon Santamaria";@raysan5
text;text_unicode_ranges;⭐⭐⭐⭐️;2.5;4.0;"Vlad Adrian";@demizdor

View file

@ -133,9 +133,8 @@ int main(void)
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
// Module Functions Definitions (local) // Module Functions Definition
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
// Draw sphere without any matrix transformation // Draw sphere without any matrix transformation
// NOTE: Sphere is drawn in world position ( 0, 0, 0 ) with radius 1.0f // NOTE: Sphere is drawn in world position ( 0, 0, 0 ) with radius 1.0f
void DrawSphereBasic(Color color) 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 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 #define DARKGRAY (Color){ 80, 80, 80, 255 } // Dark Gray
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Color, 4 components, R8G8B8A8 (32bit) // Color, 4 components, R8G8B8A8 (32bit)
typedef struct Color { typedef struct Color {
@ -97,7 +97,7 @@ typedef struct Camera {
} Camera; } Camera;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module specific Functions Declaration // Module Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
static void ErrorCallback(int error, const char *description); static void ErrorCallback(int error, const char *description);
static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods); 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 // 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 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 // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Light type // Light type
typedef enum { typedef enum {
LIGHT_DIRECTIONAL = 0, LIGHT_DIRECTIONAL = 0,
@ -66,7 +65,7 @@ typedef struct {
static int lightCount = 0; // Current number of dynamic lights that have been created 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 // Create a light and get shader locations
static Light CreateLight(int type, Vector3 position, Vector3 target, Color color, float intensity, Shader shader); 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); static void UpdateLight(Shader shader, Light light);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Main Entry Point // Program main entry point
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
int main() int main()
{ {
@ -237,9 +236,9 @@ int main()
Vector4 floorEmissiveColor = ColorNormalize(floor.materials[0].maps[MATERIAL_MAP_EMISSION].color); Vector4 floorEmissiveColor = ColorNormalize(floor.materials[0].maps[MATERIAL_MAP_EMISSION].color);
SetShaderValue(shader, emissiveColorLoc, &floorEmissiveColor, SHADER_UNIFORM_VEC4); SetShaderValue(shader, emissiveColorLoc, &floorEmissiveColor, SHADER_UNIFORM_VEC4);
// Set floor metallic and roughness values // Set floor metallic and roughness values
SetShaderValue(shader, metallicValueLoc, &floor.materials[0].maps[MATERIAL_MAP_METALNESS].value, SHADER_UNIFORM_FLOAT); 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); 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 DrawModel(floor, (Vector3){ 0.0f, 0.0f, 0.0f }, 5.0f, WHITE); // Draw floor model
@ -250,9 +249,9 @@ int main()
float emissiveIntensity = 0.01f; float emissiveIntensity = 0.01f;
SetShaderValue(shader, emissiveIntensityLoc, &emissiveIntensity, SHADER_UNIFORM_FLOAT); SetShaderValue(shader, emissiveIntensityLoc, &emissiveIntensity, SHADER_UNIFORM_FLOAT);
// Set old car metallic and roughness values // Set old car metallic and roughness values
SetShaderValue(shader, metallicValueLoc, &car.materials[0].maps[MATERIAL_MAP_METALNESS].value, SHADER_UNIFORM_FLOAT); 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); 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 DrawModel(car, (Vector3){ 0.0f, 0.0f, 0.0f }, 0.25f, WHITE); // Draw car model
@ -299,6 +298,9 @@ int main()
return 0; return 0;
} }
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
// Create light with provided data // Create light with provided data
// NOTE: It updated the global lightCount and it's limited to MAX_LIGHTS // 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) 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 "raylib.h"
#include "rlgl.h" #include "rlgl.h"
#include "math.h" // Used for tan() #include "raymath.h"
#include "raymath.h" // Used to calculate camera Direction
#include <math.h> // Required for: tanf()
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
#define GLSL_VERSION 330 #define GLSL_VERSION 330
#else // PLATFORM_ANDROID, PLATFORM_WEB #else // PLATFORM_ANDROID, PLATFORM_WEB
#define GLSL_VERSION 100 #define GLSL_VERSION 100
#endif #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 // Load custom render texture, create a writable depth texture buffer
static RenderTexture2D LoadRenderTextureDepthTex(int width, int height); static RenderTexture2D LoadRenderTextureDepthTex(int width, int height);
// Unload render texture from GPU memory (VRAM) // Unload render texture from GPU memory (VRAM)
static void UnloadRenderTextureDepthTex(RenderTexture2D target); static void UnloadRenderTextureDepthTex(RenderTexture2D target);
//------------------------------------------------------------------------------------
// Declare custom Structs
//------------------------------------------------------------------------------------
typedef struct {
unsigned int camPos, camDir, screenCenter;
}RayLocs ;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
@ -164,10 +167,10 @@ int main(void)
} }
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Define custom functions required for the example // Module Functions Definition
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Load custom render texture, create a writable depth texture buffer // 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 }; RenderTexture2D target = { 0 };
@ -206,7 +209,7 @@ RenderTexture2D LoadRenderTextureDepthTex(int width, int height)
} }
// Unload render texture from GPU memory (VRAM) // Unload render texture from GPU memory (VRAM)
void UnloadRenderTextureDepthTex(RenderTexture2D target) static void UnloadRenderTextureDepthTex(RenderTexture2D target)
{ {
if (target.id > 0) if (target.id > 0)
{ {

View file

@ -23,9 +23,9 @@
#define GLSL_VERSION 100 #define GLSL_VERSION 100
#endif #endif
//------------------------------------------------------------------------------------ //----------------------------------------------------------------------------------
// Structs definition // Types and Structures Definition
//------------------------------------------------------------------------------------ //----------------------------------------------------------------------------------
// Rounded rectangle data // Rounded rectangle data
typedef struct { typedef struct {
Vector4 cornerRadius; // Individual corner radius (top-left, top-right, bottom-left, bottom-right) 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_SPOTS 3 // NOTE: It must be the same as define in shader
#define MAX_STARS 400 #define MAX_STARS 400
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
// Spot data // Spot data
typedef struct Spot { typedef struct Spot {
Vector2 position; Vector2 position;
@ -65,6 +68,9 @@ typedef struct Star {
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
//--------------------------------------------------------------------------------------
// Module Functions Declaration
//--------------------------------------------------------------------------------------
static void UpdateStar(Star *s); static void UpdateStar(Star *s);
static void ResetStar(Star *s); static void ResetStar(Star *s);

View file

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

Some files were not shown because too many files have changed in this diff Show more