Review raylib structs comments
This commit is contained in:
parent
9f45fea31e
commit
7959d95db0
1 changed files with 86 additions and 86 deletions
172
src/raylib.h
172
src/raylib.h
|
@ -181,23 +181,23 @@
|
||||||
|
|
||||||
// Vector2 type
|
// Vector2 type
|
||||||
typedef struct Vector2 {
|
typedef struct Vector2 {
|
||||||
float x;
|
float x; // Vector x component
|
||||||
float y;
|
float y; // Vector y component
|
||||||
} Vector2;
|
} Vector2;
|
||||||
|
|
||||||
// Vector3 type
|
// Vector3 type
|
||||||
typedef struct Vector3 {
|
typedef struct Vector3 {
|
||||||
float x;
|
float x; // Vector x component
|
||||||
float y;
|
float y; // Vector y component
|
||||||
float z;
|
float z; // Vector z component
|
||||||
} Vector3;
|
} Vector3;
|
||||||
|
|
||||||
// Vector4 type
|
// Vector4 type
|
||||||
typedef struct Vector4 {
|
typedef struct Vector4 {
|
||||||
float x;
|
float x; // Vector x component
|
||||||
float y;
|
float y; // Vector y component
|
||||||
float z;
|
float z; // Vector z component
|
||||||
float w;
|
float w; // Vector w component
|
||||||
} Vector4;
|
} Vector4;
|
||||||
|
|
||||||
// Quaternion type, same as Vector4
|
// Quaternion type, same as Vector4
|
||||||
|
@ -205,26 +205,26 @@ typedef Vector4 Quaternion;
|
||||||
|
|
||||||
// Matrix type (OpenGL style 4x4 - right handed, column major)
|
// Matrix type (OpenGL style 4x4 - right handed, column major)
|
||||||
typedef struct Matrix {
|
typedef struct Matrix {
|
||||||
float m0, m4, m8, m12;
|
float m0, m4, m8, m12; // Matrix first row (4 components)
|
||||||
float m1, m5, m9, m13;
|
float m1, m5, m9, m13; // Matrix second row (4 components)
|
||||||
float m2, m6, m10, m14;
|
float m2, m6, m10, m14; // Matrix third row (4 components)
|
||||||
float m3, m7, m11, m15;
|
float m3, m7, m11, m15; // Matrix fourth row (4 components)
|
||||||
} Matrix;
|
} Matrix;
|
||||||
|
|
||||||
// Color type, RGBA (32bit)
|
// Color type, RGBA (32bit)
|
||||||
typedef struct Color {
|
typedef struct Color {
|
||||||
unsigned char r;
|
unsigned char r; // Color red value
|
||||||
unsigned char g;
|
unsigned char g; // Color green value
|
||||||
unsigned char b;
|
unsigned char b; // Color blue value
|
||||||
unsigned char a;
|
unsigned char a; // Color alpha value
|
||||||
} Color;
|
} Color;
|
||||||
|
|
||||||
// Rectangle type
|
// Rectangle type
|
||||||
typedef struct Rectangle {
|
typedef struct Rectangle {
|
||||||
float x;
|
float x; // Rectangle top-left corner position x
|
||||||
float y;
|
float y; // Rectangle top-left corner position y
|
||||||
float width;
|
float width; // Rectangle width
|
||||||
float height;
|
float height; // Rectangle height
|
||||||
} Rectangle;
|
} Rectangle;
|
||||||
|
|
||||||
// Image type, bpp always RGBA (32bit)
|
// Image type, bpp always RGBA (32bit)
|
||||||
|
@ -316,113 +316,113 @@ typedef struct Camera2D {
|
||||||
// Vertex data definning a mesh
|
// Vertex data definning a mesh
|
||||||
// NOTE: Data stored in CPU memory (and GPU)
|
// NOTE: Data stored in CPU memory (and GPU)
|
||||||
typedef struct Mesh {
|
typedef struct Mesh {
|
||||||
int vertexCount; // Number of vertices stored in arrays
|
int vertexCount; // Number of vertices stored in arrays
|
||||||
int triangleCount; // Number of triangles stored (indexed or not)
|
int triangleCount; // Number of triangles stored (indexed or not)
|
||||||
|
|
||||||
// Default vertex data
|
// Default vertex data
|
||||||
float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
|
float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
|
||||||
float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
|
float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
|
||||||
float *texcoords2; // Vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
|
float *texcoords2; // Vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
|
||||||
float *normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
|
float *normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
|
||||||
float *tangents; // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
|
float *tangents; // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
|
||||||
unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
|
unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
|
||||||
unsigned short *indices;// Vertex indices (in case vertex data comes indexed)
|
unsigned short *indices; // Vertex indices (in case vertex data comes indexed)
|
||||||
|
|
||||||
// Animation vertex data
|
// Animation vertex data
|
||||||
float *animVertices; // Animated vertex positions (after bones transformations)
|
float *animVertices; // Animated vertex positions (after bones transformations)
|
||||||
float *animNormals; // Animated normals (after bones transformations)
|
float *animNormals; // Animated normals (after bones transformations)
|
||||||
int *boneIds; // Vertex bone ids, up to 4 bones influence by vertex (skinning)
|
int *boneIds; // Vertex bone ids, up to 4 bones influence by vertex (skinning)
|
||||||
float *boneWeights; // Vertex bone weight, up to 4 bones influence by vertex (skinning)
|
float *boneWeights; // Vertex bone weight, up to 4 bones influence by vertex (skinning)
|
||||||
|
|
||||||
// OpenGL identifiers
|
// OpenGL identifiers
|
||||||
unsigned int vaoId; // OpenGL Vertex Array Object id
|
unsigned int vaoId; // OpenGL Vertex Array Object id
|
||||||
unsigned int *vboId; // OpenGL Vertex Buffer Objects id (default vertex data)
|
unsigned int *vboId; // OpenGL Vertex Buffer Objects id (default vertex data)
|
||||||
} Mesh;
|
} Mesh;
|
||||||
|
|
||||||
// Shader type (generic)
|
// Shader type (generic)
|
||||||
typedef struct Shader {
|
typedef struct Shader {
|
||||||
unsigned int id; // Shader program id
|
unsigned int id; // Shader program id
|
||||||
int *locs; // Shader locations array (MAX_SHADER_LOCATIONS)
|
int *locs; // Shader locations array (MAX_SHADER_LOCATIONS)
|
||||||
} Shader;
|
} Shader;
|
||||||
|
|
||||||
// Material texture map
|
// Material texture map
|
||||||
typedef struct MaterialMap {
|
typedef struct MaterialMap {
|
||||||
Texture2D texture; // Material map texture
|
Texture2D texture; // Material map texture
|
||||||
Color color; // Material map color
|
Color color; // Material map color
|
||||||
float value; // Material map value
|
float value; // Material map value
|
||||||
} MaterialMap;
|
} MaterialMap;
|
||||||
|
|
||||||
// Material type (generic)
|
// Material type (generic)
|
||||||
typedef struct Material {
|
typedef struct Material {
|
||||||
Shader shader; // Material shader
|
Shader shader; // Material shader
|
||||||
MaterialMap *maps; // Material maps array (MAX_MATERIAL_MAPS)
|
MaterialMap *maps; // Material maps array (MAX_MATERIAL_MAPS)
|
||||||
float params[4]; // Material generic parameters (if required)
|
float params[4]; // Material generic parameters (if required)
|
||||||
} Material;
|
} Material;
|
||||||
|
|
||||||
// Transformation properties
|
// Transformation properties
|
||||||
typedef struct Transform {
|
typedef struct Transform {
|
||||||
Vector3 translation; // Translation
|
Vector3 translation; // Translation
|
||||||
Quaternion rotation; // Rotation
|
Quaternion rotation; // Rotation
|
||||||
Vector3 scale; // Scale
|
Vector3 scale; // Scale
|
||||||
} Transform;
|
} Transform;
|
||||||
|
|
||||||
// Bone information
|
// Bone information
|
||||||
typedef struct BoneInfo {
|
typedef struct BoneInfo {
|
||||||
char name[32]; // Bone name
|
char name[32]; // Bone name
|
||||||
int parent; // Bone parent
|
int parent; // Bone parent
|
||||||
} BoneInfo;
|
} BoneInfo;
|
||||||
|
|
||||||
// Model type
|
// Model type
|
||||||
typedef struct Model {
|
typedef struct Model {
|
||||||
Matrix transform; // Local transform matrix
|
Matrix transform; // Local transform matrix
|
||||||
|
|
||||||
int meshCount; // Number of meshes
|
int meshCount; // Number of meshes
|
||||||
int materialCount; // Number of materials
|
int materialCount; // Number of materials
|
||||||
Mesh *meshes; // Meshes array
|
Mesh *meshes; // Meshes array
|
||||||
Material *materials; // Materials array
|
Material *materials; // Materials array
|
||||||
int *meshMaterial; // Mesh material number
|
int *meshMaterial; // Mesh material number
|
||||||
|
|
||||||
// Animation data
|
// Animation data
|
||||||
int boneCount; // Number of bones
|
int boneCount; // Number of bones
|
||||||
BoneInfo *bones; // Bones information (skeleton)
|
BoneInfo *bones; // Bones information (skeleton)
|
||||||
Transform *bindPose; // Bones base transformation (pose)
|
Transform *bindPose; // Bones base transformation (pose)
|
||||||
} Model;
|
} Model;
|
||||||
|
|
||||||
// Model animation
|
// Model animation
|
||||||
typedef struct ModelAnimation {
|
typedef struct ModelAnimation {
|
||||||
int boneCount; // Number of bones
|
int boneCount; // Number of bones
|
||||||
int frameCount; // Number of animation frames
|
int frameCount; // Number of animation frames
|
||||||
BoneInfo *bones; // Bones information (skeleton)
|
BoneInfo *bones; // Bones information (skeleton)
|
||||||
Transform **framePoses; // Poses array by frame
|
Transform **framePoses; // Poses array by frame
|
||||||
} ModelAnimation;
|
} ModelAnimation;
|
||||||
|
|
||||||
// Ray type (useful for raycast)
|
// Ray type (useful for raycast)
|
||||||
typedef struct Ray {
|
typedef struct Ray {
|
||||||
Vector3 position; // Ray position (origin)
|
Vector3 position; // Ray position (origin)
|
||||||
Vector3 direction; // Ray direction
|
Vector3 direction; // Ray direction
|
||||||
} Ray;
|
} Ray;
|
||||||
|
|
||||||
// Raycast hit information
|
// Raycast hit information
|
||||||
typedef struct RayHitInfo {
|
typedef struct RayHitInfo {
|
||||||
bool hit; // Did the ray hit something?
|
bool hit; // Did the ray hit something?
|
||||||
float distance; // Distance to nearest hit
|
float distance; // Distance to nearest hit
|
||||||
Vector3 position; // Position of nearest hit
|
Vector3 position; // Position of nearest hit
|
||||||
Vector3 normal; // Surface normal of hit
|
Vector3 normal; // Surface normal of hit
|
||||||
} RayHitInfo;
|
} RayHitInfo;
|
||||||
|
|
||||||
// Bounding box type
|
// Bounding box type
|
||||||
typedef struct BoundingBox {
|
typedef struct BoundingBox {
|
||||||
Vector3 min; // Minimum vertex box-corner
|
Vector3 min; // Minimum vertex box-corner
|
||||||
Vector3 max; // Maximum vertex box-corner
|
Vector3 max; // Maximum vertex box-corner
|
||||||
} BoundingBox;
|
} BoundingBox;
|
||||||
|
|
||||||
// Wave type, defines audio wave data
|
// Wave type, defines audio wave data
|
||||||
typedef struct Wave {
|
typedef struct Wave {
|
||||||
unsigned int sampleCount; // Total number of samples (considering channels!)
|
unsigned int sampleCount; // Total number of samples (considering channels!)
|
||||||
unsigned int sampleRate; // Frequency (samples per second)
|
unsigned int sampleRate; // Frequency (samples per second)
|
||||||
unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
|
unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
|
||||||
unsigned int channels; // Number of channels (1-mono, 2-stereo)
|
unsigned int channels; // Number of channels (1-mono, 2-stereo)
|
||||||
void *data; // Buffer data pointer
|
void *data; // Buffer data pointer
|
||||||
} Wave;
|
} Wave;
|
||||||
|
|
||||||
typedef struct rAudioBuffer rAudioBuffer;
|
typedef struct rAudioBuffer rAudioBuffer;
|
||||||
|
@ -430,28 +430,28 @@ typedef struct rAudioBuffer rAudioBuffer;
|
||||||
// Audio stream type
|
// Audio stream type
|
||||||
// NOTE: Useful to create custom audio streams not bound to a specific file
|
// NOTE: Useful to create custom audio streams not bound to a specific file
|
||||||
typedef struct AudioStream {
|
typedef struct AudioStream {
|
||||||
rAudioBuffer *buffer; // Pointer to internal data used by the audio system
|
rAudioBuffer *buffer; // Pointer to internal data used by the audio system
|
||||||
|
|
||||||
unsigned int sampleRate; // Frequency (samples per second)
|
unsigned int sampleRate; // Frequency (samples per second)
|
||||||
unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
|
unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
|
||||||
unsigned int channels; // Number of channels (1-mono, 2-stereo)
|
unsigned int channels; // Number of channels (1-mono, 2-stereo)
|
||||||
} AudioStream;
|
} AudioStream;
|
||||||
|
|
||||||
// Sound source type
|
// Sound source type
|
||||||
typedef struct Sound {
|
typedef struct Sound {
|
||||||
AudioStream stream; // Audio stream
|
AudioStream stream; // Audio stream
|
||||||
unsigned int sampleCount; // Total number of samples
|
unsigned int sampleCount; // Total number of samples
|
||||||
} Sound;
|
} Sound;
|
||||||
|
|
||||||
// Music stream type (audio file streaming from memory)
|
// Music stream type (audio file streaming from memory)
|
||||||
// NOTE: Anything longer than ~10 seconds should be streamed
|
// NOTE: Anything longer than ~10 seconds should be streamed
|
||||||
typedef struct Music {
|
typedef struct Music {
|
||||||
AudioStream stream; // Audio stream
|
AudioStream stream; // Audio stream
|
||||||
unsigned int sampleCount; // Total number of samples
|
unsigned int sampleCount; // Total number of samples
|
||||||
bool looping; // Music looping enable
|
bool looping; // Music looping enable
|
||||||
|
|
||||||
int ctxType; // Type of music context (audio filetype)
|
int ctxType; // Type of music context (audio filetype)
|
||||||
void *ctxData; // Audio context data, depends on type
|
void *ctxData; // Audio context data, depends on type
|
||||||
} Music;
|
} Music;
|
||||||
|
|
||||||
// Head-Mounted-Display device parameters
|
// Head-Mounted-Display device parameters
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue