Update raylib to version 5.5 (#174)

This commit is contained in:
Андрей Краевский 2024-11-25 16:18:03 +03:00 committed by GitHub
parent 90109ff804
commit ff775330c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 677 additions and 201 deletions

View File

@ -4,7 +4,7 @@
Manually tweaked, auto-generated [raylib](https://github.com/raysan5/raylib) bindings for zig.
Bindings tested on raylib version 5.5-dev and Zig 0.13.0
Bindings tested on raylib version 5.5 and Zig 0.13.0
Thanks to all the [contributors](https://github.com/Not-Nik/raylib-zig/graphs/contributors) for their help with this
binding.

View File

@ -3,13 +3,13 @@
.version = "5.5.0",
.dependencies = .{
.raylib = .{
.url = "https://github.com/raysan5/raylib/archive/c4be01329493d0e772a04de08639b4da32905d2a.tar.gz",
.hash = "1220d1c8697d41a42d4eaaf3f8709865534d1f3d6ad63f8a27500fa881380651a1c5",
.url = "https://github.com/raysan5/raylib/archive/c1ab645ca298a2801097931d1079b10ff7eb9df8.tar.gz",
.hash = "1220d93782859726c2c46a05450615b7edfc82b7319daac50cbc7c3345d660b022d7",
},
.raygui = .{
.url = "https://github.com/raysan5/raygui/archive/1e03efca48c50c5ea4b4a053d5bf04bad58d3e43.tar.gz",
.hash = "122062b24f031e68f0d11c91dfc32aed5baf06caf26ed3c80ea1802f9e788ef1c358",
}
},
},
.minimum_zig_version = "0.13.0",
.paths = .{

View File

@ -335,7 +335,6 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str,
"ExportDataAsCode",
"LoadFileData",
"SaveFileData",
"ExportDataAsCode",
"LoadImageFromMemory",
"DrawMeshInstanced",
"UnloadModelAnimations",
@ -343,6 +342,9 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str,
"DecompressData",
"EncodeDataBase64",
"DecodeDataBase64",
"ComputeCRC32",
"ComputeMD5",
"ComputeSHA1",
"SetWindowIcons",
"CheckCollisionPointPoly",
"LoadFontEx",
@ -364,7 +366,7 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str,
"DrawSplineCatmullRom",
"DrawSplineBezierQuadratic",
"DrawSplineBezierCubic",
"ImageKernelConvolution"
"ImageKernelConvolution",
]
if func_name in manual or "FromMemory" in func_name:

View File

@ -1829,7 +1829,7 @@ pub const ShaderLocationIndex = enum(c_int) {
shader_loc_map_brdf = 25,
shader_loc_vertex_boneids = 26,
shader_loc_vertex_boneweights = 27,
shader_loc_bone_matrices = 28
shader_loc_bone_matrices = 28,
};
pub const ShaderUniformDataType = enum(c_int) {
@ -1900,7 +1900,6 @@ pub const CubemapLayout = enum(c_int) {
cubemap_layout_line_horizontal = 2,
cubemap_layout_cross_three_by_four = 3,
cubemap_layout_cross_four_by_three = 4,
cubemap_layout_panorama = 5,
};
pub const FontType = enum(c_int) {
@ -1963,7 +1962,7 @@ pub const AudioCallback = ?*const fn (?*anyopaque, c_uint) callconv(.C) void;
pub const RAYLIB_VERSION_MAJOR = @as(i32, 5);
pub const RAYLIB_VERSION_MINOR = @as(i32, 5);
pub const RAYLIB_VERSION_PATCH = @as(i32, 0);
pub const RAYLIB_VERSION = "5.5-dev";
pub const RAYLIB_VERSION = "5.5";
pub const MAX_TOUCH_POINTS = 10;
pub const MAX_MATERIAL_MAPS = 12;
@ -2064,6 +2063,20 @@ pub fn decodeDataBase64(data: []const u8) []u8 {
return res;
}
pub fn computeCRC32(data: []u8) u32 {
return cdef.ComputeCRC32(data.ptr, data.len);
}
pub fn computeMD5(data: []u8) [4]u32 {
const res: [*]c_int = cdef.ComputeMD5(data.ptr, data.len);
return res[0..4].*;
}
pub fn computeSHA1(data: []u8) [5]u32 {
const res: [*]c_int = cdef.ComputeSHA1(data.ptr, data.len);
return res[0..5].*;
}
pub fn loadImageAnimFromMemory(fileType: [*:0]const u8, fileData: []const u8, frames: *i32) Image {
return cdef.LoadImageAnimFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(fileData)), @as(c_int, @intCast(fileData.len)), @as([*c]c_int, @ptrCast(frames)));
}

View File

@ -38,7 +38,14 @@ pub const rlRenderBatch = extern struct {
currentDepth: f32,
};
pub const rlGlVersion = enum(c_int) { rl_opengl_11 = 1, rl_opengl_21 = 2, rl_opengl_33 = 3, rl_opengl_43 = 4, rl_opengl_es_20 = 5, rl_opengl_es_30 = 6 };
pub const rlGlVersion = enum(c_int) {
rl_opengl_11 = 1,
rl_opengl_21 = 2,
rl_opengl_33 = 3,
rl_opengl_43 = 4,
rl_opengl_es_20 = 5,
rl_opengl_es_30 = 6,
};
pub const rlTraceLogLevel = enum(c_int) {
rl_log_all = 0,
@ -143,7 +150,12 @@ pub const rlShaderUniformDataType = enum(c_uint) {
rl_shader_uniform_sampler2d = 12,
};
pub const rlShaderAttributeDataType = enum(c_uint) { rl_shader_attrib_float = 0, rl_shader_attrib_vec2 = 1, rl_shader_attrib_vec3 = 2, rl_shader_attrib_vec4 = 3 };
pub const rlShaderAttributeDataType = enum(c_uint) {
rl_shader_attrib_float = 0,
rl_shader_attrib_vec2 = 1,
rl_shader_attrib_vec3 = 2,
rl_shader_attrib_vec4 = 3,
};
pub const rlFramebufferAttachType = enum(c_uint) {
rl_attachment_color_channel0 = 0,

View File

@ -48,6 +48,7 @@ pub extern "c" fn GetWindowScaleDPI() rl.Vector2;
pub extern "c" fn GetMonitorName(monitor: c_int) [*c]const u8;
pub extern "c" fn SetClipboardText(text: [*c]const u8) void;
pub extern "c" fn GetClipboardText() [*c]const u8;
pub extern "c" fn GetClipboardImage() rl.Image;
pub extern "c" fn EnableEventWaiting() void;
pub extern "c" fn DisableEventWaiting() void;
pub extern "c" fn ShowCursor() void;
@ -77,7 +78,7 @@ pub extern "c" fn LoadVrStereoConfig(device: rl.VrDeviceInfo) rl.VrStereoConfig;
pub extern "c" fn UnloadVrStereoConfig(config: rl.VrStereoConfig) void;
pub extern "c" fn LoadShader(vsFileName: [*c]const u8, fsFileName: [*c]const u8) rl.Shader;
pub extern "c" fn LoadShaderFromMemory(vsCode: [*c]const u8, fsCode: [*c]const u8) rl.Shader;
pub extern "c" fn IsShaderReady(shader: rl.Shader) bool;
pub extern "c" fn IsShaderValid(shader: rl.Shader) bool;
pub extern "c" fn GetShaderLocation(shader: rl.Shader, uniformName: [*c]const u8) c_int;
pub extern "c" fn GetShaderLocationAttrib(shader: rl.Shader, attribName: [*c]const u8) c_int;
pub extern "c" fn SetShaderValue(shader: rl.Shader, locIndex: c_int, value: *const anyopaque, uniformType: rl.ShaderUniformDataType) void;
@ -149,6 +150,9 @@ pub extern "c" fn CompressData(data: [*c]const u8, dataSize: c_int, compDataSize
pub extern "c" fn DecompressData(compData: [*c]const u8, compDataSize: c_int, dataSize: [*c]c_int) [*c]u8;
pub extern "c" fn EncodeDataBase64(data: [*c]const u8, dataSize: c_int, outputSize: [*c]c_int) [*c]u8;
pub extern "c" fn DecodeDataBase64(data: [*c]const u8, outputSize: [*c]c_int) [*c]u8;
pub extern "c" fn ComputeCRC32(data: [*c]u8, dataSize: c_int) c_uint;
pub extern "c" fn ComputeMD5(data: [*c]u8, dataSize: c_int) [*c]c_uint;
pub extern "c" fn ComputeSHA1(data: [*c]u8, dataSize: c_int) [*c]c_uint;
pub extern "c" fn LoadAutomationEventList(fileName: [*c]const u8) rl.AutomationEventList;
pub extern "c" fn UnloadAutomationEventList(list: rl.AutomationEventList) void;
pub extern "c" fn ExportAutomationEventList(list: rl.AutomationEventList, fileName: [*c]const u8) bool;
@ -175,7 +179,7 @@ pub extern "c" fn GetGamepadButtonPressed() rl.GamepadButton;
pub extern "c" fn GetGamepadAxisCount(gamepad: c_int) c_int;
pub extern "c" fn GetGamepadAxisMovement(gamepad: c_int, axis: c_int) f32;
pub extern "c" fn SetGamepadMappings(mappings: [*c]const u8) c_int;
pub extern "c" fn SetGamepadVibration(gamepad: c_int, leftMotor: f32, rightMotor: f32) void;
pub extern "c" fn SetGamepadVibration(gamepad: c_int, leftMotor: f32, rightMotor: f32, duration: f32) void;
pub extern "c" fn IsMouseButtonPressed(button: rl.MouseButton) bool;
pub extern "c" fn IsMouseButtonDown(button: rl.MouseButton) bool;
pub extern "c" fn IsMouseButtonReleased(button: rl.MouseButton) bool;
@ -263,13 +267,13 @@ pub extern "c" fn GetSplinePointBezierCubic(p1: rl.Vector2, c2: rl.Vector2, c3:
pub extern "c" fn CheckCollisionRecs(rec1: rl.Rectangle, rec2: rl.Rectangle) bool;
pub extern "c" fn CheckCollisionCircles(center1: rl.Vector2, radius1: f32, center2: rl.Vector2, radius2: f32) bool;
pub extern "c" fn CheckCollisionCircleRec(center: rl.Vector2, radius: f32, rec: rl.Rectangle) bool;
pub extern "c" fn CheckCollisionCircleLine(center: rl.Vector2, radius: f32, p1: rl.Vector2, p2: rl.Vector2) bool;
pub extern "c" fn CheckCollisionPointRec(point: rl.Vector2, rec: rl.Rectangle) bool;
pub extern "c" fn CheckCollisionPointCircle(point: rl.Vector2, center: rl.Vector2, radius: f32) bool;
pub extern "c" fn CheckCollisionPointTriangle(point: rl.Vector2, p1: rl.Vector2, p2: rl.Vector2, p3: rl.Vector2) bool;
pub extern "c" fn CheckCollisionPointLine(point: rl.Vector2, p1: rl.Vector2, p2: rl.Vector2, threshold: c_int) bool;
pub extern "c" fn CheckCollisionPointPoly(point: rl.Vector2, points: [*c]const rl.Vector2, pointCount: c_int) bool;
pub extern "c" fn CheckCollisionLines(startPos1: rl.Vector2, endPos1: rl.Vector2, startPos2: rl.Vector2, endPos2: rl.Vector2, collisionPoint: [*c]rl.Vector2) bool;
pub extern "c" fn CheckCollisionPointLine(point: rl.Vector2, p1: rl.Vector2, p2: rl.Vector2, threshold: c_int) bool;
pub extern "c" fn CheckCollisionCircleLine(center: rl.Vector2, radius: f32, p1: rl.Vector2, p2: rl.Vector2) bool;
pub extern "c" fn GetCollisionRec(rec1: rl.Rectangle, rec2: rl.Rectangle) rl.Rectangle;
pub extern "c" fn LoadImage(fileName: [*c]const u8) rl.Image;
pub extern "c" fn LoadImageRaw(fileName: [*c]const u8, width: c_int, height: c_int, format: rl.PixelFormat, headerSize: c_int) rl.Image;
@ -278,7 +282,7 @@ pub extern "c" fn LoadImageAnimFromMemory(fileType: [*c]const u8, fileData: [*c]
pub extern "c" fn LoadImageFromMemory(fileType: [*c]const u8, fileData: [*c]const u8, dataSize: c_int) rl.Image;
pub extern "c" fn LoadImageFromTexture(texture: rl.Texture2D) rl.Image;
pub extern "c" fn LoadImageFromScreen() rl.Image;
pub extern "c" fn IsImageReady(image: rl.Image) bool;
pub extern "c" fn IsImageValid(image: rl.Image) bool;
pub extern "c" fn UnloadImage(image: rl.Image) void;
pub extern "c" fn ExportImage(image: rl.Image, fileName: [*c]const u8) bool;
pub extern "c" fn ExportImageToMemory(image: rl.Image, fileType: [*c]const u8, fileSize: [*c]c_int) [*c]u8;
@ -354,9 +358,9 @@ pub extern "c" fn LoadTexture(fileName: [*c]const u8) rl.Texture2D;
pub extern "c" fn LoadTextureFromImage(image: rl.Image) rl.Texture2D;
pub extern "c" fn LoadTextureCubemap(image: rl.Image, layout: rl.CubemapLayout) rl.TextureCubemap;
pub extern "c" fn LoadRenderTexture(width: c_int, height: c_int) rl.RenderTexture2D;
pub extern "c" fn IsTextureReady(texture: rl.Texture2D) bool;
pub extern "c" fn IsTextureValid(texture: rl.Texture2D) bool;
pub extern "c" fn UnloadTexture(texture: rl.Texture2D) void;
pub extern "c" fn IsRenderTextureReady(target: rl.RenderTexture2D) bool;
pub extern "c" fn IsRenderTextureValid(target: rl.RenderTexture2D) bool;
pub extern "c" fn UnloadRenderTexture(target: rl.RenderTexture2D) void;
pub extern "c" fn UpdateTexture(texture: rl.Texture2D, pixels: *const anyopaque) void;
pub extern "c" fn UpdateTextureRec(texture: rl.Texture2D, rec: rl.Rectangle, pixels: *const anyopaque) void;
@ -391,7 +395,7 @@ pub extern "c" fn LoadFont(fileName: [*c]const u8) rl.Font;
pub extern "c" fn LoadFontEx(fileName: [*c]const u8, fontSize: c_int, codepoints: [*c]c_int, codepointCount: c_int) rl.Font;
pub extern "c" fn LoadFontFromImage(image: rl.Image, key: rl.Color, firstChar: c_int) rl.Font;
pub extern "c" fn LoadFontFromMemory(fileType: [*c]const u8, fileData: [*c]const u8, dataSize: c_int, fontSize: c_int, codepoints: [*c]c_int, codepointCount: c_int) rl.Font;
pub extern "c" fn IsFontReady(font: rl.Font) bool;
pub extern "c" fn IsFontValid(font: rl.Font) bool;
pub extern "c" fn LoadFontData(fileData: [*c]const u8, dataSize: c_int, fontSize: c_int, codepoints: [*c]c_int, codepointCount: c_int, ty: rl.FontType) [*c]rl.GlyphInfo;
pub extern "c" fn GenImageFontAtlas(glyphs: [*c]const rl.GlyphInfo, glyphRecs: [*c][*c]rl.Rectangle, glyphCount: c_int, fontSize: c_int, padding: c_int, packMethod: c_int) rl.Image;
pub extern "c" fn UnloadFontData(glyphs: [*c]rl.GlyphInfo, glyphCount: c_int) void;
@ -459,7 +463,7 @@ pub extern "c" fn DrawRay(ray: rl.Ray, color: rl.Color) void;
pub extern "c" fn DrawGrid(slices: c_int, spacing: f32) void;
pub extern "c" fn LoadModel(fileName: [*c]const u8) rl.Model;
pub extern "c" fn LoadModelFromMesh(mesh: rl.Mesh) rl.Model;
pub extern "c" fn IsModelReady(model: rl.Model) bool;
pub extern "c" fn IsModelValid(model: rl.Model) bool;
pub extern "c" fn UnloadModel(model: rl.Model) void;
pub extern "c" fn GetModelBoundingBox(model: rl.Model) rl.BoundingBox;
pub extern "c" fn DrawModel(model: rl.Model, position: rl.Vector3, scale: f32, tint: rl.Color) void;
@ -494,16 +498,16 @@ pub extern "c" fn GenMeshHeightmap(heightmap: rl.Image, size: rl.Vector3) rl.Mes
pub extern "c" fn GenMeshCubicmap(cubicmap: rl.Image, cubeSize: rl.Vector3) rl.Mesh;
pub extern "c" fn LoadMaterials(fileName: [*c]const u8, materialCount: [*c]c_int) [*c]rl.Material;
pub extern "c" fn LoadMaterialDefault() rl.Material;
pub extern "c" fn IsMaterialReady(material: rl.Material) bool;
pub extern "c" fn IsMaterialValid(material: rl.Material) bool;
pub extern "c" fn UnloadMaterial(material: rl.Material) void;
pub extern "c" fn SetMaterialTexture(material: [*c]rl.Material, mapType: rl.MaterialMapIndex, texture: rl.Texture2D) void;
pub extern "c" fn SetModelMeshMaterial(model: [*c]rl.Model, meshId: c_int, materialId: c_int) void;
pub extern "c" fn LoadModelAnimations(fileName: [*c]const u8, animCount: [*c]c_int) [*c]rl.ModelAnimation;
pub extern "c" fn UpdateModelAnimation(model: rl.Model, anim: rl.ModelAnimation, frame: c_int) void;
pub extern "c" fn UpdateModelAnimationBones(model: rl.Model, anim: rl.ModelAnimation, frame: c_int) void;
pub extern "c" fn UnloadModelAnimation(anim: rl.ModelAnimation) void;
pub extern "c" fn UnloadModelAnimations(animations: [*c]rl.ModelAnimation, animCount: c_int) void;
pub extern "c" fn IsModelAnimationValid(model: rl.Model, anim: rl.ModelAnimation) bool;
pub extern "c" fn UpdateModelAnimationBoneMatrices(model: rl.Model, anim: rl.ModelAnimation, frame: c_int) void;
pub extern "c" fn CheckCollisionSpheres(center1: rl.Vector3, radius1: f32, center2: rl.Vector3, radius2: f32) bool;
pub extern "c" fn CheckCollisionBoxes(box1: rl.BoundingBox, box2: rl.BoundingBox) bool;
pub extern "c" fn CheckCollisionBoxSphere(box: rl.BoundingBox, center: rl.Vector3, radius: f32) bool;
@ -519,11 +523,11 @@ pub extern "c" fn SetMasterVolume(volume: f32) void;
pub extern "c" fn GetMasterVolume() f32;
pub extern "c" fn LoadWave(fileName: [*c]const u8) rl.Wave;
pub extern "c" fn LoadWaveFromMemory(fileType: [*c]const u8, fileData: [*c]const u8, dataSize: c_int) rl.Wave;
pub extern "c" fn IsWaveReady(wave: rl.Wave) bool;
pub extern "c" fn IsWaveValid(wave: rl.Wave) bool;
pub extern "c" fn LoadSound(fileName: [*c]const u8) rl.Sound;
pub extern "c" fn LoadSoundFromWave(wave: rl.Wave) rl.Sound;
pub extern "c" fn LoadSoundAlias(source: rl.Sound) rl.Sound;
pub extern "c" fn IsSoundReady(sound: rl.Sound) bool;
pub extern "c" fn IsSoundValid(sound: rl.Sound) bool;
pub extern "c" fn UpdateSound(sound: rl.Sound, data: *const anyopaque, sampleCount: c_int) void;
pub extern "c" fn UnloadWave(wave: rl.Wave) void;
pub extern "c" fn UnloadSound(sound: rl.Sound) void;
@ -545,7 +549,7 @@ pub extern "c" fn LoadWaveSamples(wave: rl.Wave) [*c]f32;
pub extern "c" fn UnloadWaveSamples(samples: [*c]f32) void;
pub extern "c" fn LoadMusicStream(fileName: [*c]const u8) rl.Music;
pub extern "c" fn LoadMusicStreamFromMemory(fileType: [*c]const u8, data: [*c]const u8, dataSize: c_int) rl.Music;
pub extern "c" fn IsMusicReady(music: rl.Music) bool;
pub extern "c" fn IsMusicValid(music: rl.Music) bool;
pub extern "c" fn UnloadMusicStream(music: rl.Music) void;
pub extern "c" fn PlayMusicStream(music: rl.Music) void;
pub extern "c" fn IsMusicStreamPlaying(music: rl.Music) bool;
@ -560,7 +564,7 @@ pub extern "c" fn SetMusicPan(music: rl.Music, pan: f32) void;
pub extern "c" fn GetMusicTimeLength(music: rl.Music) f32;
pub extern "c" fn GetMusicTimePlayed(music: rl.Music) f32;
pub extern "c" fn LoadAudioStream(sampleRate: c_uint, sampleSize: c_uint, channels: c_uint) rl.AudioStream;
pub extern "c" fn IsAudioStreamReady(stream: rl.AudioStream) bool;
pub extern "c" fn IsAudioStreamValid(stream: rl.AudioStream) bool;
pub extern "c" fn UnloadAudioStream(stream: rl.AudioStream) void;
pub extern "c" fn UpdateAudioStream(stream: rl.AudioStream, data: *const anyopaque, frameCount: c_int) void;
pub extern "c" fn IsAudioStreamProcessed(stream: rl.AudioStream) bool;

104
lib/raylib.h vendored
View File

@ -1,22 +1,22 @@
/**********************************************************************************************
*
* raylib v5.5-dev - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
* raylib v5.5 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
*
* FEATURES:
* - NO external dependencies, all required libraries included with raylib
* - Multiplatform: Windows, Linux, FreeBSD, OpenBSD, NetBSD, DragonFly,
* MacOS, Haiku, Android, Raspberry Pi, DRM native, HTML5.
* - Written in plain C code (C99) in PascalCase/camelCase notation
* - Hardware accelerated with OpenGL (1.1, 2.1, 3.3, 4.3 or ES2 - choose at compile)
* - Hardware accelerated with OpenGL (1.1, 2.1, 3.3, 4.3, ES2, ES3 - choose at compile)
* - Unique OpenGL abstraction layer (usable as standalone module): [rlgl]
* - Multiple Fonts formats supported (TTF, XNA fonts, AngelCode fonts)
* - Multiple Fonts formats supported (TTF, OTF, FNT, BDF, Sprite fonts)
* - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
* - Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more!
* - Flexible Materials system, supporting classic maps and PBR maps
* - Animated 3D models supported (skeletal bones animation) (IQM)
* - Animated 3D models supported (skeletal bones animation) (IQM, M3D, GLTF)
* - Shaders support, including Model shaders and Postprocessing shaders
* - Powerful math module for Vector, Matrix and Quaternion operations: [raymath]
* - Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
* - Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, QOA, XM, MOD)
* - VR stereo rendering with configurable HMD device parameters
* - Bindings to multiple programming languages available!
*
@ -27,29 +27,35 @@
* - One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() [rlgl] (OpenGL 3.3 or ES2)
*
* DEPENDENCIES (included):
* [rcore] rglfw (Camilla Löwy - github.com/glfw/glfw) for window/context management and input (PLATFORM_DESKTOP)
* [rlgl] glad (David Herberth - github.com/Dav1dde/glad) for OpenGL 3.3 extensions loading (PLATFORM_DESKTOP)
* [rcore][GLFW] rglfw (Camilla Löwy - github.com/glfw/glfw) for window/context management and input
* [rcore][RGFW] rgfw (ColleagueRiley - github.com/ColleagueRiley/RGFW) for window/context management and input
* [rlgl] glad/glad_gles2 (David Herberth - github.com/Dav1dde/glad) for OpenGL 3.3 extensions loading
* [raudio] miniaudio (David Reid - github.com/mackron/miniaudio) for audio device/context management
*
* OPTIONAL DEPENDENCIES (included):
* [rcore] msf_gif (Miles Fogle) for GIF recording
* [rcore] sinfl (Micha Mettke) for DEFLATE decompression algorithm
* [rcore] sdefl (Micha Mettke) for DEFLATE compression algorithm
* [rcore] rprand (Ramon Snatamaria) for pseudo-random numbers generation
* [rtextures] qoi (Dominic Szablewski - https://phoboslab.org) for QOI image manage
* [rtextures] stb_image (Sean Barret) for images loading (BMP, TGA, PNG, JPEG, HDR...)
* [rtextures] stb_image_write (Sean Barret) for image writing (BMP, TGA, PNG, JPG)
* [rtextures] stb_image_resize (Sean Barret) for image resizing algorithms
* [rtextures] stb_image_resize2 (Sean Barret) for image resizing algorithms
* [rtextures] stb_perlin (Sean Barret) for Perlin Noise image generation
* [rtext] stb_truetype (Sean Barret) for ttf fonts loading
* [rtext] stb_rect_pack (Sean Barret) for rectangles packing
* [rmodels] par_shapes (Philip Rideout) for parametric 3d shapes generation
* [rmodels] tinyobj_loader_c (Syoyo Fujita) for models loading (OBJ, MTL)
* [rmodels] cgltf (Johannes Kuhlmann) for models loading (glTF)
* [rmodels] Model3D (bzt) for models loading (M3D, https://bztsrc.gitlab.io/model3d)
* [rmodels] m3d (bzt) for models loading (M3D, https://bztsrc.gitlab.io/model3d)
* [rmodels] vox_loader (Johann Nadalutti) for models loading (VOX)
* [raudio] dr_wav (David Reid) for WAV audio file loading
* [raudio] dr_flac (David Reid) for FLAC audio file loading
* [raudio] dr_mp3 (David Reid) for MP3 audio file loading
* [raudio] stb_vorbis (Sean Barret) for OGG audio loading
* [raudio] jar_xm (Joshua Reisenauer) for XM audio module loading
* [raudio] jar_mod (Joshua Reisenauer) for MOD audio module loading
* [raudio] qoa (Dominic Szablewski - https://phoboslab.org) for QOA audio manage
*
*
* LICENSE: zlib/libpng
@ -84,7 +90,7 @@
#define RAYLIB_VERSION_MAJOR 5
#define RAYLIB_VERSION_MINOR 5
#define RAYLIB_VERSION_PATCH 0
#define RAYLIB_VERSION "5.5-dev"
#define RAYLIB_VERSION "5.5"
// Function specifiers in case library is build/used as a shared library
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
@ -877,8 +883,7 @@ typedef enum {
CUBEMAP_LAYOUT_LINE_VERTICAL, // Layout is defined by a vertical line with faces
CUBEMAP_LAYOUT_LINE_HORIZONTAL, // Layout is defined by a horizontal line with faces
CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces
CUBEMAP_LAYOUT_PANORAMA // Layout is defined by a panorama image (equirrectangular map)
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE // Layout is defined by a 4x3 cross with cubemap faces
} CubemapLayout;
// Font type, defines generation method
@ -965,36 +970,36 @@ RLAPI void CloseWindow(void); // Close windo
RLAPI bool WindowShouldClose(void); // Check if application should close (KEY_ESCAPE pressed or windows close icon clicked)
RLAPI bool IsWindowReady(void); // Check if window has been initialized successfully
RLAPI bool IsWindowFullscreen(void); // Check if window is currently fullscreen
RLAPI bool IsWindowHidden(void); // Check if window is currently hidden (only PLATFORM_DESKTOP)
RLAPI bool IsWindowMinimized(void); // Check if window is currently minimized (only PLATFORM_DESKTOP)
RLAPI bool IsWindowMaximized(void); // Check if window is currently maximized (only PLATFORM_DESKTOP)
RLAPI bool IsWindowFocused(void); // Check if window is currently focused (only PLATFORM_DESKTOP)
RLAPI bool IsWindowHidden(void); // Check if window is currently hidden
RLAPI bool IsWindowMinimized(void); // Check if window is currently minimized
RLAPI bool IsWindowMaximized(void); // Check if window is currently maximized
RLAPI bool IsWindowFocused(void); // Check if window is currently focused
RLAPI bool IsWindowResized(void); // Check if window has been resized last frame
RLAPI bool IsWindowState(unsigned int flag); // Check if one specific window flag is enabled
RLAPI void SetWindowState(unsigned int flags); // Set window configuration state using flags (only PLATFORM_DESKTOP)
RLAPI void SetWindowState(unsigned int flags); // Set window configuration state using flags
RLAPI void ClearWindowState(unsigned int flags); // Clear window configuration state flags
RLAPI void ToggleFullscreen(void); // Toggle window state: fullscreen/windowed [resizes monitor to match window resolution] (only PLATFORM_DESKTOP)
RLAPI void ToggleBorderlessWindowed(void); // Toggle window state: borderless windowed [resizes window to match monitor resolution] (only PLATFORM_DESKTOP)
RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)
RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
RLAPI void ToggleFullscreen(void); // Toggle window state: fullscreen/windowed, resizes monitor to match window resolution
RLAPI void ToggleBorderlessWindowed(void); // Toggle window state: borderless windowed, resizes window to match monitor resolution
RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable
RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable
RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized
RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit)
RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit)
RLAPI void SetWindowTitle(const char *title); // Set title for window
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen
RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window
RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
RLAPI void SetWindowMaxSize(int width, int height); // Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE)
RLAPI void SetWindowSize(int width, int height); // Set window dimensions
RLAPI void SetWindowOpacity(float opacity); // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
RLAPI void SetWindowFocused(void); // Set window focused (only PLATFORM_DESKTOP)
RLAPI void SetWindowOpacity(float opacity); // Set window opacity [0.0f..1.0f]
RLAPI void SetWindowFocused(void); // Set window focused
RLAPI void *GetWindowHandle(void); // Get native window handle
RLAPI int GetScreenWidth(void); // Get current screen width
RLAPI int GetScreenHeight(void); // Get current screen height
RLAPI int GetRenderWidth(void); // Get current render width (it considers HiDPI)
RLAPI int GetRenderHeight(void); // Get current render height (it considers HiDPI)
RLAPI int GetMonitorCount(void); // Get number of connected monitors
RLAPI int GetCurrentMonitor(void); // Get current connected monitor
RLAPI int GetCurrentMonitor(void); // Get current monitor where window is placed
RLAPI Vector2 GetMonitorPosition(int monitor); // Get specified monitor position
RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width (current video mode used by monitor)
RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height (current video mode used by monitor)
@ -1006,6 +1011,7 @@ RLAPI Vector2 GetWindowScaleDPI(void); // Get window
RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the specified monitor
RLAPI void SetClipboardText(const char *text); // Set clipboard text content
RLAPI const char *GetClipboardText(void); // Get clipboard text content
RLAPI Image GetClipboardImage(void); // Get clipboard image content
RLAPI void EnableEventWaiting(void); // Enable waiting for events on EndDrawing(), no automatic event polling
RLAPI void DisableEventWaiting(void); // Disable waiting for events on EndDrawing(), automatic events polling
@ -1044,7 +1050,7 @@ RLAPI void UnloadVrStereoConfig(VrStereoConfig config); // Unload VR s
// NOTE: Shader functionality is not available on OpenGL 1.1
RLAPI Shader LoadShader(const char *vsFileName, const char *fsFileName); // Load shader from files and bind default locations
RLAPI Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode); // Load shader from code strings and bind default locations
RLAPI bool IsShaderReady(Shader shader); // Check if a shader is ready
RLAPI bool IsShaderValid(Shader shader); // Check if a shader is valid (loaded on GPU)
RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
RLAPI int GetShaderLocationAttrib(Shader shader, const char *attribName); // Get shader attribute location
RLAPI void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType); // Set shader uniform value
@ -1144,6 +1150,10 @@ RLAPI unsigned char *CompressData(const unsigned char *data, int dataSize, int *
RLAPI unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); // Decompress data (DEFLATE algorithm), memory must be MemFree()
RLAPI char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); // Encode data to Base64 string, memory must be MemFree()
RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); // Decode Base64 string data, memory must be MemFree()
RLAPI unsigned int ComputeCRC32(unsigned char *data, int dataSize); // Compute CRC32 hash code
RLAPI unsigned int *ComputeMD5(unsigned char *data, int dataSize); // Compute MD5 hash code, returns static int[4] (16 bytes)
RLAPI unsigned int *ComputeSHA1(unsigned char *data, int dataSize); // Compute SHA1 hash code, returns static int[5] (20 bytes)
// Automation events functionality
RLAPI AutomationEventList LoadAutomationEventList(const char *fileName); // Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS
@ -1161,7 +1171,7 @@ RLAPI void PlayAutomationEvent(AutomationEvent event);
// Input-related functions: keyboard
RLAPI bool IsKeyPressed(int key); // Check if a key has been pressed once
RLAPI bool IsKeyPressedRepeat(int key); // Check if a key has been pressed again (Only PLATFORM_DESKTOP)
RLAPI bool IsKeyPressedRepeat(int key); // Check if a key has been pressed again
RLAPI bool IsKeyDown(int key); // Check if a key is being pressed
RLAPI bool IsKeyReleased(int key); // Check if a key has been released once
RLAPI bool IsKeyUp(int key); // Check if a key is NOT being pressed
@ -1180,7 +1190,7 @@ RLAPI int GetGamepadButtonPressed(void);
RLAPI int GetGamepadAxisCount(int gamepad); // Get gamepad axis count for a gamepad
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Get axis movement value for a gamepad axis
RLAPI int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB)
RLAPI void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor); // Set gamepad vibration for both motors
RLAPI void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration); // Set gamepad vibration for both motors (duration in seconds)
// Input-related functions: mouse
RLAPI bool IsMouseButtonPressed(int button); // Check if a mouse button has been pressed once
@ -1211,7 +1221,7 @@ RLAPI int GetTouchPointCount(void); // Get number of t
RLAPI void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags
RLAPI bool IsGestureDetected(unsigned int gesture); // Check if a gesture have been detected
RLAPI int GetGestureDetected(void); // Get latest detected gesture
RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds
RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in seconds
RLAPI Vector2 GetGestureDragVector(void); // Get gesture drag vector
RLAPI float GetGestureDragAngle(void); // Get gesture drag angle
RLAPI Vector2 GetGesturePinchVector(void); // Get gesture pinch delta
@ -1295,13 +1305,13 @@ RLAPI Vector2 GetSplinePointBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vect
RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles
RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles
RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle
RLAPI bool CheckCollisionCircleLine(Vector2 center, float radius, Vector2 p1, Vector2 p2); // Check if circle collides with a line created betweeen two points [p1] and [p2]
RLAPI bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle
RLAPI bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); // Check if point is inside circle
RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); // Check if point is inside a triangle
RLAPI bool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshold); // Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]
RLAPI bool CheckCollisionPointPoly(Vector2 point, const Vector2 *points, int pointCount); // Check if point is within a polygon described by array of vertices
RLAPI bool CheckCollisionLines(Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2, Vector2 *collisionPoint); // Check the collision between two lines defined by two points each, returns collision point by reference
RLAPI bool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshold); // Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]
RLAPI bool CheckCollisionCircleLine(Vector2 center, float radius, Vector2 p1, Vector2 p2); // Check if circle collides with a line created betweeen two points [p1] and [p2]
RLAPI Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); // Get collision rectangle for two rectangles collision
//------------------------------------------------------------------------------------
@ -1317,7 +1327,7 @@ RLAPI Image LoadImageAnimFromMemory(const char *fileType, const unsigned char *f
RLAPI Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load image from memory buffer, fileType refers to extension: i.e. '.png'
RLAPI Image LoadImageFromTexture(Texture2D texture); // Load image from GPU texture data
RLAPI Image LoadImageFromScreen(void); // Load image from screen buffer and (screenshot)
RLAPI bool IsImageReady(Image image); // Check if an image is ready
RLAPI bool IsImageValid(Image image); // Check if an image is valid (data and parameters)
RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM)
RLAPI bool ExportImage(Image image, const char *fileName); // Export image data to file, returns true on success
RLAPI unsigned char *ExportImageToMemory(Image image, const char *fileType, int *fileSize); // Export image to memory buffer
@ -1403,9 +1413,9 @@ RLAPI Texture2D LoadTexture(const char *fileName);
RLAPI Texture2D LoadTextureFromImage(Image image); // Load texture from image data
RLAPI TextureCubemap LoadTextureCubemap(Image image, int layout); // Load cubemap from image, multiple image cubemap layouts supported
RLAPI RenderTexture2D LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer)
RLAPI bool IsTextureReady(Texture2D texture); // Check if a texture is ready
RLAPI bool IsTextureValid(Texture2D texture); // Check if a texture is valid (loaded in GPU)
RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)
RLAPI bool IsRenderTextureReady(RenderTexture2D target); // Check if a render texture is ready
RLAPI bool IsRenderTextureValid(RenderTexture2D target); // Check if a render texture is valid (loaded in GPU)
RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM)
RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data
RLAPI void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels); // Update GPU texture rectangle with new data
@ -1452,7 +1462,7 @@ RLAPI Font LoadFont(const char *fileName);
RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount); // Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set, font size is provided in pixels height
RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)
RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
RLAPI bool IsFontReady(Font font); // Check if a font is ready
RLAPI bool IsFontValid(Font font); // Check if a font is valid (font data loaded, WARNING: GPU texture not checked)
RLAPI GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount, int type); // Load font data for further use
RLAPI Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info
RLAPI void UnloadFontData(GlyphInfo *glyphs, int glyphCount); // Unload font chars info data (RAM)
@ -1542,7 +1552,7 @@ RLAPI void DrawGrid(int slices, float spacing);
// Model management functions
RLAPI Model LoadModel(const char *fileName); // Load model from files (meshes and materials)
RLAPI Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh (default material)
RLAPI bool IsModelReady(Model model); // Check if a model is ready
RLAPI bool IsModelValid(Model model); // Check if a model is valid (loaded in GPU, VAO/VBOs)
RLAPI void UnloadModel(Model model); // Unload model (including meshes) from memory (RAM and/or VRAM)
RLAPI BoundingBox GetModelBoundingBox(Model model); // Compute model bounding box limits (considers all meshes)
@ -1585,18 +1595,18 @@ RLAPI Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize);
// Material loading/unloading functions
RLAPI Material *LoadMaterials(const char *fileName, int *materialCount); // Load materials from model file
RLAPI Material LoadMaterialDefault(void); // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)
RLAPI bool IsMaterialReady(Material material); // Check if a material is ready
RLAPI bool IsMaterialValid(Material material); // Check if a material is valid (shader assigned, map textures loaded in GPU)
RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)
RLAPI void SetMaterialTexture(Material *material, int mapType, Texture2D texture); // Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...)
RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh
// Model animations loading/unloading functions
RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount); // Load model animations from file
RLAPI void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); // Update model animation pose
RLAPI void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); // Update model animation pose (CPU)
RLAPI void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame); // Update model animation mesh bone matrices (GPU skinning)
RLAPI void UnloadModelAnimation(ModelAnimation anim); // Unload animation data
RLAPI void UnloadModelAnimations(ModelAnimation *animations, int animCount); // Unload animation array data
RLAPI bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match
RLAPI void UpdateModelAnimationBoneMatrices(Model model, ModelAnimation anim, int frame); // Update model animation mesh bone matrices (Note GPU skinning does not work on Mac)
// Collision detection functions
RLAPI bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Check collision between two spheres
@ -1623,11 +1633,11 @@ RLAPI float GetMasterVolume(void); // Get mas
// Wave/Sound loading/unloading functions
RLAPI Wave LoadWave(const char *fileName); // Load wave data from file
RLAPI Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load wave from memory buffer, fileType refers to extension: i.e. '.wav'
RLAPI bool IsWaveReady(Wave wave); // Checks if wave data is ready
RLAPI bool IsWaveValid(Wave wave); // Checks if wave data is valid (data loaded and parameters)
RLAPI Sound LoadSound(const char *fileName); // Load sound from file
RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data
RLAPI Sound LoadSoundAlias(Sound source); // Create a new sound that shares the same sample data as the source sound, does not own the sound data
RLAPI bool IsSoundReady(Sound sound); // Checks if a sound is ready
RLAPI bool IsSoundValid(Sound sound); // Checks if a sound is valid (data loaded and buffers initialized)
RLAPI void UpdateSound(Sound sound, const void *data, int sampleCount); // Update sound buffer with new data
RLAPI void UnloadWave(Wave wave); // Unload wave data
RLAPI void UnloadSound(Sound sound); // Unload sound
@ -1653,7 +1663,7 @@ RLAPI void UnloadWaveSamples(float *samples); // Unload
// Music management functions
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
RLAPI Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, int dataSize); // Load music stream from data
RLAPI bool IsMusicReady(Music music); // Checks if a music stream is ready
RLAPI bool IsMusicValid(Music music); // Checks if a music stream is valid (context and buffers initialized)
RLAPI void UnloadMusicStream(Music music); // Unload music stream
RLAPI void PlayMusicStream(Music music); // Start music playing
RLAPI bool IsMusicStreamPlaying(Music music); // Check if music is playing
@ -1670,7 +1680,7 @@ RLAPI float GetMusicTimePlayed(Music music); // Get cur
// AudioStream management functions
RLAPI AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Load audio stream (to stream raw audio pcm data)
RLAPI bool IsAudioStreamReady(AudioStream stream); // Checks if an audio stream is ready
RLAPI bool IsAudioStreamValid(AudioStream stream); // Checks if an audio stream is valid (buffers initialized)
RLAPI void UnloadAudioStream(AudioStream stream); // Unload audio stream and free memory
RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int frameCount); // Update audio stream buffers with data
RLAPI bool IsAudioStreamProcessed(AudioStream stream); // Check if any audio stream buffers requires refill

View File

@ -1829,7 +1829,7 @@ pub const ShaderLocationIndex = enum(c_int) {
shader_loc_map_brdf = 25,
shader_loc_vertex_boneids = 26,
shader_loc_vertex_boneweights = 27,
shader_loc_bone_matrices = 28
shader_loc_bone_matrices = 28,
};
pub const ShaderUniformDataType = enum(c_int) {
@ -1900,7 +1900,6 @@ pub const CubemapLayout = enum(c_int) {
cubemap_layout_line_horizontal = 2,
cubemap_layout_cross_three_by_four = 3,
cubemap_layout_cross_four_by_three = 4,
cubemap_layout_panorama = 5,
};
pub const FontType = enum(c_int) {
@ -1963,7 +1962,7 @@ pub const AudioCallback = ?*const fn (?*anyopaque, c_uint) callconv(.C) void;
pub const RAYLIB_VERSION_MAJOR = @as(i32, 5);
pub const RAYLIB_VERSION_MINOR = @as(i32, 5);
pub const RAYLIB_VERSION_PATCH = @as(i32, 0);
pub const RAYLIB_VERSION = "5.5-dev";
pub const RAYLIB_VERSION = "5.5";
pub const MAX_TOUCH_POINTS = 10;
pub const MAX_MATERIAL_MAPS = 12;
@ -2064,6 +2063,20 @@ pub fn decodeDataBase64(data: []const u8) []u8 {
return res;
}
pub fn computeCRC32(data: []u8) u32 {
return cdef.ComputeCRC32(data.ptr, data.len);
}
pub fn computeMD5(data: []u8) [4]u32 {
const res: [*]c_int = cdef.ComputeMD5(data.ptr, data.len);
return res[0..4].*;
}
pub fn computeSHA1(data: []u8) [5]u32 {
const res: [*]c_int = cdef.ComputeSHA1(data.ptr, data.len);
return res[0..5].*;
}
pub fn loadImageAnimFromMemory(fileType: [*:0]const u8, fileData: []const u8, frames: *i32) Image {
return cdef.LoadImageAnimFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(fileData)), @as(c_int, @intCast(fileData.len)), @as([*c]c_int, @ptrCast(frames)));
}
@ -2360,22 +2373,22 @@ pub fn isWindowFullscreen() bool {
return cdef.IsWindowFullscreen();
}
/// Check if window is currently hidden (only PLATFORM_DESKTOP)
/// Check if window is currently hidden
pub fn isWindowHidden() bool {
return cdef.IsWindowHidden();
}
/// Check if window is currently minimized (only PLATFORM_DESKTOP)
/// Check if window is currently minimized
pub fn isWindowMinimized() bool {
return cdef.IsWindowMinimized();
}
/// Check if window is currently maximized (only PLATFORM_DESKTOP)
/// Check if window is currently maximized
pub fn isWindowMaximized() bool {
return cdef.IsWindowMaximized();
}
/// Check if window is currently focused (only PLATFORM_DESKTOP)
/// Check if window is currently focused
pub fn isWindowFocused() bool {
return cdef.IsWindowFocused();
}
@ -2390,7 +2403,7 @@ pub fn isWindowState(flag: ConfigFlags) bool {
return cdef.IsWindowState(flag);
}
/// Set window configuration state using flags (only PLATFORM_DESKTOP)
/// Set window configuration state using flags
pub fn setWindowState(flags: ConfigFlags) void {
cdef.SetWindowState(flags);
}
@ -2400,42 +2413,42 @@ pub fn clearWindowState(flags: ConfigFlags) void {
cdef.ClearWindowState(flags);
}
/// Toggle window state: fullscreen/windowed [resizes monitor to match window resolution] (only PLATFORM_DESKTOP)
/// Toggle window state: fullscreen/windowed, resizes monitor to match window resolution
pub fn toggleFullscreen() void {
cdef.ToggleFullscreen();
}
/// Toggle window state: borderless windowed [resizes window to match monitor resolution] (only PLATFORM_DESKTOP)
/// Toggle window state: borderless windowed, resizes window to match monitor resolution
pub fn toggleBorderlessWindowed() void {
cdef.ToggleBorderlessWindowed();
}
/// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
/// Set window state: maximized, if resizable
pub fn maximizeWindow() void {
cdef.MaximizeWindow();
}
/// Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
/// Set window state: minimized, if resizable
pub fn minimizeWindow() void {
cdef.MinimizeWindow();
}
/// Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
/// Set window state: not minimized/maximized
pub fn restoreWindow() void {
cdef.RestoreWindow();
}
/// Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)
/// Set icon for window (single image, RGBA 32bit)
pub fn setWindowIcon(image: Image) void {
cdef.SetWindowIcon(image);
}
/// Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
/// Set title for window
pub fn setWindowTitle(title: [*:0]const u8) void {
cdef.SetWindowTitle(@as([*c]const u8, @ptrCast(title)));
}
/// Set window position on screen (only PLATFORM_DESKTOP)
/// Set window position on screen
pub fn setWindowPosition(x: i32, y: i32) void {
cdef.SetWindowPosition(@as(c_int, x), @as(c_int, y));
}
@ -2460,12 +2473,12 @@ pub fn setWindowSize(width: i32, height: i32) void {
cdef.SetWindowSize(@as(c_int, width), @as(c_int, height));
}
/// Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
/// Set window opacity [0.0f..1.0f]
pub fn setWindowOpacity(opacity: f32) void {
cdef.SetWindowOpacity(opacity);
}
/// Set window focused (only PLATFORM_DESKTOP)
/// Set window focused
pub fn setWindowFocused() void {
cdef.SetWindowFocused();
}
@ -2500,7 +2513,7 @@ pub fn getMonitorCount() i32 {
return @as(i32, cdef.GetMonitorCount());
}
/// Get current connected monitor
/// Get current monitor where window is placed
pub fn getCurrentMonitor() i32 {
return @as(i32, cdef.GetCurrentMonitor());
}
@ -2560,6 +2573,11 @@ pub fn getClipboardText() [*:0]const u8 {
return std.mem.span(cdef.GetClipboardText());
}
/// Get clipboard image content
pub fn getClipboardImage() Image {
return cdef.GetClipboardImage();
}
/// Enable waiting for events on EndDrawing(), no automatic event polling
pub fn enableEventWaiting() void {
cdef.EnableEventWaiting();
@ -2695,9 +2713,9 @@ pub fn unloadVrStereoConfig(config: VrStereoConfig) void {
cdef.UnloadVrStereoConfig(config);
}
/// Check if a shader is ready
pub fn isShaderReady(shader: Shader) bool {
return cdef.IsShaderReady(shader);
/// Check if a shader is valid (loaded on GPU)
pub fn isShaderValid(shader: Shader) bool {
return cdef.IsShaderValid(shader);
}
/// Get shader uniform location
@ -3060,7 +3078,7 @@ pub fn isKeyPressed(key: KeyboardKey) bool {
return cdef.IsKeyPressed(key);
}
/// Check if a key has been pressed again (Only PLATFORM_DESKTOP)
/// Check if a key has been pressed again
pub fn isKeyPressedRepeat(key: KeyboardKey) bool {
return cdef.IsKeyPressedRepeat(key);
}
@ -3145,9 +3163,9 @@ pub fn setGamepadMappings(mappings: [*:0]const u8) i32 {
return @as(i32, cdef.SetGamepadMappings(@as([*c]const u8, @ptrCast(mappings))));
}
/// Set gamepad vibration for both motors
pub fn setGamepadVibration(gamepad: i32, leftMotor: f32, rightMotor: f32) void {
cdef.SetGamepadVibration(@as(c_int, gamepad), leftMotor, rightMotor);
/// Set gamepad vibration for both motors (duration in seconds)
pub fn setGamepadVibration(gamepad: i32, leftMotor: f32, rightMotor: f32, duration: f32) void {
cdef.SetGamepadVibration(@as(c_int, gamepad), leftMotor, rightMotor, duration);
}
/// Check if a mouse button has been pressed once
@ -3260,7 +3278,7 @@ pub fn getGestureDetected() Gesture {
return cdef.GetGestureDetected();
}
/// Get gesture hold time in milliseconds
/// Get gesture hold time in seconds
pub fn getGestureHoldDuration() f32 {
return cdef.GetGestureHoldDuration();
}
@ -3545,6 +3563,11 @@ pub fn checkCollisionCircleRec(center: Vector2, radius: f32, rec: Rectangle) boo
return cdef.CheckCollisionCircleRec(center, radius, rec);
}
/// Check if circle collides with a line created betweeen two points [p1] and [p2]
pub fn checkCollisionCircleLine(center: Vector2, radius: f32, p1: Vector2, p2: Vector2) bool {
return cdef.CheckCollisionCircleLine(center, radius, p1, p2);
}
/// Check if point is inside rectangle
pub fn checkCollisionPointRec(point: Vector2, rec: Rectangle) bool {
return cdef.CheckCollisionPointRec(point, rec);
@ -3560,19 +3583,14 @@ pub fn checkCollisionPointTriangle(point: Vector2, p1: Vector2, p2: Vector2, p3:
return cdef.CheckCollisionPointTriangle(point, p1, p2, p3);
}
/// Check the collision between two lines defined by two points each, returns collision point by reference
pub fn checkCollisionLines(startPos1: Vector2, endPos1: Vector2, startPos2: Vector2, endPos2: Vector2, collisionPoint: *Vector2) bool {
return cdef.CheckCollisionLines(startPos1, endPos1, startPos2, endPos2, @as([*c]Vector2, @ptrCast(collisionPoint)));
}
/// Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]
pub fn checkCollisionPointLine(point: Vector2, p1: Vector2, p2: Vector2, threshold: i32) bool {
return cdef.CheckCollisionPointLine(point, p1, p2, @as(c_int, threshold));
}
/// Check if circle collides with a line created betweeen two points [p1] and [p2]
pub fn checkCollisionCircleLine(center: Vector2, radius: f32, p1: Vector2, p2: Vector2) bool {
return cdef.CheckCollisionCircleLine(center, radius, p1, p2);
/// Check the collision between two lines defined by two points each, returns collision point by reference
pub fn checkCollisionLines(startPos1: Vector2, endPos1: Vector2, startPos2: Vector2, endPos2: Vector2, collisionPoint: *Vector2) bool {
return cdef.CheckCollisionLines(startPos1, endPos1, startPos2, endPos2, @as([*c]Vector2, @ptrCast(collisionPoint)));
}
/// Get collision rectangle for two rectangles collision
@ -3605,9 +3623,9 @@ pub fn loadImageFromScreen() Image {
return cdef.LoadImageFromScreen();
}
/// Check if an image is ready
pub fn isImageReady(image: Image) bool {
return cdef.IsImageReady(image);
/// Check if an image is valid (data and parameters)
pub fn isImageValid(image: Image) bool {
return cdef.IsImageValid(image);
}
/// Unload image from CPU memory (RAM)
@ -3970,9 +3988,9 @@ pub fn loadRenderTexture(width: i32, height: i32) RenderTexture2D {
return cdef.LoadRenderTexture(@as(c_int, width), @as(c_int, height));
}
/// Check if a texture is ready
pub fn isTextureReady(texture: Texture2D) bool {
return cdef.IsTextureReady(texture);
/// Check if a texture is valid (loaded in GPU)
pub fn isTextureValid(texture: Texture2D) bool {
return cdef.IsTextureValid(texture);
}
/// Unload texture from GPU memory (VRAM)
@ -3980,9 +3998,9 @@ pub fn unloadTexture(texture: Texture2D) void {
cdef.UnloadTexture(texture);
}
/// Check if a render texture is ready
pub fn isRenderTextureReady(target: RenderTexture2D) bool {
return cdef.IsRenderTextureReady(target);
/// Check if a render texture is valid (loaded in GPU)
pub fn isRenderTextureValid(target: RenderTexture2D) bool {
return cdef.IsRenderTextureValid(target);
}
/// Unload render texture from GPU memory (VRAM)
@ -4145,9 +4163,9 @@ pub fn loadFontFromImage(image: Image, key: Color, firstChar: i32) Font {
return cdef.LoadFontFromImage(image, key, @as(c_int, firstChar));
}
/// Check if a font is ready
pub fn isFontReady(font: Font) bool {
return cdef.IsFontReady(font);
/// Check if a font is valid (font data loaded, WARNING: GPU texture not checked)
pub fn isFontValid(font: Font) bool {
return cdef.IsFontValid(font);
}
/// Unload font from GPU memory (VRAM)
@ -4435,9 +4453,9 @@ pub fn loadModelFromMesh(mesh: Mesh) Model {
return cdef.LoadModelFromMesh(mesh);
}
/// Check if a model is ready
pub fn isModelReady(model: Model) bool {
return cdef.IsModelReady(model);
/// Check if a model is valid (loaded in GPU, VAO/VBOs)
pub fn isModelValid(model: Model) bool {
return cdef.IsModelValid(model);
}
/// Unload model (including meshes) from memory (RAM and/or VRAM)
@ -4600,9 +4618,9 @@ pub fn loadMaterialDefault() Material {
return cdef.LoadMaterialDefault();
}
/// Check if a material is ready
pub fn isMaterialReady(material: Material) bool {
return cdef.IsMaterialReady(material);
/// Check if a material is valid (shader assigned, map textures loaded in GPU)
pub fn isMaterialValid(material: Material) bool {
return cdef.IsMaterialValid(material);
}
/// Unload material from GPU memory (VRAM)
@ -4620,11 +4638,16 @@ pub fn setModelMeshMaterial(model: *Model, meshId: i32, materialId: i32) void {
cdef.SetModelMeshMaterial(@as([*c]Model, @ptrCast(model)), @as(c_int, meshId), @as(c_int, materialId));
}
/// Update model animation pose
/// Update model animation pose (CPU)
pub fn updateModelAnimation(model: Model, anim: ModelAnimation, frame: i32) void {
cdef.UpdateModelAnimation(model, anim, @as(c_int, frame));
}
/// Update model animation mesh bone matrices (GPU skinning)
pub fn updateModelAnimationBones(model: Model, anim: ModelAnimation, frame: i32) void {
cdef.UpdateModelAnimationBones(model, anim, @as(c_int, frame));
}
/// Unload animation data
pub fn unloadModelAnimation(anim: ModelAnimation) void {
cdef.UnloadModelAnimation(anim);
@ -4635,11 +4658,6 @@ pub fn isModelAnimationValid(model: Model, anim: ModelAnimation) bool {
return cdef.IsModelAnimationValid(model, anim);
}
/// Update model animation mesh bone matrices (Note GPU skinning does not work on Mac)
pub fn updateModelAnimationBoneMatrices(model: Model, anim: ModelAnimation, frame: i32) void {
cdef.UpdateModelAnimationBoneMatrices(model, anim, @as(c_int, frame));
}
/// Check collision between two spheres
pub fn checkCollisionSpheres(center1: Vector3, radius1: f32, center2: Vector3, radius2: f32) bool {
return cdef.CheckCollisionSpheres(center1, radius1, center2, radius2);
@ -4710,9 +4728,9 @@ pub fn loadWave(fileName: [*:0]const u8) Wave {
return cdef.LoadWave(@as([*c]const u8, @ptrCast(fileName)));
}
/// Checks if wave data is ready
pub fn isWaveReady(wave: Wave) bool {
return cdef.IsWaveReady(wave);
/// Checks if wave data is valid (data loaded and parameters)
pub fn isWaveValid(wave: Wave) bool {
return cdef.IsWaveValid(wave);
}
/// Load sound from file
@ -4730,9 +4748,9 @@ pub fn loadSoundAlias(source: Sound) Sound {
return cdef.LoadSoundAlias(source);
}
/// Checks if a sound is ready
pub fn isSoundReady(sound: Sound) bool {
return cdef.IsSoundReady(sound);
/// Checks if a sound is valid (data loaded and buffers initialized)
pub fn isSoundValid(sound: Sound) bool {
return cdef.IsSoundValid(sound);
}
/// Update sound buffer with new data
@ -4830,9 +4848,9 @@ pub fn loadMusicStream(fileName: [*:0]const u8) Music {
return cdef.LoadMusicStream(@as([*c]const u8, @ptrCast(fileName)));
}
/// Checks if a music stream is ready
pub fn isMusicReady(music: Music) bool {
return cdef.IsMusicReady(music);
/// Checks if a music stream is valid (context and buffers initialized)
pub fn isMusicValid(music: Music) bool {
return cdef.IsMusicValid(music);
}
/// Unload music stream
@ -4905,9 +4923,9 @@ pub fn loadAudioStream(sampleRate: u32, sampleSize: u32, channels: u32) AudioStr
return cdef.LoadAudioStream(@as(c_uint, sampleRate), @as(c_uint, sampleSize), @as(c_uint, channels));
}
/// Checks if an audio stream is ready
pub fn isAudioStreamReady(stream: AudioStream) bool {
return cdef.IsAudioStreamReady(stream);
/// Checks if an audio stream is valid (buffers initialized)
pub fn isAudioStreamValid(stream: AudioStream) bool {
return cdef.IsAudioStreamValid(stream);
}
/// Unload audio stream and free memory

362
lib/raymath.h vendored
View File

@ -1,6 +1,6 @@
/**********************************************************************************************
*
* raymath v1.5 - Math functions to work with Vector2, Vector3, Matrix and Quaternions
* raymath v2.0 - Math functions to work with Vector2, Vector3, Matrix and Quaternions
*
* CONVENTIONS:
* - Matrix structure is defined as row-major (memory layout) but parameters naming AND all
@ -12,7 +12,7 @@
* - Functions are always self-contained, no function use another raymath function inside,
* required code is directly re-implemented inside
* - Functions input parameters are always received by value (2 unavoidable exceptions)
* - Functions use always a "result" variable for return
* - Functions use always a "result" variable for return (except C++ operators)
* - Functions are always defined inline
* - Angles are always in radians (DEG2RAD/RAD2DEG macros provided for convenience)
* - No compound literals used to make sure libray is compatible with C++
@ -27,6 +27,8 @@
* Define static inline functions code, so #include header suffices for use.
* This may use up lots of memory.
*
* #define RAYMATH_DISABLE_CPP_OPERATORS
* Disables C++ operator overloads for raymath types.
*
* LICENSE: zlib/libpng
*
@ -2567,7 +2569,13 @@ RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotatio
if (!FloatEquals(det, 0))
{
clone.m0 /= s.x;
clone.m4 /= s.x;
clone.m8 /= s.x;
clone.m1 /= s.y;
clone.m5 /= s.y;
clone.m9 /= s.y;
clone.m2 /= s.z;
clone.m6 /= s.z;
clone.m10 /= s.z;
// Extract rotation
@ -2580,4 +2588,354 @@ RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotatio
}
}
#if defined(__cplusplus) && !defined(RAYMATH_DISABLE_CPP_OPERATORS)
// Optional C++ math operators
//-------------------------------------------------------------------------------
// Vector2 operators
static constexpr Vector2 Vector2Zeros = { 0, 0 };
static constexpr Vector2 Vector2Ones = { 1, 1 };
static constexpr Vector2 Vector2UnitX = { 1, 0 };
static constexpr Vector2 Vector2UnitY = { 0, 1 };
inline Vector2 operator + (const Vector2& lhs, const Vector2& rhs)
{
return Vector2Add(lhs, rhs);
}
inline const Vector2& operator += (Vector2& lhs, const Vector2& rhs)
{
lhs = Vector2Add(lhs, rhs);
return lhs;
}
inline Vector2 operator - (const Vector2& lhs, const Vector2& rhs)
{
return Vector2Subtract(lhs, rhs);
}
inline const Vector2& operator -= (Vector2& lhs, const Vector2& rhs)
{
lhs = Vector2Subtract(lhs, rhs);
return lhs;
}
inline Vector2 operator * (const Vector2& lhs, const float& rhs)
{
return Vector2Scale(lhs, rhs);
}
inline const Vector2& operator *= (Vector2& lhs, const float& rhs)
{
lhs = Vector2Scale(lhs, rhs);
return lhs;
}
inline Vector2 operator * (const Vector2& lhs, const Vector2& rhs)
{
return Vector2Multiply(lhs, rhs);
}
inline const Vector2& operator *= (Vector2& lhs, const Vector2& rhs)
{
lhs = Vector2Multiply(lhs, rhs);
return lhs;
}
inline Vector2 operator * (const Vector2& lhs, const Matrix& rhs)
{
return Vector2Transform(lhs, rhs);
}
inline const Vector2& operator -= (Vector2& lhs, const Matrix& rhs)
{
lhs = Vector2Transform(lhs, rhs);
return lhs;
}
inline Vector2 operator / (const Vector2& lhs, const float& rhs)
{
return Vector2Scale(lhs, 1.0f / rhs);
}
inline const Vector2& operator /= (Vector2& lhs, const float& rhs)
{
lhs = Vector2Scale(lhs, rhs);
return lhs;
}
inline Vector2 operator / (const Vector2& lhs, const Vector2& rhs)
{
return Vector2Divide(lhs, rhs);
}
inline const Vector2& operator /= (Vector2& lhs, const Vector2& rhs)
{
lhs = Vector2Divide(lhs, rhs);
return lhs;
}
inline bool operator == (const Vector2& lhs, const Vector2& rhs)
{
return FloatEquals(lhs.x, rhs.x) && FloatEquals(lhs.y, rhs.y);
}
inline bool operator != (const Vector2& lhs, const Vector2& rhs)
{
return !FloatEquals(lhs.x, rhs.x) || !FloatEquals(lhs.y, rhs.y);
}
// Vector3 operators
static constexpr Vector3 Vector3Zeros = { 0, 0, 0 };
static constexpr Vector3 Vector3Ones = { 1, 1, 1 };
static constexpr Vector3 Vector3UnitX = { 1, 0, 0 };
static constexpr Vector3 Vector3UnitY = { 0, 1, 0 };
static constexpr Vector3 Vector3UnitZ = { 0, 0, 1 };
inline Vector3 operator + (const Vector3& lhs, const Vector3& rhs)
{
return Vector3Add(lhs, rhs);
}
inline const Vector3& operator += (Vector3& lhs, const Vector3& rhs)
{
lhs = Vector3Add(lhs, rhs);
return lhs;
}
inline Vector3 operator - (const Vector3& lhs, const Vector3& rhs)
{
return Vector3Subtract(lhs, rhs);
}
inline const Vector3& operator -= (Vector3& lhs, const Vector3& rhs)
{
lhs = Vector3Subtract(lhs, rhs);
return lhs;
}
inline Vector3 operator * (const Vector3& lhs, const float& rhs)
{
return Vector3Scale(lhs, rhs);
}
inline const Vector3& operator *= (Vector3& lhs, const float& rhs)
{
lhs = Vector3Scale(lhs, rhs);
return lhs;
}
inline Vector3 operator * (const Vector3& lhs, const Vector3& rhs)
{
return Vector3Multiply(lhs, rhs);
}
inline const Vector3& operator *= (Vector3& lhs, const Vector3& rhs)
{
lhs = Vector3Multiply(lhs, rhs);
return lhs;
}
inline Vector3 operator * (const Vector3& lhs, const Matrix& rhs)
{
return Vector3Transform(lhs, rhs);
}
inline const Vector3& operator -= (Vector3& lhs, const Matrix& rhs)
{
lhs = Vector3Transform(lhs, rhs);
return lhs;
}
inline Vector3 operator / (const Vector3& lhs, const float& rhs)
{
return Vector3Scale(lhs, 1.0f / rhs);
}
inline const Vector3& operator /= (Vector3& lhs, const float& rhs)
{
lhs = Vector3Scale(lhs, rhs);
return lhs;
}
inline Vector3 operator / (const Vector3& lhs, const Vector3& rhs)
{
return Vector3Divide(lhs, rhs);
}
inline const Vector3& operator /= (Vector3& lhs, const Vector3& rhs)
{
lhs = Vector3Divide(lhs, rhs);
return lhs;
}
inline bool operator == (const Vector3& lhs, const Vector3& rhs)
{
return FloatEquals(lhs.x, rhs.x) && FloatEquals(lhs.y, rhs.y) && FloatEquals(lhs.z, rhs.z);
}
inline bool operator != (const Vector3& lhs, const Vector3& rhs)
{
return !FloatEquals(lhs.x, rhs.x) || !FloatEquals(lhs.y, rhs.y) || !FloatEquals(lhs.z, rhs.z);
}
// Vector4 operators
static constexpr Vector4 Vector4Zeros = { 0, 0, 0, 0 };
static constexpr Vector4 Vector4Ones = { 1, 1, 1, 1 };
static constexpr Vector4 Vector4UnitX = { 1, 0, 0, 0 };
static constexpr Vector4 Vector4UnitY = { 0, 1, 0, 0 };
static constexpr Vector4 Vector4UnitZ = { 0, 0, 1, 0 };
static constexpr Vector4 Vector4UnitW = { 0, 0, 0, 1 };
inline Vector4 operator + (const Vector4& lhs, const Vector4& rhs)
{
return Vector4Add(lhs, rhs);
}
inline const Vector4& operator += (Vector4& lhs, const Vector4& rhs)
{
lhs = Vector4Add(lhs, rhs);
return lhs;
}
inline Vector4 operator - (const Vector4& lhs, const Vector4& rhs)
{
return Vector4Subtract(lhs, rhs);
}
inline const Vector4& operator -= (Vector4& lhs, const Vector4& rhs)
{
lhs = Vector4Subtract(lhs, rhs);
return lhs;
}
inline Vector4 operator * (const Vector4& lhs, const float& rhs)
{
return Vector4Scale(lhs, rhs);
}
inline const Vector4& operator *= (Vector4& lhs, const float& rhs)
{
lhs = Vector4Scale(lhs, rhs);
return lhs;
}
inline Vector4 operator * (const Vector4& lhs, const Vector4& rhs)
{
return Vector4Multiply(lhs, rhs);
}
inline const Vector4& operator *= (Vector4& lhs, const Vector4& rhs)
{
lhs = Vector4Multiply(lhs, rhs);
return lhs;
}
inline Vector4 operator / (const Vector4& lhs, const float& rhs)
{
return Vector4Scale(lhs, 1.0f / rhs);
}
inline const Vector4& operator /= (Vector4& lhs, const float& rhs)
{
lhs = Vector4Scale(lhs, rhs);
return lhs;
}
inline Vector4 operator / (const Vector4& lhs, const Vector4& rhs)
{
return Vector4Divide(lhs, rhs);
}
inline const Vector4& operator /= (Vector4& lhs, const Vector4& rhs)
{
lhs = Vector4Divide(lhs, rhs);
return lhs;
}
inline bool operator == (const Vector4& lhs, const Vector4& rhs)
{
return FloatEquals(lhs.x, rhs.x) && FloatEquals(lhs.y, rhs.y) && FloatEquals(lhs.z, rhs.z) && FloatEquals(lhs.w, rhs.w);
}
inline bool operator != (const Vector4& lhs, const Vector4& rhs)
{
return !FloatEquals(lhs.x, rhs.x) || !FloatEquals(lhs.y, rhs.y) || !FloatEquals(lhs.z, rhs.z) || !FloatEquals(lhs.w, rhs.w);
}
// Quaternion operators
static constexpr Quaternion QuaternionZeros = { 0, 0, 0, 0 };
static constexpr Quaternion QuaternionOnes = { 1, 1, 1, 1 };
static constexpr Quaternion QuaternionUnitX = { 0, 0, 0, 1 };
inline Quaternion operator + (const Quaternion& lhs, const float& rhs)
{
return QuaternionAddValue(lhs, rhs);
}
inline const Quaternion& operator += (Quaternion& lhs, const float& rhs)
{
lhs = QuaternionAddValue(lhs, rhs);
return lhs;
}
inline Quaternion operator - (const Quaternion& lhs, const float& rhs)
{
return QuaternionSubtractValue(lhs, rhs);
}
inline const Quaternion& operator -= (Quaternion& lhs, const float& rhs)
{
lhs = QuaternionSubtractValue(lhs, rhs);
return lhs;
}
inline Quaternion operator * (const Quaternion& lhs, const Matrix& rhs)
{
return QuaternionTransform(lhs, rhs);
}
inline const Quaternion& operator *= (Quaternion& lhs, const Matrix& rhs)
{
lhs = QuaternionTransform(lhs, rhs);
return lhs;
}
// Matrix operators
inline Matrix operator + (const Matrix& lhs, const Matrix& rhs)
{
return MatrixAdd(lhs, rhs);
}
inline const Matrix& operator += (Matrix& lhs, const Matrix& rhs)
{
lhs = MatrixAdd(lhs, rhs);
return lhs;
}
inline Matrix operator - (const Matrix& lhs, const Matrix& rhs)
{
return MatrixSubtract(lhs, rhs);
}
inline const Matrix& operator -= (Matrix& lhs, const Matrix& rhs)
{
lhs = MatrixSubtract(lhs, rhs);
return lhs;
}
inline Matrix operator * (const Matrix& lhs, const Matrix& rhs)
{
return MatrixMultiply(lhs, rhs);
}
inline const Matrix& operator *= (Matrix& lhs, const Matrix& rhs)
{
lhs = MatrixMultiply(lhs, rhs);
return lhs;
}
//-------------------------------------------------------------------------------
#endif // C++ operators
#endif // RAYMATH_H

View File

@ -115,7 +115,7 @@ pub extern "c" fn rlDrawVertexArrayInstanced(offset: c_int, count: c_int, instan
pub extern "c" fn rlDrawVertexArrayElementsInstanced(offset: c_int, count: c_int, buffer: ?*const anyopaque, instances: c_int) void;
pub extern "c" fn rlLoadTexture(data: ?*const anyopaque, width: c_int, height: c_int, format: c_int, mipmapCount: c_int) c_uint;
pub extern "c" fn rlLoadTextureDepth(width: c_int, height: c_int, useRenderBuffer: bool) c_uint;
pub extern "c" fn rlLoadTextureCubemap(data: ?*const anyopaque, size: c_int, format: c_int) c_uint;
pub extern "c" fn rlLoadTextureCubemap(data: ?*const anyopaque, size: c_int, format: c_int, mipmapCount: c_int) c_uint;
pub extern "c" fn rlUpdateTexture(id: c_uint, offsetX: c_int, offsetY: c_int, width: c_int, height: c_int, format: c_int, data: *const anyopaque) void;
pub extern "c" fn rlGetGlTextureFormats(format: c_int, glInternalFormat: [*c]c_uint, glFormat: [*c]c_uint, glType: [*c]c_uint) void;
pub extern "c" fn rlGetPixelFormatName(format: c_uint) [*c]const u8;

147
lib/rlgl.h vendored
View File

@ -8,17 +8,17 @@
*
* ADDITIONAL NOTES:
* When choosing an OpenGL backend different than OpenGL 1.1, some internal buffer are
* initialized on rlglInit() to accumulate vertex data.
* initialized on rlglInit() to accumulate vertex data
*
* When an internal state change is required all the stored vertex data is renderer in batch,
* additionally, rlDrawRenderBatchActive() could be called to force flushing of the batch.
* additionally, rlDrawRenderBatchActive() could be called to force flushing of the batch
*
* Some resources are also loaded for convenience, here the complete list:
* - Default batch (RLGL.defaultBatch): RenderBatch system to accumulate vertex data
* - Default texture (RLGL.defaultTextureId): 1x1 white pixel R8G8B8A8
* - Default shader (RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs)
*
* Internal buffer (and resources) must be manually unloaded calling rlglClose().
* Internal buffer (and resources) must be manually unloaded calling rlglClose()
*
* CONFIGURATION:
* #define GRAPHICS_API_OPENGL_11
@ -32,9 +32,9 @@
* required by any other module, use rlGetVersion() to check it
*
* #define RLGL_IMPLEMENTATION
* Generates the implementation of the library into the included file.
* Generates the implementation of the library into the included file
* If not defined, the library is in header only mode and can be included in other headers
* or source files without problems. But only ONE file should hold the implementation.
* or source files without problems. But only ONE file should hold the implementation
*
* #define RLGL_RENDER_TEXTURES_HINT
* Enable framebuffer objects (fbo) support (enabled by default)
@ -347,7 +347,6 @@
#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6
#endif
#ifdef RL_SUPPORT_MESH_GPU_SKINNING
#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS 7
@ -750,7 +749,7 @@ RLAPI void rlDrawVertexArrayElementsInstanced(int offset, int count, const void
// Textures management
RLAPI unsigned int rlLoadTexture(const void *data, int width, int height, int format, int mipmapCount); // Load texture data
RLAPI unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer); // Load depth texture/renderbuffer (to be attached to fbo)
RLAPI unsigned int rlLoadTextureCubemap(const void *data, int size, int format); // Load texture cubemap data
RLAPI unsigned int rlLoadTextureCubemap(const void *data, int size, int format, int mipmapCount); // Load texture cubemap data
RLAPI void rlUpdateTexture(unsigned int id, int offsetX, int offsetY, int width, int height, int format, const void *data); // Update texture with new data on GPU
RLAPI void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned int *glFormat, unsigned int *glType); // Get OpenGL internal formats
RLAPI const char *rlGetPixelFormatName(unsigned int format); // Get name string for pixel format
@ -1504,8 +1503,8 @@ void rlVertex3f(float x, float y, float z)
tz = RLGL.State.transform.m2*x + RLGL.State.transform.m6*y + RLGL.State.transform.m10*z + RLGL.State.transform.m14;
}
// WARNING: We can't break primitives when launching a new batch.
// RL_LINES comes in pairs, RL_TRIANGLES come in groups of 3 vertices and RL_QUADS come in groups of 4 vertices.
// WARNING: We can't break primitives when launching a new batch
// RL_LINES comes in pairs, RL_TRIANGLES come in groups of 3 vertices and RL_QUADS come in groups of 4 vertices
// We must check current draw.mode when a new vertex is required and finish the batch only if the draw.mode draw.vertexCount is %2, %3 or %4
if (RLGL.State.vertexCounter > (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4 - 4))
{
@ -2473,25 +2472,47 @@ void rlLoadExtensions(void *loader)
}
// Check instanced rendering support
if (strcmp(extList[i], (const char *)"GL_ANGLE_instanced_arrays") == 0) // Web ANGLE
if (strstr(extList[i], (const char*)"instanced_arrays") != NULL) // Broad check for instanced_arrays
{
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedANGLE");
glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedANGLE");
glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISOREXTPROC)((rlglLoadProc)loader)("glVertexAttribDivisorANGLE");
if ((glDrawArraysInstanced != NULL) && (glDrawElementsInstanced != NULL) && (glVertexAttribDivisor != NULL)) RLGL.ExtSupported.instancing = true;
}
else
{
if ((strcmp(extList[i], (const char *)"GL_EXT_draw_instanced") == 0) && // Standard EXT
(strcmp(extList[i], (const char *)"GL_EXT_instanced_arrays") == 0))
// Specific check
if (strcmp(extList[i], (const char *)"GL_ANGLE_instanced_arrays") == 0) // ANGLE
{
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedANGLE");
glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedANGLE");
glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISOREXTPROC)((rlglLoadProc)loader)("glVertexAttribDivisorANGLE");
}
else if (strcmp(extList[i], (const char *)"GL_EXT_instanced_arrays") == 0) // EXT
{
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedEXT");
glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedEXT");
glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISOREXTPROC)((rlglLoadProc)loader)("glVertexAttribDivisorEXT");
if ((glDrawArraysInstanced != NULL) && (glDrawElementsInstanced != NULL) && (glVertexAttribDivisor != NULL)) RLGL.ExtSupported.instancing = true;
}
else if (strcmp(extList[i], (const char *)"GL_NV_instanced_arrays") == 0) // NVIDIA GLES
{
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedNV");
glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedNV");
glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISOREXTPROC)((rlglLoadProc)loader)("glVertexAttribDivisorNV");
}
// The feature will only be marked as supported if the elements from GL_XXX_instanced_arrays are present
if ((glDrawArraysInstanced != NULL) && (glDrawElementsInstanced != NULL) && (glVertexAttribDivisor != NULL)) RLGL.ExtSupported.instancing = true;
}
else if (strstr(extList[i], (const char *)"draw_instanced") != NULL)
{
// GL_ANGLE_draw_instanced doesn't exist
if (strcmp(extList[i], (const char *)"GL_EXT_draw_instanced") == 0)
{
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedEXT");
glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedEXT");
}
else if (strcmp(extList[i], (const char*)"GL_NV_draw_instanced") == 0)
{
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedNV");
glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedNV");
}
// But the functions will at least be loaded if only GL_XX_EXT_draw_instanced exist
if ((glDrawArraysInstanced != NULL) && (glDrawElementsInstanced != NULL) && (glVertexAttribDivisor != NULL)) RLGL.ExtSupported.instancing = true;
}
// Check NPOT textures support
@ -2912,11 +2933,11 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
glBufferSubData(GL_ARRAY_BUFFER, 0, RLGL.State.vertexCounter*4*sizeof(unsigned char), batch->vertexBuffer[batch->currentBuffer].colors);
//glBufferData(GL_ARRAY_BUFFER, sizeof(float)*4*4*batch->vertexBuffer[batch->currentBuffer].elementCount, batch->vertexBuffer[batch->currentBuffer].colors, GL_DYNAMIC_DRAW); // Update all buffer
// NOTE: glMapBuffer() causes sync issue.
// If GPU is working with this buffer, glMapBuffer() will wait(stall) until GPU to finish its job.
// To avoid waiting (idle), you can call first glBufferData() with NULL pointer before glMapBuffer().
// NOTE: glMapBuffer() causes sync issue
// If GPU is working with this buffer, glMapBuffer() will wait(stall) until GPU to finish its job
// To avoid waiting (idle), you can call first glBufferData() with NULL pointer before glMapBuffer()
// If you do that, the previous data in PBO will be discarded and glMapBuffer() returns a new
// allocated pointer immediately even if GPU is still working with the previous data.
// allocated pointer immediately even if GPU is still working with the previous data
// Another option: map the buffer object into client's memory
// Probably this code could be moved somewhere else...
@ -2969,7 +2990,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
}
// WARNING: For the following setup of the view, model, and normal matrices, it is expected that
// transformations and rendering occur between rlPushMatrix and rlPopMatrix.
// transformations and rendering occur between rlPushMatrix() and rlPopMatrix()
if (RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_VIEW] != -1)
{
@ -3039,15 +3060,15 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
if ((batch->draws[i].mode == RL_LINES) || (batch->draws[i].mode == RL_TRIANGLES)) glDrawArrays(batch->draws[i].mode, vertexOffset, batch->draws[i].vertexCount);
else
{
#if defined(GRAPHICS_API_OPENGL_33)
#if defined(GRAPHICS_API_OPENGL_33)
// We need to define the number of indices to be processed: elementCount*6
// NOTE: The final parameter tells the GPU the offset in bytes from the
// start of the index buffer to the location of the first index to process
glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_INT, (GLvoid *)(vertexOffset/4*6*sizeof(GLuint)));
#endif
#if defined(GRAPHICS_API_OPENGL_ES2)
#endif
#if defined(GRAPHICS_API_OPENGL_ES2)
glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_SHORT, (GLvoid *)(vertexOffset/4*6*sizeof(GLushort)));
#endif
#endif
}
vertexOffset += (batch->draws[i].vertexCount + batch->draws[i].vertexAlignment);
@ -3365,11 +3386,17 @@ unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer)
// Load texture cubemap
// NOTE: Cubemap data is expected to be 6 images in a single data array (one after the other),
// expected the following convention: +X, -X, +Y, -Y, +Z, -Z
unsigned int rlLoadTextureCubemap(const void *data, int size, int format)
unsigned int rlLoadTextureCubemap(const void *data, int size, int format, int mipmapCount)
{
unsigned int id = 0;
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
int mipSize = size;
// NOTE: Added pointer math separately from function to avoid UBSAN complaining
unsigned char *dataPtr = NULL;
if (data != NULL) dataPtr = (unsigned char *)data;
unsigned int dataSize = rlGetPixelDataSize(size, size, format);
glGenTextures(1, &id);
@ -3380,24 +3407,28 @@ unsigned int rlLoadTextureCubemap(const void *data, int size, int format)
if (glInternalFormat != 0)
{
// Load cubemap faces
for (unsigned int i = 0; i < 6; i++)
// Load cubemap faces/mipmaps
for (int i = 0; i < 6*mipmapCount; i++)
{
int mipmapLevel = i/6;
int face = i%6;
if (data == NULL)
{
if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB)
{
if ((format == RL_PIXELFORMAT_UNCOMPRESSED_R32) || (format == RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32)
|| (format == RL_PIXELFORMAT_UNCOMPRESSED_R16) || (format == RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16))
TRACELOG(RL_LOG_WARNING, "TEXTURES: Cubemap requested format not supported");
else glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, size, size, 0, glFormat, glType, NULL);
if ((format == RL_PIXELFORMAT_UNCOMPRESSED_R32) ||
(format == RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32) ||
(format == RL_PIXELFORMAT_UNCOMPRESSED_R16) ||
(format == RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16)) TRACELOG(RL_LOG_WARNING, "TEXTURES: Cubemap requested format not supported");
else glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mipmapLevel, glInternalFormat, mipSize, mipSize, 0, glFormat, glType, NULL);
}
else TRACELOG(RL_LOG_WARNING, "TEXTURES: Empty cubemap creation does not support compressed format");
}
else
{
if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, size, size, 0, glFormat, glType, (unsigned char *)data + i*dataSize);
else glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, size, size, 0, dataSize, (unsigned char *)data + i*dataSize);
if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mipmapLevel, glInternalFormat, mipSize, mipSize, 0, glFormat, glType, (unsigned char *)dataPtr + face*dataSize);
else glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mipmapLevel, glInternalFormat, mipSize, mipSize, 0, dataSize, (unsigned char *)dataPtr + face*dataSize);
}
#if defined(GRAPHICS_API_OPENGL_33)
@ -3416,11 +3447,23 @@ unsigned int rlLoadTextureCubemap(const void *data, int size, int format)
glTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
#endif
if (face == 5)
{
mipSize /= 2;
if (data != NULL) dataPtr += dataSize*6; // Increment data pointer to next mipmap
// Security check for NPOT textures
if (mipSize < 1) mipSize = 1;
dataSize = rlGetPixelDataSize(mipSize, mipSize, format);
}
}
}
// Set cubemap texture sampling parameters
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
if (mipmapCount > 1) glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
else glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
@ -3579,8 +3622,8 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format)
//glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
//glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &format);
// NOTE: Each row written to or read from by OpenGL pixel operations like glGetTexImage are aligned to a 4 byte boundary by default, which may add some padding.
// Use glPixelStorei to modify padding with the GL_[UN]PACK_ALIGNMENT setting.
// NOTE: Each row written to or read from by OpenGL pixel operations like glGetTexImage are aligned to a 4 byte boundary by default, which may add some padding
// Use glPixelStorei to modify padding with the GL_[UN]PACK_ALIGNMENT setting
// GL_PACK_ALIGNMENT affects operations that read from OpenGL memory (glReadPixels, glGetTexImage, etc.)
// GL_UNPACK_ALIGNMENT affects operations that write to OpenGL memory (glTexImage, etc.)
glPixelStorei(GL_PACK_ALIGNMENT, 1);
@ -3601,7 +3644,7 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format)
#if defined(GRAPHICS_API_OPENGL_ES2)
// glGetTexImage() is not available on OpenGL ES 2.0
// Texture width and height are required on OpenGL ES 2.0. There is no way to get it from texture id.
// Texture width and height are required on OpenGL ES 2.0, there is no way to get it from texture id
// Two possible Options:
// 1 - Bind texture to color fbo attachment and glReadPixels()
// 2 - Create an fbo, activate it, render quad with texture, glReadPixels()
@ -3767,7 +3810,7 @@ void rlUnloadFramebuffer(unsigned int id)
else if (depthType == GL_TEXTURE) glDeleteTextures(1, &depthIdU);
// NOTE: If a texture object is deleted while its image is attached to the *currently bound* framebuffer,
// the texture image is automatically detached from the currently bound framebuffer.
// the texture image is automatically detached from the currently bound framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &id);
@ -4210,7 +4253,7 @@ unsigned int rlLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId)
else
{
// Get the size of compiled shader program (not available on OpenGL ES 2.0)
// NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero.
// NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero
//GLint binarySize = 0;
//glGetProgramiv(id, GL_PROGRAM_BINARY_LENGTH, &binarySize);
@ -4316,8 +4359,12 @@ void rlSetUniformMatrix(int locIndex, Matrix mat)
// Set shader value uniform matrix
void rlSetUniformMatrices(int locIndex, const Matrix *matrices, int count)
{
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
glUniformMatrix4fv(locIndex, count, true, (const float*)matrices);
#if defined(GRAPHICS_API_OPENGL_33)
glUniformMatrix4fv(locIndex, count, true, (const float *)matrices);
#elif defined(GRAPHICS_API_OPENGL_ES2)
// WARNING: WebGL does not support Matrix transpose ("true" parameter)
// REF: https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/uniformMatrix
glUniformMatrix4fv(locIndex, count, false, (const float *)matrices);
#endif
}
@ -4400,7 +4447,7 @@ unsigned int rlLoadComputeShaderProgram(unsigned int shaderId)
else
{
// Get the size of compiled shader program (not available on OpenGL ES 2.0)
// NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero.
// NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero
//GLint binarySize = 0;
//glGetProgramiv(id, GL_PROGRAM_BINARY_LENGTH, &binarySize);
@ -4921,7 +4968,7 @@ static void rlLoadShaderDefault(void)
RLGL.State.defaultShaderLocs[RL_SHADER_LOC_VERTEX_COLOR] = glGetAttribLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR);
// Set default shader locations: uniform locations
RLGL.State.defaultShaderLocs[RL_SHADER_LOC_MATRIX_MVP] = glGetUniformLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_UNIFORM_NAME_MVP);
RLGL.State.defaultShaderLocs[RL_SHADER_LOC_MATRIX_MVP] = glGetUniformLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_UNIFORM_NAME_MVP);
RLGL.State.defaultShaderLocs[RL_SHADER_LOC_COLOR_DIFFUSE] = glGetUniformLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR);
RLGL.State.defaultShaderLocs[RL_SHADER_LOC_MAP_DIFFUSE] = glGetUniformLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0);
}

View File

@ -38,7 +38,14 @@ pub const rlRenderBatch = extern struct {
currentDepth: f32,
};
pub const rlGlVersion = enum(c_int) { rl_opengl_11 = 1, rl_opengl_21 = 2, rl_opengl_33 = 3, rl_opengl_43 = 4, rl_opengl_es_20 = 5, rl_opengl_es_30 = 6 };
pub const rlGlVersion = enum(c_int) {
rl_opengl_11 = 1,
rl_opengl_21 = 2,
rl_opengl_33 = 3,
rl_opengl_43 = 4,
rl_opengl_es_20 = 5,
rl_opengl_es_30 = 6,
};
pub const rlTraceLogLevel = enum(c_int) {
rl_log_all = 0,
@ -143,7 +150,12 @@ pub const rlShaderUniformDataType = enum(c_uint) {
rl_shader_uniform_sampler2d = 12,
};
pub const rlShaderAttributeDataType = enum(c_uint) { rl_shader_attrib_float = 0, rl_shader_attrib_vec2 = 1, rl_shader_attrib_vec3 = 2, rl_shader_attrib_vec4 = 3 };
pub const rlShaderAttributeDataType = enum(c_uint) {
rl_shader_attrib_float = 0,
rl_shader_attrib_vec2 = 1,
rl_shader_attrib_vec3 = 2,
rl_shader_attrib_vec4 = 3,
};
pub const rlFramebufferAttachType = enum(c_uint) {
rl_attachment_color_channel0 = 0,
@ -809,8 +821,8 @@ pub fn rlLoadTextureDepth(width: i32, height: i32, useRenderBuffer: bool) u32 {
}
/// Load texture cubemap data
pub fn rlLoadTextureCubemap(data: ?*const anyopaque, size: i32, format: i32) u32 {
return @as(u32, cdef.rlLoadTextureCubemap(data, @as(c_int, size), @as(c_int, format)));
pub fn rlLoadTextureCubemap(data: ?*const anyopaque, size: i32, format: i32, mipmapCount: i32) u32 {
return @as(u32, cdef.rlLoadTextureCubemap(data, @as(c_int, size), @as(c_int, format), @as(c_int, mipmapCount)));
}
/// Update texture with new data on GPU