Bump raylib/zig versions

This commit is contained in:
Nikolas 2026-04-03 18:13:05 +02:00
parent aa9ee05f22
commit 8e04b7098a
Failed to generate hash of commit
20 changed files with 1383 additions and 1027 deletions

2
.gitignore vendored
View file

@ -1,6 +1,8 @@
zig-cache/
.zig-cache/
zig-out/
zig-pkg/
.idea/
Project/*
libraylib.a

View file

@ -39,6 +39,7 @@ fn getRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.buil
const raygui_dep = b.dependency("raygui", .{
.target = target,
.optimize = optimize,
.link_libc = true,
});
rl.addRaygui(b, raylib, raygui_dep, options);
@ -55,6 +56,7 @@ fn getModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.buil
.root_source_file = b.path("lib/raylib.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
}
@ -66,6 +68,7 @@ const gui = struct {
.imports = &.{.{ .name = "raylib-zig", .module = raylib }},
.target = target,
.optimize = optimize,
.link_libc = true,
});
}
};

View file

@ -4,12 +4,12 @@
.fingerprint = 0xc4cfa8c610114f28,
.dependencies = .{
.raylib = .{
.url = "git+https://github.com/raysan5/raylib#9f831428e6be0eba8762a154e3e9139d4f071970",
.hash = "raylib-5.6.0-dev-whq8uL592gQ782dF95oci4S61qrNVYK3MhpUpNwFgZ1J",
.url = "git+https://github.com/raysan5/raylib#f36533cbd8feead845a2e0b4568ec0484a15cd10",
.hash = "raylib-5.6.0-dev-whq8uGJqKQUEDd38DCov-XG29PYzw3kM_LNbPUkcDGyM",
},
.raygui = .{
.url = "git+https://github.com/raysan5/raygui#9cdfec460b43a17264af3c181c46f62bf107ac17",
.hash = "N-V-__8AALUbbwDKkSH4nbf3Ml_dTWo9qbELvle5i9eQZMuo",
.url = "git+https://github.com/raysan5/raygui#3b2855842ab578a034f827c38cf8f62c042fc983",
.hash = "N-V-__8AAHvybwBw1kyBGn0BW_s1RqIpycNjLf_XbE-fpLUF",
},
.emsdk = .{
.url = "git+https://github.com/emscripten-core/emsdk#4.0.9",
@ -20,7 +20,7 @@
.hash = "zemscripten-0.2.0-dev-sRlDqFJSAAB8hgnRt5DDMKP3zLlDtMnUDwYRJVCa5lGY",
},
},
.minimum_zig_version = "0.15.1",
.minimum_zig_version = "0.16.0-dev.3070+b22eb176b",
.paths = .{
"build.zig",
"build.zig.zon",

View file

@ -75,6 +75,7 @@ MANUAL = [
"ComputeCRC32",
"ComputeMD5",
"ComputeSHA1",
"ComputeSHA256",
"SetWindowIcons",
"CheckCollisionPointPoly",
"ColorToInt",

View file

@ -4,7 +4,7 @@ const std = @import("std");
pub const cdef = @import("raygui-ext.zig");
test {
std.testing.refAllDeclsRecursive(@This());
std.testing.refAllDecls(@This());
}
pub const RayguiError = error{GetIcons};
@ -120,6 +120,7 @@ pub const SliderProperty = enum(c_int) {
pub const ProgressBarProperty = enum(c_int) {
progress_padding = 16,
progress_side,
};
pub const ScrollBarProperty = enum(c_int) {
@ -411,22 +412,22 @@ pub const IconName = enum(c_int) {
slicing = 231,
manual_control = 232,
collision = 233,
icon_234 = 234,
icon_235 = 235,
icon_236 = 236,
icon_237 = 237,
icon_238 = 238,
icon_239 = 239,
icon_240 = 240,
icon_241 = 241,
icon_242 = 242,
icon_243 = 243,
icon_244 = 244,
icon_245 = 245,
icon_246 = 246,
icon_247 = 247,
icon_248 = 248,
icon_249 = 249,
circle_add = 234,
circle_add_fill = 235,
circle_warning = 236,
circle_warning_fill = 237,
box_more = 238,
box_more_fill = 239,
box_minus = 240,
box_minus_fill = 241,
union_ = 242,
intersection = 243,
difference = 244,
sphere = 245,
cylinder = 246,
cone = 247,
ellipsoid = 248,
capsule = 249,
icon_250 = 250,
icon_251 = 251,
icon_252 = 252,
@ -472,13 +473,13 @@ pub fn loadIcons(fileName: [*c]const u8, loadIconsName: bool) [*c][*c]u8 {
}
/// Tab Bar control, returns TAB to be closed or -1
pub fn tabBar(bounds: Rectangle, text: [][*:0]const u8, active: *i32) i32 {
return @as(i32, cdef.GuiTabBar(bounds, @as([*c][*c]const u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(active))));
pub fn tabBar(bounds: Rectangle, text: [][*:0]u8, active: *i32) i32 {
return @as(i32, cdef.GuiTabBar(bounds, @as([*c][*c]u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(active))));
}
/// List View with extended parameters
pub fn listViewEx(bounds: Rectangle, text: [][*:0]const u8, scrollIndex: *i32, active: *i32, focus: *i32) i32 {
return @as(i32, cdef.GuiListViewEx(bounds, @as([*c][*c]const u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(scrollIndex)), @as([*c]c_int, @ptrCast(active)), @as([*c]c_int, @ptrCast(focus))));
pub fn listViewEx(bounds: Rectangle, text: [][*:0]u8, scrollIndex: *i32, active: *i32, focus: *i32) i32 {
return @as(i32, cdef.GuiListViewEx(bounds, @as([*c][*c]u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(scrollIndex)), @as([*c]c_int, @ptrCast(active)), @as([*c]c_int, @ptrCast(focus))));
}
/// Panel control, useful to group controls

View file

@ -11,7 +11,7 @@ pub const math = @import("raymath.zig");
const C = std.builtin.CallingConvention.c;
test {
std.testing.refAllDeclsRecursive(@This());
std.testing.refAllDecls(@This());
}
pub const RaylibError = error{
@ -1401,6 +1401,8 @@ pub const Camera2D = extern struct {
pub const Mesh = extern struct {
vertexCount: c_int,
triangleCount: c_int,
// Vertex attributes data
vertices: [*c]f32,
texcoords: [*c]f32,
texcoords2: [*c]f32,
@ -1408,12 +1410,18 @@ pub const Mesh = extern struct {
tangents: [*c]f32,
colors: [*c]u8,
indices: [*c]c_ushort,
// Skin data for animation
boneCount: c_int,
boneIndices: [*c]u16,
boneWeights: [*c]f32,
// Runtime animation vertex data (CPU skinning)
// NOTE: In case of GPU skinning, not used, pointers are NULL
animVertices: [*c]f32,
animNormals: [*c]f32,
boneIds: [*c]u8,
boneWeights: [*c]f32,
boneMatrices: [*c]Matrix,
boneCount: c_int,
// OpenGL identifiers
vaoId: c_int,
vboId: [*c]c_int,
@ -1476,11 +1484,19 @@ pub const Transform = extern struct {
scale: Vector3,
};
pub const ModelAnimPose = [*c]Transform;
pub const BoneInfo = extern struct {
name: [32]u8,
parent: c_int,
};
pub const ModelSkeleton = extern struct {
boneCount: c_int,
bones: [*c]BoneInfo,
bindPose: ModelAnimPose
};
pub const Model = extern struct {
transform: Matrix,
meshCount: c_int,
@ -1488,9 +1504,11 @@ pub const Model = extern struct {
meshes: [*c]Mesh,
materials: [*c]Material,
meshMaterial: [*c]c_int,
boneCount: c_int,
bones: [*c]BoneInfo,
bindPose: [*c]Transform,
// Animation data
skeleton: ModelSkeleton,
currentPose: ModelAnimPose,
boneMatrices: [*c]Matrix,
/// Load model from file (meshes and materials)
pub fn init(fileName: [:0]const u8) RaylibError!Model {
@ -1529,12 +1547,12 @@ pub const Model = extern struct {
};
pub const ModelAnimation = extern struct {
boneCount: c_int,
frameCount: c_int,
bones: [*c]BoneInfo,
framePoses: [*c][*c]Transform,
name: [32]u8,
boneCount: c_int,
keyframeCount: c_int,
keyframePoses: [*c]ModelAnimPose,
/// Unload animation data
pub fn unload(self: ModelAnimation) void {
rl.unloadModelAnimation(self);
@ -1640,7 +1658,6 @@ pub const VrStereoConfig = extern struct {
};
pub const FilePathList = extern struct {
capacity: c_uint,
count: c_uint,
paths: [*c][*c]u8,
};
@ -1662,7 +1679,7 @@ pub const AutomationEventList = extern struct {
}
};
pub const ConfigFlags = packed struct {
pub const ConfigFlags = packed struct(u32) {
__reserved: bool = false,
fullscreen_mode: bool = false,
window_resizable: bool = false,
@ -1918,8 +1935,8 @@ pub const ShaderLocationIndex = enum(c_int) {
map_brdf = 25,
vertex_boneids = 26,
vertex_boneweights = 27,
bone_matrices = 28,
shader_loc_vertex_instance_tx = 29,
matrix_bonetransforms = 28,
matrix_instancetransforms = 29,
//
};
@ -2010,7 +2027,7 @@ pub const BlendMode = enum(c_int) {
custom_separate = 7,
};
pub const Gesture = packed struct {
pub const Gesture = packed struct(u16) {
tap: bool = false,
doubletap: bool = false,
hold: bool = false,
@ -2138,6 +2155,11 @@ pub fn computeSHA1(data: []u8) [5]u32 {
return res[0..5].*;
}
pub fn computeSHA256(data: []u8) [8]u32 {
const res: [*]c_uint = cdef.ComputeSHA256(@as([*c]u8, @ptrCast(data)), @as(c_int, @intCast(data.len)));
return res[0..8].*;
}
/// Load image from file into CPU memory (RAM)
pub fn loadImage(fileName: [:0]const u8) RaylibError!Image {
const image = cdef.LoadImage(@as([*c]const u8, @ptrCast(fileName)));

View file

@ -6,7 +6,7 @@ const std = @import("std");
pub const cdef = @import("raymath-ext.zig");
test {
std.testing.refAllDeclsRecursive(@This());
std.testing.refAllDecls(@This());
}
const Matrix = rl.Matrix;

View file

@ -6,7 +6,7 @@ const std = @import("std");
pub const cdef = @import("rlgl-ext.zig");
test {
std.testing.refAllDeclsRecursive(@This());
std.testing.refAllDecls(@This());
}
const Matrix = rl.Matrix;
@ -39,7 +39,7 @@ pub const rlRenderBatch = extern struct {
};
pub const rlGlVersion = enum(c_int) {
rl_opengl_11_software = 0,
rl_opengl_software = 0,
rl_opengl_11 = 1,
rl_opengl_21 = 2,
rl_opengl_33 = 3,
@ -268,6 +268,6 @@ pub const rl_default_shader_attrib_location_color = @as(i32, 3);
pub const rl_default_shader_attrib_location_tangent = @as(i32, 4);
pub const rl_default_shader_attrib_location_texcoord2 = @as(i32, 5);
pub const rl_default_shader_attrib_location_indices = @as(i32, 6);
pub const rl_default_shader_attrib_location_boneids = @as(i32, 7);
pub const rl_default_shader_attrib_location_boneweights = @as(i32, 5);
pub const rl_default_shader_attrib_location_instance_tx = @as(i32, 9);
pub const rl_default_shader_attrib_location_boneindices = @as(i32, 7);
pub const rl_default_shader_attrib_location_boneweights = @as(i32, 8);
pub const rl_default_shader_attrib_location_instancetransform = @as(i32, 9);

View file

@ -30,7 +30,7 @@ pub extern "c" fn GuiWindowBox(bounds: rl.Rectangle, title: [*c]const u8) c_int;
pub extern "c" fn GuiGroupBox(bounds: rl.Rectangle, text: [*c]const u8) c_int;
pub extern "c" fn GuiLine(bounds: rl.Rectangle, text: [*c]const u8) c_int;
pub extern "c" fn GuiPanel(bounds: rl.Rectangle, text: [*c]const u8) c_int;
pub extern "c" fn GuiTabBar(bounds: rl.Rectangle, text: [*c][*c]const u8, count: c_int, active: [*c]c_int) c_int;
pub extern "c" fn GuiTabBar(bounds: rl.Rectangle, text: [*c][*c]u8, count: c_int, active: [*c]c_int) c_int;
pub extern "c" fn GuiScrollPanel(bounds: rl.Rectangle, text: [*c]const u8, content: rl.Rectangle, scroll: [*c]rl.Vector2, view: [*c]rl.Rectangle) c_int;
pub extern "c" fn GuiLabel(bounds: rl.Rectangle, text: [*c]const u8) c_int;
pub extern "c" fn GuiButton(bounds: rl.Rectangle, text: [*c]const u8) c_int;
@ -52,7 +52,7 @@ pub extern "c" fn GuiStatusBar(bounds: rl.Rectangle, text: [*c]const u8) c_int;
pub extern "c" fn GuiDummyRec(bounds: rl.Rectangle, text: [*c]const u8) c_int;
pub extern "c" fn GuiGrid(bounds: rl.Rectangle, text: [*c]const u8, spacing: f32, subdivs: c_int, mouseCell: [*c]rl.Vector2) c_int;
pub extern "c" fn GuiListView(bounds: rl.Rectangle, text: [*c]const u8, scrollIndex: [*c]c_int, active: [*c]c_int) c_int;
pub extern "c" fn GuiListViewEx(bounds: rl.Rectangle, text: [*c][*c]const u8, count: c_int, scrollIndex: [*c]c_int, active: [*c]c_int, focus: [*c]c_int) c_int;
pub extern "c" fn GuiListViewEx(bounds: rl.Rectangle, text: [*c][*c]u8, count: c_int, scrollIndex: [*c]c_int, active: [*c]c_int, focus: [*c]c_int) c_int;
pub extern "c" fn GuiMessageBox(bounds: rl.Rectangle, title: [*c]const u8, message: [*c]const u8, buttons: [*c]const u8) c_int;
pub extern "c" fn GuiTextInputBox(bounds: rl.Rectangle, title: [*c]const u8, message: [*c]const u8, buttons: [*c]const u8, text: [*c]u8, textMaxSize: c_int, secretViewActive: [*c]bool) c_int;
pub extern "c" fn GuiColorPicker(bounds: rl.Rectangle, text: [*c]const u8, color: [*c]rl.Color) c_int;

587
lib/raygui.h vendored

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@ const std = @import("std");
pub const cdef = @import("raygui-ext.zig");
test {
std.testing.refAllDeclsRecursive(@This());
std.testing.refAllDecls(@This());
}
pub const RayguiError = error{GetIcons};
@ -120,6 +120,7 @@ pub const SliderProperty = enum(c_int) {
pub const ProgressBarProperty = enum(c_int) {
progress_padding = 16,
progress_side,
};
pub const ScrollBarProperty = enum(c_int) {
@ -411,22 +412,22 @@ pub const IconName = enum(c_int) {
slicing = 231,
manual_control = 232,
collision = 233,
icon_234 = 234,
icon_235 = 235,
icon_236 = 236,
icon_237 = 237,
icon_238 = 238,
icon_239 = 239,
icon_240 = 240,
icon_241 = 241,
icon_242 = 242,
icon_243 = 243,
icon_244 = 244,
icon_245 = 245,
icon_246 = 246,
icon_247 = 247,
icon_248 = 248,
icon_249 = 249,
circle_add = 234,
circle_add_fill = 235,
circle_warning = 236,
circle_warning_fill = 237,
box_more = 238,
box_more_fill = 239,
box_minus = 240,
box_minus_fill = 241,
union_ = 242,
intersection = 243,
difference = 244,
sphere = 245,
cylinder = 246,
cone = 247,
ellipsoid = 248,
capsule = 249,
icon_250 = 250,
icon_251 = 251,
icon_252 = 252,
@ -472,13 +473,13 @@ pub fn loadIcons(fileName: [*c]const u8, loadIconsName: bool) [*c][*c]u8 {
}
/// Tab Bar control, returns TAB to be closed or -1
pub fn tabBar(bounds: Rectangle, text: [][*:0]const u8, active: *i32) i32 {
return @as(i32, cdef.GuiTabBar(bounds, @as([*c][*c]const u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(active))));
pub fn tabBar(bounds: Rectangle, text: [][*:0]u8, active: *i32) i32 {
return @as(i32, cdef.GuiTabBar(bounds, @as([*c][*c]u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(active))));
}
/// List View with extended parameters
pub fn listViewEx(bounds: Rectangle, text: [][*:0]const u8, scrollIndex: *i32, active: *i32, focus: *i32) i32 {
return @as(i32, cdef.GuiListViewEx(bounds, @as([*c][*c]const u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(scrollIndex)), @as([*c]c_int, @ptrCast(active)), @as([*c]c_int, @ptrCast(focus))));
pub fn listViewEx(bounds: Rectangle, text: [][*:0]u8, scrollIndex: *i32, active: *i32, focus: *i32) i32 {
return @as(i32, cdef.GuiListViewEx(bounds, @as([*c][*c]u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(scrollIndex)), @as([*c]c_int, @ptrCast(active)), @as([*c]c_int, @ptrCast(focus))));
}
/// Panel control, useful to group controls

View file

@ -108,15 +108,11 @@ pub extern "c" fn UnloadRandomSequence(sequence: [*c]c_int) void;
pub extern "c" fn TakeScreenshot(fileName: [*c]const u8) void;
pub extern "c" fn SetConfigFlags(flags: rl.ConfigFlags) void;
pub extern "c" fn OpenURL(url: [*c]const u8) void;
pub extern "c" fn TraceLog(logLevel: rl.TraceLogLevel, text: [*c]const u8, ...) void;
pub extern "c" fn SetTraceLogLevel(logLevel: rl.TraceLogLevel) void;
pub extern "c" fn TraceLog(logLevel: rl.TraceLogLevel, text: [*c]const u8, ...) void;
pub extern "c" fn MemAlloc(size: c_uint) *anyopaque;
pub extern "c" fn MemRealloc(ptr: *anyopaque, size: c_uint) *anyopaque;
pub extern "c" fn MemFree(ptr: *anyopaque) void;
pub extern "c" fn SetLoadFileDataCallback(callback: rl.LoadFileDataCallback) void;
pub extern "c" fn SetSaveFileDataCallback(callback: rl.SaveFileDataCallback) void;
pub extern "c" fn SetLoadFileTextCallback(callback: rl.LoadFileTextCallback) void;
pub extern "c" fn SetSaveFileTextCallback(callback: rl.SaveFileTextCallback) void;
pub extern "c" fn LoadFileData(fileName: [*c]const u8, dataSize: [*c]c_int) [*c]u8;
pub extern "c" fn UnloadFileData(data: [*c]u8) void;
pub extern "c" fn SaveFileData(fileName: [*c]const u8, data: *anyopaque, dataSize: c_int) bool;
@ -124,6 +120,10 @@ pub extern "c" fn ExportDataAsCode(data: [*c]const u8, dataSize: c_int, fileName
pub extern "c" fn LoadFileText(fileName: [*c]const u8) [*c]u8;
pub extern "c" fn UnloadFileText(text: [*c]u8) void;
pub extern "c" fn SaveFileText(fileName: [*c]const u8, text: [*c]const u8) bool;
pub extern "c" fn SetLoadFileDataCallback(callback: rl.LoadFileDataCallback) void;
pub extern "c" fn SetSaveFileDataCallback(callback: rl.SaveFileDataCallback) void;
pub extern "c" fn SetLoadFileTextCallback(callback: rl.LoadFileTextCallback) void;
pub extern "c" fn SetSaveFileTextCallback(callback: rl.SaveFileTextCallback) void;
pub extern "c" fn FileRename(fileName: [*c]const u8, fileRename_: [*c]const u8) c_int;
pub extern "c" fn FileRemove(fileName: [*c]const u8) c_int;
pub extern "c" fn FileCopy(srcPath: [*c]const u8, dstPath: [*c]const u8) c_int;
@ -143,7 +143,7 @@ pub extern "c" fn GetPrevDirectoryPath(dirPath: [*c]const u8) [*c]const u8;
pub extern "c" fn GetWorkingDirectory() [*c]const u8;
pub extern "c" fn GetApplicationDirectory() [*c]const u8;
pub extern "c" fn MakeDirectory(dirPath: [*c]const u8) c_int;
pub extern "c" fn ChangeDirectory(dir: [*c]const u8) bool;
pub extern "c" fn ChangeDirectory(dirPath: [*c]const u8) bool;
pub extern "c" fn IsPathFile(path: [*c]const u8) bool;
pub extern "c" fn IsFileNameValid(fileName: [*c]const u8) bool;
pub extern "c" fn LoadDirectoryFiles(dirPath: [*c]const u8) rl.FilePathList;
@ -152,6 +152,8 @@ pub extern "c" fn UnloadDirectoryFiles(files: rl.FilePathList) void;
pub extern "c" fn IsFileDropped() bool;
pub extern "c" fn LoadDroppedFiles() rl.FilePathList;
pub extern "c" fn UnloadDroppedFiles(files: rl.FilePathList) void;
pub extern "c" fn GetDirectoryFileCount(dirPath: [*c]const u8) c_uint;
pub extern "c" fn GetDirectoryFileCountEx(basePath: [*c]const u8, filter: [*c]const u8, scanSubdirs: bool) c_uint;
pub extern "c" fn CompressData(data: [*c]const u8, dataSize: c_int, compDataSize: [*c]c_int) [*c]u8;
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;
@ -159,6 +161,7 @@ pub extern "c" fn DecodeDataBase64(text: [*c]const u8, outputSize: [*c]c_int) [*
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 ComputeSHA256(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;
@ -420,6 +423,7 @@ pub extern "c" fn DrawTextCodepoints(font: rl.Font, codepoints: [*c]const c_int,
pub extern "c" fn SetTextLineSpacing(spacing: c_int) void;
pub extern "c" fn MeasureText(text: [*c]const u8, fontSize: c_int) c_int;
pub extern "c" fn MeasureTextEx(font: rl.Font, text: [*c]const u8, fontSize: f32, spacing: f32) rl.Vector2;
pub extern "c" fn MeasureTextCodepoints(font: rl.Font, codepoints: [*c]const c_int, length: c_int, fontSize: f32, spacing: f32) rl.Vector2;
pub extern "c" fn GetGlyphIndex(font: rl.Font, codepoint: c_int) c_int;
pub extern "c" fn GetGlyphInfo(font: rl.Font, codepoint: c_int) rl.GlyphInfo;
pub extern "c" fn GetGlyphAtlasRec(font: rl.Font, codepoint: c_int) rl.Rectangle;
@ -442,8 +446,11 @@ pub extern "c" fn TextSubtext(text: [*c]const u8, position: c_int, length: c_int
pub extern "c" fn TextRemoveSpaces(text: [*c]const u8) [*c]const u8;
pub extern "c" fn GetTextBetween(text: [*c]const u8, begin: [*c]const u8, end: [*c]const u8) [*c]u8;
pub extern "c" fn TextReplace(text: [*c]const u8, search: [*c]const u8, replacement: [*c]const u8) [*c]u8;
pub extern "c" fn TextReplaceAlloc(text: [*c]const u8, search: [*c]const u8, replacement: [*c]const u8) [*c]u8;
pub extern "c" fn TextReplaceBetween(text: [*c]const u8, begin: [*c]const u8, end: [*c]const u8, replacement: [*c]const u8) [*c]u8;
pub extern "c" fn TextReplaceBetweenAlloc(text: [*c]const u8, begin: [*c]const u8, end: [*c]const u8, replacement: [*c]const u8) [*c]u8;
pub extern "c" fn TextInsert(text: [*c]const u8, insert: [*c]const u8, position: c_int) [*c]u8;
pub extern "c" fn TextInsertAlloc(text: [*c]const u8, insert: [*c]const u8, position: c_int) [*c]u8;
pub extern "c" fn TextJoin(textList: [*c][*c]u8, count: c_int, delimiter: [*c]const u8) [*c]u8;
pub extern "c" fn TextSplit(text: [*c]const u8, delimiter: u8, count: [*c]c_int) [*c][*c]u8;
pub extern "c" fn TextAppend(text: [*c]u8, append: [*c]const u8, position: [*c]c_int) void;
@ -485,8 +492,6 @@ pub extern "c" fn DrawModel(model: rl.Model, position: rl.Vector3, scale: f32, t
pub extern "c" fn DrawModelEx(model: rl.Model, position: rl.Vector3, rotationAxis: rl.Vector3, rotationAngle: f32, scale: rl.Vector3, tint: rl.Color) void;
pub extern "c" fn DrawModelWires(model: rl.Model, position: rl.Vector3, scale: f32, tint: rl.Color) void;
pub extern "c" fn DrawModelWiresEx(model: rl.Model, position: rl.Vector3, rotationAxis: rl.Vector3, rotationAngle: f32, scale: rl.Vector3, tint: rl.Color) void;
pub extern "c" fn DrawModelPoints(model: rl.Model, position: rl.Vector3, scale: f32, tint: rl.Color) void;
pub extern "c" fn DrawModelPointsEx(model: rl.Model, position: rl.Vector3, rotationAxis: rl.Vector3, rotationAngle: f32, scale: rl.Vector3, tint: rl.Color) void;
pub extern "c" fn DrawBoundingBox(box: rl.BoundingBox, color: rl.Color) void;
pub extern "c" fn DrawBillboard(camera: rl.Camera, texture: rl.Texture2D, position: rl.Vector3, scale: f32, tint: rl.Color) void;
pub extern "c" fn DrawBillboardRec(camera: rl.Camera, texture: rl.Texture2D, source: rl.Rectangle, position: rl.Vector3, size: rl.Vector2, tint: rl.Color) void;
@ -518,9 +523,8 @@ 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 UpdateModelAnimation(model: rl.Model, anim: rl.ModelAnimation, frame: f32) void;
pub extern "c" fn UpdateModelAnimationEx(model: rl.Model, animA: rl.ModelAnimation, frameA: f32, animB: rl.ModelAnimation, frameB: f32, blend: f32) 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 CheckCollisionSpheres(center1: rl.Vector3, radius1: f32, center2: rl.Vector3, radius2: f32) bool;

170
lib/raylib.h vendored
View file

@ -1,16 +1,16 @@
/**********************************************************************************************
*
* raylib v5.6-dev - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
* raylib v6.0 - 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
* - Multiplatform: Windows, Linux, macOS, FreeBSD, Web, Android, Raspberry Pi, DRM native...
* - Written in plain C code (C99) in PascalCase/camelCase notation
* - 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]
* - Software renderer optional, for systems with no GPU: [rlsw]
* - Custom OpenGL abstraction layer (usable as standalone module): [rlgl]
* - Multiple Fonts formats supported (TTF, OTF, FNT, BDF, Sprite fonts)
* - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
* - Many texture formats supportted, 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, M3D, GLTF)
@ -26,14 +26,12 @@
* - One default Shader is loaded on rlglInit()->rlLoadShaderDefault() [rlgl] (OpenGL 3.3 or ES2)
* - One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() [rlgl] (OpenGL 3.3 or ES2)
*
* DEPENDENCIES (included):
* [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
* DEPENDENCIES:
* [rcore] Depends on the selected platform backend, check rcore.c header for details
* [rlgl] glad/glad_gles2 (David Herberth - github.com/Dav1dde/glad) for OpenGL 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 Santamaria) for pseudo-random numbers generation
@ -42,6 +40,7 @@
* [rtextures] stb_image_write (Sean Barret) for image writing (BMP, TGA, PNG, JPG)
* [rtextures] stb_image_resize2 (Sean Barret) for image resizing algorithms
* [rtextures] stb_perlin (Sean Barret) for Perlin Noise image generation
* [rtextures] rltexgpu (Ramon Santamaria) for GPU-compressed texture formats
* [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
@ -63,7 +62,7 @@
* raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software:
*
* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5)
* Copyright (c) 2013-2026 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@ -87,10 +86,10 @@
#include <stdarg.h> // Required for: va_list - Only used by TraceLogCallback
#define RAYLIB_VERSION_MAJOR 5
#define RAYLIB_VERSION_MINOR 6
#define RAYLIB_VERSION_MAJOR 6
#define RAYLIB_VERSION_MINOR 0
#define RAYLIB_VERSION_PATCH 0
#define RAYLIB_VERSION "5.6-dev"
#define RAYLIB_VERSION "6.0"
// 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
@ -100,13 +99,13 @@
#define __declspec(x) __attribute__((x))
#endif
#if defined(BUILD_LIBTYPE_SHARED)
#define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll)
#define RLAPI __declspec(dllexport) // Building the library as a Win32 shared library (.dll)
#elif defined(USE_LIBTYPE_SHARED)
#define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll)
#define RLAPI __declspec(dllimport) // Using the library as a Win32 shared library (.dll)
#endif
#else
#if defined(BUILD_LIBTYPE_SHARED)
#define RLAPI __attribute__((visibility("default"))) // We are building as a Unix shared library (.so/.dylib)
#define RLAPI __attribute__((visibility("default"))) // Building as a Unix shared library (.so/.dylib)
#endif
#endif
@ -158,10 +157,10 @@
#error "C++11 or later is required. Add -std=c++11"
#endif
// NOTE: We set some defines with some data types declared by raylib
// NOTE: Set some defines with some data types declared by raylib
// Other modules (raymath, rlgl) also require some of those types, so,
// to be able to use those other modules as standalone (not depending on raylib)
// this defines are very useful for internal check and avoid type (re)definitions
// this defines are useful for internal check and avoid type (re)definitions
#define RL_COLOR_TYPE
#define RL_RECTANGLE_TYPE
#define RL_VECTOR2_TYPE
@ -335,10 +334,10 @@ typedef Camera3D Camera; // Camera type fallback, defaults to Camera3D
// Camera2D, defines position/orientation in 2d space
typedef struct Camera2D {
Vector2 offset; // Camera offset (displacement from target)
Vector2 target; // Camera target (rotation and zoom origin)
float rotation; // Camera rotation in degrees
float zoom; // Camera zoom (scaling), should be 1.0f by default
Vector2 offset; // Camera offset (screen space offset from window origin)
Vector2 target; // Camera target (world space target point that is mapped to screen space offset)
float rotation; // Camera rotation in degrees (pivots around target)
float zoom; // Camera zoom (scaling around target), must not be set to 0, set to 1.0f for no scale
} Camera2D;
// Mesh, vertex data and vao/vbo
@ -355,13 +354,15 @@ typedef struct Mesh {
unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
unsigned short *indices; // Vertex indices (in case vertex data comes indexed)
// Animation vertex data
// Skin data for animation
int boneCount; // Number of bones (MAX: 256 bones)
unsigned char *boneIndices; // Vertex bone indices, up to 4 bones influence by vertex (skinning) (shader-location = 6)
float *boneWeights; // Vertex bone weight, up to 4 bones influence by vertex (skinning) (shader-location = 7)
// Runtime animation vertex data (CPU skinning)
// NOTE: In case of GPU skinning, not used, pointers are NULL
float *animVertices; // Animated vertex positions (after bones transformations)
float *animNormals; // Animated normals (after bones transformations)
unsigned char *boneIds; // Vertex bone ids, max 255 bone ids, up to 4 bones influence by vertex (skinning) (shader-location = 6)
float *boneWeights; // Vertex bone weight, up to 4 bones influence by vertex (skinning) (shader-location = 7)
Matrix *boneMatrices; // Bones animated transformation matrices
int boneCount; // Number of bones
// OpenGL identifiers
unsigned int vaoId; // OpenGL Vertex Array Object id
@ -395,12 +396,22 @@ typedef struct Transform {
Vector3 scale; // Scale
} Transform;
// Anim pose, an array of Transform[]
typedef Transform *ModelAnimPose;
// Bone, skeletal animation bone
typedef struct BoneInfo {
char name[32]; // Bone name
int parent; // Bone parent
} BoneInfo;
// Skeleton, animation bones hierarchy
typedef struct ModelSkeleton {
int boneCount; // Number of bones
BoneInfo *bones; // Bones information (skeleton)
ModelAnimPose bindPose; // Bones base transformation (Transform[])
} ModelSkeleton;
// Model, meshes, materials and animation data
typedef struct Model {
Matrix transform; // Local transform matrix
@ -412,18 +423,20 @@ typedef struct Model {
int *meshMaterial; // Mesh material number
// Animation data
int boneCount; // Number of bones
BoneInfo *bones; // Bones information (skeleton)
Transform *bindPose; // Bones base transformation (pose)
ModelSkeleton skeleton; // Skeleton for animation
// Runtime animation data (CPU/GPU skinning)
ModelAnimPose currentPose; // Current animation pose (Transform[])
Matrix *boneMatrices; // Bones animated transformation matrices
} Model;
// ModelAnimation
// ModelAnimation, contains a full animation sequence
typedef struct ModelAnimation {
int boneCount; // Number of bones
int frameCount; // Number of animation frames
BoneInfo *bones; // Bones information (skeleton)
Transform **framePoses; // Poses array by frame
char name[32]; // Animation name
int boneCount; // Number of bones (per pose)
int keyframeCount; // Number of animation key frames
ModelAnimPose *keyframePoses; // Animation sequence keyframe poses [keyframe][pose]
} ModelAnimation;
// Ray, ray for raycasting
@ -513,7 +526,6 @@ typedef struct VrStereoConfig {
// File path list
typedef struct FilePathList {
unsigned int capacity; // Filepaths max entries
unsigned int count; // Filepaths entries count
char **paths; // Filepaths entries
} FilePathList;
@ -571,8 +583,7 @@ typedef enum {
} TraceLogLevel;
// Keyboard keys (US keyboard layout)
// NOTE: Use GetKeyPressed() to allow redefining
// required keys for alternative layouts
// NOTE: Use GetKeyPressed() to allow redefining required keys for alternative layouts
typedef enum {
KEY_NULL = 0, // Key: NULL, used for no key pressed
// Alphanumeric keys
@ -723,7 +734,7 @@ typedef enum {
// Gamepad buttons
typedef enum {
GAMEPAD_BUTTON_UNKNOWN = 0, // Unknown button, just for error checking
GAMEPAD_BUTTON_UNKNOWN = 0, // Unknown button, for error checking
GAMEPAD_BUTTON_LEFT_FACE_UP, // Gamepad left DPAD up button
GAMEPAD_BUTTON_LEFT_FACE_RIGHT, // Gamepad left DPAD right button
GAMEPAD_BUTTON_LEFT_FACE_DOWN, // Gamepad left DPAD down button
@ -772,6 +783,8 @@ typedef enum {
#define MATERIAL_MAP_SPECULAR MATERIAL_MAP_METALNESS
// Shader location index
// NOTE: Some locations are tried to be set automatically on shader loading,
// but only if default attributes/uniforms names are found, check config.h for names
typedef enum {
SHADER_LOC_VERTEX_POSITION = 0, // Shader location: vertex attribute: position
SHADER_LOC_VERTEX_TEXCOORD01, // Shader location: vertex attribute: texcoord01
@ -794,15 +807,15 @@ typedef enum {
SHADER_LOC_MAP_ROUGHNESS, // Shader location: sampler2d texture: roughness
SHADER_LOC_MAP_OCCLUSION, // Shader location: sampler2d texture: occlusion
SHADER_LOC_MAP_EMISSION, // Shader location: sampler2d texture: emission
SHADER_LOC_MAP_HEIGHT, // Shader location: sampler2d texture: height
SHADER_LOC_MAP_HEIGHT, // Shader location: sampler2d texture: heightmap
SHADER_LOC_MAP_CUBEMAP, // Shader location: samplerCube texture: cubemap
SHADER_LOC_MAP_IRRADIANCE, // Shader location: samplerCube texture: irradiance
SHADER_LOC_MAP_PREFILTER, // Shader location: samplerCube texture: prefilter
SHADER_LOC_MAP_BRDF, // Shader location: sampler2d texture: brdf
SHADER_LOC_VERTEX_BONEIDS, // Shader location: vertex attribute: boneIds
SHADER_LOC_VERTEX_BONEWEIGHTS, // Shader location: vertex attribute: boneWeights
SHADER_LOC_BONE_MATRICES, // Shader location: array of matrices uniform: boneMatrices
SHADER_LOC_VERTEX_INSTANCE_TX // Shader location: vertex attribute: instanceTransform
SHADER_LOC_VERTEX_BONEIDS, // Shader location: vertex attribute: bone indices
SHADER_LOC_VERTEX_BONEWEIGHTS, // Shader location: vertex attribute: bone weights
SHADER_LOC_MATRIX_BONETRANSFORMS, // Shader location: matrix attribute: bone transforms (animation)
SHADER_LOC_VERTEX_INSTANCETRANSFORM // Shader location: vertex attribute: instance transforms
} ShaderLocationIndex;
#define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO
@ -866,7 +879,7 @@ typedef enum {
// NOTE 1: Filtering considers mipmaps if available in the texture
// NOTE 2: Filter is accordingly set for minification and magnification
typedef enum {
TEXTURE_FILTER_POINT = 0, // No filter, just pixel approximation
TEXTURE_FILTER_POINT = 0, // No filter, pixel approximation
TEXTURE_FILTER_BILINEAR, // Linear filtering
TEXTURE_FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps)
TEXTURE_FILTER_ANISOTROPIC_4X, // Anisotropic filtering 4x
@ -1100,23 +1113,17 @@ RLAPI void TakeScreenshot(const char *fileName); // Takes a scr
RLAPI void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS)
RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available)
// NOTE: Following functions implemented in module [utils]
//------------------------------------------------------------------
RLAPI void TraceLog(int logLevel, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
// Logging system
RLAPI void SetTraceLogLevel(int logLevel); // Set the current threshold (minimum) log level
RLAPI void TraceLog(int logLevel, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log
// Memory management, using internal allocators
RLAPI void *MemAlloc(unsigned int size); // Internal memory allocator
RLAPI void *MemRealloc(void *ptr, unsigned int size); // Internal memory reallocator
RLAPI void MemFree(void *ptr); // Internal memory free
// Set custom callbacks
// WARNING: Callbacks setup is intended for advanced users
RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log
RLAPI void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader
RLAPI void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver
RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader
RLAPI void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom file text data saver
// Files management functions
// File system management functions
RLAPI unsigned char *LoadFileData(const char *fileName, int *dataSize); // Load file data as byte array (read)
RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData()
RLAPI bool SaveFileData(const char *fileName, void *data, int dataSize); // Save data to file from byte array (write), returns true on success
@ -1124,9 +1131,14 @@ RLAPI bool ExportDataAsCode(const unsigned char *data, int dataSize, const char
RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string
RLAPI void UnloadFileText(char *text); // Unload file text data allocated by LoadFileText()
RLAPI bool SaveFileText(const char *fileName, const char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success
//------------------------------------------------------------------
// File system functions
// File access custom callbacks
// WARNING: Callbacks setup is intended for advanced users
RLAPI void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader
RLAPI void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver
RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader
RLAPI void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom file text data saver
RLAPI int FileRename(const char *fileName, const char *fileRename); // Rename file (if exists)
RLAPI int FileRemove(const char *fileName); // Remove file (if exists)
RLAPI int FileCopy(const char *srcPath, const char *dstPath); // Copy file from one path to another, dstPath created if it doesn't exist
@ -1146,15 +1158,17 @@ RLAPI const char *GetPrevDirectoryPath(const char *dirPath); // Get previ
RLAPI const char *GetWorkingDirectory(void); // Get current working directory (uses static string)
RLAPI const char *GetApplicationDirectory(void); // Get the directory of the running application (uses static string)
RLAPI int MakeDirectory(const char *dirPath); // Create directories (including full path requested), returns 0 on success
RLAPI bool ChangeDirectory(const char *dir); // Change working directory, return true on success
RLAPI bool ChangeDirectory(const char *dirPath); // Change working directory, return true on success
RLAPI bool IsPathFile(const char *path); // Check if a given path is a file or a directory
RLAPI bool IsFileNameValid(const char *fileName); // Check if fileName is valid for the platform/OS
RLAPI FilePathList LoadDirectoryFiles(const char *dirPath); // Load directory filepaths
RLAPI FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs); // Load directory filepaths with extension filtering and recursive directory scan. Use 'DIR' in the filter string to include directories in the result
RLAPI FilePathList LoadDirectoryFiles(const char *dirPath); // Load directory filepaths, files and directories, no subdirs scan
RLAPI FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs); // Load directory filepaths with extension filtering and subdir scan; some filters available: "*.*", "FILES*", "DIRS*"
RLAPI void UnloadDirectoryFiles(FilePathList files); // Unload filepaths
RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window
RLAPI FilePathList LoadDroppedFiles(void); // Load dropped filepaths
RLAPI void UnloadDroppedFiles(FilePathList files); // Unload dropped filepaths
RLAPI unsigned int GetDirectoryFileCount(const char *dirPath); // Get the file count in a directory
RLAPI unsigned int GetDirectoryFileCountEx(const char *basePath, const char *filter, bool scanSubdirs); // 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
// Compression/Encoding functionality
RLAPI unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize); // Compress data (DEFLATE algorithm), memory must be MemFree()
@ -1164,6 +1178,7 @@ RLAPI unsigned char *DecodeDataBase64(const char *text, int *outputSize);
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)
RLAPI unsigned int *ComputeSHA256(unsigned char *data, int dataSize); // Compute SHA256 hash code, returns static int[8] (32 bytes)
// Automation events functionality
RLAPI AutomationEventList LoadAutomationEventList(const char *fileName); // Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS
@ -1344,7 +1359,7 @@ RLAPI Image LoadImageFromScreen(void);
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
RLAPI unsigned char *ExportImageToMemory(Image image, const char *fileType, int *fileSize); // Export image to memory buffer, memory must be MemFree()
RLAPI bool ExportImageAsCode(Image image, const char *fileName); // Export image as code file defining an array of bytes, returns true on success
// Image generation functions
@ -1495,6 +1510,7 @@ RLAPI void DrawTextCodepoints(Font font, const int *codepoints, int codepointCou
RLAPI void SetTextLineSpacing(int spacing); // Set vertical line spacing when drawing with line-breaks
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
RLAPI Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // Measure string size for Font
RLAPI Vector2 MeasureTextCodepoints(Font font, const int *codepoints, int length, float fontSize, float spacing); // Measure string size for an existing array of codepoints for Font
RLAPI int GetGlyphIndex(Font font, int codepoint); // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found
RLAPI GlyphInfo GetGlyphInfo(Font font, int codepoint); // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found
RLAPI Rectangle GetGlyphAtlasRec(Font font, int codepoint); // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found
@ -1512,7 +1528,7 @@ RLAPI const char *CodepointToUTF8(int codepoint, int *utf8Size);
// Text strings management functions (no UTF-8 strings, only byte chars)
// WARNING 1: Most of these functions use internal static buffers[], it's recommended to store returned data on user-side for re-use
// WARNING 2: Some strings allocate memory internally for the returned strings, those strings must be free by user using MemFree()
// WARNING 2: Some functions allocate memory internally for the returned strings, those strings must be freed by user using MemFree()
RLAPI char **LoadTextLines(const char *text, int *count); // Load text as separate lines ('\n')
RLAPI void UnloadTextLines(char **text, int lineCount); // Unload text lines
RLAPI int TextCopy(char *dst, const char *src); // Copy one string to another, returns bytes copied
@ -1522,9 +1538,12 @@ RLAPI const char *TextFormat(const char *text, ...);
RLAPI const char *TextSubtext(const char *text, int position, int length); // Get a piece of a text string
RLAPI const char *TextRemoveSpaces(const char *text); // Remove text spaces, concat words
RLAPI char *GetTextBetween(const char *text, const char *begin, const char *end); // Get text between two strings
RLAPI char *TextReplace(const char *text, const char *search, const char *replacement); // Replace text string (WARNING: memory must be freed!)
RLAPI char *TextReplaceBetween(const char *text, const char *begin, const char *end, const char *replacement); // Replace text between two specific strings (WARNING: memory must be freed!)
RLAPI char *TextInsert(const char *text, const char *insert, int position); // Insert text in a position (WARNING: memory must be freed!)
RLAPI char *TextReplace(const char *text, const char *search, const char *replacement); // Replace text string with new string
RLAPI char *TextReplaceAlloc(const char *text, const char *search, const char *replacement); // Replace text string with new string, memory must be MemFree()
RLAPI char *TextReplaceBetween(const char *text, const char *begin, const char *end, const char *replacement); // Replace text between two specific strings
RLAPI char *TextReplaceBetweenAlloc(const char *text, const char *begin, const char *end, const char *replacement); // Replace text between two specific strings, memory must be MemFree()
RLAPI char *TextInsert(const char *text, const char *insert, int position); // Insert text in a defined byte position
RLAPI char *TextInsertAlloc(const char *text, const char *insert, int position); // Insert text in a defined byte position, memory must be MemFree()
RLAPI char *TextJoin(char **textList, int count, const char *delimiter); // Join text strings with delimiter
RLAPI char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings, using MAX_TEXTSPLIT_COUNT static strings
RLAPI void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor
@ -1580,8 +1599,6 @@ RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint);
RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters
RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set)
RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters
RLAPI void DrawModelPoints(Model model, Vector3 position, float scale, Color tint); // Draw a model as points
RLAPI void DrawModelPointsEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model as points with extended parameters
RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 position, float scale, Color tint); // Draw a billboard texture
RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint); // Draw a billboard texture defined by source
@ -1621,9 +1638,8 @@ RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId);
// 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 (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 UpdateModelAnimation(Model model, ModelAnimation anim, float frame); // Update model animation pose (vertex buffers and bone matrices)
RLAPI void UpdateModelAnimationEx(Model model, ModelAnimation animA, float frameA, ModelAnimation animB, float frameB, float blend); // Update model animation pose, blending two animations
RLAPI void UnloadModelAnimations(ModelAnimation *animations, int animCount); // Unload animation array data
RLAPI bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match
@ -1657,7 +1673,7 @@ RLAPI Sound LoadSound(const char *fileName); // Load so
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 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 (data and frame count should fit in sound)
RLAPI void UpdateSound(Sound sound, const void *data, int sampleCount); // Update sound buffer with new data (default data format: 32 bit float, stereo)
RLAPI void UnloadWave(Wave wave); // Unload wave data
RLAPI void UnloadSound(Sound sound); // Unload sound
RLAPI void UnloadSoundAlias(Sound alias); // Unload a sound alias (does not deallocate sample data)
@ -1672,7 +1688,7 @@ RLAPI void ResumeSound(Sound sound); // Resume
RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)
RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
RLAPI void SetSoundPan(Sound sound, float pan); // Set pan for a sound (0.5 is center)
RLAPI void SetSoundPan(Sound sound, float pan); // Set pan for a sound (-1.0 left, 0.0 center, 1.0 right)
RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave
RLAPI void WaveCrop(Wave *wave, int initFrame, int finalFrame); // Crop a wave to defined frames range
RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format
@ -1693,7 +1709,7 @@ RLAPI void ResumeMusicStream(Music music); // Resume
RLAPI void SeekMusicStream(Music music, float position); // Seek music to a position (in seconds)
RLAPI void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)
RLAPI void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)
RLAPI void SetMusicPan(Music music, float pan); // Set pan for a music (0.5 is center)
RLAPI void SetMusicPan(Music music, float pan); // Set pan for a music (-1.0 left, 0.0 center, 1.0 right)
RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)
RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
@ -1710,7 +1726,7 @@ RLAPI bool IsAudioStreamPlaying(AudioStream stream); // Check i
RLAPI void StopAudioStream(AudioStream stream); // Stop audio stream
RLAPI void SetAudioStreamVolume(AudioStream stream, float volume); // Set volume for audio stream (1.0 is max level)
RLAPI void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level)
RLAPI void SetAudioStreamPan(AudioStream stream, float pan); // Set pan for audio stream (0.5 is centered)
RLAPI void SetAudioStreamPan(AudioStream stream, float pan); // Set pan for audio stream (-1.0 to 1.0 range, 0.0 is centered)
RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams
RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data

View file

@ -11,7 +11,7 @@ pub const math = @import("raymath.zig");
const C = std.builtin.CallingConvention.c;
test {
std.testing.refAllDeclsRecursive(@This());
std.testing.refAllDecls(@This());
}
pub const RaylibError = error{
@ -1401,6 +1401,8 @@ pub const Camera2D = extern struct {
pub const Mesh = extern struct {
vertexCount: c_int,
triangleCount: c_int,
// Vertex attributes data
vertices: [*c]f32,
texcoords: [*c]f32,
texcoords2: [*c]f32,
@ -1408,12 +1410,18 @@ pub const Mesh = extern struct {
tangents: [*c]f32,
colors: [*c]u8,
indices: [*c]c_ushort,
// Skin data for animation
boneCount: c_int,
boneIndices: [*c]u16,
boneWeights: [*c]f32,
// Runtime animation vertex data (CPU skinning)
// NOTE: In case of GPU skinning, not used, pointers are NULL
animVertices: [*c]f32,
animNormals: [*c]f32,
boneIds: [*c]u8,
boneWeights: [*c]f32,
boneMatrices: [*c]Matrix,
boneCount: c_int,
// OpenGL identifiers
vaoId: c_int,
vboId: [*c]c_int,
@ -1476,11 +1484,19 @@ pub const Transform = extern struct {
scale: Vector3,
};
pub const ModelAnimPose = [*c]Transform;
pub const BoneInfo = extern struct {
name: [32]u8,
parent: c_int,
};
pub const ModelSkeleton = extern struct {
boneCount: c_int,
bones: [*c]BoneInfo,
bindPose: ModelAnimPose
};
pub const Model = extern struct {
transform: Matrix,
meshCount: c_int,
@ -1488,9 +1504,11 @@ pub const Model = extern struct {
meshes: [*c]Mesh,
materials: [*c]Material,
meshMaterial: [*c]c_int,
boneCount: c_int,
bones: [*c]BoneInfo,
bindPose: [*c]Transform,
// Animation data
skeleton: ModelSkeleton,
currentPose: ModelAnimPose,
boneMatrices: [*c]Matrix,
/// Load model from file (meshes and materials)
pub fn init(fileName: [:0]const u8) RaylibError!Model {
@ -1529,12 +1547,12 @@ pub const Model = extern struct {
};
pub const ModelAnimation = extern struct {
boneCount: c_int,
frameCount: c_int,
bones: [*c]BoneInfo,
framePoses: [*c][*c]Transform,
name: [32]u8,
boneCount: c_int,
keyframeCount: c_int,
keyframePoses: [*c]ModelAnimPose,
/// Unload animation data
pub fn unload(self: ModelAnimation) void {
rl.unloadModelAnimation(self);
@ -1640,7 +1658,6 @@ pub const VrStereoConfig = extern struct {
};
pub const FilePathList = extern struct {
capacity: c_uint,
count: c_uint,
paths: [*c][*c]u8,
};
@ -1662,7 +1679,7 @@ pub const AutomationEventList = extern struct {
}
};
pub const ConfigFlags = packed struct {
pub const ConfigFlags = packed struct(u32) {
__reserved: bool = false,
fullscreen_mode: bool = false,
window_resizable: bool = false,
@ -1919,8 +1936,8 @@ pub const ShaderLocationIndex = enum(c_int) {
map_brdf = 25,
vertex_boneids = 26,
vertex_boneweights = 27,
bone_matrices = 28,
shader_loc_vertex_instance_tx = 29,
matrix_bonetransforms = 28,
matrix_instancetransforms = 29,
//
};
@ -2011,7 +2028,7 @@ pub const BlendMode = enum(c_int) {
custom_separate = 7,
};
pub const Gesture = packed struct {
pub const Gesture = packed struct(u16) {
tap: bool = false,
doubletap: bool = false,
hold: bool = false,
@ -2139,6 +2156,11 @@ pub fn computeSHA1(data: []u8) [5]u32 {
return res[0..5].*;
}
pub fn computeSHA256(data: []u8) [8]u32 {
const res: [*]c_uint = cdef.ComputeSHA256(@as([*c]u8, @ptrCast(data)), @as(c_int, @intCast(data.len)));
return res[0..8].*;
}
/// Load image from file into CPU memory (RAM)
pub fn loadImage(fileName: [:0]const u8) RaylibError!Image {
const image = cdef.LoadImage(@as([*c]const u8, @ptrCast(fileName)));
@ -3128,26 +3150,6 @@ pub fn memFree(ptr: *anyopaque) void {
cdef.MemFree(ptr);
}
/// Set custom file binary data loader
pub fn setLoadFileDataCallback(callback: LoadFileDataCallback) void {
cdef.SetLoadFileDataCallback(callback);
}
/// Set custom file binary data saver
pub fn setSaveFileDataCallback(callback: SaveFileDataCallback) void {
cdef.SetSaveFileDataCallback(callback);
}
/// Set custom file text data loader
pub fn setLoadFileTextCallback(callback: LoadFileTextCallback) void {
cdef.SetLoadFileTextCallback(callback);
}
/// Set custom file text data saver
pub fn setSaveFileTextCallback(callback: SaveFileTextCallback) void {
cdef.SetSaveFileTextCallback(callback);
}
/// Load file data as byte array (read)
pub fn loadFileData(fileName: []const u8) RaylibError![]u8 {
var _len: i32 = 0;
@ -3176,6 +3178,26 @@ pub fn saveFileText(fileName: [:0]const u8, text: [:0]const u8) bool {
return cdef.SaveFileText(@as([*c]const u8, @ptrCast(fileName)), @as([*c]const u8, @ptrCast(text)));
}
/// Set custom file binary data loader
pub fn setLoadFileDataCallback(callback: LoadFileDataCallback) void {
cdef.SetLoadFileDataCallback(callback);
}
/// Set custom file binary data saver
pub fn setSaveFileDataCallback(callback: SaveFileDataCallback) void {
cdef.SetSaveFileDataCallback(callback);
}
/// Set custom file text data loader
pub fn setLoadFileTextCallback(callback: LoadFileTextCallback) void {
cdef.SetLoadFileTextCallback(callback);
}
/// Set custom file text data saver
pub fn setSaveFileTextCallback(callback: SaveFileTextCallback) void {
cdef.SetSaveFileTextCallback(callback);
}
/// Rename file (if exists)
pub fn fileRename(fileName: [:0]const u8, fileRename_: [:0]const u8) i32 {
return @as(i32, cdef.FileRename(@as([*c]const u8, @ptrCast(fileName)), @as([*c]const u8, @ptrCast(fileRename_))));
@ -3272,8 +3294,8 @@ pub fn makeDirectory(dirPath: [:0]const u8) i32 {
}
/// Change working directory, return true on success
pub fn changeDirectory(dir: [:0]const u8) bool {
return cdef.ChangeDirectory(@as([*c]const u8, @ptrCast(dir)));
pub fn changeDirectory(dirPath: [:0]const u8) bool {
return cdef.ChangeDirectory(@as([*c]const u8, @ptrCast(dirPath)));
}
/// Check if a given path is a file or a directory
@ -3286,12 +3308,12 @@ pub fn isFileNameValid(fileName: [:0]const u8) bool {
return cdef.IsFileNameValid(@as([*c]const u8, @ptrCast(fileName)));
}
/// Load directory filepaths
/// Load directory filepaths, files and directories, no subdirs scan
pub fn loadDirectoryFiles(dirPath: [:0]const u8) FilePathList {
return cdef.LoadDirectoryFiles(@as([*c]const u8, @ptrCast(dirPath)));
}
/// Load directory filepaths with extension filtering and recursive directory scan. Use 'DIR' in the filter string to include directories in the result
/// Load directory filepaths with extension filtering and subdir scan; some filters available: "*.*", "FILES*", "DIRS*"
pub fn loadDirectoryFilesEx(basePath: [:0]const u8, filter: [:0]const u8, scanSubdirs: bool) FilePathList {
return cdef.LoadDirectoryFilesEx(@as([*c]const u8, @ptrCast(basePath)), @as([*c]const u8, @ptrCast(filter)), scanSubdirs);
}
@ -3316,6 +3338,16 @@ pub fn unloadDroppedFiles(files: FilePathList) void {
cdef.UnloadDroppedFiles(files);
}
/// Get the file count in a directory
pub fn getDirectoryFileCount(dirPath: [:0]const u8) u32 {
return @as(u32, cdef.GetDirectoryFileCount(@as([*c]const u8, @ptrCast(dirPath))));
}
/// 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
pub fn getDirectoryFileCountEx(basePath: [:0]const u8, filter: [:0]const u8, scanSubdirs: bool) u32 {
return @as(u32, cdef.GetDirectoryFileCountEx(@as([*c]const u8, @ptrCast(basePath)), @as([*c]const u8, @ptrCast(filter)), scanSubdirs));
}
/// Compress data (DEFLATE algorithm), memory must be MemFree()
pub fn compressData(data: []const u8, dataSize: i32) RaylibError![]u8 {
var _len: i32 = 0;
@ -3948,7 +3980,7 @@ pub fn exportImage(image: Image, fileName: [:0]const u8) bool {
return cdef.ExportImage(image, @as([*c]const u8, @ptrCast(fileName)));
}
/// Export image to memory buffer
/// Export image to memory buffer, memory must be MemFree()
pub fn exportImageToMemory(image: Image, fileType: []const u8) RaylibError![]u8 {
var _len: i32 = 0;
const _ptr = cdef.ExportImageToMemory(image, @as([*c]const u8, @ptrCast(fileType)), @as([*c]c_int, @ptrCast(&_len)));
@ -4489,6 +4521,11 @@ pub fn measureTextEx(font: Font, text: [:0]const u8, fontSize: f32, spacing: f32
return cdef.MeasureTextEx(font, @as([*c]const u8, @ptrCast(text)), fontSize, spacing);
}
/// Measure string size for an existing array of codepoints for Font
pub fn measureTextCodepoints(font: Font, codepoints: []const c_int, length: i32, fontSize: f32, spacing: f32) Vector2 {
return cdef.MeasureTextCodepoints(font, @as([*c]const c_int, @ptrCast(codepoints)), @as(c_int, length), fontSize, spacing);
}
/// Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found
pub fn getGlyphIndex(font: Font, codepoint: i32) i32 {
return @as(i32, cdef.GetGlyphIndex(font, @as(c_int, codepoint)));
@ -4577,21 +4614,36 @@ pub fn getTextBetween(text: [:0]const u8, begin: [:0]const u8, end: [:0]const u8
return std.mem.span(cdef.GetTextBetween(@as([*c]const u8, @ptrCast(text)), @as([*c]const u8, @ptrCast(begin)), @as([*c]const u8, @ptrCast(end))));
}
/// Replace text string (WARNING: memory must be freed!)
/// Replace text string with new string
pub fn textReplace(text: [:0]const u8, search: [:0]const u8, replacement: [:0]const u8) [:0]u8 {
return std.mem.span(cdef.TextReplace(@as([*c]const u8, @ptrCast(text)), @as([*c]const u8, @ptrCast(search)), @as([*c]const u8, @ptrCast(replacement))));
}
/// Replace text between two specific strings (WARNING: memory must be freed!)
/// Replace text string with new string, memory must be MemFree()
pub fn textReplaceAlloc(text: [:0]const u8, search: [:0]const u8, replacement: [:0]const u8) [:0]u8 {
return std.mem.span(cdef.TextReplaceAlloc(@as([*c]const u8, @ptrCast(text)), @as([*c]const u8, @ptrCast(search)), @as([*c]const u8, @ptrCast(replacement))));
}
/// Replace text between two specific strings
pub fn textReplaceBetween(text: [:0]const u8, begin: [:0]const u8, end: [:0]const u8, replacement: [:0]const u8) [:0]u8 {
return std.mem.span(cdef.TextReplaceBetween(@as([*c]const u8, @ptrCast(text)), @as([*c]const u8, @ptrCast(begin)), @as([*c]const u8, @ptrCast(end)), @as([*c]const u8, @ptrCast(replacement))));
}
/// Insert text in a position (WARNING: memory must be freed!)
/// Replace text between two specific strings, memory must be MemFree()
pub fn textReplaceBetweenAlloc(text: [:0]const u8, begin: [:0]const u8, end: [:0]const u8, replacement: [:0]const u8) [:0]u8 {
return std.mem.span(cdef.TextReplaceBetweenAlloc(@as([*c]const u8, @ptrCast(text)), @as([*c]const u8, @ptrCast(begin)), @as([*c]const u8, @ptrCast(end)), @as([*c]const u8, @ptrCast(replacement))));
}
/// Insert text in a defined byte position
pub fn textInsert(text: [:0]const u8, insert: [:0]const u8, position: i32) [:0]u8 {
return std.mem.span(cdef.TextInsert(@as([*c]const u8, @ptrCast(text)), @as([*c]const u8, @ptrCast(insert)), @as(c_int, position)));
}
/// Insert text in a defined byte position, memory must be MemFree()
pub fn textInsertAlloc(text: [:0]const u8, insert: [:0]const u8, position: i32) [:0]u8 {
return std.mem.span(cdef.TextInsertAlloc(@as([*c]const u8, @ptrCast(text)), @as([*c]const u8, @ptrCast(insert)), @as(c_int, position)));
}
/// Split text into multiple strings, using MAX_TEXTSPLIT_COUNT static strings
pub fn textSplit(text: []const u8, delimiter: u8) RaylibError![][:0]u8 {
var _len: i32 = 0;
@ -4780,16 +4832,6 @@ pub fn drawModelWiresEx(model: Model, position: Vector3, rotationAxis: Vector3,
cdef.DrawModelWiresEx(model, position, rotationAxis, rotationAngle, scale, tint);
}
/// Draw a model as points
pub fn drawModelPoints(model: Model, position: Vector3, scale: f32, tint: Color) void {
cdef.DrawModelPoints(model, position, scale, tint);
}
/// Draw a model as points with extended parameters
pub fn drawModelPointsEx(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) void {
cdef.DrawModelPointsEx(model, position, rotationAxis, rotationAngle, scale, tint);
}
/// Draw bounding box (wires)
pub fn drawBoundingBox(box: BoundingBox, color: Color) void {
cdef.DrawBoundingBox(box, color);
@ -4933,19 +4975,14 @@ pub fn loadModelAnimations(fileName: []const u8) RaylibError![]ModelAnimation {
return _ptr[0..@as(usize, @intCast(_len))];
}
/// 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 pose (vertex buffers and bone matrices)
pub fn updateModelAnimation(model: Model, anim: ModelAnimation, frame: f32) void {
cdef.UpdateModelAnimation(model, anim, 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);
/// Update model animation pose, blending two animations
pub fn updateModelAnimationEx(model: Model, animA: ModelAnimation, frameA: f32, animB: ModelAnimation, frameB: f32, blend: f32) void {
cdef.UpdateModelAnimationEx(model, animA, frameA, animB, frameB, blend);
}
/// Check model animation skeleton match
@ -5038,7 +5075,7 @@ pub fn isSoundValid(sound: Sound) bool {
return cdef.IsSoundValid(sound);
}
/// Update sound buffer with new data (data and frame count should fit in sound)
/// Update sound buffer with new data (default data format: 32 bit float, stereo)
pub fn updateSound(sound: Sound, data: *const anyopaque, sampleCount: i32) void {
cdef.UpdateSound(sound, data, @as(c_int, sampleCount));
}
@ -5103,7 +5140,7 @@ pub fn setSoundPitch(sound: Sound, pitch: f32) void {
cdef.SetSoundPitch(sound, pitch);
}
/// Set pan for a sound (0.5 is center)
/// Set pan for a sound (-1.0 left, 0.0 center, 1.0 right)
pub fn setSoundPan(sound: Sound, pan: f32) void {
cdef.SetSoundPan(sound, pan);
}
@ -5183,7 +5220,7 @@ pub fn setMusicPitch(music: Music, pitch: f32) void {
cdef.SetMusicPitch(music, pitch);
}
/// Set pan for a music (0.5 is center)
/// Set pan for a music (-1.0 left, 0.0 center, 1.0 right)
pub fn setMusicPan(music: Music, pan: f32) void {
cdef.SetMusicPan(music, pan);
}
@ -5253,7 +5290,7 @@ pub fn setAudioStreamPitch(stream: AudioStream, pitch: f32) void {
cdef.SetAudioStreamPitch(stream, pitch);
}
/// Set pan for audio stream (0.5 is centered)
/// Set pan for audio stream (-1.0 to 1.0 range, 0.0 is centered)
pub fn setAudioStreamPan(stream: AudioStream, pan: f32) void {
cdef.SetAudioStreamPan(stream, pan);
}

View file

@ -109,6 +109,7 @@ pub extern "c" fn MatrixIdentity() rl.Matrix;
pub extern "c" fn MatrixAdd(left: rl.Matrix, right: rl.Matrix) rl.Matrix;
pub extern "c" fn MatrixSubtract(left: rl.Matrix, right: rl.Matrix) rl.Matrix;
pub extern "c" fn MatrixMultiply(left: rl.Matrix, right: rl.Matrix) rl.Matrix;
pub extern "c" fn MatrixMultiplyValue(left: rl.Matrix, value: f32) rl.Matrix;
pub extern "c" fn MatrixTranslate(x: f32, y: f32, z: f32) rl.Matrix;
pub extern "c" fn MatrixRotate(axis: rl.Vector3, angle: f32) rl.Matrix;
pub extern "c" fn MatrixRotateX(angle: f32) rl.Matrix;
@ -146,4 +147,5 @@ pub extern "c" fn QuaternionFromEuler(pitch: f32, yaw: f32, roll: f32) rl.Quater
pub extern "c" fn QuaternionToEuler(q: rl.Quaternion) rl.Vector3;
pub extern "c" fn QuaternionTransform(q: rl.Quaternion, mat: rl.Matrix) rl.Quaternion;
pub extern "c" fn QuaternionEquals(p: rl.Quaternion, q: rl.Quaternion) c_int;
pub extern "c" fn MatrixCompose(translation: rl.Vector3, rotation: rl.Quaternion, scale: rl.Vector3) rl.Matrix;
pub extern "c" fn MatrixDecompose(mat: rl.Matrix, translation: [*c]rl.Vector3, rotation: [*c]rl.Quaternion, scale: [*c]rl.Vector3) void;

222
lib/raymath.h vendored
View file

@ -19,20 +19,25 @@
*
* CONFIGURATION:
* #define RAYMATH_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 RAYMATH_STATIC_INLINE
* Define static inline functions code, so #include header suffices for use.
* This may use up lots of memory.
* 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.
*
* #define RAYMATH_USE_SIMD_INTRINSICS 1
* Try to enable SIMD intrinsics for MatrixMultiply()
* Note that users enabling it must be aware of the target platform where application will
* run to support the selected SIMD intrinsic, for now, only SSE is supported
*
* LICENSE: zlib/libpng
*
* Copyright (c) 2015-2025 Ramon Santamaria (@raysan5)
* Copyright (c) 2015-2026 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@ -61,11 +66,11 @@
// Function specifiers definition
#if defined(RAYMATH_IMPLEMENTATION)
#if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)
#define RMAPI __declspec(dllexport) extern inline // We are building raylib as a Win32 shared library (.dll)
#define RMAPI __declspec(dllexport) extern inline // Building raylib as a Win32 shared library (.dll)
#elif defined(BUILD_LIBTYPE_SHARED)
#define RMAPI __attribute__((visibility("default"))) // We are building raylib as a Unix shared library (.so/.dylib)
#define RMAPI __attribute__((visibility("default"))) // Building raylib as a Unix shared library (.so/.dylib)
#elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED)
#define RMAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll)
#define RMAPI __declspec(dllimport) // Using raylib as a Win32 shared library (.dll)
#else
#define RMAPI extern inline // Provide external definition
#endif
@ -79,7 +84,6 @@
#endif
#endif
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
@ -160,16 +164,51 @@ typedef struct Matrix {
#endif
// NOTE: Helper types to be used instead of array return types for *ToFloat functions
#if !defined(RL_FLOAT3_TYPE)
typedef struct float3 {
float v[3];
} float3;
#define RL_FLOAT3_TYPE
#endif
#if !defined(RL_FLOAT16_TYPE)
typedef struct float16 {
float v[16];
} float16;
#define RL_FLOAT16_TYPE
#endif
#include <math.h> // Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), floor(), fminf(), fmaxf(), fabsf()
#if RAYMATH_USE_SIMD_INTRINSICS
// SIMD is used on the most costly raymath function MatrixMultiply()
// NOTE: Only SSE intrinsics support implemented
// TODO: Consider support for other SIMD instrinsics:
// - SSEx, AVX, AVX2, FMA, NEON, RVV
/*
#if defined(__SSE4_2__)
#include <nmmintrin.h>
#define RAYMATH_SSE42_ENABLED
#elif defined(__SSE4_1__)
#include <smmintrin.h>
#define RAYMATH_SSE41_ENABLED
#elif defined(__SSSE3__)
#include <tmmintrin.h>
#define RAYMATH_SSSE3_ENABLED
#elif defined(__SSE3__)
#include <pmmintrin.h>
#define RAYMATH_SSE3_ENABLED
#elif defined(__SSE2__) || (defined(_M_AMD64) || defined(_M_X64)) // SSE2 x64
#include <emmintrin.h>
#define RAYMATH_SSE2_ENABLED
#endif
*/
#if defined(__SSE__) || defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP >= 1))
#include <xmmintrin.h>
#define RAYMATH_SSE_ENABLED
#endif
#endif
//----------------------------------------------------------------------------------
// Module Functions Definition - Utils math
//----------------------------------------------------------------------------------
@ -528,15 +567,9 @@ RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max)
{
length = sqrtf(length);
float scale = 1; // By default, 1 as the neutral element.
if (length < min)
{
scale = min/length;
}
else if (length > max)
{
scale = max/length;
}
float scale = 1; // By default, 1 as the neutral element
if (length < min) scale = min/length;
else if (length > max) scale = max/length;
result.x = v.x*scale;
result.y = v.y*scale;
@ -1050,7 +1083,7 @@ RMAPI Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c)
}
// Projects a Vector3 from screen space into object space
// NOTE: We are avoiding calling other raymath functions despite available
// NOTE: Self-contained function, no other raymath functions are called
RMAPI Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view)
{
Vector3 result = { 0 };
@ -1176,15 +1209,9 @@ RMAPI Vector3 Vector3ClampValue(Vector3 v, float min, float max)
{
length = sqrtf(length);
float scale = 1; // By default, 1 as the neutral element.
if (length < min)
{
scale = min/length;
}
else if (length > max)
{
scale = max/length;
}
float scale = 1; // By default, 1 as the neutral element
if (length < min) scale = min/length;
else if (length > max) scale = max/length;
result.x = v.x*scale;
result.y = v.y*scale;
@ -1648,6 +1675,63 @@ RMAPI Matrix MatrixMultiply(Matrix left, Matrix right)
{
Matrix result = { 0 };
#if defined(RAYMATH_SSE_ENABLED)
// Load left side and right side
__m128 c0 = _mm_set_ps(right.m12, right.m8, right.m4, right.m0);
__m128 c1 = _mm_set_ps(right.m13, right.m9, right.m5, right.m1);
__m128 c2 = _mm_set_ps(right.m14, right.m10, right.m6, right.m2);
__m128 c3 = _mm_set_ps(right.m15, right.m11, right.m7, right.m3);
// Transpose so c0..c3 become *rows* of the right matrix in semantic order
_MM_TRANSPOSE4_PS(c0, c1, c2, c3);
float tmp[4] = { 0 };
__m128 row;
// Row 0 of result: [m0, m1, m2, m3]
row = _mm_mul_ps(_mm_set1_ps(left.m0), c0);
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m1), c1));
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m2), c2));
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m3), c3));
_mm_storeu_ps(tmp, row);
result.m0 = tmp[0];
result.m1 = tmp[1];
result.m2 = tmp[2];
result.m3 = tmp[3];
// Row 1 of result: [m4, m5, m6, m7]
row = _mm_mul_ps(_mm_set1_ps(left.m4), c0);
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m5), c1));
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m6), c2));
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m7), c3));
_mm_storeu_ps(tmp, row);
result.m4 = tmp[0];
result.m5 = tmp[1];
result.m6 = tmp[2];
result.m7 = tmp[3];
// Row 2 of result: [m8, m9, m10, m11]
row = _mm_mul_ps(_mm_set1_ps(left.m8), c0);
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m9), c1));
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m10), c2));
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m11), c3));
_mm_storeu_ps(tmp, row);
result.m8 = tmp[0];
result.m9 = tmp[1];
result.m10 = tmp[2];
result.m11 = tmp[3];
// Row 3 of result: [m12, m13, m14, m15]
row = _mm_mul_ps(_mm_set1_ps(left.m12), c0);
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m13), c1));
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m14), c2));
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m15), c3));
_mm_storeu_ps(tmp, row);
result.m12 = tmp[0];
result.m13 = tmp[1];
result.m14 = tmp[2];
result.m15 = tmp[3];
#else
result.m0 = left.m0*right.m0 + left.m1*right.m4 + left.m2*right.m8 + left.m3*right.m12;
result.m1 = left.m0*right.m1 + left.m1*right.m5 + left.m2*right.m9 + left.m3*right.m13;
result.m2 = left.m0*right.m2 + left.m1*right.m6 + left.m2*right.m10 + left.m3*right.m14;
@ -1664,6 +1748,19 @@ RMAPI Matrix MatrixMultiply(Matrix left, Matrix right)
result.m13 = left.m12*right.m1 + left.m13*right.m5 + left.m14*right.m9 + left.m15*right.m13;
result.m14 = left.m12*right.m2 + left.m13*right.m6 + left.m14*right.m10 + left.m15*right.m14;
result.m15 = left.m12*right.m3 + left.m13*right.m7 + left.m14*right.m11 + left.m15*right.m15;
#endif
return result;
}
RMAPI Matrix MatrixMultiplyValue(Matrix left, float value)
{
Matrix result = {
left.m0 * value, left.m4 * value, left.m8 * value, left.m12 * value,
left.m1 * value, left.m5 * value, left.m9 * value, left.m13 * value,
left.m2 * value, left.m6 * value, left.m10 * value, left.m14 * value,
left.m3 * value, left.m7 * value, left.m11 * value, left.m15 * value
};
return result;
}
@ -2278,7 +2375,7 @@ RMAPI Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to)
result.x = cross.x;
result.y = cross.y;
result.z = cross.z;
result.w = 1.0f + cos2Theta;
result.w = sqrtf(cross.x*cross.x + cross.y*cross.y + cross.z*cross.z + cos2Theta*cos2Theta) + cos2Theta;
// QuaternionNormalize(q);
// NOTE: Normalize to essentially nlerp the original and identity to 0.5
@ -2465,8 +2562,8 @@ RMAPI void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle
}
else
{
// This occurs when the angle is zero.
// Not a problem: just set an arbitrary normalized axis.
// This occurs when the angle is zero
// Not a problem, set an arbitrary normalized axis
resAxis.x = 1.0f;
}
@ -2552,7 +2649,38 @@ RMAPI int QuaternionEquals(Quaternion p, Quaternion q)
return result;
}
// Compose a transformation matrix from rotational, translational and scaling components
// TODO: This function is not following raymath conventions defined in header: NOT self-contained
RMAPI Matrix MatrixCompose(Vector3 translation, Quaternion rotation, Vector3 scale)
{
// Initialize vectors
Vector3 right = { 1.0f, 0.0f, 0.0f };
Vector3 up = { 0.0f, 1.0f, 0.0f };
Vector3 forward = { 0.0f, 0.0f, 1.0f };
// Scale vectors
right = Vector3Scale(right, scale.x);
up = Vector3Scale(up, scale.y);
forward = Vector3Scale(forward , scale.z);
// Rotate vectors
right = Vector3RotateByQuaternion(right, rotation);
up = Vector3RotateByQuaternion(up, rotation);
forward = Vector3RotateByQuaternion(forward, rotation);
// Set result matrix output
Matrix result = {
right.x, up.x, forward.x, translation.x,
right.y, up.y, forward.y, translation.y,
right.z, up.z, forward.z, translation.z,
0.0f, 0.0f, 0.0f, 1.0f
};
return result;
}
// Decompose a transformation matrix into its rotational, translational and scaling components and remove shear
// TODO: This function is not following raymath conventions defined in header: NOT self-contained
RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotation, Vector3 *scale)
{
float eps = (float)1e-9;
@ -2562,10 +2690,10 @@ RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotatio
translation->y = mat.m13;
translation->z = mat.m14;
// Matrix Columns - Rotation will be extracted into here.
Vector3 matColumns[3] = { { mat.m0, mat.m4, mat.m8 },
// Matrix Columns - Rotation will be extracted into here
Vector3 matColumns[3] = {{ mat.m0, mat.m4, mat.m8 },
{ mat.m1, mat.m5, mat.m9 },
{ mat.m2, mat.m6, mat.m10 } };
{ mat.m2, mat.m6, mat.m10 }};
// Shear Parameters XY, XZ, and YZ (extract and ignored)
float shear[3] = { 0 };
@ -2580,17 +2708,14 @@ RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotatio
stabilizer = fmaxf(stabilizer, fabsf(matColumns[i].x));
stabilizer = fmaxf(stabilizer, fabsf(matColumns[i].y));
stabilizer = fmaxf(stabilizer, fabsf(matColumns[i].z));
};
}
matColumns[0] = Vector3Scale(matColumns[0], 1.0f / stabilizer);
matColumns[1] = Vector3Scale(matColumns[1], 1.0f / stabilizer);
matColumns[2] = Vector3Scale(matColumns[2], 1.0f / stabilizer);
// X Scale
scl.x = Vector3Length(matColumns[0]);
if (scl.x > eps)
{
matColumns[0] = Vector3Scale(matColumns[0], 1.0f / scl.x);
}
if (scl.x > eps) matColumns[0] = Vector3Scale(matColumns[0], 1.0f / scl.x);
// Compute XY shear and make col2 orthogonal
shear[0] = Vector3DotProduct(matColumns[0], matColumns[1]);
@ -2619,7 +2744,7 @@ RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotatio
shear[2] /= scl.z; // Correct YZ shear
}
// matColumns are now orthonormal in O(3). Now ensure its in SO(3) by enforcing det = 1.
// matColumns are now orthonormal in O(3). Now ensure its in SO(3) by enforcing det = 1
if (Vector3DotProduct(matColumns[0], Vector3CrossProduct(matColumns[1], matColumns[2])) < 0)
{
scl = Vector3Negate(scl);
@ -2954,6 +3079,11 @@ inline const Quaternion& operator *= (Quaternion& lhs, const Matrix& rhs)
}
// Matrix operators
static constexpr Matrix MatrixUnit = { 1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1 };
inline Matrix operator + (const Matrix& lhs, const Matrix& rhs)
{
return MatrixAdd(lhs, rhs);
@ -2986,6 +3116,18 @@ inline const Matrix& operator *= (Matrix& lhs, const Matrix& rhs)
lhs = MatrixMultiply(lhs, rhs);
return lhs;
}
inline Matrix operator * (const Matrix& lhs, const float value)
{
return MatrixMultiplyValue(lhs, value);
}
inline const Matrix& operator *= (Matrix& lhs, const float value)
{
lhs = MatrixMultiplyValue(lhs, value);
return lhs;
}
//-------------------------------------------------------------------------------
#endif // C++ operators

View file

@ -6,7 +6,7 @@ const std = @import("std");
pub const cdef = @import("raymath-ext.zig");
test {
std.testing.refAllDeclsRecursive(@This());
std.testing.refAllDecls(@This());
}
const Matrix = rl.Matrix;
@ -447,6 +447,10 @@ pub fn matrixMultiply(left: Matrix, right: Matrix) Matrix {
return cdef.MatrixMultiply(left, right);
}
pub fn matrixMultiplyValue(left: Matrix, value: f32) Matrix {
return cdef.MatrixMultiplyValue(left, value);
}
pub fn matrixTranslate(x: f32, y: f32, z: f32) Matrix {
return cdef.MatrixTranslate(x, y, z);
}
@ -595,6 +599,10 @@ pub fn quaternionEquals(p: Quaternion, q: Quaternion) i32 {
return @as(i32, cdef.QuaternionEquals(p, q));
}
pub fn matrixCompose(translation: Vector3, rotation: Quaternion, scale: Vector3) Matrix {
return cdef.MatrixCompose(translation, rotation, scale);
}
pub fn matrixDecompose(mat: Matrix, translation: *Vector3, rotation: *Quaternion, scale: *Vector3) void {
cdef.MatrixDecompose(mat, @as([*c]Vector3, @ptrCast(translation)), @as([*c]Quaternion, @ptrCast(rotation)), @as([*c]Vector3, @ptrCast(scale)));
}

View file

@ -128,23 +128,24 @@ pub extern "c" fn rlGenTextureMipmaps(id: c_uint, width: c_int, height: c_int, f
pub extern "c" fn rlReadTexturePixels(id: c_uint, width: c_int, height: c_int, format: c_int) *anyopaque;
pub extern "c" fn rlReadScreenPixels(width: c_int, height: c_int) [*c]u8;
pub extern "c" fn rlLoadFramebuffer() c_uint;
pub extern "c" fn rlFramebufferAttach(fboId: c_uint, texId: c_uint, attachType: c_int, texType: c_int, mipLevel: c_int) void;
pub extern "c" fn rlFramebufferAttach(id: c_uint, texId: c_uint, attachType: c_int, texType: c_int, mipLevel: c_int) void;
pub extern "c" fn rlFramebufferComplete(id: c_uint) bool;
pub extern "c" fn rlUnloadFramebuffer(id: c_uint) void;
pub extern "c" fn rlCopyFramebuffer(x: c_int, y: c_int, width: c_int, height: c_int, format: c_int, pixels: *anyopaque) void;
pub extern "c" fn rlResizeFramebuffer(width: c_int, height: c_int) void;
pub extern "c" fn rlLoadShaderCode(vsCode: [*c]const u8, fsCode: [*c]const u8) c_uint;
pub extern "c" fn rlCompileShader(shaderCode: [*c]const u8, ty: c_int) c_uint;
pub extern "c" fn rlLoadShaderProgram(vShaderId: c_uint, fShaderId: c_uint) c_uint;
pub extern "c" fn rlLoadShader(code: [*c]const u8, ty: c_int) c_uint;
pub extern "c" fn rlLoadShaderProgram(vsCode: [*c]const u8, fsCode: [*c]const u8) c_uint;
pub extern "c" fn rlLoadShaderProgramEx(vsId: c_uint, fsId: c_uint) c_uint;
pub extern "c" fn rlLoadShaderProgramCompute(csId: c_uint) c_uint;
pub extern "c" fn rlUnloadShader(id: c_uint) void;
pub extern "c" fn rlUnloadShaderProgram(id: c_uint) void;
pub extern "c" fn rlGetLocationUniform(shaderId: c_uint, uniformName: [*c]const u8) c_int;
pub extern "c" fn rlGetLocationAttrib(shaderId: c_uint, attribName: [*c]const u8) c_int;
pub extern "c" fn rlGetLocationUniform(id: c_uint, uniformName: [*c]const u8) c_int;
pub extern "c" fn rlGetLocationAttrib(id: c_uint, attribName: [*c]const u8) c_int;
pub extern "c" fn rlSetUniform(locIndex: c_int, value: *const anyopaque, uniformType: c_int, count: c_int) void;
pub extern "c" fn rlSetUniformMatrix(locIndex: c_int, mat: rl.Matrix) void;
pub extern "c" fn rlSetUniformMatrices(locIndex: c_int, mat: [*c]const rl.Matrix, count: c_int) void;
pub extern "c" fn rlSetUniformSampler(locIndex: c_int, textureId: c_uint) void;
pub extern "c" fn rlSetShader(id: c_uint, locs: [*c]c_int) void;
pub extern "c" fn rlLoadComputeShaderProgram(shaderId: c_uint) c_uint;
pub extern "c" fn rlComputeShaderDispatch(groupX: c_uint, groupY: c_uint, groupZ: c_uint) void;
pub extern "c" fn rlLoadShaderBuffer(size: c_uint, data: ?*const anyopaque, usageHint: c_int) c_uint;
pub extern "c" fn rlUnloadShaderBuffer(ssboId: c_uint) void;

810
lib/rlgl.h vendored

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,7 @@ const std = @import("std");
pub const cdef = @import("rlgl-ext.zig");
test {
std.testing.refAllDeclsRecursive(@This());
std.testing.refAllDecls(@This());
}
const Matrix = rl.Matrix;
@ -39,7 +39,7 @@ pub const rlRenderBatch = extern struct {
};
pub const rlGlVersion = enum(c_int) {
rl_opengl_11_software = 0,
rl_opengl_software = 0,
rl_opengl_11 = 1,
rl_opengl_21 = 2,
rl_opengl_33 = 3,
@ -268,9 +268,9 @@ pub const rl_default_shader_attrib_location_color = @as(i32, 3);
pub const rl_default_shader_attrib_location_tangent = @as(i32, 4);
pub const rl_default_shader_attrib_location_texcoord2 = @as(i32, 5);
pub const rl_default_shader_attrib_location_indices = @as(i32, 6);
pub const rl_default_shader_attrib_location_boneids = @as(i32, 7);
pub const rl_default_shader_attrib_location_boneweights = @as(i32, 5);
pub const rl_default_shader_attrib_location_instance_tx = @as(i32, 9);
pub const rl_default_shader_attrib_location_boneindices = @as(i32, 7);
pub const rl_default_shader_attrib_location_boneweights = @as(i32, 8);
pub const rl_default_shader_attrib_location_instancetransform = @as(i32, 9);
/// Choose the current matrix to be transformed
pub fn rlMatrixMode(mode: i32) void {
@ -896,8 +896,8 @@ pub fn rlLoadFramebuffer() u32 {
}
/// Attach texture/renderbuffer to a framebuffer
pub fn rlFramebufferAttach(fboId: u32, texId: u32, attachType: i32, texType: i32, mipLevel: i32) void {
cdef.rlFramebufferAttach(@as(c_uint, fboId), @as(c_uint, texId), @as(c_int, attachType), @as(c_int, texType), @as(c_int, mipLevel));
pub fn rlFramebufferAttach(id: u32, texId: u32, attachType: i32, texType: i32, mipLevel: i32) void {
cdef.rlFramebufferAttach(@as(c_uint, id), @as(c_uint, texId), @as(c_int, attachType), @as(c_int, texType), @as(c_int, mipLevel));
}
/// Verify framebuffer is complete
@ -920,19 +920,29 @@ pub fn rlResizeFramebuffer(width: i32, height: i32) void {
cdef.rlResizeFramebuffer(@as(c_int, width), @as(c_int, height));
}
/// Load (compile) shader and return shader id (type: RL_VERTEX_SHADER, RL_FRAGMENT_SHADER, RL_COMPUTE_SHADER)
pub fn rlLoadShader(code: [:0]const u8, ty: i32) u32 {
return @as(u32, cdef.rlLoadShader(@as([*c]const u8, @ptrCast(code)), @as(c_int, ty)));
}
/// Load shader from code strings
pub fn rlLoadShaderCode(vsCode: ?[:0]const u8, fsCode: ?[:0]const u8) u32 {
return @as(u32, cdef.rlLoadShaderCode(@as([*c]const u8, @ptrCast(vsCode)), @as([*c]const u8, @ptrCast(fsCode))));
pub fn rlLoadShaderProgram(vsCode: [:0]const u8, fsCode: [:0]const u8) u32 {
return @as(u32, cdef.rlLoadShaderProgram(@as([*c]const u8, @ptrCast(vsCode)), @as([*c]const u8, @ptrCast(fsCode))));
}
/// Compile custom shader and return shader id (type: RL_VERTEX_SHADER, RL_FRAGMENT_SHADER, RL_COMPUTE_SHADER)
pub fn rlCompileShader(shaderCode: [:0]const u8, ty: i32) u32 {
return @as(u32, cdef.rlCompileShader(@as([*c]const u8, @ptrCast(shaderCode)), @as(c_int, ty)));
/// Load shader program, using already loaded shader ids
pub fn rlLoadShaderProgramEx(vsId: u32, fsId: u32) u32 {
return @as(u32, cdef.rlLoadShaderProgramEx(@as(c_uint, vsId), @as(c_uint, fsId)));
}
/// Load custom shader program
pub fn rlLoadShaderProgram(vShaderId: u32, fShaderId: u32) u32 {
return @as(u32, cdef.rlLoadShaderProgram(@as(c_uint, vShaderId), @as(c_uint, fShaderId)));
/// Load compute shader program
pub fn rlLoadShaderProgramCompute(csId: u32) u32 {
return @as(u32, cdef.rlLoadShaderProgramCompute(@as(c_uint, csId)));
}
/// Unload shader, loaded with rlLoadShader()
pub fn rlUnloadShader(id: u32) void {
cdef.rlUnloadShader(@as(c_uint, id));
}
/// Unload shader program
@ -940,14 +950,14 @@ pub fn rlUnloadShaderProgram(id: u32) void {
cdef.rlUnloadShaderProgram(@as(c_uint, id));
}
/// Get shader location uniform
pub fn rlGetLocationUniform(shaderId: u32, uniformName: [:0]const u8) i32 {
return @as(i32, cdef.rlGetLocationUniform(@as(c_uint, shaderId), @as([*c]const u8, @ptrCast(uniformName))));
/// Get shader location uniform, requires shader program id
pub fn rlGetLocationUniform(id: u32, uniformName: [:0]const u8) i32 {
return @as(i32, cdef.rlGetLocationUniform(@as(c_uint, id), @as([*c]const u8, @ptrCast(uniformName))));
}
/// Get shader location attribute
pub fn rlGetLocationAttrib(shaderId: u32, attribName: [:0]const u8) i32 {
return @as(i32, cdef.rlGetLocationAttrib(@as(c_uint, shaderId), @as([*c]const u8, @ptrCast(attribName))));
/// Get shader location attribute, requires shader program id
pub fn rlGetLocationAttrib(id: u32, attribName: [:0]const u8) i32 {
return @as(i32, cdef.rlGetLocationAttrib(@as(c_uint, id), @as([*c]const u8, @ptrCast(attribName))));
}
/// Set shader value uniform
@ -975,11 +985,6 @@ pub fn rlSetShader(id: u32, locs: []i32) void {
cdef.rlSetShader(@as(c_uint, id), @as([*c]c_int, @ptrCast(locs)));
}
/// Load compute shader program
pub fn rlLoadComputeShaderProgram(shaderId: u32) u32 {
return @as(u32, cdef.rlLoadComputeShaderProgram(@as(c_uint, shaderId)));
}
/// Dispatch compute shader (equivalent to *draw* for graphics pipeline)
pub fn rlComputeShaderDispatch(groupX: u32, groupY: u32, groupZ: u32) void {
cdef.rlComputeShaderDispatch(@as(c_uint, groupX), @as(c_uint, groupY), @as(c_uint, groupZ));