Merge pull request #62 from iacore/patch-1

This commit is contained in:
Nikolas 2024-01-30 13:39:50 +01:00 committed by GitHub
commit f86a2cd40f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 4141 additions and 124 deletions

2
.gitignore vendored
View File

@ -3,6 +3,4 @@ zig-out/
.idea/ .idea/
Project/* Project/*
libraylib.a libraylib.a
raylib.h
raymath.h
**/.DS_Store **/.DS_Store

View File

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

View File

@ -16,11 +16,7 @@ pub fn link(
target: std.zig.CrossTarget, target: std.zig.CrossTarget,
optimize: std.builtin.Mode, optimize: std.builtin.Mode,
) void { ) void {
const raylib = b.dependency("raylib", .{ const lib = getRaylib(b, target, optimize);
.target = target,
.optimize = optimize,
});
const art = raylib.artifact("raylib");
const target_os = exe.target.toTarget().os.tag; const target_os = exe.target.toTarget().os.tag;
switch (target_os) { switch (target_os) {
@ -61,20 +57,26 @@ pub fn link(
}, },
} }
exe.linkLibrary(art); exe.linkLibrary(lib);
} }
pub fn getArtifact( var _raylib_lib_cache: ?*std.build.Step.Compile = null;
pub fn getRaylib(
b: *std.Build, b: *std.Build,
target: std.zig.CrossTarget, target: std.zig.CrossTarget,
optimize: std.builtin.Mode, optimize: std.builtin.Mode,
) *std.Build.Step.Compile { ) *std.Build.Step.Compile {
const raylib = b.dependency("raylib", .{ if (_raylib_lib_cache) |lib| return lib else {
.target = target, const raylib = b.dependency("raylib", .{
.optimize = optimize, .target = target,
}); .optimize = optimize,
});
return raylib.artifact("raylib"); const lib = raylib.artifact("raylib");
b.installArtifact(lib);
_raylib_lib_cache = lib;
return lib;
}
} }
// TODO: Make these not comptime. // TODO: Make these not comptime.
@ -187,12 +189,12 @@ pub fn build(b: *std.Build) !void {
const exe_lib = compileForEmscripten(b, ex.name, ex.path, target, optimize); const exe_lib = compileForEmscripten(b, ex.name, ex.path, target, optimize);
exe_lib.addModule("raylib", raylib); exe_lib.addModule("raylib", raylib);
exe_lib.addModule("raylib-math", raylib_math); exe_lib.addModule("raylib-math", raylib_math);
const raylib_artifact = getArtifact(b, target, optimize); const raylib_lib = getRaylib(b, target, optimize);
// Note that raylib itself isn't actually added to the exe_lib // Note that raylib itself isn't actually added to the exe_lib
// output file, so it also needs to be linked with emscripten. // output file, so it also needs to be linked with emscripten.
exe_lib.linkLibrary(raylib_artifact); exe_lib.linkLibrary(raylib_lib);
const link_step = try linkWithEmscripten(b, &[_]*std.Build.Step.Compile{ exe_lib, raylib_artifact }); const link_step = try linkWithEmscripten(b, &[_]*std.Build.Step.Compile{ exe_lib, raylib_lib });
link_step.addArg("--embed-file"); link_step.addArg("--embed-file");
link_step.addArg("resources/"); link_step.addArg("resources/");

View File

@ -1,10 +1,11 @@
.{ .{
.name = "raylib-zig", .name = "raylib-zig",
.version = "0.1.0", .version = "0.1.1",
.dependencies = .{ .dependencies = .{
.raylib = .{ .raylib = .{
.url = "https://github.com/raysan5/raylib/archive/6094869e3e845e90e1e8ae41b98e889fb3e13e78.tar.gz", .url = "https://github.com/raysan5/raylib/archive/5.0.tar.gz",
.hash = "12203b7a16bcf8d7fe4c9990a46d92b6f2e35531a4b82eb3bdf8ba4a0dbcc5f21415", .hash = "1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b",
}, },
}, },
.paths = .{""},
} }

View File

@ -13,7 +13,7 @@ pub fn main() anyerror!void {
defer rl.closeWindow(); // Close window and OpenGL context defer rl.closeWindow(); // Close window and OpenGL context
var boxPositionY: f32 = screenHeight / 2 - 40; var boxPositionY: f32 = screenHeight / 2 - 40;
var scrollSpeed: f32 = 4; // Scrolling speed in pixels const scrollSpeed: f32 = 4; // Scrolling speed in pixels
rl.setTargetFPS(60); // Set our game to run at 60 frames-per-second rl.setTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View File

@ -21,7 +21,15 @@ ZIGGIFY = {
"c_uint": "u32" "c_uint": "u32"
} }
IGNORE_TYPES = [
"[*c]Color",
"[*c]GlyphInfo",
"[*c]c_int",
"[*c][*c]const u8",
"[*c]Material",
"[*c]ModelAnimation",
"[*c]f32",
]
# Some C types have a different sizes on different systems and Zig # Some C types have a different sizes on different systems and Zig
# knows that so we tell it to get the system specific size for us. # knows that so we tell it to get the system specific size for us.
def c_to_zig_type(c: str) -> str: def c_to_zig_type(c: str) -> str:
@ -43,14 +51,16 @@ def ziggify_type(name: str, t: str) -> str:
"camera", "collisionPoint", "frames", "image", "colorCount", "dst", "camera", "collisionPoint", "frames", "image", "colorCount", "dst",
"texture", "srcPtr", "dstPtr", "count", "codepointSize", "utf8Size", "texture", "srcPtr", "dstPtr", "count", "codepointSize", "utf8Size",
"position", "mesh", "materialCount", "material", "model", "animCount", "position", "mesh", "materialCount", "material", "model", "animCount",
"wave", "v1", "v2", "outAxis", "outAngle", "fileSize" "wave", "v1", "v2", "outAxis", "outAngle", "fileSize",
"AutomationEventList", "list"
] ]
multi = [ multi = [
"data", "compData", "points", "fileData", "colors", "pixels", "data", "compData", "points", "fileData", "colors", "pixels",
"fontChars", "chars", "recs", "codepoints", "textList", "transforms", "fontChars", "chars", "recs", "codepoints", "textList", "transforms",
"animations", "samples", "LoadImageColors", "LoadImagePalette", "animations", "samples", "LoadImageColors", "LoadImagePalette",
"LoadFontData", "LoadCodepoints", "TextSplit", "LoadMaterials", "LoadFontData", "LoadCodepoints", "TextSplit", "LoadMaterials",
"LoadModelAnimations", "LoadWaveSamples", "images" "LoadModelAnimations", "LoadWaveSamples", "images",
"LoadRandomSequence", "sequence", "kernel", "GlyphInfo", "glyphs", "glyphRecs",
] ]
string = False string = False
@ -106,15 +116,7 @@ def make_return_cast(source_type: str, dest_type: str, inner: str) -> str:
# These all have to be done manually because their sizes depend on the # These all have to be done manually because their sizes depend on the
# function arguments. # function arguments.
if source_type in [ if source_type in IGNORE_TYPES:
"[*c]Color",
"[*c]GlyphInfo",
"[*c]c_int",
"[*c][*c]const u8",
"[*c]Material",
"[*c]ModelAnimation",
"[*c]f32",
]:
return None return None
else: else:
raise ValueError(f"Don't know what to do {source_type} {dest_type} {inner}") raise ValueError(f"Don't know what to do {source_type} {dest_type} {inner}")
@ -281,9 +283,6 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str,
"EncodeDataBase64", "EncodeDataBase64",
"DecodeDataBase64", "DecodeDataBase64",
"SetWindowIcons", "SetWindowIcons",
"DrawLineStrip",
"DrawTriangleFan",
"DrawTriangleStrip",
"CheckCollisionPointPoly", "CheckCollisionPointPoly",
"LoadFontEx", "LoadFontEx",
"GenImageFontAtlas", "GenImageFontAtlas",
@ -291,6 +290,9 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str,
"DrawTextCodepoints", "DrawTextCodepoints",
"LoadUTF8", "LoadUTF8",
"TextJoin", "TextJoin",
"DrawLineStrip",
"DrawTriangleFan",
"DrawTriangleStrip",
"DrawTriangleStrip3D", "DrawTriangleStrip3D",
] ]

View File

@ -1,4 +1,4 @@
// raylib-zig (c) Nikolas Wipper 2023 // raylib-zig (c) Nikolas Wipper 2023
const rl = @import("raylib-zig"); const rl = @import("raylib-zig.zig");
const rlm = @import("raylib-zig-math.zig"); const rlm = @import("raylib-zig-math.zig");

View File

@ -1,6 +1,6 @@
// raylib-zig (c) Nikolas Wipper 2023 // raylib-zig (c) Nikolas Wipper 2023
const rl = @import("raylib-zig"); const rl = @import("raylib-zig.zig");
const cdef = @import("raylib-zig-math-ext.zig"); const cdef = @import("raylib-zig-math-ext.zig");
const std = @import("std"); const std = @import("std");

View File

@ -1158,6 +1158,17 @@ pub const LoadFileTextCallback = ?fn ([*c]const u8) callconv(.C) [*c]u8;
pub const SaveFileTextCallback = ?fn ([*c]const u8, [*c]u8) callconv(.C) bool; pub const SaveFileTextCallback = ?fn ([*c]const u8, [*c]u8) callconv(.C) bool;
pub const AudioCallback = ?*const fn (?*anyopaque, c_uint) callconv(.C) void; pub const AudioCallback = ?*const fn (?*anyopaque, c_uint) callconv(.C) void;
pub const AutomationEvent = extern struct {
frame: c_uint = @import("std").mem.zeroes(c_uint),
type: c_uint = @import("std").mem.zeroes(c_uint),
params: [4]c_int = @import("std").mem.zeroes([4]c_int),
};
pub const AutomationEventList = extern struct {
capacity: c_uint = @import("std").mem.zeroes(c_uint),
count: c_uint = @import("std").mem.zeroes(c_uint),
events: [*c]AutomationEvent = @import("std").mem.zeroes([*c]AutomationEvent),
};
pub const RAYLIB_VERSION_MAJOR = @as(i32, 4); pub const RAYLIB_VERSION_MAJOR = @as(i32, 4);
pub const RAYLIB_VERSION_MINOR = @as(i32, 6); pub const RAYLIB_VERSION_MINOR = @as(i32, 6);
pub const RAYLIB_VERSION_PATCH = @as(i32, 0); pub const RAYLIB_VERSION_PATCH = @as(i32, 0);
@ -1376,19 +1387,19 @@ pub fn loadMusicStreamFromMemory(fileType: [:0]const u8, data: []const u8) Music
return cdef.LoadMusicStreamFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(data)), @as(c_int, @intCast(data.len))); return cdef.LoadMusicStreamFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(data)), @as(c_int, @intCast(data.len)));
} }
pub fn drawLineStrip(points: []Vector2, color: Color) void { pub fn drawLineStrip(points: []const Vector2, color: Color) void {
cdef.DrawLineStrip(@as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)), color); cdef.DrawLineStrip(@as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)), color);
} }
pub fn drawTriangleFan(points: []Vector2, color: Color) void { pub fn drawTriangleFan(points: []const Vector2, color: Color) void {
cdef.DrawTriangleFan(@as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)), color); cdef.DrawTriangleFan(@as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)), color);
} }
pub fn drawTriangleStrip(points: []Vector2, color: Color) void { pub fn drawTriangleStrip(points: []const Vector2, color: Color) void {
cdef.DrawTriangleStrip(@as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)), color); cdef.DrawTriangleStrip(@as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)), color);
} }
pub fn checkCollisionPointPoly(point: Vector2, points: []Vector2) bool { pub fn checkCollisionPointPoly(point: Vector2, points: []const Vector2) bool {
return cdef.CheckCollisionPointPoly(point, @as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len))); return cdef.CheckCollisionPointPoly(point, @as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)));
} }
@ -1412,6 +1423,6 @@ pub fn textJoin(textList: [][:0]const u8, delimiter: [:0]const u8) [:0]const u8
return std.mem.span(cdef.TextJoin(@as([*c][*c]const u8, @ptrCast(textList)), @as(c_int, @intCast(textList.len)), @as([*c]const u8, @ptrCast(delimiter)))); return std.mem.span(cdef.TextJoin(@as([*c][*c]const u8, @ptrCast(textList)), @as(c_int, @intCast(textList.len)), @as([*c]const u8, @ptrCast(delimiter))));
} }
pub fn drawTriangleStrip3D(points: []Vector3, color: Color) void { pub fn drawTriangleStrip3D(points: []const Vector3, color: Color) void {
cdef.DrawTriangleStrip3D(@as([*c]Vector3, @ptrCast(points)), @as(c_int, @intCast(points.len)), color); cdef.DrawTriangleStrip3D(@as([*c]Vector3, @ptrCast(points)), @as(c_int, @intCast(points.len)), color);
} }

View File

@ -3,8 +3,8 @@
const rl = @import("raylib-zig.zig"); const rl = @import("raylib-zig.zig");
pub extern "c" fn InitWindow(width: c_int, height: c_int, title: [*c]const u8) void; pub extern "c" fn InitWindow(width: c_int, height: c_int, title: [*c]const u8) void;
pub extern "c" fn WindowShouldClose() bool;
pub extern "c" fn CloseWindow() void; pub extern "c" fn CloseWindow() void;
pub extern "c" fn WindowShouldClose() bool;
pub extern "c" fn IsWindowReady() bool; pub extern "c" fn IsWindowReady() bool;
pub extern "c" fn IsWindowFullscreen() bool; pub extern "c" fn IsWindowFullscreen() bool;
pub extern "c" fn IsWindowHidden() bool; pub extern "c" fn IsWindowHidden() bool;
@ -26,6 +26,7 @@ pub extern "c" fn SetWindowTitle(title: [*c]const u8) void;
pub extern "c" fn SetWindowPosition(x: c_int, y: c_int) void; pub extern "c" fn SetWindowPosition(x: c_int, y: c_int) void;
pub extern "c" fn SetWindowMonitor(monitor: c_int) void; pub extern "c" fn SetWindowMonitor(monitor: c_int) void;
pub extern "c" fn SetWindowMinSize(width: c_int, height: c_int) void; pub extern "c" fn SetWindowMinSize(width: c_int, height: c_int) void;
pub extern "c" fn SetWindowMaxSize(width: c_int, height: c_int) void;
pub extern "c" fn SetWindowSize(width: c_int, height: c_int) void; pub extern "c" fn SetWindowSize(width: c_int, height: c_int) void;
pub extern "c" fn SetWindowOpacity(opacity: f32) void; pub extern "c" fn SetWindowOpacity(opacity: f32) void;
pub extern "c" fn SetWindowFocused() void; pub extern "c" fn SetWindowFocused() void;
@ -49,9 +50,6 @@ pub extern "c" fn SetClipboardText(text: [*c]const u8) void;
pub extern "c" fn GetClipboardText() [*c]const u8; pub extern "c" fn GetClipboardText() [*c]const u8;
pub extern "c" fn EnableEventWaiting() void; pub extern "c" fn EnableEventWaiting() void;
pub extern "c" fn DisableEventWaiting() void; pub extern "c" fn DisableEventWaiting() void;
pub extern "c" fn SwapScreenBuffer() void;
pub extern "c" fn PollInputEvents() void;
pub extern "c" fn WaitTime(seconds: f64) void;
pub extern "c" fn ShowCursor() void; pub extern "c" fn ShowCursor() void;
pub extern "c" fn HideCursor() void; pub extern "c" fn HideCursor() void;
pub extern "c" fn IsCursorHidden() bool; pub extern "c" fn IsCursorHidden() bool;
@ -95,27 +93,32 @@ pub extern "c" fn GetScreenToWorld2D(position: rl.Vector2, camera: rl.Camera2D)
pub extern "c" fn GetWorldToScreenEx(position: rl.Vector3, camera: rl.Camera, width: c_int, height: c_int) rl.Vector2; pub extern "c" fn GetWorldToScreenEx(position: rl.Vector3, camera: rl.Camera, width: c_int, height: c_int) rl.Vector2;
pub extern "c" fn GetWorldToScreen2D(position: rl.Vector2, camera: rl.Camera2D) rl.Vector2; pub extern "c" fn GetWorldToScreen2D(position: rl.Vector2, camera: rl.Camera2D) rl.Vector2;
pub extern "c" fn SetTargetFPS(fps: c_int) void; pub extern "c" fn SetTargetFPS(fps: c_int) void;
pub extern "c" fn GetFPS() c_int;
pub extern "c" fn GetFrameTime() f32; pub extern "c" fn GetFrameTime() f32;
pub extern "c" fn GetTime() f64; pub extern "c" fn GetTime() f64;
pub extern "c" fn GetRandomValue(min: c_int, max: c_int) c_int; pub extern "c" fn GetFPS() c_int;
pub extern "c" fn SwapScreenBuffer() void;
pub extern "c" fn PollInputEvents() void;
pub extern "c" fn WaitTime(seconds: f64) void;
pub extern "c" fn SetRandomSeed(seed: c_uint) void; pub extern "c" fn SetRandomSeed(seed: c_uint) void;
pub extern "c" fn GetRandomValue(min: c_int, max: c_int) c_int;
pub extern "c" fn LoadRandomSequence(count: c_uint, min: c_int, max: c_int) [*c]c_int;
pub extern "c" fn UnloadRandomSequence(sequence: [*c]c_int) void;
pub extern "c" fn TakeScreenshot(fileName: [*c]const u8) void; pub extern "c" fn TakeScreenshot(fileName: [*c]const u8) void;
pub extern "c" fn SetConfigFlags(flags: rl.ConfigFlags) 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 TraceLog(logLevel: rl.TraceLogLevel, text: [*c]const u8, ...) void;
pub extern "c" fn SetTraceLogLevel(logLevel: rl.TraceLogLevel) void; pub extern "c" fn SetTraceLogLevel(logLevel: rl.TraceLogLevel) void;
pub extern "c" fn MemAlloc(size: c_uint) *anyopaque; pub extern "c" fn MemAlloc(size: c_uint) *anyopaque;
pub extern "c" fn MemRealloc(ptr: *anyopaque, 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 MemFree(ptr: *anyopaque) void;
pub extern "c" fn OpenURL(url: [*c]const u8) void;
pub extern "c" fn SetLoadFileDataCallback(callback: rl.LoadFileDataCallback) void; pub extern "c" fn SetLoadFileDataCallback(callback: rl.LoadFileDataCallback) void;
pub extern "c" fn SetSaveFileDataCallback(callback: rl.SaveFileDataCallback) void; pub extern "c" fn SetSaveFileDataCallback(callback: rl.SaveFileDataCallback) void;
pub extern "c" fn SetLoadFileTextCallback(callback: rl.LoadFileTextCallback) void; pub extern "c" fn SetLoadFileTextCallback(callback: rl.LoadFileTextCallback) void;
pub extern "c" fn SetSaveFileTextCallback(callback: rl.SaveFileTextCallback) void; pub extern "c" fn SetSaveFileTextCallback(callback: rl.SaveFileTextCallback) void;
pub extern "c" fn LoadFileData(fileName: [*c]const u8, bytesRead: [*c]c_uint) [*c]u8; 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 UnloadFileData(data: [*c]u8) void;
pub extern "c" fn SaveFileData(fileName: [*c]const u8, data: *anyopaque, bytesToWrite: c_uint) bool; pub extern "c" fn SaveFileData(fileName: [*c]const u8, data: *anyopaque, dataSize: c_int) bool;
pub extern "c" fn ExportDataAsCode(data: [*c]const u8, size: c_uint, fileName: [*c]const u8) bool; pub extern "c" fn ExportDataAsCode(data: [*c]const u8, dataSize: c_int, fileName: [*c]const u8) bool;
pub extern "c" fn LoadFileText(fileName: [*c]const u8) [*c]u8; pub extern "c" fn LoadFileText(fileName: [*c]const u8) [*c]u8;
pub extern "c" fn UnloadFileText(text: [*c]u8) void; pub extern "c" fn UnloadFileText(text: [*c]u8) void;
pub extern "c" fn SaveFileText(fileName: [*c]const u8, text: [*c]u8) bool; pub extern "c" fn SaveFileText(fileName: [*c]const u8, text: [*c]u8) bool;
@ -143,13 +146,22 @@ 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 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 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 DecodeDataBase64(data: [*c]const u8, outputSize: [*c]c_int) [*c]u8;
pub extern "c" fn LoadAutomationEventList(fileName: [*c]const u8) rl.AutomationEventList;
pub extern "c" fn UnloadAutomationEventList(list: [*c]rl.AutomationEventList) void;
pub extern "c" fn ExportAutomationEventList(list: rl.AutomationEventList, fileName: [*c]const u8) bool;
pub extern "c" fn SetAutomationEventList(list: [*c]rl.AutomationEventList) void;
pub extern "c" fn SetAutomationEventBaseFrame(frame: c_int) void;
pub extern "c" fn StartAutomationEventRecording() void;
pub extern "c" fn StopAutomationEventRecording() void;
pub extern "c" fn PlayAutomationEvent(event: rl.AutomationEvent) void;
pub extern "c" fn IsKeyPressed(key: rl.KeyboardKey) bool; pub extern "c" fn IsKeyPressed(key: rl.KeyboardKey) bool;
pub extern "c" fn IsKeyPressedRepeat(key: rl.KeyboardKey) bool;
pub extern "c" fn IsKeyDown(key: rl.KeyboardKey) bool; pub extern "c" fn IsKeyDown(key: rl.KeyboardKey) bool;
pub extern "c" fn IsKeyReleased(key: rl.KeyboardKey) bool; pub extern "c" fn IsKeyReleased(key: rl.KeyboardKey) bool;
pub extern "c" fn IsKeyUp(key: rl.KeyboardKey) bool; pub extern "c" fn IsKeyUp(key: rl.KeyboardKey) bool;
pub extern "c" fn SetExitKey(key: rl.KeyboardKey) void;
pub extern "c" fn GetKeyPressed() rl.KeyboardKey; pub extern "c" fn GetKeyPressed() rl.KeyboardKey;
pub extern "c" fn GetCharPressed() c_int; pub extern "c" fn GetCharPressed() c_int;
pub extern "c" fn SetExitKey(key: rl.KeyboardKey) void;
pub extern "c" fn IsGamepadAvailable(gamepad: c_int) bool; pub extern "c" fn IsGamepadAvailable(gamepad: c_int) bool;
pub extern "c" fn GetGamepadName(gamepad: c_int) [*c]const u8; pub extern "c" fn GetGamepadName(gamepad: c_int) [*c]const u8;
pub extern "c" fn IsGamepadButtonPressed(gamepad: c_int, button: rl.GamepadButton) bool; pub extern "c" fn IsGamepadButtonPressed(gamepad: c_int, button: rl.GamepadButton) bool;
@ -195,16 +207,15 @@ pub extern "c" fn DrawPixelV(position: rl.Vector2, color: rl.Color) void;
pub extern "c" fn DrawLine(startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: rl.Color) void; pub extern "c" fn DrawLine(startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: rl.Color) void;
pub extern "c" fn DrawLineV(startPos: rl.Vector2, endPos: rl.Vector2, color: rl.Color) void; pub extern "c" fn DrawLineV(startPos: rl.Vector2, endPos: rl.Vector2, color: rl.Color) void;
pub extern "c" fn DrawLineEx(startPos: rl.Vector2, endPos: rl.Vector2, thick: f32, color: rl.Color) void; pub extern "c" fn DrawLineEx(startPos: rl.Vector2, endPos: rl.Vector2, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawLineBezier(startPos: rl.Vector2, endPos: rl.Vector2, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawLineBezierQuad(startPos: rl.Vector2, endPos: rl.Vector2, controlPos: rl.Vector2, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawLineBezierCubic(startPos: rl.Vector2, endPos: rl.Vector2, startControlPos: rl.Vector2, endControlPos: rl.Vector2, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawLineStrip(points: [*c]rl.Vector2, pointCount: c_int, color: rl.Color) void; pub extern "c" fn DrawLineStrip(points: [*c]rl.Vector2, pointCount: c_int, color: rl.Color) void;
pub extern "c" fn DrawLineBezier(startPos: rl.Vector2, endPos: rl.Vector2, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawCircle(centerX: c_int, centerY: c_int, radius: f32, color: rl.Color) void; pub extern "c" fn DrawCircle(centerX: c_int, centerY: c_int, radius: f32, color: rl.Color) void;
pub extern "c" fn DrawCircleSector(center: rl.Vector2, radius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: rl.Color) void; pub extern "c" fn DrawCircleSector(center: rl.Vector2, radius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: rl.Color) void;
pub extern "c" fn DrawCircleSectorLines(center: rl.Vector2, radius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: rl.Color) void; pub extern "c" fn DrawCircleSectorLines(center: rl.Vector2, radius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: rl.Color) void;
pub extern "c" fn DrawCircleGradient(centerX: c_int, centerY: c_int, radius: f32, color1: rl.Color, color2: rl.Color) void; pub extern "c" fn DrawCircleGradient(centerX: c_int, centerY: c_int, radius: f32, color1: rl.Color, color2: rl.Color) void;
pub extern "c" fn DrawCircleV(center: rl.Vector2, radius: f32, color: rl.Color) void; pub extern "c" fn DrawCircleV(center: rl.Vector2, radius: f32, color: rl.Color) void;
pub extern "c" fn DrawCircleLines(centerX: c_int, centerY: c_int, radius: f32, color: rl.Color) void; pub extern "c" fn DrawCircleLines(centerX: c_int, centerY: c_int, radius: f32, color: rl.Color) void;
pub extern "c" fn DrawCircleLinesV(center: rl.Vector2, radius: f32, color: rl.Color) void;
pub extern "c" fn DrawEllipse(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: rl.Color) void; pub extern "c" fn DrawEllipse(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: rl.Color) void;
pub extern "c" fn DrawEllipseLines(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: rl.Color) void; pub extern "c" fn DrawEllipseLines(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: rl.Color) void;
pub extern "c" fn DrawRing(center: rl.Vector2, innerRadius: f32, outerRadius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: rl.Color) void; pub extern "c" fn DrawRing(center: rl.Vector2, innerRadius: f32, outerRadius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: rl.Color) void;
@ -227,6 +238,21 @@ pub extern "c" fn DrawTriangleStrip(points: [*c]rl.Vector2, pointCount: c_int, c
pub extern "c" fn DrawPoly(center: rl.Vector2, sides: c_int, radius: f32, rotation: f32, color: rl.Color) void; pub extern "c" fn DrawPoly(center: rl.Vector2, sides: c_int, radius: f32, rotation: f32, color: rl.Color) void;
pub extern "c" fn DrawPolyLines(center: rl.Vector2, sides: c_int, radius: f32, rotation: f32, color: rl.Color) void; pub extern "c" fn DrawPolyLines(center: rl.Vector2, sides: c_int, radius: f32, rotation: f32, color: rl.Color) void;
pub extern "c" fn DrawPolyLinesEx(center: rl.Vector2, sides: c_int, radius: f32, rotation: f32, lineThick: f32, color: rl.Color) void; pub extern "c" fn DrawPolyLinesEx(center: rl.Vector2, sides: c_int, radius: f32, rotation: f32, lineThick: f32, color: rl.Color) void;
pub extern "c" fn DrawSplineLinear(points: [*c]rl.Vector2, pointCount: c_int, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawSplineBasis(points: [*c]rl.Vector2, pointCount: c_int, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawSplineCatmullRom(points: [*c]rl.Vector2, pointCount: c_int, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawSplineBezierQuadratic(points: [*c]rl.Vector2, pointCount: c_int, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawSplineBezierCubic(points: [*c]rl.Vector2, pointCount: c_int, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawSplineSegmentLinear(p1: rl.Vector2, p2: rl.Vector2, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawSplineSegmentBasis(p1: rl.Vector2, p2: rl.Vector2, p3: rl.Vector2, p4: rl.Vector2, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawSplineSegmentCatmullRom(p1: rl.Vector2, p2: rl.Vector2, p3: rl.Vector2, p4: rl.Vector2, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawSplineSegmentBezierQuadratic(p1: rl.Vector2, c2: rl.Vector2, p3: rl.Vector2, thick: f32, color: rl.Color) void;
pub extern "c" fn DrawSplineSegmentBezierCubic(p1: rl.Vector2, c2: rl.Vector2, c3: rl.Vector2, p4: rl.Vector2, thick: f32, color: rl.Color) void;
pub extern "c" fn GetSplinePointLinear(startPos: rl.Vector2, endPos: rl.Vector2, t: f32) rl.Vector2;
pub extern "c" fn GetSplinePointBasis(p1: rl.Vector2, p2: rl.Vector2, p3: rl.Vector2, p4: rl.Vector2, t: f32) rl.Vector2;
pub extern "c" fn GetSplinePointCatmullRom(p1: rl.Vector2, p2: rl.Vector2, p3: rl.Vector2, p4: rl.Vector2, t: f32) rl.Vector2;
pub extern "c" fn GetSplinePointBezierQuad(p1: rl.Vector2, c2: rl.Vector2, p3: rl.Vector2, t: f32) rl.Vector2;
pub extern "c" fn GetSplinePointBezierCubic(p1: rl.Vector2, c2: rl.Vector2, c3: rl.Vector2, p4: rl.Vector2, t: f32) rl.Vector2;
pub extern "c" fn CheckCollisionRecs(rec1: rl.Rectangle, rec2: rl.Rectangle) bool; 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 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 CheckCollisionCircleRec(center: rl.Vector2, radius: f32, rec: rl.Rectangle) bool;
@ -239,6 +265,7 @@ pub extern "c" fn CheckCollisionPointLine(point: rl.Vector2, p1: rl.Vector2, p2:
pub extern "c" fn GetCollisionRec(rec1: rl.Rectangle, rec2: rl.Rectangle) rl.Rectangle; 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 LoadImage(fileName: [*c]const u8) rl.Image;
pub extern "c" fn LoadImageRaw(fileName: [*c]const u8, width: c_int, height: c_int, format: c_int, headerSize: c_int) rl.Image; pub extern "c" fn LoadImageRaw(fileName: [*c]const u8, width: c_int, height: c_int, format: c_int, headerSize: c_int) rl.Image;
pub extern "c" fn LoadImageSvg(fileNameOrString: [*c]const u8, width: c_int, height: c_int) rl.Image;
pub extern "c" fn LoadImageAnim(fileName: [*c]const u8, frames: [*c]c_int) rl.Image; pub extern "c" fn LoadImageAnim(fileName: [*c]const u8, frames: [*c]c_int) rl.Image;
pub extern "c" fn LoadImageFromMemory(fileType: [*c]const u8, fileData: [*c]const u8, dataSize: c_int) rl.Image; 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 LoadImageFromTexture(texture: rl.Texture2D) rl.Image;
@ -343,13 +370,13 @@ pub extern "c" fn SetPixelColor(dstPtr: *anyopaque, color: rl.Color, format: c_i
pub extern "c" fn GetPixelDataSize(width: c_int, height: c_int, format: c_int) c_int; pub extern "c" fn GetPixelDataSize(width: c_int, height: c_int, format: c_int) c_int;
pub extern "c" fn GetFontDefault() rl.Font; pub extern "c" fn GetFontDefault() rl.Font;
pub extern "c" fn LoadFont(fileName: [*c]const u8) rl.Font; pub extern "c" fn LoadFont(fileName: [*c]const u8) rl.Font;
pub extern "c" fn LoadFontEx(fileName: [*c]const u8, fontSize: c_int, fontChars: [*c]c_int, glyphCount: c_int) 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 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, fontChars: [*c]c_int, glyphCount: 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 IsFontReady(font: rl.Font) bool;
pub extern "c" fn LoadFontData(fileData: [*c]const u8, dataSize: c_int, fontSize: c_int, fontChars: [*c]c_int, glyphCount: c_int, ty: c_int) [*c]rl.GlyphInfo; pub extern "c" fn LoadFontData(fileData: [*c]const u8, dataSize: c_int, fontSize: c_int, codepoints: [*c]c_int, codepointCount: c_int, ty: c_int) [*c]rl.GlyphInfo;
pub extern "c" fn GenImageFontAtlas(chars: [*c]const rl.GlyphInfo, recs: [*c][*c]rl.Rectangle, glyphCount: c_int, fontSize: c_int, padding: c_int, packMethod: c_int) rl.Image; 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(chars: [*c]rl.GlyphInfo, glyphCount: c_int) void; pub extern "c" fn UnloadFontData(glyphs: [*c]rl.GlyphInfo, glyphCount: c_int) void;
pub extern "c" fn UnloadFont(font: rl.Font) void; pub extern "c" fn UnloadFont(font: rl.Font) void;
pub extern "c" fn ExportFontAsCode(font: rl.Font, fileName: [*c]const u8) bool; pub extern "c" fn ExportFontAsCode(font: rl.Font, fileName: [*c]const u8) bool;
pub extern "c" fn DrawFPS(posX: c_int, posY: c_int) void; pub extern "c" fn DrawFPS(posX: c_int, posY: c_int) void;
@ -357,7 +384,7 @@ pub extern "c" fn DrawText(text: [*c]const u8, posX: c_int, posY: c_int, fontSiz
pub extern "c" fn DrawTextEx(font: rl.Font, text: [*c]const u8, position: rl.Vector2, fontSize: f32, spacing: f32, tint: rl.Color) void; pub extern "c" fn DrawTextEx(font: rl.Font, text: [*c]const u8, position: rl.Vector2, fontSize: f32, spacing: f32, tint: rl.Color) void;
pub extern "c" fn DrawTextPro(font: rl.Font, text: [*c]const u8, position: rl.Vector2, origin: rl.Vector2, rotation: f32, fontSize: f32, spacing: f32, tint: rl.Color) void; pub extern "c" fn DrawTextPro(font: rl.Font, text: [*c]const u8, position: rl.Vector2, origin: rl.Vector2, rotation: f32, fontSize: f32, spacing: f32, tint: rl.Color) void;
pub extern "c" fn DrawTextCodepoint(font: rl.Font, codepoint: c_int, position: rl.Vector2, fontSize: f32, tint: rl.Color) void; pub extern "c" fn DrawTextCodepoint(font: rl.Font, codepoint: c_int, position: rl.Vector2, fontSize: f32, tint: rl.Color) void;
pub extern "c" fn DrawTextCodepoints(font: rl.Font, codepoints: [*c]const c_int, count: c_int, position: rl.Vector2, fontSize: f32, spacing: f32, tint: rl.Color) void; pub extern "c" fn DrawTextCodepoints(font: rl.Font, codepoints: [*c]const c_int, codepointCount: c_int, position: rl.Vector2, fontSize: f32, spacing: f32, tint: rl.Color) void;
pub extern "c" fn SetTextLineSpacing(spacing: c_int) void; 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 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 MeasureTextEx(font: rl.Font, text: [*c]const u8, fontSize: f32, spacing: f32) rl.Vector2;
@ -447,10 +474,10 @@ pub extern "c" fn IsMaterialReady(material: rl.Material) bool;
pub extern "c" fn UnloadMaterial(material: rl.Material) void; pub extern "c" fn UnloadMaterial(material: rl.Material) void;
pub extern "c" fn SetMaterialTexture(material: [*c]rl.Material, mapType: c_int, texture: rl.Texture2D) void; pub extern "c" fn SetMaterialTexture(material: [*c]rl.Material, mapType: c_int, texture: rl.Texture2D) void;
pub extern "c" fn SetModelMeshMaterial(model: [*c]rl.Model, meshId: c_int, materialId: c_int) 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_uint) [*c]rl.ModelAnimation; 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 UpdateModelAnimation(model: rl.Model, anim: rl.ModelAnimation, frame: c_int) void;
pub extern "c" fn UnloadModelAnimation(anim: rl.ModelAnimation) void; pub extern "c" fn UnloadModelAnimation(anim: rl.ModelAnimation) void;
pub extern "c" fn UnloadModelAnimations(animations: [*c]rl.ModelAnimation, count: c_uint) 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 IsModelAnimationValid(model: rl.Model, anim: rl.ModelAnimation) bool;
pub extern "c" fn CheckCollisionSpheres(center1: rl.Vector3, radius1: f32, center2: rl.Vector3, radius2: f32) bool; 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 CheckCollisionBoxes(box1: rl.BoundingBox, box2: rl.BoundingBox) bool;
@ -464,6 +491,7 @@ pub extern "c" fn InitAudioDevice() void;
pub extern "c" fn CloseAudioDevice() void; pub extern "c" fn CloseAudioDevice() void;
pub extern "c" fn IsAudioDeviceReady() bool; pub extern "c" fn IsAudioDeviceReady() bool;
pub extern "c" fn SetMasterVolume(volume: f32) void; 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 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 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 IsWaveReady(wave: rl.Wave) bool;

View File

@ -1,6 +1,6 @@
// raylib-zig (c) Nikolas Wipper 2023 // raylib-zig (c) Nikolas Wipper 2023
const rl = @import("raylib-zig"); const rl = @import("raylib-zig.zig");
const rlm = @import("raylib-zig-math.zig"); const rlm = @import("raylib-zig-math.zig");
pub extern "c" fn Clamp(value: f32, min: f32, max: f32) f32; pub extern "c" fn Clamp(value: f32, min: f32, max: f32) f32;
@ -55,6 +55,8 @@ pub extern "c" fn Vector3Angle(v1: rl.Vector3, v2: rl.Vector3) f32;
pub extern "c" fn Vector3Negate(v: rl.Vector3) rl.Vector3; pub extern "c" fn Vector3Negate(v: rl.Vector3) rl.Vector3;
pub extern "c" fn Vector3Divide(v1: rl.Vector3, v2: rl.Vector3) rl.Vector3; pub extern "c" fn Vector3Divide(v1: rl.Vector3, v2: rl.Vector3) rl.Vector3;
pub extern "c" fn Vector3Normalize(v: rl.Vector3) rl.Vector3; pub extern "c" fn Vector3Normalize(v: rl.Vector3) rl.Vector3;
pub extern "c" fn Vector3Project(v1: rl.Vector3, v2: rl.Vector3) rl.Vector3;
pub extern "c" fn Vector3Reject(v1: rl.Vector3, v2: rl.Vector3) rl.Vector3;
pub extern "c" fn Vector3OrthoNormalize(v1: [*c]rl.Vector3, v2: [*c]rl.Vector3) void; pub extern "c" fn Vector3OrthoNormalize(v1: [*c]rl.Vector3, v2: [*c]rl.Vector3) void;
pub extern "c" fn Vector3Transform(v: rl.Vector3, mat: rl.Matrix) rl.Vector3; pub extern "c" fn Vector3Transform(v: rl.Vector3, mat: rl.Matrix) rl.Vector3;
pub extern "c" fn Vector3RotateByQuaternion(v: rl.Vector3, q: rl.Quaternion) rl.Vector3; pub extern "c" fn Vector3RotateByQuaternion(v: rl.Vector3, q: rl.Quaternion) rl.Vector3;

View File

@ -1,6 +1,6 @@
// raylib-zig (c) Nikolas Wipper 2023 // raylib-zig (c) Nikolas Wipper 2023
const rl = @import("raylib-zig"); const rl = @import("raylib-zig.zig");
const cdef = @import("raylib-zig-math-ext.zig"); const cdef = @import("raylib-zig-math-ext.zig");
const std = @import("std"); const std = @import("std");
@ -226,6 +226,14 @@ pub fn vector3Normalize(v: Vector3) Vector3 {
return cdef.Vector3Normalize(v); return cdef.Vector3Normalize(v);
} }
pub fn vector3Project(v1: Vector3, v2: Vector3) Vector3 {
return cdef.Vector3Project(v1, v2);
}
pub fn vector3Reject(v1: Vector3, v2: Vector3) Vector3 {
return cdef.Vector3Reject(v1, v2);
}
pub fn vector3OrthoNormalize(v1: *Vector3, v2: *Vector3) void { pub fn vector3OrthoNormalize(v1: *Vector3, v2: *Vector3) void {
cdef.Vector3OrthoNormalize(@as([*c]Vector3, @ptrCast(v1)), @as([*c]Vector3, @ptrCast(v2))); cdef.Vector3OrthoNormalize(@as([*c]Vector3, @ptrCast(v1)), @as([*c]Vector3, @ptrCast(v2)));
} }

View File

@ -542,7 +542,7 @@ pub const Font = extern struct {
return rl.loadFontFromImage(image, key, firstChar); return rl.loadFontFromImage(image, key, firstChar);
} }
pub fn fromMemory(fileType: [:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: ?[]i32) Font { pub fn fromMemory(fileType: [:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: []i32) Font {
return rl.loadFontFromMemory(fileType, fileData, fontSize, fontChars); return rl.loadFontFromMemory(fileType, fileData, fontSize, fontChars);
} }
@ -1158,6 +1158,17 @@ pub const LoadFileTextCallback = ?fn ([*c]const u8) callconv(.C) [*c]u8;
pub const SaveFileTextCallback = ?fn ([*c]const u8, [*c]u8) callconv(.C) bool; pub const SaveFileTextCallback = ?fn ([*c]const u8, [*c]u8) callconv(.C) bool;
pub const AudioCallback = ?*const fn (?*anyopaque, c_uint) callconv(.C) void; pub const AudioCallback = ?*const fn (?*anyopaque, c_uint) callconv(.C) void;
pub const AutomationEvent = extern struct {
frame: c_uint = @import("std").mem.zeroes(c_uint),
type: c_uint = @import("std").mem.zeroes(c_uint),
params: [4]c_int = @import("std").mem.zeroes([4]c_int),
};
pub const AutomationEventList = extern struct {
capacity: c_uint = @import("std").mem.zeroes(c_uint),
count: c_uint = @import("std").mem.zeroes(c_uint),
events: [*c]AutomationEvent = @import("std").mem.zeroes([*c]AutomationEvent),
};
pub const RAYLIB_VERSION_MAJOR = @as(i32, 4); pub const RAYLIB_VERSION_MAJOR = @as(i32, 4);
pub const RAYLIB_VERSION_MINOR = @as(i32, 6); pub const RAYLIB_VERSION_MINOR = @as(i32, 6);
pub const RAYLIB_VERSION_PATCH = @as(i32, 0); pub const RAYLIB_VERSION_PATCH = @as(i32, 0);
@ -1281,20 +1292,14 @@ pub fn loadImagePalette(image: Image, maxPaletteSize: i32) []Color {
return res; return res;
} }
pub fn loadFontFromMemory(fileType: [:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: ?[]i32) Font { pub fn loadFontFromMemory(fileType: [:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: []i32) Font {
var fileDataFinal: [*c]const u8 = 0; var fileDataFinal = @as([*c]const u8, 0);
var fileDataLen: c_int = undefined; var fileDataLen: i32 = 0;
if (fileData) |fileDataSure| { if (fileData) |fileDataSure| {
fileDataFinal = @ptrCast(fileDataSure); fileDataFinal = @as([*c]const u8, @ptrCast(fileDataSure));
fileDataLen = @intCast(fileDataSure.len); fileDataLen = @as(i32, @intCast(fileDataSure.len));
} }
var fontCharsFinal: [*c]c_int = 0; return cdef.LoadFontFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(fileDataFinal)), @as(c_int, @intCast(fileDataLen)), @as(c_int, fontSize), @as([*c]c_int, @ptrCast(fontChars)), @as(c_int, @intCast(fontChars.len)));
var fontCharsLen: c_int = undefined;
if (fontChars) |fontCharsSure| {
fontCharsFinal = @ptrCast(fontCharsSure);
fontCharsLen = @intCast(fontCharsSure.len);
}
return cdef.LoadFontFromMemory(@ptrCast(fileType), fileDataFinal, fileDataLen, fontSize, fontCharsFinal, fontCharsLen);
} }
pub fn loadFontData(fileData: []const u8, fontSize: i32, fontChars: []i32, ty: i32) []GlyphInfo { pub fn loadFontData(fileData: []const u8, fontSize: i32, fontChars: []i32, ty: i32) []GlyphInfo {
@ -1382,19 +1387,19 @@ pub fn loadMusicStreamFromMemory(fileType: [:0]const u8, data: []const u8) Music
return cdef.LoadMusicStreamFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(data)), @as(c_int, @intCast(data.len))); return cdef.LoadMusicStreamFromMemory(@as([*c]const u8, @ptrCast(fileType)), @as([*c]const u8, @ptrCast(data)), @as(c_int, @intCast(data.len)));
} }
pub fn drawLineStrip(points: []Vector2, color: Color) void { pub fn drawLineStrip(points: []const Vector2, color: Color) void {
cdef.DrawLineStrip(@as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)), color); cdef.DrawLineStrip(@as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)), color);
} }
pub fn drawTriangleFan(points: []Vector2, color: Color) void { pub fn drawTriangleFan(points: []const Vector2, color: Color) void {
cdef.DrawTriangleFan(@as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)), color); cdef.DrawTriangleFan(@as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)), color);
} }
pub fn drawTriangleStrip(points: []Vector2, color: Color) void { pub fn drawTriangleStrip(points: []const Vector2, color: Color) void {
cdef.DrawTriangleStrip(@as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)), color); cdef.DrawTriangleStrip(@as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)), color);
} }
pub fn checkCollisionPointPoly(point: Vector2, points: []Vector2) bool { pub fn checkCollisionPointPoly(point: Vector2, points: []const Vector2) bool {
return cdef.CheckCollisionPointPoly(point, @as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len))); return cdef.CheckCollisionPointPoly(point, @as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)));
} }
@ -1418,7 +1423,7 @@ pub fn textJoin(textList: [][:0]const u8, delimiter: [:0]const u8) [:0]const u8
return std.mem.span(cdef.TextJoin(@as([*c][*c]const u8, @ptrCast(textList)), @as(c_int, @intCast(textList.len)), @as([*c]const u8, @ptrCast(delimiter)))); return std.mem.span(cdef.TextJoin(@as([*c][*c]const u8, @ptrCast(textList)), @as(c_int, @intCast(textList.len)), @as([*c]const u8, @ptrCast(delimiter))));
} }
pub fn drawTriangleStrip3D(points: []Vector3, color: Color) void { pub fn drawTriangleStrip3D(points: []const Vector3, color: Color) void {
cdef.DrawTriangleStrip3D(@as([*c]Vector3, @ptrCast(points)), @as(c_int, @intCast(points.len)), color); cdef.DrawTriangleStrip3D(@as([*c]Vector3, @ptrCast(points)), @as(c_int, @intCast(points.len)), color);
} }
@ -1426,14 +1431,14 @@ pub fn initWindow(width: i32, height: i32, title: [:0]const u8) void {
cdef.InitWindow(@as(c_int, width), @as(c_int, height), @as([*c]const u8, @ptrCast(title))); cdef.InitWindow(@as(c_int, width), @as(c_int, height), @as([*c]const u8, @ptrCast(title)));
} }
pub fn windowShouldClose() bool {
return cdef.WindowShouldClose();
}
pub fn closeWindow() void { pub fn closeWindow() void {
cdef.CloseWindow(); cdef.CloseWindow();
} }
pub fn windowShouldClose() bool {
return cdef.WindowShouldClose();
}
pub fn isWindowReady() bool { pub fn isWindowReady() bool {
return cdef.IsWindowReady(); return cdef.IsWindowReady();
} }
@ -1514,6 +1519,10 @@ pub fn setWindowMinSize(width: i32, height: i32) void {
cdef.SetWindowMinSize(@as(c_int, width), @as(c_int, height)); cdef.SetWindowMinSize(@as(c_int, width), @as(c_int, height));
} }
pub fn setWindowMaxSize(width: i32, height: i32) void {
cdef.SetWindowMaxSize(@as(c_int, width), @as(c_int, height));
}
pub fn setWindowSize(width: i32, height: i32) void { pub fn setWindowSize(width: i32, height: i32) void {
cdef.SetWindowSize(@as(c_int, width), @as(c_int, height)); cdef.SetWindowSize(@as(c_int, width), @as(c_int, height));
} }
@ -1606,18 +1615,6 @@ pub fn disableEventWaiting() void {
cdef.DisableEventWaiting(); cdef.DisableEventWaiting();
} }
pub fn swapScreenBuffer() void {
cdef.SwapScreenBuffer();
}
pub fn pollInputEvents() void {
cdef.PollInputEvents();
}
pub fn waitTime(seconds: f64) void {
cdef.WaitTime(seconds);
}
pub fn showCursor() void { pub fn showCursor() void {
cdef.ShowCursor(); cdef.ShowCursor();
} }
@ -1782,10 +1779,6 @@ pub fn setTargetFPS(fps: i32) void {
cdef.SetTargetFPS(@as(c_int, fps)); cdef.SetTargetFPS(@as(c_int, fps));
} }
pub fn getFPS() i32 {
return @as(i32, cdef.GetFPS());
}
pub fn getFrameTime() f32 { pub fn getFrameTime() f32 {
return cdef.GetFrameTime(); return cdef.GetFrameTime();
} }
@ -1794,14 +1787,34 @@ pub fn getTime() f64 {
return cdef.GetTime(); return cdef.GetTime();
} }
pub fn getRandomValue(min: i32, max: i32) i32 { pub fn getFPS() i32 {
return @as(i32, cdef.GetRandomValue(@as(c_int, min), @as(c_int, max))); return @as(i32, cdef.GetFPS());
}
pub fn swapScreenBuffer() void {
cdef.SwapScreenBuffer();
}
pub fn pollInputEvents() void {
cdef.PollInputEvents();
}
pub fn waitTime(seconds: f64) void {
cdef.WaitTime(seconds);
} }
pub fn setRandomSeed(seed: u32) void { pub fn setRandomSeed(seed: u32) void {
cdef.SetRandomSeed(@as(c_uint, seed)); cdef.SetRandomSeed(@as(c_uint, seed));
} }
pub fn getRandomValue(min: i32, max: i32) i32 {
return @as(i32, cdef.GetRandomValue(@as(c_int, min), @as(c_int, max)));
}
pub fn unloadRandomSequence(sequence: []i32) void {
cdef.UnloadRandomSequence(@as([*c]c_int, @ptrCast(sequence)));
}
pub fn takeScreenshot(fileName: [:0]const u8) void { pub fn takeScreenshot(fileName: [:0]const u8) void {
cdef.TakeScreenshot(@as([*c]const u8, @ptrCast(fileName))); cdef.TakeScreenshot(@as([*c]const u8, @ptrCast(fileName)));
} }
@ -1810,6 +1823,10 @@ pub fn setConfigFlags(flags: ConfigFlags) void {
cdef.SetConfigFlags(flags); cdef.SetConfigFlags(flags);
} }
pub fn openURL(url: [:0]const u8) void {
cdef.OpenURL(@as([*c]const u8, @ptrCast(url)));
}
pub fn traceLog(logLevel: TraceLogLevel, text: [:0]const u8) void { pub fn traceLog(logLevel: TraceLogLevel, text: [:0]const u8) void {
cdef.TraceLog(logLevel, @as([*c]const u8, @ptrCast(text))); cdef.TraceLog(logLevel, @as([*c]const u8, @ptrCast(text)));
} }
@ -1830,10 +1847,6 @@ pub fn memFree(ptr: *anyopaque) void {
cdef.MemFree(ptr); cdef.MemFree(ptr);
} }
pub fn openURL(url: [:0]const u8) void {
cdef.OpenURL(@as([*c]const u8, @ptrCast(url)));
}
pub fn setLoadFileDataCallback(callback: LoadFileDataCallback) void { pub fn setLoadFileDataCallback(callback: LoadFileDataCallback) void {
cdef.SetLoadFileDataCallback(callback); cdef.SetLoadFileDataCallback(callback);
} }
@ -1946,10 +1959,46 @@ pub fn getFileModTime(fileName: [:0]const u8) i64 {
return @as(i64, cdef.GetFileModTime(@as([*c]const u8, @ptrCast(fileName)))); return @as(i64, cdef.GetFileModTime(@as([*c]const u8, @ptrCast(fileName))));
} }
pub fn loadAutomationEventList(fileName: [:0]const u8) AutomationEventList {
return cdef.LoadAutomationEventList(@as([*c]const u8, @ptrCast(fileName)));
}
pub fn unloadAutomationEventList(list: *AutomationEventList) void {
cdef.UnloadAutomationEventList(@as([*c]AutomationEventList, @ptrCast(list)));
}
pub fn exportAutomationEventList(list: AutomationEventList, fileName: [:0]const u8) bool {
return cdef.ExportAutomationEventList(list, @as([*c]const u8, @ptrCast(fileName)));
}
pub fn setAutomationEventList(list: *AutomationEventList) void {
cdef.SetAutomationEventList(@as([*c]AutomationEventList, @ptrCast(list)));
}
pub fn setAutomationEventBaseFrame(frame: i32) void {
cdef.SetAutomationEventBaseFrame(@as(c_int, frame));
}
pub fn startAutomationEventRecording() void {
cdef.StartAutomationEventRecording();
}
pub fn stopAutomationEventRecording() void {
cdef.StopAutomationEventRecording();
}
pub fn playAutomationEvent(event: AutomationEvent) void {
cdef.PlayAutomationEvent(event);
}
pub fn isKeyPressed(key: KeyboardKey) bool { pub fn isKeyPressed(key: KeyboardKey) bool {
return cdef.IsKeyPressed(key); return cdef.IsKeyPressed(key);
} }
pub fn isKeyPressedRepeat(key: KeyboardKey) bool {
return cdef.IsKeyPressedRepeat(key);
}
pub fn isKeyDown(key: KeyboardKey) bool { pub fn isKeyDown(key: KeyboardKey) bool {
return cdef.IsKeyDown(key); return cdef.IsKeyDown(key);
} }
@ -1962,10 +2011,6 @@ pub fn isKeyUp(key: KeyboardKey) bool {
return cdef.IsKeyUp(key); return cdef.IsKeyUp(key);
} }
pub fn setExitKey(key: KeyboardKey) void {
cdef.SetExitKey(key);
}
pub fn getKeyPressed() KeyboardKey { pub fn getKeyPressed() KeyboardKey {
return cdef.GetKeyPressed(); return cdef.GetKeyPressed();
} }
@ -1974,6 +2019,10 @@ pub fn getCharPressed() i32 {
return @as(i32, cdef.GetCharPressed()); return @as(i32, cdef.GetCharPressed());
} }
pub fn setExitKey(key: KeyboardKey) void {
cdef.SetExitKey(key);
}
pub fn isGamepadAvailable(gamepad: i32) bool { pub fn isGamepadAvailable(gamepad: i32) bool {
return cdef.IsGamepadAvailable(@as(c_int, gamepad)); return cdef.IsGamepadAvailable(@as(c_int, gamepad));
} }
@ -2158,14 +2207,6 @@ pub fn drawLineBezier(startPos: Vector2, endPos: Vector2, thick: f32, color: Col
cdef.DrawLineBezier(startPos, endPos, thick, color); cdef.DrawLineBezier(startPos, endPos, thick, color);
} }
pub fn drawLineBezierQuad(startPos: Vector2, endPos: Vector2, controlPos: Vector2, thick: f32, color: Color) void {
cdef.DrawLineBezierQuad(startPos, endPos, controlPos, thick, color);
}
pub fn drawLineBezierCubic(startPos: Vector2, endPos: Vector2, startControlPos: Vector2, endControlPos: Vector2, thick: f32, color: Color) void {
cdef.DrawLineBezierCubic(startPos, endPos, startControlPos, endControlPos, thick, color);
}
pub fn drawCircle(centerX: i32, centerY: i32, radius: f32, color: Color) void { pub fn drawCircle(centerX: i32, centerY: i32, radius: f32, color: Color) void {
cdef.DrawCircle(@as(c_int, centerX), @as(c_int, centerY), radius, color); cdef.DrawCircle(@as(c_int, centerX), @as(c_int, centerY), radius, color);
} }
@ -2190,6 +2231,10 @@ pub fn drawCircleLines(centerX: i32, centerY: i32, radius: f32, color: Color) vo
cdef.DrawCircleLines(@as(c_int, centerX), @as(c_int, centerY), radius, color); cdef.DrawCircleLines(@as(c_int, centerX), @as(c_int, centerY), radius, color);
} }
pub fn drawCircleLinesV(center: Vector2, radius: f32, color: Color) void {
cdef.DrawCircleLinesV(center, radius, color);
}
pub fn drawEllipse(centerX: i32, centerY: i32, radiusH: f32, radiusV: f32, color: Color) void { pub fn drawEllipse(centerX: i32, centerY: i32, radiusH: f32, radiusV: f32, color: Color) void {
cdef.DrawEllipse(@as(c_int, centerX), @as(c_int, centerY), radiusH, radiusV, color); cdef.DrawEllipse(@as(c_int, centerX), @as(c_int, centerY), radiusH, radiusV, color);
} }
@ -2270,6 +2315,66 @@ pub fn drawPolyLinesEx(center: Vector2, sides: i32, radius: f32, rotation: f32,
cdef.DrawPolyLinesEx(center, @as(c_int, sides), radius, rotation, lineThick, color); cdef.DrawPolyLinesEx(center, @as(c_int, sides), radius, rotation, lineThick, color);
} }
pub fn drawSplineLinear(points: []Vector2, pointCount: i32, thick: f32, color: Color) void {
cdef.DrawSplineLinear(@as([*c]Vector2, @ptrCast(points)), @as(c_int, pointCount), thick, color);
}
pub fn drawSplineBasis(points: []Vector2, pointCount: i32, thick: f32, color: Color) void {
cdef.DrawSplineBasis(@as([*c]Vector2, @ptrCast(points)), @as(c_int, pointCount), thick, color);
}
pub fn drawSplineCatmullRom(points: []Vector2, pointCount: i32, thick: f32, color: Color) void {
cdef.DrawSplineCatmullRom(@as([*c]Vector2, @ptrCast(points)), @as(c_int, pointCount), thick, color);
}
pub fn drawSplineBezierQuadratic(points: []Vector2, pointCount: i32, thick: f32, color: Color) void {
cdef.DrawSplineBezierQuadratic(@as([*c]Vector2, @ptrCast(points)), @as(c_int, pointCount), thick, color);
}
pub fn drawSplineBezierCubic(points: []Vector2, pointCount: i32, thick: f32, color: Color) void {
cdef.DrawSplineBezierCubic(@as([*c]Vector2, @ptrCast(points)), @as(c_int, pointCount), thick, color);
}
pub fn drawSplineSegmentLinear(p1: Vector2, p2: Vector2, thick: f32, color: Color) void {
cdef.DrawSplineSegmentLinear(p1, p2, thick, color);
}
pub fn drawSplineSegmentBasis(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, thick: f32, color: Color) void {
cdef.DrawSplineSegmentBasis(p1, p2, p3, p4, thick, color);
}
pub fn drawSplineSegmentCatmullRom(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, thick: f32, color: Color) void {
cdef.DrawSplineSegmentCatmullRom(p1, p2, p3, p4, thick, color);
}
pub fn drawSplineSegmentBezierQuadratic(p1: Vector2, c2: Vector2, p3: Vector2, thick: f32, color: Color) void {
cdef.DrawSplineSegmentBezierQuadratic(p1, c2, p3, thick, color);
}
pub fn drawSplineSegmentBezierCubic(p1: Vector2, c2: Vector2, c3: Vector2, p4: Vector2, thick: f32, color: Color) void {
cdef.DrawSplineSegmentBezierCubic(p1, c2, c3, p4, thick, color);
}
pub fn getSplinePointLinear(startPos: Vector2, endPos: Vector2, t: f32) Vector2 {
return cdef.GetSplinePointLinear(startPos, endPos, t);
}
pub fn getSplinePointBasis(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, t: f32) Vector2 {
return cdef.GetSplinePointBasis(p1, p2, p3, p4, t);
}
pub fn getSplinePointCatmullRom(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, t: f32) Vector2 {
return cdef.GetSplinePointCatmullRom(p1, p2, p3, p4, t);
}
pub fn getSplinePointBezierQuad(p1: Vector2, c2: Vector2, p3: Vector2, t: f32) Vector2 {
return cdef.GetSplinePointBezierQuad(p1, c2, p3, t);
}
pub fn getSplinePointBezierCubic(p1: Vector2, c2: Vector2, c3: Vector2, p4: Vector2, t: f32) Vector2 {
return cdef.GetSplinePointBezierCubic(p1, c2, c3, p4, t);
}
pub fn checkCollisionRecs(rec1: Rectangle, rec2: Rectangle) bool { pub fn checkCollisionRecs(rec1: Rectangle, rec2: Rectangle) bool {
return cdef.CheckCollisionRecs(rec1, rec2); return cdef.CheckCollisionRecs(rec1, rec2);
} }
@ -2314,6 +2419,10 @@ pub fn loadImageRaw(fileName: [:0]const u8, width: i32, height: i32, format: i32
return cdef.LoadImageRaw(@as([*c]const u8, @ptrCast(fileName)), @as(c_int, width), @as(c_int, height), @as(c_int, format), @as(c_int, headerSize)); return cdef.LoadImageRaw(@as([*c]const u8, @ptrCast(fileName)), @as(c_int, width), @as(c_int, height), @as(c_int, format), @as(c_int, headerSize));
} }
pub fn loadImageSvg(fileNameOrString: [:0]const u8, width: i32, height: i32) Image {
return cdef.LoadImageSvg(@as([*c]const u8, @ptrCast(fileNameOrString)), @as(c_int, width), @as(c_int, height));
}
pub fn loadImageAnim(fileName: [:0]const u8, frames: *i32) Image { pub fn loadImageAnim(fileName: [:0]const u8, frames: *i32) Image {
return cdef.LoadImageAnim(@as([*c]const u8, @ptrCast(fileName)), @as([*c]c_int, @ptrCast(frames))); return cdef.LoadImageAnim(@as([*c]const u8, @ptrCast(fileName)), @as([*c]c_int, @ptrCast(frames)));
} }
@ -3138,6 +3247,10 @@ pub fn setMasterVolume(volume: f32) void {
cdef.SetMasterVolume(volume); cdef.SetMasterVolume(volume);
} }
pub fn getMasterVolume() f32 {
return cdef.GetMasterVolume();
}
pub fn loadWave(fileName: [:0]const u8) Wave { pub fn loadWave(fileName: [:0]const u8) Wave {
return cdef.LoadWave(@as([*c]const u8, @ptrCast(fileName))); return cdef.LoadWave(@as([*c]const u8, @ptrCast(fileName)));
} }

1662
lib/raylib.h Normal file

File diff suppressed because it is too large Load Diff

2190
lib/raymath.h Normal file

File diff suppressed because it is too large Load Diff