From 5f16210c6ed3e80ae9e9561a9d8d49e9604a350f Mon Sep 17 00:00:00 2001 From: Lionel Briand Date: Fri, 24 May 2024 13:13:15 +0200 Subject: [PATCH] First commit --- .gitignore | 4 + LICENSE | 16 + README.MD | 150 ++++ bindings/bindings.zig | 65 ++ bindings/raygui.zig | 698 ++++++++++++++++ bindings/raylib.zig | 1805 +++++++++++++++++++++++++++++++++++++++++ bindings/rcamera.zig | 40 + bindings/rlgl.zig | 648 +++++++++++++++ build.zig | 18 + build.zig.zon | 12 + make_tar_release.sh | 15 + raygui_screenshot.png | Bin 0 -> 27410 bytes raylib.build.zig | 454 +++++++++++ 13 files changed, 3925 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.MD create mode 100644 bindings/bindings.zig create mode 100644 bindings/raygui.zig create mode 100644 bindings/raylib.zig create mode 100644 bindings/rcamera.zig create mode 100644 bindings/rlgl.zig create mode 100644 build.zig create mode 100644 build.zig.zon create mode 100755 make_tar_release.sh create mode 100644 raygui_screenshot.png create mode 100644 raylib.build.zig diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed0c4e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea +zig-cache +zig-out +release.tar.gz \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7887d68 --- /dev/null +++ b/LICENSE @@ -0,0 +1,16 @@ +Copyright (c) 2024 Lionel Briand (@L-Briand) + +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. + +Permission is granted to anyone to use this software for any purpose, including commercial +applications, and to alter it and redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not claim that you + wrote the original software. If you use this software in a product, an acknowledgment + in the product documentation would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be misrepresented + as being the original software. + + 3. This notice may not be removed or altered from any source distribution. \ No newline at end of file diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..4747952 --- /dev/null +++ b/README.MD @@ -0,0 +1,150 @@ +# Raylib Zig Bindings + +One to one translation of [raylib](https://github.com/raysan5/raylib) +and [raygui](https://github.com/raysan5/raygui) `.h` files in zig **and** build tools to compile raylib from source. + +- Raylib version `5.0` +- Raygui version `4.0` +- Zig version`0.12.0` + +At first, I wanted to learn how the zig build system worked and make a game. +But I took too much time, and now it's a tool to compile raylib directly from source with zig package manager and build +system. + +# TLDR + +[Sample project here]() using what's described below + +# Setting up a project + +You'll need raylib and raygui sources with the correct version: + +```bash +git clone --depth 1 --branch 5.0 https://github.com/raysan5/raylib.git +git clone --depth 1 --branch 4.0 https://github.com/raysan5/raygui.git +``` + +Create a `build.zig.zon` file and use this project as dependency. + +```zon +.{ + .name = "game", + .version = "0.0.0", + .dependencies = .{ + .@"raylib-zig-bindings" = .{ + .url = "TODO", + .hash = "TODO", + } + }, + .paths = .{ + "", + }, +} +``` + +Create a `build.zig` file looking like this: + +```zig +const std = @import("std"); +// Import the project from zon file. +const rlzb = @import("raylib-zig-bindings"); + +pub fn build(b: *std.Build) !void { + // Default zig setup + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const exe = b.addExecutable(.{ + .name = "game", + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = optimize, + }); + + // Adding rlzb binding files for us to use in the main.zig file. + const bindings = b.dependency("raylib-zig-bindings", .{ + .target = target, + .optimize = optimize, + }); + exe.root_module.addImport("rlzb", bindings.module("raylib-zig-bindings")); + + // Compiling raylib with main.zig + // You can select which raylib C file to add in the third parameter + var setup = try rlzb.Setup.init(b, .{ .cwd_relative = "raylib/src" }, .{}); + defer setup.deinit(); + + // This line copy the raygui.h file into raylib/src to build with it. + try setup.addRayguiToRaylibSrc(b, .{ .cwd_relative = "raygui/src/raygui.h" }); + + // If you have some raylib's C #define requirements that need to be at build time. You can set them here. + setup.setRayguiOptions(b, exe, .{}); + setup.setRCameraOptions(b, exe, .{}); + setup.setRlglOptions(b, exe, .{}); + + // Build specific for platform. + switch (target.result.os.tag) { + .windows => try setup.linkWindows(exe), + .macos => try setup.linkMacos(b, exe), + .linux => try setup.linkLinux(b, exe, .{ .platform = .DESKTOP, .backend = .X11 }), + else => @panic("Unsupported os"), + } + + // Add everything to the exe. + setup.finalize(b, exe); + + // Default zig build run command setup + b.installArtifact(exe); + const run_cmd = b.addRunArtifact(exe); + run_cmd.step.dependOn(b.getInstallStep()); + if (b.args) |args| { + run_cmd.addArgs(args); + } + const run_step = b.step("run", "Run the app"); + run_step.dependOn(&run_cmd.step); +} +``` + +And create a `src/main.zig` file. This is the translation +of [raygui code sample](https://github.com/raysan5/raygui/tree/master?tab=readme-ov-file#code-sample). + +```zig +const std = @import("std"); + +const rlzb = @import("rlzb"); +const rl = rlzb.raylib; +const rg = rlzb.raygui; + +pub fn main() !void { + rl.InitWindow(400, 200, "raygui - controls test suite"); + defer rl.CloseWindow(); + rl.SetTargetFPS(60); + + var showMessageBox = false; + + while (!rl.WindowShouldClose()) { + rl.BeginDrawing(); + const style = rg.GuiGetStyle( + rg.GuiControl.DEFAULT.toValue(), + rg.GuiDefaultProperty.BACKGROUND_COLOR.toValue(), + ); + rl.ClearBackground(rl.GetColor(@bitCast(style))); + + if (rg.GuiButton(rl.Rectangle.init(24, 24, 120, 30), "#191#Show Message") > 0) + showMessageBox = true; + + if (showMessageBox) { + const bounds = rl.Rectangle.init(85, 70, 250, 100); + const result = rg.GuiMessageBox(bounds, "#191#Message Box", "Hi! This is a message!", "Nice;Cool"); + if (result >= 0) showMessageBox = false; + } + + rl.EndDrawing(); + } + + return; +} +``` + +Then run `zig build run`. You should see a window popping up. + +![Raygui window](./raygui_screenshot.png) \ No newline at end of file diff --git a/bindings/bindings.zig b/bindings/bindings.zig new file mode 100644 index 0000000..2deb34b --- /dev/null +++ b/bindings/bindings.zig @@ -0,0 +1,65 @@ +pub const raylib = @import("raylib.zig"); +pub const rcamera = @import("rcamera.zig"); +pub const rlgl = @import("rlgl.zig"); +pub const raygui = @import("raygui.zig"); + +pub const rayall = struct { + usingnamespace raylib; + usingnamespace raylib.ConfigFlags; + usingnamespace raylib.TraceLogLevel; + usingnamespace raylib.KeyboardKey; + usingnamespace raylib.MouseButton; + usingnamespace raylib.MouseCursor; + usingnamespace raylib.GamepadButton; + usingnamespace raylib.GamepadAxis; + usingnamespace raylib.MaterialMapIndex; + usingnamespace raylib.ShaderLocationIndex; + usingnamespace raylib.ShaderUniformDataType; + usingnamespace raylib.ShaderAttributeDataType; + usingnamespace raylib.PixelFormat; + usingnamespace raylib.TextureFilter; + usingnamespace raylib.TextureWrap; + usingnamespace raylib.CubemapLayout; + usingnamespace raylib.FontType; + usingnamespace raylib.BlendMode; + usingnamespace raylib.Gesture; + usingnamespace raylib.CameraMode; + usingnamespace raylib.CameraProjection; + usingnamespace raylib.NPatchLayout; + + usingnamespace rcamera; + + usingnamespace rlgl; + usingnamespace rlgl.rlGlVersion; + usingnamespace rlgl.rlTraceLogLevel; + usingnamespace rlgl.rlPixelFormat; + usingnamespace rlgl.rlTextureFilter; + usingnamespace rlgl.rlBlendMode; + usingnamespace rlgl.rlShaderLocationIndex; + usingnamespace rlgl.rlShaderUniformDataType; + usingnamespace rlgl.rlShaderAttributeDataType; + usingnamespace rlgl.rlFramebufferAttachType; + usingnamespace rlgl.rlFramebufferAttachTextureType; + usingnamespace rlgl.rlCullMode; + + usingnamespace raygui; + usingnamespace raygui.GuiState; + usingnamespace raygui.GuiTextAlignment; + usingnamespace raygui.GuiTextAlignmentVertical; + usingnamespace raygui.GuiTextWrapMode; + usingnamespace raygui.GuiControl; + usingnamespace raygui.GuiControlProperty; + usingnamespace raygui.GuiDefaultProperty; + usingnamespace raygui.GuiToggleProperty; + usingnamespace raygui.GuiSliderProperty; + usingnamespace raygui.GuiProgressBarProperty; + usingnamespace raygui.GuiScrollBarProperty; + usingnamespace raygui.GuiCheckBoxProperty; + usingnamespace raygui.GuiComboBoxProperty; + usingnamespace raygui.GuiDropdownBoxProperty; + usingnamespace raygui.GuiTextBoxProperty; + usingnamespace raygui.GuiSpinnerProperty; + usingnamespace raygui.GuiListViewProperty; + usingnamespace raygui.GuiColorPickerProperty; + usingnamespace raygui.GuiIconName; +}; diff --git a/bindings/raygui.zig b/bindings/raygui.zig new file mode 100644 index 0000000..8332443 --- /dev/null +++ b/bindings/raygui.zig @@ -0,0 +1,698 @@ +const std = @import("std"); + +// C Options added at build time. See options.raygui.zig file. +const options = @import("raygui_options"); + +// raygui.h File + +//---------------------------------------------------------------------------------- +// Types and Structures Definition +// NOTE: Some types are required for RAYGUI_STANDALONE usage +//---------------------------------------------------------------------------------- + +pub const Vector2 = @import("raylib.zig").Vector2; +pub const Vector3 = @import("raylib.zig").Vector3; +pub const Color = @import("raylib.zig").Color; +pub const Rectangle = @import("raylib.zig").Rectangle; +pub const Texture2D = @import("raylib.zig").Texture2D; +pub const Image = @import("raylib.zig").Image; +pub const GlyphInfo = @import("raylib.zig").GlyphInfo; +pub const Font = @import("raylib.zig").Font; + +// Style property +// NOTE: Used when exporting style as code for convenience +pub const GuiStyleProp = extern struct { + controlId: c_ushort, // Control identifier + propertyId: c_ushort, // Property identifier + propertyValue: c_int, // Property value + + pub fn init(controlId: c_ushort, propertyId: c_ushort, propertyValue: c_int) GuiStyleProp { + return GuiStyleProp{ .controlId = controlId, .propertyId = propertyId, .propertyValue = propertyValue }; + } +}; + +// Gui control state +pub const GuiState = enum(c_int) { + STATE_NORMAL = 0, + STATE_FOCUSED, + STATE_PRESSED, + STATE_DISABLED, + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Gui control text alignment +pub const GuiTextAlignment = enum(c_int) { + TEXT_ALIGN_LEFT = 0, + TEXT_ALIGN_CENTER, + TEXT_ALIGN_RIGHT, + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Gui control text alignment vertical +// NOTE: Text vertical position inside the text bounds +pub const GuiTextAlignmentVertical = enum(c_int) { + TEXT_ALIGN_TOP = 0, + TEXT_ALIGN_MIDDLE, + TEXT_ALIGN_BOTTOM, + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Gui control text wrap mode +// NOTE: Useful for multiline text +pub const GuiTextWrapMode = enum(c_int) { + TEXT_WRAP_NONE = 0, + TEXT_WRAP_CHAR, + TEXT_WRAP_WORD, + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Gui controls +pub const GuiControl = enum(c_int) { + // Default -> populates to all controls when set + DEFAULT = 0, + + // Basic controls + LABEL, // Used also for: LABELBUTTON + BUTTON, + TOGGLE, // Used also for: TOGGLEGROUP + SLIDER, // Used also for: SLIDERBAR, TOGGLESLIDER + PROGRESSBAR, + CHECKBOX, + COMBOBOX, + DROPDOWNBOX, + TEXTBOX, // Used also for: TEXTBOXMULTI + VALUEBOX, + SPINNER, // Uses: BUTTON, VALUEBOX + LISTVIEW, + COLORPICKER, + SCROLLBAR, + STATUSBAR, + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Gui base properties for every control +// NOTE: RAYGUI_MAX_PROPS_BASE properties (by default 16 properties) +pub const GuiControlProperty = enum(c_int) { + BORDER_COLOR_NORMAL = 0, // Control border color in STATE_NORMAL + BASE_COLOR_NORMAL, // Control base color in STATE_NORMAL + TEXT_COLOR_NORMAL, // Control text color in STATE_NORMAL + BORDER_COLOR_FOCUSED, // Control border color in STATE_FOCUSED + BASE_COLOR_FOCUSED, // Control base color in STATE_FOCUSED + TEXT_COLOR_FOCUSED, // Control text color in STATE_FOCUSED + BORDER_COLOR_PRESSED, // Control border color in STATE_PRESSED + BASE_COLOR_PRESSED, // Control base color in STATE_PRESSED + TEXT_COLOR_PRESSED, // Control text color in STATE_PRESSED + BORDER_COLOR_DISABLED, // Control border color in STATE_DISABLED + BASE_COLOR_DISABLED, // Control base color in STATE_DISABLED + TEXT_COLOR_DISABLED, // Control text color in STATE_DISABLED + BORDER_WIDTH, // Control border size, 0 for no border + //TEXT_SIZE, // Control text size (glyphs max height) -> GLOBAL for all controls + //TEXT_SPACING, // Control text spacing between glyphs -> GLOBAL for all controls + //TEXT_LINE_SPACING // Control text spacing between lines -> GLOBAL for all controls + TEXT_PADDING, // Control text padding, not considering border + TEXT_ALIGNMENT, // Control text horizontal alignment inside control text bound (after border and padding) + //TEXT_WRAP_MODE // Control text wrap-mode inside text bounds -> GLOBAL for all controls + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// TODO: Which text styling properties should be global or per-control? +// At this moment TEXT_PADDING and TEXT_ALIGNMENT is configured and saved per control while +// TEXT_SIZE, TEXT_SPACING, TEXT_LINE_SPACING, TEXT_ALIGNMENT_VERTICAL, TEXT_WRAP_MODE are global and +// should be configured by user as needed while defining the UI layout + +// Gui extended properties depend on control +// NOTE: RAYGUI_MAX_PROPS_EXTENDED properties (by default, max 8 properties) +//---------------------------------------------------------------------------------- +// DEFAULT extended properties +// NOTE: Those properties are common to all controls or global +// WARNING: We only have 8 slots for those properties by default!!! -> New global control: TEXT? +pub const GuiDefaultProperty = enum(c_int) { + TEXT_SIZE = 16, // Text size (glyphs max height) + TEXT_SPACING, // Text spacing between glyphs + LINE_COLOR, // Line control color + BACKGROUND_COLOR, // Background color + TEXT_LINE_SPACING, // Text spacing between lines + TEXT_ALIGNMENT_VERTICAL, // Text vertical alignment inside text bounds (after border and padding) + TEXT_WRAP_MODE, // Text wrap-mode inside text bounds + //TEXT_DECORATION // Text decoration: 0-None, 1-Underline, 2-Line-through, 3-Overline + //TEXT_DECORATION_THICK // Text decoration line thikness + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Other possible text properties: +// TEXT_WEIGHT // Normal, Italic, Bold -> Requires specific font change +// TEXT_INDENT // Text indentation -> Now using TEXT_PADDING... + +// Toggle/ToggleGroup +pub const GuiToggleProperty = enum(c_int) { + GROUP_PADDING = 16, // ToggleGroup separation between toggles + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Slider/SliderBar +pub const GuiSliderProperty = enum(c_int) { + SLIDER_WIDTH = 16, // Slider size of internal bar + SLIDER_PADDING, // Slider/SliderBar internal bar padding + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// ProgressBar +pub const GuiProgressBarProperty = enum(c_int) { + PROGRESS_PADDING = 16, // ProgressBar internal padding + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// ScrollBar +pub const GuiScrollBarProperty = enum(c_int) { + ARROWS_SIZE = 16, // ScrollBar arrows size + ARROWS_VISIBLE, // ScrollBar arrows visible + SCROLL_SLIDER_PADDING, // ScrollBar slider internal padding + SCROLL_SLIDER_SIZE, // ScrollBar slider size + SCROLL_PADDING, // ScrollBar scroll padding from arrows + SCROLL_SPEED, // ScrollBar scrolling speed + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// CheckBox +pub const GuiCheckBoxProperty = enum(c_int) { + CHECK_PADDING = 16, // CheckBox internal check padding + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// ComboBox +pub const GuiComboBoxProperty = enum(c_int) { + COMBO_BUTTON_WIDTH = 16, // ComboBox right button width + COMBO_BUTTON_SPACING, // ComboBox button separation + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// DropdownBox +pub const GuiDropdownBoxProperty = enum(c_int) { + ARROW_PADDING = 16, // DropdownBox arrow separation from border and items + DROPDOWN_ITEMS_SPACING, // DropdownBox items separation + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// TextBox/TextBoxMulti/ValueBox/Spinner +pub const GuiTextBoxProperty = enum(c_int) { + TEXT_READONLY = 16, // TextBox in read-only mode: 0-text editable, 1-text no-editable + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Spinner +pub const GuiSpinnerProperty = enum(c_int) { + SPIN_BUTTON_WIDTH = 16, // Spinner left/right buttons width + SPIN_BUTTON_SPACING, // Spinner buttons separation + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// ListView +pub const GuiListViewProperty = enum(c_int) { + LIST_ITEMS_HEIGHT = 16, // ListView items height + LIST_ITEMS_SPACING, // ListView items separation + SCROLLBAR_WIDTH, // ListView scrollbar size (usually width) + SCROLLBAR_SIDE, // ListView scrollbar side (0-SCROLLBAR_LEFT_SIDE, 1-SCROLLBAR_RIGHT_SIDE) + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// ColorPicker +pub const GuiColorPickerProperty = enum(c_int) { + COLOR_SELECTOR_SIZE = 16, + HUEBAR_WIDTH, // ColorPicker right hue bar width + HUEBAR_PADDING, // ColorPicker right hue bar separation from panel + HUEBAR_SELECTOR_HEIGHT, // ColorPicker right hue bar selector height + HUEBAR_SELECTOR_OVERFLOW, // ColorPicker right hue bar selector overflow + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +pub const SCROLLBAR_LEFT_SIDE = 0; +pub const SCROLLBAR_RIGHT_SIDE = 1; + +// Global gui state control functions +pub extern fn GuiEnable() void; // Enable gui controls (global state) +pub extern fn GuiDisable() void; // Disable gui controls (global state) +pub extern fn GuiLock() void; // Lock gui controls (global state) +pub extern fn GuiUnlock() void; // Unlock gui controls (global state) +pub extern fn GuiIsLocked() bool; // Check if gui is locked (global state) +pub extern fn GuiSetAlpha(alpha: f32) void; // Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f +pub extern fn GuiSetState(state: GuiState) void; // Set gui state (global state) +pub extern fn GuiGetState() GuiState; // Get gui state (global state) + +// Font set/get functions +pub extern fn GuiSetFont(font: Font) void; // Set gui custom font (global state) +pub extern fn GuiGetFont() Font; // Get gui custom font (global state) + +// Style set/get functions +pub extern fn GuiSetStyle(control: c_int, property: c_int, value: c_int) void; // Set one style property +pub extern fn GuiGetStyle(control: c_int, property: c_int) c_int; // Get one style property + +// Styles loading functions +pub extern fn GuiLoadStyle(fileName: [*c]const u8) void; // Load style file over global style variable (.rgs) +pub extern fn GuiLoadStyleDefault() void; // Load style default over global style + +// Tooltips management functions +pub extern fn GuiEnableTooltip() void; // Enable gui tooltips (global state) +pub extern fn GuiDisableTooltip() void; // Disable gui tooltips (global state) +pub extern fn GuiSetTooltip(tooltip: [*c]const u8) void; // Set tooltip string + +// Icons functionality +pub extern fn GuiIconText(iconId: GuiIconName, text: [*c]const u8) [*c]const u8; // Get text with icon id prepended (if supported) + +// NOTE: The 4 functions below are only available when RAYGUI_NO_ICONS is set. +pub extern fn GuiSetIconScale(scale: c_int) void; // Set default icon drawing size +pub extern fn GuiGetIcons() [*c]c_uint; // Get raygui icons data pointer +pub extern fn GuiLoadIcons(fileName: [*c]const u8, loadIconsName: bool) [*c][*c]u8; // Load raygui icons file (.rgi) into internal icons data +pub extern fn GuiDrawIcon(iconId: GuiIconName, posX: c_int, posY: c_int, pixelSize: c_int, color: Color) void; // Draw icon using pixel size at specified position + +// Controls +//---------------------------------------------------------------------------------------------------------- +// Container/separator controls, useful for controls organization +pub extern fn GuiWindowBox(bounds: Rectangle, title: [*c]const u8) c_int; // Window Box control, shows a window that can be closed +pub extern fn GuiGroupBox(bounds: Rectangle, text: [*c]const u8) c_int; // Group Box control with text name +pub extern fn GuiLine(bounds: Rectangle, text: [*c]const u8) c_int; // Line separator control, could contain text +pub extern fn GuiPanel(bounds: Rectangle, text: [*c]const u8) c_int; // Panel control, useful to group controls +pub extern fn GuiTabBar(bounds: Rectangle, text: [*c][*c]const u8, count: c_int, active: [*c]c_int) c_int; // Tab Bar control, returns TAB to be closed or -1 +pub extern fn GuiScrollPanel(bounds: Rectangle, text: [*c]const u8, content: Rectangle, scroll: [*c]Vector2, view: [*c]Rectangle) c_int; // Scroll Panel control + +// Basic controls set +pub extern fn GuiLabel(bounds: Rectangle, text: [*c]const u8) c_int; // Label control, shows text +pub extern fn GuiButton(bounds: Rectangle, text: [*c]const u8) c_int; // Button control, returns true when clicked +pub extern fn GuiLabelButton(bounds: Rectangle, text: [*c]const u8) c_int; // Label button control, show true when clicked +pub extern fn GuiToggle(bounds: Rectangle, text: [*c]const u8, active: [*c]bool) c_int; // Toggle Button control, returns true when active +pub extern fn GuiToggleGroup(bounds: Rectangle, text: [*c]const u8, active: [*c]c_int) c_int; // Toggle Group control, returns active toggle index +pub extern fn GuiToggleSlider(bounds: Rectangle, text: [*c]const u8, active: [*c]c_int) c_int; // Toggle Slider control, returns true when clicked +pub extern fn GuiCheckBox(bounds: Rectangle, text: [*c]const u8, checked: [*c]bool) c_int; // Check Box control, returns true when active +pub extern fn GuiComboBox(bounds: Rectangle, text: [*c]const u8, active: [*c]c_int) c_int; // Combo Box control, returns selected item index + +pub extern fn GuiDropdownBox(bounds: Rectangle, text: [*c]const u8, active: [*c]c_int, editMode: bool) c_int; // Dropdown Box control, returns selected item +pub extern fn GuiSpinner(bounds: Rectangle, text: [*c]const u8, value: [*c]c_int, minValue: c_int, maxValue: c_int, editMode: bool) c_int; // Spinner control, returns selected value +pub extern fn GuiValueBox(bounds: Rectangle, text: [*c]const u8, value: [*c]c_int, minValue: c_int, maxValue: c_int, editMode: bool) c_int; // Value Box control, updates input text with numbers +pub extern fn GuiTextBox(bounds: Rectangle, text: [*c]u8, textSize: c_int, editMode: bool) c_int; // Text Box control, updates input text + +pub extern fn GuiSlider(bounds: Rectangle, textLeft: [*c]const u8, textRight: [*c]const u8, value: [*c]f32, minValue: f32, maxValue: f32) c_int; // Slider control, returns selected value +pub extern fn GuiSliderBar(bounds: Rectangle, textLeft: [*c]const u8, textRight: [*c]const u8, value: [*c]f32, minValue: f32, maxValue: f32) c_int; // Slider Bar control, returns selected value +pub extern fn GuiProgressBar(bounds: Rectangle, textLeft: [*c]const u8, textRight: [*c]const u8, value: [*c]f32, minValue: f32, maxValue: f32) c_int; // Progress Bar control, shows current progress value +pub extern fn GuiStatusBar(bounds: Rectangle, text: [*c]const u8) c_int; // Status Bar control, shows info text +pub extern fn GuiDummyRec(bounds: Rectangle, text: [*c]const u8) c_int; // Dummy control for placeholders +pub extern fn GuiGrid(bounds: Rectangle, text: [*c]const u8, spacing: f32, subdivs: c_int, mouseCell: [*c]Vector2) c_int; // Grid control, returns mouse cell position + +// Advance controls set +pub extern fn GuiListView(bounds: Rectangle, text: [*c]const u8, scrollIndex: [*c]c_int, active: [*c]c_int) c_int; // List View control, returns selected list item index +pub extern fn GuiListViewEx(bounds: Rectangle, text: [*c][*c]const u8, count: c_int, scrollIndex: [*c]c_int, active: [*c]c_int, focus: [*c]c_int) c_int; // List View with extended parameters +pub extern fn GuiMessageBox(bounds: Rectangle, title: [*c]const u8, message: [*c]const u8, buttons: [*c]const u8) c_int; // Message Box control, displays a message +pub extern fn GuiTextInputBox(bounds: Rectangle, title: [*c]const u8, message: [*c]const u8, buttons: [*c]const u8, text: [*c]u8, textMaxSize: c_int, secretViewActive: [*c]bool) c_int; // Text Input Box control, ask for text, supports secret +pub extern fn GuiColorPicker(bounds: Rectangle, text: [*c]const u8, color: [*c]Color) c_int; // Color Picker control (multiple color controls) +pub extern fn GuiColorPanel(bounds: Rectangle, text: [*c]const u8, color: [*c]Color) c_int; // Color Panel control +pub extern fn GuiColorBarAlpha(bounds: Rectangle, text: [*c]const u8, alpha: [*c]f32) c_int; // Color Bar Alpha control +pub extern fn GuiColorBarHue(bounds: Rectangle, text: [*c]const u8, value: [*c]f32) c_int; // Color Bar Hue control +pub extern fn GuiColorPickerHSV(bounds: Rectangle, text: [*c]const u8, colorHsv: [*c]Vector3) c_int; // Color Picker control that avoids conversion to RGB on each call (multiple color controls) +pub extern fn GuiColorPanelHSV(bounds: Rectangle, text: [*c]const u8, colorHsv: [*c]Vector3) c_int; // Color Panel control that returns HSV color value, used by GuiColorPickerHSV() +//---------------------------------------------------------------------------------------------------------- + +//---------------------------------------------------------------------------------- +// Icons enumeration +//---------------------------------------------------------------------------------- +pub const GuiIconName = enum(c_int) { + ICON_NONE = 0, + ICON_FOLDER_FILE_OPEN = 1, + ICON_FILE_SAVE_CLASSIC = 2, + ICON_FOLDER_OPEN = 3, + ICON_FOLDER_SAVE = 4, + ICON_FILE_OPEN = 5, + ICON_FILE_SAVE = 6, + ICON_FILE_EXPORT = 7, + ICON_FILE_ADD = 8, + ICON_FILE_DELETE = 9, + ICON_FILETYPE_TEXT = 10, + ICON_FILETYPE_AUDIO = 11, + ICON_FILETYPE_IMAGE = 12, + ICON_FILETYPE_PLAY = 13, + ICON_FILETYPE_VIDEO = 14, + ICON_FILETYPE_INFO = 15, + ICON_FILE_COPY = 16, + ICON_FILE_CUT = 17, + ICON_FILE_PASTE = 18, + ICON_CURSOR_HAND = 19, + ICON_CURSOR_POINTER = 20, + ICON_CURSOR_CLASSIC = 21, + ICON_PENCIL = 22, + ICON_PENCIL_BIG = 23, + ICON_BRUSH_CLASSIC = 24, + ICON_BRUSH_PAINTER = 25, + ICON_WATER_DROP = 26, + ICON_COLOR_PICKER = 27, + ICON_RUBBER = 28, + ICON_COLOR_BUCKET = 29, + ICON_TEXT_T = 30, + ICON_TEXT_A = 31, + ICON_SCALE = 32, + ICON_RESIZE = 33, + ICON_FILTER_POINT = 34, + ICON_FILTER_BILINEAR = 35, + ICON_CROP = 36, + ICON_CROP_ALPHA = 37, + ICON_SQUARE_TOGGLE = 38, + ICON_SYMMETRY = 39, + ICON_SYMMETRY_HORIZONTAL = 40, + ICON_SYMMETRY_VERTICAL = 41, + ICON_LENS = 42, + ICON_LENS_BIG = 43, + ICON_EYE_ON = 44, + ICON_EYE_OFF = 45, + ICON_FILTER_TOP = 46, + ICON_FILTER = 47, + ICON_TARGET_POINT = 48, + ICON_TARGET_SMALL = 49, + ICON_TARGET_BIG = 50, + ICON_TARGET_MOVE = 51, + ICON_CURSOR_MOVE = 52, + ICON_CURSOR_SCALE = 53, + ICON_CURSOR_SCALE_RIGHT = 54, + ICON_CURSOR_SCALE_LEFT = 55, + ICON_UNDO = 56, + ICON_REDO = 57, + ICON_REREDO = 58, + ICON_MUTATE = 59, + ICON_ROTATE = 60, + ICON_REPEAT = 61, + ICON_SHUFFLE = 62, + ICON_EMPTYBOX = 63, + ICON_TARGET = 64, + ICON_TARGET_SMALL_FILL = 65, + ICON_TARGET_BIG_FILL = 66, + ICON_TARGET_MOVE_FILL = 67, + ICON_CURSOR_MOVE_FILL = 68, + ICON_CURSOR_SCALE_FILL = 69, + ICON_CURSOR_SCALE_RIGHT_FILL = 70, + ICON_CURSOR_SCALE_LEFT_FILL = 71, + ICON_UNDO_FILL = 72, + ICON_REDO_FILL = 73, + ICON_REREDO_FILL = 74, + ICON_MUTATE_FILL = 75, + ICON_ROTATE_FILL = 76, + ICON_REPEAT_FILL = 77, + ICON_SHUFFLE_FILL = 78, + ICON_EMPTYBOX_SMALL = 79, + ICON_BOX = 80, + ICON_BOX_TOP = 81, + ICON_BOX_TOP_RIGHT = 82, + ICON_BOX_RIGHT = 83, + ICON_BOX_BOTTOM_RIGHT = 84, + ICON_BOX_BOTTOM = 85, + ICON_BOX_BOTTOM_LEFT = 86, + ICON_BOX_LEFT = 87, + ICON_BOX_TOP_LEFT = 88, + ICON_BOX_CENTER = 89, + ICON_BOX_CIRCLE_MASK = 90, + ICON_POT = 91, + ICON_ALPHA_MULTIPLY = 92, + ICON_ALPHA_CLEAR = 93, + ICON_DITHERING = 94, + ICON_MIPMAPS = 95, + ICON_BOX_GRID = 96, + ICON_GRID = 97, + ICON_BOX_CORNERS_SMALL = 98, + ICON_BOX_CORNERS_BIG = 99, + ICON_FOUR_BOXES = 100, + ICON_GRID_FILL = 101, + ICON_BOX_MULTISIZE = 102, + ICON_ZOOM_SMALL = 103, + ICON_ZOOM_MEDIUM = 104, + ICON_ZOOM_BIG = 105, + ICON_ZOOM_ALL = 106, + ICON_ZOOM_CENTER = 107, + ICON_BOX_DOTS_SMALL = 108, + ICON_BOX_DOTS_BIG = 109, + ICON_BOX_CONCENTRIC = 110, + ICON_BOX_GRID_BIG = 111, + ICON_OK_TICK = 112, + ICON_CROSS = 113, + ICON_ARROW_LEFT = 114, + ICON_ARROW_RIGHT = 115, + ICON_ARROW_DOWN = 116, + ICON_ARROW_UP = 117, + ICON_ARROW_LEFT_FILL = 118, + ICON_ARROW_RIGHT_FILL = 119, + ICON_ARROW_DOWN_FILL = 120, + ICON_ARROW_UP_FILL = 121, + ICON_AUDIO = 122, + ICON_FX = 123, + ICON_WAVE = 124, + ICON_WAVE_SINUS = 125, + ICON_WAVE_SQUARE = 126, + ICON_WAVE_TRIANGULAR = 127, + ICON_CROSS_SMALL = 128, + ICON_PLAYER_PREVIOUS = 129, + ICON_PLAYER_PLAY_BACK = 130, + ICON_PLAYER_PLAY = 131, + ICON_PLAYER_PAUSE = 132, + ICON_PLAYER_STOP = 133, + ICON_PLAYER_NEXT = 134, + ICON_PLAYER_RECORD = 135, + ICON_MAGNET = 136, + ICON_LOCK_CLOSE = 137, + ICON_LOCK_OPEN = 138, + ICON_CLOCK = 139, + ICON_TOOLS = 140, + ICON_GEAR = 141, + ICON_GEAR_BIG = 142, + ICON_BIN = 143, + ICON_HAND_POINTER = 144, + ICON_LASER = 145, + ICON_COIN = 146, + ICON_EXPLOSION = 147, + ICON_1UP = 148, + ICON_PLAYER = 149, + ICON_PLAYER_JUMP = 150, + ICON_KEY = 151, + ICON_DEMON = 152, + ICON_TEXT_POPUP = 153, + ICON_GEAR_EX = 154, + ICON_CRACK = 155, + ICON_CRACK_POINTS = 156, + ICON_STAR = 157, + ICON_DOOR = 158, + ICON_EXIT = 159, + ICON_MODE_2D = 160, + ICON_MODE_3D = 161, + ICON_CUBE = 162, + ICON_CUBE_FACE_TOP = 163, + ICON_CUBE_FACE_LEFT = 164, + ICON_CUBE_FACE_FRONT = 165, + ICON_CUBE_FACE_BOTTOM = 166, + ICON_CUBE_FACE_RIGHT = 167, + ICON_CUBE_FACE_BACK = 168, + ICON_CAMERA = 169, + ICON_SPECIAL = 170, + ICON_LINK_NET = 171, + ICON_LINK_BOXES = 172, + ICON_LINK_MULTI = 173, + ICON_LINK = 174, + ICON_LINK_BROKE = 175, + ICON_TEXT_NOTES = 176, + ICON_NOTEBOOK = 177, + ICON_SUITCASE = 178, + ICON_SUITCASE_ZIP = 179, + ICON_MAILBOX = 180, + ICON_MONITOR = 181, + ICON_PRINTER = 182, + ICON_PHOTO_CAMERA = 183, + ICON_PHOTO_CAMERA_FLASH = 184, + ICON_HOUSE = 185, + ICON_HEART = 186, + ICON_CORNER = 187, + ICON_VERTICAL_BARS = 188, + ICON_VERTICAL_BARS_FILL = 189, + ICON_LIFE_BARS = 190, + ICON_INFO = 191, + ICON_CROSSLINE = 192, + ICON_HELP = 193, + ICON_FILETYPE_ALPHA = 194, + ICON_FILETYPE_HOME = 195, + ICON_LAYERS_VISIBLE = 196, + ICON_LAYERS = 197, + ICON_WINDOW = 198, + ICON_HIDPI = 199, + ICON_FILETYPE_BINARY = 200, + ICON_HEX = 201, + ICON_SHIELD = 202, + ICON_FILE_NEW = 203, + ICON_FOLDER_ADD = 204, + ICON_ALARM = 205, + ICON_CPU = 206, + ICON_ROM = 207, + ICON_STEP_OVER = 208, + ICON_STEP_INTO = 209, + ICON_STEP_OUT = 210, + ICON_RESTART = 211, + ICON_BREAKPOINT_ON = 212, + ICON_BREAKPOINT_OFF = 213, + ICON_BURGER_MENU = 214, + ICON_CASE_SENSITIVE = 215, + ICON_REG_EXP = 216, + ICON_FOLDER = 217, + ICON_FILE = 218, + ICON_SAND_TIMER = 219, + ICON_220 = 220, + ICON_221 = 221, + ICON_222 = 222, + ICON_223 = 223, + ICON_224 = 224, + ICON_225 = 225, + ICON_226 = 226, + ICON_227 = 227, + ICON_228 = 228, + ICON_229 = 229, + ICON_230 = 230, + ICON_231 = 231, + ICON_232 = 232, + ICON_233 = 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, + ICON_250 = 250, + ICON_251 = 251, + ICON_252 = 252, + ICON_253 = 253, + ICON_254 = 254, + ICON_255 = 255, +}; diff --git a/bindings/raylib.zig b/bindings/raylib.zig new file mode 100644 index 0000000..54f2a11 --- /dev/null +++ b/bindings/raylib.zig @@ -0,0 +1,1805 @@ +const std = @import("std"); + +test { + std.testing.refAllDeclsRecursive(@This()); +} + +// raylib.h file + +pub const RAYLIB_VERSION_MAJOR = 5; +pub const RAYLIB_VERSION_MINOR = 0; +pub const RAYLIB_VERSION_PATCH = 0; +pub const RAYLIB_VERSION = "5.0"; + +// Some Basic Colors +// NOTE: Custom raylib color palette for amazing visuals on WHITE background +pub const LIGHTGRAY: Color = Color.init(200, 200, 200, 255); // Light Gray +pub const GRAY: Color = Color.init(130, 130, 130, 255); // Gray +pub const DARKGRAY: Color = Color.init(80, 80, 80, 255); // Dark Gray +pub const YELLOW: Color = Color.init(253, 249, 0, 255); // Yellow +pub const GOLD: Color = Color.init(255, 203, 0, 255); // Gold +pub const ORANGE: Color = Color.init(255, 161, 0, 255); // Orange +pub const PINK: Color = Color.init(255, 109, 194, 255); // Pink +pub const RED: Color = Color.init(230, 41, 55, 255); // Red +pub const MAROON: Color = Color.init(190, 33, 55, 255); // Maroon +pub const GREEN: Color = Color.init(0, 228, 48, 255); // Green +pub const LIME: Color = Color.init(0, 158, 47, 255); // Lime +pub const DARKGREEN: Color = Color.init(0, 117, 44, 255); // Dark Green +pub const SKYBLUE: Color = Color.init(102, 191, 255, 255); // Sky Blue +pub const BLUE: Color = Color.init(0, 121, 241, 255); // Blue +pub const DARKBLUE: Color = Color.init(0, 82, 172, 255); // Dark Blue +pub const PURPLE: Color = Color.init(200, 122, 255, 255); // Purple +pub const VIOLET: Color = Color.init(135, 60, 190, 255); // Violet +pub const DARKPURPLE: Color = Color.init(112, 31, 126, 255); // Dark Purple +pub const BEIGE: Color = Color.init(211, 176, 131, 255); // Beige +pub const BROWN: Color = Color.init(127, 106, 79, 255); // Brown +pub const DARKBROWN: Color = Color.init(76, 63, 47, 255); // Dark Brown + +pub const WHITE: Color = Color.init(255, 255, 255, 255); // White +pub const BLACK: Color = Color.init(0, 0, 0, 255); // Black +pub const BLANK: Color = Color.init(0, 0, 0, 0); // Blank (Transparent) +pub const MAGENTA: Color = Color.init(255, 0, 255, 255); // Magenta +pub const RAYWHITE: Color = Color.init(245, 245, 245, 255); // Ray's White (raylib logo) + +//---------------------------------------------------------------------------------- +// Structures Definition +//---------------------------------------------------------------------------------- + +/// Vector2, 2 components +pub const Vector2 = extern struct { + x: f32, // Vector x component + y: f32, // Vector y component + + pub fn init(x: f32, y: f32) Vector2 { + return Vector2{ .x = x, .y = y }; + } +}; + +/// Vector3, 3 components +pub const Vector3 = extern struct { + x: f32, // Vector x component + y: f32, // Vector y component + z: f32, // Vector z component + + pub fn init(x: f32, y: f32, z: f32) Vector3 { + return Vector3{ .x = x, .y = y, .z = z }; + } +}; + +/// Vector4, 4 components +pub const Vector4 = extern struct { + x: f32, // Vector x component + y: f32, // Vector y component + z: f32, // Vector z component + w: f32, // Vector w component + + pub fn init(x: f32, y: f32, z: f32, w: f32) Vector4 { + return Vector4{ .x = x, .y = y, .z = z, .w = w }; + } +}; + +// Quaternion, 4 components (Vector4 alias) +pub const Quaternion = Vector4; + +/// Matrix, 4x4 components, column major, OpenGL style, right handed +pub const Matrix = extern struct { + m0: f32, // Matrix first row (4 components) + m4: f32, + m8: f32, + m12: f32, + m1: f32, // Matrix second row (4 components) + m5: f32, + m9: f32, + m13: f32, + m2: f32, // Matrix third row (4 components) + m6: f32, + m10: f32, + m14: f32, + m3: f32, // Matrix fourth row (4 components) + m7: f32, + m11: f32, + m15: f32, + + pub fn init(m0: f32, m4: f32, m8: f32, m12: f32, m1: f32, m5: f32, m9: f32, m13: f32, m2: f32, m6: f32, m10: f32, m14: f32, m3: f32, m7: f32, m11: f32, m15: f32) Matrix { + return Matrix{ .m0 = m0, .m4 = m4, .m8 = m8, .m12 = m12, .m1 = m1, .m5 = m5, .m9 = m9, .m13 = m13, .m2 = m2, .m6 = m6, .m10 = m10, .m14 = m14, .m3 = m3, .m7 = m7, .m11 = m11, .m15 = m15 }; + } +}; + +/// Color, 4 components, R8G8B8A8 (32bit) +pub const Color = extern struct { + r: u8, // Color red value + g: u8, // Color green value + b: u8, // Color blue value + a: u8, // Color alpha value + + pub fn init(r: u8, g: u8, b: u8, a: u8) Color { + return Color{ .r = r, .g = g, .b = b, .a = a }; + } +}; + +/// Rectangle, 4 components +pub const Rectangle = extern struct { + x: f32, // Rectangle top-left corner position x + y: f32, // Rectangle top-left corner position y + width: f32, // Rectangle width + height: f32, // Rectangle height + + pub fn init(x: f32, y: f32, width: f32, height: f32) Rectangle { + return Rectangle{ .x = x, .y = y, .width = width, .height = height }; + } +}; + +/// Image, pixel data stored in CPU memory (RAM) +pub const Image = extern struct { + data: *anyopaque, // Image raw data + width: c_int, // Image base width + height: c_int, // Image base height + mipmaps: c_int, // Mipmap levels, 1 by default + format: c_int, // Data format (PixelFormat type) TODO: ENUM + + pub fn init(data: *anyopaque, width: c_int, height: c_int, mipmaps: c_int, format: c_int) Image { + return Image{ .data = data, .width = width, .height = height, .mipmaps = mipmaps, .format = format }; + } +}; + +/// Texture, tex data stored in GPU memory (VRAM) +pub const Texture = extern struct { + id: c_uint, // OpenGL texture id + width: c_int, // Texture base width + height: c_int, // Texture base height + mipmaps: c_int, // Mipmap levels, 1 by default + format: c_int, // Data format (PixelFormat type) TODO: ENUM + + pub fn init(id: c_uint, width: c_int, height: c_int, mipmaps: c_int, format: c_int) Texture { + return Texture{ .id = id, .width = width, .height = height, .mipmaps = mipmaps, .format = format }; + } +}; +// Texture2D, same as Texture +pub const Texture2D = Texture; +// TextureCubemap, same as Texture +pub const TextureCubemap = Texture; + +/// RenderTexture, fbo for texture rendering +pub const RenderTexture = extern struct { + id: c_uint, // OpenGL framebuffer object id + texture: Texture, // Color buffer attachment texture + depth: Texture, // Depth buffer attachment texture + + pub fn init(id: c_uint, texture: Texture, depth: Texture) RenderTexture { + return RenderTexture{ .id = id, .texture = texture, .depth = depth }; + } +}; +// RenderTexture2D, same as RenderTexture +pub const RenderTexture2D = RenderTexture; + +/// NPatchInfo, n-patch layout info +pub const NPatchInfo = extern struct { + source: Rectangle, // Texture source rectangle + left: c_int, // Left border offset + top: c_int, // Top border offset + right: c_int, // Right border offset + bottom: c_int, // Bottom border offset + layout: c_int, // Layout of the n-patch: 3x3, 1x3 or 3x1 + + pub fn init(source: Rectangle, left: c_int, top: c_int, right: c_int, bottom: c_int, layout: c_int) NPatchInfo { + return NPatchInfo{ .source = source, .left = left, .top = top, .right = right, .bottom = bottom, .layout = layout }; + } +}; + +/// GlyphInfo, font characters glyphs info +pub const GlyphInfo = extern struct { + value: c_int, // Character value (Unicode) + offsetX: c_int, // Character offset X when drawing + offsetY: c_int, // Character offset Y when drawing + advanceX: c_int, // Character advance position X + image: Image, // Character image data + + pub fn init(value: c_int, offsetX: c_int, offsetY: c_int, advanceX: c_int, image: Image) GlyphInfo { + return GlyphInfo{ .value = value, .offsetX = offsetX, .offsetY = offsetY, .advanceX = advanceX, .image = image }; + } +}; + +/// Font, font texture and GlyphInfo array data +pub const Font = extern struct { + baseSize: c_int, // Base size (default chars height) + glyphCount: c_int, // Number of glyph characters + glyphPadding: c_int, // Padding around the glyph characters + texture: Texture2D, // Texture atlas containing the glyphs + recs: [*c]Rectangle, // Rectangles in texture for the glyphs + glyphs: [*c]GlyphInfo, // Glyphs info data + + pub fn init(baseSize: c_int, glyphCount: c_int, glyphPadding: c_int, texture: Texture2D, recs: [*c]Rectangle, glyphs: [*c]GlyphInfo) Font { + return Font{ .baseSize = baseSize, .glyphCount = glyphCount, .glyphPadding = glyphPadding, .texture = texture, .recs = recs, .glyphs = glyphs }; + } +}; + +/// Camera, defines position/orientation in 3d space +pub const Camera3D = extern struct { + position: Vector3, // Camera position + target: Vector3, // Camera target it looks-at + up: Vector3, // Camera up vector (rotation over its axis) + fovy: f32, // Camera field-of-view aperture in Y (degrees) in perspective, used as near plane width in orthographic + projection: c_int, // Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC + + pub fn init(position: Vector3, target: Vector3, up: Vector3, fovy: f32, projection: c_int) Camera3D { + return Camera3D{ .position = position, .target = target, .up = up, .fovy = fovy, .projection = projection }; + } +}; + +/// Camera type fallback, defaults to Camera3D +pub const Camera = Camera3D; + +/// Camera2D, defines position/orientation in 2d space +pub const Camera2D = extern struct { + offset: Vector2, // Camera offset (displacement from target) + target: Vector2, // Camera target (rotation and zoom origin) + rotation: f32, // Camera rotation in degrees + zoom: f32, // Camera zoom (scaling), should be 1.0f by default + + pub fn init(offset: Vector2, target: Vector2, rotation: f32, zoom: f32) Camera2D { + return Camera2D{ .offset = offset, .target = target, .rotation = rotation, .zoom = zoom }; + } +}; + +/// Mesh, vertex data and vao/vbo +pub const Mesh = extern struct { + vertexCount: c_int, // Number of vertices stored in arrays + triangleCount: c_int, // Number of triangles stored (indexed or not) + + // Vertex attributes data + vertices: [*c]f32, // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) + texcoords: [*c]f32, // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) + texcoords2: [*c]f32, // Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5) + normals: [*c]f32, // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) + tangents: [*c]f32, // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4) + colors: [*c]u8, // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) + indices: [*c]c_ushort, // Vertex indices (in case vertex data comes indexed) + + // Animation vertex data + animVertices: [*c]f32, // Animated vertex positions (after bones transformations) + animNormals: [*c]f32, // Animated normals (after bones transformations) + boneIds: [*c]u8, // Vertex bone ids, max 255 bone ids, up to 4 bones influence by vertex (skinning) + boneWeights: [*c]f32, // Vertex bone weight, up to 4 bones influence by vertex (skinning) + + // OpenGL identifiers + vaoId: c_uint, // OpenGL Vertex Array Object id + vboId: [*c]c_uint, // OpenGL Vertex Buffer Objects id (default vertex data) + + pub fn init(vertexCount: c_int, triangleCount: c_int, vertices: [*c]f32, texcoords: [*c]f32, texcoords2: [*c]f32, normals: [*c]f32, tangents: [*c]f32, colors: [*c]u8, indices: [*c]c_ushort, animVertices: [*c]f32, animNormals: [*c]f32, boneIds: [*c]u8, boneWeights: [*c]f32, vaoId: c_uint, vboId: [*c]c_uint) Mesh { + return Mesh{ .vertexCount = vertexCount, .triangleCount = triangleCount, .vertices = vertices, .texcoords = texcoords, .texcoords2 = texcoords2, .normals = normals, .tangents = tangents, .colors = colors, .indices = indices, .animVertices = animVertices, .animNormals = animNormals, .boneIds = boneIds, .boneWeights = boneWeights, .vaoId = vaoId, .vboId = vboId }; + } +}; + +/// Shader +pub const Shader = extern struct { + id: c_uint, // Shader program id + locs: [*c]c_int, // Shader locations array (RL_MAX_SHADER_LOCATIONS) + + pub fn init(id: c_uint, locs: [*c]c_int) Shader { + return Shader{ .id = id, .locs = locs }; + } +}; + +/// MaterialMap +pub const MaterialMap = extern struct { + texture: Texture2D, // Material map texture + color: Color, // Material map color + value: f32, // Material map value + + pub fn init(texture: Texture2D, color: Color, value: f32) MaterialMap { + return MaterialMap{ .texture = texture, .color = color, .value = value }; + } +}; + +/// Material, includes shader and maps +pub const Material = extern struct { + shader: Shader, // Material shader + maps: [*c]MaterialMap, // Material maps array (MAX_MATERIAL_MAPS) + params: [4]f32, // Material generic parameters (if required) + + pub fn init(shader: Shader, maps: [*c]MaterialMap, params: [4]f32) Material { + return Material{ .shader = shader, .maps = maps, .params = params }; + } +}; + +/// Transform, vertex transformation data +pub const Transform = extern struct { + translation: Vector3, // Translation + rotation: Quaternion, // Rotation + scale: Vector3, // Scale + + pub fn init(translation: Vector3, rotation: Quaternion, scale: Vector3) Transform { + return Transform{ .translation = translation, .rotation = rotation, .scale = scale }; + } +}; + +/// Bone, skeletal animation bone +pub const BoneInfo = extern struct { + name: [32]u8, // Bone name + parent: c_int, // Bone parent + + pub fn init(name: [32]u8, parent: c_int) BoneInfo { + return BoneInfo{ .name = name, .parent = parent }; + } +}; + +/// Model, meshes, materials and animation data +pub const Model = extern struct { + transform: Matrix, // Local transform matrix + + meshCount: c_int, // Number of meshes + materialCount: c_int, // Number of materials + meshes: [*c]Mesh, // Meshes array + materials: [*c]Material, // Materials array + meshMaterial: [*c]c_int, // Mesh material number + + // Animation data + boneCount: c_int, // Number of bones + bones: [*c]BoneInfo, // Bones information (skeleton) + bindPose: [*c]Transform, // Bones base transformation (pose) + + pub fn init(transform: Matrix, meshCount: c_int, materialCount: c_int, meshes: [*c]Mesh, materials: [*c]Material, meshMaterial: [*c]c_int, boneCount: c_int, bones: [*c]BoneInfo, bindPose: [*c]Transform) Model { + return Model{ .transform = transform, .meshCount = meshCount, .materialCount = materialCount, .meshes = meshes, .materials = materials, .meshMaterial = meshMaterial, .boneCount = boneCount, .bones = bones, .bindPose = bindPose }; + } +}; + +/// ModelAnimation +pub const ModelAnimation = extern struct { + boneCount: c_int, // Number of bones + frameCount: c_int, // Number of animation frames + bones: [*c]BoneInfo, // Bones information (skeleton) + framePoses: [*c][*c]Transform, // Poses array by frame + name: [32]u8, // Animation name + + pub fn init(boneCount: c_int, frameCount: c_int, bones: [*c]BoneInfo, framePoses: [*c][*c]Transform, name: [32]u8) ModelAnimation { + return ModelAnimation{ .boneCount = boneCount, .frameCount = frameCount, .bones = bones, .framePoses = framePoses, .name = name }; + } +}; + +/// Ray, ray for raycasting +pub const Ray = extern struct { + position: Vector3, // Ray position (origin) + direction: Vector3, // Ray direction + + pub fn init(position: Vector3, direction: Vector3) Ray { + return Ray{ .position = position, .direction = direction }; + } +}; + +/// RayCollision, ray hit information +pub const RayCollision = extern struct { + hit: bool, // Did the ray hit something? + distance: f32, // Distance to the nearest hit + point: Vector3, // Point of the nearest hit + normal: Vector3, // Surface normal of hit + + pub fn init(hit: bool, distance: f32, point: Vector3, normal: Vector3) RayCollision { + return RayCollision{ .hit = hit, .distance = distance, .point = point, .normal = normal }; + } +}; + +/// BoundingBox +pub const BoundingBox = extern struct { + min: Vector3, // Minimum vertex box-corner + max: Vector3, // Maximum vertex box-corner + + pub fn init(min: Vector3, max: Vector3) BoundingBox { + return BoundingBox{ .min = min, .max = max }; + } +}; + +/// Wave, audio wave data +pub const Wave = extern struct { + frameCount: c_uint, // Total number of frames (considering channels) + sampleRate: c_uint, // Frequency (samples per second) + sampleSize: c_uint, // Bit depth (bits per sample): 8, 16, 32 (24 not supported) + channels: c_uint, // Number of channels (1-mono, 2-stereo, ...) + data: *anyopaque, // Buffer data pointer + + pub fn init(frameCount: c_uint, sampleRate: c_uint, sampleSize: c_uint, channels: c_uint, data: *anyopaque) Wave { + return Wave{ .frameCount = frameCount, .sampleRate = sampleRate, .sampleSize = sampleSize, .channels = channels, .data = data }; + } +}; + +// Opaque structs declaration +// NOTE: Actual structs are defined internally in raudio module +pub const rAudioBuffer = opaque {}; +pub const rAudioProcessor = opaque {}; + +/// AudioStream, custom audio stream +pub const AudioStream = extern struct { + buffer: *rAudioBuffer, // Pointer to internal data used by the audio system + processor: *rAudioProcessor, // Pointer to internal data processor, useful for audio effects + + sampleRate: c_uint, // Frequency (samples per second) + sampleSize: c_uint, // Bit depth (bits per sample): 8, 16, 32 (24 not supported) + channels: c_uint, // Number of channels (1-mono, 2-stereo, ...) + + pub fn init(buffer: *rAudioBuffer, processor: *rAudioProcessor, sampleRate: c_uint, sampleSize: c_uint, channels: c_uint) AudioStream { + return AudioStream{ .buffer = buffer, .processor = processor, .sampleRate = sampleRate, .sampleSize = sampleSize, .channels = channels }; + } +}; + +/// Sound +pub const Sound = extern struct { + stream: AudioStream, // Audio stream + frameCount: c_uint, // Total number of frames (considering channels) + + pub fn init(stream: AudioStream, frameCount: c_uint) Sound { + return Sound{ .stream = stream, .frameCount = frameCount }; + } +}; + +/// Music, audio stream, anything longer than ~10 seconds should be streamed +pub const Music = extern struct { + stream: AudioStream, // Audio stream + frameCount: c_uint, // Total number of frames (considering channels) + looping: bool, // Music looping enable + + ctxType: c_int, // Type of music context (audio filetype) + ctxData: *anyopaque, // Audio context data, depends on type + + pub fn init(stream: AudioStream, frameCount: c_uint, looping: bool, ctxType: c_int, ctxData: *anyopaque) Music { + return Music{ .stream = stream, .frameCount = frameCount, .looping = looping, .ctxType = ctxType, .ctxData = ctxData }; + } +}; + +/// VrDeviceInfo, Head-Mounted-Display device parameters +pub const VrDeviceInfo = extern struct { + hResolution: c_int, // Horizontal resolution in pixels + vResolution: c_int, // Vertical resolution in pixels + hScreenSize: f32, // Horizontal size in meters + vScreenSize: f32, // Vertical size in meters + eyeToScreenDistance: f32, // Distance between eye and display in meters + lensSeparationDistance: f32, // Lens separation distance in meters + interpupillaryDistance: f32, // IPD (distance between pupils) in meters + lensDistortionValues: [4]f32, // Lens distortion constant parameters + chromaAbCorrection: [4]f32, // Chromatic aberration correction parameters + + pub fn init(hResolution: c_int, vResolution: c_int, hScreenSize: f32, vScreenSize: f32, eyeToScreenDistance: f32, lensSeparationDistance: f32, interpupillaryDistance: f32, lensDistortionValues: [4]f32, chromaAbCorrection: [4]f32) VrDeviceInfo { + return VrDeviceInfo{ .hResolution = hResolution, .vResolution = vResolution, .hScreenSize = hScreenSize, .vScreenSize = vScreenSize, .eyeToScreenDistance = eyeToScreenDistance, .lensSeparationDistance = lensSeparationDistance, .interpupillaryDistance = interpupillaryDistance, .lensDistortionValues = lensDistortionValues, .chromaAbCorrection = chromaAbCorrection }; + } +}; + +/// VrStereoConfig, VR stereo rendering configuration for simulator +pub const VrStereoConfig = extern struct { + projection: [2]Matrix, // VR projection matrices (per eye) + viewOffset: [2]Matrix, // VR view offset matrices (per eye) + leftLensCenter: [2]f32, // VR left lens center + rightLensCenter: [2]f32, // VR right lens center + leftScreenCenter: [2]f32, // VR left screen center + rightScreenCenter: [2]f32, // VR right screen center + scale: [2]f32, // VR distortion scale + scaleIn: [2]f32, // VR distortion scale in + + pub fn init(projection: [2]Matrix, viewOffset: [2]Matrix, leftLensCenter: [2]f32, rightLensCenter: [2]f32, leftScreenCenter: [2]f32, rightScreenCenter: [2]f32, scale: [2]f32, scaleIn: [2]f32) VrStereoConfig { + return VrStereoConfig{ .projection = projection, .viewOffset = viewOffset, .leftLensCenter = leftLensCenter, .rightLensCenter = rightLensCenter, .leftScreenCenter = leftScreenCenter, .rightScreenCenter = rightScreenCenter, .scale = scale, .scaleIn = scaleIn }; + } +}; + +/// File path list +pub const FilePathList = extern struct { + capacity: c_uint, // Filepaths max entries + count: c_uint, // Filepaths entries count + paths: [*c][*c]u8, // Filepaths entries + + pub fn init(capacity: c_uint, count: c_uint, paths: [*c][*c]u8) FilePathList { + return FilePathList{ .capacity = capacity, .count = count, .paths = paths }; + } +}; + +/// Automation event +pub const AutomationEvent = extern struct { + frame: c_uint, // Event frame + type: c_uint, // Event type (AutomationEventType) + params: [4]c_int, // Event parameters (if required) + + pub fn init(frame: c_uint, type_: c_uint, params: [4]c_int) AutomationEvent { + return AutomationEvent{ .frame = frame, .type = type_, .params = params }; + } +}; + +/// Automation event list +pub const AutomationEventList = extern struct { + capacity: c_uint, // Events max entries (MAX_AUTOMATION_EVENTS) + count: c_uint, // Events entries count + events: [*c]AutomationEvent, // Events entries + + pub fn init(capacity: c_uint, count: c_uint, events: [*c]AutomationEvent) AutomationEventList { + return AutomationEventList{ .capacity = capacity, .count = count, .events = events }; + } +}; + +//---------------------------------------------------------------------------------- +// Enumerators Definition +//---------------------------------------------------------------------------------- + +// System/Window config flags +// NOTE: Every bit registers one state (use it with bit masks) +// By default all flags are set to 0 +pub const ConfigFlags = enum(c_int) { + FLAG_VSYNC_HINT = 0x00000040, // Set to try enabling V-Sync on GPU + FLAG_FULLSCREEN_MODE = 0x00000002, // Set to run program in fullscreen + FLAG_WINDOW_RESIZABLE = 0x00000004, // Set to allow resizable window + FLAG_WINDOW_UNDECORATED = 0x00000008, // Set to disable window decoration (frame and buttons) + FLAG_WINDOW_HIDDEN = 0x00000080, // Set to hide window + FLAG_WINDOW_MINIMIZED = 0x00000200, // Set to minimize window (iconify) + FLAG_WINDOW_MAXIMIZED = 0x00000400, // Set to maximize window (expanded to monitor) + FLAG_WINDOW_UNFOCUSED = 0x00000800, // Set to window non focused + FLAG_WINDOW_TOPMOST = 0x00001000, // Set to window always on top + FLAG_WINDOW_ALWAYS_RUN = 0x00000100, // Set to allow windows running while minimized + FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer + FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI + FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000, // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED + FLAG_BORDERLESS_WINDOWED_MODE = 0x00008000, // Set to run program in borderless windowed mode + FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X + FLAG_INTERLACED_HINT = 0x00010000, // Set to try enabling interlaced video format (for V3D) + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; +// Trace log level +// NOTE: Organized by priority level +pub const TraceLogLevel = enum(c_int) { + LOG_ALL = 0, // Display all logs + LOG_TRACE, // Trace logging, intended for internal use only + LOG_DEBUG, // Debug logging, used for internal debugging, it should be disabled on release builds + LOG_INFO, // Info logging, used for program execution info + LOG_WARNING, // Warning logging, used on recoverable failures + LOG_ERROR, // Error logging, used on unrecoverable failures + LOG_FATAL, // Fatal logging, used to abort program: exit(EXIT_FAILURE) + LOG_NONE, // Disable logging + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Keyboard keys (US keyboard layout) +// NOTE: Use GetKeyPressed() to allow redefining +// required keys for alternative layouts +pub const KeyboardKey = enum(c_int) { + KEY_NULL = 0, // Key: NULL, used for no key pressed + // Alphanumeric keys + KEY_APOSTROPHE = 39, // Key: ' + KEY_COMMA = 44, // Key: , + KEY_MINUS = 45, // Key: - + KEY_PERIOD = 46, // Key: . + KEY_SLASH = 47, // Key: / + KEY_ZERO = 48, // Key: 0 + KEY_ONE = 49, // Key: 1 + KEY_TWO = 50, // Key: 2 + KEY_THREE = 51, // Key: 3 + KEY_FOUR = 52, // Key: 4 + KEY_FIVE = 53, // Key: 5 + KEY_SIX = 54, // Key: 6 + KEY_SEVEN = 55, // Key: 7 + KEY_EIGHT = 56, // Key: 8 + KEY_NINE = 57, // Key: 9 + KEY_SEMICOLON = 59, // Key: ; + KEY_EQUAL = 61, // Key: = + KEY_A = 65, // Key: A | a + KEY_B = 66, // Key: B | b + KEY_C = 67, // Key: C | c + KEY_D = 68, // Key: D | d + KEY_E = 69, // Key: E | e + KEY_F = 70, // Key: F | f + KEY_G = 71, // Key: G | g + KEY_H = 72, // Key: H | h + KEY_I = 73, // Key: I | i + KEY_J = 74, // Key: J | j + KEY_K = 75, // Key: K | k + KEY_L = 76, // Key: L | l + KEY_M = 77, // Key: M | m + KEY_N = 78, // Key: N | n + KEY_O = 79, // Key: O | o + KEY_P = 80, // Key: P | p + KEY_Q = 81, // Key: Q | q + KEY_R = 82, // Key: R | r + KEY_S = 83, // Key: S | s + KEY_T = 84, // Key: T | t + KEY_U = 85, // Key: U | u + KEY_V = 86, // Key: V | v + KEY_W = 87, // Key: W | w + KEY_X = 88, // Key: X | x + KEY_Y = 89, // Key: Y | y + KEY_Z = 90, // Key: Z | z + KEY_LEFT_BRACKET = 91, // Key: [ + KEY_BACKSLASH = 92, // Key: '\' + KEY_RIGHT_BRACKET = 93, // Key: ] + KEY_GRAVE = 96, // Key: ` + // Function keys + KEY_SPACE = 32, // Key: Space + KEY_ESCAPE = 256, // Key: Esc + KEY_ENTER = 257, // Key: Enter + KEY_TAB = 258, // Key: Tab + KEY_BACKSPACE = 259, // Key: Backspace + KEY_INSERT = 260, // Key: Ins + KEY_DELETE = 261, // Key: Del + KEY_RIGHT = 262, // Key: Cursor right + KEY_LEFT = 263, // Key: Cursor left + KEY_DOWN = 264, // Key: Cursor down + KEY_UP = 265, // Key: Cursor up + KEY_PAGE_UP = 266, // Key: Page up + KEY_PAGE_DOWN = 267, // Key: Page down + KEY_HOME = 268, // Key: Home + KEY_END = 269, // Key: End + KEY_CAPS_LOCK = 280, // Key: Caps lock + KEY_SCROLL_LOCK = 281, // Key: Scroll down + KEY_NUM_LOCK = 282, // Key: Num lock + KEY_PRINT_SCREEN = 283, // Key: Print screen + KEY_PAUSE = 284, // Key: Pause + KEY_F1 = 290, // Key: F1 + KEY_F2 = 291, // Key: F2 + KEY_F3 = 292, // Key: F3 + KEY_F4 = 293, // Key: F4 + KEY_F5 = 294, // Key: F5 + KEY_F6 = 295, // Key: F6 + KEY_F7 = 296, // Key: F7 + KEY_F8 = 297, // Key: F8 + KEY_F9 = 298, // Key: F9 + KEY_F10 = 299, // Key: F10 + KEY_F11 = 300, // Key: F11 + KEY_F12 = 301, // Key: F12 + KEY_LEFT_SHIFT = 340, // Key: Shift left + KEY_LEFT_CONTROL = 341, // Key: Control left + KEY_LEFT_ALT = 342, // Key: Alt left + KEY_LEFT_SUPER = 343, // Key: Super left + KEY_RIGHT_SHIFT = 344, // Key: Shift right + KEY_RIGHT_CONTROL = 345, // Key: Control right + KEY_RIGHT_ALT = 346, // Key: Alt right + KEY_RIGHT_SUPER = 347, // Key: Super right + KEY_KB_MENU = 348, // Key: KB menu + // Keypad keys + KEY_KP_0 = 320, // Key: Keypad 0 + KEY_KP_1 = 321, // Key: Keypad 1 + KEY_KP_2 = 322, // Key: Keypad 2 + KEY_KP_3 = 323, // Key: Keypad 3 + KEY_KP_4 = 324, // Key: Keypad 4 + KEY_KP_5 = 325, // Key: Keypad 5 + KEY_KP_6 = 326, // Key: Keypad 6 + KEY_KP_7 = 327, // Key: Keypad 7 + KEY_KP_8 = 328, // Key: Keypad 8 + KEY_KP_9 = 329, // Key: Keypad 9 + KEY_KP_DECIMAL = 330, // Key: Keypad . + KEY_KP_DIVIDE = 331, // Key: Keypad / + KEY_KP_MULTIPLY = 332, // Key: Keypad * + KEY_KP_SUBTRACT = 333, // Key: Keypad - + KEY_KP_ADD = 334, // Key: Keypad + + KEY_KP_ENTER = 335, // Key: Keypad Enter + KEY_KP_EQUAL = 336, // Key: Keypad = + // Android key buttons + KEY_BACK = 4, // Key: Android back button + KEY_MENU = 5, // Key: Android menu button + KEY_VOLUME_UP = 24, // Key: Android volume up button + KEY_VOLUME_DOWN = 25, // Key: Android volume down button + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Mouse buttons +pub const MouseButton = enum(c_int) { + MOUSE_BUTTON_LEFT = 0, // Mouse button left + MOUSE_BUTTON_RIGHT = 1, // Mouse button right + MOUSE_BUTTON_MIDDLE = 2, // Mouse button middle (pressed wheel) + MOUSE_BUTTON_SIDE = 3, // Mouse button side (advanced mouse device) + MOUSE_BUTTON_EXTRA = 4, // Mouse button extra (advanced mouse device) + MOUSE_BUTTON_FORWARD = 5, // Mouse button forward (advanced mouse device) + MOUSE_BUTTON_BACK = 6, // Mouse button back (advanced mouse device) + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Add backwards compatibility support for deprecated names +pub const MOUSE_LEFT_BUTTON = MouseButton.MOUSE_BUTTON_LEFT; +pub const MOUSE_RIGHT_BUTTON = MouseButton.MOUSE_BUTTON_RIGHT; +pub const MOUSE_MIDDLE_BUTTON = MouseButton.MOUSE_BUTTON_MIDDLE; + +// Mouse cursor +pub const MouseCursor = enum(c_int) { + MOUSE_CURSOR_DEFAULT = 0, // Default pointer shape + MOUSE_CURSOR_ARROW = 1, // Arrow shape + MOUSE_CURSOR_IBEAM = 2, // Text writing cursor shape + MOUSE_CURSOR_CROSSHAIR = 3, // Cross shape + MOUSE_CURSOR_POINTING_HAND = 4, // Pointing hand cursor + MOUSE_CURSOR_RESIZE_EW = 5, // Horizontal resize/move arrow shape + MOUSE_CURSOR_RESIZE_NS = 6, // Vertical resize/move arrow shape + MOUSE_CURSOR_RESIZE_NWSE = 7, // Top-left to bottom-right diagonal resize/move arrow shape + MOUSE_CURSOR_RESIZE_NESW = 8, // The top-right to bottom-left diagonal resize/move arrow shape + MOUSE_CURSOR_RESIZE_ALL = 9, // The omnidirectional resize/move cursor shape + MOUSE_CURSOR_NOT_ALLOWED = 10, // The operation-not-allowed shape + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Gamepad buttons +pub const GamepadButton = enum(c_int) { + GAMEPAD_BUTTON_UNKNOWN = 0, // Unknown button, just 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 + GAMEPAD_BUTTON_LEFT_FACE_LEFT, // Gamepad left DPAD left button + GAMEPAD_BUTTON_RIGHT_FACE_UP, // Gamepad right button up (i.e. PS3: Triangle, Xbox: Y) + GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, // Gamepad right button right (i.e. PS3: Circle, Xbox: B) + GAMEPAD_BUTTON_RIGHT_FACE_DOWN, // Gamepad right button down (i.e. PS3: Cross, Xbox: A) + GAMEPAD_BUTTON_RIGHT_FACE_LEFT, // Gamepad right button left (i.e. PS3: Square, Xbox: X) + GAMEPAD_BUTTON_LEFT_TRIGGER_1, // Gamepad top/back trigger left (first), it could be a trailing button + GAMEPAD_BUTTON_LEFT_TRIGGER_2, // Gamepad top/back trigger left (second), it could be a trailing button + GAMEPAD_BUTTON_RIGHT_TRIGGER_1, // Gamepad top/back trigger right (first), it could be a trailing button + GAMEPAD_BUTTON_RIGHT_TRIGGER_2, // Gamepad top/back trigger right (second), it could be a trailing button + GAMEPAD_BUTTON_MIDDLE_LEFT, // Gamepad center buttons, left one (i.e. PS3: Select) + GAMEPAD_BUTTON_MIDDLE, // Gamepad center buttons, middle one (i.e. PS3: PS, Xbox: XBOX) + GAMEPAD_BUTTON_MIDDLE_RIGHT, // Gamepad center buttons, right one (i.e. PS3: Start) + GAMEPAD_BUTTON_LEFT_THUMB, // Gamepad joystick pressed button left + GAMEPAD_BUTTON_RIGHT_THUMB, // Gamepad joystick pressed button right + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Gamepad axis +pub const GamepadAxis = enum(c_int) { + GAMEPAD_AXIS_LEFT_X = 0, // Gamepad left stick X axis + GAMEPAD_AXIS_LEFT_Y = 1, // Gamepad left stick Y axis + GAMEPAD_AXIS_RIGHT_X = 2, // Gamepad right stick X axis + GAMEPAD_AXIS_RIGHT_Y = 3, // Gamepad right stick Y axis + GAMEPAD_AXIS_LEFT_TRIGGER = 4, // Gamepad back trigger left, pressure level: [1..-1] + GAMEPAD_AXIS_RIGHT_TRIGGER = 5, // Gamepad back trigger right, pressure level: [1..-1] + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Material map index +pub const MaterialMapIndex = enum(c_int) { + MATERIAL_MAP_ALBEDO = 0, // Albedo material (same as: MATERIAL_MAP_DIFFUSE) + MATERIAL_MAP_METALNESS, // Metalness material (same as: MATERIAL_MAP_SPECULAR) + MATERIAL_MAP_NORMAL, // Normal material + MATERIAL_MAP_ROUGHNESS, // Roughness material + MATERIAL_MAP_OCCLUSION, // Ambient occlusion material + MATERIAL_MAP_EMISSION, // Emission material + MATERIAL_MAP_HEIGHT, // Heightmap material + MATERIAL_MAP_CUBEMAP, // Cubemap material (NOTE: Uses GL_TEXTURE_CUBE_MAP) + MATERIAL_MAP_IRRADIANCE, // Irradiance material (NOTE: Uses GL_TEXTURE_CUBE_MAP) + MATERIAL_MAP_PREFILTER, // Prefilter material (NOTE: Uses GL_TEXTURE_CUBE_MAP) + MATERIAL_MAP_BRDF, // Brdf material + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +pub const MATERIAL_MAP_DIFFUSE = MaterialMapIndex.MATERIAL_MAP_ALBEDO; +pub const MATERIAL_MAP_SPECULAR = MaterialMapIndex.MATERIAL_MAP_METALNESS; + +// Shader location index +pub const ShaderLocationIndex = enum(c_int) { + SHADER_LOC_VERTEX_POSITION = 0, // Shader location: vertex attribute: position + SHADER_LOC_VERTEX_TEXCOORD01, // Shader location: vertex attribute: texcoord01 + SHADER_LOC_VERTEX_TEXCOORD02, // Shader location: vertex attribute: texcoord02 + SHADER_LOC_VERTEX_NORMAL, // Shader location: vertex attribute: normal + SHADER_LOC_VERTEX_TANGENT, // Shader location: vertex attribute: tangent + SHADER_LOC_VERTEX_COLOR, // Shader location: vertex attribute: color + SHADER_LOC_MATRIX_MVP, // Shader location: matrix uniform: model-view-projection + SHADER_LOC_MATRIX_VIEW, // Shader location: matrix uniform: view (camera transform) + SHADER_LOC_MATRIX_PROJECTION, // Shader location: matrix uniform: projection + SHADER_LOC_MATRIX_MODEL, // Shader location: matrix uniform: model (transform) + SHADER_LOC_MATRIX_NORMAL, // Shader location: matrix uniform: normal + SHADER_LOC_VECTOR_VIEW, // Shader location: vector uniform: view + SHADER_LOC_COLOR_DIFFUSE, // Shader location: vector uniform: diffuse color + SHADER_LOC_COLOR_SPECULAR, // Shader location: vector uniform: specular color + SHADER_LOC_COLOR_AMBIENT, // Shader location: vector uniform: ambient color + SHADER_LOC_MAP_ALBEDO, // Shader location: sampler2d texture: albedo (same as: SHADER_LOC_MAP_DIFFUSE) + SHADER_LOC_MAP_METALNESS, // Shader location: sampler2d texture: metalness (same as: SHADER_LOC_MAP_SPECULAR) + SHADER_LOC_MAP_NORMAL, // Shader location: sampler2d texture: normal + 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_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 + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +pub const SHADER_LOC_MAP_DIFFUSE = ShaderLocationIndex.SHADER_LOC_MAP_ALBEDO; +pub const SHADER_LOC_MAP_SPECULAR = ShaderLocationIndex.SHADER_LOC_MAP_METALNESS; + +// Shader uniform data type +pub const ShaderUniformDataType = enum(c_int) { + SHADER_UNIFORM_FLOAT = 0, // Shader uniform type: float + SHADER_UNIFORM_VEC2, // Shader uniform type: vec2 (2 float) + SHADER_UNIFORM_VEC3, // Shader uniform type: vec3 (3 float) + SHADER_UNIFORM_VEC4, // Shader uniform type: vec4 (4 float) + SHADER_UNIFORM_INT, // Shader uniform type: int + SHADER_UNIFORM_IVEC2, // Shader uniform type: ivec2 (2 int) + SHADER_UNIFORM_IVEC3, // Shader uniform type: ivec3 (3 int) + SHADER_UNIFORM_IVEC4, // Shader uniform type: ivec4 (4 int) + SHADER_UNIFORM_SAMPLER2D, // Shader uniform type: sampler2d + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Shader attribute data types +pub const ShaderAttributeDataType = enum(c_int) { + SHADER_ATTRIB_FLOAT = 0, // Shader attribute type: float + SHADER_ATTRIB_VEC2, // Shader attribute type: vec2 (2 float) + SHADER_ATTRIB_VEC3, // Shader attribute type: vec3 (3 float) + SHADER_ATTRIB_VEC4, // Shader attribute type: vec4 (4 float) + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Pixel formats +// NOTE: Support depends on OpenGL version and platform +pub const PixelFormat = enum(c_int) { + PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha) + PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels) + PIXELFORMAT_UNCOMPRESSED_R5G6B5, // 16 bpp + PIXELFORMAT_UNCOMPRESSED_R8G8B8, // 24 bpp + PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha) + PIXELFORMAT_UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha) + PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, // 32 bpp + PIXELFORMAT_UNCOMPRESSED_R32, // 32 bpp (1 channel - float) + PIXELFORMAT_UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float) + PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float) + PIXELFORMAT_UNCOMPRESSED_R16, // 16 bpp (1 channel - half float) + PIXELFORMAT_UNCOMPRESSED_R16G16B16, // 16*3 bpp (3 channels - half float) + PIXELFORMAT_UNCOMPRESSED_R16G16B16A16, // 16*4 bpp (4 channels - half float) + PIXELFORMAT_COMPRESSED_DXT1_RGB, // 4 bpp (no alpha) + PIXELFORMAT_COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha) + PIXELFORMAT_COMPRESSED_DXT3_RGBA, // 8 bpp + PIXELFORMAT_COMPRESSED_DXT5_RGBA, // 8 bpp + PIXELFORMAT_COMPRESSED_ETC1_RGB, // 4 bpp + PIXELFORMAT_COMPRESSED_ETC2_RGB, // 4 bpp + PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA, // 8 bpp + PIXELFORMAT_COMPRESSED_PVRT_RGB, // 4 bpp + PIXELFORMAT_COMPRESSED_PVRT_RGBA, // 4 bpp + PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA, // 8 bpp + PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA, // 2 bpp + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Texture parameters: filter mode +// NOTE 1: Filtering considers mipmaps if available in the texture +// NOTE 2: Filter is accordingly set for minification and magnification +pub const TextureFilter = enum(c_int) { + TEXTURE_FILTER_POINT = 0, // No filter, just pixel approximation + TEXTURE_FILTER_BILINEAR, // Linear filtering + TEXTURE_FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps) + TEXTURE_FILTER_ANISOTROPIC_4X, // Anisotropic filtering 4x + TEXTURE_FILTER_ANISOTROPIC_8X, // Anisotropic filtering 8x + TEXTURE_FILTER_ANISOTROPIC_16X, // Anisotropic filtering 16x + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Texture parameters: wrap mode +pub const TextureWrap = enum(c_int) { + TEXTURE_WRAP_REPEAT = 0, // Repeats texture in tiled mode + TEXTURE_WRAP_CLAMP, // Clamps texture to edge pixel in tiled mode + TEXTURE_WRAP_MIRROR_REPEAT, // Mirrors and repeats the texture in tiled mode + TEXTURE_WRAP_MIRROR_CLAMP, // Mirrors and clamps to border the texture in tiled mode + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Cubemap layouts +pub const CubemapLayout = enum(c_int) { + CUBEMAP_LAYOUT_AUTO_DETECT = 0, // Automatically detect layout type + CUBEMAP_LAYOUT_LINE_VERTICAL, // Layout is defined by a vertical line with faces + CUBEMAP_LAYOUT_LINE_HORIZONTAL, // Layout is defined by a horizontal line with faces + CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces + CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces + CUBEMAP_LAYOUT_PANORAMA, // Layout is defined by a panorama image (equirrectangular map) + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Font type, defines generation method +pub const FontType = enum(c_int) { + FONT_DEFAULT = 0, // Default font generation, anti-aliased + FONT_BITMAP, // Bitmap font generation, no anti-aliasing + FONT_SDF, // SDF font generation, requires external shader + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Color blending modes (pre-defined) +pub const BlendMode = enum(c_int) { + BLEND_ALPHA = 0, // Blend textures considering alpha (default) + BLEND_ADDITIVE, // Blend textures adding colors + BLEND_MULTIPLIED, // Blend textures multiplying colors + BLEND_ADD_COLORS, // Blend textures adding colors (alternative) + BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative) + BLEND_ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha + BLEND_CUSTOM, // Blend textures using custom src/dst factors (use rlSetBlendFactors()) + BLEND_CUSTOM_SEPARATE, // Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate()) + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Gesture +// NOTE: Provided as bit-wise flags to enable only desired gestures +pub const Gesture = enum(c_int) { + GESTURE_NONE = 0, // No gesture + GESTURE_TAP = 1, // Tap gesture + GESTURE_DOUBLETAP = 2, // Double tap gesture + GESTURE_HOLD = 4, // Hold gesture + GESTURE_DRAG = 8, // Drag gesture + GESTURE_SWIPE_RIGHT = 16, // Swipe right gesture + GESTURE_SWIPE_LEFT = 32, // Swipe left gesture + GESTURE_SWIPE_UP = 64, // Swipe up gesture + GESTURE_SWIPE_DOWN = 128, // Swipe down gesture + GESTURE_PINCH_IN = 256, // Pinch in gesture + GESTURE_PINCH_OUT = 512, // Pinch out gesture + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Camera system modes +pub const CameraMode = enum(c_int) { + CAMERA_CUSTOM = 0, // Camera custom, controlled by user (UpdateCamera() does nothing) + CAMERA_FREE, // Camera free mode + CAMERA_ORBITAL, // Camera orbital, around target, zoom supported + CAMERA_FIRST_PERSON, // Camera first person + CAMERA_THIRD_PERSON, // Camera third person + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Camera projection +pub const CameraProjection = enum(c_int) { + CAMERA_PERSPECTIVE = 0, // Perspective projection + CAMERA_ORTHOGRAPHIC, // Orthographic projection + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// N-patch layout +pub const NPatchLayout = enum(c_int) { + NPATCH_NINE_PATCH = 0, // Npatch layout: 3x3 tiles + NPATCH_THREE_PATCH_VERTICAL, // Npatch layout: 1x3 tiles + NPATCH_THREE_PATCH_HORIZONTAL, // Npatch layout: 3x1 tiles + + pub fn fromCInt(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toCInt(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Callbacks to hook some internal functions +// WARNING: These callbacks are intended for advance users +pub const TraceLogCallback = *const fn (loglevel: c_int, text: [*c]const u8, args: *anyopaque) callconv(.C) void; // Logging: Redirect trace log messages +pub const LoadFileDataCallback = *const fn (fileName: [*c]const u8, dataSize: [*c]c_int) callconv(.C) [*c]u8; // FileIO: Save binary data +pub const SaveFileDataCallback = *const fn (fileName: [*c]const u8, data: *anyopaque, dataSize: c_int) callconv(.C) bool; // FileIO: Load text data +pub const LoadFileTextCallback = *const fn (fileName: [*c]const u8) callconv(.C) [*c]u8; // FileIO: Load text data +pub const SaveFileTextCallback = *const fn (fileName: [*c]const u8, text: [*c]u8) callconv(.C) bool; // FileIO: Save text data + +//------------------------------------------------------------------------------------ +// Window and Graphics Device Functions (Module: core) +//------------------------------------------------------------------------------------ + +// Window-related functions +pub extern "c" fn InitWindow(width: c_int, height: c_int, title: [*c]const u8) void; // Initialize window and OpenGL context +pub extern "c" fn CloseWindow() void; // Close window and unload OpenGL context +pub extern "c" fn WindowShouldClose() bool; // Check if application should close (KEY_ESCAPE pressed or windows close icon clicked) +pub extern "c" fn IsWindowReady() bool; // Check if window has been initialized successfully +pub extern "c" fn IsWindowFullscreen() bool; // Check if window is currently fullscreen +pub extern "c" fn IsWindowHidden() bool; // Check if window is currently hidden (only PLATFORM_DESKTOP) +pub extern "c" fn IsWindowMinimized() bool; // Check if window is currently minimized (only PLATFORM_DESKTOP) +pub extern "c" fn IsWindowMaximized() bool; // Check if window is currently maximized (only PLATFORM_DESKTOP) +pub extern "c" fn IsWindowFocused() bool; // Check if window is currently focused (only PLATFORM_DESKTOP) +pub extern "c" fn IsWindowResized() bool; // Check if window has been resized last frame +pub extern "c" fn IsWindowState(flag: c_uint) bool; // Check if one specific window flag is enabled +pub extern "c" fn SetWindowState(flags: c_uint) void; // Set window configuration state using flags (only PLATFORM_DESKTOP) +pub extern "c" fn ClearWindowState(flags: c_uint) void; // Clear window configuration state flags +pub extern "c" fn ToggleFullscreen() void; // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP) +pub extern "c" fn ToggleBorderlessWindowed() void; // Toggle window state: borderless windowed (only PLATFORM_DESKTOP) +pub extern "c" fn MaximizeWindow() void; // Set window state: maximized, if resizable (only PLATFORM_DESKTOP) +pub extern "c" fn MinimizeWindow() void; // Set window state: minimized, if resizable (only PLATFORM_DESKTOP) +pub extern "c" fn RestoreWindow() void; // Set window state: not minimized/maximized (only PLATFORM_DESKTOP) +pub extern "c" fn SetWindowIcon(image: Image) void; // Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP) +pub extern "c" fn SetWindowIcons(images: [*c]Image, count: c_int) void; // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP) +pub extern "c" fn SetWindowTitle(title: [*c]const u8) void; // Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB) +pub extern "c" fn SetWindowPosition(x: c_int, y: c_int) void; // Set window position on screen (only PLATFORM_DESKTOP) +pub extern "c" fn SetWindowMonitor(monitor: c_int) void; // Set monitor for the current window +pub extern "c" fn SetWindowMinSize(width: c_int, height: c_int) void; // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) +pub extern "c" fn SetWindowMaxSize(width: c_int, height: c_int) void; // Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE) +pub extern "c" fn SetWindowSize(width: c_int, height: c_int) void; // Set window dimensions +pub extern "c" fn SetWindowOpacity(opacity: f32) void; // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP) +pub extern "c" fn SetWindowFocused() void; // Set window focused (only PLATFORM_DESKTOP) +pub extern "c" fn GetWindowHandle() *anyopaque; // Get native window handle +pub extern "c" fn GetScreenWidth() c_int; // Get current screen width +pub extern "c" fn GetScreenHeight() c_int; // Get current screen height +pub extern "c" fn GetRenderWidth() c_int; // Get current render width (it considers HiDPI) +pub extern "c" fn GetRenderHeight() c_int; // Get current render height (it considers HiDPI) +pub extern "c" fn GetMonitorCount() c_int; // Get number of connected monitors +pub extern "c" fn GetCurrentMonitor() c_int; // Get current connected monitor +pub extern "c" fn GetMonitorPosition(monitor: c_int) Vector2; // Get specified monitor position +pub extern "c" fn GetMonitorWidth(monitor: c_int) c_int; // Get specified monitor width (current video mode used by monitor) +pub extern "c" fn GetMonitorHeight(monitor: c_int) c_int; // Get specified monitor height (current video mode used by monitor) +pub extern "c" fn GetMonitorPhysicalWidth(monitor: c_int) c_int; // Get specified monitor physical width in millimetres +pub extern "c" fn GetMonitorPhysicalHeight(monitor: c_int) c_int; // Get specified monitor physical height in millimetres +pub extern "c" fn GetMonitorRefreshRate(monitor: c_int) c_int; // Get specified monitor refresh rate +pub extern "c" fn GetWindowPosition() Vector2; // Get window position XY on monitor +pub extern "c" fn GetWindowScaleDPI() Vector2; // Get window scale DPI factor +pub extern "c" fn GetMonitorName(monitor: c_int) [*c]const u8; // Get the human-readable, UTF-8 encoded name of the specified monitor +pub extern "c" fn SetClipboardText(text: [*c]const u8) void; // Set clipboard text content +pub extern "c" fn GetClipboardText() [*c]const u8; // Get clipboard text content +pub extern "c" fn EnableEventWaiting() void; // Enable waiting for events on EndDrawing(), no automatic event polling +pub extern "c" fn DisableEventWaiting() void; // Disable waiting for events on EndDrawing(), automatic events polling + +// Cursor-related functions +pub extern "c" fn ShowCursor() void; // Shows cursor +pub extern "c" fn HideCursor() void; // Hides cursor +pub extern "c" fn IsCursorHidden() bool; // Check if cursor is not visible +pub extern "c" fn EnableCursor() void; // Enables cursor (unlock cursor) +pub extern "c" fn DisableCursor() void; // Disables cursor (lock cursor) +pub extern "c" fn IsCursorOnScreen() bool; // Check if cursor is on the screen + +// Drawing-related functions +pub extern "c" fn ClearBackground(color: Color) void; // Set background color (framebuffer clear color) +pub extern "c" fn BeginDrawing() void; // Setup canvas (framebuffer) to start drawing +pub extern "c" fn EndDrawing() void; // End canvas drawing and swap buffers (double buffering) +pub extern "c" fn BeginMode2D(camera: Camera2D) void; // Begin 2D mode with custom camera (2D) +pub extern "c" fn EndMode2D() void; // Ends 2D mode with custom camera +pub extern "c" fn BeginMode3D(camera: Camera3D) void; // Begin 3D mode with custom camera (3D) +pub extern "c" fn EndMode3D() void; // Ends 3D mode and returns to default 2D orthographic mode +pub extern "c" fn BeginTextureMode(target: RenderTexture2D) void; // Begin drawing to render texture +pub extern "c" fn EndTextureMode() void; // Ends drawing to render texture +pub extern "c" fn BeginShaderMode(shader: Shader) void; // Begin custom shader drawing +pub extern "c" fn EndShaderMode() void; // End custom shader drawing (use default shader) +pub extern "c" fn BeginBlendMode(mode: c_int) void; // Begin blending mode (alpha, additive, multiplied, subtract, custom) +pub extern "c" fn EndBlendMode() void; // End blending mode (reset to default: alpha blending) +pub extern "c" fn BeginScissorMode(x: c_int, y: c_int, width: c_int, height: c_int) void; // Begin scissor mode (define screen area for following drawing) +pub extern "c" fn EndScissorMode() void; // End scissor mode +pub extern "c" fn BeginVrStereoMode(config: VrStereoConfig) void; // Begin stereo rendering (requires VR simulator) +pub extern "c" fn EndVrStereoMode() void; // End stereo rendering (requires VR simulator) + +// VR stereo config functions for VR simulator +pub extern "c" fn LoadVrStereoConfig(device: VrDeviceInfo) VrStereoConfig; // Load VR stereo config for VR simulator device parameters +pub extern "c" fn UnloadVrStereoConfig(config: VrStereoConfig) void; // Unload VR stereo config + +// Shader management functions +// NOTE: Shader functionality is not available on OpenGL 1.1 +pub extern "c" fn LoadShader(vsFileName: [*c]const u8, fsFileName: [*c]const u8) Shader; // Load shader from files and bind default locations +pub extern "c" fn LoadShaderFromMemory(vsCode: [*c]const u8, fsCode: [*c]const u8) Shader; // Load shader from code strings and bind default locations +pub extern "c" fn IsShaderReady(shader: Shader) bool; // Check if a shader is ready +pub extern "c" fn GetShaderLocation(shader: Shader, uniformName: [*c]const u8) c_int; // Get shader uniform location +pub extern "c" fn GetShaderLocationAttrib(shader: Shader, attribName: [*c]const u8) c_int; // Get shader attribute location +pub extern "c" fn SetShaderValue(shader: Shader, locIndex: c_int, value: *const anyopaque, uniformType: c_int) void; // Set shader uniform value +pub extern "c" fn SetShaderValueV(shader: Shader, locIndex: c_int, value: *const anyopaque, uniformType: c_int, count: c_int) void; // Set shader uniform value vector +pub extern "c" fn SetShaderValueMatrix(shader: Shader, locIndex: c_int, mat: Matrix) void; // Set shader uniform value (matrix 4x4) +pub extern "c" fn SetShaderValueTexture(shader: Shader, locIndex: c_int, texture: Texture2D) void; // Set shader uniform value for texture (sampler2d) +pub extern "c" fn UnloadShader(shader: Shader) void; // Unload shader from GPU memory (VRAM) + +// Screen-space-related functions +pub extern "c" fn GetMouseRay(mousePosition: Vector2, camera: Camera) Ray; // Get a ray trace from mouse position +pub extern "c" fn GetCameraMatrix(camera: Camera) Matrix; // Get camera transform matrix (view matrix) +pub extern "c" fn GetCameraMatrix2D(camera: Camera2D) Matrix; // Get camera 2d transform matrix +pub extern "c" fn GetWorldToScreen(position: Vector3, camera: Camera) Vector2; // Get the screen space position for a 3d world space position +pub extern "c" fn GetScreenToWorld2D(position: Vector2, camera: Camera2D) Vector2; // Get the world space position for a 2d camera screen space position +pub extern "c" fn GetWorldToScreenEx(position: Vector3, camera: Camera, width: c_int, height: c_int) Vector2; // Get size position for a 3d world space position +pub extern "c" fn GetWorldToScreen2D(position: Vector2, camera: Camera2D) Vector2; // Get the screen space position for a 2d camera world space position + +// Timing-related functions +pub extern "c" fn SetTargetFPS(fps: c_int) void; // Set target FPS (maximum) +pub extern "c" fn GetFrameTime() f32; // Get time in seconds for last frame drawn (delta time) +pub extern "c" fn GetTime() f64; // Get elapsed time in seconds since InitWindow() +pub extern "c" fn GetFPS() c_int; // Get current FPS + +// Custom frame control functions +// NOTE: Those functions are intended for advance users that want full control over the frame processing +// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents() +// To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL +pub extern "c" fn SwapScreenBuffer() void; // Swap back buffer with front buffer (screen drawing) +pub extern "c" fn PollInputEvents() void; // Register all input events +pub extern "c" fn WaitTime(seconds: f64) void; // Wait for some time (halt program execution) + +// Random values generation functions +pub extern "c" fn SetRandomSeed(seed: c_uint) void; // Set the seed for the random number generator +pub extern "c" fn GetRandomValue(min: c_int, max: c_int) c_int; // Get a random value between min and max (both included) +pub extern "c" fn LoadRandomSequence(count: c_uint, min: c_int, max: c_int) [*c]c_int; // Load random values sequence, no values repeated +pub extern "c" fn UnloadRandomSequence(sequence: [*c]c_int) void; // Unload random values sequence + +// Misc. functions +pub extern "c" fn TakeScreenshot(fileName: [*c]const u8) void; // Takes a screenshot of current screen (filename extension defines format) +pub extern "c" fn SetConfigFlags(flags: c_uint) void; // Setup init configuration flags (view FLAGS) +pub extern "c" fn OpenURL(url: [*c]const u8) void; // Open URL with default system browser (if available) + +// NOTE: Following functions implemented in module [utils] +//------------------------------------------------------------------ +pub extern "c" fn TraceLog(logLevel: c_int, text: [*c]const u8, ...) void; // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) +pub extern "c" fn SetTraceLogLevel(logLevel: c_int) void; // Set the current threshold (minimum) log level +pub extern "c" fn MemAlloc(size: c_uint) *anyopaque; // Internal memory allocator +pub extern "c" fn MemRealloc(ptr: *anyopaque, size: c_uint) *anyopaque; // Internal memory reallocator +pub extern "c" fn MemFree(ptr: *anyopaque) void; // Internal memory free + +// Set custom callbacks +// WARNING: Callbacks setup is intended for advance users +pub extern "c" fn SetTraceLogCallback(callback: TraceLogCallback) void; // Set custom trace log +pub extern "c" fn SetLoadFileDataCallback(callback: LoadFileDataCallback) void; // Set custom file binary data loader +pub extern "c" fn SetSaveFileDataCallback(callback: SaveFileDataCallback) void; // Set custom file binary data saver +pub extern "c" fn SetLoadFileTextCallback(callback: LoadFileTextCallback) void; // Set custom file text data loader +pub extern "c" fn SetSaveFileTextCallback(callback: SaveFileTextCallback) void; // Set custom file text data saver + +// Files management functions +pub extern "c" fn LoadFileData(fileName: [*c]const u8, dataSize: [*c]c_int) [*c]u8; // Load file data as byte array (read) +pub extern "c" fn UnloadFileData(data: [*c]u8) void; // Unload file data allocated by LoadFileData() +pub extern "c" fn SaveFileData(fileName: [*c]const u8, data: *anyopaque, dataSize: c_int) bool; // Save data to file from byte array (write), returns true on success +pub extern "c" fn ExportDataAsCode(data: [*c]const u8, dataSize: c_int, fileName: [*c]const u8) bool; // Export data to code (.h), returns true on success +pub extern "c" fn LoadFileText(fileName: [*c]const u8) [*c]u8; // Load text data from file (read), returns a '\0' terminated string +pub extern "c" fn UnloadFileText(text: [*c]u8) void; // Unload file text data allocated by LoadFileText() +pub extern "c" fn SaveFileText(fileName: [*c]const u8, text: [*c]u8) bool; // Save text data to file (write), string must be '\0' terminated, returns true on success +//------------------------------------------------------------------ + +// File system functions +pub extern "c" fn FileExists(fileName: [*c]const u8) bool; // Check if file exists +pub extern "c" fn DirectoryExists(dirPath: [*c]const u8) bool; // Check if a directory path exists +pub extern "c" fn IsFileExtension(fileName: [*c]const u8, ext: [*c]const u8) bool; // Check file extension (including point: .png, .wav) +pub extern "c" fn GetFileLength(fileName: [*c]const u8) c_int; // Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h) +pub extern "c" fn GetFileExtension(fileName: [*c]const u8) [*c]const u8; // Get pointer to extension for a filename string (includes dot: '.png') +pub extern "c" fn GetFileName(filePath: [*c]const u8) [*c]const u8; // Get pointer to filename for a path string +pub extern "c" fn GetFileNameWithoutExt(filePath: [*c]const u8) [*c]const u8; // Get filename string without extension (uses static string) +pub extern "c" fn GetDirectoryPath(filePath: [*c]const u8) [*c]const u8; // Get full path for a given fileName with path (uses static string) +pub extern "c" fn GetPrevDirectoryPath(dirPath: [*c]const u8) [*c]const u8; // Get previous directory path for a given path (uses static string) +pub extern "c" fn GetWorkingDirectory() [*c]const u8; // Get current working directory (uses static string) +pub extern "c" fn GetApplicationDirectory() [*c]const u8; // Get the directory of the running application (uses static string) +pub extern "c" fn ChangeDirectory(dir: [*c]const u8) bool; // Change working directory, return true on success +pub extern "c" fn IsPathFile(path: [*c]const u8) bool; // Check if a given path is a file or a directory +pub extern "c" fn LoadDirectoryFiles(dirPath: [*c]const u8) FilePathList; // Load directory filepaths +pub extern "c" fn LoadDirectoryFilesEx(basePath: [*c]const u8, filter: [*c]const u8, scanSubdirs: bool) FilePathList; // Load directory filepaths with extension filtering and recursive directory scan +pub extern "c" fn UnloadDirectoryFiles(files: FilePathList) void; // Unload filepaths +pub extern "c" fn IsFileDropped() bool; // Check if a file has been dropped into window +pub extern "c" fn LoadDroppedFiles() FilePathList; // Load dropped filepaths +pub extern "c" fn UnloadDroppedFiles(files: FilePathList) void; // Unload dropped filepaths +pub extern "c" fn GetFileModTime(fileName: [*c]const u8) c_long; // Get file modification time (last write time) + +// Compression/Encoding functionality +pub extern "c" fn CompressData(data: [*c]const u8, dataSize: c_int, compDataSize: [*c]c_int) [*c]u8; // Compress data (DEFLATE algorithm), memory must be MemFree() +pub extern "c" fn DecompressData(compData: [*c]const u8, compDataSize: c_int, dataSize: [*c]c_int) [*c]u8; // Decompress data (DEFLATE algorithm), memory must be MemFree() +pub extern "c" fn EncodeDataBase64(data: [*c]const u8, dataSize: c_int, outputSize: [*c]c_int) [*c]u8; // Encode data to Base64 string, memory must be MemFree() +pub extern "c" fn DecodeDataBase64(data: [*c]const u8, outputSize: [*c]c_int) [*c]u8; // Decode Base64 string data, memory must be MemFree() + +// Automation events functionality +pub extern "c" fn LoadAutomationEventList(fileName: [*c]const u8) AutomationEventList; // Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS +pub extern "c" fn UnloadAutomationEventList(list: AutomationEventList) void; // Unload automation events list from file +pub extern "c" fn ExportAutomationEventList(list: AutomationEventList, fileName: [*c]const u8) bool; // Export automation events list as text file +pub extern "c" fn SetAutomationEventList(list: [*c]AutomationEventList) void; // Set automation event list to record to +pub extern "c" fn SetAutomationEventBaseFrame(frame: c_int) void; // Set automation event internal base frame to start recording +pub extern "c" fn StartAutomationEventRecording() void; // Start recording automation events (AutomationEventList must be set) +pub extern "c" fn StopAutomationEventRecording() void; // Stop recording automation events +pub extern "c" fn PlayAutomationEvent(event: AutomationEvent) void; // Play a recorded automation event + +//------------------------------------------------------------------------------------ +// Input Handling Functions (Module: core) +//------------------------------------------------------------------------------------ + +// Input-related functions: keyboard +pub extern "c" fn IsKeyPressed(key: c_int) bool; // Check if a key has been pressed once +pub extern "c" fn IsKeyPressedRepeat(key: c_int) bool; // Check if a key has been pressed again (Only PLATFORM_DESKTOP) +pub extern "c" fn IsKeyDown(key: c_int) bool; // Check if a key is being pressed +pub extern "c" fn IsKeyReleased(key: c_int) bool; // Check if a key has been released once +pub extern "c" fn IsKeyUp(key: c_int) bool; // Check if a key is NOT being pressed +pub extern "c" fn GetKeyPressed() c_int; // Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty +pub extern "c" fn GetCharPressed() c_int; // Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty +pub extern "c" fn SetExitKey(key: c_int) void; // Set a custom key to exit program (default is ESC) + +// Input-related functions: gamepads +pub extern "c" fn IsGamepadAvailable(gamepad: c_int) bool; // Check if a gamepad is available +pub extern "c" fn GetGamepadName(gamepad: c_int) [*c]const u8; // Get gamepad internal name id +pub extern "c" fn IsGamepadButtonPressed(gamepad: c_int, button: c_int) bool; // Check if a gamepad button has been pressed once +pub extern "c" fn IsGamepadButtonDown(gamepad: c_int, button: c_int) bool; // Check if a gamepad button is being pressed +pub extern "c" fn IsGamepadButtonReleased(gamepad: c_int, button: c_int) bool; // Check if a gamepad button has been released once +pub extern "c" fn IsGamepadButtonUp(gamepad: c_int, button: c_int) bool; // Check if a gamepad button is NOT being pressed +pub extern "c" fn GetGamepadButtonPressed() c_int; // Get the last gamepad button pressed +pub extern "c" fn GetGamepadAxisCount(gamepad: c_int) c_int; // Get gamepad axis count for a gamepad +pub extern "c" fn GetGamepadAxisMovement(gamepad: c_int, axis: c_int) f32; // Get axis movement value for a gamepad axis +pub extern "c" fn SetGamepadMappings(mappings: [*c]const u8) c_int; // Set internal gamepad mappings (SDL_GameControllerDB) + +// Input-related functions: mouse +pub extern "c" fn IsMouseButtonPressed(button: c_int) bool; // Check if a mouse button has been pressed once +pub extern "c" fn IsMouseButtonDown(button: c_int) bool; // Check if a mouse button is being pressed +pub extern "c" fn IsMouseButtonReleased(button: c_int) bool; // Check if a mouse button has been released once +pub extern "c" fn IsMouseButtonUp(button: c_int) bool; // Check if a mouse button is NOT being pressed +pub extern "c" fn GetMouseX() c_int; // Get mouse position X +pub extern "c" fn GetMouseY() c_int; // Get mouse position Y +pub extern "c" fn GetMousePosition() Vector2; // Get mouse position XY +pub extern "c" fn GetMouseDelta() Vector2; // Get mouse delta between frames +pub extern "c" fn SetMousePosition(x: c_int, y: c_int) void; // Set mouse position XY +pub extern "c" fn SetMouseOffset(offsetX: c_int, offsetY: c_int) void; // Set mouse offset +pub extern "c" fn SetMouseScale(scaleX: f32, scaleY: f32) void; // Set mouse scaling +pub extern "c" fn GetMouseWheelMove() f32; // Get mouse wheel movement for X or Y, whichever is larger +pub extern "c" fn GetMouseWheelMoveV() Vector2; // Get mouse wheel movement for both X and Y +pub extern "c" fn SetMouseCursor(cursor: c_int) void; // Set mouse cursor + +// Input-related functions: touch +pub extern "c" fn GetTouchX() c_int; // Get touch position X for touch point 0 (relative to screen size) +pub extern "c" fn GetTouchY() c_int; // Get touch position Y for touch point 0 (relative to screen size) +pub extern "c" fn GetTouchPosition(index: c_int) Vector2; // Get touch position XY for a touch point index (relative to screen size) +pub extern "c" fn GetTouchPointId(index: c_int) c_int; // Get touch point identifier for given index +pub extern "c" fn GetTouchPointCount() c_int; // Get number of touch points + +//------------------------------------------------------------------------------------ +// Gestures and Touch Handling Functions (Module: rgestures) +//------------------------------------------------------------------------------------ +pub extern "c" fn SetGesturesEnabled(flags: c_uint) void; // Enable a set of gestures using flags +pub extern "c" fn IsGestureDetected(gesture: c_uint) bool; // Check if a gesture have been detected +pub extern "c" fn GetGestureDetected() c_int; // Get latest detected gesture +pub extern "c" fn GetGestureHoldDuration() f32; // Get gesture hold time in milliseconds +pub extern "c" fn GetGestureDragVector() Vector2; // Get gesture drag vector +pub extern "c" fn GetGestureDragAngle() f32; // Get gesture drag angle +pub extern "c" fn GetGesturePinchVector() Vector2; // Get gesture pinch delta +pub extern "c" fn GetGesturePinchAngle() f32; // Get gesture pinch angle + +//------------------------------------------------------------------------------------ +// Camera System Functions (Module: rcamera) +//------------------------------------------------------------------------------------ +pub extern "c" fn UpdateCamera(camera: [*c]Camera, mode: c_int) void; // Update camera position for selected mode +pub extern "c" fn UpdateCameraPro(camera: [*c]Camera, movement: Vector3, rotation: Vector3, zoom: f32) void; // Update camera movement/rotation + +//------------------------------------------------------------------------------------ +// Basic Shapes Drawing Functions (Module: shapes) +//------------------------------------------------------------------------------------ +// Set texture and rectangle to be used on shapes drawing +// NOTE: It can be useful when using basic shapes and one single font, +// defining a font char white rectangle would allow drawing everything in a single draw call +pub extern "c" fn SetShapesTexture(texture: Texture2D, source: Rectangle) void; // Set texture and rectangle to be used on shapes drawing + +// Basic shapes drawing functions +pub extern "c" fn DrawPixel(posX: c_int, posY: c_int, color: Color) void; // Draw a pixel +pub extern "c" fn DrawPixelV(position: Vector2, color: Color) void; // Draw a pixel (Vector version) +pub extern "c" fn DrawLine(startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: Color) void; // Draw a line +pub extern "c" fn DrawLineV(startPos: Vector2, endPos: Vector2, color: Color) void; // Draw a line (using gl lines) +pub extern "c" fn DrawLineEx(startPos: Vector2, endPos: Vector2, thick: f32, color: Color) void; // Draw a line (using triangles/quads) +pub extern "c" fn DrawLineStrip(points: [*c]Vector2, pointCount: c_int, color: Color) void; // Draw lines sequence (using gl lines) +pub extern "c" fn DrawLineBezier(startPos: Vector2, endPos: Vector2, thick: f32, color: Color) void; // Draw line segment cubic-bezier in-out interpolation +pub extern "c" fn DrawCircle(centerX: c_int, centerY: c_int, radius: f32, color: Color) void; // Draw a color-filled circle +pub extern "c" fn DrawCircleSector(center: Vector2, radius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: Color) void; // Draw a piece of a circle +pub extern "c" fn DrawCircleSectorLines(center: Vector2, radius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: Color) void; // Draw circle sector outline +pub extern "c" fn DrawCircleGradient(centerX: c_int, centerY: c_int, radius: f32, color1: Color, color2: Color) void; // Draw a gradient-filled circle +pub extern "c" fn DrawCircleV(center: Vector2, radius: f32, color: Color) void; // Draw a color-filled circle (Vector version) +pub extern "c" fn DrawCircleLines(centerX: c_int, centerY: c_int, radius: f32, color: Color) void; // Draw circle outline +pub extern "c" fn DrawCircleLinesV(center: Vector2, radius: f32, color: Color) void; // Draw circle outline (Vector version) +pub extern "c" fn DrawEllipse(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: Color) void; // Draw ellipse +pub extern "c" fn DrawEllipseLines(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: Color) void; // Draw ellipse outline +pub extern "c" fn DrawRing(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: Color) void; // Draw ring +pub extern "c" fn DrawRingLines(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: Color) void; // Draw ring outline +pub extern "c" fn DrawRectangle(posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void; // Draw a color-filled rectangle +pub extern "c" fn DrawRectangleV(position: Vector2, size: Vector2, color: Color) void; // Draw a color-filled rectangle (Vector version) +pub extern "c" fn DrawRectangleRec(rec: Rectangle, color: Color) void; // Draw a color-filled rectangle +pub extern "c" fn DrawRectanglePro(rec: Rectangle, origin: Vector2, rotation: f32, color: Color) void; // Draw a color-filled rectangle with pro parameters +pub extern "c" fn DrawRectangleGradientV(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: Color, color2: Color) void; // Draw a vertical-gradient-filled rectangle +pub extern "c" fn DrawRectangleGradientH(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: Color, color2: Color) void; // Draw a horizontal-gradient-filled rectangle +pub extern "c" fn DrawRectangleGradientEx(rec: Rectangle, col1: Color, col2: Color, col3: Color, col4: Color) void; // Draw a gradient-filled rectangle with custom vertex colors +pub extern "c" fn DrawRectangleLines(posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void; // Draw rectangle outline +pub extern "c" fn DrawRectangleLinesEx(rec: Rectangle, lineThick: f32, color: Color) void; // Draw rectangle outline with extended parameters +pub extern "c" fn DrawRectangleRounded(rec: Rectangle, roundness: f32, segments: c_int, color: Color) void; // Draw rectangle with rounded edges +pub extern "c" fn DrawRectangleRoundedLines(rec: Rectangle, roundness: f32, segments: c_int, lineThick: f32, color: Color) void; // Draw rectangle with rounded edges outline +pub extern "c" fn DrawTriangle(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void; // Draw a color-filled triangle (vertex in counter-clockwise order!) +pub extern "c" fn DrawTriangleLines(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void; // Draw triangle outline (vertex in counter-clockwise order!) +pub extern "c" fn DrawTriangleFan(points: [*c]Vector2, pointCount: c_int, color: Color) void; // Draw a triangle fan defined by points (first vertex is the center) +pub extern "c" fn DrawTriangleStrip(points: [*c]Vector2, pointCount: c_int, color: Color) void; // Draw a triangle strip defined by points +pub extern "c" fn DrawPoly(center: Vector2, sides: c_int, radius: f32, rotation: f32, color: Color) void; // Draw a regular polygon (Vector version) +pub extern "c" fn DrawPolyLines(center: Vector2, sides: c_int, radius: f32, rotation: f32, color: Color) void; // Draw a polygon outline of n sides +pub extern "c" fn DrawPolyLinesEx(center: Vector2, sides: c_int, radius: f32, rotation: f32, lineThick: f32, color: Color) void; // Draw a polygon outline of n sides with extended parameters + +// Splines drawing functions +pub extern "c" fn DrawSplineLinear(points: [*c]Vector2, pointCount: c_int, thick: f32, color: Color) void; // Draw spline: Linear, minimum 2 points +pub extern "c" fn DrawSplineBasis(points: [*c]Vector2, pointCount: c_int, thick: f32, color: Color) void; // Draw spline: B-Spline, minimum 4 points +pub extern "c" fn DrawSplineCatmullRom(points: [*c]Vector2, pointCount: c_int, thick: f32, color: Color) void; // Draw spline: Catmull-Rom, minimum 4 points +pub extern "c" fn DrawSplineBezierQuadratic(points: [*c]Vector2, pointCount: c_int, thick: f32, color: Color) void; // Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...] +pub extern "c" fn DrawSplineBezierCubic(points: [*c]Vector2, pointCount: c_int, thick: f32, color: Color) void; // Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...] +pub extern "c" fn DrawSplineSegmentLinear(p1: Vector2, p2: Vector2, thick: f32, color: Color) void; // Draw spline segment: Linear, 2 points +pub extern "c" fn DrawSplineSegmentBasis(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, thick: f32, color: Color) void; // Draw spline segment: B-Spline, 4 points +pub extern "c" fn DrawSplineSegmentCatmullRom(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, thick: f32, color: Color) void; // Draw spline segment: Catmull-Rom, 4 points +pub extern "c" fn DrawSplineSegmentBezierQuadratic(p1: Vector2, c2: Vector2, p3: Vector2, thick: f32, color: Color) void; // Draw spline segment: Quadratic Bezier, 2 points, 1 control point +pub extern "c" fn DrawSplineSegmentBezierCubic(p1: Vector2, c2: Vector2, c3: Vector2, p4: Vector2, thick: f32, color: Color) void; // Draw spline segment: Cubic Bezier, 2 points, 2 control points + +// Spline segment point evaluation functions, for a given t [0.0f .. 1.0f] +pub extern "c" fn GetSplinePointLinear(startPos: Vector2, endPos: Vector2, t: f32) Vector2; // Get (evaluate) spline point: Linear +pub extern "c" fn GetSplinePointBasis(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, t: f32) Vector2; // Get (evaluate) spline point: B-Spline +pub extern "c" fn GetSplinePointCatmullRom(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, t: f32) Vector2; // Get (evaluate) spline point: Catmull-Rom +pub extern "c" fn GetSplinePointBezierQuad(p1: Vector2, c2: Vector2, p3: Vector2, t: f32) Vector2; // Get (evaluate) spline point: Quadratic Bezier +pub extern "c" fn GetSplinePointBezierCubic(p1: Vector2, c2: Vector2, c3: Vector2, p4: Vector2, t: f32) Vector2; // Get (evaluate) spline point: Cubic Bezier + +// Basic shapes collision detection functions +pub extern "c" fn CheckCollisionRecs(rec1: Rectangle, rec2: Rectangle) bool; // Check collision between two rectangles +pub extern "c" fn CheckCollisionCircles(center1: Vector2, radius1: f32, center2: Vector2, radius2: f32) bool; // Check collision between two circles +pub extern "c" fn CheckCollisionCircleRec(center: Vector2, radius: f32, rec: Rectangle) bool; // Check collision between circle and rectangle +pub extern "c" fn CheckCollisionPointRec(point: Vector2, rec: Rectangle) bool; // Check if point is inside rectangle +pub extern "c" fn CheckCollisionPointCircle(point: Vector2, center: Vector2, radius: f32) bool; // Check if point is inside circle +pub extern "c" fn CheckCollisionPointTriangle(point: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) bool; // Check if point is inside a triangle +pub extern "c" fn CheckCollisionPointPoly(point: Vector2, points: [*c]Vector2, pointCount: c_int) bool; // Check if point is within a polygon described by array of vertices +pub extern "c" fn CheckCollisionLines(startPos1: Vector2, endPos1: Vector2, startPos2: Vector2, endPos2: Vector2, collisionPoint: [*c]Vector2) bool; // Check the collision between two lines defined by two points each, returns collision point by reference +pub extern "c" fn CheckCollisionPointLine(point: Vector2, p1: Vector2, p2: Vector2, threshold: c_int) bool; // Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] +pub extern "c" fn GetCollisionRec(rec1: Rectangle, rec2: Rectangle) Rectangle; // Get collision rectangle for two rectangles collision + +//------------------------------------------------------------------------------------ +// Texture Loading and Drawing Functions (Module: textures) +//------------------------------------------------------------------------------------ + +// Image loading functions +// NOTE: These functions do not require GPU access +pub extern "c" fn LoadImage(fileName: [*c]const u8) Image; // Load image from file into CPU memory (RAM) +pub extern "c" fn LoadImageRaw(fileName: [*c]const u8, width: c_int, height: c_int, format: c_int, headerSize: c_int) Image; // Load image from RAW file data +pub extern "c" fn LoadImageSvg(fileNameOrString: [*c]const u8, width: c_int, height: c_int) Image; // Load image from SVG file data or string with specified size +pub extern "c" fn LoadImageAnim(fileName: [*c]const u8, frames: [*c]c_int) Image; // Load image sequence from file (frames appended to image.data) +pub extern "c" fn LoadImageFromMemory(fileType: [*c]const u8, fileData: [*c]const u8, dataSize: c_int) Image; // Load image from memory buffer, fileType refers to extension: i.e. '.png' +pub extern "c" fn LoadImageFromTexture(texture: Texture2D) Image; // Load image from GPU texture data +pub extern "c" fn LoadImageFromScreen() Image; // Load image from screen buffer and (screenshot) +pub extern "c" fn IsImageReady(image: Image) bool; // Check if an image is ready +pub extern "c" fn UnloadImage(image: Image) void; // Unload image from CPU memory (RAM) +pub extern "c" fn ExportImage(image: Image, fileName: [*c]const u8) bool; // Export image data to file, returns true on success +pub extern "c" fn ExportImageToMemory(image: Image, fileType: [*c]const u8, fileSize: [*c]c_int) [*c]u8; // Export image to memory buffer +pub extern "c" fn ExportImageAsCode(image: Image, fileName: [*c]const u8) bool; // Export image as code file defining an array of bytes, returns true on success + +// Image generation functions +pub extern "c" fn GenImageColor(width: c_int, height: c_int, color: Color) Image; // Generate image: plain color +pub extern "c" fn GenImageGradientLinear(width: c_int, height: c_int, direction: c_int, start: Color, end: Color) Image; // Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient +pub extern "c" fn GenImageGradientRadial(width: c_int, height: c_int, density: f32, inner: Color, outer: Color) Image; // Generate image: radial gradient +pub extern "c" fn GenImageGradientSquare(width: c_int, height: c_int, density: f32, inner: Color, outer: Color) Image; // Generate image: square gradient +pub extern "c" fn GenImageChecked(width: c_int, height: c_int, checksX: c_int, checksY: c_int, col1: Color, col2: Color) Image; // Generate image: checked +pub extern "c" fn GenImageWhiteNoise(width: c_int, height: c_int, factor: f32) Image; // Generate image: white noise +pub extern "c" fn GenImagePerlinNoise(width: c_int, height: c_int, offsetX: c_int, offsetY: c_int, scale: f32) Image; // Generate image: perlin noise +pub extern "c" fn GenImageCellular(width: c_int, height: c_int, tileSize: c_int) Image; // Generate image: cellular algorithm, bigger tileSize means bigger cells +pub extern "c" fn GenImageText(width: c_int, height: c_int, text: [*c]const u8) Image; // Generate image: grayscale image from text data + +// Image manipulation functions +pub extern "c" fn ImageCopy(image: Image) Image; // Create an image duplicate (useful for transformations) +pub extern "c" fn ImageFromImage(image: Image, rec: Rectangle) Image; // Create an image from another image piece +pub extern "c" fn ImageText(text: [*c]const u8, fontSize: c_int, color: Color) Image; // Create an image from text (default font) +pub extern "c" fn ImageTextEx(font: Font, text: [*c]const u8, fontSize: f32, spacing: f32, tint: Color) Image; // Create an image from text (custom sprite font) +pub extern "c" fn ImageFormat(image: [*c]Image, newFormat: c_int) void; // Convert image data to desired format +pub extern "c" fn ImageToPOT(image: [*c]Image, fill: Color) void; // Convert image to POT (power-of-two) +pub extern "c" fn ImageCrop(image: [*c]Image, crop: Rectangle) void; // Crop an image to a defined rectangle +pub extern "c" fn ImageAlphaCrop(image: [*c]Image, threshold: f32) void; // Crop image depending on alpha value +pub extern "c" fn ImageAlphaClear(image: [*c]Image, color: Color, threshold: f32) void; // Clear alpha channel to desired color +pub extern "c" fn ImageAlphaMask(image: [*c]Image, alphaMask: Image) void; // Apply alpha mask to image +pub extern "c" fn ImageAlphaPremultiply(image: [*c]Image) void; // Premultiply alpha channel +pub extern "c" fn ImageBlurGaussian(image: [*c]Image, blurSize: c_int) void; // Apply Gaussian blur using a box blur approximation +pub extern "c" fn ImageResize(image: [*c]Image, newWidth: c_int, newHeight: c_int) void; // Resize image (Bicubic scaling algorithm) +pub extern "c" fn ImageResizeNN(image: [*c]Image, newWidth: c_int, newHeight: c_int) void; // Resize image (Nearest-Neighbor scaling algorithm) +pub extern "c" fn ImageResizeCanvas(image: [*c]Image, newWidth: c_int, newHeight: c_int, offsetX: c_int, offsetY: c_int, fill: Color) void; // Resize canvas and fill with color +pub extern "c" fn ImageMipmaps(image: [*c]Image) void; // Compute all mipmap levels for a provided image +pub extern "c" fn ImageDither(image: [*c]Image, rBpp: c_int, gBpp: c_int, bBpp: c_int, aBpp: c_int) void; // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) +pub extern "c" fn ImageFlipVertical(image: [*c]Image) void; // Flip image vertically +pub extern "c" fn ImageFlipHorizontal(image: [*c]Image) void; // Flip image horizontally +pub extern "c" fn ImageRotate(image: [*c]Image, degrees: c_int) void; // Rotate image by input angle in degrees (-359 to 359) +pub extern "c" fn ImageRotateCW(image: [*c]Image) void; // Rotate image clockwise 90deg +pub extern "c" fn ImageRotateCCW(image: [*c]Image) void; // Rotate image counter-clockwise 90deg +pub extern "c" fn ImageColorTint(image: [*c]Image, color: Color) void; // Modify image color: tint +pub extern "c" fn ImageColorInvert(image: [*c]Image) void; // Modify image color: invert +pub extern "c" fn ImageColorGrayscale(image: [*c]Image) void; // Modify image color: grayscale +pub extern "c" fn ImageColorContrast(image: [*c]Image, contrast: f32) void; // Modify image color: contrast (-100 to 100) +pub extern "c" fn ImageColorBrightness(image: [*c]Image, brightness: c_int) void; // Modify image color: brightness (-255 to 255) +pub extern "c" fn ImageColorReplace(image: [*c]Image, color: Color, replace: Color) void; // Modify image color: replace color +pub extern "c" fn LoadImageColors(image: Image) [*c]Color; // Load color data from image as a Color array (RGBA - 32bit) +pub extern "c" fn LoadImagePalette(image: Image, maxPaletteSize: c_int, colorCount: [*c]c_int) [*c]Color; // Load colors palette from image as a Color array (RGBA - 32bit) +pub extern "c" fn UnloadImageColors(colors: [*c]Color) void; // Unload color data loaded with LoadImageColors() +pub extern "c" fn UnloadImagePalette(colors: [*c]Color) void; // Unload colors palette loaded with LoadImagePalette() +pub extern "c" fn GetImageAlphaBorder(image: Image, threshold: f32) Rectangle; // Get image alpha border rectangle +pub extern "c" fn GetImageColor(image: Image, x: c_int, y: c_int) Color; // Get image pixel color at (x, y) position + +// Image drawing functions +// NOTE: Image software-rendering functions (CPU) +pub extern "c" fn ImageClearBackground(dst: [*c]Image, color: Color) void; // Clear image background with given color +pub extern "c" fn ImageDrawPixel(dst: [*c]Image, posX: c_int, posY: c_int, color: Color) void; // Draw pixel within an image +pub extern "c" fn ImageDrawPixelV(dst: [*c]Image, position: Vector2, color: Color) void; // Draw pixel within an image (Vector version) +pub extern "c" fn ImageDrawLine(dst: [*c]Image, startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: Color) void; // Draw line within an image +pub extern "c" fn ImageDrawLineV(dst: [*c]Image, start: Vector2, end: Vector2, color: Color) void; // Draw line within an image (Vector version) +pub extern "c" fn ImageDrawCircle(dst: [*c]Image, centerX: c_int, centerY: c_int, radius: c_int, color: Color) void; // Draw a filled circle within an image +pub extern "c" fn ImageDrawCircleV(dst: [*c]Image, center: Vector2, radius: c_int, color: Color) void; // Draw a filled circle within an image (Vector version) +pub extern "c" fn ImageDrawCircleLines(dst: [*c]Image, centerX: c_int, centerY: c_int, radius: c_int, color: Color) void; // Draw circle outline within an image +pub extern "c" fn ImageDrawCircleLinesV(dst: [*c]Image, center: Vector2, radius: c_int, color: Color) void; // Draw circle outline within an image (Vector version) +pub extern "c" fn ImageDrawRectangle(dst: [*c]Image, posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void; // Draw rectangle within an image +pub extern "c" fn ImageDrawRectangleV(dst: [*c]Image, position: Vector2, size: Vector2, color: Color) void; // Draw rectangle within an image (Vector version) +pub extern "c" fn ImageDrawRectangleRec(dst: [*c]Image, rec: Rectangle, color: Color) void; // Draw rectangle within an image +pub extern "c" fn ImageDrawRectangleLines(dst: [*c]Image, rec: Rectangle, thick: c_int, color: Color) void; // Draw rectangle lines within an image +pub extern "c" fn ImageDraw(dst: [*c]Image, src: Image, srcRec: Rectangle, dstRec: Rectangle, tint: Color) void; // Draw a source image within a destination image (tint applied to source) +pub extern "c" fn ImageDrawText(dst: [*c]Image, text: [*c]const u8, posX: c_int, posY: c_int, fontSize: c_int, color: Color) void; // Draw text (using default font) within an image (destination) +pub extern "c" fn ImageDrawTextEx(dst: [*c]Image, font: Font, text: [*c]const u8, position: Vector2, fontSize: f32, spacing: f32, tint: Color) void; // Draw text (custom sprite font) within an image (destination) + +// Texture loading functions +// NOTE: These functions require GPU access +pub extern "c" fn LoadTexture(fileName: [*c]const u8) Texture2D; // Load texture from file into GPU memory (VRAM) +pub extern "c" fn LoadTextureFromImage(image: Image) Texture2D; // Load texture from image data +pub extern "c" fn LoadTextureCubemap(image: Image, layout: c_int) TextureCubemap; // Load cubemap from image, multiple image cubemap layouts supported +pub extern "c" fn LoadRenderTexture(width: c_int, height: c_int) RenderTexture2D; // Load texture for rendering (framebuffer) +pub extern "c" fn IsTextureReady(texture: Texture2D) bool; // Check if a texture is ready +pub extern "c" fn UnloadTexture(texture: Texture2D) void; // Unload texture from GPU memory (VRAM) +pub extern "c" fn IsRenderTextureReady(target: RenderTexture2D) bool; // Check if a render texture is ready +pub extern "c" fn UnloadRenderTexture(target: RenderTexture2D) void; // Unload render texture from GPU memory (VRAM) +pub extern "c" fn UpdateTexture(texture: Texture2D, pixels: *const anyopaque) void; // Update GPU texture with new data +pub extern "c" fn UpdateTextureRec(texture: Texture2D, rec: Rectangle, pixels: *const anyopaque) void; // Update GPU texture rectangle with new data + +// Texture configuration functions +pub extern "c" fn GenTextureMipmaps(texture: [*c]Texture2D) void; // Generate GPU mipmaps for a texture +pub extern "c" fn SetTextureFilter(texture: Texture2D, filter: c_int) void; // Set texture scaling filter mode +pub extern "c" fn SetTextureWrap(texture: Texture2D, wrap: c_int) void; // Set texture wrapping mode + +// Texture drawing functions +pub extern "c" fn DrawTexture(texture: Texture2D, posX: c_int, posY: c_int, tint: Color) void; // Draw a Texture2D +pub extern "c" fn DrawTextureV(texture: Texture2D, position: Vector2, tint: Color) void; // Draw a Texture2D with position defined as Vector2 +pub extern "c" fn DrawTextureEx(texture: Texture2D, position: Vector2, rotation: f32, scale: f32, tint: Color) void; // Draw a Texture2D with extended parameters +pub extern "c" fn DrawTextureRec(texture: Texture2D, source: Rectangle, position: Vector2, tint: Color) void; // Draw a part of a texture defined by a rectangle +pub extern "c" fn DrawTexturePro(texture: Texture2D, source: Rectangle, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) void; // Draw a part of a texture defined by a rectangle with 'pro' parameters +pub extern "c" fn DrawTextureNPatch(texture: Texture2D, nPatchInfo: NPatchInfo, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) void; // Draws a texture (or part of it) that stretches or shrinks nicely + +// Color/pixel related functions +pub extern "c" fn Fade(color: Color, alpha: f32) Color; // Get color with alpha applied, alpha goes from 0.0f to 1.0f +pub extern "c" fn ColorToInt(color: Color) c_int; // Get hexadecimal value for a Color +pub extern "c" fn ColorNormalize(color: Color) Vector4; // Get Color normalized as float [0..1] +pub extern "c" fn ColorFromNormalized(normalized: Vector4) Color; // Get Color from normalized values [0..1] +pub extern "c" fn ColorToHSV(color: Color) Vector3; // Get HSV values for a Color, hue [0..360], saturation/value [0..1] +pub extern "c" fn ColorFromHSV(hue: f32, saturation: f32, value: f32) Color; // Get a Color from HSV values, hue [0..360], saturation/value [0..1] +pub extern "c" fn ColorTint(color: Color, tint: Color) Color; // Get color multiplied with another color +pub extern "c" fn ColorBrightness(color: Color, factor: f32) Color; // Get color with brightness correction, brightness factor goes from -1.0f to 1.0f +pub extern "c" fn ColorContrast(color: Color, contrast: f32) Color; // Get color with contrast correction, contrast values between -1.0f and 1.0f +pub extern "c" fn ColorAlpha(color: Color, alpha: f32) Color; // Get color with alpha applied, alpha goes from 0.0f to 1.0f +pub extern "c" fn ColorAlphaBlend(dst: Color, src: Color, tint: Color) Color; // Get src alpha-blended into dst color with tint +pub extern "c" fn GetColor(hexValue: c_uint) Color; // Get Color structure from hexadecimal value +pub extern "c" fn GetPixelColor(srcPtr: *anyopaque, format: c_int) Color; // Get Color from a source pixel pointer of certain format +pub extern "c" fn SetPixelColor(dstPtr: *anyopaque, color: Color, format: c_int) void; // Set color formatted into destination pixel pointer +pub extern "c" fn GetPixelDataSize(width: c_int, height: c_int, format: c_int) c_int; // Get pixel data size in bytes for certain format + +//------------------------------------------------------------------------------------ +// Font Loading and Text Drawing Functions (Module: text) +//------------------------------------------------------------------------------------ + +// Font loading/unloading functions +pub extern "c" fn GetFontDefault() Font; // Get the default Font +pub extern "c" fn LoadFont(fileName: [*c]const u8) Font; // Load font from file into GPU memory (VRAM) +pub extern "c" fn LoadFontEx(fileName: [*c]const u8, fontSize: c_int, codepoints: [*c]c_int, codepointCount: c_int) Font; // Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set +pub extern "c" fn LoadFontFromImage(image: Image, key: Color, firstChar: c_int) Font; // Load font from Image (XNA style) +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) Font; // Load font from memory buffer, fileType refers to extension: i.e. '.ttf' +pub extern "c" fn IsFontReady(font: Font) bool; // Check if a font is ready +pub extern "c" fn LoadFontData(fileData: [*c]const u8, dataSize: c_int, fontSize: c_int, codepoints: [*c]c_int, codepointCount: c_int, @"type": c_int) [*c]GlyphInfo; // Load font data for further use +pub extern "c" fn GenImageFontAtlas(glyphs: [*c]const GlyphInfo, glyphRecs: [*c][*c]Rectangle, glyphCount: c_int, fontSize: c_int, padding: c_int, packMethod: c_int) Image; // Generate image font atlas using chars info +pub extern "c" fn UnloadFontData(glyphs: [*c]GlyphInfo, glyphCount: c_int) void; // Unload font chars info data (RAM) +pub extern "c" fn UnloadFont(font: Font) void; // Unload font from GPU memory (VRAM) +pub extern "c" fn ExportFontAsCode(font: Font, fileName: [*c]const u8) bool; // Export font as code file, returns true on success + +// Text drawing functions +pub extern "c" fn DrawFPS(posX: c_int, posY: c_int) void; // Draw current FPS +pub extern "c" fn DrawText(text: [*c]const u8, posX: c_int, posY: c_int, fontSize: c_int, color: Color) void; // Draw text (using default font) +pub extern "c" fn DrawTextEx(font: Font, text: [*c]const u8, position: Vector2, fontSize: f32, spacing: f32, tint: Color) void; // Draw text using font and additional parameters +pub extern "c" fn DrawTextPro(font: Font, text: [*c]const u8, position: Vector2, origin: Vector2, rotation: f32, fontSize: f32, spacing: f32, tint: Color) void; // Draw text using Font and pro parameters (rotation) +pub extern "c" fn DrawTextCodepoint(font: Font, codepoint: c_int, position: Vector2, fontSize: f32, tint: Color) void; // Draw one character (codepoint) +pub extern "c" fn DrawTextCodepoints(font: Font, codepoints: [*c]const c_int, codepointCount: c_int, position: Vector2, fontSize: f32, spacing: f32, tint: Color) void; // Draw multiple character (codepoint) + +// Text font info functions +pub extern "c" fn SetTextLineSpacing(spacing: c_int) void; // Set vertical line spacing when drawing with line-breaks +pub extern "c" fn MeasureText(text: [*c]const u8, fontSize: c_int) c_int; // Measure string width for default font +pub extern "c" fn MeasureTextEx(font: Font, text: [*c]const u8, fontSize: f32, spacing: f32) Vector2; // Measure string size for Font +pub extern "c" fn GetGlyphIndex(font: Font, codepoint: c_int) c_int; // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found +pub extern "c" fn GetGlyphInfo(font: Font, codepoint: c_int) GlyphInfo; // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found +pub extern "c" fn GetGlyphAtlasRec(font: Font, codepoint: c_int) Rectangle; // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found + +// Text codepoints management functions (unicode characters) +pub extern "c" fn LoadUTF8(codepoints: [*c]const c_int, length: c_int) [*c]u8; // Load UTF-8 text encoded from codepoints array +pub extern "c" fn UnloadUTF8(text: [*c]u8) void; // Unload UTF-8 text encoded from codepoints array +pub extern "c" fn LoadCodepoints(text: [*c]const u8, count: [*c]c_int) [*c]c_int; // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter +pub extern "c" fn UnloadCodepoints(codepoints: [*c]c_int) void; // Unload codepoints data from memory +pub extern "c" fn GetCodepointCount(text: [*c]const u8) c_int; // Get total number of codepoints in a UTF-8 encoded string +pub extern "c" fn GetCodepoint(text: [*c]const u8, codepointSize: [*c]c_int) c_int; // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure +pub extern "c" fn GetCodepointNext(text: [*c]const u8, codepointSize: [*c]c_int) c_int; // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure +pub extern "c" fn GetCodepointPrevious(text: [*c]const u8, codepointSize: [*c]c_int) c_int; // Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure +pub extern "c" fn CodepointToUTF8(codepoint: c_int, utf8Size: [*c]c_int) [*c]const u8; // Encode one codepoint into UTF-8 byte array (array length returned as parameter) + +// Text strings management functions (no UTF-8 strings, only byte chars) +// NOTE: Some strings allocate memory internally for returned strings, just be careful! +pub extern "c" fn TextCopy(dst: [*c]u8, src: [*c]const u8) c_int; // Copy one string to another, returns bytes copied +pub extern "c" fn TextIsEqual(text1: [*c]const u8, text2: [*c]const u8) bool; // Check if two text string are equal +pub extern "c" fn TextLength(text: [*c]const u8) c_uint; // Get text length, checks for '\0' ending +pub extern "c" fn TextFormat(text: [*c]const u8, ...) [*c]const u8; // Text formatting with variables (sprintf() style) +pub extern "c" fn TextSubtext(text: [*c]const u8, position: c_int, length: c_int) [*c]const u8; // Get a piece of a text string +pub extern "c" fn TextReplace(text: [*c]u8, replace: [*c]const u8, by: [*c]const u8) [*c]u8; // Replace text string (WARNING: memory must be freed!) +pub extern "c" fn TextInsert(text: [*c]const u8, insert: [*c]const u8, position: c_int) [*c]u8; // Insert text in a position (WARNING: memory must be freed!) +pub extern "c" fn TextJoin(textList: [*c][*c]const u8, count: c_int, delimiter: [*c]const u8) [*c]const u8; // Join text strings with delimiter +pub extern "c" fn TextSplit(text: [*c]const u8, delimiter: u8, count: [*c]c_int) [*c][*c]const u8; // Split text into multiple strings +pub extern "c" fn TextAppend(text: [*c]u8, append: [*c]const u8, position: [*c]c_int) void; // Append text at specific position and move cursor! +pub extern "c" fn TextFindIndex(text: [*c]const u8, find: [*c]const u8) c_int; // Find first text occurrence within a string +pub extern "c" fn TextToUpper(text: [*c]const u8) [*c]const u8; // Get upper case version of provided string +pub extern "c" fn TextToLower(text: [*c]const u8) [*c]const u8; // Get lower case version of provided string +pub extern "c" fn TextToPascal(text: [*c]const u8) [*c]const u8; // Get Pascal case notation version of provided string +pub extern "c" fn TextToInteger(text: [*c]const u8) c_int; // Get integer value from text (negative values not supported) + +//------------------------------------------------------------------------------------ +// Basic 3d Shapes Drawing Functions (Module: models) +//------------------------------------------------------------------------------------ + +// Basic geometric 3D shapes drawing functions +pub extern "c" fn DrawLine3D(startPos: Vector3, endPos: Vector3, color: Color) void; // Draw a line in 3D world space +pub extern "c" fn DrawPoint3D(position: Vector3, color: Color) void; // Draw a point in 3D space, actually a small line +pub extern "c" fn DrawCircle3D(center: Vector3, radius: f32, rotationAxis: Vector3, rotationAngle: f32, color: Color) void; // Draw a circle in 3D world space +pub extern "c" fn DrawTriangle3D(v1: Vector3, v2: Vector3, v3: Vector3, color: Color) void; // Draw a color-filled triangle (vertex in counter-clockwise order!) +pub extern "c" fn DrawTriangleStrip3D(points: [*c]Vector3, pointCount: c_int, color: Color) void; // Draw a triangle strip defined by points +pub extern "c" fn DrawCube(position: Vector3, width: f32, height: f32, length: f32, color: Color) void; // Draw cube +pub extern "c" fn DrawCubeV(position: Vector3, size: Vector3, color: Color) void; // Draw cube (Vector version) +pub extern "c" fn DrawCubeWires(position: Vector3, width: f32, height: f32, length: f32, color: Color) void; // Draw cube wires +pub extern "c" fn DrawCubeWiresV(position: Vector3, size: Vector3, color: Color) void; // Draw cube wires (Vector version) +pub extern "c" fn DrawSphere(centerPos: Vector3, radius: f32, color: Color) void; // Draw sphere +pub extern "c" fn DrawSphereEx(centerPos: Vector3, radius: f32, rings: c_int, slices: c_int, color: Color) void; // Draw sphere with extended parameters +pub extern "c" fn DrawSphereWires(centerPos: Vector3, radius: f32, rings: c_int, slices: c_int, color: Color) void; // Draw sphere wires +pub extern "c" fn DrawCylinder(position: Vector3, radiusTop: f32, radiusBottom: f32, height: f32, slices: c_int, color: Color) void; // Draw a cylinder/cone +pub extern "c" fn DrawCylinderEx(startPos: Vector3, endPos: Vector3, startRadius: f32, endRadius: f32, sides: c_int, color: Color) void; // Draw a cylinder with base at startPos and top at endPos +pub extern "c" fn DrawCylinderWires(position: Vector3, radiusTop: f32, radiusBottom: f32, height: f32, slices: c_int, color: Color) void; // Draw a cylinder/cone wires +pub extern "c" fn DrawCylinderWiresEx(startPos: Vector3, endPos: Vector3, startRadius: f32, endRadius: f32, sides: c_int, color: Color) void; // Draw a cylinder wires with base at startPos and top at endPos +pub extern "c" fn DrawCapsule(startPos: Vector3, endPos: Vector3, radius: f32, slices: c_int, rings: c_int, color: Color) void; // Draw a capsule with the center of its sphere caps at startPos and endPos +pub extern "c" fn DrawCapsuleWires(startPos: Vector3, endPos: Vector3, radius: f32, slices: c_int, rings: c_int, color: Color) void; // Draw capsule wireframe with the center of its sphere caps at startPos and endPos +pub extern "c" fn DrawPlane(centerPos: Vector3, size: Vector2, color: Color) void; // Draw a plane XZ +pub extern "c" fn DrawRay(ray: Ray, color: Color) void; // Draw a ray line +pub extern "c" fn DrawGrid(slices: c_int, spacing: f32) void; // Draw a grid (centered at (0, 0, 0)) + +//------------------------------------------------------------------------------------ +// Model 3d Loading and Drawing Functions (Module: models) +//------------------------------------------------------------------------------------ + +// Model management functions +pub extern "c" fn LoadModel(fileName: [*c]const u8) Model; // Load model from files (meshes and materials) +pub extern "c" fn LoadModelFromMesh(mesh: Mesh) Model; // Load model from generated mesh (default material) +pub extern "c" fn IsModelReady(model: Model) bool; // Check if a model is ready +pub extern "c" fn UnloadModel(model: Model) void; // Unload model (including meshes) from memory (RAM and/or VRAM) +pub extern "c" fn GetModelBoundingBox(model: Model) BoundingBox; // Compute model bounding box limits (considers all meshes) + +// Model drawing functions +pub extern "c" fn DrawModel(model: Model, position: Vector3, scale: f32, tint: Color) void; // Draw a model (with texture if set) +pub extern "c" fn DrawModelEx(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) void; // Draw a model with extended parameters +pub extern "c" fn DrawModelWires(model: Model, position: Vector3, scale: f32, tint: Color) void; // Draw a model wires (with texture if set) +pub extern "c" fn DrawModelWiresEx(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) void; // Draw a model wires (with texture if set) with extended parameters +pub extern "c" fn DrawBoundingBox(box: BoundingBox, color: Color) void; // Draw bounding box (wires) +pub extern "c" fn DrawBillboard(camera: Camera, texture: Texture2D, position: Vector3, size: f32, tint: Color) void; // Draw a billboard texture +pub extern "c" fn DrawBillboardRec(camera: Camera, texture: Texture2D, source: Rectangle, position: Vector3, size: Vector2, tint: Color) void; // Draw a billboard texture defined by source +pub extern "c" fn DrawBillboardPro(camera: Camera, texture: Texture2D, source: Rectangle, position: Vector3, up: Vector3, size: Vector2, origin: Vector2, rotation: f32, tint: Color) void; // Draw a billboard texture defined by source and rotation + +// Mesh management functions +pub extern "c" fn UploadMesh(mesh: [*c]Mesh, dynamic: bool) void; // Upload mesh vertex data in GPU and provide VAO/VBO ids +pub extern "c" fn UpdateMeshBuffer(mesh: Mesh, index: c_int, data: *const anyopaque, dataSize: c_int, offset: c_int) void; // Update mesh vertex data in GPU for a specific buffer index +pub extern "c" fn UnloadMesh(mesh: Mesh) void; // Unload mesh data from CPU and GPU +pub extern "c" fn DrawMesh(mesh: Mesh, material: Material, transform: Matrix) void; // Draw a 3d mesh with material and transform +pub extern "c" fn DrawMeshInstanced(mesh: Mesh, material: Material, transforms: [*c]const Matrix, instances: c_int) void; // Draw multiple mesh instances with material and different transforms +pub extern "c" fn ExportMesh(mesh: Mesh, fileName: [*c]const u8) bool; // Export mesh data to file, returns true on success +pub extern "c" fn GetMeshBoundingBox(mesh: Mesh) BoundingBox; // Compute mesh bounding box limits +pub extern "c" fn GenMeshTangents(mesh: [*c]Mesh) void; // Compute mesh tangents + +// Mesh generation functions +pub extern "c" fn GenMeshPoly(sides: c_int, radius: f32) Mesh; // Generate polygonal mesh +pub extern "c" fn GenMeshPlane(width: f32, length: f32, resX: c_int, resZ: c_int) Mesh; // Generate plane mesh (with subdivisions) +pub extern "c" fn GenMeshCube(width: f32, height: f32, length: f32) Mesh; // Generate cuboid mesh +pub extern "c" fn GenMeshSphere(radius: f32, rings: c_int, slices: c_int) Mesh; // Generate sphere mesh (standard sphere) +pub extern "c" fn GenMeshHemiSphere(radius: f32, rings: c_int, slices: c_int) Mesh; // Generate half-sphere mesh (no bottom cap) +pub extern "c" fn GenMeshCylinder(radius: f32, height: f32, slices: c_int) Mesh; // Generate cylinder mesh +pub extern "c" fn GenMeshCone(radius: f32, height: f32, slices: c_int) Mesh; // Generate cone/pyramid mesh +pub extern "c" fn GenMeshTorus(radius: f32, size: f32, radSeg: c_int, sides: c_int) Mesh; // Generate torus mesh +pub extern "c" fn GenMeshKnot(radius: f32, size: f32, radSeg: c_int, sides: c_int) Mesh; // Generate trefoil knot mesh +pub extern "c" fn GenMeshHeightmap(heightmap: Image, size: Vector3) Mesh; // Generate heightmap mesh from image data +pub extern "c" fn GenMeshCubicmap(cubicmap: Image, cubeSize: Vector3) Mesh; // Generate cubes-based map mesh from image data + +// Material loading/unloading functions +pub extern "c" fn LoadMaterials(fileName: [*c]const u8, materialCount: [*c]c_int) [*c]Material; // Load materials from model file +pub extern "c" fn LoadMaterialDefault() Material; // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) +pub extern "c" fn IsMaterialReady(material: Material) bool; // Check if a material is ready +pub extern "c" fn UnloadMaterial(material: Material) void; // Unload material from GPU memory (VRAM) +pub extern "c" fn SetMaterialTexture(material: [*c]Material, mapType: c_int, texture: Texture2D) void; // Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...) +pub extern "c" fn SetModelMeshMaterial(model: [*c]Model, meshId: c_int, materialId: c_int) void; // Set material for a mesh + +// Model animations loading/unloading functions +pub extern "c" fn LoadModelAnimations(fileName: [*c]const u8, animCount: [*c]c_int) [*c]ModelAnimation; // Load model animations from file +pub extern "c" fn UpdateModelAnimation(model: Model, anim: ModelAnimation, frame: c_int) void; // Update model animation pose +pub extern "c" fn UnloadModelAnimation(anim: ModelAnimation) void; // Unload animation data +pub extern "c" fn UnloadModelAnimations(animations: [*c]ModelAnimation, animCount: c_int) void; // Unload animation array data +pub extern "c" fn IsModelAnimationValid(model: Model, anim: ModelAnimation) bool; // Check model animation skeleton match + +// Collision detection functions +pub extern "c" fn CheckCollisionSpheres(center1: Vector3, radius1: f32, center2: Vector3, radius2: f32) bool; // Check collision between two spheres +pub extern "c" fn CheckCollisionBoxes(box1: BoundingBox, box2: BoundingBox) bool; // Check collision between two bounding boxes +pub extern "c" fn CheckCollisionBoxSphere(box: BoundingBox, center: Vector3, radius: f32) bool; // Check collision between box and sphere +pub extern "c" fn GetRayCollisionSphere(ray: Ray, center: Vector3, radius: f32) RayCollision; // Get collision info between ray and sphere +pub extern "c" fn GetRayCollisionBox(ray: Ray, box: BoundingBox) RayCollision; // Get collision info between ray and box +pub extern "c" fn GetRayCollisionMesh(ray: Ray, mesh: Mesh, transform: Matrix) RayCollision; // Get collision info between ray and mesh +pub extern "c" fn GetRayCollisionTriangle(ray: Ray, p1: Vector3, p2: Vector3, p3: Vector3) RayCollision; // Get collision info between ray and triangle +pub extern "c" fn GetRayCollisionQuad(ray: Ray, p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) RayCollision; // Get collision info between ray and quad + +//------------------------------------------------------------------------------------ +// Audio Loading and Playing Functions (Module: audio) +//------------------------------------------------------------------------------------ +pub const AudioCallback = *const fn (bufferData: *anyopaque, frames: c_uint) callconv(.C) void; + +// Audio device management functions +pub extern "c" fn InitAudioDevice() void; // Initialize audio device and context +pub extern "c" fn CloseAudioDevice() void; // Close the audio device and context +pub extern "c" fn IsAudioDeviceReady() bool; // Check if audio device has been initialized successfully +pub extern "c" fn SetMasterVolume(volume: f32) void; // Set master volume (listener) +pub extern "c" fn GetMasterVolume() f32; // Get master volume (listener) + +// Wave/Sound loading/unloading functions +pub extern "c" fn LoadWave(fileName: [*c]const u8) Wave; // Load wave data from file +pub extern "c" fn LoadWaveFromMemory(fileType: [*c]const u8, fileData: [*c]const u8, dataSize: c_int) Wave; // Load wave from memory buffer, fileType refers to extension: i.e. '.wav' +pub extern "c" fn IsWaveReady(wave: Wave) bool; // Checks if wave data is ready +pub extern "c" fn LoadSound(fileName: [*c]const u8) Sound; // Load sound from file +pub extern "c" fn LoadSoundFromWave(wave: Wave) Sound; // Load sound from wave data +pub extern "c" fn LoadSoundAlias(source: Sound) Sound; // Create a new sound that shares the same sample data as the source sound, does not own the sound data +pub extern "c" fn IsSoundReady(sound: Sound) bool; // Checks if a sound is ready +pub extern "c" fn UpdateSound(sound: Sound, data: *const anyopaque, sampleCount: c_int) void; // Update sound buffer with new data +pub extern "c" fn UnloadWave(wave: Wave) void; // Unload wave data +pub extern "c" fn UnloadSound(sound: Sound) void; // Unload sound +pub extern "c" fn UnloadSoundAlias(alias: Sound) void; // Unload a sound alias (does not deallocate sample data) +pub extern "c" fn ExportWave(wave: Wave, fileName: [*c]const u8) bool; // Export wave data to file, returns true on success +pub extern "c" fn ExportWaveAsCode(wave: Wave, fileName: [*c]const u8) bool; // Export wave sample data to code (.h), returns true on success + +// Wave/Sound management functions +pub extern "c" fn PlaySound(sound: Sound) void; // Play a sound +pub extern "c" fn StopSound(sound: Sound) void; // Stop playing a sound +pub extern "c" fn PauseSound(sound: Sound) void; // Pause a sound +pub extern "c" fn ResumeSound(sound: Sound) void; // Resume a paused sound +pub extern "c" fn IsSoundPlaying(sound: Sound) bool; // Check if a sound is currently playing +pub extern "c" fn SetSoundVolume(sound: Sound, volume: f32) void; // Set volume for a sound (1.0 is max level) +pub extern "c" fn SetSoundPitch(sound: Sound, pitch: f32) void; // Set pitch for a sound (1.0 is base level) +pub extern "c" fn SetSoundPan(sound: Sound, pan: f32) void; // Set pan for a sound (0.5 is center) +pub extern "c" fn WaveCopy(wave: Wave) Wave; // Copy a wave to a new wave +pub extern "c" fn WaveCrop(wave: [*c]Wave, initSample: c_int, finalSample: c_int) void; // Crop a wave to defined samples range +pub extern "c" fn WaveFormat(wave: [*c]Wave, sampleRate: c_int, sampleSize: c_int, channels: c_int) void; // Convert wave data to desired format +pub extern "c" fn LoadWaveSamples(wave: Wave) [*c]f32; // Load samples data from wave as a 32bit float data array +pub extern "c" fn UnloadWaveSamples(samples: [*c]f32) void; // Unload samples data loaded with LoadWaveSamples() + +// Music management functions +pub extern "c" fn LoadMusicStream(fileName: [*c]const u8) Music; // Load music stream from file +pub extern "c" fn LoadMusicStreamFromMemory(fileType: [*c]const u8, data: [*c]const u8, dataSize: c_int) Music; // Load music stream from data +pub extern "c" fn IsMusicReady(music: Music) bool; // Checks if a music stream is ready +pub extern "c" fn UnloadMusicStream(music: Music) void; // Unload music stream +pub extern "c" fn PlayMusicStream(music: Music) void; // Start music playing +pub extern "c" fn IsMusicStreamPlaying(music: Music) bool; // Check if music is playing +pub extern "c" fn UpdateMusicStream(music: Music) void; // Updates buffers for music streaming +pub extern "c" fn StopMusicStream(music: Music) void; // Stop music playing +pub extern "c" fn PauseMusicStream(music: Music) void; // Pause music playing +pub extern "c" fn ResumeMusicStream(music: Music) void; // Resume playing paused music +pub extern "c" fn SeekMusicStream(music: Music, position: f32) void; // Seek music to a position (in seconds) +pub extern "c" fn SetMusicVolume(music: Music, volume: f32) void; // Set volume for music (1.0 is max level) +pub extern "c" fn SetMusicPitch(music: Music, pitch: f32) void; // Set pitch for a music (1.0 is base level) +pub extern "c" fn SetMusicPan(music: Music, pan: f32) void; // Set pan for a music (0.5 is center) +pub extern "c" fn GetMusicTimeLength(music: Music) f32; // Get music time length (in seconds) +pub extern "c" fn GetMusicTimePlayed(music: Music) f32; // Get current music time played (in seconds) + +// AudioStream management functions +pub extern "c" fn LoadAudioStream(sampleRate: c_uint, sampleSize: c_uint, channels: c_uint) AudioStream; // Load audio stream (to stream raw audio pcm data) +pub extern "c" fn IsAudioStreamReady(stream: AudioStream) bool; // Checks if an audio stream is ready +pub extern "c" fn UnloadAudioStream(stream: AudioStream) void; // Unload audio stream and free memory +pub extern "c" fn UpdateAudioStream(stream: AudioStream, data: *const anyopaque, frameCount: c_int) void; // Update audio stream buffers with data +pub extern "c" fn IsAudioStreamProcessed(stream: AudioStream) bool; // Check if any audio stream buffers requires refill +pub extern "c" fn PlayAudioStream(stream: AudioStream) void; // Play audio stream +pub extern "c" fn PauseAudioStream(stream: AudioStream) void; // Pause audio stream +pub extern "c" fn ResumeAudioStream(stream: AudioStream) void; // Resume audio stream +pub extern "c" fn IsAudioStreamPlaying(stream: AudioStream) bool; // Check if audio stream is playing +pub extern "c" fn StopAudioStream(stream: AudioStream) void; // Stop audio stream +pub extern "c" fn SetAudioStreamVolume(stream: AudioStream, volume: f32) void; // Set volume for audio stream (1.0 is max level) +pub extern "c" fn SetAudioStreamPitch(stream: AudioStream, pitch: f32) void; // Set pitch for audio stream (1.0 is base level) +pub extern "c" fn SetAudioStreamPan(stream: AudioStream, pan: f32) void; // Set pan for audio stream (0.5 is centered) +pub extern "c" fn SetAudioStreamBufferSizeDefault(size: c_int) void; // Default size for new audio streams +pub extern "c" fn SetAudioStreamCallback(stream: AudioStream, callback: AudioCallback) void; // Audio thread callback to request new data + +pub extern "c" fn AttachAudioStreamProcessor(stream: AudioStream, processor: AudioCallback) void; // Attach audio stream processor to stream, receives the samples as s +pub extern "c" fn DetachAudioStreamProcessor(stream: AudioStream, processor: AudioCallback) void; // Detach audio stream processor from stream + +pub extern "c" fn AttachAudioMixedProcessor(processor: AudioCallback) void; // Attach audio stream processor to the entire audio pipeline, receives the samples as s +pub extern "c" fn DetachAudioMixedProcessor(processor: AudioCallback) void; // Detach audio stream processor from the entire audio pipeline diff --git a/bindings/rcamera.zig b/bindings/rcamera.zig new file mode 100644 index 0000000..c7e1909 --- /dev/null +++ b/bindings/rcamera.zig @@ -0,0 +1,40 @@ +// C Options added at build time. See options.rcamera.zig file +const options = @import("rcamera_options"); + +// rcamera.h file + +pub const Vector2 = @import("raylib.zig").Vector2; +pub const Vector3 = @import("raylib.zig").Vector3; +pub const Matrix = @import("raylib.zig").Matrix; +pub const Camera3D = @import("raylib.zig").Camera3D; +pub const Camera = Camera3D; + +pub const CameraProjection = @import("raylib.zig").CameraProjection; +pub const CameraMode = @import("raylib.zig").CameraMode; + +//---------------------------------------------------------------------------------- +// Module Functions Declaration +//---------------------------------------------------------------------------------- + +pub extern "c" fn GetCameraForward(camera: [*c]Camera) Vector3; +pub extern "c" fn GetCameraUp(camera: [*c]Camera) Vector3; +pub extern "c" fn GetCameraRight(camera: [*c]Camera) Vector3; + +// Camera movement +pub extern "c" fn CameraMoveForward(camera: [*c]Camera, distance: f32, moveInWorldPlane: bool) void; +pub extern "c" fn CameraMoveUp(camera: [*c]Camera, distance: f32) void; +pub extern "c" fn CameraMoveRight(camera: [*c]Camera, distance: f32, moveInWorldPlane: bool) void; +pub extern "c" fn CameraMoveToTarget(camera: [*c]Camera, delta: f32) void; + +// Camera rotation +pub extern "c" fn CameraYaw(camera: [*c]Camera, angle: f32, rotateAroundTarget: bool) void; +pub extern "c" fn CameraPitch(camera: [*c]Camera, angle: f32, lockView: bool, rotateAroundTarget: bool, rotateUp: bool) void; +pub extern "c" fn CameraRoll(camera: [*c]Camera, angle: f32) void; + +pub extern "c" fn GetCameraViewMatrix(camera: [*c]Camera) Matrix; +pub extern "c" fn GetCameraProjectionMatrix(camera: [*c]Camera, aspect: f32) Matrix; + +test { + const std = @import("std"); + std.testing.refAllDeclsRecursive(@This()); +} diff --git a/bindings/rlgl.zig b/bindings/rlgl.zig new file mode 100644 index 0000000..cead782 --- /dev/null +++ b/bindings/rlgl.zig @@ -0,0 +1,648 @@ +// Build options + +// Same as rlGlVersion / rlGetVersion +const GraphicsApi = enum(usize) { OPENGL_11 = 1, OPENGL_21, OPENGL_33, OPENGL_43, OPENGL_ES2, OPENGL_ES3 }; + +const std = @import("std"); + +// C Options to added at build time. See options.rlgl.zig file +// In raylib the default graphic api is OPENGL_33 +const options = @import("rlgl_options"); +const selected_graphics_api: GraphicsApi = std.meta.intToEnum(GraphicsApi, options.graphics_api) catch @panic("Failed to read `rlgl_options.graphics_api` value"); + +test { + const testing = std.testing; + std.testing.refAllDeclsRecursive(@This()); + try testing.expect(@intFromEnum(rlGetVersion()) == @intFromEnum(selected_graphics_api)); +} + +// rlgl.h file + +pub const RLGL_VERSION = "4.5"; + +//---------------------------------------------------------------------------------- +// Defines and Macros +//---------------------------------------------------------------------------------- + +// Texture parameters (equivalent to OpenGL defines) +pub const RL_TEXTURE_WRAP_S = 0x2802; // GL_TEXTURE_WRAP_S +pub const RL_TEXTURE_WRAP_T = 0x2803; // GL_TEXTURE_WRAP_T +pub const RL_TEXTURE_MAG_FILTER = 0x2800; // GL_TEXTURE_MAG_FILTER +pub const RL_TEXTURE_MIN_FILTER = 0x2801; // GL_TEXTURE_MIN_FILTER + +pub const RL_TEXTURE_FILTER_NEAREST = 0x2600; // GL_NEAREST +pub const RL_TEXTURE_FILTER_LINEAR = 0x2601; // GL_LINEAR +pub const RL_TEXTURE_FILTER_MIP_NEAREST = 0x2700; // GL_NEAREST_MIPMAP_NEAREST +pub const RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR = 0x2702; // GL_NEAREST_MIPMAP_LINEAR +pub const RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST = 0x2701; // GL_LINEAR_MIPMAP_NEAREST +pub const RL_TEXTURE_FILTER_MIP_LINEAR = 0x2703; // GL_LINEAR_MIPMAP_LINEAR +pub const RL_TEXTURE_FILTER_ANISOTROPIC = 0x3000; // Anisotropic filter (custom identifier) +pub const RL_TEXTURE_MIPMAP_BIAS_RATIO = 0x4000; // Texture mipmap bias, percentage ratio (custom identifier) + +pub const RL_TEXTURE_WRAP_REPEAT = 0x2901; // GL_REPEAT +pub const RL_TEXTURE_WRAP_CLAMP = 0x812F; // GL_CLAMP_TO_EDGE +pub const RL_TEXTURE_WRAP_MIRROR_REPEAT = 0x8370; // GL_MIRRORED_REPEAT +pub const RL_TEXTURE_WRAP_MIRROR_CLAMP = 0x8742; // GL_MIRROR_CLAMP_EXT + +// Matrix modes (equivalent to OpenGL) +pub const RL_MODELVIEW = 0x1700; // GL_MODELVIEW +pub const RL_PROJECTION = 0x1701; // GL_PROJECTION +pub const RL_TEXTURE = 0x1702; // GL_TEXTURE + +// Primitive assembly draw modes +pub const RL_LINES = 0x0001; // GL_LINES +pub const RL_TRIANGLES = 0x0004; // GL_TRIANGLES +pub const RL_QUADS = 0x0007; // GL_QUADS + +// GL equivalent data types +pub const RL_UNSIGNED_BYTE = 0x1401; // GL_UNSIGNED_BYTE +pub const RL_FLOAT = 0x1406; // GL_FLOAT + +// GL buffer usage hint +pub const RL_STREAM_DRAW = 0x88E0; // GL_STREAM_DRAW +pub const RL_STREAM_READ = 0x88E1; // GL_STREAM_READ +pub const RL_STREAM_COPY = 0x88E2; // GL_STREAM_COPY +pub const RL_STATIC_DRAW = 0x88E4; // GL_STATIC_DRAW +pub const RL_STATIC_READ = 0x88E5; // GL_STATIC_READ +pub const RL_STATIC_COPY = 0x88E6; // GL_STATIC_COPY +pub const RL_DYNAMIC_DRAW = 0x88E8; // GL_DYNAMIC_DRAW +pub const RL_DYNAMIC_READ = 0x88E9; // GL_DYNAMIC_READ +pub const RL_DYNAMIC_COPY = 0x88EA; // GL_DYNAMIC_COPY + +// GL Shader type +pub const RL_FRAGMENT_SHADER = 0x8B30; // GL_FRAGMENT_SHADER +pub const RL_VERTEX_SHADER = 0x8B31; // GL_VERTEX_SHADER +pub const RL_COMPUTE_SHADER = 0x91B9; // GL_COMPUTE_SHADER + +// GL blending factors +pub const RL_ZERO = 0; // GL_ZERO +pub const RL_ONE = 1; // GL_ONE +pub const RL_SRC_COLOR = 0x0300; // GL_SRC_COLOR +pub const RL_ONE_MINUS_SRC_COLOR = 0x0301; // GL_ONE_MINUS_SRC_COLOR +pub const RL_SRC_ALPHA = 0x0302; // GL_SRC_ALPHA +pub const RL_ONE_MINUS_SRC_ALPHA = 0x0303; // GL_ONE_MINUS_SRC_ALPHA +pub const RL_DST_ALPHA = 0x0304; // GL_DST_ALPHA +pub const RL_ONE_MINUS_DST_ALPHA = 0x0305; // GL_ONE_MINUS_DST_ALPHA +pub const RL_DST_COLOR = 0x0306; // GL_DST_COLOR +pub const RL_ONE_MINUS_DST_COLOR = 0x0307; // GL_ONE_MINUS_DST_COLOR +pub const RL_SRC_ALPHA_SATURATE = 0x0308; // GL_SRC_ALPHA_SATURATE +pub const RL_CONSTANT_COLOR = 0x8001; // GL_CONSTANT_COLOR +pub const RL_ONE_MINUS_CONSTANT_COLOR = 0x8002; // GL_ONE_MINUS_CONSTANT_COLOR +pub const RL_CONSTANT_ALPHA = 0x8003; // GL_CONSTANT_ALPHA +pub const RL_ONE_MINUS_CONSTANT_ALPHA = 0x8004; // GL_ONE_MINUS_CONSTANT_ALPHA + +// GL blending functions/equations +pub const RL_FUNC_ADD = 0x8006; // GL_FUNC_ADD +pub const RL_MIN = 0x8007; // GL_MIN +pub const RL_MAX = 0x8008; // GL_MAX +pub const RL_FUNC_SUBTRACT = 0x800A; // GL_FUNC_SUBTRACT +pub const RL_FUNC_REVERSE_SUBTRACT = 0x800B; // GL_FUNC_REVERSE_SUBTRACT +pub const RL_BLEND_EQUATION = 0x8009; // GL_BLEND_EQUATION +pub const RL_BLEND_EQUATION_RGB = 0x8009; // GL_BLEND_EQUATION_RGB // (Same as BLEND_EQUATION) +pub const RL_BLEND_EQUATION_ALPHA = 0x883D; // GL_BLEND_EQUATION_ALPHA +pub const RL_BLEND_DST_RGB = 0x80C8; // GL_BLEND_DST_RGB +pub const RL_BLEND_SRC_RGB = 0x80C9; // GL_BLEND_SRC_RGB +pub const RL_BLEND_DST_ALPHA = 0x80CA; // GL_BLEND_DST_ALPHA +pub const RL_BLEND_SRC_ALPHA = 0x80CB; // GL_BLEND_SRC_ALPHA +pub const RL_BLEND_COLOR = 0x8005; // GL_BLEND_COLOR + +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- + +// Matrix, 4x4 components, column major, OpenGL style, right handed +const Matrix = @import("raylib.zig").Matrix; + +pub const rlVertexBuffer_GL33 = rlVertexBuffer_GL11; +pub const rlVertexBuffer_GL11 = extern struct { + elementCount: c_int, // Number of elements in the buffer (QUADS) + vertices: [*c]f32, // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) + texcoords: [*c]f32, // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) + colors: [*c]u8, // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) + + indices: [*c]c_uint, // Vertex indices (in case vertex data comes indexed) (6 indices per quad) + + vaoId: c_uint, // OpenGL Vertex Array Object id + vboId: [4]c_uint, // OpenGL Vertex Buffer Objects id (4 types of vertex data) + + pub fn init(elementCount: c_int, vertices: [*c]f32, texcoords: [*c]f32, colors: [*c]u8, indices: [*c]c_uint, vaoId: c_uint, vboId: [4]c_uint) @This() { + return @This(){ .elementCount = elementCount, .vertices = vertices, .texcoords = texcoords, .colors = colors, .indices = indices, .vaoId = vaoId, .vboId = vboId }; + } +}; + +pub const rlVertexBuffer_GLES2 = extern struct { + elementCount: c_int, // Number of elements in the buffer (QUADS) + vertices: [*c]f32, // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) + texcoords: [*c]f32, // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) + colors: [*c]u8, // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) + + indices: [*c]c_ushort, // Vertex indices (in case vertex data comes indexed) (6 indices per quad) + + vaoId: c_uint, // OpenGL Vertex Array Object id + vboId: [4]c_uint, // OpenGL Vertex Buffer Objects id (4 types of vertex data) + + pub fn init(elementCount: c_int, vertices: [*c]f32, texcoords: [*c]f32, colors: [*c]u8, indices: [*c]c_ushort, vaoId: c_uint, vboId: [4]c_uint) @This() { + return @This(){ .elementCount = elementCount, .vertices = vertices, .texcoords = texcoords, .colors = colors, .indices = indices, .vaoId = vaoId, .vboId = vboId }; + } +}; + +pub const rlVertexBuffer_DEFAULT = extern struct { + elementCount: c_int, // Number of elements in the buffer (QUADS) + vertices: [*c]f32, // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) + texcoords: [*c]f32, // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) + colors: [*c]u8, // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) + + vaoId: c_uint, // OpenGL Vertex Array Object id + vboId: [4]c_uint, // OpenGL Vertex Buffer Objects id (4 types of vertex data) + + pub fn init(elementCount: c_int, vertices: [*c]f32, texcoords: [*c]f32, colors: [*c]u8, vaoId: c_uint, vboId: [4]c_uint) @This() { + return @This(){ .elementCount = elementCount, .vertices = vertices, .texcoords = texcoords, .colors = colors, .vaoId = vaoId, .vboId = vboId }; + } +}; + +pub const rlVertexBuffer = switch (selected_graphics_api) { + GraphicsApi.OPENGL_11 => rlVertexBuffer_GL11, + GraphicsApi.OPENGL_33 => rlVertexBuffer_GL33, + GraphicsApi.OPENGL_ES2 => rlVertexBuffer_GLES2, + else => rlVertexBuffer_DEFAULT, +}; + +// Draw call type +// NOTE: Only texture changes register a new draw, other state-change-related elements are not +// used at this moment (vaoId, shaderId, matrices), raylib just forces a batch draw call if any +// of those state-change happens (this is done in core module) +pub const rlDrawCall = extern struct { + mode: c_uint, // Drawing mode: LINES, TRIANGLES, QUADS + vertexCount: c_uint, // Number of vertex of the draw + vertexAlignment: c_uint, // Number of vertex required for index alignment (LINES, TRIANGLES) + //unsigned int vaoId; // Vertex array id to be used on the draw -> Using RLGL.currentBatch->vertexBuffer.vaoId + //unsigned int shaderId; // Shader id to be used on the draw -> Using RLGL.currentShaderId + textureId: c_uint, // Texture id to be used on the draw -> Use to create new draw call if changes + + //Matrix projection; // Projection matrix for this draw -> Using RLGL.projection by default + //Matrix modelview; // Modelview matrix for this draw -> Using RLGL.modelview by default + + pub fn init(mode: c_uint, vertexCount: c_uint, vertexAlignment: c_uint, textureId: c_uint) rlDrawCall { + return rlDrawCall{ .mode = mode, .vertexCount = vertexCount, .vertexAlignment = vertexAlignment, .textureId = textureId }; + } +}; + +// rlRenderBatch type +pub const rlRenderBatch = extern struct { + bufferCount: c_int, // Number of vertex buffers (multi-buffering support) + currentBuffer: c_int, // Current buffer tracking in case of multi-buffering + vertexBuffer: [*c]rlVertexBuffer, // Dynamic buffer(s) for vertex data + + draws: [*c]rlDrawCall, // Draw calls array, depends on textureId + drawCounter: c_int, // Draw calls counter + currentDepth: f32, // Current depth value for next draw + pub fn init(bufferCount: c_int, currentBuffer: c_int, vertexBuffer: [*c]rlVertexBuffer, draws: [*c]rlDrawCall, drawCounter: c_int, currentDepth: f32) rlRenderBatch { + return rlRenderBatch{ .bufferCount = bufferCount, .currentBuffer = currentBuffer, .vertexBuffer = vertexBuffer, .draws = draws, .drawCounter = drawCounter, .currentDepth = currentDepth }; + } +}; + +// OpenGL version +pub const rlGlVersion = enum(c_int) { + RL_OPENGL_11 = 1, // OpenGL 1.1 + RL_OPENGL_21, // OpenGL 2.1 (GLSL 120) + RL_OPENGL_33, // OpenGL 3.3 (GLSL 330) + RL_OPENGL_43, // OpenGL 4.3 (using GLSL 330) + RL_OPENGL_ES_20, // OpenGL ES 2.0 (GLSL 100) + RL_OPENGL_ES_30, // OpenGL ES 3.0 (GLSL 300 es) + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Trace log level +// NOTE: Organized by priority level +pub const rlTraceLogLevel = enum(c_int) { + RL_LOG_ALL = 0, // Display all logs + RL_LOG_TRACE, // Trace logging, intended for internal use only + RL_LOG_DEBUG, // Debug logging, used for internal debugging, it should be disabled on release builds + RL_LOG_INFO, // Info logging, used for program execution info + RL_LOG_WARNING, // Warning logging, used on recoverable failures + RL_LOG_ERROR, // Error logging, used on unrecoverable failures + RL_LOG_FATAL, // Fatal logging, used to abort program: exit(EXIT_FAILURE) + RL_LOG_NONE, // Disable logging + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Texture pixel formats +// NOTE: Support depends on OpenGL version +pub const rlPixelFormat = enum(c_int) { + RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha) + RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels) + RL_PIXELFORMAT_UNCOMPRESSED_R5G6B5, // 16 bpp + RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8, // 24 bpp + RL_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha) + RL_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha) + RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, // 32 bpp + RL_PIXELFORMAT_UNCOMPRESSED_R32, // 32 bpp (1 channel - float) + RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float) + RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float) + RL_PIXELFORMAT_UNCOMPRESSED_R16, // 16 bpp (1 channel - half float) + RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16, // 16*3 bpp (3 channels - half float) + RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16, // 16*4 bpp (4 channels - half float) + RL_PIXELFORMAT_COMPRESSED_DXT1_RGB, // 4 bpp (no alpha) + RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha) + RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA, // 8 bpp + RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA, // 8 bpp + RL_PIXELFORMAT_COMPRESSED_ETC1_RGB, // 4 bpp + RL_PIXELFORMAT_COMPRESSED_ETC2_RGB, // 4 bpp + RL_PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA, // 8 bpp + RL_PIXELFORMAT_COMPRESSED_PVRT_RGB, // 4 bpp + RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA, // 4 bpp + RL_PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA, // 8 bpp + RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA, // 2 bpp + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Texture parameters: filter mode +// NOTE 1: Filtering considers mipmaps if available in the texture +// NOTE 2: Filter is accordingly set for minification and magnification +pub const rlTextureFilter = enum(c_int) { + RL_TEXTURE_FILTER_POINT = 0, // No filter, just pixel approximation + RL_TEXTURE_FILTER_BILINEAR, // Linear filtering + RL_TEXTURE_FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps) + RL_TEXTURE_FILTER_ANISOTROPIC_4X, // Anisotropic filtering 4x + RL_TEXTURE_FILTER_ANISOTROPIC_8X, // Anisotropic filtering 8x + RL_TEXTURE_FILTER_ANISOTROPIC_16X, // Anisotropic filtering 16x + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Color blending modes (pre-defined) +pub const rlBlendMode = enum(c_int) { + RL_BLEND_ALPHA = 0, // Blend textures considering alpha (default) + RL_BLEND_ADDITIVE, // Blend textures adding colors + RL_BLEND_MULTIPLIED, // Blend textures multiplying colors + RL_BLEND_ADD_COLORS, // Blend textures adding colors (alternative) + RL_BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative) + RL_BLEND_ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha + RL_BLEND_CUSTOM, // Blend textures using custom src/dst factors (use rlSetBlendFactors()) + RL_BLEND_CUSTOM_SEPARATE, // Blend textures using custom src/dst factors (use rlSetBlendFactorsSeparate()) + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Shader location point type +pub const rlShaderLocationIndex = enum(c_int) { + RL_SHADER_LOC_VERTEX_POSITION = 0, // Shader location: vertex attribute: position + RL_SHADER_LOC_VERTEX_TEXCOORD01, // Shader location: vertex attribute: texcoord01 + RL_SHADER_LOC_VERTEX_TEXCOORD02, // Shader location: vertex attribute: texcoord02 + RL_SHADER_LOC_VERTEX_NORMAL, // Shader location: vertex attribute: normal + RL_SHADER_LOC_VERTEX_TANGENT, // Shader location: vertex attribute: tangent + RL_SHADER_LOC_VERTEX_COLOR, // Shader location: vertex attribute: color + RL_SHADER_LOC_MATRIX_MVP, // Shader location: matrix uniform: model-view-projection + RL_SHADER_LOC_MATRIX_VIEW, // Shader location: matrix uniform: view (camera transform) + RL_SHADER_LOC_MATRIX_PROJECTION, // Shader location: matrix uniform: projection + RL_SHADER_LOC_MATRIX_MODEL, // Shader location: matrix uniform: model (transform) + RL_SHADER_LOC_MATRIX_NORMAL, // Shader location: matrix uniform: normal + RL_SHADER_LOC_VECTOR_VIEW, // Shader location: vector uniform: view + RL_SHADER_LOC_COLOR_DIFFUSE, // Shader location: vector uniform: diffuse color + RL_SHADER_LOC_COLOR_SPECULAR, // Shader location: vector uniform: specular color + RL_SHADER_LOC_COLOR_AMBIENT, // Shader location: vector uniform: ambient color + RL_SHADER_LOC_MAP_ALBEDO, // Shader location: sampler2d texture: albedo (same as: RL_SHADER_LOC_MAP_DIFFUSE) + RL_SHADER_LOC_MAP_METALNESS, // Shader location: sampler2d texture: metalness (same as: RL_SHADER_LOC_MAP_SPECULAR) + RL_SHADER_LOC_MAP_NORMAL, // Shader location: sampler2d texture: normal + RL_SHADER_LOC_MAP_ROUGHNESS, // Shader location: sampler2d texture: roughness + RL_SHADER_LOC_MAP_OCCLUSION, // Shader location: sampler2d texture: occlusion + RL_SHADER_LOC_MAP_EMISSION, // Shader location: sampler2d texture: emission + RL_SHADER_LOC_MAP_HEIGHT, // Shader location: sampler2d texture: height + RL_SHADER_LOC_MAP_CUBEMAP, // Shader location: samplerCube texture: cubemap + RL_SHADER_LOC_MAP_IRRADIANCE, // Shader location: samplerCube texture: irradiance + RL_SHADER_LOC_MAP_PREFILTER, // Shader location: samplerCube texture: prefilter + RL_SHADER_LOC_MAP_BRDF, // Shader location: sampler2d texture: brdf + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +pub const RL_SHADER_LOC_MAP_DIFFUSE = rlShaderLocationIndex.RL_SHADER_LOC_MAP_ALBEDO; +pub const RL_SHADER_LOC_MAP_SPECULAR = rlShaderLocationIndex.RL_SHADER_LOC_MAP_METALNESS; + +// Shader uniform data type +pub const rlShaderUniformDataType = enum(c_int) { + RL_SHADER_UNIFORM_FLOAT = 0, // Shader uniform type: float + RL_SHADER_UNIFORM_VEC2, // Shader uniform type: vec2 (2 float) + RL_SHADER_UNIFORM_VEC3, // Shader uniform type: vec3 (3 float) + RL_SHADER_UNIFORM_VEC4, // Shader uniform type: vec4 (4 float) + RL_SHADER_UNIFORM_INT, // Shader uniform type: int + RL_SHADER_UNIFORM_IVEC2, // Shader uniform type: ivec2 (2 int) + RL_SHADER_UNIFORM_IVEC3, // Shader uniform type: ivec3 (3 int) + RL_SHADER_UNIFORM_IVEC4, // Shader uniform type: ivec4 (4 int) + RL_SHADER_UNIFORM_SAMPLER2D, // Shader uniform type: sampler2d + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Shader attribute data types +pub const rlShaderAttributeDataType = enum(c_int) { + RL_SHADER_ATTRIB_FLOAT = 0, // Shader attribute type: float + RL_SHADER_ATTRIB_VEC2, // Shader attribute type: vec2 (2 float) + RL_SHADER_ATTRIB_VEC3, // Shader attribute type: vec3 (3 float) + RL_SHADER_ATTRIB_VEC4, // Shader attribute type: vec4 (4 float) + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Framebuffer attachment type +// NOTE: By default up to 8 color channels defined, but it can be more +pub const rlFramebufferAttachType = enum(c_int) { + RL_ATTACHMENT_COLOR_CHANNEL0 = 0, // Framebuffer attachment type: color 0 + RL_ATTACHMENT_COLOR_CHANNEL1 = 1, // Framebuffer attachment type: color 1 + RL_ATTACHMENT_COLOR_CHANNEL2 = 2, // Framebuffer attachment type: color 2 + RL_ATTACHMENT_COLOR_CHANNEL3 = 3, // Framebuffer attachment type: color 3 + RL_ATTACHMENT_COLOR_CHANNEL4 = 4, // Framebuffer attachment type: color 4 + RL_ATTACHMENT_COLOR_CHANNEL5 = 5, // Framebuffer attachment type: color 5 + RL_ATTACHMENT_COLOR_CHANNEL6 = 6, // Framebuffer attachment type: color 6 + RL_ATTACHMENT_COLOR_CHANNEL7 = 7, // Framebuffer attachment type: color 7 + RL_ATTACHMENT_DEPTH = 100, // Framebuffer attachment type: depth + RL_ATTACHMENT_STENCIL = 200, // Framebuffer attachment type: stencil + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Framebuffer texture attachment type +pub const rlFramebufferAttachTextureType = enum(c_int) { + RL_ATTACHMENT_CUBEMAP_POSITIVE_X = 0, // Framebuffer texture attachment type: cubemap, +X side + RL_ATTACHMENT_CUBEMAP_NEGATIVE_X = 1, // Framebuffer texture attachment type: cubemap, -X side + RL_ATTACHMENT_CUBEMAP_POSITIVE_Y = 2, // Framebuffer texture attachment type: cubemap, +Y side + RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y = 3, // Framebuffer texture attachment type: cubemap, -Y side + RL_ATTACHMENT_CUBEMAP_POSITIVE_Z = 4, // Framebuffer texture attachment type: cubemap, +Z side + RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z = 5, // Framebuffer texture attachment type: cubemap, -Z side + RL_ATTACHMENT_TEXTURE2D = 100, // Framebuffer texture attachment type: texture2d + RL_ATTACHMENT_RENDERBUFFER = 200, // Framebuffer texture attachment type: renderbuffer + + pub fn fromValue(value: c_int) !@This() { + return try std.meta.intToEnum(@This(), value); + } + + pub fn toValue(self: @This()) c_int { + return @intFromEnum(self); + } +}; + +// Face culling mode +pub const rlCullMode = enum(c_int) { RL_CULL_FACE_FRONT = 0, RL_CULL_FACE_BACK }; + +//------------------------------------------------------------------------------------ +// Functions Declaration - Matrix operations +//------------------------------------------------------------------------------------ + +pub extern fn rlMatrixMode(mode: c_int) void; // Choose the current matrix to be transformed +pub extern fn rlPushMatrix() void; // Push the current matrix to stack +pub extern fn rlPopMatrix() void; // Pop latest inserted matrix from stack +pub extern fn rlLoadIdentity() void; // Reset current matrix to identity matrix +pub extern fn rlTranslatef(x: f32, y: f32, z: f32) void; // Multiply the current matrix by a translation matrix +pub extern fn rlRotatef(angle: f32, x: f32, y: f32, z: f32) void; // Multiply the current matrix by a rotation matrix +pub extern fn rlScalef(x: f32, y: f32, z: f32) void; // Multiply the current matrix by a scaling matrix +pub extern fn rlMultMatrixf(matf: [*c]const f32) void; // Multiply the current matrix by another matrix +pub extern fn rlFrustum(left: f64, right: f64, bottom: f64, top: f64, znear: f64, zfar: f64) void; +pub extern fn rlOrtho(left: f64, right: f64, bottom: f64, top: f64, znear: f64, zfar: f64) void; +pub extern fn rlViewport(x: c_int, y: c_int, width: c_int, height: c_int) void; // Set the viewport area + +//------------------------------------------------------------------------------------ +// Functions Declaration - Vertex level operations +//------------------------------------------------------------------------------------ +pub extern fn rlBegin(mode: c_int) void; // Initialize drawing mode (how to organize vertex) +pub extern fn rlEnd() void; // Finish vertex providing +pub extern fn rlVertex2i(x: c_int, y: c_int) void; // Define one vertex (position) - 2 int +pub extern fn rlVertex2f(x: f32, y: f32) void; // Define one vertex (position) - 2 float +pub extern fn rlVertex3f(x: f32, y: f32, z: f32) void; // Define one vertex (position) - 3 float +pub extern fn rlTexCoord2f(x: f32, y: f32) void; // Define one vertex (texture coordinate) - 2 float +pub extern fn rlNormal3f(x: f32, y: f32, z: f32) void; // Define one vertex (normal) - 3 float +pub extern fn rlColor4ub(r: u8, g: u8, b: u8, a: u8) void; // Define one vertex (color) - 4 byte +pub extern fn rlColor3f(x: f32, y: f32, z: f32) void; // Define one vertex (color) - 3 float +pub extern fn rlColor4f(x: f32, y: f32, z: f32, w: f32) void; // Define one vertex (color) - 4 float + +//------------------------------------------------------------------------------------ +// Functions Declaration - OpenGL style functions (common to 1.1, 3.3+, ES2) +// NOTE: This functions are used to completely abstract raylib code from OpenGL layer, +// some of them are direct wrappers over OpenGL calls, some others are custom +//------------------------------------------------------------------------------------ + +// Vertex buffers state +pub extern fn rlEnableVertexArray(vaoId: c_uint) bool; // Enable vertex array (VAO, if supported) +pub extern fn rlDisableVertexArray() void; // Disable vertex array (VAO, if supported) +pub extern fn rlEnableVertexBuffer(id: c_uint) void; // Enable vertex buffer (VBO) +pub extern fn rlDisableVertexBuffer() void; // Disable vertex buffer (VBO) +pub extern fn rlEnableVertexBufferElement(id: c_uint) void; // Enable vertex buffer element (VBO element) +pub extern fn rlDisableVertexBufferElement() void; // Disable vertex buffer element (VBO element) +pub extern fn rlEnableVertexAttribute(index: c_uint) void; // Enable vertex attribute index +pub extern fn rlDisableVertexAttribute(index: c_uint) void; // Disable vertex attribute index + +pub extern "c" fn rlEnableStatePointer(vertexAttribType: c_int, buffer: *anyopaque) void; // Enable attribute state pointer +pub extern "c" fn rlDisableStatePointer(vertexAttribType: c_int) void; // Disable attribute state pointer + +// Textures state +pub extern fn rlActiveTextureSlot(slot: c_int) void; // Select and active a texture slot +pub extern fn rlEnableTexture(id: c_uint) void; // Enable texture +pub extern fn rlDisableTexture() void; // Disable texture +pub extern fn rlEnableTextureCubemap(id: c_uint) void; // Enable texture cubemap +pub extern fn rlDisableTextureCubemap() void; // Disable texture cubemap +pub extern fn rlTextureParameters(id: c_uint, param: c_int, value: c_int) void; // Set texture parameters (filter, wrap) +pub extern fn rlCubemapParameters(id: c_uint, param: c_int, value: c_int) void; // Set cubemap parameters (filter, wrap) + +// Shader state +pub extern fn rlEnableShader(id: c_uint) void; // Enable shader program +pub extern fn rlDisableShader() void; // Disable shader program + +// Framebuffer state +pub extern fn rlEnableFramebuffer(id: c_uint) void; // Enable render texture (fbo) +pub extern fn rlDisableFramebuffer() void; // Disable render texture (fbo), return to default framebuffer +pub extern fn rlActiveDrawBuffers(count: c_int) void; // Activate multiple draw color buffers +pub extern fn rlBlitFramebuffer(srcX: c_int, srcY: c_int, srcWidth: c_int, srcHeight: c_int, dstX: c_int, dstY: c_int, dstWidth: c_int, dstHeight: c_int, bufferMask: c_int) void; // Blit active framebuffer to main framebuffer + +// General render state +pub extern fn rlEnableColorBlend() void; // Disable color blending +pub extern fn rlDisableColorBlend() void; // Enable depth test +pub extern fn rlEnableDepthTest() void; // Disable depth test +pub extern fn rlDisableDepthTest() void; // Enable depth write +pub extern fn rlEnableDepthMask() void; // Disable depth write +pub extern fn rlDisableDepthMask() void; // Enable backface culling +pub extern fn rlEnableBackfaceCulling() void; // Disable backface culling +pub extern fn rlDisableBackfaceCulling() void; // Set face culling mode +pub extern fn rlSetCullFace(mode: c_int) void; // Enable scissor test +pub extern fn rlEnableScissorTest() void; // Disable scissor test +pub extern fn rlDisableScissorTest() void; // Scissor test +pub extern fn rlScissor(x: c_int, y: c_int, width: c_int, height: c_int) void; // Enable wire mode +pub extern fn rlEnableWireMode() void; // Enable point mode +pub extern fn rlEnablePointMode() void; // Disable wire mode ( and point ) maybe rename +pub extern fn rlDisableWireMode() void; // Set the line drawing width +pub extern fn rlSetLineWidth(width: f32) void; // Get the line drawing width +pub extern fn rlGetLineWidth() f32; // Enable line aliasing +pub extern fn rlEnableSmoothLines() void; // Disable line aliasing +pub extern fn rlDisableSmoothLines() void; // Enable stereo rendering +pub extern fn rlEnableStereoRender() void; // Disable stereo rendering +pub extern fn rlDisableStereoRender() void; // Check if stereo render is enabled + +pub extern fn rlClearColor(r: u8, g: u8, b: u8, a: u8) void; // Clear color buffer with color +pub extern fn rlClearScreenBuffers() void; // Clear used screen buffers (color and depth) +pub extern fn rlCheckErrors() void; // Check and log OpenGL error codes +pub extern fn rlSetBlendMode(mode: c_int) void; // Set blending mode +pub extern fn rlSetBlendFactors(glSrcFactor: c_int, glDstFactor: c_int, glEquation: c_int) void; // Set blending mode factor and equation (using OpenGL factors) +pub extern fn rlSetBlendFactorsSeparate(glSrcRGB: c_int, glDstRGB: c_int, glSrcAlpha: c_int, glDstAlpha: c_int, glEqRGB: c_int, glEqAlpha: c_int) void; // Set blending mode factors and equations separately (using OpenGL factors) + +//------------------------------------------------------------------------------------ +// Functions Declaration - rlgl functionality +//------------------------------------------------------------------------------------ +// rlgl initialization functions +pub extern fn rlglInit(width: c_int, height: c_int) void; // Initialize rlgl (buffers, shaders, textures, states) +pub extern fn rlglClose() void; // De-initialize rlgl (buffers, shaders, textures) +pub extern fn rlLoadExtensions(loader: ?*anyopaque) void; // Load OpenGL extensions (loader function required) +pub extern fn rlGetVersion() rlGlVersion; // Get current OpenGL version +pub extern fn rlSetFramebufferWidth(width: c_int) void; // Set current framebuffer width +pub extern fn rlGetFramebufferWidth() c_int; // Get default framebuffer width +pub extern fn rlSetFramebufferHeight(height: c_int) void; // Set current framebuffer height +pub extern fn rlGetFramebufferHeight() c_int; // Get default framebuffer height + +pub extern fn rlGetTextureIdDefault() c_uint; // Get default texture id +pub extern fn rlGetShaderIdDefault() c_uint; // Get default shader id +pub extern fn rlGetShaderLocsDefault() [*c]c_int; // Get default shader locations + +// Render batch management +// NOTE: rlgl provides a default render batch to behave like OpenGL 1.1 immediate mode +// but this render batch API is exposed in case of custom batches are required +pub extern fn rlLoadRenderBatch(numBuffers: c_int, bufferElements: c_int) rlRenderBatch; // Load a render batch system +pub extern fn rlUnloadRenderBatch(batch: rlRenderBatch) void; // Unload render batch system +pub extern fn rlDrawRenderBatch(batch: [*c]rlRenderBatch) void; // Draw render batch data (Update->Draw->Reset) +pub extern fn rlSetRenderBatchActive(batch: [*c]rlRenderBatch) void; // Set the active render batch for rlgl (NULL for default internal) +pub extern fn rlDrawRenderBatchActive() void; // Update and draw internal render batch +pub extern fn rlCheckRenderBatchLimit(vCount: c_int) bool; // Check internal buffer overflow for a given number of vertex + +pub extern fn rlSetTexture(id: c_uint) void; // Set current texture for render batch and check buffers limits + +//------------------------------------------------------------------------------------------------------------------------ + +// Vertex buffers management +pub extern fn rlLoadVertexArray() c_uint; // Load vertex array (vao) if supported +pub extern fn rlLoadVertexBuffer(buffer: ?*const anyopaque, size: c_int, dynamic: bool) c_uint; // Load a vertex buffer attribute +pub extern fn rlLoadVertexBufferElement(buffer: ?*const anyopaque, size: c_int, dynamic: bool) c_uint; // Load a new attributes element buffer +pub extern fn rlUpdateVertexBuffer(bufferId: c_uint, data: ?*const anyopaque, dataSize: c_int, offset: c_int) void; // Update GPU buffer with new data +pub extern fn rlUpdateVertexBufferElements(id: c_uint, data: ?*const anyopaque, dataSize: c_int, offset: c_int) void; // Update vertex buffer elements with new data +pub extern fn rlUnloadVertexArray(vaoId: c_uint) void; +pub extern fn rlUnloadVertexBuffer(vboId: c_uint) void; +pub extern fn rlSetVertexAttribute(index: c_uint, compSize: c_int, @"type": c_int, normalized: bool, stride: c_int, pointer: ?*const anyopaque) void; +pub extern fn rlSetVertexAttributeDivisor(index: c_uint, divisor: c_int) void; +pub extern fn rlSetVertexAttributeDefault(locIndex: c_int, value: ?*const anyopaque, attribType: c_int, count: c_int) void; // Set vertex attribute default value +pub extern fn rlDrawVertexArray(offset: c_int, count: c_int) void; +pub extern fn rlDrawVertexArrayElements(offset: c_int, count: c_int, buffer: ?*const anyopaque) void; +pub extern fn rlDrawVertexArrayInstanced(offset: c_int, count: c_int, instances: c_int) void; +pub extern fn rlDrawVertexArrayElementsInstanced(offset: c_int, count: c_int, buffer: ?*const anyopaque, instances: c_int) void; + +// Textures management +pub extern fn rlLoadTexture(data: ?*const anyopaque, width: c_int, height: c_int, format: c_int, mipmapCount: c_int) c_uint; // Load texture in GPU +pub extern fn rlLoadTextureDepth(width: c_int, height: c_int, useRenderBuffer: bool) c_uint; // Load depth texture/renderbuffer (to be attached to fbo) +pub extern fn rlLoadTextureCubemap(data: ?*const anyopaque, size: c_int, format: c_int) c_uint; // Load texture cubemap +pub extern fn rlUpdateTexture(id: c_uint, offsetX: c_int, offsetY: c_int, width: c_int, height: c_int, format: c_int, data: ?*const anyopaque) void; // Update GPU texture with new data +pub extern fn rlGetGlTextureFormats(format: c_int, glInternalFormat: [*c]c_uint, glFormat: [*c]c_uint, glType: [*c]c_uint) void; // Get OpenGL internal formats +pub extern fn rlGetPixelFormatName(format: c_int) [*c]const u8; // Get name string for pixel format +pub extern fn rlUnloadTexture(id: c_uint) void; // Unload texture from GPU memory +pub extern fn rlGenTextureMipmaps(id: c_uint, width: c_int, height: c_int, format: c_int, mipmaps: [*c]c_int) void; // Generate mipmap data for selected texture +pub extern fn rlReadTexturePixels(id: c_uint, width: c_int, height: c_int, format: c_int) ?*anyopaque; // Read texture pixel data +pub extern fn rlReadScreenPixels(width: c_int, height: c_int) [*c]u8; // Read screen pixel data (color buffer) + +// Framebuffer management (fbo) +pub extern fn rlLoadFramebuffer(width: c_int, height: c_int) c_uint; // Load an empty framebuffer +pub extern fn rlFramebufferAttach(fboId: c_uint, texId: c_uint, attachType: c_int, texType: c_int, mipLevel: c_int) void; // Attach texture/renderbuffer to a framebuffer +pub extern fn rlFramebufferComplete(id: c_uint) bool; // Verify framebuffer is complete +pub extern fn rlUnloadFramebuffer(id: c_uint) void; // Delete framebuffer from GPU + +// Shaders management +pub extern fn rlLoadShaderCode(vsCode: [*c]const u8, fsCode: [*c]const u8) c_uint; // Load shader from code strings +pub extern fn rlCompileShader(shaderCode: [*c]const u8, @"type": c_int) c_uint; // Compile custom shader and return shader id (type: RL_VERTEX_SHADER, RL_FRAGMENT_SHADER, RL_COMPUTE_SHADER) +pub extern fn rlLoadShaderProgram(vShaderId: c_uint, fShaderId: c_uint) c_uint; // Load custom shader program +pub extern fn rlUnloadShaderProgram(id: c_uint) void; // Unload shader program +pub extern fn rlGetLocationUniform(shaderId: c_uint, uniformName: [*c]const u8) c_int; // Get shader location uniform +pub extern fn rlGetLocationAttrib(shaderId: c_uint, attribName: [*c]const u8) c_int; // Get shader location attribute +pub extern fn rlSetUniform(locIndex: c_int, value: ?*const anyopaque, uniformType: c_int, count: c_int) void; // Set shader value uniform +pub extern fn rlSetUniformMatrix(locIndex: c_int, mat: Matrix) void; // Set shader value matrix +pub extern fn rlSetUniformSampler(locIndex: c_int, textureId: c_uint) void; // Set shader value sampler +pub extern fn rlSetShader(id: c_uint, locs: [*c]c_int) void; // Set shader currently active (id and locations) + +// Compute shader management +pub extern fn rlLoadComputeShaderProgram(shaderId: c_uint) c_uint; // Load compute shader program +pub extern fn rlComputeShaderDispatch(groupX: c_uint, groupY: c_uint, groupZ: c_uint) void; // Dispatch compute shader (equivalent to *draw* for graphics pipeline) + +// Shader buffer storage object management (ssbo) +pub extern fn rlLoadShaderBuffer(size: c_uint, data: ?*const anyopaque, usageHint: c_int) c_uint; // Load shader storage buffer object (SSBO) +pub extern fn rlUnloadShaderBuffer(ssboId: c_uint) void; // Unload shader storage buffer object (SSBO) +pub extern fn rlUpdateShaderBuffer(id: c_uint, data: ?*const anyopaque, dataSize: c_uint, offset: c_uint) void; // Update SSBO buffer data +pub extern fn rlBindShaderBuffer(id: c_uint, index: c_uint) void; // Bind SSBO buffer +pub extern fn rlReadShaderBuffer(id: c_uint, dest: ?*anyopaque, count: c_uint, offset: c_uint) void; // Read SSBO buffer data (GPU->CPU) +pub extern fn rlCopyShaderBuffer(destId: c_uint, srcId: c_uint, destOffset: c_uint, srcOffset: c_uint, count: c_uint) void; // Copy SSBO data between buffers +pub extern fn rlGetShaderBufferSize(id: c_uint) c_uint; // Get SSBO buffer size + +// Buffer management +pub extern fn rlBindImageTexture(id: c_uint, index: c_uint, format: c_int, readonly: bool) void; // Bind image texture + +// Matrix state management +pub extern fn rlGetMatrixModelview() Matrix; // Get internal modelview matrix +pub extern fn rlGetMatrixProjection() Matrix; // Get internal projection matrix +pub extern fn rlGetMatrixTransform() Matrix; // Get internal accumulated transform matrix +pub extern fn rlGetMatrixProjectionStereo(eye: c_int) Matrix; // Get internal projection matrix for stereo render (selected eye) +pub extern fn rlGetMatrixViewOffsetStereo(eye: c_int) Matrix; // Get internal view offset matrix for stereo render (selected eye) +pub extern fn rlSetMatrixProjection(proj: Matrix) void; // Set a custom projection matrix (replaces internal projection matrix) +pub extern fn rlSetMatrixModelview(view: Matrix) void; // Set a custom modelview matrix (replaces internal modelview matrix) +pub extern fn rlSetMatrixProjectionStereo(right: Matrix, left: Matrix) void; // Set eyes projection matrices for stereo rendering +pub extern fn rlSetMatrixViewOffsetStereo(right: Matrix, left: Matrix) void; // Set eyes view offsets matrices for stereo rendering + +// Quick and dirty cube/quad buffers load->draw->unload +pub extern fn rlLoadDrawCube() void; // Load and draw a cube +pub extern fn rlLoadDrawQuad() void; // Load and draw a quad diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..93ad61f --- /dev/null +++ b/build.zig @@ -0,0 +1,18 @@ +const std = @import("std"); + +pub const raylib = @import("raylib.build.zig"); +pub const Setup = raylib.RaylibSetup; + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + _ = b.addModule("raylib-zig-bindings", .{ + .root_source_file = .{ .src_path = .{ + .owner = b, + .sub_path = "bindings/bindings.zig", + } }, + .target = target, + .optimize = optimize, + }); +} + diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..12f258a --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,12 @@ +.{ + .name = "raylib-zig-bindings", + .version = "5.0.0", + .paths = .{ + "build.zig", + "build.zig.zon", + "raylib.build.zig", + "LICENSE", + "bindings", + "build", + }, +} diff --git a/make_tar_release.sh b/make_tar_release.sh new file mode 100755 index 0000000..102e3ae --- /dev/null +++ b/make_tar_release.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +FILES=( + "bindings/bindings.zig" + "bindings/raylib.zig" + "bindings/raygui.zig" + "bindings/rcamera.zig" + "bindings/rlgl.zig" + "build.zig" + "build.zig.zon" + "raylib.build.zig" + "LICENSE" +) + +tar -czvf release.tar.gz ${FILES[@]} \ No newline at end of file diff --git a/raygui_screenshot.png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7MZIiI`EW+!;HQ+nFBOA^YJX6nLXRqW=PI!b?FBT;2sUbaU>=! z$}&`K?Vz$kC?Nl#Em&cSt9dm?{DbkW<>rogSL(`kn?nQq=omO^T%z* z03F)hR!=10WAfpc^Xat0H9gY0A-bEif4yj&eAjlI%mvl}Oe-8=E*W?f=iiuH11Gh$ znUR6}`}*8ql01Gsa`SEtPGq?jhQMMbiU?p*2A)1k{icAKy;pL0t>2VZTSeBj*tQv) zU5AtK#ZlVR2MpdI*RF>IFfazfw7IiWrQWKQLVs{(kfb_T8yK(vD~>J(M4U1^mr%-S zuO_b@L~P_q<~C%nDTtsbFYq9P@P8^r<|qlWUj8sSHV<)mM;N1nIH3hPxZ8` za5YP?X`*CNSjstxjmC-`R$dGC@=FkYsw9^s$^>PA#n*wyLQ$=xZDd2$B+K9_a*b9v zKpB|$`g>`;5g6}HR$&PUKb&jXv-43n5w?LuNbH^EMW_o`mu4HFc>q^s$Q_;|VnSli zf^lZAR{^%hQ@YrI4`a+m$d5HrOFdiVmG4NQb2R8g{*ke9YQR2Af>weIF7VUIrzT+o zjLg|wzCA^8I)A<8LLeLIqTBs%wBckFi;WxpE))Hx&rPfc48;xa1q>G1k8#L>%*ynN3h9~=Be0N` z_Rw8aC7h2khK(+!*Jw?YpQP6I*l{xblzn`ZgT&%bT2tV=oRQuArgUYVP1W5JICH15Y_e_GmCX=M~~mOG+TT1J3(8oBIYgj%gM1&kmGCak-fZhYXkuZ10cZA@aQnekAKhAJ&<{C0`IP>oei zPt*8HGtn~Ul4X0L&-`y12)CXsS%{CqpauRZ2K?y!C2&%5`mU6Np~d0#;NEaG;8fD3 zY^2X*uTJMLp(Rxo6Q!(`2?i5OzfaHrZ6E=qHtzDP_e>a<1 { + step.defineCMacro("PLATFORM_DESKTOP", null); + try self.files.append("rglfw.c"); + + step.linkSystemLibrary("GL"); + step.linkSystemLibrary("rt"); + step.linkSystemLibrary("dl"); + step.linkSystemLibrary("m"); + + const glfwInclude = b.pathJoin(&[_][]const u8{ self.raylibSrcPath.getPath(b), "external", "glfw", "include" }); + step.addIncludePath(.{ .path = glfwInclude }); + step.addIncludePath(.{ .path = "/usr/include" }); + step.addLibraryPath(.{ .path = "/usr/lib" }); + + switch (options.backend) { + .X11 => { + step.defineCMacro("_GLFW_X11", null); + step.linkSystemLibrary("X11"); + }, + .WAYLAND => { + step.defineCMacro("_GLFW_WAYLAND", null); + step.linkSystemLibrary("wayland-client"); + step.linkSystemLibrary("wayland-cursor"); + step.linkSystemLibrary("wayland-egl"); + step.linkSystemLibrary("xkbcommon"); + + waylandGenerate(self, b, step, "wayland.xml", "wayland-client-protocol"); + waylandGenerate(self, b, step, "xdg-shell.xml", "xdg-shell-client-protocol"); + waylandGenerate(self, b, step, "xdg-decoration-unstable-v1.xml", "xdg-decoration-unstable-v1-client-protocol"); + waylandGenerate(self, b, step, "viewporter.xml", "viewporter-client-protocol"); + waylandGenerate(self, b, step, "relative-pointer-unstable-v1.xml", "relative-pointer-unstable-v1-client-protocol"); + waylandGenerate(self, b, step, "pointer-constraints-unstable-v1.xml", "pointer-constraints-unstable-v1-client-protocol"); + waylandGenerate(self, b, step, "fractional-scale-v1.xml", "fractional-scale-v1-client-protocol"); + waylandGenerate(self, b, step, "xdg-activation-v1.xml", "xdg-activation-v1-client-protocol"); + waylandGenerate(self, b, step, "idle-inhibit-unstable-v1.xml", "idle-inhibit-unstable-v1-client-protocol"); + }, + } + }, + .DRM => { + step.linkSystemLibrary("EGL"); + step.linkSystemLibrary("drm"); + step.linkSystemLibrary("gbm"); + step.linkSystemLibrary("pthread"); + step.linkSystemLibrary("rt"); + step.linkSystemLibrary("m"); + step.linkSystemLibrary("dl"); + step.addIncludePath(.{ .path = "/usr/include/libdrm" }); + + step.defineCMacro("PLATFORM_DRM", null); + step.defineCMacro("EGL_NO_X11", null); + + // If opengl_es2 is selected, we link against it. + if (self.rlgl) |opts| { + if (opts.graphics_api == .OPENGL_ES2) { + step.linkSystemLibrary("GLESv2"); + } + } else { + setRlglOptions(self, b, step, .{ + .graphics_api = .OPENGL_ES2, + .rl_default_batch_buffer_elements = "2048", + }); + step.linkSystemLibrary("GLESv2"); + } + }, + } + } + + // Commands to generate wayland bindings. + fn waylandGenerate( + self: *RaylibSetup, + b: *std.Build, + step: *std.Build.Step.Compile, + comptime protocol: []const u8, + comptime basename: []const u8, + ) void { + const waylandDir = b.pathJoin(&[_][]const u8{ self.raylibSrcPath.getPath(b), "external", "glfw", "deps", "wayland" }); + const protocolDir = b.pathJoin(&[_][]const u8{ waylandDir, protocol }); + + const clientHeader = basename ++ ".h"; + const privateCode = basename ++ "-code.h"; + + const client_step = b.addSystemCommand(&.{ "wayland-scanner", "client-header" }); + client_step.addFileArg(.{ .path = protocolDir }); + step.addIncludePath(client_step.addOutputFileArg(clientHeader).dirname()); + + const private_step = b.addSystemCommand(&.{ "wayland-scanner", "private-code" }); + private_step.addFileArg(.{ .path = protocolDir }); + step.addIncludePath(private_step.addOutputFileArg(privateCode).dirname()); + + step.step.dependOn(&client_step.step); + step.step.dependOn(&private_step.step); + } + + // Options + + // C macros and build options for rcamera + pub fn setRCameraOptions( + self: *RaylibSetup, + build: *std.Build, + step: *std.Build.Step.Compile, + conf: RCameraConfiguration, + ) void { + self.rcamera = conf; + const buildOpts = build.addOptions(); + if (conf.rcamera_implementation) |implementation| { + buildOpts.addOption(@TypeOf(implementation), "implementation", implementation); + if (implementation) step.defineCMacro("RCAMERA_IMPLEMENTATION", null) else step.forceUndefinedSymbol("RCAMERA_IMPLEMENTATION"); + } + if (conf.rcamera_standalone) |standalone| { + buildOpts.addOption(@TypeOf(standalone), "standalone", standalone); + if (standalone) step.defineCMacro("RCAMERA_STANDALONE", null) else step.forceUndefinedSymbol("RCAMERA_STANDALONE"); + } + step.root_module.addOptions("raygui_options", buildOpts); + } + + // C macros and build options for rlgl + pub fn setRlglOptions( + self: *RaylibSetup, + build: *std.Build, + step: *std.Build.Step.Compile, + conf: RlglConfiguration, + ) void { + self.rlgl = conf; + const buildOpts = build.addOptions(); + + buildOpts.addOption(usize, "graphics_api", @intFromEnum(conf.graphics_api)); + switch (conf.graphics_api) { + GraphicsApi.OPENGL_11 => step.defineCMacro("GRAPHICS_API_OPENGL_11", null), + GraphicsApi.OPENGL_21 => step.defineCMacro("GRAPHICS_API_OPENGL_21", null), + GraphicsApi.OPENGL_33 => step.defineCMacro("GRAPHICS_API_OPENGL_33", null), + GraphicsApi.OPENGL_43 => step.defineCMacro("GRAPHICS_API_OPENGL_43", null), + GraphicsApi.OPENGL_ES2 => step.defineCMacro("GRAPHICS_API_OPENGL_ES2", null), + GraphicsApi.OPENGL_ES3 => step.defineCMacro("GRAPHICS_API_OPENGL_ES3", null), + } + + if (conf.rlgl_implementation) |implementation| { + buildOpts.addOption(@TypeOf(implementation), "implementation", implementation); + if (implementation) step.defineCMacro("RLGL_IMPLEMENTATION", null) else step.forceUndefinedSymbol("RLGL_IMPLEMENTATION"); + } + if (conf.rlgl_render_textures_hint) |render_textures_hint| { + buildOpts.addOption(@TypeOf(render_textures_hint), "render_textures_hint", render_textures_hint); + if (render_textures_hint) step.defineCMacro("RLGL_RENDER_TEXTURES_HINT", null) else step.forceUndefinedSymbol("RLGL_RENDER_TEXTURES_HINT"); + } + if (conf.rlgl_show_gl_details_info) |show_gl_details_info| { + buildOpts.addOption(@TypeOf(show_gl_details_info), "show_gl_details_info", show_gl_details_info); + if (show_gl_details_info) step.defineCMacro("RLGL_SHOW_GL_DETAILS_INFO", null) else step.forceUndefinedSymbol("RLGL_SHOW_GL_DETAILS_INFO"); + } + if (conf.rlgl_enable_opengl_debug_context) |enable_opengl_debug_context| { + buildOpts.addOption(@TypeOf(enable_opengl_debug_context), "enable_opengl_debug_context", enable_opengl_debug_context); + if (enable_opengl_debug_context) step.defineCMacro("RLGL_ENABLE_OPENGL_DEBUG_CONTEXT", null) else step.forceUndefinedSymbol("RLGL_ENABLE_OPENGL_DEBUG_CONTEXT"); + } + if (conf.rl_default_batch_buffer_elements) |default_batch_buffer_elements| { + buildOpts.addOption(@TypeOf(default_batch_buffer_elements), "default_batch_buffer_elements", default_batch_buffer_elements); + step.defineCMacro("RL_DEFAULT_BATCH_BUFFER_ELEMENTS", default_batch_buffer_elements); + } + if (conf.rl_default_batch_buffers) |default_batch_buffers| { + buildOpts.addOption(@TypeOf(default_batch_buffers), "default_batch_buffers", default_batch_buffers); + step.defineCMacro("RL_DEFAULT_BATCH_BUFFERS", default_batch_buffers); + } + if (conf.rl_default_batch_drawcalls) |default_batch_drawcalls| { + buildOpts.addOption(@TypeOf(default_batch_drawcalls), "default_batch_drawcalls", default_batch_drawcalls); + step.defineCMacro("RL_DEFAULT_BATCH_DRAWCALLS", default_batch_drawcalls); + } + if (conf.rl_default_batch_max_texture_units) |default_batch_max_texture_units| { + buildOpts.addOption(@TypeOf(default_batch_max_texture_units), "default_batch_max_texture_units", default_batch_max_texture_units); + step.defineCMacro("RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS", default_batch_max_texture_units); + } + if (conf.rl_max_matrix_stack_size) |max_matrix_stack_size| { + buildOpts.addOption(@TypeOf(max_matrix_stack_size), "max_matrix_stack_size", max_matrix_stack_size); + step.defineCMacro("RL_MAX_MATRIX_STACK_SIZE", max_matrix_stack_size); + } + if (conf.rl_max_shader_locations) |max_shader_locations| { + buildOpts.addOption(@TypeOf(max_shader_locations), "max_shader_locations", max_shader_locations); + step.defineCMacro("RL_MAX_SHADER_LOCATIONS", max_shader_locations); + } + if (conf.rl_cull_distance_near) |cull_distance_near| { + buildOpts.addOption(@TypeOf(cull_distance_near), "cull_distance_near", cull_distance_near); + step.defineCMacro("RL_CULL_DISTANCE_NEAR", cull_distance_near); + } + if (conf.rl_cull_distance_far) |cull_distance_far| { + buildOpts.addOption(@TypeOf(cull_distance_far), "cull_distance_far", cull_distance_far); + step.defineCMacro("RL_CULL_DISTANCE_FAR", cull_distance_far); + } + + step.root_module.addOptions("rlgl_options", buildOpts); + } + + // C macros and build options for raygui + pub fn setRayguiOptions( + self: *RaylibSetup, + build: *std.Build, + step: *std.Build.Step.Compile, + conf: RayguiConfiguration, + ) void { + self.raygui = conf; + const buildOpts = build.addOptions(); + if (conf.raygui_implementation) |implementation| { + buildOpts.addOption(@TypeOf(implementation), "implementation", implementation); + if (implementation) step.defineCMacro("RAYGUI_IMPLEMENTATION", null) else step.forceUndefinedSymbol("RAYGUI_IMPLEMENTATION"); + } + if (conf.raygui_standalone) |standalone| { + buildOpts.addOption(@TypeOf(standalone), "standalone", standalone); + if (standalone) step.defineCMacro("RAYGUI_STANDALONE", null) else step.forceUndefinedSymbol("RAYGUI_STANDALONE"); + } + if (conf.raygui_no_icons) |no_icons| { + buildOpts.addOption(@TypeOf(no_icons), "no_icons", no_icons); + if (no_icons) step.defineCMacro("RAYGUI_NO_ICONS", null) else step.forceUndefinedSymbol("RAYGUI_NO_ICONS"); + } + if (conf.raygui_custom_icons) |custom_icons| { + buildOpts.addOption(@TypeOf(custom_icons), "custom_icons", custom_icons); + if (custom_icons) step.defineCMacro("RAYGUI_CUSTOM_ICONS", null) else step.forceUndefinedSymbol("RAYGUI_CUSTOM_ICONS"); + } + if (conf.raygui_debug_recs_bounds) |debug_recs_bounds| { + buildOpts.addOption(@TypeOf(debug_recs_bounds), "debug_recs_bounds", debug_recs_bounds); + if (debug_recs_bounds) step.defineCMacro("RAYGUI_DEBUG_RECS_BOUNDS", null) else step.forceUndefinedSymbol("RAYGUI_DEBUG_RECS_BOUNDS"); + } + if (conf.raygui_debug_text_bounds) |debug_text_bounds| { + buildOpts.addOption(@TypeOf(debug_text_bounds), "debug_text_bounds", debug_text_bounds); + if (debug_text_bounds) step.defineCMacro("RAYGUI_DEBUG_TEXT_BOUNDS", null) else step.forceUndefinedSymbol("RAYGUI_DEBUG_TEXT_BOUNDS"); + } + + step.root_module.addOptions("raygui_options", buildOpts); + } + + pub fn finalize( + self: *RaylibSetup, + build: *std.Build, + step: *std.Build.Step.Compile, + ) void { + // Set unsetted options + if (self.rlgl == null) setRlglOptions(self, build, step, .{}); + if (self.rcamera == null) setRCameraOptions(self, build, step, .{}); + if (self.raygui == null) setRayguiOptions(self, build, step, .{}); + + // libc is required to work with raylib c files. + if (!step.is_linking_libc) step.linkLibC(); + + // Add raylib sources to the step's module. + step.root_module.addCSourceFiles(.{ + .root = self.raylibSrcPath, + .files = self.files.items, + .flags = self.flags.items, + }); + } + + pub fn deinit(self: *RaylibSetup) void { + self.flags.deinit(); + self.files.deinit(); + } +};