ref.c3i raw
   1// This file requires 0.7.10 or later.
   2module raylib6::rl;
   3import std::math;
   4
   5const float PI = 3.14159265358979323846f;
   6const float DEG2RAD = PI / 180.0f;
   7const float RAD2DEG = 180.0f / PI;
   8
   9// Some Basic Colors
  10// NOTE: Custom raylib color palette for amazing visuals on WHITE background
  11const RLColor LIGHTGRAY   = { 200, 200, 200, 255 }; // Light Gray
  12const RLColor GRAY        = { 130, 130, 130, 255 }; // Gray
  13const RLColor DARKGRAY    = { 80, 80, 80, 255 };    // Dark Gray
  14const RLColor YELLOW      = { 253, 249, 0, 255 };   // Yellow
  15const RLColor GOLD        = { 255, 203, 0, 255 };   // Gold
  16const RLColor ORANGE      = { 255, 161, 0, 255 };   // Orange
  17const RLColor PINK        = { 255, 109, 194, 255 }; // Pink
  18const RLColor RED         = { 230, 41, 55, 255 };   // Red
  19const RLColor MAROON      = { 190, 33, 55, 255 };   // Maroon
  20const RLColor GREEN       = { 0, 228, 48, 255 };    // Green
  21const RLColor LIME        = { 0, 158, 47, 255 };    // Lime
  22const RLColor DARKGREEN   = { 0, 117, 44, 255 };    // Dark Green
  23const RLColor SKYBLUE     = { 102, 191, 255, 255 }; // Sky Blue
  24const RLColor BLUE        = { 0, 121, 241, 255 };   // Blue
  25const RLColor DARKBLUE    = { 0, 82, 172, 255 };    // Dark Blue
  26const RLColor PURPLE      = { 200, 122, 255, 255 }; // Purple
  27const RLColor VIOLET      = { 135, 60, 190, 255 };  // Violet
  28const RLColor DARKPURPLE  = { 112, 31, 126, 255 };  // Dark Purple
  29const RLColor BEIGE       = { 211, 176, 131, 255 }; // Beige
  30const RLColor BROWN       = { 127, 106, 79, 255 };  // Brown
  31const RLColor DARKBROWN   = { 76, 63, 47, 255 };    // Dark Brown
  32
  33const RLColor WHITE       = { 255, 255, 255, 255 }; // White
  34const RLColor BLACK       = { 0, 0, 0, 255 };       // Black
  35const RLColor BLANK       = { 0, 0, 0, 0 };         // Blank (Transparent)
  36const RLColor MAGENTA     = { 255, 0, 255, 255 };   // Magenta
  37const RLColor RAYWHITE    = { 245, 245, 245, 255 }; // My own White (raylib logo)
  38
  39alias RLVector2 = float[<2>];
  40alias RLVector3 = float[<3>];
  41alias RLVector4 = float[<4>];
  42alias RLRectangle = Rect;
  43
  44// Color, 4 components, R8G8B8A8 (32bit)
  45alias RLColor = char[<4>];
  46
  47// Image, pixel data stored in CPU memory (RAM)
  48struct RLImage
  49{
  50	void* data;           // Image raw data
  51	int width;           // Image base width
  52	int height;          // Image base height
  53	int mipmaps;         // Mipmap levels, 1 by default
  54	RLPixelFormat format; // Data format (PixelFormat type)
  55}
  56
  57// Texture, tex data stored in GPU memory (VRAM)
  58struct RLTexture
  59{
  60	uint id;             // OpenGL texture id
  61	int width;           // Texture base width
  62	int height;          // Texture base height
  63	int mipmaps;         // Mipmap levels, 1 by default
  64	RLPixelFormat format; // Data format (RLPixelFormat type)
  65}
  66
  67// Texture2D, same as Texture
  68alias RLTexture2D = RLTexture;
  69
  70// TextureCubemap, same as Texture
  71alias RLTextureCubemap = RLTexture;
  72
  73// RLRenderTexture, fbo for texture rendering
  74struct RLRenderTexture
  75{
  76	uint id;          // OpenGL framebuffer object id
  77	RLTexture texture; // Color buffer attachment texture
  78	RLTexture depth;   // Depth buffer attachment texture
  79}
  80
  81// RLRenderTexture2D, same as RenderTexture
  82alias RLRenderTexture2D = RLRenderTexture;
  83
  84// RLNPatchInfo, n-patch layout info
  85struct RLNPatchInfo
  86{
  87	Rect source;    // Texture source rectangle
  88	int left;             // Left border offset
  89	int top;              // Top border offset
  90	int right;            // Right border offset
  91	int bottom;           // Bottom border offset
  92	RLNPatchLayout layout; // Layout of the n-patch: 3x3, 1x3 or 3x1
  93}
  94
  95// RLGlyphInfo, font characters glyphs info
  96struct RLGlyphInfo
  97{
  98	int value;         // Character value (Unicode)
  99	int[<2>] offset_x; // Character offset when drawing
 100	int advance_x;     // Character advance position X
 101	RLImage image;      // Character image data
 102}
 103
 104// RLFont, font texture and GlyphInfo array data
 105struct RLFont
 106{
 107	int base_size;      // Base size (default chars height)
 108	int glyph_count;    // Number of glyph characters
 109	int glyph_padding;  // Padding around the glyph characters
 110	RLTexture2D texture; // Texture atlas containing the glyphs
 111	Rect* recs;   // Rectangles in texture for the glyphs
 112	RLGlyphInfo* glyphs; // Glyphs info data
 113}
 114
 115// RLCamera3D, defines position/orientation in 3d space
 116struct RLCamera3D
 117{
 118	RLVector3 position;            // Camera position
 119	RLVector3 target;              // Camera target it looks-at
 120	RLVector3 up;                  // Camera up vector (rotation over its axis)
 121	float fovy;                    // Camera field-of-view aperture in Y (degrees) in perspective, used as near plane height in world units in orthographic
 122	RLCameraProjection projection; // Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
 123}
 124
 125alias RLCamera = RLCamera3D; // Camera type fallback, defaults to Camera3D
 126
 127// RLCamera2D, defines position/orientation in 2d space
 128struct RLCamera2D
 129{
 130	RLVector2 offset;  // Camera offset (screen space offset from window origin)
 131	RLVector2 target;  // Camera target (world space target point that is mapped to screen space offset)
 132	float rotation;    // Camera rotation in degrees (pivots around target)
 133	float zoom;        // Camera zoom (scaling around target), must not be set to 0, set to 1.0f for no scale
 134}
 135
 136// RLMesh, vertex data and vao/vbo
 137struct RLMesh
 138{
 139	int vertex_count;   // Number of vertices stored in arrays
 140	int triangle_count; // Number of triangles stored (indexed or not)
 141
 142	// Vertex attributes data
 143	float* vertices;         // Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
 144	float* texcoords;        // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
 145	float* texcoords2;       // Vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
 146	float* normals;          // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
 147	float* tangents;         // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
 148	char* colors;            // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
 149	CUShort* indices;        // Vertex indices (in case vertex data comes indexed)
 150
 151    // Skin data for animation
 152    int bone_count;          // Number of bones (MAX: 256 bones)
 153    char* bone_indices;      // Vertex bone indices, up to 4 bones influence by vertex (skinning) (shader-location = 6)
 154    float *bone_weights;     // Vertex bone weight, up to 4 bones influence by vertex (skinning) (shader-location = 7)
 155
 156    // Runtime animation vertex data (CPU skinning)
 157    // NOTE: In case of GPU skinning, not used, pointers are NULL
 158    float *anim_vertices;    // Animated vertex positions (after bones transformations)
 159    float *anim_normals;     // Animated normals (after bones transformations)
 160
 161	// OpenGL identifiers
 162	uint vao_id;  // OpenGL Vertex Array Object id
 163	uint* vbo_id; // OpenGL Vertex Buffer Objects id (default vertex data)
 164}
 165
 166// RLShader
 167struct RLShader
 168{
 169	uint id;   // Shader program id
 170	int* locs; // Shader locations array (RL_MAX_SHADER_LOCATIONS)
 171}
 172
 173// RLMaterialMap
 174struct RLMaterialMap
 175{
 176	RLTexture2D texture; // Material map texture
 177	RLColor color;       // Material map color
 178	float value;         // Material map value
 179}
 180
 181// RLMaterial, includes shader and maps
 182struct RLMaterial
 183{
 184	RLShader shader;     // Material shader
 185	RLMaterialMap* maps; // Material maps array (MAX_MATERIAL_MAPS)
 186	float[4] params;     // Material generic parameters (if required)
 187}
 188
 189// Transform, vectex transformation data
 190struct RLTransform
 191{
 192	RLVector3 translation; // Translation
 193	Quat rotation; // Rotation
 194	RLVector3 scale;       // Scale
 195}
 196
 197// Anim pose, an array of Transform[]
 198alias RLModelAnimPose = RLTransform*;
 199
 200// RLBoneInfo, skeletal animation bone
 201struct RLBoneInfo
 202{
 203	char[32] name; // Bone name
 204	int parent;    // Bone parent
 205}
 206
 207// Skeleton, animation bones hierarchy
 208struct RLModelSkeleton
 209{
 210    int bone_count;            // Number of bones
 211    RLBoneInfo* bones;         // Bones information (skeleton)
 212    RLModelAnimPose bind_pose; // Bones base transformation (Transform[])
 213}
 214
 215// RLModel, meshes, materials and animation data
 216struct RLModel
 217{
 218	Mat4 transform;           // Local transform matrix
 219	int mesh_count;               // Number of meshes
 220	int material_count;           // Number of materials
 221	RLMesh* meshes;               // Meshes array
 222	RLMaterial* materials;        // Materials array
 223	int* mesh_material;           // Mesh material number
 224
 225	// Animation data
 226    RLModelSkeleton skeleton;     // Skeleton for animation
 227
 228    // Runtime animation data (CPU/GPU skinning)
 229    RLModelAnimPose current_pose; // Current animation pose (Transform[])
 230    Mat4*bone_matrices;       // Bones animated transformation matrices
 231}
 232
 233// RLModelAnimation, contains a full animation sequence
 234struct RLModelAnimation
 235{
 236	char[32] name;                   // Animation name
 237
 238    int bone_count;                  // Number of bones (per pose)
 239    int keyframe_count;              // Number of animation key frames
 240    RLModelAnimPose *keyframe_poses; // Animation sequence keyframe poses [keyframe][pose]
 241}
 242
 243// RLRay, ray for raycasting
 244struct RLRay
 245{
 246	RLVector3 position;  // Ray position (origin)
 247	RLVector3 direction; // Ray direction (normalized)
 248}
 249
 250// RLRayCollision, ray hit information
 251struct RLRayCollision
 252{
 253	bool hit;         // Did the ray hit something?
 254	float distance;   // Distance to nearest hit
 255	RLVector3 point;  // Point of nearest hit
 256	RLVector3 normal; // Surface normal of hit
 257}
 258
 259// RLBoundingBox
 260struct RLBoundingBox
 261{
 262	RLVector3 min; // Minimum vertex box-corner
 263	RLVector3 max; // Maximum vertex box-corner
 264}
 265
 266// RLWave, audio wave data
 267struct RLWave
 268{
 269	uint frameCount;  // Total number of frames (considering channels)
 270	uint sample_rate; // Frequency (samples per second)
 271	uint sample_size; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
 272	uint channels;    // Number of channels (1-mono, 2-stereo, ...)
 273	void* data;        // Buffer data pointer
 274}
 275
 276alias RLAudioBufferRef = void*;
 277alias RLAudioProcessorRef = void*;
 278
 279// RLAudioStream, custom audio stream
 280struct RLAudioStream
 281{
 282	RLAudioBufferRef buffer;       // Pointer to internal data used by the audio system
 283	RLAudioProcessorRef processor; // Pointer to internal data processor, useful for audio effects
 284
 285	uint sample_rate;             // Frequency (samples per second)
 286	uint sample_size;             // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
 287	uint channels;                // Number of channels (1-mono, 2-stereo, ...)
 288}
 289
 290
 291// RLSound
 292struct RLSound
 293{
 294	RLAudioStream stream; // Audio stream
 295	uint frame_count;    // Total number of frames (considering channels)
 296}
 297
 298// RLMusic, audio stream, anything longer than ~10 seconds should be streamed
 299struct RLMusic
 300{
 301	RLAudioStream stream; // Audio stream
 302	uint frame_count;    // Total number of frames (considering channels)
 303	bool looping;         // Music looping enable
 304
 305	int ctx_type;        // Type of music context (audio filetype)
 306	void* ctx_data;       // Audio context data, depends on type
 307}
 308
 309// RLVrDeviceInfo, Head-Mounted-Display device parameters
 310struct RLVrDeviceInfo
 311{
 312	int h_resolution;               // Horizontal resolution in pixels
 313	int v_resolution;               // Vertical resolution in pixels
 314	float h_screen_size;             // Horizontal size in meters
 315	float v_screen_size;             // Vertical size in meters
 316	float v_screen_center;           // Screen center in meters
 317	float eye_to_screen_distance;    // Distance between eye and display in meters
 318	float lens_separation_distance;  // Lens separation distance in meters
 319	float interpupillary_distance;   // IPD (distance between pupils) in meters
 320	float[4] lens_distortion_values; // Lens distortion constant parameters
 321	float[4] chroma_ab_correction;   // Chromatic aberration correction parameters
 322}
 323
 324// RLVrStereoConfig, VR stereo rendering configuration for simulator
 325struct RLVrStereoConfig
 326{
 327	Mat4[2] projection;       // VR projection matrices (per eye)
 328	Mat4[2] view_offset;      // VR view offset matrices (per eye)
 329	float[2] left_lens_center;    // VR left lens center
 330	float[2] right_lens_center;   // VR right lens center
 331	float[2] left_screen_center;  // VR left screen center
 332	float[2] right_screen_center; // VR right screen center
 333	float[2] scale;               // VR distortion scale
 334	float[2] scaleIn;             // VR distortion scale in
 335}
 336
 337struct RLFilePathList
 338{
 339	uint count;     // Filepaths entries count
 340	ZString* paths; // Filepaths entries
 341}
 342
 343// Automation event
 344struct RLAutomationEvent
 345{
 346	uint frame;    // Event frame
 347	uint type;     // Event type (AutomationEventType)
 348	int[4] params; // Event parameters (if required)
 349}
 350
 351// Automation event list
 352struct RLAutomationEventList
 353{
 354	uint capacity;            // Events max entries (MAX_AUTOMATION_EVENTS)
 355	uint count;               // Events entries count
 356	RLAutomationEvent* events; // Events entries
 357}
 358
 359// Trace log level
 360// NOTE: Organized by priority level
 361constdef RLTraceLogLevel : int
 362{
 363	ALL = 0, // Display all logs
 364	TRACE,   // Trace logging, intended for internal use only
 365	DEBUG,   // Debug logging, used for internal debugging, it should be disabled on release builds
 366	INFO,    // Info logging, used for program execution info
 367	WARNING, // Warning logging, used on recoverable failures
 368	ERROR,   // Error logging, used on unrecoverable failures
 369	FATAL,   // Fatal logging, used to abort program: exit(EXIT_FAILURE)
 370	NONE     // Disable logging
 371}
 372
 373// Mouse buttons
 374enum RLMouseButton : int
 375{
 376	LEFT,    // Mouse button left
 377	RIGHT,   // Mouse button right
 378	MIDDLE,  // Mouse button middle (pressed wheel)
 379	SIDE,    // Mouse button side (advanced mouse device)
 380	EXTRA,   // Mouse button extra (advanced mouse device)
 381	FORWARD, // Mouse button forward (advanced mouse device)
 382	BACK     // Mouse button back (advanced mouse device)
 383}
 384
 385// Mouse cursor
 386enum RLMouseCursor : int
 387{
 388	DEFAULT,       // Default pointer shape
 389	ARROW,         // Arrow shape
 390	IBEAM,         // Text writing cursor shape
 391	CROSSHAIR,     // Cross shape
 392	POINTING_HAND, // Pointing hand cursor
 393	RESIZE_EW,     // Horizontal resize/move arrow shape
 394	RESIZE_NS,     // Vertical resize/move arrow shape
 395	RESIZE_NWSE,   // Top-left to bottom-right diagonal resize/move arrow shape
 396	RESIZE_NESW,   // The top-right to bottom-left diagonal resize/move arrow shape
 397	RESIZE_ALL,    // The omnidirectional resize/move cursor shape
 398	NOT_ALLOWED    // The operation-not-allowed shape
 399}
 400
 401// Gamepad buttons
 402enum RLGamepadButton : int
 403{
 404	UNKNOWN,          // Unknown button, just for error checking
 405	LEFT_FACE_UP,     // Gamepad left DPAD up button
 406	LEFT_FACE_RIGHT,  // Gamepad left DPAD right button
 407	LEFT_FACE_DOWN,   // Gamepad left DPAD down button
 408	LEFT_FACE_LEFT,   // Gamepad left DPAD left button
 409	RIGHT_FACE_UP,    // Gamepad right button up (i.e. PS3: Triangle, Xbox: Y)
 410	RIGHT_FACE_RIGHT, // Gamepad right button right (i.e. PS3: Circle, Xbox: B)
 411	RIGHT_FACE_DOWN,  // Gamepad right button down (i.e. PS3: Cross, Xbox: A)
 412	RIGHT_FACE_LEFT,  // Gamepad right button left (i.e. PS3: Square, Xbox: X)
 413	LEFT_TRIGGER_1,   // Gamepad top/back trigger left (first), it could be a trailing button
 414	LEFT_TRIGGER_2,   // Gamepad top/back trigger left (second), it could be a trailing button
 415	RIGHT_TRIGGER_1,  // Gamepad top/back trigger right (first), it could be a trailing button
 416	RIGHT_TRIGGER_2,  // Gamepad top/back trigger right (second), it could be a trailing button
 417	MIDDLE_LEFT,      // Gamepad center buttons, left one (i.e. PS3: Select)
 418	MIDDLE,           // Gamepad center buttons, middle one (i.e. PS3: PS, Xbox: XBOX)
 419	MIDDLE_RIGHT,     // Gamepad center buttons, right one (i.e. PS3: Start)
 420	LEFT_THUMB,       // Gamepad joystick pressed button left
 421	RIGHT_THUMB       // Gamepad joystick pressed button right
 422}
 423
 424enum RLGamepadAxis : int
 425{
 426	LEFT_X,       // Gamepad left stick X axis
 427	LEFT_Y,       // Gamepad left stick Y axis
 428	RIGHT_X,      // Gamepad right stick X axis
 429	RIGHT_Y,      // Gamepad right stick Y axis
 430	LEFT_TRIGGER, // Gamepad back trigger left, pressure level: [1..-1]
 431	RIGHT_TRIGGER // Gamepad back trigger right, pressure level: [1..-1]
 432}
 433
 434// RLMaterial map index
 435constdef RLMaterialMapIndex : inline int
 436{
 437	ALBEDO = 0, // Albedo material (same as: MATERIAL_MAP_DIFFUSE)
 438	METALNESS,  // Metalness material (same as: MATERIAL_MAP_SPECULAR)
 439	NORMAL,     // Normal material
 440	ROUGHNESS,  // Roughness material
 441	OCCLUSION,  // Ambient occlusion material
 442	EMISSION,   // Emission material
 443	HEIGHT,     // Heightmap material
 444	CUBEMAP,    // Cubemap material (NOTE: Uses GL_TEXTURE_CUBE_MAP)
 445	IRRADIANCE, // Irradiance material (NOTE: Uses GL_TEXTURE_CUBE_MAP)
 446	PREFILTER,  // Prefilter material (NOTE: Uses GL_TEXTURE_CUBE_MAP)
 447	BRDF,       // Brdf material
 448
 449	// Aliases
 450	DIFFUSE = ALBEDO,    // #define MATERIAL_MAP_DIFFUSE MATERIAL_MAP_ALBEDO
 451	SPECULAR = METALNESS // #define MATERIAL_MAP_SPECULAR MATERIAL_MAP_METALNESS
 452}
 453
 454// Shader location index
 455constdef RLShaderLocationIndex
 456{
 457	VERTEX_POSITION = 0,      // Shader location: vertex attribute: position
 458	VERTEX_TEXCOORD01,        // Shader location: vertex attribute: texcoord01
 459	VERTEX_TEXCOORD02,        // Shader location: vertex attribute: texcoord02
 460	VERTEX_NORMAL,            // Shader location: vertex attribute: normal
 461	VERTEX_TANGENT,           // Shader location: vertex attribute: tangent
 462	VERTEX_COLOR,             // Shader location: vertex attribute: color
 463	MATRIX_MVP,               // Shader location: matrix uniform: model-view-projection
 464	MATRIX_VIEW,              // Shader location: matrix uniform: view (camera transform)
 465	MATRIX_PROJECTION,        // Shader location: matrix uniform: projection
 466	MATRIX_MODEL,             // Shader location: matrix uniform: model (transform)
 467	MATRIX_NORMAL,            // Shader location: matrix uniform: normal
 468	VECTOR_VIEW,              // Shader location: vector uniform: view
 469	COLOR_DIFFUSE,            // Shader location: vector uniform: diffuse color
 470	COLOR_SPECULAR,           // Shader location: vector uniform: specular color
 471	COLOR_AMBIENT,            // Shader location: vector uniform: ambient color
 472	MAP_ALBEDO,               // Shader location: sampler2d texture: albedo (same as: SHADER_LOC_MAP_DIFFUSE)
 473	MAP_METALNESS,            // Shader location: sampler2d texture: metalness (same as: SHADER_LOC_MAP_SPECULAR)
 474	MAP_NORMAL,               // Shader location: sampler2d texture: normal
 475	MAP_ROUGHNESS,            // Shader location: sampler2d texture: roughness
 476	MAP_OCCLUSION,            // Shader location: sampler2d texture: occlusion
 477	MAP_EMISSION,             // Shader location: sampler2d texture: emission
 478	MAP_HEIGHT,               // Shader location: sampler2d texture: heightmap
 479	MAP_CUBEMAP,              // Shader location: samplerCube texture: cubemap
 480	MAP_IRRADIANCE,           // Shader location: samplerCube texture: irradiance
 481	MAP_PREFILTER,            // Shader location: samplerCube texture: prefilter
 482	MAP_BRDF,                 // Shader location: sampler2d texture: brdf
 483	VERTEX_BONEIDS,           // Shader location: vertex attribute: bone indices
 484    VERTEX_BONEWEIGHTS,       // Shader location: vertex attribute: bone weights
 485    MATRIX_BONETRANSFORMS,    // Shader location: matrix attribute: bone transforms (animation)
 486    VERTEX_INSTANCETRANSFORM, // Shader location: vertex attribute: instance transforms
 487
 488	// Aliases
 489	MAP_DIFFUSE = MAP_ALBEDO,     // #define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO
 490	MAP_SPECULAR = MAP_METALNESS, // #define SHADER_LOC_MAP_SPECULAR SHADER_LOC_MAP_METALNESS
 491}
 492
 493// Shader uniform data type
 494enum RLShaderUniformDataType
 495{
 496	FLOAT,    // Shader uniform type: float
 497	VEC2,     // Shader uniform type: vec2 (2 float)
 498	VEC3,     // Shader uniform type: vec3 (3 float)
 499	VEC4,     // Shader uniform type: vec4 (4 float)
 500	INT,      // Shader uniform type: int
 501	IVEC2,    // Shader uniform type: ivec2 (2 int)
 502	IVEC3,    // Shader uniform type: ivec3 (3 int)
 503	IVEC4,    // Shader uniform type: ivec4 (4 int)
 504    UINT,     // Shader uniform type: unsigned int
 505    UIVEC2,   // Shader uniform type: uivec2 (2 unsigned int)
 506    UIVEC3,   // Shader uniform type: uivec3 (3 unsigned int)
 507    UIVEC4,   // Shader uniform type: uivec4 (4 unsigned int)
 508	SAMPLER2D // Shader uniform type: sampler2d
 509}
 510
 511// Shader attribute data types
 512enum RLShaderAttributeDataType
 513{
 514	FLOAT, // Shader attribute type: float
 515	VEC2,  // Shader attribute type: vec2 (2 float)
 516	VEC3,  // Shader attribute type: vec3 (3 float)
 517	VEC4   // Shader attribute type: vec4 (4 float)
 518}
 519
 520// Pixel formats
 521// NOTE: Support depends on OpenGL version and platform
 522constdef RLPixelFormat
 523{
 524	UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
 525	UNCOMPRESSED_GRAY_ALPHA,    // 8*2 bpp (2 channels)
 526	UNCOMPRESSED_R5G6B5,        // 16 bpp
 527	UNCOMPRESSED_R8G8B8,        // 24 bpp
 528	UNCOMPRESSED_R5G5B5A1,      // 16 bpp (1 bit alpha)
 529	UNCOMPRESSED_R4G4B4A4,      // 16 bpp (4 bit alpha)
 530	UNCOMPRESSED_R8G8B8A8,      // 32 bpp
 531	UNCOMPRESSED_R32,           // 32 bpp (1 channel - float)
 532	UNCOMPRESSED_R32G32B32,     // 32*3 bpp (3 channels - float)
 533	UNCOMPRESSED_R32G32B32A32,  // 32*4 bpp (4 channels - float)
 534	UNCOMPRESSED_R16,           // 16 bpp (1 channel - half float)
 535	UNCOMPRESSED_R16G16B16,     // 16*3 bpp (3 channels - half float)
 536	UNCOMPRESSED_R16G16B16A16,  // 16*4 bpp (4 channels - half float)
 537	COMPRESSED_DXT1_RGB,        // 4 bpp (no alpha)
 538	COMPRESSED_DXT1_RGBA,       // 4 bpp (1 bit alpha)
 539	COMPRESSED_DXT3_RGBA,       // 8 bpp
 540	COMPRESSED_DXT5_RGBA,       // 8 bpp
 541	COMPRESSED_ETC1_RGB,        // 4 bpp
 542	COMPRESSED_ETC2_RGB,        // 4 bpp
 543	COMPRESSED_ETC2_EAC_RGBA,   // 8 bpp
 544	COMPRESSED_PVRT_RGB,        // 4 bpp
 545	COMPRESSED_PVRT_RGBA,       // 4 bpp
 546	COMPRESSED_ASTC_4X4_RGBA,   // 8 bpp
 547	COMPRESSED_ASTC_8X8_RGBA    // 2 bpp
 548}
 549
 550// Texture parameters: filter mode
 551// NOTE 1: Filtering considers mipmaps if available in the texture
 552// NOTE 2: Filter is accordingly set for minification and magnification
 553enum RLTextureFilter
 554{
 555	POINT,          // No filter, just pixel approximation
 556	BILINEAR,       // Linear filtering
 557	TRILINEAR,      // Trilinear filtering (linear with mipmaps)
 558	ANISOTROPIC_4X, // Anisotropic filtering 4x
 559	ANISOTROPIC_8X, // Anisotropic filtering 8x
 560	ANISOTROPIC_16X // Anisotropic filtering 16x
 561}
 562
 563// Texture parameters: wrap mode
 564enum RLTextureWrap
 565{
 566	REPEAT,        // Repeats texture in tiled mode
 567	CLAMP,         // Clamps texture to edge pixel in tiled mode
 568	MIRROR_REPEAT, // Mirrors and repeats the texture in tiled mode
 569	MIRROR_CLAMP   // Mirrors and clamps to border the texture in tiled mode
 570}
 571
 572// Cubemap layouts
 573enum RLCubemapLayout
 574{
 575	AUTO_DETECT,         // Automatically detect layout type
 576	LINE_VERTICAL,       // Layout is defined by a vertical line with faces
 577	LINE_HORIZONTAL,     // Layout is defined by a horizontal line with faces
 578	CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces
 579	CROSS_FOUR_BY_THREE  // Layout is defined by a 4x3 cross with cubemap faces
 580}
 581
 582// Font type, defines generation method
 583enum RLFontType
 584{
 585	DEFAULT, // Default font generation, anti-aliased
 586	BITMAP,  // Bitmap font generation, no anti-aliasing
 587	SDF      // SDF font generation, requires external shader
 588}
 589
 590// Color blending modes (pre-defined)
 591enum RLBlendMode
 592{
 593	ALPHA,             // Blend textures considering alpha (default)
 594	ADDITIVE,          // Blend textures adding colors
 595	MULTIPLIED,        // Blend textures multiplying colors
 596	ADD_COLORS,        // Blend textures adding colors (alternative)
 597	SUBTRACT_COLORS,   // Blend textures subtracting colors (alternative)
 598	ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha
 599	CUSTOM,            // Blend textures using custom src/dst factors (use setBlendFactors())
 600	CUSTOM_SEPARATE    // Blend textures using custom rgb/alpha separate src/dst factors (use setBlendFactorsSeparate())
 601}
 602
 603$assert(RLBlendMode.ALPHA.ordinal == 0);
 604
 605
 606// Camera system modes
 607enum RLCameraMode
 608{
 609	CUSTOM,       // Camera custom, controlled by user (UpdateCamera() does nothing)
 610	FREE,         // Camera free mode
 611	ORBITAL,      // Camera orbital, around target, zoom supported
 612	FIRST_PERSON, // Camera first person
 613	THIRD_PERSON  // Camera third person
 614}
 615
 616// Camera projection
 617enum RLCameraProjection
 618{
 619	PERSPECTIVE, // Perspective projection
 620	ORTHOGRAPHIC // Orthographic projection
 621}
 622
 623// N-patch layout
 624enum RLNPatchLayout
 625{
 626	NINE_PATCH,            // Npatch layout: 3x3 tiles
 627	THREE_PATCH_VERTICAL,  // Npatch layout: 1x3 tiles
 628	THREE_PATCH_HORIZONTAL // Npatch layout: 3x1 tiles
 629}
 630
 631// Callbacks to hook some internal functions
 632// WARNING: This callbacks are intended for advance users
 633alias RLTraceLogCallback @if($defined(CVaList)) = fn void(RLTraceLogLevel logLevel, ZString text, CVaList args); // Logging: Redirect trace log messages
 634alias RLLoadFileDataCallback = fn char*(ZString file_name, int* data_size);           // FileIO: Load binary data
 635alias RLSaveFileDataCallback = fn bool(ZString file_name, void* data, int data_size); // FileIO: Save binary data
 636alias RLLoadFileTextCallback = fn char*(ZString file_name);              // FileIO: Load text data
 637alias RLSaveFileTextCallback = fn bool(ZString file_name, ZString text); // FileIO: Save text data
 638
 639// Window-related functions
 640fn void init_window(int width, int height, ZString title) @cname("InitWindow");     // Initialize window and OpenGL context
 641fn void close_window() @cname("CloseWindow");                                         // Close window and unload OpenGL context
 642fn bool window_should_close() @cname("WindowShouldClose");                            // Check if application should close (KEY_ESCAPE pressed or windows close icon clicked)
 643fn bool is_window_ready() @cname("IsWindowReady");                                    // Check if window has been initialized successfully
 644fn bool is_window_fullscreen() @cname("IsWindowFullscreen");                          // Check if window is currently fullscreen
 645fn bool is_window_hidden() @cname("IsWindowHidden");                                  // Check if window is currently hidden
 646fn bool is_window_minimized() @cname("IsWindowMinimized");                            // Check if window is currently minimized
 647fn bool is_window_maximized() @cname("IsWindowMaximized");                            // Check if window is currently maximized
 648fn bool is_window_focused() @cname("IsWindowFocused");                                // Check if window is currently focused
 649fn bool is_window_resized() @cname("IsWindowResized");                                // Check if window has been resized last frame
 650fn bool is_window_state(RLConfigFlag flag) @cname("IsWindowState");                     // Check if one specific window flag is enabled
 651fn void set_window_state(RLConfigFlag flags) @cname("SetWindowState");                  // Set window configuration state using flags
 652fn void clear_window_state(RLConfigFlag flags) @cname("ClearWindowState");              // Clear window configuration state flags
 653fn void toggle_fullscreen() @cname("ToggleFullscreen");                               // Toggle window state: fullscreen/windowed, resizes monitor to match window resolution
 654fn void toggle_borderless_windowed() @cname("ToggleBorderlessWindowed");              // Toggle window state: borderless windowed, resizes window to match monitor resolution
 655fn void maximize_window() @cname("MaximizeWindow");                                   // Set window state: maximized, if resizable
 656fn void minimize_window() @cname("MinimizeWindow");                                   // Set window state: minimized, if resizable
 657fn void restore_window() @cname("RestoreWindow");                                     // Restore window from being minimized/maximized
 658fn void set_window_icon(RLImage image) @cname("SetWindowIcon");                       // Set icon for window (single image, RGBA 32bit)
 659fn void set_window_icons(RLImage* images, int count) @cname("SetWindowIcons");       // Set icon for window (multiple images, RGBA 32bit)
 660fn void set_window_title(ZString title) @cname("SetWindowTitle");                     // Set title for window
 661fn void set_window_position(int x, int y) @cname("SetWindowPosition");              // Set window position on screen
 662fn void set_window_monitor(int monitor) @cname("SetWindowMonitor");                  // Set monitor for the current window
 663fn void set_window_min_size(int width, int height) @cname("SetWindowMinSize");      // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
 664fn void set_window_max_size(int width, int height) @cname("SetWindowMaxSize");      // Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE)
 665fn void set_window_size(int width, int height) @cname("SetWindowSize");             // Set window dimensions
 666fn void set_window_opacity(float opacity) @cname("SetWindowOpacity");                 // Set window opacity [0.0f..1.0f]
 667fn void set_window_focused() @cname("SetWindowFocused");                              // Set window focused
 668fn void* get_window_handle() @cname("GetWindowHandle");                               // Get native window handle
 669fn int get_screen_width() @cname("GetScreenWidth");                                  // Get current screen width
 670fn int get_screen_height() @cname("GetScreenHeight");                                // Get current screen height
 671fn int get_render_width() @cname("GetRenderWidth");                                  // Get current render width (it considers HiDPI)
 672fn int get_render_height() @cname("GetRenderHeight");                                // Get current render height (it considers HiDPI)
 673fn int get_monitor_count() @cname("GetMonitorCount");                                // Get number of connected monitors
 674fn int get_current_monitor() @cname("GetCurrentMonitor");                            // Get current monitor where window is placed
 675fn RLVector2 get_monitor_position(int monitor) @cname("GetMonitorPosition");         // Get specified monitor position
 676fn int get_monitor_width(int monitor) @cname("GetMonitorWidth");                    // Get specified monitor width (current video mode used by monitor)
 677fn int get_monitor_height(int monitor) @cname("GetMonitorHeight");                  // Get specified monitor height (current video mode used by monitor)
 678fn int get_monitor_physical_width(int monitor) @cname("GetMonitorPhysicalWidth");   // Get specified monitor physical width in millimetres
 679fn int get_monitor_physical_height(int monitor) @cname("GetMonitorPhysicalHeight"); // Get specified monitor physical height in millimetres
 680fn int get_monitor_refresh_rate(int monitor) @cname("GetMonitorRefreshRate");       // Get specified monitor refresh rate
 681fn RLVector2 get_window_position() @cname("GetWindowPosition");                       // Get window position XY on monitor
 682fn RLVector2 get_window_scale_dpi() @cname("GetWindowScaleDPI");                    // Get window scale DPI factor
 683fn ZString get_monitor_name(int monitor) @cname("GetMonitorName");                   // Get the human-readable, UTF-8 encoded name of the specified monitor
 684fn void set_clipboard_text(ZString text) @cname("SetClipboardText");                  // Set clipboard text content
 685fn ZString get_clipboard_text() @cname("GetClipboardText");                           // Get clipboard text content
 686fn RLImage get_clipboard_image() @cname("GetClipboardImage");                         // Get clipboard image content
 687fn void enable_event_waiting() @cname("EnableEventWaiting");                          // Enable waiting for events on EndDrawing(), no automatic event polling
 688fn void disable_event_waiting() @cname("DisableEventWaiting");                        // Disable waiting for events on EndDrawing(), automatic events polling
 689
 690// Cursor-related functions
 691fn void show_cursor() @cname("ShowCursor");               // Shows cursor
 692fn void hide_cursor() @cname("HideCursor");               // Hides cursor
 693fn bool is_cursor_hidden() @cname("IsCursorHidden");      // Check if cursor is not visible
 694fn void enable_cursor() @cname("EnableCursor");           // Enables cursor (unlock cursor)
 695fn void disable_cursor() @cname("DisableCursor");         // Disables cursor (lock cursor)
 696fn bool is_cursor_on_screen() @cname("IsCursorOnScreen"); // Check if cursor is on the screen
 697
 698// Drawing-related functions
 699fn void clear_background(RLColor color) @cname("ClearBackground");                              // Set background color (framebuffer clear color)
 700fn void begin_drawing() @cname("BeginDrawing");                                                 // Setup canvas (framebuffer) to start drawing
 701fn void end_drawing() @cname("EndDrawing");                                                     // End canvas drawing and swap buffers (double buffering)
 702fn void begin_mode2d(RLCamera2D camera) @cname("BeginMode2D");                                  // Begin 2D mode with custom camera (2D)
 703fn void end_mode2d() @cname("EndMode2D");                                                       // Ends 2D mode with custom camera
 704fn void begin_mode3d(RLCamera3D camera) @cname("BeginMode3D");                                  // Begin 3D mode with custom camera (3D)
 705fn void end_mode3d() @cname("EndMode3D");                                                       // Ends 3D mode and returns to default 2D orthographic mode
 706fn void begin_texture_mode(RLRenderTexture2D target) @cname("BeginTextureMode");                // Begin drawing to render texture
 707fn void end_texture_mode() @cname("EndTextureMode");                                            // Ends drawing to render texture
 708fn void begin_shader_mode(RLShader shader) @cname("BeginShaderMode");                           // Begin custom shader drawing
 709fn void end_shader_mode() @cname("EndShaderMode");                                              // End custom shader drawing (use default shader)
 710fn void begin_blend_mode(RLBlendMode mode) @cname("BeginBlendMode");                            // Begin blending mode (alpha, additive, multiplied, subtract, custom)
 711fn void end_blend_mode() @cname("EndBlendMode");                                                // End blending mode (reset to default: alpha blending)
 712fn void begin_scissor_mode(int x, int y, int width, int height) @cname("BeginScissorMode"); // Begin scissor mode (define screen area for following drawing)
 713fn void end_scissor_mode() @cname("EndScissorMode");                                            // End scissor mode
 714fn void begin_vr_stereo_mode(RLVrStereoConfig config) @cname("BeginVrStereoMode");              // Begin stereo rendering (requires VR simulator)
 715fn void end_vr_stereo_mode() @cname("EndVrStereoMode");                                         // End stereo rendering (requires VR simulator)
 716
 717// VR stereo config functions for VR simulator
 718fn RLVrStereoConfig load_vr_stereo_config(RLVrDeviceInfo device) @cname("LoadVrStereoConfig"); // Load VR stereo config for VR simulator device parameters
 719fn void unload_vr_stereo_config(RLVrStereoConfig config) @cname("UnloadVrStereoConfig");       // Unload VR stereo config
 720
 721// Shader management functions
 722// NOTE: Shader functionality is not available on OpenGL 1.1
 723fn RLShader load_shader(ZString vs_file_name, ZString fs_file_name) @cname("LoadShader");                     // Load shader from files and bind default locations
 724fn RLShader load_shader_from_memory(ZString vs_code, ZString fs_code) @cname("LoadShaderFromMemory");         // Load shader from code strings and bind default locations
 725fn bool RLShader.is_valid(RLShader shader) @cname("IsShaderValid");                                           // Check if a shader is valid (loaded on GPU)
 726fn int RLShader.get_location(RLShader shader, ZString uniform_name) @cname("GetShaderLocation");             // Get shader uniform location
 727fn int RLShader.get_location_attrib(RLShader shader, ZString attrib_name) @cname("GetShaderLocationAttrib"); // Get shader attribute location
 728fn void RLShader.set_value(RLShader shader, int loc_index, void* value, RLShaderUniformDataType uniform_type) @cname("SetShaderValue"); // Set shader uniform value
 729fn void RLShader.set_value_v(RLShader shader, int loc_index, void* value, RLShaderUniformDataType uniform_type, int count) @cname("SetShaderValueV"); // Set shader uniform value vector
 730fn void RLShader.set_value_matrix(RLShader shader, int loc_index, Mat4 mat) @cname("SetShaderValueMatrix");          // Set shader uniform value (matrix 4x4)
 731fn void RLShader.set_value_texture(RLShader shader, int loc_index, RLTexture2D texture) @cname("SetShaderValueTexture"); // Set shader uniform value and bind the texture (sampler2d)
 732fn void unload_shader(RLShader shader) @cname("UnloadShader");                                                            // Unload shader from GPU memory (VRAM)
 733
 734// Screen-space-related functions
 735fn RLRay get_screen_to_world_ray(RLVector2 position, RLCamera camera) @cname("GetScreenToWorldRay");                               // Get a ray trace from screen position (i.e mouse)
 736fn RLRay get_screen_to_world_ray_ex(RLVector2 position, RLCamera camera, int width, int height) @cname("GetScreenToWorldRayEx"); // Get a ray trace from screen position (i.e mouse) in a viewport
 737fn RLVector2 get_world_to_screen(RLVector3 position, RLCamera camera) @cname("GetWorldToScreen");                                  // Get the screen space position for a 3d world space position
 738fn RLVector2 get_world_to_screen_ex(RLVector3 position, RLCamera camera, int width, int height) @cname("GetWorldToScreenEx");    // Get size position for a 3d world space position
 739fn RLVector2 get_world_to_screen2d(RLVector2 position, RLCamera2D camera) @cname("GetWorldToScreen2D"); // Get the screen space position for a 2d camera world space position
 740fn RLVector2 get_screen_to_world2d(RLVector2 position, RLCamera2D camera) @cname("GetScreenToWorld2D"); // Get the world space position for a 2d camera screen space position
 741fn Mat4 get_camera_matrix(RLCamera camera) @cname("GetCameraMatrix");       // Get camera transform matrix (view matrix)
 742fn Mat4 get_camera_matrix2d(RLCamera2D camera) @cname("GetCameraMatrix2D"); // Get camera 2d transform matrix
 743
 744// Timing-related functions
 745fn void set_target_fps(int fps) @cname("SetTargetFPS"); // Set target FPS (maximum)
 746fn float get_frame_time() @cname("GetFrameTime");        // Get time in seconds for last frame drawn (delta time)
 747fn double get_time() @cname("GetTime");                  // Get elapsed time in seconds since InitWindow()
 748fn int get_fps() @cname("GetFPS");                      // Get current FPS
 749
 750// Custom frame control functions
 751// NOTE: Those functions are intended for advanced users that want full control over the frame processing
 752// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents()
 753// To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL
 754fn void swap_screen_buffer() @cname("SwapScreenBuffer"); // Swap back buffer with front buffer (screen drawing)
 755fn void poll_input_events() @cname("PollInputEvents");   // Register all input events
 756fn void wait_time(double seconds) @cname("WaitTime");    // Wait for some time (halt program execution)
 757
 758// Random values generation functions
 759fn void set_random_seed(uint seed) @cname("SetRandomSeed");                                 // Set the seed for the random number generator
 760fn int get_random_value(int min, int max) @cname("GetRandomValue");                       // Get a random value between min and max (both included)
 761fn int* load_random_sequence(uint count, int min, int max) @cname("LoadRandomSequence"); // Load random values sequence, no values repeated
 762fn void unload_random_sequence(int* sequence) @cname("UnloadRandomSequence");               // Unload random values sequence
 763
 764// Misc. functions
 765fn void take_screenshot(ZString file_name) @cname("TakeScreenshot"); // Takes a screenshot of current screen (filename extension defines format)
 766fn void set_config_flags(RLConfigFlag flags) @cname("SetConfigFlags"); // Setup init configuration flags (view FLAGS)
 767fn void open_url(ZString url) @cname("OpenURL");                   // Open URL with default system browser (if available)
 768
 769// NOTE: Following functions implemented in module [utils]
 770//------------------------------------------------------------------
 771fn void set_trace_log_level(RLTraceLogLevel log_level) @cname("SetTraceLogLevel");         // Set the current threshold (minimum) log level
 772fn void trace_log(RLTraceLogLevel log_level, ZString text, ...) @cname("TraceLog");        // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
 773fn void set_trace_log_callback(RLTraceLogCallback callback) @cname("SetTraceLogCallback"); // Set custom trace log
 774fn void* mem_alloc(uint size) @cname("MemAlloc");                                         // Internal memory allocator
 775fn void* mem_realloc(void* ptr, uint size) @cname("MemRealloc");                          // Internal memory reallocator
 776fn void mem_free(void* ptr) @cname("MemFree");                                             // Internal memory free
 777
 778// Files management functions
 779fn char* load_file_data(ZString file_name, int* data_size) @cname("LoadFileData");                    // Load file data as byte array (read)
 780fn void unload_file_data(char* data) @cname("UnloadFileData");                                         // Unload file data allocated by LoadFileData()
 781fn bool save_file_data(ZString file_name, void* data, int data_size) @cname("SaveFileData");          // Save data to file from byte array (write), returns true on success
 782fn bool export_data_as_code(char* data, int data_size, ZString file_name) @cname("ExportDataAsCode"); // Export data to code (.h), returns true on success
 783fn ZString load_file_text(ZString file_name) @cname("LoadFileText");                                   // Load text data from file (read), returns a '\0' terminated string
 784fn void unload_file_text(ZString file_name) @cname("UnloadFileText");                                  // Unload file text data allocated by LoadFileText()
 785fn bool save_file_text(ZString file_name, ZString text) @cname("SaveFileText");                        // Save text data to file (write), string must be '\0' terminated, returns true on success
 786//------------------------------------------------------------------
 787
 788fn void set_load_file_data_callback(RLLoadFileDataCallback callback) @cname("SetLoadFileDataCallback"); // Set custom file binary data loader
 789fn void set_save_file_data_callback(RLSaveFileDataCallback callback) @cname("SetSaveFileDataCallback"); // Set custom file binary data saver
 790fn void set_load_file_text_callback(RLLoadFileTextCallback callback) @cname("SetLoadFileTextCallback"); // Set custom file text data loader
 791fn void set_save_file_text_callback(RLSaveFileTextCallback callback) @cname("SetSaveFileTextCallback"); // Set custom file text data saver
 792
 793// File system functions
 794fn int file_rename(ZString file_name, ZString file_rename) @cname("FileRename");                            // Rename file (if exists)
 795fn int file_remove(ZString file_name) @cname("FileRemove");                                                 // Remove file (if exists)
 796fn int file_copy(ZString src_path, ZString dst_path) @cname("FileCopy");                                    // Copy file from one path to another, dstPath created if it doesn't exist
 797fn int file_move(ZString src_path, ZString dst_path) @cname("FileMove");                                    // Move file from one directory to another, dstPath created if it doesn't exist
 798fn int file_text_replace(ZString file_name, ZString search, ZString replacement) @cname("FileTextReplace"); // Replace text in an existing file
 799fn int file_text_find_index(ZString file_name, ZString search) @cname("FileTextFindIndex");                 // Find text in existing file
 800
 801fn bool file_exists(ZString file_name) @cname("FileExists");                             // Check if file exists
 802fn bool directory_exists(ZString dir_path) @cname("DirectoryExists");                    // Check if a directory path exists
 803fn bool is_file_extension(ZString file_name, ZString ext) @cname("IsFileExtension");     // Check file extension (recommended include point: .png, .wav)
 804fn int get_file_length(ZString file_name) @cname("GetFileLength");                       // Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)
 805fn CLong get_file_mod_time(ZString file_name) @cname("GetFileModTime");                  // Get file modification time (last write time)
 806fn ZString get_file_extension(ZString file_name) @cname("GetFileExtension");             // Get pointer to extension for a filename string (includes dot: '.png')
 807fn ZString get_file_name(ZString file_path) @cname("GetFileName");                       // Get pointer to filename for a path string
 808fn ZString get_file_name_without_ext(ZString file_path) @cname("GetFileNameWithoutExt"); // Get filename string without extension (uses static string)
 809fn ZString get_directory_path(ZString file_path) @cname("GetDirectoryPath");             // Get full path for a given file_name with path (uses static string)
 810fn ZString get_prev_directory_path(ZString dir_path) @cname("GetPrevDirectoryPath");     // Get previous directory path for a given path (uses static string)
 811fn ZString get_working_directory() @cname("GetWorkingDirectory");                        // Get current working directory (uses static string)
 812fn ZString get_application_directory() @cname("GetApplicationDirectory");                // Get the directory of the running application (uses static string)
 813fn int make_directory(ZString dir_path) @cname("MakeDirectory");                        // Create directories (including full path requested), returns 0 on success
 814fn bool change_directory(ZString dir_path) @cname("ChangeDirectory");                    // Change working directory, return true on success
 815fn bool is_path_file(ZString path) @cname("IsPathFile");                                 // Check if a given path is a file or a directory
 816fn bool is_file_name_valid(ZString file_name) @cname("IsFileNameValid");                 // Check if file_name is valid for the platform/OS
 817fn RLFilePathList load_directory_files(ZString dir_path) @cname("LoadDirectoryFiles");   // Load directory filepaths
 818fn RLFilePathList load_directory_files_ex(ZString base_path, ZString filter, bool scan_subdirs) @cname("LoadDirectoryFilesEx"); // Load directory filepaths with extension filtering and recursive directory scan. Use 'DIR' in the filter string to include directories in the result
 819fn void unload_directory_files(RLFilePathList files) @cname("UnloadDirectoryFiles");     // Unload filepaths
 820fn bool is_file_dropped() @cname("IsFileDropped");                                       // Check if a file has been dropped into window
 821fn RLFilePathList load_dropped_files() @cname("LoadDroppedFiles");                       // Load dropped filepaths
 822fn void unload_dropped_files(RLFilePathList files) @cname("UnloadDroppedFiles");         // Unload dropped filepaths
 823fn uint get_directory_file_count(ZString dir_path) @cname("GetDirectoryFileCount");      // Get the file count in a directory
 824fn uint get_directory_file_count_ex(ZString base_path, ZString filter, bool scan_subdirs) @cname("GetDirectoryFileCountEx"); // Get the file count in a directory with extension filtering and recursive directory scan. Use 'DIR' in the filter string to include directories in the result
 825
 826// Compression/Encoding functionality
 827fn char* compress_data(char* data, int data_size, int* comp_data_size) @cname("CompressData");          // Compress data (DEFLATE algorithm), memory must be MemFree()
 828fn char* decompress_data(char* comp_data, int comp_data_size, int* data_size) @cname("DecompressData"); // Decompress data (DEFLATE algorithm), memory must be MemFree()
 829fn char* encode_data_base64(char* data, int data_size, int* output_size) @cname("EncodeDataBase64");    // Encode data to Base64 string, memory must be MemFree()
 830fn char* decode_data_base64(ZString data, int* output_size) @cname("DecodeDataBase64");                 // Decode Base64 string data, memory must be MemFree()
 831fn uint compute_crc32(char* data, int data_size) @cname("ComputeCRC32");                                // Compute CRC32 hash code
 832fn uint[4]* compute_md5(char* data, int data_size) @cname("ComputeMD5");                                // Compute MD5 hash code, returns static uint[4] (16 bytes)
 833fn uint[5]* compute_sha1(char* data, int data_size) @cname("ComputeSHA1");                              // Compute SHA1 hash code, returns static uint[5] (20 bytes)
 834fn uint[8]* compute_sha256(char* data, int data_size) @cname("ComputeSHA256");                          // Compute SHA256 hash code, returns static int[8] (32 bytes)
 835
 836// Automation events functionality
 837fn RLAutomationEventList load_automation_event_list(ZString file_name) @cname("LoadAutomationEventList");                // Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS
 838fn void unload_automation_event_list(RLAutomationEventList list) @cname("UnloadAutomationEventList");                    // Unload automation events list from file
 839fn bool export_automation_event_list(RLAutomationEventList list, ZString file_name) @cname("ExportAutomationEventList"); // Export automation events list as text file
 840fn void set_automation_event_list(RLAutomationEventList* list) @cname("SetAutomationEventList"); // Set automation event list to record to
 841fn void set_automation_event_base_frame(int frame) @cname("SetAutomationEventBaseFrame");       // Set automation event internal base frame to start recording
 842fn void start_automation_event_recording() @cname("StartAutomationEventRecording");              // Start recording automation events (RLAutomationEventList must be set)
 843fn void stop_automation_event_recording() @cname("StopAutomationEventRecording");                // Stop recording automation events
 844fn void play_automation_event(RLAutomationEvent event) @cname("PlayAutomationEvent");            // Play a recorded automation event
 845
 846//------------------------------------------------------------------------------------
 847// Input Handling Functions (Module: core)
 848//------------------------------------------------------------------------------------
 849
 850// Input-related functions: keyboard
 851fn bool is_key_pressed(RLKeyboardKey key) @cname("IsKeyPressed");              // Check if a key has been pressed once
 852fn bool is_key_pressed_repeat(RLKeyboardKey key) @cname("IsKeyPressedRepeat"); // Check if a key has been pressed again
 853fn bool is_key_down(RLKeyboardKey key) @cname("IsKeyDown");                    // Check if a key is being pressed
 854fn bool is_key_released(RLKeyboardKey key) @cname("IsKeyReleased");            // Check if a key has been released once
 855fn bool is_key_up(RLKeyboardKey key) @cname("IsKeyUp");                        // Check if a key is NOT being pressed
 856fn RLKeyboardKey get_key_pressed() @cname("GetKeyPressed");                    // Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty
 857fn int get_char_pressed() @cname("GetCharPressed");                            // Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty
 858fn ZString get_key_name(int key) @cname("GetKeyName");                         // Get name of a QWERTY key on the current keyboard layout (eg returns string 'q' for KEY_A on an AZERTY keyboard)
 859fn void set_exit_key(RLKeyboardKey key) @cname("SetExitKey");                  // Set a custom key to exit program (default is ESC)
 860
 861// Input-related functions: gamepads
 862fn bool is_gamepad_available(int gamepad) @cname("IsGamepadAvailable");                                    // Check if a gamepad is available
 863fn ZString get_gamepad_name(int gamepad) @cname("GetGamepadName");                                         // Get gamepad internal name id
 864fn bool is_gamepad_button_pressed(int gamepad, RLGamepadButton button) @cname("IsGamepadButtonPressed");   // Check if a gamepad button has been pressed once
 865fn bool is_gamepad_button_down(int gamepad, RLGamepadButton button) @cname("IsGamepadButtonDown");         // Check if a gamepad button is being pressed
 866fn bool is_gamepad_button_released(int gamepad, RLGamepadButton button) @cname("IsGamepadButtonReleased"); // Check if a gamepad button has been released once
 867fn bool is_gamepad_button_up(int gamepad, RLGamepadButton button) @cname("IsGamepadButtonUp");             // Check if a gamepad button is NOT being pressed
 868fn RLGamepadButton get_gamepad_button_pressed() @cname("GetGamepadButtonPressed");                          // Get the last gamepad button pressed
 869fn int get_gamepad_axis_count(int gamepad) @cname("GetGamepadAxisCount");                                 // Get axis count for a gamepad
 870fn float get_gamepad_axis_movement(int gamepad, RLGamepadAxis axis) @cname("GetGamepadAxisMovement");      // Get movement value for a gamepad axis
 871fn int set_gamepad_mappings(ZString mappings) @cname("SetGamepadMappings");                                // Set internal gamepad mappings (SDL_GameControllerDB)
 872fn void set_gamepad_vibration(int gamepad, float left_motor, float right_motor, float duration) @cname("SetGamepadVibration"); // Set gamepad vibration for both motors (duration in seconds)
 873
 874// Input-related functions: mouse
 875fn bool is_mouse_button_pressed(RLMouseButton button) @cname("IsMouseButtonPressed");   // Check if a mouse button has been pressed once
 876fn bool is_mouse_button_down(RLMouseButton button) @cname("IsMouseButtonDown");         // Check if a mouse button is being pressed
 877fn bool is_mouse_button_released(RLMouseButton button) @cname("IsMouseButtonReleased"); // Check if a mouse button has been released once
 878fn bool is_mouse_button_up(RLMouseButton button) @cname("IsMouseButtonUp");             // Check if a mouse button is NOT being pressed
 879fn int get_mouse_x() @cname("GetMouseX");                                              // Get mouse position X
 880fn int get_mouse_y() @cname("GetMouseY");                                              // Get mouse position Y
 881fn RLVector2 get_mouse_position() @cname("GetMousePosition");                           // Get mouse position XY
 882fn RLVector2 get_mouse_delta() @cname("GetMouseDelta");                                 // Get mouse delta between frames
 883fn void set_mouse_position(int x, int y) @cname("SetMousePosition");                  // Set mouse position XY
 884fn void set_mouse_offset(int offset_x, int offset_y) @cname("SetMouseOffset");        // Set mouse offset
 885fn void set_mouse_scale(float scale_x, float scale_y) @cname("SetMouseScale");          // Set mouse scaling
 886fn float get_mouse_wheel_move() @cname("GetMouseWheelMove");                            // Get mouse wheel movement for X or Y, whichever is larger
 887fn RLVector2 get_mouse_wheel_move_v() @cname("GetMouseWheelMoveV");                     // Get mouse wheel movement for both X and Y
 888fn void set_mouse_cursor(RLMouseCursor cursor) @cname("SetMouseCursor");                // Set mouse cursor
 889
 890// Input-related functions: touch
 891fn int get_touch_x() @cname("GetTouchX");                              // Get touch position X for touch point 0 (relative to screen size)
 892fn int get_touch_y() @cname("GetTouchY");                              // Get touch position Y for touch point 0 (relative to screen size)
 893fn RLVector2 get_touch_position(int index) @cname("GetTouchPosition"); // Get touch position XY for a touch point index (relative to screen size)
 894fn int get_touch_point_id(int index) @cname("GetTouchPointId");       // Get touch point identifier for given index
 895fn int get_touch_point_count() @cname("GetTouchPointCount");           // Get number of touch points
 896
 897//------------------------------------------------------------------------------------
 898// Gestures and Touch Handling Functions (Module: rgestures)
 899//------------------------------------------------------------------------------------
 900fn void set_gestures_enabled(RLGesture flags) @cname("SetGesturesEnabled"); // Enable a set of gestures using flags
 901fn bool is_gesture_detected(RLGesture gesture) @cname("IsGestureDetected"); // Check if a gesture have been detected
 902fn RLGesture get_gesture_detected() @cname("GetGestureDetected");           // Get latest detected gesture
 903fn float get_gesture_hold_duration() @cname("GetGestureHoldDuration");    // Get gesture hold time in seconds
 904fn RLVector2 get_gesture_drag_vector() @cname("GetGestureDragVector");    // Get gesture drag vector
 905fn float get_gesture_drag_angle() @cname("GetGestureDragAngle");          // Get gesture drag angle
 906fn RLVector2 get_gesture_pinch_vector() @cname("GetGesturePinchVector");  // Get gesture pinch delta
 907fn float get_gesture_pinch_angle() @cname("GetGesturePinchAngle");        // Get gesture pinch angle
 908
 909//------------------------------------------------------------------------------------
 910// Camera System Functions (Module: rcamera)
 911//------------------------------------------------------------------------------------
 912fn void update_camera(RLCamera* camera, RLCameraMode mode) @cname("UpdateCamera"); // Update camera position for selected mode
 913fn void update_camera_pro(RLCamera* camera, RLVector3 movement, RLVector3 rotation, float zoom) @cname("UpdateCameraPro"); // Update camera movement/rotation
 914
 915//------------------------------------------------------------------------------------
 916// Basic Shapes Drawing Functions (Module: shapes)
 917//------------------------------------------------------------------------------------
 918// Set texture and rectangle to be used on shapes drawing
 919// NOTE: It can be useful when using basic shapes and one single font,
 920// defining a font char white rectangle would allow drawing everything in a single draw call
 921fn void set_shapes_texture(RLTexture2D texture, Rect source) @cname("SetShapesTexture"); // Set texture and rectangle to be used on shapes drawing
 922fn RLTexture2D get_shapes_texture() @cname("GetShapesTexture");                    // Get texture that is used for shapes drawing
 923fn Rect get_shapes_texture_rectangle() @cname("GetShapesTextureRectangle"); // Get texture source rectangle that is used for shapes drawing
 924
 925// Basic shapes drawing functions
 926fn void draw_pixel(int pos_x, int pos_y, RLColor color) @cname("DrawPixel");                                             // Draw a pixel using geometry [Can be slow, use with care]
 927fn void draw_pixel_v(RLVector2 position, RLColor color) @cname("DrawPixelV");                                            // Draw a pixel using geometry (Vector version) [Can be slow, use with care]
 928fn void draw_line(int start_pos_x, int start_pos_y, int end_pos_x, int end_pos_y, RLColor color) @cname("DrawLine");     // Draw a line
 929fn void draw_line_v(RLVector2 start_pos, RLVector2 end_pos, RLColor color) @cname("DrawLineV");                          // Draw a line (using gl lines)
 930fn void draw_line_ex(RLVector2 start_pos, RLVector2 end_pos, float thick, RLColor color) @cname("DrawLineEx");           // Draw a line (using triangles/quads)
 931fn void draw_line_strip(RLVector2* points, int point_count, RLColor color) @cname("DrawLineStrip");                     // Draw lines sequence (using gl lines)
 932fn void draw_line_bezier(RLVector2 start_pos, RLVector2 end_pos, float thick, RLColor color) @cname("DrawLineBezier");   // Draw line segment cubic-bezier in-out interpolation
 933fn void draw_line_dashed(RLVector2 start_pos, RLVector2 end_pos, int dashSize, int spaceSize, RLColor color) @cname("DrawLineDashed");   // Draw a dashed line
 934
 935fn void draw_circle(int center_x, int center_y, float radius, RLColor color) @cname("DrawCircle");                       // Draw a color-filled circle
 936fn void draw_circle_sector(RLVector2 center, float radius, float start_angle, float end_angle, int segments, RLColor color) @cname("DrawCircleSector");            // Draw a piece of a circle
 937fn void draw_circle_sector_lines(RLVector2 center, float radius, float start_angle, float end_angle, int segments, RLColor color) @cname("DrawCircleSectorLines"); // Draw circle sector outline
 938fn void draw_circle_gradient(int center_x, int center_y, float radius, RLColor inner, RLColor outer) @cname("DrawCircleGradient"); // Draw a gradient-filled circle
 939fn void draw_circle_v(RLVector2 center, float radius, RLColor color) @cname("DrawCircleV");                                        // Draw a color-filled circle (Vector version)
 940fn void draw_circle_lines(int center_x, int center_y, float radius, RLColor color) @cname("DrawCircleLines");                      // Draw circle outline
 941fn void draw_circle_lines_v(RLVector2 center, float radius, RLColor color) @cname("DrawCircleLinesV");                             // Draw circle outline (Vector version)
 942fn void draw_ellipse(int center_x, int center_y, float radius_h, float radius_v, RLColor color) @cname("DrawEllipse");             // Draw ellipse
 943fn void draw_ellipse_v(RLVector2 center, float radius_h, float radius_v, RLColor color) @cname("DrawEllipseV");                    // Draw ellipse (Vector version)
 944fn void draw_ellipse_lines(int center_x, int center_y, float radius_h, float radius_v, RLColor color) @cname("DrawEllipseLines");  // Draw ellipse outline
 945fn void draw_ellipse_lines_v(RLVector2 center, float radius_h, float radius_v, RLColor color) @cname("DrawEllipseLinesV");         // Draw ellipse outline (Vector version)
 946
 947fn void draw_ring(RLVector2 center, float inner_radius, float outer_radius, float start_angle, float end_angle, int segments, RLColor color) @cname("DrawRing");            // Draw ring
 948fn void draw_ring_lines(RLVector2 center, float inner_radius, float outer_radius, float start_angle, float end_angle, int segments, RLColor color) @cname("DrawRingLines"); // Draw ring outline
 949fn void draw_rectangle(int pos_x, int pos_y, int width, int height, RLColor color) @cname("DrawRectangle");                                                        // Draw a color-filled rectangle
 950fn void draw_rectangle_v(RLVector2 position, RLVector2 size, RLColor color) @cname("DrawRectangleV");                                                                  // Draw a color-filled rectangle (Vector version)
 951fn void draw_rectangle_rec(Rect rec, RLColor color) @cname("DrawRectangleRec");                                                                                 // Draw a color-filled rectangle
 952fn void draw_rectangle_pro(Rect rec, RLVector2 origin, float rotation, RLColor color) @cname("DrawRectanglePro");                                               // Draw a color-filled rectangle with pro parameters
 953fn void draw_rectangle_gradient_v(int pos_x, int pos_y, int width, int height, RLColor top, RLColor bottom) @cname("DrawRectangleGradientV");                          // Draw a vertical-gradient-filled rectangle
 954fn void draw_rectangle_gradient_h(int pos_x, int pos_y, int width, int height, RLColor left, RLColor right) @cname("DrawRectangleGradientH");                          // Draw a horizontal-gradient-filled rectangle
 955fn void draw_rectangle_gradient_ex(Rect rec, RLColor top_left, RLColor bottom_left, RLColor bottom_right, RLColor top_right) @cname("DrawRectangleGradientEx"); // Draw a gradient-filled rectangle with custom vertex colors
 956fn void draw_rectangle_lines(int pos_x, int pos_y, int width, int height, RLColor color) @cname("DrawRectangleLines");                                                 // Draw rectangle outline
 957fn void draw_rectangle_lines_ex(Rect rec, float line_thick, RLColor color) @cname("DrawRectangleLinesEx");                                                      // Draw rectangle outline with extended parameters
 958fn void draw_rectangle_rounded(Rect rec, float roundness, int segments, RLColor color) @cname("DrawRectangleRounded");                                         // Draw rectangle with rounded edges
 959fn void draw_rectangle_rounded_lines(Rect rec, float roundness, int segments, RLColor color) @cname("DrawRectangleRoundedLines");                              // Draw rectangle lines with rounded edges
 960fn void draw_rectangle_rounded_lines_ex(Rect rec, float roundness, int segments, float line_thick, RLColor color) @cname("DrawRectangleRoundedLinesEx");       // Draw rectangle with rounded edges outline
 961fn void draw_triangle(RLVector2 v1, RLVector2 v2, RLVector2 v3, RLColor color) @cname("DrawTriangle");                                                                 // Draw a color-filled triangle (vertex in counter-clockwise order!)
 962fn void draw_triangle_lines(RLVector2 v1, RLVector2 v2, RLVector2 v3, RLColor color) @cname("DrawTriangleLines");                                                      // Draw triangle outline (vertex in counter-clockwise order!)
 963fn void draw_triangle_fan(RLVector2* points, int point_count, RLColor color) @cname("DrawTriangleFan");                                                                // Draw a triangle fan defined by points (first vertex is the center)
 964fn void draw_triangle_strip(RLVector2* points, int point_count, RLColor color) @cname("DrawTriangleStrip");                                                            // Draw a triangle strip defined by points
 965fn void draw_poly(RLVector2 center, int sides, float radius, float rotation, RLColor color) @cname("DrawPoly");                                                       // Draw a regular polygon (Vector version)
 966fn void draw_poly_lines(RLVector2 center, int sides, float radius, float rotation, RLColor color) @cname("DrawPolyLines");                                            // Draw a polygon outline of n sides
 967fn void draw_poly_lines_ex(RLVector2 center, int sides, float radius, float rotation, float line_thick, RLColor color) @cname("DrawPolyLinesEx");                     // Draw a polygon outline of n sides with extended parameters
 968
 969// Splines drawing functions
 970fn void draw_spline_linear(RLVector2* points, int point_count, float thick, RLColor color) @cname("DrawSplineLinear");                    // Draw spline: Linear, minimum 2 points
 971fn void draw_spline_basis(RLVector2* points, int point_count, float thick, RLColor color) @cname("DrawSplineBasis");                      // Draw spline: B-Spline, minimum 4 points
 972fn void draw_spline_catmull_rom(RLVector2* points, int point_count, float thick, RLColor color) @cname("DrawSplineCatmullRom");           // Draw spline: Catmull-Rom, minimum 4 points
 973fn void draw_spline_bezier_quadratic(RLVector2* points, int point_count, float thick, RLColor color) @cname("DrawSplineBezierQuadratic"); // Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...]
 974fn void draw_spline_bezier_cubic(RLVector2* points, int point_count, float thick, RLColor color) @cname("DrawSplineBezierCubic");         // Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...]
 975fn void draw_spline_segment_linear(RLVector2 p1, RLVector2 p2, float thick, RLColor color) @cname("DrawSplineSegmentLinear");              // Draw spline segment: Linear, 2 points
 976fn void draw_spline_segment_basis(RLVector2 p1, RLVector2 p2, RLVector2 p3, RLVector2 p4, float thick, RLColor color) @cname("DrawSplineSegmentBasis");              // Draw spline segment: B-Spline, 4 points
 977fn void draw_spline_segment_catmull_rom(RLVector2 p1, RLVector2 p2, RLVector2 p3, RLVector2 p4, float thick, RLColor color) @cname("DrawSplineSegmentCatmullRom");   // Draw spline segment: Catmull-Rom, 4 points
 978fn void draw_spline_segment_bezier_quadratic(RLVector2 p1, RLVector2 c2, RLVector2 p3, float thick, RLColor color) @cname("DrawSplineSegmentBezierQuadratic");       // Draw spline segment: Quadratic Bezier, 2 points, 1 control point
 979fn void draw_spline_segment_bezier_cubic(RLVector2 p1, RLVector2 c2, RLVector2 c3, RLVector2 p4, float thick, RLColor color) @cname("DrawSplineSegmentBezierCubic"); // Draw spline segment: Cubic Bezier, 2 points, 2 control points
 980
 981// Spline segment point evaluation functions, for a given t [0.0f .. 1.0f]
 982fn RLVector2 get_spline_point_linear(RLVector2 start_pos, RLVector2 end_pos, float t) @cname("GetSplinePointLinear");                            // Get (evaluate) spline point: Linear
 983fn RLVector2 get_spline_point_basis(RLVector2 p1, RLVector2 p2, RLVector2 p3, RLVector2 p4, float t) @cname("GetSplinePointBasis");              // Get (evaluate) spline point: B-Spline
 984fn RLVector2 get_spline_point_catmull_rom(RLVector2 p1, RLVector2 p2, RLVector2 p3, RLVector2 p4, float t) @cname("GetSplinePointCatmullRom");   // Get (evaluate) spline point: Catmull-Rom
 985fn RLVector2 get_spline_point_bezier_quad(RLVector2 p1, RLVector2 c2, RLVector2 p3, float t) @cname("GetSplinePointBezierQuad");                 // Get (evaluate) spline point: Quadratic Bezier
 986fn RLVector2 get_spline_point_bezier_cubic(RLVector2 p1, RLVector2 c2, RLVector2 c3, RLVector2 p4, float t) @cname("GetSplinePointBezierCubic"); // Get (evaluate) spline point: Cubic Bezier
 987
 988// Basic shapes collision detection functions
 989fn bool check_collision_recs(Rect rec1, Rect rec2) @cname("CheckCollisionRecs");                                           // Check collision between two rectangles
 990fn bool check_collision_circles(RLVector2 center1, float radius1, RLVector2 center2, float radius2) @cname("CheckCollisionCircles");     // Check collision between two circles
 991fn bool check_collision_circle_rec(RLVector2 center, float radius, Rect rec) @cname("CheckCollisionCircleRec");                   // Check collision between circle and rectangle
 992fn bool check_collision_circle_line(RLVector2 center, float radius, RLVector2 p1, RLVector2 p2) @cname("CheckCollisionCircleLine");      // Check if circle collides with a line created betweeen two points [p1] and [p2]
 993fn bool check_collision_point_rec(RLVector2 point, Rect rec) @cname("CheckCollisionPointRec");                                    // Check if point is inside rectangle
 994fn bool check_collision_point_circle(RLVector2 point, RLVector2 center, float radius) @cname("CheckCollisionPointCircle");               // Check if point is inside circle
 995fn bool check_collision_point_triangle(RLVector2 point, RLVector2 p1, RLVector2 p2, RLVector2 p3) @cname("CheckCollisionPointTriangle"); // Check if point is inside a triangle
 996fn bool check_collision_point_line(RLVector2 point, RLVector2 p1, RLVector2 p2, int threshold) @cname("CheckCollisionPointLine");       // Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]
 997fn bool check_collision_point_poly(RLVector2 point, RLVector2* points, int point_count) @cname("CheckCollisionPointPoly");              // Check if point is within a polygon described by array of vertices
 998fn bool check_collision_lines(RLVector2 start_pos1, RLVector2 end_pos1, RLVector2 start_pos2, RLVector2 end_pos2, RLVector2* collision_point) @cname("CheckCollisionLines"); // Check the collision between two lines defined by two points each, returns collision point by reference
 999fn Rect get_collision_rec(Rect rec1, Rect rec2) @cname("GetCollisionRec"); // Get collision rectangle for two rectangles collision
1000
1001//------------------------------------------------------------------------------------
1002// Texture Loading and Drawing Functions (Module: textures)
1003//------------------------------------------------------------------------------------
1004
1005// Image loading functions
1006// NOTE: These functions do not require GPU access
1007fn RLImage load_image(ZString file_name) @cname("LoadImage");                                                               // Load image from file into CPU memory (RAM)
1008fn RLImage load_image_raw(ZString file_name, int width, int height, int format, int headerSize) @cname("LoadImageRaw"); // Load image from RAW file data
1009fn RLImage load_image_anim(ZString file_name, int* frames) @cname("LoadImageAnim");                                        // Load image sequence from file (frames appended to image.data)
1010fn RLImage load_image_anim_from_memory(ZString file_type, char* file_data, int data_size, int* frames) @cname("LoadImageAnimFromMemory"); // Load image sequence from memory buffer
1011fn RLImage load_image_from_memory(ZString file_type, char* file_data, int data_size) @cname("LoadImageFromMemory"); // Load image from memory buffer, file_type refers to extension: i.e. '.png'
1012fn RLImage load_image_from_texture(RLTexture2D texture) @cname("LoadImageFromTexture");                              // Load image from GPU texture data
1013fn RLImage load_image_from_screen() @cname("LoadImageFromScreen");                                                   // Load image from screen buffer and (screenshot)
1014fn bool RLImage.is_valid(RLImage image) @cname("IsImageValid");                                                      // Check if an image is valid (data and parameters)
1015fn void unload_image(RLImage image) @cname("UnloadImage");                                                           // Unload image from CPU memory (RAM)
1016fn bool export_image(RLImage image, ZString file_name) @cname("ExportImage");                                        // Export image data to file, returns true on success
1017fn char* export_image_to_memory(RLImage image, ZString file_type, int* file_size) @cname("ExportImageToMemory");    // Export image to memory buffer
1018fn bool export_image_as_code(RLImage image, ZString file_name) @cname("ExportImageAsCode");                          // Export image as code file defining an array of bytes, returns true on success
1019
1020// Image generation functions
1021fn RLImage gen_image_color(int width, int height, RLColor color) @cname("GenImageColor");                                                  // Generate image: plain color
1022fn RLImage gen_image_gradient_linear(int width, int height, int direction, RLColor start, RLColor end) @cname("GenImageGradientLinear");  // Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient
1023fn RLImage gen_image_gradient_radial(int width, int height, float density, RLColor inner, RLColor outer) @cname("GenImageGradientRadial"); // Generate image: radial gradient
1024fn RLImage gen_image_gradient_square(int width, int height, float density, RLColor inner, RLColor outer) @cname("GenImageGradientSquare"); // Generate image: square gradient
1025fn RLImage gen_image_checked(int width, int height, int checksX, int checksY, RLColor col1, RLColor col2) @cname("GenImageChecked");     // Generate image: checked
1026fn RLImage gen_image_white_noise(int width, int height, float factor) @cname("GenImageWhiteNoise");                                        // Generate image: white noise
1027fn RLImage gen_image_perlin_noise(int width, int height, int offset_x, int offset_y, float scale) @cname("GenImagePerlinNoise");         // Generate image: perlin noise
1028fn RLImage gen_image_cellular(int width, int height, int tile_size) @cname("GenImageCellular");                                           // Generate image: cellular algorithm, bigger tile_size means bigger cells
1029fn RLImage gen_image_text(int width, int height, ZString text) @cname("GenImageText");                                                     // Generate image: grayscale image from text data
1030
1031// Image manipulation functions
1032fn RLImage image_copy(RLImage image) @cname("ImageCopy");                                                                // Create an image duplicate (useful for transformations)
1033fn RLImage image_from_image(RLImage image, Rect rec) @cname("ImageFromImage");                                    // Create an image from another image piece
1034fn RLImage image_from_channel(RLImage image, int selected_channel) @cname("ImageFromChannel");                          // Create an image from a selected channel of another image (GRAYSCALE)
1035fn RLImage image_text(ZString text, int font_size, RLColor color) @cname("ImageText");                                  // Create an image from text (default font)
1036fn RLImage image_text_ex(RLFont font, ZString text, float font_size, float spacing, RLColor tint) @cname("ImageTextEx"); // Create an image from text (custom sprite font)
1037fn void image_format(RLImage* image, RLPixelFormat newFormat) @cname("ImageFormat");                                     // Convert image data to desired format
1038fn void image_to_pot(RLImage* image, RLColor fill) @cname("ImageToPOT");                                                 // Convert image to POT (power-of-two)
1039fn void image_crop(RLImage* image, Rect crop) @cname("ImageCrop");                                                // Crop an image to a defined rectangle
1040fn void image_alpha_crop(RLImage* image, float threshold) @cname("ImageAlphaCrop");                                      // Crop image depending on alpha value
1041fn void image_alpha_clear(RLImage* image, RLColor color, float threshold) @cname("ImageAlphaClear");                     // Clear alpha channel to desired color
1042fn void image_alpha_mask(RLImage* image, RLImage alpha_mask) @cname("ImageAlphaMask");                                   // Apply alpha mask to image
1043fn void image_alpha_premultiply(RLImage* image) @cname("ImageAlphaPremultiply");                                         // Premultiply alpha channel
1044fn void image_blur_gaussian(RLImage* image, int blur_size) @cname("ImageBlurGaussian");                                 // Apply Gaussian blur using a box blur approximation
1045fn void image_kernel_convolution(RLImage* image, float* kernel, int kernel_size) @cname("ImageKernelConvolution");      // Apply custom square convolution kernel to image
1046fn void image_resize(RLImage* image, int new_width, int new_height) @cname("ImageResize");                             // Resize image (Bicubic scaling algorithm)
1047fn void image_resize_nn(RLImage* image, int new_width,int new_height) @cname("ImageResizeNN");                         // Resize image (Nearest-Neighbor scaling algorithm)
1048fn void image_resize_canvas(RLImage* image, int new_width, int new_height, int offset_x, int offset_y, RLColor fill) @cname("ImageResizeCanvas"); // Resize canvas and fill with color
1049fn void image_mipmaps(RLImage* image) @cname("ImageMipmaps");                                                       // Compute all mipmap levels for a provided image
1050fn void image_dither(RLImage* image, int rBpp, int gBpp, int bBpp, int aBpp) @cname("ImageDither");             // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
1051fn void image_flip_vertical(RLImage* image) @cname("ImageFlipVertical");                                            // Flip image vertically
1052fn void image_flip_horizontal(RLImage* image) @cname("ImageFlipHorizontal");                                        // Flip image horizontally
1053fn void image_rotate(RLImage* image, int degrees) @cname("ImageRotate");                                           // Rotate image by input angle in degrees (-359 to 359)
1054fn void image_rotate_cw(RLImage* image) @cname("ImageRotateCW");                                                    // Rotate image clockwise 90deg
1055fn void image_rotate_ccw(RLImage* image) @cname("ImageRotateCCW");                                                  // Rotate image counter-clockwise 90deg
1056fn void image_color_tint(RLImage* image, RLColor color) @cname("ImageColorTint");                                   // Modify image color: tint
1057fn void image_color_invert(RLImage* image) @cname("ImageColorInvert");                                              // Modify image color: invert
1058fn void image_color_grayscale(RLImage* image) @cname("ImageColorGrayscale");                                        // Modify image color: grayscale
1059fn void image_color_contrast(RLImage* image, float contrast) @cname("ImageColorContrast");                          // Modify image color: contrast (-100 to 100)
1060fn void image_color_brightness(RLImage* image, int brightness) @cname("ImageColorBrightness");                     // Modify image color: brightness (-255 to 255)
1061fn void image_color_replace(RLImage* image, RLColor color, RLColor replace) @cname("ImageColorReplace");            // Modify image color: replace color
1062fn RLColor* load_image_colors(RLImage image) @cname("LoadImageColors");                                             // Load color data from image as a RLColor array (RGBA - 32bit)
1063fn RLColor* load_image_palette(RLImage image, int max_palette_size, int* color_count) @cname("LoadImagePalette"); // Load colors palette from image as a RLColor array (RGBA - 32bit)
1064fn void unload_image_colors(RLColor* colors) @cname("UnloadImageColors");                                           // Unload color data loaded with LoadImageColors()
1065fn void unload_image_palette(RLColor* colors) @cname("UnloadImagePalette");                                         // Unload colors palette loaded with LoadImagePalette()
1066fn Rect get_image_alpha_border(RLImage image, float threshold) @cname("GetImageAlphaBorder");                // Get image alpha border rectangle
1067fn RLColor get_image_color(RLImage image, int x, int y) @cname("GetImageColor");                                  // Get image pixel color at (x, y) position
1068
1069// Image drawing functions
1070// NOTE: RLImage software-rendering functions (CPU)
1071fn void image_clear_background(RLImage* dst, RLColor color) @cname("ImageClearBackground");             // Clear image background with given color
1072fn void image_draw_pixel(RLImage* dst, int pos_x, int pos_y, RLColor color) @cname("ImageDrawPixel"); // Draw pixel within an image
1073fn void image_draw_pixel_v(RLImage* dst, RLVector2 position, RLColor color) @cname("ImageDrawPixelV");  // Draw pixel within an image (Vector version)
1074fn void image_draw_line(RLImage* dst, int start_pos_x, int start_pos_y, int end_pos_x, int end_pos_y, RLColor color) @cname("ImageDrawLine"); // Draw line within an image
1075fn void image_draw_line_v(RLImage* dst, RLVector2 start, RLVector2 end, RLColor color) @cname("ImageDrawLineV");                         // Draw line within an image (Vector version)
1076fn void image_draw_line_ex(RLImage* dst, RLVector2 start, RLVector2 end, int thick, RLColor color) @cname("ImageDrawLineEx");           // Draw a line defining thickness within an image
1077fn void image_draw_circle(RLImage* dst, int center_x, int center_y, int radius, RLColor color) @cname("ImageDrawCircle");             // Draw a filled circle within an image
1078fn void image_draw_circle_v(RLImage* dst, RLVector2 center, int radius, RLColor color) @cname("ImageDrawCircleV");                      // Draw a filled circle within an image (Vector version)
1079fn void image_draw_circle_lines(RLImage* dst, int center_x, int center_y, int radius, RLColor color) @cname("ImageDrawCircleLines");  // Draw circle outline within an image
1080fn void image_draw_circle_lines_v(RLImage* dst, RLVector2 center, int radius, RLColor color) @cname("ImageDrawCircleLinesV");           // Draw circle outline within an image (Vector version)
1081fn void image_draw_rectangle(RLImage* dst, int pos_x, int pos_y, int width, int height, RLColor color) @cname("ImageDrawRectangle"); // Draw rectangle within an image
1082fn void image_draw_rectangle_v(RLImage* dst, RLVector2 position, RLVector2 size, RLColor color) @cname("ImageDrawRectangleV");           // Draw rectangle within an image (Vector version)
1083fn void image_draw_rectangle_rec(RLImage* dst, Rect rec, RLColor color) @cname("ImageDrawRectangleRec");                          // Draw rectangle within an image
1084fn void image_draw_rectangle_lines(RLImage* dst, Rect rec, int thick, RLColor color) @cname("ImageDrawRectangleLines");          // Draw rectangle lines within an image
1085fn void image_draw_triangle(RLImage* dst, RLVector2 v1, RLVector2 v2, RLVector2 v3, RLColor color) @cname("ImageDrawTriangle");          // Draw triangle within an image
1086fn void image_draw_triangle_ex(RLImage* dst, RLVector2 v1, RLVector2 v2, RLVector2 v3, RLColor c1, RLColor c2, RLColor c3) @cname("ImageDrawTriangleEx");        // Draw triangle with interpolated colors within an image
1087fn void image_draw_triangle_lines(RLImage* dst, RLVector2 v1, RLVector2 v2, RLVector2 v3, RLColor color) @cname("ImageDrawTriangleLines");                       // Draw triangle outline within an image
1088fn void image_draw_triangle_fan(RLImage* dst, RLVector2* points, int point_count, RLColor color) @cname("ImageDrawTriangleFan");                                // Draw a triangle fan defined by points within an image (first vertex is the center)
1089fn void image_draw_triangle_strip(RLImage* dst, RLVector2* points, int point_count, RLColor color) @cname("ImageDrawTriangleStrip");                            // Draw a triangle strip defined by points within an image
1090fn void image_draw(RLImage* dst, RLImage src, Rect srcRec, Rect dstRec, RLColor tint) @cname("ImageDraw");                                         // Draw a source image within a destination image (tint applied to source)
1091fn void image_draw_text(RLImage* dst, ZString text, int pos_x, int pos_y, int font_size, RLColor color) @cname("ImageDrawText");                              // Draw text (using default font) within an image (destination)
1092fn void image_draw_text_ex(RLImage* dst, RLFont font, ZString text, RLVector2 position, float font_size, float spacing, RLColor tint) @cname("ImageDrawTextEx"); // Draw text (custom sprite font) within an image (destination)
1093
1094// Texture loading functions
1095// NOTE: These functions require GPU access
1096fn RLTexture2D load_texture(ZString file_name) @cname("LoadTexture");                                          // Load texture from file into GPU memory (VRAM)
1097fn RLTexture2D load_texture_from_image(RLImage image) @cname("LoadTextureFromImage");                          // Load texture from image data
1098fn RLTextureCubemap load_texture_cubemap(RLImage image, RLCubemapLayout layout) @cname("LoadTextureCubemap");  // Load cubemap from image, multiple image cubemap layouts supported
1099fn RLRenderTexture2D load_render_texture(int width, int height) @cname("LoadRenderTexture");                 // Load texture for rendering (framebuffer)
1100fn bool RLTexture2D.is_valid(RLTexture2D texture) @cname("IsTextureValid");                                    // Check if a texture is valid (loaded in GPU)
1101fn void unload_texture(RLTexture2D texture) @cname("UnloadTexture");                                           // Unload texture from GPU memory (VRAM)
1102fn bool RLRenderTexture2D.is_valid(RLRenderTexture2D target) @cname("IsRenderTextureValid");                   // Check if a render texture is valid (loaded in GPU)
1103fn void unload_render_texture(RLRenderTexture2D target) @cname("UnloadRenderTexture");                         // Unload render texture from GPU memory (VRAM)
1104fn void RLTexture2D.update(RLTexture2D texture, void* pixels) @cname("UpdateTexture");                         // Update GPU texture with new data (pixels should be able to fill texture)
1105fn void RLTexture2D.update_rec(RLTexture2D texture, Rect rec, void* pixels) @cname("UpdateTextureRec"); // Update GPU texture rectangle with new data (pixels and rec should fit in texture)
1106
1107// Texture configuration functions
1108fn void gen_texture_mipmaps(RLTexture2D* texture) @cname("GenTextureMipmaps");                          // Generate GPU mipmaps for a texture
1109fn void RLTexture2D.set_filter(RLTexture2D texture, RLTextureFilter filter) @cname("SetTextureFilter"); // Set texture scaling filter mode
1110fn void RLTexture2D.set_wrap(RLTexture2D texture, RLTextureWrap wrap) @cname("SetTextureWrap");         // Set texture wrapping mode
1111
1112// Texture drawing functions
1113fn void draw_texture(RLTexture2D texture, int pos_x, int pos_y, RLColor tint) @cname("DrawTexture"); // Draw a RLTexture2D
1114fn void draw_texture_v(RLTexture2D texture, RLVector2 position, RLColor tint) @cname("DrawTextureV");  // Draw a RLTexture2D with position defined as RLVector2
1115fn void draw_texture_ex(RLTexture2D texture, RLVector2 position, float rotation, float scale, RLColor tint) @cname("DrawTextureEx"); // Draw a RLTexture2D with extended parameters
1116fn void draw_texture_rec(RLTexture2D texture, Rect source, RLVector2 position, RLColor tint) @cname("DrawTextureRec");        // Draw a part of a texture defined by a rectangle
1117fn void draw_texture_pro(RLTexture2D texture, Rect source, Rect dest, RLVector2 origin, float rotation, RLColor tint) @cname("DrawTexturePro");               // Draw a part of a texture defined by a rectangle with 'pro' parameters
1118fn void draw_texture_n_patch(RLTexture2D texture, RLNPatchInfo n_patch_info, Rect dest, RLVector2 origin, float rotation, RLColor tint) @cname("DrawTextureNPatch"); // Draws a texture (or part of it) that stretches or shrinks nicely
1119
1120// Color/pixel related functions
1121fn bool RLColor.is_equal(RLColor col1, RLColor col2) @cname("ColorIsEqual");                           // Check if two colors are equal
1122fn RLColor RLColor.fade(RLColor color, float alpha) @cname("Fade");                                    // Get color with alpha applied, alpha goes from 0.0f to 1.0f
1123fn int RLColor.to_int(RLColor color) @cname("ColorToInt");                                            // Get hexadecimal value for a RLColor (0xRRGGBBAA)
1124fn RLVector4 RLColor.normalize(RLColor color) @cname("ColorNormalize");                                // Get RLColor normalized as float [0..1]
1125fn RLColor color_from_normalized(RLVector4 normalized) @cname("ColorFromNormalized");                  // Get RLColor from normalized values [0..1]
1126fn RLVector3 RLColor.to_hsv(RLColor color) @cname("ColorToHSV");                                     // Get HSV values for a RLColor, hue [0..360], saturation/value [0..1]
1127fn RLColor color_from_hsv(float hue, float saturation, float value) @cname("ColorFromHSV");          // Get a RLColor from HSV values, hue [0..360], saturation/value [0..1]
1128fn RLColor RLColor.tint(RLColor color, RLColor tint) @cname("ColorTint");                              // Get color multiplied with another color
1129fn RLColor RLColor.brightness(RLColor color, float factor) @cname("ColorBrightness");                  // Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
1130fn RLColor RLColor.contrast(RLColor color, float contrast) @cname("ColorContrast");                    // Get color with contrast correction, contrast values between -1.0f and 1.0f
1131fn RLColor RLColor.alpha(RLColor color, float alpha) @cname("ColorAlpha");                             // Get color with alpha applied, alpha goes from 0.0f to 1.0f
1132fn RLColor RLColor.alpha_blend(RLColor dst, RLColor src, RLColor tint) @cname("ColorAlphaBlend");      // Get src alpha-blended into dst color with tint
1133fn RLColor RLColor.lerp(RLColor color1, RLColor color2, float factor) @cname("ColorLerp");             // Get color lerp interpolation between two colors, factor [0.0f..1.0f]
1134fn RLColor get_color(uint hex_value) @cname("GetColor");                                              // Get RLColor structure from hexadecimal value
1135fn RLColor get_pixel_color(void* src_ptr, RLPixelFormat format) @cname("GetPixelColor");               // Get RLColor from a source pixel pointer of certain format
1136fn void set_pixel_color(void* dst_ptr, RLColor color, RLPixelFormat format) @cname("SetPixelColor");   // Set color formatted into destination pixel pointer
1137fn int get_pixel_data_size(int width, int height, RLPixelFormat format) @cname("GetPixelDataSize"); // Get pixel data size in bytes for certain format
1138
1139//------------------------------------------------------------------------------------
1140// Font Loading and Text Drawing Functions (Module: text)
1141//------------------------------------------------------------------------------------
1142
1143// Font loading/unloading functions
1144fn RLFont get_font_default() @cname("GetFontDefault");     // Get the default RLFont
1145fn RLFont load_font(ZString file_name) @cname("LoadFont"); // Load font from file into GPU memory (VRAM)
1146fn RLFont load_font_ex(ZString file_name, int font_size, int* codepoints, int codepoint_count) @cname("LoadFontEx"); // Load font from file with extended parameters, use NULL for codepoints and 0 for codepoint_count to load the default character set, font size is provided in pixels height
1147fn RLFont load_font_from_image(RLImage image, RLColor key, int firstChar) @cname("LoadFontFromImage");                 // Load font from RLImage (XNA style)
1148fn RLFont load_font_from_memory(ZString file_type, char* file_data, int data_size, int font_size, int* codepoints, int codepoint_count) @cname("LoadFontFromMemory"); // Load font from memory buffer, file_type refers to extension: i.e. '.ttf'
1149fn bool RLFont.is_valid(RLFont font) @cname("IsFontValid"); // Check if a font is valid (font data loaded, WARNING: GPU texture not checked)
1150fn RLGlyphInfo* load_font_data(char* file_data, int data_size, int font_size, int* codepoints, int codepoint_count, RLFontType type, int *glyph_count) @cname("LoadFontData");             // Load font data for further use
1151fn RLImage gen_image_font_atlas(RLGlyphInfo* glyphs, Rect* *glyphRecs, int glyph_count, int font_size, int padding, int pack_method) @cname("GenImageFontAtlas"); // Generate image font atlas using chars info
1152fn void unload_font_data(RLGlyphInfo* glyphs, int glyph_count) @cname("UnloadFontData"); // Unload font chars info data (RAM)
1153fn void unload_font(RLFont font) @cname("UnloadFont");                                    // Unload font from GPU memory (VRAM)
1154fn bool export_font_as_code(RLFont font, ZString file_name) @cname("ExportFontAsCode");   // Export font as code file, returns true on success
1155
1156// Text drawing functions
1157fn void draw_fps(int pos_x, int pos_y) @cname("DrawFPS"); // Draw current FPS
1158fn void draw_text(ZString text, int pos_x, int pos_y, int font_size, RLColor color) @cname("DrawText"); // Draw text (using default font)
1159fn void draw_text_ex(RLFont font, ZString text, RLVector2 position, float font_size, float spacing, RLColor tint) @cname("DrawTextEx");                                           // Draw text using font and additional parameters
1160fn void draw_text_pro(RLFont font, ZString text, RLVector2 position, RLVector2 origin, float rotation, float font_size, float spacing, RLColor tint) @cname("DrawTextPro");       // Draw text using RLFont and pro parameters (rotation)
1161fn void draw_text_codepoint(RLFont font, int codepoint, RLVector2 position, float font_size, RLColor tint) @cname("DrawTextCodepoint");                                          // Draw one character (codepoint)
1162fn void draw_text_codepoints(RLFont font, int* codepoints, int codepoint_count, RLVector2 position, float font_size, float spacing, RLColor tint) @cname("DrawTextCodepoints"); // Draw multiple character (codepoint)
1163
1164// Text font info functions
1165fn void set_text_line_spacing(int spacing) @cname("SetTextLineSpacing"); // Set vertical line spacing when drawing with line-breaks
1166fn int measure_text(ZString text, int font_size) @cname("MeasureText"); // Measure string width for default font
1167fn RLVector2 measure_text_ex(RLFont font, ZString text, float font_size, float spacing) @cname("MeasureTextEx"); // Measure string size for RLFont
1168fn RLVector2 measure_text_codepoints(RLFont font, int* codepoints, int length, float font_size, float spacing) @cname("MeasureTextCodepoints"); // Measure string size for an existing array of codepoints for Font
1169
1170fn int get_glyph_index(RLFont font, int codepoint) @cname("GetGlyphIndex");               // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found
1171fn RLGlyphInfo get_glyph_info(RLFont font, int codepoint) @cname("GetGlyphInfo");          // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found
1172fn Rect get_glyph_atlas_rec(RLFont font, int codepoint) @cname("GetGlyphAtlasRec"); // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found
1173
1174// Text codepoints management functions (unicode characters)
1175fn char* load_utf8(int* codepoints, int length) @cname("LoadUTF8");                              // Load UTF-8 text encoded from codepoints array
1176fn void unload_utf8(char* text) @cname("UnloadUTF8");                                              // Unload UTF-8 text encoded from codepoints array
1177fn int* load_codepoints(ZString text, int* count) @cname("LoadCodepoints");                      // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter
1178fn void unload_codepoints(int* codepoints) @cname("UnloadCodepoints");                            // Unload codepoints data from memory
1179fn int get_codepoint_count(ZString text) @cname("GetCodepointCount");                             // Get total number of codepoints in a UTF-8 encoded string
1180fn int get_codepoint(ZString text, int* codepoint_size) @cname("GetCodepoint");                  // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
1181fn int get_codepoint_next(ZString text, int* codepoint_size) @cname("GetCodepointNext");         // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
1182fn int get_codepoint_previous(ZString text, int* codepoint_size) @cname("GetCodepointPrevious"); // Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
1183fn ZString codepoint_to_utf8(int codepoint, int* utf8_size) @cname("CodepointToUTF8");           // Encode one codepoint into UTF-8 byte array (array length returned as parameter)
1184
1185// Text strings management functions (no UTF-8 strings, only byte chars)
1186// WARNING 1: Most of these functions use internal static buffers[], it's recommended to store returned data on user-side for re-use
1187// WARNING 2: Some strings allocate memory internally for the returned strings, those strings must be free by user using MemFree()
1188fn ZString* load_text_lines(ZString text, int* count) @cname("LoadTextLines");                     // Load text as separate lines ('\n')
1189fn void unload_text_lines(ZString *text, int line_count) @cname("UnloadTextLines");                // Unload text lines
1190fn int text_copy(ZString dst, ZString src) @cname("TextCopy");                                     // Copy one string to another, returns bytes copied
1191fn bool text_is_equal(ZString text1, ZString text2) @cname("TextIsEqual");                         // Check if two text string are equal
1192fn uint text_length(ZString text) @cname("TextLength");                                            // Get text length, checks for '\0' ending
1193fn ZString text_format(ZString text, ...) @cname("TextFormat");                                    // Text formatting with variables (sprintf() style)
1194fn ZString text_subtext(ZString text, int position, int length) @cname("TextSubtext");             // Get a piece of a text string
1195fn ZString text_remove_spaces(ZString text) @cname("TextRemoveSpaces");                            // Remove text spaces, concat words
1196fn ZString get_text_between(ZString text, ZString begin, ZString end) @cname("GetTextBetween");    // Get text between two strings
1197fn char* text_replace(ZString text, ZString replace, ZString by) @cname("TextReplace");            // Replace text string
1198fn char* text_replace_alloc(ZString text, ZString replace, ZString by) @cname("TextReplaceAlloc"); // Replace text string (WARNING: memory must be freed!)
1199fn ZString text_replace_between(ZString text, ZString begin, ZString end, ZString replacement) @cname("TextReplaceBetween"); // Replace text between two specific strings
1200fn ZString text_replace_between_alloc(ZString text, ZString begin, ZString end, ZString replacement) @cname("TextReplaceBetweenAlloc"); // Replace text between two specific strings (WARNING: memory must be freed!)
1201fn char* text_insert(ZString text, ZString insert, int position) @cname("TextInsert");            // Insert text in a position
1202fn char* text_insert_alloc(ZString text, ZString insert, int position) @cname("TextInsertAlloc");  // Insert text in a position (WARNING: memory must be freed!)
1203fn ZString text_join(ZString* textList, int count, ZString delimiter) @cname("TextJoin");         // Join text strings with delimiter
1204fn ZString* text_split(ZString text, char delimiter, int* count) @cname("TextSplit");             // Split text into multiple strings, using MAX_TEXTSPLIT_COUNT static strings
1205fn void text_append(char* text, ZString append, int* position) @cname("TextAppend");              // Append text at specific position and move cursor!
1206fn int text_find_index(ZString text, ZString search) @cname("TextFindIndex");                     // Find first text occurrence within a string, -1 if not found
1207fn ZString text_to_upper(ZString text) @cname("TextToUpper");   // Get upper case version of provided string
1208fn ZString text_to_lower(ZString text) @cname("TextToLower");   // Get lower case version of provided string
1209fn ZString text_to_pascal(ZString text) @cname("TextToPascal"); // Get Pascal case notation version of provided string
1210fn ZString text_to_snake(ZString text) @cname("TextToSnake");   // Get Snake case notation version of provided string
1211fn ZString text_to_camel(ZString text) @cname("TextToCamel");   // Get Camel case notation version of provided string
1212
1213fn int text_to_integer(ZString text) @cname("TextToInteger"); // Get integer value from text
1214fn float text_to_float(ZString text) @cname("TextToFloat");    // Get float value from text
1215
1216//------------------------------------------------------------------------------------
1217// Basic 3d Shapes Drawing Functions (Module: models)
1218//------------------------------------------------------------------------------------
1219
1220// Basic geometric 3D shapes drawing functions
1221fn void draw_line3d(RLVector3 start_pos, RLVector3 end_pos, RLColor color) @cname("DrawLine3D");                                            // Draw a line in 3D world space
1222fn void draw_point3d(RLVector3 position, RLColor color) @cname("DrawPoint3D");                                                              // Draw a point in 3D space, actually a small line
1223fn void draw_circle3d(RLVector3 center, float radius, RLVector3 rotation_axis, float rotation_angle, RLColor color) @cname("DrawCircle3D"); // Draw a circle in 3D world space
1224fn void draw_triangle3d(RLVector3 v1, RLVector3 v2, RLVector3 v3, RLColor color) @cname("DrawTriangle3D");                      // Draw a color-filled triangle (vertex in counter-clockwise order!)
1225fn void draw_triangle_strip3d(RLVector3* points, int point_count, RLColor color) @cname("DrawTriangleStrip3D");                // Draw a triangle strip defined by points
1226fn void draw_cube(RLVector3 position, float width, float height, float length, RLColor color) @cname("DrawCube");               // Draw cube
1227fn void draw_cube_v(RLVector3 position, RLVector3 size, RLColor color) @cname("DrawCubeV");                                     // Draw cube (Vector version)
1228fn void draw_cube_wires(RLVector3 position, float width, float height, float length, RLColor color) @cname("DrawCubeWires");    // Draw cube wires
1229fn void draw_cube_wires_v(RLVector3 position, RLVector3 size, RLColor color) @cname("DrawCubeWiresV");                          // Draw cube wires (Vector version)
1230fn void draw_sphere(RLVector3 centerPos, float radius, RLColor color) @cname("DrawSphere");                                     // Draw sphere
1231fn void draw_sphere_ex(RLVector3 centerPos, float radius, int rings, int slices, RLColor color) @cname("DrawSphereEx");       // Draw sphere with extended parameters
1232fn void draw_sphere_wires(RLVector3 centerPos, float radius, int rings, int slices, RLColor color) @cname("DrawSphereWires"); // Draw sphere wires
1233fn void draw_cylinder(RLVector3 position, float radius_top, float radius_bottom, float height, int slices, RLColor color) @cname("DrawCylinder");            // Draw a cylinder/cone
1234fn void draw_cylinder_ex(RLVector3 start_pos, RLVector3 end_pos, float start_radius, float end_radius, int sides, RLColor color) @cname("DrawCylinderEx");   // Draw a cylinder with base at start_pos and top at end_pos
1235fn void draw_cylinder_wires(RLVector3 position, float radius_top, float radius_bottom, float height, int slices, RLColor color) @cname("DrawCylinderWires"); // Draw a cylinder/cone wires
1236fn void draw_cylinder_wires_ex(RLVector3 start_pos, RLVector3 end_pos, float start_radius, float end_radius, int sides, RLColor color) @cname("DrawCylinderWiresEx"); // Draw a cylinder wires with base at start_pos and top at end_pos
1237fn void draw_capsule(RLVector3 start_pos, RLVector3 end_pos, float radius, int slices, int rings, RLColor color) @cname("DrawCapsule");            // Draw a capsule with the center of its sphere caps at start_pos and end_pos
1238fn void draw_capsule_wires(RLVector3 start_pos, RLVector3 end_pos, float radius, int slices, int rings, RLColor color) @cname("DrawCapsuleWires"); // Draw capsule wireframe with the center of its sphere caps at start_pos and end_pos
1239fn void draw_plane(RLVector3 centerPos, RLVector2 size, RLColor color) @cname("DrawPlane"); // Draw a plane XZ
1240fn void draw_ray(RLRay ray, RLColor color) @cname("DrawRay");                               // Draw a ray line
1241fn void draw_grid(int slices, float spacing) @cname("DrawGrid");                           // Draw a grid (centered at (0, 0, 0))
1242
1243//------------------------------------------------------------------------------------
1244// Model 3d Loading and Drawing Functions (Module: models)
1245//------------------------------------------------------------------------------------
1246
1247// Model management functions
1248fn RLModel load_model(ZString file_name) @cname("LoadModel");             // Load model from files (meshes and materials)
1249fn RLModel load_model_from_mesh(RLMesh mesh) @cname("LoadModelFromMesh"); // Load model from generated mesh (default material)
1250fn bool RLModel.is_valid(RLModel model) @cname("IsModelValid");           // Check if a model is valid (loaded in GPU, VAO/VBOs)
1251fn void unload_model(RLModel model) @cname("UnloadModel");                // Unload model (including meshes) from memory (RAM and/or VRAM)
1252fn RLBoundingBox RLModel.get_bounding_box(RLModel model) @cname("GetModelBoundingBox"); // Compute model bounding box limits (considers all meshes)
1253
1254// Model drawing functions
1255fn void draw_model(RLModel model, RLVector3 position, float scale, RLColor tint) @cname("DrawModel");                                                                      // Draw a model (with texture if set)
1256fn void draw_model_ex(RLModel model, RLVector3 position, RLVector3 rotation_axis, float rotation_angle, RLVector3 scale, RLColor tint) @cname("DrawModelEx");              // Draw a model with extended parameters
1257fn void draw_model_wires(RLModel model, RLVector3 position, float scale, RLColor tint) @cname("DrawModelWires");                                                           // Draw a model wires (with texture if set)
1258fn void draw_model_wires_ex(RLModel model, RLVector3 position, RLVector3 rotation_axis, float rotation_angle, RLVector3 scale, RLColor tint) @cname("DrawModelWiresEx");   // Draw a model wires (with texture if set) with extended parameters
1259fn void draw_bounding_box(RLBoundingBox box, RLColor color) @cname("DrawBoundingBox");                                                                                     // Draw bounding box (wires)
1260fn void draw_billboard(RLCamera camera, RLTexture2D texture, RLVector3 position, float scale, RLColor tint) @cname("DrawBillboard");                                       // Draw a billboard texture
1261fn void draw_billboard_rec(RLCamera camera, RLTexture2D texture, Rect source, RLVector3 position, RLVector2 size, RLColor tint) @cname("DrawBillboardRec");         // Draw a billboard texture defined by source
1262fn void draw_billboard_pro(RLCamera camera, RLTexture2D texture, Rect source, RLVector3 position, RLVector3 up, RLVector2 size, RLVector2 origin, float rotation, RLColor tint) @cname("DrawBillboardPro"); // Draw a billboard texture defined by source and rotation
1263
1264// Mesh management functions
1265fn void upload_mesh(RLMesh* mesh, bool dynamic) @cname("UploadMesh");                                                            // Upload mesh vertex data in GPU and provide VAO/VBO ids
1266fn void update_mesh_buffer(RLMesh mesh, int index, void* data, int data_size, int offset) @cname("UpdateMeshBuffer");         // Update mesh vertex data in GPU for a specific buffer index
1267fn void unload_mesh(RLMesh mesh) @cname("UnloadMesh");                                                                           // Unload mesh data from CPU and GPU
1268fn void draw_mesh(RLMesh mesh, RLMaterial material, Mat4 transform) @cname("DrawMesh");                                      // Draw a 3d mesh with material and transform
1269fn void draw_mesh_instanced(RLMesh mesh, RLMaterial material, Mat4* transforms, int instances) @cname("DrawMeshInstanced"); // Draw multiple mesh instances with material and different transforms
1270fn RLBoundingBox get_mesh_bounding_box(RLMesh mesh) @cname("GetMeshBoundingBox");       // Compute mesh bounding box limits
1271fn void gen_mesh_tangents(RLMesh* mesh) @cname("GenMeshTangents");                      // Compute mesh tangents
1272fn bool export_mesh(RLMesh mesh, ZString file_name) @cname("ExportMesh");               // Export mesh data to file, returns true on success
1273fn bool export_mesh_as_code(RLMesh mesh, ZString file_name) @cname("ExportMeshAsCode"); // Export mesh as code file (.h) defining multiple arrays of vertex attributes
1274
1275// Mesh generation functions
1276fn RLMesh gen_mesh_poly(int sides, float radius) @cname("GenMeshPoly");                             // Generate polygonal mesh
1277fn RLMesh gen_mesh_plane(float width, float length, int res_x, int res_z) @cname("GenMeshPlane");  // Generate plane mesh (with subdivisions)
1278fn RLMesh gen_mesh_cube(float width, float height, float length) @cname("GenMeshCube");              // Generate cuboid mesh
1279fn RLMesh gen_mesh_sphere(float radius, int rings, int slices) @cname("GenMeshSphere");            // Generate sphere mesh (standard sphere)
1280fn RLMesh gen_mesh_hemi_sphere(float radius, int rings, int slices) @cname("GenMeshHemiSphere");   // Generate half-sphere mesh (no bottom cap)
1281fn RLMesh gen_mesh_cylinder(float radius, float height, int slices) @cname("GenMeshCylinder");      // Generate cylinder mesh
1282fn RLMesh gen_mesh_cone(float radius, float height, int slices) @cname("GenMeshCone");              // Generate cone/pyramid mesh
1283fn RLMesh gen_mesh_torus(float radius, float size, int rad_seg, int sides) @cname("GenMeshTorus"); // Generate torus mesh
1284fn RLMesh gen_mesh_knot(float radius, float size, int rad_seg, int sides) @cname("GenMeshKnot");   // Generate trefoil knot mesh
1285fn RLMesh gen_mesh_heightmap(RLImage heightmap, RLVector3 size) @cname("GenMeshHeightmap");          // Generate heightmap mesh from image data
1286fn RLMesh gen_mesh_cubicmap(RLImage cubicmap, RLVector3 cube_size) @cname("GenMeshCubicmap");        // Generate cubes-based map mesh from image data
1287
1288// Material loading/unloading functions
1289fn RLMaterial* load_materials(ZString file_name, int* materialCount) @cname("LoadMaterials"); // Load materials from model file
1290fn RLMaterial load_material_default() @cname("LoadMaterialDefault");                           // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)
1291fn bool RLMaterial.is_valid(RLMaterial material) @cname("IsMaterialValid");                    // Check if a material is valid (shader assigned, map textures loaded in GPU)
1292fn void unload_material(RLMaterial material) @cname("UnloadMaterial");                         // Unload material from GPU memory (VRAM)
1293fn void RLMaterial.set_texture(RLMaterial* material, RLMaterialMapIndex mapType, RLTexture2D texture) @cname("SetMaterialTexture"); // Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...)
1294fn void RLModel.set_mesh_material(RLModel* model, int meshId, int materialId) @cname("SetModelMeshMaterial");                     // Set material for a mesh
1295
1296// Model animations loading/unloading functions
1297fn RLModelAnimation* load_model_animations_(ZString file_name, int* anim_count) @cname("LoadModelAnimations");                 // Load model animations from file
1298macro RLModelAnimation[] load_model_animations(ZString file_name) { int count; return load_model_animations_(file_name, &count)[:count]; }
1299fn void update_model_animation(RLModel model, RLModelAnimation anim, float frame) @cname("UpdateModelAnimation");               // Update model animation pose (vertex buffers and bone matrices)
1300fn void update_model_animation_ex(RLModel model, RLModelAnimation anim_a, float frame_a, RLModelAnimation anim_b, float frame_b, float blend) @cname("UpdateModelAnimationEx"); // Update model animation pose, blending two animations
1301fn void unload_model_animation(RLModelAnimation anim) @cname("UnloadModelAnimation");                                       // Unload animation data
1302fn void unload_model_animations_(RLModelAnimation* animations, int anim_count) @cname("UnloadModelAnimations");             // Unload animation array data
1303macro void unload_model_animations(RLModelAnimation[] animations) { unload_model_animations_(animations.ptr, (int)animations.len); }
1304fn bool is_model_animation_valid(RLModel model, RLModelAnimation anim) @cname("IsModelAnimationValid");                     // Check model animation skeleton match
1305
1306// Collision detection functions
1307fn bool check_collision_spheres(RLVector3 center1, float radius1, RLVector3 center2, float radius2) @cname("CheckCollisionSpheres");         // Check collision between two spheres
1308fn bool check_collision_boxes(RLBoundingBox box1, RLBoundingBox box2) @cname("CheckCollisionBoxes");                                         // Check collision between two bounding boxes
1309fn bool check_collision_box_sphere(RLBoundingBox box, RLVector3 center, float radius) @cname("CheckCollisionBoxSphere");                     // Check collision between box and sphere
1310fn RLRayCollision RLRay.get_collision_sphere(RLRay ray, RLVector3 center, float radius) @cname("GetRayCollisionSphere");                     // Get collision info between ray and sphere
1311fn RLRayCollision RLRay.get_collision_box(RLRay ray, RLBoundingBox box) @cname("GetRayCollisionBox");                                        // Get collision info between ray and box
1312fn RLRayCollision RLRay.get_collision_mesh(RLRay ray, RLMesh mesh, Mat4 transform) @cname("GetRayCollisionMesh");                        // Get collision info between ray and mesh
1313fn RLRayCollision RLRay.get_collision_triangle(RLRay ray, RLVector3 p1, RLVector3 p2, RLVector3 p3) @cname("GetRayCollisionTriangle");       // Get collision info between ray and triangle
1314fn RLRayCollision RLRay.get_collision_quad(RLRay ray, RLVector3 p1, RLVector3 p2, RLVector3 p3, RLVector3 p4) @cname("GetRayCollisionQuad"); // Get collision info between ray and quad
1315
1316//------------------------------------------------------------------------------------
1317// Audio Loading and Playing Functions (Module: audio)
1318//------------------------------------------------------------------------------------
1319alias RLAudioCallback = fn void(void* bufferData, uint frames);
1320
1321// Audio device management functions
1322fn void init_audio_device() @cname("InitAudioDevice");             // Initialize audio device and context
1323fn void close_audio_device() @cname("CloseAudioDevice");           // Close the audio device and context
1324fn bool is_audio_device_ready() @cname("IsAudioDeviceReady");      // Check if audio device has been initialized successfully
1325fn void set_master_volume(float volume) @cname("SetMasterVolume"); // Set master volume (listener)
1326fn float get_master_volume() @cname("GetMasterVolume");            // Get master volume (listener)
1327
1328// Wave/Sound loading/unloading functions
1329fn RLWave load_wave(ZString file_name) @cname("LoadWave"); // Load wave data from file
1330fn RLWave load_wave_from_memory(ZString file_type, char* file_data, int data_size) @cname("LoadWaveFromMemory"); // Load wave from memory buffer, file_type refers to extension: i.e. '.wav'
1331fn bool RLWave.is_valid(RLWave wave) @cname("IsWaveValid");                                // Checks if wave data is valid (data loaded and parameters)
1332fn RLSound load_sound(ZString file_name) @cname("LoadSound");                              // Load sound from file
1333fn RLSound load_sound_from_wave(RLWave wave) @cname("LoadSoundFromWave");                  // Load sound from wave data
1334fn RLSound load_sound_alias(RLSound source) @cname("LoadSoundAlias");                      // Create a new sound that shares the same sample data as the source sound, does not own the sound data
1335fn bool RLSound.is_valid(RLSound sound) @cname("IsSoundValid");                            // Checks if a sound is valid (data loaded and buffers initialized)
1336fn void RLSound.update(RLSound sound, void* data, int sampleCount) @cname("UpdateSound");  // Update sound buffer with new data  (default data format: 32 bit float, stereo)
1337fn void unload_wave(RLWave wave) @cname("UnloadWave");                                     // Unload wave data
1338fn void unload_sound(RLSound sound) @cname("UnloadSound");                                 // Unload sound
1339fn void unload_sound_alias(RLSound alias_) @cname("UnloadSoundAlias");                     // Unload a sound alias (does not deallocate sample data)
1340fn bool export_wave(RLWave wave, ZString file_name) @cname("ExportWave");                  // Export wave data to file, returns true on success
1341fn bool export_wave_as_code(RLWave wave, ZString file_name) @cname("ExportWaveAsCode");    // Export wave sample data to code (.h), returns true on success
1342
1343// Wave/Sound management functions
1344fn void play_sound(RLSound sound) @cname("PlaySound");                               // Play a sound
1345fn void stop_sound(RLSound sound) @cname("StopSound");                               // Stop playing a sound
1346fn void pause_sound(RLSound sound) @cname("PauseSound");                             // Pause a sound
1347fn void resume_sound(RLSound sound) @cname("ResumeSound");                           // Resume a paused sound
1348fn bool is_sound_playing(RLSound sound) @cname("IsSoundPlaying");                    // Check if a sound is currently playing
1349fn void set_sound_volume(RLSound sound, float volume) @cname("SetSoundVolume");      // Set volume for a sound (1.0 is max level)
1350fn void set_sound_pitch(RLSound sound, float pitch) @cname("SetSoundPitch");         // Set pitch for a sound (1.0 is base level)
1351fn void set_sound_pan(RLSound sound, float pan) @cname("SetSoundPan");               // Set pan for a sound (-1.0 left, 0.0 center, 1.0 right)
1352fn RLWave wave_copy(RLWave wave) @cname("WaveCopy");                                 // Copy a wave to a new wave
1353fn void wave_crop(RLWave* wave, int initFrame, int finalFrame) @cname("WaveCrop"); // Crop a wave to defined frames range
1354fn void wave_format(RLWave* wave, int sample_rate, int sample_size, int channels) @cname("WaveFormat"); // Convert wave data to desired format
1355fn float* load_wave_samples(RLWave wave) @cname("LoadWaveSamples");      // Load samples data from wave as a 32bit float data array
1356fn void unload_wave_samples(float* samples) @cname("UnloadWaveSamples"); // Unload samples data loaded with LoadWaveSamples()
1357
1358// Music management functions
1359fn RLMusic load_music_stream(ZString file_name) @cname("LoadMusicStream"); // Load music stream from file
1360fn RLMusic load_music_stream_from_memory(ZString file_type, char* data, int data_size) @cname("LoadMusicStreamFromMemory"); // Load music stream from data
1361fn bool RLMusic.is_valid(RLMusic music) @cname("IsMusicValid");                     // Checks if a music stream is valid (context and buffers initialized)
1362fn void unload_music_stream(RLMusic music) @cname("UnloadMusicStream");             // Unload music stream
1363fn void play_music_stream(RLMusic music) @cname("PlayMusicStream");                 // Start music playing
1364fn bool is_music_stream_playing(RLMusic music) @cname("IsMusicStreamPlaying");      // Check if music is playing
1365fn void update_music_stream(RLMusic music) @cname("UpdateMusicStream");             // Updates buffers for music streaming
1366fn void stop_music_stream(RLMusic music) @cname("StopMusicStream");                 // Stop music playing
1367fn void pause_music_stream(RLMusic music) @cname("PauseMusicStream");               // Pause music playing
1368fn void resume_music_stream(RLMusic music) @cname("ResumeMusicStream");             // Resume playing paused music
1369fn void seek_music_stream(RLMusic music, float position) @cname("SeekMusicStream"); // Seek music to a position (in seconds)
1370fn void set_music_volume(RLMusic music, float volume) @cname("SetMusicVolume");     // Set volume for music (1.0 is max level)
1371fn void set_music_pitch(RLMusic music, float pitch) @cname("SetMusicPitch");        // Set pitch for a music (1.0 is base level)
1372fn void set_music_pan(RLMusic music, float pan) @cname("SetMusicPan");              // Set pan for a music (-1.0 left, 0.0 center, 1.0 right)
1373fn float RLMusic.get_time_length(RLMusic music) @cname("GetMusicTimeLength");       // Get music time length (in seconds)
1374fn float RLMusic.get_time_played(RLMusic music) @cname("GetMusicTimePlayed");       // Get current music time played (in seconds)
1375
1376// AudioStream management functions
1377fn RLAudioStream load_audio_stream(uint sample_rate, uint sample_size, uint channels) @cname("LoadAudioStream");  // Load audio stream (to stream raw audio pcm data)
1378fn bool RLAudioStream.is_valid(RLAudioStream stream) @cname("IsAudioStreamValid");                                   // Checks if an audio stream is valid (buffers initialized)
1379fn void unload_audio_stream(RLAudioStream stream) @cname("UnloadAudioStream");                                       // Unload audio stream and free memory
1380fn void update_audio_stream(RLAudioStream stream, void* data, int frameCount) @cname("UpdateAudioStream");          // Update audio stream buffers with data
1381fn bool RLAudioStream.is_processed(RLAudioStream stream) @cname("IsAudioStreamProcessed");                           // Check if any audio stream buffers requires refill
1382fn void play_audio_stream(RLAudioStream stream) @cname("PlayAudioStream");                                           // Play audio stream
1383fn void pause_audio_stream(RLAudioStream stream) @cname("PauseAudioStream");                                         // Pause audio stream
1384fn void resume_audio_stream(RLAudioStream stream) @cname("ResumeAudioStream");                                       // Resume audio stream
1385fn bool is_audio_stream_playing(RLAudioStream stream) @cname("IsAudioStreamPlaying");                                // Check if audio stream is playing
1386fn void stop_audio_stream(RLAudioStream stream) @cname("StopAudioStream");                                           // Stop audio stream
1387fn void RLAudioStream.set_volume(RLAudioStream stream, float volume) @cname("SetAudioStreamVolume");                 // Set volume for audio stream (1.0 is max level)
1388fn void RLAudioStream.set_pitch(RLAudioStream stream, float pitch) @cname("SetAudioStreamPitch");                    // Set pitch for audio stream (1.0 is base level)
1389fn void RLAudioStream.set_pan(RLAudioStream stream, float pan) @cname("SetAudioStreamPan");                          // Set pan for audio stream (0.5 is centered)
1390fn void set_audio_stream_buffer_size_default(int size) @cname("SetAudioStreamBufferSizeDefault");                   // Default size for new audio streams
1391fn void RLAudioStream.set_callback(RLAudioStream stream, RLAudioCallback callback) @cname("SetAudioStreamCallback"); // Audio thread callback to request new data
1392
1393fn void attach_audio_stream_processor(RLAudioStream stream, RLAudioCallback processor) @cname("AttachAudioStreamProcessor"); // Attach audio stream processor to stream, receives frames x 2 samples as 'float' (stereo)
1394fn void detach_audio_stream_processor(RLAudioStream stream, RLAudioCallback processor) @cname("DetachAudioStreamProcessor"); // Detach audio stream processor from stream
1395
1396fn void attach_audio_mixed_processor(RLAudioCallback processor) @cname("AttachAudioMixedProcessor"); // Attach audio stream processor to the entire audio pipeline, receives frames x 2 samples as 'float' (stereo)
1397fn void detach_audio_mixed_processor(RLAudioCallback processor) @cname("DetachAudioMixedProcessor"); // Detach audio stream processor from the entire audio pipeline
1398
1399
1400//----------------------------------------------------------------------------------
1401// Additional Raylib.c3 Mode helper macros
1402//----------------------------------------------------------------------------------
1403
1404<*
1405 Setup canvas (framebuffer) to start drawing, then calls [block].
1406 Drawing will end after [block] has finished.
1407*>
1408macro void @drawing(;@body)
1409{
1410	begin_drawing();
1411	defer end_drawing();
1412	@body();
1413}
1414
1415<*
1416 Setup 2D mode with custom camera to start 2D Mode, then calls [block].
1417 Mode2D will end after [block] has finished.
1418*>
1419macro void @mode2d(RLCamera2D camera ;@body)
1420{
1421	begin_mode2d(camera);
1422	defer end_mode2d();
1423	@body();
1424}
1425
1426<*
1427 Setup 3D mode with custom camera to start 2D Mode, then calls [block].
1428 Mode2D will end after [block] has finished.
1429*>
1430macro void @mode3d(RLCamera3D camera ;@body)
1431{
1432	begin_mode3d(camera);
1433	defer end_mode3d();
1434	@body();
1435}
1436
1437<*
1438 Setup texture mode to draw to render texture, then calls [block].
1439 texture mode will end after [block] has finished.
1440*>
1441macro void @texture_mode(RLRenderTexture2D texture ;@body)
1442{
1443	begin_texture_mode(texture);
1444	defer end_texture_mode();
1445	@body();
1446}
1447
1448
1449<*
1450 Setup custom shqder mode then calls [block].
1451 shader mode will end after [block] has finished.
1452*>
1453macro void @shader_mode(RLShader shader ;@body)
1454{
1455	begin_shader_mode(shader);
1456	defer end_shader_mode();
1457	@body();
1458}
1459
1460<*
1461 Setup blending mode, then calls [block].
1462 blend mode will end after [block] has finished.
1463*>
1464macro void @blend_mode(RLBlendMode mode ;@body)
1465{
1466	begin_blend_mode(mode);
1467	defer end_blend_mode();
1468	@body();
1469}
1470
1471<*
1472 Setup scissor mode then calls [block].
1473 scissor mode will end after [block] has finished.
1474*>
1475macro void @scissor_mode(int x, int y, int width, int height ;@body)
1476{
1477	begin_scissor_mode(x, y, width, height);
1478	defer end_scissor_mode();
1479	@body();
1480}
1481
1482<*
1483 Setup stereo rendering mode, then calls [block].
1484 stereo rendering mode will end after [block] has finished.
1485*>
1486macro void @vr_mode(RLVrStereoConfig config ;@body)
1487{
1488	begin_vr_stereo_mode(config);
1489	defer end_vr_stereo_mode();
1490	@body();
1491}
1492
1493
1494<*
1495 Setup rl drawing mode, then calls [block].
1496 rl_begin will end after [block] has finished.
1497*>
1498macro void @rl_mode(int mode ;@body)
1499{
1500	rl_begin(mode);
1501	defer rl_end();
1502	@body();
1503}
1504
1505//----------------------------------------------------------------------------------
1506// Enumerators Definition
1507//----------------------------------------------------------------------------------
1508
1509// System/Window config flags
1510// NOTE: Every bit registers one state (use it with bit masks)
1511// By default all flags are set to 0
1512constdef RLConfigFlag : uint
1513{
1514	VSYNC_HINT         = 0x00000040, // Set to try enabling V-Sync on GPU
1515	FULLSCREEN_MODE    = 0x00000002, // Set to run program in fullscreen
1516	WINDOW_RESIZABLE   = 0x00000004, // Set to allow resizable window
1517	WINDOW_UNDECORATED = 0x00000008, // Set to disable window decoration (frame and buttons)
1518	WINDOW_HIDDEN      = 0x00000080, // Set to hide window
1519	WINDOW_MINIMIZED   = 0x00000200, // Set to minimize window (iconify)
1520	WINDOW_MAXIMIZED   = 0x00000400, // Set to maximize window (expanded to monitor)
1521	WINDOW_UNFOCUSED   = 0x00000800, // Set to window non focused
1522	WINDOW_TOPMOST     = 0x00001000, // Set to window always on top
1523	WINDOW_ALWAYS_RUN  = 0x00000100, // Set to allow windows running while minimized
1524	WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer
1525	WINDOW_HIGHDPI     = 0x00002000, // Set to support HighDPI
1526	MSAA_4X_HINT       = 0x00000020, // Set to try enabling MSAA 4X
1527	INTERLACED_HINT    = 0x00010000  // Set to try enabling interlaced video format (for V3D)
1528}
1529
1530// Keyboard keys (US keyboard layout)
1531// NOTE: Use GetKeyPressed() to allow redefining
1532// required keys for alternative layouts
1533constdef RLKeyboardKey : int
1534{
1535	NONE            = 0,   // Key: NONE; used for no key pressed
1536	// Alphanumeric keys
1537	APOSTROPHE      = 39,  // Key: '
1538	COMMA           = 44,  // Key: ;
1539	MINUS           = 45,  // Key: -
1540	PERIOD          = 46,  // Key: .
1541	SLASH           = 47,  // Key: /
1542	ZERO            = 48,  // Key: 0
1543	ONE             = 49,  // Key: 1
1544	TWO             = 50,  // Key: 2
1545	THREE           = 51,  // Key: 3
1546	FOUR            = 52,  // Key: 4
1547	FIVE            = 53,  // Key: 5
1548	SIX             = 54,  // Key: 6
1549	SEVEN           = 55,  // Key: 7
1550	EIGHT           = 56,  // Key: 8
1551	NINE            = 57,  // Key: 9
1552	SEMICOLON       = 59,  // Key: ,
1553	EQUAL           = 61,  // Key: =
1554	A               = 65,  // Key: A | a
1555	B               = 66,  // Key: B | b
1556	C               = 67,  // Key: C | c
1557	D               = 68,  // Key: D | d
1558	E               = 69,  // Key: E | e
1559	F               = 70,  // Key: F | f
1560	G               = 71,  // Key: G | g
1561	H               = 72,  // Key: H | h
1562	I               = 73,  // Key: I | i
1563	J               = 74,  // Key: J | j
1564	K               = 75,  // Key: K | k
1565	L               = 76,  // Key: L | l
1566	M               = 77,  // Key: M | m
1567	N               = 78,  // Key: N | n
1568	O               = 79,  // Key: O | o
1569	P               = 80,  // Key: P | p
1570	Q               = 81,  // Key: Q | q
1571	R               = 82,  // Key: R | r
1572	S               = 83,  // Key: S | s
1573	T               = 84,  // Key: T | t
1574	U               = 85,  // Key: U | u
1575	V               = 86,  // Key: V | v
1576	W               = 87,  // Key: W | w
1577	X               = 88,  // Key: X | x
1578	Y               = 89,  // Key: Y | y
1579	Z               = 90,  // Key: Z | z
1580	LEFT_BRACKET    = 91,  // Key: [
1581	BACKSLASH       = 92,  // Key: '\'
1582	RIGHT_BRACKET   = 93,  // Key: ]
1583	GRAVE           = 96,  // Key: `
1584	// Function keys
1585	SPACE           = 32,  // Key: Space
1586	ESCAPE          = 256, // Key: Esc
1587	ENTER           = 257, // Key: Enter
1588	TAB             = 258, // Key: Tab
1589	BACKSPACE       = 259, // Key: Backspace
1590	INSERT          = 260, // Key: Ins
1591	DELETE          = 261, // Key: Del
1592	RIGHT           = 262, // Key: Cursor right
1593	LEFT            = 263, // Key: Cursor left
1594	DOWN            = 264, // Key: Cursor down
1595	UP              = 265, // Key: Cursor up
1596	PAGE_UP         = 266, // Key: Page up
1597	PAGE_DOWN       = 267, // Key: Page down
1598	HOME            = 268, // Key: Home
1599	END             = 269, // Key: End
1600	CAPS_LOCK       = 280, // Key: Caps lock
1601	SCROLL_LOCK     = 281, // Key: Scroll down
1602	NUM_LOCK        = 282, // Key: Num lock
1603	PRINT_SCREEN    = 283, // Key: Print screen
1604	PAUSE           = 284, // Key: Pause
1605	F1              = 290, // Key: F1
1606	F2              = 291, // Key: F2
1607	F3              = 292, // Key: F3
1608	F4              = 293, // Key: F4
1609	F5              = 294, // Key: F5
1610	F6              = 295, // Key: F6
1611	F7              = 296, // Key: F7
1612	F8              = 297, // Key: F8
1613	F9              = 298, // Key: F9
1614	F10             = 299, // Key: F10
1615	F11             = 300, // Key: F11
1616	F12             = 301, // Key: F12
1617	LEFT_SHIFT      = 340, // Key: Shift left
1618	LEFT_CONTROL    = 341, // Key: Control left
1619	LEFT_ALT        = 342, // Key: Alt left
1620	LEFT_SUPER      = 343, // Key: Super left
1621	RIGHT_SHIFT     = 344, // Key: Shift right
1622	RIGHT_CONTROL   = 345, // Key: Control right
1623	RIGHT_ALT       = 346, // Key: Alt right
1624	RIGHT_SUPER     = 347, // Key: Super right
1625	KB_MENU         = 348, // Key: KB menu
1626	// Keypad keys
1627	KP_0            = 320, // Key: Keypad 0
1628	KP_1            = 321, // Key: Keypad 1
1629	KP_2            = 322, // Key: Keypad 2
1630	KP_3            = 323, // Key: Keypad 3
1631	KP_4            = 324, // Key: Keypad 4
1632	KP_5            = 325, // Key: Keypad 5
1633	KP_6            = 326, // Key: Keypad 6
1634	KP_7            = 327, // Key: Keypad 7
1635	KP_8            = 328, // Key: Keypad 8
1636	KP_9            = 329, // Key: Keypad 9
1637	KP_DECIMAL      = 330, // Key: Keypad .
1638	KP_DIVIDE       = 331, // Key: Keypad /
1639	KP_MULTIPLY     = 332, // Key: Keypad*
1640	KP_SUBTRACT     = 333, // Key: Keypad -
1641	KP_ADD          = 334, // Key: Keypad +
1642	KP_ENTER        = 335, // Key: Keypad Enter
1643	KP_EQUAL        = 336, // Key: Keypad =
1644	// Android key buttons
1645	BACK            = 4,   // Key: Android back button
1646	MENU            = 82,  // Key: Android menu button
1647	VOLUME_UP       = 24,  // Key: Android volume up button
1648	VOLUME_DOWN     = 25,  // Key: Android volume down button
1649}
1650
1651// Gesture
1652// NOTE: It could be used as flags to enable only some gestures
1653constdef RLGesture : int
1654{
1655	NONE        = 0,   // No gesture
1656	TAP         = 1,   // Tap gesture
1657	DOUBLETAP   = 2,   // Double tap gesture
1658	HOLD        = 4,   // Hold gesture
1659	DRAG        = 8,   // Drag gesture
1660	SWIPE_RIGHT = 16,  // Swipe right gesture
1661	SWIPE_LEFT  = 32,  // Swipe left gesture
1662	SWIPE_UP    = 64,  // Swipe up gesture
1663	SWIPE_DOWN  = 128, // Swipe down gesture
1664	PINCH_IN    = 256, // Pinch in gesture
1665	PINCH_OUT   = 512, // Pinch out gesture
1666}
1667
1668// rlgl.h
1669
1670// OpenGL version
1671constdef RLGlVersion
1672{
1673   OPENGL_11 = 1,           // OpenGL 1.1
1674   OPENGL_21,               // OpenGL 2.1 (GLSL 120)
1675   OPENGL_33,               // OpenGL 3.3 (GLSL 330)
1676   OPENGL_43,               // OpenGL 4.3 (using GLSL 330)
1677   OPENGL_ES_20,            // OpenGL ES 2.0 (GLSL 100)
1678   OPENGL_ES_30             // OpenGL ES 3.0 (GLSL 300 es)
1679}
1680
1681constdef RLFramebufferAttachType : int
1682{
1683	COLOR_CHANNEL0 = 0, // Framebuffer attachment type: color 0
1684	COLOR_CHANNEL1 = 1, // Framebuffer attachment type: color 1
1685	COLOR_CHANNEL2 = 2, // Framebuffer attachment type: color 2
1686	COLOR_CHANNEL3 = 3, // Framebuffer attachment type: color 3
1687	COLOR_CHANNEL4 = 4, // Framebuffer attachment type: color 4
1688	COLOR_CHANNEL5 = 5, // Framebuffer attachment type: color 5
1689	COLOR_CHANNEL6 = 6, // Framebuffer attachment type: color 6
1690	COLOR_CHANNEL7 = 7, // Framebuffer attachment type: color 7
1691	DEPTH = 100,        // Framebuffer attachment type: depth
1692	STENCIL = 200,      // Framebuffer attachment type: stencil
1693}
1694
1695
1696constdef RLFramebufferAttachTextureType : int
1697{
1698	CUBEMAP_POSITIVE_X = 0, // Framebuffer texture attachment type: cubemap, +X side
1699	CUBEMAP_NEGATIVE_X = 1, // Framebuffer texture attachment type: cubemap, -X side
1700	CUBEMAP_POSITIVE_Y = 2, // Framebuffer texture attachment type: cubemap, +Y side
1701	CUBEMAP_NEGATIVE_Y = 3, // Framebuffer texture attachment type: cubemap, -Y side
1702	CUBEMAP_POSITIVE_Z = 4, // Framebuffer texture attachment type: cubemap, +Z side
1703	CUBEMAP_NEGATIVE_Z = 5, // Framebuffer texture attachment type: cubemap, -Z side
1704	TEXTURE2D = 100,        // Framebuffer texture attachment type: texture2d
1705	RENDERBUFFER = 200,     // Framebuffer texture attachment type: renderbuffer
1706}
1707
1708
1709const RL_LINES = 0x0001;     // GL_LINES
1710const RL_TRIANGLES = 0x0004; // GL_TRIANGLES
1711const RL_QUADS = 0x0007;     // GL_QUADS
1712
1713//------------------------------------------------------------------------------------
1714// Functions Declaration - Mat4 operations
1715//------------------------------------------------------------------------------------
1716fn void gl_matrix_mode(int mode) @cname("rlMatrixMode");                       // Choose the current matrix to be transformed
1717fn void gl_push_matrix() @cname("rlPushMatrix");                                // Push the current matrix to stack
1718fn void gl_pop_matrix() @cname("rlPopMatrix");                                  // Pop latest inserted matrix from stack
1719fn void gl_load_identity() @cname("rlLoadIdentity");                            // Reset current matrix to identity matrix
1720fn void gl_translatef(float x, float y, float z) @cname("rlTranslatef");        // Multiply the current matrix by a translation matrix
1721fn void gl_rotatef(float angle, float x, float y, float z) @cname("rlRotatef"); // Multiply the current matrix by a rotation matrix
1722fn void gl_scalef(float x, float y, float z) @cname("rlScalef");                // Multiply the current matrix by a scaling matrix
1723fn void gl_mult_matrixf(float* matf) @cname("rlMultMatrixf");                   // Multiply the current matrix by another matrix
1724fn void gl_frustum(double left, double right, double bottom, double top, double znear, double zfar) @cname("rlFrustum");
1725fn void gl_ortho(double left, double right, double bottom, double top, double znear, double zfar) @cname("rlOrtho");
1726fn void gl_viewport(int x, int y, int width, int height) @cname("rlViewport");  // Set the viewport area
1727fn void gl_set_clip_planes(double near_plane, double far_plane) @cname("rlSetClipPlanes"); // Set clip planes distances
1728fn double gl_get_cull_distance_near() @cname("rlGetCullDistanceNear");                        // Get cull plane distance near
1729fn double gl_get_cull_distance_far() @cname("rlGetCullDistanceFar");                    // Get cull plane distance far
1730
1731//------------------------------------------------------------------------------------
1732// Functions Declaration - Vertex level operations
1733//------------------------------------------------------------------------------------
1734fn void gl_begin(int mode) @cname("rlBegin");                 // Initialize drawing mode (how to organize vertex)
1735fn void gl_end() @cname("rlEnd");                             // Finish vertex providing
1736fn void gl_vertex2i(int x, int y) @cname("rlVertex2i");                       // Define one vertex (position) - 2 int
1737fn void gl_vertex2f(float x, float y) @cname("rlVertex2f");                       // Define one vertex (position) - 2 float
1738fn void gl_vertex3f(float x, float y, float z) @cname("rlVertex3f");         // Define one vertex (position) - 3 float
1739fn void gl_tex_coord2f(float x, float y) @cname("rlTexCoord2f");               // Define one vertex (texture coordinate) - 2 float
1740fn void gl_normal3f(float x, float y, float z) @cname("rlNormal3f");         // Define one vertex (normal) - 3 float
1741fn void gl_color4ub(char r, char g, char b, char a) @cname("rlColor4ub");  // Define one vertex (color) - 4 byte
1742fn void gl_color3f(float x, float y, float z) @cname("rlColor3f");          // Define one vertex (color) - 3 float
1743fn void gl_color4f(float x, float y, float z, float w) @cname("rlColor4f"); // Define one vertex (color) - 4 float
1744
1745//------------------------------------------------------------------------------------
1746// Functions Declaration - OpenGL style functions (common to 1.1, 3.3+, ES2)
1747// NOTE: This functions are used to completely abstract raylib code from OpenGL layer,
1748// some of them are direct wrappers over OpenGL calls, some others are custom
1749//------------------------------------------------------------------------------------
1750
1751// Vertex buffers state
1752fn bool gl_enable_vertex_array(uint vaoId) @cname("rlEnableVertexArray");                           // Enable vertex array (VAO, if supported)
1753fn void gl_disable_vertex_array() @cname("rlDisableVertexArray");                                   // Disable vertex array (VAO, if supported)
1754fn void gl_enable_vertex_buffer(uint id) @cname("rlEnableVertexBuffer");                 // Enable vertex buffer (VBO)
1755fn void gl_disable_vertex_buffer() @cname("rlDisableVertexBuffer");                       // Disable vertex buffer (VBO)
1756fn void gl_enable_vertex_buffer_element(uint id) @cname("rlEnableVertexBufferElement");        // Enable vertex buffer element (VBO element)
1757fn void gl_disable_vertex_buffer_element() @cname("rlDisableVertexBufferElement");              // Disable vertex buffer element (VBO element)
1758fn void gl_enable_vertex_attribute(uint index) @cname("rlEnableVertexAttribute");   // Enable vertex attribute index
1759fn void gl_disable_vertex_attribute(uint index) @cname("rlDisableVertexAttribute"); // Disable vertex attribute index
1760fn void gl_enable_state_pointer(RLShaderAttributeDataType vertex_attrib_type, void* buffer) @cname("rlEnableStatePointer"); // Enable attribute state pointer
1761fn void gl_disable_state_pointer(RLShaderAttributeDataType vertex_attrib_type) @cname("rlDisableStatePointer");             // Disable attribute state pointer
1762
1763// Textures state
1764fn void gl_active_texture_slot(int slot) @cname("rlActiveTextureSlot"); // Select and active a texture slot
1765fn void gl_enable_texture(uint id) @cname("rlEnableTexture");      // Enable texture
1766fn void gl_disable_texture() @cname("rlDisableTexture");               // Disable texture
1767fn void gl_enable_texture_cubemap(uint id) @cname("rlEnableTextureCubemap");    // Enable texture cubemap
1768fn void gl_disable_texture_cubemap() @cname("rlDisableTextureCubemap");          // Disable texture cubemap
1769fn void gl_texture_parameters(uint id, int param, int value) @cname("rlTextureParameters");  // Set texture parameters (filter, wrap)
1770fn void gl_cubemap_parameters(uint id, int param, int value) @cname("rlCubemapParameters"); // Set cubemap parameters (filter, wrap)
1771
1772// Shader state
1773fn void gl_enable_shader(uint id) @cname("rlEnableShader"); // Enable shader program
1774fn void gl_disable_shader() @cname("rlDisableShader");        // Disable shader program
1775
1776// Framebuffer state
1777fn void gl_enable_framebuffer(uint id) @cname("rlEnableFramebuffer");          // Enable render texture (fbo)
1778fn void gl_disable_framebuffer() @cname("rlDisableFramebuffer");                // Disable render texture (fbo), return to default framebuffer
1779fn uint gl_get_active_framebuffer() @cname("rlGetActiveFramebuffer");        // Get the currently active render texture (fbo), 0 for default framebuffer
1780fn void gl_active_draw_buffers(int count) @cname("rlActiveDrawBuffers"); // Activate multiple draw color buffers
1781fn void gl_blit_framebuffer(int src_x, int src_y, int src_width, int src_height, int dst_x, int dst_y, int dst_width, int dst_height, int buffer_mask) @cname("rlBlitFramebuffer"); // Blit active framebuffer to main framebuffer
1782fn void gl_bind_framebuffer(uint target, uint framebuffer) @cname("rlBindFramebuffer"); // Bind framebuffer (FBO)
1783
1784// General render state
1785fn void gl_enable_color_blend() @cname("rlEnableColorBlend");        // Enable color blending
1786fn void gl_disable_color_blend() @cname("rlDisableColorBlend");       // Disable color blending
1787fn void gl_enable_depth_test() @cname("rlEnableDepthTest");        // Enable depth test
1788fn void gl_disable_depth_test() @cname("rlDisableDepthTest");      // Disable depth test
1789fn void gl_enable_depth_mask() @cname("rlEnableDepthMask");         // Enable depth write
1790fn void gl_disable_depth_mask() @cname("rlDisableDepthMask");       // Disable depth write
1791fn void gl_enable_backface_culling() @cname("rlEnableBackfaceCulling");   // Enable backface culling
1792fn void gl_disable_backface_culling() @cname("rlDisableBackfaceCulling"); // Disable backface culling
1793fn void gl_color_mask(bool r, bool g, bool b, bool a) @cname("rlColorMask"); // Color mask control
1794fn void gl_set_cull_face(int mode) @cname("rlSetCullFace"); // Set face culling mode
1795fn void gl_enable_scissor_test() @cname("rlEnableScissorTest");                 // Enable scissor test
1796fn void gl_disable_scissor_test() @cname("rlDisableScissorTest");              // Disable scissor test
1797fn void gl_scissor(int x, int y, int width, int height) @cname("rlScissor"); // Scissor test
1798fn void gl_enable_wire_mode() @cname("rlEnableWireMode");               // Enable wire mode
1799fn void gl_enable_point_mode() @cname("rlEnablePointMode");        // Enable point mode
1800fn void gl_disable_point_mode() @cname("rlDisablePointMode");                  // Disable point mode
1801fn void gl_disable_wire_mode() @cname("rlDisableWireMode");              // Disable wire mode
1802fn void gl_set_line_width(float width) @cname("rlSetLineWidth");    // Set the line drawing width
1803fn float gl_get_line_width() @cname("rlGetLineWidth");             // Get the line drawing width
1804fn void gl_enable_smooth_lines() @cname("rlEnableSmoothLines");            // Enable line aliasing
1805fn void gl_disable_smooth_lines() @cname("rlDisableSmoothLines");           // Disable line aliasing
1806fn void gl_enable_stereo_render() @cname("rlEnableStereoRender");      // Enable stereo rendering
1807fn void gl_disable_stereo_render() @cname("rlDisableStereoRender");    // Disable stereo rendering
1808fn bool gl_is_stereo_render_enabled() @cname("rlIsStereoRenderEnabled"); // Check if stereo render is enabled
1809
1810fn void gl_clear_color(char r, char g, char b, char a) @cname("rlClearColor"); // Clear color buffer with color
1811fn void gl_clear_screen_buffers() @cname("rlClearScreenBuffers");                    // Clear used screen buffers (color and depth)
1812fn void gl_check_errors() @cname("rlCheckErrors");                                       // Check and log OpenGL error codes
1813fn void gl_set_blend_mode(RLBlendMode mode) @cname("rlSetBlendMode");             // Set blending mode
1814fn void gl_set_blend_factors(int gl_src_factor, int gl_dst_factor, int gl_equation) @cname("rlSetBlendFactors"); // Set blending mode factor and equation (using OpenGL factors)
1815fn void gl_set_blend_factors_separate(int gl_src_rgb, int gl_dst_rgb, int gl_src_alpha, int gl_dst_alpha, int gl_eq_rgb, int gl_eq_alpha) @cname("rlSetBlendFactorsSeparate"); // Set blending mode factors and equations separately (using OpenGL factors)
1816
1817
1818//------------------------------------------------------------------------------------
1819// Functions Declaration - rlgl functionality
1820//------------------------------------------------------------------------------------
1821// rlgl initialization functions
1822fn void gl_init(int width, int height) @cname("rlglInit");         // Initialize rlgl (buffers, shaders, textures, states)
1823fn void gl_close() @cname("rlglClose");                       // De-initialize rlgl (buffers, shaders, textures)
1824fn void gl_load_extensions(void* loader) @cname("rlglInit");                    // Load OpenGL extensions (loader function required)
1825fn int gl_get_version() @cname("rlGetVersion");                            // Get current OpenGL version
1826fn void gl_set_framebuffer_width(int width) @cname("rlSetFramebufferWidth");        // Set current framebuffer width
1827fn int gl_get_framebuffer_width() @cname("rlGetFramebufferWidth");                      // Get default framebuffer width
1828fn void gl_set_framebuffer_height(int height) @cname("rlSetFramebufferHeight"); // Set current framebuffer height
1829fn int gl_get_framebuffer_height() @cname("rlGetFramebufferHeight");            // Get default framebuffer height
1830
1831fn uint gl_get_texture_id_default() @cname("rlGetTextureIdDefault"); // Get default texture id
1832fn uint gl_get_shader_id_default() @cname("rlGetShaderIdDefault");  // Get default shader id
1833fn int* gl_get_shader_locs_default() @cname("rlGetShaderLocsDefault"); // Get default shader locations
1834
1835// Render batch management
1836// NOTE: rlgl provides a default render batch to behave like OpenGL 1.1 immediate mode
1837// but this render batch API is exposed in case of custom batches are required
1838fn void gl_set_texture(uint id) @cname("rlSetTexture"); // Set current texture for render batch and check buffers limits
1839
1840// Vertex buffers management
1841fn uint gl_load_vertex_array() @cname("rlLoadVertexArray");             // Load vertex array (vao) if supported
1842fn uint gl_load_vertex_buffer(void* buffer, int size, bool dynamic) @cname("rlLoadVertexBuffer"); // Load a vertex buffer object
1843fn uint gl_load_vertex_buffer_element(void* buffer, int size, bool is_dynamic) @cname("rlLoadVertexBufferElement"); // Load vertex buffer elements object
1844fn void gl_update_vertex_buffer(uint buffer_id, void* data, int data_size, int offset) @cname("rlUpdateVertexBuffer"); // Update vertex buffer object data on GPU buffer
1845fn void gl_update_vertex_buffer_elements(uint id, void* data, int data_size, int offset) @cname("rlUpdateVertexBufferElements"); // Update vertex buffer elements data on GPU buffer
1846fn void gl_unload_vertex_array(uint vao_id) @cname("rlUnloadVertexArray");     // Unload vertex array (vao)
1847fn void gl_unload_vertex_buffer(uint vbo_id) @cname("rlUnloadVertexBuffer");    // Unload vertex buffer object
1848fn void gl_set_vertex_attribute(uint index, int comp_size, int type, bool normalized, int stride, int offset) @cname("rlSetVertexAttribute"); // Set vertex attribute data configuration
1849fn void gl_set_vertex_attribute_divisor(uint index, int divisor) @cname("rlSetVertexAttributeDivisor"); // Set vertex attribute data divisor
1850fn void gl_set_vertex_attribute_default(int loc_index, void* value, int attrib_type, int count) @cname("rlSetVertexAttributeDefault"); // Set vertex attribute default value, when attribute to provided
1851fn void gl_draw_vertex_array(int offset, int count) @cname("rlDrawVertexArray");    // Draw vertex array (currently active vao)
1852fn void gl_draw_vertex_array_elements(int offset, int count, void* buffer) @cname("rlDrawVertexArrayElements"); // Draw vertex array elements
1853fn void gl_draw_vertex_array_instanced(int offset, int count, int instances) @cname("rlDrawVertexArrayInstanced"); // Draw vertex array (currently active vao) with instancing
1854fn void gl_draw_vertex_array_elements_instanced(int offset, int count, void* buffer, int instances) @cname("rlDrawVertexArrayElementsInstanced"); // Draw vertex array elements with instancing
1855
1856// Textures management
1857fn uint gl_load_texture(void* data, int width, int height, int format, int mipmap_count) @cname("rlLoadTexture"); // Load texture data
1858fn uint gl_load_texture_depth(int width, int height, bool use_render_buffer) @cname("rlLoadTextureDepth"); // Load depth texture/renderbuffer (to be attached to fbo)
1859fn uint gl_load_texture_cubemap(void* data, int size, int format, int mipmap_count) @cname("rlLoadTextureCubemap"); // Load texture cubemap data
1860fn void gl_update_texture(uint id, int offset_x, int offset_y, int width, int height, int format, void* data) @cname("rlUpdateTexture"); // Update texture with new data on GPU
1861fn void gl_get_gl_texture_formats(int format, uint* gl_internal_format, uint* gl_format, uint* gl_type) @cname("rlGetGlTextureFormats"); // Get OpenGL internal formats
1862fn char* gl_get_pixel_format_name(uint format) @cname("rlGetPixelFormatName");              // Get name string for pixel format
1863fn void gl_unload_texture(uint id) @cname("rlUnloadTexture");                              // Unload texture from GPU memory
1864fn void gl_gen_texture_mipmaps(uint id, int width, int height, int format, int *mipmaps) @cname("rlGenTextureMipmaps"); // Generate mipmap data for selected texture
1865fn void* gl_read_texture_pixels(uint id, int width, int height, int format) @cname("rlReadTexturePixels"); // Read texture pixel data
1866fn char* gl_read_screen_pixels(int width, int height) @cname("rlReadScreenPixels");           // Read screen pixel data (color buffer)
1867
1868// Framebuffer management (fbo)
1869fn uint gl_load_framebuffer() @cname("rlLoadFramebuffer");                               // Load an empty framebuffer
1870fn void gl_framebuffer_attach(uint fbo_id, uint tex_id, int attach_type, int tex_type, int mip_level) @cname("rlFramebufferAttach"); // Attach texture/renderbuffer to a framebuffer
1871fn bool gl_framebuffer_complete(uint id) @cname("rlFramebufferComplete");                        // Verify framebuffer is complete
1872fn void gl_unload_framebuffer(uint id) @cname("rlUnloadFramebuffer");                          // Delete framebuffer from GPU
1873
1874// Shaders management
1875fn uint gl_load_shader_code(char* vs_code, char* fs_code) @cname("rlLoadShaderCode");    // Load shader from code strings
1876fn uint gl_compile_shader(char* shader_code, int type) @cname("rlCompileShader");           // Compile custom shader and return shader id (type: RL_VERTEX_SHADER, RL_FRAGMENT_SHADER, RL_COMPUTE_SHADER)
1877fn uint gl_load_shader_program(uint vshader_id, uint fshader_id) @cname("rlLoadShaderProgram"); // Load custom shader program
1878fn void gl_unload_shader_program(uint id) @cname("rlUnloadShaderProgram");                              // Unload shader program
1879fn int gl_get_location_uniform(uint shader_id, char* uniform_name) @cname("rlGetLocationUniform"); // Get shader location uniform
1880fn int gl_get_location_attrib(uint shader_id, char* attrib_name) @cname("rlGetLocationAttrib");   // Get shader location attribute
1881fn void gl_set_uniform(int loc_index, void* value, int uniform_type, int count) @cname("rlSetUniform"); // Set shader value uniform
1882fn void gl_set_uniform_matrix(int loc_index, Mat4 mat) @cname("rlSetUniformMatrix");                        // Set shader value Mat4
1883fn void gl_set_uniform_matrices(int loc_index, Mat4* mat, int count) @cname("rlSetUniformMatrices");    // Set shader value matrices
1884fn void gl_set_uniform_sampler(int loc_index, uint texture_id) @cname("rlSetUniformSampler");           // Set shader value sampler
1885fn void gl_set_shader(uint id, int* locs) @cname("rlSetShader");                             // Set shader currently active (id and locations)
1886
1887// Compute shader management
1888fn uint gl_load_compute_shader_program(uint shader_id) @cname("rlLoadComputeShaderProgram");           // Load compute shader program
1889fn void gl_compute_shader_dispatch(uint group_x, uint group_y, uint group_z) @cname("rlComputeShaderDispatch"); // Dispatch compute shader (equivalent to *draw* for graphics pipeline)
1890
1891// Shader buffer storage object management (ssbo)
1892fn uint gl_load_shader_buffer(uint size, void* data, int usage_hint) @cname("rlLoadShaderBuffer"); // Load shader storage buffer object (SSBO)
1893fn void gl_unload_shader_buffer(uint ssbo_id) @cname("rlUnloadShaderBuffer");                           // Unload shader storage buffer object (SSBO)
1894fn void gl_update_shader_buffer(uint id, void* data, uint data_size, uint offset) @cname("rlUpdateShaderBuffer"); // Update SSBO buffer data
1895fn void gl_bind_shader_buffer(uint id, uint index) @cname("rlBindShaderBuffer");             // Bind SSBO buffer
1896fn void gl_read_shader_buffer(uint id, void *dest, uint count, uint offset) @cname("rlReadShaderBuffer"); // Read SSBO buffer data (GPU->CPU)
1897fn void gl_copy_shader_buffer(uint dest_id, uint src_id, uint dest_offset, uint src_offset, uint count) @cname("rlCopyShaderBuffer"); // Copy SSBO data between buffers
1898fn uint gl_get_shader_buffer_size(uint id) @cname("rlGetShaderBufferSize");                      // Get SSBO buffer size
1899
1900// Buffer management
1901fn void gl_bind_image_texture(uint id, uint index, int format, bool is_readonly) @cname("rlBindImageTexture");  // Bind image texture
1902
1903// Mat4 state management
1904fn Mat4 gl_get_matrix_modelview() @cname("rlGetMatrixModelview");                                  // Get internal modelview matrix
1905fn Mat4 gl_get_matrix_projection() @cname("rlGetMatrixProjection");                                 // Get internal projection matrix
1906fn Mat4 gl_get_matrix_transform() @cname("rlGetMatrixTransform");                                  // Get internal accumulated transform matrix
1907fn Mat4 gl_get_matrix_projection_stereo(int eye) @cname("rlGetMatrixProjectionStereo");                        // Get internal projection matrix for stereo render (selected eye)
1908fn Mat4 gl_get_matrix_view_offset_stereo(int eye) @cname("rlGetMatrixViewOffsetStereo");                        // Get internal view offset matrix for stereo render (selected eye)
1909fn void gl_set_matrix_projection(Mat4 proj) @cname("rlSetMatrixProjection");                            // Set a custom projection matrix (replaces internal projection matrix)
1910fn void gl_set_matrix_modelview(Mat4 view) @cname("rlSetMatrixModelview");                             // Set a custom modelview matrix (replaces internal modelview matrix)
1911fn void gl_set_matrix_projection_stereo(Mat4 right, Mat4 left) @cname("rlSetMatrixProjectionStereo");        // Set eyes projection matrices for stereo rendering
1912fn void gl_set_matrix_view_offset_stereo(Mat4 right, Mat4 left) @cname("rlSetMatrixViewOffsetStereo");        // Set eyes view offsets matrices for stereo rendering
1913
1914// Quick and dirty cube/quad buffers load->draw->unload
1915fn void gl_load_draw_cube() @cname("rlLoadDrawCube");     // Load and draw a cube
1916fn void gl_load_draw_quad() @cname("rlLoadDrawQuad");     // Load and draw a quad
1917
1918
1919// raymath.h
1920
1921// Decompose a transformation Mat4 into its rotational, translational and scaling components
1922fn void matrix_decompose(Mat4 mat, RLVector3* translation, Quat* rotation, RLVector3* scale) @cname("MatrixDecompose");
1923// Get perspective projection Mat4
1924
1925// Get identity Mat4
1926// Get x-rotation Mat4
1927// NOTE: Angle must be provided in radians
1928fn Mat4 matrix_rotate_x(float angle) @cname("MatrixRotateX");
1929// Get zyx-rotation Mat4
1930// NOTE: Angle must be provided in radians
1931fn Mat4 matrix_rotate_xyz(RLVector3 angle) @cname("MatrixRotateXYZ");
1932// Get zyx-rotation Mat4
1933// NOTE: Angle must be provided in radians
1934fn Mat4 matrix_rotate_zyx(RLVector3 angle) @cname("MatrixRotateZYX");
1935// Get scaling Mat4
1936
1937// Calculate quaternion cubic spline interpolation using Cubic Hermite Spline algorithm
1938// as described in the GLTF 2.0 specification: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#interpolation-cubic
1939fn Quat quaternion_cubic_hermite_spline(Quat q1, Quat out_tangent1, Quat q2, Quat in_tangent2, float t) @cname("QuaternionCubicHermiteSpline");
1940
1941// Get a quaternion for a given rotation Mat4
1942fn Quat quaternion_from_matrix(Mat4 mat) @cname("QuaternionFromMatrix");
1943// Calculate quaternion based on the rotation from one vector to another
1944
1945
1946
1947
1948// rcamera.h
1949// Moves the camera in its forward direction
1950fn void camera_move_forward(RLCamera* camera, float distance, bool move_in_world_plane) @cname("CameraMoveForward");
1951// Moves the camera target in its current right direction
1952fn void camera_move_right(RLCamera* camera, float distance, bool move_in_world_plane) @cname("CameraMoveRight");
1953// Moves the camera position closer/farther to/from the camera target
1954fn void camera_move_to_target(RLCamera* camera, float delta) @cname("CameraMoveToTarget");
1955// Moves the camera in its up direction
1956fn void camera_move_up(RLCamera* camera, float distance) @cname("CameraMoveUp");
1957// Rotates the camera around its right vector, pitch is "looking up and down"
1958//  - lockView prevents camera overrotation (aka "somersaults")
1959//  - rotate_around_target defines if rotation is around target or around its position
1960//  - rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE)
1961// NOTE: angle must be provided in radians
1962fn void camera_pitch(RLCamera* camera, float angle, bool lockView, bool rotate_around_target, bool rotate_up) @cname("CameraPitch");
1963// Rotates the camera around its forward vector
1964// Roll is "turning your head sideways to the left or right"
1965// Note: angle must be provided in radians
1966fn void camera_roll(RLCamera* camera, float angle) @cname("CameraRoll");
1967// Rotates the camera around its up vector
1968// Yaw is "looking left and right"
1969// If rotate_around_target is false, the camera rotates around its position
1970// Note: angle must be provided in radians
1971fn void camera_yaw(RLCamera* camera, float angle, bool rotate_around_target) @cname("CameraYaw");