mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-18 17:28:15 +00:00
REVIEWED: Examples comments, consistent code sections
This commit is contained in:
@@ -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
|
||||||
|
@@ -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;
|
||||||
|
@@ -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);
|
||||||
|
@@ -64,7 +64,7 @@ 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 UpdateCameraFPS(Camera *camera);
|
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 };
|
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)
|
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 };
|
||||||
|
@@ -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
|
||||||
|
|
||||||
|
@@ -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)
|
||||||
{
|
{
|
||||||
|
@@ -20,17 +20,19 @@
|
|||||||
// 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)
|
||||||
{
|
{
|
||||||
|
@@ -18,15 +18,18 @@
|
|||||||
#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 c;
|
||||||
Rectangle r;
|
Rectangle r;
|
||||||
} 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);
|
||||||
@@ -114,7 +117,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Module functions definition
|
// Module Functions Definition
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
static Color GenerateRandomColor()
|
static Color GenerateRandomColor()
|
||||||
{
|
{
|
||||||
|
@@ -128,9 +128,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)
|
||||||
|
@@ -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
|
||||||
|
@@ -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()
|
||||||
{
|
{
|
||||||
@@ -293,6 +292,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)
|
||||||
|
@@ -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
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
@@ -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
|
// 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 };
|
||||||
|
|
||||||
@@ -195,7 +198,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)
|
||||||
{
|
{
|
||||||
|
@@ -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)
|
||||||
|
@@ -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;
|
||||||
@@ -62,6 +65,9 @@ typedef struct Star {
|
|||||||
Vector2 speed;
|
Vector2 speed;
|
||||||
} Star;
|
} Star;
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Module Functions Declaration
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
static void UpdateStar(Star *s);
|
static void UpdateStar(Star *s);
|
||||||
static void ResetStar(Star *s);
|
static void ResetStar(Star *s);
|
||||||
|
|
||||||
|
@@ -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);
|
||||||
|
|
||||||
@@ -109,9 +109,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)
|
||||||
{
|
{
|
||||||
|
@@ -128,7 +128,6 @@ int main(void)
|
|||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Definition
|
// Module Functions Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Update clock time
|
// Update clock time
|
||||||
static void UpdateClock(Clock *clock)
|
static void UpdateClock(Clock *clock)
|
||||||
{
|
{
|
||||||
|
@@ -19,9 +19,6 @@
|
|||||||
|
|
||||||
#include <math.h> // Required for: sin(), cos(), PI
|
#include <math.h> // Required for: sin(), cos(), PI
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Macro Helpers
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Constant for Simulation
|
// Constant for Simulation
|
||||||
#define SIMULATION_STEPS 30
|
#define SIMULATION_STEPS 30
|
||||||
#define G 9.81
|
#define G 9.81
|
||||||
@@ -156,13 +153,16 @@ int main(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate Pendulum End Point
|
//----------------------------------------------------------------------------------
|
||||||
|
// Module Functions Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Calculate pendulum end point
|
||||||
static Vector2 CalculatePendulumEndPoint(float l, float theta)
|
static Vector2 CalculatePendulumEndPoint(float l, float theta)
|
||||||
{
|
{
|
||||||
return (Vector2){ 10*l*sin(theta), 10*l*cos(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)
|
static Vector2 CalculateDoublePendulumEndPoint(float l1, float theta1, float l2, float theta2)
|
||||||
{
|
{
|
||||||
Vector2 endpoint1 = CalculatePendulumEndPoint(l1, theta1);
|
Vector2 endpoint1 = CalculatePendulumEndPoint(l1, theta1);
|
||||||
|
@@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Module Functions Declaration
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
// Draw rectangle with rounded edges and horizontal gradient, with options to choose side of roundness
|
// 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);
|
static void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float roundnessRight, int segments, Color left, Color right);
|
||||||
|
|
||||||
@@ -83,6 +86,9 @@ int main(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Module Functions Definition
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
// Draw rectangle with rounded edges and horizontal gradient, with options to choose side of roundness
|
// 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
|
// 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)
|
static void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float roundnessRight, int segments, Color left, Color right)
|
||||||
|
@@ -41,7 +41,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Globals
|
// Global variables
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
#define LETTER_BOUNDRY_SIZE 0.25f
|
#define LETTER_BOUNDRY_SIZE 0.25f
|
||||||
#define TEXT_MAX_LAYERS 32
|
#define TEXT_MAX_LAYERS 32
|
||||||
@@ -51,7 +51,7 @@ bool SHOW_LETTER_BOUNDRY = false;
|
|||||||
bool SHOW_TEXT_BOUNDRY = false;
|
bool SHOW_TEXT_BOUNDRY = false;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Data Types definition
|
// Types and Structures Definition
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Configuration structure for waving the text
|
// Configuration structure for waving the text
|
||||||
typedef struct WaveTextConfig {
|
typedef struct WaveTextConfig {
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module functions declaration
|
// Module Functions Declaration
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Draw text using font inside rectangle limits
|
// 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);
|
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
|
// Draw text using font inside rectangle limits
|
||||||
|
@@ -24,6 +24,18 @@
|
|||||||
#define EMOJI_PER_WIDTH 8
|
#define EMOJI_PER_WIDTH 8
|
||||||
#define EMOJI_PER_HEIGHT 4
|
#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
|
// 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"
|
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"
|
"\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 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 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
|
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
|
// 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
|
// Draw text using font inside rectangle limits
|
||||||
|
@@ -19,17 +19,20 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Types and Structures Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int* data;
|
int *data;
|
||||||
int count;
|
int count;
|
||||||
int capacity;
|
int capacity;
|
||||||
} CodepointsArray;
|
} CodepointsArray;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Module functions declaration
|
// Module Functions Declaration
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
static void AddRange(CodepointsArray* array, int start, int stop);
|
static void AddCodepointRange(CodepointsArray* array, int start, int stop);
|
||||||
static Font LoadUnicodeFont(const char* fileName, int fontSize);
|
//static Font LoadUnicodeFont(const char* fileName, int fontSize);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// 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)
|
static void AddRange(CodepointsArray* array, int start, int stop)
|
||||||
{
|
{
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Module functions declaration
|
// Module Functions Declaration
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
static void NormalizeKernel(float *kernel, int size);
|
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)
|
static void NormalizeKernel(float *kernel, int size)
|
||||||
{
|
{
|
||||||
|
@@ -155,7 +155,6 @@ int main()
|
|||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Definition
|
// Module Functions Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw textured curve using Spline Cubic Bezier
|
// Draw textured curve using Spline Cubic Bezier
|
||||||
static void DrawTexturedCurve(void)
|
static void DrawTexturedCurve(void)
|
||||||
{
|
{
|
||||||
|
@@ -31,7 +31,7 @@ int screenHeight = 450;
|
|||||||
void UpdateDrawFrame(void); // Update and Draw one frame
|
void UpdateDrawFrame(void); // Update and Draw one frame
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Main Entry Point
|
// Program main entry point
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
@@ -26,18 +26,18 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Local Variables Definition (local to this module)
|
// Global Variables Definition (local to this module)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
Camera camera = { 0 };
|
Camera camera = { 0 };
|
||||||
Vector3 cubePosition = { 0 };
|
Vector3 cubePosition = { 0 };
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Local Functions Declaration
|
// Module Functions Declaration
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
static void UpdateDrawFrame(void); // Update and draw one frame
|
static void UpdateDrawFrame(void); // Update and draw one frame
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Main entry point
|
// Program main entry point
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user