From d4e51f13e23eeebf1fc694a4fc26d7c6240da8f1 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 14 Sep 2020 15:32:26 +0200 Subject: [PATCH] Updated raylib data structures (markdown) --- raylib-data-structures.md | 72 ++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/raylib-data-structures.md b/raylib-data-structures.md index 31e79d5..4203ce2 100644 --- a/raylib-data-structures.md +++ b/raylib-data-structures.md @@ -3,53 +3,55 @@ Those structures are quite common in most of the engines out there. ### raylib data structures ```c + Struct name [32bit size] [64bit change] Description +----------------------------------------------------------------------------------------------------------------------- // Basic data structures - struct Color; [ 4 bytes] // RGBA values, 4 char, 32bit color - struct Rectangle; [16 bytes] // 4 float values - struct Vector2; [ 8 bytes] // 2 float values - struct Vector3; [12 bytes] // 3 float values - struct Vector4; [16 bytes] // 4 float values - struct Matrix; [64 bytes] // 16 float values, right handed, column major - struct Quaternion; [16 bytes] // Vector4 alias + struct Color; [ 4 bytes] - // RGBA values, 4 char, 32bit color + struct Rectangle; [16 bytes] - // 4 float values + struct Vector2; [ 8 bytes] - // 2 float values + struct Vector3; [12 bytes] - // 3 float values + struct Vector4; [16 bytes] - // 4 float values + struct Matrix; [64 bytes] - // 16 float values, right handed, column major + struct Quaternion; [16 bytes] - // Vector4 alias // 2D data structures (pixels, font...) - struct Image; [20 bytes] // Image data pointer (RAM) and 4 data parameters - struct Texture2D; [20 bytes] // OpenGL texture id (VRAM) and basic info - struct Texture; [20 bytes] // Texture2D alias - struct TextureCubemap; [20 bytes] // OpenGL cubemap texture id and basic info - struct RenderTexture2D; [28 bytes] // OpenGL framebuffer id and color+depth textures - struct RenderTexture [28 bytes] // RenderTexture2D alias + struct Image; [20 bytes] [+4 bytes] // Image data pointer (RAM) and 4 data parameters + struct Texture2D; [20 bytes] - // OpenGL texture id (VRAM) and basic info + struct Texture; [20 bytes] - // Texture2D alias + struct TextureCubemap; [20 bytes] - // OpenGL cubemap texture id and basic info + struct RenderTexture2D; [28 bytes] - // OpenGL framebuffer id and color+depth textures + struct RenderTexture [28 bytes] - // RenderTexture2D alias - struct NPatchInfo [36 bytes] // Source rectangle and border offsets - struct CharInfo; [32 bytes] // One character image and info properties - struct Font; [36 bytes] // Texture atlas and recs+chars data array pointers + struct NPatchInfo [36 bytes] - // Source rectangle and border offsets + struct CharInfo; [32 bytes] [+4 bytes] // One character image and info properties + struct Font; [36 bytes] [+12 bytes] // Texture atlas and recs+chars data array pointers // Screen view structures - struct Camera2D; [24 bytes] // 2D camera offset, target, rotation and zoom - struct Camera3D; [44 bytes] // 3D camera position, target, up vectors and parameters - struct Camera; [44 bytes] // Camera3D alias - struct VrDeviceInfo; [64 bytes] // Head-Mounted-Display device configuration parameters + struct Camera2D; [24 bytes] - // 2D camera offset, target, rotation and zoom + struct Camera3D; [44 bytes] - // 3D camera position, target, up vectors and parameters + struct Camera; [44 bytes] - // Camera3D alias + struct VrDeviceInfo; [64 bytes] - // Head-Mounted-Display device configuration parameters // 3D data structures (vertex, material properties...) // NOTE: Those structures are more complex so they use some internal pointers to data - struct Mesh; [60 bytes] // Vertex data, OpenGL buffers ids, animation data (skeleton bones and pose) - struct Shader; [ 8 bytes] // OpenGL program id, locations array pointer - struct Material; [16 bytes] // Shader and maps array pointer - struct MaterialMap [28 bytes] // Texture, color and value - struct Model; [96 bytes] // Meshes+materials array pointers, transform matrix (64 bytes) - struct ModelAnimation; [16 bytes] // Skeletal bones data and frames transformation - struct BoneInfo; [36 bytes] // Bone name (32 bytes) and parent id - struct Transform; [40 bytes] // Vertex transformation: translation, rotation, scale + struct Mesh; [60 bytes] [+52 bytes] // Vertex data, OpenGL buffers ids, animation data (skeleton bones and pose) + struct Shader; [ 8 bytes] [+8 bytes] // OpenGL program id, locations array pointer + struct Material; [16 bytes] [+16 bytes] // Shader and maps array pointer + struct MaterialMap [28 bytes] - // Texture, color and value + struct Model; [96 bytes] [+24 bytes] // Meshes+materials array pointers, transform matrix (64 bytes) + struct ModelAnimation; [16 bytes] [+8 bytes] // Skeletal bones data and frames transformation + struct BoneInfo; [36 bytes] - // Bone name (32 bytes) and parent id + struct Transform; [40 bytes] - // Vertex transformation: translation, rotation, scale - struct Ray; [24 bytes] // Ray-casting position+direction vectors - struct RayHitInfo; [32 bytes] // Ray collision information - struct BoundingBox; [12 bytes] // Defined by min and max vertex + struct Ray; [24 bytes] - // Ray-casting position+direction vectors + struct RayHitInfo; [32 bytes] - // Ray collision information + struct BoundingBox; [12 bytes] - // Defined by min and max vertex // Audio related data - struct Wave; [20 bytes] // Wave data pointer (RAM) and data parameters - struct AudioStream; [16 bytes] // Audio buffer pointer (private) and parameters - struct Sound; [20 bytes] // Audio stream and samples count - struct Music; [32 bytes] // Audio stream and music data pointer for streaming + struct Wave; [20 bytes] [+4 bytes] // Wave data pointer (RAM) and data parameters + struct AudioStream; [12 bytes] [+4 bytes] // Audio buffer pointer (private) and parameters + struct Sound; [16 bytes] [+8 bytes] // Audio stream and samples count + struct Music; [18 bytes] [+12 bytes] // Audio stream and music data pointer for streaming ``` raylib abuses the data pass-by-value on most of its functions, actually, only around 10% of the functions require dealing with data pointers. For this reason, I tried to keep data structures as small as possible, usually under 64 bytes size, and use internal pointers when data requires modification by some function (usually Load/Update/Unload functions).