Make use of Zigs doc comments (#116)

* copy over inline comments

* remove trailing comma

* add more doc comments

* implement requested changes

* Newly generated file

* Manually add docstrings to raygui functions in prelude

* Fix generator script

---------

Co-authored-by: Not-Nik <nik.wipper@gmx.de>
This commit is contained in:
Dumb Bird 2024-07-03 15:32:56 -04:00 committed by GitHub
parent e98afb5252
commit 2d8e856009
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 1360 additions and 15 deletions

View File

@ -55,7 +55,7 @@ def ziggify_type(name: str, t: str, func_name) -> str:
"position", "mesh", "materialCount", "material", "model", "animCount", "position", "mesh", "materialCount", "material", "model", "animCount",
"wave", "v1", "v2", "outAxis", "outAngle", "fileSize", "wave", "v1", "v2", "outAxis", "outAngle", "fileSize",
"AutomationEventList", "list", "batch", "glInternalFormat", "glFormat", "AutomationEventList", "list", "batch", "glInternalFormat", "glFormat",
"glType", "mipmaps", "active", "scroll", "view", "checked", "mouseCell", "glType", "mipmaps", "active", "scroll", "view", "checked", "mouseCell",
"scrollIndex", "focus", "secretViewActive", "color", "alpha", "colorHsv" "scrollIndex", "focus", "secretViewActive", "color", "alpha", "colorHsv"
] ]
multi = [ multi = [
@ -225,7 +225,15 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str,
if not line.startswith(prefix): if not line.startswith(prefix):
continue continue
line = line.split(";", 1)[0] split_line = line.split(";", 1)
line = split_line[0]
if len(split_line) > 1:
desc = split_line[1].lstrip()
inline_comment = ("/" + desc) if len(desc) > 0 else ""
else:
inline_comment = ""
if leftover: if leftover:
line = leftover + line line = leftover + line
@ -267,7 +275,7 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str,
zig_c_arguments = [] zig_c_arguments = []
zig_arguments = [] zig_arguments = []
zig_call_args = [] zig_call_args = []
if not arguments: if not arguments:
arguments = "void" arguments = "void"
@ -360,6 +368,7 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str,
if return_cast: if return_cast:
zig_funcs.append( zig_funcs.append(
inline_comment +
f"pub fn {zig_name}({zig_arguments}) {zig_return}" + f"pub fn {zig_name}({zig_arguments}) {zig_return}" +
" {\n " + " {\n " +
("return " if zig_return != "void" else "") + ("return " if zig_return != "void" else "") +

View File

@ -412,6 +412,7 @@ pub const GuiIconName = enum(c_int) {
icon_255 = 255, icon_255 = 255,
}; };
/// Get raygui icons data pointer
pub fn guiGetIcons() rl.RaylibError![]u32 { pub fn guiGetIcons() rl.RaylibError![]u32 {
var res: []u32 = undefined; var res: []u32 = undefined;
@ -424,18 +425,22 @@ pub fn guiGetIcons() rl.RaylibError![]u32 {
} }
// If you REALLY need the return value of the function, you'll know what to do with it and its size yourself // If you REALLY need the return value of the function, you'll know what to do with it and its size yourself
/// Load raygui icons file (.rgi) into internal icons data
pub fn guiLoadIcons(fileName: [*c]const u8, loadIconsName: bool) [*c][*c]u8 { pub fn guiLoadIcons(fileName: [*c]const u8, loadIconsName: bool) [*c][*c]u8 {
return cdef.GuiLoadIcons(fileName, loadIconsName); return cdef.GuiLoadIcons(fileName, loadIconsName);
} }
/// Tab Bar control, returns TAB to be closed or -1
pub fn guiTabBar(bounds: Rectangle, text: [][:0]const u8, active: *i32) i32 { pub fn guiTabBar(bounds: Rectangle, text: [][:0]const u8, active: *i32) i32 {
return @as(i32, cdef.GuiTabBar(bounds, @as([*c][*c]const u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(active)))); return @as(i32, cdef.GuiTabBar(bounds, @as([*c][*c]const u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(active))));
} }
/// List View with extended parameters
pub fn guiListViewEx(bounds: Rectangle, text: [][:0]const u8, scrollIndex: *i32, active: *i32, focus: *i32) i32 { pub fn guiListViewEx(bounds: Rectangle, text: [][:0]const u8, scrollIndex: *i32, active: *i32, focus: *i32) i32 {
return @as(i32, cdef.GuiListViewEx(bounds, @as([*c][*c]const u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(scrollIndex)), @as([*c]c_int, @ptrCast(active)), @as([*c]c_int, @ptrCast(focus)))); return @as(i32, cdef.GuiListViewEx(bounds, @as([*c][*c]const u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(scrollIndex)), @as([*c]c_int, @ptrCast(active)), @as([*c]c_int, @ptrCast(focus))));
} }
/// Panel control, useful to group controls
pub fn guiPanel(bounds: Rectangle, text: ?[:0]const u8) i32 { pub fn guiPanel(bounds: Rectangle, text: ?[:0]const u8) i32 {
var textFinal = @as([*c]const u8, 0); var textFinal = @as([*c]const u8, 0);
if (text) |textSure| { if (text) |textSure| {
@ -444,6 +449,7 @@ pub fn guiPanel(bounds: Rectangle, text: ?[:0]const u8) i32 {
return @as(i32, cdef.GuiPanel(bounds, textFinal)); return @as(i32, cdef.GuiPanel(bounds, textFinal));
} }
/// Scroll Panel control
pub fn guiScrollPanel(bounds: Rectangle, text: ?[:0]const u8, content: Rectangle, scroll: *Vector2, view: *Rectangle) i32 { pub fn guiScrollPanel(bounds: Rectangle, text: ?[:0]const u8, content: Rectangle, scroll: *Vector2, view: *Rectangle) i32 {
var textFinal = @as([*c]const u8, 0); var textFinal = @as([*c]const u8, 0);
if (text) |textSure| { if (text) |textSure| {

File diff suppressed because it is too large Load Diff

View File

@ -412,6 +412,7 @@ pub const GuiIconName = enum(c_int) {
icon_255 = 255, icon_255 = 255,
}; };
/// Get raygui icons data pointer
pub fn guiGetIcons() rl.RaylibError![]u32 { pub fn guiGetIcons() rl.RaylibError![]u32 {
var res: []u32 = undefined; var res: []u32 = undefined;
@ -424,18 +425,22 @@ pub fn guiGetIcons() rl.RaylibError![]u32 {
} }
// If you REALLY need the return value of the function, you'll know what to do with it and its size yourself // If you REALLY need the return value of the function, you'll know what to do with it and its size yourself
/// Load raygui icons file (.rgi) into internal icons data
pub fn guiLoadIcons(fileName: [*c]const u8, loadIconsName: bool) [*c][*c]u8 { pub fn guiLoadIcons(fileName: [*c]const u8, loadIconsName: bool) [*c][*c]u8 {
return cdef.GuiLoadIcons(fileName, loadIconsName); return cdef.GuiLoadIcons(fileName, loadIconsName);
} }
/// Tab Bar control, returns TAB to be closed or -1
pub fn guiTabBar(bounds: Rectangle, text: [][:0]const u8, active: *i32) i32 { pub fn guiTabBar(bounds: Rectangle, text: [][:0]const u8, active: *i32) i32 {
return @as(i32, cdef.GuiTabBar(bounds, @as([*c][*c]const u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(active)))); return @as(i32, cdef.GuiTabBar(bounds, @as([*c][*c]const u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(active))));
} }
/// List View with extended parameters
pub fn guiListViewEx(bounds: Rectangle, text: [][:0]const u8, scrollIndex: *i32, active: *i32, focus: *i32) i32 { pub fn guiListViewEx(bounds: Rectangle, text: [][:0]const u8, scrollIndex: *i32, active: *i32, focus: *i32) i32 {
return @as(i32, cdef.GuiListViewEx(bounds, @as([*c][*c]const u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(scrollIndex)), @as([*c]c_int, @ptrCast(active)), @as([*c]c_int, @ptrCast(focus)))); return @as(i32, cdef.GuiListViewEx(bounds, @as([*c][*c]const u8, @ptrCast(text)), @as(c_int, @intCast(text.len)), @as([*c]c_int, @ptrCast(scrollIndex)), @as([*c]c_int, @ptrCast(active)), @as([*c]c_int, @ptrCast(focus))));
} }
/// Panel control, useful to group controls
pub fn guiPanel(bounds: Rectangle, text: ?[:0]const u8) i32 { pub fn guiPanel(bounds: Rectangle, text: ?[:0]const u8) i32 {
var textFinal = @as([*c]const u8, 0); var textFinal = @as([*c]const u8, 0);
if (text) |textSure| { if (text) |textSure| {
@ -444,6 +449,7 @@ pub fn guiPanel(bounds: Rectangle, text: ?[:0]const u8) i32 {
return @as(i32, cdef.GuiPanel(bounds, textFinal)); return @as(i32, cdef.GuiPanel(bounds, textFinal));
} }
/// Scroll Panel control
pub fn guiScrollPanel(bounds: Rectangle, text: ?[:0]const u8, content: Rectangle, scroll: *Vector2, view: *Rectangle) i32 { pub fn guiScrollPanel(bounds: Rectangle, text: ?[:0]const u8, content: Rectangle, scroll: *Vector2, view: *Rectangle) i32 {
var textFinal = @as([*c]const u8, 0); var textFinal = @as([*c]const u8, 0);
if (text) |textSure| { if (text) |textSure| {
@ -452,206 +458,257 @@ pub fn guiScrollPanel(bounds: Rectangle, text: ?[:0]const u8, content: Rectangle
return @as(i32, cdef.GuiScrollPanel(bounds, textFinal, content, @as([*c]Vector2, @ptrCast(scroll)), @as([*c]Rectangle, @ptrCast(view)))); return @as(i32, cdef.GuiScrollPanel(bounds, textFinal, content, @as([*c]Vector2, @ptrCast(scroll)), @as([*c]Rectangle, @ptrCast(view))));
} }
/// Enable gui controls (global state)
pub fn guiEnable() void { pub fn guiEnable() void {
cdef.GuiEnable(); cdef.GuiEnable();
} }
/// Disable gui controls (global state)
pub fn guiDisable() void { pub fn guiDisable() void {
cdef.GuiDisable(); cdef.GuiDisable();
} }
/// Lock gui controls (global state)
pub fn guiLock() void { pub fn guiLock() void {
cdef.GuiLock(); cdef.GuiLock();
} }
/// Unlock gui controls (global state)
pub fn guiUnlock() void { pub fn guiUnlock() void {
cdef.GuiUnlock(); cdef.GuiUnlock();
} }
/// Check if gui is locked (global state)
pub fn guiIsLocked() bool { pub fn guiIsLocked() bool {
return cdef.GuiIsLocked(); return cdef.GuiIsLocked();
} }
/// Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
pub fn guiSetAlpha(alpha: f32) void { pub fn guiSetAlpha(alpha: f32) void {
cdef.GuiSetAlpha(alpha); cdef.GuiSetAlpha(alpha);
} }
/// Set gui state (global state)
pub fn guiSetState(state: i32) void { pub fn guiSetState(state: i32) void {
cdef.GuiSetState(@as(c_int, state)); cdef.GuiSetState(@as(c_int, state));
} }
/// Get gui state (global state)
pub fn guiGetState() i32 { pub fn guiGetState() i32 {
return @as(i32, cdef.GuiGetState()); return @as(i32, cdef.GuiGetState());
} }
/// Set gui custom font (global state)
pub fn guiSetFont(font: Font) void { pub fn guiSetFont(font: Font) void {
cdef.GuiSetFont(font); cdef.GuiSetFont(font);
} }
/// Get gui custom font (global state)
pub fn guiGetFont() Font { pub fn guiGetFont() Font {
return cdef.GuiGetFont(); return cdef.GuiGetFont();
} }
/// Set one style property
pub fn guiSetStyle(control: i32, property: i32, value: i32) void { pub fn guiSetStyle(control: i32, property: i32, value: i32) void {
cdef.GuiSetStyle(@as(c_int, control), @as(c_int, property), @as(c_int, value)); cdef.GuiSetStyle(@as(c_int, control), @as(c_int, property), @as(c_int, value));
} }
/// Get one style property
pub fn guiGetStyle(control: i32, property: i32) i32 { pub fn guiGetStyle(control: i32, property: i32) i32 {
return @as(i32, cdef.GuiGetStyle(@as(c_int, control), @as(c_int, property))); return @as(i32, cdef.GuiGetStyle(@as(c_int, control), @as(c_int, property)));
} }
/// Load style file over global style variable (.rgs)
pub fn guiLoadStyle(fileName: [:0]const u8) void { pub fn guiLoadStyle(fileName: [:0]const u8) void {
cdef.GuiLoadStyle(@as([*c]const u8, @ptrCast(fileName))); cdef.GuiLoadStyle(@as([*c]const u8, @ptrCast(fileName)));
} }
/// Load style default over global style
pub fn guiLoadStyleDefault() void { pub fn guiLoadStyleDefault() void {
cdef.GuiLoadStyleDefault(); cdef.GuiLoadStyleDefault();
} }
/// Enable gui tooltips (global state)
pub fn guiEnableTooltip() void { pub fn guiEnableTooltip() void {
cdef.GuiEnableTooltip(); cdef.GuiEnableTooltip();
} }
/// Disable gui tooltips (global state)
pub fn guiDisableTooltip() void { pub fn guiDisableTooltip() void {
cdef.GuiDisableTooltip(); cdef.GuiDisableTooltip();
} }
/// Set tooltip string
pub fn guiSetTooltip(tooltip: [:0]const u8) void { pub fn guiSetTooltip(tooltip: [:0]const u8) void {
cdef.GuiSetTooltip(@as([*c]const u8, @ptrCast(tooltip))); cdef.GuiSetTooltip(@as([*c]const u8, @ptrCast(tooltip)));
} }
/// Get text with icon id prepended (if supported)
pub fn guiIconText(iconId: i32, text: [:0]const u8) [:0]const u8 { pub fn guiIconText(iconId: i32, text: [:0]const u8) [:0]const u8 {
return std.mem.span(cdef.GuiIconText(@as(c_int, iconId), @as([*c]const u8, @ptrCast(text)))); return std.mem.span(cdef.GuiIconText(@as(c_int, iconId), @as([*c]const u8, @ptrCast(text))));
} }
/// Set default icon drawing size
pub fn guiSetIconScale(scale: i32) void { pub fn guiSetIconScale(scale: i32) void {
cdef.GuiSetIconScale(@as(c_int, scale)); cdef.GuiSetIconScale(@as(c_int, scale));
} }
/// Draw icon using pixel size at specified position
pub fn guiDrawIcon(iconId: i32, posX: i32, posY: i32, pixelSize: i32, color: Color) void { pub fn guiDrawIcon(iconId: i32, posX: i32, posY: i32, pixelSize: i32, color: Color) void {
cdef.GuiDrawIcon(@as(c_int, iconId), @as(c_int, posX), @as(c_int, posY), @as(c_int, pixelSize), color); cdef.GuiDrawIcon(@as(c_int, iconId), @as(c_int, posX), @as(c_int, posY), @as(c_int, pixelSize), color);
} }
/// Window Box control, shows a window that can be closed
pub fn guiWindowBox(bounds: Rectangle, title: [:0]const u8) i32 { pub fn guiWindowBox(bounds: Rectangle, title: [:0]const u8) i32 {
return @as(i32, cdef.GuiWindowBox(bounds, @as([*c]const u8, @ptrCast(title)))); return @as(i32, cdef.GuiWindowBox(bounds, @as([*c]const u8, @ptrCast(title))));
} }
/// Group Box control with text name
pub fn guiGroupBox(bounds: Rectangle, text: [:0]const u8) i32 { pub fn guiGroupBox(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiGroupBox(bounds, @as([*c]const u8, @ptrCast(text)))); return @as(i32, cdef.GuiGroupBox(bounds, @as([*c]const u8, @ptrCast(text))));
} }
/// Line separator control, could contain text
pub fn guiLine(bounds: Rectangle, text: [:0]const u8) i32 { pub fn guiLine(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiLine(bounds, @as([*c]const u8, @ptrCast(text)))); return @as(i32, cdef.GuiLine(bounds, @as([*c]const u8, @ptrCast(text))));
} }
/// Label control
pub fn guiLabel(bounds: Rectangle, text: [:0]const u8) i32 { pub fn guiLabel(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiLabel(bounds, @as([*c]const u8, @ptrCast(text)))); return @as(i32, cdef.GuiLabel(bounds, @as([*c]const u8, @ptrCast(text))));
} }
/// Button control, returns true when clicked
pub fn guiButton(bounds: Rectangle, text: [:0]const u8) i32 { pub fn guiButton(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiButton(bounds, @as([*c]const u8, @ptrCast(text)))); return @as(i32, cdef.GuiButton(bounds, @as([*c]const u8, @ptrCast(text))));
} }
/// Label button control, returns true when clicked
pub fn guiLabelButton(bounds: Rectangle, text: [:0]const u8) i32 { pub fn guiLabelButton(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiLabelButton(bounds, @as([*c]const u8, @ptrCast(text)))); return @as(i32, cdef.GuiLabelButton(bounds, @as([*c]const u8, @ptrCast(text))));
} }
/// Toggle Button control
pub fn guiToggle(bounds: Rectangle, text: [:0]const u8, active: *bool) i32 { pub fn guiToggle(bounds: Rectangle, text: [:0]const u8, active: *bool) i32 {
return @as(i32, cdef.GuiToggle(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]bool, @ptrCast(active)))); return @as(i32, cdef.GuiToggle(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]bool, @ptrCast(active))));
} }
/// Toggle Group control
pub fn guiToggleGroup(bounds: Rectangle, text: [:0]const u8, active: *i32) i32 { pub fn guiToggleGroup(bounds: Rectangle, text: [:0]const u8, active: *i32) i32 {
return @as(i32, cdef.GuiToggleGroup(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(active)))); return @as(i32, cdef.GuiToggleGroup(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(active))));
} }
/// Toggle Slider control
pub fn guiToggleSlider(bounds: Rectangle, text: [:0]const u8, active: *i32) i32 { pub fn guiToggleSlider(bounds: Rectangle, text: [:0]const u8, active: *i32) i32 {
return @as(i32, cdef.GuiToggleSlider(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(active)))); return @as(i32, cdef.GuiToggleSlider(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(active))));
} }
/// Check Box control, returns true when active
pub fn guiCheckBox(bounds: Rectangle, text: [:0]const u8, checked: *bool) i32 { pub fn guiCheckBox(bounds: Rectangle, text: [:0]const u8, checked: *bool) i32 {
return @as(i32, cdef.GuiCheckBox(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]bool, @ptrCast(checked)))); return @as(i32, cdef.GuiCheckBox(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]bool, @ptrCast(checked))));
} }
/// Combo Box control
pub fn guiComboBox(bounds: Rectangle, text: [:0]const u8, active: *i32) i32 { pub fn guiComboBox(bounds: Rectangle, text: [:0]const u8, active: *i32) i32 {
return @as(i32, cdef.GuiComboBox(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(active)))); return @as(i32, cdef.GuiComboBox(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(active))));
} }
/// Dropdown Box control
pub fn guiDropdownBox(bounds: Rectangle, text: [:0]const u8, active: *i32, editMode: bool) i32 { pub fn guiDropdownBox(bounds: Rectangle, text: [:0]const u8, active: *i32, editMode: bool) i32 {
return @as(i32, cdef.GuiDropdownBox(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(active)), editMode)); return @as(i32, cdef.GuiDropdownBox(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(active)), editMode));
} }
/// Spinner control
pub fn guiSpinner(bounds: Rectangle, text: [:0]const u8, value: *i32, minValue: i32, maxValue: i32, editMode: bool) i32 { pub fn guiSpinner(bounds: Rectangle, text: [:0]const u8, value: *i32, minValue: i32, maxValue: i32, editMode: bool) i32 {
return @as(i32, cdef.GuiSpinner(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(value)), @as(c_int, minValue), @as(c_int, maxValue), editMode)); return @as(i32, cdef.GuiSpinner(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(value)), @as(c_int, minValue), @as(c_int, maxValue), editMode));
} }
/// Value Box control, updates input text with numbers
pub fn guiValueBox(bounds: Rectangle, text: [:0]const u8, value: *i32, minValue: i32, maxValue: i32, editMode: bool) i32 { pub fn guiValueBox(bounds: Rectangle, text: [:0]const u8, value: *i32, minValue: i32, maxValue: i32, editMode: bool) i32 {
return @as(i32, cdef.GuiValueBox(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(value)), @as(c_int, minValue), @as(c_int, maxValue), editMode)); return @as(i32, cdef.GuiValueBox(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(value)), @as(c_int, minValue), @as(c_int, maxValue), editMode));
} }
/// Value box control for float values
pub fn guiValueBoxFloat(bounds: Rectangle, text: [:0]const u8, textValue: [:0]u8, value: *f32, editMode: bool) i32 { pub fn guiValueBoxFloat(bounds: Rectangle, text: [:0]const u8, textValue: [:0]u8, value: *f32, editMode: bool) i32 {
return @as(i32, cdef.GuiValueBoxFloat(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]u8, @ptrCast(textValue)), @as([*c]f32, @ptrCast(value)), editMode)); return @as(i32, cdef.GuiValueBoxFloat(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]u8, @ptrCast(textValue)), @as([*c]f32, @ptrCast(value)), editMode));
} }
/// Text Box control, updates input text
pub fn guiTextBox(bounds: Rectangle, text: [:0]u8, textSize: i32, editMode: bool) i32 { pub fn guiTextBox(bounds: Rectangle, text: [:0]u8, textSize: i32, editMode: bool) i32 {
return @as(i32, cdef.GuiTextBox(bounds, @as([*c]u8, @ptrCast(text)), @as(c_int, textSize), editMode)); return @as(i32, cdef.GuiTextBox(bounds, @as([*c]u8, @ptrCast(text)), @as(c_int, textSize), editMode));
} }
/// Slider control
pub fn guiSlider(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32) i32 { pub fn guiSlider(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32) i32 {
return @as(i32, cdef.GuiSlider(bounds, @as([*c]const u8, @ptrCast(textLeft)), @as([*c]const u8, @ptrCast(textRight)), @as([*c]f32, @ptrCast(value)), minValue, maxValue)); return @as(i32, cdef.GuiSlider(bounds, @as([*c]const u8, @ptrCast(textLeft)), @as([*c]const u8, @ptrCast(textRight)), @as([*c]f32, @ptrCast(value)), minValue, maxValue));
} }
/// Slider Bar control
pub fn guiSliderBar(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32) i32 { pub fn guiSliderBar(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32) i32 {
return @as(i32, cdef.GuiSliderBar(bounds, @as([*c]const u8, @ptrCast(textLeft)), @as([*c]const u8, @ptrCast(textRight)), @as([*c]f32, @ptrCast(value)), minValue, maxValue)); return @as(i32, cdef.GuiSliderBar(bounds, @as([*c]const u8, @ptrCast(textLeft)), @as([*c]const u8, @ptrCast(textRight)), @as([*c]f32, @ptrCast(value)), minValue, maxValue));
} }
/// Progress Bar control
pub fn guiProgressBar(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32) i32 { pub fn guiProgressBar(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32) i32 {
return @as(i32, cdef.GuiProgressBar(bounds, @as([*c]const u8, @ptrCast(textLeft)), @as([*c]const u8, @ptrCast(textRight)), @as([*c]f32, @ptrCast(value)), minValue, maxValue)); return @as(i32, cdef.GuiProgressBar(bounds, @as([*c]const u8, @ptrCast(textLeft)), @as([*c]const u8, @ptrCast(textRight)), @as([*c]f32, @ptrCast(value)), minValue, maxValue));
} }
/// Status Bar control, shows info text
pub fn guiStatusBar(bounds: Rectangle, text: [:0]const u8) i32 { pub fn guiStatusBar(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiStatusBar(bounds, @as([*c]const u8, @ptrCast(text)))); return @as(i32, cdef.GuiStatusBar(bounds, @as([*c]const u8, @ptrCast(text))));
} }
/// Dummy control for placeholders
pub fn guiDummyRec(bounds: Rectangle, text: [:0]const u8) i32 { pub fn guiDummyRec(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiDummyRec(bounds, @as([*c]const u8, @ptrCast(text)))); return @as(i32, cdef.GuiDummyRec(bounds, @as([*c]const u8, @ptrCast(text))));
} }
/// Grid control
pub fn guiGrid(bounds: Rectangle, text: [:0]const u8, spacing: f32, subdivs: i32, mouseCell: *Vector2) i32 { pub fn guiGrid(bounds: Rectangle, text: [:0]const u8, spacing: f32, subdivs: i32, mouseCell: *Vector2) i32 {
return @as(i32, cdef.GuiGrid(bounds, @as([*c]const u8, @ptrCast(text)), spacing, @as(c_int, subdivs), @as([*c]Vector2, @ptrCast(mouseCell)))); return @as(i32, cdef.GuiGrid(bounds, @as([*c]const u8, @ptrCast(text)), spacing, @as(c_int, subdivs), @as([*c]Vector2, @ptrCast(mouseCell))));
} }
/// List View control
pub fn guiListView(bounds: Rectangle, text: [:0]const u8, scrollIndex: *i32, active: *i32) i32 { pub fn guiListView(bounds: Rectangle, text: [:0]const u8, scrollIndex: *i32, active: *i32) i32 {
return @as(i32, cdef.GuiListView(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(scrollIndex)), @as([*c]c_int, @ptrCast(active)))); return @as(i32, cdef.GuiListView(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(scrollIndex)), @as([*c]c_int, @ptrCast(active))));
} }
/// Message Box control, displays a message
pub fn guiMessageBox(bounds: Rectangle, title: [:0]const u8, message: [:0]const u8, buttons: [:0]const u8) i32 { pub fn guiMessageBox(bounds: Rectangle, title: [:0]const u8, message: [:0]const u8, buttons: [:0]const u8) i32 {
return @as(i32, cdef.GuiMessageBox(bounds, @as([*c]const u8, @ptrCast(title)), @as([*c]const u8, @ptrCast(message)), @as([*c]const u8, @ptrCast(buttons)))); return @as(i32, cdef.GuiMessageBox(bounds, @as([*c]const u8, @ptrCast(title)), @as([*c]const u8, @ptrCast(message)), @as([*c]const u8, @ptrCast(buttons))));
} }
/// Text Input Box control, ask for text, supports secret
pub fn guiTextInputBox(bounds: Rectangle, title: [:0]const u8, message: [:0]const u8, buttons: [:0]const u8, text: [:0]u8, textMaxSize: i32, secretViewActive: *bool) i32 { pub fn guiTextInputBox(bounds: Rectangle, title: [:0]const u8, message: [:0]const u8, buttons: [:0]const u8, text: [:0]u8, textMaxSize: i32, secretViewActive: *bool) i32 {
return @as(i32, cdef.GuiTextInputBox(bounds, @as([*c]const u8, @ptrCast(title)), @as([*c]const u8, @ptrCast(message)), @as([*c]const u8, @ptrCast(buttons)), @as([*c]u8, @ptrCast(text)), @as(c_int, textMaxSize), @as([*c]bool, @ptrCast(secretViewActive)))); return @as(i32, cdef.GuiTextInputBox(bounds, @as([*c]const u8, @ptrCast(title)), @as([*c]const u8, @ptrCast(message)), @as([*c]const u8, @ptrCast(buttons)), @as([*c]u8, @ptrCast(text)), @as(c_int, textMaxSize), @as([*c]bool, @ptrCast(secretViewActive))));
} }
/// Color Picker control (multiple color controls)
pub fn guiColorPicker(bounds: Rectangle, text: [:0]const u8, color: *Color) i32 { pub fn guiColorPicker(bounds: Rectangle, text: [:0]const u8, color: *Color) i32 {
return @as(i32, cdef.GuiColorPicker(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]Color, @ptrCast(color)))); return @as(i32, cdef.GuiColorPicker(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]Color, @ptrCast(color))));
} }
/// Color Panel control
pub fn guiColorPanel(bounds: Rectangle, text: [:0]const u8, color: *Color) i32 { pub fn guiColorPanel(bounds: Rectangle, text: [:0]const u8, color: *Color) i32 {
return @as(i32, cdef.GuiColorPanel(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]Color, @ptrCast(color)))); return @as(i32, cdef.GuiColorPanel(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]Color, @ptrCast(color))));
} }
/// Color Bar Alpha control
pub fn guiColorBarAlpha(bounds: Rectangle, text: [:0]const u8, alpha: *f32) i32 { pub fn guiColorBarAlpha(bounds: Rectangle, text: [:0]const u8, alpha: *f32) i32 {
return @as(i32, cdef.GuiColorBarAlpha(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]f32, @ptrCast(alpha)))); return @as(i32, cdef.GuiColorBarAlpha(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]f32, @ptrCast(alpha))));
} }
/// Color Bar Hue control
pub fn guiColorBarHue(bounds: Rectangle, text: [:0]const u8, value: *f32) i32 { pub fn guiColorBarHue(bounds: Rectangle, text: [:0]const u8, value: *f32) i32 {
return @as(i32, cdef.GuiColorBarHue(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]f32, @ptrCast(value)))); return @as(i32, cdef.GuiColorBarHue(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]f32, @ptrCast(value))));
} }
/// Color Picker control that avoids conversion to RGB on each call (multiple color controls)
pub fn guiColorPickerHSV(bounds: Rectangle, text: [:0]const u8, colorHsv: *Vector3) i32 { pub fn guiColorPickerHSV(bounds: Rectangle, text: [:0]const u8, colorHsv: *Vector3) i32 {
return @as(i32, cdef.GuiColorPickerHSV(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]Vector3, @ptrCast(colorHsv)))); return @as(i32, cdef.GuiColorPickerHSV(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]Vector3, @ptrCast(colorHsv))));
} }
/// Color Panel control that updates Hue-Saturation-Value color value, used by GuiColorPickerHSV()
pub fn guiColorPanelHSV(bounds: Rectangle, text: [:0]const u8, colorHsv: *Vector3) i32 { pub fn guiColorPanelHSV(bounds: Rectangle, text: [:0]const u8, colorHsv: *Vector3) i32 {
return @as(i32, cdef.GuiColorPanelHSV(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]Vector3, @ptrCast(colorHsv)))); return @as(i32, cdef.GuiColorPanelHSV(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]Vector3, @ptrCast(colorHsv))));
} }

File diff suppressed because it is too large Load Diff

View File

@ -188,34 +188,42 @@ pub const RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR = @as(i32, 3);
pub const RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT = @as(i32, 4); pub const RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT = @as(i32, 4);
pub const RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 = @as(i32, 5); pub const RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 = @as(i32, 5);
/// Choose the current matrix to be transformed
pub fn rlMatrixMode(mode: i32) void { pub fn rlMatrixMode(mode: i32) void {
cdef.rlMatrixMode(@as(c_int, mode)); cdef.rlMatrixMode(@as(c_int, mode));
} }
/// Push the current matrix to stack
pub fn rlPushMatrix() void { pub fn rlPushMatrix() void {
cdef.rlPushMatrix(); cdef.rlPushMatrix();
} }
/// Pop latest inserted matrix from stack
pub fn rlPopMatrix() void { pub fn rlPopMatrix() void {
cdef.rlPopMatrix(); cdef.rlPopMatrix();
} }
/// Reset current matrix to identity matrix
pub fn rlLoadIdentity() void { pub fn rlLoadIdentity() void {
cdef.rlLoadIdentity(); cdef.rlLoadIdentity();
} }
/// Multiply the current matrix by a translation matrix
pub fn rlTranslatef(x: f32, y: f32, z: f32) void { pub fn rlTranslatef(x: f32, y: f32, z: f32) void {
cdef.rlTranslatef(x, y, z); cdef.rlTranslatef(x, y, z);
} }
/// Multiply the current matrix by a rotation matrix
pub fn rlRotatef(angle: f32, x: f32, y: f32, z: f32) void { pub fn rlRotatef(angle: f32, x: f32, y: f32, z: f32) void {
cdef.rlRotatef(angle, x, y, z); cdef.rlRotatef(angle, x, y, z);
} }
/// Multiply the current matrix by a scaling matrix
pub fn rlScalef(x: f32, y: f32, z: f32) void { pub fn rlScalef(x: f32, y: f32, z: f32) void {
cdef.rlScalef(x, y, z); cdef.rlScalef(x, y, z);
} }
/// Multiply the current matrix by another matrix
pub fn rlMultMatrixf(matf: []const f32) void { pub fn rlMultMatrixf(matf: []const f32) void {
cdef.rlMultMatrixf(@as([*c]const f32, @ptrCast(matf))); cdef.rlMultMatrixf(@as([*c]const f32, @ptrCast(matf)));
} }
@ -228,578 +236,722 @@ pub fn rlOrtho(left: f64, right: f64, bottom: f64, top: f64, znear: f64, zfar: f
cdef.rlOrtho(left, right, bottom, top, znear, zfar); cdef.rlOrtho(left, right, bottom, top, znear, zfar);
} }
/// Set the viewport area
pub fn rlViewport(x: i32, y: i32, width: i32, height: i32) void { pub fn rlViewport(x: i32, y: i32, width: i32, height: i32) void {
cdef.rlViewport(@as(c_int, x), @as(c_int, y), @as(c_int, width), @as(c_int, height)); cdef.rlViewport(@as(c_int, x), @as(c_int, y), @as(c_int, width), @as(c_int, height));
} }
/// Set clip planes distances
pub fn rlSetClipPlanes(near: f64, far: f64) void { pub fn rlSetClipPlanes(near: f64, far: f64) void {
cdef.rlSetClipPlanes(near, far); cdef.rlSetClipPlanes(near, far);
} }
/// Get cull plane distance near
pub fn rlGetCullDistanceNear() f64 { pub fn rlGetCullDistanceNear() f64 {
return cdef.rlGetCullDistanceNear(); return cdef.rlGetCullDistanceNear();
} }
/// Get cull plane distance far
pub fn rlGetCullDistanceFar() f64 { pub fn rlGetCullDistanceFar() f64 {
return cdef.rlGetCullDistanceFar(); return cdef.rlGetCullDistanceFar();
} }
/// Initialize drawing mode (how to organize vertex)
pub fn rlBegin(mode: i32) void { pub fn rlBegin(mode: i32) void {
cdef.rlBegin(@as(c_int, mode)); cdef.rlBegin(@as(c_int, mode));
} }
/// Finish vertex providing
pub fn rlEnd() void { pub fn rlEnd() void {
cdef.rlEnd(); cdef.rlEnd();
} }
/// Define one vertex (position) - 2 int
pub fn rlVertex2i(x: i32, y: i32) void { pub fn rlVertex2i(x: i32, y: i32) void {
cdef.rlVertex2i(@as(c_int, x), @as(c_int, y)); cdef.rlVertex2i(@as(c_int, x), @as(c_int, y));
} }
/// Define one vertex (position) - 2 float
pub fn rlVertex2f(x: f32, y: f32) void { pub fn rlVertex2f(x: f32, y: f32) void {
cdef.rlVertex2f(x, y); cdef.rlVertex2f(x, y);
} }
/// Define one vertex (position) - 3 float
pub fn rlVertex3f(x: f32, y: f32, z: f32) void { pub fn rlVertex3f(x: f32, y: f32, z: f32) void {
cdef.rlVertex3f(x, y, z); cdef.rlVertex3f(x, y, z);
} }
/// Define one vertex (texture coordinate) - 2 float
pub fn rlTexCoord2f(x: f32, y: f32) void { pub fn rlTexCoord2f(x: f32, y: f32) void {
cdef.rlTexCoord2f(x, y); cdef.rlTexCoord2f(x, y);
} }
/// Define one vertex (normal) - 3 float
pub fn rlNormal3f(x: f32, y: f32, z: f32) void { pub fn rlNormal3f(x: f32, y: f32, z: f32) void {
cdef.rlNormal3f(x, y, z); cdef.rlNormal3f(x, y, z);
} }
/// Define one vertex (color) - 4 byte
pub fn rlColor4ub(r: u8, g: u8, b: u8, a: u8) void { pub fn rlColor4ub(r: u8, g: u8, b: u8, a: u8) void {
cdef.rlColor4ub(r, g, b, a); cdef.rlColor4ub(r, g, b, a);
} }
/// Define one vertex (color) - 3 float
pub fn rlColor3f(x: f32, y: f32, z: f32) void { pub fn rlColor3f(x: f32, y: f32, z: f32) void {
cdef.rlColor3f(x, y, z); cdef.rlColor3f(x, y, z);
} }
/// Define one vertex (color) - 4 float
pub fn rlColor4f(x: f32, y: f32, z: f32, w: f32) void { pub fn rlColor4f(x: f32, y: f32, z: f32, w: f32) void {
cdef.rlColor4f(x, y, z, w); cdef.rlColor4f(x, y, z, w);
} }
/// Enable vertex array (VAO, if supported)
pub fn rlEnableVertexArray(vaoId: u32) bool { pub fn rlEnableVertexArray(vaoId: u32) bool {
return cdef.rlEnableVertexArray(@as(c_uint, vaoId)); return cdef.rlEnableVertexArray(@as(c_uint, vaoId));
} }
/// Disable vertex array (VAO, if supported)
pub fn rlDisableVertexArray() void { pub fn rlDisableVertexArray() void {
cdef.rlDisableVertexArray(); cdef.rlDisableVertexArray();
} }
/// Enable vertex buffer (VBO)
pub fn rlEnableVertexBuffer(id: u32) void { pub fn rlEnableVertexBuffer(id: u32) void {
cdef.rlEnableVertexBuffer(@as(c_uint, id)); cdef.rlEnableVertexBuffer(@as(c_uint, id));
} }
/// Disable vertex buffer (VBO)
pub fn rlDisableVertexBuffer() void { pub fn rlDisableVertexBuffer() void {
cdef.rlDisableVertexBuffer(); cdef.rlDisableVertexBuffer();
} }
/// Enable vertex buffer element (VBO element)
pub fn rlEnableVertexBufferElement(id: u32) void { pub fn rlEnableVertexBufferElement(id: u32) void {
cdef.rlEnableVertexBufferElement(@as(c_uint, id)); cdef.rlEnableVertexBufferElement(@as(c_uint, id));
} }
/// Disable vertex buffer element (VBO element)
pub fn rlDisableVertexBufferElement() void { pub fn rlDisableVertexBufferElement() void {
cdef.rlDisableVertexBufferElement(); cdef.rlDisableVertexBufferElement();
} }
/// Enable vertex attribute index
pub fn rlEnableVertexAttribute(index: u32) void { pub fn rlEnableVertexAttribute(index: u32) void {
cdef.rlEnableVertexAttribute(@as(c_uint, index)); cdef.rlEnableVertexAttribute(@as(c_uint, index));
} }
/// Disable vertex attribute index
pub fn rlDisableVertexAttribute(index: u32) void { pub fn rlDisableVertexAttribute(index: u32) void {
cdef.rlDisableVertexAttribute(@as(c_uint, index)); cdef.rlDisableVertexAttribute(@as(c_uint, index));
} }
/// Enable attribute state pointer
pub fn rlEnableStatePointer(vertexAttribType: i32, buffer: *anyopaque) void { pub fn rlEnableStatePointer(vertexAttribType: i32, buffer: *anyopaque) void {
cdef.rlEnableStatePointer(@as(c_int, vertexAttribType), buffer); cdef.rlEnableStatePointer(@as(c_int, vertexAttribType), buffer);
} }
/// Disable attribute state pointer
pub fn rlDisableStatePointer(vertexAttribType: i32) void { pub fn rlDisableStatePointer(vertexAttribType: i32) void {
cdef.rlDisableStatePointer(@as(c_int, vertexAttribType)); cdef.rlDisableStatePointer(@as(c_int, vertexAttribType));
} }
/// Select and active a texture slot
pub fn rlActiveTextureSlot(slot: i32) void { pub fn rlActiveTextureSlot(slot: i32) void {
cdef.rlActiveTextureSlot(@as(c_int, slot)); cdef.rlActiveTextureSlot(@as(c_int, slot));
} }
/// Enable texture
pub fn rlEnableTexture(id: u32) void { pub fn rlEnableTexture(id: u32) void {
cdef.rlEnableTexture(@as(c_uint, id)); cdef.rlEnableTexture(@as(c_uint, id));
} }
/// Disable texture
pub fn rlDisableTexture() void { pub fn rlDisableTexture() void {
cdef.rlDisableTexture(); cdef.rlDisableTexture();
} }
/// Enable texture cubemap
pub fn rlEnableTextureCubemap(id: u32) void { pub fn rlEnableTextureCubemap(id: u32) void {
cdef.rlEnableTextureCubemap(@as(c_uint, id)); cdef.rlEnableTextureCubemap(@as(c_uint, id));
} }
/// Disable texture cubemap
pub fn rlDisableTextureCubemap() void { pub fn rlDisableTextureCubemap() void {
cdef.rlDisableTextureCubemap(); cdef.rlDisableTextureCubemap();
} }
/// Set texture parameters (filter, wrap)
pub fn rlTextureParameters(id: u32, param: i32, value: i32) void { pub fn rlTextureParameters(id: u32, param: i32, value: i32) void {
cdef.rlTextureParameters(@as(c_uint, id), @as(c_int, param), @as(c_int, value)); cdef.rlTextureParameters(@as(c_uint, id), @as(c_int, param), @as(c_int, value));
} }
/// Set cubemap parameters (filter, wrap)
pub fn rlCubemapParameters(id: u32, param: i32, value: i32) void { pub fn rlCubemapParameters(id: u32, param: i32, value: i32) void {
cdef.rlCubemapParameters(@as(c_uint, id), @as(c_int, param), @as(c_int, value)); cdef.rlCubemapParameters(@as(c_uint, id), @as(c_int, param), @as(c_int, value));
} }
/// Enable shader program
pub fn rlEnableShader(id: u32) void { pub fn rlEnableShader(id: u32) void {
cdef.rlEnableShader(@as(c_uint, id)); cdef.rlEnableShader(@as(c_uint, id));
} }
/// Disable shader program
pub fn rlDisableShader() void { pub fn rlDisableShader() void {
cdef.rlDisableShader(); cdef.rlDisableShader();
} }
/// Enable render texture (fbo)
pub fn rlEnableFramebuffer(id: u32) void { pub fn rlEnableFramebuffer(id: u32) void {
cdef.rlEnableFramebuffer(@as(c_uint, id)); cdef.rlEnableFramebuffer(@as(c_uint, id));
} }
/// Disable render texture (fbo), return to default framebuffer
pub fn rlDisableFramebuffer() void { pub fn rlDisableFramebuffer() void {
cdef.rlDisableFramebuffer(); cdef.rlDisableFramebuffer();
} }
/// Get the currently active render texture (fbo), 0 for default framebuffer
pub fn rlGetActiveFramebuffer() u32 { pub fn rlGetActiveFramebuffer() u32 {
return @as(u32, cdef.rlGetActiveFramebuffer()); return @as(u32, cdef.rlGetActiveFramebuffer());
} }
/// Activate multiple draw color buffers
pub fn rlActiveDrawBuffers(count: i32) void { pub fn rlActiveDrawBuffers(count: i32) void {
cdef.rlActiveDrawBuffers(@as(c_int, count)); cdef.rlActiveDrawBuffers(@as(c_int, count));
} }
/// Blit active framebuffer to main framebuffer
pub fn rlBlitFramebuffer(srcX: i32, srcY: i32, srcWidth: i32, srcHeight: i32, dstX: i32, dstY: i32, dstWidth: i32, dstHeight: i32, bufferMask: i32) void { pub fn rlBlitFramebuffer(srcX: i32, srcY: i32, srcWidth: i32, srcHeight: i32, dstX: i32, dstY: i32, dstWidth: i32, dstHeight: i32, bufferMask: i32) void {
cdef.rlBlitFramebuffer(@as(c_int, srcX), @as(c_int, srcY), @as(c_int, srcWidth), @as(c_int, srcHeight), @as(c_int, dstX), @as(c_int, dstY), @as(c_int, dstWidth), @as(c_int, dstHeight), @as(c_int, bufferMask)); cdef.rlBlitFramebuffer(@as(c_int, srcX), @as(c_int, srcY), @as(c_int, srcWidth), @as(c_int, srcHeight), @as(c_int, dstX), @as(c_int, dstY), @as(c_int, dstWidth), @as(c_int, dstHeight), @as(c_int, bufferMask));
} }
/// Bind framebuffer (FBO)
pub fn rlBindFramebuffer(target: u32, framebuffer: u32) void { pub fn rlBindFramebuffer(target: u32, framebuffer: u32) void {
cdef.rlBindFramebuffer(@as(c_uint, target), @as(c_uint, framebuffer)); cdef.rlBindFramebuffer(@as(c_uint, target), @as(c_uint, framebuffer));
} }
/// Enable color blending
pub fn rlEnableColorBlend() void { pub fn rlEnableColorBlend() void {
cdef.rlEnableColorBlend(); cdef.rlEnableColorBlend();
} }
/// Disable color blending
pub fn rlDisableColorBlend() void { pub fn rlDisableColorBlend() void {
cdef.rlDisableColorBlend(); cdef.rlDisableColorBlend();
} }
/// Enable depth test
pub fn rlEnableDepthTest() void { pub fn rlEnableDepthTest() void {
cdef.rlEnableDepthTest(); cdef.rlEnableDepthTest();
} }
/// Disable depth test
pub fn rlDisableDepthTest() void { pub fn rlDisableDepthTest() void {
cdef.rlDisableDepthTest(); cdef.rlDisableDepthTest();
} }
/// Enable depth write
pub fn rlEnableDepthMask() void { pub fn rlEnableDepthMask() void {
cdef.rlEnableDepthMask(); cdef.rlEnableDepthMask();
} }
/// Disable depth write
pub fn rlDisableDepthMask() void { pub fn rlDisableDepthMask() void {
cdef.rlDisableDepthMask(); cdef.rlDisableDepthMask();
} }
/// Enable backface culling
pub fn rlEnableBackfaceCulling() void { pub fn rlEnableBackfaceCulling() void {
cdef.rlEnableBackfaceCulling(); cdef.rlEnableBackfaceCulling();
} }
/// Disable backface culling
pub fn rlDisableBackfaceCulling() void { pub fn rlDisableBackfaceCulling() void {
cdef.rlDisableBackfaceCulling(); cdef.rlDisableBackfaceCulling();
} }
/// Color mask control
pub fn rlColorMask(r: bool, g: bool, b: bool, a: bool) void { pub fn rlColorMask(r: bool, g: bool, b: bool, a: bool) void {
cdef.rlColorMask(r, g, b, a); cdef.rlColorMask(r, g, b, a);
} }
/// Set face culling mode
pub fn rlSetCullFace(mode: i32) void { pub fn rlSetCullFace(mode: i32) void {
cdef.rlSetCullFace(@as(c_int, mode)); cdef.rlSetCullFace(@as(c_int, mode));
} }
/// Enable scissor test
pub fn rlEnableScissorTest() void { pub fn rlEnableScissorTest() void {
cdef.rlEnableScissorTest(); cdef.rlEnableScissorTest();
} }
/// Disable scissor test
pub fn rlDisableScissorTest() void { pub fn rlDisableScissorTest() void {
cdef.rlDisableScissorTest(); cdef.rlDisableScissorTest();
} }
/// Scissor test
pub fn rlScissor(x: i32, y: i32, width: i32, height: i32) void { pub fn rlScissor(x: i32, y: i32, width: i32, height: i32) void {
cdef.rlScissor(@as(c_int, x), @as(c_int, y), @as(c_int, width), @as(c_int, height)); cdef.rlScissor(@as(c_int, x), @as(c_int, y), @as(c_int, width), @as(c_int, height));
} }
/// Enable wire mode
pub fn rlEnableWireMode() void { pub fn rlEnableWireMode() void {
cdef.rlEnableWireMode(); cdef.rlEnableWireMode();
} }
/// Enable point mode
pub fn rlEnablePointMode() void { pub fn rlEnablePointMode() void {
cdef.rlEnablePointMode(); cdef.rlEnablePointMode();
} }
/// Disable wire mode ( and point ) maybe rename
pub fn rlDisableWireMode() void { pub fn rlDisableWireMode() void {
cdef.rlDisableWireMode(); cdef.rlDisableWireMode();
} }
/// Set the line drawing width
pub fn rlSetLineWidth(width: f32) void { pub fn rlSetLineWidth(width: f32) void {
cdef.rlSetLineWidth(width); cdef.rlSetLineWidth(width);
} }
/// Get the line drawing width
pub fn rlGetLineWidth() f32 { pub fn rlGetLineWidth() f32 {
return cdef.rlGetLineWidth(); return cdef.rlGetLineWidth();
} }
/// Enable line aliasing
pub fn rlEnableSmoothLines() void { pub fn rlEnableSmoothLines() void {
cdef.rlEnableSmoothLines(); cdef.rlEnableSmoothLines();
} }
/// Disable line aliasing
pub fn rlDisableSmoothLines() void { pub fn rlDisableSmoothLines() void {
cdef.rlDisableSmoothLines(); cdef.rlDisableSmoothLines();
} }
/// Enable stereo rendering
pub fn rlEnableStereoRender() void { pub fn rlEnableStereoRender() void {
cdef.rlEnableStereoRender(); cdef.rlEnableStereoRender();
} }
/// Disable stereo rendering
pub fn rlDisableStereoRender() void { pub fn rlDisableStereoRender() void {
cdef.rlDisableStereoRender(); cdef.rlDisableStereoRender();
} }
/// Check if stereo render is enabled
pub fn rlIsStereoRenderEnabled() bool { pub fn rlIsStereoRenderEnabled() bool {
return cdef.rlIsStereoRenderEnabled(); return cdef.rlIsStereoRenderEnabled();
} }
/// Clear color buffer with color
pub fn rlClearColor(r: u8, g: u8, b: u8, a: u8) void { pub fn rlClearColor(r: u8, g: u8, b: u8, a: u8) void {
cdef.rlClearColor(r, g, b, a); cdef.rlClearColor(r, g, b, a);
} }
/// Clear used screen buffers (color and depth)
pub fn rlClearScreenBuffers() void { pub fn rlClearScreenBuffers() void {
cdef.rlClearScreenBuffers(); cdef.rlClearScreenBuffers();
} }
/// Check and log OpenGL error codes
pub fn rlCheckErrors() void { pub fn rlCheckErrors() void {
cdef.rlCheckErrors(); cdef.rlCheckErrors();
} }
/// Set blending mode
pub fn rlSetBlendMode(mode: i32) void { pub fn rlSetBlendMode(mode: i32) void {
cdef.rlSetBlendMode(@as(c_int, mode)); cdef.rlSetBlendMode(@as(c_int, mode));
} }
/// Set blending mode factor and equation (using OpenGL factors)
pub fn rlSetBlendFactors(glSrcFactor: i32, glDstFactor: i32, glEquation: i32) void { pub fn rlSetBlendFactors(glSrcFactor: i32, glDstFactor: i32, glEquation: i32) void {
cdef.rlSetBlendFactors(@as(c_int, glSrcFactor), @as(c_int, glDstFactor), @as(c_int, glEquation)); cdef.rlSetBlendFactors(@as(c_int, glSrcFactor), @as(c_int, glDstFactor), @as(c_int, glEquation));
} }
/// Set blending mode factors and equations separately (using OpenGL factors)
pub fn rlSetBlendFactorsSeparate(glSrcRGB: i32, glDstRGB: i32, glSrcAlpha: i32, glDstAlpha: i32, glEqRGB: i32, glEqAlpha: i32) void { pub fn rlSetBlendFactorsSeparate(glSrcRGB: i32, glDstRGB: i32, glSrcAlpha: i32, glDstAlpha: i32, glEqRGB: i32, glEqAlpha: i32) void {
cdef.rlSetBlendFactorsSeparate(@as(c_int, glSrcRGB), @as(c_int, glDstRGB), @as(c_int, glSrcAlpha), @as(c_int, glDstAlpha), @as(c_int, glEqRGB), @as(c_int, glEqAlpha)); cdef.rlSetBlendFactorsSeparate(@as(c_int, glSrcRGB), @as(c_int, glDstRGB), @as(c_int, glSrcAlpha), @as(c_int, glDstAlpha), @as(c_int, glEqRGB), @as(c_int, glEqAlpha));
} }
/// Initialize rlgl (buffers, shaders, textures, states)
pub fn rlglInit(width: i32, height: i32) void { pub fn rlglInit(width: i32, height: i32) void {
cdef.rlglInit(@as(c_int, width), @as(c_int, height)); cdef.rlglInit(@as(c_int, width), @as(c_int, height));
} }
/// De-initialize rlgl (buffers, shaders, textures)
pub fn rlglClose() void { pub fn rlglClose() void {
cdef.rlglClose(); cdef.rlglClose();
} }
/// Load OpenGL extensions (loader function required)
pub fn rlLoadExtensions(loader: *anyopaque) void { pub fn rlLoadExtensions(loader: *anyopaque) void {
cdef.rlLoadExtensions(loader); cdef.rlLoadExtensions(loader);
} }
/// Get current OpenGL version
pub fn rlGetVersion() i32 { pub fn rlGetVersion() i32 {
return @as(i32, cdef.rlGetVersion()); return @as(i32, cdef.rlGetVersion());
} }
/// Set current framebuffer width
pub fn rlSetFramebufferWidth(width: i32) void { pub fn rlSetFramebufferWidth(width: i32) void {
cdef.rlSetFramebufferWidth(@as(c_int, width)); cdef.rlSetFramebufferWidth(@as(c_int, width));
} }
/// Get default framebuffer width
pub fn rlGetFramebufferWidth() i32 { pub fn rlGetFramebufferWidth() i32 {
return @as(i32, cdef.rlGetFramebufferWidth()); return @as(i32, cdef.rlGetFramebufferWidth());
} }
/// Set current framebuffer height
pub fn rlSetFramebufferHeight(height: i32) void { pub fn rlSetFramebufferHeight(height: i32) void {
cdef.rlSetFramebufferHeight(@as(c_int, height)); cdef.rlSetFramebufferHeight(@as(c_int, height));
} }
/// Get default framebuffer height
pub fn rlGetFramebufferHeight() i32 { pub fn rlGetFramebufferHeight() i32 {
return @as(i32, cdef.rlGetFramebufferHeight()); return @as(i32, cdef.rlGetFramebufferHeight());
} }
/// Get default texture id
pub fn rlGetTextureIdDefault() u32 { pub fn rlGetTextureIdDefault() u32 {
return @as(u32, cdef.rlGetTextureIdDefault()); return @as(u32, cdef.rlGetTextureIdDefault());
} }
/// Get default shader id
pub fn rlGetShaderIdDefault() u32 { pub fn rlGetShaderIdDefault() u32 {
return @as(u32, cdef.rlGetShaderIdDefault()); return @as(u32, cdef.rlGetShaderIdDefault());
} }
/// Load a render batch system
pub fn rlLoadRenderBatch(numBuffers: i32, bufferElements: i32) rlRenderBatch { pub fn rlLoadRenderBatch(numBuffers: i32, bufferElements: i32) rlRenderBatch {
return cdef.rlLoadRenderBatch(@as(c_int, numBuffers), @as(c_int, bufferElements)); return cdef.rlLoadRenderBatch(@as(c_int, numBuffers), @as(c_int, bufferElements));
} }
/// Unload render batch system
pub fn rlUnloadRenderBatch(batch: rlRenderBatch) void { pub fn rlUnloadRenderBatch(batch: rlRenderBatch) void {
cdef.rlUnloadRenderBatch(batch); cdef.rlUnloadRenderBatch(batch);
} }
/// Draw render batch data (Update->Draw->Reset)
pub fn rlDrawRenderBatch(batch: *rlRenderBatch) void { pub fn rlDrawRenderBatch(batch: *rlRenderBatch) void {
cdef.rlDrawRenderBatch(@as([*c]rlRenderBatch, @ptrCast(batch))); cdef.rlDrawRenderBatch(@as([*c]rlRenderBatch, @ptrCast(batch)));
} }
/// Set the active render batch for rlgl (NULL for default internal)
pub fn rlSetRenderBatchActive(batch: *rlRenderBatch) void { pub fn rlSetRenderBatchActive(batch: *rlRenderBatch) void {
cdef.rlSetRenderBatchActive(@as([*c]rlRenderBatch, @ptrCast(batch))); cdef.rlSetRenderBatchActive(@as([*c]rlRenderBatch, @ptrCast(batch)));
} }
/// Update and draw internal render batch
pub fn rlDrawRenderBatchActive() void { pub fn rlDrawRenderBatchActive() void {
cdef.rlDrawRenderBatchActive(); cdef.rlDrawRenderBatchActive();
} }
/// Check internal buffer overflow for a given number of vertex
pub fn rlCheckRenderBatchLimit(vCount: i32) bool { pub fn rlCheckRenderBatchLimit(vCount: i32) bool {
return cdef.rlCheckRenderBatchLimit(@as(c_int, vCount)); return cdef.rlCheckRenderBatchLimit(@as(c_int, vCount));
} }
/// Set current texture for render batch and check buffers limits
pub fn rlSetTexture(id: u32) void { pub fn rlSetTexture(id: u32) void {
cdef.rlSetTexture(@as(c_uint, id)); cdef.rlSetTexture(@as(c_uint, id));
} }
/// Load vertex array (vao) if supported
pub fn rlLoadVertexArray() u32 { pub fn rlLoadVertexArray() u32 {
return @as(u32, cdef.rlLoadVertexArray()); return @as(u32, cdef.rlLoadVertexArray());
} }
/// Load a vertex buffer object
pub fn rlLoadVertexBuffer(buffer: *const anyopaque, size: i32, dynamic: bool) u32 { pub fn rlLoadVertexBuffer(buffer: *const anyopaque, size: i32, dynamic: bool) u32 {
return @as(u32, cdef.rlLoadVertexBuffer(buffer, @as(c_int, size), dynamic)); return @as(u32, cdef.rlLoadVertexBuffer(buffer, @as(c_int, size), dynamic));
} }
/// Load vertex buffer elements object
pub fn rlLoadVertexBufferElement(buffer: *const anyopaque, size: i32, dynamic: bool) u32 { pub fn rlLoadVertexBufferElement(buffer: *const anyopaque, size: i32, dynamic: bool) u32 {
return @as(u32, cdef.rlLoadVertexBufferElement(buffer, @as(c_int, size), dynamic)); return @as(u32, cdef.rlLoadVertexBufferElement(buffer, @as(c_int, size), dynamic));
} }
/// Update vertex buffer object data on GPU buffer
pub fn rlUpdateVertexBuffer(bufferId: u32, data: *const anyopaque, dataSize: i32, offset: i32) void { pub fn rlUpdateVertexBuffer(bufferId: u32, data: *const anyopaque, dataSize: i32, offset: i32) void {
cdef.rlUpdateVertexBuffer(@as(c_uint, bufferId), data, @as(c_int, dataSize), @as(c_int, offset)); cdef.rlUpdateVertexBuffer(@as(c_uint, bufferId), data, @as(c_int, dataSize), @as(c_int, offset));
} }
/// Update vertex buffer elements data on GPU buffer
pub fn rlUpdateVertexBufferElements(id: u32, data: *const anyopaque, dataSize: i32, offset: i32) void { pub fn rlUpdateVertexBufferElements(id: u32, data: *const anyopaque, dataSize: i32, offset: i32) void {
cdef.rlUpdateVertexBufferElements(@as(c_uint, id), data, @as(c_int, dataSize), @as(c_int, offset)); cdef.rlUpdateVertexBufferElements(@as(c_uint, id), data, @as(c_int, dataSize), @as(c_int, offset));
} }
/// Unload vertex array (vao)
pub fn rlUnloadVertexArray(vaoId: u32) void { pub fn rlUnloadVertexArray(vaoId: u32) void {
cdef.rlUnloadVertexArray(@as(c_uint, vaoId)); cdef.rlUnloadVertexArray(@as(c_uint, vaoId));
} }
/// Unload vertex buffer object
pub fn rlUnloadVertexBuffer(vboId: u32) void { pub fn rlUnloadVertexBuffer(vboId: u32) void {
cdef.rlUnloadVertexBuffer(@as(c_uint, vboId)); cdef.rlUnloadVertexBuffer(@as(c_uint, vboId));
} }
/// Set vertex attribute data configuration
pub fn rlSetVertexAttribute(index: u32, compSize: i32, ty: i32, normalized: bool, stride: i32, offset: i32) void { pub fn rlSetVertexAttribute(index: u32, compSize: i32, ty: i32, normalized: bool, stride: i32, offset: i32) void {
cdef.rlSetVertexAttribute(@as(c_uint, index), @as(c_int, compSize), @as(c_int, ty), normalized, @as(c_int, stride), @as(c_int, offset)); cdef.rlSetVertexAttribute(@as(c_uint, index), @as(c_int, compSize), @as(c_int, ty), normalized, @as(c_int, stride), @as(c_int, offset));
} }
/// Set vertex attribute data divisor
pub fn rlSetVertexAttributeDivisor(index: u32, divisor: i32) void { pub fn rlSetVertexAttributeDivisor(index: u32, divisor: i32) void {
cdef.rlSetVertexAttributeDivisor(@as(c_uint, index), @as(c_int, divisor)); cdef.rlSetVertexAttributeDivisor(@as(c_uint, index), @as(c_int, divisor));
} }
/// Set vertex attribute default value, when attribute to provided
pub fn rlSetVertexAttributeDefault(locIndex: i32, value: *const anyopaque, attribType: i32, count: i32) void { pub fn rlSetVertexAttributeDefault(locIndex: i32, value: *const anyopaque, attribType: i32, count: i32) void {
cdef.rlSetVertexAttributeDefault(@as(c_int, locIndex), value, @as(c_int, attribType), @as(c_int, count)); cdef.rlSetVertexAttributeDefault(@as(c_int, locIndex), value, @as(c_int, attribType), @as(c_int, count));
} }
/// Draw vertex array (currently active vao)
pub fn rlDrawVertexArray(offset: i32, count: i32) void { pub fn rlDrawVertexArray(offset: i32, count: i32) void {
cdef.rlDrawVertexArray(@as(c_int, offset), @as(c_int, count)); cdef.rlDrawVertexArray(@as(c_int, offset), @as(c_int, count));
} }
/// Draw vertex array elements
pub fn rlDrawVertexArrayElements(offset: i32, count: i32, buffer: ?*const anyopaque) void { pub fn rlDrawVertexArrayElements(offset: i32, count: i32, buffer: ?*const anyopaque) void {
cdef.rlDrawVertexArrayElements(@as(c_int, offset), @as(c_int, count), buffer); cdef.rlDrawVertexArrayElements(@as(c_int, offset), @as(c_int, count), buffer);
} }
/// Draw vertex array (currently active vao) with instancing
pub fn rlDrawVertexArrayInstanced(offset: i32, count: i32, instances: i32) void { pub fn rlDrawVertexArrayInstanced(offset: i32, count: i32, instances: i32) void {
cdef.rlDrawVertexArrayInstanced(@as(c_int, offset), @as(c_int, count), @as(c_int, instances)); cdef.rlDrawVertexArrayInstanced(@as(c_int, offset), @as(c_int, count), @as(c_int, instances));
} }
/// Draw vertex array elements with instancing
pub fn rlDrawVertexArrayElementsInstanced(offset: i32, count: i32, buffer: ?*const anyopaque, instances: i32) void { pub fn rlDrawVertexArrayElementsInstanced(offset: i32, count: i32, buffer: ?*const anyopaque, instances: i32) void {
cdef.rlDrawVertexArrayElementsInstanced(@as(c_int, offset), @as(c_int, count), buffer, @as(c_int, instances)); cdef.rlDrawVertexArrayElementsInstanced(@as(c_int, offset), @as(c_int, count), buffer, @as(c_int, instances));
} }
/// Load texture data
pub fn rlLoadTexture(data: *const anyopaque, width: i32, height: i32, format: i32, mipmapCount: i32) u32 { pub fn rlLoadTexture(data: *const anyopaque, width: i32, height: i32, format: i32, mipmapCount: i32) u32 {
return @as(u32, cdef.rlLoadTexture(data, @as(c_int, width), @as(c_int, height), @as(c_int, format), @as(c_int, mipmapCount))); return @as(u32, cdef.rlLoadTexture(data, @as(c_int, width), @as(c_int, height), @as(c_int, format), @as(c_int, mipmapCount)));
} }
/// Load depth texture/renderbuffer (to be attached to fbo)
pub fn rlLoadTextureDepth(width: i32, height: i32, useRenderBuffer: bool) u32 { pub fn rlLoadTextureDepth(width: i32, height: i32, useRenderBuffer: bool) u32 {
return @as(u32, cdef.rlLoadTextureDepth(@as(c_int, width), @as(c_int, height), useRenderBuffer)); return @as(u32, cdef.rlLoadTextureDepth(@as(c_int, width), @as(c_int, height), useRenderBuffer));
} }
/// Load texture cubemap data
pub fn rlLoadTextureCubemap(data: *const anyopaque, size: i32, format: i32) u32 { pub fn rlLoadTextureCubemap(data: *const anyopaque, size: i32, format: i32) u32 {
return @as(u32, cdef.rlLoadTextureCubemap(data, @as(c_int, size), @as(c_int, format))); return @as(u32, cdef.rlLoadTextureCubemap(data, @as(c_int, size), @as(c_int, format)));
} }
/// Update texture with new data on GPU
pub fn rlUpdateTexture(id: u32, offsetX: i32, offsetY: i32, width: i32, height: i32, format: i32, data: *const anyopaque) void { pub fn rlUpdateTexture(id: u32, offsetX: i32, offsetY: i32, width: i32, height: i32, format: i32, data: *const anyopaque) void {
cdef.rlUpdateTexture(@as(c_uint, id), @as(c_int, offsetX), @as(c_int, offsetY), @as(c_int, width), @as(c_int, height), @as(c_int, format), data); cdef.rlUpdateTexture(@as(c_uint, id), @as(c_int, offsetX), @as(c_int, offsetY), @as(c_int, width), @as(c_int, height), @as(c_int, format), data);
} }
/// Get OpenGL internal formats
pub fn rlGetGlTextureFormats(format: i32, glInternalFormat: *u32, glFormat: *u32, glType: *u32) void { pub fn rlGetGlTextureFormats(format: i32, glInternalFormat: *u32, glFormat: *u32, glType: *u32) void {
cdef.rlGetGlTextureFormats(@as(c_int, format), @as([*c]c_uint, @ptrCast(glInternalFormat)), @as([*c]c_uint, @ptrCast(glFormat)), @as([*c]c_uint, @ptrCast(glType))); cdef.rlGetGlTextureFormats(@as(c_int, format), @as([*c]c_uint, @ptrCast(glInternalFormat)), @as([*c]c_uint, @ptrCast(glFormat)), @as([*c]c_uint, @ptrCast(glType)));
} }
/// Get name string for pixel format
pub fn rlGetPixelFormatName(format: u32) [:0]const u8 { pub fn rlGetPixelFormatName(format: u32) [:0]const u8 {
return std.mem.span(cdef.rlGetPixelFormatName(@as(c_uint, format))); return std.mem.span(cdef.rlGetPixelFormatName(@as(c_uint, format)));
} }
/// Unload texture from GPU memory
pub fn rlUnloadTexture(id: u32) void { pub fn rlUnloadTexture(id: u32) void {
cdef.rlUnloadTexture(@as(c_uint, id)); cdef.rlUnloadTexture(@as(c_uint, id));
} }
/// Generate mipmap data for selected texture
pub fn rlGenTextureMipmaps(id: u32, width: i32, height: i32, format: i32, mipmaps: *i32) void { pub fn rlGenTextureMipmaps(id: u32, width: i32, height: i32, format: i32, mipmaps: *i32) void {
cdef.rlGenTextureMipmaps(@as(c_uint, id), @as(c_int, width), @as(c_int, height), @as(c_int, format), @as([*c]c_int, @ptrCast(mipmaps))); cdef.rlGenTextureMipmaps(@as(c_uint, id), @as(c_int, width), @as(c_int, height), @as(c_int, format), @as([*c]c_int, @ptrCast(mipmaps)));
} }
/// Read texture pixel data
pub fn rlReadTexturePixels(id: u32, width: i32, height: i32, format: i32) *anyopaque { pub fn rlReadTexturePixels(id: u32, width: i32, height: i32, format: i32) *anyopaque {
return cdef.rlReadTexturePixels(@as(c_uint, id), @as(c_int, width), @as(c_int, height), @as(c_int, format)); return cdef.rlReadTexturePixels(@as(c_uint, id), @as(c_int, width), @as(c_int, height), @as(c_int, format));
} }
/// Read screen pixel data (color buffer)
pub fn rlReadScreenPixels(width: i32, height: i32) [:0]u8 { pub fn rlReadScreenPixels(width: i32, height: i32) [:0]u8 {
return std.mem.span(cdef.rlReadScreenPixels(@as(c_int, width), @as(c_int, height))); return std.mem.span(cdef.rlReadScreenPixels(@as(c_int, width), @as(c_int, height)));
} }
/// Load an empty framebuffer
pub fn rlLoadFramebuffer() u32 { pub fn rlLoadFramebuffer() u32 {
return @as(u32, cdef.rlLoadFramebuffer()); return @as(u32, cdef.rlLoadFramebuffer());
} }
/// Attach texture/renderbuffer to a framebuffer
pub fn rlFramebufferAttach(fboId: u32, texId: u32, attachType: i32, texType: i32, mipLevel: i32) void { pub fn rlFramebufferAttach(fboId: u32, texId: u32, attachType: i32, texType: i32, mipLevel: i32) void {
cdef.rlFramebufferAttach(@as(c_uint, fboId), @as(c_uint, texId), @as(c_int, attachType), @as(c_int, texType), @as(c_int, mipLevel)); cdef.rlFramebufferAttach(@as(c_uint, fboId), @as(c_uint, texId), @as(c_int, attachType), @as(c_int, texType), @as(c_int, mipLevel));
} }
/// Verify framebuffer is complete
pub fn rlFramebufferComplete(id: u32) bool { pub fn rlFramebufferComplete(id: u32) bool {
return cdef.rlFramebufferComplete(@as(c_uint, id)); return cdef.rlFramebufferComplete(@as(c_uint, id));
} }
/// Delete framebuffer from GPU
pub fn rlUnloadFramebuffer(id: u32) void { pub fn rlUnloadFramebuffer(id: u32) void {
cdef.rlUnloadFramebuffer(@as(c_uint, id)); cdef.rlUnloadFramebuffer(@as(c_uint, id));
} }
/// Load shader from code strings
pub fn rlLoadShaderCode(vsCode: [:0]const u8, fsCode: [:0]const u8) u32 { pub fn rlLoadShaderCode(vsCode: [:0]const u8, fsCode: [:0]const u8) u32 {
return @as(u32, cdef.rlLoadShaderCode(@as([*c]const u8, @ptrCast(vsCode)), @as([*c]const u8, @ptrCast(fsCode)))); return @as(u32, cdef.rlLoadShaderCode(@as([*c]const u8, @ptrCast(vsCode)), @as([*c]const u8, @ptrCast(fsCode))));
} }
/// Compile custom shader and return shader id (type: RL_VERTEX_SHADER, RL_FRAGMENT_SHADER, RL_COMPUTE_SHADER)
pub fn rlCompileShader(shaderCode: [:0]const u8, ty: i32) u32 { pub fn rlCompileShader(shaderCode: [:0]const u8, ty: i32) u32 {
return @as(u32, cdef.rlCompileShader(@as([*c]const u8, @ptrCast(shaderCode)), @as(c_int, ty))); return @as(u32, cdef.rlCompileShader(@as([*c]const u8, @ptrCast(shaderCode)), @as(c_int, ty)));
} }
/// Load custom shader program
pub fn rlLoadShaderProgram(vShaderId: u32, fShaderId: u32) u32 { pub fn rlLoadShaderProgram(vShaderId: u32, fShaderId: u32) u32 {
return @as(u32, cdef.rlLoadShaderProgram(@as(c_uint, vShaderId), @as(c_uint, fShaderId))); return @as(u32, cdef.rlLoadShaderProgram(@as(c_uint, vShaderId), @as(c_uint, fShaderId)));
} }
/// Unload shader program
pub fn rlUnloadShaderProgram(id: u32) void { pub fn rlUnloadShaderProgram(id: u32) void {
cdef.rlUnloadShaderProgram(@as(c_uint, id)); cdef.rlUnloadShaderProgram(@as(c_uint, id));
} }
/// Get shader location uniform
pub fn rlGetLocationUniform(shaderId: u32, uniformName: [:0]const u8) i32 { pub fn rlGetLocationUniform(shaderId: u32, uniformName: [:0]const u8) i32 {
return @as(i32, cdef.rlGetLocationUniform(@as(c_uint, shaderId), @as([*c]const u8, @ptrCast(uniformName)))); return @as(i32, cdef.rlGetLocationUniform(@as(c_uint, shaderId), @as([*c]const u8, @ptrCast(uniformName))));
} }
/// Get shader location attribute
pub fn rlGetLocationAttrib(shaderId: u32, attribName: [:0]const u8) i32 { pub fn rlGetLocationAttrib(shaderId: u32, attribName: [:0]const u8) i32 {
return @as(i32, cdef.rlGetLocationAttrib(@as(c_uint, shaderId), @as([*c]const u8, @ptrCast(attribName)))); return @as(i32, cdef.rlGetLocationAttrib(@as(c_uint, shaderId), @as([*c]const u8, @ptrCast(attribName))));
} }
/// Set shader value uniform
pub fn rlSetUniform(locIndex: i32, value: *const anyopaque, uniformType: i32, count: i32) void { pub fn rlSetUniform(locIndex: i32, value: *const anyopaque, uniformType: i32, count: i32) void {
cdef.rlSetUniform(@as(c_int, locIndex), value, @as(c_int, uniformType), @as(c_int, count)); cdef.rlSetUniform(@as(c_int, locIndex), value, @as(c_int, uniformType), @as(c_int, count));
} }
/// Set shader value matrix
pub fn rlSetUniformMatrix(locIndex: i32, mat: Matrix) void { pub fn rlSetUniformMatrix(locIndex: i32, mat: Matrix) void {
cdef.rlSetUniformMatrix(@as(c_int, locIndex), mat); cdef.rlSetUniformMatrix(@as(c_int, locIndex), mat);
} }
/// Set shader value sampler
pub fn rlSetUniformSampler(locIndex: i32, textureId: u32) void { pub fn rlSetUniformSampler(locIndex: i32, textureId: u32) void {
cdef.rlSetUniformSampler(@as(c_int, locIndex), @as(c_uint, textureId)); cdef.rlSetUniformSampler(@as(c_int, locIndex), @as(c_uint, textureId));
} }
/// Set shader currently active (id and locations)
pub fn rlSetShader(id: u32, locs: []i32) void { pub fn rlSetShader(id: u32, locs: []i32) void {
cdef.rlSetShader(@as(c_uint, id), @as([*c]c_int, @ptrCast(locs))); cdef.rlSetShader(@as(c_uint, id), @as([*c]c_int, @ptrCast(locs)));
} }
/// Load compute shader program
pub fn rlLoadComputeShaderProgram(shaderId: u32) u32 { pub fn rlLoadComputeShaderProgram(shaderId: u32) u32 {
return @as(u32, cdef.rlLoadComputeShaderProgram(@as(c_uint, shaderId))); return @as(u32, cdef.rlLoadComputeShaderProgram(@as(c_uint, shaderId)));
} }
/// Dispatch compute shader (equivalent to *draw* for graphics pipeline)
pub fn rlComputeShaderDispatch(groupX: u32, groupY: u32, groupZ: u32) void { pub fn rlComputeShaderDispatch(groupX: u32, groupY: u32, groupZ: u32) void {
cdef.rlComputeShaderDispatch(@as(c_uint, groupX), @as(c_uint, groupY), @as(c_uint, groupZ)); cdef.rlComputeShaderDispatch(@as(c_uint, groupX), @as(c_uint, groupY), @as(c_uint, groupZ));
} }
/// Load shader storage buffer object (SSBO)
pub fn rlLoadShaderBuffer(size: u32, data: *const anyopaque, usageHint: i32) u32 { pub fn rlLoadShaderBuffer(size: u32, data: *const anyopaque, usageHint: i32) u32 {
return @as(u32, cdef.rlLoadShaderBuffer(@as(c_uint, size), data, @as(c_int, usageHint))); return @as(u32, cdef.rlLoadShaderBuffer(@as(c_uint, size), data, @as(c_int, usageHint)));
} }
/// Unload shader storage buffer object (SSBO)
pub fn rlUnloadShaderBuffer(ssboId: u32) void { pub fn rlUnloadShaderBuffer(ssboId: u32) void {
cdef.rlUnloadShaderBuffer(@as(c_uint, ssboId)); cdef.rlUnloadShaderBuffer(@as(c_uint, ssboId));
} }
/// Update SSBO buffer data
pub fn rlUpdateShaderBuffer(id: u32, data: *const anyopaque, dataSize: u32, offset: u32) void { pub fn rlUpdateShaderBuffer(id: u32, data: *const anyopaque, dataSize: u32, offset: u32) void {
cdef.rlUpdateShaderBuffer(@as(c_uint, id), data, @as(c_uint, dataSize), @as(c_uint, offset)); cdef.rlUpdateShaderBuffer(@as(c_uint, id), data, @as(c_uint, dataSize), @as(c_uint, offset));
} }
/// Bind SSBO buffer
pub fn rlBindShaderBuffer(id: u32, index: u32) void { pub fn rlBindShaderBuffer(id: u32, index: u32) void {
cdef.rlBindShaderBuffer(@as(c_uint, id), @as(c_uint, index)); cdef.rlBindShaderBuffer(@as(c_uint, id), @as(c_uint, index));
} }
/// Read SSBO buffer data (GPU->CPU)
pub fn rlReadShaderBuffer(id: u32, dest: *anyopaque, count: u32, offset: u32) void { pub fn rlReadShaderBuffer(id: u32, dest: *anyopaque, count: u32, offset: u32) void {
cdef.rlReadShaderBuffer(@as(c_uint, id), dest, @as(c_uint, count), @as(c_uint, offset)); cdef.rlReadShaderBuffer(@as(c_uint, id), dest, @as(c_uint, count), @as(c_uint, offset));
} }
/// Copy SSBO data between buffers
pub fn rlCopyShaderBuffer(destId: u32, srcId: u32, destOffset: u32, srcOffset: u32, count: u32) void { pub fn rlCopyShaderBuffer(destId: u32, srcId: u32, destOffset: u32, srcOffset: u32, count: u32) void {
cdef.rlCopyShaderBuffer(@as(c_uint, destId), @as(c_uint, srcId), @as(c_uint, destOffset), @as(c_uint, srcOffset), @as(c_uint, count)); cdef.rlCopyShaderBuffer(@as(c_uint, destId), @as(c_uint, srcId), @as(c_uint, destOffset), @as(c_uint, srcOffset), @as(c_uint, count));
} }
/// Get SSBO buffer size
pub fn rlGetShaderBufferSize(id: u32) u32 { pub fn rlGetShaderBufferSize(id: u32) u32 {
return @as(u32, cdef.rlGetShaderBufferSize(@as(c_uint, id))); return @as(u32, cdef.rlGetShaderBufferSize(@as(c_uint, id)));
} }
/// Bind image texture
pub fn rlBindImageTexture(id: u32, index: u32, format: i32, readonly: bool) void { pub fn rlBindImageTexture(id: u32, index: u32, format: i32, readonly: bool) void {
cdef.rlBindImageTexture(@as(c_uint, id), @as(c_uint, index), @as(c_int, format), readonly); cdef.rlBindImageTexture(@as(c_uint, id), @as(c_uint, index), @as(c_int, format), readonly);
} }
/// Get internal modelview matrix
pub fn rlGetMatrixModelview() Matrix { pub fn rlGetMatrixModelview() Matrix {
return cdef.rlGetMatrixModelview(); return cdef.rlGetMatrixModelview();
} }
/// Get internal projection matrix
pub fn rlGetMatrixProjection() Matrix { pub fn rlGetMatrixProjection() Matrix {
return cdef.rlGetMatrixProjection(); return cdef.rlGetMatrixProjection();
} }
/// Get internal accumulated transform matrix
pub fn rlGetMatrixTransform() Matrix { pub fn rlGetMatrixTransform() Matrix {
return cdef.rlGetMatrixTransform(); return cdef.rlGetMatrixTransform();
} }
/// Get internal projection matrix for stereo render (selected eye)
pub fn rlGetMatrixProjectionStereo(eye: i32) Matrix { pub fn rlGetMatrixProjectionStereo(eye: i32) Matrix {
return cdef.rlGetMatrixProjectionStereo(@as(c_int, eye)); return cdef.rlGetMatrixProjectionStereo(@as(c_int, eye));
} }
/// Get internal view offset matrix for stereo render (selected eye)
pub fn rlGetMatrixViewOffsetStereo(eye: i32) Matrix { pub fn rlGetMatrixViewOffsetStereo(eye: i32) Matrix {
return cdef.rlGetMatrixViewOffsetStereo(@as(c_int, eye)); return cdef.rlGetMatrixViewOffsetStereo(@as(c_int, eye));
} }
/// Set a custom projection matrix (replaces internal projection matrix)
pub fn rlSetMatrixProjection(proj: Matrix) void { pub fn rlSetMatrixProjection(proj: Matrix) void {
cdef.rlSetMatrixProjection(proj); cdef.rlSetMatrixProjection(proj);
} }
/// Set a custom modelview matrix (replaces internal modelview matrix)
pub fn rlSetMatrixModelview(view: Matrix) void { pub fn rlSetMatrixModelview(view: Matrix) void {
cdef.rlSetMatrixModelview(view); cdef.rlSetMatrixModelview(view);
} }
/// Set eyes projection matrices for stereo rendering
pub fn rlSetMatrixProjectionStereo(right: Matrix, left: Matrix) void { pub fn rlSetMatrixProjectionStereo(right: Matrix, left: Matrix) void {
cdef.rlSetMatrixProjectionStereo(right, left); cdef.rlSetMatrixProjectionStereo(right, left);
} }
/// Set eyes view offsets matrices for stereo rendering
pub fn rlSetMatrixViewOffsetStereo(right: Matrix, left: Matrix) void { pub fn rlSetMatrixViewOffsetStereo(right: Matrix, left: Matrix) void {
cdef.rlSetMatrixViewOffsetStereo(right, left); cdef.rlSetMatrixViewOffsetStereo(right, left);
} }
/// Load and draw a cube
pub fn rlLoadDrawCube() void { pub fn rlLoadDrawCube() void {
cdef.rlLoadDrawCube(); cdef.rlLoadDrawCube();
} }
/// Load and draw a quad
pub fn rlLoadDrawQuad() void { pub fn rlLoadDrawQuad() void {
cdef.rlLoadDrawQuad(); cdef.rlLoadDrawQuad();
} }